diff --git a/.github/workflows/cpp_format.yml b/.github/workflows/cpp_format.yml new file mode 100644 index 000000000..6370e9848 --- /dev/null +++ b/.github/workflows/cpp_format.yml @@ -0,0 +1,26 @@ +name: cpp-linter +on: + pull_request: + branches: [main] + paths: ['**.c', '**.cpp', '**.h', '**.hpp', '**.cxx', '**.hxx', '**.cc', '**.hh', '*.mm', '**CMakeLists.txt', '**.cmake'] + push: + branches: [main] + paths: ['**.c', '**.cpp', '**.h', '**.hpp', '**.cxx', '**.hxx', '**.cc', '**.hh', '*.mm', '**CMakeLists.txt', '**.cmake'] +jobs: + cpp-linter: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: 'file' # Use .clang-format config file. + tidy-checks: '-*' # disable clang-tidy checks. + step-summary: true + format-review: true + + - name: Fail fast?! + if: steps.linter.outputs.clang-format-checks-failed > 0 + run: exit 1 diff --git a/shadercompiler/ASTNode.cpp b/shadercompiler/ASTNode.cpp index 9d6dca79f..2f463f593 100644 --- a/shadercompiler/ASTNode.cpp +++ b/shadercompiler/ASTNode.cpp @@ -5,15 +5,15 @@ #include "HLSLParser.h" #include "ParserUtils.h" -ASTNode::ASTNode( ASTNodeType type, const FileLocation& location, ScopeSymbolTable* scope, const ScannerToken* token ) - :m_nodeType( type ), +ASTNode::ASTNode( ASTNodeType type, const FileLocation& location, ScopeSymbolTable* scope, const ScannerToken* token ) : + m_nodeType( type ), m_symbol( nullptr ), m_location( location ), - m_scope( scope ) + m_scope( scope ) { m_type.FromTokenType( 0 ); if( token ) - { + { m_token = *token; } else @@ -66,11 +66,11 @@ void ASTNode::ReplaceChild( size_t place, ASTNode* child ) void ASTNode::ReplaceChild( ASTNode* old, ASTNode* child ) { - auto found = find( begin( m_children ), end( m_children ), old ); - if( found != end( m_children ) ) - { - *found = child; - } + auto found = find( begin( m_children ), end( m_children ), old ); + if( found != end( m_children ) ) + { + *found = child; + } } void ASTNode::RemoveChild( size_t place ) @@ -150,7 +150,7 @@ const ScannerToken* ASTNode::GetToken() const } } -void ASTNode::SetToken(const ScannerToken& token) +void ASTNode::SetToken( const ScannerToken& token ) { m_token = token; } diff --git a/shadercompiler/ASTNode.h b/shadercompiler/ASTNode.h index f5e633c06..3b52de813 100644 --- a/shadercompiler/ASTNode.h +++ b/shadercompiler/ASTNode.h @@ -114,7 +114,7 @@ class ASTNode void AddChild( ASTNode* child ); void InsertChild( size_t place, ASTNode* child ); void ReplaceChild( size_t place, ASTNode* child ); - void ReplaceChild( ASTNode* old, ASTNode* child ); + void ReplaceChild( ASTNode* old, ASTNode* child ); void RemoveChild( size_t place ); void RemoveChild( ASTNode* child ); @@ -147,7 +147,7 @@ class ASTNode void FindNodes( ASTNodeType type, std::vector& nodes ); template - ASTNode* Map( T callback ) + ASTNode* Map( T callback ) { ASTNode* newNode = callback( this ); for( size_t i = 0; i < newNode->m_children.size(); ++i ) @@ -161,7 +161,7 @@ class ASTNode } private: - ASTNodeType m_nodeType; + ASTNodeType m_nodeType; ScannerToken m_token; Symbol* m_symbol; Type m_type; diff --git a/shadercompiler/CachingIncludeHandler.cpp b/shadercompiler/CachingIncludeHandler.cpp index 9f5b7869b..7f2150290 100644 --- a/shadercompiler/CachingIncludeHandler.cpp +++ b/shadercompiler/CachingIncludeHandler.cpp @@ -12,10 +12,10 @@ // TODO MACOS: This function is just a stub. Make sure it covers all cases. namespace { - BOOL PathIsRelative( LPCSTR pszPath ) - { - return pszPath[0] != '/'; - } +BOOL PathIsRelative( LPCSTR pszPath ) +{ + return pszPath[0] != '/'; +} } #endif @@ -201,7 +201,7 @@ std::optional CachingIncludeHandler::AddPre return std::nullopt; } - auto &info = fileFromPath->second; + auto& info = fileFromPath->second; auto length = strlen( prefix ); auto data = malloc( info.size + length + 2 ); if( data == NULL ) diff --git a/shadercompiler/CachingIncludeHandler.h b/shadercompiler/CachingIncludeHandler.h index 827e7db75..48672b78d 100644 --- a/shadercompiler/CachingIncludeHandler.h +++ b/shadercompiler/CachingIncludeHandler.h @@ -4,9 +4,9 @@ // -------------------------------------------------------------------------------------- // Description: -// CachingIncludeHandler is an include handler for D3D effect compiler. It caches -// contents of included files, so the next time they are requested it returns cached -// contents. This object can be accessed from different threads. +// CachingIncludeHandler is an include handler for D3D effect compiler. It caches +// contents of included files, so the next time they are requested it returns cached +// contents. This object can be accessed from different threads. // -------------------------------------------------------------------------------------- class CachingIncludeHandler { @@ -27,6 +27,7 @@ class CachingIncludeHandler void SetRootPath( const char* shaderPath ); std::optional AddPrefix( const char* fileName, const char* prefix ); + private: typedef std::map PathFromFile; typedef std::map FileFromPath; diff --git a/shadercompiler/CompileMessageQueue.cpp b/shadercompiler/CompileMessageQueue.cpp index 003554b01..10ff47c82 100644 --- a/shadercompiler/CompileMessageQueue.cpp +++ b/shadercompiler/CompileMessageQueue.cpp @@ -4,8 +4,8 @@ #include "CompileMessageQueue.h" -CompileMessageQueue::CompileMessageQueue() - :m_stop( false ) +CompileMessageQueue::CompileMessageQueue() : + m_stop( false ) { m_thread = std::thread( [this] { this->Run(); } ); } @@ -33,7 +33,7 @@ void CompileMessageQueue::AddMessages( IDxcBlobEncoding* blob ) if( size > 0 ) { m_messagesMutex.lock(); - m_messages.push( reinterpret_cast(blob->GetBufferPointer()) ); + m_messages.push( reinterpret_cast( blob->GetBufferPointer() ) ); m_messagesMutex.unlock(); m_queueEvent.notify_one(); } @@ -49,7 +49,7 @@ void CompileMessageQueue::AddMessage( const char* format, ... ) va_end( args ); std::string message; - message.resize(count); + message.resize( count ); va_start( args, format ); count = vsnprintf( &message[0], message.size(), format, args ); @@ -140,12 +140,12 @@ void CompileMessageQueue::OutputMessages( const char* messages, size_t length ) const char* end = messages + 1; while( *start && start - messages < ptrdiff_t( length ) ) { - if( *end == 0 || end - messages >= ptrdiff_t( length ) || (end[0] == '\n' && (end - messages + 1 >= ptrdiff_t( length ) || !isspace( end[1] ))) ) + if( *end == 0 || end - messages >= ptrdiff_t( length ) || ( end[0] == '\n' && ( end - messages + 1 >= ptrdiff_t( length ) || !isspace( end[1] ) ) ) ) { std::string message( start, end ); if( m_printedMessages.insert( message ).second ) { - const char* memoryRefs[] = { "\\memory(", "/memory(", "/memory:", "memory:"}; + const char* memoryRefs[] = { "\\memory(", "/memory(", "/memory:", "memory:" }; for( auto memoryRef : memoryRefs ) { auto pos = message.find( memoryRef ); diff --git a/shadercompiler/CompileMessageQueue.h b/shadercompiler/CompileMessageQueue.h index 8b2189c0d..ca3261181 100644 --- a/shadercompiler/CompileMessageQueue.h +++ b/shadercompiler/CompileMessageQueue.h @@ -20,7 +20,7 @@ class CompileMessageQueue void AddMessages( IDxcBlobEncoding* buffer ); // windows only? or is it also for mac #endif void AddMessage( const char* format, ... ); - + void Flush(); void SetEntryFileName( const char* fileName ); diff --git a/shadercompiler/DxReflection.cpp b/shadercompiler/DxReflection.cpp index 00e43fa3e..441af64e8 100644 --- a/shadercompiler/DxReflection.cpp +++ b/shadercompiler/DxReflection.cpp @@ -10,44 +10,44 @@ namespace DxReflection { - bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ) +bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ) +{ + switch( annotation.type ) { - switch( annotation.type ) + case OP_FLOAT: + case OP_HALF: + case OP_DOUBLE: + result.type = ANNOTATION_TYPE_FLOAT; + result.floatValue = float( ParseFloat( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); + return true; + + case OP_UINT: + case OP_INT: + result.type = ANNOTATION_TYPE_INT; + result.intValue = ParseNumber( annotation.value.stringValue.start, annotation.value.stringValue.end ); + return true; + + case OP_BOOL: + result.type = ANNOTATION_TYPE_BOOL; + result.intValue = annotation.value.intValue ? 1 : 0; + if( ToString( annotation.name ) == "Tr2sRGB" ) + { + isSRGB = result.intValue != 0; + } + else if( ToString( annotation.name ) == "AutoRegister" ) { - case OP_FLOAT: - case OP_HALF: - case OP_DOUBLE: - result.type = ANNOTATION_TYPE_FLOAT; - result.floatValue = float( ParseFloat( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); - return true; - - case OP_UINT: - case OP_INT: - result.type = ANNOTATION_TYPE_INT; - result.intValue = ParseNumber( annotation.value.stringValue.start, annotation.value.stringValue.end ); - return true; - - case OP_BOOL: - result.type = ANNOTATION_TYPE_BOOL; - result.intValue = annotation.value.intValue ? 1 : 0; - if( ToString( annotation.name ) == "Tr2sRGB" ) - { - isSRGB = result.intValue != 0; - } - else if( ToString( annotation.name ) == "AutoRegister" ) - { - isAutoregister = result.intValue != 0; - } - return true; - - case OP_STRING: - result.type = ANNOTATION_TYPE_STRING; - result.stringValue = g_stringTable.AddString( ParseString( annotation.value.stringValue ).c_str() ); - return true; + isAutoregister = result.intValue != 0; } + return true; - return false; + case OP_STRING: + result.type = ANNOTATION_TYPE_STRING; + result.stringValue = g_stringTable.AddString( ParseString( annotation.value.stringValue ).c_str() ); + return true; } + return false; +} + } #endif \ No newline at end of file diff --git a/shadercompiler/DxReflection.h b/shadercompiler/DxReflection.h index f49941d26..0489a294e 100644 --- a/shadercompiler/DxReflection.h +++ b/shadercompiler/DxReflection.h @@ -23,716 +23,712 @@ extern StateDescription g_samplerStates[]; namespace DxReflection { - template struct ArgType; +template +struct ArgType; - template - struct ArgType - { - static const size_t nargs = sizeof...(Args); +template +struct ArgType +{ + static const size_t nargs = sizeof...( Args ); - typedef R result_type; + typedef R result_type; - template - struct arg - { - typedef typename std::tuple_element>::type type; - }; + template + struct arg + { + typedef typename std::tuple_element>::type type; }; +}; - bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ); +bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ); - template - static bool GetTextureType( const T& desc, TextureType& type ) +template +static bool GetTextureType( const T& desc, TextureType& type ) +{ + switch( desc.Type ) { - switch( desc.Type ) + case D3D_SIT_TEXTURE: + type = TEX_TYPE_TYPELESS; + switch( desc.Dimension ) { - case D3D_SIT_TEXTURE: - type = TEX_TYPE_TYPELESS; - switch( desc.Dimension ) - { - case D3D10_SRV_DIMENSION_TEXTURE1D: - type = TEX_TYPE_1D; - break; - case D3D10_SRV_DIMENSION_TEXTURE2D: - type = TEX_TYPE_2D; - break; - case D3D10_SRV_DIMENSION_TEXTURE3D: - type = TEX_TYPE_3D; - break; - case D3D10_SRV_DIMENSION_TEXTURECUBE: - type = TEX_TYPE_CUBE; - break; - case D3D10_SRV_DIMENSION_BUFFER: - type = TEX_TYPE_BUFFER; - break; - } - break; - case D3D_SIT_TBUFFER: - type = TEX_TYPE_TBUFFER; + case D3D10_SRV_DIMENSION_TEXTURE1D: + type = TEX_TYPE_1D; break; - case D3D_SIT_STRUCTURED: - type = TEX_TYPE_STRUCTURED_BUFFER; + case D3D10_SRV_DIMENSION_TEXTURE2D: + type = TEX_TYPE_2D; break; - case D3D_SIT_BYTEADDRESS: - type = TEX_TYPE_BYTEADDRESS_BUFFER; + case D3D10_SRV_DIMENSION_TEXTURE3D: + type = TEX_TYPE_3D; break; - case D3D_SIT_UAV_RWTYPED: - type = TEX_TYPE_UAV_RWTYPED; - break; - case D3D_SIT_UAV_RWSTRUCTURED: - type = TEX_TYPE_UAV_RWSTRUCTURED; + case D3D10_SRV_DIMENSION_TEXTURECUBE: + type = TEX_TYPE_CUBE; break; - case D3D_SIT_UAV_RWBYTEADDRESS: - type = TEX_TYPE_UAV_RWBYTEADDRESS; - break; - case D3D_SIT_UAV_APPEND_STRUCTURED: - type = TEX_TYPE_UAV_APPEND_STRUCTURED; - break; - case D3D_SIT_UAV_CONSUME_STRUCTURED: - type = TEX_TYPE_UAV_CONSUME_STRUCTURED; + case D3D10_SRV_DIMENSION_BUFFER: + type = TEX_TYPE_BUFFER; break; - case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: - type = TEX_TYPE_UAV_RWSTRUCTURED_WITH_COUNTER; - break; - case 12: // D3D_SIT_RTACCELERATIONSTRUCTURE: - type = TEX_TYPE_RAYTRACING_ACCELERATION_STRUCTURE; - break; - default: - return false; } - return true; + break; + case D3D_SIT_TBUFFER: + type = TEX_TYPE_TBUFFER; + break; + case D3D_SIT_STRUCTURED: + type = TEX_TYPE_STRUCTURED_BUFFER; + break; + case D3D_SIT_BYTEADDRESS: + type = TEX_TYPE_BYTEADDRESS_BUFFER; + break; + case D3D_SIT_UAV_RWTYPED: + type = TEX_TYPE_UAV_RWTYPED; + break; + case D3D_SIT_UAV_RWSTRUCTURED: + type = TEX_TYPE_UAV_RWSTRUCTURED; + break; + case D3D_SIT_UAV_RWBYTEADDRESS: + type = TEX_TYPE_UAV_RWBYTEADDRESS; + break; + case D3D_SIT_UAV_APPEND_STRUCTURED: + type = TEX_TYPE_UAV_APPEND_STRUCTURED; + break; + case D3D_SIT_UAV_CONSUME_STRUCTURED: + type = TEX_TYPE_UAV_CONSUME_STRUCTURED; + break; + case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: + type = TEX_TYPE_UAV_RWSTRUCTURED_WITH_COUNTER; + break; + case 12: // D3D_SIT_RTACCELERATIONSTRUCTURE: + type = TEX_TYPE_RAYTRACING_ACCELERATION_STRUCTURE; + break; + default: + return false; } + return true; +} - template - RegisterInputType GetRegisterType( const T& desc ) +template +RegisterInputType GetRegisterType( const T& desc ) +{ + switch( desc.Type ) { - switch( desc.Type ) + case D3D_SIT_CBUFFER: + return RT_CONSTANT_BUFFER; + case D3D_SIT_TEXTURE: + switch( desc.Dimension ) { - case D3D_SIT_CBUFFER: - return RT_CONSTANT_BUFFER; - case D3D_SIT_TEXTURE: - switch( desc.Dimension ) - { - case D3D_SRV_DIMENSION_TEXTURE1D: - return RT_SRV_TEXTURE1D; - case D3D_SRV_DIMENSION_TEXTURE1DARRAY: - return RT_SRV_TEXTURE1DARRAY; - case D3D_SRV_DIMENSION_TEXTURE2D: - return RT_SRV_TEXTURE2D; - case D3D_SRV_DIMENSION_TEXTURE2DARRAY: - return RT_SRV_TEXTURE2DARRAY; - case D3D_SRV_DIMENSION_TEXTURE2DMS: - return RT_SRV_TEXTURE2DMS; - case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: - return RT_SRV_TEXTURE2DMSARRAY; - case D3D_SRV_DIMENSION_TEXTURE3D: - return RT_SRV_TEXTURE3D; - case D3D_SRV_DIMENSION_TEXTURECUBE: - return RT_SRV_TEXTURECUBE; - case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: - return RT_SRV_TEXTURECUBEARRAY; - default: - return RT_SRV_BUFFER; - } - case D3D_SIT_SAMPLER: - return RT_SAMPLER; - case D3D_SIT_UAV_RWTYPED: - switch( desc.Dimension ) - { - case D3D_SRV_DIMENSION_TEXTURE1D: - return RT_UAV_TEXTURE1D; - case D3D_SRV_DIMENSION_TEXTURE1DARRAY: - return RT_UAV_TEXTURE1DARRAY; - case D3D_SRV_DIMENSION_TEXTURE2D: - return RT_UAV_TEXTURE2D; - case D3D_SRV_DIMENSION_TEXTURE2DARRAY: - return RT_UAV_TEXTURE2DARRAY; - case D3D_SRV_DIMENSION_TEXTURE2DMS: - return RT_UAV_TEXTURE2DMS; - case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: - return RT_UAV_TEXTURE2DMSARRAY; - case D3D_SRV_DIMENSION_TEXTURE3D: - return RT_UAV_TEXTURE3D; - case D3D_SRV_DIMENSION_TEXTURECUBE: - return RT_UAV_TEXTURECUBE; - case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: - return RT_UAV_TEXTURECUBEARRAY; - default: - return RT_UAV_BUFFER; - } - case D3D_SIT_STRUCTURED: - return RT_SRV_STRUCTURED_BUFFER; - case D3D_SIT_UAV_RWSTRUCTURED: - case D3D_SIT_UAV_APPEND_STRUCTURED: - case D3D_SIT_UAV_CONSUME_STRUCTURED: - case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: - return RT_UAV_STRUCTURED_BUFFER; - // D3D_SIT_TBUFFER??? - case D3D_SIT_BYTEADDRESS: - return RT_SRV_BUFFER; - case D3D_SIT_UAV_RWBYTEADDRESS: - return RT_UAV_BUFFER; + case D3D_SRV_DIMENSION_TEXTURE1D: + return RT_SRV_TEXTURE1D; + case D3D_SRV_DIMENSION_TEXTURE1DARRAY: + return RT_SRV_TEXTURE1DARRAY; + case D3D_SRV_DIMENSION_TEXTURE2D: + return RT_SRV_TEXTURE2D; + case D3D_SRV_DIMENSION_TEXTURE2DARRAY: + return RT_SRV_TEXTURE2DARRAY; + case D3D_SRV_DIMENSION_TEXTURE2DMS: + return RT_SRV_TEXTURE2DMS; + case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: + return RT_SRV_TEXTURE2DMSARRAY; + case D3D_SRV_DIMENSION_TEXTURE3D: + return RT_SRV_TEXTURE3D; + case D3D_SRV_DIMENSION_TEXTURECUBE: + return RT_SRV_TEXTURECUBE; + case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: + return RT_SRV_TEXTURECUBEARRAY; default: return RT_SRV_BUFFER; } + case D3D_SIT_SAMPLER: + return RT_SAMPLER; + case D3D_SIT_UAV_RWTYPED: + switch( desc.Dimension ) + { + case D3D_SRV_DIMENSION_TEXTURE1D: + return RT_UAV_TEXTURE1D; + case D3D_SRV_DIMENSION_TEXTURE1DARRAY: + return RT_UAV_TEXTURE1DARRAY; + case D3D_SRV_DIMENSION_TEXTURE2D: + return RT_UAV_TEXTURE2D; + case D3D_SRV_DIMENSION_TEXTURE2DARRAY: + return RT_UAV_TEXTURE2DARRAY; + case D3D_SRV_DIMENSION_TEXTURE2DMS: + return RT_UAV_TEXTURE2DMS; + case D3D_SRV_DIMENSION_TEXTURE2DMSARRAY: + return RT_UAV_TEXTURE2DMSARRAY; + case D3D_SRV_DIMENSION_TEXTURE3D: + return RT_UAV_TEXTURE3D; + case D3D_SRV_DIMENSION_TEXTURECUBE: + return RT_UAV_TEXTURECUBE; + case D3D_SRV_DIMENSION_TEXTURECUBEARRAY: + return RT_UAV_TEXTURECUBEARRAY; + default: + return RT_UAV_BUFFER; + } + case D3D_SIT_STRUCTURED: + return RT_SRV_STRUCTURED_BUFFER; + case D3D_SIT_UAV_RWSTRUCTURED: + case D3D_SIT_UAV_APPEND_STRUCTURED: + case D3D_SIT_UAV_CONSUME_STRUCTURED: + case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: + return RT_UAV_STRUCTURED_BUFFER; + // D3D_SIT_TBUFFER??? + case D3D_SIT_BYTEADDRESS: + return RT_SRV_BUFFER; + case D3D_SIT_UAV_RWBYTEADDRESS: + return RT_UAV_BUFFER; + default: + return RT_SRV_BUFFER; } +} - inline uint8_t GetSpaceFromDesc( const D3D11_SHADER_INPUT_BIND_DESC& ) - { - return 0; - } +inline uint8_t GetSpaceFromDesc( const D3D11_SHADER_INPUT_BIND_DESC& ) +{ + return 0; +} - inline uint8_t GetSpaceFromDesc( const D3D12_SHADER_INPUT_BIND_DESC& desc ) - { - return uint8_t( desc.Space ); - } +inline uint8_t GetSpaceFromDesc( const D3D12_SHADER_INPUT_BIND_DESC& desc ) +{ + return uint8_t( desc.Space ); +} - struct ReflectionDx11 - { - using Reflection = ID3D11ShaderReflection; - using ShaderDesc = D3D11_SHADER_DESC; - using BufferDesc = D3D11_SHADER_BUFFER_DESC; - using InputBindDesc = D3D11_SHADER_INPUT_BIND_DESC; - using VariableDesc = D3D11_SHADER_VARIABLE_DESC; - using TypeDesc = D3D11_SHADER_TYPE_DESC; - using SignatureParamDesc = D3D11_SIGNATURE_PARAMETER_DESC; - }; +struct ReflectionDx11 +{ + using Reflection = ID3D11ShaderReflection; + using ShaderDesc = D3D11_SHADER_DESC; + using BufferDesc = D3D11_SHADER_BUFFER_DESC; + using InputBindDesc = D3D11_SHADER_INPUT_BIND_DESC; + using VariableDesc = D3D11_SHADER_VARIABLE_DESC; + using TypeDesc = D3D11_SHADER_TYPE_DESC; + using SignatureParamDesc = D3D11_SIGNATURE_PARAMETER_DESC; +}; + +struct FunctionDx12 +{ + using Reflection = ID3D12FunctionReflection; + using ShaderDesc = D3D12_FUNCTION_DESC; + using BufferDesc = D3D12_SHADER_BUFFER_DESC; + using InputBindDesc = D3D12_SHADER_INPUT_BIND_DESC; + using VariableDesc = D3D12_SHADER_VARIABLE_DESC; + using TypeDesc = D3D12_SHADER_TYPE_DESC; + using SignatureParamDesc = D3D12_SIGNATURE_PARAMETER_DESC; +}; + +enum class ReflectionTarget +{ + SHADER_INPUT, + LOCAL_INPUT, + GLOBAL_INPUT, +}; - struct FunctionDx12 - { - using Reflection = ID3D12FunctionReflection; - using ShaderDesc = D3D12_FUNCTION_DESC; - using BufferDesc = D3D12_SHADER_BUFFER_DESC; - using InputBindDesc = D3D12_SHADER_INPUT_BIND_DESC; - using VariableDesc = D3D12_SHADER_VARIABLE_DESC; - using TypeDesc = D3D12_SHADER_TYPE_DESC; - using SignatureParamDesc = D3D12_SIGNATURE_PARAMETER_DESC; - }; +template +static bool ProcessReflection( ParserState& parserState, typename Traits::Reflection* reflection, bool collectStaticSamplers, StageData& stage, std::map& annotations, ReflectionTarget reflectionTarget = ReflectionTarget::SHADER_INPUT, const std::vector& filter = {} ) +{ + ZoneScoped; - enum class ReflectionTarget + typename Traits::ShaderDesc reflDesc; + if( FAILED( reflection->GetDesc( &reflDesc ) ) ) { - SHADER_INPUT, - LOCAL_INPUT, - GLOBAL_INPUT, - }; + g_messages.AddMessage( "\\memory(0): error X0000: Could not get shader reflection description" ); + return false; + } - template - static bool ProcessReflection( ParserState& parserState, typename Traits::Reflection* reflection, bool collectStaticSamplers, StageData& stage, std::map& annotations, ReflectionTarget reflectionTarget = ReflectionTarget::SHADER_INPUT, const std::vector& filter = {} ) + for( unsigned cbIndex = 0; cbIndex < reflDesc.ConstantBuffers; ++cbIndex ) { - ZoneScoped; + auto cb = reflection->GetConstantBufferByIndex( cbIndex ); + + typename Traits::BufferDesc cbDesc; + cb->GetDesc( &cbDesc ); - typename Traits::ShaderDesc reflDesc; - if( FAILED( reflection->GetDesc( &reflDesc ) ) ) + if( strcmp( cbDesc.Name, "$Globals" ) ) { - g_messages.AddMessage( "\\memory(0): error X0000: Could not get shader reflection description" ); - return false; + typename Traits::InputBindDesc resDesc; + if( FAILED( reflection->GetResourceBindingDescByName( cbDesc.Name, &resDesc ) ) ) + { + continue; + } + if( resDesc.BindPoint != 0 || resDesc.Type != D3D_SIT_CBUFFER ) + { + continue; + } } - for( unsigned cbIndex = 0; cbIndex < reflDesc.ConstantBuffers; ++cbIndex ) + if( reflectionTarget == ReflectionTarget::GLOBAL_INPUT ) { - auto cb = reflection->GetConstantBufferByIndex( cbIndex ); + continue; + } - typename Traits::BufferDesc cbDesc; - cb->GetDesc( &cbDesc ); + for( unsigned i = 0; i < cbDesc.Variables; ++i ) + { + auto variable = cb->GetVariableByIndex( i ); - if( strcmp( cbDesc.Name, "$Globals" ) ) + typename Traits::VariableDesc varDesc; + if( FAILED( variable->GetDesc( &varDesc ) ) ) { - typename Traits::InputBindDesc resDesc; - if( FAILED( reflection->GetResourceBindingDescByName( cbDesc.Name, &resDesc ) ) ) - { - continue; - } - if( resDesc.BindPoint != 0 || resDesc.Type != D3D_SIT_CBUFFER ) + if( g_printWarnings ) { - continue; + g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader constant #%i description", i ); } + continue; } - - if( reflectionTarget == ReflectionTarget::GLOBAL_INPUT ) + if( ( varDesc.uFlags & D3D_SVF_USED ) == 0 ) { continue; } - for( unsigned i = 0; i < cbDesc.Variables; ++i ) + auto type = variable->GetType(); + typename Traits::TypeDesc typeDesc; + if( FAILED( type->GetDesc( &typeDesc ) ) ) { - auto variable = cb->GetVariableByIndex( i ); - - typename Traits::VariableDesc varDesc; - if( FAILED( variable->GetDesc( &varDesc ) ) ) - { - if( g_printWarnings ) - { - g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader constant #%i description", i ); - } - continue; - } - if( (varDesc.uFlags & D3D_SVF_USED) == 0 ) - { - continue; - } - - auto type = variable->GetType(); - typename Traits::TypeDesc typeDesc; - if( FAILED( type->GetDesc( &typeDesc ) ) ) + if( g_printWarnings ) { - if( g_printWarnings ) - { - g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader constant \"%s\" type description", varDesc.Name ); - } - continue; + g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader constant \"%s\" type description", varDesc.Name ); } + continue; + } - Constant constant; - constant.name = g_stringTable.AddString( varDesc.Name ); - constant.offset = varDesc.StartOffset; - constant.size = varDesc.Size; + Constant constant; + constant.name = g_stringTable.AddString( varDesc.Name ); + constant.offset = varDesc.StartOffset; + constant.size = varDesc.Size; - switch( typeDesc.Type ) - { - case D3D_SVT_FLOAT: - constant.type = CONSTANT_TYPE_FLOAT; - break; - case D3D_SVT_INT: - constant.type = CONSTANT_TYPE_INT; - break; - case D3D_SVT_UINT: - constant.type = CONSTANT_TYPE_UINT; - break; - case D3D_SVT_BOOL: - constant.type = CONSTANT_TYPE_BOOL; - break; - default: - constant.type = CONSTANT_TYPE_OTHER; - } - switch( typeDesc.Class ) - { - case D3D_SVC_SCALAR: - constant.dimension = 1; - break; - case D3D_SVC_VECTOR: - constant.dimension = uint8_t( varDesc.Size / 4 ); - break; - case D3D_SVC_MATRIX_ROWS: - case D3D_SVC_MATRIX_COLUMNS: - constant.dimension = 16; - break; - default: - constant.dimension = 1; - } - constant.elements = typeDesc.Elements; - constant.isSRGB = false; - constant.isAutoregister = false; + switch( typeDesc.Type ) + { + case D3D_SVT_FLOAT: + constant.type = CONSTANT_TYPE_FLOAT; + break; + case D3D_SVT_INT: + constant.type = CONSTANT_TYPE_INT; + break; + case D3D_SVT_UINT: + constant.type = CONSTANT_TYPE_UINT; + break; + case D3D_SVT_BOOL: + constant.type = CONSTANT_TYPE_BOOL; + break; + default: + constant.type = CONSTANT_TYPE_OTHER; + } + switch( typeDesc.Class ) + { + case D3D_SVC_SCALAR: + constant.dimension = 1; + break; + case D3D_SVC_VECTOR: + constant.dimension = uint8_t( varDesc.Size / 4 ); + break; + case D3D_SVC_MATRIX_ROWS: + case D3D_SVC_MATRIX_COLUMNS: + constant.dimension = 16; + break; + default: + constant.dimension = 1; + } + constant.elements = typeDesc.Elements; + constant.isSRGB = false; + constant.isAutoregister = false; - if( varDesc.DefaultValue ) - { - stage.defaultValues.resize( std::max( stage.defaultValues.size(), size_t( constant.offset + constant.size ) ) ); - memcpy( &stage.defaultValues[constant.offset], varDesc.DefaultValue, constant.size ); - } + if( varDesc.DefaultValue ) + { + stage.defaultValues.resize( std::max( stage.defaultValues.size(), size_t( constant.offset + constant.size ) ) ); + memcpy( &stage.defaultValues[constant.offset], varDesc.DefaultValue, constant.size ); + } - if( Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( varDesc.Name ) ) + if( Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( varDesc.Name ) ) + { + if( annotations.find( constant.name ) == annotations.end() ) { - if( annotations.find( constant.name ) == annotations.end() ) + ParameterAnnotation paramAnnotations; + if( symbol->annotations ) { - ParameterAnnotation paramAnnotations; - if( symbol->annotations ) + for( auto a = symbol->annotations->begin(); a != symbol->annotations->end(); ++a ) { - for( auto a = symbol->annotations->begin(); a != symbol->annotations->end(); ++a ) + Annotation result; + if( MakeEffectAnnotationFromSymbolAnnotation( *a, result, constant.isSRGB, constant.isAutoregister ) ) { - Annotation result; - if( MakeEffectAnnotationFromSymbolAnnotation( *a, result, constant.isSRGB, constant.isAutoregister ) ) - { - paramAnnotations.annotations[g_stringTable.AddString( ToString( a->name ).c_str() )] = result; - } + paramAnnotations.annotations[g_stringTable.AddString( ToString( a->name ).c_str() )] = result; } } - if( symbol->type.IsBindlessHandle() ) - { - Annotation symbolAnnotation; - symbolAnnotation.type = ANNOTATION_TYPE_INT; - symbolAnnotation.intValue = symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ? 100 : BindlessTextureType( symbol->type.builtInType ); - paramAnnotations.annotations[g_stringTable.AddString( "BindlessHandleType" )] = symbolAnnotation; - } - if( !paramAnnotations.annotations.empty() ) - { - annotations[constant.name] = paramAnnotations; - } } - if( symbol->type.IsBindlessHandle() && symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ) + if( symbol->type.IsBindlessHandle() ) { - auto found = std::find_if( begin( parserState.m_bindlessSamplers ), end( parserState.m_bindlessSamplers ), [symbol]( const auto& bs ) { return bs.name == symbol; } ); - if( found != end( parserState.m_bindlessSamplers ) ) + Annotation symbolAnnotation; + symbolAnnotation.type = ANNOTATION_TYPE_INT; + symbolAnnotation.intValue = symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ? 100 : BindlessTextureType( symbol->type.builtInType ); + paramAnnotations.annotations[g_stringTable.AddString( "BindlessHandleType" )] = symbolAnnotation; + } + if( !paramAnnotations.annotations.empty() ) + { + annotations[constant.name] = paramAnnotations; + } + } + if( symbol->type.IsBindlessHandle() && symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ) + { + auto found = std::find_if( begin( parserState.m_bindlessSamplers ), end( parserState.m_bindlessSamplers ), [symbol]( const auto& bs ) { return bs.name == symbol; } ); + if( found != end( parserState.m_bindlessSamplers ) ) + { + Sampler sampler; + if( GetSamplerState( parserState, found->definition, sampler ) ) { - Sampler sampler; - if( GetSamplerState( parserState, found->definition, sampler ) ) - { - sampler.name = constant.name; - stage.samplers[uint8_t( 100 + ( found - begin( parserState.m_bindlessSamplers ) ) )] = sampler; - } + sampler.name = constant.name; + stage.samplers[uint8_t( 100 + ( found - begin( parserState.m_bindlessSamplers ) ) )] = sampler; } } } - stage.constants.push_back( constant ); } + stage.constants.push_back( constant ); } + } - auto GetRegisterSpace = []( Symbol* symbol ) -> uint8_t { - if( symbol ) + auto GetRegisterSpace = []( Symbol* symbol ) -> uint8_t { + if( symbol ) + { + if( !symbol->registerSpecifier.empty() ) { - if( !symbol->registerSpecifier.empty() ) + auto space = symbol->registerSpecifier.begin()->second.space; + if( space > 0 ) { - auto space = symbol->registerSpecifier.begin()->second.space; - if( space > 0 ) - { - return uint8_t( space ); - } + return uint8_t( space ); } } - return 0; - }; + } + return 0; + }; - for( unsigned i = 0; i < reflDesc.BoundResources; ++i ) + for( unsigned i = 0; i < reflDesc.BoundResources; ++i ) + { + typename Traits::InputBindDesc desc; + if( FAILED( reflection->GetResourceBindingDesc( i, &desc ) ) ) { - typename Traits::InputBindDesc desc; - if( FAILED( reflection->GetResourceBindingDesc( i, &desc ) ) ) + if( g_printWarnings ) { - if( g_printWarnings ) - { - g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader resource #%i description", i ); - } - continue; + g_messages.AddMessage( "\\memory(0): warning X0000: Could not get shader resource #%i description", i ); } + continue; + } - switch ( reflectionTarget ) + switch( reflectionTarget ) + { + case ReflectionTarget::LOCAL_INPUT: + if( desc.Type == D3D_SIT_CBUFFER ) { - case ReflectionTarget::LOCAL_INPUT: - if( desc.Type == D3D_SIT_CBUFFER ) - { - auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); - if( found != end( filter ) ) - { - continue; - } - break; - } - else + auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); + if( found != end( filter ) ) { continue; } - case ReflectionTarget::GLOBAL_INPUT: - if( desc.Type == D3D_SIT_CBUFFER ) - { - auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); - if( found == end( filter ) ) - { - continue; - } - } - else - { - auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); - if( found == end( filter ) ) - { - g_messages.AddMessage( "\\memory(0): error X0000: Ray tracing shader may not use SRV/UAV/Sampler \"%s\" not declared in the globalinput", desc.Name ); - return false; - } - } - break; - default: break; } - - switch( desc.Type ) + else { - case D3D_SIT_SAMPLER: + continue; + } + case ReflectionTarget::GLOBAL_INPUT: + if( desc.Type == D3D_SIT_CBUFFER ) { - //stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint } ); - - Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); - if( symbol == nullptr || symbol->definition == nullptr ) + auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); + if( found == end( filter ) ) { - if( g_printWarnings ) - { - g_messages.AddMessage( "\\memory(0): warning X0000: Could not find sampler \"%s\" definition in the source code", desc.Name ); - } - stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); continue; } - Sampler sampler; - //sampler.name = g_stringTable.AddString( desc.Name ); - if( !GetSamplerState( parserState, symbol->definition, sampler ) ) + } + else + { + auto found = std::find_if( begin( filter ), end( filter ), [desc]( const auto& f ) { return f.name == desc.Name; } ); + if( found == end( filter ) ) { + g_messages.AddMessage( "\\memory(0): error X0000: Ray tracing shader may not use SRV/UAV/Sampler \"%s\" not declared in the globalinput", desc.Name ); return false; } - StaticSampler staticSampler; - if( desc.BindCount == 1 && collectStaticSamplers && ConvertToStaticSampler( staticSampler, sampler ) ) - { - staticSampler.registerIndex = desc.BindPoint; - staticSampler.registerSpace = GetRegisterSpace( symbol ); - stage.staticSamplers.push_back( staticSampler ); - } - else - { - sampler.name = g_stringTable.AddString( desc.Name ); - stage.samplers[uint8_t( desc.BindPoint )] = sampler; - stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); - - if( symbol && symbol->annotations ) - { - ParameterAnnotation paramAnnotations; - for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai ) - { - Annotation result; - bool srgb, autoregister; - if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, srgb, autoregister ) ) - { - paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result; - } - } - if( !paramAnnotations.annotations.empty() ) - { - annotations[g_stringTable.AddString( desc.Name )] = paramAnnotations; - } - } - - } - //stage.samplers[uint8_t( desc.BindPoint )] = sampler; } break; - case D3D_SIT_UAV_RWTYPED: - case D3D_SIT_UAV_RWSTRUCTURED: - case D3D_SIT_UAV_RWBYTEADDRESS: - case D3D_SIT_UAV_APPEND_STRUCTURED: - case D3D_SIT_UAV_CONSUME_STRUCTURED: - case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: - { - //stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint } ); - Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); - stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); + default: + break; + } - Uav uav; - uav.count = desc.BindCount; - uav.isAutoregister = false; - std::string uavName = desc.Name; + switch( desc.Type ) + { + case D3D_SIT_SAMPLER: { + //stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint } ); - //Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); - if( symbol == nullptr ) + Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); + if( symbol == nullptr || symbol->definition == nullptr ) + { + if( g_printWarnings ) { - continue; + g_messages.AddMessage( "\\memory(0): warning X0000: Could not find sampler \"%s\" definition in the source code", desc.Name ); } + stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); + continue; + } + Sampler sampler; + //sampler.name = g_stringTable.AddString( desc.Name ); + if( !GetSamplerState( parserState, symbol->definition, sampler ) ) + { + return false; + } + StaticSampler staticSampler; + if( desc.BindCount == 1 && collectStaticSamplers && ConvertToStaticSampler( staticSampler, sampler ) ) + { + staticSampler.registerIndex = desc.BindPoint; + staticSampler.registerSpace = GetRegisterSpace( symbol ); + stage.staticSamplers.push_back( staticSampler ); + } + else + { + sampler.name = g_stringTable.AddString( desc.Name ); + stage.samplers[uint8_t( desc.BindPoint )] = sampler; + stage.registerInputs.push_back( { RT_SAMPLER, desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); + if( symbol && symbol->annotations ) { ParameterAnnotation paramAnnotations; - - bool srgb; - uav.isAutoregister = false; - for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai ) { Annotation result; - if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, srgb, uav.isAutoregister ) ) + bool srgb, autoregister; + if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, srgb, autoregister ) ) { paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result; } } - if( !paramAnnotations.annotations.empty() ) { - annotations[g_stringTable.AddString( uavName.c_str() )] = paramAnnotations; + annotations[g_stringTable.AddString( desc.Name )] = paramAnnotations; } } + } + //stage.samplers[uint8_t( desc.BindPoint )] = sampler; + } + break; + case D3D_SIT_UAV_RWTYPED: + case D3D_SIT_UAV_RWSTRUCTURED: + case D3D_SIT_UAV_RWBYTEADDRESS: + case D3D_SIT_UAV_APPEND_STRUCTURED: + case D3D_SIT_UAV_CONSUME_STRUCTURED: + case D3D_SIT_UAV_RWSTRUCTURED_WITH_COUNTER: { + //stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint } ); + Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); + stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); + + Uav uav; + uav.count = desc.BindCount; + uav.isAutoregister = false; + std::string uavName = desc.Name; + + //Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); + if( symbol == nullptr ) + { + continue; + } + if( symbol && symbol->annotations ) + { + ParameterAnnotation paramAnnotations; + bool srgb; + uav.isAutoregister = false; - uav.name = g_stringTable.AddString( uavName.c_str() ); - if( !GetTextureType( desc, uav.type ) ) + for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai ) { - continue; + Annotation result; + if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, srgb, uav.isAutoregister ) ) + { + paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result; + } + } + + if( !paramAnnotations.annotations.empty() ) + { + annotations[g_stringTable.AddString( uavName.c_str() )] = paramAnnotations; } - stage.uavs[uint8_t( desc.BindPoint )] = uav; } - break; - case D3D_SIT_CBUFFER: + + + uav.name = g_stringTable.AddString( uavName.c_str() ); + if( !GetTextureType( desc, uav.type ) ) { - stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetSpaceFromDesc( desc ) } ); - break; + continue; } - default: - { - Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); - stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); + stage.uavs[uint8_t( desc.BindPoint )] = uav; + } + break; + case D3D_SIT_CBUFFER: { + stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetSpaceFromDesc( desc ) } ); + break; + } + default: { + Symbol* symbol = parserState.GetSymbolTable().LookupGlobal( desc.Name ); + stage.registerInputs.push_back( { GetRegisterType( desc ), desc.BindPoint, desc.BindCount, GetRegisterSpace( symbol ) } ); - Texture texture; - texture.count = desc.BindCount; - texture.isSRGB = false; - texture.isAutoregister = false; - std::string textureName = desc.Name; + Texture texture; + texture.count = desc.BindCount; + texture.isSRGB = false; + texture.isAutoregister = false; + std::string textureName = desc.Name; - if( symbol == nullptr ) - { - continue; - } - // For legacy sampling functions (like tex2D) the reflection will create "dummy" - // texture object with the same name as the sampler, so we need to find the - // actual texture object from sampler definition. - if( symbol && symbol->type.IsSampler() ) + if( symbol == nullptr ) + { + continue; + } + // For legacy sampling functions (like tex2D) the reflection will create "dummy" + // texture object with the same name as the sampler, so we need to find the + // actual texture object from sampler definition. + if( symbol && symbol->type.IsSampler() ) + { + if( symbol->definition ) { - if( symbol->definition ) + ASTNode* states = symbol->definition->GetChildOrNull( 1 ); + if( states && states->GetNodeType() == ASTNodeType::NT_SAMPLER_STATE_LIST ) { - ASTNode* states = symbol->definition->GetChildOrNull( 1 ); - if( states && states->GetNodeType() == ASTNodeType::NT_SAMPLER_STATE_LIST ) + for( size_t k = 0; k < states->GetChildrenCount(); ++k ) { - for( size_t k = 0; k < states->GetChildrenCount(); ++k ) + ASTNode* state = states->GetChild( k ); + std::string name = ToString( state->GetToken()->stringValue ); + if( _stricmp( name.c_str(), "Texture" ) == 0 ) { - ASTNode* state = states->GetChild( k ); - std::string name = ToString( state->GetToken()->stringValue ); - if( _stricmp( name.c_str(), "Texture" ) == 0 ) + ASTNode* value = state->GetChildOrNull( 0 ); + if( value && value->GetSymbol() ) { - ASTNode* value = state->GetChildOrNull( 0 ); - if( value && value->GetSymbol() ) - { - textureName = ToString( value->GetSymbol()->name ); - } - } - else if( _stricmp( name.c_str(), "SRGBTexture" ) == 0 ) - { - Sampler sampler; - sampler.srgbTexture = 0; - ParseStateAssignment( parserState, state, g_samplerStates, &sampler ); - texture.isSRGB = sampler.srgbTexture != 0; + textureName = ToString( value->GetSymbol()->name ); } } + else if( _stricmp( name.c_str(), "SRGBTexture" ) == 0 ) + { + Sampler sampler; + sampler.srgbTexture = 0; + ParseStateAssignment( parserState, state, g_samplerStates, &sampler ); + texture.isSRGB = sampler.srgbTexture != 0; + } } } } - else if( symbol && symbol->annotations ) - { - ParameterAnnotation paramAnnotations; - - texture.isSRGB = false; - texture.isAutoregister = false; + } + else if( symbol && symbol->annotations ) + { + ParameterAnnotation paramAnnotations; - for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai ) - { - Annotation result; - if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, texture.isSRGB, texture.isAutoregister ) ) - { - paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result; - } - } + texture.isSRGB = false; + texture.isAutoregister = false; - if( !paramAnnotations.annotations.empty() ) + for( auto ai = symbol->annotations->begin(); ai != symbol->annotations->end(); ++ai ) + { + Annotation result; + if( MakeEffectAnnotationFromSymbolAnnotation( *ai, result, texture.isSRGB, texture.isAutoregister ) ) { - annotations[g_stringTable.AddString( textureName.c_str() )] = paramAnnotations; + paramAnnotations.annotations[g_stringTable.AddString( ToString( ai->name ).c_str() )] = result; } } - - texture.name = g_stringTable.AddString( textureName.c_str() ); - if( !GetTextureType( desc, texture.type ) ) + if( !paramAnnotations.annotations.empty() ) { - continue; + annotations[g_stringTable.AddString( textureName.c_str() )] = paramAnnotations; } - stage.textures[uint8_t( desc.BindPoint )] = texture; } + + + texture.name = g_stringTable.AddString( textureName.c_str() ); + if( !GetTextureType( desc, texture.type ) ) + { + continue; } + stage.textures[uint8_t( desc.BindPoint )] = texture; + } } - return true; } + return true; +} - template - static bool ProcessReflection( ParserState& parserState, typename Traits::Reflection* reflection, bool collectStaticSamplers, StageInput& stage, std::map& annotations ) +template +static bool ProcessReflection( ParserState& parserState, typename Traits::Reflection* reflection, bool collectStaticSamplers, StageInput& stage, std::map& annotations ) +{ + if( !ProcessReflection( parserState, reflection, collectStaticSamplers, static_cast( stage ), annotations ) ) { - if( !ProcessReflection( parserState, reflection, collectStaticSamplers, static_cast(stage), annotations ) ) - { - return false; - } + return false; + } - typename Traits::ShaderDesc reflDesc; - reflection->GetDesc( &reflDesc ); + typename Traits::ShaderDesc reflDesc; + reflection->GetDesc( &reflDesc ); - reflection->GetThreadGroupSize( &stage.threadGroupSize[0], &stage.threadGroupSize[1], &stage.threadGroupSize[2] ); + reflection->GetThreadGroupSize( &stage.threadGroupSize[0], &stage.threadGroupSize[1], &stage.threadGroupSize[2] ); - for( unsigned k = 0; k < reflDesc.InputParameters; ++k ) + for( unsigned k = 0; k < reflDesc.InputParameters; ++k ) + { + typename Traits::SignatureParamDesc desc; + if( FAILED( reflection->GetInputParameterDesc( k, &desc ) ) ) { - typename Traits::SignatureParamDesc desc; - if( FAILED( reflection->GetInputParameterDesc( k, &desc ) ) ) - { - g_messages.AddMessage( "\\memory(0): error X0000: Could not get shader input parameter description" ); - return false; - } - if( desc.SystemValueType == D3D10_NAME_UNDEFINED ) + g_messages.AddMessage( "\\memory(0): error X0000: Could not get shader input parameter description" ); + return false; + } + if( desc.SystemValueType == D3D10_NAME_UNDEFINED ) + { + bool found = false; + PipelineInputDescription input; + for( int n = 0; n < UC_NUM_USAGE_CODE; ++n ) { - bool found = false; - PipelineInputDescription input; - for( int n = 0; n < UC_NUM_USAGE_CODE; ++n ) + if( _stricmp( desc.SemanticName, GetStringForUsageCode( n ) ) == 0 ) { - if( _stricmp( desc.SemanticName, GetStringForUsageCode( n ) ) == 0 ) + input.name = uint8_t( n ); + input.registerIndex = uint8_t( desc.Register ); + input.index = uint8_t( desc.SemanticIndex ); + input.usedMask = desc.ReadWriteMask; + switch( desc.ComponentType ) { - input.name = uint8_t( n ); - input.registerIndex = uint8_t( desc.Register ); - input.index = uint8_t( desc.SemanticIndex ); - input.usedMask = desc.ReadWriteMask; - switch( desc.ComponentType ) - { - case D3D_REGISTER_COMPONENT_FLOAT32: - input.type = CONSTANT_TYPE_FLOAT; - break; - case D3D_REGISTER_COMPONENT_SINT32: - input.type = CONSTANT_TYPE_INT; - break; - case D3D_REGISTER_COMPONENT_UINT32: - input.type = CONSTANT_TYPE_UINT; - break; - default: - input.type = CONSTANT_TYPE_OTHER; - break; - } - if( desc.Mask >= (1 << 7) ) - { - input.dimension = 8; - } - else if( desc.Mask >= (1 << 6) ) - { - input.dimension = 7; - } - else if( desc.Mask >= (1 << 5) ) - { - input.dimension = 6; - } - else if( desc.Mask >= (1 << 4) ) - { - input.dimension = 5; - } - else if( desc.Mask >= (1 << 3) ) - { - input.dimension = 4; - } - else if( desc.Mask >= (1 << 2) ) - { - input.dimension = 3; - } - else if( desc.Mask >= (1 << 1) ) - { - input.dimension = 2; - } - else - { - input.dimension = 1; - } - stage.pipelineInputs.push_back( input ); - found = true; + case D3D_REGISTER_COMPONENT_FLOAT32: + input.type = CONSTANT_TYPE_FLOAT; + break; + case D3D_REGISTER_COMPONENT_SINT32: + input.type = CONSTANT_TYPE_INT; + break; + case D3D_REGISTER_COMPONENT_UINT32: + input.type = CONSTANT_TYPE_UINT; + break; + default: + input.type = CONSTANT_TYPE_OTHER; break; } - } - if( !found && g_printWarnings ) - { - g_messages.AddMessage( "\\memory(0): error X0000: Shader uses unsupported input semantics \"%s\"", desc.SemanticName ); - return false; + if( desc.Mask >= ( 1 << 7 ) ) + { + input.dimension = 8; + } + else if( desc.Mask >= ( 1 << 6 ) ) + { + input.dimension = 7; + } + else if( desc.Mask >= ( 1 << 5 ) ) + { + input.dimension = 6; + } + else if( desc.Mask >= ( 1 << 4 ) ) + { + input.dimension = 5; + } + else if( desc.Mask >= ( 1 << 3 ) ) + { + input.dimension = 4; + } + else if( desc.Mask >= ( 1 << 2 ) ) + { + input.dimension = 3; + } + else if( desc.Mask >= ( 1 << 1 ) ) + { + input.dimension = 2; + } + else + { + input.dimension = 1; + } + stage.pipelineInputs.push_back( input ); + found = true; + break; } } + if( !found && g_printWarnings ) + { + g_messages.AddMessage( "\\memory(0): error X0000: Shader uses unsupported input semantics \"%s\"", desc.SemanticName ); + return false; + } } - return true; } + return true; +} } diff --git a/shadercompiler/EffectCompilerBase.h b/shadercompiler/EffectCompilerBase.h index a604bffc7..5a67d7c4e 100644 --- a/shadercompiler/EffectCompilerBase.h +++ b/shadercompiler/EffectCompilerBase.h @@ -8,7 +8,9 @@ struct Macro; class EffectCompilerBase { public: - virtual ~EffectCompilerBase() {} + virtual ~EffectCompilerBase() + { + } virtual bool Create() = 0; virtual bool CompileEffect( const char* source, size_t sourceLength, const std::vector& defines, EffectData& result, class IWorkQueue* workQueue ) = 0; diff --git a/shadercompiler/EffectCompilerDX11.cpp b/shadercompiler/EffectCompilerDX11.cpp index e0656bfe2..9512daa97 100644 --- a/shadercompiler/EffectCompilerDX11.cpp +++ b/shadercompiler/EffectCompilerDX11.cpp @@ -25,10 +25,9 @@ #include "DxReflection.h" #include -#define DXIL_FOURCC(ch0, ch1, ch2, ch3) ( \ - (uint32_t)(uint8_t)(ch0) | (uint32_t)(uint8_t)(ch1) << 8 | \ - (uint32_t)(uint8_t)(ch2) << 16 | (uint32_t)(uint8_t)(ch3) << 24 \ - ) +#define DXIL_FOURCC( ch0, ch1, ch2, ch3 ) ( \ + (uint32_t)(uint8_t)( ch0 ) | (uint32_t)(uint8_t)( ch1 ) << 8 | \ + (uint32_t)(uint8_t)( ch2 ) << 16 | (uint32_t)(uint8_t)( ch3 ) << 24 ) enum DxilFourCC { @@ -161,7 +160,7 @@ void PrintValuePath( std::ostream& os, const std::vector& path, const c } if( *it ) { - os << (*it)->name; + os << ( *it )->name; } else { @@ -185,8 +184,7 @@ static void PatchSemantics( InputStageType shaderStage, ASTNode* callNode ) std::vector targetPath; switch( shaderStage ) { - case VERTEX_STAGE: - { + case VERTEX_STAGE: { const char* semantics[] = { "position", nullptr }; if( FindOutputBySemantics( functionHeader, semantics, &targetPath ) ) { @@ -201,8 +199,7 @@ static void PatchSemantics( InputStageType shaderStage, ASTNode* callNode ) } break; } - case PIXEL_STAGE: - { + case PIXEL_STAGE: { { const char* semantics[] = { "color", "color0", nullptr }; if( FindOutputBySemantics( functionHeader, semantics, &targetPath ) ) @@ -307,14 +304,14 @@ static PatchAction PatchShader( InputStageType shaderStage, ASTNode* callNode, P if( vposPath.back() ) { if( vposPath.back()->type.symbol || - (vposPath.back()->type.builtInType == OP_FLOAT && vposPath.back()->type.width == 4 && vposPath.back()->type.height == 1) ) + ( vposPath.back()->type.builtInType == OP_FLOAT && vposPath.back()->type.width == 4 && vposPath.back()->type.height == 1 ) ) { fixVPOSType = false; } } } - if( !wrapUniforms && !fixVPOS && !fixVPOSType && (shaderStage != VERTEX_STAGE || outPositionPath.empty()) ) + if( !wrapUniforms && !fixVPOS && !fixVPOSType && ( shaderStage != VERTEX_STAGE || outPositionPath.empty() ) ) { entryPointName = ToString( entryPointSymbol->name ); return PATCH_USE; @@ -512,7 +509,7 @@ bool MatchShaderInputOutput( ID3D11ShaderReflection* output, ID3D11ShaderReflect g_messages.AddMessage( "\\memory(0): error X0000: Could not get shader output parameter description" ); return false; } - if( vsDesc.Register == psDesc.Register && ((~vsDesc.Mask & psDesc.Mask) == 0) ) + if( vsDesc.Register == psDesc.Register && ( ( ~vsDesc.Mask & psDesc.Mask ) == 0 ) ) { if( _stricmp( vsDesc.SemanticName, psDesc.SemanticName ) || vsDesc.SemanticIndex != psDesc.SemanticIndex ) { @@ -569,52 +566,12 @@ void PrintShaderOutListing( YamlOutput& listing, ID3DBlob* effectData, ID3D11Sha CComPtr disassembly; if( SUCCEEDED( D3DDisassemble( effectData->GetBufferPointer(), effectData->GetBufferSize(), D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS, nullptr, &disassembly ) ) ) { - listing.literal( "asm" ).literal( reinterpret_cast(disassembly->GetBufferPointer()) ); + listing.literal( "asm" ).literal( reinterpret_cast( disassembly->GetBufferPointer() ) ); } D3D11_SHADER_DESC desc; if( reflection && SUCCEEDED( reflection->GetDesc( &desc ) ) ) { - listing.literal( "stats" ).dict() - .literal( "Resources" ).dict() - .literal( "constantBuffers" ).literal( desc.ConstantBuffers ) - .literal( "boundResources" ).literal( desc.BoundResources ) - .literal( "inputParameters" ).literal( desc.InputParameters ) - .literal( "outputParameters" ).literal( desc.OutputParameters ) - .literal( "tempRegisterCount" ).literal( desc.TempRegisterCount ) - .literal( "tempArrayCount" ).literal( desc.TempArrayCount ) - .end() - .literal( "Instructions" ).dict() - .literal( "instructionCount" ).literal( desc.InstructionCount ) - .literal( "defCount" ).literal( desc.DefCount ) - .literal( "textureNormalInstructions" ).literal( desc.TextureNormalInstructions ) - .literal( "textureLoadInstructions" ).literal( desc.TextureLoadInstructions ) - .literal( "textureCompInstructions" ).literal( desc.TextureCompInstructions ) - .literal( "textureBiasInstructions" ).literal( desc.TextureBiasInstructions ) - .literal( "textureGradientInstructions" ).literal( desc.TextureGradientInstructions ) - .literal( "floatInstructionCount" ).literal( desc.FloatInstructionCount ) - .literal( "intInstructionCount" ).literal( desc.IntInstructionCount ) - .literal( "uintInstructionCount" ).literal( desc.UintInstructionCount ) - .literal( "staticFlowControlCount" ).literal( desc.StaticFlowControlCount ) - .literal( "dynamicFlowControlCount" ).literal( desc.DynamicFlowControlCount ) - .literal( "macroInstructionCount" ).literal( desc.MacroInstructionCount ) - .literal( "arrayInstructionCount" ).literal( desc.ArrayInstructionCount ) - .literal( "cutInstructionCount" ).literal( desc.CutInstructionCount ) - .literal( "emitInstructionCount" ).literal( desc.EmitInstructionCount ) - .literal( "cBarrierInstructions" ).literal( desc.cBarrierInstructions ) - .literal( "cInterlockedInstructions" ).literal( desc.cInterlockedInstructions ) - .literal( "cTextureStoreInstructions" ).literal( desc.cTextureStoreInstructions ) - .end() - .literal( "Misc" ).dict() - .literal( "GSOutputTopology" ).literal( desc.GSOutputTopology ) - .literal( "inputPrimitive" ).literal( desc.InputPrimitive ) - .literal( "GSMaxOutputVertexCount" ).literal( desc.GSMaxOutputVertexCount ) - .literal( "patchConstantParameters" ).literal( desc.PatchConstantParameters ) - .literal( "cGSInstanceCount" ).literal( desc.cGSInstanceCount ) - .literal( "HSOutputPrimitive" ).literal( desc.HSOutputPrimitive ) - .literal( "HSPartitioning" ).literal( desc.HSPartitioning ) - .literal( "tessellatorDomain" ).literal( desc.TessellatorDomain ) - .end() - .end(); + listing.literal( "stats" ).dict().literal( "Resources" ).dict().literal( "constantBuffers" ).literal( desc.ConstantBuffers ).literal( "boundResources" ).literal( desc.BoundResources ).literal( "inputParameters" ).literal( desc.InputParameters ).literal( "outputParameters" ).literal( desc.OutputParameters ).literal( "tempRegisterCount" ).literal( desc.TempRegisterCount ).literal( "tempArrayCount" ).literal( desc.TempArrayCount ).end().literal( "Instructions" ).dict().literal( "instructionCount" ).literal( desc.InstructionCount ).literal( "defCount" ).literal( desc.DefCount ).literal( "textureNormalInstructions" ).literal( desc.TextureNormalInstructions ).literal( "textureLoadInstructions" ).literal( desc.TextureLoadInstructions ).literal( "textureCompInstructions" ).literal( desc.TextureCompInstructions ).literal( "textureBiasInstructions" ).literal( desc.TextureBiasInstructions ).literal( "textureGradientInstructions" ).literal( desc.TextureGradientInstructions ).literal( "floatInstructionCount" ).literal( desc.FloatInstructionCount ).literal( "intInstructionCount" ).literal( desc.IntInstructionCount ).literal( "uintInstructionCount" ).literal( desc.UintInstructionCount ).literal( "staticFlowControlCount" ).literal( desc.StaticFlowControlCount ).literal( "dynamicFlowControlCount" ).literal( desc.DynamicFlowControlCount ).literal( "macroInstructionCount" ).literal( desc.MacroInstructionCount ).literal( "arrayInstructionCount" ).literal( desc.ArrayInstructionCount ).literal( "cutInstructionCount" ).literal( desc.CutInstructionCount ).literal( "emitInstructionCount" ).literal( desc.EmitInstructionCount ).literal( "cBarrierInstructions" ).literal( desc.cBarrierInstructions ).literal( "cInterlockedInstructions" ).literal( desc.cInterlockedInstructions ).literal( "cTextureStoreInstructions" ).literal( desc.cTextureStoreInstructions ).end().literal( "Misc" ).dict().literal( "GSOutputTopology" ).literal( desc.GSOutputTopology ).literal( "inputPrimitive" ).literal( desc.InputPrimitive ).literal( "GSMaxOutputVertexCount" ).literal( desc.GSMaxOutputVertexCount ).literal( "patchConstantParameters" ).literal( desc.PatchConstantParameters ).literal( "cGSInstanceCount" ).literal( desc.cGSInstanceCount ).literal( "HSOutputPrimitive" ).literal( desc.HSOutputPrimitive ).literal( "HSPartitioning" ).literal( desc.HSPartitioning ).literal( "tessellatorDomain" ).literal( desc.TessellatorDomain ).end().end(); } } @@ -628,29 +585,34 @@ void PrintAnnotations( YamlOutput& listing, const std::mapfirst ) ) + .literal( "name" ) + .literal( g_stringTable.GetString( a->first ) ) .literal( "annotationType" ); switch( a->second.type ) { case ANNOTATION_TYPE_BOOL: listing .literal( "bool" ) - .literal( "value" ).literal( a->second.intValue != 0 ); + .literal( "value" ) + .literal( a->second.intValue != 0 ); break; case ANNOTATION_TYPE_INT: listing .literal( "int" ) - .literal( "value" ).literal( a->second.intValue ); + .literal( "value" ) + .literal( a->second.intValue ); break; case ANNOTATION_TYPE_FLOAT: listing .literal( "float" ) - .literal( "value" ).literal( a->second.floatValue ); + .literal( "value" ) + .literal( a->second.floatValue ); break; default: listing .literal( "string" ) - .literal( "value" ).literal( g_stringTable.GetString( a->second.stringValue ) ); + .literal( "value" ) + .literal( g_stringTable.GetString( a->second.stringValue ) ); break; } listing.end(); @@ -728,12 +690,18 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa for( auto it = stage.constants.begin(); it != stage.constants.end(); ++it ) { listing.dict() - .literal( "name" ).literal( g_stringTable.GetString( it->name ) ) - .literal( "constantType" ).literal( ToString( it->type ) ) - .literal( "dimension" ).literal( it->dimension ) - .literal( "arrayElements" ).literal( it->elements ) - .literal( "autoregister" ).literal( it->isAutoregister ) - .literal( "sRGB" ).literal( it->isSRGB ); + .literal( "name" ) + .literal( g_stringTable.GetString( it->name ) ) + .literal( "constantType" ) + .literal( ToString( it->type ) ) + .literal( "dimension" ) + .literal( it->dimension ) + .literal( "arrayElements" ) + .literal( it->elements ) + .literal( "autoregister" ) + .literal( it->isAutoregister ) + .literal( "sRGB" ) + .literal( it->isSRGB ); auto annotations = result.annotations.find( it->name ); if( annotations != result.annotations.end() ) { @@ -749,24 +717,47 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa for( auto it = stage.samplers.begin(); it != stage.samplers.end(); ++it ) { listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "filter" ).literal( int( it->second.filter ) ) - .literal( "comparison" ).literal( int( it->second.comparison ) ) - .literal( "minFilter" ).literal( int( it->second.minFilter ) ) - .literal( "magFilter" ).literal( int( it->second.magFilter ) ) - .literal( "mipFilter" ).literal( int( it->second.mipFilter ) ) - .literal( "addressU" ).literal( int( it->second.addressU ) ) - .literal( "addressV" ).literal( int( it->second.addressV ) ) - .literal( "addressW" ).literal( int( it->second.addressW ) ) - .literal( "mipLODBias" ).literal( it->second.mipLODBias ) - .literal( "maxAnisotropy" ).literal( int( it->second.maxAnisotropy ) ) - .literal( "comparisonFunc" ).literal( int( it->second.comparisonFunc ) ) - .literal( "borderColor" ).list().literal( it->second.borderColor.x ).literal( it->second.borderColor.y ).literal( it->second.borderColor.z ).literal( it->second.borderColor.w ).end() - .literal( "minLOD" ).literal( it->second.minLOD ) - .literal( "maxLOD" ).literal( it->second.maxLOD ) - .literal( "srgbTexture" ).literal( it->second.srgbTexture != 0 ) - .literal( "isDynamic" ).literal( it->second.isDynamic != 0 ); + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "filter" ) + .literal( int( it->second.filter ) ) + .literal( "comparison" ) + .literal( int( it->second.comparison ) ) + .literal( "minFilter" ) + .literal( int( it->second.minFilter ) ) + .literal( "magFilter" ) + .literal( int( it->second.magFilter ) ) + .literal( "mipFilter" ) + .literal( int( it->second.mipFilter ) ) + .literal( "addressU" ) + .literal( int( it->second.addressU ) ) + .literal( "addressV" ) + .literal( int( it->second.addressV ) ) + .literal( "addressW" ) + .literal( int( it->second.addressW ) ) + .literal( "mipLODBias" ) + .literal( it->second.mipLODBias ) + .literal( "maxAnisotropy" ) + .literal( int( it->second.maxAnisotropy ) ) + .literal( "comparisonFunc" ) + .literal( int( it->second.comparisonFunc ) ) + .literal( "borderColor" ) + .list() + .literal( it->second.borderColor.x ) + .literal( it->second.borderColor.y ) + .literal( it->second.borderColor.z ) + .literal( it->second.borderColor.w ) + .end() + .literal( "minLOD" ) + .literal( it->second.minLOD ) + .literal( "maxLOD" ) + .literal( it->second.maxLOD ) + .literal( "srgbTexture" ) + .literal( it->second.srgbTexture != 0 ) + .literal( "isDynamic" ) + .literal( it->second.isDynamic != 0 ); auto annotations = result.annotations.find( it->second.name ); if( annotations != result.annotations.end() ) { @@ -782,11 +773,16 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa for( auto it = stage.textures.begin(); it != stage.textures.end(); ++it ) { listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "textureType" ).literal( it->second.type ) - .literal( "autoregister" ).literal( it->second.isAutoregister ) - .literal( "sRGB" ).literal( it->second.isSRGB ); + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "textureType" ) + .literal( it->second.type ) + .literal( "autoregister" ) + .literal( it->second.isAutoregister ) + .literal( "sRGB" ) + .literal( it->second.isSRGB ); auto annotations = result.annotations.find( it->second.name ); if( annotations != result.annotations.end() ) { @@ -802,10 +798,14 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa for( auto it = stage.uavs.begin(); it != stage.uavs.end(); ++it ) { listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "resourceType" ).literal( it->second.type ) - .literal( "autoregister" ).literal( it->second.isAutoregister ); + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "resourceType" ) + .literal( it->second.type ) + .literal( "autoregister" ) + .literal( it->second.isAutoregister ); auto annotations = result.annotations.find( it->second.name ); if( annotations != result.annotations.end() ) { @@ -821,8 +821,10 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa for( auto it = stage.registerInputs.begin(); it != stage.registerInputs.end(); ++it ) { listing.dict() - .literal( "registerType" ).literal( it->registerType ) - .literal( "register" ).literal( it->registerIndex ) + .literal( "registerType" ) + .literal( it->registerType ) + .literal( "register" ) + .literal( it->registerIndex ) .end(); } listing.end(); @@ -831,17 +833,21 @@ void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectDa void PrintStageInfo( YamlOutput& listing, const StageInput& stage, const EffectData& result ) { - PrintStageInfo( listing, static_cast(stage), result ); + PrintStageInfo( listing, static_cast( stage ), result ); if( !stage.pipelineInputs.empty() ) { listing.literal( "inputs" ).list(); for( auto it = stage.pipelineInputs.begin(); it != stage.pipelineInputs.end(); ++it ) { listing.dict() - .literal( "register" ).literal( it->registerIndex ) - .literal( "name" ).literal( it->name ) - .literal( "index" ).literal( it->index ) - .literal( "usedMask" ).literal( it->usedMask ) + .literal( "register" ) + .literal( it->registerIndex ) + .literal( "name" ) + .literal( it->name ) + .literal( "index" ) + .literal( it->index ) + .literal( "usedMask" ) + .literal( it->usedMask ) .end(); } listing.end(); // inputs @@ -1035,7 +1041,7 @@ RegisterInputDescription GetRegisterInputDescription( const Type& type, const Re } -TextureType TypeToTextureType( const Type& type ) +TextureType TypeToTextureType( const Type& type ) { switch( type.builtInType ) { @@ -1204,7 +1210,6 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, d.location.lineNumber = 0; d.value = MakeInlineString( it->value.c_str() ); state.m_defines[MakeInlineString( it->name.c_str() )] = d; - } if( !state.Parse() ) @@ -1227,10 +1232,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, YamlListing listing; listing.dict(); - listing.literal( "permutation" ).dict() - .literal( "platform" ).literal( "DX11" ) - .literal( "id" ).literal( "000" ) - .literal( "defines" ).dict(); + listing.literal( "permutation" ).dict().literal( "platform" ).literal( "DX11" ).literal( "id" ).literal( "000" ).literal( "defines" ).dict(); for( auto it = begin( defines ); it != end( defines ); ++it ) { listing.literal( it->name ).literal( it->value ); @@ -1245,8 +1247,10 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, technique.name = g_stringTable.AddString( ToString( techniqueNode->GetToken()->stringValue ).c_str() ); listing.dict() - .literal( "name" ).literal( techniqueNode->GetToken()->stringValue ) - .literal( "passes" ).list(); + .literal( "name" ) + .literal( techniqueNode->GetToken()->stringValue ) + .literal( "passes" ) + .list(); for( size_t passIx = 0; passIx < techniqueNode->GetChildrenCount(); ++passIx ) { @@ -1351,7 +1355,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, } CompilerInputStream os( state, ShadingLanguage::HLSL ); - os << HLSL{ state.GetTree(), & state.GetSymbolTable() }; + os << HLSL{ state.GetTree(), &state.GetSymbolTable() }; std::string entryPoint = ToString( shaderNode->GetChild( 1 )->GetSymbol()->name ); @@ -1371,7 +1375,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, { std::lock_guard scope( m_compiledCS ); auto found = m_compiled.find( code ); - if ( found == end( m_compiled ) ) + if( found == end( m_compiled ) ) { // Yep, this thread will have to compile. Make an entry into the cache. syncData = std::make_shared(); @@ -1421,7 +1425,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, &compiledEffectData, &errors ); } - + if( FAILED( hr ) ) { // We failed compilation, let's print errors. @@ -1488,8 +1492,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, } - auto handleStrippedData = [&]( ID3DBlob* blob ) - { + auto handleStrippedData = [&]( ID3DBlob* blob ) { // No idea what happens when assigning strippedEffectData = effectData, with effectData now being a raw pointer, and not taking any chances... stage.shaderSize = uint32_t( blob->GetBufferSize() ); stage.shaderDataStr = g_stringTable.AddString( blob->GetBufferPointer(), blob->GetBufferSize() ); @@ -1499,10 +1502,10 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, { ZoneScopedN( "D3DStripShader" ); if( FAILED( D3DStripShader( - effectData->GetBufferPointer(), - effectData->GetBufferSize(), - D3DCOMPILER_STRIP_REFLECTION_DATA | D3DCOMPILER_STRIP_DEBUG_INFO | D3DCOMPILER_STRIP_TEST_BLOBS, - &strippedEffectData ) ) ) + effectData->GetBufferPointer(), + effectData->GetBufferSize(), + D3DCOMPILER_STRIP_REFLECTION_DATA | D3DCOMPILER_STRIP_DEBUG_INFO | D3DCOMPILER_STRIP_TEST_BLOBS, + &strippedEffectData ) ) ) { handleStrippedData( effectData ); } @@ -1523,7 +1526,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, return false; } } - + if( !DxReflection::ProcessReflection( state, reflection.p, compileOptions.useStaticSamplers, stage, result.annotations ) ) { return false; @@ -1557,10 +1560,14 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, if( listing.enabled() ) { listing.dict() - .literal( "profile" ).literal( profile ) - .literal( "original" ).dict() - .literal( "entryPoint" ).literal( patchEntryPoint ) - .literal( "source" ).literal( SanitizeCode( code ) ); + .literal( "profile" ) + .literal( profile ) + .literal( "original" ) + .dict() + .literal( "entryPoint" ) + .literal( patchEntryPoint ) + .literal( "source" ) + .literal( SanitizeCode( code ) ); PrintShaderOutListing( listing, effectData, reflection ); listing.end(); } @@ -1580,7 +1587,8 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, HULL_STAGE, DOMAIN_STAGE, GEOMETRY_STAGE, - PIXEL_STAGE, }; + PIXEL_STAGE, + }; for( int i = 0; i < 6; ++i ) { if( reflections[i] ) @@ -1621,8 +1629,10 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, continue; } listing.dict() - .literal( "name" ).literal( libNode->GetToken()->stringValue ) - .literal( "exports" ).list(); + .literal( "name" ) + .literal( libNode->GetToken()->stringValue ) + .literal( "exports" ) + .list(); Library library; library.payloadSize = 0; @@ -1639,11 +1649,11 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, if( childNode->GetNodeType() == NT_SHADER_ASSIGNMENT ) { ShaderExport shaderExport; - if( auto parsed = ParseRtShaderName( childNode->GetToken()->stringValue ) ) - { - shaderExport.type = parsed.value(); - } - else + if( auto parsed = ParseRtShaderName( childNode->GetToken()->stringValue ) ) + { + shaderExport.type = parsed.value(); + } + else { state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( childNode->GetToken()->stringValue ).c_str() ); return false; @@ -1656,7 +1666,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, { return false; } - for ( auto& gi : globalInputs ) + for( auto& gi : globalInputs ) { if( gi.symbol ) { @@ -1707,7 +1717,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, } CompilerInputStream os( state, ShadingLanguage::HLSL ); - os << HLSL{ state.GetTree(), & state.GetSymbolTable() }; + os << HLSL{ state.GetTree(), &state.GetSymbolTable() }; std::string code = os.str(); library.source = code; @@ -1764,7 +1774,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, { arguments[argumentsSize++] = DXC_ARG_DEBUG; //-Zi } - if ( g_skipOptimization ) + if( g_skipOptimization ) { arguments[argumentsSize++] = DXC_ARG_SKIP_OPTIMIZATIONS; //-Od } @@ -1779,12 +1789,12 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, CComPtr pCompileResult; HRESULT hrCompilation = compiler->Compile( &sourceBuffer, arguments, argumentsSize, nullptr, IID_PPV_ARGS( &pCompileResult ) ); - + if( FAILED( hrCompilation ) ) { // We failed compilation, let's print errors. syncData->libraryResource = nullptr; - + CComPtr errors; pCompileResult->GetOutput( DXC_OUT_ERRORS, IID_PPV_ARGS( &errors ), nullptr ); if( errors && errors->GetStringLength() > 0 ) @@ -1894,7 +1904,7 @@ bool EffectCompilerDX11::CompileEffect( const char* source, size_t sourceLength, CComPtr disassembly; if( SUCCEEDED( compiler->Disassemble( compiled, &disassembly ) ) ) { - listing.literal( "asm" ).literal( reinterpret_cast(disassembly->GetBufferPointer()) ); + listing.literal( "asm" ).literal( reinterpret_cast( disassembly->GetBufferPointer() ) ); } listing.end(); PrintStageInfo( listing, library.globalInputs, result ); diff --git a/shadercompiler/EffectCompilerDX12.h b/shadercompiler/EffectCompilerDX12.h index da6354854..2b92be973 100644 --- a/shadercompiler/EffectCompilerDX12.h +++ b/shadercompiler/EffectCompilerDX12.h @@ -6,7 +6,7 @@ #include "EffectCompilerDX11.h" -class EffectCompilerDX12: public EffectCompilerBase +class EffectCompilerDX12 : public EffectCompilerBase { public: bool Create(); diff --git a/shadercompiler/EffectCompilerMetal.cpp b/shadercompiler/EffectCompilerMetal.cpp index f810259fe..1c4e2b322 100644 --- a/shadercompiler/EffectCompilerMetal.cpp +++ b/shadercompiler/EffectCompilerMetal.cpp @@ -19,16 +19,16 @@ extern std::string g_metalToolsPath; -const char MSL_INCLUDE[] = +const char MSL_INCLUDE[] = #include "MSLInclude.h" -; + ; - // Values below must be synchronized with (propagated from) TrinityAL/metal/MetalWorkQueue.h -#define METAL_MAX_BOUND_BUFFERS 31 +// Values below must be synchronized with (propagated from) TrinityAL/metal/MetalWorkQueue.h +#define METAL_MAX_BOUND_BUFFERS 31 #define METAL_MAX_BOUND_TEXTURES 31 // 31+ on iOS, 128 on macOS #define METAL_MAX_BOUND_SAMPLERS 16 #define METAL_MAX_VERTEX_STREAMS 32 -#define METAL_MAX_RENDER_TARGETS 4 // Matches DX12 define (RENDER_TARGET_COUNT) +#define METAL_MAX_RENDER_TARGETS 4 // Matches DX12 define (RENDER_TARGET_COUNT) #define METAL_VERTEX_STREAM_BUFFER_COUNT 4 #define METAL_BUFFER_COUNT 27 @@ -49,906 +49,885 @@ extern bool g_printWarnings; namespace { - std::mutex s_fileMutex; +std::mutex s_fileMutex; - struct AtomicFn - { - std::string m_opMsl; - std::string m_opHlsl; - }; +struct AtomicFn +{ + std::string m_opMsl; + std::string m_opHlsl; +}; - inline CodeStream& operator<<( CodeStream& os, const AtomicFn& afun) - { - os << "void Interlocked" << afun.m_opHlsl << "(threadgroup uint& dest, uint value, thread uint& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(threadgroup uint& dest, uint value) {atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(threadgroup int& dest, int value, thread int& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(threadgroup int& dest, int value) {atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(device uint& dest, uint value, thread uint& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(device uint& dest, uint value) {atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(device int& dest, int value, thread int& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; - os << "void Interlocked" << afun.m_opHlsl << "(device int& dest, int value) {atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; - return os; - } +inline CodeStream& operator<<( CodeStream& os, const AtomicFn& afun ) +{ + os << "void Interlocked" << afun.m_opHlsl << "(threadgroup uint& dest, uint value, thread uint& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(threadgroup uint& dest, uint value) {atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(threadgroup int& dest, int value, thread int& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(threadgroup int& dest, int value) {atomic_fetch_" << afun.m_opMsl << "_explicit((threadgroup atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(device uint& dest, uint value, thread uint& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(device uint& dest, uint value) {atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_uint*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(device int& dest, int value, thread int& original_value) {original_value = atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; + os << "void Interlocked" << afun.m_opHlsl << "(device int& dest, int value) {atomic_fetch_" << afun.m_opMsl << "_explicit((device atomic_int*)&dest, value, memory_order_relaxed);}\n\n"; + return os; +} - void PatchStdlibFunctions( ParserState& state ) - { - Symbol* symbol = state.GetSymbolTable().Lookup( MakeInlineString( "lerp" ) ); - symbol->name = MakeInlineString( "mix" ); +void PatchStdlibFunctions( ParserState& state ) +{ + Symbol* symbol = state.GetSymbolTable().Lookup( MakeInlineString( "lerp" ) ); + symbol->name = MakeInlineString( "mix" ); - symbol = state.GetSymbolTable().Lookup( MakeInlineString( "frac" ) ); - symbol->name = MakeInlineString( "fract" ); + symbol = state.GetSymbolTable().Lookup( MakeInlineString( "frac" ) ); + symbol->name = MakeInlineString( "fract" ); - symbol = state.GetSymbolTable().Lookup( MakeInlineString( "ddx" ) ); - symbol->name = MakeInlineString( "dfdx" ); + symbol = state.GetSymbolTable().Lookup( MakeInlineString( "ddx" ) ); + symbol->name = MakeInlineString( "dfdx" ); - symbol = state.GetSymbolTable().Lookup( MakeInlineString( "ddy" ) ); - symbol->name = MakeInlineString( "dfdy" ); + symbol = state.GetSymbolTable().Lookup( MakeInlineString( "ddy" ) ); + symbol->name = MakeInlineString( "dfdy" ); - symbol = state.GetSymbolTable().Lookup( MakeInlineString( "atan2" ) ); - symbol->name = MakeInlineString( "precise::atan2" ); - } + symbol = state.GetSymbolTable().Lookup( MakeInlineString( "atan2" ) ); + symbol->name = MakeInlineString( "precise::atan2" ); +} - void ReplaceFloatModulo( ParserState& state ) - { - ZoneScoped; +void ReplaceFloatModulo( ParserState& state ) +{ + ZoneScoped; - state.GetTree()->Map( [&]( auto node ) { - if( node->GetNodeType() == NT_EXPRESSION && node->GetToken()->type == OP_PERCENT ) + state.GetTree()->Map( [&]( auto node ) { + if( node->GetNodeType() == NT_EXPRESSION && node->GetToken()->type == OP_PERCENT ) + { + if( node->GetChild( 1 )->GetType().IsScalarOrVector() && node->GetChild( 1 )->GetType().builtInType == OP_FLOAT ) { - if( node->GetChild( 1 )->GetType().IsScalarOrVector() && node->GetChild( 1 )->GetType().builtInType == OP_FLOAT ) + auto token = ScannerToken::ID( MakeInlineString( "fmod" ), node->GetLocation() ); + auto call = new ASTNode( NT_FUNCTION_CALL, node->GetLocation(), node->GetScope(), &token ); + call->AddChild( node->GetChild( 0 ) ); + call->AddChild( node->GetChild( 1 ) ); + std::string diagnosticMessage; + Symbol* symbol = state.GetSymbolTable().LookupFunction( token.stringValue, call, diagnosticMessage ); + if( symbol ) { - auto token = ScannerToken::ID( MakeInlineString( "fmod" ), node->GetLocation() ); - auto call = new ASTNode( NT_FUNCTION_CALL, node->GetLocation(), node->GetScope(), &token ); - call->AddChild( node->GetChild( 0 ) ); - call->AddChild( node->GetChild( 1 ) ); - std::string diagnosticMessage; - Symbol* symbol = state.GetSymbolTable().LookupFunction( token.stringValue, call, diagnosticMessage ); - if( symbol ) + if( symbol->intrinsicType ) { - if( symbol->intrinsicType ) - { - call->SetType( ( *symbol->intrinsicType )( call, -1 ) ); - } - else - { - call->SetType( symbol->type ); - } - call->SetSymbol( symbol ); - return call; + call->SetType( ( *symbol->intrinsicType )( call, -1 ) ); + } + else + { + call->SetType( symbol->type ); } + call->SetSymbol( symbol ); + return call; } } - return node; - } ); - } + } + return node; + } ); +} - void ConvertSyncFunctionsToMetal( ASTNode* node ) +void ConvertSyncFunctionsToMetal( ASTNode* node ) +{ + if( !node ) { - if( !node ) - { - return; - } + return; + } - if( node->GetNodeType() == NT_FUNCTION_CALL ) + if( node->GetNodeType() == NT_FUNCTION_CALL ) + { + Symbol* symbol = node->GetSymbol(); + if( symbol ) { - Symbol* symbol = node->GetSymbol(); - if( symbol ) + if( symbol->name == "GroupMemoryBarrierWithGroupSync" || + symbol->name == "threadgroup_barrier" ) { - if( symbol->name == "GroupMemoryBarrierWithGroupSync" || - symbol->name == "threadgroup_barrier" ) - { - symbol->name = MakeInlineString( "threadgroup_barrier" ); + symbol->name = MakeInlineString( "threadgroup_barrier" ); - ScannerToken token = {}; - token.type = OP_IN; - token.stringValue = MakeInlineString( "mem_flags::mem_threadgroup" ); - token.fileLocation = node->GetLocation(); + ScannerToken token = {}; + token.type = OP_IN; + token.stringValue = MakeInlineString( "mem_flags::mem_threadgroup" ); + token.fileLocation = node->GetLocation(); - ASTNode* arg = new ASTNode( NT_CONSTANT, node->GetLocation(), node->GetScope(), &token ); + ASTNode* arg = new ASTNode( NT_CONSTANT, node->GetLocation(), node->GetScope(), &token ); - node->AddChild( arg ); + node->AddChild( arg ); - return; - } + return; } } - - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) - { - ASTNode* child = node->GetChild( i ); - ConvertSyncFunctionsToMetal( child ); - } } - void ConvertSyncFunctionsToMetal( std::map& functions ) + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - ZoneScoped; + ASTNode* child = node->GetChild( i ); + ConvertSyncFunctionsToMetal( child ); + } +} - for( auto& it : functions ) - { - ASTNode* node = it.second; - assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); +void ConvertSyncFunctionsToMetal( std::map& functions ) +{ + ZoneScoped; - ASTNode* body = node->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + for( auto& it : functions ) + { + ASTNode* node = it.second; + assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); - ConvertSyncFunctionsToMetal( body ); - } + ASTNode* body = node->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); + + ConvertSyncFunctionsToMetal( body ); } +} - void CollectFunctions( ParserState& state, std::map& functions ) - { - ZoneScoped; +void CollectFunctions( ParserState& state, std::map& functions ) +{ + ZoneScoped; - ASTNode* root = state.GetTree(); - if( !root ) - { - return; - } + ASTNode* root = state.GetTree(); + if( !root ) + { + return; + } - for( size_t i = 0, n = root->GetChildrenCount(); i < n; ++i ) + for( size_t i = 0, n = root->GetChildrenCount(); i < n; ++i ) + { + ASTNode* node = root->GetChild( i ); + if( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ) { - ASTNode* node = root->GetChild( i ); - if( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ) - { - ASTNode* header = node->GetChild( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + ASTNode* header = node->GetChild( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - functions[header->GetSymbol()] = node; - } + functions[header->GetSymbol()] = node; } } +} - void AddStructDotPrefix( ASTNode* node, const std::set& structMembers, Symbol* symbol ) +void AddStructDotPrefix( ASTNode* node, const std::set& structMembers, Symbol* symbol ) +{ + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) + ASTNode* childNode = node->GetChild( i ); + if( !childNode ) { - ASTNode* childNode = node->GetChild( i ); - if( !childNode ) - { - continue; - } + continue; + } - if( childNode->GetNodeType() == NT_VAR_IDENTIFIER ) + if( childNode->GetNodeType() == NT_VAR_IDENTIFIER ) + { + auto it = structMembers.find( childNode->GetSymbol() ); + if( it != structMembers.end() ) { - auto it = structMembers.find( childNode->GetSymbol() ); - if( it != structMembers.end() ) - { - ScannerToken token = {}; - token.type = OP_DOT; + ScannerToken token = {}; + token.type = OP_DOT; - ASTNode* prefix = new ASTNode( NT_VAR_IDENTIFIER, childNode->GetLocation(), childNode->GetScope(), nullptr ); - prefix->SetSymbol( symbol ); + ASTNode* prefix = new ASTNode( NT_VAR_IDENTIFIER, childNode->GetLocation(), childNode->GetScope(), nullptr ); + prefix->SetSymbol( symbol ); - ASTNode* dotNode = new ASTNode( NT_POSTFIX_EXPRESSION, childNode->GetLocation(), childNode->GetScope(), &token ); - dotNode->AddChild( prefix ); - dotNode->AddChild( childNode ); - dotNode->SetType( childNode->GetType() ); + ASTNode* dotNode = new ASTNode( NT_POSTFIX_EXPRESSION, childNode->GetLocation(), childNode->GetScope(), &token ); + dotNode->AddChild( prefix ); + dotNode->AddChild( childNode ); + dotNode->SetType( childNode->GetType() ); - node->ReplaceChild( i, dotNode ); - } + node->ReplaceChild( i, dotNode ); } - - AddStructDotPrefix( childNode, structMembers, symbol ); } + + AddStructDotPrefix( childNode, structMembers, symbol ); } +} - void AddFunctionArgument( ASTNode* parent, const Symbol* functionSymbol, Symbol* arg ) - { - assert( parent ); +void AddFunctionArgument( ASTNode* parent, const Symbol* functionSymbol, Symbol* arg ) +{ + assert( parent ); - for( size_t i = 0, n = parent->GetChildrenCount(); i < n; ++i ) + for( size_t i = 0, n = parent->GetChildrenCount(); i < n; ++i ) + { + ASTNode* node = parent->GetChild( i ); + if( !node ) { - ASTNode* node = parent->GetChild( i ); - if( !node ) - { - continue; - } - - if( node->GetNodeType() == NT_FUNCTION_CALL && - node->GetSymbol() == functionSymbol ) - { - ASTNode* child = new ASTNode( NT_VAR_IDENTIFIER, node->GetLocation(), node->GetScope(), nullptr ); - child->SetSymbol( arg ); + continue; + } - node->InsertChild( 0, child ); - } + if( node->GetNodeType() == NT_FUNCTION_CALL && + node->GetSymbol() == functionSymbol ) + { + ASTNode* child = new ASTNode( NT_VAR_IDENTIFIER, node->GetLocation(), node->GetScope(), nullptr ); + child->SetSymbol( arg ); - AddFunctionArgument( node, functionSymbol, arg ); + node->InsertChild( 0, child ); } + + AddFunctionArgument( node, functionSymbol, arg ); } +} - void AddFunctionArgument( std::map& functions, const Symbol* functionSymbol, Symbol* arg ) +void AddFunctionArgument( std::map& functions, const Symbol* functionSymbol, Symbol* arg ) +{ + for( auto& it : functions ) { - for( auto& it : functions ) - { - ASTNode* node = it.second; - assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); + ASTNode* node = it.second; + assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); - ASTNode* body = node->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + ASTNode* body = node->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - AddFunctionArgument( body, functionSymbol, arg ); - } + AddFunctionArgument( body, functionSymbol, arg ); } +} - bool SearchFunctionsForGlobals( ASTNode* node, const std::set& structMembers, const std::map& functions, std::map& functionsWithGlobals, std::map& functionsWithoutGlobals ) +bool SearchFunctionsForGlobals( ASTNode* node, const std::set& structMembers, const std::map& functions, std::map& functionsWithGlobals, std::map& functionsWithoutGlobals ) +{ + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) + ASTNode* childNode = node->GetChild( i ); + if( !childNode ) + { + continue; + } + + if( childNode->GetNodeType() == NT_VAR_IDENTIFIER ) { - ASTNode* childNode = node->GetChild( i ); - if( !childNode ) + Symbol* symbol = childNode->GetSymbol(); + + auto it = structMembers.find( symbol ); + if( it != structMembers.end() ) { - continue; + return true; } - - if( childNode->GetNodeType() == NT_VAR_IDENTIFIER ) + } + else if( childNode->GetNodeType() == NT_FUNCTION_CALL ) + { + Symbol* symbol = childNode->GetSymbol(); + if( symbol ) { - Symbol* symbol = childNode->GetSymbol(); - - auto it = structMembers.find( symbol ); - if( it != structMembers.end() ) + if( functionsWithGlobals.find( symbol ) != functionsWithGlobals.end() ) { + // The function was aready marked as using globals. return true; } - } - else if( childNode->GetNodeType() == NT_FUNCTION_CALL ) - { - Symbol* symbol = childNode->GetSymbol(); - if( symbol ) + else if( functionsWithoutGlobals.find( symbol ) == functionsWithoutGlobals.end() ) { - if( functionsWithGlobals.find( symbol ) != functionsWithGlobals.end() ) - { - // The function was aready marked as using globals. - return true; - } - else if( functionsWithoutGlobals.find( symbol ) == functionsWithoutGlobals.end() ) + // If the function wasn't found in both lists it means either it was not checked yet + // or it's a standard library function. + auto it = functions.find( symbol ); + if( it != functions.end() ) { - // If the function wasn't found in both lists it means either it was not checked yet - // or it's a standard library function. - auto it = functions.find( symbol ); - if( it != functions.end() ) - { - ASTNode* definition = it->second; - assert( definition && definition->GetNodeType() == NT_FUNCTION_DEFINITION ); + ASTNode* definition = it->second; + assert( definition && definition->GetNodeType() == NT_FUNCTION_DEFINITION ); - [[maybe_unused]] ASTNode* header = definition->GetChild( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - assert( header->GetSymbol() == symbol ); + [[maybe_unused]] ASTNode* header = definition->GetChild( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + assert( header->GetSymbol() == symbol ); - ASTNode* body = definition->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + ASTNode* body = definition->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - bool found = SearchFunctionsForGlobals( body, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); - if( found ) - { - functionsWithGlobals.insert( { it->first, it->second } ); - return true; - } - else - { - functionsWithoutGlobals.insert( { it->first, it->second } ); - } + bool found = SearchFunctionsForGlobals( body, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); + if( found ) + { + functionsWithGlobals.insert( { it->first, it->second } ); + return true; + } + else + { + functionsWithoutGlobals.insert( { it->first, it->second } ); } } } } + } - // Search child nodes. - bool found = SearchFunctionsForGlobals( childNode, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); - if( found ) - { - return true; - } + // Search child nodes. + bool found = SearchFunctionsForGlobals( childNode, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); + if( found ) + { + return true; } - return false; } + return false; +} - void SearchFunctionsForGlobals( const std::set& structMembers, const std::map& functions, std::map& functionsWithGlobals, std::map& functionsWithoutGlobals ) +void SearchFunctionsForGlobals( const std::set& structMembers, const std::map& functions, std::map& functionsWithGlobals, std::map& functionsWithoutGlobals ) +{ + for( auto& it : functions ) { - for( auto& it : functions ) - { - ASTNode* node = it.second; - assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); + ASTNode* node = it.second; + assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); - [[maybe_unused]] ASTNode* header = node->GetChild( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + [[maybe_unused]] ASTNode* header = node->GetChild( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - // Is already processed? - if( functionsWithGlobals.find( it.first ) != functionsWithGlobals.end() || - functionsWithoutGlobals.find( it.first ) != functionsWithoutGlobals.end() ) - { - continue; - } + // Is already processed? + if( functionsWithGlobals.find( it.first ) != functionsWithGlobals.end() || + functionsWithoutGlobals.find( it.first ) != functionsWithoutGlobals.end() ) + { + continue; + } - ASTNode* body = node->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + ASTNode* body = node->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - bool found = SearchFunctionsForGlobals( body, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); - if( found ) - { - functionsWithGlobals.insert( { it.first, it.second } ); - } - else - { - functionsWithoutGlobals.insert( { it.first, it.second } ); - } + bool found = SearchFunctionsForGlobals( body, structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); + if( found ) + { + functionsWithGlobals.insert( { it.first, it.second } ); + } + else + { + functionsWithoutGlobals.insert( { it.first, it.second } ); } } +} - void PatchGlobalsInFunctions( std::map& functions, Symbol* typeSymbol, const InlineString& globalsName, const std::set& structMembers ) - { - assert( !structMembers.empty() ); +void PatchGlobalsInFunctions( std::map& functions, Symbol* typeSymbol, const InlineString& globalsName, const std::set& structMembers ) +{ + assert( !structMembers.empty() ); - std::map functionsWithGlobals; - std::map functionsWithoutGlobals; + std::map functionsWithGlobals; + std::map functionsWithoutGlobals; - SearchFunctionsForGlobals( structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); + SearchFunctionsForGlobals( structMembers, functions, functionsWithGlobals, functionsWithoutGlobals ); - ScannerToken token = {}; - token.type = OP_INOUT; + ScannerToken token = {}; + token.type = OP_INOUT; - for( auto& it : functionsWithGlobals ) - { - ASTNode* node = it.second; - assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); + for( auto& it : functionsWithGlobals ) + { + ASTNode* node = it.second; + assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); - ASTNode* header = node->GetChild( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + ASTNode* header = node->GetChild( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - ASTNode* body = node->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + ASTNode* body = node->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - Symbol* symbol = node->GetScope()->AddSymbol( globalsName, DISALOW_OVERRIDES ); - symbol->type.FromSymbol( typeSymbol ); - symbol->addressSpace = AddressSpace::Constant; - symbol->registerSpecifier = typeSymbol->registerSpecifier; + Symbol* symbol = node->GetScope()->AddSymbol( globalsName, DISALOW_OVERRIDES ); + symbol->type.FromSymbol( typeSymbol ); + symbol->addressSpace = AddressSpace::Constant; + symbol->registerSpecifier = typeSymbol->registerSpecifier; - token.fileLocation = header->GetLocation(); + token.fileLocation = header->GetLocation(); - Type type; - type.FromSymbol( typeSymbol ); + Type type; + type.FromSymbol( typeSymbol ); - ASTNode* globalsParam = new ASTNode( NT_FUNCTION_PARAMETER, header->GetLocation(), header->GetScope(), &token ); - globalsParam->SetType( type ); - globalsParam->SetSymbol( symbol ); + ASTNode* globalsParam = new ASTNode( NT_FUNCTION_PARAMETER, header->GetLocation(), header->GetScope(), &token ); + globalsParam->SetType( type ); + globalsParam->SetSymbol( symbol ); - header->InsertChild( 0, globalsParam ); + header->InsertChild( 0, globalsParam ); - AddFunctionArgument( functionsWithGlobals, header->GetSymbol(), symbol ); + AddFunctionArgument( functionsWithGlobals, header->GetSymbol(), symbol ); - AddStructDotPrefix( body, structMembers, symbol ); - } + AddStructDotPrefix( body, structMembers, symbol ); } +} - bool IsGlobalVarUsed( const std::map& functions, const InlineString& name, ASTNode* node ) +bool IsGlobalVarUsed( const std::map& functions, const InlineString& name, ASTNode* node ) +{ + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) + ASTNode* childNode = node->GetChild( i ); + if( !childNode ) { - ASTNode* childNode = node->GetChild( i ); - if( !childNode ) - { - continue; - } + continue; + } - if( childNode->GetSymbol() && - childNode->GetSymbol()->name == name ) - { - return true; - } + if( childNode->GetSymbol() && + childNode->GetSymbol()->name == name ) + { + return true; + } - bool isUsed = IsGlobalVarUsed( functions, name, childNode ); - if( isUsed ) - { - return true; - } + bool isUsed = IsGlobalVarUsed( functions, name, childNode ); + if( isUsed ) + { + return true; + } - // Recursively search in functions. - if( childNode->GetNodeType() == NT_FUNCTION_CALL && - childNode->GetSymbol() ) + // Recursively search in functions. + if( childNode->GetNodeType() == NT_FUNCTION_CALL && + childNode->GetSymbol() ) + { + auto it = functions.find( childNode->GetSymbol() ); + if( it != functions.end() ) { - auto it = functions.find( childNode->GetSymbol() ); - if( it != functions.end() ) - { - ASTNode* body = it->second->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + ASTNode* body = it->second->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - if( IsGlobalVarUsed( functions, name, body ) ) - { - return true; - } + if( IsGlobalVarUsed( functions, name, body ) ) + { + return true; } } } - - return false; } - void AddUsedGlobalsAsFunctionParams( std::map& functions, const std::vector& globals ) + return false; +} + +void AddUsedGlobalsAsFunctionParams( std::map& functions, const std::vector& globals ) +{ + ZoneScoped; + + for( auto& it : functions ) { - ZoneScoped; + ASTNode* node = it.second; + assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); - for( auto& it : functions ) - { - ASTNode* node = it.second; - assert( node && node->GetNodeType() == NT_FUNCTION_DEFINITION ); + ASTNode* header = node->GetChild( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - ASTNode* header = node->GetChild( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + ASTNode* body = node->GetChild( 1 ); + assert( body->GetNodeType() == NT_BLOCK ); - ASTNode* body = node->GetChild( 1 ); - assert( body->GetNodeType() == NT_BLOCK ); + for( auto globalIt : globals ) + { + Symbol* varSymbol = globalIt->GetSymbol(); + const Type& type = varSymbol->type; - for( auto globalIt : globals ) + bool used = IsGlobalVarUsed( functions, varSymbol->name, body ); + if( used ) { - Symbol* varSymbol = globalIt->GetSymbol(); - const Type& type = varSymbol->type; + ScannerToken token = {}; + token.type = OP_IN; + token.fileLocation = header->GetLocation(); - bool used = IsGlobalVarUsed( functions, varSymbol->name, body ); - if( used ) + Symbol* symbol = node->GetScope()->AddSymbol( varSymbol->name, DISALOW_OVERRIDES ); + + // If symbol is null it means the function already has a parameter with such name. + if( !symbol ) { - ScannerToken token = {}; - token.type = OP_IN; - token.fileLocation = header->GetLocation(); + // Make sure the existing symbol has the same type we expect. + symbol = node->GetScope()->Lookup( varSymbol->name ); + assert( symbol && symbol->type == varSymbol->type ); - Symbol* symbol = node->GetScope()->AddSymbol( varSymbol->name, DISALOW_OVERRIDES ); + continue; + } - // If symbol is null it means the function already has a parameter with such name. - if( !symbol ) - { - // Make sure the existing symbol has the same type we expect. - symbol = node->GetScope()->Lookup( varSymbol->name ); - assert( symbol && symbol->type == varSymbol->type ); + symbol->type = type; - continue; + // Textures and samplers do not need an address space attribute. + if( type.symbol && + type.symbol->definition && + type.symbol->definition->GetNodeType() == NT_STRUCT ) + { + if( type.storageClass == OP_GROUPSHARED ) + { + symbol->addressSpace = AddressSpace::Threadgroup; } - - symbol->type = type; - - // Textures and samplers do not need an address space attribute. - if( type.symbol && - type.symbol->definition && - type.symbol->definition->GetNodeType() == NT_STRUCT ) + else { - if( type.storageClass == OP_GROUPSHARED ) - { - symbol->addressSpace = AddressSpace::Threadgroup; - } - else - { - symbol->addressSpace = AddressSpace::Constant; - } + symbol->addressSpace = AddressSpace::Constant; + } - if( varSymbol->type.symbol && type.arrayDimensions == 0) - { - token.type = OP_INOUT; - } + if( varSymbol->type.symbol && type.arrayDimensions == 0 ) + { + token.type = OP_INOUT; } - else + } + else + { + switch( type.builtInType ) { - switch( type.builtInType ) + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + symbol->addressSpace = AddressSpace::Device; + break; + default: + if( type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) ) { - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: symbol->addressSpace = AddressSpace::Device; - break; - default: - if (type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) ) - { - symbol->addressSpace = AddressSpace::Device; - } - else if( type.storageClass == OP_GROUPSHARED ) + } + else if( type.storageClass == OP_GROUPSHARED ) + { + symbol->addressSpace = AddressSpace::Threadgroup; + if( type.arrayDimensions == 0 ) { - symbol->addressSpace = AddressSpace::Threadgroup; - if( type.arrayDimensions == 0 ) - { - token.type = OP_INOUT; - } + token.type = OP_INOUT; } - break; } + break; } + } - ASTNode* param = new ASTNode( NT_FUNCTION_PARAMETER, header->GetLocation(), header->GetScope(), &token ); - param->SetType( varSymbol->type ); - param->SetSymbol( symbol ); - - ASTNode* bracketList = globalIt->GetChildOrNull( 0 ); - if( bracketList ) - { - param->AddChild( bracketList->Copy() ); - } - header->InsertChild( 0, param ); + ASTNode* param = new ASTNode( NT_FUNCTION_PARAMETER, header->GetLocation(), header->GetScope(), &token ); + param->SetType( varSymbol->type ); + param->SetSymbol( symbol ); - AddFunctionArgument( functions, header->GetSymbol(), symbol ); + ASTNode* bracketList = globalIt->GetChildOrNull( 0 ); + if( bracketList ) + { + param->AddChild( bracketList->Copy() ); } + header->InsertChild( 0, param ); + + AddFunctionArgument( functions, header->GetSymbol(), symbol ); } } } +} - void StripSemanticsInsideStucts( ASTNode* structNode ) +void StripSemanticsInsideStucts( ASTNode* structNode ) +{ + for( auto memberNode : structNode->GetChildren() ) { - for( auto memberNode : structNode->GetChildren() ) + assert( memberNode && memberNode->GetNodeType() == NT_STRUCT_MEMBER ); + + for( auto childNode : memberNode->GetChildren() ) { - assert( memberNode && memberNode->GetNodeType() == NT_STRUCT_MEMBER ); + assert( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ); - for( auto childNode : memberNode->GetChildren() ) + Symbol* symbol = childNode->GetSymbol(); + if( symbol && symbol->semantic ) { - assert( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ); - - Symbol* symbol = childNode->GetSymbol(); - if( symbol && symbol->semantic ) - { - symbol->semantic.start = symbol->semantic.end = nullptr; - } + symbol->semantic.start = symbol->semantic.end = nullptr; } } } +} - void CollectGlobals( - ParserState& state, - std::map& functions, - std::vector& globals ) +void CollectGlobals( + ParserState& state, + std::map& functions, + std::vector& globals ) +{ + ZoneScoped; + + ASTNode* root = state.GetTree(); + if( !root ) { - ZoneScoped; + return; + } + + ASTNode* globalsStruct = nullptr; + ASTNode* uiStruct = nullptr; - ASTNode* root = state.GetTree(); - if( !root ) + std::set globalsStructMembers; + std::set uiStructMembers; + std::vector cbuffers; + + // Move all globals to the new buffer. + for( size_t i = 0; i < root->GetChildrenCount(); ++i ) + { + ASTNode* node = root->GetChild( i ); + if( node && node->GetNodeType() == NT_CBUFFER ) { - return; - } + auto cbufferStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); + + Symbol* globalsSymbol = node->GetSymbol(); + globalsSymbol->isTypeName = true; + globalsSymbol->definition = cbufferStruct; + if( globalsSymbol->registerSpecifier.empty() ) + { + globalsSymbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::CBuffer, 0 ); + } + else + { + globalsSymbol->registerSpecifier.begin()->second.registerType = MetalRegister::CBuffer; + } - ASTNode* globalsStruct = nullptr; - ASTNode* uiStruct = nullptr; + cbufferStruct->SetSymbol( globalsSymbol ); - std::set globalsStructMembers; - std::set uiStructMembers; - std::vector cbuffers; + for( size_t j = 0; j < node->GetChildrenCount(); ++j ) + { + node->GetChild( j )->SetNodeType( NT_STRUCT_MEMBER ); + cbufferStruct->AddChild( node->GetChild( j ) ); + } - // Move all globals to the new buffer. - for( size_t i = 0; i < root->GetChildrenCount(); ++i ) + state.GetTree()->ReplaceChild( i, cbufferStruct ); + cbuffers.push_back( cbufferStruct ); + continue; + } + if( node && node->GetNodeType() == NT_VAR_DECLARATION_LIST ) { - ASTNode* node = root->GetChild( i ); - if( node && node->GetNodeType() == NT_CBUFFER ) - { - auto cbufferStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); - - Symbol* globalsSymbol = node->GetSymbol(); - globalsSymbol->isTypeName = true; - globalsSymbol->definition = cbufferStruct; - if( globalsSymbol->registerSpecifier.empty() ) - { - globalsSymbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::CBuffer, 0 ); - } - else - { - globalsSymbol->registerSpecifier.begin()->second.registerType = MetalRegister::CBuffer; - } - - cbufferStruct->SetSymbol( globalsSymbol ); - - for( size_t j = 0; j < node->GetChildrenCount(); ++j ) - { - node->GetChild( j )->SetNodeType( NT_STRUCT_MEMBER ); - cbufferStruct->AddChild( node->GetChild( j ) ); - } - - state.GetTree()->ReplaceChild( i, cbufferStruct ); - cbuffers.push_back( cbufferStruct ); - continue; - } - if( node && node->GetNodeType() == NT_VAR_DECLARATION_LIST ) + ASTNode* childNode = node->GetChildOrNull( 0 ); + if( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ) { - ASTNode* childNode = node->GetChildOrNull( 0 ); - if( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ) + Symbol* symbol = childNode->GetSymbol(); + const Type& type = childNode->GetType(); + + if( childNode->GetType().modifier == OP_CONST ) + { + symbol->addressSpace = AddressSpace::Constant; + } + else if( childNode->GetType().storageClass == OP_GROUPSHARED ) + { + symbol->addressSpace = AddressSpace::Threadgroup; + + globals.push_back( childNode ); + root->RemoveChild( i ); + --i; + } + else if( symbol->name == "g_uiTransforms" ) { - Symbol* symbol = childNode->GetSymbol(); - const Type& type = childNode->GetType(); + symbol->registerSpecifier.clear(); - if( childNode->GetType().modifier == OP_CONST ) + if( !uiStruct ) { - symbol->addressSpace = AddressSpace::Constant; + uiStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); + + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::CBuffer; + reg.registerNumber = GetCBufferIndex( MakeInlineString( "g_uiTransforms" ) ); + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; + + Symbol* uiSymbol = state.GetSymbolTable().AddSymbol( MakeInlineString( "UITransforms" ) ); + uiSymbol->isTypeName = true; + uiSymbol->definition = uiStruct; + uiSymbol->registerSpecifier[reg.shaderProfile] = reg; + + uiStruct->SetSymbol( uiSymbol ); + + node->SetNodeType( NT_STRUCT_MEMBER ); + uiStruct->AddChild( node ); + + root->ReplaceChild( i, uiStruct ); } - else if(childNode->GetType().storageClass == OP_GROUPSHARED) + else { - symbol->addressSpace = AddressSpace::Threadgroup; + node->SetNodeType( NT_STRUCT_MEMBER ); + uiStruct->AddChild( node ); - globals.push_back(childNode); root->RemoveChild( i ); --i; } - else if( symbol->name == "g_uiTransforms" ) + + uiStructMembers.insert( symbol ); + } + else + { + if( type.symbol && + type.symbol->definition && + type.symbol->definition->GetNodeType() == NT_STRUCT ) { - symbol->registerSpecifier.clear(); + assert( symbol ); - if( !uiStruct ) + // Strip cbuffer registers. + for( auto& it : symbol->registerSpecifier ) { - uiStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); - - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::CBuffer; - reg.registerNumber = GetCBufferIndex( MakeInlineString( "g_uiTransforms" ) ); - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - - Symbol* uiSymbol = state.GetSymbolTable().AddSymbol( MakeInlineString( "UITransforms" ) ); - uiSymbol->isTypeName = true; - uiSymbol->definition = uiStruct; - uiSymbol->registerSpecifier[reg.shaderProfile] = reg; - - uiStruct->SetSymbol( uiSymbol ); - - node->SetNodeType( NT_STRUCT_MEMBER ); - uiStruct->AddChild( node ); - - root->ReplaceChild( i, uiStruct ); + if( it.second.registerType == MetalRegister::CBuffer ) + { + symbol->registerSpecifier.erase( it.first ); + break; + } } - else - { - node->SetNodeType( NT_STRUCT_MEMBER ); - uiStruct->AddChild( node ); - root->RemoveChild( i ); - --i; - } + globals.push_back( childNode ); + + root->RemoveChild( i ); + --i; + } + else if( type.builtInType == OP_BUFFER || + type.builtInType == OP_STRUCTUREDBUFFER || + type.builtInType == OP_RWBUFFER || + type.builtInType == OP_RWSTRUCTUREDBUFFER || + type.builtInType == OP_RAYTRACING_ACCELERATION_STRUCTURE || + type.builtInType == OP_TEXTURE || + type.builtInType == OP_TEXTURE1D || + type.builtInType == OP_TEXTURE1DARRAY || + type.builtInType == OP_TEXTURE2D || + type.builtInType == OP_TEXTURE2DARRAY || + type.builtInType == OP_TEXTURE3D || + // type.builtInType == OP_TEXTURE3DARRAY || + type.builtInType == OP_TEXTURECUBE || + type.builtInType == OP_TEXTURECUBEARRAY || + type.builtInType == OP_TEXTURE2DMS || + type.builtInType == OP_TEXTURE2DMSARRAY || + type.builtInType == OP_RWTEXTURE1D || + type.builtInType == OP_RWTEXTURE1DARRAY || + type.builtInType == OP_RWTEXTURE2D || + type.builtInType == OP_RWTEXTURE2DARRAY || + type.builtInType == OP_RWTEXTURE3D + // type.builtInType == OP_RWTEXTURE3DARRAY || + ) + { + globals.push_back( childNode ); - uiStructMembers.insert( symbol ); + root->RemoveChild( i ); + --i; } - else + else if( type.IsSampler() ) { - if( type.symbol && - type.symbol->definition && - type.symbol->definition->GetNodeType() == NT_STRUCT ) + bool isDynamic = true; + Sampler sampler; + StaticSampler staticSampler = {}; + if( GetSamplerState( state, childNode, sampler ) ) { - assert( symbol ); - - // Strip cbuffer registers. - for( auto& it : symbol->registerSpecifier ) + isDynamic = sampler.isDynamic; + if( !isDynamic ) { - if( it.second.registerType == MetalRegister::CBuffer ) + if( !ConvertToStaticSampler( staticSampler, sampler ) ) { - symbol->registerSpecifier.erase( it.first ); - break; + isDynamic = true; } } + } + if( isDynamic ) + { globals.push_back( childNode ); root->RemoveChild( i ); --i; } - else if( type.builtInType == OP_BUFFER || - type.builtInType == OP_STRUCTUREDBUFFER || - type.builtInType == OP_RWBUFFER || - type.builtInType == OP_RWSTRUCTUREDBUFFER || - type.builtInType == OP_RAYTRACING_ACCELERATION_STRUCTURE || - type.builtInType == OP_TEXTURE || - type.builtInType == OP_TEXTURE1D || - type.builtInType == OP_TEXTURE1DARRAY || - type.builtInType == OP_TEXTURE2D || - type.builtInType == OP_TEXTURE2DARRAY || - type.builtInType == OP_TEXTURE3D || - // type.builtInType == OP_TEXTURE3DARRAY || - type.builtInType == OP_TEXTURECUBE || - type.builtInType == OP_TEXTURECUBEARRAY || - type.builtInType == OP_TEXTURE2DMS || - type.builtInType == OP_TEXTURE2DMSARRAY || - type.builtInType == OP_RWTEXTURE1D || - type.builtInType == OP_RWTEXTURE1DARRAY || - type.builtInType == OP_RWTEXTURE2D || - type.builtInType == OP_RWTEXTURE2DARRAY || - type.builtInType == OP_RWTEXTURE3D - // type.builtInType == OP_RWTEXTURE3DARRAY || - ) + else { - globals.push_back( childNode ); - - root->RemoveChild( i ); - --i; + symbol->addressSpace = AddressSpace::Constexpr; + childNode->GetChild( 1 )->m_extraData = new StaticSampler( staticSampler ); } - else if( type.IsSampler() ) + } + else + { + if( !globalsStruct ) { - bool isDynamic = true; - Sampler sampler; - StaticSampler staticSampler = {}; - if( GetSamplerState( state, childNode, sampler ) ) - { - isDynamic = sampler.isDynamic; - if( !isDynamic ) - { - if( !ConvertToStaticSampler( staticSampler, sampler ) ) - { - isDynamic = true; - } - } - } + InlineString name = MakeInlineString( "GlobalsData" ); + globalsStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); - if( isDynamic ) - { - globals.push_back( childNode ); + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::CBuffer; + reg.registerNumber = GetCBufferIndex( name ); + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; - root->RemoveChild( i ); - --i; - } - else - { - symbol->addressSpace = AddressSpace::Constexpr; - childNode->GetChild( 1 )->m_extraData = new StaticSampler( staticSampler ); - } + Symbol* globalsSymbol = state.GetSymbolTable().AddSymbol( name ); + globalsSymbol->isTypeName = true; + globalsSymbol->definition = globalsStruct; + globalsSymbol->registerSpecifier[reg.shaderProfile] = reg; + + globalsStruct->SetSymbol( globalsSymbol ); + + node->SetNodeType( NT_STRUCT_MEMBER ); + globalsStruct->AddChild( node ); + + root->ReplaceChild( i, globalsStruct ); } else { - if( !globalsStruct ) - { - InlineString name = MakeInlineString( "GlobalsData" ); - globalsStruct = new ASTNode( NT_STRUCT, node->GetLocation(), node->GetScope(), nullptr ); - - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::CBuffer; - reg.registerNumber = GetCBufferIndex( name ); - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - - Symbol* globalsSymbol = state.GetSymbolTable().AddSymbol( name ); - globalsSymbol->isTypeName = true; - globalsSymbol->definition = globalsStruct; - globalsSymbol->registerSpecifier[reg.shaderProfile] = reg; - - globalsStruct->SetSymbol( globalsSymbol ); - - node->SetNodeType( NT_STRUCT_MEMBER ); - globalsStruct->AddChild( node ); - - root->ReplaceChild( i, globalsStruct ); - } - else - { - node->SetNodeType( NT_STRUCT_MEMBER ); - globalsStruct->AddChild( node ); - - root->RemoveChild( i ); - --i; - } + node->SetNodeType( NT_STRUCT_MEMBER ); + globalsStruct->AddChild( node ); - globalsStructMembers.insert( symbol ); + root->RemoveChild( i ); + --i; } + + globalsStructMembers.insert( symbol ); } } } } + } - if( globalsStruct && !globalsStructMembers.empty() ) - { - PatchGlobalsInFunctions( functions, globalsStruct->GetSymbol(), MakeInlineString( "Globals" ), globalsStructMembers ); - - StripSemanticsInsideStucts( globalsStruct ); - } - - if( uiStruct && !uiStructMembers.empty() ) - { - PatchGlobalsInFunctions( functions, uiStruct->GetSymbol(), MakeInlineString( "UI" ), uiStructMembers ); + if( globalsStruct && !globalsStructMembers.empty() ) + { + PatchGlobalsInFunctions( functions, globalsStruct->GetSymbol(), MakeInlineString( "Globals" ), globalsStructMembers ); - StripSemanticsInsideStucts( uiStruct ); - } - - for( auto cbuffer : cbuffers ) - { - std::set members; - for( auto child : cbuffer->GetChildren() ) - { - for( auto name : child->GetChildren() ) - { - members.insert( name->GetSymbol() ); - } - } - - PatchGlobalsInFunctions( functions, cbuffer->GetSymbol(), state.AllocateNameWithPrefix( "cbuffer" ), members ); - } + StripSemanticsInsideStucts( globalsStruct ); } - ASTNode* CreateShaderTableArgument( ParserState& state, const Type& payloadType, ScopeSymbolTable* scope ) + if( uiStruct && !uiStructMembers.empty() ) { - std::string shaderTableTypeName = "ShaderTableT<" + payloadType.ToString() + ",__RtGlobalInput>"; - auto t = scope->AddSymbol( state.AllocateName( shaderTableTypeName.c_str() ), DISALOW_OVERRIDES ); - t->isTypeName = true; - - auto shaderTable = state.NewNode( NT_FUNCTION_PARAMETER ); - auto symbol = scope->AddSymbol( MakeInlineString( "__rtShaderTable" ), DISALOW_OVERRIDES ); - symbol->type = TypeFromSymbol( t ); - symbol->definition = shaderTable; - symbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::SRV, 2 ); - symbol->addressSpace = AddressSpace::Constant; - shaderTable->SetType( symbol->type ); - shaderTable->SetSymbol( symbol ); - shaderTable->AddChild( nullptr ); - shaderTable->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); + PatchGlobalsInFunctions( functions, uiStruct->GetSymbol(), MakeInlineString( "UI" ), uiStructMembers ); - return shaderTable; + StripSemanticsInsideStucts( uiStruct ); } - void AddShaderTableArguments( ParserState& state, const std::map& functions ) + for( auto cbuffer : cbuffers ) { - auto traceRays = find_if( begin( state.GetDX9Functions() ), end( state.GetDX9Functions() ), []( auto& name ) { return strcmp( name.first, "TraceRay" ) == 0; } ); - if( traceRays == end( state.GetDX9Functions() ) ) + std::set members; + for( auto child : cbuffer->GetChildren() ) { - return; + for( auto name : child->GetChildren() ) + { + members.insert( name->GetSymbol() ); + } } - // Find TraceRay calls and map them to the payload type. - std::map payloadTypes; - // Maps function to the shader table argument symbol. - std::map patchedHeaders; - patchedHeaders[traceRays->second] = nullptr; + PatchGlobalsInFunctions( functions, cbuffer->GetSymbol(), state.AllocateNameWithPrefix( "cbuffer" ), members ); + } +} + +ASTNode* CreateShaderTableArgument( ParserState& state, const Type& payloadType, ScopeSymbolTable* scope ) +{ + std::string shaderTableTypeName = "ShaderTableT<" + payloadType.ToString() + ",__RtGlobalInput>"; + auto t = scope->AddSymbol( state.AllocateName( shaderTableTypeName.c_str() ), DISALOW_OVERRIDES ); + t->isTypeName = true; + + auto shaderTable = state.NewNode( NT_FUNCTION_PARAMETER ); + auto symbol = scope->AddSymbol( MakeInlineString( "__rtShaderTable" ), DISALOW_OVERRIDES ); + symbol->type = TypeFromSymbol( t ); + symbol->definition = shaderTable; + symbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::SRV, 2 ); + symbol->addressSpace = AddressSpace::Constant; + shaderTable->SetType( symbol->type ); + shaderTable->SetSymbol( symbol ); + shaderTable->AddChild( nullptr ); + shaderTable->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); + + return shaderTable; +} + +void AddShaderTableArguments( ParserState& state, const std::map& functions ) +{ + auto traceRays = find_if( begin( state.GetDX9Functions() ), end( state.GetDX9Functions() ), []( auto& name ) { return strcmp( name.first, "TraceRay" ) == 0; } ); + if( traceRays == end( state.GetDX9Functions() ) ) + { + return; + } + + // Find TraceRay calls and map them to the payload type. + std::map payloadTypes; + // Maps function to the shader table argument symbol. + std::map patchedHeaders; + patchedHeaders[traceRays->second] = nullptr; - // Add shader table argument to functions that end up calling TraceRay. - bool modified = true; - while( modified ) + // Add shader table argument to functions that end up calling TraceRay. + bool modified = true; + while( modified ) + { + modified = false; + for( auto& func : functions ) { - modified = false; - for( auto& func : functions ) - { - func.second->Map( [&]( ASTNode* node ) { - if( node->GetNodeType() == NT_FUNCTION_CALL ) + func.second->Map( [&]( ASTNode* node ) { + if( node->GetNodeType() == NT_FUNCTION_CALL ) + { + Symbol* funcSymbol = node->GetSymbol(); + if( patchedHeaders.find( funcSymbol ) != end( patchedHeaders ) ) { - Symbol* funcSymbol = node->GetSymbol(); - if( patchedHeaders.find( funcSymbol ) != end( patchedHeaders ) ) + if( patchedHeaders.find( func.first ) == patchedHeaders.end() ) { - if( patchedHeaders.find( func.first ) == patchedHeaders.end() ) + Type payloadType; + if( funcSymbol == traceRays->second ) { - Type payloadType; - if( funcSymbol == traceRays->second ) - { - if( auto payloadArg = node->GetChildOrNull( 7 ) ) - { - payloadType = payloadArg->GetType(); - } - } - else + if( auto payloadArg = node->GetChildOrNull( 7 ) ) { - payloadType = payloadTypes[funcSymbol]; + payloadType = payloadArg->GetType(); } - auto shaderTable = CreateShaderTableArgument( state, payloadType, node->GetScope() ); - - ASTNode* header = func.second->GetChild( 0 ); - header->InsertChild( 0, shaderTable ); - patchedHeaders[func.first] = shaderTable->GetSymbol(); - payloadTypes[func.first] = payloadType; - - modified = true; } - } - } - return node; - } ); - } - } + else + { + payloadType = payloadTypes[funcSymbol]; + } + auto shaderTable = CreateShaderTableArgument( state, payloadType, node->GetScope() ); - // Add shader table argument to function calls. - for( auto& func : functions ) - { - if( patchedHeaders.find( func.first ) == patchedHeaders.end() ) - { - continue; - } - func.second->Map( [&]( ASTNode* node ) { - if( node->GetNodeType() == NT_FUNCTION_CALL ) - { - Symbol* symbol = node->GetSymbol(); - if( symbol && patchedHeaders.find( symbol ) != end( patchedHeaders ) ) - { - node->InsertChild( 0, NewVarIdentifier( state, patchedHeaders[func.first] ) ); + ASTNode* header = func.second->GetChild( 0 ); + header->InsertChild( 0, shaderTable ); + patchedHeaders[func.first] = shaderTable->GetSymbol(); + payloadTypes[func.first] = payloadType; + + modified = true; + } } } return node; @@ -956,754 +935,825 @@ namespace } } - void PrintAnnotations( YamlOutput& listing, const std::map& annotations ) + // Add shader table argument to function calls. + for( auto& func : functions ) { - if( !listing.enabled() ) + if( patchedHeaders.find( func.first ) == patchedHeaders.end() ) { - return; + continue; } - listing.literal( "annotations" ).list(); - for( auto a = annotations.begin(); a != annotations.end(); ++a ) - { - listing.dict() - .literal( "name" ).literal( g_stringTable.GetString( a->first ) ) - .literal( "annotationType" ); - switch( a->second.type ) + func.second->Map( [&]( ASTNode* node ) { + if( node->GetNodeType() == NT_FUNCTION_CALL ) { - case ANNOTATION_TYPE_BOOL: - listing - .literal( "bool" ) - .literal( "value" ).literal( a->second.intValue != 0 ); - break; - case ANNOTATION_TYPE_INT: - listing - .literal( "int" ) - .literal( "value" ).literal( a->second.intValue ); - break; - case ANNOTATION_TYPE_FLOAT: - listing - .literal( "float" ) - .literal( "value" ).literal( a->second.floatValue ); - break; - default: - listing - .literal( "string" ) - .literal( "value" ).literal( g_stringTable.GetString( a->second.stringValue ) ); - break; + Symbol* symbol = node->GetSymbol(); + if( symbol && patchedHeaders.find( symbol ) != end( patchedHeaders ) ) + { + node->InsertChild( 0, NewVarIdentifier( state, patchedHeaders[func.first] ) ); + } } - listing.end(); + return node; + } ); + } +} + +void PrintAnnotations( YamlOutput& listing, const std::map& annotations ) +{ + if( !listing.enabled() ) + { + return; + } + listing.literal( "annotations" ).list(); + for( auto a = annotations.begin(); a != annotations.end(); ++a ) + { + listing.dict() + .literal( "name" ) + .literal( g_stringTable.GetString( a->first ) ) + .literal( "annotationType" ); + switch( a->second.type ) + { + case ANNOTATION_TYPE_BOOL: + listing + .literal( "bool" ) + .literal( "value" ) + .literal( a->second.intValue != 0 ); + break; + case ANNOTATION_TYPE_INT: + listing + .literal( "int" ) + .literal( "value" ) + .literal( a->second.intValue ); + break; + case ANNOTATION_TYPE_FLOAT: + listing + .literal( "float" ) + .literal( "value" ) + .literal( a->second.floatValue ); + break; + default: + listing + .literal( "string" ) + .literal( "value" ) + .literal( g_stringTable.GetString( a->second.stringValue ) ); + break; } listing.end(); } + listing.end(); +} - void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectData& result ) +void PrintStageInfo( YamlOutput& listing, const StageData& stage, const EffectData& result ) +{ + if( !listing.enabled() ) { - if( !listing.enabled() ) - { - return; - } - if( !stage.constants.empty() ) - { - listing.literal( "constants" ).list(); - for( auto it = stage.constants.begin(); it != stage.constants.end(); ++it ) - { - listing.dict() - .literal( "name" ).literal( g_stringTable.GetString( it->name ) ) - .literal( "constantType" ).literal( ToString( it->type ) ) - // .literal( "offset" ).literal( it->offset ) - // .literal( "size" ).literal( it->size ) - .literal( "dimension" ).literal( it->dimension ) - .literal( "arrayElements" ).literal( it->elements ) - .literal( "autoregister" ).literal( it->isAutoregister ) - .literal( "sRGB" ).literal( it->isSRGB ); - auto annotations = result.annotations.find( it->name ); - if( annotations != result.annotations.end() ) - { - PrintAnnotations( listing, annotations->second.annotations ); - } - listing.end(); - } - listing.end(); - } - if( !stage.samplers.empty() ) + return; + } + if( !stage.constants.empty() ) + { + listing.literal( "constants" ).list(); + for( auto it = stage.constants.begin(); it != stage.constants.end(); ++it ) { - listing.literal( "samplers" ).list(); - for( auto it = stage.samplers.begin(); it != stage.samplers.end(); ++it ) - { - listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "filter" ).literal( int( it->second.filter ) ) - .literal( "comparison" ).literal( int( it->second.comparison ) ) - .literal( "minFilter" ).literal( int( it->second.minFilter ) ) - .literal( "magFilter" ).literal( int( it->second.magFilter ) ) - .literal( "mipFilter" ).literal( int( it->second.mipFilter ) ) - .literal( "addressU" ).literal( int( it->second.addressU ) ) - .literal( "addressV" ).literal( int( it->second.addressV ) ) - .literal( "addressW" ).literal( int( it->second.addressW ) ) - .literal( "mipLODBias" ).literal( it->second.mipLODBias ) - .literal( "maxAnisotropy" ).literal( int( it->second.maxAnisotropy ) ) - .literal( "comparisonFunc" ).literal( int( it->second.comparisonFunc ) ) - .literal( "borderColor" ).list().literal( it->second.borderColor.x ).literal( it->second.borderColor.y ).literal( it->second.borderColor.z ).literal( it->second.borderColor.w ).end() - .literal( "minLOD" ).literal( it->second.minLOD ) - .literal( "maxLOD" ).literal( it->second.maxLOD ) - .literal( "srgbTexture" ).literal( it->second.srgbTexture != 0 ); - auto annotations = result.annotations.find( it->second.name ); - if( annotations != result.annotations.end() ) - { - PrintAnnotations( listing, annotations->second.annotations ); - } - listing.end(); + listing.dict() + .literal( "name" ) + .literal( g_stringTable.GetString( it->name ) ) + .literal( "constantType" ) + .literal( ToString( it->type ) ) + // .literal( "offset" ).literal( it->offset ) + // .literal( "size" ).literal( it->size ) + .literal( "dimension" ) + .literal( it->dimension ) + .literal( "arrayElements" ) + .literal( it->elements ) + .literal( "autoregister" ) + .literal( it->isAutoregister ) + .literal( "sRGB" ) + .literal( it->isSRGB ); + auto annotations = result.annotations.find( it->name ); + if( annotations != result.annotations.end() ) + { + PrintAnnotations( listing, annotations->second.annotations ); } listing.end(); } - if( !stage.textures.empty() ) + listing.end(); + } + if( !stage.samplers.empty() ) + { + listing.literal( "samplers" ).list(); + for( auto it = stage.samplers.begin(); it != stage.samplers.end(); ++it ) { - listing.literal( "textures" ).list(); - for( auto it = stage.textures.begin(); it != stage.textures.end(); ++it ) - { - listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "textureType" ).literal( it->second.type ) - .literal( "autoregister" ).literal( it->second.isAutoregister ) - .literal( "sRGB" ).literal( it->second.isSRGB ); - auto annotations = result.annotations.find( it->second.name ); - if( annotations != result.annotations.end() ) - { - PrintAnnotations( listing, annotations->second.annotations ); - } - listing.end(); + listing.dict() + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "filter" ) + .literal( int( it->second.filter ) ) + .literal( "comparison" ) + .literal( int( it->second.comparison ) ) + .literal( "minFilter" ) + .literal( int( it->second.minFilter ) ) + .literal( "magFilter" ) + .literal( int( it->second.magFilter ) ) + .literal( "mipFilter" ) + .literal( int( it->second.mipFilter ) ) + .literal( "addressU" ) + .literal( int( it->second.addressU ) ) + .literal( "addressV" ) + .literal( int( it->second.addressV ) ) + .literal( "addressW" ) + .literal( int( it->second.addressW ) ) + .literal( "mipLODBias" ) + .literal( it->second.mipLODBias ) + .literal( "maxAnisotropy" ) + .literal( int( it->second.maxAnisotropy ) ) + .literal( "comparisonFunc" ) + .literal( int( it->second.comparisonFunc ) ) + .literal( "borderColor" ) + .list() + .literal( it->second.borderColor.x ) + .literal( it->second.borderColor.y ) + .literal( it->second.borderColor.z ) + .literal( it->second.borderColor.w ) + .end() + .literal( "minLOD" ) + .literal( it->second.minLOD ) + .literal( "maxLOD" ) + .literal( it->second.maxLOD ) + .literal( "srgbTexture" ) + .literal( it->second.srgbTexture != 0 ); + auto annotations = result.annotations.find( it->second.name ); + if( annotations != result.annotations.end() ) + { + PrintAnnotations( listing, annotations->second.annotations ); } listing.end(); } - if( !stage.uavs.empty() ) + listing.end(); + } + if( !stage.textures.empty() ) + { + listing.literal( "textures" ).list(); + for( auto it = stage.textures.begin(); it != stage.textures.end(); ++it ) { - listing.literal( "uavs" ).list(); - for( auto it = stage.uavs.begin(); it != stage.uavs.end(); ++it ) - { - listing.dict() - .literal( "register" ).literal( it->first ) - .literal( "name" ).literal( g_stringTable.GetString( it->second.name ) ) - .literal( "resourceType" ).literal( it->second.type ) - .literal( "autoregister" ).literal( it->second.isAutoregister ); - auto annotations = result.annotations.find( it->second.name ); - if( annotations != result.annotations.end() ) - { - PrintAnnotations( listing, annotations->second.annotations ); - } - listing.end(); + listing.dict() + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "textureType" ) + .literal( it->second.type ) + .literal( "autoregister" ) + .literal( it->second.isAutoregister ) + .literal( "sRGB" ) + .literal( it->second.isSRGB ); + auto annotations = result.annotations.find( it->second.name ); + if( annotations != result.annotations.end() ) + { + PrintAnnotations( listing, annotations->second.annotations ); } listing.end(); } - if( !stage.registerInputs.empty() ) + listing.end(); + } + if( !stage.uavs.empty() ) + { + listing.literal( "uavs" ).list(); + for( auto it = stage.uavs.begin(); it != stage.uavs.end(); ++it ) { - listing.literal( "registers" ).list(); - for( auto it = stage.registerInputs.begin(); it != stage.registerInputs.end(); ++it ) - { - listing.dict() - .literal( "registerType" ).literal( it->registerType ) - .literal( "register" ).literal( it->registerIndex ) - .end(); + listing.dict() + .literal( "register" ) + .literal( it->first ) + .literal( "name" ) + .literal( g_stringTable.GetString( it->second.name ) ) + .literal( "resourceType" ) + .literal( it->second.type ) + .literal( "autoregister" ) + .literal( it->second.isAutoregister ); + auto annotations = result.annotations.find( it->second.name ); + if( annotations != result.annotations.end() ) + { + PrintAnnotations( listing, annotations->second.annotations ); } listing.end(); } + listing.end(); } - - void PrintStageInfo( YamlOutput& listing, const StageInput& stage, const EffectData& result ) - { - PrintStageInfo( listing, static_cast( stage ), result ); - if( !stage.pipelineInputs.empty() ) - { - listing.literal( "inputs" ).list(); - for( auto it = stage.pipelineInputs.begin(); it != stage.pipelineInputs.end(); ++it ) - { - listing.dict() - .literal( "register" ).literal( it->registerIndex ) - .literal( "name" ).literal( it->name ) - .literal( "index" ).literal( it->index ) - .literal( "usedMask" ).literal( it->usedMask ) - .literal( "type" ).literal( ToString( it->type ) ) - .literal( "dimension" ).literal( it->dimension ) - .end(); - } - listing.end(); - } - } - - std::string SanitizeCode( const std::string& src ) + if( !stage.registerInputs.empty() ) { - std::regex line( "#line[^\\n]*\\n?\\n" ); - return std::regex_replace( src, line, std::string( "" ) ); + listing.literal( "registers" ).list(); + for( auto it = stage.registerInputs.begin(); it != stage.registerInputs.end(); ++it ) + { + listing.dict() + .literal( "registerType" ) + .literal( it->registerType ) + .literal( "register" ) + .literal( it->registerIndex ) + .end(); + } + listing.end(); } +} - bool ParseShaderName( const InlineString& name, InputStageType& type ) +void PrintStageInfo( YamlOutput& listing, const StageInput& stage, const EffectData& result ) +{ + PrintStageInfo( listing, static_cast( stage ), result ); + if( !stage.pipelineInputs.empty() ) { - if( _stricmp( ToString( name ).c_str(), "vertexshader" ) == 0 ) - { - type = VERTEX_STAGE; - } - else if( _stricmp( ToString( name ).c_str(), "pixelshader" ) == 0 ) + listing.literal( "inputs" ).list(); + for( auto it = stage.pipelineInputs.begin(); it != stage.pipelineInputs.end(); ++it ) { - type = PIXEL_STAGE; + listing.dict() + .literal( "register" ) + .literal( it->registerIndex ) + .literal( "name" ) + .literal( it->name ) + .literal( "index" ) + .literal( it->index ) + .literal( "usedMask" ) + .literal( it->usedMask ) + .literal( "type" ) + .literal( ToString( it->type ) ) + .literal( "dimension" ) + .literal( it->dimension ) + .end(); } - else if( _stricmp( ToString( name ).c_str(), "computeshader" ) == 0 ) - { - type = COMPUTE_STAGE; - } - else if( _stricmp( ToString( name ).c_str(), "geometryshader" ) == 0 ) - { - type = GEOMETRY_STAGE; - } - else if( _stricmp( ToString( name ).c_str(), "hullshader" ) == 0 ) - { - type = HULL_STAGE; - } - else if( _stricmp( ToString( name ).c_str(), "domainshader" ) == 0 ) - { - type = DOMAIN_STAGE; - } - else - { - return false; - } - return true; + listing.end(); } +} + +std::string SanitizeCode( const std::string& src ) +{ + std::regex line( "#line[^\\n]*\\n?\\n" ); + return std::regex_replace( src, line, std::string( "" ) ); +} - RegisterSpecifier MetalSystemSemantics( MetalSystemSemanticsType::Enum type ) +bool ParseShaderName( const InlineString& name, InputStageType& type ) +{ + if( _stricmp( ToString( name ).c_str(), "vertexshader" ) == 0 ) { - return RegisterSpecifier::Register( MetalRegister::System, type ); + type = VERTEX_STAGE; } - - const std::map s_systemSemantics = { - // vertex shader input semantics - { MakeInlineString( "SV_VertexID" ), MetalSystemSemanticsType::vertex_id }, - { MakeInlineString( "SV_InstanceID" ), MetalSystemSemanticsType::instance_id }, - // compute shader - { MakeInlineString( "SV_DispatchThreadID" ), MetalSystemSemanticsType::thread_position_in_grid }, - { MakeInlineString( "SV_GroupThreadID" ), MetalSystemSemanticsType::thread_position_in_threadgroup }, - { MakeInlineString( "SV_GroupIndex" ), MetalSystemSemanticsType::thread_index_in_threadgroup }, - { MakeInlineString( "SV_GroupID" ), MetalSystemSemanticsType::threadgroup_position_in_grid }, - { MakeInlineString( "SV_SampleIndex" ), MetalSystemSemanticsType::sample_id } - // TODO: Add more. - }; - - void RemapSystemSemanticsDXtoMetal( ASTNode* callNode ) + else if( _stricmp( ToString( name ).c_str(), "pixelshader" ) == 0 ) + { + type = PIXEL_STAGE; + } + else if( _stricmp( ToString( name ).c_str(), "computeshader" ) == 0 ) + { + type = COMPUTE_STAGE; + } + else if( _stricmp( ToString( name ).c_str(), "geometryshader" ) == 0 ) + { + type = GEOMETRY_STAGE; + } + else if( _stricmp( ToString( name ).c_str(), "hullshader" ) == 0 ) + { + type = HULL_STAGE; + } + else if( _stricmp( ToString( name ).c_str(), "domainshader" ) == 0 ) + { + type = DOMAIN_STAGE; + } + else { - ZoneScoped; + return false; + } + return true; +} - const InlineString shaderProfile = MakeInlineString( "" ); +RegisterSpecifier MetalSystemSemantics( MetalSystemSemanticsType::Enum type ) +{ + return RegisterSpecifier::Register( MetalRegister::System, type ); +} - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return; - } +const std::map s_systemSemantics = { + // vertex shader input semantics + { MakeInlineString( "SV_VertexID" ), MetalSystemSemanticsType::vertex_id }, + { MakeInlineString( "SV_InstanceID" ), MetalSystemSemanticsType::instance_id }, + // compute shader + { MakeInlineString( "SV_DispatchThreadID" ), MetalSystemSemanticsType::thread_position_in_grid }, + { MakeInlineString( "SV_GroupThreadID" ), MetalSystemSemanticsType::thread_position_in_threadgroup }, + { MakeInlineString( "SV_GroupIndex" ), MetalSystemSemanticsType::thread_index_in_threadgroup }, + { MakeInlineString( "SV_GroupID" ), MetalSystemSemanticsType::threadgroup_position_in_grid }, + { MakeInlineString( "SV_SampleIndex" ), MetalSystemSemanticsType::sample_id } + // TODO: Add more. +}; - ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); +void RemapSystemSemanticsDXtoMetal( ASTNode* callNode ) +{ + ZoneScoped; - for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) - { - ASTNode* param = header->GetChild( i ); - Symbol* symbol = param->GetSymbol(); + const InlineString shaderProfile = MakeInlineString( "" ); - auto it = s_systemSemantics.find( symbol->semantic ); - if( it != s_systemSemantics.end() ) - { - symbol->registerSpecifier[ shaderProfile ] = MetalSystemSemantics( it->second ); - } - } + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return; } - bool RemapVertexInputSemanticsDXToMetal( StageInput& stage, Symbol* symbol, int& nextAttributeNumber ) + ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + + for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) { - if( !symbol || !symbol->semantic ) + ASTNode* param = header->GetChild( i ); + Symbol* symbol = param->GetSymbol(); + + auto it = s_systemSemantics.find( symbol->semantic ); + if( it != s_systemSemantics.end() ) { - return false; + symbol->registerSpecifier[shaderProfile] = MetalSystemSemantics( it->second ); } + } +} + +bool RemapVertexInputSemanticsDXToMetal( StageInput& stage, Symbol* symbol, int& nextAttributeNumber ) +{ + if( !symbol || !symbol->semantic ) + { + return false; + } - std::regex vsSemantics( "((position)|(color)|(normal)|(tangent)|(binormal)|(texcoord)|(blendindices)|(blendweight))(\\d*)", std::regex_constants::icase ); + std::regex vsSemantics( "((position)|(color)|(normal)|(tangent)|(binormal)|(texcoord)|(blendindices)|(blendweight))(\\d*)", std::regex_constants::icase ); - auto semantic = ToString( symbol->semantic ); - std::smatch match; - if( std::regex_match( semantic, match, vsSemantics ) ) + auto semantic = ToString( symbol->semantic ); + std::smatch match; + if( std::regex_match( semantic, match, vsSemantics ) ) + { + PipelineInputDescription input; + for( int i = 0; i < UC_NUM_USAGE_CODE; ++i ) { - PipelineInputDescription input; - for( int i = 0; i < UC_NUM_USAGE_CODE; ++i ) - { - if( match[i + 2].matched ) - { - input.name = uint8_t( i ); - break; - } - } - input.registerIndex = uint8_t( nextAttributeNumber ); - input.index = match[10].str().empty() ? 0 : uint8_t( stoi( match[10] ) ); - input.usedMask = 0xff; - switch( symbol->type.builtInType ) + if( match[i + 2].matched ) { - case OP_FLOAT: - input.type = CONSTANT_TYPE_FLOAT; - break; - case OP_INT: - input.type = CONSTANT_TYPE_INT; - break; - case OP_UINT: - input.type = CONSTANT_TYPE_UINT; - break; - case OP_BOOL: - input.type = CONSTANT_TYPE_BOOL; - break; - default: - input.type = CONSTANT_TYPE_OTHER; + input.name = uint8_t( i ); break; } - input.dimension = uint8_t( symbol->type.width * symbol->type.height ); + } + input.registerIndex = uint8_t( nextAttributeNumber ); + input.index = match[10].str().empty() ? 0 : uint8_t( stoi( match[10] ) ); + input.usedMask = 0xff; + switch( symbol->type.builtInType ) + { + case OP_FLOAT: + input.type = CONSTANT_TYPE_FLOAT; + break; + case OP_INT: + input.type = CONSTANT_TYPE_INT; + break; + case OP_UINT: + input.type = CONSTANT_TYPE_UINT; + break; + case OP_BOOL: + input.type = CONSTANT_TYPE_BOOL; + break; + default: + input.type = CONSTANT_TYPE_OTHER; + break; + } + input.dimension = uint8_t( symbol->type.width * symbol->type.height ); - stage.pipelineInputs.push_back( input ); + stage.pipelineInputs.push_back( input ); - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::Attribute; - reg.registerNumber = nextAttributeNumber; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::Attribute; + reg.registerNumber = nextAttributeNumber; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; - symbol->registerSpecifier[reg.shaderProfile] = reg; - symbol->semantic.start = symbol->semantic.end = nullptr; + symbol->registerSpecifier[reg.shaderProfile] = reg; + symbol->semantic.start = symbol->semantic.end = nullptr; - ++nextAttributeNumber; - return true; - } - else - { - g_messages.AddMessage( "\\memory(0): warning X0000: Vertex shader uses unsupported input semantics \"%s\"", ToString( symbol->semantic ).c_str() ); - return false; - } + ++nextAttributeNumber; + return true; } - - bool RemapVertexInputSemanticsDXToMetal( StageInput& stage, ASTNode* node, int& nextAttributeNumber ) + else { - assert( node && node->GetNodeType() == NT_STRUCT ); + g_messages.AddMessage( "\\memory(0): warning X0000: Vertex shader uses unsupported input semantics \"%s\"", ToString( symbol->semantic ).c_str() ); + return false; + } +} + +bool RemapVertexInputSemanticsDXToMetal( StageInput& stage, ASTNode* node, int& nextAttributeNumber ) +{ + assert( node && node->GetNodeType() == NT_STRUCT ); - bool result = false; + bool result = false; - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) - { - ASTNode* member = node->GetChild( i ); - assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) + { + ASTNode* member = node->GetChild( i ); + assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); - // TODO: Is it actually enough to handle only the first child? - ASTNode* decl = member->GetChild( 0 ); - assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); + // TODO: Is it actually enough to handle only the first child? + ASTNode* decl = member->GetChild( 0 ); + assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); - Symbol* symbol = decl->GetSymbol(); - const Type& type = symbol->type; + Symbol* symbol = decl->GetSymbol(); + const Type& type = symbol->type; - // Is it a nested struct? - if( type.symbol && - type.symbol->definition && - type.symbol->definition->GetNodeType() == NT_STRUCT ) + // Is it a nested struct? + if( type.symbol && + type.symbol->definition && + type.symbol->definition->GetNodeType() == NT_STRUCT ) + { + result = RemapVertexInputSemanticsDXToMetal( stage, type.symbol->definition, nextAttributeNumber ) || result; + } + else + { + if( !symbol->semantic ) { - result = RemapVertexInputSemanticsDXToMetal( stage, type.symbol->definition, nextAttributeNumber ) || result; + continue; } - else - { - if( !symbol->semantic ) - { - continue; - } - result = RemapVertexInputSemanticsDXToMetal( stage, symbol, nextAttributeNumber ) || result; - } + result = RemapVertexInputSemanticsDXToMetal( stage, symbol, nextAttributeNumber ) || result; } + } - return result; + return result; +} + +void RemapVertexOutputSemanticsDXToMetal( Symbol* symbol ) +{ + if( IEquals( symbol->semantic, "POSITION" ) || IEquals( symbol->semantic, "POSITION0" ) || IEquals( symbol->semantic, "SV_Position" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::position_invariant ); + } + else if( IEquals( symbol->semantic, "SV_ClipDistance" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::clip_distance ); + } + else if( IEquals( symbol->semantic, "PSIZE" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::point_size ); + } + else + { + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::User; + reg.registerNumber = -1; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; + symbol->registerSpecifier[reg.shaderProfile] = reg; } +} + +void RemapVertexOutputSemanticsDXToMetal( ASTNode* node ) +{ + assert( node && node->GetNodeType() == NT_STRUCT ); - void RemapVertexOutputSemanticsDXToMetal( Symbol* symbol ) + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - if( IEquals( symbol->semantic, "POSITION" ) || IEquals( symbol->semantic, "POSITION0" ) || IEquals( symbol->semantic, "SV_Position" ) ) - { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::position_invariant ); - } - else if( IEquals( symbol->semantic, "SV_ClipDistance" ) ) - { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::clip_distance ); - } - else if( IEquals( symbol->semantic, "PSIZE" ) ) - { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::point_size ); - } - else - { - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::User; - reg.registerNumber = -1; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - symbol->registerSpecifier[reg.shaderProfile] = reg; - } + ASTNode* member = node->GetChild( i ); + assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); + + ASTNode* decl = member->GetChild( 0 ); + assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); + + Symbol* symbol = decl->GetSymbol(); + RemapVertexOutputSemanticsDXToMetal( symbol ); } +} - void RemapVertexOutputSemanticsDXToMetal( ASTNode* node ) +bool RemapFragmentInputSemanticsDXToMetal( Symbol* symbol ) +{ + if( !symbol || !symbol->semantic ) { - assert( node && node->GetNodeType() == NT_STRUCT ); + return false; + } - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) - { - ASTNode* member = node->GetChild( i ); - assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); + bool found = false; - ASTNode* decl = member->GetChild( 0 ); - assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); + if( IEquals( symbol->semantic, "SV_Position" ) || + IEquals( symbol->semantic, "POSITION" ) || + IEquals( symbol->semantic, "POSITION0" ) || + IEquals( symbol->semantic, "VPOS" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::position ); + found = true; + } + else if( IEquals( symbol->semantic, "VFACE" ) || + IEquals( symbol->semantic, "SV_IsFrontFace" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::front_facing ); + found = true; + } + else if( symbol->semantic ) + { + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::User; + reg.registerNumber = -1; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; - Symbol* symbol = decl->GetSymbol(); - RemapVertexOutputSemanticsDXToMetal( symbol ); - } + symbol->registerSpecifier[reg.shaderProfile] = reg; + found = true; } - bool RemapFragmentInputSemanticsDXToMetal( Symbol* symbol ) + return found; +} + +bool RemapFragmentInputSemanticsDXToMetal( ASTNode* node ) +{ + assert( node && node->GetNodeType() == NT_STRUCT ); + + bool result = false; + + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - if( !symbol || !symbol->semantic ) + ASTNode* member = node->GetChild( i ); + // assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); + + ASTNode* decl = member->GetChild( 0 ); + assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); + + Symbol* symbol = decl->GetSymbol(); + if( !symbol->semantic ) { - return false; + continue; } - bool found = false; + result = RemapFragmentInputSemanticsDXToMetal( symbol ) || result; + } + + return result; +} + +void RemapFragmentOutputSemanticsDXToMetal( Symbol* symbol ) +{ + const MetalSystemSemanticsType::Enum colorN[8] = { + MetalSystemSemanticsType::color_0, + MetalSystemSemanticsType::color_1, + MetalSystemSemanticsType::color_2, + MetalSystemSemanticsType::color_3, + MetalSystemSemanticsType::color_4, + MetalSystemSemanticsType::color_5, + MetalSystemSemanticsType::color_6, + MetalSystemSemanticsType::color_7 + }; - if( IEquals( symbol->semantic, "SV_Position" ) || - IEquals( symbol->semantic, "POSITION" ) || - IEquals( symbol->semantic, "POSITION0" ) || - IEquals( symbol->semantic, "VPOS" ) ) + if( _strnicmp( symbol->semantic.start, "COLOR", 5 ) == 0 ) + { + const size_t len = symbol->semantic.end - symbol->semantic.start; + if( len > 5 ) { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::position ); - found = true; + // Handle cases of COLORN. + int index = symbol->semantic.start[5] - '0'; + assert( 0 <= index && index < 8 ); + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( colorN[index] ); } - else if( IEquals( symbol->semantic, "VFACE" ) || - IEquals( symbol->semantic, "SV_IsFrontFace" ) ) + else { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::front_facing ); - found = true; + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::color_0 ); } - else if( symbol->semantic ) + } + else if( _strnicmp( symbol->semantic.start, "SV_Target", 9 ) == 0 ) + { + const size_t len = symbol->semantic.end - symbol->semantic.start; + if( len > 9 ) { - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::User; - reg.registerNumber = -1; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - - symbol->registerSpecifier[reg.shaderProfile] = reg; - found = true; + // Handle cases of SV_TargetN. + int index = symbol->semantic.start[9] - '0'; + assert( 0 <= index && index < 8 ); + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( colorN[index] ); } - - return found; + else + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::color_0 ); + } + } + else if( IEquals( symbol->semantic, "DEPTH" ) || + IEquals( symbol->semantic, "SV_Depth" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::depth ); + } + else if( IEquals( symbol->semantic, "SV_StencilRef" ) ) + { + symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::stencil ); + } + else + { + g_messages.AddMessage( "\\memory(0): warning X0000: Fragment shader uses unsupported output semantics \"%s\"", ToString( symbol->semantic ).c_str() ); } +} + +void RemapFragmentOutputSemanticsDXToMetal( ASTNode* node ) +{ + assert( node && node->GetNodeType() == NT_STRUCT ); - bool RemapFragmentInputSemanticsDXToMetal( ASTNode* node ) + for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) { - assert( node && node->GetNodeType() == NT_STRUCT ); + ASTNode* member = node->GetChild( i ); + assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); - bool result = false; + ASTNode* decl = member->GetChild( 0 ); + assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) - { - ASTNode* member = node->GetChild( i ); - // assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); + Symbol* symbol = decl->GetSymbol(); + RemapFragmentOutputSemanticsDXToMetal( symbol ); + } +} - ASTNode* decl = member->GetChild( 0 ); - assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); +void PrepareVertexFunction( StageInput& stage, ASTNode* callNode ) +{ + assert( stage.type == VERTEX_STAGE ); - Symbol* symbol = decl->GetSymbol(); - if( !symbol->semantic ) + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return; + } + + ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); + + int nextAttributeNumber = 0; + for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) + { + ASTNode* param = header->GetChild( i ); + Symbol* symbol = param->GetSymbol(); + const Symbol* typeSymbol = symbol->type.symbol; + + if( typeSymbol ) + { + // This funciton parameter is of struct type. Check if this struct has declarations + // with input semantics. + bool hasInputs = RemapVertexInputSemanticsDXToMetal( stage, typeSymbol->definition, nextAttributeNumber ); + + if( hasInputs ) + { + // [[stage_in]] + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::StageIn; + reg.registerNumber = -1; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; + symbol->registerSpecifier[reg.shaderProfile] = reg; + } + else { - continue; + // Inherit register specifier from the type. + symbol->registerSpecifier = typeSymbol->registerSpecifier; } + } + else if( symbol->type.builtInType ) + { + RemapVertexInputSemanticsDXToMetal( stage, symbol, nextAttributeNumber ); + } + } - result = RemapFragmentInputSemanticsDXToMetal( symbol ) || result; + const Type& returnType = header->GetType(); + if( returnType.symbol ) + { + ASTNode* def = returnType.symbol->definition; + if( def && def->GetNodeType() == NT_STRUCT ) + { + RemapVertexOutputSemanticsDXToMetal( def ); } + } +} - return result; +void PrepareFragmentFunction( StageInput&, ASTNode* callNode ) +{ + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return; } - void RemapFragmentOutputSemanticsDXToMetal( Symbol* symbol ) + ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); + if( !header ) { - const MetalSystemSemanticsType::Enum colorN[8] = { - MetalSystemSemanticsType::color_0, - MetalSystemSemanticsType::color_1, - MetalSystemSemanticsType::color_2, - MetalSystemSemanticsType::color_3, - MetalSystemSemanticsType::color_4, - MetalSystemSemanticsType::color_5, - MetalSystemSemanticsType::color_6, - MetalSystemSemanticsType::color_7 - }; + return; + } + assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - if( _strnicmp( symbol->semantic.start, "COLOR", 5 ) == 0 ) - { - const size_t len = symbol->semantic.end - symbol->semantic.start; - if( len > 5 ) - { - // Handle cases of COLORN. - int index = symbol->semantic.start[5] - '0'; - assert( 0 <= index && index < 8 ); - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( colorN[index] ); + for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) + { + ASTNode* param = header->GetChild( i ); + Symbol* symbol = param->GetSymbol(); + const Symbol* typeSymbol = symbol->type.symbol; + + if( typeSymbol ) + { + // This funciton parameter is of struct type. Check if this struct has declarations + // with input semantics. + bool hasInputs = RemapFragmentInputSemanticsDXToMetal( typeSymbol->definition ); + + if( hasInputs ) + { + // [[stage_in]] + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::StageIn; + reg.registerNumber = -1; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; + symbol->registerSpecifier[reg.shaderProfile] = reg; } else { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::color_0 ); + // Inherit register specifier from the type. + symbol->registerSpecifier = typeSymbol->registerSpecifier; } } - else if( _strnicmp( symbol->semantic.start, "SV_Target", 9 ) == 0 ) + else if( symbol->type.builtInType ) { - const size_t len = symbol->semantic.end - symbol->semantic.start; - if( len > 9 ) + if( param->GetToken() && param->GetToken()->type == OP_OUT ) { - // Handle cases of SV_TargetN. - int index = symbol->semantic.start[9] - '0'; - assert( 0 <= index && index < 8 ); - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( colorN[index] ); + RemapFragmentOutputSemanticsDXToMetal( symbol ); } else { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::color_0 ); + RemapFragmentInputSemanticsDXToMetal( symbol ); } } - else if( IEquals( symbol->semantic, "DEPTH" ) || - IEquals( symbol->semantic, "SV_Depth" ) ) - { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::depth ); - } - else if( IEquals( symbol->semantic, "SV_StencilRef" ) ) - { - symbol->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::stencil ); - } - else - { - g_messages.AddMessage( "\\memory(0): warning X0000: Fragment shader uses unsupported output semantics \"%s\"", ToString( symbol->semantic ).c_str() ); - } } - void RemapFragmentOutputSemanticsDXToMetal( ASTNode* node ) + const Type& returnType = header->GetType(); + if( returnType.symbol ) { - assert( node && node->GetNodeType() == NT_STRUCT ); - - for( size_t i = 0, n = node->GetChildrenCount(); i < n; ++i ) + ASTNode* def = returnType.symbol->definition; + if( def && def->GetNodeType() == NT_STRUCT ) { - ASTNode* member = node->GetChild( i ); - assert( member && member->GetNodeType() == NT_STRUCT_MEMBER ); - - ASTNode* decl = member->GetChild( 0 ); - assert( decl && decl->GetNodeType() == NT_NAME_DECLARATION ); - - Symbol* symbol = decl->GetSymbol(); - RemapFragmentOutputSemanticsDXToMetal( symbol ); + RemapFragmentOutputSemanticsDXToMetal( def ); } } +} - void PrepareVertexFunction( StageInput& stage, ASTNode* callNode ) - { - assert( stage.type == VERTEX_STAGE ); +void PrepareKernelFunction( StageInput&, ASTNode* ) +{ +} - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return; - } - - ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - - int nextAttributeNumber = 0; - for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) - { - ASTNode* param = header->GetChild( i ); - Symbol* symbol = param->GetSymbol(); - const Symbol* typeSymbol = symbol->type.symbol; - - if( typeSymbol ) - { - // This funciton parameter is of struct type. Check if this struct has declarations - // with input semantics. - bool hasInputs = RemapVertexInputSemanticsDXToMetal( stage, typeSymbol->definition, nextAttributeNumber ); - - if( hasInputs ) - { - // [[stage_in]] - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::StageIn; - reg.registerNumber = -1; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - symbol->registerSpecifier[reg.shaderProfile] = reg; - } - else - { - // Inherit register specifier from the type. - symbol->registerSpecifier = typeSymbol->registerSpecifier; - } - } - else if( symbol->type.builtInType ) - { - RemapVertexInputSemanticsDXToMetal( stage, symbol, nextAttributeNumber ); - } - } - - const Type& returnType = header->GetType(); - if( returnType.symbol ) - { - ASTNode* def = returnType.symbol->definition; - if( def && def->GetNodeType() == NT_STRUCT ) - { - RemapVertexOutputSemanticsDXToMetal( def ); - } - } - } +void GetThreadGroupSize( StageInput& stage, ParserState& state, ASTNode* callNode ) +{ + stage.threadGroupSize[0] = 1; + stage.threadGroupSize[1] = 1; + stage.threadGroupSize[2] = 1; - void PrepareFragmentFunction( StageInput&, ASTNode* callNode ) + if( stage.type != COMPUTE_STAGE ) { - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return; - } - - ASTNode* header = entryPointSymbol->definition->GetChildOrNull( 0 ); - if( !header ) - { - return; - } - assert( header->GetNodeType() == NT_FUNCTION_HEADER ); - - for( size_t i = 0, n = header->GetChildrenCount(); i < n; ++i ) - { - ASTNode* param = header->GetChild( i ); - Symbol* symbol = param->GetSymbol(); - const Symbol* typeSymbol = symbol->type.symbol; - - if( typeSymbol ) - { - // This funciton parameter is of struct type. Check if this struct has declarations - // with input semantics. - bool hasInputs = RemapFragmentInputSemanticsDXToMetal( typeSymbol->definition ); - - if( hasInputs ) - { - // [[stage_in]] - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::StageIn; - reg.registerNumber = -1; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - symbol->registerSpecifier[reg.shaderProfile] = reg; - } - else - { - // Inherit register specifier from the type. - symbol->registerSpecifier = typeSymbol->registerSpecifier; - } - } - else if( symbol->type.builtInType ) - { - if( param->GetToken() && param->GetToken()->type == OP_OUT ) - { - RemapFragmentOutputSemanticsDXToMetal( symbol ); - } - else - { - RemapFragmentInputSemanticsDXToMetal( symbol ); - } - } - } - - const Type& returnType = header->GetType(); - if( returnType.symbol ) - { - ASTNode* def = returnType.symbol->definition; - if( def && def->GetNodeType() == NT_STRUCT ) - { - RemapFragmentOutputSemanticsDXToMetal( def ); - } - } + return; } - void PrepareKernelFunction( StageInput&, ASTNode* ) + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) { + return; } - void GetThreadGroupSize( StageInput& stage, ParserState& state, ASTNode* callNode ) + ASTNode* attribList = entryPointSymbol->definition->GetChildOrNull( 2 ); + if( attribList && attribList->GetNodeType() == NT_FUNCTION_ATTRIBUTE_LIST ) { - stage.threadGroupSize[0] = 1; - stage.threadGroupSize[1] = 1; - stage.threadGroupSize[2] = 1; - - if( stage.type != COMPUTE_STAGE ) - { - return; - } - - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) + // Find [numthreads(X, Y, Z)] attribute. + for( size_t i = 0, n = attribList->GetChildrenCount(); i < n; ++i ) { - return; - } + ASTNode* attribute = attribList->GetChild( i ); + assert( attribute->GetNodeType() == NT_FUNCTION_ATTRIBUTE ); - ASTNode* attribList = entryPointSymbol->definition->GetChildOrNull( 2 ); - if( attribList && attribList->GetNodeType() == NT_FUNCTION_ATTRIBUTE_LIST ) - { - // Find [numthreads(X, Y, Z)] attribute. - for( size_t i = 0, n = attribList->GetChildrenCount(); i < n; ++i ) + if( attribute->GetToken()->stringValue != "numthreads" ) { - ASTNode* attribute = attribList->GetChild( i ); - assert( attribute->GetNodeType() == NT_FUNCTION_ATTRIBUTE ); + continue; + } - if( attribute->GetToken()->stringValue != "numthreads" ) - { - continue; - } + for( size_t j = 0; j < 3; ++j ) + { + ASTNode* child = attribute->GetChildOrNull( j ); - for( size_t j = 0; j < 3; ++j ) - { - ASTNode* child = attribute->GetChildOrNull( j ); + InlineString valueString = ( child && child->GetToken() ) ? child->GetToken()->stringValue : InlineString{ nullptr, nullptr }; + unsigned long value = valueString ? std::strtoul( valueString.start, nullptr, 10 ) : 1; - InlineString valueString = (child && child->GetToken() ) ? child->GetToken()->stringValue : InlineString{ nullptr, nullptr }; - unsigned long value = valueString ? std::strtoul( valueString.start, nullptr, 10 ) : 1; + stage.threadGroupSize[j] = (uint32_t)value; + } - stage.threadGroupSize[ j ] = (uint32_t) value; - } - - if( stage.threadGroupSize[0] * stage.threadGroupSize[1] * stage.threadGroupSize[2] > 512 ) - { - state.ShowMessage( attribute->GetLocation(), EC_CUSTOM_WARNING, "number of threads per group exceeds Intel limit of 512; computer shader invoketion will fail on Intel macs" ); - } + if( stage.threadGroupSize[0] * stage.threadGroupSize[1] * stage.threadGroupSize[2] > 512 ) + { + state.ShowMessage( attribute->GetLocation(), EC_CUSTOM_WARNING, "number of threads per group exceeds Intel limit of 512; computer shader invoketion will fail on Intel macs" ); } } } +} - bool AutoAssignRegistersForNode( ParserState& state, ASTNode* functionHeader, const FileLocation& messageLocation ) - { - /* +bool AutoAssignRegistersForNode( ParserState& state, ASTNode* functionHeader, const FileLocation& messageLocation ) +{ + /* This function assigns "registers" i.e. Metal input attributes [[buffer(###)]] or [[texture(###)]] to the shader arguments. Metal partitions the set off all inputs into "buffers" and "textures", which is somewhat different from DirectX that partitions @@ -1722,2912 +1772,2962 @@ namespace */ - auto GetAssignedSymbolNames = []( const std::vector& symbols ) { - std::string result; - for( auto symbol : symbols ) + auto GetAssignedSymbolNames = []( const std::vector& symbols ) { + std::string result; + for( auto symbol : symbols ) + { + if( !result.empty() ) { - if( !result.empty() ) - { - result += ", "; - } - result += ToString( symbol->name ); + result += ", "; } - return result; - }; + result += ToString( symbol->name ); + } + return result; + }; - auto RecordRegister = [&state]( int index, std::vector& registers, ASTNode* node ) { - Symbol* symbol = node->GetSymbol(); + auto RecordRegister = [&state]( int index, std::vector& registers, ASTNode* node ) { + Symbol* symbol = node->GetSymbol(); - if( index < 0 || index >= int( registers.size() ) ) - { - state.ShowMessage( - node->GetLocation(), - EC_CUSTOM_ERROR, - "Couldn't allocate a register for %s. Reason: Invalid register index.", - ToString( symbol->name ).c_str() ); - return false; - } + if( index < 0 || index >= int( registers.size() ) ) + { + state.ShowMessage( + node->GetLocation(), + EC_CUSTOM_ERROR, + "Couldn't allocate a register for %s. Reason: Invalid register index.", + ToString( symbol->name ).c_str() ); + return false; + } - if( !registers[index] ) + if( !registers[index] ) + { + registers[index] = symbol; + return true; + } + else + { + state.ShowMessage( + node->GetLocation(), + EC_CUSTOM_ERROR, + "Couldn't allocate a register for %s. Reason: register %d already assigned to %s.", + ToString( symbol->name ).c_str(), + index, + ToString( registers[index]->name ).c_str() ); + return false; + } + }; + + auto FindUnusedRegister = []( const std::vector& registers, int& index ) { + for( size_t i = 0; i < registers.size(); ++i ) + { + if( !registers[i] ) { - registers[index] = symbol; + index = int( i ); return true; } - else - { - state.ShowMessage( - node->GetLocation(), - EC_CUSTOM_ERROR, - "Couldn't allocate a register for %s. Reason: register %d already assigned to %s.", - ToString( symbol->name ).c_str(), - index, - ToString( registers[index]->name ).c_str() ); - return false; - } - }; + } + return false; + }; - auto FindUnusedRegister = []( const std::vector& registers, int& index ) { - for( size_t i = 0; i < registers.size(); ++i ) - { - if( !registers[i] ) - { - index = int( i ); - return true; - } - } - return false; - }; + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = MetalRegister::Invalid; + reg.registerNumber = -1; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = MetalRegister::Invalid; - reg.registerNumber = -1; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; + auto AssignRegister = [&]( Symbol* symbol, std::vector& registers, MetalRegister::Enum registerType ) { + reg.registerType = registerType; + if( FindUnusedRegister( registers, reg.registerNumber ) ) + { + symbol->registerSpecifier[reg.shaderProfile] = reg; + registers[reg.registerNumber] = symbol; + return true; + } + state.ShowMessage( + messageLocation, + EC_CUSTOM_ERROR, + "Couldn't allocate a register for %s. Reason: no free registers left. Already assigned registers: %s", + ToString( symbol->name ).c_str(), + GetAssignedSymbolNames( registers ).c_str() ); + return false; + }; - auto AssignRegister = [&]( Symbol* symbol, std::vector& registers, MetalRegister::Enum registerType ) { - reg.registerType = registerType; - if( FindUnusedRegister( registers, reg.registerNumber ) ) - { - symbol->registerSpecifier[reg.shaderProfile] = reg; - registers[reg.registerNumber] = symbol; - return true; - } - state.ShowMessage( - messageLocation, - EC_CUSTOM_ERROR, - "Couldn't allocate a register for %s. Reason: no free registers left. Already assigned registers: %s", - ToString( symbol->name ).c_str(), - GetAssignedSymbolNames( registers ).c_str() ); - return false; - }; + // strictly for constant buffers + std::vector buffers( METAL_MAX_BOUND_BUFFERS, nullptr ); + // shared between SRVs and UAVs: both textures and buffers + std::vector textures( METAL_MAX_BOUND_TEXTURES, nullptr ); + // samplers + std::vector samplers( METAL_MAX_BOUND_SAMPLERS, nullptr ); - // strictly for constant buffers - std::vector buffers( METAL_MAX_BOUND_BUFFERS, nullptr ); - // shared between SRVs and UAVs: both textures and buffers - std::vector textures( METAL_MAX_BOUND_TEXTURES, nullptr ); - // samplers - std::vector samplers( METAL_MAX_BOUND_SAMPLERS, nullptr ); + // Mark the first 4 buffer slots as occupied for vertex streams + Symbol vertexStream; + buffers[0] = &vertexStream; + buffers[1] = &vertexStream; + buffers[2] = &vertexStream; + buffers[3] = &vertexStream; - // Mark the first 4 buffer slots as occupied for vertex streams - Symbol vertexStream; - buffers[0] = &vertexStream; - buffers[1] = &vertexStream; - buffers[2] = &vertexStream; - buffers[3] = &vertexStream; + // Accumulate already used registers. + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + ASTNode* paramNode = functionHeader->GetChild( i ); + Symbol* symbol = paramNode->GetSymbol(); - // Accumulate already used registers. - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + const Type& type = paramNode->GetType(); + if( type.IsStruct() ) { - ASTNode* paramNode = functionHeader->GetChild( i ); - Symbol* symbol = paramNode->GetSymbol(); - - const Type& type = paramNode->GetType(); - if( type.IsStruct() ) + if( symbol->registerSpecifier.empty() ) { - if( symbol->registerSpecifier.empty() ) + int index = GetCBufferIndex( symbol ); + if( index >= 0 ) { - int index = GetCBufferIndex( symbol ); - if( index >= 0 ) - { - assert( index < METAL_BUFFER_COUNT ); + assert( index < METAL_BUFFER_COUNT ); - if( RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) - { - reg.registerType = MetalRegister::CBuffer; - reg.registerNumber = index; + if( RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) + { + reg.registerType = MetalRegister::CBuffer; + reg.registerNumber = index; - symbol->registerSpecifier[reg.shaderProfile] = reg; - } - else - { - return false; - } + symbol->registerSpecifier[reg.shaderProfile] = reg; + } + else + { + return false; } } - else - { - // Note: We only check the first register. - const RegisterSpecifier& existingReg = symbol->registerSpecifier.cbegin()->second; + } + else + { + // Note: We only check the first register. + const RegisterSpecifier& existingReg = symbol->registerSpecifier.cbegin()->second; - assert( existingReg.registerType != MetalRegister::SRV && existingReg.registerType != MetalRegister::UAV ); - if( existingReg.registerType == MetalRegister::CBuffer ) + assert( existingReg.registerType != MetalRegister::SRV && existingReg.registerType != MetalRegister::UAV ); + if( existingReg.registerType == MetalRegister::CBuffer ) + { + int index = existingReg.registerNumber; + if( !RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) { - int index = existingReg.registerNumber; - if( !RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) - { - return false; - } + return false; } } + } - continue; + continue; + } + + if( symbol->registerSpecifier.empty() ) + { + continue; + } + + // Note: We only check the first register. + const RegisterSpecifier& existingReg = symbol->registerSpecifier.cbegin()->second; + + switch( type.builtInType ) + { + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + assert( existingReg.registerType == MetalRegister::SRV ); + if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) + { + return false; } + break; - if( symbol->registerSpecifier.empty() ) + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: + assert( existingReg.registerType == MetalRegister::UAV ); + if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) { - continue; + return false; } + break; - // Note: We only check the first register. - const RegisterSpecifier& existingReg = symbol->registerSpecifier.cbegin()->second; + case OP_TEXTURE: + case OP_TEXTURE1D: + case OP_TEXTURE1DARRAY: + case OP_TEXTURE2D: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE3D: + // case OP_TEXTURE3DARRAY: + case OP_TEXTURECUBE: + case OP_TEXTURECUBEARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: + assert( existingReg.registerType == MetalRegister::Texture ); + if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) + { + return false; + } + break; - switch( type.builtInType ) + case OP_RWTEXTURE1D: + case OP_RWTEXTURE1DARRAY: + case OP_RWTEXTURE2D: + case OP_RWTEXTURE2DARRAY: + case OP_RWTEXTURE3D: + // case OP_RWTEXTURE3DARRAY: + assert( existingReg.registerType == MetalRegister::UAV ); + if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) { - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - assert( existingReg.registerType == MetalRegister::SRV ); - if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) - { - return false; - } - break; + return false; + } + break; - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: - assert( existingReg.registerType == MetalRegister::UAV ); + case OP_SAMPLER: + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLERCOMPARISON: + if( type.arrayDimensions > 0 ) + { + assert( existingReg.registerType == MetalRegister::Texture ); if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) { return false; } - break; - - case OP_TEXTURE: - case OP_TEXTURE1D: - case OP_TEXTURE1DARRAY: - case OP_TEXTURE2D: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE3D: - // case OP_TEXTURE3DARRAY: - case OP_TEXTURECUBE: - case OP_TEXTURECUBEARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: - assert( existingReg.registerType == MetalRegister::Texture ); - if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) + } + else + { + assert( existingReg.registerType == MetalRegister::Sampler ); + if( !RecordRegister( existingReg.registerNumber, samplers, paramNode ) ) { return false; } - break; - - case OP_RWTEXTURE1D: - case OP_RWTEXTURE1DARRAY: - case OP_RWTEXTURE2D: - case OP_RWTEXTURE2DARRAY: - case OP_RWTEXTURE3D: - // case OP_RWTEXTURE3DARRAY: - assert( existingReg.registerType == MetalRegister::UAV ); - if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) - { - return false; - } - break; - - case OP_SAMPLER: - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLERCOMPARISON: - if( type.arrayDimensions > 0 ) - { - assert( existingReg.registerType == MetalRegister::Texture ); - if( !RecordRegister( existingReg.registerNumber, textures, paramNode ) ) - { - return false; - } - } - else - { - assert( existingReg.registerType == MetalRegister::Sampler ); - if( !RecordRegister( existingReg.registerNumber, samplers, paramNode ) ) - { - return false; - } - } - break; - - default: - break; } + break; + + default: + break; } + } - // Assign registers for constant buffers - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + // Assign registers for constant buffers + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); + Symbol* symbol = paramNode->GetSymbol(); + if( !symbol->registerSpecifier.empty() ) + { + continue; + } + const Type& type = paramNode->GetType(); + if( type.IsStruct() ) { - ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); - Symbol* symbol = paramNode->GetSymbol(); - if( !symbol->registerSpecifier.empty() ) + int index = GetCBufferIndex( symbol ); + if( RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) { - continue; + reg.registerType = MetalRegister::CBuffer; + reg.registerNumber = index; + symbol->registerSpecifier[reg.shaderProfile] = reg; } - const Type& type = paramNode->GetType(); - if( type.IsStruct() ) + else { - int index = GetCBufferIndex( symbol ); - if( RecordRegister( index + METAL_VERTEX_STREAM_BUFFER_COUNT, buffers, paramNode ) ) - { - reg.registerType = MetalRegister::CBuffer; - reg.registerNumber = index; - symbol->registerSpecifier[reg.shaderProfile] = reg; - } - else - { - return false; - } + return false; } } + } - // Assign registers for SRV/UAV buffers - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + // Assign registers for SRV/UAV buffers + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); + Symbol* symbol = paramNode->GetSymbol(); + + if( !symbol->registerSpecifier.empty() ) { - ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); - Symbol* symbol = paramNode->GetSymbol(); + continue; + } + const Type& type = paramNode->GetType(); + if( type.IsStruct() ) + { + continue; + } + + reg.registerType = MetalRegister::Invalid; + reg.registerNumber = -1; - if( !symbol->registerSpecifier.empty() ) + switch( type.builtInType ) + { + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + reg.registerType = MetalRegister::SRV; + break; + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: + reg.registerType = MetalRegister::UAV; + break; + case OP_TEXTURE: + case OP_TEXTURE1D: + case OP_TEXTURE1DARRAY: + case OP_TEXTURE2D: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE3D: + // case OP_TEXTURE3DARRAY: + case OP_TEXTURECUBE: + case OP_TEXTURECUBEARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: + if( type.arrayDimensions ) { - continue; + reg.registerType = MetalRegister::SRV; + break; } - const Type& type = paramNode->GetType(); - if( type.IsStruct() ) + else { continue; } - - reg.registerType = MetalRegister::Invalid; - reg.registerNumber = -1; - - switch( type.builtInType ) + case OP_SAMPLER: + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLERCOMPARISON: + if( symbol->type.arrayDimensions > 0 ) { - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: reg.registerType = MetalRegister::SRV; break; - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: - reg.registerType = MetalRegister::UAV; - break; - case OP_TEXTURE: - case OP_TEXTURE1D: - case OP_TEXTURE1DARRAY: - case OP_TEXTURE2D: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE3D: - // case OP_TEXTURE3DARRAY: - case OP_TEXTURECUBE: - case OP_TEXTURECUBEARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: - if( type.arrayDimensions ) - { - reg.registerType = MetalRegister::SRV; - break; - } - else - { - continue; - } - case OP_SAMPLER: - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLERCOMPARISON: - if( symbol->type.arrayDimensions > 0 ) - { - reg.registerType = MetalRegister::SRV; - break; - } - else - { - continue; - } - default: - continue; } - - if ( !AssignRegister( symbol, buffers, static_cast( reg.registerType ) ) ) + else { - return false; + continue; } - // Also mark texture slot occupied - textures[reg.registerNumber] = symbol; + default: + continue; } - // Assign texture and sampler registers. - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + if( !AssignRegister( symbol, buffers, static_cast( reg.registerType ) ) ) { - ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); - assert( paramNode ); + return false; + } + // Also mark texture slot occupied + textures[reg.registerNumber] = symbol; + } - Symbol* symbol = paramNode->GetSymbol(); - assert( symbol ); + // Assign texture and sampler registers. + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + ASTNode* paramNode = functionHeader->GetChild( functionHeader->GetChildrenCount() - 1 - i ); + assert( paramNode ); - if( !symbol->registerSpecifier.empty() ) - { - // The register already assigned. - continue; - } - const Type& type = paramNode->GetType(); - if( type.IsStruct() ) - { - continue; - } + Symbol* symbol = paramNode->GetSymbol(); + assert( symbol ); - reg.registerType = MetalRegister::Invalid; - reg.registerNumber = -1; + if( !symbol->registerSpecifier.empty() ) + { + // The register already assigned. + continue; + } + const Type& type = paramNode->GetType(); + if( type.IsStruct() ) + { + continue; + } - switch( type.builtInType ) + reg.registerType = MetalRegister::Invalid; + reg.registerNumber = -1; + + switch( type.builtInType ) + { + case OP_TEXTURE: + case OP_TEXTURE1D: + case OP_TEXTURE1DARRAY: + case OP_TEXTURE2D: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE3D: + // case OP_TEXTURE3DARRAY: + case OP_TEXTURECUBE: + case OP_TEXTURECUBEARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: + if( type.arrayDimensions == 0 ) { - case OP_TEXTURE: - case OP_TEXTURE1D: - case OP_TEXTURE1DARRAY: - case OP_TEXTURE2D: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE3D: - // case OP_TEXTURE3DARRAY: - case OP_TEXTURECUBE: - case OP_TEXTURECUBEARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: - if( type.arrayDimensions == 0 ) + if( !AssignRegister( symbol, textures, MetalRegister::Texture ) ) { - if( !AssignRegister( symbol, textures, MetalRegister::Texture ) ) - { - return false; - } + return false; } - break; + } + break; - case OP_RWTEXTURE1D: - case OP_RWTEXTURE1DARRAY: - case OP_RWTEXTURE2D: - case OP_RWTEXTURE2DARRAY: - case OP_RWTEXTURE3D: + case OP_RWTEXTURE1D: + case OP_RWTEXTURE1DARRAY: + case OP_RWTEXTURE2D: + case OP_RWTEXTURE2DARRAY: + case OP_RWTEXTURE3D: // case OP_RWTEXTURE3DARRAY: - if( !AssignRegister( symbol, textures, MetalRegister::UAV ) ) - { - return false; - } - break; + if( !AssignRegister( symbol, textures, MetalRegister::UAV ) ) + { + return false; + } + break; - case OP_SAMPLER: - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLERCOMPARISON: - if ( symbol->type.arrayDimensions == 0 ) + case OP_SAMPLER: + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLERCOMPARISON: + if( symbol->type.arrayDimensions == 0 ) + { + if( !AssignRegister( symbol, samplers, MetalRegister::Sampler ) ) { - if( !AssignRegister( symbol, samplers, MetalRegister::Sampler ) ) - { - return false; - } + return false; } - break; - - default: - continue; } - } + break; - return true; + default: + continue; + } } - bool AutoAssignRegisters( ParserState& state, ASTNode* callNode ) - { - ZoneScoped; + return true; +} - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return false; - } +bool AutoAssignRegisters( ParserState& state, ASTNode* callNode ) +{ + ZoneScoped; - ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); - if( !functionHeader ) - { - return false; - } - return AutoAssignRegistersForNode( state, functionHeader, callNode->GetLocation() ); + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return false; } - ASTNode* NewStructMember( ParserState& state, Symbol* sourceSymbol ) + ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); + if( !functionHeader ) { - auto symbol = state.GetSymbolTable().AddSymbol( state.AllocateNameWithPrefix( sourceSymbol->name ) ); - auto nameDecl = state.NewNode( NT_NAME_DECLARATION ); - symbol->definition = nameDecl; - symbol->type = sourceSymbol->type; - symbol->interpolationModifier = sourceSymbol->interpolationModifier; - symbol->semantic = sourceSymbol->semantic; - nameDecl->SetSymbol( symbol ); - nameDecl->SetType( sourceSymbol->type ); - - auto member = state.NewNode( NT_STRUCT_MEMBER ); - member->AddChild( nameDecl ); - member->SetType( sourceSymbol->type ); - return member; + return false; } + return AutoAssignRegistersForNode( state, functionHeader, callNode->GetLocation() ); +} - // Collects fields from nested structures and copies them int a flat structure - // In the process gathers access expressions for source struct fields (in the form blah.foo.bar...) - void GatherFields( ASTNode* destStruct, std::vector& accessors, ASTNode* accessParent, ASTNode* sourceStruct, ParserState& state ) +ASTNode* NewStructMember( ParserState& state, Symbol* sourceSymbol ) +{ + auto symbol = state.GetSymbolTable().AddSymbol( state.AllocateNameWithPrefix( sourceSymbol->name ) ); + auto nameDecl = state.NewNode( NT_NAME_DECLARATION ); + symbol->definition = nameDecl; + symbol->type = sourceSymbol->type; + symbol->interpolationModifier = sourceSymbol->interpolationModifier; + symbol->semantic = sourceSymbol->semantic; + nameDecl->SetSymbol( symbol ); + nameDecl->SetType( sourceSymbol->type ); + + auto member = state.NewNode( NT_STRUCT_MEMBER ); + member->AddChild( nameDecl ); + member->SetType( sourceSymbol->type ); + return member; +} + +// Collects fields from nested structures and copies them int a flat structure +// In the process gathers access expressions for source struct fields (in the form blah.foo.bar...) +void GatherFields( ASTNode* destStruct, std::vector& accessors, ASTNode* accessParent, ASTNode* sourceStruct, ParserState& state ) +{ + for( auto member : sourceStruct->GetChildren() ) { - for( auto member : sourceStruct->GetChildren() ) + if( member->GetType().IsStruct() ) { - if( member->GetType().IsStruct() ) + for( auto name : member->GetChildren() ) { - for( auto name : member->GetChildren() ) - { - GatherFields( destStruct, accessors, NewDot( state, accessParent->Copy(), name->GetSymbol() ), name->GetType().symbol->definition, state ); - } + GatherFields( destStruct, accessors, NewDot( state, accessParent->Copy(), name->GetSymbol() ), name->GetType().symbol->definition, state ); } - else + } + else + { + for( auto name : member->GetChildren() ) { - for( auto name : member->GetChildren() ) + auto it = s_systemSemantics.find( name->GetSymbol()->semantic ); + if( it == s_systemSemantics.end() ) { - auto it = s_systemSemantics.find( name->GetSymbol()->semantic ); - if( it == s_systemSemantics.end() ) - { - destStruct->AddChild( NewStructMember( state, name->GetSymbol() ) ); - accessors.push_back( NewDot( state, accessParent->Copy(), name->GetSymbol() ) ); - } + destStruct->AddChild( NewStructMember( state, name->GetSymbol() ) ); + accessors.push_back( NewDot( state, accessParent->Copy(), name->GetSymbol() ) ); } } } } +} - void GatherSystemFields( ASTNode* destStruct, std::vector& accessors, std::vector& argumentAccessors, ASTNode* accessParent, ASTNode* sourceStruct, ASTNode* shaderBody, ParserState& state ) +void GatherSystemFields( ASTNode* destStruct, std::vector& accessors, std::vector& argumentAccessors, ASTNode* accessParent, ASTNode* sourceStruct, ASTNode* shaderBody, ParserState& state ) +{ + for( auto member : sourceStruct->GetChildren() ) { - for( auto member : sourceStruct->GetChildren() ) + if( member->GetType().IsStruct() ) { - if( member->GetType().IsStruct() ) + for( auto name : member->GetChildren() ) { - for( auto name : member->GetChildren() ) - { - GatherSystemFields( destStruct, accessors, argumentAccessors, NewDot( state, accessParent->Copy(), name->GetSymbol() ), name->GetType().symbol->definition, shaderBody, state ); - } + GatherSystemFields( destStruct, accessors, argumentAccessors, NewDot( state, accessParent->Copy(), name->GetSymbol() ), name->GetType().symbol->definition, shaderBody, state ); } - else + } + else + { + for( auto name : member->GetChildren() ) { - for( auto name : member->GetChildren() ) + auto it = s_systemSemantics.find( name->GetSymbol()->semantic ); + if( it != s_systemSemantics.end() ) { - auto it = s_systemSemantics.find( name->GetSymbol()->semantic ); - if( it != s_systemSemantics.end() ) + auto param = NewFunctionParameter( state, name->GetType() ); + param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( it->second ); + destStruct->AddChild( param ); + argumentAccessors.push_back( NewVarIdentifier( state, param->GetSymbol() ) ); + accessors.push_back( NewDot( state, accessParent->Copy(), name->GetSymbol() ) ); + + // subtract base_vertex from vertex_id to match dx12 behaviour for SV_VertexID + if( name->GetSymbol()->semantic == "SV_VertexID" ) { - auto param = NewFunctionParameter( state, name->GetType() ); - param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( it->second ); - destStruct->AddChild( param ); - argumentAccessors.push_back( NewVarIdentifier( state, param->GetSymbol() ) ); - accessors.push_back( NewDot( state, accessParent->Copy(), name->GetSymbol() ) ); - - // subtract base_vertex from vertex_id to match dx12 behaviour for SV_VertexID - if( name->GetSymbol()->semantic == "SV_VertexID" ) - { - auto base_param = NewFunctionParameter( state, hlsl::uint_t ); - base_param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_vertex ); - destStruct->AddChild( base_param ); - - auto assignment = NewBinaryExpression( - state, - OP_SUB_ASSIGN, - NewVarIdentifier( state, param->GetSymbol() ), - NewVarIdentifier( state, base_param->GetSymbol() ) ); - ASTNode* node = NewExpressionStatement( state, assignment ); - shaderBody->AddChild( node ); - } + auto base_param = NewFunctionParameter( state, hlsl::uint_t ); + base_param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_vertex ); + destStruct->AddChild( base_param ); + + auto assignment = NewBinaryExpression( + state, + OP_SUB_ASSIGN, + NewVarIdentifier( state, param->GetSymbol() ), + NewVarIdentifier( state, base_param->GetSymbol() ) ); + ASTNode* node = NewExpressionStatement( state, assignment ); + shaderBody->AddChild( node ); + } - // subtract base_instance from instance_id to match dx12 behaviour for SV_InstanceID - if( name->GetSymbol()->semantic == "SV_InstanceID" ) - { - auto base_param = NewFunctionParameter( state, hlsl::uint_t ); - base_param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_instance ); - destStruct->AddChild( base_param ); - - auto assignment = NewBinaryExpression( - state, - OP_SUB_ASSIGN, - NewVarIdentifier( state, param->GetSymbol() ), - NewVarIdentifier( state, base_param->GetSymbol() ) ); - ASTNode* node = NewExpressionStatement( state, assignment ); - shaderBody->AddChild( node ); - } + // subtract base_instance from instance_id to match dx12 behaviour for SV_InstanceID + if( name->GetSymbol()->semantic == "SV_InstanceID" ) + { + auto base_param = NewFunctionParameter( state, hlsl::uint_t ); + base_param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_instance ); + destStruct->AddChild( base_param ); + + auto assignment = NewBinaryExpression( + state, + OP_SUB_ASSIGN, + NewVarIdentifier( state, param->GetSymbol() ), + NewVarIdentifier( state, base_param->GetSymbol() ) ); + ASTNode* node = NewExpressionStatement( state, assignment ); + shaderBody->AddChild( node ); } } } } } +} - bool HasSystemRegister( Symbol* symbol ) - { - assert( symbol ); +bool HasSystemRegister( Symbol* symbol ) +{ + assert( symbol ); - bool hasSystemRegister = false; - for( auto& it : symbol->registerSpecifier ) + bool hasSystemRegister = false; + for( auto& it : symbol->registerSpecifier ) + { + if( it.second.registerType == MetalRegister::System ) { - if( it.second.registerType == MetalRegister::System ) - { - hasSystemRegister = true; - break; - } + hasSystemRegister = true; + break; } - - return hasSystemRegister; } - // Given a function header, gathers all inputs for [[stage_in]] into a flat structure - void GatherInputs( ASTNode* destStruct, std::vector& accessors, const std::vector& params, ASTNode* header, ParserState& state ) + return hasSystemRegister; +} + +// Given a function header, gathers all inputs for [[stage_in]] into a flat structure +void GatherInputs( ASTNode* destStruct, std::vector& accessors, const std::vector& params, ASTNode* header, ParserState& state ) +{ + for( size_t i = 0; i < header->GetChildrenCount(); ++i ) { - for( size_t i = 0; i < header->GetChildrenCount(); ++i ) + auto arg = header->GetChild( i ); + + if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) + { + continue; + } + bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; + if( !isIn ) { - auto arg = header->GetChild( i ); + continue; + } - if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) - { - continue; - } - bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; - if( !isIn ) - { - continue; - } + Symbol* symbol = arg->GetSymbol(); + if( !symbol ) + { + continue; + } - Symbol* symbol = arg->GetSymbol(); - if( !symbol ) - { - continue; - } + if( HasSystemRegister( symbol ) ) + { + continue; + } - if( HasSystemRegister( symbol ) ) - { - continue; - } - - if( !params[i] ) - { - continue; - } + if( !params[i] ) + { + continue; + } - if( symbol->type.IsStruct() ) - { - GatherFields( destStruct, accessors, NewVarIdentifier( state, params[i] ), symbol->type.symbol->definition, state ); - } - else if( symbol->type.IsScalarOrVector() ) - { - destStruct->AddChild( NewStructMember( state, symbol ) ); - accessors.push_back( NewVarIdentifier( state, params[i] ) ); - } + if( symbol->type.IsStruct() ) + { + GatherFields( destStruct, accessors, NewVarIdentifier( state, params[i] ), symbol->type.symbol->definition, state ); + } + else if( symbol->type.IsScalarOrVector() ) + { + destStruct->AddChild( NewStructMember( state, symbol ) ); + accessors.push_back( NewVarIdentifier( state, params[i] ) ); } } +} - void GatherSystemInputs( ASTNode* destStruct, std::vector& accessors, std::vector& argumentAccessors, const std::vector& params, ASTNode* header, ASTNode* shaderBody, ParserState& state ) +void GatherSystemInputs( ASTNode* destStruct, std::vector& accessors, std::vector& argumentAccessors, const std::vector& params, ASTNode* header, ASTNode* shaderBody, ParserState& state ) +{ + for( size_t i = 0; i < header->GetChildrenCount(); ++i ) { - for( size_t i = 0; i < header->GetChildrenCount(); ++i ) + auto arg = header->GetChild( i ); + + if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) + { + continue; + } + bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; + if( !isIn ) { - auto arg = header->GetChild( i ); + continue; + } - if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) - { - continue; - } - bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; - if( !isIn ) + Symbol* symbol = arg->GetSymbol(); + if( !symbol ) + { + continue; + } + + if( HasSystemRegister( symbol ) ) + { + // subtract base_vertex from vertex_id to match dx12 behaviour for SV_VertexID + if( symbol->semantic == "SV_VertexID" ) { - continue; + auto param = NewFunctionParameter( state, hlsl::uint_t ); + param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_vertex ); + destStruct->AddChild( param ); + + auto assignment = NewBinaryExpression( + state, + OP_SUB_ASSIGN, + NewVarIdentifier( state, header->GetChild( i )->GetSymbol() ), + NewVarIdentifier( state, param->GetSymbol() ) ); + ASTNode* node = NewExpressionStatement( state, assignment ); + shaderBody->AddChild( node ); } - Symbol* symbol = arg->GetSymbol(); - if( !symbol ) + // subtract base_instance from instance_id to match dx12 behaviour for SV_InstanceID + if( symbol->semantic == "SV_InstanceID" ) { - continue; + auto param = NewFunctionParameter( state, hlsl::uint_t ); + param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_instance ); + destStruct->AddChild( param ); + + auto assignment = NewBinaryExpression( + state, + OP_SUB_ASSIGN, + NewVarIdentifier( state, header->GetChild( i )->GetSymbol() ), + NewVarIdentifier( state, param->GetSymbol() ) ); + ASTNode* node = NewExpressionStatement( state, assignment ); + shaderBody->AddChild( node ); } - if( HasSystemRegister( symbol ) ) - { - // subtract base_vertex from vertex_id to match dx12 behaviour for SV_VertexID - if( symbol->semantic == "SV_VertexID" ) - { - auto param = NewFunctionParameter( state, hlsl::uint_t ); - param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_vertex ); - destStruct->AddChild( param ); + continue; + } - auto assignment = NewBinaryExpression( - state, - OP_SUB_ASSIGN, - NewVarIdentifier( state, header->GetChild( i )->GetSymbol() ), - NewVarIdentifier( state, param->GetSymbol() ) ); - ASTNode* node = NewExpressionStatement( state, assignment ); - shaderBody->AddChild( node ); - } + if( !params[i] ) + { + continue; + } - // subtract base_instance from instance_id to match dx12 behaviour for SV_InstanceID - if( symbol->semantic == "SV_InstanceID" ) - { - auto param = NewFunctionParameter( state, hlsl::uint_t ); - param->GetSymbol()->registerSpecifier[{}] = MetalSystemSemantics( MetalSystemSemanticsType::Enum::base_instance ); - destStruct->AddChild( param ); + if( symbol->type.IsStruct() ) + { + GatherSystemFields( destStruct, accessors, argumentAccessors, NewVarIdentifier( state, params[i] ), symbol->type.symbol->definition, shaderBody, state ); + } + } +} - auto assignment = NewBinaryExpression( - state, - OP_SUB_ASSIGN, - NewVarIdentifier( state, header->GetChild( i )->GetSymbol() ), - NewVarIdentifier( state, param->GetSymbol() ) ); - ASTNode* node = NewExpressionStatement( state, assignment ); - shaderBody->AddChild( node ); - } +// Given a function header, gathers all function outputs into a flat structure +void GatherOutputs( ASTNode* destStruct, std::vector& accessors, const std::vector& params, ASTNode* header, ParserState& state ) +{ + for( size_t i = 0; i < header->GetChildrenCount(); ++i ) + { + auto arg = header->GetChild( i ); - continue; - } + if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) + { + continue; + } - if( !params[i] ) - { - continue; - } + bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; + if( isIn ) + { + continue; + } - if( symbol->type.IsStruct() ) - { - GatherSystemFields( destStruct, accessors, argumentAccessors, NewVarIdentifier( state, params[i] ), symbol->type.symbol->definition, shaderBody, state ); - } + Symbol* symbol = arg->GetSymbol(); + if( symbol == nullptr ) + { + continue; } - } - // Given a function header, gathers all function outputs into a flat structure - void GatherOutputs( ASTNode* destStruct, std::vector& accessors, const std::vector& params, ASTNode* header, ParserState& state ) + auto access = NewVarIdentifier( state, params[i] ); + + if( symbol->type.IsStruct() ) + { + GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state ); + } + else if( symbol->type.IsScalarOrVector() ) + { + destStruct->AddChild( NewStructMember( state, symbol ) ); + accessors.push_back( access ); + } + } + if( header->GetType().IsStruct() || header->GetType().IsScalarOrVector() ) { - for( size_t i = 0; i < header->GetChildrenCount(); ++i ) + Symbol* symbol = header->GetSymbol(); + auto access = NewVarIdentifier( state, params.back() ); + + if( symbol->type.IsStruct() ) + { + GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state ); + } + else { - auto arg = header->GetChild( i ); + destStruct->AddChild( NewStructMember( state, symbol ) ); + accessors.push_back( access ); + } + } +} - if( IsUniformInputArgument( arg ) || arg->GetSymbol()->addressSpace != AddressSpace::None ) - { - continue; - } +// Patches VPOS usages for pixel shaders: a common Dx9 legacy pattern of passing both POSITION (from +// vertex shader) and VPOS. Function remaps VPOS inputs to POSION so that there are no duplicate semantics +// in the stage_in struct. +bool PatchVpos( ParserState& state, ASTNode* inputsStruct, std::vector& argumentAccessors ) +{ + Type float4 = TypeFromTokenType( OP_FLOAT ); + float4.width = 4; - bool isIn = arg->GetToken() == 0 || arg->GetToken()->type == OP_IN; - if( isIn ) + // First find POSITION input + ASTNode* position = nullptr; + size_t positionIndex = 0; + for( size_t index = 0; index < inputsStruct->GetChildrenCount(); ++index ) + { + auto child = inputsStruct->GetChild( index ); + auto member = child->GetChild( 0 ); + if( IEquals( member->GetSymbol()->semantic, "SV_Position" ) || IEquals( member->GetSymbol()->semantic, "POSITION" ) || IEquals( member->GetSymbol()->semantic, "POSITION0" ) ) + { + if( child->GetType() != float4 ) { - continue; + state.ShowMessage( EC_CUSTOM_ERROR, "Pixel shader %s input needs to be a float4", ToString( member->GetSymbol()->semantic ).c_str() ); + return false; } + position = child; + positionIndex = index; + break; + } + } - Symbol* symbol = arg->GetSymbol(); - if( symbol == nullptr ) + // Find any other POSITION/VPOS inputs and remap them to the first POSITION + for( size_t index = 0; index < inputsStruct->GetChildrenCount(); ++index ) + { + auto child = inputsStruct->GetChild( index ); + if( child == position ) + { + continue; + } + auto member = child->GetChild( 0 ); + if( IEquals( member->GetSymbol()->semantic, "SV_Position" ) || IEquals( member->GetSymbol()->semantic, "POSITION" ) || IEquals( member->GetSymbol()->semantic, "POSITION0" ) || IEquals( member->GetSymbol()->semantic, "VPOS" ) ) + { + if( !child->GetType().IsScalarOrVector() || child->GetType().builtInType != OP_FLOAT ) { - continue; + state.ShowMessage( EC_CUSTOM_ERROR, "Pixel shader %s input needs to be a float vector", ToString( member->GetSymbol()->semantic ).c_str() ); + return false; } - - auto access = NewVarIdentifier( state, params[i] ); - - if( symbol->type.IsStruct() ) + if( position ) { - GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state ); + if( position->GetType() != child->GetType() ) + { + const char* swizzles = "xyzw"; + argumentAccessors[index] = NewDot( state, + argumentAccessors[positionIndex]->Copy(), + MakeInlineString( swizzles, swizzles + 4 - child->GetType().width ) ); + } + else + { + argumentAccessors[index] = argumentAccessors[positionIndex]->Copy(); + } + inputsStruct->RemoveChild( index ); + --index; } - else if( symbol->type.IsScalarOrVector() ) + else if( child->GetType().width != 4 ) { - destStruct->AddChild( NewStructMember( state, symbol ) ); - accessors.push_back( access ); + const char* swizzles = "xyzw"; + argumentAccessors[index] = NewDot( state, + argumentAccessors[index]->Copy(), + MakeInlineString( swizzles, swizzles + 4 - child->GetType().width ) ); + child->SetType( float4 ); + member->SetType( float4 ); + member->GetSymbol()->type = float4; } } - if( header->GetType().IsStruct() || header->GetType().IsScalarOrVector() ) - { - Symbol* symbol = header->GetSymbol(); - auto access = NewVarIdentifier( state, params.back() ); + } + return true; +} - if( symbol->type.IsStruct() ) +void ApplyPackedModifier( ASTNode* structNode, bool tightPacking ) +{ + for( auto member : structNode->GetChildren() ) + { + for( auto var : member->GetChildren() ) + { + auto& type = var->GetSymbol()->type; + if( type.IsVector() && ( tightPacking || type.width == 3 ) && type.builtInType != OP_BOOL ) { - GatherFields( destStruct, accessors, access, symbol->type.symbol->definition, state ); + type.modifier = OP_PACKOFFSET; // let us abuse this token type! } - else + else if( type.IsStruct() ) { - destStruct->AddChild( NewStructMember( state, symbol ) ); - accessors.push_back( access ); + ApplyPackedModifier( type.symbol->definition, tightPacking ); } } } - - // Patches VPOS usages for pixel shaders: a common Dx9 legacy pattern of passing both POSITION (from - // vertex shader) and VPOS. Function remaps VPOS inputs to POSION so that there are no duplicate semantics - // in the stage_in struct. - bool PatchVpos( ParserState& state, ASTNode* inputsStruct, std::vector& argumentAccessors ) +} + +void ApplyPackedModifiersToConstantBuffers( ASTNode* functionDefinition ) +{ + ASTNode* functionHeader = functionDefinition->GetChildOrNull( 0 ); + if( !functionHeader ) { - Type float4 = TypeFromTokenType( OP_FLOAT ); - float4.width = 4; - - // First find POSITION input - ASTNode* position = nullptr; - size_t positionIndex = 0; - for( size_t index = 0; index < inputsStruct->GetChildrenCount(); ++index ) - { - auto child = inputsStruct->GetChild( index ); - auto member = child->GetChild( 0 ); - if( IEquals( member->GetSymbol()->semantic, "SV_Position" ) || IEquals( member->GetSymbol()->semantic, "POSITION" ) || IEquals( member->GetSymbol()->semantic, "POSITION0" ) ) + return; + } + + for( auto arg : functionHeader->GetChildren() ) + { + if( Symbol* symbol = arg->GetSymbol() ) + { + auto& type = symbol->type; + if( type.IsStruct() && GetCBufferIndex( symbol ) >= 0 ) { - if( child->GetType() != float4 ) - { - state.ShowMessage( EC_CUSTOM_ERROR, "Pixel shader %s input needs to be a float4", ToString( member->GetSymbol()->semantic ).c_str() ); - return false; - } - position = child; - positionIndex = index; - break; + ApplyPackedModifier( type.symbol->definition, false ); } - } - - // Find any other POSITION/VPOS inputs and remap them to the first POSITION - for( size_t index = 0; index < inputsStruct->GetChildrenCount(); ++index ) - { - auto child = inputsStruct->GetChild( index ); - if( child == position ) + else if( type.IsStruct() && !symbol->registerSpecifier.empty() && symbol->registerSpecifier.begin()->second.registerType == MetalRegister::CBuffer ) { - continue; + ApplyPackedModifier( type.symbol->definition, false ); } - auto member = child->GetChild( 0 ); - if( IEquals( member->GetSymbol()->semantic, "SV_Position" ) || IEquals( member->GetSymbol()->semantic, "POSITION" ) || IEquals( member->GetSymbol()->semantic, "POSITION0" ) || IEquals( member->GetSymbol()->semantic, "VPOS" ) ) + else if( type.symbol == nullptr && ( type.builtInType == OP_STRUCTUREDBUFFER || type.builtInType == OP_RWSTRUCTUREDBUFFER ) ) { - if( !child->GetType().IsScalarOrVector() || child->GetType().builtInType != OP_FLOAT ) - { - state.ShowMessage( EC_CUSTOM_ERROR, "Pixel shader %s input needs to be a float vector", ToString( member->GetSymbol()->semantic ).c_str() ); - return false; - } - if( position ) - { - if( position->GetType() != child->GetType() ) - { - const char* swizzles = "xyzw"; - argumentAccessors[index] = NewDot( state, - argumentAccessors[positionIndex]->Copy(), - MakeInlineString( swizzles, swizzles + 4 - child->GetType().width ) ); - } - else - { - argumentAccessors[index] = argumentAccessors[positionIndex]->Copy(); - } - inputsStruct->RemoveChild( index ); - --index; - } - else if( child->GetType().width != 4 ) + if( type.templateParameter && type.templateParameter->IsStruct() ) { - const char* swizzles = "xyzw"; - argumentAccessors[index] = NewDot( state, - argumentAccessors[index]->Copy(), - MakeInlineString( swizzles, swizzles + 4 - child->GetType().width ) ); - child->SetType( float4 ); - member->SetType( float4 ); - member->GetSymbol()->type = float4; + ApplyPackedModifier( type.templateParameter->symbol->definition, true ); } } } - return true; } +} + +enum class PatchShaderType +{ + VERTEX, + PIXEL, + COMPUTE, + + RAY_GEN, + MISS, + CLOSEST_HIT, + ANY_HIT, +}; - void ApplyPackedModifier( ASTNode* structNode, bool tightPacking ) +InlineString GetEntryPointName( PatchShaderType shaderType, ASTNode* callNode ) +{ + switch( shaderType ) { - for( auto member : structNode->GetChildren() ) - { - for( auto var : member->GetChildren() ) - { - auto& type = var->GetSymbol()->type; - if( type.IsVector() && ( tightPacking || type.width == 3 ) && type.builtInType != OP_BOOL ) - { - type.modifier = OP_PACKOFFSET; // let us abuse this token type! - } - else if( type.IsStruct() ) - { - ApplyPackedModifier( type.symbol->definition, tightPacking ); - } - } - } + case PatchShaderType::VERTEX: + return MakeInlineString( "mainVS" ); + case PatchShaderType::PIXEL: + return MakeInlineString( "mainPS" ); + case PatchShaderType::COMPUTE: + return MakeInlineString( "mainCS" ); + default: + return callNode->GetSymbol()->name; + } +} + +InlineString GetShaderAttribute( PatchShaderType shaderType ) +{ + switch( shaderType ) + { + case PatchShaderType::VERTEX: + return MakeInlineString( "vertex" ); + case PatchShaderType::PIXEL: + return MakeInlineString( "fragment" ); + case PatchShaderType::COMPUTE: + return MakeInlineString( "kernel" ); + case PatchShaderType::RAY_GEN: + return MakeInlineString( "kernel" ); + case PatchShaderType::MISS: + case PatchShaderType::CLOSEST_HIT: + return MakeInlineString( "[[visible]]" ); + case PatchShaderType::ANY_HIT: + return MakeInlineString( "[[intersection(triangle, __INTERSECION_TAGS)]]" ); + default: + return MakeInlineString( "" ); } +} - void ApplyPackedModifiersToConstantBuffers( ASTNode* functionDefinition ) +void FindCallsToSymbol( ASTNode* node, Symbol* symbol, std::vector& calls ) +{ + if( node->GetNodeType() == NT_FUNCTION_CALL ) { - ASTNode* functionHeader = functionDefinition->GetChildOrNull( 0 ); - if( !functionHeader ) + if( node->GetSymbol() == symbol ) { - return; + calls.push_back( node ); } - - for( auto arg : functionHeader->GetChildren() ) + if( node->GetSymbol() && node->GetSymbol()->definition ) { - if( Symbol* symbol = arg->GetSymbol() ) - { - auto& type = symbol->type; - if( type.IsStruct() && GetCBufferIndex( symbol ) >= 0 ) - { - ApplyPackedModifier( type.symbol->definition, false ); - } - else if( type.IsStruct() && !symbol->registerSpecifier.empty() && symbol->registerSpecifier.begin()->second.registerType == MetalRegister::CBuffer ) - { - ApplyPackedModifier( type.symbol->definition, false ); - } - else if( type.symbol == nullptr && ( type.builtInType == OP_STRUCTUREDBUFFER || type.builtInType == OP_RWSTRUCTUREDBUFFER ) ) - { - if( type.templateParameter && type.templateParameter->IsStruct() ) - { - ApplyPackedModifier( type.templateParameter->symbol->definition, true ); - } - } - } + FindCallsToSymbol( node->GetSymbol()->definition, symbol, calls ); } } + for( auto& child : node->GetChildren() ) + { + if( child ) + { + FindCallsToSymbol( child, symbol, calls ); + } + } +} - enum class PatchShaderType - { - VERTEX, - PIXEL, - COMPUTE, - - RAY_GEN, - MISS, - CLOSEST_HIT, - ANY_HIT, - }; - - InlineString GetEntryPointName( PatchShaderType shaderType, ASTNode* callNode ) - { - switch ( shaderType ) - { - case PatchShaderType::VERTEX: - return MakeInlineString( "mainVS" ); - case PatchShaderType::PIXEL: - return MakeInlineString( "mainPS" ); - case PatchShaderType::COMPUTE: - return MakeInlineString( "mainCS" ); - default: - return callNode->GetSymbol()->name; - } - } - - InlineString GetShaderAttribute( PatchShaderType shaderType ) - { - switch ( shaderType ) - { - case PatchShaderType::VERTEX: - return MakeInlineString( "vertex" ); - case PatchShaderType::PIXEL: - return MakeInlineString( "fragment" ); - case PatchShaderType::COMPUTE: - return MakeInlineString( "kernel" ); - case PatchShaderType::RAY_GEN: - return MakeInlineString( "kernel" ); - case PatchShaderType::MISS: - case PatchShaderType::CLOSEST_HIT: - return MakeInlineString( "[[visible]]" ); - case PatchShaderType::ANY_HIT: - return MakeInlineString( "[[intersection(triangle, __INTERSECION_TAGS)]]" ); - default: - return MakeInlineString( "" ); - } - - } - - void FindCallsToSymbol( ASTNode* node, Symbol* symbol, std::vector& calls ) - { - if( node->GetNodeType() == NT_FUNCTION_CALL ) - { - if( node->GetSymbol() == symbol ) - { - calls.push_back( node ); - } - if( node->GetSymbol() && node->GetSymbol()->definition ) - { - FindCallsToSymbol( node->GetSymbol()->definition, symbol, calls ); - } - } - for( auto& child : node->GetChildren() ) - { - if( child ) - { - FindCallsToSymbol( child, symbol, calls ); - } - } - } - - // Creates a new shader functions with all the inputs/outputs layed out for Metal: - // - all [[stage_in]] inputs are put into a new flat struct - // - all outputs are put into a new struct - // - uniform arguments are moved to local variables inside the shader - // - all the other arguments from the original entry point are passed as is - // Returns new entry point function definition (added to AST root) - ASTNode* PatchShader( PatchShaderType shaderType, ASTNode* callNode, ParserState& state ) - { - ZoneScoped; - - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return nullptr; - } - - ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); - if( !functionHeader ) - { - return nullptr; - } - - ScannerToken shaderName = ScannerToken::ID( GetEntryPointName( shaderType, callNode ) ); - - state.GetCurrentLocation().fileName = shaderName.stringValue; - state.GetCurrentLocation().lineNumber = 1; - - ASTNode* inputsStruct = NewStruct( state, state.AllocateNameWithPrefix( "StageInData" ) ); - ASTNode* outputsStruct = NewStruct( state, state.AllocateNameWithPrefix( "StageOutData" ) ); - - auto header = state.NewNode( NT_FUNCTION_HEADER, shaderName ); - auto shaderSymbol = state.GetSymbolTable().AddSymbol( shaderName.stringValue, ALLOW_OVERRIDES ); - shaderSymbol->isFunction = true; - header->SetSymbol( shaderSymbol ); - - state.GetSymbolTable().EnterScope(); - - auto shaderBody = state.NewNode( NT_BLOCK ); - - std::vector params; - - size_t uniformArgIndex = 0; +// Creates a new shader functions with all the inputs/outputs layed out for Metal: +// - all [[stage_in]] inputs are put into a new flat struct +// - all outputs are put into a new struct +// - uniform arguments are moved to local variables inside the shader +// - all the other arguments from the original entry point are passed as is +// Returns new entry point function definition (added to AST root) +ASTNode* PatchShader( PatchShaderType shaderType, ASTNode* callNode, ParserState& state ) +{ + ZoneScoped; - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) - { - // Create local variable declarations for original shader function arguments + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return nullptr; + } - ASTNode* sourceArg = functionHeader->GetChild( i ); - Symbol* sourceSymbol = sourceArg->GetSymbol(); - ASTNode* bracketList = sourceArg->GetChildOrNull( 0 ); + ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); + if( !functionHeader ) + { + return nullptr; + } - if( sourceSymbol->addressSpace != AddressSpace::Threadgroup && - !IsUniformInputArgument( sourceArg ) && - ( ( !sourceArg->GetType().IsStruct() && !sourceArg->GetType().IsScalarOrVector() ) || - sourceSymbol->addressSpace != AddressSpace::None || - HasSystemRegister( sourceSymbol ) ) ) - { - params.push_back( nullptr ); - continue; - } - - auto isUniform = IsUniformInputArgument( sourceArg ); - if( shaderType >= PatchShaderType::RAY_GEN && !isUniform ) - { - params.push_back( nullptr ); - continue; - } - - auto declList = NewVarDeclaration( state, - sourceArg->GetType(), - state.AllocateName( sourceSymbol->name ) ); - ASTNode* declaration = declList->GetChild( 0 ); - auto nameSymbol = declaration->GetSymbol(); - nameSymbol->addressSpace = sourceSymbol->addressSpace; - shaderBody->AddChild( declList ); + ScannerToken shaderName = ScannerToken::ID( GetEntryPointName( shaderType, callNode ) ); - params.push_back( nameSymbol ); + state.GetCurrentLocation().fileName = shaderName.stringValue; + state.GetCurrentLocation().lineNumber = 1; - if( isUniform ) - { - // uniform arguments are initialized with whatever was passed in the call node + ASTNode* inputsStruct = NewStruct( state, state.AllocateNameWithPrefix( "StageInData" ) ); + ASTNode* outputsStruct = NewStruct( state, state.AllocateNameWithPrefix( "StageOutData" ) ); - if( callNode->GetChildrenCount() <= uniformArgIndex ) - { - state.ShowMessage( callNode->GetLocation(), EC_NO_OVERRIDE, ToString( functionHeader->GetToken()->stringValue ).c_str(), "" ); - return nullptr; - } + auto header = state.NewNode( NT_FUNCTION_HEADER, shaderName ); + auto shaderSymbol = state.GetSymbolTable().AddSymbol( shaderName.stringValue, ALLOW_OVERRIDES ); + shaderSymbol->isFunction = true; + header->SetSymbol( shaderSymbol ); - declaration->AddChild( nullptr ); - declaration->AddChild( callNode->GetChild( uniformArgIndex++ ) ); - } - else if( bracketList ) - { - declaration->AddChild( bracketList->Copy() ); - } + state.GetSymbolTable().EnterScope(); + + auto shaderBody = state.NewNode( NT_BLOCK ); + + std::vector params; + + size_t uniformArgIndex = 0; + + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + // Create local variable declarations for original shader function arguments + + ASTNode* sourceArg = functionHeader->GetChild( i ); + Symbol* sourceSymbol = sourceArg->GetSymbol(); + ASTNode* bracketList = sourceArg->GetChildOrNull( 0 ); + + if( sourceSymbol->addressSpace != AddressSpace::Threadgroup && + !IsUniformInputArgument( sourceArg ) && + ( ( !sourceArg->GetType().IsStruct() && !sourceArg->GetType().IsScalarOrVector() ) || + sourceSymbol->addressSpace != AddressSpace::None || + HasSystemRegister( sourceSymbol ) ) ) + { + params.push_back( nullptr ); + continue; } - if( callNode->GetChildrenCount() != uniformArgIndex ) + + auto isUniform = IsUniformInputArgument( sourceArg ); + if( shaderType >= PatchShaderType::RAY_GEN && !isUniform ) { - state.ShowMessage( callNode->GetLocation(), EC_NO_OVERRIDE, ToString( functionHeader->GetToken()->stringValue ).c_str(), "" ); - return nullptr; + params.push_back( nullptr ); + continue; } - bool hasReturnType = functionHeader->GetType() != hlsl::void_t; - if( hasReturnType ) + auto declList = NewVarDeclaration( state, + sourceArg->GetType(), + state.AllocateName( sourceSymbol->name ) ); + ASTNode* declaration = declList->GetChild( 0 ); + auto nameSymbol = declaration->GetSymbol(); + nameSymbol->addressSpace = sourceSymbol->addressSpace; + shaderBody->AddChild( declList ); + + params.push_back( nameSymbol ); + + if( isUniform ) { - // Local variable for return value + // uniform arguments are initialized with whatever was passed in the call node - auto declList = NewVarDeclaration( state, functionHeader->GetType(), state.AllocateNameWithPrefix( "result" ) ); - auto nameSymbol = declList->GetChild( 0 )->GetSymbol(); - shaderBody->AddChild( declList ); + if( callNode->GetChildrenCount() <= uniformArgIndex ) + { + state.ShowMessage( callNode->GetLocation(), EC_NO_OVERRIDE, ToString( functionHeader->GetToken()->stringValue ).c_str(), "" ); + return nullptr; + } - params.push_back( nameSymbol ); + declaration->AddChild( nullptr ); + declaration->AddChild( callNode->GetChild( uniformArgIndex++ ) ); + } + else if( bracketList ) + { + declaration->AddChild( bracketList->Copy() ); } + } + if( callNode->GetChildrenCount() != uniformArgIndex ) + { + state.ShowMessage( callNode->GetLocation(), EC_NO_OVERRIDE, ToString( functionHeader->GetToken()->stringValue ).c_str(), "" ); + return nullptr; + } + + bool hasReturnType = functionHeader->GetType() != hlsl::void_t; + if( hasReturnType ) + { + // Local variable for return value + + auto declList = NewVarDeclaration( state, functionHeader->GetType(), state.AllocateNameWithPrefix( "result" ) ); + auto nameSymbol = declList->GetChild( 0 )->GetSymbol(); + shaderBody->AddChild( declList ); + + params.push_back( nameSymbol ); + } + + std::vector inputAccessors; + std::vector outputAccessors; + std::vector argumentAccessors; + + GatherSystemInputs( header, inputAccessors, argumentAccessors, params, functionHeader, shaderBody, state ); + GatherInputs( inputsStruct, inputAccessors, params, functionHeader, state ); + GatherOutputs( outputsStruct, outputAccessors, params, functionHeader, state ); + + Symbol* stageInSymbol = nullptr; + + // Don't add an empty input struct. + if( inputsStruct->GetChildrenCount() == 0 ) + { + delete inputsStruct; + inputsStruct = nullptr; + } + else + { + state.GetTree()->AddChild( inputsStruct ); + + // Add [[stage_in]] parameter. + auto stageIn = NewFunctionParameter( state, TypeFromSymbol( inputsStruct->GetSymbol() ), state.AllocateNameWithPrefix( "stageIn" ) ); + header->AddChild( stageIn ); - std::vector inputAccessors; - std::vector outputAccessors; - std::vector argumentAccessors; + stageInSymbol = stageIn->GetSymbol(); + stageInSymbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::StageIn ); + } - GatherSystemInputs( header, inputAccessors, argumentAccessors, params, functionHeader, shaderBody, state ); - GatherInputs( inputsStruct, inputAccessors, params, functionHeader, state ); - GatherOutputs( outputsStruct, outputAccessors, params, functionHeader, state ); + // Don't add an empty output struct. + if( outputsStruct->GetChildrenCount() == 0 ) + { + delete outputsStruct; + outputsStruct = nullptr; + } + else + { + state.GetTree()->AddChild( outputsStruct ); + } - Symbol* stageInSymbol = nullptr; - // Don't add an empty input struct. - if( inputsStruct->GetChildrenCount() == 0 ) + if( inputsStruct ) + { + for( size_t i = 0; i < inputsStruct->GetChildrenCount(); ++i ) { - delete inputsStruct; - inputsStruct = nullptr; + argumentAccessors.push_back( NewDot( state, NewVarIdentifier( state, stageInSymbol ), inputsStruct->GetChild( i )->GetChild( 0 )->GetSymbol() ) ); } - else + + if( shaderType == PatchShaderType::PIXEL ) + { + if( !PatchVpos( state, inputsStruct, argumentAccessors ) ) + { + return nullptr; + } + } + } + + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + // Add parameters for the rest of original shader inputs + ASTNode* sourceArg = functionHeader->GetChild( i ); + Symbol* sourceSymbol = sourceArg->GetSymbol(); + + if( sourceSymbol->addressSpace != AddressSpace::Threadgroup && + !IsUniformInputArgument( sourceArg ) && + ( ( !sourceArg->GetType().IsStruct() && !sourceArg->GetType().IsScalarOrVector() ) || + sourceSymbol->addressSpace != AddressSpace::None || + HasSystemRegister( sourceSymbol ) ) ) { - state.GetTree()->AddChild( inputsStruct ); + auto arg = NewFunctionParameter( state, sourceArg->GetType(), state.AllocateName( sourceSymbol->name ) ); + arg->GetSymbol()->addressSpace = sourceSymbol->addressSpace; + arg->GetSymbol()->registerSpecifier.swap( sourceSymbol->registerSpecifier ); + // arg->GetSymbol()->registerSpecifier = sourceSymbol->registerSpecifier; - // Add [[stage_in]] parameter. - auto stageIn = NewFunctionParameter( state, TypeFromSymbol( inputsStruct->GetSymbol() ), state.AllocateNameWithPrefix( "stageIn" ) ); - header->AddChild( stageIn ); + if( sourceArg->GetType().IsStruct() ) + { + ScannerToken ref = {}; + ref.type = OP_INOUT; + + arg->SetToken( &ref ); + } - stageInSymbol = stageIn->GetSymbol(); - stageInSymbol->registerSpecifier[MakeInlineString( "" )] = RegisterSpecifier::Register( MetalRegister::StageIn ); + header->AddChild( arg ); + params[i] = arg->GetSymbol(); } + } - // Don't add an empty output struct. - if( outputsStruct->GetChildrenCount() == 0 ) + if( inputsStruct ) + { + for( size_t i = 0; i < inputAccessors.size(); ++i ) { - delete outputsStruct; - outputsStruct = nullptr; + // Add assignments for all inputsStruct fields. + auto assignment = NewBinaryExpression( + state, + OP_EQUAL, + inputAccessors[i], + argumentAccessors[i] ); + shaderBody->AddChild( NewExpressionStatement( state, assignment ) ); } - else + } + if( shaderType >= PatchShaderType::RAY_GEN ) + { + auto& statements = entryPointSymbol->definition->GetChild( 1 )->GetChildren(); + for( auto& stmt : statements ) { - state.GetTree()->AddChild( outputsStruct ); + shaderBody->AddChild( stmt->Copy() ); } - - - if( inputsStruct ) + header->SetType( hlsl::void_t ); + } + else + { + // Call the original function + auto call = state.NewNode( NT_FUNCTION_CALL, ScannerToken::ID( entryPointSymbol->name ) ); + call->SetSymbol( entryPointSymbol ); + call->SetType( functionHeader->GetType() ); + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) { - for( size_t i = 0; i < inputsStruct->GetChildrenCount(); ++i ) + if( ( params[i]->type.IsTexture() || params[i]->type.IsSampler() || params[i]->type.IsBuffer() ) && params[i]->type.arrayDimensions > 0 ) { - argumentAccessors.push_back( NewDot( state, NewVarIdentifier( state, stageInSymbol ), inputsStruct->GetChild( i )->GetChild( 0 )->GetSymbol() ) ); + auto cast = state.NewNode( NT_CAST_EXPRESSION ); + cast->SetType( params[i]->type ); + cast->AddChild( NewVarIdentifier( state, params[i] ) ); + call->AddChild( cast ); + cast->SetSymbol( params[i] ); } - - if( shaderType == PatchShaderType::PIXEL ) + else { - if( !PatchVpos( state, inputsStruct, argumentAccessors ) ) - { - return nullptr; - } + call->AddChild( NewVarIdentifier( state, params[i] ) ); } } - - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + if( hasReturnType ) { - // Add parameters for the rest of original shader inputs - ASTNode* sourceArg = functionHeader->GetChild( i ); - Symbol* sourceSymbol = sourceArg->GetSymbol(); + auto assignment = NewBinaryExpression( + state, + OP_EQUAL, + NewVarIdentifier( state, params.back() ), + call ); - if( sourceSymbol->addressSpace != AddressSpace::Threadgroup && - !IsUniformInputArgument( sourceArg ) && - ( ( !sourceArg->GetType().IsStruct() && !sourceArg->GetType().IsScalarOrVector() ) || - sourceSymbol->addressSpace != AddressSpace::None || - HasSystemRegister( sourceSymbol ) ) ) - { - auto arg = NewFunctionParameter( state, sourceArg->GetType(), state.AllocateName( sourceSymbol->name ) ); - arg->GetSymbol()->addressSpace = sourceSymbol->addressSpace; - arg->GetSymbol()->registerSpecifier.swap( sourceSymbol->registerSpecifier ); - // arg->GetSymbol()->registerSpecifier = sourceSymbol->registerSpecifier; + shaderBody->AddChild( NewExpressionStatement( state, assignment ) ); + } + else + { + shaderBody->AddChild( NewExpressionStatement( state, call ) ); + } - if( sourceArg->GetType().IsStruct() ) - { - ScannerToken ref = {}; - ref.type = OP_INOUT; + if( outputsStruct ) + { + header->SetType( TypeFromSymbol( outputsStruct->GetSymbol() ) ); - arg->SetToken( &ref ); - } + // Create a local variable for outputs + auto resultDeclList = NewVarDeclaration( state, TypeFromSymbol( outputsStruct->GetSymbol() ), state.AllocateNameWithPrefix( "stageOut" ) ); + auto resultSymbol = resultDeclList->GetChild( 0 )->GetSymbol(); + shaderBody->AddChild( resultDeclList ); - header->AddChild( arg ); - params[i] = arg->GetSymbol(); - } - } - - if( inputsStruct ) - { - for( size_t i = 0; i < inputAccessors.size(); ++i ) + for( size_t i = 0; i < outputsStruct->GetChildrenCount(); ++i ) { - // Add assignments for all inputsStruct fields. + // Add assignments for all fields in the output struct auto assignment = NewBinaryExpression( - state, - OP_EQUAL, - inputAccessors[i], - argumentAccessors[i] ); + state, + OP_EQUAL, + NewDot( state, NewVarIdentifier( state, resultSymbol ), outputsStruct->GetChild( i )->GetChild( 0 )->GetSymbol() ), + outputAccessors[i] ); shaderBody->AddChild( NewExpressionStatement( state, assignment ) ); } + + shaderBody->AddChild( NewReturn( state, NewVarIdentifier( state, resultSymbol ) ) ); + } + else + { + header->SetType( TypeFromTokenType( OP_VOID ) ); + } + } + + state.GetSymbolTable().LeaveScope(); + + auto shader = state.NewNode( NT_FUNCTION_DEFINITION ); + shaderSymbol->type = header->GetType(); + shaderSymbol->definition = shader; + shader->AddChild( header ); + shader->AddChild( shaderBody ); + + auto attribList = state.NewNode( NT_FUNCTION_ATTRIBUTE_LIST ); + attribList->AddChild( state.NewNode( NT_FUNCTION_ATTRIBUTE, ScannerToken::ID( GetShaderAttribute( shaderType ) ) ) ); + shader->AddChild( attribList ); + state.GetTree()->AddChild( shader ); + + // If the patched shader ends up using global scalar variables via uniform arguments, we need to + // convert their references into GlobalsData field lookups + if( auto globalStructSymbol = state.GetSymbolTable().Lookup( MakeInlineString( "GlobalsData" ) ) ) + { + std::set globalsStructMembers; + for( auto member : globalStructSymbol->definition->GetChildren() ) + { + globalsStructMembers.insert( member->GetChild( 0 )->GetSymbol() ); } - if( shaderType >= PatchShaderType::RAY_GEN ) - { - auto& statements = entryPointSymbol->definition->GetChild( 1 )->GetChildren(); - for( auto& stmt : statements ) - { - shaderBody->AddChild( stmt->Copy() ); - } - header->SetType( hlsl::void_t ); - } - else - { - // Call the original function - auto call = state.NewNode( NT_FUNCTION_CALL, ScannerToken::ID( entryPointSymbol->name ) ); - call->SetSymbol( entryPointSymbol ); - call->SetType( functionHeader->GetType() ); - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) - { - if( ( params[i]->type.IsTexture() || params[i]->type.IsSampler() || params[i]->type.IsBuffer() ) && params[i]->type.arrayDimensions > 0 ) - { - auto cast = state.NewNode( NT_CAST_EXPRESSION ); - cast->SetType( params[i]->type ); - cast->AddChild( NewVarIdentifier( state, params[i] ) ); - call->AddChild( cast ); - cast->SetSymbol( params[i] ); - } - else - { - call->AddChild( NewVarIdentifier( state, params[i] ) ); - } - } - if( hasReturnType ) - { - auto assignment = NewBinaryExpression( - state, - OP_EQUAL, - NewVarIdentifier( state, params.back() ), - call ); - - shaderBody->AddChild( NewExpressionStatement( state, assignment ) ); - } - else - { - shaderBody->AddChild( NewExpressionStatement( state, call ) ); - } - - if( outputsStruct ) - { - header->SetType( TypeFromSymbol( outputsStruct->GetSymbol() ) ); - - // Create a local variable for outputs - auto resultDeclList = NewVarDeclaration( state, TypeFromSymbol( outputsStruct->GetSymbol() ), state.AllocateNameWithPrefix( "stageOut" ) ); - auto resultSymbol = resultDeclList->GetChild( 0 )->GetSymbol(); - shaderBody->AddChild( resultDeclList ); - - for( size_t i = 0; i < outputsStruct->GetChildrenCount(); ++i ) - { - // Add assignments for all fields in the output struct - auto assignment = NewBinaryExpression( - state, - OP_EQUAL, - NewDot( state, NewVarIdentifier( state, resultSymbol ), outputsStruct->GetChild( i )->GetChild( 0 )->GetSymbol() ), - outputAccessors[i] ); - shaderBody->AddChild( NewExpressionStatement( state, assignment ) ); - } - - shaderBody->AddChild( NewReturn( state, NewVarIdentifier( state, resultSymbol ) ) ); - } - else - { - header->SetType( TypeFromTokenType( OP_VOID ) ); - } - } - - state.GetSymbolTable().LeaveScope(); - - auto shader = state.NewNode( NT_FUNCTION_DEFINITION ); - shaderSymbol->type = header->GetType(); - shaderSymbol->definition = shader; - shader->AddChild( header ); - shader->AddChild( shaderBody ); - - auto attribList = state.NewNode( NT_FUNCTION_ATTRIBUTE_LIST ); - attribList->AddChild( state.NewNode( NT_FUNCTION_ATTRIBUTE, ScannerToken::ID( GetShaderAttribute( shaderType ) ) ) ); - shader->AddChild( attribList ); - state.GetTree()->AddChild( shader ); - - // If the patched shader ends up using global scalar variables via uniform arguments, we need to - // convert their references into GlobalsData field lookups - if( auto globalStructSymbol = state.GetSymbolTable().Lookup( MakeInlineString( "GlobalsData" ) ) ) - { - std::set globalsStructMembers; - for( auto member : globalStructSymbol->definition->GetChildren() ) + Symbol* globalsParam = nullptr; + for( auto param : header->GetChildren() ) + { + if( param->GetType().symbol == globalStructSymbol ) { - globalsStructMembers.insert( member->GetChild( 0 )->GetSymbol() ); + globalsParam = param->GetSymbol(); + break; } - Symbol* globalsParam = nullptr; - for( auto param : header->GetChildren() ) + } + shaderBody->Map( [&]( auto node ) { + if( node->GetNodeType() == NT_VAR_IDENTIFIER && globalsStructMembers.find( node->GetSymbol() ) != end( globalsStructMembers ) ) { - if( param->GetType().symbol == globalStructSymbol ) + if( !globalsParam ) { + Type type = TypeFromSymbol( globalStructSymbol ); + ScannerToken token = {}; + token.type = OP_INOUT; + + auto param = NewFunctionParameter( state, type, MakeInlineString( "Globals" ) ); + param->SetToken( &token ); + header->AddChild( param ); globalsParam = param->GetSymbol(); - break; + globalsParam->addressSpace = AddressSpace::Constant; } + return NewDot( state, NewVarIdentifier( state, globalsParam ), node->GetSymbol()->name ); } - shaderBody->Map( [&]( auto node ) { - if( node->GetNodeType() == NT_VAR_IDENTIFIER && globalsStructMembers.find( node->GetSymbol() ) != end( globalsStructMembers ) ) - { - if( !globalsParam ) - { - Type type = TypeFromSymbol( globalStructSymbol ); - ScannerToken token = {}; - token.type = OP_INOUT; + return node; + } ); + } - auto param = NewFunctionParameter( state, type, MakeInlineString( "Globals" ) ); - param->SetToken( &token ); - header->AddChild( param ); - globalsParam = param->GetSymbol(); - globalsParam->addressSpace = AddressSpace::Constant; - } - return NewDot( state, NewVarIdentifier( state, globalsParam ), node->GetSymbol()->name ); - } - return node; - } ); + return shader; +} + +struct RtShaderSourceArguments +{ + ASTNode* payloadArg = nullptr; + ASTNode* attributeArg = nullptr; + ASTNode* shaderTableArg = nullptr; + std::vector other; +}; + +RtShaderSourceArguments ClassifyRtShaderArguments( ASTNode* functionHeader ) +{ + RtShaderSourceArguments result; + + for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) + { + ASTNode* sourceArg = functionHeader->GetChild( i ); + Symbol* sourceSymbol = sourceArg->GetSymbol(); + + bool isPayload = sourceArg->GetType().IsStruct() && sourceSymbol->addressSpace == AddressSpace::None && !result.payloadArg; + bool isAttribute = sourceArg->GetType().IsStruct() && sourceSymbol->addressSpace == AddressSpace::None && result.payloadArg; + if( isPayload ) + { + result.payloadArg = sourceArg; + } + else if( isAttribute ) + { + result.attributeArg = sourceArg; + } + else if( sourceArg->GetType().symbol && ContainsSubstring( sourceArg->GetType().symbol->name, "ShaderTableT<" ) ) + { + result.shaderTableArg = sourceArg; + } + else + { + result.other.push_back( sourceArg ); } + } + return result; +} - return shader; +ASTNode* PatchRtShader( RtShaderType shaderType, ASTNode* callNode, ParserState& state, std::vector& rtConstantBuffers, const std::vector& globalInput, ASTNode* globalInputsStruct ) +{ + ZoneScoped; + + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return nullptr; } - struct RtShaderSourceArguments + ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); + if( !functionHeader ) { - ASTNode* payloadArg = nullptr; - ASTNode* attributeArg = nullptr; - ASTNode* shaderTableArg = nullptr; - std::vector other; - }; + return nullptr; + } + + ApplyPackedModifiersToConstantBuffers( entryPointSymbol->definition ); + + ScannerToken shaderName = ScannerToken::ID( callNode->GetSymbol()->name ); - RtShaderSourceArguments ClassifyRtShaderArguments( ASTNode* functionHeader ) + state.GetCurrentLocation().fileName = shaderName.stringValue; + state.GetCurrentLocation().lineNumber = 1; + + auto header = state.NewNode( NT_FUNCTION_HEADER, shaderName ); + auto shaderSymbol = state.GetSymbolTable().AddSymbol( shaderName.stringValue, ALLOW_OVERRIDES ); + shaderSymbol->isFunction = true; + header->SetSymbol( shaderSymbol ); + + state.GetSymbolTable().EnterScope(); + + auto shaderBody = state.NewNode( NT_BLOCK ); + + ASTNode* payloadArg = nullptr; + ASTNode* attributeArg = nullptr; + + auto sourceArguments = ClassifyRtShaderArguments( functionHeader ); + if( sourceArguments.payloadArg ) + { + payloadArg = NewFunctionParameter( state, sourceArguments.payloadArg->GetType(), state.AllocateName( sourceArguments.payloadArg->GetSymbol()->name ) ); + payloadArg->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); + header->AddChild( payloadArg ); + } + if( sourceArguments.attributeArg ) { - RtShaderSourceArguments result; + attributeArg = NewFunctionParameter( state, sourceArguments.attributeArg->GetType(), state.AllocateName( sourceArguments.attributeArg->GetSymbol()->name ) ); + header->AddChild( attributeArg ); + } - for( size_t i = 0; i < functionHeader->GetChildrenCount(); ++i ) - { - ASTNode* sourceArg = functionHeader->GetChild( i ); - Symbol* sourceSymbol = sourceArg->GetSymbol(); + ASTNode* localInputArg = nullptr; + { + auto t = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "device __RtLocalMaterial*" ) ); + localInputArg = NewFunctionParameter( state, TypeFromSymbol( t ), "__rtMaterials", RegisterSpecifier::Register( MetalRegister::SRV, 0 ) ); + header->AddChild( localInputArg ); + } - bool isPayload = sourceArg->GetType().IsStruct() && sourceSymbol->addressSpace == AddressSpace::None && !result.payloadArg; - bool isAttribute = sourceArg->GetType().IsStruct() && sourceSymbol->addressSpace == AddressSpace::None && result.payloadArg; - if( isPayload ) - { - result.payloadArg = sourceArg; - } - else if( isAttribute ) - { - result.attributeArg = sourceArg; - } - else if( sourceArg->GetType().symbol && ContainsSubstring( sourceArg->GetType().symbol->name, "ShaderTableT<" ) ) - { - result.shaderTableArg = sourceArg; - } - else - { - result.other.push_back( sourceArg ); - } - } - return result; + ASTNode* globalInputArg = nullptr; + { + globalInputArg = NewFunctionParameter( state, TypeFromSymbol( globalInputsStruct->GetSymbol() ), "__rtGlobals", RegisterSpecifier::Register( MetalRegister::SRV, 1 ) ); + globalInputArg->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); + globalInputArg->GetSymbol()->addressSpace = AddressSpace::Constant; + header->AddChild( globalInputArg ); } - ASTNode* PatchRtShader( RtShaderType shaderType, ASTNode* callNode, ParserState& state, std::vector& rtConstantBuffers, const std::vector& globalInput, ASTNode* globalInputsStruct ) - { - ZoneScoped; + if( sourceArguments.shaderTableArg ) + { + header->AddChild( sourceArguments.shaderTableArg->Copy() ); + } + else if( payloadArg ) + { + auto shaderTable = CreateShaderTableArgument( state, payloadArg->GetType(), state.GetSymbolTable().GetCurrentScope() ); + header->AddChild( shaderTable ); + } + + Symbol* hitGroupOffset = nullptr; + if( shaderType == RtShaderType::ANY_HIT ) + { + auto arg = NewFunctionParameter( state, hlsl::uint_t, "__instance_intersection_function_table_offset", MetalSystemSemantics( MetalSystemSemanticsType::instance_intersection_function_table_offset ) ); + header->AddChild( arg ); + hitGroupOffset = arg->GetSymbol(); + } + + auto autoT = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "auto" ) ); + auto autoRefT = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "auto&" ) ); - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return nullptr; - } + { + for( auto arg : sourceArguments.other ) + { + auto foundGlobal = find_if( begin( globalInput ), end( globalInput ), [arg]( auto& x ) { + bool isCBuffer = x.type.symbol == nullptr && x.type.builtInType == 0; + if( isCBuffer ) + { + return arg->GetType().symbol && arg->GetType().symbol->definition == x.declaration; + } + return x.name == arg->GetSymbol()->name; + } ); - ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); - if( !functionHeader ) - { - return nullptr; - } + if( foundGlobal != end( globalInput ) ) + { + auto localSymbol = state.GetSymbolTable().AddSymbol( arg->GetSymbol()->name, ALLOW_OVERRIDES ); + localSymbol->type = TypeFromSymbol( autoT ); - ApplyPackedModifiersToConstantBuffers( entryPointSymbol->definition ); + auto memberName = foundGlobal == end( globalInput ) ? arg->GetSymbol()->name : foundGlobal->name; + auto rhs = NewDot( state, NewVarIdentifier( state, globalInputArg->GetSymbol() ), memberName ); + if( arg->GetType().symbol ) + { + auto access = state.NewNode( NT_POSTFIX_EXPRESSION, ScannerToken::FromTokenType( OP_LEFT_BRACKET ) ); + access->AddChild( rhs ); + access->AddChild( NewLiteralConst( state, 0u ) ); + rhs = access; + } + else + { + rhs = NewCastExpression( state, arg->GetType(), rhs ); + } + rhs->SetSymbol( arg->GetSymbol() ); - ScannerToken shaderName = ScannerToken::ID( callNode->GetSymbol()->name ); + auto decl = NewVarDeclaration( state, localSymbol, rhs ); + localSymbol->definition = decl; + decl->GetChild( 0 )->AddChild( nullptr ); + shaderBody->AddChild( decl ); + } + else + { + int idx = -1; + if( Symbol* symbol = arg->GetSymbol() ) + { + if( symbol && !symbol->registerSpecifier.empty() ) + { + const RegisterSpecifier& reg = symbol->registerSpecifier.cbegin()->second; + if( reg.registerType == MetalRegister::CBuffer ) + { + idx = reg.registerNumber; + } + } + if( idx < 0 ) + { + idx = GetCBufferIndex( arg->GetSymbol() ); + } + if( idx >= 0 ) + { + auto registerNumber = uint32_t( idx ); - state.GetCurrentLocation().fileName = shaderName.stringValue; - state.GetCurrentLocation().lineNumber = 1; + if( rtConstantBuffers.size() <= registerNumber ) + { + rtConstantBuffers.resize( registerNumber + 1 ); + rtConstantBuffers[registerNumber] = arg->GetSymbol(); + } - auto header = state.NewNode( NT_FUNCTION_HEADER, shaderName ); - auto shaderSymbol = state.GetSymbolTable().AddSymbol( shaderName.stringValue, ALLOW_OVERRIDES ); - shaderSymbol->isFunction = true; - header->SetSymbol( shaderSymbol ); + ASTNode* hitGroupOffsetParam; + if( shaderType == RtShaderType::ANY_HIT ) + { + hitGroupOffsetParam = NewVarIdentifier( state, hitGroupOffset ); + } + else + { + // For closest hit and miss shaders, the calleer takes care of the offset + hitGroupOffsetParam = NewLiteralConst( state, 0u ); + } - state.GetSymbolTable().EnterScope(); + std::string funcName = "__GetLocalRTBuffer<" + symbol->type.ToString() + ">"; + auto ctr = NewFunctionCall( state, TypeFromSymbol( autoRefT ), state.AllocateName( funcName.c_str() ).start, { NewVarIdentifier( state, localInputArg->GetSymbol() ), hitGroupOffsetParam, NewLiteralConst( state, registerNumber ) } ); - auto shaderBody = state.NewNode( NT_BLOCK ); + auto localSymbol = state.GetSymbolTable().AddSymbol( arg->GetSymbol()->name, ALLOW_OVERRIDES ); + localSymbol->addressSpace = AddressSpace::Constant; + localSymbol->type = TypeFromSymbol( autoRefT ); - ASTNode* payloadArg = nullptr; - ASTNode* attributeArg = nullptr; + auto decl = NewVarDeclaration( state, localSymbol, ctr ); + localSymbol->definition = decl; + decl->GetChild( 0 )->AddChild( nullptr ); + shaderBody->AddChild( decl ); - auto sourceArguments = ClassifyRtShaderArguments( functionHeader ); - if( sourceArguments.payloadArg ) - { - payloadArg = NewFunctionParameter( state, sourceArguments.payloadArg->GetType(), state.AllocateName( sourceArguments.payloadArg->GetSymbol()->name ) ); - payloadArg->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); - header->AddChild( payloadArg ); - } - if( sourceArguments.attributeArg ) - { - attributeArg = NewFunctionParameter( state, sourceArguments.attributeArg->GetType(), state.AllocateName( sourceArguments.attributeArg->GetSymbol()->name ) ); - header->AddChild( attributeArg ); + arg->GetSymbol()->registerSpecifier.clear(); + arg->GetSymbol()->addressSpace = AddressSpace::None; + } + } + } } + } - ASTNode* localInputArg = nullptr; + if( shaderType == RtShaderType::ANY_HIT ) + { + if( payloadArg ) { - auto t = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "device __RtLocalMaterial*" ) ); - localInputArg = NewFunctionParameter( state, TypeFromSymbol( t ), "__rtMaterials", RegisterSpecifier::Register( MetalRegister::SRV, 0 ) ); - header->AddChild( localInputArg ); + payloadArg->GetSymbol()->addressSpace = AddressSpace::RayData; + payloadArg->GetSymbol()->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::payload ); } - ASTNode* globalInputArg = nullptr; + if( attributeArg ) { - globalInputArg = NewFunctionParameter( state, TypeFromSymbol( globalInputsStruct->GetSymbol() ), "__rtGlobals", RegisterSpecifier::Register( MetalRegister::SRV, 1 ) ); - globalInputArg->SetToken( ScannerToken::FromTokenType( OP_INOUT ) ); - globalInputArg->GetSymbol()->addressSpace = AddressSpace::Constant; - header->AddChild( globalInputArg ); - } + auto arg = NewFunctionParameter( state, hlsl::float2_t, "__barycentricCoords", MetalSystemSemantics( MetalSystemSemanticsType::barycentric_coord ) ); - if( sourceArguments.shaderTableArg ) - { - header->AddChild( sourceArguments.shaderTableArg->Copy() ); + auto cast = NewCastExpression( state, attributeArg->GetSymbol()->type, NewVarIdentifier( state, arg->GetSymbol() ) ); + shaderBody->AddChild( NewVarDeclaration( state, attributeArg->GetSymbol(), cast ) ); + + header->ReplaceChild( attributeArg, arg ); } - else if( payloadArg ) - { - auto shaderTable = CreateShaderTableArgument( state, payloadArg->GetType(), state.GetSymbolTable().GetCurrentScope() ); - header->AddChild( shaderTable ); - } - Symbol* hitGroupOffset = nullptr; - if( shaderType == RtShaderType::ANY_HIT ) - { - auto arg = NewFunctionParameter( state, hlsl::uint_t, "__instance_intersection_function_table_offset", MetalSystemSemantics( MetalSystemSemanticsType::instance_intersection_function_table_offset ) ); + auto metalHitSVt = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "__MetalHitSV" ) ); + auto metalHitSVDecl = NewVarDeclaration( state, TypeFromSymbol( metalHitSVt ), MakeInlineString( "__metalHitSV" ) ); + shaderBody->AddChild( metalHitSVDecl ); + auto metalHitSV = metalHitSVDecl->GetChild( 0 )->GetSymbol(); + + auto AddSystemValue = [&state, shaderBody, metalHitSV, header]( Type t, MetalSystemSemanticsType::Enum semantics ) { + auto name = MetalSystemSemanticsType::GetString( semantics ); + auto arg = NewFunctionParameter( state, t, ( "__" + std::string( name ) ).c_str(), MetalSystemSemantics( semantics ) ); header->AddChild( arg ); - hitGroupOffset = arg->GetSymbol(); - } - auto autoT = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "auto" ) ); - auto autoRefT = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "auto&" ) ); + auto left = NewDot( state, NewVarIdentifier( state, metalHitSV ), state.GetSymbolTable().AddSymbol( MakeInlineString( name ) ) ); + left->SetType( arg->GetSymbol()->type ); + auto right = NewVarIdentifier( state, arg->GetSymbol() ); + right->SetType( arg->GetSymbol()->type ); + shaderBody->AddChild( NewExpressionStatement( state, NewBinaryExpression( state, OP_EQUAL, left, right ) ) ); + }; - { - for( auto arg : sourceArguments.other ) - { - auto foundGlobal = find_if( begin( globalInput ), end( globalInput ), [arg]( auto& x ) { - bool isCBuffer = x.type.symbol == nullptr && x.type.builtInType == 0; - if( isCBuffer ) - { - return arg->GetType().symbol && arg->GetType().symbol->definition == x.declaration; - } - return x.name == arg->GetSymbol()->name; - } ); + AddSystemValue( hlsl::uint_t, MetalSystemSemanticsType::instance_id ); + AddSystemValue( hlsl::uint_t, MetalSystemSemanticsType::primitive_id ); + AddSystemValue( hlsl::float3_t, MetalSystemSemanticsType::origin ); + AddSystemValue( hlsl::float3_t, MetalSystemSemanticsType::direction ); + AddSystemValue( hlsl::float_t, MetalSystemSemanticsType::min_distance ); + AddSystemValue( hlsl::float_t, MetalSystemSemanticsType::distance ); + AddSystemValue( TypeFromTokenType( OP_FLOAT, 3, 4 ), MetalSystemSemanticsType::object_to_world_transform ); + AddSystemValue( TypeFromTokenType( OP_FLOAT, 3, 4 ), MetalSystemSemanticsType::world_to_object_transform ); + } + else if( shaderType == RtShaderType::RAY_GEN ) + { + header->AddChild( NewFunctionParameter( state, hlsl::uint3_t, "__dispatchRaysIndex", MetalSystemSemantics( MetalSystemSemanticsType::thread_position_in_grid ) ) ); + header->AddChild( NewFunctionParameter( state, hlsl::uint3_t, "__dispatchRaysDimensions", MetalSystemSemantics( MetalSystemSemanticsType::threads_per_grid ) ) ); + } + else + { + auto metalHitSVt = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "__MetalHitSV" ) ); - if( foundGlobal != end( globalInput ) ) - { - auto localSymbol = state.GetSymbolTable().AddSymbol( arg->GetSymbol()->name, ALLOW_OVERRIDES ); - localSymbol->type = TypeFromSymbol( autoT ); + auto arg = NewFunctionParameter( state, TypeFromSymbol( metalHitSVt ), "__metalHitSV" ); - auto memberName = foundGlobal == end( globalInput ) ? arg->GetSymbol()->name : foundGlobal->name; - auto rhs = NewDot( state, NewVarIdentifier( state, globalInputArg->GetSymbol() ), memberName ); - if( arg->GetType().symbol ) - { - auto access = state.NewNode( NT_POSTFIX_EXPRESSION, ScannerToken::FromTokenType( OP_LEFT_BRACKET ) ); - access->AddChild( rhs ); - access->AddChild( NewLiteralConst( state, 0u ) ); - rhs = access; - } - else - { - rhs = NewCastExpression( state, arg->GetType(), rhs ); - } - rhs->SetSymbol( arg->GetSymbol() ); + if( attributeArg ) + { + auto dot = NewDot( state, NewVarIdentifier( state, arg->GetSymbol() ), state.GetSymbolTable().AddSymbol( MakeInlineString( "barycentric_coord" ) ) ); + dot->SetType( hlsl::float2_t ); - auto decl = NewVarDeclaration( state, localSymbol, rhs ); - localSymbol->definition = decl; - decl->GetChild( 0 )->AddChild( nullptr ); - shaderBody->AddChild( decl ); - } - else - { - int idx = -1; - if( Symbol* symbol = arg->GetSymbol() ) - { - if( symbol && !symbol->registerSpecifier.empty() ) - { - const RegisterSpecifier& reg = symbol->registerSpecifier.cbegin()->second; - if( reg.registerType == MetalRegister::CBuffer ) - { - idx = reg.registerNumber; - } - } - if( idx < 0 ) - { - idx = GetCBufferIndex( arg->GetSymbol() ); - } - if( idx >= 0 ) - { - auto registerNumber = uint32_t( idx ); + auto declList = NewVarDeclaration( state, attributeArg->GetSymbol(), NewCastExpression( state, attributeArg->GetSymbol()->type, dot ) ); + shaderBody->AddChild( declList ); - if( rtConstantBuffers.size() <= registerNumber ) - { - rtConstantBuffers.resize( registerNumber + 1 ); - rtConstantBuffers[registerNumber] = arg->GetSymbol(); - } + header->RemoveChild( attributeArg ); + } + header->InsertChild( 1, arg ); + } - ASTNode* hitGroupOffsetParam; - if ( shaderType == RtShaderType::ANY_HIT ) - { - hitGroupOffsetParam = NewVarIdentifier( state, hitGroupOffset ); - } - else - { - // For closest hit and miss shaders, the calleer takes care of the offset - hitGroupOffsetParam = NewLiteralConst( state, 0u ); - } + for( auto& stmt : entryPointSymbol->definition->GetChild( 1 )->GetChildren() ) + { + shaderBody->AddChild( stmt->Copy() ); + } + if( shaderType == RtShaderType::ANY_HIT ) + { + header->SetType( hlsl::bool_t ); + shaderBody->AddChild( NewReturn( state, NewLiteralConst( state, true ) ) ); + } + else + { + header->SetType( hlsl::void_t ); + } - std::string funcName = "__GetLocalRTBuffer<" + symbol->type.ToString() + ">"; - auto ctr = NewFunctionCall( state, TypeFromSymbol( autoRefT ), state.AllocateName( funcName.c_str() ).start, - { NewVarIdentifier( state, localInputArg->GetSymbol() ), hitGroupOffsetParam, NewLiteralConst( state, registerNumber ) } ); + state.GetSymbolTable().LeaveScope(); - auto localSymbol = state.GetSymbolTable().AddSymbol( arg->GetSymbol()->name, ALLOW_OVERRIDES ); - localSymbol->addressSpace = AddressSpace::Constant; - localSymbol->type = TypeFromSymbol( autoRefT ); + auto shader = state.NewNode( NT_FUNCTION_DEFINITION ); + shaderSymbol->type = header->GetType(); + shaderSymbol->definition = shader; + shader->AddChild( header ); + shader->AddChild( shaderBody ); - auto decl = NewVarDeclaration( state, localSymbol, ctr ); - localSymbol->definition = decl; - decl->GetChild( 0 )->AddChild( nullptr ); - shaderBody->AddChild( decl ); + auto attribList = state.NewNode( NT_FUNCTION_ATTRIBUTE_LIST ); - arg->GetSymbol()->registerSpecifier.clear(); - arg->GetSymbol()->addressSpace = AddressSpace::None; - } - } - } - } - } - - if( shaderType == RtShaderType::ANY_HIT ) - { - if( payloadArg ) - { - payloadArg->GetSymbol()->addressSpace = AddressSpace::RayData; - payloadArg->GetSymbol()->registerSpecifier[MakeInlineString( "" )] = MetalSystemSemantics( MetalSystemSemanticsType::payload ); - } - - if( attributeArg ) - { - auto arg = NewFunctionParameter( state, hlsl::float2_t, "__barycentricCoords", MetalSystemSemantics( MetalSystemSemanticsType::barycentric_coord ) ); - - auto cast = NewCastExpression( state, attributeArg->GetSymbol()->type, NewVarIdentifier( state, arg->GetSymbol() ) ); - shaderBody->AddChild( NewVarDeclaration( state, attributeArg->GetSymbol(), cast ) ); - - header->ReplaceChild( attributeArg, arg ); - } - - auto metalHitSVt = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "__MetalHitSV" ) ); - auto metalHitSVDecl = NewVarDeclaration( state, TypeFromSymbol( metalHitSVt ), MakeInlineString( "__metalHitSV" ) ); - shaderBody->AddChild( metalHitSVDecl ); - auto metalHitSV = metalHitSVDecl->GetChild( 0 )->GetSymbol(); - - auto AddSystemValue = [&state, shaderBody, metalHitSV, header]( Type t, MetalSystemSemanticsType::Enum semantics ) { - auto name = MetalSystemSemanticsType::GetString( semantics ); - auto arg = NewFunctionParameter( state, t, ( "__" + std::string( name ) ).c_str(), MetalSystemSemantics( semantics ) ); - header->AddChild( arg ); - - auto left = NewDot( state, NewVarIdentifier( state, metalHitSV ), state.GetSymbolTable().AddSymbol( MakeInlineString( name ) ) ); - left->SetType( arg->GetSymbol()->type ); - auto right = NewVarIdentifier( state, arg->GetSymbol() ); - right->SetType( arg->GetSymbol()->type ); - shaderBody->AddChild( NewExpressionStatement( state, NewBinaryExpression( state, OP_EQUAL, left, right ) ) ); - - }; - - AddSystemValue( hlsl::uint_t, MetalSystemSemanticsType::instance_id ); - AddSystemValue( hlsl::uint_t, MetalSystemSemanticsType::primitive_id ); - AddSystemValue( hlsl::float3_t, MetalSystemSemanticsType::origin ); - AddSystemValue( hlsl::float3_t, MetalSystemSemanticsType::direction ); - AddSystemValue( hlsl::float_t, MetalSystemSemanticsType::min_distance ); - AddSystemValue( hlsl::float_t, MetalSystemSemanticsType::distance ); - AddSystemValue( TypeFromTokenType( OP_FLOAT, 3, 4 ), MetalSystemSemanticsType::object_to_world_transform ); - AddSystemValue( TypeFromTokenType( OP_FLOAT, 3, 4 ), MetalSystemSemanticsType::world_to_object_transform ); - } - else if( shaderType == RtShaderType::RAY_GEN ) - { - header->AddChild( NewFunctionParameter( state, hlsl::uint3_t, "__dispatchRaysIndex", MetalSystemSemantics( MetalSystemSemanticsType::thread_position_in_grid ) ) ); - header->AddChild( NewFunctionParameter( state, hlsl::uint3_t, "__dispatchRaysDimensions", MetalSystemSemantics( MetalSystemSemanticsType::threads_per_grid ) ) ); - } - else - { - auto metalHitSVt = state.GetSymbolTable().AddTypeSymbol( MakeInlineString( "__MetalHitSV" ) ); - - auto arg = NewFunctionParameter( state, TypeFromSymbol( metalHitSVt ), "__metalHitSV" ); - - if( attributeArg ) - { - auto dot = NewDot( state, NewVarIdentifier( state, arg->GetSymbol() ), state.GetSymbolTable().AddSymbol( MakeInlineString( "barycentric_coord" ) ) ); - dot->SetType( hlsl::float2_t ); - - auto declList = NewVarDeclaration( state, attributeArg->GetSymbol(), NewCastExpression( state, attributeArg->GetSymbol()->type, dot ) ); - shaderBody->AddChild( declList ); - - header->RemoveChild( attributeArg ); - } - header->InsertChild( 1, arg ); - } - - for( auto& stmt : entryPointSymbol->definition->GetChild( 1 )->GetChildren() ) - { - shaderBody->AddChild( stmt->Copy() ); - } - if( shaderType == RtShaderType::ANY_HIT ) - { - header->SetType( hlsl::bool_t ); - shaderBody->AddChild( NewReturn( state, NewLiteralConst( state, true ) ) ); - } - else - { - header->SetType( hlsl::void_t ); - } - - state.GetSymbolTable().LeaveScope(); - - auto shader = state.NewNode( NT_FUNCTION_DEFINITION ); - shaderSymbol->type = header->GetType(); - shaderSymbol->definition = shader; - shader->AddChild( header ); - shader->AddChild( shaderBody ); - - auto attribList = state.NewNode( NT_FUNCTION_ATTRIBUTE_LIST ); - - InlineString funcAttr; - switch( shaderType ) - { - case RtShaderType::RAY_GEN: - funcAttr = MakeInlineString( "kernel" ); - break; - case RtShaderType::ANY_HIT: - funcAttr = MakeInlineString( "[[intersection(triangle, __INTERSECION_TAGS)]]" ); - break; - default: - funcAttr = MakeInlineString( "[[visible]]" ); - } + InlineString funcAttr; + switch( shaderType ) + { + case RtShaderType::RAY_GEN: + funcAttr = MakeInlineString( "kernel" ); + break; + case RtShaderType::ANY_HIT: + funcAttr = MakeInlineString( "[[intersection(triangle, __INTERSECION_TAGS)]]" ); + break; + default: + funcAttr = MakeInlineString( "[[visible]]" ); + } - attribList->AddChild( state.NewNode( NT_FUNCTION_ATTRIBUTE, ScannerToken::ID( funcAttr ) ) ); - shader->AddChild( attribList ); - state.GetTree()->AddChild( shader ); + attribList->AddChild( state.NewNode( NT_FUNCTION_ATTRIBUTE, ScannerToken::ID( funcAttr ) ) ); + shader->AddChild( attribList ); + state.GetTree()->AddChild( shader ); - return shader; - } + return shader; +} - bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ) +bool MakeEffectAnnotationFromSymbolAnnotation( const SymbolAnnotation& annotation, Annotation& result, bool& isSRGB, bool& isAutoregister ) +{ + switch( annotation.type ) { - switch( annotation.type ) - { - case OP_FLOAT: - case OP_HALF: - case OP_DOUBLE: - result.type = ANNOTATION_TYPE_FLOAT; - result.floatValue = float( ParseFloat( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); - return true; - - case OP_UINT: - case OP_INT: - result.type = ANNOTATION_TYPE_INT; - result.intValue = int32_t( ParseNumber( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); - return true; + case OP_FLOAT: + case OP_HALF: + case OP_DOUBLE: + result.type = ANNOTATION_TYPE_FLOAT; + result.floatValue = float( ParseFloat( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); + return true; - case OP_BOOL: - result.type = ANNOTATION_TYPE_BOOL; - result.intValue = annotation.value.intValue ? 1 : 0; - if( annotation.name == "Tr2sRGB" ) - { - isSRGB = result.intValue != 0; - } - else if( annotation.name == "AutoRegister" ) - { - isAutoregister = result.intValue != 0; - } - return true; + case OP_UINT: + case OP_INT: + result.type = ANNOTATION_TYPE_INT; + result.intValue = int32_t( ParseNumber( annotation.value.stringValue.start, annotation.value.stringValue.end ) ); + return true; - case OP_STRING: - result.type = ANNOTATION_TYPE_STRING; - result.stringValue = g_stringTable.AddString( ParseString( annotation.value.stringValue ).c_str() ); - return true; + case OP_BOOL: + result.type = ANNOTATION_TYPE_BOOL; + result.intValue = annotation.value.intValue ? 1 : 0; + if( annotation.name == "Tr2sRGB" ) + { + isSRGB = result.intValue != 0; } + else if( annotation.name == "AutoRegister" ) + { + isAutoregister = result.intValue != 0; + } + return true; - return false; + case OP_STRING: + result.type = ANNOTATION_TYPE_STRING; + result.stringValue = g_stringTable.AddString( ParseString( annotation.value.stringValue ).c_str() ); + return true; } - void CalculateSizeAndOffset(const Type& type, size_t& size, size_t& offset) - { - size_t typeSize = 0; - size_t typeAlignment = 0; + return false; +} + +void CalculateSizeAndOffset( const Type& type, size_t& size, size_t& offset ) +{ + size_t typeSize = 0; + size_t typeAlignment = 0; - const size_t boolSize[4] = { 1, 2, 4, 4 }; - const size_t boolAlignment[4] = { 1, 2, 4, 4 }; + const size_t boolSize[4] = { 1, 2, 4, 4 }; + const size_t boolAlignment[4] = { 1, 2, 4, 4 }; - const size_t intSize[4] = { 4, 8, 16, 16 }; - const size_t intAlignment[4] = { 4, 8, 16, 16 }; + const size_t intSize[4] = { 4, 8, 16, 16 }; + const size_t intAlignment[4] = { 4, 8, 16, 16 }; - const size_t packedIntSize[4] = { 4, 8, 12, 16 }; - const size_t packedIntAlignment[4] = { 4, 4, 4, 4 }; + const size_t packedIntSize[4] = { 4, 8, 12, 16 }; + const size_t packedIntAlignment[4] = { 4, 4, 4, 4 }; - const size_t floatSize[4] = { 4, 8, 16, 16 }; - const size_t floatAlignment[4] = { 4, 8, 16, 16 }; + const size_t floatSize[4] = { 4, 8, 16, 16 }; + const size_t floatAlignment[4] = { 4, 8, 16, 16 }; - const size_t packedFloatSize[4] = { 4, 8, 12, 16 }; - const size_t packedFloatAlignment[4] = { 4, 4, 4, 4 }; + const size_t packedFloatSize[4] = { 4, 8, 12, 16 }; + const size_t packedFloatAlignment[4] = { 4, 4, 4, 4 }; - const size_t floatMatrixSize[ 3 ][ 3 ] = { - { 16, 32, 32 }, // 2x2, 2x3, 2x4 - { 24, 48, 48 }, // 3x2, 3x3, 3x4 - { 32, 64, 64 } // 4x2, 4x3, 4x4 - }; - const size_t floatMatrixAlignment[ 3 ][ 3 ] = { - { 8, 16, 16 }, // 2x2, 2x3, 2x4 - { 8, 16, 16 }, // 3x2, 3x3, 3x4 - { 8, 16, 16 } // 4x2, 4x3, 4x4 - }; + const size_t floatMatrixSize[3][3] = { + { 16, 32, 32 }, // 2x2, 2x3, 2x4 + { 24, 48, 48 }, // 3x2, 3x3, 3x4 + { 32, 64, 64 } // 4x2, 4x3, 4x4 + }; + const size_t floatMatrixAlignment[3][3] = { + { 8, 16, 16 }, // 2x2, 2x3, 2x4 + { 8, 16, 16 }, // 3x2, 3x3, 3x4 + { 8, 16, 16 } // 4x2, 4x3, 4x4 + }; - assert( 1 <= type.width && type.width <= 4 ); - assert( 1 <= type.height && type.height <= 4 ); + assert( 1 <= type.width && type.width <= 4 ); + assert( 1 <= type.height && type.height <= 4 ); - bool isPacked = type.modifier == OP_PACKOFFSET; + bool isPacked = type.modifier == OP_PACKOFFSET; - switch( type.builtInType ) + switch( type.builtInType ) + { + case OP_BOOL: + typeSize = boolSize[type.width - 1]; + typeAlignment = boolAlignment[type.width - 1]; + break; + case OP_INT: + case OP_UINT: + case OP_BINDLESSHANDLETEXTURE2D: + case OP_BINDLESSHANDLETEXTURE3D: + case OP_BINDLESSHANDLETEXTURECUBE: + case OP_BINDLESSHANDLESAMPLER: + if( isPacked ) + { + typeSize = packedIntSize[type.width - 1]; + typeAlignment = packedIntAlignment[type.width - 1]; + } + else + { + typeSize = intSize[type.width - 1]; + typeAlignment = intAlignment[type.width - 1]; + } + break; + case OP_FLOAT: + if( type.height == 1 ) { - case OP_BOOL: - typeSize = boolSize[ type.width - 1 ]; - typeAlignment = boolAlignment[ type.width - 1 ]; - break; - case OP_INT: - case OP_UINT: - case OP_BINDLESSHANDLETEXTURE2D: - case OP_BINDLESSHANDLETEXTURE3D: - case OP_BINDLESSHANDLETEXTURECUBE: - case OP_BINDLESSHANDLESAMPLER: if( isPacked ) { - typeSize = packedIntSize[type.width - 1]; - typeAlignment = packedIntAlignment[type.width - 1]; + typeSize = packedFloatSize[type.width - 1]; + typeAlignment = packedFloatAlignment[type.width - 1]; } else { - typeSize = intSize[type.width - 1]; - typeAlignment = intAlignment[type.width - 1]; - } - break; - case OP_FLOAT: - if( type.height == 1 ) - { - if( isPacked ) - { - typeSize = packedFloatSize[type.width - 1]; - typeAlignment = packedFloatAlignment[type.width - 1]; - } - else - { - typeSize = floatSize[type.width - 1]; - typeAlignment = floatAlignment[type.width - 1]; - } + typeSize = floatSize[type.width - 1]; + typeAlignment = floatAlignment[type.width - 1]; } - else - { - assert( 2 <= type.width && type.width <= 4 ); - assert( 2 <= type.height && type.height <= 4 ); + } + else + { + assert( 2 <= type.width && type.width <= 4 ); + assert( 2 <= type.height && type.height <= 4 ); - int row = type.width - 2; - int col = type.height - 2; + int row = type.width - 2; + int col = type.height - 2; - // Matrices are column-major in MSL. - typeSize = floatMatrixSize[ col ][ row ]; - typeAlignment = floatMatrixAlignment[ col ][ row ]; - } - break; - default: - assert( false && "Unsupported type" ); - break; + // Matrices are column-major in MSL. + typeSize = floatMatrixSize[col][row]; + typeAlignment = floatMatrixAlignment[col][row]; } + break; + default: + assert( false && "Unsupported type" ); + break; + } - size = typeSize; + size = typeSize; - offset += typeAlignment - 1; - offset -= offset % typeAlignment; - } + offset += typeAlignment - 1; + offset -= offset % typeAlignment; +} - bool FillDefaults( ParserState& state, ASTNode* node, void* outDefaultValues, const Type& type ) +bool FillDefaults( ParserState& state, ASTNode* node, void* outDefaultValues, const Type& type ) +{ + Type expectedType = type; + ExpressionValue value; + + if( type.IsMatrix() ) { - Type expectedType = type; - ExpressionValue value; + state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); + return false; + } - if( type.IsMatrix() ) - { - state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); - return false; - } + if( EvaluateInitializer( state, node, expectedType, value, nullptr ) ) + { + uint32_t count = type.width * type.height; + assert( count == value.size() ); - if( EvaluateInitializer( state, node, expectedType, value, nullptr ) ) + if( type.builtInType == OP_FLOAT ) { - uint32_t count = type.width * type.height; - assert( count == value.size() ); - - if( type.builtInType == OP_FLOAT ) - { - float* floatValues = (float*)outDefaultValues; - for ( size_t i = 0; i < count; ++i ) - { - *floatValues++ = float( value[i].floatValue ); - } - } - else if( type.builtInType == OP_INT ) + float* floatValues = (float*)outDefaultValues; + for( size_t i = 0; i < count; ++i ) { - int32_t* intValues = (int32_t*)outDefaultValues; - for ( size_t i = 0; i < count; ++i ) - { - *intValues++ = int32_t( value[i].intValue ); - } + *floatValues++ = float( value[i].floatValue ); } - else + } + else if( type.builtInType == OP_INT ) + { + int32_t* intValues = (int32_t*)outDefaultValues; + for( size_t i = 0; i < count; ++i ) { - // Type not supported. - state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); - return false; + *intValues++ = int32_t( value[i].intValue ); } - - return true; + } + else + { + // Type not supported. + state.ShowMessage( node->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); + return false; } - return false; + return true; } - bool CollectConstants( ParserState& state, StageData& stage, ASTNode* node, std::map& annotations ) - { - assert( node->GetNodeType() == NT_STRUCT ); + return false; +} - size_t offset = 0; +bool CollectConstants( ParserState& state, StageData& stage, ASTNode* node, std::map& annotations ) +{ + assert( node->GetNodeType() == NT_STRUCT ); - for( auto memberNode : node->GetChildren() ) - { - assert( memberNode && memberNode->GetNodeType() == NT_STRUCT_MEMBER ); + size_t offset = 0; - for( auto childNode : memberNode->GetChildren() ) - { - assert( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ); + for( auto memberNode : node->GetChildren() ) + { + assert( memberNode && memberNode->GetNodeType() == NT_STRUCT_MEMBER ); - Symbol* symbol = childNode->GetSymbol(); - assert( symbol ); + for( auto childNode : memberNode->GetChildren() ) + { + assert( childNode && childNode->GetNodeType() == NT_NAME_DECLARATION ); - if( !symbol->used ) - { - continue; - } + Symbol* symbol = childNode->GetSymbol(); + assert( symbol ); + + if( !symbol->used ) + { + continue; + } - const Type& type = symbol->type; + const Type& type = symbol->type; - // Multi-dimensional arrays are not supported yet. - assert( type.arrayDimensions <= 1 ); + // Multi-dimensional arrays are not supported yet. + assert( type.arrayDimensions <= 1 ); - size_t size = 0; - CalculateSizeAndOffset( type, size, offset ); + size_t size = 0; + CalculateSizeAndOffset( type, size, offset ); - int elementCount = 1; - for( int i = 0; i < type.arrayDimensions; ++i ) - { - elementCount *= type.arraySizes[ i ]; - } + int elementCount = 1; + for( int i = 0; i < type.arrayDimensions; ++i ) + { + elementCount *= type.arraySizes[i]; + } - // Note: This calculation is correct only when type can be tightly packed in an array, - // i.e. type size divisible by alignment. - size *= elementCount; + // Note: This calculation is correct only when type can be tightly packed in an array, + // i.e. type size divisible by alignment. + size *= elementCount; - Constant constant; - constant.name = g_stringTable.AddString( symbol->name ); - constant.offset = (uint32_t) offset; - constant.size = (uint32_t) size; + Constant constant; + constant.name = g_stringTable.AddString( symbol->name ); + constant.offset = (uint32_t)offset; + constant.size = (uint32_t)size; - offset += size; + offset += size; - switch( type.builtInType ) - { - case OP_FLOAT: - constant.type = CONSTANT_TYPE_FLOAT; - break; - case OP_INT: - constant.type = CONSTANT_TYPE_INT; - break; - case OP_UINT: - case OP_BINDLESSHANDLETEXTURE2D: - case OP_BINDLESSHANDLETEXTURE3D: - case OP_BINDLESSHANDLETEXTURECUBE: - case OP_BINDLESSHANDLESAMPLER: - constant.type = CONSTANT_TYPE_UINT; - break; - case OP_BOOL: - constant.type = CONSTANT_TYPE_BOOL; - break; - default: - constant.type = CONSTANT_TYPE_OTHER; - break; - } + switch( type.builtInType ) + { + case OP_FLOAT: + constant.type = CONSTANT_TYPE_FLOAT; + break; + case OP_INT: + constant.type = CONSTANT_TYPE_INT; + break; + case OP_UINT: + case OP_BINDLESSHANDLETEXTURE2D: + case OP_BINDLESSHANDLETEXTURE3D: + case OP_BINDLESSHANDLETEXTURECUBE: + case OP_BINDLESSHANDLESAMPLER: + constant.type = CONSTANT_TYPE_UINT; + break; + case OP_BOOL: + constant.type = CONSTANT_TYPE_BOOL; + break; + default: + constant.type = CONSTANT_TYPE_OTHER; + break; + } - constant.dimension = uint8_t( type.width * type.height ); - constant.elements = (uint32_t) elementCount; - constant.isSRGB = false; - constant.isAutoregister = false; + constant.dimension = uint8_t( type.width * type.height ); + constant.elements = (uint32_t)elementCount; + constant.isSRGB = false; + constant.isAutoregister = false; - stage.defaultValues.resize( std::max( stage.defaultValues.size(), size_t( constant.offset + constant.size ) ) ); + stage.defaultValues.resize( std::max( stage.defaultValues.size(), size_t( constant.offset + constant.size ) ) ); - // Init with zeroes. - memset( &stage.defaultValues[constant.offset], 0, constant.size ); + // Init with zeroes. + memset( &stage.defaultValues[constant.offset], 0, constant.size ); - // Has default value? - ASTNode* defaultValueNode = childNode->GetChildOrNull( 1 ); - if( defaultValueNode ) + // Has default value? + ASTNode* defaultValueNode = childNode->GetChildOrNull( 1 ); + if( defaultValueNode ) + { + if( type.arrayDimensions == 0 ) { - if( type.arrayDimensions == 0 ) + if( !FillDefaults( state, defaultValueNode, stage.defaultValues.data() + constant.offset, type ) ) { - if( !FillDefaults( state, defaultValueNode, stage.defaultValues.data() + constant.offset, type ) ) - { - return false; - } + return false; } - else if( type.arrayDimensions == 1 ) + } + else if( type.arrayDimensions == 1 ) + { + for( size_t i = 0, n = defaultValueNode->GetChildrenCount(); i < n; ++i ) { - for( size_t i = 0, n = defaultValueNode->GetChildrenCount(); i < n; ++i ) + size_t elementOffset = constant.offset + i * size / elementCount; + if( !FillDefaults( state, defaultValueNode->GetChild( i ), stage.defaultValues.data() + elementOffset, type ) ) { - size_t elementOffset = constant.offset + i * size / elementCount; - if( !FillDefaults( state, defaultValueNode->GetChild( i ), stage.defaultValues.data() + elementOffset, type ) ) - { - return false; - } + return false; } } - else - { - state.ShowMessage( defaultValueNode->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); - return false; - } } + else + { + state.ShowMessage( defaultValueNode->GetLocation(), EC_UNSUPPORTED_TYPE, type.ToString().c_str() ); + return false; + } + } - if( annotations.find( constant.name ) == annotations.end() ) - { - ParameterAnnotation paramAnnotations; + if( annotations.find( constant.name ) == annotations.end() ) + { + ParameterAnnotation paramAnnotations; - if( symbol->annotations ) + if( symbol->annotations ) + { + for( auto a = symbol->annotations->begin(); a != symbol->annotations->end(); ++a ) { - for( auto a = symbol->annotations->begin(); a != symbol->annotations->end(); ++a ) + Annotation result; + if( MakeEffectAnnotationFromSymbolAnnotation( *a, result, constant.isSRGB, constant.isAutoregister ) ) { - Annotation result; - if( MakeEffectAnnotationFromSymbolAnnotation( *a, result, constant.isSRGB, constant.isAutoregister ) ) - { - paramAnnotations.annotations[g_stringTable.AddString( a->name )] = result; - } + paramAnnotations.annotations[g_stringTable.AddString( a->name )] = result; } } - if( symbol->type.IsBindlessHandle() ) - { - Annotation symbolAnnotation; - symbolAnnotation.type = ANNOTATION_TYPE_INT; - symbolAnnotation.intValue = symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ? 100 : BindlessTextureType( symbol->type.builtInType ); - paramAnnotations.annotations[g_stringTable.AddString( "BindlessHandleType" )] = symbolAnnotation; - } - if( !paramAnnotations.annotations.empty() ) - { - annotations[constant.name] = paramAnnotations; - } } + if( symbol->type.IsBindlessHandle() ) + { + Annotation symbolAnnotation; + symbolAnnotation.type = ANNOTATION_TYPE_INT; + symbolAnnotation.intValue = symbol->type.builtInType == OP_BINDLESSHANDLESAMPLER ? 100 : BindlessTextureType( symbol->type.builtInType ); + paramAnnotations.annotations[g_stringTable.AddString( "BindlessHandleType" )] = symbolAnnotation; + } + if( !paramAnnotations.annotations.empty() ) + { + annotations[constant.name] = paramAnnotations; + } + } - if( type.builtInType == OP_BINDLESSHANDLESAMPLER ) + if( type.builtInType == OP_BINDLESSHANDLESAMPLER ) + { + auto found = std::find_if( begin( state.m_bindlessSamplers ), end( state.m_bindlessSamplers ), [symbol]( const auto& bs ) { return bs.name == symbol; } ); + if( found != end( state.m_bindlessSamplers ) ) { - auto found = std::find_if( begin( state.m_bindlessSamplers ), end( state.m_bindlessSamplers ), [symbol]( const auto& bs ) { return bs.name == symbol; } ); - if( found != end( state.m_bindlessSamplers ) ) + Sampler sampler; + if( GetSamplerState( state, found->definition, sampler ) ) { - Sampler sampler; - if( GetSamplerState( state, found->definition, sampler ) ) - { - sampler.name = constant.name; - stage.samplers[uint8_t( 100 + ( found - begin( state.m_bindlessSamplers ) ) )] = sampler; - } + sampler.name = constant.name; + stage.samplers[uint8_t( 100 + ( found - begin( state.m_bindlessSamplers ) ) )] = sampler; } } - - stage.constants.push_back( constant ); } + + stage.constants.push_back( constant ); } - return true; } + return true; +} - RegisterInputType TypeToRegisterInputType( const Type& type ) +RegisterInputType TypeToRegisterInputType( const Type& type ) +{ + switch( type.builtInType ) { - switch( type.builtInType ) - { - case OP_BUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - return RT_SRV_BUFFER; - case OP_STRUCTUREDBUFFER: - return RT_SRV_STRUCTURED_BUFFER; - case OP_RWBUFFER: - return RT_UAV_BUFFER; - case OP_RWSTRUCTUREDBUFFER: - return RT_UAV_STRUCTURED_BUFFER; - case OP_TEXTURE: - return RT_SRV_TEXTURE2D; - case OP_TEXTURE1D: - return RT_SRV_TEXTURE1D; - case OP_TEXTURE1DARRAY: - return RT_SRV_TEXTURE1DARRAY; - case OP_TEXTURE2D: - return RT_SRV_TEXTURE2D; - case OP_TEXTURE2DARRAY: - return RT_SRV_TEXTURE2DARRAY; - case OP_TEXTURE3D: - return RT_SRV_TEXTURE3D; - case OP_TEXTURECUBE: - return RT_SRV_TEXTURECUBE; - case OP_TEXTURECUBEARRAY: - return RT_SRV_TEXTURECUBEARRAY; - case OP_TEXTURE2DMS: - return RT_SRV_TEXTURE2DMS; - case OP_TEXTURE2DMSARRAY: - return RT_SRV_TEXTURE2DMSARRAY; - case OP_RWTEXTURE1D: - return RT_UAV_TEXTURE1D; - case OP_RWTEXTURE1DARRAY: - return RT_UAV_TEXTURE1DARRAY; - case OP_RWTEXTURE2D: - return RT_UAV_TEXTURE2D; - case OP_RWTEXTURE2DARRAY: - return RT_UAV_TEXTURE2DARRAY; - case OP_RWTEXTURE3D: - return RT_UAV_TEXTURE3D; - case OP_SAMPLER: - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLERCOMPARISON: - return RT_SAMPLER; - default: - assert( false ); - return RT_SRV_TEXTURE2D; - } + case OP_BUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + return RT_SRV_BUFFER; + case OP_STRUCTUREDBUFFER: + return RT_SRV_STRUCTURED_BUFFER; + case OP_RWBUFFER: + return RT_UAV_BUFFER; + case OP_RWSTRUCTUREDBUFFER: + return RT_UAV_STRUCTURED_BUFFER; + case OP_TEXTURE: + return RT_SRV_TEXTURE2D; + case OP_TEXTURE1D: + return RT_SRV_TEXTURE1D; + case OP_TEXTURE1DARRAY: + return RT_SRV_TEXTURE1DARRAY; + case OP_TEXTURE2D: + return RT_SRV_TEXTURE2D; + case OP_TEXTURE2DARRAY: + return RT_SRV_TEXTURE2DARRAY; + case OP_TEXTURE3D: + return RT_SRV_TEXTURE3D; + case OP_TEXTURECUBE: + return RT_SRV_TEXTURECUBE; + case OP_TEXTURECUBEARRAY: + return RT_SRV_TEXTURECUBEARRAY; + case OP_TEXTURE2DMS: + return RT_SRV_TEXTURE2DMS; + case OP_TEXTURE2DMSARRAY: + return RT_SRV_TEXTURE2DMSARRAY; + case OP_RWTEXTURE1D: + return RT_UAV_TEXTURE1D; + case OP_RWTEXTURE1DARRAY: + return RT_UAV_TEXTURE1DARRAY; + case OP_RWTEXTURE2D: + return RT_UAV_TEXTURE2D; + case OP_RWTEXTURE2DARRAY: + return RT_UAV_TEXTURE2DARRAY; + case OP_RWTEXTURE3D: + return RT_UAV_TEXTURE3D; + case OP_SAMPLER: + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLERCOMPARISON: + return RT_SAMPLER; + default: + assert( false ); + return RT_SRV_TEXTURE2D; + } +} +TextureType TypeToTextureType( const Type& type ) +{ + switch( type.builtInType ) + { + case OP_TEXTURE1D: + case OP_TEXTURE1DARRAY: + case OP_RWTEXTURE1D: + case OP_RWTEXTURE1DARRAY: + return TEX_TYPE_1D; + case OP_TEXTURE: + case OP_TEXTURE2D: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: + case OP_RWTEXTURE2D: + case OP_RWTEXTURE2DARRAY: + return TEX_TYPE_2D; + case OP_TEXTURE3D: + case OP_RWTEXTURE3D: + case OP_TEXTURE3DARRAY: + return TEX_TYPE_3D; + case OP_TEXTURECUBE: + case OP_TEXTURECUBEARRAY: + return TEX_TYPE_CUBE; + case OP_BUFFER: + case OP_RWBUFFER: + return TEX_TYPE_BUFFER; + case OP_STRUCTUREDBUFFER: + case OP_RWSTRUCTUREDBUFFER: + return TEX_TYPE_STRUCTURED_BUFFER; + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + return TEX_TYPE_RAYTRACING_ACCELERATION_STRUCTURE; + default: + return TEX_TYPE_INVALID; } - TextureType TypeToTextureType( const Type& type ) +} + +bool ExtractAnnotations( const InlineString& name, ParserState& state, ParameterAnnotation& paramAnnotations, bool* srgb, bool* autoregister ) +{ + paramAnnotations.annotations.clear(); + + bool localSrgb = false; + bool localAutoregister = false; + + auto globalSymbol = state.GetSymbolTable().LookupGlobal( ToString( name ).c_str() ); + if( globalSymbol && globalSymbol->annotations ) { - switch( type.builtInType ) + + for( auto& ai : *globalSymbol->annotations ) { - case OP_TEXTURE1D: - case OP_TEXTURE1DARRAY: - case OP_RWTEXTURE1D: - case OP_RWTEXTURE1DARRAY: - return TEX_TYPE_1D; - case OP_TEXTURE: - case OP_TEXTURE2D: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: - case OP_RWTEXTURE2D: - case OP_RWTEXTURE2DARRAY: - return TEX_TYPE_2D; - case OP_TEXTURE3D: - case OP_RWTEXTURE3D: - case OP_TEXTURE3DARRAY: - return TEX_TYPE_3D; - case OP_TEXTURECUBE: - case OP_TEXTURECUBEARRAY: - return TEX_TYPE_CUBE; - case OP_BUFFER: - case OP_RWBUFFER: - return TEX_TYPE_BUFFER; - case OP_STRUCTUREDBUFFER: - case OP_RWSTRUCTUREDBUFFER: - return TEX_TYPE_STRUCTURED_BUFFER; - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - return TEX_TYPE_RAYTRACING_ACCELERATION_STRUCTURE; - default: - return TEX_TYPE_INVALID; + Annotation result; + if( MakeEffectAnnotationFromSymbolAnnotation( ai, result, localSrgb, localAutoregister ) ) + { + paramAnnotations.annotations[g_stringTable.AddString( ai.name )] = result; + } } } - - bool ExtractAnnotations( const InlineString& name, ParserState& state, ParameterAnnotation& paramAnnotations, bool* srgb, bool* autoregister ) + if( srgb ) { - paramAnnotations.annotations.clear(); + *srgb = localSrgb; + } + if( autoregister ) + { + *autoregister = localAutoregister; + } + return !paramAnnotations.annotations.empty(); +} - bool localSrgb = false; - bool localAutoregister = false; +bool CollectConstants( ParserState& state, StageData& stage, std::map& annotations ) +{ + const InlineString globalsStructName = MakeInlineString( "GlobalsData" ); - auto globalSymbol = state.GetSymbolTable().LookupGlobal( ToString( name ).c_str() ); - if( globalSymbol && globalSymbol->annotations ) + ASTNode* root = state.GetTree(); + if( root ) + { + // Find "GlobalsData" struct. + for( size_t i = 0, n = root->GetChildrenCount(); i < n; ++i ) { - - for( auto& ai : *globalSymbol->annotations ) + ASTNode* node = root->GetChild( i ); + if( node && node->GetNodeType() == NT_STRUCT && + node->GetSymbol() && node->GetSymbol()->name == globalsStructName ) { - Annotation result; - if( MakeEffectAnnotationFromSymbolAnnotation( ai, result, localSrgb, localAutoregister ) ) + if( !CollectConstants( state, stage, node, annotations ) ) { - paramAnnotations.annotations[g_stringTable.AddString( ai.name )] = result; + return false; } } } - if( srgb ) - { - *srgb = localSrgb; - } - if( autoregister ) - { - *autoregister = localAutoregister; - } - return !paramAnnotations.annotations.empty(); - } - - bool CollectConstants( ParserState& state, StageData& stage, std::map& annotations ) - { - const InlineString globalsStructName = MakeInlineString( "GlobalsData" ); - - ASTNode* root = state.GetTree(); - if( root ) - { - // Find "GlobalsData" struct. - for( size_t i = 0, n = root->GetChildrenCount(); i < n; ++i ) - { - ASTNode* node = root->GetChild( i ); - if( node && node->GetNodeType() == NT_STRUCT && - node->GetSymbol() && node->GetSymbol()->name == globalsStructName ) - { - if( !CollectConstants( state, stage, node, annotations ) ) - { - return false; - } - } - } - } - return true; - } - - bool GetStageData( ParserState& state, StageData& stage, std::vector rtConstantBuffers, std::map& annotations ) - { - if( !CollectConstants( state, stage, annotations ) ) - { - return false; - } - - for( size_t i = 0; i < rtConstantBuffers.size(); ++i ) - { - if( !rtConstantBuffers[i] ) - { - continue; - } - RegisterInputDescription r = { RT_CONSTANT_BUFFER, (uint32_t)i, 1, 0 }; - if( find( begin( stage.registerInputs ), end( stage.registerInputs ), r ) == end( stage.registerInputs ) ) - { - stage.registerInputs.push_back( r ); - } - } - return true; - } - - bool GetStageDataForNode( ParserState & state, StageData & stage, ASTNode * functionHeader, std::map & annotations ) - { - for( size_t i = 0, n = functionHeader->GetChildrenCount(); i < n; ++i ) - { - ASTNode* child = functionHeader->GetChild( i ); - assert( child ); - - Symbol* symbol = child->GetSymbol(); - assert( symbol ); + } + return true; +} - const Type& type = child->GetType(); +bool GetStageData( ParserState& state, StageData& stage, std::vector rtConstantBuffers, std::map& annotations ) +{ + if( !CollectConstants( state, stage, annotations ) ) + { + return false; + } - assert( !symbol->registerSpecifier.empty() ); - const RegisterSpecifier& reg = symbol->registerSpecifier.cbegin()->second; + for( size_t i = 0; i < rtConstantBuffers.size(); ++i ) + { + if( !rtConstantBuffers[i] ) + { + continue; + } + RegisterInputDescription r = { RT_CONSTANT_BUFFER, (uint32_t)i, 1, 0 }; + if( find( begin( stage.registerInputs ), end( stage.registerInputs ), r ) == end( stage.registerInputs ) ) + { + stage.registerInputs.push_back( r ); + } + } + return true; +} - switch( reg.registerType ) - { - case MetalRegister::CBuffer: - { - stage.registerInputs.push_back( { RT_CONSTANT_BUFFER, (uint32_t)reg.registerNumber, 1, 0 } ); - } - continue; - default: - break; - } +bool GetStageDataForNode( ParserState& state, StageData& stage, ASTNode* functionHeader, std::map& annotations ) +{ + for( size_t i = 0, n = functionHeader->GetChildrenCount(); i < n; ++i ) + { + ASTNode* child = functionHeader->GetChild( i ); + assert( child ); - if( type.arrayDimensions > 0 ) - { - assert( reg.registerType == MetalRegister::SRV || reg.registerType == MetalRegister::UAV ); + Symbol* symbol = child->GetSymbol(); + assert( symbol ); - if( symbol->used ) - { - if( reg.registerType == MetalRegister::SRV ) - { - if ( type.IsSampler() ) - { - stage.registerInputs.push_back( { RT_SAMPLER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); + const Type& type = child->GetType(); - Sampler sampler = {}; + assert( !symbol->registerSpecifier.empty() ); + const RegisterSpecifier& reg = symbol->registerSpecifier.cbegin()->second; - auto globalSamplerSymbol = state.GetSymbolTable().LookupGlobal( ToString( symbol->name ).c_str() ); - if( !GetSamplerState( state, globalSamplerSymbol->definition, sampler ) ) - { - return false; - } + switch( reg.registerType ) + { + case MetalRegister::CBuffer: { + stage.registerInputs.push_back( { RT_CONSTANT_BUFFER, (uint32_t)reg.registerNumber, 1, 0 } ); + } + continue; + default: + break; + } - if( sampler.addressU == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressV == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressW == D3D11_TEXTURE_ADDRESS_BORDER ) - { - auto& c = sampler.borderColor; - if( ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 0 ) && - ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 1 ) && - ( c.x != 1 || c.y != 1 || c.z != 1 || c.w != 1 ) ) - { - state.ShowMessage( globalSamplerSymbol->definition->GetLocation(), EC_CUSTOM_ERROR, "sampler border color is not one of colors supported by Metal" ); - return false; - } - } + if( type.arrayDimensions > 0 ) + { + assert( reg.registerType == MetalRegister::SRV || reg.registerType == MetalRegister::UAV ); - sampler.name = g_stringTable.AddString( symbol->name ); + if( symbol->used ) + { + if( reg.registerType == MetalRegister::SRV ) + { + if( type.IsSampler() ) + { + stage.registerInputs.push_back( { RT_SAMPLER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, nullptr ) ) - { - annotations[sampler.name] = paramAnnotations; - } + Sampler sampler = {}; - stage.samplers[uint8_t( reg.registerNumber )] = sampler; - } - else + auto globalSamplerSymbol = state.GetSymbolTable().LookupGlobal( ToString( symbol->name ).c_str() ); + if( !GetSamplerState( state, globalSamplerSymbol->definition, sampler ) ) { - stage.registerInputs.push_back( { RT_SRV_BUFFER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); + return false; + } - Texture texture; - texture.name = g_stringTable.AddString( symbol->name ); - texture.type = TypeToTextureType( type ); - if( texture.type == TEX_TYPE_INVALID ) - { - continue; - } - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) + if( sampler.addressU == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressV == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressW == D3D11_TEXTURE_ADDRESS_BORDER ) + { + auto& c = sampler.borderColor; + if( ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 0 ) && + ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 1 ) && + ( c.x != 1 || c.y != 1 || c.z != 1 || c.w != 1 ) ) { - annotations[texture.name] = paramAnnotations; + state.ShowMessage( globalSamplerSymbol->definition->GetLocation(), EC_CUSTOM_ERROR, "sampler border color is not one of colors supported by Metal" ); + return false; } - stage.textures[uint8_t( reg.registerNumber )] = texture; } + + sampler.name = g_stringTable.AddString( symbol->name ); + + ParameterAnnotation paramAnnotations; + if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, nullptr ) ) + { + annotations[sampler.name] = paramAnnotations; + } + + stage.samplers[uint8_t( reg.registerNumber )] = sampler; } else { - stage.registerInputs.push_back( { RT_UAV_BUFFER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); + stage.registerInputs.push_back( { RT_SRV_BUFFER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); - Uav texture; + Texture texture; texture.name = g_stringTable.AddString( symbol->name ); texture.type = TypeToTextureType( type ); if( texture.type == TEX_TYPE_INVALID ) { continue; } - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &texture.isAutoregister ) ) + if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) { annotations[texture.name] = paramAnnotations; } + stage.textures[uint8_t( reg.registerNumber )] = texture; + } + } + else + { + stage.registerInputs.push_back( { RT_UAV_BUFFER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); + + Uav texture; + texture.name = g_stringTable.AddString( symbol->name ); + texture.type = TypeToTextureType( type ); + if( texture.type == TEX_TYPE_INVALID ) + { + continue; + } - stage.uavs[uint8_t( reg.registerNumber )] = texture; + ParameterAnnotation paramAnnotations; + if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &texture.isAutoregister ) ) + { + annotations[texture.name] = paramAnnotations; } + + stage.uavs[uint8_t( reg.registerNumber )] = texture; } } - else + } + else + { + switch( type.builtInType ) { - switch( type.builtInType ) - { - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - { - assert( reg.registerType == MetalRegister::CBuffer || - reg.registerType == MetalRegister::SRV ); + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: { + assert( reg.registerType == MetalRegister::CBuffer || + reg.registerType == MetalRegister::SRV ); - stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); + stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); - if( symbol->used ) + if( symbol->used ) + { + Texture texture; + texture.name = g_stringTable.AddString( symbol->name ); + texture.type = TypeToTextureType( type ); + + ParameterAnnotation paramAnnotations; + if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) { - Texture texture; - texture.name = g_stringTable.AddString( symbol->name ); - texture.type = TypeToTextureType( type ); + annotations[texture.name] = paramAnnotations; + } - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) - { - annotations[texture.name] = paramAnnotations; - } + stage.textures[uint8_t( reg.registerNumber )] = texture; + } + } + break; - stage.textures[uint8_t( reg.registerNumber )] = texture; + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: { + assert( reg.registerType == MetalRegister::UAV ); + + stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 1 } ); + + if( symbol->used ) + { + Uav uav; + uav.name = g_stringTable.AddString( symbol->name ); + uav.type = TypeToTextureType( type ); + + ParameterAnnotation paramAnnotations; + if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &uav.isAutoregister ) ) + { + annotations[uav.name] = paramAnnotations; } + + stage.uavs[uint8_t( reg.registerNumber )] = uav; } - break; + } + break; - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: { - assert( reg.registerType == MetalRegister::UAV ); + case OP_TEXTURE: + case OP_TEXTURE1D: + case OP_TEXTURE1DARRAY: + case OP_TEXTURE2D: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE3D: + // case OP_TEXTURE3DARRAY: + case OP_TEXTURECUBE: + case OP_TEXTURECUBEARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: { + assert( reg.registerType == MetalRegister::Texture ); - stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 1 } ); + stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); - if( symbol->used ) + if( symbol->used ) + { + Texture texture; + texture.name = g_stringTable.AddString( symbol->name ); + texture.type = TypeToTextureType( type ); + if( texture.type == TEX_TYPE_INVALID ) { - Uav uav; - uav.name = g_stringTable.AddString( symbol->name ); - uav.type = TypeToTextureType( type ); - - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &uav.isAutoregister ) ) - { - annotations[uav.name] = paramAnnotations; - } + continue; + } - stage.uavs[uint8_t( reg.registerNumber )] = uav; + ParameterAnnotation paramAnnotations; + if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) + { + annotations[texture.name] = paramAnnotations; } + + stage.textures[uint8_t( reg.registerNumber )] = texture; } break; - - case OP_TEXTURE: - case OP_TEXTURE1D: - case OP_TEXTURE1DARRAY: - case OP_TEXTURE2D: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE3D: - // case OP_TEXTURE3DARRAY: - case OP_TEXTURECUBE: - case OP_TEXTURECUBEARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: { - assert( reg.registerType == MetalRegister::Texture ); + } + case OP_RWTEXTURE1D: + case OP_RWTEXTURE1DARRAY: + case OP_RWTEXTURE2D: + case OP_RWTEXTURE2DARRAY: + case OP_RWTEXTURE3D: + // case OP_RWTEXTURE3DARRAY: + { + assert( reg.registerType == MetalRegister::UAV ); stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); if( symbol->used ) { - Texture texture; - texture.name = g_stringTable.AddString( symbol->name ); - texture.type = TypeToTextureType( type ); - if( texture.type == TEX_TYPE_INVALID ) + Uav uav; + uav.name = g_stringTable.AddString( symbol->name ); + uav.type = TypeToTextureType( type ); + if( uav.type == TEX_TYPE_INVALID ) { continue; } ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, &texture.isSRGB, &texture.isAutoregister ) ) + if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &uav.isAutoregister ) ) { - annotations[texture.name] = paramAnnotations; + annotations[uav.name] = paramAnnotations; } - stage.textures[uint8_t( reg.registerNumber )] = texture; + stage.uavs[uint8_t( reg.registerNumber )] = uav; } + break; } - case OP_RWTEXTURE1D: - case OP_RWTEXTURE1DARRAY: - case OP_RWTEXTURE2D: - case OP_RWTEXTURE2DARRAY: - case OP_RWTEXTURE3D: - // case OP_RWTEXTURE3DARRAY: - { - assert( reg.registerType == MetalRegister::UAV ); - stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); - - if( symbol->used ) - { - Uav uav; - uav.name = g_stringTable.AddString( symbol->name ); - uav.type = TypeToTextureType( type ); - if( uav.type == TEX_TYPE_INVALID ) - { - continue; - } + case OP_SAMPLER: + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLERCOMPARISON: { + assert( reg.registerType == MetalRegister::Sampler ); - ParameterAnnotation paramAnnotations; - if( ExtractAnnotations( symbol->name, state, paramAnnotations, nullptr, &uav.isAutoregister ) ) - { - annotations[uav.name] = paramAnnotations; - } + stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); - stage.uavs[uint8_t( reg.registerNumber )] = uav; - } + if( symbol->used ) + { + Sampler sampler = {}; - break; + auto globalSamplerSymbol = state.GetSymbolTable().LookupGlobal( ToString( symbol->name ).c_str() ); + if( !GetSamplerState( state, globalSamplerSymbol->definition, sampler ) ) + { + return false; } - case OP_SAMPLER: - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLERCOMPARISON: { - assert( reg.registerType == MetalRegister::Sampler ); - - stage.registerInputs.push_back( { TypeToRegisterInputType( type ), (uint32_t)reg.registerNumber, 1, 0 } ); - - if( symbol->used ) + if( sampler.addressU == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressV == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressW == D3D11_TEXTURE_ADDRESS_BORDER ) { - Sampler sampler = {}; - - auto globalSamplerSymbol = state.GetSymbolTable().LookupGlobal( ToString( symbol->name ).c_str() ); - if( !GetSamplerState( state, globalSamplerSymbol->definition, sampler ) ) + auto& c = sampler.borderColor; + if( ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 0 ) && + ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 1 ) && + ( c.x != 1 || c.y != 1 || c.z != 1 || c.w != 1 ) ) { + state.ShowMessage( globalSamplerSymbol->definition->GetLocation(), EC_CUSTOM_ERROR, "sampler border color is not one of colors supported by Metal" ); return false; } - - if( sampler.addressU == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressV == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressW == D3D11_TEXTURE_ADDRESS_BORDER ) - { - auto& c = sampler.borderColor; - if( ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 0 ) && - ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 1 ) && - ( c.x != 1 || c.y != 1 || c.z != 1 || c.w != 1 ) ) - { - state.ShowMessage( globalSamplerSymbol->definition->GetLocation(), EC_CUSTOM_ERROR, "sampler border color is not one of colors supported by Metal" ); - return false; - } - } - - sampler.name = g_stringTable.AddString( symbol->name ); - - stage.samplers[uint8_t( reg.registerNumber )] = sampler; } - break; - } + sampler.name = g_stringTable.AddString( symbol->name ); - default: - break; + stage.samplers[uint8_t( reg.registerNumber )] = sampler; } + + break; } - } - return true; + default: + break; + } + } } - bool GetStageData( ParserState& state, StageData& stage, ASTNode* callNode, std::map& annotations ) + return true; +} + +bool GetStageData( ParserState& state, StageData& stage, ASTNode* callNode, std::map& annotations ) +{ + if( !CollectConstants( state, stage, annotations ) ) { - if( !CollectConstants( state, stage, annotations ) ) - { - return false; - } + return false; + } - Symbol* entryPointSymbol = callNode->GetSymbol(); - if( !entryPointSymbol || !entryPointSymbol->definition ) - { - return false; - } + Symbol* entryPointSymbol = callNode->GetSymbol(); + if( !entryPointSymbol || !entryPointSymbol->definition ) + { + return false; + } - ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); - if( !functionHeader ) - { - return false; - } - return GetStageDataForNode( state, stage, functionHeader, annotations ); + ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); + if( !functionHeader ) + { + return false; } + return GetStageDataForNode( state, stage, functionHeader, annotations ); +} - bool GetGlobalInputData( ParserState& state, StageData& stage, const std::vector& globalInputs, ASTNode* globalInputsStruct, std::map& annotations ) +bool GetGlobalInputData( ParserState& state, StageData& stage, const std::vector& globalInputs, ASTNode* globalInputsStruct, std::map& annotations ) +{ + auto tmp = state.NewNode( NT_FUNCTION_HEADER ); + for( size_t gi = 0; gi < globalInputs.size(); ++gi ) { - auto tmp = state.NewNode( NT_FUNCTION_HEADER ); - for( size_t gi = 0; gi < globalInputs.size(); ++gi ) - { - auto member = globalInputsStruct->GetChild( gi )->GetChild( 0 )->Copy(); - member->SetType( globalInputs[gi].type ); - tmp->AddChild( member ); - } - if( !AutoAssignRegistersForNode( state, tmp, globalInputsStruct->GetLocation() ) ) - { - return false; - } - if( !GetStageDataForNode( state, stage, tmp, annotations ) ) - { - return false; - } - for( auto& element : tmp->GetChildren() ) - { - element->GetSymbol()->registerSpecifier.clear(); - } - return true; + auto member = globalInputsStruct->GetChild( gi )->GetChild( 0 )->Copy(); + member->SetType( globalInputs[gi].type ); + tmp->AddChild( member ); + } + if( !AutoAssignRegistersForNode( state, tmp, globalInputsStruct->GetLocation() ) ) + { + return false; + } + if( !GetStageDataForNode( state, stage, tmp, annotations ) ) + { + return false; + } + for( auto& element : tmp->GetChildren() ) + { + element->GetSymbol()->registerSpecifier.clear(); } + return true; +} - std::pair RunProcess( const char* commandLine ) - { - s_fileMutex.lock(); +std::pair RunProcess( const char* commandLine ) +{ + s_fileMutex.lock(); #ifdef _WIN32 - FILE* process = _popen( commandLine, "r" ); + FILE* process = _popen( commandLine, "r" ); #else - FILE* process = popen( commandLine, "r" ); + FILE* process = popen( commandLine, "r" ); #endif - s_fileMutex.unlock(); + s_fileMutex.unlock(); - if( !process ) - { - return std::make_pair( -1, "" ); - } - std::string output; - char readBuffer[128]; - while( fgets( readBuffer, sizeof( readBuffer ), process ) ) - { - output += readBuffer; - } + if( !process ) + { + return std::make_pair( -1, "" ); + } + std::string output; + char readBuffer[128]; + while( fgets( readBuffer, sizeof( readBuffer ), process ) ) + { + output += readBuffer; + } #ifdef _WIN32 - return std::make_pair( _pclose( process ), output ); + return std::make_pair( _pclose( process ), output ); #else - return std::make_pair( pclose( process ), output ); + return std::make_pair( pclose( process ), output ); #endif - } +} - template - void SplitString( const std::string& string, char delim, T callback ) +template +void SplitString( const std::string& string, char delim, T callback ) +{ + size_t last = 0; + size_t next = 0; + while( ( next = string.find( delim, last ) ) != std::string::npos ) { - size_t last = 0; - size_t next = 0; - while( ( next = string.find( delim, last ) ) != std::string::npos ) - { - callback( string.substr( last, next - last ) ); - last = next + 1; - } - callback( string.substr( last ) ); + callback( string.substr( last, next - last ) ); + last = next + 1; } + callback( string.substr( last ) ); +} - struct MetalTool - { - std::string name; - }; +struct MetalTool +{ + std::string name; +}; - std::string MetalTool( const char* name ) - { - std::ostringstream cmd; +std::string MetalTool( const char* name ) +{ + std::ostringstream cmd; #ifdef _WIN32 - if( !g_metalToolsPath.empty() ) - { - cmd << "\"" << g_metalToolsPath << "\\macos\\bin\\" << name << ".exe\""; - } - else - { - char programFiles[MAX_PATH] = { 0 }; - size_t programFilesSize; - getenv_s( &programFilesSize, programFiles, "PROGRAMFILES" ); + if( !g_metalToolsPath.empty() ) + { + cmd << "\"" << g_metalToolsPath << "\\macos\\bin\\" << name << ".exe\""; + } + else + { + char programFiles[MAX_PATH] = { 0 }; + size_t programFilesSize; + getenv_s( &programFilesSize, programFiles, "PROGRAMFILES" ); - cmd << "\"" << programFiles << "\\Metal Developer Tools\\metal\\macos\\bin\\" << name << ".exe\""; - } + cmd << "\"" << programFiles << "\\Metal Developer Tools\\metal\\macos\\bin\\" << name << ".exe\""; + } #else - cmd << "xcrun -sdk macosx " << name; + cmd << "xcrun -sdk macosx " << name; #endif - return cmd.str(); - } + return cmd.str(); +} - // Implements a disgusting method of funding which shader parameters turn out to be unused by the shader - // and emits warnings for them. - // Uses metal-objdump to disassemble the shader binary, finds a shader definition and looks through parameters. - // Parameters having "readnone" token are unused. Or so I think... - void DetectUnusedArguments( const char* libPath, ParserState& state, ASTNode* callNode ) - { - ZoneScoped; +// Implements a disgusting method of funding which shader parameters turn out to be unused by the shader +// and emits warnings for them. +// Uses metal-objdump to disassemble the shader binary, finds a shader definition and looks through parameters. +// Parameters having "readnone" token are unused. Or so I think... +void DetectUnusedArguments( const char* libPath, ParserState& state, ASTNode* callNode ) +{ + ZoneScoped; - std::string entryName = ToString( callNode->GetChild( 1 )->GetSymbol()->name ); - auto functionHeader = callNode->GetChild( 1 )->GetSymbol()->definition->GetChild( 0 ); + std::string entryName = ToString( callNode->GetChild( 1 )->GetSymbol()->name ); + auto functionHeader = callNode->GetChild( 1 )->GetSymbol()->definition->GetChild( 0 ); - for( auto child : functionHeader->GetChildren() ) + for( auto child : functionHeader->GetChildren() ) + { + if( child && child->GetSymbol() ) { - if( child && child->GetSymbol() ) - { - child->GetSymbol()->used = true; - } + child->GetSymbol()->used = true; } + } - std::ostringstream cmd; - cmd << MetalTool( "metal-objdump" ) << " -disassemble " << libPath; - auto objdump = RunProcess( cmd.str().c_str() ); - if( objdump.first != 0 ) - { - state.ShowMessage( callNode->GetLocation(), EC_CUSTOM_WARNING, "failed to run objdump, unused parameter information is unavailable" ); - } + std::ostringstream cmd; + cmd << MetalTool( "metal-objdump" ) << " -disassemble " << libPath; + auto objdump = RunProcess( cmd.str().c_str() ); + if( objdump.first != 0 ) + { + state.ShowMessage( callNode->GetLocation(), EC_CUSTOM_WARNING, "failed to run objdump, unused parameter information is unavailable" ); + } - size_t argumentIndex = 0; - size_t stageInIndex = 0; + size_t argumentIndex = 0; + size_t stageInIndex = 0; - std::regex shader( "define.*@" + entryName + "(.*)" ); - std::smatch match; - if( std::regex_search( objdump.second, match, shader ) ) - { - auto args = match[1].str(); - SplitString( args, ',', [&]( auto arg ) { - std::string argName = arg; - Symbol* argumentSymbol = nullptr; + std::regex shader( "define.*@" + entryName + "(.*)" ); + std::smatch match; + if( std::regex_search( objdump.second, match, shader ) ) + { + auto args = match[1].str(); + SplitString( args, ',', [&]( auto arg ) { + std::string argName = arg; + Symbol* argumentSymbol = nullptr; - if( argumentIndex < functionHeader->GetChildrenCount() ) - { - argumentSymbol = functionHeader->GetChild( argumentIndex )->GetSymbol(); + if( argumentIndex < functionHeader->GetChildrenCount() ) + { + argumentSymbol = functionHeader->GetChild( argumentIndex )->GetSymbol(); - bool isStageIn = false; - for( auto reg : argumentSymbol->registerSpecifier ) + bool isStageIn = false; + for( auto reg : argumentSymbol->registerSpecifier ) + { + if( reg.second.registerType == MetalRegister::StageIn ) { - if( reg.second.registerType == MetalRegister::StageIn ) - { - isStageIn = true; - break; - } + isStageIn = true; + break; } + } - argName = ToString( argumentSymbol->name ); - if( isStageIn ) - { - argName += "." + ToString( functionHeader->GetChild( argumentIndex )->GetType().symbol->definition->GetChild( stageInIndex )->GetChild( 0 )->GetSymbol()->name ); - if( ++stageInIndex >= functionHeader->GetChild( argumentIndex )->GetType().symbol->definition->GetChildrenCount() ) - { - ++argumentIndex; - } - } - else + argName = ToString( argumentSymbol->name ); + if( isStageIn ) + { + argName += "." + ToString( functionHeader->GetChild( argumentIndex )->GetType().symbol->definition->GetChild( stageInIndex )->GetChild( 0 )->GetSymbol()->name ); + if( ++stageInIndex >= functionHeader->GetChild( argumentIndex )->GetType().symbol->definition->GetChildrenCount() ) { ++argumentIndex; } } + else + { + ++argumentIndex; + } + } - if( arg.find( "readnone" ) != std::string::npos ) + if( arg.find( "readnone" ) != std::string::npos ) + { + state.ShowMessage( callNode->GetLocation(), EC_CUSTOM_WARNING, "Unused argument %s", argName.c_str() ); + if( argumentSymbol ) { - state.ShowMessage( callNode->GetLocation(), EC_CUSTOM_WARNING, "Unused argument %s", argName.c_str() ); - if( argumentSymbol ) - { - argumentSymbol->used = false; - } + argumentSymbol->used = false; } - } ); + } + } ); + } +} + +bool IsIndexOperator( const ASTNode* node ) +{ + return node->GetNodeType() == NT_POSTFIX_EXPRESSION && node->GetToken() && node->GetToken()->type == OP_LEFT_BRACKET; +} + +void ExpandInitializerList( ASTNode* initializer, std::vector& children ) +{ + for( auto child : initializer->GetChildren() ) + { + if( child->GetNodeType() == NT_INLINE_CONSTRUCTOR ) + { + ExpandInitializerList( child, children ); + } + else + { + children.push_back( child ); + } + } +} + +void PatchMatrixInitializer( ASTNode* parent, unsigned index, const Type& type ) +{ + // wrap matrix initializer in a "constructor", i.e. { a, b,..} -> float4x4( { a, b, ..} ) + auto initializer = parent->GetChild( index ); + if( type.arrayDimensions > 0 ) + { + auto elementType = type; + --elementType.arrayDimensions; + + for( unsigned i = 0; i < initializer->GetChildrenCount(); ++i ) + { + PatchMatrixInitializer( initializer, i, elementType ); + } + } + else + { + std::vector children; + ExpandInitializerList( initializer, children ); + + if( int( children.size() ) == type.width * type.height ) + { + initializer->GetChildren().clear(); + + for( int row = 0; row < type.height; ++row ) + { + auto rowNode = new ASTNode( NT_INLINE_CONSTRUCTOR, initializer->GetLocation(), initializer->GetScope(), nullptr ); + rowNode->SetType( TypeFromTokenType( OP_FLOAT, type.width ) ); + for( int col = 0; col < type.width; ++col ) + { + rowNode->AddChild( children[row * type.width + col] ); + } + initializer->AddChild( rowNode ); + } + } + + ScannerToken token; + token.type = type.builtInType; + token.fileLocation = initializer->GetLocation(); + token.intValue = type.width | ( type.height << 8 ); + auto constructor = new ASTNode( NT_FUNCTION_CALL, initializer->GetLocation(), initializer->GetScope(), &token ); + constructor->AddChild( initializer ); + initializer->SetType( type ); + constructor->SetType( type ); + parent->ReplaceChild( index, constructor ); + } +} + +void PatchMatrixRows( ParserState& state, ASTNode* node, ASTNode* parent = nullptr, bool rvalue = true, ASTNode* assignment = nullptr ) +{ + if( node->GetNodeType() == NT_NAME_DECLARATION && node->GetType().IsMatrix() && node->GetChildOrNull( 1 ) && node->GetChild( 1 )->GetNodeType() == NT_INLINE_CONSTRUCTOR ) + { + PatchMatrixInitializer( node, 1, node->GetType() ); + } + + if( node->GetNodeType() == NT_FUNCTION_CALL && node->GetSymbol() == nullptr && node->GetType().IsMatrix() ) + { + // transpose matrix constructors + auto copy = node->Copy(); + auto transpose = ScannerToken::ID( MakeInlineString( "transpose" ), node->GetLocation() ); + node->SetToken( &transpose ); + node->GetChildren().clear(); + node->AddChild( copy ); + + std::string diagnosticMessage; + Symbol* symbol = state.GetSymbolTable().LookupFunction( transpose.stringValue, node, diagnosticMessage ); + assert( symbol ); + node->SetSymbol( symbol ); + + if( symbol->intrinsicType ) + { + node->SetType( ( *symbol->intrinsicType )( node, -1 ) ); + } + else + { + node->SetType( symbol->type ); + } + node = copy; + } + // looking for matrix[] expressions + if( IsIndexOperator( node ) && node->GetChild( 0 )->GetType().IsMatrix() && node->GetChild( 0 )->GetType().arrayDimensions == 0 ) + { + if( parent && parent->GetChild( 0 ) == node && IsIndexOperator( parent ) ) + { + // m[x][y] -> m[y][x] + auto x = node->GetChild( 1 ); + node->ReplaceChild( 1, parent->GetChild( 1 ) ); + parent->ReplaceChild( 1, x ); + } + else + { + const auto& matrixType = node->GetChild( 0 )->GetType(); + if( rvalue ) + { + // replace m[x] with matrixRow(m, x) + ScannerToken callToken = ScannerToken::ID( MakeInlineString( "matrixRow" ), node->GetLocation() ); + node->SetToken( &callToken ); + node->SetNodeType( NT_FUNCTION_CALL ); + } + else + { + // replace m[x] with MatrixRow#LH<#>(m, x) + char* name = state.AllocateString( 32 ); +#ifdef _WIN32 + sprintf_s( name, 32, "MatrixRow%dLH<%d>", matrixType.height, matrixType.width ); +#else + snprintf( name, 32, "MatrixRow%dLH<%d>", matrixType.height, matrixType.width ); +#endif + ScannerToken callToken = ScannerToken::ID( MakeInlineString( name ), node->GetLocation() ); + node->SetToken( &callToken ); + node->SetNodeType( NT_FUNCTION_CALL ); + } + } + } + if( node->GetNodeType() == NT_EXPRESSION && node->GetToken() ) + { + switch( node->GetToken()->type ) + { + case OP_EQUAL: + case OP_MUL_ASSIGN: + case OP_DIV_ASSIGN: + case OP_MOD_ASSIGN: + case OP_ADD_ASSIGN: + case OP_SUB_ASSIGN: + case OP_AND_ASSIGN: + case OP_OR_ASSIGN: + case OP_XOR_ASSIGN: + case OP_LEFT_ASSIGN: + case OP_RIGHT_ASSIGN: + PatchMatrixRows( state, node->GetChild( 0 ), node, false, node ); + PatchMatrixRows( state, node->GetChild( 1 ), node, true, node ); + return; } } - - bool IsIndexOperator( const ASTNode* node ) + if( node->GetNodeType() != NT_POSTFIX_EXPRESSION ) { - return node->GetNodeType() == NT_POSTFIX_EXPRESSION && node->GetToken() && node->GetToken()->type == OP_LEFT_BRACKET; + rvalue = true; } - - void ExpandInitializerList( ASTNode* initializer, std::vector& children ) + for( auto child : node->GetChildren() ) { - for( auto child : initializer->GetChildren() ) + if( !child ) { - if( child->GetNodeType() == NT_INLINE_CONSTRUCTOR ) - { - ExpandInitializerList( child, children ); - } - else - { - children.push_back( child ); - } + continue; } + PatchMatrixRows( state, child, node, rvalue, assignment ); } +} - void PatchMatrixInitializer( ASTNode* parent, unsigned index, const Type& type ) - { - // wrap matrix initializer in a "constructor", i.e. { a, b,..} -> float4x4( { a, b, ..} ) - auto initializer = parent->GetChild( index ); - if( type.arrayDimensions > 0 ) - { - auto elementType = type; - --elementType.arrayDimensions; +std::vector CompileCode( const std::string& code, const std::vector& defines, bool forceOldVersion = true ) +{ + std::vector compiledCode; - for( unsigned i = 0; i < initializer->GetChildrenCount(); ++i ) - { - PatchMatrixInitializer( initializer, i, elementType ); - } - } - else - { - std::vector children; - ExpandInitializerList( initializer, children ); + // "mktemp" function calls to "arc4random" which is not reentrant. So, we need to sync + // our threads here to avoid parallel execution of this function. + s_fileMutex.lock(); - if( int( children.size() ) == type.width * type.height ) - { - initializer->GetChildren().clear(); +#ifdef _WIN32 + char srcFilenameTemplate[] = "mtl_tmpXXXXXXX"; + char binFilenameTemplate[] = "air_tmpXXXXXXX"; - for( int row = 0; row < type.height; ++row ) - { - auto rowNode = new ASTNode( NT_INLINE_CONSTRUCTOR, initializer->GetLocation(), initializer->GetScope(), nullptr ); - rowNode->SetType( TypeFromTokenType( OP_FLOAT, type.width ) ); - for( int col = 0; col < type.width; ++col ) - { - rowNode->AddChild( children[ row * type.width + col ] ); - } - initializer->AddChild( rowNode ); - } - } + _mktemp_s( srcFilenameTemplate ); + _mktemp_s( binFilenameTemplate ); - ScannerToken token; - token.type = type.builtInType; - token.fileLocation = initializer->GetLocation(); - token.intValue = type.width | ( type.height << 8 ); - auto constructor = new ASTNode( NT_FUNCTION_CALL, initializer->GetLocation(), initializer->GetScope(), &token ); - constructor->AddChild( initializer ); - initializer->SetType( type ); - constructor->SetType( type ); - parent->ReplaceChild( index, constructor ); - } + char* srcFilename = srcFilenameTemplate; + char* binFilename = binFilenameTemplate; +#else + char srcFilenameTemplate[] = "src_XXXXXXX.metal"; + char binFilenameTemplate[] = "bin_XXXXXXX.air"; + + char* srcFilename = nullptr; + char* binFilename = nullptr; + + { + int srcFd = mkstemps( srcFilenameTemplate, 6 ); + int binFd = mkstemps( binFilenameTemplate, 4 ); + + srcFilename = ( srcFd != -1 ) ? srcFilenameTemplate : nullptr; + binFilename = ( binFd != -1 ) ? binFilenameTemplate : nullptr; + + close( srcFd ); + close( binFd ); } +#endif + s_fileMutex.unlock(); - void PatchMatrixRows( ParserState& state, ASTNode* node, ASTNode* parent = nullptr, bool rvalue = true, ASTNode* assignment = nullptr ) + if( !srcFilename || !binFilename ) { - if( node->GetNodeType() == NT_NAME_DECLARATION && node->GetType().IsMatrix() && node->GetChildOrNull( 1 ) && node->GetChild( 1 )->GetNodeType() == NT_INLINE_CONSTRUCTOR ) - { - PatchMatrixInitializer( node, 1, node->GetType() ); - } + // Failed to generate a name for temporary file(s). + return compiledCode; + } - if( node->GetNodeType() == NT_FUNCTION_CALL && node->GetSymbol() == nullptr && node->GetType().IsMatrix() ) + do + { + // Write shader source into temp file. { - // transpose matrix constructors - auto copy = node->Copy(); - auto transpose = ScannerToken::ID( MakeInlineString( "transpose" ), node->GetLocation() ); - node->SetToken( &transpose ); - node->GetChildren().clear(); - node->AddChild( copy ); + ZoneScopedN( "Write Source" ); - std::string diagnosticMessage; - Symbol* symbol = state.GetSymbolTable().LookupFunction( transpose.stringValue, node, diagnosticMessage ); - assert( symbol ); - node->SetSymbol( symbol ); - - if( symbol->intrinsicType ) + std::lock_guard withFileMutex( s_fileMutex ); + FILE* file = nullptr; + if( fopen_s( &file, srcFilename, "w" ) != 0 ) { - node->SetType( ( *symbol->intrinsicType )( node, -1 ) ); + // Failed to create shader source file. + break; } - else + size_t bytesWritten = fwrite( code.c_str(), 1, code.length(), file ); + fclose( file ); + file = nullptr; + + if( bytesWritten != code.length() ) { - node->SetType( symbol->type ); + // Failed to write shader source file. + break; } - node = copy; } - // looking for matrix[] expressions - if( IsIndexOperator( node ) && node->GetChild( 0 )->GetType().IsMatrix() && node->GetChild( 0 )->GetType().arrayDimensions == 0 ) + + // Compile shader. { - if( parent && parent->GetChild( 0 ) == node && IsIndexOperator( parent ) ) + ZoneScopedN( "Call compiler" ); + + std::ostringstream cmd; + cmd << MetalTool( "metal" ) << " -x metal "; + if( forceOldVersion ) { - // m[x][y] -> m[y][x] - auto x = node->GetChild( 1 ); - node->ReplaceChild( 1, parent->GetChild( 1 ) ); - parent->ReplaceChild( 1, x ); + cmd << "-std=macos-metal2.1 -mmacos-version-min=10.14 "; } else { - const auto& matrixType = node->GetChild( 0 )->GetType(); - if( rvalue ) - { - // replace m[x] with matrixRow(m, x) - ScannerToken callToken = ScannerToken::ID( MakeInlineString( "matrixRow" ), node->GetLocation() ); - node->SetToken( &callToken ); - node->SetNodeType( NT_FUNCTION_CALL ); - } - else - { - // replace m[x] with MatrixRow#LH<#>(m, x) - char* name = state.AllocateString( 32 ); -#ifdef _WIN32 - sprintf_s( name, 32, "MatrixRow%dLH<%d>", matrixType.height, matrixType.width ); + cmd << "-std=metal3.0 "; + } + // This switch should probably be done in runtime via a command-line argument to ShaderCompiler. +#if 1 + // Disable shader debug information. + cmd << "-Wno-unused-variable -Wno-missing-braces 2>&1"; #else - snprintf( name, 32, "MatrixRow%dLH<%d>", matrixType.height, matrixType.width ); + // Enable shader debug information. + cmd << "-frecord-sources=yes -gline-tables-only -Wno-unused-variable -Wno-missing-braces 2>&1"; #endif - ScannerToken callToken = ScannerToken::ID( MakeInlineString( name ), node->GetLocation() ); - node->SetToken( &callToken ); - node->SetNodeType( NT_FUNCTION_CALL ); - } + for( auto& it : defines ) + { + cmd << " -D" << it.name << '=' << it.value; } - } - if( node->GetNodeType() == NT_EXPRESSION && node->GetToken() ) - { - switch( node->GetToken()->type ) + cmd << " " << srcFilename << " -o " << binFilename; + // g_messages.AddMessage( "Compile shader: %s", cmd.str().c_str() ); + + auto compilerOutput = RunProcess( cmd.str().c_str() ); + if( !compilerOutput.second.empty() ) { - case OP_EQUAL: - case OP_MUL_ASSIGN: - case OP_DIV_ASSIGN: - case OP_MOD_ASSIGN: - case OP_ADD_ASSIGN: - case OP_SUB_ASSIGN: - case OP_AND_ASSIGN: - case OP_OR_ASSIGN: - case OP_XOR_ASSIGN: - case OP_LEFT_ASSIGN: - case OP_RIGHT_ASSIGN: - PatchMatrixRows( state, node->GetChild( 0 ), node, false, node ); - PatchMatrixRows( state, node->GetChild( 1 ), node, true, node ); - return; + g_messages.AddMessage( "%s", compilerOutput.second.c_str() ); } + if( compilerOutput.first != 0 ) + { + // Shader compilation failed. + break; + } + + // Disabled unused arguments detection because it provides nothing more than noise + // DetectUnusedArguments( binFilename, state, shaderNode ); } - if( node->GetNodeType() != NT_POSTFIX_EXPRESSION ) + + // Read shader binary. { - rvalue = true; + ZoneScopedN( "Read binary" ); + + std::lock_guard withFileMutex( s_fileMutex ); + FILE* file = nullptr; + if( fopen_s( &file, binFilename, "rb" ) != 0 ) + { + // Failed to open compiled shader file. + break; + } + + fseek( file, 0, SEEK_END ); + fpos_t pos = 0; + fgetpos( file, &pos ); + fseek( file, 0, SEEK_SET ); + + size_t dataSize = pos; + compiledCode.resize( dataSize ); + + size_t readBytes = fread( compiledCode.data(), 1, dataSize, file ); + + fclose( file ); + file = nullptr; + + if( readBytes != dataSize ) + { + // Failed to read compiled shader binary from file. + compiledCode.clear(); + break; + } } - for( auto child : node->GetChildren() ) + } while( false ); + + // Remove temp files. + { + std::lock_guard withFileMutex( s_fileMutex ); + remove( srcFilename ); + remove( binFilename ); + } + return compiledCode; +} + +void AssignDeviceSpaceToSymbols( ASTNode* node ) +{ + if( !node ) + { + return; + } + if( auto symbol = node->GetSymbol() ) + { + auto type = symbol->type; + switch( type.builtInType ) { - if( !child ) + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + symbol->addressSpace = AddressSpace::Device; + break; + default: + if( type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) ) { - continue; + symbol->addressSpace = AddressSpace::Device; } - PatchMatrixRows( state, child, node, rvalue, assignment ); - } - } - - std::vector CompileCode( const std::string& code, const std::vector& defines, bool forceOldVersion = true ) - { - std::vector compiledCode; - - // "mktemp" function calls to "arc4random" which is not reentrant. So, we need to sync - // our threads here to avoid parallel execution of this function. - s_fileMutex.lock(); - - #ifdef _WIN32 - char srcFilenameTemplate[] = "mtl_tmpXXXXXXX"; - char binFilenameTemplate[] = "air_tmpXXXXXXX"; - - _mktemp_s( srcFilenameTemplate ); - _mktemp_s( binFilenameTemplate ); - - char* srcFilename = srcFilenameTemplate; - char* binFilename = binFilenameTemplate; - #else - char srcFilenameTemplate[] = "src_XXXXXXX.metal"; - char binFilenameTemplate[] = "bin_XXXXXXX.air"; - - char* srcFilename = nullptr; - char* binFilename = nullptr; - - { - int srcFd = mkstemps( srcFilenameTemplate, 6 ); - int binFd = mkstemps( binFilenameTemplate, 4 ); - - srcFilename = ( srcFd != -1 ) ? srcFilenameTemplate : nullptr; - binFilename = ( binFd != -1 ) ? binFilenameTemplate : nullptr; - - close( srcFd ); - close( binFd ); - } - #endif - s_fileMutex.unlock(); - - if( !srcFilename || !binFilename ) - { - // Failed to generate a name for temporary file(s). - return compiledCode; - } - - do - { - // Write shader source into temp file. - { - ZoneScopedN( "Write Source" ); - - std::lock_guard withFileMutex( s_fileMutex ); - FILE* file = nullptr; - if( fopen_s( &file, srcFilename, "w" ) != 0 ) - { - // Failed to create shader source file. - break; - } - size_t bytesWritten = fwrite( code.c_str(), 1, code.length(), file ); - fclose( file ); - file = nullptr; - - if( bytesWritten != code.length() ) - { - // Failed to write shader source file. - break; - } - } - - // Compile shader. - { - ZoneScopedN( "Call compiler" ); - - std::ostringstream cmd; - cmd << MetalTool( "metal" ) << " -x metal "; - if( forceOldVersion ) - { - cmd << "-std=macos-metal2.1 -mmacos-version-min=10.14 "; - } - else - { - cmd << "-std=metal3.0 "; - } - // This switch should probably be done in runtime via a command-line argument to ShaderCompiler. - #if 1 - // Disable shader debug information. - cmd << "-Wno-unused-variable -Wno-missing-braces 2>&1"; - #else - // Enable shader debug information. - cmd << "-frecord-sources=yes -gline-tables-only -Wno-unused-variable -Wno-missing-braces 2>&1"; - #endif - for( auto& it : defines ) - { - cmd << " -D" << it.name << '=' << it.value; - } - cmd << " " << srcFilename << " -o " << binFilename; - // g_messages.AddMessage( "Compile shader: %s", cmd.str().c_str() ); - - auto compilerOutput = RunProcess( cmd.str().c_str() ); - if( !compilerOutput.second.empty() ) - { - g_messages.AddMessage( "%s", compilerOutput.second.c_str() ); - } - if( compilerOutput.first != 0 ) - { - // Shader compilation failed. - break; - } - - // Disabled unused arguments detection because it provides nothing more than noise - // DetectUnusedArguments( binFilename, state, shaderNode ); - } - - // Read shader binary. - { - ZoneScopedN( "Read binary" ); - - std::lock_guard withFileMutex( s_fileMutex ); - FILE* file = nullptr; - if( fopen_s( &file, binFilename, "rb" ) != 0 ) - { - // Failed to open compiled shader file. - break; - } - - fseek( file, 0, SEEK_END ); - fpos_t pos = 0; - fgetpos( file, &pos ); - fseek( file, 0, SEEK_SET ); - - size_t dataSize = pos; - compiledCode.resize( dataSize ); - - size_t readBytes = fread( compiledCode.data(), 1, dataSize, file ); - - fclose( file ); - file = nullptr; - - if( readBytes != dataSize ) - { - // Failed to read compiled shader binary from file. - compiledCode.clear(); - break; - } - } - } while( false ); - - // Remove temp files. - { - std::lock_guard withFileMutex( s_fileMutex ); - remove( srcFilename ); - remove( binFilename ); - } - return compiledCode; - } - - void AssignDeviceSpaceToSymbols( ASTNode* node ) + break; + } + } + for( auto child : node->GetChildren() ) { - if( !node ) + AssignDeviceSpaceToSymbols( child ); + } +} + +ASTNode* CreateGlobalInputsStruct( ParserState& state, const std::vector& globalInputs ) +{ + state.GetSymbolTable().EnterScope(); + auto globalInputsStruct = NewStruct( state, state.AllocateName( "__RtGlobalInput" ) ); + for( auto& in : globalInputs ) + { + auto existing = state.GetSymbolTable().LookupGlobal( ToString( in.name ).c_str() ); + if( !existing ) { - return; + existing = state.GetSymbolTable().LookupBuffer( in.name ); + } + auto symbol = state.GetSymbolTable().AddSymbol( existing->name ); + if( existing->isTypeName ) + { + symbol->type.FromSymbol( existing ); + symbol->registerSpecifier = existing->registerSpecifier; + } + else + { + symbol->type = existing->type; + } + auto type = symbol->type; + if( type.symbol && + type.symbol->definition && + type.symbol->definition->GetNodeType() == NT_STRUCT ) + { + symbol->type = TypeFromTokenType( OP_STRUCTUREDBUFFER ); + symbol->type.templateParameter = new Type( type ); + symbol->addressSpace = AddressSpace::Constant; } - if( auto symbol = node->GetSymbol() ) + else { - auto type = symbol->type; switch( type.builtInType ) { case OP_BUFFER: @@ -4636,111 +4736,56 @@ namespace case OP_RWSTRUCTUREDBUFFER: case OP_RAYTRACING_ACCELERATION_STRUCTURE: symbol->addressSpace = AddressSpace::Device; + if( type.arrayDimensions ) + { + symbol->resourceRefWrapped = true; + } break; default: if( type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) ) { symbol->addressSpace = AddressSpace::Device; + symbol->resourceRefWrapped = true; } break; } } - for( auto child : node->GetChildren() ) - { - AssignDeviceSpaceToSymbols( child ); - } - } + auto decl = state.NewNode( NT_NAME_DECLARATION ); + decl->SetSymbol( symbol ); + decl->SetType( symbol->type ); - ASTNode* CreateGlobalInputsStruct( ParserState& state, const std::vector& globalInputs ) - { - state.GetSymbolTable().EnterScope(); - auto globalInputsStruct = NewStruct( state, state.AllocateName( "__RtGlobalInput" ) ); - for( auto& in : globalInputs ) + if( !existing->isTypeName ) { - auto existing = state.GetSymbolTable().LookupGlobal( ToString( in.name ).c_str() ); - if( !existing ) - { - existing = state.GetSymbolTable().LookupBuffer( in.name ); - } - auto symbol = state.GetSymbolTable().AddSymbol( existing->name ); - if ( existing->isTypeName ) - { - symbol->type.FromSymbol( existing ); - symbol->registerSpecifier = existing->registerSpecifier; - } - else - { - symbol->type = existing->type; - } - auto type = symbol->type; - if( type.symbol && - type.symbol->definition && - type.symbol->definition->GetNodeType() == NT_STRUCT ) - { - symbol->type = TypeFromTokenType( OP_STRUCTUREDBUFFER ); - symbol->type.templateParameter = new Type( type ); - symbol->addressSpace = AddressSpace::Constant; - } - else - { - switch( type.builtInType ) - { - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - symbol->addressSpace = AddressSpace::Device; - if( type.arrayDimensions ) - { - symbol->resourceRefWrapped = true; - } - break; - default: - if( type.arrayDimensions && ( type.IsTexture() || type.IsSampler() ) ) - { - symbol->addressSpace = AddressSpace::Device; - symbol->resourceRefWrapped = true; - } - break; - } - } - auto decl = state.NewNode( NT_NAME_DECLARATION ); - decl->SetSymbol( symbol ); - decl->SetType( symbol->type ); - - if( !existing->isTypeName ) + if( ASTNode* bracketList = existing->definition->GetChildOrNull( 0 ) ) { - if( ASTNode* bracketList = existing->definition->GetChildOrNull( 0 ) ) - { - decl->AddChild( bracketList->Copy() ); - } + decl->AddChild( bracketList->Copy() ); } - auto member = state.NewNode( NT_STRUCT_MEMBER ); - member->AddChild( decl ); - member->SetType( in.type ); - globalInputsStruct->AddChild( member ); } - state.GetSymbolTable().LeaveScope(); - bool inserted = false; - for( size_t i = 0; i < state.GetTree()->GetChildrenCount(); ++i ) + auto member = state.NewNode( NT_STRUCT_MEMBER ); + member->AddChild( decl ); + member->SetType( in.type ); + globalInputsStruct->AddChild( member ); + } + state.GetSymbolTable().LeaveScope(); + bool inserted = false; + for( size_t i = 0; i < state.GetTree()->GetChildrenCount(); ++i ) + { + if( auto child = state.GetTree()->GetChild( i ) ) { - if( auto child = state.GetTree()->GetChild( i ) ) + if( child->GetNodeType() != NT_STRUCT ) { - if( child->GetNodeType() != NT_STRUCT ) - { - state.GetTree()->InsertChild( i, globalInputsStruct ); - inserted = true; - break; - } + state.GetTree()->InsertChild( i, globalInputsStruct ); + inserted = true; + break; } } - if( !inserted ) - { - state.GetTree()->AddChild( globalInputsStruct ); - } - return globalInputsStruct; } + if( !inserted ) + { + state.GetTree()->AddChild( globalInputsStruct ); + } + return globalInputsStruct; +} } const char* MetalSystemSemanticsType::GetString( int type ) @@ -4770,13 +4815,13 @@ const char* MetalSystemSemanticsType::GetString( int type ) "thread_index_in_threadgroup", "threadgroup_position_in_grid", "sample_id", - "threads_per_grid", - "payload", - "barycentric_coord", - "origin", - "direction", - "min_distance", - "distance", + "threads_per_grid", + "payload", + "barycentric_coord", + "origin", + "direction", + "min_distance", + "distance", "instance_intersection_function_table_offset", "object_to_world_transform", "world_to_object_transform", @@ -4787,7 +4832,7 @@ const char* MetalSystemSemanticsType::GetString( int type ) const int typeCount = sizeof( strings ) / sizeof( strings[0] ); if( 0 <= type && type < typeCount ) { - return strings[ type ]; + return strings[type]; } return "!!invalid_system_semantic!!"; @@ -4874,10 +4919,7 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength YamlListing listing; listing.dict(); - listing.literal( "permutation" ).dict() - .literal( "platform" ).literal( "Metal" ) - .literal( "id" ).literal( "000" ) - .literal( "defines" ).dict(); + listing.literal( "permutation" ).dict().literal( "platform" ).literal( "Metal" ).literal( "id" ).literal( "000" ).literal( "defines" ).dict(); for( auto it = begin( defines ); it != end( defines ); ++it ) { listing.literal( it->name ).literal( it->value ); @@ -4900,54 +4942,54 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength for( size_t passIx = 0; passIx < techniqueNode->GetChildrenCount(); ++passIx ) { ASTNode* passNode = techniqueNode->GetChild( passIx ); - if( passNode->GetNodeType() != NT_PASS ) - { - continue; - } - listing.list(); - Pass outPass; + if( passNode->GetNodeType() != NT_PASS ) + { + continue; + } + listing.list(); + Pass outPass; for( size_t stateIx = 0; stateIx < passNode->GetChildrenCount(); ++stateIx ) { if( passNode->GetChild( stateIx )->GetNodeType() == NT_STATE_ASSIGNMENT ) { - unsigned stateCode = 0; - unsigned value = 0; - if( ParseStateAssignment( state, passNode->GetChild( stateIx ), g_renderStates, &value ) ) + unsigned stateCode = 0; + unsigned value = 0; + if( ParseStateAssignment( state, passNode->GetChild( stateIx ), g_renderStates, &value ) ) + { + std::string name = ToString( passNode->GetChild( stateIx )->GetToken()->stringValue ); + for( int i = 0; g_renderStateNames[i].name; ++i ) { - std::string name = ToString( passNode->GetChild( stateIx )->GetToken()->stringValue ); - for( int i = 0; g_renderStateNames[i].name; ++i ) + if( _stricmp( name.c_str(), g_renderStateNames[i].name ) == 0 ) { - if( _stricmp( name.c_str(), g_renderStateNames[i].name ) == 0 ) - { - stateCode = g_renderStateNames[i].value; - } + stateCode = g_renderStateNames[i].value; } - switch( stateCode ) + } + switch( stateCode ) + { + case unsigned( -1 ): + case unsigned( -2 ): + case unsigned( -3 ): + case unsigned( -4 ): + case unsigned( -5 ): + case unsigned( -6 ): + if( value != 0 ) { - case unsigned( -1 ): - case unsigned( -2 ): - case unsigned( -3 ): - case unsigned( -4 ): - case unsigned( -5 ): - case unsigned( -6 ): - if( value != 0 ) - { - state.ShowMessage( passNode->GetChild( stateIx )->GetLocation(), EC_INVALID_STATE_VALUE, name.c_str() ); - } - break; - case 0: - state.ShowMessage( passNode->GetChild( stateIx )->GetLocation(), EC_STATE_DEPRECATED, name.c_str() ); - break; - default: - outPass.states[stateCode] = value; + state.ShowMessage( passNode->GetChild( stateIx )->GetLocation(), EC_INVALID_STATE_VALUE, name.c_str() ); } + break; + case 0: + state.ShowMessage( passNode->GetChild( stateIx )->GetLocation(), EC_STATE_DEPRECATED, name.c_str() ); + break; + default: + outPass.states[stateCode] = value; } - continue; + } + continue; } if( passNode->GetChild( stateIx )->GetNodeType() != NT_SHADER_ASSIGNMENT ) { - continue; + continue; } ASTNode* shaderNode = passNode->GetChild( stateIx ); @@ -4955,15 +4997,15 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength StageInput stage; if( !ParseShaderName( shaderNode->GetToken()->stringValue, stage.type ) ) { - state.ShowMessage( shaderNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( shaderNode->GetToken()->stringValue ).c_str() ); - return false; + state.ShowMessage( shaderNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( shaderNode->GetToken()->stringValue ).c_str() ); + return false; } std::string profile = ToString( shaderNode->GetChild( 0 )->GetToken()->stringValue ); if( shaderNode->GetChild( 1 )->GetSymbol() == nullptr ) { - return false; + return false; } // This must be called before PatchShader, because patching doesn't preserve @@ -4974,35 +5016,35 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength std::string shaderCacheKey; { - state.GetSymbolTable().ResetUsedFlag(); - MarkUsedSymbols( shaderNode->GetChild( 1 ), state ); + state.GetSymbolTable().ResetUsedFlag(); + MarkUsedSymbols( shaderNode->GetChild( 1 ), state ); - CompilerInputStream os( state, ShadingLanguage::MSL ); - os << MSL{ state.GetTree(), &state.GetSymbolTable() }; - shaderCacheKey = os.str(); - state.GetSymbolTable().ResetUsedFlag(); + CompilerInputStream os( state, ShadingLanguage::MSL ); + os << MSL{ state.GetTree(), &state.GetSymbolTable() }; + shaderCacheKey = os.str(); + state.GetSymbolTable().ResetUsedFlag(); + } + PatchShaderType patchShaderType; + switch( stage.type ) + { + case VERTEX_STAGE: + patchShaderType = PatchShaderType::VERTEX; + break; + case PIXEL_STAGE: + patchShaderType = PatchShaderType::PIXEL; + break; + case COMPUTE_STAGE: + patchShaderType = PatchShaderType::COMPUTE; + break; + default: + state.ShowMessage( shaderNode->GetLocation(), EC_CUSTOM_ERROR, "Shader type %i is not supported by Metal", int( stage.type ) ); + return false; } - PatchShaderType patchShaderType; - switch ( stage.type ) - { - case VERTEX_STAGE: - patchShaderType = PatchShaderType::VERTEX; - break; - case PIXEL_STAGE: - patchShaderType = PatchShaderType::PIXEL; - break; - case COMPUTE_STAGE: - patchShaderType = PatchShaderType::COMPUTE; - break; - default: - state.ShowMessage( shaderNode->GetLocation(), EC_CUSTOM_ERROR, "Shader type %i is not supported by Metal", int( stage.type ) ); - return false; - } auto patchedShader = PatchShader( patchShaderType, shaderNode->GetChild( 1 ), state ); if( !patchedShader ) { - return false; + return false; } shaderNode->GetChild( 1 )->SetSymbol( patchedShader->GetChild( 0 )->GetSymbol() ); @@ -5011,28 +5053,28 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength switch( stage.type ) { case VERTEX_STAGE: - PrepareVertexFunction( stage, shaderNode->GetChild( 1 ) ); - break; + PrepareVertexFunction( stage, shaderNode->GetChild( 1 ) ); + break; case PIXEL_STAGE: - PrepareFragmentFunction( stage, shaderNode->GetChild( 1 ) ); - break; + PrepareFragmentFunction( stage, shaderNode->GetChild( 1 ) ); + break; case COMPUTE_STAGE: - PrepareKernelFunction( stage, shaderNode->GetChild( 1 ) ); - break; + PrepareKernelFunction( stage, shaderNode->GetChild( 1 ) ); + break; default: - assert( false && "Not supported." ); - break; + assert( false && "Not supported." ); + break; } // Assign register numbers to all input textures, buffers, and samplers if they // don't have any register assigned already. if( !AutoAssignRegisters( state, shaderNode->GetChild( 1 ) ) ) { - return false; + return false; } state.GetSymbolTable().ResetUsedFlag(); - state.ResetPragmaUsage(); + state.ResetPragmaUsage(); MarkUsedSymbols( shaderNode->GetChild( 1 ), state ); CompilerInputStream os( state, ShadingLanguage::MSL ); @@ -5112,7 +5154,7 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength stage.shaderSize = uint32_t( compiledCode.size() ); stage.shaderDataStr = g_stringTable.AddString( compiledCode.data(), compiledCode.size() ); - + if( !GetStageData( state, stage, shaderNode->GetChild( 1 ), result.annotations ) ) { @@ -5147,10 +5189,14 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength stage.source = os.str(); listing.dict() - .literal( "profile" ).literal( profile ) - .literal( "original" ).dict() - .literal( "entryPoint" ).literal( ToString( shaderNode->GetChild( 1 )->GetSymbol()->name ) ) - .literal( "source" ).literal( SanitizeCode( os.str() ) ); + .literal( "profile" ) + .literal( profile ) + .literal( "original" ) + .dict() + .literal( "entryPoint" ) + .literal( ToString( shaderNode->GetChild( 1 )->GetSymbol()->name ) ) + .literal( "source" ) + .literal( SanitizeCode( os.str() ) ); // TODO // PrintShaderOutListing( listing, effectData, reflection ); listing.end(); @@ -5173,55 +5219,57 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength listing.end(); // stages list } - listing.end(); // pases list - - listing.literal( "libraries" ).list(); - - for( size_t passIx = 0; passIx < techniqueNode->GetChildrenCount(); ++passIx ) - { - ASTNode* libNode = techniqueNode->GetChild( passIx ); - if( libNode->GetNodeType() != NT_LIBRARY ) - { - continue; - } - listing.dict() - .literal( "name" ).literal( libNode->GetToken()->stringValue ) - .literal( "exports" ).list(); - - Library library; - library.payloadSize = 0; - library.hitGroupName = g_stringTable.AddString( "" ); - library.globalInputs.defaultValuesStr = INVALID_REFERENCE; - library.localInputs.defaultValuesStr = INVALID_REFERENCE; - - std::map shaders; + listing.end(); // pases list + + listing.literal( "libraries" ).list(); + + for( size_t passIx = 0; passIx < techniqueNode->GetChildrenCount(); ++passIx ) + { + ASTNode* libNode = techniqueNode->GetChild( passIx ); + if( libNode->GetNodeType() != NT_LIBRARY ) + { + continue; + } + listing.dict() + .literal( "name" ) + .literal( libNode->GetToken()->stringValue ) + .literal( "exports" ) + .list(); + + Library library; + library.payloadSize = 0; + library.hitGroupName = g_stringTable.AddString( "" ); + library.globalInputs.defaultValuesStr = INVALID_REFERENCE; + library.localInputs.defaultValuesStr = INVALID_REFERENCE; + + std::map shaders; std::vector globalInputs; ASTNode* globalInputsStruct = nullptr; - state.GetSymbolTable().ResetUsedFlag(); - - for( size_t i = 0; i < libNode->GetChildrenCount(); ++i ) - { - auto childNode = libNode->GetChild( i ); - if( childNode->GetNodeType() == NT_SHADER_ASSIGNMENT ) - { - ShaderExport shaderExport; - if( auto parsed = ParseRtShaderName( childNode->GetToken()->stringValue ) ) - { - shaderExport.type = parsed.value(); - } - else - { - state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( childNode->GetToken()->stringValue ).c_str() ); - return false; - } - listing.literal( childNode->GetChild( 1 )->GetSymbol()->name ); - - if( shaderExport.type == RtShaderType ::INTERSECTION ) + state.GetSymbolTable().ResetUsedFlag(); + + for( size_t i = 0; i < libNode->GetChildrenCount(); ++i ) + { + auto childNode = libNode->GetChild( i ); + if( childNode->GetNodeType() == NT_SHADER_ASSIGNMENT ) + { + ShaderExport shaderExport; + if( auto parsed = ParseRtShaderName( childNode->GetToken()->stringValue ) ) + { + shaderExport.type = parsed.value(); + } + else + { + state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( childNode->GetToken()->stringValue ).c_str() ); + return false; + } + listing.literal( childNode->GetChild( 1 )->GetSymbol()->name ); + + if( shaderExport.type == RtShaderType ::INTERSECTION ) { - state.ShowMessage( childNode->GetLocation(), EC_CUSTOM_ERROR, "Shader type %i is not supported by Metal", int( shaderExport.type.operator RtShaderType() ) ); - return false; - } + state.ShowMessage( childNode->GetLocation(), EC_CUSTOM_ERROR, "Shader type %i is not supported by Metal", int( shaderExport.type.operator RtShaderType() ) ); + return false; + } if( !ProcessGlobalInputAttribute( state, childNode->GetChild( 1 )->GetSymbol()->definition, globalInputs ) ) { @@ -5232,81 +5280,81 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength globalInputsStruct = CreateGlobalInputsStruct( state, globalInputs ); } - std::vector rtConstantBuffers; - ASTNode* shader = PatchRtShader( shaderExport.type, childNode->GetChild( 1 ), state, rtConstantBuffers, globalInputs, globalInputsStruct ); - - childNode->GetChild( 1 )->SetSymbol( shader->GetChild( 0 )->GetSymbol() ); + std::vector rtConstantBuffers; + ASTNode* shader = PatchRtShader( shaderExport.type, childNode->GetChild( 1 ), state, rtConstantBuffers, globalInputs, globalInputsStruct ); + + childNode->GetChild( 1 )->SetSymbol( shader->GetChild( 0 )->GetSymbol() ); - MarkUsedSymbols( shader, state ); - for ( auto& gi : globalInputs ) + MarkUsedSymbols( shader, state ); + for( auto& gi : globalInputs ) { MarkUsedSymbols( gi.declaration, state ); } - if( !GetStageData( state, library.localInputs, rtConstantBuffers, result.annotations ) ) - { - return false; - } + if( !GetStageData( state, library.localInputs, rtConstantBuffers, result.annotations ) ) + { + return false; + } if( !library.globalInputs.defaultValues.empty() ) - { - library.globalInputs.defaultValuesStr = g_stringTable.AddString( &library.globalInputs.defaultValues[0], library.globalInputs.defaultValues.size() ); - } - if( !library.localInputs.defaultValues.empty() ) - { - library.localInputs.defaultValuesStr = g_stringTable.AddString( &library.localInputs.defaultValues[0], library.localInputs.defaultValues.size() ); - } - - shaderExport.name = g_stringTable.AddString( ToString( childNode->GetChild( 1 )->GetSymbol()->name ).c_str() ); - library.exports.push_back( shaderExport ); - } - else if( childNode->GetNodeType() == NT_STATE_ASSIGNMENT ) - { - auto name = childNode->GetToken()->stringValue; - if( EqualsCaseInsensitive( name, "payloadsize" ) ) - { - Type type; - type.FromTokenType( OP_UINT ); - ExpressionValue value; - if( !EvaluateExpression( state, childNode->GetChildOrNull( 0 ), type, value, nullptr ) ) - { - state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( name ).c_str() ); - return false; - } - library.payloadSize = uint32_t( value[0].intValue ); - } - else if( EqualsCaseInsensitive( name, "hitgroupname" ) ) - { - Type type; - type.FromTokenType( OP_STRING ); - ExpressionValue value; - if( !EvaluateExpression( state, childNode->GetChildOrNull( 0 ), type, value, nullptr ) ) - { - state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( name ).c_str() ); - return false; - } - library.hitGroupName = g_stringTable.AddString( value[0].stringValue.c_str() ); - } - } - } - listing.end(); // exports list + { + library.globalInputs.defaultValuesStr = g_stringTable.AddString( &library.globalInputs.defaultValues[0], library.globalInputs.defaultValues.size() ); + } + if( !library.localInputs.defaultValues.empty() ) + { + library.localInputs.defaultValuesStr = g_stringTable.AddString( &library.localInputs.defaultValues[0], library.localInputs.defaultValues.size() ); + } + + shaderExport.name = g_stringTable.AddString( ToString( childNode->GetChild( 1 )->GetSymbol()->name ).c_str() ); + library.exports.push_back( shaderExport ); + } + else if( childNode->GetNodeType() == NT_STATE_ASSIGNMENT ) + { + auto name = childNode->GetToken()->stringValue; + if( EqualsCaseInsensitive( name, "payloadsize" ) ) + { + Type type; + type.FromTokenType( OP_UINT ); + ExpressionValue value; + if( !EvaluateExpression( state, childNode->GetChildOrNull( 0 ), type, value, nullptr ) ) + { + state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( name ).c_str() ); + return false; + } + library.payloadSize = uint32_t( value[0].intValue ); + } + else if( EqualsCaseInsensitive( name, "hitgroupname" ) ) + { + Type type; + type.FromTokenType( OP_STRING ); + ExpressionValue value; + if( !EvaluateExpression( state, childNode->GetChildOrNull( 0 ), type, value, nullptr ) ) + { + state.ShowMessage( childNode->GetToken()->fileLocation, EC_INVALID_STATE, ToString( name ).c_str() ); + return false; + } + library.hitGroupName = g_stringTable.AddString( value[0].stringValue.c_str() ); + } + } + } + listing.end(); // exports list if( !GetGlobalInputData( state, library.globalInputs, globalInputs, globalInputsStruct, result.annotations ) ) { return false; } - - CompilerInputStream os( state, ShadingLanguage::MSL ); - os << MSL_INCLUDE; - os << AtomicFn{ "add", "Add" }; - os << AtomicFn{ "max", "Max" }; - os << AtomicFn{ "min", "Min" }; - os << AtomicFn{ "and", "And" }; - os << AtomicFn{ "or", "Or" }; - os << AtomicFn{ "xor", "Xor" }; - - os << MSL{ state.GetTree(), &state.GetSymbolTable() }; - //printf( "%s\n", SanitizeCode( os.str() ).c_str() ); + + CompilerInputStream os( state, ShadingLanguage::MSL ); + os << MSL_INCLUDE; + os << AtomicFn{ "add", "Add" }; + os << AtomicFn{ "max", "Max" }; + os << AtomicFn{ "min", "Min" }; + os << AtomicFn{ "and", "And" }; + os << AtomicFn{ "or", "Or" }; + os << AtomicFn{ "xor", "Xor" }; + + os << MSL{ state.GetTree(), &state.GetSymbolTable() }; + //printf( "%s\n", SanitizeCode( os.str() ).c_str() ); library.source = os.str(); @@ -5379,20 +5427,19 @@ bool EffectCompilerMetal::CompileEffect( const char* source, size_t sourceLength library.shaderDataStr = g_stringTable.AddString( compiledCode.data(), compiledCode.size() ); - technique.libraries.push_back( library ); + technique.libraries.push_back( library ); - if( listing.enabled() ) - { - listing.literal( "profile" ).literal( "lib" ); - listing.literal( "original" ).dict(); - listing.literal( "source" ).literal( SanitizeCode( os.str() ) ); - listing.end(); - PrintStageInfo( listing, library.globalInputs, result ); - } - listing.end(); - - } - listing.end(); // libraries list + if( listing.enabled() ) + { + listing.literal( "profile" ).literal( "lib" ); + listing.literal( "original" ).dict(); + listing.literal( "source" ).literal( SanitizeCode( os.str() ) ); + listing.end(); + PrintStageInfo( listing, library.globalInputs, result ); + } + listing.end(); + } + listing.end(); // libraries list result.techniques.push_back( technique ); listing.end(); // technique dict diff --git a/shadercompiler/EffectCompilerMetal.h b/shadercompiler/EffectCompilerMetal.h index 5cc2879cc..a046a4f76 100644 --- a/shadercompiler/EffectCompilerMetal.h +++ b/shadercompiler/EffectCompilerMetal.h @@ -51,14 +51,14 @@ struct MetalSystemSemanticsType thread_index_in_threadgroup, threadgroup_position_in_grid, sample_id, - threads_per_grid, - - payload, - barycentric_coord, - origin, - direction, - min_distance, - distance, + threads_per_grid, + + payload, + barycentric_coord, + origin, + direction, + min_distance, + distance, instance_intersection_function_table_offset, object_to_world_transform, world_to_object_transform, @@ -72,7 +72,7 @@ struct MetalSystemSemanticsType static const char* GetString( int type ); }; -class EffectCompilerMetal: public EffectCompilerBase +class EffectCompilerMetal : public EffectCompilerBase { public: bool Create() override; diff --git a/shadercompiler/EffectData.cpp b/shadercompiler/EffectData.cpp index f7f579bce..97cb2984e 100644 --- a/shadercompiler/EffectData.cpp +++ b/shadercompiler/EffectData.cpp @@ -17,7 +17,7 @@ const char* GetStringForUsageCode( int usageCode ) }; assert( 0 <= usageCode && usageCode < int( sizeof( str ) / sizeof( *str ) ) ); - return str[ usageCode ]; + return str[usageCode]; } const char* ToString( ConstantType constType ) diff --git a/shadercompiler/EffectData.h b/shadercompiler/EffectData.h index 479383431..4ac453195 100644 --- a/shadercompiler/EffectData.h +++ b/shadercompiler/EffectData.h @@ -42,12 +42,12 @@ enum AnnotationType enum TextureType { - TEX_TYPE_1D = 1, + TEX_TYPE_1D = 1, TEX_TYPE_2D, TEX_TYPE_3D, TEX_TYPE_CUBE, - TEX_TYPE_TYPELESS, // valid but unknown dimensions + TEX_TYPE_TYPELESS, // valid but unknown dimensions // buffers TEX_TYPE_BUFFER, @@ -130,8 +130,8 @@ class PackAs public: PackAs() = default; - PackAs( T v ) - :t( v ) + PackAs( T v ) : + t( v ) { } @@ -139,7 +139,7 @@ class PackAs { return t; } - operator T&( ) + operator T&() { return t; } @@ -152,6 +152,7 @@ class PackAs { return static_cast

( t ); } + private: T t; }; @@ -162,8 +163,8 @@ class PackAs class PackedStream { public: - explicit PackedStream( void* data, size_t size ) - :m_size( size ) + explicit PackedStream( void* data, size_t size ) : + m_size( size ) { m_data = static_cast( data ); m_start = m_data; @@ -221,6 +222,7 @@ class PackedStream *reinterpret_cast( m_data ) = value.Packed(); m_data += sizeof( P ); } + private: uint8_t* m_data; void* m_start; @@ -231,8 +233,8 @@ class PackedStream class SizeCountStream { public: - SizeCountStream() - :m_size( 0 ) + SizeCountStream() : + m_size( 0 ) { } @@ -270,6 +272,7 @@ class SizeCountStream { m_size += sizeof( P ); } + private: size_t m_size; }; @@ -292,7 +295,7 @@ struct Constant bool operator==( const Constant& other ) const { - return name == other.name && offset == other.offset && size == other.size && type == other.type && + return name == other.name && offset == other.offset && size == other.size && type == other.type && dimension == other.dimension && elements == other.elements && isSRGB == other.isSRGB && isAutoregister == other.isAutoregister; } @@ -388,8 +391,7 @@ struct Sampler bool operator==( const Sampler& sampler ) const { - return - comparison == sampler.comparison && + return comparison == sampler.comparison && minFilter == sampler.minFilter && magFilter == sampler.magFilter && mipFilter == sampler.mipFilter && @@ -410,7 +412,11 @@ struct Sampler bool operator<( const Sampler& sampler ) const { -#define COMPARE( field ) if( field < sampler.field ) return true; if( field > sampler.field ) return false; +#define COMPARE( field ) \ + if( field < sampler.field ) \ + return true; \ + if( field > sampler.field ) \ + return false; COMPARE( comparison ); COMPARE( minFilter ); COMPARE( magFilter ); @@ -609,7 +615,7 @@ struct ParameterAnnotation return strcmp( g_stringTable.GetString( a ), g_stringTable.GetString( b ) ) < 0; } ); - for (auto key : keys) + for( auto key : keys ) { stream.Save( key ); annotations[key].Save( stream ); @@ -708,7 +714,6 @@ struct StageInput : public StageData uint32_t threadGroupSize[3]; std::vector pipelineInputs; std::string source; // not persisted: for testing/debugging only - }; typedef std::map RenderStates; @@ -807,7 +812,7 @@ struct PDB { std::string name; #if _WIN32 - CComPtr pdbBlob; // this is for dx11/dx12. metal will require another field. + CComPtr pdbBlob; // this is for dx11/dx12. metal will require another field. #endif }; diff --git a/shadercompiler/FXAnalyzer.cpp b/shadercompiler/FXAnalyzer.cpp index b643f1f1d..94bcc9bbe 100644 --- a/shadercompiler/FXAnalyzer.cpp +++ b/shadercompiler/FXAnalyzer.cpp @@ -147,8 +147,8 @@ enum D3DRENDERSTATETYPE #define DEFINE_VALUE( prefix, value ) { #value, prefix##_##value } #define DEFINE_VALUE1( value, name ) \ - { \ -#name, value \ + { \ + #name, value \ } static StateValue s_addressValues[] = { @@ -157,14 +157,14 @@ static StateValue s_addressValues[] = { DEFINE_VALUE( D3D11_TEXTURE_ADDRESS, CLAMP ), DEFINE_VALUE( D3D11_TEXTURE_ADDRESS, BORDER ), DEFINE_VALUE1( D3D11_TEXTURE_ADDRESS_MIRROR_ONCE, MIRRORONCE ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_filterValues[] = { DEFINE_VALUE( D3DTEXF, NONE ), DEFINE_VALUE( D3DTEXF, POINT ), DEFINE_VALUE( D3DTEXF, LINEAR ), DEFINE_VALUE( D3DTEXF, ANISOTROPIC ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_filter11Values[] = { DEFINE_VALUE( D3D11_FILTER, MIN_MAG_MIP_POINT ), @@ -185,7 +185,7 @@ static StateValue s_filter11Values[] = { DEFINE_VALUE( D3D11_FILTER, COMPARISON_MIN_MAG_LINEAR_MIP_POINT ), DEFINE_VALUE( D3D11_FILTER, COMPARISON_MIN_MAG_MIP_LINEAR ), DEFINE_VALUE( D3D11_FILTER, COMPARISON_ANISOTROPIC ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_comparisonValues[] = { DEFINE_VALUE( D3D11_COMPARISON, NEVER ), @@ -193,14 +193,14 @@ static StateValue s_comparisonValues[] = { DEFINE_VALUE( D3D11_COMPARISON, EQUAL ), DEFINE_VALUE( D3D11_COMPARISON, LESS_EQUAL ), DEFINE_VALUE( D3D11_COMPARISON, GREATER ), - DEFINE_VALUE( D3D11_COMPARISON, NOT_EQUAL ), + DEFINE_VALUE( D3D11_COMPARISON, NOT_EQUAL ), DEFINE_VALUE( D3D11_COMPARISON, GREATER_EQUAL ), DEFINE_VALUE( D3D11_COMPARISON, ALWAYS ), DEFINE_VALUE1( D3D11_COMPARISON_LESS_EQUAL, LESSEQUAL ), DEFINE_VALUE1( D3D11_COMPARISON_NOT_EQUAL, NOTEQUAL ), DEFINE_VALUE1( D3D11_COMPARISON_GREATER_EQUAL, GREATEREQUAL ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_blendValues[] = { DEFINE_VALUE1( D3D11_BLEND_ZERO, ZERO ), @@ -219,7 +219,7 @@ static StateValue s_blendValues[] = { DEFINE_VALUE1( D3D11_BLEND_INV_BLEND_FACTOR, INVBLENDFACTOR ), DEFINE_VALUE1( D3D11_BLEND_SRC1_COLOR, SRCCOLOR2 ), DEFINE_VALUE1( D3D11_BLEND_INV_SRC1_COLOR, INVSRCCOLOR2 ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_blendOpValues[] = { DEFINE_VALUE1( D3D11_BLEND_OP_ADD, ADD ), @@ -227,19 +227,19 @@ static StateValue s_blendOpValues[] = { DEFINE_VALUE1( D3D11_BLEND_OP_REV_SUBTRACT, REVSUBTRACT ), DEFINE_VALUE1( D3D11_BLEND_OP_MIN, MIN ), DEFINE_VALUE1( D3D11_BLEND_OP_MAX, MAX ), - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_fillModeValues[] = { DEFINE_VALUE( D3D11_FILL, WIREFRAME ), DEFINE_VALUE( D3D11_FILL, SOLID ), - { nullptr, 0 }, + { nullptr, 0 }, }; // This was an elegant way to convert effects from LH to RH static StateValue s_cullModeValues[] = { DEFINE_VALUE( D3DCULL, NONE ), { "CW", D3DCULL_CCW }, { "CCW", D3DCULL_CW }, - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_colorWriteValues[] = { DEFINE_VALUE( D3DCOLORWRITEENABLE, RED ), @@ -248,18 +248,18 @@ static StateValue s_colorWriteValues[] = { DEFINE_VALUE( D3DCOLORWRITEENABLE, ALPHA ), { "false", 0 }, { "true", 0xf }, - { nullptr, 0 }, + { nullptr, 0 }, }; static StateValue s_boolValues[] = { - { "true", 1 }, - { "false", 0 }, - { nullptr, 0 }, + { "true", 1 }, + { "false", 0 }, + { nullptr, 0 }, }; static StateValue s_shaderValues[] = { - { "NULL", 0 }, - { nullptr, 0 }, + { "NULL", 0 }, + { nullptr, 0 }, }; StateValue g_renderStateNames[] = { @@ -292,70 +292,69 @@ StateValue g_renderStateNames[] = { { "geometryshader", 0xffffffff - 4 }, { "hullshader", 0xffffffff - 5 }, { "domainshader", 0xffffffff - 6 }, - { nullptr, 0 }, + { nullptr, 0 }, }; StateDescription g_samplerStates[] = { - { "AddressU", SVT_BYTE, s_addressValues, offsetof( Sampler, addressU ) }, - { "AddressV", SVT_BYTE, s_addressValues, offsetof( Sampler, addressV ) }, - { "AddressW", SVT_BYTE, s_addressValues, offsetof( Sampler, addressW ) }, - { "BorderColor", SVT_COLOR, nullptr, offsetof( Sampler, borderColor ) }, - { "MagFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, magFilter ) }, - { "MinFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, minFilter ) }, - { "MipFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, mipFilter ) }, - { "Filter", SVT_BYTE, s_filter11Values, offsetof( Sampler, filter ) }, - { "MaxAnisotropy", SVT_BYTE, nullptr, offsetof( Sampler, maxAnisotropy ) }, - { "MaxMipLevel", SVT_FLOAT, nullptr, offsetof( Sampler, minLOD ) }, - { "MinLOD", SVT_FLOAT, nullptr, offsetof( Sampler, minLOD ) }, - { "MaxLOD", SVT_FLOAT, nullptr, offsetof( Sampler, maxLOD ) }, - { "MipMapLodBias", SVT_FLOAT, nullptr, offsetof( Sampler, mipLODBias ) }, - { "ComparisonFunc", SVT_BYTE, s_comparisonValues, offsetof( Sampler, comparisonFunc ) }, - { "SRGBTexture", SVT_BOOL, s_boolValues, offsetof( Sampler, srgbTexture ) }, - { "IsDynamic", SVT_BOOL, s_boolValues, offsetof( Sampler, isDynamic ) }, - { nullptr, SVT_BOOL, nullptr, 0 }, + { "AddressU", SVT_BYTE, s_addressValues, offsetof( Sampler, addressU ) }, + { "AddressV", SVT_BYTE, s_addressValues, offsetof( Sampler, addressV ) }, + { "AddressW", SVT_BYTE, s_addressValues, offsetof( Sampler, addressW ) }, + { "BorderColor", SVT_COLOR, nullptr, offsetof( Sampler, borderColor ) }, + { "MagFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, magFilter ) }, + { "MinFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, minFilter ) }, + { "MipFilter", SVT_BYTE, s_filterValues, offsetof( Sampler, mipFilter ) }, + { "Filter", SVT_BYTE, s_filter11Values, offsetof( Sampler, filter ) }, + { "MaxAnisotropy", SVT_BYTE, nullptr, offsetof( Sampler, maxAnisotropy ) }, + { "MaxMipLevel", SVT_FLOAT, nullptr, offsetof( Sampler, minLOD ) }, + { "MinLOD", SVT_FLOAT, nullptr, offsetof( Sampler, minLOD ) }, + { "MaxLOD", SVT_FLOAT, nullptr, offsetof( Sampler, maxLOD ) }, + { "MipMapLodBias", SVT_FLOAT, nullptr, offsetof( Sampler, mipLODBias ) }, + { "ComparisonFunc", SVT_BYTE, s_comparisonValues, offsetof( Sampler, comparisonFunc ) }, + { "SRGBTexture", SVT_BOOL, s_boolValues, offsetof( Sampler, srgbTexture ) }, + { "IsDynamic", SVT_BOOL, s_boolValues, offsetof( Sampler, isDynamic ) }, + { nullptr, SVT_BOOL, nullptr, 0 }, }; StateDescription g_renderStates[] = { - { "AlphaTestEnable", SVT_BOOL, s_boolValues, 0 }, - { "SrcBlend", SVT_DWORD, s_blendValues, 0 }, - { "DestBlend", SVT_DWORD, s_blendValues, 0 }, - { "AlphaRef", SVT_DWORD, nullptr, 0 }, - { "AlphaFunc", SVT_DWORD, s_comparisonValues, 0 }, - { "AlphaBlendEnable", SVT_BOOL, s_boolValues, 0 }, - { "BlendOp", SVT_DWORD, s_blendOpValues, 0 }, - { "ZEnable", SVT_BOOL, s_boolValues, 0 }, - { "ZWriteEnable", SVT_BOOL, s_boolValues, 0 }, - { "ZFunc", SVT_DWORD, s_comparisonValues, 0 }, - { "FillMode", SVT_DWORD, s_fillModeValues, 0 }, - { "ColorWriteEnable", SVT_DWORD, s_colorWriteValues, 0 }, - { "DepthBias", SVT_FLOAT, nullptr, 0 }, - { "SlopeScaleDepthBias", SVT_FLOAT, nullptr, 0 }, - { "SRGBWriteEnable", SVT_BOOL, s_boolValues, 0 }, - { "SeparateAlphaBlendEnable", SVT_BOOL, s_boolValues, 0 }, - { "BlendOpAlpha", SVT_DWORD, s_blendOpValues, 0 }, - { "SrcBlendAlpha", SVT_DWORD, s_blendValues, 0 }, - { "DestBlendAlpha", SVT_DWORD, s_blendValues, 0 }, - { "ColorWriteEnable1", SVT_BOOL, s_boolValues, 0 }, - { "ColorWriteEnable2", SVT_BOOL, s_boolValues, 0 }, - { "ColorWriteEnable3", SVT_BOOL, s_boolValues, 0 }, - { "CullMode", SVT_DWORD, s_cullModeValues, 0 }, - { "LocalViewer", SVT_BOOL, s_boolValues, 0 }, + { "AlphaTestEnable", SVT_BOOL, s_boolValues, 0 }, + { "SrcBlend", SVT_DWORD, s_blendValues, 0 }, + { "DestBlend", SVT_DWORD, s_blendValues, 0 }, + { "AlphaRef", SVT_DWORD, nullptr, 0 }, + { "AlphaFunc", SVT_DWORD, s_comparisonValues, 0 }, + { "AlphaBlendEnable", SVT_BOOL, s_boolValues, 0 }, + { "BlendOp", SVT_DWORD, s_blendOpValues, 0 }, + { "ZEnable", SVT_BOOL, s_boolValues, 0 }, + { "ZWriteEnable", SVT_BOOL, s_boolValues, 0 }, + { "ZFunc", SVT_DWORD, s_comparisonValues, 0 }, + { "FillMode", SVT_DWORD, s_fillModeValues, 0 }, + { "ColorWriteEnable", SVT_DWORD, s_colorWriteValues, 0 }, + { "DepthBias", SVT_FLOAT, nullptr, 0 }, + { "SlopeScaleDepthBias", SVT_FLOAT, nullptr, 0 }, + { "SRGBWriteEnable", SVT_BOOL, s_boolValues, 0 }, + { "SeparateAlphaBlendEnable", SVT_BOOL, s_boolValues, 0 }, + { "BlendOpAlpha", SVT_DWORD, s_blendOpValues, 0 }, + { "SrcBlendAlpha", SVT_DWORD, s_blendValues, 0 }, + { "DestBlendAlpha", SVT_DWORD, s_blendValues, 0 }, + { "ColorWriteEnable1", SVT_BOOL, s_boolValues, 0 }, + { "ColorWriteEnable2", SVT_BOOL, s_boolValues, 0 }, + { "ColorWriteEnable3", SVT_BOOL, s_boolValues, 0 }, + { "CullMode", SVT_DWORD, s_cullModeValues, 0 }, + { "LocalViewer", SVT_BOOL, s_boolValues, 0 }, - { "vertexshader", SVT_DWORD, s_shaderValues, 0 }, - { "pixelshader", SVT_DWORD, s_shaderValues, 0 }, - { "computeshader", SVT_DWORD, s_shaderValues, 0 }, - { "geometryshader", SVT_DWORD, s_shaderValues, 0 }, - { "hullshader", SVT_DWORD, s_shaderValues, 0 }, - { "domainshader", SVT_DWORD, s_shaderValues, 0 }, + { "vertexshader", SVT_DWORD, s_shaderValues, 0 }, + { "pixelshader", SVT_DWORD, s_shaderValues, 0 }, + { "computeshader", SVT_DWORD, s_shaderValues, 0 }, + { "geometryshader", SVT_DWORD, s_shaderValues, 0 }, + { "hullshader", SVT_DWORD, s_shaderValues, 0 }, + { "domainshader", SVT_DWORD, s_shaderValues, 0 }, - { nullptr, SVT_BOOL, nullptr, 0 }, + { nullptr, SVT_BOOL, nullptr, 0 }, }; - static bool CastExpressionElementValue( ExpressionValueElement& value, int from, int to ) { if( from == to ) @@ -566,14 +565,13 @@ bool EvaluateExpression( ParserState& state, ASTNode* node, Type& type, Expressi value.push_back( element ); } return true; - case OP_STRING_CONST: - { + case OP_STRING_CONST: { type.FromTokenType( OP_STRING ); ExpressionValueElement element; element.stringValue = ParseString( node->GetToken()->stringValue ); value.push_back( element ); } - return true; + return true; } return false; case NT_VAR_IDENTIFIER: { @@ -614,8 +612,7 @@ bool EvaluateExpression( ParserState& state, ASTNode* node, Type& type, Expressi state.ShowMessage( node->GetToken()->fileLocation, EC_INVALID_STATE_VALUE, ToString( node->GetToken()->stringValue ).c_str() ); } return false; - case NT_EXPRESSION: - { + case NT_EXPRESSION: { if( node->GetToken()->type == 0 ) { if( !EvaluateExpression( state, node->GetChild( 0 ), type, value, stateValues ) ) @@ -1460,59 +1457,59 @@ bool EvaluateExpression( ParserState& state, ASTNode* node, Type& type, Expressi state.ShowMessage( node->GetToken()->fileLocation, EC_FUNCTIONS_NOT_SUPPORTED, ToString( node->GetSymbol()->name ).c_str() ); return false; } - memset( &type, 0, sizeof( type ) ); - type.FromToken( *node->GetToken() ); - switch( type.builtInType ) + memset( &type, 0, sizeof( type ) ); + type.FromToken( *node->GetToken() ); + switch( type.builtInType ) + { + case OP_BOOL: + case OP_INT: + case OP_UINT: + type.builtInType = OP_INT; + break; + case OP_HALF: + case OP_FLOAT: + case OP_DOUBLE: + type.builtInType = OP_FLOAT; + break; + default: + state.ShowMessage( node->GetToken()->fileLocation, EC_UNSUPPORTED_TYPE, ToString( node->GetToken()->stringValue ).c_str() ); + return false; + } + + int elements = type.width * type.height; + + for( unsigned i = 0; i < node->GetChildrenCount(); ++i ) + { + Type childType; + ExpressionValue childValue; + if( !EvaluateExpression( state, node->GetChild( i ), childType, childValue, stateValues ) ) { - case OP_BOOL: - case OP_INT: - case OP_UINT: - type.builtInType = OP_INT; - break; - case OP_HALF: - case OP_FLOAT: - case OP_DOUBLE: - type.builtInType = OP_FLOAT; - break; - default: - state.ShowMessage( node->GetToken()->fileLocation, EC_UNSUPPORTED_TYPE, ToString( node->GetToken()->stringValue ).c_str() ); return false; } - - int elements = type.width * type.height; - - for( unsigned i = 0; i < node->GetChildrenCount(); ++i ) + Type newChildType = childType; + newChildType.builtInType = type.builtInType; + if( !CastExpressionValue( childValue, childType, newChildType ) ) { - Type childType; - ExpressionValue childValue; - if( !EvaluateExpression( state, node->GetChild( i ), childType, childValue, stateValues ) ) - { - return false; - } - Type newChildType = childType; - newChildType.builtInType = type.builtInType; - if( !CastExpressionValue( childValue, childType, newChildType ) ) + state.ShowMessage( node->GetToken()->fileLocation, EC_INVALID_IMPLICIT_CAST ); + return false; + } + for( int j = 0; j < childType.width * childType.height; ++j ) + { + value.push_back( childValue[j] ); + if( elements == 0 ) { - state.ShowMessage( node->GetToken()->fileLocation, EC_INVALID_IMPLICIT_CAST ); + state.ShowMessage( node->GetToken()->fileLocation, EC_INCORRECT_NUMBER_OF_ARGS ); return false; } - for( int j = 0; j < childType.width * childType.height; ++j ) - { - value.push_back( childValue[j] ); - if( elements == 0 ) - { - state.ShowMessage( node->GetToken()->fileLocation, EC_INCORRECT_NUMBER_OF_ARGS ); - return false; - } - elements--; - } - } - if( elements > 0 ) - { - state.ShowMessage( node->GetToken()->fileLocation, EC_INCORRECT_NUMBER_OF_ARGS ); - return false; + elements--; } } + if( elements > 0 ) + { + state.ShowMessage( node->GetToken()->fileLocation, EC_INCORRECT_NUMBER_OF_ARGS ); + return false; + } + } return true; default: state.ShowMessage( node->GetLocation(), EC_OPERATOR_NOT_SUPPORTED ); @@ -1523,14 +1520,6 @@ bool EvaluateExpression( ParserState& state, ASTNode* node, Type& type, Expressi - - - - - - - - bool GetStateValue( ParserState& state, ASTNode* value, const StateDescription& desc, void* dataBlob ) { BYTE* blob = reinterpret_cast( dataBlob ); @@ -1611,13 +1600,12 @@ bool GetStateValue( ParserState& state, ASTNode* value, const StateDescription& case SVT_BOOL: *reinterpret_cast( blob + desc.offset ) = BYTE( exprValue[0].intValue ? 1 : 0 ); return true; - case SVT_COLOR: - { - reinterpret_cast( blob + desc.offset )->x = float( exprValue[0].floatValue ); - reinterpret_cast( blob + desc.offset )->y = float( exprValue[1].floatValue ); - reinterpret_cast( blob + desc.offset )->z = float( exprValue[2].floatValue ); - reinterpret_cast( blob + desc.offset )->w = float( exprValue[3].floatValue ); - } + case SVT_COLOR: { + reinterpret_cast( blob + desc.offset )->x = float( exprValue[0].floatValue ); + reinterpret_cast( blob + desc.offset )->y = float( exprValue[1].floatValue ); + reinterpret_cast( blob + desc.offset )->z = float( exprValue[2].floatValue ); + reinterpret_cast( blob + desc.offset )->w = float( exprValue[3].floatValue ); + } return true; } return false; @@ -1725,10 +1713,10 @@ bool GetSamplerState( ParserState& parserState, ASTNode* node, Sampler& sampler //} //else //{ - // sampler.filter = D3D11_ENCODE_BASIC_FILTER( - // sampler.minFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, - // sampler.magFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, - // sampler.mipFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, + // sampler.filter = D3D11_ENCODE_BASIC_FILTER( + // sampler.minFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, + // sampler.magFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, + // sampler.mipFilter == D3DTEXF_LINEAR ? D3D11_FILTER_TYPE_LINEAR : D3D11_FILTER_TYPE_POINT, // FALSE ); //} } @@ -1802,28 +1790,28 @@ int EvaluateIntegerExpression( ParserState& state, ASTNode* node, int defaultVal std::optional ParseRtShaderName( const InlineString& name ) { - if( EqualsCaseInsensitive( name, "raygenshader" ) ) - { - return RtShaderType::RAY_GEN; - } - else if( EqualsCaseInsensitive( name, "missshader" ) ) - { - return RtShaderType::MISS; - } - else if( EqualsCaseInsensitive( name, "closesthitshader" ) ) - { - return RtShaderType::CLOSEST_HIT; - } - else if( EqualsCaseInsensitive( name, "anyhitshader" ) ) - { - return RtShaderType::ANY_HIT; - } - else if( EqualsCaseInsensitive( name, "intersectionshader" ) ) - { - return RtShaderType::INTERSECTION; - } - else - { - return {}; - } + if( EqualsCaseInsensitive( name, "raygenshader" ) ) + { + return RtShaderType::RAY_GEN; + } + else if( EqualsCaseInsensitive( name, "missshader" ) ) + { + return RtShaderType::MISS; + } + else if( EqualsCaseInsensitive( name, "closesthitshader" ) ) + { + return RtShaderType::CLOSEST_HIT; + } + else if( EqualsCaseInsensitive( name, "anyhitshader" ) ) + { + return RtShaderType::ANY_HIT; + } + else if( EqualsCaseInsensitive( name, "intersectionshader" ) ) + { + return RtShaderType::INTERSECTION; + } + else + { + return {}; + } } diff --git a/shadercompiler/InlineString.h b/shadercompiler/InlineString.h index 9c828c319..d19e025ba 100644 --- a/shadercompiler/InlineString.h +++ b/shadercompiler/InlineString.h @@ -11,7 +11,10 @@ struct InlineString const char* start; const char* end; - operator bool() const { return start != nullptr; } + operator bool() const + { + return start != nullptr; + } }; inline InlineString MakeInlineString( const char* start, const char* end ) @@ -89,32 +92,26 @@ inline bool operator<( const InlineString& str0, const InlineString& str1 ) inline bool IEquals( const InlineString& a, const InlineString& b ) { - return std::equal(a.start, a.end, - b.start, b.end, - [](char a, char b) { - return tolower(a) == tolower(b); - }); + return std::equal( a.start, a.end, b.start, b.end, []( char a, char b ) { + return tolower( a ) == tolower( b ); + } ); } inline bool IEquals( const InlineString& a, const char* b ) { - return std::equal(a.start, a.end, - b, b + strlen( b ), - [](char a, char b) { - return tolower(a) == tolower(b); - }); + return std::equal( a.start, a.end, b, b + strlen( b ), []( char a, char b ) { + return tolower( a ) == tolower( b ); + } ); } struct ILess { inline bool operator()( const InlineString& a, const InlineString& b ) const { - - return std::lexicographical_compare(a.start, a.end, - b.start, b.end, - [](char a, char b) { - return tolower(a) < tolower(b); - }); + + return std::lexicographical_compare( a.start, a.end, b.start, b.end, []( char a, char b ) { + return tolower( a ) < tolower( b ); + } ); } }; diff --git a/shadercompiler/IntrinsicTypes.h b/shadercompiler/IntrinsicTypes.h index ceb9a7a32..d5b38c0e4 100644 --- a/shadercompiler/IntrinsicTypes.h +++ b/shadercompiler/IntrinsicTypes.h @@ -173,7 +173,7 @@ inline Symbol* AddConstant( SymbolTable& table, const char* name, int opType ) return symbol; } -template +template int TypeSameAsArg( ASTNode* call ) { ASTNode* arg0 = call->GetChildOrNull( Arg ); @@ -185,7 +185,7 @@ int TypeSameAsArg( ASTNode* call ) } -template +template int TypeIs( ASTNode* ) { return type; @@ -210,7 +210,7 @@ inline int CommonArgType( ASTNode* call ) return type; } -template +template void DimSameAsArg( ASTNode* call, int& width, int& height ) { ASTNode* arg0 = call->GetChildOrNull( Arg ); @@ -226,7 +226,7 @@ void DimSameAsArg( ASTNode* call, int& width, int& height ) } } -template +template void DimIs( ASTNode*, int& width, int& height ) { width = Width; @@ -250,7 +250,7 @@ inline void CommonArgDim( ASTNode* call, int& width, int& height ) typedef int ( *TypeComponent )( ASTNode* call ); typedef void ( *DimComponent )( ASTNode* call, int& width, int& height ); -template +template Type FunctionDescription0( ASTNode* call, int argIndex ) { Type type; @@ -264,10 +264,11 @@ Type FunctionDescription0( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim> Type FunctionDescription1( ASTNode* call, int argIndex ) { Type type; @@ -286,11 +287,13 @@ Type FunctionDescription1( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim, - TypeComponent Arg1Type, DimComponent Arg1Dim -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim, + TypeComponent Arg1Type, + DimComponent Arg1Dim> Type FunctionDescription2( ASTNode* call, int argIndex ) { Type type; @@ -313,11 +316,15 @@ Type FunctionDescription2( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim, int Arg0Modifier, - TypeComponent Arg1Type, DimComponent Arg1Dim, int Arg1Modifier -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim, + int Arg0Modifier, + TypeComponent Arg1Type, + DimComponent Arg1Dim, + int Arg1Modifier> Type FunctionDescription2Ex( ASTNode* call, int argIndex ) { Type type; @@ -342,12 +349,15 @@ Type FunctionDescription2Ex( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim, - TypeComponent Arg1Type, DimComponent Arg1Dim, - TypeComponent Arg2Type, DimComponent Arg2Dim -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim, + TypeComponent Arg1Type, + DimComponent Arg1Dim, + TypeComponent Arg2Type, + DimComponent Arg2Dim> Type FunctionDescription3( ASTNode* call, int argIndex ) { Type type; @@ -374,13 +384,17 @@ Type FunctionDescription3( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim, - TypeComponent Arg1Type, DimComponent Arg1Dim, - TypeComponent Arg2Type, DimComponent Arg2Dim, - TypeComponent Arg3Type, DimComponent Arg3Dim -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim, + TypeComponent Arg1Type, + DimComponent Arg1Dim, + TypeComponent Arg2Type, + DimComponent Arg2Dim, + TypeComponent Arg3Type, + DimComponent Arg3Dim> Type FunctionDescription4( ASTNode* call, int argIndex ) { Type type; @@ -411,17 +425,25 @@ Type FunctionDescription4( ASTNode* call, int argIndex ) return type; } -template< - TypeComponent ResultType, DimComponent ResultDim, - TypeComponent Arg0Type, DimComponent Arg0Dim, - TypeComponent Arg1Type, DimComponent Arg1Dim, - TypeComponent Arg2Type, DimComponent Arg2Dim, - TypeComponent Arg3Type, DimComponent Arg3Dim, - TypeComponent Arg4Type, DimComponent Arg4Dim, - TypeComponent Arg5Type, DimComponent Arg5Dim, - TypeComponent Arg6Type, DimComponent Arg6Dim, - TypeComponent Arg7Type, DimComponent Arg7Dim -> +template < + TypeComponent ResultType, + DimComponent ResultDim, + TypeComponent Arg0Type, + DimComponent Arg0Dim, + TypeComponent Arg1Type, + DimComponent Arg1Dim, + TypeComponent Arg2Type, + DimComponent Arg2Dim, + TypeComponent Arg3Type, + DimComponent Arg3Dim, + TypeComponent Arg4Type, + DimComponent Arg4Dim, + TypeComponent Arg5Type, + DimComponent Arg5Dim, + TypeComponent Arg6Type, + DimComponent Arg6Dim, + TypeComponent Arg7Type, + DimComponent Arg7Dim> Type FunctionDescription8( ASTNode* call, int argIndex ) { Type type; diff --git a/shadercompiler/Macro.h b/shadercompiler/Macro.h index 82c22fd3b..8c6a18d25 100644 --- a/shadercompiler/Macro.h +++ b/shadercompiler/Macro.h @@ -9,7 +9,7 @@ struct Macro std::string value; template - static bool FillDxMacros( D3D_SHADER_MACRO (&outMacros)[Size], Iterator inBegin, Iterator inEnd ) + static bool FillDxMacros( D3D_SHADER_MACRO ( &outMacros )[Size], Iterator inBegin, Iterator inEnd ) { bool result = true; size_t i = 0; diff --git a/shadercompiler/ModifiedTime.cpp b/shadercompiler/ModifiedTime.cpp index 7eeaea0b6..bd11d80ad 100644 --- a/shadercompiler/ModifiedTime.cpp +++ b/shadercompiler/ModifiedTime.cpp @@ -12,126 +12,126 @@ namespace { - CachingIncludeHandler s_includeHandler; +CachingIncludeHandler s_includeHandler; - char* GetNextWord( char* string ) - { +char* GetNextWord( char* string ) +{ - char* end = string; - while( *end && *end != ' ' && *end != '\n' ) - { - ++end; - } - switch (*end) - { - case 0: - return end; - case '\n': - *end = 0; - return end; - default: - *end = 0; - return end + 1; - } + char* end = string; + while( *end && *end != ' ' && *end != '\n' ) + { + ++end; + } + switch( *end ) + { + case 0: + return end; + case '\n': + *end = 0; + return end; + default: + *end = 0; + return end + 1; } +} - struct HashCheckArguments - { - std::string sourcePath; - std::string outputPath; - std::vector defines; - }; +struct HashCheckArguments +{ + std::string sourcePath; + std::string outputPath; + std::vector defines; +}; - std::mutex s_modifiedOutputsCS; - std::set s_modifiedOutputs; +std::mutex s_modifiedOutputsCS; +std::set s_modifiedOutputs; - const std::regex s_include( "#[[:space:]]*include[[:space:]]*[<\"]([^>\"]*)" ); +const std::regex s_include( "#[[:space:]]*include[[:space:]]*[<\"]([^>\"]*)" ); - bool IsOutputUpToDate(const char* path, const std::string& sourceHash ) +bool IsOutputUpToDate( const char* path, const std::string& sourceHash ) +{ + FILE* file = nullptr; + fopen_s( &file, path, "rb" ); + if( !file ) + { + return false; + } + uint32_t fileVersion; + if( fread( &fileVersion, sizeof( fileVersion ), 1, file ) != 1 ) { - FILE* file = nullptr; - fopen_s( &file, path, "rb" ); - if( !file ) - { - return false; - } - uint32_t fileVersion; - if( fread( &fileVersion, sizeof( fileVersion ), 1, file ) != 1 ) - { - fclose( file ); - return false; - } - if( fileVersion != DATA_VERSION ) - { - fclose( file ); - return false; - } - uint8_t compilerVersion[4]; - if( fread( compilerVersion, sizeof( compilerVersion ), 1, file ) != 1 ) - { - fclose( file ); - return false; - } - if( compilerVersion[0] != ShaderCompilerVersion[0] || compilerVersion[1] != ShaderCompilerVersion[1] || compilerVersion[2] != ShaderCompilerVersion[2] ) - { - fclose( file ); - return false; - } - - char buffer[MD5::HashBytes * 2]; - if( fread( buffer, sizeof( buffer ), 1, file ) != 1 ) - { - fclose( file ); - return false; - } fclose( file ); - - return sourceHash == std::string( buffer, buffer + sizeof( buffer ) ); + return false; + } + if( fileVersion != DATA_VERSION ) + { + fclose( file ); + return false; + } + uint8_t compilerVersion[4]; + if( fread( compilerVersion, sizeof( compilerVersion ), 1, file ) != 1 ) + { + fclose( file ); + return false; + } + if( compilerVersion[0] != ShaderCompilerVersion[0] || compilerVersion[1] != ShaderCompilerVersion[1] || compilerVersion[2] != ShaderCompilerVersion[2] ) + { + fclose( file ); + return false; } - bool CheckHash( const HashCheckArguments& query ) + char buffer[MD5::HashBytes * 2]; + if( fread( buffer, sizeof( buffer ), 1, file ) != 1 ) { - { - std::lock_guard scope( s_modifiedOutputsCS ); - if( s_modifiedOutputs.find( query.outputPath ) != s_modifiedOutputs.end() ) - { - return true; - } - } + fclose( file ); + return false; + } + fclose( file ); - auto in = ::GetSourceHash( query.sourcePath.c_str(), query.defines ); + return sourceHash == std::string( buffer, buffer + sizeof( buffer ) ); +} - if( !IsOutputUpToDate( query.outputPath.c_str(), in ) ) +bool CheckHash( const HashCheckArguments& query ) +{ + { + std::lock_guard scope( s_modifiedOutputsCS ); + if( s_modifiedOutputs.find( query.outputPath ) != s_modifiedOutputs.end() ) { - std::lock_guard scope( s_modifiedOutputsCS ); - s_modifiedOutputs.insert( query.outputPath ); + return true; } + } - return true; + auto in = ::GetSourceHash( query.sourcePath.c_str(), query.defines ); + + if( !IsOutputUpToDate( query.outputPath.c_str(), in ) ) + { + std::lock_guard scope( s_modifiedOutputsCS ); + s_modifiedOutputs.insert( query.outputPath ); } - void GetSourceHash( const char* sourcePath, const char* parentData, const char* rootPath, std::set& visited, MD5& md5 ) + return true; +} + +void GetSourceHash( const char* sourcePath, const char* parentData, const char* rootPath, std::set& visited, MD5& md5 ) +{ + if( visited.find( sourcePath ) != end( visited ) ) { - if( visited.find( sourcePath ) != end( visited ) ) - { - return; - } - visited.insert( sourcePath ); - if( auto opened = s_includeHandler.Open( sourcePath, parentData, rootPath ) ) - { - md5.add( opened->data, opened->size ); + return; + } + visited.insert( sourcePath ); + if( auto opened = s_includeHandler.Open( sourcePath, parentData, rootPath ) ) + { + md5.add( opened->data, opened->size ); - std::cmatch match; - auto begin = opened->data; - while( std::regex_search( begin, opened->data + opened->size, match, s_include ) ) - { - GetSourceHash( match[1].str().c_str(), opened->data, rootPath, visited, md5 ); - begin += match.position() + match.length(); - } + std::cmatch match; + auto begin = opened->data; + while( std::regex_search( begin, opened->data + opened->size, match, s_include ) ) + { + GetSourceHash( match[1].str().c_str(), opened->data, rootPath, visited, md5 ); + begin += match.position() + match.length(); } } +} } @@ -152,13 +152,13 @@ std::string GetSourceHash( const char* sourcePath, const std::vector& def md5.add( each.name.c_str(), each.name.length() ); md5.add( each.value.c_str(), each.value.length() ); } - + // safety mechanism so that teamcity overwrites submitted shaders that have been built with undesirable settings md5.add( &g_optimizationLevel, sizeof( g_optimizationLevel ) ); md5.add( &g_avoidFlowControl, sizeof( g_avoidFlowControl ) ); md5.add( &g_generatePDB, sizeof( g_generatePDB ) ); md5.add( &g_skipOptimization, sizeof( g_skipOptimization ) ); - + GetSourceHash( sourcePath, nullptr, sourcePath, visited, md5 ); return md5.getHash(); } @@ -170,7 +170,7 @@ void PrintOutOfDateFiles( size_t workerCount ) char buffer[4096]; while( !feof( stdin ) ) { - if( !fgets( buffer, sizeof(buffer), stdin ) ) + if( !fgets( buffer, sizeof( buffer ), stdin ) ) { break; } diff --git a/shadercompiler/OutputHLSL.cpp b/shadercompiler/OutputHLSL.cpp index 9e7d3ca0b..c45221bf1 100644 --- a/shadercompiler/OutputHLSL.cpp +++ b/shadercompiler/OutputHLSL.cpp @@ -12,427 +12,427 @@ namespace { - // XSL = X Shading Language. Can be either HLSL or MSL. - template< typename XSL > - struct Children +// XSL = X Shading Language. Can be either HLSL or MSL. +template +struct Children +{ + Children( XSL parent_, const char* glue_, size_t offset_ = 0 ) : + parent( parent_ ), + glue( glue_ ), + offset( offset_ ) { - Children( XSL parent_, const char* glue_, size_t offset_ = 0 ) - :parent( parent_ ), - glue( glue_ ), - offset( offset_ ) - { - } + } - XSL parent; - const char* glue; - size_t offset; - }; + XSL parent; + const char* glue; + size_t offset; +}; - template< typename XSL > - XSL XSLChild( const XSL& parent, size_t childIndex ) - { - return XSL{ parent.node->GetChild( childIndex ), parent.symbolTable }; - } +template +XSL XSLChild( const XSL& parent, size_t childIndex ) +{ + return XSL{ parent.node->GetChild( childIndex ), parent.symbolTable }; +} - template< typename XSL > - CodeStream& operator<<( CodeStream& os, const Children& children ) +template +CodeStream& operator<<( CodeStream& os, const Children& children ) +{ + for( size_t i = children.offset; i < children.parent.node->GetChildrenCount(); ++i ) { - for( size_t i = children.offset; i < children.parent.node->GetChildrenCount(); ++i ) + if( i ) { - if( i ) - { - os << children.glue; - } - os << XSLChild( children.parent, i ); + os << children.glue; } - return os; + os << XSLChild( children.parent, i ); } + return os; +} - bool HasUsedDeclarations( ASTNode* node ) +bool HasUsedDeclarations( ASTNode* node ) +{ + for( unsigned i = 0; i < node->GetChildrenCount(); ++i ) { - for( unsigned i = 0; i < node->GetChildrenCount(); ++i ) + if( node->GetChild( i ) ) { - if( node->GetChild( i ) ) + if( node->GetChild( i )->GetNodeType() == NT_VAR_DECLARATION_LIST ) { - if( node->GetChild( i )->GetNodeType() == NT_VAR_DECLARATION_LIST ) + if( HasUsedDeclarations( node->GetChild( i ) ) ) { - if( HasUsedDeclarations( node->GetChild( i ) ) ) - { - return true; - } + return true; } - else if( node->GetChild( i )->GetNodeType() == NT_NAME_DECLARATION ) + } + else if( node->GetChild( i )->GetNodeType() == NT_NAME_DECLARATION ) + { + if( node->GetChild( i )->GetSymbol() && node->GetChild( i )->GetSymbol()->used ) { - if( node->GetChild( i )->GetSymbol() && node->GetChild( i )->GetSymbol()->used ) - { - return true; - } + return true; } } } - return false; } + return false; +} - std::map s_operators = { - { OP_MUL_ASSIGN, "*=" }, - { OP_DIV_ASSIGN, "/=" }, - { OP_MOD_ASSIGN, "%=" }, - { OP_ADD_ASSIGN, "+=" }, - { OP_SUB_ASSIGN, "-=" }, - { OP_LEFT_ASSIGN, "<<=" }, - { OP_RIGHT_ASSIGN, ">>=" }, - { OP_AND_ASSIGN, "&=" }, - { OP_XOR_ASSIGN, "^=" }, - { OP_OR_ASSIGN, "|=" }, - { OP_INC_OP, "++" }, - { OP_DEC_OP, "--" }, - { OP_LEFT_OP, "<<" }, - { OP_RIGHT_OP, ">>" }, - { OP_LE_OP, "<=" }, - { OP_GE_OP, ">=" }, - { OP_EQ_OP, "==" }, - { OP_NE_OP, "!=" }, - { OP_AND_OP, "&&" }, - { OP_OR_OP, "||" }, - { OP_PLUS, "+" }, - { OP_DASH, "-" }, - { OP_BANG, "!" }, - { OP_TILDE, "~" }, - { OP_STAR, "*" }, - { OP_SLASH, "/" }, - { OP_PERCENT, "%" }, - { OP_COMA, "," }, - { OP_LESS, "<" }, - { OP_MORE, ">" }, - { OP_AMPERSAND, "&" }, - { OP_CARET, "^" }, - { OP_VERTICAL_BAR, "|" }, - { OP_EQUAL, "=" } - }; +std::map s_operators = { + { OP_MUL_ASSIGN, "*=" }, + { OP_DIV_ASSIGN, "/=" }, + { OP_MOD_ASSIGN, "%=" }, + { OP_ADD_ASSIGN, "+=" }, + { OP_SUB_ASSIGN, "-=" }, + { OP_LEFT_ASSIGN, "<<=" }, + { OP_RIGHT_ASSIGN, ">>=" }, + { OP_AND_ASSIGN, "&=" }, + { OP_XOR_ASSIGN, "^=" }, + { OP_OR_ASSIGN, "|=" }, + { OP_INC_OP, "++" }, + { OP_DEC_OP, "--" }, + { OP_LEFT_OP, "<<" }, + { OP_RIGHT_OP, ">>" }, + { OP_LE_OP, "<=" }, + { OP_GE_OP, ">=" }, + { OP_EQ_OP, "==" }, + { OP_NE_OP, "!=" }, + { OP_AND_OP, "&&" }, + { OP_OR_OP, "||" }, + { OP_PLUS, "+" }, + { OP_DASH, "-" }, + { OP_BANG, "!" }, + { OP_TILDE, "~" }, + { OP_STAR, "*" }, + { OP_SLASH, "/" }, + { OP_PERCENT, "%" }, + { OP_COMA, "," }, + { OP_LESS, "<" }, + { OP_MORE, ">" }, + { OP_AMPERSAND, "&" }, + { OP_CARET, "^" }, + { OP_VERTICAL_BAR, "|" }, + { OP_EQUAL, "=" } +}; - static const char* GetOperatorSymbol( int operatorID ) +static const char* GetOperatorSymbol( int operatorID ) +{ + auto it = s_operators.find( operatorID ); + if( it == s_operators.end() ) { - auto it = s_operators.find( operatorID ); - if( it == s_operators.end() ) - { - return ""; - } - return it->second.c_str(); + return ""; } + return it->second.c_str(); +} - void PrintTypeHLSL11( CodeStream& os, Type type ) +void PrintTypeHLSL11( CodeStream& os, Type type ) +{ + switch( type.storageClass ) + { + case OP_EXTERN: + os << "extern "; + break; + case OP_NOINTERPOLATION: + os << "nointerpolation "; + break; + case OP_PRECISE: + os << "precise "; + break; + case OP_SHARED: + os << "shared "; + break; + case OP_GROUPSHARED: + os << "groupshared "; + break; + case OP_STATIC: + os << "static "; + break; + case OP_UNIFORM: + os << "uniform "; + break; + case OP_VOLATILE: + os << "volatile "; + break; + } + switch( type.modifier ) + { + case OP_CONST: + os << "const "; + break; + case OP_ROW_MAJOR: + os << "row_major "; + break; + case OP_COLUMN_MAJOR: + os << "column_major "; + break; + } + if( type.symbol ) + { + os << type.symbol->name; + } + else { - switch( type.storageClass ) + switch( type.builtInType ) { - case OP_EXTERN: - os << "extern "; - break; - case OP_NOINTERPOLATION: - os << "nointerpolation "; - break; - case OP_PRECISE: - os << "precise "; + case OP_FLOAT: + os << "float"; break; - case OP_SHARED: - os << "shared "; + case OP_INT: + os << "int"; break; - case OP_GROUPSHARED: - os << "groupshared "; + case OP_UINT: + os << "uint"; break; - case OP_STATIC: - os << "static "; + case OP_HALF: + os << "min16float"; break; - case OP_UNIFORM: - os << "uniform "; - break; - case OP_VOLATILE: - os << "volatile "; - break; - } - switch( type.modifier ) - { - case OP_CONST: - os << "const "; + case OP_DOUBLE: + os << "double"; break; - case OP_ROW_MAJOR: - os << "row_major "; + case OP_BOOL: + os << "bool"; break; - case OP_COLUMN_MAJOR: - os << "column_major "; + case OP_STRING: + os << "string"; break; - } - if( type.symbol ) - { - os << type.symbol->name; - } - else - { - switch( type.builtInType ) + case OP_VOID: + os << "void"; + return; + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLER: + os << "sampler"; + return; + case OP_SAMPLERCOMPARISON: + os << "SamplerComparisonState"; + return; + case OP_TEXTURE1D: + os << "Texture1D"; + if( type.templateParameter ) { - case OP_FLOAT: - os << "float"; - break; - case OP_INT: - os << "int"; - break; - case OP_UINT: - os << "uint"; - break; - case OP_HALF: - os << "min16float"; - break; - case OP_DOUBLE: - os << "double"; - break; - case OP_BOOL: - os << "bool"; - break; - case OP_STRING: - os << "string"; - break; - case OP_VOID: - os << "void"; - return; - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLER: - os << "sampler"; - return; - case OP_SAMPLERCOMPARISON: - os << "SamplerComparisonState"; - return; - case OP_TEXTURE1D: - os << "Texture1D"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE2D: - os << "Texture2D"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE3D: - os << "Texture3D"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURECUBE: - os << "TextureCube"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE1DARRAY: - os << "Texture1DArray"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE2DARRAY: - os << "Texture2DArray"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE3DARRAY: - os << "Texture3DArray"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURECUBEARRAY: - os << "TextureCubeArray"; - if( type.templateParameter ) - { - os << '<' << *type.templateParameter << '>'; - } - return; - case OP_TEXTURE2DMS: - os << "Texture2DMS"; - os << '<' << *type.templateParameter; - if( type.templateSamples > 0 ) - { - os << ", " << type.templateSamples; - } - os << '>'; - return; - case OP_TEXTURE2DMSARRAY: - os << "Texture2DMSArray"; - os << '<' << *type.templateParameter; - if( type.templateSamples > 0 ) - { - os << ", " << type.templateSamples; - } - os << '>'; - return; - case OP_TEXTURE: - os << "Texture2D"; - return; - case OP_BUFFER: - os << "Buffer" << '<' << *type.templateParameter << '>'; - return; - case OP_APPENDSTRUCTUREDBUFFER: - os << "AppendStructuredBuffer" << '<' << *type.templateParameter << '>'; - return; - case OP_BYTEADDRESSBUFFER: - os << "ByteAddressBuffer"; - return; - case OP_CONSUMESTRUCTUREDBUFFER: - os << "ConsumeStructuredBuffer" << '<' << *type.templateParameter << '>'; - return; - case OP_INPUTPATCH: - os << "InputPatch"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << ", " << type.templateSamples << '>'; - return; - case OP_OUTPUTPATCH: - os << "OutputPatch"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << ", " << type.templateSamples << '>'; - return; - case OP_RWBUFFER: - os << "RWBuffer"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWBYTEADDRESSBUFFER: - os << "RWByteAddressBuffer"; - return; - case OP_RWSTRUCTUREDBUFFER: - os << "RWStructuredBuffer"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE1D: - os << "RWTexture1D"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE1DARRAY: - os << "RWTexture1DArray"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE2D: - os << "RWTexture2D"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE2DARRAY: - os << "RWTexture2DArray"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE3D: - os << "RWTexture3D"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_RWTEXTURE3DARRAY: - os << "RWTexture3DArray"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_STRUCTUREDBUFFER: - os << "StructuredBuffer"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_POINTSTREAM: - os << "PointStream"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_LINESTREAM: - os << "LineStream"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_TRIANGLESTREAM: - os << "TriangleStream"; - os << '<'; - PrintTypeHLSL11( os, *type.templateParameter ); - os << '>'; - return; - case OP_BINDLESSHANDLETEXTURE2D: - case OP_BINDLESSHANDLETEXTURE3D: - case OP_BINDLESSHANDLETEXTURECUBE: - case OP_BINDLESSHANDLESAMPLER: - os << "uint"; - return; - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - os << "RaytracingAccelerationStructure"; - return; - case OP_RAY_DESC: - os << "RayDesc"; - return; - default: - os << "!!error_type!!"; - return; + os << '<' << *type.templateParameter << '>'; } - if( type.width > 1 || type.height > 1 ) + return; + case OP_TEXTURE2D: + os << "Texture2D"; + if( type.templateParameter ) { - os << type.width; - if( type.height > 1 ) - { - os << 'x' << type.height; - } + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURE3D: + os << "Texture3D"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURECUBE: + os << "TextureCube"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURE1DARRAY: + os << "Texture1DArray"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURE2DARRAY: + os << "Texture2DArray"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURE3DARRAY: + os << "Texture3DArray"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURECUBEARRAY: + os << "TextureCubeArray"; + if( type.templateParameter ) + { + os << '<' << *type.templateParameter << '>'; + } + return; + case OP_TEXTURE2DMS: + os << "Texture2DMS"; + os << '<' << *type.templateParameter; + if( type.templateSamples > 0 ) + { + os << ", " << type.templateSamples; + } + os << '>'; + return; + case OP_TEXTURE2DMSARRAY: + os << "Texture2DMSArray"; + os << '<' << *type.templateParameter; + if( type.templateSamples > 0 ) + { + os << ", " << type.templateSamples; + } + os << '>'; + return; + case OP_TEXTURE: + os << "Texture2D"; + return; + case OP_BUFFER: + os << "Buffer" << '<' << *type.templateParameter << '>'; + return; + case OP_APPENDSTRUCTUREDBUFFER: + os << "AppendStructuredBuffer" << '<' << *type.templateParameter << '>'; + return; + case OP_BYTEADDRESSBUFFER: + os << "ByteAddressBuffer"; + return; + case OP_CONSUMESTRUCTUREDBUFFER: + os << "ConsumeStructuredBuffer" << '<' << *type.templateParameter << '>'; + return; + case OP_INPUTPATCH: + os << "InputPatch"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << ", " << type.templateSamples << '>'; + return; + case OP_OUTPUTPATCH: + os << "OutputPatch"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << ", " << type.templateSamples << '>'; + return; + case OP_RWBUFFER: + os << "RWBuffer"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWBYTEADDRESSBUFFER: + os << "RWByteAddressBuffer"; + return; + case OP_RWSTRUCTUREDBUFFER: + os << "RWStructuredBuffer"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE1D: + os << "RWTexture1D"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE1DARRAY: + os << "RWTexture1DArray"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE2D: + os << "RWTexture2D"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE2DARRAY: + os << "RWTexture2DArray"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE3D: + os << "RWTexture3D"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_RWTEXTURE3DARRAY: + os << "RWTexture3DArray"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_STRUCTUREDBUFFER: + os << "StructuredBuffer"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_POINTSTREAM: + os << "PointStream"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_LINESTREAM: + os << "LineStream"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_TRIANGLESTREAM: + os << "TriangleStream"; + os << '<'; + PrintTypeHLSL11( os, *type.templateParameter ); + os << '>'; + return; + case OP_BINDLESSHANDLETEXTURE2D: + case OP_BINDLESSHANDLETEXTURE3D: + case OP_BINDLESSHANDLETEXTURECUBE: + case OP_BINDLESSHANDLESAMPLER: + os << "uint"; + return; + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + os << "RaytracingAccelerationStructure"; + return; + case OP_RAY_DESC: + os << "RayDesc"; + return; + default: + os << "!!error_type!!"; + return; + } + if( type.width > 1 || type.height > 1 ) + { + os << type.width; + if( type.height > 1 ) + { + os << 'x' << type.height; } } } +} - Type ScalarType( const Type& type ) +Type ScalarType( const Type& type ) +{ + Type scalarType = type; + scalarType.width = scalarType.height = 1; + return scalarType; +} + +Type MslTextureTemplateType( const Type& textureType ) +{ + if( textureType.templateParameter ) { - Type scalarType = type; - scalarType.width = scalarType.height = 1; - return scalarType; + // Metal expects type of only one texture component here. + return ScalarType( *textureType.templateParameter ); } - - Type MslTextureTemplateType( const Type& textureType ) + else { - if( textureType.templateParameter ) - { - // Metal expects type of only one texture component here. - return ScalarType( *textureType.templateParameter ); - } - else - { - return TypeFromTokenType( OP_FLOAT ); - } + return TypeFromTokenType( OP_FLOAT ); } +} - void PrintTypeMSL( CodeStream& os, Type type ) +void PrintTypeMSL( CodeStream& os, Type type ) +{ + switch( type.storageClass ) { - switch( type.storageClass ) - { - case OP_EXTERN: - os << "extern "; - break; - //TODO + case OP_EXTERN: + os << "extern "; + break; + //TODO #if 0 case OP_NOINTERPOLATION: os << "nointerpolation "; @@ -444,173 +444,173 @@ namespace os << "shared "; break; #endif - case OP_GROUPSHARED: - // Already processed and mapped to AddressSpace::Threadgroup. - break; - case OP_STATIC: - os << "static "; - break; - //TODO + case OP_GROUPSHARED: + // Already processed and mapped to AddressSpace::Threadgroup. + break; + case OP_STATIC: + os << "static "; + break; + //TODO #if 0 case OP_UNIFORM: os << "uniform "; break; #endif - case OP_VOLATILE: - os << "volatile "; - break; - } - if( type.modifier == OP_CONST ) - { - os << "const "; - } - else if( type.modifier == OP_PACKOFFSET ) - { - os << "packed_"; - } - if( type.symbol ) - { - os << type.symbol->name; - } - else + case OP_VOLATILE: + os << "volatile "; + break; + } + if( type.modifier == OP_CONST ) + { + os << "const "; + } + else if( type.modifier == OP_PACKOFFSET ) + { + os << "packed_"; + } + if( type.symbol ) + { + os << type.symbol->name; + } + else + { + switch( type.builtInType ) { - switch( type.builtInType ) - { - case OP_BOOL: - os << "bool"; - break; - case OP_INT: - os << "int"; - break; - case OP_UINT: - os << "uint"; - break; - case OP_HALF: - os << "half"; - break; - case OP_FLOAT: - os << "float"; - break; + case OP_BOOL: + os << "bool"; + break; + case OP_INT: + os << "int"; + break; + case OP_UINT: + os << "uint"; + break; + case OP_HALF: + os << "half"; + break; + case OP_FLOAT: + os << "float"; + break; #if 0 case OP_DOUBLE: os << "double"; break; #endif - case OP_VOID: - os << "void"; - return; - case OP_STRING: - os << "string"; - break; - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLER: - case OP_SAMPLERCOMPARISON: - os << "sampler"; - return; + case OP_VOID: + os << "void"; + return; + case OP_STRING: + os << "string"; + break; + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLER: + case OP_SAMPLERCOMPARISON: + os << "sampler"; + return; // TODO #if 0 case OP_SAMPLERCOMPARISON: os << "SamplerComparisonState"; return; #endif - case OP_TEXTURE1D: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texture1d<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURE1DARRAY: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texture1d_array<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURE: - case OP_TEXTURE2D: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - if( type.isDepthTexture ) - { - os << "depth2d"; - } - else - { - os << "texture2d"; - } - os << "<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURE2DARRAY: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - if( type.isDepthTexture ) - { - os << "depth2d_array"; - } - else - { - os << "texture2d_array"; - } - os << "<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURE3D: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texture3d<" << MslTextureTemplateType( type ) << '>'; - return; + case OP_TEXTURE1D: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texture1d<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURE1DARRAY: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texture1d_array<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURE: + case OP_TEXTURE2D: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + if( type.isDepthTexture ) + { + os << "depth2d"; + } + else + { + os << "texture2d"; + } + os << "<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURE2DARRAY: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + if( type.isDepthTexture ) + { + os << "depth2d_array"; + } + else + { + os << "texture2d_array"; + } + os << "<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURE3D: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texture3d<" << MslTextureTemplateType( type ) << '>'; + return; #if 0 // There is no "texture3d_array" in MSL. case OP_TEXTURE3DARRAY: os << "texture3d_array<" << MslTextureTemplateType( type ) << '>'; return; #endif - case OP_TEXTURECUBE: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texturecube<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURECUBEARRAY: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texturecube_array<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_TEXTURE2DMS: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texture2d_ms<" << MslTextureTemplateType( type ) << '>'; - return; - // Supported since Metal 2.0 (macOS) and Metal 1.0 (iOS). - case OP_TEXTURE2DMSARRAY: - if( type.arrayDimensions > 0 ) - { - os << "const "; - } - os << "texture2d_ms_array<" << MslTextureTemplateType( type ) << '>'; - return; - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - os << "const " << *type.templateParameter << '*'; - return; - case OP_RWBUFFER: - case OP_RWSTRUCTUREDBUFFER: - os << *type.templateParameter << '*'; - return; - //TODO + case OP_TEXTURECUBE: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texturecube<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURECUBEARRAY: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texturecube_array<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_TEXTURE2DMS: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texture2d_ms<" << MslTextureTemplateType( type ) << '>'; + return; + // Supported since Metal 2.0 (macOS) and Metal 1.0 (iOS). + case OP_TEXTURE2DMSARRAY: + if( type.arrayDimensions > 0 ) + { + os << "const "; + } + os << "texture2d_ms_array<" << MslTextureTemplateType( type ) << '>'; + return; + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + os << "const " << *type.templateParameter << '*'; + return; + case OP_RWBUFFER: + case OP_RWSTRUCTUREDBUFFER: + os << *type.templateParameter << '*'; + return; + //TODO #if 0 case OP_APPENDSTRUCTUREDBUFFER: os << "AppendStructuredBuffer" << '<' << *type.templateParameter << '>'; @@ -633,33 +633,33 @@ namespace os << "RWByteAddressBuffer"; return; #endif - case OP_RWTEXTURE1D: - os << "texture1d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_": "" ) << "write>"; - return; - case OP_RWTEXTURE1DARRAY: - os << "texture1d_array<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; - return; - case OP_RWTEXTURE2D: - os << "texture2d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; - return; - case OP_RWTEXTURE2DARRAY: - os << "texture2d_array<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; - return; - case OP_RWTEXTURE3D: - os << "texture3d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; - return; - case OP_BINDLESSHANDLETEXTURE2D: - case OP_BINDLESSHANDLETEXTURE3D: - case OP_BINDLESSHANDLETEXTURECUBE: - case OP_BINDLESSHANDLESAMPLER: - os << "uint"; - return; - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - os << "RaytracingAccelerationStructure"; - return; - case OP_RAY_DESC: - os << "RayDesc"; - return; + case OP_RWTEXTURE1D: + os << "texture1d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; + return; + case OP_RWTEXTURE1DARRAY: + os << "texture1d_array<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; + return; + case OP_RWTEXTURE2D: + os << "texture2d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; + return; + case OP_RWTEXTURE2DARRAY: + os << "texture2d_array<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; + return; + case OP_RWTEXTURE3D: + os << "texture3d<" << MslTextureTemplateType( type ) << ", access::" << ( type.metalTextureAccess ? "read_" : "" ) << "write>"; + return; + case OP_BINDLESSHANDLETEXTURE2D: + case OP_BINDLESSHANDLETEXTURE3D: + case OP_BINDLESSHANDLETEXTURECUBE: + case OP_BINDLESSHANDLESAMPLER: + os << "uint"; + return; + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + os << "RaytracingAccelerationStructure"; + return; + case OP_RAY_DESC: + os << "RayDesc"; + return; #if 0 // There is no "texture3d_array" in MSL. case OP_RWTEXTURE3DARRAY: @@ -679,29 +679,28 @@ namespace os << '<' << *type.templateParameter << '>'; return; #endif - default: - os << "!!unsupported type: " << type.ToString() << "!!"; - return; + default: + os << "!!unsupported type: " << type.ToString() << "!!"; + return; + } + if( type.width > 1 || type.height > 1 ) + { + if( type.height > 1 ) + { + os << type.height << 'x' << type.width; } - if( type.width > 1 || type.height > 1 ) + else { - if( type.height > 1 ) - { - os << type.height << 'x' << type.width; - } - else - { - os << type.width; - } + os << type.width; } } } +} } -CompilerInputStream::CompilerInputStream( ParserState& state, const ShadingLanguage lang ) - :CodeStream( lang ) - ,m_state( state ) +CompilerInputStream::CompilerInputStream( ParserState& state, const ShadingLanguage lang ) : + CodeStream( lang ), m_state( state ) { m_location.fileName = MakeInlineString( "" ); m_location.lineNumber = unsigned( -1 ); @@ -813,7 +812,7 @@ CodeStream& operator<<( CodeStream& os, const HLSL& hlsl ) break; case NT_EXPRESSION: os << "( " << Child( 0 ) << " )"; - if( node->GetToken()->type != OP_LEFT_PAREN ) + if( node->GetToken()->type != OP_LEFT_PAREN ) { os << " " << GetOperatorSymbol( node->GetToken()->type ) << " ( " << Child( 1 ) << " )"; } @@ -842,7 +841,7 @@ CodeStream& operator<<( CodeStream& os, const HLSL& hlsl ) { os << node->GetSymbol()->name; } - os << "( " << Indent() << Children( hlsl , ", " ) << Unindent() << " )"; + os << "( " << Indent() << Children( hlsl, ", " ) << Unindent() << " )"; break; case NT_FUNCTION_HEADER: if( !node->GetSymbol()->used ) @@ -913,8 +912,7 @@ CodeStream& operator<<( CodeStream& os, const HLSL& hlsl ) os << " = " << Child( 1 ); } break; - case NT_NAME_DECLARATION: - { + case NT_NAME_DECLARATION: { if( !node->GetSymbol()->used ) { break; @@ -1147,8 +1145,7 @@ CodeStream& operator<<( CodeStream& os, const HLSL& hlsl ) } os << ";" << Endl(); break; - case NT_CBUFFER: - { + case NT_CBUFFER: { if( !HasUsedDeclarations( node ) ) { break; @@ -1350,21 +1347,20 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) os << "( " << Child( 0 ) << " )"; switch( node->GetToken()->type ) { - case OP_LEFT_BRACKET: + case OP_LEFT_BRACKET: { + auto indexType = node->GetChild( 1 )->GetType(); + + if( indexType.IsScalarOrVector() && indexType.builtInType != OP_INT && indexType.builtInType != OP_UINT ) { - auto indexType = node->GetChild( 1 )->GetType(); - - if( indexType.IsScalarOrVector() && indexType.builtInType != OP_INT && indexType.builtInType != OP_UINT ) - { - indexType.builtInType = OP_INT; - os << "[(" << indexType << ")(" << Child( 1 ) << ")]"; - } - else - { - os << "[" << Child( 1 ) << "]"; - } + indexType.builtInType = OP_INT; + os << "[(" << indexType << ")(" << Child( 1 ) << ")]"; } - break; + else + { + os << "[" << Child( 1 ) << "]"; + } + } + break; case OP_DOT: os << "." << Child( 1 ); break; @@ -1378,7 +1374,7 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) break; case NT_EXPRESSION: os << "( " << Child( 0 ) << " )"; - if( node->GetToken()->type != OP_LEFT_PAREN ) + if( node->GetToken()->type != OP_LEFT_PAREN ) { os << " " << GetOperatorSymbol( node->GetToken()->type ) << " ( " << Child( 1 ) << " )"; } @@ -1394,7 +1390,7 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) else if( node->GetType().IsMatrix() && ( node->GetChild( 0 )->GetType().IsMatrix() || ( node->GetChild( 0 )->GetNodeType() == NT_POSTFIX_EXPRESSION && - node->GetChild( 0 )->GetChild( 1 )->GetType().IsMatrix() ) ) ) + node->GetChild( 0 )->GetChild( 1 )->GetType().IsMatrix() ) ) ) { os << "to_" << node->GetType() << "( " << Child( 0 ) << " )"; } @@ -1405,25 +1401,25 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) switch( symbol->addressSpace ) { case AddressSpace::Constant: - os << "constant "; - break; + os << "constant "; + break; case AddressSpace::Device: - os << "device "; - break; + os << "device "; + break; case AddressSpace::Thread: - os << "thread "; - break; + os << "thread "; + break; case AddressSpace::Threadgroup: - os << "threadgroup "; - break; + os << "threadgroup "; + break; default: - break; + break; } os << node->GetType(); for( int i = 0; i < node->GetType().arrayDimensions; ++i ) { - if ( node->GetType().IsBuffer() ) + if( node->GetType().IsBuffer() ) { switch( symbol->addressSpace ) { @@ -1451,7 +1447,6 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) } os << ")( " << Child( 0 ) << " )"; - } else { @@ -1534,8 +1529,7 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) os << " " << node->GetSymbol()->name << "( " << Indent() << Children( msl, ", " ) << Unindent() << " )"; os.Endl(); break; - case NT_FUNCTION_PARAMETER: - { + case NT_FUNCTION_PARAMETER: { // TODO #if 0 if( node->GetSymbol() ) @@ -1567,36 +1561,36 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) // Treat "out" and "inout" parameters as references. switch( node->GetToken()->type ) { - case OP_OUT: - case OP_INOUT: - // References need an address space. The default will be "thread". - if( symbol->addressSpace == AddressSpace::None ) - { - symbol->addressSpace = AddressSpace::Thread; - } - isReference = true; - break; + case OP_OUT: + case OP_INOUT: + // References need an address space. The default will be "thread". + if( symbol->addressSpace == AddressSpace::None ) + { + symbol->addressSpace = AddressSpace::Thread; + } + isReference = true; + break; } } switch( symbol->addressSpace ) { - case AddressSpace::Constant: - os << "constant "; - break; - case AddressSpace::Device: - os << "device "; - break; - case AddressSpace::Thread: - os << "thread "; - break; - case AddressSpace::Threadgroup: - os << "threadgroup "; - break; - case AddressSpace::RayData: - os << "ray_data "; - break; - default: - break; + case AddressSpace::Constant: + os << "constant "; + break; + case AddressSpace::Device: + os << "device "; + break; + case AddressSpace::Thread: + os << "thread "; + break; + case AddressSpace::Threadgroup: + os << "threadgroup "; + break; + case AddressSpace::RayData: + os << "ray_data "; + break; + default: + break; } // TODO: Do we need this? Child[2] is a primitive type for (unsupported) geometry shaders. #if 0 @@ -1669,7 +1663,7 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) if( isReference ) { // Don't need to add & for arrays. - if( node->GetType().arrayDimensions == 0) + if( node->GetType().arrayDimensions == 0 ) { os << '&'; } @@ -1743,8 +1737,7 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) } } break; - case NT_NAME_DECLARATION: - { + case NT_NAME_DECLARATION: { Symbol* symbol = node->GetSymbol(); if( !symbol->used ) { @@ -2031,32 +2024,31 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) os << Child( 1 ) << Endl(); } break; - case NT_SAMPLER_STATE_LIST: - { - if( node->m_extraData ) - { - StaticSampler* sampler = static_cast( node->m_extraData ); - os << '('; - os << "s_address::" << MSLAddressMode( sampler->addressU ); - os << ", " << "t_address::" << MSLAddressMode( sampler->addressV ); - os << ", " << "r_address::" << MSLAddressMode( sampler->addressW ); - os << ", " << "border_color::" << MSLBorderColor( sampler->borderColor ); - os << ", " << "mag_filter::" << MSLFilterMode( sampler->magFilter ); - os << ", " << "min_filter::" << MSLFilterMode( sampler->minFilter ); - os << ", " << "mip_filter::" << MSLMipFilterMode( sampler->mipFilter ); - os << ", " << "compare_func::" << MSLCompareFunc( sampler->comparisonFunc ); - if( sampler->minFilter == 3 || sampler->magFilter == 3 || sampler->mipFilter == 3 ) - { - os << ", " << "max_anisotropy(" << int( sampler->maxAnisotropy ) << ")"; - } - if( sampler->minLOD != -std::numeric_limits::max() || sampler->maxLOD != std::numeric_limits::max() ) - { - os << ", " << "lod_clamp(" << sampler->minLOD << ", " << sampler->maxLOD << ")"; - } - os << ')'; + case NT_SAMPLER_STATE_LIST: { + if( node->m_extraData ) + { + StaticSampler* sampler = static_cast( node->m_extraData ); + os << '('; + os << "s_address::" << MSLAddressMode( sampler->addressU ); + os << ", " << "t_address::" << MSLAddressMode( sampler->addressV ); + os << ", " << "r_address::" << MSLAddressMode( sampler->addressW ); + os << ", " << "border_color::" << MSLBorderColor( sampler->borderColor ); + os << ", " << "mag_filter::" << MSLFilterMode( sampler->magFilter ); + os << ", " << "min_filter::" << MSLFilterMode( sampler->minFilter ); + os << ", " << "mip_filter::" << MSLMipFilterMode( sampler->mipFilter ); + os << ", " << "compare_func::" << MSLCompareFunc( sampler->comparisonFunc ); + if( sampler->minFilter == 3 || sampler->magFilter == 3 || sampler->mipFilter == 3 ) + { + os << ", " << "max_anisotropy(" << int( sampler->maxAnisotropy ) << ")"; + } + if( sampler->minLOD != -std::numeric_limits::max() || sampler->maxLOD != std::numeric_limits::max() ) + { + os << ", " << "lod_clamp(" << sampler->minLOD << ", " << sampler->maxLOD << ")"; } + os << ')'; } - break; + } + break; case NT_STATE_ASSIGNMENT: os << node->GetToken()->stringValue << " = "; if( node->GetSymbol() ) @@ -2080,15 +2072,14 @@ CodeStream& operator<<( CodeStream& os, const MSL& msl ) case NT_FUNCTION_ATTRIBUTE_LIST: os << Children( msl, "" ); break; - case NT_FUNCTION_ATTRIBUTE: + case NT_FUNCTION_ATTRIBUTE: { + auto attrib = ToString( node->GetToken()->stringValue ); + if( attrib == "vertex" || attrib == "fragment" || attrib == "kernel" || ( attrib.length() > 4 && attrib.substr( 0, 2 ) == "[[" ) ) { - auto attrib = ToString( node->GetToken()->stringValue ); - if( attrib == "vertex" || attrib == "fragment" || attrib == "kernel" || ( attrib.length() > 4 && attrib.substr( 0, 2 ) == "[[") ) - { - os << ' ' << attrib << ' '; - } + os << ' ' << attrib << ' '; } - break; + } + break; case NT_FUNCTION_ATTRIBUTE_VALUE: case NT_PRIMITIVE_TYPE: os << node->GetToken()->stringValue; diff --git a/shadercompiler/OutputHLSL.h b/shadercompiler/OutputHLSL.h index 2462da227..8b5d0c9e9 100644 --- a/shadercompiler/OutputHLSL.h +++ b/shadercompiler/OutputHLSL.h @@ -15,9 +15,10 @@ enum class ShadingLanguage class CodeStream : public std::stringstream { public: - explicit CodeStream( const ShadingLanguage lang ) - : shadingLanguage( lang ) - {} + explicit CodeStream( const ShadingLanguage lang ) : + shadingLanguage( lang ) + { + } virtual void Endl() = 0; virtual void ChangeLocation( const FileLocation& location ) = 0; @@ -36,6 +37,7 @@ class CompilerInputStream : public CodeStream void ChangeLocation( const FileLocation& location ) override; void Indent() override; void Unindent() override; + private: ParserState& m_state; FileLocation m_location; @@ -54,9 +56,15 @@ inline CodeStream& operator<<( CodeStream& os, const FileLocation& location ) return os; } -struct Indent {}; -struct Unindent {}; -struct Endl {}; +struct Indent +{ +}; +struct Unindent +{ +}; +struct Endl +{ +}; inline CodeStream& operator<<( CodeStream& os, const Indent& ) { diff --git a/shadercompiler/ParserState.cpp b/shadercompiler/ParserState.cpp index 446e08fc4..6883c82b1 100644 --- a/shadercompiler/ParserState.cpp +++ b/shadercompiler/ParserState.cpp @@ -15,20 +15,20 @@ extern CompileMessageQueue g_messages; -void *ParseAlloc( void *(*mallocProc)(size_t) ); -void ParseFree( void *p, void (*freeProc)(void*) ); -void Parse( void *yyp, int yymajor, ScannerToken token, ParserState* state ); -void ParseTrace(FILE *TraceFILE, char *zTracePrompt); +void* ParseAlloc( void* ( *mallocProc )(size_t)); +void ParseFree( void* p, void ( *freeProc )( void* ) ); +void Parse( void* yyp, int yymajor, ScannerToken token, ParserState* state ); +void ParseTrace( FILE* TraceFILE, char* zTracePrompt ); -void *PreprocessorParseAlloc( void *(*mallocProc)(size_t) ); -void PreprocessorParseFree( void *p, void (*freeProc)(void*) ); -void PreprocessorParse( void *yyp, int yymajor, ScannerToken token, ParserState* state ); -void PreprocessorParseTrace(FILE *TraceFILE, char *zTracePrompt); +void* PreprocessorParseAlloc( void* ( *mallocProc )(size_t)); +void PreprocessorParseFree( void* p, void ( *freeProc )( void* ) ); +void PreprocessorParse( void* yyp, int yymajor, ScannerToken token, ParserState* state ); +void PreprocessorParseTrace( FILE* TraceFILE, char* zTracePrompt ); ScannerToken ScannerToken::ID( const InlineString& value, const FileLocation& location ) { - return { OP_ID, 0, value, location }; + return { OP_ID, 0, value, location }; } ScannerToken ScannerToken::FromTokenType( int type, const FileLocation& location ) @@ -188,16 +188,24 @@ void ParserState::AddIntrinsics() table, "TraceRay", &FunctionDescription8< - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1>, - TypeIs, DimIs<1, 1> - > ); + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>, + TypeIs, + DimIs<1, 1>> ); m_dx9TextureFunctions.insert( AddFunction( table, "tex1D", &FunctionDescription4, DimIs<4, 1>, TypeIs, DimIs<1, 1>, TypeIs, DimIs<1, 1>, TypeIs, DimIs<1, 1>, TypeIs, DimIs<1, 1>> ) ); m_dx9TextureFunctions.insert( AddFunction( table, "tex1Dbias", &FunctionDescription2, DimIs<4, 1>, TypeIs, DimIs<1, 1>, TypeIs, DimIs<4, 1>> ) ); @@ -237,8 +245,8 @@ void ParserState::AddIntrinsics() } -ParserState::ParserState( const InlineString& code ) - :m_newLine( true ), +ParserState::ParserState( const InlineString& code ) : + m_newLine( true ), m_mode( HLSL ), m_expandMacros( true ), m_symbols( nullptr ), @@ -278,8 +286,8 @@ ParserState::~ParserState() } } -extern PreprocessorScanResult GetPreprocessorToken( ParserState &state, PreprocessorToken& token ); -extern bool ConvertToScannerToken( ParserState &state, const PreprocessorToken& ppToken, ScannerToken& token ); +extern PreprocessorScanResult GetPreprocessorToken( ParserState& state, PreprocessorToken& token ); +extern bool ConvertToScannerToken( ParserState& state, const PreprocessorToken& ppToken, ScannerToken& token ); bool ParserState::ParseMacroArguments( std::vector& arguments ) { @@ -490,8 +498,7 @@ PreprocessorScanResult ParserState::GetPreprocessorToken( PreprocessorToken& tok return code; } concatToken.append( nextToken.string.start, nextToken.string.end ); - } - while( FindConcatOperator( depth ) ); + } while( FindConcatOperator( depth ) ); char* string = AllocateString( concatToken.length() + 1 ); memcpy( string, concatToken.c_str(), concatToken.length() ); string[concatToken.length()] = 0; @@ -514,17 +521,16 @@ bool IsPermutationPragma( const std::string& pragma ) bool GetPermutationInfo( const std::string& pragma, Permutation& permutation ) { const std::regex permutationExpr( "permutation[[:space:]]*\\([[:space:]]*" - "([[:alpha:]_][[:alnum:]_]*)[[:space:]]*,[[:space:]]*" - "(?:values[[:space:]]*=[[:space:]]*)?" - "\\([[:space:]]*" - "([[:alpha:]_][[:alnum:]_]*[[:space:]]*(?:=[[:space:]]*[[:digit:]]+[[:space:]]*)?" - "(?:,[[:space:]]*[[:alpha:]_][[:alnum:]_]*[[:space:]]*(?:=[[:space:]]*[[:digit:]]+[[:space:]]*)?)+)" - "[[:space:]]*\\)" - "(?:[[:space:]]*,[[:space:]]*(?:default[[:space:]]*=[[:space:]]*)?([[:alpha:]_][[:alnum:]_]*))?" - "(?:[[:space:]]*,[[:space:]]*(?:description[[:space:]]*=[[:space:]]*)?\"([^\"]*)\")?" - "(?:[[:space:]]*,[[:space:]]*(?:type[[:space:]]*=[[:space:]]*)?([[:alpha:]_][[:alnum:]_]*))?" - "[[:space:]]*\\)[[:space:]]*" - ); + "([[:alpha:]_][[:alnum:]_]*)[[:space:]]*,[[:space:]]*" + "(?:values[[:space:]]*=[[:space:]]*)?" + "\\([[:space:]]*" + "([[:alpha:]_][[:alnum:]_]*[[:space:]]*(?:=[[:space:]]*[[:digit:]]+[[:space:]]*)?" + "(?:,[[:space:]]*[[:alpha:]_][[:alnum:]_]*[[:space:]]*(?:=[[:space:]]*[[:digit:]]+[[:space:]]*)?)+)" + "[[:space:]]*\\)" + "(?:[[:space:]]*,[[:space:]]*(?:default[[:space:]]*=[[:space:]]*)?([[:alpha:]_][[:alnum:]_]*))?" + "(?:[[:space:]]*,[[:space:]]*(?:description[[:space:]]*=[[:space:]]*)?\"([^\"]*)\")?" + "(?:[[:space:]]*,[[:space:]]*(?:type[[:space:]]*=[[:space:]]*)?([[:alpha:]_][[:alnum:]_]*))?" + "[[:space:]]*\\)[[:space:]]*" ); const std::regex valueExpr( "[[:space:]]*(?:,[[:space:]]*)?([[:alpha:]_][[:alnum:]_]*)(?:[[:space:]]*=[[:space:]]*([[:digit:]]+))?" ); std::smatch match; @@ -637,19 +643,18 @@ bool ParserState::DiscoverPermutations( Permutations& permutations ) { case PPSR_ERROR: break; - case PPSR_EOF: + case PPSR_EOF: { + if( m_fileStack.size() > 1 ) { - if( m_fileStack.size() > 1 ) - { - m_fileStack.pop_back(); - } - else - { - done = true; - break; - } + m_fileStack.pop_back(); } - break; + else + { + done = true; + break; + } + } + break; case PPSR_OK: ConvertToScannerToken( *this, ppToken, token ); break; @@ -684,7 +689,7 @@ bool ParserState::Parse() void* parser = ParseAlloc( malloc ); m_symbols->EnterScope(); - + ScannerToken token; bool done = false; @@ -697,19 +702,18 @@ bool ParserState::Parse() case PPSR_ERROR: ParseFree( parser, free ); return false; - case PPSR_EOF: + case PPSR_EOF: { + if( m_fileStack.size() > 1 ) { - if( m_fileStack.size() > 1 ) - { - m_fileStack.pop_back(); - } - else - { - done = true; - break; - } + m_fileStack.pop_back(); } - break; + else + { + done = true; + break; + } + } + break; case PPSR_OK: if( !ConvertToScannerToken( *this, ppToken, token ) ) { @@ -800,16 +804,15 @@ PreprocessorScanResult ParserState::EvaluatePreprocessorCondition( const InlineS { case PPSR_ERROR: return PPSR_ERROR; - case PPSR_EOF: + case PPSR_EOF: { + m_fileStack.pop_back(); + if( m_fileStack.size() == depth ) { - m_fileStack.pop_back(); - if( m_fileStack.size() == depth ) - { - done = true; - break; - } + done = true; + break; } - break; + } + break; case PPSR_OK: if( !ConvertToScannerToken( *this, ppToken, token ) ) { @@ -858,7 +861,7 @@ FileLocation& ParserState::GetCurrentLocation() InlineString ParserState::AllocateName() { - const char *format = "_new_symbol_%04i"; + const char* format = "_new_symbol_%04i"; size_t len = strlen( format ) + 1; char* newName = new char[len]; #if _WIN32 @@ -893,7 +896,7 @@ InlineString ParserState::AllocateName( const InlineString& name ) #else std::strncpy( newName, name.start, len - 1 ); #endif - newName[ len - 1 ] = '\0'; + newName[len - 1] = '\0'; m_strings.push_back( newName ); return MakeInlineString( newName, newName + len - 1 ); @@ -901,7 +904,7 @@ InlineString ParserState::AllocateName( const InlineString& name ) InlineString ParserState::AllocateNameWithPrefix( const char* prefix ) { - const char *format = "__%s_%04i"; + const char* format = "__%s_%04i"; size_t len = strlen( format ) - 2 + strlen( prefix ) + 1; char* newName = new char[len]; #if _WIN32 @@ -915,7 +918,7 @@ InlineString ParserState::AllocateNameWithPrefix( const char* prefix ) InlineString ParserState::AllocateNameWithPrefix( const InlineString& prefix ) { - const char *format = "__%s_%04i"; + const char* format = "__%s_%04i"; size_t len = strlen( format ) - 2 + ( prefix.end - prefix.start ) + 1; char* newName = new char[len]; #if _WIN32 @@ -1147,12 +1150,11 @@ void ParserState::ShowMessageImpl( const FileLocation& location, int32_t errorCo char buffer1[2048], buffer2[2048]; std::string fileName( location.fileName.start, location.fileName.end ); - if( errorCode == EC_REGISTER_ASSIGNMENT_DEPRECATED || - errorCode == EC_MISMATCHED_TEXTURE_TYPE || + if( errorCode == EC_REGISTER_ASSIGNMENT_DEPRECATED || + errorCode == EC_MISMATCHED_TEXTURE_TYPE || errorCode == EC_STATE_DEPRECATED || errorCode == EC_SAMPLER_WITHOUT_TEXTURE || - errorCode == EC_CUSTOM_WARNING - ) + errorCode == EC_CUSTOM_WARNING ) { #if _WIN32 sprintf_s( buffer1, "%s(%i): warning t%i: ", fileName.c_str(), location.lineNumber, errorCode + 1000 ); @@ -1169,16 +1171,16 @@ void ParserState::ShowMessageImpl( const FileLocation& location, int32_t errorCo #endif m_hasErrors = true; } - - const char* format; + + const char* format; if( errorCode == EC_CUSTOM_ERROR || errorCode == EC_CUSTOM_WARNING ) - { - format = va_arg( args, const char* ); - } - else - { - format = errorMessages[errorCode]; - } + { + format = va_arg( args, const char* ); + } + else + { + format = errorMessages[errorCode]; + } #if _WIN32 vsprintf_s( buffer2, format, args ); #else @@ -1192,12 +1194,12 @@ void ParserState::ShowMessageImpl( const FileLocation& location, int32_t errorCo ASTNode* ParserState::NewNode( int nodeType ) { - return new ASTNode( ASTNodeType( nodeType ), GetCurrentLocation(), GetSymbolTable().GetCurrentScope(), nullptr ); + return new ASTNode( ASTNodeType( nodeType ), GetCurrentLocation(), GetSymbolTable().GetCurrentScope(), nullptr ); } ASTNode* ParserState::NewNode( int nodeType, const ScannerToken& token ) { - return new ASTNode( ASTNodeType( nodeType ), GetCurrentLocation(), GetSymbolTable().GetCurrentScope(), &token ); + return new ASTNode( ASTNodeType( nodeType ), GetCurrentLocation(), GetSymbolTable().GetCurrentScope(), &token ); } void ParserState::AddBindlessSampler( const Symbol* name, ASTNode* definition ) diff --git a/shadercompiler/ParserUtils.cpp b/shadercompiler/ParserUtils.cpp index ae7f6b9f2..d42566e00 100644 --- a/shadercompiler/ParserUtils.cpp +++ b/shadercompiler/ParserUtils.cpp @@ -112,12 +112,11 @@ std::string ParseString( const InlineString& string ) case '4': case '5': case '6': - case '7': - { - long code = ParseNumber( c, string.end, 8 ); - result.append( 1, static_cast( code ) ); - } - break; + case '7': { + long code = ParseNumber( c, string.end, 8 ); + result.append( 1, static_cast( code ) ); + } + break; case 'x': case 'X': if( isxdigit( c[2] ) ) @@ -187,7 +186,7 @@ void MarkUsedSymbols( ASTNode* entryPoint, SymbolTable& symbols ) } // "Globals" struct is a special case and we don't want to mark all of it's members // as "used" automatically. - if( !(entryPoint->GetNodeType() == NT_STRUCT && entryPoint->GetSymbol()->name == globalsStructName ) && entryPoint->GetNodeType() != NT_SAMPLER_STATE_LIST ) + if( !( entryPoint->GetNodeType() == NT_STRUCT && entryPoint->GetSymbol()->name == globalsStructName ) && entryPoint->GetNodeType() != NT_SAMPLER_STATE_LIST ) { for( size_t i = 0; i < entryPoint->GetChildrenCount(); ++i ) { @@ -204,10 +203,10 @@ void MarkUsedSymbols( ASTNode* entryPoint, SymbolTable& symbols ) } if( entryPoint->GetSymbol() ) { - if( entryPoint->GetSymbol()->definition ) - { - MarkUsedSymbols( entryPoint->GetSymbol()->definition, symbols ); - } + if( entryPoint->GetSymbol()->definition ) + { + MarkUsedSymbols( entryPoint->GetSymbol()->definition, symbols ); + } if( entryPoint->GetSymbol()->type.symbol && entryPoint->GetSymbol()->type.symbol->definition ) { MarkUsedSymbols( entryPoint->GetSymbol()->type.symbol->definition, symbols ); @@ -440,9 +439,9 @@ bool ComputeMemberType( const Type& leftType, const InlineString& member, Type& int swizzleSet = 0; for( const char* c = member.start; c != member.end; ++c ) { - const char *set1 = "xyzw"; - const char *set2 = "rgba"; - if( const char *pos = strchr( set1, *c ) ) + const char* set1 = "xyzw"; + const char* set2 = "rgba"; + if( const char* pos = strchr( set1, *c ) ) { if( swizzleSet == 2 ) { @@ -454,7 +453,7 @@ bool ComputeMemberType( const Type& leftType, const InlineString& member, Type& } swizzleSet = 1; } - else if( const char *pos2 = strchr( set2, *c ) ) + else if( const char* pos2 = strchr( set2, *c ) ) { if( swizzleSet == 1 ) { @@ -479,7 +478,7 @@ bool ComputeMemberType( const Type& leftType, const InlineString& member, Type& } -static ASTNode* AddCBuffer( ParserState& state, ASTNode* node, int cbufferIndex, ASTNode*&shadowStruct ) +static ASTNode* AddCBuffer( ParserState& state, ASTNode* node, int cbufferIndex, ASTNode*& shadowStruct ) { shadowStruct = nullptr; @@ -561,7 +560,7 @@ int GetCBufferIndex( const Symbol* symbol ) return GetCBufferIndex( symbol->name ); } -static void PatchCBuffers( ParserState& state, ASTNode* parent, unsigned &index ) +static void PatchCBuffers( ParserState& state, ASTNode* parent, unsigned& index ) { ASTNode* node = parent->GetChild( index ); if( node == nullptr ) @@ -616,132 +615,171 @@ bool IsUniformInputArgument( ASTNode* argument ) namespace { - struct Registers +struct Registers +{ + std::set b; + std::set t; + std::set s; + std::set u; + std::set spaces; +}; + +std::set* GetRegisterSet( Registers& registers, char specifier ) +{ + switch( specifier ) { - std::set b; - std::set t; - std::set s; - std::set u; - std::set spaces; - }; + case 'b': + return ®isters.b; + case 't': + return ®isters.t; + case 's': + return ®isters.s; + case 'u': + return ®isters.u; + default: + return nullptr; + } +} - std::set* GetRegisterSet( Registers& registers, char specifier ) +bool DoesProfileMatchStage( const InlineString& profile, InputStageType stage ) +{ + if( profile == MakeInlineString( "" ) ) { - switch( specifier ) - { - case 'b': - return ®isters.b; - case 't': - return ®isters.t; - case 's': - return ®isters.s; - case 'u': - return ®isters.u; - default: - return nullptr; - } + return true; } - - bool DoesProfileMatchStage( const InlineString& profile, InputStageType stage ) + switch( stage ) { - if( profile == MakeInlineString( "" ) ) - { - return true; - } - switch( stage ) - { - case VERTEX_STAGE: - return profile == MakeInlineString( "vs" ); - case PIXEL_STAGE: - return profile == MakeInlineString( "ps" ); - case COMPUTE_STAGE: - return profile == MakeInlineString( "cs" ); - case GEOMETRY_STAGE: - return profile == MakeInlineString( "gs" ); - case HULL_STAGE: - return profile == MakeInlineString( "hs" ); - case DOMAIN_STAGE: - return profile == MakeInlineString( "ds" ); - default: - return false; - } + case VERTEX_STAGE: + return profile == MakeInlineString( "vs" ); + case PIXEL_STAGE: + return profile == MakeInlineString( "ps" ); + case COMPUTE_STAGE: + return profile == MakeInlineString( "cs" ); + case GEOMETRY_STAGE: + return profile == MakeInlineString( "gs" ); + case HULL_STAGE: + return profile == MakeInlineString( "hs" ); + case DOMAIN_STAGE: + return profile == MakeInlineString( "ds" ); + default: + return false; } +} - int AllocateRegister( std::set& set ) +int AllocateRegister( std::set& set ) +{ + for( int i = 0;; ++i ) { - for( int i = 0; ; ++i ) + auto inserted = set.insert( i ); + if( inserted.second ) { - auto inserted = set.insert( i ); - if( inserted.second ) - { - return i; - } + return i; } } +} - char GetRegisterType( const Type& type ) +char GetRegisterType( const Type& type ) +{ + if( type.symbol ) { - if( type.symbol ) - { - return 0; - } - switch( type.builtInType ) - { - case OP_SAMPLER2D: - case OP_SAMPLER3D: - case OP_SAMPLERCUBE: - case OP_SAMPLER: - case OP_SAMPLERCOMPARISON: - return 's'; - case OP_TEXTURE1D: - case OP_TEXTURE2D: - case OP_TEXTURE3D: - case OP_TEXTURECUBE: - case OP_TEXTURE1DARRAY: - case OP_TEXTURE2DARRAY: - case OP_TEXTURE3DARRAY: - case OP_TEXTURECUBEARRAY: - case OP_TEXTURE2DMS: - case OP_TEXTURE2DMSARRAY: - case OP_TEXTURE: - case OP_BUFFER: - case OP_STRUCTUREDBUFFER: - case OP_RAYTRACING_ACCELERATION_STRUCTURE: - case OP_BYTEADDRESSBUFFER: - return 't'; - case OP_APPENDSTRUCTUREDBUFFER: - case OP_CONSUMESTRUCTUREDBUFFER: - case OP_RWBUFFER: - case OP_RWBYTEADDRESSBUFFER: - case OP_RWSTRUCTUREDBUFFER: - case OP_RWTEXTURE1D: - case OP_RWTEXTURE1DARRAY: - case OP_RWTEXTURE2D: - case OP_RWTEXTURE2DARRAY: - case OP_RWTEXTURE3D: - case OP_RWTEXTURE3DARRAY: - return 'u'; - default: - return 0; - } + return 0; } - - bool SymbolMatchesGlobalInput( const Symbol& symbol, const GlobalInputElement& element ) + switch( type.builtInType ) { - return symbol.name == element.name && symbol.type == element.type; + case OP_SAMPLER2D: + case OP_SAMPLER3D: + case OP_SAMPLERCUBE: + case OP_SAMPLER: + case OP_SAMPLERCOMPARISON: + return 's'; + case OP_TEXTURE1D: + case OP_TEXTURE2D: + case OP_TEXTURE3D: + case OP_TEXTURECUBE: + case OP_TEXTURE1DARRAY: + case OP_TEXTURE2DARRAY: + case OP_TEXTURE3DARRAY: + case OP_TEXTURECUBEARRAY: + case OP_TEXTURE2DMS: + case OP_TEXTURE2DMSARRAY: + case OP_TEXTURE: + case OP_BUFFER: + case OP_STRUCTUREDBUFFER: + case OP_RAYTRACING_ACCELERATION_STRUCTURE: + case OP_BYTEADDRESSBUFFER: + return 't'; + case OP_APPENDSTRUCTUREDBUFFER: + case OP_CONSUMESTRUCTUREDBUFFER: + case OP_RWBUFFER: + case OP_RWBYTEADDRESSBUFFER: + case OP_RWSTRUCTUREDBUFFER: + case OP_RWTEXTURE1D: + case OP_RWTEXTURE1DARRAY: + case OP_RWTEXTURE2D: + case OP_RWTEXTURE2DARRAY: + case OP_RWTEXTURE3D: + case OP_RWTEXTURE3DARRAY: + return 'u'; + default: + return 0; } +} - void AssignRegisters( ASTNode* root, InputStageType stage, Registers& registers, const std::vector& globalInput, std::vector& globalInputRegisters ) +bool SymbolMatchesGlobalInput( const Symbol& symbol, const GlobalInputElement& element ) +{ + return symbol.name == element.name && symbol.type == element.type; +} + +void AssignRegisters( ASTNode* root, InputStageType stage, Registers& registers, const std::vector& globalInput, std::vector& globalInputRegisters ) +{ + if( !root ) + { + return; + } + switch( root->GetNodeType() ) { - if( !root ) + case NT_CBUFFER: + if( root->GetSymbol()->used ) + { + bool assigned = false; + for( auto& r : root->GetSymbol()->registerSpecifier ) + { + if( r.second.explicitRegister && DoesProfileMatchStage( r.first, stage ) ) + { + assigned = true; + break; + } + } + if( !assigned ) + { + RegisterSpecifier r; + r.shaderProfile = MakeInlineString( "" ); + r.registerType = 'b'; + r.registerNumber = AllocateRegister( registers.b ); + r.subComponent = -1; + r.space = 0; + r.explicitRegister = false; + r.explicitSpace = false; + root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; + } + } + break; + case NT_NAME_DECLARATION: + if( !root->GetSymbol()->used ) { return; } - switch( root->GetNodeType() ) + if( auto registerType = GetRegisterType( root->GetSymbol()->type ) ) { - case NT_CBUFFER: - if( root->GetSymbol()->used ) + auto globalElement = std::find_if( begin( globalInput ), end( globalInput ), [symbol = root->GetSymbol()]( const auto& element ) { return SymbolMatchesGlobalInput( *symbol, element ); } ); + if( globalElement != end( globalInput ) ) { + auto& r = globalInputRegisters[globalElement - begin( globalInput )]; + root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; + } + else + { + bool assigned = false; for( auto& r : root->GetSymbol()->registerSpecifier ) { @@ -753,83 +791,44 @@ namespace } if( !assigned ) { + bool isArray = root->GetChildOrNull( 0 ) && root->GetChildOrNull( 0 )->GetNodeType() == NT_BRACKET_LIST; + RegisterSpecifier r; r.shaderProfile = MakeInlineString( "" ); - r.registerType = 'b'; - r.registerNumber = AllocateRegister( registers.b ); - r.subComponent = -1; - r.space = 0; - r.explicitRegister = false; - r.explicitSpace = false; - root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; - } - } - break; - case NT_NAME_DECLARATION: - if( !root->GetSymbol()->used ) - { - return; - } - if( auto registerType = GetRegisterType( root->GetSymbol()->type ) ) - { - auto globalElement = std::find_if( begin( globalInput ), end( globalInput ), [symbol = root->GetSymbol()]( const auto& element ) { return SymbolMatchesGlobalInput( *symbol, element ); } ); - if ( globalElement != end( globalInput ) ) - { - auto& r = globalInputRegisters[globalElement - begin( globalInput )]; - root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; - } - else - { - - bool assigned = false; - for( auto& r : root->GetSymbol()->registerSpecifier ) + r.registerType = registerType; + r.registerNumber = AllocateRegister( *GetRegisterSet( registers, registerType ) ); + if( isArray ) { - if( r.second.explicitRegister && DoesProfileMatchStage( r.first, stage ) ) - { - assigned = true; - break; - } + r.space = AllocateRegister( registers.spaces ); } - if( !assigned ) + else { - bool isArray = root->GetChildOrNull( 0 ) && root->GetChildOrNull( 0 )->GetNodeType() == NT_BRACKET_LIST; - - RegisterSpecifier r; - r.shaderProfile = MakeInlineString( "" ); - r.registerType = registerType; - r.registerNumber = AllocateRegister( *GetRegisterSet( registers, registerType ) ); - if( isArray ) - { - r.space = AllocateRegister( registers.spaces ); - } - else - { - r.space = 0; - } - r.subComponent = -1; - r.explicitRegister = false; - r.explicitSpace = false; - root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; + r.space = 0; } + r.subComponent = -1; + r.explicitRegister = false; + r.explicitSpace = false; + root->GetSymbol()->registerSpecifier[r.shaderProfile] = r; } } - break; - case NT_PROGRAM: - case NT_VAR_DECLARATION_LIST: - for( size_t i = 0; i < root->GetChildrenCount(); ++i ) - { - AssignRegisters( root->GetChild( i ), stage, registers, globalInput, globalInputRegisters ); - } - break; - default: - break; } + break; + case NT_PROGRAM: + case NT_VAR_DECLARATION_LIST: + for( size_t i = 0; i < root->GetChildrenCount(); ++i ) + { + AssignRegisters( root->GetChild( i ), stage, registers, globalInput, globalInputRegisters ); + } + break; + default: + break; } } +} void AssignGlobalInputRegisters( const std::vector& globalInput, Registers& registers, std::vector& globalInputRegisters ) { - for ( auto& input : globalInput ) + for( auto& input : globalInput ) { if( auto registerType = GetRegisterType( input.type ) ) { @@ -852,7 +851,7 @@ void AssignGlobalInputRegisters( const std::vector& globalIn r.explicitSpace = false; globalInputRegisters.push_back( r ); } - else if ( input.declaration && input.declaration->GetNodeType() == NT_CBUFFER ) + else if( input.declaration && input.declaration->GetNodeType() == NT_CBUFFER ) { bool assigned = false; for( auto& r : input.declaration->GetSymbol()->registerSpecifier ) @@ -944,12 +943,11 @@ void SortProgramNodes( ASTNode* root ) std::stable_sort( root->GetChildren().begin(), root->GetChildren().end(), - []( ASTNode* a, ASTNode* b ) -> bool - { - auto pA = GetNodeOrder( a ); - auto pB = GetNodeOrder( b ); - return pA < pB; - } ); + []( ASTNode* a, ASTNode* b ) -> bool { + auto pA = GetNodeOrder( a ); + auto pB = GetNodeOrder( b ); + return pA < pB; + } ); } void CreateGlobalsCB( ParserState& state ) @@ -1064,24 +1062,24 @@ ASTNode* NewVarIdentifier( ParserState& state, Symbol* var ) ASTNode* NewLiteralConst( ParserState& state, float value ) { ScannerToken token = { OP_FLOAT, 0, state.AllocateName( std::to_string( value ).c_str() ), {} }; - auto result = state.NewNode(NT_CONSTANT, token ); + auto result = state.NewNode( NT_CONSTANT, token ); result->SetType( TypeFromTokenType( OP_FLOAT ) ); return result; } ASTNode* NewLiteralConst( ParserState& state, uint32_t value ) { - ScannerToken token = { OP_UINT, 0, state.AllocateName( std::to_string( value ).c_str() ), {} }; - auto result = state.NewNode( NT_CONSTANT, token ); - result->SetType( TypeFromTokenType( OP_UINT ) ); - return result; + ScannerToken token = { OP_UINT, 0, state.AllocateName( std::to_string( value ).c_str() ), {} }; + auto result = state.NewNode( NT_CONSTANT, token ); + result->SetType( TypeFromTokenType( OP_UINT ) ); + return result; } ASTNode* NewLiteralConst( ParserState& state, bool value ) { - auto result = state.NewNode( NT_CONSTANT, { OP_BOOL_CONST, 1, MakeInlineString( value ? "true" : "false" ), {} } ); - result->SetType( hlsl::bool_t ); - return result; + auto result = state.NewNode( NT_CONSTANT, { OP_BOOL_CONST, 1, MakeInlineString( value ? "true" : "false" ), {} } ); + result->SetType( hlsl::bool_t ); + return result; } ASTNode* NewDot( ParserState& state, ASTNode* expr, Symbol* field ) @@ -1158,41 +1156,41 @@ ASTNode* NewVarDeclaration( ParserState& state, const Type& type, const InlineSt ASTNode* NewVarDeclaration( ParserState& state, Symbol* symbol, ASTNode* initializer ) { - auto nameDecl = state.NewNode( NT_NAME_DECLARATION ); - nameDecl->SetSymbol( symbol ); - nameDecl->SetType( symbol->type ); - - auto declList = state.NewNode( NT_VAR_DECLARATION_LIST ); - declList->AddChild( nameDecl ); - declList->SetType( symbol->type ); - - if( initializer ) - { - nameDecl->AddChild( nullptr ); - nameDecl->AddChild( initializer ); - } - return declList; + auto nameDecl = state.NewNode( NT_NAME_DECLARATION ); + nameDecl->SetSymbol( symbol ); + nameDecl->SetType( symbol->type ); + + auto declList = state.NewNode( NT_VAR_DECLARATION_LIST ); + declList->AddChild( nameDecl ); + declList->SetType( symbol->type ); + + if( initializer ) + { + nameDecl->AddChild( nullptr ); + nameDecl->AddChild( initializer ); + } + return declList; } ASTNode* NewFunctionCall( ParserState& state, const Type& type, const char* name, const std::vector& args ) { - ScannerToken token = ScannerToken::ID( MakeInlineString( name ) ); - auto ctr = state.NewNode( NT_FUNCTION_CALL ); - ctr->SetToken( &token ); - ctr->SetType( type ); - for( auto arg : args ) - { - ctr->AddChild( arg ); - } - return ctr; + ScannerToken token = ScannerToken::ID( MakeInlineString( name ) ); + auto ctr = state.NewNode( NT_FUNCTION_CALL ); + ctr->SetToken( &token ); + ctr->SetType( type ); + for( auto arg : args ) + { + ctr->AddChild( arg ); + } + return ctr; } ASTNode* NewCastExpression( ParserState& state, const Type& type, ASTNode* child ) { - auto cast = state.NewNode( NT_CAST_EXPRESSION ); - cast->SetType( type ); - cast->AddChild( child ); - return cast; + auto cast = state.NewNode( NT_CAST_EXPRESSION ); + cast->SetType( type ); + cast->AddChild( child ); + return cast; } ASTNode* NewExpressionStatement( ParserState& state, ASTNode* expr ) @@ -1220,7 +1218,7 @@ ASTNode* NewFunctionParameter( ParserState& state, const Type& type, const Inlin symbol->definition = param; param->SetType( symbol->type ); param->SetSymbol( symbol ); - if (type.arrayDimensions) + if( type.arrayDimensions ) { auto brackets = state.NewNode( NT_BRACKET_LIST ); brackets->AddChild( nullptr ); @@ -1236,14 +1234,14 @@ ASTNode* NewFunctionParameter( ParserState& state, const Type& type, const Inlin ASTNode* NewFunctionParameter( ParserState& state, const Type& type, const char* name ) { - return NewFunctionParameter( state, type, state.AllocateName( name ) ); + return NewFunctionParameter( state, type, state.AllocateName( name ) ); } ASTNode* NewFunctionParameter( ParserState& state, const Type& type, const char* name, const RegisterSpecifier& reg ) { - auto arg = NewFunctionParameter( state, type, state.AllocateName( name ) ); - arg->GetSymbol()->registerSpecifier[MakeInlineString( "" )] = reg; - return arg; + auto arg = NewFunctionParameter( state, type, state.AllocateName( name ) ); + arg->GetSymbol()->registerSpecifier[MakeInlineString( "" )] = reg; + return arg; } std::optional PreprocessString( const InlineString& input ); @@ -1253,13 +1251,13 @@ std::optional> TokenizeGlobalInput( const InlineString std::optional> ParseGlobalInput( ParserState& state, const ScannerToken& input ) { auto processed = PreprocessString( input.stringValue ); - if ( !processed ) + if( !processed ) { return {}; } auto tokens = TokenizeGlobalInput( { processed->c_str(), processed->c_str() + processed->size() } ); - if ( !tokens ) + if( !tokens ) { state.ShowMessage( input.fileLocation, EC_CUSTOM_ERROR, "Malformed globalinput string" ); return {}; @@ -1270,8 +1268,8 @@ std::optional> ParseGlobalInput( ParserState& st { auto symbol = state.GetSymbolTable().LookupGlobal( ToString( name ).c_str() ); bool isCBuffer = false; - bool useCBuffers = false; - if ( useCBuffers ) + bool useCBuffers = false; + if( useCBuffers ) { if( symbol && symbol->type.IsStruct() ) { @@ -1282,7 +1280,6 @@ std::optional> ParseGlobalInput( ParserState& st symbol = state.GetSymbolTable().LookupBuffer( name ); isCBuffer = true; } - } else { @@ -1296,7 +1293,7 @@ std::optional> ParseGlobalInput( ParserState& st isCBuffer = true; } } - if ( !symbol ) + if( !symbol ) { state.ShowMessage( input.fileLocation, EC_UNDECLARED_IDENTIFIER, ToString( name ).c_str() ); return {}; diff --git a/shadercompiler/ShaderCompiler.cpp b/shadercompiler/ShaderCompiler.cpp index 7b5ea7598..294755c73 100644 --- a/shadercompiler/ShaderCompiler.cpp +++ b/shadercompiler/ShaderCompiler.cpp @@ -245,8 +245,8 @@ bool DiscoverPermutations( Permutations& permutations, const char* shaderSource, struct ProgramArguments { - ProgramArguments() - :shaderPath( nullptr ), + ProgramArguments() : + shaderPath( nullptr ), outputPath( nullptr ), pdbPath( nullptr ), coreCount( std::max( 1u, std::thread::hardware_concurrency() ) ), @@ -256,7 +256,6 @@ struct ProgramArguments ignorePermutations( false ), telemetry( false ) { - } char* shaderPath; @@ -501,7 +500,8 @@ void AddPermutationsToWorkQueue( CompileQueue& queue, const Permutations& permut struct WithTelemetry { #if CCP_TELEMETRY_ENABLED - explicit WithTelemetry( bool enable ) : m_enabled(enable) + explicit WithTelemetry( bool enable ) : + m_enabled( enable ) { if( !enable ) { @@ -514,7 +514,7 @@ struct WithTelemetry ~WithTelemetry() { - if ( m_enabled ) + if( m_enabled ) { FrameMark; #if TRACY_MANUAL_LIFETIME @@ -523,8 +523,8 @@ struct WithTelemetry } } - private: - bool m_enabled{false}; +private: + bool m_enabled{ false }; #else explicit WithTelemetry( bool ) { @@ -580,9 +580,9 @@ LONG WINAPI ReportException( _In_ EXCEPTION_POINTERS* ) #if _WIN32 -int _tmain(int argc, _TCHAR* argv[]) +int _tmain( int argc, _TCHAR* argv[] ) #else -int main(int argc, char* argv[]) +int main( int argc, char* argv[] ) #endif { @@ -654,7 +654,8 @@ int main(int argc, char* argv[]) { for( auto jt = it->options.begin(); jt != it->options.end(); ++jt ) { - os << "#line " << it->location.lineNumber << std::endl << "#define " << jt->name << ' ' << jt->value << std::endl; + os << "#line " << it->location.lineNumber << std::endl + << "#define " << jt->name << ' ' << jt->value << std::endl; } } os << "#line 1" << std::endl; @@ -822,7 +823,7 @@ int main(int argc, char* argv[]) fwrite( &version, 1, sizeof( uint32_t ), file ); fwrite( &ShaderCompilerVersion, sizeof( ShaderCompilerVersion ), 1, file ); - + auto hash = GetSourceHash( args.shaderPath, args.defines ); fwrite( hash.c_str(), 1, hash.length(), file ); @@ -850,7 +851,7 @@ int main(int argc, char* argv[]) { if( it->second ) { - for ( const auto& pdb : it->second->data.pdbs ) + for( const auto& pdb : it->second->data.pdbs ) { // Open the output pdbFile FILE* pdbFile = nullptr; diff --git a/shadercompiler/StringTable.cpp b/shadercompiler/StringTable.cpp index 8d42fd903..de0456498 100644 --- a/shadercompiler/StringTable.cpp +++ b/shadercompiler/StringTable.cpp @@ -6,8 +6,8 @@ const StringReference INVALID_REFERENCE = StringTable::GetInvalidReference(); -StringTable::StringTable() - :m_sorted( true ) +StringTable::StringTable() : + m_sorted( true ) { } diff --git a/shadercompiler/StringTable.h b/shadercompiler/StringTable.h index 24fcc99dc..f93e6c1b6 100644 --- a/shadercompiler/StringTable.h +++ b/shadercompiler/StringTable.h @@ -17,6 +17,7 @@ class StringReference { return reference < other.reference; } + private: uint32_t reference; friend class StringTable; @@ -39,12 +40,12 @@ class StringTable size_t GetSize() const; static StringReference GetInvalidReference(); -private: +private: struct Blob { - Blob( const void* data, size_t size ) - :m_data(nullptr), + Blob( const void* data, size_t size ) : + m_data( nullptr ), m_size( size ) { if( size ) @@ -54,8 +55,8 @@ class StringTable } } - Blob( const Blob& other ) - :m_size( other.m_size ) + Blob( const Blob& other ) : + m_size( other.m_size ) { if( other.m_data ) { @@ -68,8 +69,8 @@ class StringTable } } - Blob( Blob&& other ) - :m_data( other.m_data ), + Blob( Blob&& other ) : + m_data( other.m_data ), m_size( other.m_size ) { other.m_data = nullptr; @@ -138,7 +139,7 @@ class StringTable struct BlobPtrHash { - size_t operator ()( const Blob* ptr ) const + size_t operator()( const Blob* ptr ) const { return size_t( *ptr ); } diff --git a/shadercompiler/SymbolTable.cpp b/shadercompiler/SymbolTable.cpp index eb190182f..c2946b121 100644 --- a/shadercompiler/SymbolTable.cpp +++ b/shadercompiler/SymbolTable.cpp @@ -13,9 +13,11 @@ bool PackOffset::Create( ParserState& state, const ScannerToken& subComponentTok component.start = component.end = nullptr; char registerType; - if( !ParseRegisterID( subComponentToken.stringValue.start, - subComponentToken.stringValue.end, - registerType, subComponent ) || registerType != 'c' ) + if( !ParseRegisterID( subComponentToken.stringValue.start, + subComponentToken.stringValue.end, + registerType, + subComponent ) || + registerType != 'c' ) { state.ShowMessage( subComponentToken.fileLocation, EC_INVALID_PACK_OFFSET ); return false; @@ -29,16 +31,16 @@ bool PackOffset::Create( ParserState& state, const ScannerToken& subComponentTok RegisterSpecifier RegisterSpecifier::Register( char type, int index ) { - RegisterSpecifier reg; - reg.shaderProfile.start = nullptr; - reg.shaderProfile.end = nullptr; - reg.registerType = type; - reg.registerNumber = index; - reg.subComponent = -1; - reg.space = -1; - reg.explicitRegister = true; - reg.explicitSpace = false; - return reg; + RegisterSpecifier reg; + reg.shaderProfile.start = nullptr; + reg.shaderProfile.end = nullptr; + reg.registerType = type; + reg.registerNumber = index; + reg.subComponent = -1; + reg.space = -1; + reg.explicitRegister = true; + reg.explicitSpace = false; + return reg; } @@ -66,8 +68,8 @@ bool CompareSymbols::operator()( const Symbol* symbol0, const Symbol* symbol1 ) return false; } -Symbol::Symbol() - :isTypeName( false ), +Symbol::Symbol() : + isTypeName( false ), isFunction( false ), interpolationModifier( 0 ), annotations( nullptr ), @@ -87,8 +89,8 @@ Symbol::Symbol() type.FromTokenType( 0 ); } -ScopeSymbolTable::ScopeSymbolTable( ScopeSymbolTable* parent ) - :m_parent( parent ) +ScopeSymbolTable::ScopeSymbolTable( ScopeSymbolTable* parent ) : + m_parent( parent ) { } @@ -141,7 +143,7 @@ static bool MatchParameter( ASTNode* parameter, ASTNode* argument, int& casts ) else if( parameter->GetToken() && parameter->GetToken()->type == OP_INOUT ) { int tmp; - return parameter->GetType().CanImplicitCast( argumentType, casts ) && + return parameter->GetType().CanImplicitCast( argumentType, casts ) && parameter->GetType().CanImplicitCast( parameter->GetType(), tmp ); } else @@ -158,7 +160,7 @@ Symbol* ScopeSymbolTable::LookupFunctionDeclaration( const InlineString& name, A { for( auto it = scope->m_symbols.begin(); it != scope->m_symbols.end(); ++it ) { - if( (*it)->name == name && (*it)->definition && (*it)->definition->GetNodeType() == NT_FUNCTION_HEADER ) + if( ( *it )->name == name && ( *it )->definition && ( *it )->definition->GetNodeType() == NT_FUNCTION_HEADER ) { overrides.push_back( std::make_pair( *it, 100000 ) ); } @@ -211,7 +213,7 @@ Symbol* ScopeSymbolTable::LookupFunction( const InlineString& name, ASTNode* cal { for( auto it = scope->m_symbols.begin(); it != scope->m_symbols.end(); ++it ) { - if( (*it)->name == name ) + if( ( *it )->name == name ) { overrides.push_back( std::make_pair( *it, 100000 ) ); } diff --git a/shadercompiler/SymbolTable.h b/shadercompiler/SymbolTable.h index ac0665cfb..1e7451954 100644 --- a/shadercompiler/SymbolTable.h +++ b/shadercompiler/SymbolTable.h @@ -51,7 +51,7 @@ enum class AddressSpace Threadgroup_imageblock, Constexpr, - RayData, + RayData, }; typedef std::vector SymbolAnnotations; @@ -81,7 +81,7 @@ struct Symbol // Specific to Metal shaders. AddressSpace addressSpace; - bool resourceRefWrapped; // type is wrapped in _ResourceRef structure + bool resourceRefWrapped; // type is wrapped in _ResourceRef structure bool used; }; @@ -112,6 +112,7 @@ class ScopeSymbolTable ScopeSymbolTable* GetParent(); void ResetUsedFlag(); + private: ScopeSymbolTable* m_parent; std::vector m_symbols; @@ -143,6 +144,7 @@ class SymbolTable Symbol* LookupGlobal( const char* string ) const; void ResetUsedFlag(); + private: ScopeSymbolTable* m_root; ScopeSymbolTable* m_current; diff --git a/shadercompiler/TextureFunctionConversionDX11.cpp b/shadercompiler/TextureFunctionConversionDX11.cpp index 8d47d7505..c3fa7a993 100644 --- a/shadercompiler/TextureFunctionConversionDX11.cpp +++ b/shadercompiler/TextureFunctionConversionDX11.cpp @@ -70,8 +70,8 @@ static ASTNode* GetSamplerArg( ASTNode* arg ) { return GetSamplerArg( arg->GetChildOrNull( 0 ) ); } - default: - break; + default: + break; } return nullptr; } @@ -207,10 +207,10 @@ static Symbol* FindTextureToSampler( ParserState& state, ASTNode* sampler, std:: return nullptr; } -static ASTNode* FindDX9TexSampleCalls( ParserState& state, - ASTNode* node, - const std::set& dx9TextureFunctions, - std::map& samplers ) +static ASTNode* FindDX9TexSampleCalls( ParserState& state, + ASTNode* node, + const std::set& dx9TextureFunctions, + std::map& samplers ) { if( node == nullptr ) { @@ -240,7 +240,7 @@ static ASTNode* FindDX9TexSampleCalls( ParserState& state, token.fileLocation.fileName.start = token.fileLocation.fileName.end = nullptr; token.fileLocation.lineNumber = 0; token.type = OP_DOT; - ASTNode *var = new ASTNode( NT_VAR_IDENTIFIER, node->GetLocation(), node->GetScope(), nullptr ); + ASTNode* var = new ASTNode( NT_VAR_IDENTIFIER, node->GetLocation(), node->GetScope(), nullptr ); var->SetSymbol( texture ); var->SetType( texture->type ); result = new ASTNode( NT_POSTFIX_EXPRESSION, node->GetLocation(), node->GetScope(), &token ); @@ -470,9 +470,9 @@ static ASTNode* FindDX9TexSampleCalls( ParserState& state, return result; } -static void PatchFunctionHeaders( ASTNode* node, - std::map& samplers, - std::map>& functions ) +static void PatchFunctionHeaders( ASTNode* node, + std::map& samplers, + std::map>& functions ) { if( node == nullptr ) { @@ -519,10 +519,10 @@ static void PatchFunctionHeaders( ASTNode* node, } } -static void PatchCalls( ParserState& state, - ASTNode* node, - std::map& samplers, - const std::map>& functions ) +static void PatchCalls( ParserState& state, + ASTNode* node, + std::map& samplers, + const std::map>& functions ) { if( node == nullptr ) { @@ -576,8 +576,7 @@ static void PatchCalls( ParserState& state, } if( texture == nullptr ) { - if( samplerArg->definition && samplerArg->definition->GetNodeType() == NT_FUNCTION_PARAMETER - && node->GetSymbol() && node->GetSymbol()->definition ) + if( samplerArg->definition && samplerArg->definition->GetNodeType() == NT_FUNCTION_PARAMETER && node->GetSymbol() && node->GetSymbol()->definition ) { ASTNode* header = node->GetSymbol()->definition; if( header->GetNodeType() == NT_FUNCTION_DEFINITION ) @@ -770,7 +769,7 @@ void PatchMetalBufferCalls( ParserState& state, ASTNode* node ) if( functionToken.stringValue == "Load" ) { // b.Load(index) -> b[index] - if ( call->GetChildrenCount() == 2 ) + if( call->GetChildrenCount() == 2 ) { state.ShowMessage( call->GetLocation(), EC_CUSTOM_ERROR, "Metal does not support Load with status argument" ); } @@ -783,7 +782,7 @@ void PatchMetalBufferCalls( ParserState& state, ASTNode* node ) node->RemoveChild( 1 ); } } - else if ( functionToken.stringValue == "GetDimensions" ) + else if( functionToken.stringValue == "GetDimensions" ) { state.ShowMessage( call->GetLocation(), EC_CUSTOM_ERROR, "Metal does not support GetDimensions method for buffers" ); } @@ -798,9 +797,8 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) { auto textureType = node->GetChild( 0 )->GetType(); ASTNode* call = node->GetChild( 1 ); - - auto WrapInOption = [=]( const std::vector& childIndexes, const char* option ) - { + + auto WrapInOption = [=]( const std::vector& childIndexes, const char* option ) { ScannerToken token = ScannerToken::ID( MakeInlineString( option ) ); token.fileLocation = call->GetLocation(); ASTNode* options = new ASTNode( NT_FUNCTION_CALL, call->GetLocation(), call->GetScope(), &token ); @@ -839,7 +837,7 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) // t.SampleGrad(sampler, coord, dx, dy) -> t.sample(sampler, coord, gradient#(dx, dy)) // TODO: support offset? functionToken.stringValue = MakeInlineString( "sample" ); - switch ( textureType.builtInType ) + switch( textureType.builtInType ) { case OP_TEXTURE3D: WrapInOption( { 2, 3 }, "gradient3d" ); @@ -864,7 +862,7 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) { isGatherCall = true; functionToken.stringValue = MakeInlineString( "gather" ); - + // Add x component enumeration to the function //auto x = ScannerToken::FromTokenType(OP_INT_CONST, call->GetLocation()); //x.stringValue = MakeInlineString("component::x"); @@ -873,31 +871,31 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) SplitCoordVec( call, textureType ); } - else if (functionToken.stringValue == "GatherGreen") + else if( functionToken.stringValue == "GatherGreen" ) { isGatherCall = true; - functionToken.stringValue = MakeInlineString("gather"); - + functionToken.stringValue = MakeInlineString( "gather" ); + // Add y component enumeration to the function - auto y = ScannerToken::FromTokenType(OP_INT_CONST, call->GetLocation()); - y.stringValue = MakeInlineString("component::y"); - ASTNode* component = new ASTNode(NT_CONSTANT, call->GetLocation(), call->GetScope(), &y); - call->AddChild(component); + auto y = ScannerToken::FromTokenType( OP_INT_CONST, call->GetLocation() ); + y.stringValue = MakeInlineString( "component::y" ); + ASTNode* component = new ASTNode( NT_CONSTANT, call->GetLocation(), call->GetScope(), &y ); + call->AddChild( component ); - SplitCoordVec(call, textureType); + SplitCoordVec( call, textureType ); } - else if (functionToken.stringValue == "GatherBlue") + else if( functionToken.stringValue == "GatherBlue" ) { isGatherCall = true; - functionToken.stringValue = MakeInlineString("gather"); - + functionToken.stringValue = MakeInlineString( "gather" ); + // Add z component enumeration to the function - auto z = ScannerToken::FromTokenType(OP_INT_CONST, call->GetLocation()); - z.stringValue = MakeInlineString("component::z"); - ASTNode* component = new ASTNode(NT_CONSTANT, call->GetLocation(), call->GetScope(), &z); - call->AddChild(component); + auto z = ScannerToken::FromTokenType( OP_INT_CONST, call->GetLocation() ); + z.stringValue = MakeInlineString( "component::z" ); + ASTNode* component = new ASTNode( NT_CONSTANT, call->GetLocation(), call->GetScope(), &z ); + call->AddChild( component ); - SplitCoordVec(call, textureType); + SplitCoordVec( call, textureType ); } else if( functionToken.stringValue == "Load" ) { @@ -909,11 +907,11 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) if( node->GetChild( 0 )->GetSymbol() && ( textureType.builtInType == OP_RWTEXTURE1D || - textureType.builtInType == OP_RWTEXTURE1DARRAY || - textureType.builtInType == OP_RWTEXTURE2D || - textureType.builtInType == OP_RWTEXTURE2DARRAY || - textureType.builtInType == OP_RWTEXTURE3D || - textureType.builtInType == OP_RWTEXTURE3DARRAY ) ) + textureType.builtInType == OP_RWTEXTURE1DARRAY || + textureType.builtInType == OP_RWTEXTURE2D || + textureType.builtInType == OP_RWTEXTURE2DARRAY || + textureType.builtInType == OP_RWTEXTURE3D || + textureType.builtInType == OP_RWTEXTURE3DARRAY ) ) { node->GetChild( 0 )->GetSymbol()->type.metalTextureAccess = 1; } @@ -944,7 +942,7 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) swizzle = ScannerToken::ID( MakeInlineString( xyzw + coord->GetType().width - 1, xyzw + coord->GetType().width ) ); dot = new ASTNode( NT_POSTFIX_EXPRESSION, coord->GetLocation(), coord->GetScope(), &swizzle ); dot->AddChild( coord->Copy() ); - call->InsertChild( 1 , dot ); + call->InsertChild( 1, dot ); } else if( coord->GetType().builtInType != OP_UINT ) { @@ -959,7 +957,7 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) } SplitCoordVec( call, textureType, 0 ); } - else if (functionToken.stringValue == "SampleCmp") + else if( functionToken.stringValue == "SampleCmp" ) { // t.SampleCmp(sampler, coord, cmp [,offset]) -> t.sample_compare(sampler, coord, cmp, [offset]) functionToken.stringValue = MakeInlineString( "sample_compare" ); @@ -987,7 +985,7 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) { return node; } - + call->SetToken( &functionToken ); if( !textureType.isDepthTexture && !isGatherCall && textureType.templateParameter && textureType.templateParameter->width != 4 ) @@ -1000,9 +998,9 @@ ASTNode* PatchMetalTextureCall( ASTNode* node ) Type callType = *textureType.templateParameter; callType.width = 4; node->SetType( callType ); - + dot->SetType( *textureType.templateParameter ); - + return dot; } return node; @@ -1025,11 +1023,11 @@ ASTNode* PatchMetalTextureCalls( ParserState& state, ASTNode* node, bool rightHa return node; } if( node->GetNodeType() == NT_POSTFIX_EXPRESSION && - node->GetToken() && - node->GetToken()->type == OP_DOT && - node->GetChildrenCount() == 2 && - node->GetChild( 0 )->GetType().IsTexture() && - node->GetChild( 1 )->GetNodeType() == NT_FUNCTION_CALL ) + node->GetToken() && + node->GetToken()->type == OP_DOT && + node->GetChildrenCount() == 2 && + node->GetChild( 0 )->GetType().IsTexture() && + node->GetChild( 1 )->GetNodeType() == NT_FUNCTION_CALL ) { node = PatchMetalTextureCall( node ); } @@ -1082,7 +1080,7 @@ ASTNode* PatchMetalTextureCalls( ParserState& state, ASTNode* node, bool rightHa dot = NewDot( state, arg->Copy(), MakeInlineString( xyzw + dimension, xyzw + dimension + 1 ) ); call->InsertChild( 1, dot ); }; - switch (textureType.builtInType) + switch( textureType.builtInType ) { case OP_TEXTURE1DARRAY: case OP_RWTEXTURE1DARRAY: @@ -1122,7 +1120,7 @@ ASTNode* PatchMetalTextureCalls( ParserState& state, ASTNode* node, bool rightHa state.ShowMessage( node->GetLocation(), EC_CUSTOM_ERROR, "cannot rewite texture assignment for Metal" ); } } - bool isAssignment = false; + bool isAssignment = false; if( node->GetNodeType() == NT_EXPRESSION ) { switch( node->GetToken()->type ) diff --git a/shadercompiler/Type.cpp b/shadercompiler/Type.cpp index 932156503..2187a24cd 100644 --- a/shadercompiler/Type.cpp +++ b/shadercompiler/Type.cpp @@ -13,9 +13,9 @@ bool Type::operator==( const Type& type ) const { return symbol == type.symbol; } - return builtInType == type.builtInType && - width == type.width && - height == type.height && + return builtInType == type.builtInType && + width == type.width && + height == type.height && ( ( templateParameter == nullptr && type.templateParameter == nullptr ) || ( templateParameter != nullptr && type.templateParameter != nullptr && *templateParameter == *type.templateParameter && templateSamples == type.templateSamples ) ) && ( !IsTexture() || isDepthTexture == type.isDepthTexture ); @@ -107,39 +107,39 @@ bool Type::IsBindlessHandle() const bool Type::IsScalarOrVector() const { - return symbol == nullptr && + return symbol == nullptr && ( builtInType == OP_INT || - builtInType == OP_UINT || - builtInType == OP_BOOL || - builtInType == OP_HALF || - builtInType == OP_FLOAT || - builtInType == OP_DOUBLE || - builtInType == OP_BINDLESSHANDLETEXTURE2D || - builtInType == OP_BINDLESSHANDLETEXTURE3D || - builtInType == OP_BINDLESSHANDLETEXTURECUBE || - builtInType == OP_BINDLESSHANDLESAMPLER ); + builtInType == OP_UINT || + builtInType == OP_BOOL || + builtInType == OP_HALF || + builtInType == OP_FLOAT || + builtInType == OP_DOUBLE || + builtInType == OP_BINDLESSHANDLETEXTURE2D || + builtInType == OP_BINDLESSHANDLETEXTURE3D || + builtInType == OP_BINDLESSHANDLETEXTURECUBE || + builtInType == OP_BINDLESSHANDLESAMPLER ); } bool Type::IsTexture() const { - return symbol == nullptr && + return symbol == nullptr && ( builtInType == OP_TEXTURE || - builtInType == OP_TEXTURE1D || - builtInType == OP_TEXTURE2D || - builtInType == OP_TEXTURE3D || - builtInType == OP_TEXTURECUBE || - builtInType == OP_TEXTURE1DARRAY || - builtInType == OP_TEXTURE2DARRAY || - builtInType == OP_TEXTURE3DARRAY || - builtInType == OP_TEXTURECUBEARRAY || - builtInType == OP_TEXTURE2DMS || - builtInType == OP_TEXTURE2DMSARRAY || - builtInType == OP_RWTEXTURE1D || - builtInType == OP_RWTEXTURE2D || - builtInType == OP_RWTEXTURE3D || - builtInType == OP_RWTEXTURE1DARRAY || - builtInType == OP_RWTEXTURE2DARRAY || - builtInType == OP_RWTEXTURE3DARRAY ); + builtInType == OP_TEXTURE1D || + builtInType == OP_TEXTURE2D || + builtInType == OP_TEXTURE3D || + builtInType == OP_TEXTURECUBE || + builtInType == OP_TEXTURE1DARRAY || + builtInType == OP_TEXTURE2DARRAY || + builtInType == OP_TEXTURE3DARRAY || + builtInType == OP_TEXTURECUBEARRAY || + builtInType == OP_TEXTURE2DMS || + builtInType == OP_TEXTURE2DMSARRAY || + builtInType == OP_RWTEXTURE1D || + builtInType == OP_RWTEXTURE2D || + builtInType == OP_RWTEXTURE3D || + builtInType == OP_RWTEXTURE1DARRAY || + builtInType == OP_RWTEXTURE2DARRAY || + builtInType == OP_RWTEXTURE3DARRAY ); } bool Type::IsTextureArray() const @@ -158,13 +158,13 @@ bool Type::IsTextureArray() const bool Type::IsSampler() const { - return symbol == nullptr && + return symbol == nullptr && ( builtInType == OP_SAMPLER || - builtInType == OP_SAMPLER1D || - builtInType == OP_SAMPLER2D || - builtInType == OP_SAMPLER3D || - builtInType == OP_SAMPLERCUBE || - builtInType == OP_SAMPLERCOMPARISON ); + builtInType == OP_SAMPLER1D || + builtInType == OP_SAMPLER2D || + builtInType == OP_SAMPLER3D || + builtInType == OP_SAMPLERCUBE || + builtInType == OP_SAMPLERCOMPARISON ); } bool Type::IsBuffer() const @@ -246,9 +246,9 @@ bool Type::GetMethodType( ASTNode* methodCall, Type& returnType ) const return true; } if( method == MakeInlineString( "Load" ) || - method == MakeInlineString( "Sample" ) || - method == MakeInlineString( "SampleBias" ) || - method == MakeInlineString( "SampleGrad" ) || + method == MakeInlineString( "Sample" ) || + method == MakeInlineString( "SampleBias" ) || + method == MakeInlineString( "SampleGrad" ) || method == MakeInlineString( "SampleLevel" ) ) { if( templateParameter ) @@ -393,15 +393,15 @@ bool Type::GetMethodType( ASTNode* methodCall, Type& returnType ) const return false; case OP_RWBYTEADDRESSBUFFER: if( method == MakeInlineString( "GetDimensions" ) || - method == MakeInlineString( "InterlockedAdd" ) || - method == MakeInlineString( "InterlockedAnd" ) || - - method == MakeInlineString( "InterlockedCompareExchange" ) || - method == MakeInlineString( "InterlockedCompareStore" ) || - method == MakeInlineString( "InterlockedExchange" ) || - method == MakeInlineString( "InterlockedMax" ) || - method == MakeInlineString( "InterlockedMin" ) || - method == MakeInlineString( "InterlockedOr" ) || + method == MakeInlineString( "InterlockedAdd" ) || + method == MakeInlineString( "InterlockedAnd" ) || + + method == MakeInlineString( "InterlockedCompareExchange" ) || + method == MakeInlineString( "InterlockedCompareStore" ) || + method == MakeInlineString( "InterlockedExchange" ) || + method == MakeInlineString( "InterlockedMax" ) || + method == MakeInlineString( "InterlockedMin" ) || + method == MakeInlineString( "InterlockedOr" ) || method == MakeInlineString( "InterlockedXor" ) || method == MakeInlineString( "Store" ) || method == MakeInlineString( "Store2" ) || @@ -438,7 +438,7 @@ bool Type::GetMethodType( ASTNode* methodCall, Type& returnType ) const case OP_POINTSTREAM: case OP_LINESTREAM: case OP_TRIANGLESTREAM: - if( method == MakeInlineString( "Append" ) || + if( method == MakeInlineString( "Append" ) || method == MakeInlineString( "RestartStrip" ) ) { returnType.FromTokenType( OP_VOID ); @@ -643,7 +643,7 @@ bool Type::GetIndexedType( Type& type ) const else { type.FromTokenType( OP_FLOAT ); - if (isDepthTexture) + if( isDepthTexture ) { type.width = 1; } @@ -687,18 +687,18 @@ bool Type::GetIndexedType( Type& type ) const Type TypeFromSymbol( const Symbol* symbol ) { - Type t; - t.FromSymbol( symbol ); - return t; + Type t; + t.FromSymbol( symbol ); + return t; } Type TypeFromTokenType( int type, int width, int height ) { - Type t; - t.FromTokenType( type ); - t.width = width; - t.height = height; - return t; + Type t; + t.FromTokenType( type ); + t.width = width; + t.height = height; + return t; } bool GetCommonType( const Type& type0, const Type& type1, Type& type ) @@ -773,7 +773,8 @@ int GetNumericTypePrecedence( int type ) -namespace hlsl { +namespace hlsl +{ const Type void_t = TypeFromTokenType( OP_VOID ); diff --git a/shadercompiler/Type.h b/shadercompiler/Type.h index 2f9489ad0..2e1bcfad3 100644 --- a/shadercompiler/Type.h +++ b/shadercompiler/Type.h @@ -53,7 +53,8 @@ Type TypeFromTokenType( int type, int width = 1, int height = 1 ); bool GetCommonType( const Type& type0, const Type& type1, Type& type ); int GetNumericTypePrecedence( int type ); -namespace hlsl { +namespace hlsl +{ extern const Type void_t; diff --git a/shadercompiler/WorkQueue.h b/shadercompiler/WorkQueue.h index 41fd077d6..fcd97ceb6 100644 --- a/shadercompiler/WorkQueue.h +++ b/shadercompiler/WorkQueue.h @@ -14,8 +14,8 @@ template class WorkQueue { public: - WorkQueue( size_t workerCount, Processor processor ) - :m_processor( processor ) + WorkQueue( size_t workerCount, Processor processor ) : + m_processor( processor ) { for( size_t i = 0; i < workerCount; ++i ) { @@ -57,8 +57,8 @@ class WorkQueue } m_workerThreads.clear(); } -private: +private: void PutPtr( T* item ) { std::lock_guard scope( m_mutex ); @@ -138,7 +138,7 @@ class WorkQueue2 : IWorkQueue } #endif started = false; - + for( size_t i = 0; i < totalWorkerCount; ++i ) { m_workerThreads.emplace_back( std::thread( [this] { WorkerThread(); } ) ); @@ -202,7 +202,7 @@ class WorkQueue2 : IWorkQueue { #ifdef __APPLE__ auto waitResult = semaphore_wait( m_activeWorkersSemaphore ); - if ( waitResult != KERN_SUCCESS ) + if( waitResult != KERN_SUCCESS ) { g_messages.AddMessage( "WorkQueue2: Waiting on m_activeWorkersSemaphore failed! Error: %d", waitResult ); } @@ -258,7 +258,7 @@ class WorkQueue2 : IWorkQueue T* item = nullptr; { std::unique_lock scope( m_queueMutex ); - if ( m_queue.empty() ) + if( m_queue.empty() ) { break; } diff --git a/shadercompiler/YamlOutput.h b/shadercompiler/YamlOutput.h index 757bc34a3..a5b4e3be7 100644 --- a/shadercompiler/YamlOutput.h +++ b/shadercompiler/YamlOutput.h @@ -8,8 +8,8 @@ class YamlOutput { public: - explicit YamlOutput( bool enabled = true ) - :m_expected( ROOT ), + explicit YamlOutput( bool enabled = true ) : + m_expected( ROOT ), m_enabled( enabled ) { } @@ -232,6 +232,7 @@ class YamlOutput } return m_os.str(); } + private: static std::string quote( const std::string& str ) { @@ -338,8 +339,8 @@ extern bool g_generateListing; class YamlListing : public YamlOutput { public: - explicit YamlListing( bool enabled = true ) - :YamlOutput( g_generateListing && enabled ) + explicit YamlListing( bool enabled = true ) : + YamlOutput( g_generateListing && enabled ) { } diff --git a/shadercompiler/lempar.c b/shadercompiler/lempar.c index c82e33298..00a7618fc 100644 --- a/shadercompiler/lempar.c +++ b/shadercompiler/lempar.c @@ -22,6 +22,7 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +/* clang-format off */ #include #include /************ Begin %include sections from the grammar ************************/ @@ -1073,4 +1074,4 @@ int ParseFallback(int iToken){ (void)iToken; return 0; #endif -} +} \ No newline at end of file diff --git a/shadercompiler/preprocessorLempar.c b/shadercompiler/preprocessorLempar.c index 9654de8ac..de67f1c50 100644 --- a/shadercompiler/preprocessorLempar.c +++ b/shadercompiler/preprocessorLempar.c @@ -22,6 +22,7 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ +/* clang-format off */ #include #include /************ Begin %include sections from the grammar ************************/ @@ -1073,4 +1074,4 @@ int PreprocessorParseFallback(int iToken){ (void)iToken; return 0; #endif -} +} \ No newline at end of file diff --git a/shadercompiler/stdafx.h b/shadercompiler/stdafx.h index 23b2dbca1..7c7c94d16 100644 --- a/shadercompiler/stdafx.h +++ b/shadercompiler/stdafx.h @@ -7,8 +7,8 @@ #pragma once -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #if _WIN32 @@ -44,8 +44,8 @@ #define S_OK 0x00000000 #define E_FAIL 0x80004005 -#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -#define FAILED(hr) (((HRESULT)(hr)) < 0) +#define SUCCEEDED( hr ) ( ( (HRESULT)( hr ) ) >= 0 ) +#define FAILED( hr ) ( ( (HRESULT)( hr ) ) < 0 ) #define D3D11_FILTER_REDUCTION_TYPE_MASK ( 0x3 ) #define D3D11_FILTER_REDUCTION_TYPE_SHIFT ( 7 ) @@ -55,25 +55,21 @@ #define D3D11_MIP_FILTER_SHIFT ( 0 ) #define D3D11_ANISOTROPIC_FILTERING_BIT ( 0x40 ) -#define D3D11_DECODE_MIN_FILTER( d3d11Filter ) \ - ( ( D3D11_FILTER_TYPE ) \ - ( ( ( d3d11Filter ) >> D3D11_MIN_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) -#define D3D11_DECODE_MAG_FILTER( d3d11Filter ) \ - ( ( D3D11_FILTER_TYPE ) \ - ( ( ( d3d11Filter ) >> D3D11_MAG_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) -#define D3D11_DECODE_MIP_FILTER( d3d11Filter ) \ - ( ( D3D11_FILTER_TYPE ) \ - ( ( ( d3d11Filter ) >> D3D11_MIP_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) -#define D3D11_DECODE_FILTER_REDUCTION( d3d11Filter ) \ - ( ( D3D11_FILTER_REDUCTION_TYPE ) \ - ( ( ( d3d11Filter ) >> D3D11_FILTER_REDUCTION_TYPE_SHIFT ) & D3D11_FILTER_REDUCTION_TYPE_MASK ) ) -#define D3D11_DECODE_IS_COMPARISON_FILTER( d3d11Filter ) \ - ( D3D11_DECODE_FILTER_REDUCTION( d3d11Filter ) == D3D11_FILTER_REDUCTION_TYPE_COMPARISON ) -#define D3D11_DECODE_IS_ANISOTROPIC_FILTER( d3d11Filter ) \ - ( ( ( d3d11Filter ) & D3D11_ANISOTROPIC_FILTERING_BIT ) && \ - ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MIN_FILTER( d3d11Filter ) ) && \ - ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MAG_FILTER( d3d11Filter ) ) && \ - ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MIP_FILTER( d3d11Filter ) ) ) +#define D3D11_DECODE_MIN_FILTER( d3d11Filter ) \ + ( (D3D11_FILTER_TYPE)( ( ( d3d11Filter ) >> D3D11_MIN_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) +#define D3D11_DECODE_MAG_FILTER( d3d11Filter ) \ + ( (D3D11_FILTER_TYPE)( ( ( d3d11Filter ) >> D3D11_MAG_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) +#define D3D11_DECODE_MIP_FILTER( d3d11Filter ) \ + ( (D3D11_FILTER_TYPE)( ( ( d3d11Filter ) >> D3D11_MIP_FILTER_SHIFT ) & D3D11_FILTER_TYPE_MASK ) ) +#define D3D11_DECODE_FILTER_REDUCTION( d3d11Filter ) \ + ( (D3D11_FILTER_REDUCTION_TYPE)( ( ( d3d11Filter ) >> D3D11_FILTER_REDUCTION_TYPE_SHIFT ) & D3D11_FILTER_REDUCTION_TYPE_MASK ) ) +#define D3D11_DECODE_IS_COMPARISON_FILTER( d3d11Filter ) \ + ( D3D11_DECODE_FILTER_REDUCTION( d3d11Filter ) == D3D11_FILTER_REDUCTION_TYPE_COMPARISON ) +#define D3D11_DECODE_IS_ANISOTROPIC_FILTER( d3d11Filter ) \ + ( ( ( d3d11Filter ) & D3D11_ANISOTROPIC_FILTERING_BIT ) && \ + ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MIN_FILTER( d3d11Filter ) ) && \ + ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MAG_FILTER( d3d11Filter ) ) && \ + ( D3D11_FILTER_TYPE_LINEAR == D3D11_DECODE_MIP_FILTER( d3d11Filter ) ) ) // Definitions taken from https://docs.microsoft.com/en-gb/windows/win32/winprog/windows-data-types // Note: On Windows platform DWORD is defined as @@ -94,15 +90,16 @@ typedef const char* LPCSTR; typedef char* LPSTR; typedef const void* LPCVOID; typedef void* LPVOID; -typedef void *PVOID; +typedef void* PVOID; // typedef long LONG; typedef int32_t LONG; typedef LONG HRESULT; typedef PVOID HANDLE; -typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; +typedef struct _FILETIME +{ + DWORD dwLowDateTime; + DWORD dwHighDateTime; } FILETIME, *PFILETIME, *LPFILETIME; struct ID3DInclude @@ -111,8 +108,8 @@ struct ID3DInclude typedef struct D3D_SHADER_MACRO { - LPCSTR Name; - LPCSTR Definition; + LPCSTR Name; + LPCSTR Definition; } D3D_SHADER_MACRO, *LPD3D_SHADER_MACRO; enum D3D_INCLUDE_TYPE @@ -122,7 +119,8 @@ enum D3D_INCLUDE_TYPE D3D_INCLUDE_FORCE_DWORD = 0x7fffffff }; -enum D3D11_FILTER { +enum D3D11_FILTER +{ D3D11_FILTER_MIN_MAG_MIP_POINT = 0, D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, @@ -142,7 +140,7 @@ enum D3D11_FILTER { D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, D3D11_FILTER_COMPARISON_ANISOTROPIC = 0xd5, - D3D11_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + D3D11_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, D3D11_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, D3D11_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, D3D11_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, @@ -162,7 +160,8 @@ enum D3D11_FILTER { D3D11_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5 }; -enum D3D11_COMPARISON_FUNC { +enum D3D11_COMPARISON_FUNC +{ D3D11_COMPARISON_NEVER = 1, D3D11_COMPARISON_LESS = 2, D3D11_COMPARISON_EQUAL = 3, @@ -173,7 +172,8 @@ enum D3D11_COMPARISON_FUNC { D3D11_COMPARISON_ALWAYS = 8 }; -enum D3D11_TEXTURE_ADDRESS_MODE { +enum D3D11_TEXTURE_ADDRESS_MODE +{ D3D11_TEXTURE_ADDRESS_WRAP = 1, D3D11_TEXTURE_ADDRESS_MIRROR = 2, D3D11_TEXTURE_ADDRESS_CLAMP = 3, @@ -181,16 +181,18 @@ enum D3D11_TEXTURE_ADDRESS_MODE { D3D11_TEXTURE_ADDRESS_MIRROR_ONCE = 5 }; -enum D3D11_FILTER_TYPE { - D3D11_FILTER_TYPE_POINT, - D3D11_FILTER_TYPE_LINEAR +enum D3D11_FILTER_TYPE +{ + D3D11_FILTER_TYPE_POINT, + D3D11_FILTER_TYPE_LINEAR }; -enum D3D11_FILTER_REDUCTION_TYPE { - D3D11_FILTER_REDUCTION_TYPE_STANDARD, - D3D11_FILTER_REDUCTION_TYPE_COMPARISON, - D3D11_FILTER_REDUCTION_TYPE_MINIMUM, - D3D11_FILTER_REDUCTION_TYPE_MAXIMUM +enum D3D11_FILTER_REDUCTION_TYPE +{ + D3D11_FILTER_REDUCTION_TYPE_STANDARD, + D3D11_FILTER_REDUCTION_TYPE_COMPARISON, + D3D11_FILTER_REDUCTION_TYPE_MINIMUM, + D3D11_FILTER_REDUCTION_TYPE_MAXIMUM }; enum D3D11_BLEND @@ -252,7 +254,7 @@ enum D3D11_FILL_MODE #include #include -#if !NDEBUG +#if !NDEBUG #undef CCP_TELEMETRY_ENABLED #endif @@ -260,7 +262,7 @@ enum D3D11_FILL_MODE #include #else #define ZoneScoped -#define ZoneScopedN(x) +#define ZoneScopedN( x ) #endif #ifndef _WIN32 diff --git a/trinity/ALResultBlue.cpp b/trinity/ALResultBlue.cpp index 67dc5a09d..f5d72059c 100644 --- a/trinity/ALResultBlue.cpp +++ b/trinity/ALResultBlue.cpp @@ -19,17 +19,17 @@ BLUE_DEFINE_EXCEPTION( ALInvalidCallError, ALError ); // Python exception class appropriate for the given ALResult code // -------------------------------------------------------------------------------------- BLUE_BEGIN_GET_EXCEPTION( ALResult ) - switch( result.GetCategory() ) - { - case ALResult::INVALID_CALL: - return BLUE_GET_EXCEPTION( ALInvalidCallError ); - case ALResult::DEVICE_LOST: - return BLUE_GET_EXCEPTION( ALDeviceLostError ); - case ALResult::DEVICE_NOT_AVAILABLE: - return BLUE_GET_EXCEPTION( ALDeviceNotAvailable ); - case ALResult::OUT_OF_MEMORY: - return BLUE_GET_EXCEPTION( ALOutOfMemoryError ); - default: - return BLUE_GET_EXCEPTION( ALError ); - } +switch( result.GetCategory() ) +{ +case ALResult::INVALID_CALL: + return BLUE_GET_EXCEPTION( ALInvalidCallError ); +case ALResult::DEVICE_LOST: + return BLUE_GET_EXCEPTION( ALDeviceLostError ); +case ALResult::DEVICE_NOT_AVAILABLE: + return BLUE_GET_EXCEPTION( ALDeviceNotAvailable ); +case ALResult::OUT_OF_MEMORY: + return BLUE_GET_EXCEPTION( ALOutOfMemoryError ); +default: + return BLUE_GET_EXCEPTION( ALError ); +} BLUE_END_GET_EXCEPTION() diff --git a/trinity/Audio/Tr2AudioStretchAuto.cpp b/trinity/Audio/Tr2AudioStretchAuto.cpp index f5c9683ce..80f18b028 100644 --- a/trinity/Audio/Tr2AudioStretchAuto.cpp +++ b/trinity/Audio/Tr2AudioStretchAuto.cpp @@ -5,14 +5,16 @@ #include "Tr2Renderer.h" Tr2AudioStretchAuto::Tr2AudioStretchAuto( IRoot* lockobj ) -{} +{ +} Tr2AudioStretchAuto::~Tr2AudioStretchAuto() -{} +{ +} unsigned int Tr2AudioStretchAuto::TriggerOutburstEvent() { - if ( nullptr != m_sourceEmitter ) + if( nullptr != m_sourceEmitter ) { return m_sourceEmitter.p->SendEvent( m_outburstEvent ); } @@ -21,7 +23,7 @@ unsigned int Tr2AudioStretchAuto::TriggerOutburstEvent() unsigned int Tr2AudioStretchAuto::TriggerImpactEvent() { - if ( nullptr != m_destEmitter) + if( nullptr != m_destEmitter ) { return m_destEmitter.p->SendEvent( m_impactEvent ); } @@ -30,7 +32,7 @@ unsigned int Tr2AudioStretchAuto::TriggerImpactEvent() unsigned int Tr2AudioStretchAuto::TriggerStretchEvent() { - if ( nullptr != m_stretchEmitter) + if( nullptr != m_stretchEmitter ) { return m_stretchEmitter.p->SendEvent( m_stretchEvent ); } diff --git a/trinity/Audio/Tr2AudioStretchAuto.h b/trinity/Audio/Tr2AudioStretchAuto.h index b4d14f5d8..ad4d0b60d 100644 --- a/trinity/Audio/Tr2AudioStretchAuto.h +++ b/trinity/Audio/Tr2AudioStretchAuto.h @@ -17,6 +17,7 @@ BLUE_CLASS( Tr2AudioStretchAuto ) : unsigned int TriggerOutburstEvent(); unsigned int TriggerImpactEvent(); unsigned int TriggerStretchEvent(); + protected: std::wstring m_outburstEvent; std::wstring m_impactEvent; diff --git a/trinity/Audio/Tr2AudioStretchAuto_Blue.cpp b/trinity/Audio/Tr2AudioStretchAuto_Blue.cpp index efb43969d..7f228443a 100644 --- a/trinity/Audio/Tr2AudioStretchAuto_Blue.cpp +++ b/trinity/Audio/Tr2AudioStretchAuto_Blue.cpp @@ -9,45 +9,39 @@ const Be::ClassInfo* Tr2AudioStretchAuto::ExposeToBlue() { EXPOSURE_BEGIN( Tr2AudioStretchAuto, ":jessica-help-url: https://wiki.ccpgames.com/display/CAudio/Tr2AudioStretchAuto" ) MAP_INTERFACE( Tr2AudioStretchBase ) - MAP_INTERFACE( ITr2Audio ) + MAP_INTERFACE( ITr2Audio ) MAP_ATTRIBUTE( "sourceEmitter", m_sourceEmitter, "Source audio emitter, Follows the source position. The outburst event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "destinationEmitter", m_destEmitter, "Destination audio emitter, follows the destination position. The impact event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "stretchEmitter", m_stretchEmitter, "Audio emitter for the looping part of the stretch effect. It follows the camera as long as it is between the " "source and destination. The stretch event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "outburstEvent", m_outburstEvent, "The event to play on the outburst of the weapon firing. Comes from the source audio emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "impactEvent", m_impactEvent, "The event to play on the impact of the weapon hitting the destination. Comes from the destination audio emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "stretchEvent", m_stretchEvent, "The event to play on the stretch effect between the source and destination. Comes from the stretch emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Audio/Tr2AudioStretchBase.cpp b/trinity/Audio/Tr2AudioStretchBase.cpp index d82a59269..8b78cfd7e 100644 --- a/trinity/Audio/Tr2AudioStretchBase.cpp +++ b/trinity/Audio/Tr2AudioStretchBase.cpp @@ -10,24 +10,25 @@ Tr2AudioStretchBase::Tr2AudioStretchBase( IRoot* lockobj ) } Tr2AudioStretchBase::~Tr2AudioStretchBase() -{} +{ +} bool Tr2AudioStretchBase::Initialize() { // If emitters don't already exist, create and set default names - if ( nullptr == m_sourceEmitter ) + if( nullptr == m_sourceEmitter ) { - BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast(&m_sourceEmitter.p)); + BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast( &m_sourceEmitter.p ) ); m_sourceEmitter.p->SetName( "stretch_source_sfx" ); } - if ( nullptr == m_destEmitter) + if( nullptr == m_destEmitter ) { - BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast(&m_destEmitter.p)); + BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast( &m_destEmitter.p ) ); m_destEmitter.p->SetName( "stretch_dest_sfx" ); } - if ( nullptr == m_stretchEmitter) + if( nullptr == m_stretchEmitter ) { - BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast(&m_stretchEmitter.p)); + BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast( &m_stretchEmitter.p ) ); m_stretchEmitter.p->SetName( "stretch_mid_sfx" ); } @@ -36,41 +37,41 @@ bool Tr2AudioStretchBase::Initialize() void Tr2AudioStretchBase::Update( Vector3& sourcePosition, Vector3& destPosition ) { - Vector3 front(0,1,0), top(0,0,1); - if ( nullptr != m_sourceEmitter ) + Vector3 front( 0, 1, 0 ), top( 0, 0, 1 ); + if( nullptr != m_sourceEmitter ) { m_sourceEmitter->SetPosition( front, top, sourcePosition ); } - if ( nullptr != m_destEmitter ) + if( nullptr != m_destEmitter ) { m_destEmitter->SetPosition( front, top, destPosition ); } - if ( nullptr != m_stretchEmitter) + if( nullptr != m_stretchEmitter ) { // Place the stretch audio emitter between the source and destination points and // follow the camera as long as it is between source and dest. Vector3 cameraPos = Tr2Renderer::GetViewPosition(); Vector3 sp = cameraPos - sourcePosition; Vector3 dp = destPosition - sourcePosition; - Vector3 offset = Dot( sp, dp ) / Dot(dp, dp) * dp; + Vector3 offset = Dot( sp, dp ) / Dot( dp, dp ) * dp; offset = ClampLength( offset, Length( dp ) ); Vector3 dest = sourcePosition; dest = Dot( dp, dest + offset ) > 0 ? dest + offset : dest; - m_stretchEmitter->SetPosition( front, top, dest); + m_stretchEmitter->SetPosition( front, top, dest ); } } ITr2AudEmitterPtr Tr2AudioStretchBase::FindEmitterByName( const char* name ) -{ - if ( m_sourceEmitter->GetName() == name ) +{ + if( m_sourceEmitter->GetName() == name ) { return m_sourceEmitter; } - else if ( m_destEmitter->GetName() == name ) + else if( m_destEmitter->GetName() == name ) { return m_destEmitter; } - else if ( m_stretchEmitter->GetName() == name ) + else if( m_stretchEmitter->GetName() == name ) { return m_stretchEmitter; } @@ -79,15 +80,15 @@ ITr2AudEmitterPtr Tr2AudioStretchBase::FindEmitterByName( const char* name ) void Tr2AudioStretchBase::GetDebugOptions( Tr2DebugRendererOptions& options ) { - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_sourceEmitter.p ) ) + if( auto tmp = dynamic_cast( m_sourceEmitter.p ) ) { tmp->GetDebugOptions( options ); } - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_destEmitter.p ) ) + if( auto tmp = dynamic_cast( m_destEmitter.p ) ) { tmp->GetDebugOptions( options ); } - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_stretchEmitter.p ) ) + if( auto tmp = dynamic_cast( m_stretchEmitter.p ) ) { tmp->GetDebugOptions( options ); } @@ -95,15 +96,15 @@ void Tr2AudioStretchBase::GetDebugOptions( Tr2DebugRendererOptions& options ) void Tr2AudioStretchBase::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_sourceEmitter.p ) ) + if( auto tmp = dynamic_cast( m_sourceEmitter.p ) ) { tmp->RenderDebugInfo( renderer ); } - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_destEmitter.p ) ) + if( auto tmp = dynamic_cast( m_destEmitter.p ) ) { tmp->RenderDebugInfo( renderer ); } - if ( auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_stretchEmitter.p ) ) + if( auto tmp = dynamic_cast( m_stretchEmitter.p ) ) { tmp->RenderDebugInfo( renderer ); } diff --git a/trinity/Audio/Tr2AudioStretchBase.h b/trinity/Audio/Tr2AudioStretchBase.h index f9f0472a9..b8b609960 100644 --- a/trinity/Audio/Tr2AudioStretchBase.h +++ b/trinity/Audio/Tr2AudioStretchBase.h @@ -6,9 +6,9 @@ #include #include -BLUE_CLASS( Tr2AudioStretchBase ): +BLUE_CLASS( Tr2AudioStretchBase ) : public IInitialize, - public ITr2Audio, + public ITr2Audio, public ITr2DebugRenderable { public: @@ -24,12 +24,13 @@ BLUE_CLASS( Tr2AudioStretchBase ): // Places the source and destination audio emitters at the source and // destination positions of the stretch effect. Places the stretch // emitter between those two points relative to the camera. - void Update( Vector3& sourcePosition, Vector3& destPosition ); + void Update( Vector3 & sourcePosition, Vector3 & destPosition ); ITr2AudEmitterPtr FindEmitterByName( const char* name ) override; // debug - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); + protected: ITr2AudEmitterPtr m_sourceEmitter; ITr2AudEmitterPtr m_destEmitter; diff --git a/trinity/Audio/Tr2AudioStretchBase_Blue.cpp b/trinity/Audio/Tr2AudioStretchBase_Blue.cpp index 8b6129a6a..bc3426e8a 100644 --- a/trinity/Audio/Tr2AudioStretchBase_Blue.cpp +++ b/trinity/Audio/Tr2AudioStretchBase_Blue.cpp @@ -11,27 +11,24 @@ const Be::ClassInfo* Tr2AudioStretchBase::ExposeToBlue() { EXPOSURE_BEGIN( Tr2AudioStretchBase, ":jessica-help-url: https://wiki.ccpgames.com/display/CAudio/Tr2AudioStretchBase" ) MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( ITr2DebugRenderable) + MAP_INTERFACE( ITr2DebugRenderable ) MAP_INTERFACE( ITr2Audio ) MAP_ATTRIBUTE( "sourceEmitter", m_sourceEmitter, "Source audio emitter, Follows the source position. The outburst event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "destinationEmitter", m_destEmitter, "Destination audio emitter, follows the destination position. The impact event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "stretchEmitter", m_stretchEmitter, "Audio emitter for the looping part of the stretch effect. It follows the camera as long as it is between the " "source and destination. The stretch event will come from this emitter.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Controllers/Actions/ITr2ControllerAction.h b/trinity/Controllers/Actions/ITr2ControllerAction.h index 8aa526014..0c728c07a 100644 --- a/trinity/Controllers/Actions/ITr2ControllerAction.h +++ b/trinity/Controllers/Actions/ITr2ControllerAction.h @@ -5,14 +5,22 @@ BLUE_DECLARE_INTERFACE( ITr2ActionController ); -BLUE_INTERFACE( ITr2ControllerAction ) : public IRoot +BLUE_INTERFACE( ITr2ControllerAction ) : + public IRoot { virtual void Link( ITr2ActionController & controller ){}; virtual void Unlink() {}; - virtual void Start( ITr2ActionController& controller ) {} - virtual void Stop( ITr2ActionController& controller ) {} + virtual void Start( ITr2ActionController & controller ) + { + } + virtual void Stop( ITr2ActionController & controller ) + { + } virtual void RebaseSimTime( Be::Time diff ) {}; - virtual bool CanTransition() const { return true; } + virtual bool CanTransition() const + { + return true; + } }; BLUE_DECLARE_IVECTOR( ITr2ControllerAction ); diff --git a/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.cpp b/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.cpp index df088fcbd..e29f92363 100644 --- a/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.cpp +++ b/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.cpp @@ -10,19 +10,19 @@ namespace { - float StateTime( float* stateTime ) - { - return *stateTime; - } +float StateTime( float* stateTime ) +{ + return *stateTime; +} - CcpParser::Function s_extraFunctions[] = { - CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, 0 ), - }; - } +CcpParser::Function s_extraFunctions[] = { + CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, 0 ), +}; +} -Tr2ActionAnimateCurveSet::Tr2ActionAnimateCurveSet( IRoot* ) - :m_controller( nullptr ), +Tr2ActionAnimateCurveSet::Tr2ActionAnimateCurveSet( IRoot* ) : + m_controller( nullptr ), m_value( "StateTime()" ), m_startTime( 0 ), m_lastSimTime( 0 ) diff --git a/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.h b/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.h index 7eef7bd2c..70b76aedf 100644 --- a/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.h +++ b/trinity/Controllers/Actions/Tr2ActionAnimateCurveSet.h @@ -9,7 +9,7 @@ BLUE_DECLARE( TriCurveSet ); -BLUE_CLASS( Tr2ActionAnimateCurveSet ) : +BLUE_CLASS( Tr2ActionAnimateCurveSet ) : public ITr2ControllerAction, public ITr2Updateable, public INotify @@ -19,22 +19,23 @@ BLUE_CLASS( Tr2ActionAnimateCurveSet ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; void RebaseSimTime( Be::Time diff ) override; virtual void Update( Be::Time realTime, Be::Time simTime ); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); bool IsExpressionValid() const; std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: bool IsAttrExpressionValid( const char* attributeName ) const; diff --git a/trinity/Controllers/Actions/Tr2ActionAnimateValue.cpp b/trinity/Controllers/Actions/Tr2ActionAnimateValue.cpp index 408bf9fd0..e71f386f9 100644 --- a/trinity/Controllers/Actions/Tr2ActionAnimateValue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionAnimateValue.cpp @@ -9,35 +9,35 @@ namespace { - struct ExtraBuffer - { - const Tr2ActionAnimateValue* action = nullptr; - float* stateTime = nullptr; - }; +struct ExtraBuffer +{ + const Tr2ActionAnimateValue* action = nullptr; + float* stateTime = nullptr; +}; - float StateTime( float* stateTime ) - { - return *stateTime; - } +float StateTime( float* stateTime ) +{ + return *stateTime; +} - float Curve( Tr2ActionAnimateValue* action, float time ) +float Curve( Tr2ActionAnimateValue* action, float time ) +{ + if( !action ) { - if( !action ) - { - return 0; - } - return action->GetCurveValue( time ); + return 0; } + return action->GetCurveValue( time ); +} - CcpParser::Function s_extraFunctions[] = { - CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, stateTime ) ), - CcpParser::Function( "Curve", Curve, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, action ) ), - }; +CcpParser::Function s_extraFunctions[] = { + CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, stateTime ) ), + CcpParser::Function( "Curve", Curve, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, action ) ), +}; } -Tr2ActionAnimateValue::Tr2ActionAnimateValue( IRoot* ) - :m_controller( nullptr ), +Tr2ActionAnimateValue::Tr2ActionAnimateValue( IRoot* ) : + m_controller( nullptr ), m_value( "Curve(StateTime())" ), m_startTime( 0 ), m_lastSimTime( 0 ), diff --git a/trinity/Controllers/Actions/Tr2ActionAnimateValue.h b/trinity/Controllers/Actions/Tr2ActionAnimateValue.h index 0380817a3..ab98045da 100644 --- a/trinity/Controllers/Actions/Tr2ActionAnimateValue.h +++ b/trinity/Controllers/Actions/Tr2ActionAnimateValue.h @@ -23,15 +23,15 @@ BLUE_CLASS( Tr2ActionAnimateValue ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; void RebaseSimTime( Be::Time diff ) override; virtual void Update( Be::Time realTime, Be::Time simTime ); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); bool IsBindingValid() const; bool IsExpressionValid() const; @@ -41,6 +41,7 @@ BLUE_CLASS( Tr2ActionAnimateValue ) : IRootPtr GetDestination() const; std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: bool IsAttrExpressionValid( const char* attributeName ) const; void LinkDestination( const ITr2ActionController& controller ); diff --git a/trinity/Controllers/Actions/Tr2ActionBindRTPC.cpp b/trinity/Controllers/Actions/Tr2ActionBindRTPC.cpp index 91f4a4c6b..acbe8e8dc 100644 --- a/trinity/Controllers/Actions/Tr2ActionBindRTPC.cpp +++ b/trinity/Controllers/Actions/Tr2ActionBindRTPC.cpp @@ -10,35 +10,35 @@ namespace { - struct ExtraBuffer - { - const Tr2ActionBindRTPC* action = nullptr; - float* stateTime = nullptr; - }; +struct ExtraBuffer +{ + const Tr2ActionBindRTPC* action = nullptr; + float* stateTime = nullptr; +}; - float StateTime( float* stateTime ) - { - return *stateTime; - } +float StateTime( float* stateTime ) +{ + return *stateTime; +} - float Curve( Tr2ActionBindRTPC* action, float time ) +float Curve( Tr2ActionBindRTPC* action, float time ) +{ + if( !action ) { - if( !action ) - { - return 0; - } - return action->GetCurveValue( time ); + return 0; } + return action->GetCurveValue( time ); +} - CcpParser::Function s_extraFunctions[] = { - CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, stateTime ) ), - CcpParser::Function( "Curve", Curve, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, action ) ), - }; +CcpParser::Function s_extraFunctions[] = { + CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, stateTime ) ), + CcpParser::Function( "Curve", Curve, Tr2ControllerExpression::EXTRA_BUFFER_INDEX, offsetof( ExtraBuffer, action ) ), +}; } -Tr2ActionBindRTPC::Tr2ActionBindRTPC( IRoot* ): +Tr2ActionBindRTPC::Tr2ActionBindRTPC( IRoot* ) : m_controller( nullptr ), m_value( "" ), m_startTime( 0 ), @@ -105,7 +105,7 @@ void Tr2ActionBindRTPC::Update( Be::Time realTime, Be::Time simTime ) ExtraBuffer buffer = { this, &time }; auto value = m_evaluator.Eval( &buffer ); - if ( value.first && m_emitter ) + if( value.first && m_emitter ) { m_emitter->SetRTPC( m_rtpcName, value.second ); } diff --git a/trinity/Controllers/Actions/Tr2ActionBindRTPC.h b/trinity/Controllers/Actions/Tr2ActionBindRTPC.h index d5bd104f7..3ff2588eb 100644 --- a/trinity/Controllers/Actions/Tr2ActionBindRTPC.h +++ b/trinity/Controllers/Actions/Tr2ActionBindRTPC.h @@ -23,22 +23,23 @@ BLUE_CLASS( Tr2ActionBindRTPC ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void StartWithController( ITr2ActionController* controller ); - void Stop( ITr2ActionController& controller ) override; - void StopWithController( ITr2ActionController* controller ); + void Start( ITr2ActionController & controller ) override; + void StartWithController( ITr2ActionController * controller ); + void Stop( ITr2ActionController & controller ) override; + void StopWithController( ITr2ActionController * controller ); virtual void Update( Be::Time realTime, Be::Time simTime ); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); bool IsExpressionValid() const; std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; float GetCurveValue( float time ) const; + private: bool IsAttrExpressionValid( const char* attributeName ) const; diff --git a/trinity/Controllers/Actions/Tr2ActionCallback.h b/trinity/Controllers/Actions/Tr2ActionCallback.h index 2016b96d4..33000c32f 100644 --- a/trinity/Controllers/Actions/Tr2ActionCallback.h +++ b/trinity/Controllers/Actions/Tr2ActionCallback.h @@ -6,12 +6,13 @@ -BLUE_CLASS( Tr2ActionCallback ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionCallback ) : + public ITr2ControllerAction { public: EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; private: BlueSharedString m_callbackName; diff --git a/trinity/Controllers/Actions/Tr2ActionCallback_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionCallback_Blue.cpp index 13584e100..5c29c9560 100644 --- a/trinity/Controllers/Actions/Tr2ActionCallback_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionCallback_Blue.cpp @@ -17,5 +17,5 @@ const Be::ClassInfo* Tr2ActionCallback::ExposeToBlue() m_callbackName, "The name of the callback that is registered on the controller", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp index 897b85abb..637e4b83d 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.cpp @@ -81,30 +81,31 @@ void Tr2ActionChildEffect::Start( ITr2ActionController& controller ) { if( EveMultiEffectPtr multiEffect = BlueCastPtr( controller.GetOwner() ) ) { - if( EveMultiEffectParameterPtr mep = multiEffect->GetParameterByName( m_targetAnotherOwner ) ) - { - owner = BlueCastPtr( mep->GetParameterObject() ); - } - } else if (EveStretch3Ptr stretch3 = BlueCastPtr( controller.GetOwner() )) - { - if ( m_targetAnotherOwner == BlueSharedString("SourceSpaceObject") ) - { - IEveSpaceObject2Ptr source = stretch3->GetSourceSpaceObject(); - owner = BlueCastPtr( source ); - } - - if ( m_targetAnotherOwner == BlueSharedString("DestSpaceObject") ) - { - IEveSpaceObject2Ptr dest = stretch3->GetDestSpaceObject(); - owner = BlueCastPtr( dest ); - } - } + if( EveMultiEffectParameterPtr mep = multiEffect->GetParameterByName( m_targetAnotherOwner ) ) + { + owner = BlueCastPtr( mep->GetParameterObject() ); + } + } + else if( EveStretch3Ptr stretch3 = BlueCastPtr( controller.GetOwner() ) ) + { + if( m_targetAnotherOwner == BlueSharedString( "SourceSpaceObject" ) ) + { + IEveSpaceObject2Ptr source = stretch3->GetSourceSpaceObject(); + owner = BlueCastPtr( source ); + } + + if( m_targetAnotherOwner == BlueSharedString( "DestSpaceObject" ) ) + { + IEveSpaceObject2Ptr dest = stretch3->GetDestSpaceObject(); + owner = BlueCastPtr( dest ); + } + } } if( !owner ) { return; } - rebind = true; + rebind = true; } m_child = nullptr; @@ -124,14 +125,14 @@ void Tr2ActionChildEffect::Start( ITr2ActionController& controller ) owner->AddToEffectChildrenList( m_child ); m_child->StartControllers(); } - if( rebind ) - { - EveMultiEffectPtr effect = BlueCastPtr( controller.GetOwner() ); - if( effect ) - { - effect->Rebind( true ); - } - } + if( rebind ) + { + EveMultiEffectPtr effect = BlueCastPtr( controller.GetOwner() ); + if( effect ) + { + effect->Rebind( true ); + } + } } } @@ -169,27 +170,27 @@ void Tr2ActionChildEffect::Stop( ITr2ActionController& controller ) cast->RemoveFromEffectChildrenList( m_child ); } } - else if (EveStretch3Ptr stretch3 = BlueCastPtr( controller.GetOwner() )) - { - IEveEffectChildrenOwnerPtr cast; - - if ( m_targetAnotherOwner == BlueSharedString("SourceSpaceObject") ) - { - IEveSpaceObject2Ptr source = stretch3->GetSourceSpaceObject(); - cast = BlueCastPtr( source ); - } - - if ( m_targetAnotherOwner == BlueSharedString("DestSpaceObject") ) - { - IEveSpaceObject2Ptr dest = stretch3->GetDestSpaceObject(); - cast = BlueCastPtr( dest ); - } - - if( cast ) - { - cast->RemoveFromEffectChildrenList( m_child ); - } - } + else if( EveStretch3Ptr stretch3 = BlueCastPtr( controller.GetOwner() ) ) + { + IEveEffectChildrenOwnerPtr cast; + + if( m_targetAnotherOwner == BlueSharedString( "SourceSpaceObject" ) ) + { + IEveSpaceObject2Ptr source = stretch3->GetSourceSpaceObject(); + cast = BlueCastPtr( source ); + } + + if( m_targetAnotherOwner == BlueSharedString( "DestSpaceObject" ) ) + { + IEveSpaceObject2Ptr dest = stretch3->GetDestSpaceObject(); + cast = BlueCastPtr( dest ); + } + + if( cast ) + { + cast->RemoveFromEffectChildrenList( m_child ); + } + } } } m_child = nullptr; diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect.h b/trinity/Controllers/Actions/Tr2ActionChildEffect.h index e3ad99d41..10efcb47e 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect.h +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect.h @@ -7,15 +7,16 @@ BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); -BLUE_CLASS( Tr2ActionChildEffect ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionChildEffect ) : + public ITr2ControllerAction { public: Tr2ActionChildEffect( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; - void Link( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; + void Link( ITr2ActionController & controller ) override; private: std::string m_path; diff --git a/trinity/Controllers/Actions/Tr2ActionChildEffect_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionChildEffect_Blue.cpp index cd5eb1418..d3961bb1d 100644 --- a/trinity/Controllers/Actions/Tr2ActionChildEffect_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionChildEffect_Blue.cpp @@ -12,9 +12,9 @@ const Be::ClassInfo* Tr2ActionChildEffect::ExposeToBlue() MAP_INTERFACE( Tr2ActionChildEffect ) MAP_INTERFACE( ITr2ControllerAction ) - MAP_ATTRIBUTE( - "path", - m_path, + MAP_ATTRIBUTE( + "path", + m_path, "Overlay .red file path\n" ":jessica-widget: filepath\n" ":jessica-file-filter: redfile", diff --git a/trinity/Controllers/Actions/Tr2ActionOverlay.cpp b/trinity/Controllers/Actions/Tr2ActionOverlay.cpp index 70d8eefe7..318dff754 100644 --- a/trinity/Controllers/Actions/Tr2ActionOverlay.cpp +++ b/trinity/Controllers/Actions/Tr2ActionOverlay.cpp @@ -143,7 +143,7 @@ void Tr2ActionOverlay::LoadOverlay( EveSpaceObject2* owner ) StringRemove( path, "_skinned" ); } - bool urgent = BeResMan->IsUrgentResourceLoads( ); + bool urgent = BeResMan->IsUrgentResourceLoads(); BeResMan->SetUrgentResourceLoads( true ); m_overlay = BeResMan->LoadObject( path.c_str() ); BeResMan->SetUrgentResourceLoads( urgent ); diff --git a/trinity/Controllers/Actions/Tr2ActionOverlay.h b/trinity/Controllers/Actions/Tr2ActionOverlay.h index 95e531587..c78eef625 100644 --- a/trinity/Controllers/Actions/Tr2ActionOverlay.h +++ b/trinity/Controllers/Actions/Tr2ActionOverlay.h @@ -15,12 +15,12 @@ BLUE_CLASS( Tr2ActionOverlay ) : public: Tr2ActionOverlay( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; private: - void LoadOverlay( EveSpaceObject2* owner ); + void LoadOverlay( EveSpaceObject2 * owner ); std::string m_path; std::string m_overlayName; diff --git a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp index 681417699..eed76b4ac 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.cpp @@ -11,8 +11,8 @@ #include "Eve/EveEffectRoot2.h" -Tr2ActionPlayCurveSet::Tr2ActionPlayCurveSet( IRoot* ) - :m_startTime( 0 ), +Tr2ActionPlayCurveSet::Tr2ActionPlayCurveSet( IRoot* ) : + m_startTime( 0 ), m_prevTime( 0 ), m_duration( 0 ), m_syncToRange( false ) diff --git a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.h b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.h index ad66a66c9..9239ad528 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.h +++ b/trinity/Controllers/Actions/Tr2ActionPlayCurveSet.h @@ -6,20 +6,22 @@ #include "Include/ITr2Updateable.h" -BLUE_CLASS( Tr2ActionPlayCurveSet ) : public ITr2ControllerAction, public ITr2Updateable +BLUE_CLASS( Tr2ActionPlayCurveSet ) : + public ITr2ControllerAction, public ITr2Updateable { public: Tr2ActionPlayCurveSet( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; void RebaseSimTime( Be::Time diff ) override; bool CanTransition() const override; virtual void Update( Be::Time realTime, Be::Time simTime ); + private: std::string m_curveSetName; std::string m_rangeName; diff --git a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.cpp b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.cpp index 8bd8c6fb2..51f25e7ea 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.cpp @@ -6,8 +6,8 @@ #include "Tr2GrannyAnimation.h" -Tr2ActionPlayMeshAnimation::Tr2ActionPlayMeshAnimation( IRoot* lockobj ) - :m_controller( nullptr ), +Tr2ActionPlayMeshAnimation::Tr2ActionPlayMeshAnimation( IRoot* lockobj ) : + m_controller( nullptr ), m_destinationType( DestinationType::OWNER ), m_playAction( ENQUEUE_PLAY ), m_stopAction( ENQUEUE_STOP ), diff --git a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.h b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.h index 2b6b87d10..475e71166 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.h +++ b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation.h @@ -32,10 +32,10 @@ BLUE_CLASS( Tr2ActionPlayMeshAnimation ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; bool OnModified( Be::Var * value ) override; diff --git a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation_Blue.cpp index 6858b0e6b..faf0907b1 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlayMeshAnimation_Blue.cpp @@ -8,26 +8,24 @@ BLUE_DEFINE( Tr2ActionPlayMeshAnimation ); namespace { - Be::VarChooser PlayActionChooser[] = - { - { "Play", BeCast( Tr2ActionPlayMeshAnimation::PLAY ), "Play animation immediately" }, - { "Enqueue Play", BeCast( Tr2ActionPlayMeshAnimation::ENQUEUE_PLAY ), "Play animation after all other animations complete" }, - { 0 } - }; - Be::VarChooser StopActionChooser[] = - { - { "Stop", BeCast( Tr2ActionPlayMeshAnimation::STOP ), "Stop animation immediately" }, - { "Enqueue Stop", BeCast( Tr2ActionPlayMeshAnimation::ENQUEUE_STOP ), "Stop animation after loop finishes" }, - { "None", BeCast( Tr2ActionPlayMeshAnimation::NONE ), "Do not stop animation" }, - { 0 } - }; - Be::VarChooser DestinationTypeChooser[] = { - { "Owner", BeCast( Tr2ActionPlayMeshAnimation::DestinationType::OWNER ), "Action affects the owner" }, - { "Child", BeCast( Tr2ActionPlayMeshAnimation::DestinationType::CHILD ), "Action affect a child object" }, - { 0 } - }; +Be::VarChooser PlayActionChooser[] = { + { "Play", BeCast( Tr2ActionPlayMeshAnimation::PLAY ), "Play animation immediately" }, + { "Enqueue Play", BeCast( Tr2ActionPlayMeshAnimation::ENQUEUE_PLAY ), "Play animation after all other animations complete" }, + { 0 } +}; +Be::VarChooser StopActionChooser[] = { + { "Stop", BeCast( Tr2ActionPlayMeshAnimation::STOP ), "Stop animation immediately" }, + { "Enqueue Stop", BeCast( Tr2ActionPlayMeshAnimation::ENQUEUE_STOP ), "Stop animation after loop finishes" }, + { "None", BeCast( Tr2ActionPlayMeshAnimation::NONE ), "Do not stop animation" }, + { 0 } +}; +Be::VarChooser DestinationTypeChooser[] = { + { "Owner", BeCast( Tr2ActionPlayMeshAnimation::DestinationType::OWNER ), "Action affects the owner" }, + { "Child", BeCast( Tr2ActionPlayMeshAnimation::DestinationType::CHILD ), "Action affect a child object" }, + { 0 } +}; - } +} const Be::ClassInfo* Tr2ActionPlayMeshAnimation::ExposeToBlue() { diff --git a/trinity/Controllers/Actions/Tr2ActionPlaySound.cpp b/trinity/Controllers/Actions/Tr2ActionPlaySound.cpp index 8b7d378de..ba2cfe887 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlaySound.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPlaySound.cpp @@ -28,7 +28,7 @@ void Tr2ActionPlaySound::Start( ITr2ActionController& controller ) { owner = BlueCastPtr( mep->GetParameterObject() ); } - } + } else if( IEveEffectChildrenOwnerPtr childEffectOwner = BlueCastPtr( controller.GetOwner() ) ) { owner = BlueCastPtr( childEffectOwner->GetEffectChildByName( m_target.c_str() ) ); diff --git a/trinity/Controllers/Actions/Tr2ActionPlaySound.h b/trinity/Controllers/Actions/Tr2ActionPlaySound.h index 3a58a69cf..78e6389e7 100644 --- a/trinity/Controllers/Actions/Tr2ActionPlaySound.h +++ b/trinity/Controllers/Actions/Tr2ActionPlaySound.h @@ -5,15 +5,17 @@ #include "ITr2ControllerAction.h" -BLUE_CLASS( Tr2ActionPlaySound ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionPlaySound ) : + public ITr2ControllerAction { public: Tr2ActionPlaySound( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; void StartWithController( PyObject * controller ); + private: BlueSharedString m_emitterName; BlueSharedString m_soundEvent; diff --git a/trinity/Controllers/Actions/Tr2ActionPython.cpp b/trinity/Controllers/Actions/Tr2ActionPython.cpp index a95f56889..9cf41d9d4 100644 --- a/trinity/Controllers/Actions/Tr2ActionPython.cpp +++ b/trinity/Controllers/Actions/Tr2ActionPython.cpp @@ -128,13 +128,11 @@ void Tr2ActionPython::Stop( ITr2ActionController& controller ) void Tr2ActionPython::Update( Be::Time realTime, Be::Time simTime ) { - ContinueOnMainThread( [ - self = Tr2ActionPythonPtr( this ), - controllerPtr = ITr2ActionControllerPtr( m_controller ), - owner = IRootPtr( m_controller->GetOwner() ), - realDt = TimeAsFloat( realTime - m_prevRealTime ), - simDt = TimeAsFloat( simTime - m_prevSimTime )]() { - + ContinueOnMainThread( [self = Tr2ActionPythonPtr( this ), + controllerPtr = ITr2ActionControllerPtr( m_controller ), + owner = IRootPtr( m_controller->GetOwner() ), + realDt = TimeAsFloat( realTime - m_prevRealTime ), + simDt = TimeAsFloat( simTime - m_prevSimTime )]() { self->m_vtable.onUpdate.CallVoid( owner, controllerPtr, realDt, simDt ); } ); m_prevRealTime = realTime; @@ -161,8 +159,7 @@ void Tr2ActionPython::InstantiateObject() m_instance = CreateInstance( m_module.c_str(), m_className.c_str() ); - auto ExtractMethod = [&]( const char* methodName, BlueScriptCallback& callback ) - { + auto ExtractMethod = [&]( const char* methodName, BlueScriptCallback& callback ) { BluePy method( PyObject_GetAttrString( m_instance, methodName ) ); if( method && PyCallable_Check( method ) ) { @@ -238,7 +235,7 @@ unsigned char* Tr2ActionPython::AllocateReadBuffer( const char* memberName, size void Tr2ActionPython::SetBufferAndSize( const char* memberName, uint8_t* buffer, size_t bufferSize ) { - if ( !m_instance ) + if( !m_instance ) { InstantiateObject(); } diff --git a/trinity/Controllers/Actions/Tr2ActionPython.h b/trinity/Controllers/Actions/Tr2ActionPython.h index 1d27deb05..024fe6713 100644 --- a/trinity/Controllers/Actions/Tr2ActionPython.h +++ b/trinity/Controllers/Actions/Tr2ActionPython.h @@ -21,10 +21,10 @@ BLUE_CLASS( Tr2ActionPython ) : bool Initialize() override; bool OnModified( Be::Var * value ) override; - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void Stop( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; + void Stop( ITr2ActionController & controller ) override; void Update( Be::Time realTime, Be::Time simTime ) override; diff --git a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.cpp b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.cpp index 46e880b34..104728e90 100644 --- a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.cpp +++ b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.cpp @@ -5,30 +5,30 @@ #include "Controllers/Tr2Controller.h" -Tr2ActionResetClipSphereCenter::Tr2ActionResetClipSphereCenter( IRoot* lockobj ) - :m_resetBehavior( OBJECT_CENTER ), +Tr2ActionResetClipSphereCenter::Tr2ActionResetClipSphereCenter( IRoot* lockobj ) : + m_resetBehavior( OBJECT_CENTER ), m_locatorIndex( -1 ), m_locatorSetName( "" ) { } -void Tr2ActionResetClipSphereCenter::ResetClipSphereToLocator( EveSpaceObject2* owner, BlueSharedString locatorSetName, int locatorIndex) +void Tr2ActionResetClipSphereCenter::ResetClipSphereToLocator( EveSpaceObject2* owner, BlueSharedString locatorSetName, int locatorIndex ) { auto locators = owner->GetLocatorsForSet( locatorSetName ); - if( locators && (locatorIndex < 0 || locators->size() > size_t( locatorIndex ) ) ) + if( locators && ( locatorIndex < 0 || locators->size() > size_t( locatorIndex ) ) ) { - if( locatorIndex < 0 ) + if( locatorIndex < 0 ) { locatorIndex = rand() % locators->size(); } - auto& locator = (*locators)[locatorIndex]; + auto& locator = ( *locators )[locatorIndex]; owner->ResetClipSphereCenterToPos( locator.position ); } } void Tr2ActionResetClipSphereCenter::Start( ITr2ActionController& controller ) -{ +{ if( EveSpaceObject2Ptr owner = BlueCastPtr( controller.GetOwner() ) ) { switch( m_resetBehavior ) @@ -44,6 +44,5 @@ void Tr2ActionResetClipSphereCenter::Start( ITr2ActionController& controller ) owner->ResetClipSphereCenter(); break; } - } } \ No newline at end of file diff --git a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.h b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.h index e9891701c..0d0909aba 100644 --- a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.h +++ b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter.h @@ -6,7 +6,8 @@ #include "Eve/SpaceObject/EveSpaceObject2.h" -BLUE_CLASS( Tr2ActionResetClipSphereCenter ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionResetClipSphereCenter ) : + public ITr2ControllerAction { public: enum ResetBehavior @@ -20,10 +21,10 @@ BLUE_CLASS( Tr2ActionResetClipSphereCenter ) : public ITr2ControllerAction EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; private: - void ResetClipSphereToLocator( EveSpaceObject2* owner, BlueSharedString locatorSetName, int locatorIndex ); + void ResetClipSphereToLocator( EveSpaceObject2 * owner, BlueSharedString locatorSetName, int locatorIndex ); BlueSharedString m_locatorSetName; int32_t m_locatorIndex; diff --git a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter_Blue.cpp index f92c78b69..c0e313b3c 100644 --- a/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionResetClipSphereCenter_Blue.cpp @@ -7,13 +7,12 @@ BLUE_DEFINE( Tr2ActionResetClipSphereCenter ); namespace { - Be::VarChooser ResetBehaviorChooser[] = - { - { "Object Center", BeCast( Tr2ActionResetClipSphereCenter::OBJECT_CENTER ), "Sets the clipsphere to the center of the object" }, - { "Last Hit Damage Locator", BeCast( Tr2ActionResetClipSphereCenter::LAST_DAMAGELOCATOR_HIT ), "Sets the clipsphere to the last damage locator hit. If there has no damage locator been hit, then a random one is selected" }, - { "Custom", BeCast( Tr2ActionResetClipSphereCenter::CUSTOM ), "Sets the clipsphere to the locator defined in 'locatorSetName' and 'locatorIndex'" }, - { 0 } - }; +Be::VarChooser ResetBehaviorChooser[] = { + { "Object Center", BeCast( Tr2ActionResetClipSphereCenter::OBJECT_CENTER ), "Sets the clipsphere to the center of the object" }, + { "Last Hit Damage Locator", BeCast( Tr2ActionResetClipSphereCenter::LAST_DAMAGELOCATOR_HIT ), "Sets the clipsphere to the last damage locator hit. If there has no damage locator been hit, then a random one is selected" }, + { "Custom", BeCast( Tr2ActionResetClipSphereCenter::CUSTOM ), "Sets the clipsphere to the locator defined in 'locatorSetName' and 'locatorIndex'" }, + { 0 } +}; } const Be::ClassInfo* Tr2ActionResetClipSphereCenter::ExposeToBlue() diff --git a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.cpp b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.cpp index 9590cde8f..f6293a467 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.cpp @@ -45,13 +45,13 @@ void Tr2ActionSetAttenuationScaling::StartWithController( ITr2ActionController* Start( *controller ); } -// Convert a scaling percentage to float for Wwise. If defined, apply +// Convert a scaling percentage to float for Wwise. If defined, apply // a value from a controller variable to the final scaling factor. float Tr2ActionSetAttenuationScaling::GetScalingFactor() const { float controllerVariableValue = 0; - if ( !m_controllerVariableName.empty() && m_controller != nullptr ) + if( !m_controllerVariableName.empty() && m_controller != nullptr ) { if( auto var = m_controller->GetFloatVariableByName( m_controllerVariableName.c_str() ) ) { @@ -59,7 +59,7 @@ float Tr2ActionSetAttenuationScaling::GetScalingFactor() const } } - if ( controllerVariableValue != 0 ) + if( controllerVariableValue != 0 ) { return m_scalingFactor * controllerVariableValue; } diff --git a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.h b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.h index 10b913051..adcf0d585 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.h +++ b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling.h @@ -5,17 +5,17 @@ #include "ITr2ControllerAction.h" BLUE_CLASS( Tr2ActionSetAttenuationScaling ) : - public ITr2ControllerAction + public ITr2ControllerAction { public: Tr2ActionSetAttenuationScaling( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; - void StartWithController( ITr2ActionController* controller ); + void Start( ITr2ActionController & controller ) override; + void StartWithController( ITr2ActionController * controller ); float GetScalingFactor() const; diff --git a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling_Blue.cpp index 57bfaa3ef..566c58fcd 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetAttenuationScaling_Blue.cpp @@ -14,32 +14,28 @@ const Be::ClassInfo* Tr2ActionSetAttenuationScaling::ExposeToBlue() MAP_INTERFACE( ITr2ControllerAction ) MAP_ATTRIBUTE( "emitter", - m_emitterName, - "Emitter name", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( "controllerVariable", - m_controllerVariableName, + m_emitterName, + "Emitter name", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "controllerVariable", + m_controllerVariableName, "Optionally multiply the value of a controller variable by the scaling factor.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "scalingFactor", - m_scalingFactor, - "The amount you want to scale attenuation by. Applies to all sounds on an emitter.\n" - "Example values:\n" - "0.5 = halfing the attenuation range\n" - "1.0 = keeping the attenuation range as defined in Wwise\n" - "2.0 = Doubling attenuation range \n" + m_scalingFactor, + "The amount you want to scale attenuation by. Applies to all sounds on an emitter.\n" + "Example values:\n" + "0.5 = halfing the attenuation range\n" + "1.0 = keeping the attenuation range as defined in Wwise\n" + "2.0 = Doubling attenuation range \n" "Debug notes: \n" - "* You cannot see this visually represented without stopping the sound and starting it again.\n" + "* You cannot see this visually represented without stopping the sound and starting it again.\n" "* All emitters that are scaled by this will change their color to red", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) // MAP_PROPERTY_READONLY is called regularly by Jessica so this will be updated at all times in Jessica. - MAP_PROPERTY_READONLY("finalScalingFactor", - GetScalingFactor, - "The final scaling factor that will be sent to Wwise." - ) + MAP_PROPERTY_READONLY( "finalScalingFactor", + GetScalingFactor, + "The final scaling factor that will be sent to Wwise." ) MAP_METHOD_AND_WRAP( "StartWithController", StartWithController, diff --git a/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix.h b/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix.h index a4a6f8d76..6101b89e9 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix.h +++ b/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix.h @@ -5,15 +5,16 @@ #include "ITr2ControllerAction.h" -BLUE_CLASS( Tr2ActionSetAudioEmitterPrefix ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionSetAudioEmitterPrefix ) : + public ITr2ControllerAction { public: Tr2ActionSetAudioEmitterPrefix( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; - void StartWithController( ITr2ActionController* controller ); + void Start( ITr2ActionController & controller ) override; + void StartWithController( ITr2ActionController * controller ); private: std::string m_emitterName; diff --git a/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix_Blue.cpp index 19a2f4fca..f26f81d12 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetAudioEmitterPrefix_Blue.cpp @@ -19,7 +19,6 @@ const Be::ClassInfo* Tr2ActionSetAudioEmitterPrefix::ExposeToBlue() "StartWithController", StartWithController, "Starts the action manually without changing state machine state.\n" - ":param controller: The controller sent to the start method of the action.\n" - ) + ":param controller: The controller sent to the start method of the action.\n" ) EXPOSURE_END() } diff --git a/trinity/Controllers/Actions/Tr2ActionSetAudioSwitch.h b/trinity/Controllers/Actions/Tr2ActionSetAudioSwitch.h index 596a85a55..50a553dc7 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetAudioSwitch.h +++ b/trinity/Controllers/Actions/Tr2ActionSetAudioSwitch.h @@ -6,15 +6,16 @@ // A mechanism through which you can set switches in Wwise from a controller. -BLUE_CLASS( Tr2ActionSetAudioSwitch ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionSetAudioSwitch ) : + public ITr2ControllerAction { public: Tr2ActionSetAudioSwitch( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; - void StartWithController( ITr2ActionController* controller ); + void Start( ITr2ActionController & controller ) override; + void StartWithController( ITr2ActionController * controller ); private: std::string m_emitterName; diff --git a/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable.h b/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable.h index 6a7f929f0..117988293 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable.h +++ b/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable.h @@ -20,14 +20,15 @@ BLUE_CLASS( Tr2ActionSetExternalControllerVariable ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); bool IsDestinationValid() const; bool IsVariableValid() const; + private: void LinkToDestinationOwner(); diff --git a/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable_Blue.cpp index 4462ef6e2..9e1d9f639 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetExternalControllerVariable_Blue.cpp @@ -21,8 +21,8 @@ const Be::ClassInfo* Tr2ActionSetExternalControllerVariable::ExposeToBlue() MAP_ATTRIBUTE( "sourceVariable", m_sourceVariable, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "startControllers", m_startControllers, "", Be::READWRITE | Be::PERSIST ) - MAP_PROPERTY_READONLY( "destinationIsValid", IsDestinationValid, "") + MAP_PROPERTY_READONLY( "destinationIsValid", IsDestinationValid, "" ) - - EXPOSURE_END() + + EXPOSURE_END() } diff --git a/trinity/Controllers/Actions/Tr2ActionSetShaderOption.cpp b/trinity/Controllers/Actions/Tr2ActionSetShaderOption.cpp index 22d0dfd29..8aad78655 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetShaderOption.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetShaderOption.cpp @@ -8,7 +8,7 @@ void Tr2ActionSetShaderOption::Start( ITr2ActionController& controller ) { IShaderConfigurerPtr owner = BlueCastPtr( controller.GetOwner() ); - if ( nullptr == owner ) + if( nullptr == owner ) { return; } diff --git a/trinity/Controllers/Actions/Tr2ActionSetShaderOption.h b/trinity/Controllers/Actions/Tr2ActionSetShaderOption.h index ff449464c..30540d00b 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetShaderOption.h +++ b/trinity/Controllers/Actions/Tr2ActionSetShaderOption.h @@ -3,13 +3,14 @@ #pragma once #include "ITr2ControllerAction.h" - -BLUE_CLASS( Tr2ActionSetShaderOption ) : public ITr2ControllerAction + +BLUE_CLASS( Tr2ActionSetShaderOption ) : + public ITr2ControllerAction { public: EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; private: BlueSharedString m_optionKey; diff --git a/trinity/Controllers/Actions/Tr2ActionSetValue.cpp b/trinity/Controllers/Actions/Tr2ActionSetValue.cpp index cad3dff18..7a2a9726f 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetValue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetValue.cpp @@ -7,11 +7,10 @@ #include "Controllers/Tr2ControllerFloatVariable.h" -Tr2ActionSetValue::Tr2ActionSetValue( IRoot* ) - :m_controller( nullptr ), +Tr2ActionSetValue::Tr2ActionSetValue( IRoot* ) : + m_controller( nullptr ), m_delayBinding( false ) { - } void Tr2ActionSetValue::Link( ITr2ActionController& controller ) @@ -46,7 +45,7 @@ void Tr2ActionSetValue::Start( ITr2ActionController& controller ) { return; } - m_destination.SetValue( value.second ); + m_destination.SetValue( value.second ); } bool Tr2ActionSetValue::OnModified( Be::Var* value ) diff --git a/trinity/Controllers/Actions/Tr2ActionSetValue.h b/trinity/Controllers/Actions/Tr2ActionSetValue.h index 3bd600005..a3e9a8c61 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetValue.h +++ b/trinity/Controllers/Actions/Tr2ActionSetValue.h @@ -19,11 +19,11 @@ BLUE_CLASS( Tr2ActionSetValue ) : EXPOSE_TO_BLUE(); - void Link( ITr2ActionController& controller ) override; + void Link( ITr2ActionController & controller ) override; void Unlink() override; - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); bool IsBindingValid() const; bool IsExpressionValid() const; @@ -31,6 +31,7 @@ BLUE_CLASS( Tr2ActionSetValue ) : IRootPtr GetDestination() const; std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: bool IsAttrExpressionValid( const char* attributeName ) const; void LinkDestination( const ITr2ActionController& controller ); diff --git a/trinity/Controllers/Actions/Tr2ActionSetValue_Blue.cpp b/trinity/Controllers/Actions/Tr2ActionSetValue_Blue.cpp index b9f451b4f..2ff613383 100644 --- a/trinity/Controllers/Actions/Tr2ActionSetValue_Blue.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSetValue_Blue.cpp @@ -19,13 +19,13 @@ const Be::ClassInfo* Tr2ActionSetValue::ExposeToBlue() MAP_ATTRIBUTE( "attribute", m_destination.m_attribute, "Destination attribute name", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "value", m_value, "Attribute value expression\n:jessica-widget: expression", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "delayBinding", + MAP_ATTRIBUTE( + "delayBinding", m_delayBinding, "If binding of the destination path needs to be delayed until the action is executed, rather than \n" "binding when the parent controller is linked with the owner. This attribute needs to be turned off most\n" "of the time for performance. Valid usages of this are for changing dynamically created\n" - "subobjects of the parent.", + "subobjects of the parent.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_PROPERTY_READONLY( "isExpressionValid", IsExpressionValid, "Is \"value\" expression valid" ) diff --git a/trinity/Controllers/Actions/Tr2ActionSpawnParticles.cpp b/trinity/Controllers/Actions/Tr2ActionSpawnParticles.cpp index a48cce21a..97f89717d 100644 --- a/trinity/Controllers/Actions/Tr2ActionSpawnParticles.cpp +++ b/trinity/Controllers/Actions/Tr2ActionSpawnParticles.cpp @@ -5,8 +5,8 @@ #include "Particle/Tr2DynamicEmitter.h" -Tr2ActionSpawnParticles::Tr2ActionSpawnParticles( IRoot* ) - :m_rate( 1.f ) +Tr2ActionSpawnParticles::Tr2ActionSpawnParticles( IRoot* ) : + m_rate( 1.f ) { } diff --git a/trinity/Controllers/Actions/Tr2ActionSpawnParticles.h b/trinity/Controllers/Actions/Tr2ActionSpawnParticles.h index 185d97ca6..17bb1e5d6 100644 --- a/trinity/Controllers/Actions/Tr2ActionSpawnParticles.h +++ b/trinity/Controllers/Actions/Tr2ActionSpawnParticles.h @@ -7,14 +7,15 @@ BLUE_DECLARE( Tr2DynamicEmitter ); -BLUE_CLASS( Tr2ActionSpawnParticles ) : public ITr2ControllerAction +BLUE_CLASS( Tr2ActionSpawnParticles ) : + public ITr2ControllerAction { public: Tr2ActionSpawnParticles( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void Start( ITr2ActionController& controller ) override; + void Start( ITr2ActionController & controller ) override; private: Tr2DynamicEmitterPtr m_emitter; diff --git a/trinity/Controllers/Finalizers/ITr2StateMachineStateFinalizer.h b/trinity/Controllers/Finalizers/ITr2StateMachineStateFinalizer.h index c0cf5a3d2..9c6a3fbd4 100644 --- a/trinity/Controllers/Finalizers/ITr2StateMachineStateFinalizer.h +++ b/trinity/Controllers/Finalizers/ITr2StateMachineStateFinalizer.h @@ -6,9 +6,10 @@ BLUE_DECLARE( Tr2Controller ); -BLUE_INTERFACE( ITr2StateMachineStateFinalizer ) : public IRoot +BLUE_INTERFACE( ITr2StateMachineStateFinalizer ) : + public IRoot { - virtual void Link( Tr2Controller& controller ) {}; + virtual void Link( Tr2Controller & controller ){}; virtual void Unlink() {}; - virtual bool CanTransition( Tr2Controller& controller ) const = 0; + virtual bool CanTransition( Tr2Controller & controller ) const = 0; }; diff --git a/trinity/Controllers/Finalizers/Tr2SyncToAnimation.cpp b/trinity/Controllers/Finalizers/Tr2SyncToAnimation.cpp index 10eb8c96a..daf054052 100644 --- a/trinity/Controllers/Finalizers/Tr2SyncToAnimation.cpp +++ b/trinity/Controllers/Finalizers/Tr2SyncToAnimation.cpp @@ -19,7 +19,7 @@ bool Tr2SyncToAnimation::CanTransition( Tr2Controller& controller ) const { return true; } - auto layer = ac->GetAnimationLayer( m_mask.empty() ? nullptr : m_mask.c_str() ); + auto layer = ac->GetAnimationLayer( m_mask.empty() ? nullptr : m_mask.c_str() ); if( !layer ) { return true; diff --git a/trinity/Controllers/Finalizers/Tr2SyncToAnimation.h b/trinity/Controllers/Finalizers/Tr2SyncToAnimation.h index 5feac8c0d..16dee5299 100644 --- a/trinity/Controllers/Finalizers/Tr2SyncToAnimation.h +++ b/trinity/Controllers/Finalizers/Tr2SyncToAnimation.h @@ -5,12 +5,14 @@ #include "ITr2StateMachineStateFinalizer.h" -BLUE_CLASS( Tr2SyncToAnimation ): public ITr2StateMachineStateFinalizer +BLUE_CLASS( Tr2SyncToAnimation ) : + public ITr2StateMachineStateFinalizer { public: EXPOSE_TO_BLUE(); - bool CanTransition( Tr2Controller& controller ) const; + bool CanTransition( Tr2Controller & controller ) const; + private: std::string m_mask; }; diff --git a/trinity/Controllers/ITr2Controller.h b/trinity/Controllers/ITr2Controller.h index 83aaeff14..101b0b247 100644 --- a/trinity/Controllers/ITr2Controller.h +++ b/trinity/Controllers/ITr2Controller.h @@ -13,29 +13,44 @@ enum class UnlinkReason DELETING }; -BLUE_INTERFACE( ITr2Controller ) : public IRoot +BLUE_INTERFACE( ITr2Controller ) : + public IRoot { // Called when a controller is attached to the owning object. The owner makes sure that Link is // called before any other method on the controller. - virtual void Link( IRoot& owner ) {} + virtual void Link( IRoot & owner ) + { + } // Called when a controller is detached from the owning object. The controller should clean up // any references to the owner here. - virtual void Unlink( UnlinkReason reason = UnlinkReason::UNLINKING ) {} + virtual void Unlink( UnlinkReason reason = UnlinkReason::UNLINKING ) + { + } // Returns if the controller already linked to its owner virtual bool IsLinked() const = 0; // Called when the controller needs to start controlling the owner. - virtual void Start() {} + virtual void Start() + { + } // Called when the controller needs to stop controlling the owner. - virtual void Stop() {} + virtual void Stop() + { + } // Called every frame between Start and Stop calls. - virtual void Update( float normalizedUpdateFrequency ) {} + virtual void Update( float normalizedUpdateFrequency ) + { + } // Sets controller variable to a new value. - virtual void SetVariable( const char* name, float value ) {} + virtual void SetVariable( const char* name, float value ) + { + } // Handle an instanteous event - virtual void HandleEvent( const char* eventName ) {} + virtual void HandleEvent( const char* eventName ) + { + } }; // A controller that supports controller actions diff --git a/trinity/Controllers/ITr2ControllerOwner.h b/trinity/Controllers/ITr2ControllerOwner.h index 733ee63a7..80c46618c 100644 --- a/trinity/Controllers/ITr2ControllerOwner.h +++ b/trinity/Controllers/ITr2ControllerOwner.h @@ -5,20 +5,27 @@ #include "Tr2Controller.h" -BLUE_INTERFACE( ITr2ControllerOwner ) : public IRoot +BLUE_INTERFACE( ITr2ControllerOwner ) : + public IRoot { // Called when we need to set a controller variable - virtual void SetControllerVariable( const char* name, float value ) {} + virtual void SetControllerVariable( const char* name, float value ) + { + } // Called when we need a value of a controller variable virtual bool GetControllerValueByName( const char* name, float& out ) { return false; } // Called when we need to handle a controller variable - virtual void HandleControllerEvent( const char* name ) {} + virtual void HandleControllerEvent( const char* name ) + { + } // Called when we want to start all the controllers - virtual void StartControllers() {} - virtual void GetBindingRoots( std::unordered_map& variables ) + virtual void StartControllers() + { + } + virtual void GetBindingRoots( std::unordered_map & variables ) { variables["Owner"] = this->GetRootObject(); }; diff --git a/trinity/Controllers/Tr2BindingPoint.cpp b/trinity/Controllers/Tr2BindingPoint.cpp index 256d0a23c..413f1751b 100644 --- a/trinity/Controllers/Tr2BindingPoint.cpp +++ b/trinity/Controllers/Tr2BindingPoint.cpp @@ -6,273 +6,272 @@ namespace { - std::pair FindEntry( IRoot* object, const char* name ) +std::pair FindEntry( IRoot* object, const char* name ) +{ + if( !object ) { - if( !object ) - { - return std::make_pair( nullptr, nullptr ); - } - auto type = object->ClassType(); - ssize_t offs = 0; - // Loop over all entries - this double loop covers chaining - for( ; type; offs += type->mOffsetToParent, type = type->mParentClassInfo ) + return std::make_pair( nullptr, nullptr ); + } + auto type = object->ClassType(); + ssize_t offs = 0; + // Loop over all entries - this double loop covers chaining + for( ; type; offs += type->mOffsetToParent, type = type->mParentClassInfo ) + { + for( const Be::VarEntry* entry = type->mMemberTable; entry->mName; entry++ ) { - for( const Be::VarEntry* entry = type->mMemberTable; entry->mName; entry++ ) + if( !entry->mGetProperty && strcmp( entry->mName, name ) == 0 ) { - if( !entry->mGetProperty && strcmp( entry->mName, name ) == 0 ) - { - return std::make_pair( entry, BLUEMAPMEMBEROFFSET( object, entry, type, offs ) ); - } + return std::make_pair( entry, BLUEMAPMEMBEROFFSET( object, entry, type, offs ) ); } } - return std::make_pair( nullptr, nullptr ); } + return std::make_pair( nullptr, nullptr ); +} - IRoot* GetIRootAttribute( IRoot* object, const std::string& name ) +IRoot* GetIRootAttribute( IRoot* object, const std::string& name ) +{ + auto entry = FindEntry( object, name.c_str() ); + if( !entry.second ) + { + return nullptr; + } + if( entry.first->mSize && ( entry.first->mType == Be::IROOT || entry.first->mType == Be::IROOTPTR ) ) { - auto entry = FindEntry( object, name.c_str() ); - if( !entry.second ) + if( entry.first->mType == Be::IROOTPTR ) { - return nullptr; + return entry.second->mIRootPtr; } - if( entry.first->mSize && ( entry.first->mType == Be::IROOT || entry.first->mType == Be::IROOTPTR ) ) + else { - if( entry.first->mType == Be::IROOTPTR ) - { - return entry.second->mIRootPtr; - } - else - { - return reinterpret_cast( entry.second ); - } + return reinterpret_cast( entry.second ); } - return nullptr; } + return nullptr; +} + +bool GetStringAttribute( IRoot* object, const std::string& name, std::string& value ) +{ + auto entry = FindEntry( object, name.c_str() ); + if( !entry.second ) + { + return false; + } + switch( entry.first->mType ) + { + case Be::CHARARRAY: + value = reinterpret_cast( entry.second ); + return true; + case Be::CSTRING: + value = reinterpret_cast( entry.second->mCharPtr ); + return true; + case Be::STDSTRING: + value = *reinterpret_cast( entry.second ); + return true; + case Be::SHAREDSTRING: + value = reinterpret_cast( entry.second )->c_str(); + return true; + default: + return false; + } +} - bool GetStringAttribute( IRoot* object, const std::string& name, std::string& value ) +IRoot* GetListElement( IRoot* object, ssize_t index ) +{ + if( IListPtr list = BlueCastPtr( object ) ) { - auto entry = FindEntry( object, name.c_str() ); - if( !entry.second ) + if( index < 0 ) { - return false; + index += int( list->GetSize() ); } - switch( entry.first->mType ) + if( index >= 0 && index < list->GetSize() ) { - case Be::CHARARRAY: - value = reinterpret_cast( entry.second ); - return true; - case Be::CSTRING: - value = reinterpret_cast( entry.second->mCharPtr ); - return true; - case Be::STDSTRING: - value = *reinterpret_cast( entry.second ); - return true; - case Be::SHAREDSTRING: - value = reinterpret_cast( entry.second )->c_str(); - return true; - default: - return false; + return list->GetAt( index ); } } + return nullptr; +} - IRoot* GetListElement( IRoot* object, ssize_t index ) +IRoot* GetListElement( IRoot* object, const std::string& name ) +{ + if( IListPtr list = BlueCastPtr( object ) ) { - if( IListPtr list = BlueCastPtr( object ) ) + auto size = list->GetSize(); + for( ssize_t i = 0; i < size; ++i ) { - if( index < 0 ) - { - index += int( list->GetSize() ); - } - if( index >= 0 && index < list->GetSize() ) + auto element = list->GetAt( i ); + std::string elementName; + if( GetStringAttribute( element, "name", elementName ) && elementName == name ) { - return list->GetAt( index ); + return element; } } - return nullptr; } + return nullptr; +} + +bool IsAlpha( char ch ) +{ + return ( ch >= 'a' && ch <= 'z' ) || ( ch >= 'A' && ch <= 'Z' ); +} - IRoot* GetListElement( IRoot* object, const std::string& name ) +bool IsNum( char ch ) +{ + return ch >= '0' && ch <= '9'; +} + +const char* MatchRoot( const char* path ) +{ + if( !IsAlpha( *path ) && *path != '_' ) { - if( IListPtr list = BlueCastPtr( object ) ) + return path; + } + ++path; + while( true ) + { + if( !IsAlpha( *path ) && !IsNum( *path ) && *path != '_' ) { - auto size = list->GetSize(); - for( ssize_t i = 0; i < size; ++i ) - { - auto element = list->GetAt( i ); - std::string elementName; - if( GetStringAttribute( element, "name", elementName ) && elementName == name ) - { - return element; - } - } - + return path; } - return nullptr; + ++path; } +} - bool IsAlpha( char ch ) +const char* MatchProperty( const char* path ) +{ + if( *path != '.' ) { - return ( ch >= 'a' && ch <= 'z' ) || ( ch >= 'A' && ch <= 'Z' ); + return path; } + ++path; + return MatchRoot( path ); +} - bool IsNum( char ch ) +const char* MatchNumericIndex( const char* path ) +{ + auto start = path; + if( *path != '[' ) { - return ch >= '0' && ch <= '9'; + return path; } - - const char* MatchRoot( const char* path ) + ++path; + if( *path == '-' ) { - if( !IsAlpha( *path ) && *path != '_' ) - { - return path; - } ++path; - while( true ) + } + while( true ) + { + if( !IsNum( *path ) ) { - if( !IsAlpha( *path ) && !IsNum( *path ) && *path != '_' ) + if( *path == ']' ) { + ++path; return path; } - ++path; + else + { + return start; + } } + ++path; } +} - const char* MatchProperty( const char* path ) +const char* MatchNameIndex( const char* path ) +{ + auto start = path; + if( *path != '[' ) { - if( *path != '.' ) - { - return path; - } - ++path; - return MatchRoot( path ); + return path; } - - const char* MatchNumericIndex( const char* path ) + ++path; + if( *path != '\"' ) { - auto start = path; - if( *path != '[' ) - { - return path; - } - ++path; - if( *path == '-' ) - { - ++path; - } - while( true ) - { - if( !IsNum( *path ) ) - { - if( *path == ']' ) - { - ++path; - return path; - } - else - { - return start; - } - } - ++path; - } + return start; } - - const char* MatchNameIndex( const char* path ) + ++path; + while( true ) { - auto start = path; - if( *path != '[' ) - { - return path; - } - ++path; - if( *path != '\"' ) + if( *path == 0 ) { return start; } - ++path; - while( true ) + if( *path == '\"' ) { - if( *path == 0 ) + if( path[1] == ']' ) { - return start; + return path + 2; } - if( *path == '\"' ) + else { - if( path[1] == ']' ) - { - return path + 2; - } - else - { - return start; - } + return start; } - ++path; } + ++path; + } +} + +IRoot* ResolveReference( const std::string& reference, const std::vector>& roots ) +{ + if( reference.empty() ) + { + return nullptr; } - IRoot* ResolveReference( const std::string& reference, const std::vector>& roots ) + auto rootEnd = MatchRoot( reference.c_str() ); + if( rootEnd == reference.c_str() ) { - if( reference.empty() ) - { - return nullptr; - } + return nullptr; + } + auto rootLength = rootEnd - reference.c_str(); - auto rootEnd = MatchRoot( reference.c_str() ); - if( rootEnd == reference.c_str() ) + auto found = std::find_if( begin( roots ), end( roots ), [&]( const auto& x ) { + return x.first.length() == rootLength && strncmp( x.first.c_str(), reference.c_str(), rootLength ) == 0; + } ); + if( found == roots.end() ) + { + return nullptr; + } + auto object = found->second; + + const char* start = rootEnd; + while( *start ) + { + const char* end; + end = MatchProperty( start ); + if( end != start ) { - return nullptr; + auto attrName = std::string( start + 1, end ); + object = GetIRootAttribute( object, attrName ); + start = end; + continue; } - auto rootLength = rootEnd - reference.c_str(); - - auto found = std::find_if( begin( roots ), end( roots ), [&]( const auto& x ) { - return x.first.length() == rootLength && strncmp( x.first.c_str(), reference.c_str(), rootLength ) == 0; - } ); - if( found == roots.end() ) + end = MatchNumericIndex( start ); + if( end != start ) { - return nullptr; + auto index = std::atoi( start + 1 ); + object = GetListElement( object, ssize_t( index ) ); + start = end; + continue; } - auto object = found->second; - - const char* start = rootEnd; - while( *start ) + end = MatchNameIndex( start ); + if( end != start ) { - const char* end; - end = MatchProperty( start ); - if( end != start ) - { - auto attrName = std::string( start + 1, end ); - object = GetIRootAttribute( object, attrName ); - start = end; - continue; - } - end = MatchNumericIndex( start ); - if( end != start ) - { - auto index = std::atoi( start + 1 ); - object = GetListElement( object, ssize_t( index ) ); - start = end; - continue; - } - end = MatchNameIndex( start ); - if( end != start ) - { - auto name = std::string( start + 2, end - 2 ); - object = GetListElement( object, name ); - start = end; - continue; - } - return nullptr; + auto name = std::string( start + 2, end - 2 ); + object = GetListElement( object, name ); + start = end; + continue; } - return object; + return nullptr; } + return object; +} } -Tr2BindingPoint::Tr2BindingPoint() - :m_entry( nullptr ), +Tr2BindingPoint::Tr2BindingPoint() : + m_entry( nullptr ), m_destination( nullptr ), m_entryOffset( -1 ), m_arraySize( 0 ) @@ -499,10 +498,9 @@ IRootPtr ResolveObjectPath( const std::string& reference, const std::map m_resolvedObject; BlueWeakRef m_notifyPtr; diff --git a/trinity/Controllers/Tr2Controller.cpp b/trinity/Controllers/Tr2Controller.cpp index abfdebe31..63b2de9e8 100644 --- a/trinity/Controllers/Tr2Controller.cpp +++ b/trinity/Controllers/Tr2Controller.cpp @@ -18,8 +18,8 @@ CCP_STATS_DECLARE( controllerLinkCount, "Trinity/Controllers/LinkCount", false, CcpMutex g_controllerMutex( "", "g_controllerMutex" ); -Tr2Controller::Tr2Controller( IRoot* lockobj ) - :PARENTLOCK( m_stateMachines ), +Tr2Controller::Tr2Controller( IRoot* lockobj ) : + PARENTLOCK( m_stateMachines ), PARENTLOCK( m_variables ), PARENTLOCK( m_eventHandlers ), m_updateables( "Tr2Controller::m_updateables" ), @@ -94,8 +94,7 @@ void Tr2Controller::OnListModified( long event, ssize_t key, ssize_t key2, IRoot switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - case BELIST_REMOVED: - { + case BELIST_REMOVED: { if( auto owner = m_owner ) { Unlink(); @@ -201,7 +200,7 @@ bool Tr2Controller::IsLinked() const } void Tr2Controller::Start() -{ +{ if( m_isActive ) { Stop(); @@ -329,7 +328,7 @@ void Tr2Controller::GetExpressionTermInfo( std::vector out.push_back( Tr2ExpressionTermInfo::Variable( "Variables", ( *it )->GetName().c_str(), "controller variable" ) ); } } - + const PTr2ControllerFloatVariableVector& Tr2Controller::GetVariables() const { return m_variables; @@ -405,7 +404,7 @@ void Tr2Controller::Callback( BlueSharedString callbackName ) void Tr2Controller::RegisterCallback( BlueSharedString callbackName, BlueScriptCallback callback ) { - m_callbacks.push_back(std::pair( callbackName, callback) ); + m_callbacks.push_back( std::pair( callbackName, callback ) ); } void Tr2Controller::ClearCallbacks() diff --git a/trinity/Controllers/Tr2Controller.h b/trinity/Controllers/Tr2Controller.h index efad09ea7..d8004fff2 100644 --- a/trinity/Controllers/Tr2Controller.h +++ b/trinity/Controllers/Tr2Controller.h @@ -14,7 +14,7 @@ BLUE_DECLARE( Tr2ControllerEventHandler ); BLUE_DECLARE_VECTOR( Tr2ControllerEventHandler ); BLUE_DECLARE_INTERFACE( ITr2Updateable ); -BLUE_CLASS( Tr2Controller ): +BLUE_CLASS( Tr2Controller ) : public ITr2ActionController, public IListNotify, public EveThrottleable @@ -26,7 +26,7 @@ BLUE_CLASS( Tr2Controller ): virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); - virtual void Link( IRoot& owner ); + virtual void Link( IRoot & owner ); virtual void Unlink( UnlinkReason reason = UnlinkReason::UNLINKING ); bool IsLinked() const override; @@ -50,25 +50,28 @@ BLUE_CLASS( Tr2Controller ): void* GetTempArena() const; const std::vector>& GetBindingPathRoots() const; - void RegisterUpdateable( ITr2Updateable& updateable ); - void UnRegisterUpdateable( ITr2Updateable& updateable ); + void RegisterUpdateable( ITr2Updateable & updateable ); + void UnRegisterUpdateable( ITr2Updateable & updateable ); - void Callback( BlueSharedString callbackName); + void Callback( BlueSharedString callbackName ); void RegisterCallback( BlueSharedString callbackName, BlueScriptCallback callback ); void ClearCallbacks(); void ReLink(); private: - size_t GetCallbackCount() { return m_callbacks.size(); }; + size_t GetCallbackCount() + { + return m_callbacks.size(); + }; std::string m_name; PTr2StateMachineVector m_stateMachines; PTr2ControllerFloatVariableVector m_variables; PTr2ControllerEventHandlerVector m_eventHandlers; - + TrackableStdSet m_updateables; - std::vector> m_callbacks; + std::vector> m_callbacks; std::vector m_variableView; CcpMallocBuffer m_variableData; mutable CcpMallocBuffer m_tempArena; diff --git a/trinity/Controllers/Tr2ControllerEventHandler.cpp b/trinity/Controllers/Tr2ControllerEventHandler.cpp index a031a93fb..d2f895a24 100644 --- a/trinity/Controllers/Tr2ControllerEventHandler.cpp +++ b/trinity/Controllers/Tr2ControllerEventHandler.cpp @@ -5,8 +5,8 @@ #include "Actions/ITr2ControllerAction.h" -Tr2ControllerEventHandler::Tr2ControllerEventHandler( IRoot* lockobj ) - :PARENTLOCK( m_actions ), +Tr2ControllerEventHandler::Tr2ControllerEventHandler( IRoot* lockobj ) : + PARENTLOCK( m_actions ), m_controller( nullptr ) { m_actions.SetNotify( this ); diff --git a/trinity/Controllers/Tr2ControllerEventHandler.h b/trinity/Controllers/Tr2ControllerEventHandler.h index 4dc034abc..08ae9b594 100644 --- a/trinity/Controllers/Tr2ControllerEventHandler.h +++ b/trinity/Controllers/Tr2ControllerEventHandler.h @@ -8,7 +8,8 @@ BLUE_DECLARE_IVECTOR( ITr2ControllerAction ); BLUE_DECLARE_INTERFACE( ITr2ActionController ); -BLUE_CLASS( Tr2ControllerEventHandler ): public IListNotify +BLUE_CLASS( Tr2ControllerEventHandler ) : + public IListNotify { public: Tr2ControllerEventHandler( IRoot* lockobj = nullptr ); diff --git a/trinity/Controllers/Tr2ControllerExpression.cpp b/trinity/Controllers/Tr2ControllerExpression.cpp index d08bbffa5..95f6af4eb 100644 --- a/trinity/Controllers/Tr2ControllerExpression.cpp +++ b/trinity/Controllers/Tr2ControllerExpression.cpp @@ -28,497 +28,497 @@ TRI_REGISTER_SETTING( "controllerServerTime", g_controllerServerTime ); namespace { - float StateTime( const Tr2StateMachine* stateMachine ) +float StateTime( const Tr2StateMachine* stateMachine ) +{ + return stateMachine ? stateMachine->GetStateRunTime() : 0; +} + +float CurveSetTime( IRoot* owner, const char* name ) +{ + ITr2CurveSetOwnerPtr csOwner = BlueCastPtr( owner ); + if( !csOwner ) { - return stateMachine ? stateMachine->GetStateRunTime() : 0; + return 0; } - - float CurveSetTime( IRoot* owner, const char* name ) + if( auto slash = strchr( name, '/' ) ) { - ITr2CurveSetOwnerPtr csOwner = BlueCastPtr( owner ); - if( !csOwner ) - { - return 0; - } - if( auto slash = strchr( name, '/' ) ) - { - std::string csName = name; - std::string rangeName = csName.substr( slash - name + 1 ); - csName = csName.substr( 0, slash - name ); - return csOwner->GetRangeDuration( csName, rangeName ); - } - else - { - return csOwner->GetCurveSetDuration( name ); - } + std::string csName = name; + std::string rangeName = csName.substr( slash - name + 1 ); + csName = csName.substr( 0, slash - name ); + return csOwner->GetRangeDuration( csName, rangeName ); } - - float GetExternalControllerVariable( IRoot* ctx, const char* name, float defaultVal ) + else { - ITr2ControllerOwnerPtr owner = BlueCastPtr( ctx ); - if( !owner ) - { - return defaultVal; - } - - float value = 0.0; - if( owner->GetControllerValueByName( name, value ) ) - { - return value; - } + return csOwner->GetCurveSetDuration( name ); + } +} +float GetExternalControllerVariable( IRoot* ctx, const char* name, float defaultVal ) +{ + ITr2ControllerOwnerPtr owner = BlueCastPtr( ctx ); + if( !owner ) + { return defaultVal; } - float AnimationTime( IRoot* ctx, const char* name ) + float value = 0.0; + if( owner->GetControllerValueByName( name, value ) ) { - EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ); - if( !spaceObject ) - { - return 0; - } - auto ac = spaceObject->GetAnimationController(); - if( !ac ) - { - return 0; - } - return ac->FindAnimationDurationByName( name ); + return value; } - float Random( float min, float max) + return defaultVal; +} + +float AnimationTime( IRoot* ctx, const char* name ) +{ + EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ); + if( !spaceObject ) { - float result = min + rand() % int( max - min ); - return result; + return 0; } - - float Mod( float number, float mod ) + auto ac = spaceObject->GetAnimationController(); + if( !ac ) { - if( mod == 0 ) - { - return 0; - } - return fmod( number, mod ); + return 0; } + return ac->FindAnimationDurationByName( name ); +} - float IsAnimationPlaying( IRoot* ctx, const char* layerName ) +float Random( float min, float max ) +{ + float result = min + rand() % int( max - min ); + return result; +} + +float Mod( float number, float mod ) +{ + if( mod == 0 ) { - EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ); - if( !spaceObject ) - { - return 0; - } - auto ac = spaceObject->GetAnimationController(); - if( !ac ) - { - return 0; - } - auto layer = ac->GetAnimationLayer( layerName && !*layerName ? nullptr : layerName ); - if( !layer ) - { - return 0; - } - auto remaining = layer->GetAnimationRemainingTime(); - return remaining > 0; + return 0; } + return fmod( number, mod ); +} - float KillCount( IRoot* ctx ) +float IsAnimationPlaying( IRoot* ctx, const char* layerName ) +{ + EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ); + if( !spaceObject ) { - if( EveShip2Ptr ship = BlueCastPtr( ctx ) ) - { - return ship->GetKillCounterValue(); - } - return 0.0f; + return 0; } - - float BoundingSphereRadius( IRoot* ctx ) + auto ac = spaceObject->GetAnimationController(); + if( !ac ) { - if( EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ) ) - { - return spaceObject->GetRadius(); - } - return 0.0f; + return 0; } - - float ShipSpeed( IRoot* ctx ) + auto layer = ac->GetAnimationLayer( layerName && !*layerName ? nullptr : layerName ); + if( !layer ) { - if( g_controllerFunctionOverrideEnabled ) - { - return g_controllerShipSpeed; - } - if( IEveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ) ) - { - Vector3 velocity; - spaceObject->GetWorldVelocity( velocity ); - return Length( velocity ); - } - else if( EveChildContainerPtr child = BlueCastPtr( ctx ) ) - { - Vector3 velocity; - child->GetWorldVelocity( velocity ); - return Length( velocity ); - } return 0; } + auto remaining = layer->GetAnimationRemainingTime(); + return remaining > 0; +} - float ShaderQuality() +float KillCount( IRoot* ctx ) +{ + if( EveShip2Ptr ship = BlueCastPtr( ctx ) ) { - TR2SHADERMODEL settings = Tr2Renderer::GetShaderModel(); - - switch( settings ) - { - case TR2SM_3_0_LO: - return 0.f; - case TR2SM_3_0_HI: - return 1.f; - case TR2SM_3_0_DEPTH: - return 2.f; - default: - return 0.f; - } + return ship->GetKillCounterValue(); } + return 0.0f; +} - float ShipMaxSpeed( IRoot* ctx ) +float BoundingSphereRadius( IRoot* ctx ) +{ + if( EveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ) ) { - if( g_controllerFunctionOverrideEnabled ) - { - return g_controllerShipMaxSpeed; - } - if( EveShip2Ptr ship = BlueCastPtr( ctx ) ) - { - auto speed = ship->GetMaxSpeed(); - return speed > 0 ? speed : 1; - } - else if( EveChildContainerPtr child = BlueCastPtr( ctx ) ) - { - auto speed = child->GetOwnerMaxSpeed(); - return speed > 0 ? speed : 1; - } - else if( EveChildInstanceContainerPtr child = BlueCastPtr( ctx ) ) - { - auto speed = child->GetOwnerMaxSpeed(); - return speed > 0 ? speed : 1; - } - return 1; + return spaceObject->GetRadius(); } + return 0.0f; +} - float BoosterIntensity( void* ctx ) +float ShipSpeed( IRoot* ctx ) +{ + if( g_controllerFunctionOverrideEnabled ) { - if( EveShip2Ptr ship = BlueCastPtr( static_cast( ctx ) ) ) - { - auto intensity = ship->GetBoosterIntensity(); - return intensity > 0 ? intensity: 0; - } - return 0.0f; + return g_controllerShipSpeed; } - - bool IsValidVariableName( const char* name ) + if( IEveSpaceObject2Ptr spaceObject = BlueCastPtr( ctx ) ) { - auto isLetter = []( char x ) { - return ( x >= 'a' && x <= 'z' ) || ( x >= 'A' && x <= 'Z' ) || ( x == '_' ); - }; - auto isDigit = []( char x ) { - return x >= '0' && x <= '9'; - }; - if( !isLetter( *name ) ) - { - return false; - } - ++name; - while( *name ) - { - if( !isLetter( *name ) && !isDigit( *name) ) - { - return false; - } - ++name; - } - return true; + Vector3 velocity; + spaceObject->GetWorldVelocity( velocity ); + return Length( velocity ); } - -#ifdef _WIN32 - // We really need something like FileTimeToSystemTime in blue and platform-independent - - SYSTEMTIME GetServerTimeParts() + else if( EveChildContainerPtr child = BlueCastPtr( ctx ) ) { - Be::Time time; - if( g_controllerFunctionOverrideEnabled ) - { - time = g_controllerServerTime; - } - else - { - time = BeOS->GetCurrentFrameTime(); - } - - SYSTEMTIME st = {}; - FileTimeToSystemTime( (FILETIME*)&time, &st ); - return st; + Vector3 velocity; + child->GetWorldVelocity( velocity ); + return Length( velocity ); } + return 0; +} + +float ShaderQuality() +{ + TR2SHADERMODEL settings = Tr2Renderer::GetShaderModel(); - float GetServerYear() + switch( settings ) { - return float( GetServerTimeParts().wYear ); + case TR2SM_3_0_LO: + return 0.f; + case TR2SM_3_0_HI: + return 1.f; + case TR2SM_3_0_DEPTH: + return 2.f; + default: + return 0.f; } +} - float GetServerMonth() +float ShipMaxSpeed( IRoot* ctx ) +{ + if( g_controllerFunctionOverrideEnabled ) { - return float( GetServerTimeParts().wMonth ); + return g_controllerShipMaxSpeed; } - - float GetServerDay() + if( EveShip2Ptr ship = BlueCastPtr( ctx ) ) { - return float( GetServerTimeParts().wDay ); + auto speed = ship->GetMaxSpeed(); + return speed > 0 ? speed : 1; } - - float GetServerDayOfWeek() + else if( EveChildContainerPtr child = BlueCastPtr( ctx ) ) { - return float( GetServerTimeParts().wDayOfWeek ); + auto speed = child->GetOwnerMaxSpeed(); + return speed > 0 ? speed : 1; } - - float GetServerHour() + else if( EveChildInstanceContainerPtr child = BlueCastPtr( ctx ) ) { - return float( GetServerTimeParts().wHour ); + auto speed = child->GetOwnerMaxSpeed(); + return speed > 0 ? speed : 1; } + return 1; +} - float GetServerMinute() +float BoosterIntensity( void* ctx ) +{ + if( EveShip2Ptr ship = BlueCastPtr( static_cast( ctx ) ) ) { - return float( GetServerTimeParts().wMinute ); + auto intensity = ship->GetBoosterIntensity(); + return intensity > 0 ? intensity : 0; } + return 0.0f; +} - float GetServerSecond() +bool IsValidVariableName( const char* name ) +{ + auto isLetter = []( char x ) { + return ( x >= 'a' && x <= 'z' ) || ( x >= 'A' && x <= 'Z' ) || ( x == '_' ); + }; + auto isDigit = []( char x ) { + return x >= '0' && x <= '9'; + }; + if( !isLetter( *name ) ) { - return float( GetServerTimeParts().wSecond ); + return false; } - -#else - struct tm GetServerTimeParts() - { - Be::Time time; - if( g_controllerFunctionOverrideEnabled ) - { - time = g_controllerServerTime; - } - else - { - time = BeOS->GetCurrentFrameTime(); - } - - time_t t = time_t( time / 10000000 ); - return *localtime( &t ); - } - float GetServerYear() - { - return float( 1900 + GetServerTimeParts().tm_year ); - } - - float GetServerMonth() - { - return float( GetServerTimeParts().tm_mon + 1 ); - } - - float GetServerDay() - { - return float( GetServerTimeParts().tm_mday ); - } - - float GetServerDayOfWeek() - { - return float( GetServerTimeParts().tm_wday ); - } - - float GetServerHour() - { - return float( GetServerTimeParts().tm_hour ); - } - - float GetServerMinute() - { - return float( GetServerTimeParts().tm_min ); - } - - float GetServerSecond() - { - return float( GetServerTimeParts().tm_sec ); - } -#endif - - float IsWeekend() + ++name; + while( *name ) { - if( int( GetServerDayOfWeek() ) % 6 == 0 ) - { - return 1.f; - } - else + if( !isLetter( *name ) && !isDigit( *name ) ) { - return 0.f; + return false; } + ++name; } + return true; +} + +#ifdef _WIN32 +// We really need something like FileTimeToSystemTime in blue and platform-independent - float TimePhase( float period ) +SYSTEMTIME GetServerTimeParts() +{ + Be::Time time; + if( g_controllerFunctionOverrideEnabled ) { - auto p = TimeFromDouble( period ); - if( !p ) - { - return 0; - } - if( p < 0 ) - { - p = -p; - } - Be::Time time; - if( g_controllerFunctionOverrideEnabled ) - { - time = g_controllerServerTime; - } - else - { - time = BeOS->GetCurrentFrameTime(); - } - return TimeAsFloat( time % p ); + time = g_controllerServerTime; } + else + { + time = BeOS->GetCurrentFrameTime(); + } + + SYSTEMTIME st = {}; + FileTimeToSystemTime( (FILETIME*)&time, &st ); + return st; +} + +float GetServerYear() +{ + return float( GetServerTimeParts().wYear ); +} + +float GetServerMonth() +{ + return float( GetServerTimeParts().wMonth ); +} + +float GetServerDay() +{ + return float( GetServerTimeParts().wDay ); +} + +float GetServerDayOfWeek() +{ + return float( GetServerTimeParts().wDayOfWeek ); +} - typedef float ( *TimeGetter )(); +float GetServerHour() +{ + return float( GetServerTimeParts().wHour ); +} - // Helper function for serverTime comparisons - template - float ServerTimeComparisonHelper( float year, float month, float day, float hour, float minute, float second, Op overQualifier, Op2 disqualifier ) +float GetServerMinute() +{ + return float( GetServerTimeParts().wMinute ); +} + +float GetServerSecond() +{ + return float( GetServerTimeParts().wSecond ); +} + +#else +struct tm GetServerTimeParts() +{ + Be::Time time; + if( g_controllerFunctionOverrideEnabled ) { - struct TimeComp - { - TimeGetter getter; - float userVariable; - } comps[] = { - { GetServerYear, year }, - { GetServerMonth, month }, - { GetServerDay, day }, - { GetServerHour, hour }, - { GetServerMinute, minute }, - { GetServerSecond, second } - }; - - for( const auto& c : comps ) - { - if( c.userVariable == -1.f ) - { - continue; - } - float serverVariable = c.getter(); - if( overQualifier( serverVariable, c.userVariable ) ) - { - return 1.f; - } - if( disqualifier( serverVariable, c.userVariable ) ) - { - return 0.f; - } - } + time = g_controllerServerTime; + } + else + { + time = BeOS->GetCurrentFrameTime(); + } + + time_t t = time_t( time / 10000000 ); + return *localtime( &t ); +} +float GetServerYear() +{ + return float( 1900 + GetServerTimeParts().tm_year ); +} + +float GetServerMonth() +{ + return float( GetServerTimeParts().tm_mon + 1 ); +} + +float GetServerDay() +{ + return float( GetServerTimeParts().tm_mday ); +} + +float GetServerDayOfWeek() +{ + return float( GetServerTimeParts().tm_wday ); +} + +float GetServerHour() +{ + return float( GetServerTimeParts().tm_hour ); +} + +float GetServerMinute() +{ + return float( GetServerTimeParts().tm_min ); +} - // never overQualified, disqualified or all were set to -1 +float GetServerSecond() +{ + return float( GetServerTimeParts().tm_sec ); +} +#endif + +float IsWeekend() +{ + if( int( GetServerDayOfWeek() ) % 6 == 0 ) + { return 1.f; } - - float ServerTimeGreaterThan( float year, float month, float day, float hour, float minute, float second ) + else { - return ServerTimeComparisonHelper( year, month, day, hour, minute, second, std::greater(), std::less() ); + return 0.f; } +} - float ServerTimeLessThanOrEqual( float year, float month, float day, float hour, float minute, float second ) +float TimePhase( float period ) +{ + auto p = TimeFromDouble( period ); + if( !p ) { - return ServerTimeComparisonHelper( year, month, day, hour, minute, second, std::less(), std::greater() ); + return 0; } - - float ServerTimeEqual( float year, float month, float day, float hour, float minute, float second ) + if( p < 0 ) + { + p = -p; + } + Be::Time time; + if( g_controllerFunctionOverrideEnabled ) + { + time = g_controllerServerTime; + } + else { - return ServerTimeComparisonHelper( year, month, day, hour, minute, second, []( float f1, float f2 ) { return false; }, std::not_equal_to() ); + time = BeOS->GetCurrentFrameTime(); } + return TimeAsFloat( time % p ); +} + +typedef float ( *TimeGetter )(); + +// Helper function for serverTime comparisons +template +float ServerTimeComparisonHelper( float year, float month, float day, float hour, float minute, float second, Op overQualifier, Op2 disqualifier ) +{ + struct TimeComp + { + TimeGetter getter; + float userVariable; + } comps[] = { + { GetServerYear, year }, + { GetServerMonth, month }, + { GetServerDay, day }, + { GetServerHour, hour }, + { GetServerMinute, minute }, + { GetServerSecond, second } + }; - float DaysSinceServerTime( float year, float month, float day ) + for( const auto& c : comps ) { - int serverYear = int( GetServerYear() ) - 1900; - int serverMonth = int( GetServerMonth() ); - int serverDay = int( GetServerDay() ); - int targetYear = year == -1.f ? serverYear : int( year ) - 1900; - int targetMonth = month == -1.f ? serverMonth : int( month ); - int targetDay = day == -1.f ? serverDay : int( day ); - struct std::tm a = { 0, 0, 0, targetDay, targetMonth, targetYear }; - struct std::tm b = { 0, 0, 0, serverDay, serverMonth, serverYear }; - std::time_t x = std::mktime( &a ); - std::time_t y = std::mktime( &b ); - if( x != (std::time_t)( -1 ) && y != (std::time_t)( -1 ) ) + if( c.userVariable == -1.f ) { - double differenceInDays = std::difftime( y, x ) / ( 60 * 60 * 24 ); - return float( differenceInDays ); + continue; } + float serverVariable = c.getter(); + if( overQualifier( serverVariable, c.userVariable ) ) + { + return 1.f; + } + if( disqualifier( serverVariable, c.userVariable ) ) + { + return 0.f; + } + } - return std::numeric_limits::min(); - } - - CcpParser::Function s_functions[] = { - CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::STATE_MACHINE_BUFFER_INDEX, 0 ), - CcpParser::Function( "AnimationTime", AnimationTime, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "IsAnimationPlaying", IsAnimationPlaying, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "CurveSetTime", CurveSetTime, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "GetExternalControllerVariable", GetExternalControllerVariable, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "ShipSpeed", ShipSpeed, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "ShipMaxSpeed", ShipMaxSpeed, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "Random", Random ), - CcpParser::Function( "ShipBoosterIntensity", BoosterIntensity, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "KillCount", KillCount, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - CcpParser::Function( "BoundingSphereRadius", BoundingSphereRadius, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), - - CcpParser::Function( "IsWeekend", IsWeekend ), - CcpParser::Function( "ServerYear", GetServerYear ), - CcpParser::Function( "ServerMonth", GetServerMonth ), - CcpParser::Function( "ServerDay", GetServerDay ), - CcpParser::Function( "ServerDayOfWeek", GetServerDayOfWeek ), - CcpParser::Function( "ServerHour", GetServerHour ), - CcpParser::Function( "ServerMinute", GetServerMinute ), - CcpParser::Function( "ServerSecond", GetServerSecond ), - CcpParser::Function( "ServerTimePhase", TimePhase ), - CcpParser::Function( "ServerTimeGreaterThan", ServerTimeGreaterThan ), - CcpParser::Function( "ServerTimeLessThanOrEqual", ServerTimeLessThanOrEqual ), - CcpParser::Function( "ServerTimeEqual", ServerTimeEqual ), - CcpParser::Function( "DaysSinceServerTime", DaysSinceServerTime ), - CcpParser::Function( "ShaderQuality", ShaderQuality ), - }; + // never overQualified, disqualified or all were set to -1 + return 1.f; +} + +float ServerTimeGreaterThan( float year, float month, float day, float hour, float minute, float second ) +{ + return ServerTimeComparisonHelper( year, month, day, hour, minute, second, std::greater(), std::less() ); +} +float ServerTimeLessThanOrEqual( float year, float month, float day, float hour, float minute, float second ) +{ + return ServerTimeComparisonHelper( year, month, day, hour, minute, second, std::less(), std::greater() ); +} - struct ParserObserver: public CcpParser::Observer - { - CcpParser::VariableView m_variables = {}; - uint64_t m_mask = 0; - bool m_maskOverflow = false; - bool m_hasNonPureFunctions = false; +float ServerTimeEqual( float year, float month, float day, float hour, float minute, float second ) +{ + return ServerTimeComparisonHelper( year, month, day, hour, minute, second, []( float f1, float f2 ) { return false; }, std::not_equal_to() ); +} - void OnVariable( const CcpParser::Variable* variable ) override +float DaysSinceServerTime( float year, float month, float day ) +{ + int serverYear = int( GetServerYear() ) - 1900; + int serverMonth = int( GetServerMonth() ); + int serverDay = int( GetServerDay() ); + int targetYear = year == -1.f ? serverYear : int( year ) - 1900; + int targetMonth = month == -1.f ? serverMonth : int( month ); + int targetDay = day == -1.f ? serverDay : int( day ); + struct std::tm a = { 0, 0, 0, targetDay, targetMonth, targetYear }; + struct std::tm b = { 0, 0, 0, serverDay, serverMonth, serverYear }; + std::time_t x = std::mktime( &a ); + std::time_t y = std::mktime( &b ); + if( x != (std::time_t)( -1 ) && y != (std::time_t)( -1 ) ) + { + double differenceInDays = std::difftime( y, x ) / ( 60 * 60 * 24 ); + return float( differenceInDays ); + } + + return std::numeric_limits::min(); +} + +CcpParser::Function s_functions[] = { + CcpParser::Function( "StateTime", StateTime, Tr2ControllerExpression::STATE_MACHINE_BUFFER_INDEX, 0 ), + CcpParser::Function( "AnimationTime", AnimationTime, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "IsAnimationPlaying", IsAnimationPlaying, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "CurveSetTime", CurveSetTime, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "GetExternalControllerVariable", GetExternalControllerVariable, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "ShipSpeed", ShipSpeed, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "ShipMaxSpeed", ShipMaxSpeed, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "Random", Random ), + CcpParser::Function( "ShipBoosterIntensity", BoosterIntensity, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "KillCount", KillCount, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + CcpParser::Function( "BoundingSphereRadius", BoundingSphereRadius, Tr2ControllerExpression::OWNER_BUFFER_INDEX, 0 ), + + CcpParser::Function( "IsWeekend", IsWeekend ), + CcpParser::Function( "ServerYear", GetServerYear ), + CcpParser::Function( "ServerMonth", GetServerMonth ), + CcpParser::Function( "ServerDay", GetServerDay ), + CcpParser::Function( "ServerDayOfWeek", GetServerDayOfWeek ), + CcpParser::Function( "ServerHour", GetServerHour ), + CcpParser::Function( "ServerMinute", GetServerMinute ), + CcpParser::Function( "ServerSecond", GetServerSecond ), + CcpParser::Function( "ServerTimePhase", TimePhase ), + CcpParser::Function( "ServerTimeGreaterThan", ServerTimeGreaterThan ), + CcpParser::Function( "ServerTimeLessThanOrEqual", ServerTimeLessThanOrEqual ), + CcpParser::Function( "ServerTimeEqual", ServerTimeEqual ), + CcpParser::Function( "DaysSinceServerTime", DaysSinceServerTime ), + CcpParser::Function( "ShaderQuality", ShaderQuality ), +}; + + +struct ParserObserver : public CcpParser::Observer +{ + CcpParser::VariableView m_variables = {}; + uint64_t m_mask = 0; + bool m_maskOverflow = false; + bool m_hasNonPureFunctions = false; + + void OnVariable( const CcpParser::Variable* variable ) override + { + auto offset = variable - m_variables.data; + if( offset >= 0 && offset < ptrdiff_t( m_variables.count ) ) { - auto offset = variable - m_variables.data; - if( offset >= 0 && offset < ptrdiff_t( m_variables.count ) ) + if( offset >= 64 ) { - if( offset >= 64 ) - { - m_maskOverflow = true; - } - else - { - m_mask |= 1ull << offset; - } + m_maskOverflow = true; } - } - - void OnFunction( const CcpParser::Function* func ) override - { - if( !HasFlag( func->flags, CcpParser::FunctionFlags::PURE_FUNC ) ) + else { - m_hasNonPureFunctions = true; + m_mask |= 1ull << offset; } } - }; + } + + void OnFunction( const CcpParser::Function* func ) override + { + if( !HasFlag( func->flags, CcpParser::FunctionFlags::PURE_FUNC ) ) + { + m_hasNonPureFunctions = true; + } + } +}; } -Tr2ControllerExpression::Tr2ControllerExpression() - :m_stateMachine( nullptr ), +Tr2ControllerExpression::Tr2ControllerExpression() : + m_stateMachine( nullptr ), m_controller( nullptr ), m_variableMask( 0 ) { @@ -619,9 +619,8 @@ void Tr2ControllerExpression::GetExpressionTermInfo( std::vectorRebaseSimTime(diff); + ( *state )->RebaseSimTime( diff ); } } diff --git a/trinity/Controllers/Tr2StateMachine.h b/trinity/Controllers/Tr2StateMachine.h index 5df444459..06d07bd32 100644 --- a/trinity/Controllers/Tr2StateMachine.h +++ b/trinity/Controllers/Tr2StateMachine.h @@ -22,11 +22,11 @@ BLUE_CLASS( Tr2StateMachine ) : virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); virtual void OnSimClockRebase( Be::Time oldTime, Be::Time newTime ); - void Link( Tr2Controller& controller ); + void Link( Tr2Controller & controller ); void Unlink( UnlinkReason reason = UnlinkReason::UNLINKING ); void Start(); @@ -38,6 +38,7 @@ BLUE_CLASS( Tr2StateMachine ) : float GetMachineRunTime() const; float GetStateRunTime() const; + private: void FollowTransitions( uint64_t variableDirtyMask ); std::string m_name; diff --git a/trinity/Controllers/Tr2StateMachineState.cpp b/trinity/Controllers/Tr2StateMachineState.cpp index 552ddbe07..8148705ec 100644 --- a/trinity/Controllers/Tr2StateMachineState.cpp +++ b/trinity/Controllers/Tr2StateMachineState.cpp @@ -301,7 +301,7 @@ void Tr2StateMachineState::Stop() auto owner = m_stateMachine->GetController() != nullptr ? m_stateMachine->GetController()->GetOwner() : nullptr; for( auto it = begin( m_actions ); it != end( m_actions ); ++it ) { - ContinueOnMainThread( [_ = IRootPtr(owner), action = ITr2ControllerActionPtr( *it ), self = Tr2StateMachineStatePtr( this )]() { + ContinueOnMainThread( [_ = IRootPtr( owner ), action = ITr2ControllerActionPtr( *it ), self = Tr2StateMachineStatePtr( this )]() { if( self->m_stateMachine && action ) { action->Stop( *self->m_stateMachine->GetController() ); diff --git a/trinity/Controllers/Tr2StateMachineState.h b/trinity/Controllers/Tr2StateMachineState.h index bce6fd372..2e2f1582f 100644 --- a/trinity/Controllers/Tr2StateMachineState.h +++ b/trinity/Controllers/Tr2StateMachineState.h @@ -20,7 +20,7 @@ BLUE_CLASS( Tr2StateMachineState ) : EXPOSE_TO_BLUE(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); void Link( const Tr2StateMachine& stateMachine ); @@ -35,6 +35,7 @@ BLUE_CLASS( Tr2StateMachineState ) : const std::string& GetName() const; const Tr2StateMachine* GetStateMachine() const; void UpdateVariableMask() const; + private: Tr2StateMachineState* GetNextState() const; IRoot* GetStateMachinePtr() const; diff --git a/trinity/Controllers/Tr2StateMachineTransition.cpp b/trinity/Controllers/Tr2StateMachineTransition.cpp index f54c98fce..5b10b3b25 100644 --- a/trinity/Controllers/Tr2StateMachineTransition.cpp +++ b/trinity/Controllers/Tr2StateMachineTransition.cpp @@ -9,8 +9,8 @@ #include "Tr2ControllerFloatVariable.h" -Tr2StateMachineTransition::Tr2StateMachineTransition( IRoot* lockobj ) - :m_source( nullptr ) +Tr2StateMachineTransition::Tr2StateMachineTransition( IRoot* lockobj ) : + m_source( nullptr ) { } diff --git a/trinity/Controllers/Tr2StateMachineTransition.h b/trinity/Controllers/Tr2StateMachineTransition.h index 3b2f353a2..4b3c8f301 100644 --- a/trinity/Controllers/Tr2StateMachineTransition.h +++ b/trinity/Controllers/Tr2StateMachineTransition.h @@ -9,14 +9,15 @@ BLUE_DECLARE( Tr2StateMachineState ); BLUE_DECLARE( Tr2ExpressionTermInfo ); -BLUE_CLASS( Tr2StateMachineTransition ) : public INotify +BLUE_CLASS( Tr2StateMachineTransition ) : + public INotify { public: Tr2StateMachineTransition( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); void Link( const Tr2StateMachineState& state ); void Unlink(); @@ -31,6 +32,7 @@ BLUE_CLASS( Tr2StateMachineTransition ) : public INotify std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: void UpdateDestination(); bool IsExpressionValid( const char* attributeName ) const; diff --git a/trinity/Controllers/Tr2StateMachineTransition_Blue.cpp b/trinity/Controllers/Tr2StateMachineTransition_Blue.cpp index f3e76399c..2ed425396 100644 --- a/trinity/Controllers/Tr2StateMachineTransition_Blue.cpp +++ b/trinity/Controllers/Tr2StateMachineTransition_Blue.cpp @@ -21,12 +21,12 @@ const Be::ClassInfo* Tr2StateMachineTransition::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetState", GetSource, "" ) - MAP_METHOD_AND_WRAP( - "GetExpressionTermInfo", - GetExpressionTermInfo, + MAP_METHOD_AND_WRAP( + "GetExpressionTermInfo", + GetExpressionTermInfo, "Returns information on addional functions and variables available to the expression" ) - MAP_METHOD_AND_WRAP( - "IsExpressionValid", + MAP_METHOD_AND_WRAP( + "IsExpressionValid", IsExpressionValid, "Checks if the expression is valid\n" ":param attrName: name of the attribute containing the expression" ) diff --git a/trinity/Controllers/Tr2TimelineController.cpp b/trinity/Controllers/Tr2TimelineController.cpp index 7bc4a7278..884150b1b 100644 --- a/trinity/Controllers/Tr2TimelineController.cpp +++ b/trinity/Controllers/Tr2TimelineController.cpp @@ -510,7 +510,7 @@ void Tr2TimelineController::AddAction( ITr2ControllerAction* action, float start m_actions.Append( action ); - if ( m_owner ) + if( m_owner ) { action->Link( *this ); } @@ -594,7 +594,7 @@ void Tr2TimelineController::EnableTrack( uint32_t trackID, bool enable ) { auto action = m_actions[i]; auto& entry = m_entries[i]; - if ( InRange( m_time, entry ) && entry.trackID == trackID ) + if( InRange( m_time, entry ) && entry.trackID == trackID ) { if( enable ) { diff --git a/trinity/Controllers/Tr2TimelineController.h b/trinity/Controllers/Tr2TimelineController.h index 0b5e8f8f3..e62216cf1 100644 --- a/trinity/Controllers/Tr2TimelineController.h +++ b/trinity/Controllers/Tr2TimelineController.h @@ -66,7 +66,7 @@ BLUE_CLASS( Tr2TimelineController ) : BlueStdResult SetActionStartTime( size_t index, float startTime ); BlueStdResult SetActionEndTime( size_t index, float endTime ); BlueStdResult SetActionTrackID( size_t index, uint32_t trackID ); - void AddAction( ITr2ControllerAction* action, float startTime, float endTime, uint32_t trackID = 0 ); + void AddAction( ITr2ControllerAction * action, float startTime, float endTime, uint32_t trackID = 0 ); BlueStdResult RemoveAction( size_t index ); bool IsActionEnabled( size_t index ) const; diff --git a/trinity/Controllers/Tr2TimelineController_Blue.cpp b/trinity/Controllers/Tr2TimelineController_Blue.cpp index 0642d0c7a..91cc3ae0b 100644 --- a/trinity/Controllers/Tr2TimelineController_Blue.cpp +++ b/trinity/Controllers/Tr2TimelineController_Blue.cpp @@ -15,35 +15,35 @@ const Be::ClassInfo* Tr2TimelineController::ExposeToBlue() MAP_INTERFACE( ITr2ActionController ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "variables", - m_variables, - "List of controller variables", + MAP_ATTRIBUTE( + "variables", + m_variables, + "List of controller variables", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "eventHandlers", - m_eventHandlers, - "List of event handlers that are fired when HandleEvent is called", + MAP_ATTRIBUTE( + "eventHandlers", + m_eventHandlers, + "List of event handlers that are fired when HandleEvent is called", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "isPlaying", - m_isActive, - "True if the timeline is playing or paused (i.e. Start has been called)", + MAP_ATTRIBUTE( + "isPlaying", + m_isActive, + "True if the timeline is playing or paused (i.e. Start has been called)", Be::READ ) - MAP_ATTRIBUTE( - "isPaused", - m_isPaused, - "When it is True the timeline does not avance time while playing", + MAP_ATTRIBUTE( + "isPaused", + m_isPaused, + "When it is True the timeline does not avance time while playing", Be::READ ) - MAP_PROPERTY( - "time", - GetTime, - SetTime, + MAP_PROPERTY( + "time", + GetTime, + SetTime, "Current play time from the start of the timeline in seconds" ) - MAP_ATTRIBUTE( - "timeScale", - m_timeScale, - "Scale for time when playing to speed up or slow down the playback", + MAP_ATTRIBUTE( + "timeScale", + m_timeScale, + "Scale for time when playing to speed up or slow down the playback", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "actions", m_actions, "", Be::PERSISTONLY ) diff --git a/trinity/Curves/Fader/Tr2ScalarFader.cpp b/trinity/Curves/Fader/Tr2ScalarFader.cpp index da91a0ca8..0a227e395 100644 --- a/trinity/Curves/Fader/Tr2ScalarFader.cpp +++ b/trinity/Curves/Fader/Tr2ScalarFader.cpp @@ -113,6 +113,3 @@ bool Tr2ScalarFader::IsKickInZero() const { return ( m_fadeTime <= 0.f ); } - - - diff --git a/trinity/Curves/Fader/Tr2ScalarFader_Blue.cpp b/trinity/Curves/Fader/Tr2ScalarFader_Blue.cpp index d93d5f92d..68247b161 100644 --- a/trinity/Curves/Fader/Tr2ScalarFader_Blue.cpp +++ b/trinity/Curves/Fader/Tr2ScalarFader_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( Tr2ScalarFader ); const Be::ClassInfo* Tr2ScalarFader::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ScalarFader, "" ) - MAP_INTERFACE( Tr2ScalarFader ) + EXPOSURE_BEGIN( Tr2ScalarFader, "" ) + MAP_INTERFACE( Tr2ScalarFader ) MAP_ATTRIBUTE( "value", m_value, "The actual value of this fader", Be::READWRITE ) MAP_ATTRIBUTE( "fading", m_fading, "Holds the current fading speed", Be::READWRITE ) diff --git a/trinity/Curves/Tr2BoneMatrixCurve.cpp b/trinity/Curves/Tr2BoneMatrixCurve.cpp index 77c6e5d22..2076d238c 100644 --- a/trinity/Curves/Tr2BoneMatrixCurve.cpp +++ b/trinity/Curves/Tr2BoneMatrixCurve.cpp @@ -85,10 +85,10 @@ void Tr2BoneMatrixCurve::Sort( void ) { if( m_keys.size() > 1 ) { - m_keys.Sort( ( IList::CompareFn )CompareKeys, NULL ); + m_keys.Sort( (IList::CompareFn)CompareKeys, NULL ); } // We might have added a key passed the length of the curve - if ( m_keys.back()->m_time > m_length ) + if( m_keys.back()->m_time > m_length ) { Tr2MatrixKey* back = m_keys.back(); float preLength = m_length; @@ -96,8 +96,8 @@ void Tr2BoneMatrixCurve::Sort( void ) m_length = back->m_time; m_endValue = back->m_value; - if ( preLength > 0.0f ) - { + if( preLength > 0.0f ) + { back->m_time = preLength; back->m_value = endValue; } @@ -120,12 +120,11 @@ void Tr2BoneMatrixCurve::Sort( void ) // Return Value: // The matrix result of the 'interpolation' // -------------------------------------------------------------------------------------- -Matrix* Tr2BoneMatrixCurve::Interpolate( Matrix* out, Tr2MatrixKey* /*startKey*/, - Tr2MatrixKey* /*endKey*/ ) +Matrix* Tr2BoneMatrixCurve::Interpolate( Matrix* out, Tr2MatrixKey* /*startKey*/, Tr2MatrixKey* /*endKey*/ ) { if( !m_skinnedObject || m_bone.empty() ) { - *out = XMMatrixIdentity(); + *out = XMMatrixIdentity(); return out; } @@ -138,7 +137,7 @@ Matrix* Tr2BoneMatrixCurve::Interpolate( Matrix* out, Tr2MatrixKey* /*startKey*/ } } - const Matrix * m = m_skinnedObject->GetBoneTransform( m_cachedJoint ); + const Matrix* m = m_skinnedObject->GetBoneTransform( m_cachedJoint ); if( m ) { // We've got the bone in local space, now we need to multiply it @@ -147,7 +146,7 @@ Matrix* Tr2BoneMatrixCurve::Interpolate( Matrix* out, Tr2MatrixKey* /*startKey*/ } else { - *out = XMMatrixIdentity(); + *out = XMMatrixIdentity(); } return out; } \ No newline at end of file diff --git a/trinity/Curves/Tr2BoneMatrixCurve.h b/trinity/Curves/Tr2BoneMatrixCurve.h index 28055498f..154378d4a 100644 --- a/trinity/Curves/Tr2BoneMatrixCurve.h +++ b/trinity/Curves/Tr2BoneMatrixCurve.h @@ -14,13 +14,15 @@ // See Also: // Tr2Key, Matrix, Tr2BoneMatrixCurve // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2MatrixKey ): +BLUE_CLASS( Tr2MatrixKey ) : public IRoot, public Tr2Key { public: // Contructor - Tr2MatrixKey( IRoot* lockobj = NULL ) {} + Tr2MatrixKey( IRoot* lockobj = NULL ) + { + } // Blue exposure EXPOSE_TO_BLUE(); @@ -33,7 +35,7 @@ BLUE_DECLARE_VECTOR( Tr2MatrixKey ); // See Also: // Tr2MatrixKey // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2BoneMatrixCurve ): +BLUE_CLASS( Tr2BoneMatrixCurve ) : public Tr2Curve { public: @@ -46,22 +48,25 @@ BLUE_CLASS( Tr2BoneMatrixCurve ): // Sorts the matrix keys void Sort( void ); // Gets the world-transformed bone matrix from the skinned object - Matrix* Interpolate( Matrix* out, Tr2MatrixKey* startKey, Tr2MatrixKey* endKey ); + Matrix* Interpolate( Matrix * out, Tr2MatrixKey * startKey, Tr2MatrixKey * endKey ); // Pointer to the skinned object - Tr2SkinnedObjectPtr m_skinnedObject; + Tr2SkinnedObjectPtr m_skinnedObject; // Sets the name of the target bone void SetBone( const std::string& bone ); // Gets the name of the target bone - const std::string& GetBone() const { return m_bone; } + const std::string& GetBone() const + { + return m_bone; + } private: - std::string m_bone; - unsigned m_cachedJoint; - unsigned m_skeletonTag; + std::string m_bone; + unsigned m_cachedJoint; + unsigned m_skeletonTag; // Additional transform in bone's local space - Matrix m_transform; + Matrix m_transform; void AddKey_( float time, const Matrix& value ); }; diff --git a/trinity/Curves/Tr2BoneMatrixCurve_Blue.cpp b/trinity/Curves/Tr2BoneMatrixCurve_Blue.cpp index 873e20e6c..07e8e3815 100644 --- a/trinity/Curves/Tr2BoneMatrixCurve_Blue.cpp +++ b/trinity/Curves/Tr2BoneMatrixCurve_Blue.cpp @@ -12,7 +12,7 @@ const Be::ClassInfo* Tr2MatrixKey::ExposeToBlue() MAP_INTERFACE( Tr2MatrixKey ) MAP_ATTRIBUTE( "time", m_time, "", Be::READWRITE | Be::PERSIST ) -// MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "", Be::READWRITE | Be::PERSIST | Be::ENUM, QuaternionInterpolationChooser ) + // MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "", Be::READWRITE | Be::PERSIST | Be::ENUM, QuaternionInterpolationChooser ) MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() @@ -36,62 +36,61 @@ const Be::ClassInfo* Tr2BoneMatrixCurve::ExposeToBlue() MAP_ATTRIBUTE( "endValue", m_endValue, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "skinnedObject", m_skinnedObject, "", Be::READWRITE ) -// MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "", Be::READWRITE | Be::PERSIST | Be::ENUM, QuaternionInterpolationChooser ) + // MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "", Be::READWRITE | Be::PERSIST | Be::ENUM, QuaternionInterpolationChooser ) MAP_ATTRIBUTE( "keys", m_keys, "These are the keys of the curve", Be::PERSISTONLY ) - MAP_PROPERTY ( "bone", GetBone, SetBone, "Bone within skinnedObject to track" ) + MAP_PROPERTY( "bone", GetBone, SetBone, "Bone within skinnedObject to track" ) MAP_ATTRIBUTE( "transform", m_transform, "Additional transform in bone local space", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "AddKey", - AddKey, + MAP_METHOD_AND_WRAP( + "AddKey", + AddKey, "Adds a new key\n" ":param time: key time\n" - ":param value: key value" - ); - MAP_METHOD_AND_WRAP( - "RemoveKey", - RemoveKey, + ":param value: key value" ); + MAP_METHOD_AND_WRAP( + "RemoveKey", + RemoveKey, "Removes a key\n" ":param idx: key index" ); MAP_METHOD_AND_WRAP( "GetKeyCount", GetKeyCount, "Returns number of keys" ); - MAP_METHOD_AND_WRAP( - "GetValueAt", - GetValueAt, + MAP_METHOD_AND_WRAP( + "GetValueAt", + GetValueAt, "Returns curve value at a given time\n" ":param time: input time" ); - MAP_METHOD_AND_WRAP( - "GetKeyValue", - GetKeyValue, + MAP_METHOD_AND_WRAP( + "GetKeyValue", + GetKeyValue, "Returns key value\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyTime", - GetKeyTime, + MAP_METHOD_AND_WRAP( + "GetKeyTime", + GetKeyTime, "Returns key time\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyInterpolation", - GetKeyInterpolation, + MAP_METHOD_AND_WRAP( + "GetKeyInterpolation", + GetKeyInterpolation, "Returns interpolation type for the key\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "SetKeyValue", - SetKeyValue, + MAP_METHOD_AND_WRAP( + "SetKeyValue", + SetKeyValue, "Changes key value\n" ":param idx: key index\n" ":param value: new key value" ); - MAP_METHOD_AND_WRAP( - "SetKeyTime", - SetKeyTime, + MAP_METHOD_AND_WRAP( + "SetKeyTime", + SetKeyTime, "Changes key time.\n" "You need to call Sort() afterwards, to make sure the keys are in the correct order.\n" ":param idx: key index\n" ":param time: new key time" ); - MAP_METHOD_AND_WRAP( - "SetKeyInterpolation", - SetKeyInterpolation, + MAP_METHOD_AND_WRAP( + "SetKeyInterpolation", + SetKeyInterpolation, "Changes key interpolation type\n" ":param idx: key index\n" ":param interpolation: new interpolation type" ); diff --git a/trinity/Curves/Tr2CurveColor.cpp b/trinity/Curves/Tr2CurveColor.cpp index 4d2d80953..c726bbfc4 100644 --- a/trinity/Curves/Tr2CurveColor.cpp +++ b/trinity/Curves/Tr2CurveColor.cpp @@ -7,8 +7,8 @@ // -------------------------------------------------------------------------------- -Tr2CurveColor::Tr2CurveColor( IRoot* lockobj ) - :PARENTLOCK( m_r ), +Tr2CurveColor::Tr2CurveColor( IRoot* lockobj ) : + PARENTLOCK( m_r ), PARENTLOCK( m_g ), PARENTLOCK( m_b ), PARENTLOCK( m_a ), diff --git a/trinity/Curves/Tr2CurveColor.h b/trinity/Curves/Tr2CurveColor.h index 60a256aff..a3aa5ce0e 100644 --- a/trinity/Curves/Tr2CurveColor.h +++ b/trinity/Curves/Tr2CurveColor.h @@ -18,10 +18,10 @@ BLUE_CLASS( Tr2CurveColor ) : virtual void UpdateValue( double time ); - virtual Color* Update( Color* in, Be::Time time ); - virtual Color* Update( Color* in, double time ); - virtual Color* GetValueAt( Color* in, Be::Time time ); - virtual Color* GetValueAt( Color* in, double time ); + virtual Color* Update( Color * in, Be::Time time ); + virtual Color* Update( Color * in, double time ); + virtual Color* GetValueAt( Color * in, Be::Time time ); + virtual Color* GetValueAt( Color * in, double time ); virtual float Length(); diff --git a/trinity/Curves/Tr2CurveColorMixer.cpp b/trinity/Curves/Tr2CurveColorMixer.cpp index 6757f36c4..ca199079c 100644 --- a/trinity/Curves/Tr2CurveColorMixer.cpp +++ b/trinity/Curves/Tr2CurveColorMixer.cpp @@ -2,8 +2,8 @@ #include "Tr2CurveColorMixer.h" -Tr2CurveColorMixer::Tr2CurveColorMixer( IRoot* lockobj ) - :m_currentValue( 0, 0, 0, 1 ), +Tr2CurveColorMixer::Tr2CurveColorMixer( IRoot* lockobj ) : + m_currentValue( 0, 0, 0, 1 ), m_convertedLinearValue( 0, 0, 0, 1 ), m_color1( 0, 0, 0, 1 ), m_color2( 0, 0, 0, 1 ), @@ -36,7 +36,7 @@ Color Tr2CurveColorMixer::GetValue( double time ) const // color intensity float i = ( out.r * 0.299f ) + ( out.g * 0.587f ) + ( out.b * 0.114f ); - out = Lerp( Color(i,i,i,i), out, max( 0.0f, m_saturation ) ); + out = Lerp( Color( i, i, i, i ), out, max( 0.0f, m_saturation ) ); return out * m_brightness; } @@ -70,7 +70,7 @@ void Tr2CurveColorMixer::InvertLinearColor( Color* in, Color* out ) { // converting the input color from linear to srgb out->r = InvertLinearValue( in->r ); - out->b= InvertLinearValue( in->b ); + out->b = InvertLinearValue( in->b ); out->g = InvertLinearValue( in->g ); } @@ -80,6 +80,6 @@ float Tr2CurveColorMixer::InvertLinearValue( float x ) { return x / 12.92f; } - - return std::pow( (x + 0.055f) / 1.055f ,2.4f); + + return std::pow( ( x + 0.055f ) / 1.055f, 2.4f ); } diff --git a/trinity/Curves/Tr2CurveColorMixer.h b/trinity/Curves/Tr2CurveColorMixer.h index 02557405d..87c790195 100644 --- a/trinity/Curves/Tr2CurveColorMixer.h +++ b/trinity/Curves/Tr2CurveColorMixer.h @@ -21,13 +21,14 @@ BLUE_CLASS( Tr2CurveColorMixer ) : // ITriColorFunction void UpdateValue( double time ) override; - Color* Update( Color* in, Be::Time time ) override; - Color* Update( Color* in, double time ) override; - Color* GetValueAt( Color* in, Be::Time time ) override; - Color* GetValueAt( Color* in, double time ) override; + Color* Update( Color * in, Be::Time time ) override; + Color* Update( Color * in, double time ) override; + Color* GetValueAt( Color * in, Be::Time time ) override; + Color* GetValueAt( Color * in, double time ) override; // ITriCurveLength float Length() override; + private: // this function was added as an option to convert Linear color to SRGB Color void InvertLinearColor( Color * in, Color * out ); diff --git a/trinity/Curves/Tr2CurveColorMixer_Blue.cpp b/trinity/Curves/Tr2CurveColorMixer_Blue.cpp index 9e737c48f..0f1282640 100644 --- a/trinity/Curves/Tr2CurveColorMixer_Blue.cpp +++ b/trinity/Curves/Tr2CurveColorMixer_Blue.cpp @@ -57,7 +57,7 @@ const Be::ClassInfo* Tr2CurveColorMixer::ExposeToBlue() MAP_ATTRIBUTE( "convertedLinearValue", m_convertedLinearValue, - "Curve value after applying SRGB transformation to the current value, this is used for the cases in" + "Curve value after applying SRGB transformation to the current value, this is used for the cases in" "\n which a linear transformation to the values is occurring such as fog and light colors", Be::READ ) @@ -65,8 +65,7 @@ const Be::ClassInfo* Tr2CurveColorMixer::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time" - ":param time: input time" - ) + ":param time: input time" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveColor_Blue.cpp b/trinity/Curves/Tr2CurveColor_Blue.cpp index 67adcb512..058af4a63 100644 --- a/trinity/Curves/Tr2CurveColor_Blue.cpp +++ b/trinity/Curves/Tr2CurveColor_Blue.cpp @@ -62,8 +62,7 @@ const Be::ClassInfo* Tr2CurveColor::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -75,15 +74,13 @@ const Be::ClassInfo* Tr2CurveColor::ExposeToBlue() ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.HERMITE\n" ":param leftTangent: optional key left (incoming) tangent, defaults to (0, 0, 0, 0)\n" ":param rightTangent: optional key right (outgoing) tangent, defaults to (0, 0, 0, 0)\n" - ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" - ) + ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveCombiner.cpp b/trinity/Curves/Tr2CurveCombiner.cpp index a9480d5dd..2e055e97e 100644 --- a/trinity/Curves/Tr2CurveCombiner.cpp +++ b/trinity/Curves/Tr2CurveCombiner.cpp @@ -3,19 +3,19 @@ #include "Tr2CurveCombiner.h" -Tr2CurveCombiner::Tr2CurveCombiner( IRoot* lockobj ) - :PARENTLOCK( m_curves ), +Tr2CurveCombiner::Tr2CurveCombiner( IRoot* lockobj ) : + PARENTLOCK( m_curves ), m_currentValue( 0, 0, 0 ) { } void Tr2CurveCombiner::UpdateValue( double time ) { - Vector3 out(0.f, 0.f, 0.f); + Vector3 out( 0.f, 0.f, 0.f ); for( auto it = begin( m_curves ); it != end( m_curves ); ++it ) { - Vector3 temp(0.f, 0.f, 0.f ); - (*it)->Update( &temp, time ); + Vector3 temp( 0.f, 0.f, 0.f ); + ( *it )->Update( &temp, time ); out += temp; } m_currentValue = out; @@ -28,7 +28,7 @@ float Tr2CurveCombiner::Length() { if( ITriCurveLengthPtr curve = BlueCastPtr( *it ) ) { - maxLength = max(curve->Length(), maxLength); + maxLength = max( curve->Length(), maxLength ); } } return maxLength; @@ -36,7 +36,7 @@ float Tr2CurveCombiner::Length() Vector3 Tr2CurveCombiner::GetValue( double time ) const { - Vector3 out(0.f, 0.f, 0.f); + Vector3 out( 0.f, 0.f, 0.f ); for( auto it = begin( m_curves ); it != end( m_curves ); ++it ) { Vector3 temp( 0.f, 0.f, 0.f ); @@ -49,10 +49,10 @@ Vector3 Tr2CurveCombiner::GetValue( double time ) const // -------------------------------------------------------------------------------- Vector3* Tr2CurveCombiner::Update( Vector3* in, Be::Time time ) { - Vector3 out(0.f, 0.f, 0.f); + Vector3 out( 0.f, 0.f, 0.f ); for( auto it = begin( m_curves ); it != end( m_curves ); ++it ) { - Vector3 temp(0.f, 0.f, 0.f); + Vector3 temp( 0.f, 0.f, 0.f ); ( *it )->Update( &temp, time ); out += temp; } @@ -64,10 +64,10 @@ Vector3* Tr2CurveCombiner::Update( Vector3* in, Be::Time time ) // -------------------------------------------------------------------------------- Vector3* Tr2CurveCombiner::Update( Vector3* in, double time ) { - Vector3 out(0.f, 0.f, 0.f); + Vector3 out( 0.f, 0.f, 0.f ); for( auto it = begin( m_curves ); it != end( m_curves ); ++it ) { - Vector3 temp(0.f, 0.f, 0.f); + Vector3 temp( 0.f, 0.f, 0.f ); ( *it )->Update( &temp, time ); out += temp; } diff --git a/trinity/Curves/Tr2CurveCombiner.h b/trinity/Curves/Tr2CurveCombiner.h index 0e316e16a..0b6d2e6f4 100644 --- a/trinity/Curves/Tr2CurveCombiner.h +++ b/trinity/Curves/Tr2CurveCombiner.h @@ -10,7 +10,7 @@ BLUE_DECLARE_INTERFACE( ITriVectorFunction ); BLUE_DECLARE_IVECTOR( ITriVectorFunction ); -BLUE_CLASS( Tr2CurveCombiner ): +BLUE_CLASS( Tr2CurveCombiner ) : public ITriCurveLength, public ITriVectorFunction { @@ -25,15 +25,16 @@ BLUE_CLASS( Tr2CurveCombiner ): Vector3 GetValue( double time ) const; - Vector3* Update( Vector3* in, Be::Time time ) override; - Vector3* Update( Vector3* in, double time ) override; - Vector3* GetValueAt( Vector3* in, Be::Time time ) override; - Vector3* GetValueAt( Vector3* in, double time ) override; - Vector3* GetValueDotAt( Vector3* in, Be::Time time ) override; - Vector3* GetValueDotAt( Vector3* in, double time ) override; - Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ) override; - Vector3* GetValueDoubleDotAt( Vector3* in, double time ) override; - Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ) override; + Vector3* Update( Vector3 * in, Be::Time time ) override; + Vector3* Update( Vector3 * in, double time ) override; + Vector3* GetValueAt( Vector3 * in, Be::Time time ) override; + Vector3* GetValueAt( Vector3 * in, double time ) override; + Vector3* GetValueDotAt( Vector3 * in, Be::Time time ) override; + Vector3* GetValueDotAt( Vector3 * in, double time ) override; + Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ) override; + Vector3* GetValueDoubleDotAt( Vector3 * in, double time ) override; + Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ) override; + private: std::string m_name; PITriVectorFunctionVector m_curves; diff --git a/trinity/Curves/Tr2CurveCombiner_Blue.cpp b/trinity/Curves/Tr2CurveCombiner_Blue.cpp index 69d8fcd15..8fc6f1b91 100644 --- a/trinity/Curves/Tr2CurveCombiner_Blue.cpp +++ b/trinity/Curves/Tr2CurveCombiner_Blue.cpp @@ -35,8 +35,7 @@ const Be::ClassInfo* Tr2CurveCombiner::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveConstant.cpp b/trinity/Curves/Tr2CurveConstant.cpp index e63d2c2bc..21796b217 100644 --- a/trinity/Curves/Tr2CurveConstant.cpp +++ b/trinity/Curves/Tr2CurveConstant.cpp @@ -6,8 +6,8 @@ // -------------------------------------------------------------------------------- -Tr2CurveConstant::Tr2CurveConstant( IRoot* ) - :m_value( 0, 0, 0, 0 ) +Tr2CurveConstant::Tr2CurveConstant( IRoot* ) : + m_value( 0, 0, 0, 0 ) { } diff --git a/trinity/Curves/Tr2CurveConstant.h b/trinity/Curves/Tr2CurveConstant.h index 378dd9b2e..7f0ab04d2 100644 --- a/trinity/Curves/Tr2CurveConstant.h +++ b/trinity/Curves/Tr2CurveConstant.h @@ -4,7 +4,7 @@ #include -BLUE_CLASS( Tr2CurveConstant ): +BLUE_CLASS( Tr2CurveConstant ) : public ITriScalarFunction, public ITriVectorFunction, public ITriQuaternionFunction, @@ -23,29 +23,29 @@ BLUE_CLASS( Tr2CurveConstant ): virtual float GetValueAt( double time ); virtual void ScaleTime( float s ); - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); - - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); - - virtual Color* Update( Color* in, Be::Time time ); - virtual Color* Update( Color* in, double time ); - virtual Color* GetValueAt( Color* in, Be::Time time ); - virtual Color* GetValueAt( Color* in, double time ); + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); + + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); + + virtual Color* Update( Color * in, Be::Time time ); + virtual Color* Update( Color * in, double time ); + virtual Color* GetValueAt( Color * in, Be::Time time ); + virtual Color* GetValueAt( Color * in, double time ); private: std::string m_name; diff --git a/trinity/Curves/Tr2CurveConstant_Blue.cpp b/trinity/Curves/Tr2CurveConstant_Blue.cpp index b075f6053..1d658639c 100644 --- a/trinity/Curves/Tr2CurveConstant_Blue.cpp +++ b/trinity/Curves/Tr2CurveConstant_Blue.cpp @@ -15,7 +15,7 @@ const Be::ClassInfo* Tr2CurveConstant::ExposeToBlue() MAP_INTERFACE( ITriColorFunction ) { Be::InterfaceEntry entry = { &GetITriFunctionIID(), BLUE_INTERFACEOFFSET( ITriScalarFunction ) }; - s_interfaces.push_back( entry ); + s_interfaces.push_back( entry ); } MAP_ATTRIBUTE( diff --git a/trinity/Curves/Tr2CurveEulerRotation.cpp b/trinity/Curves/Tr2CurveEulerRotation.cpp index dd34b69ff..cdea6d11f 100644 --- a/trinity/Curves/Tr2CurveEulerRotation.cpp +++ b/trinity/Curves/Tr2CurveEulerRotation.cpp @@ -5,8 +5,8 @@ #include "Tr2CurveScalar.h" -Tr2CurveEulerRotation::Tr2CurveEulerRotation( IRoot* lockobj ) - :PARENTLOCK( m_yaw ), +Tr2CurveEulerRotation::Tr2CurveEulerRotation( IRoot* lockobj ) : + PARENTLOCK( m_yaw ), PARENTLOCK( m_pitch ), PARENTLOCK( m_roll ), m_currentValue( 0, 0, 0, 1 ) @@ -18,7 +18,7 @@ void Tr2CurveEulerRotation::UpdateValue( double time ) float yaw = m_yaw.Update( time ); float pitch = m_pitch.Update( time ); float roll = m_roll.Update( time ); - m_currentValue = RotationQuaternion( yaw, pitch, roll ); + m_currentValue = RotationQuaternion( yaw, pitch, roll ); } float Tr2CurveEulerRotation::Length() @@ -31,7 +31,7 @@ Quaternion Tr2CurveEulerRotation::GetValue( double time ) const float yaw = m_yaw.GetValue( time ); float pitch = m_pitch.GetValue( time ); float roll = m_roll.GetValue( time ); - return RotationQuaternion( yaw, pitch, roll ); + return RotationQuaternion( yaw, pitch, roll ); } // -------------------------------------------------------------------------------- diff --git a/trinity/Curves/Tr2CurveEulerRotation.h b/trinity/Curves/Tr2CurveEulerRotation.h index cbdfe5036..6afe032f9 100644 --- a/trinity/Curves/Tr2CurveEulerRotation.h +++ b/trinity/Curves/Tr2CurveEulerRotation.h @@ -19,14 +19,14 @@ BLUE_CLASS( Tr2CurveEulerRotation ) : virtual void UpdateValue( double time ); - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); virtual float Length(); @@ -41,6 +41,7 @@ BLUE_CLASS( Tr2CurveEulerRotation ) : Be::OptionalWithDefaultValue tangentType ); void SetExtrapolation( Tr2CurveExtrapolation::Type extrapolation ); + private: std::string m_name; diff --git a/trinity/Curves/Tr2CurveEulerRotationExpression.cpp b/trinity/Curves/Tr2CurveEulerRotationExpression.cpp index bda479e1e..2ca779ac6 100644 --- a/trinity/Curves/Tr2CurveEulerRotationExpression.cpp +++ b/trinity/Curves/Tr2CurveEulerRotationExpression.cpp @@ -11,79 +11,79 @@ extern bool g_expressionCurveFakeRandom; namespace { - // -------------------------------------------------------------------------------- - float Fractal( const Tr2CurveEulerRotationExpression* curve, float x, float alpha, float beta, float n ) - { - return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), alpha, beta, int( n + 0.5f ) ) + 1.0 ) / 2.0 ); - } +// -------------------------------------------------------------------------------- +float Fractal( const Tr2CurveEulerRotationExpression* curve, float x, float alpha, float beta, float n ) +{ + return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), alpha, beta, int( n + 0.5f ) ) + 1.0 ) / 2.0 ); +} - // -------------------------------------------------------------------------------- - float Noise( const Tr2CurveEulerRotationExpression* curve, float x ) - { - return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); - } +// -------------------------------------------------------------------------------- +float Noise( const Tr2CurveEulerRotationExpression* curve, float x ) +{ + return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); +} - // -------------------------------------------------------------------------------- - float RandomConstant( const Tr2CurveEulerRotationExpression* curve, float a, float b ) - { - return ( ( b - a ) * curve->GetRandomConstant() ) + a; - } +// -------------------------------------------------------------------------------- +float RandomConstant( const Tr2CurveEulerRotationExpression* curve, float a, float b ) +{ + return ( ( b - a ) * curve->GetRandomConstant() ) + a; +} - float RandomHash( const Tr2CurveEulerRotationExpression* curve, float a, float b, float x ) - { - std::seed_seq::result_type seeds[] = { - *reinterpret_cast( &x ), - std::seed_seq::result_type( reinterpret_cast( curve ) ) - }; - std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); - std::minstd_rand0 e1( seq ); - std::uniform_real_distribution d( a, b ); - return d( e1 ); - } +float RandomHash( const Tr2CurveEulerRotationExpression* curve, float a, float b, float x ) +{ + std::seed_seq::result_type seeds[] = { + *reinterpret_cast( &x ), + std::seed_seq::result_type( reinterpret_cast( curve ) ) + }; + std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); + std::minstd_rand0 e1( seq ); + std::uniform_real_distribution d( a, b ); + return d( e1 ); +} - // -------------------------------------------------------------------------------- - float Random( float a, float b ) +// -------------------------------------------------------------------------------- +float Random( float a, float b ) +{ + if( g_expressionCurveFakeRandom ) { - if( g_expressionCurveFakeRandom ) - { - return ( ( b - a ) * 0.41f ) + a; - } - return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; + return ( ( b - a ) * 0.41f ) + a; } + return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; +} - // -------------------------------------------------------------------------------- - float Input( const Tr2CurveEulerRotationExpression* curve, float index ) - { - return curve->GetInputValue( int32_t( index + 0.5f ) ); - } +// -------------------------------------------------------------------------------- +float Input( const Tr2CurveEulerRotationExpression* curve, float index ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ) ); +} - // -------------------------------------------------------------------------------- - float InputAt( const Tr2CurveEulerRotationExpression* curve, float index, float time ) - { - return curve->GetInputValue( int32_t( index + 0.5f ), time ); - } +// -------------------------------------------------------------------------------- +float InputAt( const Tr2CurveEulerRotationExpression* curve, float index, float time ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ), time ); +} - CcpParser::Function s_functions[] = { - CcpParser::Function( "fractal", &Fractal, 1, 0 ), - CcpParser::Function( "noise", &Noise, 1, 0 ), - CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), - CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), - CcpParser::Function( "random", &Random ), - CcpParser::Function( "randhash", &RandomHash, 1, 0 ), - CcpParser::Function( "input", &Input, 1, 0 ), - CcpParser::Function( "inputAt", &InputAt, 1, 0 ), - CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), - CcpParser::Function( "radians", &XMConvertToRadians, CcpParser::FunctionFlags::PURE_FUNC ), - }; - CcpParser::Constant s_constants[] = { - { "pi", 3.1415926f }, - { "pi2", 2.0f * 3.1415926f }, - }; +CcpParser::Function s_functions[] = { + CcpParser::Function( "fractal", &Fractal, 1, 0 ), + CcpParser::Function( "noise", &Noise, 1, 0 ), + CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), + CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), + CcpParser::Function( "random", &Random ), + CcpParser::Function( "randhash", &RandomHash, 1, 0 ), + CcpParser::Function( "input", &Input, 1, 0 ), + CcpParser::Function( "inputAt", &InputAt, 1, 0 ), + CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), + CcpParser::Function( "radians", &XMConvertToRadians, CcpParser::FunctionFlags::PURE_FUNC ), +}; +CcpParser::Constant s_constants[] = { + { "pi", 3.1415926f }, + { "pi2", 2.0f * 3.1415926f }, +}; } // -------------------------------------------------------------------------------- -Tr2CurveEulerRotationExpression::Tr2CurveEulerRotationExpression( IRoot* lockobj ) - :PARENTLOCK( m_inputs ), +Tr2CurveEulerRotationExpression::Tr2CurveEulerRotationExpression( IRoot* lockobj ) : + PARENTLOCK( m_inputs ), m_currentValue( 0, 0, 0, 1 ), m_timeScale( 1 ), m_randomConstant( float( rand() ) / RAND_MAX ) @@ -103,7 +103,6 @@ bool Tr2CurveEulerRotationExpression::Initialize() } } return true; - } // -------------------------------------------------------------------------------- @@ -130,7 +129,7 @@ Quaternion Tr2CurveEulerRotationExpression::GetValue( double time ) const } components[i] = m_programs[i].Eval( buffers, m_tempArena.get() ); } - return RotationQuaternion( result.x, result.y, result.z ); + return RotationQuaternion( result.x, result.y, result.z ); } // -------------------------------------------------------------------------------- diff --git a/trinity/Curves/Tr2CurveEulerRotationExpression.h b/trinity/Curves/Tr2CurveEulerRotationExpression.h index 563a94da6..08289132f 100644 --- a/trinity/Curves/Tr2CurveEulerRotationExpression.h +++ b/trinity/Curves/Tr2CurveEulerRotationExpression.h @@ -10,7 +10,8 @@ BLUE_DECLARE_IVECTOR( ITriScalarFunction ); BLUE_DECLARE( Tr2ExpressionTermInfo ); -BLUE_CLASS( Tr2CurveEulerRotationExpression ) : public ITriQuaternionFunction, public IInitialize +BLUE_CLASS( Tr2CurveEulerRotationExpression ) : + public ITriQuaternionFunction, public IInitialize { public: Tr2CurveEulerRotationExpression( IRoot* lockobj = nullptr ); @@ -40,18 +41,19 @@ BLUE_CLASS( Tr2CurveEulerRotationExpression ) : public ITriQuaternionFunction, p float GetInputValue( int index, float time ) const; - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); void ResetRandomConstant(); std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: std::string m_name; std::string m_expressions[3]; @@ -63,11 +65,11 @@ BLUE_CLASS( Tr2CurveEulerRotationExpression ) : public ITriQuaternionFunction, p Quaternion m_currentValue; float m_timeScale; float m_randomConstant; - + struct Arguments { mutable float m_time = 0; - + float m_input1 = 0; float m_input2 = 0; float m_input3 = 0; diff --git a/trinity/Curves/Tr2CurveEulerRotationExpression_Blue.cpp b/trinity/Curves/Tr2CurveEulerRotationExpression_Blue.cpp index 7d0efc3ce..0f245b07b 100644 --- a/trinity/Curves/Tr2CurveEulerRotationExpression_Blue.cpp +++ b/trinity/Curves/Tr2CurveEulerRotationExpression_Blue.cpp @@ -87,28 +87,24 @@ const Be::ClassInfo* Tr2CurveEulerRotationExpression::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "ResetRandomConstant", ResetRandomConstant, "Resets curve random constant to a new random value\n" ":jessica-favorite:\n" - ":jessica-icon: timeline/refreshrandom.png" - ) + ":jessica-icon: timeline/refreshrandom.png" ) MAP_METHOD_AND_WRAP( "GetExpressionTermInfo", GetExpressionTermInfo, - "Returns information on addional functions and variables available to the expression" - ) + "Returns information on addional functions and variables available to the expression" ) MAP_METHOD_AND_WRAP( "EvaluateExpression", EvaluateExpression, "Evaluates an expression against this object\n" - ":param expression: expression to evaluate" - ) + ":param expression: expression to evaluate" ) EXPOSURE_END() } diff --git a/trinity/Curves/Tr2CurveEulerRotation_Blue.cpp b/trinity/Curves/Tr2CurveEulerRotation_Blue.cpp index 9be31e1b6..450798812 100644 --- a/trinity/Curves/Tr2CurveEulerRotation_Blue.cpp +++ b/trinity/Curves/Tr2CurveEulerRotation_Blue.cpp @@ -43,8 +43,7 @@ const Be::ClassInfo* Tr2CurveEulerRotation::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -56,15 +55,13 @@ const Be::ClassInfo* Tr2CurveEulerRotation::ExposeToBlue() ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.HERMITE\n" ":param leftTangent: optional key left (incoming) tangent, defaults to (0, 0, 0)\n" ":param rightTangent: optional key right (outgoing) tangent, defaults to (0, 0, 0)\n" - ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" - ) + ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveQuaternion.cpp b/trinity/Curves/Tr2CurveQuaternion.cpp index c802a4e9c..6c9e7e238 100644 --- a/trinity/Curves/Tr2CurveQuaternion.cpp +++ b/trinity/Curves/Tr2CurveQuaternion.cpp @@ -8,8 +8,7 @@ extern Be::VarChooser Tr2CurveInterpolationChooser[]; namespace { -BlueStructureDefinition Tr2CurveQuaternionKeyDef[] = -{ +BlueStructureDefinition Tr2CurveQuaternionKeyDef[] = { { "time", Be::FLOAT32_1, 0 }, { "value", Be::FLOAT32_4, 4 }, { "id", Be::USHORT_1, 20 }, @@ -22,8 +21,8 @@ const Tr2CurveQuaternionKey s_defaultKey = { 0.f, Quaternion( 0.f, 0.f, 0.f, 1.f // -------------------------------------------------------------------------------- -Tr2CurveQuaternion::Tr2CurveQuaternion( IRoot* lockobj ) - :PARENTLOCK( m_keys ), +Tr2CurveQuaternion::Tr2CurveQuaternion( IRoot* lockobj ) : + PARENTLOCK( m_keys ), m_currentValue( 0.f, 0.f, 0.f, 1.f ), m_lastSegment( 0 ), m_extrapolationBefore( Tr2CurveExtrapolation::CLAMP ), diff --git a/trinity/Curves/Tr2CurveQuaternion.h b/trinity/Curves/Tr2CurveQuaternion.h index 91f962ab6..d690f1171 100644 --- a/trinity/Curves/Tr2CurveQuaternion.h +++ b/trinity/Curves/Tr2CurveQuaternion.h @@ -21,7 +21,8 @@ struct Tr2CurveQuaternionKey BLUE_DECLARE_STRUCTURE_LIST( Tr2CurveQuaternionKey ); -BLUE_CLASS( Tr2CurveQuaternion ) : public ITriQuaternionFunction, public ITriCurveLength +BLUE_CLASS( Tr2CurveQuaternion ) : + public ITriQuaternionFunction, public ITriCurveLength { public: Tr2CurveQuaternion( IRoot* lockobj = nullptr ); @@ -30,14 +31,14 @@ BLUE_CLASS( Tr2CurveQuaternion ) : public ITriQuaternionFunction, public ITriCur virtual void UpdateValue( double time ); - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); virtual float Length(); @@ -52,6 +53,7 @@ BLUE_CLASS( Tr2CurveQuaternion ) : public ITriQuaternionFunction, public ITriCur Be::OptionalWithDefaultValue interpolation ); void SetExtrapolation( Tr2CurveExtrapolation::Type extrapolation ); + private: float GetLocalTime( double time ) const; Quaternion GetSegmentValue( float time, const Tr2CurveQuaternionKey& k0, const Tr2CurveQuaternionKey& k1 ) const; diff --git a/trinity/Curves/Tr2CurveQuaternion_Blue.cpp b/trinity/Curves/Tr2CurveQuaternion_Blue.cpp index 690c8bf6f..b57d737b9 100644 --- a/trinity/Curves/Tr2CurveQuaternion_Blue.cpp +++ b/trinity/Curves/Tr2CurveQuaternion_Blue.cpp @@ -50,14 +50,12 @@ const Be::ClassInfo* Tr2CurveQuaternion::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "OnKeysChanged", OnKeysChanged, - "Method to call whenever keys change" - ) + "Method to call whenever keys change" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -66,15 +64,13 @@ const Be::ClassInfo* Tr2CurveQuaternion::ExposeToBlue() "Adds a new key to the curve\n" ":param time: key time\n" ":param value: key value\n" - ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.LINEAR\n" - ) + ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.LINEAR\n" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveRandomAxisRotation.cpp b/trinity/Curves/Tr2CurveRandomAxisRotation.cpp index 78811a472..5f4cfd175 100644 --- a/trinity/Curves/Tr2CurveRandomAxisRotation.cpp +++ b/trinity/Curves/Tr2CurveRandomAxisRotation.cpp @@ -6,15 +6,15 @@ namespace { - float RandAngle( std::default_random_engine& engine ) - { - return float( engine() - engine.min() ) / ( engine.max() - engine.min() ) * XM_PI * 2; - } +float RandAngle( std::default_random_engine& engine ) +{ + return float( engine() - engine.min() ) / ( engine.max() - engine.min() ) * XM_PI * 2; +} } // -------------------------------------------------------------------------------- -Tr2CurveRandomAxisRotation::Tr2CurveRandomAxisRotation( IRoot* lockobj ) - :m_seed( 0 ), +Tr2CurveRandomAxisRotation::Tr2CurveRandomAxisRotation( IRoot* lockobj ) : + m_seed( 0 ), m_period( 1.f ) { SeedChanged(); diff --git a/trinity/Curves/Tr2CurveRandomAxisRotation.h b/trinity/Curves/Tr2CurveRandomAxisRotation.h index 4495699c8..ac0cc0ce3 100644 --- a/trinity/Curves/Tr2CurveRandomAxisRotation.h +++ b/trinity/Curves/Tr2CurveRandomAxisRotation.h @@ -4,7 +4,8 @@ #include -BLUE_CLASS( Tr2CurveRandomAxisRotation ): public ITriQuaternionFunction, public IInitialize +BLUE_CLASS( Tr2CurveRandomAxisRotation ) : + public ITriQuaternionFunction, public IInitialize { public: Tr2CurveRandomAxisRotation( IRoot* lockobj = nullptr ); @@ -13,14 +14,14 @@ BLUE_CLASS( Tr2CurveRandomAxisRotation ): public ITriQuaternionFunction, public virtual void UpdateValue( double time ); - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); virtual bool Initialize(); @@ -28,6 +29,7 @@ BLUE_CLASS( Tr2CurveRandomAxisRotation ): public ITriQuaternionFunction, public uint32_t GetSeed() const; void SetSeed( uint32_t seed ); + public: void SeedChanged(); diff --git a/trinity/Curves/Tr2CurveRandomAxisRotation_Blue.cpp b/trinity/Curves/Tr2CurveRandomAxisRotation_Blue.cpp index d10cefddd..ffc61f563 100644 --- a/trinity/Curves/Tr2CurveRandomAxisRotation_Blue.cpp +++ b/trinity/Curves/Tr2CurveRandomAxisRotation_Blue.cpp @@ -46,8 +46,7 @@ const Be::ClassInfo* Tr2CurveRandomAxisRotation::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveScalar.cpp b/trinity/Curves/Tr2CurveScalar.cpp index 12315b85b..62a323c30 100644 --- a/trinity/Curves/Tr2CurveScalar.cpp +++ b/trinity/Curves/Tr2CurveScalar.cpp @@ -9,8 +9,7 @@ extern Be::VarChooser Tr2CurveTangentTypeChooser[]; namespace { -BlueStructureDefinition Tr2CurveScalarKeyDef[] = -{ +BlueStructureDefinition Tr2CurveScalarKeyDef[] = { { "time", Be::FLOAT32_1, 0 }, { "value", Be::FLOAT32_1, 4 }, { "leftTangent", Be::FLOAT32_1, 8 }, @@ -69,8 +68,8 @@ float GetAutoClamppedTangent( float prevTime, float prevValue, float time, float } // -------------------------------------------------------------------------------- -Tr2CurveScalar::Tr2CurveScalar( IRoot* lockobj ) - :PARENTLOCK( m_keys ), +Tr2CurveScalar::Tr2CurveScalar( IRoot* lockobj ) : + PARENTLOCK( m_keys ), m_timeOffset( 0.f ), m_timeScale( 1.f ), m_currentValue( 0.f ), @@ -228,50 +227,50 @@ float Tr2CurveScalar::GetValue( double time ) const // -------------------------------------------------------------------------------- float Tr2CurveScalar::GetTangent( double time ) const { - if ( m_keys.empty() ) + if( m_keys.empty() ) { return 0; } auto count = m_keys.size(); - if ( m_extrapolationBefore == Tr2CurveExtrapolation::LINEAR || m_extrapolationAfter == Tr2CurveExtrapolation::LINEAR ) + if( m_extrapolationBefore == Tr2CurveExtrapolation::LINEAR || m_extrapolationAfter == Tr2CurveExtrapolation::LINEAR ) { float t = float( time / (double)m_timeScale - (double)m_timeOffset ); - if ( m_extrapolationBefore == Tr2CurveExtrapolation::LINEAR && t < m_keys[0].m_time ) + if( m_extrapolationBefore == Tr2CurveExtrapolation::LINEAR && t < m_keys[0].m_time ) { return m_keys[0].m_leftTangent; } - else if ( m_extrapolationAfter == Tr2CurveExtrapolation::LINEAR && t > m_keys[count - 1].m_time ) + else if( m_extrapolationAfter == Tr2CurveExtrapolation::LINEAR && t > m_keys[count - 1].m_time ) { return m_keys[count - 1].m_rightTangent; } } - if ( count == 1 ) + if( count == 1 ) { return m_keys[0].m_rightTangent; } - if ( m_extrapolationBefore == Tr2CurveExtrapolation::CLAMP && float( time / (double)m_timeScale - (double)m_timeOffset ) <= m_keys[0].m_time ) + if( m_extrapolationBefore == Tr2CurveExtrapolation::CLAMP && float( time / (double)m_timeScale - (double)m_timeOffset ) <= m_keys[0].m_time ) { return 0; } - if ( m_extrapolationAfter == Tr2CurveExtrapolation::CLAMP && float( time / (double)m_timeScale - (double)m_timeOffset ) >= m_keys[m_keys.size() - 1].m_time ) + if( m_extrapolationAfter == Tr2CurveExtrapolation::CLAMP && float( time / (double)m_timeScale - (double)m_timeOffset ) >= m_keys[m_keys.size() - 1].m_time ) { return 0; } float t = GetLocalTime( time ); - for ( size_t i = 0; i + 1 < count; ++i ) + for( size_t i = 0; i + 1 < count; ++i ) { auto& k0 = m_keys[i]; auto& k1 = m_keys[i + 1]; - if ( t >= k0.m_time && t < k1.m_time ) + if( t >= k0.m_time && t < k1.m_time ) { return GetSegmentTangent( t, k0, k1 ); } @@ -282,9 +281,9 @@ float Tr2CurveScalar::GetTangent( double time ) const // -------------------------------------------------------------------------------- void Tr2CurveScalar::OnKeysChanged() { - std::stable_sort( - m_keys.begin(), - m_keys.end(), + std::stable_sort( + m_keys.begin(), + m_keys.end(), []( const Tr2CurveScalarKey& k0, const Tr2CurveScalarKey& k1 ) { return k0.m_time < k1.m_time; } ); for( size_t i = 0; i < m_keys.size(); ++i ) @@ -303,12 +302,14 @@ void Tr2CurveScalar::OnKeysChanged() } else { - float tangent = GetAutoClamppedTangent( - m_keys[i - 1].m_time, - m_keys[i - 1].m_value, - k.m_time, - k.m_value, m_keys - [i + 1].m_time, + float tangent = GetAutoClamppedTangent( + m_keys[i - 1].m_time, + m_keys[i - 1].m_value, + k.m_time, + k.m_value, + m_keys + [i + 1] + .m_time, m_keys[i + 1].m_value ); k.m_leftTangent = tangent; @@ -326,11 +327,12 @@ void Tr2CurveScalar::OnKeysChanged() } else { - float tangent = GetAutoTangent( - m_keys[i - 1].m_time, - m_keys[i - 1].m_value, - k.m_time, k.m_value, - m_keys[i + 1].m_time, + float tangent = GetAutoTangent( + m_keys[i - 1].m_time, + m_keys[i - 1].m_value, + k.m_time, + k.m_value, + m_keys[i + 1].m_time, m_keys[i + 1].m_value ); k.m_leftTangent = tangent; @@ -416,8 +418,7 @@ float Tr2CurveScalar::GetSegmentValue( float time, const Tr2CurveScalarKey& k0, return k1.m_value; } return k0.m_value + ( k1.m_value - k0.m_value ) * ( time - k0.m_time ) / ( k1.m_time - k0.m_time ); - case Tr2CurveInterpolation::HERMITE: - { + case Tr2CurveInterpolation::HERMITE: { float length = k1.m_time - k0.m_time; if( length == 0 ) { @@ -445,16 +446,15 @@ float Tr2CurveScalar::GetSegmentValue( float time, const Tr2CurveScalarKey& k0, // -------------------------------------------------------------------------------- float Tr2CurveScalar::GetSegmentTangent( float time, const Tr2CurveScalarKey& k0, const Tr2CurveScalarKey& k1 ) const { - switch ( k0.m_interpolation ) + switch( k0.m_interpolation ) { case Tr2CurveInterpolation::CONSTANT: return 0; case Tr2CurveInterpolation::LINEAR: return ( k1.m_value - k0.m_value ) / ( k1.m_time - k0.m_time ); - case Tr2CurveInterpolation::HERMITE: - { + case Tr2CurveInterpolation::HERMITE: { float length = k1.m_time - k0.m_time; - if ( length == 0 ) + if( length == 0 ) { return k1.m_rightTangent; } diff --git a/trinity/Curves/Tr2CurveScalar.h b/trinity/Curves/Tr2CurveScalar.h index 3bd3072e0..86f356112 100644 --- a/trinity/Curves/Tr2CurveScalar.h +++ b/trinity/Curves/Tr2CurveScalar.h @@ -7,47 +7,47 @@ namespace Tr2CurveInterpolation { - enum Type - { - // Constant (L0) interpolation - CONSTANT = 0, - // Linear (L1) interpolation - LINEAR = 1, - // Hermite/cubic (L2) interpolation - HERMITE = 2, - }; +enum Type +{ + // Constant (L0) interpolation + CONSTANT = 0, + // Linear (L1) interpolation + LINEAR = 1, + // Hermite/cubic (L2) interpolation + HERMITE = 2, +}; } namespace Tr2CurveTangentType { - enum Type - { - // Auto-adjusted tangents (without overshoots) - AUTO_CLAMP = 0, - // Auto-adjusted tangents - AUTO = 1, - // Joined hand-edited tangents - FREE_JOINED = 2, - // Split hand-edited tangents - FREE_SPLIT = 3, - }; +enum Type +{ + // Auto-adjusted tangents (without overshoots) + AUTO_CLAMP = 0, + // Auto-adjusted tangents + AUTO = 1, + // Joined hand-edited tangents + FREE_JOINED = 2, + // Split hand-edited tangents + FREE_SPLIT = 3, +}; } namespace Tr2CurveExtrapolation { - enum Type - { - // Use first/last values when outside curve time range - CLAMP = 0, - // Cycle the curve - CYCLE = 1, - // Cycle the curve with mirroring - MIRROR = 2, - // Linear exprapolation based on first/last key tangent - LINEAR = 3, - }; +enum Type +{ + // Use first/last values when outside curve time range + CLAMP = 0, + // Cycle the curve + CYCLE = 1, + // Cycle the curve with mirroring + MIRROR = 2, + // Linear exprapolation based on first/last key tangent + LINEAR = 3, +}; } @@ -83,13 +83,14 @@ struct Tr2CurveScalarDefinition struct Tr2CurveRasterizeDestination { - uint32_t width; // destination texture width in pixels + uint32_t width; // destination texture width in pixels uint32_t stride; // destination texture stride in float16 elements Float_16* data; }; -BLUE_CLASS( Tr2CurveScalar ): public ITriScalarFunction, public ITriCurveLength +BLUE_CLASS( Tr2CurveScalar ) : + public ITriScalarFunction, public ITriCurveLength { public: Tr2CurveScalar( IRoot* lockobj = nullptr ); diff --git a/trinity/Curves/Tr2CurveScalarExpression.cpp b/trinity/Curves/Tr2CurveScalarExpression.cpp index 9deaf60d6..a0343ad53 100644 --- a/trinity/Curves/Tr2CurveScalarExpression.cpp +++ b/trinity/Curves/Tr2CurveScalarExpression.cpp @@ -15,78 +15,78 @@ TRI_REGISTER_SETTING( "expressionCurveFakeRandom", g_expressionCurveFakeRandom ) namespace { - // -------------------------------------------------------------------------------- - float Fractal( const Tr2CurveScalarExpression* curve, float x, float alpha, float beta, float n ) - { +// -------------------------------------------------------------------------------- +float Fractal( const Tr2CurveScalarExpression* curve, float x, float alpha, float beta, float n ) +{ return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), alpha, beta, int( n + 0.5f ) ) + 1.0 ) / 2.0 ); - } +} - // -------------------------------------------------------------------------------- - float Noise( const Tr2CurveScalarExpression* curve, float x ) - { - return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); - } +// -------------------------------------------------------------------------------- +float Noise( const Tr2CurveScalarExpression* curve, float x ) +{ + return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); +} - // -------------------------------------------------------------------------------- - float RandomConstant( const Tr2CurveScalarExpression* curve, float a, float b ) - { - return ( ( b - a ) * curve->GetRandomConstant() ) + a; - } +// -------------------------------------------------------------------------------- +float RandomConstant( const Tr2CurveScalarExpression* curve, float a, float b ) +{ + return ( ( b - a ) * curve->GetRandomConstant() ) + a; +} - float RandomHash( const Tr2CurveScalarExpression* curve, float a, float b, float x ) - { - std::seed_seq::result_type seeds[] = { - *reinterpret_cast( &x ), - std::seed_seq::result_type( reinterpret_cast( curve ) ) - }; - std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); - std::minstd_rand0 e1( seq ); - std::uniform_real_distribution d( a, b ); - return d( e1 ); - } +float RandomHash( const Tr2CurveScalarExpression* curve, float a, float b, float x ) +{ + std::seed_seq::result_type seeds[] = { + *reinterpret_cast( &x ), + std::seed_seq::result_type( reinterpret_cast( curve ) ) + }; + std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); + std::minstd_rand0 e1( seq ); + std::uniform_real_distribution d( a, b ); + return d( e1 ); +} - // -------------------------------------------------------------------------------- - float Random( float a, float b ) +// -------------------------------------------------------------------------------- +float Random( float a, float b ) +{ + if( g_expressionCurveFakeRandom ) { - if( g_expressionCurveFakeRandom ) - { - return ( ( b - a ) * 0.41f ) + a; - } - return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; + return ( ( b - a ) * 0.41f ) + a; } + return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; +} - // -------------------------------------------------------------------------------- - float Input( const Tr2CurveScalarExpression* curve, float index ) - { - return curve->GetInputValue( int32_t( index + 0.5f ) ); - } +// -------------------------------------------------------------------------------- +float Input( const Tr2CurveScalarExpression* curve, float index ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ) ); +} - // -------------------------------------------------------------------------------- - float InputAt( const Tr2CurveScalarExpression* curve, float index, float time ) - { - return curve->GetInputValue( int32_t( index + 0.5f ), time ); - } +// -------------------------------------------------------------------------------- +float InputAt( const Tr2CurveScalarExpression* curve, float index, float time ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ), time ); +} - CcpParser::Function s_functions[] = { - CcpParser::Function( "fractal", &Fractal, 1, 0 ), - CcpParser::Function( "noise", &Noise, 1, 0 ), - CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), - CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), - CcpParser::Function( "random", &Random ), - CcpParser::Function( "randhash", &RandomHash, 1, 0 ), - CcpParser::Function( "input", &Input, 1, 0 ), - CcpParser::Function( "inputAt", &InputAt, 1, 0 ), - CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), - }; - CcpParser::Constant s_constants[] = { - { "pi", 3.1415926f }, - { "pi2", 2.0f * 3.1415926f }, - }; +CcpParser::Function s_functions[] = { + CcpParser::Function( "fractal", &Fractal, 1, 0 ), + CcpParser::Function( "noise", &Noise, 1, 0 ), + CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), + CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), + CcpParser::Function( "random", &Random ), + CcpParser::Function( "randhash", &RandomHash, 1, 0 ), + CcpParser::Function( "input", &Input, 1, 0 ), + CcpParser::Function( "inputAt", &InputAt, 1, 0 ), + CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), +}; +CcpParser::Constant s_constants[] = { + { "pi", 3.1415926f }, + { "pi2", 2.0f * 3.1415926f }, +}; } // -------------------------------------------------------------------------------- -Tr2CurveScalarExpression::Tr2CurveScalarExpression( IRoot* lockobj ) - :PARENTLOCK( m_inputs ), +Tr2CurveScalarExpression::Tr2CurveScalarExpression( IRoot* lockobj ) : + PARENTLOCK( m_inputs ), m_currentValue( 0 ), m_timeScale( 1 ), m_randomConstant( float( rand() ) / RAND_MAX ) diff --git a/trinity/Curves/Tr2CurveScalarExpression.h b/trinity/Curves/Tr2CurveScalarExpression.h index daeba7dd3..dd3bbc0e2 100644 --- a/trinity/Curves/Tr2CurveScalarExpression.h +++ b/trinity/Curves/Tr2CurveScalarExpression.h @@ -10,7 +10,8 @@ BLUE_DECLARE_IVECTOR( ITriScalarFunction ); BLUE_DECLARE( Tr2ExpressionTermInfo ); -BLUE_CLASS( Tr2CurveScalarExpression ) : public ITriScalarFunction, public IInitialize +BLUE_CLASS( Tr2CurveScalarExpression ) : + public ITriScalarFunction, public IInitialize { public: Tr2CurveScalarExpression( IRoot* lockobj = nullptr ); @@ -38,6 +39,7 @@ BLUE_CLASS( Tr2CurveScalarExpression ) : public ITriScalarFunction, public IInit void ResetRandomConstant(); std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: std::string m_name; std::string m_expression; @@ -50,11 +52,11 @@ BLUE_CLASS( Tr2CurveScalarExpression ) : public ITriScalarFunction, public IInit float m_currentValue; float m_timeScale; float m_randomConstant; - + struct Arguments { mutable float m_time = 0; - + float m_input1 = 0; float m_input2 = 0; float m_input3 = 0; diff --git a/trinity/Curves/Tr2CurveScalarExpression_Blue.cpp b/trinity/Curves/Tr2CurveScalarExpression_Blue.cpp index f876c8f07..74ea770bd 100644 --- a/trinity/Curves/Tr2CurveScalarExpression_Blue.cpp +++ b/trinity/Curves/Tr2CurveScalarExpression_Blue.cpp @@ -24,10 +24,10 @@ const Be::ClassInfo* Tr2CurveScalarExpression::ExposeToBlue() m_expression, "Curve expression\n:jessica-widget: expression", Be::PERSISTONLY ) - MAP_PROPERTY( - "expression", - GetExpression, - SetExpression, + MAP_PROPERTY( + "expression", + GetExpression, + SetExpression, "Curve expression\n:jessica-widget: expression" ) MAP_ATTRIBUTE( "currentValue", @@ -65,28 +65,24 @@ const Be::ClassInfo* Tr2CurveScalarExpression::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "ResetRandomConstant", ResetRandomConstant, "Resets curve random constant to a new random value\n" ":jessica-favorite:\n" - ":jessica-icon: timeline/refreshrandom.png" - ) + ":jessica-icon: timeline/refreshrandom.png" ) MAP_METHOD_AND_WRAP( "GetExpressionTermInfo", GetExpressionTermInfo, - "Returns information on addional functions and variables available to the expression" - ) + "Returns information on addional functions and variables available to the expression" ) MAP_METHOD_AND_WRAP( "EvaluateExpression", EvaluateExpression, "Evaluates an expression against this object\n" - ":param expression: expression to evaluate" - ) + ":param expression: expression to evaluate" ) EXPOSURE_END() } diff --git a/trinity/Curves/Tr2CurveScalar_Blue.cpp b/trinity/Curves/Tr2CurveScalar_Blue.cpp index 4ad2675f8..2593a6fdd 100644 --- a/trinity/Curves/Tr2CurveScalar_Blue.cpp +++ b/trinity/Curves/Tr2CurveScalar_Blue.cpp @@ -6,73 +6,48 @@ BLUE_DEFINE( Tr2CurveScalar ); -Be::VarChooser Tr2CurveInterpolationChooser[] = -{ - { - "CONSTANT", - BeCast( Tr2CurveInterpolation::CONSTANT ), - "Performs a constant interpolation" - }, - { - "LINEAR", - BeCast( Tr2CurveInterpolation::LINEAR ), - "Performs a linear interpolation" - }, - { - "HERMITE", - BeCast( Tr2CurveInterpolation::HERMITE ), - "Performs a hermite interpolation" - }, +Be::VarChooser Tr2CurveInterpolationChooser[] = { + { "CONSTANT", + BeCast( Tr2CurveInterpolation::CONSTANT ), + "Performs a constant interpolation" }, + { "LINEAR", + BeCast( Tr2CurveInterpolation::LINEAR ), + "Performs a linear interpolation" }, + { "HERMITE", + BeCast( Tr2CurveInterpolation::HERMITE ), + "Performs a hermite interpolation" }, { 0 } }; -Be::VarChooser Tr2CurveTangentTypeChooser[] = -{ - { - "AUTO_CLAMP", - BeCast( Tr2CurveTangentType::AUTO_CLAMP ), - "Automatically adjust tangents clamping overshoots" - }, - { - "AUTO", - BeCast( Tr2CurveTangentType::AUTO ), - "Automatically adjust tangents" - }, - { - "FREE_JOINED", - BeCast( Tr2CurveTangentType::FREE_JOINED ), - "Manually adjusted unified tangents" - }, - { - "FREE_SPLIT", - BeCast( Tr2CurveTangentType::FREE_SPLIT ), - "Manually adjusted broken tangents" - }, +Be::VarChooser Tr2CurveTangentTypeChooser[] = { + { "AUTO_CLAMP", + BeCast( Tr2CurveTangentType::AUTO_CLAMP ), + "Automatically adjust tangents clamping overshoots" }, + { "AUTO", + BeCast( Tr2CurveTangentType::AUTO ), + "Automatically adjust tangents" }, + { "FREE_JOINED", + BeCast( Tr2CurveTangentType::FREE_JOINED ), + "Manually adjusted unified tangents" }, + { "FREE_SPLIT", + BeCast( Tr2CurveTangentType::FREE_SPLIT ), + "Manually adjusted broken tangents" }, { 0 } }; -Be::VarChooser Tr2CurveExtrapolationChooser[] = -{ - { - "CLAMP", - BeCast( Tr2CurveExtrapolation::CLAMP ), - "Use start/end values" - }, - { - "CYCLE", - BeCast( Tr2CurveExtrapolation::CYCLE ), - "Cycle the curve" - }, - { - "MIRROR", - BeCast( Tr2CurveExtrapolation::MIRROR ), - "Mirror the curve" - }, - { - "LINEAR", - BeCast( Tr2CurveExtrapolation::LINEAR ), - "Linear exprapolation based on first/last key tangent" - }, +Be::VarChooser Tr2CurveExtrapolationChooser[] = { + { "CLAMP", + BeCast( Tr2CurveExtrapolation::CLAMP ), + "Use start/end values" }, + { "CYCLE", + BeCast( Tr2CurveExtrapolation::CYCLE ), + "Cycle the curve" }, + { "MIRROR", + BeCast( Tr2CurveExtrapolation::MIRROR ), + "Mirror the curve" }, + { "LINEAR", + BeCast( Tr2CurveExtrapolation::LINEAR ), + "Linear exprapolation based on first/last key tangent" }, { 0 } }; @@ -90,27 +65,27 @@ const Be::ClassInfo* Tr2CurveScalar::ExposeToBlue() MAP_INTERFACE( ITriFunction ) MAP_INTERFACE( ITriCurveLength ) - MAP_ATTRIBUTE( - "keys", - m_keys, - "Curve control keys", + MAP_ATTRIBUTE( + "keys", + m_keys, + "Curve control keys", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "name", - m_name, - "", + MAP_ATTRIBUTE( + "name", + m_name, + "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "currentValue", - m_currentValue, - "Curve value after the last update", + MAP_ATTRIBUTE( + "currentValue", + m_currentValue, + "Curve value after the last update", Be::READ ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "extrapolationBefore", - m_extrapolationBefore, - "Curve extrapolation type for time before the start of the curve", - Be::ENUM | Be::READWRITE | Be::PERSIST, + MAP_ATTRIBUTE_WITH_CHOOSER( + "extrapolationBefore", + m_extrapolationBefore, + "Curve extrapolation type for time before the start of the curve", + Be::ENUM | Be::READWRITE | Be::PERSIST, Tr2CurveExtrapolationChooser ) MAP_ATTRIBUTE_WITH_CHOOSER( "extrapolationAfter", @@ -119,62 +94,55 @@ const Be::ClassInfo* Tr2CurveScalar::ExposeToBlue() Be::ENUM | Be::READWRITE | Be::PERSIST, Tr2CurveExtrapolationChooser ) - MAP_ATTRIBUTE( - "timeOffset", - m_timeOffset, - "Curve internal time offset", + MAP_ATTRIBUTE( + "timeOffset", + m_timeOffset, + "Curve internal time offset", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( - "timeScale", - m_timeScale, - "Curve internal time scale", + "timeScale", + m_timeScale, + "Curve internal time scale", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "GetTangentAt", GetTangent, "Returns the tangent to the curve at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "OnKeysChanged", OnKeysChanged, - "Method to call whenever keys change" - ) + "Method to call whenever keys change" ) MAP_METHOD_AND_WRAP( "GetTimeOffset", GetTimeOffset, - "Returns internal time offset in seconds" - ) + "Returns internal time offset in seconds" ) MAP_METHOD_AND_WRAP( "SetTimeOffset", SetTimeOffset, "Set new time offset in seconds\n" - ":param timeOffset: new time offset" - ) + ":param timeOffset: new time offset" ) MAP_METHOD_AND_WRAP( "GetTimeScale", GetTimeScale, - "Returns internal time scaling factor" - ) + "Returns internal time scaling factor" ) MAP_METHOD_AND_WRAP( "SetTimeScale", SetTimeScale, "Set new time scaling factor\n" - ":param timeScaling: new time scaling factor" - ) + ":param timeScaling: new time scaling factor" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -186,15 +154,13 @@ const Be::ClassInfo* Tr2CurveScalar::ExposeToBlue() ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.HERMITE\n" ":param leftTangent: optional key left (incoming) tangent, defaults to 0\n" ":param rightTangent: optional key right (outgoing) tangent, defaults to 0\n" - ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" - ) + ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveVector2.cpp b/trinity/Curves/Tr2CurveVector2.cpp index fd5ad4764..5a9879946 100644 --- a/trinity/Curves/Tr2CurveVector2.cpp +++ b/trinity/Curves/Tr2CurveVector2.cpp @@ -6,8 +6,8 @@ // -------------------------------------------------------------------------------- -Tr2CurveVector2::Tr2CurveVector2( IRoot* lockobj ) - :PARENTLOCK( m_x ), +Tr2CurveVector2::Tr2CurveVector2( IRoot* lockobj ) : + PARENTLOCK( m_x ), PARENTLOCK( m_y ), m_currentValue( 0, 0 ) { diff --git a/trinity/Curves/Tr2CurveVector2.h b/trinity/Curves/Tr2CurveVector2.h index cbe852def..4eaca79da 100644 --- a/trinity/Curves/Tr2CurveVector2.h +++ b/trinity/Curves/Tr2CurveVector2.h @@ -32,6 +32,7 @@ BLUE_CLASS( Tr2CurveVector2 ) : Be::OptionalWithDefaultValue tangentType ); void SetExtrapolation( Tr2CurveExtrapolation::Type extrapolation ); + private: std::string m_name; diff --git a/trinity/Curves/Tr2CurveVector2_Blue.cpp b/trinity/Curves/Tr2CurveVector2_Blue.cpp index 06a7079b8..42b61c870 100644 --- a/trinity/Curves/Tr2CurveVector2_Blue.cpp +++ b/trinity/Curves/Tr2CurveVector2_Blue.cpp @@ -37,8 +37,7 @@ const Be::ClassInfo* Tr2CurveVector2::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -50,15 +49,13 @@ const Be::ClassInfo* Tr2CurveVector2::ExposeToBlue() ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.HERMITE\n" ":param leftTangent: optional key left (incoming) tangent, defaults to (0, 0)\n" ":param rightTangent: optional key right (outgoing) tangent, defaults to (0, 0)\n" - ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" - ) + ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveVector3.cpp b/trinity/Curves/Tr2CurveVector3.cpp index d26686fb1..1777c1a71 100644 --- a/trinity/Curves/Tr2CurveVector3.cpp +++ b/trinity/Curves/Tr2CurveVector3.cpp @@ -5,8 +5,8 @@ #include "Tr2CurveScalar.h" -Tr2CurveVector3::Tr2CurveVector3( IRoot* lockobj ) - :PARENTLOCK( m_x ), +Tr2CurveVector3::Tr2CurveVector3( IRoot* lockobj ) : + PARENTLOCK( m_x ), PARENTLOCK( m_y ), PARENTLOCK( m_z ), m_currentValue( 0, 0, 0 ) diff --git a/trinity/Curves/Tr2CurveVector3.h b/trinity/Curves/Tr2CurveVector3.h index b609e06bb..3a03f1a27 100644 --- a/trinity/Curves/Tr2CurveVector3.h +++ b/trinity/Curves/Tr2CurveVector3.h @@ -8,7 +8,7 @@ #include -BLUE_CLASS( Tr2CurveVector3 ): +BLUE_CLASS( Tr2CurveVector3 ) : public ITriCurveLength, public ITriVectorFunction { @@ -33,15 +33,16 @@ BLUE_CLASS( Tr2CurveVector3 ): void SetExtrapolation( Tr2CurveExtrapolation::Type extrapolation ); - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); + private: std::string m_name; diff --git a/trinity/Curves/Tr2CurveVector3Expression.cpp b/trinity/Curves/Tr2CurveVector3Expression.cpp index ff9e19f13..50b4bd698 100644 --- a/trinity/Curves/Tr2CurveVector3Expression.cpp +++ b/trinity/Curves/Tr2CurveVector3Expression.cpp @@ -11,78 +11,78 @@ extern bool g_expressionCurveFakeRandom; namespace { - // -------------------------------------------------------------------------------- - float Fractal( const Tr2CurveVector3Expression* curve, float x, float alpha, float beta, float n ) - { - return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), alpha, beta, int( n + 0.5f ) ) + 1.0 ) / 2.0 ); - } +// -------------------------------------------------------------------------------- +float Fractal( const Tr2CurveVector3Expression* curve, float x, float alpha, float beta, float n ) +{ + return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), alpha, beta, int( n + 0.5f ) ) + 1.0 ) / 2.0 ); +} - // -------------------------------------------------------------------------------- - float Noise( const Tr2CurveVector3Expression* curve, float x ) - { - return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); - } +// -------------------------------------------------------------------------------- +float Noise( const Tr2CurveVector3Expression* curve, float x ) +{ + return float( ( PerlinNoise1D( x + curve->GetRandomConstant(), 1.0, 1.0, 1 ) + 1.0 ) / 2.0 ); +} - // -------------------------------------------------------------------------------- - float RandomConstant( const Tr2CurveVector3Expression* curve, float a, float b ) - { - return ( ( b - a ) * curve->GetRandomConstant() ) + a; - } +// -------------------------------------------------------------------------------- +float RandomConstant( const Tr2CurveVector3Expression* curve, float a, float b ) +{ + return ( ( b - a ) * curve->GetRandomConstant() ) + a; +} - float RandomHash( const Tr2CurveVector3Expression* curve, float a, float b, float x ) - { - std::seed_seq::result_type seeds[] = { - *reinterpret_cast( &x ), - std::seed_seq::result_type( reinterpret_cast( curve ) ) - }; - std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); - std::minstd_rand0 e1( seq ); - std::uniform_real_distribution d( a, b ); - return d( e1 ); - } +float RandomHash( const Tr2CurveVector3Expression* curve, float a, float b, float x ) +{ + std::seed_seq::result_type seeds[] = { + *reinterpret_cast( &x ), + std::seed_seq::result_type( reinterpret_cast( curve ) ) + }; + std::seed_seq seq( std::begin( seeds ), std::end( seeds ) ); + std::minstd_rand0 e1( seq ); + std::uniform_real_distribution d( a, b ); + return d( e1 ); +} - // -------------------------------------------------------------------------------- - float Random( float a, float b ) +// -------------------------------------------------------------------------------- +float Random( float a, float b ) +{ + if( g_expressionCurveFakeRandom ) { - if( g_expressionCurveFakeRandom ) - { - return ( ( b - a ) * 0.41f ) + a; - } - return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; + return ( ( b - a ) * 0.41f ) + a; } + return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; +} - // -------------------------------------------------------------------------------- - float Input( const Tr2CurveVector3Expression* curve, float index ) - { - return curve->GetInputValue( int32_t( index + 0.5f ) ); - } +// -------------------------------------------------------------------------------- +float Input( const Tr2CurveVector3Expression* curve, float index ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ) ); +} - // -------------------------------------------------------------------------------- - float InputAt( const Tr2CurveVector3Expression* curve, float index, float time ) - { - return curve->GetInputValue( int32_t( index + 0.5f ), time ); - } +// -------------------------------------------------------------------------------- +float InputAt( const Tr2CurveVector3Expression* curve, float index, float time ) +{ + return curve->GetInputValue( int32_t( index + 0.5f ), time ); +} - CcpParser::Function s_functions[] = { - CcpParser::Function( "fractal", &Fractal, 1, 0 ), - CcpParser::Function( "noise", &Noise, 1, 0 ), - CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), - CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), - CcpParser::Function( "random", &Random ), - CcpParser::Function( "randhash", &RandomHash, 1, 0 ), - CcpParser::Function( "input", &Input, 1, 0 ), - CcpParser::Function( "inputAt", &InputAt, 1, 0 ), - CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), - }; - CcpParser::Constant s_constants[] = { - { "pi", 3.1415926f }, - { "pi2", 2.0f * 3.1415926f }, - }; +CcpParser::Function s_functions[] = { + CcpParser::Function( "fractal", &Fractal, 1, 0 ), + CcpParser::Function( "noise", &Noise, 1, 0 ), + CcpParser::Function( "randomConstant", &RandomConstant, 1, 0 ), + CcpParser::Function( "randconst", &RandomConstant, 1, 0 ), + CcpParser::Function( "random", &Random ), + CcpParser::Function( "randhash", &RandomHash, 1, 0 ), + CcpParser::Function( "input", &Input, 1, 0 ), + CcpParser::Function( "inputAt", &InputAt, 1, 0 ), + CcpParser::Function( "clamp", &TriClamp, CcpParser::FunctionFlags::PURE_FUNC ), +}; +CcpParser::Constant s_constants[] = { + { "pi", 3.1415926f }, + { "pi2", 2.0f * 3.1415926f }, +}; } // -------------------------------------------------------------------------------- -Tr2CurveVector3Expression::Tr2CurveVector3Expression( IRoot* lockobj ) - :PARENTLOCK( m_inputs ), +Tr2CurveVector3Expression::Tr2CurveVector3Expression( IRoot* lockobj ) : + PARENTLOCK( m_inputs ), m_currentValue( 0, 0, 0 ), m_timeScale( 1 ), m_randomConstant( float( rand() ) / RAND_MAX ) @@ -102,7 +102,6 @@ bool Tr2CurveVector3Expression::Initialize() } } return true; - } // -------------------------------------------------------------------------------- diff --git a/trinity/Curves/Tr2CurveVector3Expression.h b/trinity/Curves/Tr2CurveVector3Expression.h index 78dd0cd75..b0562674d 100644 --- a/trinity/Curves/Tr2CurveVector3Expression.h +++ b/trinity/Curves/Tr2CurveVector3Expression.h @@ -11,7 +11,8 @@ BLUE_DECLARE_IVECTOR( ITriScalarFunction ); BLUE_DECLARE( Tr2ExpressionTermInfo ); -BLUE_CLASS( Tr2CurveVector3Expression ) : public ITriColorFunction, public ITriVectorFunction, public IInitialize +BLUE_CLASS( Tr2CurveVector3Expression ) : + public ITriColorFunction, public ITriVectorFunction, public IInitialize { public: Tr2CurveVector3Expression( IRoot* lockobj = nullptr ); @@ -40,24 +41,25 @@ BLUE_CLASS( Tr2CurveVector3Expression ) : public ITriColorFunction, public ITriV float GetInputValue( int index ) const; float GetInputValue( int index, float time ) const; - virtual Color* Update( Color* in, Be::Time time ); - virtual Color* Update( Color* in, double time ); - virtual Color* GetValueAt( Color* in, Be::Time time ); - virtual Color* GetValueAt( Color* in, double time ); - - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + virtual Color* Update( Color * in, Be::Time time ); + virtual Color* Update( Color * in, double time ); + virtual Color* GetValueAt( Color * in, Be::Time time ); + virtual Color* GetValueAt( Color * in, double time ); + + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); void ResetRandomConstant(); std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; + private: std::string m_name; std::string m_expressions[3]; @@ -69,11 +71,11 @@ BLUE_CLASS( Tr2CurveVector3Expression ) : public ITriColorFunction, public ITriV Vector3 m_currentValue; float m_timeScale; float m_randomConstant; - + struct Arguments { mutable float m_time = 0; - + float m_input1 = 0; float m_input2 = 0; float m_input3 = 0; diff --git a/trinity/Curves/Tr2CurveVector3Expression_Blue.cpp b/trinity/Curves/Tr2CurveVector3Expression_Blue.cpp index 9e1cfd392..d1c1c3266 100644 --- a/trinity/Curves/Tr2CurveVector3Expression_Blue.cpp +++ b/trinity/Curves/Tr2CurveVector3Expression_Blue.cpp @@ -12,7 +12,7 @@ const Be::ClassInfo* Tr2CurveVector3Expression::ExposeToBlue() MAP_INTERFACE( Tr2CurveVector3Expression ) MAP_INTERFACE( ITriColorFunction ) MAP_INTERFACE( ITriVectorFunction ) - { + { Be::InterfaceEntry entry = { &GetITriFunctionIID(), BLUE_INTERFACEOFFSET( ITriColorFunction ) }; s_interfaces.push_back( entry ); } @@ -91,28 +91,24 @@ const Be::ClassInfo* Tr2CurveVector3Expression::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP( "ResetRandomConstant", ResetRandomConstant, "Resets curve random constant to a new random value\n" ":jessica-favorite:\n" - ":jessica-icon: timeline/refreshrandom.png" - ) + ":jessica-icon: timeline/refreshrandom.png" ) MAP_METHOD_AND_WRAP( "GetExpressionTermInfo", GetExpressionTermInfo, - "Returns information on addional functions and variables available to the expression" - ) + "Returns information on addional functions and variables available to the expression" ) MAP_METHOD_AND_WRAP( "EvaluateExpression", EvaluateExpression, "Evaluates an expression against this object\n" - ":param expression: expression to evaluate" - ) + ":param expression: expression to evaluate" ) EXPOSURE_END() } diff --git a/trinity/Curves/Tr2CurveVector3Lerp.cpp b/trinity/Curves/Tr2CurveVector3Lerp.cpp index f0167ffd7..b99e5075d 100644 --- a/trinity/Curves/Tr2CurveVector3Lerp.cpp +++ b/trinity/Curves/Tr2CurveVector3Lerp.cpp @@ -5,7 +5,7 @@ #include "Tr2CurveScalar.h" -Tr2CurveVector3Lerp::Tr2CurveVector3Lerp( IRoot* lockobj ): +Tr2CurveVector3Lerp::Tr2CurveVector3Lerp( IRoot* lockobj ) : m_curveStartTime( 1.0 ), m_initialValue( 0, 0, 0 ), m_startInterpolation( Tr2CurveVector3LerpKeyInterpolation::HERMITE ) @@ -37,7 +37,7 @@ Vector3 Tr2CurveVector3Lerp::GetValue( double time ) const v = LerpToFirstKey( time ); } else - { + { m_curve->GetValueAt( &v, time - m_curveStartTime ); } return v; @@ -66,8 +66,8 @@ Vector3 Tr2CurveVector3Lerp::LerpToFirstKey( double time ) const float c2 = -2.0f * s * s * s + 3.0f * s * s; float c1 = 1.0f - c2; - // Hermite with 0 tangents - return prev * c1 + next * c2 ; + // Hermite with 0 tangents + return prev * c1 + next * c2; } return Vector3( 0, 0, 0 ); diff --git a/trinity/Curves/Tr2CurveVector3Lerp.h b/trinity/Curves/Tr2CurveVector3Lerp.h index 7fff395d7..7a6791fb3 100644 --- a/trinity/Curves/Tr2CurveVector3Lerp.h +++ b/trinity/Curves/Tr2CurveVector3Lerp.h @@ -31,15 +31,16 @@ BLUE_CLASS( Tr2CurveVector3Lerp ) : Vector3 GetValue( double time ) const; - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); + private: Vector3 LerpToFirstKey( double time ) const; Vector3 GetAutoTangent() const; @@ -54,7 +55,6 @@ BLUE_CLASS( Tr2CurveVector3Lerp ) : Tr2CurveVector3LerpKeyInterpolation::Type m_startInterpolation; ITriVectorFunctionPtr m_curve; - }; TYPEDEF_BLUECLASS( Tr2CurveVector3Lerp ); \ No newline at end of file diff --git a/trinity/Curves/Tr2CurveVector3Lerp_Blue.cpp b/trinity/Curves/Tr2CurveVector3Lerp_Blue.cpp index 12e5e2cf9..2d04f9363 100644 --- a/trinity/Curves/Tr2CurveVector3Lerp_Blue.cpp +++ b/trinity/Curves/Tr2CurveVector3Lerp_Blue.cpp @@ -41,7 +41,7 @@ const Be::ClassInfo* Tr2CurveVector3Lerp::ExposeToBlue() m_startInterpolation, "The interpolation from initial value to first key", Be::ENUM | Be::READWRITE, - Tr2CurveVector3LerpKeyInterpolationChooser ) + Tr2CurveVector3LerpKeyInterpolationChooser ) MAP_ATTRIBUTE( "curve", @@ -54,19 +54,17 @@ const Be::ClassInfo* Tr2CurveVector3Lerp::ExposeToBlue() m_curveStartTime, "The time when the curve starts", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "currentValue", m_currentValue, "Curve value after the last update", Be::READ ) - + MAP_METHOD_AND_WRAP( "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) EXPOSURE_END() } - diff --git a/trinity/Curves/Tr2CurveVector3_Blue.cpp b/trinity/Curves/Tr2CurveVector3_Blue.cpp index 50a804826..5e98e9d1f 100644 --- a/trinity/Curves/Tr2CurveVector3_Blue.cpp +++ b/trinity/Curves/Tr2CurveVector3_Blue.cpp @@ -43,8 +43,7 @@ const Be::ClassInfo* Tr2CurveVector3::ExposeToBlue() "GetValueAt", GetValue, "Returns curve value at specified time\n" - ":param time: input time" - ) + ":param time: input time" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "AddKey", @@ -56,15 +55,13 @@ const Be::ClassInfo* Tr2CurveVector3::ExposeToBlue() ":param interpolation: optional interpolation type for the segment following this key, defaults to trinity.Tr2CurveInterpolation.HERMITE\n" ":param leftTangent: optional key left (incoming) tangent, defaults to (0, 0, 0)\n" ":param rightTangent: optional key right (outgoing) tangent, defaults to (0, 0, 0)\n" - ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" - ) + ":param tangentType: optional key tangent type, defaults to trinity.Tr2CurveTangentType.AUTO_CLAMP" ) MAP_METHOD_AND_WRAP( "SetExtrapolation", SetExtrapolation, "Assigns both extrapolationBefore and extrapolationAfter\n" - ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" - ) + ":param extrapolation: new extrapolation (trinity.Tr2CurveExtrapolation enum)" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2DistanceTracker.cpp b/trinity/Curves/Tr2DistanceTracker.cpp index 50369caf0..e1c49d12a 100644 --- a/trinity/Curves/Tr2DistanceTracker.cpp +++ b/trinity/Curves/Tr2DistanceTracker.cpp @@ -8,7 +8,7 @@ // Description: // Default constructor. // -------------------------------------------------------------------------------------- -Tr2DistanceTracker::Tr2DistanceTracker( IRoot* lockobj ): +Tr2DistanceTracker::Tr2DistanceTracker( IRoot* lockobj ) : m_signedDistance( true ), m_distanceToClosest( true ), m_value( 0 ), @@ -26,34 +26,34 @@ Tr2DistanceTracker::Tr2DistanceTracker( IRoot* lockobj ): // -------------------------------------------------------------------------------------- void Tr2DistanceTracker::UpdateValue( double time ) { - if( m_source ) - { - m_source->GetValueAt( &m_sourcePosition, time ); - } - if( m_target ) - { - m_target->GetValueAt( &m_targetPosition, time ); - } + if( m_source ) + { + m_source->GetValueAt( &m_sourcePosition, time ); + } + if( m_target ) + { + m_target->GetValueAt( &m_targetPosition, time ); + } - Vector3 d = m_targetPosition - m_sourcePosition; - float projection = XMVectorGetX( XMVector3Dot( d, m_direction ) ); - - if( m_distanceToClosest ) - { - m_value = projection; - if( !m_signedDistance ) - { - m_value = std::abs( m_value ); - } - } - else - { - m_value = XMVectorGetX( XMVector3Length( d ) ); - if( m_signedDistance && projection < 0) - { - m_value = -m_value; - } - } + Vector3 d = m_targetPosition - m_sourcePosition; + float projection = XMVectorGetX( XMVector3Dot( d, m_direction ) ); + + if( m_distanceToClosest ) + { + m_value = projection; + if( !m_signedDistance ) + { + m_value = std::abs( m_value ); + } + } + else + { + m_value = XMVectorGetX( XMVector3Length( d ) ); + if( m_signedDistance && projection < 0 ) + { + m_value = -m_value; + } + } } bool Tr2DistanceTracker::OnModified( Be::Var* val ) diff --git a/trinity/Curves/Tr2DistanceTracker.h b/trinity/Curves/Tr2DistanceTracker.h index 9e25fc3a2..7196506e2 100644 --- a/trinity/Curves/Tr2DistanceTracker.h +++ b/trinity/Curves/Tr2DistanceTracker.h @@ -11,11 +11,10 @@ BLUE_DECLARE( Tr2DistanceTracker ); // -------------------------------------------------------------------------------------- // Description: -// Tr2DistanceTracker is a +// Tr2DistanceTracker is a // -------------------------------------------------------------------------------------- -class Tr2DistanceTracker : - public ITriFunction, - public INotify +class Tr2DistanceTracker : public ITriFunction, + public INotify { public: // Constructor @@ -25,27 +24,28 @@ class Tr2DistanceTracker : void UpdateValue( double time ); bool OnModified( Be::Var* val ); + private: std::wstring m_name; // Determine weather distance is signed based on direction vector - bool m_signedDistance; + bool m_signedDistance; - // Track distance to closest point between source and target - bool m_distanceToClosest; + // Track distance to closest point between source and target + bool m_distanceToClosest; - float m_value; + float m_value; - // Normalized direction vector - Vector3 m_direction; + // Normalized direction vector + Vector3 m_direction; - // Source and destination objects - ITriVectorFunctionPtr m_target; - ITriVectorFunctionPtr m_source; + // Source and destination objects + ITriVectorFunctionPtr m_target; + ITriVectorFunctionPtr m_source; - // Source and destination positions - Vector3 m_targetPosition; - Vector3 m_sourcePosition; + // Source and destination positions + Vector3 m_targetPosition; + Vector3 m_sourcePosition; }; TYPEDEF_BLUECLASS( Tr2DistanceTracker ); diff --git a/trinity/Curves/Tr2DistanceTracker_Blue.cpp b/trinity/Curves/Tr2DistanceTracker_Blue.cpp index fdc328de6..3f9f9b7d8 100644 --- a/trinity/Curves/Tr2DistanceTracker_Blue.cpp +++ b/trinity/Curves/Tr2DistanceTracker_Blue.cpp @@ -7,23 +7,23 @@ BLUE_DEFINE( Tr2DistanceTracker ); const Be::ClassInfo* Tr2DistanceTracker::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2DistanceTracker, ":jessica-deprecated: True" ) + EXPOSURE_BEGIN( Tr2DistanceTracker, ":jessica-deprecated: True" ) + + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( INotify ) - MAP_INTERFACE( ITriFunction ) - MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "value", m_value, "", Be::READ ) MAP_ATTRIBUTE( "signedDistance", m_signedDistance, "Is distance signed based on direction", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "distanceToClosest", m_distanceToClosest, "Calculate distance to closest intersection point", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "distanceToClosest", m_distanceToClosest, "Calculate distance to closest intersection point", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "direction", m_direction, "Directional vector used for signed distance and closest intersection", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "sourceObject", m_source, "Distance is calculated from source to the target object", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "targetObject", m_target, "Distance is calculated from source to the target object", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "sourcePosition", m_sourcePosition, "The source object position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourcePosition", m_sourcePosition, "The source object position", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "targetPosition", m_targetPosition, "The target object position", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_END() + + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2FollowCurve.cpp b/trinity/Curves/Tr2FollowCurve.cpp index a1d77f4a7..34e267352 100644 --- a/trinity/Curves/Tr2FollowCurve.cpp +++ b/trinity/Curves/Tr2FollowCurve.cpp @@ -10,7 +10,7 @@ Tr2FollowCurve::Tr2FollowCurve( IRoot* lockobj ) : m_keys.SetNotify( this ); } -Tr2FollowCurve::~Tr2FollowCurve( ) +Tr2FollowCurve::~Tr2FollowCurve() { m_keys.Clear(); } @@ -37,7 +37,6 @@ void Tr2FollowCurve::OnListModified( long event, ssize_t key, ssize_t key2, IRoo break; } } - } Vector3 Tr2FollowCurve::GetValue( double time ) const @@ -48,16 +47,16 @@ Vector3 Tr2FollowCurve::GetValue( double time ) const for( auto key = begin( m_keys ); key != end( m_keys ); ++key ) { auto k = *key; - + if( time < k->GetTime() ) { nextKey = k; break; } - currentKey = k; + currentKey = k; } - if( nextKey && currentKey ) + if( nextKey && currentKey ) { value = GetSegmentValue( float( time ), *currentKey, *nextKey ); } @@ -83,8 +82,7 @@ Vector3 Tr2FollowCurve::GetSegmentValue( float time, ITr2FollowCurveKey& k0, ITr return k1.GetValue(); } return k0.GetValue() + ( k1.GetValue() - k0.GetValue() ) * ( time - k0.GetTime() ) / ( k1.GetTime() - k0.GetTime() ); - case Tr2FollowCurveKeyInterpolation::HERMITE: - { + case Tr2FollowCurveKeyInterpolation::HERMITE: { float length = k1.GetTime() - k0.GetTime(); if( length == 0 ) { @@ -105,7 +103,7 @@ Vector3 Tr2FollowCurve::GetSegmentValue( float time, ITr2FollowCurveKey& k0, ITr return k0.GetValue() * c1 + k1.GetValue() * c2 + inTangent * c3 + outTangent * c4; } default: - return Vector3(0, 0, 0); + return Vector3( 0, 0, 0 ); } } @@ -158,4 +156,3 @@ Vector3d* Tr2FollowCurve::InterpolatedPosition( Vector3d* out, Be::Time time ) { return out; } - diff --git a/trinity/Curves/Tr2FollowCurve.h b/trinity/Curves/Tr2FollowCurve.h index 9e18e894a..a72a4d21d 100644 --- a/trinity/Curves/Tr2FollowCurve.h +++ b/trinity/Curves/Tr2FollowCurve.h @@ -14,8 +14,8 @@ BLUE_CLASS( Tr2FollowCurve ) : { public: Tr2FollowCurve( IRoot* lockobj = nullptr ); - ~Tr2FollowCurve( ); - + ~Tr2FollowCurve(); + EXPOSE_TO_BLUE(); virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); @@ -23,23 +23,23 @@ BLUE_CLASS( Tr2FollowCurve ) : Vector3 GetValue( double time ) const; - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); + private: Vector3 GetSegmentValue( float time, ITr2FollowCurveKey& k0, ITr2FollowCurveKey& k1 ) const; std::string m_name; - + PITr2FollowCurveKeyVector m_keys; Vector3 m_currentValue; - }; TYPEDEF_BLUECLASS( Tr2FollowCurve ); diff --git a/trinity/Curves/Tr2FollowCurveKey.cpp b/trinity/Curves/Tr2FollowCurveKey.cpp index d11ce64c5..c2e1d37a4 100644 --- a/trinity/Curves/Tr2FollowCurveKey.cpp +++ b/trinity/Curves/Tr2FollowCurveKey.cpp @@ -6,7 +6,7 @@ #include "include/TriMath.h" -Tr2ObjectFollowCurveKey::Tr2ObjectFollowCurveKey( IRoot* lockobj ) : +Tr2ObjectFollowCurveKey::Tr2ObjectFollowCurveKey( IRoot* lockobj ) : m_time( 0 ), m_leftTangent( 0, 0, 0 ), m_rightTangent( 0, 0, 0 ), @@ -15,7 +15,7 @@ Tr2ObjectFollowCurveKey::Tr2ObjectFollowCurveKey( IRoot* lockobj ) : m_interpolation( Tr2FollowCurveKeyInterpolation::LINEAR ), m_offset( 0.0, 0.0, 0.0 ), m_rotationSetting( NO_ROTATION ), - m_locator(nullptr) + m_locator( nullptr ) { } @@ -51,7 +51,7 @@ bool Tr2ObjectFollowCurveKey::Initialize() return true; } -bool Tr2ObjectFollowCurveKey::OnModified( Be::Var *value ) +bool Tr2ObjectFollowCurveKey::OnModified( Be::Var* value ) { if( IsMatch( value, m_offsetLocatorName ) || IsMatch( value, m_object ) ) { @@ -73,7 +73,7 @@ Locator* Tr2ObjectFollowCurveKey::GetLocator() auto locators = so->GetLocatorsForSet( m_offsetLocatorName ); if( locators != nullptr && locators->size() > 0 ) { - return const_cast< Locator* >( &( *locators )[0] ); + return const_cast( &( *locators )[0] ); } } return nullptr; @@ -163,12 +163,10 @@ Tr2CameraFollowCurveKey::Tr2CameraFollowCurveKey( IRoot* lockobj ) : m_lastEnabledFrontClip( 10 ), m_lastEnabledInverseViewMatrix( Matrix() ) { - } Tr2CameraFollowCurveKey::~Tr2CameraFollowCurveKey() { - } bool Tr2CameraFollowCurveKey::Initialize() @@ -177,7 +175,7 @@ bool Tr2CameraFollowCurveKey::Initialize() return true; } -bool Tr2CameraFollowCurveKey::OnModified( Be::Var *value ) +bool Tr2CameraFollowCurveKey::OnModified( Be::Var* value ) { if( IsMatch( value, m_fovMultiplication ) ) { @@ -214,10 +212,10 @@ void Tr2CameraFollowCurveKey::CalculateBoxPosition() m_frontClip = m_lastEnabledFrontClip; } - + float tanOuterFov = tan( m_fov ); float tanInnerFov = tan( m_fov * m_fovMultiplication ); - + float nearClipPlaneSize = m_frontClip / tanOuterFov; float aspectRatio = Tr2Renderer::GetAspectRatio(); @@ -249,10 +247,10 @@ void Tr2CameraFollowCurveKey::CalculateBoxPosition() m_boxPosition = TransformCoord( boxOffsetXY + boxCenter, rotMatrix ); } -Vector3 Tr2CameraFollowCurveKey::GetValue( ) +Vector3 Tr2CameraFollowCurveKey::GetValue() { CalculateBoxPosition(); - + return m_boxPosition; } diff --git a/trinity/Curves/Tr2FollowCurveKey.h b/trinity/Curves/Tr2FollowCurveKey.h index 6e5b36559..0d38ee8df 100644 --- a/trinity/Curves/Tr2FollowCurveKey.h +++ b/trinity/Curves/Tr2FollowCurveKey.h @@ -8,21 +8,22 @@ BLUE_DECLARE( EveSpaceObject2 ); namespace Tr2FollowCurveKeyInterpolation { - enum Type - { - // Constant (L0) interpolation - CONSTANT = 0, - // Linear (L1) interpolation - LINEAR = 1, - // Hermite/cubic (L2) interpolation - HERMITE = 2, - }; +enum Type +{ + // Constant (L0) interpolation + CONSTANT = 0, + // Linear (L1) interpolation + LINEAR = 1, + // Hermite/cubic (L2) interpolation + HERMITE = 2, +}; } - BLUE_INTERFACE( ITr2FollowCurveKey ): public IRoot +BLUE_INTERFACE( ITr2FollowCurveKey ) : + public IRoot { -public: +public: virtual Vector3 GetValue() = 0; virtual const float GetTime() = 0; virtual const Tr2FollowCurveKeyInterpolation::Type GetInterpolationType() = 0; @@ -37,7 +38,8 @@ BLUE_CLASS( Tr2ObjectFollowCurveKey ) : public IInitialize { public: - enum RotationSetting { + enum RotationSetting + { NO_ROTATION, MODEL_ROTATION, LOCATOR_ROTATION @@ -53,7 +55,7 @@ BLUE_CLASS( Tr2ObjectFollowCurveKey ) : bool Initialize(); // INotify - bool OnModified( Be::Var *value ); + bool OnModified( Be::Var * value ); // ITr2FollowCurveKey Vector3 GetValue(); @@ -64,7 +66,7 @@ BLUE_CLASS( Tr2ObjectFollowCurveKey ) : private: Locator* GetLocator(); - + Matrix GetLocatorRotation(); Matrix GetModelRotation(); @@ -83,7 +85,6 @@ BLUE_CLASS( Tr2ObjectFollowCurveKey ) : RotationSetting m_rotationSetting; Locator* m_locator; - }; TYPEDEF_BLUECLASS( Tr2ObjectFollowCurveKey ); @@ -104,7 +105,7 @@ BLUE_CLASS( Tr2CameraFollowCurveKey ) : bool Initialize(); // INotify - bool OnModified( Be::Var *value ); + bool OnModified( Be::Var * value ); // ITr2FollowCurveKey Vector3 GetValue(); @@ -119,7 +120,7 @@ BLUE_CLASS( Tr2CameraFollowCurveKey ) : BlueSharedString m_name; float m_fovMultiplication; - float m_angle; + float m_angle; float m_angleZero; Vector3 m_objectBounds; Vector3 m_offset; @@ -143,7 +144,5 @@ BLUE_CLASS( Tr2CameraFollowCurveKey ) : float m_lastEnabledFOV; float m_lastEnabledFrontClip; Matrix m_lastEnabledInverseViewMatrix; - - }; TYPEDEF_BLUECLASS( Tr2CameraFollowCurveKey ); \ No newline at end of file diff --git a/trinity/Curves/Tr2FollowCurveKey_Blue.cpp b/trinity/Curves/Tr2FollowCurveKey_Blue.cpp index 4946e6608..0933aba21 100644 --- a/trinity/Curves/Tr2FollowCurveKey_Blue.cpp +++ b/trinity/Curves/Tr2FollowCurveKey_Blue.cpp @@ -8,43 +8,29 @@ BLUE_DEFINE( Tr2ObjectFollowCurveKey ); BLUE_DEFINE( Tr2CameraFollowCurveKey ); -Be::VarChooser RotationChooser[] = -{ - { - "NO_ROTATION", - BeCast( Tr2ObjectFollowCurveKey::NO_ROTATION ), - "No Rotation" - }, - { - "LOCATOR_ROTATION", - BeCast( Tr2ObjectFollowCurveKey::LOCATOR_ROTATION ), - "Locator rotation" - }, - { - "MODEL_ROTATION", - BeCast( Tr2ObjectFollowCurveKey::MODEL_ROTATION ), - "Model rotation" - }, +Be::VarChooser RotationChooser[] = { + { "NO_ROTATION", + BeCast( Tr2ObjectFollowCurveKey::NO_ROTATION ), + "No Rotation" }, + { "LOCATOR_ROTATION", + BeCast( Tr2ObjectFollowCurveKey::LOCATOR_ROTATION ), + "Locator rotation" }, + { "MODEL_ROTATION", + BeCast( Tr2ObjectFollowCurveKey::MODEL_ROTATION ), + "Model rotation" }, { 0 } }; -Be::VarChooser Tr2FollowCurveKeyInterpolationChooser[] = -{ - { - "CONSTANT", - BeCast( Tr2FollowCurveKeyInterpolation::CONSTANT ), - "Performs a constant interpolation" - }, - { - "LINEAR", - BeCast( Tr2FollowCurveKeyInterpolation::LINEAR ), - "Performs a linear interpolation" - }, - { - "HERMITE", - BeCast( Tr2FollowCurveKeyInterpolation::HERMITE ), - "Performs a hermite interpolation" - }, +Be::VarChooser Tr2FollowCurveKeyInterpolationChooser[] = { + { "CONSTANT", + BeCast( Tr2FollowCurveKeyInterpolation::CONSTANT ), + "Performs a constant interpolation" }, + { "LINEAR", + BeCast( Tr2FollowCurveKeyInterpolation::LINEAR ), + "Performs a linear interpolation" }, + { "HERMITE", + BeCast( Tr2FollowCurveKeyInterpolation::HERMITE ), + "Performs a hermite interpolation" }, { 0 } }; @@ -57,14 +43,14 @@ const Be::ClassInfo* Tr2ObjectFollowCurveKey::ExposeToBlue() EXPOSURE_BEGIN( Tr2ObjectFollowCurveKey, "" ) MAP_INTERFACE( ITr2FollowCurveKey ) MAP_INTERFACE( INotify ) - MAP_INTERFACE( IInitialize) + MAP_INTERFACE( IInitialize ) MAP_ATTRIBUTE( "name", m_name, "name of the key", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "object", m_object, "the object that is used", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "time", m_time, "The start time of the key", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "The interpolation of the key", Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2FollowCurveKeyInterpolationChooser ) MAP_ATTRIBUTE( "leftTangent", m_leftTangent, "The left tangent of the key", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rightTangent", m_rightTangent, "The right tangent of the key", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rightTangent", m_rightTangent, "The right tangent of the key", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotatedLeftTangent", m_rotatedLeftTangent, "The rotated left tangent of the key", Be::READ ) MAP_ATTRIBUTE( "rotatedRightTangent", m_rotatedRightTangent, "The rotated right tangent of the key", Be::READ ) MAP_ATTRIBUTE( "offsetLocatorName", m_offsetLocatorName, "The name of the offset locator", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -94,6 +80,6 @@ const Be::ClassInfo* Tr2CameraFollowCurveKey::ExposeToBlue() MAP_ATTRIBUTE( "fovMultiplication", m_fovMultiplication, "A fraction of the fov where the box is not allowed to enter (0.25 - 0.75)", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "offset", m_offset, "An offset of the bounding box position", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boxPosition", m_boxPosition, "The position of the box", Be::READ ) - MAP_ATTRIBUTE( "enabled", m_enabled, "Enables/Disables the camera (stores the last active camera)", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "enabled", m_enabled, "Enables/Disables the camera (stores the last active camera)", Be::READWRITE | Be::NOTIFY ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2FollowCurve_Blue.cpp b/trinity/Curves/Tr2FollowCurve_Blue.cpp index 7ce5be57a..7a45fcb19 100644 --- a/trinity/Curves/Tr2FollowCurve_Blue.cpp +++ b/trinity/Curves/Tr2FollowCurve_Blue.cpp @@ -14,6 +14,6 @@ const Be::ClassInfo* Tr2FollowCurve::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "The name of the curve", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "keys", m_keys, "The keys of the curve", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "currentValue", m_currentValue, "The current value of the curve", Be::READ ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/Tr2GrannyEventTrack.cpp b/trinity/Curves/Tr2GrannyEventTrack.cpp index 6d737f5e3..0d346de89 100644 --- a/trinity/Curves/Tr2GrannyEventTrack.cpp +++ b/trinity/Curves/Tr2GrannyEventTrack.cpp @@ -3,8 +3,8 @@ #include "StdAfx.h" #include "Tr2GrannyEventTrack.h" -Tr2GrannyEventTrack::Tr2GrannyEventTrack( IRoot* lockobj ) - :m_track( nullptr ), +Tr2GrannyEventTrack::Tr2GrannyEventTrack( IRoot* lockobj ) : + m_track( nullptr ), m_previousTime( 0 ), m_previousIndex( 0 ) { @@ -18,21 +18,21 @@ void Tr2GrannyEventTrack::UpdateValueImpl( double time ) m_previousIndex = 0; } while( m_previousIndex < m_track->EntryCount ) - { - auto& entry = m_track->Entries[m_previousIndex]; - if( ( entry.TimeStamp >= m_previousTime ) && ( entry.TimeStamp <= time ) ) - { + { + auto& entry = m_track->Entries[m_previousIndex]; + if( ( entry.TimeStamp >= m_previousTime ) && ( entry.TimeStamp <= time ) ) + { if( m_eventListener ) { m_eventListener->HandleEvent( CA2W( entry.Text ) ); } - } + } else if( entry.TimeStamp > time ) { break; } ++m_previousIndex; - } + } m_previousTime = time; } @@ -48,7 +48,7 @@ void Tr2GrannyEventTrack::ApplyTracks( granny_track_group* group, float duration // find the track we want to sample for( int i = 0; i < group->TextTrackCount; ++i ) { - granny_text_track& track = group->TextTracks[i]; + granny_text_track& track = group->TextTracks[i]; if( m_name == track.Name ) { @@ -57,7 +57,7 @@ void Tr2GrannyEventTrack::ApplyTracks( granny_track_group* group, float duration m_previousTime = 0; m_previousIndex = 0; return; - } + } } } diff --git a/trinity/Curves/Tr2GrannyEventTrack.h b/trinity/Curves/Tr2GrannyEventTrack.h index 7e9a55731..853e2cefc 100644 --- a/trinity/Curves/Tr2GrannyEventTrack.h +++ b/trinity/Curves/Tr2GrannyEventTrack.h @@ -11,7 +11,8 @@ // Tr2GrannyEventTrack is a curve used to playback Granny text tracks. For each text // key the class executes provided IBlueEventListener. // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GrannyEventTrack ): public Tr2GrannyTrack +BLUE_CLASS( Tr2GrannyEventTrack ) : + public Tr2GrannyTrack { public: Tr2GrannyEventTrack( IRoot* lockobj = NULL ); @@ -20,8 +21,9 @@ BLUE_CLASS( Tr2GrannyEventTrack ): public Tr2GrannyTrack void UpdateValueImpl( double time ); void ResetTracks( void ); - void ApplyTracks( granny_track_group* group, float duration, float timeStep ); + void ApplyTracks( granny_track_group * group, float duration, float timeStep ); bool TracksReady( void ); + protected: granny_text_track* m_track; double m_previousTime; diff --git a/trinity/Curves/Tr2GrannyTrack.cpp b/trinity/Curves/Tr2GrannyTrack.cpp index 1eef2973c..f298584a5 100644 --- a/trinity/Curves/Tr2GrannyTrack.cpp +++ b/trinity/Curves/Tr2GrannyTrack.cpp @@ -5,11 +5,10 @@ #include "Resources/TriGrannyRes.h" // Curve set -Tr2GrannyTrack::Tr2GrannyTrack( IRoot* lockobj ): +Tr2GrannyTrack::Tr2GrannyTrack( IRoot* lockobj ) : m_duration( 0.0f ), m_cycle( false ) { - } Tr2GrannyTrack::~Tr2GrannyTrack() @@ -28,11 +27,11 @@ void Tr2GrannyTrack::UpdateValue( double time ) return; } - if ( m_cycle ) + if( m_cycle ) { time = fmod( time, (double)m_duration ); } - // if you go below zero or beyond the duration of the granny curve, + // if you go below zero or beyond the duration of the granny curve, // granny gets Alzheimer and the result is all over the place // plus she will throw some assert popups at you if( time <= m_duration && time >= 0.0 ) @@ -50,11 +49,11 @@ bool Tr2GrannyTrack::Initialize() bool Tr2GrannyTrack::OnModified( Be::Var* value ) { if( IsMatch( value, m_grannyResPath ) ) - { - SetGrannyResource( ); + { + SetGrannyResource(); } - - if( IsMatch( value, m_name ) || + + if( IsMatch( value, m_name ) || IsMatch( value, m_group ) ) { ResetTracks(); @@ -78,7 +77,7 @@ void Tr2GrannyTrack::ReleaseCachedData( BlueAsyncRes* p ) void Tr2GrannyTrack::RebuildCachedData( BlueAsyncRes* p ) { - if ( p == m_grannyRes && p->IsGood() ) + if( p == m_grannyRes && p->IsGood() ) { SetCurves(); } @@ -95,7 +94,7 @@ void Tr2GrannyTrack::SetGrannyResource() if( !m_grannyResPath.empty() ) { BeResMan->GetResource( m_grannyResPath.c_str(), "raw", BlueInterfaceIID(), (void**)&m_grannyRes ); - } + } else { ReleaseCachedData( m_grannyRes ); @@ -122,9 +121,9 @@ void Tr2GrannyTrack::SetCurves( void ) return; } - granny_file_info* info = GrannyGetFileInfo(file); - if ( !info ) - { + granny_file_info* info = GrannyGetFileInfo( file ); + if( !info ) + { CCP_LOGERR( "Tr2GrannyTrack::SetCurves: unable to obtain a granny_file_info from the input file\n" ); return; } @@ -132,13 +131,13 @@ void Tr2GrannyTrack::SetCurves( void ) for( int animIdx = 0; animIdx < info->AnimationCount; ++animIdx ) { granny_animation* animation = info->Animations[animIdx]; - if ( !animation ) + if( !animation ) continue; // find the group we belong to for( int tGIdx = 0; tGIdx < animation->TrackGroupCount; ++tGIdx ) { granny_track_group* trackGroup = animation->TrackGroups[tGIdx]; - if ( !trackGroup ) + if( !trackGroup ) continue; if( m_group == trackGroup->Name ) @@ -150,28 +149,28 @@ void Tr2GrannyTrack::SetCurves( void ) } } -granny_curve2* CompressCurve( +granny_curve2* CompressCurve( granny_real32 Tolerance, - granny_real32 dT, + granny_real32 dT, bool AsQuats, - granny_data_type_definition** CurveFormats, + granny_data_type_definition** CurveFormats, int NumFormats, granny_data_type_definition* ShaderType, - granny_real32* IdentityVector, - int KnotCount, - int Dimension, - std::vector &Data) + granny_real32* IdentityVector, + int KnotCount, + int Dimension, + std::vector& Data ) { granny_int32x SolverFlags = - (GrannyBSplineSolverExtraDOFKnotZero | - GrannyBSplineSolverForceEndpointAlignment | - (AsQuats ? GrannyBSplineSolverEvaluateAsQuaternions : 0)); + ( GrannyBSplineSolverExtraDOFKnotZero | + GrannyBSplineSolverForceEndpointAlignment | + ( AsQuats ? GrannyBSplineSolverEvaluateAsQuaternions : 0 ) ); granny_compress_curve_parameters Params; Params.DesiredDegree = 2; Params.AllowDegreeReduction = true; Params.AllowReductionOnMissedTolerance = true; - Params.ErrorTolerance = Tolerance; // !!! + Params.ErrorTolerance = Tolerance; // !!! Params.C0Threshold = 0.0f; Params.C1Threshold = 0.0f; Params.PossibleCompressionTypes = CurveFormats; @@ -180,20 +179,18 @@ granny_curve2* CompressCurve( Params.IdentityCompressionType = GrannyCurveDataDaIdentityType; Params.IdentityVector = IdentityVector; - granny_bspline_solver *Solver = GrannyAllocateBSplineSolver( 2, KnotCount, Dimension ); + granny_bspline_solver* Solver = GrannyAllocateBSplineSolver( 2, KnotCount, Dimension ); bool AcheivedTol; // convert the key framed curve to a compressed bspline granny_curve2* newCurve = - GrannyCompressCurve( Solver, SolverFlags, &Params, - &Data[0], Dimension, KnotCount, - dT, &AcheivedTol ); + GrannyCompressCurve( Solver, SolverFlags, &Params, &Data[0], Dimension, KnotCount, dT, &AcheivedTol ); - GrannyDeallocateBSplineSolver(Solver); + GrannyDeallocateBSplineSolver( Solver ); - if ( newCurve ) + if( newCurve ) { - if(!AcheivedTol) + if( !AcheivedTol ) { CCP_LOGWARN( "CompressCurve: Failed to achieve tolerance\n" ); } diff --git a/trinity/Curves/Tr2GrannyTrack.h b/trinity/Curves/Tr2GrannyTrack.h index 09812774a..344deb437 100644 --- a/trinity/Curves/Tr2GrannyTrack.h +++ b/trinity/Curves/Tr2GrannyTrack.h @@ -10,11 +10,11 @@ BLUE_DECLARE( TriGrannyRes ); // This static compressCurve func comes from the Granny Preprocessor -#define ArrayLength(x) (sizeof(x) / sizeof((x)[0])) +#define ArrayLength( x ) ( sizeof( x ) / sizeof( ( x )[0] ) ) -static granny_real32 PositionTolerance = 0.1f; -static granny_real32 OrientationTolerance = GrannyOrientationToleranceFromDegrees(0.1f); // important! :) -static granny_real32 ScaleShearTolerance = 0.1f; +static granny_real32 PositionTolerance = 0.1f; +static granny_real32 OrientationTolerance = GrannyOrientationToleranceFromDegrees( 0.1f ); // important! :) +static granny_real32 ScaleShearTolerance = 0.1f; static granny_data_type_definition* PositionCurveFormats[] = { GrannyCurveDataDaK32fC32fType, @@ -31,7 +31,7 @@ static granny_data_type_definition* OrientationCurveFormats[] = { GrannyCurveDataD4nK16uC15uType, }; -static granny_data_type_definition *ScaleShearCurveFormats[] = { +static granny_data_type_definition* ScaleShearCurveFormats[] = { GrannyCurveDataDaK32fC32fType, GrannyCurveDataD9I1K8uC8uType, GrannyCurveDataD9I3K8uC8uType, @@ -40,21 +40,20 @@ static granny_data_type_definition *ScaleShearCurveFormats[] = { GrannyCurveDataD9I1K16uC16uType, GrannyCurveDataD9I3K16uC16uType, }; -granny_curve2* CompressCurve( +granny_curve2* CompressCurve( granny_real32 Tolerance, - granny_real32 dT, + granny_real32 dT, bool AsQuats, - granny_data_type_definition** CurveFormats, + granny_data_type_definition** CurveFormats, int NumFormats, granny_data_type_definition* ShaderType, - granny_real32* IdentityVector, + granny_real32* IdentityVector, int KnotCount, int Dimension, - std::vector& Data - ); + std::vector& Data ); -BLUE_CLASS( Tr2GrannyTrack ): -public ITriFunction, +BLUE_CLASS( Tr2GrannyTrack ) : + public ITriFunction, public IInitialize, public ITriCurveLength, public INotify, @@ -69,8 +68,8 @@ public ITriFunction, ////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); ////////////////////////////////////////////////////////////////////////// // IInitialize @@ -78,7 +77,7 @@ public ITriFunction, ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); void SetGrannyResource(); @@ -86,18 +85,21 @@ public ITriFunction, virtual void UpdateValueImpl( double time ) = 0; virtual void ResetTracks( void ) = 0; - virtual void ApplyTracks( granny_track_group* group, float duration, float timeStep ) = 0; + virtual void ApplyTracks( granny_track_group * group, float duration, float timeStep ) = 0; virtual bool TracksReady( void ) = 0; - float Length() { return m_duration; } + float Length() + { + return m_duration; + } void SetCurves( void ); - + protected: - bool m_cycle; + bool m_cycle; granny_real32 m_duration; std::string m_name; - std::string m_group; + std::string m_group; std::string m_grannyResPath; TriGrannyResPtr m_grannyRes; }; diff --git a/trinity/Curves/Tr2GrannyTrack_Blue.cpp b/trinity/Curves/Tr2GrannyTrack_Blue.cpp index 83a2a0a5b..84ac88989 100644 --- a/trinity/Curves/Tr2GrannyTrack_Blue.cpp +++ b/trinity/Curves/Tr2GrannyTrack_Blue.cpp @@ -8,16 +8,16 @@ BLUE_DEFINE_ABSTRACT( Tr2GrannyTrack ); const Be::ClassInfo* Tr2GrannyTrack::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GrannyTrack, "" ) - MAP_INTERFACE( Tr2GrannyTrack ) + EXPOSURE_BEGIN( Tr2GrannyTrack, "" ) + MAP_INTERFACE( Tr2GrannyTrack ) MAP_INTERFACE( ITriFunction ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_ATTRIBUTE_WITH_CHOOSER( "grannyResPath", m_grannyResPath, "A res path to the granny resource", Be::READWRITE | Be::PERSIST | Be::NOTIFY, TriGR2Chooser ) - MAP_ATTRIBUTE( "grannyRes", m_grannyRes, "The granny resource holding the curves", Be::READ ) + MAP_ATTRIBUTE( "grannyRes", m_grannyRes, "The granny resource holding the curves", Be::READ ) MAP_ATTRIBUTE( "name", m_name, "The name of the transform track", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "group", m_group, "The name of the track group", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "duration", m_duration, "The duration of the animation", Be::READ ) MAP_ATTRIBUTE( "cycle", m_cycle, "Should we cycle the animation", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Curves/Tr2GrannyTransformTrack.cpp b/trinity/Curves/Tr2GrannyTransformTrack.cpp index 00ca6b077..62d235e6b 100644 --- a/trinity/Curves/Tr2GrannyTransformTrack.cpp +++ b/trinity/Curves/Tr2GrannyTransformTrack.cpp @@ -7,8 +7,8 @@ #include "Utilities/GrannyCurveHelpers.h" // Curve set -Tr2GrannyTransformTrack::Tr2GrannyTransformTrack( IRoot* lockobj ): - Tr2GrannyTrack( lockobj ), +Tr2GrannyTransformTrack::Tr2GrannyTransformTrack( IRoot* lockobj ) : + Tr2GrannyTrack( lockobj ), m_positionCurve( NULL ), m_orientationCurve( NULL ), m_scaleCurve( NULL ), @@ -21,7 +21,7 @@ Tr2GrannyTransformTrack::Tr2GrannyTransformTrack( IRoot* lockobj ): bool Tr2GrannyTransformTrack::TracksReady( void ) { - return ( m_positionCurve != NULL && m_orientationCurve != NULL && m_scaleCurve != NULL); + return ( m_positionCurve != NULL && m_orientationCurve != NULL && m_scaleCurve != NULL ); } void Tr2GrannyTransformTrack::UpdateValueImpl( double time ) @@ -33,7 +33,7 @@ void Tr2GrannyTransformTrack::UpdateValueImpl( double time ) } else { - GrannyEvaluateCurveAtT( 3, false, false, m_positionCurve, false, m_duration, (float)time,(float*)&m_translation, GrannyCurveIdentityPosition ); + GrannyEvaluateCurveAtT( 3, false, false, m_positionCurve, false, m_duration, (float)time, (float*)&m_translation, GrannyCurveIdentityPosition ); } if( GrannyCurveIsKeyframed( m_orientationCurve ) ) @@ -42,13 +42,13 @@ void Tr2GrannyTransformTrack::UpdateValueImpl( double time ) } else { - GrannyEvaluateCurveAtT( 4, false, false, m_orientationCurve, false, m_duration, (float)time,(float*)&m_rotation, GrannyCurveIdentityOrientation ); + GrannyEvaluateCurveAtT( 4, false, false, m_orientationCurve, false, m_duration, (float)time, (float*)&m_rotation, GrannyCurveIdentityOrientation ); } GrannyEvaluateCurveAtT( 9, false, false, m_scaleCurve, false, m_duration, (float)time, scaleShear, GrannyCurveIdentityScaleShear ); - m_scale.x = XMVectorGetX(XMVector3Length( *(Vector3*)&scaleShear[0] )); - m_scale.y = XMVectorGetX(XMVector3Length( *(Vector3*)&scaleShear[3] )); - m_scale.z = XMVectorGetX(XMVector3Length( *(Vector3*)&scaleShear[6] )); + m_scale.x = XMVectorGetX( XMVector3Length( *(Vector3*)&scaleShear[0] ) ); + m_scale.y = XMVectorGetX( XMVector3Length( *(Vector3*)&scaleShear[3] ) ); + m_scale.z = XMVectorGetX( XMVector3Length( *(Vector3*)&scaleShear[6] ) ); } void Tr2GrannyTransformTrack::ResetTracks( void ) @@ -62,7 +62,7 @@ void Tr2GrannyTransformTrack::ApplyTracks( granny_track_group* group, float dura { for( int tTIdx = 0; tTIdx < group->TransformTrackCount; ++tTIdx ) { - granny_transform_track& track = group->TransformTracks[tTIdx]; + granny_transform_track& track = group->TransformTracks[tTIdx]; if( m_name == track.Name ) { @@ -80,18 +80,17 @@ void Tr2GrannyTransformTrack::ApplyTracks( granny_track_group* group, float dura GrannyCurveExtractKnotValues( &track.PositionCurve, 0, KnotCount, 0, &Data[0], GrannyCurveIdentityPosition ); m_positionCurve = CompressCurve( - PositionTolerance, // error tolerance + PositionTolerance, // error tolerance timeStep, // the time step between frames - false, // solve as quaternions + false, // solve as quaternions PositionCurveFormats, // possible compression formats - ArrayLength(PositionCurveFormats),// number of compression formats + ArrayLength( PositionCurveFormats ), // number of compression formats GrannyCurveDataD3Constant32fType, // constant compression type GrannyCurveIdentityPosition, KnotCount, Dimension, - Data - ); // - } + Data ); // + } else { m_positionCurve = &track.PositionCurve; @@ -106,23 +105,22 @@ void Tr2GrannyTransformTrack::ApplyTracks( granny_track_group* group, float dura GrannyCurveExtractKnotValues( &track.OrientationCurve, 0, KnotCount, 0, &Data[0], GrannyCurveIdentityOrientation ); m_orientationCurve = CompressCurve( OrientationTolerance, - timeStep, + timeStep, true, - OrientationCurveFormats, - ArrayLength(OrientationCurveFormats), + OrientationCurveFormats, + ArrayLength( OrientationCurveFormats ), GrannyCurveDataD4Constant32fType, GrannyCurveIdentityOrientation, KnotCount, Dimension, - Data - ); + Data ); } else { m_orientationCurve = &track.OrientationCurve; } - + if( GrannyCurveIsKeyframed( &track.ScaleShearCurve ) ) { int KnotCount = GrannyCurveGetKnotCount( &track.ScaleShearCurve ); @@ -131,24 +129,23 @@ void Tr2GrannyTransformTrack::ApplyTracks( granny_track_group* group, float dura std::vector Data( KnotCount * Dimension ); GrannyCurveExtractKnotValues( &track.ScaleShearCurve, 0, KnotCount, 0, &Data[0], GrannyCurveIdentityScaleShear ); m_scaleCurve = CompressCurve( - ScaleShearTolerance, - timeStep, + ScaleShearTolerance, + timeStep, false, - ScaleShearCurveFormats, - ArrayLength(ScaleShearCurveFormats), + ScaleShearCurveFormats, + ArrayLength( ScaleShearCurveFormats ), GrannyCurveDataDaConstant32fType, GrannyCurveIdentityScaleShear, KnotCount, Dimension, - Data - ); + Data ); } else { m_scaleCurve = &track.ScaleShearCurve; } - UpdateValue( 0.0 );// set the default values to start values of the curve + UpdateValue( 0.0 ); // set the default values to start values of the curve return; - } + } } } diff --git a/trinity/Curves/Tr2GrannyTransformTrack.h b/trinity/Curves/Tr2GrannyTransformTrack.h index d55915534..b1d2157f3 100644 --- a/trinity/Curves/Tr2GrannyTransformTrack.h +++ b/trinity/Curves/Tr2GrannyTransformTrack.h @@ -11,7 +11,7 @@ BLUE_DECLARE( TriGrannyRes ); -BLUE_CLASS( Tr2GrannyTransformTrack ): +BLUE_CLASS( Tr2GrannyTransformTrack ) : public Tr2GrannyTrack { public: @@ -19,11 +19,10 @@ BLUE_CLASS( Tr2GrannyTransformTrack ): Tr2GrannyTransformTrack( IRoot* lockobj = NULL ); void UpdateValueImpl( double time ); void ResetTracks( void ); - void ApplyTracks( granny_track_group* group, float duration, float timeStep ); + void ApplyTracks( granny_track_group * group, float duration, float timeStep ); bool TracksReady( void ); protected: - Vector3 m_translation; Quaternion m_rotation; Vector3 m_scale; @@ -31,7 +30,6 @@ BLUE_CLASS( Tr2GrannyTransformTrack ): granny_curve2* m_orientationCurve; granny_curve2* m_scaleCurve; bool m_compressCurves; - }; TYPEDEF_BLUECLASS( Tr2GrannyTransformTrack ); diff --git a/trinity/Curves/Tr2GrannyTransformTrack_Blue.cpp b/trinity/Curves/Tr2GrannyTransformTrack_Blue.cpp index 5504d174d..f598f0012 100644 --- a/trinity/Curves/Tr2GrannyTransformTrack_Blue.cpp +++ b/trinity/Curves/Tr2GrannyTransformTrack_Blue.cpp @@ -12,13 +12,11 @@ const Be::ClassInfo* Tr2GrannyTransformTrack::ExposeToBlue() MAP_ATTRIBUTE( "translation", m_translation, "The position of the track", Be::READ ) MAP_ATTRIBUTE( "rotation", m_rotation, "The orientation of the track", Be::READ ) MAP_ATTRIBUTE( "scale", m_scale, "The scale of the track", Be::READ ) - MAP_ATTRIBUTE - ( - "compressCurves", - m_compressCurves, + MAP_ATTRIBUTE( + "compressCurves", + m_compressCurves, "If set, the curves are compressed (fitted to splines). This is more\n" "efficient to work with but can introduce artifacts.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_CHAINTO( Tr2GrannyTrack ) } diff --git a/trinity/Curves/Tr2GrannyVectorTrack.cpp b/trinity/Curves/Tr2GrannyVectorTrack.cpp index 8beb85fa9..1669cec75 100644 --- a/trinity/Curves/Tr2GrannyVectorTrack.cpp +++ b/trinity/Curves/Tr2GrannyVectorTrack.cpp @@ -6,8 +6,8 @@ #include "Utilities/GrannyCurveHelpers.h" // Curve set -Tr2GrannyVectorTrack::Tr2GrannyVectorTrack( IRoot* lockobj ): - Tr2GrannyTrack( lockobj ), +Tr2GrannyVectorTrack::Tr2GrannyVectorTrack( IRoot* lockobj ) : + Tr2GrannyTrack( lockobj ), m_valueCurve( NULL ) { m_value = 0.0f; @@ -27,7 +27,7 @@ void Tr2GrannyVectorTrack::UpdateValueImpl( double time ) } else { - GrannyEvaluateCurveAtT( 1, false, false, m_valueCurve, false, m_duration, (float)time,(float*)&m_value, &defaultValue ); + GrannyEvaluateCurveAtT( 1, false, false, m_valueCurve, false, m_duration, (float)time, (float*)&m_value, &defaultValue ); } } @@ -41,14 +41,14 @@ void Tr2GrannyVectorTrack::ApplyTracks( granny_track_group* group, float duratio // find the track we want to sample for( int tTIdx = 0; tTIdx < group->VectorTrackCount; ++tTIdx ) { - granny_vector_track& track = group->VectorTracks[tTIdx]; + granny_vector_track& track = group->VectorTracks[tTIdx]; if( m_name == track.Name ) { m_duration = duration; m_valueCurve = &track.ValueCurve; - UpdateValue( 0.0 );// set the default values to start values of the curve + UpdateValue( 0.0 ); // set the default values to start values of the curve return; - } + } } } diff --git a/trinity/Curves/Tr2GrannyVectorTrack.h b/trinity/Curves/Tr2GrannyVectorTrack.h index fac55e592..c870d44a1 100644 --- a/trinity/Curves/Tr2GrannyVectorTrack.h +++ b/trinity/Curves/Tr2GrannyVectorTrack.h @@ -11,19 +11,18 @@ BLUE_DECLARE( TriGrannyRes ); -BLUE_CLASS( Tr2GrannyVectorTrack ): -public Tr2GrannyTrack +BLUE_CLASS( Tr2GrannyVectorTrack ) : + public Tr2GrannyTrack { public: EXPOSE_TO_BLUE(); Tr2GrannyVectorTrack( IRoot* lockobj = NULL ); void UpdateValueImpl( double time ) override; void ResetTracks( void ) override; - void ApplyTracks( granny_track_group* group, float duration, float timeStep ) override; + void ApplyTracks( granny_track_group * group, float duration, float timeStep ) override; bool TracksReady( void ) override; protected: - float m_value; granny_curve2* m_valueCurve; }; diff --git a/trinity/Curves/Tr2QuaternionLerpCurve.cpp b/trinity/Curves/Tr2QuaternionLerpCurve.cpp index 3389acbe9..a73e6623f 100644 --- a/trinity/Curves/Tr2QuaternionLerpCurve.cpp +++ b/trinity/Curves/Tr2QuaternionLerpCurve.cpp @@ -5,10 +5,10 @@ #include "include/TriMath.h" -Tr2QuaternionLerpCurve::Tr2QuaternionLerpCurve(IRoot* lockobj) : - m_start( 0 ), +Tr2QuaternionLerpCurve::Tr2QuaternionLerpCurve( IRoot* lockobj ) : + m_start( 0 ), m_length( 0 ), - m_value( 0.0f, 0.0f, 0.0f, 1.0f ) + m_value( 0.0f, 0.0f, 0.0f, 1.0f ) { } @@ -19,102 +19,94 @@ Tr2QuaternionLerpCurve::~Tr2QuaternionLerpCurve() Quaternion* Tr2QuaternionLerpCurve::Update( - Quaternion* in, - Be::Time t - ) + Quaternion* in, + Be::Time t ) { - GetValueAt( &m_value, t ); - *in = m_value; - return in; + GetValueAt( &m_value, t ); + *in = m_value; + return in; } Quaternion* Tr2QuaternionLerpCurve::Update( - Quaternion* in, - double t - ) + Quaternion* in, + double t ) { - GetValueAt( &m_value, t ); - *in = m_value; - return in; + GetValueAt( &m_value, t ); + *in = m_value; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueAt( - Quaternion* in, - Be::Time now - ) + Quaternion* in, + Be::Time now ) { - if( !m_startCurve || !m_endCurve || m_length <= 0 ) - { - return in; - } + if( !m_startCurve || !m_endCurve || m_length <= 0 ) + { + return in; + } - Quaternion start; - Quaternion end; + Quaternion start; + Quaternion end; - float delta = TimeAsFloat( now - m_start ); - float ratio = TriClamp( delta / m_length, 0.0f, 1.0f ); + float delta = TimeAsFloat( now - m_start ); + float ratio = TriClamp( delta / m_length, 0.0f, 1.0f ); - *in = Slerp( *m_startCurve->GetValueAt( &start, now ), *m_endCurve->GetValueAt( &end, now ), ratio ); + *in = Slerp( *m_startCurve->GetValueAt( &start, now ), *m_endCurve->GetValueAt( &end, now ), ratio ); - return in; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueAt( - Quaternion* in, - double pos - ) + Quaternion* in, + double pos ) { - if( !m_startCurve || !m_endCurve || m_length <= 0 ) - { - return in; - } + if( !m_startCurve || !m_endCurve || m_length <= 0 ) + { + return in; + } - Quaternion start; - Quaternion end; + Quaternion start; + Quaternion end; - float delta = float( pos - TimeAsDouble( m_start ) ); + float delta = float( pos - TimeAsDouble( m_start ) ); float ratio = TriClamp( delta / m_length, 0.0f, 1.0f ); - *in = Slerp( *m_startCurve->GetValueAt( &start, pos ), *m_endCurve->GetValueAt( &end, pos ), ratio ); + *in = Slerp( *m_startCurve->GetValueAt( &start, pos ), *m_endCurve->GetValueAt( &end, pos ), ratio ); - return in; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueDotAt( - Quaternion* in, - Be::Time time - ) + Quaternion* in, + Be::Time time ) { - return in; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueDotAt( - Quaternion* in, - double time - ) + Quaternion* in, + double time ) { - return in; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueDoubleDotAt( - Quaternion* in, - Be::Time time - ) + Quaternion* in, + Be::Time time ) { - return in; + return in; } Quaternion* Tr2QuaternionLerpCurve::GetValueDoubleDotAt( - Quaternion* in, - double time - ) + Quaternion* in, + double time ) { - return in; + return in; } diff --git a/trinity/Curves/Tr2QuaternionLerpCurve.h b/trinity/Curves/Tr2QuaternionLerpCurve.h index ffea947af..b625aaf7b 100644 --- a/trinity/Curves/Tr2QuaternionLerpCurve.h +++ b/trinity/Curves/Tr2QuaternionLerpCurve.h @@ -7,76 +7,74 @@ #include #include -class Tr2QuaternionLerpCurve : - public ITriQuaternionFunction, - public ITriCurveLength +class Tr2QuaternionLerpCurve : public ITriQuaternionFunction, + public ITriCurveLength { public: - EXPOSE_TO_BLUE(); - - Be::Time m_start; - float m_length; - - Quaternion m_value; - ITriQuaternionFunctionPtr m_startCurve; - ITriQuaternionFunctionPtr m_endCurve; - - Tr2QuaternionLerpCurve(IRoot* lockobj = NULL); - ~Tr2QuaternionLerpCurve(); - - ///////////////////////////////////////////////////////////////////////////////////// - // ITriFunction - ///////////////////////////////////////////////////////////////////////////////////// - void UpdateValue( double time ) { Quaternion q; Update( &q, time ); } - - ///////////////////////////////////////////////////////////////////////////////////// - // ITriCurveLength - ///////////////////////////////////////////////////////////////////////////////////// - float Length() { return m_length; } - - ///////////////////////////////////////////////////////////////////////////////////// - // ITriQuaternionFunction - ///////////////////////////////////////////////////////////////////////////////////// - Quaternion* Update( - Quaternion* in, - Be::Time time - ); - - Quaternion* Update( - Quaternion* in, - double time - ); - - Quaternion* GetValueAt( - Quaternion* in, - Be::Time time - ); - - Quaternion* GetValueAt( - Quaternion* in, - double time - ); - - Quaternion* GetValueDotAt( - Quaternion* in, - Be::Time time - ); - - Quaternion* GetValueDotAt( - Quaternion* in, - double time - ); - - Quaternion* GetValueDoubleDotAt( - Quaternion* in, - Be::Time time - ); - - Quaternion* GetValueDoubleDotAt( - Quaternion* in, - double time - ); + EXPOSE_TO_BLUE(); + + Be::Time m_start; + float m_length; + + Quaternion m_value; + ITriQuaternionFunctionPtr m_startCurve; + ITriQuaternionFunctionPtr m_endCurve; + + Tr2QuaternionLerpCurve( IRoot* lockobj = NULL ); + ~Tr2QuaternionLerpCurve(); + + ///////////////////////////////////////////////////////////////////////////////////// + // ITriFunction + ///////////////////////////////////////////////////////////////////////////////////// + void UpdateValue( double time ) + { + Quaternion q; + Update( &q, time ); + } + + ///////////////////////////////////////////////////////////////////////////////////// + // ITriCurveLength + ///////////////////////////////////////////////////////////////////////////////////// + float Length() + { + return m_length; + } + + ///////////////////////////////////////////////////////////////////////////////////// + // ITriQuaternionFunction + ///////////////////////////////////////////////////////////////////////////////////// + Quaternion* Update( + Quaternion* in, + Be::Time time ); + + Quaternion* Update( + Quaternion* in, + double time ); + + Quaternion* GetValueAt( + Quaternion* in, + Be::Time time ); + + Quaternion* GetValueAt( + Quaternion* in, + double time ); + + Quaternion* GetValueDotAt( + Quaternion* in, + Be::Time time ); + + Quaternion* GetValueDotAt( + Quaternion* in, + double time ); + + Quaternion* GetValueDoubleDotAt( + Quaternion* in, + Be::Time time ); + + Quaternion* GetValueDoubleDotAt( + Quaternion* in, + double time ); }; -TYPEDEF_BLUECLASS(Tr2QuaternionLerpCurve); +TYPEDEF_BLUECLASS( Tr2QuaternionLerpCurve ); #endif //Tr2QuaternionLerpCurve_h diff --git a/trinity/Curves/Tr2QuaternionLerpCurve_Blue.cpp b/trinity/Curves/Tr2QuaternionLerpCurve_Blue.cpp index 70c930004..b5ac1dfde 100644 --- a/trinity/Curves/Tr2QuaternionLerpCurve_Blue.cpp +++ b/trinity/Curves/Tr2QuaternionLerpCurve_Blue.cpp @@ -7,46 +7,36 @@ BLUE_DEFINE( Tr2QuaternionLerpCurve ); const Be::ClassInfo* Tr2QuaternionLerpCurve::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2QuaternionLerpCurve, ":jessica-deprecated: True") - MAP_INTERFACE(ITriFunction) - MAP_INTERFACE(ITriQuaternionFunction) - MAP_INTERFACE(ITriCurveLength) + EXPOSURE_BEGIN( Tr2QuaternionLerpCurve, ":jessica-deprecated: True" ) + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( ITriQuaternionFunction ) + MAP_INTERFACE( ITriCurveLength ) - MAP_ATTRIBUTE - ( - "start", - m_start, - "The time at which the sequence should begin", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "length", - m_length, - "Length of the ", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "value", - m_value, - "na", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "startCurve", - m_startCurve, - "Starting rotation curve", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "endCurve", - m_endCurve, - "End rotation curve", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "start", + m_start, + "The time at which the sequence should begin", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "length", + m_length, + "Length of the ", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "value", + m_value, + "na", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "startCurve", + m_startCurve, + "Starting rotation curve", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "endCurve", + m_endCurve, + "End rotation curve", + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Curves/Tr2RotationAdapter.cpp b/trinity/Curves/Tr2RotationAdapter.cpp index 47c0ccc03..160388ad0 100644 --- a/trinity/Curves/Tr2RotationAdapter.cpp +++ b/trinity/Curves/Tr2RotationAdapter.cpp @@ -6,14 +6,13 @@ // -------------------------------------------------------------------------------- -Tr2RotationAdapter::Tr2RotationAdapter( IRoot* ) - :m_value( 0, 0, 0, 1 ), +Tr2RotationAdapter::Tr2RotationAdapter( IRoot* ) : + m_value( 0, 0, 0, 1 ), m_currentValue( 0, 0, 0, 1 ), m_start( 0 ), m_timeScale( 1.f ), m_offset( 0 ) { - } // -------------------------------------------------------------------------------- @@ -89,7 +88,6 @@ Quaternion* Tr2RotationAdapter::GetValueAt( Quaternion* in, double time ) *in = m_value; } return in; - } // -------------------------------------------------------------------------------- diff --git a/trinity/Curves/Tr2RotationAdapter.h b/trinity/Curves/Tr2RotationAdapter.h index 2b4d8773e..8b6e631c7 100644 --- a/trinity/Curves/Tr2RotationAdapter.h +++ b/trinity/Curves/Tr2RotationAdapter.h @@ -4,7 +4,8 @@ #include -BLUE_CLASS( Tr2RotationAdapter ) : public ITriQuaternionFunction +BLUE_CLASS( Tr2RotationAdapter ) : + public ITriQuaternionFunction { public: Tr2RotationAdapter( IRoot* lockobj = nullptr ); @@ -12,18 +13,19 @@ BLUE_CLASS( Tr2RotationAdapter ) : public ITriQuaternionFunction EXPOSE_TO_BLUE(); virtual void UpdateValue( double time ); - virtual Quaternion* Update( Quaternion* in, Be::Time time ); - virtual Quaternion* Update( Quaternion* in, double time ); - virtual Quaternion* GetValueAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDotAt( Quaternion* in, double time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, Be::Time time ); - virtual Quaternion* GetValueDoubleDotAt( Quaternion* in, double time ); + virtual Quaternion* Update( Quaternion * in, Be::Time time ); + virtual Quaternion* Update( Quaternion * in, double time ); + virtual Quaternion* GetValueAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDotAt( Quaternion * in, double time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, Be::Time time ); + virtual Quaternion* GetValueDoubleDotAt( Quaternion * in, double time ); void RandomizeStart( float range ); void ScaleTime( float scale ); void ResetStart(); + private: double GetLocalTime( double time ) const; double GetLocalTime( Be::Time time ) const; diff --git a/trinity/Curves/Tr2ScalarExprKeyCurve.cpp b/trinity/Curves/Tr2ScalarExprKeyCurve.cpp index feff779e3..524704863 100644 --- a/trinity/Curves/Tr2ScalarExprKeyCurve.cpp +++ b/trinity/Curves/Tr2ScalarExprKeyCurve.cpp @@ -17,7 +17,7 @@ // -------------------------------------------------------------------------------------- static float perlin_wrap( float x, float a, float b, float n ) { - return (float)((PerlinNoise1D( x, a, b, (int)n)+1.0)*0.5); + return (float)( ( PerlinNoise1D( x, a, b, (int)n ) + 1.0 ) * 0.5 ); } // -------------------------------------------------------------------------------------- @@ -30,7 +30,7 @@ static float perlin_wrap( float x, float a, float b, float n ) // -------------------------------------------------------------------------------------- static float perlin_wrap_simple( float x ) { - return (float)((PerlinNoise1D( x, 1.1, 2.0, (int)3)+1.0)*0.5); + return (float)( ( PerlinNoise1D( x, 1.1, 2.0, (int)3 ) + 1.0 ) * 0.5 ); } // -------------------------------------------------------------------------------------- @@ -44,7 +44,7 @@ static float perlin_wrap_simple( float x ) // -------------------------------------------------------------------------------------- static float frandom( float a, float b ) { - return ((b-a)*((float)rand()/RAND_MAX))+a; + return ( ( b - a ) * ( (float)rand() / RAND_MAX ) ) + a; } namespace @@ -65,7 +65,7 @@ struct VariableBuffer float m_value; float m_leftTangent; float m_rightTangent; - + float m_inputVar1; float m_inputVar2; float m_inputVar3; @@ -82,8 +82,8 @@ struct VariableBuffer // Description: // Tr2ScalarExprKey destructor. // -------------------------------------------------------------------------------------- -Tr2ScalarExprKey::Tr2ScalarExprKey( IRoot* lockobj ) -: m_inputVar1( 0.0f ), +Tr2ScalarExprKey::Tr2ScalarExprKey( IRoot* lockobj ) : + m_inputVar1( 0.0f ), m_inputVar2( 0.0f ), m_inputVar3( 0.0f ), m_inputVar4( 0.0f ), @@ -118,9 +118,9 @@ bool Tr2ScalarExprKey::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the key to respond to parameter +// Implements INotify interface. Allows the key to respond to parameter // changes generated in Python. If one of expression changes it is recompiled. -// Any change to attributes also triggers all expressions to be re-evaluated. +// Any change to attributes also triggers all expressions to be re-evaluated. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -144,7 +144,7 @@ bool Tr2ScalarExprKey::OnModified( Be::Var* value ) { SetExpression( m_rightTangentParser, m_rightTangentExpression ); } - + VariableBuffer buffer; buffer.m_time = m_time; buffer.m_value = m_value; @@ -180,7 +180,7 @@ bool Tr2ScalarExprKey::OnModified( Be::Var* value ) // -------------------------------------------------------------------------------------- // Description: -// Re-compiles muParser with a new expression. +// Re-compiles muParser with a new expression. // Arguments: // parser - A parser // expression - Expression to compile @@ -233,7 +233,7 @@ void Tr2ScalarExprKey::SetExpression( CcpParser::Program& parser, std::string& e // -------------------------------------------------------------------------------------- // Description: -// Re-generates random constant (passed to muParser expressions). +// Re-generates random constant (passed to muParser expressions). // -------------------------------------------------------------------------------------- void Tr2ScalarExprKey::RegenRandomConstant() { @@ -258,7 +258,7 @@ void Tr2ScalarExprKey::UpdateValues( Tr2ScalarExprKey* previousKey ) m_prevKeyTime = 0.0f; m_prevKeyValue = 0.0f; } - + VariableBuffer buffer; buffer.m_time = m_time; buffer.m_value = m_value; @@ -295,8 +295,8 @@ void Tr2ScalarExprKey::UpdateValues( Tr2ScalarExprKey* previousKey ) // Description: // Tr2ScalarExprKeyCurve constructor. // -------------------------------------------------------------------------------------- -Tr2ScalarExprKeyCurve::Tr2ScalarExprKeyCurve( IRoot* lockobj ) -: m_currentValue( 0.f ), +Tr2ScalarExprKeyCurve::Tr2ScalarExprKeyCurve( IRoot* lockobj ) : + m_currentValue( 0.f ), m_reversed( false ), m_cycle( false ), m_timeOffset( 0.f ), @@ -338,7 +338,7 @@ void Tr2ScalarExprKeyCurve::ReEvaluateKeys() // -------------------------------------------------------------------------------------- float Tr2ScalarExprKeyCurve::GetKeyLeftTangent( unsigned int idx ) { - if ( idx < (unsigned int)m_keys.size() ) + if( idx < (unsigned int)m_keys.size() ) { return m_keys[idx]->m_leftTangent; } @@ -354,7 +354,7 @@ float Tr2ScalarExprKeyCurve::GetKeyLeftTangent( unsigned int idx ) // -------------------------------------------------------------------------------------- void Tr2ScalarExprKeyCurve::SetKeyLeftTangent( unsigned int idx, float tangent ) { - if ( idx < (unsigned int)m_keys.size() ) + if( idx < (unsigned int)m_keys.size() ) { m_keys[idx]->m_leftTangent = tangent; } @@ -368,7 +368,7 @@ void Tr2ScalarExprKeyCurve::SetKeyLeftTangent( unsigned int idx, float tangent ) // -------------------------------------------------------------------------------------- float Tr2ScalarExprKeyCurve::GetKeyRightTangent( unsigned int idx ) { - if ( idx < (unsigned int)m_keys.size() ) + if( idx < (unsigned int)m_keys.size() ) { return m_keys[idx]->m_rightTangent; } @@ -384,7 +384,7 @@ float Tr2ScalarExprKeyCurve::GetKeyRightTangent( unsigned int idx ) // -------------------------------------------------------------------------------------- void Tr2ScalarExprKeyCurve::SetKeyRightTangent( unsigned int idx, float tangent ) { - if ( idx < (unsigned int)m_keys.size() ) + if( idx < (unsigned int)m_keys.size() ) { m_keys[idx]->m_rightTangent = tangent; } @@ -438,7 +438,7 @@ void Tr2ScalarExprKeyCurve::UpdateValue( double time ) // -------------------------------------------------------------------------------------- float Tr2ScalarExprKeyCurve::GetValueAt( double time ) { - if ( m_keys.empty() ) + if( m_keys.empty() ) { return 0.0f; } @@ -451,20 +451,20 @@ float Tr2ScalarExprKeyCurve::GetValueAt( double time ) time = time / (double)m_timeScale - (double)m_timeOffset; - if ( length <= 0.0f || time <= 0.0 ) + if( length <= 0.0f || time <= 0.0 ) { return m_keys.front()->m_value; } - if ( time > length + m_keys.front()->m_time ) + if( time > length + m_keys.front()->m_time ) { - if ( m_cycle ) + if( m_cycle ) { time = m_keys.front()->m_value + fmod( time - m_keys.front()->m_value, (double)length ); } else { - if ( m_reversed ) + if( m_reversed ) { return m_keys.front()->m_value; } @@ -473,31 +473,31 @@ float Tr2ScalarExprKeyCurve::GetValueAt( double time ) return m_keys.back()->m_value; } } - } + } - if ( m_reversed ) + if( m_reversed ) { time = m_keys.front()->m_value + ( (double)length - ( time - m_keys.front()->m_value ) ); } Tr2ScalarExprKey* startKey = m_keys[0]; Tr2ScalarExprKey* endKey = m_keys.back(); - if ( time <= startKey->m_time ) // We are between the start of the curve and the first key + if( time <= startKey->m_time ) // We are between the start of the curve and the first key { Interpolate( &result, float( time ), NULL, startKey ); } - else if ( time >= endKey->m_time ) // We are between the last key and the end of the curve + else if( time >= endKey->m_time ) // We are between the last key and the end of the curve { Interpolate( &result, float( time ), endKey, NULL ); } else - { + { endKey = startKey; - for ( size_t i = 1; i < m_keys.size(); ++i ) + for( size_t i = 1; i < m_keys.size(); ++i ) { startKey = endKey; endKey = m_keys[i]; - if ( endKey->m_time > time ) + if( endKey->m_time > time ) { break; } @@ -650,86 +650,83 @@ float* Tr2ScalarExprKeyCurve::Interpolate( float* out, float time, Tr2ScalarExpr float startValue = m_keys.front()->m_value; float endValue = m_keys.back()->m_value; unsigned int interp = m_interpolation; - if ( lastKey ) + if( lastKey ) { interp = lastKey->m_interpolation; - time -= lastKey->m_time; + time -= lastKey->m_time; } // The tr2 curves have by default a start and end point switch( interp ) { - case LINEAR: - { // We are in between two keys start------x---0----x------end - if ( lastKey && nextKey ) - { - startValue = lastKey->m_value; - endValue = nextKey->m_value; - deltaTime = nextKey->m_time - lastKey->m_time; - } - // We are in between the start of the curve and the next key - // start--0---x-------x------end - else if ( lastKey == NULL && nextKey != NULL ) - { - startValue = endValue = nextKey->m_value; - deltaTime = nextKey->m_time; - } - // We are in between the end of the curve and the last key - // start------x-------x--0---end - else if ( lastKey != NULL && nextKey == NULL ) - { - startValue = endValue = lastKey->m_value; - deltaTime = Length() - lastKey->m_time; - }// else there are no keys, just the start and end point . start---0---end - *out = startValue + ( endValue - startValue)*(time/deltaTime); - break; + case LINEAR: { // We are in between two keys start------x---0----x------end + if( lastKey && nextKey ) + { + startValue = lastKey->m_value; + endValue = nextKey->m_value; + deltaTime = nextKey->m_time - lastKey->m_time; } - case HERMITE: + // We are in between the start of the curve and the next key + // start--0---x-------x------end + else if( lastKey == NULL && nextKey != NULL ) { - float inTangent = 0.0f; - float outTangent = 0.0f; - // We are in between two keys start------x---0----x------end - if ( lastKey && nextKey ) - { - startValue = lastKey->m_value; - inTangent = lastKey->m_rightTangent; - endValue = nextKey->m_value; - outTangent = nextKey->m_leftTangent; - deltaTime = nextKey->m_time - lastKey->m_time; - } - // We are in between the start of the curve and the next key - // start--0---x-------x------end - else if ( lastKey == NULL && nextKey != NULL ) - { - startValue = endValue = nextKey->m_value; - outTangent = nextKey->m_leftTangent; - deltaTime = nextKey->m_time; - } - // We are in between the end of the curve and the last key - // start------x-------x--0---end - else if ( lastKey != NULL && nextKey == NULL ) - { - startValue = endValue = lastKey->m_value; - inTangent = lastKey->m_rightTangent; - deltaTime = Length() - lastKey->m_time; - }// else there are no keys, just the start and end point . start---0---end + startValue = endValue = nextKey->m_value; + deltaTime = nextKey->m_time; + } + // We are in between the end of the curve and the last key + // start------x-------x--0---end + else if( lastKey != NULL && nextKey == NULL ) + { + startValue = endValue = lastKey->m_value; + deltaTime = Length() - lastKey->m_time; + } // else there are no keys, just the start and end point . start---0---end + *out = startValue + ( endValue - startValue ) * ( time / deltaTime ); + break; + } + case HERMITE: { + float inTangent = 0.0f; + float outTangent = 0.0f; + // We are in between two keys start------x---0----x------end + if( lastKey && nextKey ) + { + startValue = lastKey->m_value; + inTangent = lastKey->m_rightTangent; + endValue = nextKey->m_value; + outTangent = nextKey->m_leftTangent; + deltaTime = nextKey->m_time - lastKey->m_time; + } + // We are in between the start of the curve and the next key + // start--0---x-------x------end + else if( lastKey == NULL && nextKey != NULL ) + { + startValue = endValue = nextKey->m_value; + outTangent = nextKey->m_leftTangent; + deltaTime = nextKey->m_time; + } + // We are in between the end of the curve and the last key + // start------x-------x--0---end + else if( lastKey != NULL && nextKey == NULL ) + { + startValue = endValue = lastKey->m_value; + inTangent = lastKey->m_rightTangent; + deltaTime = Length() - lastKey->m_time; + } // else there are no keys, just the start and end point . start---0---end - float s = time/deltaTime; - float s2 = s*s; - float s3 = s2*s; + float s = time / deltaTime; + float s2 = s * s; + float s3 = s2 * s; - float c2 = -2.0f*s3 + 3.0f*s2; - float c1 = 1.0f - c2; - float c4 = s3 - s2; - float c3 = s + c4 - s2; + float c2 = -2.0f * s3 + 3.0f * s2; + float c1 = 1.0f - c2; + float c4 = s3 - s2; + float c3 = s + c4 - s2; - *out = startValue*c1 + endValue*c2 + inTangent * c3 + outTangent * c4; - break; - } + *out = startValue * c1 + endValue * c2 + inTangent * c3 + outTangent * c4; + break; + } default: break; } return out; } - diff --git a/trinity/Curves/Tr2ScalarExprKeyCurve.h b/trinity/Curves/Tr2ScalarExprKeyCurve.h index 830d3ac78..71645c21d 100644 --- a/trinity/Curves/Tr2ScalarExprKeyCurve.h +++ b/trinity/Curves/Tr2ScalarExprKeyCurve.h @@ -24,8 +24,8 @@ BLUE_CLASS( Tr2ScalarExprKey ) : EXPOSE_TO_BLUE(); - using IInitialize::Lock; - using IInitialize::Unlock; + using IInitialize::Lock; + using IInitialize::Unlock; ///////////////////////////////////////////////////////////// // IInitialize @@ -33,15 +33,16 @@ BLUE_CLASS( Tr2ScalarExprKey ) : ///////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); void RegenRandomConstant(); - void UpdateValues( Tr2ScalarExprKey* previousKey ); + void UpdateValues( Tr2ScalarExprKey * previousKey ); // Tangent for non-linear interpolation modes - float m_leftTangent; + float m_leftTangent; // Tangent for non-linear interpolation modes - float m_rightTangent; + float m_rightTangent; + private: // Parser for time expression CcpParser::Program m_timeParser; @@ -81,7 +82,7 @@ BLUE_CLASS( Tr2ScalarExprKey ) : // Value of the previous key (can be used in expressions) float m_prevKeyValue; - void SetExpression( CcpParser::Program& parser, std::string & expression ); + void SetExpression( CcpParser::Program & parser, std::string & expression ); }; BLUE_DECLARE_VECTOR( Tr2ScalarExprKey ); @@ -92,13 +93,13 @@ BLUE_DECLARE_VECTOR( Tr2ScalarExprKey ); // See Also: // Tr2ScalarExprKey // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ScalarExprKeyCurve ): +BLUE_CLASS( Tr2ScalarExprKeyCurve ) : public ITriFunction, public IInitialize, public ITriCurveLength { public: - Tr2ScalarExprKeyCurve( IRoot* lockobj = NULL ); + Tr2ScalarExprKeyCurve( IRoot* lockobj = NULL ); EXPOSE_TO_BLUE(); @@ -124,7 +125,10 @@ BLUE_CLASS( Tr2ScalarExprKeyCurve ): unsigned int GetKeyInterpolation( unsigned int idx ); void SetKeyInterpolation( unsigned int idx, unsigned int interp ); - unsigned int GetKeyCount() const { return (unsigned int)m_keys.size(); } + unsigned int GetKeyCount() const + { + return (unsigned int)m_keys.size(); + } int AddKey( float time, float value, float leftTangent, float rightTangent, unsigned int interpolation ); void RemoveKey( unsigned int idx ); @@ -138,9 +142,10 @@ BLUE_CLASS( Tr2ScalarExprKeyCurve ): void SetKeyRightTangent( unsigned int idx, float tangent ); // Starting tangent value - float m_startTangent; - // End tangent value` - float m_endTangent; + float m_startTangent; + // End tangent value` + float m_endTangent; + private: void ReEvaluateKeys(); float* Interpolate( float* out, float time, Tr2ScalarExprKey* lastKey, Tr2ScalarExprKey* nextKey ); diff --git a/trinity/Curves/Tr2ScalarExprKeyCurve_Blue.cpp b/trinity/Curves/Tr2ScalarExprKeyCurve_Blue.cpp index ce244b196..b29434688 100644 --- a/trinity/Curves/Tr2ScalarExprKeyCurve_Blue.cpp +++ b/trinity/Curves/Tr2ScalarExprKeyCurve_Blue.cpp @@ -6,33 +6,26 @@ BLUE_DEFINE( Tr2ScalarExprKeyCurve ); BLUE_DEFINE( Tr2ScalarExprKey ); -Be::VarChooser ScalarInterpolationChooser[] = -{ - { - "CONSTANT", - BeCast( CONSTANT ), - "Performs a constant interpolation" - }, - { - "LINEAR", - BeCast( LINEAR ), - "Performs a linear interpolation" - }, - { - "HERMITE", - BeCast( HERMITE ), - "Performs a Hermite spline interpolation" - }, +Be::VarChooser ScalarInterpolationChooser[] = { + { "CONSTANT", + BeCast( CONSTANT ), + "Performs a constant interpolation" }, + { "LINEAR", + BeCast( LINEAR ), + "Performs a linear interpolation" }, + { "HERMITE", + BeCast( HERMITE ), + "Performs a Hermite spline interpolation" }, { 0 } }; const Be::ClassInfo* Tr2ScalarExprKey::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ScalarExprKey, "" ) - MAP_INTERFACE( Tr2ScalarExprKey ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) - + EXPOSURE_BEGIN( Tr2ScalarExprKey, "" ) + MAP_INTERFACE( Tr2ScalarExprKey ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) + MAP_ATTRIBUTE( "time", m_time, "Key time", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "value", m_value, "Key value", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "left", m_leftTangent, "Left tangent value", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) @@ -56,15 +49,15 @@ const Be::ClassInfo* Tr2ScalarExprKey::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "Curve interpolation at key", Be::READWRITE | Be::PERSIST | Be::ENUM, ScalarInterpolationChooser ) - MAP_METHOD_AND_WRAP( "RegenRandomConstant", RegenRandomConstant, "Regenerate the randomConstant variable for expressions") + MAP_METHOD_AND_WRAP( "RegenRandomConstant", RegenRandomConstant, "Regenerate the randomConstant variable for expressions" ) EXPOSURE_END() } const Be::ClassInfo* Tr2ScalarExprKeyCurve::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ScalarExprKeyCurve, ":jessica-deprecated:" ) + EXPOSURE_BEGIN( Tr2ScalarExprKeyCurve, ":jessica-deprecated:" ) MAP_INTERFACE( ITriFunction ) - MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( IInitialize ) MAP_INTERFACE( ITriCurveLength ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) @@ -78,84 +71,83 @@ const Be::ClassInfo* Tr2ScalarExprKeyCurve::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "interpolation", m_interpolation, "", Be::READWRITE | Be::PERSIST | Be::ENUM, ScalarInterpolationChooser ) MAP_ATTRIBUTE( "keys", m_keys, "These are the keys of the curve", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "AddKey", - AddKey, - 3, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "AddKey", + AddKey, + 3, "Adds a new key to the curve\n" ":param time: key time\n" ":param value: key value\n" ":param leftTangent: key left tangent value\n" ":param rightTangent: key right tangent value\n" ":param interpolation: key interpolation type" ); - MAP_METHOD_AND_WRAP( - "RemoveKey", - RemoveKey, + MAP_METHOD_AND_WRAP( + "RemoveKey", + RemoveKey, "Removes a key\n" ":param idx: key index" ); MAP_METHOD_AND_WRAP( "GetKeyCount", GetKeyCount, "Returns number of keys" ); - MAP_METHOD_AND_WRAP( - "GetValueAt", - GetValueAt, + MAP_METHOD_AND_WRAP( + "GetValueAt", + GetValueAt, "Returns curve value at a given time\n" ":param time: input time" ); - MAP_METHOD_AND_WRAP( - "GetKeyValue", - GetKeyValue, + MAP_METHOD_AND_WRAP( + "GetKeyValue", + GetKeyValue, "Returns key value\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyTime", - GetKeyTime, + MAP_METHOD_AND_WRAP( + "GetKeyTime", + GetKeyTime, "Returns key time\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyLeftTangent", - GetKeyLeftTangent, + MAP_METHOD_AND_WRAP( + "GetKeyLeftTangent", + GetKeyLeftTangent, "Returns key left tangent value\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyRightTangent", - GetKeyRightTangent, + MAP_METHOD_AND_WRAP( + "GetKeyRightTangent", + GetKeyRightTangent, "Returns key left tangent value\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyInterpolation", - GetKeyInterpolation, + MAP_METHOD_AND_WRAP( + "GetKeyInterpolation", + GetKeyInterpolation, "Returns interpolation type for the key\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "SetKeyValue", - SetKeyValue, + MAP_METHOD_AND_WRAP( + "SetKeyValue", + SetKeyValue, "Changes key value\n" ":param idx: key index\n" ":param value: new key value" ); - MAP_METHOD_AND_WRAP( - "SetKeyTime", - SetKeyTime, + MAP_METHOD_AND_WRAP( + "SetKeyTime", + SetKeyTime, "Changes key time.\n" "You need to call Sort() afterwards, to make sure the keys are in the correct order.\n" ":param idx: key index\n" ":param time: new key time" ); - MAP_METHOD_AND_WRAP( - "SetKeyLeftTangent", - SetKeyLeftTangent, + MAP_METHOD_AND_WRAP( + "SetKeyLeftTangent", + SetKeyLeftTangent, "Changes key left tangent value" ":param idx: key index\n" ":param value: new key left tangent value" ); - MAP_METHOD_AND_WRAP( - "SetKeyRightTangent", - SetKeyRightTangent, + MAP_METHOD_AND_WRAP( + "SetKeyRightTangent", + SetKeyRightTangent, "Changes key right tangent value" ":param idx: key index\n" ":param value: new key left tangent value" ); - MAP_METHOD_AND_WRAP( - "SetKeyInterpolation", - SetKeyInterpolation, + MAP_METHOD_AND_WRAP( + "SetKeyInterpolation", + SetKeyInterpolation, "Changes key interpolation type\n" ":param idx: key index\n" ":param interpolation: new interpolation type" ); MAP_METHOD_AND_WRAP( "Sort", Sort, "Re-evaluate key expressions" ); - EXPOSURE_END() + EXPOSURE_END() } - diff --git a/trinity/Curves/Tr2TranslationAdapter.cpp b/trinity/Curves/Tr2TranslationAdapter.cpp index 7b4ccc988..d47242fc9 100644 --- a/trinity/Curves/Tr2TranslationAdapter.cpp +++ b/trinity/Curves/Tr2TranslationAdapter.cpp @@ -7,15 +7,14 @@ // -------------------------------------------------------------------------------- -Tr2TranslationAdapter::Tr2TranslationAdapter( IRoot* ) - :m_start( 0 ), +Tr2TranslationAdapter::Tr2TranslationAdapter( IRoot* ) : + m_start( 0 ), m_offset( 0 ), m_value( 0, 0, 0 ), m_currentValue( 0, 0, 0 ), m_rotationOffset( 0, 0, 0, 1 ), m_timeScale( 1 ) { - } // -------------------------------------------------------------------------------- @@ -97,7 +96,6 @@ Vector3* Tr2TranslationAdapter::GetValueAt( Vector3* in, double time ) *in = m_value; } return in; - } // -------------------------------------------------------------------------------- diff --git a/trinity/Curves/Tr2TranslationAdapter.h b/trinity/Curves/Tr2TranslationAdapter.h index 1be4bd70e..0f072e483 100644 --- a/trinity/Curves/Tr2TranslationAdapter.h +++ b/trinity/Curves/Tr2TranslationAdapter.h @@ -4,7 +4,8 @@ #include -BLUE_CLASS( Tr2TranslationAdapter ): public ITriVectorFunction +BLUE_CLASS( Tr2TranslationAdapter ) : + public ITriVectorFunction { public: Tr2TranslationAdapter( IRoot* lockobj = nullptr ); @@ -12,19 +13,20 @@ BLUE_CLASS( Tr2TranslationAdapter ): public ITriVectorFunction EXPOSE_TO_BLUE(); virtual void UpdateValue( double time ); - virtual Vector3* Update( Vector3* in, Be::Time time ); - virtual Vector3* Update( Vector3* in, double time ); - virtual Vector3* GetValueAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueAt( Vector3* in, double time ); - virtual Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDotAt( Vector3* in, double time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - virtual Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - virtual Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + virtual Vector3* Update( Vector3 * in, Be::Time time ); + virtual Vector3* Update( Vector3 * in, double time ); + virtual Vector3* GetValueAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueAt( Vector3 * in, double time ); + virtual Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDotAt( Vector3 * in, double time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + virtual Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + virtual Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); void RandomizeStart( float range ); void ScaleTime( float scale ); void ResetStart(); + private: double GetLocalTime( double time ) const; double GetLocalTime( Be::Time time ) const; diff --git a/trinity/Curves/TriCurveSet.cpp b/trinity/Curves/TriCurveSet.cpp index 11c7e4e6b..fb45aedac 100644 --- a/trinity/Curves/TriCurveSet.cpp +++ b/trinity/Curves/TriCurveSet.cpp @@ -9,8 +9,8 @@ #include #include -Tr2CurveSetRange::Tr2CurveSetRange( IRoot* ) - :m_startTime( 0 ), +Tr2CurveSetRange::Tr2CurveSetRange( IRoot* ) : + m_startTime( 0 ), m_endTime( 1 ), m_looped( false ) { @@ -48,7 +48,7 @@ TriCurveSet::~TriCurveSet() } } -void TriCurveSet::Update( Be::Time realTime, Be::Time simTime ) +void TriCurveSet::Update( Be::Time realTime, Be::Time simTime ) { double time; if( m_useRealTime ) @@ -79,7 +79,7 @@ void TriCurveSet::Update( double time ) { CCP_STATS_ZONE( __FUNCTION__ ); - if ( m_driver != nullptr ) + if( m_driver != nullptr ) { time = m_driver->GetCurveSetTime( time ); } @@ -95,7 +95,7 @@ void TriCurveSet::Update( double time ) { if( m_startTime < 0.0 ) { - if ( m_driver != nullptr ) + if( m_driver != nullptr ) { m_startTime = 0; } @@ -130,7 +130,7 @@ void TriCurveSet::Update( double time ) } } - if( (m_endTime > 0.0) && ((m_startTime + m_scaledTime) >= m_endTime) ) + if( ( m_endTime > 0.0 ) && ( ( m_startTime + m_scaledTime ) >= m_endTime ) ) { m_scaledTime = m_endTime - m_startTime - 0.001f; m_stopOnNextFrame = true; @@ -204,8 +204,8 @@ void TriCurveSet::PlayTimeRange( const char* name ) return; } } - - if ( rangeFound ) + + if( rangeFound ) { Stop(); } @@ -222,7 +222,7 @@ void TriCurveSet::PlayFrom( double time ) // some curves need to know about a play start (event curves) for( ITriFunctionVector::const_iterator it = m_curves.begin(); it != m_curves.end(); ++it ) { - (*it)->Reset(); + ( *it )->Reset(); } m_callback.Destroy(); @@ -319,7 +319,7 @@ bool TriCurveSet::IsPlaying() const void TriCurveSet::UpdateWithCurrentTime() { - Update( double(BeOS->GetCurrentFrameTime()) ); + Update( double( BeOS->GetCurrentFrameTime() ) ); } void TriCurveSet::SetTimeRange( double timeMin, double timeMax, Be::OptionalWithDefaultValue looped ) diff --git a/trinity/Curves/TriCurveSet.h b/trinity/Curves/TriCurveSet.h index c0a232e0a..4f2c6617a 100644 --- a/trinity/Curves/TriCurveSet.h +++ b/trinity/Curves/TriCurveSet.h @@ -17,7 +17,8 @@ BLUE_DECLARE_IVECTOR( ITr2ValueBinding ); BLUE_DECLARE_INTERFACE( ICurveSetDriver ); -BLUE_CLASS( Tr2CurveSetRange ): public IRoot +BLUE_CLASS( Tr2CurveSetRange ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -36,14 +37,14 @@ TYPEDEF_BLUECLASS( Tr2CurveSetRange ); BLUE_DECLARE_VECTOR( Tr2CurveSetRange ); -BLUE_CLASS( TriCurveSet ): - public IInitialize, - public ITr2Updateable, - public ISimTimeRebaseNotify +BLUE_CLASS( TriCurveSet ) : + public IInitialize, + public ITr2Updateable, + public ISimTimeRebaseNotify { public: - EXPOSE_TO_BLUE(); - TriCurveSet( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriCurveSet( IRoot* lockobj = NULL ); ~TriCurveSet(); void Update( double time ); @@ -64,17 +65,32 @@ BLUE_CLASS( TriCurveSet ): void ApplyTime( double time ); // access the name - const std::string& GetName() const { return m_name; } + const std::string& GetName() const + { + return m_name; + } void SetName( const std::string& name ); // access the curves - size_t GetCurvesCount() const { return m_curves.size(); } - ITriFunctionPtr GetCurve( unsigned int _id ) { return m_curves[ _id ]; } + size_t GetCurvesCount() const + { + return m_curves.size(); + } + ITriFunctionPtr GetCurve( unsigned int _id ) + { + return m_curves[_id]; + } void AddCurve( ITriFunctionPtr curve ); // access the bindings - size_t GetBindingsCount() const { return m_bindings.size(); } - ITr2ValueBindingPtr GetBinding( unsigned int _id ) { return m_bindings[ _id ]; } + size_t GetBindingsCount() const + { + return m_bindings.size(); + } + ITr2ValueBindingPtr GetBinding( unsigned int _id ) + { + return m_bindings[_id]; + } void AddBinding( ITr2ValueBindingPtr binding ); // Gets the duration of the longest non-cycling curve in the curve set @@ -86,7 +102,7 @@ BLUE_CLASS( TriCurveSet ): ////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ////////////////////////////////////////////////////////////////////////// // ISimTimeRebaseNotify void OnSimClockRebase( Be::Time oldTime, Be::Time newTime ); @@ -95,6 +111,7 @@ BLUE_CLASS( TriCurveSet ): void ResetTimeRange(); bool HasTimeRange() const; std::pair GetTimeRange() const; + private: void UpdateWithCurrentTime(); diff --git a/trinity/Curves/TriCurveSet_Blue.cpp b/trinity/Curves/TriCurveSet_Blue.cpp index 7ded8702b..ade813c9b 100644 --- a/trinity/Curves/TriCurveSet_Blue.cpp +++ b/trinity/Curves/TriCurveSet_Blue.cpp @@ -9,16 +9,15 @@ BLUE_DEFINE_INTERFACE( ITr2CurveSetOwner ); BLUE_DEFINE( Tr2CurveSetRange ); -const Be::ClassInfo* Tr2CurveSetRange::ExposeToBlue() -{ +const Be::ClassInfo* Tr2CurveSetRange::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2CurveSetRange, "" ) MAP_INTERFACE( Tr2CurveSetRange ) - MAP_ATTRIBUTE( "name", m_name, "Time range name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "startTime", m_startTime, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endTime", m_endTime, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "looped", m_looped, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "Time range name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "startTime", m_startTime, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endTime", m_endTime, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "looped", m_looped, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } @@ -26,48 +25,37 @@ BLUE_DEFINE( TriCurveSet ); const Be::ClassInfo* TriCurveSet::ExposeToBlue() { - EXPOSURE_BEGIN( TriCurveSet,"" ) - MAP_INTERFACE( TriCurveSet ) + EXPOSURE_BEGIN( TriCurveSet, "" ) + MAP_INTERFACE( TriCurveSet ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( ITr2Updateable ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "Name of this curve set", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "curves", - m_curves, - "List of curves. Bind these curves to target objects with a binding.", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "bindings", - m_bindings, - "List of bindings. Note that a single curve can have multiple bindings.", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "driver", - m_driver, - "The type of object you want driving the the values of curves in this curve set. If not set then this curve set will be driven by time.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "curves", + m_curves, + "List of curves. Bind these curves to target objects with a binding.", + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "bindings", + m_bindings, + "List of bindings. Note that a single curve can have multiple bindings.", + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "driver", + m_driver, + "The type of object you want driving the the values of curves in this curve set. If not set then this curve set will be driven by time.", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "ranges", m_ranges, "List of named time ranges.", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "scale", m_scale, "Scaling factor applied to time when curves are playing.\n" @@ -75,25 +63,19 @@ const Be::ClassInfo* TriCurveSet::ExposeToBlue() "Values higher than 1.0 make the curves play faster, lower than 1.0\n" "make them play slower.\n" "Negative values make the curves play backwards.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "playOnLoad", m_playOnLoad, "If set, the curve set plays automatically on load. Otherwise Play must be" "called explicitly to start it.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isPlaying", m_isPlaying, "True if the curve set is playing", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "scaledTime", m_scaledTime, "This is the time value passed into the curves when sampling their values.\n" @@ -102,76 +84,62 @@ const Be::ClassInfo* TriCurveSet::ExposeToBlue() "Note that this value can be changed at any time, making the curves\n" "jump to that point in time. To have absolute control over this time\n" "value, set the scale factor to 0.\n", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "useSimTimeRebase", m_useSimTimeRebase, "Should internal time be rebased when sim time is rebased. Will only work if loaded with this attribute set.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "useRealTime", m_useRealTime, "If set, curves are updated based on real time, rather than sim time (the default). This means\n" "they will not be affected by time dilation and should generally only be used for UI animations.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Update", UpdateWithCurrentTime, - "Updates the curve set with the current frame time." - ) + "Updates the curve set with the current frame time." ) - MAP_METHOD_AND_WRAP( - "Play", - Play, + MAP_METHOD_AND_WRAP( + "Play", + Play, "Play this curve set from the start\n" ":jessica-favorite:\n" - ":jessica-icon: timeline/play.png" - ) - MAP_METHOD_AND_WRAP( - "PlayFrom", - PlayFrom, + ":jessica-icon: timeline/play.png" ) + MAP_METHOD_AND_WRAP( + "PlayFrom", + PlayFrom, "Play this curve set from the given time (in seconds)\n" ":param time: start time offset in seconds" ) - MAP_METHOD_AND_WRAP( - "Stop", - Stop, - "Stop the playback of this curveset\n" + MAP_METHOD_AND_WRAP( + "Stop", + Stop, + "Stop the playback of this curveset\n" ":jessica-favorite:\n" - ":jessica-icon: timeline/stop.png" - ) + ":jessica-icon: timeline/stop.png" ) MAP_METHOD_AND_WRAP( "StopOnNextFrame", StopOnNextFrame, "Stop the playback of this curveset on the next frame" ) - MAP_METHOD_AND_WRAP( - "StopAfter", - StopAfter, + MAP_METHOD_AND_WRAP( + "StopAfter", + StopAfter, "Stop the playback of this curveset after the given number of seconds\n" ":param time: time in seconds" ) MAP_METHOD_AND_WRAP( "GetMaxCurveDuration", GetMaxCurveDuration, "Gets the duration of the longest non-cycling curve" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "StopAfterWithCallback", StopAfterWithCallback, "Stop the playback of this curveset after the given number of seconds, issuing a callback to Python when the playback stops\n" "WARNING! Callbacks work reliably only for UI curve sets (executed by device); callbacks for curve sets attached to 3D objects\n" "in the scene may cause deadlocks.\n" ":param time: time in seconds\n" - ":param cb: callback function" - ) - MAP_METHOD_AND_WRAP - ( + ":param cb: callback function" ) + MAP_METHOD_AND_WRAP( "Apply", Apply, - "Re-evaluates curves and applies bindings once using curve set current time" - ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + "Re-evaluates curves and applies bindings once using curve set current time" ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "SetTimeRange", SetTimeRange, 1, @@ -179,27 +147,20 @@ const Be::ClassInfo* TriCurveSet::ExposeToBlue() "it will loop time inside the range while playing.\n" ":param minTime: min time value for the range\n" ":param maxTime: max time value for the range\n" - ":param looped: should we loop inside the time range" - ) - MAP_METHOD_AND_WRAP - ( + ":param looped: should we loop inside the time range" ) + MAP_METHOD_AND_WRAP( "ResetTimeRange", ResetTimeRange, - "Clears time range previously set up using SetTimeRange method" - ) - MAP_METHOD_AND_WRAP - ( + "Clears time range previously set up using SetTimeRange method" ) + MAP_METHOD_AND_WRAP( "HasTimeRange", HasTimeRange, - "Queries if the curve set has a time range set up" - ) - MAP_METHOD_AND_WRAP - ( + "Queries if the curve set has a time range set up" ) + MAP_METHOD_AND_WRAP( "GetTimeRange", GetTimeRange, - "Returns time range min and max time" - ) + "Returns time range min and max time" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Curves/TriEventCurve.cpp b/trinity/Curves/TriEventCurve.cpp index 072077ac9..70b66d77b 100644 --- a/trinity/Curves/TriEventCurve.cpp +++ b/trinity/Curves/TriEventCurve.cpp @@ -7,23 +7,23 @@ #if BLUE_WITH_PYTHON namespace { - void EventKeyCallback( void* context ) - { - TriEventKey* key = reinterpret_cast( context ); - - PyObject* result = PyObject_CallObject( key->m_callable, key->m_callableArgs ); - if( result ) - { - Py_DECREF( result ); - } - else - { - ; //TODO: Handle error - } +void EventKeyCallback( void* context ) +{ + TriEventKey* key = reinterpret_cast( context ); - // A reference was added when the callback was set up - release it here. - key->Unlock(); + PyObject* result = PyObject_CallObject( key->m_callable, key->m_callableArgs ); + if( result ) + { + Py_DECREF( result ); } + else + { + ; //TODO: Handle error + } + + // A reference was added when the callback was set up - release it here. + key->Unlock(); +} } #endif @@ -56,33 +56,32 @@ void TriEventCurve::UpdateValue( double time ) // and do nothing. return; } - + switch( m_extrapolation ) { - case TRIEXT_CYCLE: - { - float localNow = (float)fmod( m_time, (double)m_length ); - if( localNow < m_localTime ) - { - // We've wrapped around - m_currentKeyIt = m_keys.begin(); - } - m_localTime = localNow; - } - break; + case TRIEXT_CYCLE: { + float localNow = (float)fmod( m_time, (double)m_length ); + if( localNow < m_localTime ) + { + // We've wrapped around + m_currentKeyIt = m_keys.begin(); + } + m_localTime = localNow; + } + break; - default: - m_localTime = (float)m_time; - break; + default: + m_localTime = (float)m_time; + break; } - - while( (m_currentKeyIt != m_keys.end()) && (m_localTime >= (*m_currentKeyIt)->m_time) ) + + while( ( m_currentKeyIt != m_keys.end() ) && ( m_localTime >= ( *m_currentKeyIt )->m_time ) ) { // Found a key that has a time value of less than or equal to now TriEventKey* currentKey = *m_currentKeyIt; m_value = currentKey->m_value; - + // Fire off event #if BLUE_WITH_PYTHON if( currentKey->m_callable ) @@ -99,14 +98,14 @@ void TriEventCurve::UpdateValue( double time ) } else #endif - if( m_eventListener ) + if( m_eventListener ) { if( !currentKey->m_value.empty() ) { m_eventListener->HandleEvent( currentKey->m_value.c_str() ); } } - + ++m_currentKeyIt; } @@ -128,7 +127,7 @@ void TriEventCurve::AddKey( float time, const std::wstring& evtName ) key->m_time = time; key->m_value = evtName.c_str(); - InsertKey(key); + InsertKey( key ); } #if BLUE_WITH_PYTHON @@ -159,7 +158,7 @@ void TriEventCurve::AddCallableKey( float time, PyObject* callable, PyObject* ar } key->m_callableArgs = argsAsTuple; - InsertKey(key); + InsertKey( key ); } #endif @@ -194,7 +193,7 @@ bool TriEventCurve::Initialize() float TriEventCurve::GetKeyTime( int ix ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) { return m_keys[ix]->m_time; } @@ -203,7 +202,7 @@ float TriEventCurve::GetKeyTime( int ix ) std::wstring TriEventCurve::GetKeyValue( int ix ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) { return m_keys[ix]->m_value; } @@ -212,7 +211,7 @@ std::wstring TriEventCurve::GetKeyValue( int ix ) void TriEventCurve::SetKeyTime( int ix, float time ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) { m_keys[ix]->m_time = time; m_keys.Sort( (IList::CompareFn)CompareKeys, NULL ); @@ -222,7 +221,7 @@ void TriEventCurve::SetKeyTime( int ix, float time ) void TriEventCurve::SetKeyValue( int ix, std::wstring value ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) { m_keys[ix]->m_value = value; } @@ -231,22 +230,22 @@ void TriEventCurve::SetKeyValue( int ix, std::wstring value ) #if BLUE_WITH_PYTHON PyObject* TriEventCurve::GetCallableKeyValue( int ix ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) - { - Py_XINCREF( m_keys[ix]->m_callable ); - return m_keys[ix]->m_callable; - } - Py_RETURN_NONE; + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) + { + Py_XINCREF( m_keys[ix]->m_callable ); + return m_keys[ix]->m_callable; + } + Py_RETURN_NONE; } PyObject* TriEventCurve::GetCallableKeyArgs( int ix ) { - if( (ix < m_keys.GetSize()) && (ix >= 0) ) - { - Py_XINCREF( m_keys[ix]->m_callableArgs ); - return m_keys[ix]->m_callableArgs; - } - Py_RETURN_NONE; + if( ( ix < m_keys.GetSize() ) && ( ix >= 0 ) ) + { + Py_XINCREF( m_keys[ix]->m_callableArgs ); + return m_keys[ix]->m_callableArgs; + } + Py_RETURN_NONE; } #endif diff --git a/trinity/Curves/TriEventCurve.h b/trinity/Curves/TriEventCurve.h index 422706e00..b1035ade6 100644 --- a/trinity/Curves/TriEventCurve.h +++ b/trinity/Curves/TriEventCurve.h @@ -14,14 +14,13 @@ BLUE_DECLARE( TriEventCurve ); -class TriEventCurve: - public ITriFunction, - public IInitialize, - public ITriCurveLength +class TriEventCurve : public ITriFunction, + public IInitialize, + public ITriCurveLength { public: - EXPOSE_TO_BLUE(); - TriEventCurve( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriEventCurve( IRoot* lockobj = NULL ); ////////////////////////////////////////////////////////////////////////// // ITriFunction @@ -33,7 +32,10 @@ class TriEventCurve: ////////////////////////////////////////////////////////////////////////// // ITriEventCurve - float Length() { return m_length; } + float Length() + { + return m_length; + } void Sort(); @@ -50,8 +52,8 @@ class TriEventCurve: void SetKeyValue( int ix, std::wstring value ); #if BLUE_WITH_PYTHON - PyObject* GetCallableKeyValue( int ix ); - PyObject* GetCallableKeyArgs( int ix ); + PyObject* GetCallableKeyValue( int ix ); + PyObject* GetCallableKeyArgs( int ix ); #endif int GetKeyCount(); diff --git a/trinity/Curves/TriEventCurve_Blue.cpp b/trinity/Curves/TriEventCurve_Blue.cpp index 55cb41331..54e41224a 100644 --- a/trinity/Curves/TriEventCurve_Blue.cpp +++ b/trinity/Curves/TriEventCurve_Blue.cpp @@ -8,133 +8,113 @@ BLUE_DEFINE( TriEventCurve ); const Be::ClassInfo* TriEventCurve::ExposeToBlue() { - EXPOSURE_BEGIN( TriEventCurve, ":jessica-deprecated: True" ) - MAP_INTERFACE( TriEventCurve ) + EXPOSURE_BEGIN( TriEventCurve, ":jessica-deprecated: True" ) + MAP_INTERFACE( TriEventCurve ) MAP_INTERFACE( ITriFunction ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( ITriCurveLength ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "time", m_time, "Current time of the curve", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "length", m_length, "Length of the curve", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "localTime", m_localTime, "Local time - reset to 0 when curve cycles.", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "value", m_value, "The string value of the last key triggered.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "keys", - m_keys, - "These are the keys of the curve", - Be::PERSISTONLY - ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "extrapolation", - m_extrapolation, - "This controls how time values outside the range of the curve are handled", - Be::READWRITE | Be::PERSIST | Be::ENUM, - TriExtrapolation - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "keys", + m_keys, + "These are the keys of the curve", + Be::PERSISTONLY ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "extrapolation", + m_extrapolation, + "This controls how time values outside the range of the curve are handled", + Be::READWRITE | Be::PERSIST | Be::ENUM, + TriExtrapolation ) + MAP_ATTRIBUTE( "eventListener", m_eventListener, "", - Be::READWRITE - ) + Be::READWRITE ) - MAP_METHOD_AND_WRAP - ( - "AddKey", - AddKey, + MAP_METHOD_AND_WRAP( + "AddKey", + AddKey, "Adds a key with a string value. This string value is passed to\n" "the handler when the key is triggered.\n" ":param time: key time\n" - ":param evtName: event name" - ) + ":param evtName: event name" ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP - ( - "AddCallableKey", - AddCallableKey, + MAP_METHOD_AND_WRAP( + "AddCallableKey", + AddCallableKey, "Adds a key with a callable. This callable is called when the key\n" "is triggered.\n" ":param time: key time\n" ":param cb: callback callable\n" - ":param args: arguments for the cb" - ) + ":param args: arguments for the cb" ) #endif - MAP_METHOD_AND_WRAP( - "RemoveKey", - RemoveKey, + MAP_METHOD_AND_WRAP( + "RemoveKey", + RemoveKey, "Removes a key\n" ":param idx: key index" ); MAP_METHOD_AND_WRAP( "GetKeyCount", GetKeyCount, "Returns number of keys" ); - MAP_METHOD_AND_WRAP( - "GetKeyValue", - GetKeyValue, + MAP_METHOD_AND_WRAP( + "GetKeyValue", + GetKeyValue, "Returns key value\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetKeyTime", - GetKeyTime, + MAP_METHOD_AND_WRAP( + "GetKeyTime", + GetKeyTime, "Returns key time\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "SetKeyValue", - SetKeyValue, + MAP_METHOD_AND_WRAP( + "SetKeyValue", + SetKeyValue, "Changes key value\n" ":param idx: key index\n" ":param value: new key value" ); - MAP_METHOD_AND_WRAP( - "SetKeyTime", - SetKeyTime, + MAP_METHOD_AND_WRAP( + "SetKeyTime", + SetKeyTime, "Changes key time.\n" ":param idx: key index\n" ":param time: new key time" ); #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP( - "GetCallableKeyValue", - GetCallableKeyValue, + MAP_METHOD_AND_WRAP( + "GetCallableKeyValue", + GetCallableKeyValue, "Returns callable associated with the key\n" ":param idx: key index" ); - MAP_METHOD_AND_WRAP( - "GetCallableKeyArgs", - GetCallableKeyArgs, + MAP_METHOD_AND_WRAP( + "GetCallableKeyArgs", + GetCallableKeyArgs, "Returns callable arguments for the key\n" ":param idx: key index" ); #endif - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Curves/TriEventKey.h b/trinity/Curves/TriEventKey.h index ea5232ad6..a2717ea63 100644 --- a/trinity/Curves/TriEventKey.h +++ b/trinity/Curves/TriEventKey.h @@ -7,13 +7,13 @@ #include -BLUE_CLASS( TriEventKey ): - public IRoot +BLUE_CLASS( TriEventKey ) : + public IRoot { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); - TriEventKey( IRoot* lockobj = NULL ); + TriEventKey( IRoot* lockobj = NULL ); ~TriEventKey(); float m_time; diff --git a/trinity/Curves/TriEventKey_Blue.cpp b/trinity/Curves/TriEventKey_Blue.cpp index e5f6606f8..53955521e 100644 --- a/trinity/Curves/TriEventKey_Blue.cpp +++ b/trinity/Curves/TriEventKey_Blue.cpp @@ -7,42 +7,34 @@ BLUE_DEFINE( TriEventKey ); const Be::ClassInfo* TriEventKey::ExposeToBlue() { - EXPOSURE_BEGIN( TriEventKey, "" ) - MAP_INTERFACE( TriEventKey ) - - MAP_ATTRIBUTE - ( - "time", - m_time, - "Time value for this key", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "value", - m_value, + EXPOSURE_BEGIN( TriEventKey, "" ) + MAP_INTERFACE( TriEventKey ) + + MAP_ATTRIBUTE( + "time", + m_time, + "Time value for this key", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "value", + m_value, "String associated with this key. This is passed to the event curve\n" - "handler in the case where no callable is set.", - Be::READWRITE | Be::PERSIST - ) + "handler in the case where no callable is set.", + Be::READWRITE | Be::PERSIST ) #if BLUE_WITH_PYTHON - MAP_ATTRIBUTE - ( - "callable", - m_callable, + MAP_ATTRIBUTE( + "callable", + m_callable, "A Python callable, called when the event triggers.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( - "callableArgs", - m_callableArgs, + MAP_ATTRIBUTE( + "callableArgs", + m_callableArgs, "Arguments passed to the Python callable, called when the event triggers.", - Be::READWRITE - ) + Be::READWRITE ) #endif EXPOSURE_END() diff --git a/trinity/Eve/AudioGameObject.cpp b/trinity/Eve/AudioGameObject.cpp index 8a18b7498..0eae1106b 100644 --- a/trinity/Eve/AudioGameObject.cpp +++ b/trinity/Eve/AudioGameObject.cpp @@ -10,7 +10,8 @@ AudioGameObject::AudioGameObject( IRoot* lockobj ) : m_translation( 0.0f, 0.0f, 0.0f ), m_mute( false ), m_display( true ) -{} +{ +} bool AudioGameObject::Initialize() { @@ -20,7 +21,7 @@ bool AudioGameObject::Initialize() return true; } - if( SUCCEEDED( BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast(&m_audioEmitter.p) ) ) ) + if( SUCCEEDED( BeClasses->CreateInstanceFromName( "AudEmitter", BlueInterfaceIID(), reinterpret_cast( &m_audioEmitter.p ) ) ) ) { UpdateWorldTransform( Be::Time( 0.0 ) ); @@ -91,27 +92,27 @@ void AudioGameObject::GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpac { } -void AudioGameObject::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void AudioGameObject::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { UpdateWorldTransform( t ); Matrix currentTransform = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), m_rotation, m_translation ) * m_worldTransform; position = currentTransform.GetTranslation(); } -void AudioGameObject::GetModelCenterWorldPosition( Vector3 &position ) const +void AudioGameObject::GetModelCenterWorldPosition( Vector3& position ) const { Matrix currentTransform = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), m_rotation, m_translation ) * m_worldTransform; position = currentTransform.GetTranslation(); } -bool AudioGameObject::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) +bool AudioGameObject::GetLocalBoundingBox( Vector3& min, Vector3& max ) { min = Vector3( -1.0f, -1.0f, -1.0f ); max = Vector3( 1.0f, 1.0f, 1.0f ); return true; } -void AudioGameObject::GetLocalToWorldTransform( Matrix &transform ) const +void AudioGameObject::GetLocalToWorldTransform( Matrix& transform ) const { transform = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), m_rotation, m_translation ) * m_worldTransform; } diff --git a/trinity/Eve/AudioGameObject.h b/trinity/Eve/AudioGameObject.h index 3d17144ee..4e69a1d3e 100644 --- a/trinity/Eve/AudioGameObject.h +++ b/trinity/Eve/AudioGameObject.h @@ -10,12 +10,12 @@ #include "IEveSpaceObject2.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif #include @@ -34,7 +34,7 @@ BLUE_DECLARE( AudioGameObject ); * */ -BLUE_CLASS( AudioGameObject ): +BLUE_CLASS( AudioGameObject ) : public IWorldPosition, public IEveSpaceObject2, public IInitialize, @@ -43,41 +43,44 @@ BLUE_CLASS( AudioGameObject ): { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); AudioGameObject( IRoot* lockobj = NULL ); bool Initialize(); void py__init__(); - - virtual bool OnModified( Be::Var* val ); + + virtual bool OnModified( Be::Var * val ); // IEveSpaceObject2 void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const; - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - void GetModelCenterWorldPosition( Vector3 &position ) const; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - void GetLocalToWorldTransform( Matrix &transform ) const; + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void GetPerObjectStructs( EveSpaceObjectVSData & vsData, EveSpaceObjectPSData & psData ) const; + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + void GetModelCenterWorldPosition( Vector3 & position ) const; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + void GetLocalToWorldTransform( Matrix & transform ) const; // IWorldPosition virtual Vector3 GetWorldPosition(); virtual Quaternion GetWorldRotation(); - + // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); - + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); + /** * @brief Gets the audio emitter for this object. * @return Smart pointer to the emitter, or null if not initialized */ - ITr2AudEmitterPtr GetAudioEmitter() const { return m_audioEmitter; } + ITr2AudEmitterPtr GetAudioEmitter() const + { + return m_audioEmitter; + } /** * @brief Sets the name of this object's audio emitter. @@ -99,7 +102,6 @@ BLUE_CLASS( AudioGameObject ): void UpdateWorldTransform( Be::Time time ); protected: - ITriVectorFunctionPtr m_ballPosition; ITriQuaternionFunctionPtr m_ballRotation; bool m_display; diff --git a/trinity/Eve/AudioGameObject_Blue.cpp b/trinity/Eve/AudioGameObject_Blue.cpp index cf9ad4f1c..0698f9da1 100644 --- a/trinity/Eve/AudioGameObject_Blue.cpp +++ b/trinity/Eve/AudioGameObject_Blue.cpp @@ -7,84 +7,66 @@ BLUE_DEFINE( AudioGameObject ); const Be::ClassInfo* AudioGameObject::ExposeToBlue() { - EXPOSURE_BEGIN( AudioGameObject, "Standalone audio object for 3D positioning without being attached to assets." ) + EXPOSURE_BEGIN( AudioGameObject, "Standalone audio object for 3D positioning without being attached to assets." ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( IWorldPosition ) MAP_INTERFACE( ITr2DebugRenderable ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "Name of the audio object", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "mute", - m_mute, + m_mute, "Mute state of the audio emitter", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "rotation", m_rotation, "Local rotation of the object", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "translation", m_translation, "Local translation of the object", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "translationCurve", m_ballPosition, "Function for animated position updates", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "rotationCurve", m_ballRotation, "Function for animated rotation updates", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "Not really used for audio objects, but here for consistency with the EveSpaceObject interface", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "externalParameters", m_externalParameters, "List of external parameters to bind to object elements", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "audioEmitter", m_audioEmitter, "Exposure of the audio emitter object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "GetAudioEmitter", GetAudioEmitter, "Gets the audio emitter for this object" ) @@ -92,7 +74,7 @@ const Be::ClassInfo* AudioGameObject::ExposeToBlue() MAP_METHOD_AND_WRAP( "PlayAudioEvent", PlayAudioEvent, "Plays an audio event on this object's emitter" ) - MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initialize the audio emitter after construction/deserialization" ) + MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initialize the audio emitter after construction/deserialization" ) - EXPOSURE_END(); + EXPOSURE_END(); } \ No newline at end of file diff --git a/trinity/Eve/EveCamera.cpp b/trinity/Eve/EveCamera.cpp index d0d38d76f..63e1f260d 100644 --- a/trinity/Eve/EveCamera.cpp +++ b/trinity/Eve/EveCamera.cpp @@ -21,60 +21,60 @@ static inline float CutoffYawPitch( float value, float speed ) return value; } -EveCamera::EveCamera(IRoot* lockobj) : - m_friction ( 7.0f ), - m_maxSpeed ( 0.05f ), - m_zoomKey ( 0 ), - m_zoomTime ( 0.0f ), - - m_fieldOfView ( defFOV ), - m_frontClip ( 10.0f ), - m_backClip ( 10000000.0f ), +EveCamera::EveCamera( IRoot* lockobj ) : + m_friction( 7.0f ), + m_maxSpeed( 0.05f ), + m_zoomKey( 0 ), + m_zoomTime( 0.0f ), + + m_fieldOfView( defFOV ), + m_frontClip( 10.0f ), + m_backClip( 10000000.0f ), // if TRI_PIBY2 is used everything gets borken at the top :-( ?!?! - m_minPitch ( -1.4f ), - m_maxPitch ( 1.4f ), - m_minYaw ( 0.0f ), - m_maxYaw ( 0.0f ), - - m_noise ( false), - m_noiseScale (1.0f), - m_noiseDamp (1.1f), - - m_idleMove ( false ), - m_idleScale ( 2.0f ), - m_idleSpeed ( 0.8f ), - - m_yawInt (0.0f), - m_pitchInt (0.0f), - m_yawIntSpeed (0.0f), - m_pitchIntSpeed (0.0f), - - m_idleTheta ( 0.0f ), - m_trackInterest ( false ), - m_NoiseyN ( 0.0f ), - m_NoisexN ( 0.0f ), - m_maxNoise ( 80.0f ), - - m_yaw ( 0.0f ), - m_pitch ( 0.0f ), - m_yawSpeed ( 0.0f ), - m_pitchSpeed ( 0.0f ), - m_time ( 0 ), - m_start(0), - - m_projectionCenterOffset(0.0f), + m_minPitch( -1.4f ), + m_maxPitch( 1.4f ), + m_minYaw( 0.0f ), + m_maxYaw( 0.0f ), + + m_noise( false ), + m_noiseScale( 1.0f ), + m_noiseDamp( 1.1f ), + + m_idleMove( false ), + m_idleScale( 2.0f ), + m_idleSpeed( 0.8f ), + + m_yawInt( 0.0f ), + m_pitchInt( 0.0f ), + m_yawIntSpeed( 0.0f ), + m_pitchIntSpeed( 0.0f ), + + m_idleTheta( 0.0f ), + m_trackInterest( false ), + m_NoiseyN( 0.0f ), + m_NoisexN( 0.0f ), + m_maxNoise( 80.0f ), + + m_yaw( 0.0f ), + m_pitch( 0.0f ), + m_yawSpeed( 0.0f ), + m_pitchSpeed( 0.0f ), + m_time( 0 ), + m_start( 0 ), + + m_projectionCenterOffset( 0.0f ), m_rotationAroundParent( 0.f, 0.f, 0.f, 1.f ), m_rotationOfInterest( 0.f, 0.f, 0.f, 1.f ), - m_translationFromParent(0, 0, 20.0f), + m_translationFromParent( 0, 0, 20.0f ), - m_pos(0, 0, 0), - m_intr(0, 0, 0), - m_viewVec(0, 0, 0), - m_rightVec(0, 0, 0), - m_upVec(0, 0, 0), - m_alignment(0, 1, 0), + m_pos( 0, 0, 0 ), + m_intr( 0, 0, 0 ), + m_viewVec( 0, 0, 0 ), + m_rightVec( 0, 0, 0 ), + m_upVec( 0, 0, 0 ), + m_alignment( 0, 1, 0 ), - m_extraParentTranslation(0, 0, 0), + m_extraParentTranslation( 0, 0, 0 ), m_useExtraParentTranslation( false ), m_update( true ), @@ -84,10 +84,10 @@ EveCamera::EveCamera(IRoot* lockobj) : Tr2CurveScalarPtr zoomCurve; zoomCurve.CreateInstance(); - zoomCurve->AddKey( 0.0f, defFOV, Tr2CurveInterpolation::HERMITE, 0.0f,-11.0f, Tr2CurveTangentType::FREE_SPLIT ); - zoomCurve->AddKey( 0.225f, 0.8f, Tr2CurveInterpolation::HERMITE, 0.0f, -9.0f, Tr2CurveTangentType::FREE_SPLIT ); - zoomCurve->AddKey( 0.45f, 0.1f, Tr2CurveInterpolation::HERMITE, 0.0f, 20.0f, Tr2CurveTangentType::FREE_SPLIT ); - zoomCurve->AddKey( 0.675f, defFOV, Tr2CurveInterpolation::HERMITE, 0.0f, 0.0f, Tr2CurveTangentType::FREE_SPLIT ); + zoomCurve->AddKey( 0.0f, defFOV, Tr2CurveInterpolation::HERMITE, 0.0f, -11.0f, Tr2CurveTangentType::FREE_SPLIT ); + zoomCurve->AddKey( 0.225f, 0.8f, Tr2CurveInterpolation::HERMITE, 0.0f, -9.0f, Tr2CurveTangentType::FREE_SPLIT ); + zoomCurve->AddKey( 0.45f, 0.1f, Tr2CurveInterpolation::HERMITE, 0.0f, 20.0f, Tr2CurveTangentType::FREE_SPLIT ); + zoomCurve->AddKey( 0.675f, defFOV, Tr2CurveInterpolation::HERMITE, 0.0f, 0.0f, Tr2CurveTangentType::FREE_SPLIT ); m_zoomCurve = zoomCurve; @@ -101,34 +101,34 @@ EveCamera::~EveCamera() } -void EveCamera::OrbitParent(float horizontal, float vertical) +void EveCamera::OrbitParent( float horizontal, float vertical ) { //Accumulates Yaw and Pitch angles float oldYaw = m_yawSpeed; float oldPitch = m_pitchSpeed; - m_yawSpeed += m_maxSpeed*horizontal; - m_pitchSpeed -= m_maxSpeed*vertical; + m_yawSpeed += m_maxSpeed * horizontal; + m_pitchSpeed -= m_maxSpeed * vertical; // Pitch is clamped, but the speed variable is allowed to go way beyond limits // when going above or below thresholds, but if on the way back, assume it // was exactly at the threshold. This is to have consistent spring responsiveness - if(m_pitchSpeed > m_maxPitch && m_pitchSpeed - oldPitch < 0.0f) + if( m_pitchSpeed > m_maxPitch && m_pitchSpeed - oldPitch < 0.0f ) m_pitchSpeed = m_maxPitch; - else if(m_pitchSpeed < m_minPitch && oldPitch-m_pitchSpeed < 0.0f) + else if( m_pitchSpeed < m_minPitch && oldPitch - m_pitchSpeed < 0.0f ) m_pitchSpeed = m_minPitch; - if(m_minYaw != m_maxYaw){ + if( m_minYaw != m_maxYaw ) + { // Yaw limits specified, so clamp yaw as well - if(m_yawSpeed > m_maxYaw && m_yawSpeed - oldYaw < 0.0f) + if( m_yawSpeed > m_maxYaw && m_yawSpeed - oldYaw < 0.0f ) m_yawSpeed = m_maxYaw; - else if(m_yawSpeed < m_minYaw && oldYaw-m_yawSpeed < 0.0f) + else if( m_yawSpeed < m_minYaw && oldYaw - m_yawSpeed < 0.0f ) m_yawSpeed = m_minYaw; } - } -void EveCamera::SetOrbit(float yaw, float pitch) +void EveCamera::SetOrbit( float yaw, float pitch ) { m_yaw = yaw; m_pitch = pitch; @@ -136,11 +136,11 @@ void EveCamera::SetOrbit(float yaw, float pitch) m_yawSpeed = m_yaw; m_pitchSpeed = m_pitch; - m_yawSpeed = fmodf(m_yawSpeed,TRI_2PI); - m_yaw = fmodf(m_yaw,TRI_2PI); + m_yawSpeed = fmodf( m_yawSpeed, TRI_2PI ); + m_yaw = fmodf( m_yaw, TRI_2PI ); } -void EveCamera::SetRotationOnOrbit(float yaw, float pitch) +void EveCamera::SetRotationOnOrbit( float yaw, float pitch ) { m_yawInt = yaw; m_pitchInt = pitch; @@ -151,36 +151,37 @@ void EveCamera::SetRotationOnOrbit(float yaw, float pitch) m_rotationOfInterest = RotationQuaternion( m_yawInt, m_pitchInt, 0.0f ); } -void EveCamera::RotateOnOrbit(float horizontal, float vertical) +void EveCamera::RotateOnOrbit( float horizontal, float vertical ) { //Accumulates Yaw and Pitch angles float oldYaw = m_yawIntSpeed; float oldPitch = m_pitchIntSpeed; - m_yawIntSpeed += m_maxSpeed*horizontal; - m_pitchIntSpeed -= m_maxSpeed*vertical; + m_yawIntSpeed += m_maxSpeed * horizontal; + m_pitchIntSpeed -= m_maxSpeed * vertical; // Pitch is clamped, but the speed variable is allowed to go way beyond limits // when going above or below thresholds, but if on the way back, assume it // was exactly at the threshold. This is to have consistent spring responsiveness - if(m_pitchIntSpeed > m_maxPitch && m_pitchIntSpeed - oldPitch < 0.0f) + if( m_pitchIntSpeed > m_maxPitch && m_pitchIntSpeed - oldPitch < 0.0f ) m_pitchIntSpeed = m_maxPitch; - else if(m_pitchIntSpeed < m_minPitch && oldPitch-m_pitchIntSpeed < 0.0f) + else if( m_pitchIntSpeed < m_minPitch && oldPitch - m_pitchIntSpeed < 0.0f ) m_pitchIntSpeed = m_minPitch; - if(m_minYaw != m_maxYaw){ + if( m_minYaw != m_maxYaw ) + { // Yaw limits specified, so clamp yaw as well - if(m_yawIntSpeed > m_maxYaw && m_yawIntSpeed - oldYaw < 0.0f) + if( m_yawIntSpeed > m_maxYaw && m_yawIntSpeed - oldYaw < 0.0f ) m_yawIntSpeed = m_maxYaw; - else if(m_yawIntSpeed < m_minYaw && oldYaw-m_yawIntSpeed < 0.0f) + else if( m_yawIntSpeed < m_minYaw && oldYaw - m_yawIntSpeed < 0.0f ) m_yawIntSpeed = m_minYaw; } - + m_rotationOfInterest = RotationQuaternion( m_yawInt, m_pitchInt, 0.0f ); } -void EveCamera::Dolly(float factor) +void EveCamera::Dolly( float factor ) { m_translationFromParent.z += factor; } @@ -193,18 +194,18 @@ void EveCamera::Zoom( Be::OptionalWithDefaultValue key ) { size = ssize_t( curve->GetKeys().size() ); } - if (size < 1) + if( size < 1 ) { CCP_LOGERR( "Tried to zoom but the camera had no keys on zoomCurve" ); return; } - if (key != -1) + if( key != -1 ) m_zoomKey = key; else m_zoomKey++; - if(m_zoomKey >= ( size - 1) ) - m_zoomKey = 0; + if( m_zoomKey >= ( size - 1 ) ) + m_zoomKey = 0; if( Tr2CurveScalarPtr curve = BlueCastPtr( m_zoomCurve ) ) { @@ -222,15 +223,14 @@ const TriProjectionPtr EveCamera::GetProjection() return m_projectionMatrix; } -const Vector3* EveCamera::GetPosition( - ) +const Vector3* EveCamera::GetPosition() { return &m_pos; } void EveCamera::Update( Be::Time t ) -{ - if(!m_update) +{ + if( !m_update ) return; bool failed = false; @@ -240,33 +240,35 @@ void EveCamera::Update( Be::Time t ) } // 'dT' is the time span since this function was last called - float dT = float(TimeAsDouble(BeOS->GetInfo()->mRealTime - m_time)); + float dT = float( TimeAsDouble( BeOS->GetInfo()->mRealTime - m_time ) ); m_time = BeOS->GetInfo()->mRealTime; - Vector3 parentPosition(0, 0, 0); - if (m_parentTranslationCurve) + Vector3 parentPosition( 0, 0, 0 ); + if( m_parentTranslationCurve ) { - m_parentTranslationCurve->GetValueAt(&parentPosition, t); + m_parentTranslationCurve->GetValueAt( &parentPosition, t ); } - if (m_useExtraParentTranslation) + if( m_useExtraParentTranslation ) { parentPosition += m_extraParentTranslation; } // Limit camera translation by parent bounding radius - if ( m_translationFromParent.z < max(1.f, m_frontClip) ) + if( m_translationFromParent.z < max( 1.f, m_frontClip ) ) { - m_translationFromParent.z = max(1.f, m_frontClip); + m_translationFromParent.z = max( 1.f, m_frontClip ); } - if ( !IsFinite( m_translationFromParent ) ) + if( !IsFinite( m_translationFromParent ) ) { if( !m_failedLastFrame ) { - CCP_LOGERR( "EveCamera: m_translationFromParent not finite(%f, %f, %f). Setting to safe value.", - m_translationFromParent.x, m_translationFromParent.y, m_translationFromParent.z ); + CCP_LOGERR( "EveCamera: m_translationFromParent not finite(%f, %f, %f). Setting to safe value.", + m_translationFromParent.x, + m_translationFromParent.y, + m_translationFromParent.z ); } - m_translationFromParent = Vector3(0, 0, 1); + m_translationFromParent = Vector3( 0, 0, 1 ); failed = true; } @@ -285,17 +287,17 @@ void EveCamera::Update( Be::Time t ) } // Cap the pitch input at twich the max(to keep some pressure) - m_yaw = (m_yaw + m_friction * dT * m_yawSpeed) / (1.0f + m_friction * dT); + m_yaw = ( m_yaw + m_friction * dT * m_yawSpeed ) / ( 1.0f + m_friction * dT ); m_yaw = CutoffYawPitch( m_yaw, m_yawSpeed ); - m_pitch = (m_pitch + m_friction * dT * m_pitchSpeed)/(1.0f + m_friction * dT); + m_pitch = ( m_pitch + m_friction * dT * m_pitchSpeed ) / ( 1.0f + m_friction * dT ); m_pitch = CutoffYawPitch( m_pitch, m_pitchSpeed ); - + CapPitchAndYaw(); // Find absolute camera position m_rotationAroundParent = RotationQuaternion( m_yaw, m_pitch, 0.0f ); Vector3 vecCamPos; - TriVectorRotateQuaternion(&vecCamPos, &m_translationFromParent, &m_rotationAroundParent); + TriVectorRotateQuaternion( &vecCamPos, &m_translationFromParent, &m_rotationAroundParent ); vecCamPos += parentPosition; @@ -303,32 +305,32 @@ void EveCamera::Update( Be::Time t ) //////////////////////////////////////////////////////////////////////// // Calculate perputal idle motion //////////////////////////////////////////////////////////////////////// - + // Use the 'Eight' curve m_idleTheta += dT * m_idleSpeed; - if(m_idleTheta > TRI_2PI) + if( m_idleTheta > TRI_2PI ) { - m_idleTheta = fmodf(m_idleTheta, TRI_2PI); + m_idleTheta = fmodf( m_idleTheta, TRI_2PI ); } - float idleYaw=0.0f,idlePitch=0.0f; - if(m_idleMove) + float idleYaw = 0.0f, idlePitch = 0.0f; + if( m_idleMove ) { - idleYaw = m_idleScale * cosf(m_idleTheta); - idlePitch = 1.2f * idleYaw * sinf(m_idleTheta); + idleYaw = m_idleScale * cosf( m_idleTheta ); + idlePitch = 1.2f * idleYaw * sinf( m_idleTheta ); } - if(m_noiseCurve) + if( m_noiseCurve ) { - m_noise = m_noiseCurve->Update(TimeAsDouble(t - m_start)) > 0.0f; + m_noise = m_noiseCurve->Update( TimeAsDouble( t - m_start ) ) > 0.0f; } else { m_noise = false; } - if(m_noise) + if( m_noise ) { - if(m_noiseScaleCurve) + if( m_noiseScaleCurve ) { float noiseScale = m_noiseScaleCurve->Update( TimeAsDouble( t - m_start ) ); if( IsFinite( noiseScale ) ) @@ -340,7 +342,7 @@ void EveCamera::Update( Be::Time t ) CCP_LOGERR( "EveCamera: Got non-finite noise scale." ); } } - if(m_noiseDampCurve) + if( m_noiseDampCurve ) { float noiseDamp = m_noiseDampCurve->Update( TimeAsDouble( t - m_start ) ); if( IsFinite( noiseDamp ) ) @@ -353,22 +355,22 @@ void EveCamera::Update( Be::Time t ) } } float ran = TriRand() - 0.5f; - m_NoisexN = (m_NoisexN + m_noiseDamp*ran)/(1.0f + m_noiseDamp*dT); + m_NoisexN = ( m_NoisexN + m_noiseDamp * ran ) / ( 1.0f + m_noiseDamp * dT ); m_NoisexN = TriClamp( m_NoisexN, -m_maxNoise, m_maxNoise ); - ran = TriRand()-0.5f; - m_NoiseyN = (m_NoiseyN + m_noiseDamp*ran)/(1.0f + m_noiseDamp*dT); + ran = TriRand() - 0.5f; + m_NoiseyN = ( m_NoiseyN + m_noiseDamp * ran ) / ( 1.0f + m_noiseDamp * dT ); m_NoiseyN = TriClamp( m_NoiseyN, -m_maxNoise, m_maxNoise ); idleYaw += m_noiseScale * m_NoisexN; idlePitch += m_noiseScale * m_NoiseyN; } - + // Find the interest point of the camera (probably the ship) - Vector3 vecCamIntr(parentPosition); + Vector3 vecCamIntr( parentPosition ); Vector3 toInterest = vecCamIntr - vecCamPos; Vector3 side; - Vector3 up = Vector3(0.0f,1.0f,0.0f); - + Vector3 up = Vector3( 0.0f, 1.0f, 0.0f ); + toInterest = Normalize( toInterest ); //draw a line through the interest, 100 meters long Vector3 extendedInterest = toInterest * 100.0f; @@ -388,18 +390,18 @@ void EveCamera::Update( Be::Time t ) /////////////////////////////////////////////////////////////////////// // And Finally animate the rotation around the 'other' interest if present //////////////////////////////////////////////////////////////////////// - m_yawInt = (m_yawInt + m_friction*dT*m_yawIntSpeed)/(1.0f + m_friction*dT); + m_yawInt = ( m_yawInt + m_friction * dT * m_yawIntSpeed ) / ( 1.0f + m_friction * dT ); m_yawInt = CutoffYawPitch( m_yawInt, m_yawIntSpeed ); - m_pitchInt = (m_pitchInt + m_friction*dT*m_pitchIntSpeed)/(1.0f + m_friction*dT); + m_pitchInt = ( m_pitchInt + m_friction * dT * m_pitchIntSpeed ) / ( 1.0f + m_friction * dT ); m_pitchInt = CutoffYawPitch( m_pitchInt, m_pitchIntSpeed ); // check if we are tracking an interest, in which // case determine its yaw and pitch and make that the target - if(m_trackInterest && m_interestTranslationCurve) + if( m_trackInterest && m_interestTranslationCurve ) { Vector3 aPos; - m_interestTranslationCurve->GetValueAt(&aPos, t); - float aYaw,aPitch,r; + m_interestTranslationCurve->GetValueAt( &aPos, t ); + float aYaw, aPitch, r; aPos = aPos - vecCamPos; Vector3 tPos; @@ -407,32 +409,33 @@ void EveCamera::Update( Be::Time t ) tPos.y = Dot( aPos, up ); tPos.z = Dot( aPos, toInterest ); r = Length( tPos ); - if(r>0.0f) - aPitch = asinf(tPos.y/r); + if( r > 0.0f ) + aPitch = asinf( tPos.y / r ); else aPitch = 0.0f; - aYaw = atan2f(tPos.x,tPos.z); + aYaw = atan2f( tPos.x, tPos.z ); m_yawIntSpeed = -aYaw; m_pitchIntSpeed = aPitch; - } - else if(m_rotationOfInterest.x == 0.0f && m_rotationOfInterest.y == 0.0f && m_rotationOfInterest.z == 0.0f && m_rotationOfInterest.w == 1.0f) + } + else if( m_rotationOfInterest.x == 0.0f && m_rotationOfInterest.y == 0.0f && m_rotationOfInterest.z == 0.0f && m_rotationOfInterest.w == 1.0f ) { m_yawIntSpeed = m_pitchIntSpeed = 0.0f; } - + // Cap both yat and pitch - if(m_pitchInt > m_maxPitch) + if( m_pitchInt > m_maxPitch ) m_pitchInt = m_maxPitch; - else if (m_pitchInt < m_minPitch) + else if( m_pitchInt < m_minPitch ) m_pitchInt = m_minPitch; - if(m_minYaw != m_maxYaw){ - if(m_yawInt > m_maxYaw) + if( m_minYaw != m_maxYaw ) + { + if( m_yawInt > m_maxYaw ) m_yawInt = m_maxYaw; - else if (m_yaw < m_minYaw) + else if( m_yaw < m_minYaw ) m_yawInt = m_minYaw; } @@ -440,8 +443,8 @@ void EveCamera::Update( Be::Time t ) //////////////////////////////////////////////////////////////////////// // Set up the camera at the calculated position and with the calculated interest - //////////////////////////////////////////////////////////////////////// - + //////////////////////////////////////////////////////////////////////// + // We transform the m_alignment direction to avoid having to worry about the view direction // and the alignemnt being parallel Vector3 realUpDir; @@ -452,9 +455,14 @@ void EveCamera::Update( Be::Time t ) { if( !m_failedLastFrame ) { - CCP_LOGERR( "EveCamera: Invalid up direction (%f, %f, %f), rotation (%f, %f, %f, %f)", - realUpDir.x, realUpDir.y, realUpDir.z, - m_rotationAroundParent.x, m_rotationAroundParent.y, m_rotationAroundParent.z, m_rotationAroundParent.w); + CCP_LOGERR( "EveCamera: Invalid up direction (%f, %f, %f), rotation (%f, %f, %f, %f)", + realUpDir.x, + realUpDir.y, + realUpDir.z, + m_rotationAroundParent.x, + m_rotationAroundParent.y, + m_rotationAroundParent.z, + m_rotationAroundParent.w ); } realUpDir = Vector3( 0, 1, 0 ); failed = true; @@ -466,7 +474,9 @@ void EveCamera::Update( Be::Time t ) if( !m_failedLastFrame ) { CCP_LOGERR( "EveCamera: Camera position and camera interest identical(%f, %f, %f).", - vecCamPos.x, vecCamPos.y, vecCamPos.z ); + vecCamPos.x, + vecCamPos.y, + vecCamPos.z ); } vecCamPos += m_translationFromParent; failed = true; @@ -476,22 +486,25 @@ void EveCamera::Update( Be::Time t ) if( !m_failedLastFrame ) { CCP_LOGERR( "EveCamera: Camera interest(%f, %f, %f) and/or position(%f, %f, %f) invalid.", - vecCamIntr.x, vecCamIntr.y, vecCamIntr.z, - vecCamPos.x, vecCamPos.y, vecCamPos.z); + vecCamIntr.x, + vecCamIntr.y, + vecCamIntr.z, + vecCamPos.x, + vecCamPos.y, + vecCamPos.z ); } - vecCamIntr = Vector3(0, 0, 0); + vecCamIntr = Vector3( 0, 0, 0 ); vecCamPos = m_translationFromParent; failed = true; } - + Matrix viewTransform, viewTransformInt; viewTransform = LookAtMatrix( vecCamPos, vecCamIntr, realUpDir ); // now rotate toward other interest Quaternion tmpResult = Inverse( m_rotationOfInterest ); TriMatrixRotate( &viewTransformInt, &viewTransform, &tmpResult ); - CalculateProjectionMatrix( &m_projectionTransform, gTriDev->AspectRatio(), m_fieldOfView, - m_projectionCenterOffset, 0, m_frontClip, m_backClip, m_projectionMatrix ); + CalculateProjectionMatrix( &m_projectionTransform, gTriDev->AspectRatio(), m_fieldOfView, m_projectionCenterOffset, 0, m_frontClip, m_backClip, m_projectionMatrix ); // update cached attribs @@ -500,10 +513,10 @@ void EveCamera::Update( Be::Time t ) m_viewVec = Vector3( viewTransformInt._13, viewTransformInt._23, viewTransformInt._33 ); m_upVec = Vector3( viewTransformInt._12, viewTransformInt._22, viewTransformInt._32 ); m_rightVec = Vector3( viewTransformInt._11, viewTransformInt._21, viewTransformInt._31 ); - + if( Length( m_viewVec ) && Length( m_upVec ) && Length( m_rightVec ) ) { - m_viewMatrix->SetTransform(viewTransformInt); + m_viewMatrix->SetTransform( viewTransformInt ); } else { @@ -516,8 +529,8 @@ void EveCamera::Update( Be::Time t ) m_viewVec = Vector3( viewTransform._13, viewTransform._23, viewTransform._33 ); m_upVec = Vector3( viewTransform._12, viewTransform._22, viewTransform._32 ); m_rightVec = Vector3( viewTransform._11, viewTransform._21, viewTransform._31 ); - - m_viewMatrix->SetTransform(viewTransform); + + m_viewMatrix->SetTransform( viewTransform ); } if( m_audio2Listener ) @@ -533,42 +546,42 @@ void EveCamera::Update( Be::Time t ) bool EveCamera::OnModified( - Be::Var* value - ) + Be::Var* value ) { if( IsMatch( value, m_rotationAroundParent ) ) - { + { float unused; - TriQuaternionToYawPitchRoll(&m_yaw, &m_pitch, &unused, &m_rotationAroundParent); - } + TriQuaternionToYawPitchRoll( &m_yaw, &m_pitch, &unused, &m_rotationAroundParent ); + } else if( IsMatch( value, m_interestTranslationCurve ) ) { - if( m_interestTranslationCurve && (m_interestTranslationCurve != m_parentTranslationCurve)) + if( m_interestTranslationCurve && ( m_interestTranslationCurve != m_parentTranslationCurve ) ) { m_trackInterest = true; } else - { + { m_trackInterest = false; m_yawIntSpeed = 0.0f; m_pitchIntSpeed = 0.0f; } - } + } return true; } void EveCamera::CapPitchAndYaw() { - if(m_pitch > m_maxPitch) + if( m_pitch > m_maxPitch ) m_pitch = m_maxPitch; - else if (m_pitch < m_minPitch) + else if( m_pitch < m_minPitch ) m_pitch = m_minPitch; - if(m_minYaw != m_maxYaw){ - if(m_yaw > m_maxYaw) + if( m_minYaw != m_maxYaw ) + { + if( m_yaw > m_maxYaw ) m_yaw = m_maxYaw; - else if (m_yaw < m_minYaw) + else if( m_yaw < m_minYaw ) m_yaw = m_minYaw; } } @@ -601,11 +614,11 @@ void EveCamera::CalculateProjectionMatrix( Matrix* mat, float aspectRatio, float // TriProjection itself rather than transmogrifying the matrix here. float dX = aspectRatio * front * tan( fov / 2 ); float dY = front * tan( fov / 2 ); - + if( aspectRatio > 1.6f ) { - // The field of view in x is now too warped so we switch things around and - // adjust the matrix so that the fov in x doesn't go beyond what it would be + // The field of view in x is now too warped so we switch things around and + // adjust the matrix so that the fov in x doesn't go beyond what it would be // at a 1.6 aspect ratio. Note that 1920/1200 = 1.6. float adjustment = aspectRatio / 1.6f; dX /= adjustment; @@ -619,7 +632,7 @@ void EveCamera::CalculateProjectionMatrix( Matrix* mat, float aspectRatio, float if( projection ) { - // TODO: as per comment at the top here. Should call something like + // TODO: as per comment at the top here. Should call something like // projection->OffCenterAspectAdjust(left, right, -dy, dy, front, back, aspectClamp(1.6 in this case)) projection->CustomProjection( (Matrix)*mat ); } @@ -638,7 +651,7 @@ void EveCamera::CalculateProjectionMatrix( Matrix* mat, float aspectRatio, float // ------------------------------------------------------------- float EveCamera::CalculateFovFromProjection( const Matrix& mat ) { - float aspectRatio = ( mat._11 ? mat._22 / mat._11 : 0.0f); + float aspectRatio = ( mat._11 ? mat._22 / mat._11 : 0.0f ); float aspectAdjustment = 1.0f; if( aspectRatio > 1.6f ) { diff --git a/trinity/Eve/EveCamera.h b/trinity/Eve/EveCamera.h index 12e1fdb65..2ca7881d8 100644 --- a/trinity/Eve/EveCamera.h +++ b/trinity/Eve/EveCamera.h @@ -4,7 +4,7 @@ #define _EVECAMERA_H_ #define EVECAMERA_Description \ -"EveCamera defines a target camera, what is position and interest. There have \r\n\ + "EveCamera defines a target camera, what is position and interest. There have \r\n\ been some requests for a free camera, position and orientation but that kind of \r\n\ camera behaviour will probably be handled by a separate object. EveCamera \r\n\ exposes m_pos m_intr m_viewVec which are updated every Render. This is done \r\n\ @@ -19,8 +19,7 @@ BLUE_DECLARE( TriView ); BLUE_DECLARE_INTERFACE( ITriVectorFunction ); BLUE_DECLARE_INTERFACE( ITriScalarFunction ); -class EveCamera: - public INotify +class EveCamera : public INotify { public: static void CalculateProjectionMatrix( Matrix* mat, float aspectRatio, float fov, float offsetX, float offsetY, float front, float back, TriProjection* triProjection ); @@ -33,8 +32,8 @@ class EveCamera: EXPOSE_TO_BLUE(); - EveCamera(IRoot* lockobj = NULL); - ~EveCamera(); + EveCamera( IRoot* lockobj = NULL ); + ~EveCamera(); ///////////////////////////////////////////////////////////////////////////////////// void OrbitParent( float horizontal, float vertical ); @@ -63,10 +62,10 @@ class EveCamera: ITriVectorFunctionPtr m_parentTranslationCurve; ITriVectorFunctionPtr m_interestTranslationCurve; IBluePlacementObserverPtr m_audio2Listener; - + Vector3 m_translationFromParent; Quaternion m_rotationAroundParent; - Quaternion m_rotationOfInterest; + Quaternion m_rotationOfInterest; Vector3 m_alignment; Vector3 m_extraParentTranslation; @@ -140,7 +139,6 @@ class EveCamera: IBlueEventListenerPtr m_errorListener; bool m_failedLastFrame; }; -TYPEDEF_BLUECLASS(EveCamera); +TYPEDEF_BLUECLASS( EveCamera ); #endif - diff --git a/trinity/Eve/EveCamera_Blue.cpp b/trinity/Eve/EveCamera_Blue.cpp index 70ad41add..6db45156f 100644 --- a/trinity/Eve/EveCamera_Blue.cpp +++ b/trinity/Eve/EveCamera_Blue.cpp @@ -6,338 +6,272 @@ BLUE_DEFINE( EveCamera ); const Be::ClassInfo* EveCamera::ExposeToBlue() -{ - EXPOSURE_BEGIN(EveCamera, "") - MAP_INTERFACE(EveCamera) - MAP_INTERFACE(INotify) +{ + EXPOSURE_BEGIN( EveCamera, "" ) + MAP_INTERFACE( EveCamera ) + MAP_INTERFACE( INotify ) //////////////////////////////////////////////////////////////////////////// // parent - MAP_ATTRIBUTE - ( - "parent", - m_parentTranslationCurve, - "na", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "audio2Listener", + MAP_ATTRIBUTE( + "parent", + m_parentTranslationCurve, + "na", + Be::READWRITE ) + + MAP_ATTRIBUTE( + "audio2Listener", m_audio2Listener, - "Audio2 listener", - Be::READWRITE - ) + "Audio2 listener", + Be::READWRITE ) //////////////////////////////////////////////////////////////////////////// // translationFromParent - MAP_ATTRIBUTE - ( - "translationFromParent", - m_translationFromParent.z, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "translationFromParent", + m_translationFromParent.z, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // rotationAroundParent - MAP_ATTRIBUTE - ( - "rotationAroundParent", - m_rotationAroundParent, - "na", - Be::READWRITE |Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "rotationAroundParent", + m_rotationAroundParent, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // interest - MAP_ATTRIBUTE - ( - "interest", - m_interestTranslationCurve, - "na", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "interest", + m_interestTranslationCurve, + "na", + Be::READWRITE | Be::NOTIFY ) //////////////////////////////////////////////////////////////////////////// // rotationOfInterest - MAP_ATTRIBUTE - ( - "rotationOfInterest", - m_rotationOfInterest, - "na", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "rotationOfInterest", + m_rotationOfInterest, + "na", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) //////////////////////////////////////////////////////////////////////////// // minPitch - MAP_ATTRIBUTE - ( - "minPitch", - m_minPitch, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "minPitch", + m_minPitch, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // maxPitch - MAP_ATTRIBUTE - ( - "maxPitch", - m_maxPitch, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "maxPitch", + m_maxPitch, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // minYaw - MAP_ATTRIBUTE - ( - "minYaw", - m_minYaw, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "minYaw", + m_minYaw, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // maxYaw - MAP_ATTRIBUTE - ( - "maxYaw", - m_maxYaw, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "maxYaw", + m_maxYaw, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // alignment - MAP_ATTRIBUTE - ( - "alignment", - m_alignment, - "This is the base up vector for the view transform", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "alignment", + m_alignment, + "This is the base up vector for the view transform", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // fieldOfView - MAP_ATTRIBUTE - ( - "fieldOfView", - m_fieldOfView, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "fieldOfView", + m_fieldOfView, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // frontClip - MAP_ATTRIBUTE - ( - "frontClip", - m_frontClip, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "frontClip", + m_frontClip, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // backClip - MAP_ATTRIBUTE - ( - "backClip", - m_backClip, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "backClip", + m_backClip, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // friction - MAP_ATTRIBUTE - ( - "friction", - m_friction, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "friction", + m_friction, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Idle movement on or off - MAP_ATTRIBUTE - ( - "idleMove", - m_idleMove, - "Whether camera should rock gently while idle", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "idleMove", + m_idleMove, + "Whether camera should rock gently while idle", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Amplitude of idle hover - MAP_ATTRIBUTE - ( - "idleScale", - m_idleScale, - "The amplitude of the idle movement", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "idleScale", + m_idleScale, + "The amplitude of the idle movement", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Speed of idle move - MAP_ATTRIBUTE - ( - "idleSpeed", - m_idleSpeed, - "How fast is the movement", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "idleSpeed", + m_idleSpeed, + "How fast is the movement", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // camera noise on/off - MAP_ATTRIBUTE - ( - "noise", - m_noise, - "Camera noise on off", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "noise", + m_noise, + "Camera noise on off", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Amplitude of camera noise - MAP_ATTRIBUTE - ( - "noiseScale", - m_noiseScale, - "Amplitude of camera noise", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "noiseScale", + m_noiseScale, + "Amplitude of camera noise", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Damping of noise - MAP_ATTRIBUTE - ( - "noiseDamp", - m_noiseDamp, - "How spastic is your noise", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "noiseDamp", + m_noiseDamp, + "How spastic is your noise", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // noiseCurve - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "noiseCurve", m_noiseCurve, "na", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // noiseScaleCurve - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "noiseScaleCurve", m_noiseScaleCurve, "na", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // noiseDampCurve - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "noiseDampCurve", m_noiseDampCurve, "na", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // maxSpeed - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxSpeed", m_maxSpeed, "na", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // update - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "update", m_update, "na", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // pos - MAP_ATTRIBUTE - ( - "pos", - m_pos, - "na", - Be::READ | Be::PERSIST - ) + MAP_ATTRIBUTE( + "pos", + m_pos, + "na", + Be::READ | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // intr - MAP_ATTRIBUTE - ( - "intr", - m_intr, - "na", - Be::READ | Be::PERSIST - ) + MAP_ATTRIBUTE( + "intr", + m_intr, + "na", + Be::READ | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // viewVec - MAP_ATTRIBUTE - ( - "viewVec", - m_viewVec, - "na", - Be::READ - ) + MAP_ATTRIBUTE( + "viewVec", + m_viewVec, + "na", + Be::READ ) //////////////////////////////////////////////////////////////////////////// // rightVec - MAP_ATTRIBUTE - ( - "rightVec", - m_rightVec, - "na", - Be::READ - ) + MAP_ATTRIBUTE( + "rightVec", + m_rightVec, + "na", + Be::READ ) //////////////////////////////////////////////////////////////////////////// // upVec - MAP_ATTRIBUTE - ( - "upVec", + MAP_ATTRIBUTE( + "upVec", m_upVec, - "na", - Be::READ - ) + "na", + Be::READ ) //////////////////////////////////////////////////////////////////////////// // zoomCurve - MAP_ATTRIBUTE - ( - "zoomCurve", - m_zoomCurve, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "zoomCurve", + m_zoomCurve, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // camera plane shift - MAP_ATTRIBUTE - ( - "centerOffset", - m_projectionCenterOffset, + MAP_ATTRIBUTE( + "centerOffset", + m_projectionCenterOffset, "Camera's center offset", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "extraTranslation", m_extraParentTranslation, "Extra offset from lookat target(parent)", Be::READWRITE ); @@ -345,73 +279,63 @@ const Be::ClassInfo* EveCamera::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // the camera's current pitch and yaw - MAP_ATTRIBUTE - ( - "pitch", - m_pitch, + MAP_ATTRIBUTE( + "pitch", + m_pitch, "Camera's current pitch", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "yaw", - m_yaw, - "Camera's current yaw", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "yaw", + m_yaw, + "Camera's current yaw", + Be::READ | Be::PERSIST ) // Handler for doing error reporting/raising MAP_ATTRIBUTE( "errorHandler", m_errorListener, "A listener that gets called if look at target is invalid", Be::READWRITE ); - MAP_METHOD_AND_WRAP( - "SetRotationOnOrbit", - SetRotationOnOrbit, + MAP_METHOD_AND_WRAP( + "SetRotationOnOrbit", + SetRotationOnOrbit, "Sets the rotation away from the parent look-at direction in terms of yaw and pitch\n" ":param yaw: yaw in radians\n" ":param pitch: pitch in radians" ) - MAP_METHOD_AND_WRAP( - "SetOrbit", - SetOrbit, + MAP_METHOD_AND_WRAP( + "SetOrbit", + SetOrbit, "Sets the orbit around parent in terms of yaw and pitch\n" ":param yaw: yaw in radians\n" ":param pitch: pitch in radians" ) - MAP_ATTRIBUTE - ( - "projectionMatrix", - m_projectionMatrix, - "TriProjection representing the camera's current projection", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( - "viewMatrix", - m_viewMatrix, - "TriView representing the camera's current view matrix", - Be::READ - ) - - MAP_METHOD_AND_WRAP( - "OrbitParent", - OrbitParent, + MAP_ATTRIBUTE( + "projectionMatrix", + m_projectionMatrix, + "TriProjection representing the camera's current projection", + Be::READWRITE ) + MAP_ATTRIBUTE( + "viewMatrix", + m_viewMatrix, + "TriView representing the camera's current view matrix", + Be::READ ) + + MAP_METHOD_AND_WRAP( + "OrbitParent", + OrbitParent, ":param horizontal: \n" - ":param vertical: \n" - ) - MAP_METHOD_AND_WRAP( - "RotateOnOrbit", - RotateOnOrbit, + ":param vertical: \n" ) + MAP_METHOD_AND_WRAP( + "RotateOnOrbit", + RotateOnOrbit, ":param horizontal: \n" - ":param vertical: \n" - ) - MAP_METHOD_AND_WRAP( - "Dolly", - Dolly, + ":param vertical: \n" ) + MAP_METHOD_AND_WRAP( + "Dolly", + Dolly, ":param factor: " ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "Zoom", - Zoom, - 1, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "Zoom", + Zoom, + 1, ":param key: \n" ) MAP_METHOD_AND_WRAP( diff --git a/trinity/Eve/EveComponentRegistry.cpp b/trinity/Eve/EveComponentRegistry.cpp index bb9e61926..541e3841e 100644 --- a/trinity/Eve/EveComponentRegistry.cpp +++ b/trinity/Eve/EveComponentRegistry.cpp @@ -80,7 +80,7 @@ void EveComponentRegistry::UnRegister( EveEntity* entity ) m_registeredEntities.pop_back(); entity->m_registry = nullptr; - entity->m_indexInRegistry = - 1; + entity->m_indexInRegistry = -1; } // UnRegisters all components for a specific entity @@ -161,4 +161,3 @@ std::vector> EveComponentRegistry::GetComponentIn return info; } - diff --git a/trinity/Eve/EveComponentRegistry.h b/trinity/Eve/EveComponentRegistry.h index ed540b378..96d2ba68c 100644 --- a/trinity/Eve/EveComponentRegistry.h +++ b/trinity/Eve/EveComponentRegistry.h @@ -26,12 +26,12 @@ inline const char* GetComponentName() static_assert( workAroundForCppStandard::value, "Type being used as a component which hasn't been registered via REGISTER_COMPONENT_TYPE" ); } -#define REGISTER_COMPONENT_TYPE( name, componentType ) \ - \ - template <> \ - inline const char* GetComponentName() \ - { \ - return name; \ +#define REGISTER_COMPONENT_TYPE( name, componentType ) \ + \ + template <> \ + inline const char* GetComponentName() \ + { \ + return name; \ }; class IEveComponentCollection @@ -80,14 +80,14 @@ BLUE_CLASS( EveComponentRegistry ) : // Registers a specific components for a specific entity, creates a component collection if it doesn´t exist template - void RegisterComponent( EveEntity* entity ); + void RegisterComponent( EveEntity * entity ); // UnRegisters a single component for a specific entity template - void UnRegisterComponent( EveEntity* entity ); + void UnRegisterComponent( EveEntity * entity ); // UnRegisters all components for a specific entity - void UnRegisterAllComponents( EveEntity* entity ); + void UnRegisterAllComponents( EveEntity * entity ); void Clear(); @@ -102,24 +102,24 @@ BLUE_CLASS( EveComponentRegistry ) : template void ProcessComponentsUntil( R processor ) const; - template - const std::vector& GetComponents(); + template + const std::vector& GetComponents(); - template + template size_t ComponentCount() const; - void Register( EveEntity* entity ); - void UnRegister( EveEntity* entity ); - void ReRegister( EveEntity* entity ); + void Register( EveEntity * entity ); + void UnRegister( EveEntity * entity ); + void ReRegister( EveEntity * entity ); private: IEveComponentCollection* GetComponentCollection( const char* componentName ) const; - void AddToCollection( IEveComponentCollection* collection, EveEntity* entity ); - void RemoveFromCollection( IEveComponentCollection* collection, EveEntity* entity ); + void AddToCollection( IEveComponentCollection * collection, EveEntity * entity ); + void RemoveFromCollection( IEveComponentCollection * collection, EveEntity * entity ); void RemoveCollectionFromEntityState( IEveComponentCollection * collection, EveEntity * entity ); - template + template IEveComponentCollection* AddCollection( const char* componentName ); std::vector> GetComponentInfo() const; @@ -151,7 +151,7 @@ bool EveComponentCollection::Add( EveEntity* entity, uint32_t* index ) { if( T* component = dynamic_cast( entity ) ) { - *index = (uint32_t) m_collection.size(); + *index = (uint32_t)m_collection.size(); m_collection.push_back( component ); return true; } @@ -323,7 +323,7 @@ size_t EveComponentRegistry::ComponentCount() const template IEveComponentCollection* EveComponentRegistry::AddCollection( const char* componentName ) { - int32_t componentCollectionIndex = (int32_t) m_componentCollections.size(); + int32_t componentCollectionIndex = (int32_t)m_componentCollections.size(); // no more than 32 EveComponentCollections can exist, since we use a bitwise comparison in the entity m_state CCP_ASSERT( componentCollectionIndex < 32 ); diff --git a/trinity/Eve/EveDistanceField.cpp b/trinity/Eve/EveDistanceField.cpp index 5512236e5..5ac198926 100644 --- a/trinity/Eve/EveDistanceField.cpp +++ b/trinity/Eve/EveDistanceField.cpp @@ -33,23 +33,23 @@ EveDistanceField::EveDistanceField( IRoot* lockobj ) : float EveDistanceField::CalculateFieldCoverageAndDistance( Be::Time t, const Vector3& posRef, const Vector3& originShift ) { Vector3 minBounds( FLT_MAX, FLT_MAX, FLT_MAX ); - Vector3 maxBounds( -FLT_MAX, -FLT_MAX, -FLT_MAX); + Vector3 maxBounds( -FLT_MAX, -FLT_MAX, -FLT_MAX ); Vector3 averagePos( 0, 0, 0 ); Vector3 posObj; float distanceNowSq = m_maxDistance * m_maxDistance; - + if( m_objects.empty() ) { m_middle += originShift; return Length( posRef ); } - + const float oneOverCount = 1.f / (float)m_objects.size(); // Calculate bounds and center for( auto oit = m_objects.begin(); oit != m_objects.end(); ++oit ) { - (*oit)->GetValueAt( &posObj, t ); + ( *oit )->GetValueAt( &posObj, t ); averagePos += posObj * oneOverCount; posObj = posObj - posRef; distanceNowSq = std::min( distanceNowSq, LengthSq( posObj ) ); @@ -61,7 +61,7 @@ float EveDistanceField::CalculateFieldCoverageAndDistance( Be::Time t, const Vec float averageDistance = 0; for( auto oit = m_objects.begin(); oit != m_objects.end(); ++oit ) { - (*oit)->GetValueAt( &posObj, t ); + ( *oit )->GetValueAt( &posObj, t ); posObj = posObj - averagePos; averageDistance += Length( posObj ) * oneOverCount; } @@ -69,7 +69,7 @@ float EveDistanceField::CalculateFieldCoverageAndDistance( Be::Time t, const Vec // Calculate bounding box for objects close enough to the average position for( auto oit = m_objects.begin(); oit != m_objects.end(); ++oit ) { - (*oit)->GetValueAt( &posObj, t ); + ( *oit )->GetValueAt( &posObj, t ); const Vector3 d = posObj - averagePos; float distance = Length( d ); if( m_distanceThreshold == 0.f || distance <= m_distanceThreshold * averageDistance ) @@ -101,7 +101,7 @@ float EveDistanceField::CalculateFieldCoverageAndDistance( Be::Time t, const Vec { m_middle += originShift; } - + return std::sqrt( distanceNowSq ); } @@ -115,7 +115,7 @@ void EveDistanceField::Update( const EveUpdateContext& updateContext ) posRef = m_cameraView->GetTransform().GetTranslation(); } Be::Time t = updateContext.GetTime(); - + if( m_updateDistanceCurve ) { UpdateDistanceCurveSize(); @@ -132,7 +132,7 @@ void EveDistanceField::Update( const EveUpdateContext& updateContext ) distanceNow = CalculateFieldCoverageAndDistance( t, posRef, originShift ); } else - { + { if( m_objects.size() == 1 ) { m_objects[0]->GetValueAt( &m_middle, t ); @@ -141,7 +141,7 @@ void EveDistanceField::Update( const EveUpdateContext& updateContext ) { m_middle += originShift; } - + Vector3 posObj = m_middle - posRef; distanceNow = std::min( distanceNow, Length( posObj ) ); } @@ -173,7 +173,7 @@ void EveDistanceField::Update( const EveUpdateContext& updateContext ) for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { Vector3 position; - (*it)->GetValueAt( &position, t ); + ( *it )->GetValueAt( &position, t ); m_debugPositions.push_back( position ); } m_debug = false; @@ -205,7 +205,7 @@ void EveDistanceField::CreateCurveSet() m_distanceCurve->AddKey( 50000.0f, 0, Tr2CurveInterpolation::LINEAR, 0, 0, Tr2CurveTangentType::AUTO ); m_distanceCurve->SetTimeOffset( 0 ); - m_curveSet->AddCurve( ( ITriFunctionPtr ) m_distanceCurve ); + m_curveSet->AddCurve( (ITriFunctionPtr)m_distanceCurve ); } void EveDistanceField::SetupStaticDistanceField( Vector3 dimensions, Vector3 position, float distanceThreshold, float timeAdjustmentSecondsOut, float timeAdjustmentSecondsIn ) @@ -255,8 +255,7 @@ void EveDistanceField::OnListModified( ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ) + const IList* theList ) { if( theList != &m_objects ) { @@ -283,8 +282,8 @@ void EveDistanceField::OnListModified( // -------------------------------------------------------------------------------------- bool EveDistanceField::OnModified( Be::Var* value ) { - - if( IsMatch( value, m_maxDistance ) || + + if( IsMatch( value, m_maxDistance ) || IsMatch( value, m_minDistance ) ) { m_updateDistanceCurve = true; @@ -327,5 +326,3 @@ void EveDistanceField::RenderDebugInfo( ITr2DebugRenderer2& renderer ) renderer.DrawSphere( this, pos, m_maxDistance, 8, Tr2DebugRenderer::Wireframe, 0x1f1f1f1f ); } } - - diff --git a/trinity/Eve/EveDistanceField.h b/trinity/Eve/EveDistanceField.h index e455f0f80..d00b77465 100644 --- a/trinity/Eve/EveDistanceField.h +++ b/trinity/Eve/EveDistanceField.h @@ -18,7 +18,7 @@ BLUE_DECLARE( Tr2CurveScalar ); // Keeps track of a number of objects, max camera distance from them and estimates // a simple volume the covers the objects. // -------------------------------------------------------------------------------------- -BLUE_CLASS( EveDistanceField ): +BLUE_CLASS( EveDistanceField ) : public IListNotify, public INotify, public ITr2DebugRenderable @@ -31,22 +31,23 @@ BLUE_CLASS( EveDistanceField ): ///////////////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); - + ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); void Update( const EveUpdateContext& updateContext ); - + void SetupStaticDistanceField( Vector3 dimensions, Vector3 position, float distanceThreshold, float timeAdjustmentSecondsOut, float timeAdjustemntSecondsIn ); void SetupDynamicDistanceField( float distanceThreshold, float timeAdjustmentSecondsOut, float timeAdjustemntSecondsIn ); void SetMaxDistance( float maxDistnace ); + private: void CreateCurveSet(); void UpdateDistanceCurveSize(); @@ -92,11 +93,11 @@ BLUE_CLASS( EveDistanceField ): void SetNeutralValues(); float CalculateFieldCoverageAndDistance( Be::Time t, const Vector3& posRef, const Vector3& originShift ); - // members for debug purposes + // members for debug purposes bool m_debug; std::vector m_debugPositions; }; - + TYPEDEF_BLUECLASS( EveDistanceField ); #endif \ No newline at end of file diff --git a/trinity/Eve/EveDistanceField_Blue.cpp b/trinity/Eve/EveDistanceField_Blue.cpp index 2c48311d6..06a6adaa2 100644 --- a/trinity/Eve/EveDistanceField_Blue.cpp +++ b/trinity/Eve/EveDistanceField_Blue.cpp @@ -8,51 +8,49 @@ BLUE_DEFINE( EveDistanceField ); const Be::ClassInfo* EveDistanceField::ExposeToBlue() { EXPOSURE_BEGIN( EveDistanceField, "" ) - MAP_INTERFACE( EveDistanceField ) + MAP_INTERFACE( EveDistanceField ) MAP_INTERFACE( IListNotify ) MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "cameraView", m_cameraView, "na", Be::READWRITE ) - MAP_ATTRIBUTE( "objects", m_objects, "na", Be::READ | Be::NOTIFY ) + MAP_ATTRIBUTE( "objects", m_objects, "na", Be::READ | Be::NOTIFY ) MAP_ATTRIBUTE( "curveSet", m_curveSet, "na", Be::READWRITE ) MAP_ATTRIBUTE( "distance", m_distance, "na", Be::READWRITE ) - - MAP_ATTRIBUTE( "timeAdjustmentSecondsOut", - m_timeAdjustmentSecondsOut, - "Adjust how long it takes to settle on a new value when zooming out", - Be::READWRITE ) - MAP_ATTRIBUTE( "timeAdjustmentSecondsIn", - m_timeAdjustmentSecondsIn, - "Adjust how long it takes to settle on a new value when zooming in", - Be::READWRITE ) + + MAP_ATTRIBUTE( "timeAdjustmentSecondsOut", + m_timeAdjustmentSecondsOut, + "Adjust how long it takes to settle on a new value when zooming out", + Be::READWRITE ) + MAP_ATTRIBUTE( "timeAdjustmentSecondsIn", + m_timeAdjustmentSecondsIn, + "Adjust how long it takes to settle on a new value when zooming in", + Be::READWRITE ) MAP_ATTRIBUTE( "dimensions", m_dimensions, "", Be::READ ); MAP_ATTRIBUTE( "midpoint", m_middle, "", Be::READ ); MAP_ATTRIBUTE( "distanceThreshold", m_distanceThreshold, "", Be::READWRITE ); MAP_ATTRIBUTE( "maxXZRatio", m_maxXZRatio, "", Be::READWRITE ); MAP_ATTRIBUTE( "minYRatio", m_minYRatio, "", Be::READWRITE ); - + MAP_ATTRIBUTE( "minDistance", m_minDistance, "The threshold distance from an object in the field where you are 100% inside the environment", Be::READWRITE | Be::NOTIFY ); MAP_ATTRIBUTE( "maxDistance", m_maxDistance, "The threshold distance from an object in the field where you are outside the environment", Be::READWRITE | Be::NOTIFY ); - - MAP_METHOD_AND_WRAP( - "SetupDynamicDistanceField", - SetupDynamicDistanceField, + + MAP_METHOD_AND_WRAP( + "SetupDynamicDistanceField", + SetupDynamicDistanceField, "Sets up the distance field as a dynamic distance field\n" ":param threshold: distance threshold\n" ":param timeOut: time adjustment seconds out\n" - ":param timeIn: time adjustment seconds in\n" - ) - MAP_METHOD_AND_WRAP( - "SetupStaticDistanceField", - SetupStaticDistanceField, + ":param timeIn: time adjustment seconds in\n" ) + MAP_METHOD_AND_WRAP( + "SetupStaticDistanceField", + SetupStaticDistanceField, "Sets up the distance field as a static distance field\n" ":param dimensions: field size\n" ":param position: field position\n" ":param threshold: distance threshold\n" ":param timeOut: time adjustment seconds out\n" - ":param timeIn: time adjustment seconds in\n" - ) + ":param timeIn: time adjustment seconds in\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/EveEffectRoot2.cpp b/trinity/Eve/EveEffectRoot2.cpp index 1d02b8dc0..b37c60d85 100644 --- a/trinity/Eve/EveEffectRoot2.cpp +++ b/trinity/Eve/EveEffectRoot2.cpp @@ -143,11 +143,11 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo { for( ssize_t i = 0; i < list->GetSize(); ++i ) { - if( EveEntityPtr entity = BlueCastPtr( list->GetAt(i) ) ) + if( EveEntityPtr entity = BlueCastPtr( list->GetAt( i ) ) ) { entity->UnRegister( GetComponentRegistry() ); } - } + } } default: break; @@ -176,7 +176,7 @@ void EveEffectRoot2::OnListModified( long event, ssize_t key, ssize_t key2, IRoo } void EveEffectRoot2::UpdateSyncronous( const EveUpdateContext& updateContext ) -{ +{ CCP_STATS_ZONE( __FUNCTION__ ); UpdateWorldTransform( updateContext.GetTime() ); @@ -187,7 +187,7 @@ void EveEffectRoot2::UpdateSyncronous( const EveUpdateContext& updateContext ) for( TriObserverLocalVector::iterator it = m_observers.begin(); it != m_observers.end(); ++it ) { - (*it)->Update( m_lastUpdateMatrix ); + ( *it )->Update( m_lastUpdateMatrix ); } if( !m_effectChildren.empty() ) @@ -209,8 +209,8 @@ void EveEffectRoot2::UpdateSyncronous( const EveUpdateContext& updateContext ) } } -void EveEffectRoot2::UpdateAsyncronous( const EveUpdateContext& updateContext ) -{ +void EveEffectRoot2::UpdateAsyncronous( const EveUpdateContext& updateContext ) +{ float controllerUpdateFrequency = 0.f; if( m_display ) @@ -234,7 +234,7 @@ void EveEffectRoot2::UpdateAsyncronous( const EveUpdateContext& updateContext ) Be::Time time = updateContext.GetTime(); for( auto it = m_curveSets.begin(); it != m_curveSets.end(); it++ ) { - (*it)->Update( time, time ); + ( *it )->Update( time, time ); } if( !m_effectChildren.empty() ) @@ -269,7 +269,7 @@ void EveEffectRoot2::UpdateVisibility( const EveUpdateContext& updateContext, co Vector4 boundingSphere; GetBoundingSphere( boundingSphere ); BoundingSphereTransform( m_worldTransform, boundingSphere ); - + if( updateContext.GetFrustum().IsSphereVisible( &boundingSphere ) ) { m_estimatedSize = updateContext.GetFrustum().GetPixelSizeAccross( &boundingSphere ); @@ -289,14 +289,14 @@ void EveEffectRoot2::UpdateVisibility( const EveUpdateContext& updateContext, co m_changeLOD |= oldLod != m_lodLevel; } - + for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) { - (*ecIt)->UpdateVisibility( updateContext, parentTransform, m_lodLevel ); + ( *ecIt )->UpdateVisibility( updateContext, parentTransform, m_lodLevel ); } } -void EveEffectRoot2::GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) +void EveEffectRoot2::GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) { if( !m_display ) { @@ -307,36 +307,36 @@ void EveEffectRoot2::GetRenderables( std::vector& renderables, { m_changeLOD = false; - for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) + for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) { - (*ecIt)->ChangeLOD( m_lodLevel ); + ( *ecIt )->ChangeLOD( m_lodLevel ); } } for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) { - (*ecIt)->GetRenderables( renderables ); + ( *ecIt )->GetRenderables( renderables ); } } void EveEffectRoot2::UpdateControllers( float updateFrequency ) { - for ( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { ( *it )->Update( updateFrequency ); } } bool EveEffectRoot2::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const -{ +{ sphere = m_boundingSphere; return true; }; void EveEffectRoot2::UpdateWorldTransform( Be::Time time ) -{ +{ Quaternion rotation; Vector3 translation; @@ -358,7 +358,7 @@ void EveEffectRoot2::UpdateWorldTransform( Be::Time time ) rotation = Quaternion( 0.0f, 0.0f, 0.0f, 1.0f ); } - + if( m_modelRotation ) { Quaternion modelRotation; @@ -367,7 +367,7 @@ void EveEffectRoot2::UpdateWorldTransform( Be::Time time ) } m_worldTransform = RotationMatrix( rotation ) * TranslationMatrix( translation ); - + if( m_modelTranslation ) { Vector3 modelTranslation; @@ -378,7 +378,7 @@ void EveEffectRoot2::UpdateWorldTransform( Be::Time time ) } -void EveEffectRoot2::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void EveEffectRoot2::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { // This version of the function should perform an update on the model / ball position Matrix currentTransform; @@ -389,20 +389,20 @@ void EveEffectRoot2::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time position = TransformCoord( m_boundingSphere.GetXYZ(), currentTransform ); } -void EveEffectRoot2::GetModelCenterWorldPosition( Vector3 &position ) const +void EveEffectRoot2::GetModelCenterWorldPosition( Vector3& position ) const { // This version of the function does not perform an update on the object position = TransformCoord( m_boundingSphere.GetXYZ(), m_lastUpdateMatrix ); } -bool EveEffectRoot2::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) +bool EveEffectRoot2::GetLocalBoundingBox( Vector3& min, Vector3& max ) { // If possible, return an AABB in local coordinates return false; } -void EveEffectRoot2::GetLocalToWorldTransform( Matrix &transform ) const +void EveEffectRoot2::GetLocalToWorldTransform( Matrix& transform ) const { // Get the local to world transform transform = m_lastUpdateMatrix; @@ -418,7 +418,7 @@ void EveEffectRoot2::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) void EveEffectRoot2::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) { - if (!m_display ) + if( !m_display ) { return; } @@ -436,8 +436,9 @@ void EveEffectRoot2::GetLights( Tr2LightManager& lightManager ) const } XMMATRIX worldTransform = m_lastUpdateMatrix; - float scaling = XMVectorGetX( XMVectorAdd( XMVector3LengthEst( m_lastUpdateMatrix.GetX() ), - XMVectorAdd( XMVector3LengthEst( m_lastUpdateMatrix.GetY() ), XMVector3LengthEst( m_lastUpdateMatrix.GetZ() ) ) ) ) / 3.f; + float scaling = XMVectorGetX( XMVectorAdd( XMVector3LengthEst( m_lastUpdateMatrix.GetX() ), + XMVectorAdd( XMVector3LengthEst( m_lastUpdateMatrix.GetY() ), XMVector3LengthEst( m_lastUpdateMatrix.GetZ() ) ) ) ) / + 3.f; for( auto it = std::begin( m_lights ); it != std::end( m_lights ); ++it ) { ( *it )->AddLight( lightManager, worldTransform, scaling ); @@ -479,10 +480,10 @@ void EveEffectRoot2::GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpace void EveEffectRoot2::RegisterSecondaryLightSource( Tr2ShLightingManager& manager ) { static const Color s_noAlbedoColor( 0.f, 0.f, 0.f, 0.f ); - manager.RegisterSecondaryLightSource( - &m_worldTransform.GetTranslation(), - &m_secondaryLightingSphereRadiusWorld, - &s_noAlbedoColor, + manager.RegisterSecondaryLightSource( + &m_worldTransform.GetTranslation(), + &m_secondaryLightingSphereRadiusWorld, + &s_noAlbedoColor, &m_secondaryLightingEmissiveColor ); } @@ -492,12 +493,12 @@ void EveEffectRoot2::UnregisterSecondaryLightSource( Tr2ShLightingManager& manag } -void EveEffectRoot2::RegisterComponents( ) +void EveEffectRoot2::RegisterComponents() { auto registry = GetComponentRegistry(); if( registry && m_display ) { - if ( !m_lights.empty() ) + if( !m_lights.empty() ) { registry->RegisterComponent( this ); } @@ -508,10 +509,10 @@ void EveEffectRoot2::RegisterComponents( ) entity->Register( registry ); } } - } + } } -void EveEffectRoot2::UnRegisterComponents( ) +void EveEffectRoot2::UnRegisterComponents() { auto registry = GetComponentRegistry(); if( registry ) @@ -608,7 +609,7 @@ int EveEffectRoot2::GetClosestDamageLocatorIndex( const Vector3* position ) return 0; } -int EveEffectRoot2::GetGoodDamageLocatorIndex( const Vector3 &position ) +int EveEffectRoot2::GetGoodDamageLocatorIndex( const Vector3& position ) { return 0; } @@ -651,13 +652,13 @@ Quaternion EveEffectRoot2::GetWorldRotation() void EveEffectRoot2::GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ) { - GetDamageLocatorPosition(out, -1, true ); - - if( hit && source ) + GetDamageLocatorPosition( out, -1, true ); + + if( hit && source ) { Vector3 local( *hit - *out ); Vector3 dir = Normalize( *hit - *source ); - + local -= dir * Dot( dir, local ); local = Normalize( local ); @@ -668,8 +669,8 @@ void EveEffectRoot2::GetMissPosition( const Vector3* hit, const Vector3* source, // ----------------------------------------------------------------------------- PIEveSpaceObjectChildVector& EveEffectRoot2::GetChildren() -{ - return m_effectChildren; +{ + return m_effectChildren; } // ----------------------------------------------------------------------------- @@ -791,7 +792,7 @@ void EveEffectRoot2::GetDebugOptions( Tr2DebugRendererOptions& options ) options.insert( "Bounding Sphere" ); options.insert( "Lights" ); - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->GetDebugOptions( options ); } @@ -808,7 +809,7 @@ void EveEffectRoot2::GetDebugOptions( Tr2DebugRendererOptions& options ) // ----------------------------------------------------------------------------- void EveEffectRoot2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if (renderer.HasOption( GetRawRoot(), "Bounding Sphere" )) + if( renderer.HasOption( GetRawRoot(), "Bounding Sphere" ) ) { renderer.DrawSphere( this, m_boundingSphere.GetXYZ(), GetBoundingSphereRadius(), 8, Tr2DebugRenderer::Wireframe, 0xffff00ff ); } @@ -829,7 +830,7 @@ void EveEffectRoot2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) } } - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->RenderDebugInfo( renderer ); } @@ -928,9 +929,9 @@ void EveEffectRoot2::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) void EveEffectRoot2::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - for ( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) + for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - IEveSpaceObjectChild *child = *it; + IEveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } @@ -952,7 +953,7 @@ ITr2AudEmitterPtr EveEffectRoot2::FindSoundEmitter( const char* name ) if( auto owner = dynamic_cast( *it ) ) { auto emitter = owner->FindSoundEmitter( name ); - if ( emitter != nullptr ) + if( emitter != nullptr ) { return emitter; } @@ -981,17 +982,17 @@ void EveEffectRoot2::SetMute( bool isMute ) void EveEffectRoot2::FreezeHighDetailMesh() { m_lodLevel = TR2_LOD_HIGH; - for (auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt) + for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) { - (*ecIt)->ChangeLOD(m_lodLevel); + ( *ecIt )->ChangeLOD( m_lodLevel ); } } -void EveEffectRoot2::SetProceduralContainerVariable( const char *name, float value ) +void EveEffectRoot2::SetProceduralContainerVariable( const char* name, float value ) { - for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); it++ ) - { - auto child = *it; - child->SetProceduralContainerVariable( name, value ); - } + for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); it++ ) + { + auto child = *it; + child->SetProceduralContainerVariable( name, value ); + } } \ No newline at end of file diff --git a/trinity/Eve/EveEffectRoot2.h b/trinity/Eve/EveEffectRoot2.h index 97c0a5d76..2f49183c5 100644 --- a/trinity/Eve/EveEffectRoot2.h +++ b/trinity/Eve/EveEffectRoot2.h @@ -34,7 +34,7 @@ BLUE_DECLARE_VECTOR( Tr2ExternalParameter ); BLUE_DECLARE( EveEffectRoot2 ); -BLUE_CLASS( EveEffectRoot2 ): +BLUE_CLASS( EveEffectRoot2 ) : public IWorldPosition, public IEveSpaceObject2, public IInitialize, @@ -53,13 +53,13 @@ BLUE_CLASS( EveEffectRoot2 ): { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using IEveSpaceObject2::Lock; using IEveSpaceObject2::Unlock; EveEffectRoot2( IRoot* lockobj = NULL ); - ~EveEffectRoot2( ); - + ~EveEffectRoot2(); + ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); @@ -67,31 +67,31 @@ BLUE_CLASS( EveEffectRoot2 ): ////////////////////////////////////////////////////////////////////////////////////// // IListNotify virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); - + ////////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* val ); + virtual bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const; - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - void GetModelCenterWorldPosition( Vector3 &position ) const; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - void GetLocalToWorldTransform( Matrix &transform ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void GetPerObjectStructs( EveSpaceObjectVSData & vsData, EveSpaceObjectPSData & psData ) const; + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + void GetModelCenterWorldPosition( Vector3 & position ) const; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + void GetLocalToWorldTransform( Matrix & transform ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); - void SetProceduralContainerVariable( const char *name, float value ) override; + void SetProceduralContainerVariable( const char* name, float value ) override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; - void AddLight( Tr2Light* light ) override; + void GetLights( Tr2LightManager & lightManager ) const override; + void AddLight( Tr2Light * light ) override; void ClearLights() override; ////////////////////////////////////////////////////////////////////////////////////// @@ -101,21 +101,21 @@ BLUE_CLASS( EveEffectRoot2 ): ////////////////////////////////////////////////////////////////////////////////////// // EveEntity - void RegisterComponents( ); - void UnRegisterComponents( ); - + void RegisterComponents(); + void UnRegisterComponents(); + ////////////////////////////////////////////////////////////////////////////////////// // ITriTargetable unsigned int GetDamageLocatorCount() const; int GetClosestDamageLocatorIndex( const Vector3* position ); - bool GetDamageLocatorPosition( Vector3* out, int index, bool inWorldSpace ); - bool GetDamageLocatorDirection( Vector3* out, int index, bool inWorldSpace ); + bool GetDamageLocatorPosition( Vector3 * out, int index, bool inWorldSpace ); + bool GetDamageLocatorDirection( Vector3 * out, int index, bool inWorldSpace ); void GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ); int GetGoodDamageLocatorIndex( const Vector3& position ); float GetRadius() const; int CreateImpact( int damageLocatorIndex, const Vector3& direction, float lifeTime, float size ); - bool UpdateImpact( Vector3& out, const Vector3& direction, int impactIndex ); - bool GetImpactPosition( Vector3& out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); + bool UpdateImpact( Vector3 & out, const Vector3& direction, int impactIndex ); + bool GetImpactPosition( Vector3 & out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); bool HasImpactConfigurationShield() const; @@ -135,14 +135,14 @@ BLUE_CLASS( EveEffectRoot2 ): ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -185,15 +185,18 @@ BLUE_CLASS( EveEffectRoot2 ): // Lods bool m_dynamicLODSelection; bool m_changeLOD; - + PTr2LightVector m_lights; PITr2ControllerVector m_controllers; std::vector> m_controllerVariables; - float GetBoundingSphereRadius() { return m_boundingSphere.w; } + float GetBoundingSphereRadius() + { + return m_boundingSphere.w; + } float m_estimatedSize; float m_effectDuration; - + IBlueEventListenerPtr m_loadedEventListener; protected: @@ -206,10 +209,10 @@ BLUE_CLASS( EveEffectRoot2 ): Vector3 m_scaling; Quaternion m_rotation; Vector3 m_translation; - + ITriVectorFunctionPtr m_ballPosition; ITriQuaternionFunctionPtr m_ballRotation; - + PTriCurveSetVector m_curveSets; // last known results from updating m_ballPosition and m_ballRotation @@ -222,7 +225,6 @@ BLUE_CLASS( EveEffectRoot2 ): // Current LOD level Tr2Lod m_lodLevel; - }; TYPEDEF_BLUECLASS( EveEffectRoot2 ); diff --git a/trinity/Eve/EveEffectRoot2_Blue.cpp b/trinity/Eve/EveEffectRoot2_Blue.cpp index 31605e349..f15a86690 100644 --- a/trinity/Eve/EveEffectRoot2_Blue.cpp +++ b/trinity/Eve/EveEffectRoot2_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( EveEffectRoot2 ); const Be::ClassInfo* EveEffectRoot2::ExposeToBlue() { - EXPOSURE_BEGIN( EveEffectRoot2, "" ) + EXPOSURE_BEGIN( EveEffectRoot2, "" ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -16,90 +16,71 @@ const Be::ClassInfo* EveEffectRoot2::ExposeToBlue() MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IEveEffectChildrenOwner ) MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE ( IShaderConfigurer ) + MAP_INTERFACE( IShaderConfigurer ) MAP_INTERFACE( ITr2SoundEmitterOwner ) MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( IWorldPosition ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - - MAP_ATTRIBUTE( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "mute", - m_mute, + m_mute, "", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) + - - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "estimatedSize", m_estimatedSize, "", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "lodLevel", m_lodLevel, "", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "dynamicLOD", m_dynamicLODSelection, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translationCurve", m_ballPosition, "Vector function slot for attaching a destiny ball to set the position of an object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "rotationCurve", m_ballRotation, "Quaternion function slot for attaching a destiny ball to set the rotation of an object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "modelTranslationCurve", m_modelTranslation, "Used to add animated translations to ships", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "modelRotationCurve", m_modelRotation, "Used to add rotations to the basic rotation curve", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) #if BLUE_WITH_PYTHON // expose bounding sphere as two variables: center pos and radius @@ -112,22 +93,18 @@ const Be::ClassInfo* EveEffectRoot2::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "duration", m_effectDuration, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE - ( + + MAP_ATTRIBUTE( "effectChildren", m_effectChildren, "", - Be::READ | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "observers", - m_observers, + Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( + "observers", + m_observers, "Observers for pushing data between modules every frame. Currently used to push locator data out to the audio2 module.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, "Returns the bounding sphere radius." ) @@ -139,65 +116,59 @@ const Be::ClassInfo* EveEffectRoot2::ExposeToBlue() MAP_ATTRIBUTE( "controllers", m_controllers, "List of object controllers", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "secondaryLightingSphereRadius", - m_secondaryLightingSphereRadiusLocal, - "Radius of secondary light source", + MAP_ATTRIBUTE( + "secondaryLightingSphereRadius", + m_secondaryLightingSphereRadiusLocal, + "Radius of secondary light source", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "secondaryLightingEmissiveColor", - m_secondaryLightingEmissiveColor, - "Color of the secondary light source", + MAP_ATTRIBUTE( + "secondaryLightingEmissiveColor", + m_secondaryLightingEmissiveColor, + "Color of the secondary light source", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "Start", - Start, + MAP_METHOD_AND_WRAP( + "Start", + Start, "Play all top level curveSets\n" ":jessica-favorite:\n" ":jessica-icon: timeline/play.png" ) - MAP_METHOD_AND_WRAP( - "Stop", - Stop, - "Stop all top level curveSets.\n" + MAP_METHOD_AND_WRAP( + "Stop", + Stop, + "Stop all top level curveSets.\n" ":jessica-favorite:\n" ":jessica-icon: timeline/stop.png" ) - - MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, "Returns the bounding sphere radius." ) + + MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, "Returns the bounding sphere radius." ) MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) - MAP_METHOD_AND_WRAP - ( + "Start all controllers" ) + MAP_METHOD_AND_WRAP( "FreezeHighDetailMesh", FreezeHighDetailMesh, - "" - ) - - MAP_METHOD_AND_WRAP( - "SetProceduralContainerVariable", - SetProceduralContainerVariable, - "Set variable for all applicable ProceduralContainer\n" - ":param name: variable name\n" - ":param value: new variable value\n" - ) - - EXPOSURE_END(); + "" ) + + MAP_METHOD_AND_WRAP( + "SetProceduralContainerVariable", + SetProceduralContainerVariable, + "Set variable for all applicable ProceduralContainer\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) + + EXPOSURE_END(); } diff --git a/trinity/Eve/EveEntity.cpp b/trinity/Eve/EveEntity.cpp index 8a26837b5..7331f0733 100644 --- a/trinity/Eve/EveEntity.cpp +++ b/trinity/Eve/EveEntity.cpp @@ -10,34 +10,35 @@ extern int g_eveReflectionMode; namespace EntityComponents { - bool ShouldReflect( ReflectionMode mode ) +bool ShouldReflect( ReflectionMode mode ) +{ + if( g_eveReflectionMode == ReflectionSetting::REFLECTION_SETTING_OFF ) + { + return false; + } + + switch( mode ) { - if( g_eveReflectionMode == ReflectionSetting::REFLECTION_SETTING_OFF ) - { - return false; - } - - switch( mode ) - { - case REFLECT_NEVER: - return false; - case REFLECT_LOW_MEDIUM_HIGH: - return true; - case REFLECT_MEDIUM_AND_HIGH: - return g_eveReflectionMode != ReflectionSetting::REFLECTION_SETTING_LOW; // we have either medium, high or highest settings - case REFLECT_HIGH: - return g_eveReflectionMode == ReflectionSetting::REFLECTION_SETTING_HIGH || g_eveReflectionMode == REFLECTION_SETTING_ULTRA; - default: - return false; - } + case REFLECT_NEVER: + return false; + case REFLECT_LOW_MEDIUM_HIGH: + return true; + case REFLECT_MEDIUM_AND_HIGH: + return g_eveReflectionMode != ReflectionSetting::REFLECTION_SETTING_LOW; // we have either medium, high or highest settings + case REFLECT_HIGH: + return g_eveReflectionMode == ReflectionSetting::REFLECTION_SETTING_HIGH || g_eveReflectionMode == REFLECTION_SETTING_ULTRA; + default: + return false; } } +} EveEntity::EveEntity( IRoot* root ) : m_registry( nullptr ), m_componentIndexLookup( {} ), m_indexInRegistry( -1 ) -{} +{ +} EveEntity::~EveEntity() { @@ -108,21 +109,17 @@ EveComponentRegistry* EveEntity::GetComponentRegistry() const std::optional EveEntity::GetComponentIndex( uint32_t componentBit ) const { - auto index = std::find_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), - [componentBit]( const auto& pair ) - { - return pair.first == componentBit; + auto index = std::find_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), [componentBit]( const auto& pair ) { + return pair.first == componentBit; } ); - return index == m_componentIndexLookup.end() ? std::nullopt : std::make_optional(index->second); + return index == m_componentIndexLookup.end() ? std::nullopt : std::make_optional( index->second ); } void EveEntity::SetComponentState( uint32_t componentBit, uint32_t index ) { - auto componentIndex = std::find_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), - [componentBit]( const auto& pair ) - { - return pair.first == componentBit; + auto componentIndex = std::find_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), [componentBit]( const auto& pair ) { + return pair.first == componentBit; } ); if( componentIndex == m_componentIndexLookup.end() ) @@ -137,10 +134,8 @@ void EveEntity::SetComponentState( uint32_t componentBit, uint32_t index ) void EveEntity::RemoveComponentState( uint32_t componentBit ) { - auto removed = std::remove_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), - [componentBit]( const auto& pair ) - { - return pair.first == componentBit; + auto removed = std::remove_if( m_componentIndexLookup.begin(), m_componentIndexLookup.end(), [componentBit]( const auto& pair ) { + return pair.first == componentBit; } ); m_componentIndexLookup.erase( removed, m_componentIndexLookup.end() ); diff --git a/trinity/Eve/EveEntity.h b/trinity/Eve/EveEntity.h index b6947d806..6554f7c59 100644 --- a/trinity/Eve/EveEntity.h +++ b/trinity/Eve/EveEntity.h @@ -6,26 +6,26 @@ namespace EntityComponents { - enum ReflectionMode - { - REFLECT_HIGH, - REFLECT_MEDIUM_AND_HIGH, - REFLECT_LOW_MEDIUM_HIGH, - REFLECT_NEVER - }; - - enum ReflectionSetting - { - REFLECTION_SETTING_OFF, - REFLECTION_SETTING_LOW, - REFLECTION_SETTING_MEDIUM, - REFLECTION_SETTING_HIGH, - REFLECTION_SETTING_ULTRA, - }; - - bool ShouldReflect( ReflectionMode mode ); - - extern const Be::VarChooser ReflectionModeChooser[]; +enum ReflectionMode +{ + REFLECT_HIGH, + REFLECT_MEDIUM_AND_HIGH, + REFLECT_LOW_MEDIUM_HIGH, + REFLECT_NEVER +}; + +enum ReflectionSetting +{ + REFLECTION_SETTING_OFF, + REFLECTION_SETTING_LOW, + REFLECTION_SETTING_MEDIUM, + REFLECTION_SETTING_HIGH, + REFLECTION_SETTING_ULTRA, +}; + +bool ShouldReflect( ReflectionMode mode ); + +extern const Be::VarChooser ReflectionModeChooser[]; } BLUE_CLASS( EveEntity ) : @@ -37,8 +37,8 @@ BLUE_CLASS( EveEntity ) : EveEntity( IRoot* lockobj = NULL ); ~EveEntity(); - void Register( EveComponentRegistry* registry ); - void UnRegister( EveComponentRegistry* registry ); + void Register( EveComponentRegistry * registry ); + void UnRegister( EveComponentRegistry * registry ); bool IsInRegistry() const; diff --git a/trinity/Eve/EveEntity_Blue.cpp b/trinity/Eve/EveEntity_Blue.cpp index bb1c35a96..2f8e66675 100644 --- a/trinity/Eve/EveEntity_Blue.cpp +++ b/trinity/Eve/EveEntity_Blue.cpp @@ -7,15 +7,15 @@ BLUE_DEFINE( EveEntity ); namespace EntityComponents { - const Be::VarChooser ReflectionModeChooser[] = { - { "Never", BeCast( REFLECT_NEVER ), "Never render into the reflection map" }, - { "LowMediumAndHigh", BeCast( REFLECT_LOW_MEDIUM_HIGH ), "Render into the reflection map when reflection settings is set to low, medium or high" }, - { "MediumAndHigh", BeCast( REFLECT_MEDIUM_AND_HIGH ), "Render into the reflection map when reflection settings is set to medium or high" }, - { "High", BeCast( REFLECT_HIGH ), "Only render into the reflection map when reflection settings is set to high" }, - { 0 } - }; +const Be::VarChooser ReflectionModeChooser[] = { + { "Never", BeCast( REFLECT_NEVER ), "Never render into the reflection map" }, + { "LowMediumAndHigh", BeCast( REFLECT_LOW_MEDIUM_HIGH ), "Render into the reflection map when reflection settings is set to low, medium or high" }, + { "MediumAndHigh", BeCast( REFLECT_MEDIUM_AND_HIGH ), "Render into the reflection map when reflection settings is set to medium or high" }, + { "High", BeCast( REFLECT_HIGH ), "Only render into the reflection map when reflection settings is set to high" }, + { 0 } +}; - BLUE_REGISTER_ENUM_EX( "ReflectionModeType", ReflectionMode, ReflectionModeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +BLUE_REGISTER_ENUM_EX( "ReflectionModeType", ReflectionMode, ReflectionModeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); } diff --git a/trinity/Eve/EveInstancedMeshManager.cpp b/trinity/Eve/EveInstancedMeshManager.cpp index 8fc398e37..a9c418d3e 100644 --- a/trinity/Eve/EveInstancedMeshManager.cpp +++ b/trinity/Eve/EveInstancedMeshManager.cpp @@ -727,7 +727,7 @@ std::pair EveInstancedMeshManager::GetPickedObject( uint32_t BinVisibleInstances( mesh, meshInfo, group ); auto& lod = meshInfo.lodIndices[objectId - group.pickingObjectId]; uint32_t instanceId = 0; - if ( areaId < lod.size() ) + if( areaId < lod.size() ) { instanceId = uint32_t( mesh.isDynamic ? static_cast( lod[areaId].first ) - group.dynamicInstances : static_cast( lod[areaId].first ) - group.staticInstances ); } @@ -840,7 +840,7 @@ void EveInstancedMeshManager::GetPickingBatches( EvePendingPickingReadback& read accumulator->Commit( batch ); - traceback.push_back( {group.owner, group.ownerIndex} ); + traceback.push_back( { group.owner, group.ownerIndex } ); } objectIdOffset += static_cast( meshInfo.lodIndices.size() ); } diff --git a/trinity/Eve/EveInstancedMeshManager.h b/trinity/Eve/EveInstancedMeshManager.h index 7d04bdd62..3b4209c66 100644 --- a/trinity/Eve/EveInstancedMeshManager.h +++ b/trinity/Eve/EveInstancedMeshManager.h @@ -170,7 +170,7 @@ class EveInstancedMeshManager uint32_t sphereGroupIndex = 0; uint32_t perObjectDataIndex = 0; uint32_t ownerIndex = 0; - IRootPtr owner; // Used for picking + IRootPtr owner; // Used for picking uint32_t pickingObjectId = 0; }; diff --git a/trinity/Eve/EveLODHelper.cpp b/trinity/Eve/EveLODHelper.cpp index bdcd9f5c9..6ea47bebf 100644 --- a/trinity/Eve/EveLODHelper.cpp +++ b/trinity/Eve/EveLODHelper.cpp @@ -33,6 +33,3 @@ Tr2Lod EveLODHelper::MergeLOD( Tr2Lod lod0, const Vector4& sphere, const EveUpda } return TR2_LOD_UNSPECIFIED; } - - - diff --git a/trinity/Eve/EveLODHelper.h b/trinity/Eve/EveLODHelper.h index debb8b51d..ff5b104da 100644 --- a/trinity/Eve/EveLODHelper.h +++ b/trinity/Eve/EveLODHelper.h @@ -12,7 +12,11 @@ extern float g_eveSpaceSceneLowUpdateRate; extern float g_eveSpaceSceneMediumUpdateRate; -enum BoundingSphereQuery { EVE_BOUNDS_NORMAL, EVE_BOUNDS_WITH_CHILDREN }; +enum BoundingSphereQuery +{ + EVE_BOUNDS_NORMAL, + EVE_BOUNDS_WITH_CHILDREN +}; class EveLODHelper { diff --git a/trinity/Eve/EveLensflare.cpp b/trinity/Eve/EveLensflare.cpp index e2d1ff997..075d3ec0e 100644 --- a/trinity/Eve/EveLensflare.cpp +++ b/trinity/Eve/EveLensflare.cpp @@ -67,7 +67,7 @@ EveLensflare::EveLensflare( IRoot* lockobj ) : m_update( true ), m_isVisible( false ), m_position( 0.0f, 0.0f, 0.0f ), - m_cameraFactor( 20.f ), + m_cameraFactor( 20.f ), m_sunSize( 0.f ), m_directionVar( "LensflareFxDirectionScale", Vector4( 0.f, 0.f, 0.f, 1.f ) ), m_occScaleVar( "LensflareFxOccScale", Vector4( 1.f, 0.f, 0.f, 0.f ) ), @@ -124,7 +124,7 @@ void EveLensflare::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* // -------------------------------------------------------------------------------- // Description: -// Clean up controllers by unlinking them +// Clean up controllers by unlinking them // -------------------------------------------------------------------------------- EveLensflare::~EveLensflare() { @@ -216,12 +216,12 @@ void EveLensflare::PrepareRender( const TriFrustum& frustum ) // build the matrix that will rotate the flares into position // by using the position of the camera and the direction to the world pos Vector3 negDirVec = -m_direction; - TriMatrixArcFromForward(&m_transform, &negDirVec); + TriMatrixArcFromForward( &m_transform, &negDirVec ); m_transform._41 = cameraSpacePos.x; m_transform._42 = cameraSpacePos.y; m_transform._43 = cameraSpacePos.z; - m_transform._44 = 1.0f; - + m_transform._44 = 1.0f; + // pass important data to shader m_directionVar = Vector4( m_direction, m_sunSize ); @@ -230,7 +230,7 @@ void EveLensflare::PrepareRender( const TriFrustum& frustum ) direction = Transform( direction, frustum.m_projectionMatrix ); direction.x /= direction.w; direction.y /= direction.w; - float distanceToEdge = 1 - std::min( 1 - std::abs( direction.x ), 1 - std::abs( direction.y ) ); + float distanceToEdge = 1 - std::min( 1 - std::abs( direction.x ), 1 - std::abs( direction.y ) ); float distanceToCenter = Length( *reinterpret_cast( &direction ) ); float radialAngle = atan2( direction.y, direction.x ) + TRI_PI; @@ -278,7 +278,7 @@ void EveLensflare::PrepareRender( const TriFrustum& frustum ) void EveLensflare::GetRenderables( const TriFrustum& frustum, std::vector& renderables ) { // display? - if( !m_display || !m_isVisible) + if( !m_display || !m_isVisible ) { return; } @@ -286,7 +286,7 @@ void EveLensflare::GetRenderables( const TriFrustum& frustum, std::vectorGetRenderables( renderables, nullptr ); + ( *it )->GetRenderables( renderables, nullptr ); } if( m_mesh ) @@ -496,7 +496,7 @@ void EveLensflare::SetControllerVariable( const char* name, float value ) void EveLensflare::HandleControllerEvent( const char* name ) { - for( auto it = m_controllers.begin(); it != m_controllers.end(); ++it ) + for( auto it = m_controllers.begin(); it != m_controllers.end(); ++it ) { ( *it )->HandleEvent( name ); } diff --git a/trinity/Eve/EveLensflare.h b/trinity/Eve/EveLensflare.h index 80968959b..a956badd0 100644 --- a/trinity/Eve/EveLensflare.h +++ b/trinity/Eve/EveLensflare.h @@ -36,17 +36,16 @@ BLUE_DECLARE( Tr2Mesh ); // SeeAlso: // EveSpaceScene, EveOccluder, Tr2TransformModifier // -------------------------------------------------------------------------------- -class EveLensflare : - public ITr2Renderable, - public ITr2CurveSetOwner, - public ITr2ControllerOwner, - public IInitialize, - public IListNotify +class EveLensflare : public ITr2Renderable, + public ITr2CurveSetOwner, + public ITr2ControllerOwner, + public IInitialize, + public IListNotify { public: EXPOSE_TO_BLUE(); - EveLensflare(IRoot* lockobj = NULL); + EveLensflare( IRoot* lockobj = NULL ); ~EveLensflare(); // timing @@ -67,10 +66,10 @@ class EveLensflare : bool Initialize(); void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); - + virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); - virtual bool HasTransparentBatches(); - virtual float GetSortValue(); + virtual bool HasTransparentBatches(); + virtual float GetSortValue(); virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); ///////////////////////////////////////////////////////////////////////////////////// @@ -80,13 +79,13 @@ class EveLensflare : virtual void UpdateCurveSet( const std::string& name, Be::Time time ); virtual float GetCurveSetDuration( const std::string& name ) const; virtual float GetRangeDuration( const std::string& name, const std::string& rangeName ) const; - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner void SetControllerVariable( const char* name, float value ); void HandleControllerEvent( const char* name ) override; void StartControllers(); - + private: // name diff --git a/trinity/Eve/EveLensflare_Blue.cpp b/trinity/Eve/EveLensflare_Blue.cpp index 4a6bc4c13..f8024764b 100644 --- a/trinity/Eve/EveLensflare_Blue.cpp +++ b/trinity/Eve/EveLensflare_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( EveLensflare ); const Be::ClassInfo* EveLensflare::ExposeToBlue() { EXPOSURE_BEGIN( EveLensflare, "" ) - MAP_INTERFACE( EveLensflare ) + MAP_INTERFACE( EveLensflare ) MAP_INTERFACE( ITr2ControllerOwner ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -19,7 +19,7 @@ const Be::ClassInfo* EveLensflare::ExposeToBlue() MAP_ATTRIBUTE( "update", m_update, "Toggle updates", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "cameraFactor", m_cameraFactor, "na", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE("mesh", m_mesh, "A mesh that is rendered as a flare", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "mesh", m_mesh, "A mesh that is rendered as a flare", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "position", m_position, "position of this lensflare", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translationCurve", m_translationCurve, "", Be::READWRITE ) @@ -28,40 +28,40 @@ const Be::ClassInfo* EveLensflare::ExposeToBlue() MAP_ATTRIBUTE( "occluders", m_occluders, "foreground (ships, stations, etc.) occluders module of this lensflare", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "backgroundOccluders", m_backgroundOccluders, "background (planets) occluders module of this lensflare", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "distanceToEdgeCurves", - m_distanceToEdgeCurves, - "List of curves that accept biased distance to closest edge (0 at center, 1 at edge, >1 ouside the screen) as an argument", + MAP_ATTRIBUTE( + "distanceToEdgeCurves", + m_distanceToEdgeCurves, + "List of curves that accept biased distance to closest edge (0 at center, 1 at edge, >1 ouside the screen) as an argument", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "distanceToCenterCurves", - m_distanceToCenterCurves, - "List of curves that accept distance to screen center as an argument", + MAP_ATTRIBUTE( + "distanceToCenterCurves", + m_distanceToCenterCurves, + "List of curves that accept distance to screen center as an argument", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "radialAngleCurves", - m_radialAngleCurves, - "List of curves that accept screen position polar coordinate angle as an argument", + MAP_ATTRIBUTE( + "radialAngleCurves", + m_radialAngleCurves, + "List of curves that accept screen position polar coordinate angle as an argument", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "xDistanceToCenter", - m_xDistanceToCenter, - "List of curves that accept signed distance to screen center along x axis as an argument (biased by +10)", + MAP_ATTRIBUTE( + "xDistanceToCenter", + m_xDistanceToCenter, + "List of curves that accept signed distance to screen center along x axis as an argument (biased by +10)", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "yDistanceToCenter", - m_yDistanceToCenter, - "List of curves that accept signed distance to screen center along y axis as an argument (biased by +10)", + MAP_ATTRIBUTE( + "yDistanceToCenter", + m_yDistanceToCenter, + "List of curves that accept signed distance to screen center along y axis as an argument (biased by +10)", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "bindings", - m_bindings, - "List of value bindings", + MAP_ATTRIBUTE( + "bindings", + m_bindings, + "List of value bindings", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "curveSets", - m_curveSets, - "List of curve sets", + MAP_ATTRIBUTE( + "curveSets", + m_curveSets, + "List of curve sets", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "controllers", m_controllers, "List of object controllers", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( @@ -69,13 +69,11 @@ const Be::ClassInfo* EveLensflare::ExposeToBlue() SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) - + "Start all controllers" ) + EXPOSURE_END() } diff --git a/trinity/Eve/EveMultiEffect.cpp b/trinity/Eve/EveMultiEffect.cpp index f78429be3..4d44929fc 100644 --- a/trinity/Eve/EveMultiEffect.cpp +++ b/trinity/Eve/EveMultiEffect.cpp @@ -8,7 +8,7 @@ #include "Eve/EveUpdateContext.h" #include "Curves/TriCurveSet.h" -EveMultiEffect::EveMultiEffect( IRoot* lockobj ) : +EveMultiEffect::EveMultiEffect( IRoot* lockobj ) : PARENTLOCK( m_parameters ), PARENTLOCK( m_bindings ), PARENTLOCK( m_externalParameters ), @@ -52,7 +52,7 @@ void EveMultiEffect::Rebind( bool onlyUpdateBindings ) { ( *binding )->Link(); const Be::Time time = 0; - ( *binding )->Update( time ); + ( *binding )->Update( time ); } if( onlyUpdateBindings ) @@ -157,10 +157,10 @@ bool EveMultiEffect::SetParameter( BlueSharedString parameterName, IRoot* object { for( auto param = m_parameters.begin(); param != m_parameters.end(); ++param ) { - if( ( *param )->GetName() == parameterName ) + if( ( *param )->GetName() == parameterName ) { ( *param )->SetParameterObject( object ); - + Rebind(); return true; } @@ -172,7 +172,7 @@ EveMultiEffectParameter* EveMultiEffect::GetParameterByName( BlueSharedString pa { for( auto param = m_parameters.begin(); param != m_parameters.end(); ++param ) { - if( (*param)->GetName() == parameterName ) + if( ( *param )->GetName() == parameterName ) { return *param; } @@ -212,7 +212,7 @@ void EveMultiEffect::GetBindingRoots( std::unordered_map& v ITr2ControllerOwner::GetBindingRoots( variables ); for( auto param = begin( m_parameters ); param != end( m_parameters ); ++param ) { - variables[ ( *param )->GetName().c_str() ] = ( *param )->GetParameterObject(); + variables[( *param )->GetName().c_str()] = ( *param )->GetParameterObject(); } } @@ -292,7 +292,7 @@ float EveMultiEffect::GetRangeDuration( const std::string& name, const std::stri ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 -void EveMultiEffect::UpdateSyncronous( const EveUpdateContext& updateContext ) +void EveMultiEffect::UpdateSyncronous( const EveUpdateContext& updateContext ) { Be::Time time = updateContext.GetTime(); @@ -314,14 +314,38 @@ void EveMultiEffect::UpdateSyncronous( const EveUpdateContext& updateContext ) } -void EveMultiEffect::UpdateAsyncronous( const EveUpdateContext& updateContext ) {} -void EveMultiEffect::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) {} -void EveMultiEffect::GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) {} -bool EveMultiEffect::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { return false; } -void EveMultiEffect::GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const {} -void EveMultiEffect::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) {} -void EveMultiEffect::GetModelCenterWorldPosition( Vector3 &position ) const {} -bool EveMultiEffect::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } -void EveMultiEffect::GetLocalToWorldTransform( Matrix &transform ) const {} -void EveMultiEffect::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) {} -void EveMultiEffect::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) {} \ No newline at end of file +void EveMultiEffect::UpdateAsyncronous( const EveUpdateContext& updateContext ) +{ +} +void EveMultiEffect::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) +{ +} +void EveMultiEffect::GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) +{ +} +bool EveMultiEffect::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const +{ + return false; +} +void EveMultiEffect::GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const +{ +} +void EveMultiEffect::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) +{ +} +void EveMultiEffect::GetModelCenterWorldPosition( Vector3& position ) const +{ +} +bool EveMultiEffect::GetLocalBoundingBox( Vector3& min, Vector3& max ) +{ + return false; +} +void EveMultiEffect::GetLocalToWorldTransform( Matrix& transform ) const +{ +} +void EveMultiEffect::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) +{ +} +void EveMultiEffect::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) +{ +} \ No newline at end of file diff --git a/trinity/Eve/EveMultiEffect.h b/trinity/Eve/EveMultiEffect.h index 8749b7894..08b6226f2 100644 --- a/trinity/Eve/EveMultiEffect.h +++ b/trinity/Eve/EveMultiEffect.h @@ -34,14 +34,14 @@ BLUE_CLASS( EveMultiEffect ) : public ITr2ControllerOwner, public ITr2CurveSetOwner { -public: +public: EXPOSE_TO_BLUE(); EveMultiEffect( IRoot* lockobj = NULL ); ~EveMultiEffect(); - + void Rebind( bool onlyUpdateBindings = 0 ); - bool SetParameter( BlueSharedString parameterName, IRoot* object ); + bool SetParameter( BlueSharedString parameterName, IRoot * object ); EveMultiEffectParameter* GetParameterByName( BlueSharedString parameterName ); ////////////////////////////////////////////////////////////////////////////////////// @@ -49,7 +49,7 @@ BLUE_CLASS( EveMultiEffect ) : void SetControllerVariable( const char* name, float value ); void HandleControllerEvent( const char* name ); void StartControllers(); - void GetBindingRoots( std::unordered_map& variables ); + void GetBindingRoots( std::unordered_map & variables ); ////////////////////////////////////////////////////////////////////////////////////// // ITr2DynamicBindingOwner @@ -62,7 +62,7 @@ BLUE_CLASS( EveMultiEffect ) : virtual void UpdateCurveSet( const std::string& name, Be::Time time ); virtual float GetCurveSetDuration( const std::string& name ) const; virtual float GetRangeDuration( const std::string& name, const std::string& rangeName ) const; - + ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); @@ -76,14 +76,14 @@ BLUE_CLASS( EveMultiEffect ) : void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const; - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - void GetModelCenterWorldPosition( Vector3 &position ) const; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - void GetLocalToWorldTransform( Matrix &transform ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void GetPerObjectStructs( EveSpaceObjectVSData & vsData, EveSpaceObjectPSData & psData ) const; + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + void GetModelCenterWorldPosition( Vector3 & position ) const; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + void GetLocalToWorldTransform( Matrix & transform ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); private: diff --git a/trinity/Eve/EveMultiEffectParameter.cpp b/trinity/Eve/EveMultiEffectParameter.cpp index 4f4a71f5e..3d425bf8f 100644 --- a/trinity/Eve/EveMultiEffectParameter.cpp +++ b/trinity/Eve/EveMultiEffectParameter.cpp @@ -12,7 +12,6 @@ EveMultiEffectParameter::EveMultiEffectParameter( IRoot* lockobj ) : m_owner( nullptr ), m_type( TYPE_UNDEFINED ) { - } void EveMultiEffectParameter::SetOwner( EveMultiEffect* owner ) @@ -22,7 +21,7 @@ void EveMultiEffectParameter::SetOwner( EveMultiEffect* owner ) bool EveMultiEffectParameter::OnModified( Be::Var* value ) { - if( IsMatch( value, m_object ) && this->m_owner != nullptr) + if( IsMatch( value, m_object ) && this->m_owner != nullptr ) { this->m_owner->Rebind(); } @@ -39,7 +38,7 @@ IRoot* EveMultiEffectParameter::GetParameterObject() return m_object; } -bool EveMultiEffectParameter::IsValid( ) +bool EveMultiEffectParameter::IsValid() { if( m_object == nullptr ) { diff --git a/trinity/Eve/EveMultiEffectParameter.h b/trinity/Eve/EveMultiEffectParameter.h index df30345a0..45db0c622 100644 --- a/trinity/Eve/EveMultiEffectParameter.h +++ b/trinity/Eve/EveMultiEffectParameter.h @@ -24,23 +24,22 @@ BLUE_CLASS( EveMultiEffectParameter ) : EXPOSE_TO_BLUE(); EveMultiEffectParameter( IRoot* lockobj = NULL ); - void SetParameterObject( IRoot* object ); + void SetParameterObject( IRoot * object ); bool IsValid(); - void SetOwner( EveMultiEffect* owner ); + void SetOwner( EveMultiEffect * owner ); IRoot* GetParameterObject(); BlueSharedString GetName(); - + ////////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); private: BlueSharedString m_name; IRootPtr m_object; EveMultiEffect* m_owner; ParameterType m_type; - }; TYPEDEF_BLUECLASS( EveMultiEffectParameter ); diff --git a/trinity/Eve/EveMultiEffectParameter_Blue.cpp b/trinity/Eve/EveMultiEffectParameter_Blue.cpp index 6755fd5a2..c6b042b92 100644 --- a/trinity/Eve/EveMultiEffectParameter_Blue.cpp +++ b/trinity/Eve/EveMultiEffectParameter_Blue.cpp @@ -5,8 +5,7 @@ BLUE_DEFINE( EveMultiEffectParameter ); -Be::VarChooser EveMultiEffectParameterTypeChooser[] = -{ +Be::VarChooser EveMultiEffectParameterTypeChooser[] = { { "EveSpaceObject2", BeCast( EveMultiEffectParameter::TYPE_EVESPACEOBJECT ), "The parameter is of EveSpaceObject2 type" }, { "EveEffectRoot2", BeCast( EveMultiEffectParameter::TYPE_EVEEFFECTROOT ), "The parameter is of EveEffectRoot2 type" }, { "Anything", BeCast( EveMultiEffectParameter::TYPE_ANYTHING ), "The parameter can be anything" }, @@ -21,10 +20,10 @@ const Be::ClassInfo* EveMultiEffectParameter::ExposeToBlue() EXPOSURE_BEGIN( EveMultiEffectParameter, "" ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "object", m_object, "The object to add bindings to", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE_WITH_CHOOSER( "type", m_type, "The type of object that this parameter is supposed to be bound to", Be::READWRITE | Be::ENUM, EveMultiEffectParameterTypeChooser ) MAP_PROPERTY_READONLY( "isValid", IsValid, "Is the parameter valid" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/EveMultiEffect_Blue.cpp b/trinity/Eve/EveMultiEffect_Blue.cpp index 792dc499c..80e524d99 100644 --- a/trinity/Eve/EveMultiEffect_Blue.cpp +++ b/trinity/Eve/EveMultiEffect_Blue.cpp @@ -20,86 +20,70 @@ const Be::ClassInfo* EveMultiEffect::ExposeToBlue() "name", m_name, "The name of the multi effect", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "parameters", m_parameters, "A list of objects that can be set from the python side", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "controllers", m_controllers, "A list of controllers that control the multieffect", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "externalParameters", m_externalParameters, "A list of external parameters that are linked to multieffect properties", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "curveSets", m_curveSets, "A list of curvesets", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "bindings", m_bindings, "A list of bindings between parameters/curves", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "SetParameter", - SetParameter, + MAP_METHOD_AND_WRAP( + "SetParameter", + SetParameter, "Sets a named parameter\n" ":param parameterName: the name of a defined parameter \n" ":param object: the object that will be attached to the parameter\n" - ":return : True if it is successful, False otherwise" - ) + ":return : True if it is successful, False otherwise" ) MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Sets a controller variable\n" ":param name: the name of a controller variable\n" - ":param value: The value of the variable\n" - ) + ":param value: The value of the variable\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Handles controller event of a particular name\n" - ":param name: the name of a event\n" - ) + ":param name: the name of a event\n" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Starts the controllers\n" - ) - - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "Starts the controllers\n" ) + + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "Rebind", Rebind, 1, "Rebinds all bindings to parameters\n" - ":param onlyUpdateBindings: true to only update bindings, false to also update controller refs" - ) - - EXPOSURE_END( ); + ":param onlyUpdateBindings: true to only update bindings, false to also update controller refs" ) + + EXPOSURE_END(); } diff --git a/trinity/Eve/EveOccluder.cpp b/trinity/Eve/EveOccluder.cpp index 8cad4ee73..4eaa1aec5 100644 --- a/trinity/Eve/EveOccluder.cpp +++ b/trinity/Eve/EveOccluder.cpp @@ -108,7 +108,7 @@ void Tr2OcclusionBuffer::ResizeBuffer() old = *buffer; } m_buffer->Create( m_size, Tr2RenderContextEnum::PIXEL_FORMAT_R32_UINT, Tr2GpuBuffer::GPU_WRITABLE ); - + if( old.IsValid() ) { USE_MAIN_THREAD_RENDER_CONTEXT(); diff --git a/trinity/Eve/EveOccluder.h b/trinity/Eve/EveOccluder.h index c79207180..dd8a4fba2 100644 --- a/trinity/Eve/EveOccluder.h +++ b/trinity/Eve/EveOccluder.h @@ -20,8 +20,7 @@ BLUE_DECLARE( Tr2Effect ); class Tr2OcclusionBuffer : public Tr2DeviceResource { public: - - using Offset = std::shared_ptr; + using Offset = std::shared_ptr; Tr2OcclusionBuffer(); @@ -60,13 +59,12 @@ class Tr2OcclusionBuffer : public Tr2DeviceResource // SeeAlso: // EveLensflare // -------------------------------------------------------------------------------- -class EveOccluder : - public IRoot +class EveOccluder : public IRoot { public: EXPOSE_TO_BLUE(); - EveOccluder(IRoot* lockobj = NULL); + EveOccluder( IRoot* lockobj = NULL ); // do the occlusion rendering/querying void RunQuery( Tr2RenderContext& renderContext, const EveUpdateContext& updateContext, const Matrix& transform, uint32_t bufferOffset, float fogWeight ); diff --git a/trinity/Eve/EveOccluder_Blue.cpp b/trinity/Eve/EveOccluder_Blue.cpp index 533e09830..7596f5bd9 100644 --- a/trinity/Eve/EveOccluder_Blue.cpp +++ b/trinity/Eve/EveOccluder_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( EveOccluder ); const Be::ClassInfo* EveOccluder::ExposeToBlue() { EXPOSURE_BEGIN( EveOccluder, "" ) - MAP_INTERFACE( EveOccluder ) + MAP_INTERFACE( EveOccluder ) MAP_ATTRIBUTE( "name", m_name, "A name for this occluder", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Toggle visibility", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/EveParticleDirectForce.cpp b/trinity/Eve/EveParticleDirectForce.cpp index e050b171d..111adc659 100644 --- a/trinity/Eve/EveParticleDirectForce.cpp +++ b/trinity/Eve/EveParticleDirectForce.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "EveParticleDirectForce.h" -EveParticleDirectForce::EveParticleDirectForce( IRoot* lockobj ): +EveParticleDirectForce::EveParticleDirectForce( IRoot* lockobj ) : Tr2ParticleDirectForce( lockobj ) { } diff --git a/trinity/Eve/EveParticleDirectForce.h b/trinity/Eve/EveParticleDirectForce.h index 32975e970..645131401 100644 --- a/trinity/Eve/EveParticleDirectForce.h +++ b/trinity/Eve/EveParticleDirectForce.h @@ -10,13 +10,12 @@ BLUE_DECLARE( EveParticleDirectForce ); // -------------------------------------------------------------------------------------- // Description: -// Constant force for particle systems. All the code was moved to Tr2ParticleDirectForce. +// Constant force for particle systems. All the code was moved to Tr2ParticleDirectForce. // This class stays for backward compatibility. // See Also: // Tr2ParticleDirectForce // -------------------------------------------------------------------------------------- -class EveParticleDirectForce: - public Tr2ParticleDirectForce +class EveParticleDirectForce : public Tr2ParticleDirectForce { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Eve/EveParticleDirectForce_Blue.cpp b/trinity/Eve/EveParticleDirectForce_Blue.cpp index 3b33fc73b..0855520a6 100644 --- a/trinity/Eve/EveParticleDirectForce_Blue.cpp +++ b/trinity/Eve/EveParticleDirectForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( EveParticleDirectForce ); const Be::ClassInfo* EveParticleDirectForce::ExposeToBlue() { - EXPOSURE_BEGIN(EveParticleDirectForce, "" ) + EXPOSURE_BEGIN( EveParticleDirectForce, "" ) MAP_INTERFACE( EveParticleDirectForce ) EXPOSURE_CHAINTO( Tr2ParticleDirectForce ) } diff --git a/trinity/Eve/EveParticleDragForce.cpp b/trinity/Eve/EveParticleDragForce.cpp index 95a3e7839..78a353531 100644 --- a/trinity/Eve/EveParticleDragForce.cpp +++ b/trinity/Eve/EveParticleDragForce.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "EveParticleDragForce.h" -EveParticleDragForce::EveParticleDragForce( IRoot* lockobj ): +EveParticleDragForce::EveParticleDragForce( IRoot* lockobj ) : Tr2ParticleDragForce( lockobj ) { } diff --git a/trinity/Eve/EveParticleDragForce.h b/trinity/Eve/EveParticleDragForce.h index f53229b2e..ead1b4ad7 100644 --- a/trinity/Eve/EveParticleDragForce.h +++ b/trinity/Eve/EveParticleDragForce.h @@ -10,13 +10,12 @@ BLUE_DECLARE( EveParticleDragForce ); // -------------------------------------------------------------------------------------- // Description: -// Drag force for particle systems. All the code was moved to Tr2ParticleDragForce. +// Drag force for particle systems. All the code was moved to Tr2ParticleDragForce. // This class stays for backward compatibility. // See Also: // Tr2ParticleDragForce // -------------------------------------------------------------------------------------- -class EveParticleDragForce: - public Tr2ParticleDragForce +class EveParticleDragForce : public Tr2ParticleDragForce { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Eve/EveParticleDragForce_Blue.cpp b/trinity/Eve/EveParticleDragForce_Blue.cpp index bb4d67998..c45c046e2 100644 --- a/trinity/Eve/EveParticleDragForce_Blue.cpp +++ b/trinity/Eve/EveParticleDragForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( EveParticleDragForce ); const Be::ClassInfo* EveParticleDragForce::ExposeToBlue() { - EXPOSURE_BEGIN(EveParticleDragForce, "" ) + EXPOSURE_BEGIN( EveParticleDragForce, "" ) MAP_INTERFACE( EveParticleDragForce ) EXPOSURE_CHAINTO( Tr2ParticleDragForce ) } diff --git a/trinity/Eve/EveParticleSpringAttractor.h b/trinity/Eve/EveParticleSpringAttractor.h index 302a349cc..cf9cf462a 100644 --- a/trinity/Eve/EveParticleSpringAttractor.h +++ b/trinity/Eve/EveParticleSpringAttractor.h @@ -10,18 +10,18 @@ BLUE_DECLARE( EveParticleSpring ); // -------------------------------------------------------------------------------------- // Description: -// Spring force for particle systems. All the code was moved to Tr2ParticleSpring. +// Spring force for particle systems. All the code was moved to Tr2ParticleSpring. // This class stays for backward compatibility. // See Also: // Tr2ParticleSpring // -------------------------------------------------------------------------------------- -class EveParticleSpring: - public Tr2ParticleSpring +class EveParticleSpring : public Tr2ParticleSpring { public: EXPOSE_TO_BLUE(); - EveParticleSpring( IRoot* lockobj = 0 );; + EveParticleSpring( IRoot* lockobj = 0 ); + ; }; TYPEDEF_BLUECLASS( EveParticleSpring ); diff --git a/trinity/Eve/EveParticleSpringAttractor_Blue.cpp b/trinity/Eve/EveParticleSpringAttractor_Blue.cpp index cfe68838c..186154351 100644 --- a/trinity/Eve/EveParticleSpringAttractor_Blue.cpp +++ b/trinity/Eve/EveParticleSpringAttractor_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( EveParticleSpring ); const Be::ClassInfo* EveParticleSpring::ExposeToBlue() { - EXPOSURE_BEGIN(EveParticleSpring, "" ) + EXPOSURE_BEGIN( EveParticleSpring, "" ) MAP_INTERFACE( EveParticleSpring ) EXPOSURE_CHAINTO( Tr2ParticleSpring ) } diff --git a/trinity/Eve/EvePicking.cpp b/trinity/Eve/EvePicking.cpp index edf466a26..885f551f7 100644 --- a/trinity/Eve/EvePicking.cpp +++ b/trinity/Eve/EvePicking.cpp @@ -7,12 +7,11 @@ - EvePendingPickingReadback::EvePendingPickingReadback( uint32_t pickedX, uint32_t pickedY ) : m_pickedX( pickedX ), m_pickedY( pickedY ), m_debugPickBuffer( NULL, ImageIO::PIXEL_FORMAT_R32G32B32A32_FLOAT ), - m_debugPickData(nullptr), + m_debugPickData( nullptr ), m_mainPickBuffer( NULL, ImageIO::PIXEL_FORMAT_B8G8R8A8_UNORM ), m_mainPickData( nullptr ) { diff --git a/trinity/Eve/EvePicking.h b/trinity/Eve/EvePicking.h index d443b8df7..86376848d 100644 --- a/trinity/Eve/EvePicking.h +++ b/trinity/Eve/EvePicking.h @@ -25,7 +25,7 @@ class EvePendingPickingReadback : public Tr2DeviceResource uint64_t m_frameIndex; - + std::vector m_debugLineObjects; std::vector m_debugTriangleObjects; Tr2PickBuffer m_debugPickBuffer; @@ -37,7 +37,7 @@ class EvePendingPickingReadback : public Tr2DeviceResource Tr2PickBuffer m_mainPickBuffer; const void* m_mainPickData; - + ///////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ) override; diff --git a/trinity/Eve/EvePlanet.cpp b/trinity/Eve/EvePlanet.cpp index 63f6be926..2f213983f 100644 --- a/trinity/Eve/EvePlanet.cpp +++ b/trinity/Eve/EvePlanet.cpp @@ -40,7 +40,7 @@ void EvePlanet::UnregisterSecondaryLightSource( Tr2ShLightingManager& manager ) manager.UnregisterSecondaryLightSource( &m_worldTransform.GetTranslation() ); } -void EvePlanet::UpdateEffectChildren( const EveUpdateContext& updateContext, Matrix &worldTransform, float renderScale ) +void EvePlanet::UpdateEffectChildren( const EveUpdateContext& updateContext, Matrix& worldTransform, float renderScale ) { EveChildUpdateParams params; params.spaceObjectParent = nullptr; @@ -87,16 +87,16 @@ void EvePlanet::UpdatePlanetSyncronous( const EveUpdateContext& updateContext, f m_ballRotation->Update( &rotation, time ); } - // Add Ball & EffectRoot Translation & Rotation + // Add Ball & EffectRoot Translation & Rotation translation += m_translation; - rotation = Normalize( rotation * m_rotation); + rotation = Normalize( rotation * m_rotation ); m_worldTransform = TransformationMatrix( m_scaling, rotation, translation ); - UpdateEffectChildren( updateContext, m_worldTransform, renderScale); + UpdateEffectChildren( updateContext, m_worldTransform, renderScale ); - for (auto it = m_curveSets.begin(); it != m_curveSets.end(); ++it) + for( auto it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( time, time ); + ( *it )->Update( time, time ); } // Update the controllers @@ -106,9 +106,8 @@ void EvePlanet::UpdatePlanetSyncronous( const EveUpdateContext& updateContext, f TriObserverLocalVector::iterator observersEnd = m_observers.end(); for( TriObserverLocalVector::iterator it = m_observers.begin(); it != observersEnd; ++it ) { - (*it)->Update( m_worldTransform ); + ( *it )->Update( m_worldTransform ); } - } Matrix EvePlanet::CalculatePlanetScaleTransform( const Matrix& worldTransform, float renderScale ) const @@ -122,10 +121,10 @@ void EvePlanet::UpdatePlanetVisibility( const EveUpdateContext& updateContext, f const auto scaledTransform = CalculatePlanetScaleTransform( m_worldTransform, renderScale ); // pixel diameters, also for the max possible - m_estimatedPixelDiameter = EstimatePixelDiameterPos( reinterpret_cast(&scaledTransform._41), 1.f / Tr2Renderer::GetProjectionTransform()._11, renderScale ); - m_estimatedMaxPixelDiameter = EstimatePixelDiameterPos( reinterpret_cast(&scaledTransform._41), tanf( FOV_MIN / 2.f ), renderScale ); + m_estimatedPixelDiameter = EstimatePixelDiameterPos( reinterpret_cast( &scaledTransform._41 ), 1.f / Tr2Renderer::GetProjectionTransform()._11, renderScale ); + m_estimatedMaxPixelDiameter = EstimatePixelDiameterPos( reinterpret_cast( &scaledTransform._41 ), tanf( FOV_MIN / 2.f ), renderScale ); - for ( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) + for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { ( *it )->UpdateVisibility( updateContext, scaledTransform, m_lodLevel ); } @@ -182,18 +181,18 @@ float EvePlanet::EstimatePixelDiameterDist( float scaledDistance, float tanFOV, { const auto halfWidthProjection = Tr2Renderer::GetViewport().width * 0.5f / tanFOV; - // get radius od + // get radius od const auto radius = m_radius / scale; // clamp values close to zero and below const float epsilon = 1e-5f; if( scaledDistance < epsilon ) { - scaledDistance = epsilon; + scaledDistance = epsilon; } if( radius < epsilon ) - { + { return 0.0f; } @@ -208,7 +207,7 @@ void EvePlanet::GetZOnlyRenderables( std::vector& renderables ) return; } - if ( m_lodLevel != TR2_LOD_HIGH ) + if( m_lodLevel != TR2_LOD_HIGH ) { return; } @@ -219,23 +218,23 @@ void EvePlanet::GetZOnlyRenderables( std::vector& renderables ) } } -void EvePlanet::GetRenderables( std::vector& renderables) +void EvePlanet::GetRenderables( std::vector& renderables ) { if( !m_display ) { return; } - if( m_lodLevel != TR2_LOD_HIGH) + if( m_lodLevel != TR2_LOD_HIGH ) { return; } - + // visible at all? if( m_estimatedPixelDiameter > m_minScreenSize ) { - for ( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) + for( auto ecIt = m_effectChildren.begin(); ecIt != m_effectChildren.end(); ++ecIt ) { - (*ecIt)->GetRenderables( renderables ); + ( *ecIt )->GetRenderables( renderables ); } } } @@ -252,13 +251,13 @@ ITriVectorFunctionPtr EvePlanet::GetTranslationCurve() void EvePlanet::UpdateLOD() { - if ( !m_display ) + if( !m_display ) { return; } // visible at all? - if ( m_estimatedPixelDiameter > m_minScreenSize ) + if( m_estimatedPixelDiameter > m_minScreenSize ) { SetLod( TR2_LOD_HIGH ); } @@ -275,7 +274,7 @@ void EvePlanet::SetLod( Tr2Lod lod ) for( auto it = m_effectChildren.begin(); it != m_effectChildren.end(); ++it ) { - (*it)->ChangeLOD( m_lodLevel ); + ( *it )->ChangeLOD( m_lodLevel ); } if( nullptr != m_zOnlyModel ) { @@ -359,14 +358,14 @@ bool EvePlanet::HasImpactConfigurationShield() const void EvePlanet::GetDebugOptions( Tr2DebugRendererOptions& options ) { - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->GetDebugOptions( options ); } - for ( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) + for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { - if ( auto renderable = dynamic_cast< ITr2DebugRenderable* >( *it ) ) + if( auto renderable = dynamic_cast( *it ) ) { renderable->GetDebugOptions( options ); } @@ -375,14 +374,14 @@ void EvePlanet::GetDebugOptions( Tr2DebugRendererOptions& options ) void EvePlanet::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->RenderDebugInfo( renderer ); } - for ( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) + for( auto it = begin( m_effectChildren ); it != end( m_effectChildren ); ++it ) { - if ( auto renderable = dynamic_cast< ITr2DebugRenderable* >( *it ) ) + if( auto renderable = dynamic_cast( *it ) ) { renderable->RenderDebugInfo( renderer ); } diff --git a/trinity/Eve/EvePlanet.h b/trinity/Eve/EvePlanet.h index 57856d9a9..e565f6e51 100644 --- a/trinity/Eve/EvePlanet.h +++ b/trinity/Eve/EvePlanet.h @@ -11,17 +11,17 @@ #include "EveEffectRoot2.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif BLUE_DECLARE( EvePlanet ); BLUE_DECLARE_VECTOR( EvePlanet ); -BLUE_DECLARE( EveTransform ); +BLUE_DECLARE( EveTransform ); BLUE_DECLARE( Tr2ExternalParameter ); BLUE_DECLARE_VECTOR( Tr2ExternalParameter ); BLUE_DECLARE( EveEffectRoot2 ); @@ -33,26 +33,26 @@ struct ViewDistanceInfo; class EveUpdateContext; -BLUE_CLASS( EvePlanet ): +BLUE_CLASS( EvePlanet ) : public EveEffectRoot2 { public: - EXPOSE_TO_BLUE(); - EvePlanet( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EvePlanet( IRoot* lockobj = NULL ); ~EvePlanet(); - void UpdatePlanetSyncronous( const EveUpdateContext & updateContext, float renderScale ); + void UpdatePlanetSyncronous( const EveUpdateContext& updateContext, float renderScale ); void UpdatePlanetVisibility( const EveUpdateContext& updateContext, float renderScale ); void UpdateZOnlyVisibility( const EveUpdateContext& updateContext ); - void GetRenderables( std::vector& renderables); - void GetZOnlyRenderables( std::vector& renderables ); - + void GetRenderables( std::vector & renderables ); + void GetZOnlyRenderables( std::vector & renderables ); + void UpdateLOD(); void SetRenderScale( float value ); float GetEstimatedPixelDiameter(); ITriVectorFunctionPtr GetTranslationCurve(); - + static const float SCALE; // IWorldPosition @@ -67,19 +67,19 @@ BLUE_CLASS( EvePlanet ): // ITriTargetable unsigned int GetDamageLocatorCount() const; int GetClosestDamageLocatorIndex( const Vector3* position ); - bool GetDamageLocatorPosition( Vector3* out, int index, bool inWorldSpace ); - bool GetDamageLocatorDirection( Vector3* out, int index, bool inWorldSpace ); + bool GetDamageLocatorPosition( Vector3 * out, int index, bool inWorldSpace ); + bool GetDamageLocatorDirection( Vector3 * out, int index, bool inWorldSpace ); void GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ); int GetGoodDamageLocatorIndex( const Vector3& position ); float GetRadius() const; int CreateImpact( int damageLocatorIndex, const Vector3& direction, float lifeTime, float size ); - bool UpdateImpact( Vector3& out, const Vector3& direction, int impactIndex ); - bool GetImpactPosition( Vector3& out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); + bool UpdateImpact( Vector3 & out, const Vector3& direction, int impactIndex ); + bool GetImpactPosition( Vector3 & out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); bool HasImpactConfigurationShield() const; // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); private: Matrix CalculatePlanetScaleTransform( const Matrix& worldTransform, float renderScale ) const; @@ -102,7 +102,7 @@ BLUE_CLASS( EvePlanet ): Color m_albedoColor; Color m_emissiveColor; EveChildMeshPtr m_zOnlyModel; - + using EveEffectRoot2::GetRenderables; // Silence warning about this hidden function }; diff --git a/trinity/Eve/EvePlanet_Blue.cpp b/trinity/Eve/EvePlanet_Blue.cpp index 80194272d..4d7d1a4fb 100644 --- a/trinity/Eve/EvePlanet_Blue.cpp +++ b/trinity/Eve/EvePlanet_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( EvePlanet ); const Be::ClassInfo* EvePlanet::ExposeToBlue() { - EXPOSURE_BEGIN( EvePlanet, "" ) + EXPOSURE_BEGIN( EvePlanet, "" ) MAP_INTERFACE( EvePlanet ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2SecondaryLightSource ) @@ -17,27 +17,21 @@ const Be::ClassInfo* EvePlanet::ExposeToBlue() MAP_INTERFACE( IShaderConfigurer ) MAP_INTERFACE( ITr2SoundEmitterOwner ) MAP_INTERFACE( IWorldPosition ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "radius", m_radius, "The planet's radius", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "albedoColor", m_albedoColor, "Planet albedo color, used for secondary lighting", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "minScreenSize", m_minScreenSize, "Minimum screen size for planet rendering", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "zOnlyModel", m_zOnlyModel, @@ -53,5 +47,5 @@ const Be::ClassInfo* EvePlanet::ExposeToBlue() m_estimatedPixelDiameter, "Planet size in pixels as it appears from the camera perspective. ", Be::READ | Be::PERSIST ) - EXPOSURE_CHAINTO(EveEffectRoot2) + EXPOSURE_CHAINTO( EveEffectRoot2 ) } diff --git a/trinity/Eve/EveRootTransform.cpp b/trinity/Eve/EveRootTransform.cpp index 78aca0f90..1f276d3c5 100644 --- a/trinity/Eve/EveRootTransform.cpp +++ b/trinity/Eve/EveRootTransform.cpp @@ -6,7 +6,7 @@ #include -EveRootTransform::EveRootTransform( IRoot* lockobj ): +EveRootTransform::EveRootTransform( IRoot* lockobj ) : m_boundingSphereRadius( -1.0f ), m_lastUpdateMatrix( IdentityMatrix() ) { @@ -70,7 +70,7 @@ void EveRootTransform::Update( const EveUpdateContext& updateContext ) void EveRootTransform::UpdateViewDependentData( const TriFrustum& frustum, const Matrix& /*parentTransform*/ ) { // parentTransform is identity, since we're the root transform - EveTransform::UpdateViewDependentData( frustum, m_lastUpdateMatrix ); + EveTransform::UpdateViewDependentData( frustum, m_lastUpdateMatrix ); } // -------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ int EveRootTransform::GetClosestDamageLocatorIndex( const Vector3* position ) return 0; } -int EveRootTransform::GetGoodDamageLocatorIndex( const Vector3 &position ) +int EveRootTransform::GetGoodDamageLocatorIndex( const Vector3& position ) { return 0; } @@ -142,13 +142,13 @@ bool EveRootTransform::UpdateImpact( Vector3& out, const Vector3& direction, int void EveRootTransform::GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ) { - GetDamageLocatorPosition(out, -1, true ); - - if( hit && source ) + GetDamageLocatorPosition( out, -1, true ); + + if( hit && source ) { Vector3 local( *hit - *out ); Vector3 dir = Normalize( *hit - *source ); - + local -= dir * Dot( dir, local ); local = Normalize( local ); diff --git a/trinity/Eve/EveRootTransform.h b/trinity/Eve/EveRootTransform.h index 77a75b7aa..f6b70a75c 100644 --- a/trinity/Eve/EveRootTransform.h +++ b/trinity/Eve/EveRootTransform.h @@ -13,12 +13,11 @@ BLUE_DECLARE( EveRootTransform ); BLUE_DECLARE_INTERFACE( ITriVectorFunction ); BLUE_DECLARE_INTERFACE( ITriQuaternionFunction ); -class EveRootTransform: - public EveTransform, - public ITriTargetable +class EveRootTransform : public EveTransform, + public ITriTargetable { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using EveTransform::Lock; using EveTransform::Unlock; @@ -58,7 +57,10 @@ class EveRootTransform: // last known results from updating m_ballPosition and m_ballRotation Matrix m_lastUpdateMatrix; - float GetBoundingSphereRadius() { return m_boundingSphereRadius; } + float GetBoundingSphereRadius() + { + return m_boundingSphereRadius; + } }; TYPEDEF_BLUECLASS( EveRootTransform ); diff --git a/trinity/Eve/EveRootTransform_Blue.cpp b/trinity/Eve/EveRootTransform_Blue.cpp index 8cdd4276a..2f98d7f7b 100644 --- a/trinity/Eve/EveRootTransform_Blue.cpp +++ b/trinity/Eve/EveRootTransform_Blue.cpp @@ -7,72 +7,56 @@ BLUE_DEFINE( EveRootTransform ); const Be::ClassInfo* EveRootTransform::ExposeToBlue() { - EXPOSURE_BEGIN( EveRootTransform, "" ) - MAP_INTERFACE( EveRootTransform ) + EXPOSURE_BEGIN( EveRootTransform, "" ) + MAP_INTERFACE( EveRootTransform ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITriTargetable ) MAP_INTERFACE( ITr2Pickable ) MAP_INTERFACE( IWorldPosition ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translationCurve", m_ballPosition, "Vector function slot for attaching a destiny ball to set the position of an object", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotationCurve", m_ballRotation, "Quaternion function slot for attaching a destiny ball to set the rotation of an object", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "modelRotationCurve", m_modelRotation, "Used to add rotations to the basic rotation curve", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "modelTranslationCurve", m_modelTranslation, "Used to add animated translations to ships", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "children", m_children, "", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphereRadius, "authorable bounding sphere radius, used by the camera in Eve", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "observers", - m_observers, + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "observers", + m_observers, "Observers for pushing data between modules every frame. Currently used to push locator data out to the audio2 module.", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "lodLevel", m_lodLevel, "the object's active LOD", - Be::READ - ) - MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, "Returns the bounding sphere radius." ) + Be::READ ) + MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, "Returns the bounding sphere radius." ) - EXPOSURE_CHAINTO( Tr2Transform ) + EXPOSURE_CHAINTO( Tr2Transform ) // Note that the chaining skips over EveTransform. This is done to convince Jessica // to only allow EveTransform objects as children of this, not other EveRootTransform diff --git a/trinity/Eve/EveSpaceScene.cpp b/trinity/Eve/EveSpaceScene.cpp index 50dd06de8..df06d846d 100644 --- a/trinity/Eve/EveSpaceScene.cpp +++ b/trinity/Eve/EveSpaceScene.cpp @@ -121,16 +121,15 @@ TRI_REGISTER_SETTING( "enablePostProcessDebugging", g_enablePostProcessDebugging namespace { -const char* VISUALIZER_EFFECT_PATH[EveSpaceScene::VM_COUNT] = - { - "", - "res:/Graphics/Effect/Managed/Space/Visualizer/Texcoord0.fx", - "res:/Graphics/Effect/Managed/Space/Visualizer/Texcoord1.fx", - "res:/Graphics/Effect/Managed/Space/Visualizer/White.fx", - "res:/Graphics/Effect/Managed/Space/Visualizer/Overdraw.fx", - "res:/Graphics/Effect/Managed/Space/Visualizer/Wireframe.fx", - "res:/Graphics/Effect/Managed/Space/Visualizer/LightCount.fx", - }; +const char* VISUALIZER_EFFECT_PATH[EveSpaceScene::VM_COUNT] = { + "", + "res:/Graphics/Effect/Managed/Space/Visualizer/Texcoord0.fx", + "res:/Graphics/Effect/Managed/Space/Visualizer/Texcoord1.fx", + "res:/Graphics/Effect/Managed/Space/Visualizer/White.fx", + "res:/Graphics/Effect/Managed/Space/Visualizer/Overdraw.fx", + "res:/Graphics/Effect/Managed/Space/Visualizer/Wireframe.fx", + "res:/Graphics/Effect/Managed/Space/Visualizer/LightCount.fx", +}; TriFrustum CreatePickingFrustum() { @@ -318,7 +317,7 @@ EveSpaceScene::~EveSpaceScene() { CCP_DELETE( it->second ); } - CCP_DELETE( m_pickingBatches ); + CCP_DELETE( m_pickingBatches ); ClearComponentRegistry(); } @@ -411,8 +410,6 @@ void EveSpaceScene::UpdatePostProcessAttributes() { m_combinedPostProcess = nullptr; } - - } BluePy EveSpaceScene::GetPostProcessDebug() const @@ -443,7 +440,7 @@ void EveSpaceScene::Update( Be::Time realTime, Be::Time simTime ) auto frame = renderContext.GetRecordingFrameNumber(); Tr2RingBuffer::GetInstance().SetFrameNumbers( frame, renderContext.GetRenderedFrameNumber() ); Tr2RingBuffer::GetInstance().SetFrameNumbers( frame, renderContext.GetRenderedFrameNumber() ); - + if( frame == m_lastUpdateFrame ) { // already updated this frame @@ -488,7 +485,7 @@ void EveSpaceScene::Update( Be::Time realTime, Be::Time simTime ) { CCP_STATS_ZONE( "UpdateBackgroundObjects" ); - + for( auto it = m_backgroundObjects.begin(); it != m_backgroundObjects.end(); ++it ) { ( *it )->UpdateSyncronous( m_updateContext ); @@ -564,11 +561,11 @@ void EveSpaceScene::Update( Be::Time realTime, Be::Time simTime ) Tr2ParallelTaskGroup taskGroup = {}; m_updateContext.SetTaskGroup( &taskGroup ); - + for( auto& object : m_objects ) { taskGroup.run( [object, this] { - object->UpdateAsyncronous( m_updateContext ); + object->UpdateAsyncronous( m_updateContext ); } ); } for( auto& object : m_uiObjects ) @@ -583,7 +580,7 @@ void EveSpaceScene::Update( Be::Time realTime, Be::Time simTime ) } ExecuteMainThreadActions(); - // update the combined postprocess attributes + // update the combined postprocess attributes UpdatePostProcessAttributes(); // Update the sun direction from the ball @@ -598,7 +595,7 @@ void EveSpaceScene::Update( Be::Time realTime, Be::Time simTime ) m_sunData.DirWorld = -sunDirection; } - + // every space scene has a reference position Vector3d sceneReferencePoint = m_updateContext.GetOrigin(); @@ -636,28 +633,27 @@ EveSpaceScene::ShadowResources EveSpaceScene::SetupCascadedShadows( Tr2RenderRea // projection._22 // = -2.0f * zn / ( b - t ) // projection._31 // = 1.0f + 2.0f * l / ( r - l ) // projection._32 // = -1.0f - 2.0f * t / ( b - t ) - float rightMinusLeft = 2.f / projection._11; // = ( r - l ) / zn - float bottomMinusTop = 2.f / -projection._22; // = ( b - t ) / zn - float left = ( projection._31 - 1.f ) / 2.f * rightMinusLeft; // = l / zn - float top = ( -projection._32 - 1.f ) / 2.f * bottomMinusTop; // = t / zn - float right = rightMinusLeft + left; // = r / zn - float bottom = bottomMinusTop + top; // = b / zn + float rightMinusLeft = 2.f / projection._11; // = ( r - l ) / zn + float bottomMinusTop = 2.f / -projection._22; // = ( b - t ) / zn + float left = ( projection._31 - 1.f ) / 2.f * rightMinusLeft; // = l / zn + float top = ( -projection._32 - 1.f ) / 2.f * bottomMinusTop; // = t / zn + float right = rightMinusLeft + left; // = r / zn + float bottom = bottomMinusTop + top; // = b / zn auto sunDir = m_sunData.DirWorld; // set up frustums for( unsigned int splitIndex = 0; splitIndex < SHADOW_FRUSTUM_COUNT; ++splitIndex ) { - ShadowMap::SplitSetup splitSetupInfo = shadowMap.SetupShadowSplit( splitIndex, Tr2Renderer::GetInverseViewTransform(), - m_sunData.DirWorld, viewFrustum.m_zNear, left, right, top, bottom ); + ShadowMap::SplitSetup splitSetupInfo = shadowMap.SetupShadowSplit( splitIndex, Tr2Renderer::GetInverseViewTransform(), m_sunData.DirWorld, viewFrustum.m_zNear, left, right, top, bottom ); // Get the split up camera frustum so we can use it to do some "half space culling" for objects - TriFrustum frustum = m_updateContext.GetFrustum(); + TriFrustum frustum = m_updateContext.GetFrustum(); const Matrix viewProj = Inverse( splitSetupInfo.invViewProj ); frustum.ExtractFrustum( &viewProj ); cameraFrustums[splitIndex] = frustum; - shadowFrustums[splitIndex] = TriShadowOrthoFrustum( splitSetupInfo.shadowFrustum, shadowMapSize, sunDir ) ; + shadowFrustums[splitIndex] = TriShadowOrthoFrustum( splitSetupInfo.shadowFrustum, shadowMapSize, sunDir ); splitSetup[splitIndex] = splitSetupInfo; } @@ -730,7 +726,6 @@ EveSpaceScene::ShadowResources EveSpaceScene::SetupCascadedShadows( Tr2RenderRea { info.caster->GetShadowBatches( m_shadowBatches[frustumIndex].get(), info.perObjectData, info.radius ); } - } ); } @@ -757,7 +752,7 @@ EveSpaceScene::ShadowResources EveSpaceScene::SetupCascadedShadows( Tr2RenderRea m_shadowBatches[i]->Clear(); m_shadowAllocators[i].Clear(); continue; - } + } shadowMap.BeginShadowRendering( renderContext, i ); @@ -884,8 +879,8 @@ void GetBatchesFromRenderables( Tr2RenderableSortList* const objectsWithTransparencies, EveSpaceScene::BatchMap& batches, EveSpaceScene::PerThreadBatchMap& perThreadBatches, - const TriBatchType* batchTypes, - const unsigned batchTypeCount, + const TriBatchType* batchTypes, + const unsigned batchTypeCount, Tr2RenderReason reason ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -962,14 +957,13 @@ void EveSpaceScene::GetAllBatchesFromRenderables( std::vector& return; } - static const TriBatchType s_allTypes[] = - { - TRIBATCHTYPE_OPAQUE, - TRIBATCHTYPE_DECAL, - TRIBATCHTYPE_ADDITIVE, - TRIBATCHTYPE_DEPTH, - TRIBATCHTYPE_DISTORTION - }; + static const TriBatchType s_allTypes[] = { + TRIBATCHTYPE_OPAQUE, + TRIBATCHTYPE_DECAL, + TRIBATCHTYPE_ADDITIVE, + TRIBATCHTYPE_DEPTH, + TRIBATCHTYPE_DISTORTION + }; unsigned typeCount = unsigned( sizeof( s_allTypes ) / sizeof( s_allTypes[0] ) ); if( !includeDistortions ) @@ -996,11 +990,10 @@ void EveSpaceScene::GetOpaqueBatchesFromRenderables( std::vector return; } - static const TriBatchType s_allTypes[] = - { - TRIBATCHTYPE_DEPTH - }; + static const TriBatchType s_allTypes[] = { + TRIBATCHTYPE_DEPTH + }; ::GetBatchesFromRenderables( &objectRenderables[0], (unsigned int)objectRenderables.size(), nullptr, batches, m_perThreadBatches, s_allTypes, 1, reason ); } @@ -1047,11 +1039,10 @@ void EveSpaceScene::GetTransparentBatchesFromRenderables( std::vector allObjects; std::vector renderables; Tr2RenderableSortList transparentObjects; @@ -1460,16 +1451,17 @@ void EveSpaceScene::GatherBatches( bool includeDistortions, Tr2RenderContext& re m_cameraAttachmentParent->UpdateAsyncronous( m_updateContext ); m_cameraAttachmentParent->UpdateVisibility( m_updateContext, identity ); - Tr2ParallelDo( m_staticParticles.begin(), m_staticParticles.end(), [&]( EveSceneStaticParticles* staticParticles ){ + Tr2ParallelDo( m_staticParticles.begin(), m_staticParticles.end(), [&]( EveSceneStaticParticles* staticParticles ) { staticParticles->UpdateVisibility( m_updateContext ); } ); - + Tr2ParallelDo( m_planets.begin(), m_planets.end(), [&]( EvePlanet* obj ) { obj->UpdateZOnlyVisibility( m_updateContext ); } ); // until we have proper support for multiple lensflares we just do it in a list... - for( auto& lensflare : m_lensflares ){ + for( auto& lensflare : m_lensflares ) + { lensflare->UpdateVisibility( m_updateContext ); } } @@ -1523,12 +1515,7 @@ void EveSpaceScene::GatherBatches( bool includeDistortions, Tr2RenderContext& re m_instancedMeshManager->CollectMeshes( *m_componentRegistry ); - m_instancedMeshManager->GetBatches( m_updateContext.GetFrustum(), m_updateContext.GetInvLodFactor(), { - { TRIBATCHTYPE_OPAQUE, *m_primaryBatches[TRIBATCHTYPE_OPAQUE] }, - { TRIBATCHTYPE_DECAL, *m_primaryBatches[TRIBATCHTYPE_DECAL] }, - { TRIBATCHTYPE_ADDITIVE, *m_primaryBatches[TRIBATCHTYPE_ADDITIVE] }, - { TRIBATCHTYPE_DEPTH, *m_primaryBatches[TRIBATCHTYPE_DEPTH] }, - { TRIBATCHTYPE_DISTORTION, *m_primaryBatches[TRIBATCHTYPE_DISTORTION] } } ); + m_instancedMeshManager->GetBatches( m_updateContext.GetFrustum(), m_updateContext.GetInvLodFactor(), { { TRIBATCHTYPE_OPAQUE, *m_primaryBatches[TRIBATCHTYPE_OPAQUE] }, { TRIBATCHTYPE_DECAL, *m_primaryBatches[TRIBATCHTYPE_DECAL] }, { TRIBATCHTYPE_ADDITIVE, *m_primaryBatches[TRIBATCHTYPE_ADDITIVE] }, { TRIBATCHTYPE_DEPTH, *m_primaryBatches[TRIBATCHTYPE_DEPTH] }, { TRIBATCHTYPE_DISTORTION, *m_primaryBatches[TRIBATCHTYPE_DISTORTION] } } ); FinalizeBatches( m_primaryBatches ); @@ -1910,14 +1897,14 @@ void EveSpaceScene::RenderReflectionPass( Tr2GpuResourcePool& gpuResourcePool, T ClearBatches( m_secondaryBatches ); bool hasInstancedBatches = m_instancedMeshManager->GetBatches( - m_updateContext.GetFrustum(), - m_updateContext.GetInvLodFactor(), - { - { TRIBATCHTYPE_OPAQUE, *m_secondaryBatches[TRIBATCHTYPE_OPAQUE] }, - { TRIBATCHTYPE_DECAL, *m_secondaryBatches[TRIBATCHTYPE_DECAL] }, - { TRIBATCHTYPE_ADDITIVE, *m_secondaryBatches[TRIBATCHTYPE_ADDITIVE] }, - { TRIBATCHTYPE_DEPTH, *m_secondaryBatches[TRIBATCHTYPE_DEPTH] }, - } ) > 0; + m_updateContext.GetFrustum(), + m_updateContext.GetInvLodFactor(), + { + { TRIBATCHTYPE_OPAQUE, *m_secondaryBatches[TRIBATCHTYPE_OPAQUE] }, + { TRIBATCHTYPE_DECAL, *m_secondaryBatches[TRIBATCHTYPE_DECAL] }, + { TRIBATCHTYPE_ADDITIVE, *m_secondaryBatches[TRIBATCHTYPE_ADDITIVE] }, + { TRIBATCHTYPE_DEPTH, *m_secondaryBatches[TRIBATCHTYPE_DEPTH] }, + } ) > 0; if( hasFog || !visibleRenderables.empty() || hasInstancedBatches ) { @@ -2033,10 +2020,10 @@ bool EveSpaceScene::RenderBackgroundPass( const Tr2TextureAL& depthMap, const Tr TriFrustum frustum; Matrix planetProjection = EveCamera::ModifyClipPlanes( Tr2Renderer::GetProjectionTransform(), 0.01f, 1e5f ); frustum.DeriveFrustum( &Tr2Renderer::GetViewTransform(), &Tr2Renderer::GetViewPosition(), &planetProjection, renderContext.m_esm.GetViewport() ); - + auto normalFrustum = m_updateContext.GetFrustum(); - m_updateContext.SetFrustum(frustum); + m_updateContext.SetFrustum( frustum ); for( auto it = m_planets.begin(); it != m_planets.end(); ++it ) { @@ -2107,7 +2094,7 @@ bool EveSpaceScene::RenderBackgroundPassObjects( const Tr2TextureAL& depthMap, c renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE ); Tr2Renderer::DrawCameraSpaceScreenQuad( renderContext, m_backgroundEffect->GetShaderStateInterface(), m_backgroundEffect ); - + if( reason == BACKGROUND_RENDER_REFLECTION ) { // Reset the nebula intensity to the original one @@ -2207,7 +2194,7 @@ bool EveSpaceScene::RenderBackgroundPassObjects( const Tr2TextureAL& depthMap, c void EveSpaceScene::RenderDepthPass( const Tr2TextureAL& depthMap, const Tr2TextureAL& normalMap, const Tr2TextureAL& customStencil, Tr2RenderContext& renderContext, const BlueSharedString& techniqueName ) { CCP_STATS_ZONE( __FUNCTION__ ); - + if( !m_display ) { return; @@ -2359,13 +2346,12 @@ void EveSpaceScene::RenderDepthPass( const Tr2TextureAL& depthMap, const Tr2Text m_volumetricsRenderer->SetPlanets( planets, maxPlanets ); } - } void EveSpaceScene::RenderVolumetricShadowMap( Tr2RenderContext& renderContext ) { CCP_STATS_ZONE( __FUNCTION__ ); - + auto shadowCasters = m_componentRegistry->GetComponents(); m_componentRegistry->ProcessComponents( [this, &renderContext, &shadowCasters]( ITr2VolumetricRenderable* volumetric ) -> void { @@ -2470,14 +2456,14 @@ std::pair EveSpaceScen m_viewLast, m_projectionLast ); - auto clouds = m_volumetricsRenderer->RenderVolumetrics( - *m_componentRegistry, - m_updateContext.GetFrustum(), + auto clouds = m_volumetricsRenderer->RenderVolumetrics( + *m_componentRegistry, + m_updateContext.GetFrustum(), depthMap, - froxelFog, + froxelFog, m_sunData.DirWorld, - m_perFramePS.VolumetricSlices, - m_shadowQuality == ShadowQuality::SHADOW_RAYTRACED && m_enableShadows, + m_perFramePS.VolumetricSlices, + m_shadowQuality == ShadowQuality::SHADOW_RAYTRACED && m_enableShadows, gpuResourcePool, renderContext ); return { froxelFog, clouds }; @@ -2498,15 +2484,15 @@ bool EveSpaceScene::PrepareShadowMapForLights( Tr2RenderContext& renderContext, return true; } -void EveSpaceScene::RenderShadowMapForSpotLight( - Tr2RenderContext& renderContext, - const std::vector& shadowCasters, - uint32_t shadowMapScale, - uint32_t shadowMapOffsetX, - uint32_t shadowMapOffsetY, - const Vector3& lightPosition, - const Matrix& view, - const Matrix& projection, +void EveSpaceScene::RenderShadowMapForSpotLight( + Tr2RenderContext& renderContext, + const std::vector& shadowCasters, + uint32_t shadowMapScale, + uint32_t shadowMapOffsetX, + uint32_t shadowMapOffsetY, + const Vector3& lightPosition, + const Matrix& view, + const Matrix& projection, const Tr2TextureAL& shadowMap ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -2514,9 +2500,9 @@ void EveSpaceScene::RenderShadowMapForSpotLight( renderContext.m_esm.PushViewport(); renderContext.m_esm.UpdateRenderTargetViewport( shadowMap.GetWidth(), shadowMap.GetHeight() ); renderContext.m_esm.SetViewport( shadowMapScale, shadowMapScale, shadowMapOffsetX, shadowMapOffsetY, 0, 1 ); - + const float margin = 16.f; - const float marginScale = 1.f - (margin / shadowMapScale); + const float marginScale = 1.f - ( margin / shadowMapScale ); const Matrix marginMatrix = ScalingMatrix( Vector3( marginScale, marginScale, 1.f ) ); const Matrix viewProj = view * projection * marginMatrix; @@ -2532,7 +2518,7 @@ void EveSpaceScene::RenderShadowMapForSpotLight( if( sizeInShadow > 5.0f ) { auto perObjData = caster->GetShadowPerObjectData( m_shadowBatches[0].get() ); - caster->GetShadowBatches( m_shadowBatches[0].get(), perObjData, min( (float)shadowMapScale, sizeInShadow) ); + caster->GetShadowBatches( m_shadowBatches[0].get(), perObjData, min( (float)shadowMapScale, sizeInShadow ) ); } } @@ -2558,7 +2544,7 @@ void EveSpaceScene::RenderShadowMapForSpotLight( renderContext.m_esm.SetInvertedDepthTest( true ); ON_BLOCK_EXIT( [&] { renderContext.m_esm.SetInvertedDepthTest( false ); } ); } - + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE ); renderContext.RenderBatches( m_shadowBatches[0].get(), BlueSharedString( "DynamicLightShadow" ) ); } @@ -2575,8 +2561,7 @@ void EveSpaceScene::RenderShadowMapForLight( Tr2RenderContext& renderContext, co { // pointlight Vector3 directions[6] = { - Vector3( 1.f, 0.f, 0.f ), Vector3( 0.f, 1.f, 0.f ), Vector3( 0.f, 0.f, 1.f ), - Vector3( -1.f, 0.f, 0.f ), Vector3( 0.f, -1.f, 0.f ), Vector3( 0.f, 0.f, -1.f ) + Vector3( 1.f, 0.f, 0.f ), Vector3( 0.f, 1.f, 0.f ), Vector3( 0.f, 0.f, 1.f ), Vector3( -1.f, 0.f, 0.f ), Vector3( 0.f, -1.f, 0.f ), Vector3( 0.f, 0.f, -1.f ) }; float fov = 90.f / 360.f * TRI_2PI; // we flip near and far plane for reverse z @@ -2694,12 +2679,12 @@ EveSpaceScene::ShadowResources EveSpaceScene::RenderShadows( const Tr2TextureAL& // Description: // Main rendering of foreground objects. // -------------------------------------------------------------------------------------- -bool EveSpaceScene::RenderMainPass( - const Tr2TextureAL& colorMap, - const Tr2TextureAL& depthMap, - const Tr2TextureAL& distortionMap, - const Tr2TextureAL& velocityMap, - const Tr2TextureAL& opaqueColorMap, +bool EveSpaceScene::RenderMainPass( + const Tr2TextureAL& colorMap, + const Tr2TextureAL& depthMap, + const Tr2TextureAL& distortionMap, + const Tr2TextureAL& velocityMap, + const Tr2TextureAL& opaqueColorMap, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) { @@ -2708,12 +2693,12 @@ bool EveSpaceScene::RenderMainPass( bool hasForegroundDistortionBatches = false; renderContext.m_esm.BeginManagedRendering(); - + if( !m_display ) { return hasForegroundDistortionBatches; } - + renderContext.AddGpuMarker( __FUNCTION__ ); renderContext.SetReadOnlyDepth( true ); @@ -2760,17 +2745,17 @@ bool EveSpaceScene::RenderMainPass( m_sssss->SetupScreenSpaceSubSurfaceScattering( renderContext, m_primaryBatches[TRIBATCHTYPE_OPAQUE], colorMap, opaqueColorMap, depthMap, gpuResourcePool ); Tr2Renderer::SetProjectionTransform( m_jitteredProjection ); - + PopulateAndApplyPerFrameData( renderContext ); auto [froxelFog, volumetricSlices] = RenderVolumetrics( depthMap, gpuResourcePool, renderContext ); GlobalStore().RegisterVariable( "EveSceneFogVolumeMap", volumetricSlices ); GlobalStore().RegisterVariable( "EveSceneFroxelFogMap", froxelFog ); - RenderTransparentBatches( m_primaryBatches, renderContext ); - if( distortionMap.IsValid() ) - { - hasForegroundDistortionBatches = RenderDistortionBatches( m_primaryBatches, distortionMap, depthMap, renderContext ); - } + RenderTransparentBatches( m_primaryBatches, renderContext ); + if( distortionMap.IsValid() ) + { + hasForegroundDistortionBatches = RenderDistortionBatches( m_primaryBatches, distortionMap, depthMap, renderContext ); + } //GPU particles if( GetGpuParticleSystem() ) @@ -2870,7 +2855,7 @@ void EveSpaceScene::EndRender( Tr2RenderContext& renderContext ) // Clear primary batches ClearBatches( m_primaryBatches ); - + // Store the view transform from this frame m_viewLast = Tr2Renderer::GetViewTransform(); m_projectionLast = m_projection; @@ -3125,15 +3110,15 @@ void EveSpaceScene::PopulatePerFramePSData( PerFramePSData& data, Tr2ShadowMap* data.Time = Tr2Renderer::GetAnimationTime(); data.Upscaling = 1.0f; - - data.FrameIndex = (uint32_t) Tr2Renderer::GetCurrentFrameCounter(); - data.Jittering = m_jitter != Vector4(0, 0, 0, 0); - data.ShadowQuality = 1 << (uint32_t) m_shadowQuality; + data.FrameIndex = (uint32_t)Tr2Renderer::GetCurrentFrameCounter(); + data.Jittering = m_jitter != Vector4( 0, 0, 0, 0 ); + + data.ShadowQuality = 1 << (uint32_t)m_shadowQuality; if( auto lightManager = Tr2LightManager::GetInstance() ) { - data.InverseShadowMapAtlasSize = lightManager->GetShadowMapAtlasSettings().actualTextureSize > 0 ? + data.InverseShadowMapAtlasSize = lightManager->GetShadowMapAtlasSettings().actualTextureSize > 0 ? 1.f / lightManager->GetShadowMapAtlasSettings().actualTextureSize : 0.f; data.ShadowMapAtlasEntryMinSizeLog2 = lightManager->GetShadowMapAtlasSettings().entryMinSizeLog2; @@ -3144,7 +3129,7 @@ void EveSpaceScene::PopulatePerFramePSData( PerFramePSData& data, Tr2ShadowMap* data.ShadowMapAtlasEntryMinSizeLog2 = 0; } data.ShadowMapSettings = Vector4( 1.f, 1.f, 0.f, 0.f ); - + data.ShadowLightness = 0; data.DepthMapSampleCount = 1.0f; //legacy @@ -3164,7 +3149,7 @@ void EveSpaceScene::PopulatePerFramePSData( PerFramePSData& data, Tr2ShadowMap* { data.SceneMipLodBias += m_sceneDefaultPostProcess->GetMipLodBias(); } - data.Upscaling = m_upscalingAmount; + data.Upscaling = m_upscalingAmount; } else if( m_sceneDefaultPostProcess ) { @@ -3276,7 +3261,7 @@ bool EveSpaceScene::Initialize() bool EveSpaceScene::OnModified( Be::Var* value ) { if( IsMatch( value, m_reflectionProbe ) || IsMatch( value, m_envMapResPath ) ) - { + { m_staticEnvMapTextureRes.Unlock(); if( m_staticEnvMapHandle ) @@ -3455,8 +3440,7 @@ void EveSpaceScene::OnListModified( } break; - case BELIST_INSERTED: - { + case BELIST_INSERTED: { if( m_shLightingManager ) { ITr2SecondaryLightSourcePtr lightSource = BlueCastPtr( value ); @@ -3480,8 +3464,7 @@ void EveSpaceScene::OnListModified( } } break; - case BELIST_REMOVED: - { + case BELIST_REMOVED: { if( m_shLightingManager ) { ITr2SecondaryLightSourcePtr lightSource = BlueCastPtr( value ); @@ -3765,7 +3748,7 @@ void EveSpaceScene::PerformPicking( EvePickingContext* listener, bool immediate, object = traceback.first; uint32_t instanceID = 0; //Not supported for async queries yet, as it is very hard to reconstruct. uint32_t ownerIndex = traceback.second; - area = instanceID | (ownerIndex << 16); + area = instanceID | ( ownerIndex << 16 ); } } } @@ -3860,11 +3843,11 @@ void EveSpaceScene::RenderPlanets( Tr2RenderContext& renderContext ) ScopeGuard guardPopViewTransform = MakeGuard( Tr2Renderer::PopViewTransform ); Matrix lastPlanetViewMatrix = CreatePlanetViewMatrix( m_viewLast ); - Tr2Renderer::SetViewTransform( CreatePlanetViewMatrix( Tr2Renderer::GetViewTransform() )); - + Tr2Renderer::SetViewTransform( CreatePlanetViewMatrix( Tr2Renderer::GetViewTransform() ) ); + Matrix planetProjection = EveCamera::ModifyClipPlanes( m_projection, 0.01f, 1e5f ) * m_jitterMatrix; Matrix lastPlanetProjection = EveCamera::ModifyClipPlanes( m_projectionLast, 0.01f, 1e5f ) * m_jitterMatrix; //apply the same transformations and jitter to both so that they all cancel out. - + Tr2Renderer::SetProjectionTransform( planetProjection ); std::vector planetRenderables; @@ -3940,7 +3923,7 @@ void EveSpaceScene::ClearRenderTargetIfNoBatches( const Tr2TextureAL& rt, uint32 void EveSpaceScene::SetupPlanetsAsShadowCaster( CcpMath::Sphere* planets, size_t maxPlanets ) { Vector3 sunPosition = { 0, 0, 0 }; - if ( m_sunBall ) + if( m_sunBall ) { m_sunBall->GetValueAt( &sunPosition, m_updateContext.GetTime() ); } @@ -3984,7 +3967,7 @@ void EveSpaceScene::SetupPlanetsAsShadowCaster( CcpMath::Sphere* planets, size_t // cut unnecessary objects from the list, or if we only have 1 planet the other index is just filled with 0 values visiblePlanets.resize( maxPlanets ); - for( size_t i = 0 ; i < maxPlanets ; i++ ) + for( size_t i = 0; i < maxPlanets; i++ ) { planets[i] = CcpMath::Sphere( visiblePlanets[i].sphere ); } @@ -4191,7 +4174,7 @@ void EveSpaceScene::ProcessOutdatedRTAnimations( Tr2RenderContext& renderContext std::vector pointsLightDatas; std::vector spotLightFrustums; - + // Process other lights if( auto lightManager = Tr2LightManager::GetInstance() ) { @@ -4221,8 +4204,7 @@ void EveSpaceScene::ProcessOutdatedRTAnimations( Tr2RenderContext& renderContext } // Find all casters and mark those that are casting shadows as dirty so RT can rebuild it - m_componentRegistry->ProcessComponents( [&]( IEveShadowCaster* caster ) -> void - { + m_componentRegistry->ProcessComponents( [&]( IEveShadowCaster* caster ) -> void { if( caster->IsShadowCastingDirty() ) { return; @@ -4237,7 +4219,7 @@ void EveSpaceScene::ProcessOutdatedRTAnimations( Tr2RenderContext& renderContext } } - + for( auto lightData : pointsLightDatas ) { if( caster->IsCastingShadow( m_updateContext.GetFrustum(), lightData->position, lightData->radius, TR2RENDERREASON_NORMAL ) ) @@ -4246,7 +4228,7 @@ void EveSpaceScene::ProcessOutdatedRTAnimations( Tr2RenderContext& renderContext return; } } - + for( const auto& shadowFrustum : spotLightFrustums ) { float sizeInShadow = 0.0f; @@ -4266,12 +4248,12 @@ void RegisterWithVariableStore( const EveSpaceScene::ShadowResources& shadowReso const uint8_t whiteR8[1] = { 255 }; Tr2SubresourceData initData = { whiteR8, 1, 1 }; - GlobalStore().RegisterVariable( - "EveSpaceSceneShadowMap", + GlobalStore().RegisterVariable( + "EveSpaceSceneShadowMap", shadowResources.shadowMap.IsValid() ? shadowResources.shadowMap : gpuResourcePool.GetPersistentTexture( "EmptyShadow", 1, 1, ImageIO::PIXEL_FORMAT_R8_UNORM, Tr2GpuUsage::SHADER_RESOURCE, &initData ) ); GlobalStore().RegisterVariable( "EveSpaceSceneCascadedShadowMap", shadowResources.cascadedShadowDepth ); GlobalStore().RegisterVariable( - "EveSpaceSceneDynamicShadowMap", - shadowResources.pointLightShadowMap.IsValid() ? shadowResources.pointLightShadowMap : gpuResourcePool.GetPersistentTexture( "EmptyShadowUint", 1, 1, ImageIO::PIXEL_FORMAT_R8_UINT, Tr2GpuUsage::SHADER_RESOURCE, &initData ) ); + "EveSpaceSceneDynamicShadowMap", + shadowResources.pointLightShadowMap.IsValid() ? shadowResources.pointLightShadowMap : gpuResourcePool.GetPersistentTexture( "EmptyShadowUint", 1, 1, ImageIO::PIXEL_FORMAT_R8_UINT, Tr2GpuUsage::SHADER_RESOURCE, &initData ) ); GlobalStore().RegisterVariable( "ShadowMapAtlas", shadowResources.pointLightShadowDepth ); } diff --git a/trinity/Eve/EveSpaceScene.h b/trinity/Eve/EveSpaceScene.h index f67f35974..5a9d88cec 100644 --- a/trinity/Eve/EveSpaceScene.h +++ b/trinity/Eve/EveSpaceScene.h @@ -116,7 +116,7 @@ BLUE_CLASS( EveSpaceScene ) : ////////////////////////////////////////////////////////////////////////////////////// // ITr2Scene virtual void Update( Be::Time realTime, Be::Time simTime ); - virtual void Render( Tr2RenderContext& renderContext ); + virtual void Render( Tr2RenderContext & renderContext ); virtual void RenderDebugInfo( Tr2RenderContext & renderContext ); @@ -133,26 +133,26 @@ BLUE_CLASS( EveSpaceScene ) : }; ShadowResources RenderShadows( const Tr2TextureAL& depthMap, const Tr2TextureAL& normalMap, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); - bool RenderMainPass( - const Tr2TextureAL& colorMap, - const Tr2TextureAL& depthMap, - const Tr2TextureAL& distortionMap, - const Tr2TextureAL& velocityMap, - const Tr2TextureAL& opaqueColorMap, + bool RenderMainPass( + const Tr2TextureAL& colorMap, + const Tr2TextureAL& depthMap, + const Tr2TextureAL& distortionMap, + const Tr2TextureAL& velocityMap, + const Tr2TextureAL& opaqueColorMap, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); void RunLensflareOcclusionQueries( const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext ); void RenderDepthPass( const Tr2TextureAL& depthMap, const Tr2TextureAL& normalMap, const Tr2TextureAL& customStencil, Tr2RenderContext& renderContext, const BlueSharedString& techniqueName = BlueSharedString( "Depth" ) ); bool RenderBackgroundPass( const Tr2TextureAL& depthMap, const Tr2TextureAL& distortionMap, const Tr2TextureAL& velocityMap, Tr2RenderContext& renderContext ); - void RenderReflectionPass( Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); - void BeginRender( bool enableDistortion, Tr2RenderContext & renderContext ); + void RenderReflectionPass( Tr2GpuResourcePool & gpuResourcePool, Tr2RenderContext & renderContext ); + void BeginRender( bool enableDistortion, Tr2RenderContext& renderContext ); void EndRender( Tr2RenderContext & renderContext ); void Render3DUI( Tr2RenderContext & renderContext ); void PopulateAndApplyPerFrameData( Tr2RenderContext & renderContext ); - void ApplyUpscalingToPerFrameData( uint32_t width, uint32_t height, Tr2RenderContext & renderContext ); + void ApplyUpscalingToPerFrameData( uint32_t width, uint32_t height, Tr2RenderContext& renderContext ); - void GatherBatches( bool includeDistortions, Tr2RenderContext & renderContext ); + void GatherBatches( bool includeDistortions, Tr2RenderContext& renderContext ); void PrepareRaytracedShadows( Tr2RenderContext & renderContext ); ////////////////////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ BLUE_CLASS( EveSpaceScene ) : ////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, @@ -224,7 +224,7 @@ BLUE_CLASS( EveSpaceScene ) : struct ShadowInfo { - ShadowInfo( float radius, IEveShadowCaster* caster, Tr2PerObjectData* perObjectData ): + ShadowInfo( float radius, IEveShadowCaster* caster, Tr2PerObjectData* perObjectData ) : radius( radius ), caster( caster ), perObjectData( perObjectData ) @@ -277,9 +277,9 @@ BLUE_CLASS( EveSpaceScene ) : uint32_t FrameIndex; uint32_t Jittering; //0 if off, 1 if on - float InverseShadowMapAtlasSize; // shadow map atlas for dynamic lights - uint32_t ShadowMapAtlasEntryMinSizeLog2; // shadow map atlas for dynamic lights - + float InverseShadowMapAtlasSize; // shadow map atlas for dynamic lights + uint32_t ShadowMapAtlasEntryMinSizeLog2; // shadow map atlas for dynamic lights + float VolumetricSlices[4]; // Cascaded shadow maps @@ -313,7 +313,7 @@ BLUE_CLASS( EveSpaceScene ) : // pass sun data to vertexshader, so certain lighting-calculations can be done per-vertex and not per-pixel SunData Sun; Vector3 FogFactors; - float pad; + float pad; // pass resolution to vertexshader, can be usefull in some crazy shaders Vector2 TargetResolution; // pass fov x and y @@ -334,7 +334,7 @@ BLUE_CLASS( EveSpaceScene ) : struct PlanetInfo { - Vector4 sphere = Vector4(0,0,0,0); + Vector4 sphere = Vector4( 0, 0, 0, 0 ); float pixelSize = 0.0; }; EvePlanetPerObjData m_planetPerObjData; @@ -342,21 +342,21 @@ BLUE_CLASS( EveSpaceScene ) : void PopulatePerFrameVSData( PerFrameVSData & data, Tr2RenderContext & renderContext ); void PopulatePerFramePSData( PerFramePSData & data, Tr2RenderContext & renderContext ); - void PopulatePerFramePSData( PerFramePSData & data, Tr2ShadowMap* shadowMap, Tr2RenderContext & renderContext ); + void PopulatePerFramePSData( PerFramePSData & data, Tr2ShadowMap * shadowMap, Tr2RenderContext & renderContext ); void ApplyPerFrameData( Tr2RenderContext & renderContext ); - void UpdatePlanets( const EveUpdateContext & updateContext ); + void UpdatePlanets( const EveUpdateContext& updateContext ); void RenderPlanets( Tr2RenderContext & renderContext ); void RenderDistortion( Tr2RenderContext & renderContext ); Matrix CreatePlanetViewMatrix( const Matrix& original ); - void SetupPlanetsAsShadowCaster( CcpMath::Sphere* planets, size_t maxPlanets ); + void SetupPlanetsAsShadowCaster( CcpMath::Sphere * planets, size_t maxPlanets ); void SetupPlanetsAsShadowCaster( Tr2RenderContext & renderContext ); // Batch gathering and preparation - void GetAllBatchesFromRenderables( std::vector & objectRenderables, Tr2RenderableSortList & objectsWithTransparencies, bool includeDistortions, BatchMap & batches, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + void GetAllBatchesFromRenderables( std::vector & objectRenderables, Tr2RenderableSortList & objectsWithTransparencies, bool includeDistortions, BatchMap& batches, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); void GetOpaqueBatchesFromRenderables( std::vector & objectRenderables, BatchMap & batches, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); void GetDepthBatchesFromRenderables( std::vector & objectRenderables, BatchMap & batches, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); void GetTransparentBatchesFromRenderables( std::vector & objectRenderables, Tr2RenderableSortList & objectsWithTransparencies, bool includeDistortions, BatchMap& batches, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); @@ -366,7 +366,7 @@ BLUE_CLASS( EveSpaceScene ) : void RenderOpaqueBatches( BatchMap & batches, Tr2RenderContext & renderContext ); void RenderTransparentBatches( BatchMap & batches, Tr2RenderContext & renderContext ); void RenderTransparentBatches2( BatchMap & batches, Tr2RenderContext & renderContext, bool pass ); - bool RenderDistortionBatches( BatchMap& batches, const Tr2TextureAL& distortionMap, const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext ); + bool RenderDistortionBatches( BatchMap & batches, const Tr2TextureAL& distortionMap, const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext ); // Utility rendering functions void RenderBatch( ITriRenderBatchAccumulator * batch, @@ -405,14 +405,14 @@ BLUE_CLASS( EveSpaceScene ) : Tr2ShadowMapPtr m_cascadedShadowMap; Tr2ShadowMapPtr m_reflectionShadowMap; - PIEveSpaceObject2Vector m_backgroundObjects; - PEvePlanetVector m_planets; + PIEveSpaceObject2Vector m_backgroundObjects; + PEvePlanetVector m_planets; PIEveSpaceObject2Vector m_objects; PIEveSpaceObject2Vector m_uiObjects; - IEveSpaceObject2Ptr m_warpTunnel; - PTriCurveSetVector m_curveSets; - PEveLensflareVector m_lensflares; - EveUpdateContext m_updateContext; + IEveSpaceObject2Ptr m_warpTunnel; + PTriCurveSetVector m_curveSets; + PEveLensflareVector m_lensflares; + EveUpdateContext m_updateContext; PEveDistanceFieldVector m_distanceFields; // Primary batches, gathered in BeginRender and @@ -464,16 +464,16 @@ BLUE_CLASS( EveSpaceScene ) : CTr2RuntimeGpuBuffer m_sharedIndexVertexBufferWrapper; Tr2Variable m_sharedIndexVertexBufferVar; - + CTr2RuntimeGpuBuffer m_bakedMorphTargetBufferWrapper; Tr2Variable m_bakedMorphTargetBufferVar; - + Tr2Variable m_depthMapVar; Tr2SSSSSPtr m_sssss; // has the velocity map been written to? - bool m_velocityMapDirty; + bool m_velocityMapDirty; void ClearRenderTargetIfNoBatches( const Tr2TextureAL& rt, uint32_t slot, Tr2RenderContext& renderContext, size_t batchCount ); @@ -533,9 +533,9 @@ BLUE_CLASS( EveSpaceScene ) : Be::Time m_updateTime; EveSpaceObject2Ptr m_egoBall; - Tr2ConstantBufferAL m_perFrameVSBuffer; - Tr2ConstantBufferAL m_perFramePSBuffer; - Tr2ConstantBufferAL m_shadowPerFrameVSBuffer; + Tr2ConstantBufferAL m_perFrameVSBuffer; + Tr2ConstantBufferAL m_perFramePSBuffer; + Tr2ConstantBufferAL m_shadowPerFrameVSBuffer; // Cascaded shadows ShadowResources SetupCascadedShadows( Tr2RenderReason renderReason, Tr2ShadowMap & shadowMap, const TriFrustum& viewFrustum, const Tr2TextureAL& depthMap, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); @@ -545,10 +545,10 @@ BLUE_CLASS( EveSpaceScene ) : ITriRenderBatchAccumulator* m_pickingBatches; - void SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport, Tr2RenderContext& renderContext ); + void SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport, Tr2RenderContext& renderContext ); void GetPickingObjectsToRender( std::vector & pickableRenderObjects ); - + public: IRoot* PickObject( int x, int y, TriProjection* proj, TriView* view, TriViewport* viewport, Be::OptionalWithDefaultValue filter ); // for use by python, uses default immediate context @@ -560,7 +560,7 @@ BLUE_CLASS( EveSpaceScene ) : void PerformPicking( EvePickingContext * listener, bool immediate, int x, int y, TriProjection* proj, TriView* view, TriViewport* viewport, Tr2PickTypes pickTypes, Tr2PrimaryRenderContext& renderContext ); - + protected: EveStarfieldPtr m_starfield; @@ -623,7 +623,7 @@ BLUE_CLASS( EveSpaceScene ) : float m_upscalingAmount; Vector4 m_jitter; // xy: projection offset, zw: pixel offset - void Jitter( Tr2RenderContext& renderContext ); + void Jitter( Tr2RenderContext & renderContext ); Tr2ImpostorManagerPtr m_impostorManager; @@ -653,15 +653,15 @@ BLUE_CLASS( EveSpaceScene ) : // Dynamic light shadow maps bool PrepareShadowMapForLights( Tr2RenderContext & renderContext, const Tr2TextureAL& shadowMap ); - void RenderShadowMapForSpotLight( - Tr2RenderContext & renderContext, - const std::vector& shadowCasters, - uint32_t shadowMapScale, - uint32_t shadowMapOffsetX, - uint32_t shadowMapOffsetY, - const Vector3& lightPosition, - const Matrix& view, - const Matrix& projection, + void RenderShadowMapForSpotLight( + Tr2RenderContext & renderContext, + const std::vector& shadowCasters, + uint32_t shadowMapScale, + uint32_t shadowMapOffsetX, + uint32_t shadowMapOffsetY, + const Vector3& lightPosition, + const Matrix& view, + const Matrix& projection, const Tr2TextureAL& shadowMap ); void RenderShadowMapForLight( Tr2RenderContext & renderContext, const std::vector& shadowCasters, const Tr2LightManager::PerLightData& lightData, const Tr2TextureAL& shadowMap ); void FinishRenderingShadowMapForLights( Tr2RenderContext & renderContext ); diff --git a/trinity/Eve/EveSpaceSceneRenderDriver.cpp b/trinity/Eve/EveSpaceSceneRenderDriver.cpp index 1740d6a2a..c72520ae5 100644 --- a/trinity/Eve/EveSpaceSceneRenderDriver.cpp +++ b/trinity/Eve/EveSpaceSceneRenderDriver.cpp @@ -29,7 +29,7 @@ void BeginRenderPass( Tr2RenderContext& renderContext, const std::initializer_li } // clear out remaining slots, generously assuming max 4 render targets const uint32_t maxRenderTargets = 4; - for ( ; index < maxRenderTargets; ++index ) + for( ; index < maxRenderTargets; ++index ) { renderContext.m_esm.SetRenderTarget( index++, Tr2TextureAL{} ); } @@ -298,12 +298,12 @@ void EveSpaceSceneRenderDriver::PropagateSettings() bool EveSpaceSceneRenderDriver::Validate( const Span& destDimensions, const Span& outputs, Be::Time realTime, Be::Time simTime ) { - if ( destDimensions.size == 0 ) + if( destDimensions.size == 0 ) { CCP_ASSERT_M( false, "EveSpaceSceneRenderDriver requires at least one destination texture" ); return false; } - if ( !m_enableRendering ) + if( !m_enableRendering ) { return true; } @@ -323,7 +323,7 @@ bool EveSpaceSceneRenderDriver::Validate( const Span& SetupUpscaling( displaySize ); const auto renderSize = GetRenderSize( displaySize ); - if ( m_background ) + if( m_background ) { auto bgDimensions = Tr2BitmapDimensions( renderSize.width, renderSize.height, 1, m_internalPixelFormat ); if( !m_background->Validate( { &bgDimensions, 1 }, {}, realTime, simTime ) ) @@ -331,7 +331,7 @@ bool EveSpaceSceneRenderDriver::Validate( const Span& return false; } } - if ( m_sceneOverlay ) + if( m_sceneOverlay ) { Tr2BitmapDimensions overlayDimensions[] = { Tr2BitmapDimensions( renderSize.width, renderSize.height, 1, m_internalPixelFormat ), @@ -343,7 +343,7 @@ bool EveSpaceSceneRenderDriver::Validate( const Span& } } - for ( auto& output : outputs ) + for( auto& output : outputs ) { if( strcmp( output.c_str(), "DepthMap" ) != 0 && strcmp( output.c_str(), "VelocityMap" ) != 0 && @@ -521,7 +521,7 @@ void EveSpaceSceneRenderDriver::Execute( const Span& destina GlobalStore().RegisterVariable( "SpaceSceneNormalMap", normalMap ); GlobalStore().RegisterVariable( "SpaceSceneCustomStencil", customStencil ); ON_BLOCK_EXIT( [&] { GlobalStore().RegisterVariable( "SpaceSceneCustomStencil", Tr2TextureAL{} ); } ); - + Tr2GpuResourcePool::Texture opaqueBackBuffer; EveSpaceScene::ShadowResources shadowResources; if( m_scene->m_display && m_mainPassRenderingEnabled ) @@ -563,7 +563,6 @@ void EveSpaceSceneRenderDriver::Execute( const Span& destina } distortionMap = {}; GlobalStore().RegisterVariable( "SSAOMap", Tr2TextureAL{} ); - } else { @@ -637,7 +636,7 @@ void EveSpaceSceneRenderDriver::UpdateGpuParticleSystem( Tr2RenderContext& rende if( m_scene->GetGpuParticleSystem() ) { GPU_REGION( renderContext, "Particles" ); - m_scene->PopulateAndApplyPerFrameData( renderContext ); + m_scene->PopulateAndApplyPerFrameData( renderContext ); m_scene->GetGpuParticleSystem()->Update( m_scene->m_updateTime, m_scene->m_updateContext.GetOriginShift(), renderContext ); } } @@ -766,4 +765,3 @@ void EveSpaceSceneRenderDriver::SetScene( EveSpaceScene* scene ) } m_scene = scene; } - diff --git a/trinity/Eve/EveSpaceSceneRenderDriver.h b/trinity/Eve/EveSpaceSceneRenderDriver.h index 9a302914f..78ad4ef0c 100644 --- a/trinity/Eve/EveSpaceSceneRenderDriver.h +++ b/trinity/Eve/EveSpaceSceneRenderDriver.h @@ -24,7 +24,6 @@ BLUE_DECLARE( Tr2Sprite2dScene ); - BLUE_CLASS( EveSpaceSceneRenderDriver ) : public ITr2RenderNode, public Tr2DeviceResource @@ -83,14 +82,14 @@ BLUE_CLASS( EveSpaceSceneRenderDriver ) : { m_settings = settings; } - + void SetDebugMode( bool enable ); bool GetDebugMode() const; std::vector GetAllTempTextures() const; EveSpaceScene* GetScene() const; - void SetScene( EveSpaceScene* scene ); + void SetScene( EveSpaceScene * scene ); EXPOSE_TO_BLUE(); @@ -106,7 +105,7 @@ BLUE_CLASS( EveSpaceSceneRenderDriver ) : Tr2GpuResourcePool::Texture GetCustomStencilMapIfNeeded( const TextureSize2D& size, const Span& outputs ); Tr2GpuResourcePool::Texture GetOpaqueColorMapIfNeeded( const TextureSize2D& size, const Span& outputs ); - void UpdateGpuParticleSystem( Tr2RenderContext& renderContext ); + void UpdateGpuParticleSystem( Tr2RenderContext & renderContext ); Tr2GpuResourcePool::Texture RenderSSAO( const Tr2TextureAL& depthMap, const Tr2TextureAL& normalMap, Tr2RenderContext& renderContext ); @@ -170,6 +169,3 @@ BLUE_CLASS( EveSpaceSceneRenderDriver ) : }; TYPEDEF_BLUECLASS( EveSpaceSceneRenderDriver ); - - - diff --git a/trinity/Eve/EveSpaceSceneRenderDriver_Blue.cpp b/trinity/Eve/EveSpaceSceneRenderDriver_Blue.cpp index fb8ecdafb..312dc625f 100644 --- a/trinity/Eve/EveSpaceSceneRenderDriver_Blue.cpp +++ b/trinity/Eve/EveSpaceSceneRenderDriver_Blue.cpp @@ -242,22 +242,22 @@ const Be::ClassInfo* EveSpaceSceneRenderDriver::ExposeToBlue() "Render node to render after (or instead of) the main color pass of the scene", Be::READWRITE ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "customStencilFormat", - m_customStencilFormat, - "Pixel format for custom stencil buffer generated in depth pass. Set to Unknown to disable.", - Be::READWRITE | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "customStencilFormat", + m_customStencilFormat, + "Pixel format for custom stencil buffer generated in depth pass. Set to Unknown to disable.", + Be::READWRITE | Be::ENUM, Tr2RenderContextEnum_PixelFormat_Chooser ) - MAP_ATTRIBUTE( - "depthPassTechnique", - m_depthPassTechnique, - "Name of the shader technique used during the depth pass", + MAP_ATTRIBUTE( + "depthPassTechnique", + m_depthPassTechnique, + "Name of the shader technique used during the depth pass", Be::READWRITE ) MAP_METHOD_AND_WRAP( - "GetAllTempTextures", - GetAllTempTextures, + "GetAllTempTextures", + GetAllTempTextures, "Returns all temp textures used by the gpu resource pool. For debugging purposes." ) MAP_PROPERTY( diff --git a/trinity/Eve/EveSpaceScene_Blue.cpp b/trinity/Eve/EveSpaceScene_Blue.cpp index 94c9bdd12..0d8ccd9d3 100644 --- a/trinity/Eve/EveSpaceScene_Blue.cpp +++ b/trinity/Eve/EveSpaceScene_Blue.cpp @@ -18,31 +18,30 @@ BLUE_DEFINE( EveSpaceScene ); BLUE_DEFINE_INTERFACE( IEveReferencePoint ); BLUE_DEFINE_INTERFACE( IEveBallpark ); -Be::VarChooser EveVisualizerChooser[] = - { - { "None", - BeCast( EveSpaceScene::VM_NONE ), - "No visualizer - use normal rendering" }, - { "TexCoord0", - BeCast( EveSpaceScene::VM_TEXCOORD0 ), - "" }, - { "TexCoord1", - BeCast( EveSpaceScene::VM_TEXCOORD1 ), - "" }, - { "White", - BeCast( EveSpaceScene::VM_WHITE ), - "" }, - { "Overdraw", - BeCast( EveSpaceScene::VM_OVERDRAW ), - "" }, - { "Wireframe", - BeCast( EveSpaceScene::VW_WIREFRAME ), - "" }, - { "LightCount", - BeCast( EveSpaceScene::VW_LIGHT_COUNT ), - "" }, +Be::VarChooser EveVisualizerChooser[] = { + { "None", + BeCast( EveSpaceScene::VM_NONE ), + "No visualizer - use normal rendering" }, + { "TexCoord0", + BeCast( EveSpaceScene::VM_TEXCOORD0 ), + "" }, + { "TexCoord1", + BeCast( EveSpaceScene::VM_TEXCOORD1 ), + "" }, + { "White", + BeCast( EveSpaceScene::VM_WHITE ), + "" }, + { "Overdraw", + BeCast( EveSpaceScene::VM_OVERDRAW ), + "" }, + { "Wireframe", + BeCast( EveSpaceScene::VW_WIREFRAME ), + "" }, + { "LightCount", + BeCast( EveSpaceScene::VW_LIGHT_COUNT ), + "" }, { 0 } - }; +}; BLUE_REGISTER_ENUM_EX( "EveVisualizeMethod", EveSpaceScene::EveVisualizeMethod, EveVisualizerChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); #if BLUE_WITH_PYTHON @@ -313,7 +312,7 @@ const Be::ClassInfo* EveSpaceScene::ExposeToBlue() "Set quality for shadows \n" "jessica-hidden: True", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( + MAP_ATTRIBUTE( "raytracingManager", m_rtManager, "Raytracing manager\n" @@ -382,7 +381,7 @@ const Be::ClassInfo* EveSpaceScene::ExposeToBlue() "In the end this will control which environment map mip will be used (1 will use the lowest mip, 0 will use the highest mip)\n" ":jessica-group: Lighting", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "fogColor", m_fogColor, ":jessica-group: Fog\n:jessica-tuple-type: linearcolor", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "fogStart", m_fogStart, "Depth at which fogging starts.\n:jessica-group: Fog", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "fogEnd", m_fogEnd, "Depth at which the fog does not get thicker.\n:jessica-group: Fog", Be::READWRITE | Be::PERSIST ) @@ -465,7 +464,7 @@ const Be::ClassInfo* EveSpaceScene::ExposeToBlue() m_updateTime, "Time of the last call to Update, for this scene", Be::READ ) - + MAP_PROPERTY_READONLY( "quadRenderer", GetQuadRenderer, @@ -550,13 +549,12 @@ const Be::ClassInfo* EveSpaceScene::ExposeToBlue() ReregisterEntities, "Re registers all entities" ) - MAP_PROPERTY( - "shadowsInReflections", - IsShadowsInReflectionsEnabled, + MAP_PROPERTY( + "shadowsInReflections", + IsShadowsInReflectionsEnabled, EnableShadowsInReflections, "Enables/disables shadows in the reflection cubemap (only if shadows are enabled)\n\n" - ":jessica-group: Shadows" - ) + ":jessica-group: Shadows" ) EXPOSURE_END() } diff --git a/trinity/Eve/EveStarfield.cpp b/trinity/Eve/EveStarfield.cpp index 8bb3853b7..e28c1a6c0 100644 --- a/trinity/Eve/EveStarfield.cpp +++ b/trinity/Eve/EveStarfield.cpp @@ -21,20 +21,20 @@ struct StarfieldSpriteVertex uint8_t padding[2]; }; -void GenerateStar(float minDist, float maxDist, float minFlashRate, float maxFlashRate, float minIntensity, StarfieldSpriteVertex* star) +void GenerateStar( float minDist, float maxDist, float minFlashRate, float maxFlashRate, float minIntensity, StarfieldSpriteVertex* star ) { - float t = TriRand()*2.0f*3.1415926535897932384626433832795f; - float u = (TriRand()-0.5f)*2.0f; + float t = TriRand() * 2.0f * 3.1415926535897932384626433832795f; + float u = ( TriRand() - 0.5f ) * 2.0f; float dist = TriRand(); - float radius = Lerp(minDist, maxDist, dist * dist); - float sq = sqrtf(1.0f-u*u); + float radius = Lerp( minDist, maxDist, dist * dist ); + float sq = sqrtf( 1.0f - u * u ); - star->position = Vector3(radius*sq*cosf(t), radius*sq*sinf(t), radius*u); + star->position = Vector3( radius * sq * cosf( t ), radius * sq * sinf( t ), radius * u ); star->colorIndex = TriRand(); - star->flashIntensity = TriRand() * (1 - minIntensity) + minIntensity; + star->flashIntensity = TriRand() * ( 1 - minIntensity ) + minIntensity; star->flashPhase = TriRand(); - star->flashRate = TriRand() * (maxFlashRate - minFlashRate) + minFlashRate; - star->textureIndex = TriRandInt(4); + star->flashRate = TriRand() * ( maxFlashRate - minFlashRate ) + minFlashRate; + star->textureIndex = TriRandInt( 4 ); } EveStarfield::EveStarfield( IRoot* lockobj ) : @@ -42,11 +42,11 @@ EveStarfield::EveStarfield( IRoot* lockobj ) : m_vertexCount( 0 ), m_starCount( 500 ), m_seed( 0 ), - m_maxDistance(300), - m_minDistance(100), - m_maxFlashRate(1), - m_minFlashRate(0.5), - m_minFlashIntensity(0), + m_maxDistance( 300 ), + m_minDistance( 100 ), + m_maxFlashRate( 1 ), + m_minFlashRate( 0.5 ), + m_minFlashIntensity( 0 ), m_display( true ), m_dirty( false ), m_vertexDeclHandle( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) @@ -124,10 +124,10 @@ bool EveStarfield::OnPrepareResources() vd.Add( vd.FLOAT32_1, vd.TEXCOORD, 1 ); vd.Add( vd.FLOAT32_1, vd.TEXCOORD, 2 ); vd.Add( vd.FLOAT32_1, vd.TEXCOORD, 3 ); - vd.Add( vd.UBYTE_4 , vd.TEXCOORD, 4 ); + vd.Add( vd.UBYTE_4, vd.TEXCOORD, 4 ); } - m_vertexDeclHandle= Tr2EffectStateManager::GetVertexDeclarationHandle( s_spriteVertexDecl ); + m_vertexDeclHandle = Tr2EffectStateManager::GetVertexDeclarationHandle( s_spriteVertexDecl ); if( m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) { return false; @@ -139,12 +139,12 @@ bool EveStarfield::OnPrepareResources() std::vector verts( m_vertexCount ); - TriSrand(Be::Time(this->m_seed)); - + TriSrand( Be::Time( this->m_seed ) ); + StarfieldSpriteVertex star; for( int i = 0; i < m_starCount; ++i ) { - GenerateStar(m_minDistance, m_maxDistance, m_minFlashRate, m_maxFlashRate, m_minFlashIntensity, &star); + GenerateStar( m_minDistance, m_maxDistance, m_minFlashRate, m_maxFlashRate, m_minFlashIntensity, &star ); for( int j = 0; j < 4; ++j ) { StarfieldSpriteVertex& vertex = verts[i * 4 + j]; @@ -159,13 +159,14 @@ bool EveStarfield::OnPrepareResources() } USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( m_vertexBuffer.Create( - m_bytesPerVertex, - m_vertexCount, - Tr2GpuUsage::VERTEX_BUFFER, - Tr2CpuUsage::NONE, - &verts[0], - renderContext ), false ); + CR_RETURN_VAL( m_vertexBuffer.Create( + m_bytesPerVertex, + m_vertexCount, + Tr2GpuUsage::VERTEX_BUFFER, + Tr2CpuUsage::NONE, + &verts[0], + renderContext ), + false ); Tr2Renderer::ReserveQuadListIndexBuffer( m_starCount ); diff --git a/trinity/Eve/EveStarfield.h b/trinity/Eve/EveStarfield.h index 4589750b5..4132fb1c5 100644 --- a/trinity/Eve/EveStarfield.h +++ b/trinity/Eve/EveStarfield.h @@ -13,10 +13,9 @@ BLUE_DECLARE( Tr2Effect ); class ITriRenderBatchAccumulator; class Tr2PerObjectData; -class EveStarfield : - public INotify, - public IInitialize, - public Tr2DeviceResource +class EveStarfield : public INotify, + public IInitialize, + public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); @@ -41,15 +40,16 @@ class EveStarfield : ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); + public: - ///////////////////////////////////////////////////////////////////////////////////// // INotify bool OnModified( Be::Var* val ); -private: +private: bool m_display; int32_t m_starCount; int32_t m_seed; diff --git a/trinity/Eve/EveStarfield_Blue.cpp b/trinity/Eve/EveStarfield_Blue.cpp index d6785f538..2d5e22fe7 100644 --- a/trinity/Eve/EveStarfield_Blue.cpp +++ b/trinity/Eve/EveStarfield_Blue.cpp @@ -12,77 +12,59 @@ const Be::ClassInfo* EveStarfield::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "display", + MAP_ATTRIBUTE( + "display", m_display, - "na", - Be::READWRITE | Be::PERSIST - ) + "na", + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "numStars", - m_starCount, - "Total number of stars.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "seed", - m_seed, - "A seed that controls star generation.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "maxDist", - m_maxDistance, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "numStars", + m_starCount, + "Total number of stars.", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "minDist", - m_minDistance, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "seed", + m_seed, + "A seed that controls star generation.", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "minFlashRate", - m_minFlashRate, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "maxDist", + m_maxDistance, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "maxFlashRate", - m_maxFlashRate, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "minDist", + m_minDistance, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "minFlashIntensity", - m_minFlashIntensity, - "Determines how bright a star flashes. Should be a number between 0 and 1.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "minFlashRate", + m_minFlashRate, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "effect", - m_effect, - "The effect used to draw individual stars.", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "maxFlashRate", + m_maxFlashRate, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + + MAP_ATTRIBUTE( + "minFlashIntensity", + m_minFlashIntensity, + "Determines how bright a star flashes. Should be a number between 0 and 1.", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + + MAP_ATTRIBUTE( + "effect", + m_effect, + "The effect used to draw individual stars.", + Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/EveTransform.cpp b/trinity/Eve/EveTransform.cpp index cf28d005d..a02e2bf9d 100644 --- a/trinity/Eve/EveTransform.cpp +++ b/trinity/Eve/EveTransform.cpp @@ -26,8 +26,8 @@ EveTransform::EveTransform( IRoot* lockobj ) : m_isVisible( true ), m_hideOnLowQuality( false ), m_visibilityThreshold( 2.0f ), - m_lastRelativePosition(0,0,0), - m_lastDeltaTime(0.f), + m_lastRelativePosition( 0, 0, 0 ), + m_lastDeltaTime( 0.f ), m_lastCurveUpdateDelta( g_eveSpaceSceneLowUpdateRate ), m_useLodLevel( true ), m_lodLevel( TR2_LOD_LOW ), @@ -106,7 +106,7 @@ void EveTransform::UpdateAsyncronous( const EveUpdateContext& updateContext ) m_lastCurveUpdateDelta = 0; for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( TimeAsDouble( time ) ); + ( *it )->Update( TimeAsDouble( time ) ); } } } @@ -119,14 +119,14 @@ void EveTransform::UpdateAsyncronous( const EveUpdateContext& updateContext ) for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - (*it)->UpdateTransform( m_worldTransform ); + ( *it )->UpdateTransform( m_worldTransform ); } if( !m_particleEmitters.empty() ) { ITr2GenericEmitter::UpdateArguments args( time, updateContext.GetGpuParticleSystem(), m_worldTransform, updateContext.GetOriginShift() ); for( auto it = m_particleEmitters.begin(); it != m_particleEmitters.end(); ++it ) { - (*it)->Update( args ); + ( *it )->Update( args ); } } if( !m_particleSystems.empty() ) @@ -145,13 +145,13 @@ void EveTransform::UpdateViewDependentData( const TriFrustum& frustum, const Mat for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - (*it)->UpdateViewDependentData( &frustum, m_worldTransform ); + ( *it )->UpdateViewDependentData( &frustum, m_worldTransform ); } TriObserverLocalVector::iterator observersEnd = m_observers.end(); for( TriObserverLocalVector::iterator it = m_observers.begin(); it != observersEnd; ++it ) { - (*it)->Update( m_worldTransform ); + ( *it )->Update( m_worldTransform ); } } @@ -161,7 +161,7 @@ void EveTransform::GetDebugOptions( Tr2DebugRendererOptions& options ) options.insert( "Bounding Sphere" ); options.insert( "Names" ); - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->GetDebugOptions( options ); } @@ -185,7 +185,7 @@ void EveTransform::RenderDebugInfo( ITr2DebugRenderer2& renderer ) return; } - for ( auto it = m_observers.begin(); it != m_observers.end(); ++it ) + for( auto it = m_observers.begin(); it != m_observers.end(); ++it ) { ( *it )->RenderDebugInfo( renderer ); } @@ -263,7 +263,7 @@ void EveTransform::GetRenderables( std::vector& renderables, Tr for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); it++ ) { - (*it)->SortParticles(); + ( *it )->SortParticles(); } if( m_isVisible && m_mesh ) @@ -294,7 +294,7 @@ void EveTransform::UpdateVisibility( const EveUpdateContext& updateContext, cons } UpdateViewDependentData( updateContext.GetFrustum(), parentTransform ); - + if( m_mesh ) { Vector4 boundingSphere; @@ -340,7 +340,7 @@ void EveTransform::UpdateVisibility( const EveUpdateContext& updateContext, cons { IEveTransform* p = *it; p->UpdateVisibility( updateContext, m_worldTransform ); - + // Use the highest child LOD level. m_lodLevel = EveLODHelper::MergeLOD( m_lodLevel, p->GetLODLevel() ); } @@ -367,13 +367,13 @@ bool EveTransform::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query BoundingSphereFromBox( sphere, minBounds, maxBounds, &m_worldTransform ); valid = true; } - + if( query == EVE_BOUNDS_WITH_CHILDREN ) { - Vector4 boundingSphere(0,0,0,100.f); + Vector4 boundingSphere( 0, 0, 0, 100.f ); for( auto it = m_children.cbegin(); it != m_children.cend(); it++ ) { - if( (*it)->GetBoundingSphere( boundingSphere, query ) ) + if( ( *it )->GetBoundingSphere( boundingSphere, query ) ) { BoundingSphereSetOrUpdate( boundingSphere, sphere, valid ); valid = true; @@ -384,7 +384,7 @@ bool EveTransform::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query return valid; } -void EveTransform::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void EveTransform::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { // As with EveSpaceObject2, we need to make sure that we fully update the position to give to the camera // This has to happen before the Scene2 update, where other objects may be camera aligned @@ -403,7 +403,7 @@ Quaternion EveTransform::GetWorldRotation() return m_rotation; } -void EveTransform::GetModelCenterWorldPosition( Vector3 &position ) const +void EveTransform::GetModelCenterWorldPosition( Vector3& position ) const { position = m_worldTransform.GetTranslation(); } @@ -416,7 +416,7 @@ void EveTransform::PlayCurveSets() { for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Play(); + ( *it )->Play(); } } @@ -428,7 +428,7 @@ void EveTransform::PlayCurveSet( const std::string& name, const std::string& ran { for( auto it = m_curveSets.begin(); it != m_curveSets.end(); it++ ) { - if( (*it)->GetName() == name ) + if( ( *it )->GetName() == name ) { if( rangeName.empty() ) { @@ -451,9 +451,9 @@ void EveTransform::StopCurveSet( const std::string& name ) { for( auto it = m_curveSets.begin(); it != m_curveSets.end(); it++ ) { - if( (*it)->GetName() == name ) + if( ( *it )->GetName() == name ) { - (*it)->Stop(); + ( *it )->Stop(); } } } diff --git a/trinity/Eve/EveTransform.h b/trinity/Eve/EveTransform.h index b4928eabe..669fdd1e8 100644 --- a/trinity/Eve/EveTransform.h +++ b/trinity/Eve/EveTransform.h @@ -29,7 +29,7 @@ BLUE_DECLARE_IVECTOR( ITr2GenericEmitter ); BLUE_DECLARE( EveTransform ); BLUE_DECLARE_VECTOR( EveTransform ); -BLUE_CLASS( EveTransform ): +BLUE_CLASS( EveTransform ) : public Tr2Transform, public IEveTransform, public IEveSpaceObject2, @@ -40,31 +40,37 @@ BLUE_CLASS( EveTransform ): public ITr2DebugRenderable { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using Tr2Transform::Lock; using Tr2Transform::Unlock; - EveTransform( IRoot* lockobj = NULL ); + EveTransform( IRoot* lockobj = NULL ); - virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ); + virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ); ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObject2 + // IEveSpaceObject2 void Update( const EveUpdateContext& updateContext ) override; void UpdateSyncronous( const EveUpdateContext& updateContext ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) override; - void GetRenderables( std::vector& renderables ) override; - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) override; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const override; - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) override; - void GetModelCenterWorldPosition( Vector3 &position ) const override; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) override { return false; } - void GetLocalToWorldTransform( Matrix &transform ) const override { transform = IdentityMatrix(); } + void GetRenderables( std::vector & renderables ) override; + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ) override; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ) override; + void GetModelCenterWorldPosition( Vector3 & position ) const override; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) override + { + return false; + } + void GetLocalToWorldTransform( Matrix & transform ) const override + { + transform = IdentityMatrix(); + } ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - mostly implemented by Tr2Transform except for these - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); ///////////////////////////////////////////////////////////////////////////////////// // IWorldPosition @@ -74,17 +80,20 @@ BLUE_CLASS( EveTransform ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } - virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); - + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } + virtual void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); + ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); // EveTransforms can be under EveTransforms PIEveTransformVector m_children; @@ -95,7 +104,7 @@ BLUE_CLASS( EveTransform ): // Generic particle system/emitter lists (Python-exposed) PTr2ParticleSystemVector m_particleSystems; PITr2GenericEmitterVector m_particleEmitters; - + Tr2Lod GetLODLevel() const; void PlayCurveSets(); @@ -104,14 +113,17 @@ BLUE_CLASS( EveTransform ): float GetCurveSetDuration( const std::string& name ) const; float GetRangeDuration( const std::string& name, const std::string& rangeName ) const; - void SetDisplay( bool value ) { m_display = value; }; + void SetDisplay( bool value ) + { + m_display = value; + }; protected: bool m_isVisible; bool m_useLodLevel; bool m_hideOnLowQuality; Tr2Lod m_lodLevel; - + float m_visibilityThreshold; Vector3 m_lastRelativePosition; @@ -121,8 +133,8 @@ BLUE_CLASS( EveTransform ): Vector3 m_overrideBoundsMin; Vector3 m_overrideBoundsMax; - Tr2MeshBasePtr m_meshLod; // This thing is deprecated and should be removed once there are no references to it in branch/content - + Tr2MeshBasePtr m_meshLod; // This thing is deprecated and should be removed once there are no references to it in branch/content + private: using Tr2Transform::Update; // Silence warning about this hidden function }; @@ -134,11 +146,12 @@ class EveBasicPerObjectData : public Tr2PerObjectData public: virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { - FillAndSetConstants( *buffers[Tr2RenderContextEnum::VERTEX_SHADER], - &m_world, sizeof( m_world ) + sizeof( m_worldLast ) + sizeof( m_worldInverse ), - Tr2RenderContextEnum::VERTEX_SHADER, - Tr2Renderer::GetPerObjectVSStartRegister(), - renderContext ); + FillAndSetConstants( *buffers[Tr2RenderContextEnum::VERTEX_SHADER], + &m_world, + sizeof( m_world ) + sizeof( m_worldLast ) + sizeof( m_worldInverse ), + Tr2RenderContextEnum::VERTEX_SHADER, + Tr2Renderer::GetPerObjectVSStartRegister(), + renderContext ); } void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override { diff --git a/trinity/Eve/EveTransform_Blue.cpp b/trinity/Eve/EveTransform_Blue.cpp index d7ec1f75d..5921ea44f 100644 --- a/trinity/Eve/EveTransform_Blue.cpp +++ b/trinity/Eve/EveTransform_Blue.cpp @@ -9,102 +9,80 @@ BLUE_DEFINE_INTERFACE( IEveTransform ); const Be::ClassInfo* EveTransform::ExposeToBlue() { - EXPOSURE_BEGIN( EveTransform, "" ) - MAP_INTERFACE( EveTransform ) + EXPOSURE_BEGIN( EveTransform, "" ) + MAP_INTERFACE( EveTransform ) MAP_INTERFACE( IEveTransform ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2Pickable ) MAP_INTERFACE( IWorldPosition ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE - ( - "hideOnLowQuality", + MAP_ATTRIBUTE( + "hideOnLowQuality", m_hideOnLowQuality, - "Disables this whole transform and all of it's children when low quaility is selected.", - Be::READWRITE | Be::PERSIST - ) + "Disables this whole transform and all of it's children when low quaility is selected.", + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "visibilityThreshold", m_visibilityThreshold, "If the transform holds a mesh, it is only rendered if its estimated pixel\n" "diameter is above this threshold. Note that rendering of the children is" "not affected. Also setting this to -1.0 disables culling.\n", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "children", m_children, "", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "particleEmitters", m_particleEmitters, "A list of emitters owned by this transform", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "particleSystems", m_particleSystems, "A list of particle systems owned by this transform", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "observers", - m_observers, + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "observers", + m_observers, "Observers for pushing data between modules every frame. Currently used to push locator data out to the audio2 module.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "useLodLevel", m_useLodLevel, "Use the lodLevel to downscale this object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "lodLevel", m_lodLevel, "Current LOD level, 1(high) to 3(low)", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "meshLod", m_meshLod, ":jessica-hidden: True", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "overrideBoundsMin", m_overrideBoundsMin, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "overrideBoundsMax", m_overrideBoundsMax, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2Transform ) + EXPOSURE_CHAINTO( Tr2Transform ) } diff --git a/trinity/Eve/EveUpdateContext.h b/trinity/Eve/EveUpdateContext.h index d8713b3fb..86cd95e23 100644 --- a/trinity/Eve/EveUpdateContext.h +++ b/trinity/Eve/EveUpdateContext.h @@ -17,14 +17,16 @@ BLUE_DECLARE( Tr2GpuParticleSystem ); class EveUpdateContext { public: - EveUpdateContext() {} - EveUpdateContext( Be::Time time ) : + EveUpdateContext() + { + } + EveUpdateContext( Be::Time time ) : m_lastTime( 0 ), m_currentTime( 0 ), m_origin( UNINITIALIZED_ORIGIN, UNINITIALIZED_ORIGIN, UNINITIALIZED_ORIGIN ), m_originShift( 0, 0, 0 ), m_originShiftRemainder( 0, 0, 0 ), - m_visibilityThreshold(0.f), + m_visibilityThreshold( 0.f ), m_highDetailThreshold( 0.f ), m_mediumDetailThreshold( 0.f ), m_lowDetailThreshold( 0.f ), @@ -160,7 +162,7 @@ class EveUpdateContext { return m_lowDetailThreshold; } - + void SetLodFactor( float lodFactor ) { m_lodFactor = lodFactor; @@ -211,7 +213,7 @@ class EveUpdateContext float m_lowDetailThreshold; float m_lodFactor; float m_invLodFactor; - TriFrustum m_frustum; + TriFrustum m_frustum; }; #endif //EveUpdateContext_h diff --git a/trinity/Eve/IEveFiringEffectElement.h b/trinity/Eve/IEveFiringEffectElement.h index 751e9e079..f34d1d2e1 100644 --- a/trinity/Eve/IEveFiringEffectElement.h +++ b/trinity/Eve/IEveFiringEffectElement.h @@ -8,7 +8,8 @@ class Tr2LightManager; class Tr2QuadRenderer; BLUE_DECLARE_INTERFACE( ITr2Renderable ); -BLUE_INTERFACE( IEveFiringEffectElement ): public IRoot +BLUE_INTERFACE( IEveFiringEffectElement ) : + public IRoot { virtual void SetDestObjectScale( float scale ) = 0; virtual void StartMoving() = 0; @@ -20,17 +21,27 @@ BLUE_INTERFACE( IEveFiringEffectElement ): public IRoot virtual void SetFiringTransform( const Vector3& source, const Vector3& dest ) = 0; virtual void DisplayEndPoints( bool displaySource, bool displayDest ) = 0; - virtual void Update( const EveUpdateContext& updateContext ) {} + virtual void Update( const EveUpdateContext& updateContext ) + { + } virtual void UpdateEffectAsync( const EveUpdateContext& updateContext ) = 0; virtual void UpdateEffectSync( const EveUpdateContext& updateContext ) = 0; - + virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) = 0; - virtual void GetRenderables( std::vector& renderables ) = 0; - - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) {} - virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) {} - virtual void SetIntensity( float intensity ) {} - virtual void SetDisplay( bool display ) {} + virtual void GetRenderables( std::vector & renderables ) = 0; + + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) + { + } + virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) + { + } + virtual void SetIntensity( float intensity ) + { + } + virtual void SetDisplay( bool display ) + { + } }; BLUE_DECLARE_IVECTOR( IEveFiringEffectElement ); \ No newline at end of file diff --git a/trinity/Eve/IEveShadowCaster.h b/trinity/Eve/IEveShadowCaster.h index 8b99fb8e0..fd239a147 100644 --- a/trinity/Eve/IEveShadowCaster.h +++ b/trinity/Eve/IEveShadowCaster.h @@ -32,9 +32,9 @@ class TriShadowOrthoFrustum : public IEveShadowFrustum Vector3 m_sunDir; public: - TriShadowOrthoFrustum(): + TriShadowOrthoFrustum() : m_shadow( {} ), - m_shadowMapSize(0), + m_shadowMapSize( 0 ), m_sunDir( {} ) { } @@ -142,13 +142,23 @@ BLUE_INTERFACE( IEveShadowCaster ) : { // Used for cascaded shadow map virtual bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const = 0; - virtual bool IsCastingShadow( const TriFrustum& cameraFrustum, Vector3 position, float radius, Tr2RenderReason renderReason ) const { return false; } + virtual bool IsCastingShadow( const TriFrustum& cameraFrustum, Vector3 position, float radius, Tr2RenderReason renderReason ) const + { + return false; + } virtual void GetShadowBatches( ITriRenderBatchAccumulator * batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize ) = 0; virtual Tr2PerObjectData* GetShadowPerObjectData( ITriRenderBatchAccumulator * accumulator ) = 0; // raytraced shadows - virtual void PushRtGeometry( Tr2RaytracingManager& ) const{ } - virtual void MarkRtDirty() { } - virtual bool IsShadowCastingDirty() const { return false; } + virtual void PushRtGeometry( Tr2RaytracingManager& ) const + { + } + virtual void MarkRtDirty() + { + } + virtual bool IsShadowCastingDirty() const + { + return false; + } }; REGISTER_COMPONENT_TYPE( "ShadowCaster", IEveShadowCaster ); diff --git a/trinity/Eve/IEveSpaceObject2.h b/trinity/Eve/IEveSpaceObject2.h index 9dd05bf61..a1e47c104 100644 --- a/trinity/Eve/IEveSpaceObject2.h +++ b/trinity/Eve/IEveSpaceObject2.h @@ -17,7 +17,8 @@ class Tr2QuadRenderer; class Tr2LightManager; class Tr2ImpostorManager; -BLUE_INTERFACE( IEveSpaceObject2 ) : public IRoot +BLUE_INTERFACE( IEveSpaceObject2 ) : + public IRoot { // public struct to pass this info to children @@ -33,39 +34,56 @@ BLUE_INTERFACE( IEveSpaceObject2 ) : public IRoot float clipFactor2 = 0; const Vector4* shLighting = nullptr; Vector4 customData = Vector4( 0, 0, 0, 0 ); -}; + }; virtual void UpdateSyncronous( const EveUpdateContext& updateContext ) = 0; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext ) = 0; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) = 0; - virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) = 0; - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const = 0; + virtual void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ) = 0; + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const = 0; // This version of the function should perform an update on the model / ball position - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) = 0; + virtual void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ) = 0; // This version of the function should not update the object - virtual void GetModelCenterWorldPosition( Vector3 &position ) const = 0; + virtual void GetModelCenterWorldPosition( Vector3 & position ) const = 0; // If possible, return an AABB in local coordinates - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) = 0; + virtual bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) = 0; // Get the local to world transform - virtual void GetLocalToWorldTransform( Matrix &transform ) const = 0; + virtual void GetLocalToWorldTransform( Matrix & transform ) const = 0; - virtual void GetWorldVelocity( Vector3& velocity ) const { velocity = Vector3( 0, 0, 0 ); } + virtual void GetWorldVelocity( Vector3 & velocity ) const + { + velocity = Vector3( 0, 0, 0 ); + } // Registers an object and its attachments with the quad renderer - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) {} + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) + { + } // Adds quads from space object and its attachments to the quad renderer. ATTENTION: this function is called in-parallel - virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) {} + virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) + { + } - virtual void GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const {} + virtual void GetPerObjectStructs( EveSpaceObjectVSData & vsData, EveSpaceObjectPSData & psData ) const + { + } - virtual bool IsPickable() const { return true; } + virtual bool IsPickable() const + { + return true; + } - virtual bool IsAudioOccluder() const { return false; } + virtual bool IsAudioOccluder() const + { + return false; + } - virtual void SetProceduralContainerVariable( const char *name, float value ) {} + virtual void SetProceduralContainerVariable( const char* name, float value ) + { + } virtual void GetParentData( IEveSpaceObject2::ParentData * pd ) const {}; }; diff --git a/trinity/Eve/IEveTransform.h b/trinity/Eve/IEveTransform.h index 06ee976cd..c222dd973 100644 --- a/trinity/Eve/IEveTransform.h +++ b/trinity/Eve/IEveTransform.h @@ -11,12 +11,13 @@ class TriFrustum; class Tr2RenderContext; class EveUpdateContext; -BLUE_INTERFACE( IEveTransform ) : public IRoot +BLUE_INTERFACE( IEveTransform ) : + public IRoot { virtual void Update( const EveUpdateContext& updateContext ) = 0; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) = 0; - virtual void GetRenderables( std::vector& renderables ) = 0; - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const = 0; + virtual void GetRenderables( std::vector & renderables ) = 0; + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const = 0; virtual Tr2Lod GetLODLevel() const = 0; }; diff --git a/trinity/Eve/Renderable/EveSceneStaticParticles.cpp b/trinity/Eve/Renderable/EveSceneStaticParticles.cpp index 5f797f49f..0d1ca0a46 100644 --- a/trinity/Eve/Renderable/EveSceneStaticParticles.cpp +++ b/trinity/Eve/Renderable/EveSceneStaticParticles.cpp @@ -99,7 +99,7 @@ void EveSceneStaticParticles::Update( const EveUpdateContext& updateContext ) // calc float offset from egopos to center of particles Vector3d offset = m_centerOfClusters - updateContext.GetOrigin(); // build a transform matrix - m_worldMatrix = TranslationMatrix( float(offset.x), float(offset.y), float(offset.z) ); + m_worldMatrix = TranslationMatrix( float( offset.x ), float( offset.y ), float( offset.z ) ); m_center = TransformCoord( m_boundingSphere.GetXYZ(), m_worldMatrix ); } @@ -118,7 +118,7 @@ void EveSceneStaticParticles::UpdateVisibility( const EveUpdateContext& updateCo bool estimatedSizeWithinBounds = m_estimatedSize > PARTICLE_CLUSTER_MIN_SIZE * updateContext.GetLodFactor(); bool inBoundingSphere = LengthSq( m_center - frustum.m_viewPos ) <= m_boundingSphere.w * m_boundingSphere.w; - + m_visible = inBoundingSphere || ( IsVisible( updateContext ) && estimatedSizeWithinBounds ); } @@ -238,16 +238,16 @@ void EveSceneStaticParticles::Rebuild() // setup particle system Tr2VertexDefinition particleBufferVtxDef; - particleBufferVtxDef.Add(Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::POSITION); - particleBufferVtxDef.Add(Tr2VertexDefinition::FLOAT32_1, Tr2VertexDefinition::TEXCOORD, 0); - particleBufferVtxDef.Add(Tr2VertexDefinition::FLOAT32_4, Tr2VertexDefinition::TEXCOORD, 1); + particleBufferVtxDef.Add( Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::POSITION ); + particleBufferVtxDef.Add( Tr2VertexDefinition::FLOAT32_1, Tr2VertexDefinition::TEXCOORD, 0 ); + particleBufferVtxDef.Add( Tr2VertexDefinition::FLOAT32_4, Tr2VertexDefinition::TEXCOORD, 1 ); instanceData->SetLayout( particleBufferVtxDef ); // need total radius and a center for all clusters m_centerOfClusters = Vector3d( 0.0, 0.0, 0.0 ); for( auto it = m_clusters.begin(); it != m_clusters.end(); ++it ) { - const ClusterData* clusterData = &(*it); + const ClusterData* clusterData = &( *it ); m_centerOfClusters += Vector3d( (double)clusterData->position.x, (double)clusterData->position.y, (double)clusterData->position.z ); } m_centerOfClusters /= (double)m_clusters.size(); @@ -256,7 +256,7 @@ void EveSceneStaticParticles::Rebuild() size_t particleBufferSize = 0; for( auto it = m_clusters.begin(); it != m_clusters.end(); ++it ) { - const ClusterData* clusterData = &(*it); + const ClusterData* clusterData = &( *it ); particleBufferSize += size_t( m_clusterParticleDensity * clusterData->radius ); } @@ -271,17 +271,17 @@ void EveSceneStaticParticles::Rebuild() particleBufferSize = 0; for( auto it = m_clusters.begin(); it != m_clusters.end(); ++it ) { - const ClusterData* clusterData = &(*it); + const ClusterData* clusterData = &( *it ); particleBufferSize += size_t( m_clusterParticleDensityAdjust * m_clusterParticleDensity * clusterData->radius ); } - + // alloc big buffer in the particle system ParticleBufferItem* currentParticleBufferItem = static_cast( instanceData->GetData( (unsigned int)particleBufferSize ) ); // run over all the clusters and build for( auto it = m_clusters.begin(); it != m_clusters.end(); ++it ) { - const ClusterData* clusterData = &(*it); + const ClusterData* clusterData = &( *it ); int particlesPerCluster = int( m_clusterParticleDensityAdjust * m_clusterParticleDensity * clusterData->radius ); @@ -306,15 +306,14 @@ void EveSceneStaticParticles::Rebuild() // color (the alpha of the color is the seed) currentParticleBufferItem->color = Lerp( clusterData->color1, clusterData->color2, TriFloatRandom01() ); - currentParticleBufferItem->color.a = float(i) / float(particlesPerCluster); - + currentParticleBufferItem->color.a = float( i ) / float( particlesPerCluster ); + // size currentParticleBufferItem->size = TriFloatRandom01() * std::min( clusterData->radius / 10.f, m_maxSize ) + m_minSize; // next item in buffer ++currentParticleBufferItem; } - } // finish up the instance buffer @@ -326,9 +325,4 @@ void EveSceneStaticParticles::Rebuild() // calculate a rough bounding sphere BoundingSphereFromBox( m_boundingSphere, bbmin, bbmax ); - } - - - - diff --git a/trinity/Eve/Renderable/EveSceneStaticParticles.h b/trinity/Eve/Renderable/EveSceneStaticParticles.h index 74b41ee00..b81d5c752 100644 --- a/trinity/Eve/Renderable/EveSceneStaticParticles.h +++ b/trinity/Eve/Renderable/EveSceneStaticParticles.h @@ -25,7 +25,7 @@ BLUE_CLASS( EveSceneStaticParticles ) : public: EXPOSE_TO_BLUE(); - EveSceneStaticParticles(IRoot* lockobj = NULL); + EveSceneStaticParticles( IRoot* lockobj = NULL ); ~EveSceneStaticParticles(); // structs @@ -51,8 +51,8 @@ BLUE_CLASS( EveSceneStaticParticles ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -62,7 +62,7 @@ BLUE_CLASS( EveSceneStaticParticles ) : virtual bool HasTransparentBatches(); virtual float GetSortValue(); virtual bool IsVisible( const EveUpdateContext& updateContext ) const override; - + // update & render void Update( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext ); @@ -97,7 +97,7 @@ BLUE_CLASS( EveSceneStaticParticles ) : // bounding sphere Vector4 m_boundingSphere; - // the actual rendering object + // the actual rendering object Tr2InstancedMeshPtr m_mesh; bool m_visible; }; diff --git a/trinity/Eve/Renderable/EveSceneStaticParticles_Blue.cpp b/trinity/Eve/Renderable/EveSceneStaticParticles_Blue.cpp index 3571820e3..5b8d6cb07 100644 --- a/trinity/Eve/Renderable/EveSceneStaticParticles_Blue.cpp +++ b/trinity/Eve/Renderable/EveSceneStaticParticles_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveSceneStaticParticles ); const Be::ClassInfo* EveSceneStaticParticles::ExposeToBlue() { - EXPOSURE_BEGIN( EveSceneStaticParticles, "" ) - MAP_INTERFACE( EveSceneStaticParticles ) + EXPOSURE_BEGIN( EveSceneStaticParticles, "" ) + MAP_INTERFACE( EveSceneStaticParticles ) MAP_INTERFACE( IInitialize ) MAP_ATTRIBUTE( "maxParticleCount", m_maxParticleCount, "The total particle count this module can handle", Be::READWRITE ) @@ -35,5 +35,5 @@ const Be::ClassInfo* EveSceneStaticParticles::ExposeToBlue() MAP_METHOD_AND_WRAP( "ClearClusters", ClearClusters, "Remove all clusters" ) MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Once finished adding clusters, we need to build internal buffers etc." ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.cpp b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.cpp index 82a2f6ad1..7c019dac2 100644 --- a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.cpp +++ b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.cpp @@ -5,8 +5,8 @@ #include "Eve/IEveFiringEffectElement.h" -EveFiringEffectElementContainer::EveFiringEffectElementContainer( IRoot* lockObj ) - :m_source( XMMatrixIdentity() ), +EveFiringEffectElementContainer::EveFiringEffectElementContainer( IRoot* lockObj ) : + m_source( XMMatrixIdentity() ), m_destination( 0, 0, 0 ), m_destinationScale( 1.f ), m_display( true ), @@ -62,20 +62,20 @@ bool EveFiringEffectElementContainer::GetBoundingSphere( Vector4& sphere, Boundi return false; } -void EveFiringEffectElementContainer::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void EveFiringEffectElementContainer::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { } -void EveFiringEffectElementContainer::GetModelCenterWorldPosition( Vector3 &position ) const +void EveFiringEffectElementContainer::GetModelCenterWorldPosition( Vector3& position ) const { } -bool EveFiringEffectElementContainer::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) +bool EveFiringEffectElementContainer::GetLocalBoundingBox( Vector3& min, Vector3& max ) { return false; } -void EveFiringEffectElementContainer::GetLocalToWorldTransform( Matrix &transform ) const +void EveFiringEffectElementContainer::GetLocalToWorldTransform( Matrix& transform ) const { transform = XMMatrixIdentity(); } diff --git a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.h b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.h index d8a087ac2..40d421828 100644 --- a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.h +++ b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer.h @@ -11,7 +11,7 @@ BLUE_DECLARE_INTERFACE( IEveFiringEffectElement ); // -------------------------------------------------------------------------------------- // Description: -// A simple top-level container to host an IEveFiringEffectElement element for easy +// A simple top-level container to host an IEveFiringEffectElement element for easy // editing. // -------------------------------------------------------------------------------------- BLUE_CLASS( EveFiringEffectElementContainer ) : @@ -26,24 +26,24 @@ BLUE_CLASS( EveFiringEffectElementContainer ) : virtual void UpdateSyncronous( const EveUpdateContext& updateContext ); virtual void UpdateAsyncronous( const EveUpdateContext& updateContext ); virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - + virtual void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; // This version of the function should perform an update on the model / ball position - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); + virtual void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); // This version of the function should not update the object - virtual void GetModelCenterWorldPosition( Vector3 &position ) const; + virtual void GetModelCenterWorldPosition( Vector3 & position ) const; // If possible, return an AABB in local coordinates - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); + virtual bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); // Get the local to world transform - virtual void GetLocalToWorldTransform( Matrix &transform ) const; + virtual void GetLocalToWorldTransform( Matrix & transform ) const; void StartFiring(); void StopFiring(); @@ -52,10 +52,9 @@ BLUE_CLASS( EveFiringEffectElementContainer ) : bool GetActive() const; IEveFiringEffectElement* GetElement(); - void SetElement( IEveFiringEffectElement* element ); + void SetElement( IEveFiringEffectElement * element ); private: - IEveFiringEffectElementPtr m_element; Matrix m_source; diff --git a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer_Blue.cpp index 3fcc264d7..087d5c960 100644 --- a/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveFiringEffectElementContainer_Blue.cpp @@ -12,91 +12,69 @@ const Be::ClassInfo* EveFiringEffectElementContainer::ExposeToBlue() MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "Show/hide the effect", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "element", m_element, "Firing element", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "element", - GetElement, - SetElement, - "Firing element" - ) + Be::PERSISTONLY ) - MAP_PROPERTY - ( + MAP_PROPERTY( + "element", + GetElement, + SetElement, + "Firing element" ) + + MAP_PROPERTY( "active", GetActive, SetActive, - "Is the effect active" - ) + "Is the effect active" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "sourceTransform", m_source, "Firing source transform, used if useSourceTransform is on", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "source", m_source.GetTranslation(), "Firing source position", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "destination", m_destination, "Firing target position", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationScale", m_destinationScale, "Target scale", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "useSourceTransform", m_useSourceTransform, "Should the effect use the full transform or just a position", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displaySource", m_displaySource, "Show/hide effects at the source", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displayDestination", m_displayDestination, "Show/hide effects at the destination", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.cpp b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.cpp index ce98aa4d0..2f31fb23d 100644 --- a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.cpp +++ b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.cpp @@ -9,7 +9,7 @@ #include "include/TriMath.h" -EveLocalPositionCurve::EveLocalPositionCurve(IRoot* lockobj) : +EveLocalPositionCurve::EveLocalPositionCurve( IRoot* lockobj ) : m_value( 0.f, 0.f, 0.f ), m_boundingBoxSize( 0.f, 0.f, 0.f ), m_positionOffset( 0.f, 0.f, 0.f ), @@ -17,10 +17,10 @@ EveLocalPositionCurve::EveLocalPositionCurve(IRoot* lockobj) : m_locatorIndex( -1 ), m_impactEffectIndex( -1 ), m_impactSize( 1.f ), - m_behavior ( POS_NONE ), + m_behavior( POS_NONE ), m_offset( 0.f ), m_muzzleIndex( 0 ) -{ +{ } EveLocalPositionCurve::~EveLocalPositionCurve() @@ -74,9 +74,9 @@ Vector3* EveLocalPositionCurve::CalculateOffsetPosition( Vector3* in, Be::Time t Vector3* EveLocalPositionCurve::CalculateNearestBoundingPoint( Vector3* in, Be::Time t ) { - if (m_parentPositionCurve && m_alignPositionCurve && m_parentRotationCurve) + if( m_parentPositionCurve && m_alignPositionCurve && m_parentRotationCurve ) { - + Vector3 pt; Vector3 at; Quaternion parentRotation; @@ -94,11 +94,11 @@ Vector3* EveLocalPositionCurve::CalculateNearestBoundingPoint( Vector3* in, Be:: * system of the parent transform, then solve the question of how much it needs to be scaled by to reach * the bounding sphere, then perform this on the un-transformed vector. (which, like the object itself, is pre-transformed) * -------------------------------------------------------------------------------------------------- */ - + Matrix matInv; parentRotation = Inverse( Normalize( parentRotation ) ); matInv = RotationMatrix( parentRotation ); - + Vector3 transformedDir = TransformCoord( dir, matInv ); // Dir is now transformed into the direction in relation to the rotation of the ship @@ -108,30 +108,28 @@ Vector3* EveLocalPositionCurve::CalculateNearestBoundingPoint( Vector3* in, Be:: // if the object is really small (or the bounding size is erroring), just use the center of it, rather than // giving a NaN result in this formula - if ((m_boundingBoxSize.x > 10.0)&&(m_boundingBoxSize.y > 10.0)&&(m_boundingBoxSize.z > 10.0)) + if( ( m_boundingBoxSize.x > 10.0 ) && ( m_boundingBoxSize.y > 10.0 ) && ( m_boundingBoxSize.z > 10.0 ) ) { // Forumula for an ellipsiod is // 1 = (x^2 / a^2) + (y^2 / b^2) + (z^2 / c^2) - // now we need to solve the question, how much do we need to scale the vector + // now we need to solve the question, how much do we need to scale the vector // (all three axes equally) for the vector to satisfy the ellipsiod equation // solution to 1 = (x*theta)^2/a^2 + .... // (always want the positive answer) scalingValue += fabs( - (m_boundingBoxSize.x * m_boundingBoxSize.y * m_boundingBoxSize.z) / - sqrt( - (transformedDir.x * transformedDir.x) * (m_boundingBoxSize.y * m_boundingBoxSize.y) * (m_boundingBoxSize.z * m_boundingBoxSize.z) + - (transformedDir.y * transformedDir.y) * (m_boundingBoxSize.x * m_boundingBoxSize.x) * (m_boundingBoxSize.z * m_boundingBoxSize.z) + - (transformedDir.z * transformedDir.z) * (m_boundingBoxSize.x * m_boundingBoxSize.x) * (m_boundingBoxSize.y * m_boundingBoxSize.y) - ) - ); + ( m_boundingBoxSize.x * m_boundingBoxSize.y * m_boundingBoxSize.z ) / + sqrt( + ( transformedDir.x * transformedDir.x ) * ( m_boundingBoxSize.y * m_boundingBoxSize.y ) * ( m_boundingBoxSize.z * m_boundingBoxSize.z ) + + ( transformedDir.y * transformedDir.y ) * ( m_boundingBoxSize.x * m_boundingBoxSize.x ) * ( m_boundingBoxSize.z * m_boundingBoxSize.z ) + + ( transformedDir.z * transformedDir.z ) * ( m_boundingBoxSize.x * m_boundingBoxSize.x ) * ( m_boundingBoxSize.y * m_boundingBoxSize.y ) ) ); } // Apply the scaling to the original direction vector - in->x = pt.x + (dir.x * scalingValue); - in->y = pt.y + (dir.y * scalingValue); - in->z = pt.z + (dir.z * scalingValue); + in->x = pt.x + ( dir.x * scalingValue ); + in->y = pt.y + ( dir.y * scalingValue ); + in->z = pt.z + ( dir.z * scalingValue ); } - else if (m_parentPositionCurve) + else if( m_parentPositionCurve ) { Vector3 pt; m_parentPositionCurve->GetValueAt( &pt, t ); @@ -144,7 +142,7 @@ Vector3* EveLocalPositionCurve::CalculateNearestBoundingPoint( Vector3* in, Be:: } Vector3* EveLocalPositionCurve::GetCenterBoundingSphere( Vector3* in, Be::Time t ) -{ +{ if( m_parentObject ) { Vector3 tr; @@ -158,17 +156,17 @@ Vector3* EveLocalPositionCurve::GetCenterBoundingSphere( Vector3* in, Be::Time t } Vector3* EveLocalPositionCurve::GetDamageLocator( Vector3* in, Be::Time t ) -{ +{ if( m_alignPositionCurve && m_parentObject ) { - ITriTargetable* target = dynamic_cast< ITriTargetable* >( m_parentObject.p ); + ITriTargetable* target = dynamic_cast( m_parentObject.p ); if( !target ) { CCP_LOGERR( "Parent object is not targetable. Unable to get valid damage locators." ); return in; } - if ( m_damageLocatorIndex == -1 ) + if( m_damageLocatorIndex == -1 ) { Vector3 parentPos; m_alignPositionCurve->GetValueAt( &parentPos, t ); @@ -187,13 +185,13 @@ Vector3* EveLocalPositionCurve::GetDamageLocator( Vector3* in, Be::Time t ) Vector3* EveLocalPositionCurve::GetNearestFiringLocator( Vector3* in, Be::Time t ) { - if( m_parentObject && m_locatorIndex != -1 && !m_locatorSetName.empty()) + if( m_parentObject && m_locatorIndex != -1 && !m_locatorSetName.empty() ) { - if( EveSpaceObject2* target = dynamic_cast< EveSpaceObject2* >( m_parentObject.p ) ) + if( EveSpaceObject2* target = dynamic_cast( m_parentObject.p ) ) { Vector3 locatorPos( 0, 0, 0 ); target->GetLocatorPosition( &locatorPos, m_locatorIndex, true, m_locatorSetName ); - + in->x = locatorPos.x; in->y = locatorPos.y; in->y = locatorPos.y; @@ -208,10 +206,10 @@ Vector3* EveLocalPositionCurve::GetNearestFiringLocator( Vector3* in, Be::Time t // Calculate impact position onto the target aiming for a damage locator // -------------------------------------------------------------------------------- Vector3* EveLocalPositionCurve::GetDamageLocatorImpact( Vector3* in, Be::Time t ) -{ +{ if( m_alignPositionCurve && m_parentObject ) { - ITriTargetable* target = dynamic_cast< ITriTargetable* >( m_parentObject.p ); + ITriTargetable* target = dynamic_cast( m_parentObject.p ); if( !target ) { @@ -252,7 +250,7 @@ Vector3* EveLocalPositionCurve::GetDamageLocatorImpact( Vector3* in, Be::Time t Vector3* EveLocalPositionCurve::GetFiringTurretPosition( Vector3* in, Be::Time t ) { - if( m_turretSetObject) + if( m_turretSetObject ) { auto turretWorld = m_turretSetObject->GetFiringBoneWorldTransform( m_muzzleIndex ).GetTranslation(); @@ -270,8 +268,7 @@ Vector3* EveLocalPositionCurve::GetFiringTurretPosition( Vector3* in, Be::Time t Vector3* EveLocalPositionCurve::Update( Vector3* in, - Be::Time t - ) + Be::Time t ) { switch( m_behavior ) { @@ -314,7 +311,6 @@ Vector3* EveLocalPositionCurve::GetValueAt( Vector3* in, Be::Time time ) in->z = m_value.z; Update( in, time ); return in; - } Vector3* EveLocalPositionCurve::GetValueAt( Vector3* in, double time ) @@ -346,24 +342,16 @@ Vector3* EveLocalPositionCurve::GetValueDotAt( Vector3* in, double time ) return in; } -Vector3d* EveLocalPositionCurve::InterpolatedPosition( Vector3d* out, Be::Time time ) +Vector3d* EveLocalPositionCurve::InterpolatedPosition( Vector3d* out, Be::Time time ) { out->x = m_value.x; out->y = m_value.y; out->z = m_value.z; return out; - } void EveLocalPositionCurve::SetBehavior( LocalPositionBehavior behavior ) { m_behavior = behavior; } - - - - - - - diff --git a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.h b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.h index 52b5e33c0..2f78dfb98 100644 --- a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.h +++ b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve.h @@ -14,8 +14,7 @@ the LocalPositionBehavior enum.\r\n */ BLUE_DECLARE( EveTurretSet ); -class EveLocalPositionCurve: - public ITriVectorFunction +class EveLocalPositionCurve : public ITriVectorFunction { public: @@ -41,7 +40,11 @@ class EveLocalPositionCurve: ///////////////////////////////////////////////////////////////////////////////////// // ITriVectorFunction - void UpdateValue( double time ) { Vector3 v; Update( &v, time ); } + void UpdateValue( double time ) + { + Vector3 v; + Update( &v, time ); + } Vector3* Update( Vector3* in, Be::Time time ); Vector3* Update( Vector3* in, double time ); @@ -83,7 +86,7 @@ class EveLocalPositionCurve: // turret data int m_muzzleIndex; - + Vector3* CalculateOffsetPlaneRotation( Vector3* in, Be::Time t ); Vector3* CalculateOffsetPosition( Vector3* in, Be::Time t ); Vector3* CalculateNearestBoundingPoint( Vector3* in, Be::Time t ); @@ -94,6 +97,6 @@ class EveLocalPositionCurve: Vector3* GetFiringTurretPosition( Vector3* in, Be::Time t ); }; -TYPEDEF_BLUECLASS(EveLocalPositionCurve); +TYPEDEF_BLUECLASS( EveLocalPositionCurve ); -#endif +#endif diff --git a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve_Blue.cpp index 98dd0f963..05bd602b5 100644 --- a/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveLocalPositionCurve_Blue.cpp @@ -5,191 +5,141 @@ BLUE_DEFINE( EveLocalPositionCurve ); -Be::VarChooser EveLocalPositionChooser[] = -{ - { - "none", - BeCast( EveLocalPositionCurve::POS_NONE ), - "No position." - }, - { - "nearestBounds", - BeCast( EveLocalPositionCurve::POS_NEAREST_BOUNDING_POINT ), - "use the closest point on the ellyptical bounding sphere of the parent object." - }, - { - "centerBounds", - BeCast( EveLocalPositionCurve::POS_CENTER_BOUNDING_POINT), - "Use the center of the bounding sphere of the parent object." - }, - { - "damageLocator", - BeCast( EveLocalPositionCurve::POS_TARGET_DMG_LOCATOR ), - "Use a damage locator of the target object." - }, - { - "damageLocatorImpact", - BeCast( EveLocalPositionCurve::POS_TARGET_DMG_LOCATOR_IMPACT ), - "Use a damage locator of the target object, but with impact effect" - }, - { - "offsetPosition", - BeCast( EveLocalPositionCurve::POS_OFFSET_POSITION ), - "Calculate a position based on an offset from parent position" - }, - { - "offsetPlaneRotation", - BeCast( EveLocalPositionCurve::POS_OFFSET_PLANE_ROTATION ), - "Moves the vector from parentPositionCurve(or 0, 0, 0) to alignedPositionCurve OR positionOffset to the xz plane " - "containing parentPositionCurve, maintaining the vector's length." - }, - { - "nearestFiringLocator", - BeCast( EveLocalPositionCurve::POS_NEAREST_FIRING_LOCATOR ), - "Use the nearest firing locator of source object" - }, - { - "activeTurret", - BeCast( EveLocalPositionCurve::POS_ACTIVE_TURRET), - "Use the active turret world position" - }, +Be::VarChooser EveLocalPositionChooser[] = { + { "none", + BeCast( EveLocalPositionCurve::POS_NONE ), + "No position." }, + { "nearestBounds", + BeCast( EveLocalPositionCurve::POS_NEAREST_BOUNDING_POINT ), + "use the closest point on the ellyptical bounding sphere of the parent object." }, + { "centerBounds", + BeCast( EveLocalPositionCurve::POS_CENTER_BOUNDING_POINT ), + "Use the center of the bounding sphere of the parent object." }, + { "damageLocator", + BeCast( EveLocalPositionCurve::POS_TARGET_DMG_LOCATOR ), + "Use a damage locator of the target object." }, + { "damageLocatorImpact", + BeCast( EveLocalPositionCurve::POS_TARGET_DMG_LOCATOR_IMPACT ), + "Use a damage locator of the target object, but with impact effect" }, + { "offsetPosition", + BeCast( EveLocalPositionCurve::POS_OFFSET_POSITION ), + "Calculate a position based on an offset from parent position" }, + { "offsetPlaneRotation", + BeCast( EveLocalPositionCurve::POS_OFFSET_PLANE_ROTATION ), + "Moves the vector from parentPositionCurve(or 0, 0, 0) to alignedPositionCurve OR positionOffset to the xz plane " + "containing parentPositionCurve, maintaining the vector's length." }, + { "nearestFiringLocator", + BeCast( EveLocalPositionCurve::POS_NEAREST_FIRING_LOCATOR ), + "Use the nearest firing locator of source object" }, + { "activeTurret", + BeCast( EveLocalPositionCurve::POS_ACTIVE_TURRET ), + "Use the active turret world position" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( - "EveLocalPositionBehavior", - EveLocalPositionCurve::LocalPositionBehavior, - EveLocalPositionChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "EveLocalPositionBehavior", + EveLocalPositionCurve::LocalPositionBehavior, + EveLocalPositionChooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); const Be::ClassInfo* EveLocalPositionCurve::ExposeToBlue() { EXPOSURE_BEGIN( EveLocalPositionCurve, "" ) MAP_INTERFACE( ITriVectorFunction ) - - MAP_ATTRIBUTE_WITH_CHOOSER - ( + + MAP_ATTRIBUTE_WITH_CHOOSER( "behavior", m_behavior, "Chooses between position calculation behaviour.", - Be::READWRITE | Be::PERSIST | Be::ENUM, - EveLocalPositionChooser - ) + Be::READWRITE | Be::PERSIST | Be::ENUM, + EveLocalPositionChooser ) - MAP_ATTRIBUTE - ( - "parentPositionCurve", + MAP_ATTRIBUTE( + "parentPositionCurve", m_parentPositionCurve, - "na", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + "na", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parentRotationCurve", m_parentRotationCurve, "na", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( - "alignPositionCurve", + MAP_ATTRIBUTE( + "alignPositionCurve", m_alignPositionCurve, - "na", - Be::READWRITE | Be::PERSIST - ) + "na", + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "parent", m_parentObject, "na", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "turretSetObject", m_turretSetObject, "na", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "muzzleIndex", m_muzzleIndex, "na", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "value", - m_value, - "na", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "boundingSize", - m_boundingBoxSize, - "na", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "offset", - m_offset, - "na", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE ) + + MAP_ATTRIBUTE( + "value", + m_value, + "na", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "boundingSize", + m_boundingBoxSize, + "na", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "offset", + m_offset, + "na", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "The locatorSet name that is being used by the curve", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "locatorIndex", m_locatorIndex, "The locator index that is being used by the curve", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "positionOffset", - m_positionOffset, - "na", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "damageLocatorIndex", - m_damageLocatorIndex, - "The damage locator index that is being used by the curve", - Be::READ - ) + Be::READWRITE ) + + MAP_ATTRIBUTE( + "positionOffset", + m_positionOffset, + "na", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "damageLocatorIndex", + m_damageLocatorIndex, + "The damage locator index that is being used by the curve", + Be::READ ) MAP_ATTRIBUTE( "impactSize", m_impactSize, "Holds the size of the impact effect", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", SetBehavior, 1, "Create a EveLocalPostitionCurve with a render step that issues a Python callback\n" - ":param cb: a Python callable (default None)" - ) + ":param cb: a Python callable (default None)" ) EXPOSURE_END() } diff --git a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.cpp b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.cpp index 73e798db8..0160a87d0 100644 --- a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.cpp +++ b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.cpp @@ -6,7 +6,7 @@ #include "include/TriMath.h" -EveRemotePositionCurve::EveRemotePositionCurve(IRoot* lockobj) : +EveRemotePositionCurve::EveRemotePositionCurve( IRoot* lockobj ) : m_value( 0.f, 0.f, 0.f ), m_offsetDir1( 0.f, 0.f, 0.f ), m_offsetDir2( 0.f, 0.f, 0.f ), @@ -14,7 +14,7 @@ EveRemotePositionCurve::EveRemotePositionCurve(IRoot* lockobj) : m_delayTime( 0.f ), m_sweepTime( 1.f ), m_cycle( false ) -{ +{ } EveRemotePositionCurve::~EveRemotePositionCurve() @@ -139,7 +139,6 @@ Vector3* EveRemotePositionCurve::GetValueDotAt( Vector3* in, double time ) // -------------------------------------------------------------------------------- Vector3d* EveRemotePositionCurve::InterpolatedPosition( Vector3d* out, Be::Time time ) { - *out = Vector3d( double(m_value.x), double(m_value.y), double(m_value.z) ); + *out = Vector3d( double( m_value.x ), double( m_value.y ), double( m_value.z ) ); return out; } - diff --git a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.h b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.h index e3ed05b5a..3730fa1e7 100644 --- a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.h +++ b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve.h @@ -18,16 +18,20 @@ BLUE_CLASS( EveRemotePositionCurve ) : ///////////////////////////////////////////////////////////////////////////////////// // ITriVectorFunction - void UpdateValue( double time ) { Vector3 v; Update( &v, time ); } - Vector3* Update( Vector3* in, Be::Time time ); - Vector3* Update( Vector3* in, double time ); - Vector3* GetValueAt( Vector3* in, Be::Time time ); - Vector3* GetValueAt( Vector3* in, double time ); - Vector3* GetValueDotAt( Vector3* in, Be::Time time ); - Vector3* GetValueDotAt( Vector3* in, double time ); - Vector3* GetValueDoubleDotAt( Vector3* in, Be::Time time ); - Vector3* GetValueDoubleDotAt( Vector3* in, double time ); - Vector3d* InterpolatedPosition( Vector3d* out, Be::Time time ); + void UpdateValue( double time ) + { + Vector3 v; + Update( &v, time ); + } + Vector3* Update( Vector3 * in, Be::Time time ); + Vector3* Update( Vector3 * in, double time ); + Vector3* GetValueAt( Vector3 * in, Be::Time time ); + Vector3* GetValueAt( Vector3 * in, double time ); + Vector3* GetValueDotAt( Vector3 * in, Be::Time time ); + Vector3* GetValueDotAt( Vector3 * in, double time ); + Vector3* GetValueDoubleDotAt( Vector3 * in, Be::Time time ); + Vector3* GetValueDoubleDotAt( Vector3 * in, double time ); + Vector3d* InterpolatedPosition( Vector3d * out, Be::Time time ); private: // the start point curve @@ -51,4 +55,4 @@ BLUE_CLASS( EveRemotePositionCurve ) : TYPEDEF_BLUECLASS( EveRemotePositionCurve ); -#endif +#endif diff --git a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve_Blue.cpp index 94acf874b..d212c9785 100644 --- a/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveRemotePositionCurve_Blue.cpp @@ -17,6 +17,6 @@ const Be::ClassInfo* EveRemotePositionCurve::ExposeToBlue() MAP_ATTRIBUTE( "delayTime", m_delayTime, "A certain time to wait until the sweep starts", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "sweepTime", m_sweepTime, "Total time of one sweep", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "cycle", m_cycle, "Does it start all over again?", Be::READWRITE | Be::PERSIST ) - + EXPOSURE_END() } diff --git a/trinity/Eve/Renderable/Stretch/EveStretch.cpp b/trinity/Eve/Renderable/Stretch/EveStretch.cpp index bb7b02bac..1a49299f7 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch.cpp @@ -12,7 +12,7 @@ #include "Audio/Tr2AudioStretchAuto.h" #include "Audio/Tr2AudioStretchBase.h" -static const Vector3 Y_AXIS(0.0f, 1.0f, 0.0f); +static const Vector3 Y_AXIS( 0.0f, 1.0f, 0.0f ); EveStretch::EveStretch( IRoot* lockobj ) : PARENTLOCK( m_curveSets ), @@ -108,12 +108,12 @@ void EveStretch::UpdateAsyncronous( const EveUpdateContext& updateContext ) m_destObject->Update( updateContext ); } - if (auto tmp = dynamic_cast< Tr2AudioStretchBase* > ( m_audio.p )) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->Update( m_sourcePosition, m_destinationPosition ); } - if (m_stretchAudio != nullptr ) + if( m_stretchAudio != nullptr ) { m_stretchAudio->Update( m_sourcePosition, m_destinationPosition ); } @@ -166,7 +166,7 @@ void EveStretch::UpdateCurves( const EveUpdateContext& updateContext ) for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( TimeAsDouble( time ) ); + ( *it )->Update( TimeAsDouble( time ) ); } } } @@ -293,7 +293,7 @@ void EveStretch::UpdateVisibility( const EveUpdateContext& updateContext, const } } -void EveStretch::GetRenderables( std::vector& renderables) +void EveStretch::GetRenderables( std::vector& renderables ) { GetRenderables( renderables, nullptr ); } @@ -337,7 +337,7 @@ void EveStretch::StartMoving() m_moveObject->SetDisplay( true ); } - if ( auto tmp = dynamic_cast< Tr2AudioStretchAuto* > ( m_audio.p ) ) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->TriggerStretchEvent(); } @@ -348,7 +348,7 @@ void EveStretch::Start() { StartMoving(); - if ( !m_curveSets.empty() ) + if( !m_curveSets.empty() ) { m_curveSets.front()->Play(); } @@ -449,7 +449,6 @@ void EveStretch::StartFiring( float delay ) { curveSet->PlayFrom( -delay ); StartMoving(); - } else if( curveSet->GetName() == "play_loop" ) { @@ -462,14 +461,14 @@ void EveStretch::StartFiring( float delay ) } } - if ( auto tmp = dynamic_cast< Tr2AudioStretchAuto* > ( m_audio.p ) ) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->TriggerOutburstEvent(); tmp->TriggerImpactEvent(); tmp->TriggerStretchEvent(); } - if ( m_stretchAudio != nullptr ) + if( m_stretchAudio != nullptr ) { m_stretchAudio->Start(); } @@ -546,7 +545,8 @@ void EveStretch::GetLights( Tr2LightManager& lightManager ) const m = RotationXMatrix( -XM_PI / 2.0f ); m = m * m_sourceTransform; scaling = XMVectorGetX( XMVectorAdd( XMVector3LengthEst( m.GetX() ), - XMVectorAdd( XMVector3LengthEst( m.GetY() ), XMVector3LengthEst( m.GetZ() ) ) ) ) / 3.f; + XMVectorAdd( XMVector3LengthEst( m.GetY() ), XMVector3LengthEst( m.GetZ() ) ) ) ) / + 3.f; } else { @@ -579,12 +579,12 @@ void EveStretch::GetLights( Tr2LightManager& lightManager ) const void EveStretch::GetDebugOptions( Tr2DebugRendererOptions& options ) { - if (auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_audio.p )) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->GetDebugOptions( options ); } - if (auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_stretchAudio.p )) + if( auto tmp = dynamic_cast( m_stretchAudio.p ) ) { tmp->GetDebugOptions( options ); } @@ -592,12 +592,12 @@ void EveStretch::GetDebugOptions( Tr2DebugRendererOptions& options ) void EveStretch::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if (auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_audio.p )) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->RenderDebugInfo( renderer ); } - if (auto tmp = dynamic_cast< ITr2DebugRenderable* > ( m_stretchAudio.p )) + if( auto tmp = dynamic_cast( m_stretchAudio.p ) ) { tmp->RenderDebugInfo( renderer ); } diff --git a/trinity/Eve/Renderable/Stretch/EveStretch.h b/trinity/Eve/Renderable/Stretch/EveStretch.h index e7ed87c78..dbd9851e9 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch.h +++ b/trinity/Eve/Renderable/Stretch/EveStretch.h @@ -17,18 +17,17 @@ BLUE_DECLARE( EveStretch ); BLUE_DECLARE( TriFloat ); -class EveStretch: - public IEveFiringEffectElement, - public INotify, - public IEveTransform, - public IEveSpaceObject2, - public ITr2DebugRenderable, - public ITr2LightOwner, - public EveEntity +class EveStretch : public IEveFiringEffectElement, + public INotify, + public IEveTransform, + public IEveSpaceObject2, + public ITr2DebugRenderable, + public ITr2LightOwner, + public EveEntity { public: - EXPOSE_TO_BLUE(); - EveStretch( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EveStretch( IRoot* lockobj = NULL ); void SetSourcePosition( Vector3 val ); void SetDestinationPosition( Vector3 val ); @@ -46,11 +45,17 @@ class EveStretch: void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); virtual void GetRenderables( std::vector& renderables ); virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) {}; - virtual void GetModelCenterWorldPosition( Vector3 &position ) const {}; - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } - virtual void GetLocalToWorldTransform( Matrix &transform ) const { transform = IdentityMatrix(); } + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + virtual void UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) {}; + virtual void GetModelCenterWorldPosition( Vector3& position ) const {}; + virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ) + { + return false; + } + virtual void GetLocalToWorldTransform( Matrix& transform ) const + { + transform = IdentityMatrix(); + } ///////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner @@ -68,21 +73,39 @@ class EveStretch: // IEveTranfrom virtual void Update( const EveUpdateContext& updateContext ); virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ) {}; - virtual Tr2Lod GetLODLevel() const { return m_lodLevel; } - - unsigned int GetCurveSetCount() const { return (unsigned int)m_curveSets.size(); } - TriCurveSetPtr GetCurveSet( unsigned int n ) { return m_curveSets[n]; } + virtual Tr2Lod GetLODLevel() const + { + return m_lodLevel; + } + + unsigned int GetCurveSetCount() const + { + return (unsigned int)m_curveSets.size(); + } + TriCurveSetPtr GetCurveSet( unsigned int n ) + { + return m_curveSets[n]; + } // toggle display of source and dest objects of the stretcher - void SetDisplayDestObject( bool display ) { m_displayDestObject = display; } - void SetDisplaySourceObject( bool display ) { m_displaySourceObject = display; } + void SetDisplayDestObject( bool display ) + { + m_displayDestObject = display; + } + void SetDisplaySourceObject( bool display ) + { + m_displaySourceObject = display; + } void UpdateCurves( const EveUpdateContext& updateContext ); void Start(); virtual void SetDisplay( bool display ); - virtual void SetDestObjectScale( float scale ) { m_destObjectScale = scale; }; + virtual void SetDestObjectScale( float scale ) + { + m_destObjectScale = scale; + }; virtual void StartMoving(); virtual float GetCurveDuration(); virtual void StartFiring( float delay ); @@ -94,11 +117,15 @@ class EveStretch: virtual void SetFiringTransform( const Vector3& source, const Vector3& dest ); virtual void DisplayEndPoints( bool displaySource, bool displayDest ); - void SetSourceObjectScale( float scale ) { m_sourceObjectScale = scale; }; + void SetSourceObjectScale( float scale ) + { + m_sourceObjectScale = scale; + }; // debug void GetDebugOptions( Tr2DebugRendererOptions& options ); void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + private: Tr2Lod m_lodLevel; Be::Time m_lastCurveUpdateTime; @@ -127,12 +154,12 @@ class EveStretch: Matrix m_sourceTransform; Matrix m_destinationTransform; - Vector3 m_sourcePosition; + Vector3 m_sourcePosition; Vector3 m_destinationPosition; ITriVectorFunctionPtr m_source; ITriVectorFunctionPtr m_dest; - + EveTransformPtr m_sourceObject; EveTransformPtr m_destObject; EveTransformPtr m_stretchObject; diff --git a/trinity/Eve/Renderable/Stretch/EveStretch2.cpp b/trinity/Eve/Renderable/Stretch/EveStretch2.cpp index bc1978e39..a936bc794 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch2.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch2.cpp @@ -17,64 +17,64 @@ namespace { - class StretchPerObjectData : public Tr2PerObjectData +class StretchPerObjectData : public Tr2PerObjectData +{ +public: + virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { - public: - virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const - { - FillAndSetConstants( - *buffers[Tr2RenderContextEnum::VERTEX_SHADER], - m_data, - m_size, - Tr2RenderContextEnum::VERTEX_SHADER, - Tr2Renderer::GetPerObjectVSStartRegister(), - renderContext ); - FillAndSetConstants( - *buffers[Tr2RenderContextEnum::PIXEL_SHADER], - m_data, - m_size, - Tr2RenderContextEnum::PIXEL_SHADER, - Tr2Renderer::GetPerObjectPSStartRegister(), - renderContext ); - } + FillAndSetConstants( + *buffers[Tr2RenderContextEnum::VERTEX_SHADER], + m_data, + m_size, + Tr2RenderContextEnum::VERTEX_SHADER, + Tr2Renderer::GetPerObjectVSStartRegister(), + renderContext ); + FillAndSetConstants( + *buffers[Tr2RenderContextEnum::PIXEL_SHADER], + m_data, + m_size, + Tr2RenderContextEnum::PIXEL_SHADER, + Tr2Renderer::GetPerObjectPSStartRegister(), + renderContext ); + } - void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override - { - writer.SetPerObjectData( Tr2RenderContextEnum::VERTEX_SHADER, m_data, m_size ); - writer.SetPerObjectData( Tr2RenderContextEnum::PIXEL_SHADER, m_data, m_size ); - } + void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override + { + writer.SetPerObjectData( Tr2RenderContextEnum::VERTEX_SHADER, m_data, m_size ); + writer.SetPerObjectData( Tr2RenderContextEnum::PIXEL_SHADER, m_data, m_size ); + } - void* m_data; - size_t m_size; - }; + void* m_data; + size_t m_size; +}; - struct Vertex - { - float quadIndex; - float cornerIndex; - }; +struct Vertex +{ + float quadIndex; + float cornerIndex; +}; - const uint32_t MAX_QUAD_COUNT = 128; +const uint32_t MAX_QUAD_COUNT = 128; - ALResult GetEveStretch2Quads( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) +ALResult GetEveStretch2Quads( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) +{ + std::vector data( MAX_QUAD_COUNT * 4 ); + for( uint32_t i = 0; i < MAX_QUAD_COUNT; ++i ) { - std::vector data( MAX_QUAD_COUNT * 4 ); - for( uint32_t i = 0; i < MAX_QUAD_COUNT; ++i ) + for( uint32_t j = 0; j < 4; ++j ) { - for( uint32_t j = 0; j < 4; ++j ) - { - data[i * 4 + j].quadIndex = float( i ); - data[i * 4 + j].cornerIndex = float( j ); - } + data[i * 4 + j].quadIndex = float( i ); + data[i * 4 + j].cornerIndex = float( j ); } - - return g_sharedBuffer.Allocate( sizeof( Vertex ), MAX_QUAD_COUNT * 4, data.data(), renderContext, vb ); } + return g_sharedBuffer.Allocate( sizeof( Vertex ), MAX_QUAD_COUNT * 4, data.data(), renderContext, vb ); } -EveStretch2::EveStretch2( IRoot* lockObj ) - :m_source( 0.f, 0.f, 0.f ), +} + +EveStretch2::EveStretch2( IRoot* lockObj ) : + m_source( 0.f, 0.f, 0.f ), m_destination( 0.f, 0.f, 0.f ), m_currentDestinationScale( 1.f ), m_destinationScale( 1.f ), @@ -190,7 +190,7 @@ void EveStretch2::SetDisplay( bool display ) m_visible = display; if( m_visible != prev ) { - ReRegister(); + ReRegister(); } } @@ -199,7 +199,7 @@ void EveStretch2::SetIntensity( float intensity ) float prev = m_intensity; m_intensity = intensity; - if( ( prev == 0 && intensity > 0 ) || (prev > 0 && intensity == 0 ) ) + if( ( prev == 0 && intensity > 0 ) || ( prev > 0 && intensity == 0 ) ) { ReRegister(); } @@ -399,7 +399,7 @@ void EveStretch2::RegisterComponents() void EveStretch2::GetLights( Tr2LightManager& lightManager ) const { - if( !m_visible || m_intensity == 0) + if( !m_visible || m_intensity == 0 ) { return; } @@ -417,12 +417,12 @@ void EveStretch2::GetLights( Tr2LightManager& lightManager ) const } } -void EveStretch2::GetDebugOptions( Tr2DebugRendererOptions& options ) +void EveStretch2::GetDebugOptions( Tr2DebugRendererOptions& options ) { options.insert( "Stretch bounds" ); } -void EveStretch2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) +void EveStretch2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { if( renderer.HasOption( this, "Stretch bounds" ) ) { diff --git a/trinity/Eve/Renderable/Stretch/EveStretch2.h b/trinity/Eve/Renderable/Stretch/EveStretch2.h index f469b28d9..263247b28 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch2.h +++ b/trinity/Eve/Renderable/Stretch/EveStretch2.h @@ -20,10 +20,10 @@ BLUE_DECLARE( TriObserverLocal ); // -------------------------------------------------------------------------------------- // Description: // EveStretch2 is a simplified version of EveStretch. Renders an effect between two -// points as a set of quads. +// points as a set of quads. // -------------------------------------------------------------------------------------- -BLUE_CLASS( EveStretch2 ) - :public IEveFiringEffectElement, +BLUE_CLASS( EveStretch2 ) : + public IEveFiringEffectElement, public ITr2Renderable, public Tr2DeviceResource, public IInitialize, @@ -38,7 +38,7 @@ BLUE_CLASS( EveStretch2 ) EveStretch2( IRoot* lockObj = nullptr ); virtual bool Initialize(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); virtual void SetDestObjectScale( float scale ); virtual void StartMoving(); @@ -57,17 +57,17 @@ BLUE_CLASS( EveStretch2 ) virtual void UpdateEffectSync( const EveUpdateContext& updateContext ) override; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - virtual void GetRenderables( std::vector& renderables ); + virtual void GetRenderables( std::vector & renderables ); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches(); virtual float GetSortValue(); ///////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - virtual void GetLights( Tr2LightManager& lightManager ) const override; - + virtual void GetLights( Tr2LightManager & lightManager ) const override; + ///////////////////////////////////////////////////////////////////////////////////// // EveEntity virtual void RegisterComponents() override; @@ -80,8 +80,9 @@ BLUE_CLASS( EveStretch2 ) protected: virtual void ReleaseResources( TriStorage s ); virtual bool OnPrepareResources(); + private: - void GetEndPointTransforms( Matrix& source, Matrix& destination ) const; + void GetEndPointTransforms( Matrix & source, Matrix & destination ) const; Matrix GetDestinationTransform() const; Tr2EffectPtr m_effect; @@ -108,7 +109,7 @@ BLUE_CLASS( EveStretch2 ) Vector4 m_effectData[2]; uint32_t m_quadCount; - Tr2ProceduralBuffer m_vb; + Tr2ProceduralBuffer m_vb; unsigned int m_vertexDeclHandle; float m_intensity; diff --git a/trinity/Eve/Renderable/Stretch/EveStretch2_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveStretch2_Blue.cpp index a5c2b5d53..c48f60ec3 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch2_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch2_Blue.cpp @@ -17,93 +17,69 @@ const Be::ClassInfo* EveStretch2::ExposeToBlue() MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effect", m_effect, "Effect to use for the stretch", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "quadCount", m_quadCount, "Number of quads to render for the effect", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "start", m_start, "Curve set to play when firing effect starts", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "loop", m_loop, "Curve set that is played when the effect is active", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "end", m_end, "Curve set to play when the effect stops", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceLight", m_sourceLight, "Point light at the effect source", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationLight", m_destinationLight, "Point light at the effect destination", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceEmitter", m_sourceEmitter, "GPU particle emitter at the source", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationEmitter", m_destinationEmitter, "GPU particle emitter at the destination", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceObserver", m_sourceObserver, "Observer at the source position", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationObserver", m_destinationObserver, "Observer at the destination position", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boundingRadius", m_boundingRadius, diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp index fa41a97cd..ef4a5711e 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.cpp @@ -73,7 +73,7 @@ bool EveStretch3::Initialize() IEveSpaceObject2* EveStretch3::GetSourceSpaceObject() const { - return m_sourceSpaceObject; + return m_sourceSpaceObject; } void EveStretch3::SetSourceSpaceObject( IEveSpaceObject2* spaceObject ) @@ -723,15 +723,13 @@ void EveStretch3::RegisterComponents() auto registry = this->GetComponentRegistry(); if( registry && m_display ) { - RunOnComponents( - [this]( IEveSpaceObjectChild* c ) - { + RunOnComponents( + [this]( IEveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->Register( GetComponentRegistry() ); } - } - ); + } ); } } @@ -740,15 +738,13 @@ void EveStretch3::UnRegisterComponents() auto registry = this->GetComponentRegistry(); if( registry ) { - RunOnComponents( - [this]( IEveSpaceObjectChild* c ) - { + RunOnComponents( + [this]( IEveSpaceObjectChild* c ) { if( EveEntityPtr entity = BlueCastPtr( c ) ) { entity->UnRegister( GetComponentRegistry() ); } - } - ); + } ); } } @@ -849,12 +845,12 @@ void EveStretch3::GetDebugOptions( Tr2DebugRendererOptions& options ) } } ); - if(auto tmp = dynamic_cast( m_audio.p ) ) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->GetDebugOptions( options ); } - if( auto tmp = dynamic_cast< ITr2DebugRenderable* >( m_stretchAudio.p ) ) + if( auto tmp = dynamic_cast( m_stretchAudio.p ) ) { tmp->GetDebugOptions( options ); } @@ -874,12 +870,12 @@ void EveStretch3::RenderDebugInfo( ITr2DebugRenderer2& renderer ) } } ); - if( auto tmp = dynamic_cast< ITr2DebugRenderable* >( m_audio.p ) ) + if( auto tmp = dynamic_cast( m_audio.p ) ) { tmp->RenderDebugInfo( renderer ); } - if( auto tmp = dynamic_cast< ITr2DebugRenderable* >( m_stretchAudio.p ) ) + if( auto tmp = dynamic_cast( m_stretchAudio.p ) ) { tmp->RenderDebugInfo( renderer ); } diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3.h b/trinity/Eve/Renderable/Stretch/EveStretch3.h index bf0025c23..1040a537d 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3.h +++ b/trinity/Eve/Renderable/Stretch/EveStretch3.h @@ -30,7 +30,7 @@ BLUE_DECLARE( Tr2DynamicBinding ); BLUE_DECLARE_VECTOR( Tr2DynamicBinding ); -BLUE_CLASS( EveStretch3 ): +BLUE_CLASS( EveStretch3 ) : public IEveFiringEffectElement, public ITr2DebugRenderable, public ITr2DynamicBindingOwner, @@ -44,13 +44,13 @@ BLUE_CLASS( EveStretch3 ): public EveEntity { public: - EXPOSE_TO_BLUE(); - EveStretch3( IRoot* lockobj = NULL ); - ~EveStretch3(); + EXPOSE_TO_BLUE(); + EveStretch3( IRoot* lockobj = NULL ); + ~EveStretch3(); - void Rebind( bool onlyUpdateBindings = 0 ); - IEveSpaceObject2* GetSourceSpaceObject() const; - IEveSpaceObject2* GetDestSpaceObject() const; + void Rebind( bool onlyUpdateBindings = 0 ); + IEveSpaceObject2* GetSourceSpaceObject() const; + IEveSpaceObject2* GetDestSpaceObject() const; ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -61,14 +61,14 @@ BLUE_CLASS( EveStretch3 ): virtual void UpdateSyncronous( const EveUpdateContext& updateContext ); virtual void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - virtual void GetRenderables( std::vector& renderables ); - virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - virtual void GetModelCenterWorldPosition( Vector3 &position ) const; - virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ); - virtual void GetLocalToWorldTransform( Matrix& transform ) const; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + virtual void GetRenderables( std::vector & renderables ); + virtual void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + virtual void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + virtual void GetModelCenterWorldPosition( Vector3 & position ) const; + virtual bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + virtual void GetLocalToWorldTransform( Matrix & transform ) const; + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); ///////////////////////////////////////////////////////////////////////////////////// @@ -81,11 +81,11 @@ BLUE_CLASS( EveStretch3 ): virtual void SetControllerVariable( const char* name, float value ); virtual void HandleControllerEvent( const char* name ); virtual void StartControllers(); - virtual void GetBindingRoots( std::unordered_map& variables ); + virtual void GetBindingRoots( std::unordered_map & variables ); ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; ////////////////////////////////////////////////////////////////////////// // IListNotify @@ -93,8 +93,8 @@ BLUE_CLASS( EveStretch3 ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2CurveSetOwner @@ -127,17 +127,17 @@ BLUE_CLASS( EveStretch3 ): ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; IEveSpaceObjectChild* GetSourceObject(); - void SetSourceObject( IEveSpaceObjectChild* sourceObject ); + void SetSourceObject( IEveSpaceObjectChild * sourceObject ); IEveSpaceObjectChild* GetDestObject(); - void SetDestObject( IEveSpaceObjectChild* destObject ); + void SetDestObject( IEveSpaceObjectChild * destObject ); IEveSpaceObjectChild* GetStretchObject(); - void SetStretchObject( IEveSpaceObjectChild* stretchObject ); + void SetStretchObject( IEveSpaceObjectChild * stretchObject ); IEveSpaceObjectChild* GetMoveObject(); - void SetMoveObject( IEveSpaceObjectChild* moveObject ); + void SetMoveObject( IEveSpaceObjectChild * moveObject ); private: - - enum StretchState { + enum StretchState + { STRETCH_STATE_UNDEFINED, STRETCH_STATE_STARTING, STRETCH_STATE_STARTED, @@ -195,4 +195,3 @@ BLUE_CLASS( EveStretch3 ): }; TYPEDEF_BLUECLASS( EveStretch3 ); - diff --git a/trinity/Eve/Renderable/Stretch/EveStretch3_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveStretch3_Blue.cpp index d3daabd85..b96ac8d58 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch3_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch3_Blue.cpp @@ -8,8 +8,8 @@ BLUE_DEFINE_INTERFACE( IStretchAudio ); const Be::ClassInfo* EveStretch3::ExposeToBlue() { - EXPOSURE_BEGIN( EveStretch3, "" ) - MAP_INTERFACE( EveStretch3 ) + EXPOSURE_BEGIN( EveStretch3, "" ) + MAP_INTERFACE( EveStretch3 ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IListNotify ) MAP_INTERFACE( IInitialize ) @@ -21,230 +21,177 @@ const Be::ClassInfo* EveStretch3::ExposeToBlue() MAP_INTERFACE( ITr2SoundEmitterOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "If set, this transform hierarchy is displayed.\n" "Note that turning off display does not automatically turn\n" "off update.", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "update", m_update, "If set, this transform hierarchy is updated every frame.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "source", m_source, "", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "dest", m_dest, "", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "sourcePosition", m_sourcePosition, "", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "destinationPosition", m_destinationPosition, "", - Be::READ - ) - - MAP_ATTRIBUTE - ( + Be::READ ) + + MAP_ATTRIBUTE( "length", m_length, "Distance between the source and the destination", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_PROPERTY - ( + MAP_PROPERTY( "sourceSpaceObject", GetSourceSpaceObject, SetSourceSpaceObject, - "" - ) + "" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "destSpaceObject", GetDestSpaceObject, SetDestSpaceObject, - "" - ) + "" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "sourceObject", m_sourceObject, "Object to be rendered at the source", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "sourceObject", - GetSourceObject, - SetSourceObject, - "Object to be rendered at the source" - ) - - MAP_ATTRIBUTE - ( + Be::PERSISTONLY ) + + MAP_PROPERTY( + "sourceObject", + GetSourceObject, + SetSourceObject, + "Object to be rendered at the source" ) + + MAP_ATTRIBUTE( "destObject", m_destObject, "Object to be rendered at the destination", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "destObject", - GetDestObject, - SetDestObject, - "Object to be rendered at the destination" - ) - - MAP_ATTRIBUTE - ( + Be::PERSISTONLY ) + + MAP_PROPERTY( + "destObject", + GetDestObject, + SetDestObject, + "Object to be rendered at the destination" ) + + MAP_ATTRIBUTE( "stretchObject", m_stretchObject, "Object to be stretched from source to destination", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "stretchObject", - GetStretchObject, - SetStretchObject, - "Object to be stretched from source to destination" - ) - - MAP_ATTRIBUTE - ( + Be::PERSISTONLY ) + + MAP_PROPERTY( + "stretchObject", + GetStretchObject, + SetStretchObject, + "Object to be stretched from source to destination" ) + + MAP_ATTRIBUTE( "moveObject", m_moveObject, "Unstretched object to be translated from source to destination", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "moveObject", - GetMoveObject, - SetMoveObject, - "Unstretched object to be translated from source to destination" - ) - - MAP_ATTRIBUTE - ( + Be::PERSISTONLY ) + + MAP_PROPERTY( + "moveObject", + GetMoveObject, + SetMoveObject, + "Unstretched object to be translated from source to destination" ) + + MAP_ATTRIBUTE( "moveProgression", m_moveProgression, "A value between 0 and 1 to determine the position of the move object between source and dest", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "startTime", m_startTime, "Start time", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "controllers", m_controllers, "Controllers for awesomeness", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curvesets for animating things", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "dynamicBindings", m_dynamicBindings, "Dynamic bindings", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "audio", m_audio, "The type of audio to be used for this asset\n:jessica-deprecated: True\n:jessica-hidden: True", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "stretchAudio", m_stretchAudio, "An audio object specifically for stretch effects.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "StartFiring", StartFiring, "Starts the firing effect\n " ":param delay: The delay in seconds until it start firing (sets the firingDelay variable on the controllers)" - "" - ) + "" ) MAP_METHOD_AND_WRAP( "StopFiring", StopFiring, - "Stops the firing effect" - ) + "Stops the firing effect" ) MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/Renderable/Stretch/EveStretch_Blue.cpp b/trinity/Eve/Renderable/Stretch/EveStretch_Blue.cpp index 6a8cd6699..bb6e9a935 100644 --- a/trinity/Eve/Renderable/Stretch/EveStretch_Blue.cpp +++ b/trinity/Eve/Renderable/Stretch/EveStretch_Blue.cpp @@ -10,8 +10,8 @@ BLUE_DEFINE_INTERFACE( IStrechAudio ); const Be::ClassInfo* EveStretch::ExposeToBlue() { - EXPOSURE_BEGIN( EveStretch, "" ) - MAP_INTERFACE( EveStretch ) + EXPOSURE_BEGIN( EveStretch, "" ) + MAP_INTERFACE( EveStretch ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IEveTransform ) MAP_INTERFACE( IEveSpaceObject2 ) @@ -20,180 +20,134 @@ const Be::ClassInfo* EveStretch::ExposeToBlue() MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "If set, this transform hierarchy is displayed.\n" "Note that turning off display does not automatically turn\n" "off update.", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Start", Start, - "Trigger the movement if moveObject and curves exist." - ) + "Trigger the movement if moveObject and curves exist." ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "update", m_update, "If set, this transform hierarchy is updated every frame.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "source", m_source, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "dest", m_dest, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceObject", m_sourceObject, "Object to be rendered at the source", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destObject", m_destObject, "Object to be rendered at the destination", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "stretchObject", m_stretchObject, "Object to be stretched from source to destination", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "moveObject", m_moveObject, "Unstretched object to be translated from source to destination", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "sourceLights", m_sourceLights, "Lights at the source object", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "destLights", m_destLights, "Lights at the destination object", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "progressCurve", m_progressCurve, "Curve that determines the interpolated position of the move object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "startTime", m_startTime, "Start time", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "moveCompletion", m_moveCompletion, "Curveset that is triggered when the progress reaches 1.0", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "moveCompleted", m_moveCompleted, "Gets set to true when the move object reached destination", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "moving", m_moving, "Flag that is set when Play is called. Tells you that the move has started.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curvesets for animating things", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "length", m_length, "Distance between the source and the destination", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "lodLevel", m_lodLevel, "Current LOD level, 1(high) to 3(low)", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "useCurveLod", m_useCurveLod, "Should curves be LOD'd", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "audio", m_audio, "The type of audio to be used for this asset\n:jessica-deprecated: True\n:jessica-hidden: True", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "stretchAudio", m_stretchAudio, "An audio object specifically for stretch effects.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.cpp b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.cpp index 5f5d108d4..0a312e8d3 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.cpp @@ -46,7 +46,7 @@ float g_lightNoise[g_lightNoiseSize]; bool g_lightNoiseInitialized = false; -EveBoosterSet2Renderable::EveBoosterSet2Renderable( IRoot* lockobj ) : +EveBoosterSet2Renderable::EveBoosterSet2Renderable( IRoot* lockobj ) : m_isVisible( false ), m_parentRotation( 0.f, 0.f, 0.f, 1.f ), m_parentSpeed( 0.f ), @@ -69,10 +69,10 @@ EveBoosterSet2Renderable::EveBoosterSet2Renderable( IRoot* lockobj ) : // "invalidate" all trail control positions for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - m_trailsControlPositions[ i ] = Vector3( 0.f, 0.f, 0.f ); - m_trailsControlNormals[ i ] = Vector3( 0.f, 0.f, -1.f ); - m_trailsControlNormalsFactor[ i ] = 1.f; - m_trailsSequenceLength[ i ] = 0.f; + m_trailsControlPositions[i] = Vector3( 0.f, 0.f, 0.f ); + m_trailsControlNormals[i] = Vector3( 0.f, 0.f, -1.f ); + m_trailsControlNormalsFactor[i] = 1.f; + m_trailsSequenceLength[i] = 0.f; } m_trailsOffsets = (XMVECTOR*)CCP_ALIGNED_MALLOC( "EveBoosterSet2::m_trailsOffsets", sizeof( XMVECTOR ) * EVE_MAX_POSITION_OFFSET_COUNT, 16 ); @@ -128,7 +128,7 @@ float EveBoosterSet2Renderable::CalculateIntensity( const Vector3& acceleration, // dampening (like drum noise) accFactor = accFactor * 0.2f + m_lastAccFactor * 0.8f; m_lastAccFactor = accFactor; - float value = m_lastValue * 0.8f + ( speedMultiplier * speedRatio + accMultiplier * accFactor ) * 0.2f; + float value = m_lastValue * 0.8f + ( speedMultiplier * speedRatio + accMultiplier * accFactor ) * 0.2f; value = min( value, 2.0f ); m_lastValue = value; @@ -216,7 +216,7 @@ void EveBoosterSet2Renderable::GetBatches( ITriRenderBatchAccumulator* batches, batch.SetDrawIndexedInstanced( 3 * 2 * EVE_BOOSTER_PLANES_COUNT[shape], uint32_t( m_boosterSet->m_singleBoosters.size() ), - indexBuffer.GetStartIndex() , + indexBuffer.GetStartIndex(), vb.GetOffset() / vb.GetStride(), m_boosterSet->m_instanceBuffer.GetOffset() / m_boosterSet->m_instanceBuffer.GetStride() ); batches->Commit( batch ); @@ -281,8 +281,8 @@ Tr2PerObjectData* EveBoosterSet2Renderable::GetPerObjectData( ITriRenderBatchAcc for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - perObjectData->m_vsData.trailsControlPositions[ i ] = Vector4( m_trailsControlPositions[ i ], m_trailsSequenceLength[ i ] ); - perObjectData->m_vsData.trailsControlNormals[ i ] = Vector4( m_trailsControlNormals[ i ], m_trailsControlNormalsFactor[ i ] ); + perObjectData->m_vsData.trailsControlPositions[i] = Vector4( m_trailsControlPositions[i], m_trailsSequenceLength[i] ); + perObjectData->m_vsData.trailsControlNormals[i] = Vector4( m_trailsControlNormals[i], m_trailsControlNormalsFactor[i] ); } return perObjectData; @@ -322,7 +322,7 @@ void EveBoosterSet2Renderable::UpdateVisibility( const EveUpdateContext& updateC float sqDist = FLT_MAX; for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - Vector3 tmp( m_trailsControlPositions[ i ] - frustum.m_viewPos ); + Vector3 tmp( m_trailsControlPositions[i] - frustum.m_viewPos ); float d = LengthSq( tmp ); if( d < sqDist ) { @@ -330,7 +330,7 @@ void EveBoosterSet2Renderable::UpdateVisibility( const EveUpdateContext& updateC cntrPosIdx = i; } } - Vector4 tmp( m_trailsControlPositions[ cntrPosIdx ], transformedBoundingSphere.w ); + Vector4 tmp( m_trailsControlPositions[cntrPosIdx], transformedBoundingSphere.w ); float trailsLOD = 7.5f * frustum.GetPixelSizeAccross( &tmp ); m_trailsVisible = trailsLOD > updateContext.GetLowDetailThreshold(); @@ -358,7 +358,7 @@ void EveBoosterSet2Renderable::GetRenderables( std::vector& ren // -------------------------------------------------------------------------------- // Description: -// Does a lot of calculations for trails based on the movement of the parent (aka +// Does a lot of calculations for trails based on the movement of the parent (aka // the ship). Calling the function that calculates all the spline data. // Arguments: // deltaT - time since last frame @@ -427,7 +427,7 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) m_trailsOffsetAccu -= movementDir; // how many interations fit into elapsed time since last frame? - unsigned int iterCount = ( unsigned int )( m_trailsTimeToNext / EVE_POSITION_OFFSET_DELTAT ); + unsigned int iterCount = (unsigned int)( m_trailsTimeToNext / EVE_POSITION_OFFSET_DELTAT ); // cumulative offset XMVECTOR offset = ( ( EVE_POSITION_OFFSET_DELTAT / m_trailsTimeToNext ) * iterCount ) * m_trailsOffsetAccu; @@ -444,7 +444,7 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) { for( unsigned int i = 0; i < EVE_MAX_POSITION_OFFSET_COUNT; ++i ) { - m_trailsOffsets[ i ] = XMVectorAdd( m_trailsOffsets[i], offset ); + m_trailsOffsets[i] = XMVectorAdd( m_trailsOffsets[i], offset ); } } @@ -457,7 +457,7 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) m_trailsOffsetLatest = 0; } - m_trailsOffsets[m_trailsOffsetLatest] = ( ( iterCount - 1 - j ) * ( EVE_POSITION_OFFSET_DELTAT / m_trailsTimeToNext ) ) * m_trailsOffsetAccu;// offsets[j + 1]; + m_trailsOffsets[m_trailsOffsetLatest] = ( ( iterCount - 1 - j ) * ( EVE_POSITION_OFFSET_DELTAT / m_trailsTimeToNext ) ) * m_trailsOffsetAccu; // offsets[j + 1]; } } else @@ -484,11 +484,11 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) } if( n < iterCount ) { - m_trailsOffsets[ i ] = XMVectorMultiply( partialOffset, XMVectorReplicate( float( iterCount - 1 - n ) ) ); + m_trailsOffsets[i] = XMVectorMultiply( partialOffset, XMVectorReplicate( float( iterCount - 1 - n ) ) ); } else { - m_trailsOffsets[ i ] = XMVectorAdd( m_trailsOffsets[i], offset ); + m_trailsOffsets[i] = XMVectorAdd( m_trailsOffsets[i], offset ); } } m_trailsOffsetLatest = ( m_trailsOffsetLatest + iterCount - 1 ) % EVE_MAX_POSITION_OFFSET_COUNT; @@ -502,7 +502,7 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) int ringIdx = m_trailsOffsetLatest; for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - m_trailsControlPositions[ i ] = parentPos + Vector3( m_trailsOffsets[ ringIdx ] ); + m_trailsControlPositions[i] = parentPos + Vector3( m_trailsOffsets[ringIdx] ); ringIdx -= (unsigned int)( m_trailsTimeDelta / EVE_POSITION_OFFSET_DELTAT ); if( ringIdx < 0 ) @@ -517,8 +517,8 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { Vector3 rotatedOffset; - TriVectorRotateMatrix( &rotatedOffset, &m_boosterSet->m_trailsStaticOffsets[ i ], &m_parentTransform ); - m_trailsControlPositions[ i ] = parentPos + rotatedOffset; + TriVectorRotateMatrix( &rotatedOffset, &m_boosterSet->m_trailsStaticOffsets[i], &m_parentTransform ); + m_trailsControlPositions[i] = parentPos + rotatedOffset; } } @@ -527,7 +527,7 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) m_trailsTotalLength = 0.f; for( unsigned int i = 1; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - Vector3 sequenceDir = m_trailsControlPositions[ i ] - m_trailsControlPositions[ i - 1 ]; + Vector3 sequenceDir = m_trailsControlPositions[i] - m_trailsControlPositions[i - 1]; m_trailsTotalLength += Length( sequenceDir ); } @@ -541,8 +541,8 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { Vector3 r = Vector3( boosterBoundsSphere.w, boosterBoundsSphere.w, boosterBoundsSphere.w ); - Vector3 boundMin( m_trailsControlPositions[ i ] - r ); - Vector3 boundMax( m_trailsControlPositions[ i ] + r ); + Vector3 boundMin( m_trailsControlPositions[i] - r ); + Vector3 boundMax( m_trailsControlPositions[i] + r ); BoundingBoxUpdate( m_trailsBoundsMin, m_trailsBoundsMax, boundMin, boundMax ); } @@ -552,34 +552,34 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) m_trailsControlNormals[0] = TransformNormal( firstTangent, m_parentTransform ); // last tangent is always from before-last to last point - Vector3 lastDir = m_trailsControlPositions[ EVE_MAX_CONTROL_POINT_COUNT - 1 ] - m_trailsControlPositions[ EVE_MAX_CONTROL_POINT_COUNT - 2 ]; - m_trailsControlNormals[ EVE_MAX_CONTROL_POINT_COUNT - 1 ] = 0.5f * lastDir; + Vector3 lastDir = m_trailsControlPositions[EVE_MAX_CONTROL_POINT_COUNT - 1] - m_trailsControlPositions[EVE_MAX_CONTROL_POINT_COUNT - 2]; + m_trailsControlNormals[EVE_MAX_CONTROL_POINT_COUNT - 1] = 0.5f * lastDir; // the rest is calculated according to c-r (or something...) for( unsigned int i = 1; i < EVE_MAX_CONTROL_POINT_COUNT - 1; ++i ) { // from -1 to +1 - Vector3 dir = m_trailsControlPositions[ i + 1 ] - m_trailsControlPositions[ i - 1 ]; + Vector3 dir = m_trailsControlPositions[i + 1] - m_trailsControlPositions[i - 1]; m_trailsControlNormals[i] = Normalize( dir ); // adjust length! - Vector3 t0( m_trailsControlPositions[ i + 1 ] - m_trailsControlPositions[ i ] ); - Vector3 t1( m_trailsControlPositions[ i ] - m_trailsControlPositions[ i - 1 ] ); + Vector3 t0( m_trailsControlPositions[i + 1] - m_trailsControlPositions[i] ); + Vector3 t1( m_trailsControlPositions[i] - m_trailsControlPositions[i - 1] ); float len0 = Length( t0 ); float len1 = Length( t1 ); // keep the normal add len0 and store a factor to calc a len1-normal - m_trailsControlNormals[ i ] *= len0; - m_trailsControlNormalsFactor[ i ] = len1 / len0; + m_trailsControlNormals[i] *= len0; + m_trailsControlNormalsFactor[i] = len1 / len0; } for( unsigned int i = 1; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { // "sequence length" value is the length of this segment normalized along the whole trail - Vector3 segment( m_trailsControlPositions[ i ] - m_trailsControlPositions[ i - 1 ] ); - m_trailsSequenceLength[ i ] = Length( segment ); + Vector3 segment( m_trailsControlPositions[i] - m_trailsControlPositions[i - 1] ); + m_trailsSequenceLength[i] = Length( segment ); // normalize if non-zero length if( m_trailsTotalLength > 0.f ) { - m_trailsSequenceLength[ i ] /= m_trailsTotalLength; + m_trailsSequenceLength[i] /= m_trailsTotalLength; } } } @@ -587,70 +587,70 @@ void EveBoosterSet2Renderable::CalculateSplineData( float deltaT ) namespace { - ALResult GetBoxVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) - { - const uint32_t vertexCount = 4 * 6; - EveBoosterSet2::BoosterVertex vertices[vertexCount]; - auto p = &vertices[0]; - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - - return g_sharedBuffer.Allocate( sizeof( EveBoosterSet2::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); - } - - ALResult GetStarVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) - { - const uint32_t vertexCount = 4 * 4; - EveBoosterSet2::BoosterVertex vertices[vertexCount]; - auto p = &vertices[0]; - for( unsigned int i = 0; i < vertexCount; i += 4 ) - { - float t = (float)i * XM_PI / 4.f / 4.f; - float x = cos( t ) * 0.5f; - float y = sin( t ) * 0.5f; - p->position = Vector3( -x, -y, 0.f ); - p->texCoord = Vector2( 1.f, 1.f ); - ++p; - p->position = Vector3( -x, -y, -1.f ); - p->texCoord = Vector2( 1.f, 0.f ); - ++p; - p->position = Vector3( x, y, -1.f ); - p->texCoord = Vector2( 0.f, 0.f ); - ++p; - p->position = Vector3( x, y, 0.0f ); - p->texCoord = Vector2( 0.f, 1.f ); - ++p; - } +ALResult GetBoxVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) +{ + const uint32_t vertexCount = 4 * 6; + EveBoosterSet2::BoosterVertex vertices[vertexCount]; + auto p = &vertices[0]; + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + + return g_sharedBuffer.Allocate( sizeof( EveBoosterSet2::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); +} - return g_sharedBuffer.Allocate( sizeof( EveBoosterSet2::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); - } +ALResult GetStarVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) +{ + const uint32_t vertexCount = 4 * 4; + EveBoosterSet2::BoosterVertex vertices[vertexCount]; + auto p = &vertices[0]; + for( unsigned int i = 0; i < vertexCount; i += 4 ) + { + float t = (float)i * XM_PI / 4.f / 4.f; + float x = cos( t ) * 0.5f; + float y = sin( t ) * 0.5f; + p->position = Vector3( -x, -y, 0.f ); + p->texCoord = Vector2( 1.f, 1.f ); + ++p; + p->position = Vector3( -x, -y, -1.f ); + p->texCoord = Vector2( 1.f, 0.f ); + ++p; + p->position = Vector3( x, y, -1.f ); + p->texCoord = Vector2( 0.f, 0.f ); + ++p; + p->position = Vector3( x, y, 0.0f ); + p->texCoord = Vector2( 0.f, 1.f ); + ++p; + } + + return g_sharedBuffer.Allocate( sizeof( EveBoosterSet2::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); +} } // -------------------------------------------------------------------------------- @@ -691,10 +691,10 @@ EveBoosterSet2::EveBoosterSet2( IRoot* lockobj ) : m_vertexBuffer( BlueSharedString( "BoosterBoxVB" ), GetBoxVB ) { BoundingSphereInitialize( m_boosterBoundingSphere ); - + for( unsigned int i = 0; i < EVE_MAX_CONTROL_POINT_COUNT; ++i ) { - m_trailsStaticOffsets[ i ] = Vector3( 0.f, 0.f, 0.f ); + m_trailsStaticOffsets[i] = Vector3( 0.f, 0.f, 0.f ); } if( !g_lightNoiseInitialized ) @@ -762,8 +762,8 @@ bool EveBoosterSet2::OnModified( Be::Var* value ) else if( IsMatch( value, m_staticTrailLength ) ) { float step = m_staticTrailLength / ( EVE_MAX_CONTROL_POINT_COUNT - 1 ); - - for( unsigned int i = 0; i UpdateTrails( deltaT, t ); + ( *it )->UpdateTrails( deltaT, t ); } m_trails->Update( t ); } @@ -913,31 +913,28 @@ void EveBoosterSet2::CreateFlares( SingleBoosterData& boosterData ) float seed = float( rand() ) / float( RAND_MAX ) * 0.7f; Vector3 spritePos = pos - 2.5f * dir; - m_glows->Add( spritePos, seed, seed, scale * m_glowScale, scale * m_glowScale, 0.0f, - m_glowColor, m_warpGlowColor ); + m_glows->Add( spritePos, seed, seed, scale * m_glowScale, scale * m_glowScale, 0.0f, m_glowColor, m_warpGlowColor ); spritePos = pos - 3.0f * dir; - m_glows->Add( spritePos, seed, 1.0f + seed, scale * m_symHaloScale, scale * m_symHaloScale, 0.0f, - m_haloColor, m_warpHaloColor ); + m_glows->Add( spritePos, seed, 1.0f + seed, scale * m_symHaloScale, scale * m_symHaloScale, 0.0f, m_haloColor, m_warpHaloColor ); spritePos = pos - 3.01f * dir; - m_glows->Add( spritePos, seed, 1.0f + seed, scale * m_haloScaleX, scale * m_haloScaleY, 0.0f, - m_haloColor, m_warpHaloColor ); + m_glows->Add( spritePos, seed, 1.0f + seed, scale * m_haloScaleX, scale * m_haloScaleY, 0.0f, m_haloColor, m_warpHaloColor ); } // -------------------------------------------------------------------------------- // Description: // Set all internal data of this set // -------------------------------------------------------------------------------- -void EveBoosterSet2::SetData( - float glowScale, - const Color* glowColor, - const Color* warpGlowColor, - float symHaloScale, - float haloScaleX, - float haloScaleY, - const Color* haloColor, - const Color* warpHaloColor, +void EveBoosterSet2::SetData( + float glowScale, + const Color* glowColor, + const Color* warpGlowColor, + float symHaloScale, + float haloScaleX, + float haloScaleY, + const Color* haloColor, + const Color* warpHaloColor, bool alwaysOn ) { m_glowScale = glowScale; @@ -1032,7 +1029,7 @@ bool EveBoosterSet2::OnPrepareResources() // create vertex-declarartion m_vertexDeclHandle = Tr2EffectStateManager::GetVertexDeclarationHandle( s_boosterInstancedVertex ); - if( m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) + if( m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) { return false; } @@ -1079,7 +1076,7 @@ void EveBoosterSet2::RebuildInstanceData( Tr2RenderContext& /*renderContext*/ ) // create and fill with star-shape's position and some random-value std::vector vertices( boosterCount ); - for( unsigned int i = 0; i < boosterCount ; ++i ) + for( unsigned int i = 0; i < boosterCount; ++i ) { vertices[i].transform = m_singleBoosters[i].transform; vertices[i].wavePhase = (float)rand() / (float)RAND_MAX; @@ -1103,7 +1100,7 @@ void EveBoosterSet2::UpdateVisibility( const EveUpdateContext& updateContext ) { for( auto it = m_boosterRenderables.begin(); it != m_boosterRenderables.end(); it++ ) { - (*it)->UpdateVisibility( updateContext ); + ( *it )->UpdateVisibility( updateContext ); } if( m_glows ) { @@ -1143,7 +1140,7 @@ void EveBoosterSet2::GetRenderables( std::vector& renderables ) { for( auto it = m_boosterRenderables.begin(); it != m_boosterRenderables.end(); it++ ) { - (*it)->GetRenderables( renderables ); + ( *it )->GetRenderables( renderables ); } } } @@ -1163,7 +1160,7 @@ float EveBoosterSet2::GetBoosterIntensity() const float oneOverCount = 1.f / (float)m_boosterRenderables.size(); for( auto it = m_boosterRenderables.begin(); it != m_boosterRenderables.end(); it++ ) { - intensity += (*it)->GetIntensity() * oneOverCount; + intensity += ( *it )->GetIntensity() * oneOverCount; } return intensity; } @@ -1197,19 +1194,19 @@ void EveBoosterSet2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) for( uint32_t j = 0; j < m_singleBoosters.size(); ++j ) { Matrix transform = m_singleBoosters[j].transform * ( *it )->m_parentTransform; - renderer.DrawCylinder( - Tr2DebugObjectReference( this, j ), - transform, - Vector3( 0, 0, 0 ), - Vector3( 0, 0, -1 ), - 1.0f, - 8, - ITr2DebugRenderer2::Lit, + renderer.DrawCylinder( + Tr2DebugObjectReference( this, j ), + transform, + Vector3( 0, 0, 0 ), + Vector3( 0, 0, -1 ), + 1.0f, + 8, + ITr2DebugRenderer2::Lit, Tr2DebugColor( 0x88ffff00, 0x22ffff00 ) ); } // trails box - renderer.DrawBox( this, (*it)->m_trailsBoundsMin, (*it)->m_trailsBoundsMax, ITr2DebugRenderer2::Wireframe, 0xff00ffff ); + renderer.DrawBox( this, ( *it )->m_trailsBoundsMin, ( *it )->m_trailsBoundsMax, ITr2DebugRenderer2::Wireframe, 0xff00ffff ); if( m_glows ) { @@ -1229,7 +1226,7 @@ void EveBoosterSet2::GetBoundingSphere( Vector4& boundingSphere ) const for( auto it = m_boosterRenderables.begin(); it != m_boosterRenderables.end(); it++ ) { Vector4 bs; - (*it)->GetBoundingSphere( bs ); + ( *it )->GetBoundingSphere( bs ); BoundingSphereUpdate( bs, boundingSphere ); } } @@ -1264,9 +1261,9 @@ void EveBoosterSet2::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Mat for( auto it = m_boosterRenderables.begin(); it != m_boosterRenderables.end(); it++ ) { - if( (*it)->m_boostersVisible || !m_flareLodEnabled ) + if( ( *it )->m_boostersVisible || !m_flareLodEnabled ) { - m_glows->AddBoosterGlowToQuadRenderer( quadRenderer, (*it)->m_parentTransform, (*it)->m_overallIntensity, m_warpIntensity ); + m_glows->AddBoosterGlowToQuadRenderer( quadRenderer, ( *it )->m_parentTransform, ( *it )->m_overallIntensity, m_warpIntensity ); } } } @@ -1275,7 +1272,7 @@ void EveBoosterSet2::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Mat void EveBoosterSet2::RegisterComponents() { auto registry = this->GetComponentRegistry(); - if ( registry ) + if( registry ) { registry->RegisterComponent( this ); } @@ -1296,16 +1293,16 @@ void EveBoosterSet2::GetLights( Tr2LightManager& lightManager ) const for( auto dit = m_boosterRenderables.begin(); dit != m_boosterRenderables.end(); dit++ ) { - if( (*dit)->m_overallIntensity <= 0 ) + if( ( *dit )->m_overallIntensity <= 0 ) { continue; } float warpIntensity = std::min( std::max( m_warpIntensity, 0.f ), 1.f ); float radiusFactor = m_lightRadius * ( 1.f - warpIntensity ) + m_lightWarpRadius * warpIntensity; - radiusFactor *= (*dit)->m_overallIntensity; + radiusFactor *= ( *dit )->m_overallIntensity; Color color = m_lightColor * ( 1.f - warpIntensity ) + m_lightWarpColor * warpIntensity; - XMMATRIX transform = (*dit)->m_parentTransform; + XMMATRIX transform = ( *dit )->m_parentTransform; for( auto it = std::begin( m_singleBoosters ); it != std::end( m_singleBoosters ); ++it ) { float phase = ( it->lightPhase + Tr2Renderer::GetAnimationTime() ) * m_lightFlickerFrequency; @@ -1313,11 +1310,10 @@ void EveBoosterSet2::GetLights( Tr2LightManager& lightManager ) const float p1 = g_lightNoise[( int( phase ) + 1 ) % g_lightNoiseSize]; float t = phase - std::floor( phase ); float flicker = 1 + m_lightFlickerAmplitude * 2.0f * ( p0 * ( 1.0f - t ) + p1 * t ) - m_lightFlickerAmplitude; - lightManager.AddPointLight( - Vector3( XMVector3TransformCoord( it->lightPosition, transform ) ), + lightManager.AddPointLight( + Vector3( XMVector3TransformCoord( it->lightPosition, transform ) ), it->lightRadius * radiusFactor, color * flicker ); - } } } @@ -1329,7 +1325,7 @@ void EveBoosterSet2::GetLights( Tr2LightManager& lightManager ) const void EveBoosterSetPerObjectData::SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { FillAndSetConstants( *buffers[VERTEX_SHADER], m_vsData, VERTEX_SHADER, Tr2Renderer::GetPerObjectVSStartRegister(), renderContext ); - FillAndSetConstants( *buffers[PIXEL_SHADER ], m_psData, PIXEL_SHADER , Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); + FillAndSetConstants( *buffers[PIXEL_SHADER], m_psData, PIXEL_SHADER, Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); } void EveBoosterSetPerObjectData::ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const diff --git a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.h b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.h index bc5567707..47c88712e 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.h +++ b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2.h @@ -82,7 +82,7 @@ class EveBoosterSetPerObjectData : public Tr2PerObjectData BLUE_DECLARE( EveBoosterSet2 ); -BLUE_CLASS( EveBoosterSet2Renderable ): +BLUE_CLASS( EveBoosterSet2Renderable ) : public ITr2Renderable { public: @@ -90,25 +90,28 @@ BLUE_CLASS( EveBoosterSet2Renderable ): EveBoosterSet2Renderable( IRoot* lockobj = NULL ); ~EveBoosterSet2Renderable(); - + void Update( float deltaT, Be::Time t, const Matrix& parentMatrix, float parentSpeed, const Vector3& parentAcceleration, const Quaternion& parentRotation ); // get the transformed bounding sphere, ready for use - void GetBoundingSphere( Vector4& boundingSphere ) const; + void GetBoundingSphere( Vector4 & boundingSphere ) const; // rendering void UpdateVisibility( const EveUpdateContext& updateContext ); - void GetRenderables( std::vector& renderables ); + void GetRenderables( std::vector & renderables ); void UpdateTrails( float deltaT, Be::Time t ); - float GetIntensity() const { return m_overallIntensity; } + float GetIntensity() const + { + return m_overallIntensity; + } ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches(); - virtual float GetSortValue(); + virtual float GetSortValue(); + + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); - EveBoosterSet2* m_boosterSet; // calculated the booster intensity (=gain) from ship's ball @@ -122,13 +125,13 @@ BLUE_CLASS( EveBoosterSet2Renderable ): bool m_boosterHighLod; bool m_boostersVisible; bool m_trailsVisible; - + // parent ship data float m_parentSpeed; // parent ship transform Matrix m_parentTransform; Quaternion m_parentRotation; - + // booster gain stuff float m_lastAccFactor; float m_lastValue; @@ -168,7 +171,7 @@ BLUE_DECLARE_VECTOR( EveBoosterSet2Renderable ); // SeeAlso: // EveShip2, EveSpriteSet // -------------------------------------------------------------------------------- -BLUE_CLASS( EveBoosterSet2 ): +BLUE_CLASS( EveBoosterSet2 ) : public IInitialize, public INotify, public Tr2DeviceResource, @@ -197,7 +200,7 @@ BLUE_CLASS( EveBoosterSet2 ): ///////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource @@ -208,6 +211,7 @@ BLUE_CLASS( EveBoosterSet2 ): void RegisterComponents() override; friend class EveBoosterSet2Renderable; + private: bool OnPrepareResources(); @@ -232,43 +236,43 @@ BLUE_CLASS( EveBoosterSet2 ): PEveBoosterSet2RenderableVector m_boosterRenderables; // timing - void Update( float deltaT, Be::Time t, const Matrix& parentMatrix, float parentSpeed, const Vector3& parentAcceleration, const Quaternion& parentRotation, int boosterInstance=0 ); + void Update( float deltaT, Be::Time t, const Matrix& parentMatrix, float parentSpeed, const Vector3& parentAcceleration, const Quaternion& parentRotation, int boosterInstance = 0 ); void UpdateTrails( float deltaT, Be::Time t ); // manage individual exhaust points void Clear(); void Add( const Matrix* localMatrix, const Vector4* functionality, bool hasTrail, uint32_t atlasIndex0, uint32_t atlasIndex1, float lightScale = 1 ); // set internal visual data - void SetData( - float glowScale, - const Color* glowColor, - const Color* warpGlowColor, - float symHaloScale, - float haloScaleX, - float haloScaleY, - const Color* haloColor, - const Color* warpHaloColor, + void SetData( + float glowScale, + const Color* glowColor, + const Color* warpGlowColor, + float symHaloScale, + float haloScaleX, + float haloScaleY, + const Color* haloColor, + const Color* warpHaloColor, bool alwaysOn ); void SetLightData( float offset, float flickerAmplitude, float flickerFrequency, float radius, const Color& color, float warpRadius, const Color& warpColor ); - void SetEffect( Tr2Effect* effect, Tr2Effect* effectFar ); + void SetEffect( Tr2Effect * effect, Tr2Effect * effectFar ); void SetGlow( EveSpriteSetPtr glow ); void SetTrail( EveTrailsSetPtr trail ); // rendering void UpdateVisibility( const EveUpdateContext& updateContext ); - void GetRenderables( std::vector& renderables ); + void GetRenderables( std::vector & renderables ); // query booster intensity float GetBoosterIntensity() const; float GetBoosterIntensity( int index ) const; // just debug info - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); // get the transformed bounding sphere, ready for use - void GetBoundingSphere( Vector4& boundingSphere ) const; + void GetBoundingSphere( Vector4 & boundingSphere ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& pool ); - void AddToQuadRenderer( Tr2QuadRenderer& pool, const Matrix& world ); + void RegisterWithQuadRenderer( Tr2QuadRenderer & pool ); + void AddToQuadRenderer( Tr2QuadRenderer & pool, const Matrix& world ); ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; private: // indivual data of each booster (position, etc.) @@ -285,10 +289,10 @@ BLUE_CLASS( EveBoosterSet2 ): std::vector m_singleBoosters; // re-alloc and init the instance vertex buffers - void RebuildInstanceData( Tr2RenderContext& renderContext ); + void RebuildInstanceData( Tr2RenderContext & renderContext ); // function to create the flares from boosterdata - void CreateFlares( SingleBoosterData& boosterData ); + void CreateFlares( SingleBoosterData & boosterData ); // toggle display bool m_display; @@ -333,7 +337,7 @@ BLUE_CLASS( EveBoosterSet2 ): Color m_haloColor; Color m_warpGlowColor; Color m_warpHaloColor; - + // trail spline data float m_trailsSmoothing; // toggle trail physics updates diff --git a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2_Blue.cpp index 94f3e14bb..b8ed94fc7 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveBoosterSet2_Blue.cpp @@ -5,25 +5,24 @@ BLUE_DEFINE( EveBoosterSet2Renderable ); -const Be::ClassInfo* EveBoosterSet2Renderable::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveBoosterSet2Renderable, "" ) - MAP_INTERFACE( EveBoosterSet2Renderable ) - MAP_INTERFACE( ITr2Renderable ) - - MAP_ATTRIBUTE( "overallIntensity", m_overallIntensity, "The overall intensity of the boosters resulting from velo, acceleration, etc.", Be::READ ) - MAP_ATTRIBUTE( "parentSpeed", m_parentSpeed, "The speed of the ship", Be::READWRITE ) - MAP_ATTRIBUTE( "parentRotation", m_parentRotation, "The rotation of the ship", Be::READWRITE ) - MAP_ATTRIBUTE( "trailsBoundsMin", m_trailsBoundsMin, "Minimum aa bounding box of the trails", Be::READ ) - MAP_ATTRIBUTE( "trailsBoundsMax", m_trailsBoundsMax, "Maximum aa bounding box of the trails", Be::READ ) - MAP_ATTRIBUTE( "trailsTimeDelta", m_trailsTimeDelta, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "trailIntensity", m_trailIntensity, "", Be::READ ) - MAP_ATTRIBUTE( "trailsTotalLength", m_trailsTotalLength, "", Be::READ ) - MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READ ) - MAP_ATTRIBUTE( "trailsVisible", m_trailsVisible, "", Be::READ ) - MAP_ATTRIBUTE( "boostersVisible", m_boostersVisible, "", Be::READ ) - MAP_ATTRIBUTE( "boosterHighLod", m_boosterHighLod, "Are the boosters using high lods (using the near effect)", Be::READ ) - EXPOSURE_END() +const Be::ClassInfo* EveBoosterSet2Renderable::ExposeToBlue(){ + EXPOSURE_BEGIN( EveBoosterSet2Renderable, "" ) + MAP_INTERFACE( EveBoosterSet2Renderable ) + MAP_INTERFACE( ITr2Renderable ) + + MAP_ATTRIBUTE( "overallIntensity", m_overallIntensity, "The overall intensity of the boosters resulting from velo, acceleration, etc.", Be::READ ) + MAP_ATTRIBUTE( "parentSpeed", m_parentSpeed, "The speed of the ship", Be::READWRITE ) + MAP_ATTRIBUTE( "parentRotation", m_parentRotation, "The rotation of the ship", Be::READWRITE ) + MAP_ATTRIBUTE( "trailsBoundsMin", m_trailsBoundsMin, "Minimum aa bounding box of the trails", Be::READ ) + MAP_ATTRIBUTE( "trailsBoundsMax", m_trailsBoundsMax, "Maximum aa bounding box of the trails", Be::READ ) + MAP_ATTRIBUTE( "trailsTimeDelta", m_trailsTimeDelta, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "trailIntensity", m_trailIntensity, "", Be::READ ) + MAP_ATTRIBUTE( "trailsTotalLength", m_trailsTotalLength, "", Be::READ ) + MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READ ) + MAP_ATTRIBUTE( "trailsVisible", m_trailsVisible, "", Be::READ ) + MAP_ATTRIBUTE( "boostersVisible", m_boostersVisible, "", Be::READ ) + MAP_ATTRIBUTE( "boosterHighLod", m_boosterHighLod, "Are the boosters using high lods (using the near effect)", Be::READ ) + EXPOSURE_END() } @@ -31,19 +30,18 @@ BLUE_DEFINE( EveBoosterSet2 ); const Be::ClassInfo* EveBoosterSet2::ExposeToBlue() { - EXPOSURE_BEGIN( EveBoosterSet2, "" ) - MAP_INTERFACE( EveBoosterSet2 ) + EXPOSURE_BEGIN( EveBoosterSet2, "" ) + MAP_INTERFACE( EveBoosterSet2 ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE( - "display", - m_display, + MAP_ATTRIBUTE( + "display", + m_display, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "physicsUpdate", m_physicsUpdate, "This enables updating of the boosters trails based on physics sim", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "destinyUpdate", m_destinyUpdate, "This enables updating speed etc. from destiny simulation", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxSize", m_maxSize, "The biggest booster size of this set.", Be::READ ) @@ -54,81 +52,63 @@ const Be::ClassInfo* EveBoosterSet2::ExposeToBlue() MAP_ATTRIBUTE( "boosterBoundingSphereRadius", m_boosterBoundingSphere.w, "The radius of the minimum bounding sphere of the boosters", Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxVel", m_maxVel, "Max velocity of the ball", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "trailsSmoothing", m_trailsSmoothing, "Smoothness for bending (length of tangents of splines)", Be::READWRITE | Be::PERSIST ) // glows - MAP_ATTRIBUTE - ( - "glowScale", - m_glowScale, + MAP_ATTRIBUTE( + "glowScale", + m_glowScale, "Scale of glow sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "glowColor", - m_glowColor, + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "glowColor", + m_glowColor, "Color of glow sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "symHaloScale", - m_symHaloScale, + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "symHaloScale", + m_symHaloScale, "Scale on halo sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "haloScaleX", - m_haloScaleX, + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "haloScaleX", + m_haloScaleX, "Scale on halo sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloScaleY", m_haloScaleY, "Scale on halo sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloColor", m_haloColor, "Color of glow sprites\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "warpGlowColor", m_warpGlowColor, "Color of glow sprites in warp\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "warpHaloColor", m_warpHaloColor, "Color of halo sprites in warp\n" ":jessica-group: Glow", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "lightOffset", m_lightOffset, ":jessica-group: Lights", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightFlickerAmplitude", m_lightFlickerAmplitude, ":jessica-group: Lights", Be::READWRITE | Be::PERSIST ) @@ -138,22 +118,18 @@ const Be::ClassInfo* EveBoosterSet2::ExposeToBlue() MAP_ATTRIBUTE( "lightWarpRadius", m_lightWarpRadius, ":jessica-group: Lights", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightWarpColor", m_lightWarpColor, ":jessica-group: Lights", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "alwaysOn", m_alwaysOn, "Toggle whether the boosters are always on or not. Useful for Jessica and marketing reasons.\n" ":jessica-group: Fakery", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "alwaysOnIntensity", m_alwaysOnIntensity, "Booster intensity when alwaysOn is turned on. Useful for Jessica and marketing reasons.\n" ":jessica-group: Fakery", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTrailLength", m_staticTrailLength, ":jessica-group: Fakery", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "flareLodEnabled", m_flareLodEnabled, ":jessica-group: Fakery", Be::READWRITE | Be::NOTIFY ) diff --git a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.cpp b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.cpp index 458e6c071..f0aa5a6f3 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.cpp @@ -21,7 +21,7 @@ extern bool g_eveSpaceObjectImpactEffectEnabled; // consts static const float IMPACT_HOLE_TO_ARMOR_DAMAGE_RATIO = 12.f; -static const float IMPACT_HOLE_TO_HULL_DAMAGE_RATIO = 4.f; +static const float IMPACT_HOLE_TO_HULL_DAMAGE_RATIO = 4.f; static const float IMPACT_ARMOR_SIZE_FACTOR = 0.0129f; static const float IMPACT_ARMOR_SIZE_MAX = 10.f; static const float IMPACT_SHIELD_SIZE_MAX = 2000.f; @@ -84,7 +84,7 @@ void EveImpactOverlay::Set( TriPerlinCurvePtr hullDamageFlickerCurve, Tr2GpuUniq // -------------------------------------------------------------------------------- // Description: -// Sets the name of the impact overlay, this is used for seeding the randomness of +// Sets the name of the impact overlay, this is used for seeding the randomness of // the impacts between session changes // -------------------------------------------------------------------------------- void EveImpactOverlay::SetSeed( unsigned int seed ) @@ -98,7 +98,7 @@ void EveImpactOverlay::SetSeed( unsigned int seed ) // Sets the amount of damage locators, used for the randomness of the impacts // between session change // -------------------------------------------------------------------------------- -void EveImpactOverlay::SetDamageLocatorCount( unsigned int count) +void EveImpactOverlay::SetDamageLocatorCount( unsigned int count ) { m_damageLocatorCount = count; } @@ -133,9 +133,9 @@ void EveImpactOverlay::UpdateSyncronous( const EveUpdateContext& updateContext, // update block data m_dataTextureBlockID = dataTextureMgr->RequestBlockData( &m_impactTexelHeader.v[0], - (uint32_t)m_impactTexelData.size(), - m_impactTexelData.empty() ? nullptr : &m_impactTexelData[0].v[0], - m_renderPriority ); + (uint32_t)m_impactTexelData.size(), + m_impactTexelData.empty() ? nullptr : &m_impactTexelData[0].v[0], + m_renderPriority ); // spawn armor impact particles? if( updateContext.GetGpuParticleSystem() ) @@ -147,7 +147,7 @@ void EveImpactOverlay::UpdateSyncronous( const EveUpdateContext& updateContext, for( auto aidit = m_armorImpactData.begin(); aidit != m_armorImpactData.end(); ++aidit ) { if( aidit->second.requestSpawnDebris ) - { + { // where? Vector3 impactPosWS( 0.f, 0.f, 0.f ); parent->GetDamageLocatorPosition( &impactPosWS, aidit->second.damageLocatorIndex, true ); @@ -197,7 +197,7 @@ void EveImpactOverlay::UpdateAsyncronous( const EveUpdateContext& updateContext, sidit->second.timeLeft -= updateContext.GetDeltaT(); if( sidit->second.timeLeft <= 0.f ) { - m_shieldImpactData.erase(sidit++); + m_shieldImpactData.erase( sidit++ ); } else { @@ -216,7 +216,7 @@ void EveImpactOverlay::UpdateAsyncronous( const EveUpdateContext& updateContext, aidit->second.size -= updateContext.GetDeltaT() / m_armorImpactLifeTime; if( aidit->second.size <= 0.f ) { - m_armorImpactData.erase(aidit++); + m_armorImpactData.erase( aidit++ ); } else { @@ -237,21 +237,21 @@ void EveImpactOverlay::UpdateAsyncronous( const EveUpdateContext& updateContext, // the block header is the first column in the data texture, set it! m_impactTexelHeader.v[0] = Vector4( float( m_shieldImpactData.size() ), - m_overallShieldImpact, - m_shieldImpactColorFade, - m_shieldImpactParentSize ); + m_overallShieldImpact, + m_shieldImpactColorFade, + m_shieldImpactParentSize ); m_impactTexelHeader.v[1] = Vector4( m_shieldHardening->GetFaderValue(), - m_shieldBoosting->GetFaderValue(), - m_shieldHardening->GetKickInValue(), - m_shieldBoosting->GetKickInValue() ); + m_shieldBoosting->GetFaderValue(), + m_shieldHardening->GetKickInValue(), + m_shieldBoosting->GetKickInValue() ); m_impactTexelHeader.v[2] = Vector4( float( m_armorImpactData.size() ), - m_armorImpactParentSize, - m_hullRepairing->GetFaderValue(), - m_hullRepairing->GetKickInValue() ); + m_armorImpactParentSize, + m_hullRepairing->GetFaderValue(), + m_hullRepairing->GetKickInValue() ); m_impactTexelHeader.v[3] = Vector4( m_armorRepairing->GetFaderValue(), - m_armorHardening->GetFaderValue(), - m_armorRepairing->GetKickInValue(), - m_armorHardening->GetKickInValue() ); + m_armorHardening->GetFaderValue(), + m_armorRepairing->GetKickInValue(), + m_armorHardening->GetKickInValue() ); // no activity? if( !HasGeneralActivity() ) @@ -302,13 +302,13 @@ void EveImpactOverlay::UpdateAsyncronous( const EveUpdateContext& updateContext, parent->GetDamageLocatorPosition( &tgtPosWS, shieldData->damageLocatorIndex, true ); Vector3 pos = GetShieldImpactPosition( parentInverseWorldTransform, tgtPosWS, shieldData->direction, shieldEllipsoidCenter, shieldEllipsoidRadii ); - + // "encode" it in texels texelData->v[0] = Vector4( pos, shieldData->timeLeft ); texelData->v[1] = Vector4( shieldData->size, shieldData->intensity, 0.f, shieldData->lifeTime ); // also need this intercept position in WS shieldData->interceptPosition = TransformCoord( pos, parentWorldTransform ); - + ++i; } } @@ -604,7 +604,7 @@ void EveImpactOverlay::SetDamageState( float shield, float armor, float hull, bo std::uniform_real_distribution damageSizeDistribution( 0.2f, 0.8f ); for( size_t i = m_armorImpactData.size(); i < m_armorImpactGoalCount; ++i ) - { + { CreateArmorImpact( damageLocatorDistribution( generator ), damageSizeDistribution( generator ), m_debugForceSpawnDebris ); } } @@ -635,7 +635,7 @@ int EveImpactOverlay::CreateImpact( int damageLocatorIndex, const Vector3& direc { return -1; } - + // what's the situation? if( m_configuration == ITriTargetable::IMPACT_SHIELD && lod != TR2_LOD_LOW ) { @@ -669,7 +669,7 @@ bool EveImpactOverlay::UpdateImpact( Vector3& out, const Vector3& direction, int { // put new direction in there shieldData->second.direction = direction; - // and return the old "intercept" position + // and return the old "intercept" position out = shieldData->second.interceptPosition; return true; } @@ -717,7 +717,7 @@ int EveImpactOverlay::CreateShieldImpact( int damageLocatorIndex, const Vector3& // if we have one that is close enough, use it instead and hand back that index if( closestImpactAtSameDmgLocAngle > 0.95f ) { - ShieldImpactData* p = &m_shieldImpactData[ closestImpactAtSameDmgLocIdx ]; + ShieldImpactData* p = &m_shieldImpactData[closestImpactAtSameDmgLocIdx]; p->direction = nrmDir; p->timeLeft = IMPACT_SHIELD_FADEOUT * lifeTime; p->size = std::max( size, p->size ); @@ -730,7 +730,7 @@ int EveImpactOverlay::CreateShieldImpact( int damageLocatorIndex, const Vector3& // if we have no more room, use one of the existing ones, no matter how good they are and what locator they hit if( closestImpactAtAnyDmgLocIdx != -1 ) { - ShieldImpactData* p = &m_shieldImpactData[ closestImpactAtAnyDmgLocIdx ]; + ShieldImpactData* p = &m_shieldImpactData[closestImpactAtAnyDmgLocIdx]; p->direction = nrmDir; p->timeLeft = IMPACT_SHIELD_FADEOUT * lifeTime; p->size = std::max( size, p->size ); @@ -738,7 +738,7 @@ int EveImpactOverlay::CreateShieldImpact( int damageLocatorIndex, const Vector3& return closestImpactAtAnyDmgLocIdx; } - + // need the inverse world matrix Matrix parentWorldTransform, parentInverseWorldTransform; parent->GetLocalToWorldTransform( parentWorldTransform ); @@ -762,7 +762,7 @@ int EveImpactOverlay::CreateShieldImpact( int damageLocatorIndex, const Vector3& sid.lifeTime = sid.timeLeft = IMPACT_SHIELD_FADEOUT * lifeTime; sid.size = size; sid.intensity = intensity; - m_shieldImpactData[ m_impactDataNextIdx ] = sid; + m_shieldImpactData[m_impactDataNextIdx] = sid; return m_impactDataNextIdx++; } @@ -790,7 +790,7 @@ int EveImpactOverlay::CreateArmorImpact( int damageLocatorIndex, float size, boo aid.damageLocatorIndex = damageLocatorIndex; aid.size = size; aid.requestSpawnDebris = spawnEffects && !Tr2Renderer::IsLowQuality(); - m_armorImpactData[ m_impactDataNextIdx ] = aid; + m_armorImpactData[m_impactDataNextIdx] = aid; return m_impactDataNextIdx++; } @@ -822,4 +822,3 @@ Tr2Effect* EveImpactOverlay::GetArmorDamageShader( TriBatchType batchType ) cons } return m_armorDamageShader; } - diff --git a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.h b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.h index c86ea2af6..570414868 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.h +++ b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay.h @@ -74,14 +74,14 @@ BLUE_CLASS( EveImpactOverlay ) : // Updates void UpdateSyncronous( const EveUpdateContext& updateContext, EveSpaceObject2* parent ); void UpdateAsyncronous( const EveUpdateContext& updateContext, EveSpaceObject2* parent ); - + ///////////////////////////////////////////////////////////////////////////////////// // Rendering - void GetBatches( ITriRenderBatchAccumulator* accumulator, TriBatchType batchType, const Tr2PerObjectData* perObjectData, float screenSize ); + void GetBatches( ITriRenderBatchAccumulator * accumulator, TriBatchType batchType, const Tr2PerObjectData* perObjectData, float screenSize ); Tr2Effect* GetArmorDamageShader( TriBatchType batchType ) const; // setup - void Set( TriPerlinCurvePtr hullDamageFlickerCurve, Tr2GpuUniqueEmitterPtr armorDamageEmitter, Tr2GpuUniqueEmitterPtr hullImpactEmitter, Tr2EffectPtr armorDamageShader, Tr2MeshBase* shieldImpactMesh, bool shieldIsEllipsoid ); + void Set( TriPerlinCurvePtr hullDamageFlickerCurve, Tr2GpuUniqueEmitterPtr armorDamageEmitter, Tr2GpuUniqueEmitterPtr hullImpactEmitter, Tr2EffectPtr armorDamageShader, Tr2MeshBase * shieldImpactMesh, bool shieldIsEllipsoid ); // getters int32_t GetDataTextureOffset() const; @@ -104,7 +104,7 @@ BLUE_CLASS( EveImpactOverlay ) : // control impacts int CreateImpact( int damageLocatorIndex, const Vector3& direction, float lifeTime, float size, float intensity, Tr2Lod lod, EveSpaceObject2* parent ); - bool UpdateImpact( Vector3& out, const Vector3& direction, int impactIndex ); + bool UpdateImpact( Vector3 & out, const Vector3& direction, int impactIndex ); // helper for checking activity bool HasGeneralActivity() const; diff --git a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay_Blue.cpp index 846e4159f..7a45fbde5 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveImpactOverlay_Blue.cpp @@ -7,10 +7,10 @@ BLUE_DEFINE( EveImpactOverlay ); const Be::ClassInfo* EveImpactOverlay::ExposeToBlue() { - EXPOSURE_BEGIN( EveImpactOverlay, "" ) - MAP_INTERFACE( EveImpactOverlay ) + EXPOSURE_BEGIN( EveImpactOverlay, "" ) + MAP_INTERFACE( EveImpactOverlay ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "seed", m_seed, "", Be::READ ) MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE ) MAP_ATTRIBUTE( "configuration", m_configuration, "Impact goes into what?", Be::READ ) @@ -38,20 +38,19 @@ const Be::ClassInfo* EveImpactOverlay::ExposeToBlue() MAP_ATTRIBUTE( "armorHardening", m_armorHardening, "", Be::READWRITE ) MAP_ATTRIBUTE( "hullRepairing", m_hullRepairing, "", Be::READWRITE ) - + MAP_ATTRIBUTE( "hullDamageFlickerCurve", m_hullDamageFlickerCurve, "This is the flickering for hull damage", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "hullDamageFactor", m_hullDamageFactor, "How much hull damage to show?", Be::READWRITE ) MAP_ATTRIBUTE( "hullImpactEmitter", m_hullImpactEmitter, "The hull impact emitter", Be::READWRITE | Be::PERSIST ) - + MAP_METHOD_AND_WRAP( "GetArmorImpactLifeTime", GetArmorImpactLifeTime, - "Value for how long the overlay effect plays.\n" - ) + "Value for how long the overlay effect plays.\n" ) MAP_METHOD_AND_WRAP( "GetLastDamageState", GetLastDamageState, "Last configured damage state (shield, armor, hull).\n" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.cpp b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.cpp index e41114791..fcf2502c2 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.cpp @@ -23,7 +23,7 @@ EveMeshOverlayEffect::~EveMeshOverlayEffect() // Description: // EveMeshOverlayEffect constructor // -------------------------------------------------------------------------------------- -EveMeshOverlayEffect::EveMeshOverlayEffect( IRoot* lockobj ): +EveMeshOverlayEffect::EveMeshOverlayEffect( IRoot* lockobj ) : m_display( true ), m_update( true ), PARENTLOCK( m_opaqueEffects ), @@ -31,9 +31,9 @@ EveMeshOverlayEffect::EveMeshOverlayEffect( IRoot* lockobj ): PARENTLOCK( m_transparentEffects ), PARENTLOCK( m_additiveEffects ), PARENTLOCK( m_distortionEffects ), - PARENTLOCK( m_controllers ) + PARENTLOCK( m_controllers ) { - m_controllers.SetNotify( this ); + m_controllers.SetNotify( this ); } // -------------------------------------------------------------------------------------- @@ -59,28 +59,32 @@ bool EveMeshOverlayEffect::Initialize() // -------------------------------------------------------------------------------------- void EveMeshOverlayEffect::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) { - if (list == &m_controllers && (event & BELIST_LOADING) == 0) { - switch (event & BELIST_EVENTMASK) { - case BELIST_INSERTED: - if (ITr2ControllerPtr controller = BlueCastPtr(value)) { - controller->Link(*GetRawRoot()); - } - break; - case BELIST_REMOVED: - if (ITr2ControllerPtr controller = BlueCastPtr(value)) { - controller->Unlink(); - } - break; + if( list == &m_controllers && ( event & BELIST_LOADING ) == 0 ) + { + switch( event & BELIST_EVENTMASK ) + { + case BELIST_INSERTED: + if( ITr2ControllerPtr controller = BlueCastPtr( value ) ) + { + controller->Link( *GetRawRoot() ); + } + break; + case BELIST_REMOVED: + if( ITr2ControllerPtr controller = BlueCastPtr( value ) ) + { + controller->Unlink(); + } + break; case BELIST_UNLOADSTART: for( auto& controller : m_controllers ) { controller->Unlink(); } break; - default: - break; - } - } + default: + break; + } + } } // -------------------------------------------------------------------------------------- @@ -109,9 +113,9 @@ bool EveMeshOverlayEffect::HasTransparentArea() const inline void SetIndividualShaderOption( const PTr2EffectVector& effectVector, const BlueSharedString& name, const BlueSharedString& value ) { - for (auto it = effectVector.begin(); it != effectVector.end(); ++it) + for( auto it = effectVector.begin(); it != effectVector.end(); ++it ) { - Tr2Effect *effect = *it; + Tr2Effect* effect = *it; effect->SetOption( name, value ); } } @@ -128,35 +132,35 @@ void EveMeshOverlayEffect::SetShaderOption( const BlueSharedString& name, const // -------------------------------------------------------------------------------------- // Description: -// GetEffect. +// GetEffect. // Return Value: // A Tr2EffectVector of effects. // -------------------------------------------------------------------------------------- -const PTr2EffectVector& EveMeshOverlayEffect::GetEffects(TriBatchType batchType, bool& success) const +const PTr2EffectVector& EveMeshOverlayEffect::GetEffects( TriBatchType batchType, bool& success ) const { - if ( m_display ) + if( m_display ) { - if ( batchType == TRIBATCHTYPE_OPAQUE ) + if( batchType == TRIBATCHTYPE_OPAQUE ) { success = true; return m_opaqueEffects; } - else if ( batchType == TRIBATCHTYPE_DECAL ) + else if( batchType == TRIBATCHTYPE_DECAL ) { success = true; return m_decalEffects; } - else if ( batchType == TRIBATCHTYPE_TRANSPARENT ) + else if( batchType == TRIBATCHTYPE_TRANSPARENT ) { success = true; return m_transparentEffects; } - else if ( batchType == TRIBATCHTYPE_ADDITIVE ) + else if( batchType == TRIBATCHTYPE_ADDITIVE ) { success = true; return m_additiveEffects; } - else if ( batchType == TRIBATCHTYPE_DISTORTION ) + else if( batchType == TRIBATCHTYPE_DISTORTION ) { success = true; return m_distortionEffects; @@ -171,27 +175,27 @@ const PTr2EffectVector& EveMeshOverlayEffect::GetEffects(TriBatchType batchType, void EveMeshOverlayEffect::SetControllerVariable( const char* name, float value ) { - for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) - { - ( *it )->SetVariable( name, value ); - } + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + { + ( *it )->SetVariable( name, value ); + } } void EveMeshOverlayEffect::HandleControllerEvent( const char* name ) { - for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) - { - ( *it )->HandleEvent( name ); - } + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + { + ( *it )->HandleEvent( name ); + } } void EveMeshOverlayEffect::StartControllers() { - for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) - { - ( *it )->Start(); - } + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + { + ( *it )->Start(); + } } // -------------------------------------------------------------------------------- @@ -199,69 +203,69 @@ void EveMeshOverlayEffect::StartControllers() void EveMeshOverlayEffect::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - if( !m_curveSet ) - { - return; - } - - if( m_curveSet->GetName() == name ) - { - if( rangeName.empty() ) - { - m_curveSet->ResetTimeRange(); - m_curveSet->Play(); - } - else - { - m_curveSet->PlayTimeRange( rangeName.c_str() ); - } - } + if( !m_curveSet ) + { + return; + } + + if( m_curveSet->GetName() == name ) + { + if( rangeName.empty() ) + { + m_curveSet->ResetTimeRange(); + m_curveSet->Play(); + } + else + { + m_curveSet->PlayTimeRange( rangeName.c_str() ); + } + } } void EveMeshOverlayEffect::StopCurveSet( const std::string& name ) { - if( !m_curveSet ) - { - return; - } - - if( m_curveSet->GetName() == name ) - { - m_curveSet->Stop(); - } + if( !m_curveSet ) + { + return; + } + + if( m_curveSet->GetName() == name ) + { + m_curveSet->Stop(); + } } float EveMeshOverlayEffect::GetCurveSetDuration( const std::string& name ) const { - float maxDuration = 0.f; - - if( !m_curveSet ) - { - return maxDuration; - } - - if( m_curveSet->GetName() == name ) - { - maxDuration = max( maxDuration, m_curveSet->GetMaxCurveDuration() ); - } - return maxDuration; + float maxDuration = 0.f; + + if( !m_curveSet ) + { + return maxDuration; + } + + if( m_curveSet->GetName() == name ) + { + maxDuration = max( maxDuration, m_curveSet->GetMaxCurveDuration() ); + } + return maxDuration; } float EveMeshOverlayEffect::GetRangeDuration( const std::string& name, const std::string& rangeName ) const { - float maxDuration = 0.f; + float maxDuration = 0.f; - if( !m_curveSet ) - { - return maxDuration; - } + if( !m_curveSet ) + { + return maxDuration; + } - if( m_curveSet->GetName() == name ) - { - maxDuration = max( maxDuration, m_curveSet->GetRangeDuration( rangeName.c_str() ) ); - } + if( m_curveSet->GetName() == name ) + { + maxDuration = max( maxDuration, m_curveSet->GetRangeDuration( rangeName.c_str() ) ); + } - return maxDuration; + return maxDuration; } // -------------------------------------------------------------------------------------- @@ -277,8 +281,8 @@ void EveMeshOverlayEffect::Update( Be::Time realTime, Be::Time simTime ) m_curveSet->Update( realTime, simTime ); - for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) - { - ( *it )->Update( 0.5f ); - } + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + { + ( *it )->Update( 0.5f ); + } } diff --git a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h index d60f35e9d..e62f95026 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h +++ b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect.h @@ -24,10 +24,10 @@ BLUE_DECLARE_IVECTOR( ITr2Controller ); // Tr2SpaceObject2 // -------------------------------------------------------------------------------- BLUE_CLASS( EveMeshOverlayEffect ) : - public IInitialize, - public IListNotify, - public ITr2ControllerOwner, - public ITr2CurveSetOwner + public IInitialize, + public IListNotify, + public ITr2ControllerOwner, + public ITr2CurveSetOwner { public: EXPOSE_TO_BLUE(); @@ -40,9 +40,9 @@ BLUE_CLASS( EveMeshOverlayEffect ) : TYPE_COUNT, }; - EveMeshOverlayEffect(IRoot* lockobj = NULL); + EveMeshOverlayEffect( IRoot* lockobj = NULL ); ~EveMeshOverlayEffect(); - + const PTr2EffectVector& GetEffects( TriBatchType batchType, bool& success ) const; void Update( Be::Time realTime, Be::Time simTime ); @@ -54,26 +54,26 @@ BLUE_CLASS( EveMeshOverlayEffect ) : void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ); - ////////////////////////////////////////////////////////////////////////////////////// - // IInitialize - bool Initialize() override; + ////////////////////////////////////////////////////////////////////////////////////// + // IInitialize + bool Initialize() override; - ///////////////////////////////////////////////////////////////////////////////////// - // IListNotify - void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; + ///////////////////////////////////////////////////////////////////////////////////// + // IListNotify + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; - ///////////////////////////////////////////////////////////////////////////////////// - // ITr2ControllerOwner - void SetControllerVariable( const char* name, float value ) override; - void HandleControllerEvent( const char* name ) override; - void StartControllers() override; + ///////////////////////////////////////////////////////////////////////////////////// + // ITr2ControllerOwner + void SetControllerVariable( const char* name, float value ) override; + void HandleControllerEvent( const char* name ) override; + void StartControllers() override; - ///////////////////////////////////////////////////////////////////////////////////// - // ITr2CurveSetOwner - void PlayCurveSet( const std::string& name, const std::string& rangeName ) override; - void StopCurveSet( const std::string& name ) override; - float GetCurveSetDuration( const std::string& name ) const override; - float GetRangeDuration( const std::string& name, const std::string& rangeName ) const override; + ///////////////////////////////////////////////////////////////////////////////////// + // ITr2CurveSetOwner + void PlayCurveSet( const std::string& name, const std::string& rangeName ) override; + void StopCurveSet( const std::string& name ) override; + float GetCurveSetDuration( const std::string& name ) const override; + float GetRangeDuration( const std::string& name, const std::string& rangeName ) const override; std::string m_name; @@ -89,11 +89,10 @@ BLUE_CLASS( EveMeshOverlayEffect ) : PTr2EffectVector m_additiveEffects; PTr2EffectVector m_distortionEffects; - PITr2ControllerVector m_controllers; + PITr2ControllerVector m_controllers; // animating this overlay effect TriCurveSetPtr m_curveSet; - }; TYPEDEF_BLUECLASS( EveMeshOverlayEffect ); diff --git a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect_Blue.cpp index 113bb3ece..07bfe4f00 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveMeshOverlayEffect_Blue.cpp @@ -11,11 +11,11 @@ BLUE_DEFINE( EveMeshOverlayEffect ); const Be::ClassInfo* EveMeshOverlayEffect::ExposeToBlue() { EXPOSURE_BEGIN( EveMeshOverlayEffect, "" ) - MAP_INTERFACE( EveMeshOverlayEffect ) + MAP_INTERFACE( EveMeshOverlayEffect ) MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE( ITr2CurveSetOwner ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( ITr2ControllerOwner ) + MAP_INTERFACE( ITr2CurveSetOwner ) MAP_ATTRIBUTE( "display", m_display, "Toggle visibility", Be::READWRITE ) MAP_ATTRIBUTE( "update", m_update, "Toggle update", Be::READWRITE ) @@ -26,6 +26,6 @@ const Be::ClassInfo* EveMeshOverlayEffect::ExposeToBlue() MAP_ATTRIBUTE( "transparentEffects", m_transparentEffects, "List of transparent effects.", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "additiveEffects", m_additiveEffects, "List of additive effect, rendered after transparencies", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "distortionEffects", m_distortionEffects, "List of distortion effects", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "controllers", m_controllers, "Controllers for awesomeness", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "controllers", m_controllers, "Controllers for awesomeness", Be::READ | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp index 3a6354c58..b3388e9fb 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.cpp @@ -24,10 +24,9 @@ TRI_REGISTER_SETTING( "buildDecalBuffers", g_buildDecalBuffers ); using namespace Tr2RenderContextEnum; -static BlueStructureDefinition s_eveSpaceObjectDecalIndexDef[] = -{ - { "index", Be::UINT32_1, 0 }, - {0} +static BlueStructureDefinition s_eveSpaceObjectDecalIndexDef[] = { + { "index", Be::UINT32_1, 0 }, + { 0 } }; // ------------------------------------------------------------------------------------------------------ @@ -86,7 +85,7 @@ bool EveSpaceObjectDecal::Initialize() // ------------------------------------------------------------------------------------------------------ bool EveSpaceObjectDecal::OnModified( Be::Var* value ) { - if( IsMatch( value, m_position ) || IsMatch( value, m_rotation ) || IsMatch( value, m_scaling ) ) + if( IsMatch( value, m_position ) || IsMatch( value, m_rotation ) || IsMatch( value, m_scaling ) ) { // update the decal matrix UpdateDecalMatrix(); @@ -126,7 +125,7 @@ void EveSpaceObjectDecal::UpdateVisibility( const EveUpdateContext& updateContex if( m_minScreenSize > 0 ) { - Matrix worldDecalMatrix = m_parentBoneMatrix * parentData->transform; + Matrix worldDecalMatrix = m_parentBoneMatrix * parentData->transform; Vector3 min( -1, -1, -1 ); Vector3 max( 1, 1, 1 ); @@ -146,12 +145,12 @@ void EveSpaceObjectDecal::UpdateVisibility( const EveUpdateContext& updateContex m_parentData = *parentData; return; } - else if( !frustum.IsBoxVisible( min, max) ) + else if( !frustum.IsBoxVisible( min, max ) ) { m_isVisible = 0; return; } - + Vector3 closest = ClosestPointToBoundingBox( min, max, frustum.m_viewPos ); worldDecalMatrix = TranslationMatrix( closest - frustum.m_viewPos ) * worldDecalMatrix; } @@ -162,14 +161,14 @@ void EveSpaceObjectDecal::UpdateVisibility( const EveUpdateContext& updateContex float sphereRadius( Length( min - max ) / 2 ); auto pixelSize = frustum.GetPixelSizeAccrossEst( sphereCenter, sphereRadius ); - + float modifiedMinScreen = m_minScreenSize * updateContext.GetLodFactor(); if( pixelSize < modifiedMinScreen ) { m_isVisible = 0; return; } - + m_isVisible = std::min( ( pixelSize - modifiedMinScreen ) / ( modifiedMinScreen * 0.5f ), 1.f ); } else @@ -196,7 +195,7 @@ void EveSpaceObjectDecal::GetRenderables( std::vector& renderab auto mesh = geomRes->GetMeshData( 0 ); - if( !m_decalGeometry || (mesh && mesh->m_lodMask != m_decalGeometry->m_lodMask) ) + if( !m_decalGeometry || ( mesh && mesh->m_lodMask != m_decalGeometry->m_lodMask ) ) { if( HasStaticIndexBuffers() ) { @@ -248,8 +247,8 @@ bool EveSpaceObjectDecal::HasTransparentBatches() // Description: // Todo // -------------------------------------------------------------------------------- -void EveSpaceObjectDecal::GetBatches( ITriRenderBatchAccumulator* batches, - TriBatchType batchType, +void EveSpaceObjectDecal::GetBatches( ITriRenderBatchAccumulator* batches, + TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { @@ -353,26 +352,26 @@ Tr2PerObjectData* EveSpaceObjectDecal::GetPerObjectData( ITriRenderBatchAccumula return NULL; } - // world matrix - perObjectData->m_vsData.m_worldMatrix = Transpose( m_parentData.transform ); + // world matrix + perObjectData->m_vsData.m_worldMatrix = Transpose( m_parentData.transform ); // inv world matrix - perObjectData->m_vsData.m_invWorldMatrix = Inverse( perObjectData->m_vsData.m_worldMatrix ); + perObjectData->m_vsData.m_invWorldMatrix = Inverse( perObjectData->m_vsData.m_worldMatrix ); // decal matrix (both nrm and inv) - perObjectData->m_vsData.m_decalMatrix = Transpose( m_decalMatrix ); - perObjectData->m_vsData.m_inverseDecalMatrix = Transpose( m_inverseDecalMatrix ); + perObjectData->m_vsData.m_decalMatrix = Transpose( m_decalMatrix ); + perObjectData->m_vsData.m_inverseDecalMatrix = Transpose( m_inverseDecalMatrix ); // matrix from possible bone animation of parent - perObjectData->m_vsData.m_parentBoneMatrix = Transpose( m_parentBoneMatrix ); - perObjectData->m_vsData.m_invParentBoneMatrix = Inverse( Transpose( m_parentBoneMatrix ) ); + perObjectData->m_vsData.m_parentBoneMatrix = Transpose( m_parentBoneMatrix ); + perObjectData->m_vsData.m_invParentBoneMatrix = Inverse( Transpose( m_parentBoneMatrix ) ); // clip sphere data from parent - perObjectData->m_psData.m_shipData = m_parentData.shipData; - perObjectData->m_psData.m_clipData = Vector4( m_parentData.clipSphereCenter, m_parentData.clipRadiusSq ); + perObjectData->m_psData.m_shipData = m_parentData.shipData; + perObjectData->m_psData.m_clipData = Vector4( m_parentData.clipSphereCenter, m_parentData.clipRadiusSq ); perObjectData->m_psData.m_clipRadius2Sq = m_parentData.clipRadius2Sq; // display data - perObjectData->m_psData.m_displayData = Vector4( (float)m_parentData.killCount, m_isVisible, 0.f, 0.f ); + perObjectData->m_psData.m_displayData = Vector4( (float)m_parentData.killCount, m_isVisible, 0.f, 0.f ); if( m_parentData.shLighting ) { @@ -386,7 +385,7 @@ Tr2PerObjectData* EveSpaceObjectDecal::GetPerObjectData( ITriRenderBatchAccumula return perObjectData; } -void EveSpaceObjectDecal::CopyFrom( EveSpaceObjectDecal *object ) +void EveSpaceObjectDecal::CopyFrom( EveSpaceObjectDecal* object ) { m_display = object->m_display; m_position = object->m_position; @@ -406,7 +405,7 @@ void EveSpaceObjectDecal::RenderDebugInfo( ITr2DebugRenderer2& renderer, const M Matrix worldDecalMatrix = m_parentBoneMatrix * worldMatrix; if( m_instanceData != nullptr ) { - if( Tr2RuntimeInstanceDataPtr runtimeInstanceData = BlueCastPtr(m_instanceData) ) + if( Tr2RuntimeInstanceDataPtr runtimeInstanceData = BlueCastPtr( m_instanceData ) ) { // do some magic for instanced meshes that have decals! const char* data = reinterpret_cast( runtimeInstanceData->GetData() ); @@ -454,11 +453,10 @@ void EveSpaceObjectDecal::RenderDebugInfo( ITr2DebugRenderer2& renderer, const M renderer.DrawBox( this, instancedDecalMatrix, Vector3( -1, -1, -1 ), Vector3( 1, 1, 1 ), Tr2DebugRenderer::Wireframe, Tr2DebugColor( 0xff00ffff, 0x2200ffff ) ); renderer.DrawBox( this, instancedDecalMatrix, Vector3( -1, -1, -1 ), Vector3( 1, 1, 1 ), Tr2DebugRenderer::Solid, 0 ); } - } } } - else + else { worldDecalMatrix = m_decalMatrix * worldDecalMatrix; renderer.DrawBox( this, worldDecalMatrix, Vector3( -1, -1, -1 ), Vector3( 1, 1, 1 ), Tr2DebugRenderer::Wireframe, Tr2DebugColor( 0xff00ffff, 0x2200ffff ) ); @@ -489,7 +487,7 @@ void EveSpaceObjectDecal::SetBoneMatrix( const Float4x3* bonesMatrices, int bone } // keep it - TriMatrixCopyFrom3x4( &m_parentBoneMatrix, &bonesMatrices[ m_parentBoneIndex ] ); + TriMatrixCopyFrom3x4( &m_parentBoneMatrix, &bonesMatrices[m_parentBoneIndex] ); } // -------------------------------------------------------------------------------------- @@ -619,7 +617,7 @@ void EveSpaceObjectDecal::CreateDecalIndexBuffers( TriGeometryResPtr geomRes, De TriGeometryResMeshData* meshData = geomRes->GetMeshData( 0 ); - if (!meshData) + if( !meshData ) { return; } @@ -633,7 +631,7 @@ void EveSpaceObjectDecal::CreateDecalIndexBuffers( TriGeometryResPtr geomRes, De } } - std::shared_ptr newDecal = std::make_shared(); + std::shared_ptr newDecal = std::make_shared(); newDecal->m_inverseDecalMatrix = m_inverseDecalMatrix; newDecal->m_lodMask = meshData->m_lodMask; @@ -974,8 +972,8 @@ void EveSpaceObjectDecal::SetPriority( uint32_t priority ) void EveDecalPerObjectData::SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { // add up constant count, see EveDecalPerObjectData - FillAndSetConstants( *buffers[VERTEX_SHADER], &m_vsData, sizeof(DecalVSPerObjectData), VERTEX_SHADER, Tr2Renderer::GetPerObjectVSStartRegister(), renderContext ); - FillAndSetConstants( *buffers[PIXEL_SHADER], &m_psData, sizeof(DecalPSPerObjectData), PIXEL_SHADER, Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); + FillAndSetConstants( *buffers[VERTEX_SHADER], &m_vsData, sizeof( DecalVSPerObjectData ), VERTEX_SHADER, Tr2Renderer::GetPerObjectVSStartRegister(), renderContext ); + FillAndSetConstants( *buffers[PIXEL_SHADER], &m_psData, sizeof( DecalPSPerObjectData ), PIXEL_SHADER, Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); } void EveDecalPerObjectData::ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const diff --git a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h index fca88cbbb..6de349978 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h +++ b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal.h @@ -24,22 +24,24 @@ BLUE_DECLARE( TriFrustum ); BLUE_DECLARE( Tr2DebugRenderer ); BLUE_DECLARE( Tr2InstancedMesh ); -struct DecalVSPerObjectData { - Matrix m_worldMatrix; - Matrix m_invWorldMatrix; - Matrix m_decalMatrix; - Matrix m_inverseDecalMatrix; - Matrix m_parentBoneMatrix; - Matrix m_invParentBoneMatrix; +struct DecalVSPerObjectData +{ + Matrix m_worldMatrix; + Matrix m_invWorldMatrix; + Matrix m_decalMatrix; + Matrix m_inverseDecalMatrix; + Matrix m_parentBoneMatrix; + Matrix m_invParentBoneMatrix; }; -struct DecalPSPerObjectData { - Vector4 m_displayData; - Vector4 m_shipData; - Vector4 m_clipData; +struct DecalPSPerObjectData +{ + Vector4 m_displayData; + Vector4 m_shipData; + Vector4 m_clipData; float m_clipRadius2Sq; Vector3 m_unused; - Vector4 m_shLightingCoefficients[Tr2ShLightingManager::PACKED_COEFFICIENT_COUNT]; + Vector4 m_shLightingCoefficients[Tr2ShLightingManager::PACKED_COEFFICIENT_COUNT]; }; // -------------------------------------------------------------------------------- @@ -55,9 +57,9 @@ class EveDecalPerObjectData : public Tr2PerObjectData void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override; // vs per object data - DecalVSPerObjectData m_vsData; + DecalVSPerObjectData m_vsData; // pixel shader per object data - DecalPSPerObjectData m_psData; + DecalPSPerObjectData m_psData; }; struct DecalMeshCache @@ -74,7 +76,7 @@ struct DecalMeshCache // Description: // ToDo // -------------------------------------------------------------------------------- -BLUE_CLASS( EveSpaceObjectDecal ) : +BLUE_CLASS( EveSpaceObjectDecal ) : public IInitialize, public Tr2DeviceResource, public INotify, @@ -87,43 +89,47 @@ BLUE_CLASS( EveSpaceObjectDecal ) : using IInitialize::Lock; using IInitialize::Unlock; - EveSpaceObjectDecal(IRoot* lockobj = NULL); + EveSpaceObjectDecal( IRoot* lockobj = NULL ); ~EveSpaceObjectDecal(); ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: +public: ////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } - virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } + virtual void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual bool HasTransparentBatches(); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); // copy init - void CopyFrom( EveSpaceObjectDecal *object ); + void CopyFrom( EveSpaceObjectDecal * object ); // access void UpdateVisibility( const EveUpdateContext& updateContext, const IEveSpaceObject2::ParentData* parentData ); - void GetRenderables( std::vector& renderables, DecalMeshCache& meshCache, TriGeometryRes* geomRes, float screensize ); - void GetInstancedRenderables( std::vector& renderables, DecalMeshCache& meshCache, const Tr2InstancedMesh* instancedMesh, float instanceScreenSize = std::numeric_limits::max() ); + void GetRenderables( std::vector & renderables, DecalMeshCache & meshCache, TriGeometryRes * geomRes, float screensize ); + void GetInstancedRenderables( std::vector & renderables, DecalMeshCache & meshCache, const Tr2InstancedMesh* instancedMesh, float instanceScreenSize = std::numeric_limits::max() ); // access position etc. const Vector3& GetPosition() const; @@ -138,7 +144,7 @@ BLUE_CLASS( EveSpaceObjectDecal ) : void SetMinScreenSize( float minScreenSize ); // edit helper - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix ) const; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldMatrix ) const; // set things from the parent, the spaceobject void SetBoneMatrix( const Float4x3* bonesMatrices, int bonesMatricesCount ); @@ -154,7 +160,7 @@ BLUE_CLASS( EveSpaceObjectDecal ) : private: // create - void CreateDecalIndexBuffers( TriGeometryResPtr geomRes, DecalMeshCache& meshCache ); + void CreateDecalIndexBuffers( TriGeometryResPtr geomRes, DecalMeshCache & meshCache ); // update void UpdateDecalMatrix(); void CreateStaticIndexBuffers( TriGeometryResPtr geomRes ); @@ -208,7 +214,7 @@ BLUE_CLASS( EveSpaceObjectDecal ) : // Bounds for mimicing the frustum culling and fading for instanced hulls that have decals Vector3 m_minBounds, m_maxBounds; - // the geometry can be frozen + // the geometry can be frozen bool m_isGeometryFrozen; }; diff --git a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal_Blue.cpp index f8a196d36..945c4c9b6 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveSpaceObjectDecal_Blue.cpp @@ -8,10 +8,10 @@ BLUE_DEFINE( EveSpaceObjectDecal ); const Be::ClassInfo* EveSpaceObjectDecal::ExposeToBlue() { EXPOSURE_BEGIN( EveSpaceObjectDecal, "" ) - MAP_INTERFACE( EveSpaceObjectDecal ) + MAP_INTERFACE( EveSpaceObjectDecal ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( ITr2Renderable ) + MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2Pickable ) MAP_ATTRIBUTE( "name", m_name, "A name for this decal", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.cpp b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.cpp index 59bb89d31..798f1195e 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.cpp @@ -18,7 +18,7 @@ using namespace Tr2RenderContextEnum; EveTrailsSet::EveTrailsSet( IRoot* lockobj ) : m_display( true ), m_trailVertexDeclElementCount( 0 ), - m_vertexDeclHandle( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), + m_vertexDeclHandle( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_fadeSpeed( 1.f ) { PrepareResources(); @@ -72,7 +72,7 @@ void EveTrailsSet::InitializeGeometryResource() if( !m_geometryResPath.empty() ) { // get new geometry resource - BeResMan->GetResource( m_geometryResPath, "", BlueInterfaceIID(), (void**)& m_geometryResource ); + BeResMan->GetResource( m_geometryResPath, "", BlueInterfaceIID(), (void**)&m_geometryResource ); } // attach callback, so ::RebuildCachedData() will be called when it finished loading @@ -281,18 +281,18 @@ void EveTrailsSet::InitializeInstanceBuffer() // create and fill with star-shape's position and some random-value std::vector verts( trailCount ); - for( unsigned int i = 0; i < trailCount ; ++i ) + for( unsigned int i = 0; i < trailCount; ++i ) { verts[i].transform = Vector4( m_trailData[i].transform._41, m_trailData[i].transform._42, m_trailData[i].transform._43, m_trailData[i].size ); } USE_MAIN_THREAD_RENDER_CONTEXT(); - - CR_RETURN( g_sharedBuffer.Allocate( + + CR_RETURN( g_sharedBuffer.Allocate( sizeof( InstanceVertex ), - trailCount, - &verts[0], - renderContext, + trailCount, + &verts[0], + renderContext, m_instanceBuffer ) ); } diff --git a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.h b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.h index e0433a6b5..75d10f42f 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.h +++ b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet.h @@ -21,7 +21,7 @@ BLUE_DECLARE( TriGeometryRes ); // SeeAlso: // EveBoosterSet2 // -------------------------------------------------------------------------------- -BLUE_CLASS( EveTrailsSet ): +BLUE_CLASS( EveTrailsSet ) : public IInitialize, public INotify, public IBlueAsyncResNotifyTarget, @@ -42,16 +42,17 @@ BLUE_CLASS( EveTrailsSet ): ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); ////////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); @@ -70,10 +71,13 @@ BLUE_CLASS( EveTrailsSet ): void Clear(); void Add( const Matrix* localMatrix, float size ); // rendering - void GetBatches( ITriRenderBatchAccumulator* accumulator, const Tr2PerObjectData* perObjectData ); + void GetBatches( ITriRenderBatchAccumulator * accumulator, const Tr2PerObjectData* perObjectData ); // query fade speed - float GetFadeSpeed() const { return m_fadeSpeed; } + float GetFadeSpeed() const + { + return m_fadeSpeed; + } // set internal visual data void SetEffect( Tr2EffectPtr effect ); void SetMeshResPath( const char* path ); diff --git a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet_Blue.cpp index 22ba56520..072257cbe 100644 --- a/trinity/Eve/SpaceObject/Attachments/EveTrailsSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/EveTrailsSet_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveTrailsSet ); const Be::ClassInfo* EveTrailsSet::ExposeToBlue() { - EXPOSURE_BEGIN( EveTrailsSet, "" ) - MAP_INTERFACE( EveTrailsSet ) + EXPOSURE_BEGIN( EveTrailsSet, "" ) + MAP_INTERFACE( EveTrailsSet ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -21,5 +21,5 @@ const Be::ClassInfo* EveTrailsSet::ExposeToBlue() MAP_ATTRIBUTE( "effect", m_effect, "Shader used for rendering", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "geometryResource", m_geometryResource, "Base geometry used for rendering", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.cpp index 65ca87b1c..32a0c5046 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.cpp @@ -17,25 +17,24 @@ namespace { - const int32_t PICK_ID_OFFSET = 101; - - BlueStructureDefinition s_bannerStructureDef[] = - { - { "bone", Be::INT32_1, 0 }, - { "position", Be::FLOAT32_3, 4 }, - { "rotation", Be::FLOAT32_4, 16 }, - { "scaling", Be::FLOAT32_3, 32 }, - { "angleX", Be::FLOAT32_1, 44 }, - { "angleY", Be::FLOAT32_1, 48 }, - { 0 } - }; +const int32_t PICK_ID_OFFSET = 101; + +BlueStructureDefinition s_bannerStructureDef[] = { + { "bone", Be::INT32_1, 0 }, + { "position", Be::FLOAT32_3, 4 }, + { "rotation", Be::FLOAT32_4, 16 }, + { "scaling", Be::FLOAT32_3, 32 }, + { "angleX", Be::FLOAT32_1, 44 }, + { "angleY", Be::FLOAT32_1, 48 }, + { 0 } +}; - EveBannerItem s_defaultBannerItem; +EveBannerItem s_defaultBannerItem; } -EveBannerItem::EveBannerItem() - :bone( -1 ), +EveBannerItem::EveBannerItem() : + bone( -1 ), position( 0, 0, 0 ), rotation( 0, 0, 0, 1 ), scaling( 1, 1, 1 ), @@ -76,8 +75,8 @@ struct EveBannerSet::Vertex { } - Vertex( const Vector3& pos, const Vector3& norm, const Vector2& tc, int32_t bone ) - :position( pos ), + Vertex( const Vector3& pos, const Vector3& norm, const Vector2& tc, int32_t bone ) : + position( pos ), normal( Vector4( norm, 0 ) ), texCoord( tc ) { @@ -87,8 +86,8 @@ struct EveBannerSet::Vertex }; -EveBannerSet::EveBannerSet( IRoot* lockobj ) - :PARENTLOCK( m_banners ), +EveBannerSet::EveBannerSet( IRoot* lockobj ) : + PARENTLOCK( m_banners ), m_key( 0 ), m_vertexDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_maxBannerRadius( 0 ), @@ -164,7 +163,7 @@ bool EveBannerSet::UpdateVisibility( const EveUpdateContext& updateContext, cons void EveBannerSet::UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float activationStrength, float boosterGain ) { - for( auto& light : m_lights ) + for( auto& light : m_lights ) { if( light.lightData.boneIndex > 0 && light.lightData.boneIndex < boneCount ) { @@ -279,19 +278,19 @@ void EveBannerSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& { for( auto& l : m_lights ) { - Quaternion q = Quaternion(0, 0, 0, 1); + Quaternion q = Quaternion( 0, 0, 0, 1 ); Vector3 scale = Vector3( 1, 1, 1 ); Matrix t = TranslationMatrix( l.lightData.position ) * l.boneMatrix; - Color c = Saturate(l.lightData.color, l.saturation); + Color c = Saturate( l.lightData.color, l.saturation ); - if( nullptr != m_primaryTextureParameter ) + if( nullptr != m_primaryTextureParameter ) { c = GetAverageColor(); } c.a = 0.5; - + renderer.DrawSphere( Tr2DebugObjectReference( m_banners.GetRawRoot(), l.index ), t, @@ -308,7 +307,6 @@ void EveBannerSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } @@ -338,7 +336,7 @@ void EveBannerSet::SetKey( int32_t key ) void EveBannerSet::AddLightFromSOF( const EveBannerLight& light ) { - m_lights.push_back(light); + m_lights.push_back( light ); } void EveBannerSet::SetPrimaryTextureParameter( TriTextureParameterPtr primaryTextureParameter ) @@ -481,13 +479,13 @@ void EveBannerSet::GetLights( Tr2LightManager& lightManager ) const auto lightFeatures = LightFeatures(); lightFeatures.parentBrightness = m_activationStrength; - for( auto light: m_lights ) + for( auto light : m_lights ) { - light.lightData.color = Saturate(averageColor, light.saturation); + light.lightData.color = Saturate( averageColor, light.saturation ); lightFeatures.profileIndex = light.lightProfile == nullptr ? 0 : light.lightProfile->GetTextureIndex(); auto data = light.lightData.AsPerPointLightData( light.boneMatrix, lightFeatures, lightManager.GetCurrentSpaceSceneShadowQuality() ); - + lightManager.AddLight( data ); } } @@ -696,128 +694,128 @@ void EveBannerSet::CreateCurvedBannerGeometry( std::vector& vertexBuffer namespace { - float GetVerticalCurvedBannerApectRatio( const EveBannerItem& banner ) - { - auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); - auto normalTransform = Inverse( Transpose( transform ) ); +float GetVerticalCurvedBannerApectRatio( const EveBannerItem& banner ) +{ + auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); + auto normalTransform = Inverse( Transpose( transform ) ); - float clamppedAngleY = std::max( 0.f, std::min( banner.angleY, 180.f ) ); + float clamppedAngleY = std::max( 0.f, std::min( banner.angleY, 180.f ) ); - uint32_t segmentsY = 1 + uint32_t( clamppedAngleY / 5 ); + uint32_t segmentsY = 1 + uint32_t( clamppedAngleY / 5 ); - auto halfAngleY = clamppedAngleY / 180.f * XM_PI / 2; + auto halfAngleY = clamppedAngleY / 180.f * XM_PI / 2; - float scaleY = 0.5f / sin( halfAngleY ); + float scaleY = 0.5f / sin( halfAngleY ); - Vector3 prevPos; - float uLength = banner.scaling.x; - float vLength = 0; + Vector3 prevPos; + float uLength = banner.scaling.x; + float vLength = 0; - for( uint32_t j = 0; j <= segmentsY; ++j ) - { - float y = float( j ) / ( segmentsY ); - float angleY = -halfAngleY + y * 2 * halfAngleY; - float sinAngleY = sin( angleY + XM_PIDIV2 ); - float cosAngleY = cos( angleY + XM_PIDIV2 ); + for( uint32_t j = 0; j <= segmentsY; ++j ) + { + float y = float( j ) / ( segmentsY ); + float angleY = -halfAngleY + y * 2 * halfAngleY; + float sinAngleY = sin( angleY + XM_PIDIV2 ); + float cosAngleY = cos( angleY + XM_PIDIV2 ); - Vector3 pos = TransformCoord( Vector3( 0, cosAngleY * scaleY, ( sinAngleY - 1 ) * scaleY ), transform ); - if( j ) - { - vLength += Length( pos - prevPos ); - } - prevPos = pos; + Vector3 pos = TransformCoord( Vector3( 0, cosAngleY * scaleY, ( sinAngleY - 1 ) * scaleY ), transform ); + if( j ) + { + vLength += Length( pos - prevPos ); } - - return uLength / vLength; + prevPos = pos; } - float GetHorizontalCurvedBannerApectRatio( const EveBannerItem& banner ) - { - auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); - auto normalTransform = Inverse( Transpose( transform ) ); + return uLength / vLength; +} - float clamppedAngleX = std::max( 0.f, std::min( banner.angleX, 180.f ) ); +float GetHorizontalCurvedBannerApectRatio( const EveBannerItem& banner ) +{ + auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); + auto normalTransform = Inverse( Transpose( transform ) ); - uint32_t segmentsX = 1 + uint32_t( clamppedAngleX / 5 ); + float clamppedAngleX = std::max( 0.f, std::min( banner.angleX, 180.f ) ); - auto halfAngleX = clamppedAngleX / 180.f * XM_PI / 2; + uint32_t segmentsX = 1 + uint32_t( clamppedAngleX / 5 ); - float scaleX = 0.5f / sin( halfAngleX ); + auto halfAngleX = clamppedAngleX / 180.f * XM_PI / 2; - Vector3 prevPos; - float uLength = 0; - float vLength = banner.scaling.y; + float scaleX = 0.5f / sin( halfAngleX ); - for( uint32_t i = 0; i <= segmentsX; ++i ) - { - float x = float( i ) / ( segmentsX ); - float angleX = -halfAngleX + x * 2 * halfAngleX; - float sinAngleX = sin( angleX ); - float cosAngleX = cos( angleX ); + Vector3 prevPos; + float uLength = 0; + float vLength = banner.scaling.y; - Vector3 pos = TransformCoord( Vector3( sinAngleX * scaleX, 0, ( cosAngleX - 1 ) * scaleX ), transform ); - if( i ) - { - uLength += Length( pos - prevPos ); - } - prevPos = pos; + for( uint32_t i = 0; i <= segmentsX; ++i ) + { + float x = float( i ) / ( segmentsX ); + float angleX = -halfAngleX + x * 2 * halfAngleX; + float sinAngleX = sin( angleX ); + float cosAngleX = cos( angleX ); + + Vector3 pos = TransformCoord( Vector3( sinAngleX * scaleX, 0, ( cosAngleX - 1 ) * scaleX ), transform ); + if( i ) + { + uLength += Length( pos - prevPos ); } - return uLength / vLength; + prevPos = pos; } + return uLength / vLength; +} - float GetCurvedBannerApectRatio( const EveBannerItem& banner ) - { - auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); - auto normalTransform = Inverse( Transpose( transform ) ); +float GetCurvedBannerApectRatio( const EveBannerItem& banner ) +{ + auto transform = TransformationMatrix( banner.scaling, banner.rotation, banner.position ); + auto normalTransform = Inverse( Transpose( transform ) ); - float clamppedAngleX = std::max( 0.f, std::min( banner.angleX, 180.f ) ); - float clamppedAngleY = std::max( 0.f, std::min( banner.angleY, 180.f ) ); + float clamppedAngleX = std::max( 0.f, std::min( banner.angleX, 180.f ) ); + float clamppedAngleY = std::max( 0.f, std::min( banner.angleY, 180.f ) ); - uint32_t segmentsX = 1 + uint32_t( clamppedAngleX / 5 ); - uint32_t segmentsY = 1 + uint32_t( clamppedAngleY / 5 ); + uint32_t segmentsX = 1 + uint32_t( clamppedAngleX / 5 ); + uint32_t segmentsY = 1 + uint32_t( clamppedAngleY / 5 ); - auto halfAngleX = clamppedAngleX / 180.f * XM_PI / 2; - auto halfAngleY = clamppedAngleY / 180.f * XM_PI / 2; + auto halfAngleX = clamppedAngleX / 180.f * XM_PI / 2; + auto halfAngleY = clamppedAngleY / 180.f * XM_PI / 2; - float scaleX = 0.5f / sin( halfAngleX ); - float scaleY = 0.5f / sin( halfAngleY ); - float scaleZ = std::min( scaleX, scaleY ); + float scaleX = 0.5f / sin( halfAngleX ); + float scaleY = 0.5f / sin( halfAngleY ); + float scaleZ = std::min( scaleX, scaleY ); - Vector3 prevPos; - float uLength = 0; - float vLength = 0; + Vector3 prevPos; + float uLength = 0; + float vLength = 0; - for( uint32_t i = 0; i <= segmentsX; ++i ) - { - float x = float( i ) / ( segmentsX ); - float angleX = -halfAngleX + x * 2 * halfAngleX; - float sinAngleX = sin( angleX ); - float cosAngleX = cos( angleX ); + for( uint32_t i = 0; i <= segmentsX; ++i ) + { + float x = float( i ) / ( segmentsX ); + float angleX = -halfAngleX + x * 2 * halfAngleX; + float sinAngleX = sin( angleX ); + float cosAngleX = cos( angleX ); - Vector3 pos = TransformCoord( Vector3( sinAngleX * scaleX, 0, ( cosAngleX - 1 ) * scaleZ ), transform ); - if( i ) - { - uLength += Length( prevPos - pos ); - } - prevPos = pos; + Vector3 pos = TransformCoord( Vector3( sinAngleX * scaleX, 0, ( cosAngleX - 1 ) * scaleZ ), transform ); + if( i ) + { + uLength += Length( prevPos - pos ); } + prevPos = pos; + } - for( uint32_t j = 0; j <= segmentsY; ++j ) - { - float y = float( j ) / ( segmentsY ); - float angleY = -halfAngleY + y * 2 * halfAngleY; - float sinAngleY = sin( angleY + XM_PIDIV2 ); - float cosAngleY = cos( angleY + XM_PIDIV2 ); + for( uint32_t j = 0; j <= segmentsY; ++j ) + { + float y = float( j ) / ( segmentsY ); + float angleY = -halfAngleY + y * 2 * halfAngleY; + float sinAngleY = sin( angleY + XM_PIDIV2 ); + float cosAngleY = cos( angleY + XM_PIDIV2 ); - Vector3 pos = TransformCoord( Vector3( 0, cosAngleY * scaleY, ( sinAngleY - 1 ) * scaleZ ), transform ); - if( j ) - { - vLength += Length( prevPos - pos ); - } - prevPos = pos; + Vector3 pos = TransformCoord( Vector3( 0, cosAngleY * scaleY, ( sinAngleY - 1 ) * scaleZ ), transform ); + if( j ) + { + vLength += Length( prevPos - pos ); } - return uLength / vLength; + prevPos = pos; } + return uLength / vLength; +} } float EveBannerSet::GetBannerAspectRatio( const EveBannerItem& banner ) diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.h index 2a50fa8cf..440bb0967 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet.h @@ -26,7 +26,7 @@ struct EveBannerItem int32_t reference; }; -struct EveBannerLight +struct EveBannerLight { EveBannerLight(); EveBannerLight( const LightData& lightData, float saturation, uint32_t index, const std::wstring& profilePath ); @@ -42,8 +42,8 @@ struct EveBannerLight BLUE_DECLARE_STRUCTURE_LIST( EveBannerItem ); -BLUE_CLASS( EveBannerSet ) - : public IEveSpaceObjectAttachment, +BLUE_CLASS( EveBannerSet ) : + public IEveSpaceObjectAttachment, public IInitialize, public IBlueStructureListNotify, public Tr2DeviceResource, @@ -59,17 +59,17 @@ BLUE_CLASS( EveBannerSet ) virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ) override; - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; void AddBanner( const EveBannerItem& banner ); - void SetEffect( Tr2Effect* effect ); + void SetEffect( Tr2Effect * effect ); void SetPrimaryTextureParameter( TriTextureParameterPtr primaryTextureParameter ); void AddLightFromSOF( const EveBannerLight& light ); - + void SetKey( int32_t key ); void Rebuild(); @@ -79,14 +79,14 @@ BLUE_CLASS( EveBannerSet ) static float GetBannerAspectRatio( const EveBannerItem& banner ); - + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; Color GetAverageColor() const; @@ -95,15 +95,16 @@ BLUE_CLASS( EveBannerSet ) virtual bool OnPrepareResources() override; virtual void OnStructureListModified( Event event, const void* item, size_t index, IBlueStructureList* list ) override; + private: struct Vertex; AxisAlignedBoundingBox GetAabb( const Float4x3* bones, size_t boneCount ) const; - void CreateBannerGeometry( std::vector& vertices, std::vector& indices, const EveBannerItem& item ) const; - void CreateFlatBannerGeometry( std::vector& vertices, std::vector& indices, const EveBannerItem& item ) const; - void CreateVerticalCurvedBannerGeometry( std::vector& vertices, std::vector& indices, const EveBannerItem& item ) const; - void CreateHorizontalCurvedBannerGeometry( std::vector& vertices, std::vector& indices, const EveBannerItem& item ) const; - void CreateCurvedBannerGeometry( std::vector& vertices, std::vector& indices, const EveBannerItem& item ) const; + void CreateBannerGeometry( std::vector & vertices, std::vector & indices, const EveBannerItem& item ) const; + void CreateFlatBannerGeometry( std::vector & vertices, std::vector & indices, const EveBannerItem& item ) const; + void CreateVerticalCurvedBannerGeometry( std::vector & vertices, std::vector & indices, const EveBannerItem& item ) const; + void CreateHorizontalCurvedBannerGeometry( std::vector & vertices, std::vector & indices, const EveBannerItem& item ) const; + void CreateCurvedBannerGeometry( std::vector & vertices, std::vector & indices, const EveBannerItem& item ) const; std::string m_name; int32_t m_key; @@ -123,7 +124,7 @@ BLUE_CLASS( EveBannerSet ) std::vector m_lights; float m_colorSaturation; float m_activationStrength; - + bool m_display; bool m_isPickable; bool m_isVisible; diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet_Blue.cpp index 62e583711..b453bdab5 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveBannerSet_Blue.cpp @@ -23,11 +23,10 @@ const Be::ClassInfo* EveBannerSet::ExposeToBlue() MAP_ATTRIBUTE( "banners", m_banners, "", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Rebuild internal buffers" ) - MAP_METHOD_AND_WRAP( - "GetReference", - GetReference, + MAP_METHOD_AND_WRAP( + "GetReference", + GetReference, "Returns private reference ID stored for each banner\n" - ":param index: banner index\n" - ) + ":param index: banner index\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.cpp index 085de4caf..c06bc2c3b 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.cpp @@ -39,7 +39,6 @@ EveHazeSetLight::EveHazeSetLight() : boneMatrix( IdentityMatrix() ), boosterGainInfluence( false ) { - } EveHazeSetLight::EveHazeSetLight( const LightData& lightData, uint32_t index, const std::wstring& profilePath, bool boosterGainInfluence ) : @@ -157,12 +156,13 @@ bool EveHazeSet::OnPrepareResources() // some index helpers to create a box static uint8_t s_boxInds[6][4] = { - { 0, 1, 2, 3 }, - { 7, 6, 5, 4 }, - { 0, 4, 5, 1 }, - { 3, 2, 6, 7 }, - { 1, 5, 6, 2 }, - { 4, 0, 3, 7 } }; + { 0, 1, 2, 3 }, + { 7, 6, 5, 4 }, + { 0, 4, 5, 1 }, + { 3, 2, 6, 7 }, + { 1, 5, 6, 2 }, + { 4, 0, 3, 7 } + }; // fill it unsigned int n = (unsigned int)m_hazes.GetSize(); @@ -253,10 +253,10 @@ void EveHazeSet::CreateBoundingBox() // -------------------------------------------------------------------------------- void EveHazeSet::GetBatches( ITriRenderBatchAccumulator* accumulator, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { - if( batchType != TRIBATCHTYPE_ADDITIVE || !m_vertexBuffer.IsValid() || reason == Tr2RenderReason::TR2RENDERREASON_REFLECTION) + if( batchType != TRIBATCHTYPE_ADDITIVE || !m_vertexBuffer.IsValid() || reason == Tr2RenderReason::TR2RENDERREASON_REFLECTION ) { return; - } + } if( m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) { @@ -331,7 +331,7 @@ void EveHazeSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& pa int32_t boneIndex = haze->m_boneIndex; Quaternion rotation( haze->m_rotation ); Vector3 position( haze->m_position ); - + if( boneIndex > -1 && boneIndex < int( boneCount ) ) { Matrix boneTF = IdentityMatrix(); @@ -350,7 +350,7 @@ void EveHazeSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& pa { for( auto& l : m_lights ) { - Matrix t = TranslationMatrix( l.lightData.position ) * l.boneMatrix; + Matrix t = TranslationMatrix( l.lightData.position ) * l.boneMatrix; Color c = l.lightData.color; @@ -374,7 +374,6 @@ void EveHazeSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& pa 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } @@ -404,11 +403,12 @@ void EveHazeSet::RegisterComponents() void EveHazeSet::GetLights( Tr2LightManager& lightManager ) const { LightFeatures features = LightFeatures(); - + for( auto& light : m_lights ) { features.parentBrightness = m_activationStrength; - if( light.boosterGainInfluence ) { + if( light.boosterGainInfluence ) + { features.parentBrightness *= m_boosterGain; } features.profileIndex = light.lightProfile == nullptr ? 0 : light.lightProfile->GetTextureIndex(); diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.h index f349f71a0..e27d6ff53 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet.h @@ -18,9 +18,9 @@ struct ViewDistanceInfo; class Tr2PerObjectData; -struct EveHazeSetLight +struct EveHazeSetLight { - EveHazeSetLight(); + EveHazeSetLight(); EveHazeSetLight( const LightData& lightData, uint32_t index, const std::wstring& profilePath, bool boosterGainInfluence ); LightData lightData; @@ -66,8 +66,8 @@ BLUE_CLASS( EveHazeSet ) : virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ) override; virtual void GetBatches( ITriRenderBatchAccumulator * accumulator, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = Tr2RenderReason::TR2RENDERREASON_NORMAL ) override; - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; void AddLightFromSOF( const EveHazeSetLight& light ); @@ -78,7 +78,7 @@ BLUE_CLASS( EveHazeSet ) : ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; // setup void Setup( Tr2EffectPtr effect ); diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSetItem_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSetItem_Blue.cpp index 3875da96c..7bab48a8e 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSetItem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSetItem_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveHazeSetItem ); const Be::ClassInfo* EveHazeSetItem::ExposeToBlue() { - EXPOSURE_BEGIN( EveHazeSetItem, "" ) - MAP_INTERFACE( EveHazeSetItem ) + EXPOSURE_BEGIN( EveHazeSetItem, "" ) + MAP_INTERFACE( EveHazeSetItem ) MAP_ATTRIBUTE( "name", m_name, "Standard name", Be::READWRITE | Be::PERSIST ) @@ -19,5 +19,5 @@ const Be::ClassInfo* EveHazeSetItem::ExposeToBlue() MAP_ATTRIBUTE( "hazeData", m_hazeData, "Various data for this haze", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boneIndex", m_boneIndex, "the bone index this plane is tight to\n:jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet_Blue.cpp index e5983e831..b7fc36ca3 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveHazeSet_Blue.cpp @@ -18,7 +18,7 @@ const Be::ClassInfo* EveHazeSet::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "Standard name", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "hazes", m_hazes, "The list of all haze items", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "effect", m_effect, "Effect to use for rendering hazes", Be::READWRITE | Be::PERSIST ) - + MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Rebuild resources after adding/removing/changing individual items" ) EXPOSURE_END() diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.cpp index a4ccf121b..1875cfba0 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.cpp @@ -188,7 +188,7 @@ void EvePlaneSet::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix Matrix boneTransform = IdentityMatrix(); size_t idx = 0; - if ( m_isSkinned ) + if( m_isSkinned ) { for( auto& vertex : m_items ) { @@ -210,7 +210,6 @@ void EvePlaneSet::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix vertex.transform3 = Vector4( transform._13, transform._23, transform._33, transform._43 ); vertex.color = data.color * activation; } - } else { @@ -248,7 +247,7 @@ bool EvePlaneSet::UpdateVisibility( const EveUpdateContext& updateContext, const void EvePlaneSet::UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float activationStrength, float boosterGain ) { - for( auto& light : m_lights ) + for( auto& light : m_lights ) { if( light.lightData.boneIndex > 0 && light.lightData.boneIndex < boneCount ) { @@ -465,7 +464,6 @@ void EvePlaneSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& p 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } @@ -507,10 +505,10 @@ Color EvePlaneSet::GetAverageColor() const image = GetAverageColor( m_imageMapParameter ); mask = GetAverageColor( m_maskMapParameter ); - return Color( layer1.r * layer2.r * image.r * mask.r, - layer1.g * layer2.g * image.g * mask.g, - layer1.b * layer2.b * image.b * mask.b, - layer1.a * layer2.a * image.a * mask.a ); + return Color( layer1.r * layer2.r * image.r * mask.r, + layer1.g * layer2.g * image.g * mask.g, + layer1.b * layer2.b * image.b * mask.b, + layer1.a * layer2.a * image.a * mask.a ); } Color EvePlaneSet::GetAverageColor( const TriTextureParameterPtr& map ) const diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.h index a485b3c0e..084783614 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet.h @@ -24,7 +24,7 @@ struct ViewDistanceInfo; class Tr2PerObjectData; -struct EvePlaneLight +struct EvePlaneLight { EvePlaneLight(); @@ -50,7 +50,7 @@ struct EvePlaneLight // SeeAlso: // EveBoosterSet2 // -------------------------------------------------------------------------------- -BLUE_CLASS( EvePlaneSet ): +BLUE_CLASS( EvePlaneSet ) : public IEveSpaceObjectAttachment, public IInitialize, public INotify, @@ -69,10 +69,10 @@ BLUE_CLASS( EvePlaneSet ): ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectAttachment @@ -81,8 +81,8 @@ BLUE_CLASS( EvePlaneSet ): void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void AddToQuadRenderer( Tr2QuadRenderer & quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ) override; virtual void GetBatches( ITriRenderBatchAccumulator * accumulator, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = Tr2RenderReason::TR2RENDERREASON_NORMAL ); - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); void AddLightFromSOF( const EvePlaneLight& light ); @@ -92,7 +92,7 @@ BLUE_CLASS( EvePlaneSet ): ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; void SetImageMapParameter( TriTextureParameterPtr imageMapParameter ); void SetLayerMap1Parameter( TriTextureParameterPtr layerMap1Parameter ); @@ -116,8 +116,9 @@ BLUE_CLASS( EvePlaneSet ): void Rebuild(); EvePlaneSetItemVector* GetPlanes(); + private: - Color GetAverageColor( ) const; + Color GetAverageColor() const; Color GetAverageColor( const TriTextureParameterPtr& ) const; struct PlaneVertex diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem.h b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem.h index 0151d215b..14c4c3c43 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem.h @@ -17,7 +17,7 @@ BLUE_DECLARE_VECTOR( EvePlaneSetItem ); // -------------------------------------------------------------------------------- BLUE_CLASS( EvePlaneSetItem ) : public IRoot - + { public: EXPOSE_TO_BLUE(); @@ -26,7 +26,7 @@ BLUE_CLASS( EvePlaneSetItem ) : CcpMath::AxisAlignedBox GetBounds() const; int32_t GetBoneIndex() const; - + // name BlueSharedString m_name; // positional attributes diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem_Blue.cpp index 9f95e5bd0..3a368b3ab 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSetItem_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EvePlaneSetItem ); const Be::ClassInfo* EvePlaneSetItem::ExposeToBlue() { - EXPOSURE_BEGIN( EvePlaneSetItem, "" ) - MAP_INTERFACE( EvePlaneSetItem ) + EXPOSURE_BEGIN( EvePlaneSetItem, "" ) + MAP_INTERFACE( EvePlaneSetItem ) MAP_ATTRIBUTE( "name", m_name, "Standard name", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "position", m_position, "Translation", Be::READWRITE | Be::PERSIST ) @@ -21,5 +21,5 @@ const Be::ClassInfo* EvePlaneSetItem::ExposeToBlue() MAP_ATTRIBUTE( "layer2Scroll", m_layer2Scroll, "Color", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boneIndex", m_boneIndex, "the bone index this plane is tight to\n:jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maskAtlasID", m_maskAtlasID, "the atlas ID for the mask map", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet_Blue.cpp index cc5dd3ed5..4f4304b73 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EvePlaneSet_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EvePlaneSet ); const Be::ClassInfo* EvePlaneSet::ExposeToBlue() { - EXPOSURE_BEGIN( EvePlaneSet, "" ) - MAP_INTERFACE( EvePlaneSet ) + EXPOSURE_BEGIN( EvePlaneSet, "" ) + MAP_INTERFACE( EvePlaneSet ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IEveSpaceObjectAttachment ) @@ -22,8 +22,8 @@ const Be::ClassInfo* EvePlaneSet::ExposeToBlue() MAP_ATTRIBUTE( "skinned", m_isSkinned, "Is the plane set skinned (requires that the owner object is skinned)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "planes", m_planes, "The list of all plane items", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "effect", m_effect, "Effect to use for rendering planes", Be::READWRITE | Be::PERSIST ) - + MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Rebuild resources after adding/removing/changing individual items" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.cpp index f45cfa804..6b96e0a81 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.cpp @@ -6,71 +6,71 @@ namespace EveSpaceObjectAttachmentUtils { - float Blink( float blinkRate, float blinkPhase, float minScale, float maxScale ) +float Blink( float blinkRate, float blinkPhase, float minScale, float maxScale ) +{ + if( blinkRate == 0.0f ) { - if( blinkRate == 0.0f ) - { - return minScale; - } - const float FLASH_PEAK_TIME = 0.05f; - float intPart; - float f = modf( Tr2Renderer::GetAnimationTime() * blinkRate + blinkPhase, &intPart ); + return minScale; + } + const float FLASH_PEAK_TIME = 0.05f; + float intPart; + float f = modf( Tr2Renderer::GetAnimationTime() * blinkRate + blinkPhase, &intPart ); - float peak = FLASH_PEAK_TIME * blinkRate; - float result = 0.0f; - float end = peak * 4.0f; + float peak = FLASH_PEAK_TIME * blinkRate; + float result = 0.0f; + float end = peak * 4.0f; - auto lerp = []( float a, float b, float f ) { - return a + f * ( b - a ); - }; + auto lerp = []( float a, float b, float f ) { + return a + f * ( b - a ); + }; - if( peak < 0.0001f ) - { - peak = 1.0f; - } - if( f < peak ) - { - result = lerp( 0.0f, 1.0f, f / peak ); - } - else if( f < end ) - { - result = lerp( 1.0f, 0.0f, ( f - peak ) / ( end - peak ) ); - } - return ( maxScale - minScale ) * result + minScale; - } - - float FadeIn( float blinkRate, float blinkPhase ) + if( peak < 0.0001f ) { - float intPart; - return modf( ( Tr2Renderer::GetAnimationTime() + blinkPhase ) * blinkRate, &intPart ); + peak = 1.0f; } - - float FadeOut( float blinkRate, float blinkPhase ) + if( f < peak ) { - return 1.0f - FadeIn( blinkRate, blinkPhase ); + result = lerp( 0.0f, 1.0f, f / peak ); } - - float FadeInOut( float blinkRate, float blinkPhase ) + else if( f < end ) { - float timeModPi = fmodf( Tr2Renderer::GetAnimationTime() * blinkRate * TRI_2PI, TRI_2PI ); - return ( sin( timeModPi + blinkPhase * TRI_2PI ) + 1.0f ) / 2.0f; + result = lerp( 1.0f, 0.0f, ( f - peak ) / ( end - peak ) ); } + return ( maxScale - minScale ) * result + minScale; +} + +float FadeIn( float blinkRate, float blinkPhase ) +{ + float intPart; + return modf( ( Tr2Renderer::GetAnimationTime() + blinkPhase ) * blinkRate, &intPart ); +} - float Fade( FadeType type, float blinkRate, float blinkPhase ) +float FadeOut( float blinkRate, float blinkPhase ) +{ + return 1.0f - FadeIn( blinkRate, blinkPhase ); +} + +float FadeInOut( float blinkRate, float blinkPhase ) +{ + float timeModPi = fmodf( Tr2Renderer::GetAnimationTime() * blinkRate * TRI_2PI, TRI_2PI ); + return ( sin( timeModPi + blinkPhase * TRI_2PI ) + 1.0f ) / 2.0f; +} + +float Fade( FadeType type, float blinkRate, float blinkPhase ) +{ + // returns the intensity + switch( type ) { - // returns the intensity - switch( type ) - { - case FT_BLINK: // Regular blinking (with a fixed curve) - return Blink( blinkRate, blinkPhase, 0, 1 ); - case FT_FADEIN: // Fade IN (Ramp up) - return FadeIn( blinkRate, blinkPhase ); - case FT_FADEOUT: // Fade OUT (Ramp down) - return FadeOut( blinkRate, blinkPhase ); - case FT_FADEINOUT: // Fade IN/OUT (Sinewave) - return FadeInOut( blinkRate, blinkPhase ); - default: - return 1.0f; - } + case FT_BLINK: // Regular blinking (with a fixed curve) + return Blink( blinkRate, blinkPhase, 0, 1 ); + case FT_FADEIN: // Fade IN (Ramp up) + return FadeIn( blinkRate, blinkPhase ); + case FT_FADEOUT: // Fade OUT (Ramp down) + return FadeOut( blinkRate, blinkPhase ); + case FT_FADEINOUT: // Fade IN/OUT (Sinewave) + return FadeInOut( blinkRate, blinkPhase ); + default: + return 1.0f; } } +} diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.h index 2a0101019..17fd18992 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpaceObjectAttachmentUtils.h @@ -4,19 +4,19 @@ namespace EveSpaceObjectAttachmentUtils { - enum FadeType - { - FT_NONE, - FT_BLINK, - FT_FADEIN, - FT_FADEOUT, - FT_FADEINOUT - }; +enum FadeType +{ + FT_NONE, + FT_BLINK, + FT_FADEIN, + FT_FADEOUT, + FT_FADEINOUT +}; - float Blink( float blinkRate, float blinkPhase, float minScale, float maxScale ); - float FadeIn( float blinkRate, float blinkPhase ); - float FadeOut( float blinkRate, float blinkPhase ); - float FadeInOut( float blinkRate, float blinkPhase ); +float Blink( float blinkRate, float blinkPhase, float minScale, float maxScale ); +float FadeIn( float blinkRate, float blinkPhase ); +float FadeOut( float blinkRate, float blinkPhase ); +float FadeInOut( float blinkRate, float blinkPhase ); - float Fade( FadeType type, float blinkRate, float blinkPhase ); +float Fade( FadeType type, float blinkRate, float blinkPhase ); } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.cpp index f0b8ea02e..f0184bae4 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.cpp @@ -24,8 +24,8 @@ const Tr2VertexDefinition& EveSpotlightSet::GlowPoolVertex::GetDefinition() vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 0, 1, 1 ); vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 1, 1, 1 ); vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 2, 1, 1 ); - vd.Add( vd.FLOAT16_4 , vd.COLOR, 0, 1, 1 ); - vd.Add( vd.FLOAT16_4 , vd.COLOR, 1, 1, 1 ); + vd.Add( vd.FLOAT16_4, vd.COLOR, 0, 1, 1 ); + vd.Add( vd.FLOAT16_4, vd.COLOR, 1, 1, 1 ); vd.Add( vd.FLOAT16_4, vd.TEXCOORD, 3, 1, 1 ); } return s_definition; @@ -42,7 +42,7 @@ const Tr2VertexDefinition& EveSpotlightSet::ConePoolVertex::GetDefinition() vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 0, 1, 1 ); vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 1, 1, 1 ); vd.Add( vd.FLOAT32_4, vd.TEXCOORD, 2, 1, 1 ); - vd.Add( vd.FLOAT16_4 , vd.COLOR, 0, 1, 1 ); + vd.Add( vd.FLOAT16_4, vd.COLOR, 0, 1, 1 ); vd.Add( vd.FLOAT16_2, vd.TEXCOORD, 3, 1, 1 ); } return s_definition; @@ -59,10 +59,9 @@ const int SPRITE_QUAD_COUNT = 2; EveSpotlightLight::EveSpotlightLight() : lightData( LightData() ), index( 0 ), - boneMatrix( IdentityMatrix() ), + boneMatrix( IdentityMatrix() ), boosterGainInfluence( false ) { - } EveSpotlightLight::EveSpotlightLight( const LightData& lightData, uint32_t index, const std::wstring& profilePath, bool boosterGainInfluence ) : @@ -150,7 +149,7 @@ bool EveSpotlightSet::UpdateVisibility( const EveUpdateContext& updateContext, c void EveSpotlightSet::UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float activationStrength, float boosterGain ) { - for( auto& light : m_lights ) + for( auto& light : m_lights ) { if( light.lightData.boneIndex > 0 && light.lightData.boneIndex < boneCount ) { @@ -181,7 +180,7 @@ AxisAlignedBoundingBox EveSpotlightSet::GetAabb( const Float4x3* bones, size_t b // -------------------------------------------------------------------------------- // Description: -// Registers set effects with quad renderer if quad rendering was enabled with +// Registers set effects with quad renderer if quad rendering was enabled with // UseQuadRenderer call. // Arguments: // quadRenderer - quad renderer @@ -194,7 +193,7 @@ void EveSpotlightSet::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) // -------------------------------------------------------------------------------- // Description: -// Adds sprites to render with quad renderer if quad rendering was enabled with +// Adds sprites to render with quad renderer if quad rendering was enabled with // UseQuadRenderer call. // Arguments: // quadRenderer - quad renderer @@ -516,7 +515,6 @@ void EveSpotlightSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matri 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } @@ -542,7 +540,8 @@ void EveSpotlightSet::GetLights( Tr2LightManager& lightManager ) const for( auto& light : m_lights ) { features.parentBrightness = m_activationStrength; - if( light.boosterGainInfluence ) { + if( light.boosterGainInfluence ) + { features.parentBrightness *= m_boosterGain; } features.profileIndex = light.lightProfile == nullptr ? 0 : light.lightProfile->GetTextureIndex(); diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.h index 8228b12c9..f30d19de7 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet.h @@ -20,8 +20,9 @@ BLUE_DECLARE_VECTOR( EveSpotlightSet ); BLUE_DECLARE( Tr2Effect ); BLUE_DECLARE( Tr2DebugRenderer ); -struct EveSpotlightLight { - EveSpotlightLight(); +struct EveSpotlightLight +{ + EveSpotlightLight(); EveSpotlightLight( const LightData& lightData, uint32_t index, const std::wstring& profilePath, bool boosterGainInfluence ); LightData lightData; @@ -38,29 +39,29 @@ struct EveSpotlightLight { // SeeAlso: // EveSpriteSet, EveSpaceObject2 // -------------------------------------------------------------------------------- -BLUE_CLASS( EveSpotlightSet ): +BLUE_CLASS( EveSpotlightSet ) : public IEveSpaceObjectAttachment, public IInitialize, public ITr2LightOwner, public EveEntity { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using IInitialize::Lock; using IInitialize::Unlock; - EveSpotlightSet( IRoot* lockobj = NULL ); + EveSpotlightSet( IRoot* lockobj = NULL ); ~EveSpotlightSet(); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectAttachment virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ); - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); - virtual void AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ); - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo(ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount); + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); + virtual void AddToQuadRenderer( Tr2QuadRenderer & quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); void AddLightFromSOF( const EveSpotlightLight& light ); @@ -70,7 +71,7 @@ BLUE_CLASS( EveSpotlightSet ): ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -94,10 +95,10 @@ BLUE_CLASS( EveSpotlightSet ): const EveSpotlightSetItemVector* GetSpotlightItems() const; void AddSpotlightItem( EveSpotlightSetItemPtr item ); - void SetShaderOption (const BlueSharedString& name, const BlueSharedString& value ) override; + void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; private: - bool m_display; + bool m_display; bool m_skinned; std::string m_name; float m_intensity; @@ -147,8 +148,8 @@ BLUE_CLASS( EveSpotlightSet ): }; TrackableStdVector m_spotlightData; - void RegisterQuadRendererCone( Tr2QuadRenderer& quadRenderer ); - void RegisterQuadRendererGlow( Tr2QuadRenderer& quadRenderer ); + void RegisterQuadRendererCone( Tr2QuadRenderer & quadRenderer ); + void RegisterQuadRendererGlow( Tr2QuadRenderer & quadRenderer ); // bounding box functions AxisAlignedBoundingBox GetAabb( const Float4x3* bones, size_t boneCount ) const; diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.cpp index cedced66a..53a588911 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.cpp @@ -9,9 +9,9 @@ // -------------------------------------------------------------------------------- EveSpotlightSetItem::EveSpotlightSetItem( IRoot* lockobj ) : m_spriteScale( 1.0f, 1.0f, 1.0f ), - m_coneColor ( 1.0f, 1.0f, 1.0f, 1.0f ), + m_coneColor( 1.0f, 1.0f, 1.0f, 1.0f ), m_spriteColor( 1.0f, 1.0f, 1.0f, 1.0f ), - m_flareColor ( 1.0f, 1.0f, 1.0f, 1.0f ), + m_flareColor( 1.0f, 1.0f, 1.0f, 1.0f ), m_boneIndex( 0 ), m_boosterGainInfluence( false ), m_transform( IdentityMatrix() ) diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.h index 97740fefe..4b75d2cd3 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem.h @@ -31,7 +31,7 @@ BLUE_CLASS( EveSpotlightSetItem ) : Matrix m_transform; // 1st value is the uniform glow scale the 2nd and 3rd are the flare scale in 2D - Vector3 m_spriteScale; + Vector3 m_spriteScale; Color m_coneColor; Color m_spriteColor; diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem_Blue.cpp index ada5d3c01..dcf53cac3 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSetItem_Blue.cpp @@ -7,12 +7,12 @@ BLUE_DEFINE( EveSpotlightSetItem ); const Be::ClassInfo* EveSpotlightSetItem::ExposeToBlue() { - EXPOSURE_BEGIN( EveSpotlightSetItem, "" ) - MAP_INTERFACE( EveSpotlightSetItem ) + EXPOSURE_BEGIN( EveSpotlightSetItem, "" ) + MAP_INTERFACE( EveSpotlightSetItem ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "transform", m_transform, "The tranform matrix for the item", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "coneColor", m_coneColor, "The color of the cone of light", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "spriteColor", m_spriteColor, "The color of the glow at the base of the spotlight", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "flareColor", m_flareColor, "The color of the flare", Be::READWRITE | Be::PERSIST ) @@ -21,13 +21,11 @@ const Be::ClassInfo* EveSpotlightSetItem::ExposeToBlue() MAP_ATTRIBUTE( "boosterGainInfluence", m_boosterGainInfluence, "Toggles if this spotlight can be used to show ship movement speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "spriteScale", - m_spriteScale, - "This scale of the glow and flare at the base of the spotlight. First value is the uniform glow and the other two control the flare in 2D.", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "spriteScale", + m_spriteScale, + "This scale of the glow and flare at the base of the spotlight. First value is the uniform glow and the other two control the flare in 2D.", + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet_Blue.cpp index 517686cbd..989310f21 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpotlightSet_Blue.cpp @@ -14,59 +14,45 @@ const Be::ClassInfo* EveSpotlightSet::ExposeToBlue() MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "display", m_display, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "Is the set skinned (requires that the owner object to be skinned)", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "intensity", m_intensity, "Overall intensity", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "coneEffect", m_coneEffect, "Effect to use to render the spotlight cones", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "glowEffect", m_glowEffect, "Effect to use to render the spotlight glows", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "spotlightItems", m_spotlightItems, "", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Rebuild resources after adding/removing/changing individual items" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.cpp index d62c79573..8bb84e668 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.cpp @@ -107,7 +107,8 @@ bool EveSpriteLineSet::ReallocateResources() EveSpriteSet::SpriteData* spr = &m_spriteData[totalBufferidx]; float index = 0.0f; - for( auto& pos : positions ) { + for( auto& pos : positions ) + { // fill static pool data vtx->position = pos; vtx->warpColor = vtx->color = ( ( spriteLine->m_color & 0xff0000 ) >> 16 ) | ( spriteLine->m_color & 0xff00ff00 ) | ( ( spriteLine->m_color & 0xff ) << 16 ); @@ -150,7 +151,7 @@ bool EveSpriteLineSet::UpdateVisibility( const EveUpdateContext& updateContext, void EveSpriteLineSet::UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float activationStrength, float boosterGain ) { - for( auto& light : m_lights ) + for( auto& light : m_lights ) { if( light.lightData.boneIndex > 0 && light.lightData.boneIndex < boneCount ) { @@ -257,7 +258,8 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr { Matrix transform = parentTransform; - for( auto& spriteLine : m_spriteLines ) { + for( auto& spriteLine : m_spriteLines ) + { auto boneIndex = spriteLine->m_boneIndex; Tr2DebugColor color( Color( 0.0f, 0.7f, 0.9f, 0.5f ), Color( 0.0f, 0.7f, 0.9f, 0.1f ) ); @@ -277,8 +279,10 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr unsigned index = 0; Vector3 lastPos( 0.0, 0.0, 0.0 ); - for( auto& position : spriteLine->GetPositions() ) { - if( index != 0 ) { + for( auto& position : spriteLine->GetPositions() ) + { + if( index != 0 ) + { renderer.DrawCylinder( spriteLine, transform, @@ -287,8 +291,7 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr spriteLine->m_minScale / 2.0f, 8, Tr2DebugRenderer::Lit, - color - ); + color ); } index += 1; lastPos = position; @@ -301,7 +304,6 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr 6, Tr2DebugRenderer::Lit, color ); - } } } @@ -314,7 +316,7 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr Color c = l.lightData.color; float blinkScale = EveSpaceObjectAttachmentUtils::Blink( l.blinkRate, l.blinkPhase, l.minScale, l.maxScale ); - + c.a = 0.5; auto spriteLine = l.index > m_spriteLines.size() ? nullptr : m_spriteLines[l.index]; @@ -335,7 +337,6 @@ void EveSpriteLineSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matr 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.h index 8d0f30157..9c29b993e 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet.h @@ -19,7 +19,7 @@ BLUE_DECLARE( Tr2Effect ); // Description: // This class is for rendering a line made of sprite set blinkies // -------------------------------------------------------------------------------- -BLUE_CLASS( EveSpriteLineSet ): +BLUE_CLASS( EveSpriteLineSet ) : public IEveSpaceObjectAttachment, public IInitialize, public ITr2LightOwner, @@ -36,30 +36,29 @@ BLUE_CLASS( EveSpriteLineSet ): bool Initialize(); public: - ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectAttachment virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ); - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); - virtual void AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ); + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); + virtual void AddToQuadRenderer( Tr2QuadRenderer & quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ); void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ); // setup void Setup( Tr2EffectPtr effect, bool isSkinned ); void Add( EveSpriteLineSetItemPtr newItem ); void AddLightFromSOF( const EveSpriteLight& light ); - + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; // rebuild resources void Rebuild(); @@ -85,14 +84,13 @@ BLUE_CLASS( EveSpriteLineSet ): // all the line set PEveSpriteLineSetItemVector m_spriteLines; - + // bounding box functions AxisAlignedBoundingBox GetAabb( const Float4x3* bones, size_t boneCount ) const; // bounding boxes that are static AxisAlignedBoundingBox m_aabb; // bounding boxes are grouped together by bone index std::vector> m_boundingBoxes; - }; TYPEDEF_BLUECLASS( EveSpriteLineSet ); diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem.cpp index d12a07b1d..2cf613bbd 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem.cpp @@ -49,26 +49,27 @@ int32_t EveSpriteLineSetItem::GetBoneIndex() const } -const std::vector EveSpriteLineSetItem::GetPositions() const { +const std::vector EveSpriteLineSetItem::GetPositions() const +{ std::vector positions = std::vector(); - Matrix m = RotationMatrix(m_rotation); + Matrix m = RotationMatrix( m_rotation ); if( m_isCircle ) { // how many sprites on this line? - size_t numOfSprites = size_t(m_spacing); + size_t numOfSprites = size_t( m_spacing ); - positions.reserve(numOfSprites); + positions.reserve( numOfSprites ); float alpha = 0.f; - for (size_t i = 0; i < numOfSprites; ++i) + for( size_t i = 0; i < numOfSprites; ++i ) { // position on an ellipsoid in x,z-plane - Vector3 pos(m_scaling.x * sinf(alpha), 0.f, m_scaling.y * cosf(alpha)); - pos = TransformCoord(pos, m); + Vector3 pos( m_scaling.x * sinf( alpha ), 0.f, m_scaling.y * cosf( alpha ) ); + pos = TransformCoord( pos, m ); pos += m_position; - positions.push_back(pos); - + positions.push_back( pos ); + // next alpha += TRI_2PI / m_spacing; } @@ -76,17 +77,17 @@ const std::vector EveSpriteLineSetItem::GetPositions() const { else { // how many sprites on this line? - size_t numOfSprites = size_t(m_scaling.x); + size_t numOfSprites = size_t( m_scaling.x ); - positions.reserve(numOfSprites); + positions.reserve( numOfSprites ); // start populating the sprites from this line - Vector3 pos(m_position); - Vector3 dir = TransformNormal(Vector3(1.f, 0.f, 0.f), m); + Vector3 pos( m_position ); + Vector3 dir = TransformNormal( Vector3( 1.f, 0.f, 0.f ), m ); - for (size_t i = 0; i < numOfSprites; ++i) + for( size_t i = 0; i < numOfSprites; ++i ) { - positions.push_back(pos); + positions.push_back( pos ); // next pos += m_spacing * dir; diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem_Blue.cpp index c4c3b928b..30d0f7c69 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSetItem_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveSpriteLineSetItem ); const Be::ClassInfo* EveSpriteLineSetItem::ExposeToBlue() { - EXPOSURE_BEGIN( EveSpriteLineSetItem, "" ) - MAP_INTERFACE( EveSpriteLineSetItem ) + EXPOSURE_BEGIN( EveSpriteLineSetItem, "" ) + MAP_INTERFACE( EveSpriteLineSetItem ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "isCircle", m_isCircle, "", Be::READWRITE | Be::PERSIST ) @@ -24,5 +24,5 @@ const Be::ClassInfo* EveSpriteLineSetItem::ExposeToBlue() MAP_ATTRIBUTE( "falloff", m_falloff, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet_Blue.cpp index 39ed14bff..812720c1e 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteLineSet_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveSpriteLineSet ); const Be::ClassInfo* EveSpriteLineSet::ExposeToBlue() { - EXPOSURE_BEGIN( EveSpriteLineSet, "" ) - MAP_INTERFACE( EveSpriteLineSet ) + EXPOSURE_BEGIN( EveSpriteLineSet, "" ) + MAP_INTERFACE( EveSpriteLineSet ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( IEveSpaceObjectAttachment ) MAP_INTERFACE( ITr2LightOwner ) diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.cpp index ca9dad360..e27a6f1df 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.cpp @@ -26,8 +26,8 @@ const Tr2VertexDefinition& EveSpriteSet::PoolVertex::GetDefinition() vd.Add( vd.FLOAT32_3, vd.POSITION, 0, 1, 1 ); vd.Add( vd.FLOAT16_4, vd.TEXCOORD, 0, 1, 1 ); vd.Add( vd.FLOAT16_2, vd.TEXCOORD, 1, 1, 1 ); - vd.Add( vd.UBYTE_4_NORM , vd.COLOR, 0, 1, 1 ); - vd.Add( vd.UBYTE_4_NORM , vd.COLOR, 1, 1, 1 ); + vd.Add( vd.UBYTE_4_NORM, vd.COLOR, 0, 1, 1 ); + vd.Add( vd.UBYTE_4_NORM, vd.COLOR, 1, 1, 1 ); } return s_spriteVertexDecl; } @@ -41,7 +41,6 @@ EveSpriteLight::EveSpriteLight() : maxScale( 0 ), boneMatrix( IdentityMatrix() ) { - } EveSpriteLight::EveSpriteLight( const LightData& lightData, float blinkPhase, float blinkRate, float minScale, float maxScale, uint32_t index, const std::wstring& profilePath ) : @@ -83,7 +82,7 @@ bool EveSpriteSet::Initialize() // -------------------------------------------------------------------------------- // Description: -// Adds sprites to render as booster glow with quad renderer if quad rendering +// Adds sprites to render as booster glow with quad renderer if quad rendering // was enabled with UseQuadRenderer call. // Arguments: // quadRenderer - quad renderer @@ -99,13 +98,12 @@ void EveSpriteSet::AddBoosterGlowToQuadRenderer( Tr2QuadRenderer& quadRenderer, Matrix m = IdentityMatrix(); auto n = m_spriteData.size(); - XMVector3TransformCoordStream( reinterpret_cast - ( &m_buffer[0].position ), - sizeof( PoolVertex ), - reinterpret_cast( &m_spriteData[0].position ), - sizeof( SpriteData ), - uint32_t( n ), - world ); + XMVector3TransformCoordStream( reinterpret_cast( &m_buffer[0].position ), + sizeof( PoolVertex ), + reinterpret_cast( &m_spriteData[0].position ), + sizeof( SpriteData ), + uint32_t( n ), + world ); Float_16 zDirX( XMConvertFloatToHalf( world.GetZ().x ) ); Float_16 zDirY( XMConvertFloatToHalf( world.GetZ().y ) ); @@ -183,12 +181,12 @@ void EveSpriteSet::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matri auto n = m_spriteData.size(); if( !m_skinned ) { - XMVector3TransformCoordStream( - reinterpret_cast( &m_buffer[0].position ), - sizeof( PoolVertex ), - reinterpret_cast( &m_spriteData[0] ), - sizeof( SpriteData ), - uint32_t( n ), + XMVector3TransformCoordStream( + reinterpret_cast( &m_buffer[0].position ), + sizeof( PoolVertex ), + reinterpret_cast( &m_spriteData[0] ), + sizeof( SpriteData ), + uint32_t( n ), parentTransform ); } else @@ -200,14 +198,14 @@ void EveSpriteSet::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matri { TriMatrixCopyFrom3x4( &m, &bones[boneIndex] ); XMVECTOR position = XMVector3TransformCoord( XMLoadFloat3( reinterpret_cast( &m_spriteData[i] ) ), m ); - XMStoreFloat3( - reinterpret_cast( &m_buffer[i].position ), + XMStoreFloat3( + reinterpret_cast( &m_buffer[i].position ), XMVector3TransformCoord( position, parentTransform ) ); } else { - XMStoreFloat3( - reinterpret_cast( &m_buffer[i].position ), + XMStoreFloat3( + reinterpret_cast( &m_buffer[i].position ), XMVector3TransformCoord( XMLoadFloat3( reinterpret_cast( &m_spriteData[i] ) ), parentTransform ) ); } } @@ -222,17 +220,17 @@ void EveSpriteSet::AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matri void EveSpriteSet::Clear() { - m_sprites.Remove(-1); + m_sprites.Remove( -1 ); } -void EveSpriteSet::Add( - const Vector3& pos, - float blinkRate, - float blinkPhase, - float minScale, - float maxScale, - float falloff, - const Color& color, +void EveSpriteSet::Add( + const Vector3& pos, + float blinkRate, + float blinkPhase, + float minScale, + float maxScale, + float falloff, + const Color& color, const Color& warpColor ) { EveSpriteSetItemPtr item; @@ -318,12 +316,12 @@ void EveSpriteSet::Rebuild() auto& vertex = m_buffer[i]; vertex.position = sprite->m_position; uint32_t color = sprite->m_color; - vertex.color = + vertex.color = ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); color = sprite->m_warpColor; - vertex.warpColor = + vertex.warpColor = ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); @@ -425,7 +423,6 @@ void EveSpriteSet::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& 10, Tr2DebugRenderer::Solid, Tr2DebugColor( c ) ); - } } } @@ -436,7 +433,7 @@ void EveSpriteSet::SetShaderOption( const BlueSharedString& name, const BlueShar { m_effect->SetOption( name, value ); m_effectHash = m_effect->GetHashValue(); - RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); + RegisterWithQuadRenderer( *Tr2QuadRenderer::Instance() ); } } @@ -467,6 +464,6 @@ void EveSpriteSet::GetLights( Tr2LightManager& lightManager ) const float blinkScale = EveSpaceObjectAttachmentUtils::Blink( light.blinkRate, light.blinkPhase, light.minScale, light.maxScale ); data.radius *= blinkScale; data.innerRadius = Float_16( float( data.innerRadius ) * blinkScale ); - lightManager.AddLight(data); + lightManager.AddLight( data ); } } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.h b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.h index 31017fa8a..d6f2ecfdd 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet.h @@ -20,7 +20,8 @@ class ITriRenderBatchAccumulator; class Tr2PerObjectData; class Tr2QuadRenderer; -struct EveSpriteLight { +struct EveSpriteLight +{ EveSpriteLight(); EveSpriteLight( const LightData& lightData, float blinkPhase, float blinkRate, float minScale, float maxScale, uint32_t index, const std::wstring& profilePath ); @@ -35,7 +36,7 @@ struct EveSpriteLight { Matrix boneMatrix; }; -BLUE_CLASS( EveSpriteSet ): +BLUE_CLASS( EveSpriteSet ) : public IEveSpaceObjectAttachment, public IInitialize, public ITr2LightOwner, @@ -77,7 +78,7 @@ BLUE_CLASS( EveSpriteSet ): void Add( const Vector3& pos, float blinkRate, float blinkPhase, float minScale, float maxScale, float falloff, const Color& color, const Color& warpColor ); void Add( const Vector3& pos, float scale, const Color& color, const Color& warpColor ); void Add( EveSpriteSetItemPtr newItem ); - + // Rebuild resources void Rebuild(); @@ -85,10 +86,10 @@ BLUE_CLASS( EveSpriteSet ): // IEveSpaceObjectAttachment virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ) override; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; - virtual void AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ) override; - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; + virtual void AddToQuadRenderer( Tr2QuadRenderer & quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ) override; + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; void AddLightFromSOF( const EveSpriteLight& light ); @@ -99,9 +100,9 @@ BLUE_CLASS( EveSpriteSet ): ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; - void AddBoosterGlowToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& world, float boosterGain, float warpIntensity ); + void AddBoosterGlowToQuadRenderer( Tr2QuadRenderer & quadRenderer, const Matrix& world, float boosterGain, float warpIntensity ); EveSpriteSetItemVector* GetSprites(); const char* GetName(); diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSetItem_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSetItem_Blue.cpp index fcfa8b248..8c7ca0dec 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSetItem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSetItem_Blue.cpp @@ -7,73 +7,55 @@ BLUE_DEFINE( EveSpriteSetItem ); const Be::ClassInfo* EveSpriteSetItem::ExposeToBlue() { - EXPOSURE_BEGIN( EveSpriteSetItem, "" ) - MAP_INTERFACE( EveSpriteSetItem ) + EXPOSURE_BEGIN( EveSpriteSetItem, "" ) + MAP_INTERFACE( EveSpriteSetItem ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "position", - m_position, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "blinkRate", - m_blinkRate, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "blinkPhase", - m_blinkPhase, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "minScale", - m_minScale, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "maxScale", - m_maxScale, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "falloff", - m_falloff, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "color", - m_color, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "warpColor", - m_warpColor, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "boneIndex", - m_boneIndex, + MAP_ATTRIBUTE( + "position", + m_position, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( + "blinkRate", + m_blinkRate, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "blinkPhase", + m_blinkPhase, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "minScale", + m_minScale, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "maxScale", + m_maxScale, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "falloff", + m_falloff, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "color", + m_color, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( + "warpColor", + m_warpColor, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( + "boneIndex", + m_boneIndex, "the bone index this blinky is tight to\n:jessica-widget: boneindex", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet_Blue.cpp b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet_Blue.cpp index d0294a0ef..87fadec2a 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Attachments/Sets/EveSpriteSet_Blue.cpp @@ -8,57 +8,45 @@ BLUE_DEFINE( EveSpriteSet ); const Be::ClassInfo* EveSpriteSet::ExposeToBlue() { - EXPOSURE_BEGIN( EveSpriteSet, "" ) - MAP_INTERFACE( EveSpriteSet ) + EXPOSURE_BEGIN( EveSpriteSet, "" ) + MAP_INTERFACE( EveSpriteSet ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( IEveSpaceObjectAttachment ) MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( + "name", + m_name, + "", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sprites", m_sprites, "", - Be::READ | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "effect", - m_effect, - "Effect to use for rendering sprites", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "display", - m_display, - "Specifies whether to render the object or not", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "skinned", - m_skinned, - "Is the sprite set skinned (requires that the owner object is skinned)", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "intensity", - m_intensity, - "Overall sprite intensity", - Be::READWRITE | Be::PERSIST - ) + Be::READ | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "effect", + m_effect, + "Effect to use for rendering sprites", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "display", + m_display, + "Specifies whether to render the object or not", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "skinned", + m_skinned, + "Is the sprite set skinned (requires that the owner object is skinned)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "intensity", + m_intensity, + "Overall sprite intensity", + Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Rebuild", Rebuild, "Rebuild resources after adding/removing/changing individual sprites" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachment.h b/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachment.h index fd516668c..9bbfc8a20 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachment.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachment.h @@ -12,19 +12,35 @@ class Tr2QuadRenderer; class TriFrustum; -BLUE_INTERFACE( IEveSpaceObjectAttachment ) : public IRoot +BLUE_INTERFACE( IEveSpaceObjectAttachment ) : + public IRoot{ + virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ){ return false; +} + +virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = Tr2RenderReason::TR2RENDERREASON_NORMAL ) { - virtual bool UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) { return false; } +} - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = Tr2RenderReason::TR2RENDERREASON_NORMAL ) {} +virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) +{ +} +virtual void AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ) +{ +} - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) {} - virtual void AddToQuadRenderer( Tr2QuadRenderer& quadRenderer, const Matrix& parentTransform, float activation, float boosterGain, const Float4x3* bones, size_t boneCount ) {} +virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) +{ +} +virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) +{ +} - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) {} - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Float4x3* bones, size_t boneCount ) {} +virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) +{ +} - virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {} - - virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ) {} -}; +virtual void UpdateLights( const Matrix& parentTransform, const Float4x3* bones, size_t boneCount, float parentStrength, float boosterGain ) +{ +} +} +; diff --git a/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachmentOwner.h b/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachmentOwner.h index f049c71fc..abf27cd09 100644 --- a/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachmentOwner.h +++ b/trinity/Eve/SpaceObject/Attachments/Sets/IEveSpaceObjectAttachmentOwner.h @@ -7,6 +7,6 @@ BLUE_DECLARE_INTERFACE( IEveSpaceObjectAttachment ); BLUE_INTERFACE( IEveSpaceObjectAttachmentOwner ) : public IRoot { - virtual void AddAttachment( IEveSpaceObjectAttachment* attachment ) = 0; + virtual void AddAttachment( IEveSpaceObjectAttachment * attachment ) = 0; virtual void ClearAttachments() = 0; }; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Allign.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Allign.cpp index 595e932e5..68be9b189 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Allign.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Allign.cpp @@ -4,7 +4,7 @@ #include "Allign.h" -Allign::Allign( IRoot* lockobj ): +Allign::Allign( IRoot* lockobj ) : m_enabled( true ), m_behaviorWeight( 1 ), m_visionRange( 75 ), @@ -24,31 +24,30 @@ int Allign::GetProcessPriority() return m_priority; } -std::vector Allign::CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius) +std::vector Allign::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { std::vector returnForces; if( !m_enabled ) { return returnForces; } - + int c = 0; - if ( m_frameCounter == 0 ) + if( m_frameCounter == 0 ) { m_lastPullForces.clear(); - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) { - if ( dronesInSearchRadius[c].empty() ) + if( dronesInSearchRadius[c].empty() ) { - m_lastPullForces.push_back( Vector3(0,0,0) ); + m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); continue; } Vector3 groupDirection = Vector3( 0, 0, 0 ); - for ( auto a = dronesInSearchRadius[ c ].begin(); a != dronesInSearchRadius[ c ].end(); ++a ) + for( auto a = dronesInSearchRadius[c].begin(); a != dronesInSearchRadius[c].end(); ++a ) { - if( (*a)->id == agent->id ) + if( ( *a )->id == agent->id ) { continue; } @@ -64,10 +63,10 @@ std::vector Allign::CalculateBehavior(std::vector& agents, } else { - m_lastPullForces.push_back( Vector3(0,0,0 ) ); + m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); } - if ( group.m_collectForces ) + if( group.m_collectForces ) { Vector3 forceOffset = Normalize( pullVector ) * group.GetBoundingSphereRadius(); returnForces.push_back( agent->position + forceOffset ); @@ -77,25 +76,25 @@ std::vector Allign::CalculateBehavior(std::vector& agents, } else { - if ( m_lastPullForces.empty() ) + if( m_lastPullForces.empty() ) { return returnForces; } - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) { - if ( c >= static_cast< int >( m_lastPullForces.size() ) ) + if( c >= static_cast( m_lastPullForces.size() ) ) { break; } - agent->acceleration += m_lastPullForces[ c ]; + agent->acceleration += m_lastPullForces[c]; - if ( group.m_collectForces && m_lastPullForces[ c ] != Vector3( 0, 0, 0 ) ) + if( group.m_collectForces && m_lastPullForces[c] != Vector3( 0, 0, 0 ) ) { - Vector3 forceOffset = Normalize( m_lastPullForces[ c ] ) * group.GetBoundingSphereRadius(); + Vector3 forceOffset = Normalize( m_lastPullForces[c] ) * group.GetBoundingSphereRadius(); returnForces.push_back( agent->position + forceOffset ); - returnForces.push_back( m_lastPullForces[ c ] ); + returnForces.push_back( m_lastPullForces[c] ); } } } @@ -104,7 +103,7 @@ std::vector Allign::CalculateBehavior(std::vector& agents, float Allign::GetBehaviorSearchRadius() { - if ( m_frameCounter >= m_framesBetweenUpdates ) + if( m_frameCounter >= m_framesBetweenUpdates ) { m_frameCounter = 0; return m_visionRange; @@ -121,15 +120,16 @@ void Allign::GetDebugOptions( Tr2DebugRendererOptions& options ) options.insert( "BehaviorVisionRanges" ); } -void Allign::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation) +void Allign::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ) { - if ( renderer.HasOption( this, "BehaviorVisionRanges" ) ) + if( renderer.HasOption( this, "BehaviorVisionRanges" ) ) { - if ( m_visionRange <= 0 ) return; + if( m_visionRange <= 0 ) + return; float lengthLerp = min( 1.f, max( 0.f, m_visionRange / 1500 ) ); - for ( auto agent = agents.begin(); agent != agents.end(); ++agent ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent ) { - + renderer.DrawSphere( this, TranslationMatrix( agent->position ) * parentWorldLocation, m_visionRange, 6, ITr2DebugRenderer2::Wireframe, Lerp( Color( 0xffffffff ), Color( 0xff1111ff ), lengthLerp ) ); } } diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Allign.h b/trinity/Eve/SpaceObject/Children/Behaviors/Allign.h index 9fedea0d2..619ddbdea 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Allign.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Allign.h @@ -15,10 +15,9 @@ BLUE_CLASS( Allign ) : Allign( IRoot* lockobj = nullptr ); ~Allign(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); float GetBehaviorSearchRadius(); virtual int GetProcessPriority(); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Allign_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Allign_Blue.cpp index 9d963d11d..d1d7af0b2 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Allign_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Allign_Blue.cpp @@ -5,14 +5,13 @@ BLUE_DEFINE( Allign ); -Be::VarChooser BehaviorPriorityChooser[] = - { - { "LEAST_PRIORITY", BeCast( IBehavior::LEAST_PRIORITY ), "Has the lowest priority" }, - { "LESS_PRIORITY", BeCast( IBehavior::LESS_PRIORITY ), "Second to lowest priority" }, - { "MORE_PRIORITY", BeCast( IBehavior::MORE_PRIORITY ), "second highest priority" }, - { "MOST_PRIORITY", BeCast( IBehavior::MOST_PRIORITY ), "highest priority" }, - { 0 } - }; +Be::VarChooser BehaviorPriorityChooser[] = { + { "LEAST_PRIORITY", BeCast( IBehavior::LEAST_PRIORITY ), "Has the lowest priority" }, + { "LESS_PRIORITY", BeCast( IBehavior::LESS_PRIORITY ), "Second to lowest priority" }, + { "MORE_PRIORITY", BeCast( IBehavior::MORE_PRIORITY ), "second highest priority" }, + { "MOST_PRIORITY", BeCast( IBehavior::MOST_PRIORITY ), "highest priority" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "BehaviorPriority", IBehavior::ProcessPriority, BehaviorPriorityChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); @@ -23,8 +22,7 @@ const Be::ClassInfo* Allign::ExposeToBlue() MAP_INTERFACE( Allign ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "behaviorWeight", m_behaviorWeight, "", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.cpp index 2951466b5..d92679f93 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.cpp @@ -4,7 +4,7 @@ #include "ApproachGroup.h" -ApproachGroup::ApproachGroup( IRoot* lockobj ): +ApproachGroup::ApproachGroup( IRoot* lockobj ) : m_enabled( true ), m_visionRange( 150 ), m_behaviorWeight( 60 ), @@ -24,36 +24,35 @@ int ApproachGroup::GetProcessPriority() return m_priority; } -std::vector ApproachGroup::CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius) +std::vector ApproachGroup::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { std::vector returnForces; - + if( !m_enabled ) { return returnForces; } int c = 0; - if ( m_frameCounter == 0 ) + if( m_frameCounter == 0 ) { m_lastPullForces.clear(); - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) { - if ( dronesInSearchRadius[ c ].empty() ) + if( dronesInSearchRadius[c].empty() ) { m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); continue; } Vector3 middleP = Vector3( 0, 0, 0 ); - for ( auto a = dronesInSearchRadius[ c ].begin(); a != dronesInSearchRadius[ c ].end(); ++a ) + for( auto a = dronesInSearchRadius[c].begin(); a != dronesInSearchRadius[c].end(); ++a ) { middleP += ( *a )->position; } - middleP /= static_cast< float >( dronesInSearchRadius[ c ].size() ); + middleP /= static_cast( dronesInSearchRadius[c].size() ); - if( middleP - agent->position == Vector3(0,0,0)) + if( middleP - agent->position == Vector3( 0, 0, 0 ) ) { m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); continue; @@ -61,7 +60,7 @@ std::vector ApproachGroup::CalculateBehavior(std::vector& a Vector3 pullVector = Normalize( middleP - agent->position ) * m_behaviorWeight; - if ( LengthSq( pullVector ) > 0 ) + if( LengthSq( pullVector ) > 0 ) { agent->acceleration += pullVector; m_lastPullForces.push_back( pullVector ); @@ -71,7 +70,7 @@ std::vector ApproachGroup::CalculateBehavior(std::vector& a m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); } - if ( group.m_collectForces ) + if( group.m_collectForces ) { Vector3 forceOffset = Normalize( pullVector ) * group.GetBoundingSphereRadius(); returnForces.push_back( agent->position + forceOffset ); @@ -81,25 +80,25 @@ std::vector ApproachGroup::CalculateBehavior(std::vector& a } else { - if ( m_lastPullForces.empty() ) + if( m_lastPullForces.empty() ) { return returnForces; } - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) { - if ( c >= static_cast< int >(m_lastPullForces.size()) ) + if( c >= static_cast( m_lastPullForces.size() ) ) { break; } agent->acceleration += m_lastPullForces[c]; - if ( group.m_collectForces && m_lastPullForces[ c ] != Vector3( 0, 0, 0 ) ) + if( group.m_collectForces && m_lastPullForces[c] != Vector3( 0, 0, 0 ) ) { - Vector3 forceOffset = Normalize( m_lastPullForces[ c ] ) * group.GetBoundingSphereRadius(); + Vector3 forceOffset = Normalize( m_lastPullForces[c] ) * group.GetBoundingSphereRadius(); returnForces.push_back( agent->position + forceOffset ); - returnForces.push_back( m_lastPullForces[ c ] ); + returnForces.push_back( m_lastPullForces[c] ); } } } @@ -108,7 +107,7 @@ std::vector ApproachGroup::CalculateBehavior(std::vector& a float ApproachGroup::GetBehaviorSearchRadius() { - if ( m_frameCounter >= m_framesBetweenUpdates ) + if( m_frameCounter >= m_framesBetweenUpdates ) { m_frameCounter = 0; return m_visionRange; @@ -125,13 +124,14 @@ void ApproachGroup::GetDebugOptions( Tr2DebugRendererOptions& options ) options.insert( "BehaviorVisionRanges" ); } -void ApproachGroup::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation) +void ApproachGroup::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ) { - if ( renderer.HasOption( this, "BehaviorVisionRanges" ) ) + if( renderer.HasOption( this, "BehaviorVisionRanges" ) ) { - if ( m_visionRange <= 0 ) return; + if( m_visionRange <= 0 ) + return; float lengthLerp = min( 1.f, max( 0.f, m_visionRange / 1500 ) ); - for ( auto agent = agents.begin(); agent != agents.end(); ++agent ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent ) { renderer.DrawSphere( this, TranslationMatrix( agent->position ) * parentWorldLocation, m_visionRange, 6, Tr2DebugRenderer::Wireframe, Lerp( Color( 0xffffffff ), Color( 0xff1111ff ), lengthLerp ) ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.h b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.h index c318a9a00..2cc1516ef 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup.h @@ -15,10 +15,9 @@ BLUE_CLASS( ApproachGroup ) : ApproachGroup( IRoot* lockobj = nullptr ); ~ApproachGroup(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); float GetBehaviorSearchRadius(); virtual int GetProcessPriority(); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup_Blue.cpp index b8d9b4e60..961975ecb 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ApproachGroup_Blue.cpp @@ -20,5 +20,5 @@ const Be::ClassInfo* ApproachGroup::ExposeToBlue() MAP_ATTRIBUTE( "visionRange", m_visionRange, "How far the drone looks for it's buddies", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "framesBetweenUpdates", m_framesBetweenUpdates, "updateFrequency to lessen the load", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.cpp index 37322ed6f..221674c21 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.cpp @@ -189,7 +189,7 @@ std::vector BackAndForth::CalculateBehavior( std::vector& a } agent->acceleration += desiredVelocity - agent->velocity; } - + return todo; } diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.h b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.h index 975134c7e..fd8d6404a 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth.h @@ -17,7 +17,8 @@ struct BackAndForthData deliver( false ), arrived( true ), timePassed( 0.f ) - {} + { + } Vector3 locatorTarget; Vector3 locatorDirection; @@ -46,14 +47,13 @@ BLUE_CLASS( BackAndForth ) : virtual size_t GetScratchMemorySize() const; virtual void InitializeScratch( void* scratchMemory ); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); int GetProcessPriority(); std::string GetBehaviorName(); - void SetParent( IEveSpaceObject2 *parent ); + void SetParent( IEveSpaceObject2 * parent ); private: bool m_enabled; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth_Blue.cpp index 1be828d21..f6e875b5c 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BackAndForth_Blue.cpp @@ -7,13 +7,12 @@ BLUE_DEFINE( BackAndForth ); extern Be::VarChooser BehaviorPriorityChooser[]; -Be::VarChooser LocatorChooser[] = - { - { "localLocators", BeCast( BackAndForth::LOCAL_LOCATORS ), "Place locators manually, this is for back and forth locators." }, - { "parentLocatorSet", BeCast( BackAndForth::PARENT_LOCATORS ), "use the parent's locatorSet for drones to seek. Remember to set the locatorSetName" }, - { "targetLocatorSet", BeCast( BackAndForth::TARGET_LOCATORS ), "use the target's locatorSet for drones to seek. Remember to set the locatorSetName" }, - { 0 } - }; +Be::VarChooser LocatorChooser[] = { + { "localLocators", BeCast( BackAndForth::LOCAL_LOCATORS ), "Place locators manually, this is for back and forth locators." }, + { "parentLocatorSet", BeCast( BackAndForth::PARENT_LOCATORS ), "use the parent's locatorSet for drones to seek. Remember to set the locatorSetName" }, + { "targetLocatorSet", BeCast( BackAndForth::TARGET_LOCATORS ), "use the target's locatorSet for drones to seek. Remember to set the locatorSetName" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "LocatorType", BackAndForth::LocatorType, LocatorChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); const Be::ClassInfo* BackAndForth::ExposeToBlue() diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.cpp index 4b47542db..8571b9a6f 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.cpp @@ -85,8 +85,7 @@ void BehaviorGroup::OnListModified( { switch( event & BELIST_EVENTMASK ) { - case BELIST_INSERTED: - { + case BELIST_INSERTED: { m_scratchData.insert( m_scratchData.begin() + key, CcpMallocBuffer() ); if( !m_agents.empty() ) { @@ -420,7 +419,7 @@ void BehaviorGroup::RemoveAgent() return; } // Removes a random agent - int rand = TriRandInt( int(m_agents.size()) ); + int rand = TriRandInt( int( m_agents.size() ) ); RemoveSpecificAgent( rand ); OnAgentCountChanged(); @@ -569,7 +568,7 @@ void BehaviorGroup::UpdateAgents( const float dt, EveChildBehaviorSystem& system auto bs = m_boundingSphereRadius * m_scale; - const std::vector>>* dronesInRange = m_tree->FindDronesInRange( m_agents, ranges, bs ); + const std::vector>>* dronesInRange = m_tree->FindDronesInRange( m_agents, ranges, bs ); //Calculate the behaviors if( m_collectForces ) @@ -699,7 +698,7 @@ void BehaviorGroup::GetShipInfoForBuffer( uint8_t* data, const Matrix& parentWor if( m_currentScreenSize == 0.0 ) { - memset( data, 0, m_agents.size() * (24 * sizeof( float )) ); + memset( data, 0, m_agents.size() * ( 24 * sizeof( float ) ) ); return; } @@ -988,7 +987,7 @@ void BehaviorGroup::SetPlayFXBehavior() } } -void BehaviorGroup::GetLights(Tr2LightManager& lightManager) const +void BehaviorGroup::GetLights( Tr2LightManager& lightManager ) const { if( m_booster && m_booster->GetDisplay() ) { diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.h b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.h index 6b305a468..58f0c4d95 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup.h @@ -62,8 +62,8 @@ BLUE_CLASS( BehaviorGroup ) : void AddAgents( const std::vector& positions ); void RemoveAgent(); void RemoveSpecificAgent( int index ); - void UpdateAsyncronous( const EveUpdateContext & updateContext ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ); + void UpdateAsyncronous( const EveUpdateContext& updateContext ); + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAgents( const float dt, EveChildBehaviorSystem& system ); float AllTheSame(); bool IsGroupVisible() const; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.cpp index 58b4bc710..037199ad0 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.cpp @@ -16,63 +16,63 @@ namespace { - ALResult GetBoxVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) - { - const uint32_t vertexCount = 4 * 6; - BehaviorGroupBooster::BoosterVertex vertices[vertexCount]; - auto p = &vertices[0]; - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); - ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); - ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); - - ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); - ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); - ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); - - return g_sharedBuffer.Allocate( sizeof( BehaviorGroupBooster::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); - } - - Tr2VertexDefinition& GetQuadDefinition() +ALResult GetBoxVB( Tr2SuballocatedBuffer::Allocation& vb, Tr2PrimaryRenderContext& renderContext ) +{ + const uint32_t vertexCount = 4 * 6; + BehaviorGroupBooster::BoosterVertex vertices[vertexCount]; + auto p = &vertices[0]; + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, -1.0f, 0.0f ); + ( p++ )->position = Vector3( -1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, -1.0f ); + ( p++ )->position = Vector3( 1.0f, -1.0f, 0.0f ); + + ( p++ )->position = Vector3( -1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, 0.0f ); + ( p++ )->position = Vector3( 1.0f, 1.0f, -1.0f ); + ( p++ )->position = Vector3( -1.0f, 1.0f, -1.0f ); + + return g_sharedBuffer.Allocate( sizeof( BehaviorGroupBooster::BoosterVertex ), vertexCount, &vertices[0], renderContext, vb ); +} + +Tr2VertexDefinition& GetQuadDefinition() +{ + static Tr2VertexDefinition def; + if( def.empty() ) { - static Tr2VertexDefinition def; - if( def.empty() ) - { - def.Add( def.FLOAT32_1, def.TEXCOORD, 5 ); + def.Add( def.FLOAT32_1, def.TEXCOORD, 5 ); - def.Add( def.FLOAT32_4, def.POSITION, 0, 1, 1 ); - def.Add( def.FLOAT32_4, def.POSITION, 1, 1, 1 ); - def.Add( def.FLOAT32_4, def.POSITION, 2, 1, 1 ); - def.Add( def.FLOAT32_4, def.POSITION, 3, 1, 1 ); - def.Add( def.FLOAT32_4, def.POSITION, 4, 1, 1 ); - def.Add( def.FLOAT32_4, def.POSITION, 5, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 0, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 1, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 2, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 3, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 4, 1, 1 ); + def.Add( def.FLOAT32_4, def.POSITION, 5, 1, 1 ); - def.Add( def.FLOAT16_4, def.TEXCOORD, 0, 1, 1 ); - def.Add( def.FLOAT16_2, def.TEXCOORD, 1, 1, 1 ); - } - return def; + def.Add( def.FLOAT16_4, def.TEXCOORD, 0, 1, 1 ); + def.Add( def.FLOAT16_2, def.TEXCOORD, 1, 1, 1 ); } + return def; +} } @@ -159,7 +159,7 @@ void BehaviorGroupBooster::InitializeEffects() } if( m_haloFlareEffect == nullptr ) { - m_haloFlareEffect = CreateFlareEffect(); + m_haloFlareEffect = CreateFlareEffect(); InitializeHaloFlare(); } SetupQuads(); @@ -186,7 +186,7 @@ bool BehaviorGroupBooster::OnModified( Be::Var* value ) InitializeHaloFlare(); SetupQuads(); } - else + else { m_haloFlares.clear(); } @@ -198,7 +198,7 @@ bool BehaviorGroupBooster::OnModified( Be::Var* value ) InitializeAmbientFlare(); SetupQuads(); } - else + else { m_ambientFlares.clear(); } @@ -228,7 +228,7 @@ void BehaviorGroupBooster::SetupQuads() // turn the halo correctly so it works with the halo modifier m_haloMatrix = RotationMatrix( Quaternion( 0, 1, 0, 0 ) ); - + AdjustFlareLists(); } @@ -242,7 +242,7 @@ void BehaviorGroupBooster::AdjustFlareLists() return; } - if( m_flareCount == 0) + if( m_flareCount == 0 ) { return; } @@ -270,11 +270,13 @@ Vector3 BehaviorGroupBooster::GetOffset() const return m_boosterOffset; } -unsigned int BehaviorGroupBooster::GetAtlasIndex0() const { +unsigned int BehaviorGroupBooster::GetAtlasIndex0() const +{ return m_atlasIndex0; } -unsigned int BehaviorGroupBooster::GetAtlasIndex1() const { +unsigned int BehaviorGroupBooster::GetAtlasIndex1() const +{ return m_atlasIndex1; } @@ -310,7 +312,7 @@ void BehaviorGroupBooster::SetupBoosterEffect( Tr2EffectPtr effect ) Vector4 shapeAtlasSize( float( shapeAtlasHeight ), float( shapeAtlasCount ), 0, 0 ); effect->AddParameterVector4( BlueSharedString( "ShapeAtlasSize" ), &shapeAtlasSize ); effect->AddParameterVector4( BlueSharedString( "BoosterScale" ), &boosterScale ); - + effect->AddResourceTexture2D( BlueSharedString( "ShapeMap" ), "res:/dx9/model/booster/shape01.dds" ); effect->AddResourceTexture2D( BlueSharedString( "GradientMap0" ), "res:/dx9/model/booster/gradient01.dds" ); effect->AddResourceTexture2D( BlueSharedString( "GradientMap1" ), "res:/dx9/model/booster/gradient02.dds" ); @@ -325,9 +327,9 @@ Tr2EffectPtr BehaviorGroupBooster::CreateBoosterEffect( const BlueSharedString& effect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/Booster/DroneBoosterVolumetric.fx" ); effect->SetOption( BlueSharedString( "BOOSTER_LOD" ), lodOption ); - + SetupBoosterEffect( effect ); - + // finish effect and set it effect->EndUpdate(); return effect; @@ -346,7 +348,7 @@ Tr2EffectPtr BehaviorGroupBooster::CreateFlareEffect() return effect; } -void BehaviorGroupBooster::CreateBuffer() +void BehaviorGroupBooster::CreateBuffer() { if( Tr2Renderer::GetShaderModel() >= TR2SM_3_0_HI ) { @@ -398,7 +400,7 @@ Tr2RenderBatch BehaviorGroupBooster::GetBatch( Tr2BufferAL* instanceBuffer, unsi } void BehaviorGroupBooster::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) -{ +{ if( m_ambientFlareEffect != nullptr ) { m_ambientFlareHash = m_ambientFlareEffect->GetHashValue(); @@ -418,7 +420,7 @@ void BehaviorGroupBooster::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr { return; } - + if( !m_haloFlares.empty() && m_haloFlareEffect && m_displayHazeFlare ) { quadRenderer.AddQuads( m_haloFlareHash, &m_haloFlares[0], m_flareCount ); @@ -444,13 +446,13 @@ void BehaviorGroupBooster::AddLight( Tr2LightManager& lightManager, Vector3 posi void BehaviorGroupBooster::AddFlare( const Matrix& agentTransform, float lod, float intensity, unsigned int agentIndex, float shipBoundingSphereRadius, float groupScale ) { - // This is unlikely, but can happen during editing (importing a booster before it has been told how many flares there are) - if( m_flareCount == 0 ) + // This is unlikely, but can happen during editing (importing a booster before it has been told how many flares there are) + if( m_flareCount == 0 ) { return; } - Matrix groupScaleMatrix = ScalingMatrix(groupScale, groupScale, groupScale); + Matrix groupScaleMatrix = ScalingMatrix( groupScale, groupScale, groupScale ); if( m_haloFlareEffect && m_haloFlares.size() == m_flareCount ) { @@ -458,12 +460,12 @@ void BehaviorGroupBooster::AddFlare( const Matrix& agentTransform, float lod, fl float haloModification = ( 1.0f + lod ) * ( 1.0f + lod ) * ( lod - 1.0f ) * ( lod - 1.0f ); haloModification = max( 0.0f, haloModification ); float scaledBrightness = 0.1f + 0.9f * intensity * m_haloFlareBrightness * haloModification; - + // offset the halo towards the center of the ship when we lod out Vector3 modOffset = haloModification * m_haloFlareOffset; auto offset = TranslationMatrix( modOffset ) * groupScaleMatrix; // scale the offset with the group so it moves further out with increasing groupScale - auto haloMatrix = m_haloModifier->ApplyTransform( m_haloMatrix * offset * agentTransform, 0, nullptr ); + auto haloMatrix = m_haloModifier->ApplyTransform( m_haloMatrix * offset * agentTransform, 0, nullptr ); if( m_haloFlareNoiseAmplitude != 0.f ) { @@ -485,9 +487,9 @@ void BehaviorGroupBooster::AddFlare( const Matrix& agentTransform, float lod, fl float scaledBrightness = ( 0.25f + 0.25f * intensity + 0.5f * mod * intensity ) * m_ambientFlareBrightness; Vector3 nearScale = mod * m_ambientFlareScale * groupScale; float farScale = ( 1.0f - mod ) * shipBoundingSphereRadius * groupScale * 2.0f; - + // the further away from the camera, the closer the flare is to the center of the agent - Vector3 modOffset = mod * m_ambientFlareOffset * groupScale; + Vector3 modOffset = mod * m_ambientFlareOffset * groupScale; if( m_ambientFlareNoiseAmplitude != 0.f ) { @@ -495,7 +497,7 @@ void BehaviorGroupBooster::AddFlare( const Matrix& agentTransform, float lod, fl scaledBrightness *= ( ( noise + 1.0f ) / 2.0f ) * m_ambientFlareNoiseAmplitude; } - q.m_brightness[0] = Float_16( scaledBrightness ); + q.m_brightness[0] = Float_16( scaledBrightness ); q.m_parentTransform0 = Vector4( agentTransform._11, agentTransform._21, agentTransform._31, agentTransform._41 ); q.m_parentTransform1 = Vector4( agentTransform._12, agentTransform._22, agentTransform._32, agentTransform._42 ); q.m_parentTransform2 = Vector4( agentTransform._13, agentTransform._23, agentTransform._33, agentTransform._43 ); @@ -514,8 +516,8 @@ void BehaviorGroupBooster::AddFlare( const Matrix& agentTransform, float lod, fl void BehaviorGroupBooster::RenderBoosterDebug( ITr2DebugRenderer2& renderer, Tr2DebugObjectReference owner, const Matrix& agentTransform ) { - auto boosterTransform = TranslationMatrix( m_boosterOffset ); - + auto boosterTransform = TranslationMatrix( m_boosterOffset ); + renderer.DrawCylinder( owner, boosterTransform * agentTransform, diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.h b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.h index e21a1d3a6..1d30dcc1f 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster.h @@ -16,7 +16,7 @@ struct Tr2RenderBatch; // -------------------------------------------------------------------------------------- // Description: // A class that describes look of behavior group boosters -// This is very hardcoded, since we don't support multiple booster types +// This is very hardcoded, since we don't support multiple booster types // -------------------------------------------------------------------------------------- BLUE_CLASS( BehaviorGroupBooster ) : public IInitialize, @@ -32,18 +32,20 @@ BLUE_CLASS( BehaviorGroupBooster ) : struct Quad { - Quad() {} + Quad() + { + } - Quad( const Matrix& parentTransform, const Matrix& localTransform, const Color& color, float brightness ) + Quad( const Matrix& parentTransform, const Matrix& localTransform, const Color& color, float brightness ) { m_parentTransform0 = Vector4( parentTransform._11, parentTransform._21, parentTransform._31, parentTransform._41 ); m_parentTransform1 = Vector4( parentTransform._12, parentTransform._22, parentTransform._32, parentTransform._42 ); m_parentTransform2 = Vector4( parentTransform._13, parentTransform._23, parentTransform._33, parentTransform._43 ); - + m_localTransform0 = Vector4( localTransform._11, localTransform._21, localTransform._31, localTransform._41 ); m_localTransform1 = Vector4( localTransform._12, localTransform._22, localTransform._32, localTransform._42 ); m_localTransform2 = Vector4( localTransform._13, localTransform._23, localTransform._33, localTransform._43 ); - + m_color[0] = Float_16( color.r ); m_color[1] = Float_16( color.g ); m_color[2] = Float_16( color.b ); @@ -73,23 +75,23 @@ BLUE_CLASS( BehaviorGroupBooster ) : void InitializeEffects(); // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; void CreateBuffer(); Tr2EffectPtr GetEffect(); unsigned int GetVertexDeclaration() const; void RebuildFlareBuffer( unsigned int count ); - + Tr2RenderBatch GetBatch( Tr2BufferAL * instanceBuffer, unsigned int startInstance, unsigned int instanceDataStride, unsigned int count ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void AddLight( Tr2LightManager & lightManager, Vector3 position, float radiusModifier, int agentIndex, const Matrix& parentTransform ); void AddFlare( const Matrix& agentTransform, float lod, float intensity, unsigned int agentIndex, float shipBoundingSphereRadius, float groupScale ); - void RenderBoosterDebug( ITr2DebugRenderer2& renderer, Tr2DebugObjectReference owner, const Matrix& transform ); - void RenderLightDebug( ITr2DebugRenderer2& renderer, Tr2DebugObjectReference owner, const Matrix& transform ); + void RenderBoosterDebug( ITr2DebugRenderer2 & renderer, Tr2DebugObjectReference owner, const Matrix& transform ); + void RenderLightDebug( ITr2DebugRenderer2 & renderer, Tr2DebugObjectReference owner, const Matrix& transform ); bool GetDisplay() const; float GetLightSize() const; @@ -108,7 +110,7 @@ BLUE_CLASS( BehaviorGroupBooster ) : void SetupBoosterEffect( Tr2EffectPtr effect ); void SetupQuads(); void AdjustFlareLists(); - + Vector3 m_boosterOffset; float m_lightRadius; Color m_lightColor; @@ -121,7 +123,7 @@ BLUE_CLASS( BehaviorGroupBooster ) : Tr2EffectPtr m_haloFlareEffect; unsigned int m_haloFlareHash; - + Vector3 m_haloFlareOffset; Vector3 m_haloFlareScale; float m_haloFlareBrightness; @@ -131,7 +133,7 @@ BLUE_CLASS( BehaviorGroupBooster ) : uint32_t m_haloFlareNoiseOctaves; EveChildModifierHaloPtr m_haloModifier; Matrix m_haloMatrix; - + Tr2EffectPtr m_ambientFlareEffect; unsigned int m_ambientFlareHash; Vector3 m_ambientFlareOffset; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster_Blue.cpp index ef495eded..391efac45 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroupBooster_Blue.cpp @@ -6,48 +6,46 @@ BLUE_DEFINE( BehaviorGroupBooster ); -const Be::ClassInfo* BehaviorGroupBooster::ExposeToBlue() -{ +const Be::ClassInfo* BehaviorGroupBooster::ExposeToBlue() { EXPOSURE_BEGIN( BehaviorGroupBooster, "" ) MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify) - - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "flareCount", m_flareCount, "How many flares are being rendered", Be::READ ) - - MAP_ATTRIBUTE( "boosterOffset", m_boosterOffset, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "atlasIndex0", m_atlasIndex0, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "atlasIndex1", m_atlasIndex1, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boosterEffect", m_boosterEffect, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "haloFlareEffect", m_haloFlareEffect, "The effect for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "haloFlareOffset", m_haloFlareOffset, "The offset for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "haloFlareScale", m_haloFlareScale, "The scale for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "haloFlareBrightness", m_haloFlareBrightness, "The brightness for the halo flare \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "haloFlareColor", m_haloFlareColor, "The color for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "haloFlareNoiseSpeed", m_haloFlareNoiseSpeed, "The noise speed for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "haloFlareNoiseAmplitude", m_haloFlareNoiseAmplitude, "The noise amplitude for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "haloFlareNoiseOctaves", m_haloFlareNoiseOctaves, "The noise octaves for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "ambientFlareEffect", m_ambientFlareEffect, "The effect for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "ambientFlareOffset", m_ambientFlareOffset, "The offset for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "ambientFlareScale", m_ambientFlareScale, "The scale for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "ambientFlareBrightness", m_ambientFlareBrightness, "The brightness for the ambient flare \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "ambientFlareColor", m_ambientFlareColor, "The color for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "ambientFlareNoiseSpeed", m_ambientFlareNoiseSpeed, "The noise speed for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "ambientFlareNoiseAmplitude", m_ambientFlareNoiseAmplitude, "The noise amplitude for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "ambientFlareNoiseOctaves", m_ambientFlareNoiseOctaves, "The noise octaves for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "lightRadius", m_lightRadius, "The radius of the light. \n:jessica-group: Light", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightColor", m_lightColor, "The color of the light. \n:jessica-group: Light", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "displayBoosters", m_displayBoosters, "Should the boosters be displayed \njessica-group: Debug", Be::READWRITE ) - MAP_ATTRIBUTE( "displayHazeFlare", m_displayHazeFlare, "Should the halo flare be displayed \njessica-group: Debug", Be::READWRITE ) - MAP_ATTRIBUTE( "displayAmbientFlare", m_displayAmbientFlare, "Should the ambient flare be displayed \njessica-group: Debug", Be::READWRITE ) - - MAP_METHOD_AND_WRAP( "InitializeEffects", InitializeEffects, "Initializes effects that have not been set (booster, haze flare and ambient flare)") - - EXPOSURE_END() -}; + MAP_INTERFACE( INotify ) + + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "flareCount", m_flareCount, "How many flares are being rendered", Be::READ ) + + MAP_ATTRIBUTE( "boosterOffset", m_boosterOffset, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "atlasIndex0", m_atlasIndex0, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "atlasIndex1", m_atlasIndex1, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boosterEffect", m_boosterEffect, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "haloFlareEffect", m_haloFlareEffect, "The effect for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloFlareOffset", m_haloFlareOffset, "The offset for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloFlareScale", m_haloFlareScale, "The scale for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloFlareBrightness", m_haloFlareBrightness, "The brightness for the halo flare \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloFlareColor", m_haloFlareColor, "The color for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "haloFlareNoiseSpeed", m_haloFlareNoiseSpeed, "The noise speed for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "haloFlareNoiseAmplitude", m_haloFlareNoiseAmplitude, "The noise amplitude for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "haloFlareNoiseOctaves", m_haloFlareNoiseOctaves, "The noise octaves for the halo flare. \n:jessica-group: Halo Flare", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "ambientFlareEffect", m_ambientFlareEffect, "The effect for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "ambientFlareOffset", m_ambientFlareOffset, "The offset for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "ambientFlareScale", m_ambientFlareScale, "The scale for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "ambientFlareBrightness", m_ambientFlareBrightness, "The brightness for the ambient flare \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "ambientFlareColor", m_ambientFlareColor, "The color for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "ambientFlareNoiseSpeed", m_ambientFlareNoiseSpeed, "The noise speed for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "ambientFlareNoiseAmplitude", m_ambientFlareNoiseAmplitude, "The noise amplitude for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "ambientFlareNoiseOctaves", m_ambientFlareNoiseOctaves, "The noise octaves for the ambient flare. \n:jessica-group: Ambient Flare", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "lightRadius", m_lightRadius, "The radius of the light. \n:jessica-group: Light", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightColor", m_lightColor, "The color of the light. \n:jessica-group: Light", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "displayBoosters", m_displayBoosters, "Should the boosters be displayed \njessica-group: Debug", Be::READWRITE ) + MAP_ATTRIBUTE( "displayHazeFlare", m_displayHazeFlare, "Should the halo flare be displayed \njessica-group: Debug", Be::READWRITE ) + MAP_ATTRIBUTE( "displayAmbientFlare", m_displayAmbientFlare, "Should the ambient flare be displayed \njessica-group: Debug", Be::READWRITE ) + + MAP_METHOD_AND_WRAP( "InitializeEffects", InitializeEffects, "Initializes effects that have not been set (booster, haze flare and ambient flare)" ) + + EXPOSURE_END() +}; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup_Blue.cpp index 56acc6b8d..53e54f12e 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/BehaviorGroup_Blue.cpp @@ -31,15 +31,15 @@ const Be::ClassInfo* BehaviorGroup::ExposeToBlue() MAP_ATTRIBUTE( "blendScreenSizeMin", m_blendScreenSizeMin, "Agent will be drawn as a sprite if screen-size is less than this value.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "blendScreenSizeMax", m_blendScreenSizeMax, "Agent will be drawn as a mesh if screeen-size is greater than this value.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphereRadius, "The radius of the bounding sphere, applied to each agent.", Be::READWRITE | Be::PERSIST ) - + MAP_METHOD_AND_WRAP( "AddAgent", AddAgent, "Adds a drone to the swarm \n:jessica-placement: TOOLBAR\n:jessica-icon: far-drone-alt\n" ) MAP_METHOD_AND_WRAP( "RemoveAgent", RemoveAgent, "removes a random drone from the swarm \n:jessica-placement: TOOLBAR\n:jessica-icon: far-dumpster\n" ) MAP_METHOD_AND_WRAP( "SetCount", SetCount, "Specify a desired number of agents for the system \n:param count: number of agents\n:jessica-placement: TOOLBAR\n:jessica-icon: far-ball-pile\n" ) MAP_METHOD_AND_WRAP( "CreateAgentTree", CreateAgentTree, "a temp DEV toggle \n:jessica-placement: TOOLBAR\n:jessica-icon: fab-dev\n" ) - + MAP_ATTRIBUTE( "debugMode", m_debugMode, "Toggle for debugging intensity/lod \njessica-group: Debug", Be::READWRITE ) MAP_ATTRIBUTE( "debugLodLevel", m_debugLodLevel, "LOD level override (0 - 1) \njessica-group: Debug", Be::READWRITE ) MAP_ATTRIBUTE( "debugIntensity", m_debugIntensity, "Intensity override (0 - 1) \njessica-group: Debug", Be::READWRITE ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance.h b/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance.h index 656187a7d..209fad875 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance.h @@ -17,10 +17,9 @@ BLUE_CLASS( CollisionAvoidance ) : CollisionAvoidance( IRoot* lockobj = nullptr ); ~CollisionAvoidance(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); int GetProcessPriority(); private: diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance_Blue.cpp index 7f632771e..9797bb924 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/CollisionAvoidance_Blue.cpp @@ -13,8 +13,7 @@ const Be::ClassInfo* CollisionAvoidance::ExposeToBlue() MAP_INTERFACE( CollisionAvoidance ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "exclusionVolumes", m_exclusionVolumes, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "avoidanceScalar", m_collisionAvoidanceScalar, "", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAgent.h b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAgent.h index 460e8ba3c..b30d20711 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAgent.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAgent.h @@ -7,7 +7,7 @@ #include "include/TriMath.h" struct DroneAgent -{ +{ DroneAgent() : rotation( 0, 0, 0, 1 ), position( 0, 0, 0 ), @@ -23,11 +23,12 @@ struct DroneAgent fxStartTime( -1 ), lastTransform( IdentityMatrix() ), // LOD - xfade( 0.f ), - screenSize( 0.f ), + xfade( 0.f ), + screenSize( 0.f ), isVisible( false ), closestAgentInGroup( nullptr ) - {} + { + } DroneAgent* closestAgentInGroup; Quaternion rotation; Vector3 position; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.cpp index 003787ed1..e232a5c2a 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.cpp @@ -33,7 +33,7 @@ std::vector DroneAvoidance::CalculateBehavior( std::vector& { return returnForces; } - + int c = 0; if( m_frameCounter == 0 ) { @@ -74,7 +74,7 @@ std::vector DroneAvoidance::CalculateBehavior( std::vector& avoidanceDirection += agent->position - ( *a )->position; } - + if( avoidanceDirection == Vector3( 0, 0, 0 ) ) { m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.h b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.h index af528fb8e..e0fe81187 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance.h @@ -15,10 +15,9 @@ BLUE_CLASS( DroneAvoidance ) : DroneAvoidance( IRoot* lockobj = nullptr ); ~DroneAvoidance(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); float GetBehaviorSearchRadius(); virtual int GetProcessPriority(); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance_Blue.cpp index b90d012b4..22d729494 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/DroneAvoidance_Blue.cpp @@ -13,13 +13,12 @@ const Be::ClassInfo* DroneAvoidance::ExposeToBlue() MAP_INTERFACE( DroneAvoidance ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "behaviorWeight", m_behaviorWeight, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "visionRange", m_visionRange, "How far the drone looks for it's buddies", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "framesBetweenUpdates", m_framesBetweenUpdates, "updateFrequency to lessen the load", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.cpp index adffde9ac..20f7636ec 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.cpp @@ -3,11 +3,11 @@ #include "StdAfx.h" #include "EveKDdroneManagementTree.h" -EveKDdroneManagementTree::EveKDdroneManagementTree( IRoot* lockobj ): - m_debugSquareSize(0), - m_updateTimeCounter(0), - m_timeBetweenUpdate(1), //update every '1' seconds - m_maxFoundPerAgent(5) +EveKDdroneManagementTree::EveKDdroneManagementTree( IRoot* lockobj ) : + m_debugSquareSize( 0 ), + m_updateTimeCounter( 0 ), + m_timeBetweenUpdate( 1 ), //update every '1' seconds + m_maxFoundPerAgent( 5 ) { } @@ -15,7 +15,7 @@ EveKDdroneManagementTree::~EveKDdroneManagementTree() { } -void EveKDdroneManagementTree::CreateTree(std::vector& agents, size_t NumberOfBehaviors ) +void EveKDdroneManagementTree::CreateTree( std::vector& agents, size_t NumberOfBehaviors ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -25,17 +25,17 @@ void EveKDdroneManagementTree::CreateTree(std::vector& agents, size_ } ChangeAgentsIntoAgentRefs( agents ); - AgentRef tree = *SplitSort( 0, static_cast< int > ( agents.size() ) - 1, Z); + AgentRef tree = *SplitSort( 0, static_cast( agents.size() ) - 1, Z ); m_tree = tree; m_groupSearchReturnInfoBlock.clear(); - for ( int j = 0; j < static_cast< int >(NumberOfBehaviors); j++ ) + for( int j = 0; j < static_cast( NumberOfBehaviors ); j++ ) { - std::vector < std::vector > perAgentData; - for ( unsigned int i = 0; i < agents.size(); i++ ) + std::vector> perAgentData; + for( unsigned int i = 0; i < agents.size(); i++ ) { - perAgentData.push_back( std::vector () ); + perAgentData.push_back( std::vector() ); } m_groupSearchReturnInfoBlock.push_back( perAgentData ); } @@ -43,7 +43,7 @@ void EveKDdroneManagementTree::CreateTree(std::vector& agents, size_ void EveKDdroneManagementTree::UpdateTree( const float dt ) { - if ( m_timeBetweenUpdate != -1 && m_updateTimeCounter >= m_timeBetweenUpdate ) + if( m_timeBetweenUpdate != -1 && m_updateTimeCounter >= m_timeBetweenUpdate ) { m_updateTimeCounter = 0; m_tree = *CompareNodeToChildren( &m_tree ); @@ -57,21 +57,20 @@ void EveKDdroneManagementTree::UpdateTree( const float dt ) // checking axis for if there needs to be a re-construction EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::CompareNodeToChildren( AgentRef* node ) { - if ( node == nullptr ) + if( node == nullptr ) { return nullptr; } - if ( node->left == nullptr && node->right == nullptr ) + if( node->left == nullptr && node->right == nullptr ) { return node; } - switch ( node->planeType ) + switch( node->planeType ) { case X: - if (IsBiggestOnAxis(node->left, node->agent->position.x, X) && IsSmallestOnAxis( - node->right, node->agent->position.x, X)) + if( IsBiggestOnAxis( node->left, node->agent->position.x, X ) && IsSmallestOnAxis( node->right, node->agent->position.x, X ) ) { node->left = CompareNodeToChildren( node->left ); node->right = CompareNodeToChildren( node->right ); @@ -83,8 +82,7 @@ EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::CompareNodeToChild } break; case Y: - if ( IsBiggestOnAxis( node->left, node->agent->position.y, Y ) && IsSmallestOnAxis( - node->right, node->agent->position.y, Y ) ) + if( IsBiggestOnAxis( node->left, node->agent->position.y, Y ) && IsSmallestOnAxis( node->right, node->agent->position.y, Y ) ) { node->left = CompareNodeToChildren( node->left ); node->right = CompareNodeToChildren( node->right ); @@ -96,8 +94,7 @@ EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::CompareNodeToChild } break; case Z: - if ( IsBiggestOnAxis( node->left, node->agent->position.z, Z ) && IsSmallestOnAxis( - node->right, node->agent->position.z, Z ) ) + if( IsBiggestOnAxis( node->left, node->agent->position.z, Z ) && IsSmallestOnAxis( node->right, node->agent->position.z, Z ) ) { node->left = CompareNodeToChildren( node->left ); node->right = CompareNodeToChildren( node->right ); @@ -114,45 +111,42 @@ EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::CompareNodeToChild bool EveKDdroneManagementTree::IsBiggestOnAxis( AgentRef* node, float n, PlaneType pt ) { - if ( node == nullptr ) + if( node == nullptr ) { return true; } - switch ( node->planeType ) + switch( node->planeType ) { case X: // if this is an X-split axis we only look at the bigger side - if( pt == X) + if( pt == X ) { return n >= node->agent->position.x && IsBiggestOnAxis( node->right, n, X ); } else { - return n >= node->agent->position.x && IsBiggestOnAxis( node->left, n, X ) - && IsBiggestOnAxis( node->right, n, X ); + return n >= node->agent->position.x && IsBiggestOnAxis( node->left, n, X ) && IsBiggestOnAxis( node->right, n, X ); } break; case Y: - if ( pt == Y ) + if( pt == Y ) { return n >= node->agent->position.y && IsBiggestOnAxis( node->right, n, Y ); } else { - return n >= node->agent->position.y && IsBiggestOnAxis( node->left, n, Y ) - && IsBiggestOnAxis( node->right, n, Y ); + return n >= node->agent->position.y && IsBiggestOnAxis( node->left, n, Y ) && IsBiggestOnAxis( node->right, n, Y ); } break; case Z: - if ( pt == Z ) + if( pt == Z ) { return n >= node->agent->position.z && IsBiggestOnAxis( node->right, n, Z ); } else { - return n >= node->agent->position.z && IsBiggestOnAxis( node->left, n, Z ) - && IsBiggestOnAxis( node->right, n, Z ); + return n >= node->agent->position.z && IsBiggestOnAxis( node->left, n, Z ) && IsBiggestOnAxis( node->right, n, Z ); } break; } @@ -162,45 +156,42 @@ bool EveKDdroneManagementTree::IsBiggestOnAxis( AgentRef* node, float n, PlaneTy bool EveKDdroneManagementTree::IsSmallestOnAxis( AgentRef* node, const float n, PlaneType pt ) { - if ( node == nullptr ) + if( node == nullptr ) { return true; } - switch ( node->planeType ) + switch( node->planeType ) { case X: // if this is an X-split axis we only look at the smaller side - if ( pt == X ) + if( pt == X ) { return n <= node->agent->position.x && IsSmallestOnAxis( node->left, n, X ); } else { - return n <= node->agent->position.x && IsSmallestOnAxis( node->left, n, X ) - && IsSmallestOnAxis( node->right, n, X ); + return n <= node->agent->position.x && IsSmallestOnAxis( node->left, n, X ) && IsSmallestOnAxis( node->right, n, X ); } break; case Y: - if ( pt == Y ) + if( pt == Y ) { return n <= node->agent->position.y && IsSmallestOnAxis( node->left, n, Y ); } else { - return n <= node->agent->position.y && IsSmallestOnAxis( node->left, n, Y ) - && IsSmallestOnAxis( node->right, n, Y ); + return n <= node->agent->position.y && IsSmallestOnAxis( node->left, n, Y ) && IsSmallestOnAxis( node->right, n, Y ); } break; case Z: - if ( pt == Z ) + if( pt == Z ) { return n <= node->agent->position.z && IsSmallestOnAxis( node->left, n, Z ); } else { - return n <= node->agent->position.z && IsSmallestOnAxis( node->left, n, Z ) - && IsSmallestOnAxis( node->right, n, Z ); + return n <= node->agent->position.z && IsSmallestOnAxis( node->left, n, Z ) && IsSmallestOnAxis( node->right, n, Z ); } break; } @@ -214,8 +205,8 @@ EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::SplitSort( int b, { m_agentRefs[b].b = b; m_agentRefs[e].e = e; - m_agentRefs[ b ].left = nullptr; - m_agentRefs[ b ].right = nullptr; + m_agentRefs[b].left = nullptr; + m_agentRefs[b].right = nullptr; return &m_agentRefs[b]; } @@ -226,14 +217,14 @@ EveKDdroneManagementTree::AgentRef* EveKDdroneManagementTree::SplitSort( int b, SortByAxis( m_agentRefs, b, e + 1, pt ); - int m = b + ( (e - b) / 2 ); // middlePoint + int m = b + ( ( e - b ) / 2 ); // middlePoint - m_agentRefs[ m ].b = b; - m_agentRefs[ m ].e = e; + m_agentRefs[m].b = b; + m_agentRefs[m].e = e; pt = FindNextSplitAxis( pt ); - m_agentRefs[ m ].left = SplitSort( b, m - 1,pt); - m_agentRefs[ m ].right = SplitSort( m + 1, e, pt); + m_agentRefs[m].left = SplitSort( b, m - 1, pt ); + m_agentRefs[m].right = SplitSort( m + 1, e, pt ); return &m_agentRefs[m]; } @@ -242,21 +233,21 @@ void EveKDdroneManagementTree::ChangeAgentsIntoAgentRefs( std::vector& EveKDdroneManagementTree::SortByAxis( std::vector& agents, int - b, int e, PlaneType pt ) const +std::vector& EveKDdroneManagementTree::SortByAxis( std::vector& agents, int b, int e, PlaneType pt ) const { - for ( auto ag = agents.begin() + b; ag != agents.begin() + e; ++ag ) + for( auto ag = agents.begin() + b; ag != agents.begin() + e; ++ag ) { ag->planeType = pt; } @@ -285,7 +275,7 @@ std::vector& EveKDdroneManagementTree::SortB // but this one is a standard tree search DroneAgent* EveKDdroneManagementTree::FindClosestAgent( const Vector3 pos ) { - if ( m_tree.agent == nullptr ) + if( m_tree.agent == nullptr ) { return nullptr; } @@ -300,29 +290,29 @@ DroneAgent* EveKDdroneManagementTree::FindClosestAgent( const Vector3 pos ) void EveKDdroneManagementTree::FindClosestAgentRecursive( const Vector3& pos, AgentRef* currentNode, closestDrone& agent ) const { - if ( currentNode == nullptr ) + if( currentNode == nullptr ) { return; } float distToPoint = Length( currentNode->agent->position - pos ); - - if ( agent.rangeBetween > distToPoint ) + + if( agent.rangeBetween > distToPoint ) { agent.rangeBetween = distToPoint; agent.agent = currentNode->agent; } // Dig Through tree disregarding spaces on the other side of the splitting hyperplane - switch ( currentNode->planeType ) + switch( currentNode->planeType ) { case X: - if ( currentNode->agent->position.x < pos.x ) + if( currentNode->agent->position.x < pos.x ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); // now when going back up through the recursion we have a best range to compare to - if ( currentNode->agent->position.x + agent.rangeBetween > pos.x ) + if( currentNode->agent->position.x + agent.rangeBetween > pos.x ) { FindClosestAgentRecursive( pos, currentNode->left, agent ); } @@ -331,18 +321,18 @@ void EveKDdroneManagementTree::FindClosestAgentRecursive( const Vector3& pos, Ag { FindClosestAgentRecursive( pos, currentNode->left, agent ); - if ( currentNode->agent->position.x - agent.rangeBetween < pos.x ) + if( currentNode->agent->position.x - agent.rangeBetween < pos.x ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); } } break; case Y: - if ( currentNode->agent->position.y < pos.y ) + if( currentNode->agent->position.y < pos.y ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); - if ( currentNode->agent->position.y + agent.rangeBetween > pos.y ) + if( currentNode->agent->position.y + agent.rangeBetween > pos.y ) { FindClosestAgentRecursive( pos, currentNode->left, agent ); } @@ -351,18 +341,18 @@ void EveKDdroneManagementTree::FindClosestAgentRecursive( const Vector3& pos, Ag { FindClosestAgentRecursive( pos, currentNode->left, agent ); - if ( currentNode->agent->position.y - agent.rangeBetween < pos.y ) + if( currentNode->agent->position.y - agent.rangeBetween < pos.y ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); } } break; case Z: - if ( currentNode->agent->position.z < pos.z ) + if( currentNode->agent->position.z < pos.z ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); - if ( currentNode->agent->position.z + agent.rangeBetween > pos.z ) + if( currentNode->agent->position.z + agent.rangeBetween > pos.z ) { FindClosestAgentRecursive( pos, currentNode->left, agent ); } @@ -371,7 +361,7 @@ void EveKDdroneManagementTree::FindClosestAgentRecursive( const Vector3& pos, Ag { FindClosestAgentRecursive( pos, currentNode->left, agent ); - if ( currentNode->agent->position.z - agent.rangeBetween < pos.z ) + if( currentNode->agent->position.z - agent.rangeBetween < pos.z ) { FindClosestAgentRecursive( pos, currentNode->right, agent ); } @@ -383,21 +373,22 @@ void EveKDdroneManagementTree::FindClosestAgentRecursive( const Vector3& pos, Ag // This is a very specialized function optimized for searching for multiple ranges for multiple agents at the same time // Use: vvv = FindDronesInRange( (list of agents), (list of visionRanges/search-radiuses), (their own collision size / bounding sphere )); -// After: vvv is an orginized tri-dementional list where the 1st index is the Behavior's index, -// 2nd the agent's index and the 3rd is the list of found agents in range (up to m_maxFoundPerAgent) +// After: vvv is an orginized tri-dementional list where the 1st index is the Behavior's index, +// 2nd the agent's index and the 3rd is the list of found agents in range (up to m_maxFoundPerAgent) const std::vector>>* EveKDdroneManagementTree::FindDronesInRange( std::vector& agents, - std::vector& ranges, const float& BehaviorGroupBoundingSphereRadius) + std::vector& ranges, + const float& BehaviorGroupBoundingSphereRadius ) { CCP_STATS_ZONE( __FUNCTION__ ); std::vector searchRanges; int behaviorNumber = 0; - for ( auto r = ranges.begin(); r != ranges.end(); ++r ) + for( auto r = ranges.begin(); r != ranges.end(); ++r ) { SearchRange br; br.behaviorNbr = behaviorNumber; behaviorNumber++; - if ( *r == -1 ) + if( *r == -1 ) { br.radius = -1; } @@ -410,7 +401,7 @@ const std::vector>>* EveKDdroneManagementTr std::sort( searchRanges.begin(), searchRanges.end(), compareRef() ); - + if( !m_groupSearchReturnInfoBlock.empty() ) { for( int j = 0; j < behaviorNumber; ++j ) @@ -422,12 +413,12 @@ const std::vector>>* EveKDdroneManagementTr } } - if ( searchRanges.empty() ) + if( searchRanges.empty() ) { return &m_groupSearchReturnInfoBlock; } - if ( searchRanges.begin()->radius == -1 ) + if( searchRanges.begin()->radius == -1 ) { return &m_groupSearchReturnInfoBlock; } @@ -438,11 +429,10 @@ const std::vector>>* EveKDdroneManagementTr return &m_groupSearchReturnInfoBlock; } -void EveKDdroneManagementTree::SearchThroughTree( std::vector>>& closeAgents, AgentRef* node, - std::vector& agents, const std::vector& ranges, int& activeRange ) const +void EveKDdroneManagementTree::SearchThroughTree( std::vector>>& closeAgents, AgentRef* node, std::vector& agents, const std::vector& ranges, int& activeRange ) const { int c = 0; - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, ++c ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, ++c ) { activeRange = 0; SearchThroughTreeHelperFunction( closeAgents, node, *agent, ranges, activeRange, c ); @@ -451,35 +441,39 @@ void EveKDdroneManagementTree::SearchThroughTree( std::vector>>& closeAgents, - AgentRef* node, DroneAgent& agent, const std::vector& ranges, int& activeRange, int& c ) const + AgentRef* node, + DroneAgent& agent, + const std::vector& ranges, + int& activeRange, + int& c ) const { - if ( node == nullptr ) + if( node == nullptr ) { return; } - if ( activeRange > ( static_cast< int >( ranges.size() ) - 1 ) ) + if( activeRange > ( static_cast( ranges.size() ) - 1 ) ) { return; } - if ( ranges[ activeRange ].radius == -1 ) + if( ranges[activeRange].radius == -1 ) { return; } float dist = LengthSq( node->agent->position - agent.position ); - float range = ranges[ activeRange ].radius; + float range = ranges[activeRange].radius; - if ( dist < range * range ) + if( dist < range * range ) { AddAgentToSearchLists( closeAgents, node, dist, ranges, activeRange, c ); - if ( closeAgents[ ranges[ activeRange ].behaviorNbr ][ c ].size() < m_maxFoundPerAgent ) + if( closeAgents[ranges[activeRange].behaviorNbr][c].size() < m_maxFoundPerAgent ) { AddAgentToSearchLists( closeAgents, node, dist, ranges, activeRange, c ); } - else if ( closeAgents[ ranges[ activeRange ].behaviorNbr ][ c ].size() == m_maxFoundPerAgent ) + else if( closeAgents[ranges[activeRange].behaviorNbr][c].size() == m_maxFoundPerAgent ) { AddAgentToSearchLists( closeAgents, node, dist, ranges, activeRange, c ); activeRange++; @@ -487,34 +481,34 @@ void EveKDdroneManagementTree::SearchThroughTreeHelperFunction( std::vectorplaneType ) + switch( node->planeType ) { case X: - if ( node->agent->position.x - agent.position.x <= range ) + if( node->agent->position.x - agent.position.x <= range ) { SearchThroughTreeHelperFunction( closeAgents, node->right, agent, ranges, activeRange, c ); } - if ( node->agent->position.x - agent.position.x >= range ) + if( node->agent->position.x - agent.position.x >= range ) { SearchThroughTreeHelperFunction( closeAgents, node->left, agent, ranges, activeRange, c ); } break; case Y: - if ( node->agent->position.y - agent.position.y <= range ) + if( node->agent->position.y - agent.position.y <= range ) { SearchThroughTreeHelperFunction( closeAgents, node->right, agent, ranges, activeRange, c ); } - if ( node->agent->position.y - agent.position.y >= range ) + if( node->agent->position.y - agent.position.y >= range ) { SearchThroughTreeHelperFunction( closeAgents, node->left, agent, ranges, activeRange, c ); } break; case Z: - if ( node->agent->position.z - agent.position.z <= range ) + if( node->agent->position.z - agent.position.z <= range ) { SearchThroughTreeHelperFunction( closeAgents, node->right, agent, ranges, activeRange, c ); } - if ( node->agent->position.z - agent.position.z >= range ) + if( node->agent->position.z - agent.position.z >= range ) { SearchThroughTreeHelperFunction( closeAgents, node->left, agent, ranges, activeRange, c ); } @@ -522,14 +516,13 @@ void EveKDdroneManagementTree::SearchThroughTreeHelperFunction( std::vector>>& closeAgents, AgentRef* node, - float dist, const std::vector& ranges , int activeRange, int agentNbr ) +void EveKDdroneManagementTree::AddAgentToSearchLists( std::vector>>& closeAgents, AgentRef* node, float dist, const std::vector& ranges, int activeRange, int agentNbr ) { - for ( auto r = ranges.begin() + activeRange; r != ranges.end(); ++r ) + for( auto r = ranges.begin() + activeRange; r != ranges.end(); ++r ) { if( dist < r->radius * r->radius ) { - closeAgents[ r->behaviorNbr ][agentNbr].push_back( node->agent ); + closeAgents[r->behaviorNbr][agentNbr].push_back( node->agent ); } else { @@ -548,8 +541,7 @@ void EveKDdroneManagementTree::RenderDebugInfo( ITr2DebugRenderer2& renderer, Ma DrawDebugTree( renderer, &m_tree, debugSquareCorner1, debugSquareCorner2, pwt ); } -void EveKDdroneManagementTree::DrawDebugTree( ITr2DebugRenderer2& renderer, AgentRef* tree, Vector3& debugSquareCorner1, - Vector3& debugSquareCorner2, Vector3& pwt ) +void EveKDdroneManagementTree::DrawDebugTree( ITr2DebugRenderer2& renderer, AgentRef* tree, Vector3& debugSquareCorner1, Vector3& debugSquareCorner2, Vector3& pwt ) { if( tree == nullptr ) { @@ -564,7 +556,7 @@ void EveKDdroneManagementTree::DrawDebugTree( ITr2DebugRenderer2& renderer, Agen Vector3 newCorner1; Vector3 newCorner2; - switch ( (tree)->planeType ) + switch( ( tree )->planeType ) { case X: newCorner1 = Vector3( ( tree )->agent->position.x + .1f, debugSquareCorner1.y, debugSquareCorner1.z ); @@ -591,15 +583,15 @@ void EveKDdroneManagementTree::DrawDebugTree( ITr2DebugRenderer2& renderer, Agen DrawDebugTree( renderer, tree->right, debugSquareCorner1, newCorner2, pwt ); break; } - m_debugSquareSize = max(max(max(m_debugSquareSize, 1.5f * abs(tree->agent->position.x) ), - 1.5f * abs(tree->agent->position.y) ),1.5f * abs(tree->agent->position.z) ); + m_debugSquareSize = max( max( max( m_debugSquareSize, 1.5f * abs( tree->agent->position.x ) ), + 1.5f * abs( tree->agent->position.y ) ), + 1.5f * abs( tree->agent->position.z ) ); } -void EveKDdroneManagementTree::DrawSquareInnerLines( ITr2DebugRenderer2& renderer, Vector3& agentPos, Vector3& P1, - Vector3& P2, Color C, PlaneType pt, Vector3& pwt ) +void EveKDdroneManagementTree::DrawSquareInnerLines( ITr2DebugRenderer2& renderer, Vector3& agentPos, Vector3& P1, Vector3& P2, Color C, PlaneType pt, Vector3& pwt ) { - - switch ( pt ) + + switch( pt ) { case X: renderer.DrawLine( nullptr, agentPos + pwt, P1 + pwt, C ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.h b/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.h index 5f7142153..a2fe3c115 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/EveKDdroneManagementTree.h @@ -8,7 +8,8 @@ #include "DroneAgent.h" #include -BLUE_CLASS(EveKDdroneManagementTree): public IRoot +BLUE_CLASS( EveKDdroneManagementTree ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -17,8 +18,8 @@ BLUE_CLASS(EveKDdroneManagementTree): public IRoot void UpdateTree( const float dt ); DroneAgent* FindClosestAgent( const Vector3 pos ); - void CreateTree(std::vector& agents, size_t BNbr); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, Matrix& parentWorldLocation ); + void CreateTree( std::vector & agents, size_t BNbr ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, Matrix & parentWorldLocation ); const std::vector>>* FindDronesInRange( std::vector & agents, std::vector & ranges, const float& BehaviorGroupBoundingSphereRadius ); @@ -74,7 +75,7 @@ BLUE_CLASS(EveKDdroneManagementTree): public IRoot { bool operator()( const AgentRef& lhs, const AgentRef& rhs ) const { - return lhs.agent->position[ rhs.planeType ] < rhs.agent->position[ rhs.planeType ]; + return lhs.agent->position[rhs.planeType] < rhs.agent->position[rhs.planeType]; } bool operator()( const SearchRange& lhs, const SearchRange& rhs ) const @@ -84,32 +85,28 @@ BLUE_CLASS(EveKDdroneManagementTree): public IRoot }; PlaneType FindNextSplitAxis( PlaneType pt ); - AgentRef* CompareNodeToChildren(AgentRef* node ); + AgentRef* CompareNodeToChildren( AgentRef * node ); AgentRef* SplitSort( int b, int e, PlaneType pt ); - bool IsBiggestOnAxis( AgentRef* node, float n, PlaneType pt ); - bool IsSmallestOnAxis( AgentRef* node, float n, PlaneType pt ); - void ChangeAgentsIntoAgentRefs( std::vector& agents ); + bool IsBiggestOnAxis( AgentRef * node, float n, PlaneType pt ); + bool IsSmallestOnAxis( AgentRef * node, float n, PlaneType pt ); + void ChangeAgentsIntoAgentRefs( std::vector & agents ); void FindClosestAgentRecursive( const Vector3& pos, AgentRef* currentNode, closestDrone& agent ) const; - std::vector& SortByAxis( std::vector& agents, int b, int e, PlaneType pt ) const; - void SearchThroughTree( std::vector>> & closeAgents, AgentRef * node, std::vector & agents, const std::vector & ranges, int& activeRange ) const; - static void AddAgentToSearchLists(std::vector>>& closeAgents, AgentRef* node, float dist, const std::vector< - SearchRange>& ranges, int activeRange, int agentNbr); - void SearchThroughTreeHelperFunction(std::vector>>& closeAgents, AgentRef* node, DroneAgent& agent, const std::vector< - SearchRange>& ranges, int& activeRange, int& c) const; - + std::vector& SortByAxis( std::vector & agents, int b, int e, PlaneType pt ) const; + void SearchThroughTree( std::vector>> & closeAgents, AgentRef * node, std::vector & agents, const std::vector& ranges, int& activeRange ) const; + static void AddAgentToSearchLists( std::vector>> & closeAgents, AgentRef * node, float dist, const std::vector& ranges, int activeRange, int agentNbr ); + void SearchThroughTreeHelperFunction( std::vector>> & closeAgents, AgentRef * node, DroneAgent & agent, const std::vector& ranges, int& activeRange, int& c ) const; + // debug - void DrawDebugTree( ITr2DebugRenderer2& renderer, AgentRef* tree, Vector3& debugSquareCorner1, Vector3& debugSquareCorner2, Vector3& pwt ); - void DrawSquareInnerLines( ITr2DebugRenderer2& renderer, Vector3& agentPos, Vector3& P1, Vector3& P2, Color C, PlaneType pt, Vector3& pwt ); + void DrawDebugTree( ITr2DebugRenderer2 & renderer, AgentRef * tree, Vector3 & debugSquareCorner1, Vector3 & debugSquareCorner2, Vector3 & pwt ); + void DrawSquareInnerLines( ITr2DebugRenderer2 & renderer, Vector3 & agentPos, Vector3 & P1, Vector3 & P2, Color C, PlaneType pt, Vector3 & pwt ); AgentRef m_tree; float m_debugSquareSize; float m_updateTimeCounter; size_t m_maxFoundPerAgent; float m_timeBetweenUpdate; - std::vector< AgentRef > m_agentRefs; - std::vector< std::vector < std::vector >> m_groupSearchReturnInfoBlock; - - + std::vector m_agentRefs; + std::vector>> m_groupSearchReturnInfoBlock; }; TYPEDEF_BLUECLASS( EveKDdroneManagementTree ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.cpp index 863eb53fe..278b44943 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.cpp @@ -36,26 +36,26 @@ int FollowASpline::GetProcessPriority() void FollowASpline::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) { - if ( theList == &m_splineTunnels ) + if( theList == &m_splineTunnels ) { - switch ( event & BELIST_EVENTMASK ) + switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if ( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &FollowASpline::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xff5555aa ); } break; case BELIST_REMOVED: - if ( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &FollowASpline::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xff5555aa ); } break; case BELIST_LOADFINISHED: - if ( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &FollowASpline::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xff5555aa ); @@ -70,7 +70,7 @@ void FollowASpline::OnListModified( long event, ssize_t key, ssize_t key2, IRoot float FollowASpline::ProcessTunnelEntrances( DroneAgent& agent, const std::vector& tunnels, FollowASplineData* data ) { // not associated with a tunnel - for ( auto tunnel = tunnels.begin(); tunnel != tunnels.end(); ++tunnel ) + for( auto tunnel = tunnels.begin(); tunnel != tunnels.end(); ++tunnel ) { auto t = ( *tunnel ); @@ -79,16 +79,16 @@ float FollowASpline::ProcessTunnelEntrances( DroneAgent& agent, const std::vecto return 0; } - Vector3 dist = t->splinePoints[ 0 ].pos - agent.position; + Vector3 dist = t->splinePoints[0].pos - agent.position; float length = Length( dist ); - if ( length < t->pointOfNoReturnSize ) + if( length < t->pointOfNoReturnSize ) { data->tunnelLock = t->tunnelID; data->tunnelPoint = 0; } - else if ( length < t->pullSize ) + else if( length < t->pullSize ) { - if ( t->pullSize == t->pointOfNoReturnSize ) + if( t->pullSize == t->pointOfNoReturnSize ) { continue; } @@ -104,10 +104,9 @@ float FollowASpline::ProcessTunnelEntrances( DroneAgent& agent, const std::vecto } -bool FollowASpline::ProcessAssignedTunnel(DroneAgent& agent, const std::vector& tunnels, - BehaviorGroup& group, FollowASplineData* data) +bool FollowASpline::ProcessAssignedTunnel( DroneAgent& agent, const std::vector& tunnels, BehaviorGroup& group, FollowASplineData* data ) { - if( data->tunnelLock > static_cast< int >(tunnels.size())) + if( data->tunnelLock > static_cast( tunnels.size() ) ) { return false; } @@ -115,22 +114,22 @@ bool FollowASpline::ProcessAssignedTunnel(DroneAgent& agent, const std::vectortunnelLock ); const auto pID = data->tunnelPoint; // Point ID - Vector3 targetVector = t->splinePoints[ pID ].pos - agent.position; + Vector3 targetVector = t->splinePoints[pID].pos - agent.position; Vector3 vectorBetween( 0, 0, 0 ); - if ( t->splinePoints[ pID ] == ( *t->splinePoints.begin() ) ) + if( t->splinePoints[pID] == ( *t->splinePoints.begin() ) ) { - vectorBetween = t->splinePoints[ pID ].rot; + vectorBetween = t->splinePoints[pID].rot; } else { - vectorBetween = t->splinePoints[ pID - 1 ].rot; + vectorBetween = t->splinePoints[pID - 1].rot; } - const float lengthBetweenPoints = Length(vectorBetween); + const float lengthBetweenPoints = Length( vectorBetween ); if( 0 != lengthBetweenPoints ) - { + { // an offset is added to the target point so that they don't all follow the same line const float dotProd = Dot( targetVector, vectorBetween ); const Vector3 vectorProj = ( dotProd / ( lengthBetweenPoints * lengthBetweenPoints ) ) * vectorBetween; @@ -139,14 +138,14 @@ bool FollowASpline::ProcessAssignedTunnel(DroneAgent& agent, const std::vectorsplinePoints[ pID ] == ( *t->splinePoints.end() ) ) + + if( t->splinePoints[pID] == ( *t->splinePoints.end() ) ) { - m_desiredVector = t->splinePoints[ pID ].rot; + m_desiredVector = t->splinePoints[pID].rot; // the Dot product is positive if the agent is facing the target point - if ( Dot( targetVector, Vector3( agent.rotation ) ) < 0 ) + if( Dot( targetVector, Vector3( agent.rotation ) ) < 0 ) { data->tunnelLock = -1; data->tunnelPoint = 0; @@ -159,27 +158,27 @@ bool FollowASpline::ProcessAssignedTunnel(DroneAgent& agent, const std::vectorsplinePoints[ pID ].rot + targetVector ); - if ( Dot( Normalize( targetVector ), Normalize( m_desiredVector ) ) < m_cornerSmoothener ) + m_desiredVector = m_cornerSmoothener * ( 1 - blendingMod ) * Normalize( targetVector ) + + ( 1 - m_cornerSmoothener ) * blendingMod * Normalize( t->splinePoints[pID].rot + targetVector ); + if( Dot( Normalize( targetVector ), Normalize( m_desiredVector ) ) < m_cornerSmoothener ) { m_desiredVector = targetVector; } - if ((lengthFromShip - group.GetBoundingSphereRadius()) < (t->cylWidth)/1.5) + if( ( lengthFromShip - group.GetBoundingSphereRadius() ) < ( t->cylWidth ) / 1.5 ) { data->tunnelPoint++; return true; } //rework into cylinder collision - if ( lengthFromShip > ( group.GetBoundingSphereRadius() + lengthBetweenPoints * 1.5) && Dot( targetVector, vectorBetween ) < 0 ) + if( lengthFromShip > ( group.GetBoundingSphereRadius() + lengthBetweenPoints * 1.5 ) && Dot( targetVector, vectorBetween ) < 0 ) { data->tunnelLock = -1; data->tunnelPoint = 0; @@ -199,8 +198,7 @@ void FollowASpline::InitializeScratch( void* scratchMemory ) *static_cast( scratchMemory ) = FollowASplineData(); } -std::vector FollowASpline::CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius) +std::vector FollowASpline::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -210,7 +208,7 @@ std::vector FollowASpline::CalculateBehavior(std::vector& a return forceVectors; } - if ( m_frameCounter >= m_framesBetweenUpdates ) + if( m_frameCounter >= m_framesBetweenUpdates ) { m_frameCounter = 0; } @@ -220,7 +218,7 @@ std::vector FollowASpline::CalculateBehavior(std::vector& a } - if ( m_frameCounter == 0 ) + if( m_frameCounter == 0 ) { if( m_shouldReassignTunnelIDs ) { @@ -232,19 +230,19 @@ std::vector FollowASpline::CalculateBehavior(std::vector& a m_lastPullForces.clear(); m_targetPointVector.clear(); - auto data = static_cast< FollowASplineData* >( scratchData ); - for ( auto drone = agents.begin(); drone != agents.end(); ++drone, data++ ) + auto data = static_cast( scratchData ); + for( auto drone = agents.begin(); drone != agents.end(); ++drone, data++ ) { m_desiredVector = Vector3( 0, 0, 0 ); float rampingForce = 1; - if ( data->tunnelLock == -1 ) + if( data->tunnelLock == -1 ) { rampingForce = ProcessTunnelEntrances( *drone, m_privateTunnels, data ); } // tunnelLock can change in ProcessTunnelEntrances so if->else is not equivalent - if ( data->tunnelLock != -1 ) + if( data->tunnelLock != -1 ) { if( ProcessAssignedTunnel( *drone, m_privateTunnels, group, data ) ) { @@ -257,7 +255,7 @@ std::vector FollowASpline::CalculateBehavior(std::vector& a } } - if ( m_desiredVector == Vector3( 0, 0, 0 ) ) + if( m_desiredVector == Vector3( 0, 0, 0 ) ) { m_lastPullForces.push_back( Vector3( 0, 0, 0 ) ); continue; @@ -274,20 +272,20 @@ std::vector FollowASpline::CalculateBehavior(std::vector& a } else { - if ( m_lastPullForces.empty() ) + if( m_lastPullForces.empty() ) { return forceVectors; } int c = 0; - for ( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) + for( auto agent = agents.begin(); agent != agents.end(); ++agent, c++ ) { - agent->acceleration += m_lastPullForces[ c ]; + agent->acceleration += m_lastPullForces[c]; - if ( group.m_collectForces && m_lastPullForces[ c ] != Vector3( 0, 0, 0 ) ) + if( group.m_collectForces && m_lastPullForces[c] != Vector3( 0, 0, 0 ) ) { - Vector3 forceOffset = Normalize( m_lastPullForces[ c ] ) * group.GetBoundingSphereRadius(); + Vector3 forceOffset = Normalize( m_lastPullForces[c] ) * group.GetBoundingSphereRadius(); forceVectors.push_back( agent->position + forceOffset ); - forceVectors.push_back( m_lastPullForces[ c ] ); + forceVectors.push_back( m_lastPullForces[c] ); } } } @@ -300,7 +298,7 @@ bool FollowASpline::CheckForAndUpdateFormation( std::vector& agents, if( formationBH ) { - auto form = dynamic_cast ( formationBH ); + auto form = dynamic_cast( formationBH ); if( form ) { if( form->InFormation() ) @@ -321,13 +319,13 @@ bool FollowASpline::CheckForAndUpdateFormation( std::vector& agents, void FollowASpline::UpdateTunnelRegistry() { m_privateTunnels.clear(); - if ( !m_splineTunnels.empty() ) + if( !m_splineTunnels.empty() ) { - for ( auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it ) + for( auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it ) { const auto tunnelGroup = ( *it )->GetTunnels(); - for ( auto tunnel = begin( *tunnelGroup ); tunnel != end( *tunnelGroup ); ++tunnel ) + for( auto tunnel = begin( *tunnelGroup ); tunnel != end( *tunnelGroup ); ++tunnel ) { m_privateTunnels.push_back( &*tunnel ); } @@ -342,29 +340,29 @@ void FollowASpline::ReassignTunnelIDsAndAddSystemTunnels( EveChildBehaviorSystem const auto tunnels = system.GetTunnels(); //std::vector pointersToTunnels; - for ( auto it = begin( *tunnels ); it != end( *tunnels ); ++it ) + for( auto it = begin( *tunnels ); it != end( *tunnels ); ++it ) { - m_privateTunnels.insert( m_privateTunnels.begin(), const_cast< SplineTunnel* > (&(*it)) ); + m_privateTunnels.insert( m_privateTunnels.begin(), const_cast( &( *it ) ) ); } //m_privateTunnels.insert( m_privateTunnels.begin(), tunnels->begin(), tunnels->end() ); int id = 0; - if ( !tunnels->empty() ) + if( !tunnels->empty() ) { id = tunnels->back().tunnelID; - } + } - if ( m_privateTunnels.empty() ) + if( m_privateTunnels.empty() ) { m_shouldReassignTunnelIDs = false; return; } - for ( auto it = begin( m_privateTunnels ); it != end( m_privateTunnels ); ++it ) + for( auto it = begin( m_privateTunnels ); it != end( m_privateTunnels ); ++it ) { - (*it)->tunnelID = id; + ( *it )->tunnelID = id; id++; } @@ -378,15 +376,14 @@ void FollowASpline::GetDebugOptions( Tr2DebugRendererOptions& options ) void FollowASpline::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ) { - if ( renderer.HasOption( this, "SplineTunnels" ) ) + if( renderer.HasOption( this, "SplineTunnels" ) ) { - for ( auto tPoint = m_targetPointVector.begin(); tPoint != m_targetPointVector.end(); ++tPoint ) + for( auto tPoint = m_targetPointVector.begin(); tPoint != m_targetPointVector.end(); ++tPoint ) { - renderer.DrawSphere( this, TranslationMatrix( ( *tPoint ) ) * parentWorldLocation, - 2, 6, Tr2DebugRenderer::Wireframe, 0xff114444 ); + renderer.DrawSphere( this, TranslationMatrix( ( *tPoint ) ) * parentWorldLocation, 2, 6, Tr2DebugRenderer::Wireframe, 0xff114444 ); } - for ( auto t = m_splineTunnels.begin(); t != m_splineTunnels.end(); ++t ) + for( auto t = m_splineTunnels.begin(); t != m_splineTunnels.end(); ++t ) { ( *t )->RenderDebugInfo( renderer, parentWorldLocation ); } diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.h b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.h index 4b21a1bb0..c57e44b42 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline.h @@ -31,36 +31,35 @@ BLUE_CLASS( FollowASpline ) : EXPOSE_TO_BLUE(); FollowASpline( IRoot* lockobj = nullptr ); ~FollowASpline(); - + virtual size_t GetScratchMemorySize() const; virtual void InitializeScratch( void* scratchMemory ); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - bool OnModified(Be::Var* value); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + bool OnModified( Be::Var * value ); void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); virtual int GetProcessPriority(); - + private: bool m_enabled; - float ProcessTunnelEntrances(DroneAgent& agent, const std::vector& tunnels, FollowASplineData* data); - bool ProcessAssignedTunnel(DroneAgent& agent, const std::vector& tunnels, BehaviorGroup& group, FollowASplineData* data); - bool CheckForAndUpdateFormation( std::vector& agents, BehaviorGroup& group, void* scratchData, int tunnel, int tunnelPoint ); - void ReassignTunnelIDsAndAddSystemTunnels( EveChildBehaviorSystem& system ); + float ProcessTunnelEntrances( DroneAgent & agent, const std::vector& tunnels, FollowASplineData* data ); + bool ProcessAssignedTunnel( DroneAgent & agent, const std::vector& tunnels, BehaviorGroup& group, FollowASplineData* data ); + bool CheckForAndUpdateFormation( std::vector & agents, BehaviorGroup & group, void* scratchData, int tunnel, int tunnelPoint ); + void ReassignTunnelIDsAndAddSystemTunnels( EveChildBehaviorSystem & system ); void UpdateTunnelRegistry(); PSplineTunnelGroupVector m_splineTunnels; std::vector m_privateTunnels; bool m_shouldReassignTunnelIDs; TunnelGroupType m_tunnelGroupType; - float m_behaviorWeight; + float m_behaviorWeight; float m_smoothPullFactor; float m_cornerSmoothener; Vector3 m_desiredVector; - std::vector m_targetPointVector; + std::vector m_targetPointVector; int m_framesBetweenUpdates; int m_frameCounter; std::vector m_lastPullForces; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline_Blue.cpp index ea8b08f75..e45244f24 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/FollowASpline_Blue.cpp @@ -5,8 +5,7 @@ BLUE_DEFINE_INTERFACE( IBehavior ); -Be::VarChooser FollowASplineTunnelGroupTypeChooser[] = -{ +Be::VarChooser FollowASplineTunnelGroupTypeChooser[] = { { "Exit_Tunnels", BeCast( SplineTunnelGroup::EXIT_TUNNELS ), "Tunnels Drones flock to when set to exit the scene" }, { "Entrance_Tunnels", BeCast( SplineTunnelGroup::ENTRANCE_TUNNELS ), "Tunnels Drones flock to when entering the scene" }, { "Other_Tunnels", BeCast( SplineTunnelGroup::OTHER_TUNNELS ), "pathways in the scene (hallways etc)" }, @@ -25,11 +24,9 @@ const Be::ClassInfo* FollowASpline::ExposeToBlue() MAP_INTERFACE( IBehavior ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE_WITH_CHOOSER( "tunnelGroupType", m_tunnelGroupType, "designate what TunnelGroup this behavior Should Look for", - Be::READWRITE | Be::PERSIST | Be::ENUM, FollowASplineTunnelGroupTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "tunnelGroupType", m_tunnelGroupType, "designate what TunnelGroup this behavior Should Look for", Be::READWRITE | Be::PERSIST | Be::ENUM, FollowASplineTunnelGroupTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "behaviorWeight", m_behaviorWeight, "here you configure how hard it is for other behaviors to interact with this one", Be::READWRITE | Be::PERSIST ) @@ -37,8 +34,7 @@ const Be::ClassInfo* FollowASpline::ExposeToBlue() MAP_ATTRIBUTE( "cornerSmoothener", m_cornerSmoothener, "The lower this one is the more it factors the next splinePoint, looks more natural when lower but is more reliable for complex tunnels (and sharp turns)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "splineTunnels", m_splineTunnels, "", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "remapTunnels", UpdateTunnelRegistry, - "if you added system tunnels after this behavior you need to recalibrate with this \n:jessica-placement: TOOLBAR\n:jessica-icon: far-bomb\n" ) + MAP_METHOD_AND_WRAP( "remapTunnels", UpdateTunnelRegistry, "if you added system tunnels after this behavior you need to recalibrate with this \n:jessica-placement: TOOLBAR\n:jessica-icon: far-bomb\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Formation.h b/trinity/Eve/SpaceObject/Children/Behaviors/Formation.h index f9189a3ef..0203c5131 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Formation.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Formation.h @@ -10,7 +10,8 @@ struct FormationData { FormationData() : assignedSlot( -1 ) - {} + { + } int assignedSlot; }; @@ -22,16 +23,15 @@ BLUE_CLASS( Formation ) : EXPOSE_TO_BLUE(); Formation( IRoot* lockobj = nullptr ); ~Formation(); - + virtual size_t GetScratchMemorySize() const; virtual void InitializeScratch( void* scratchMemory ); int GetProcessPriority(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); std::string GetBehaviorName(); bool InFormation(); void Reset(); @@ -39,14 +39,14 @@ BLUE_CLASS( Formation ) : private: bool m_enabled; - void InitializeFormation(std::vector& agents, void* scratchData, float radius); - void CreateFormationGrid(std::vector& agents, Vector3& targetDir, float radius); - void AssignSlots(std::vector& agents, void* scratchData); + void InitializeFormation( std::vector & agents, void* scratchData, float radius ); + void CreateFormationGrid( std::vector & agents, Vector3 & targetDir, float radius ); + void AssignSlots( std::vector & agents, void* scratchData ); void BreakFormation(); - void UpdateFormation(const float deltaTime, BehaviorGroup& group); - void calculateFormationInertia(Vector3& acceleration, const float deltaTime); - void UpdateAgents(std::vector& agents, void* scratchData, float radius); - bool CheckIfFormalizing(std::vector& agents, void* scratchData); + void UpdateFormation( const float deltaTime, BehaviorGroup& group ); + void calculateFormationInertia( Vector3 & acceleration, const float deltaTime ); + void UpdateAgents( std::vector & agents, void* scratchData, float radius ); + bool CheckIfFormalizing( std::vector & agents, void* scratchData ); std::vector m_formationGrid; std::vector m_formationGridReserver; @@ -54,7 +54,7 @@ BLUE_CLASS( Formation ) : bool m_isFormalizing; Vector3 m_formationPosition; float m_maxFormationVelocityScaler; - + int32_t m_framesBetweenUpdates; int32_t m_frameCounter; int32_t m_stubbornness; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Formation_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Formation_Blue.cpp index 6da402ccc..b74d39bbc 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Formation_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Formation_Blue.cpp @@ -13,8 +13,7 @@ const Be::ClassInfo* Formation::ExposeToBlue() MAP_INTERFACE( Formation ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "behaviorWeight", m_behaviorWeight, "", Be::READWRITE | Be::PERSIST ) @@ -24,5 +23,5 @@ const Be::ClassInfo* Formation::ExposeToBlue() MAP_ATTRIBUTE( "inFormation", m_inFormation, "a debug to see when group is attemting to form", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.cpp index d0f6de2f3..827dbd108 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.cpp @@ -4,7 +4,7 @@ #include "InclusionVolume.h" -InclusionVolume::InclusionVolume( IRoot* lockobj ): +InclusionVolume::InclusionVolume( IRoot* lockobj ) : PARENTLOCK( m_inclusionVolumes ), m_enabled( true ), m_behaviorWeight( 60.0f ), @@ -23,8 +23,7 @@ int InclusionVolume::GetProcessPriority() return m_priority; } -std::vector InclusionVolume::CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius) +std::vector InclusionVolume::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -33,31 +32,30 @@ std::vector InclusionVolume::CalculateBehavior(std::vector& { return returnForces; } - for ( auto agent = agents.begin(); agent != agents.end(); ++agent) + for( auto agent = agents.begin(); agent != agents.end(); ++agent ) { Vector3 force( 0, 0, 0 ); Vector3 Nforce( 0, 0, 0 ); float status; Vector3 boxPos; - for ( auto volume = m_inclusionVolumes.begin(); volume != m_inclusionVolumes.end(); ++volume ) + for( auto volume = m_inclusionVolumes.begin(); volume != m_inclusionVolumes.end(); ++volume ) { boxPos = ( *volume )->GetBoundingSphere().center; status = ( *volume )->GetIntensity( agent->position ); - - - if ( status == 1 ) + + + if( status == 1 ) { force = Vector3( 0, 0, 0 ); Nforce = Vector3( 0, 0, 0 ); break; } - else if ( status > 0 ) + else if( status > 0 ) { Nforce = Normalize( boxPos - agent->position ); - + force = Nforce * m_behaviorWeight; - } } @@ -75,11 +73,11 @@ void InclusionVolume::GetDebugOptions( Tr2DebugRendererOptions& options ) options.insert( "InclusionVolumes" ); } -void InclusionVolume::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation) +void InclusionVolume::RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ) { - if ( renderer.HasOption( this, "InclusionVolumes" ) ) + if( renderer.HasOption( this, "InclusionVolumes" ) ) { - for ( auto volume = m_inclusionVolumes.begin(); volume != m_inclusionVolumes.end(); ++volume ) + for( auto volume = m_inclusionVolumes.begin(); volume != m_inclusionVolumes.end(); ++volume ) { ( *volume )->RenderDebugInfo( renderer, parentWorldLocation ); } diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.h b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.h index 6a7795194..55b836118 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume.h @@ -19,10 +19,9 @@ BLUE_CLASS( InclusionVolume ) : ~InclusionVolume(); virtual int GetProcessPriority(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); private: bool m_enabled; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume_Blue.cpp index 1283b3c26..eeab0cb1d 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/InclusionVolume_Blue.cpp @@ -13,13 +13,12 @@ const Be::ClassInfo* InclusionVolume::ExposeToBlue() MAP_INTERFACE( InclusionVolume ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "inclusionVolumes", m_inclusionVolumes, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "behaviorWeight", m_behaviorWeight, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "framesBetweenUpdates", m_framesBetweenUpdates, "updateFrequency to lessen the load", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.cpp index ec338a049..3ce0901cf 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.cpp @@ -67,7 +67,7 @@ std::vector Inertia::CalculateBehavior( std::vector& agents } // needs to be data - float agentVelocityLength = Length(agent->velocity); + float agentVelocityLength = Length( agent->velocity ); data->inertiaWeight = group.GetMaxVelocity() - agentVelocityLength; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.h b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.h index 3f7f39ca6..bdd6beb79 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia.h @@ -36,7 +36,7 @@ BLUE_CLASS( Inertia ) : private: bool m_enabled; float m_maxAcceleration; - float m_minInertiaWeight; // We always want some inertia when the agent is at full speed + float m_minInertiaWeight; // We always want some inertia when the agent is at full speed float m_maxRotationSpeed; int32_t m_priority; }; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia_Blue.cpp index 4a1b49985..4fab051a0 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Inertia_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Inertia_Blue.cpp @@ -13,8 +13,7 @@ const Be::ClassInfo* Inertia::ExposeToBlue() MAP_INTERFACE( Inertia ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minInertiaWeight", m_minInertiaWeight, "", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX.h b/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX.h index 00e384055..e9e55bfae 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX.h @@ -39,12 +39,11 @@ BLUE_CLASS( PlayFX ) : // PlayFX virtual size_t GetScratchMemorySize() const; virtual void InitializeScratch( void* scratchMemory ); - virtual std::vector CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); std::string GetBehaviorName(); int GetProcessPriority(); - void GetRenderables( std::vector& renderables ); + void GetRenderables( std::vector & renderables ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -53,7 +52,10 @@ BLUE_CLASS( PlayFX ) : void UpdateAsyncronous( const EveUpdateContext& updateContext, const Matrix& parentTransform ); void UpdateSyncronous( const EveUpdateContext& updateContext ); - void UpdateState( bool state ) { m_stop = state; } + void UpdateState( bool state ) + { + m_stop = state; + } void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX_Blue.cpp index e2a72dbed..2ce0c545e 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/PlayFX_Blue.cpp @@ -22,6 +22,6 @@ const Be::ClassInfo* PlayFX::ExposeToBlue() MAP_ATTRIBUTE( "sec", m_sec, "How long should the fx play", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "firingEffect", m_firingEffect, "A stretch effect for this firing effect", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "generatedFiringEffects", m_firingEffects, "generated firing effects", Be::READ ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.cpp index 1214be368..ee7e900d2 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.cpp @@ -349,7 +349,7 @@ bool ProcessLifetime::FindInitialSpawnPoint( DroneAgent& drone, ProcessLifetimeD size_t randomNr = rand() % ( sizeIndex ); // pick a random splineTunnel - auto splineTunnel = (*tunnels)[randomNr]; + auto splineTunnel = ( *tunnels )[randomNr]; // return early if there are no curves or the curves aren't loaded if( splineTunnel->GetCurveSets()->empty() ) @@ -409,7 +409,7 @@ void ProcessLifetime::FindASpawnPoint( DroneAgent& agent, ProcessLifetimeData* d tunnelIndex.push_back( ( *tunnel )->tunnelID ); } } - } + } if( potentialPoints.empty() ) { diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.h b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.h index 1cc8a724e..441884077 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime.h @@ -45,34 +45,36 @@ BLUE_CLASS( ProcessLifetime ) : bool Initialize(); // Notify - bool OnModified(Be::Var* value); - void OnListModified(long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList); + bool OnModified( Be::Var * value ); + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); std::string GetBehaviorName(); virtual size_t GetScratchMemorySize() const; virtual void InitializeScratch( void* scratchMemory ); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& sys, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, std::vector& agents, Matrix& parentWorldLocation); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& sys, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, std::vector & agents, Matrix & parentWorldLocation ); virtual int GetProcessPriority(); - void UpdateState( bool state ) { m_exit = state; } + void UpdateState( bool state ) + { + m_exit = state; + } std::vector GetPotentialPoints(); std::vector GetEntrancePoints(); - + private: - void FindASpawnPoint( DroneAgent& agent, ProcessLifetimeData* data, BehaviorGroup& group ); - bool FindInitialSpawnPoint( DroneAgent& agent, ProcessLifetimeData* data, Vector3& pos, SplineTunnelGroupVector* systemTunnels ); - bool ProcessTunnel( DroneAgent& agent, SplineTunnel& tunnel, int& pointID, float boundingSphere ); + void FindASpawnPoint( DroneAgent & agent, ProcessLifetimeData * data, BehaviorGroup & group ); + bool FindInitialSpawnPoint( DroneAgent & agent, ProcessLifetimeData * data, Vector3 & pos, SplineTunnelGroupVector * systemTunnels ); + bool ProcessTunnel( DroneAgent & agent, SplineTunnel & tunnel, int& pointID, float boundingSphere ); void FindAndAssignAnExitTunnel( const DroneAgent& agent, ProcessLifetimeData* data ); void UpdateTunnelRegistry(); - void ReassignTunnelIDsAndAddSystemTunnels( EveChildBehaviorSystem& system ); + void ReassignTunnelIDsAndAddSystemTunnels( EveChildBehaviorSystem & system ); float GetRandomOffset( float cylWidth ) const; - float m_firstAgentLifetime; // debug visualization + float m_firstAgentLifetime; // debug visualization PSplineTunnelGroupVector m_splineTunnels; std::vector m_privateTunnels; diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime_Blue.cpp index 7edc2afe0..14095d59d 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/ProcessLifetime_Blue.cpp @@ -3,8 +3,7 @@ #include "StdAfx.h" #include "ProcessLifetime.h" -Be::VarChooser ProcessLifetimeTunnelGroupTypeChooser[] = -{ +Be::VarChooser ProcessLifetimeTunnelGroupTypeChooser[] = { { "Exit_Tunnels", BeCast( SplineTunnelGroup::EXIT_TUNNELS ), "Tunnels Drones flock to when set to exit the scene" }, { "Entrance_Tunnels", BeCast( SplineTunnelGroup::ENTRANCE_TUNNELS ), "Tunnels Drones flock to when entering the scene" }, { "Other_Tunnels", BeCast( SplineTunnelGroup::OTHER_TUNNELS ), "pathways in the scene (hallways etc)" }, @@ -25,8 +24,7 @@ const Be::ClassInfo* ProcessLifetime::ExposeToBlue() MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "exit", m_exit, "Trigger to have drones search for an exit tunnel", Be::READWRITE ) MAP_ATTRIBUTE( "firstAgentLifetime", m_firstAgentLifetime, "Current lifetime for first agent in the group", Be::READ ) @@ -36,7 +34,7 @@ const Be::ClassInfo* ProcessLifetime::ExposeToBlue() MAP_ATTRIBUTE( "respawnAgentsOnDeath", m_respawnAgentsOnDeath, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "splineTunnels", m_splineTunnels, "", Be::READ | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "firstSpawnAtRandomPlaces", m_firstSpawnAtRandomPlaces, "If true, on load drones will spawn around the tunnel", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.cpp index f9ab289e9..ddf357daa 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.cpp @@ -78,13 +78,13 @@ std::vector SeekTarget::CalculateBehavior( std::vector& age int agentCount = 0; for( auto agent = agents.begin(); agent != agents.end(); ++agent, ++data ) { - + // find an initial spawn position // might have to move this to behaviorGroup for this to be used in other behaviors but this is just a test if( !data->hasSpawned && m_firstSpawnAtRandomPlaces ) { Vector3 spawnPos; - spawnPos = FindSpawnPoint( ); + spawnPos = FindSpawnPoint(); group.m_spawnPosition = spawnPos; agent->position = spawnPos; data->hasSpawned = true; @@ -256,8 +256,8 @@ std::vector SeekTarget::CalculateBehavior( std::vector& age // Move the drone in the desired direction auto force = desiredVelocity * m_behaviorWeight - agent->velocity; agent->acceleration += desiredVelocity - agent->velocity; - - Vector3 forceOffset = (force) * group.GetBoundingSphereRadius(); + + Vector3 forceOffset = (force)*group.GetBoundingSphereRadius(); m_returnForces.push_back( agent->position + forceOffset ); m_returnForces.push_back( force ); } @@ -269,7 +269,7 @@ std::vector SeekTarget::CalculateBehavior( std::vector& age m_repairTimePassed += deltaTime; } - + return m_returnForces; } @@ -327,7 +327,7 @@ void SeekTarget::SetupShipRepair() m_repair = true; } -Vector3 SeekTarget::FindSpawnPoint( ) +Vector3 SeekTarget::FindSpawnPoint() { auto seekLocators = GetLocatorsForSet( m_locatorSetName ); if( seekLocators != NULL && seekLocators[0].size() > 0 ) diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.h b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.h index 85ef0158d..f8cd5d4b2 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget.h @@ -112,19 +112,6 @@ TYPEDEF_BLUECLASS( SeekTarget ); - - - - - - - - - - - - - /* void EveChildEffectPropagator::ProcessRefLocators( IEveSpaceObject2* parent ) { diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget_Blue.cpp index e670a1eda..e9b01e869 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SeekTarget_Blue.cpp @@ -13,9 +13,8 @@ const Be::ClassInfo* SeekTarget::ExposeToBlue() MAP_INTERFACE( SeekTarget ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) - + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "locatorSet", m_locatorSet, "Set of Blue structure lists of locators identified by a name", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "Name of locatorSet", Be::READWRITE | Be::PERSIST ) @@ -68,10 +67,10 @@ const Be::ClassInfo* SeekTarget::ExposeToBlue() SplitBoundingBox, "Splits bounding box into sub boxes if ship is large enough.\n" ":param transforms: target" ) - + MAP_METHOD_AND_WRAP( - "AddLocatorSet", - AddLocatorSet, + "AddLocatorSet", + AddLocatorSet, "Adds a locatorSet to the behavior \n:jessica-placement: TOOLBAR\n:jessica-icon: fa-map-pin\n" ) MAP_METHOD_AND_WRAP( @@ -80,5 +79,5 @@ const Be::ClassInfo* SeekTarget::ExposeToBlue() "Set the totalRepairTime \n" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.cpp index f2394475c..0c68209ba 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.cpp @@ -14,7 +14,7 @@ SpawnDrones::SpawnDrones( IRoot* lockobj ) : m_count( 1 ), m_spawnPosition( 0, 0, 0 ), m_gridInfo( 1, 1, 1, 10 ), - m_gridSpacing( 0, 0, 0), + m_gridSpacing( 0, 0, 0 ), m_gridFullnessFactor( 1.f ) { } @@ -23,14 +23,14 @@ SpawnDrones::~SpawnDrones() { } -void SpawnDrones::UpdateGrid(BehaviorGroup& group) +void SpawnDrones::UpdateGrid( BehaviorGroup& group ) { CCP_STATS_ZONE( __FUNCTION__ ); // for behaviors to work we always have to add one decoy drone, delete that one so he doesn't mess up the cube for( unsigned int i = 0; i < group.GetCount(); i++ ) { - group.SetCount( 0 ); + group.SetCount( 0 ); } Vector3 startPos = group.m_spawnPosition; @@ -84,8 +84,7 @@ void SpawnDrones::UpdateGrid(BehaviorGroup& group) group.m_spawnPosition = Vector3( 0, 0, 0 ); } -std::vector SpawnDrones::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) +std::vector SpawnDrones::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -122,7 +121,7 @@ std::vector SpawnDrones::CalculateBehavior( std::vector& ag auto behavior = group.GetBehaviorByName( "ProcessLifetime" ); if( behavior != nullptr ) { - auto processLifetime = dynamic_cast ( behavior ); + auto processLifetime = dynamic_cast( behavior ); if( processLifetime ) { std::vector spawnPoints = processLifetime->GetEntrancePoints(); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.h b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.h index 0c0f4d48a..261876a62 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones.h @@ -14,8 +14,7 @@ BLUE_CLASS( SpawnDrones ) : SpawnDrones( IRoot* lockobj = nullptr ); ~SpawnDrones(); - virtual std::vector CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); void GridToggleReset(); void UpdateGrid( BehaviorGroup & group ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones_Blue.cpp index 508cd09be..122010637 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SpawnDrones_Blue.cpp @@ -23,9 +23,9 @@ const Be::ClassInfo* SpawnDrones::ExposeToBlue() MAP_ATTRIBUTE( "gridInfo", m_gridInfo, "x = count of drones in x row, y = count of drones in y row, z = count of drones in z row, w = distance between models \n:jessica-group: Grid", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "gridSpacing", m_gridSpacing, "(x,y,z) spacing in between models \n:jessica-group: Grid", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "gridFullnessFactor", m_gridFullnessFactor, "[0-1] how full should the grid be, 0 being no drones and 1 being fully populated, -1 will randomize the percentage factor \n:jessica-group: Grid", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + MAP_METHOD_AND_WRAP( "gridToggleReset", GridToggleReset, "toggle to 'reset' grid spawning \n:jessica-placement: TOOLBAR\n:jessica-icon: far-bomb\n" ) - - EXPOSURE_END() + + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.cpp index 3aedfefc2..cb69ecc16 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.cpp @@ -37,32 +37,32 @@ void SplineTunnelGroup::SetSystemTunnelFunctionReferenceAndColor( const std::fun void SplineTunnelGroup::CreateSplineTunnels() { m_tunnels.clear(); - for ( auto cSet = m_curveSets.begin(); cSet != m_curveSets.end(); ++cSet ) + for( auto cSet = m_curveSets.begin(); cSet != m_curveSets.end(); ++cSet ) { - float curveDur = (*cSet)->Length(); - int breakPoints = GetNumBreakPoints(); - std::vector < Vector3 > Positions; - float stepSize = curveDur / (breakPoints + 1); + float curveDur = ( *cSet )->Length(); + int breakPoints = GetNumBreakPoints(); + std::vector Positions; + float stepSize = curveDur / ( breakPoints + 1 ); - for( int i = 0; i < ( breakPoints + 2 ); i++) + for( int i = 0; i < ( breakPoints + 2 ); i++ ) { - Positions.push_back( (*cSet)->GetValue( i * stepSize ) ); + Positions.push_back( ( *cSet )->GetValue( i * stepSize ) ); } SplineTunnelPoint point; std::vector splinePoints; - for (int i = 0; i < (breakPoints + 1); i++) + for( int i = 0; i < ( breakPoints + 1 ); i++ ) { point.pos = Positions[i]; point.rot = Positions[i + 1] - Positions[i]; splinePoints.push_back( point ); } - + point.pos = Positions[breakPoints + 1]; point.rot = Positions[breakPoints + 1] - Positions[breakPoints]; splinePoints.push_back( point ); - + SplineTunnel tunnel; tunnel.splinePoints = splinePoints; tunnel.cylWidth = m_tunnelWidth; @@ -72,7 +72,7 @@ void SplineTunnelGroup::CreateSplineTunnels() m_tunnels.push_back( tunnel ); } - if ( m_changeSystemTunnelRegistry ) + if( m_changeSystemTunnelRegistry ) { ( m_changeSystemTunnelRegistry )(); } @@ -95,7 +95,7 @@ void SplineTunnelGroup::SetNumBreakPoints( int val ) int SplineTunnelGroup::GetNumBreakPoints() const { - return max(m_numBreakPoints, 0); + return max( m_numBreakPoints, 0 ); } ///////////////////////////////////////////////////////////////////////////////////// @@ -118,18 +118,18 @@ bool SplineTunnelGroup::OnModified( Be::Var* value ) void SplineTunnelGroup::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) { - if (theList == &m_curveSets) + if( theList == &m_curveSets ) { - switch (event & BELIST_EVENTMASK) + switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - CreateSplineTunnels(); + CreateSplineTunnels(); break; case BELIST_REMOVED: - CreateSplineTunnels(); + CreateSplineTunnels(); break; case BELIST_LOADFINISHED: - CreateSplineTunnels(); + CreateSplineTunnels(); break; default: break; @@ -147,28 +147,22 @@ void SplineTunnelGroup::GetDebugOptions( Tr2DebugRendererOptions& options ) void SplineTunnelGroup::RenderDebugInfo( ITr2DebugRenderer2& renderer, Matrix& parentWorldLocation ) { - for (auto tunnel = m_tunnels.begin(); tunnel != m_tunnels.end(); ++tunnel) + for( auto tunnel = m_tunnels.begin(); tunnel != m_tunnels.end(); ++tunnel ) { // render first Point - renderer.DrawSphere(this, TranslationMatrix((*tunnel).splinePoints[0].pos) * parentWorldLocation, - (*tunnel).pullSize, 6, Tr2DebugRenderer::Wireframe, 0xff551111); - renderer.DrawSphere(this, TranslationMatrix((*tunnel).splinePoints[0].pos) * parentWorldLocation, - (*tunnel).pointOfNoReturnSize, 6, Tr2DebugRenderer::Wireframe, 0xff551111); + renderer.DrawSphere( this, TranslationMatrix( ( *tunnel ).splinePoints[0].pos ) * parentWorldLocation, ( *tunnel ).pullSize, 6, Tr2DebugRenderer::Wireframe, 0xff551111 ); + renderer.DrawSphere( this, TranslationMatrix( ( *tunnel ).splinePoints[0].pos ) * parentWorldLocation, ( *tunnel ).pointOfNoReturnSize, 6, Tr2DebugRenderer::Wireframe, 0xff551111 ); // render last point ? probably gonna be removed renderer.DrawSphere( - this, TranslationMatrix((*tunnel).splinePoints[GetNumBreakPoints() + 1].pos) * parentWorldLocation, 5, 6, - Tr2DebugRenderer::Wireframe, 0xff335555); + this, TranslationMatrix( ( *tunnel ).splinePoints[GetNumBreakPoints() + 1].pos ) * parentWorldLocation, 5, 6, Tr2DebugRenderer::Wireframe, 0xff335555 ); // render the points in-between - auto pnts = (*tunnel).splinePoints; - for (auto point = pnts.begin(); point != pnts.end(); ++point) + auto pnts = ( *tunnel ).splinePoints; + for( auto point = pnts.begin(); point != pnts.end(); ++point ) { - renderer.DrawSphere(this, TranslationMatrix(point->pos) * parentWorldLocation, ( *tunnel ).cylWidth, 6, - Tr2DebugRenderer::Wireframe, 0xff555555); - renderer.DrawCylinder( this, (TranslationMatrix( point->pos ) * parentWorldLocation).GetTranslation(), - (TranslationMatrix(point->pos + point->rot) * parentWorldLocation).GetTranslation(), (*tunnel).cylWidth, - 8, Tr2DebugRenderer::Wireframe, m_debugColor ); + renderer.DrawSphere( this, TranslationMatrix( point->pos ) * parentWorldLocation, ( *tunnel ).cylWidth, 6, Tr2DebugRenderer::Wireframe, 0xff555555 ); + renderer.DrawCylinder( this, ( TranslationMatrix( point->pos ) * parentWorldLocation ).GetTranslation(), ( TranslationMatrix( point->pos + point->rot ) * parentWorldLocation ).GetTranslation(), ( *tunnel ).cylWidth, 8, Tr2DebugRenderer::Wireframe, m_debugColor ); } } } diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.h b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.h index 4fd01c280..1bacb334d 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup.h @@ -12,23 +12,22 @@ struct ITr2Renderable; struct SplineTunnelPoint { - friend bool operator==(const SplineTunnelPoint& lhs, const SplineTunnelPoint& rhs) + friend bool operator==( const SplineTunnelPoint& lhs, const SplineTunnelPoint& rhs ) { - return lhs.accelerationMultiplier == rhs.accelerationMultiplier - && lhs.pos == rhs.pos - && lhs.rot == rhs.rot; + return lhs.accelerationMultiplier == rhs.accelerationMultiplier && lhs.pos == rhs.pos && lhs.rot == rhs.rot; } - friend bool operator!=(const SplineTunnelPoint& lhs, const SplineTunnelPoint& rhs) + friend bool operator!=( const SplineTunnelPoint& lhs, const SplineTunnelPoint& rhs ) { - return !(lhs == rhs); + return !( lhs == rhs ); } SplineTunnelPoint() : accelerationMultiplier( 1.f ), pos( 0, 0, 0 ), rot( 0, 0, 0 ) - {} + { + } float accelerationMultiplier; Vector3 pos; @@ -43,7 +42,8 @@ struct SplineTunnel cylWidth( 20 ), tunnelID( -1 ), tunnelGroupType( 0 ) - {} + { + } int tunnelID; int tunnelGroupType; @@ -75,27 +75,26 @@ BLUE_CLASS( SplineTunnelGroup ) : SplineTunnelGroup( IRoot* lockobj = nullptr ); ~SplineTunnelGroup(); TunnelGroupType GetTunnelGroupType() const; - void SetSystemTunnelFunctionReferenceAndColor(const std::function& F, uint32_t color ); + void SetSystemTunnelFunctionReferenceAndColor( const std::function& F, uint32_t color ); // This ( SplineTunnelGroup | special functions ) void CreateSplineTunnels(); std::vector* GetTunnels(); - void SetNumBreakPoints(int val); + void SetNumBreakPoints( int val ); int GetNumBreakPoints() const; Tr2CurveVector3Vector* GetCurveSets(); // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, Matrix& parentWorldLocation ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, Matrix & parentWorldLocation ); // IInitialize static bool Initialize(); - void OnListModified(long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList); - bool OnModified( Be::Var* value ); - + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); + bool OnModified( Be::Var * value ); -private: +private: TunnelGroupType m_tunnelGroupType; int32_t m_numBreakPoints; std::vector m_tunnels; @@ -105,8 +104,7 @@ BLUE_CLASS( SplineTunnelGroup ) : float m_entrancePullSize; float m_entrySize; uint32_t m_debugColor; - -}; +}; TYPEDEF_BLUECLASS( SplineTunnelGroup ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup_Blue.cpp index 530a41245..f99d53aae 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/SplineTunnelGroup_Blue.cpp @@ -5,8 +5,7 @@ #include "Eve/SpaceObject/Children/EveChildContainer.h" -Be::VarChooser SplineTunnelGroupTypeChooser[] = -{ +Be::VarChooser SplineTunnelGroupTypeChooser[] = { // If you modify this make sure to go through the behaviors and add the same modification { "Exit_Tunnels", BeCast( SplineTunnelGroup::EXIT_TUNNELS ), "Tunnels Drones flock to when set to exit the scene" }, { "Entrance_Tunnels", BeCast( SplineTunnelGroup::ENTRANCE_TUNNELS ), "Tunnels Drones flock to when entering the scene" }, @@ -25,16 +24,14 @@ const Be::ClassInfo* SplineTunnelGroup::ExposeToBlue() MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "curveSets", m_curveSets, "", Be::READ | Be::PERSIST | Be::NOTIFY ) - - MAP_ATTRIBUTE_WITH_CHOOSER("tunnelGroupType", m_tunnelGroupType, "control when drones interact with these tunnels", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, SplineTunnelGroupTypeChooser) + + MAP_ATTRIBUTE_WITH_CHOOSER( "tunnelGroupType", m_tunnelGroupType, "control when drones interact with these tunnels", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, SplineTunnelGroupTypeChooser ) MAP_ATTRIBUTE( "breakPoints", m_numBreakPoints, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "tunnelWidth", m_tunnelWidth, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "entrancePullSize", m_entrancePullSize, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "entrySize", m_entrySize, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_METHOD_AND_WRAP("createSplineTunnels", CreateSplineTunnels, - "recreate all tunnels \n:jessica-placement: TOOLBAR\n:jessica-icon: far-bomb\n") + MAP_METHOD_AND_WRAP( "createSplineTunnels", CreateSplineTunnels, "recreate all tunnels \n:jessica-placement: TOOLBAR\n:jessica-icon: far-bomb\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Wander.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Wander.cpp index a4b4e68f1..2fb3f1ba7 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Wander.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Wander.cpp @@ -5,13 +5,13 @@ #include "Include/TriMath.h" #include "include/TriQuaternion.h" -Wander::Wander(IRoot* lockobj) : +Wander::Wander( IRoot* lockobj ) : m_enabled( true ), m_weightWander( 240.f ), - rand1(0.2), - rand2(0.8), - rand3(1.2), - m_freq(2), + rand1( 0.2 ), + rand2( 0.8 ), + rand3( 1.2 ), + m_freq( 2 ), m_priority( LEAST_PRIORITY ) { } @@ -25,8 +25,7 @@ int Wander::GetProcessPriority() return m_priority; } -std::vector Wander::CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius) +std::vector Wander::CalculateBehavior( std::vector& agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ) { CCP_STATS_ZONE( __FUNCTION__ ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Wander.h b/trinity/Eve/SpaceObject/Children/Behaviors/Wander.h index 4fa106ba2..2a66d7298 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Wander.h +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Wander.h @@ -14,19 +14,17 @@ BLUE_CLASS( Wander ) : Wander( IRoot* lockobj = nullptr ); ~Wander(); - virtual std::vector CalculateBehavior(std::vector& agents, void* scratchData, const float deltaTime, - BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius); + virtual std::vector CalculateBehavior( std::vector & agents, void* scratchData, const float deltaTime, BehaviorGroup& group, EveChildBehaviorSystem& system, const std::vector>& dronesInSearchRadius ); virtual int GetProcessPriority(); private: bool m_enabled; - float m_weightWander; //priority of behavior + float m_weightWander; //priority of behavior float rand1; float rand2; float rand3; float m_freq; int32_t m_priority; - }; TYPEDEF_BLUECLASS( Wander ); diff --git a/trinity/Eve/SpaceObject/Children/Behaviors/Wander_Blue.cpp b/trinity/Eve/SpaceObject/Children/Behaviors/Wander_Blue.cpp index 00db20819..9f1fc8ebb 100644 --- a/trinity/Eve/SpaceObject/Children/Behaviors/Wander_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/Behaviors/Wander_Blue.cpp @@ -13,8 +13,7 @@ const Be::ClassInfo* Wander::ExposeToBlue() MAP_INTERFACE( Wander ) MAP_INTERFACE( IBehavior ) - MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", - Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "behaviorPriority", m_priority, "control what priority this behavior should have", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, BehaviorPriorityChooser ) MAP_ATTRIBUTE( "enabled", m_enabled, "Should this behavior be active", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "weightWander", m_weightWander, "How much weight should this behavior have", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp index 83065b5cf..0e8c8b2f9 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.cpp @@ -4,12 +4,11 @@ #include "EveChildAudio.h" -EveChildAudio::EveChildAudio( IRoot* lockobj ): -m_name( "EveChildAudio" ), -m_mute( false ), -m_worldTransform( IdentityMatrix() ) +EveChildAudio::EveChildAudio( IRoot* lockobj ) : + m_name( "EveChildAudio" ), + m_mute( false ), + m_worldTransform( IdentityMatrix() ) { - } bool EveChildAudio::Initialize() @@ -33,7 +32,7 @@ bool EveChildAudio::Initialize() { emitterName = m_name; } - m_audioEmitter->Initialize( emitterName, L"", position); + m_audioEmitter->Initialize( emitterName, L"", position ); return true; } @@ -92,12 +91,10 @@ void EveChildAudio::GetLocalToWorldTransform( Matrix& transform ) const void EveChildAudio::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) { - } void EveChildAudio::GetRenderables( std::vector& renderables ) { - } bool EveChildAudio::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const @@ -122,12 +119,12 @@ void EveChildAudio::UpdateSyncronous( const EveUpdateContext& updateContext, con } UpdateTransform( localToWorldTransform ); - if( m_audioEmitter && !m_mute) + if( m_audioEmitter && !m_mute ) { Vector3 position = m_worldTransform.GetTranslation(); Quaternion rotation = RotationQuaternion( m_worldTransform ); Matrix rotationMatrix = RotationMatrix( rotation ); - Vector3 front = TransformNormal( Vector3( 0, 1, 0 ), rotationMatrix); + Vector3 front = TransformNormal( Vector3( 0, 1, 0 ), rotationMatrix ); Vector3 top = TransformNormal( Vector3( 0, 0, 1 ), rotationMatrix ); m_audioEmitter->SetPosition( front, top, position ); } @@ -147,7 +144,6 @@ void EveChildAudio::SetEmitterName( const std::string& name ) void EveChildAudio::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { - } void EveChildAudio::ChangeLOD( Tr2Lod lod ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio.h b/trinity/Eve/SpaceObject/Children/EveChildAudio.h index dfdcd1e53..cbabd87cb 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio.h +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio.h @@ -7,12 +7,12 @@ #include "EveChildTransform.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif #include @@ -33,16 +33,16 @@ BLUE_CLASS( EveChildAudio ) : public INotify, public ITr2DebugRenderable { - public: - EXPOSE_TO_BLUE(); +public: + EXPOSE_TO_BLUE(); - /** + /** * @brief Constructs an EveChildAudio instance. * @param lockobj Optional lock object for thread safety (default: NULL). */ - EveChildAudio( IRoot* lockobj = NULL ); + EveChildAudio( IRoot* lockobj = NULL ); - /** + /** * @brief Initializes the audio child after loading from a .red file or construction. * * Called by the Blue framework after the object is fully constructed or deserialized. @@ -50,14 +50,14 @@ BLUE_CLASS( EveChildAudio ) : * * @return true if initialization succeeded, false otherwise. */ - bool Initialize(); + bool Initialize(); - /** + /** * @brief Python initialization hook. */ - void py__init__(); + void py__init__(); - /** + /** * @brief Handles modification notifications from the Blue framework. * * Called when a property with Be::NOTIFY changes. @@ -65,35 +65,35 @@ BLUE_CLASS( EveChildAudio ) : * @param val Pointer to the modified variable. * @return true if the modification was successfully. */ - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); - /** + /** * @brief Sets the name of the audio emitter. * @param name The emitter name to set. */ - void SetEmitterName( const std::string& name ); - - // Implementing the IEveSpaceObjectChild interface - const char* GetName() const; - void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix & transform ) const; - void ChangeLOD( Tr2Lod lod ); - void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); + void SetEmitterName( const std::string& name ); + + // Implementing the IEveSpaceObjectChild interface + const char* GetName() const; + void SetName( const char* name ); + void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); + void GetLocalToWorldTransform( Matrix & transform ) const; + void ChangeLOD( Tr2Lod lod ); + void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; - - private: - std::string m_name; ///< The name identifier for this audio child. - Matrix m_worldTransform; ///< Cached world transformation matrix. - bool m_mute; ///< Whether audio playback is muted. - ITr2AudEmitterPtr m_audioEmitter; ///< The audio emitter instance. + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; + +private: + std::string m_name; ///< The name identifier for this audio child. + Matrix m_worldTransform; ///< Cached world transformation matrix. + bool m_mute; ///< Whether audio playback is muted. + ITr2AudEmitterPtr m_audioEmitter; ///< The audio emitter instance. }; /** diff --git a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp index d4f505448..a156c15ed 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildAudio_Blue.cpp @@ -7,18 +7,18 @@ BLUE_DEFINE( EveChildAudio ); const Be::ClassInfo* EveChildAudio::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildAudio, "Audio emitter space object child" ) - MAP_INTERFACE( EveChildAudio ) - MAP_INTERFACE( IEveSpaceObjectChild ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) + EXPOSURE_BEGIN( EveChildAudio, "Audio emitter space object child" ) + MAP_INTERFACE( EveChildAudio ) + MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST| Be::NOTIFY) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "mute", m_mute, "Mute state", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( "audioEmitter", m_audioEmitter, "The audio emitter", Be::READ| Be::PERSIST ) + MAP_ATTRIBUTE( "audioEmitter", m_audioEmitter, "The audio emitter", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "SetEmitterName", SetEmitterName, "Sets emitter name" ) + MAP_METHOD_AND_WRAP( "SetEmitterName", SetEmitterName, "Sets emitter name" ) MAP_METHOD_AND_WRAP( "__init__", py__init__, "Initialize the audio emitter after contruction/deserialization" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp index cfbf90b30..0a2c09176 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.cpp @@ -11,33 +11,34 @@ namespace { - class EveChildBehaviorSystemPerObjectData : public Tr2PerObjectData +class EveChildBehaviorSystemPerObjectData : public Tr2PerObjectData +{ +public: + virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { - public: - virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const - { - FillAndSetConstants( *buffers[Tr2RenderContextEnum::VERTEX_SHADER], - m_vsData, - sizeof( *m_vsData ), - Tr2RenderContextEnum::VERTEX_SHADER, - Tr2Renderer::GetPerObjectVSStartRegister(), - renderContext ); - FillAndSetConstants( *buffers[Tr2RenderContextEnum::PIXEL_SHADER], - m_psData, sizeof( *m_psData ), - Tr2RenderContextEnum::PIXEL_SHADER, - Tr2Renderer::GetPerObjectPSStartRegister(), - renderContext ); - } + FillAndSetConstants( *buffers[Tr2RenderContextEnum::VERTEX_SHADER], + m_vsData, + sizeof( *m_vsData ), + Tr2RenderContextEnum::VERTEX_SHADER, + Tr2Renderer::GetPerObjectVSStartRegister(), + renderContext ); + FillAndSetConstants( *buffers[Tr2RenderContextEnum::PIXEL_SHADER], + m_psData, + sizeof( *m_psData ), + Tr2RenderContextEnum::PIXEL_SHADER, + Tr2Renderer::GetPerObjectPSStartRegister(), + renderContext ); + } - void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const - { - writer.SetPerObjectData( Tr2RenderContextEnum::VERTEX_SHADER, m_vsData, sizeof( *m_vsData ) ); - writer.SetPerObjectData( Tr2RenderContextEnum::PIXEL_SHADER, m_psData, sizeof( *m_psData ) ); - } + void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const + { + writer.SetPerObjectData( Tr2RenderContextEnum::VERTEX_SHADER, m_vsData, sizeof( *m_vsData ) ); + writer.SetPerObjectData( Tr2RenderContextEnum::PIXEL_SHADER, m_psData, sizeof( *m_psData ) ); + } - EveSpaceObjectPSData* m_psData; - EveSpaceObjectVSData* m_vsData; - }; + EveSpaceObjectPSData* m_psData; + EveSpaceObjectVSData* m_vsData; +}; } @@ -65,7 +66,7 @@ EveChildBehaviorSystem::~EveChildBehaviorSystem() bool EveChildBehaviorSystem::Initialize() { - if ( m_staticTransform ) + if( m_staticTransform ) { RebuildLocalTransform(); } @@ -86,12 +87,12 @@ bool EveChildBehaviorSystem::OnModified( Be::Var* value ) void EveChildBehaviorSystem::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) { - if ( theList == &m_behaviorGroups ) + if( theList == &m_behaviorGroups ) { - switch ( event & BELIST_EVENTMASK ) + switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if ( BehaviorGroupPtr handler = BlueCastPtr( value ) ) + if( BehaviorGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &EveChildBehaviorSystem::ChangeBufferInstanceCount, this ); handler->SetVertexFunctionReferance( f ); @@ -99,49 +100,51 @@ void EveChildBehaviorSystem::OnListModified( long event, ssize_t key, ssize_t ke } break; case BELIST_REMOVED: - if ( BehaviorGroupPtr handler = BlueCastPtr( value ) ) + if( BehaviorGroupPtr handler = BlueCastPtr( value ) ) { ChangeBufferInstanceCount(); } break; case BELIST_LOADFINISHED: - if ( BehaviorGroupPtr handler = BlueCastPtr( value ) ) + if( BehaviorGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &EveChildBehaviorSystem::ChangeBufferInstanceCount, this ); handler->SetVertexFunctionReferance( f ); handler->InitializeGeometryResource(); } - else m_behaviorGroupLoaded = false; //this is for when this file is loaded but the groups have yet to be loaded + else + m_behaviorGroupLoaded = false; //this is for when this file is loaded but the groups have yet to be loaded break; default: break; } } - if (theList == &m_splineTunnels) + if( theList == &m_splineTunnels ) { - switch ( event & BELIST_EVENTMASK ) + switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if (SplineTunnelGroupPtr handler = BlueCastPtr( value )) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &EveChildBehaviorSystem::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xffffff00 ); } break; case BELIST_REMOVED: - if (SplineTunnelGroupPtr handler = BlueCastPtr( value )) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &EveChildBehaviorSystem::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xffffff00 ); } break; case BELIST_LOADFINISHED: - if (SplineTunnelGroupPtr handler = BlueCastPtr( value )) + if( SplineTunnelGroupPtr handler = BlueCastPtr( value ) ) { std::function f = std::bind( &EveChildBehaviorSystem::UpdateTunnelRegistry, this ); handler->SetSystemTunnelFunctionReferenceAndColor( f, 0xffffff00 ); } - else m_behaviorGroupLoadedForTunnel = false; //this is for when this file is loaded but the groups have yet to be loaded + else + m_behaviorGroupLoadedForTunnel = false; //this is for when this file is loaded but the groups have yet to be loaded break; default: break; @@ -186,7 +189,7 @@ void EveChildBehaviorSystem::OnListModified( long event, ssize_t key, ssize_t ke bool EveChildBehaviorSystem::OnPrepareResources() { USE_MAIN_THREAD_RENDER_CONTEXT(); - + // Start with a fresh buffer m_shipInstanceBuffer = Tr2BufferAL(); m_boosterInstanceBuffer = Tr2BufferAL(); @@ -208,7 +211,7 @@ unsigned int EveChildBehaviorSystem::GetInstanceBufferCount() const // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2InstanceData interface. Returns number of instances in the instance +// Implements ITr2InstanceData interface. Returns number of instances in the instance // buffer. // Arguments: // bufferIndex - (unused) instance buffer index @@ -218,9 +221,9 @@ unsigned int EveChildBehaviorSystem::GetInstanceBufferCount() const unsigned int EveChildBehaviorSystem::GetInstanceBufferVertexCount( unsigned int bufferIndex ) const { size_t size = 0; - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - size += (*it)->GetSize(); + size += ( *it )->GetSize(); } return unsigned( size ); } @@ -229,11 +232,11 @@ unsigned int EveChildBehaviorSystem::GetInstanceBufferVertexCount( unsigned int // The onListNotify takes care of all other cases (like when just a new behavior group is loaded) void EveChildBehaviorSystem::PassInVertexesToBehaviorGroups() { - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { std::function f = std::bind( &EveChildBehaviorSystem::ChangeBufferInstanceCount, this ); - (*it)->SetVertexFunctionReferance( f ); - (*it)->InitializeGeometryResource(); + ( *it )->SetVertexFunctionReferance( f ); + ( *it )->InitializeGeometryResource(); } m_behaviorGroupLoaded = true; } @@ -242,10 +245,10 @@ void EveChildBehaviorSystem::PassInVertexesToBehaviorGroups() // The onListNotify takes care of all other cases (like when just a new behavior group is loaded) void EveChildBehaviorSystem::PassInTunnelFunctionsToBehaviorGroups() { - for (auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it) + for( auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it ) { std::function f = std::bind( &EveChildBehaviorSystem::UpdateTunnelRegistry, this ); - (*it)->SetSystemTunnelFunctionReferenceAndColor( f, 0xffffff00 ); + ( *it )->SetSystemTunnelFunctionReferenceAndColor( f, 0xffffff00 ); } m_behaviorGroupLoadedForTunnel = true; } @@ -266,9 +269,9 @@ void EveChildBehaviorSystem::UpdateSyncronous( const EveUpdateContext& updateCon PassInTunnelFunctionsToBehaviorGroups(); } - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - (*it)->CreateVertexDeclaration(); + ( *it )->CreateVertexDeclaration(); } for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) @@ -283,7 +286,7 @@ void EveChildBehaviorSystem::UpdateSyncronous( const EveUpdateContext& updateCon // EveChildBehaviorSystem void EveChildBehaviorSystem::UpdateAgents( const float dt ) { - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { ( *it )->UpdateAgents( dt, *this ); } @@ -292,11 +295,11 @@ void EveChildBehaviorSystem::UpdateAgents( const float dt ) void EveChildBehaviorSystem::UpdateBuffer( Tr2RenderContext& renderContext ) { m_startInstanceValues.clear(); - + uint8_t* shipData; uint8_t* boosterData; - - + + CR_RETURN( m_shipInstanceBuffer.MapForWriting( shipData, renderContext ) ); ON_BLOCK_EXIT( [&] { m_shipInstanceBuffer.UnmapForWriting( renderContext ); } ); @@ -306,7 +309,7 @@ void EveChildBehaviorSystem::UpdateBuffer( Tr2RenderContext& renderContext ) Matrix WT = EveChildTransform::m_worldTransform; uint32_t totalShipsSoFar = 0; - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { int count = ( *it )->GetCount(); @@ -319,20 +322,19 @@ void EveChildBehaviorSystem::UpdateBuffer( Tr2RenderContext& renderContext ) boosterData += count * m_boosterStride; //save base instance offset for this group - ( *it )->SetGroupIndexIndicator( static_cast(m_startInstanceValues.size()) ); + ( *it )->SetGroupIndexIndicator( static_cast( m_startInstanceValues.size() ) ); m_startInstanceValues.push_back( totalShipsSoFar ); totalShipsSoFar += count; } } -void EveChildBehaviorSystem::GetGroupBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Tr2PerObjectData* perObjectData, Tr2MeshPtr mesh, BehaviorGroup* group ) +void EveChildBehaviorSystem::GetGroupBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2MeshPtr mesh, BehaviorGroup* group ) { if( !group->m_display ) { return; } - if ( mesh == nullptr ) + if( mesh == nullptr ) { return; } @@ -360,8 +362,7 @@ void EveChildBehaviorSystem::GetGroupBatches( ITriRenderBatchAccumulator* batche } } -void EveChildBehaviorSystem::GetGroupBoosterBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Tr2PerObjectData* perObjectData, BehaviorGroup* group ) +void EveChildBehaviorSystem::GetGroupBoosterBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, BehaviorGroup* group ) { if( batchType != TRIBATCHTYPE_ADDITIVE ) { @@ -374,24 +375,23 @@ void EveChildBehaviorSystem::GetGroupBoosterBatches( ITriRenderBatchAccumulator* return; } - auto batch = group->GetBooster()->GetBatch( - &m_boosterInstanceBuffer, - m_startInstanceValues[group->GetGroupIndexIndicator()], - m_boosterStride, + auto batch = group->GetBooster()->GetBatch( + &m_boosterInstanceBuffer, + m_startInstanceValues[group->GetGroupIndexIndicator()], + m_boosterStride, uint32_t( group->GetSize() ) ); batch.SetPerObjectData( perObjectData ); batches->Commit( batch ); } -void EveChildBehaviorSystem::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) +void EveChildBehaviorSystem::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { - if ( !m_display ) + if( !m_display ) { return; } - if ( !m_shipInstanceBuffer.IsValid() || !m_boosterInstanceBuffer.IsValid() ) + if( !m_shipInstanceBuffer.IsValid() || !m_boosterInstanceBuffer.IsValid() ) { return; } @@ -399,21 +399,20 @@ void EveChildBehaviorSystem::GetBatches( ITriRenderBatchAccumulator* batches, Tr // If all groups are not visble -> do not render bool isAnyGroupVisible = std::any_of( m_behaviorGroups.begin(), m_behaviorGroups.end(), - []( BehaviorGroup* group ) - { return group->IsGroupVisible() == true; } ); - if ( !isAnyGroupVisible ) + []( BehaviorGroup* group ) { return group->IsGroupVisible() == true; } ); + if( !isAnyGroupVisible ) { return; } - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { auto group = *it; - //same is 1 if you are far away and should only see sprites and 0 for only ships ( ]0-1[ -> both ) + //same is 1 if you are far away and should only see sprites and 0 for only ships ( ]0-1[ -> both ) const float same = group->AllTheSame(); - if ( same != 1 ) + if( same != 1 ) { GetGroupBatches( batches, batchType, perObjectData, group->GetMesh(), group ); GetGroupBoosterBatches( batches, batchType, perObjectData, group ); @@ -425,12 +424,12 @@ void EveChildBehaviorSystem::GetBatches( ITriRenderBatchAccumulator* batches, Tr bool EveChildBehaviorSystem::HasTransparentBatches() { bool hasTransparentBatches = false; - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - auto mesh = (*it)->GetMesh(); - if ( m_display && mesh ) + auto mesh = ( *it )->GetMesh(); + if( m_display && mesh ) { - if ( !(mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty()) ) + if( !( mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty() ) ) { hasTransparentBatches = true; break; @@ -458,7 +457,7 @@ Tr2PerObjectData* EveChildBehaviorSystem::GetPerObjectData( ITriRenderBatchAccum { EveChildBehaviorSystemPerObjectData* perObjectData = accumulator->Allocate(); - if ( !perObjectData ) + if( !perObjectData ) { return nullptr; } @@ -474,24 +473,24 @@ void EveChildBehaviorSystem::GetDebugOptions( Tr2DebugRendererOptions& options ) { options.insert( "SplineTunnels" ); - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - (*it)->GetDebugOptions( options ); + ( *it )->GetDebugOptions( options ); } } void EveChildBehaviorSystem::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - (*it)->RenderDebugInfo( renderer, EveChildTransform::m_worldTransform ); + ( *it )->RenderDebugInfo( renderer, EveChildTransform::m_worldTransform ); } - if (renderer.HasOption( this, "SplineTunnels" )) + if( renderer.HasOption( this, "SplineTunnels" ) ) { - for (auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it) + for( auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it ) { - (*it)->RenderDebugInfo( renderer, EveChildTransform::m_worldTransform ); + ( *it )->RenderDebugInfo( renderer, EveChildTransform::m_worldTransform ); } } } @@ -510,18 +509,18 @@ void EveChildBehaviorSystem::UpdateTunnelRegistry() { m_tunnels.clear(); int id = 0; - for (auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it) + for( auto it = begin( m_splineTunnels ); it != end( m_splineTunnels ); ++it ) { - auto group = (*it)->GetTunnels(); - for (auto tunnel = begin( *group ); tunnel != end( *group ); ++tunnel) + auto group = ( *it )->GetTunnels(); + for( auto tunnel = begin( *group ); tunnel != end( *group ); ++tunnel ) { - (*tunnel).tunnelID = id; + ( *tunnel ).tunnelID = id; id++; - m_tunnels.push_back(*tunnel); + m_tunnels.push_back( *tunnel ); } } - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { ( *it )->InitializeGeometryResource(); } @@ -532,12 +531,12 @@ void EveChildBehaviorSystem::ChangeBufferInstanceCount() USE_MAIN_THREAD_RENDER_CONTEXT(); size_t temp = 0; - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { - temp += (*it)->GetSize(); + temp += ( *it )->GetSize(); } - unsigned int numAgents = static_cast(temp); + unsigned int numAgents = static_cast( temp ); m_instanceCount = numAgents; // TODO: Review m_instanceCount @@ -547,24 +546,21 @@ void EveChildBehaviorSystem::ChangeBufferInstanceCount() m_instanceCount++; } - CR_RETURN(m_shipInstanceBuffer.Create( + CR_RETURN( m_shipInstanceBuffer.Create( m_shipStride, // 12 * sizeof( float ) m_instanceCount, // Number of instances Tr2GpuUsage::VERTEX_BUFFER, // VERTEX_BUFFER Tr2CpuUsage::WRITE_OFTEN, // WRITE_OFTEN nullptr, - renderContext - )); + renderContext ) ); - CR_RETURN(m_boosterInstanceBuffer.Create( + CR_RETURN( m_boosterInstanceBuffer.Create( m_boosterStride, // 12 * sizeof( float ) m_instanceCount, // Number of instances Tr2GpuUsage::VERTEX_BUFFER, // VERTEX_BUFFER Tr2CpuUsage::WRITE_OFTEN, // WRITE_OFTEN nullptr, - renderContext - )); - + renderContext ) ); } // for validation and objects interacting with the shader attributes @@ -587,11 +583,11 @@ void EveChildBehaviorSystem::UpdateAsyncronous( const EveUpdateContext& updateCo { Matrix localToWorldTransform; - if ( nullptr != params.childParent ) + if( nullptr != params.childParent ) { params.childParent->GetLocalToWorldTransform( localToWorldTransform ); } - else if ( nullptr != params.spaceObjectParent ) + else if( nullptr != params.spaceObjectParent ) { params.spaceObjectParent->GetLocalToWorldTransform( localToWorldTransform ); params.spaceObjectParent->GetPerObjectStructs( m_vsData, m_psData ); @@ -663,7 +659,7 @@ void EveChildBehaviorSystem::UpdateVisibility( const EveUpdateContext& updateCon return; } - for ( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) + for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { ( *it )->UpdateVisibility( updateContext, m_worldTransform ); } @@ -714,7 +710,7 @@ void EveChildBehaviorSystem::UnRegisterComponents() } } -void EveChildBehaviorSystem::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) +void EveChildBehaviorSystem::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { for( auto it = begin( m_behaviorGroups ); it != end( m_behaviorGroups ); ++it ) { @@ -739,5 +735,3 @@ Matrix EveChildBehaviorSystem::GetWorldTransform() { return m_worldTransform; } - - diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h index ca172d668..a5a4b4fe3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem.h @@ -38,7 +38,8 @@ BLUE_CLASS( EveChildBehaviorSystem ) : EveChildBehaviorSystem( IRoot* lockobj = nullptr ); ~EveChildBehaviorSystem(); - enum RenderType { + enum RenderType + { RENDER_SHIP, RENDER_BOOSTER, @@ -49,42 +50,43 @@ BLUE_CLASS( EveChildBehaviorSystem ) : // EveChildMesh void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); // IInitialize bool Initialize(); - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const struct IList* theList - ); + const struct IList* theList ); ///////////////////////////////////////////////////////////////////////////////////// // Tr2DeviceResource - void ReleaseResources( TriStorage s ) {} + void ReleaseResources( TriStorage s ) + { + } const char* GetName() const; void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); void ChangeLOD( Tr2Lod lod ); - + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; Matrix GetWorldTransform(); @@ -102,12 +104,11 @@ BLUE_CLASS( EveChildBehaviorSystem ) : bool GetInstanceBufferBoundingBox( unsigned int bufferIndex, Vector3& minBounds, Vector3& maxBounds ) const; bool HasTransparentBatches(); float GetSortValue(); - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); std::vector> GetVertexElementAddedThroughCode() const; private: - bool OnPrepareResources(); void PassInVertexesToBehaviorGroups(); void PassInTunnelFunctionsToBehaviorGroups(); @@ -117,20 +118,17 @@ BLUE_CLASS( EveChildBehaviorSystem ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); - + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); + void UpdateTunnelRegistry(); ///////////////////////////////////////////////////////////////////////////////////// // EveChildBehaviorSystem void UpdateAgents( const float deltaTime ); - void UpdateBuffer( Tr2RenderContext& renderContext ); - void GetGroupBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Tr2PerObjectData* perObjectData, - Tr2MeshPtr mesh, BehaviorGroup* group ); - void GetGroupBoosterBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Tr2PerObjectData* perObjectData, BehaviorGroup* group ); + void UpdateBuffer( Tr2RenderContext & renderContext ); + void GetGroupBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2MeshPtr mesh, BehaviorGroup* group ); + void GetGroupBoosterBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, BehaviorGroup* group ); EveSpaceObjectPSData m_psData; diff --git a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp index 07ef92980..7737739c7 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBehaviorSystem_Blue.cpp @@ -25,11 +25,10 @@ const Be::ClassInfo* EveChildBehaviorSystem::ExposeToBlue() MAP_ATTRIBUTE( "behaviorGroups", m_behaviorGroups, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "splineTunnels", m_splineTunnels, "", Be::READ | Be::PERSIST | Be::NOTIFY ) - MAP_METHOD_AND_WRAP( - "GetVertexElementAddedThroughCode", - GetVertexElementAddedThroughCode, - "for validation and objects requiring vertex elements added to the shader through code\n:jessica-hidden: True" - ) - + MAP_METHOD_AND_WRAP( + "GetVertexElementAddedThroughCode", + GetVertexElementAddedThroughCode, + "for validation and objects requiring vertex elements added to the shader through code\n:jessica-hidden: True" ) + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp index 9fbfa3d52..ddb989ae1 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.cpp @@ -192,7 +192,7 @@ void EveChildBulletStorm::Rebuild() PerInstanceVertex* v = &verts[0]; for( unsigned int i = 0; i < (unsigned int)locatorList->size(); ++i ) { - const Locator& locator = (*locatorList)[i]; + const Locator& locator = ( *locatorList )[i]; // per stream start Vector3 startPosOS = locator.position; @@ -240,10 +240,10 @@ void EveChildBulletStorm::StartEffect() // -------------------------------------------------------------------------------- // Description: -// This stops bullets appearing, but keeps the bullets that have been generated, +// This stops bullets appearing, but keeps the bullets that have been generated, // so the effects seems to be stopping // -------------------------------------------------------------------------------- -void EveChildBulletStorm::StopEffect() +void EveChildBulletStorm::StopEffect() { m_clipShereMul = -1.0f; m_clipSphere = 0.0f; @@ -287,7 +287,7 @@ void EveChildBulletStorm::UpdateAsyncronous( const EveUpdateContext& updateConte m_targetBlobs[i] = Vector4( targetPosWS, max( targetSize.w, BULLETSTORM_MIN_TARGETSIZE ) ); } - + // keep the radius of the soutrceobject here if( m_sourceObject ) { @@ -301,7 +301,7 @@ void EveChildBulletStorm::UpdateAsyncronous( const EveUpdateContext& updateConte // update the start/stop mechanic if( m_changingClipSphere ) { - m_clipSphere += m_clipShereMul * m_speed * updateContext.GetDeltaT() / (m_sourceRadius + m_range); + m_clipSphere += m_clipShereMul * m_speed * updateContext.GetDeltaT() / ( m_sourceRadius + m_range ); m_clipSphere = std::max( -1.0f, std::min( 1.0f, m_clipSphere ) ); m_changingClipSphere = std::abs( m_clipSphere ) != 1; } @@ -399,7 +399,7 @@ Tr2PerObjectData* EveChildBulletStorm::GetPerObjectData( ITriRenderBatchAccumula } perObjectData->m_worldTransform = XMMatrixTranspose( m_worldTransform ); - perObjectData->m_effectInfo = Vector4( float(m_targetObjects.size()), m_sourceRadius + m_range, m_clipSphere, m_speed ); + perObjectData->m_effectInfo = Vector4( float( m_targetObjects.size() ), m_sourceRadius + m_range, m_clipSphere, m_speed ); for( size_t i = 0; i < m_targetBlobs.size(); ++i ) { diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h index c8e5aa4be..f78c16289 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm.h @@ -45,38 +45,41 @@ BLUE_CLASS( EveChildBulletStorm ) : EveChildBulletStorm( IRoot* lockobj = NULL ); ~EveChildBulletStorm(); - + ///////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild const char* GetName() const; void SetName( const char* name ); - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) {} - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) + { + } + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable bool HasTransparentBatches(); - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); float GetSortValue(); - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp index 55476a953..86ba7b4a1 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildBulletStorm_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveChildBulletStorm ); const Be::ClassInfo* EveChildBulletStorm::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildBulletStorm, "" ) - MAP_INTERFACE( EveChildBulletStorm ) + EXPOSURE_BEGIN( EveChildBulletStorm, "" ) + MAP_INTERFACE( EveChildBulletStorm ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( INotify ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp index 752d7b4e4..c80462793 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.cpp @@ -24,15 +24,16 @@ class EveChildCloudPerObjectData : public Tr2PerObjectData public: virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { - static const unsigned mask = - ( 1 << VERTEX_SHADER ) | - SHADER_TYPE_EXISTS( COMPUTE_SHADER ) | - SHADER_TYPE_EXISTS( GEOMETRY_SHADER ) | - SHADER_TYPE_EXISTS( HULL_SHADER ) | - SHADER_TYPE_EXISTS( DOMAIN_SHADER) ; - FillAndSetConstants( + static const unsigned mask = + ( 1 << VERTEX_SHADER ) | + SHADER_TYPE_EXISTS( COMPUTE_SHADER ) | + SHADER_TYPE_EXISTS( GEOMETRY_SHADER ) | + SHADER_TYPE_EXISTS( HULL_SHADER ) | + SHADER_TYPE_EXISTS( DOMAIN_SHADER ); + FillAndSetConstants( *buffers[Tr2RenderContextEnum::VERTEX_SHADER], - &m_data, sizeof( m_data ), + &m_data, + sizeof( m_data ), mask, Tr2Renderer::GetPerObjectVSStartRegister(), renderContext ); @@ -60,12 +61,12 @@ class EveChildCloudPerObjectData : public Tr2PerObjectData // -------------------------------------------------------------------------------------- // Description: -// Calculates axis aligned bounding box of a given box in projection space. The +// Calculates axis aligned bounding box of a given box in projection space. The // function projects all the vertices, discards vertices outside frusum (ignoring far -// plane), clips edges with near plane and computes AABB clipped to [-1, 1] range. +// plane), clips edges with near plane and computes AABB clipped to [-1, 1] range. // Function assumes non-orthographic projection. // -------------------------------------------------------------------------------------- -void GetProjectedCubeBounds( AxisAlignedBoundingBox& box, const Matrix& worldView, const Matrix& proj, float nearPlane, const Vector3& min, const Vector3& max ) +void GetProjectedCubeBounds( AxisAlignedBoundingBox& box, const Matrix& worldView, const Matrix& proj, float nearPlane, const Vector3& min, const Vector3& max ) { Vector3 sides[6][4] = { { @@ -162,8 +163,8 @@ void GetProjectedCubeBounds( AxisAlignedBoundingBox& box, const Matrix& worldVi -EveChildCloud::EveChildCloud( IRoot* lockobj ) - :m_localTransform( IdentityMatrix() ), +EveChildCloud::EveChildCloud( IRoot* lockobj ) : + m_localTransform( IdentityMatrix() ), m_worldTransform( IdentityMatrix() ), m_scaling( 1.0f, 1.0f, 1.0f ), m_translation( 0.f, 0.f, 0.f ), @@ -179,7 +180,7 @@ EveChildCloud::EveChildCloud( IRoot* lockobj ) m_minScreenSize( 0.0f ), m_cellScreenSize( 0.3f ), m_currentIB( 0 ), - m_lastLodFactor(1.0f) + m_lastLodFactor( 1.0f ) { PrepareResources(); } @@ -243,8 +244,8 @@ bool EveChildCloud::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery quer return true; } -void EveChildCloud::GetLocalToWorldTransform( Matrix &transform ) const -{ +void EveChildCloud::GetLocalToWorldTransform( Matrix& transform ) const +{ transform = m_worldTransform; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud.h b/trinity/Eve/SpaceObject/Children/EveChildCloud.h index eea5ec0a9..f6c107e28 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud.h @@ -30,7 +30,7 @@ BLUE_CLASS( EveChildCloud ) : public: EXPOSE_TO_BLUE(); - EveChildCloud(IRoot* lockobj = NULL); + EveChildCloud( IRoot* lockobj = NULL ); ~EveChildCloud(); ////////////////////////////////////////////////////////////////////////// @@ -39,7 +39,7 @@ BLUE_CLASS( EveChildCloud ) : ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild @@ -47,19 +47,21 @@ BLUE_CLASS( EveChildCloud ) : virtual void SetName( const char* name ); virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - virtual void GetLocalToWorldTransform( Matrix &transform ) const; + virtual void GetLocalToWorldTransform( Matrix & transform ) const; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - virtual void GetRenderables( std::vector& renderables ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) {} + virtual void GetRenderables( std::vector & renderables ); + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) + { + } virtual void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches(); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource @@ -67,8 +69,8 @@ BLUE_CLASS( EveChildCloud ) : ////////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); private: bool OnPrepareResources(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp index 087181796..3e48803ae 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.cpp @@ -895,11 +895,11 @@ void EveChildCloud2::SetupShadowFrustum( ShadowInfo& shadowInfo, Vector3 sunDir aabb.m_max.z += 2500000.f; m_lightViewProj = lightView * OrthoOffCenterMatrix( aabb.m_max.x, aabb.m_min.x, aabb.m_max.y, aabb.m_min.y, -aabb.m_max.z, -aabb.m_min.z ); - + // create shadow frustum out from lightView, aabb.min, aabb.max TriFrustumOrtho shadowFrustum; shadowFrustum.DeriveFrustum( lightView, aabb.m_min, aabb.m_max ); - + shadowInfo.aabbMax = aabb.m_max; shadowInfo.lightViewProj = m_lightViewProj; shadowInfo.shadowFrustum = shadowFrustum; diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h index 29f716fb6..9dce9cbbb 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2.h +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2.h @@ -41,7 +41,7 @@ BLUE_CLASS( EveChildCloud2 ) : public: EXPOSE_TO_BLUE(); - EveChildCloud2(IRoot* lockobj = NULL); + EveChildCloud2( IRoot* lockobj = NULL ); ~EveChildCloud2(); ////////////////////////////////////////////////////////////////////////// @@ -50,8 +50,8 @@ BLUE_CLASS( EveChildCloud2 ) : ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); - + virtual bool OnModified( Be::Var * value ); + ////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; @@ -62,18 +62,20 @@ BLUE_CLASS( EveChildCloud2 ) : virtual void SetName( const char* name ) override; virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - virtual void GetLocalToWorldTransform( Matrix& transform ) const override; + virtual void GetLocalToWorldTransform( Matrix & transform ) const override; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - virtual void GetRenderables( std::vector& renderables ) override; - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; + virtual void GetRenderables( std::vector & renderables ) override; + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override { } - virtual void ChangeLOD( Tr2Lod lod ) override {} - + virtual void ChangeLOD( Tr2Lod lod ) override + { + } + ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2VolumetricRenderable @@ -81,7 +83,7 @@ BLUE_CLASS( EveChildCloud2 ) : void GetVolumetricBatches( const TriFrustum& frustum, ITriRenderBatchAccumulator* batches ) override; bool UpdateVolumetricLightmap( Tr2RenderContext & renderContext ) override; void SetSceneInformation( const SceneInformation& sceneInformation ) override; - void GetVolumetricShadowBatches( ITriRenderBatchAccumulator* batches ) override; + void GetVolumetricShadowBatches( ITriRenderBatchAccumulator * batches ) override; void GetVolumetricShadowInfo( ShadowInfo & shadowInfo, Vector3 sunDir ) override; bool PrepareCloudShadowMap( Tr2RenderContext & renderContext ) override; void SetCloudShadowMapHandle() override; @@ -100,15 +102,15 @@ BLUE_CLASS( EveChildCloud2 ) : ////////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); void ClearVariableStore(); void RegisterComponents() override; void SetupShadowFrustum( ShadowInfo & shadowInfo, Vector3 sunDir ); - + bool IsLightmapDirty() const; void MarkLightmapDirty( bool ); @@ -143,10 +145,9 @@ BLUE_CLASS( EveChildCloud2 ) : }; private: - bool OnPrepareResources(); - void PopulatePerObjectData( PerObjectData& data, float screenSize ) const; - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator, float screenSize ); + void PopulatePerObjectData( PerObjectData & data, float screenSize ) const; + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator, float screenSize ); void CreateEmptyLightMap(); bool HasValidTransform() const; @@ -214,15 +215,15 @@ BLUE_CLASS( EveChildCloud2 ) : Vector3 m_mapOffsets[3]; const Vector3 m_unitCube[8] = { - //The unit cube in DirectX is from( -1, -1, 0 ) to ( 1, 1, 1 ) - Vector3( -1, -1, 0 ), // vertex 0 - Vector3( -1, 1, 0 ), // vertex 1 - Vector3( 1, 1, 0 ), // etc.. - Vector3( 1, -1, 0 ), - Vector3( -1, -1, 1 ), - Vector3( -1, 1, 1 ), - Vector3( 1, 1, 1 ), - Vector3( 1, -1, 1 ) + //The unit cube in DirectX is from( -1, -1, 0 ) to ( 1, 1, 1 ) + Vector3( -1, -1, 0 ), // vertex 0 + Vector3( -1, 1, 0 ), // vertex 1 + Vector3( 1, 1, 0 ), // etc.. + Vector3( 1, -1, 0 ), + Vector3( -1, -1, 1 ), + Vector3( -1, 1, 1 ), + Vector3( 1, 1, 1 ), + Vector3( 1, -1, 1 ) }; Matrix m_lightViewProj; diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp index 0dc951978..c4245e970 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud2_Blue.cpp @@ -9,8 +9,8 @@ BLUE_DEFINE( EveChildCloud2 ); const Be::ClassInfo* EveChildCloud2::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildCloud2, "Cloud space object child" ) - MAP_INTERFACE( EveChildCloud2 ) + EXPOSURE_BEGIN( EveChildCloud2, "Cloud space object child" ) + MAP_INTERFACE( EveChildCloud2 ) MAP_INTERFACE( ITr2VolumetricRenderable ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -51,10 +51,10 @@ const Be::ClassInfo* EveChildCloud2::ExposeToBlue() m_shadowMapDS, "Depth stencil used for shadows.", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( - "minScreenSize", - m_minScreenSize, - "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", + MAP_ATTRIBUTE( + "minScreenSize", + m_minScreenSize, + "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "textureTiling", m_mapTiling[0], "Tiling for the main density/temerature texture. Used for camera-attached clouds.\n:jessica-group: Tiling", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp index dd0ad0bc5..be2b2c06b 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildCloud_Blue.cpp @@ -8,8 +8,8 @@ BLUE_DEFINE( EveChildCloud ); const Be::ClassInfo* EveChildCloud::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildCloud, "Cloud space object child" ) - MAP_INTERFACE( EveChildCloud ) + EXPOSURE_BEGIN( EveChildCloud, "Cloud space object child" ) + MAP_INTERFACE( EveChildCloud ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -28,10 +28,10 @@ const Be::ClassInfo* EveChildCloud::ExposeToBlue() MAP_ATTRIBUTE( "boundingSphere", m_boundingSphere, "Used for culling", Be::READ ) MAP_ATTRIBUTE( "preTesselationLevel", m_preTesselationLevel, "Number of triangles per width/heigth", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "volume", m_volume, "Shape volume texture editor", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minScreenSize", - m_minScreenSize, - "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", + MAP_ATTRIBUTE( + "minScreenSize", + m_minScreenSize, + "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "cellScreenSize", m_cellScreenSize, "Target size of a single cell in a grid on the screen (in pixels)", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp index 45d1e22c7..a0641cb6b 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.cpp @@ -40,9 +40,9 @@ EveChildContainer::EveChildContainer( IRoot* lockobj ) : m_activationStrength( 1.0f ) { m_controllers.SetNotify( this ); - m_objects.SetNotify( this ); - m_attachments.SetNotify( this ); - m_lights.SetNotify( this ); + m_objects.SetNotify( this ); + m_attachments.SetNotify( this ); + m_lights.SetNotify( this ); memset( &m_vsData, 0, sizeof( EveSpaceObjectVSData ) ); memset( &m_psData, 0, sizeof( EveSpaceObjectPSData ) ); @@ -94,7 +94,6 @@ void EveChildContainer::SetMute( bool isMute ) m_mute = isMute; MuteChildren(); } - } void EveChildContainer::MuteChildren() @@ -172,7 +171,7 @@ void EveChildContainer::OnListModified( long event, ssize_t key, ssize_t key2, I break; } } - } + } if( list == &m_attachments && ( event & BELIST_LOADING ) == 0 ) { @@ -207,26 +206,26 @@ void EveChildContainer::OnListModified( long event, ssize_t key, ssize_t key2, I } } - if( list == &m_objects && (event & BELIST_EVENTMASK) == BELIST_INSERTED ) - { - if( m_inheritProperties ) - { - if( IEveInheritPropertiesOwnerPtr obj = BlueCastPtr( value) ) + if( list == &m_objects && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED ) + { + if( m_inheritProperties ) + { + if( IEveInheritPropertiesOwnerPtr obj = BlueCastPtr( value ) ) { obj->SetInheritProperties( m_inheritProperties->GetProperties() ); } - } - } - - if( list == &m_lights && (event & BELIST_EVENTMASK) == BELIST_INSERTED ) - { - if( m_inheritProperties ) - { - if( IEveInheritPropertiesOwnerPtr light = BlueCastPtr( value) ) + } + } + + if( list == &m_lights && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED ) + { + if( m_inheritProperties ) + { + if( IEveInheritPropertiesOwnerPtr light = BlueCastPtr( value ) ) { light->SetInheritProperties( m_inheritProperties->GetProperties() ); } - } + } } if( list == &m_lights ) @@ -261,7 +260,7 @@ void EveChildContainer::RegisterComponents() auto registry = this->GetComponentRegistry(); if( registry && m_display && IsUpdating() ) { - if ( !m_lights.empty() ) + if( !m_lights.empty() ) { registry->RegisterComponent( this ); } @@ -270,7 +269,7 @@ void EveChildContainer::RegisterComponents() { if( EveEntityPtr entity = BlueCastPtr( *it ) ) { - entity->Register( registry ); + entity->Register( registry ); } } @@ -319,7 +318,7 @@ void EveChildContainer::SetShaderOption( const BlueSharedString& name, const Blu child->SetShaderOption( name, value ); } - for( auto& attachment: m_attachments ) + for( auto& attachment : m_attachments ) { attachment->SetShaderOption( name, value ); } @@ -400,12 +399,12 @@ void EveChildContainer::UpdateVisibility( const EveUpdateContext& updateContext, const Float4x3* bones = nullptr; if( m_animationOwner && m_animationOwner->GetAnimationController() ) { - Tr2GrannyAnimationUtils::GetBoneList( m_animationOwner->GetAnimationController(), bones, boneCount ); + Tr2GrannyAnimationUtils::GetBoneList( m_animationOwner->GetAnimationController(), bones, boneCount ); } for( auto it = begin( m_attachments ); it != end( m_attachments ); ++it ) { - ( *it )->UpdateVisibility( updateContext, m_worldTransform, bones, boneCount); + ( *it )->UpdateVisibility( updateContext, m_worldTransform, bones, boneCount ); } } } @@ -458,7 +457,7 @@ void EveChildContainer::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer { ( *it )->RegisterWithQuadRenderer( quadRenderer ); } - for( auto& it: m_attachments ) + for( auto& it : m_attachments ) { it->RegisterWithQuadRenderer( quadRenderer ); } @@ -491,7 +490,7 @@ void EveChildContainer::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2Qu { it->AddToQuadRenderer( quadRenderer, m_worldTransform, 1.0, 0.0, bones, boneCount ); } - } + } } void EveChildContainer::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -589,7 +588,7 @@ void EveChildContainer::DoUpdateAsyncronous( const EveUpdateContext& updateConte m_psData.worldTransformLast = m_vsData.worldTransformLast; m_psData.invWorldTransform = m_vsData.invWorldTransform; } - + EveChildUpdateParams newParams = params; newParams.isVisible &= m_display; newParams.childParent = this; @@ -629,7 +628,7 @@ void EveChildContainer::DoUpdateAsyncronous( const EveUpdateContext& updateConte ( *it )->UpdateAsyncronous( updateContext, newParams ); } - for( auto it = m_lights.begin(); it != m_lights.end(); ++it) + for( auto it = m_lights.begin(); it != m_lights.end(); ++it ) { ( *it )->SetBoneMatrix( bones, boneCount ); } @@ -866,7 +865,7 @@ void EveChildContainer::GetDebugOptions( Tr2DebugRendererOptions& options ) ( *it )->GetDebugOptions( options ); } - for( auto& it: m_attachments) + for( auto& it : m_attachments ) { it->GetDebugOptions( options ); } @@ -909,7 +908,7 @@ void EveChildContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { Tr2GrannyAnimationUtils::GetBoneList( m_animationOwner->GetAnimationController(), bones, boneCount ); } - for( auto& it: m_attachments ) + for( auto& it : m_attachments ) { it->RenderDebugInfo( renderer, m_worldTransform, bones, boneCount ); } @@ -924,7 +923,7 @@ void EveChildContainer::AddController( ITr2Controller* controller ) void EveChildContainer::SetControllerVariable( const char* name, float value ) { auto found = find_if( begin( m_controllerVariables ), end( m_controllerVariables ), [name]( auto& x ) { return x.first == name; } ); - if ( found == end( m_controllerVariables ) ) + if( found == end( m_controllerVariables ) ) { m_controllerVariables.push_back( { name, value } ); } @@ -1023,21 +1022,21 @@ void EveChildContainer::SetInheritProperties( const Color* colorSet ) } m_inheritProperties->SetProperties( colorSet ); - for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) - { - if( IEveInheritPropertiesOwnerPtr cast = BlueCastPtr(*it) ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + { + if( IEveInheritPropertiesOwnerPtr cast = BlueCastPtr( *it ) ) { cast->SetInheritProperties( colorSet ); } - } + } - for( auto it = m_lights.begin(); it != m_lights.end(); it++ ) - { + for( auto it = m_lights.begin(); it != m_lights.end(); it++ ) + { if( IEveInheritPropertiesOwnerPtr light = BlueCastPtr( *it ) ) { light->SetInheritProperties( colorSet ); } - } + } } ITr2AudEmitterPtr EveChildContainer::FindSoundEmitter( const char* name ) @@ -1066,7 +1065,7 @@ ITr2AudEmitterPtr EveChildContainer::FindSoundEmitter( const char* name ) return nullptr; } -void EveChildContainer::AddObserver( TriObserverLocalPtr observer ) +void EveChildContainer::AddObserver( TriObserverLocalPtr observer ) { m_observers.Append( observer ); } @@ -1103,13 +1102,13 @@ void EveChildContainer::AddTransformModifier( IEveChildTransformModifier* modifi m_transformModifiers.Append( modifier ); } -void EveChildContainer::SetProceduralContainerVariable( const char *name, float value ) +void EveChildContainer::SetProceduralContainerVariable( const char* name, float value ) { - for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) - { - auto child = *it; - child->SetProceduralContainerVariable( name, value ); - } + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + { + auto child = *it; + child->SetProceduralContainerVariable( name, value ); + } } void EveChildContainer::SetAnimationOwner( ITr2GrannyAnimationOwner* animationOwner ) @@ -1136,7 +1135,7 @@ void EveChildContainer::GetBatches( ITriRenderBatchAccumulator* batches, TriBatc { if( m_display && reason == TR2RENDERREASON_NORMAL && m_activationStrength != 0.0 ) { - for( auto& it : m_attachments) + for( auto& it : m_attachments ) { it->GetBatches( batches, batchType, perObjectData, reason ); } @@ -1159,9 +1158,9 @@ uint32_t EveChildContainer::GetPerObjectDataSize( Tr2RenderContextEnum::ShaderTy { return sizeof( m_vsData ); } - else if( shaderType == Tr2RenderContextEnum::PIXEL_SHADER) + else if( shaderType == Tr2RenderContextEnum::PIXEL_SHADER ) { - return sizeof( m_psData ); + return sizeof( m_psData ); } return 0; } @@ -1192,7 +1191,7 @@ Tr2PerObjectData* EveChildContainer::GetPerObjectData( ITriRenderBatchAccumulato } m_vsData.boneOffsets[0] = m_boneOffsets.GetCurrentFrameOffset(); m_vsData.boneOffsets[1] = m_boneOffsets.GetPreviousFrameOffset(); - + Tr2PerObjectDataWithPersistentBuffers* perObjectData = accumulator->Allocate>(); if( !perObjectData ) { diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer.h b/trinity/Eve/SpaceObject/Children/EveChildContainer.h index c3752cf1e..e8bdeac85 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer.h @@ -69,14 +69,14 @@ BLUE_CLASS( EveChildContainer ) : // IEveSpaceObjectChild void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; - void AddTransformModifier( IEveChildTransformModifier* modifier ) override; - void SetProceduralContainerVariable( const char* name, float value ) override; + void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + void SetProceduralContainerVariable( const char* name, float value ) override; ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -115,20 +115,20 @@ BLUE_CLASS( EveChildContainer ) : void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, Matrix& parentTransform ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ); ////////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; void SetOrigin( Origin origin ); @@ -146,15 +146,15 @@ BLUE_CLASS( EveChildContainer ) : void PlayAllCurveSets() override; void StopAllCurveSets() override; - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); - void GetWorldVelocity( Vector3& velocity ) const; + void GetWorldVelocity( Vector3 & velocity ) const; void SetInheritProperties( const Color* colorSet ) override; float GetOwnerMaxSpeed() const; - void SetAnimationOwner( ITr2GrannyAnimationOwner* animationOwner ); + void SetAnimationOwner( ITr2GrannyAnimationOwner * animationOwner ); enum DisplayQualityModifier { @@ -174,7 +174,7 @@ BLUE_CLASS( EveChildContainer ) : PIEveSpaceObjectChildVector m_objects; protected: - void DoUpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ); + void DoUpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void MuteChildren(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp index a53a8bfa3..9e345bbf3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildContainer_Blue.cpp @@ -4,26 +4,24 @@ #include "EveChildContainer.h" -Be::VarChooser EveSpaceObjectChildOriginChooser[] = -{ +Be::VarChooser EveSpaceObjectChildOriginChooser[] = { { "SPACE", BeCast( IEveSpaceObjectChild::SPACE ), "Origin in Space" }, { "SOF", BeCast( IEveSpaceObjectChild::SOF ), "Origin in SOF" }, { 0 } }; BLUE_REGISTER_ENUM_EX( "EveSpaceObjectChildOrigin", IEveSpaceObjectChild::Origin, EveSpaceObjectChildOriginChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser EveChildContainerDataSetShaderChooser[] = -{ - { "None_", BeCast(EveChildContainer::SHADER_ALL), "Visible to users with all shader settings" }, - { "Medium_and_High", BeCast(EveChildContainer::SHADER_HIGHMID), "Visible for users with shader settings on Medium or High" }, - { "Low_and_Medium", BeCast(EveChildContainer::SHADER_LOWMID), "Visible for users with shader settings on Low or Medium" }, - { "High", BeCast(EveChildContainer::SHADER_HIGH), "Only visible for users with shader settings on High" }, - { "Medium", BeCast(EveChildContainer::SHADER_MED), "Only visible for users with shader settings on Medium" }, - { "Low", BeCast(EveChildContainer::SHADER_LOW), "Only visible for users with shader settings on Low" }, - { "Only Reflections", BeCast(EveChildContainer::ONLY_REFLECTIONS), "Only visible in the reflections" }, +Be::VarChooser EveChildContainerDataSetShaderChooser[] = { + { "None_", BeCast( EveChildContainer::SHADER_ALL ), "Visible to users with all shader settings" }, + { "Medium_and_High", BeCast( EveChildContainer::SHADER_HIGHMID ), "Visible for users with shader settings on Medium or High" }, + { "Low_and_Medium", BeCast( EveChildContainer::SHADER_LOWMID ), "Visible for users with shader settings on Low or Medium" }, + { "High", BeCast( EveChildContainer::SHADER_HIGH ), "Only visible for users with shader settings on High" }, + { "Medium", BeCast( EveChildContainer::SHADER_MED ), "Only visible for users with shader settings on Medium" }, + { "Low", BeCast( EveChildContainer::SHADER_LOW ), "Only visible for users with shader settings on Low" }, + { "Only Reflections", BeCast( EveChildContainer::ONLY_REFLECTIONS ), "Only visible in the reflections" }, { 0 } }; -BLUE_REGISTER_ENUM_EX("SetShader", EveChildContainer::DisplayQualityModifier, EveChildContainerDataSetShaderChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE); +BLUE_REGISTER_ENUM_EX( "SetShader", EveChildContainer::DisplayQualityModifier, EveChildContainerDataSetShaderChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( EveChildContainer ); @@ -31,8 +29,8 @@ BLUE_DEFINE( EveChildContainer ); const Be::ClassInfo* EveChildContainer::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildContainer, "" ) - MAP_INTERFACE( EveChildContainer ) + EXPOSURE_BEGIN( EveChildContainer, "" ) + MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( EveEntity ) MAP_INTERFACE( ITr2LightOwner ) MAP_INTERFACE( IEveSpaceObjectChild ) @@ -57,20 +55,20 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() MAP_ATTRIBUTE( "curveSets", m_curveSets, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER("displayFilter", m_displayFilter, "Choose the shader quality settings for users you'd like to display childs to", Be::READWRITE | Be::PERSIST | Be::ENUM | Be::NOTIFY, EveChildContainerDataSetShaderChooser ) - MAP_PROPERTY_READONLY("isRendering", IsRendering, "Are the current childs being rendered with the current filter and shader settings") - MAP_PROPERTY_READONLY("isUpdating", IsUpdating, "Are the current childs being updated with the current filter and shader settings") + MAP_ATTRIBUTE_WITH_CHOOSER( "displayFilter", m_displayFilter, "Choose the shader quality settings for users you'd like to display childs to", Be::READWRITE | Be::PERSIST | Be::ENUM | Be::NOTIFY, EveChildContainerDataSetShaderChooser ) + MAP_PROPERTY_READONLY( "isRendering", IsRendering, "Are the current childs being rendered with the current filter and shader settings" ) + MAP_PROPERTY_READONLY( "isUpdating", IsUpdating, "Are the current childs being updated with the current filter and shader settings" ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "Should this container ignore the parent rotation.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "useStaticScale", m_useStaticScale, "Should this container ignore the parent scale.", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "observers", m_observers, "List of audio observers", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "lights", m_lights, "List of dynamic lights", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "fxAttributes", m_fxAttributes, "List of dynamic fxAttributes", Be::READ | Be::PERSIST ) @@ -83,34 +81,30 @@ const Be::ClassInfo* EveChildContainer::ExposeToBlue() MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) - MAP_METHOD_AND_WRAP( - "SetProceduralContainerVariable", - SetProceduralContainerVariable, - "Set variable for all applicable ProceduralContainers\n" - ":param name: variable name\n" - ":param value: new variable value\n" - ) + MAP_METHOD_AND_WRAP( + "SetProceduralContainerVariable", + SetProceduralContainerVariable, + "Set variable for all applicable ProceduralContainers\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) + "Start all controllers" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp index 7abd8027e..dc5824371 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.cpp @@ -8,8 +8,8 @@ #include "Curves/Tr2CurveScalar.h" #include "EveChildInstanceContainer.h" -EveChildEffectPropagator::EveChildEffectPropagator( IRoot* lockobj ) - :EveChildContainer( lockobj ), +EveChildEffectPropagator::EveChildEffectPropagator( IRoot* lockobj ) : + EveChildContainer( lockobj ), m_effectScaling( 1.0f, 1.0f, 1.0f ), m_triggerSphereOffset( 0.0f, 0.0f, 0.0f ), m_type( LOCAL_LOCATORS ), @@ -67,7 +67,7 @@ bool EveChildEffectPropagator::OnModified( Be::Var* value ) m_effect->DisableEditMode( true ); } } - + if( IsMatch( value, m_completeness ) ) { m_completeness = min( 1.f, max( 0.f, m_completeness ) ); @@ -87,7 +87,7 @@ bool EveChildEffectPropagator::OnModified( Be::Var* value ) { if( m_frequency != 0.f ) { - m_playTime = float( m_currentTriggerIndex ) / m_frequency; + m_playTime = float( m_currentTriggerIndex ) / m_frequency; } } @@ -179,8 +179,8 @@ void EveChildEffectPropagator::UpdateSyncronous( const EveUpdateContext& updateC if( m_triggerMethod == INTERVAL_TRIGGERS ) { - int size = (int) max( floor( m_effectDuration * m_frequency ), 0.f ); - std::vector arr(size); + int size = (int)max( floor( m_effectDuration * m_frequency ), 0.f ); + std::vector arr( size ); for( int x = 0; x < size; ++x ) { arr[x] = -1; @@ -216,7 +216,7 @@ void EveChildEffectPropagator::UpdateSyncronous( const EveUpdateContext& updateC break; case INSTANT_PERMANENT: m_playTime += updateContext.GetDeltaT(); - if( m_currentTriggerIndex == 0 ) + if( m_currentTriggerIndex == 0 ) { for( auto it = m_processedTransforms.begin(); it != m_processedTransforms.end(); ++it ) { @@ -252,7 +252,7 @@ void EveChildEffectPropagator::UpdateTriggerCurve( const EveUpdateContext& updat { return; } - + if( m_replayAfterDelay ) { if( m_delayTimer > 0 ) @@ -281,7 +281,7 @@ void EveChildEffectPropagator::UpdateTriggerInterval( const EveUpdateContext& up { return; } - + if( m_stopAfterNumTriggers > 0.0 && m_effectDuration != -1.f && m_playTime > ( m_stopAfterNumTriggers / m_frequency + m_effectDuration ) ) { Stop(); @@ -302,7 +302,7 @@ void EveChildEffectPropagator::UpdateTriggerInterval( const EveUpdateContext& up m_effect->CreateInstance( it->scale, it->rotation, it->position ); m_currentTriggerIndex++; } - + if( m_effectDuration != -1.f && m_playTime > ( (float)m_numDeleted / m_frequency ) + m_effectDuration ) { m_effect->PopFront(); @@ -310,7 +310,7 @@ void EveChildEffectPropagator::UpdateTriggerInterval( const EveUpdateContext& up if( m_numDeleted == m_currentTriggerIndex ) { - m_currentTriggerIndex = 0; // prevent debug rendering on a running loop after it finishes (see InstanceContainers) + m_currentTriggerIndex = 0; // prevent debug rendering on a running loop after it finishes (see InstanceContainers) m_lastTriggered.clear(); } } @@ -319,16 +319,16 @@ void EveChildEffectPropagator::UpdateTriggerInterval( const EveUpdateContext& up int EveChildEffectPropagator::GetSmartRandomLocatorIndex() { int locatorIndex = -1; - int ptSize = (int) m_processedTransforms.size(); - int ltSize = (int) m_lastTriggered.size(); + int ptSize = (int)m_processedTransforms.size(); + int ltSize = (int)m_lastTriggered.size(); - if( ltSize >= ptSize || m_frequency * m_effectDuration > 0.75f * float(ptSize) ) // (*) + if( ltSize >= ptSize || m_frequency * m_effectDuration > 0.75f * float( ptSize ) ) // (*) { locatorIndex = TriRandInt( ptSize ); } else { - // this loop should never repeat more than 2-3 times and most often no + // this loop should never repeat more than 2-3 times and most often no // repeats at all. I also made an early exit condition ->(*). // The assumption is that this is faster than keeping an organized // index array barring excluded indexes. The only bad scenario is when all of these @@ -429,7 +429,7 @@ void EveChildEffectPropagator::ProcessLocalLocators() float l = LengthSq( t.position ); m_triggerSphereScalarMulti = m_triggerSphereScalarMulti > l ? m_triggerSphereScalarMulti : l; t.rotation = it->direction; - float rand = m_randScaleMin + TriRand() * (m_randScaleMax - m_randScaleMin); + float rand = m_randScaleMin + TriRand() * ( m_randScaleMax - m_randScaleMin ); t.scale = m_effectScaling * rand; m_processedTransforms.emplace_back( t ); } @@ -470,12 +470,11 @@ void EveChildEffectPropagator::ProcessRefLocators( IEveSpaceObject2* parent ) Transform t; t.position = locator->position; t.rotation = locator->direction; - float rand = m_randScaleMin + TriRand() * (m_randScaleMax - m_randScaleMin); + float rand = m_randScaleMin + TriRand() * ( m_randScaleMax - m_randScaleMin ); t.scale = m_effectScaling * rand; m_processedTransforms.emplace_back( t ); } } - } void EveChildEffectPropagator::ProcessRandomSpreadLocators() @@ -488,8 +487,8 @@ void EveChildEffectPropagator::ProcessRandomSpreadLocators() } float dist = TriRand(); - dist += (m_rndClosenessPreference - dist) * TriRand(); - dist = m_rndMinRangeThreshold + (m_rndRange - m_rndMinRangeThreshold) * dist; + dist += ( m_rndClosenessPreference - dist ) * TriRand(); + dist = m_rndMinRangeThreshold + ( m_rndRange - m_rndMinRangeThreshold ) * dist; float a = TRI_2PI * TriRand(); float z = TriRand() * 2.f - 1.f; @@ -499,7 +498,7 @@ void EveChildEffectPropagator::ProcessRandomSpreadLocators() t.position = angle * dist; TriQuaternionDirVector( &t.rotation, &angle ); - float rand = m_randScaleMin + TriRand() * (m_randScaleMax - m_randScaleMin); + float rand = m_randScaleMin + TriRand() * ( m_randScaleMax - m_randScaleMin ); t.scale = m_effectScaling * rand; m_processedTransforms.emplace_back( t ); } @@ -544,7 +543,7 @@ void EveChildEffectPropagator::RecalculateLocatorSizes() { for( auto it = m_processedTransforms.begin(); it != m_processedTransforms.end(); ++it ) { - float rand = m_randScaleMin + TriRand() * (m_randScaleMax - m_randScaleMin); + float rand = m_randScaleMin + TriRand() * ( m_randScaleMax - m_randScaleMin ); it->scale = m_effectScaling * rand; } } @@ -587,7 +586,10 @@ void EveChildEffectPropagator::RenderDebugInfo( ITr2DebugRenderer2& renderer ) if( m_triggerSphereRadiusCurve != nullptr ) { float currentRad = m_triggerSphereRadiusCurve->GetValueAt( m_playTime ) * m_triggerSphereScalarMulti; - if( m_type == LOCATOR_SET_BY_REF ) { currentRad *= 2; } + if( m_type == LOCATOR_SET_BY_REF ) + { + currentRad *= 2; + } renderer.DrawSphere( this, TranslationMatrix( m_triggerSphereOffset * m_triggerSphereScalarMulti ) * m_worldTransform, currentRad, 12, Tr2DebugRenderer::Wireframe, 0xbbffbbff ); } @@ -609,8 +611,7 @@ void EveChildEffectPropagator::RenderDebugInfo( ITr2DebugRenderer2& renderer ) Length( it->scale ) * m_triggerSphereScalarMulti / 50.f, 8, Tr2DebugRenderer::Lit, - 0x990088ff - ); + 0x990088ff ); } } else @@ -624,8 +625,7 @@ void EveChildEffectPropagator::RenderDebugInfo( ITr2DebugRenderer2& renderer ) Length( it->scale ) * m_triggerSphereScalarMulti / 50.f, 8, Tr2DebugRenderer::Lit, - 0x990088ff - ); + 0x990088ff ); } } diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h index 9cf604d26..12deb0d46 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator.h @@ -29,20 +29,20 @@ BLUE_CLASS( EveChildEffectPropagator ) : void Stop(); bool Initialize() override; - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; - void GetRenderables( std::vector& renderables ) override; + void GetRenderables( std::vector & renderables ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void SetControllerVariable( const char* name, float value ) override; void GetDebugOptions( Tr2DebugRendererOptions & options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; + - ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; @@ -79,11 +79,11 @@ BLUE_CLASS( EveChildEffectPropagator ) : } }; - void ProcessLocators( IEveSpaceObject2* parent ); + void ProcessLocators( IEveSpaceObject2 * parent ); void ProcessRandomSpreadLocators(); void RecalculateLocatorSizes(); void ProcessLocalLocators(); - void ProcessRefLocators( IEveSpaceObject2* parent ); + void ProcessRefLocators( IEveSpaceObject2 * parent ); void UpdateTriggerCurve( const EveUpdateContext& updateContext ); void UpdateTriggerInterval( const EveUpdateContext& updateContext ); @@ -93,12 +93,12 @@ BLUE_CLASS( EveChildEffectPropagator ) : int GetSmartRandomLocatorIndex(); EveChildInstanceContainer* GetEffect() const; - void SetEffect( EveChildInstanceContainer* effect ); + void SetEffect( EveChildInstanceContainer * effect ); float m_playTime; - EveChildInstanceContainerPtr m_effect; // Child containing trigger effect - IEveSpaceObjectChildPtr m_effectShared; // Child containing shared parts of the effect (particle systems etc.) + EveChildInstanceContainerPtr m_effect; // Child containing trigger effect + IEveSpaceObjectChildPtr m_effectShared; // Child containing shared parts of the effect (particle systems etc.) Vector3 m_effectScaling; float m_randScaleMin; @@ -118,12 +118,12 @@ BLUE_CLASS( EveChildEffectPropagator ) : float m_delayTimer; bool m_replayAfterDelay; - // Locator By Referance + // Locator By Referance BlueSharedString m_locatorSetName; float m_completeness; // RANDOM_SPREAD - int64_t m_numTriggers; + int64_t m_numTriggers; float m_rndRange; float m_rndClosenessPreference; float m_rndMinRangeThreshold; diff --git a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp index e69a14bf8..2391292dc 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildEffectPropagator_Blue.cpp @@ -4,8 +4,7 @@ #include "EveChildEffectPropagator.h" -Be::VarChooser PropagationChooser[] = -{ +Be::VarChooser PropagationChooser[] = { { "localLocators", BeCast( EveChildEffectPropagator::LOCAL_LOCATORS ), "just place your triggers manually" }, { "externalLocatorSet", BeCast( EveChildEffectPropagator::LOCATOR_SET_BY_REF ), "use a parent's locatorSet to propagate" }, { "randomSpread", BeCast( EveChildEffectPropagator::RANDOM_SPREAD ), "spreads locators randomly" }, @@ -13,8 +12,7 @@ Be::VarChooser PropagationChooser[] = }; BLUE_REGISTER_ENUM_EX( "EffectPropagationType", EveChildEffectPropagator::PropagationType, PropagationChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser PropagationTriggerChooser[] = -{ +Be::VarChooser PropagationTriggerChooser[] = { { "triggerSphereCurve", BeCast( EveChildEffectPropagator::TRIGGER_SPHERE_CURVE ), "animate a radius to trigger the effect" }, { "intervalTriggers", BeCast( EveChildEffectPropagator::INTERVAL_TRIGGERS ), "continuous effect trigger" }, { "instantPermanent", BeCast( EveChildEffectPropagator::INSTANT_PERMANENT ), "propagate instantly over set and no clean-up" }, @@ -26,22 +24,22 @@ BLUE_DEFINE( EveChildEffectPropagator ); const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildEffectPropagator, "Specialized explosion propagator object child" ) - MAP_INTERFACE( EveChildEffectPropagator ) - MAP_INTERFACE( EveChildContainer ) + EXPOSURE_BEGIN( EveChildEffectPropagator, "Specialized explosion propagator object child" ) + MAP_INTERFACE( EveChildEffectPropagator ) + MAP_INTERFACE( EveChildContainer ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( INotify ) - MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( EveEntity ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "effect", m_effect, "childInstanceContainer", Be::PERSISTONLY | Be::NOTIFY ) MAP_PROPERTY( "effect", GetEffect, SetEffect, "The instance container that manages the instances" ) - MAP_ATTRIBUTE( "triggerSphereRadiusCurve", m_triggerSphereRadiusCurve, "Manage the the triggering of effects based on a distance from the triggerSphereOffset", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "triggerSphereRadiusCurve", m_triggerSphereRadiusCurve, "Manage the the triggering of effects based on a distance from the triggerSphereOffset", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localLocators", m_localLocators, "locators for a self-contained propagation", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "curveSets", m_curveSets, "", Be::READ | Be::PERSIST ) - + MAP_ATTRIBUTE_WITH_CHOOSER( "propagationType", m_type, "", Be::READWRITE | Be::PERSIST | Be::ENUM | Be::NOTIFY, PropagationChooser ) MAP_ATTRIBUTE_WITH_CHOOSER( "triggerMethood", m_triggerMethod, "", Be::READWRITE | Be::PERSIST | Be::ENUM | Be::NOTIFY, PropagationTriggerChooser ) @@ -49,8 +47,8 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() MAP_ATTRIBUTE( "isPlaying", m_isPlaying, "Is the effect playing", Be::READ ) MAP_ATTRIBUTE( "playTime", m_playTime, "Time since the start of playback", Be::READ ) MAP_ATTRIBUTE( "triggerSphereScalarMulti", m_triggerSphereScalarMulti, "multiplied by the scalar curve", Be::READ ) - - MAP_ATTRIBUTE( "completeness", m_completeness, "range: [0:1] ~to use if you don't want 100% of a Locset. Doesn't work for randomSpread\n:jessica-group: SpawnSettings", Be::READWRITE | Be::PERSIST |Be::NOTIFY ) + + MAP_ATTRIBUTE( "completeness", m_completeness, "range: [0:1] ~to use if you don't want 100% of a Locset. Doesn't work for randomSpread\n:jessica-group: SpawnSettings", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "triggerSphereOffset", m_triggerSphereOffset, "Centerpoint of the trigger sphere\n:jessica-group: SpawnSettings", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "effectScaling", m_effectScaling, "general Vec3 to enlarge the effects (set on spawn)\n:jessica-group: SpawnSettings", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "randScaleMin", m_randScaleMin, "additional randomness -> scaling range\n:jessica-group: SpawnSettings", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -64,16 +62,15 @@ const Be::ClassInfo* EveChildEffectPropagator::ExposeToBlue() MAP_ATTRIBUTE( "range", m_rndRange, "total range locators can spawn in\n:jessica-group: RandomLocators", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "minRangeThreshold", m_rndMinRangeThreshold, "should they always spawn at least x meters away from center? \n:jessica-group: RandomLocators", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "ClosenessPreference", m_rndClosenessPreference, "distribution point. (closer to 0/1 more similar)\n:jessica-group: RandomLocators", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "name of the locator set\n:jessica-group: ExternalLocatorSet", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + MAP_ATTRIBUTE( "frequency", m_frequency, "triggers per sec\n:jessica-group: intervalTriggers", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::NOTIFY ) MAP_ATTRIBUTE( "durationPerEffect", m_effectDuration, "how long until per instance cleanup\n:jessica-group: intervalTriggers", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "stopAfterNumTriggers", m_stopAfterNumTriggers, "-1 to never stop else it stops after [num] creations \n:jessica-group: intervalTriggers", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) MAP_METHOD_AND_WRAP( "Stop", Stop, "Stops effect playback.\n:jessica-favorite:\n:jessica-icon: timeline/stop.png" ) - - EXPOSURE_END() -} + EXPOSURE_END() +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp index 12951ab10..a252e4579 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.cpp @@ -5,8 +5,8 @@ #include "Eve/EveUpdateContext.h" #include "Particle/Tr2SphereShapeAttributeGenerator.h" -EveChildExplosion::EveChildExplosion( IRoot* lockobj ) - :EveChildContainer( lockobj ), +EveChildExplosion::EveChildExplosion( IRoot* lockobj ) : + EveChildContainer( lockobj ), PARENTLOCK( m_localExplosions ), PARENTLOCK( m_globalExplosions ), PARENTLOCK( m_globalExplosionInstances ), @@ -83,9 +83,9 @@ void EveChildExplosion::Play() CalculateExplosionTimes( uint32_t( m_localExplosionTransforms.size() ) ); m_playTime = 0; m_countdownToGlobalExplosionStart = m_globalExplosionTime; - + RebuildLocalTransform(); - m_isPlaying = true; + m_isPlaying = true; } // -------------------------------------------------------------------------------------- @@ -116,24 +116,24 @@ void EveChildExplosion::CalculateExplosionTimes( uint32_t localExplosionCount ) float timeUntilLastLocalExplosion = 0.f; m_globalExplosionTime = 0.f; m_totalDuration = 0.f; - - if( localExplosionCount != 0) + + if( localExplosionCount != 0 ) { timeUntilLastLocalExplosion += m_localExplosionDelay; m_globalExplosionTime += m_globalExplosionDelay; } - for(uint32_t i = 0; i < localExplosionCount; i++) + for( uint32_t i = 0; i < localExplosionCount; i++ ) { - auto explosionTime = std::pow( m_localExplosionIntervalFactor, float( i ) ) * - m_localExplosionInterval * float( rand() ) / float( RAND_MAX ); - - m_localExplosionTimes.push_back(explosionTime); + auto explosionTime = std::pow( m_localExplosionIntervalFactor, float( i ) ) * + m_localExplosionInterval * float( rand() ) / float( RAND_MAX ); + + m_localExplosionTimes.push_back( explosionTime ); timeUntilLastLocalExplosion += explosionTime; } float totalLocalDuration = m_localDuration + timeUntilLastLocalExplosion; m_globalExplosionTime += timeUntilLastLocalExplosion; - + // max this because we might have explosions that do not have a global explosion m_totalDuration = max( totalLocalDuration, m_globalExplosionTime + m_globalDuration ); @@ -148,18 +148,18 @@ void EveChildExplosion::CalculateExplosionTimes( uint32_t localExplosionCount ) // -------------------------------------------------------------------------------------- void EveChildExplosion::SetLocalExplosionTransforms( const std::vector& transforms ) { - + m_localExplosionTransforms.clear(); - m_localExplosionTransforms.insert( - m_localExplosionTransforms.begin(), - transforms.begin(), + m_localExplosionTransforms.insert( + m_localExplosionTransforms.begin(), + transforms.begin(), transforms.end() ); } // -------------------------------------------------------------------------------------- // Description: // Assigns a offset to use as an offset for the global explosion -// This offset will be scaled by the inverse of the parent scale, so it is positioned +// This offset will be scaled by the inverse of the parent scale, so it is positioned // correctly // Arguments: // offset - The offset to use @@ -170,7 +170,6 @@ void EveChildExplosion::SetGlobalExplosionOffset( const Vector3& offset ) m_globalExplosionOffset.x /= this->m_scaling.x; m_globalExplosionOffset.y /= this->m_scaling.y; m_globalExplosionOffset.z /= this->m_scaling.z; - } // -------------------------------------------------------------------------------------- @@ -187,7 +186,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, if( m_localExplosion || !m_localExplosions.empty() ) { // we only want to remove the small explosions if there is a big explosion - if( m_wreckSwitchTime > 0 && m_playTime > m_wreckSwitchTime && m_globalDuration > 0) + if( m_wreckSwitchTime > 0 && m_playTime > m_wreckSwitchTime && m_globalDuration > 0 ) { m_nextLocalExplosion = m_localExplosionTransforms.size(); for( size_t i = 0; i < m_objects.size(); ) @@ -202,7 +201,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, } } } - + while( m_nextLocalExplosionTime < dt && m_nextLocalExplosion < m_localExplosionTransforms.size() ) { XMVECTOR det; @@ -227,14 +226,14 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, { IEveSpaceObjectChildPtr instance; if( BeClasses->CopyTo( m_globalExplosion, (IRoot**)&instance.p ) ) - { - Quaternion rotation = Quaternion( 0.0, 0.0 ,0.0, 1.0 ); - + { + Quaternion rotation = Quaternion( 0.0, 0.0, 0.0, 1.0 ); + m_globalExplosionContainer.CreateInstance(); - m_globalExplosionContainer->SetupWithStaticRotation(&m_globalExplosionScaling, &rotation, &m_globalExplosionOffset, TR2_LOD_LOW ); + m_globalExplosionContainer->SetupWithStaticRotation( &m_globalExplosionScaling, &rotation, &m_globalExplosionOffset, TR2_LOD_LOW ); m_globalExplosionContainer->m_objects.Append( instance ); - + m_objects.Append( m_globalExplosionContainer->GetRawRoot() ); m_globalExplosionInstances.Append( instance ); } @@ -263,13 +262,13 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, { auto globalExplosion = ( *it ); IEveSpaceObjectChildPtr instance; - if( BeClasses->CopyTo( globalExplosion, ( IRoot** )&instance.p ) ) + if( BeClasses->CopyTo( globalExplosion, (IRoot**)&instance.p ) ) { m_globalExplosionContainer->m_objects.Append( instance ); m_globalExplosionInstances.Append( instance ); } - } - + } + // manually register the container, since it has now been created if( this->IsInRegistry() && !m_globalExplosionContainer->IsInRegistry() ) { @@ -283,7 +282,7 @@ void EveChildExplosion::UpdateSyncronous( const EveUpdateContext& updateContext, } } } - + if( m_playTime > m_totalDuration ) { Stop(); @@ -338,23 +337,23 @@ void EveChildExplosion::FindSharedObjects() { continue; } - + const Be::ClassInfo* type = obj->ClassType(); for( ssize_t xtraoffs = 0; type; xtraoffs += type->mOffsetToParent, type = type->mParentClassInfo ) { - for( const Be::VarEntry *entry = type->mMemberTable; entry->mName; entry++ ) + for( const Be::VarEntry* entry = type->mMemberTable; entry->mName; entry++ ) { if( ( entry->mEditFlags & Be::PERSIST ) && ( entry->mType == Be::IROOT || entry->mType == Be::IROOTPTR ) ) { Be::Var* value = BLUEMAPMEMBEROFFSET( obj, entry, type, xtraoffs ); - if( entry->mType == Be::IROOTPTR ) + if( entry->mType == Be::IROOTPTR ) { if( value->mIRootPtr ) { stack.push_back( value->mIRootPtr ); } - } - else + } + else { stack.push_back( reinterpret_cast( value ) ); } @@ -366,9 +365,9 @@ void EveChildExplosion::FindSharedObjects() { ListInfo info; list->GetInfo( &info ); - for( ssize_t i = 0; i < list->GetSize(); i++ ) + for( ssize_t i = 0; i < list->GetSize(); i++ ) { - if( IRoot *item = list->GetAt(i) ) + if( IRoot* item = list->GetAt( i ) ) { stack.push_back( item ); } @@ -391,7 +390,7 @@ void EveChildExplosion::FindSharedObjects() // -------------------------------------------------------------------------------------- // Description: // Callback for BeClasses->CopyTo. When a local explosion instance is copied we need to -// retain all references to the shared part of the local explosion. This function +// retain all references to the shared part of the local explosion. This function // provides a custom copy for such references. // Arguments: // source - Source object to copy @@ -442,8 +441,8 @@ void EveChildExplosion::UpdateEmitter( IRoot* source, IRoot** dest, ICopier* cop Vector3 position; Quaternion rotation; generator->GetTransform( position, rotation ); - position = XMQuaternionMultiply( transform.rotation, - XMQuaternionMultiply( position, XMQuaternionConjugate( transform.rotation ) ) ); + position = XMQuaternionMultiply( transform.rotation, + XMQuaternionMultiply( position, XMQuaternionConjugate( transform.rotation ) ) ); rotation = XMQuaternionMultiply( transform.rotation, rotation ); generator->SetTransform( position + transform.position, rotation ); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h index 96c0140e9..42953d774 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion.h +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion.h @@ -11,8 +11,8 @@ BLUE_DECLARE_VECTOR( Tr2SphereShapeAttributeGenerator ); // -------------------------------------------------------------------------------------- // Description: -// EveChildExplosion is a specialized EveSpaceObject2 child class that creates an -// explosion animation. The explosion contains multiple "local" explosions and a single +// EveChildExplosion is a specialized EveSpaceObject2 child class that creates an +// explosion animation. The explosion contains multiple "local" explosions and a single // "global" explosion. // -------------------------------------------------------------------------------------- BLUE_CLASS( EveChildExplosion ) : @@ -30,9 +30,9 @@ BLUE_CLASS( EveChildExplosion ) : void SetGlobalExplosionOffset( const Vector3& offset ); void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); + - ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; @@ -44,12 +44,12 @@ BLUE_CLASS( EveChildExplosion ) : Quaternion rotation; Vector3 position; }; - - void CalculateExplosionTimes(uint32_t localExplosionCount); + + void CalculateExplosionTimes( uint32_t localExplosionCount ); void FindSharedObjects(); void SpawnLocalExplosion( const Matrix& transform ); - static ICopier::OverrideResult CopyElement( IRoot* source, IRoot** dest, ICopier* copier, void* context ); - static void UpdateEmitter( IRoot* source, IRoot** dest, ICopier* copier, void* context ); + static ICopier::OverrideResult CopyElement( IRoot * source, IRoot * *dest, ICopier * copier, void* context ); + static void UpdateEmitter( IRoot * source, IRoot * *dest, ICopier * copier, void* context ); // Delay from explosion start to the first "local" explosion in seconds float m_localExplosionDelay; @@ -71,7 +71,7 @@ BLUE_CLASS( EveChildExplosion ) : float m_globalDuration; float m_totalDuration; - + // Child containing local explosion effect IEveSpaceObjectChildPtr m_localExplosion; @@ -104,7 +104,7 @@ BLUE_CLASS( EveChildExplosion ) : // Local explosion scaling Vector3 m_localExplosionScaling; - + // Is the effect playing bool m_isPlaying; }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp index e97cbf89c..4a8777e78 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildExplosion_Blue.cpp @@ -8,101 +8,101 @@ BLUE_DEFINE( EveChildExplosion ); const Be::ClassInfo* EveChildExplosion::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildExplosion, "Specialized explosion space object child" ) - MAP_INTERFACE( EveChildExplosion ) - MAP_INTERFACE( EveChildContainer ) - MAP_INTERFACE( EveEntity ) + EXPOSURE_BEGIN( EveChildExplosion, "Specialized explosion space object child" ) + MAP_INTERFACE( EveChildExplosion ) + MAP_INTERFACE( EveChildContainer ) + MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosion", - m_localExplosion, - "Child containing local explosion effect", + MAP_ATTRIBUTE( + "localExplosion", + m_localExplosion, + "Child containing local explosion effect", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosions", - m_localExplosions, - "List of children containing versions of local explosion effect", + MAP_ATTRIBUTE( + "localExplosions", + m_localExplosions, + "List of children containing versions of local explosion effect", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosionShared", - m_localExplosionShared, - "Child containing shared parts of the local explosion effect (particle systems etc.)", + MAP_ATTRIBUTE( + "localExplosionShared", + m_localExplosionShared, + "Child containing shared parts of the local explosion effect (particle systems etc.)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "globalExplosion", - m_globalExplosion, - "Child containing global explosion effect", + MAP_ATTRIBUTE( + "globalExplosion", + m_globalExplosion, + "Child containing global explosion effect", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "globalExplosions", m_globalExplosions, "Children containing global explosion effects", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosionDelay", - m_localExplosionDelay, - "Delay from explosion start to the first \"local\" explosion in seconds", + MAP_ATTRIBUTE( + "localExplosionDelay", + m_localExplosionDelay, + "Delay from explosion start to the first \"local\" explosion in seconds", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosionInterval", - m_localExplosionInterval, - "Maximum interval between local explosions in seconds", + MAP_ATTRIBUTE( + "localExplosionInterval", + m_localExplosionInterval, + "Maximum interval between local explosions in seconds", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "localExplosionIntervalFactor", - m_localExplosionIntervalFactor, - "Coefficent to apply to m_localExplosionInterval for consecutive explosions", + MAP_ATTRIBUTE( + "localExplosionIntervalFactor", + m_localExplosionIntervalFactor, + "Coefficent to apply to m_localExplosionInterval for consecutive explosions", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "globalExplosionDelay", - m_globalExplosionDelay, - "Delay from the end of the last \"local\" explosion to the start of the \"global\" explosion in seconds", + MAP_ATTRIBUTE( + "globalExplosionDelay", + m_globalExplosionDelay, + "Delay from the end of the last \"local\" explosion to the start of the \"global\" explosion in seconds", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "wreckSwitchTime", - m_wreckSwitchTime, - "Time from the start of the explosion to the point when original model needs to be switched to the wreck", + MAP_ATTRIBUTE( + "wreckSwitchTime", + m_wreckSwitchTime, + "Time from the start of the explosion to the point when original model needs to be switched to the wreck", Be::READ ) - MAP_ATTRIBUTE( - "wreckSwitchOffsetFromGlobalStart", - m_wreckSwitchOffsetFromGlobalStart, - "Time from the start of the global explosion that the model will be switched", + MAP_ATTRIBUTE( + "wreckSwitchOffsetFromGlobalStart", + m_wreckSwitchOffsetFromGlobalStart, + "Time from the start of the global explosion that the model will be switched", Be::READWRITE ) - MAP_ATTRIBUTE( - "localDuration", - m_localDuration, - "Total duration of a single local explosion", + MAP_ATTRIBUTE( + "localDuration", + m_localDuration, + "Total duration of a single local explosion", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "globalDuration", - m_globalDuration, - "Duration of the global explosion", + MAP_ATTRIBUTE( + "globalDuration", + m_globalDuration, + "Duration of the global explosion", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( - "totalDuration", - m_totalDuration, - "Duration of the complete explosion", + + MAP_ATTRIBUTE( + "totalDuration", + m_totalDuration, + "Duration of the complete explosion", Be::READ ) - - MAP_ATTRIBUTE( - "globalExplosionTime", - m_globalExplosionTime, - "The start of the global explosion", + + MAP_ATTRIBUTE( + "globalExplosionTime", + m_globalExplosionTime, + "The start of the global explosion", Be::READ ) - MAP_ATTRIBUTE( - "isPlaying", - m_isPlaying, - "Is the effect playing", + MAP_ATTRIBUTE( + "isPlaying", + m_isPlaying, + "Is the effect playing", Be::READ ) - MAP_ATTRIBUTE( - "playTime", - m_playTime, - "Time since the start of playback", + MAP_ATTRIBUTE( + "playTime", + m_playTime, + "Time since the start of playback", Be::READ ) MAP_ATTRIBUTE( "generatedLocalExplosions", m_objects, "", Be::READ ) MAP_ATTRIBUTE( "generatedGlobalExplosions", m_globalExplosionContainer, "", Be::READ ) @@ -111,36 +111,35 @@ const Be::ClassInfo* EveChildExplosion::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localScaling", m_localExplosionScaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "globalScaling", m_globalExplosionScaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "globalScaling", m_globalExplosionScaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) - MAP_METHOD_AND_WRAP( - "Play", - Play, + MAP_METHOD_AND_WRAP( + "Play", + Play, "Starts effect playback.\n" ":jessica-favorite:\n" ":jessica-icon: timeline/play.png" ) - MAP_METHOD_AND_WRAP( - "Stop", - Stop, + MAP_METHOD_AND_WRAP( + "Stop", + Stop, "Stops effect playback.\n" ":jessica-favorite:\n" ":jessica-icon: timeline/stop.png" ) - MAP_METHOD_AND_WRAP( - "SetLocalExplosionTransforms", - SetLocalExplosionTransforms, + MAP_METHOD_AND_WRAP( + "SetLocalExplosionTransforms", + SetLocalExplosionTransforms, "Assigns transforms for local explosions.\n" ":param transforms: list of matricies to be used as local explosion transforms" ) - MAP_METHOD_AND_WRAP( - "SetGlobalExplosionOffset", - SetGlobalExplosionOffset, + MAP_METHOD_AND_WRAP( + "SetGlobalExplosionOffset", + SetGlobalExplosionOffset, "Sets the global explosion offset.\n" ":param offset: Vector3 that to be used as the global explosion offset should be in local coordinates" ) - - EXPOSURE_END() -} + EXPOSURE_END() +} diff --git a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h index 30f2a098e..9e1d49362 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildFogVolume.h @@ -33,7 +33,7 @@ BLUE_CLASS( EveChildFogVolume ) : const char* GetName() const override; void SetName( const char* name ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector & renderables ) override {}; + void GetRenderables( std::vector & renderables ) override{}; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.cpp b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.cpp index 36d9db7e7..371c17dd6 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.cpp @@ -15,7 +15,7 @@ EveChildInheritProperties::~EveChildInheritProperties() void EveChildInheritProperties::SetProperties( const Color* colorSet ) { - if (colorSet) + if( colorSet ) { memcpy( m_colorSet, colorSet, sizeof( m_colorSet ) ); } @@ -23,5 +23,5 @@ void EveChildInheritProperties::SetProperties( const Color* colorSet ) const Color* EveChildInheritProperties::GetProperties() { - return m_colorSet; + return m_colorSet; } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.h b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.h index 420cb04aa..0f7dda704 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties.h @@ -15,8 +15,9 @@ BLUE_CLASS( EveChildInheritProperties ) : EveChildInheritProperties( IRoot* lockobj = NULL ); ~EveChildInheritProperties(); - void SetProperties( const Color *colorSet ); - const Color* GetProperties(); + void SetProperties( const Color* colorSet ); + const Color* GetProperties(); + protected: Color m_colorSet[SOFDataFactionColorChooser::TYPE_MAX]; }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties_Blue.cpp index 679f61b0d..1849f0107 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInheritProperties_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInheritProperties_Blue.cpp @@ -13,8 +13,8 @@ const Be::ClassInfo* EveChildInheritProperties::ExposeToBlue() EXPOSURE_BEGIN( EveChildInheritProperties, "" ) MAP_INTERFACE( EveChildInheritProperties ) -#define COLOR_DEFINE( _Color, _COLOR )\ - MAP_ATTRIBUTE( #_Color, m_colorSet[TYPE_ ## _COLOR], ":jessica-group:SOF Faction Glow Colors", Be::READ ) +#define COLOR_DEFINE( _Color, _COLOR ) \ + MAP_ATTRIBUTE( #_Color, m_colorSet[TYPE_##_COLOR], ":jessica-group:SOF Faction Glow Colors", Be::READ ) COLOR_DEFINE( Primary, PRIMARY ) COLOR_DEFINE( Secondary, SECONDARY ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp index 333411d13..0d67cf3f0 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.cpp @@ -10,14 +10,13 @@ namespace { -BlueStructureDefinition s_eveChildInstanceTransformStructureDef[] = - { - { "scale", Be::FLOAT32_3, 0 }, - { "rotation", Be::FLOAT32_4, 12 }, - { "translation", Be::FLOAT32_3, 28 }, - { "boneIndex", Be::INT32_1, 40 }, - { 0 } - }; +BlueStructureDefinition s_eveChildInstanceTransformStructureDef[] = { + { "scale", Be::FLOAT32_3, 0 }, + { "rotation", Be::FLOAT32_4, 12 }, + { "translation", Be::FLOAT32_3, 28 }, + { "boneIndex", Be::INT32_1, 40 }, + { 0 } +}; EveChildInstanceTransform s_defaultEveChildInstanceTransform; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h index 7eb3bb4f2..42fce1a86 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer.h @@ -51,34 +51,34 @@ BLUE_CLASS( EveChildInstanceContainer ) : void DistributeAcrossLocatorset( const BlueSharedString locatorSetName ); float GetOwnerMaxSpeed() const; - + ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild const char* GetName() const; void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, Matrix& parentTransform ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ); void SetOrigin( Origin origin ); void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; bool IsAlwaysOn() const override; void SetInheritProperties( const Color* colorSet ); - void GetWorldVelocity( Vector3& velocity ) const; + void GetWorldVelocity( Vector3 & velocity ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void AddTransformModifier( IEveChildTransformModifier* modifier ) override; - + void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -100,12 +100,12 @@ BLUE_CLASS( EveChildInstanceContainer ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; ///////////////////////////////////////////////////////////////////////////////////// // IListNotify @@ -120,7 +120,7 @@ BLUE_CLASS( EveChildInstanceContainer ) : void RegisterComponents() override; void UnRegisterComponents() override; - void CreateInstance(const Vector3& scale, const Quaternion& rotation, const Vector3& translation, const int32_t boneIndex = -1); + void CreateInstance( const Vector3& scale, const Quaternion& rotation, const Vector3& translation, const int32_t boneIndex = -1 ); void ClearInstanceList(); void PopFront(); void DisableEditMode( bool disable ); @@ -130,14 +130,13 @@ BLUE_CLASS( EveChildInstanceContainer ) : void UpdateInstance( const uint32_t index, const Vector3& scale, const Quaternion& rotation, const Vector3& translation ); IEveSpaceObjectChildPtr GetSource(); - void SetSource( IEveSpaceObjectChild* source ); + void SetSource( IEveSpaceObjectChild * source ); protected: - void CreateInstances( IEveSpaceObject2* parent ); + void CreateInstances( IEveSpaceObject2 * parent ); void RunOnInstances( std::function func ) const; protected: - BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp index bb76ff2d4..1dd3207d2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceContainer_Blue.cpp @@ -6,65 +6,61 @@ BLUE_DEFINE( EveChildInstanceContainer ); BLUE_DECLARE_INTERFACE( ITr2DebugRenderable ); -const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() -{ +const Be::ClassInfo* EveChildInstanceContainer::ExposeToBlue() { EXPOSURE_BEGIN( EveChildInstanceContainer, "" ) MAP_INTERFACE( EveChildInstanceContainer ) - MAP_INTERFACE( IEveSpaceObjectChild ) - MAP_INTERFACE( ITr2CurveSetOwner ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IEveEffectChildrenOwner ) - MAP_INTERFACE( IShaderConfigurer ) - MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( EveEntity ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) + MAP_INTERFACE( IEveSpaceObjectChild ) + MAP_INTERFACE( ITr2CurveSetOwner ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IEveEffectChildrenOwner ) + MAP_INTERFACE( IShaderConfigurer ) + MAP_INTERFACE( ITr2ControllerOwner ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( EveEntity ) - MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "alwaysOn", m_isAlwaysOn, "If false this will be hidden if a spaceobjects activation strength < 0.5. If True then it is always on.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) + MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "Properties inherited from the parent ship when loaded through SOF", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "origin", m_origin, "Where did this effect originate from", Be::READ ) - MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) - MAP_METHOD_AND_WRAP( - "SetControllerVariable", - SetControllerVariable, - "Set variable for all applicable controllers\n" - ":param name: variable name\n" - ":param value: new variable value\n" - ) + MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useSRT", m_useSRT, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "HandleControllerEvent", - HandleControllerEvent, - "Pass an event to controllers\n" - ":param name: event name" - ) + MAP_METHOD_AND_WRAP( + "SetControllerVariable", + SetControllerVariable, + "Set variable for all applicable controllers\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) - MAP_METHOD_AND_WRAP( - "StartControllers", - StartControllers, - "Start all controllers" - ) + MAP_METHOD_AND_WRAP( + "HandleControllerEvent", + HandleControllerEvent, + "Pass an event to controllers\n" + ":param name: event name" ) - MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) - MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) + MAP_METHOD_AND_WRAP( + "StartControllers", + StartControllers, + "Start all controllers" ) - MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) - MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) - MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "source", m_source, "The sourceObject to instance", Be::PERSISTONLY ) + MAP_PROPERTY( "source", GetSource, SetSource, "The sourceObject to instance" ) - EXPOSURE_END() + MAP_ATTRIBUTE( "locatorSet", m_locatorSetName, "The name of the locatorset to distribute across", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "reset", m_reset, "Redistributes the source", Be::READWRITE ) + MAP_ATTRIBUTE( "instances", m_instances, "The generated instances\n:jessica-skip-validation:", Be::READ ) + MAP_ATTRIBUTE( "transforms", m_transforms, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST | Be::NOTIFY ) + + EXPOSURE_END() }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.cpp index 2535bbaed..1dc084a35 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.cpp @@ -127,7 +127,7 @@ void EveChildInstanceMeshRenderer::UpdateBoundingSphere( const PlacementDataWith if( ( m_mesh->GetGeometryResource() )->IsGood() ) { TriGeometryResMeshData* meshData = m_mesh->GetGeometryResource()->GetMeshData( m_mesh->GetMeshIndex() ); - baseMeshSize = meshData->m_boundingSphere.w; + baseMeshSize = meshData->m_boundingSphere.w; } } @@ -138,9 +138,9 @@ void EveChildInstanceMeshRenderer::UpdateBoundingSphere( const PlacementDataWith for( size_t index = 0; index < m_totalObjectCount; index++ ) { Vector3 pointPos = placements[index].initialTranslation + placements[index].additionalTranslation; - float dist = LengthSq( pointPos - center ); // calculate squared for efficiency - Vector3 pointScale = placements[index].initialScale * placements[index].additionalScale; - float longestAxis = max( max( pointScale.x, pointScale.y ), pointScale.z ) ; + float dist = LengthSq( pointPos - center ); // calculate squared for efficiency + Vector3 pointScale = placements[index].initialScale * placements[index].additionalScale; + float longestAxis = max( max( pointScale.x, pointScale.y ), pointScale.z ); largestScale = max( longestAxis, largestScale ); longestDistance = max( dist, longestDistance ); } @@ -234,7 +234,7 @@ void EveChildInstanceMeshRenderer::UpdateGeometryResource( const PlacementDataWi std::vector instances; instances.reserve( m_totalObjectCount ); - std::vector instanceTransforms; // for raytracing + std::vector instanceTransforms; // for raytracing instanceTransforms.reserve( m_totalObjectCount ); Vector3 position, scaling; @@ -265,7 +265,7 @@ void EveChildInstanceMeshRenderer::UpdateGeometryResource( const PlacementDataWi { Quaternion objUpToCamera; Vector3 objDir; - Vector3 angleToCamera = Normalize( camPos - TransformCoord( position, m_worldTransform )); + Vector3 angleToCamera = Normalize( camPos - TransformCoord( position, m_worldTransform ) ); Quaternion originRotation = Inverse( RotationQuaternion( m_worldTransform ) ); TriVectorRotateQuaternion( &objDir, &up, &originRotation ); @@ -356,7 +356,7 @@ void EveChildInstanceMeshRenderer::UpdateInstanceData( std::vectorGetInstanceGeometryResource(); - + if( !geometryResource->IsInstanceDataReady() ) { ConfigureInstanceData(); @@ -368,7 +368,7 @@ void EveChildInstanceMeshRenderer::UpdateInstanceData( std::vectorGetData( unsigned( instances.size() ) ); memcpy( dest, &instances[0], sizeof( instances[0] ) * instances.size() ); geoRes->UpdateData(); - + float maxScale = 0; CcpMath::AxisAlignedBox aabb; for( auto& instance : instances ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h index dbbd8d24e..0a9c2929d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer.h @@ -15,7 +15,7 @@ BLUE_DECLARE_INTERFACE( IEveDistributionMethod ); -BLUE_CLASS( EveChildInstanceMeshRenderer ): +BLUE_CLASS( EveChildInstanceMeshRenderer ) : public EveChildMesh { public: @@ -27,7 +27,7 @@ BLUE_CLASS( EveChildInstanceMeshRenderer ): bool IsVisible( const EveUpdateContext& updateContext ) const override; bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ) override; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void ConfigureInstanceData() const; virtual uint32_t GetNumberOfEntities() const; diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp index 5fa7dfda0..cb209e33b 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstanceMeshRenderer_Blue.cpp @@ -41,6 +41,6 @@ const Be::ClassInfo* EveChildInstanceMeshRenderer::ExposeToBlue() MAP_ATTRIBUTE( "minScreenSize", m_minScreenSize, "", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "RefreshStaticGeometry", RefreshStaticGeometry, "if static geo parameters were changed during authoring: refresh here\n:jessica-placement: TOOLBAR" ) - + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp index ec8a6c46b..4bc9ddbef 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.cpp @@ -141,14 +141,14 @@ void EveChildInstancedMeshes::PushRtGeometry( Tr2RaytracingManager& rtManager ) } XMMATRIX m = *reinterpret_cast( instanceTransform.worldTransform ); - m.r[3] = XMVectorSet( 0, 0, 0, 1 ); + m.r[3] = XMVectorSet( 0, 0, 0, 1 ); m = XMMatrixMultiply( XMMatrixTranspose( m ), m_worldTransform ); mesh.rtMeshes[lodIndex].instanceWorldTransforms.push_back( Float4x3( Matrix( m ) ) ); } for( auto& lod : mesh.rtMeshes ) { - if ( lod.instanceWorldTransforms.empty() ) + if( lod.instanceWorldTransforms.empty() ) { continue; } @@ -187,7 +187,6 @@ void EveChildInstancedMeshes::UpdateVisibility( const EveUpdateContext& updateCo void EveChildInstancedMeshes::GetRenderables( std::vector& renderables ) { - } bool EveChildInstancedMeshes::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const @@ -272,7 +271,7 @@ void EveChildInstancedMeshes::UpdateAsyncronous( const EveUpdateContext& updateC if( !mesh.instanceSpheres.empty() ) { - if ( mesh.sphereHandle ) + if( mesh.sphereHandle ) { mesh.sphereHandle.owner->SetSphereGroupBounds( mesh.sphereHandle, mesh.worldBoundingSphere, mesh.flags ); } @@ -316,7 +315,7 @@ void EveChildInstancedMeshes::UpdateAsyncronous( const EveUpdateContext& updateC lod.rtMesh->UpdateRtMesh( mesh.geometry, mesh.meshIndex, lod.maxScreenSize ); for( auto& area : mesh.areas ) { - if ( area.batchType != TRIBATCHTYPE_OPAQUE ) + if( area.batchType != TRIBATCHTYPE_OPAQUE ) { continue; } @@ -339,12 +338,11 @@ void EveChildInstancedMeshes::Setup( const Vector3* scale, const Quaternion* rot void EveChildInstancedMeshes::ChangeLOD( Tr2Lod lod ) { - } void EveChildInstancedMeshes::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - for( auto& mesh: m_meshes ) + for( auto& mesh : m_meshes ) { for( auto& area : mesh.areas ) { @@ -361,7 +359,7 @@ void EveChildInstancedMeshes::SetShaderOption( const BlueSharedString& name, con } -void EveChildInstancedMeshes::AddMesh( +void EveChildInstancedMeshes::AddMesh( const char* geometryPath, bool castsShadow, EntityComponents::ReflectionMode reflectionMode, @@ -392,7 +390,7 @@ void EveChildInstancedMeshes::AddMesh( a.effectHash = a.effect ? a.effect->GetHashValue() : 0; } mesh.instances.reserve( count ); - for ( size_t i = 0; i < count; ++i ) + for( size_t i = 0; i < count; ++i ) { EveInstancedMeshManager::StaticPerInstanceData instanceData; auto& mat = instanceTransforms[i]; @@ -442,7 +440,7 @@ void EveChildInstancedMeshes::RebuildCachedData( BlueAsyncRes* p ) { mesh.combinedVertexDeclaration = Tr2EffectStateManager::UNINITIALIZED_DECLARATION; - if ( auto data = mesh.geometry->GetMeshData( mesh.meshIndex ) ) + if( auto data = mesh.geometry->GetMeshData( mesh.meshIndex ) ) { Tr2VertexDefinition elements; if( Tr2EffectStateManager::GetVertexDeclarationElements( data->m_vertexDeclarationHandle, elements ) ) @@ -570,7 +568,7 @@ void EveChildInstancedMeshes::RenderDebugInfo( ITr2DebugRenderer2& renderer ) continue; } renderer.DrawSphere( this, mesh.worldBoundingSphere.center, mesh.worldBoundingSphere.radius, 20, ITr2DebugRenderer2::Wireframe, Tr2DebugColor( 0xffaa8800, 0x22aa8800 ) ); - for ( auto& sphere : mesh.instanceSpheres ) + for( auto& sphere : mesh.instanceSpheres ) { renderer.DrawSphere( this, sphere.center, sphere.radius, 10, ITr2DebugRenderer2::Wireframe, Tr2DebugColor( 0xff008800, 0x22008800 ) ); } @@ -652,7 +650,7 @@ BluePy EveChildInstancedMeshes::GetMeshDisplay( uint32_t meshId ) const return {}; } auto& mesh = m_meshes[meshId]; - if ( mesh.display ) + if( mesh.display ) { return BluePy( Py_True, true ); } @@ -670,7 +668,7 @@ BluePy EveChildInstancedMeshes::SetMeshDisplay( uint32_t meshId, bool display ) return {}; } auto& mesh = m_meshes[meshId]; - if ( mesh.display != display ) + if( mesh.display != display ) { mesh.display = display; m_allRegistered = false; @@ -704,4 +702,3 @@ bool EveChildInstancedMeshes::OnPrepareResources() { return true; } - diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h index f73fc1da5..5a25e441d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes.h @@ -29,11 +29,11 @@ BLUE_CLASS( EveChildInstancedMeshes ) : const char* GetName() const override; void SetName( const char* name ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector& renderables ) override; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const override; + void GetRenderables( std::vector & renderables ) override; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void GetLocalToWorldTransform( Matrix& transform ) const override; + void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; void ChangeLOD( Tr2Lod lod ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -72,14 +72,14 @@ BLUE_CLASS( EveChildInstancedMeshes ) : EveInstancedMeshManager::MeshGroupHandle meshGroupHandle; }; - void AddMesh( - const char* geometryPath, - bool castsShadow, - EntityComponents::ReflectionMode reflectionMode, - uint32_t meshIndex, + void AddMesh( + const char* geometryPath, + bool castsShadow, + EntityComponents::ReflectionMode reflectionMode, + uint32_t meshIndex, const MeshArea* areas, size_t areaCount, - const Matrix* instanceTransforms, + const Matrix* instanceTransforms, size_t count, const BlueSharedString& sofHullName, const BlueSharedString& sofLocatorSetName ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp index a352dea0f..59c4d83b7 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildInstancedMeshes_Blue.cpp @@ -26,9 +26,9 @@ const Be::ClassInfo* EveChildInstancedMeshes::ExposeToBlue() ":param areaId: The areaID returned from mouse picking method\n" ":rtype: None | (str, str, int)" ) - MAP_METHOD_AND_WRAP( - "GetMeshCount", - GetMeshCount, + MAP_METHOD_AND_WRAP( + "GetMeshCount", + GetMeshCount, "Returns the number of instanced meshes in this object." ) MAP_METHOD_AND_WRAP( "GetMeshInfo", diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp index cd82734a6..23bfe5459 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.cpp @@ -14,7 +14,7 @@ IEveLightingOverride::Overrides IEveLightingOverride::Overrides::operator*( floa return result; } -IEveLightingOverride::Overrides IEveLightingOverride::Overrides::operator + ( const Overrides& rhs ) const +IEveLightingOverride::Overrides IEveLightingOverride::Overrides::operator+( const Overrides& rhs ) const { Overrides result = *this; result.sunColor += rhs.sunColor; @@ -39,7 +39,7 @@ EveChildLightingOverride::EveChildLightingOverride( IRoot* lockobj ) : m_overrides.intensity = 0.0f; } -EveChildLightingOverride::OverrideInfo EveChildLightingOverride::GetOverrides() const +EveChildLightingOverride::OverrideInfo EveChildLightingOverride::GetOverrides() const { return m_overrides; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h index d44754c28..c786b7f34 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLightingOverride.h @@ -55,16 +55,16 @@ BLUE_CLASS( EveChildLightingOverride ) : // IEveSpaceObjectChild const char* GetName() const override; void SetName( const char* name ) override; - void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override{}; + void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override {}; void GetRenderables( std::vector & renderables ) override{}; bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const override; - void ChangeLOD( Tr2Lod lod ) override{}; + void ChangeLOD( Tr2Lod lod ) override {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override{}; + void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override {}; void RegisterComponents() override; void UnRegisterComponents() override; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h index fc3ae7522..56146263b 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet.h @@ -37,7 +37,7 @@ BLUE_CLASS( EveChildLineSet ) : ////////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild @@ -53,7 +53,7 @@ BLUE_CLASS( EveChildLineSet ) : void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override {}; void GetRenderables( std::vector & renderables ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override {}; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override{}; ///////////////////////////////////////////////////////////////////////////////////// // Tr2DeviceResource @@ -76,24 +76,31 @@ BLUE_CLASS( EveChildLineSet ) : ///////////////////////////////////////////////////////////////////////////////////// // Debug - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; - void GetWorldVelocity( Vector3& velocity ) const; + void GetWorldVelocity( Vector3 & velocity ) const; ///////////////////////////////////////////////////////////////////////////////////// // EveChildLineSet Tr2MeshPtr GetMesh() const; float GetOwnerMaxSpeed() const; void CreateSpriteVertexDeclaration(); - float GetSortValue() { return 0.f; }; - void UpdateBuffer( Tr2RenderContext& renderContext ); + float GetSortValue() + { + return 0.f; + }; + void UpdateBuffer( Tr2RenderContext & renderContext ); std::vector> GetVertexElementAddedThroughCode() const; - enum lineSetType { OBJECT_RENDER, LINE_RENDER, BOTH }; + enum lineSetType + { + OBJECT_RENDER, + LINE_RENDER, + BOTH + }; private: - void InitializeLineSet(); void GenerateManagedPoints(); void UpdateBoundingSphere( bool reCalculateChildren = true ); @@ -101,7 +108,7 @@ BLUE_CLASS( EveChildLineSet ) : BlueSharedString m_name; Vector3 m_worldVelocity; float m_ownerMaxSpeed; - + bool m_display; bool m_isAlwaysOn; bool m_updateLineSet; @@ -132,7 +139,7 @@ BLUE_CLASS( EveChildLineSet ) : //animate - lineRender float m_scrollSpeed; - + // visibility culls Vector4 m_boundingSphere; float m_currentScreenSize; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp index 8c82aac0c..63fd188f8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLineSet_Blue.cpp @@ -4,8 +4,7 @@ #include "EveChildLineSet.h" #include "Behaviors/BehaviorGroup.h" -Be::VarChooser LineSetTypeChooser[] = -{ +Be::VarChooser LineSetTypeChooser[] = { { "ObjectRender", BeCast( EveChildLineSet::OBJECT_RENDER ), "sprites or other objects are rendered at each segment" }, { "LineRender", BeCast( EveChildLineSet::LINE_RENDER ), "To render a 3dLine shader between the points" }, { "Both", BeCast( EveChildLineSet::BOTH ), "Both of the above" }, @@ -41,9 +40,9 @@ const Be::ClassInfo* EveChildLineSet::ExposeToBlue() MAP_ATTRIBUTE( "brightness", m_brightness, "a multiplier for the animColor render\n:jessica-group: LineRender", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "baseColor", m_baseColor, "color for lines\n:jessica-group: LineRender", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "animColor", m_animColor, "color for lines\n:jessica-group: LineRender", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + MAP_METHOD_AND_WRAP( "GetVertexElementAddedThroughCode", GetVertexElementAddedThroughCode, "for validation and objects requiring vertex elements added to the shader through code\n:jessica-hidden: True" ) - + // leafs MAP_ATTRIBUTE( "lines", m_lines, "define any number of lines/paths to draw", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "lineSet", m_lineSet, ":jessica-hidden: True", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildLink.cpp b/trinity/Eve/SpaceObject/Children/EveChildLink.cpp index a9f508b93..7fc935da8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLink.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLink.cpp @@ -50,7 +50,7 @@ void EveChildLink::UpdateSyncronous( const EveUpdateContext& updateContext, cons // source is from parent Vector3 srcPos; - if ( params.spaceObjectParent ) + if( params.spaceObjectParent ) { params.spaceObjectParent->GetModelCenterWorldPosition( srcPos ); } @@ -76,12 +76,12 @@ void EveChildLink::UpdateAsyncronous( const EveUpdateContext& updateContext, con // update the special link curves for( ITriFunctionVector::const_iterator it = m_linkStrengthCurves.begin(); it != m_linkStrengthCurves.end(); ++it ) { - (*it)->UpdateValue( m_linkStrength ); + ( *it )->UpdateValue( m_linkStrength ); } for( ITr2ValueBindingVector::const_iterator it = m_linkStrengthBindings.begin(); it != m_linkStrengthBindings.end(); ++it ) { - (*it)->CopyValue(); + ( *it )->CopyValue(); } // get parent worldmatrix and parent's shield ellipsoid offset @@ -100,7 +100,7 @@ void EveChildLink::UpdateAsyncronous( const EveUpdateContext& updateContext, con p->GetShapeEllipsoid( shieldEllipsoidCenter, t ); } } - else + else { return; } @@ -117,11 +117,11 @@ void EveChildLink::UpdateAsyncronous( const EveUpdateContext& updateContext, con } else { - // link strength comes from distance vs. barrier - float div = abs(m_linkBarrier - m_targetRadius ) ; + // link strength comes from distance vs. barrier + float div = abs( m_linkBarrier - m_targetRadius ); m_linkStrength = TriClamp( 1.0f - ( m_currentDistance - m_targetRadius ) / div, 0.f, 1.f ); } - + // need inverse rotation-only from worldmatrix Matrix invRotationWorldMat; TriMatrixRemoveTranslation( &invRotationWorldMat, &m_worldTransform ); @@ -142,7 +142,7 @@ void EveChildLink::UpdateAsyncronous( const EveUpdateContext& updateContext, con // update perobject data buffers m_perObjectDataVs.InvalidateBufferData(); m_perObjectDataPs.InvalidateBufferData(); - + if( params.spaceObjectParent ) { params.spaceObjectParent->GetPerObjectStructs( m_vsData, m_psData ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildLink.h b/trinity/Eve/SpaceObject/Children/EveChildLink.h index 1b8992090..bcfeb78a3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLink.h +++ b/trinity/Eve/SpaceObject/Children/EveChildLink.h @@ -20,15 +20,15 @@ BLUE_CLASS( EveChildLink ) : EveChildLink( IRoot* lockobj = NULL ); ~EveChildLink(); - + ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ) {}; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query ) const; bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const override; diff --git a/trinity/Eve/SpaceObject/Children/EveChildLink_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildLink_Blue.cpp index 3b355140c..0778f0421 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildLink_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildLink_Blue.cpp @@ -7,9 +7,9 @@ BLUE_DEFINE( EveChildLink ); const Be::ClassInfo* EveChildLink::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildLink, "" ) - MAP_INTERFACE( EveChildLink ) - MAP_INTERFACE( EveChildMesh ) + EXPOSURE_BEGIN( EveChildLink, "" ) + MAP_INTERFACE( EveChildLink ) + MAP_INTERFACE( EveChildMesh ) MAP_ATTRIBUTE( "currentDirection", m_currentDirection, "Current normalized direction to link source in worldspace", Be::READ ) MAP_ATTRIBUTE( "currentDistance", m_currentDistance, "Current distance to link source", Be::READ ) @@ -20,5 +20,5 @@ const Be::ClassInfo* EveChildLink::ExposeToBlue() MAP_ATTRIBUTE( "linkStrengthCurves", m_linkStrengthCurves, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "linkStrengthBindings", m_linkStrengthBindings, "", Be::READ | Be::PERSIST ) - EXPOSURE_CHAINTO( EveChildMesh ) + EXPOSURE_CHAINTO( EveChildMesh ) } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp index 9b3615575..a9efa903e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.cpp @@ -49,9 +49,9 @@ EveChildMesh::EveChildMesh( IRoot* lockobj ) : m_instanceCount( 0 ), m_morphAnimationOffsets( {} ), m_audioInstanceId( EveSpaceObject2::NextAudioInstanceId() ), - m_audioGeometrySetId(0), - m_audioGeometryRegistered(false), - m_allowAudioGeometry(true), + m_audioGeometrySetId( 0 ), + m_audioGeometryRegistered( false ), + m_allowAudioGeometry( true ), EveChildTransform(), EveEntity( lockobj ) { @@ -135,7 +135,7 @@ void EveChildMesh::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* } } - if ( list == &m_lights ) + if( list == &m_lights ) { auto maskedEvent = event & BELIST_EVENTMASK; if( ( maskedEvent == BELIST_UNLOADSTART ) || ( ( maskedEvent == BELIST_REMOVED ) && m_lights.empty() ) ) @@ -192,7 +192,7 @@ void EveChildMesh::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* bool EveChildMesh::OnModified( Be::Var* val ) { - if( IsMatch( val, m_reflectionMode ) || IsMatch( val, m_display) || IsMatch( val, m_mesh) || IsMatch( val, m_castShadow ) ) + if( IsMatch( val, m_reflectionMode ) || IsMatch( val, m_display ) || IsMatch( val, m_mesh ) || IsMatch( val, m_castShadow ) ) { ReRegister(); } @@ -239,7 +239,7 @@ void EveChildMesh::InitializeAnimation() void EveChildMesh::RegisterComponents() { auto registry = this->GetComponentRegistry(); - if( registry && m_display ) + if( registry && m_display ) { if( !m_lights.empty() ) { @@ -329,7 +329,7 @@ bool EveChildMesh::IsCastingShadow( const TriFrustum& cameraFrustum, const IEveS } else { - sizeInShadow = shadowFrustum.GetSizeInShadow( bs ); + sizeInShadow = shadowFrustum.GetSizeInShadow( bs ); } } return sizeInShadow > 5.f; @@ -390,7 +390,7 @@ void EveChildMesh::UpdateVisibility( const EveUpdateContext& updateContext, cons { bounds = m_mesh->GetBounds(); } - + bounds.Transform( m_worldTransform ); m_currentScreenSize = frustum.GetPixelSizeAccross( m_worldBoundingSphere ); @@ -506,18 +506,18 @@ void EveChildMesh::UpdateRtSkeleton() { return; } - + auto meshIndex = m_mesh->GetMeshIndex(); auto lod = m_mesh->GetGeometryResource()->GetMeshLod( meshIndex, m_currentScreenSize ); if( !lod ) { return; } - + // check skinning bool hasSkinned = false; - - auto areas = m_mesh->GetAreas( TRIBATCHTYPE_OPAQUE ); + + auto areas = m_mesh->GetAreas( TRIBATCHTYPE_OPAQUE ); for( auto it = begin( *areas ); it != end( *areas ); ++it ) { if( lod->m_areas[std::max( 0, ( *it )->GetIndex() )].m_isSkinned ) @@ -559,7 +559,7 @@ void EveChildMesh::UpdateRtSkeleton() for( auto it = begin( *areas ); it != end( *areas ); ++it ) { auto meshAreaIndex = std::max( 0, ( *it )->GetIndex() ); - + if( lod->m_areas[meshAreaIndex].m_isSkinned || lod->m_areas[meshAreaIndex].m_isMorphed ) { ( *it )->GetRtMeshArea()->MarkBlasOutdated(); @@ -572,20 +572,20 @@ void EveChildMesh::GetRenderables( std::vector& renderables ) { if( m_isVisible ) { - if( m_instancedMesh ) + if( m_instancedMesh ) { if( m_instancesVisible ) { renderables.push_back( this ); - if (!m_decals.empty()) + if( !m_decals.empty() ) { auto geometryRes = m_mesh->GetGeometryResource(); - if (geometryRes) + if( geometryRes ) { DecalMeshCache meshCache; // run over every decal and update it - for (EveSpaceObjectDecalVector::const_iterator it = m_decals.begin(); it != m_decals.end(); ++it) + for( EveSpaceObjectDecalVector::const_iterator it = m_decals.begin(); it != m_decals.end(); ++it ) { // now prep to get the renderables ( *it )->GetInstancedRenderables( renderables, meshCache, m_instancedMesh, m_currentInstanceScreenSize ); @@ -630,7 +630,7 @@ bool EveChildMesh::HasTransparentBatches() { if( m_display && m_mesh ) { - return !(m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty()); + return !( m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty() ); } return false; @@ -657,14 +657,14 @@ void EveChildMesh::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType { m_mesh->GetBatches( batches, m_mesh->GetAreas( batchType ), perObjectData, min( m_currentInstanceScreenSize, m_currentScreenSize ) ); } - + if( m_activationStrength != 0.0 ) { for( auto it = begin( m_attachments ); it != end( m_attachments ); ++it ) { ( *it )->GetBatches( batches, batchType, perObjectData, reason ); } - } + } } } @@ -687,7 +687,7 @@ void EveChildMesh::PushRtGeometry( Tr2RaytracingManager& rtManager ) const auto rtMesh = m_mesh->GetRtMesh(); - if ( !rtMesh || !rtMesh->IsGood() ) + if( !rtMesh || !rtMesh->IsGood() ) { return; } @@ -717,7 +717,7 @@ void EveChildMesh::PushRtGeometry( Tr2RaytracingManager& rtManager ) const auto m = XMMatrixMultiply( instanceTransform, m_worldTransform ); m_instanceWorldTransforms.push_back( Float4x3( Matrix( m ) ) ); } - + auto idm = IdentityMatrix(); UpdateRtPerObjectData( m_psData, &idm, renderContext, m_rtPerObjectData ); @@ -821,7 +821,7 @@ Tr2PerObjectData* EveChildMesh::GetPerObjectData( ITriRenderBatchAccumulator* ac m_vsData.bakedMorphTargetVertexDataOffset = m_bakedMorphAllocation.GetOffset(); } } - } + } auto [bones, boneCount] = GetBoneTransforms(); m_vsData.boneOffsets[2] = uint32_t( boneCount ); @@ -912,7 +912,7 @@ void EveChildMesh::UpdateAsyncronous( const EveUpdateContext& updateContext, con UpdateTransform( localToWorldTransform ); for( auto it = m_transformModifiers.begin(); it != m_transformModifiers.end(); it++ ) { - m_worldTransform = (*it)->ApplyTransform( m_worldTransform, params.boneCount, params.bones ); + m_worldTransform = ( *it )->ApplyTransform( m_worldTransform, params.boneCount, params.bones ); } bool allowAudioGeometry = !params.spaceObjectParent || params.spaceObjectParent->IsAudioOccluder(); @@ -936,7 +936,7 @@ void EveChildMesh::UpdateAsyncronous( const EveUpdateContext& updateContext, con // need to move the clipdata inversely of the translation of the childmesh m_vsData.clipData = Vector4( m_vsData.clipData.GetXYZ() - m_translation, m_vsData.clipData.w ); m_psData.clipSphereCenter = m_psData.clipSphereCenter - m_translation; - + // update the world transform of the parent m_parentData.transform = m_worldTransform; } @@ -1150,7 +1150,7 @@ bool EveChildMesh::IsAlwaysOn() const void EveChildMesh::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - if ( nullptr != m_mesh ) + if( nullptr != m_mesh ) { m_mesh->SetShaderOption( name, value ); } @@ -1196,7 +1196,7 @@ void EveChildMesh::RenderDebugInfo( ITr2DebugRenderer2& renderer ) } if( m_mesh ) { - if ( m_animationUpdater && m_animationUpdater->IsInitialized() ) + if( m_animationUpdater && m_animationUpdater->IsInitialized() ) { auto [meshBindingIndices, boneCount] = GetMeshBindingIndices(); auto [morphTargets, morphTargetCount] = GetMorphTargets( MorphTargetAnimationFilter::ALL ); @@ -1314,12 +1314,12 @@ std::pair EveChildMesh::GetMorphTarg result = std::make_pair( m_morphAnimationBuffer.data(), m_morphAnimationOffsets.m_allCount ); break; case MorphTargetAnimationFilter::RUNTIME_EVALUATED: - if ( m_isMorphsBaked ) + if( m_isMorphsBaked ) { result = std::make_pair( m_morphAnimationBuffer.data() + m_morphAnimationOffsets.m_runtimeEvaluatedOffset, m_morphAnimationOffsets.m_runtimeEvaluatedCount ); } else - { + { // as long as the baking code hasn't been executed yet, we will rely on runtime evaluation for everything result = std::make_pair( m_morphAnimationBuffer.data(), m_morphAnimationOffsets.m_allCount ); } @@ -1386,7 +1386,7 @@ void EveChildMesh::UpdateMorphAnimationBuffer() m_morphAnimationOffsets.m_runtimeEvaluatedOffset = 0; m_morphAnimationOffsets.m_runtimeEvaluatedCount = uint32_t( std::distance( m_morphAnimationBuffer.begin(), runtimeEvaluatedEnd ) ); - + // the baked values follow the runtime evaluated values in the buffer auto bakedEnd = std::partition( runtimeEvaluatedEnd, m_morphAnimationBuffer.end(), [&]( const Tr2MorphTargetAnimationData& data ) { return data.m_weight >= EPSILON && m_mesh->IsBakedMorph( data.m_index ); @@ -1412,7 +1412,7 @@ void EveChildMesh::BakeMorphs() m_mergeMorphsEffect->StartUpdate(); m_mergeMorphsEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/System/MorphBaking.fx" ); m_mergeMorphsEffect->EndUpdate(); - } + } // Set baked morph weights m_bakeMorphs = true; @@ -1505,7 +1505,7 @@ bool EveChildMesh::PrepareMorphBuffers( Tr2RenderContext& renderContext ) Tr2VertexDefinition::Item* positionItem = vertexDefinition.Find( Tr2VertexDefinition::POSITION ); Tr2VertexDefinition::Item* tangentItem = vertexDefinition.Find( Tr2VertexDefinition::TANGENT ); - if(positionItem) + if( positionItem ) { data->vertexDataPositionOffset = positionItem->m_offset; } @@ -1523,7 +1523,6 @@ bool EveChildMesh::PrepareMorphBuffers( Tr2RenderContext& renderContext ) data->vertexDataTangentOffset = std::numeric_limits::max(); } } - } m_mergeMorphsConstantBuffer.Unlock( renderContext ); @@ -1557,11 +1556,10 @@ bool EveChildMesh::UpdateMeshMorphs( Tr2RenderContext& renderContext ) Tr2Renderer::RunComputeShader( m_mergeMorphsEffect, BlueSharedString( "MorphBaking" ), - (vertexCount + 63) / 64, + ( vertexCount + 63 ) / 64, 1, 1, - renderContext - ); + renderContext ); auto rtMesh = m_mesh->GetRtMesh(); @@ -1620,7 +1618,7 @@ const std::pair EveChildMesh::GetMeshBindingIndices() co return std::make_pair( nullptr, 0 ); } - + void EveChildMesh::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { if( m_attachments.empty() || !m_isVisible || !m_display ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh.h b/trinity/Eve/SpaceObject/Children/EveChildMesh.h index d9dae7e09..54d5e1b52 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh.h +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh.h @@ -82,18 +82,18 @@ BLUE_CLASS( EveChildMesh ) : const char* GetName() const; void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ) override; virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); bool IsAlwaysOn() const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; void SetScale( const Vector3& scale ); - void AddTransformModifier( IEveChildTransformModifier* modifier ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; @@ -109,9 +109,9 @@ BLUE_CLASS( EveChildMesh ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual bool HasTransparentBatches(); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); virtual bool IsVisible( const EveUpdateContext& updateContext ) const override; ///////////////////////////////////////////////////////////////////////////////////// @@ -124,19 +124,19 @@ BLUE_CLASS( EveChildMesh ) : ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectAttachmentOwner - void AddAttachment( IEveSpaceObjectAttachment* attachment ); + void AddAttachment( IEveSpaceObjectAttachment * attachment ); void ClearAttachments(); ///////////////////////////////////////////////////////////////////////////////////// // IEveLightOwner - virtual void GetLights( Tr2LightManager& lightManager ) const override; - virtual void AddLight( Tr2Light* newLight ) override; + virtual void GetLights( Tr2LightManager & lightManager ) const override; + virtual void AddLight( Tr2Light * newLight ) override; virtual void ClearLights() override; - + ///////////////////////////////////////////////////////////////////////////////////// // IEveShadowCaster bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const override; @@ -147,8 +147,8 @@ BLUE_CLASS( EveChildMesh ) : void MarkRtDirty() override; bool IsShadowCastingDirty() const override; - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; ///////////////////////////////////////////////////////////////////////////////////// // PerObjectData @@ -161,14 +161,14 @@ BLUE_CLASS( EveChildMesh ) : void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) override; // access - void SetMesh( Tr2MeshBase* mesh ); + void SetMesh( Tr2MeshBase * mesh ); void SetOrigin( Origin origin ); void SetReflectionMode( EntityComponents::ReflectionMode reflectionMode ); void SetCastShadow( bool castShadow ); void SetMinScreenSize( float minScreenSize ); Tr2GrannyAnimation* GetAnimationController() const override; - void SetAnimationController( Tr2GrannyAnimation* animation ); + void SetAnimationController( Tr2GrannyAnimation * animation ); void SetInstanceTransforms( std::vector instances ); @@ -210,7 +210,7 @@ BLUE_CLASS( EveChildMesh ) : // the mesh Tr2MeshBasePtr m_mesh; - Tr2InstancedMeshPtr m_instancedMesh; // Cached downcast of m_mesh + Tr2InstancedMeshPtr m_instancedMesh; // Cached downcast of m_mesh IEveSpaceObject2::ParentData m_parentData; PIEveChildTransformModifierVector m_transformModifiers; diff --git a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp index bde228f30..de99e6f6a 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildMesh_Blue.cpp @@ -7,9 +7,9 @@ BLUE_DEFINE( EveChildMesh ); const Be::ClassInfo* EveChildMesh::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildMesh, "" ) - MAP_INTERFACE( EveChildMesh ) - MAP_INTERFACE( EveEntity ) + EXPOSURE_BEGIN( EveChildMesh, "" ) + MAP_INTERFACE( EveChildMesh ) + MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveSpaceObjectDecalOwner ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) @@ -21,7 +21,7 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() MAP_INTERFACE( ITr2Pickable ) MAP_INTERFACE( IEveShadowCaster ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "castShadow", m_castShadow, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "updateAnimation", m_updateAnimation, "Should the object update its animation updater every frame", Be::READWRITE | Be::PERSIST ) @@ -33,16 +33,16 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() "Granny animation exposure", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "Lowest LOD this guy is visible\n:jessica-group: LOD", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minScreenSize", - m_minScreenSize, - "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", + MAP_ATTRIBUTE( + "minScreenSize", + m_minScreenSize, + "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ) + MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_ATTRIBUTE( "currentInstanceScreenSize", m_currentInstanceScreenSize, "Screen size of instances for last frame\n:jessica-group: LOD", Be::READ ) MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) @@ -58,19 +58,18 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() MAP_ATTRIBUTE( "lights", m_lights, "Lights attached to the object", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) - + MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When is this object rendered into the cubemap", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, EntityComponents::ReflectionModeChooser ); - MAP_METHOD_AND_WRAP( - "GetSofSourceLocator", - GetSofSourceLocator, + MAP_METHOD_AND_WRAP( + "GetSofSourceLocator", + GetSofSourceLocator, "Returns SOF locator source information for the mesh given the picked areaID.\n" "Returns a tuple (SOF hull name, locator set name, locator index) or None if no SOF source is found.\n" "For the method to work the space object should have been built using SOF in the editor mode.\n\n" ":param areaId: The areaID returned from mouse picking method\n" - ":rtype: None | (str, str, int)" - ) - + ":rtype: None | (str, str, int)" ) + MAP_METHOD_AND_WRAP( "GetMorphTargetNames", GetMorphTargetNames, @@ -89,5 +88,5 @@ const Be::ClassInfo* EveChildMesh::ExposeToBlue() "GetMorphTargetWeight( name )\n\n" "Returns the weight of the morph target. Returns 0 if no morph target with that name was found.\n" ":param name: morph target name\n" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp index 5427007bf..6d01b4d4e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.cpp @@ -15,36 +15,36 @@ namespace { - class EveChildParticleSpherePerObjectData : public Tr2PerObjectData +class EveChildParticleSpherePerObjectData : public Tr2PerObjectData +{ +public: + virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { - public: - virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const - { - static const unsigned mask = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ); - FillAndSetConstants( - *buffers[m_bufferType], - &m_data, - sizeof( m_data ), - mask, - m_register, - renderContext ); - } + static const unsigned mask = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ); + FillAndSetConstants( + *buffers[m_bufferType], + &m_data, + sizeof( m_data ), + mask, + m_register, + renderContext ); + } - struct Data - { - Matrix m_world; - Matrix m_worldInverseTranspose; - } m_data; + struct Data + { + Matrix m_world; + Matrix m_worldInverseTranspose; + } m_data; - int32_t m_bufferType; - int32_t m_register; - }; + int32_t m_bufferType; + int32_t m_register; +}; } // ----------------------------------------------------------------------------- -EveChildParticleSphere::EveChildParticleSphere( IRoot* lockobj ) - :PARENTLOCK( m_generators ), +EveChildParticleSphere::EveChildParticleSphere( IRoot* lockobj ) : + PARENTLOCK( m_generators ), m_worldTransform( IdentityMatrix() ), m_boundingSphere( 0, 0, 0, 500 ), m_bindStatus( BIND_PENDING ), @@ -260,11 +260,10 @@ void EveChildParticleSphere::Refresh() m_particleSystem->UpdateElementDeclaration(); - const Tr2ParticleElementDataMap &declaration = m_particleSystem->GetElementDeclaration(); + const Tr2ParticleElementDataMap& declaration = m_particleSystem->GetElementDeclaration(); std::set elements; - auto Bind = [&]( Tr2ParticleElementDeclarationName::Type type ) -> Tr2ParticleElementData - { + auto Bind = [&]( Tr2ParticleElementDeclarationName::Type type ) -> Tr2ParticleElementData { Tr2ParticleElementDeclarationName element( type ); if( elements.find( element ) == elements.end() ) { @@ -322,8 +321,7 @@ void EveChildParticleSphere::ApplyConstraint( const Vector3& previousReferencePo return; } - auto constraint = [&]( float** particles, unsigned* strides, unsigned count ) - { + auto constraint = [&]( float** particles, unsigned* strides, unsigned count ) { Tr2ParticleStreamIterator position( particles, strides, m_positionElement ); Tr2ParticleStreamIterator velocity( particles, strides, m_velocityElement ); Tr2ParticleStreamIterator lifetime( particles, strides, m_lifetimeElement ); @@ -361,8 +359,7 @@ void EveChildParticleSphere::ApplyConstraint( const Vector3& previousReferencePo // ----------------------------------------------------------------------------- void EveChildParticleSphere::FillParticleData( float** particle, const Vector3& previousReferencePosition, const Vector3& velocityDirection ) { - auto randf = []() - { + auto randf = []() { return float( rand() ) / RAND_MAX; }; @@ -424,8 +421,7 @@ void EveChildParticleSphere::AddParticles( const Vector3& previousReferencePosit return; } - auto randf = []() - { + auto randf = []() { return float( rand() ) / RAND_MAX; }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h index b573fdb80..975b379a2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSphere.h @@ -26,25 +26,26 @@ BLUE_CLASS( EveChildParticleSphere ) : // IEveSpaceObjectChild const char* GetName() const; void SetName( const char* name ); - void GetRenderables( std::vector& renderables ); + void GetRenderables( std::vector & renderables ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); void ChangeLOD( Tr2Lod lod ) {}; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); bool HasTransparentBatches(); float GetSortValue(); - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); bool CheckBinding(); void Refresh(); + private: void Update( const EveUpdateContext& updateContext ); void ApplyConstraint( const Vector3& previousReferencePosition, const Vector3& velocityDirection ); diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp index a4fd8a586..1fe57bbf2 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.cpp @@ -16,7 +16,7 @@ #include "Utilities/BoundingSphere.h" -EveChildParticleSystem::EveChildParticleSystem( IRoot* lockobj ): +EveChildParticleSystem::EveChildParticleSystem( IRoot* lockobj ) : EveChildTransform(), PARENTLOCK( m_particleEmitters ), PARENTLOCK( m_particleSystems ), @@ -68,9 +68,9 @@ void EveChildParticleSystem::RegisterComponents() } -bool EveChildParticleSystem::OnModified( Be::Var* value) +bool EveChildParticleSystem::OnModified( Be::Var* value ) { - if( IsMatch(value, m_reflectionMode) || IsMatch(value, m_display)) + if( IsMatch( value, m_reflectionMode ) || IsMatch( value, m_display ) ) { ReRegister(); } @@ -115,7 +115,7 @@ void EveChildParticleSystem::UpdateVisibility( const EveUpdateContext& updateCon { for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - (*it)->UpdateViewDependentData( &frustum, m_worldTransform ); + ( *it )->UpdateViewDependentData( &frustum, m_worldTransform ); } } } @@ -136,7 +136,7 @@ void EveChildParticleSystem::GetRenderables( std::vector& rende for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - (*it)->SortParticles(); + ( *it )->SortParticles(); } renderables.push_back( this ); @@ -144,7 +144,7 @@ void EveChildParticleSystem::GetRenderables( std::vector& rende bool EveChildParticleSystem::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { - if( m_boundingSphere.w == -1 ) + if( m_boundingSphere.w == -1 ) { return false; } @@ -156,7 +156,7 @@ bool EveChildParticleSystem::HasTransparentBatches() { if( m_display && m_mesh ) { - return !(m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty()); + return !( m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty() ); } return false; @@ -164,7 +164,7 @@ bool EveChildParticleSystem::HasTransparentBatches() void EveChildParticleSystem::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { - if( m_display && m_mesh && m_mesh->GetAreas(batchType)->size() != 0 ) + if( m_display && m_mesh && m_mesh->GetAreas( batchType )->size() != 0 ) { m_mesh->GetBatches( batches, m_mesh->GetAreas( batchType ), perObjectData, std::numeric_limits::max(), reason == Tr2RenderReason::TR2RENDERREASON_REFLECTION ); } @@ -214,9 +214,9 @@ void EveChildParticleSystem::UpdateAsyncronous( const EveUpdateContext& updateCo UpdateTransform( localToWorldTransform ); for( auto it = m_transformModifiers.begin(); it != m_transformModifiers.end(); ++it ) { - m_worldTransform = (*it)->ApplyTransform( m_worldTransform, params.boneCount, params.bones ); + m_worldTransform = ( *it )->ApplyTransform( m_worldTransform, params.boneCount, params.bones ); } - + Vector3 minBounds, maxBounds; if( m_mesh && m_mesh->GetBoundingBox( minBounds, maxBounds ) ) { @@ -227,7 +227,7 @@ void EveChildParticleSystem::UpdateAsyncronous( const EveUpdateContext& updateCo { m_lodSphere.x = 0.0f; m_lodSphere.y = 0.0f; - m_lodSphere.z = 0.0f; + m_lodSphere.z = 0.0f; m_lodSphere.w = m_lodSphereRadius; BoundingSphereTransform( m_worldTransform, m_lodSphere ); @@ -239,7 +239,7 @@ void EveChildParticleSystem::UpdateAsyncronous( const EveUpdateContext& updateCo for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - (*it)->UpdateTransform( m_worldTransform ); + ( *it )->UpdateTransform( m_worldTransform ); } if( !m_particleEmitters.empty() ) { @@ -260,15 +260,15 @@ void EveChildParticleSystem::UpdateAsyncronous( const EveUpdateContext& updateCo } } } - ITr2GenericEmitter::UpdateArguments args( - updateContext.GetTime(), - updateContext.GetGpuParticleSystem(), - m_worldTransform, + ITr2GenericEmitter::UpdateArguments args( + updateContext.GetTime(), + updateContext.GetGpuParticleSystem(), + m_worldTransform, updateContext.GetOriginShift(), emitCountFactor ); for( auto it = m_particleEmitters.begin(); it != m_particleEmitters.end(); ++it ) { - (*it)->Update( args ); + ( *it )->Update( args ); } } if( !m_particleSystems.empty() ) @@ -301,26 +301,26 @@ void EveChildParticleSystem::GetLocalToWorldTransform( Matrix& transform ) const // -------------------------------------------------------------------------------- void EveChildParticleSystem::ChangeLOD( Tr2Lod lod ) { - if ( !m_useDynamicLod ) + if( !m_useDynamicLod ) { return; } - for ( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) + for( auto it = m_particleSystems.begin(); it != m_particleSystems.end(); ++it ) { - unsigned original = (*it)->GetOriginalMaxParticles(); + unsigned original = ( *it )->GetOriginalMaxParticles(); unsigned particleCount = original; - if ( lod == TR2_LOD_LOW ) + if( lod == TR2_LOD_LOW ) { - particleCount = min( m_lodClampLow, (unsigned)( original * m_lodFactorLow )); + particleCount = min( m_lodClampLow, (unsigned)( original * m_lodFactorLow ) ); } - else if ( lod == TR2_LOD_MEDIUM ) + else if( lod == TR2_LOD_MEDIUM ) { particleCount = (int)( original * m_lodFactorMedium ); } - - (*it)->SetMaxParticleCount( particleCount ); + + ( *it )->SetMaxParticleCount( particleCount ); } } diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h index 299d6e8af..d3197edac 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem.h @@ -38,36 +38,39 @@ BLUE_CLASS( EveChildParticleSystem ) : EveChildParticleSystem( IRoot* lockobj = NULL ); ~EveChildParticleSystem(); - + ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild const char* GetName() const; void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ); void PlayCurveSet( const std::string& name, const std::string& rangeName ) {}; void StopCurveSet( const std::string& name ) {}; - float GetCurveSetDuration( const std::string& name ) const { return 0; } + float GetCurveSetDuration( const std::string& name ) const + { + return 0; + } virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - void AddTransformModifier( IEveChildTransformModifier* modifier ) override; - + void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable bool HasTransparentBatches(); - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); float GetSortValue(); - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); bool IsVisible( const EveUpdateContext& updateContext ) const override; - + ///////////////////////////////////////////////////////////////////////////////////// // IInitialize virtual bool Initialize(); - + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents(); @@ -75,11 +78,12 @@ BLUE_CLASS( EveChildParticleSystem ) : ///////////////////////////////////////////////////////////////////////////////////// // INotify bool OnModified( Be::Var * value ); - - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; PITr2GenericEmitterVector m_particleEmitters; + private: BlueSharedString m_name; diff --git a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp index a78fac22c..66bdaa945 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildParticleSystem_Blue.cpp @@ -7,15 +7,15 @@ BLUE_DEFINE( EveChildParticleSystem ); const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildParticleSystem, "" ) - MAP_INTERFACE( EveChildParticleSystem ) - MAP_INTERFACE( EveEntity ) + EXPOSURE_BEGIN( EveChildParticleSystem, "" ) + MAP_INTERFACE( EveChildParticleSystem ) + MAP_INTERFACE( EveEntity ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "mesh", m_mesh, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "particleEmitters", m_particleEmitters, "", Be::READ | Be::PERSIST ) @@ -23,60 +23,52 @@ const Be::ClassInfo* EveChildParticleSystem::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, "", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When is this object rendered into the cubemap", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, EntityComponents::ReflectionModeChooser ); - MAP_ATTRIBUTE - ( - "useDynamicLod", - m_useDynamicLod, - "Dynamically change the max particle count \n" - ":jessica-group: LOD", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "lodClampLow", - m_lodClampLow, - "Amount of particles when the LOD is on Low. Set this to 0 for no particles. \n" - ":jessica-group: LOD", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "lodFactorLow", - m_lodFactorLow, - "Max particle multiplier when the LOD is low \n" - ":jessica-group: LOD", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "lodFactorMedium", - m_lodFactorMedium, - "Max particle multiplier when the LOD is medium \n" - ":jessica-group: LOD", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( - "lodSphereRadius", - m_lodSphereRadius, - "Bounding sphere radius for LOD calculations when mesh is not present.\n:jessica-group: LOD", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minScreenSize", - m_minScreenSize, - "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", - Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "useDynamicLod", + m_useDynamicLod, + "Dynamically change the max particle count \n" + ":jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "lodClampLow", + m_lodClampLow, + "Amount of particles when the LOD is on Low. Set this to 0 for no particles. \n" + ":jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "lodFactorLow", + m_lodFactorLow, + "Max particle multiplier when the LOD is low \n" + ":jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "lodFactorMedium", + m_lodFactorMedium, + "Max particle multiplier when the LOD is medium \n" + ":jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "lodSphereRadius", + m_lodSphereRadius, + "Bounding sphere radius for LOD calculations when mesh is not present.\n:jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "minScreenSize", + m_minScreenSize, + "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp index 44aceb7e3..90ab0a190 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.cpp @@ -41,22 +41,22 @@ bool EveChildPlug::Initialize() void EveChildPlug::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ) { - if ( list == &m_controllers && ( event & BELIST_LOADING ) == 0 ) + if( list == &m_controllers && ( event & BELIST_LOADING ) == 0 ) { - switch ( event & BELIST_EVENTMASK ) + switch( event & BELIST_EVENTMASK ) { case BELIST_INSERTED: - if ( ITr2ControllerPtr controller = BlueCastPtr( value ) ) + if( ITr2ControllerPtr controller = BlueCastPtr( value ) ) { controller->Link( *GetRawRoot() ); - for ( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) + for( auto it = begin( m_controllerVariables ); it != end( m_controllerVariables ); ++it ) { controller->SetVariable( it->first.c_str(), it->second ); } } break; case BELIST_REMOVED: - if ( ITr2ControllerPtr controller = BlueCastPtr( value ) ) + if( ITr2ControllerPtr controller = BlueCastPtr( value ) ) { controller->Unlink(); } @@ -169,10 +169,10 @@ void EveChildPlug::UpdateVisibility( const EveUpdateContext& updateContext, cons { return; } - + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->UpdateVisibility( updateContext, parentTransform, parentLod ); + ( *it )->UpdateVisibility( updateContext, parentTransform, parentLod ); } } @@ -185,7 +185,7 @@ void EveChildPlug::GetRenderables( std::vector& renderables ) for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->GetRenderables( renderables ); + ( *it )->GetRenderables( renderables ); } } @@ -195,7 +195,7 @@ bool EveChildPlug::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if( (*it)->GetBoundingSphere( bSphere ) ) + if( ( *it )->GetBoundingSphere( bSphere ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -208,19 +208,19 @@ void EveChildPlug::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->RegisterWithQuadRenderer( quadRenderer ); + ( *it )->RegisterWithQuadRenderer( quadRenderer ); } } void EveChildPlug::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { - if (!m_display ) + if( !m_display ) { return; } for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->AddQuadsToQuadRenderer( frustum, quadRenderer ); + ( *it )->AddQuadsToQuadRenderer( frustum, quadRenderer ); } } @@ -232,7 +232,7 @@ void EveChildPlug::UpdateSyncronous( const EveUpdateContext& updateContext, cons for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->UpdateSyncronous( updateContext, newParams ); + ( *it )->UpdateSyncronous( updateContext, newParams ); } } @@ -246,9 +246,9 @@ void EveChildPlug::UpdateAsyncronous( const EveUpdateContext& updateContext, con for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - (*it)->UpdateAsyncronous( updateContext, newParams ); + ( *it )->UpdateAsyncronous( updateContext, newParams ); } - for ( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { ( *it )->Update( params.controllerUpdateFrequency ); } @@ -261,7 +261,7 @@ void EveChildPlug::GetLocalToWorldTransform( Matrix& transform ) const void EveChildPlug::ChangeLOD( Tr2Lod lod ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { ( *it )->ChangeLOD( lod ); } @@ -269,9 +269,9 @@ void EveChildPlug::ChangeLOD( Tr2Lod lod ) void EveChildPlug::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); ++it ) + for( auto it = m_objects.begin(); it != m_objects.end(); ++it ) { - IEveSpaceObjectChild *child = *it; + IEveSpaceObjectChild* child = *it; child->SetShaderOption( name, value ); } } @@ -300,9 +300,9 @@ void EveChildPlug::StopAllCurveSets() void EveChildPlug::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { owner->PlayCurveSet( name, rangeName ); } @@ -311,9 +311,9 @@ void EveChildPlug::PlayCurveSet( const std::string& name, const std::string& ran void EveChildPlug::StopCurveSet( const std::string& name ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { owner->StopCurveSet( name ); } @@ -322,9 +322,9 @@ void EveChildPlug::StopCurveSet( const std::string& name ) void EveChildPlug::UpdateCurveSet( const std::string& name, Be::Time time ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { owner->UpdateCurveSet( name, time ); } @@ -334,9 +334,9 @@ void EveChildPlug::UpdateCurveSet( const std::string& name, Be::Time time ) float EveChildPlug::GetCurveSetDuration( const std::string& name ) const { float maxDuration = 0.f; - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { maxDuration = max( maxDuration, owner->GetCurveSetDuration( name ) ); } @@ -348,9 +348,9 @@ float EveChildPlug::GetCurveSetDuration( const std::string& name ) const float EveChildPlug::GetRangeDuration( const std::string& name, const std::string& rangeName ) const { float maxDuration = 0.f; - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { maxDuration = max( maxDuration, owner->GetRangeDuration( name, rangeName ) ); } @@ -412,7 +412,7 @@ void EveChildPlug::SetControllerVariable( const char* name, float value ) void EveChildPlug::HandleControllerEvent( const char* name ) { - for ( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { ( *it )->HandleEvent( name ); } @@ -420,7 +420,7 @@ void EveChildPlug::HandleControllerEvent( const char* name ) void EveChildPlug::StartControllers() { - for ( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) + for( auto it = begin( m_controllers ); it != end( m_controllers ); ++it ) { ( *it )->Start(); } @@ -483,7 +483,7 @@ const PTr2ExternalParameterVector& EveChildPlug::GetExternalParameters() const void EveChildPlug::SetInheritProperties( const Color* colorSet ) { - if ( !m_inheritProperties ) + if( !m_inheritProperties ) { m_inheritProperties.CreateInstance(); } @@ -492,12 +492,12 @@ void EveChildPlug::SetInheritProperties( const Color* colorSet ) ITr2AudEmitterPtr EveChildPlug::FindSoundEmitter( const char* name ) { - for ( auto it = m_objects.begin(); it != m_objects.end(); it++ ) + for( auto it = m_objects.begin(); it != m_objects.end(); it++ ) { - if ( auto owner = dynamic_cast( *it ) ) + if( auto owner = dynamic_cast( *it ) ) { auto emitter = owner->FindSoundEmitter( name ); - if ( emitter != nullptr ) + if( emitter != nullptr ) { return emitter; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug.h b/trinity/Eve/SpaceObject/Children/EveChildPlug.h index dccea2e83..efdabcfb8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug.h @@ -24,7 +24,7 @@ BLUE_CLASS( EveChildPlug ) : public ITr2CurveSetOwner, public IInitialize, public INotify, - public IListNotify, + public IListNotify, public IEveEffectChildrenOwner, public ITr2DebugRenderable, public IShaderConfigurer, @@ -52,9 +52,9 @@ BLUE_CLASS( EveChildPlug ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); - + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; @@ -64,14 +64,14 @@ BLUE_CLASS( EveChildPlug ) : void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -92,11 +92,11 @@ BLUE_CLASS( EveChildPlug ) : void StartControllers(); void SetInheritProperties( const Color* colorSet ); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); // external parameters - void AddExternalParameter( Tr2ExternalParameter* externalParameter ); + void AddExternalParameter( Tr2ExternalParameter * externalParameter ); const PTr2ExternalParameterVector& GetExternalParameters() const; ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp index 43ad1e6f3..97d8b9cd5 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPlug_Blue.cpp @@ -31,21 +31,18 @@ const Be::ClassInfo* EveChildPlug::ExposeToBlue() SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) + "Start all controllers" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp index cf4f6b966..d82375bf8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.cpp @@ -8,10 +8,10 @@ #include "Utilities/BoundingSphere.h" -EveChildPostProcessVolume::EveChildPostProcessVolume( IRoot* lockobj ) : +EveChildPostProcessVolume::EveChildPostProcessVolume( IRoot* lockobj ) : PARENTLOCK( m_volumes ), PARENTLOCK( m_exclusionVolumes ), - m_boundingSphere( Vector3( 0.0, 0.0, 0.0), 0.0 ) + m_boundingSphere( Vector3( 0.0, 0.0, 0.0 ), 0.0 ) { m_postProcessAttributes.CreateInstance(); m_postProcessAttributes->intensity = 0.0f; @@ -31,7 +31,7 @@ void EveChildPostProcessVolume::RebuildBoundingSphere() for( auto volume = m_volumes.begin(); volume != m_volumes.end(); ++volume ) { auto volumeSphere = ( *volume )->GetBoundingSphere(); - + // this code is hijacked from carbon-math, it should live there but I don't want to touch carbon-math for now if( !volumeSphere.IsInitialized() ) { @@ -78,12 +78,11 @@ const char* EveChildPostProcessVolume::GetName() const void EveChildPostProcessVolume::SetName( const char* name ) { - m_name = BlueSharedString(name); + m_name = BlueSharedString( name ); } void EveChildPostProcessVolume::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { - } bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const @@ -96,7 +95,6 @@ bool EveChildPostProcessVolume::GetBoundingSphere( Vector4& sphere, BoundingSphe void EveChildPostProcessVolume::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - } void EveChildPostProcessVolume::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -161,7 +159,6 @@ void EveChildPostProcessVolume::UpdateTransformFromParent( const EveChildUpdateP void EveChildPostProcessVolume::GetLocalToWorldTransform( Matrix& transform ) const { - } void EveChildPostProcessVolume::Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) @@ -195,17 +192,17 @@ void EveChildPostProcessVolume::GetDebugOptions( Tr2DebugRendererOptions& option void EveChildPostProcessVolume::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if (renderer.HasOption( this, "Volumes" )) + if( renderer.HasOption( this, "Volumes" ) ) { for( auto volume = m_volumes.begin(); volume != m_volumes.end(); ++volume ) { - (*volume)->RenderDebugInfo( renderer, m_worldTransform, 0xFFFFFFFF ); + ( *volume )->RenderDebugInfo( renderer, m_worldTransform, 0xFFFFFFFF ); } } - if (renderer.HasOption( this, "ExclusionVolumes" )) + if( renderer.HasOption( this, "ExclusionVolumes" ) ) { - for (auto volume = m_exclusionVolumes.begin(); volume != m_exclusionVolumes.end(); ++volume) + for( auto volume = m_exclusionVolumes.begin(); volume != m_exclusionVolumes.end(); ++volume ) { ( *volume )->RenderDebugInfo( renderer, m_worldTransform, 0xFFFF3333 ); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h index e0016643e..10d33b44a 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume.h @@ -38,14 +38,14 @@ BLUE_CLASS( EveChildPostProcessVolume ) : void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ){}; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; bool IsAlwaysOn() const; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {} ; + void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) {}; virtual void RegisterComponents(); virtual void UnRegisterComponents(); @@ -56,8 +56,8 @@ BLUE_CLASS( EveChildPostProcessVolume ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2PostProcessOwner @@ -68,7 +68,7 @@ BLUE_CLASS( EveChildPostProcessVolume ) : BlueSharedString m_name; PIEveVolumeVector m_volumes; - PIEveVolumeVector m_exclusionVolumes; + PIEveVolumeVector m_exclusionVolumes; CcpMath::Sphere m_boundingSphere; diff --git a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp index 6665b03af..32907e00a 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildPostProcessVolume_Blue.cpp @@ -17,7 +17,7 @@ const Be::ClassInfo* EveChildPostProcessVolume::ExposeToBlue() MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boundingSphereCenter", m_boundingSphere.center, "", Be::READ ) MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphere.radius, "", Be::READ ) MAP_ATTRIBUTE( "volumes", m_volumes, "", Be::READ | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp index c19628474..a4a8eea7e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.cpp @@ -11,7 +11,7 @@ #include "TriFrustum.h" -EveChildQuad::EveChildQuad( IRoot* lockobj ): +EveChildQuad::EveChildQuad( IRoot* lockobj ) : m_effectKey( 0 ), m_position( 0.f, 0.f, 0.f ), m_viewRotation( 0.f ), @@ -96,7 +96,7 @@ void EveChildQuad::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRen { if( m_display && m_effect && m_isVisible ) { - quadRenderer.AddQuads( m_effectKey, &m_quad, 1 ); + quadRenderer.AddQuads( m_effectKey, &m_quad, 1 ); } } diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad.h b/trinity/Eve/SpaceObject/Children/EveChildQuad.h index dc7603092..926bf64e1 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad.h +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad.h @@ -30,23 +30,23 @@ BLUE_CLASS( EveChildQuad ) : const char* GetName() const; void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void ChangeLOD( Tr2Lod lod ) {}; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ); - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual bool HasTransparentBatches(); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); - + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); + ///////////////////////////////////////////////////////////////////////////////////// // IInitialize virtual bool Initialize(); diff --git a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp index 4e838c994..1e9f446a0 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildQuad_Blue.cpp @@ -7,12 +7,12 @@ BLUE_DEFINE( EveChildQuad ); const Be::ClassInfo* EveChildQuad::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildQuad, "" ) - MAP_INTERFACE( EveChildQuad ) + EXPOSURE_BEGIN( EveChildQuad, "" ) + MAP_INTERFACE( EveChildQuad ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Show/hide object", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "editMode", m_editMode, "Turn on when tweaking effect", Be::READWRITE ) MAP_ATTRIBUTE( "effect", m_effect, "Effect to be used for rendering a quad", Be::READWRITE | Be::PERSIST ) @@ -21,18 +21,18 @@ const Be::ClassInfo* EveChildQuad::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "viewRotation", m_viewRotation, "Quad rotation", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minScreenSize", - m_minScreenSize, - "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", + MAP_ATTRIBUTE( + "minScreenSize", + m_minScreenSize, + "Minimal size of object on screen, objects smaller than this size are not rendered.\n:jessica-group: LOD", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "Screen size for last frame\n:jessica-group: LOD", Be::READ ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform if useSRT is set." ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp index 85cc00e80..23a00cdd8 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.cpp @@ -10,7 +10,7 @@ EveChildRef::EveChildRef( IRoot* lockobj ) : EveChildTransform(), m_display( true ), - m_loadChildAutomatically( true ) + m_loadChildAutomatically( true ) { } @@ -25,47 +25,47 @@ const char* EveChildRef::GetResPath() const void EveChildRef::SetResPath( const char* resPath ) { - if ( m_resPath != resPath ) + if( m_resPath != resPath ) { m_resPath = resPath; - if( m_loadChildAutomatically ) - { - LoadChild(); - } + if( m_loadChildAutomatically ) + { + LoadChild(); + } } } void EveChildRef::Reload( bool bypassAutoLoadBlocker ) { - if( m_loadChildAutomatically || bypassAutoLoadBlocker ) - { - LoadChild(); - } + if( m_loadChildAutomatically || bypassAutoLoadBlocker ) + { + LoadChild(); + } } void EveChildRef::SetAutoLoadBlocker( bool shouldBlockAutoLoad ) { - m_loadChildAutomatically = !shouldBlockAutoLoad; + m_loadChildAutomatically = !shouldBlockAutoLoad; } bool EveChildRef::Initialize() { - if( m_loadChildAutomatically ) - { - LoadChild(); - } + if( m_loadChildAutomatically ) + { + LoadChild(); + } return true; } bool EveChildRef::OnModified( Be::Var* value ) { - if ( IsMatch( value, m_resPath ) ) + if( IsMatch( value, m_resPath ) ) { - if( m_loadChildAutomatically ) - { - LoadChild(); - } + if( m_loadChildAutomatically ) + { + LoadChild(); + } } if( IsMatch( value, m_display ) ) { @@ -108,7 +108,7 @@ void EveChildRef::UnRegisterComponents() IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) const { - if ( auto ref = dynamic_cast( m_child.p ) ) + if( auto ref = dynamic_cast( m_child.p ) ) { return ref->GetEffectChildByName( name ); } @@ -117,7 +117,7 @@ IEveSpaceObjectChildPtr EveChildRef::GetEffectChildByName( const char* name ) co void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) { - if ( auto ref = dynamic_cast( m_child.p ) ) + if( auto ref = dynamic_cast( m_child.p ) ) { ref->AddToEffectChildrenList( child ); } @@ -125,27 +125,27 @@ void EveChildRef::AddToEffectChildrenList( IEveSpaceObjectChild* child ) void EveChildRef::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) { - if ( auto ref = dynamic_cast( m_child.p ) ) + if( auto ref = dynamic_cast( m_child.p ) ) { ref->RemoveFromEffectChildrenList( child ); } } -void EveChildRef::SetProceduralContainerVariable(const char *name, float value) +void EveChildRef::SetProceduralContainerVariable( const char* name, float value ) { - if ( m_child ) - { - m_child->SetProceduralContainerVariable( name, value ); - } + if( m_child ) + { + m_child->SetProceduralContainerVariable( name, value ); + } } void EveChildRef::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { - if ( !m_display ) + if( !m_display ) { return; } - if ( m_child ) + if( m_child ) { m_child->UpdateVisibility( updateContext, parentTransform, parentLod ); } @@ -153,7 +153,7 @@ void EveChildRef::UpdateVisibility( const EveUpdateContext& updateContext, const void EveChildRef::GetRenderables( std::vector& renderables ) { - if ( m_display && m_child ) + if( m_display && m_child ) { m_child->GetRenderables( renderables ); } @@ -163,7 +163,7 @@ bool EveChildRef::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if ( m_child && m_child->GetBoundingSphere( bSphere ) ) + if( m_child && m_child->GetBoundingSphere( bSphere ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -173,7 +173,7 @@ bool EveChildRef::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query void EveChildRef::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { - if ( m_child ) + if( m_child ) { m_child->RegisterWithQuadRenderer( quadRenderer ); } @@ -181,7 +181,7 @@ void EveChildRef::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) void EveChildRef::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { - if ( m_display && m_child ) + if( m_display && m_child ) { m_child->AddQuadsToQuadRenderer( frustum, quadRenderer ); } @@ -189,7 +189,7 @@ void EveChildRef::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRend void EveChildRef::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - if ( m_child ) + if( m_child ) { EveChildUpdateParams newParams = params; newParams.isVisible &= m_display; @@ -211,7 +211,7 @@ void EveChildRef::UpdateAsyncronous( const EveUpdateContext& updateContext, cons newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - if ( m_child ) + if( m_child ) { m_child->UpdateAsyncronous( updateContext, newParams ); } @@ -224,7 +224,7 @@ void EveChildRef::GetLocalToWorldTransform( Matrix& transform ) const void EveChildRef::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { owner->PlayCurveSet( name, rangeName ); } @@ -232,7 +232,7 @@ void EveChildRef::PlayCurveSet( const std::string& name, const std::string& rang void EveChildRef::StopCurveSet( const std::string& name ) { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { owner->StopCurveSet( name ); } @@ -240,7 +240,7 @@ void EveChildRef::StopCurveSet( const std::string& name ) void EveChildRef::UpdateCurveSet( const std::string& name, Be::Time time ) { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { owner->UpdateCurveSet( name, time ); } @@ -248,7 +248,7 @@ void EveChildRef::UpdateCurveSet( const std::string& name, Be::Time time ) float EveChildRef::GetCurveSetDuration( const std::string& name ) const { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { owner->GetCurveSetDuration( name ); } @@ -257,7 +257,7 @@ float EveChildRef::GetCurveSetDuration( const std::string& name ) const float EveChildRef::GetRangeDuration( const std::string& name, const std::string& rangeName ) const { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { owner->GetRangeDuration( name, rangeName ); } @@ -266,15 +266,15 @@ float EveChildRef::GetRangeDuration( const std::string& name, const std::string& void EveChildRef::PlayAllCurveSets() { - if ( auto owner = dynamic_cast( m_child.p ) ) - { - owner->PlayAllCurveSets(); - } + if( auto owner = dynamic_cast( m_child.p ) ) + { + owner->PlayAllCurveSets(); + } } void EveChildRef::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - if ( m_child ) + if( m_child ) { return m_child->SetShaderOption( name, value ); } @@ -287,7 +287,7 @@ void EveChildRef::Setup( const Vector3* scale, const Quaternion* rotation, const void EveChildRef::ChangeLOD( Tr2Lod lod ) { - if ( m_child ) + if( m_child ) { m_child->ChangeLOD( lod ); } @@ -295,7 +295,7 @@ void EveChildRef::ChangeLOD( Tr2Lod lod ) void EveChildRef::SetControllerVariable( const char* name, float value ) { - if ( m_child ) + if( m_child ) { m_child->SetControllerVariable( name, value ); } @@ -303,7 +303,7 @@ void EveChildRef::SetControllerVariable( const char* name, float value ) void EveChildRef::HandleControllerEvent( const char* name ) { - if ( m_child ) + if( m_child ) { m_child->HandleControllerEvent( name ); } @@ -311,7 +311,7 @@ void EveChildRef::HandleControllerEvent( const char* name ) void EveChildRef::SetInheritProperties( const Color* colorSet ) { - if ( m_child ) + if( m_child ) { if( IEveInheritPropertiesOwnerPtr child = BlueCastPtr( m_child ) ) { @@ -322,7 +322,7 @@ void EveChildRef::SetInheritProperties( const Color* colorSet ) void EveChildRef::StartControllers() { - if ( m_child ) + if( m_child ) { m_child->StartControllers(); } @@ -330,7 +330,7 @@ void EveChildRef::StartControllers() void EveChildRef::GetDebugOptions( Tr2DebugRendererOptions& options ) { - if ( auto renderable = dynamic_cast( m_child.p ) ) + if( auto renderable = dynamic_cast( m_child.p ) ) { renderable->GetDebugOptions( options ); } @@ -338,11 +338,11 @@ void EveChildRef::GetDebugOptions( Tr2DebugRendererOptions& options ) void EveChildRef::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if ( !m_display ) + if( !m_display ) { return; } - if ( auto renderable = dynamic_cast( m_child.p ) ) + if( auto renderable = dynamic_cast( m_child.p ) ) { renderable->RenderDebugInfo( renderer ); } @@ -352,10 +352,10 @@ bool EveChildRef::LoadChild() { // unregister the old child UnRegisterComponents(); - + CCP_LOG( "Loading child red file %s", m_resPath.c_str() ); m_child = BeResMan->LoadObject( m_resPath.c_str() ); - if ( !m_child ) + if( !m_child ) { CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_resPath.c_str() ); return false; @@ -368,7 +368,7 @@ bool EveChildRef::LoadChild() ITr2AudEmitterPtr EveChildRef::FindSoundEmitter( const char* name ) { - if ( auto owner = dynamic_cast( m_child.p ) ) + if( auto owner = dynamic_cast( m_child.p ) ) { return owner->FindSoundEmitter( name ); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef.h b/trinity/Eve/SpaceObject/Children/EveChildRef.h index 25d185aee..1ef6ca39d 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef.h +++ b/trinity/Eve/SpaceObject/Children/EveChildRef.h @@ -36,8 +36,8 @@ BLUE_CLASS( EveChildRef ) : const char* GetResPath() const; void SetResPath( const char* resPath ); - void Reload( bool bypassAutoLoadBlocker = false); - void SetAutoLoadBlocker( bool shouldBlockAutoLoad ); + void Reload( bool bypassAutoLoadBlocker = false ); + void SetAutoLoadBlocker( bool shouldBlockAutoLoad ); ////////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -45,7 +45,7 @@ BLUE_CLASS( EveChildRef ) : ///////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -60,20 +60,20 @@ BLUE_CLASS( EveChildRef ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); - void SetProceduralContainerVariable( const char *name, float value ) override; + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); + void SetProceduralContainerVariable( const char* name, float value ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -84,7 +84,7 @@ BLUE_CLASS( EveChildRef ) : void UpdateCurveSet( const std::string& name, Be::Time time ); float GetCurveSetDuration( const std::string& name ) const; float GetRangeDuration( const std::string& name, const std::string& rangeName ) const; - void PlayAllCurveSets() override; + void PlayAllCurveSets() override; void ChangeLOD( Tr2Lod lod ); void SetControllerVariable( const char* name, float value ); @@ -94,11 +94,11 @@ BLUE_CLASS( EveChildRef ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); - + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); + ///////////////////////////////////////////////////////////////////////////////////// - // ITr2SoundEmitterOwner + // ITr2SoundEmitterOwner ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; protected: @@ -108,7 +108,7 @@ BLUE_CLASS( EveChildRef ) : BlueSharedString m_name; std::string m_resPath; - bool m_loadChildAutomatically; + bool m_loadChildAutomatically; bool m_display; }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp index 0443dd220..ed5256332 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildRef_Blue.cpp @@ -21,7 +21,7 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "resPath", m_resPath, "Path to a red file.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY) + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "child", m_child, "Reference to the loaded child.\n:jessica-hidden: True\n", Be::READ ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) @@ -43,28 +43,24 @@ const Be::ClassInfo* EveChildRef::ExposeToBlue() "Set variable for all applicable controllers\n" ":jessica-hidden: True\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n:jessica-hidden: True\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, "Start all controllers\n" - ":jessica-hidden: True\n" - ) + ":jessica-hidden: True\n" ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "Reload", - Reload, - 1, - "Reload the effect child.\n" - ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "Reload", + Reload, + 1, + "Reload the effect child.\n" ) + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp index 60124a2cf..8c89fb919 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.cpp @@ -12,8 +12,8 @@ #include "SocketParameters/EveSocketParameter.h" -EveChildSocket::EveChildSocket( IRoot* lockobj ) - :PARENTLOCK( m_parameters ), +EveChildSocket::EveChildSocket( IRoot* lockobj ) : + PARENTLOCK( m_parameters ), m_plug(), m_name(), m_plugResPath(), @@ -32,7 +32,7 @@ const char* EveChildSocket::GetPlugResPath() const void EveChildSocket::SetPlugResPath( const char* resPath ) { - if ( m_plugResPath != resPath ) + if( m_plugResPath != resPath ) { m_plugResPath = resPath; LoadChild(); @@ -53,14 +53,14 @@ bool Contains( std::string str, const char* term ) bool EveChildSocket::AddParameterForExternal( Tr2ExternalParameter& externalParam ) { auto destination = externalParam.GetDestinationEntry(); - if ( !destination || !externalParam.IsValid() ) + if( !destination || !externalParam.IsValid() ) { CCP_LOGWARN( "EveChildSocket: destinationObject is not set for one of the plug's external parameters." ); return false; } EveSocketParameterBindingBasePtr ptr; - switch ( destination->mType ) + switch( destination->mType ) { case Be::BYTE: case Be::BOOL: @@ -79,17 +79,17 @@ bool EveChildSocket::AddParameterForExternal( Tr2ExternalParameter& externalPara break; case Be::FLOATARRAY: - if ( destination->GetFloatArraySize() == 2 ) + if( destination->GetFloatArraySize() == 2 ) { ptr.CreateInstance( BlueClassTypeTraits::Class() ); } - else if ( destination->GetFloatArraySize() == 3 ) + else if( destination->GetFloatArraySize() == 3 ) { ptr.CreateInstance( BlueClassTypeTraits::Class() ); } - else if ( destination->GetFloatArraySize() == 4 ) + else if( destination->GetFloatArraySize() == 4 ) { - if ( Contains(destination->mName, "color" ) ) + if( Contains( destination->mName, "color" ) ) { ptr.CreateInstance( BlueClassTypeTraits::Class() ); } @@ -109,7 +109,7 @@ bool EveChildSocket::AddParameterForExternal( Tr2ExternalParameter& externalPara case Be::CHARARRAY: case Be::CSTRING: case Be::WCSTRING: - if ( Contains( destination->mName, "path" ) ) + if( Contains( destination->mName, "path" ) ) { ptr.CreateInstance( BlueClassTypeTraits::Class() ); } @@ -124,7 +124,7 @@ bool EveChildSocket::AddParameterForExternal( Tr2ExternalParameter& externalPara break; } - if ( ptr ) + if( ptr ) { ptr->SetName( externalParam.GetName() ); ptr->BindToExternalParameter( externalParam ); @@ -141,29 +141,29 @@ bool EveChildSocket::AddParameterForExternal( Tr2ExternalParameter& externalPara void EveChildSocket::BindParameters() { - if ( m_plug ) + if( m_plug ) { // clear out old bindings - for ( auto paramIt = begin( m_parameters ); paramIt != end( m_parameters ); ++paramIt ) + for( auto paramIt = begin( m_parameters ); paramIt != end( m_parameters ); ++paramIt ) { ( *paramIt )->ClearBindings(); } // Attach all the new external params const PTr2ExternalParameterVector& externalParams = m_plug->GetExternalParameters(); - for ( auto it = begin( externalParams ); it != end( externalParams ); ++it ) + for( auto it = begin( externalParams ); it != end( externalParams ); ++it ) { bool paramBound = false; - for ( auto paramIt = begin( m_parameters ); paramIt != end( m_parameters ); ++paramIt ) + for( auto paramIt = begin( m_parameters ); paramIt != end( m_parameters ); ++paramIt ) { - if ( ( *paramIt )->BindToExternalParameter( **it ) ) + if( ( *paramIt )->BindToExternalParameter( **it ) ) { paramBound = true; break; } } // No appropriate SocketParameter found, so make a new one if possible. - if ( !paramBound ) + if( !paramBound ) { AddParameterForExternal( **it ); } @@ -173,9 +173,9 @@ void EveChildSocket::BindParameters() void EveChildSocket::Propogate() { - if ( m_plug ) + if( m_plug ) { - for ( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) { ( *it )->Propagate(); } @@ -193,7 +193,7 @@ bool EveChildSocket::Initialize() bool EveChildSocket::OnModified( Be::Var* value ) { - if ( IsMatch( value, m_plugResPath ) ) + if( IsMatch( value, m_plugResPath ) ) { Initialize(); } @@ -248,7 +248,7 @@ void EveChildSocket::SetName( const char* name ) IEveSpaceObjectChildPtr EveChildSocket::GetEffectChildByName( const char* name ) const { - if ( m_plug ) + if( m_plug ) { return m_plug->GetEffectChildByName( name ); } @@ -265,11 +265,11 @@ void EveChildSocket::RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) void EveChildSocket::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) { - if ( !m_display ) + if( !m_display ) { return; } - if ( m_plug ) + if( m_plug ) { m_plug->UpdateVisibility( updateContext, parentTransform, parentLod ); } @@ -277,7 +277,7 @@ void EveChildSocket::UpdateVisibility( const EveUpdateContext& updateContext, co void EveChildSocket::GetRenderables( std::vector& renderables ) { - if ( m_display && m_plug ) + if( m_display && m_plug ) { m_plug->GetRenderables( renderables ); } @@ -287,7 +287,7 @@ bool EveChildSocket::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery que { bool success = false; Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if ( m_plug && m_plug->GetBoundingSphere( bSphere ) ) + if( m_plug && m_plug->GetBoundingSphere( bSphere ) ) { BoundingSphereSetOrUpdate( bSphere, sphere, success ); success = true; @@ -297,7 +297,7 @@ bool EveChildSocket::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery que void EveChildSocket::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { - if ( m_plug ) + if( m_plug ) { m_plug->RegisterWithQuadRenderer( quadRenderer ); } @@ -305,7 +305,7 @@ void EveChildSocket::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) void EveChildSocket::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const { - if ( m_display && m_plug ) + if( m_display && m_plug ) { m_plug->AddQuadsToQuadRenderer( frustum, quadRenderer ); } @@ -313,9 +313,9 @@ void EveChildSocket::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadR void EveChildSocket::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - if ( m_plug ) + if( m_plug ) { - for ( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) { ( *it )->Propagate(); } @@ -340,7 +340,7 @@ void EveChildSocket::UpdateAsyncronous( const EveUpdateContext& updateContext, c newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - if ( m_plug ) + if( m_plug ) { m_plug->UpdateAsyncronous( updateContext, newParams ); } @@ -369,7 +369,7 @@ void EveChildSocket::StopAllCurveSets() void EveChildSocket::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - if ( m_plug ) + if( m_plug ) { m_plug->PlayCurveSet( name, rangeName ); } @@ -377,7 +377,7 @@ void EveChildSocket::PlayCurveSet( const std::string& name, const std::string& r void EveChildSocket::StopCurveSet( const std::string& name ) { - if ( m_plug ) + if( m_plug ) { m_plug->StopCurveSet( name ); } @@ -385,7 +385,7 @@ void EveChildSocket::StopCurveSet( const std::string& name ) void EveChildSocket::UpdateCurveSet( const std::string& name, Be::Time time ) { - if ( m_plug ) + if( m_plug ) { m_plug->UpdateCurveSet( name, time ); } @@ -393,7 +393,7 @@ void EveChildSocket::UpdateCurveSet( const std::string& name, Be::Time time ) float EveChildSocket::GetCurveSetDuration( const std::string& name ) const { - if ( m_plug ) + if( m_plug ) { return m_plug->GetCurveSetDuration( name ); } @@ -402,7 +402,7 @@ float EveChildSocket::GetCurveSetDuration( const std::string& name ) const float EveChildSocket::GetRangeDuration( const std::string& name, const std::string& rangeName ) const { - if ( m_plug ) + if( m_plug ) { return m_plug->GetRangeDuration( name, rangeName ); } @@ -411,7 +411,7 @@ float EveChildSocket::GetRangeDuration( const std::string& name, const std::stri void EveChildSocket::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - if ( m_plug ) + if( m_plug ) { return m_plug->SetShaderOption( name, value ); } @@ -424,7 +424,7 @@ void EveChildSocket::Setup( const Vector3* scale, const Quaternion* rotation, co void EveChildSocket::ChangeLOD( Tr2Lod lod ) { - if ( m_plug ) + if( m_plug ) { m_plug->ChangeLOD( lod ); } @@ -432,7 +432,7 @@ void EveChildSocket::ChangeLOD( Tr2Lod lod ) void EveChildSocket::SetControllerVariable( const char* name, float value ) { - if ( m_plug ) + if( m_plug ) { m_plug->SetControllerVariable( name, value ); } @@ -440,7 +440,7 @@ void EveChildSocket::SetControllerVariable( const char* name, float value ) void EveChildSocket::HandleControllerEvent( const char* name ) { - if ( m_plug ) + if( m_plug ) { m_plug->HandleControllerEvent( name ); } @@ -448,7 +448,7 @@ void EveChildSocket::HandleControllerEvent( const char* name ) void EveChildSocket::SetInheritProperties( const Color* colorSet ) { - if ( m_plug ) + if( m_plug ) { m_plug->SetInheritProperties( colorSet ); } @@ -456,7 +456,7 @@ void EveChildSocket::SetInheritProperties( const Color* colorSet ) void EveChildSocket::StartControllers() { - if ( m_plug ) + if( m_plug ) { m_plug->StartControllers(); } @@ -464,11 +464,11 @@ void EveChildSocket::StartControllers() void EveChildSocket::GetDebugOptions( Tr2DebugRendererOptions& options ) { - if ( !m_plug ) + if( !m_plug ) { return; } - if ( auto renderable = dynamic_cast( &*m_plug ) ) + if( auto renderable = dynamic_cast( &*m_plug ) ) { renderable->GetDebugOptions( options ); } @@ -476,11 +476,11 @@ void EveChildSocket::GetDebugOptions( Tr2DebugRendererOptions& options ) void EveChildSocket::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if ( !m_display || !m_plug ) + if( !m_display || !m_plug ) { return; } - if ( auto renderable = dynamic_cast( &*m_plug ) ) + if( auto renderable = dynamic_cast( &*m_plug ) ) { renderable->RenderDebugInfo( renderer ); } @@ -493,7 +493,7 @@ bool EveChildSocket::LoadChild() CCP_LOG( "Loading child red file %s", m_plugResPath.c_str() ); m_plug = BeResMan->LoadObject( m_plugResPath.c_str() ); - if ( !m_plug ) + if( !m_plug ) { CCP_LOGERR( "Red file %s is invalid or not an Eve Child type.", m_plugResPath.c_str() ); return false; @@ -506,7 +506,7 @@ bool EveChildSocket::LoadChild() ITr2AudEmitterPtr EveChildSocket::FindSoundEmitter( const char* name ) { - if ( m_plug ) + if( m_plug ) { return m_plug->FindSoundEmitter( name ); } diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket.h b/trinity/Eve/SpaceObject/Children/EveChildSocket.h index 553fa48c5..0827ae425 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket.h @@ -40,7 +40,7 @@ BLUE_CLASS( EveChildSocket ) : void SetPlugResPath( const char* resPath ); void Reload(); - bool AddParameterForExternal( Tr2ExternalParameter& externalParam ); + bool AddParameterForExternal( Tr2ExternalParameter & externalParam ); void BindParameters(); void Propogate(); @@ -50,7 +50,7 @@ BLUE_CLASS( EveChildSocket ) : ///////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild @@ -60,8 +60,8 @@ BLUE_CLASS( EveChildSocket ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity @@ -69,14 +69,14 @@ BLUE_CLASS( EveChildSocket ) : void UnRegisterComponents() override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); - void GetRenderables( std::vector& renderables ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void GetRenderables( std::vector & renderables ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ); - void GetLocalToWorldTransform( Matrix& transform ) const; + void GetLocalToWorldTransform( Matrix & transform ) const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; @@ -99,8 +99,8 @@ BLUE_CLASS( EveChildSocket ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; @@ -113,7 +113,7 @@ BLUE_CLASS( EveChildSocket ) : std::string m_plugResPath; bool m_display; - + PIEveSocketParameterVector m_parameters; }; diff --git a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp index 8db7724b7..109731c0e 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSocket_Blue.cpp @@ -21,7 +21,7 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "resPath", m_plugResPath, "Path to the plug (must be a red file with just an EveChildPlug).", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY) + MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "plug", m_plug, "Reference to the loaded plus.\n:jessica-hidden: True\n", Be::READ ) MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) @@ -31,7 +31,7 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "parameters", m_parameters, "List of specialized parameters.", Be::READ | Be::PERSIST | Be::NOTIFY ) MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform.\n:jessica-hidden: True\n" ) @@ -42,37 +42,32 @@ const Be::ClassInfo* EveChildSocket::ExposeToBlue() "Set variable for all applicable controllers\n" ":jessica-hidden: True\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" ":jessica-hidden: True\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, "Start all controllers" - ":jessica-hidden: True\n" - ) + ":jessica-hidden: True\n" ) MAP_METHOD_AND_WRAP( "Reload", Reload, - "Reload the effect child.\n" - ) + "Reload the effect child.\n" ) MAP_METHOD_AND_WRAP( "Rebind", BindParameters, "Rebind parameters." ":jessica-placement:\n" - ":jessica-icon: far-sync\n" - ) + ":jessica-icon: far-sync\n" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.cpp b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.cpp index 72de3f8ea..5cc2d6225 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.cpp @@ -31,23 +31,23 @@ void EveChildSpherePin::UpdateAsyncronous( const EveUpdateContext& updateContext { EveChildMesh::UpdateAsyncronous( updateContext, params ); const auto time = updateContext.GetTime(); - for (auto it = m_curveSets.begin(); it != m_curveSets.end(); ++it) + for( auto it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( time, time ); + ( *it )->Update( time, time ); } } Tr2PerObjectData* EveChildSpherePin::GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) { - + // allocate only once auto perObjectData = accumulator->Allocate(); - - if ( nullptr == perObjectData ) + + if( nullptr == perObjectData ) { return nullptr; } - + // set world matrix perObjectData->m_worldMatrix = Transpose( m_worldTransform ); // set all other pin data @@ -56,7 +56,7 @@ Tr2PerObjectData* EveChildSpherePin::GetPerObjectData( ITriRenderBatchAccumulato perObjectData->m_pinColor = Vector4( m_pinColor.r, m_pinColor.g, m_pinColor.b, m_pinColor.a ); perObjectData->m_pinThreshold = Vector4( m_pinAlphaThreshold, 0.f, 0.f, 0.f ); perObjectData->m_pinRadiusPrecalc = Vector4( sinf( m_pinRadius ), cosf( m_pinRadius ), sinf( m_pinRotation ), cosf( m_pinRotation ) ); - perObjectData->m_pinUV = Vector4(1.f, 1.f, .0f, .0f); + perObjectData->m_pinUV = Vector4( 1.f, 1.f, .0f, .0f ); return perObjectData; } diff --git a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h index e73fe50c3..3b9f501a3 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h +++ b/trinity/Eve/SpaceObject/Children/EveChildSpherePin.h @@ -39,10 +39,9 @@ BLUE_CLASS( EveChildSpherePin ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); private: - Vector3 m_centerNormal; float m_pinMaxRadius; float m_pinRadius; diff --git a/trinity/Eve/SpaceObject/Children/EveChildTransform.cpp b/trinity/Eve/SpaceObject/Children/EveChildTransform.cpp index 3145bd405..02ca2b585 100644 --- a/trinity/Eve/SpaceObject/Children/EveChildTransform.cpp +++ b/trinity/Eve/SpaceObject/Children/EveChildTransform.cpp @@ -56,7 +56,7 @@ void EveChildTransform::SetupWithStaticTransform( const Vector3* scale, const Qu Setup( scale, rotation, translation, lowestLodVisible ); } -void EveChildTransform::UpdateTransform( const Matrix& parentTransform ) +void EveChildTransform::UpdateTransform( const Matrix& parentTransform ) { if( m_staticTransform || !m_useSRT ) { diff --git a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.cpp b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.cpp index 9cf15b21c..bbdc52061 100644 --- a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.cpp +++ b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.cpp @@ -33,8 +33,8 @@ bool EveCloudVolumeBall::OnModified( Be::Var* value ) } -EveCloudEditableVolume::EveCloudEditableVolume( IRoot* lockobj ) - :PARENTLOCK( m_balls ), +EveCloudEditableVolume::EveCloudEditableVolume( IRoot* lockobj ) : + PARENTLOCK( m_balls ), m_width( 64 ), m_height( 64 ), m_depth( 64 ), @@ -141,7 +141,7 @@ void EveCloudEditableVolume::OnListModified( } break; case BELIST_REMOVED: - if(event & BELIST_UNLOADING) + if( event & BELIST_UNLOADING ) { return; } @@ -245,7 +245,7 @@ void EveCloudEditableVolume::RasterizeBalls( RasterizeParams& params ) for( auto it = params.balls[0].begin(); it != params.balls[0].end(); ++it ) { RasterizeBall( *it, params, pixels.get() ); - if( params.status != Working) + if( params.status != Working ) { params.status = Aborted; return; @@ -269,7 +269,7 @@ void EveCloudEditableVolume::RasterizeBallsAnimated( RasterizeParams& params ) for( auto it = params.balls[f].begin(); it != params.balls[f].end(); ++it ) { RasterizeBall( *it, params, pixels.get() ); - if( params.status != Working) + if( params.status != Working ) { params.status = Aborted; return; @@ -317,7 +317,7 @@ void EveCloudEditableVolume::RasterizeBall( const EveCloudVolumeBall::BallData& float dx = x - ball.m_position.x; dx *= dx; - float distance = std::min( 1.f, sqrtf( dx + dy + dz ) / ball.m_radius ); + float distance = std::min( 1.f, sqrtf( dx + dy + dz ) / ball.m_radius ); float alpha = pow( 1.f - distance, ball.m_falloff ); int offset = ( i + j * params.width + k * params.width * params.height ) * 4; @@ -347,10 +347,10 @@ void EveCloudEditableVolume::RenderDebugInfo( const Matrix& world, Tr2RenderCont for( auto it = m_balls.begin(); it != m_balls.end(); ++it ) { Vector3 position = TransformCoord( ( *it )->m_ballData.m_position, world ); - Tr2Renderer::DrawSphere( position, - ( *it )->m_ballData.m_radius * world._11, - 10, - ( uint32_t( ( *it )->m_ballData.m_opacity * 255 ) << 24 ) | ( *it )->m_ballData.m_selfIllumination ); + Tr2Renderer::DrawSphere( position, + ( *it )->m_ballData.m_radius * world._11, + 10, + ( uint32_t( ( *it )->m_ballData.m_opacity * 255 ) << 24 ) | ( *it )->m_ballData.m_selfIllumination ); } } @@ -382,8 +382,8 @@ void EveCloudEditableVolume::RenderDebugInfo( ITr2DebugRenderer2& renderer, cons -EveCloudVolumeTextureParameter::EveCloudVolumeTextureParameter( IRoot* lockobj ) - :m_isUsedByEffect( false ) +EveCloudVolumeTextureParameter::EveCloudVolumeTextureParameter( IRoot* lockobj ) : + m_isUsedByEffect( false ) { } @@ -399,7 +399,7 @@ const char* EveCloudVolumeTextureParameter::GetParameterName() const void EveCloudVolumeTextureParameter::RebuildEffectHandles( Tr2Shader* effectRes ) { m_isUsedByEffect = false; - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { return; } @@ -422,7 +422,7 @@ bool EveCloudVolumeTextureParameter::CopyToResourceSet( bool isSrgb = ( flags & RESOURCE_FLAG_SRGB ) != 0; auto colorSpace = isSrgb ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; if( Tr2TextureAL* tex = ( resource ? resource->GetTexture() : nullptr ) ) - { + { return resourceDesc.SetSrv( stage, registerIndex, *tex, colorSpace ); } diff --git a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.h b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.h index ca8631a36..198b75f1e 100644 --- a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.h +++ b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume.h @@ -19,17 +19,18 @@ class Tr2PerObjectData; // Description: // A ball for EveCloudEditableVolume objects. // -------------------------------------------------------------------------------- -BLUE_CLASS( EveCloudVolumeBall ): public INotify +BLUE_CLASS( EveCloudVolumeBall ) : + public INotify { public: EXPOSE_TO_BLUE(); - EveCloudVolumeBall(IRoot* lockobj = NULL); + EveCloudVolumeBall( IRoot* lockobj = NULL ); ~EveCloudVolumeBall(); ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); struct BallData { @@ -52,7 +53,7 @@ BLUE_DECLARE_VECTOR( EveCloudVolumeBall ); // An "editor" for volume textures used by EveCloud. Maintains a list of balls // (EveCloudVolumeBall) that are rasterized into a volume texture. // -------------------------------------------------------------------------------- -BLUE_CLASS( EveCloudEditableVolume ): +BLUE_CLASS( EveCloudEditableVolume ) : public IInitialize, public INotify, public IListNotify @@ -60,7 +61,7 @@ BLUE_CLASS( EveCloudEditableVolume ): public: EXPOSE_TO_BLUE(); - EveCloudEditableVolume(IRoot* lockobj = NULL); + EveCloudEditableVolume( IRoot* lockobj = NULL ); ~EveCloudEditableVolume(); ////////////////////////////////////////////////////////////////////////// @@ -69,7 +70,7 @@ BLUE_CLASS( EveCloudEditableVolume ): ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////// // IListNotify @@ -80,8 +81,8 @@ BLUE_CLASS( EveCloudEditableVolume ): IRoot* value, const struct IList* theList ); - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform ); void OnVolumeModified(); @@ -89,6 +90,7 @@ BLUE_CLASS( EveCloudEditableVolume ): void RenderDebugInfo( const Matrix& world, Tr2RenderContext& renderContext ); TriTextureRes* GetTexture() const; + private: static const size_t MAX_FRAMES = 4; @@ -110,8 +112,8 @@ BLUE_CLASS( EveCloudEditableVolume ): }; static uint32_t ThreadProc( void* context ); static uint32_t ThreadProcAnimated( void* context ); - static void RasterizeBalls( RasterizeParams& params ); - static void RasterizeBallsAnimated( RasterizeParams& params ); + static void RasterizeBalls( RasterizeParams & params ); + static void RasterizeBallsAnimated( RasterizeParams & params ); static void RasterizeBall( const EveCloudVolumeBall::BallData& ball, const RasterizeParams& params, float* pixels ); Tr2HostBitmapPtr Rasterize(); @@ -136,7 +138,7 @@ TYPEDEF_BLUECLASS( EveCloudEditableVolume ); BLUE_DECLARE_VECTOR( EveCloudEditableVolume ); -BLUE_CLASS( EveCloudVolumeTextureParameter ): +BLUE_CLASS( EveCloudVolumeTextureParameter ) : public ITriEffectResourceParameter { @@ -149,16 +151,17 @@ BLUE_CLASS( EveCloudVolumeTextureParameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); ////////////////////////////////////////////////////////////////////////// // ITriEffectResourceParameter virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const; unsigned GetHashValue( unsigned startingHash ) const; + private: BlueSharedString m_name; EveCloudEditableVolumePtr m_volume; diff --git a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp index 13b1d1569..341307099 100644 --- a/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/EveCloudEditableVolume_Blue.cpp @@ -6,54 +6,52 @@ BLUE_DEFINE( EveCloudVolumeBall ); -const Be::ClassInfo* EveCloudVolumeBall::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveCloudVolumeBall, "Ball for EveCloudEditableVolume" ) - MAP_INTERFACE( EveCloudVolumeBall ) - MAP_INTERFACE( INotify ) - - MAP_ATTRIBUTE( "position", m_ballData.m_position, "Ball position", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "radius", m_ballData.m_radius, "Ball radius", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "selfIllumination", m_ballData.m_selfIllumination, "Self-illumination per unit volume", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "opacity", m_ballData.m_opacity, "Opacity per unit volume", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "falloff", m_ballData.m_falloff, "Opacity/illumination falloff power", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() +const Be::ClassInfo* EveCloudVolumeBall::ExposeToBlue(){ + EXPOSURE_BEGIN( EveCloudVolumeBall, "Ball for EveCloudEditableVolume" ) + MAP_INTERFACE( EveCloudVolumeBall ) + MAP_INTERFACE( INotify ) + + MAP_ATTRIBUTE( "position", m_ballData.m_position, "Ball position", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "radius", m_ballData.m_radius, "Ball radius", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "selfIllumination", m_ballData.m_selfIllumination, "Self-illumination per unit volume", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "opacity", m_ballData.m_opacity, "Opacity per unit volume", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "falloff", m_ballData.m_falloff, "Opacity/illumination falloff power", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + EXPOSURE_END() } BLUE_DEFINE( EveCloudEditableVolume ); -const Be::ClassInfo* EveCloudEditableVolume::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveCloudEditableVolume, "Volume texture editor" ) - MAP_INTERFACE( EveCloudEditableVolume ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) - - MAP_ATTRIBUTE( "texture", m_texture, "Result texture", Be::READ ) - MAP_ATTRIBUTE( "bitmap", m_bitmap, "Result bitmap", Be::READ ) - MAP_ATTRIBUTE( "balls", m_balls, "List of volume balls", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "width", m_width, "Texture width", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "height", m_height, "Texture height", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "depth", m_depth, "Texture depth", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "renderDebugInfo", m_renderDebugInfo, "Toggle rendering of debuggin information", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "animated", m_animated, "If set than balls are sampled at different time intervals and packed into a texture", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets for balls", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "OnVolumeModified", OnVolumeModified, "Trigger re-rasterizing of the volume into the texture" ) - MAP_METHOD_AND_WRAP( "Rasterize", Rasterize, "Rasterizes balls into a texture and returns result as a Tr2HostBitmap" ) - EXPOSURE_END() +const Be::ClassInfo* EveCloudEditableVolume::ExposeToBlue(){ + EXPOSURE_BEGIN( EveCloudEditableVolume, "Volume texture editor" ) + MAP_INTERFACE( EveCloudEditableVolume ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) + + MAP_ATTRIBUTE( "texture", m_texture, "Result texture", Be::READ ) + MAP_ATTRIBUTE( "bitmap", m_bitmap, "Result bitmap", Be::READ ) + MAP_ATTRIBUTE( "balls", m_balls, "List of volume balls", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "width", m_width, "Texture width", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "height", m_height, "Texture height", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "depth", m_depth, "Texture depth", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "renderDebugInfo", m_renderDebugInfo, "Toggle rendering of debuggin information", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "animated", m_animated, "If set than balls are sampled at different time intervals and packed into a texture", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets for balls", Be::READ | Be::PERSIST ) + MAP_METHOD_AND_WRAP( "OnVolumeModified", OnVolumeModified, "Trigger re-rasterizing of the volume into the texture" ) + MAP_METHOD_AND_WRAP( "Rasterize", Rasterize, "Rasterizes balls into a texture and returns result as a Tr2HostBitmap" ) + EXPOSURE_END() } BLUE_DEFINE( EveCloudVolumeTextureParameter ); const Be::ClassInfo* EveCloudVolumeTextureParameter::ExposeToBlue() { - EXPOSURE_BEGIN( EveCloudVolumeTextureParameter, "Cloud volume texture parameter" ) - MAP_INTERFACE( EveCloudVolumeTextureParameter ) + EXPOSURE_BEGIN( EveCloudVolumeTextureParameter, "Cloud volume texture parameter" ) + MAP_INTERFACE( EveCloudVolumeTextureParameter ) MAP_INTERFACE( ITriEffectResourceParameter ) MAP_ATTRIBUTE( "name", m_name, "Parameter name", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "volume", m_volume, "Cloud editor volume", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "isUsedByEffect", m_isUsedByEffect, "Is parameter used by effect", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h index 0e24365cc..b7a510709 100644 --- a/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h +++ b/trinity/Eve/SpaceObject/Children/IEveEffectChildrenOwner.h @@ -6,9 +6,10 @@ BLUE_DECLARE_INTERFACE( IEveSpaceObjectChild ); -BLUE_INTERFACE( IEveEffectChildrenOwner ): public IRoot +BLUE_INTERFACE( IEveEffectChildrenOwner ) : + public IRoot { virtual IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const = 0; - virtual void AddToEffectChildrenList( IEveSpaceObjectChild* child ) = 0; - virtual void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ) = 0; + virtual void AddToEffectChildrenList( IEveSpaceObjectChild * child ) = 0; + virtual void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ) = 0; }; \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h b/trinity/Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h index f1e729d61..0825cccd3 100644 --- a/trinity/Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h +++ b/trinity/Eve/SpaceObject/Children/IEveInheritPropertiesOwner.h @@ -2,7 +2,8 @@ #pragma once -BLUE_INTERFACE( IEveInheritPropertiesOwner ) : public IRoot +BLUE_INTERFACE( IEveInheritPropertiesOwner ) : + public IRoot { virtual void SetInheritProperties( const Color* colorSet ) = 0; }; diff --git a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h index 0a66f9e85..8a8cd6c73 100644 --- a/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h +++ b/trinity/Eve/SpaceObject/Children/IEveSpaceObjectChild.h @@ -16,8 +16,8 @@ BLUE_DECLARE_INTERFACE( IEveChildTransformModifier ); struct EveChildUpdateParams { - EveChildUpdateParams() - :spaceObjectParent( nullptr ), + EveChildUpdateParams() : + spaceObjectParent( nullptr ), childParent( nullptr ), boneCount( 0 ), bones( nullptr ), @@ -42,9 +42,11 @@ struct EveChildUpdateParams Vector3 worldVelocity; }; -BLUE_INTERFACE( IEveSpaceObjectChild ) : public IRoot +BLUE_INTERFACE( IEveSpaceObjectChild ) : + public IRoot { - enum Origin { + enum Origin + { SPACE, SOF, }; @@ -53,17 +55,24 @@ BLUE_INTERFACE( IEveSpaceObjectChild ) : public IRoot virtual void SetName( const char* name ) = 0; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) = 0; - virtual void GetRenderables( std::vector& renderables ) = 0; - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const = 0; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) {} - virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const {} - + virtual void GetRenderables( std::vector & renderables ) = 0; + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const = 0; + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) + { + } + virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const + { + } + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - virtual void GetLocalToWorldTransform( Matrix& transform ) const = 0; - - virtual bool IsAlwaysOn() const { return false; }; + virtual void GetLocalToWorldTransform( Matrix & transform ) const = 0; + + virtual bool IsAlwaysOn() const + { + return false; + }; virtual void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) = 0; @@ -79,7 +88,7 @@ BLUE_INTERFACE( IEveSpaceObjectChild ) : public IRoot virtual void SetOrigin( Origin origin ) {}; - virtual void AddTransformModifier( IEveChildTransformModifier* modifier ) {}; + virtual void AddTransformModifier( IEveChildTransformModifier * modifier ){}; virtual void SetMute( bool isMuted ) {}; }; diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.cpp b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.cpp index abb28b843..a8f7682c7 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.cpp +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.cpp @@ -92,7 +92,7 @@ void EveBezierCurve::GetPointCount( unsigned& count ) void EveBezierCurve::GeneratePoints( const Matrix& parentTransform ) { const int seg = m_scaleSegmentsByCompleteness ? int( ( m_segments + 0.5f ) * ( 1.f - abs( m_completeness - 1.f ) ) ) : int( m_segments + 0.5f ); - + if( seg <= 1 ) { return; @@ -113,7 +113,7 @@ void EveBezierCurve::GeneratePoints( const Matrix& parentTransform ) for( int i = 0; i < seg; i++ ) { - float LoC = ( float( i ) / float( seg ) ) + m_segmentOffset / float( seg ); // LoC = Location on Curve + float LoC = ( float( i ) / float( seg ) ) + m_segmentOffset / float( seg ); // LoC = Location on Curve LoC = ( ( LoC * ( min( m_completeness, 1.f ) - max( 0.f, m_completeness - 1.0f ) ) ) + max( 0.f, m_completeness - 1.0f ) ); float X = ( 1 - LoC ) * ( 1 - LoC ) * m_point1.x + 2 * ( 1 - LoC ) * LoC * m_bezierPoint.x + LoC * LoC * m_point2.x; float Y = ( 1 - LoC ) * ( 1 - LoC ) * m_point1.y + 2 * ( 1 - LoC ) * LoC * m_bezierPoint.y + LoC * LoC * m_point2.y; @@ -135,7 +135,7 @@ void EveBezierCurve::CalculateBoundingSphere( float meshSize, bool reCalculateCh { meshSize = m_meshSize; } - + const Vector3 center = ( m_point1 + m_point2 + m_bezierPoint ) / 3.f; const float rad = max( max( LengthSq( m_bezierPoint - center ), LengthSq( m_point2 - center ) ), LengthSq( m_point1 - center ) ); m_boundingSphere = Vector4( center, sqrt( rad ) + meshSize ); @@ -157,7 +157,7 @@ void EveBezierCurve::UpdateVisibility( const TriFrustum& frustum, Tr2Lod parentL m_isVisible = false; Vector4 sphere = m_boundingSphere; - + BoundingSphereTransform( m_localTransform * systemLocation, sphere ); m_isVisible = frustum.IsSphereVisible( &( sphere ) ); @@ -169,7 +169,7 @@ void EveBezierCurve::AddLinesToSet( EveCurveLineSet& lineSet, const Vector4& col { return; } - + if( m_regeneratePoints ) { GeneratePoints(); @@ -177,8 +177,8 @@ void EveBezierCurve::AddLinesToSet( EveCurveLineSet& lineSet, const Vector4& col } int seg = m_scaleSegmentsByCompleteness ? int( ( m_segments + 0.5f ) * ( 1.f - abs( m_completeness - 1.f ) ) ) : int( m_segments + 0.5f ); - seg = min( seg, (int) m_points.size() ); - + seg = min( seg, (int)m_points.size() ); + for( int i = 0; i < seg; i++ ) { int nextPoint = ( i + 1 ) % seg; @@ -193,7 +193,7 @@ void EveBezierCurve::AddLinesToSet( EveCurveLineSet& lineSet, const Vector4& col { continue; } - + id = lineSet.AddStraightLine( TransformCoord( m_points[i], m_localTransform ), color, TransformCoord( m_point2, m_localTransform ), color, m_lineWidth ); } @@ -216,10 +216,10 @@ void EveBezierCurve::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& da } return; } - + Vector3 scale, translation; Quaternion objRot, worldRot; - + Vector3 targetPoint = m_point2; Vector3 dirToNextPoint( 0.f, 1.f, 0.f ); unsigned count = 0; @@ -237,17 +237,17 @@ void EveBezierCurve::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& da const unsigned nextPoint = ( count + 1 >= unsigned( m_points.size() ) ) ? 0 : count + 1; - + if( nextPoint == 0 ) { if( m_completeness < 1.f ) { - Matrix m = ScalingMatrix( Vector3(0.f,0.f,0.f) ); + Matrix m = ScalingMatrix( Vector3( 0.f, 0.f, 0.f ) ); memcpy( data, &m, stride ); data += stride; continue; } - + translation = Lerp( *point, TransformCoord( m_point2, m_worldTransform ), m_animValue ); dirToNextPoint = TransformCoord( m_point2, m_worldTransform ) - translation; } @@ -277,11 +277,11 @@ void EveBezierCurve::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& da const Vector3 angleToCamera = Tr2Renderer::GetViewPosition() - TransformCoord( translation, m_localTransform * systemLocation ); dirToNextPoint = TransformCoord( angleToCamera, Inverse( rotMat ) ); } - + TriQuaternionArcFromForward( &objRot, &dirToNextPoint ); - + Matrix matrix = TransformationMatrix( sizeMod * m_objectScale, objRot, translation ) * m_localTransform; - + Matrix m = Transpose( matrix ); memcpy( data, &m, stride ); data += stride; diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.h b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.h index d84b8b638..966f72066 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.h +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve.h @@ -17,22 +17,22 @@ BLUE_CLASS( EveBezierCurve ) : ~EveBezierCurve(); bool Update( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t * &data, const Matrix& systemLocation, const unsigned stride ) override; + void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t*& data, const Matrix& systemLocation, const unsigned stride ) override; void GeneratePoints( const Matrix& parentTransform = IdentityMatrix() ) override; void GetPointCount( unsigned& count ) override; void AddLinesToSet( EveCurveLineSet & lineSet, const Vector4& color, const Vector4& animColor, float scrollSpeed ) override; - + void CalculateBoundingSphere( float meshSize = 0.0, bool reCalculateChildren = true ) override; void GetBoundingSphere( Vector4 & sphere ) override; void UpdateVisibility( const TriFrustum& frustum, Tr2Lod parentLod, const Matrix& systemLocation ) override; // IInitialize bool Initialize() override; - + // INotify bool OnModified( Be::Var * value ) override; - + // Debug renderable virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& systemLocation ); @@ -42,12 +42,12 @@ BLUE_CLASS( EveBezierCurve ) : std::vector m_points; Vector4 m_boundingSphere; Matrix m_parentTransform; - + Vector3 m_point1; Vector3 m_point2; Vector3 m_bezierPoint; Vector3 m_objectScale; - + float m_completeness; float m_segments; float m_lineWidth; diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve_Blue.cpp b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve_Blue.cpp index 9bb327d16..a4a41047e 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveBezierCurve_Blue.cpp @@ -20,22 +20,48 @@ const Be::ClassInfo* EveBezierCurve::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READ ) - - MAP_ATTRIBUTE( "point1", m_point1, "endpoint for the curve (multiplied by scale)\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "point2", m_point2, "endpoint for the curve (multiplied by scale)\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "bezierPoint", m_bezierPoint, "use this to bend the curve\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "completeness", m_completeness, "can be animated to have the line only partialy complete it's path\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "segments", m_segments, "nuber of segments that the curve is split up into\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "segmentOffset", m_segmentOffset, "offset to precicely position points\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - - MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "embolden the lines as you wish \n"":jessica-group: lineRender-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - - MAP_ATTRIBUTE( "scaleSegmentsByCompleteness", m_scaleSegmentsByCompleteness, "reduce number of segments when completeness != 1\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "scaleEndpoints", m_scaleEndpoints, "reduce mesh size of objects at the ends\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "billboardObjects", m_billboardObjects, "should meshes face the camera \n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "objectScale", m_objectScale, "enlarge/reduce object mesh size\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "movementSpeed", m_movementSpeed, "how fast objects move\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "animValue", m_animValue, "debug location in relation to the 'movementSpeed' var\n"":jessica-group: Mesh-Options", Be::READ ) - + + MAP_ATTRIBUTE( "point1", m_point1, "endpoint for the curve (multiplied by scale)\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "point2", m_point2, "endpoint for the curve (multiplied by scale)\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "bezierPoint", m_bezierPoint, "use this to bend the curve\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "completeness", m_completeness, "can be animated to have the line only partialy complete it's path\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "segments", m_segments, "nuber of segments that the curve is split up into\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "segmentOffset", m_segmentOffset, "offset to precicely position points\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "embolden the lines as you wish \n" + ":jessica-group: lineRender-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "scaleSegmentsByCompleteness", m_scaleSegmentsByCompleteness, "reduce number of segments when completeness != 1\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "scaleEndpoints", m_scaleEndpoints, "reduce mesh size of objects at the ends\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "billboardObjects", m_billboardObjects, "should meshes face the camera \n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "objectScale", m_objectScale, "enlarge/reduce object mesh size\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "movementSpeed", m_movementSpeed, "how fast objects move\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "animValue", m_animValue, "debug location in relation to the 'movementSpeed' var\n" + ":jessica-group: Mesh-Options", + Be::READ ) + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.cpp b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.cpp index d386655a0..6ffc361ff 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.cpp +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.cpp @@ -22,7 +22,7 @@ EveCircle::EveCircle( IRoot* lockobj ) : m_meshSize( 0.f ), m_scaleSegmentsByCompleteness( false ), m_regeneratePoints( true ), - m_billboardObjects( false), + m_billboardObjects( false ), m_scaleEndpoints( true ), m_isVisible( true ), m_display( true ) @@ -54,7 +54,7 @@ bool EveCircle::OnModified( Be::Var* value ) if( IsMatch( value, m_startPoint ) ) { - m_startPoint = fmod(m_startPoint, 1.f); + m_startPoint = fmod( m_startPoint, 1.f ); } @@ -90,7 +90,7 @@ void EveCircle::GetPointCount( unsigned& count ) void EveCircle::GeneratePoints( const Matrix& parentTransform ) { const int seg = m_scaleSegmentsByCompleteness ? int( ( m_segments + 0.5f ) * ( 1.f - abs( m_completeness - 1.f ) ) ) : int( m_segments + 0.5f ); - + if( seg <= 1 ) { return; @@ -106,7 +106,7 @@ void EveCircle::GeneratePoints( const Matrix& parentTransform ) UpdateTransform( m_parentTransform ); } - + const float totalArc = ( 1.f - abs( m_completeness - 1.f ) ) * XM_2PI; const float startOffset = m_startPoint * XM_2PI + max( m_completeness - 1.f, 0.f ) * XM_2PI + totalArc / ( 2 * seg ); @@ -128,7 +128,7 @@ void EveCircle::GeneratePoints( const Matrix& parentTransform ) float Z = sin( locOnCircle ) * m_circleRadius; m_points.emplace_back( Vector3( X, Y, Z ) ); } - + m_regeneratePoints = false; } @@ -142,8 +142,8 @@ void EveCircle::CalculateBoundingSphere( float meshSize, bool reCalculateChildre { meshSize = m_meshSize; } - - m_boundingSphere = Vector4( Vector3(0.f, 0.f,0.f ), m_circleRadius + m_lineWidth + meshSize ); + + m_boundingSphere = Vector4( Vector3( 0.f, 0.f, 0.f ), m_circleRadius + m_lineWidth + meshSize ); } void EveCircle::GetBoundingSphere( Vector4& sphere ) @@ -185,18 +185,18 @@ void EveCircle::AddLinesToSet( EveCurveLineSet& lineSet, const Vector4& color, c int seg = m_scaleSegmentsByCompleteness ? int( ( m_segments + 0.5f ) * ( 1.f - abs( m_completeness - 1.f ) ) ) : int( m_segments + 0.5f ); seg = min( seg, (int)m_points.size() ); - + for( int i = 0; i < seg; i++ ) { int nextPoint = ( i + 1 ) % seg; unsigned id; - if(m_completeness != 1.f && nextPoint == 0) + if( m_completeness != 1.f && nextPoint == 0 ) { continue; } - - + + id = lineSet.AddStraightLine( TransformCoord( m_points[i], m_localTransform ), color, TransformCoord( m_points[nextPoint], m_localTransform ), color, m_lineWidth ); if( scrollSpeed != 0 ) @@ -218,7 +218,7 @@ void EveCircle::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& data, c } return; } - + Vector3 scale, translation; Quaternion objRot, worldRot; @@ -226,7 +226,7 @@ void EveCircle::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& data, c for( auto point = m_points.begin(); point != m_points.end(); ++point ) { float sizeMod = 1.f; - + if( m_scaleEndpoints && m_completeness != 1.f ) { sizeMod = ( count + 2 >= unsigned( m_points.size() ) ) ? 1.0f - m_animValue : sizeMod; @@ -237,16 +237,16 @@ void EveCircle::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& data, c Vector3 dirToNextPoint( 0.f, 1.f, 0.f ); const unsigned nextPoint = ( count + 1 >= unsigned( m_points.size() ) ) ? 0 : count + 1; translation = Lerp( m_points[count], m_points[nextPoint], m_animValue ); - + if( m_billboardObjects ) { Vector3 tmpScale, tmpTranslation; Quaternion tmpRotation; - Decompose( tmpScale, tmpRotation, tmpTranslation, m_localTransform*systemLocation ); + Decompose( tmpScale, tmpRotation, tmpTranslation, m_localTransform * systemLocation ); Matrix rotMat = RotationMatrix( tmpRotation ); const Vector3 angleToCamera = Tr2Renderer::GetViewPosition() - TransformCoord( translation, m_localTransform * systemLocation ); - dirToNextPoint = TransformCoord( angleToCamera, Inverse(rotMat) ); + dirToNextPoint = TransformCoord( angleToCamera, Inverse( rotMat ) ); } else { @@ -255,7 +255,7 @@ void EveCircle::UpdateBuffer( Tr2RenderContext& renderContext, uint8_t*& data, c } TriQuaternionArcFromForward( &objRot, &dirToNextPoint ); - + Matrix matrix = TransformationMatrix( sizeMod * m_objectScale, objRot, translation ) * m_localTransform; Matrix m = Transpose( matrix ); diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.h b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.h index a2f534ac4..1720de83d 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.h +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle.h @@ -15,10 +15,10 @@ BLUE_CLASS( EveCircle ) : EXPOSE_TO_BLUE(); EveCircle( IRoot* lockobj = nullptr ); ~EveCircle(); - + bool Update( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t * &data, const Matrix& systemLocation, const unsigned stride ) override; - + void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t*& data, const Matrix& systemLocation, const unsigned stride ) override; + void GeneratePoints( const Matrix& parentTransform = IdentityMatrix() ) override; void GetPointCount( unsigned& count ) override; void AddLinesToSet( EveCurveLineSet & lineSet, const Vector4& color, const Vector4& animColor, float scrollSpeed ) override; @@ -32,7 +32,7 @@ BLUE_CLASS( EveCircle ) : // INotify bool OnModified( Be::Var * value ) override; - + // Debug renderable void GetDebugOptions( Tr2DebugRendererOptions & options ) override; void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentWorldLocation ) override; @@ -42,11 +42,11 @@ BLUE_CLASS( EveCircle ) : BlueSharedString m_name; std::vector m_points; Matrix m_parentTransform; - + Vector4 m_boundingSphere; Vector4 m_circleDistort; Vector3 m_objectScale; - + float m_circleRadius; float m_completeness; float m_segments; @@ -55,7 +55,7 @@ BLUE_CLASS( EveCircle ) : float m_animValue; float m_startPoint; float m_meshSize; - + bool m_isVisible; bool m_display; bool m_scaleEndpoints; diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle_Blue.cpp b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle_Blue.cpp index 922432e90..2502305aa 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveCircle_Blue.cpp @@ -18,21 +18,43 @@ const Be::ClassInfo* EveCircle::ExposeToBlue() MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READ ) - - MAP_ATTRIBUTE( "circleRadius", m_circleRadius, "the circle's radius\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "circleDistort", m_circleDistort, "use this to bend/transform/animate the circle on the y axis\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "numSegments", m_segments, "nuber of segments that the circle is split up into\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "completeness", m_completeness, "attribute to move the ends conecting to either side making an arc [0-2]\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "startPoint", m_startPoint, "used with completeness to control where the gap is [0-1]\n"":jessica-group: Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - - MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "embolden the lines as you wish \n"":jessica-group: lineRender-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - - MAP_ATTRIBUTE( "scaleSegmentsByCompleteness", m_scaleSegmentsByCompleteness, "reduce number of segments when completeness != 1\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "scaleEndpoints", m_scaleEndpoints, "reduce mesh size of objects at the ends\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "circleRadius", m_circleRadius, "the circle's radius\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "circleDistort", m_circleDistort, "use this to bend/transform/animate the circle on the y axis\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "numSegments", m_segments, "nuber of segments that the circle is split up into\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "completeness", m_completeness, "attribute to move the ends conecting to either side making an arc [0-2]\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "startPoint", m_startPoint, "used with completeness to control where the gap is [0-1]\n" + ":jessica-group: Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "embolden the lines as you wish \n" + ":jessica-group: lineRender-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "scaleSegmentsByCompleteness", m_scaleSegmentsByCompleteness, "reduce number of segments when completeness != 1\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "scaleEndpoints", m_scaleEndpoints, "reduce mesh size of objects at the ends\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "billboardObjects", m_billboardObjects, ":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "objectScale", m_objectScale, "enlarge/reduce object mesh size\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "movementSpeed", m_movementSpeed, "how fast objects move\n"":jessica-group: Mesh-Options", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "animValue", m_animValue, "debug location in relation to the 'movementSpeed' var\n"":jessica-group: Mesh-Options", Be::READ ) - + MAP_ATTRIBUTE( "objectScale", m_objectScale, "enlarge/reduce object mesh size\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "movementSpeed", m_movementSpeed, "how fast objects move\n" + ":jessica-group: Mesh-Options", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "animValue", m_animValue, "debug location in relation to the 'movementSpeed' var\n" + ":jessica-group: Mesh-Options", + Be::READ ) + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer.h b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer.h index ad6c64a76..6f2afcef2 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer.h +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer.h @@ -18,9 +18,9 @@ BLUE_CLASS( EveLineChildContainer ) : EXPOSE_TO_BLUE(); EveLineChildContainer( IRoot* lockobj = nullptr ); ~EveLineChildContainer(); - + bool Update( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t * &data, const Matrix& systemLocation, const unsigned stride ) override; + void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t*& data, const Matrix& systemLocation, const unsigned stride ) override; void GeneratePoints( const Matrix& parentTransform = IdentityMatrix() ) override; void GetPointCount( unsigned& count ) override; @@ -35,7 +35,7 @@ BLUE_CLASS( EveLineChildContainer ) : // IListNotify void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; - + // Debug renderable void GetDebugOptions( Tr2DebugRendererOptions & options ) override; void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentWorldLocation ) override; diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer_Blue.cpp index d989e82a3..e9046becc 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/EveLineChildContainer_Blue.cpp @@ -20,6 +20,6 @@ const Be::ClassInfo* EveLineChildContainer::ExposeToBlue() MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/LineSetPaths/IEveLineSetPath.h b/trinity/Eve/SpaceObject/Children/LineSetPaths/IEveLineSetPath.h index 910b93ec4..1b6733a81 100644 --- a/trinity/Eve/SpaceObject/Children/LineSetPaths/IEveLineSetPath.h +++ b/trinity/Eve/SpaceObject/Children/LineSetPaths/IEveLineSetPath.h @@ -10,16 +10,16 @@ BLUE_INTERFACE( IEveLineSetPath ) : virtual void UpdateBuffer( Tr2RenderContext & renderContext, uint8_t*& data, const Matrix& systemLocation, const unsigned stride ) = 0; virtual void GeneratePoints( const Matrix& parentTransform = IdentityMatrix() ) = 0; - virtual void GetPointCount( unsigned& count) = 0; + virtual void GetPointCount( unsigned& count ) = 0; virtual void AddLinesToSet( EveCurveLineSet & lineSet, const Vector4& color, const Vector4& animColor, float scrollSpeed ) = 0; virtual void CalculateBoundingSphere( float meshSize = 0.0, bool reCalculateChildren = true ) = 0; - virtual void GetBoundingSphere( Vector4& sphere ) = 0; + virtual void GetBoundingSphere( Vector4 & sphere ) = 0; virtual void UpdateVisibility( const TriFrustum& frustum, Tr2Lod parentLod, const Matrix& systemLocation ) = 0; // Debug render - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ) = 0; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& systemLocation ) = 0; + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) = 0; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& systemLocation ) = 0; }; BLUE_DECLARE_INTERFACE( IEveLineSetPath ); @@ -51,7 +51,7 @@ inline void CalculateBoundingSphereForLineSetPaths( Vector4& boundingSphere, PIE for( auto it = begin( lines ); it != end( lines ); ++it ) { - (*it)->GetBoundingSphere( sphere ); + ( *it )->GetBoundingSphere( sphere ); sum += sphere.GetXYZ(); biggestRad = max( biggestRad, sphere.w ); } @@ -60,7 +60,7 @@ inline void CalculateBoundingSphereForLineSetPaths( Vector4& boundingSphere, PIE for( auto it = begin( lines ); it != end( lines ); ++it ) { - (*it)->GetBoundingSphere( sphere ); + ( *it )->GetBoundingSphere( sphere ); distSq = max( distSq, LengthSq( sphere.GetXYZ() - sum ) ); } diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp index 373fcd9f2..d47fb4bb0 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.cpp @@ -6,9 +6,9 @@ EveChildProceduralContainer::EveChildProceduralContainer( IRoot* lockobj ) : EveChildTransform(), - PARENTLOCK( m_transformModifiers ), - m_proceduralContainerVariables( "EveChildContainer::m_proceduralContainerVariables" ), - m_display( true ) + PARENTLOCK( m_transformModifiers ), + m_proceduralContainerVariables( "EveChildContainer::m_proceduralContainerVariables" ), + m_display( true ) { } @@ -18,12 +18,12 @@ EveChildProceduralContainer::~EveChildProceduralContainer() const char* EveChildProceduralContainer::GetName() const { - return m_name.c_str(); + return m_name.c_str(); } void EveChildProceduralContainer::SetName( const char* name ) { - m_name = BlueSharedString( name ); + m_name = BlueSharedString( name ); } bool EveChildProceduralContainer::Initialize() @@ -42,38 +42,38 @@ void EveChildProceduralContainer::UpdateVisibility( const EveUpdateContext& upda return; } - if ( nullptr != m_selectedObject ) - { - m_selectedObject->UpdateVisibility( updateContext, parentTransform, parentLod ); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->UpdateVisibility( updateContext, parentTransform, parentLod ); + } } void EveChildProceduralContainer::GetRenderables( std::vector& renderables ) { - if ( m_display && m_selectedObject ) - { - m_selectedObject->GetRenderables( renderables ); - } + if( m_display && m_selectedObject ) + { + m_selectedObject->GetRenderables( renderables ); + } } bool EveChildProceduralContainer::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { - bool success = false; - Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); - if ( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere ) ) - { - BoundingSphereSetOrUpdate( bSphere, sphere, success ); - success = true; - } - return success; + bool success = false; + Vector4 bSphere( 0.f, 0.f, 0.f, -1.f ); + if( m_selectedObject && m_selectedObject->GetBoundingSphere( bSphere ) ) + { + BoundingSphereSetOrUpdate( bSphere, sphere, success ); + success = true; + } + return success; } void EveChildProceduralContainer::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->RegisterWithQuadRenderer( quadRenderer ); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->RegisterWithQuadRenderer( quadRenderer ); + } } void EveChildProceduralContainer::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const @@ -82,10 +82,10 @@ void EveChildProceduralContainer::AddQuadsToQuadRenderer( const TriFrustum& frus { return; } - if ( nullptr != m_selectedObject ) - { - m_selectedObject->AddQuadsToQuadRenderer(frustum, quadRenderer); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->AddQuadsToQuadRenderer( frustum, quadRenderer ); + } } void EveChildProceduralContainer::UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) @@ -95,10 +95,10 @@ void EveChildProceduralContainer::UpdateSyncronous( const EveUpdateContext& upda newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - if ( nullptr != m_selectedObject ) - { - m_selectedObject->UpdateSyncronous(updateContext, newParams); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->UpdateSyncronous( updateContext, newParams ); + } if( nullptr != m_selectionMethod && m_selectionMethod->IsSelectedChildModified() ) { @@ -122,58 +122,58 @@ void EveChildProceduralContainer::UpdateAsyncronous( const EveUpdateContext& upd newParams.childParent = this; newParams.localToWorldTransform = m_worldTransform; - if ( nullptr != m_selectedObject ) - { - m_selectedObject->UpdateAsyncronous(updateContext, newParams); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->UpdateAsyncronous( updateContext, newParams ); + } - if ( nullptr != m_selectionMethod ) - { - m_selectionMethod->UpdateAsyncronous(updateContext, newParams); - } + if( nullptr != m_selectionMethod ) + { + m_selectionMethod->UpdateAsyncronous( updateContext, newParams ); + } } void EveChildProceduralContainer::ConfigureSelectedObject() { - EveChildRefPtr child = m_selectionMethod->GetSelectedChild(); - if( child != nullptr ) - { - for( auto it = begin( m_proceduralContainerVariables ); it != end( m_proceduralContainerVariables ); ++it ) - { - child->SetProceduralContainerVariable( it->first.c_str(), it->second ); - } - } + EveChildRefPtr child = m_selectionMethod->GetSelectedChild(); + if( child != nullptr ) + { + for( auto it = begin( m_proceduralContainerVariables ); it != end( m_proceduralContainerVariables ); ++it ) + { + child->SetProceduralContainerVariable( it->first.c_str(), it->second ); + } + } auto registry = GetComponentRegistry(); if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { entity->UnRegister( registry ); } - m_selectedObject = child; + m_selectedObject = child; if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { entity->Register( registry ); } } -void EveChildProceduralContainer::SetProceduralContainerVariable(const char *name, float value) +void EveChildProceduralContainer::SetProceduralContainerVariable( const char* name, float value ) { - m_proceduralContainerVariables[name] = value; - if( m_selectionMethod ) - { - m_selectionMethod->SetProceduralMethodVariable( name, value ); - } + m_proceduralContainerVariables[name] = value; + if( m_selectionMethod ) + { + m_selectionMethod->SetProceduralMethodVariable( name, value ); + } } const char* EveChildProceduralContainer::GetMethodVariableName() { - const char* name = "methodUnassigned"; + const char* name = "methodUnassigned"; - if( m_selectionMethod ) - { - name = m_selectionMethod->GetProceduralMethodVariable(); - } + if( m_selectionMethod ) + { + name = m_selectionMethod->GetProceduralMethodVariable(); + } - return name; + return name; } // --- other interface functions --- @@ -185,60 +185,60 @@ void EveChildProceduralContainer::GetLocalToWorldTransform( Matrix& transform ) void EveChildProceduralContainer::ChangeLOD( Tr2Lod lod ) { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->ChangeLOD( lod ); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->ChangeLOD( lod ); + } } void EveChildProceduralContainer::PlayCurveSet( const std::string& name, const std::string& rangeName ) { - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - owner->PlayCurveSet( name, rangeName ); - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + owner->PlayCurveSet( name, rangeName ); + } } void EveChildProceduralContainer::PlayAllCurveSets() { - if( auto child = dynamic_cast( &(*m_selectedObject) ) ) - { - child->PlayAllCurveSets(); - } + if( auto child = dynamic_cast( &( *m_selectedObject ) ) ) + { + child->PlayAllCurveSets(); + } } void EveChildProceduralContainer::StopAllCurveSets() { - if( auto child = dynamic_cast( &(*m_selectedObject) ) ) - { - child->StopAllCurveSets(); - } + if( auto child = dynamic_cast( &( *m_selectedObject ) ) ) + { + child->StopAllCurveSets(); + } } void EveChildProceduralContainer::StopCurveSet( const std::string& name ) { - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - owner->StopCurveSet( name ); - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + owner->StopCurveSet( name ); + } } void EveChildProceduralContainer::UpdateCurveSet( const std::string& name, Be::Time time ) { - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - owner->UpdateCurveSet( name, time ); - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + owner->UpdateCurveSet( name, time ); + } } float EveChildProceduralContainer::GetCurveSetDuration( const std::string& name ) const { float maxDuration = 0.f; - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - maxDuration = max( maxDuration, owner->GetCurveSetDuration( name ) ); - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + maxDuration = max( maxDuration, owner->GetCurveSetDuration( name ) ); + } return maxDuration; } @@ -247,10 +247,10 @@ float EveChildProceduralContainer::GetRangeDuration( const std::string& name, co { float maxDuration = 0.f; - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - maxDuration = max( maxDuration, owner->GetRangeDuration( name, rangeName ) ); - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + maxDuration = max( maxDuration, owner->GetRangeDuration( name, rangeName ) ); + } return maxDuration; } @@ -262,38 +262,38 @@ void EveChildProceduralContainer::Setup( const Vector3* scale, const Quaternion* void EveChildProceduralContainer::SetControllerVariable( const char* name, float value ) { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->SetControllerVariable( name, value ); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->SetControllerVariable( name, value ); + } } void EveChildProceduralContainer::HandleControllerEvent( const char* name ) { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->HandleControllerEvent(name); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->HandleControllerEvent( name ); + } } void EveChildProceduralContainer::StartControllers() { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->StartControllers(); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->StartControllers(); + } } ITr2AudEmitterPtr EveChildProceduralContainer::FindSoundEmitter( const char* name ) { - if( auto owner = dynamic_cast( &(*m_selectedObject) ) ) - { - auto emitter = owner->FindSoundEmitter( name ); - if( emitter != nullptr ) - { - return emitter; - } - } + if( auto owner = dynamic_cast( &( *m_selectedObject ) ) ) + { + auto emitter = owner->FindSoundEmitter( name ); + if( emitter != nullptr ) + { + return emitter; + } + } return nullptr; } @@ -304,10 +304,10 @@ void EveChildProceduralContainer::AddTransformModifier( IEveChildTransformModifi void EveChildProceduralContainer::SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) { - if ( nullptr != m_selectedObject ) - { - m_selectedObject->SetShaderOption(name, value); - } + if( nullptr != m_selectedObject ) + { + m_selectedObject->SetShaderOption( name, value ); + } } bool EveChildProceduralContainer::OnModified( Be::Var* val ) @@ -323,7 +323,7 @@ void EveChildProceduralContainer::RegisterComponents() { auto registry = this->GetComponentRegistry(); - if( registry && m_display ) + if( registry && m_display ) { if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { @@ -334,58 +334,58 @@ void EveChildProceduralContainer::RegisterComponents() void EveChildProceduralContainer::UnRegisterComponents() { auto registry = this->GetComponentRegistry(); - if ( registry ) + if( registry ) { if( EveEntityPtr entity = BlueCastPtr( m_selectedObject ) ) { entity->UnRegister( GetComponentRegistry() ); } - } + } } void EveChildProceduralContainer::SetInheritProperties( const Color* colorSet ) { - if ( nullptr != m_selectedObject ) - { + if( nullptr != m_selectedObject ) + { if( IEveInheritPropertiesOwnerPtr child = BlueCastPtr( m_selectedObject ) ) { child->SetInheritProperties( colorSet ); } - } + } //TODO instead set properties on the m_selectionMethod } void EveChildProceduralContainer::GetDebugOptions( Tr2DebugRendererOptions& options ) { - if( auto renderable = dynamic_cast( &(*m_selectedObject) ) ) - { - renderable->GetDebugOptions( options ); - } - options.insert( "ProceduralVolumes" ); + if( auto renderable = dynamic_cast( &( *m_selectedObject ) ) ) + { + renderable->GetDebugOptions( options ); + } + options.insert( "ProceduralVolumes" ); } void EveChildProceduralContainer::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if( !m_display ) - { - return; - } - - if( auto renderable = dynamic_cast( &(*m_selectedObject) ) ) - { - renderable->RenderDebugInfo( renderer ); - } - - if( renderer.HasOption( this, "ProceduralVolumes" ) ) - { - if( m_selectionMethod != nullptr ) - { - IEveVolumeVector* debugVolumes = m_selectionMethod->GetDebugVolumes(); - - for( auto volume = debugVolumes->begin(); volume != debugVolumes->end(); ++volume ) - { - ( *volume )->RenderDebugInfo( renderer, m_worldTransform ); - } - } - } + if( !m_display ) + { + return; + } + + if( auto renderable = dynamic_cast( &( *m_selectedObject ) ) ) + { + renderable->RenderDebugInfo( renderer ); + } + + if( renderer.HasOption( this, "ProceduralVolumes" ) ) + { + if( m_selectionMethod != nullptr ) + { + IEveVolumeVector* debugVolumes = m_selectionMethod->GetDebugVolumes(); + + for( auto volume = debugVolumes->begin(); volume != debugVolumes->end(); ++volume ) + { + ( *volume )->RenderDebugInfo( renderer, m_worldTransform ); + } + } + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h index 9250e2c4f..122ee0afc 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer.h @@ -14,10 +14,10 @@ BLUE_CLASS( EveChildProceduralContainer ) : public IEveSpaceObjectChild, - public ITr2CurveSetOwner, + public ITr2CurveSetOwner, public IEveInheritPropertiesOwner, public EveChildTransform, - public ITr2SoundEmitterOwner, + public ITr2SoundEmitterOwner, public IInitialize, public INotify, public IListNotify, @@ -28,22 +28,22 @@ BLUE_CLASS( EveChildProceduralContainer ) : public: EXPOSE_TO_BLUE(); - EveChildProceduralContainer( IRoot* lockobj = NULL ); + EveChildProceduralContainer( IRoot* lockobj = NULL ); ~EveChildProceduralContainer(); - const char* GetName() const override; - void SetName( const char* name ) override; + const char* GetName() const override; + void SetName( const char* name ) override; - void ConfigureSelectedObject(); - const char* GetMethodVariableName(); + void ConfigureSelectedObject(); + const char* GetMethodVariableName(); - ////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize() override; ////////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; ////////////////////////////////////////////////////////////////////////////////////// // IListNotify @@ -51,8 +51,8 @@ BLUE_CLASS( EveChildProceduralContainer ) : ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChildOwner - void AddTransformModifier( IEveChildTransformModifier* modifier ) override; - void SetProceduralContainerVariable(const char *name, float value) ; + void AddTransformModifier( IEveChildTransformModifier * modifier ) override; + void SetProceduralContainerVariable( const char* name, float value ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -60,52 +60,52 @@ BLUE_CLASS( EveChildProceduralContainer ) : void HandleControllerEvent( const char* name ) override; void StartControllers() override; - ///////////////////////////////////////////////////////////////////////////////////// - // ITr2CurveSetOwner - void PlayCurveSet( const std::string& name, const std::string& rangeName ) override; - void StopCurveSet( const std::string& name ) override; - void UpdateCurveSet( const std::string& name, Be::Time time ) override; - float GetCurveSetDuration( const std::string& name ) const override; - float GetRangeDuration( const std::string& name, const std::string& rangeName ) const override; - void PlayAllCurveSets() override; - void StopAllCurveSets() override; - - ///////////////////////////////////////////////////////////////////////////////////// - // IEveSpaceObjectChild + ///////////////////////////////////////////////////////////////////////////////////// + // ITr2CurveSetOwner + void PlayCurveSet( const std::string& name, const std::string& rangeName ) override; + void StopCurveSet( const std::string& name ) override; + void UpdateCurveSet( const std::string& name, Be::Time time ) override; + float GetCurveSetDuration( const std::string& name ) const override; + float GetRangeDuration( const std::string& name, const std::string& rangeName ) const override; + void PlayAllCurveSets() override; + void StopAllCurveSets() override; + + ///////////////////////////////////////////////////////////////////////////////////// + // IEveSpaceObjectChild void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector& renderables ) override; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + void GetRenderables( std::vector & renderables ) override; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void GetLocalToWorldTransform( Matrix& transform ) const override; - void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; + void GetLocalToWorldTransform( Matrix & transform ) const override; + void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; void ChangeLOD( Tr2Lod lod ) override; - ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; - void SetInheritProperties( const Color* colorSet ) override; + ITr2AudEmitterPtr FindSoundEmitter( const char* name ) override; + void SetInheritProperties( const Color* colorSet ) override; ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; - ///////////////////////////////////////////////////////////////////////////////////// - // EveChildTransform + ///////////////////////////////////////////////////////////////////////////////////// + // EveChildTransform void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; - ///////////////////////////////////////////////////////////////////////////////////// - // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + ///////////////////////////////////////////////////////////////////////////////////// + // ITr2DebugRenderable + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; protected: IEveSpaceObjectChildPtr m_selectedObject; - IEveProceduralSelectionMethodPtr m_selectionMethod; + IEveProceduralSelectionMethodPtr m_selectionMethod; BlueSharedString m_name; PIEveChildTransformModifierVector m_transformModifiers; - TrackableStdUnorderedMap m_proceduralContainerVariables; + TrackableStdUnorderedMap m_proceduralContainerVariables; bool m_display; }; diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp index 8dfa38298..e86efdcb0 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/EveChildProceduralContainer_Blue.cpp @@ -6,8 +6,8 @@ BLUE_DEFINE( EveChildProceduralContainer ); const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildProceduralContainer, "" ) - MAP_INTERFACE( EveChildProceduralContainer ) + EXPOSURE_BEGIN( EveChildProceduralContainer, "" ) + MAP_INTERFACE( EveChildProceduralContainer ) MAP_INTERFACE( IEveSpaceObjectChild ) MAP_INTERFACE( ITr2CurveSetOwner ) MAP_INTERFACE( IInitialize ) @@ -22,22 +22,25 @@ const Be::ClassInfo* EveChildProceduralContainer::ExposeToBlue() MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "localTransform", m_localTransform, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "", Be::READ ) MAP_ATTRIBUTE( "useSRT", m_useSRT, "Should local transform be built from scaling, rotation and translation attributes.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "staticTransform", m_staticTransform, "Does local transform need to be rebuilt every frame.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "useStaticRotation", m_useStaticRotation, "Should this container ignore the parent rotation.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "selectionMethod", m_selectionMethod, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "selectedObject", m_selectedObject, ":jessica-icon: fa-cube", Be::READ ) - MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, ":jessica-hidden: True", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "selectionMethod", m_selectionMethod, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "selectedObject", m_selectedObject, ":jessica-icon: fa-cube", Be::READ ) + MAP_ATTRIBUTE( "transformModifiers", m_transformModifiers, ":jessica-hidden: True", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) - MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" ":param value: new variable value\n" ) - MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" ":param name: event name" ) + MAP_METHOD_AND_WRAP( "RebuildLocalTransform", RebuildLocalTransform, "Rebuilds local transform." ) + MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) + MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, "Start all controllers" ) - MAP_METHOD_AND_WRAP( "GetMethodVariableName", GetMethodVariableName, "Get the name of the seed variable being utilized" ) - MAP_METHOD_AND_WRAP( "SetProceduralContainerVariable", SetProceduralContainerVariable, "Set variable for all applicable ProceduralContainers\n:param name: variable name\n:param value: new variable value\n" ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP( "GetMethodVariableName", GetMethodVariableName, "Get the name of the seed variable being utilized" ) + MAP_METHOD_AND_WRAP( "SetProceduralContainerVariable", SetProceduralContainerVariable, "Set variable for all applicable ProceduralContainers\n:param name: variable name\n:param value: new variable value\n" ) + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.cpp index 4c994e208..37b836862 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.cpp @@ -4,10 +4,10 @@ EveProceduralMethodAttributeMap::EveProceduralMethodAttributeMap( IRoot* lockobj ) : - PARENTLOCK( m_parameters ), - PARENTLOCK( m_debugVolumes ), - m_selectedChildIndex( -1 ), - m_selectedChildModified( false ) + PARENTLOCK( m_parameters ), + PARENTLOCK( m_debugVolumes ), + m_selectedChildIndex( -1 ), + m_selectedChildModified( false ) { } @@ -18,79 +18,79 @@ EveProceduralMethodAttributeMap::~EveProceduralMethodAttributeMap() bool EveProceduralMethodAttributeMap::OnModified( Be::Var* value ) { - if( IsMatch( value, m_seed ) ) - { - SelectParameter(); - } + if( IsMatch( value, m_seed ) ) + { + SelectParameter(); + } - return true; + return true; } void EveProceduralMethodAttributeMap::SelectParameter() { - int currentChild = m_selectedChildIndex; - int index = 0; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - if( strcmp( (*it)->GetName(), m_seed.c_str() ) == 0 ) - { - m_selectedChildIndex = index; - break; - } - index++; - } + int currentChild = m_selectedChildIndex; + int index = 0; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + if( strcmp( ( *it )->GetName(), m_seed.c_str() ) == 0 ) + { + m_selectedChildIndex = index; + break; + } + index++; + } - if( currentChild != m_selectedChildIndex) - { - m_selectedChildModified = true; - } + if( currentChild != m_selectedChildIndex ) + { + m_selectedChildModified = true; + } } bool EveProceduralMethodAttributeMap::IsSelectedChildModified() const { - return m_selectedChildModified; + return m_selectedChildModified; } EveChildRefPtr EveProceduralMethodAttributeMap::GetSelectedChild() { - if ( m_selectedChildIndex < 0 || m_selectedChildIndex > (m_parameters.size() - 1) ) - { - return nullptr; - } + if( m_selectedChildIndex < 0 || m_selectedChildIndex > ( m_parameters.size() - 1 ) ) + { + return nullptr; + } - m_selectedChildModified = false; - EveProceduralMethodAttributeMapParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); + m_selectedChildModified = false; + EveProceduralMethodAttributeMapParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); - if( param != nullptr ) - { - auto child = param->GetChild(); - if( child != nullptr && strlen(child->GetResPath()) != 0 ) - { - param->Load(); - return child; - } - } - return nullptr; + if( param != nullptr ) + { + auto child = param->GetChild(); + if( child != nullptr && strlen( child->GetResPath() ) != 0 ) + { + param->Load(); + return child; + } + } + return nullptr; } void EveProceduralMethodAttributeMap::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - bool reselect = false; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - if( ( *it )->IsModified() ) - { - reselect = true; - ( *it )->SetModified( false ); - } - } - if( reselect ) - { - SelectParameter(); - } + bool reselect = false; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + if( ( *it )->IsModified() ) + { + reselect = true; + ( *it )->SetModified( false ); + } + } + if( reselect ) + { + SelectParameter(); + } } IEveVolumeVector* EveProceduralMethodAttributeMap::GetDebugVolumes() { - return &m_debugVolumes; + return &m_debugVolumes; } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.h index 3da8fb626..18ff98b2a 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap.h @@ -14,33 +14,34 @@ BLUE_DECLARE_INTERFACE( IEveVolume ); BLUE_CLASS( EveProceduralMethodAttributeMap ) : public IEveProceduralSelectionMethod, - public INotify + public INotify { public: EXPOSE_TO_BLUE(); - EveProceduralMethodAttributeMap( IRoot* lockobj = NULL ); + EveProceduralMethodAttributeMap( IRoot* lockobj = NULL ); ~EveProceduralMethodAttributeMap(); - void SelectParameter(); + void SelectParameter(); - // IEveProceduralSelectionMethod - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - bool IsSelectedChildModified() const override; - EveChildRefPtr GetSelectedChild() override; - IEveVolumeVector* GetDebugVolumes() override; + // IEveProceduralSelectionMethod + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; + bool IsSelectedChildModified() const override; + EveChildRefPtr GetSelectedChild() override; + IEveVolumeVector* GetDebugVolumes() override; - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; protected: - BlueSharedString m_mappedAttribute; - BlueSharedString m_seed; - int m_selectedChildIndex; - PEveProceduralMethodAttributeMapParameterVector m_parameters; + BlueSharedString m_mappedAttribute; + BlueSharedString m_seed; + int m_selectedChildIndex; + PEveProceduralMethodAttributeMapParameterVector m_parameters; + private: - bool m_selectedChildModified; - PIEveVolumeVector m_debugVolumes; + bool m_selectedChildModified; + PIEveVolumeVector m_debugVolumes; }; TYPEDEF_BLUECLASS( EveProceduralMethodAttributeMap ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.cpp index a4a491d6f..ee2b42fcf 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.cpp @@ -4,7 +4,7 @@ EveProceduralMethodAttributeMapParameter::EveProceduralMethodAttributeMapParameter( IRoot* lockobj ) : - m_modified( false ) + m_modified( false ) { } @@ -14,50 +14,50 @@ EveProceduralMethodAttributeMapParameter::~EveProceduralMethodAttributeMapParame bool EveProceduralMethodAttributeMapParameter::Initialize() { - if( m_child == nullptr ) - { - m_child.CreateInstance(); - } - return true; + if( m_child == nullptr ) + { + m_child.CreateInstance(); + } + return true; } bool EveProceduralMethodAttributeMapParameter::OnModified( Be::Var* value ) { - if( IsMatch( value, m_child ) ) - { - if( m_child != nullptr ) - { - m_child->SetAutoLoadBlocker(true); - } - } + if( IsMatch( value, m_child ) ) + { + if( m_child != nullptr ) + { + m_child->SetAutoLoadBlocker( true ); + } + } - return true; + return true; } void EveProceduralMethodAttributeMapParameter::SetModified( bool isModified ) { - m_modified = isModified; + m_modified = isModified; } bool EveProceduralMethodAttributeMapParameter::IsModified() const { - return m_modified; + return m_modified; } const char* EveProceduralMethodAttributeMapParameter::GetName() const { - return m_name.c_str(); + return m_name.c_str(); } EveChildRefPtr EveProceduralMethodAttributeMapParameter::GetChild() { - return m_child; + return m_child; } void EveProceduralMethodAttributeMapParameter::Load() { - if( m_child != nullptr ) - { - m_child->Reload(true); - } + if( m_child != nullptr ) + { + m_child->Reload( true ); + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.h index 5bbd5cad4..e68a7f076 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter.h @@ -6,30 +6,32 @@ #include "Tr2DebugRenderer.h" BLUE_CLASS( EveProceduralMethodAttributeMapParameter ) : - public INotify, - public IInitialize + public INotify, + public IInitialize { public: - EXPOSE_TO_BLUE(); - EveProceduralMethodAttributeMapParameter( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EveProceduralMethodAttributeMapParameter( IRoot* lockobj = NULL ); ~EveProceduralMethodAttributeMapParameter(); - const char* GetName() const; - void SetModified( bool isModified ); - bool IsModified() const; - EveChildRefPtr GetChild(); - void Load(); + const char* GetName() const; + void SetModified( bool isModified ); + bool IsModified() const; + EveChildRefPtr GetChild(); + void Load(); - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; + + // IInitialize + bool Initialize() override; - // IInitialize - bool Initialize() override; protected: BlueSharedString m_name; - EveChildRefPtr m_child; + EveChildRefPtr m_child; + private: - bool m_modified; + bool m_modified; }; TYPEDEF_BLUECLASS( EveProceduralMethodAttributeMapParameter ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter_Blue.cpp index 74769f007..e214db3f2 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMapParameter_Blue.cpp @@ -7,15 +7,13 @@ BLUE_DEFINE( EveProceduralMethodAttributeMapParameter ); const Be::ClassInfo* EveProceduralMethodAttributeMapParameter::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodAttributeMapParameter, "" ) - MAP_INTERFACE( EveProceduralMethodAttributeMapParameter ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveProceduralMethodAttributeMapParameter, "" ) + MAP_INTERFACE( EveProceduralMethodAttributeMapParameter ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap_Blue.cpp index cf88d6cbc..efcdfe518 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodAttributeMap_Blue.cpp @@ -6,19 +6,17 @@ BLUE_DEFINE( EveProceduralMethodAttributeMap ); const Be::ClassInfo* EveProceduralMethodAttributeMap::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodAttributeMap, "" ) - MAP_INTERFACE( EveProceduralMethodAttributeMap ) - MAP_INTERFACE( IEveProceduralSelectionMethod ) - MAP_INTERFACE( INotify ) + EXPOSURE_BEGIN( EveProceduralMethodAttributeMap, "" ) + MAP_INTERFACE( EveProceduralMethodAttributeMap ) + MAP_INTERFACE( IEveProceduralSelectionMethod ) + MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "thresholdAttribute", m_mappedAttribute, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) + MAP_ATTRIBUTE( "thresholdAttribute", m_mappedAttribute, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.cpp index ef9284df6..ad35c0d8a 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.cpp @@ -4,15 +4,15 @@ EveProceduralMethodCycling::EveProceduralMethodCycling( IRoot* lockobj ) : - PARENTLOCK( m_parameters ), - PARENTLOCK( m_debugVolumes ), - m_selectedChildIndex( -1 ), - m_selectedChildModified( false ), - m_startTime( 0 ), - m_startTimeOffset( 0.0 ), + PARENTLOCK( m_parameters ), + PARENTLOCK( m_debugVolumes ), + m_selectedChildIndex( -1 ), + m_selectedChildModified( false ), + m_startTime( 0 ), + m_startTimeOffset( 0.0 ), m_randomizeOrder( false ) { - m_parameters.SetNotify( this ); + m_parameters.SetNotify( this ); } EveProceduralMethodCycling::~EveProceduralMethodCycling() @@ -22,29 +22,29 @@ EveProceduralMethodCycling::~EveProceduralMethodCycling() bool EveProceduralMethodCycling::OnModified( Be::Var* value ) { - return true; + return true; } void EveProceduralMethodCycling::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* list ) { - if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) - { - SelectParameter(); - } + if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) + { + SelectParameter(); + } } void EveProceduralMethodCycling::SelectParameter() { - if (m_parameters.empty()) - { - return; - } + if( m_parameters.empty() ) + { + return; + } - if ( m_randomizeOrder && m_parameters.size() > 2 ) + if( m_randomizeOrder && m_parameters.size() > 2 ) { int oldIndex = m_selectedChildIndex; - m_selectedChildIndex = rand() % ( (int)(m_parameters.size()) - 1 ); - if ( m_selectedChildIndex >= oldIndex ) + m_selectedChildIndex = rand() % ( (int)( m_parameters.size() ) - 1 ); + if( m_selectedChildIndex >= oldIndex ) { m_selectedChildIndex++; } @@ -55,57 +55,57 @@ void EveProceduralMethodCycling::SelectParameter() m_selectedChildIndex %= (int)m_parameters.size(); } - m_startTime = BeOS->GetCurrentFrameTime() - TimeFromDouble((double) m_startTimeOffset); - m_selectedChildModified = true; + m_startTime = BeOS->GetCurrentFrameTime() - TimeFromDouble( (double)m_startTimeOffset ); + m_selectedChildModified = true; } bool EveProceduralMethodCycling::IsSelectedChildModified() const { - return m_selectedChildModified; + return m_selectedChildModified; } EveChildRefPtr EveProceduralMethodCycling::GetSelectedChild() { - if ( m_selectedChildIndex < 0 || m_selectedChildIndex > (m_parameters.size() - 1) ) - { - return nullptr; - } - - m_selectedChildModified = false; - EveProceduralMethodCyclingParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); - - if( param != nullptr ) - { - auto child = param->GetChild(); - if( child != nullptr && strlen( child->GetResPath()) != 0 ) - { - param->Load(); - return child; - } - } - return nullptr; + if( m_selectedChildIndex < 0 || m_selectedChildIndex > ( m_parameters.size() - 1 ) ) + { + return nullptr; + } + + m_selectedChildModified = false; + EveProceduralMethodCyclingParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); + + if( param != nullptr ) + { + auto child = param->GetChild(); + if( child != nullptr && strlen( child->GetResPath() ) != 0 ) + { + param->Load(); + return child; + } + } + return nullptr; } void EveProceduralMethodCycling::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - if ( m_selectedChildIndex < 0 || m_selectedChildIndex > (m_parameters.size() - 1) ) - { - SelectParameter(); - return; - } - EveProceduralMethodCyclingParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); - - if( param != nullptr ) - { - float elapsedTime = TimeAsFloat( BeOS->GetCurrentFrameTime() - m_startTime ); - if (elapsedTime >= param->GetDuration()) - { - SelectParameter(); - } - } + if( m_selectedChildIndex < 0 || m_selectedChildIndex > ( m_parameters.size() - 1 ) ) + { + SelectParameter(); + return; + } + EveProceduralMethodCyclingParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); + + if( param != nullptr ) + { + float elapsedTime = TimeAsFloat( BeOS->GetCurrentFrameTime() - m_startTime ); + if( elapsedTime >= param->GetDuration() ) + { + SelectParameter(); + } + } } IEveVolumeVector* EveProceduralMethodCycling::GetDebugVolumes() { - return &m_debugVolumes; + return &m_debugVolumes; } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.h index 91a676993..5ddb3b9ea 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling.h @@ -14,39 +14,40 @@ BLUE_DECLARE_INTERFACE( IEveVolume ); BLUE_CLASS( EveProceduralMethodCycling ) : public IEveProceduralSelectionMethod, - public IListNotify, - public INotify + public IListNotify, + public INotify { public: EXPOSE_TO_BLUE(); - EveProceduralMethodCycling( IRoot* lockobj = NULL ); + EveProceduralMethodCycling( IRoot* lockobj = NULL ); ~EveProceduralMethodCycling(); - void SelectParameter(); + void SelectParameter(); - // IEveProceduralSelectionMethod - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - bool IsSelectedChildModified() const override; - EveChildRefPtr GetSelectedChild() override; - IEveVolumeVector* GetDebugVolumes() override; + // IEveProceduralSelectionMethod + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; + bool IsSelectedChildModified() const override; + EveChildRefPtr GetSelectedChild() override; + IEveVolumeVector* GetDebugVolumes() override; - // IListNotify - void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; + // IListNotify + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; protected: - BlueSharedString m_name; - int m_selectedChildIndex; - PEveProceduralMethodCyclingParameterVector m_parameters; + BlueSharedString m_name; + int m_selectedChildIndex; + PEveProceduralMethodCyclingParameterVector m_parameters; + private: - bool m_selectedChildModified; + bool m_selectedChildModified; bool m_randomizeOrder; - PIEveVolumeVector m_debugVolumes; - Be::Time m_startTime; - float m_startTimeOffset; + PIEveVolumeVector m_debugVolumes; + Be::Time m_startTime; + float m_startTimeOffset; }; TYPEDEF_BLUECLASS( EveProceduralMethodCycling ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.cpp index f094ff938..bbae7fb52 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.cpp @@ -4,11 +4,11 @@ EveProceduralMethodCyclingParameter::EveProceduralMethodCyclingParameter( IRoot* lockobj ) : - m_modified( false ), - m_hasLoaded( false ), - m_restartRequired( true ), - m_reloadRequired( false ), - m_playDuration( 1.f ) + m_modified( false ), + m_hasLoaded( false ), + m_restartRequired( true ), + m_reloadRequired( false ), + m_playDuration( 1.f ) { } @@ -18,66 +18,66 @@ EveProceduralMethodCyclingParameter::~EveProceduralMethodCyclingParameter() bool EveProceduralMethodCyclingParameter::Initialize() { - if( m_child == nullptr ) - { - m_child.CreateInstance(); - } - return true; + if( m_child == nullptr ) + { + m_child.CreateInstance(); + } + return true; } bool EveProceduralMethodCyclingParameter::OnModified( Be::Var* value ) { - if( IsMatch( value, m_child ) ) - { - if( m_child != nullptr ) - { - m_child->SetAutoLoadBlocker(true); - } - } + if( IsMatch( value, m_child ) ) + { + if( m_child != nullptr ) + { + m_child->SetAutoLoadBlocker( true ); + } + } - return true; + return true; } void EveProceduralMethodCyclingParameter::SetModified( bool isModified ) { - m_modified = isModified; + m_modified = isModified; } bool EveProceduralMethodCyclingParameter::IsModified() const { - return m_modified; + return m_modified; } const char* EveProceduralMethodCyclingParameter::GetName() const { - return m_name.c_str(); + return m_name.c_str(); } EveChildRefPtr EveProceduralMethodCyclingParameter::GetChild() { - return m_child; + return m_child; } float EveProceduralMethodCyclingParameter::GetDuration() const { - return m_playDuration; + return m_playDuration; } void EveProceduralMethodCyclingParameter::Load() { - if( m_hasLoaded && !m_reloadRequired ) - { - if( m_restartRequired ) - { - m_child->StartControllers(); - m_child->PlayAllCurveSets(); - } - return; - } + if( m_hasLoaded && !m_reloadRequired ) + { + if( m_restartRequired ) + { + m_child->StartControllers(); + m_child->PlayAllCurveSets(); + } + return; + } - if( m_child != nullptr ) - { - m_child->Reload(true); - m_hasLoaded = true; - } + if( m_child != nullptr ) + { + m_child->Reload( true ); + m_hasLoaded = true; + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.h index 0d09861f2..f066e42c9 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter.h @@ -6,36 +6,37 @@ #include "Tr2DebugRenderer.h" BLUE_CLASS( EveProceduralMethodCyclingParameter ) : - public INotify, - public IInitialize + public INotify, + public IInitialize { public: - EXPOSE_TO_BLUE(); - EveProceduralMethodCyclingParameter( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EveProceduralMethodCyclingParameter( IRoot* lockobj = NULL ); ~EveProceduralMethodCyclingParameter(); - const char* GetName() const; - void SetModified( bool isModified ); - bool IsModified() const; - EveChildRefPtr GetChild(); - void Load(); - float GetDuration() const; + const char* GetName() const; + void SetModified( bool isModified ); + bool IsModified() const; + EveChildRefPtr GetChild(); + void Load(); + float GetDuration() const; - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; + + // IInitialize + bool Initialize() override; - // IInitialize - bool Initialize() override; protected: BlueSharedString m_name; - EveChildRefPtr m_child; + EveChildRefPtr m_child; private: - bool m_modified; - bool m_hasLoaded; - bool m_restartRequired; - bool m_reloadRequired; - float m_playDuration; + bool m_modified; + bool m_hasLoaded; + bool m_restartRequired; + bool m_reloadRequired; + float m_playDuration; }; TYPEDEF_BLUECLASS( EveProceduralMethodCyclingParameter ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter_Blue.cpp index 60485bb5d..518830a8f 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCyclingParameter_Blue.cpp @@ -7,18 +7,16 @@ BLUE_DEFINE( EveProceduralMethodCyclingParameter ); const Be::ClassInfo* EveProceduralMethodCyclingParameter::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodCyclingParameter, "" ) - MAP_INTERFACE( EveProceduralMethodCyclingParameter ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IInitialize ) - - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "playDuration", m_playDuration, "how long we stay on the child until we move on to the next one", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "restartRequired", m_restartRequired, "restarts curvesets / controlers when activated", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "reloadRequired", m_reloadRequired, "only enable this if child needs to be reloaded for each loop", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_END() + EXPOSURE_BEGIN( EveProceduralMethodCyclingParameter, "" ) + MAP_INTERFACE( EveProceduralMethodCyclingParameter ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IInitialize ) + + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "playDuration", m_playDuration, "how long we stay on the child until we move on to the next one", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "restartRequired", m_restartRequired, "restarts curvesets / controlers when activated", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "reloadRequired", m_reloadRequired, "only enable this if child needs to be reloaded for each loop", Be::READWRITE | Be::PERSIST ) + + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling_Blue.cpp index af8abe01d..0f7751297 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodCycling_Blue.cpp @@ -6,22 +6,24 @@ BLUE_DEFINE( EveProceduralMethodCycling ); const Be::ClassInfo* EveProceduralMethodCycling::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodCycling, "" ) - MAP_INTERFACE( EveProceduralMethodCycling ) - MAP_INTERFACE( IEveProceduralSelectionMethod ) - MAP_INTERFACE( INotify ) + EXPOSURE_BEGIN( EveProceduralMethodCycling, "" ) + MAP_INTERFACE( EveProceduralMethodCycling ) + MAP_INTERFACE( IEveProceduralSelectionMethod ) + MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) + MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) - MAP_ATTRIBUTE( "startTimeOffset", m_startTimeOffset, "applies to first switch after playing\n"":jessica-group:randomOptions", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomizeOrder", m_randomizeOrder, "enable this and it will always pick a random one to swap to\n"":jessica-group:randomOptions", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "startTimeOffset", m_startTimeOffset, "applies to first switch after playing\n" + ":jessica-group:randomOptions", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomizeOrder", m_randomizeOrder, "enable this and it will always pick a random one to swap to\n" + ":jessica-group:randomOptions", + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "restart", SelectParameter, "restart the container \n:jessica-placement: TOOLBAR\n:jessica-icon: fa-arrows-spin\n" ) - - EXPOSURE_END() -} - + EXPOSURE_END() +} diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.cpp index fe2108323..3ba78fba2 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.cpp @@ -4,14 +4,14 @@ EveProceduralMethodRandom::EveProceduralMethodRandom( IRoot* lockobj ) : - PARENTLOCK( m_parameters ), - PARENTLOCK( m_debugVolumes ), - m_seed( -1 ), - m_selectedChildIndex( -1 ), - m_totalWeight( 0 ), - m_selectedChildModified( false ) + PARENTLOCK( m_parameters ), + PARENTLOCK( m_debugVolumes ), + m_seed( -1 ), + m_selectedChildIndex( -1 ), + m_totalWeight( 0 ), + m_selectedChildModified( false ) { - m_parameters.SetNotify( this ); + m_parameters.SetNotify( this ); } EveProceduralMethodRandom::~EveProceduralMethodRandom() @@ -20,135 +20,135 @@ EveProceduralMethodRandom::~EveProceduralMethodRandom() bool EveProceduralMethodRandom::Initialize() { - GenerateParameterMapping(); - return true; + GenerateParameterMapping(); + return true; } bool EveProceduralMethodRandom::OnModified( Be::Var* value ) { - if( IsMatch( value, m_seed ) ) - { - SelectARandomParameter(); - } + if( IsMatch( value, m_seed ) ) + { + SelectARandomParameter(); + } - return true; + return true; } void EveProceduralMethodRandom::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* list ) { - if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) - { - GenerateParameterMapping(); - } + if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) + { + GenerateParameterMapping(); + } } void EveProceduralMethodRandom::GenerateParameterMapping() { - m_parameterMapping.clear(); - m_parameterMapping.reserve( m_parameters.size() ); - m_totalWeight = 0; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - m_totalWeight += ( *it )->GetWeighting(); - m_parameterMapping.push_back( m_totalWeight ); - } + m_parameterMapping.clear(); + m_parameterMapping.reserve( m_parameters.size() ); + m_totalWeight = 0; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + m_totalWeight += ( *it )->GetWeighting(); + m_parameterMapping.push_back( m_totalWeight ); + } } void EveProceduralMethodRandom::SelectARandomParameter() { - if( m_parameterMapping.empty() ) - { - return; - } - - int currentChild = m_selectedChildIndex; - srand( (int)m_seed ); - int rnd = (int)rand() % m_totalWeight; - - m_selectedChildIndex = -1; - for( int i = 0; i < (int)m_parameterMapping.size(); i++ ) - { - if( rnd < m_parameterMapping[i] ) - { - m_selectedChildIndex = i; - break; - } - } - - if( currentChild != m_selectedChildIndex) - { - m_selectedChildModified = true; - } + if( m_parameterMapping.empty() ) + { + return; + } + + int currentChild = m_selectedChildIndex; + srand( (int)m_seed ); + int rnd = (int)rand() % m_totalWeight; + + m_selectedChildIndex = -1; + for( int i = 0; i < (int)m_parameterMapping.size(); i++ ) + { + if( rnd < m_parameterMapping[i] ) + { + m_selectedChildIndex = i; + break; + } + } + + if( currentChild != m_selectedChildIndex ) + { + m_selectedChildModified = true; + } } bool EveProceduralMethodRandom::IsSelectedChildModified() const { - return m_selectedChildModified; + return m_selectedChildModified; } EveChildRefPtr EveProceduralMethodRandom::GetSelectedChild() { - if ( m_selectedChildIndex < 0 || m_selectedChildIndex > (m_parameters.size() - 1) ) - { - return nullptr; - } - - m_selectedChildModified = false; - EveProceduralMethodRandomParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); - - if( param != nullptr ) - { - auto child = param->GetChild(); - if( child != nullptr && strlen(child->GetResPath()) != 0 ) - { - param->Load(); - return child; - } - } - return nullptr; + if( m_selectedChildIndex < 0 || m_selectedChildIndex > ( m_parameters.size() - 1 ) ) + { + return nullptr; + } + + m_selectedChildModified = false; + EveProceduralMethodRandomParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); + + if( param != nullptr ) + { + auto child = param->GetChild(); + if( child != nullptr && strlen( child->GetResPath() ) != 0 ) + { + param->Load(); + return child; + } + } + return nullptr; } void EveProceduralMethodRandom::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - bool regenerateParameterMap = false; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - if( ( *it )->IsModified() ) - { - regenerateParameterMap = true; - ( *it )->SetModified( false ); - } - } - if( regenerateParameterMap ) - { - GenerateParameterMapping(); - SelectARandomParameter(); - } + bool regenerateParameterMap = false; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + if( ( *it )->IsModified() ) + { + regenerateParameterMap = true; + ( *it )->SetModified( false ); + } + } + if( regenerateParameterMap ) + { + GenerateParameterMapping(); + SelectARandomParameter(); + } } IEveVolumeVector* EveProceduralMethodRandom::GetDebugVolumes() { - return &m_debugVolumes; + return &m_debugVolumes; } void EveProceduralMethodRandom::SetProceduralMethodVariable( const char* name, float value ) { - if( strcmp( name, m_seedName.c_str() ) == 0) - { - if( m_seed != value) - { - m_seed = value; - SelectARandomParameter(); - } - } + if( strcmp( name, m_seedName.c_str() ) == 0 ) + { + if( m_seed != value ) + { + m_seed = value; + SelectARandomParameter(); + } + } } const char* EveProceduralMethodRandom::GetProceduralMethodVariable() { - if( strcmp( "", m_seedName.c_str() ) == 0 ) - { - return "nameMissing"; - } + if( strcmp( "", m_seedName.c_str() ) == 0 ) + { + return "nameMissing"; + } - return m_seedName.c_str(); + return m_seedName.c_str(); } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.h index bb3b6efeb..2102783eb 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom.h @@ -13,48 +13,49 @@ BLUE_DECLARE_INTERFACE( IEveVolume ); BLUE_CLASS( EveProceduralMethodRandom ) : public IEveProceduralSelectionMethod, - public INotify, - public IListNotify, - public IInitialize + public INotify, + public IListNotify, + public IInitialize { public: EXPOSE_TO_BLUE(); - EveProceduralMethodRandom( IRoot* lockobj = NULL ); + EveProceduralMethodRandom( IRoot* lockobj = NULL ); ~EveProceduralMethodRandom(); - void SelectARandomParameter(); - void GenerateParameterMapping(); + void SelectARandomParameter(); + void GenerateParameterMapping(); - void SetProceduralMethodVariable( const char* name, float value ) override; - const char* GetProceduralMethodVariable() override; + void SetProceduralMethodVariable( const char* name, float value ) override; + const char* GetProceduralMethodVariable() override; - // IEveProceduralSelectionMethod - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - bool IsSelectedChildModified() const override; - EveChildRefPtr GetSelectedChild() override; - IEveVolumeVector* GetDebugVolumes() override; + // IEveProceduralSelectionMethod + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; + bool IsSelectedChildModified() const override; + EveChildRefPtr GetSelectedChild() override; + IEveVolumeVector* GetDebugVolumes() override; - // IInitialize - bool Initialize() override; + // IInitialize + bool Initialize() override; - // IListNotify - void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; + // IListNotify + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; protected: BlueSharedString m_name; - BlueSharedString m_seedName; - float m_seed; - int m_selectedChildIndex; - int m_totalWeight; - std::vector m_parameterMapping; - PEveProceduralMethodRandomParameterVector m_parameters; + BlueSharedString m_seedName; + float m_seed; + int m_selectedChildIndex; + int m_totalWeight; + std::vector m_parameterMapping; + PEveProceduralMethodRandomParameterVector m_parameters; + private: - bool m_selectedChildModified; - PIEveVolumeVector m_debugVolumes; + bool m_selectedChildModified; + PIEveVolumeVector m_debugVolumes; }; TYPEDEF_BLUECLASS( EveProceduralMethodRandom ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.cpp index 04e11f12f..3b2ee8dc8 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.cpp @@ -4,8 +4,8 @@ EveProceduralMethodRandomParameter::EveProceduralMethodRandomParameter( IRoot* lockobj ) : - m_weighting( 1 ), - m_modified( false ) + m_weighting( 1 ), + m_modified( false ) { } @@ -15,66 +15,66 @@ EveProceduralMethodRandomParameter::~EveProceduralMethodRandomParameter() const char* EveProceduralMethodRandomParameter::GetName() const { - return m_name.c_str(); + return m_name.c_str(); } void EveProceduralMethodRandomParameter::SetName( const char* name ) { - m_name = BlueSharedString( name ); + m_name = BlueSharedString( name ); } bool EveProceduralMethodRandomParameter::Initialize() { - if( m_child == nullptr ) - { - m_child.CreateInstance(); - } - return true; + if( m_child == nullptr ) + { + m_child.CreateInstance(); + } + return true; } bool EveProceduralMethodRandomParameter::OnModified( Be::Var* value ) { - if( IsMatch( value, m_weighting ) ) - { - m_weighting = max( m_weighting, 1 ); - m_modified = true; - } + if( IsMatch( value, m_weighting ) ) + { + m_weighting = max( m_weighting, 1 ); + m_modified = true; + } - if( IsMatch( value, m_child ) ) - { - if( m_child != nullptr ) - { - m_child->SetAutoLoadBlocker( true ); - } - } + if( IsMatch( value, m_child ) ) + { + if( m_child != nullptr ) + { + m_child->SetAutoLoadBlocker( true ); + } + } - return true; + return true; } void EveProceduralMethodRandomParameter::SetModified( bool isModified ) { - m_modified = isModified; + m_modified = isModified; } bool EveProceduralMethodRandomParameter::IsModified() const { - return m_modified; + return m_modified; } int EveProceduralMethodRandomParameter::GetWeighting() const { - return m_weighting; + return m_weighting; } EveChildRefPtr EveProceduralMethodRandomParameter::GetChild() { - return m_child; + return m_child; } void EveProceduralMethodRandomParameter::Load() { - if( m_child != nullptr ) - { - m_child->Reload(true); - } + if( m_child != nullptr ) + { + m_child->Reload( true ); + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.h index ae6093a7f..1f7c74b55 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter.h @@ -6,34 +6,36 @@ #include "Tr2DebugRenderer.h" BLUE_CLASS( EveProceduralMethodRandomParameter ) : - public INotify, - public IInitialize + public INotify, + public IInitialize { public: - EXPOSE_TO_BLUE(); - EveProceduralMethodRandomParameter( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EveProceduralMethodRandomParameter( IRoot* lockobj = NULL ); ~EveProceduralMethodRandomParameter(); - const char* GetName() const; - void SetName( const char* name ); + const char* GetName() const; + void SetName( const char* name ); - int GetWeighting() const; - void SetModified( bool isModified ); - bool IsModified() const; - EveChildRefPtr GetChild(); - void Load(); + int GetWeighting() const; + void SetModified( bool isModified ); + bool IsModified() const; + EveChildRefPtr GetChild(); + void Load(); - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; + + // IInitialize + bool Initialize() override; - // IInitialize - bool Initialize() override; protected: BlueSharedString m_name; - EveChildRefPtr m_child; - int m_weighting; + EveChildRefPtr m_child; + int m_weighting; + private: - bool m_modified; + bool m_modified; }; TYPEDEF_BLUECLASS( EveProceduralMethodRandomParameter ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter_Blue.cpp index 838b73d96..a17330fac 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandomParameter_Blue.cpp @@ -7,16 +7,14 @@ BLUE_DEFINE( EveProceduralMethodRandomParameter ); const Be::ClassInfo* EveProceduralMethodRandomParameter::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodRandomParameter, "" ) - MAP_INTERFACE( EveProceduralMethodRandomParameter ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveProceduralMethodRandomParameter, "" ) + MAP_INTERFACE( EveProceduralMethodRandomParameter ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weighting", m_weighting, "adjust the likelihood of this child being chosen relative to total weighting", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weighting", m_weighting, "adjust the likelihood of this child being chosen relative to total weighting", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom_Blue.cpp index 62cd4561e..41d185c71 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodRandom_Blue.cpp @@ -8,24 +8,22 @@ BLUE_DEFINE( EveProceduralMethodRandom ); const Be::ClassInfo* EveProceduralMethodRandom::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodRandom, "" ) - MAP_INTERFACE( EveProceduralMethodRandom ) - MAP_INTERFACE( IEveProceduralSelectionMethod ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveProceduralMethodRandom, "" ) + MAP_INTERFACE( EveProceduralMethodRandom ) + MAP_INTERFACE( IEveProceduralSelectionMethod ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "seedName", m_seedName, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) - MAP_ATTRIBUTE( "totalWeight", m_totalWeight, "combined weighting of all the parameters", Be::READ ) + MAP_ATTRIBUTE( "seedName", m_seedName, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) + MAP_ATTRIBUTE( "totalWeight", m_totalWeight, "combined weighting of all the parameters", Be::READ ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.cpp index a0386adc0..cf444a182 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.cpp @@ -4,8 +4,8 @@ EveProceduralMethodThresholdParameter::EveProceduralMethodThresholdParameter( IRoot* lockobj ) : - m_threshold( 1.f ), - m_modified( false ) + m_threshold( 1.f ), + m_modified( false ) { } @@ -15,56 +15,56 @@ EveProceduralMethodThresholdParameter::~EveProceduralMethodThresholdParameter() bool EveProceduralMethodThresholdParameter::Initialize() { - if( m_child == nullptr ) - { - m_child.CreateInstance(); - } - return true; + if( m_child == nullptr ) + { + m_child.CreateInstance(); + } + return true; } bool EveProceduralMethodThresholdParameter::OnModified( Be::Var* value ) { - if( IsMatch( value, m_threshold ) ) - { - m_threshold = max( m_threshold, 0.f ); - m_modified = true; - } + if( IsMatch( value, m_threshold ) ) + { + m_threshold = max( m_threshold, 0.f ); + m_modified = true; + } - if( IsMatch( value, m_child ) ) - { - if( m_child != nullptr ) - { - m_child->SetAutoLoadBlocker(true); - } - } + if( IsMatch( value, m_child ) ) + { + if( m_child != nullptr ) + { + m_child->SetAutoLoadBlocker( true ); + } + } - return true; + return true; } void EveProceduralMethodThresholdParameter::SetModified( bool isModified ) { - m_modified = isModified; + m_modified = isModified; } bool EveProceduralMethodThresholdParameter::IsModified() const { - return m_modified; + return m_modified; } float EveProceduralMethodThresholdParameter::GetThreshold() const { - return m_threshold; + return m_threshold; } EveChildRefPtr EveProceduralMethodThresholdParameter::GetChild() { - return m_child; + return m_child; } void EveProceduralMethodThresholdParameter::Load() { - if( m_child != nullptr ) - { - m_child->Reload(true); - } + if( m_child != nullptr ) + { + m_child->Reload( true ); + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.h index 7bfc4e4f3..e8e9b44b2 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter.h @@ -6,31 +6,33 @@ #include "Tr2DebugRenderer.h" BLUE_CLASS( EveProceduralMethodThresholdParameter ) : - public INotify, - public IInitialize + public INotify, + public IInitialize { public: - EXPOSE_TO_BLUE(); - EveProceduralMethodThresholdParameter( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + EveProceduralMethodThresholdParameter( IRoot* lockobj = NULL ); ~EveProceduralMethodThresholdParameter(); - float GetThreshold() const; - void SetModified( bool isModified ); - bool IsModified() const; - EveChildRefPtr GetChild(); - void Load(); + float GetThreshold() const; + void SetModified( bool isModified ); + bool IsModified() const; + EveChildRefPtr GetChild(); + void Load(); - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; + + // IInitialize + bool Initialize() override; - // IInitialize - bool Initialize() override; protected: BlueSharedString m_name; - EveChildRefPtr m_child; - float m_threshold; + EveChildRefPtr m_child; + float m_threshold; + private: - bool m_modified; + bool m_modified; }; TYPEDEF_BLUECLASS( EveProceduralMethodThresholdParameter ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter_Blue.cpp index 2a035123e..377851fff 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholdParameter_Blue.cpp @@ -7,16 +7,14 @@ BLUE_DEFINE( EveProceduralMethodThresholdParameter ); const Be::ClassInfo* EveProceduralMethodThresholdParameter::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodThresholdParameter, "" ) - MAP_INTERFACE( EveProceduralMethodThresholdParameter ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveProceduralMethodThresholdParameter, "" ) + MAP_INTERFACE( EveProceduralMethodThresholdParameter ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "threshold", m_threshold, "parameter will be selected if seed is lower than this value but higher than others passing the threshold", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "threshold", m_threshold, "parameter will be selected if seed is lower than this value but higher than others passing the threshold", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "child", m_child, ":jessica-icon: fa-suitcase-rolling", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.cpp index 6ffe0cbbe..8192489ca 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.cpp @@ -4,13 +4,13 @@ EveProceduralMethodThresholds::EveProceduralMethodThresholds( IRoot* lockobj ) : - PARENTLOCK( m_parameters ), - PARENTLOCK( m_debugVolumes ), - m_seed( -1.f ), - m_selectedChildIndex( -1 ), - m_selectedChildModified( false ) + PARENTLOCK( m_parameters ), + PARENTLOCK( m_debugVolumes ), + m_seed( -1.f ), + m_selectedChildIndex( -1 ), + m_selectedChildModified( false ) { - m_parameters.SetNotify( this ); + m_parameters.SetNotify( this ); } EveProceduralMethodThresholds::~EveProceduralMethodThresholds() @@ -19,126 +19,126 @@ EveProceduralMethodThresholds::~EveProceduralMethodThresholds() bool EveProceduralMethodThresholds::Initialize() { - SortParameters(); - return true; + SortParameters(); + return true; } bool EveProceduralMethodThresholds::OnModified( Be::Var* value ) { - if( IsMatch( value, m_seed ) ) - { - SelectParameter(); - } + if( IsMatch( value, m_seed ) ) + { + SelectParameter(); + } - return true; + return true; } void EveProceduralMethodThresholds::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* list ) { - if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) - { - SortParameters(); - } + if( list == &m_parameters && ( event & BELIST_LOADING ) == 0 ) + { + SortParameters(); + } } void EveProceduralMethodThresholds::SelectParameter() { - int currentChild = m_selectedChildIndex; - - int index = 0; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - if( m_seed <= ( *it )->GetThreshold() ) - { - m_selectedChildIndex = index; - break; - } - index++; - } - - if( currentChild != m_selectedChildIndex) - { - m_selectedChildModified = true; - } + int currentChild = m_selectedChildIndex; + + int index = 0; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + if( m_seed <= ( *it )->GetThreshold() ) + { + m_selectedChildIndex = index; + break; + } + index++; + } + + if( currentChild != m_selectedChildIndex ) + { + m_selectedChildModified = true; + } } // A Struct declaration to use for sorting in function SortParameters() struct SelectiveParameterCompare { - inline bool operator() (const EveProceduralMethodThresholdParameter* param1, const EveProceduralMethodThresholdParameter* param2) - { - return ( param1->GetThreshold() < param2->GetThreshold() ); - } + inline bool operator()( const EveProceduralMethodThresholdParameter* param1, const EveProceduralMethodThresholdParameter* param2 ) + { + return ( param1->GetThreshold() < param2->GetThreshold() ); + } }; void EveProceduralMethodThresholds::SortParameters() { - if(m_parameters.size() < 2 ) - { - return; - } + if( m_parameters.size() < 2 ) + { + return; + } - std::sort(begin( m_parameters ), end( m_parameters ), SelectiveParameterCompare() ); + std::sort( begin( m_parameters ), end( m_parameters ), SelectiveParameterCompare() ); } bool EveProceduralMethodThresholds::IsSelectedChildModified() const { - return m_selectedChildModified; + return m_selectedChildModified; } EveChildRefPtr EveProceduralMethodThresholds::GetSelectedChild() { - if ( m_selectedChildIndex < 0 || m_selectedChildIndex > (m_parameters.size() - 1) ) - { - return nullptr; - } - - m_selectedChildModified = false; - EveProceduralMethodThresholdParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); - - if( param != nullptr ) - { - auto child = param->GetChild(); - if( child != nullptr && strlen(child->GetResPath()) != 0 ) - { - param->Load(); - return child; - } - } - return nullptr; + if( m_selectedChildIndex < 0 || m_selectedChildIndex > ( m_parameters.size() - 1 ) ) + { + return nullptr; + } + + m_selectedChildModified = false; + EveProceduralMethodThresholdParameterPtr param = BlueCastPtr( m_parameters.GetAt( m_selectedChildIndex ) ); + + if( param != nullptr ) + { + auto child = param->GetChild(); + if( child != nullptr && strlen( child->GetResPath() ) != 0 ) + { + param->Load(); + return child; + } + } + return nullptr; } void EveProceduralMethodThresholds::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - bool reselect = false; - for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) - { - if( ( *it )->IsModified() ) - { - reselect = true; - ( *it )->SetModified( false ); - } - } - if( reselect ) - { - SortParameters(); - SelectParameter(); - } + bool reselect = false; + for( auto it = begin( m_parameters ); it != end( m_parameters ); ++it ) + { + if( ( *it )->IsModified() ) + { + reselect = true; + ( *it )->SetModified( false ); + } + } + if( reselect ) + { + SortParameters(); + SelectParameter(); + } } IEveVolumeVector* EveProceduralMethodThresholds::GetDebugVolumes() { - return &m_debugVolumes; + return &m_debugVolumes; } void EveProceduralMethodThresholds::SetProceduralMethodVariable( const char* name, float value ) { - if( strcmp( name, m_thresholdAttribute.c_str() ) == 0) - { - if( m_seed != value) - { - m_seed = value; - SelectParameter(); - } - } + if( strcmp( name, m_thresholdAttribute.c_str() ) == 0 ) + { + if( m_seed != value ) + { + m_seed = value; + SelectParameter(); + } + } } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.h index 125e8cd1f..9fd2fd338 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds.h @@ -14,45 +14,46 @@ BLUE_DECLARE_INTERFACE( IEveVolume ); BLUE_CLASS( EveProceduralMethodThresholds ) : public IEveProceduralSelectionMethod, - public INotify, - public IListNotify, - public IInitialize + public INotify, + public IListNotify, + public IInitialize { public: EXPOSE_TO_BLUE(); - EveProceduralMethodThresholds( IRoot* lockobj = NULL ); + EveProceduralMethodThresholds( IRoot* lockobj = NULL ); ~EveProceduralMethodThresholds(); - void SelectParameter(); - void SortParameters(); + void SelectParameter(); + void SortParameters(); - void SetProceduralMethodVariable( const char* name, float value ) override; + void SetProceduralMethodVariable( const char* name, float value ) override; - // IEveProceduralSelectionMethod - void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - bool IsSelectedChildModified() const override; - EveChildRefPtr GetSelectedChild() override; - IEveVolumeVector* GetDebugVolumes() override; + // IEveProceduralSelectionMethod + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; + bool IsSelectedChildModified() const override; + EveChildRefPtr GetSelectedChild() override; + IEveVolumeVector* GetDebugVolumes() override; - // IInitialize - bool Initialize() override; + // IInitialize + bool Initialize() override; - // IListNotify - void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; + // IListNotify + void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; - // INotify - bool OnModified( Be::Var* value ) override; + // INotify + bool OnModified( Be::Var * value ) override; protected: BlueSharedString m_name; - BlueSharedString m_thresholdAttribute; - float m_seed; - int m_selectedChildIndex; - PEveProceduralMethodThresholdParameterVector m_parameters; + BlueSharedString m_thresholdAttribute; + float m_seed; + int m_selectedChildIndex; + PEveProceduralMethodThresholdParameterVector m_parameters; + private: - bool m_selectedChildModified; - PIEveVolumeVector m_debugVolumes; + bool m_selectedChildModified; + PIEveVolumeVector m_debugVolumes; }; TYPEDEF_BLUECLASS( EveProceduralMethodThresholds ); \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds_Blue.cpp b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds_Blue.cpp index 9b2029275..1a5e65b7d 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/EveProceduralMethodThresholds_Blue.cpp @@ -6,23 +6,21 @@ BLUE_DEFINE( EveProceduralMethodThresholds ); const Be::ClassInfo* EveProceduralMethodThresholds::ExposeToBlue() { - EXPOSURE_BEGIN( EveProceduralMethodThresholds, "" ) - MAP_INTERFACE( EveProceduralMethodThresholds ) - MAP_INTERFACE( IEveProceduralSelectionMethod ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveProceduralMethodThresholds, "" ) + MAP_INTERFACE( EveProceduralMethodThresholds ) + MAP_INTERFACE( IEveProceduralSelectionMethod ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "a descriptive name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "thresholdAttribute", m_thresholdAttribute, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) + MAP_ATTRIBUTE( "thresholdAttribute", m_thresholdAttribute, "name of the gameplay attribute you want to use as a seed, not persisted /n", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "seed_temp", m_seed, "temp until we hook in gameplay attributes, will be read only at that point", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "selectedChild", m_selectedChildIndex, "selection result", Be::READ ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "debugVolumes", m_debugVolumes, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } - - diff --git a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/IEveProceduralSelectionMethod.h b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/IEveProceduralSelectionMethod.h index 6e4fb6ac0..32b297ffa 100644 --- a/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/IEveProceduralSelectionMethod.h +++ b/trinity/Eve/SpaceObject/Children/ProceduralContainer/SelectionMethods/IEveProceduralSelectionMethod.h @@ -6,13 +6,17 @@ #include "Eve/SpaceObject/Children/EveChildRef.h" #include "Eve/Volume/IEveVolume.h" -BLUE_INTERFACE( IEveProceduralSelectionMethod ): public IRoot +BLUE_INTERFACE( IEveProceduralSelectionMethod ) : + public IRoot { - virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; - virtual bool IsSelectedChildModified() const = 0; - virtual IEveVolumeVector* GetDebugVolumes() = 0; - virtual EveChildRefPtr GetSelectedChild() = 0; + virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) = 0; + virtual bool IsSelectedChildModified() const = 0; + virtual IEveVolumeVector* GetDebugVolumes() = 0; + virtual EveChildRefPtr GetSelectedChild() = 0; - virtual void SetProceduralMethodVariable( const char* name, float value ) {}; - virtual const char* GetProceduralMethodVariable() {return "not Implemented";}; + virtual void SetProceduralMethodVariable( const char* name, float value ) {}; + virtual const char* GetProceduralMethodVariable() + { + return "not Implemented"; + }; }; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp index 57177640b..2cba8fc94 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.cpp @@ -78,7 +78,7 @@ void EveChildSmartLightSet::UpdateSyncronous( const EveUpdateContext& updateCont { m_distribution->UpdateSyncronous( updateContext, params ); } - + for( auto it : m_lightGroups ) { it->UpdateSyncronous( updateContext, params, m_distribution ); diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h index 47afed759..a5b1b1ea2 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet.h @@ -36,11 +36,14 @@ BLUE_CLASS( EveChildSmartLightSet ) : void SetName( const char* name ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ); void GetRenderables( std::vector & renderables ); - bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const { return false; }; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const + { + return false; + }; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ) override; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void GetLocalToWorldTransform( Matrix & transform ) const; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) {}; void ChangeLOD( Tr2Lod lod ) {}; @@ -55,7 +58,7 @@ BLUE_CLASS( EveChildSmartLightSet ) : void SetInheritProperties( const Color* colorSet ); // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); // IListNotify void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ); diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp index 4a4d330c3..cddf27441 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveChildSmartLightSet_Blue.cpp @@ -18,7 +18,7 @@ const Be::ClassInfo* EveChildSmartLightSet::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "distribution", m_distribution, "distributionMethod for entities\n:jessica-icon: map-location-dot\n:jessica-help-url: https://ccpgames.atlassian.net/wiki/spaces/TTL/pages/1311441160/Distributions\n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightGroups", m_lightGroups, "list of lights and light-renderables", Be::READ | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightBaseGroup_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightBaseGroup_Blue.cpp index 3008a9b66..a9885bd53 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightBaseGroup_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightBaseGroup_Blue.cpp @@ -16,7 +16,7 @@ const Be::ClassInfo* EveSmartLightBaseGroup::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "factionColor", m_selectedColor, "Light color\n:jessica-group: ColorSettings", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) MAP_ATTRIBUTE( "customColor", m_color, "Quad color\n:jessica-tuple-type: linearcolor\n:jessica-group: ColorSettings", Be::READWRITE | Be::PERSIST ) MAP_PROPERTY_READONLY( "activeColor", GetGroupColor, "color being used\n:jessica-tuple-type: linearcolor\n:jessica-group: ColorSettings" ) - + MAP_ATTRIBUTE( "attributeModifiers", m_attributeModifiers, "list of attribute modifiers", Be::READ | Be::PERSIST ) EXPOSURE_END() diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.cpp index f5c05b49a..fe89281df 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.cpp @@ -6,7 +6,7 @@ const PlacementDataWithIdentifier s_PlacementDataWithIdentifierDefaultKey; -EveSmartLightColorShareGroup::EveSmartLightColorShareGroup( IRoot* lockobj ) : +EveSmartLightColorShareGroup::EveSmartLightColorShareGroup( IRoot* lockobj ) : PARENTLOCK( m_lightGroups ), m_display( true ) { diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.h index 0af8d602c..fe588ceb5 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightColorShareGroup.h @@ -22,8 +22,8 @@ BLUE_CLASS( EveSmartLightColorShareGroup ) : void AddQuadsToQuadRenderer( const PlacementDataWithIdentifierStructureList& placements, size_t size, const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; void GetRenderables( std::vector & renderables ) override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; void SetControllerVariable( const char* name, float value ) override; void SetInheritProperties( const Color* colorSet ) override; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; @@ -34,7 +34,7 @@ BLUE_CLASS( EveSmartLightColorShareGroup ) : void RegisterComponents() override; void UnRegisterComponents() override; // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; // IListNotify void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const struct IList* theList ) override; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh.h index 73f8223d0..15c63c163 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh.h @@ -18,10 +18,10 @@ BLUE_CLASS( EveSmartLightMesh ) : EveSmartLightMesh( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ) override {}; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ) override {}; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override {}; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override {}; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; void GetRenderables( std::vector & renderables ) override; uint32_t GetNumberOfEntities() const override; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh_Blue.cpp index 2b9e231d4..d21306294 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightMesh_Blue.cpp @@ -17,7 +17,7 @@ const Be::ClassInfo* EveSmartLightMesh::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IEveShadowCaster ) - + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST ) @@ -39,8 +39,8 @@ const Be::ClassInfo* EveSmartLightMesh::ExposeToBlue() MAP_ATTRIBUTE( "currentScreenSize", m_currentScreenSize, "", Be::READ ) MAP_ATTRIBUTE( "attributeModifiers", m_attributeModifiers, "list of attribute modifiers", Be::READ | Be::PERSIST | Be::NOTIFY ) - + MAP_METHOD_AND_WRAP( "RefreshStaticGeometry", RefreshStaticGeometry, "if static geo parameters were changed during authoring: refresh here\n:jessica-placement: TOOLBAR" ) - + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.cpp index 128c98cbe..32b85c910 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.cpp @@ -5,8 +5,8 @@ #include "Resources/Tr2LightProfileRes.h" #include "TriMath.h" -EveSmartLightPointLight::EveSmartLightPointLight( IRoot* lockobj ): - m_staticOffsetTranslation( 0.f, 0.f, 0.f), +EveSmartLightPointLight::EveSmartLightPointLight( IRoot* lockobj ) : + m_staticOffsetTranslation( 0.f, 0.f, 0.f ), m_staticOffsetRotation( 0.f, 0.f, 0.f, 1.f ), m_activationStrength( 1.f ), m_display( true ) @@ -56,7 +56,7 @@ void EveSmartLightPointLight::UpdateSyncronous( const EveUpdateContext& updateCo void EveSmartLightPointLight::RegisterComponents() { auto registry = this->GetComponentRegistry(); - if( registry ) + if( registry ) { registry->RegisterComponent( this ); } @@ -73,8 +73,9 @@ void EveSmartLightPointLight::GetLights( Tr2LightManager& lightManager ) const size_t size = m_distribution->GetNumberOfPlacements(); float scaling = XMVectorGetX( XMVectorAdd( XMVector3LengthEst( m_worldTransform.GetX() ), - XMVectorAdd( XMVector3LengthEst( m_worldTransform.GetY() ), - XMVector3LengthEst( m_worldTransform.GetZ() ) ) ) ) / 3.f; + XMVectorAdd( XMVector3LengthEst( m_worldTransform.GetY() ), + XMVector3LengthEst( m_worldTransform.GetZ() ) ) ) ) / + 3.f; int16_t profileIndex = m_lightProfile ? m_lightProfile->GetTextureIndex() + 1 : 0; Vector4 groupColor = this->GetGroupColor(); @@ -84,8 +85,8 @@ void EveSmartLightPointLight::GetLights( Tr2LightManager& lightManager ) const Vector3 lightPosition( 0.f, 0.f, 0.f ); Vector3 lightRotation( 0.f, 1.f, 0.f ); Tr2LightManager::PerLightData pointLightData; - - float perLightScaling = std::max( { placements[index].initialScale.x, placements[index].initialScale.y , placements[index].initialScale.z } ); + + float perLightScaling = std::max( { placements[index].initialScale.x, placements[index].initialScale.y, placements[index].initialScale.z } ); perLightScaling *= std::max( { placements[index].additionalScale.x, placements[index].additionalScale.y, placements[index].additionalScale.z } ); pointLightData.radius = m_lightGroupData.radius * scaling * perLightScaling; @@ -102,7 +103,7 @@ void EveSmartLightPointLight::GetLights( Tr2LightManager& lightManager ) const lightPosition += placements[index].initialTranslation + placements[index].additionalTranslation; lightPosition = Vector3( XMVector3TransformCoord( lightPosition, lightTransform ) ); pointLightData.position = lightPosition; - + rotation *= m_staticOffsetRotation; TriVectorRotateQuaternion( &lightRotation, &lightRotation, &rotation ); lightRotation *= -1.f; @@ -124,7 +125,7 @@ void EveSmartLightPointLight::GetLights( Tr2LightManager& lightManager ) const pointLightData.outerAngle = Float_16( cos( TRI_2PI * m_lightGroupData.outerAngle / 360.0f ) ); pointLightData.innerAngle = Float_16( cos( TRI_2PI * m_lightGroupData.innerAngle / 360.0f ) ); } - + lightManager.AddLight( pointLightData ); } } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.h index 88f38bb1e..0d85bb2f3 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight.h @@ -22,13 +22,13 @@ BLUE_CLASS( EveSmartLightPointLight ) : EXPOSE_TO_BLUE(); EveSmartLightPointLight( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const PlacementDataWithIdentifierStructureList& placements, size_t size ) override; void RegisterComponents() override; // ITr2LightOwner - void GetLights( Tr2LightManager& lightManager ) const override; + void GetLights( Tr2LightManager & lightManager ) const override; // INotify bool OnModified( Be::Var * value ); diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight_Blue.cpp index 2bb6accb0..aa0eac4ba 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightPointLight_Blue.cpp @@ -25,7 +25,7 @@ const Be::ClassInfo* EveSmartLightPointLight::ExposeToBlue() MAP_ATTRIBUTE( "radius", m_lightGroupData.radius, "Light radius", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "innerRadius", m_lightGroupData.innerRadius, "Inner light radius (to mimick a glowing sphere)", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "brightness", m_lightGroupData.brightness, "Light brightness (modulates color) for easier animation", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "lightProfilePath", m_lightProfilePath, "Path to IES profile\n:jessica-widget: filepath\n:jessica-file-filter: ies", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.cpp index c1cee309e..71460742c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.cpp @@ -7,7 +7,7 @@ #include "TriMath.h" -EveSmartLightQuad::EveSmartLightQuad( IRoot* lockobj ): +EveSmartLightQuad::EveSmartLightQuad( IRoot* lockobj ) : m_staticOffsetTranslation( 0.f, 0.f, 0.f ), m_display( true ), m_softQuad( false ), @@ -126,13 +126,13 @@ void EveSmartLightQuad::AddQuadsToQuadRenderer( const PlacementDataWithIdentifie float scaleZ = placements[index].initialScale.z * placements[index].additionalScale.z * m_staticQuadScale.z; quadPosition = Vector3( 0.f, 0.f, 0.f ); - Quaternion quadRotation = placements[index].initialRotation * placements[index].additionalRotation; + Quaternion quadRotation = placements[index].initialRotation * placements[index].additionalRotation; if( m_staticOffsetTranslation != quadPosition ) { TriVectorRotateQuaternion( &quadPosition, &m_staticOffsetTranslation, &quadRotation ); } - + Vector3 quadDirection( 0.f, 1.f, 0.f ); TriVectorRotateQuaternion( &quadDirection, &quadDirection, &quadRotation ); TriVectorRotateMatrix( &quadDirection, &quadDirection, &m_worldTransform ); @@ -168,5 +168,3 @@ void EveSmartLightQuad::AddQuadsToQuadRenderer( const PlacementDataWithIdentifie } } } - - diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.h index aaafd209b..a99f5118b 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightQuad.h @@ -23,8 +23,8 @@ BLUE_CLASS( EveSmartLightQuad ) : EveSmartLightQuad( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; - void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) override; void AddQuadsToQuadRenderer( const PlacementDataWithIdentifierStructureList& placements, size_t size, const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const override; void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightSpotLight_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightSpotLight_Blue.cpp index ae7407754..6838b69ac 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightSpotLight_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/EveSmartLightSpotLight_Blue.cpp @@ -12,6 +12,6 @@ const Be::ClassInfo* EveSmartLightSpotLight::ExposeToBlue() MAP_ATTRIBUTE( "innerAngle", m_lightGroupData.innerAngle, "Inner angle of the spotlight (in degrees)\n:jessica-group: SpotLightOptions", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "outerAngle", m_lightGroupData.outerAngle, "Outer angle of the spotlight (in degrees)\n:jessica-group: SpotLightOptions", Be::READWRITE | Be::PERSIST ) - + EXPOSURE_CHAINTO( EveSmartLightPointLight ) } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/IEveSmartLightGroup.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/IEveSmartLightGroup.h index 1f08ec7b8..aeae2410a 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/IEveSmartLightGroup.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/IEveSmartLightGroup.h @@ -11,12 +11,12 @@ BLUE_INTERFACE( IEveSmartLightGroup ) : public: virtual void SetColor( const Color& color ) {}; virtual void AddQuadsToQuadRenderer( const PlacementDataWithIdentifierStructureList& placements, size_t size, const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) const {}; - virtual void GetRenderables( std::vector & renderables ) {}; - virtual void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ){}; - virtual void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ){}; - virtual void SetControllerVariable( const char* name, float value ){}; - virtual void SetInheritProperties( const Color* colorSet ){}; + virtual void GetRenderables( std::vector & renderables ){}; + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) {}; + virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionMethod* distribution ) {}; + virtual void SetControllerVariable( const char* name, float value ) {}; + virtual void SetInheritProperties( const Color* colorSet ) {}; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) {}; virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ){}; - virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const PlacementDataWithIdentifierStructureList& placements, size_t size){}; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const PlacementDataWithIdentifierStructureList& placements, size_t size ) {}; }; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.cpp index ddf2278cb..cd12d043c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "EveSmartLightAttributeModifierBucket.h" -EveSmartLightAttributeModifierBucket::EveSmartLightAttributeModifierBucket( IRoot* lockobj ): +EveSmartLightAttributeModifierBucket::EveSmartLightAttributeModifierBucket( IRoot* lockobj ) : PARENTLOCK( m_attributeModifiers ), m_name( "bucket" ) { @@ -58,11 +58,10 @@ void EveSmartLightAttributeModifierBucket::ResetChildren( bool parentActive ) { for( auto attributeModifier : m_attributeModifiers ) { - if( EveSmartLightBaseAttributeModifierPtr attributeModPtr = BlueCastPtr( attributeModifier ) ) + if( EveSmartLightBaseAttributeModifierPtr attributeModPtr = BlueCastPtr( attributeModifier ) ) { bool isActive = parentActive && m_active; attributeModPtr->ResetPlayTime( isActive ); } } } - diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.h index 7f0a8310f..c6cb98965 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket.h @@ -18,7 +18,7 @@ BLUE_CLASS( EveSmartLightAttributeModifierBucket ) : EveSmartLightAttributeModifierBucket( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, float activationMultiplier ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, float activationMultiplier ) override; void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) override; void ResetPlayTime( bool active ) override; void SetActive( bool isActive ); diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket_Blue.cpp index 115194bca..de2636d94 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierBucket_Blue.cpp @@ -23,7 +23,8 @@ const Be::ClassInfo* EveSmartLightAttributeModifierBucket::ExposeToBlue() MAP_ATTRIBUTE( "startsActive", m_startsActive, "should it be active on load (if false but active=true, then it will animate into active state)\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "crossFadeDuration", m_crossFadeDuration, "how many sec does the blending animation take\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.0,20.0)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "crossFadeIntensity", m_crossFadeIntensity, "is the animation linear or frontEnd/backend focused. (1=linear, closer to 0 comes in fast, above 1 -> ease in slowly)" - "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ) + "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "activationValue", m_activationValue, "[0:1] to visualize/debug the crossfade\n:jessica-group: AttributeModifierBlending", Be::READ ) MAP_ATTRIBUTE( "finalAttributeMultiplier", m_finalActivationStrength, "to visualize/debug compound activationStrength\n:jessica-group: AttributeModifierBlending", Be::READ ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.cpp index 29440fee4..687ca0f82 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.cpp @@ -12,7 +12,7 @@ EveSmartLightAttributeModifierCameraDependency::EveSmartLightAttributeModifierCa m_useCameraDistance( false ), m_inverseDistanceFormula( false ), m_minimumDistance( 1000.f ), - m_maximumDistance( 10000.f), + m_maximumDistance( 10000.f ), m_useCameraLookAt( false ), m_inverselookAtFormula( false ), m_lookAtIntencity( 1.f ), @@ -20,7 +20,7 @@ EveSmartLightAttributeModifierCameraDependency::EveSmartLightAttributeModifierCa m_useCameraPlacement( false ), m_inversePlacementFormula( false ), m_placementIntencity( 1.f ), - m_overwritePosition( false ), + m_overwritePosition( false ), m_overwriteDirection( false ), m_positionOverwrite( 0.f, 0.f, 0.f ), m_angleOverwrite( 0.f, 0.f, 0.f ) @@ -75,7 +75,7 @@ const float EveSmartLightAttributeModifierCameraDependency::GetPlacementAmplitud { if( m_useCameraPlacement ) { - Vector3 eDir = m_overwriteDirection ? Normalize(m_angleOverwrite) : entityDirection; + Vector3 eDir = m_overwriteDirection ? Normalize( m_angleOverwrite ) : entityDirection; float placementAmplitude = max( 0.f, -Dot( Normalize( vec2obj ), eDir ) ); if( m_placementIntencity != 1.f ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.h index cebc91d89..b35514f74 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency.h @@ -15,14 +15,14 @@ BLUE_CLASS( EveSmartLightAttributeModifierCameraDependency ) : EveSmartLightAttributeModifierCameraDependency( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, float activationMultiplier ); + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, float activationMultiplier ); void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) override; private: const float GetActivationValue( const Vector3& objectPosition, const Vector3& entityDirection ); const float GetDistanceAmplitude( const Vector3& vec2Obj ); const float GetLookAtAmplitude( const Vector3& vec2obj ); - const float GetPlacementAmplitude( const Vector3& vec2Obj, const Vector3& entityDirection ); + const float GetPlacementAmplitude( const Vector3& vec2Obj, const Vector3& entityDirection ); bool m_useCameraDistance; bool m_inverseDistanceFormula; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency_Blue.cpp index 5b3103be8..7510c89a3 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierCameraDependency_Blue.cpp @@ -22,16 +22,16 @@ const Be::ClassInfo* EveSmartLightAttributeModifierCameraDependency::ExposeToBlu MAP_ATTRIBUTE( "inverseDistanceFormula", m_inverseDistanceFormula, "if you want to increase the strength on moving further away instead\n:jessica-group: CameraDistance", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "minimumDistance", m_minimumDistance, "at what distance to start changing intensity\n:jessica-group: CameraDistance", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "maximumDistance", m_maximumDistance, "at what distance to stop changing intensity\n:jessica-group: CameraDistance", Be::READWRITE | Be::PERSIST ); - + MAP_ATTRIBUTE( "useCameraLookAt", m_useCameraLookAt, "if you want to change intencity based on if you are looking at the object\n:jessica-group: CameraLookAt", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "inverselookAtFormula", m_inverselookAtFormula, "if want intencity to be at full strength when NOT looking at your object\n:jessica-group: CameraLookAt", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "lookAtIntensity", m_lookAtIntencity, "to have the falloff be non-linear over range (fast or slow from center)\n:jessica-group: CameraLookAt\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "lookAtVisionCone", m_lookAtVisionCone, "degree range at which we modify attributeStrength \n:jessica-group: CameraLookAt\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ); - + MAP_ATTRIBUTE( "useCameraPlacement", m_useCameraPlacement, "increase activation strength when you are in front of the object\n:jessica-group: cameraPlacement", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "inversePlacementFormula", m_inversePlacementFormula, "increase activation strength when you are NOT in front of the object\n:jessica-group: cameraPlacement", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "placementIntensity", m_placementIntencity, "to have the falloff be non-linear\n:jessica-group: cameraPlacement\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ); - + MAP_ATTRIBUTE( "attributeMultiplier", m_activationStrength, "scale modifier effect\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "finalAttributeMultiplier", m_finalActivationStrength, "to visualize/debug compound activationStrength\n:jessica-group: AttributeModifierBlending", Be::READ ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.cpp index ab03b06f1..282913489 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.cpp @@ -4,7 +4,7 @@ #include "EveSmartLightAttributeModifierColor.h" #include "Eve/SpaceObjectFactory/EveSOFData.h" -EveSmartLightAttributeModifierColor::EveSmartLightAttributeModifierColor( IRoot* lockobj ): +EveSmartLightAttributeModifierColor::EveSmartLightAttributeModifierColor( IRoot* lockobj ) : m_saturationMultiplier( 1.f ), m_brightnessMultiplier( 1.f ), m_blendValue( 1.f ), @@ -61,7 +61,7 @@ void EveSmartLightAttributeModifierColor::ProcessAttributeModifier( Vector3& att float i = ( activeColor.r * 0.299f ) + ( activeColor.g * 0.587f ) + ( activeColor.b * 0.114f ); activeColor = Lerp( Color( i, i, i, i ), activeColor, max( 0.0f, activationAdjustedSaturationMultiplier ) ); } - + activeColor *= activationAdjustedBrightnessMultiplier; attribute.x = min( 1.f, max( 0.f, activeColor.r ) ); attribute.y = min( 1.f, max( 0.f, activeColor.g ) ); diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.h index 8a7bf9be3..193a3b9be 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierColor.h @@ -16,10 +16,10 @@ BLUE_CLASS( EveSmartLightAttributeModifierColor ) : EveSmartLightAttributeModifierColor( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, float activationMultiplier ); + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, float activationMultiplier ); void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) override; void SetInheritProperties( const Color* colorSet ) override; - + private: Color GetGroupColor() const; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierControllerVariableListener_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierControllerVariableListener_Blue.cpp index 8d326850d..aa6a4f33a 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierControllerVariableListener_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierControllerVariableListener_Blue.cpp @@ -17,7 +17,7 @@ const Be::ClassInfo* EveSmartLightAttributeModifierControllerVariableListener::E MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "attributeModifiers", m_attributeModifiers, "list of attribute modifiers", Be::READ | Be::PERSIST | Be::NOTIFY ) - + MAP_ATTRIBUTE( "name", m_name, "organize your tree", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "variableName", m_variableName, "activate and deactivate bucket based on this variable", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "value", m_value, "editable for authoring but triggered automatically from controller states", Be::READWRITE | Be::PERSIST | Be::NOTIFY ); @@ -28,7 +28,8 @@ const Be::ClassInfo* EveSmartLightAttributeModifierControllerVariableListener::E MAP_ATTRIBUTE( "active", m_active, "triggered by controller events\n:jessica-group: AttributeModifierBlending", Be::READ ) MAP_ATTRIBUTE( "crossFadeDuration", m_crossFadeDuration, "how many sec does the blending animation take\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.0,20.0)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "crossFadeIntensity", m_crossFadeIntensity, "is the animation linear or frontEnd/backend focused. (1=linear, closer to 0 comes in fast, above 1 -> ease in slowly)" - "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ) + "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "activationValue", m_activationValue, "[0:1] to visualize/debug the crossfade\n:jessica-group: AttributeModifierBlending", Be::READ ) MAP_ATTRIBUTE( "finalAttributeMultiplier", m_finalActivationStrength, "to visualize/debug compound activationStrength\n:jessica-group: AttributeModifierBlending", Be::READ ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.cpp index 78208ae39..a58b2dd31 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.cpp @@ -82,7 +82,7 @@ CcpParser::Constant s_constants[] = { }; } -EveSmartLightAttributeModifierExpressionBucket::EveSmartLightAttributeModifierExpressionBucket( IRoot* lockobj ) : +EveSmartLightAttributeModifierExpressionBucket::EveSmartLightAttributeModifierExpressionBucket( IRoot* lockobj ) : PARENTLOCK( m_inputs ), m_randomConstant( float( rand() ) / RAND_MAX ) { @@ -91,7 +91,7 @@ EveSmartLightAttributeModifierExpressionBucket::EveSmartLightAttributeModifierEx } bool EveSmartLightAttributeModifierExpressionBucket::Initialize() -{ +{ EveSmartLightAttributeModifierBucket::Initialize(); if( !m_expression.empty() ) { diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.h index 1bd339fd4..77a3a93aa 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket.h @@ -35,8 +35,8 @@ BLUE_CLASS( EveSmartLightAttributeModifierExpressionBucket ) : std::vector GetExpressionTermInfo() const; BlueStdResult EvaluateExpression( const char* expression, float& value ) const; -private: +private: std::string m_name; std::string m_expression; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket_Blue.cpp index 899e9c698..6b478e763 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierExpressionBucket_Blue.cpp @@ -14,10 +14,10 @@ const Be::ClassInfo* EveSmartLightAttributeModifierExpressionBucket::ExposeToBlu MAP_INTERFACE( IEveSmartLightGroupAttributeModifier ) MAP_INTERFACE( EveSmartLightBaseAttributeModifier ) MAP_INTERFACE( IInitialize ) - + MAP_ATTRIBUTE( "name", m_name, "organize your tree", Be::READWRITE | Be::PERSIST ); - MAP_ATTRIBUTE( "expression", m_expression, "Curve expression\n:jessica-widget: expression", Be::PERSISTONLY ) + MAP_ATTRIBUTE( "expression", m_expression, "Curve expression\n:jessica-widget: expression", Be::PERSISTONLY ) MAP_PROPERTY( "expression", GetExpression, SetExpression, "Curve expression\n:jessica-widget: expression" ) MAP_ATTRIBUTE( "currentValue", m_activationStrength, "Value after the last update", Be::READ ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.cpp index c0de0aaca..4ac3b120e 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.cpp @@ -4,7 +4,7 @@ #include "EveSmartLightAttributeModifierNoise.h" #include "TriMath.h" -EveSmartLightAttributeModifierNoise::EveSmartLightAttributeModifierNoise( IRoot* lockobj ): +EveSmartLightAttributeModifierNoise::EveSmartLightAttributeModifierNoise( IRoot* lockobj ) : m_noiseAmplitude( 0.f ), m_noiseFrequency( 1.f ), m_noiseOctaves( 1 ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.h index 5b5f7a12f..c92e7851c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightAttributeModifierNoise.h @@ -15,7 +15,7 @@ BLUE_CLASS( EveSmartLightAttributeModifierNoise ) : EveSmartLightAttributeModifierNoise( IRoot* lockobj = nullptr ); - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, float activationMultiplier ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, float activationMultiplier ) override; void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) override; private: diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.cpp index 11ef68d8f..4cf28323c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.cpp @@ -4,14 +4,14 @@ #include "EveSmartLightBaseAttributeModifier.h" #include "include/TriMath.h" -EveSmartLightBaseAttributeModifier::EveSmartLightBaseAttributeModifier( IRoot* lockobj ): - m_activationStrength( 1.f), +EveSmartLightBaseAttributeModifier::EveSmartLightBaseAttributeModifier( IRoot* lockobj ) : + m_activationStrength( 1.f ), m_active( true ), m_startsActive( true ), m_isChangingActivation( false ), m_crossFadeDuration( 1.f ), m_crossFadeIntensity( 1.f ), - m_activationValuePreMapped( 1.f), + m_activationValuePreMapped( 1.f ), m_activationValue( 1.f ), m_finalActivationStrength( 1.f ), m_perInstanceOffset( 0.f ), @@ -34,7 +34,7 @@ bool EveSmartLightBaseAttributeModifier::Initialize() bool EveSmartLightBaseAttributeModifier::OnModified( Be::Var* value ) { - if( IsMatch(value, m_active) ) + if( IsMatch( value, m_active ) ) { m_isChangingActivation = true; if( m_crossFadeIntensity > 0.f ) @@ -127,10 +127,10 @@ void EveSmartLightBaseAttributeModifier::UpdateActivationStrength( float parentA float EveSmartLightBaseAttributeModifier::GetActivationStrength( const PlacementDataWithIdentifier& placement ) { float activationMultiplier = 1.f; - + if( m_activationOverLifetime ) { - float idOffset = float(placement.initialPlacementID) * m_perInstanceOffset; + float idOffset = float( placement.initialPlacementID ) * m_perInstanceOffset; switch( m_lifeTimeFormula ) { case PER_INSTANCE_LIFETIME: @@ -142,10 +142,10 @@ float EveSmartLightBaseAttributeModifier::GetActivationStrength( const Placement case STATIC: activationMultiplier = m_activationOverLifetime->GetValueAt( double( idOffset ) ); break; - default: + default: break; } } - + return m_finalActivationStrength * activationMultiplier; } diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h index cba73a015..34f63f71e 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier.h @@ -38,7 +38,7 @@ BLUE_CLASS( EveSmartLightBaseAttributeModifier ) : protected: float GetActivationStrength( const PlacementDataWithIdentifier& placement ); void MapActivationValue(); - virtual void ResetChildren( bool parentActive ){}; + virtual void ResetChildren( bool parentActive ) {}; std::string m_name; Tr2CurveScalarPtr m_activationOverLifetime; @@ -52,7 +52,7 @@ BLUE_CLASS( EveSmartLightBaseAttributeModifier ) : float m_finalActivationStrength; float m_activationStrength; float m_crossFadeDuration; - float m_crossFadeIntensity; + float m_crossFadeIntensity; float m_activationValue; float m_activationValuePreMapped; float m_playTime; diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier_Blue.cpp b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier_Blue.cpp index bca29ac10..fdb170e12 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/EveSmartLightBaseAttributeModifier_Blue.cpp @@ -22,7 +22,7 @@ const Be::ClassInfo* EveSmartLightBaseAttributeModifier::ExposeToBlue() MAP_INTERFACE( EveSmartLightBaseAttributeModifier ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - + MAP_ATTRIBUTE( "attributeMultiplier", m_activationStrength, "scale modifier effect\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "active", m_active, "turn the attribute modifier on/off\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -31,12 +31,13 @@ const Be::ClassInfo* EveSmartLightBaseAttributeModifier::ExposeToBlue() MAP_ATTRIBUTE( "perInstanceOffset", m_perInstanceOffset, "offest based on id*this on the lifeTime curve\n:jessica-group: LifeTimeValueSettings", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "restartPlayTimeWhenInactive", m_restartPlayTimeWhenInactive, "to be able to trigger playTime start sequences multiple times \n:jessica-group: LifeTimeValueSettings", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "playTime", m_playTime, "for how long modifier has been running \n:jessica-group: LifeTimeValueSettings", Be::READ ) - + MAP_ATTRIBUTE( "startsActive", m_startsActive, "should it be active on load (if false but active=true, then it will animate into active state)\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "delayedActivation", m_delayedActivation, "when triggered, should we wait before activating?\n:jessica-group: AttributeModifierBlending", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "crossFadeDuration", m_crossFadeDuration, "how many sec does the blending animation take\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.0,20.0)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "crossFadeIntensity", m_crossFadeIntensity, "is the animation linear or frontEnd/backend focused. (1=linear, closer to 0 comes in fast, above 1 -> ease in slowly)" - "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", Be::READWRITE | Be::PERSIST ) + "\n:jessica-group: AttributeModifierBlending\n:jessica-numeric-range: (0.1,10.0)", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "activationValue", m_activationValue, "[0:1] to visualize/debug the crossfade\n:jessica-group: AttributeModifierBlending", Be::READ ) MAP_ATTRIBUTE( "finalAttributeMultiplier", m_finalActivationStrength, "to visualize/debug compound multiplier *affected by parent-strength(\n:jessica-group: AttributeModifierBlending", Be::READ ) diff --git a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/IEveSmartLightGroupAttributeModifier.h b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/IEveSmartLightGroupAttributeModifier.h index 5ea081c9e..0ac67530c 100644 --- a/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/IEveSmartLightGroupAttributeModifier.h +++ b/trinity/Eve/SpaceObject/Children/SmartLightSets/attributeModifiers/IEveSmartLightGroupAttributeModifier.h @@ -9,11 +9,9 @@ BLUE_INTERFACE( IEveSmartLightGroupAttributeModifier ) : public IRoot { public: - virtual void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, float activationMultiplier ) = 0; - virtual void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) = 0; + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, float activationMultiplier ) = 0; + virtual void ProcessAttributeModifier( Vector3 & attribute, const PlacementDataWithIdentifier& placement, const Vector3& entityPosition, const Vector3& entityDirection, float modifierStrength ) = 0; virtual void SetControllerVariable( const char* name, float value ) {}; - virtual void SetInheritProperties( const Color* colorSet ){}; + virtual void SetInheritProperties( const Color* colorSet ) {}; }; - - diff --git a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.cpp b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.cpp index 6c76e9216..e440a35fa 100644 --- a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.cpp +++ b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.cpp @@ -28,7 +28,7 @@ void EveSocketParameterBindingBase::ClearBindings() bool EveSocketParameterBindingBase::BindToExternalParameter( Tr2ExternalParameter& externalParameter ) { - if ( !externalParameter.IsValid() || externalParameter.GetName() != m_name ) + if( !externalParameter.IsValid() || externalParameter.GetName() != m_name ) { return false; } @@ -37,12 +37,12 @@ bool EveSocketParameterBindingBase::BindToExternalParameter( Tr2ExternalParamete // the value attribute of any derived class should be exposed in blue as "value" to make this work... binding->SetSource( "value", this ); binding->Initialize(); - if ( !binding->IsValid() ) + if( !binding->IsValid() ) { return false; } - - if ( !ExtractDefault( externalParameter ) ) + + if( !ExtractDefault( externalParameter ) ) { return false; } @@ -58,7 +58,7 @@ bool EveSocketParameterBindingBase::Used() const void EveSocketParameterBindingBase::Propagate() { - for ( auto it = begin( m_bindings ); it != end( m_bindings ); ++it ) + for( auto it = begin( m_bindings ); it != end( m_bindings ); ++it ) { ( *it )->CopyValue(); } @@ -194,7 +194,7 @@ bool GetExternalParameterValue( Vector2& value, const Tr2ExternalParameter& exte } switch( entry->mType ) { - case Be::FLOATARRAY: + case Be::FLOATARRAY: if( entry->GetFloatArraySize() == 2 ) { auto v = reinterpret_cast( src ); @@ -351,54 +351,54 @@ bool GetExternalParameterValue( Color& value, const Tr2ExternalParameter& extern } -#define SOCKET_PARAMETER_DEFINE( _className, _valueType, _defaultValue )\ - _className::_className( IRoot* lockobj ) :\ - EveSocketParameterBindingBase( lockobj ),\ - m_defaults( ),\ - m_value( _defaultValue )\ - {\ - }\ - _className::~_className()\ - {\ - }\ - void _className::ClearBindings()\ - {\ - m_defaults.clear();\ - EveSocketParameterBindingBase::ClearBindings();\ - }\ - void _className::Reset()\ - {\ - for ( size_t i = 0; i < m_bindings.size(); ++i )\ - {\ - m_value = m_defaults[i];\ - m_bindings[i]->CopyValue();\ - }\ - ClearBindings();\ - }\ - bool _className::ExtractDefault( const Tr2ExternalParameter& externalParameter )\ - {\ - _valueType value;\ - if( GetExternalParameterValue( value, externalParameter ) )\ - {\ - m_defaults.push_back( value );\ - }\ - else\ - {\ - m_defaults.push_back( _defaultValue );\ - }\ - return true;\ - }\ - void _className::SetValueToDefault()\ - {\ - if (!m_defaults.empty())\ - {\ - m_value = m_defaults[0];\ - }\ - else\ - {\ - m_value = _defaultValue;\ - }\ - }\ +#define SOCKET_PARAMETER_DEFINE( _className, _valueType, _defaultValue ) \ + _className::_className( IRoot* lockobj ) : \ + EveSocketParameterBindingBase( lockobj ), \ + m_defaults(), \ + m_value( _defaultValue ) \ + { \ + } \ + _className::~_className() \ + { \ + } \ + void _className::ClearBindings() \ + { \ + m_defaults.clear(); \ + EveSocketParameterBindingBase::ClearBindings(); \ + } \ + void _className::Reset() \ + { \ + for( size_t i = 0; i < m_bindings.size(); ++i ) \ + { \ + m_value = m_defaults[i]; \ + m_bindings[i]->CopyValue(); \ + } \ + ClearBindings(); \ + } \ + bool _className::ExtractDefault( const Tr2ExternalParameter& externalParameter ) \ + { \ + _valueType value; \ + if( GetExternalParameterValue( value, externalParameter ) ) \ + { \ + m_defaults.push_back( value ); \ + } \ + else \ + { \ + m_defaults.push_back( _defaultValue ); \ + } \ + return true; \ + } \ + void _className::SetValueToDefault() \ + { \ + if( !m_defaults.empty() ) \ + { \ + m_value = m_defaults[0]; \ + } \ + else \ + { \ + m_value = _defaultValue; \ + } \ + } SOCKET_PARAMETER_DEFINE( EveSocketParameterBool, bool, false ); SOCKET_PARAMETER_DEFINE( EveSocketParameterInt, int, 0 ); @@ -410,8 +410,8 @@ SOCKET_PARAMETER_DEFINE( EveSocketParameterColor, Color, Color( 0, 0, 0, 0 ) ); EveSocketParameterString::EveSocketParameterString( IRoot* lockobj ) : PARENTLOCK( m_externalParameters ), - m_name(""), - m_value(""), + m_name( "" ), + m_value( "" ), m_valueExposure(), m_defaults() { @@ -423,7 +423,7 @@ EveSocketParameterString::~EveSocketParameterString() bool EveSocketParameterString::Initialize() { - if ( !m_valueExposure ) + if( !m_valueExposure ) { m_valueExposure.CreateInstance(); m_valueExposure->SetName( "valueExposure" ); @@ -442,12 +442,12 @@ void EveSocketParameterString::ClearBindings() bool EveSocketParameterString::BindToExternalParameter( Tr2ExternalParameter& externalParameter ) { Initialize(); - if ( !externalParameter.IsValid() || externalParameter.GetName() != m_name ) + if( !externalParameter.IsValid() || externalParameter.GetName() != m_name ) { return false; } - if ( !ExtractDefault( externalParameter ) ) + if( !ExtractDefault( externalParameter ) ) { return false; } @@ -458,23 +458,23 @@ bool EveSocketParameterString::BindToExternalParameter( Tr2ExternalParameter& ex bool EveSocketParameterString::ExtractDefault( const Tr2ExternalParameter& externalParameter ) { - std::string value; - BlueScriptValue blueValue; - externalParameter.GetValue( blueValue ); - if ( BlueExtractArgument( blueValue, value, 0 ) ) + std::string value; + BlueScriptValue blueValue; + externalParameter.GetValue( blueValue ); + if( BlueExtractArgument( blueValue, value, 0 ) ) { - m_defaults.push_back( value ); + m_defaults.push_back( value ); } else { - m_defaults.push_back( "" ); + m_defaults.push_back( "" ); } - return true; + return true; } void EveSocketParameterString::SetValueToDefault() { - if (!m_defaults.empty()) + if( !m_defaults.empty() ) { m_value = m_defaults[0]; } @@ -487,11 +487,11 @@ bool EveSocketParameterString::Used() const void EveSocketParameterString::Propagate() { - if ( m_valueExposure && m_valueExposure->IsValid() ) + if( m_valueExposure && m_valueExposure->IsValid() ) { BlueScriptValue v; m_valueExposure->GetValue( v ); - for ( auto it = begin( m_externalParameters ); it != end( m_externalParameters ); ++it ) + for( auto it = begin( m_externalParameters ); it != end( m_externalParameters ); ++it ) { ( *it )->SetValue( v ); } diff --git a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.h b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.h index b209064a3..60303c1d2 100644 --- a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.h +++ b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter.h @@ -21,11 +21,17 @@ BLUE_CLASS( EveSocketParameterBindingBase ) : EveSocketParameterBindingBase( IRoot* lockobj = nullptr ); ~EveSocketParameterBindingBase(); - virtual const char* GetName() const { return m_name.c_str(); } - virtual void SetName( const char* name ) { m_name = name; } + virtual const char* GetName() const + { + return m_name.c_str(); + } + virtual void SetName( const char* name ) + { + m_name = name; + } virtual void ClearBindings(); - virtual bool BindToExternalParameter( Tr2ExternalParameter& externalParameter ); + virtual bool BindToExternalParameter( Tr2ExternalParameter & externalParameter ); bool Used() const; virtual void Propagate(); @@ -40,23 +46,25 @@ BLUE_CLASS( EveSocketParameterBindingBase ) : TYPEDEF_BLUECLASS( EveSocketParameterBindingBase ); -#define SOCKET_PARAM_DECLARE( _className, _valueType )\ - BLUE_CLASS( _className ) :\ - public EveSocketParameterBindingBase\ - {\ - public:\ - EXPOSE_TO_BLUE();\ - _className( IRoot* lockobj = nullptr );\ - ~_className();\ - virtual void ClearBindings();\ - virtual void Reset();\ - virtual void SetValueToDefault();\ - protected:\ - virtual bool ExtractDefault( const Tr2ExternalParameter& externalParameter );\ - private:\ - _valueType m_value;\ - std::vector<_valueType> m_defaults;\ - };\ +#define SOCKET_PARAM_DECLARE( _className, _valueType ) \ + BLUE_CLASS( _className ) : \ + public EveSocketParameterBindingBase \ + { \ + public: \ + EXPOSE_TO_BLUE(); \ + _className( IRoot* lockobj = nullptr ); \ + ~_className(); \ + virtual void ClearBindings(); \ + virtual void Reset(); \ + virtual void SetValueToDefault(); \ + \ + protected: \ + virtual bool ExtractDefault( const Tr2ExternalParameter& externalParameter ); \ + \ + private: \ + _valueType m_value; \ + std::vector<_valueType> m_defaults; \ + }; \ TYPEDEF_BLUECLASS( _className ); SOCKET_PARAM_DECLARE( EveSocketParameterBool, bool ); @@ -79,11 +87,17 @@ BLUE_CLASS( EveSocketParameterString ) : bool Initialize(); - const char* GetName() const { return m_name.c_str(); } - void SetName( const char* name ) { m_name = name; } + const char* GetName() const + { + return m_name.c_str(); + } + void SetName( const char* name ) + { + m_name = name; + } void ClearBindings(); - bool BindToExternalParameter( Tr2ExternalParameter& externalParameter ); + bool BindToExternalParameter( Tr2ExternalParameter & externalParameter ); void SetValueToDefault(); bool Used() const; diff --git a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter_Blue.cpp b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter_Blue.cpp index 085a96f22..4f8075c55 100644 --- a/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/SocketParameters/EveSocketParameter_Blue.cpp @@ -8,28 +8,26 @@ BLUE_DEFINE_INTERFACE( IEveSocketParameter ); BLUE_DEFINE_ABSTRACT( EveSocketParameterBindingBase ); -const Be::ClassInfo* EveSocketParameterBindingBase::ExposeToBlue() -{ +const Be::ClassInfo* EveSocketParameterBindingBase::ExposeToBlue(){ EXPOSURE_BEGIN( EveSocketParameterBindingBase, "" ) - EXPOSURE_END() + EXPOSURE_END() } -#define SOCKET_PARAM_EXPOSE_TO_BLUE( _className, _valueDescription )\ - BLUE_DEFINE( _className );\ - const Be::ClassInfo* _className::ExposeToBlue()\ - {\ - EXPOSURE_BEGIN( _className, "\n:jessica-icon: fal-paragraph\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" )\ - MAP_INTERFACE( IEveSocketParameter )\ - MAP_ATTRIBUTE( "name", m_name, "Attribute name.", Be::READWRITE | Be::PERSIST )\ - MAP_ATTRIBUTE( "value", m_value, _valueDescription, Be::READWRITE | Be::PERSIST )\ - MAP_METHOD_AND_WRAP( "Used", Used, "")\ - MAP_METHOD_AND_WRAP(\ - "SetValueToDefault",\ - SetValueToDefault,\ - "Reset the value to the default value (whatever the first external parameter bound to is in the original plug."\ - ":jessica-placement:\n"\ - )\ - EXPOSURE_END()\ +#define SOCKET_PARAM_EXPOSE_TO_BLUE( _className, _valueDescription ) \ + BLUE_DEFINE( _className ); \ + const Be::ClassInfo* _className::ExposeToBlue() \ + { \ + EXPOSURE_BEGIN( _className, "\n:jessica-icon: fal-paragraph\n:jessica-icon-color: (123, 28, 212)\n:jessica-help-url: https://wiki.ccpgames.com/pages/viewpage.action?spaceKey=TTL&title=Plugs+and+Sockets \n" ) \ + MAP_INTERFACE( IEveSocketParameter ) \ + MAP_ATTRIBUTE( "name", m_name, "Attribute name.", Be::READWRITE | Be::PERSIST ) \ + MAP_ATTRIBUTE( "value", m_value, _valueDescription, Be::READWRITE | Be::PERSIST ) \ + MAP_METHOD_AND_WRAP( "Used", Used, "" ) \ + MAP_METHOD_AND_WRAP( \ + "SetValueToDefault", \ + SetValueToDefault, \ + "Reset the value to the default value (whatever the first external parameter bound to is in the original plug." \ + ":jessica-placement:\n" ) \ + EXPOSURE_END() \ } SOCKET_PARAM_EXPOSE_TO_BLUE( EveSocketParameterBool, "Attribute value.\n:jessica-widget: checkbox\n" ); diff --git a/trinity/Eve/SpaceObject/Children/SocketParameters/IEveSocketParameter.h b/trinity/Eve/SpaceObject/Children/SocketParameters/IEveSocketParameter.h index c7656979a..8b27e5d6f 100644 --- a/trinity/Eve/SpaceObject/Children/SocketParameters/IEveSocketParameter.h +++ b/trinity/Eve/SpaceObject/Children/SocketParameters/IEveSocketParameter.h @@ -6,19 +6,31 @@ BLUE_DECLARE( Tr2ExternalParameter ); -BLUE_INTERFACE( IEveSocketParameter ) : +BLUE_INTERFACE( IEveSocketParameter ) : public IInitialize { - virtual const char* GetName() const { return ""; }; + virtual const char* GetName() const + { + return ""; + }; virtual void SetName( const char* name ) {}; - virtual bool Initialize() { return true; }; + virtual bool Initialize() + { + return true; + }; virtual void ClearBindings() {}; - virtual bool BindToExternalParameter( Tr2ExternalParameter& externalParameter ) { return true; }; + virtual bool BindToExternalParameter( Tr2ExternalParameter & externalParameter ) + { + return true; + }; virtual void Reset() {}; virtual void SetValueToDefault() {}; - virtual bool Used() const { return true; } + virtual bool Used() const + { + return true; + } virtual void Propagate() {}; }; diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.cpp index 8d09a8dd8..ba4b1bf5a 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.cpp @@ -5,8 +5,8 @@ #include "Utilities/MatrixUtils.h" -EveChildModifierAttachToBone::EveChildModifierAttachToBone( IRoot* ) - :m_boneIndex( -1 ) +EveChildModifierAttachToBone::EveChildModifierAttachToBone( IRoot* ) : + m_boneIndex( -1 ) { } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.h index 8145967df..b7e87d4d7 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierAttachToBone.h @@ -15,6 +15,7 @@ BLUE_CLASS( EveChildModifierAttachToBone ) : Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const; void SetBoneIndex( int32_t index ); + private: int32_t m_boneIndex; }; diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.cpp index bac578906..464593b45 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.cpp @@ -5,7 +5,7 @@ #include "Tr2Renderer.h" #include "EveChildModifierTransformCommon.h" -EveChildModifierBillboard3D::EveChildModifierBillboard3D( IRoot* lockobj ): +EveChildModifierBillboard3D::EveChildModifierBillboard3D( IRoot* lockobj ) : m_fixed( false ) { } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.h index 02cc2bfeb..58eb2fe39 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBillboard3D.h @@ -16,6 +16,7 @@ BLUE_CLASS( EveChildModifierBillboard3D ) : ~EveChildModifierBillboard3D(); Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const; + private: bool m_fixed; }; diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBooster.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBooster.cpp index 1d5a72a3e..99f2266f2 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBooster.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierBooster.cpp @@ -21,9 +21,9 @@ Matrix EveChildModifierBooster::ApplyTransform( const Matrix& transform, size_t, DistanceBase( transform, alignMat, distCenter, d ); float radius = 0.5f; - float B = sqrtf( distCenter*distCenter - radius*radius ); + float B = sqrtf( distCenter * distCenter - radius * radius ); float scale = B / distCenter; - float trans = -radius*radius / (distCenter*scale); + float trans = -radius * radius / ( distCenter * scale ); Matrix scalingTransform = ScalingMatrix( scale, scale, scale ); Matrix translationTransform = TranslationMatrix( 0.0f, 0.0f, trans ); diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHalo.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHalo.cpp index 182cb78c3..78b9a4838 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHalo.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHalo.cpp @@ -28,15 +28,14 @@ Matrix EveChildModifierHalo::ApplyTransform( const Matrix& transform, size_t, co float scale = Dot( Normalize( d ), - Normalize( *TriVectorRotatedBasisMatrix( &backward, TRITA_Z, &transform ) ) - ); + Normalize( *TriVectorRotatedBasisMatrix( &backward, TRITA_Z, &transform ) ) ); - if (scale < 0.0f) + if( scale < 0.0f ) { scale = 0.0f; } - finalScale *= scale*scale; + finalScale *= scale * scale; const Matrix& invView = Tr2Renderer::GetInverseViewTransform(); diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHaloInverted.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHaloInverted.cpp index d069f0f46..88281b103 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHaloInverted.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierHaloInverted.cpp @@ -27,7 +27,7 @@ Matrix EveChildModifierHaloInverted::ApplyTransform( const Matrix& transform, si Vector3 backward = -forward; float scale = Dot( Normalize( d ), backward ); - if (scale < 0.0f) + if( scale < 0.0f ) { scale = 0.0f; } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.cpp index 538bf0ef5..a6194d531 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "EveChildModifierSRT.h" -EveChildModifierSRT::EveChildModifierSRT( IRoot* lockobj ): +EveChildModifierSRT::EveChildModifierSRT( IRoot* lockobj ) : m_scaling( 1.f, 1.f, 1.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_translation( 0.f, 0.f, 0.f ) diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.h index 41829811b..3a7c167b2 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT.h @@ -14,7 +14,7 @@ BLUE_CLASS( EveChildModifierSRT ) : EveChildModifierSRT( IRoot* lockobj = NULL ); ~EveChildModifierSRT(); - + Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const; private: diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT_Blue.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT_Blue.cpp index 7aefc6357..68650fbd8 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT_Blue.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierSRT_Blue.cpp @@ -8,13 +8,13 @@ BLUE_DEFINE_INTERFACE( IEveChildTransformModifier ); const Be::ClassInfo* EveChildModifierSRT::ExposeToBlue() { - EXPOSURE_BEGIN( EveChildModifierSRT, "" ) - MAP_INTERFACE( EveChildModifierSRT ) - MAP_INTERFACE( IEveChildTransformModifier ) + EXPOSURE_BEGIN( EveChildModifierSRT, "" ) + MAP_INTERFACE( EveChildModifierSRT ) + MAP_INTERFACE( IEveChildTransformModifier ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ); - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.cpp index 9027cdddd..17dbd776a 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.cpp @@ -4,7 +4,7 @@ #include "EveChildModifierStretch.h" #include "Include/TriMath.h" -EveChildModifierStretch::EveChildModifierStretch( IRoot* lockobj ): +EveChildModifierStretch::EveChildModifierStretch( IRoot* lockobj ) : m_destPosition( 0, 0, 0 ) { } @@ -12,8 +12,8 @@ EveChildModifierStretch::EveChildModifierStretch( IRoot* lockobj ): EveChildModifierStretch::~EveChildModifierStretch() { } - -void EveChildModifierStretch::SetDest( ITriVectorFunction* dest ) + +void EveChildModifierStretch::SetDest( ITriVectorFunction* dest ) { m_dest = dest; } @@ -34,7 +34,7 @@ Matrix EveChildModifierStretch::ApplyTransform( const Matrix& transform, size_t, Decompose( sourceScale, sourceRotation, sourceTranslation, transform ); start = transform.GetTranslation(); - Be::Time now = BeOS->GetCurrentFrameTime(); + Be::Time now = BeOS->GetCurrentFrameTime(); if( m_dest ) { m_dest->GetValueAt( &end, now ); @@ -46,7 +46,7 @@ Matrix EveChildModifierStretch::ApplyTransform( const Matrix& transform, size_t, TriQuaternionArcFromForward( &rotation, &dir ); float length = Length( diff ); - Vector3 scale = Vector3( sourceScale.x, sourceScale.y, length ); + Vector3 scale = Vector3( sourceScale.x, sourceScale.y, length ); - return RotationMatrix(sourceRotation) * TransformationMatrix( scale, rotation, start + diff / 2.0f ); + return RotationMatrix( sourceRotation ) * TransformationMatrix( scale, rotation, start + diff / 2.0f ); } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h index ca6c6aca3..d2defb4c9 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierStretch.h @@ -16,7 +16,7 @@ BLUE_CLASS( EveChildModifierStretch ) : ~EveChildModifierStretch(); Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const; - void SetDest( ITriVectorFunction* dest ); + void SetDest( ITriVectorFunction * dest ); void SetDestPosition( Vector3 destPosition ); private: diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTransformCommon.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTransformCommon.h index 1e6d62d1c..ea6c2a9df 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTransformCommon.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTransformCommon.h @@ -8,7 +8,7 @@ #include "include/TriMath.h" #include "Tr2Renderer.h" -inline void DistanceBase( const Matrix &transform, Matrix& alignMat, float& distCenter, Vector3& d ) +inline void DistanceBase( const Matrix& transform, Matrix& alignMat, float& distCenter, Vector3& d ) { const Vector3& myPos = transform.GetTranslation(); const Vector3& camPos = Tr2Renderer::GetViewPosition(); @@ -19,7 +19,7 @@ inline void DistanceBase( const Matrix &transform, Matrix& alignMat, float& dist TriVectorRotateMatrix( &camFwd, &camFwd, &parentT ); float lengthSq = LengthSq( transform.GetX() ); - if ( lengthSq != 0 ) + if( lengthSq != 0 ) { camFwd.x /= lengthSq; } @@ -29,7 +29,7 @@ inline void DistanceBase( const Matrix &transform, Matrix& alignMat, float& dist } lengthSq = LengthSq( transform.GetY() ); - if ( lengthSq != 0 ) + if( lengthSq != 0 ) { camFwd.y /= lengthSq; } @@ -39,7 +39,7 @@ inline void DistanceBase( const Matrix &transform, Matrix& alignMat, float& dist } lengthSq = LengthSq( transform.GetZ() ); - if ( lengthSq != 0 ) + if( lengthSq != 0 ) { camFwd.z /= lengthSq; } @@ -60,7 +60,7 @@ inline void DistanceBase( const Matrix &transform, Matrix& alignMat, float& dist TriMatrixChangeBase( &alignMat, &camFwd, &up ); } -inline Matrix Billboard2D( const Matrix &transform ) +inline Matrix Billboard2D( const Matrix& transform ) { float parentScaleX = Length( transform.GetX() ); float parentScaleY = Length( transform.GetY() ); @@ -86,20 +86,17 @@ inline Matrix Billboard2D( const Matrix &transform ) inline Matrix Billboard3D( const Vector3& position ) { const Vector3& camPos = Tr2Renderer::GetViewPosition(); - + Vector3 toObject = Normalize( camPos - position ); Vector3 right = Normalize( Cross( Vector3( 0, 1, 0 ), toObject ) ); - if( LengthSq(right) == 0.0 ) + if( LengthSq( right ) == 0.0 ) { right = Vector3( 1, 0, 0 ); } Vector3 up = Normalize( Cross( toObject, right ) ); - + return Matrix( - right.x, right.y, right.z, 0, - up.x, up.y, up.z, 0, - toObject.x, toObject.y, toObject.z, 0, - 0, 0, 0, 1 ); + right.x, right.y, right.z, 0, up.x, up.y, up.z, 0, toObject.x, toObject.y, toObject.z, 0, 0, 0, 0, 1 ); } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.cpp b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.cpp index addc2d3e2..8ef9e0645 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.cpp +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.cpp @@ -4,7 +4,7 @@ #include "EveChildModifierTranslateWithCamera.h" #include "Tr2Renderer.h" -EveChildModifierTranslateWithCamera::EveChildModifierTranslateWithCamera( IRoot* lockobj ): +EveChildModifierTranslateWithCamera::EveChildModifierTranslateWithCamera( IRoot* lockobj ) : m_attachedToCamera( false ) { } @@ -16,7 +16,7 @@ EveChildModifierTranslateWithCamera::~EveChildModifierTranslateWithCamera() Matrix EveChildModifierTranslateWithCamera::ApplyTransform( const Matrix& transform, size_t, const Float4x3* ) const { Matrix result = transform; - if( m_attachedToCamera ) + if( m_attachedToCamera ) { result.GetTranslation() = Tr2Renderer::GetViewPosition(); } diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.h index 752a32c8c..172ba1ea8 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/EveChildModifierTranslateWithCamera.h @@ -16,6 +16,7 @@ BLUE_CLASS( EveChildModifierTranslateWithCamera ) : ~EveChildModifierTranslateWithCamera(); Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const; + private: bool m_attachedToCamera; }; diff --git a/trinity/Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h b/trinity/Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h index 5cfdebe3e..2dc3fd3e3 100644 --- a/trinity/Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h +++ b/trinity/Eve/SpaceObject/Children/TransformModifiers/IEveChildTransformModifier.h @@ -5,7 +5,8 @@ #define IEveChildTransformModifier_H -BLUE_INTERFACE( IEveChildTransformModifier ) : public IRoot +BLUE_INTERFACE( IEveChildTransformModifier ) : + public IRoot { public: virtual Matrix ApplyTransform( const Matrix& transform, size_t boneCount, const Float4x3* bones ) const = 0; diff --git a/trinity/Eve/SpaceObject/EveMissile.cpp b/trinity/Eve/SpaceObject/EveMissile.cpp index 17512ef91..67a227523 100644 --- a/trinity/Eve/SpaceObject/EveMissile.cpp +++ b/trinity/Eve/SpaceObject/EveMissile.cpp @@ -10,7 +10,7 @@ #include "include/IEveReferencePoint.h" // keep track of missiles -CCP_STATS_DECLARE( eveMissileObjects, "Trinity/Missiles/missileObjects", true, CST_COUNTER_LOW, "Number of missiles (MIRVs) in this frame."); +CCP_STATS_DECLARE( eveMissileObjects, "Trinity/Missiles/missileObjects", true, CST_COUNTER_LOW, "Number of missiles (MIRVs) in this frame." ); // -------------------------------------------------------------------------------- // Description: @@ -51,7 +51,7 @@ bool EveMissile::Initialize() // make 100% sure perticle emitting on all the warheads is disabled for( PEveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { - (*it)->EnableParticleEmitting( false ); + ( *it )->EnableParticleEmitting( false ); } return true; @@ -149,14 +149,14 @@ void EveMissile::UpdateSyncronous( const EveUpdateContext& updateContext ) if( speed > 0.f ) { // update the total alive time based on time already passed and distance / speed of missile ball to target - Vector3 dir(myPosition - targetPositionWS); + Vector3 dir( myPosition - targetPositionWS ); m_estimatedTotalAliveTime = m_time + ( Length( dir ) - m_targetRadius ) / speed; m_lastValidSpeed = speed; } else if( m_lastValidSpeed > 0.f ) { // This means the ball has hit the target, but the warhead may still on the way to the target - Vector3 dir(myPosition - targetPositionWS); + Vector3 dir( myPosition - targetPositionWS ); myVelocity = Normalize( dir ); myVelocity *= m_lastValidSpeed; } @@ -169,11 +169,11 @@ void EveMissile::UpdateSyncronous( const EveUpdateContext& updateContext ) { EveMissileWarhead* wh = *it; // Handle the warhead state - const EveMissileWarhead::StateChangeEvent evt = wh->UpdateState( deltaT, m_estimatedTotalAliveTime, m_target ) ; + const EveMissileWarhead::StateChangeEvent evt = wh->UpdateState( deltaT, m_estimatedTotalAliveTime, m_target ); if( wh->GetState() != EveMissileWarhead::STATE_DEAD ) { - Vector3 locatorPositionWS(worldPos); + Vector3 locatorPositionWS( worldPos ); Matrix locatorMatrix; if( m_target ) @@ -196,12 +196,12 @@ void EveMissile::UpdateSyncronous( const EveUpdateContext& updateContext ) wh->Update( updateContext ); } - const EveMissileWarhead::StateChangeEvent evt2 = wh->CheckImpact( deltaT, m_estimatedTotalAliveTime, m_target ) ; + const EveMissileWarhead::StateChangeEvent evt2 = wh->CheckImpact( deltaT, m_estimatedTotalAliveTime, m_target ); if( evt2 == EveMissileWarhead::EVT_EXPLODE ) { if( m_callback ) { - D3DPERF_EVENT(L"EveMissile explosion callback"); + D3DPERF_EVENT( L"EveMissile explosion callback" ); m_callback.CallVoid( wh->GetWarheadID() ); } } @@ -218,8 +218,8 @@ void EveMissile::UpdateVisibility( const EveUpdateContext& updateContext, const // collect the renderables from every warhead this MIRV has for( EveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { - EveMissileWarhead* warhead = (*it); - + EveMissileWarhead* warhead = ( *it ); + // apply the offset transform to the transform of this spaceobject Matrix subMissileTransform = warhead->GetCurrentOffsetTransform() * m_worldTransform; @@ -250,7 +250,7 @@ void EveMissile::GetRenderables( std::vector& renderables, Tr2I // collect the renderables from every warhead this MIRV has for( EveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { - (*it)->GetRenderables( renderables, impostors ); + ( *it )->GetRenderables( renderables, impostors ); } } @@ -287,7 +287,7 @@ void EveMissile::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { for( EveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { - (*it)->RenderDebugInfo( renderer ); + ( *it )->RenderDebugInfo( renderer ); } } } @@ -346,7 +346,7 @@ void EveMissile::Start( const Vector3& shipVelocity, float estimatedFlyingTime ) // disable particle emitting here, it will get enabled in a later state of each warhead for( PEveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { - (*it)->EnableParticleEmitting( false ); + ( *it )->EnableParticleEmitting( false ); } // start! @@ -369,7 +369,7 @@ bool EveMissile::RebuildMissileBoundingSphere() for( PEveMissileWarheadVector::const_iterator it = m_warheads.begin(); it != m_warheads.end(); ++it ) { Vector4 localBoundingSphere; - if( (*it)->GetLocalBoundingSphere( localBoundingSphere ) ) + if( ( *it )->GetLocalBoundingSphere( localBoundingSphere ) ) { // add the local bounding sphere of each warhead to the b-sphere of this missileMIRV BoundingSphereUpdate( localBoundingSphere, sphere ); diff --git a/trinity/Eve/SpaceObject/EveMissile.h b/trinity/Eve/SpaceObject/EveMissile.h index fc5994063..245879c5d 100644 --- a/trinity/Eve/SpaceObject/EveMissile.h +++ b/trinity/Eve/SpaceObject/EveMissile.h @@ -21,8 +21,7 @@ BLUE_DECLARE_VECTOR( EveMissileWarhead ); // SeeAlso: // EveMissileWarhead, EveSpaceObject2 // -------------------------------------------------------------------------------- -class EveMissile : - public EveSpaceObject2 +class EveMissile : public EveSpaceObject2 { public: EXPOSE_TO_BLUE(); @@ -39,13 +38,13 @@ class EveMissile : virtual void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - overriding EveSpaceObject2 implementations - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) ; + virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); ///////////////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Eve/SpaceObject/EveMissileWarhead.cpp b/trinity/Eve/SpaceObject/EveMissileWarhead.cpp index f2061a0a7..542626a8b 100644 --- a/trinity/Eve/SpaceObject/EveMissileWarhead.cpp +++ b/trinity/Eve/SpaceObject/EveMissileWarhead.cpp @@ -13,7 +13,7 @@ #include "Particle/Tr2GpuSharedEmitter.h" // keep track of missiles -CCP_STATS_DECLARE( eveVisibleWarheadObjects, "Trinity/Missiles/visibleWarheadObjects", true, CST_COUNTER_LOW, "Number of individual warheads visible in this frame."); +CCP_STATS_DECLARE( eveVisibleWarheadObjects, "Trinity/Missiles/visibleWarheadObjects", true, CST_COUNTER_LOW, "Number of individual warheads visible in this frame." ); // -------------------------------------------------------------------------------- @@ -126,7 +126,7 @@ void EveMissileWarhead::UpdateVisibility( const EveUpdateContext& updateContext, auto& frustum = updateContext.GetFrustum(); m_isVisible = true; UpdateViewDependentData( frustum, parentTransform ); - + if( m_mesh ) { Vector4 boundingSphere; @@ -134,7 +134,7 @@ void EveMissileWarhead::UpdateVisibility( const EveUpdateContext& updateContext, { // check visibility with camera or, if threshold set to negative, no culling if( frustum.IsSphereVisible( &boundingSphere ) ) - { + { float estimatedSize = frustum.GetPixelSizeAccross( &boundingSphere ); if( estimatedSize >= updateContext.GetMediumDetailThreshold() ) { @@ -183,7 +183,7 @@ void EveMissileWarhead::GetRenderables( std::vector& renderable { return; } - + if( m_mesh ) { renderables.push_back( this ); @@ -232,7 +232,7 @@ void EveMissileWarhead::EnableParticleEmitting( bool enable ) for( PIEveTransformVector::const_iterator it = m_children.begin(); it != m_children.end(); ++it ) { EveTransformPtr child; - if( (*it)->QueryInterface( BlueInterfaceIID(), (void**)&child, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)&child, BEQI_SILENT ) ) { // do we have an attached GPU emitter? for( auto emIt = child->m_particleEmitters.begin(); emIt != child->m_particleEmitters.end(); ++emIt ) @@ -359,7 +359,7 @@ EveMissileWarhead::StateChangeEvent EveMissileWarhead::UpdateState( float deltaT StateChangeEvent evt = EVT_NONE; Vector3 position; - const float estimatedTotalFlyingTime = (estimatedTotalAliveTime + 0.1f) * m_speedModifier; + const float estimatedTotalFlyingTime = ( estimatedTotalAliveTime + 0.1f ) * m_speedModifier; // calc a value from 0 to 1 across the whole (estimated) flying time, (excluding eject-phase time and delay time) const float flight01 = TriClamp( m_flyingTime / estimatedTotalFlyingTime, 0.f, 1.f ); @@ -426,7 +426,7 @@ EveMissileWarhead::StateChangeEvent EveMissileWarhead::CheckImpact( float deltaT { return evt; } - const float estimatedTotalFlyingTime = (estimatedTotalAliveTime + 0.1f) * m_speedModifier; + const float estimatedTotalFlyingTime = ( estimatedTotalAliveTime + 0.1f ) * m_speedModifier; // calc a value from 0 to 1 across the whole (estimated) flying time, (excluding eject-phase time and delay time) const float flight01 = TriClamp( ( m_flyingTime - deltaT ) / estimatedTotalFlyingTime, 0.f, 1.f ); @@ -512,7 +512,7 @@ void EveMissileWarhead::UpdateWarhead( float deltaT, float estimatedTotalAliveTi } // from the total alive time caclulate the total flying time - const float estimatedTotalFlyingTime = (estimatedTotalAliveTime + 0.1f) * m_speedModifier; + const float estimatedTotalFlyingTime = ( estimatedTotalAliveTime + 0.1f ) * m_speedModifier; // calc a value from 0 to 1 across the whole (estimated) flying time, (excluding eject-phase time and delay time) @@ -549,7 +549,7 @@ void EveMissileWarhead::UpdateWarhead( float deltaT, float estimatedTotalAliveTi // apply the animated offset, but be carefull: scale it down in beginning and end! m_currentOffset += powf( sinf( XM_PI * flight01 ), 2.f ) * m_pathOffset; - + // override some behaviour for bombs if( m_bombFlightpath ) { @@ -622,9 +622,8 @@ uint32_t EveMissileWarhead::GetPerObjectDataSize( Tr2RenderContextEnum::ShaderTy } else { - return - 64 + // m_vsWorldMatrix - 16; // m_missileSize + return 64 + // m_vsWorldMatrix + 16; // m_missileSize } } @@ -634,7 +633,7 @@ void EveMissileWarhead::UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType { uint8_t* perObjectVS = static_cast( data ); *reinterpret_cast( perObjectVS ) = Transpose( m_worldTransform ); - perObjectVS += sizeof(Matrix); + perObjectVS += sizeof( Matrix ); *reinterpret_cast( perObjectVS ) = Vector4( m_warheadRadius, m_warheadLength, 0, 0 ); } @@ -643,7 +642,7 @@ void EveMissileWarhead::UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType void EveMissileWarhead::RenderDebugInfoFromParent( ITr2DebugRenderer2& renderer, Matrix transform ) { - srand( static_cast( reinterpret_cast( this ))); + srand( static_cast( reinterpret_cast( this ) ) ); uint32_t color = 0xff000000 + rand() % 0x00ffffff; renderer.DrawLine( this, transform.GetTranslation(), this->GetWorldPosition(), color ); renderer.DrawLine( this, this->GetWorldPosition(), TransformCoord( m_currentEndOffset, transform ), 0xff999999 ); @@ -689,4 +688,3 @@ void EveMissileWarheadPerObjectData::SetPerObjectDataToDevice( Tr2ConstantBuffer { Tr2PerObjectDataWithPersistentBuffers::SetPerObjectDataToDevice( buffers, constantTypeMask, renderContext ); } - diff --git a/trinity/Eve/SpaceObject/EveMissileWarhead.h b/trinity/Eve/SpaceObject/EveMissileWarhead.h index 85d1bc66f..4a6e447c9 100644 --- a/trinity/Eve/SpaceObject/EveMissileWarhead.h +++ b/trinity/Eve/SpaceObject/EveMissileWarhead.h @@ -18,8 +18,7 @@ BLUE_DECLARE( EveSpriteSet ); // SeeAlso: // EveMissile, EveTransform // -------------------------------------------------------------------------------- -class EveMissileWarhead : - public EveTransform +class EveMissileWarhead : public EveTransform { public: EXPOSE_TO_BLUE(); @@ -62,8 +61,14 @@ class EveMissileWarhead : void Launch( const Matrix& startTransform ); // locator access - void SetTargetLocator( int damageLocator ) { m_targetLocator = damageLocator; } - int GetTargetLocator() const { return m_targetLocator; } + void SetTargetLocator( int damageLocator ) + { + m_targetLocator = damageLocator; + } + int GetTargetLocator() const + { + return m_targetLocator; + } // enable particle emitting on this warhead void EnableParticleEmitting( bool enable ); @@ -90,10 +95,16 @@ class EveMissileWarhead : // state handling StateChangeEvent UpdateState( float deltaT, float estimatedAliveTime, ITriTargetable* target ); StateChangeEvent CheckImpact( float deltaT, float estimatedTotalAliveTime, ITriTargetable* target ); - State GetState() const { return m_state; } + State GetState() const + { + return m_state; + } // this warhead's unique ID - int GetWarheadID() const { return m_id; } + int GetWarheadID() const + { + return m_id; + } uint32_t GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const; void UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType shaderType, uint32_t size, void* data ); @@ -126,7 +137,7 @@ class EveMissileWarhead : bool m_startDataValid; bool m_doSpread; - // + // Vector3 m_movement; Vector3 m_posLastFrame; diff --git a/trinity/Eve/SpaceObject/EveMissileWarhead_Blue.cpp b/trinity/Eve/SpaceObject/EveMissileWarhead_Blue.cpp index d99b03892..e25283ad0 100644 --- a/trinity/Eve/SpaceObject/EveMissileWarhead_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveMissileWarhead_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveMissileWarhead ); const Be::ClassInfo* EveMissileWarhead::ExposeToBlue() { - EXPOSURE_BEGIN( EveMissileWarhead, "" ) - MAP_INTERFACE( EveMissileWarhead ) + EXPOSURE_BEGIN( EveMissileWarhead, "" ) + MAP_INTERFACE( EveMissileWarhead ) MAP_INTERFACE( EveTransform ) MAP_ATTRIBUTE( "startDataValid", m_startDataValid, "", Be::READWRITE ) diff --git a/trinity/Eve/SpaceObject/EveMissile_Blue.cpp b/trinity/Eve/SpaceObject/EveMissile_Blue.cpp index e2182c86b..43e845ade 100644 --- a/trinity/Eve/SpaceObject/EveMissile_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveMissile_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveMissile ); const Be::ClassInfo* EveMissile::ExposeToBlue() { - EXPOSURE_BEGIN( EveMissile, "" ) - MAP_INTERFACE( EveMissile ) + EXPOSURE_BEGIN( EveMissile, "" ) + MAP_INTERFACE( EveMissile ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2Renderable ) @@ -35,5 +35,5 @@ const Be::ClassInfo* EveMissile::ExposeToBlue() RebuildMissileBoundingSphere, "Rebuild the missile object's bounding sphere based on the internal position of all attached warheads.\n" ) - EXPOSURE_CHAINTO( EveSpaceObject2 ) + EXPOSURE_CHAINTO( EveSpaceObject2 ) } diff --git a/trinity/Eve/SpaceObject/EveMobile.h b/trinity/Eve/SpaceObject/EveMobile.h index 44d79b68a..9f7368702 100644 --- a/trinity/Eve/SpaceObject/EveMobile.h +++ b/trinity/Eve/SpaceObject/EveMobile.h @@ -39,9 +39,9 @@ BLUE_CLASS( EveMobile ) : void UpdateAsyncronous( const EveUpdateContext& updateContext ) override; void PrepareShaderData( const EveUpdateContext& updateContext ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) override; - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) override; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) override; - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ) override; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) override; + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) override; void SetControllerVariable( const char* name, float value ) override; void HandleControllerEvent( const char* name ) override; @@ -53,8 +53,8 @@ BLUE_CLASS( EveMobile ) : ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; // re-positions all attached turrets to the corresponding locators void RebuildTurretPositions(); @@ -63,7 +63,7 @@ BLUE_CLASS( EveMobile ) : // Asynch update for turret sets virtual void UpdateTurretsAsyncronous( const EveUpdateContext& updateContext ); - void SetShaderOption(const BlueSharedString& name, const BlueSharedString& value) override; + void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; // Active turret info int GetActiveTurretCount() const; @@ -82,11 +82,12 @@ BLUE_CLASS( EveMobile ) : ///////////////////////////////////////////////////////////////////////////////////// // activation //float m_activationStrength; - + ///////////////////////////////////////////////////////////////////////////////////// // turrets PEveTurretSetVector m_turretSets; virtual const Matrix* GetTurretTransform( unsigned int turretSetIndex ) const; + private: ///////////////////////////////////////////////////////////////////////////////////// // turrets diff --git a/trinity/Eve/SpaceObject/EveMobile_Blue.cpp b/trinity/Eve/SpaceObject/EveMobile_Blue.cpp index 5920992fb..083bc8efe 100644 --- a/trinity/Eve/SpaceObject/EveMobile_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveMobile_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveMobile ); const Be::ClassInfo* EveMobile::ExposeToBlue() { - EXPOSURE_BEGIN( EveMobile, "" ) - MAP_INTERFACE( EveMobile ) + EXPOSURE_BEGIN( EveMobile, "" ) + MAP_INTERFACE( EveMobile ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IListNotify ) @@ -18,15 +18,14 @@ const Be::ClassInfo* EveMobile::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetTurretLocatorIndex", - GetTurretLocatorIndex, + GetTurretLocatorIndex, "Get the index for the locator in the ship's locator-list used for a single turret\n" ":param turretSetIdx: index of the turretSet in the ship's turretset list\n" - ":param slotIdx: index of the individual single turret in the turretset\n" - ) + ":param slotIdx: index of the individual single turret in the turretset\n" ) MAP_METHOD_AND_WRAP( "GetTurretLocatorCount", GetTurretLocatorCount, "Returns the turret locator count of locators and bones matching the correct naming scheme." ) - MAP_METHOD_AND_WRAP( "RebuildTurretPositions", RebuildTurretPositions, "Re-positions all the turrets on this ship" ) - + MAP_METHOD_AND_WRAP( "RebuildTurretPositions", RebuildTurretPositions, "Re-positions all the turrets on this ship" ) - EXPOSURE_CHAINTO( EveSpaceObject2 ) + + EXPOSURE_CHAINTO( EveSpaceObject2 ) } diff --git a/trinity/Eve/SpaceObject/EveShip2.cpp b/trinity/Eve/SpaceObject/EveShip2.cpp index 27af442c9..732314140 100644 --- a/trinity/Eve/SpaceObject/EveShip2.cpp +++ b/trinity/Eve/SpaceObject/EveShip2.cpp @@ -198,7 +198,7 @@ bool EveShip2::DisplayBoosters() const float EveShip2::GetKillCounterValue() const { - return static_cast( m_displayKillCounterValue ); + return static_cast( m_displayKillCounterValue ); } void EveShip2::GetDebugOptions( Tr2DebugRendererOptions& options ) @@ -244,7 +244,7 @@ void EveShip2::RebuildBoosterSet() const unsigned int kLocatorPrefixLength = (unsigned int)strlen( kLocatorPrefix ); unsigned int n = (unsigned int)m_locators.size(); - for( unsigned int i = 0; i < n ; ++i ) + for( unsigned int i = 0; i < n; ++i ) { EveLocator2Ptr locator = m_locators[i]; const char* locatorName = locator->GetName(); @@ -308,16 +308,16 @@ void EveShip2::SetAudioParameter( IRoot* aud ) m_audioParameterInfo.classInfo = m_audioSpeedParameter->ClassType(); m_audioParameterInfo.offset = 0; m_audioParameterInfo.entry = TriValueBinding::FindEntry( "value", m_audioParameterInfo.classInfo, m_audioParameterInfo.offset ); - + if( m_audioParameterInfo.entry ) { if( m_audioParameterInfo.entry->mType == Be::FLOAT ) { - m_audioParameterInfo.destinationValue = BLUEMAPMEMBEROFFSET( - aud, - m_audioParameterInfo.entry, - m_audioParameterInfo.classInfo, - m_audioParameterInfo.offset ); + m_audioParameterInfo.destinationValue = BLUEMAPMEMBEROFFSET( + aud, + m_audioParameterInfo.entry, + m_audioParameterInfo.classInfo, + m_audioParameterInfo.offset ); } if( m_audioParameterInfo.entry->mEditFlags & Be::NOTIFY ) { @@ -361,7 +361,7 @@ IRoot* EveShip2::GetAudioParameter() const // -------------------------------------------------------------------------------------- void EveShip2::UpdateShipSpeedForAudio() { - if(( m_maxSpeed == 0.0f ) || ( m_boosters == NULL )) + if( ( m_maxSpeed == 0.0f ) || ( m_boosters == NULL ) ) { return; } @@ -376,7 +376,6 @@ void EveShip2::UpdateShipSpeedForAudio() { m_audioSpeedNotify->OnModified( (Be::Var*)m_audioParameterInfo.destinationValue ); } - } } @@ -387,7 +386,7 @@ float EveShip2::GetMaxSpeed() const float EveShip2::GetBoosterIntensity() const { - if ( m_boosters != nullptr ) + if( m_boosters != nullptr ) { return m_boosters->GetBoosterIntensity(); } diff --git a/trinity/Eve/SpaceObject/EveShip2.h b/trinity/Eve/SpaceObject/EveShip2.h index ba3a9d3a5..728f590b1 100644 --- a/trinity/Eve/SpaceObject/EveShip2.h +++ b/trinity/Eve/SpaceObject/EveShip2.h @@ -30,33 +30,33 @@ BLUE_CLASS( EveShip2 ) : virtual void UpdateSyncronous( const EveUpdateContext& updateContext ) override; virtual void UpdateAsyncronous( const EveUpdateContext& updateContext ) override; virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) override; - virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ) override; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) override; + virtual void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ) override; + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ) override; virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ) override; virtual void GetParentData( EveSpaceObject2::ParentData * pd ) const override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - overriding EveSpaceObject2 implementations - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); ///////////////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - overriding EveSpaceObject2 implementations - virtual void RebuildCachedData( BlueAsyncRes* p ); + virtual void RebuildCachedData( BlueAsyncRes * p ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); void RegisterComponents() override; void UnRegisterComponents() override; EveBoosterSet2* GetBoosters(); - void SetBoosters( EveBoosterSet2* boosters ); + void SetBoosters( EveBoosterSet2 * boosters ); // re-positions all attached boosters to the corresponding locators void RebuildBoosterSet(); - float GetKillCounterValue() const; + float GetKillCounterValue() const; float GetMaxSpeed() const; float GetBoosterIntensity() const; @@ -70,8 +70,8 @@ BLUE_CLASS( EveShip2 ) : virtual bool DisplayBoosters() const; virtual void UpdateBoosters( const EveUpdateContext& updateContext ); -private: +private: // For Audio IRootPtr m_audioSpeedParameter; INotifyPtr m_audioSpeedNotify; @@ -88,7 +88,7 @@ BLUE_CLASS( EveShip2 ) : void UpdateShipSpeedForAudio(); // Property accessors - void SetAudioParameter( IRoot* aud ); + void SetAudioParameter( IRoot * aud ); IRoot* GetAudioParameter() const; // on ship info displays diff --git a/trinity/Eve/SpaceObject/EveShip2_Blue.cpp b/trinity/Eve/SpaceObject/EveShip2_Blue.cpp index 2a799994e..617c63c66 100644 --- a/trinity/Eve/SpaceObject/EveShip2_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveShip2_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveShip2 ); const Be::ClassInfo* EveShip2::ExposeToBlue() { - EXPOSURE_BEGIN( EveShip2, "" ) - MAP_INTERFACE( EveShip2 ) + EXPOSURE_BEGIN( EveShip2, "" ) + MAP_INTERFACE( EveShip2 ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( IListNotify ) diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp index 99d736cc0..c580579b1 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.cpp @@ -594,7 +594,6 @@ void EveSpaceObject2::UpdateSyncronous( const EveUpdateContext& updateContext ) } RegisterAudioGeometry(); - } void EveSpaceObject2::UpdateAsyncronous( const EveUpdateContext& updateContext ) @@ -947,7 +946,7 @@ void EveSpaceObject2::RenderDebugInfo( ITr2DebugRenderer2& renderer ) for( auto it = m_locators.begin(); it != m_locators.end(); ++it ) { Matrix transform = ( *it )->GetTransform(); - + if( m_animationUpdater ) { m_animationUpdater->GetBoneWorldTransform( ( *it )->GetName(), transform ); @@ -1068,7 +1067,7 @@ Matrix EveSpaceObject2::GetEveLocatorTransform( const char* name ) const return result; } } - + return locator->GetTransform(); } @@ -1147,7 +1146,7 @@ void EveSpaceObject2::GetShadowBatches( ITriRenderBatchAccumulator* batches, con { return; } - + TriGeometryRes* geomRes = m_mesh->GetGeometryResource(); if( !geomRes || !geomRes->IsGood() ) { @@ -1289,15 +1288,13 @@ const Matrix* EveSpaceObject2::GetLocatorTransform( LocatorType lt, unsigned int { switch( lt ) { - case ELT_TRANSFORM: - { + case ELT_TRANSFORM: { EveLocator2* t = m_locators[lix]; return &t->GetTransform(); } break; - case ELT_JOINT: - { + case ELT_JOINT: { if( !m_animationUpdater ) { return nullptr; @@ -1521,8 +1518,7 @@ std::pair EveSpaceObject2::CalculateSkinnedBoundingBoxFromTran Vector3 localMin, localMax; GetLocalBoundingBox( localMin, localMax ); AxisAlignedBoundingBox box( localMin, localMax ); - box.EnumerateVertices( [&transform, &bbMin, &bbMax]( const Vector3& vertex ) - { + box.EnumerateVertices( [&transform, &bbMin, &bbMax]( const Vector3& vertex ) { Vector4 pos = Transform( Vector4( vertex, 1.f ), transform ); pos /= pos.w; @@ -1737,7 +1733,7 @@ void EveSpaceObject2::UpdateVisibility( const EveUpdateContext& updateContext, c if( updateContext.m_raytracingEnabled ) { - UpdateRtMesh(updateContext); + UpdateRtMesh( updateContext ); UpdateRtSkeleton(); } } @@ -1769,28 +1765,28 @@ void EveSpaceObject2::UpdateRtSkeleton() { return; } - + auto rtMesh = m_mesh->GetRtMesh(); if( !rtMesh ) { return; } - + auto geo = m_mesh->GetGeometryResource(); if( !geo || !geo->IsGood() ) { return; } - + auto meshIndex = m_mesh->GetMeshIndex(); auto lod = geo->GetMeshLod( meshIndex, m_meshScreenSize ); if( !lod ) { return; } - + bool hasSkinned = false; - + auto areas = m_mesh->GetAreas( TRIBATCHTYPE_OPAQUE ); for( auto& area : *areas ) { @@ -1806,7 +1802,7 @@ void EveSpaceObject2::UpdateRtSkeleton() { return; //no skinned areas } - + auto boneCount = uint32_t( m_animationUpdater->GetMeshBoneCount() ); m_boneOffsets.UploadTransforms( Tr2RingBuffer::GetInstance(), reinterpret_cast( m_animationUpdater->GetMeshBoneMatrixList() ), boneCount ); auto offset = m_boneOffsets.GetCurrentFrameOffset(); @@ -2032,7 +2028,7 @@ int EveSpaceObject2::GetBoneCount() const } return GrannyGetMeshBindingBoneCount( m_animationUpdater->m_meshBinding ); } -#else +#else else { return 0; @@ -3579,7 +3575,7 @@ void EveSpaceObject2::RegisterComponents() if( registry && m_display ) { - if ( !m_lights.empty() ) + if( !m_lights.empty() ) { registry->RegisterComponent( this ); } @@ -4012,12 +4008,12 @@ void EveSpaceObject2::PushRtGeometry( Tr2RaytracingManager& rtManager ) const } USE_MAIN_THREAD_RENDER_CONTEXT(); - + const Tr2MeshAreaVector* opaqueAreas = m_mesh->GetAreas( TRIBATCHTYPE_OPAQUE ); UpdateRtPerObjectData( m_psData, nullptr, renderContext, m_rtPerObjectData ); - - #pragma region geometry + +#pragma region geometry uint32_t vertexBufferDataIndex = 0; for( Tr2MeshAreaVector::const_iterator it = opaqueAreas->begin(); it != opaqueAreas->end(); ++it, ++vertexBufferDataIndex ) { diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2.h b/trinity/Eve/SpaceObject/EveSpaceObject2.h index eacc4b8c6..19ded272d 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2.h +++ b/trinity/Eve/SpaceObject/EveSpaceObject2.h @@ -45,8 +45,8 @@ // consts -#define EVE_SPACEOBJECT_DIRT_LEVEL_DEFAULT (0.f) -#define EVE_SPACEOBJECT_CUSTOWMASK_MAX (2) +#define EVE_SPACEOBJECT_DIRT_LEVEL_DEFAULT ( 0.f ) +#define EVE_SPACEOBJECT_CUSTOWMASK_MAX ( 2 ) // forwards BLUE_DECLARE_INTERFACE( IEveSpaceObject2 ); @@ -105,8 +105,8 @@ struct EveSpaceObjectVSData Vector4 clipData; Vector4 ellpsoidRadii; Vector4 ellpsoidCenter; - Matrix customMaskMatrix[ EVE_SPACEOBJECT_CUSTOWMASK_MAX ]; - Vector4 customMaskData[ EVE_SPACEOBJECT_CUSTOWMASK_MAX ]; + Matrix customMaskMatrix[EVE_SPACEOBJECT_CUSTOWMASK_MAX]; + Vector4 customMaskData[EVE_SPACEOBJECT_CUSTOWMASK_MAX]; uint32_t boneOffsets[4]; uint32_t morphTargetVertexDataOffset; uint32_t morphTargetAnimationDataOffset; @@ -132,8 +132,8 @@ struct EveSpaceObjectPSData float clipSphereFactor2; float clipSphereFactor; Vector4 shLightingCoefficients[Tr2ShLightingManager::PACKED_COEFFICIENT_COUNT]; - Vector4 customMaskMaterialIDs[ EVE_SPACEOBJECT_CUSTOWMASK_MAX ]; - Vector4 customMaskTargets[ EVE_SPACEOBJECT_CUSTOWMASK_MAX ]; + Vector4 customMaskMaterialIDs[EVE_SPACEOBJECT_CUSTOWMASK_MAX]; + Vector4 customMaskTargets[EVE_SPACEOBJECT_CUSTOWMASK_MAX]; Vector4 customMaskClamps; Vector4 screenSize; @@ -181,8 +181,8 @@ struct EveSpacePerObjectData // mesh - mesh containing the geometry to be rendered // worldTransform - world transform of the object the areas/mesh belong to // --------------------------------------------------------------------------------------- -void GetSortedBatchesFromMeshAreaVector( const Tr2MeshAreaVector* areas, - ITriRenderBatchAccumulator* batches, +void GetSortedBatchesFromMeshAreaVector( const Tr2MeshAreaVector* areas, + ITriRenderBatchAccumulator* batches, const Tr2PerObjectData* perObjectData, const Tr2MeshBase* mesh, float screenSize, @@ -199,13 +199,13 @@ void UpdateRtVertexBufferData( Tr2PrimaryRenderContext& renderContext, Tr2MeshBa // it has any). Note that the locator transforms are expected to be static and are not // updated per frame, for performance reasons. // -------------------------------------------------------------------------------- -BLUE_CLASS( EveSpaceObject2 ): +BLUE_CLASS( EveSpaceObject2 ) : public IInitialize, public ITr2Renderable, public IEveSpaceObject2, public IEveShadowCaster, public IBlueAsyncResNotifyTarget, - public ITr2Pickable, + public ITr2Pickable, public ITr2BoundingBox, public ITriTargetable, public IWorldPosition, @@ -230,7 +230,10 @@ BLUE_CLASS( EveSpaceObject2 ): public: EXPOSE_TO_BLUE(); - static uint64_t NextAudioInstanceId() { return s_nextAudioInstanceId++; } + static uint64_t NextAudioInstanceId() + { + return s_nextAudioInstanceId++; + } using IInitialize::Lock; using IInitialize::Unlock; @@ -248,8 +251,11 @@ BLUE_CLASS( EveSpaceObject2 ): }; // Mesh accessors, used by the builder - Tr2MeshBase* GetMesh() const { return m_mesh; } - void SetMesh( Tr2MeshBase* mesh ); + Tr2MeshBase* GetMesh() const + { + return m_mesh; + } + void SetMesh( Tr2MeshBase * mesh ); void PlayAnimation( const char* animName, bool replace, int loopCount, float start, float speed, Be::OptionalWithDefaultValue clearWhenDone ); void PlayAnimationOnce( const char* animName ); @@ -263,7 +269,7 @@ BLUE_CLASS( EveSpaceObject2 ): int GetBoneCount() const; // Actually submit renderables to the list, called from GetRenderables - virtual void PushRenderables( std::vector& renderables ); + virtual void PushRenderables( std::vector & renderables ); ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 @@ -271,15 +277,15 @@ BLUE_CLASS( EveSpaceObject2 ): virtual void UpdateAsyncronous( const EveUpdateContext& updateContext ); virtual void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); virtual void PrepareShaderData( const EveUpdateContext& updateContext ); - virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - virtual void GetModelCenterWorldPosition( Vector3 &position ) const; - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - virtual void GetLocalToWorldTransform( Matrix &transform ) const; - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + virtual void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + virtual bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + virtual void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + virtual void GetModelCenterWorldPosition( Vector3 & position ) const; + virtual bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + virtual void GetLocalToWorldTransform( Matrix & transform ) const; + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); - virtual void SetProceduralContainerVariable( const char *name, float value ) override; + virtual void SetProceduralContainerVariable( const char* name, float value ) override; virtual bool IsPickable() const; virtual void GetParentData( IEveSpaceObject2::ParentData * pd ) const; @@ -301,32 +307,32 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual bool HasTransparentBatches(); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); virtual bool IsVisible( const EveUpdateContext& updateContext ) const override; ///////////////////////////////////////////////////////////////////////////////////// // IAsyncLoadedResNotifyTarget - virtual void ReleaseCachedData( BlueAsyncRes* p ); - virtual void RebuildCachedData( BlueAsyncRes* p ); + virtual void ReleaseCachedData( BlueAsyncRes * p ); + virtual void RebuildCachedData( BlueAsyncRes * p ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable virtual IRoot* GetID( uint16_t ); - virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); + virtual void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2BoundingBox - virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const; + virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const; virtual bool IsBoundingBoxReady() const; - + ///////////////////////////////////////////////////////////////////////////////////// // ITriTargetable unsigned int GetDamageLocatorCount() const; int GetClosestDamageLocatorIndex( const Vector3* position ); - virtual bool GetDamageLocatorPosition( Vector3* out, int index, bool inWorldSpace ); - virtual bool GetDamageLocatorDirection( Vector3* out, int index, bool inWorldSpace ); + virtual bool GetDamageLocatorPosition( Vector3 * out, int index, bool inWorldSpace ); + virtual bool GetDamageLocatorDirection( Vector3 * out, int index, bool inWorldSpace ); void GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ); int GetGoodDamageLocatorIndex( const Vector3& position ); float GetRadius() const; @@ -334,9 +340,9 @@ BLUE_CLASS( EveSpaceObject2 ): int CreateImpactFromPosition( const Vector3& position, const Vector3& direction, float lifeTime, float size ); void SetLastDamageLocatorHit( unsigned int locator ); - bool UpdateImpact( Vector3& out, const Vector3& direction, int impactIndex ); + bool UpdateImpact( Vector3 & out, const Vector3& direction, int impactIndex ); ImpactConfiguration GetImpactConfiguration() const override; - bool GetImpactPosition( Vector3& out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); + bool GetImpactPosition( Vector3 & out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ); bool HasImpactConfigurationShield() const; ///////////////////////////////////////////////////////////////////////////////////// @@ -347,13 +353,13 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2ShLightingReceiver virtual void UpdateShLighting( Tr2ShLightingManager&, const EveUpdateContext& updateContext ); @@ -361,27 +367,27 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2SecondaryLightSource - void RegisterSecondaryLightSource( Tr2ShLightingManager& manager ); - void UnregisterSecondaryLightSource( Tr2ShLightingManager& manager ); + void RegisterSecondaryLightSource( Tr2ShLightingManager & manager ); + void UnregisterSecondaryLightSource( Tr2ShLightingManager & manager ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ImpostorSource virtual void GetImpostorBatches( const TriFrustum& frustum, std::map& batches ); virtual float GetRenderPriority( const ImpostorHash& oldHash, const ImpostorHash& newHash ) const; - virtual bool GetImpostorBoundingSphere( Vector4& sphere ) const; + virtual bool GetImpostorBoundingSphere( Vector4 & sphere ) const; virtual void GetLastImpostorBoundingSphere( Vector4 & sphere ) const; ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); ///////////////////////////////////////////////////////////////////////////////////// // IEveEffectChildrenOwner IEveSpaceObjectChildPtr GetEffectChildByName( const char* name ) const; - void AddToEffectChildrenList( IEveSpaceObjectChild* child ); - void RemoveFromEffectChildrenList( IEveSpaceObjectChild* child ); + void AddToEffectChildrenList( IEveSpaceObjectChild * child ); + void RemoveFromEffectChildrenList( IEveSpaceObjectChild * child ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2ControllerOwner @@ -389,8 +395,8 @@ BLUE_CLASS( EveSpaceObject2 ): void HandleControllerEvent( const char* name ) override; void StartControllers(); bool GetControllerValueByName( const char* name, float& out ); - virtual void AddController( ITr2Controller* controller ) override; - + virtual void AddController( ITr2Controller * controller ) override; + ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectDecalOwner virtual void AddDecal( EveSpaceObjectDecalPtr newDecal ) override; @@ -402,23 +408,26 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2LightOwner - virtual void GetLights( Tr2LightManager& lightManager ) const override; - virtual void AddLight( Tr2Light* newLight ); + virtual void GetLights( Tr2LightManager & lightManager ) const override; + virtual void AddLight( Tr2Light * newLight ); virtual void ClearLights(); // For stateful GPU particles ITriVectorFunctionPtr GetPositionFunction(); Vector3 GetModelWorldPosition() const; - void GetWorldVelocity( Vector3& velocity ) const; + void GetWorldVelocity( Vector3 & velocity ) const; - Tr2GrannyAnimation* GetAnimationController() const override { return m_animationUpdater; } - bool IsAnimated() const; + Tr2GrannyAnimation* GetAnimationController() const override + { + return m_animationUpdater; + } + bool IsAnimated() const; // bounding sphere void SetBoundingSphereInformation( const CcpMath::Sphere& boundingSphere ); - Be::Result GetLocalBoundingBoxFromScript( std::pair& result ); - void GetShapeEllipsoid( Vector3& center, Vector3& radius ); + Be::Result GetLocalBoundingBoxFromScript( std::pair & result ); + void GetShapeEllipsoid( Vector3 & center, Vector3 & radius ); void SetShapeEllipsoid( const CcpMath::AxisAlignedEllipsoid& ellipsoid ); // access to visiblity @@ -435,7 +444,7 @@ BLUE_CLASS( EveSpaceObject2 ): // access stuff void AddCurveSet( TriCurveSetPtr newCurveSet ); - void AddLocator( EveLocator2* newLocator ); + void AddLocator( EveLocator2 * newLocator ); void AddOverlayEffect( EveMeshOverlayEffectPtr newOverlayEffect ); void RemoveOverlayEffect( EveMeshOverlayEffectPtr newOverlayEffect ); EveMeshOverlayEffectPtr GetOverlayEffectByName( const char* name ) const; @@ -460,8 +469,8 @@ BLUE_CLASS( EveSpaceObject2 ): unsigned int GetLocatorCount( BlueSharedString locatorSetName ) const; Vector3 GetLocatorPositionFromSet( int index, bool inWorldSpace, BlueSharedString locatorSetName ); Vector3 GetLocatorRotationFromSet( int index, bool inWorldSpace, BlueSharedString locatorSetName ); - bool GetLocatorPosition( Vector3* out, int index, bool inWorldSpace, BlueSharedString locatorSetName ); - bool GetLocatorDirection( Vector3* out, int index, bool inWorldSpace, BlueSharedString locatorSetName ); + bool GetLocatorPosition( Vector3 * out, int index, bool inWorldSpace, BlueSharedString locatorSetName ); + bool GetLocatorDirection( Vector3 * out, int index, bool inWorldSpace, BlueSharedString locatorSetName ); int GetGoodLocatorIndex( const Vector3& position, BlueSharedString locatorSetName ); // Function to find closest locator without worrying about direction of locator int GetCloseLocatorIndex( const Vector3& position, BlueSharedString locatorSetName ); @@ -469,8 +478,14 @@ BLUE_CLASS( EveSpaceObject2 ): // access to curves void SetModelRotationCurve( ITriQuaternionFunctionPtr rotationCurve ); void SetModelTranslationCurve( ITriVectorFunctionPtr translationCurve ); - ITriQuaternionFunctionPtr GetModelRotationCurve() const { return m_modelRotation; }; - ITriVectorFunctionPtr GetModelTranslationCurve() const { return m_modelTranslation; }; + ITriQuaternionFunctionPtr GetModelRotationCurve() const + { + return m_modelRotation; + }; + ITriVectorFunctionPtr GetModelTranslationCurve() const + { + return m_modelTranslation; + }; // access to dna void SetDnaString( const char* dna ); @@ -489,10 +504,10 @@ BLUE_CLASS( EveSpaceObject2 ): uint32_t GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const; void UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType shaderType, uint32_t size, void* ); - void GetPerObjectStructs( EveSpaceObjectVSData& vsData, EveSpaceObjectPSData& psData ) const; + void GetPerObjectStructs( EveSpaceObjectVSData & vsData, EveSpaceObjectPSData & psData ) const; // external parameters - void AddExternalParameter( Tr2ExternalParameter* externalParameter ); + void AddExternalParameter( Tr2ExternalParameter * externalParameter ); std::map GetControllerVariables() const; @@ -535,7 +550,7 @@ BLUE_CLASS( EveSpaceObject2 ): void GetBatchesFromOverlayVector( ITriRenderBatchAccumulator * batches, const Tr2PerObjectData* perObjectData, TriBatchType batchType, Tr2MeshBase* mesh ); // Consideration for child classes - void PushChildrenAndDecalRenderables( std::vector& renderables ); + void PushChildrenAndDecalRenderables( std::vector & renderables ); virtual void UpdateWorldTransform( Be::Time time ); @@ -550,7 +565,7 @@ BLUE_CLASS( EveSpaceObject2 ): bool m_isAnimated; bool m_castShadow; std::vector m_shadowMeshOpaqueAreas; - + Matrix m_worldTransform; Matrix m_invWorldTransform; Vector3 m_worldPosition; // used to expose the position of the object to python @@ -599,7 +614,7 @@ BLUE_CLASS( EveSpaceObject2 ): float m_estimatedPixelDiameterWithChildren; float m_meshScreenSize; - + Tr2GrannyAnimationPtr m_animationUpdater; ///////////////////////////////////////////////////////////////////////////////////// @@ -671,12 +686,12 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // locator sets PEveLocatorSetsVector m_locatorSets; - + ///////////////////////////////////////////////////////////////////////////////////// // Dynamic lighting PTr2LightVector m_lights; - + Color m_albedoColor; float m_secondaryLightingSphereRadius; @@ -684,7 +699,7 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // children - PIEveTransformVector m_children; + PIEveTransformVector m_children; virtual bool DisplayChildren() const; ///////////////////////////////////////////////////////////////////////////////////// @@ -699,7 +714,7 @@ BLUE_CLASS( EveSpaceObject2 ): ///////////////////////////////////////////////////////////////////////////////////// // dirt levels float m_dirtLevel; - + Be::Time m_lastCurveUpdateTime; Be::Time m_lastUpdateTransformTime; // Children transforms @@ -707,12 +722,12 @@ BLUE_CLASS( EveSpaceObject2 ): Vector3d m_previousPosition; Tr2BindingVector3Ptr m_positionDelta; PTriCurveSetVector m_curveSets; - + ///////////////////////////////////////////////////////////////////////////////////// // Object space damage locator information - virtual void GetLocatorInObjectSpace( Vector3& position, Vector3& direction, const Locator& locator ) const; + virtual void GetLocatorInObjectSpace( Vector3 & position, Vector3 & direction, const Locator& locator ) const; + - ///////////////////////////////////////////////////////////////////////////////////// // Observer position virtual Matrix GetObserverTransform(); @@ -726,19 +741,21 @@ BLUE_CLASS( EveSpaceObject2 ): ITr2AudGeometryPtr GetAudioGeometry() const; public: - virtual bool IsAudioOccluder() const override { return m_isAudioOccluder; } + virtual bool IsAudioOccluder() const override + { + return m_isAudioOccluder; + } protected: - void SetAudioGeometry( ITr2AudGeometry* audioGeometry ); + void SetAudioGeometry( ITr2AudGeometry * audioGeometry ); void UnregisterAudioGeometry(); void RegisterAudioGeometry(); static std::atomic s_nextAudioInstanceId; - private: - +private: #if BLUE_WITH_PYTHON - static PyObject* PyTransformLocators( PyObject* self, PyObject* args ); + static PyObject* PyTransformLocators( PyObject * self, PyObject * args ); #endif bool m_dynamicBoundingSphereEnabled; @@ -750,12 +767,11 @@ BLUE_CLASS( EveSpaceObject2 ): EntityComponents::ReflectionMode m_reflectionMode; - void UpdateRtMesh(const EveUpdateContext& updateContext); + void UpdateRtMesh( const EveUpdateContext& updateContext ); void UpdateRtSkeleton(); mutable Tr2ConstantBufferAL m_rtPerObjectData; Tr2RingBufferOffsets m_boneOffsets; - }; TYPEDEF_BLUECLASS( EveSpaceObject2 ); diff --git a/trinity/Eve/SpaceObject/EveSpaceObject2_Blue.cpp b/trinity/Eve/SpaceObject/EveSpaceObject2_Blue.cpp index f6c3e80c1..3564b07e5 100644 --- a/trinity/Eve/SpaceObject/EveSpaceObject2_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveSpaceObject2_Blue.cpp @@ -29,41 +29,41 @@ BLUE_DEFINE_ABSTRACT( EveSpaceObject2 ); namespace { - void TransformLocator( Vector3& position, Quaternion& rotation, int boneIndex, Tr2GrannyAnimation* animation ) +void TransformLocator( Vector3& position, Quaternion& rotation, int boneIndex, Tr2GrannyAnimation* animation ) +{ + if( boneIndex > 0 && animation && animation->IsInitialized() ) { - if( boneIndex > 0 && animation && animation->IsInitialized() ) + size_t boneCount = size_t( animation->GetMeshBoneCount() ); + if( boneCount ) { - size_t boneCount = size_t( animation->GetMeshBoneCount() ); - if( boneCount ) - { - const Float4x3* bones = animation->GetMeshBoneMatrixList(); - Matrix boneTF = IdentityMatrix(); - TriMatrixCopyFrom3x4( &boneTF, &bones[boneIndex] ); - position = XMVector3TransformCoord( position, boneTF ); + const Float4x3* bones = animation->GetMeshBoneMatrixList(); + Matrix boneTF = IdentityMatrix(); + TriMatrixCopyFrom3x4( &boneTF, &bones[boneIndex] ); + position = XMVector3TransformCoord( position, boneTF ); - rotation = XMQuaternionMultiply( rotation, XMQuaternionRotationMatrix( boneTF ) ); - } + rotation = XMQuaternionMultiply( rotation, XMQuaternionRotationMatrix( boneTF ) ); } } +} - void ApplyModelTransform( Vector3& position, Quaternion& rotation, ITriVectorFunctionPtr modelTranslationCurve, ITriQuaternionFunctionPtr modelRotationCurve ) +void ApplyModelTransform( Vector3& position, Quaternion& rotation, ITriVectorFunctionPtr modelTranslationCurve, ITriQuaternionFunctionPtr modelRotationCurve ) +{ + if( modelTranslationCurve ) { - if( modelTranslationCurve ) - { - Vector3 pos( 0, 0, 0 ); - modelTranslationCurve->GetValueAt( &pos, Be::Time() ); - position += pos; - } + Vector3 pos( 0, 0, 0 ); + modelTranslationCurve->GetValueAt( &pos, Be::Time() ); + position += pos; + } - if( modelRotationCurve ) - { - Quaternion quat( 0, 0, 0, 1 ); - modelRotationCurve->GetValueAt( &quat, Be::Time() ); - position = XMVector3Rotate( position, quat ); - rotation = XMQuaternionMultiply( rotation, quat ); - } + if( modelRotationCurve ) + { + Quaternion quat( 0, 0, 0, 1 ); + modelRotationCurve->GetValueAt( &quat, Be::Time() ); + position = XMVector3Rotate( position, quat ); + rotation = XMQuaternionMultiply( rotation, quat ); } } +} PyObject* EveSpaceObject2::PyTransformLocators( PyObject* self, PyObject* args ) { @@ -102,7 +102,7 @@ PyObject* EveSpaceObject2::PyTransformLocators( PyObject* self, PyObject* args ) else if( PySequence_Check( pyLocators ) ) { PyObject* result = PyList_New( PySequence_Size( pyLocators ) ); - for( ssize_t i = 0; ; ++i ) + for( ssize_t i = 0;; ++i ) { auto item = PySequence_GetItem( pyLocators, i ); if( !item ) @@ -117,7 +117,7 @@ PyObject* EveSpaceObject2::PyTransformLocators( PyObject* self, PyObject* args ) !BlueExtractVector( PyTuple_GET_ITEM( item, 1 ), &rotation.x, 4 ) || !PyLong_Check( PyTuple_GET_ITEM( item, 2 ) ) ) { Py_DECREF( item ); - PyErr_SetString( PyExc_TypeError, "arument must be a sequence of (position, rotation, boneIndex) tuples" ); + PyErr_SetString( PyExc_TypeError, "arument must be a sequence of (position, rotation, boneIndex) tuples" ); return nullptr; } int boneIndex = int( PyLong_AsLong( PyTuple_GET_ITEM( item, 2 ) ) ); @@ -135,7 +135,7 @@ PyObject* EveSpaceObject2::PyTransformLocators( PyObject* self, PyObject* args ) } return result; } - PyErr_SetString( PyExc_TypeError, "arument must be a sequence of (position, rotation, boneIndex) tuples" ); + PyErr_SetString( PyExc_TypeError, "arument must be a sequence of (position, rotation, boneIndex) tuples" ); return nullptr; } #endif @@ -170,176 +170,134 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() MAP_ATTRIBUTE( "dna", m_dna, "If created by the SOF, this is the DNA string", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "activationStrength", m_activationStrength, "Ship's activation strength", Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "Specifies whether to render the object or not", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "mute", m_mute, "", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "update", m_update, "Specifies whether to update the object or not", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "castShadow", m_castShadow, "If set, shadow is enabled", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isAnimated", m_isAnimated, "If set, we have animations", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isPickable", m_isPickable, "Enables/disables picking for the object", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "mesh", m_mesh, "Mesh for rendering space object", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "meshLod", m_mesh, "Mesh with levels-of-detail for rendering space object\n:jessica-hidden: True", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "locatorSets", m_locatorSets, "Set of Blue structure lists of locators identified by a name", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translationCurve", m_ballPosition, "Vector function slot for attaching a destiny ball to set the position of a ship", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "rotationCurve", m_ballRotation, "Quaternion function slot for attaching a destiny ball to set the rotation of a ship", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "modelRotationCurve", m_modelRotation, "Used to add rotations to the basic rotation curve", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "modelTranslationCurve", m_modelTranslation, "Used to add animated translations to ships", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "worldPosition", m_worldPosition, "Position in world space", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "worldRotation", m_worldRotation, "Rotation in world space", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "modelScale", m_modelScale, "Scaling of this object (ONLY USED BY ASTEROIDS!)", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "attachments", m_attachments, "Item sets attached to the object", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "locators", m_locators, "Locators for things such as turrets, boosters, etc. Locators can also come from a skeleton.", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "observers", m_observers, "Observers for pushing data between modules every frame. Currently used to push locator data out to the audio2 module.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) MAP_PROPERTY( "audioGeometry", GetAudioGeometry, SetAudioGeometry, "Audio geometry interface for Wwise Spatial Audio occlusion and diffraction processing." ) MAP_ATTRIBUTE( "impactOverlay", m_impactOverlay, "object for rendering damage/impact fx on this space object.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "decals", m_decals, "list of all decals on this space object.", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "estimatedPixelDiameter", m_estimatedPixelDiameter, "Estimated pixel diameter given the current view/projection transforms.\n", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "estimatedPixelDiameterWithChildren", m_estimatedPixelDiameterWithChildren, "Estimated pixel diameter given the current view/projection transforms.\n", - Be::READ - ) + Be::READ ) MAP_ATTRIBUTE( "clipSphereFactor", m_clipSphereFactor, "Object's clip state", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "clipSphereFactor2", m_clipSphereFactor2, "Object's clip state for the second clip sphere", Be::READWRITE | Be::NOTIFY ) @@ -358,87 +316,64 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() MAP_ATTRIBUTE( "generatedShapeEllipsoidCenter", m_generatedShapeEllipsoidCenter, "Generated or User-authored ellipsoid data for center", Be::READ ) MAP_ATTRIBUTE( "generatedShapeEllipsoidRadius", m_generatedShapeEllipsoidRadius, "Generated or User-authored ellipsoid data for radii", Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectChildren", m_effectChildren, "", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "children", m_children, "", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curvesets for animating things", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "inheritProperties", m_inheritProperties, "", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "dynamicBoundingSphereEnabled", m_dynamicBoundingSphereEnabled, "Indicate if object uses dynamic bounding spheres", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( "GetBoneCount", GetBoneCount, "Returns the number of bones in the granny." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetBoundingSphereRadius", GetBoundingSphereRadius, - "Returns the bounding sphere radius." - ) - MAP_METHOD_AND_WRAP - ( + "Returns the bounding sphere radius." ) + MAP_METHOD_AND_WRAP( "GetBoundingSphereCenter", GetBoundingSphereCenter, - "Returns the bounding sphere center." - ) + "Returns the bounding sphere center." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CalculateSkinnedBoundingSphere", CalculateSkinnedBoundingSphere, - "Calculate and return skinned bounding sphere." - ) - MAP_METHOD_AND_WRAP - ( + "Calculate and return skinned bounding sphere." ) + MAP_METHOD_AND_WRAP( "CalculateSkinnedBoundingBoxFromTransform", CalculateSkinnedBoundingBoxFromTransform, "Calculate and return bounding sphere of the object projected by the transform provided.\n" - ":param transform: object transform matrix" - ) + ":param transform: object transform matrix" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RebuildBoundingSphereInformation", RebuildBoundingSphereInformation, - "Rebuilds the bounding data." - ) - MAP_METHOD_AND_WRAP - ( + "Rebuilds the bounding data." ) + MAP_METHOD_AND_WRAP( "GetLocalBoundingBox", GetLocalBoundingBoxFromScript, - "Returns the bounding box of the object in local coordinates." - ) - MAP_METHOD_AND_WRAP - ( + "Returns the bounding box of the object in local coordinates." ) + MAP_METHOD_AND_WRAP( "PlayAnimation", PlayAnimationOnce, "Plays the given animation, replacing whatever animation was playing before.\n" - ":param name: animation name" - ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + ":param name: animation name" ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "PlayAnimationEx", PlayAnimationEx, 1, @@ -447,18 +382,14 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() ":param loopCount: can be 0 to loop forever.\n" ":param delay: time (in seconds) from now before animation should start playing.\n" ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" - ":param clearWhenDone: boolean True to clear animation when done, boolean False to keep it playing. Defaults to True\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param clearWhenDone: boolean True to clear animation when done, boolean False to keep it playing. Defaults to True\n" ) + MAP_METHOD_AND_WRAP( "ChainAnimation", ChainAnimation, "Plays the given animation, starting when currently playing animation finishes.\n" "If it is looping then it is replaced at the end of the current loop.\n" - ":param name: animation name" - ) - MAP_METHOD_AND_WRAP - ( + ":param name: animation name" ) + MAP_METHOD_AND_WRAP( "ChainAnimationEx", ChainAnimationEx, "Plays the given animation, starting when currently playing animation finishes.\n" @@ -466,76 +397,57 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() ":param name: animation name\n" ":param loopCount: can be 0 to loop forever.\n" ":param delay: time (in seconds) from now before animation should start playing.\n" - ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" ) + MAP_METHOD_AND_WRAP( "EndAnimation", EndAnimation, "EndAnimation()\n\n" - "Stops currently playing animation at the end of the current loop iteration." - ) - MAP_METHOD_AND_WRAP - ( + "Stops currently playing animation at the end of the current loop iteration." ) + MAP_METHOD_AND_WRAP( "ClearAnimations", ClearAnimations, "ClearAnimations()\n\n" - "Abruptly ends all animations." - ) - MAP_METHOD_AND_WRAP - ( + "Abruptly ends all animations." ) + MAP_METHOD_AND_WRAP( "FreezeHighDetailMesh", FreezeHighDetailMesh, - "Freezes the high detail mesh and prevents LOD selection or resource unloading." - ) + "Freezes the high detail mesh and prevents LOD selection or resource unloading." ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "overlayEffects", m_overlayEffects, "A list of effects that are added to the current LOD. Rendered additive.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "animationUpdater", m_animationUpdater, "Granny animation exposure", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "positionDelta", m_positionDelta, "Change in global position of the object during the frame", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "albedoColor", m_albedoColor, "Space object overall albedo color. Used for secondary lighting. In linear RGB space.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "secondaryLightingSphereRadius", m_secondaryLightingSphereRadius, "Sphere radius used to approximate space object for secondary lighting.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "lastDamageLocatorHit", m_lastDamageLocatorHit, "The last damagelocator hit.", - Be::READ - ) + Be::READ ) MAP_METHOD_AND_WRAP( "GetDamageLocatorCount", GetDamageLocatorCount, "Get number of damage locators on this ship" ) MAP_METHOD_AND_WRAP( @@ -565,81 +477,72 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() ":param shield: shield damage\n" ":param armor: armor damage\n" ":param hull: hull damage\n" - ":param createArmorImpacts: True to create armor impacts\n" - ) + ":param createArmorImpacts: True to create armor impacts\n" ) MAP_METHOD_AND_WRAP( "SetImpactAnimation", SetImpactAnimation, "Set the impact's animations.\n" ":param name: animation name\n" ":param enable: enable/disable animation\n" - ":param duration: animation duration\n" - ) + ":param duration: animation duration\n" ) MAP_METHOD_AND_WRAP( "GetGoodLocatorIndex", GetCloseLocatorIndex, "Get the closest locator in set to target.\n" ":param position: position of target\n" - ":param locatorSetName: name of locator set \n" - )MAP_METHOD_AND_WRAP( + ":param locatorSetName: name of locator set \n" ) + MAP_METHOD_AND_WRAP( "GetCloseLocatorIndex", GetCloseLocatorIndex, "Get the closest locator in set to target, does not mind about direction of locator.\n" ":param position: position of target\n" - ":param locatorSetName: name of locator set \n" - ) - MAP_METHOD_AND_WRAP( - "GetLocatorPositionFromSet", - GetLocatorPositionFromSet, - "locator position from a set Specified by name\n" - ":param index: locator index\n" - ":param inWorldSpace: position of target\n" - ":param locatorSetName: name of locator set \n" - ) + ":param locatorSetName: name of locator set \n" ) + MAP_METHOD_AND_WRAP( + "GetLocatorPositionFromSet", + GetLocatorPositionFromSet, + "locator position from a set Specified by name\n" + ":param index: locator index\n" + ":param inWorldSpace: position of target\n" + ":param locatorSetName: name of locator set \n" ) + MAP_METHOD_AND_WRAP( + "GetLocatorRotationFromSet", + GetLocatorRotationFromSet, + "locator rotation in worldspace\n" + ":param index: locator index\n" + ":param inWorldSpace: position of target\n" + ":param locatorSetName: name of locator set \n" ) + MAP_METHOD_AND_WRAP( "ClearImpactDamage", ClearImpactDamage, "Clear all the impact/damage effects." ) + MAP_METHOD_AND_WRAP( + "CreateImpact", + CreateImpact, + "debug only\n" + ":param idx: damage locator index\n" + ":param direction: incoming damage direction\n" + ":param lifeTime: effect time\n" + ":param size: effect size" ); MAP_METHOD_AND_WRAP( - "GetLocatorRotationFromSet", - GetLocatorRotationFromSet, - "locator rotation in worldspace\n" - ":param index: locator index\n" - ":param inWorldSpace: position of target\n" - ":param locatorSetName: name of locator set \n" - ) - MAP_METHOD_AND_WRAP( "ClearImpactDamage", ClearImpactDamage, "Clear all the impact/damage effects." ) - MAP_METHOD_AND_WRAP( - "CreateImpact", - CreateImpact, - "debug only\n" - ":param idx: damage locator index\n" + "CreateImpactFromPosition", + CreateImpactFromPosition, + "Creates an impact facing a position\n" + ":param position: damage source position\n" ":param direction: incoming damage direction\n" ":param lifeTime: effect time\n" - ":param size: effect size" - ); - MAP_METHOD_AND_WRAP( - "CreateImpactFromPosition", - CreateImpactFromPosition, - "Creates an impact facing a position\n" - ":param position: damage source position\n" - ":param direction: incoming damage direction\n" - ":param lifeTime: effect time\n" - ":param size: effect size" - ); - MAP_METHOD_AND_WRAP( "IsImpostor", IsImpostor, "Is this object in the impostor mode?" ); - - MAP_ATTRIBUTE - ( - "modelWorldPosition", - m_boundingSphereWorldCenter, - "The spaceobject's model world position", - Be::READ - ) - - MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When is this object rendered into the cubemap", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, EntityComponents::ReflectionModeChooser ); - - MAP_ATTRIBUTE( "customShaderData", m_psData.customData, "Custom data passed to space object shaders via per-object data", Be::READWRITE ) - - MAP_ATTRIBUTE( "lights", m_lights, "List of dynamic lights", Be::READ | Be::PERSIST | Be::NOTIFY ); - - MAP_ATTRIBUTE( "externalParameters", m_externalParameters, "List of external parameters to bind to object elements", Be::READ | Be::PERSIST ) + ":param size: effect size" ); + MAP_METHOD_AND_WRAP( "IsImpostor", IsImpostor, "Is this object in the impostor mode?" ); + + MAP_ATTRIBUTE( + "modelWorldPosition", + m_boundingSphereWorldCenter, + "The spaceobject's model world position", + Be::READ ) + + MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When is this object rendered into the cubemap", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, EntityComponents::ReflectionModeChooser ); + + MAP_ATTRIBUTE( "customShaderData", m_psData.customData, "Custom data passed to space object shaders via per-object data", Be::READWRITE ) + + MAP_ATTRIBUTE( "lights", m_lights, "List of dynamic lights", Be::READ | Be::PERSIST | Be::NOTIFY ); + + MAP_ATTRIBUTE( "externalParameters", m_externalParameters, "List of external parameters to bind to object elements", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "controllers", m_controllers, "List of object controllers", Be::READ | Be::PERSIST ) MAP_METHOD_AND_WRAP( @@ -647,47 +550,41 @@ const Be::ClassInfo* EveSpaceObject2::ExposeToBlue() SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) + "Start all controllers" ) MAP_METHOD_AND_WRAP( "GetControllerVariables", GetControllerVariables, - "Returns all previously set contrller variables" - ) + "Returns all previously set contrller variables" ) MAP_METHOD_AND_WRAP( "GetLocatorTransform", GetEveLocatorTransform, "Returns locator to object transform (taking bone bindings in account)\n" - ":param locator: locator name belonging to this object" - ) + ":param locator: locator name belonging to this object" ) MAP_METHOD_AND_WRAP( "GetLastUsedMeshLod", GetLastUsedMeshLod, "Returns last used mesh LOD index. For debugging purposes" ) - MAP_METHOD_AND_WRAP( - "SetProceduralContainerVariable", - SetProceduralContainerVariable, - "Set variable for all applicable ProceduralContainer\n" - ":param name: variable name\n" - ":param value: new variable value\n" - ) + MAP_METHOD_AND_WRAP( + "SetProceduralContainerVariable", + SetProceduralContainerVariable, + "Set variable for all applicable ProceduralContainer\n" + ":param name: variable name\n" + ":param value: new variable value\n" ) #if BLUE_WITH_PYTHON MAP_METHOD( diff --git a/trinity/Eve/SpaceObject/EveStation2.cpp b/trinity/Eve/SpaceObject/EveStation2.cpp index d44668d84..8b3a6920f 100644 --- a/trinity/Eve/SpaceObject/EveStation2.cpp +++ b/trinity/Eve/SpaceObject/EveStation2.cpp @@ -11,7 +11,7 @@ // Description: // Initialize data members // -------------------------------------------------------------------------------- -EveStation2::EveStation2( IRoot* lockobj ) : +EveStation2::EveStation2( IRoot* lockobj ) : EveSpaceObject2( lockobj ) { } @@ -37,7 +37,7 @@ void EveStation2::PrepareShaderData( const EveUpdateContext& updateContext ) // -------------------------------------------------------------------------------- // Description: -// Override base ::UpdateSyncronous() function, so we can update the turrets and +// Override base ::UpdateSyncronous() function, so we can update the turrets and // their positions (if they are attached to animated bones!) // -------------------------------------------------------------------------------- void EveStation2::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) diff --git a/trinity/Eve/SpaceObject/EveStation2.h b/trinity/Eve/SpaceObject/EveStation2.h index 1b99bca2c..9ee0f1798 100644 --- a/trinity/Eve/SpaceObject/EveStation2.h +++ b/trinity/Eve/SpaceObject/EveStation2.h @@ -10,7 +10,7 @@ BLUE_DECLARE( EveStation2 ); BLUE_DECLARE( EveSpriteSet ); BLUE_DECLARE_VECTOR( EveSpriteSet ); -BLUE_CLASS( EveStation2 ): +BLUE_CLASS( EveStation2 ) : public EveSpaceObject2 { public: @@ -21,7 +21,7 @@ BLUE_CLASS( EveStation2 ): ///////////////////////////////////////////////////////////////////////////////////// // Overrides of EveSpaceObject2 implementations - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); void PrepareShaderData( const EveUpdateContext& updateContext ) override; }; diff --git a/trinity/Eve/SpaceObject/EveStation2_Blue.cpp b/trinity/Eve/SpaceObject/EveStation2_Blue.cpp index e178a4338..47a8cb80a 100644 --- a/trinity/Eve/SpaceObject/EveStation2_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveStation2_Blue.cpp @@ -7,10 +7,10 @@ BLUE_DEFINE( EveStation2 ); const Be::ClassInfo* EveStation2::ExposeToBlue() { - EXPOSURE_BEGIN( EveStation2, "" ) - MAP_INTERFACE( EveStation2 ) + EXPOSURE_BEGIN( EveStation2, "" ) + MAP_INTERFACE( EveStation2 ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( ITr2Renderable ) - EXPOSURE_CHAINTO( EveSpaceObject2 ) + EXPOSURE_CHAINTO( EveSpaceObject2 ) } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/EveSwarm.cpp b/trinity/Eve/SpaceObject/EveSwarm.cpp index 847955276..d362aab48 100644 --- a/trinity/Eve/SpaceObject/EveSwarm.cpp +++ b/trinity/Eve/SpaceObject/EveSwarm.cpp @@ -20,7 +20,7 @@ #include "Eve/Turret/EveTurretSet.h" EveSwarmRenderable::EveSwarmRenderable( IRoot* lockobj ) : -PARENTLOCK( m_decals ) + PARENTLOCK( m_decals ) { memset( &m_psData, 0, sizeof( EveSpaceObjectPSData ) ); memset( &m_vsData, 0, sizeof( EveSpaceObjectVSData ) ); @@ -38,7 +38,7 @@ void EveSwarmRenderable::GetBatches( ITriRenderBatchAccumulator* batches, TriBat { return; } - + Tr2MeshAreaVector* areas = m_mesh->GetAreas( batchType ); // transparent needs sorted meshareas if( batchType != TRIBATCHTYPE_TRANSPARENT ) @@ -100,7 +100,7 @@ bool EveSwarmRenderable::HasTransparentBatches() { if( m_mesh ) { - return !(m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty()); + return !( m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty() ); } return false; @@ -122,7 +122,7 @@ void EveSwarmRenderable::SetWorldTransform( const Matrix& transform ) m_psData.worldTransform = m_vsData.worldTransform; m_psData.worldTransformLast = m_vsData.worldTransformLast; m_psData.invWorldTransform = m_vsData.invWorldTransform; - + m_perObjectDataVs.InvalidateBufferData(); m_perObjectDataPs.InvalidateBufferData(); } @@ -151,14 +151,14 @@ void EveSwarmRenderable::SetShaderData( const EveSpaceObjectVSData& vsData, cons m_psData.shipData.w = psData.shipData.w; } -void EveSwarmRenderable::InitDecals( const PEveSpaceObjectDecalVector &decals ) +void EveSwarmRenderable::InitDecals( const PEveSpaceObjectDecalVector& decals ) { - for (EveSpaceObjectDecalVector::const_iterator it = decals.begin(); it != decals.end(); ++it) + for( EveSpaceObjectDecalVector::const_iterator it = decals.begin(); it != decals.end(); ++it ) { EveSpaceObjectDecalPtr decal; decal.CreateInstance(); decal->CopyFrom( *it ); - + m_decals.Append( decal->GetRawRoot() ); } } @@ -171,7 +171,7 @@ void EveSwarmRenderable::PushDecals( std::vector& renderables, { DecalMeshCache meshCache; // run over every decal and update it - for (EveSpaceObjectDecalVector::const_iterator it = m_decals.begin(); it != m_decals.end(); ++it) + for( EveSpaceObjectDecalVector::const_iterator it = m_decals.begin(); it != m_decals.end(); ++it ) { // now prep to get the renderables ( *it )->GetRenderables( renderables, meshCache, geometryRes, screensize ); @@ -285,17 +285,16 @@ void EveSwarmRenderable::GetShadowBatches( ITriRenderBatchAccumulator* batches, return; } - Tr2MeshAreaVector* areas = m_mesh->GetAreas(TRIBATCHTYPE_OPAQUE); - for (auto& area : *areas) + Tr2MeshAreaVector* areas = m_mesh->GetAreas( TRIBATCHTYPE_OPAQUE ); + for( auto& area : *areas ) { if( !area->GetDisplay() ) { continue; } Tr2RenderBatch batch = CreateGeometryBatch( lod, area, perObjectData ); - batches->Commit(batch); + batches->Commit( batch ); } - } Tr2PerObjectData* EveSwarmRenderable::GetShadowPerObjectData( ITriRenderBatchAccumulator* accumulator ) @@ -374,7 +373,7 @@ void EveSwarm::RebuildCachedData( BlueAsyncRes* p ) EveShip2::RebuildCachedData( p ); for( auto it = m_renderables.begin(); it != m_renderables.end(); ++it ) { - (*it)->InitializeRenderable( this, m_mesh ); + ( *it )->InitializeRenderable( this, m_mesh ); } } @@ -432,7 +431,7 @@ void EveSwarm::UpdateTurretsAsyncronous( const EveUpdateContext& updateContext ) IEveSpaceObject2::ParentData pd; memset( &pd, 0, sizeof( ParentData ) ); - pd.transform = *GetTurretTransform( (*it)->GetSwarmID() ); + pd.transform = *GetTurretTransform( ( *it )->GetSwarmID() ); pd.shipData = m_spaceObjectShipData; pd.clipSphereCenter = m_psData.clipSphereCenter; pd.clipRadiusSq = m_psData.clipRadiusSq; @@ -471,17 +470,17 @@ void EveSwarm::UpdateAsyncronous( const EveUpdateContext& context ) for( unsigned i = 0; i < m_vehicles.size() && rit != m_renderables.end(); i++, rit++ ) { Matrix world = RotationMatrix( m_vehicles[i].rotation ) * TranslationMatrix( m_vehicles[i].position ); - (*rit)->SetWorldTransform( world ); - + ( *rit )->SetWorldTransform( world ); + if( m_boosters ) { Be::Time time = context.GetTime(); float deltaT = context.GetDeltaT(); float speed = Length( m_vehicles[i].velocity ); m_boosters->Update( deltaT, time, world, speed, m_vehicles[i].acceleration, m_vehicles[i].rotation, i ); - (*rit)->SetBoosterIntensity( m_boosters->GetBoosterIntensity() ); + ( *rit )->SetBoosterIntensity( m_boosters->GetBoosterIntensity() ); } - (*rit)->SetShaderData( m_vsData, m_psData ); + ( *rit )->SetShaderData( m_vsData, m_psData ); } if( m_boosters ) { @@ -506,7 +505,7 @@ void EveSwarm::UpdateSwarm( Be::Time t ) { m_timeLast = t; } - + Vector3 worldTransformLast = m_worldPosition; UpdateWorldTransform( t ); @@ -518,17 +517,17 @@ void EveSwarm::UpdateSwarm( Be::Time t ) m_vehicles[i].position = m_worldPosition; } } - + float timeDelta = TimeAsFloat( t - m_timeLast ); float timeSeconds = TimeAsFloat( t - m_timeLast ) * m_behavior.m_timeMultiplier; if( timeSeconds > m_behavior.m_maxTime ) { timeSeconds = m_behavior.m_maxTime; } - + m_timeSinceUpdate += timeDelta; m_timeLast = t; - + bool updateNow = m_isVisible || m_timeSinceUpdate >= m_lodUpdateTime; if( !updateNow ) { @@ -573,7 +572,7 @@ void EveSwarm::UpdateSwarm( Be::Time t ) { m_started = true; } - + Vector3 center( 0, 0, 0 ); Vector3 alignment( 0, 0, 0 ); if( updateNow ) @@ -625,7 +624,7 @@ void EveSwarm::UpdateSwarm( Be::Time t ) } // Never let the center of the squadron get more than m_maxDistance from the world position(client hangs for while f.x.) - center = 0.5f * (m_squadBoundsMin + m_squadBoundsMax); + center = 0.5f * ( m_squadBoundsMin + m_squadBoundsMax ); Vector3 d = m_worldPosition - center; float distance = Length( d ); float maxDistance = Lerp( m_behavior.m_maxDistance0, m_behavior.m_maxDistance1, TriLinearize( m_behavior.m_speed0, m_behavior.m_speed1, Length( m_worldVelocity ) ) ); @@ -644,7 +643,7 @@ void EveSwarm::UpdateSwarm( Be::Time t ) } // -------------------------------------------------------------------------------- // Description: -// Registers space object attachments (sprite and spotlight sets) with quad +// Registers space object attachments (sprite and spotlight sets) with quad // renderer. // Arguments: // quadRenderer - quad renderer @@ -653,7 +652,7 @@ void EveSwarm::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ) { for( auto it = m_attachments.begin(); it != m_attachments.end(); ++it ) { - (*it)->RegisterWithQuadRenderer( quadRenderer ); + ( *it )->RegisterWithQuadRenderer( quadRenderer ); } if( m_boosters ) { @@ -678,7 +677,7 @@ void EveSwarm::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRendere { for( auto it = m_attachments.begin(); it != m_attachments.end(); ++it ) { - (*it)->AddToQuadRenderer( quadRenderer, *(*rit)->GetWorldTransform(), 1, 1, nullptr, 0 ); + ( *it )->AddToQuadRenderer( quadRenderer, *( *rit )->GetWorldTransform(), 1, 1, nullptr, 0 ); } } if( DisplayBoosters() ) @@ -712,7 +711,7 @@ void EveSwarm::RenderDebugInfo( ITr2DebugRenderer2& renderer ) renderer.DrawLine( this, pos, pos + m_vehicles[i].velocity, 0xffff00ff ); renderer.DrawLine( this, pos, pos + m_vehicles[i].acceleration, 0xff0000ff ); } - + if( renderer.HasOption( this, "Forces" ) && m_debugInfo.size() > i ) { renderer.DrawLine( this, pos, pos + m_debugInfo[i].alignment, 0xff7f7f00 ); @@ -744,7 +743,7 @@ void EveSwarm::PushRenderables( std::vector& renderables ) // are decals visible? if( m_mesh && m_isMeshVisible ) { - for (auto it = m_renderables.begin(); it != m_renderables.end(); it++) + for( auto it = m_renderables.begin(); it != m_renderables.end(); it++ ) { renderables.push_back( *it ); ( *it )->PushDecals( renderables, m_meshScreenSize ); @@ -755,7 +754,7 @@ void EveSwarm::PushRenderables( std::vector& renderables ) void EveSwarm::UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) { EveShip2::UpdateVisibility( updateContext, parentTransform ); - + // are decals visible? if( m_mesh && m_isMeshVisible ) { @@ -799,7 +798,7 @@ void EveSwarm::UpdateWorldBounds() // Description: // GetBoundingSphere. See EveSpaceObject2 // -------------------------------------------------------------------------------- -bool EveSwarm::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const +bool EveSwarm::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) const { Vector4 s; EveShip2::GetBoundingSphere( s, query ); @@ -814,7 +813,7 @@ bool EveSwarm::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query ) c // how to do this on demand. // Original description: This version of the function should perform an update on the model / ball position // -------------------------------------------------------------------------------- -void EveSwarm::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void EveSwarm::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { if( m_swarmingEnabled ) { @@ -831,7 +830,7 @@ void EveSwarm::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) // Description: // From EveShip2 // -------------------------------------------------------------------------------- -void EveSwarm::GetModelCenterWorldPosition( Vector3 &position ) const +void EveSwarm::GetModelCenterWorldPosition( Vector3& position ) const { if( m_swarmingEnabled ) { @@ -847,7 +846,7 @@ void EveSwarm::GetModelCenterWorldPosition( Vector3 &position ) const // Description: // From EveShip2 // -------------------------------------------------------------------------------- -bool EveSwarm::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) +bool EveSwarm::GetLocalBoundingBox( Vector3& min, Vector3& max ) { if( m_mesh && m_mesh->GetBoundingBox( min, max ) ) { @@ -933,7 +932,7 @@ void EveSwarm::AddSwarmer() m_debugInfo.push_back( SwarmVehicleDebug() ); } m_count++; - + if( m_boosters ) { m_boosters->SetCount( m_count ); @@ -948,7 +947,7 @@ Vector3 EveSwarm::RemoveSwarmer() { if( m_vehicles.empty() ) { - return Vector3(0, 0, 0); + return Vector3( 0, 0, 0 ); } auto componentRegistry = GetComponentRegistry(); @@ -969,7 +968,7 @@ Vector3 EveSwarm::RemoveSwarmer() m_debugInfo.pop_back(); } m_count--; - + if( m_boosters ) { m_boosters->SetCount( m_count ); @@ -1147,7 +1146,7 @@ Vector3 EveSwarm::CalculateForces( int i0, std::vector& swarmers, auto wander = m_behavior.m_weightWander * Calculate_Wander( swarmers[i0], m_behavior.m_wanderDistance, m_behavior.m_wanderRadius, m_behavior.m_wanderFluctuation, timeSeconds ); auto cohesion = m_behavior.m_weightCohesion * Calculate_Cohesion( swarmers[i0].position, centerOfMass ); auto anchor = Calculate_Cohesion( swarmers[i0].position, followPosition ); - auto anchorDistance = Length( anchor ); + auto anchorDistance = Length( anchor ); anchorDistance = TriLinearize( m_behavior.m_anchorRadius0, m_behavior.m_anchorRadius1, anchorDistance ); anchor = anchorDistance * m_behavior.m_weightAnchor * anchor; auto align = m_behavior.m_weightAlign * alignment; @@ -1175,7 +1174,7 @@ Vector3 EveSwarm::CalculateForces( int i0, std::vector& swarmers, formationPosition = formationPosition - formationDirection * m_behavior.m_formationDistance * rankMultiplier - formationSide * m_behavior.m_formationDistance * rankMultiplier * 0.5f; } auto formation = m_behavior.m_weightFormation * Calculate_Cohesion( swarmers[i0].position, formationPosition ); - + // Debug info if( m_debugShowForces && m_debugInfo.size() > static_cast( i0 ) ) { @@ -1209,7 +1208,7 @@ inline Vector3 EveSwarm::Calculate_Separation( Vector3 p0, Vector3 p1 ) float length = Length( d ); if( length == 0.f ) { - return Vector3(TriRand() - 0.5f, TriRand() - 0.5f, TriRand() - 0.5f); + return Vector3( TriRand() - 0.5f, TriRand() - 0.5f, TriRand() - 0.5f ); } return Normalize( d ) * m_behavior.m_separationDistance / length; } @@ -1222,7 +1221,7 @@ Vector3 EveSwarm::Calculate_Wander( SwarmVehicle& s, float wanderDistance, float { // Evolve the target point on the 'sphere' around a point wanderDistance in front of our swarmer Vector3 target = s.wanderTarget; - Vector3 newOffset = Normalize( Vector3( 2*TriRand() - 1.f, 2*TriRand() - 1.f, 2*TriRand() - 1.f ) ); + Vector3 newOffset = Normalize( Vector3( 2 * TriRand() - 1.f, 2 * TriRand() - 1.f, 2 * TriRand() - 1.f ) ); newOffset *= fluctuation * radius * t; target += newOffset; target = Normalize( target ); diff --git a/trinity/Eve/SpaceObject/EveSwarm.h b/trinity/Eve/SpaceObject/EveSwarm.h index b36b3f901..6de1dc903 100644 --- a/trinity/Eve/SpaceObject/EveSwarm.h +++ b/trinity/Eve/SpaceObject/EveSwarm.h @@ -28,54 +28,58 @@ BLUE_CLASS( EveSwarmRenderable ) : explicit EveSwarmRenderable( IRoot* lockobj = nullptr ); ~EveSwarmRenderable(); - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; + + bool HasTransparentBatches() override; + float GetSortValue() override; - bool HasTransparentBatches() override; - float GetSortValue() override; + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ) override; - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) override; - ///////////////////////////////////////////////////////////////////////////////////// // PerObjectData void UpdatePerObjectBuffer( Tr2RenderContextEnum::ShaderType shaderType, uint32_t size, void* ); uint32_t GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const; - + ///////////////////////////////////////////////////////////////////////////////////// // EveSwarmRenderable - void InitializeRenderable( EveSwarm* owner, Tr2MeshBase* mesh ); + void InitializeRenderable( EveSwarm * owner, Tr2MeshBase * mesh ); void SetWorldTransform( const Matrix& transform ); - const Matrix* GetWorldTransform() const { return &m_worldTransform; } + const Matrix* GetWorldTransform() const + { + return &m_worldTransform; + } void SetBoosterIntensity( float intensity ); void SetShaderData( const EveSpaceObjectVSData& vsData, const EveSpaceObjectPSData& psData ); - void InitDecals( const PEveSpaceObjectDecalVector &decals ); - void PushDecals( std::vector& renderables, float screensize ); + void InitDecals( const PEveSpaceObjectDecalVector& decals ); + void PushDecals( std::vector & renderables, float screensize ); void UpdateDecalVisibility( const EveUpdateContext& updateContext, IEveSpaceObject2::ParentData& pd, Tr2GrannyAnimation* animationUpdater ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable IRoot* GetID( uint16_t ) override; - void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) override; + void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) override; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; - + ////////////////////////////////////////////////////////////////////////////////////// // IEveShadowCaster bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const override; - void GetShadowBatches( ITriRenderBatchAccumulator* batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize ) override; - Tr2PerObjectData* GetShadowPerObjectData( ITriRenderBatchAccumulator* accumulator ) override; + void GetShadowBatches( ITriRenderBatchAccumulator * batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize ) override; + Tr2PerObjectData* GetShadowPerObjectData( ITriRenderBatchAccumulator * accumulator ) override; ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; + private: Tr2MeshBasePtr m_mesh; BlueWeakRef m_owner; Matrix m_worldTransform; PEveSpaceObjectDecalVector m_decals; - + Tr2PersistentPerObjectData m_perObjectDataVs; Tr2PersistentPerObjectData m_perObjectDataPs; EveSpaceObjectPSData m_psData; @@ -93,7 +97,8 @@ struct SwarmVehicle position( 0, 0, 0 ), wanderTarget( 0, 0, 0 ), roll( 0.f ) - {} + { + } Quaternion rotation; Vector3 acceleration; @@ -118,7 +123,7 @@ BLUE_CLASS( EveSwarm ) : explicit EveSwarm( IRoot* lockobj = nullptr ); ~EveSwarm(); - + ///////////////////////////////////////////////////////////////////////////////////// // EveSwarm void AddSwarmer(); @@ -126,7 +131,7 @@ BLUE_CLASS( EveSwarm ) : void SetCount( int count ); void EnableSwarming( bool enable ); void PickFiringOrigin(); - + struct BehaviorProperties { BehaviorProperties() : @@ -157,15 +162,16 @@ BLUE_CLASS( EveSwarm ) : m_maxDeceleration( 200.f ), m_weightFormation( 1.f ), m_formationDistance( 50.f ) - {} + { + } float m_mass; float m_speedMultiplier; float m_speedMinimum; float m_agility; - - float m_maxDistance0; // Max allowed distance from ball - float m_maxDistance1; // Max allowed distance from ball + + float m_maxDistance0; // Max allowed distance from ball + float m_maxDistance1; // Max allowed distance from ball float m_timeMultiplier; // Time multiplier, mostly for debug float m_maxTime; // Never update by more than this, anything too long and things stop making sense @@ -189,8 +195,8 @@ BLUE_CLASS( EveSwarm ) : // looking random movement characteristics. float m_weightWander; float m_wanderFluctuation; // How fast the point on the sphere changes - float m_wanderDistance; // How far in front of the vehicle is the sphere - float m_wanderRadius; // Radius of the sphere + float m_wanderDistance; // How far in front of the vehicle is the sphere + float m_wanderRadius; // Radius of the sphere // Anchor: Steer vehicles toward the center point/ball float m_weightAnchor; @@ -206,55 +212,61 @@ BLUE_CLASS( EveSwarm ) : float m_weightFormation; float m_formationDistance; }; - void SetBehavior( const BehaviorProperties* behavior ) { m_behavior = *behavior; } + void SetBehavior( const BehaviorProperties* behavior ) + { + m_behavior = *behavior; + } ///////////////////////////////////////////////////////////////////////////////////// // EveShip2 overrides void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateTurretsAsyncronous( const EveUpdateContext& updateContext ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ) override; - void PushRenderables( std::vector& renderables ); - void RebuildCachedData( BlueAsyncRes* p ); - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - void GetModelCenterWorldPosition( Vector3 &position ) const; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + void PushRenderables( std::vector & renderables ); + void RebuildCachedData( BlueAsyncRes * p ); + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + void GetModelCenterWorldPosition( Vector3 & position ) const; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize virtual bool Initialize(); - + ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - virtual void GetDebugOptions( Tr2DebugRendererOptions& options ); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ); - + virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; void UnRegisterComponents() override; + protected: ///////////////////////////////////////////////////////////////////////////////////// // Object space damage locator information - virtual void GetLocatorInObjectSpace( Vector3& position, Vector3& direction, const Locator& locator ) const; - virtual bool GetDamageLocatorPosition( Vector3* out, int index, bool inWorldSpace ); - + virtual void GetLocatorInObjectSpace( Vector3 & position, Vector3 & direction, const Locator& locator ) const; + virtual bool GetDamageLocatorPosition( Vector3 * out, int index, bool inWorldSpace ); + ///////////////////////////////////////////////////////////////////////////////////// // EveShip2 override void UpdateWorldBounds(); void EstimatePixelDiameter( const TriFrustum& frustum ); Matrix GetObserverTransform() override; const Matrix* GetTurretTransform( unsigned int turretSetIndex ) const; - - void UpdateBoosters( const EveUpdateContext& updateContext ) override {} + + void UpdateBoosters( const EveUpdateContext& updateContext ) override + { + } void UpdateWorldTransform( Be::Time time ); private: @@ -292,9 +304,9 @@ BLUE_CLASS( EveSwarm ) : Vector3 CalculateForces( int i0, std::vector& swarmers, const Vector3& followPosition, const Vector3& centerOfMass, const Vector3& alignment, const Vector3& formationDirection, const Vector3& formationSide, float timeSeconds ); Vector3 Calculate_Cohesion( Vector3 p0, Vector3 p1 ); Vector3 Calculate_Separation( Vector3 p0, Vector3 p1 ); - Vector3 Calculate_Wander( SwarmVehicle& s, float wanderDistance, float radius, float fluctuation, float t ); - void UpdateOrientation( SwarmVehicle* s, float t ); - + Vector3 Calculate_Wander( SwarmVehicle & s, float wanderDistance, float radius, float fluctuation, float t ); + void UpdateOrientation( SwarmVehicle * s, float t ); + bool m_debugShowForces; void EnableSwarmForceDebug( bool enable ); }; diff --git a/trinity/Eve/SpaceObject/EveSwarm_Blue.cpp b/trinity/Eve/SpaceObject/EveSwarm_Blue.cpp index 1609d46a4..907ebfb08 100644 --- a/trinity/Eve/SpaceObject/EveSwarm_Blue.cpp +++ b/trinity/Eve/SpaceObject/EveSwarm_Blue.cpp @@ -5,21 +5,20 @@ BLUE_DEFINE( EveSwarmRenderable ); -const Be::ClassInfo* EveSwarmRenderable::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSwarmRenderable, "" ) +const Be::ClassInfo* EveSwarmRenderable::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSwarmRenderable, "" ) MAP_INTERFACE( ITr2Pickable ) - MAP_INTERFACE( EveEntity ) - MAP_INTERFACE( IEveShadowCaster ) - EXPOSURE_END() + MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( IEveShadowCaster ) + EXPOSURE_END() } BLUE_DEFINE( EveSwarm ); const Be::ClassInfo* EveSwarm::ExposeToBlue() { - EXPOSURE_BEGIN( EveSwarm, "" ) - MAP_INTERFACE( EveSwarm ) + EXPOSURE_BEGIN( EveSwarm, "" ) + MAP_INTERFACE( EveSwarm ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) @@ -49,30 +48,29 @@ const Be::ClassInfo* EveSwarm::ExposeToBlue() MAP_ATTRIBUTE( "anchorRadius1", m_behavior.m_anchorRadius1, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "weightDeceleration", m_behavior.m_weightDecelerate, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxDeceleration", m_behavior.m_maxDeceleration, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "separationDistance", m_behavior.m_separationDistance, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "formationDistance", m_behavior.m_formationDistance, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "wanderFluctuation", m_behavior.m_wanderFluctuation, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "wanderDistance", m_behavior.m_wanderDistance, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "wanderRadius", m_behavior.m_wanderRadius, ":jessica-group: Behavior", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "debugShowForces", m_debugShowForces, ":jessica-group: Debug", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_METHOD_AND_WRAP( "AddSwarmer", AddSwarmer, "" ) MAP_METHOD_AND_WRAP( "RemoveSwarmer", RemoveSwarmer, "" ) - MAP_METHOD_AND_WRAP( - "SetCount", - SetCount, + MAP_METHOD_AND_WRAP( + "SetCount", + SetCount, "Set number of things in the swarm\n" - ":param count: number of things in the swarm" - ) - MAP_METHOD_AND_WRAP( - "EnableSwarming", - EnableSwarming, + ":param count: number of things in the swarm" ) + MAP_METHOD_AND_WRAP( + "EnableSwarming", + EnableSwarming, "Enable/disable swarming\n" ":param enable: enable/disable swarming" ) MAP_METHOD_AND_WRAP( "PickFiringOrigin", PickFiringOrigin, "" ) - - EXPOSURE_CHAINTO( EveShip2 ) + + EXPOSURE_CHAINTO( EveShip2 ) } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/EveCustomMask.cpp b/trinity/Eve/SpaceObject/Utils/EveCustomMask.cpp index 163add605..c435e2772 100644 --- a/trinity/Eve/SpaceObject/Utils/EveCustomMask.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveCustomMask.cpp @@ -91,5 +91,3 @@ void EveCustomMask::ZeroPerObjectData( size_t n, EveSpaceObjectVSData* vsData, E vsData->customMaskMatrix[n] = IdentityMatrix(); psData->customMaskTargets[n] = psData->customMaskMaterialIDs[n] = vsData->customMaskData[n] = Vector4( 0.f, 0.f, 0.f, 0.f ); } - - diff --git a/trinity/Eve/SpaceObject/Utils/EveCustomMask.h b/trinity/Eve/SpaceObject/Utils/EveCustomMask.h index b45189da8..965dd5a41 100644 --- a/trinity/Eve/SpaceObject/Utils/EveCustomMask.h +++ b/trinity/Eve/SpaceObject/Utils/EveCustomMask.h @@ -24,8 +24,8 @@ BLUE_CLASS( EveCustomMask ) : ~EveCustomMask(); // access - void GetDebugDrawMatrix( Matrix* matrix, float objectRadius ) const; - void FillPerObjectData( size_t n, EveSpaceObjectVSData* vsData, EveSpaceObjectPSData* psData ) const; + void GetDebugDrawMatrix( Matrix * matrix, float objectRadius ) const; + void FillPerObjectData( size_t n, EveSpaceObjectVSData* vsData, EveSpaceObjectPSData* psData ) const; void Setup( const Vector3& position, const Vector3& scaling, const Quaternion& rotation, bool isMirrored, bool clampU, bool clampV, uint8_t srcID, const Vector4& targets ); static void ZeroPerObjectData( size_t n, EveSpaceObjectVSData* vsData, EveSpaceObjectPSData* psData ); @@ -46,7 +46,6 @@ BLUE_CLASS( EveCustomMask ) : bool m_isMirrored; bool m_clampU; bool m_clampV; - }; TYPEDEF_BLUECLASS( EveCustomMask ); diff --git a/trinity/Eve/SpaceObject/Utils/EveCustomMask_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveCustomMask_Blue.cpp index e1e3c9f9c..61a1aafe6 100644 --- a/trinity/Eve/SpaceObject/Utils/EveCustomMask_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveCustomMask_Blue.cpp @@ -6,8 +6,8 @@ BLUE_DEFINE( EveCustomMask ); const Be::ClassInfo* EveCustomMask::ExposeToBlue() { - EXPOSURE_BEGIN( EveCustomMask, "" ) - MAP_INTERFACE( EveCustomMask ) + EXPOSURE_BEGIN( EveCustomMask, "" ) + MAP_INTERFACE( EveCustomMask ) MAP_ATTRIBUTE( "position", m_position, "data\n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "scaling", m_scaling, "data\n", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierScaleBySpaceObjectParent.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierScaleBySpaceObjectParent.cpp index a796d9120..0fc3f9d51 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierScaleBySpaceObjectParent.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierScaleBySpaceObjectParent.cpp @@ -25,12 +25,12 @@ DistributionEntityLifeTimeEvent EveDistributionModifierScaleBySpaceObjectParent: if( m_scaleCurve != nullptr ) { Vector3 finalScale; - m_scaleCurve->GetValueAt( &finalScale, double(bounds.w) ); + m_scaleCurve->GetValueAt( &finalScale, double( bounds.w ) ); placement.additionalScale *= finalScale; } else { - float assetRatio = bounds.w / max(m_authoredForBoundingRadius, 1.f); + float assetRatio = bounds.w / max( m_authoredForBoundingRadius, 1.f ); float finalScale; if( assetRatio > 1.f ) { diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierTransformOffset.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierTransformOffset.cpp index e40dcd5d9..2601bcfcc 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierTransformOffset.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/EveDistributionModifierTransformOffset.cpp @@ -4,7 +4,7 @@ #include "EveDistributionModifierTransformOffset.h" #include "TriMath.h" -EveDistributionModifierTransformOffset::EveDistributionModifierTransformOffset( IRoot* lockobj ) : +EveDistributionModifierTransformOffset::EveDistributionModifierTransformOffset( IRoot* lockobj ) : m_translation( 0.f, 0.f, 0.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_scale( 1.f, 1.f, 1.f ) diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/IEveDistributionModifier.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/IEveDistributionModifier.h index 9588afaa6..7b4f93b0d 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/IEveDistributionModifier.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionAttributeModifiers/IEveDistributionModifier.h @@ -26,13 +26,14 @@ struct PlacementDataWithIdentifier lifeTime( 0.0 ), uniqueID( 0 ), initialPlacementID( -1 ) - {} - + { + } + Vector3 initialTranslation; Quaternion initialRotation; Vector3 initialScale; Vector3 additionalTranslation; - Vector3 translationFrameDelta; // for motion vectors + Vector3 translationFrameDelta; // for motion vectors Quaternion additionalRotation; Vector3 additionalScale; int32_t boneIndex; @@ -54,6 +55,9 @@ BLUE_INTERFACE( IEveDistributionModifier ) : public IRoot { public: - virtual bool AffectsTransform() { return false; } + virtual bool AffectsTransform() + { + return false; + } virtual DistributionEntityLifeTimeEvent ProcessDistributionModifier( PlacementDataWithIdentifier & placement, float deltaTime, const EveChildUpdateParams& params ) = 0; }; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.cpp index 5c28e8ba8..2273d4ca2 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.cpp @@ -11,7 +11,7 @@ static BlueStructureDefinition LocatorStructureWithScaleDef[] = { { 0 } }; -const Locator s_LocatorWithScaleDefaultKey = Locator { Vector3( 0.0, 0.0, 0.0 ), Quaternion( 0.0, 0.0, 0.0, 1.0 ), Vector3( 1.0, 1.0, 1.0 ), -1 }; +const Locator s_LocatorWithScaleDefaultKey = Locator{ Vector3( 0.0, 0.0, 0.0 ), Quaternion( 0.0, 0.0, 0.0, 1.0 ), Vector3( 1.0, 1.0, 1.0 ), -1 }; EveDistributionPlacementGeneratorLocators::EveDistributionPlacementGeneratorLocators( IRoot* lockobj ) : PARENTLOCK( m_locators ), diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.h index 56fc6beb2..e16b5929d 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorLocators.h @@ -17,9 +17,9 @@ BLUE_CLASS( EveDistributionPlacementGeneratorLocators ) : EveDistributionPlacementGeneratorLocators( IRoot* lockobj = nullptr ); - void GetInitialPlacements( std::vector & placements, uint32_t & trackingID ) override; + void GetInitialPlacements( std::vector & placements, uint32_t& trackingID ) override; bool IsRequestingRegeneration() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; // IBlueStructureListNotify void OnStructureListModified( Event event, const void* item, size_t index, IBlueStructureList* list ) override; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.cpp index 0c2716d93..666fdd57c 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.cpp @@ -74,7 +74,7 @@ void EveDistributionPlacementGeneratorParentLocators::UpdateSyncronous( const Ev } } -///////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////// // INotify bool EveDistributionPlacementGeneratorParentLocators::OnModified( Be::Var* value ) { diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.h index b5d74115c..4dd65b6c4 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators.h @@ -15,9 +15,9 @@ BLUE_CLASS( EveDistributionPlacementGeneratorParentLocators ) : EveDistributionPlacementGeneratorParentLocators( IRoot* lockobj = nullptr ); ~EveDistributionPlacementGeneratorParentLocators(); - void GetInitialPlacements( std::vector & placements, uint32_t & trackingID ) override; + void GetInitialPlacements( std::vector & placements, uint32_t& trackingID ) override; bool IsRequestingRegeneration() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; // INotify bool OnModified( Be::Var * value ) override; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators_Blue.cpp index 95614dd0d..ef358b375 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorParentLocators_Blue.cpp @@ -12,7 +12,6 @@ const Be::ClassInfo* EveDistributionPlacementGeneratorParentLocators::ExposeToBl MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "name of the parent locator set", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + EXPOSURE_END() } - \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.cpp index d2b276682..dcbf830a1 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.cpp @@ -44,7 +44,7 @@ void EveDistributionPlacementGeneratorVolume::GetInitialPlacements( std::vector< Vector3 offset = m_volume->GetBoundingSphere().center; placements.reserve( placements.size() + points.size() ); - for( auto &point : points ) + for( auto& point : points ) { InitialPlacement placement; placement.timeOutDuration = 0.0; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.h index 522f7df56..c2e579d07 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume.h @@ -21,7 +21,7 @@ BLUE_CLASS( EveDistributionPlacementGeneratorVolume ) : bool IsRequestingRegeneration() override; void RequestRegeneration(); - + // IInitializ bool Initialize() override; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume_Blue.cpp index 57767ddd5..2ac4aa7fa 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/EveDistributionPlacementGeneratorVolume_Blue.cpp @@ -13,7 +13,7 @@ const Be::ClassInfo* EveDistributionPlacementGeneratorVolume::ExposeToBlue() MAP_INTERFACE( EveDistributionPlacementGeneratorVolume ) MAP_INTERFACE( IEveDistributionPlacementGenerators ) MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) + MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "volume", m_volume, "Volume To generate points in", Be::PERSISTONLY ) MAP_PROPERTY( "volume", GetVolume, SetVolume, "Volume To generate points in" ) diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/IEveDistributionPlacementGenerators.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/IEveDistributionPlacementGenerators.h index 31aa23890..c572f3b99 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/IEveDistributionPlacementGenerators.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionPlacementGenerators/IEveDistributionPlacementGenerators.h @@ -8,5 +8,5 @@ BLUE_INTERFACE( IEveDistributionPlacementGenerators ) : { virtual void GetInitialPlacements( std::vector & placements, uint32_t& trackingID ) = 0; virtual bool IsRequestingRegeneration() = 0; - virtual void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ){}; + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) {}; }; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomOffset.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomOffset.cpp index 331016a8d..a065be26a 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomOffset.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomOffset.cpp @@ -5,10 +5,10 @@ #include "TriMath.h" #include "random" -EveDistributionSpawnModifierRandomOffset::EveDistributionSpawnModifierRandomOffset( IRoot* lockobj ): +EveDistributionSpawnModifierRandomOffset::EveDistributionSpawnModifierRandomOffset( IRoot* lockobj ) : m_consistentRandom( false ), m_uniformOffset( false ), - m_minOffset( 0.f, 0.f, 0.f ), + m_minOffset( 0.f, 0.f, 0.f ), m_maxOffset( 0.f, 0.f, 0.f ) { m_timeSeed = uint32_t( BeOS->GetCurrentFrameTime() ); @@ -49,4 +49,3 @@ void EveDistributionSpawnModifierRandomOffset::ProcessSpawnModifier( PlacementDa TriVectorRotateQuaternion( &randomOffset, &randomOffset, &placement.initialRotation ); placement.initialTranslation += randomOffset; } - diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomRotation.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomRotation.cpp index ccf022eb9..90eee5e8a 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomRotation.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomRotation.cpp @@ -8,7 +8,7 @@ static const Vector3 Y_AXIS( 0.0f, 1.0f, 0.0f ); -EveDistributionSpawnModifierRandomRotation::EveDistributionSpawnModifierRandomRotation( IRoot* lockobj ): +EveDistributionSpawnModifierRandomRotation::EveDistributionSpawnModifierRandomRotation( IRoot* lockobj ) : m_consistentRandom( false ), m_overrideRotation( false ), m_minRotation( 0.f, 0.f, 0.f ), @@ -53,4 +53,3 @@ void EveDistributionSpawnModifierRandomRotation::ProcessSpawnModifier( Placement placement.initialRotation = rotation * placement.initialRotation; } } - diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomScale.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomScale.cpp index 0c529ff06..17639ccbf 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomScale.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawnModifiers/EveDistributionSpawnModifierRandomScale.cpp @@ -5,7 +5,7 @@ #include "TriMath.h" #include "random" -EveDistributionSpawnModifierRandomScale::EveDistributionSpawnModifierRandomScale( IRoot* lockobj ): +EveDistributionSpawnModifierRandomScale::EveDistributionSpawnModifierRandomScale( IRoot* lockobj ) : m_consistentRandom( false ), m_uniformScale( false ), m_overrideScale( false ), @@ -34,7 +34,7 @@ void EveDistributionSpawnModifierRandomScale::ProcessSpawnModifier( PlacementDat generator.seed( randSeed ); - Vector3 randomScale( 1.f, 1.f, 1.f); + Vector3 randomScale( 1.f, 1.f, 1.f ); if( m_uniformScale ) { diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.cpp index e7aa01831..c97ac06c9 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.cpp @@ -4,7 +4,7 @@ #include "EveDistributionSpawnerBurst.h" #include "include/TriMath.h" -EveDistributionSpawnerBurst::EveDistributionSpawnerBurst( IRoot* lockobj ): +EveDistributionSpawnerBurst::EveDistributionSpawnerBurst( IRoot* lockobj ) : m_delayBeforeInitialBurst( 0.f ), m_completeness( 1.f ), m_additionalTriggersPerBurst( 0 ), @@ -31,7 +31,7 @@ void EveDistributionSpawnerBurst::UpdateSyncronous( const EveUpdateContext& upda else if( m_localTimer < m_delayBeforeInitialBurst ) { m_localTimer += updateContext.GetDeltaT(); - } + } else { uint32_t availableTriggers = owner.GetFreePlacementCount(); diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.h index 05b3660e1..c6f4ce3b8 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerBurst.h @@ -11,9 +11,9 @@ BLUE_CLASS( EveDistributionSpawnerBurst ) : EveDistributionSpawnerBurst( IRoot* lockobj = nullptr ); - void Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; private: float m_delayBeforeInitialBurst; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.cpp index 4f44bf31b..48a5fc2eb 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.cpp @@ -3,11 +3,11 @@ #include "StdAfx.h" #include "EveDistributionSpawnerControllerTrigger.h" -EveDistributionSpawnerControllerTrigger::EveDistributionSpawnerControllerTrigger( IRoot* lockobj ) : +EveDistributionSpawnerControllerTrigger::EveDistributionSpawnerControllerTrigger( IRoot* lockobj ) : PARENTLOCK( m_distributionSpawners ), m_isActive( false ), m_restartOnReceivingValue( false ), - m_invertReceivedValue( false ), + m_invertReceivedValue( false ), m_value( 0.f ) { } @@ -73,7 +73,7 @@ void EveDistributionSpawnerControllerTrigger::SetControllerVariable( const char* if( m_invertReceivedValue ) { - m_isActive = 1.f - m_value > 0.f; + m_isActive = 1.f - m_value > 0.f; } else { diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.h index be76531fa..f44463a36 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerControllerTrigger.h @@ -15,9 +15,9 @@ BLUE_CLASS( EveDistributionSpawnerControllerTrigger ) : EveDistributionSpawnerControllerTrigger( IRoot* lockobj = nullptr ); - void Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; void SetControllerVariable( const char* name, float value ) override; bool OnModified( Be::Var * value ) override; @@ -33,4 +33,3 @@ BLUE_CLASS( EveDistributionSpawnerControllerTrigger ) : }; TYPEDEF_BLUECLASS( EveDistributionSpawnerControllerTrigger ); - diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.cpp index 5ab42401b..00cb4bad0 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.cpp @@ -4,11 +4,11 @@ #include "EveDistributionSpawnerInterval.h" #include "include/TriMath.h" -EveDistributionSpawnerInterval::EveDistributionSpawnerInterval( IRoot* lockobj ): +EveDistributionSpawnerInterval::EveDistributionSpawnerInterval( IRoot* lockobj ) : m_localTimer( 0.f ), m_delayBeforeInitialSpawn( 0.f ), m_numTriggered( 0 ), - m_numberOfTriggers( 0 ), + m_numberOfTriggers( 0 ), m_delayBetweenRepeats( 1.f ), m_useRandomStartOffset( true ), m_currentRandomizedIntervalDelta( 0.f ), diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.h index c5723a9f2..c0f3793c6 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval.h @@ -13,9 +13,9 @@ BLUE_CLASS( EveDistributionSpawnerInterval ) : EveDistributionSpawnerInterval( IRoot* lockobj = nullptr ); - void Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; private: float m_delayBeforeInitialSpawn; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval_Blue.cpp index bc237882c..67d5bddd0 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerInterval_Blue.cpp @@ -18,4 +18,3 @@ const Be::ClassInfo* EveDistributionSpawnerInterval::ExposeToBlue() EXPOSURE_END() } - \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.cpp index 73700d425..b2fdd9a8b 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.cpp @@ -70,7 +70,7 @@ void EveDistributionSpawnerTriggerPlane::UpdateSyncronous( const EveUpdateContex { return; } - + float normalizedPlayTime = ( m_currentPlayTime - m_delayBeforeActivation ) / max( 0.01f, m_playDuration ); if( !m_reversePlaneAnimation ) diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.h index abf3b6f4d..09bc5ec5a 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerPlane.h @@ -13,9 +13,9 @@ BLUE_CLASS( EveDistributionSpawnerTriggerPlane ) : EveDistributionSpawnerTriggerPlane( IRoot* lockobj = nullptr ); - void Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; private: std::vector> m_distSortedIndexes; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.cpp index 5b09a9bf8..6fc380108 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.cpp @@ -48,7 +48,7 @@ void EveDistributionSpawnerTriggerSnake::UpdateSyncronous( const EveUpdateContex } m_currentTravelTime += updateContext.GetDeltaT(); - + if( m_travelDurationToNextPoint > 0.f ) { m_travelProgress = m_currentTravelTime / m_travelDurationToNextPoint; @@ -60,7 +60,7 @@ void EveDistributionSpawnerTriggerSnake::UpdateSyncronous( const EveUpdateContex if( m_travelProgress >= 1.f ) { - + owner.TriggerEntityByID( m_activeTargetUniqueID ); m_currentTravelTime = 0.f; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.h index 350fa0505..e06fabee8 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSnake.h @@ -13,9 +13,9 @@ BLUE_CLASS( EveDistributionSpawnerTriggerSnake ) : EveDistributionSpawnerTriggerSnake( IRoot* lockobj = nullptr ); - void Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; private: int32_t m_totalDestinations; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSphere.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSphere.cpp index 183e507f9..958e1a5a5 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSphere.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/EveDistributionSpawnerTriggerSphere.cpp @@ -5,7 +5,7 @@ #include "include/TriMath.h" EveDistributionSpawnerTriggerSphere::EveDistributionSpawnerTriggerSphere( IRoot* lockobj ) : - m_sphereOffset( 0.f, 0.f, 0.f), + m_sphereOffset( 0.f, 0.f, 0.f ), m_delayBeforeActivation( 0.f ), m_playDuration( 1.f ), m_currentPlayTime( 0.f ), @@ -34,8 +34,8 @@ void EveDistributionSpawnerTriggerSphere::Reset( const std::vector & placements ) override; + void Reset( const std::vector& placements ) override; void Restart() override; - void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; + void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) override; private: - std::vector> m_distSortedIndexes; + std::vector> m_distSortedIndexes; Vector3 m_sphereOffset; float m_delayBeforeActivation; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/IEveDistributionSpawner.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/IEveDistributionSpawner.h index ff3c84db5..92b52093a 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/IEveDistributionSpawner.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/DistributionSpawners/IEveDistributionSpawner.h @@ -13,14 +13,14 @@ BLUE_INTERFACE( IEveDistributionRulesParent ) : virtual int32_t TriggerEntityByID( uint32_t entityID ) = 0; virtual PlacementDataWithIdentifier* GetInitialPlacementData( uint32_t index ) = 0; virtual uint32_t GetFreePlacementCount() = 0; - virtual int32_t GetClosestFreePlacement( Vector3& position ) = 0; + virtual int32_t GetClosestFreePlacement( Vector3 & position ) = 0; }; BLUE_INTERFACE( IEveDistributionSpawner ) : public IRoot { - virtual void Reset( const std::vector& placements ){}; - virtual void Restart(){}; // reset values without regenerating data - virtual void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ){}; - virtual void SetControllerVariable( const char* name, float value ){}; + virtual void Reset( const std::vector& placements ) {}; + virtual void Restart() {}; // reset values without regenerating data + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params, IEveDistributionRulesParent& owner ) {}; + virtual void SetControllerVariable( const char* name, float value ) {}; }; diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.cpp b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.cpp index 5831917ed..748132364 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.cpp @@ -35,7 +35,7 @@ EveBaseDistributionMethod::EveBaseDistributionMethod( IRoot* lockobj ) : m_playTime( 0.f ), m_playtimeMultiplier( 1.f ), m_isPlaying( true ), - m_placementDataCenter( 0.f, 0.f, 0.f) + m_placementDataCenter( 0.f, 0.f, 0.f ) { m_placementData.SetStructureDefinition( PlacementDataWithIdentifierDef ); m_placementData.SetDefaultValue( &s_PlacementDataWithIdentifierDefaultKey ); @@ -53,12 +53,12 @@ void EveBaseDistributionMethod::RegeneratePlacementData() placementGenerator->GetInitialPlacements( m_initialPlacements, counter ); } - for( uint32_t i = 0; i < uint32_t(m_initialPlacements.size()); i++ ) + for( uint32_t i = 0; i < uint32_t( m_initialPlacements.size() ); i++ ) { m_uniqueIDIndices[m_initialPlacements[i].placement.uniqueID] = i; } - m_numFreePlacements = uint32_t(m_initialPlacements.size()); + m_numFreePlacements = uint32_t( m_initialPlacements.size() ); } size_t EveBaseDistributionMethod::GetNumberOfPlacements() @@ -160,7 +160,7 @@ void EveBaseDistributionMethod::UpdateSyncronous( const EveUpdateContext& update } else { - SwapInitialPlacements( uint32_t(indx), m_numFreePlacements ); + SwapInitialPlacements( uint32_t( indx ), m_numFreePlacements ); m_numFreePlacements++; continue; } @@ -190,7 +190,7 @@ void EveBaseDistributionMethod::UpdateSyncronous( const EveUpdateContext& update m_placementData[indx].additionalRotation = Quaternion( 0.f, 0.f, 0.f, 1.f ); m_placementData[indx].additionalScale = Vector3( 1.f, 1.f, 1.f ); } - + if( m_placementData[indx].boneIndex >= 0 && m_placementData[indx].boneIndex < params.boneCount ) { Matrix boneMatrix = IdentityMatrix(); @@ -205,7 +205,7 @@ void EveBaseDistributionMethod::UpdateSyncronous( const EveUpdateContext& update for( auto distributionModifier : m_distributionModifiers ) { auto lifeTimeEvent = distributionModifier->ProcessDistributionModifier( m_placementData[indx], dt, params ); - + if( lifeTimeEvent != DistributionEntityLifeTimeEvent::DO_NOTHING ) { this->HandleDistributionEntityLifetimeEvent( indx, lifeTimeEvent ); @@ -226,7 +226,7 @@ void EveBaseDistributionMethod::UpdateSyncronous( const EveUpdateContext& update } } - m_placementDataCenter /= float(m_placementData.size()); + m_placementDataCenter /= float( m_placementData.size() ); for( auto spawner : m_distributionSpawners ) { @@ -369,7 +369,7 @@ void EveBaseDistributionMethod::AddEntities( uint32_t howMany ) size_t originalSize = m_placementData.size(); m_placementData.Resize( originalSize + min( howMany, m_numFreePlacements ) ); - + for( size_t i = 0; i < howMany; ++i ) { if( m_numFreePlacements < 1 ) @@ -396,7 +396,7 @@ int32_t EveBaseDistributionMethod::TriggerEntityByID( uint32_t entityID ) { return -1; } - + if( m_initialPlacements[entityIdx].timeOutDuration > 0.0 ) { return -1; @@ -404,7 +404,7 @@ int32_t EveBaseDistributionMethod::TriggerEntityByID( uint32_t entityID ) m_initialPlacements[entityIdx].timeOutDuration = m_timeOutOnTriggering; - if( uint32_t(entityIdx) < m_numFreePlacements ) + if( uint32_t( entityIdx ) < m_numFreePlacements ) { m_numFreePlacements--; @@ -429,7 +429,7 @@ PlacementDataWithIdentifier* EveBaseDistributionMethod::GetInitialPlacementData( { int32_t entityIdx = this->GetInitialPlacementIndexByID( uniqueID ); - if( entityIdx >= int32_t( m_initialPlacements.size() ) ) + if( entityIdx >= int32_t( m_initialPlacements.size() ) ) { return nullptr; } @@ -463,7 +463,7 @@ int32_t EveBaseDistributionMethod::GetClosestFreePlacement( Vector3& position ) } } - return int32_t(m_initialPlacements[bestIndex].placement.uniqueID); + return int32_t( m_initialPlacements[bestIndex].placement.uniqueID ); } void EveBaseDistributionMethod::SetControllerVariable( const char* name, float value ) diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.h index cba3b9859..6fb23bc42 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/EveBaseDistributionMethod.h @@ -48,7 +48,7 @@ BLUE_CLASS( EveBaseDistributionMethod ) : void AddEntities( uint32_t howMany = 1 ) override; int32_t TriggerEntityByID( uint32_t entityID ) override; uint32_t GetFreePlacementCount() override; - int32_t GetClosestFreePlacement( Vector3& position ) override; + int32_t GetClosestFreePlacement( Vector3 & position ) override; PlacementDataWithIdentifier* GetInitialPlacementData( uint32_t index ) override; // IInitialize @@ -60,7 +60,7 @@ BLUE_CLASS( EveBaseDistributionMethod ) : protected: int32_t GetInitialPlacementIndexByID( uint32_t entityID ); void SwapInitialPlacements( uint32_t indexA, uint32_t indexB ); - void GetPlacement( PlacementDataWithIdentifier& placement, uint32_t entityID = 0 ); + void GetPlacement( PlacementDataWithIdentifier & placement, uint32_t entityID = 0 ); void GetRandomPlacement( PlacementDataWithIdentifier & placement ); Matrix GetInitialPlacementMatrixForPlacement( PlacementDataWithIdentifier & placement ); diff --git a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/IEveDistributionMethod.h b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/IEveDistributionMethod.h index 74e1ba63f..3f6afd101 100644 --- a/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/IEveDistributionMethod.h +++ b/trinity/Eve/SpaceObject/Utils/EveDistributionMethods/IEveDistributionMethod.h @@ -13,7 +13,7 @@ BLUE_INTERFACE( IEveDistributionMethod ) : virtual const Vector3 GetPlacementDataCenter() const = 0; virtual const bool GetHasDynamicMovement() const = 0; - virtual void UpdateSyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ){}; - virtual void UpdateAsyncronous( const EveUpdateContext & updateContext, const EveChildUpdateParams& params ){}; + virtual void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) {}; + virtual void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) {}; virtual void SetControllerVariable( const char* name, float value ) {}; }; diff --git a/trinity/Eve/SpaceObject/Utils/EveLocator2.cpp b/trinity/Eve/SpaceObject/Utils/EveLocator2.cpp index 46ee13d9b..104788272 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocator2.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocator2.cpp @@ -4,7 +4,7 @@ #include "EveLocator2.h" -EveLocator2::EveLocator2( IRoot* lockobj ) - :m_transform( IdentityMatrix() ) +EveLocator2::EveLocator2( IRoot* lockobj ) : + m_transform( IdentityMatrix() ) { } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/EveLocator2.h b/trinity/Eve/SpaceObject/Utils/EveLocator2.h index 12459f4db..95e9728ae 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocator2.h +++ b/trinity/Eve/SpaceObject/Utils/EveLocator2.h @@ -7,19 +7,35 @@ -BLUE_CLASS( EveLocator2 ) : public IRoot +BLUE_CLASS( EveLocator2 ) : + public IRoot { public: EXPOSE_TO_BLUE(); EveLocator2( IRoot* lockobj = NULL ); - const char* GetName() const { return m_name.c_str(); } - void SetName( const char* name ) { m_name = BlueSharedString( name ); } - void SetName( const BlueSharedString& name ) { m_name = name; } - - const Matrix& GetTransform() const { return m_transform; } - void SetTransform( const Matrix& val) { m_transform = val; } + const char* GetName() const + { + return m_name.c_str(); + } + void SetName( const char* name ) + { + m_name = BlueSharedString( name ); + } + void SetName( const BlueSharedString& name ) + { + m_name = name; + } + + const Matrix& GetTransform() const + { + return m_transform; + } + void SetTransform( const Matrix& val ) + { + m_transform = val; + } protected: BlueSharedString m_name; diff --git a/trinity/Eve/SpaceObject/Utils/EveLocator2_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveLocator2_Blue.cpp index 7c8888797..d30a760af 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocator2_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocator2_Blue.cpp @@ -8,11 +8,11 @@ BLUE_DEFINE( EveLocator2 ); const Be::ClassInfo* EveLocator2::ExposeToBlue() { - EXPOSURE_BEGIN( EveLocator2, "" ) - MAP_INTERFACE( EveLocator2 ) + EXPOSURE_BEGIN( EveLocator2, "" ) + MAP_INTERFACE( EveLocator2 ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp index a9b2a87d3..d59caa871 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.cpp @@ -4,8 +4,7 @@ #include "EveLocatorSets.h" // locator item definition -static BlueStructureDefinition LocatorStructureDef[] = -{ +static BlueStructureDefinition LocatorStructureDef[] = { { "position", Be::FLOAT32_3, 0 }, { "direction", Be::FLOAT32_4, 12 }, { "scale", Be::FLOAT32_3, 28 }, @@ -34,7 +33,7 @@ EveLocatorSets::~EveLocatorSets() // -------------------------------------------------------------------------------- void EveLocatorSets::Translate( const Vector3& offset ) { - if( LengthSq(offset) == 0.0f ) + if( LengthSq( offset ) == 0.0f ) { return; } @@ -52,7 +51,7 @@ void EveLocatorSets::Append( const Locator* locators, size_t count ) { size_t originalSize = m_locators.size(); m_locators.Resize( originalSize + count ); - memcpy( &m_locators[ originalSize ], locators, count * sizeof( Locator ) ); + memcpy( &m_locators[originalSize], locators, count * sizeof( Locator ) ); } // -------------------------------------------------------------------------------- diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h index 1e16df1b8..e844ece6b 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets.h @@ -28,9 +28,9 @@ BLUE_CLASS( EveLocatorSets ) : ~EveLocatorSets(); // access - template + template void Set( const char* name, const T* locators, size_t count ); - + void Translate( const Vector3& offset ); void Append( const Locator* locators, size_t count ); @@ -39,7 +39,7 @@ BLUE_CLASS( EveLocatorSets ) : const LocatorStructureList* GetLocators() const; const char* GetName() const; void SetName( BlueSharedString name ); - + private: // name to identify set BlueSharedString m_name; @@ -55,7 +55,7 @@ void EveLocatorSets::Set( const char* name, const T* locators, size_t count ) m_name = BlueSharedString( name ); m_locators.Clear(); m_locators.Resize( count ); - for( int i = 0; i < count; ++i) + for( int i = 0; i < count; ++i ) { m_locators[i] = (Locator)locators[i]; } diff --git a/trinity/Eve/SpaceObject/Utils/EveLocatorSets_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveLocatorSets_Blue.cpp index 61e9ceade..0c2aeb1f3 100644 --- a/trinity/Eve/SpaceObject/Utils/EveLocatorSets_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveLocatorSets_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveLocatorSets ); const Be::ClassInfo* EveLocatorSets::ExposeToBlue() { - EXPOSURE_BEGIN( EveLocatorSets, "" ) - MAP_INTERFACE( EveLocatorSets ) + EXPOSURE_BEGIN( EveLocatorSets, "" ) + MAP_INTERFACE( EveLocatorSets ) MAP_ATTRIBUTE( "name", m_name, "The unique name of this set of locators", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "locators", m_locators, "List of all the locators of this set", Be::READ | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObject/Utils/EveThrottleable.cpp b/trinity/Eve/SpaceObject/Utils/EveThrottleable.cpp index de5266cd7..22223008e 100644 --- a/trinity/Eve/SpaceObject/Utils/EveThrottleable.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveThrottleable.cpp @@ -28,7 +28,7 @@ bool EveThrottleable::ShouldSkipUpdate( float normalizedUpdateFrequency ) return true; } - float updateFrequency = normalizedUpdateFrequency * float( m_maxUpdateFrequency - m_minUpdateFrequency ) + float(m_minUpdateFrequency); + float updateFrequency = normalizedUpdateFrequency * float( m_maxUpdateFrequency - m_minUpdateFrequency ) + float( m_minUpdateFrequency ); m_currentUpdateFrequency = max( updateFrequency, 0.1f ); // floor: update every 10 sec at the least m_nextUpdateTS = currentTime + TimeFromDouble( 1.0 / m_currentUpdateFrequency ); return false; diff --git a/trinity/Eve/SpaceObject/Utils/EveThrottleable.h b/trinity/Eve/SpaceObject/Utils/EveThrottleable.h index ea5a02bc8..56e8c2c6e 100644 --- a/trinity/Eve/SpaceObject/Utils/EveThrottleable.h +++ b/trinity/Eve/SpaceObject/Utils/EveThrottleable.h @@ -3,7 +3,7 @@ #pragma once -BLUE_CLASS( EveThrottleable ): +BLUE_CLASS( EveThrottleable ) : public IRoot { public: diff --git a/trinity/Eve/SpaceObject/Utils/EveThrottleable_Blue.cpp b/trinity/Eve/SpaceObject/Utils/EveThrottleable_Blue.cpp index b38e6ba28..e3a900e69 100644 --- a/trinity/Eve/SpaceObject/Utils/EveThrottleable_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/EveThrottleable_Blue.cpp @@ -15,5 +15,5 @@ const Be::ClassInfo* EveThrottleable::ExposeToBlue() MAP_ATTRIBUTE( "maxUpdateFrequency", m_maxUpdateFrequency, "how often we process states when the object is very close\n:jessica-group: updateFrequency", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "currentUpdateFrequency", m_currentUpdateFrequency, "approximately how many times per sec the controllers updates when throttling is enabled \n:jessica-group: updateFrequency", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.cpp b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.cpp index 171a1ab57..131bcac23 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.cpp +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.cpp @@ -20,13 +20,13 @@ EveCameraFxAttributes::~EveCameraFxAttributes() void EveCameraFxAttributes::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { // gather attributes - Vector3 objPos(0.0, 0.0, 0.0); + Vector3 objPos( 0.0, 0.0, 0.0 ); if( nullptr != params.spaceObjectParent ) { params.spaceObjectParent->GetModelCenterWorldPosition( objPos ); } - + if( nullptr != params.childParent ) { Matrix localToWorldTransform; @@ -34,16 +34,16 @@ void EveCameraFxAttributes::UpdateAsyncronous( const EveUpdateContext& updateCon m_rotationWithChildTransform = Vector3( localToWorldTransform._13, localToWorldTransform._23, localToWorldTransform._33 ); objPos = localToWorldTransform.GetTranslation(); } - + const Vector3 camPos = Tr2Renderer::GetViewPosition(); const Vector3 vec2obj = objPos - camPos; const Matrix view = Tr2Renderer::GetViewTransform(); - + m_distanceToCamera = Length( vec2obj ); m_lookAngleToObject = -( Dot( Tr2Renderer::GetViewLookAt(), vec2obj ) / m_distanceToCamera ); - - + + m_objectRotation = Vector3( params.localToWorldTransform._13, params.localToWorldTransform._23, params.localToWorldTransform._33 ); m_cameraRotation = Vector3( view._13, view._23, view._33 ); } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h index d7f7a34a9..db557831e 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes.h @@ -15,7 +15,7 @@ BLUE_CLASS( EveCameraFxAttributes ) : EXPOSE_TO_BLUE(); EveCameraFxAttributes( IRoot* lockobj = nullptr ); ~EveCameraFxAttributes(); - + void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; private: @@ -24,7 +24,7 @@ BLUE_CLASS( EveCameraFxAttributes ) : float m_distanceToCamera; float m_lookAngleToObject; - + Vector3 m_objectRotation; Vector3 m_rotationWithChildTransform; Vector3 m_cameraRotation; diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes_Blue.cpp b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes_Blue.cpp index 8614b0a45..fb2b88508 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveCameraFxAttributes_Blue.cpp @@ -12,7 +12,7 @@ const Be::ClassInfo* EveCameraFxAttributes::ExposeToBlue() EXPOSURE_BEGIN( EveCameraFxAttributes, "" ) MAP_INTERFACE( EveCameraFxAttributes ) MAP_INTERFACE( IEveFxAttribute ) - + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "distanceToCamera", m_distanceToCamera, "spaceObject distance to camera\n:jessica-group: General", Be::READ ) @@ -21,6 +21,6 @@ const Be::ClassInfo* EveCameraFxAttributes::ExposeToBlue() MAP_ATTRIBUTE( "objectRotation", m_objectRotation, "\n:jessica-group: Rotation", Be::READ ) MAP_ATTRIBUTE( "rotationWithChildTransform", m_rotationWithChildTransform, "\n:jessica-group: Rotation", Be::READ ) MAP_ATTRIBUTE( "cameraRotation", m_cameraRotation, "\n:jessica-group: Rotation", Be::READ ) - + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.cpp b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.cpp index 3d34b7e18..c8b89c286 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.cpp +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.cpp @@ -7,11 +7,11 @@ #include "Eve/SpaceObject/EveShip2.h" EveSpaceObjectFxAttributes::EveSpaceObjectFxAttributes( IRoot* lockobj ) : - m_activationStrength( 1.f ), + m_activationStrength( 1.f ), m_distanceToShip( 0 ), m_boundingSphereRadius( 0 ), m_distanceToChildParent( 0 ), - m_killCount( 0 ), + m_killCount( 0 ), m_initialized( false ), m_generatedShapeEllipsoidCenter( 0.f, 0.f, 0.f ), m_generatedShapeEllipsoidRadius( 0.f, 0.f, 0.f ), @@ -26,22 +26,22 @@ EveSpaceObjectFxAttributes::~EveSpaceObjectFxAttributes() void EveSpaceObjectFxAttributes::UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) { - if (nullptr == params.spaceObjectParent) - { - return; - } + if( nullptr == params.spaceObjectParent ) + { + return; + } if( !m_initialized ) { // things we only want to calculate once - if ( EveSpaceObject2Ptr rootParent = BlueCastPtr( params.spaceObjectParent ) ) - { - rootParent->GetShapeEllipsoid(m_generatedShapeEllipsoidCenter, m_generatedShapeEllipsoidRadius ); - } + if( EveSpaceObject2Ptr rootParent = BlueCastPtr( params.spaceObjectParent ) ) + { + rootParent->GetShapeEllipsoid( m_generatedShapeEllipsoidCenter, m_generatedShapeEllipsoidRadius ); + } m_initialized = true; } - + // gather attributes Vector3 objPos; Vector4 sphere; @@ -53,7 +53,7 @@ void EveSpaceObjectFxAttributes::UpdateAsyncronous( const EveUpdateContext& upda m_parentWorldTranslation = objPos; m_parentWorldRotation = RotationQuaternion( parentWorldTransform ); - m_activationStrength = params.activationStrength; + m_activationStrength = params.activationStrength; m_distanceToShip = Length( objPos ) - m_boundingSphereRadius; m_boundingSphereRadius = sphere.w; diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.h b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.h index d7c00e556..92930d4f2 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.h +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes.h @@ -23,11 +23,11 @@ BLUE_CLASS( EveSpaceObjectFxAttributes ) : BlueSharedString m_name; bool m_initialized; - float m_activationStrength; + float m_activationStrength; float m_distanceToShip; float m_boundingSphereRadius; float m_distanceToChildParent; - float m_killCount; + float m_killCount; float m_activeTurretCount; Vector3 m_generatedShapeEllipsoidCenter; Vector3 m_generatedShapeEllipsoidRadius; diff --git a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes_Blue.cpp b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes_Blue.cpp index 1962436e2..ff4bfdc70 100644 --- a/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes_Blue.cpp +++ b/trinity/Eve/SpaceObject/Utils/fxAttributes/EveSpaceObjectFxAttributes_Blue.cpp @@ -10,22 +10,22 @@ const Be::ClassInfo* EveSpaceObjectFxAttributes::ExposeToBlue() EXPOSURE_BEGIN( EveSpaceObjectFxAttributes, "" ) MAP_INTERFACE( EveSpaceObjectFxAttributes ) MAP_INTERFACE( IEveFxAttribute ) - + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "activationStrength", m_activationStrength, "activityStrength of the spaceObject parent \n:jessica-group: General", Be::READ ) - MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphereRadius, "SpaceObject Parent bounding sphere radius \n:jessica-group: General", Be::READ ) + MAP_ATTRIBUTE( "activationStrength", m_activationStrength, "activityStrength of the spaceObject parent \n:jessica-group: General", Be::READ ) + MAP_ATTRIBUTE( "boundingSphereRadius", m_boundingSphereRadius, "SpaceObject Parent bounding sphere radius \n:jessica-group: General", Be::READ ) MAP_ATTRIBUTE( "generatedShapeEllipsoidCenter", m_generatedShapeEllipsoidCenter, "Generated or User-authored ellipsoid data for center \n:jessica-group: General", Be::READ ) MAP_ATTRIBUTE( "generatedShapeEllipsoidRadius", m_generatedShapeEllipsoidRadius, "Generated or User-authored ellipsoid data for radii \n:jessica-group: General", Be::READ ) MAP_ATTRIBUTE( "activeTurretCount", m_activeTurretCount, "Count of how many active turrets are on the spaceObject parent \n:jessica-group: General", Be::READ ) MAP_ATTRIBUTE( "parentWorldTranslation", m_parentWorldTranslation, "the world translation of the spaceObject parent\n:jessica-group: General", Be::READ ) MAP_ATTRIBUTE( "parentWorldRotation", m_parentWorldRotation, "the world rotation of the spaceObject parent\n:jessica-group: General", Be::READ ) - + MAP_ATTRIBUTE( "ship", m_distanceToShip, "player ship distance to spaceObject-parent \n:jessica-group: DistanceTo", Be::READ ) MAP_ATTRIBUTE( "childParent", m_distanceToChildParent, "distance to closest-parent \n:jessica-group: DistanceTo", Be::READ ) - MAP_ATTRIBUTE( "killCount", m_killCount, "How many ships has the SpaceObject owner killed \n:jessica-group: SpicyStuff", Be::READ ) + MAP_ATTRIBUTE( "killCount", m_killCount, "How many ships has the SpaceObject owner killed \n:jessica-group: SpicyStuff", Be::READ ) + - EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp index da47844ef..b809f11a4 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.cpp @@ -140,7 +140,7 @@ EveSOF::EveSOF( IRoot* lockobj ) : m_hazeSetEffectSpherical->StartUpdate(); m_hazeSetEffectSpherical->SetEffectPathName( "res:/graphics/effect/managed/space/spaceobject/fx/hazespherical.fx" ); m_hazeSetEffectSpherical->EndUpdate(); - + m_skinnedHazeSetEffectSpherical.CreateInstance(); m_skinnedHazeSetEffectSpherical->StartUpdate(); m_skinnedHazeSetEffectSpherical->SetEffectPathName( "res:/graphics/effect/managed/space/spaceobject/fx/skinned_hazespherical.fx" ); @@ -158,7 +158,6 @@ EveSOF::EveSOF( IRoot* lockobj ) : // -------------------------------------------------------------------------------- EveSOF::~EveSOF() { - } // -------------------------------------------------------------------------------- @@ -180,7 +179,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) s += std::string( dnaString ); CCP_STATS_ZONE( s.c_str() ); - EveSOFDNAPtr dna = CreateDna(dnaString); + EveSOFDNAPtr dna = CreateDna( dnaString ); if( dna == nullptr ) { return nullptr; @@ -238,7 +237,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) return newObj->GetRawRoot(); } - + // get us the base geometry SetupMesh( newObj, dna ); SetupCustomMask( newObj, dna ); @@ -249,7 +248,7 @@ IRootPtr EveSOF::BuildFromDNA( const char* dnaString ) // locators to ship SetupLocators( newObj, dna ); SetupLocatorSets( newObj, dna, centerOffset ); - + // Attachments SetupAttachments( BlueCastPtr( newObj->GetRawRoot() ), dna, centerOffset, EveSOFDataHullBuildFilter::STANDALONE ); @@ -312,9 +311,9 @@ void EveSOF::SetupAttachments( IEveSpaceObjectAttachmentOwnerPtr newObj, const E SetupPlaneSets( newObj, dna, offsets, buildFlags ); SetupSpriteLineSets( newObj, dna, offsets, buildFlags ); SetupHazeSets( newObj, dna, offsets, buildFlags ); - - // Banners need to have external parameters, which we don't have for anything except for EveSpaceObject2Ptr... - // So no banners for layouts... yet + + // Banners need to have external parameters, which we don't have for anything except for EveSpaceObject2Ptr... + // So no banners for layouts... yet if( EveSpaceObject2Ptr spaceObject = BlueCastPtr( newObj->GetRootObject() ) ) { if( !dna->UsingSof6() ) @@ -326,10 +325,10 @@ void EveSOF::SetupAttachments( IEveSpaceObjectAttachmentOwnerPtr newObj, const E SetupBannerSets( spaceObject, dna, offsets ); } } - - if( ITr2LightOwnerPtr lightOwner = BlueCastPtr(newObj->GetRootObject() ) ) + + if( ITr2LightOwnerPtr lightOwner = BlueCastPtr( newObj->GetRootObject() ) ) { - SetupLights( lightOwner, dna, offsets ); + SetupLights( lightOwner, dna, offsets ); } } @@ -421,36 +420,31 @@ EveSpaceObject2Ptr EveSOF::CreateSpaceObject( const EveSOFDNAPtr dna ) const switch( dna->GetBuildClass() ) { - case EveSOFDataHull::BUILDCLASS_STATIONARY: - { + case EveSOFDataHull::BUILDCLASS_STATIONARY: { EveStation2Ptr newStation; newStation.CreateInstance(); spaceObject = newStation; } break; - case EveSOFDataHull::BUILDCLASS_MOBILE: - { + case EveSOFDataHull::BUILDCLASS_MOBILE: { EveMobilePtr newMobile; newMobile.CreateInstance(); spaceObject = newMobile; } break; - case EveSOFDataHull::BUILDCLASS_SHIP: - { + case EveSOFDataHull::BUILDCLASS_SHIP: { EveShip2Ptr newShip; newShip.CreateInstance(); spaceObject = newShip; } break; - case EveSOFDataHull::BUILDCLASS_SWARM: - { + case EveSOFDataHull::BUILDCLASS_SWARM: { EveSwarmPtr newSwarm; newSwarm.CreateInstance(); spaceObject = newSwarm; } break; - case EveSOFDataHull::BUILDCLASS_EXTENSION: - { + case EveSOFDataHull::BUILDCLASS_EXTENSION: { EveMobilePtr newRoot; newRoot.CreateInstance(); spaceObject = newRoot; @@ -512,7 +506,7 @@ Tr2MeshPtr EveSOF::CreateMesh( const EveSOFDNAPtr dna ) const // gr2 res path mesh->SetMeshResPath( dna->GetHullGeometryResPath().c_str() ); - + SetupShaders( dna, mesh ); // some areas need an accompanying depth area @@ -525,17 +519,17 @@ Tr2MeshPtr EveSOF::CreateMesh( const EveSOFDNAPtr dna ) const void EveSOF::GenerateDepthFromAreaVector( Tr2MeshBase* mesh, const Tr2MeshAreaVector* meshAreaVector, const EveSOFDNAPtr dna ) const { Tr2MeshAreaVector* depthAreas = mesh->GetAreas( TRIBATCHTYPE_DEPTH ); - if( depthAreas ) + if( depthAreas ) { for( auto srcMeshArea = meshAreaVector->begin(); srcMeshArea != meshAreaVector->end(); ++srcMeshArea ) { - if( (*srcMeshArea)->GetGenerateDepthArea() ) + if( ( *srcMeshArea )->GetGenerateDepthArea() ) { Tr2MeshAreaPtr destMeshArea; BeClasses->CopyTo( *srcMeshArea, (IRoot**)&destMeshArea ); - Tr2Effect* destShader = dynamic_cast(destMeshArea->GetMaterialInterface()); - Tr2Effect* srcShader = dynamic_cast((*srcMeshArea)->GetMaterialInterface()); + Tr2Effect* destShader = dynamic_cast( destMeshArea->GetMaterialInterface() ); + Tr2Effect* srcShader = dynamic_cast( ( *srcMeshArea )->GetMaterialInterface() ); if( destShader && srcShader ) { const EveSOFDataMgr::GenericShaderData* depthOnlyShaderData = dna->GetGenericAreaShaderData( m_depthOnlyEffectName ); @@ -629,14 +623,14 @@ size_t EveSOF::FillMeshAreaVector( Tr2MeshAreaVector* meshAreaVector, TriBatchTy // pattern textures if( patternLayerCount > 0 ) { - bool deletePatterData = false; - auto pattern = dna->GetPatternApplicationData( deletePatterData ); + bool deletePatterData = false; + auto pattern = dna->GetPatternApplicationData( deletePatterData ); newShader->SetOption( BlueSharedString( "SPACE_OBJECT_PPT_ENABLED" ), BlueSharedString( "SOPPT_ENABLED" ) ); - + for( size_t i = 0; i < patternLayerCount; ++i ) { const EveSOFDataMgr::PatternLayerData* patternLayerData = dna->GetPatternLayerData( pattern, i ); - + if( patternLayerData && dna->IsPatternLayerApplicableToArea( patternLayerData, area->areaType ) ) { newShader->AddResourceTexture2D( patternLayerData->textureName, patternLayerData->textureResFilePath.c_str() ); @@ -645,14 +639,14 @@ size_t EveSOF::FillMeshAreaVector( Tr2MeshAreaVector* meshAreaVector, TriBatchTy newShader->AddSamplerOverride( BlueSharedString( std::string( patternLayerData->textureName.c_str() ) + "Sampler" ), patternLayerData->projectionAddressModeU, patternLayerData->projectionAddressModeV ); } } - if( deletePatterData ) - { - delete pattern; - } + if( deletePatterData ) + { + delete pattern; + } } - else + else { - newShader->SetOption( BlueSharedString( "SPACE_OBJECT_PPT_ENABLED" ), BlueSharedString( "SOPPT_DISABLED" ) ); + newShader->SetOption( BlueSharedString( "SPACE_OBJECT_PPT_ENABLED" ), BlueSharedString( "SOPPT_DISABLED" ) ); } // default shader textures & parameters from the generic data @@ -728,7 +722,7 @@ void EveSOF::SetupSpriteSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSO const std::vector& hullSpriteSets = dna->GetHullSpriteSets( hullIdx ); for( auto ssit = hullSpriteSets.begin(); ssit != hullSpriteSets.end(); ++ssit ) { - const EveSOFDataMgr::HullSpriteSetData* spriteSetData = &(*ssit); + const EveSOFDataMgr::HullSpriteSetData* spriteSetData = &( *ssit ); // visible? if( dna->IsInVisibilityData( spriteSetData->visibilityGroup ) ) @@ -746,7 +740,7 @@ void EveSOF::SetupSpriteSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSO // add all the individual items for( auto ssiit = spriteSetData->items.begin(); ssiit != spriteSetData->items.end(); ++ssiit ) { - const EveSOFDataMgr::HullSpriteSetItemData* itemData = &(*ssiit); + const EveSOFDataMgr::HullSpriteSetItemData* itemData = &( *ssiit ); // color data? const Color* colorSet = dna->GetColorSet(); @@ -773,7 +767,7 @@ void EveSOF::SetupSpriteSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSO if( itemData->light ) { auto saturatedColor = Saturate( spriteSetItem->m_color, itemData->light->saturation ); - auto lightData = itemData->light->AsLightData( saturatedColor, 1.0f); + auto lightData = itemData->light->AsLightData( saturatedColor, 1.0f ); lightData.position += spriteSetItem->m_position; lightData.boneIndex = spriteSetItem->m_boneIndex; @@ -782,10 +776,10 @@ void EveSOF::SetupSpriteSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSO } index++; } - spriteSet->Add(spriteSetItem); + spriteSet->Add( spriteSetItem ); } } - + // spriteset needs internal rebuild spriteSet->Rebuild(); // put set onto ship @@ -856,7 +850,7 @@ void EveSOF::SetupSpotlightSets( IEveSpaceObjectAttachmentOwnerPtr obj, const Ev spotlightSet->SetSkinned( spotlightSetData.skinned && buildFlags != EveSOFDataHullBuildFilter::INSTANCED_PLACEMENT ); uint32_t index = 0; - for( auto& offset: offsets) + for( auto& offset : offsets ) { // add all individual items for( auto& ssiit : spotlightSetData.items ) @@ -900,12 +894,13 @@ void EveSOF::SetupSpotlightSets( IEveSpaceObjectAttachmentOwnerPtr obj, const Ev spotlightSetItem->m_boosterGainInfluence = ssiit.boosterGainInfluence; spotlightSetItem->m_spriteScale = ssiit.spriteScale; - Matrix transformed = XMMatrixMultiply( XMMatrixMultiply(ssiit.transform, TranslationMatrix(hullOffset)), offset ); + Matrix transformed = XMMatrixMultiply( XMMatrixMultiply( ssiit.transform, TranslationMatrix( hullOffset ) ), offset ); TriMatrixTranslate( &spotlightSetItem->m_transform, &transformed, &hullOffset ); - + if( dna->UsingSof6() ) { - if( ssiit.light ) { + if( ssiit.light ) + { Quaternion rotation; Vector3 pos; Vector3 scale; @@ -917,7 +912,8 @@ void EveSOF::SetupSpotlightSets( IEveSpaceObjectAttachmentOwnerPtr obj, const Ev float innerAngle = 0.0f; float outerAngle = 0.0f; - if( scale.z > 0.f ) { + if( scale.z > 0.f ) + { innerAngle = atanf( max( scale.x, scale.y ) / ( 2.0f * scale.z ) ) * 180.0f / TRI_PI; outerAngle = atanf( max( scale.x, scale.y ) / ( 2.0f * scale.z ) ) * 180.0f / TRI_PI; } @@ -933,13 +929,13 @@ void EveSOF::SetupSpotlightSets( IEveSpaceObjectAttachmentOwnerPtr obj, const Ev spotlightSet->AddLightFromSOF( EveSpotlightLight( data, index, ssiit.light->lightProfilePath, ssiit.boosterGainInfluence ) ); } index++; - } + } // add it spotlightSet->AddSpotlightItem( spotlightSetItem ); } } - + // spotlightset needs internal rebuild spotlightSet->Rebuild(); // add to ship @@ -990,7 +986,7 @@ void EveSOF::SetupPlaneSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOF TriTextureParameterPtr imageMap, layer1, layer2, mask; - auto CreateTextureParameter = []( const char* name, const char* path, TriTextureParameterPtr ¶m ) { + auto CreateTextureParameter = []( const char* name, const char* path, TriTextureParameterPtr& param ) { param.CreateInstance(); param->SetParameterName( BlueSharedString( name ) ); param->SetResourcePath( path ); @@ -1012,26 +1008,25 @@ void EveSOF::SetupPlaneSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOF break; } - // textures + // textures planeEffect->AddResource( CreateTextureParameter( "Layer1Map", planeSetData.layer1MapResPath.c_str(), layer1 ) ); planeEffect->AddResource( CreateTextureParameter( "Layer2Map", planeSetData.layer2MapResPath.c_str(), layer2 ) ); planeEffect->AddResource( CreateTextureParameter( "MaskMap", planeSetData.maskMapResPath.c_str(), mask ) ); // parameters float angularFadeOut = planeSetData.usage == EveSOFDataHullPlaneSet::USAGE_HAZE ? 1.f : 0.f; - Vector4 planeData( + Vector4 planeData( angularFadeOut, (float)planeSetData.atlasSize, std::floor( planeSetData.atlasAspectRatio.x ), - std::floor( planeSetData.atlasAspectRatio.y ) - ); + std::floor( planeSetData.atlasAspectRatio.y ) ); planeEffect->AddParameterVector4( BlueSharedString( "PlaneData" ), &planeData ); // finish up shader and set it planeEffect->EndUpdate(); planeSet->SetEffect( planeEffect ); uint32_t index = 0; - + planeSet->SetIsSkinned( isSkinned ); @@ -1086,7 +1081,8 @@ void EveSOF::SetupPlaneSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOF planeSet->SetMaskMapParameter( mask ); } - for( auto& pslight : psiit.lights ) { + for( auto& pslight : psiit.lights ) + { float maxScale = max( psiit.scaling.x, max( psiit.scaling.y, psiit.scaling.z ) ); auto saturatedColor = Saturate( planeSetItem->m_color, pslight.saturation ); auto lightData = pslight.AsLightData( saturatedColor, maxScale ); @@ -1135,7 +1131,7 @@ void EveSOF::SetupSpriteLineSets( IEveSpaceObjectAttachmentOwnerPtr obj, const E const std::vector& hullSpriteLineSets = dna->GetHullSpriteLineSets( hullIdx ); for( auto slsit = hullSpriteLineSets.begin(); slsit != hullSpriteLineSets.end(); ++slsit ) { - const EveSOFDataMgr::HullSpriteLineSetData* spriteLineSetData = &(*slsit); + const EveSOFDataMgr::HullSpriteLineSetData* spriteLineSetData = &( *slsit ); // visible? if( dna->IsInVisibilityData( spriteLineSetData->visibilityGroup ) ) @@ -1163,10 +1159,10 @@ void EveSOF::SetupSpriteLineSets( IEveSpaceObjectAttachmentOwnerPtr obj, const E // set it up the colorset data spriteLineSetItem->m_color = itemData->intensity * colorSet[itemData->colorType]; - + // set up the position data Vector3 tmp; - Matrix m = TransformationMatrix( Vector3(1.0f, 1.0f, 1.0f), itemData->rotation, itemData->position + hullOffset ) * offset; + Matrix m = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), itemData->rotation, itemData->position + hullOffset ) * offset; Decompose( tmp, spriteLineSetItem->m_rotation, spriteLineSetItem->m_position, m ); // set it up the per-hull data @@ -1254,7 +1250,7 @@ void EveSOF::SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFD const std::vector& hullHazeSets = dna->GetHullHazeSets( hullIdx ); for( auto hhsit = hullHazeSets.begin(); hhsit != hullHazeSets.end(); ++hhsit ) { - const EveSOFDataMgr::HullHazeSetData* hazeSetData = &(*hhsit); + const EveSOFDataMgr::HullHazeSetData* hazeSetData = &( *hhsit ); // vivible? if( dna->IsInVisibilityData( hazeSetData->visibilityGroup ) ) @@ -1269,7 +1265,7 @@ void EveSOF::SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFD case EveSOFDataHullHazeSet::TYPE_SPHERICAL: if( hazeSetData->skinned && buildFlags != EveSOFDataHullBuildFilter::INSTANCED_PLACEMENT ) { - hazeSet->Setup( m_skinnedHazeSetEffectSpherical ); + hazeSet->Setup( m_skinnedHazeSetEffectSpherical ); } else { @@ -1282,12 +1278,12 @@ void EveSOF::SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFD } uint32_t index = 0; - for( auto& offset: offsets ) + for( auto& offset : offsets ) { // add all the individual items for( auto hhsiit = hazeSetData->items.begin(); hhsiit != hazeSetData->items.end(); ++hhsiit ) { - const EveSOFDataMgr::HullHazeSetItemData* itemData = &(*hhsiit); + const EveSOFDataMgr::HullHazeSetItemData* itemData = &( *hhsiit ); // color data from colorset const Color* colorSet = dna->GetColorSet(); @@ -1309,7 +1305,7 @@ void EveSOF::SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFD hazeSetItem->m_scaling = itemData->scaling; hazeSetItem->m_boneIndex = itemData->boneIndex; hazeSetItem->m_hazeData = Vector4( itemData->hazeFalloff, itemData->sourceSize, itemData->sourceBrightness, itemData->boosterGainInfluence ? 1.f : 0.f ); - + if( dna->UsingSof6() ) { hazeSetItem->m_color = Saturate( hazeSetItem->m_color, itemData->saturation ); @@ -1330,14 +1326,14 @@ void EveSOF::SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFD hazeSet->AddLightFromSOF( hazeSetLight ); } } - + index++; // put it into hazeset hazeSet->AddHazeItem( hazeSetItem ); } } - + // spriteset needs internal rebuild hazeSet->Rebuild(); // put set onto ship @@ -1384,7 +1380,7 @@ void EveSOF::SetupBanners( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const { bannerSet.CreateInstance(); } - + for( auto& offset : offsets ) { auto modifiedData = EveBannerItem( itemData.item ); @@ -1410,7 +1406,7 @@ void EveSOF::SetupBanners( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const data.noiseAmplitude = itemData.bannerLight.noiseAmplitude; data.noiseFrequency = itemData.bannerLight.noiseFrequency; data.noiseOctaves = itemData.bannerLight.noiseOctaves; - + EveBannerLight bannerLight; bannerLight.lightData = data; bannerLight.saturation = itemData.bannerLight.saturation; @@ -1455,12 +1451,12 @@ void EveSOF::SetupBanners( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const bannerSet->Rebuild(); obj->AddAttachment( bannerSet ); - static const char* names[] = { - "AllianceLogoResPath", - "CorpLogoResPath", - "CeoPortraitResPath", - "VerticalBannerResPath", - "HorizontalBannerResPath", + static const char* names[] = { + "AllianceLogoResPath", + "CorpLogoResPath", + "CeoPortraitResPath", + "VerticalBannerResPath", + "HorizontalBannerResPath", "TargetSystemAllianceLogoResPath", "TargetSystemVerticalBannerResPath", "TargetSystemHorizontalBannerResPath", @@ -1556,7 +1552,8 @@ void EveSOF::SetupBannerSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, co bannerSet->AddBanner( modifiedItem ); - if( banner.light ) { + if( banner.light ) + { Vector3 scale = banner.item.scaling; float maxScale = max( scale.x, max( scale.y, scale.z ) ); @@ -1564,7 +1561,7 @@ void EveSOF::SetupBannerSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, co auto lightData = banner.light->AsLightData( black, maxScale ); lightData.position = Transform( lightData.position, RotationMatrix( modifiedItem.rotation ) ) + modifiedItem.position; lightData.rotation = Normalize( lightData.rotation * modifiedItem.rotation ); - + EveBannerLight bannerLight( lightData, banner.light->saturation, index, banner.light->lightProfilePath ); bannerSet->AddLightFromSOF( bannerLight ); @@ -1698,7 +1695,7 @@ void RecursiveBindParticleEmitters( EveTransform* transform, TriCurveSet* curveS for( auto emitterIt = transform->m_particleEmitters.begin(); emitterIt != transform->m_particleEmitters.end(); ++emitterIt ) { Tr2DynamicEmitterPtr dynamicEmitter; - if( !(*emitterIt)->QueryInterface( BlueInterfaceIID(), (void**)&dynamicEmitter ) ) + if( !( *emitterIt )->QueryInterface( BlueInterfaceIID(), (void**)&dynamicEmitter ) ) { continue; } @@ -1714,7 +1711,7 @@ void RecursiveBindParticleEmitters( EveTransform* transform, TriCurveSet* curveS for( auto childIt = transform->m_children.begin(); childIt != transform->m_children.end(); ++childIt ) { EveTransformPtr childTransform; - if( !(*childIt)->QueryInterface( BlueInterfaceIID(), (void**)&childTransform ) ) + if( !( *childIt )->QueryInterface( BlueInterfaceIID(), (void**)&childTransform ) ) { continue; } @@ -1751,7 +1748,7 @@ void RecursiveBindParticleEmitters( IEveSpaceObjectChild* child, TriCurveSet* cu // -------------------------------------------------------------------------------- // Description: // Add Children and Animations to the ship -// +// // -------------------------------------------------------------------------------- void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChildrenOwnerPtr childOwner, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const { @@ -1788,7 +1785,7 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild // is it of right type? if( EveTransformPtr child = BlueCastPtr( p ) ) { - for(auto& offset: offsets) + for( auto& offset : offsets ) { EveTransformPtr transformedChild = BlueCastPtr( BlueCopy( child ) ); @@ -1804,9 +1801,9 @@ void EveSOF::SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChild { childrenToBindTo[childIt->id].push_back( transformedChild ); } - + obj->AddToChildrenList( transformedChild ); - } + } } else if( IEveSpaceObjectChildPtr effectChild = BlueCastPtr( p ) ) { @@ -2053,13 +2050,13 @@ void EveSOF::SetupAudio( ITr2SoundEmitterOwnerPtr newObj, const EveSOFDNAPtr dna TriObserverLocalPtr observer; observer.CreateInstance(); observer->m_name = cit->name; - observer->SetPosition( XMVector3TransformCoord(cit->position, parentOffset) ); + observer->SetPosition( XMVector3TransformCoord( cit->position, parentOffset ) ); // Convert rotation to a front value Vector3 front; static const Vector3 zAxis( 0.f, 0.f, 1.f ); Quaternion rot = cit->rotation * parentRotation; - TriVectorRotateQuaternion( &front, &zAxis, &rot); + TriVectorRotateQuaternion( &front, &zAxis, &rot ); observer->SetFront( front ); @@ -2119,7 +2116,7 @@ Tr2InstancedMeshPtr EveSOF::CreateInstancedMesh( std::vectorSetBoundingBox( aabb ); mesh->SetDynamicScaledBounds( sqrt( maxScale ) ); - + mesh->SetInstanceGeometryRes( instanceData ); mesh->SetMeshResPath( resPath.c_str() ); @@ -2165,7 +2162,7 @@ void EveSOF::SetupShaders( const EveSOFDNAPtr dna, Tr2MeshBase* mesh ) const void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr dna, const std::vector& offsets ) const { const std::vector& hullInstanced = dna->GetHullInstancedMeshes(); - + if( hullInstanced.empty() ) { // No need to do anything! @@ -2183,12 +2180,12 @@ void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr for( auto instIt = hullInstanced.begin(); instIt != hullInstanced.end(); ++instIt ) { - const EveSOFDataMgr::HullInstancedMesh* him = &(*instIt); + const EveSOFDataMgr::HullInstancedMesh* him = &( *instIt ); if( him->instances.empty() ) { continue; } - + EveChildMeshPtr childMesh; childMesh.CreateInstance(); @@ -2201,17 +2198,13 @@ void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr if( offsets.size() > 1 || offsets[0] != IdentityMatrix() ) { instances.reserve( offsets.size() * him->instances.size() ); - for( auto &offset : offsets ) + for( auto& offset : offsets ) { std::transform( ( him->instances ).begin(), ( him->instances ).end(), std::back_inserter( instances ), [&offset, &instanceTransforms]( EveSOFDataMgr::HullMeshInstance instance ) -> EveSOFDataMgr::HullMeshInstance { - EveSOFDataMgr::HullMeshInstance i( instance ); - - Matrix m = Matrix( i.transform0.x, i.transform1.x, i.transform2.x, 0, - i.transform0.y, i.transform1.y, i.transform2.y, 0, - i.transform0.z, i.transform1.z, i.transform2.z, 0, - i.transform0.w, i.transform1.w, i.transform2.w, 1); - + + Matrix m = Matrix( i.transform0.x, i.transform1.x, i.transform2.x, 0, i.transform0.y, i.transform1.y, i.transform2.y, 0, i.transform0.z, i.transform1.z, i.transform2.z, 0, i.transform0.w, i.transform1.w, i.transform2.w, 1 ); + m = Transpose( m * offset ); i.transform0 = *reinterpret_cast( &m.GetX() ); i.transform1 = *reinterpret_cast( &m.GetY() ); @@ -2230,13 +2223,10 @@ void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr else { instances = him->instances; - for ( auto& i : him->instances ) + for( auto& i : him->instances ) { - Matrix m = Matrix( - i.transform0.x, i.transform1.x, i.transform2.x, 0, - i.transform0.y, i.transform1.y, i.transform2.y, 0, - i.transform0.z, i.transform1.z, i.transform2.z, 0, - i.transform0.w, i.transform1.w, i.transform2.w, 1 ); + Matrix m = Matrix( + i.transform0.x, i.transform1.x, i.transform2.x, 0, i.transform0.y, i.transform1.y, i.transform2.y, 0, i.transform0.z, i.transform1.z, i.transform2.z, 0, i.transform0.w, i.transform1.w, i.transform2.w, 1 ); instanceTransforms.push_back( m ); } } @@ -2313,7 +2303,7 @@ void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr qualityControl->SetName( "Shader Quality Controlled Instanced Mesh" ); qualityControl->Setup( nullptr, nullptr, nullptr, him->lowestLodVisible ); qualityControl->AddToEffectChildrenList( childMesh ); - qualityControl->SetDisplayQualityModifier( (EveChildContainer::DisplayQualityModifier) him->displayModifier ); + qualityControl->SetDisplayQualityModifier( (EveChildContainer::DisplayQualityModifier)him->displayModifier ); // and add it to the main mesh container meshContainer->AddToEffectChildrenList( qualityControl ); @@ -2331,7 +2321,7 @@ void EveSOF::SetupInstancedMeshes( EveSpaceObject2Ptr newObj, const EveSOFDNAPtr // -------------------------------------------------------------------------------- void EveSOF::SetupCustomMask( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const { - bool deletePatterData = false; + bool deletePatterData = false; const EveSOFDataMgr::PatternApplicationData* data = dna->GetPatternApplicationData( deletePatterData ); if( data ) @@ -2364,10 +2354,10 @@ void EveSOF::SetupCustomMask( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) c } } } - if( deletePatterData ) - { - delete data; - } + if( deletePatterData ) + { + delete data; + } } } @@ -2578,7 +2568,7 @@ void EveSOF::SetupLights( ITr2LightOwnerPtr spaceObject, const EveSOFDNAPtr dna, // set up the position data Vector3 tmp; - Matrix m = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), lightSetItem.rotation, lightSetItem.position + hullOffset) * offset; + Matrix m = TransformationMatrix( Vector3( 1.0f, 1.0f, 1.0f ), lightSetItem.rotation, lightSetItem.position + hullOffset ) * offset; Decompose( tmp, data.rotation, data.position, m ); data.radius = lightSetItem.radius; @@ -2728,13 +2718,13 @@ void EveSOF::SetupBoosters( EveShip2Ptr ship, const EveSOFDNAPtr dna ) const trailEffect->EndUpdate(); trail->SetEffect( trailEffect ); trail->SetMeshResPath( g_volumetricTrailPath.c_str() ); - + set->SetTrail( trail ); } // add all the indiviual items and make a locatorSet marking booster locations std::vector locators; - locators.reserve(hdata->items.size()); + locators.reserve( hdata->items.size() ); for( auto biit = hdata->items.begin(); biit != hdata->items.end(); ++biit ) { EveLocator2Ptr locator; @@ -2765,10 +2755,10 @@ void EveSOF::SetupBoosters( EveShip2Ptr ship, const EveSOFDNAPtr dna ) const std::vector locatorList; locSet.CreateInstance(); locatorList.reserve( locators.size() ); - + for( auto locator : locators ) { - Locator loc = locator; + Locator loc = locator; locatorList.push_back( loc ); } @@ -2803,7 +2793,7 @@ void EveSOF::SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPt { const std::vector& hullDecalSets = dna->GetHullDecalSets( hullIdx ); - for( const auto &hullDecalSet : hullDecalSets ) + for( const auto& hullDecalSet : hullDecalSets ) { if( !dna->IsInVisibilityData( hullDecalSet.visibilityGroup ) ) { @@ -2821,7 +2811,7 @@ void EveSOF::SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPt // create EveSpaceObjectDecalPtr decal; decal.CreateInstance(); - + // set general datas decal->SetPosition( itemData.position + hullOffset ); decal->SetRotation( itemData.rotation ); @@ -2857,7 +2847,7 @@ void EveSOF::SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPt // construct shader path and set it on the Tr2Effect std::string shaderPath = dna->GetDecalShaderLocationResPath() + std::string( "/" ) + dna->GetShaderPrefix( false ) + m_decalsEffectName[itemData.usage].c_str(); shader->SetEffectPathName( shaderPath.c_str() ); - + // Set the glow color based on the colors in the colorsetuS if( itemData.usage != EveSOFDataHullDecalSetItem::USAGE_LOGO && itemData.usage != EveSOFDataHullDecalSetItem::USAGE_STANDARD ) { @@ -2899,7 +2889,7 @@ void EveSOF::SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPt } } } - + // Set the logo from the logoset if( itemData.usage == EveSOFDataHullDecalSetItem::USAGE_LOGO ) { @@ -2908,7 +2898,7 @@ void EveSOF::SetupDecalSets( IEveSpaceObjectDecalOwnerPtr obj, const EveSOFDNAPt { for( auto textureit = logo->textures.begin(); textureit != logo->textures.end(); ++textureit ) { - shader->AddResourceTexture2D( (*textureit).first, (*textureit).second.resFilePath.c_str() ); + shader->AddResourceTexture2D( ( *textureit ).first, ( *textureit ).second.resFilePath.c_str() ); } } } @@ -3047,15 +3037,15 @@ void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutCon { const std::vector locatorSetNames = dna->GetHullLocatorSetNames( hullIdx ); - for(const auto & locatorSetName : locatorSetNames) + for( const auto& locatorSetName : locatorSetNames ) { const std::vector* locators = dna->GetHullLocators( locatorSetName.c_str(), hullIdx ); std::vector locatorsCopy( *locators ); auto existingSet = locatorSets.find( locatorSetName ); - if( existingSet == locatorSets.end()) + if( existingSet == locatorSets.end() ) { - locatorSets.insert({locatorSetName, locatorsCopy} ); + locatorSets.insert( { locatorSetName, locatorsCopy } ); } else { @@ -3069,7 +3059,7 @@ void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutCon { return; } - + // dna can have multiple layouts for( size_t layoutIdx = 0; layoutIdx < dna->GetLayoutCount(); ++layoutIdx ) { @@ -3093,7 +3083,7 @@ void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutCon { ProcessPlacementDistributionOrGroup( placement, obj, sharedMeshes, dna, locatorSets, layoutIdx, placementIdx, offsets, layoutContainer ); } - + if( layout->scrambleSeed ) { TriSrand( oldSeed + seedOverwrite ); // restore seed if scrambled for parent proceduralness @@ -3103,7 +3093,7 @@ void EveSOF::SetupLayout( EveSpaceObject2Ptr obj, EveChildContainerPtr layoutCon void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData& placement, EveSpaceObject2Ptr obj, - EveChildInstancedMeshesPtr& sharedMeshes, + EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSets, size_t& layoutIdx, @@ -3216,7 +3206,7 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem EveSOFDNAPtr placementDna; placementDna.CreateInstance(); - auto layout = dna->GetLayoutData(layoutIdx); + auto layout = dna->GetLayoutData( layoutIdx ); placementDna->Setup( layout->name, placement.descriptor, dna, &m_dataMgr ); if( placement.isInstanced ) { @@ -3228,8 +3218,8 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem if( !placement.descriptor.layout.empty() ) { // for sub-layouts to have their own random generation instead of sharing the same - std::vector singleLocator(1); - for( auto &locator : locators ) + std::vector singleLocator( 1 ); + for( auto& locator : locators ) { singleLocator[0] = locator; CreatePlacement( obj, sharedMeshes, placementDna, dna, placement, singleLocator, offsets, layoutContainer ); @@ -3243,7 +3233,7 @@ void EveSOF::ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacem placementIdx++; } - + bool EveSOF::ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData& placement, const EveSOFDNAPtr dna ) @@ -3258,7 +3248,7 @@ bool EveSOF::ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacem break; } case EveSOFDataMgr::PARENT_MATCH: { - + bool hull = condition.spaceObjectParentDescriptor.hull.empty() ? true : true; // TODO condition.spaceObjectParentDescriptor.hull == dna->; bool faction = condition.spaceObjectParentDescriptor.faction.empty() ? true : condition.spaceObjectParentDescriptor.faction == dna->GetFactionName(); bool race = condition.spaceObjectParentDescriptor.race.empty() ? true : condition.spaceObjectParentDescriptor.race == dna->GetRaceName(); @@ -3310,7 +3300,7 @@ bool EveSOF::ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacem break; } - if (!distributionSuccessful) + if( !distributionSuccessful ) { return false; } @@ -3318,7 +3308,7 @@ bool EveSOF::ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacem for( auto condition : placement.placementConditions ) { - if( condition.distributionType == EveSOFDataMgr::DEPLETION_COUNTER) + if( condition.distributionType == EveSOFDataMgr::DEPLETION_COUNTER ) { // consume counters if enabled // TODO @@ -3332,9 +3322,9 @@ bool EveSOF::ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacem void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution& distributionData, - const EveSOFDNAPtr dna, - std::vector& placementSet, - std::vector& managedLocatorSet ) + const EveSOFDNAPtr dna, + std::vector& placementSet, + std::vector& managedLocatorSet ) { float preCount = float( placementSet.size() ) * ( 1.f - distributionData.completeness ); float remainder = fmod( preCount, 1.f ); @@ -3351,32 +3341,36 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem std::map rankedLocators; // uniqueID, sorted rankings where =Vector4(Xaxis, Yaxis, Zaxis, distFromCenter) for( auto locator : placementSet ) { - rankedLocators.insert({locator.uniqueID, Vector4(0,0,0,0)}); + rankedLocators.insert( { locator.uniqueID, Vector4( 0, 0, 0, 0 ) } ); } if( distributionData.placementBias.x != 0.f ) { - std::sort(placementSet.begin(), placementSet.end(),[] (auto &a,auto &b) { return a.position.x < b.position.x; }); - for( size_t i = 0; i < placementSet.size(); i++) rankedLocators[placementSet[i].uniqueID].x = float(i); + std::sort( placementSet.begin(), placementSet.end(), []( auto& a, auto& b ) { return a.position.x < b.position.x; } ); + for( size_t i = 0; i < placementSet.size(); i++ ) + rankedLocators[placementSet[i].uniqueID].x = float( i ); } if( distributionData.placementBias.y != 0.f ) { - std::sort(placementSet.begin(), placementSet.end(),[] (auto &a,auto &b) { return a.position.y < b.position.y; }); - for( size_t i = 0; i < placementSet.size(); i++) rankedLocators[placementSet[i].uniqueID].y = float(i); + std::sort( placementSet.begin(), placementSet.end(), []( auto& a, auto& b ) { return a.position.y < b.position.y; } ); + for( size_t i = 0; i < placementSet.size(); i++ ) + rankedLocators[placementSet[i].uniqueID].y = float( i ); } if( distributionData.placementBias.z != 0.f ) { - std::sort(placementSet.begin(), placementSet.end(),[] (auto &a,auto &b) { return a.position.z < b.position.z; }); - for( size_t i = 0; i < placementSet.size(); i++) rankedLocators[placementSet[i].uniqueID].z = float(i); + std::sort( placementSet.begin(), placementSet.end(), []( auto& a, auto& b ) { return a.position.z < b.position.z; } ); + for( size_t i = 0; i < placementSet.size(); i++ ) + rankedLocators[placementSet[i].uniqueID].z = float( i ); } if( distributionData.centerBias != 0.f ) { - std::sort(placementSet.begin(), placementSet.end(),[] (auto &a,auto &b) { return LengthSq(a.position) < LengthSq(b.position); }); - for( size_t i = 0; i < placementSet.size(); i++) rankedLocators[placementSet[i].uniqueID].w = float(i); + std::sort( placementSet.begin(), placementSet.end(), []( auto& a, auto& b ) { return LengthSq( a.position ) < LengthSq( b.position ); } ); + for( size_t i = 0; i < placementSet.size(); i++ ) + rankedLocators[placementSet[i].uniqueID].w = float( i ); } - float biasAmmount = Length(distributionData.placementBias) + abs(distributionData.centerBias); - float randomFactor = max(1.f - biasAmmount, 0.f); // BiasAmmount -> [0-2] + float biasAmmount = Length( distributionData.placementBias ) + abs( distributionData.centerBias ); + float randomFactor = max( 1.f - biasAmmount, 0.f ); // BiasAmmount -> [0-2] for( auto& locator : placementSet ) { @@ -3386,22 +3380,23 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem powerRank *= -1; powerRank += float( placementSet.size() ) * TriRand() * randomFactor * 4.f; float cb = distributionData.centerBias; - cb = cb < 0 ? ( float(placementSet.size()) - rankedLocators[uID].w ) * abs(cb) : rankedLocators[uID].w * cb; + cb = cb < 0 ? ( float( placementSet.size() ) - rankedLocators[uID].w ) * abs( cb ) : rankedLocators[uID].w * cb; powerRank += cb; // reuse the map vector for sorting as we no longer need it rankedLocators[uID].x = powerRank; } - struct { - bool operator()(EveSOFDataMgr::LocatorDirectionData &a,EveSOFDataMgr::LocatorDirectionData &b, std::map &priorityMap) const + struct + { + bool operator()( EveSOFDataMgr::LocatorDirectionData& a, EveSOFDataMgr::LocatorDirectionData& b, std::map& priorityMap ) const { return priorityMap[a.uniqueID].x < priorityMap[b.uniqueID].x; } } prioritySort; using namespace std::placeholders; - std::sort(placementSet.begin(), placementSet.end(), std::bind(prioritySort, _1, _2, rankedLocators )); + std::sort( placementSet.begin(), placementSet.end(), std::bind( prioritySort, _1, _2, rankedLocators ) ); } while( count > 0 ) @@ -3411,7 +3406,7 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem } - if( LengthSq(distributionData.randomRotationMaxSteps) > 0.f ) + if( LengthSq( distributionData.randomRotationMaxSteps ) > 0.f ) { // handle rotation randomness float yaw, pitch, roll, stepYaw, stepPitch, stepRoll; @@ -3422,7 +3417,7 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem yaw = stepYaw * floor( distributionData.randomRotationMaxSteps[0] * TriRand() + 0.5f ); pitch = stepPitch * floor( distributionData.randomRotationMaxSteps[1] * TriRand() + 0.5f ); roll = stepRoll * floor( distributionData.randomRotationMaxSteps[2] * TriRand() + 0.5f ); - + Quaternion randomRotation = RotationQuaternion( yaw, pitch, roll ); locator.rotation *= randomRotation; @@ -3441,7 +3436,7 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem { if( managedLocatorSet[index].uniqueID == locator.uniqueID ) { - std::swap(managedLocatorSet[index], managedLocatorSet.back()); + std::swap( managedLocatorSet[index], managedLocatorSet.back() ); managedLocatorSet.pop_back(); break; } @@ -3449,10 +3444,10 @@ void EveSOF::ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacem } } -void EveSOF::CreatePlacement( - EveSpaceObject2Ptr parent, - EveChildInstancedMeshesPtr& sharedMeshes, - EveSOFDNAPtr extensionDna, +void EveSOF::CreatePlacement( + EveSpaceObject2Ptr parent, + EveChildInstancedMeshesPtr& sharedMeshes, + EveSOFDNAPtr extensionDna, const EveSOFDNAPtr& parentDna, EveSOFDataMgr::ExtensionPlacementData& placement, const std::vector& locators, @@ -3469,9 +3464,9 @@ void EveSOF::CreatePlacement( std::vector placementOffsets; placementOffsets.reserve( nestedOffsets.size() * locators.size() ); - - CcpMath::Sphere updatedBoundingSphere(extensionDna->GetParentBoundingSphere()); - CcpMath::AxisAlignedEllipsoid updatedEllipsoid(extensionDna->GetParentHullShapeEllipsoid()); + + CcpMath::Sphere updatedBoundingSphere( extensionDna->GetParentBoundingSphere() ); + CcpMath::AxisAlignedEllipsoid updatedEllipsoid( extensionDna->GetParentHullShapeEllipsoid() ); // Stuff for instanced placements std::vector instances; @@ -3481,8 +3476,8 @@ void EveSOF::CreatePlacement( // Placement Containers - used for non instanced meshes, controllers, effects and audio std::vector placementContainers; - - BlueSharedString extensionName = BlueSharedString(placement.name); + + BlueSharedString extensionName = BlueSharedString( placement.name ); bool hasChildEffects = ( extensionDna->GetHullChildSets().size() > 0 && extensionDna->UsingSof6() ) || ( extensionDna->GetHullChildren().size() > 0 && !extensionDna->UsingSof6() ); bool hasControllers = extensionDna->GetHullControllers().size() > 0; @@ -3497,7 +3492,7 @@ void EveSOF::CreatePlacement( Vector3 randomScale = loc->scaling; if( placement.hasDistribution ) { - if (placement.distribution.uniformScaling) + if( placement.distribution.uniformScaling ) { randomScale = randomScale * Lerp( placement.distribution.randomScaleMin, placement.distribution.randomScaleMax, TriRand() ); } @@ -3561,7 +3556,7 @@ void EveSOF::CreatePlacement( BeObjectMetadata->Set( weak, "SofLocatorIndex", std::to_string( loc - locators.begin() ).c_str() ); } if( hasAnimation ) - { + { Tr2GrannyAnimationPtr animationPtr; animationPtr.CreateInstance(); child->SetAnimationController( animationPtr ); @@ -3588,7 +3583,7 @@ void EveSOF::CreatePlacement( CcpMath::Sphere instanceSphere( extensionDna->GetHullBoundingSphere() ); instanceSphere.Transform( transform ); - + if( placement.extendsBoundingSphere ) { // update the bounding sphere of the parent @@ -3621,7 +3616,7 @@ void EveSOF::CreatePlacement( } } - if( placement.isInstanced) + if( placement.isInstanced ) { if( placement.isShared ) { @@ -3646,14 +3641,14 @@ void EveSOF::CreatePlacement( { auto effect = area->GetMaterialInterface(); effect->SetOption( BlueSharedString( "SPACE_OBJECT_INSTANCED_ATTACHMENT" ), BlueSharedString( "SOIA_SHARED" ) ); - areas.push_back( EveChildInstancedMeshes::MeshArea{ effect, type == TRIBATCHTYPE_DECAL ? TRIBATCHTYPE_OPAQUE : type , uint32_t( area->GetIndex() ), uint32_t( area->GetCount() ) } ); + areas.push_back( EveChildInstancedMeshes::MeshArea{ effect, type == TRIBATCHTYPE_DECAL ? TRIBATCHTYPE_OPAQUE : type, uint32_t( area->GetIndex() ), uint32_t( area->GetCount() ) } ); } } - sharedMeshes->AddMesh( - extensionDna->GetHullGeometryResPath().c_str(), - extensionDna->CastShadow(), - extensionDna->GetReflectionMode(), - 0, + sharedMeshes->AddMesh( + extensionDna->GetHullGeometryResPath().c_str(), + extensionDna->CastShadow(), + extensionDna->GetReflectionMode(), + 0, areas.data(), areas.size(), placementOffsets.data(), @@ -3727,7 +3722,7 @@ void EveSOF::CreatePlacement( placementContainers[index++ % placementContainers.size()]->AddToEffectChildrenList( effect ); } } - + if( needsPlacementContainer ) { for( auto& placementContainer : placementContainers ) @@ -3736,7 +3731,7 @@ void EveSOF::CreatePlacement( if( !placementContainer->Empty() ) { layoutContainer->AddToEffectChildrenList( placementContainer ); - } + } } } @@ -3796,7 +3791,7 @@ void EveSOF::SetupTurretMaterialFromFaction( EveTurretSet* turretSet, const char for( auto it = shader->m_parameters.begin(); it != shader->m_parameters.end(); ++it ) { // build the parameter - EveSOFUtilsParameterName param( genericData->materialPrefixes, (*it)->GetParameterName() ); + EveSOFUtilsParameterName param( genericData->materialPrefixes, ( *it )->GetParameterName() ); if( param.IsMaterialIdxValid() ) { param.ChangeMaterialIdx( genericData, factionData->materialUsageList[param.GetMaterialIdx()] ); @@ -3806,7 +3801,7 @@ void EveSOF::SetupTurretMaterialFromFaction( EveTurretSet* turretSet, const char if( res ) { Tr2Vector4ParameterPtr p; - if( (*it)->QueryInterface( BlueInterfaceIID(), (void**)&p, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)&p, BEQI_SILENT ) ) { p->SetValue( *res ); } @@ -3855,11 +3850,11 @@ void EveSOF::SetupTurretMaterialFromDNA( EveTurretSet* turretSet, const char* dn // then non-const parameters for( auto it = shader->m_parameters.begin(); it != shader->m_parameters.end(); ++it ) { - const Vector4* parentValue = dna->GetFactionTurretParameters( BlueSharedString( (*it)->GetParameterName() ) ); + const Vector4* parentValue = dna->GetFactionTurretParameters( BlueSharedString( ( *it )->GetParameterName() ) ); if( parentValue ) { Tr2Vector4ParameterPtr param; - if( (*it)->QueryInterface( BlueInterfaceIID(), (void**)¶m, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)¶m, BEQI_SILENT ) ) { param->SetValue( *parentValue ); } @@ -3868,4 +3863,3 @@ void EveSOF::SetupTurretMaterialFromDNA( EveTurretSet* turretSet, const char* dn } } } - diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF.h b/trinity/Eve/SpaceObjectFactory/EveSOF.h index dfdf26537..afa18c47b 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOF.h @@ -50,10 +50,11 @@ BLUE_CLASS( EveSOF ) : bool ValidateDNA( const char* dnaString ); // change the material of a turret with SOF data - void SetupTurretMaterialFromDNA( EveTurretSet* turretSet, const char* dnaString ); - void SetupTurretMaterialFromFaction( EveTurretSet* turretSet, const char* factionName ); + void SetupTurretMaterialFromDNA( EveTurretSet * turretSet, const char* dnaString ); + void SetupTurretMaterialFromFaction( EveTurretSet * turretSet, const char* factionName ); bool LoadData( const char* filePath ); + private: // creation EveSpaceObject2Ptr CreateSpaceObject( const EveSOFDNAPtr dna ) const; @@ -75,7 +76,7 @@ BLUE_CLASS( EveSOF ) : } // Use the object as its own hasher (needs to be explicit for non fundamental types in >VS2015) - size_t operator() ( const InheritableTextureKey &key ) const + size_t operator()( const InheritableTextureKey& key ) const { return key; } @@ -92,8 +93,8 @@ BLUE_CLASS( EveSOF ) : void SetupPlaneSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; void SetupSpriteLineSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; void SetupHazeSets( IEveSpaceObjectAttachmentOwnerPtr obj, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; - void SetupBanners( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; - void SetupBannerSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; + void SetupBanners( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; + void SetupBannerSets( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna, const std::vector& offsets ) const; void SetupEffects( EveSpaceObject2Ptr obj, IEveEffectChildrenOwnerPtr childOwner, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; void SetupChildrenAndAnimations( EveSpaceObject2Ptr obj, IEveEffectChildrenOwnerPtr childOwner, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; void SetupEffectChildren( EveSpaceObject2Ptr newObj, IEveEffectChildrenOwnerPtr childOwner, const EveSOFDNAPtr dna, const std::vector& offsets, uint32_t buildFlags ) const; @@ -112,15 +113,15 @@ BLUE_CLASS( EveSOF ) : Tr2MeshPtr CreateMesh( const EveSOFDNAPtr dna ) const; Tr2InstancedMeshPtr CreateInstancedMesh( std::vector instances, std::string resPath ) const; void SetupShaders( const EveSOFDNAPtr dna, Tr2MeshBase* mesh ) const; - - void CreatePlacement( - EveSpaceObject2Ptr parent, - EveChildInstancedMeshesPtr& sharedMeshes, - EveSOFDNAPtr extensionDna, - const EveSOFDNAPtr& parentDna, - EveSOFDataMgr::ExtensionPlacementData& placement, - const std::vector& locators, - const std::vector& nestedOffsets, + + void CreatePlacement( + EveSpaceObject2Ptr parent, + EveChildInstancedMeshesPtr & sharedMeshes, + EveSOFDNAPtr extensionDna, + const EveSOFDNAPtr& parentDna, + EveSOFDataMgr::ExtensionPlacementData& placement, + const std::vector& locators, + const std::vector& nestedOffsets, EveChildContainerPtr layoutContainer ); void SetupCustomMask( EveSpaceObject2Ptr obj, const EveSOFDNAPtr dna ) const; @@ -130,14 +131,14 @@ BLUE_CLASS( EveSOF ) : Tr2EffectPtr CreateBoosterEffect( const EveSOFDataMgr::RaceBoosterData* rdata, const BlueSharedString& lodOption ) const; - bool ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData& placement, const EveSOFDNAPtr dna ); - void ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution& distributionData, const EveSOFDNAPtr dna, std::vector& placementSet, std::vector& managedLocatorSet ); - void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData & distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr& sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer ); + bool ProcessLayoutDistributionConditions( EveSOFDataMgr::ExtensionPlacementData & placement, const EveSOFDNAPtr dna ); + void ProcessLayoutDistributionDistribute( EveSOFDataMgr::ExtensionPlacementDistribution & distributionData, const EveSOFDNAPtr dna, std::vector& placementSet, std::vector& managedLocatorSet ); + void ProcessPlacementDistributionOrGroup( EveSOFDataMgr::ExtensionPlacementData & distributionData, EveSpaceObject2Ptr obj, EveChildInstancedMeshesPtr & sharedMeshes, const EveSOFDNAPtr dna, std::map>& managedLocatorSet, size_t& layoutIdx, size_t& placementIdx, const std::vector& offsets, EveChildContainerPtr childContainer ); // helper functions - size_t FillMeshAreaVector( Tr2MeshAreaVector* meshAreaVector, TriBatchType areaType, const EveSOFDNAPtr dna, size_t hullIdx, size_t meshIndexOffset ) const; - bool GenerateLodResourcePaths( std::string& mediumResPath, std::string& lowResPath, std::string& ultraResPath, const char* resPath, const char* usage ) const; - void GenerateDepthFromAreaVector( Tr2MeshBase* mesh, const Tr2MeshAreaVector* meshAreaVector, const EveSOFDNAPtr dna ) const; + size_t FillMeshAreaVector( Tr2MeshAreaVector * meshAreaVector, TriBatchType areaType, const EveSOFDNAPtr dna, size_t hullIdx, size_t meshIndexOffset ) const; + bool GenerateLodResourcePaths( std::string & mediumResPath, std::string & lowResPath, std::string & ultraResPath, const char* resPath, const char* usage ) const; + void GenerateDepthFromAreaVector( Tr2MeshBase * mesh, const Tr2MeshAreaVector* meshAreaVector, const EveSOFDNAPtr dna ) const; void CreatePointLightData( const Vector3& pos, const float scale, const Color& color, const EveSOFDataMgr::PointLightAttachment* lightData ) const; void CreateTexturedPointLightData( const Vector3& pos, const float scale, const std::string& texturePath, const EveSOFDataMgr::PointLightAttachment* lightData ) const; diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp index f28e32f71..5147e78b7 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp @@ -21,28 +21,28 @@ static char s_dnaSeperatorList = ';'; // dna commands static std::string s_dnaCommands[] = { - "invalid", // CMD_INVALID - "material", // CMD_MATERIAL - "mesh", // CMD_MESH - "respathinsert", // CMD_RESPATHINSERT - "variant", // CMD_VARIANT - "class", // CMD_CLASS - "pattern", // CMD_PATTERN - "layout", // CMD_LAYOUT - "experimental", // CMD_EXPERIMENTAL + "invalid", // CMD_INVALID + "material", // CMD_MATERIAL + "mesh", // CMD_MESH + "respathinsert", // CMD_RESPATHINSERT + "variant", // CMD_VARIANT + "class", // CMD_CLASS + "pattern", // CMD_PATTERN + "layout", // CMD_LAYOUT + "experimental", // CMD_EXPERIMENTAL }; // build classes static std::string s_dnaClasses[] = { - "ship", // BUILDCLASS_SHIP - "mobile", // BUILDCLASS_MOBILE - "stationary", // BUILDCLASS_STATIONARY - "swarm", // BUILDCLASS_SWARM - "extension", // BUILDCLASS_EXTENSION + "ship", // BUILDCLASS_SHIP + "mobile", // BUILDCLASS_MOBILE + "stationary", // BUILDCLASS_STATIONARY + "swarm", // BUILDCLASS_SWARM + "extension", // BUILDCLASS_EXTENSION }; -static_assert( sizeof( s_dnaClasses ) / sizeof( s_dnaClasses[0] ) == EveSOFDataHull::BUILDCLASS_COUNT, - "number of items in s_dnaClasses array does not match the number of items in EveSOFDataHull::BuildClass" ); +static_assert( sizeof( s_dnaClasses ) / sizeof( s_dnaClasses[0] ) == EveSOFDataHull::BUILDCLASS_COUNT, + "number of items in s_dnaClasses array does not match the number of items in EveSOFDataHull::BuildClass" ); // -------------------------------------------------------------------------------- // Description: @@ -190,7 +190,7 @@ bool EveSOFDNA::ValidateContent() break; case CMD_LAYOUT: // Has at least 1 layout - if( cit->second.size() == 0) + if( cit->second.size() == 0 ) { return false; } @@ -240,7 +240,7 @@ void EveSOFDNA::Setup( const char* dnaString, EveSOFDataMgrPtr dataMgr ) for( size_t dnaSubpart = 3; dnaSubpart < dnaParts.size(); ++dnaSubpart ) { // split into command and args - StringSplit( commandArgs, dnaParts[ dnaSubpart ].c_str(), s_dnaSeperatorArg ); + StringSplit( commandArgs, dnaParts[dnaSubpart].c_str(), s_dnaSeperatorArg ); if( commandArgs.size() != 2 ) { CCP_LOGERR( "Invalid SOF DNA, incorrect command and args: %s", dnaString ); @@ -325,7 +325,7 @@ void EveSOFDNA::Setup( const char* dnaString, EveSOFDataMgrPtr dataMgr ) } // store the parent bounding sphere here as a copy of the hull bounding sphere... - m_parentBoundingSphere = GetHullBoundingSphere(); + m_parentBoundingSphere = GetHullBoundingSphere(); m_parentHullShapeEllipsoid = GetHullShapeEllipsoid(); m_isSkinned = m_hullDatas[0]->isSkinned; @@ -345,7 +345,7 @@ void EveSOFDNA::Setup( const BlueSharedString layoutName, const EveSOFDataMgr::D // The descriptor needs to have a hull!!! m_hullDatas.clear(); StringSplit( m_hullNames, descriptor.hull.c_str(), s_dnaSeperatorList ); - for( auto hullName: m_hullNames) + for( auto hullName : m_hullNames ) { const EveSOFDataMgr::HullData* h = m_dataMgr->GetHullData( hullName.c_str() ); if( h == nullptr ) @@ -353,15 +353,15 @@ void EveSOFDNA::Setup( const BlueSharedString layoutName, const EveSOFDataMgr::D CCP_LOGERR( "Couldn't find the requested hull: %s for layout: %s", hullName.c_str(), layoutName.c_str() ); return; } - m_hullDatas.push_back( h ); + m_hullDatas.push_back( h ); } - + if( m_hullDatas.empty() ) { CCP_LOGERR( "Couldn't find at least one hull name for layout: %s", layoutName.c_str() ); return; } - + m_factionName = descriptor.faction.empty() ? parent->m_factionName : descriptor.faction.c_str(); m_raceName = descriptor.race.empty() ? parent->m_raceName : descriptor.race.c_str(); @@ -381,7 +381,7 @@ void EveSOFDNA::Setup( const BlueSharedString layoutName, const EveSOFDataMgr::D } // Process Materials - std::vector materialArgs(4, "None"); + std::vector materialArgs( 4, "None" ); bool gotMaterials = parent->GetDnaCommandArgs( CMD_MATERIAL, materialArgs ); // Small question about how this should function, if the parent has 2 materials // and the descriptor has 1 material, what should we do then? Override? Merge? TBD! @@ -417,7 +417,7 @@ void EveSOFDNA::Setup( const BlueSharedString layoutName, const EveSOFDataMgr::D { m_commands[s_dnaCommands[CMD_RESPATHINSERT]] = respathInsert; } - + // Process respath insert std::vector variant; if( parent->GetDnaCommandArgs( CMD_VARIANT, variant ) ) @@ -451,21 +451,21 @@ void EveSOFDNA::Setup( const BlueSharedString layoutName, const EveSOFDataMgr::D // contruct the dna string m_dna = std::string( descriptor.hull.c_str() ) + s_dnaSeperatorCmd + std::string( m_factionName ) + s_dnaSeperatorCmd + std::string( m_raceName ); - for( auto commands: m_commands ) + for( auto commands : m_commands ) { auto commandType = commands.first; auto commandArgs = commands.second; m_dna += s_dnaSeperatorCmd + commandType + s_dnaSeperatorArg; - for( auto arg: commandArgs ) + for( auto arg : commandArgs ) { m_dna += arg + s_dnaSeperatorList; } m_dna.pop_back(); } - // This allows us to get the top parent hulls information + // This allows us to get the top parent hulls information m_parentBoundingSphere = parent->GetParentBoundingSphere(); m_parentHullShapeEllipsoid = parent->GetParentHullShapeEllipsoid(); @@ -857,9 +857,10 @@ const std::vector* EveSOFDNA::GetHullLocato unsigned int EveSOFDNA::GetLocatorCount( const char* setName ) const { size_t count = 0; - for( const auto& hull : m_hullDatas ) { + for( const auto& hull : m_hullDatas ) + { auto locatorSet = hull->locatorSets.find( BlueSharedString( setName ) ); - + if( locatorSet != hull->locatorSets.end() ) { count += locatorSet->second.size(); @@ -947,7 +948,7 @@ void EveSOFDNA::ModifyTextureResPath( std::string& resPath, std::unordered_mapresPathInsert.empty()) + if( !m_factionData->resPathInsert.empty() ) { pathInsert = m_factionData->resPathInsert.c_str(); } @@ -960,7 +961,7 @@ void EveSOFDNA::ModifyTextureResPath( std::string& resPath, std::unordered_mapgeometryResFilePath; } @@ -1150,7 +1151,7 @@ CcpMath::Sphere EveSOFDNA::GetParentBoundingSphere() const // -------------------------------------------------------------------------------- // Description: -// Returns the shape ellipsoid, needed for layouts to recalculate the +// Returns the shape ellipsoid, needed for layouts to recalculate the // ellipsoid data // -------------------------------------------------------------------------------- CcpMath::AxisAlignedEllipsoid& EveSOFDNA::GetParentHullShapeEllipsoid() @@ -1296,7 +1297,7 @@ const Vector4* EveSOFDNA::GetMeshAreaParameter( EveSOFDataArea::AreaType areaTyp EveSOFUtilsParameterName param( m_genericData->patternMaterialPrefixes, parameterName.c_str() ); if( param.IsMaterialIdxValid() ) { - if( param.GetMaterialIdx() == 0) + if( param.GetMaterialIdx() == 0 ) { // get the material from the lib using the racial name const Vector4* res = EveSOFUtils::SearchForParameterData( m_dataMgr, m_factionData->defaultPatternLayer1MaterialName.c_str(), ¶m ); @@ -1356,7 +1357,6 @@ const Vector4* EveSOFDNA::GetMeshAreaParameter( EveSOFDataArea::AreaType areaTyp { return &it->second; } - } // nope, nothing found @@ -1497,9 +1497,9 @@ size_t EveSOFDNA::GetPatternLayerCount() const if( UsingSof6() ) { auto applicationData = GetFactionalPatternApplicationData(); - if( nullptr != applicationData) + if( nullptr != applicationData ) { - return applicationData->layerAndProjection.size(); + return applicationData->layerAndProjection.size(); } // could not find the hull in the pattern or couldn't find the pattern, so just fall out of this function } @@ -1558,7 +1558,7 @@ const EveSOFDataMgr::PatternApplicationData* EveSOFDNA::GetHullPatternApplicatio return &finder->second; } } - + return nullptr; } @@ -1568,21 +1568,22 @@ const EveSOFDataMgr::PatternApplicationData* EveSOFDNA::GetHullPatternApplicatio // -------------------------------------------------------------------------------- const EveSOFDataMgr::PatternApplicationData* EveSOFDNA::GetPatternApplicationData( bool& theCallerNeedsToDeleteTheResultBecauseIAmBroken ) const { - theCallerNeedsToDeleteTheResultBecauseIAmBroken = false; + theCallerNeedsToDeleteTheResultBecauseIAmBroken = false; if( !HasDnaCommand( CMD_PATTERN ) ) { if( UsingSof6() ) { return GetFactionalPatternApplicationData(); } - else { + else + { // ok no DNA command for a pattern, so we use the default from the hull auto patternTransform = &m_hullDatas[0]->defaultPattern; auto patternLayer = &m_factionData->defaultPatternInfo; EveSOFDataMgr::PatternApplicationData* application = new EveSOFDataMgr::PatternApplicationData(); application->layerAndProjection.push_back( std::make_pair( *patternLayer, *patternTransform ) ); - theCallerNeedsToDeleteTheResultBecauseIAmBroken = true; + theCallerNeedsToDeleteTheResultBecauseIAmBroken = true; return application; } } @@ -1623,7 +1624,7 @@ const EveSOFDataMgr::PatternProjectionData* EveSOFDNA::GetPatternProjectionData( // Description: // Return pattern layer data, but needs to exist for provided hull! // -------------------------------------------------------------------------------- -const EveSOFDataMgr::PatternLayerData* EveSOFDNA::GetPatternLayerData( const EveSOFDataMgr::PatternApplicationData* patternApplicationData, size_t layer ) const +const EveSOFDataMgr::PatternLayerData* EveSOFDNA::GetPatternLayerData( const EveSOFDataMgr::PatternApplicationData* patternApplicationData, size_t layer ) const { if( nullptr == patternApplicationData ) { @@ -1653,7 +1654,7 @@ const EveSOFDataMgr::PatternLayerData* EveSOFDNA::GetPatternLayerData( const Eve // -------------------------------------------------------------------------------- const Vector4 EveSOFDNA::GetMaterialTargets( const EveSOFDataMgr::PatternLayerData* layerData ) const { - return layerData->materialTargets; + return layerData->materialTargets; } // -------------------------------------------------------------------------------- @@ -1661,7 +1662,7 @@ const Vector4 EveSOFDNA::GetMaterialTargets( const EveSOFDataMgr::PatternLayerDa // Return pattern data // -------------------------------------------------------------------------------- bool EveSOFDNA::IsPatternLayerApplicableToArea( const EveSOFDataMgr::PatternLayerData* layerData, EveSOFDataArea::AreaType areaType ) const -{ +{ if( nullptr == layerData ) { return false; @@ -1697,7 +1698,7 @@ const std::vector* EveSOFDNA::GetPlacementL { auto hull = m_hullDatas[hullIndex]; auto locators = hull->locatorSets.find( locatorSetName ); - if( locators == hull->locatorSets.end()) + if( locators == hull->locatorSets.end() ) { return nullptr; } @@ -1741,7 +1742,7 @@ bool EveSOFDNA::HasDnaCommand( DnaCommand cmd ) const bool EveSOFDNA::GetDnaCommandArgs( DnaCommand cmd, std::vector& args ) const { // try to find it! - auto commandIt = m_commands.find( s_dnaCommands[ cmd ] ); + auto commandIt = m_commands.find( s_dnaCommands[cmd] ); if( commandIt == m_commands.end() ) { return false; @@ -1765,12 +1766,12 @@ bool EveSOFDNA::UsingSof6() const BlueSharedString EveSOFDNA::GetFactionName() const { - return BlueSharedString(m_factionName); + return BlueSharedString( m_factionName ); } BlueSharedString EveSOFDNA::GetRaceName() const { - return BlueSharedString(m_raceName); + return BlueSharedString( m_raceName ); } EntityComponents::ReflectionMode EveSOFDNA::GetReflectionMode() const diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDNA.h b/trinity/Eve/SpaceObjectFactory/EveSOFDNA.h index 9d27df869..2e59a309c 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDNA.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDNA.h @@ -38,7 +38,7 @@ BLUE_CLASS( EveSOFDNA ) : CMD_PATTERN, CMD_LAYOUT, CMD_MAX - }; + }; // initialize this dna void Setup( const char* dnaString, EveSOFDataMgrPtr dataMgr ); @@ -112,7 +112,7 @@ BLUE_CLASS( EveSOFDNA ) : bool GetHullTextureWithMeshIndex( std::string & resPath, const BlueSharedString& textureName, int32_t meshIndex, size_t n, std::unordered_map* existingFilesCache ) const; // get faction data - void ModifyTextureResPath( std::string& resPath, std::unordered_map* existingFilesCache ) const; + void ModifyTextureResPath( std::string & resPath, std::unordered_map * existingFilesCache ) const; const Vector4* GetFactionTurretParameters( const BlueSharedString& parameterName ) const; const EveSOFDataMgr::FactionPlaneSetColorData* GetFactionPlaneSetData( int groupIndex ) const; const EveSOFDataMgr::FactionSpotlightSetColorData* GetFactionSpotlightSetData( int groupIndex ) const; @@ -162,7 +162,7 @@ BLUE_CLASS( EveSOFDNA ) : // special cusomt data setup void SetupCustomData(); // search for a dna - bool GetDnaCommandArgs( DnaCommand cmd, std::vector& args ) const; + bool GetDnaCommandArgs( DnaCommand cmd, std::vector & args ) const; bool HasDnaCommand( DnaCommand cmd ) const; // the factional pattern application data diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDNA_Blue.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFDNA_Blue.cpp index 67826b88a..7a7fb7ef9 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDNA_Blue.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDNA_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveSOFDNA ); const Be::ClassInfo* EveSOFDNA::ExposeToBlue() { - EXPOSURE_BEGIN( EveSOFDNA, "" ) - MAP_INTERFACE( EveSOFDNA ) + EXPOSURE_BEGIN( EveSOFDNA, "" ) + MAP_INTERFACE( EveSOFDNA ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFData.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFData.cpp index 244f928bc..a2bee69a0 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFData.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFData.cpp @@ -21,18 +21,22 @@ EveSOFData::EveSOFData( IRoot* lockobj ) : PARENTLOCK( m_material ), PARENTLOCK( m_pattern ), PARENTLOCK( m_layout ) -{} +{ +} EveSOFData::~EveSOFData() -{} +{ +} EveSOFDataAreaMaterial::EveSOFDataAreaMaterial( IRoot* lockobj ) : m_glowColorType( SOFDataFactionColorChooser::TYPE_HULL ) -{} +{ +} EveSOFDataArea::EveSOFDataArea( IRoot* lockobj ) -{} +{ +} EveSOFDataFactionColorSet::EveSOFDataFactionColorSet( IRoot* lockobj ) @@ -47,7 +51,7 @@ EveSOFDataFactionColorSet::EveSOFDataFactionColorSet( IRoot* lockobj ) m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_SIEGE_FX] = Color( uint32_t( 0xFFFF5E2D ) ); // Artist authored default value } -EveSOFDataLogo::EveSOFDataLogo( IRoot* lockobj ): +EveSOFDataLogo::EveSOFDataLogo( IRoot* lockobj ) : PARENTLOCK( m_textures ) { } @@ -60,44 +64,47 @@ EveSOFDataLogoSet::EveSOFDataLogoSet( IRoot* lockobj ) } } -EveSOFDataBlink::EveSOFDataBlink( IRoot* lockobj ) +EveSOFDataBlink::EveSOFDataBlink( IRoot* lockobj ) { } EveSOFDataBlinkType::EveSOFDataBlinkType( IRoot* lockobj ) { - for ( uint32_t i = 0; i < TYPE_CYCLE; ++i ) + for( uint32_t i = 0; i < TYPE_CYCLE; ++i ) { - m_blinkType[i] = EveSOFDataBlinkPtr(); + m_blinkType[i] = EveSOFDataBlinkPtr(); } } EveSOFDataParameter::EveSOFDataParameter( IRoot* lockobj ) : m_value( 0.f, 0.f, 0.f, 0.f ) -{} +{ +} EveSOFDataFactionHullArea::EveSOFDataFactionHullArea( IRoot* lockobj ) : PARENTLOCK( m_parameters ) -{} +{ +} EveSOFDataFactionChild::EveSOFDataFactionChild( IRoot* lockobj ) : m_groupIndex( -1 ), m_isVisible( false ) -{} +{ +} EveSOFDataTexture::EveSOFDataTexture( IRoot* lockobj ) -{} +{ +} -static BlueStructureDefinition s_eveSOFMeshInstanceDef[] = -{ - { "rotation", Be::FLOAT32_4, 0 }, - { "scaling", Be::FLOAT32_3, 16 }, - { "translation", Be::FLOAT32_3, 28 }, - { "boneIndex", Be::INT32_1, 40 }, +static BlueStructureDefinition s_eveSOFMeshInstanceDef[] = { + { "rotation", Be::FLOAT32_4, 0 }, + { "scaling", Be::FLOAT32_3, 16 }, + { "translation", Be::FLOAT32_3, 28 }, + { "boneIndex", Be::INT32_1, 40 }, { 0 } }; @@ -113,17 +120,20 @@ EveSOFDataInstancedMesh::EveSOFDataInstancedMesh( IRoot* lockobj ) : EveSOFDataGenericString::EveSOFDataGenericString( IRoot* lockobj ) -{} +{ +} EveSOFDataVisibilityGroup::EveSOFDataVisibilityGroup( IRoot* lockobj ) -{} +{ +} EveSOFDataGenericShader::EveSOFDataGenericShader( IRoot* lockobj ) : m_doGenerateDepthArea( true ), PARENTLOCK( m_parameters ), PARENTLOCK( m_defaultTextures ), PARENTLOCK( m_defaultParameters ) -{} +{ +} EveSOFDataGenericDecalShader::EveSOFDataGenericDecalShader( IRoot* lockobj ) : @@ -131,7 +141,8 @@ EveSOFDataGenericDecalShader::EveSOFDataGenericDecalShader( IRoot* lockobj ) : PARENTLOCK( m_defaultTextures ), PARENTLOCK( m_parentTextures ), m_additive( false ) -{} +{ +} EveSOFDataGenericDamage::EveSOFDataGenericDamage( IRoot* lockobj ) : @@ -154,7 +165,8 @@ EveSOFDataGenericDamage::EveSOFDataGenericDamage( IRoot* lockobj ) : m_armorParticleTurbulenceAmplitude( 0.f ), m_armorParticleTurbulenceFrequency( 1 ), m_armorParticleColorMidPoint( 0.5f ) -{} +{ +} EveSOFDataGenericHullDamage::EveSOFDataGenericHullDamage( IRoot* lockobj ) : m_hullParticleRate( 0.f ), @@ -173,7 +185,8 @@ EveSOFDataGenericHullDamage::EveSOFDataGenericHullDamage( IRoot* lockobj ) : m_hullParticleDrag( 0.f ), m_hullParticleTurbulenceAmplitude( 0.f ), m_hullParticleTurbulenceFrequency( 1 ) -{} +{ +} EveSOFDataGeneric::EveSOFDataGeneric( IRoot* lockobj ) : PARENTLOCK( m_materialPrefixes ), @@ -193,14 +206,15 @@ EveSOFDataGeneric::EveSOFDataGeneric( IRoot* lockobj ) : EveSOFDataGenericVariant::EveSOFDataGenericVariant( IRoot* lockobj ) : m_isTransparent( false ) - {} +{ +} EveSOFDataGenericHullCategory::EveSOFDataGenericHullCategory( IRoot* lockobj ) : - m_categoryName( "" ), - m_reflectionMode( EntityComponents::REFLECT_NEVER ) - { - } + m_categoryName( "" ), + m_reflectionMode( EntityComponents::REFLECT_NEVER ) +{ +} EveSOFDataFaction::EveSOFDataFaction( IRoot* lockobj ) : @@ -222,8 +236,9 @@ EveSOFDataBoosterShape::EveSOFDataBoosterShape( IRoot* lockobj ) : m_noiseAmplitureEnd( 0.f, 0.f, 0.f, 0.f ), m_noiseFrequency( 0.f, 0.f, 0.f, 0.f ), m_color( 0.f, 0.f, 0.f, 0.f ) -{} - +{ +} + EveSOFDataBooster::EveSOFDataBooster( IRoot* lockobj ) : m_scale( 1.f, 1.f, 1.f, 1.f ), @@ -256,7 +271,7 @@ EveSOFDataBooster::EveSOFDataBooster( IRoot* lockobj ) : EveSOFDataRaceDamage::EveSOFDataRaceDamage( IRoot* lockobj ) : PARENTLOCK( m_armorImpactParameters ), - PARENTLOCK( m_armorImpactTextures), + PARENTLOCK( m_armorImpactTextures ), PARENTLOCK( m_shieldImpactParameters ), PARENTLOCK( m_shieldImpactTextures ) { @@ -313,18 +328,21 @@ EveSOFDataHull::EveSOFDataHull( IRoot* lockobj ) : m_sof6( false ), m_impactEffectType( IMPACTEFFECT_NONE ), m_audioPosition( 0.f, 0.f, 0.f ) -{} +{ +} EveSOFDataRace::EveSOFDataRace( IRoot* lockobj ) : m_hullPrimaryHeatColorType( SOFDataFactionColorChooser::TYPE_BOOSTER ), m_hullReactorHeatColorType( SOFDataFactionColorChooser::TYPE_REACTOR ) -{} +{ +} EveSOFDataMaterial::EveSOFDataMaterial( IRoot* lockobj ) : PARENTLOCK( m_parameters ) -{} +{ +} EveSOFDataPatternMaterialOverride::EveSOFDataPatternMaterialOverride( IRoot* lockobj ) : m_isTargetMtl1( true ), @@ -335,10 +353,11 @@ EveSOFDataPatternMaterialOverride::EveSOFDataPatternMaterialOverride( IRoot* loc } EveSOFDataPatternPerHull::EveSOFDataPatternPerHull( IRoot* lockobj ) -{} +{ +} -EveSOFDataPatternLayer::EveSOFDataPatternLayer(IRoot* lockobj) : +EveSOFDataPatternLayer::EveSOFDataPatternLayer( IRoot* lockobj ) : m_projectionTypeU( PROJECTION_REPEAT ), m_projectionTypeV( PROJECTION_REPEAT ), m_materialSource( SOURCE_MATERIAL1 ), @@ -346,7 +365,8 @@ EveSOFDataPatternLayer::EveSOFDataPatternLayer(IRoot* lockobj) : m_isTargetMtl2( true ), m_isTargetMtl3( true ), m_isTargetMtl4( true ) -{} +{ +} EveSOFDataPatternLayerProperties::EveSOFDataPatternLayerProperties( IRoot* lockobj ) : m_projectionTypeU( PROJECTION_REPEAT ), @@ -360,7 +380,7 @@ EveSOFDataPatternLayerProperties::EveSOFDataPatternLayerProperties( IRoot* locko } EveSOFDataPatternApplicationGroup::EveSOFDataPatternApplicationGroup( IRoot* lockobj ) : - PARENTLOCK(m_projections) + PARENTLOCK( m_projections ) { } @@ -369,7 +389,8 @@ EveSOFDataPatternTransform::EveSOFDataPatternTransform( IRoot* lockobj ) : m_scaling( 1.f, 1.f, 1.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_isMirrored( false ) -{} +{ +} EveSOFDataPattern::EveSOFDataPattern( IRoot* lockobj ) : @@ -387,18 +408,18 @@ EveSOFDataHullArea::EveSOFDataHullArea( IRoot* lockobj ) : m_count( 1 ), m_blockedMaterials( 0 ), m_areaType( EveSOFDataArea::TYPE_PRIMARY ) -{} +{ +} -static BlueStructureDefinition s_eveSOFDecalIndexDef[] = -{ - { "index", Be::UINT32_1, 0 }, - {0} +static BlueStructureDefinition s_eveSOFDecalIndexDef[] = { + { "index", Be::UINT32_1, 0 }, + { 0 } }; -EveSOFDataHullLocator::EveSOFDataHullLocator( IRoot* lockobj ) - :m_transform( IdentityMatrix() ) +EveSOFDataHullLocator::EveSOFDataHullLocator( IRoot* lockobj ) : + m_transform( IdentityMatrix() ) { } @@ -448,7 +469,8 @@ std::string EveSOFDataHullChildSetItem::GetName() EveSOFDataHullChildSet::EveSOFDataHullChildSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} std::string EveSOFDataHullChildSet::GetName() { @@ -464,7 +486,8 @@ EveSOFDataHullChild::EveSOFDataHullChild( IRoot* lockobj ) : m_id( -1 ), m_groupIndex( -1 ), m_buildFilter( EveSOFDataHullBuildFilter::DEFAULT_FILTER ) -{} +{ +} std::string EveSOFDataHullChild::GetName() { @@ -497,7 +520,8 @@ EveSOFDataHullAnimation::EveSOFDataHullAnimation( IRoot* lockobj ) : m_id( -1 ), m_startRate( -1 ), m_endRate( -1 ) -{} +{ +} EveSOFDataPointLightAttachment::EveSOFDataPointLightAttachment( IRoot* lockobj ) : m_saturation( 1.0f ), @@ -510,7 +534,8 @@ EveSOFDataPointLightAttachment::EveSOFDataPointLightAttachment( IRoot* lockobj ) m_noiseOctaves( 1 ), m_lightProfilePath( L"" ), m_rotation( Quaternion( 0, 0, 0, 1 ) ) -{} +{ +} EveSOFDataSpotLightAttachment::EveSOFDataSpotLightAttachment( IRoot* lockobj ) : m_saturation( 1.0f ), @@ -524,26 +549,20 @@ EveSOFDataSpotLightAttachment::EveSOFDataSpotLightAttachment( IRoot* lockobj ) : m_noiseFrequency( 1.0 ), m_noiseOctaves( 1 ), m_lightProfilePath( L"" ) -{} +{ +} EveSOFDataHullSpotlightSet::EveSOFDataHullSpotlightSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ), m_skinned( false ), m_zOffset( 0.f ) -{} +{ +} EveSOFDataHullSpotlightSetItem::EveSOFDataHullSpotlightSetItem( IRoot* lockobj ) : - m_boneIndex( 0 ), m_groupIndex( -1 ), - m_boosterGainInfluence( false ), - m_spriteScale( 1.f, 1.f, 1.f ), - m_coneIntensity( 0.f ), - m_flareIntensity( 0.f ), - m_spriteIntensity( 0.f ), - m_saturation( 1.f ), - m_transform( IdentityMatrix() ), - m_colorType( SOFDataFactionColorChooser::TYPE_HULL ) + m_boneIndex( 0 ), m_groupIndex( -1 ), m_boosterGainInfluence( false ), m_spriteScale( 1.f, 1.f, 1.f ), m_coneIntensity( 0.f ), m_flareIntensity( 0.f ), m_spriteIntensity( 0.f ), m_saturation( 1.f ), m_transform( IdentityMatrix() ), m_colorType( SOFDataFactionColorChooser::TYPE_HULL ) { m_light = nullptr; } @@ -556,7 +575,8 @@ EveSOFDataHullPlaneSet::EveSOFDataHullPlaneSet( IRoot* lockobj ) : m_usage( USAGE_STANDARD ), m_atlasSize( 1 ), m_atlasAspectRatio( 1, 1 ) -{} +{ +} EveSOFDataHullPlaneSetItem::EveSOFDataHullPlaneSetItem( IRoot* lockobj ) : @@ -588,12 +608,18 @@ EveSOFDataHullSpriteSet::EveSOFDataHullSpriteSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_skinned( false ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} EveSOFDataHullSpriteSetItem::EveSOFDataHullSpriteSetItem( IRoot* lockobj ) : m_position( 0.f, 0.f, 0.f ), - m_blinkRate( 0.1f ), m_blinkPhase( 0.f ), m_minScale( 1.f ), m_maxScale( 10.f ), m_falloff( 0.f ), m_intensity( 1.f ), + m_blinkRate( 0.1f ), + m_blinkPhase( 0.f ), + m_minScale( 1.f ), + m_maxScale( 10.f ), + m_falloff( 0.f ), + m_intensity( 1.f ), m_saturation( 1.f ), m_boneIndex( 0 ), m_colorType( SOFDataFactionColorChooser::TYPE_PRIMARY ) @@ -606,16 +632,11 @@ EveSOFDataHullSpriteLineSet::EveSOFDataHullSpriteLineSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_skinned( false ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} EveSOFDataHullSpriteLineSetItem::EveSOFDataHullSpriteLineSetItem( IRoot* lockobj ) : - m_position( 0.f, 0.f, 0.f ), m_scaling( 1.f, 1.f, 1.f ), - m_rotation( 0.f, 0.f, 0.f, 1.f ), - m_spacing( 1.f ), m_blinkRate( 0.1f ), m_blinkPhase( 0.f ), m_blinkPhaseShift( 0.f ), m_minScale( 1.f ), m_maxScale( 10.f ), m_falloff( 0.f ), m_intensity( 1.f ), - m_saturation( 1.f ), - m_boneIndex( 0 ), - m_isCircle( false ), - m_colorType( SOFDataFactionColorChooser::TYPE_PRIMARY ) + m_position( 0.f, 0.f, 0.f ), m_scaling( 1.f, 1.f, 1.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_spacing( 1.f ), m_blinkRate( 0.1f ), m_blinkPhase( 0.f ), m_blinkPhaseShift( 0.f ), m_minScale( 1.f ), m_maxScale( 10.f ), m_falloff( 0.f ), m_intensity( 1.f ), m_saturation( 1.f ), m_boneIndex( 0 ), m_isCircle( false ), m_colorType( SOFDataFactionColorChooser::TYPE_PRIMARY ) { m_light = nullptr; } @@ -625,15 +646,20 @@ EveSOFDataHullHazeSet::EveSOFDataHullHazeSet( IRoot* lockobj ) : m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ), m_skinned( false ), m_hazeType( EveSOFDataHullHazeSet::TYPE_SPHERICAL ) -{} +{ +} EveSOFDataHullHazeSetItem::EveSOFDataHullHazeSetItem( IRoot* lockobj ) : PARENTLOCK( m_lights ), - m_position( 0.f, 0.f, 0.f ), m_scaling( 1.f, 1.f, 1.f ), + m_position( 0.f, 0.f, 0.f ), + m_scaling( 1.f, 1.f, 1.f ), m_boneIndex( -1 ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_colorType( SOFDataFactionColorChooser::TYPE_PRIMARY ), - m_hazeBrightness( 1.f ), m_hazeFalloff( 6.f ), m_sourceSize( 0.2f ), m_sourceBrightness( 2.f ), + m_hazeBrightness( 1.f ), + m_hazeFalloff( 6.f ), + m_sourceSize( 0.2f ), + m_sourceBrightness( 2.f ), m_saturation( 1.f ), m_boosterGainInfluence( false ) { @@ -643,18 +669,19 @@ EveSOFDataHullHazeSetItem::EveSOFDataHullHazeSetItem( IRoot* lockobj ) : /// Banners /// -EveSOFDataHullBannerLight::EveSOFDataHullBannerLight( IRoot* ) - :m_radiusMultiplier( 1 ), +EveSOFDataHullBannerLight::EveSOFDataHullBannerLight( IRoot* ) : + m_radiusMultiplier( 1 ), m_brightness( 1 ), m_innerRadiusMultiplier( 0.3 ), m_noiseAmplitude( 0 ), m_noiseFrequency( 1 ), m_noiseOctaves( 1 ), m_saturation( 1 ) -{} +{ +} -EveSOFDataHullBanner::EveSOFDataHullBanner( IRoot* ) - :m_usage( VERTICAL_BANNER ), +EveSOFDataHullBanner::EveSOFDataHullBanner( IRoot* ) : + m_usage( VERTICAL_BANNER ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ), m_position( 0, 0, 0 ), m_scaling( 1, 1, 1 ), @@ -754,10 +781,11 @@ void EveSOFDataHullBanner::SetScaling( const Vector3& scaling ) } } -EveSOFDataHullBannerSet::EveSOFDataHullBannerSet( IRoot* lockobj ): +EveSOFDataHullBannerSet::EveSOFDataHullBannerSet( IRoot* lockobj ) : PARENTLOCK( m_banners ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} std::string EveSOFDataHullBannerSet::GetName() @@ -866,10 +894,11 @@ void EveSOFDataHullBannerSetItem::SetScaling( const Vector3& scaling ) } } -EveSOFDataHullDecalSet::EveSOFDataHullDecalSet( IRoot* lockobj ): +EveSOFDataHullDecalSet::EveSOFDataHullDecalSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} EveSOFDataMultiHullDecalIndexBuffers::EveSOFDataMultiHullDecalIndexBuffers( IRoot* lockobj ) : PARENTLOCK( m_indexBuffers ) @@ -933,11 +962,12 @@ unsigned char* EveSOFDataDecalIndexBuffer::AllocateReadBuffer( const char* membe EveSOFDataHullLightSet::EveSOFDataHullLightSet( IRoot* lockobj ) : PARENTLOCK( m_items ), m_visibilityGroup( PRIMARY_VISIBILITY_GROUP ) -{} +{ +} EveSOFDataHullLightSetItem::EveSOFDataHullLightSetItem( IRoot* lockobj ) : - m_name("") + m_name( "" ) { m_data.brightness = 0.0f; m_data.innerRadius = 0.0f; @@ -972,25 +1002,29 @@ EveSOFDataHullLightSetSpotLight::EveSOFDataHullLightSetSpotLight( IRoot* lockobj EveSOFDataFactionVisibilityGroupSet::EveSOFDataFactionVisibilityGroupSet( IRoot* lockobj ) : PARENTLOCK( m_visibilityGroups ) -{} +{ +} EveSOFDataFactionSpotlightSet::EveSOFDataFactionSpotlightSet( IRoot* lockobj ) : m_groupIndex( -1 ), m_coneColor( 0.f, 0.f, 0.f, 0.f ), m_spriteColor( 0.f, 0.f, 0.f, 0.f ), m_flareColor( 0.f, 0.f, 0.f, 0.f ) -{} +{ +} EveSOFDataFactionPlaneSet::EveSOFDataFactionPlaneSet( IRoot* lockobj ) : m_groupIndex( -1 ), m_color( 0.f, 0.f, 0.f, 0.f ) -{} +{ +} EveSOFDataHullBooster::EveSOFDataHullBooster( IRoot* lockobj ) : PARENTLOCK( m_items ), m_alwaysOn( false ), m_hasTrails( true ) -{} +{ +} EveSOFDataHullBoosterItem::EveSOFDataHullBoosterItem( IRoot* lockobj ) : @@ -1003,8 +1037,8 @@ EveSOFDataHullBoosterItem::EveSOFDataHullBoosterItem( IRoot* lockobj ) : { } -EveSOFDataHullSoundEmitter::EveSOFDataHullSoundEmitter( IRoot* ): - m_position( Vector3(0.0, 0.0, 0.0) ), +EveSOFDataHullSoundEmitter::EveSOFDataHullSoundEmitter( IRoot* ) : + m_position( Vector3( 0.0, 0.0, 0.0 ) ), m_rotation( Quaternion( 0.f, 0.f, 0.f, 1.f ) ), m_attenuationScalingFactor( 1.0f ) { @@ -1023,7 +1057,7 @@ EveSOFDNADescriptor::EveSOFDNADescriptor( IRoot* ) : { } -EveSOFDataHullExtensionPlacement::EveSOFDataHullExtensionPlacement( IRoot* lockobj ): +EveSOFDataHullExtensionPlacement::EveSOFDataHullExtensionPlacement( IRoot* lockobj ) : PARENTLOCK( m_distributionConditions ), m_name( "" ), m_locatorSetName( "" ), @@ -1038,7 +1072,7 @@ EveSOFDataHullExtensionPlacement::EveSOFDataHullExtensionPlacement( IRoot* lock m_descriptor.CreateInstance(); } -EveSOFDataHullExtensionPlacementGroup::EveSOFDataHullExtensionPlacementGroup(IRoot* lockobj) : +EveSOFDataHullExtensionPlacementGroup::EveSOFDataHullExtensionPlacementGroup( IRoot* lockobj ) : PARENTLOCK( m_placements ), PARENTLOCK( m_distributionConditions ), PARENTLOCK( m_depletionCounters ), diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFData.h b/trinity/Eve/SpaceObjectFactory/EveSOFData.h index 205611f08..cd27a44f0 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFData.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFData.h @@ -19,7 +19,9 @@ BLUE_CLASS( EveSOFDataParameter ) : public: EXPOSE_TO_BLUE(); EveSOFDataParameter( IRoot* lockobj = NULL ); - ~EveSOFDataParameter() {} + ~EveSOFDataParameter() + { + } // simple shader parameter BlueSharedString m_name; @@ -34,7 +36,9 @@ BLUE_CLASS( EveSOFDataGenericString ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericString( IRoot* lockobj = NULL ); - ~EveSOFDataGenericString() {} + ~EveSOFDataGenericString() + { + } std::string m_str; }; @@ -63,7 +67,9 @@ BLUE_CLASS( EveSOFDataTexture ) : public: EXPOSE_TO_BLUE(); EveSOFDataTexture( IRoot* lockobj = NULL ); - ~EveSOFDataTexture() {} + ~EveSOFDataTexture() + { + } // data std::string m_resFilePath; @@ -90,12 +96,14 @@ BLUE_CLASS( EveSOFDataInstancedMesh ) : public: EXPOSE_TO_BLUE(); EveSOFDataInstancedMesh( IRoot* lockobj = NULL ); - ~EveSOFDataInstancedMesh() {} + ~EveSOFDataInstancedMesh() + { + } // data BlueSharedString m_name; Tr2Lod m_lowestLodVisible; - + enum DisplayQualityModifier { SHADER_ALL = 5, @@ -121,7 +129,9 @@ BLUE_CLASS( EveSOFDataTransform ) : public: EXPOSE_TO_BLUE(); EveSOFDataTransform( IRoot* lockobj = NULL ); - ~EveSOFDataTransform() {} + ~EveSOFDataTransform() + { + } // data Vector3 m_position; @@ -134,56 +144,56 @@ BLUE_DECLARE_VECTOR( EveSOFDataTransform ); namespace SOFDataFactionColorChooser { - enum ColorType - { - TYPE_PRIMARY = 0, - TYPE_SECONDARY, - TYPE_TERTIARY, - TYPE_BLACK, - TYPE_WHITE, - TYPE_YELLOW, - TYPE_ORANGE, - TYPE_RED, - TYPE_BLUE, - TYPE_GREEN, - TYPE_CYAN, - TYPE_FIRE, - TYPE_HULL, - TYPE_GLASS, - TYPE_REACTOR, - TYPE_DARKHULL, - TYPE_BOOSTER, - TYPE_KILLMARK, - TYPE_PRIMARY_LIGHT, - TYPE_SECONDARY_LIGHT, - TYPE_TERTIARY_LIGHT, - TYPE_WHITE_LIGHT, - TYPE_PRIMARY_HOLOGRAM, - TYPE_SECONDARY_HOLOGRAM, - TYPE_TERTIARY_HOLOGRAM, - TYPE_STATE_0, - TYPE_STATE_1, - TYPE_STATE_2, - TYPE_STATE_3, - TYPE_STATE_VULNERABLE, - TYPE_STATE_INVULNERABLE, - TYPE_PRIMARY_FORCEFIELD, - TYPE_SECONDARY_FORCEFIELD, - TYPE_PRIMARY_BANNER, - TYPE_PRIMARY_FX, - TYPE_SECONDARY_FX, - TYPE_PRIMARY_SPOTLIGHT, - TYPE_SECONDARY_SPOTLIGHT, - TYPE_TERTIARY_SPOTLIGHT, - TYPE_PRIMARY_BILLBOARD, - TYPE_PRIMARY_WARP_FX, - TYPE_PRIMARY_ATTACK_FX, - TYPE_PRIMARY_SIEGE_FX, - TYPE_PRIMARY_DOCKED_FX, - TYPE_MAX, - }; - - extern const Be::VarChooser EveSOFDataFactionColorSetTypeChooser[]; +enum ColorType +{ + TYPE_PRIMARY = 0, + TYPE_SECONDARY, + TYPE_TERTIARY, + TYPE_BLACK, + TYPE_WHITE, + TYPE_YELLOW, + TYPE_ORANGE, + TYPE_RED, + TYPE_BLUE, + TYPE_GREEN, + TYPE_CYAN, + TYPE_FIRE, + TYPE_HULL, + TYPE_GLASS, + TYPE_REACTOR, + TYPE_DARKHULL, + TYPE_BOOSTER, + TYPE_KILLMARK, + TYPE_PRIMARY_LIGHT, + TYPE_SECONDARY_LIGHT, + TYPE_TERTIARY_LIGHT, + TYPE_WHITE_LIGHT, + TYPE_PRIMARY_HOLOGRAM, + TYPE_SECONDARY_HOLOGRAM, + TYPE_TERTIARY_HOLOGRAM, + TYPE_STATE_0, + TYPE_STATE_1, + TYPE_STATE_2, + TYPE_STATE_3, + TYPE_STATE_VULNERABLE, + TYPE_STATE_INVULNERABLE, + TYPE_PRIMARY_FORCEFIELD, + TYPE_SECONDARY_FORCEFIELD, + TYPE_PRIMARY_BANNER, + TYPE_PRIMARY_FX, + TYPE_SECONDARY_FX, + TYPE_PRIMARY_SPOTLIGHT, + TYPE_SECONDARY_SPOTLIGHT, + TYPE_TERTIARY_SPOTLIGHT, + TYPE_PRIMARY_BILLBOARD, + TYPE_PRIMARY_WARP_FX, + TYPE_PRIMARY_ATTACK_FX, + TYPE_PRIMARY_SIEGE_FX, + TYPE_PRIMARY_DOCKED_FX, + TYPE_MAX, +}; + +extern const Be::VarChooser EveSOFDataFactionColorSetTypeChooser[]; } BLUE_CLASS( EveSOFDataFactionColorSet ) : @@ -192,7 +202,9 @@ BLUE_CLASS( EveSOFDataFactionColorSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionColorSet( IRoot* lockobj = NULL ); - ~EveSOFDataFactionColorSet() {} + ~EveSOFDataFactionColorSet() + { + } // color data @@ -206,7 +218,9 @@ BLUE_CLASS( EveSOFDataLogo ) : public: EXPOSE_TO_BLUE(); EveSOFDataLogo( IRoot* lockobj = NULL ); - ~EveSOFDataLogo() {} + ~EveSOFDataLogo() + { + } PEveSOFDataTextureVector m_textures; }; @@ -219,7 +233,9 @@ BLUE_CLASS( EveSOFDataLogoSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataLogoSet( IRoot* lockobj = NULL ); - ~EveSOFDataLogoSet() {} + ~EveSOFDataLogoSet() + { + } // color type enum LogoType @@ -245,7 +261,9 @@ BLUE_CLASS( EveSOFDataBlink ) : public: EXPOSE_TO_BLUE(); EveSOFDataBlink( IRoot* lockobj = NULL ); - ~EveSOFDataBlink() {} + ~EveSOFDataBlink() + { + } }; TYPEDEF_BLUECLASS( EveSOFDataBlink ); @@ -256,7 +274,9 @@ BLUE_CLASS( EveSOFDataBlinkType ) : public: EXPOSE_TO_BLUE(); EveSOFDataBlinkType( IRoot* lockobj = NULL ); - ~EveSOFDataBlinkType() {} + ~EveSOFDataBlinkType() + { + } // color type enum BlinkType @@ -279,7 +299,9 @@ BLUE_CLASS( EveSOFDataAreaMaterial ) : public: EXPOSE_TO_BLUE(); EveSOFDataAreaMaterial( IRoot* lockobj = NULL ); - ~EveSOFDataAreaMaterial() {} + ~EveSOFDataAreaMaterial() + { + } // materials enum MaterialType @@ -293,7 +315,7 @@ BLUE_CLASS( EveSOFDataAreaMaterial ) : // data std::string m_material[MATERIAL_MAX]; - SOFDataFactionColorChooser::ColorType m_glowColorType; + SOFDataFactionColorChooser::ColorType m_glowColorType; }; TYPEDEF_BLUECLASS( EveSOFDataAreaMaterial ); @@ -303,7 +325,9 @@ BLUE_CLASS( EveSOFDataArea ) : public: EXPOSE_TO_BLUE(); EveSOFDataArea( IRoot* lockobj = NULL ); - ~EveSOFDataArea() {} + ~EveSOFDataArea() + { + } // area type enum AreaType @@ -338,7 +362,9 @@ BLUE_CLASS( EveSOFDataPatternTransform ) : public: EXPOSE_TO_BLUE(); EveSOFDataPatternTransform( IRoot* lockobj = NULL ); - ~EveSOFDataPatternTransform() {} + ~EveSOFDataPatternTransform() + { + } // per-hull positional data Vector3 m_position; @@ -354,7 +380,7 @@ TYPEDEF_BLUECLASS( EveSOFDataPatternTransform ); BLUE_CLASS( EveSOFDataPatternMaterialOverride ) : public IRoot { -public: +public: EXPOSE_TO_BLUE(); EveSOFDataPatternMaterialOverride( IRoot* lockobj = NULL ); ~EveSOFDataPatternMaterialOverride() @@ -372,7 +398,9 @@ BLUE_CLASS( EveSOFDataPatternPerHull ) : public: EXPOSE_TO_BLUE(); EveSOFDataPatternPerHull( IRoot* lockobj = NULL ); - ~EveSOFDataPatternPerHull() {} + ~EveSOFDataPatternPerHull() + { + } // exact hull name BlueSharedString m_name; @@ -391,7 +419,9 @@ BLUE_CLASS( EveSOFDataPatternLayer ) : public: EXPOSE_TO_BLUE(); EveSOFDataPatternLayer( IRoot* lockobj = NULL ); - ~EveSOFDataPatternLayer() {} + ~EveSOFDataPatternLayer() + { + } // texture projection type enum ProjectionType @@ -448,7 +478,7 @@ BLUE_CLASS( EveSOFDataPatternLayerProperties ) : ProjectionType m_projectionTypeU, m_projectionTypeV; // what is the pattern's material target? bool m_isTargetMtl1, m_isTargetMtl2, m_isTargetMtl3, m_isTargetMtl4; - + // applicable area types bool m_applicableAreas[EveSOFDataArea::AreaType::TYPE_MAX]; }; @@ -484,7 +514,9 @@ BLUE_CLASS( EveSOFDataPattern ) : public: EXPOSE_TO_BLUE(); EveSOFDataPattern( IRoot* lockobj = NULL ); - ~EveSOFDataPattern() {} + ~EveSOFDataPattern() + { + } // pattern name std::string m_name; @@ -512,7 +544,9 @@ BLUE_CLASS( EveSOFDataPointLightAttachment ) : public: EXPOSE_TO_BLUE(); EveSOFDataPointLightAttachment( IRoot* lockobj = NULL ); - ~EveSOFDataPointLightAttachment() {} + ~EveSOFDataPointLightAttachment() + { + } float m_saturation; float m_intensity; @@ -525,7 +559,7 @@ BLUE_CLASS( EveSOFDataPointLightAttachment ) : int32_t m_noiseOctaves; std::wstring m_lightProfilePath; }; -TYPEDEF_BLUECLASS( EveSOFDataPointLightAttachment ); +TYPEDEF_BLUECLASS( EveSOFDataPointLightAttachment ); BLUE_DECLARE_VECTOR( EveSOFDataPointLightAttachment ); @@ -535,7 +569,9 @@ BLUE_CLASS( EveSOFDataSpotLightAttachment ) : public: EXPOSE_TO_BLUE(); EveSOFDataSpotLightAttachment( IRoot* lockobj = NULL ); - ~EveSOFDataSpotLightAttachment() {} + ~EveSOFDataSpotLightAttachment() + { + } float m_saturation; float m_intensity; @@ -559,7 +595,9 @@ BLUE_CLASS( EveSOFDataHullSpotlightSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpotlightSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpotlightSetItem() {} + ~EveSOFDataHullSpotlightSetItem() + { + } // per-hull data of a spotlightset Matrix m_transform; @@ -580,7 +618,9 @@ BLUE_CLASS( EveSOFDataHullSpotlightSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpotlightSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpotlightSet() {} + ~EveSOFDataHullSpotlightSet() + { + } // data std::string m_name; @@ -602,7 +642,9 @@ BLUE_CLASS( EveSOFDataHullPlaneSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullPlaneSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullPlaneSetItem() {} + ~EveSOFDataHullPlaneSetItem() + { + } // per-hull data of a planeset Vector3 m_position; @@ -614,9 +656,9 @@ BLUE_CLASS( EveSOFDataHullPlaneSetItem ) : float m_saturation; Vector4 m_layer1Transform, m_layer2Transform, m_layer1Scroll, m_layer2Scroll; int32_t m_boneIndex, m_groupIndex, m_maskMapAtlasIndex; - + // Blink data parameters - float m_rate, m_phase, m_dutyCycle; + float m_rate, m_phase, m_dutyCycle; int32_t m_blinkMode; PEveSOFDataPointLightAttachmentVector m_lights; @@ -631,7 +673,9 @@ BLUE_CLASS( EveSOFDataHullPlaneSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullPlaneSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullPlaneSet() {} + ~EveSOFDataHullPlaneSet() + { + } // decal type enum Usage @@ -664,13 +708,15 @@ BLUE_CLASS( EveSOFDataHullSpriteSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpriteSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpriteSetItem() {} + ~EveSOFDataHullSpriteSetItem() + { + } // per-hull data of a spriteset Vector3 m_position; float m_blinkRate, m_blinkPhase, m_minScale, m_maxScale, m_falloff, m_intensity, m_saturation; int32_t m_boneIndex; - SOFDataFactionColorChooser::ColorType m_colorType; + SOFDataFactionColorChooser::ColorType m_colorType; EveSOFDataPointLightAttachmentPtr m_light; }; @@ -684,7 +730,9 @@ BLUE_CLASS( EveSOFDataHullSpriteSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpriteSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpriteSet() {} + ~EveSOFDataHullSpriteSet() + { + } std::string m_name; // visibility group name @@ -693,7 +741,6 @@ BLUE_CLASS( EveSOFDataHullSpriteSet ) : bool m_skinned; // items PEveSOFDataHullSpriteSetItemVector m_items; - }; TYPEDEF_BLUECLASS( EveSOFDataHullSpriteSet ); BLUE_DECLARE_VECTOR( EveSOFDataHullSpriteSet ); @@ -705,7 +752,9 @@ BLUE_CLASS( EveSOFDataHullSpriteLineSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpriteLineSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpriteLineSetItem() {} + ~EveSOFDataHullSpriteLineSetItem() + { + } // per-hull data of a sprite line set Vector3 m_position, m_scaling; @@ -713,7 +762,7 @@ BLUE_CLASS( EveSOFDataHullSpriteLineSetItem ) : float m_spacing, m_blinkRate, m_blinkPhase, m_blinkPhaseShift, m_minScale, m_maxScale, m_falloff, m_intensity, m_saturation; int32_t m_boneIndex; bool m_isCircle; - SOFDataFactionColorChooser::ColorType m_colorType; + SOFDataFactionColorChooser::ColorType m_colorType; EveSOFDataPointLightAttachmentPtr m_light; }; TYPEDEF_BLUECLASS( EveSOFDataHullSpriteLineSetItem ); @@ -726,7 +775,9 @@ BLUE_CLASS( EveSOFDataHullSpriteLineSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullSpriteLineSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullSpriteLineSet() {} + ~EveSOFDataHullSpriteLineSet() + { + } // animated? std::string m_name; @@ -747,14 +798,16 @@ BLUE_CLASS( EveSOFDataHullHazeSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullHazeSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullHazeSetItem() {} + ~EveSOFDataHullHazeSetItem() + { + } // per-hull data of a haze set Vector3 m_position, m_scaling; int32_t m_boneIndex; Quaternion m_rotation; - SOFDataFactionColorChooser::ColorType m_colorType; + SOFDataFactionColorChooser::ColorType m_colorType; float m_hazeBrightness, m_hazeFalloff, m_sourceSize, m_sourceBrightness, m_saturation; bool m_boosterGainInfluence; @@ -770,7 +823,9 @@ BLUE_CLASS( EveSOFDataHullHazeSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullHazeSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullHazeSet() {} + ~EveSOFDataHullHazeSet() + { + } // haze type enum HazeType @@ -973,7 +1028,9 @@ BLUE_CLASS( EveSOFDataHullBoosterItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullBoosterItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullBoosterItem() {} + ~EveSOFDataHullBoosterItem() + { + } // per-hull data of a booster Matrix m_transform; @@ -993,7 +1050,9 @@ BLUE_CLASS( EveSOFDataHullBooster ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullBooster( IRoot* lockobj = NULL ); - ~EveSOFDataHullBooster() {} + ~EveSOFDataHullBooster() + { + } // per-hull data of a booster bool m_alwaysOn, m_hasTrails; @@ -1009,7 +1068,9 @@ BLUE_CLASS( EveSOFDataHullArea ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullArea( IRoot* lockobj = NULL ); - ~EveSOFDataHullArea() {} + ~EveSOFDataHullArea() + { + } // data uint32_t m_index; @@ -1031,7 +1092,9 @@ BLUE_CLASS( EveSOFDataHullLocator ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLocator( IRoot* lockobj = NULL ); - ~EveSOFDataHullLocator() {} + ~EveSOFDataHullLocator() + { + } // data BlueSharedString m_name; @@ -1054,7 +1117,9 @@ BLUE_CLASS( EveSOFDataHullLocatorSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLocatorSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullLocatorSet() {} + ~EveSOFDataHullLocatorSet() + { + } // data BlueSharedString m_name; @@ -1141,7 +1206,9 @@ BLUE_CLASS( EveSOFDataHullChild ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullChild( IRoot* lockobj = NULL ); - ~EveSOFDataHullChild() {} + ~EveSOFDataHullChild() + { + } std::string GetName(); @@ -1166,7 +1233,9 @@ BLUE_CLASS( EveSOFDataHullAnimation ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullAnimation( IRoot* lockobj = NULL ); - ~EveSOFDataHullAnimation() {} + ~EveSOFDataHullAnimation() + { + } std::string m_name; @@ -1175,13 +1244,13 @@ BLUE_CLASS( EveSOFDataHullAnimation ) : Vector4 m_endRotationValue; float m_startRotationTime; float m_endRotationTime; - + // modelTranslationCurve control Vector3 m_startTranslationValue; Vector3 m_endTranslationValue; float m_startTranslationTime; float m_endTranslationTime; - + // The id of the children whose partice systems are controlled by the animation int32_t m_id; // The particle system spawn rates @@ -1239,7 +1308,9 @@ BLUE_CLASS( EveSOFDataHullDecalSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullDecalSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullDecalSetItem() {} + ~EveSOFDataHullDecalSetItem() + { + } // decal type enum Usage @@ -1262,7 +1333,7 @@ BLUE_CLASS( EveSOFDataHullDecalSetItem ) : Vector3 m_position, m_scaling; Quaternion m_rotation; int32_t m_boneIndex, m_meshIndex; - SOFDataFactionColorChooser::ColorType m_glowColorType; + SOFDataFactionColorChooser::ColorType m_glowColorType; PEveSOFDataTextureVector m_textures; PEveSOFDataParameterVector m_parameters; PEveSOFDataDecalIndexBufferVector m_indexBuffers; @@ -1278,7 +1349,9 @@ BLUE_CLASS( EveSOFDataHullDecalSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullDecalSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullDecalSet() {} + ~EveSOFDataHullDecalSet() + { + } // general std::string m_name; @@ -1298,9 +1371,11 @@ BLUE_CLASS( EveSOFDataHullLightSetItem ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLightSetItem( IRoot* lockobj = NULL ); - ~EveSOFDataHullLightSetItem() {} - - enum LIGHT_TYPE + ~EveSOFDataHullLightSetItem() + { + } + + enum LIGHT_TYPE { POINT_LIGHT, TEXTURED_POINT_LIGHT, @@ -1317,7 +1392,7 @@ BLUE_CLASS( EveSOFDataHullLightSetItem ) : float noiseAmplitude; float noiseFrequency; int noiseOctaves; - SOFDataFactionColorChooser::ColorType lightColor; + SOFDataFactionColorChooser::ColorType lightColor; std::wstring texturePath; float innerAngle; float outerAngle; @@ -1327,7 +1402,6 @@ BLUE_CLASS( EveSOFDataHullLightSetItem ) : } m_data; std::string m_name; - }; TYPEDEF_BLUECLASS( EveSOFDataHullLightSetItem ); BLUE_DECLARE_VECTOR( EveSOFDataHullLightSetItem ); @@ -1339,7 +1413,7 @@ BLUE_CLASS( EveSOFDataHullLightSetTexturedPointLight ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLightSetTexturedPointLight( IRoot* lockobj = NULL ); - ~EveSOFDataHullLightSetTexturedPointLight() {}; + ~EveSOFDataHullLightSetTexturedPointLight(){}; }; TYPEDEF_BLUECLASS( EveSOFDataHullLightSetTexturedPointLight ); BLUE_DECLARE_VECTOR( EveSOFDataHullLightSetTexturedPointLight ); @@ -1351,8 +1425,7 @@ BLUE_CLASS( EveSOFDataHullLightSetSpotLight ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLightSetSpotLight( IRoot* lockobj = NULL ); - ~EveSOFDataHullLightSetSpotLight() {}; - + ~EveSOFDataHullLightSetSpotLight(){}; }; TYPEDEF_BLUECLASS( EveSOFDataHullLightSetSpotLight ); BLUE_DECLARE_VECTOR( EveSOFDataHullLightSetSpotLight ); @@ -1364,7 +1437,9 @@ BLUE_CLASS( EveSOFDataHullLightSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullLightSet( IRoot* lockobj = NULL ); - ~EveSOFDataHullLightSet() {} + ~EveSOFDataHullLightSet() + { + } // general std::string m_name; @@ -1393,12 +1468,15 @@ TYPEDEF_BLUECLASS( EveSOFDataHullController ); BLUE_DECLARE_VECTOR( EveSOFDataHullController ); -BLUE_CLASS( EveSOFDataHullSoundEmitter ): public IRoot +BLUE_CLASS( EveSOFDataHullSoundEmitter ) : + public IRoot { public: EXPOSE_TO_BLUE(); EveSOFDataHullSoundEmitter( IRoot* lockobj = NULL ); - ~EveSOFDataHullSoundEmitter() {} + ~EveSOFDataHullSoundEmitter() + { + } float m_attenuationScalingFactor; std::string m_name; @@ -1416,7 +1494,9 @@ BLUE_CLASS( EveSOFDataHull ) : public: EXPOSE_TO_BLUE(); EveSOFDataHull( IRoot* lockobj = NULL ); - ~EveSOFDataHull() {} + ~EveSOFDataHull() + { + } // trinity output class enum BuildClass @@ -1443,7 +1523,7 @@ BLUE_CLASS( EveSOFDataHull ) : // description std::string m_description; - + // hull category used for validation BlueSharedString m_category; @@ -1459,7 +1539,7 @@ BLUE_CLASS( EveSOFDataHull ) : bool m_enableDynamicBoundingSphere; bool m_castShadow; bool m_sof6; - + // materials PEveSOFDataHullAreaVector m_opaqueAreas; PEveSOFDataHullAreaVector m_decalAreas; @@ -1477,7 +1557,7 @@ BLUE_CLASS( EveSOFDataHull ) : PEveSOFDataHullSpriteLineSetVector m_spriteLineSets; PEveSOFDataHullHazeSetVector m_hazeSets; PEveSOFDataHullBannerVector m_banners; - PEveSOFDataHullBannerSetVector m_bannerSets; + PEveSOFDataHullBannerSetVector m_bannerSets; PEveSOFDataHullDecalSetVector m_decalSets; PEveSOFDataHullLightSetVector m_lightSets; ImpactEffectType m_impactEffectType; @@ -1526,7 +1606,9 @@ BLUE_CLASS( EveSOFDataFactionVisibilityGroupSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionVisibilityGroupSet( IRoot* lockobj = NULL ); - ~EveSOFDataFactionVisibilityGroupSet() {} + ~EveSOFDataFactionVisibilityGroupSet() + { + } // visibility groups PEveSOFDataGenericStringVector m_visibilityGroups; @@ -1541,7 +1623,9 @@ BLUE_CLASS( EveSOFDataFactionSpotlightSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionSpotlightSet( IRoot* lockobj = NULL ); - ~EveSOFDataFactionSpotlightSet() {} + ~EveSOFDataFactionSpotlightSet() + { + } // per-faction data of a spotlight int32_t m_groupIndex; @@ -1558,7 +1642,9 @@ BLUE_CLASS( EveSOFDataFactionPlaneSet ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionPlaneSet( IRoot* lockobj = NULL ); - ~EveSOFDataFactionPlaneSet() {} + ~EveSOFDataFactionPlaneSet() + { + } // per-faction data of a planeset int32_t m_groupIndex; @@ -1575,7 +1661,9 @@ BLUE_CLASS( EveSOFDataFactionChild ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionChild( IRoot* lockobj = NULL ); - ~EveSOFDataFactionChild() {} + ~EveSOFDataFactionChild() + { + } // group int32_t m_groupIndex; @@ -1592,7 +1680,9 @@ BLUE_CLASS( EveSOFDataFactionHullArea ) : public: EXPOSE_TO_BLUE(); EveSOFDataFactionHullArea( IRoot* lockobj = NULL ); - ~EveSOFDataFactionHullArea() {} + ~EveSOFDataFactionHullArea() + { + } // designation BlueSharedString m_name; @@ -1609,7 +1699,9 @@ BLUE_CLASS( EveSOFDataFaction ) : public: EXPOSE_TO_BLUE(); EveSOFDataFaction( IRoot* lockobj = NULL ); - ~EveSOFDataFaction() {} + ~EveSOFDataFaction() + { + } // description std::string m_description; @@ -1643,7 +1735,6 @@ BLUE_CLASS( EveSOFDataFaction ) : std::string m_defaultPatternLayer1MaterialName; std::string m_defaultPatternLayer2MaterialName; std::string m_defaultPatternName; - }; TYPEDEF_BLUECLASS( EveSOFDataFaction ); BLUE_DECLARE_VECTOR( EveSOFDataFaction ); @@ -1678,7 +1769,9 @@ BLUE_CLASS( EveSOFDataBooster ) : public: EXPOSE_TO_BLUE(); EveSOFDataBooster( IRoot* lockobj = NULL ); - ~EveSOFDataBooster() {} + ~EveSOFDataBooster() + { + } // data float m_glowScale, m_symHaloScale, m_haloScaleX, m_haloScaleY; @@ -1712,7 +1805,9 @@ BLUE_CLASS( EveSOFDataRaceDamage ) : public: EXPOSE_TO_BLUE(); EveSOFDataRaceDamage( IRoot* lockobj = NULL ); - ~EveSOFDataRaceDamage() {} + ~EveSOFDataRaceDamage() + { + } // armor damage PEveSOFDataParameterVector m_armorImpactParameters; @@ -1732,7 +1827,9 @@ BLUE_CLASS( EveSOFDataRace ) : public: EXPOSE_TO_BLUE(); EveSOFDataRace( IRoot* lockobj = NULL ); - ~EveSOFDataRace() {} + ~EveSOFDataRace() + { + } // race name std::string m_name; @@ -1740,8 +1837,8 @@ BLUE_CLASS( EveSOFDataRace ) : // data EveSOFDataBoosterPtr m_booster; // colors - SOFDataFactionColorChooser::ColorType m_hullPrimaryHeatColorType; - SOFDataFactionColorChooser::ColorType m_hullReactorHeatColorType; + SOFDataFactionColorChooser::ColorType m_hullPrimaryHeatColorType; + SOFDataFactionColorChooser::ColorType m_hullReactorHeatColorType; // impact effect EveSOFDataRaceDamagePtr m_damage; }; @@ -1751,8 +1848,6 @@ BLUE_DECLARE_VECTOR( EveSOFDataRace ); - - // -------------------------------------------------------------------------------- // All data storage classes for per material data // -------------------------------------------------------------------------------- @@ -1763,7 +1858,9 @@ BLUE_CLASS( EveSOFDataMaterial ) : public: EXPOSE_TO_BLUE(); EveSOFDataMaterial( IRoot* lockobj = NULL ); - ~EveSOFDataMaterial() {} + ~EveSOFDataMaterial() + { + } // material name std::string m_name; @@ -1812,9 +1909,7 @@ BLUE_DECLARE_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ); BLUE_DECLARE_IVECTOR( IEveSOFDataHullExtensionPlacementDistribution ); BLUE_INTERFACE( IEveSOFDataHullExtensionPlacement ) : - public IRoot -{ -}; + public IRoot{}; BLUE_DECLARE_INTERFACE( IEveSOFDataHullExtensionPlacement ); BLUE_DECLARE_IVECTOR( IEveSOFDataHullExtensionPlacement ); @@ -1855,7 +1950,9 @@ BLUE_CLASS( EveSOFDataHullExtensionPlacementDistributionDepletionCounter ) : public: EXPOSE_TO_BLUE(); EveSOFDataHullExtensionPlacementDistributionDepletionCounter( IRoot* lockobj = NULL ); - ~EveSOFDataHullExtensionPlacementDistributionDepletionCounter(){} + ~EveSOFDataHullExtensionPlacementDistributionDepletionCounter() + { + } PEveSOFDataDistributionDepletionCounterVector m_depletionCounters; }; TYPEDEF_BLUECLASS( EveSOFDataHullExtensionPlacementDistributionDepletionCounter ); @@ -1893,7 +1990,7 @@ BLUE_CLASS( EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings ) : SHADER_MED = 2, SHADER_LOW = 0, }; - + DisplayQualityModifier m_displayFilter; }; TYPEDEF_BLUECLASS( EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings ); @@ -2016,7 +2113,9 @@ BLUE_CLASS( EveSOFDataGenericDamage ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericDamage( IRoot* lockobj = NULL ); - ~EveSOFDataGenericDamage() {} + ~EveSOFDataGenericDamage() + { + } // hull damage flicker float m_flickerPerlinSpeed; @@ -2057,8 +2156,10 @@ BLUE_CLASS( EveSOFDataGenericHullDamage ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericHullDamage( IRoot* lockobj = NULL ); - ~EveSOFDataGenericHullDamage() {} - + ~EveSOFDataGenericHullDamage() + { + } + // hull debris particles float m_hullParticleRate; float m_hullParticleInnerAngle; @@ -2086,7 +2187,9 @@ BLUE_CLASS( EveSOFDataGenericShader ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericShader( IRoot* lockobj = NULL ); - ~EveSOFDataGenericShader() {} + ~EveSOFDataGenericShader() + { + } BlueSharedString m_shader; @@ -2110,7 +2213,9 @@ BLUE_CLASS( EveSOFDataGenericDecalShader ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericDecalShader( IRoot* lockobj = NULL ); - ~EveSOFDataGenericDecalShader() {} + ~EveSOFDataGenericDecalShader() + { + } BlueSharedString m_shader; @@ -2134,8 +2239,12 @@ BLUE_CLASS( EveSOFDataGenericSwarm ) : { public: EXPOSE_TO_BLUE(); - EveSOFDataGenericSwarm( IRoot* lockobj = NULL ) {} - ~EveSOFDataGenericSwarm() {} + EveSOFDataGenericSwarm( IRoot* lockobj = NULL ) + { + } + ~EveSOFDataGenericSwarm() + { + } EveSwarm::BehaviorProperties m_behavior; }; @@ -2149,7 +2258,9 @@ BLUE_CLASS( EveSOFDataGenericVariant ) : public: EXPOSE_TO_BLUE(); EveSOFDataGenericVariant( IRoot* lockobj = NULL ); - ~EveSOFDataGenericVariant() {} + ~EveSOFDataGenericVariant() + { + } // name id BlueSharedString m_name; @@ -2189,7 +2300,9 @@ BLUE_CLASS( EveSOFDataGeneric ) : public: EXPOSE_TO_BLUE(); EveSOFDataGeneric( IRoot* lockobj = NULL ); - ~EveSOFDataGeneric() {} + ~EveSOFDataGeneric() + { + } // default textures std::string m_resPathDefaultAlliance; @@ -2217,7 +2330,7 @@ BLUE_CLASS( EveSOFDataGeneric ) : // damage data EveSOFDataGenericDamagePtr m_damage; EveSOFDataGenericHullDamagePtr m_hullDamage; - + // swarm data EveSOFDataGenericSwarmPtr m_swarm; diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.cpp index bb5165238..45aa3e47f 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.cpp @@ -14,7 +14,7 @@ uint32_t GetVisibilityGroupHash( const BlueSharedString visibilityGroup ) } -EveSOFDataMgr::HullSpotlightSetItemData::HullSpotlightSetItemData( const EveSOFDataHullSpotlightSetItem& item ): +EveSOFDataMgr::HullSpotlightSetItemData::HullSpotlightSetItemData( const EveSOFDataHullSpotlightSetItem& item ) : boneIndex( item.m_boneIndex ), boosterGainInfluence( item.m_boosterGainInfluence ), colorType( item.m_colorType ), @@ -27,13 +27,13 @@ EveSOFDataMgr::HullSpotlightSetItemData::HullSpotlightSetItemData( const EveSOFD saturation( item.m_saturation ), light( nullptr ) { - if (item.m_light) - { + if( item.m_light ) + { light = std::make_unique( *item.m_light ); } } -EveSOFDataMgr::HullSpotlightSetData::HullSpotlightSetData( const EveSOFDataHullSpotlightSet& spotLightSet ): +EveSOFDataMgr::HullSpotlightSetData::HullSpotlightSetData( const EveSOFDataHullSpotlightSet& spotLightSet ) : skinned( spotLightSet.m_skinned ), zOffset( spotLightSet.m_zOffset ), visibilityGroup( GetVisibilityGroupHash( spotLightSet.m_visibilityGroup ) ), @@ -47,7 +47,7 @@ EveSOFDataMgr::HullSpotlightSetData::HullSpotlightSetData( const EveSOFDataHullS } } -EveSOFDataMgr::HullPlaneSetItemData::HullPlaneSetItemData( const EveSOFDataHullPlaneSetItem& item ): +EveSOFDataMgr::HullPlaneSetItemData::HullPlaneSetItemData( const EveSOFDataHullPlaneSetItem& item ) : boneIndex( item.m_boneIndex ), layer1Scroll( item.m_layer1Scroll ), layer1Transform( item.m_layer1Transform ), @@ -68,7 +68,7 @@ EveSOFDataMgr::HullPlaneSetItemData::HullPlaneSetItemData( const EveSOFDataHullP saturation( item.m_saturation ) { lights.reserve( item.m_lights.size() ); - for( auto& l : item.m_lights ) + for( auto& l : item.m_lights ) { lights.push_back( PointLightAttachment( *l ) ); } @@ -92,7 +92,8 @@ EveSOFDataMgr::HullPlaneSetData::HullPlaneSetData( const EveSOFDataHullPlaneSet& } -EveSOFDataMgr::PointLightAttachment::PointLightAttachment( const EveSOFDataPointLightAttachment& light ) { +EveSOFDataMgr::PointLightAttachment::PointLightAttachment( const EveSOFDataPointLightAttachment& light ) +{ this->innerScaleMultiplier = light.m_innerScaleMultiplier; this->intensity = light.m_intensity; this->noiseAmplitude = light.m_noiseAmplitude; @@ -105,7 +106,8 @@ EveSOFDataMgr::PointLightAttachment::PointLightAttachment( const EveSOFDataPoint this->rotation = light.m_rotation; } -LightData EveSOFDataMgr::PointLightAttachment::AsLightData( Color& color, float scale ) const { +LightData EveSOFDataMgr::PointLightAttachment::AsLightData( Color& color, float scale ) const +{ LightData data; data.color = color; data.position = this->translation; @@ -120,7 +122,8 @@ LightData EveSOFDataMgr::PointLightAttachment::AsLightData( Color& color, float return data; } -EveSOFDataMgr::SpotLightAttachment::SpotLightAttachment( const EveSOFDataSpotLightAttachment& light ) { +EveSOFDataMgr::SpotLightAttachment::SpotLightAttachment( const EveSOFDataSpotLightAttachment& light ) +{ this->innerAngleMultiplier = light.m_innerAngleMultiplier; this->translation = light.m_translation; this->intensity = light.m_intensity; @@ -134,7 +137,8 @@ EveSOFDataMgr::SpotLightAttachment::SpotLightAttachment( const EveSOFDataSpotLig this->lightProfilePath = light.m_lightProfilePath; } -LightData EveSOFDataMgr::SpotLightAttachment::AsLightData( Color& color, float scale, float innerAngle, float outerAngle ) const { +LightData EveSOFDataMgr::SpotLightAttachment::AsLightData( Color& color, float scale, float innerAngle, float outerAngle ) const +{ LightData data; data.color = color; data.position = this->translation; @@ -736,9 +740,9 @@ void EveSOFDataMgr::GenerateHullData( HullData& hd, EveSOFDataHullPtr srcData ) hssid.saturation = spriteSetItemData->m_saturation; hssid.colorType = spriteSetItemData->m_colorType; hssid.light = nullptr; - if( spriteSetItemData->m_light ) + if( spriteSetItemData->m_light ) { - hssid.light = std::make_unique( PointLightAttachment( *spriteSetItemData->m_light )); + hssid.light = std::make_unique( PointLightAttachment( *spriteSetItemData->m_light ) ); } hssd.items.push_back( std::move( hssid ) ); } @@ -831,7 +835,7 @@ void EveSOFDataMgr::GenerateHullData( HullData& hd, EveSOFDataHullPtr srcData ) hhsid.lights = std::vector(); hhsid.lights.reserve( hazeSetItemData->m_lights.size() ); - for( auto& light: hazeSetItemData->m_lights ) + for( auto& light : hazeSetItemData->m_lights ) { hhsid.lights.push_back( PointLightAttachment( *light ) ); } @@ -911,12 +915,12 @@ void EveSOFDataMgr::GenerateHullData( HullData& hd, EveSOFDataHullPtr srcData ) data.item.bone = bannerItem->m_boneIndex; data.item.reference = bannerIndex++; data.light = nullptr; - if( bannerItem->m_light ) + if( bannerItem->m_light ) { data.light = std::make_shared( *bannerItem->m_light ); } - set.bannerTypes[bannerItem->m_usage].push_back( std::move( data) ); + set.bannerTypes[bannerItem->m_usage].push_back( std::move( data ) ); } hd.bannerSets.push_back( std::move( set ) ); } @@ -952,7 +956,7 @@ void EveSOFDataMgr::GenerateHullData( HullData& hd, EveSOFDataHullPtr srcData ) itemData.indexBuffers.push_back( buffer->m_indexBuffer ); } - for ( const auto& mhBuffers : itemPtr->m_multiHullIndexBuffers ) + for( const auto& mhBuffers : itemPtr->m_multiHullIndexBuffers ) { itemData.multiHullIndexBuffers.push_back( MultiHullDecalIndexBuffers( *mhBuffers ) ); } @@ -1535,7 +1539,7 @@ void EveSOFDataMgr::GeneratePatternData( PatternData& pd, EveSOFDataPatternPtr s { pd.applicationData.clear(); pd.sof6 = srcData->m_sof6; - + // per-layer data PatternLayerData pld1, pld2; @@ -1604,7 +1608,7 @@ EveSOFDataMgr::ExtensionPlacementData EveSOFDataMgr::UnpackPlacementData( IEveSO { auto placementData = ExtensionPlacementData(); - if (EveSOFDataHullExtensionPlacementPtr placement = BlueCastPtr( placementOrGroup )) + if( EveSOFDataHullExtensionPlacementPtr placement = BlueCastPtr( placementOrGroup ) ) { placementData.isAGroup = false; placementData.enabled = placement->m_enabled; @@ -1653,7 +1657,7 @@ EveSOFDataMgr::ExtensionPlacementData EveSOFDataMgr::UnpackPlacementData( IEveSO if( EveSOFDataHullExtensionPlacementGroupPtr placement = BlueCastPtr( placementOrGroup ) ) { placementData.isAGroup = true; - + placementData.name = BlueSharedString( placement->m_name ); placementData.enabled = placement->m_enabled; @@ -1715,7 +1719,7 @@ EveSOFDataMgr::ExtensionPlacementDistribution EveSOFDataMgr::generateDistributio placementDistribution.randomRotationStepSizeYPR = distributionObj->m_randomRotationStepSizeYPR; placementDistribution.randomRotationMaxSteps = distributionObj->m_randomRotationMaxSteps; placementDistribution.randomScaleMin = distributionObj->m_randomScaleMin; - placementDistribution.randomScaleMax = distributionObj->m_randomScaleMax; + placementDistribution.randomScaleMax = distributionObj->m_randomScaleMax; placementDistribution.uniformScaling = distributionObj->m_uniformScale; placementDistribution.occupyLocators = distributionObj->m_occupyLocators; @@ -2062,7 +2066,7 @@ void EveSOFDataMgr::GenerateGenericData( GenericData& gd, EveSOFDataGenericPtr s { continue; } - gd.categoryData[std::string( categoryData->m_categoryName.c_str())] = categoryData->m_reflectionMode; + gd.categoryData[std::string( categoryData->m_categoryName.c_str() )] = categoryData->m_reflectionMode; } // turret area type override diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h index 651ff83c8..cadfd89e9 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr.h @@ -131,9 +131,9 @@ BLUE_CLASS( EveSOFDataMgr ) : float centerBias; int32_t cap; Quaternion randomRotationStepSizeYPR; - Vector3 randomRotationMaxSteps; - Vector3 randomScaleMin; - Vector3 randomScaleMax; + Vector3 randomRotationMaxSteps; + Vector3 randomScaleMin; + Vector3 randomScaleMax; bool uniformScaling; bool occupyLocators; }; @@ -209,7 +209,8 @@ BLUE_CLASS( EveSOFDataMgr ) : std::vector items; }; - struct PointLightAttachment { + struct PointLightAttachment + { explicit PointLightAttachment( const EveSOFDataPointLightAttachment& light ); LightData AsLightData( Color& color, float scale ) const; Vector3 translation; @@ -224,7 +225,8 @@ BLUE_CLASS( EveSOFDataMgr ) : std::wstring lightProfilePath; }; - struct SpotLightAttachment { + struct SpotLightAttachment + { explicit SpotLightAttachment( const EveSOFDataSpotLightAttachment& light ); LightData AsLightData( Color& color, float scale, float innerAngle, float outerAngle ) const; Vector3 translation; @@ -378,7 +380,7 @@ BLUE_CLASS( EveSOFDataMgr ) : struct HullBannerSetItemData { EveBannerItem item; - // storing this as a shared pointer because it "needs" to be copyable + // storing this as a shared pointer because it "needs" to be copyable // for the map that stores HullBannerSetItemData std::shared_ptr light; }; @@ -525,8 +527,8 @@ BLUE_CLASS( EveSOFDataMgr ) : { HullData() = default; HullData( const HullData& ) = delete; - HullData( HullData&& ) = default; - HullData& operator = ( HullData&& ) = default; + HullData( HullData&& ) = default; + HullData& operator=( HullData&& ) = default; EveSOFDataHull::BuildClass buildClass; std::string geometryResFilePath; @@ -543,7 +545,7 @@ BLUE_CLASS( EveSOFDataMgr ) : std::vector planeSets; std::vector spriteLineSets; std::vector hazeSets; - std::vector banners; + std::vector banners; std::vector bannerSets; // new banners std::vector hullDecalSets; std::vector hullLightSets; @@ -829,13 +831,13 @@ BLUE_CLASS( EveSOFDataMgr ) : // loading all the data bool LoadData( const char* filePath ); - bool SetData( EveSOFData* dbData ); + bool SetData( EveSOFData * dbData ); // update individual parts bool UpdateHull( const char* hullName, EveSOFDataHull* hullData ); bool UpdateFaction( const char* factionName, EveSOFDataFaction* factionData ); bool UpdateRace( const char* raceName, EveSOFDataRace* raceData ); - bool UpdateGeneric( EveSOFDataGeneric* genericData ); + bool UpdateGeneric( EveSOFDataGeneric * genericData ); bool UpdateMaterial( const char* materialName, EveSOFDataMaterial* materialData ); bool UpdatePattern( const char* patternName, EveSOFDataPattern* patternData ); bool UpdateLayout( const char* layoutName, EveSOFDataLayout* layoutData ); @@ -860,7 +862,7 @@ BLUE_CLASS( EveSOFDataMgr ) : // access to layout data bool HasLayoutData( const char* layoutName ) const; const LayoutData* GetLayoutData( const char* layoutName ) const; - const std::vector GetLayoutData( std::vector& layouts) const; + const std::vector GetLayoutData( std::vector & layouts ) const; private: // load indiviual parts of data @@ -874,22 +876,22 @@ BLUE_CLASS( EveSOFDataMgr ) : HullAreas LoadHullAreaData( const EveSOFDataHullAreaPtr hullArea ) const; // helper functions to pass data from trinity object to stl containers - void GenerateHullData( HullData& hd, EveSOFDataHullPtr srcData ) const; - void GenerateFactionData( FactionData& fd, EveSOFDataFactionPtr srcData ) const; - void GenerateRaceData( RaceData& rd, EveSOFDataRacePtr srcData ) const; - void GenerateGenericData( GenericData& gd, EveSOFDataGenericPtr srcData ) const; - void GenerateMaterialData( MaterialData& rd, EveSOFDataMaterialPtr srcData ) const; - void GeneratePatternData( PatternData& rd, EveSOFDataPatternPtr srcData ) const; - void GenerateLayoutData( LayoutData& ld, EveSOFDataLayoutPtr srcData ) const; - void LoadLocatorData( HullData & hd, EveSOFDataHullPtr srcData, IEveSOFDataHullLocatorSetPtr locatorSetOrGroup, uint32_t & uniqueID ) const; - - + void GenerateHullData( HullData & hd, EveSOFDataHullPtr srcData ) const; + void GenerateFactionData( FactionData & fd, EveSOFDataFactionPtr srcData ) const; + void GenerateRaceData( RaceData & rd, EveSOFDataRacePtr srcData ) const; + void GenerateGenericData( GenericData & gd, EveSOFDataGenericPtr srcData ) const; + void GenerateMaterialData( MaterialData & rd, EveSOFDataMaterialPtr srcData ) const; + void GeneratePatternData( PatternData & rd, EveSOFDataPatternPtr srcData ) const; + void GenerateLayoutData( LayoutData & ld, EveSOFDataLayoutPtr srcData ) const; + void LoadLocatorData( HullData & hd, EveSOFDataHullPtr srcData, IEveSOFDataHullLocatorSetPtr locatorSetOrGroup, uint32_t& uniqueID ) const; + + ExtensionPlacementData UnpackPlacementData( IEveSOFDataHullExtensionPlacementPtr placement ) const; // helper function to deal with layout Distributions ExtensionPlacementDistribution generateDistributionData( EveSOFDataHullExtensionPlacementDistributionPlacementPtr distributionObj ) const; ExtensionPlacementDistributionCondition generateDistributionConditionData( IEveSOFDataHullExtensionPlacementDistributionPtr distributionObj ) const; - // keep all hull data in a map + // keep all hull data in a map std::map m_hullData; // keep all faction data in a map std::map m_factionData; diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr_Blue.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr_Blue.cpp index 39e8efe88..7a144ccfc 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr_Blue.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFDataMgr_Blue.cpp @@ -10,101 +10,87 @@ BLUE_DEFINE( EveSOFDataMgr ); const Be::ClassInfo* EveSOFDataMgr::ExposeToBlue() { - EXPOSURE_BEGIN( EveSOFDataMgr, "" ) - MAP_INTERFACE( EveSOFDataMgr ) + EXPOSURE_BEGIN( EveSOFDataMgr, "" ) + MAP_INTERFACE( EveSOFDataMgr ) - MAP_METHOD_AND_WRAP( - "LoadData", - LoadData, + MAP_METHOD_AND_WRAP( + "LoadData", + LoadData, "Inject all the data into this mgr, providing a redfile path\n" - ":param filePath: res path to the data file" - ) - MAP_METHOD_AND_WRAP( - "SetData", - SetData, + ":param filePath: res path to the data file" ) + MAP_METHOD_AND_WRAP( + "SetData", + SetData, "Inject all the data into this mgr, providing a blue object\n" - ":param dbData: SOF data" - ) + ":param dbData: SOF data" ) - MAP_METHOD_AND_WRAP( - "UpdateHull", - UpdateHull, + MAP_METHOD_AND_WRAP( + "UpdateHull", + UpdateHull, "Update a specific hull\n" ":param name: hull name\n" - ":param data: hull definition" - ) - MAP_METHOD_AND_WRAP( - "UpdateFaction", - UpdateFaction, + ":param data: hull definition" ) + MAP_METHOD_AND_WRAP( + "UpdateFaction", + UpdateFaction, "Update a specific faction\n" ":param name: faction name\n" - ":param data: faction definition" - ) - MAP_METHOD_AND_WRAP( - "UpdateRace", - UpdateRace, + ":param data: faction definition" ) + MAP_METHOD_AND_WRAP( + "UpdateRace", + UpdateRace, "Update a specific race\n" ":param name: race name\n" - ":param data: race definition" - ) - MAP_METHOD_AND_WRAP( - "UpdateGeneric", - UpdateGeneric, + ":param data: race definition" ) + MAP_METHOD_AND_WRAP( + "UpdateGeneric", + UpdateGeneric, "Update the generic data\n" - ":param data: generic definition" - ) - MAP_METHOD_AND_WRAP( - "UpdateMaterial", - UpdateMaterial, + ":param data: generic definition" ) + MAP_METHOD_AND_WRAP( + "UpdateMaterial", + UpdateMaterial, "Update a specific material\n" ":param name: material name\n" - ":param data: material definition" - ) - MAP_METHOD_AND_WRAP( - "UpdatePattern", - UpdatePattern, - "Update a specific pattern\n" + ":param data: material definition" ) + MAP_METHOD_AND_WRAP( + "UpdatePattern", + UpdatePattern, + "Update a specific pattern\n" ":param name: pattern name\n" - ":param data: pattern definition" - ) + ":param data: pattern definition" ) MAP_METHOD_AND_WRAP( "UpdateLayout", UpdateLayout, "Update a specific layout\n" ":param name: layout name\n" - ":param data: layout definition" - ) + ":param data: layout definition" ) - MAP_METHOD_AND_WRAP( - "HasFactionData", - HasFactionData, + MAP_METHOD_AND_WRAP( + "HasFactionData", + HasFactionData, "Does this faction exist?\n" - ":param name: faction name\n" - ) - MAP_METHOD_AND_WRAP( - "HasHullData", - HasHullData, - "Does this hull exist?\n" - ":param name: hull name\n" - ) - MAP_METHOD_AND_WRAP( - "HasRaceData", - HasRaceData, - "Does this race exist?\n" - ":param name: race name\n" - ) - MAP_METHOD_AND_WRAP( - "HasMaterialData", - HasMaterialData, - "Does this material exist?\n" - ":param name: material name\n" - ) - MAP_METHOD_AND_WRAP( - "HasPatternData", - HasPatternData, - "Does this pattern exist?\n" - ":param name: pattern name\n" - ) + ":param name: faction name\n" ) + MAP_METHOD_AND_WRAP( + "HasHullData", + HasHullData, + "Does this hull exist?\n" + ":param name: hull name\n" ) + MAP_METHOD_AND_WRAP( + "HasRaceData", + HasRaceData, + "Does this race exist?\n" + ":param name: race name\n" ) + MAP_METHOD_AND_WRAP( + "HasMaterialData", + HasMaterialData, + "Does this material exist?\n" + ":param name: material name\n" ) + MAP_METHOD_AND_WRAP( + "HasPatternData", + HasPatternData, + "Does this pattern exist?\n" + ":param name: pattern name\n" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue.cpp index 51ccdce8c..28efb3c22 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue.cpp @@ -7,70 +7,67 @@ namespace SOFDataFactionColorChooser { -const Be::VarChooser EveSOFDataFactionColorSetTypeChooser[] = - { - { "Primary", BeCast( TYPE_PRIMARY ), "Primary Color" }, - { "Secondary", BeCast( TYPE_SECONDARY ), "Secondary Color" }, - { "Tertiary", BeCast( TYPE_TERTIARY ), "Tertiary Color" }, - { "Black", BeCast( TYPE_BLACK ), "Black Color" }, - { "White", BeCast( TYPE_WHITE ), "White" }, - { "Yellow", BeCast( TYPE_YELLOW ), "Yellow" }, - { "Orange", BeCast( TYPE_ORANGE ), "Orange" }, - { "Red", BeCast( TYPE_RED ), "Red" }, - { "Blue", BeCast( TYPE_BLUE ), "Blue" }, - { "Green", BeCast( TYPE_GREEN ), "Green" }, - { "Cyan", BeCast( TYPE_CYAN ), "Cyan" }, - { "Fire", BeCast( TYPE_FIRE ), "Fire" }, - { "Hull", BeCast( TYPE_HULL ), "Material Hullarea Glow" }, - { "Glass", BeCast( TYPE_GLASS ), "Material Glassarea Glow" }, - { "Reactor", BeCast( TYPE_REACTOR ), "Material Reactorarea Glow" }, - { "Darkhull", BeCast( TYPE_DARKHULL ), "Material Darkhull Glow" }, - { "Booster", BeCast( TYPE_BOOSTER ), "Material Hullarea Heat Shimmer Glow" }, - { "Killmark", BeCast( TYPE_KILLMARK ), "Killmark glow color" }, - { "PrimaryLight", BeCast( TYPE_PRIMARY_LIGHT ), "Primary light color" }, - { "SecondaryLight", BeCast( TYPE_SECONDARY_LIGHT ), "Secondary light color" }, - { "TertiaryLight", BeCast( TYPE_TERTIARY_LIGHT ), "Tertiary light color" }, - { "WhiteLight", BeCast( TYPE_WHITE_LIGHT ), "White light color" }, - { "PrimaryHologram", BeCast( TYPE_PRIMARY_HOLOGRAM ), "Primary Hologram"}, - { "SecondaryHologram", BeCast( TYPE_SECONDARY_HOLOGRAM ), "Secondary Hologram color" }, - { "TertiaryHologram", BeCast( TYPE_TERTIARY_HOLOGRAM ), "Tertiary Hologram color" }, - { "State0", BeCast( TYPE_STATE_0 ), "State 0 color" }, - { "State1", BeCast( TYPE_STATE_1 ), "State 1 color" }, - { "State2", BeCast( TYPE_STATE_2 ), "State 2 color" }, - { "State3", BeCast( TYPE_STATE_3 ), "State 3 color" }, - { "StateVulnerable", BeCast( TYPE_STATE_VULNERABLE ), "State Vulnerable color" }, - { "StateInvulnerable", BeCast( TYPE_STATE_INVULNERABLE ), "State Invulnerable color" }, - { "PrimaryForcefield", BeCast( TYPE_PRIMARY_FORCEFIELD ), "Primary Forcefield color" }, - { "SecondaryForcefield", BeCast( TYPE_SECONDARY_FORCEFIELD ), "Secondary Forcefield color" }, - { "PrimaryBanner", BeCast( TYPE_PRIMARY_BANNER ), "Primary Banner color" }, - { "PrimaryFx", BeCast( TYPE_PRIMARY_FX ), "Primary Fx color" }, - { "SecondaryFx", BeCast( TYPE_SECONDARY_FX ), "Secondary Fx color" }, - { "PrimarySpotlight", BeCast( TYPE_PRIMARY_SPOTLIGHT ), "Primary spotlight color" }, - { "SecondarySpotlight", BeCast( TYPE_SECONDARY_SPOTLIGHT ), "Secondary spotlight color" }, - { "TertiarySpotlight", BeCast( TYPE_TERTIARY_SPOTLIGHT ), "Tertiary spotlight color" }, - { "PrimaryBillboard", BeCast( TYPE_PRIMARY_BILLBOARD ), "Primary Billboard color" }, - { "PrimaryWarpFx", BeCast( TYPE_PRIMARY_WARP_FX ), "Primary Warp FX color" }, - { "PrimaryAttackFX", BeCast( TYPE_PRIMARY_ATTACK_FX ), "Primary Attack FX color" }, - { "PrimarySiegeFX", BeCast( TYPE_PRIMARY_SIEGE_FX ), "Primary Siege FX color" }, - { "PrimaryDockedFX", BeCast( TYPE_PRIMARY_DOCKED_FX ), "Primary Docked FX color" }, - { 0 } - }; +const Be::VarChooser EveSOFDataFactionColorSetTypeChooser[] = { + { "Primary", BeCast( TYPE_PRIMARY ), "Primary Color" }, + { "Secondary", BeCast( TYPE_SECONDARY ), "Secondary Color" }, + { "Tertiary", BeCast( TYPE_TERTIARY ), "Tertiary Color" }, + { "Black", BeCast( TYPE_BLACK ), "Black Color" }, + { "White", BeCast( TYPE_WHITE ), "White" }, + { "Yellow", BeCast( TYPE_YELLOW ), "Yellow" }, + { "Orange", BeCast( TYPE_ORANGE ), "Orange" }, + { "Red", BeCast( TYPE_RED ), "Red" }, + { "Blue", BeCast( TYPE_BLUE ), "Blue" }, + { "Green", BeCast( TYPE_GREEN ), "Green" }, + { "Cyan", BeCast( TYPE_CYAN ), "Cyan" }, + { "Fire", BeCast( TYPE_FIRE ), "Fire" }, + { "Hull", BeCast( TYPE_HULL ), "Material Hullarea Glow" }, + { "Glass", BeCast( TYPE_GLASS ), "Material Glassarea Glow" }, + { "Reactor", BeCast( TYPE_REACTOR ), "Material Reactorarea Glow" }, + { "Darkhull", BeCast( TYPE_DARKHULL ), "Material Darkhull Glow" }, + { "Booster", BeCast( TYPE_BOOSTER ), "Material Hullarea Heat Shimmer Glow" }, + { "Killmark", BeCast( TYPE_KILLMARK ), "Killmark glow color" }, + { "PrimaryLight", BeCast( TYPE_PRIMARY_LIGHT ), "Primary light color" }, + { "SecondaryLight", BeCast( TYPE_SECONDARY_LIGHT ), "Secondary light color" }, + { "TertiaryLight", BeCast( TYPE_TERTIARY_LIGHT ), "Tertiary light color" }, + { "WhiteLight", BeCast( TYPE_WHITE_LIGHT ), "White light color" }, + { "PrimaryHologram", BeCast( TYPE_PRIMARY_HOLOGRAM ), "Primary Hologram" }, + { "SecondaryHologram", BeCast( TYPE_SECONDARY_HOLOGRAM ), "Secondary Hologram color" }, + { "TertiaryHologram", BeCast( TYPE_TERTIARY_HOLOGRAM ), "Tertiary Hologram color" }, + { "State0", BeCast( TYPE_STATE_0 ), "State 0 color" }, + { "State1", BeCast( TYPE_STATE_1 ), "State 1 color" }, + { "State2", BeCast( TYPE_STATE_2 ), "State 2 color" }, + { "State3", BeCast( TYPE_STATE_3 ), "State 3 color" }, + { "StateVulnerable", BeCast( TYPE_STATE_VULNERABLE ), "State Vulnerable color" }, + { "StateInvulnerable", BeCast( TYPE_STATE_INVULNERABLE ), "State Invulnerable color" }, + { "PrimaryForcefield", BeCast( TYPE_PRIMARY_FORCEFIELD ), "Primary Forcefield color" }, + { "SecondaryForcefield", BeCast( TYPE_SECONDARY_FORCEFIELD ), "Secondary Forcefield color" }, + { "PrimaryBanner", BeCast( TYPE_PRIMARY_BANNER ), "Primary Banner color" }, + { "PrimaryFx", BeCast( TYPE_PRIMARY_FX ), "Primary Fx color" }, + { "SecondaryFx", BeCast( TYPE_SECONDARY_FX ), "Secondary Fx color" }, + { "PrimarySpotlight", BeCast( TYPE_PRIMARY_SPOTLIGHT ), "Primary spotlight color" }, + { "SecondarySpotlight", BeCast( TYPE_SECONDARY_SPOTLIGHT ), "Secondary spotlight color" }, + { "TertiarySpotlight", BeCast( TYPE_TERTIARY_SPOTLIGHT ), "Tertiary spotlight color" }, + { "PrimaryBillboard", BeCast( TYPE_PRIMARY_BILLBOARD ), "Primary Billboard color" }, + { "PrimaryWarpFx", BeCast( TYPE_PRIMARY_WARP_FX ), "Primary Warp FX color" }, + { "PrimaryAttackFX", BeCast( TYPE_PRIMARY_ATTACK_FX ), "Primary Attack FX color" }, + { "PrimarySiegeFX", BeCast( TYPE_PRIMARY_SIEGE_FX ), "Primary Siege FX color" }, + { "PrimaryDockedFX", BeCast( TYPE_PRIMARY_DOCKED_FX ), "Primary Docked FX color" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "EveSOFDataFactionColorSetType", ColorType, EveSOFDataFactionColorSetTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); } -Be::VarChooser EveSOFDataLogoSetTypeChooser[] = -{ +Be::VarChooser EveSOFDataLogoSetTypeChooser[] = { { "Primary", BeCast( EveSOFDataLogoSet::TYPE_PRIMARY ), "Primary Logo" }, { "Secondary", BeCast( EveSOFDataLogoSet::TYPE_SECONDARY ), "Secondary Logo" }, - { "Tertiary", BeCast( EveSOFDataLogoSet::TYPE_TERTIARY), "Tertiary Logo" }, + { "Tertiary", BeCast( EveSOFDataLogoSet::TYPE_TERTIARY ), "Tertiary Logo" }, { "Marking_01", BeCast( EveSOFDataLogoSet::TYPE_MARKING_01 ), "Marking 01 Logo" }, { "Marking_02", BeCast( EveSOFDataLogoSet::TYPE_MARKING_02 ), "Marking 02 Logo" }, { 0 } }; BLUE_REGISTER_ENUM_EX( "EveSOFDataLogoSetType", EveSOFDataLogoSet::LogoType, EveSOFDataLogoSetTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser EveSOFDataPlaneSetBlinkTypeChooser [] = -{ +Be::VarChooser EveSOFDataPlaneSetBlinkTypeChooser[] = { { "Static", BeCast( EveSOFDataBlinkType::TYPE_STATIC ), "Static, no blinking" }, { "Blink", BeCast( EveSOFDataBlinkType::TYPE_BLINK ), "Regular blink" }, { "FadeIn", BeCast( EveSOFDataBlinkType::TYPE_FADE_IN ), "Fade in" }, @@ -81,23 +78,21 @@ Be::VarChooser EveSOFDataPlaneSetBlinkTypeChooser [] = BLUE_REGISTER_ENUM_EX( "EveSOFDataBlinkType", EveSOFDataBlinkType::BlinkType, EveSOFDataPlaneSetBlinkTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( EveSOFDataAreaMaterial ); -const Be::ClassInfo* EveSOFDataAreaMaterial::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataAreaMaterial::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataAreaMaterial, "" ) MAP_INTERFACE( EveSOFDataAreaMaterial ) - MAP_ATTRIBUTE( "material1", m_material[MATERIAL1], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material2", m_material[MATERIAL2], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material3", m_material[MATERIAL3], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material4", m_material[MATERIAL4], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_glowColorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - EXPOSURE_END() + MAP_ATTRIBUTE( "material1", m_material[MATERIAL1], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material2", m_material[MATERIAL2], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material3", m_material[MATERIAL3], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material4", m_material[MATERIAL4], ":jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_glowColorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + EXPOSURE_END() } -Be::VarChooser EveSOFDataHazeTypeChooser[] = -{ +Be::VarChooser EveSOFDataHazeTypeChooser[] = { { "Spherical", BeCast( EveSOFDataHullHazeSet::TYPE_SPHERICAL ), "Spherical Haze" }, { "HalfSpherical_DONOTUSE", BeCast( EveSOFDataHullHazeSet::TYPE_HALFSPHERICAL ), "HalfSpherical Haze" }, { 0 } @@ -115,13 +110,12 @@ Be::VarChooser EveSOFDataHullBuildFilterChooser[] = { BLUE_REGISTER_ENUM_EX( "EveSOFDataHullBuildFilter", uint32_t, EveSOFDataHullBuildFilterChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser EveSOFDataAreaTypeChooser[] = -{ +Be::VarChooser EveSOFDataAreaTypeChooser[] = { { "Primary", BeCast( EveSOFDataArea::TYPE_PRIMARY ), "Primary Area Type" }, { "Glass", BeCast( EveSOFDataArea::TYPE_GLASS ), "Area Type Glass" }, { "Sails", BeCast( EveSOFDataArea::TYPE_SAILS ), "Area Type Sails" }, { "Reactor", BeCast( EveSOFDataArea::TYPE_REACTOR ), "Area Type Reactor" }, - { "Darkhull", BeCast( EveSOFDataArea::TYPE_DARKHULL), "Area Type Dark Hull" }, + { "Darkhull", BeCast( EveSOFDataArea::TYPE_DARKHULL ), "Area Type Dark Hull" }, { "Wreck", BeCast( EveSOFDataArea::TYPE_WRECK ), "Area Type Generic Wreck" }, { "Rock", BeCast( EveSOFDataArea::TYPE_ROCK ), "Area Type Rock" }, { "Monument", BeCast( EveSOFDataArea::TYPE_MONUMENT ), "Area Type Monument" }, @@ -134,263 +128,251 @@ Be::VarChooser EveSOFDataAreaTypeChooser[] = BLUE_REGISTER_ENUM_EX( "EveSOFDataAreaType", EveSOFDataArea::AreaType, EveSOFDataAreaTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( EveSOFDataArea ); -const Be::ClassInfo* EveSOFDataArea::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataArea::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataArea, "" ) MAP_INTERFACE( EveSOFDataArea ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_PRIMARY].mKey, m_materials[TYPE_PRIMARY], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_GLASS].mKey, m_materials[TYPE_GLASS], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_SAILS].mKey, m_materials[TYPE_SAILS], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_REACTOR].mKey, m_materials[TYPE_REACTOR], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_DARKHULL].mKey, m_materials[TYPE_DARKHULL], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_ROCK].mKey, m_materials[TYPE_ROCK], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_MONUMENT].mKey, m_materials[TYPE_MONUMENT], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_ORNAMENT].mKey, m_materials[TYPE_ORNAMENT], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_SIMPLEPRIMARY].mKey, m_materials[TYPE_SIMPLEPRIMARY], "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_TURRET].mKey, m_materials[TYPE_TURRET], "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_PRIMARY].mKey, m_materials[TYPE_PRIMARY], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_GLASS].mKey, m_materials[TYPE_GLASS], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_SAILS].mKey, m_materials[TYPE_SAILS], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_REACTOR].mKey, m_materials[TYPE_REACTOR], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_DARKHULL].mKey, m_materials[TYPE_DARKHULL], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_ROCK].mKey, m_materials[TYPE_ROCK], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_MONUMENT].mKey, m_materials[TYPE_MONUMENT], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_ORNAMENT].mKey, m_materials[TYPE_ORNAMENT], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_SIMPLEPRIMARY].mKey, m_materials[TYPE_SIMPLEPRIMARY], "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[TYPE_TURRET].mKey, m_materials[TYPE_TURRET], "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } - BLUE_DEFINE( EveSOFDataFactionColorSet ); -const Be::ClassInfo* EveSOFDataFactionColorSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataFactionColorSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataFactionColorSet, "" ) MAP_INTERFACE( EveSOFDataFactionColorSet ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BLACK].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BLACK], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_WHITE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_WHITE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_YELLOW].mKey, m_colors[SOFDataFactionColorChooser::TYPE_YELLOW], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_ORANGE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_ORANGE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_RED].mKey, m_colors[SOFDataFactionColorChooser::TYPE_RED], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BLUE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BLUE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_GREEN].mKey, m_colors[SOFDataFactionColorChooser::TYPE_GREEN], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_CYAN].mKey, m_colors[SOFDataFactionColorChooser::TYPE_CYAN], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_FIRE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_FIRE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_HULL].mKey, m_colors[SOFDataFactionColorChooser::TYPE_HULL], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_GLASS].mKey, m_colors[SOFDataFactionColorChooser::TYPE_GLASS], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_REACTOR].mKey, m_colors[SOFDataFactionColorChooser::TYPE_REACTOR], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_DARKHULL].mKey, m_colors[SOFDataFactionColorChooser::TYPE_DARKHULL], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BOOSTER].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BOOSTER], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_KILLMARK].mKey, m_colors[SOFDataFactionColorChooser::TYPE_KILLMARK], ":jessica-group:Decal Glow Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_WHITE_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_WHITE_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_0].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_0], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_1].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_1], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_2].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_2], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_3].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_3], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_VULNERABLE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_VULNERABLE], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_INVULNERABLE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_INVULNERABLE], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_FORCEFIELD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_FORCEFIELD], ":jessica-group:Forcefield Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_FORCEFIELD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_FORCEFIELD], ":jessica-group:Forcefield Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_BANNER].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_BANNER], ":jessica-group:Planeset Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_BILLBOARD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_BILLBOARD], ":jessica-group:Planeset Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_WARP_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_WARP_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_ATTACK_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_ATTACK_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_SIEGE_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_SIEGE_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_DOCKED_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_DOCKED_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BLACK].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BLACK], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_WHITE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_WHITE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_YELLOW].mKey, m_colors[SOFDataFactionColorChooser::TYPE_YELLOW], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_ORANGE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_ORANGE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_RED].mKey, m_colors[SOFDataFactionColorChooser::TYPE_RED], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BLUE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BLUE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_GREEN].mKey, m_colors[SOFDataFactionColorChooser::TYPE_GREEN], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_CYAN].mKey, m_colors[SOFDataFactionColorChooser::TYPE_CYAN], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_FIRE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_FIRE], ":jessica-group:Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_HULL].mKey, m_colors[SOFDataFactionColorChooser::TYPE_HULL], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_GLASS].mKey, m_colors[SOFDataFactionColorChooser::TYPE_GLASS], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_REACTOR].mKey, m_colors[SOFDataFactionColorChooser::TYPE_REACTOR], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_DARKHULL].mKey, m_colors[SOFDataFactionColorChooser::TYPE_DARKHULL], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_BOOSTER].mKey, m_colors[SOFDataFactionColorChooser::TYPE_BOOSTER], ":jessica-group:Material Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_KILLMARK].mKey, m_colors[SOFDataFactionColorChooser::TYPE_KILLMARK], ":jessica-group:Decal Glow Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_WHITE_LIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_WHITE_LIGHT], ":jessica-group:Light Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_SPOTLIGHT].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_SPOTLIGHT], ":jessica-group:Spotlight Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_TERTIARY_HOLOGRAM].mKey, m_colors[SOFDataFactionColorChooser::TYPE_TERTIARY_HOLOGRAM], ":jessica-group:Hologram Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_0].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_0], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_1].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_1], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_2].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_2], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_3].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_3], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_VULNERABLE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_VULNERABLE], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_STATE_INVULNERABLE].mKey, m_colors[SOFDataFactionColorChooser::TYPE_STATE_INVULNERABLE], ":jessica-group:State Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_FORCEFIELD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_FORCEFIELD], ":jessica-group:Forcefield Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_FORCEFIELD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_FORCEFIELD], ":jessica-group:Forcefield Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_BANNER].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_BANNER], ":jessica-group:Planeset Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_BILLBOARD].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_BILLBOARD], ":jessica-group:Planeset Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_SECONDARY_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_SECONDARY_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_WARP_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_WARP_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_ATTACK_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_ATTACK_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_SIEGE_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_SIEGE_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser[SOFDataFactionColorChooser::TYPE_PRIMARY_DOCKED_FX].mKey, m_colors[SOFDataFactionColorChooser::TYPE_PRIMARY_DOCKED_FX], ":jessica-group:FX Colors", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataBoosterShape ); -const Be::ClassInfo* EveSOFDataBoosterShape::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataBoosterShape, "" ) - MAP_INTERFACE( EveSOFDataBoosterShape ) - - MAP_ATTRIBUTE( "noiseFunction", m_noiseFunction, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseSpeed", m_noiseSpeed, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitureStart", m_noiseAmplitureStart, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitureEnd", m_noiseAmplitureEnd, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataBoosterShape::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataBoosterShape, "" ) + MAP_INTERFACE( EveSOFDataBoosterShape ) + + MAP_ATTRIBUTE( "noiseFunction", m_noiseFunction, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseSpeed", m_noiseSpeed, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitureStart", m_noiseAmplitureStart, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitureEnd", m_noiseAmplitureEnd, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataBooster ); -const Be::ClassInfo* EveSOFDataBooster::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataBooster, "" ) - MAP_INTERFACE( EveSOFDataBooster ) - - MAP_ATTRIBUTE( "scale", m_scale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "glowColor", m_glowColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "warpGlowColor", m_warpGlowColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "glowScale", m_glowScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "haloColor", m_haloColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "warpHalpColor", m_warpHaloColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "haloScaleX", m_haloScaleX, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "haloScaleY", m_haloScaleY, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "symHaloScale", m_symHaloScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "trailColor", m_trailColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "trailSize", m_trailSize, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shape0", m_shape0, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shape1", m_shape1, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "warpShape0", m_warpShape0, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "warpShape1", m_warpShape1, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shapeAtlasResPath", m_shapeAtlasResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "gradient0ResPath", m_gradient0ResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "gradient1ResPath", m_gradient1ResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shapeAtlasHeight", m_shapeAtlasHeight, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shapeAtlasCount", m_shapeAtlasCount, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightOffset", m_lightOffset, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightRadius", m_lightRadius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightWarpRadius", m_lightWarpRadius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightFlickerAmplitude", m_lightFlickerAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightFlickerFrequency", m_lightFlickerFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightColor", m_lightColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightWarpColor", m_lightWarpColor, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataBooster::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataBooster, "" ) + MAP_INTERFACE( EveSOFDataBooster ) + + MAP_ATTRIBUTE( "scale", m_scale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "glowColor", m_glowColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "warpGlowColor", m_warpGlowColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "glowScale", m_glowScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "haloColor", m_haloColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "warpHalpColor", m_warpHaloColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "haloScaleX", m_haloScaleX, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "haloScaleY", m_haloScaleY, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "symHaloScale", m_symHaloScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "trailColor", m_trailColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "trailSize", m_trailSize, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shape0", m_shape0, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shape1", m_shape1, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "warpShape0", m_warpShape0, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "warpShape1", m_warpShape1, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shapeAtlasResPath", m_shapeAtlasResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "gradient0ResPath", m_gradient0ResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "gradient1ResPath", m_gradient1ResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shapeAtlasHeight", m_shapeAtlasHeight, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shapeAtlasCount", m_shapeAtlasCount, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightOffset", m_lightOffset, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightRadius", m_lightRadius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightWarpRadius", m_lightWarpRadius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightFlickerAmplitude", m_lightFlickerAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightFlickerFrequency", m_lightFlickerFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightColor", m_lightColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightWarpColor", m_lightWarpColor, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataRaceDamage ); -const Be::ClassInfo* EveSOFDataRaceDamage::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataRaceDamage::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataRaceDamage, "" ) MAP_INTERFACE( EveSOFDataRaceDamage ) - MAP_ATTRIBUTE( "armorImpactParameters", m_armorImpactParameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "armorImpactTextures", m_armorImpactTextures, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "shieldImpactParameters", m_shieldImpactParameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "shieldImpactTextures", m_shieldImpactTextures, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "armorImpactParameters", m_armorImpactParameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "armorImpactTextures", m_armorImpactTextures, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "shieldImpactParameters", m_shieldImpactParameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "shieldImpactTextures", m_shieldImpactTextures, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } -BLUE_DEFINE(EveSOFDataPointLightAttachment); -const Be::ClassInfo* EveSOFDataPointLightAttachment::ExposeToBlue() -{ - EXPOSURE_BEGIN(EveSOFDataPointLightAttachment, "") - MAP_INTERFACE(EveSOFDataPointLightAttachment) - - MAP_ATTRIBUTE( "saturation", m_saturation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerScaleMultiplier", m_innerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "outerScaleMultiplier", m_outerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitude", m_noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseOctaves", m_noiseOctaves, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightProfilePath", m_lightProfilePath, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +BLUE_DEFINE( EveSOFDataPointLightAttachment ); +const Be::ClassInfo* EveSOFDataPointLightAttachment::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataPointLightAttachment, "" ) + MAP_INTERFACE( EveSOFDataPointLightAttachment ) + + MAP_ATTRIBUTE( "saturation", m_saturation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerScaleMultiplier", m_innerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "outerScaleMultiplier", m_outerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitude", m_noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseOctaves", m_noiseOctaves, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightProfilePath", m_lightProfilePath, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } -BLUE_DEFINE(EveSOFDataSpotLightAttachment); -const Be::ClassInfo* EveSOFDataSpotLightAttachment::ExposeToBlue() -{ +BLUE_DEFINE( EveSOFDataSpotLightAttachment ); +const Be::ClassInfo* EveSOFDataSpotLightAttachment::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataSpotLightAttachment, "" ) MAP_INTERFACE( EveSOFDataSpotLightAttachment ) - MAP_ATTRIBUTE( "saturation", m_saturation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerAngleMultiplier", m_innerAngleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "outerAngleMultiplier", m_outerAngleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerScaleMultiplier", m_innerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "outerScaleMultiplier", m_outerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitude", m_noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseOctaves", m_noiseOctaves, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightProfilePath", m_lightProfilePath, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "saturation", m_saturation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerAngleMultiplier", m_innerAngleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "outerAngleMultiplier", m_outerAngleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerScaleMultiplier", m_innerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "outerScaleMultiplier", m_outerScaleMultiplier, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitude", m_noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseOctaves", m_noiseOctaves, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightProfilePath", m_lightProfilePath, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpotlightSetItem ); -const Be::ClassInfo* EveSOFDataHullSpotlightSetItem::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullSpotlightSetItem, "" ) - MAP_INTERFACE( EveSOFDataHullSpotlightSetItem ) - - MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "Used with SOF-6", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "boosterGainInfluence", m_boosterGainInfluence, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "spriteScale", m_spriteScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "coneIntensity", m_coneIntensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "flareIntensity", m_flareIntensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "spriteIntensity", m_spriteIntensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST) - MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullSpotlightSetItem::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullSpotlightSetItem, "" ) + MAP_INTERFACE( EveSOFDataHullSpotlightSetItem ) + + MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "Used with SOF-6", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "boosterGainInfluence", m_boosterGainInfluence, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "spriteScale", m_spriteScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "coneIntensity", m_coneIntensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "flareIntensity", m_flareIntensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "spriteIntensity", m_spriteIntensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpotlightSet ); -const Be::ClassInfo* EveSOFDataHullSpotlightSet::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullSpotlightSet, "" ) - MAP_INTERFACE( EveSOFDataHullSpotlightSet ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\nUsed with SOF-6 \n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "skinned", m_skinned, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "zOffset", m_zOffset, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "coneTextureResPath", m_coneTextureResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "glowTextureResPath", m_glowTextureResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this spotlightset", Be::READ | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullSpotlightSet::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullSpotlightSet, "" ) + MAP_INTERFACE( EveSOFDataHullSpotlightSet ) + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\nUsed with SOF-6 \n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "zOffset", m_zOffset, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "coneTextureResPath", m_coneTextureResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "glowTextureResPath", m_glowTextureResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this spotlightset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullPlaneSetItem ); -const Be::ClassInfo* EveSOFDataHullPlaneSetItem::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullPlaneSetItem, "" ) - MAP_INTERFACE( EveSOFDataHullPlaneSetItem ) - - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "Used with SOF-6", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "intensity", m_intensity, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer1Transform", m_layer1Transform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer1Scroll", m_layer1Scroll, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer2Transform", m_layer2Transform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer2Scroll", m_layer2Scroll, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maskMapAtlasIndex", m_maskMapAtlasIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkRate", m_rate, "rate (Hz)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkPhase", m_phase, "phase (0.-1.)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "blinkMode", m_blinkMode, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPlaneSetBlinkTypeChooser ) - MAP_ATTRIBUTE( "lights", m_lights, "Used with SOF-6", Be::READ | Be::PERSIST ) - - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullPlaneSetItem::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullPlaneSetItem, "" ) + MAP_INTERFACE( EveSOFDataHullPlaneSetItem ) + + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "Used with SOF-6", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "intensity", m_intensity, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer1Transform", m_layer1Transform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer1Scroll", m_layer1Scroll, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer2Transform", m_layer2Transform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer2Scroll", m_layer2Scroll, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maskMapAtlasIndex", m_maskMapAtlasIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkRate", m_rate, "rate (Hz)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkPhase", m_phase, "phase (0.-1.)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "blinkMode", m_blinkMode, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPlaneSetBlinkTypeChooser ) + MAP_ATTRIBUTE( "lights", m_lights, "Used with SOF-6", Be::READ | Be::PERSIST ) + + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullPlaneSet ); -Be::VarChooser EveSOFDataHullPlaneSetUsageChooser[] = -{ +Be::VarChooser EveSOFDataHullPlaneSetUsageChooser[] = { { "Standard", BeCast( EveSOFDataHullPlaneSet::USAGE_STANDARD ), "Standard planeset" }, { "SpaceVideo", BeCast( EveSOFDataHullPlaneSet::USAGE_SPACE_VIDEO ), "Space Video planeset" }, { "HangarVideo", BeCast( EveSOFDataHullPlaneSet::USAGE_HANGAR_VIDEO ), "Hangar Video planeset" }, @@ -399,188 +381,177 @@ Be::VarChooser EveSOFDataHullPlaneSetUsageChooser[] = }; BLUE_REGISTER_ENUM_EX( "HullPlanesetUsage", EveSOFDataHullPlaneSet::Usage, EveSOFDataHullPlaneSetUsageChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::ClassInfo* EveSOFDataHullPlaneSet::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullPlaneSet, "" ) - MAP_INTERFACE( EveSOFDataHullPlaneSet ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\nUsed with SOF-6 \n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer1MapResPath", m_layer1MapResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer2MapResPath", m_layer2MapResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maskMapResPath", m_maskMapResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER("usage", m_usage, "Choose the usage of this planeSet", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullPlaneSetUsageChooser ) - MAP_ATTRIBUTE( "atlasSize", m_atlasSize, "Specifies the uniform division of a texture atlas into a square grid of chunks.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "atlasAspectRatio", m_atlasAspectRatio, "Adjusts the chunk sizes within the atlas for non-uniform X and Y dimensions.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "skinned", m_skinned, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "items", m_items, "The items in this planeset", Be::READ | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullPlaneSet::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullPlaneSet, "" ) + MAP_INTERFACE( EveSOFDataHullPlaneSet ) + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\nUsed with SOF-6 \n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer1MapResPath", m_layer1MapResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer2MapResPath", m_layer2MapResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maskMapResPath", m_maskMapResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Choose the usage of this planeSet", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullPlaneSetUsageChooser ) + MAP_ATTRIBUTE( "atlasSize", m_atlasSize, "Specifies the uniform division of a texture atlas into a square grid of chunks.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "atlasAspectRatio", m_atlasAspectRatio, "Adjusts the chunk sizes within the atlas for non-uniform X and Y dimensions.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "items", m_items, "The items in this planeset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFactionVisibilityGroupSet ); -const Be::ClassInfo* EveSOFDataFactionVisibilityGroupSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataFactionVisibilityGroupSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataFactionVisibilityGroupSet, "" ) MAP_INTERFACE( EveSOFDataFactionVisibilityGroupSet ) - MAP_ATTRIBUTE( "visibilityGroups", m_visibilityGroups, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "visibilityGroups", m_visibilityGroups, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFactionSpotlightSet ); -const Be::ClassInfo* EveSOFDataFactionSpotlightSet::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataFactionSpotlightSet, "" ) - MAP_INTERFACE( EveSOFDataFactionSpotlightSet ) - - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "coneColor", m_coneColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "spriteColor", m_spriteColor, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "flareColor", m_flareColor, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataFactionSpotlightSet::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataFactionSpotlightSet, "" ) + MAP_INTERFACE( EveSOFDataFactionSpotlightSet ) + + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "coneColor", m_coneColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "spriteColor", m_spriteColor, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "flareColor", m_flareColor, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFactionPlaneSet ); -const Be::ClassInfo* EveSOFDataFactionPlaneSet::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataFactionPlaneSet, "" ) - MAP_INTERFACE( EveSOFDataFactionPlaneSet ) - - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataFactionPlaneSet::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataFactionPlaneSet, "" ) + MAP_INTERFACE( EveSOFDataFactionPlaneSet ) + + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpriteSetItem ); -const Be::ClassInfo* EveSOFDataHullSpriteSetItem::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullSpriteSetItem, "" ) - MAP_INTERFACE( EveSOFDataHullSpriteSetItem ) - - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkRate", m_blinkRate, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkPhase", m_blinkPhase, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "minScale", m_minScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxScale", m_maxScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "falloff", m_falloff, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullSpriteSetItem::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullSpriteSetItem, "" ) + MAP_INTERFACE( EveSOFDataHullSpriteSetItem ) + + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkRate", m_blinkRate, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkPhase", m_blinkPhase, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "minScale", m_minScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxScale", m_maxScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "falloff", m_falloff, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpriteSet ); -const Be::ClassInfo* EveSOFDataHullSpriteSet::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullSpriteSet, "" ) - MAP_INTERFACE( EveSOFDataHullSpriteSet ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "skinned", m_skinned, "Is this spriteset bone-animated.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this spriteset", Be::READ | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullSpriteSet::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullSpriteSet, "" ) + MAP_INTERFACE( EveSOFDataHullSpriteSet ) + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "Is this spriteset bone-animated.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this spriteset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpriteLineSetItem ); -const Be::ClassInfo* EveSOFDataHullSpriteLineSetItem::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullSpriteLineSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullSpriteLineSetItem, "" ) MAP_INTERFACE( EveSOFDataHullSpriteLineSetItem ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "spacing", m_spacing, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkRate", m_blinkRate, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkPhase", m_blinkPhase, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blinkPhaseShift", m_blinkPhaseShift, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "minScale", m_minScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxScale", m_maxScale, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "falloff", m_falloff, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isCircle", m_isCircle, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST) - EXPOSURE_END() + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "spacing", m_spacing, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkRate", m_blinkRate, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkPhase", m_blinkPhase, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blinkPhaseShift", m_blinkPhaseShift, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "minScale", m_minScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxScale", m_maxScale, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "falloff", m_falloff, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "intensity", m_intensity, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isCircle", m_isCircle, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "light", m_light, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSpriteLineSet ); -const Be::ClassInfo* EveSOFDataHullSpriteLineSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullSpriteLineSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullSpriteLineSet, "" ) MAP_INTERFACE( EveSOFDataHullSpriteLineSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "skinned", m_skinned, "Is this spriteset bone-animated.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this spritelineset", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "Is this spriteset bone-animated.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this spritelineset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullHazeSetItem ); -const Be::ClassInfo* EveSOFDataHullHazeSetItem::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullHazeSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullHazeSetItem, "" ) MAP_INTERFACE( EveSOFDataHullHazeSetItem ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hazeBrightness", m_hazeBrightness, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hazeFalloff", m_hazeFalloff, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "sourceBrightness", m_sourceBrightness, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "sourceSize", m_sourceSize, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boosterGainInfluence", m_boosterGainInfluence, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lights", m_lights, "Used with SOF-6", Be::READ | Be::PERSIST ) - - EXPOSURE_END() + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "colorType", m_colorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "saturation", m_saturation, "Used with SOF-6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hazeBrightness", m_hazeBrightness, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hazeFalloff", m_hazeFalloff, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceBrightness", m_sourceBrightness, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "sourceSize", m_sourceSize, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boosterGainInfluence", m_boosterGainInfluence, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lights", m_lights, "Used with SOF-6", Be::READ | Be::PERSIST ) + + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullHazeSet ); -const Be::ClassInfo* EveSOFDataHullHazeSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullHazeSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullHazeSet, "" ) MAP_INTERFACE( EveSOFDataHullHazeSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "hazeType", m_hazeType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHazeTypeChooser ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "skinned", m_skinned, "Is this hazeset bone-animated.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this hazeset", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "hazeType", m_hazeType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHazeTypeChooser ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "skinned", m_skinned, "Is this hazeset bone-animated.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this hazeset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } -Be::VarChooser EveSOFDataHullBannerUsageChooser[] = -{ +Be::VarChooser EveSOFDataHullBannerUsageChooser[] = { { "AllianceLogo", BeCast( EveSOFDataHullBanner::ALLIANCE_LOGO ), "Alliance logo" }, { "CorpLogo", BeCast( EveSOFDataHullBanner::CORP_LOGO ), "Corporation logo" }, { "CeoPortrait", BeCast( EveSOFDataHullBanner::CEO_PORTRAIT ), "Ceo portrait" }, @@ -642,8 +613,7 @@ Be::VarChooser EveSOFDataHullBannerSetItemUsageChooser[] = { BLUE_REGISTER_ENUM_EX( "HullBannerSetItemUsage", EveSOFDataHullBannerSetItem::Usage, EveSOFDataHullBannerSetItemUsageChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( EveSOFDataHullBannerLight ); -const Be::ClassInfo* EveSOFDataHullBannerLight::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullBannerLight::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullBannerLight, "" ) MAP_ATTRIBUTE( "brightness", @@ -651,79 +621,78 @@ const Be::ClassInfo* EveSOFDataHullBannerLight::ExposeToBlue() "A multiplier for the light's brightness\n" ":jessica-group: Light", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "radiusMultiplier", - m_radiusMultiplier, - "Multiplier for the size of the light \n" - ":jessica-group: Light", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "innerRadiusMultiplier", - m_innerRadiusMultiplier, - "A multiplier for the light's inner radius based on it's scaling mod (default is 1/3 of the outer radius)\n" - ":jessica-group: Light", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "noiseAmplitude", - m_noiseAmplitude, - "Brightness noise amplitude\n" - ":jessica-group: Noise", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "noiseFrequency", - m_noiseFrequency, - "Brightness noise frequency\n" - ":jessica-group: Noise", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "noiceOctaves", - m_noiseOctaves, - "Brightness turbulance octives\n" - ":jessica-group: Noise", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "saturation", - m_saturation, - "color saturation for banner lights \n" - ":jessica-group: ColorMix", - Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( + "radiusMultiplier", + m_radiusMultiplier, + "Multiplier for the size of the light \n" + ":jessica-group: Light", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "innerRadiusMultiplier", + m_innerRadiusMultiplier, + "A multiplier for the light's inner radius based on it's scaling mod (default is 1/3 of the outer radius)\n" + ":jessica-group: Light", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "noiseAmplitude", + m_noiseAmplitude, + "Brightness noise amplitude\n" + ":jessica-group: Noise", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "noiseFrequency", + m_noiseFrequency, + "Brightness noise frequency\n" + ":jessica-group: Noise", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "noiceOctaves", + m_noiseOctaves, + "Brightness turbulance octives\n" + ":jessica-group: Noise", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "saturation", + m_saturation, + "color saturation for banner lights \n" + ":jessica-group: ColorMix", + Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullBanner ); -const Be::ClassInfo* EveSOFDataHullBanner::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullBanner::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullBanner, "" ) MAP_INTERFACE( EveSOFDataHullBanner ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Banner usage", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullBannerUsageChooser ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::PERSISTONLY ) - MAP_PROPERTY( "scaling", GetScaling, SetScaling, "" ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "angleX", m_angleX, "", Be::PERSISTONLY ) - MAP_PROPERTY( "angleX", GetAngleX, SetAngleX, "Horizontal curve angle" ) - MAP_ATTRIBUTE( "angleY", m_angleY, "", Be::PERSISTONLY ) - MAP_PROPERTY( "angleY", GetAngleY, SetAngleY, "Vertical curve angle" ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Banner usage", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullBannerUsageChooser ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::PERSISTONLY ) + MAP_PROPERTY( "scaling", GetScaling, SetScaling, "" ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "angleX", m_angleX, "", Be::PERSISTONLY ) + MAP_PROPERTY( "angleX", GetAngleX, SetAngleX, "Horizontal curve angle" ) + MAP_ATTRIBUTE( "angleY", m_angleY, "", Be::PERSISTONLY ) + MAP_PROPERTY( "angleY", GetAngleY, SetAngleY, "Vertical curve angle" ) - MAP_ATTRIBUTE( "lightOverride", m_lightOverride, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "lightOverride", m_lightOverride, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maintainAspectRatio", m_maintainAspectRatio, "Maintain UV aspect ratio when manipulating a banner", Be::READWRITE ) - EXPOSURE_END() + MAP_ATTRIBUTE( "maintainAspectRatio", m_maintainAspectRatio, "Maintain UV aspect ratio when manipulating a banner", Be::READWRITE ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullBannerSet ); const Be::ClassInfo* EveSOFDataHullBannerSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullBannerSet, "" ) MAP_INTERFACE( EveSOFDataHullBannerSet ) - MAP_PROPERTY_READONLY( "name", GetName, "") - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, ":jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "banners", m_banners, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "name", GetName, "" ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, ":jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "banners", m_banners, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullBannerSetItem ); @@ -731,132 +700,124 @@ const Be::ClassInfo* EveSOFDataHullBannerSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullBannerSetItem, "" ) MAP_INTERFACE( EveSOFDataHullBannerSetItem ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Banner usage", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullBannerSetItemUsageChooser ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::PERSISTONLY ) - MAP_PROPERTY( "scaling", GetScaling, SetScaling, "" ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "angleX", m_angleX, "", Be::PERSISTONLY ) - MAP_PROPERTY( "angleX", GetAngleX, SetAngleX, "Horizontal curve angle" ) - MAP_ATTRIBUTE( "angleY", m_angleY, "", Be::PERSISTONLY ) - MAP_PROPERTY( "angleY", GetAngleY, SetAngleY, "Vertical curve angle" ) - MAP_ATTRIBUTE( "light", m_light, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "maintainAspectRatio", m_maintainAspectRatio, "Maintain UV aspect ratio when manipulating a banner", Be::READWRITE ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Banner usage", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataHullBannerSetItemUsageChooser ) + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::PERSISTONLY ) + MAP_PROPERTY( "scaling", GetScaling, SetScaling, "" ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "angleX", m_angleX, "", Be::PERSISTONLY ) + MAP_PROPERTY( "angleX", GetAngleX, SetAngleX, "Horizontal curve angle" ) + MAP_ATTRIBUTE( "angleY", m_angleY, "", Be::PERSISTONLY ) + MAP_PROPERTY( "angleY", GetAngleY, SetAngleY, "Vertical curve angle" ) + MAP_ATTRIBUTE( "light", m_light, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "maintainAspectRatio", m_maintainAspectRatio, "Maintain UV aspect ratio when manipulating a banner", Be::READWRITE ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullBooster ); -const Be::ClassInfo* EveSOFDataHullBooster::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullBooster, "" ) - MAP_INTERFACE( EveSOFDataHullBooster ) - - MAP_ATTRIBUTE( "alwaysOn", m_alwaysOn, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hasTrails", m_hasTrails, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullBooster::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullBooster, "" ) + MAP_INTERFACE( EveSOFDataHullBooster ) + + MAP_ATTRIBUTE( "alwaysOn", m_alwaysOn, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hasTrails", m_hasTrails, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullBoosterItem ); -const Be::ClassInfo* EveSOFDataHullBoosterItem::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullBoosterItem, "" ) - MAP_INTERFACE( EveSOFDataHullBoosterItem ) - - MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "functionality", m_functionality, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hasTrail", m_hasTrail, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "atlasIndex0", m_atlasIndex0, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "atlasIndex1", m_atlasIndex1, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lightScale", m_lightScale, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullBoosterItem::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullBoosterItem, "" ) + MAP_INTERFACE( EveSOFDataHullBoosterItem ) + + MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "functionality", m_functionality, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hasTrail", m_hasTrail, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "atlasIndex0", m_atlasIndex0, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "atlasIndex1", m_atlasIndex1, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lightScale", m_lightScale, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataTexture ); -const Be::ClassInfo* EveSOFDataTexture::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataTexture, "" ) - MAP_INTERFACE( EveSOFDataTexture ) +const Be::ClassInfo* EveSOFDataTexture::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataTexture, "" ) + MAP_INTERFACE( EveSOFDataTexture ) - MAP_ATTRIBUTE( "resFilePath", m_resFilePath, "Resource path.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "Parameter name of this texture", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "resFilePath", m_resFilePath, "Resource path.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "Parameter name of this texture", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullArea ); -const Be::ClassInfo* EveSOFDataHullArea::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullArea, "" ) - MAP_INTERFACE( EveSOFDataHullArea ) - - MAP_ATTRIBUTE( "index", m_index, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "count", m_count, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shader", m_shader, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blockedMaterials", m_blockedMaterials, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "areaType", m_areaType, "na", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataAreaTypeChooser ) - MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullArea::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullArea, "" ) + MAP_INTERFACE( EveSOFDataHullArea ) + + MAP_ATTRIBUTE( "index", m_index, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "count", m_count, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shader", m_shader, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blockedMaterials", m_blockedMaterials, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "areaType", m_areaType, "na", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataAreaTypeChooser ) + MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLocator ); -const Be::ClassInfo* EveSOFDataHullLocator::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullLocator, "" ) - MAP_INTERFACE( EveSOFDataHullLocator ) +const Be::ClassInfo* EveSOFDataHullLocator::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullLocator, "" ) + MAP_INTERFACE( EveSOFDataHullLocator ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transform", m_transform, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE_INTERFACE( IEveSOFDataHullLocatorSet ); BLUE_DEFINE( EveSOFDataHullLocatorSet ); -const Be::ClassInfo* EveSOFDataHullLocatorSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLocatorSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLocatorSet, "" ) MAP_INTERFACE( EveSOFDataHullLocatorSet ) - MAP_INTERFACE( IEveSOFDataHullLocatorSet ) + MAP_INTERFACE( IEveSOFDataHullLocatorSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "locators", m_locators, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "locators", m_locators, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLocatorSetGroup ); -const Be::ClassInfo* EveSOFDataHullLocatorSetGroup::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLocatorSetGroup::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLocatorSetGroup, ":jessica-icon: far-folder-tree" ) MAP_INTERFACE( EveSOFDataHullLocatorSetGroup ) - MAP_INTERFACE( IEveSOFDataHullLocatorSet ) + MAP_INTERFACE( IEveSOFDataHullLocatorSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "locatorSets", m_locatorSets, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "locatorSets", m_locatorSets, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataTransform ); -const Be::ClassInfo* EveSOFDataTransform::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataTransform, "" ) - MAP_INTERFACE( EveSOFDataTransform ) - - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataTransform::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataTransform, "" ) + MAP_INTERFACE( EveSOFDataTransform ) + + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } @@ -865,191 +826,184 @@ const Be::ClassInfo* EveSOFDataHullChildSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullChildSet, "" ) MAP_INTERFACE( EveSOFDataHullChildSet ) - MAP_PROPERTY_READONLY( "name", GetName, "" ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, ":jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "name", GetName, "" ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, ":jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullChildSetItem ); const Be::ClassInfo* EveSOFDataHullChildSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullChildSetItem, "" ) MAP_INTERFACE( EveSOFDataHullChildSetItem ) - MAP_PROPERTY_READONLY( "name", GetName, "" ) - MAP_ATTRIBUTE( "redFilePath", m_redFilePath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "name", GetName, "" ) + MAP_ATTRIBUTE( "redFilePath", m_redFilePath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullChild ); -const Be::ClassInfo* EveSOFDataHullChild::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullChild, "" ) - MAP_INTERFACE( EveSOFDataHullChild ) - - MAP_PROPERTY_READONLY( "name", GetName, "" ) - MAP_ATTRIBUTE( "redFilePath", m_redFilePath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "id", m_id, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullChild::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullChild, "" ) + MAP_INTERFACE( EveSOFDataHullChild ) + + MAP_PROPERTY_READONLY( "name", GetName, "" ) + MAP_ATTRIBUTE( "redFilePath", m_redFilePath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translation", m_translation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "id", m_id, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullAnimation ); -const Be::ClassInfo* EveSOFDataHullAnimation::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHullAnimation, "" ) - MAP_INTERFACE( EveSOFDataHullAnimation ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "startRotationValue", m_startRotationValue, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endRotationValue", m_endRotationValue, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "startRotationTime", m_startRotationTime, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endRotationTime", m_endRotationTime, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "startTranslationValue", m_startTranslationValue, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endTranslationValue", m_endTranslationValue, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "startTranslationTime", m_startTranslationTime, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endTranslationTime", m_endTranslationTime, "", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "id", m_id, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "startRate", m_startRate, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "endRate", m_endRate, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHullAnimation::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHullAnimation, "" ) + MAP_INTERFACE( EveSOFDataHullAnimation ) + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "startRotationValue", m_startRotationValue, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endRotationValue", m_endRotationValue, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "startRotationTime", m_startRotationTime, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endRotationTime", m_endRotationTime, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "startTranslationValue", m_startTranslationValue, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endTranslationValue", m_endTranslationValue, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "startTranslationTime", m_startTranslationTime, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endTranslationTime", m_endTranslationTime, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "id", m_id, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "startRate", m_startRate, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "endRate", m_endRate, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullController ); -const Be::ClassInfo* EveSOFDataHullController::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullController::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullController, "" ) MAP_INTERFACE( EveSOFDataHullController ) - MAP_PROPERTY_READONLY( "name", GetName, "" ) - MAP_ATTRIBUTE( - "path", - m_path, - "Path to the red file for the controller\n" - ":jessica-widget: filepath\n" - ":jessica-file-filter: redfile", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) - EXPOSURE_END() + MAP_PROPERTY_READONLY( "name", GetName, "" ) + MAP_ATTRIBUTE( + "path", + m_path, + "Path to the red file for the controller\n" + ":jessica-widget: filepath\n" + ":jessica-file-filter: redfile", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "buildFilter", m_buildFilter, "", Be::READWRITE | Be::PERSIST, EveSOFDataHullBuildFilterChooser ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullSoundEmitter ); -const Be::ClassInfo* EveSOFDataHullSoundEmitter::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullSoundEmitter::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullSoundEmitter, "" ) MAP_INTERFACE( EveSOFDataHullSoundEmitter ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "prefix", m_prefix, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "attenuationScalingFactor", - m_attenuationScalingFactor, - "The attenuation scaling factor when this audio emitter is initially spawned.", - Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "prefix", m_prefix, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "attenuationScalingFactor", + m_attenuationScalingFactor, + "The attenuation scaling factor when this audio emitter is initially spawned.", + Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHull ); -Be::VarChooser EveSOFBuildClassChooser[] = -{ - { "EveShip2", BeCast( EveSOFDataHull::BUILDCLASS_SHIP ), "Build an EveShip2" }, - { "EveMobile", BeCast( EveSOFDataHull::BUILDCLASS_MOBILE ), "Build an EveMobile" }, - { "EveStation2", BeCast( EveSOFDataHull::BUILDCLASS_STATIONARY ), "Build an EveStation2" }, - { "EveSwarm", BeCast( EveSOFDataHull::BUILDCLASS_SWARM ), "Build an EveSwarm" }, - { "Extension", BeCast( EveSOFDataHull::BUILDCLASS_EXTENSION), "Build an EveEffectRoot with a child" }, +Be::VarChooser EveSOFBuildClassChooser[] = { + { "EveShip2", BeCast( EveSOFDataHull::BUILDCLASS_SHIP ), "Build an EveShip2" }, + { "EveMobile", BeCast( EveSOFDataHull::BUILDCLASS_MOBILE ), "Build an EveMobile" }, + { "EveStation2", BeCast( EveSOFDataHull::BUILDCLASS_STATIONARY ), "Build an EveStation2" }, + { "EveSwarm", BeCast( EveSOFDataHull::BUILDCLASS_SWARM ), "Build an EveSwarm" }, + { "Extension", BeCast( EveSOFDataHull::BUILDCLASS_EXTENSION ), "Build an EveEffectRoot with a child" }, { 0 } }; BLUE_REGISTER_ENUM_EX( "BuildClass", EveSOFDataHull::BuildClass, EveSOFBuildClassChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser EveSOFImpactEffectTypeChooser[] = -{ +Be::VarChooser EveSOFImpactEffectTypeChooser[] = { { "Nothing", BeCast( EveSOFDataHull::IMPACTEFFECT_NONE ), "No impact effects" }, { "Ellipsoid", BeCast( EveSOFDataHull::IMPACTEFFECT_ELLIPSOID ), "Use ellipsoid for shield" }, - { "Hull", BeCast( EveSOFDataHull::IMPACTEFFECT_HULL), "Use ellipsoid for hull" }, + { "Hull", BeCast( EveSOFDataHull::IMPACTEFFECT_HULL ), "Use ellipsoid for hull" }, { 0 } }; BLUE_REGISTER_ENUM_EX( "ImpactEffectType", EveSOFDataHull::ImpactEffectType, EveSOFImpactEffectTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::ClassInfo* EveSOFDataHull::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataHull, "" ) - MAP_INTERFACE( EveSOFDataHull ) - - MAP_ATTRIBUTE( "name", m_name, "The hull name, eg cb2_t1. This functions as an ID.", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "sof6", m_sof6, "Use SOF-6 features", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "description", m_description, "A description string. NOT used by the SOF, it's just for debugging purposes.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "category", m_category, "A category string. NOT used by the SOF, it's for tool validation.\n:jessica-widget: hullcategory", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE_WITH_CHOOSER("buildClass", m_buildClass, "Choose the output trinity class", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFBuildClassChooser ) - - MAP_ATTRIBUTE( "geometryResFilePath", m_geometryResFilePath, "The res file path to the gr2 file", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boundingSphere", m_boundingSphere, "The actual size of the geometry", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shapeEllipsoidCenter", m_shapeEllipsoidCenter, "The geometry's shape ellipsoid: center", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shapeEllipsoidRadius", m_shapeEllipsoidRadius, "The geometry's shape ellipsoid: center", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isSkinned", m_isSkinned, "Does this hull need skinned shaders?", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "enableDynamicBoundingSphere", m_enableDynamicBoundingSphere, "Used to toggle dynamic bounding sphere.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "castShadow", m_castShadow, "Used to toggle shadow casting.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "opaqueAreas", m_opaqueAreas, "The opaque areas on this mesh", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "decalAreas", m_decalAreas, "The decal aSOFDatareas on this mesh", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "transparentAreas", m_transparentAreas, "The transparent areas on this mesh", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "additiveAreas", m_additiveAreas, "The additive areas on this mesh", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "distortionAreas", m_distortionAreas, "The distortion areas on this mesh", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "defaultPattern", m_defaultPattern, "The default pattern projection data for this hull", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "spriteSets", m_spriteSets, "The spritesets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "spotlightSets", m_spotlightSets, "The spotlightsets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "planeSets", m_planeSets, "The planesets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "spriteLineSets", m_spriteLineSets, "The spritelinesets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "hazeSets", m_hazeSets, "The hazesets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "banners", m_banners, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "bannerSets", m_bannerSets, "The bannerSets\nUsed with SOF-6", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "decalSets", m_decalSets, "The decalsets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "lightSets", m_lightSets, "The lightSets", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "impactEffectType", m_impactEffectType, "Type of impact effect on this hull", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFImpactEffectTypeChooser ) - - MAP_ATTRIBUTE( "booster", m_booster, "The booster", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "audioPosition", m_audioPosition, "The audio position", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "children", m_children, "List of children", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "childSets", m_childSets, "Set of child effects\nUsed with SOF-6", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "soundEmitters", m_soundEmitters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "controllers", m_controllers, "List of controller references", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "animations", m_animations, "List of animations", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "instancedMeshes", m_instancedMeshes, "List of instanced meshes", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "locatorTurrets", m_locatorTurrets, "Turret locators", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "locatorSets", m_locatorSets, "Damage locators", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "modelRotationCurvePath", m_modelRotationCurvePath, "Model rotation curve path", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "modelTranslationCurvePath", m_modelTranslationCurvePath, "Model translation curve path", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataHull::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataHull, "" ) + MAP_INTERFACE( EveSOFDataHull ) + + MAP_ATTRIBUTE( "name", m_name, "The hull name, eg cb2_t1. This functions as an ID.", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "sof6", m_sof6, "Use SOF-6 features", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "description", m_description, "A description string. NOT used by the SOF, it's just for debugging purposes.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "category", m_category, "A category string. NOT used by the SOF, it's for tool validation.\n:jessica-widget: hullcategory", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE_WITH_CHOOSER( "buildClass", m_buildClass, "Choose the output trinity class", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFBuildClassChooser ) + + MAP_ATTRIBUTE( "geometryResFilePath", m_geometryResFilePath, "The res file path to the gr2 file", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boundingSphere", m_boundingSphere, "The actual size of the geometry", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shapeEllipsoidCenter", m_shapeEllipsoidCenter, "The geometry's shape ellipsoid: center", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shapeEllipsoidRadius", m_shapeEllipsoidRadius, "The geometry's shape ellipsoid: center", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isSkinned", m_isSkinned, "Does this hull need skinned shaders?", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "enableDynamicBoundingSphere", m_enableDynamicBoundingSphere, "Used to toggle dynamic bounding sphere.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "castShadow", m_castShadow, "Used to toggle shadow casting.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "opaqueAreas", m_opaqueAreas, "The opaque areas on this mesh", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "decalAreas", m_decalAreas, "The decal aSOFDatareas on this mesh", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "transparentAreas", m_transparentAreas, "The transparent areas on this mesh", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "additiveAreas", m_additiveAreas, "The additive areas on this mesh", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "distortionAreas", m_distortionAreas, "The distortion areas on this mesh", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "defaultPattern", m_defaultPattern, "The default pattern projection data for this hull", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "spriteSets", m_spriteSets, "The spritesets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "spotlightSets", m_spotlightSets, "The spotlightsets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "planeSets", m_planeSets, "The planesets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "spriteLineSets", m_spriteLineSets, "The spritelinesets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "hazeSets", m_hazeSets, "The hazesets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "banners", m_banners, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "bannerSets", m_bannerSets, "The bannerSets\nUsed with SOF-6", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "decalSets", m_decalSets, "The decalsets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "lightSets", m_lightSets, "The lightSets", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "impactEffectType", m_impactEffectType, "Type of impact effect on this hull", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFImpactEffectTypeChooser ) + + MAP_ATTRIBUTE( "booster", m_booster, "The booster", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "audioPosition", m_audioPosition, "The audio position", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "children", m_children, "List of children", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "childSets", m_childSets, "Set of child effects\nUsed with SOF-6", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "soundEmitters", m_soundEmitters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "controllers", m_controllers, "List of controller references", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "animations", m_animations, "List of animations", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "instancedMeshes", m_instancedMeshes, "List of instanced meshes", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "locatorTurrets", m_locatorTurrets, "Turret locators", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "locatorSets", m_locatorSets, "Damage locators", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "modelRotationCurvePath", m_modelRotationCurvePath, "Model rotation curve path", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "modelTranslationCurvePath", m_modelTranslationCurvePath, "Model translation curve path", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } @@ -1058,153 +1012,145 @@ BLUE_DEFINE( EveSOFDataMultiHullDecalIndexBuffers ); const Be::ClassInfo* EveSOFDataMultiHullDecalIndexBuffers::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataMultiHullDecalIndexBuffers, "" ) MAP_INTERFACE( EveSOFDataMultiHullDecalIndexBuffers ) - MAP_ATTRIBUTE( "combinedGeometryResPath", m_combinedGeometryResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "indexBuffers", m_indexBuffers, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "combinedGeometryResPath", m_combinedGeometryResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "indexBuffers", m_indexBuffers, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullDecalSetItem ); -Be::VarChooser EveSOFDecalUsageChooser[] = - { - { "Standard", BeCast( EveSOFDataHullDecalSetItem::USAGE_STANDARD ), "Standard decal" }, - { "KillCounter", BeCast( EveSOFDataHullDecalSetItem::USAGE_KILLCOUNTER ), "The killcounter decal" }, - { "Hole", BeCast( EveSOFDataHullDecalSetItem::USAGE_HOLE ), "Hole decal" }, - { "Cylindrical", BeCast( EveSOFDataHullDecalSetItem::USAGE_CYLINDRICAL ), "Cylindrical decal" }, - { "GlowCylindrical", BeCast( EveSOFDataHullDecalSetItem::USAGE_GLOWCYLINDRICAL ), "Glow cylindrical decal" }, - { "Glow", BeCast( EveSOFDataHullDecalSetItem::USAGE_GLOWSTANDARD ), "Glow decal" }, - { "Logo", BeCast( EveSOFDataHullDecalSetItem::USAGE_LOGO), "Logo decal" }, - { 0 } - }; +Be::VarChooser EveSOFDecalUsageChooser[] = { + { "Standard", BeCast( EveSOFDataHullDecalSetItem::USAGE_STANDARD ), "Standard decal" }, + { "KillCounter", BeCast( EveSOFDataHullDecalSetItem::USAGE_KILLCOUNTER ), "The killcounter decal" }, + { "Hole", BeCast( EveSOFDataHullDecalSetItem::USAGE_HOLE ), "Hole decal" }, + { "Cylindrical", BeCast( EveSOFDataHullDecalSetItem::USAGE_CYLINDRICAL ), "Cylindrical decal" }, + { "GlowCylindrical", BeCast( EveSOFDataHullDecalSetItem::USAGE_GLOWCYLINDRICAL ), "Glow cylindrical decal" }, + { "Glow", BeCast( EveSOFDataHullDecalSetItem::USAGE_GLOWSTANDARD ), "Glow decal" }, + { "Logo", BeCast( EveSOFDataHullDecalSetItem::USAGE_LOGO ), "Logo decal" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "DecalUsage", EveSOFDataHullDecalSetItem::Usage, EveSOFDecalUsageChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::ClassInfo* EveSOFDataHullDecalSetItem::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullDecalSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullDecalSetItem, "" ) MAP_INTERFACE( EveSOFDataHullDecalSetItem ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Choose the usage of this decal", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDecalUsageChooser ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "meshIndex", m_meshIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "glowColorType", m_glowColorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "logoType", m_logoType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataLogoSetTypeChooser ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "indexBuffers", m_indexBuffers, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "multiHullIndexBuffers", m_multiHullIndexBuffers, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "usage", m_usage, "Choose the usage of this decal", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDecalUsageChooser ) + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "meshIndex", m_meshIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "glowColorType", m_glowColorType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "logoType", m_logoType, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataLogoSetTypeChooser ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "indexBuffers", m_indexBuffers, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "multiHullIndexBuffers", m_multiHullIndexBuffers, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLightSetItem ); -const Be::ClassInfo* EveSOFDataHullLightSetItem::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLightSetItem::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLightSetItem, "" ) MAP_INTERFACE( EveSOFDataHullLightSetItem ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) - MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "lightColor", m_data.lightColor, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) + MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "lightColor", m_data.lightColor, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) + + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLightSetTexturedPointLight ); -const Be::ClassInfo* EveSOFDataHullLightSetTexturedPointLight::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLightSetTexturedPointLight::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLightSetTexturedPointLight, "" ) MAP_INTERFACE( EveSOFDataHullLightSetTexturedPointLight ) - MAP_INTERFACE( EveSOFDataHullLightSetItem ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) - MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "texturePath", m_data.texturePath, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( EveSOFDataHullLightSetItem ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) + MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "texturePath", m_data.texturePath, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLightSetSpotLight ); -const Be::ClassInfo* EveSOFDataHullLightSetSpotLight::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLightSetSpotLight::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLightSetSpotLight, "" ) MAP_INTERFACE( EveSOFDataHullLightSetSpotLight ) - MAP_INTERFACE( EveSOFDataHullLightSetItem ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) - MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_data.rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "lightColor", m_data.lightColor, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "innerAngle", m_data.innerAngle, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "outerAngle", m_data.outerAngle, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_END() + MAP_INTERFACE( EveSOFDataHullLightSetItem ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "flags", m_data.flags, "Various light options", Be::READWRITE | Be::PERSIST, Tr2LightFlagChooser ) + MAP_ATTRIBUTE( "position", m_data.position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "boneIndex", m_data.boneIndex, ":jessica-widget: boneindex", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_data.rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "lightColor", m_data.lightColor, "", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "radius", m_data.radius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerRadius", m_data.innerRadius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "innerAngle", m_data.innerAngle, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "outerAngle", m_data.outerAngle, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "brightness", m_data.brightness, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseAmplitude", m_data.noiseAmplitude, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseFrequency", m_data.noiseFrequency, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "noiseOctaves", m_data.noiseOctaves, "", Be::READWRITE | Be::PERSIST ) + + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataLogoSet ); -const Be::ClassInfo* EveSOFDataLogoSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataLogoSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataLogoSet, "" ) MAP_INTERFACE( EveSOFDataLogoSet ) - MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_PRIMARY].mKey, m_logos[TYPE_PRIMARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_SECONDARY].mKey, m_logos[TYPE_SECONDARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_TERTIARY].mKey, m_logos[TYPE_TERTIARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_MARKING_01].mKey, m_logos[TYPE_MARKING_01], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_MARKING_02].mKey, m_logos[TYPE_MARKING_02], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_PRIMARY].mKey, m_logos[TYPE_PRIMARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_SECONDARY].mKey, m_logos[TYPE_SECONDARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_TERTIARY].mKey, m_logos[TYPE_TERTIARY], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_MARKING_01].mKey, m_logos[TYPE_MARKING_01], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataLogoSetTypeChooser[TYPE_MARKING_02].mKey, m_logos[TYPE_MARKING_02], ":jessica-group:Logos", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataBlinkType ); -const Be::ClassInfo* EveSOFDataBlinkType::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataBlinkType::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataBlinkType, "" ) MAP_INTERFACE( EveSOFDataBlinkType ) - MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_BLINK].mKey, m_blinkType[TYPE_BLINK], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_FADE_IN].mKey, m_blinkType[TYPE_FADE_IN], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_FADE_OUT].mKey, m_blinkType[TYPE_FADE_OUT], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_CYCLE].mKey, m_blinkType[TYPE_CYCLE], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_BLINK].mKey, m_blinkType[TYPE_BLINK], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_FADE_IN].mKey, m_blinkType[TYPE_FADE_IN], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_FADE_OUT].mKey, m_blinkType[TYPE_FADE_OUT], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataPlaneSetBlinkTypeChooser[TYPE_CYCLE].mKey, m_blinkType[TYPE_CYCLE], ":jessica-group:Blink", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPatternLayer ); -Be::VarChooser EveSOFDataPatternLayerProjectionTypeChooser[] = - { - { "Repeat", BeCast( EveSOFDataPatternLayer::PROJECTION_REPEAT ), "Repeat pattern texture projection" }, - { "Clamp", BeCast( EveSOFDataPatternLayer::PROJECTION_CLAMP ), "Clamp the projection" }, - { "Border", BeCast( EveSOFDataPatternLayer::PROJECTION_BORDER ), "Border the projection" }, - { 0 } - }; +Be::VarChooser EveSOFDataPatternLayerProjectionTypeChooser[] = { + { "Repeat", BeCast( EveSOFDataPatternLayer::PROJECTION_REPEAT ), "Repeat pattern texture projection" }, + { "Clamp", BeCast( EveSOFDataPatternLayer::PROJECTION_CLAMP ), "Clamp the projection" }, + { "Border", BeCast( EveSOFDataPatternLayer::PROJECTION_BORDER ), "Border the projection" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "EveSOFDataPatternLayerProjectionType", EveSOFDataPatternLayer::ProjectionType, EveSOFDataPatternLayerProjectionTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); @@ -1213,61 +1159,59 @@ const Be::ClassInfo* EveSOFDataPatternLayerProperties::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternLayerProperties, "" ) MAP_INTERFACE( EveSOFDataPatternLayerProperties ) - MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeU", m_projectionTypeU, "Choose the type of texture projection in u direction\n :jessica-group: Projection Direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeV", m_projectionTypeV, "Choose the type of texture projection in v direction\n :jessica-group: Projection Direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) - MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_PRIMARY].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_PRIMARY], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_GLASS].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_GLASS], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_SAILS].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_SAILS], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_REACTOR].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_REACTOR], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_DARKHULL].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_DARKHULL], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_ROCK].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_ROCK], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_MONUMENT].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_MONUMENT], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_ORNAMENT].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_ORNAMENT], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_SIMPLEPRIMARY].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_SIMPLEPRIMARY], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_END() + MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeU", m_projectionTypeU, "Choose the type of texture projection in u direction\n :jessica-group: Projection Direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeV", m_projectionTypeV, "Choose the type of texture projection in v direction\n :jessica-group: Projection Direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) + MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4\n :jessica-group: Materials", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_PRIMARY].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_PRIMARY], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_GLASS].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_GLASS], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_SAILS].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_SAILS], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_REACTOR].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_REACTOR], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_DARKHULL].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_DARKHULL], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_ROCK].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_ROCK], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_MONUMENT].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_MONUMENT], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_ORNAMENT].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_ORNAMENT], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( EveSOFDataAreaTypeChooser[EveSOFDataArea::AreaType::TYPE_SIMPLEPRIMARY].mKey, m_applicableAreas[EveSOFDataArea::AreaType::TYPE_SIMPLEPRIMARY], ":jessica-group: Applicable Areas", Be::READWRITE | Be::PERSIST ) + + EXPOSURE_END() } -Be::VarChooser EveSOFDataPatternLayerMaterialSourceChooser[] = - { - { "Material1", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL1 ), "Base material #1" }, - { "Material2", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL2 ), "Base material #2" }, - { "Material3", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL3 ), "Base material #3" }, - { "Material4", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL4 ), "Base material #4" }, - { "PatternMaterial1", BeCast( EveSOFDataPatternLayer::SOURCE_PATTERN1 ), "Pattern material 1" }, - { "PatternMaterial2", BeCast( EveSOFDataPatternLayer::SOURCE_PATTERN2 ), "Pattern material 2" }, - { 0 } - }; +Be::VarChooser EveSOFDataPatternLayerMaterialSourceChooser[] = { + { "Material1", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL1 ), "Base material #1" }, + { "Material2", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL2 ), "Base material #2" }, + { "Material3", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL3 ), "Base material #3" }, + { "Material4", BeCast( EveSOFDataPatternLayer::SOURCE_MATERIAL4 ), "Base material #4" }, + { "PatternMaterial1", BeCast( EveSOFDataPatternLayer::SOURCE_PATTERN1 ), "Pattern material 1" }, + { "PatternMaterial2", BeCast( EveSOFDataPatternLayer::SOURCE_PATTERN2 ), "Pattern material 2" }, + { 0 } +}; BLUE_REGISTER_ENUM_EX( "EveSOFDataPatternLayerMaterialSource", EveSOFDataPatternLayer::MaterialSource, EveSOFDataPatternLayerMaterialSourceChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::ClassInfo* EveSOFDataPatternLayer::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataPatternLayer::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternLayer, "" ) MAP_INTERFACE( EveSOFDataPatternLayer ) - MAP_ATTRIBUTE( "textureName", m_textureName, "Texture name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "textureResFilePath", m_textureResFilePath, "Texture resfile", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeU", m_projectionTypeU, "Choose the type of texture projection in u direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeV", m_projectionTypeV, "Choose the type of texture projection in v direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "materialSource", m_materialSource, "Choose the material source for the pattern", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerMaterialSourceChooser ) - MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "textureName", m_textureName, "Texture name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "textureResFilePath", m_textureResFilePath, "Texture resfile", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeU", m_projectionTypeU, "Choose the type of texture projection in u direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "projectionTypeV", m_projectionTypeV, "Choose the type of texture projection in v direction", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerProjectionTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "materialSource", m_materialSource, "Choose the material source for the pattern", Be::READWRITE | Be::PERSIST | Be::ENUM, EveSOFDataPatternLayerMaterialSourceChooser ) + MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGeneric ); const Be::ClassInfo* EveSOFDataGeneric::ExposeToBlue() { - EXPOSURE_BEGIN( EveSOFDataGeneric, "" ) - MAP_INTERFACE( EveSOFDataGeneric ) + EXPOSURE_BEGIN( EveSOFDataGeneric, "" ) + MAP_INTERFACE( EveSOFDataGeneric ) MAP_ATTRIBUTE( "resPathDefaultAlliance", m_resPathDefaultAlliance, "The texture for the default alliance logo\n:jessica-group: DefaultTextures\n:jessica-widget: filepath\n:jessica-file-filter: texture", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "resPathDefaultCorp", m_resPathDefaultCorp, "The texture for the default corp logo\n:jessica-group: DefaultTextures\n:jessica-widget: filepath\n:jessica-file-filter: texture", Be::READWRITE | Be::PERSIST ) @@ -1275,7 +1219,7 @@ const Be::ClassInfo* EveSOFDataGeneric::ExposeToBlue() MAP_ATTRIBUTE( "areaShaderLocation", m_areaShaderLocation, "The location of all the area shaders\n:jessica-group: ShaderInfo", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "decalShaderLocation", m_decalShaderLocation, "The location of all the decal shaders\n:jessica-group: ShaderInfo", Be::READWRITE | Be::PERSIST ) -#define MAP_SCREENSIZE( sc ) MAP_ATTRIBUTE( "decalMinScreenSize" # sc, m_decalMinScreenSizes[EveSOFDataHullDecalSetItem::USAGE_##sc], ":jessica-group: Decal Min Screen Size", Be::READWRITE | Be::PERSIST ) +#define MAP_SCREENSIZE( sc ) MAP_ATTRIBUTE( "decalMinScreenSize" #sc, m_decalMinScreenSizes[EveSOFDataHullDecalSetItem::USAGE_##sc], ":jessica-group: Decal Min Screen Size", Be::READWRITE | Be::PERSIST ) MAP_SCREENSIZE( STANDARD ) MAP_SCREENSIZE( KILLCOUNTER ) @@ -1304,5 +1248,5 @@ const Be::ClassInfo* EveSOFDataGeneric::ExposeToBlue() MAP_ATTRIBUTE( "hullCategories", m_hullCategories, "All the hull categories", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "hullCategoriesData", m_hullCategoryData, "New hull categories that contain reflection settings", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue2.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue2.cpp index a05aa176c..bceec5cdc 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue2.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFData_Blue2.cpp @@ -8,27 +8,25 @@ #include "EveSOFData.h" BLUE_DEFINE( EveSOFDataParameter ); -const Be::ClassInfo* EveSOFDataParameter::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataParameter, "" ) - MAP_INTERFACE( EveSOFDataParameter ) +const Be::ClassInfo* EveSOFDataParameter::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataParameter, "" ) + MAP_INTERFACE( EveSOFDataParameter ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFactionHullArea ); -const Be::ClassInfo* EveSOFDataFactionHullArea::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataFactionHullArea, "" ) - MAP_INTERFACE( EveSOFDataFactionHullArea ) +const Be::ClassInfo* EveSOFDataFactionHullArea::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataFactionHullArea, "" ) + MAP_INTERFACE( EveSOFDataFactionHullArea ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } @@ -48,173 +46,162 @@ const Be::ClassInfo* EveSOFDataInstancedMesh::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataInstancedMesh, "" ) MAP_INTERFACE( EveSOFDataInstancedMesh ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "displayModifier", m_displayModifier, "Selects when this instance is shown based on shader quality", Be::READWRITE | Be::PERSIST | Be::ENUM, DisplayFlagModifierChooser ) - MAP_ATTRIBUTE( "geometryResPath", m_geometryResPath, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "instances", m_instances, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "shader", m_shader, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "lowestLodVisible", m_lowestLodVisible, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "displayModifier", m_displayModifier, "Selects when this instance is shown based on shader quality", Be::READWRITE | Be::PERSIST | Be::ENUM, DisplayFlagModifierChooser ) + MAP_ATTRIBUTE( "geometryResPath", m_geometryResPath, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "instances", m_instances, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "shader", m_shader, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFactionChild ); -const Be::ClassInfo* EveSOFDataFactionChild::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataFactionChild, "" ) - MAP_INTERFACE( EveSOFDataFactionChild ) +const Be::ClassInfo* EveSOFDataFactionChild::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataFactionChild, "" ) + MAP_INTERFACE( EveSOFDataFactionChild ) - MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "groupIndex", m_groupIndex, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isVisible", m_isVisible, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullDecalSet ); -const Be::ClassInfo* EveSOFDataHullDecalSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullDecalSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullDecalSet, "" ) MAP_INTERFACE( EveSOFDataHullDecalSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this decalset", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this decalset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataDecalIndexBuffer ); -const Be::ClassInfo* EveSOFDataDecalIndexBuffer::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataDecalIndexBuffer::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataDecalIndexBuffer, "" ) MAP_INTERFACE( EveSOFDataDecalIndexBuffer ) - MAP_INTERFACE( ICustomPersist ) + MAP_INTERFACE( ICustomPersist ) - MAP_METHOD_AND_WRAP( "GetIndices", GetIndices, "Gets the index buffer array" ) - MAP_METHOD_AND_WRAP( "AddIndex", AddIndex, "Add an index to the index buffer" ) - MAP_ATTRIBUTE_AS_CUSTOM_BINARY_BLOCK( "indexBuffer" ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP( "GetIndices", GetIndices, "Gets the index buffer array" ) + MAP_METHOD_AND_WRAP( "AddIndex", AddIndex, "Add an index to the index buffer" ) + MAP_ATTRIBUTE_AS_CUSTOM_BINARY_BLOCK( "indexBuffer" ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullLightSet ); -const Be::ClassInfo* EveSOFDataHullLightSet::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataHullLightSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullLightSet, "" ) MAP_INTERFACE( EveSOFDataHullLightSet ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "items", m_items, "The items in this decalset", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroup", m_visibilityGroup, "Name for visibility group to toggle visibility for the whole set.\n:jessica-widget: visibilitygroup", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "items", m_items, "The items in this decalset", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataLogo ); -const Be::ClassInfo* EveSOFDataLogo::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataLogo::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataLogo, "" ) MAP_INTERFACE( EveSOFDataLogo ) - MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "textures", m_textures, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataBlink ); -const Be::ClassInfo* EveSOFDataBlink::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataBlink::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataBlink, "" ) MAP_INTERFACE( EveSOFDataBlink ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataFaction ); -const Be::ClassInfo* EveSOFDataFaction::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataFaction, "" ) - MAP_INTERFACE( EveSOFDataFaction ) - - MAP_ATTRIBUTE( "name", m_name, "The faction name, eg sarum. This functions as an ID.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "description", m_description, "A description string. NOT used by the SOF, it's just for debugging purposes.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "resPathInsert", m_resPathInsert, "Insert string to build texture res path.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "areaTypes", m_areaTypes, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "colorSet", m_colorSet, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "logoSet", m_logoSet, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "spotlightSets", m_spotlightSets, "All the groups of spotlight sets.", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "planeSets", m_planeSets, "All the groups of plane sets.", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "children", m_children, "All the groups of children.", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "visibilityGroupSet", m_visibilityGroupSet, "All visibility groups enabled on this faction.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "materialUsageMtl1", m_materialUsageMtl1, "Material usage of Mtl1\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "materialUsageMtl2", m_materialUsageMtl2, "Material usage of Mtl2\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "materialUsageMtl3", m_materialUsageMtl3, "Material usage of Mtl3\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "materialUsageMtl4", m_materialUsageMtl4, "Material usage of Mtl4\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultPattern", m_defaultPattern, "The default pattern data for this faction\n:jessica-group: DefaultPattern", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultPatternLayer1MaterialName", m_defaultPatternLayer1MaterialName, "The default pattern material name for this faction and layer 1\n:jessica-group: DefaultPattern\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultPatternLayer2MaterialName", m_defaultPatternLayer2MaterialName, "The default pattern material name for this faction and layer 2\n:jessica-group: DefaultPattern\n:jessica-sub-group: WIP \n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultPatternName", m_defaultPatternName, "The default pattern used for this faction \n:jessica-widget: patternpicker \n:jessica-group: DefaultPattern\n:jessica-sub-group: WIP", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() +const Be::ClassInfo* EveSOFDataFaction::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataFaction, "" ) + MAP_INTERFACE( EveSOFDataFaction ) + + MAP_ATTRIBUTE( "name", m_name, "The faction name, eg sarum. This functions as an ID.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "description", m_description, "A description string. NOT used by the SOF, it's just for debugging purposes.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "resPathInsert", m_resPathInsert, "Insert string to build texture res path.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "areaTypes", m_areaTypes, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "colorSet", m_colorSet, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "logoSet", m_logoSet, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "spotlightSets", m_spotlightSets, "All the groups of spotlight sets.", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "planeSets", m_planeSets, "All the groups of plane sets.", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "children", m_children, "All the groups of children.", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "visibilityGroupSet", m_visibilityGroupSet, "All visibility groups enabled on this faction.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "materialUsageMtl1", m_materialUsageMtl1, "Material usage of Mtl1\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "materialUsageMtl2", m_materialUsageMtl2, "Material usage of Mtl2\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "materialUsageMtl3", m_materialUsageMtl3, "Material usage of Mtl3\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "materialUsageMtl4", m_materialUsageMtl4, "Material usage of Mtl4\n:jessica-group: MaterialUsage", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultPattern", m_defaultPattern, "The default pattern data for this faction\n:jessica-group: DefaultPattern", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultPatternLayer1MaterialName", m_defaultPatternLayer1MaterialName, "The default pattern material name for this faction and layer 1\n:jessica-group: DefaultPattern\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultPatternLayer2MaterialName", m_defaultPatternLayer2MaterialName, "The default pattern material name for this faction and layer 2\n:jessica-group: DefaultPattern\n:jessica-sub-group: WIP \n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultPatternName", m_defaultPatternName, "The default pattern used for this faction \n:jessica-widget: patternpicker \n:jessica-group: DefaultPattern\n:jessica-sub-group: WIP", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataRace ); -const Be::ClassInfo* EveSOFDataRace::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataRace, "" ) - MAP_INTERFACE( EveSOFDataRace ) +const Be::ClassInfo* EveSOFDataRace::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataRace, "" ) + MAP_INTERFACE( EveSOFDataRace ) - MAP_ATTRIBUTE( "name", m_name, "The race name, eg caldari. This functions as an ID.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "booster", m_booster, "All the booster data for this race.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "hullPrimaryHeatColorType", m_hullPrimaryHeatColorType, "Per race heat (booster) color for primary hulls", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( "hullReactorHeatColorType", m_hullReactorHeatColorType, "Per race heat (booster) color for reactor hulls", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_ATTRIBUTE( "damage", m_damage, "Pre race damage system data", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The race name, eg caldari. This functions as an ID.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "booster", m_booster, "All the booster data for this race.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "hullPrimaryHeatColorType", m_hullPrimaryHeatColorType, "Per race heat (booster) color for primary hulls", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "hullReactorHeatColorType", m_hullReactorHeatColorType, "Per race heat (booster) color for reactor hulls", Be::READWRITE | Be::PERSIST | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_ATTRIBUTE( "damage", m_damage, "Pre race damage system data", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataMaterial ); -const Be::ClassInfo* EveSOFDataMaterial::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataMaterial, "" ) - MAP_INTERFACE( EveSOFDataMaterial ) +const Be::ClassInfo* EveSOFDataMaterial::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataMaterial, "" ) + MAP_INTERFACE( EveSOFDataMaterial ) - MAP_ATTRIBUTE( "name", m_name, "The material name. This functions as an ID.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "All the material parameters.", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The material name. This functions as an ID.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "All the material parameters.", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPattern ); -const Be::ClassInfo* EveSOFDataPattern::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataPattern::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPattern, "" ) MAP_INTERFACE( EveSOFDataPattern ) - MAP_ATTRIBUTE( "sof6", m_sof6, "Used with SOF6", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "name", m_name, "The pattern name. This functions as an ID.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer1", m_layer1, "Pattern data for layer #1.", Be::READWRITE | Be::PERSIST) - MAP_ATTRIBUTE( "layer2", m_layer2, "Pattern data for layer #2.", Be::READWRITE | Be::PERSIST) - MAP_ATTRIBUTE( "projections", m_projections, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "applicationGroups", m_applicationGroups, "Groups that define how the pattern is applied to its hulls", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "sof6", m_sof6, "Used with SOF6", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "The pattern name. This functions as an ID.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer1", m_layer1, "Pattern data for layer #1.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer2", m_layer2, "Pattern data for layer #2.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "projections", m_projections, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "applicationGroups", m_applicationGroups, "Groups that define how the pattern is applied to its hulls", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPatternTransform ); -const Be::ClassInfo* EveSOFDataPatternTransform::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataPatternTransform::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternTransform, "" ) MAP_INTERFACE( EveSOFDataPatternTransform ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isMirrored", m_isMirrored, "This pattern is mirrored across all this ship's hull.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isMirrored", m_isMirrored, "This pattern is mirrored across all this ship's hull.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPatternMaterialOverride ); @@ -222,12 +209,12 @@ const Be::ClassInfo* EveSOFDataPatternMaterialOverride::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternMaterialOverride, "" ) MAP_INTERFACE( EveSOFDataPatternMaterialOverride ) - MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl1", m_isTargetMtl1, "This pattern goes onto material 1", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl2", m_isTargetMtl2, "This pattern goes onto material 2", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl3", m_isTargetMtl3, "This pattern goes onto material 3", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTargetMtl4", m_isTargetMtl4, "This pattern goes onto material 4", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPatternApplicationGroup ); @@ -235,24 +222,23 @@ const Be::ClassInfo* EveSOFDataPatternApplicationGroup::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternApplicationGroup, "" ) MAP_INTERFACE( EveSOFDataPatternApplicationGroup ) - MAP_ATTRIBUTE( "name", m_name, "The name of the group", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer1Properties", m_layer1Properties, "Properties for layer 1 to define how to apply the layer to the hulls", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layer2Properties", m_layer2Properties, "Properties for layer 2 to define how to apply the layer to the hulls", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "projections", m_projections, "The projections for different hulls", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "The name of the group", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer1Properties", m_layer1Properties, "Properties for layer 1 to define how to apply the layer to the hulls", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layer2Properties", m_layer2Properties, "Properties for layer 2 to define how to apply the layer to the hulls", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "projections", m_projections, "The projections for different hulls", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataPatternPerHull ); -const Be::ClassInfo* EveSOFDataPatternPerHull::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataPatternPerHull::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataPatternPerHull, "" ) MAP_INTERFACE( EveSOFDataPatternPerHull ) - MAP_ATTRIBUTE( "name", m_name, "The exact hull name. This functions as an ID.\n:jessica-widget: hullpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "transformLayer1", m_transformLayer1, "Pattern projection transform for layer #1.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "transformLayer2", m_transformLayer2, "Pattern projection transform for layer #2.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The exact hull name. This functions as an ID.\n:jessica-widget: hullpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transformLayer1", m_transformLayer1, "Pattern projection transform for layer #1.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transformLayer2", m_transformLayer2, "Pattern projection transform for layer #2.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE_INTERFACE( IEveSOFDataHullExtensionPlacement ); @@ -261,45 +247,45 @@ BLUE_DEFINE( EveSOFDataHullExtensionPlacement ); const Be::ClassInfo* EveSOFDataHullExtensionPlacement::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacement, ":jessica-icon:far-folder" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacement ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacement ) - MAP_ATTRIBUTE( "name", m_name, "The name of the placement", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "enabled", m_enabled, "Mostly for use during Authoring to prevent loading segments while working on others", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "The name of the locatorset to distribute the extension", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "offset", m_offset, "The offset of the extension (", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "distribution", m_distribution, "The distribution of the extensions. If empty, the extension are distributed to every locator", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "distributionConditions", m_distributionConditions, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "descriptor", m_descriptor, "The dna descriptor of the extension", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isInstanced", m_isInstanced, "is the mesh instanced? instanced meshes cannot be animated", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isShared", m_isShared, "is the instanced mesh shared? only relevant if isInstanced. shared instances are rendered as a single draw call for the entire scene", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "extendsBoundingSphere", m_extendsBoundingSphere, "If true then it will grow the boundingsphere of the parent", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "extendsShieldEllipsoid", m_extendsShieldEllipsoid, "If true then it will grow the shield ellipsoid of the parent", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacement ) + MAP_ATTRIBUTE( "name", m_name, "The name of the placement", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "enabled", m_enabled, "Mostly for use during Authoring to prevent loading segments while working on others", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "locatorSetName", m_locatorSetName, "The name of the locatorset to distribute the extension", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "offset", m_offset, "The offset of the extension (", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "distribution", m_distribution, "The distribution of the extensions. If empty, the extension are distributed to every locator", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "distributionConditions", m_distributionConditions, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "descriptor", m_descriptor, "The dna descriptor of the extension", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isInstanced", m_isInstanced, "is the mesh instanced? instanced meshes cannot be animated", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isShared", m_isShared, "is the instanced mesh shared? only relevant if isInstanced. shared instances are rendered as a single draw call for the entire scene", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "extendsBoundingSphere", m_extendsBoundingSphere, "If true then it will grow the boundingsphere of the parent", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "extendsShieldEllipsoid", m_extendsShieldEllipsoid, "If true then it will grow the shield ellipsoid of the parent", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullExtensionPlacementGroup ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementGroup::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementGroup, ":jessica-icon:far-folder-tree" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementGroup ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacement ) - MAP_ATTRIBUTE( "name", m_name, "The name of the placement", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "enabled", m_enabled, "Mostly for use during Authoring to prevent loading segments while working on others", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "placements", m_placements, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "distributionConditions", m_distributionConditions, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacement ) + MAP_ATTRIBUTE( "name", m_name, "The name of the placement", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "enabled", m_enabled, "Mostly for use during Authoring to prevent loading segments while working on others", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "placements", m_placements, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "distributionConditions", m_distributionConditions, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataLayout ); const Be::ClassInfo* EveSOFDataLayout::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataLayout, "" ) MAP_INTERFACE( EveSOFDataLayout ) - MAP_ATTRIBUTE( "name", m_name, "The name of the layout", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "seed", m_seed, "used in all random processing for the placements", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomizeSeedOnLoad", m_randomizeSeedOnLoad, "this will non-proceduraly scramble the seed on load", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "placements", m_placements, "The placements of the layout", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "The name of the layout", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "seed", m_seed, "used in all random processing for the placements", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomizeSeedOnLoad", m_randomizeSeedOnLoad, "this will non-proceduraly scramble the seed on load", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "placements", m_placements, "The placements of the layout", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } @@ -307,10 +293,10 @@ BLUE_DEFINE( EveSOFDataHullExtensionBucket ); const Be::ClassInfo* EveSOFDataHullExtensionBucket::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionBucket, "" ) MAP_INTERFACE( EveSOFDataHullExtensionBucket ) - MAP_ATTRIBUTE( "name", m_name, "The name of the layout", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "placements", m_placements, "The placements of the layout", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The name of the layout", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "placements", m_placements, "The placements of the layout", Be::READ | Be::PERSIST ) + EXPOSURE_END() } @@ -318,9 +304,9 @@ BLUE_DEFINE( EveSOFDataDistributionDepletionCounter ); const Be::ClassInfo* EveSOFDataDistributionDepletionCounter::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataDistributionDepletionCounter, ":jessica-icon:far-cookie" ) MAP_INTERFACE( EveSOFDataDistributionDepletionCounter ) - MAP_ATTRIBUTE( "name", m_name, "The name the counter to Add or subtract from", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The name the counter to Add or subtract from", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ); @@ -329,87 +315,85 @@ BLUE_DEFINE( EveSOFDataHullExtensionPlacementDistributionParentMatch ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementDistributionParentMatch::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementDistributionParentMatch, ":jessica-icon:far-child" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementDistributionParentMatch ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) - MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parentDescriptor", m_parentDescriptor, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) + MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parentDescriptor", m_parentDescriptor, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullExtensionPlacementDistributionDepletionCounter ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementDistributionDepletionCounter::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementDistributionDepletionCounter, ":jessica-icon:far-cookie-bite" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementDistributionDepletionCounter ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) - MAP_ATTRIBUTE( "name", m_name, "The name the counter to Add or subtract from", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) + MAP_ATTRIBUTE( "name", m_name, "The name the counter to Add or subtract from", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "depletionCounters", m_depletionCounters, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullExtensionPlacementDistributionRandomChance ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementDistributionRandomChance::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementDistributionRandomChance, ":jessica-icon:far-dice" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementDistributionRandomChance ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) - MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "chanceOfUsage", m_chanceOfUsage, "[0:1], 1 = 100%", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) + MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "chanceOfUsage", m_chanceOfUsage, "[0:1], 1 = 100%", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings, ":jessica-icon:far-gear" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementDistributionMapGraphicSettings ) - MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) - MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "displayFilter", m_displayFilter, "Selects when this instance is picked based on shader quality", Be::READWRITE | Be::PERSIST | Be::ENUM, DisplayFlagModifierChooser ) - EXPOSURE_END() + MAP_INTERFACE( IEveSOFDataHullExtensionPlacementDistribution ) + MAP_ATTRIBUTE( "name", m_name, "The name of the distribution", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "displayFilter", m_displayFilter, "Selects when this instance is picked based on shader quality", Be::READWRITE | Be::PERSIST | Be::ENUM, DisplayFlagModifierChooser ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataHullExtensionPlacementDistributionPlacement ); const Be::ClassInfo* EveSOFDataHullExtensionPlacementDistributionPlacement::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataHullExtensionPlacementDistributionPlacement, "ParentMatch\n:jessica-icon-color: (123, 28, 212)\n:jessica-icon:far-slot-machine" ) MAP_INTERFACE( EveSOFDataHullExtensionPlacementDistributionPlacement ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "completeness", m_completeness, "chance per locator of being utilized, 0.5=50%", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "placementBias", m_placementBias, "Vector to direct the spread of placements towards a direction", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "centerBias", m_centerBias, "0=doesn't care, -1=prioritizes edges, 1=starts from center", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "cap", m_cap, "cap on how many locators this distribution can utilize (0=uncapped)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomRotationStepSizeYPR", m_randomRotationStepSizeYPR, "step size for randomizing rotations, (yaw, pitch, roll) in degrees (90 = quarter circle)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomRotationMaxSteps", m_randomRotationMaxSteps, "max number of times the above stepSize can be added per locator", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomScaleMin", m_randomScaleMin, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "randomScaleMax", m_randomScaleMax, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "uniformScale", m_uniformScale, "when toggled the random value is on the linear axis between min and max", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "occupyLocators", m_occupyLocators, "when toggled the placement will reserve locator from other layouts", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "completeness", m_completeness, "chance per locator of being utilized, 0.5=50%", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "placementBias", m_placementBias, "Vector to direct the spread of placements towards a direction", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "centerBias", m_centerBias, "0=doesn't care, -1=prioritizes edges, 1=starts from center", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "cap", m_cap, "cap on how many locators this distribution can utilize (0=uncapped)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomRotationStepSizeYPR", m_randomRotationStepSizeYPR, "step size for randomizing rotations, (yaw, pitch, roll) in degrees (90 = quarter circle)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomRotationMaxSteps", m_randomRotationMaxSteps, "max number of times the above stepSize can be added per locator", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomScaleMin", m_randomScaleMin, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "randomScaleMax", m_randomScaleMax, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "uniformScale", m_uniformScale, "when toggled the random value is on the linear axis between min and max", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "occupyLocators", m_occupyLocators, "when toggled the placement will reserve locator from other layouts", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFDNADescriptor ); -const Be::ClassInfo* EveSOFDNADescriptor::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDNADescriptor::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDNADescriptor, ":jessica-icon:far-dna" ) MAP_INTERFACE( EveSOFDNADescriptor ) - MAP_ATTRIBUTE( "hull", m_hull, "The hull extension of the dna (only hulls with buildclass BUILDCLASS_EXTENSION are permitted)\n:jessica-widget: hullextensionpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "faction", m_faction, "The faction of the dna\n:jessica-widget: factionpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "race", m_race, "The race of the dna\n:jessica-widget: racepicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "layout", m_layout, "The layout of the dna\n:jessica-widget: layoutpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "pattern", m_pattern, "The pattern of the dna\n:jessica-widget: patternpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material1", m_material1, "The 1. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material2", m_material2, "The 2. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material3", m_material3, "The 3. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material4", m_material4, "The 4. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "hull", m_hull, "The hull extension of the dna (only hulls with buildclass BUILDCLASS_EXTENSION are permitted)\n:jessica-widget: hullextensionpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "faction", m_faction, "The faction of the dna\n:jessica-widget: factionpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "race", m_race, "The race of the dna\n:jessica-widget: racepicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "layout", m_layout, "The layout of the dna\n:jessica-widget: layoutpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "pattern", m_pattern, "The pattern of the dna\n:jessica-widget: patternpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material1", m_material1, "The 1. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material2", m_material2, "The 2. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material3", m_material3, "The 3. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material4", m_material4, "The 4. material of the dna\n:jessica-widget: materialpicker", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericString ); -const Be::ClassInfo* EveSOFDataGenericString::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataGenericString, "" ) - MAP_INTERFACE( EveSOFDataGenericString ) +const Be::ClassInfo* EveSOFDataGenericString::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataGenericString, "" ) + MAP_INTERFACE( EveSOFDataGenericString ) - MAP_ATTRIBUTE( "str", m_str, "The actual string", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "str", m_str, "The actual string", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataVisibilityGroup ); @@ -417,144 +401,138 @@ const Be::ClassInfo* EveSOFDataVisibilityGroup::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataVisibilityGroup, "" ) MAP_INTERFACE( EveSOFDataVisibilityGroup ) - MAP_ATTRIBUTE( "name", m_name, "The name of the visibilty group", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "description", m_description, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The name of the visibilty group", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "description", m_description, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericDamage ); -const Be::ClassInfo* EveSOFDataGenericDamage::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataGenericDamage::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericDamage, "" ) MAP_INTERFACE( EveSOFDataGenericDamage ) - MAP_ATTRIBUTE( "flickerPerlinSpeed", m_flickerPerlinSpeed, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "flickerPerlinAlpha", m_flickerPerlinAlpha, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "flickerPerlinBeta", m_flickerPerlinBeta, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "flickerPerlinN", m_flickerPerlinN, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleRate", m_armorParticleRate, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleAngle", m_armorParticleAngle, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleMinMaxSpeed", m_armorParticleMinMaxSpeed, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleMinMaxLifeTime", m_armorParticleMinMaxLifeTime, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleSizes", m_armorParticleSizes, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleColor0", m_armorParticleColor0, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleColor1", m_armorParticleColor1, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleColor2", m_armorParticleColor2, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleColor3", m_armorParticleColor3, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleTextureIndex", m_armorParticleTextureIndex, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleVelocityStretchRotation", m_armorParticleVelocityStretchRotation, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleDrag", m_armorParticleDrag, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleTurbulenceAmplitude", m_armorParticleTurbulenceAmplitude, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleTurbulenceFrequency", m_armorParticleTurbulenceFrequency, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorParticleColorMidPoint", m_armorParticleColorMidPoint, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "armorShader", m_armorShader, "Shader for armor damage", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shieldShaderEllipsoid", m_shieldShaderEllipsoid, "Shader for elliptical shield impact", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shieldShaderHull", m_shieldShaderHull, "Shader for hull shield impact", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shieldGeometryResFilePath", m_shieldGeometryResFilePath, "Geometry for shield impact", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "flickerPerlinSpeed", m_flickerPerlinSpeed, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "flickerPerlinAlpha", m_flickerPerlinAlpha, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "flickerPerlinBeta", m_flickerPerlinBeta, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "flickerPerlinN", m_flickerPerlinN, "Hull damage perlin noise flicker speed", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleRate", m_armorParticleRate, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleAngle", m_armorParticleAngle, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleMinMaxSpeed", m_armorParticleMinMaxSpeed, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleMinMaxLifeTime", m_armorParticleMinMaxLifeTime, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleSizes", m_armorParticleSizes, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleColor0", m_armorParticleColor0, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleColor1", m_armorParticleColor1, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleColor2", m_armorParticleColor2, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleColor3", m_armorParticleColor3, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleTextureIndex", m_armorParticleTextureIndex, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleVelocityStretchRotation", m_armorParticleVelocityStretchRotation, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleDrag", m_armorParticleDrag, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleTurbulenceAmplitude", m_armorParticleTurbulenceAmplitude, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleTurbulenceFrequency", m_armorParticleTurbulenceFrequency, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorParticleColorMidPoint", m_armorParticleColorMidPoint, "Armor damage impacte particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "armorShader", m_armorShader, "Shader for armor damage", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shieldShaderEllipsoid", m_shieldShaderEllipsoid, "Shader for elliptical shield impact", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shieldShaderHull", m_shieldShaderHull, "Shader for hull shield impact", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shieldGeometryResFilePath", m_shieldGeometryResFilePath, "Geometry for shield impact", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericHullDamage ); -const Be::ClassInfo* EveSOFDataGenericHullDamage::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataGenericHullDamage::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericHullDamage, "" ) MAP_INTERFACE( EveSOFDataGenericHullDamage ) - MAP_ATTRIBUTE( "hullParticleRate", m_hullParticleRate, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleAngle", m_hullParticleAngle, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleColorMidpoint", m_hullParticleColorMidpoint, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleInnerAngle", m_hullParticleInnerAngle, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleMinMaxSpeed", m_hullParticleMinMaxSpeed, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleMinMaxLifeTime", m_hullParticleMinMaxLifeTime, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleSizes", m_hullParticleSizes, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleColor0", m_hullParticleColor0, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleColor1", m_hullParticleColor1, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleColor2", m_hullParticleColor2, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleColor3", m_hullParticleColor3, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleTextureIndex", m_hullParticleTextureIndex, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleVelocityStretchRotation", m_hullParticleVelocityStretchRotation, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleDrag", m_hullParticleDrag, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleTurbulenceAmplitude", m_hullParticleTurbulenceAmplitude, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullParticleTurbulenceFrequency", m_hullParticleTurbulenceFrequency, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "hullParticleRate", m_hullParticleRate, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleAngle", m_hullParticleAngle, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleColorMidpoint", m_hullParticleColorMidpoint, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleInnerAngle", m_hullParticleInnerAngle, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleMinMaxSpeed", m_hullParticleMinMaxSpeed, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleMinMaxLifeTime", m_hullParticleMinMaxLifeTime, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleSizes", m_hullParticleSizes, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleColor0", m_hullParticleColor0, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleColor1", m_hullParticleColor1, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleColor2", m_hullParticleColor2, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleColor3", m_hullParticleColor3, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleTextureIndex", m_hullParticleTextureIndex, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleVelocityStretchRotation", m_hullParticleVelocityStretchRotation, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleDrag", m_hullParticleDrag, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleTurbulenceAmplitude", m_hullParticleTurbulenceAmplitude, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullParticleTurbulenceFrequency", m_hullParticleTurbulenceFrequency, "hull damage impact particlesystem data", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericSwarm ); -const Be::ClassInfo* EveSOFDataGenericSwarm::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataGenericSwarm::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericSwarm, "" ) MAP_INTERFACE( EveSOFDataGenericSwarm ) - MAP_ATTRIBUTE( "speedMultiplier", m_behavior.m_speedMultiplier, "Max swarmer speed = shipSpeed*speedMultiplier+speedMinimum", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "speedMinimum", m_behavior.m_speedMinimum, "Max swarmer speed = shipSpeed*speedMultiplier+speedMinimum", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxDistance0", m_behavior.m_maxDistance0, "Max allowed distance from world position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxDistance1", m_behavior.m_maxDistance1, "Max allowed distance from world position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxTime", m_behavior.m_maxTime, "Maximum time for simulation per update", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "speed0", m_behavior.m_speed0, "Lower speed limit for max distance", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "speed1", m_behavior.m_speed1, "Upper speed limit for max distance", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightFormation", m_behavior.m_weightFormation, "Weight of triangle formation", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightCohesion", m_behavior.m_weightCohesion, "Cohesion weight, steer swarmers to center of mass", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightSeparation", m_behavior.m_weightSeparation, "Weight of steering away from nearby swarmers", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightAlign", m_behavior.m_weightAlign, "This should be in newtons, based of average direction of swarmers", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightWander", m_behavior.m_weightWander, "Weight of wandering behavior", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightAnchor", m_behavior.m_weightAnchor, "Weight of the force steering swarmers to the world position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "anchorRadius0", m_behavior.m_anchorRadius0, "Anchor force reaches zero here", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "anchorRadius1", m_behavior.m_anchorRadius1, "Anchor force is at maximum beyond this distance", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "weightDeceleration", m_behavior.m_weightDecelerate, "Weight of deceleration(multiplied with current velocity)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxDeceleration", m_behavior.m_maxDeceleration, "Maximum amount of deceleration in newtons", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "separationDistance", m_behavior.m_separationDistance, "Distance for separation", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "formationDistance", m_behavior.m_formationDistance, "Distance formation", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( "wanderFluctuation", m_behavior.m_wanderFluctuation, "Defines how fast wander target point on projected sphere fluctuates", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "wanderDistance", m_behavior.m_wanderDistance, "Distance of projected sphere in front of swarmers", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "wanderRadius", m_behavior.m_wanderRadius, "Radius of the projected sphere", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "speedMultiplier", m_behavior.m_speedMultiplier, "Max swarmer speed = shipSpeed*speedMultiplier+speedMinimum", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "speedMinimum", m_behavior.m_speedMinimum, "Max swarmer speed = shipSpeed*speedMultiplier+speedMinimum", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxDistance0", m_behavior.m_maxDistance0, "Max allowed distance from world position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxDistance1", m_behavior.m_maxDistance1, "Max allowed distance from world position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxTime", m_behavior.m_maxTime, "Maximum time for simulation per update", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "speed0", m_behavior.m_speed0, "Lower speed limit for max distance", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "speed1", m_behavior.m_speed1, "Upper speed limit for max distance", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightFormation", m_behavior.m_weightFormation, "Weight of triangle formation", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightCohesion", m_behavior.m_weightCohesion, "Cohesion weight, steer swarmers to center of mass", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightSeparation", m_behavior.m_weightSeparation, "Weight of steering away from nearby swarmers", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightAlign", m_behavior.m_weightAlign, "This should be in newtons, based of average direction of swarmers", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightWander", m_behavior.m_weightWander, "Weight of wandering behavior", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightAnchor", m_behavior.m_weightAnchor, "Weight of the force steering swarmers to the world position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "anchorRadius0", m_behavior.m_anchorRadius0, "Anchor force reaches zero here", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "anchorRadius1", m_behavior.m_anchorRadius1, "Anchor force is at maximum beyond this distance", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "weightDeceleration", m_behavior.m_weightDecelerate, "Weight of deceleration(multiplied with current velocity)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxDeceleration", m_behavior.m_maxDeceleration, "Maximum amount of deceleration in newtons", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "separationDistance", m_behavior.m_separationDistance, "Distance for separation", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "formationDistance", m_behavior.m_formationDistance, "Distance formation", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "wanderFluctuation", m_behavior.m_wanderFluctuation, "Defines how fast wander target point on projected sphere fluctuates", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "wanderDistance", m_behavior.m_wanderDistance, "Distance of projected sphere in front of swarmers", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "wanderRadius", m_behavior.m_wanderRadius, "Radius of the projected sphere", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericShader ); -const Be::ClassInfo* EveSOFDataGenericShader::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveSOFDataGenericShader, "" ) - MAP_INTERFACE( EveSOFDataGenericShader ) +const Be::ClassInfo* EveSOFDataGenericShader::ExposeToBlue(){ + EXPOSURE_BEGIN( EveSOFDataGenericShader, "" ) + MAP_INTERFACE( EveSOFDataGenericShader ) - MAP_ATTRIBUTE( "shader", m_shader, "The actual shader", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "transparencyTextureName", m_transparencyTextureName, "Some shaders have transparency maps.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "doGenerateDepthArea", m_doGenerateDepthArea, "Some shaders need an accompanying depth area.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "Complete list of all parameters for this shader", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultTextures", m_defaultTextures, "Default (global) textures for this shader", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultParameters", m_defaultParameters, "Default (global) parameters for this shader", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "shader", m_shader, "The actual shader", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transparencyTextureName", m_transparencyTextureName, "Some shaders have transparency maps.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "doGenerateDepthArea", m_doGenerateDepthArea, "Some shaders need an accompanying depth area.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "Complete list of all parameters for this shader", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultTextures", m_defaultTextures, "Default (global) textures for this shader", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultParameters", m_defaultParameters, "Default (global) parameters for this shader", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericDecalShader ); -const Be::ClassInfo* EveSOFDataGenericDecalShader::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataGenericDecalShader::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericDecalShader, "" ) MAP_INTERFACE( EveSOFDataGenericDecalShader ) - MAP_ATTRIBUTE( "shader", m_shader, "The actual shader", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parameters", m_parameters, "Complete list of all parameters for this shader", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "defaultTextures", m_defaultTextures, "Default (global) textures for this shader", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "parentTextures", m_parentTextures, "Parent textures from the hull", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( "additive", m_additive, "Render decals with this shader during the additive pass rather than the decal pass to make sure they are rendered on top of any other decals", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "shader", m_shader, "The actual shader", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parameters", m_parameters, "Complete list of all parameters for this shader", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "defaultTextures", m_defaultTextures, "Default (global) textures for this shader", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "parentTextures", m_parentTextures, "Parent textures from the hull", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "additive", m_additive, "Render decals with this shader during the additive pass rather than the decal pass to make sure they are rendered on top of any other decals", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericVariant ); -const Be::ClassInfo* EveSOFDataGenericVariant::ExposeToBlue() -{ +const Be::ClassInfo* EveSOFDataGenericVariant::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericVariant, "" ) MAP_INTERFACE( EveSOFDataGenericVariant ) - MAP_ATTRIBUTE( "name", m_name, "Variant name", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isTransparent", m_isTransparent, "What area does it go into", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "hullArea", m_hullArea, "The actual hull area data", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "Variant name", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isTransparent", m_isTransparent, "What area does it go into", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "hullArea", m_hullArea, "The actual hull area data", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveSOFDataGenericHullCategory ); @@ -562,18 +540,18 @@ const Be::ClassInfo* EveSOFDataGenericHullCategory::ExposeToBlue(){ EXPOSURE_BEGIN( EveSOFDataGenericHullCategory, "" ) MAP_INTERFACE( EveSOFDataGenericHullCategory ) - MAP_ATTRIBUTE( "name", m_categoryName, "The hull category", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When this hull category is rendered in the cubemap", Be::READWRITE | Be::PERSIST | Be::ENUM, EntityComponents::ReflectionModeChooser ) + MAP_ATTRIBUTE( "name", m_categoryName, "The hull category", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "reflectionMode", m_reflectionMode, "When this hull category is rendered in the cubemap", Be::READWRITE | Be::PERSIST | Be::ENUM, EntityComponents::ReflectionModeChooser ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveSOFData ); const Be::ClassInfo* EveSOFData::ExposeToBlue() { - EXPOSURE_BEGIN( EveSOFData, "" ) - MAP_INTERFACE( EveSOFData ) + EXPOSURE_BEGIN( EveSOFData, "" ) + MAP_INTERFACE( EveSOFData ) MAP_ATTRIBUTE( "generic", m_generic, "All the generic data we have in EVE", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "hull", m_hull, "All the hull data we have in EVE", Be::READ | Be::PERSIST ) diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFUtils.cpp b/trinity/Eve/SpaceObjectFactory/EveSOFUtils.cpp index fb02eef70..3e49bc0f1 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFUtils.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOFUtils.cpp @@ -9,14 +9,15 @@ // Description: // Initialize data members and do all initial analyzing // -------------------------------------------------------------------------------- -EveSOFUtilsParameterName::EveSOFUtilsParameterName( const std::vector& prefixes, const char* parameterName ) : m_fullname( parameterName ), m_materialIdx( -1 ) +EveSOFUtilsParameterName::EveSOFUtilsParameterName( const std::vector& prefixes, const char* parameterName ) : + m_fullname( parameterName ), m_materialIdx( -1 ) { // try to find the material prefix and with that indentify the index for( size_t i = 0; i < prefixes.size(); ++i ) { if( StringStartsWithI( m_fullname.c_str(), prefixes[i].c_str() ) ) { - m_materialIdx = int32_t(i); + m_materialIdx = int32_t( i ); m_shortname = parameterName + prefixes[i].length(); return; } @@ -99,7 +100,7 @@ void EveSOFUtils::GeneratePatternProjectionData( EveSOFDataMgr::PatternProjectio // Description: // Fill structs from other structs // -------------------------------------------------------------------------------- -void EveSOFUtils::GeneratePatternLayerData( EveSOFDataMgr::PatternLayerData* pld, const EveSOFDataPatternLayer* patternLayer, const EveSOFDataPatternLayerProperties* patternProperties ) +void EveSOFUtils::GeneratePatternLayerData( EveSOFDataMgr::PatternLayerData* pld, const EveSOFDataPatternLayer* patternLayer, const EveSOFDataPatternLayerProperties* patternProperties ) { if( patternLayer ) { @@ -110,12 +111,12 @@ void EveSOFUtils::GeneratePatternLayerData( EveSOFDataMgr::PatternLayerData* pld if( patternProperties ) { // projection types, translate to AL enums right here - pld->projectionAddressModeU = GetTextureAddressMode( (EveSOFDataPatternLayer::ProjectionType) patternProperties->m_projectionTypeU ); - pld->projectionAddressModeV = GetTextureAddressMode( (EveSOFDataPatternLayer::ProjectionType) patternProperties->m_projectionTypeV ); - + pld->projectionAddressModeU = GetTextureAddressMode( (EveSOFDataPatternLayer::ProjectionType)patternProperties->m_projectionTypeU ); + pld->projectionAddressModeV = GetTextureAddressMode( (EveSOFDataPatternLayer::ProjectionType)patternProperties->m_projectionTypeV ); + // material targets are bools, but need to be stored as floats (for shader) pld->materialTargets = CreateMaterialApplicationVector( patternProperties->m_isTargetMtl1, patternProperties->m_isTargetMtl2, patternProperties->m_isTargetMtl3, patternProperties->m_isTargetMtl4 ); - + for( int i = 0; i < EveSOFDataArea::AreaType::TYPE_MAX; i++ ) { pld->applicableAreas[(EveSOFDataArea::AreaType)i] = patternProperties->m_applicableAreas[i]; @@ -128,11 +129,9 @@ void EveSOFUtils::GeneratePatternLayerData( EveSOFDataMgr::PatternLayerData* pld pld->projectionAddressModeV = GetTextureAddressMode( patternLayer->m_projectionTypeV ); // material targets are bools, but need to be stored as floats (for shader) pld->materialTargets = CreateMaterialApplicationVector( patternLayer->m_isTargetMtl1, patternLayer->m_isTargetMtl2, patternLayer->m_isTargetMtl3, patternLayer->m_isTargetMtl4 ); - } // material source id can be directly transltaed from enum pld->materialSourceID = (uint8_t)patternLayer->m_materialSource; - } else { @@ -204,7 +203,7 @@ const Vector4* EveSOFUtils::SearchForParameterData( const EveSOFDataMgr* dataMgr auto finder = areaMaterialData->glowColor.find( k ); if( finder != areaMaterialData->glowColor.end() ) { - SOFDataFactionColorChooser::ColorType glowColorType = finder->second; + SOFDataFactionColorChooser::ColorType glowColorType = finder->second; return (const Vector4*)&colorSet[glowColorType]; } } @@ -217,5 +216,3 @@ const Vector4* EveSOFUtils::SearchForParameterData( const EveSOFDataMgr* dataMgr return nullptr; } - - diff --git a/trinity/Eve/SpaceObjectFactory/EveSOFUtils.h b/trinity/Eve/SpaceObjectFactory/EveSOFUtils.h index 1e53ae1b4..f44a0fd44 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOFUtils.h +++ b/trinity/Eve/SpaceObjectFactory/EveSOFUtils.h @@ -26,7 +26,7 @@ class EveSOFUtilsParameterName // substitute void ChangeMaterialIdx( const EveSOFDataMgr::GenericData* genericData, int32_t idx ); - + private: // direct copy of the original name std::string m_fullname; diff --git a/trinity/Eve/SpaceObjectFactory/EveSOF_Blue.cpp b/trinity/Eve/SpaceObjectFactory/EveSOF_Blue.cpp index f98983dcf..ca0387049 100644 --- a/trinity/Eve/SpaceObjectFactory/EveSOF_Blue.cpp +++ b/trinity/Eve/SpaceObjectFactory/EveSOF_Blue.cpp @@ -9,49 +9,44 @@ BLUE_DEFINE( EveSOF ); const Be::ClassInfo* EveSOF::ExposeToBlue() { - EXPOSURE_BEGIN( EveSOF, "" ) - MAP_INTERFACE( EveSOF ) + EXPOSURE_BEGIN( EveSOF, "" ) + MAP_INTERFACE( EveSOF ) MAP_ATTRIBUTE( "dataMgr", m_dataMgr, "Holds all the source data to the ships", Be::READ ) MAP_ATTRIBUTE( "allowFileCaching", m_allowFileCaching, "Allow caching of \"file exists\" queries in SOF for better performance", Be::READWRITE ) MAP_ATTRIBUTE( "editorMode", m_editorMode, "When enabled some features will operate differently for the benefit of those editing sof data.", Be::READWRITE ) - MAP_METHOD_AND_WRAP( - "Build", - Build, + MAP_METHOD_AND_WRAP( + "Build", + Build, "Builds a space object\n" ":param hullName: hull name\n" ":param factionName: faction name\n" - ":param raceName: race name\n" - ) - MAP_METHOD_AND_WRAP( - "BuildFromDNA", - BuildFromDNA, + ":param raceName: race name\n" ) + MAP_METHOD_AND_WRAP( + "BuildFromDNA", + BuildFromDNA, "Builds a space object from the given DNA\n" - ":param dna: space object DNA" - ) - MAP_METHOD_AND_WRAP( - "ValidateDNA", - ValidateDNA, + ":param dna: space object DNA" ) + MAP_METHOD_AND_WRAP( + "ValidateDNA", + ValidateDNA, "Validates the content of a given DNA string. This is slow and should only be used for offline validation!\n" - ":param dna: space object DNA" - ) + ":param dna: space object DNA" ) - MAP_METHOD_AND_WRAP( - "SetupTurretMaterialFromDNA", - SetupTurretMaterialFromDNA, + MAP_METHOD_AND_WRAP( + "SetupTurretMaterialFromDNA", + SetupTurretMaterialFromDNA, "Change the material of the turret with SOF data\n" ":param turretSet: turret set that will be modified\n" - ":param dna: DNA of the owner space object" - ) - MAP_METHOD_AND_WRAP( - "SetupTurretMaterialFromFaction", - SetupTurretMaterialFromFaction, + ":param dna: DNA of the owner space object" ) + MAP_METHOD_AND_WRAP( + "SetupTurretMaterialFromFaction", + SetupTurretMaterialFromFaction, "Change the material of the turret according to the faction in SOF\n" ":param turretSet: turret set that will be modified\n" - ":param faction: faction name" - ) + ":param faction: faction name" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Eve/Turret/EveTurretFiringFX.cpp b/trinity/Eve/Turret/EveTurretFiringFX.cpp index 3faf70c8a..4da0ad848 100644 --- a/trinity/Eve/Turret/EveTurretFiringFX.cpp +++ b/trinity/Eve/Turret/EveTurretFiringFX.cpp @@ -18,7 +18,7 @@ const std::wstring AUDIO_IMPACT_SWITCH_HULL = L"Hull"; namespace { - const float LOD_ANGLE_FACTOR = 0.002f; +const float LOD_ANGLE_FACTOR = 0.002f; } // -------------------------------------------------------------------------------- @@ -70,8 +70,8 @@ EveTurretFiringFX::~EveTurretFiringFX() void EveTurretFiringFX::CleanUp() { // shut down the firing effect and send the stop_play - StopFiring(); - // Kick the curves so any sound change will trigger (playing -> stop) + StopFiring(); + // Kick the curves so any sound change will trigger (playing -> stop) EveUpdateContext ctx( BeOS->GetCurrentFrameTime() ); UpdateAsynchronous( ctx ); UpdateSynchronous( ctx ); @@ -82,8 +82,8 @@ void EveTurretFiringFX::CleanUp() // If loading from a .red file, everything is read now // -------------------------------------------------------------------------------- bool EveTurretFiringFX::Initialize() -{ - if( m_firingDurationOverride >= 0.0f ) +{ + if( m_firingDurationOverride >= 0.0f ) { m_firingDuration = m_firingDurationOverride; } @@ -119,7 +119,7 @@ void EveTurretFiringFX::SetMuzzleBoneID( int muzzleID, unsigned int boneID ) // sanity check if( muzzleID >= 0 && muzzleID < MUZZLECOUNT_MAX ) { - m_perMuzzleData[ muzzleID ].muzzlePositionBoneID = boneID; + m_perMuzzleData[muzzleID].muzzlePositionBoneID = boneID; } } @@ -135,7 +135,7 @@ void EveTurretFiringFX::SetMuzzleTransform( int muzzleID, const Matrix* transfor // sanity check if( muzzleID >= 0 && muzzleID < MUZZLECOUNT_MAX ) { - m_perMuzzleData[ muzzleID ].muzzleTransform = *transform; + m_perMuzzleData[muzzleID].muzzleTransform = *transform; } } @@ -159,23 +159,23 @@ void EveTurretFiringFX::SetEndPosition( const Vector3* endPos ) // -------------------------------------------------------------------------------- void EveTurretFiringFX::SetScaleByRadius( float radius ) { - if ( !m_scaleEffectTarget ) + if( !m_scaleEffectTarget ) { return; } // The scale is a linear scale from min scale to max scale when radius is within min and max radius. Other values get clamped. float scale = ( radius - m_minRadius ) * ( m_maxScale - m_minScale ) / ( m_maxRadius - m_minRadius ) + m_minScale; - scale = max( m_minScale, min( m_maxScale, scale) ); + scale = max( m_minScale, min( m_maxScale, scale ) ); - for ( auto it = m_stretch.begin(); it != m_stretch.end(); it++ ) + for( auto it = m_stretch.begin(); it != m_stretch.end(); it++ ) { - (*it)->SetDestObjectScale( scale ); + ( *it )->SetDestObjectScale( scale ); } - if ( m_destinationObserver != nullptr ) + if( m_destinationObserver != nullptr ) { - if ( ITr2AudEmitterPtr emitter = BlueCastPtr( m_destinationObserver->GetObserver() ) ) + if( ITr2AudEmitterPtr emitter = BlueCastPtr( m_destinationObserver->GetObserver() ) ) { emitter->SetAttenuationScalingFactor( radius ); } @@ -294,7 +294,7 @@ void EveTurretFiringFX::PrepareFiring( float delay, unsigned int muzzleID, unsig if( prevFiring != m_isFiring ) { - ReRegister(); + ReRegister(); } } @@ -308,7 +308,7 @@ float EveTurretFiringFX::GetCurveDuration() // check all stretch effects and see if we have to start them for( unsigned int i = 0; i < m_stretch.size(); ++i ) { - auto stretchEffect = m_stretch[ i ]; + auto stretchEffect = m_stretch[i]; maxDuration = std::max( maxDuration, stretchEffect->GetCurveDuration() ); } return maxDuration; @@ -331,9 +331,9 @@ bool EveTurretFiringFX::GetStartPosition( Vector3& pos ) const uint32_t cntr = 0; for( size_t i = 0; i < m_stretch.size(); ++i ) { - if( m_perMuzzleData[ i ].started ) + if( m_perMuzzleData[i].started ) { - p += m_perMuzzleData[ i ].muzzleTransform.GetTranslation(); + p += m_perMuzzleData[i].muzzleTransform.GetTranslation(); ++cntr; } } @@ -386,7 +386,7 @@ const char* EveTurretFiringFX::GetFiringBoneName() const void EveTurretFiringFX::StartMuzzleEffect( int muzzleID ) { // fire! - auto stretchEffect = m_stretch[ muzzleID ]; + auto stretchEffect = m_stretch[muzzleID]; auto delay = m_perMuzzleData[muzzleID].currentStartDelay; stretchEffect->StartFiring( delay ); if( m_startCurveSet ) @@ -399,8 +399,8 @@ void EveTurretFiringFX::StartMuzzleEffect( int muzzleID ) } // set this effect to started - m_perMuzzleData[ muzzleID ].started = true; - m_perMuzzleData[ muzzleID ].readyToStart = false; + m_perMuzzleData[muzzleID].started = true; + m_perMuzzleData[muzzleID].readyToStart = false; } // -------------------------------------------------------------------------------- @@ -418,15 +418,14 @@ void EveTurretFiringFX::StopFiring() for( unsigned int m = 0; m < m_stretch.size(); ++m ) { // get the running effect - auto stretchEffect = m_stretch[ m ]; + auto stretchEffect = m_stretch[m]; stretchEffect->StopFiring(); // set this effect to ended - m_perMuzzleData[ m ].started = false; - m_perMuzzleData[ m ].readyToStart = false; - m_perMuzzleData[ m ].currentStartDelay = 0.f; - m_perMuzzleData[ m ].elapsedTime = 0.f; - + m_perMuzzleData[m].started = false; + m_perMuzzleData[m].readyToStart = false; + m_perMuzzleData[m].currentStartDelay = 0.f; + m_perMuzzleData[m].elapsedTime = 0.f; } if( m_startCurveSet ) @@ -452,7 +451,7 @@ bool EveTurretFiringFX::ReadyToFire() const { if( m_perMuzzleData[i].elapsedTime < m_firingDuration || m_isLoopFiring ) { - if( !m_perMuzzleData[i].started && m_perMuzzleData[i].readyToStart) + if( !m_perMuzzleData[i].started && m_perMuzzleData[i].readyToStart ) { return true; } @@ -479,7 +478,7 @@ bool EveTurretFiringFX::UpdateAsynchronous( const EveUpdateContext& updateContex { float deltaT = updateContext.GetDeltaT(); bool retVal = false; - + // check all stretch effects and see if we have to start them for( unsigned int i = 0; i < m_stretch.size(); ++i ) { @@ -498,7 +497,7 @@ bool EveTurretFiringFX::UpdateAsynchronous( const EveUpdateContext& updateContex // cannot start firing effect directly when entering FIRE state, cause they might have a delay... if( !m_perMuzzleData[i].started ) { - + if( m_perMuzzleData[i].readyToStart ) { // play two parts of the firing effect @@ -569,14 +568,14 @@ bool EveTurretFiringFX::UpdateAsynchronous( const EveUpdateContext& updateContex return retVal; } -bool EveTurretFiringFX::UpdateSynchronous( const EveUpdateContext &updateContext ) +bool EveTurretFiringFX::UpdateSynchronous( const EveUpdateContext& updateContext ) { // check all stretch effects and see if we have to start or stop them for( unsigned int i = 0; i < m_stretch.size(); ++i ) - { + { if( m_perMuzzleData[i].elapsedTime < m_firingDuration || m_isLoopFiring ) { - auto stretchEffect = m_stretch[i]; + auto stretchEffect = m_stretch[i]; stretchEffect->UpdateEffectSync( updateContext ); } } @@ -597,7 +596,7 @@ void EveTurretFiringFX::UpdateVisibility( const EveUpdateContext& updateContext { if( m_perMuzzleData[i].started ) { - if ( m_firingDuration >= m_perMuzzleData[i].elapsedTime || m_isLoopFiring ) + if( m_firingDuration >= m_perMuzzleData[i].elapsedTime || m_isLoopFiring ) { m_stretch[i]->UpdateVisibility( updateContext, m ); } @@ -689,7 +688,7 @@ void EveTurretFiringFX::GetRenderables( std::vector& renderable { if( m_perMuzzleData[i].started ) { - if ( m_firingDuration >= m_perMuzzleData[i].elapsedTime || m_isLoopFiring ) + if( m_firingDuration >= m_perMuzzleData[i].elapsedTime || m_isLoopFiring ) { m_stretch[i]->GetRenderables( renderables ); } @@ -719,7 +718,7 @@ unsigned int EveTurretFiringFX::GetPerMuzzleBoneID( int muzzleID ) const // sanity check if( muzzleID >= 0 && muzzleID < MUZZLECOUNT_MAX ) { - return m_perMuzzleData[ muzzleID ].muzzlePositionBoneID; + return m_perMuzzleData[muzzleID].muzzlePositionBoneID; } // error return INVALID_TURRET_INDEX; @@ -796,12 +795,11 @@ void EveTurretFiringFX::SetControllerVariable( const char* name, float value ) for( auto it = m_stretch.begin(); it != m_stretch.end(); ++it ) { ITr2ControllerOwnerPtr co; - if( ( *it )->QueryInterface( BlueInterfaceIID(), ( void** )&co, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)&co, BEQI_SILENT ) ) { co->SetControllerVariable( name, value ); } } - } void EveTurretFiringFX::HandleControllerEvent( const char* name ) @@ -809,7 +807,7 @@ void EveTurretFiringFX::HandleControllerEvent( const char* name ) for( auto it = m_stretch.begin(); it != m_stretch.end(); ++it ) { ITr2ControllerOwnerPtr co; - if( ( *it )->QueryInterface( BlueInterfaceIID(), ( void** )&co, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)&co, BEQI_SILENT ) ) { co->HandleControllerEvent( name ); } @@ -821,7 +819,7 @@ void EveTurretFiringFX::HandleControllerEvent( const char* name ) // Set the impact configuration of the target's impact overlay effect and handle setting values on the target's // audio emitter based off of the given impact configuration. // Arguments: -// impactConfiguration - The impact configuration state of the current target. +// impactConfiguration - The impact configuration state of the current target. // -------------------------------------------------------------------------------- void EveTurretFiringFX::SetImpactConfiguration( ITriTargetable::ImpactConfiguration impactConfiguration ) { @@ -831,7 +829,7 @@ void EveTurretFiringFX::SetImpactConfiguration( ITriTargetable::ImpactConfigurat { if( auto destAudioEmitter = dynamic_cast( m_destinationObserver->GetObserver() ) ) { - switch ( impactConfiguration ) + switch( impactConfiguration ) { case ITriTargetable::ImpactConfiguration::IMPACT_ARMOR: destAudioEmitter->SetSwitch( AUDIO_IMPACT_SWITCH_GROUP, AUDIO_IMPACT_SWITCH_ARMOR ); @@ -854,14 +852,14 @@ void EveTurretFiringFX::StartControllers() for( auto it = m_stretch.begin(); it != m_stretch.end(); ++it ) { ITr2ControllerOwnerPtr co; - if( ( *it )->QueryInterface( BlueInterfaceIID(), ( void** )&co, BEQI_SILENT ) ) + if( ( *it )->QueryInterface( BlueInterfaceIID(), (void**)&co, BEQI_SILENT ) ) { co->StartControllers(); } } } -void EveTurretFiringFX::GetDebugOptions( Tr2DebugRendererOptions& options ) +void EveTurretFiringFX::GetDebugOptions( Tr2DebugRendererOptions& options ) { for( auto stretch : m_stretch ) { @@ -882,7 +880,7 @@ void EveTurretFiringFX::GetDebugOptions( Tr2DebugRendererOptions& options ) } } -void EveTurretFiringFX::RenderDebugInfo( ITr2DebugRenderer2& renderer ) +void EveTurretFiringFX::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { for( auto stretch : m_stretch ) { diff --git a/trinity/Eve/Turret/EveTurretFiringFX.h b/trinity/Eve/Turret/EveTurretFiringFX.h index d7947864b..016359445 100644 --- a/trinity/Eve/Turret/EveTurretFiringFX.h +++ b/trinity/Eve/Turret/EveTurretFiringFX.h @@ -30,13 +30,12 @@ class Tr2LightManager; // SeeAlso: // EveStretch // -------------------------------------------------------------------------------- -class EveTurretFiringFX : - public IInitialize, - public INotify, - public IListNotify, - public ITr2ControllerOwner, - public ITr2DebugRenderable, - public EveEntity +class EveTurretFiringFX : public IInitialize, + public INotify, + public IListNotify, + public ITr2ControllerOwner, + public ITr2DebugRenderable, + public EveEntity { public: EXPOSE_TO_BLUE(); @@ -44,20 +43,20 @@ class EveTurretFiringFX : using IInitialize::Unlock; using IInitialize::Lock; - EveTurretFiringFX(IRoot* lockobj = NULL); + EveTurretFiringFX( IRoot* lockobj = NULL ); ~EveTurretFiringFX(); - + void CleanUp(); ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ////////////////////////////////////////////////////////////////////////// // INotify bool OnModified( Be::Var* val ); - + ////////////////////////////////////////////////////////////////////////// // IListNotify virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* list ); @@ -117,10 +116,22 @@ class EveTurretFiringFX : void StopFiring(); // toggle display of source and dest objects of the stretcher - void SetDisplayDestObject( bool display ) { m_displayDestObject = display; } - bool GetDisplayDestObject() const { return m_displayDestObject; } - void SetDisplaySourceObject( bool display ) { m_displaySourceObject = display; } - bool GetDisplaySourceObject() const { return m_displaySourceObject; } + void SetDisplayDestObject( bool display ) + { + m_displayDestObject = display; + } + bool GetDisplayDestObject() const + { + return m_displayDestObject; + } + void SetDisplaySourceObject( bool display ) + { + m_displaySourceObject = display; + } + bool GetDisplaySourceObject() const + { + return m_displaySourceObject; + } virtual void RegisterComponents() override; virtual void UnRegisterComponents() override; @@ -170,7 +181,7 @@ class EveTurretFiringFX : // to-be-attached to bone name BlueSharedString m_boneName; - // firing effect data (is of fixed length, so there is a max muzzle count per turret!) + // firing effect data (is of fixed length, so there is a max muzzle count per turret!) struct PerMuzzleData { // state of the effect diff --git a/trinity/Eve/Turret/EveTurretFiringFX_Blue.cpp b/trinity/Eve/Turret/EveTurretFiringFX_Blue.cpp index 25c942964..14633dbd7 100644 --- a/trinity/Eve/Turret/EveTurretFiringFX_Blue.cpp +++ b/trinity/Eve/Turret/EveTurretFiringFX_Blue.cpp @@ -10,13 +10,13 @@ BLUE_DEFINE( EveTurretFiringFX ); const Be::ClassInfo* EveTurretFiringFX::ExposeToBlue() { EXPOSURE_BEGIN( EveTurretFiringFX, "" ) - MAP_INTERFACE( EveTurretFiringFX ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( IListNotify ) - MAP_INTERFACE( ITr2ControllerOwner ) - MAP_INTERFACE( EveEntity ) - + MAP_INTERFACE( EveTurretFiringFX ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( IListNotify ) + MAP_INTERFACE( ITr2ControllerOwner ) + MAP_INTERFACE( EveEntity ) + MAP_ATTRIBUTE( "name", m_name, "A name for this firing effect", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Toggle rendering", Be::READWRITE | Be::NOTIFY ) @@ -46,7 +46,7 @@ const Be::ClassInfo* EveTurretFiringFX::ExposeToBlue() MAP_ATTRIBUTE( "stretch", m_stretch, "A list of stretch effects for this firing effect", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "endPosition", m_endPosition, "Destination or end position", Be::READWRITE ) - + MAP_ATTRIBUTE( "scaleEffectTarget", m_scaleEffectTarget, "Toggle whether the firing effect target object is scaled by the target object", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minRadius", m_minRadius, "Used for scaling the firing effect", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxRadius", m_maxRadius, "Used for scaling the firing effect", Be::READWRITE | Be::PERSIST ) @@ -55,20 +55,16 @@ const Be::ClassInfo* EveTurretFiringFX::ExposeToBlue() MAP_ATTRIBUTE( "startCurveSet", m_startCurveSet, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "stopCurveSet", m_stopCurveSet, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "sourceObserver", m_sourceObserver, "Observer at the source position", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationObserver", m_destinationObserver, "Observer at the destination position", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "GetPerMuzzleEffectCount", @@ -77,6 +73,3 @@ const Be::ClassInfo* EveTurretFiringFX::ExposeToBlue() EXPOSURE_END() } - - - diff --git a/trinity/Eve/Turret/EveTurretSet.cpp b/trinity/Eve/Turret/EveTurretSet.cpp index 4f6adfcf4..87efc0812 100644 --- a/trinity/Eve/Turret/EveTurretSet.cpp +++ b/trinity/Eve/Turret/EveTurretSet.cpp @@ -55,13 +55,13 @@ const float TRACKING_FADE_TIME = 1.f; namespace { - bool IsUsingCMF( TriGeometryRes* geometryResource ) - { - // The only reason the null pointer check is here, is to be able to call IsUsingCMF. - // Do not rely on this function to test for geometryResource's existance in other places! - // This function will be removed in the future, alongside all granny code. - return !geometryResource || !geometryResource->IsGood() || geometryResource->IsUsingCMF(); - } +bool IsUsingCMF( TriGeometryRes* geometryResource ) +{ + // The only reason the null pointer check is here, is to be able to call IsUsingCMF. + // Do not rely on this function to test for geometryResource's existance in other places! + // This function will be removed in the future, alongside all granny code. + return !geometryResource || !geometryResource->IsGood() || geometryResource->IsUsingCMF(); +} } @@ -196,7 +196,8 @@ bool EveTurretSet::Initialize() // -------------------------------------------------------------------------------- bool EveTurretSet::OnModified( Be::Var* value ) { - if( IsMatch( value, m_display ) ) { + if( IsMatch( value, m_display ) ) + { ReRegister(); } else if( IsMatch( value, m_geomResPath ) ) @@ -506,7 +507,7 @@ void EveTurretSet::Cleanup() turret.pose.skeleton = nullptr; turret.worldTransforms.clear(); } - + #if WITH_GRANNY // granny invalid m_grnModel = NULL; @@ -1081,7 +1082,7 @@ void EveTurretSet::RebuildCachedData( BlueAsyncRes* p ) } InitializeAnimation(); - + // animation already requested in a queue? if( !m_animationQueue.empty() ) { @@ -1481,7 +1482,7 @@ void EveTurretSet::UpdateAsyncronous( const EveUpdateContext& updateContext, con } UpdateSingleTurrets(); - + // setup and update attached firing effect if( m_firingEffect ) { @@ -1733,63 +1734,58 @@ void EveTurretSet::ModifySystemBoneTransform( SystemBones bone, const Vector3* t break; case SYSBONE_ROTATION: case SYSBONE_ROTATION01: - case SYSBONE_ROTATION02: - { - // rotation of turret 360 degress, alpha is between -pi and pi - float alpha = atan2( target->x, target->z ); - // never forget do apply influence! - alpha *= m_trackingInfluence; - // 1st: make quaternion - Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); - // 2nd: apply this quat after the original one - quat = rotation * quat; - // 3rd: make granny_transform from quat - rotation = quat; - } - break; - case SYSBONE_COUNTER_ROTATION: - { - // inverse(!!) rotation of turret 360 degress, alpha is between -pi and pi - float alpha = -1.f * atan2( target->x, target->z ); - // never forget do apply influence! - alpha *= m_trackingInfluence; - // 1st: make quaternion - Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); - // 2nd: apply this quat after the original one - quat = rotation * quat; - // 3rd: make granny_transform from quat - rotation = quat; - } - break; + case SYSBONE_ROTATION02: { + // rotation of turret 360 degress, alpha is between -pi and pi + float alpha = atan2( target->x, target->z ); + // never forget do apply influence! + alpha *= m_trackingInfluence; + // 1st: make quaternion + Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); + // 2nd: apply this quat after the original one + quat = rotation * quat; + // 3rd: make granny_transform from quat + rotation = quat; + } + break; + case SYSBONE_COUNTER_ROTATION: { + // inverse(!!) rotation of turret 360 degress, alpha is between -pi and pi + float alpha = -1.f * atan2( target->x, target->z ); + // never forget do apply influence! + alpha *= m_trackingInfluence; + // 1st: make quaternion + Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); + // 2nd: apply this quat after the original one + quat = rotation * quat; + // 3rd: make granny_transform from quat + rotation = quat; + } + break; case SYSBONE_PITCH: case SYSBONE_PITCH1: - case SYSBONE_PITCH2: - { - CalcTransformForPitchBone( target, XMConvertToRadians( m_sysBonePitchMin ), XMConvertToRadians( m_sysBonePitchMax ), bone, localTransform, rotation ); - } - break; - case SYSBONE_SCALED_HEIGHT: - { - // pitch of barrel 90 degrees - Vector3 dirNrm = Normalize( *target ); - float height = TriClamp( dirNrm.y, 0.f, 1.f ); - // never forget do apply influence! - height *= m_trackingInfluence; - // it's a pos extension with a scale - Vector3 pos = Vector3( 0.f, height * m_sysBoneHeight, 0.f ) + position; - position = pos; - } - break; + case SYSBONE_PITCH2: { + CalcTransformForPitchBone( target, XMConvertToRadians( m_sysBonePitchMin ), XMConvertToRadians( m_sysBonePitchMax ), bone, localTransform, rotation ); + } + break; + case SYSBONE_SCALED_HEIGHT: { + // pitch of barrel 90 degrees + Vector3 dirNrm = Normalize( *target ); + float height = TriClamp( dirNrm.y, 0.f, 1.f ); + // never forget do apply influence! + height *= m_trackingInfluence; + // it's a pos extension with a scale + Vector3 pos = Vector3( 0.f, height * m_sysBoneHeight, 0.f ) + position; + position = pos; + } + break; case SYSBONE_SCALED_PITCH01: case SYSBONE_SCALED_PITCH02: case SYSBONE_SCALED_PITCH03: case SYSBONE_SCALED_PITCH04: case SYSBONE_SCALED_PITCH05: - case SYSBONE_SCALED_PITCH06: - { - CalcTransformForPitchBone( target, 0.f, XMConvertToRadians( m_sysBonePitchMax ), bone, nullptr, rotation ); - } - break; + case SYSBONE_SCALED_PITCH06: { + CalcTransformForPitchBone( target, 0.f, XMConvertToRadians( m_sysBonePitchMax ), bone, nullptr, rotation ); + } + break; default: break; } @@ -2025,7 +2021,7 @@ int EveTurretSet::GetState() const // -------------------------------------------------------------------------------- bool EveTurretSet::IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const { - if( !m_display || !m_geometryResource) + if( !m_display || !m_geometryResource ) { return false; } @@ -2205,11 +2201,11 @@ void EveTurretSet::GetBatches( ITriRenderBatchAccumulator* batches, batch.SetMaterial( m_turretEffect ); batch.SetGeometry( m_vertexDeclHandle, lod->m_vertexAllocation, m_instanceBuffer, lod->m_indexAllocation ); batch.SetPerObjectData( perObjectData ); - batch.SetDrawIndexedInstanced( - lod->m_primitiveCount * 3, - m_visibleCount, - lod->m_indexAllocation.GetStartIndex(), - lod->m_vertexAllocation.GetOffset() / lod->m_vertexAllocation.GetStride(), + batch.SetDrawIndexedInstanced( + lod->m_primitiveCount * 3, + m_visibleCount, + lod->m_indexAllocation.GetStartIndex(), + lod->m_vertexAllocation.GetOffset() / lod->m_vertexAllocation.GetStride(), m_instanceBuffer.GetOffset() / m_instanceBuffer.GetStride() ); if( batch ) @@ -2535,7 +2531,7 @@ void EveTurretSet::PushRtGeometry( Tr2RaytracingManager& rtManager ) const USE_MAIN_THREAD_RENDER_CONTEXT(); - + for( auto it = m_singleTurrets.begin(); it != m_singleTurrets.end(); ++it ) { if( it->visible && it->valid && it->rtMesh && it->rtMesh->IsGood() && it->rtMeshArea ) @@ -2614,7 +2610,7 @@ float EveTurretSet::PlayAnimation( unsigned int turretIndex, const std::string& size_t animIx = cmfData->animations.size(); if( !animName.empty() ) { - auto animation = std::find_if( cmfData->animations.begin(), cmfData->animations.end(), [&animName]( const cmf::Animation& anim ) { + auto animation = std::find_if( cmfData->animations.begin(), cmfData->animations.end(), [&animName]( const cmf::Animation& anim ) { return cmf::ToStdStringView( anim.name ) == animName; } ); if( animation == cmfData->animations.end() ) @@ -2784,8 +2780,7 @@ void EveTurretSet::StopAnimation( unsigned int turretIndex, float delay ) { if( m_singleTurrets[turretIndex].sequencer ) { - m_singleTurrets[turretIndex].sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_singleTurrets[turretIndex].sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { player->SetStopTime( delay + Tr2Renderer::GetAnimationTime() ); } ); diff --git a/trinity/Eve/Turret/EveTurretSet.h b/trinity/Eve/Turret/EveTurretSet.h index a97edd909..baa640760 100644 --- a/trinity/Eve/Turret/EveTurretSet.h +++ b/trinity/Eve/Turret/EveTurretSet.h @@ -44,24 +44,26 @@ const unsigned int EVE_MAX_TURRETS_PER_SET = 24; // maximum time offset for turret firing const float EVE_TURRET_RANDOM_DELAY_MAX = 0.6f; -struct EveTurretSetVSData { - Vector4 m_baseCutoffData; - Vector4 m_turretSetData; - Matrix m_shipMatrix; +struct EveTurretSetVSData +{ + Vector4 m_baseCutoffData; + Vector4 m_turretSetData; + Matrix m_shipMatrix; Matrix m_prevShipMatrix; uint32_t m_currentBoneOffset; uint32_t m_prevBoneOffset; uint32_t _unused[2]; - // per turret data - Vector4 m_turretTranslation[EVE_MAX_TURRETS_PER_SET]; - Quaternion m_turretRotation[EVE_MAX_TURRETS_PER_SET]; + // per turret data + Vector4 m_turretTranslation[EVE_MAX_TURRETS_PER_SET]; + Quaternion m_turretRotation[EVE_MAX_TURRETS_PER_SET]; }; -struct EveTurretSetPSData { - Vector4 m_shipData; - Vector4 m_clipData1; +struct EveTurretSetPSData +{ + Vector4 m_shipData; + Vector4 m_clipData1; float m_clipRadius2Sq; Vector3 m_unused; Vector4 m_shLightingCoefficients[Tr2ShLightingManager::PACKED_COEFFICIENT_COUNT]; @@ -80,10 +82,10 @@ class EveTurretSetPerObjectData : public Tr2PerObjectData void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override; // vs per object data - EveTurretSetVSData m_vsData; + EveTurretSetVSData m_vsData; // pixel shader per object data - EveTurretSetPSData m_psData; + EveTurretSetPSData m_psData; }; // -------------------------------------------------------------------------------- @@ -96,7 +98,7 @@ class EveTurretSetPerObjectData : public Tr2PerObjectData // SeeAlso: // EveShip2 // -------------------------------------------------------------------------------- -BLUE_CLASS( EveTurretSet ): +BLUE_CLASS( EveTurretSet ) : public IInitialize, public INotify, public IBlueAsyncResNotifyTarget, @@ -114,28 +116,28 @@ BLUE_CLASS( EveTurretSet ): using IInitialize::Unlock; using IInitialize::Lock; - explicit EveTurretSet(IRoot* lockobj = nullptr); + explicit EveTurretSet( IRoot* lockobj = nullptr ); ~EveTurretSet(); ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize() override; - + ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable bool HasTransparentBatches() override; - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; float GetSortValue() override; - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) override; + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ) override; ///////////////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ) override; - void RebuildCachedData( BlueAsyncRes* p ) override; + void ReleaseCachedData( BlueAsyncRes * p ) override; + void RebuildCachedData( BlueAsyncRes * p ) override; ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource @@ -146,12 +148,12 @@ BLUE_CLASS( EveTurretSet ): void SetControllerVariable( const char* name, float value ); void HandleControllerEvent( const char* name ); void StartControllers(); - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; - + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; + ////////////////////////////////////////////////////////////////////////////////////// // EveEntity void RegisterComponents() override; @@ -160,8 +162,8 @@ BLUE_CLASS( EveTurretSet ): ////////////////////////////////////////////////////////////////////////////////////// // IEveShadowCaster bool IsCastingShadow( const TriFrustum& cameraFrustum, const IEveShadowFrustum& shadowFrustum, Tr2RenderReason renderReason, float& sizeInShadow ) const override; - void GetShadowBatches( ITriRenderBatchAccumulator* batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize ) override; - Tr2PerObjectData* GetShadowPerObjectData( ITriRenderBatchAccumulator* accumulator ) override; + void GetShadowBatches( ITriRenderBatchAccumulator * batches, const Tr2PerObjectData* perObjectData, float shadowPixelSize ) override; + Tr2PerObjectData* GetShadowPerObjectData( ITriRenderBatchAccumulator * accumulator ) override; void PushRtGeometry( Tr2RaytracingManager & rtManager ) const override; int GetState() const; @@ -172,7 +174,7 @@ BLUE_CLASS( EveTurretSet ): public: // set local position void SetLocalTransform( unsigned int turretIndex, const Matrix* localMatrix ); - void UpdateTurretTransforms(const Matrix* parentWorldMatrix); + void UpdateTurretTransforms( const Matrix* parentWorldMatrix ); // timing and worldspace positioning void UpdateSyncronous( const EveUpdateContext& updateContext, const Matrix* parentMatrix ); @@ -180,8 +182,8 @@ BLUE_CLASS( EveTurretSet ): // rendering void UpdateVisibility( const EveUpdateContext& updateContext ); - void GetRenderables( std::vector& renderables, const Vector4* shLighting ); - + void GetRenderables( std::vector & renderables, const Vector4* shLighting ); + // rebuild the bounding sphere size void RebuildBoundingSphere(); // disable LODing @@ -206,9 +208,12 @@ BLUE_CLASS( EveTurretSet ): // get locator names const char* GetLocatorName() const; int GetSlotNumber() const; - unsigned int GetSwarmID() const { return m_swarmID; } + unsigned int GetSwarmID() const + { + return m_swarmID; + } - bool GetLocalBoundingBox( Vector3& aabbMin, Vector3& aabbMax ); + bool GetLocalBoundingBox( Vector3 & aabbMin, Vector3 & aabbMax ); // get worldmatrix of the currently firing bone Matrix GetFiringBoneWorldTransform( unsigned int muzzle ) const; @@ -216,12 +221,15 @@ BLUE_CLASS( EveTurretSet ): // missed shots void SetShotMissed( bool missed ); double GetLastShotTime() const; - float GetShotTimeVariance() const { return EVE_TURRET_RANDOM_DELAY_MAX; } + float GetShotTimeVariance() const + { + return EVE_TURRET_RANDOM_DELAY_MAX; + } size_t MissQueueSize() const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) override; - - void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + + void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); // turret LOD @@ -244,8 +252,8 @@ BLUE_CLASS( EveTurretSet ): STATE_FIRING, STATE_RELOADING, }; + private: - // system-controlled bones enum SystemBones { @@ -295,9 +303,9 @@ BLUE_CLASS( EveTurretSet ): void CalcTransformForPitchBone( const Vector3* target, float minPitch, float maxPitch, unsigned int boneIndex, const Matrix* localTransform, Quaternion& rotation ) const; // Returns the correct pitch factor for a specific bone index - float GetBonePitchFactor(unsigned int boneIndex) const; + float GetBonePitchFactor( unsigned int boneIndex ) const; // Returns the correct pitch offset for a specific bone index - float GetBonePitchOffset(unsigned int boneIndex) const; + float GetBonePitchOffset( unsigned int boneIndex ) const; // animation float PlayAnimation( unsigned int turretIndex, const std::string& animName, const std::string& animNameIdle, float delay = 0.f ); @@ -313,10 +321,10 @@ BLUE_CLASS( EveTurretSet ): void UpdateRtSkeleton(); EveTurretFiringFX* GetFiringEffect(); - void SetFiringEffect( EveTurretFiringFX* firingEffect ); + void SetFiringEffect( EveTurretFiringFX * firingEffect ); IEveSpaceObjectChild* GetAmbientEffect(); - void SetAmbientEffect( IEveSpaceObjectChild* ambientEffect ); + void SetAmbientEffect( IEveSpaceObjectChild * ambientEffect ); // name std::string m_name; @@ -347,24 +355,24 @@ BLUE_CLASS( EveTurretSet ): // keep a vector of data on each pair of the turret struct SingleTurretData { - bool valid; - bool visible; + bool valid; + bool visible; // positions - Vector4 localPosition; - Quaternion localQuaternion; - Matrix localMatrix; - Matrix worldMatrix; + Vector4 localPosition; + Quaternion localQuaternion; + Matrix localMatrix; + Matrix worldMatrix; // animation #if WITH_GRANNY - granny_skeleton* grnSkeleton = nullptr; - granny_model_instance* grnModelInstance = nullptr; - granny_local_pose* grnLocalPose = nullptr; - granny_world_pose* grnWorldPose = nullptr; + granny_skeleton* grnSkeleton = nullptr; + granny_model_instance* grnModelInstance = nullptr; + granny_local_pose* grnLocalPose = nullptr; + granny_world_pose* grnWorldPose = nullptr; #endif - std::unique_ptr sequencer; - cmf::SkeletonPose pose; - std::vector worldTransforms; + std::unique_ptr sequencer; + cmf::SkeletonPose pose; + std::vector worldTransforms; std::unique_ptr rtMesh; std::unique_ptr rtMeshArea; @@ -375,7 +383,7 @@ BLUE_CLASS( EveTurretSet ): bool m_useDynamicBounds; #if WITH_GRANNY - void InitializeGrannyDynamicBounds( granny_file_info* fi, granny_skeleton* skeleton ); + void InitializeGrannyDynamicBounds( granny_file_info * fi, granny_skeleton * skeleton ); #endif void InitializeDynamicBounds( const cmf::Data* cmfData, const cmf::Skeleton* skeleton ); @@ -399,7 +407,7 @@ BLUE_CLASS( EveTurretSet ): Tr2SuballocatedBuffer::Allocation m_instanceBuffer; // Assign the target object - void SetTargetObject( IRoot* target ); + void SetTargetObject( IRoot * target ); ITriTargetablePtr GetTargetObject(); void SetTargetScale(); @@ -423,9 +431,9 @@ BLUE_CLASS( EveTurretSet ): // animation struct AnimationRequest { - int turretIndex; - std::string animName; - std::string animNameIdle; + int turretIndex; + std::string animName; + std::string animNameIdle; }; std::vector m_animationQueue; #if WITH_GRANNY @@ -456,13 +464,13 @@ BLUE_CLASS( EveTurretSet ): float m_sysBonePitch02Factor; float m_sysBonePitch03Offset; float m_sysBonePitch03Factor; - + Matrix GetTurretBoneTransform( uint32_t closestTurret, uint32_t boneID ) const; // state of turret set State m_state; - // the turret that's currently active(firing) - int m_activeTurret; + // the turret that's currently active(firing) + int m_activeTurret; // time to re-check active turret float m_recheckTimeLeft; @@ -495,7 +503,6 @@ BLUE_CLASS( EveTurretSet ): std::wstring m_targetingToIdleMovementAudioEvent; Tr2RingBufferOffsets m_boneOffsets; - }; TYPEDEF_BLUECLASS( EveTurretSet ); diff --git a/trinity/Eve/Turret/EveTurretSet_Blue.cpp b/trinity/Eve/Turret/EveTurretSet_Blue.cpp index 35332b65f..fbe2562be 100644 --- a/trinity/Eve/Turret/EveTurretSet_Blue.cpp +++ b/trinity/Eve/Turret/EveTurretSet_Blue.cpp @@ -8,55 +8,39 @@ BLUE_DEFINE( EveTurretSet ); -Be::VarChooser LODChooser[] = -{ - { - "LOD_INVALID", - BeCast( EveTurretSet::LOD_INVALID ), - "" - }, - { - "LOD_EMPTY", - BeCast( EveTurretSet::LOD_EMPTY ), - "" - }, - { - "LOD_HIGHEST", - BeCast( EveTurretSet::LOD_HIGHEST ), - "" - }, - { - "LOD_DISABLED", - BeCast( EveTurretSet::LOD_DISABLED ), - "" - }, +Be::VarChooser LODChooser[] = { + { "LOD_INVALID", + BeCast( EveTurretSet::LOD_INVALID ), + "" }, + { "LOD_EMPTY", + BeCast( EveTurretSet::LOD_EMPTY ), + "" }, + { "LOD_HIGHEST", + BeCast( EveTurretSet::LOD_HIGHEST ), + "" }, + { "LOD_DISABLED", + BeCast( EveTurretSet::LOD_DISABLED ), + "" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( - "EveTurretSetLOD", - EveTurretSet::LOD, - LODChooser, +BLUE_REGISTER_ENUM_EX( + "EveTurretSetLOD", + EveTurretSet::LOD, + LODChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); -Be::VarChooser ImpactBehaviourChooser[] = -{ - { - "DAMAGE_LOCATOR", - BeCast( ImpactBehaviour::DAMAGE_LOCATOR ), - "" - }, - { - "SHIELD_ELLIPSOID", - BeCast( ImpactBehaviour::SHIELD_ELLIPSOID ), - "" - }, - { - "CENTER", - BeCast( ImpactBehaviour::CENTER ), - "" - }, +Be::VarChooser ImpactBehaviourChooser[] = { + { "DAMAGE_LOCATOR", + BeCast( ImpactBehaviour::DAMAGE_LOCATOR ), + "" }, + { "SHIELD_ELLIPSOID", + BeCast( ImpactBehaviour::SHIELD_ELLIPSOID ), + "" }, + { "CENTER", + BeCast( ImpactBehaviour::CENTER ), + "" }, { 0 } }; @@ -64,12 +48,12 @@ Be::VarChooser ImpactBehaviourChooser[] = const Be::ClassInfo* EveTurretSet::ExposeToBlue() { EXPOSURE_BEGIN( EveTurretSet, "" ) - MAP_INTERFACE( EveTurretSet ) - MAP_INTERFACE( EveEntity ) - MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( EveTurretSet ) + MAP_INTERFACE( EveEntity ) + MAP_INTERFACE( IInitialize ) MAP_INTERFACE( EveEntity ) - MAP_INTERFACE( INotify ) - MAP_INTERFACE( ITr2Renderable ) + MAP_INTERFACE( INotify ) + MAP_INTERFACE( ITr2Renderable ) MAP_ATTRIBUTE( "name", m_name, "A name for this turret pair", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Toggle rendering", Be::READWRITE ) @@ -90,8 +74,8 @@ const Be::ClassInfo* EveTurretSet::ExposeToBlue() MAP_ATTRIBUTE( "locatorName", m_locatorName, "locator name for all turrets of this pair (A, B, C is auto-attached!)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "slotNumber", m_slotNumber, "the slot number of the turret", Be::READWRITE ) MAP_ATTRIBUTE( "swarmID", m_swarmID, "id of the swarmer using this turret set(fighters) used for deriving turret transforms", Be::READWRITE ) - - MAP_PROPERTY( "targetObject", GetTargetObject, SetTargetObject, "object this set of turrets will track" ) + + MAP_PROPERTY( "targetObject", GetTargetObject, SetTargetObject, "object this set of turrets will track" ) MAP_ATTRIBUTE( "target", m_target, "Info on the target", Be::READ ) MAP_ATTRIBUTE( "turretEffect", m_turretEffect, "The effect to use to draw the turret pair", Be::READWRITE | Be::PERSIST ) @@ -127,7 +111,7 @@ const Be::ClassInfo* EveTurretSet::ExposeToBlue() MAP_ATTRIBUTE( "laserMissBehaviour", m_laserMissBehaviour, "Whether or not to use laser-like properties when this turret misses", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "projectileMissBehaviour", m_projectileMissBehaviour, "Whether or not to use projectile properties when this turret misses", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "impactSize", m_impactSize, "Size of impacts. No impact if size is 0 or less", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "impactBehaviour", m_impactBehaviour, "What do we want to hit? ", Be::READWRITE | Be::NOTIFY | Be::PERSIST | Be::ENUM, ImpactBehaviourChooser ) @@ -187,15 +171,14 @@ const Be::ClassInfo* EveTurretSet::ExposeToBlue() MAP_METHOD_AND_WRAP( "ForceStateTargeting", ForceStateTargeting, - "Force into state targeting: no anim, no transition, just flip.") + "Force into state targeting: no anim, no transition, just flip." ) MAP_METHOD_AND_WRAP( "SetShotMissed", SetShotMissed, "Set whether the last turret shot missed.\n" - ":param missed: was the last shot a miss" - ) - + ":param missed: was the last shot a miss" ) + MAP_METHOD_AND_WRAP( "GetLastShotTime", GetLastShotTime, @@ -204,40 +187,37 @@ const Be::ClassInfo* EveTurretSet::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetShotTimeVariance", GetShotTimeVariance, - "Get maximum time variance between turrets in a set.") + "Get maximum time variance between turrets in a set." ) MAP_METHOD_AND_WRAP( "MissQueueSize", MissQueueSize, - "Get the size of the active miss/hit queue.") + "Get the size of the active miss/hit queue." ) MAP_METHOD_AND_WRAP( "GetFiringBoneWorldTransform", GetFiringBoneWorldTransform, "Returns the world transform matrix of the specfified firing bone in the currently firing turret." "\n:param idx: index of the firing bone in the current model." - "\n:returns: The world transform matrix.") + "\n:returns: The world transform matrix." ) MAP_METHOD_AND_WRAP( "SetControllerVariable", SetControllerVariable, "Set variable for all applicable controllers\n" ":param name: variable name\n" - ":param value: new variable value\n" - ) + ":param value: new variable value\n" ) MAP_METHOD_AND_WRAP( "HandleControllerEvent", HandleControllerEvent, "Pass an event to controllers\n" - ":param name: event name" - ) + ":param name: event name" ) MAP_METHOD_AND_WRAP( "StartControllers", StartControllers, - "Start all controllers" - ) + "Start all controllers" ) EXPOSURE_END() } diff --git a/trinity/Eve/Turret/EveTurretTarget.cpp b/trinity/Eve/Turret/EveTurretTarget.cpp index 95b6a4bbc..a4126ae26 100644 --- a/trinity/Eve/Turret/EveTurretTarget.cpp +++ b/trinity/Eve/Turret/EveTurretTarget.cpp @@ -119,7 +119,7 @@ void EveTurretTarget::StartFireAtLocator( int l, float delay, float length, cons if( m_object ) { m_impactLength = std::max( length, 0.f ); - m_impactDelay = delay; + m_impactDelay = delay; // If we have a laser that has no buildup, we need to create an impact straigt away // Otherwise we have the chance of the laser ending on the hull, intead of the shield where it should be @@ -134,7 +134,7 @@ void EveTurretTarget::StartFireAtLocator( int l, float delay, float length, cons m_impactID = m_object->CreateImpact( m_locator, dirToSource, m_impactLength, m_impactSize ); m_impactDelay = -1.f; } - } + } } } } @@ -156,7 +156,7 @@ void EveTurretTarget::StopFireAtLocator() // -------------------------------------------------------------------------------- // Description: -// Gets the impact position based on some parameters +// Gets the impact position based on some parameters // -------------------------------------------------------------------------------- void EveTurretTarget::GetImpactPosition( Vector3& out, const Vector3* source ) @@ -167,7 +167,7 @@ void EveTurretTarget::GetImpactPosition( Vector3& out, const Vector3* source ) { m_object->GetDamageLocatorPosition( &out, m_locator, true ); - if( LengthSq(out) > 22379561604000000000000.f ) // AU squared + if( LengthSq( out ) > 22379561604000000000000.f ) // AU squared { out = m_objectPos->GetWorldPosition(); } @@ -215,7 +215,7 @@ void EveTurretTarget::Update( float deltaT, const Vector3* source ) { float dist = Length( direction ); direction /= dist; - m_positionMiss += direction * ( dist + 5000.f) * ( 1.f + 0.5f * m_randomMissDistanceOffset ); + m_positionMiss += direction * ( dist + 5000.f ) * ( 1.f + 0.5f * m_randomMissDistanceOffset ); } if( m_impactBehaviour == ImpactBehaviour::DAMAGE_LOCATOR ) @@ -238,7 +238,7 @@ void EveTurretTarget::Update( float deltaT, const Vector3* source ) } } } - + m_trackingPosition = m_targetPosition; // are we still fading from an old position? if( m_positionOldInfluence > 0.f ) @@ -328,7 +328,7 @@ int EveTurretTarget::FindRandomValidLocator( const Vector3& source, Vector3& pos // Description: // Set the internal behaviour of the hit/miss functionality // -------------------------------------------------------------------------------- -void EveTurretTarget::SetBehaviour( bool laserMiss, bool projectileMiss, float impactSize, ImpactBehaviour::Type impactBehaviour) +void EveTurretTarget::SetBehaviour( bool laserMiss, bool projectileMiss, float impactSize, ImpactBehaviour::Type impactBehaviour ) { m_laserMissBehaviour = laserMiss; m_projectileMissBehaviour = projectileMiss; @@ -340,12 +340,12 @@ void EveTurretTarget::SetBehaviour( bool laserMiss, bool projectileMiss, float i // Description: // Method to pop from the miss queue. // -------------------------------------------------------------------------------- -bool EveTurretTarget::PopShotMissed() -{ +bool EveTurretTarget::PopShotMissed() +{ m_lastShotIsMiss = m_missQueue.empty() ? false : m_missQueue.front(); if( !m_missQueue.empty() ) { - m_missQueue.pop_front(); + m_missQueue.pop_front(); } return m_lastShotIsMiss; } @@ -355,7 +355,7 @@ bool EveTurretTarget::PopShotMissed() // Get the hit/miss status of the last shot info. // -------------------------------------------------------------------------------- bool EveTurretTarget::GetShotMissed() const -{ +{ return m_lastShotIsMiss; } @@ -364,7 +364,7 @@ bool EveTurretTarget::GetShotMissed() const // Add a hit/miss to the shot queue. // -------------------------------------------------------------------------------- void EveTurretTarget::SetShotMissed( bool missed ) -{ +{ m_missQueue.push_back( missed ); m_lastShotTime = TimeAsDouble( BeOS->GetActualTime() ); // in case we get way behind, start dropping miss events, rather than infinitely accumulating. @@ -408,7 +408,7 @@ float EveTurretTarget::GetRadius() const // -------------------------------------------------------------------------------- // Description: -// Pass through the GetImpactConfiguration call to the target object +// Pass through the GetImpactConfiguration call to the target object // -------------------------------------------------------------------------------- ITriTargetable::ImpactConfiguration EveTurretTarget::GetImpactConfiguration() const { diff --git a/trinity/Eve/Turret/EveTurretTarget.h b/trinity/Eve/Turret/EveTurretTarget.h index 67d65f865..d4de78f8c 100644 --- a/trinity/Eve/Turret/EveTurretTarget.h +++ b/trinity/Eve/Turret/EveTurretTarget.h @@ -6,13 +6,15 @@ #include "Include/ITriTargetable.h" -namespace ImpactBehaviour { - - enum Type { - DAMAGE_LOCATOR, - SHIELD_ELLIPSOID, - CENTER - }; +namespace ImpactBehaviour +{ + +enum Type +{ + DAMAGE_LOCATOR, + SHIELD_ELLIPSOID, + CENTER +}; } @@ -30,7 +32,7 @@ BLUE_CLASS( EveTurretTarget ) : // access target object ITriTargetablePtr GetTargetable() const; - bool SetTargetable( IRoot* object ); + bool SetTargetable( IRoot * object ); // access locator int GetLocator() const; @@ -58,7 +60,7 @@ BLUE_CLASS( EveTurretTarget ) : bool ShowDestObject() const; private: - void GetImpactPosition( Vector3& out, const Vector3* source ); + void GetImpactPosition( Vector3 & out, const Vector3* source ); // data ITriTargetablePtr m_object; diff --git a/trinity/Eve/Turret/EveTurretTarget_Blue.cpp b/trinity/Eve/Turret/EveTurretTarget_Blue.cpp index 677b740a6..5c39a72c4 100644 --- a/trinity/Eve/Turret/EveTurretTarget_Blue.cpp +++ b/trinity/Eve/Turret/EveTurretTarget_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveTurretTarget ); const Be::ClassInfo* EveTurretTarget::ExposeToBlue() { - EXPOSURE_BEGIN( EveTurretTarget, "" ) - MAP_INTERFACE( EveTurretTarget ) + EXPOSURE_BEGIN( EveTurretTarget, "" ) + MAP_INTERFACE( EveTurretTarget ) MAP_ATTRIBUTE( "locator", m_locator, "Target locator ID", Be::READ ) MAP_ATTRIBUTE( "position", m_trackingPosition, "Position the turret is tracking", Be::READ ) diff --git a/trinity/Eve/UI/EveConnector.cpp b/trinity/Eve/UI/EveConnector.cpp index c171f93fb..82070d8ad 100644 --- a/trinity/Eve/UI/EveConnector.cpp +++ b/trinity/Eve/UI/EveConnector.cpp @@ -32,7 +32,7 @@ void EveConnector::Update( const EveUpdateContext& context ) { m_sourceObject->GetValueAt( &m_sourcePosition, context.GetTime() ); } - + if( m_destObject ) { m_destObject->GetValueAt( &m_destPosition, context.GetTime() ); @@ -119,11 +119,11 @@ inline void EveConnector::AnimateSegment( EveCurveLineSet* lineSet, int lineID ) { speed = m_animationSpeed / m_lineLength; } - lineSet->ChangeLineAnimation( lineID, ( Vector4 )m_animationColor, speed, m_lineLength * m_animationScale ); + lineSet->ChangeLineAnimation( lineID, (Vector4)m_animationColor, speed, m_lineLength * m_animationScale ); } else { - lineSet->ChangeLineAnimation( lineID, ( Vector4 )m_animationColor, m_animationSpeed, m_animationScale ); + lineSet->ChangeLineAnimation( lineID, (Vector4)m_animationColor, m_animationSpeed, m_animationScale ); } } } @@ -174,19 +174,18 @@ inline void EveConnector::AddOrbit( EveCurveLineSet* lineSet, const Vector3& cen inline void EveConnector::AddStraightLine( EveCurveLineSet* lineSet, const Vector3& source, const Vector3& destination, bool fadeEnd ) { - Vector4 endColor = ( Vector4 )m_color; + Vector4 endColor = (Vector4)m_color; if( fadeEnd ) { endColor *= 0; } - int id = lineSet->AddStraightLine( source, ( Vector4 )m_color, destination, endColor, m_width ); + int id = lineSet->AddStraightLine( source, (Vector4)m_color, destination, endColor, m_width ); AnimateSegment( lineSet, id ); - } inline void EveConnector::AddSpheredSegment( EveCurveLineSet* lineSet, const Vector3& p0, const Vector3& p1, const Vector3& center ) { - int id = lineSet->AddSpheredLineCrt( p0, ( Vector4 )m_color, p1, ( Vector4 )m_color, center, m_width ); + int id = lineSet->AddSpheredLineCrt( p0, (Vector4)m_color, p1, (Vector4)m_color, center, m_width ); AnimateSegment( lineSet, id ); } @@ -194,11 +193,11 @@ inline void EveConnector::AddEllipse( EveCurveLineSet* lineSet, const Vector3& c { Vector3 side, front; CalculateSideAndFront( normal, side, front ); - + float rotationRad = rotation * TRI_PI / 180.0f; float cosRot = cos( rotationRad ); float sinRot = sin( rotationRad ); - + Vector3 rotatedSide = side * cosRot + front * sinRot; Vector3 rotatedFront = -side * sinRot + front * cosRot; @@ -226,7 +225,7 @@ inline void EveConnector::AddEllipse( EveCurveLineSet* lineSet, const Vector3& c inline void EveConnector::AddCurvedLine( EveCurveLineSet* lineSet, const Vector3& point1, const Vector3& point2, const Vector3& middle, int segments ) { - int lineId = lineSet->AddCurvedLineCrt( point1, ( Vector4 )m_color, point2, ( Vector4 )m_color, middle, m_width, segments ); + int lineId = lineSet->AddCurvedLineCrt( point1, (Vector4)m_color, point2, (Vector4)m_color, middle, m_width, segments ); AnimateSegment( lineSet, lineId ); } diff --git a/trinity/Eve/UI/EveConnector.h b/trinity/Eve/UI/EveConnector.h index 5df61e0b7..df5abf591 100644 --- a/trinity/Eve/UI/EveConnector.h +++ b/trinity/Eve/UI/EveConnector.h @@ -21,10 +21,20 @@ BLUE_CLASS( EveConnector ) : EveConnector( IRoot* lockobj = NULL ); ~EveConnector(); - enum ConnectorType { PointToPoint, XZ_CircleStraight, XZ_Circle, StraightAnchor, CurvedAnchor, Orbit, Circle, Ellipse }; + enum ConnectorType + { + PointToPoint, + XZ_CircleStraight, + XZ_Circle, + StraightAnchor, + CurvedAnchor, + Orbit, + Circle, + Ellipse + }; void Update( const EveUpdateContext& context ); - void AddLine( EveCurveLineSet* lineSet ); + void AddLine( EveCurveLineSet * lineSet ); private: ITriVectorFunctionPtr m_sourceObject; @@ -38,7 +48,7 @@ BLUE_CLASS( EveConnector ) : Color m_color; Color m_animationColor; - + float m_animationSpeed; float m_animationScale; float m_width; @@ -49,14 +59,14 @@ BLUE_CLASS( EveConnector ) : bool m_autoScaleAnimation; // Some helper functions(inline) - void AnimateSegment( EveCurveLineSet* lineSet, int lineID ); - void AddCircle( EveCurveLineSet* lineSet, const Vector3& center, float radius ); - void AddCircle( EveCurveLineSet* lineSet, const Vector3& center, float radius, const Vector3& normal ); + void AnimateSegment( EveCurveLineSet * lineSet, int lineID ); + void AddCircle( EveCurveLineSet * lineSet, const Vector3& center, float radius ); + void AddCircle( EveCurveLineSet * lineSet, const Vector3& center, float radius, const Vector3& normal ); void AddEllipse( EveCurveLineSet * lineSet, const Vector3& center, float radiusX, float radiusY, float rotation, const Vector3& normal ); - void AddOrbit( EveCurveLineSet* lineSet, const Vector3& center, float radius, const Vector3& normal ); - void AddStraightLine( EveCurveLineSet* lineSet, const Vector3& source, const Vector3& destination, bool fadeEnd=false ); - void AddSpheredSegment( EveCurveLineSet* lineSet, const Vector3& p0, const Vector3& p1, const Vector3& center ); - void AddCurvedLine( EveCurveLineSet* lineSet, const Vector3& p0, const Vector3& p1, const Vector3& center, int segments ); + void AddOrbit( EveCurveLineSet * lineSet, const Vector3& center, float radius, const Vector3& normal ); + void AddStraightLine( EveCurveLineSet * lineSet, const Vector3& source, const Vector3& destination, bool fadeEnd = false ); + void AddSpheredSegment( EveCurveLineSet * lineSet, const Vector3& p0, const Vector3& p1, const Vector3& center ); + void AddCurvedLine( EveCurveLineSet * lineSet, const Vector3& p0, const Vector3& p1, const Vector3& center, int segments ); void CalculateSideAndFront( const Vector3& upDir, Vector3& outSide, Vector3& outFront ); }; diff --git a/trinity/Eve/UI/EveConnector_Blue.cpp b/trinity/Eve/UI/EveConnector_Blue.cpp index 9f40cac0e..7726baaee 100644 --- a/trinity/Eve/UI/EveConnector_Blue.cpp +++ b/trinity/Eve/UI/EveConnector_Blue.cpp @@ -3,64 +3,46 @@ #include "StdAfx.h" #include "EveConnector.h" -Be::VarChooser EveConnectorTypeChooser[] = -{ - { - "PointToPoint", - BeCast( EveConnector::PointToPoint ), - "Connection between two points" - }, - { - "StraightAnchor", - BeCast( EveConnector::StraightAnchor ), - "Anchor line from dest to xz plane containing source" - }, - { - "CurvedAnchor", - BeCast( EveConnector::CurvedAnchor ), - "Sphered line from dest to xz plane containing source using source as the center" - }, - { - "XZ_Circle", - BeCast( EveConnector::XZ_Circle ), - "Circle in xz plane going through the 'CurvedAnchor' point with source as the center" - }, - { - "XZ_CircleStraight", - BeCast( EveConnector::XZ_CircleStraight ), - "Circle in xz plane going through the 'StraightAnchor' point with source as the center" - }, - { - "Circle", - BeCast( EveConnector::Circle ), - "Circle in the plane normal plane" - }, - { - "Ellipse", - BeCast( EveConnector::Ellipse ), - "Ellipse in the plane normal plane, radiusX is destPosition.x, radiusY is destPosition.y and ellipse rotation is destPosition.z" - }, - { - "Orbit", - BeCast( EveConnector::Orbit ), - "Draws an orbit using planeNormal and radius" - }, +Be::VarChooser EveConnectorTypeChooser[] = { + { "PointToPoint", + BeCast( EveConnector::PointToPoint ), + "Connection between two points" }, + { "StraightAnchor", + BeCast( EveConnector::StraightAnchor ), + "Anchor line from dest to xz plane containing source" }, + { "CurvedAnchor", + BeCast( EveConnector::CurvedAnchor ), + "Sphered line from dest to xz plane containing source using source as the center" }, + { "XZ_Circle", + BeCast( EveConnector::XZ_Circle ), + "Circle in xz plane going through the 'CurvedAnchor' point with source as the center" }, + { "XZ_CircleStraight", + BeCast( EveConnector::XZ_CircleStraight ), + "Circle in xz plane going through the 'StraightAnchor' point with source as the center" }, + { "Circle", + BeCast( EveConnector::Circle ), + "Circle in the plane normal plane" }, + { "Ellipse", + BeCast( EveConnector::Ellipse ), + "Ellipse in the plane normal plane, radiusX is destPosition.x, radiusY is destPosition.y and ellipse rotation is destPosition.z" }, + { "Orbit", + BeCast( EveConnector::Orbit ), + "Draws an orbit using planeNormal and radius" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( +BLUE_REGISTER_ENUM_EX( "EveConnectorStyle", EveConnector::ConnectorType, EveConnectorTypeChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); + ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( EveConnector ); const Be::ClassInfo* EveConnector::ExposeToBlue() { - EXPOSURE_BEGIN( EveConnector, "" ) - MAP_INTERFACE( EveConnector ) + EXPOSURE_BEGIN( EveConnector, "" ) + MAP_INTERFACE( EveConnector ) MAP_ATTRIBUTE( "color", m_color, "", Be::READWRITE | Be::PERSIST ); MAP_ATTRIBUTE( "lineWidth", m_width, "", Be::READWRITE | Be::PERSIST ); @@ -81,5 +63,5 @@ const Be::ClassInfo* EveConnector::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "type", m_type, "", Be::READWRITE | Be::PERSIST | Be::ENUM, EveConnectorTypeChooser ); - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/UI/EveCurveLineSet.cpp b/trinity/Eve/UI/EveCurveLineSet.cpp index bd348d4ac..bdac81104 100644 --- a/trinity/Eve/UI/EveCurveLineSet.cpp +++ b/trinity/Eve/UI/EveCurveLineSet.cpp @@ -16,7 +16,7 @@ static const char* CURVE_PICK_EFFECT_PATH = "res:/Graphics/Effect/Managed/Space/ CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); // ------------------------------------------------------------------------------------------------------ -EveCurveLineSet::EveCurveLineSet( IRoot* lockobj /*= NULL*/ ): +EveCurveLineSet::EveCurveLineSet( IRoot* lockobj /*= NULL*/ ) : Tr2CurveLineSet( lockobj ), m_isVisible( false ) { diff --git a/trinity/Eve/UI/EveCurveLineSet.h b/trinity/Eve/UI/EveCurveLineSet.h index adde1830d..6d61319d0 100644 --- a/trinity/Eve/UI/EveCurveLineSet.h +++ b/trinity/Eve/UI/EveCurveLineSet.h @@ -13,7 +13,7 @@ BLUE_DECLARE( EveCurveLineSet ); class Tr2PerObjectData; class Tr2PerObjectDataStandard; -BLUE_CLASS( EveCurveLineSet ): +BLUE_CLASS( EveCurveLineSet ) : public Tr2CurveLineSet, public IEveTransform, public IEveSpaceObject2 @@ -21,30 +21,43 @@ BLUE_CLASS( EveCurveLineSet ): public: EXPOSE_TO_BLUE(); - EveCurveLineSet(IRoot* lockobj = NULL); + EveCurveLineSet( IRoot* lockobj = NULL ); ~EveCurveLineSet(); - - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); + + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 void UpdateSyncronous( const EveUpdateContext& updateContext ); void UpdateAsyncronous( const EveUpdateContext& updateContext ); void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + void GetRenderables( std::vector & renderables ); + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; ///////////////////////////////////////////////////////////////////////////////////// // IEveTransform void Update( const EveUpdateContext& updateContext ); - Tr2Lod GetLODLevel() const { return TR2_LOD_HIGH; } + Tr2Lod GetLODLevel() const + { + return TR2_LOD_HIGH; + } // No sensible implementation? - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) {} - void GetModelCenterWorldPosition( Vector3 &position ) const {} - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } - void GetLocalToWorldTransform( Matrix &transform ) const { transform = IdentityMatrix(); } + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ) + { + } + void GetModelCenterWorldPosition( Vector3 & position ) const + { + } + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) + { + return false; + } + void GetLocalToWorldTransform( Matrix & transform ) const + { + transform = IdentityMatrix(); + } private: bool m_isVisible; diff --git a/trinity/Eve/UI/EveEllipseDefinition.h b/trinity/Eve/UI/EveEllipseDefinition.h index 7ee2b5fda..409cb3760 100644 --- a/trinity/Eve/UI/EveEllipseDefinition.h +++ b/trinity/Eve/UI/EveEllipseDefinition.h @@ -10,14 +10,15 @@ BLUE_DECLARE( EveEllipseDefinition ); * A single closed elliptical orbit. Held in lists by EveEllipseSet. * Parent registers a dirty flag pointer so editor edits can trigger geometry rebuilds. */ -BLUE_CLASS( EveEllipseDefinition ) : public INotify +BLUE_CLASS( EveEllipseDefinition ) : + public INotify { public: EXPOSE_TO_BLUE(); EveEllipseDefinition( IRoot* lockobj = nullptr ); - bool OnModified( Be::Var* val ) override; + bool OnModified( Be::Var * val ) override; void SetDirtyFlag( bool* dirtyFlag ); diff --git a/trinity/Eve/UI/EveEllipseSet.cpp b/trinity/Eve/UI/EveEllipseSet.cpp index d457b9bc4..4e04b6070 100644 --- a/trinity/Eve/UI/EveEllipseSet.cpp +++ b/trinity/Eve/UI/EveEllipseSet.cpp @@ -67,8 +67,8 @@ void BuildOrbitEllipseAxes( const EveEllipseDefinition& spec, Vector3& outU, Vec std::string g_ellipseRibbonEffectPath = ""; TRI_REGISTER_SETTING( "ellipseRibbonEffectPath", g_ellipseRibbonEffectPath ); -EveEllipseSet::EveEllipseSet( IRoot* lockobj ) - : PARENTLOCK( m_ellipses ) +EveEllipseSet::EveEllipseSet( IRoot* lockobj ) : + PARENTLOCK( m_ellipses ) { m_ellipses.SetNotify( this ); BoundingSphereInitialize( m_boundingSphere ); @@ -101,7 +101,7 @@ bool EveEllipseSet::OnPrepareResources() void EveEllipseSet::ClearEllipses() { - for ( auto& spec : m_ellipses ) + for( auto& spec : m_ellipses ) { spec->SetDirtyFlag( nullptr ); } @@ -134,7 +134,7 @@ const char* EveEllipseSet::GetName() const void EveEllipseSet::SetName( const char* name ) { - m_name = BlueSharedString(name); + m_name = BlueSharedString( name ); } EveEllipseSet::~EveEllipseSet() @@ -301,14 +301,14 @@ void EveEllipseSet::RebuildGeometry( const EveUpdateContext& updateContext ) tangent = tangent * ( 1.f / tangentLength ); // Left edge: sideSign = -1 - vertices[ vWrite ].centerPos = point; - vertices[ vWrite ].tangentSide = Vector4( tangent.x, tangent.y, tangent.z, -1.f ); + vertices[vWrite].centerPos = point; + vertices[vWrite].tangentSide = Vector4( tangent.x, tangent.y, tangent.z, -1.f ); BoundingSphereUpdate( point, m_boundingSphere ); vWrite++; // Right edge: sideSign = +1 - vertices[ vWrite ].centerPos = point; - vertices[ vWrite ].tangentSide = Vector4( tangent.x, tangent.y, tangent.z, 1.f ); + vertices[vWrite].centerPos = point; + vertices[vWrite].tangentSide = Vector4( tangent.x, tangent.y, tangent.z, 1.f ); BoundingSphereUpdate( point, m_boundingSphere ); vWrite++; } @@ -320,12 +320,12 @@ void EveEllipseSet::RebuildGeometry( const EveUpdateContext& updateContext ) const uint32_t curRight = baseVertexIndex + 2u * i + 1u; const uint32_t nextLeft = baseVertexIndex + 2u * next; const uint32_t nextRight = baseVertexIndex + 2u * next + 1u; - indices[ iWrite++ ] = curLeft; - indices[ iWrite++ ] = nextLeft; - indices[ iWrite++ ] = curRight; - indices[ iWrite++ ] = curRight; - indices[ iWrite++ ] = nextLeft; - indices[ iWrite++ ] = nextRight; + indices[iWrite++] = curLeft; + indices[iWrite++] = nextLeft; + indices[iWrite++] = curRight; + indices[iWrite++] = curRight; + indices[iWrite++] = nextLeft; + indices[iWrite++] = nextRight; } } @@ -440,8 +440,7 @@ void EveEllipseSet::GetBatches( ITriRenderBatchAccumulator* accumulator, TriBatc { PrepareResources(); } - if( !m_effect || !m_vertexBuffer.IsValid() || !m_indexBuffer.IsValid() || m_indexCount == 0 - || m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) + if( !m_effect || !m_vertexBuffer.IsValid() || !m_indexBuffer.IsValid() || m_indexCount == 0 || m_vertexDeclHandle == Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) { return; } diff --git a/trinity/Eve/UI/EveEllipseSet.h b/trinity/Eve/UI/EveEllipseSet.h index 76ea25aa7..2c1639d16 100644 --- a/trinity/Eve/UI/EveEllipseSet.h +++ b/trinity/Eve/UI/EveEllipseSet.h @@ -29,36 +29,36 @@ BLUE_CLASS( EveEllipseSet ) : EveEllipseSet( IRoot* lockobj = nullptr ); ~EveEllipseSet() override; - + void py__init__(); void ClearEllipses(); bool AddEllipse( const Vector3& center, float semiMajor, float semiMinor, const Vector3& planeNormal, float rotationDegrees ); - + ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObjectChild const char* GetName() const override; void SetName( const char* name ) override; void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform, Tr2Lod parentLod ) override; - void GetRenderables( std::vector& renderables ) override; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; + void GetRenderables( std::vector & renderables ) override; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const override; void UpdateSyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; void UpdateAsyncronous( const EveUpdateContext& updateContext, const EveChildUpdateParams& params ) override; - void GetLocalToWorldTransform( Matrix& transform ) const override; + void GetLocalToWorldTransform( Matrix & transform ) const override; void Setup( const Vector3* scale, const Quaternion* rotation, const Vector3* translation, Tr2Lod lowestLodVisible ) override; void ChangeLOD( Tr2Lod lod ) override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable IRoot* GetID( uint16_t ) override; - void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) override; + void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) override; ////////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) override; bool HasTransparentBatches() override; float GetSortValue() override; - Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) override; + Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ) override; ////////////////////////////////////////////////////////////////////////////////////// // Tr2DeviceResource @@ -70,7 +70,7 @@ BLUE_CLASS( EveEllipseSet ) : ////////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ) override; + bool OnModified( Be::Var * val ) override; BlueSharedString m_name; bool m_display = true; @@ -82,7 +82,7 @@ BLUE_CLASS( EveEllipseSet ) : Tr2EffectPtr m_effect; private: - void CommitRibbonBatch( ITriRenderBatchAccumulator* accumulator, const Tr2PerObjectData* perObjectData, Tr2EffectPtr& effect ); + void CommitRibbonBatch( ITriRenderBatchAccumulator * accumulator, const Tr2PerObjectData* perObjectData, Tr2EffectPtr& effect ); bool OnPrepareResources() override; diff --git a/trinity/Eve/UI/EveLineContainer.cpp b/trinity/Eve/UI/EveLineContainer.cpp index 61c2738b4..8f6ddf017 100644 --- a/trinity/Eve/UI/EveLineContainer.cpp +++ b/trinity/Eve/UI/EveLineContainer.cpp @@ -28,8 +28,8 @@ void EveLineContainer::Update( const EveUpdateContext& context ) m_lineSet->ClearLines(); for( auto it = m_connectors.begin(); it != m_connectors.end(); it++ ) { - (*it)->Update( context ); - (*it)->AddLine( m_lineSet ); + ( *it )->Update( context ); + ( *it )->AddLine( m_lineSet ); } m_lineSet->SubmitChanges(); } @@ -70,7 +70,7 @@ bool EveLineContainer::GetBoundingSphere( Vector4& sphere, BoundingSphereQuery q } // This version of the function should perform an update on the model / ball position -void EveLineContainer::UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) +void EveLineContainer::UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) { if( m_lineSet ) { @@ -79,7 +79,7 @@ void EveLineContainer::UpdateModelCenterWorldPosition( Vector3 &position, Be::Ti } // This version of the function should not update the object -void EveLineContainer::GetModelCenterWorldPosition( Vector3 &position ) const +void EveLineContainer::GetModelCenterWorldPosition( Vector3& position ) const { if( m_lineSet ) { @@ -88,7 +88,7 @@ void EveLineContainer::GetModelCenterWorldPosition( Vector3 &position ) const } // If possible, return an AABB in local coordinates -bool EveLineContainer::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) +bool EveLineContainer::GetLocalBoundingBox( Vector3& min, Vector3& max ) { if( m_lineSet ) { @@ -98,7 +98,7 @@ bool EveLineContainer::GetLocalBoundingBox( Vector3 &min, Vector3 &max ) } // Get the local to world transform -void EveLineContainer::GetLocalToWorldTransform( Matrix &transform ) const +void EveLineContainer::GetLocalToWorldTransform( Matrix& transform ) const { if( m_lineSet ) { diff --git a/trinity/Eve/UI/EveLineContainer.h b/trinity/Eve/UI/EveLineContainer.h index ac5fcba7d..27d74678e 100644 --- a/trinity/Eve/UI/EveLineContainer.h +++ b/trinity/Eve/UI/EveLineContainer.h @@ -23,21 +23,26 @@ BLUE_CLASS( EveLineContainer ) : ~EveLineContainer(); void Update( const EveUpdateContext& context ); - + ////////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 - void UpdateSyncronous( const EveUpdateContext& updateContext ) { Update( updateContext ); } - void UpdateAsyncronous( const EveUpdateContext& updateContext ) {} + void UpdateSyncronous( const EveUpdateContext& updateContext ) + { + Update( updateContext ); + } + void UpdateAsyncronous( const EveUpdateContext& updateContext ) + { + } void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ); - void GetModelCenterWorldPosition( Vector3 &position ) const; - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ); - void GetLocalToWorldTransform( Matrix &transform ) const; + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ); + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ); + void GetModelCenterWorldPosition( Vector3 & position ) const; + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ); + void GetLocalToWorldTransform( Matrix & transform ) const; private: - BlueSharedString m_name; + BlueSharedString m_name; PEveConnectorVector m_connectors; EveCurveLineSetPtr m_lineSet; diff --git a/trinity/Eve/UI/EveLineContainer_Blue.cpp b/trinity/Eve/UI/EveLineContainer_Blue.cpp index 754ca9d2e..e53bd84ba 100644 --- a/trinity/Eve/UI/EveLineContainer_Blue.cpp +++ b/trinity/Eve/UI/EveLineContainer_Blue.cpp @@ -7,8 +7,8 @@ BLUE_DEFINE( EveLineContainer ); const Be::ClassInfo* EveLineContainer::ExposeToBlue() { - EXPOSURE_BEGIN( EveLineContainer, "" ) - MAP_INTERFACE( EveLineContainer ) + EXPOSURE_BEGIN( EveLineContainer, "" ) + MAP_INTERFACE( EveLineContainer ) MAP_INTERFACE( IEveSpaceObject2 ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); @@ -16,5 +16,5 @@ const Be::ClassInfo* EveLineContainer::ExposeToBlue() MAP_ATTRIBUTE( "connectors", m_connectors, "", Be::READ | Be::PERSIST ); MAP_ATTRIBUTE( "lineSet", m_lineSet, "", Be::READWRITE | Be::PERSIST ); - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/UI/EveLineSet.cpp b/trinity/Eve/UI/EveLineSet.cpp index e80a96442..122f38f1c 100644 --- a/trinity/Eve/UI/EveLineSet.cpp +++ b/trinity/Eve/UI/EveLineSet.cpp @@ -14,7 +14,7 @@ using namespace Tr2RenderContextEnum; -EveLineSet::EveLineSet( IRoot* lockobj /*= NULL*/ ): +EveLineSet::EveLineSet( IRoot* lockobj /*= NULL*/ ) : m_display( true ), m_boundingSphere( 0.f, 0.f, 0.f, 0.f ), m_vertexDeclHandle( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), @@ -65,7 +65,7 @@ bool EveLineSet::OnPrepareResources() return false; } } - + if( !m_vertexBuffer.IsValid() ) { CR_RETURN_VAL( @@ -75,8 +75,8 @@ bool EveLineSet::OnPrepareResources() Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, - renderContext ) - , false ); + renderContext ), + false ); } void* vertexBuffer; @@ -163,14 +163,14 @@ bool EveLineSet::HasTransparentBatches() return true; } -void EveLineSet::GetBatches( ITriRenderBatchAccumulator* accumulator, - TriBatchType batchType, - const Tr2PerObjectData* perObjectData, - Tr2RenderReason reason ) +void EveLineSet::GetBatches( ITriRenderBatchAccumulator* accumulator, + TriBatchType batchType, + const Tr2PerObjectData* perObjectData, + Tr2RenderReason reason ) { // Is only rendered as transparent or additive. - if( !(batchType == TRIBATCHTYPE_TRANSPARENT && m_isRenderedAsTransparent) && - !(batchType == TRIBATCHTYPE_ADDITIVE && !m_isRenderedAsTransparent)) + if( !( batchType == TRIBATCHTYPE_TRANSPARENT && m_isRenderedAsTransparent ) && + !( batchType == TRIBATCHTYPE_ADDITIVE && !m_isRenderedAsTransparent ) ) { return; } @@ -249,7 +249,7 @@ bool EveLineSet::SubmitChanges() if( m_lines.size() > m_maxCurrentLineCount ) { - // increase the size of the buffer + // increase the size of the buffer m_maxCurrentLineCount = (unsigned int)m_lines.capacity(); ReleaseResources( TRISTORAGE_ALL ); } @@ -268,7 +268,7 @@ bool EveLineSet::SubmitChanges() memcpy( vertexBuffer, &m_lines[0], sizeof( EveLineData ) * m_lines.size() ); m_vertexBuffer.UnmapForWriting( renderContext ); - + m_currentSubmittedLineCount = (unsigned int)m_lines.size(); // also update the bounding sphere here @@ -284,7 +284,7 @@ bool EveLineSet::SubmitChanges() void EveLineSet::RemoveLine( unsigned int id ) { - if( id < m_lines.size() ) + if( id < m_lines.size() ) { m_lines.erase( m_lines.begin() + id ); } diff --git a/trinity/Eve/UI/EveLineSet.h b/trinity/Eve/UI/EveLineSet.h index 6faf25fbb..c79117a2e 100644 --- a/trinity/Eve/UI/EveLineSet.h +++ b/trinity/Eve/UI/EveLineSet.h @@ -27,17 +27,16 @@ struct EveLineData Color m_color2; }; -class EveLineSet : - public IInitialize, - public ITr2Renderable, - public IEveTransform, - public IEveSpaceObject2, - public Tr2DeviceResource +class EveLineSet : public IInitialize, + public ITr2Renderable, + public IEveTransform, + public IEveSpaceObject2, + public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); - EveLineSet(IRoot* lockobj = NULL); + EveLineSet( IRoot* lockobj = NULL ); ~EveLineSet(); ////////////////////////////////////////////////////////////////////////////////////// @@ -51,7 +50,7 @@ class EveLineSet : void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); virtual void GetRenderables( std::vector& renderables ); virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; ///////////////////////////////////////////////////////////////////////////////////// // IEveTransform @@ -59,18 +58,29 @@ class EveLineSet : virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ); // No sensible implementation? - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) {} - virtual void GetModelCenterWorldPosition( Vector3 &position ) const {} - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } - virtual void GetLocalToWorldTransform( Matrix &transform ) const { transform = IdentityMatrix(); } + virtual void UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) + { + } + virtual void GetModelCenterWorldPosition( Vector3& position ) const + { + } + virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ) + { + return false; + } + virtual void GetLocalToWorldTransform( Matrix& transform ) const + { + transform = IdentityMatrix(); + } ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: +public: ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); @@ -78,8 +88,12 @@ class EveLineSet : virtual bool HasTransparentBatches(); virtual float GetSortValue(); virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); - - Tr2Lod GetLODLevel() const { return TR2_LOD_HIGH; } + + Tr2Lod GetLODLevel() const + { + return TR2_LOD_HIGH; + } + private: // name std::string m_name; @@ -107,16 +121,17 @@ class EveLineSet : // Python interface unsigned int AddLine( const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2 ); - void RemoveLine( unsigned int id );; + void RemoveLine( unsigned int id ); + ; void ChangeLine( unsigned int id, const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2 ); void ChangeLineColor( unsigned int id, const Vector4& color1, const Vector4& color2 ); - void ChangeLinePosition(unsigned int id, const Vector3& position1, const Vector3& position2 );; + void ChangeLinePosition( unsigned int id, const Vector3& position1, const Vector3& position2 ); + ; void ClearLines(); - - bool SubmitChanges(); + bool SubmitChanges(); }; TYPEDEF_BLUECLASS( EveLineSet ); diff --git a/trinity/Eve/UI/EveLineSet_Blue.cpp b/trinity/Eve/UI/EveLineSet_Blue.cpp index 6114358fc..bba56aab4 100644 --- a/trinity/Eve/UI/EveLineSet_Blue.cpp +++ b/trinity/Eve/UI/EveLineSet_Blue.cpp @@ -15,78 +15,65 @@ const Be::ClassInfo* EveLineSet::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "A name for this line set", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Toggle visibility for this line set", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "effect", - m_effect, - "The effect to use to draw the particles", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( + "effect", + m_effect, + "The effect to use to draw the particles", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "renderTransparent", m_isRenderedAsTransparent, "Toggles rendering transparently, compared to the default of additive.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "translationCurve", m_ballPosition, "Vector function slot for attaching a destiny ball to set the position of a ship", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotationCurve", m_ballRotation, "Quaternion function slot for attaching a destiny ball to set the rotation of a ship", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "AddLine", - AddLine, + MAP_METHOD_AND_WRAP( + "AddLine", + AddLine, "Adds a line to the line set, but does not submit it. Returns line ID.\n" ":param startPosition: line start position\n" ":param startColor: line start color\n" ":param endPosition: line end position\n" - ":param endColor: line end color\n" - ) - MAP_METHOD_AND_WRAP( - "RemoveLine", - RemoveLine, + ":param endColor: line end color\n" ) + MAP_METHOD_AND_WRAP( + "RemoveLine", + RemoveLine, "Removes a line, requires a call to SubmitChanges before being updated on the video card.\n" - ":param idx: line ID\n" - ) + ":param idx: line ID\n" ) - MAP_METHOD_AND_WRAP( - "ChangeLine", - ChangeLine, + MAP_METHOD_AND_WRAP( + "ChangeLine", + ChangeLine, "Changes the properties of a line. Requires a call to SubmitChanges before it will show up.\n" ":param idx: line ID\n" ":param startPosition: line start position\n" ":param startColor: line start color\n" ":param endPosition: line end position\n" - ":param endColor: line end color\n" - ) - MAP_METHOD_AND_WRAP( - "ChangeLineColor", - ChangeLineColor, + ":param endColor: line end color\n" ) + MAP_METHOD_AND_WRAP( + "ChangeLineColor", + ChangeLineColor, "Changes just the colour of a line. Requires a call to SubmitChanges before it will show up.\n" ":param idx: line ID\n" ":param startColor: line start color\n" - ":param endColor: line end color\n" - ) - MAP_METHOD_AND_WRAP( - "ChangeLinePosition", - ChangeLinePosition, + ":param endColor: line end color\n" ) + MAP_METHOD_AND_WRAP( + "ChangeLinePosition", + ChangeLinePosition, "Changes the start and endpositions of a line. Requires a call to SubmitChanges before it will show up.\n" ":param idx: line ID\n" ":param startPosition: line start position\n" - ":param endPosition: line end position\n" - ) + ":param endPosition: line end position\n" ) MAP_METHOD_AND_WRAP( "ClearLines", ClearLines, "Clears all lines. Requires a call to SubmitChanges to complete." ) MAP_METHOD_AND_WRAP( "SubmitChanges", SubmitChanges, "Submits changes, returning false if it fails for any reason." ) diff --git a/trinity/Eve/UI/EveProjectBracket.cpp b/trinity/Eve/UI/EveProjectBracket.cpp index cd6e82988..0eb0c1134 100644 --- a/trinity/Eve/UI/EveProjectBracket.cpp +++ b/trinity/Eve/UI/EveProjectBracket.cpp @@ -23,7 +23,7 @@ EveProjectBracket::EveProjectBracket( IRoot* lockobj /*= NULL */ ) : m_marginTop( 0.0f ), m_marginBottom( 0.0f ), m_minDispRange( 0.0f ), - m_maxDispRange( FLT_MAX), + m_maxDispRange( FLT_MAX ), m_cameraDistance( 0.0f ), m_offsetX( 0 ), m_offsetY( 0 ), @@ -41,12 +41,12 @@ static Vector3 BicylindricProjection( const Vector3& pos, const TriViewport& vie //horizontal rotation to center. We use vector arithmetic for speed, by just projecting //the vector on the vertical view plane, and then correcting the z coordinate to get the //correct vector length. - float zSq = pos.z*pos.z; + float zSq = pos.z * pos.z; Vector3 v[2] = { //rotate onto vertical plane about the vertical axis - Vector3(0.0f, -pos.y, sqrtf(pos.x*pos.x + zSq)), + Vector3( 0.0f, -pos.y, sqrtf( pos.x * pos.x + zSq ) ), //Same for horizontal - Vector3(pos.x, 0.0f, sqrtf(pos.y*pos.y + zSq)) + Vector3( pos.x, 0.0f, sqrtf( pos.y * pos.y + zSq ) ) }; //now, project both vectors (view already done) @@ -59,7 +59,7 @@ static Vector3 BicylindricProjection( const Vector3& pos, const TriViewport& vie Vector3 res; res.x = v[1].x; res.y = v[0].y; - res.z = (behind? -0.5f : 0.5f)*(v[0].z + v[1].z); + res.z = ( behind ? -0.5f : 0.5f ) * ( v[0].z + v[1].z ); return res; } @@ -84,7 +84,7 @@ void EveProjectBracket::UpdateValue( double time ) pos = TransformCoord( pos, Tr2Renderer::GetViewTransform() ); - bool isInFront = (pos.z <= 0.0f); + bool isInFront = ( pos.z <= 0.0f ); m_isInFront = isInFront; m_cameraDistance = Length( pos ); @@ -97,19 +97,19 @@ void EveProjectBracket::UpdateValue( double time ) float x = projectedPosition.x; float y = projectedPosition.y; - + m_rawProjectedPosition.x = x; m_rawProjectedPosition.y = y; // Brackets behind the camera with the 'dock' flag cleared are hidden - if( (!isInFront && !m_dock) ) + if( ( !isInFront && !m_dock ) ) { SetBracketDisplayState( false ); return; } // Brackets outside the display range are hidden - if( (m_cameraDistance < m_minDispRange) || (m_cameraDistance > m_maxDispRange) ) + if( ( m_cameraDistance < m_minDispRange ) || ( m_cameraDistance > m_maxDispRange ) ) { SetBracketDisplayState( false ); return; @@ -154,11 +154,11 @@ void EveProjectBracket::UpdateValue( double time ) float halfViewportHeight = (float)( vp.height ) * 0.5f; if( y >= halfViewportHeight ) { - y = (y - halfViewportHeight)*1.5f + halfViewportHeight; + y = ( y - halfViewportHeight ) * 1.5f + halfViewportHeight; } else { - y = halfViewportHeight - (halfViewportHeight - y)*1.5f; + y = halfViewportHeight - ( halfViewportHeight - y ) * 1.5f; } if( isInFront ) @@ -184,7 +184,7 @@ void EveProjectBracket::UpdateValue( double time ) } else { - if( x > ( (float)vp.width )*0.5f ) + if( x > ( (float)vp.width ) * 0.5f ) { x = left; } @@ -209,8 +209,8 @@ void EveProjectBracket::UpdateValue( double time ) if( m_integerCoordinates ) { - x = floor( x + 0.5f); - y = floor( y + 0.5f); + x = floor( x + 0.5f ); + y = floor( y + 0.5f ); } if( g_debugRenderer ) @@ -240,7 +240,7 @@ void EveProjectBracket::UpdateValue( double time ) void EveProjectBracket::SetBracketDisplayState( bool state ) { - if( (state == m_isVisible) && m_isVisibleStateSet ) + if( ( state == m_isVisible ) && m_isVisibleStateSet ) { return; } @@ -262,4 +262,3 @@ void EveProjectBracket::SetBracketDisplayState( bool state ) m_displayChangeCallback.CallVoid( this, state ); } } - diff --git a/trinity/Eve/UI/EveProjectBracket.h b/trinity/Eve/UI/EveProjectBracket.h index 93f9d47be..e39e02bcc 100644 --- a/trinity/Eve/UI/EveProjectBracket.h +++ b/trinity/Eve/UI/EveProjectBracket.h @@ -14,8 +14,7 @@ BLUE_DECLARE( Tr2Sprite2dContainer ); BLUE_DECLARE( EveSprite2dBracket ); BLUE_DECLARE_INTERFACE( IWorldPosition ); -class EveProjectBracket : - public ITriFunction +class EveProjectBracket : public ITriFunction { public: EXPOSE_TO_BLUE(); @@ -73,7 +72,7 @@ class EveProjectBracket : // things around without Transform headaches. float m_offsetX; float m_offsetY; - + // The bracket container Tr2Sprite2dContainerPtr m_parent; diff --git a/trinity/Eve/UI/EveProjectBracket_Blue.cpp b/trinity/Eve/UI/EveProjectBracket_Blue.cpp index dc1e6f46a..ff5364c51 100644 --- a/trinity/Eve/UI/EveProjectBracket_Blue.cpp +++ b/trinity/Eve/UI/EveProjectBracket_Blue.cpp @@ -11,198 +11,148 @@ const Be::ClassInfo* EveProjectBracket::ExposeToBlue() EXPOSURE_BEGIN( EveProjectBracket, "Projects a 3D position to 2D for brackets\n:jessica-deprecated: True" ) MAP_INTERFACE( ITriFunction ) MAP_INTERFACE( EveProjectBracket ) - - MAP_ATTRIBUTE - ( + + MAP_ATTRIBUTE( "name", m_name, "Name of this object", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE ) + + MAP_ATTRIBUTE( "trackBall", m_trackBall, "Destiny ball used as source for bracket projection", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "ballTrackingScaling", m_ballTrackingScaling, "A scaling factor to apply to tracking balls", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "trackTransform", m_trackTransform, "The source position in 3D space. Note that 'trackBall' has priority.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "trackPosition", m_trackPosition, "Fixed position to track - used if neither trackBall or trackTransform are set.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "bracket", m_bracket, "The sprite container to receive the projected position", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "bracketIcon", m_bracketIcon, "The sprite to receive the projected position", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "parent", m_parent, "Parent of the sprite container", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "dock", m_dock, "Should the bracket dock on the sides if source is off the screen?" "\nIf not, the visible flag is toggled depending on off-screen status", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "marginLeft", m_marginLeft, "", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "marginRight", m_marginRight, "", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "marginTop", m_marginTop, "", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "marginBottom", m_marginBottom, "", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "minDispRange", m_minDispRange, "Bracket is hidden if the camera is closer to the object than this value", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxDispRange", m_maxDispRange, "Bracket is hidden if the camera is farther from the object than this value", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "cameraDistance", m_cameraDistance, "Distance of projected position to camera.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "offsetX", m_offsetX, "Horizontal offset for the bracket", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "offsetY", m_offsetY, "Vertical offset for the bracket", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "integerCoordinates", m_integerCoordinates, "If true (default), then projected coordinates are rounded to integer coordinates", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "projectedPosition", m_projectedPosition, "The projected 2d position.", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "rawProjectedPosition", m_rawProjectedPosition, "The raw projected 2d position, without any clamping applied.", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "displayChangeCallback", m_displayChangeCallback, "An optional callback that is called whenever the display state of the bracket\n" "is changed. It should be a callable, accepting one boolean argument (the new display state).", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "bracketUpdateCallback", m_bracketUpdateCallback, "An optional callback that is called whenever the bracket is updated while visible", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isVisible", m_isVisible, "Visibility state of projected bracket", - Be::READ - ) - - MAP_ATTRIBUTE - ( + Be::READ ) + + MAP_ATTRIBUTE( "isInFront", m_isInFront, "Flag telling if project bracket is infront or back of the camera", - Be::READ - ) + Be::READ ) EXPOSURE_END() } diff --git a/trinity/Eve/UI/EveSpherePin.cpp b/trinity/Eve/UI/EveSpherePin.cpp index ab4bb66c3..e211792d2 100644 --- a/trinity/Eve/UI/EveSpherePin.cpp +++ b/trinity/Eve/UI/EveSpherePin.cpp @@ -25,7 +25,7 @@ using namespace Tr2RenderContextEnum; std::map* s_treeMap = new std::map(); // ------------------------------------------------------------------------------------------------------ -EveSpherePin::EveSpherePin( IRoot* lockobj /*= NULL*/ ): +EveSpherePin::EveSpherePin( IRoot* lockobj /*= NULL*/ ) : PARENTLOCK( m_curveSets ), m_scaling( 1.f, 1.f, 1.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), @@ -88,14 +88,13 @@ bool EveSpherePin::OnModified( Be::Var* value ) { m_pinEffect->SetEffectPathName( m_pinEffectResPath.c_str() ); } - else - if( IsMatch( value, m_centerNormal ) || - IsMatch( value, m_pinRadius ) || - IsMatch( value, m_pinMaxRadius ) || - IsMatch( value, m_pinRotation ) || - IsMatch( value, m_pinColor ) || - IsMatch( value, m_pinAlphaThreshold ) || - IsMatch( value, m_uvAtlasScaleOffset ) ) + else if( IsMatch( value, m_centerNormal ) || + IsMatch( value, m_pinRadius ) || + IsMatch( value, m_pinMaxRadius ) || + IsMatch( value, m_pinRotation ) || + IsMatch( value, m_pinColor ) || + IsMatch( value, m_pinAlphaThreshold ) || + IsMatch( value, m_uvAtlasScaleOffset ) ) { BuildBoundingSphere(); if( IsMatch( value, m_centerNormal ) || IsMatch( value, m_pinMaxRadius ) ) @@ -126,7 +125,7 @@ void EveSpherePin::CreateIndexBuffer() { std::vector indices; int success = m_tree->GetIndices( m_centerNormal, m_pinMaxRadius, m_primitiveCount, indices ); - + if( !success ) { return; @@ -141,12 +140,12 @@ void EveSpherePin::CreateIndexBuffer() USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN( m_indexBuffer.Create( - 2, - m_primitiveCount * 3, + CR_RETURN( m_indexBuffer.Create( + 2, + m_primitiveCount * 3, Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::NONE, - &indices[0], + &indices[0], renderContext ) ); m_rebuildIndices = 0; @@ -194,7 +193,7 @@ void EveSpherePin::UpdateSyncronous( const EveUpdateContext& updateContext ) { TriGrannyResPtr granny; BeResMan->GetResource( m_geomResPath, "raw", granny ); - if ( granny ) + if( granny ) { if( !( *s_treeMap )[granny] ) { @@ -219,7 +218,6 @@ void EveSpherePin::UpdateSyncronous( const EveUpdateContext& updateContext ) CreateIndexBuffer(); } } - } // ------------------------------------------------------------------------------------------------------ @@ -230,7 +228,7 @@ void EveSpherePin::UpdateAsyncronous( const EveUpdateContext& updateContext ) { for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( TimeAsDouble( updateContext.GetTime() ) ); + ( *it )->Update( TimeAsDouble( updateContext.GetTime() ) ); } } } @@ -278,7 +276,7 @@ void EveSpherePin::GetRenderables( std::vector& renderables, Tr return; } // cull! -// if( frustum.IsSphereVisible( &boundingSphere ) ) + // if( frustum.IsSphereVisible( &boundingSphere ) ) { renderables.push_back( this ); } @@ -305,8 +303,8 @@ bool EveSpherePin::HasTransparentBatches() } // ----------------------------------------------------------------------------- -void EveSpherePin::GetBatches( ITriRenderBatchAccumulator* accumulator, - TriBatchType batchType, +void EveSpherePin::GetBatches( ITriRenderBatchAccumulator* accumulator, + TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { @@ -349,7 +347,7 @@ Tr2PerObjectData* EveSpherePin::GetPerObjectData( ITriRenderBatchAccumulator* ac perObjectData->m_worldMatrix = Transpose( m_worldTransform ); // set all other pin data perObjectData->m_pinPosition = Vector4( m_centerNormal, m_pinRadius ); - perObjectData->m_pinRotation = Vector4( m_pinRotation, 0.f, 0.f, 0.f ); + perObjectData->m_pinRotation = Vector4( m_pinRotation, 0.f, 0.f, 0.f ); perObjectData->m_pinColor = Vector4( m_pinColor.r, m_pinColor.g, m_pinColor.b, m_pinColor.a ); perObjectData->m_pinThreshold = Vector4( m_pinAlphaThreshold, 0.f, 0.f, 0.f ); perObjectData->m_pinRadiusPrecalc = Vector4( sinf( m_pinRadius ), cosf( m_pinRadius ), sinf( m_pinRotation ), cosf( m_pinRotation ) ); diff --git a/trinity/Eve/UI/EveSpherePin.h b/trinity/Eve/UI/EveSpherePin.h index 2384193e5..05dd9a19f 100644 --- a/trinity/Eve/UI/EveSpherePin.h +++ b/trinity/Eve/UI/EveSpherePin.h @@ -46,20 +46,19 @@ class EveSpherePinPerObjectData : public Tr2PerObjectData // SeeAlso: // EvePlanet // -------------------------------------------------------------------------------- -class EveSpherePin : - public IInitialize, - public ITr2Renderable, - public IEveTransform, - public IEveSpaceObject2, - public Tr2DeviceResource, - public IBlueAsyncResNotifyTarget, - public ITr2Pickable, - public INotify +class EveSpherePin : public IInitialize, + public ITr2Renderable, + public IEveTransform, + public IEveSpaceObject2, + public Tr2DeviceResource, + public IBlueAsyncResNotifyTarget, + public ITr2Pickable, + public INotify { public: EXPOSE_TO_BLUE(); - EveSpherePin(IRoot* lockobj = NULL); + EveSpherePin( IRoot* lockobj = NULL ); ~EveSpherePin(); ////////////////////////////////////////////////////////////////////////////////////// @@ -73,34 +72,51 @@ class EveSpherePin : void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); virtual void GetRenderables( std::vector& renderables ); virtual void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ); - virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const; + virtual bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const; ///////////////////////////////////////////////////////////////////////////////////// // IEveTransform virtual void Update( const EveUpdateContext& updateContext ); virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ); - Tr2Lod GetLODLevel() const { return TR2_LOD_HIGH; } + Tr2Lod GetLODLevel() const + { + return TR2_LOD_HIGH; + } ///////////////////////////////////////////////////////////////////////////////////// // INotify bool OnModified( Be::Var* val ); // No sensible implementation? - virtual void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) {} - virtual void GetModelCenterWorldPosition( Vector3 &position ) const {} - virtual bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } - virtual void GetLocalToWorldTransform( Matrix &transform ) const { transform = IdentityMatrix(); } + virtual void UpdateModelCenterWorldPosition( Vector3& position, Be::Time t ) + { + } + virtual void GetModelCenterWorldPosition( Vector3& position ) const + { + } + virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ) + { + return false; + } + virtual void GetLocalToWorldTransform( Matrix& transform ) const + { + transform = IdentityMatrix(); + } ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: +public: ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ///////////////////////////////////////////////////////////////////////////////////// @@ -119,7 +135,7 @@ class EveSpherePin : // geom res void InitializeGeometryResource(); - + private: // name std::string m_name; diff --git a/trinity/Eve/UI/EveSpherePinIndexTree.cpp b/trinity/Eve/UI/EveSpherePinIndexTree.cpp index 5f68f9c90..33e6fbf7f 100644 --- a/trinity/Eve/UI/EveSpherePinIndexTree.cpp +++ b/trinity/Eve/UI/EveSpherePinIndexTree.cpp @@ -20,7 +20,8 @@ struct EveSpherePinIndexTree::TreeNode thetaMax( 0 ), phiMin( 0 ), phiMax( 0 ) - {} + { + } float thetaMin, thetaMax, phiMin, phiMax; @@ -32,13 +33,15 @@ struct EveSpherePinIndexTree::TreeNode struct EveSpherePinIndexTree::Face { - Face( ) : index1( 0 ), index2( 0 ), index3( 0 ), flag( false ), radius( 0.f ) - {} + Face() : + index1( 0 ), index2( 0 ), index3( 0 ), flag( false ), radius( 0.f ) + { + } Vector3 center; float radius; unsigned int index1, index2, index3; - + bool flag; }; @@ -54,13 +57,13 @@ void CreateChildNodes( EveSpherePinIndexTree::TreeNode* node ) node->left->thetaMax = node->thetaMax; node->left->thetaMin = node->thetaMin; - + node->left->phiMin = node->phiMin; node->left->phiMax = medium; node->right->thetaMax = node->thetaMax; node->right->thetaMin = node->thetaMin; - + node->right->phiMin = medium; node->right->phiMax = node->phiMax; } @@ -70,13 +73,13 @@ void CreateChildNodes( EveSpherePinIndexTree::TreeNode* node ) node->left->thetaMax = medium; node->left->thetaMin = node->thetaMin; - + node->left->phiMin = node->phiMin; node->left->phiMax = node->phiMax; node->right->thetaMax = node->thetaMax; node->right->thetaMin = medium; - + node->right->phiMin = node->phiMin; node->right->phiMax = node->phiMax; } @@ -111,7 +114,7 @@ EveSpherePinIndexTree::TreeNode* CreateTree( EveSpherePinIndexTree::TreeNode* no // ------------------------------------------------------------------------------------------------------ inline void CarthesianToSpherical( Vector3& carth, Vector2& spherical ) -{ // spherical = Vector2( theta, phi ) +{ // spherical = Vector2( theta, phi ) float radius = sqrt( Dot( carth, carth ) ); spherical.x = XM_PI / 2.0f - acos( carth.y / radius ); spherical.y = atan2( -carth.z, carth.x ); @@ -122,7 +125,7 @@ bool ExtractVertices( const cmf::Data& cmfData, const void* vbData, std::vector< { auto mesh = cmfData.meshes[0].lods[0]; auto decl = cmfData.meshes[0].decl; - + const cmf::VertexElement* posElem = cmf::FindElement( decl, cmf::Usage::Position ); if( !posElem ) { @@ -165,13 +168,16 @@ EveSpherePinIndexTree::Face* ExtractFaceData( const cmf::Data& cmfData, const vo faces[i].center.x = ( min( min( verts[index1].x, verts[index2].x ), verts[index3].x ) + - max( max( verts[index1].x, verts[index2].x ), verts[index3].x ) ) / 2.0f; + max( max( verts[index1].x, verts[index2].x ), verts[index3].x ) ) / + 2.0f; faces[i].center.y = ( min( min( verts[index1].y, verts[index2].y ), verts[index3].y ) + - max( max( verts[index1].y, verts[index2].y ), verts[index3].y ) ) / 2.0f; + max( max( verts[index1].y, verts[index2].y ), verts[index3].y ) ) / + 2.0f; faces[i].center.z = ( min( min( verts[index1].z, verts[index2].z ), verts[index3].z ) + - max( max( verts[index1].z, verts[index2].z ), verts[index3].z ) ) / 2.0f; + max( max( verts[index1].z, verts[index2].z ), verts[index3].z ) ) / + 2.0f; Vector3 d1( verts[index1] - faces[i].center ); Vector3 d2( verts[index2] - faces[i].center ); @@ -214,9 +220,9 @@ bool ExtractVertices( const granny_mesh& mesh, std::vector& sphericalVe } int numVerts = mesh.PrimaryVertexData->VertexCount; - sphericalVerts.resize(numVerts); - verts.resize(numVerts); - for ( int i = 0; i < numVerts; i++ ) + sphericalVerts.resize( numVerts ); + verts.resize( numVerts ); + for( int i = 0; i < numVerts; i++ ) { Vector3 p1; if( position->Type == GrannyReal16Member ) @@ -255,45 +261,48 @@ EveSpherePinIndexTree::Face* ExtractFaceData( const granny_mesh& mesh, std::vect { return nullptr; } - + EveSpherePinIndexTree::Face* faces = new EveSpherePinIndexTree::Face[numPrim]; - for ( int i = 0; i < numPrim; i++ ) - { + for( int i = 0; i < numPrim; i++ ) + { unsigned int index1 = 0; unsigned int index2 = 0; unsigned int index3 = 0; if( pShortIndices ) { - index1 = pShortIndices[i*3]; - index2 = pShortIndices[(i*3)+1]; - index3 = pShortIndices[(i*3)+2]; + index1 = pShortIndices[i * 3]; + index2 = pShortIndices[( i * 3 ) + 1]; + index3 = pShortIndices[( i * 3 ) + 2]; } else { - index1 = pLongIndices[i*3]; - index2 = pLongIndices[(i*3)+1]; - index3 = pLongIndices[(i*3)+2]; + index1 = pLongIndices[i * 3]; + index2 = pLongIndices[( i * 3 ) + 1]; + index3 = pLongIndices[( i * 3 ) + 2]; } faces[i].index1 = index1; faces[i].index2 = index2; faces[i].index3 = index3; - faces[i].center.x = + faces[i].center.x = ( min( min( verts[index1].x, verts[index2].x ), verts[index3].x ) + - max( max( verts[index1].x, verts[index2].x ), verts[index3].x ) ) / 2.0f; - faces[i].center.y = + max( max( verts[index1].x, verts[index2].x ), verts[index3].x ) ) / + 2.0f; + faces[i].center.y = ( min( min( verts[index1].y, verts[index2].y ), verts[index3].y ) + - max( max( verts[index1].y, verts[index2].y ), verts[index3].y ) ) / 2.0f; - faces[i].center.z = + max( max( verts[index1].y, verts[index2].y ), verts[index3].y ) ) / + 2.0f; + faces[i].center.z = ( min( min( verts[index1].z, verts[index2].z ), verts[index3].z ) + - max( max( verts[index1].z, verts[index2].z ), verts[index3].z ) ) / 2.0f; - - Vector3 d1(verts[index1] - faces[i].center); - Vector3 d2(verts[index2] - faces[i].center); - Vector3 d3(verts[index3] - faces[i].center); + max( max( verts[index1].z, verts[index2].z ), verts[index3].z ) ) / + 2.0f; + + Vector3 d1( verts[index1] - faces[i].center ); + Vector3 d2( verts[index2] - faces[i].center ); + Vector3 d3( verts[index3] - faces[i].center ); faces[i].radius = Length( d1 ); faces[i].radius = max( faces[i].radius, Length( d2 ) ); faces[i].radius = max( faces[i].radius, Length( d3 ) ); @@ -306,16 +315,16 @@ EveSpherePinIndexTree::Face* ExtractFaceData( const granny_mesh& mesh, std::vect // ------------------------------------------------------------------------------------------------------ int OverlapTest( EveSpherePinIndexTree::TreeNode* n, EveSpherePinIndexTree::Face* f, std::vector& vertices ) { - float maxTheta = max( vertices[f->index1].x, max( vertices[f->index2].x, vertices[f->index3].x) ); - float minTheta = min( vertices[f->index1].x, min( vertices[f->index2].x, vertices[f->index3].x) ); - float maxPhi = max( vertices[f->index1].y, max( vertices[f->index2].y, vertices[f->index3].y) ); - float minPhi = min( vertices[f->index1].y, min( vertices[f->index2].y, vertices[f->index3].y) ); - - if( (maxPhi - minPhi) > XM_PI ) + float maxTheta = max( vertices[f->index1].x, max( vertices[f->index2].x, vertices[f->index3].x ) ); + float minTheta = min( vertices[f->index1].x, min( vertices[f->index2].x, vertices[f->index3].x ) ); + float maxPhi = max( vertices[f->index1].y, max( vertices[f->index2].y, vertices[f->index3].y ) ); + float minPhi = min( vertices[f->index1].y, min( vertices[f->index2].y, vertices[f->index3].y ) ); + + if( ( maxPhi - minPhi ) > XM_PI ) { float temp = minPhi; minPhi = maxPhi; - maxPhi = temp + 2*XM_PI; + maxPhi = temp + 2 * XM_PI; } int phiOverlap = 0; @@ -323,7 +332,7 @@ int OverlapTest( EveSpherePinIndexTree::TreeNode* n, EveSpherePinIndexTree::Face { phiOverlap = 1; } - else if( minPhi < n->phiMax && minPhi >= n->phiMin ) + else if( minPhi < n->phiMax && minPhi >= n->phiMin ) { phiOverlap = 1; } @@ -343,13 +352,13 @@ int OverlapTest( EveSpherePinIndexTree::TreeNode* n, EveSpherePinIndexTree::Face // ------------------------------------------------------------------------------------------------------ int OverlapTest( EveSpherePinIndexTree::TreeNode* n, float minTheta, float maxTheta, float minPhi, float maxPhi ) -{ +{ int phiOverlap = 0; if( minPhi < n->phiMin && maxPhi > n->phiMin ) { phiOverlap = 1; } - else if( minPhi < n->phiMax && minPhi >= n->phiMin ) + else if( minPhi < n->phiMax && minPhi >= n->phiMin ) { phiOverlap = 1; } @@ -411,7 +420,7 @@ EveSpherePinIndexTree::EveSpherePinIndexTree( TriGrannyRes* granny ) : } // ------------------------------------------------------------------------------------------------------ -EveSpherePinIndexTree::~EveSpherePinIndexTree(void) +EveSpherePinIndexTree::~EveSpherePinIndexTree( void ) { if( m_tree ) { @@ -546,12 +555,12 @@ int EveSpherePinIndexTree::MarkFaces( EveSpherePinIndexTree::TreeNode* node, flo return faceCount; } - + for( std::vector::const_iterator it = node->faces.begin(); it != node->faces.end(); ++it ) { - if( !((*it)->flag) ) + if( !( ( *it )->flag ) ) { - (*it)->flag = 1; + ( *it )->flag = 1; faceCount++; m_markedFaces.push_back( *it ); } @@ -568,11 +577,11 @@ int EveSpherePinIndexTree::GetIndices( Vector3& point, float radius, int& primit return 0; } - Vector3 pole(0,1,0); + Vector3 pole( 0, 1, 0 ); Vector2 p, phiMinSC, phiMaxSC; CarthesianToSpherical( point, p ); - + float minTheta = p.x - radius; float maxTheta = p.x + radius; float minPhi; @@ -608,7 +617,7 @@ int EveSpherePinIndexTree::GetIndices( Vector3& point, float radius, int& primit maxPhi = p.y + radius / cos( minTheta ); } } - + if( maxPhi > PHI_MAX ) { primitives = MarkFaces( m_tree, minTheta, maxTheta, minPhi, PHI_MAX ) + MarkFaces( m_tree, minTheta, maxTheta, PHI_MIN, maxPhi - 2 * XM_PI ); @@ -624,19 +633,19 @@ int EveSpherePinIndexTree::GetIndices( Vector3& point, float radius, int& primit indices.resize( primitives * 3 ); int rejected = 0; - + for( int i = 0; i < primitives; i++ ) { - Face* face = m_markedFaces[i]; + Face* face = m_markedFaces[i]; face->flag = 0; - Vector3 d(face->center - point ); + Vector3 d( face->center - point ); float len = Length( d ); if( len <= radius + face->radius ) { - indices[(i - rejected) * 3] = face->index1; - indices[(i - rejected) * 3 + 1] = face->index2; - indices[(i - rejected) * 3 + 2] = face->index3; + indices[( i - rejected ) * 3] = face->index1; + indices[( i - rejected ) * 3 + 1] = face->index2; + indices[( i - rejected ) * 3 + 2] = face->index3; } else { diff --git a/trinity/Eve/UI/EveSpherePinIndexTree.h b/trinity/Eve/UI/EveSpherePinIndexTree.h index 691bd4f88..f80f91dab 100644 --- a/trinity/Eve/UI/EveSpherePinIndexTree.h +++ b/trinity/Eve/UI/EveSpherePinIndexTree.h @@ -14,12 +14,16 @@ class EveSpherePinIndexTree struct TreeNode; explicit EveSpherePinIndexTree( TriGrannyRes* granny ); - ~EveSpherePinIndexTree(void); + ~EveSpherePinIndexTree( void ); int Initialize(); int GetIndices( Vector3& point, float radius, int& primitives, std::vector& indices ); - int IsInitialized() { return m_initialized; } + int IsInitialized() + { + return m_initialized; + } + private: TriGrannyResPtr m_granny; @@ -30,7 +34,7 @@ class EveSpherePinIndexTree Face* m_faces; int m_initialized; - + std::vector m_markedFaces; int MarkFaces( TreeNode* node, float minTheta, float maxTheta, float minPhi, float maxPhi ); diff --git a/trinity/Eve/UI/EveSpherePin_Blue.cpp b/trinity/Eve/UI/EveSpherePin_Blue.cpp index 08c0524fd..3b0dd7eb0 100644 --- a/trinity/Eve/UI/EveSpherePin_Blue.cpp +++ b/trinity/Eve/UI/EveSpherePin_Blue.cpp @@ -40,9 +40,9 @@ const Be::ClassInfo* EveSpherePin::ExposeToBlue() MAP_ATTRIBUTE( "pinMaxRadius", m_pinMaxRadius, "radius of the pin on the sphere surface in radians, this is the size used by the geometry and should be set as rarely as possible", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "pinRotation", m_pinRotation, "rotation of the pin on the sphere surface in radians", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "pinColor", m_pinColor, "color modulation", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE( "color", m_pinColor, "color modulation", Be::READWRITE | Be::NOTIFY | Be::PERSIST) + MAP_ATTRIBUTE( "color", m_pinColor, "color modulation", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "pinAlphaThreshold", m_pinAlphaThreshold, "special alpha value that can be used to show a progress bar", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - + MAP_ATTRIBUTE( "primitiveCount", m_primitiveCount, "", Be::READ ) EXPOSURE_END() diff --git a/trinity/Eve/UI/EveTacticalOverlay.cpp b/trinity/Eve/UI/EveTacticalOverlay.cpp index f2775ca23..6d7b8437a 100644 --- a/trinity/Eve/UI/EveTacticalOverlay.cpp +++ b/trinity/Eve/UI/EveTacticalOverlay.cpp @@ -142,7 +142,7 @@ void EveTacticalOverlay::RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer } } -void EveTacticalOverlay::UpdateSyncronous( const EveUpdateContext& updateContext ) +void EveTacticalOverlay::UpdateSyncronous( const EveUpdateContext& updateContext ) { if( m_positionCurve ) { @@ -152,7 +152,7 @@ void EveTacticalOverlay::UpdateSyncronous( const EveUpdateContext& updateContext for( auto it = m_trackObjects.begin(); it != m_trackObjects.end(); it++ ) { - (*it)->UpdatePosition( updateContext ); + ( *it )->UpdatePosition( updateContext ); } RegisterVariables(); } @@ -220,7 +220,7 @@ void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext m_connectorBuffer.clear(); m_anchorBuffer.clear(); m_velocityBuffer.clear(); - + Vector3 up( 0, 1, 0 ); float distanceThreshold = ( m_ranges.x + m_ranges.y ) * m_ranges.z; float requestedSegments = 0.f; @@ -228,8 +228,8 @@ void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext for( auto it = m_trackObjects.begin(); it != m_trackObjects.end(); it++ ) { - Vector3 position = (*it)->GetPosition(); - float radius = (*it)->GetRadius(); + Vector3 position = ( *it )->GetPosition(); + float radius = ( *it )->GetRadius(); Vector3 direction = position - m_rootPosition; float distance = Length( direction ); if( distance > distanceThreshold ) @@ -239,7 +239,7 @@ void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext direction.y = 0; direction = Normalize( direction ); - if( !(direction.x || direction.z) ) + if( !( direction.x || direction.z ) ) { direction.x = 0.01; } @@ -250,7 +250,7 @@ void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext { continue; } - + float pixelDiameter = frustum.GetPixelSizeAccross( &bs ); float segments = GetSubdivisionCount( pixelDiameter, m_connectorSegmentsLow, m_connectorSegmentsMedium, m_connectorSegmentsHigh, updateContext ); if( segments != 0 ) @@ -283,27 +283,27 @@ void EveTacticalOverlay::UpdateVisibility( const EveUpdateContext& updateContext float segmentInfo = segments * 256.f + j; vtx.instanceData = Vector4( position, segmentInfo ); vtx.instanceData2 = floor( radius ) + interestReducedIntensity; - m_connectorBuffer.push_back(vtx); + m_connectorBuffer.push_back( vtx ); } // Object properties(radius and movement) for( float i = 0; i < 3; i++ ) { - if( i == 1.f && !((*it)->IsAggressive()) ) + if( i == 1.f && !( ( *it )->IsAggressive() ) ) { continue; } - if( i == 0.f && !((*it)->ShowVelocity())) + if( i == 0.f && !( ( *it )->ShowVelocity() ) ) { continue; } VelocityConnectorVertex vtx; vtx.instanceData = Vector4( position, i ); float blink = i == 1 ? 0.9f : 0.f; - vtx.instanceData2 = Vector4( (*it)->GetVelocity(), floor( radius ) + blink ); + vtx.instanceData2 = Vector4( ( *it )->GetVelocity(), floor( radius ) + blink ); m_velocityBuffer.push_back( vtx ); } } - + VelocityConnectorVertex vtx; // Add velocity for your ship vtx.instanceData = Vector4( m_rootPosition, 0.f ); @@ -338,4 +338,3 @@ void EveTacticalOverlay::AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2Q quadRenderer.AddQuads( m_anchorEffectHash, m_anchorBuffer.data(), m_anchorBuffer.size() ); quadRenderer.AddQuads( m_velocityEffectHash, m_velocityBuffer.data(), m_velocityBuffer.size() ); } - diff --git a/trinity/Eve/UI/EveTacticalOverlay.h b/trinity/Eve/UI/EveTacticalOverlay.h index 3502bed86..74fcb7187 100644 --- a/trinity/Eve/UI/EveTacticalOverlay.h +++ b/trinity/Eve/UI/EveTacticalOverlay.h @@ -11,21 +11,38 @@ BLUE_DECLARE( Tr2Effect ); -BLUE_CLASS( EveTacticalOverlayTrackObject ): +BLUE_CLASS( EveTacticalOverlayTrackObject ) : public IRoot { public: EXPOSE_TO_BLUE(); EveTacticalOverlayTrackObject( IRoot* lockobj = NULL ); - ~EveTacticalOverlayTrackObject() {} + ~EveTacticalOverlayTrackObject() + { + } void UpdatePosition( const EveUpdateContext& updateContext ); - inline Vector3 GetVelocity() const { return m_velocity; } - inline Vector3 GetPosition() const { return m_position; } - inline float GetRadius() const { return m_radius; } - inline bool IsAggressive() const { return m_aggressive; } - inline bool ShowVelocity() const { return m_showVelocity; } + inline Vector3 GetVelocity() const + { + return m_velocity; + } + inline Vector3 GetPosition() const + { + return m_position; + } + inline float GetRadius() const + { + return m_radius; + } + inline bool IsAggressive() const + { + return m_aggressive; + } + inline bool ShowVelocity() const + { + return m_showVelocity; + } private: ITriVectorFunctionPtr m_positionCurve; @@ -61,36 +78,53 @@ BLUE_CLASS( EveTacticalOverlay ) : Vector4 instanceData; static const Tr2VertexDefinition& GetDefinition(); }; - + struct VelocityConnectorVertex { Vector4 instanceData; Vector4 instanceData2; static const Tr2VertexDefinition& GetDefinition(); }; - + ///////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 void UpdateSyncronous( const EveUpdateContext& updateContext ); - void UpdateAsyncronous( const EveUpdateContext& updateContext ) {} + void UpdateAsyncronous( const EveUpdateContext& updateContext ) + { + } void UpdateVisibility( const EveUpdateContext& updateContext, const Matrix& parentTransform ); - void GetRenderables( std::vector& renderables, Tr2ImpostorManager* impostors ){}; - bool GetBoundingSphere( Vector4& sphere, BoundingSphereQuery query=EVE_BOUNDS_NORMAL ) const { return false; } - void UpdateModelCenterWorldPosition( Vector3 &position, Be::Time t ) { position = Vector3( 0.f, 0.f, 0.f ); } - void GetModelCenterWorldPosition( Vector3 &position ) const { position = Vector3( 0.f, 0.f, 0.f ); } - bool GetLocalBoundingBox( Vector3 &min, Vector3 &max ) { return false; } - void GetLocalToWorldTransform( Matrix &transform ) const { transform = IdentityMatrix(); } + void GetRenderables( std::vector & renderables, Tr2ImpostorManager * impostors ){}; + bool GetBoundingSphere( Vector4 & sphere, BoundingSphereQuery query = EVE_BOUNDS_NORMAL ) const + { + return false; + } + void UpdateModelCenterWorldPosition( Vector3 & position, Be::Time t ) + { + position = Vector3( 0.f, 0.f, 0.f ); + } + void GetModelCenterWorldPosition( Vector3 & position ) const + { + position = Vector3( 0.f, 0.f, 0.f ); + } + bool GetLocalBoundingBox( Vector3 & min, Vector3 & max ) + { + return false; + } + void GetLocalToWorldTransform( Matrix & transform ) const + { + transform = IdentityMatrix(); + } // Registers an object and its attachments with the quad renderer - virtual void RegisterWithQuadRenderer( Tr2QuadRenderer& quadRenderer ); + virtual void RegisterWithQuadRenderer( Tr2QuadRenderer & quadRenderer ); // Adds quads from space object and its attachments to the quad renderer. ATTENTION: this function is called in-parallel virtual void AddQuadsToQuadRenderer( const TriFrustum& frustum, Tr2QuadRenderer& quadRenderer ); @@ -117,7 +151,7 @@ BLUE_CLASS( EveTacticalOverlay ) : float m_interestRange; float m_outsideInterestIntensity; - + // minimum radius of an object for us to bother drawing a radius line for it float m_minRadiusForRange; // x - active range; y - fadeout length; z - multiplier for range and fadeout; w - source radius @@ -128,11 +162,11 @@ BLUE_CLASS( EveTacticalOverlay ) : ITriVectorFunctionPtr m_positionCurve; Vector3 m_rootPosition; Vector3 m_rootVelocity; - + // local variable store for passing parameters to effects Tr2VariableStorePtr m_variableStore; void RegisterVariables(); - void SetVariableStore( Tr2Effect* effect ); + void SetVariableStore( Tr2Effect * effect ); }; TYPEDEF_BLUECLASS( EveTacticalOverlay ); diff --git a/trinity/Eve/UI/EveTacticalOverlay_Blue.cpp b/trinity/Eve/UI/EveTacticalOverlay_Blue.cpp index 00e85dd14..60a9309bc 100644 --- a/trinity/Eve/UI/EveTacticalOverlay_Blue.cpp +++ b/trinity/Eve/UI/EveTacticalOverlay_Blue.cpp @@ -4,30 +4,29 @@ #include "EveTacticalOverlay.h" BLUE_DEFINE( EveTacticalOverlayTrackObject ); -const Be::ClassInfo* EveTacticalOverlayTrackObject::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveTacticalOverlayTrackObject, "" ) - MAP_INTERFACE( EveTacticalOverlayTrackObject ) +const Be::ClassInfo* EveTacticalOverlayTrackObject::ExposeToBlue(){ + EXPOSURE_BEGIN( EveTacticalOverlayTrackObject, "" ) + MAP_INTERFACE( EveTacticalOverlayTrackObject ) - MAP_ATTRIBUTE( "translationCurve", m_positionCurve, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "radius", m_radius, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "isAggressive", m_aggressive, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "showVelocity", m_showVelocity, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "translationCurve", m_positionCurve, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "radius", m_radius, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isAggressive", m_aggressive, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "showVelocity", m_showVelocity, "", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( EveTacticalOverlay ); const Be::ClassInfo* EveTacticalOverlay::ExposeToBlue() { - EXPOSURE_BEGIN( EveTacticalOverlay, "" ) - MAP_INTERFACE( EveTacticalOverlay ) - MAP_INTERFACE( IEveSpaceObject2 ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( EveTacticalOverlay, "" ) + MAP_INTERFACE( EveTacticalOverlay ) + MAP_INTERFACE( IEveSpaceObject2 ) + MAP_INTERFACE( IInitialize ) MAP_ATTRIBUTE( "trackObjects", m_trackObjects, "", Be::READ ) MAP_ATTRIBUTE( "interestObject", m_interestObject, "", Be::READWRITE ) - + MAP_ATTRIBUTE( "anchorEffect", m_anchorEffect, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "connectorEffect", m_connectorEffect, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "velocityEffect", m_velocityEffect, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -36,11 +35,11 @@ const Be::ClassInfo* EveTacticalOverlay::ExposeToBlue() MAP_ATTRIBUTE( "rangeFadeLength", m_ranges.y, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rangeMultiplier", m_ranges.z, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "sourceRadius", m_ranges.w, "", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "interestRange", m_interestRange, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "outsideInterestIntensity", m_outsideInterestIntensity, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minRadiusForRange", m_minRadiusForRange, "", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "segmentsLow", m_connectorSegmentsLow, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "segmentsMedium", m_connectorSegmentsMedium, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "segmentsHigh", m_connectorSegmentsHigh, "", Be::READWRITE | Be::PERSIST ) @@ -52,5 +51,5 @@ const Be::ClassInfo* EveTacticalOverlay::ExposeToBlue() MAP_ATTRIBUTE( "translationCurve", m_positionCurve, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldPosition", m_rootPosition, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/UI/EveTacticalTrails.cpp b/trinity/Eve/UI/EveTacticalTrails.cpp index 3cb41977b..62bef200b 100644 --- a/trinity/Eve/UI/EveTacticalTrails.cpp +++ b/trinity/Eve/UI/EveTacticalTrails.cpp @@ -119,7 +119,7 @@ void EveTacticalTrails::UpdateSyncronous( const EveUpdateContext& updateContext if( object.positions.size() >= 2 ) { auto it = begin( object.positions ); - while ( it + 1 != end( object.positions ) && TimeAsFloat( now - ( it + 1 )->time ) > m_fadeOutTime ) + while( it + 1 != end( object.positions ) && TimeAsFloat( now - ( it + 1 )->time ) > m_fadeOutTime ) { ++it; } @@ -173,8 +173,7 @@ void EveTacticalTrails::UpdateSyncronous( const EveUpdateContext& updateContext void EveTacticalTrails::UpdateGraphicsState( Be::Time now ) { - m_segmentCount = accumulate( m_trackedObjects.begin(), m_trackedObjects.end(), 0u, - []( uint32_t sum, const auto& object ) { return sum + static_cast( std::max( object.positions.size(), size_t( 1 ) ) - 1 ); } ); + m_segmentCount = accumulate( m_trackedObjects.begin(), m_trackedObjects.end(), 0u, []( uint32_t sum, const auto& object ) { return sum + static_cast( std::max( object.positions.size(), size_t( 1 ) ) - 1 ); } ); if( m_segmentCount == 0 ) { return; @@ -299,7 +298,7 @@ void EveTacticalTrails::GetLocalToWorldTransform( Matrix& transform ) const void EveTacticalTrails::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { - if ( batchType != TRIBATCHTYPE_TRANSPARENT ) + if( batchType != TRIBATCHTYPE_TRANSPARENT ) { return; } diff --git a/trinity/Eve/UI/EveTacticalTrails.h b/trinity/Eve/UI/EveTacticalTrails.h index 66d14dae5..4ef23c63d 100644 --- a/trinity/Eve/UI/EveTacticalTrails.h +++ b/trinity/Eve/UI/EveTacticalTrails.h @@ -18,8 +18,8 @@ BLUE_CLASS( EveTacticalTrails ) : EveTacticalTrails( IRoot* lockobj = nullptr ); - void RegisterObject( ITriVectorFunction* object ); - void UnregisterObject( ITriVectorFunction* object ); + void RegisterObject( ITriVectorFunction * object ); + void UnregisterObject( ITriVectorFunction * object ); ///////////////////////////////////////////////////////////////////////////////////// // IEveSpaceObject2 diff --git a/trinity/Eve/UI/EveTacticalTrails_Blue.cpp b/trinity/Eve/UI/EveTacticalTrails_Blue.cpp index b8ab4c3b0..70dfeb0ec 100644 --- a/trinity/Eve/UI/EveTacticalTrails_Blue.cpp +++ b/trinity/Eve/UI/EveTacticalTrails_Blue.cpp @@ -19,19 +19,17 @@ const Be::ClassInfo* EveTacticalTrails::ExposeToBlue() MAP_ATTRIBUTE( "segments", m_segmentCount, "Number of segments rendered, for debugging", Be::READ ) - MAP_METHOD_AND_WRAP( - "RegisterObject", - RegisterObject, + MAP_METHOD_AND_WRAP( + "RegisterObject", + RegisterObject, "Registers a new object with the trail system. After registering the object will leave trails when it moves.\n" "The object is supposed to be a Destiny ball for a ship.\n\n" - ":param obj: The object to register\n" - ) - MAP_METHOD_AND_WRAP( - "UnregisterObject", - UnregisterObject, + ":param obj: The object to register\n" ) + MAP_METHOD_AND_WRAP( + "UnregisterObject", + UnregisterObject, "Unregisters a previously registered object from the trails system. The trails left by the object prior to\n" "unregistering will fade out over time.\n\n" - ":param obj: The object to unregister\n" - ) + ":param obj: The object to unregister\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/UI/EveUiObject.cpp b/trinity/Eve/UI/EveUiObject.cpp index 6776021d7..8c509681d 100644 --- a/trinity/Eve/UI/EveUiObject.cpp +++ b/trinity/Eve/UI/EveUiObject.cpp @@ -83,7 +83,7 @@ void EveUiObject::SetVisibilityForArea( const char* areaName, bool enable ) // find all areas with the provided name and toggle visibility for( uint32_t i = 0; i < TRIBATCHTYPE_COUNT_OF_BATCH_TYPES; ++i ) { - const Tr2MeshAreaVector* areas = mesh->GetAreas( ( TriBatchType)i ); + const Tr2MeshAreaVector* areas = mesh->GetAreas( (TriBatchType)i ); if( areas ) { for( Tr2MeshAreaVector::const_iterator it = areas->begin(); it != areas->end(); ++it ) diff --git a/trinity/Eve/UI/EveUiObject.h b/trinity/Eve/UI/EveUiObject.h index 6434227db..8c1628416 100644 --- a/trinity/Eve/UI/EveUiObject.h +++ b/trinity/Eve/UI/EveUiObject.h @@ -4,7 +4,7 @@ #include "Eve/SpaceObject/EveSpaceObject2.h" -BLUE_CLASS( EveUiObject ): +BLUE_CLASS( EveUiObject ) : public EveSpaceObject2 { public: @@ -28,4 +28,3 @@ BLUE_CLASS( EveUiObject ): }; TYPEDEF_BLUECLASS( EveUiObject ); - diff --git a/trinity/Eve/UI/EveUiObject_Blue.cpp b/trinity/Eve/UI/EveUiObject_Blue.cpp index 23ab31858..1d75cc721 100644 --- a/trinity/Eve/UI/EveUiObject_Blue.cpp +++ b/trinity/Eve/UI/EveUiObject_Blue.cpp @@ -13,13 +13,11 @@ const Be::ClassInfo* EveUiObject::ExposeToBlue() MAP_ATTRIBUTE( "usePerspectiveScale", m_usePerspectiveScale, "Use distance-based scaling (perspective)", Be::READWRITE ); - MAP_METHOD_AND_WRAP( "GetNameForPickingAreaID", GetNameForPickingAreaID, - "Get a unique name for the area ID provided by the scene picking\n" - ":param areaID: index provided by the picking" ) - MAP_METHOD_AND_WRAP( "SetVisibilityForArea", SetVisibilityForArea, - "Change visibility of an area of this object\n" - ":param areaName: name of the area\n" - ":param enable: enable or disable rendering" ) + MAP_METHOD_AND_WRAP( "GetNameForPickingAreaID", GetNameForPickingAreaID, "Get a unique name for the area ID provided by the scene picking\n" + ":param areaID: index provided by the picking" ) + MAP_METHOD_AND_WRAP( "SetVisibilityForArea", SetVisibilityForArea, "Change visibility of an area of this object\n" + ":param areaName: name of the area\n" + ":param enable: enable or disable rendering" ) EXPOSURE_CHAINTO( EveSpaceObject2 ) } \ No newline at end of file diff --git a/trinity/Eve/VirtualCamera/EveVirtualCamera.cpp b/trinity/Eve/VirtualCamera/EveVirtualCamera.cpp index 14e4a7026..0417754d2 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCamera.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCamera.cpp @@ -12,95 +12,95 @@ namespace { - static const Vector3 UP = Vector3(0, 1, 0); - static const Vector3 RIGHT = Vector3(1, 0, 0); - static const Vector3 FORWARD = Vector3(0, 0, 1); - static const float DEBUG_SCALAR = 0.01f; - static const float SCRUB_INCREMENT_DT = 1.0f / 60.0f; - static const int SCRUB_MAX_ITERATIONS = 20; - static const uint32_t DEBUG_COLOR_SUCCESS = 0xffaa9911; - static const uint32_t DEBUG_COLOR_FAIL = 0xffff0000; - static const Tr2DebugColor DEBUG_COLOR = Tr2DebugColor( DEBUG_COLOR_SUCCESS, DEBUG_COLOR_FAIL ); - // Little buffer space between the camera position and the debug gizmos so they aren't visible when - // looking through the camera, regardless of near clipping plane. - static const float DEBUG_BORDER_SIZE = 0.1f; - - Vector3 GetCenterOfAnchors( const PIEveSpaceObject2Vector& anchors ) +static const Vector3 UP = Vector3( 0, 1, 0 ); +static const Vector3 RIGHT = Vector3( 1, 0, 0 ); +static const Vector3 FORWARD = Vector3( 0, 0, 1 ); +static const float DEBUG_SCALAR = 0.01f; +static const float SCRUB_INCREMENT_DT = 1.0f / 60.0f; +static const int SCRUB_MAX_ITERATIONS = 20; +static const uint32_t DEBUG_COLOR_SUCCESS = 0xffaa9911; +static const uint32_t DEBUG_COLOR_FAIL = 0xffff0000; +static const Tr2DebugColor DEBUG_COLOR = Tr2DebugColor( DEBUG_COLOR_SUCCESS, DEBUG_COLOR_FAIL ); +// Little buffer space between the camera position and the debug gizmos so they aren't visible when +// looking through the camera, regardless of near clipping plane. +static const float DEBUG_BORDER_SIZE = 0.1f; + +Vector3 GetCenterOfAnchors( const PIEveSpaceObject2Vector& anchors ) +{ + if( anchors.size() == 0 ) { - if( anchors.size() == 0 ) + return Vector3( 0, 0, 0 ); + } + else + { + Vector3d center = Vector3d( 0, 0, 0 ); // using doubles because precision. + for( auto it = anchors.begin(); it != anchors.end(); ++it ) { - return Vector3( 0, 0, 0 ); + Vector3 out; + ( *it )->GetModelCenterWorldPosition( out ); + center += out; } - else + center /= (double)anchors.size(); + return Vector3( (float)center.x, (float)center.y, (float)center.z ); + } +} + +float GetAnchorsBoundingSphereRadius( const PIEveSpaceObject2Vector& anchors, const Vector3& center ) +{ + if( anchors.size() == 0 ) + { + // If behaviours are relative to the bounding sphere radius but we don't have one, might as well let them + // work in kilometers. Space is pretty big after all. + return 1000.0f; + } + else + { + float radius = 0.0f; + for( auto it = anchors.begin(); it != anchors.end(); ++it ) { - Vector3d center = Vector3d(0, 0, 0); // using doubles because precision. - for( auto it = anchors.begin(); it != anchors.end(); ++it ) + Vector4 bs; + if( ( *it )->GetBoundingSphere( bs ) ) { - Vector3 out; - ( *it )->GetModelCenterWorldPosition( out ); - center += out; + Vector3 objCenter; + ( *it )->GetModelCenterWorldPosition( objCenter ); + float dist = Length( objCenter - center ) + bs.w; + radius = std::max( dist, radius ); } - center /= (double)anchors.size(); - return Vector3( (float)center.x, (float)center.y, (float)center.z ); } - } - - float GetAnchorsBoundingSphereRadius( const PIEveSpaceObject2Vector& anchors, const Vector3& center ) - { - if( anchors.size() == 0 ) + if( radius == 0.0f ) { - // If behaviours are relative to the bounding sphere radius but we don't have one, might as well let them - // work in kilometers. Space is pretty big after all. return 1000.0f; } else { - float radius = 0.0f; - for( auto it = anchors.begin(); it != anchors.end(); ++it ) - { - Vector4 bs; - if( ( *it )->GetBoundingSphere( bs ) ) - { - Vector3 objCenter; - ( *it )->GetModelCenterWorldPosition( objCenter ); - float dist = Length( objCenter - center ) + bs.w; - radius = std::max(dist, radius); - } - } - if(radius == 0.0f) - { - return 1000.0f; - } - else - { - return radius; - } + return radius; } } +} - Vector3 GetForwardDirectionOfAnchors( const PIEveSpaceObject2Vector& anchors ) +Vector3 GetForwardDirectionOfAnchors( const PIEveSpaceObject2Vector& anchors ) +{ + if( anchors.size() == 0 ) { - if( anchors.size() == 0 ) - { - return Vector3( 0, 0, 1 ); - } - else + return Vector3( 0, 0, 1 ); + } + else + { + Vector3d forward = Vector3d( 0, 0, 0 ); // using doubles because precision. + for( auto it = anchors.begin(); it != anchors.end(); ++it ) { - Vector3d forward = Vector3d(0, 0, 0); // using doubles because precision. - for( auto it = anchors.begin(); it != anchors.end(); ++it ) - { - Matrix out; - ( *it )->GetLocalToWorldTransform( out ); - Vector3 fwd; - auto tmp = RotationQuaternion( out ); // apple-clang complains about "taking address of temporary" - TriVectorRotateQuaternion( &fwd, &FORWARD, &tmp ); - forward += Normalize( fwd ); - } - forward /= (double)anchors.size(); - return Normalize( Vector3( (float)forward.x, 0, (float)forward.z ) ); + Matrix out; + ( *it )->GetLocalToWorldTransform( out ); + Vector3 fwd; + auto tmp = RotationQuaternion( out ); // apple-clang complains about "taking address of temporary" + TriVectorRotateQuaternion( &fwd, &FORWARD, &tmp ); + forward += Normalize( fwd ); } + forward /= (double)anchors.size(); + return Normalize( Vector3( (float)forward.x, 0, (float)forward.z ) ); } } +} EveVirtualCamera::EveVirtualCamera( IRoot* lockobj ) : PARENTLOCK( m_positionBehaviours ), @@ -109,14 +109,14 @@ EveVirtualCamera::EveVirtualCamera( IRoot* lockobj ) : PARENTLOCK( m_rollBehaviours ), PARENTLOCK( m_positionAnchors ), PARENTLOCK( m_pointOfInterestAnchors ), - m_name("Virtual Camera"), - m_isRunning(false), - m_fov(1.0f), - m_roll(0.0f), - m_position(0, 0, 0), - m_pointOfInterest(0, 0, 0), - m_localElapsedTime(0.0f), - m_animationTimelineLength(10.0f), + m_name( "Virtual Camera" ), + m_isRunning( false ), + m_fov( 1.0f ), + m_roll( 0.0f ), + m_position( 0, 0, 0 ), + m_pointOfInterest( 0, 0, 0 ), + m_localElapsedTime( 0.0f ), + m_animationTimelineLength( 10.0f ), m_projection(), m_positionAnchorCenter(), m_positionAnchorRadius(), @@ -160,8 +160,8 @@ Vector3 EveVirtualCamera::GetUpDirection() const Vector3 up = Normalize( Cross( right, viewDir ) ); Quaternion roll = RotationQuaternion( viewDir, XMConvertToRadians( -m_roll ) ); - TriVectorRotateQuaternion(&up, &up, &roll); - return Normalize(up); + TriVectorRotateQuaternion( &up, &up, &roll ); + return Normalize( up ); } Vector3 EveVirtualCamera::GetRightDirection() const @@ -245,7 +245,7 @@ void EveVirtualCamera::Update( float deltaTime ) void EveVirtualCamera::Play() { - if(m_isRunning) + if( m_isRunning ) { return; } @@ -255,7 +255,7 @@ void EveVirtualCamera::Play() void EveVirtualCamera::Pause() { - if(!m_isRunning) + if( !m_isRunning ) { return; } @@ -266,7 +266,7 @@ void EveVirtualCamera::Pause() void EveVirtualCamera::Stop() { Reset(); - if(!m_isRunning) + if( !m_isRunning ) { return; } @@ -324,7 +324,7 @@ const std::string& EveVirtualCamera::GetName() const return m_name; } -void EveVirtualCamera::SetName(const std::string& name) +void EveVirtualCamera::SetName( const std::string& name ) { m_name = name; } @@ -411,8 +411,8 @@ void EveVirtualCamera::RenderDebugInfo( ITr2DebugRenderer2& renderer ) m_positionAnchorRadius = GetAnchorsBoundingSphereRadius( m_positionAnchors, m_positionAnchorCenter ); m_pointOfInterestAnchorRadius = GetAnchorsBoundingSphereRadius( m_pointOfInterestAnchors, m_pointOfInterestAnchorCenter ); - auto coneSize = std::max(m_positionAnchorRadius * DEBUG_SCALAR, 1.0f); - auto poiSize = std::max(m_pointOfInterestAnchorRadius * DEBUG_SCALAR, 1.0f); + auto coneSize = std::max( m_positionAnchorRadius * DEBUG_SCALAR, 1.0f ); + auto poiSize = std::max( m_pointOfInterestAnchorRadius * DEBUG_SCALAR, 1.0f ); auto invView = Inverse( GetViewMatrix() ); auto coneTransform = TransformationMatrix( Vector3( 1, 1, 1 ), RotationQuaternion( RIGHT, XM_PI / 2 ), Vector3( 0, 0, coneSize / 2.0f + DEBUG_BORDER_SIZE ) ) * invView; @@ -423,11 +423,11 @@ void EveVirtualCamera::RenderDebugInfo( ITr2DebugRenderer2& renderer ) renderer.DrawCylinder( this, filmReel1Transform, coneSize, coneSize / 4, 12, Tr2DebugRenderer::Lit, DEBUG_COLOR ); renderer.DrawCylinder( this, filmReel2Transform, coneSize / 1.5f, coneSize / 4, 12, Tr2DebugRenderer::Lit, DEBUG_COLOR ); renderer.DrawCone( this, coneTransform, -coneSize, coneSize, 12, Tr2DebugRenderer::Lit, DEBUG_COLOR ); - renderer.DrawBox( this, invView, Vector3(coneSize / 1.5f, coneSize, coneSize + DEBUG_BORDER_SIZE), Vector3(-coneSize / 1.5f, -coneSize, coneSize * 4), Tr2DebugRenderer::Lit, DEBUG_COLOR ); + renderer.DrawBox( this, invView, Vector3( coneSize / 1.5f, coneSize, coneSize + DEBUG_BORDER_SIZE ), Vector3( -coneSize / 1.5f, -coneSize, coneSize * 4 ), Tr2DebugRenderer::Lit, DEBUG_COLOR ); renderer.DrawText( TRI_DBG_FONT_LARGE, m_position + GetForwardDirection() * coneSize * -2.0f, DEBUG_COLOR_SUCCESS, m_name.c_str() ); // Draw the point of interest - renderer.DrawText( TRI_DBG_FONT_LARGE, m_pointOfInterest, DEBUG_COLOR_SUCCESS, (m_name + " POI").c_str() ); + renderer.DrawText( TRI_DBG_FONT_LARGE, m_pointOfInterest, DEBUG_COLOR_SUCCESS, ( m_name + " POI" ).c_str() ); renderer.DrawSphere( this, m_pointOfInterest, poiSize, 16, Tr2DebugRenderer::Lit, DEBUG_COLOR ); } } diff --git a/trinity/Eve/VirtualCamera/EveVirtualCamera.h b/trinity/Eve/VirtualCamera/EveVirtualCamera.h index e8a0e1bc9..925336baa 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCamera.h +++ b/trinity/Eve/VirtualCamera/EveVirtualCamera.h @@ -22,15 +22,15 @@ BLUE_CLASS( EveVirtualCamera ) : EveVirtualCamera( IRoot* lockobj = NULL ); ~EveVirtualCamera(); - Matrix GetViewMatrix(); + Matrix GetViewMatrix(); Matrix GetProjectionMatrix( float aspectRatio, float frontClip, float backClip ); - Vector3 GetViewDirection() const; - Vector3 GetForwardDirection() const; + Vector3 GetViewDirection() const; + Vector3 GetForwardDirection() const; Vector3 GetUpDirection() const; Vector3 GetRightDirection() const; - void Update( float deltaTime ); + void Update( float deltaTime ); void Play(); void Pause(); @@ -43,7 +43,7 @@ BLUE_CLASS( EveVirtualCamera ) : /* Not for general use, only in situations where you need a virtual camera bound to an external system. */ void UpdateExternal( Vector3 position, Vector3 pointOfInterest, float fov, float roll ); - + const std::string& GetName() const; void SetName( const std::string& name ); float GetAnimationTimelineLength() const; @@ -57,21 +57,21 @@ BLUE_CLASS( EveVirtualCamera ) : Vector3 GetPointOfInterest() const; void SetPointOfInterest( const Vector3& pointOfInterest ); - void AddPositionBehaviour( EveVirtualCameraBehaviourVector3Base* behaviour ); - void AddPointOfInterestBehaviour( EveVirtualCameraBehaviourVector3Base* behaviour ); - void AddFOVBehaviour( EveVirtualCameraBehaviourFloatBase* behaviour ); - void AddRollBehaviour( EveVirtualCameraBehaviourFloatBase* behaviour ); - + void AddPositionBehaviour( EveVirtualCameraBehaviourVector3Base * behaviour ); + void AddPointOfInterestBehaviour( EveVirtualCameraBehaviourVector3Base * behaviour ); + void AddFOVBehaviour( EveVirtualCameraBehaviourFloatBase * behaviour ); + void AddRollBehaviour( EveVirtualCameraBehaviourFloatBase * behaviour ); + ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; private: std::string m_name; bool m_isRunning; - + PEveVirtualCameraBehaviourVector3BaseVector m_positionBehaviours; PEveVirtualCameraBehaviourVector3BaseVector m_pointOfInterestBehaviours; PEveVirtualCameraBehaviourFloatBaseVector m_fovBehaviours; @@ -81,19 +81,19 @@ BLUE_CLASS( EveVirtualCamera ) : float m_roll; Vector3 m_position; Vector3 m_pointOfInterest; - + PIEveSpaceObject2Vector m_positionAnchors; PIEveSpaceObject2Vector m_pointOfInterestAnchors; - + float m_localElapsedTime; float m_animationTimelineLength; TriProjectionPtr m_projection; - + Vector3 m_positionAnchorCenter; float m_positionAnchorRadius; Vector3 m_positionAnchorForwardDirection; - + Vector3 m_pointOfInterestAnchorCenter; float m_pointOfInterestAnchorRadius; Vector3 m_pointOfInterestAnchorForwardDirection; diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.cpp index 3097cebac..2d56ee926 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.cpp @@ -8,53 +8,54 @@ namespace { - static const Vector3 UP = Vector3( 0, 1, 0 ); - static const Vector3 FORWARD = Vector3( 0, 0, 1 ); +static const Vector3 UP = Vector3( 0, 1, 0 ); +static const Vector3 FORWARD = Vector3( 0, 0, 1 ); - Vector3 RotateVectorWithAnchor( Vector3 value, Vector3 anchorForwardDirection ) - { +Vector3 RotateVectorWithAnchor( Vector3 value, Vector3 anchorForwardDirection ) +{ - Vector3 horizontalDirection = Normalize( Vector3( anchorForwardDirection.x, 0, anchorForwardDirection.z ) ); - auto rot = RotationQuaternion( Cross( FORWARD, horizontalDirection ), AngleFromNormalized( horizontalDirection, FORWARD ) ); - return XMVector3TransformCoord( Normalize( value ), XMMatrixRotationQuaternion( rot ) ) * Length( value ); - } + Vector3 horizontalDirection = Normalize( Vector3( anchorForwardDirection.x, 0, anchorForwardDirection.z ) ); + auto rot = RotationQuaternion( Cross( FORWARD, horizontalDirection ), AngleFromNormalized( horizontalDirection, FORWARD ) ); + return XMVector3TransformCoord( Normalize( value ), XMMatrixRotationQuaternion( rot ) ) * Length( value ); +} - void InitializeCurveAsEaseInOut( Tr2CurveScalarPtr& curve ) - { - curve.CreateInstance(); - curve->SetExtrapolation( Tr2CurveExtrapolation::LINEAR ); - curve->AddKey( 0.0f, 0.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - curve->AddKey( 1.0f, 1.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - } +void InitializeCurveAsEaseInOut( Tr2CurveScalarPtr& curve ) +{ + curve.CreateInstance(); + curve->SetExtrapolation( Tr2CurveExtrapolation::LINEAR ); + curve->AddKey( 0.0f, 0.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); + curve->AddKey( 1.0f, 1.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); +} - void InitializeCurveAsConstant( Tr2CurveScalarPtr& curve, float value ) - { - curve.CreateInstance(); - curve->SetExtrapolation( Tr2CurveExtrapolation::LINEAR ); - curve->AddKey( 0.0f, value, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - curve->AddKey( 1.0f, value, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - } +void InitializeCurveAsConstant( Tr2CurveScalarPtr& curve, float value ) +{ + curve.CreateInstance(); + curve->SetExtrapolation( Tr2CurveExtrapolation::LINEAR ); + curve->AddKey( 0.0f, value, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); + curve->AddKey( 1.0f, value, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); +} - // Get perlin noise in the range -1 to 1. - float ClampedNoise(double offset, float frequency, int octaves) - { - return float( PerlinNoise1D( offset * frequency, 2.0, 2.0, octaves ) ); - } +// Get perlin noise in the range -1 to 1. +float ClampedNoise( double offset, float frequency, int octaves ) +{ + return float( PerlinNoise1D( offset * frequency, 2.0, 2.0, octaves ) ); +} } // ============================================================================= // Float Behaviour Interface / Base // ============================================================================= -EveVirtualCameraBehaviourFloatBase::EveVirtualCameraBehaviourFloatBase( const char* name ): +EveVirtualCameraBehaviourFloatBase::EveVirtualCameraBehaviourFloatBase( const char* name ) : m_name( name ), m_active( true ) -{} +{ +} EveVirtualCameraBehaviourFloatBase::~EveVirtualCameraBehaviourFloatBase() { } - + const std::string& EveVirtualCameraBehaviourFloatBase::GetName() const { return m_name; @@ -65,9 +66,9 @@ void EveVirtualCameraBehaviourFloatBase::SetName( const std::string& name ) m_name = name; } -bool EveVirtualCameraBehaviourFloatBase::OnModified( Be::Var * value ) +bool EveVirtualCameraBehaviourFloatBase::OnModified( Be::Var* value ) { - if ( IsMatch( value, m_name ) ) + if( IsMatch( value, m_name ) ) { SetName( m_name ); } @@ -150,7 +151,7 @@ EveVirtualCameraBehaviourFloatNoise::EveVirtualCameraBehaviourFloatNoise( IRoot* m_magnitudeCurve->AddKey( 0.001f, 0.8f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); m_magnitudeCurve->AddKey( 0.1f, 1.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); m_magnitudeCurve->AddKey( 1.0f, 0.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - + SetName( m_name ); TriSrand( BeOS->GetCurrentFrameTime() ); @@ -205,7 +206,7 @@ float EveVirtualCameraBehaviourFloatDamping::Update( const EveVirtualCamera& cam else { m_lastValue = m_lastValue + ( current - m_lastValue ) * m_dampingRatio; - return m_lastValue - current; + return m_lastValue - current; } } @@ -216,12 +217,13 @@ float EveVirtualCameraBehaviourFloatDamping::Update( const EveVirtualCamera& cam EveVirtualCameraBehaviourVector3Base::EveVirtualCameraBehaviourVector3Base( const char* name ) : m_name( name ), m_active( true ) -{} +{ +} EveVirtualCameraBehaviourVector3Base::~EveVirtualCameraBehaviourVector3Base() { } - + const std::string& EveVirtualCameraBehaviourVector3Base::GetName() const { return m_name; @@ -232,9 +234,9 @@ void EveVirtualCameraBehaviourVector3Base::SetName( const std::string& name ) m_name = name; } -bool EveVirtualCameraBehaviourVector3Base::OnModified( Be::Var * value ) +bool EveVirtualCameraBehaviourVector3Base::OnModified( Be::Var* value ) { - if ( IsMatch( value, m_name ) ) + if( IsMatch( value, m_name ) ) { SetName( m_name ); } @@ -252,11 +254,11 @@ bool EveVirtualCameraBehaviourVector3Base::IsActive() EveVirtualCameraBehaviourVector3MoveBetween::EveVirtualCameraBehaviourVector3MoveBetween( IRoot* lockobj ) : EveVirtualCameraBehaviourVector3Base( "Move Between" ), - m_start(0, 0, 0), - m_end(0, 0, 0), + m_start( 0, 0, 0 ), + m_end( 0, 0, 0 ), m_interpolationCurve(), - m_proportional(false), - m_world(true) + m_proportional( false ), + m_world( true ) { InitializeCurveAsEaseInOut( m_interpolationCurve ); SetName( m_name ); @@ -281,7 +283,7 @@ Vector3 EveVirtualCameraBehaviourVector3MoveBetween::Update( const EveVirtualCam start *= anchorRadius; end *= anchorRadius; } - if(!m_world) + if( !m_world ) { start = RotateVectorWithAnchor( start, anchorForwardDirection ); end = RotateVectorWithAnchor( end, anchorForwardDirection ); @@ -309,9 +311,9 @@ Vector3 EveVirtualCameraBehaviourVector3MoveBetween::Update( const EveVirtualCam EveVirtualCameraBehaviourVector3Offset::EveVirtualCameraBehaviourVector3Offset( IRoot* lockobj ) : EveVirtualCameraBehaviourVector3Base( "Offset" ), - m_offset(0, 0, 0), - m_proportional(true), - m_world(false) + m_offset( 0, 0, 0 ), + m_proportional( true ), + m_world( false ) { } @@ -342,9 +344,9 @@ Vector3 EveVirtualCameraBehaviourVector3Offset::Update( const EveVirtualCamera& EveVirtualCameraBehaviourVector3Orbit::EveVirtualCameraBehaviourVector3Orbit( IRoot* lockobj ) : EveVirtualCameraBehaviourVector3Base( "Orbit" ), - m_start(0.0f), - m_end(180.0f), - m_distance(1.0f), + m_start( 0.0f ), + m_end( 180.0f ), + m_distance( 1.0f ), m_distanceScalarCurve(), m_orbitCurve(), m_proportional( true ), @@ -386,7 +388,7 @@ Vector3 EveVirtualCameraBehaviourVector3Orbit::Update( const EveVirtualCamera& c angle = m_start + ( m_end - m_start ) * localElapsedTime / camera.GetAnimationTimelineLength(); } auto rotation = RotationQuaternion( UP, XMConvertToRadians( angle ) ); - + TriVectorRotateQuaternion( &orbitDir, &orbitDir, &rotation ); float range = m_distance; @@ -491,7 +493,7 @@ EveVirtualCameraBehaviourVector3Shake::EveVirtualCameraBehaviourVector3Shake( IR m_magnitudeCurve->AddKey( 0.001f, 0.8f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); m_magnitudeCurve->AddKey( 0.1f, 1.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); m_magnitudeCurve->AddKey( 1.0f, 0.0f, Tr2CurveInterpolation::HERMITE, 0, 0, Tr2CurveTangentType::AUTO_CLAMP ); - + SetName( m_name ); } @@ -517,12 +519,12 @@ Vector3 EveVirtualCameraBehaviourVector3Shake::Update( const EveVirtualCamera& c { offset *= m_magnitudeCurve->GetValue( localElapsedTime / camera.GetAnimationTimelineLength() ); } - - if(m_scaleByView) + + if( m_scaleByView ) { - offset.x = atan(offset.x) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); - offset.y = atan(offset.y) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); - offset.z = atan(offset.z) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); + offset.x = atan( offset.x ) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); + offset.y = atan( offset.y ) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); + offset.z = atan( offset.z ) * Length( camera.GetPointOfInterest() - camera.GetPosition() ); } return camera.GetRightDirection() * offset.x + camera.GetUpDirection() * offset.y + camera.GetForwardDirection() * offset.z; @@ -553,9 +555,9 @@ Vector3 EveVirtualCameraBehaviourVector3Damping::Update( const EveVirtualCamera& else { m_lastPosition = m_lastPosition + ( current - m_lastPosition ) * m_dampingRatio; - return m_lastPosition - current; + return m_lastPosition - current; } -} +} // ============================================================================= @@ -587,6 +589,6 @@ Vector3 EveVirtualCameraBehaviourVector3Inertia::Update( const EveVirtualCamera& auto velocity = m_lastVelocity + ( ( current - m_lastPosition ) - m_lastVelocity ) * ( 1.0f / m_inertiaFactor ); m_lastPosition = m_lastPosition + velocity; m_lastVelocity = velocity * deltaTime; - return m_lastPosition - current; + return m_lastPosition - current; } -} +} diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.h b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.h index 75b5fa88b..7a177fa34 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.h +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour.h @@ -14,11 +14,11 @@ BLUE_CLASS( EveVirtualCameraBehaviourFloatBase ) : { public: EXPOSE_TO_BLUE(); - + EveVirtualCameraBehaviourFloatBase( const char* name ); virtual ~EveVirtualCameraBehaviourFloatBase(); - - const std::string& GetName() const; + + const std::string& GetName() const; virtual void SetName( const std::string& name ); ////////////////////////////////////////////////////////////////////////// @@ -97,7 +97,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourFloatNoise ) : virtual void SetName( const std::string& name ) override; virtual float Update( const EveVirtualCamera& camera, float current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; - + private: float m_frequency; int32_t m_octaves; @@ -138,13 +138,13 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3Base ) : { public: EXPOSE_TO_BLUE(); - + EveVirtualCameraBehaviourVector3Base( const char* name ); virtual ~EveVirtualCameraBehaviourVector3Base(); - - virtual const std::string& GetName() const; + + virtual const std::string& GetName() const; virtual void SetName( const std::string& name ); - + ////////////////////////////////////////////////////////////////////////// // INotify virtual bool OnModified( Be::Var * value ) override; @@ -174,7 +174,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3MoveBetween ) : ~EveVirtualCameraBehaviourVector3MoveBetween(); virtual void SetName( const std::string& name ) override; - + virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; private: @@ -224,9 +224,9 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3Orbit ) : ~EveVirtualCameraBehaviourVector3Orbit(); virtual void SetName( const std::string& name ) override; - + virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; - + private: float m_start; float m_end; @@ -253,7 +253,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3MoveForward ) : ~EveVirtualCameraBehaviourVector3MoveForward(); virtual void SetName( const std::string& name ) override; - + virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; protected: @@ -295,7 +295,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3MoveUp ) : EXPOSE_TO_BLUE(); EveVirtualCameraBehaviourVector3MoveUp( IRoot* lockobj = NULL ); - + virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; }; @@ -315,9 +315,9 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3Shake ) : ~EveVirtualCameraBehaviourVector3Shake(); virtual void SetName( const std::string& name ) override; - + virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; - + private: float m_frequency; int32_t m_octaves; @@ -342,7 +342,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3Damping ) : ~EveVirtualCameraBehaviourVector3Damping(); virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; - + private: Vector3 m_lastPosition; float m_dampingRatio; @@ -365,7 +365,7 @@ BLUE_CLASS( EveVirtualCameraBehaviourVector3Inertia ) : ~EveVirtualCameraBehaviourVector3Inertia(); virtual Vector3 Update( const EveVirtualCamera& camera, const Vector3& current, float deltaTime, float localElapsedTime, const Vector3& anchorPosition, float anchorRadius, const Vector3& anchorForwardDirection ) override; - + private: Vector3 m_lastPosition; Vector3 m_lastVelocity; diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour_Blue.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour_Blue.cpp index 0d09b101f..c799bd0da 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour_Blue.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraBehaviour_Blue.cpp @@ -9,13 +9,12 @@ BLUE_DEFINE_ABSTRACT( EveVirtualCameraBehaviourFloatBase ); -const Be::ClassInfo* EveVirtualCameraBehaviourFloatBase::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourFloatBase::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourFloatBase, "" ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "The name.", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE( "active", m_active, "If not active the node is disabled.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The name.", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "active", m_active, "If not active the node is disabled.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } // ============================================================================= @@ -24,12 +23,11 @@ const Be::ClassInfo* EveVirtualCameraBehaviourFloatBase::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourFloatSet ); -const Be::ClassInfo* EveVirtualCameraBehaviourFloatSet::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourFloatSet::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourFloatSet, "Lerp from one position to another over time." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "value", m_value, "The value to set.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) + MAP_ATTRIBUTE( "value", m_value, "The value to set.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) } // ============================================================================= @@ -38,13 +36,12 @@ const Be::ClassInfo* EveVirtualCameraBehaviourFloatSet::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourFloatAdd ); -const Be::ClassInfo* EveVirtualCameraBehaviourFloatAdd::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourFloatAdd::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourFloatAdd, "Lerp from one position to another over time." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "value", m_value, "The value to set.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaleCurve", m_scaleCurve, "A curve to dictate how to scale the value over the lifetime of the caemra.\nIf not used the value is absolute.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) + MAP_ATTRIBUTE( "value", m_value, "The value to set.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaleCurve", m_scaleCurve, "A curve to dictate how to scale the value over the lifetime of the caemra.\nIf not used the value is absolute.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) } // ============================================================================= @@ -53,15 +50,14 @@ const Be::ClassInfo* EveVirtualCameraBehaviourFloatAdd::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourFloatNoise ); -const Be::ClassInfo* EveVirtualCameraBehaviourFloatNoise::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourFloatNoise::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourFloatNoise, "Shakes around the position / point of interest. Can be scaled by view when applied to the point of interest so it acts as a rotations shake." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "perlineScale", m_frequency, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "octaves", m_octaves, "Determines the detail of the noise. Higher values give more detailed noise.\n:jessica-numeric-range: (1, 16)\n", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "magnitude", m_magnitude, "Scales the overall noise effect.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "magnitudeCurve", m_magnitudeCurve, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) + MAP_ATTRIBUTE( "perlineScale", m_frequency, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "octaves", m_octaves, "Determines the detail of the noise. Higher values give more detailed noise.\n:jessica-numeric-range: (1, 16)\n", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "magnitude", m_magnitude, "Scales the overall noise effect.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "magnitudeCurve", m_magnitudeCurve, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) } // ============================================================================= @@ -70,12 +66,11 @@ const Be::ClassInfo* EveVirtualCameraBehaviourFloatNoise::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourFloatDamping ); -const Be::ClassInfo* EveVirtualCameraBehaviourFloatDamping::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourFloatDamping::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourFloatDamping, "Shakes around the position / point of interest. Can be scaled by view when applied to the point of interest so it acts as a rotations shake." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "dampingFactor", m_dampingRatio, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) + MAP_ATTRIBUTE( "dampingFactor", m_dampingRatio, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourFloatBase ) } // ============================================================================= @@ -84,13 +79,12 @@ const Be::ClassInfo* EveVirtualCameraBehaviourFloatDamping::ExposeToBlue() BLUE_DEFINE_ABSTRACT( EveVirtualCameraBehaviourVector3Base ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3Base::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3Base::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Base, "" ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "name", m_name, "The name.", Be::READWRITE| Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE( "active", m_active, "If not active the node is disabled.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "The name.", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "active", m_active, "If not active the node is disabled.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } // ============================================================================= @@ -99,16 +93,15 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3Base::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3MoveBetween ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveBetween::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveBetween::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3MoveBetween, "Lerp from one position to another over time." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "start", m_start, "Start position.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "end", m_end, "End position.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "interpolationCurve", m_interpolationCurve, "Optional curve to define how to lerp from start to end.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "world", m_world, "If true the offset is in world coordinates,\notherwise it's in local coordinates (i.e. relative to the anchors).", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "start", m_start, "Start position.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "end", m_end, "End position.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "interpolationCurve", m_interpolationCurve, "Optional curve to define how to lerp from start to end.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "world", m_world, "If true the offset is in world coordinates,\notherwise it's in local coordinates (i.e. relative to the anchors).", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -117,14 +110,13 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveBetween::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3Offset ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3Offset::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3Offset::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Offset, "Lerp from one position to another over time." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "offset", m_offset, "Offset from the anchor center (or origin if no anchor objects are supplied).", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "world", m_world, "If true the offset is in world coordinates,\notherwise it's in local coordinates (i.e. relative to the anchors).", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "offset", m_offset, "Offset from the anchor center (or origin if no anchor objects are supplied).", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "world", m_world, "If true the offset is in world coordinates,\notherwise it's in local coordinates (i.e. relative to the anchors).", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -133,18 +125,17 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3Offset::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3Orbit ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3Orbit::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3Orbit::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Orbit, "Lerp from one position to another over time." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "start", m_start, "Starting orbit position (in degrees) where 0 is in front\nof the anchor objects and 180 is behind.", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE( "end", m_end, "End orbit position (in degrees) where 0 is in front\nof the anchor objects and 180 is behind.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "distance", m_distance, "The range to orbit the object.\nEither in metres, km or scaled by the bounding\nsphere of the anchor obejcts. See proportional.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "distanceScalarCurve", m_distanceScalarCurve, "A curve to scale the range with.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "orbitCurve", m_orbitCurve, "A curve to dictate how to lerp from start to end.\nWhen not specified interpolation is simply linear.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "world", m_world, "If true the orbit angle is an angle from the world forward direction (0, 0, 1),\notherwise it's an angle from the forward direction of the anchors.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "start", m_start, "Starting orbit position (in degrees) where 0 is in front\nof the anchor objects and 180 is behind.", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "end", m_end, "End orbit position (in degrees) where 0 is in front\nof the anchor objects and 180 is behind.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "distance", m_distance, "The range to orbit the object.\nEither in metres, km or scaled by the bounding\nsphere of the anchor obejcts. See proportional.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "distanceScalarCurve", m_distanceScalarCurve, "A curve to scale the range with.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "orbitCurve", m_orbitCurve, "A curve to dictate how to lerp from start to end.\nWhen not specified interpolation is simply linear.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "world", m_world, "If true the orbit angle is an angle from the world forward direction (0, 0, 1),\notherwise it's an angle from the forward direction of the anchors.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -153,14 +144,13 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3Orbit::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3MoveForward ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveForward::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveForward::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3MoveForward, "Move the camera forward (a.k.a. dolly)." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "value", m_value, "The amount to move in by.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaleCurve", m_scaleCurve, "A curve to dictate how to scale the value over the lifetime of the caemra.\nIf not used the value is absolute.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the value is in meters,\nif true the value is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "value", m_value, "The amount to move in by.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaleCurve", m_scaleCurve, "A curve to dictate how to scale the value over the lifetime of the caemra.\nIf not used the value is absolute.\nShould typically range from 0-1 in value and time.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "proportional", m_proportional, "If false, the value is in meters,\nif true the value is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -169,11 +159,10 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveForward::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3MoveRight ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveRight::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveRight::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3MoveRight, "Move the camera right (a.k.a. truck)." ) MAP_INTERFACE( INotify ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3MoveForward ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3MoveForward ) } // ============================================================================= @@ -182,11 +171,10 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveRight::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3MoveUp ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveUp::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveUp::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3MoveUp, "Move the camera up (a.k.a. pedestal)." ) MAP_INTERFACE( INotify ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3MoveForward ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3MoveForward ) } // ============================================================================= @@ -195,16 +183,15 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3MoveUp::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3Shake ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3Shake::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraBehaviourVector3Shake::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Shake, "Shakes around the position / point of interest. Can be scaled by view when applied to the point of interest so it acts as a rotations shake." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "perlineScale", m_frequency, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "octaves", m_octaves, "Determines the detail of the noise. Higher values give more detailed noise.\n:jessica-numeric-range: (1, 16)\n", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "magnitude", m_magnitude, "Scales the overall noise effect.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "magnitudeCurve", m_magnitudeCurve, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scaleByView", m_scaleByView, "Typically on. Scales the overall shake relative to the distance from the camera to the point of interest so the shake feels consistent no matter the \"zoom\" level.", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "perlineScale", m_frequency, "Scales the perlin noise used. Higher values means higher frequency.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "octaves", m_octaves, "Determines the detail of the noise. Higher values give more detailed noise.\n:jessica-numeric-range: (1, 16)\n", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "magnitude", m_magnitude, "Scales the overall noise effect.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "magnitudeCurve", m_magnitudeCurve, "If false, the offset is in meters,\nif true the offset is scaled by the anchor object collision sphere radius.", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaleByView", m_scaleByView, "Typically on. Scales the overall shake relative to the distance from the camera to the point of interest so the shake feels consistent no matter the \"zoom\" level.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -213,12 +200,11 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3Shake::ExposeToBlue() BLUE_DEFINE( EveVirtualCameraBehaviourVector3Damping ); -const Be::ClassInfo* EveVirtualCameraBehaviourVector3Damping::ExposeToBlue() -{ - EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Damping, "Adds a damping factor to the velocity of behaviours that come before it in the stack, smoothing out sudden changes.\n") +const Be::ClassInfo* EveVirtualCameraBehaviourVector3Damping::ExposeToBlue(){ + EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Damping, "Adds a damping factor to the velocity of behaviours that come before it in the stack, smoothing out sudden changes.\n" ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "m_dampingRatio", m_dampingRatio, "Scalar from 0-1 to scale down the velocity of the camera.\nA value of 1 has no effect.\n:jessica-numeric-range: (0.0, 1.0)\n", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) + MAP_ATTRIBUTE( "m_dampingRatio", m_dampingRatio, "Scalar from 0-1 to scale down the velocity of the camera.\nA value of 1 has no effect.\n:jessica-numeric-range: (0.0, 1.0)\n", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } // ============================================================================= @@ -231,14 +217,13 @@ const Be::ClassInfo* EveVirtualCameraBehaviourVector3Inertia::ExposeToBlue() { EXPOSURE_BEGIN( EveVirtualCameraBehaviourVector3Inertia, "Adds a damping factor to the behaviours that come before it in the stack, adding weight to the camera and smoothing out velocity spikes.\nAdd to the end of the stack to give the camera inertia." ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( - "inertiaFactor", - m_inertiaFactor, + MAP_ATTRIBUTE( + "inertiaFactor", + m_inertiaFactor, "Adds a sense of inertia. Values > 1 are \"underdamped\" and give a spring like inertia.\n" "A value of 1 is \"critically damped\" which has no real effect.\n" "A value < 1 would result in explosive behaviour and is undesirable\n" ":jessica-numeric-range: (1.0, 1000.0)\n", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) EXPOSURE_CHAINTO( EveVirtualCameraBehaviourVector3Base ) } diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.cpp index 09cfbd111..9631638c2 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.cpp @@ -75,7 +75,7 @@ EveVirtualCameraPtr EveVirtualCameraSystem::GetCameraByName( const std::string& { for( auto it = m_cameras.begin(); it != m_cameras.end(); ++it ) { - if( (*it)->GetName() == name ) + if( ( *it )->GetName() == name ) { return *it; } @@ -95,7 +95,7 @@ void EveVirtualCameraSystem::SetMainCamera( const EveVirtualCameraPtr& camera, c { auto current = GetMainCamera(); SetMainCamera( camera ); - if(transition) + if( transition ) { transition->SetSource( current ); transition->SetTarget( GetMainCamera() ); @@ -104,7 +104,7 @@ void EveVirtualCameraSystem::SetMainCamera( const EveVirtualCameraPtr& camera, c m_transition = transition; } -void EveVirtualCameraSystem::CutToCamera( EveVirtualCamera * camera ) +void EveVirtualCameraSystem::CutToCamera( EveVirtualCamera* camera ) { if( camera && camera != GetMainCamera() ) { @@ -114,7 +114,7 @@ void EveVirtualCameraSystem::CutToCamera( EveVirtualCamera * camera ) } } -void EveVirtualCameraSystem::LerpToCamera( EveVirtualCamera * camera, float transitionTime ) +void EveVirtualCameraSystem::LerpToCamera( EveVirtualCamera* camera, float transitionTime ) { if( camera && camera != GetMainCamera() ) { @@ -136,7 +136,7 @@ void EveVirtualCameraSystem::Update( Be::Time simTime ) { m_lastUpdate = simTime; } - float deltaTime = TimeAsFloat(simTime - m_lastUpdate); + float deltaTime = TimeAsFloat( simTime - m_lastUpdate ); m_lastUpdate = simTime; for( auto it = m_cameras.begin(); it != m_cameras.end(); ++it ) @@ -148,7 +148,7 @@ void EveVirtualCameraSystem::Update( Be::Time simTime ) m_externalCamera->Update( deltaTime ); } - if( m_transition ) + if( m_transition ) { m_transition->Update( deltaTime ); if( m_transition->IsComplete() ) @@ -160,7 +160,7 @@ void EveVirtualCameraSystem::Update( Be::Time simTime ) void EveVirtualCameraSystem::GetDebugOptions( Tr2DebugRendererOptions& options ) { - for ( auto it = m_cameras.begin(); it != m_cameras.end(); ++it ) + for( auto it = m_cameras.begin(); it != m_cameras.end(); ++it ) { ( *it )->GetDebugOptions( options ); } diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.h b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.h index 748c9e835..66589cbeb 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.h +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem.h @@ -27,23 +27,23 @@ BLUE_CLASS( EveVirtualCameraSystem ) : EveVirtualCameraPtr GetCurrentCamera(); EveVirtualCameraPtr GetMainCamera(); - // Add camera, unless it's the external camera or already in this systems cameras list. + // Add camera, unless it's the external camera or already in this systems cameras list. // Returns true if successfully added. bool AddCamera( const EveVirtualCameraPtr& camera ); - + EveVirtualCameraPtr GetCameraByName( const std::string& cameraName ) const; - + void CutToCamera( EveVirtualCamera * camera ); - void LerpToCamera( EveVirtualCamera * camera, float lerpTime=1.0f ); + void LerpToCamera( EveVirtualCamera * camera, float lerpTime = 1.0f ); bool IsExternallyControlled(); void Update( Be::Time simTime ); - + ///////////////////////////////////////////////////////////////////////////////////// // ITr2DebugRenderable - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) override; private: void SetMainCamera( const EveVirtualCameraPtr& cameraIndex ); diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem_Blue.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem_Blue.cpp index 7a0edb596..1c73c209e 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraSystem_Blue.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraSystem_Blue.cpp @@ -17,31 +17,28 @@ const Be::ClassInfo* EveVirtualCameraSystem::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetCurrentCamera", GetCurrentCamera, "Get the current camera, taking into account any temporary, transition cameras." ) MAP_METHOD_AND_WRAP( "GetMainCamera", GetMainCamera, "Get whichever camera is either the main one or is marked to become it after a transition completes." ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "CutToCamera", - CutToCamera, + CutToCamera, "Cut to the target camera.\n" ":param camera: A camera to cut to, cannot be None.\n" - ":type camera: trinity.EveVirtualCamera\n" - ) - MAP_METHOD_AND_WRAP( + ":type camera: trinity.EveVirtualCamera\n" ) + MAP_METHOD_AND_WRAP( "LerpToCamera", - LerpToCamera, - "Lerp to the target camera.\n" + LerpToCamera, + "Lerp to the target camera.\n" ":param camera: A camera to cut to, cannot be None.\n" ":type camera: trinity.EveVirtualCamera\n" ":param lerpTime: the time to perform the lerp transition over.\n" - ":type lerpTime: float\n" - ) + ":type lerpTime: float\n" ) MAP_METHOD_AND_WRAP( "IsExternallyControlled", IsExternallyControlled, "True if the current camera in use is the \"externalCamera\", thus the system is expected to be getting driven by an external system via this camera." ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "GetCameraByName", - GetCameraByName, + GetCameraByName, "Get the first camera found matching the given name.\n" ":param cameraName: The name of the camera to find.\n" - ":type cameraName: str\n" - ) + ":type cameraName: str\n" ) EXPOSURE_END() } diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.cpp index 755794fb9..d94c31643 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.cpp @@ -15,10 +15,10 @@ EveVirtualCameraTransitionBase::EveVirtualCameraTransitionBase( IRoot* lockobj ) EveVirtualCameraTransitionBase::~EveVirtualCameraTransitionBase() { } - + EveVirtualCameraPtr EveVirtualCameraTransitionBase::GetCamera() { - if(IsComplete()) + if( IsComplete() ) { return m_targetCamera; } @@ -55,7 +55,7 @@ void EveVirtualCameraTransitionBase::Play() void EveVirtualCameraTransitionBase::Stop() { - if(m_targetCamera) + if( m_targetCamera ) { m_targetCamera->Play(); } @@ -63,7 +63,7 @@ void EveVirtualCameraTransitionBase::Stop() { m_sourceCamera->Pause(); } - if(m_transitionCamera) + if( m_transitionCamera ) { m_transitionCamera->Pause(); } @@ -100,9 +100,9 @@ void EveVirtualCameraTransitionCut::Update( float deltaTime ) EveVirtualCameraTransitionBase::Update( deltaTime ); } -EveVirtualCameraTransitionLerp::EveVirtualCameraTransitionLerp( IRoot* lockobj ): +EveVirtualCameraTransitionLerp::EveVirtualCameraTransitionLerp( IRoot* lockobj ) : EveVirtualCameraTransitionBase( lockobj ), - m_transitionTime(1.0f), + m_transitionTime( 1.0f ), m_localTime(), m_transitionCurve() { @@ -134,7 +134,7 @@ void EveVirtualCameraTransitionLerp::Play() void EveVirtualCameraTransitionLerp::Update( float deltaTime ) { m_localTime += deltaTime; - if( m_transitionCamera && m_sourceCamera && m_targetCamera) + if( m_transitionCamera && m_sourceCamera && m_targetCamera ) { auto lerpAmount = 1.0f; if( m_transitionTime > 0.0f ) @@ -152,8 +152,7 @@ void EveVirtualCameraTransitionLerp::Update( float deltaTime ) Lerp( m_sourceCamera->GetPosition(), m_targetCamera->GetPosition(), lerpAmount ), Lerp( m_sourceCamera->GetPointOfInterest(), m_targetCamera->GetPointOfInterest(), lerpAmount ), m_sourceCamera->GetFov() + ( m_targetCamera->GetFov() - m_sourceCamera->GetFov() ) * lerpAmount, - m_sourceCamera->GetRoll() + ( m_targetCamera->GetRoll() - m_sourceCamera->GetRoll() ) * lerpAmount - ); + m_sourceCamera->GetRoll() + ( m_targetCamera->GetRoll() - m_sourceCamera->GetRoll() ) * lerpAmount ); } EveVirtualCameraTransitionBase::Update( deltaTime ); } diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.h b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.h index 68ebe7a3b..f694a1981 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.h +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition.h @@ -13,7 +13,7 @@ BLUE_CLASS( EveVirtualCameraTransitionBase ) : EveVirtualCameraTransitionBase( IRoot* lockobj = NULL ); ~EveVirtualCameraTransitionBase(); - + virtual bool IsComplete() const = 0; virtual EveVirtualCameraPtr GetCamera(); virtual void SetSource( const EveVirtualCameraPtr& camera ); @@ -21,7 +21,7 @@ BLUE_CLASS( EveVirtualCameraTransitionBase ) : virtual void Play(); virtual void Stop(); virtual void Update( float deltaTime ); - + protected: EveVirtualCameraPtr m_sourceCamera; EveVirtualCameraPtr m_targetCamera; @@ -36,7 +36,7 @@ BLUE_CLASS( EveVirtualCameraTransitionCut ) : EveVirtualCameraTransitionCut( IRoot* lockobj = NULL ); ~EveVirtualCameraTransitionCut(); - + virtual bool IsComplete() const override; virtual void Update( float deltaTime ) override; }; @@ -51,7 +51,7 @@ BLUE_CLASS( EveVirtualCameraTransitionLerp ) : EveVirtualCameraTransitionLerp( IRoot* lockobj = NULL ); ~EveVirtualCameraTransitionLerp(); - + virtual bool IsComplete() const override; virtual void Play() override; virtual void Update( float deltaTime ) override; diff --git a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition_Blue.cpp b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition_Blue.cpp index eaa45a5bb..5f1360f70 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCameraTransition_Blue.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCameraTransition_Blue.cpp @@ -5,18 +5,16 @@ BLUE_DEFINE_ABSTRACT( EveVirtualCameraTransitionBase ); -const Be::ClassInfo* EveVirtualCameraTransitionBase::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraTransitionBase::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraTransitionBase, "" ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( EveVirtualCameraTransitionCut ); -const Be::ClassInfo* EveVirtualCameraTransitionCut::ExposeToBlue() -{ +const Be::ClassInfo* EveVirtualCameraTransitionCut::ExposeToBlue(){ EXPOSURE_BEGIN( EveVirtualCameraTransitionCut, "A transition that cuts quickly to a target camera." ) - EXPOSURE_CHAINTO( EveVirtualCameraTransitionBase ) + EXPOSURE_CHAINTO( EveVirtualCameraTransitionBase ) } BLUE_DEFINE( EveVirtualCameraTransitionLerp ); diff --git a/trinity/Eve/VirtualCamera/EveVirtualCamera_Blue.cpp b/trinity/Eve/VirtualCamera/EveVirtualCamera_Blue.cpp index 55d2d7941..b9d0db37f 100644 --- a/trinity/Eve/VirtualCamera/EveVirtualCamera_Blue.cpp +++ b/trinity/Eve/VirtualCamera/EveVirtualCamera_Blue.cpp @@ -10,14 +10,14 @@ const Be::ClassInfo* EveVirtualCamera::ExposeToBlue() EXPOSURE_BEGIN( EveVirtualCamera, "A virtual camera, managed by a VirtualCameraSystem which is, in turn, consumed by a real camera." ) MAP_ATTRIBUTE( "name", m_name, "The name for the camera.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "animationTimelineLength", m_animationTimelineLength, "The length of time, in seconds, the camera's behaviours animate over.\n:jessica-widget: float\n:jessica-numeric-range: (0.0, 99999.0)", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "running", m_isRunning, "True if the camera is currently active.", Be::READ ) MAP_ATTRIBUTE( "fov", m_fov, "The field of view.", Be::READ ) MAP_ATTRIBUTE( "roll", m_roll, "The camera roll.", Be::READ ) MAP_ATTRIBUTE( "position", m_position, "Camera position.", Be::READ ) MAP_ATTRIBUTE( "pointOfInterest", m_pointOfInterest, "Point of interest.", Be::READ ) - + MAP_ATTRIBUTE( "localElapsedTime", m_localElapsedTime, "Local elapsed time.", Be::READ ) MAP_ATTRIBUTE( "positionAnchorCenter", m_positionAnchorCenter, "Center of the position anchor objects.", Be::READ ) MAP_ATTRIBUTE( "positionAnchorRadius", m_positionAnchorRadius, "Radius of the position anchor objects bounding sphere.", Be::READ ) @@ -25,17 +25,17 @@ const Be::ClassInfo* EveVirtualCamera::ExposeToBlue() MAP_ATTRIBUTE( "pointOfInterestAnchorCenter", m_positionAnchorCenter, "Center of the point of interest anchor objects.", Be::READ ) MAP_ATTRIBUTE( "pointOfInterestAnchorRadius", m_positionAnchorRadius, "Radius of the point of interest anchor objects bounding sphere.", Be::READ ) MAP_ATTRIBUTE( "pointOfInterestAnchorForwardDirection", m_pointOfInterestAnchorForwardDirection, "Radius of the position anchor objects bounding sphere.", Be::READ ) - + MAP_PROPERTY_READONLY( "forward", GetViewDirection, "The forward direction." ) MAP_PROPERTY_READONLY( "right", GetRightDirection, "The right direction." ) MAP_PROPERTY_READONLY( "up", GetUpDirection, "The up direction." ) - + MAP_METHOD_AND_WRAP( "GetViewMatrix", GetViewMatrix, "The forward direction." ) MAP_METHOD_AND_WRAP( "GetProjectionMatrix", GetProjectionMatrix, "The right direction." ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "UpdateExternal", - UpdateExternal, + UpdateExternal, "Not for general use, only for situations where you need a virtual camera bound to an external system. Do not use with behaviours.\n" ":param position: the position of the camera.\n" ":type position: tuple[float, float, float]\n" @@ -44,26 +44,24 @@ const Be::ClassInfo* EveVirtualCamera::ExposeToBlue() ":param fov: the field of view.\n" ":type fov: float\n" ":param roll: the roll amount.\n" - ":type roll: float\n" - ) + ":type roll: float\n" ) MAP_METHOD_AND_WRAP( "Play", Play, "Used for debugging, starting / stopping should be left up to the EveVirtualCameraSystem to which this camera belongs.\n:jessica-placement: BOTH\n:jessica-icon: far-play" ) MAP_METHOD_AND_WRAP( "Pause", Pause, "Used for debugging, starting / stopping should be left up to the EveVirtualCameraSystem to which this camera belongs.\n:jessica-placement: BOTH\n:jessica-icon: far-pause" ) MAP_METHOD_AND_WRAP( "Stop", Stop, "Used for debugging, starting / stopping should be left up to the EveVirtualCameraSystem to which this camera belongs.\n:jessica-placement: BOTH\n:jessica-icon: far-stop" ) - MAP_METHOD_AND_WRAP( - "UpdateToLocalTime", - UpdateToLocalTime, + MAP_METHOD_AND_WRAP( + "UpdateToLocalTime", + UpdateToLocalTime, "Used to set the localElapsedTime. Simulates the camera moving through time to get to that localElapsedTime thus allowing behaviours to act appropriately.\n" ":param time: the target playback time to scrub the camera to.\n" - ":type time: float\n" - ) + ":type time: float\n" ) MAP_ATTRIBUTE( "positionBehaviours", m_positionBehaviours, "The behaviours that drive the camera position.", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "pointOfInterestBehaviours", m_pointOfInterestBehaviours, "The behaviours that drive the camera point of interest.", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "fovBehaviours", m_fovBehaviours, "The behaviours that drive the camera fov.", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "rollBehaviours", m_rollBehaviours, "The behaviours that drive the camera roll.", Be::READ | Be::PERSIST ) - + MAP_ATTRIBUTE( "positionAnchors", m_positionAnchors, "List of objects which act as the anchors for all position related behaviours.", Be::READ ) MAP_ATTRIBUTE( "pointOfInterestAnchors", m_pointOfInterestAnchors, "List of objects which act as the anchors for all point of interest related behaviours.", Be::READ ) EXPOSURE_END() diff --git a/trinity/Eve/Volume/EveBoxVolume.cpp b/trinity/Eve/Volume/EveBoxVolume.cpp index 061b185c3..1bdf2a8ac 100644 --- a/trinity/Eve/Volume/EveBoxVolume.cpp +++ b/trinity/Eve/Volume/EveBoxVolume.cpp @@ -72,10 +72,10 @@ float EveBoxVolume::GetIntensity( Vector3 position ) { return 1.0f; } - + Vector3 rayDir = Normalize( -axisAlignedPosition ); - // we are somewhere in between + // we are somewhere in between IntersectAxisAlignedBoxRay( MIN_AABB, MAX_AABB, axisAlignedPosition, rayDir, m_outerIntersection ); IntersectAxisAlignedBoxRay( MIN_AABB, MAX_AABB, axisAlignedInnerPosition, rayDir, m_innerIntersection ); @@ -99,7 +99,7 @@ void EveBoxVolume::UnregisterForChanges( uint32_t callbackID ) void EveBoxVolume::Setup() { m_scaling = XMVectorMax( m_scaling, Vector3( 0, 0, 0 ) ); - m_innerScaling = XMVectorMin( XMVectorMax(m_innerScaling, Vector3( 0, 0, 0 ) ), m_scaling ); + m_innerScaling = XMVectorMin( XMVectorMax( m_innerScaling, Vector3( 0, 0, 0 ) ), m_scaling ); m_boxTransform = TransformationMatrix( m_scaling, m_rotation, m_position ); m_innerBoxTransform = TransformationMatrix( m_innerScaling, m_rotation, m_position ); @@ -119,12 +119,12 @@ void EveBoxVolume::GeneratePointsInVolume( std::vector& points, size_t // volume is not properly defined return; } - + float leftRightSideSize = ( m_scaling.x - m_innerScaling.x ) * m_scaling.y * m_scaling.z; float topBottomSize = m_innerScaling.x * ( m_scaling.y - m_innerScaling.y ) * m_scaling.z; float frontBackLidSize = m_innerScaling.x * m_innerScaling.y * ( m_scaling.z - m_innerScaling.z ); - float outerSidesSize = 2.f * (leftRightSideSize + topBottomSize + frontBackLidSize); + float outerSidesSize = 2.f * ( leftRightSideSize + topBottomSize + frontBackLidSize ); float innerToOuterSizeRatio = 0.f; if( !excludeInnerVolume ) @@ -136,7 +136,7 @@ void EveBoxVolume::GeneratePointsInVolume( std::vector& points, size_t // as the outer volume is only half filled by default so we use the difference multiplied by 0.5 float adjustedOuterCubeSize = ( m_innerScaling.x + 0.5f * rangeX ) * ( m_innerScaling.y + 0.5f * rangeY ) * ( m_innerScaling.z + 0.5f * rangeZ ); innerToOuterSizeRatio = ( m_innerScaling.x * m_innerScaling.y * m_innerScaling.z ) / adjustedOuterCubeSize; - innerToOuterSizeRatio = 1.f - pow( 1.f - innerToOuterSizeRatio, 0.8f + 0.2f * fallOffFactor ); // absorb more points into inner shape for steep falloffs + innerToOuterSizeRatio = 1.f - pow( 1.f - innerToOuterSizeRatio, 0.8f + 0.2f * fallOffFactor ); // absorb more points into inner shape for steep falloffs } points.reserve( points.size() + howManyToAdd ); @@ -168,7 +168,7 @@ void EveBoxVolume::GeneratePointsInVolume( std::vector& points, size_t float Z = TriRand() * m_scaling.z - 0.5f * m_scaling.z; position = Vector3( X, Y, Z ); } - else if( zonePicker < 2.f * (leftRightSideSize + topBottomSize) ) + else if( zonePicker < 2.f * ( leftRightSideSize + topBottomSize ) ) { float rand = 0.5f * m_innerScaling.y + pow( TriRand(), fallOffFactor ) * ( m_scaling.y - m_innerScaling.y ) * 0.5f; float X = TriRand() * m_innerScaling.x - 0.5f * m_innerScaling.x; @@ -178,7 +178,7 @@ void EveBoxVolume::GeneratePointsInVolume( std::vector& points, size_t } else { - float rand = 0.5f * m_innerScaling.y + pow(TriRand(), fallOffFactor) * ( m_scaling.y - m_innerScaling.y ) * 0.5f; + float rand = 0.5f * m_innerScaling.y + pow( TriRand(), fallOffFactor ) * ( m_scaling.y - m_innerScaling.y ) * 0.5f; float X = TriRand() * m_innerScaling.x - 0.5f * m_innerScaling.x; float Y = TriRand() * m_innerScaling.y - 0.5f * m_innerScaling.y; float Z = zonePicker < outerSidesSize - frontBackLidSize ? rand : -rand; @@ -202,7 +202,7 @@ bool EveBoxVolume::OnModified( Be::Var* val ) { Setup(); } - + for( auto callBack : m_onChangeCallbacks ) { if( callBack.second != nullptr ) diff --git a/trinity/Eve/Volume/EveBoxVolume.h b/trinity/Eve/Volume/EveBoxVolume.h index 07b2bc20b..4afa5d7ea 100644 --- a/trinity/Eve/Volume/EveBoxVolume.h +++ b/trinity/Eve/Volume/EveBoxVolume.h @@ -34,10 +34,9 @@ BLUE_CLASS( EveBoxVolume ) : ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); private: - void Setup(); BlueSharedString m_name; diff --git a/trinity/Eve/Volume/EveBoxVolume_Blue.cpp b/trinity/Eve/Volume/EveBoxVolume_Blue.cpp index 7c18390a3..6afd4b048 100644 --- a/trinity/Eve/Volume/EveBoxVolume_Blue.cpp +++ b/trinity/Eve/Volume/EveBoxVolume_Blue.cpp @@ -22,5 +22,5 @@ const Be::ClassInfo* EveBoxVolume::ExposeToBlue() MAP_ATTRIBUTE( "debugShowIntersection", m_debugShowIntersection, "When volume debugging is on, you the intersection points can be shown", Be::READWRITE ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/Volume/EveEllipsoidVolume.cpp b/trinity/Eve/Volume/EveEllipsoidVolume.cpp index 9be2415d5..b0d26afd9 100644 --- a/trinity/Eve/Volume/EveEllipsoidVolume.cpp +++ b/trinity/Eve/Volume/EveEllipsoidVolume.cpp @@ -86,7 +86,7 @@ float EveEllipsoidVolume::GetIntensity( Vector3 position ) return 1.0f; } - m_innerIntersection = Vector3(0, 0, 0); + m_innerIntersection = Vector3( 0, 0, 0 ); Vector3 rayDir = Normalize( m_position - position ); IntersectEllipsoidRayClosest( m_outerIntersection, m_position, m_shape, position, rayDir ); @@ -128,7 +128,7 @@ void EveEllipsoidVolume::GeneratePointsInVolume( std::vector& points, s Vector3 angle( sqrt( 1.f - z * z ) * cos( a ), sqrt( 1.f - z * z ) * sin( a ), z ); angle = Normalize( angle ); - if( (float( rand() ) / RAND_MAX) > sizeDifference ) + if( ( float( rand() ) / RAND_MAX ) > sizeDifference ) { position = angle * ( m_innerShape + ( m_shape - m_innerShape ) * pow( (float)rand() / RAND_MAX, 0.75f * fallOffFactor ) ); } diff --git a/trinity/Eve/Volume/EveEllipsoidVolume.h b/trinity/Eve/Volume/EveEllipsoidVolume.h index e846e36c4..855d1cc47 100644 --- a/trinity/Eve/Volume/EveEllipsoidVolume.h +++ b/trinity/Eve/Volume/EveEllipsoidVolume.h @@ -28,7 +28,7 @@ BLUE_CLASS( EveEllipsoidVolume ) : ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////// // IInitialize @@ -55,7 +55,6 @@ BLUE_CLASS( EveEllipsoidVolume ) : std::map> m_onChangeCallbacks; uint32_t m_nextCallbackID; - }; TYPEDEF_BLUECLASS( EveEllipsoidVolume ); \ No newline at end of file diff --git a/trinity/Eve/Volume/EveEllipsoidVolume_Blue.cpp b/trinity/Eve/Volume/EveEllipsoidVolume_Blue.cpp index 2caab1cbf..ba5104e3e 100644 --- a/trinity/Eve/Volume/EveEllipsoidVolume_Blue.cpp +++ b/trinity/Eve/Volume/EveEllipsoidVolume_Blue.cpp @@ -20,5 +20,5 @@ const Be::ClassInfo* EveEllipsoidVolume::ExposeToBlue() MAP_ATTRIBUTE( "debugShowIntersection", m_debugShowIntersection, "When volume debugging is on, you the intersection points can be shown", Be::READWRITE ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/Volume/EveSphereVolume.cpp b/trinity/Eve/Volume/EveSphereVolume.cpp index a86e3759b..e0f9c8e9d 100644 --- a/trinity/Eve/Volume/EveSphereVolume.cpp +++ b/trinity/Eve/Volume/EveSphereVolume.cpp @@ -7,7 +7,7 @@ #include "include/TriMath.h" EveSphereVolume::EveSphereVolume( IRoot* lockobj ) : - m_innerSphere( Vector3(0.0f, 0.0f, 0.0f), 1.0f ), + m_innerSphere( Vector3( 0.0f, 0.0f, 0.0f ), 1.0f ), m_outerSphere( Vector3( 0.0f, 0.0f, 0.0f ), 1.0f ), m_nextCallbackID( 1 ) { @@ -30,10 +30,10 @@ const CcpMath::Sphere EveSphereVolume::GetBoundingSphere() const float EveSphereVolume::GetIntensity( Vector3 position ) { - if( m_outerSphere.IsPointInside(position) ) + if( m_outerSphere.IsPointInside( position ) ) { // since the innersphere is offset from the outer sphere, we need to construct a new one that is centered in the owners object space - CcpMath::Sphere innerModified(m_innerSphere); + CcpMath::Sphere innerModified( m_innerSphere ); innerModified.center += m_outerSphere.center; if( innerModified.IsPointInside( position ) ) { @@ -43,7 +43,7 @@ float EveSphereVolume::GetIntensity( Vector3 position ) // will need a more complex solution for that float distFromInnnerCenter = LengthSq( position - m_outerSphere.center ); float distFromInnerSurface = distFromInnnerCenter - pow( innerModified.radius, 2.0f ); - + float interpolationDistance = pow( m_outerSphere.radius, 2.0f ) - pow( innerModified.radius, 2.0f ); return 1.0f - distFromInnerSurface / interpolationDistance; } @@ -80,7 +80,7 @@ void EveSphereVolume::GeneratePointsInVolume( std::vector& points, size for( size_t i = 0; i < howManyToAdd; i++ ) { - if( (float) rand() / RAND_MAX < sizeDifference ) + if( (float)rand() / RAND_MAX < sizeDifference ) { // inner volume dist = m_innerSphere.radius * pow( (float)rand() / RAND_MAX, 1.f / 3.f ); @@ -100,7 +100,6 @@ void EveSphereVolume::GeneratePointsInVolume( std::vector& points, size points.push_back( position ); } } - } uint32_t EveSphereVolume::RegisterForChanges( const std::function& callBack ) @@ -118,7 +117,7 @@ void EveSphereVolume::UnregisterForChanges( uint32_t callbackID ) // INotify bool EveSphereVolume::OnModified( Be::Var* val ) { - + if( IsMatch( val, m_innerSphere.radius ) ) { if( m_innerSphere.radius > m_outerSphere.radius ) @@ -133,7 +132,7 @@ bool EveSphereVolume::OnModified( Be::Var* val ) if( m_innerSphere.radius > m_outerSphere.radius ) { - m_innerSphere.radius = m_outerSphere.radius; + m_innerSphere.radius = m_outerSphere.radius; } } diff --git a/trinity/Eve/Volume/EveSphereVolume.h b/trinity/Eve/Volume/EveSphereVolume.h index 516819f7a..03e61dd31 100644 --- a/trinity/Eve/Volume/EveSphereVolume.h +++ b/trinity/Eve/Volume/EveSphereVolume.h @@ -18,7 +18,7 @@ BLUE_CLASS( EveSphereVolume ) : ///////////////////////////////////////////////////////////////////////////////////// // IEveVolume - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Color& baseColor ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Color& baseColor ) override; float GetIntensity( Vector3 position ) override; uint32_t RegisterForChanges( const std::function& callBack ) override; void UnregisterForChanges( uint32_t callbackID ) override; @@ -27,7 +27,7 @@ BLUE_CLASS( EveSphereVolume ) : ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); private: BlueSharedString m_name; diff --git a/trinity/Eve/Volume/EveSphereVolume_Blue.cpp b/trinity/Eve/Volume/EveSphereVolume_Blue.cpp index c330aeda8..0d3bb8b7b 100644 --- a/trinity/Eve/Volume/EveSphereVolume_Blue.cpp +++ b/trinity/Eve/Volume/EveSphereVolume_Blue.cpp @@ -17,5 +17,5 @@ const Be::ClassInfo* EveSphereVolume::ExposeToBlue() MAP_ATTRIBUTE( "radius", m_outerSphere.radius, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "innerRadius", m_innerSphere.radius, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Eve/Volume/IEveVolume.h b/trinity/Eve/Volume/IEveVolume.h index 3cb7782e3..d46188bb7 100644 --- a/trinity/Eve/Volume/IEveVolume.h +++ b/trinity/Eve/Volume/IEveVolume.h @@ -7,14 +7,15 @@ BLUE_DECLARE_INTERFACE( IEveVolume ); -BLUE_INTERFACE( IEveVolume ) : public IRoot +BLUE_INTERFACE( IEveVolume ) : + public IRoot { virtual float GetIntensity( Vector3 position ) = 0; - virtual uint32_t RegisterForChanges( const std::function & callBack ) = 0; // returns the callbackID + virtual uint32_t RegisterForChanges( const std::function& callBack ) = 0; // returns the callbackID virtual void UnregisterForChanges( uint32_t callbackID ) = 0; // GeneratePointsFromOuterVolume : returns N points in volume with directions facing the closest outward surface - virtual void GeneratePointsInVolume( std::vector& points, size_t howManyToAdd, bool excludeInnerVolume, float fallOffFactor ) = 0; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& parentTransform, const Color& baseColor = 0xFFFFFFFF) = 0; + virtual void GeneratePointsInVolume( std::vector & points, size_t howManyToAdd, bool excludeInnerVolume, float fallOffFactor ) = 0; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& parentTransform, const Color& baseColor = 0xFFFFFFFF ) = 0; virtual const CcpMath::Sphere GetBoundingSphere() const = 0; }; BLUE_DECLARE_IVECTOR( IEveVolume ); diff --git a/trinity/EveSprite2dBracket.cpp b/trinity/EveSprite2dBracket.cpp index fd7e70976..67bdc65dc 100644 --- a/trinity/EveSprite2dBracket.cpp +++ b/trinity/EveSprite2dBracket.cpp @@ -8,7 +8,6 @@ EveSprite2dBracket::EveSprite2dBracket( IRoot* lockobj /*= nullptr */ ) : m_color( 1.0, 1.0f, 1.0f, 1.0f ), m_display( true ) { - } Vector2 EveSprite2dBracket::GetTranslation() const @@ -40,4 +39,3 @@ void EveSprite2dBracket::SetDisplay( bool b ) { m_display = b; } - diff --git a/trinity/EveSprite2dBracket.h b/trinity/EveSprite2dBracket.h index 09c4066a8..614a989d3 100644 --- a/trinity/EveSprite2dBracket.h +++ b/trinity/EveSprite2dBracket.h @@ -19,7 +19,7 @@ BLUE_CLASS( EveSprite2dBracket ) : Tr2AtlasTexture* GetIcon() const; const Color& GetColor() const; - + void SetDisplay( bool b ); bool IsDisplay() const; diff --git a/trinity/EveSprite2dBracketRenderer.cpp b/trinity/EveSprite2dBracketRenderer.cpp index 0093cb3f6..f05784a94 100644 --- a/trinity/EveSprite2dBracketRenderer.cpp +++ b/trinity/EveSprite2dBracketRenderer.cpp @@ -10,7 +10,6 @@ EveSprite2dBracketRenderer::EveSprite2dBracketRenderer( IRoot* lockobj /*= nullp PARENTLOCK( m_brackets ), m_bracketCountInBuffers( 0 ) { - } unsigned int EveSprite2dBracketRenderer::GetVertexCount() @@ -66,7 +65,7 @@ void EveSprite2dBracketRenderer::GatherSprites( Tr2Sprite2dScene* renderer ) { CCP_LOGERR( "%s failed to lock vertex buffer (%d)", __FUNCTION__, hr ); return; - } + } // Fill the index buffer now - it only changes when the count changes. unsigned short* indices; @@ -76,7 +75,7 @@ void EveSprite2dBracketRenderer::GatherSprites( Tr2Sprite2dScene* renderer ) CCP_LOGERR( "%s failed to lock index buffer (%d)", __FUNCTION__, hr ); return; } - ON_BLOCK_EXIT( [&]{ m_indexBuffer.UnmapForWriting( renderContext ); } ); + ON_BLOCK_EXIT( [&] { m_indexBuffer.UnmapForWriting( renderContext ); } ); unsigned short* curIndex = indices; unsigned int spriteIx = 0; @@ -85,7 +84,7 @@ void EveSprite2dBracketRenderer::GatherSprites( Tr2Sprite2dScene* renderer ) { for( unsigned int i = 0; i < 4; ++i ) { - Tr2Sprite2dD3DVertex& v = vertices[spriteIx*4 + i]; + Tr2Sprite2dD3DVertex& v = vertices[spriteIx * 4 + i]; v.glowBrightness = 1; v.blendMode = PackBlendMode( TR2_SBM_BLEND, Tr2SpriteTarget::COLOR ); @@ -172,7 +171,7 @@ void EveSprite2dBracketRenderer::GatherSprites( Tr2Sprite2dScene* renderer ) tl.position.y = translation.y; tl.texCoord[0] = Vector2( xZero, yZero ); tl.color = color; - + Tr2Sprite2dD3DVertex& tr = curVertex[1]; tr.position.x = translation.x + width; tr.position.y = translation.y; diff --git a/trinity/EveSprite2dBracketRenderer.h b/trinity/EveSprite2dBracketRenderer.h index 0407bdbfb..fb7d472eb 100644 --- a/trinity/EveSprite2dBracketRenderer.h +++ b/trinity/EveSprite2dBracketRenderer.h @@ -12,9 +12,8 @@ BLUE_DECLARE( EveSprite2dBracket ); BLUE_DECLARE_VECTOR( EveSprite2dBracket ); BLUE_DECLARE( Tr2AtlasTexture ); -class EveSprite2dBracketRenderer : - public Tr2SpriteObject, - public Tr2DeviceResource +class EveSprite2dBracketRenderer : public Tr2SpriteObject, + public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); @@ -29,6 +28,7 @@ class EveSprite2dBracketRenderer : ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); @@ -41,8 +41,8 @@ class EveSprite2dBracketRenderer : // Vertex/index buffers. They are recreated whenever the count of // brackets changes. - Tr2BufferAL m_vertexBuffer; - Tr2BufferAL m_indexBuffer; + Tr2BufferAL m_vertexBuffer; + Tr2BufferAL m_indexBuffer; }; TYPEDEF_BLUECLASS( EveSprite2dBracketRenderer ); diff --git a/trinity/EveSprite2dBracketRenderer_Blue.cpp b/trinity/EveSprite2dBracketRenderer_Blue.cpp index a0ae765c5..459fc9778 100644 --- a/trinity/EveSprite2dBracketRenderer_Blue.cpp +++ b/trinity/EveSprite2dBracketRenderer_Blue.cpp @@ -11,21 +11,17 @@ const Be::ClassInfo* EveSprite2dBracketRenderer::ExposeToBlue() EXPOSURE_BEGIN( EveSprite2dBracketRenderer, "" ) MAP_INTERFACE( EveSprite2dBracketRenderer ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "brackets", m_brackets, "The list of individual brackets", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "iconAtlas", m_iconAtlas, "A reference to a texture in the atlas that all icons are assumed to live in.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_CHAINTO( Tr2SpriteObject ) } \ No newline at end of file diff --git a/trinity/EveSprite2dBracket_Blue.cpp b/trinity/EveSprite2dBracket_Blue.cpp index a8af24ec9..545075ab8 100644 --- a/trinity/EveSprite2dBracket_Blue.cpp +++ b/trinity/EveSprite2dBracket_Blue.cpp @@ -10,37 +10,29 @@ const Be::ClassInfo* EveSprite2dBracket::ExposeToBlue() EXPOSURE_BEGIN( EveSprite2dBracket, "" ) MAP_INTERFACE( EveSprite2dBracket ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "display", m_display, "Is the bracket visible?", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translation", m_translation, "Translation of this bracket.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "icon", m_icon, "Icon of this bracket.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "color", m_color, "Color of this bracket.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Font/Tr2FontManager.cpp b/trinity/Font/Tr2FontManager.cpp index 382606a2d..b9ed6a08c 100644 --- a/trinity/Font/Tr2FontManager.cpp +++ b/trinity/Font/Tr2FontManager.cpp @@ -14,7 +14,7 @@ using namespace Tr2RenderContextEnum; -CCP_STATS_DECLARE( fontMem, "Trinity/FontMemory", false, CST_MEMORY, "Memory used by the font system"); +CCP_STATS_DECLARE( fontMem, "Trinity/FontMemory", false, CST_MEMORY, "Memory used by the font system" ); Tr2FontManager* g_fontManager = NULL; @@ -53,7 +53,7 @@ void* Tr2FreeTypeRealloc( FT_Memory memory, long curSize, long newSize, void* bl static struct FT_MemoryRec_ s_ft_memory = { NULL, Tr2FreeTypeAlloc, Tr2FreeTypeFree, Tr2FreeTypeRealloc }; -static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count ); +static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ); static void FileClose( FT_Stream stream ); static const char* s_cookie = "fontMan"; @@ -83,7 +83,7 @@ void Tr2FontManager::Shutdown() g_fontManager = NULL; } -Tr2FontManager::Tr2FontManager( IRoot* lockobj ) : +Tr2FontManager::Tr2FontManager( IRoot* lockobj ) : m_manager( NULL ), m_cmCache( NULL ), m_sbitCache( NULL ), @@ -96,9 +96,9 @@ Tr2FontManager::Tr2FontManager( IRoot* lockobj ) : m_reverseFaceMap( "Tr2FontManager/m_reverseFaceMap" ), m_sbitToTextureMap( "Tr2FontManager/m_sbitToTextureMap" ), m_sbitToCachedTextureMap( "Tr2FontManager/m_sbitToCachedTextureMap" ), - m_textureToSbitMap( "Tr2FontManager/m_textureToSbitMap"), + m_textureToSbitMap( "Tr2FontManager/m_textureToSbitMap" ), m_totalGlyphsCachedSize( 0 ), - m_glyphCacheBudget( 512*1024 ) + m_glyphCacheBudget( 512 * 1024 ) { FT_Error err = FT_New_Library( &s_ft_memory, &m_ftLib ); if( err ) @@ -209,7 +209,7 @@ FT_Size_Metrics Tr2FontManager::LookupMetrics( const FaceID& faceID, unsigned in { CCP_STATS_ZONE( __FUNCTION__ ); - FTC_ScalerRec scaler = {(FTC_FaceID)faceID, width, height, 1, 0, 0 }; // 1 indicates to use pixel sizes + FTC_ScalerRec scaler = { (FTC_FaceID)faceID, width, height, 1, 0, 0 }; // 1 indicates to use pixel sizes FT_Size size; FT_Error err = FTC_Manager_LookupSize( m_manager, &scaler, &size ); if( err ) @@ -239,7 +239,7 @@ std::pair Tr2FontManager::LookupMetricsFromScript( const FaceID& faceI // Returns: // Horizontal (x) kerning value, in pixels, for the given glyph pair. ////////////////////////////////////////////////////////////////////////// -FT_Pos Tr2FontManager::LookupKerningXP(const FaceID& faceID, int leftIndex, int rightIndex ) +FT_Pos Tr2FontManager::LookupKerningXP( const FaceID& faceID, int leftIndex, int rightIndex ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -298,7 +298,7 @@ int Tr2FontManager::LookupGlyphIndex( const FaceID& faceID, int charCode ) // height - the height of the font, in pixels // glyphIndex - glyph index as returned by LookupGlyphIndex ////////////////////////////////////////////////////////////////////////// - Be::Result Tr2FontManager::LookupSBit( const FaceID& faceID, int width, int height, int glyphIndex, Tr2SBitWrapper** result ) +Be::Result Tr2FontManager::LookupSBit( const FaceID& faceID, int width, int height, int glyphIndex, Tr2SBitWrapper** result ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -326,7 +326,7 @@ int Tr2FontManager::LookupGlyphIndex( const FaceID& faceID, int charCode ) inline FT_Fixed Fix( float f ) { - return (FT_Fixed) floor(f * float(1<<16) + 0.5f); + return (FT_Fixed)floor( f * float( 1 << 16 ) + 0.5f ); } //----------------------------------------------------------------------------- @@ -370,14 +370,14 @@ FT_Face Tr2FontManager::LoadFromDisk( FTC_FaceID id ) // to the stream when it is done, making it safe for // us to delete it there. FT_Stream stream = CCP_NEW( "Tr2FontManager/LoadFromDisk/stream" ) FT_StreamRec; - if( !stream ) + if( !stream ) { return NULL; } memset( stream, 0, sizeof( *stream ) ); stream->descriptor.pointer = (void*)fp.p; - + stream->read = &FileRead; stream->close = &FileClose; stream->size = (unsigned int)fileLength; @@ -386,7 +386,7 @@ FT_Face Tr2FontManager::LoadFromDisk( FTC_FaceID id ) openargs.flags = FT_OPEN_STREAM; openargs.stream = stream; FT_Face face; - FT_Error e = FT_Open_Face(m_ftLib, &openargs, 0, &face); + FT_Error e = FT_Open_Face( m_ftLib, &openargs, 0, &face ); if( e ) { CCP_LOGERR( "Tr2FontManager::LoadFromDisk: FT_Open_Face failed for '%s'", fontPath ); @@ -408,7 +408,7 @@ FT_Face Tr2FontManager::LoadFromDisk( FTC_FaceID id ) FT_Error Tr2FontManager::FaceRequester( FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face* aface ) { Tr2FontManager* fm = reinterpret_cast( request_data ); - + *aface = fm->LoadFromDisk( face_id ); if( *aface == NULL ) { @@ -422,7 +422,7 @@ FT_Error Tr2FontManager::FaceRequester( FTC_FaceID face_id, FT_Library library, //A function to get the bit value from a b/w bitmap inline int GetBit( uint8_t* line, int bit ) { - const int c = (int)line[bit>>3]; + const int c = (int)line[bit >> 3]; const int mask = 128 >> ( bit & 7 ); return c & mask; } @@ -494,7 +494,7 @@ bool Tr2FontManager::GetAtlasTextureForSbit( FTC_SBit sbit, Tr2AtlasTexture** at if( sbit->format == 1 ) { - for( int l = 0; l < sbit->height; ++l ) + for( int l = 0; l < sbit->height; ++l ) { uint32_t* pDestLine = (uint32_t*)( (char*)pDest + l * pitch ); uint8_t* pSrcLine = (uint8_t*)sbit->buffer + l * sbit->pitch; @@ -518,7 +518,7 @@ bool Tr2FontManager::GetAtlasTextureForSbit( FTC_SBit sbit, Tr2AtlasTexture** at } else { - for( int l = 0; l < sbit->height; ++l ) + for( int l = 0; l < sbit->height; ++l ) { uint32_t* pDestLine = (uint32_t*)( (uint8_t*)pDest + l * pitch ); uint8_t* pSrcLine = (uint8_t*)sbit->buffer + l * sbit->pitch; @@ -540,7 +540,7 @@ bool Tr2FontManager::GetAtlasTextureForSbit( FTC_SBit sbit, Tr2AtlasTexture** at uint32_t* pLastLine = (uint32_t*)( (uint8_t*)pDest + sbit->height * pitch ); CCP_ASSERT( pitch >= sbit->width * 4u ); memset( pLastLine, 0, sbit->width * 4 ); - + tex->UnlockBuffer(); BluePtr weakObj( BlueCastPtr( tex->GetRawRoot() ) ); @@ -561,7 +561,7 @@ void Tr2FontManager::WeakRefNotify( IWeakObject* p ) { // Object is about to die - we resurrect it, but move it to a different map. FTC_SBit sbit = m_textureToSbitMap[p]; - + // Remove the object from the main map m_sbitToTextureMap.erase( sbit ); m_textureToSbitMap.erase( p ); @@ -576,7 +576,7 @@ void Tr2FontManager::WeakRefNotify( IWeakObject* p ) entry.glyphObject = p; entry.lastFrameUsed = unsigned( Tr2Renderer::GetCurrentFrameCounter() ); entry.memoryUsage = memoryUsage; - m_sbitToCachedTextureMap[ sbit ] = entry; + m_sbitToCachedTextureMap[sbit] = entry; p->Lock(); m_totalGlyphsCachedSize += memoryUsage; @@ -733,7 +733,7 @@ std::pair Tr2FontManager::LookupFaceIDAndGlyphIndex( const std::string static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) { IResFile* fp = (IResFile*)stream->descriptor.pointer; - + if( count == 0 ) { ssize_t ret = fp->Seek( offset, ICcpStream::SO_BEGIN ); @@ -755,7 +755,7 @@ static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned while( (unsigned long)bytesRead < count ) { bytesRead += fp->Read( (void*)tmpData, count - bytesRead ); - + memcpy( buffer, tmpData, bytesRead ); buffer += bytesRead; } @@ -766,8 +766,8 @@ static unsigned long FileRead( FT_Stream stream, unsigned long offset, unsigned static void FileClose( FT_Stream stream ) { - IResFile* fp = ((IResFile*)stream->descriptor.pointer); - + IResFile* fp = ( (IResFile*)stream->descriptor.pointer ); + // Close the file handle and remove the last reference // to that ResFile instance, effectively deleting it. fp->Close(); @@ -777,4 +777,3 @@ static void FileClose( FT_Stream stream ) // Delete the stream we created in LoadFromDisk delete stream; } - diff --git a/trinity/Font/Tr2FontManager.h b/trinity/Font/Tr2FontManager.h index 1565c5e67..7e00ff9f0 100644 --- a/trinity/Font/Tr2FontManager.h +++ b/trinity/Font/Tr2FontManager.h @@ -17,7 +17,7 @@ BLUE_DECLARE_IVECTOR( IResFile ); BLUE_DECLARE( Tr2FontManager ); BLUE_DECLARE( Tr2SBitWrapper ); BLUE_DECLARE( Tr2AtlasTexture ); - + typedef uintptr_t FaceID; extern const char* TR2_FONT_FALLBACK; @@ -31,11 +31,10 @@ extern const char* TR2_FONT_FALLBACK; // Tr2FontManager is a singleton, accessed from C++ via g_fontManager. // It exposes some functions to Python as Trinity module functions. ////////////////////////////////////////////////////////////////////////// -class Tr2FontManager : - public IRoot, - public IBlueEvents, - public IWeakRef, - public Tr2DeviceResource +class Tr2FontManager : public IRoot, + public IBlueEvents, + public IWeakRef, + public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); @@ -64,16 +63,28 @@ class Tr2FontManager : std::pair LookupFaceIDAndGlyphIndex( const std::string& faceName, int charCode ); // Returns kerning value for the glyph pair - FT_Pos LookupKerningXP(const FaceID& faceID, int leftIndex, int rightIndex ); + FT_Pos LookupKerningXP( const FaceID& faceID, int leftIndex, int rightIndex ); // Returns an sbit (small bitmap) for the given glyph index Be::Result LookupSBit( const FaceID& faceID, int width, int height, int glyphIndex, Tr2SBitWrapper** result ); - FTC_Manager GetManager() const { return m_manager; } - FTC_CMapCache GetCmCache() const { return m_cmCache; } - FTC_SBitCache GetSbitCache() const { return m_sbitCache; } + FTC_Manager GetManager() const + { + return m_manager; + } + FTC_CMapCache GetCmCache() const + { + return m_cmCache; + } + FTC_SBitCache GetSbitCache() const + { + return m_sbitCache; + } - unsigned int GetLoadFlag() const { return m_loadflag; } + unsigned int GetLoadFlag() const + { + return m_loadflag; + } bool GetAtlasTextureForSbit( FTC_SBit sbit, Tr2AtlasTexture** at ); @@ -101,6 +112,7 @@ class Tr2FontManager : ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); @@ -124,7 +136,7 @@ class Tr2FontManager : FT_Library m_ftLib; FTC_Face_Requester m_requesterCallback; - + // Cache Managers FTC_Manager m_manager; FTC_CMapCache m_cmCache; diff --git a/trinity/Font/Tr2FontManager_Blue.cpp b/trinity/Font/Tr2FontManager_Blue.cpp index 4b9206df0..ec7203492 100644 --- a/trinity/Font/Tr2FontManager_Blue.cpp +++ b/trinity/Font/Tr2FontManager_Blue.cpp @@ -25,12 +25,12 @@ static bool GetBuf( void** buffer, Py_ssize_t* bufLen, PyObject* arrayO ) } #endif -PyObject* PyClearBuffer(PyObject *self, PyObject *args) +PyObject* PyClearBuffer( PyObject* self, PyObject* args ) { - PyObject *arrayO; + PyObject* arrayO; int width, height, pitch; int col = 0; - if (!PyArg_ParseTuple(args,"Oiii|i", &arrayO, &width, &height, &pitch, &col)) + if( !PyArg_ParseTuple( args, "Oiii|i", &arrayO, &width, &height, &pitch, &col ) ) return 0; void* destPtr = nullptr; @@ -41,36 +41,36 @@ PyObject* PyClearBuffer(PyObject *self, PyObject *args) return nullptr; } #else - Py_buffer buf; - if(PyObject_GetBuffer(arrayO, &buf, PyBUF_SIMPLE) == -1) + Py_buffer buf; + if( PyObject_GetBuffer( arrayO, &buf, PyBUF_SIMPLE ) == -1 ) { return nullptr; } ON_BLOCK_EXIT( [&] { PyBuffer_Release( &buf ); } ); - destPtr = buf.buf; - destLen = buf.len; + destPtr = buf.buf; + destLen = buf.len; #endif - if( width*4 > pitch ) + if( width * 4 > pitch ) { - PyErr_SetString(PyExc_RuntimeError, "width larger than pitch!"); + PyErr_SetString( PyExc_RuntimeError, "width larger than pitch!" ); return nullptr; } if( height * pitch > destLen ) { - PyErr_SetString(PyExc_RuntimeError, "destination too short!"); + PyErr_SetString( PyExc_RuntimeError, "destination too short!" ); return nullptr; } - for( int i = 0; i struct delete_disposer { void operator()( T* delete_this ) - { delete delete_this; } + { + delete delete_this; + } }; // Tr2FontRenderData holds the data from one AddText call struct Tr2FontRenderData { // cppcheck-suppress uninitMemberVar - Tr2FontRenderData() - :tail( nullptr ), - bitmapCount( 0 ) - { + Tr2FontRenderData() : + tail( nullptr ), + bitmapCount( 0 ) + { } USE_CACHED_ALLOCATOR( Tr2FontRenderData ) - + // cursorX value that was in effect before this text segment was added. // This is used to reset the cursor when canceling text. int prevCursorX; @@ -133,7 +135,7 @@ void Tr2FontMeasurer::Reset() m_ascender = 0; m_descender = 0; m_currentFace = 0; - + for( auto it = m_renderData.begin(); it != m_renderData.end(); ++it ) { Tr2FontRenderData* rd = *it; @@ -145,17 +147,17 @@ void Tr2FontMeasurer::Reset() { Tr2FontRenderData* rd = *it; delete rd; - } + } m_committedRenderData.clear(); if( m_vertices ) { - CCP_DELETE [] m_vertices; + CCP_DELETE[] m_vertices; m_vertices = nullptr; m_vertexCount = 0; - CCP_DELETE [] m_indices; + CCP_DELETE[] m_indices; m_indices = nullptr; m_indexCount = 0; } @@ -234,7 +236,7 @@ unsigned int Tr2FontMeasurer::AddText( const std::wstring& text ) // Store cursor position for possible cancellation of text renderData->prevCursorX = m_cursorX; - + if( m_underline ) { renderData->underline = true; @@ -298,7 +300,7 @@ unsigned int Tr2FontMeasurer::AddText( const std::wstring& text ) } m_fallbackCmapIndex = FT_Get_Charmap_Index( m_ftFallbackFace->charmap ); - + m_imgTypeFallback.face_id = (FTC_FaceID)m_fallbackFace; m_imgTypeFallback.flags = g_fontManager->GetLoadFlag(); m_imgTypeFallback.width = m_fontSize; @@ -446,7 +448,7 @@ int Tr2FontMeasurer::GetIndexAtPos( int x ) { CharacterBitmap& cbit = *sbIter; - if( (x >= cbit.x) && (x <= cbit.x + cbit.sbit->xadvance) ) + if( ( x >= cbit.x ) && ( x <= cbit.x + cbit.sbit->xadvance ) ) { return ix; } @@ -530,12 +532,12 @@ void Tr2FontMeasurer::DrawToTexture( TriTextureRes* texture ) void* pBits; uint32_t Pitch; CR_RETURN( tex->MapForWriting( Tr2TextureSubresource( 0 ), pBits, Pitch, renderContext ) ); - ON_BLOCK_EXIT( [&]{ tex->UnmapForWriting( renderContext ); } ); + ON_BLOCK_EXIT( [&] { tex->UnmapForWriting( renderContext ); } ); - DrawToBuffer( texture->GetWidth(), - texture->GetHeight(), - pBits, - Pitch ); + DrawToBuffer( texture->GetWidth(), + texture->GetHeight(), + pBits, + Pitch ); } void Tr2FontMeasurer::DrawToHostBitmap( Tr2HostBitmap* hostBitmap ) @@ -547,10 +549,10 @@ void Tr2FontMeasurer::DrawToHostBitmap( Tr2HostBitmap* hostBitmap ) return; } - DrawToBuffer( hostBitmap->GetWidth(), - hostBitmap->GetHeight(), - hostBitmap->GetRawData(), - hostBitmap->GetPitch() ); + DrawToBuffer( hostBitmap->GetWidth(), + hostBitmap->GetHeight(), + hostBitmap->GetRawData(), + hostBitmap->GetPitch() ); } bool Tr2FontMeasurer::HasCommittedText() @@ -566,22 +568,22 @@ bool Tr2FontMeasurer::HasUncommittedText() //A function to get the bit value from a b/w bitmap inline int GetBit( uint8_t* line, int bit ) { - const int c = (int)line[bit>>3]; + const int c = (int)line[bit >> 3]; const int mask = 128 >> ( bit & 7 ); return c & mask; } -void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, - uint32_t destHeight, - void* pData, - uint32_t pitch ) +void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, + uint32_t destHeight, + void* pData, + uint32_t pitch ) { CCP_STATS_ZONE( __FUNCTION__ ); for( uint32_t i = 0; i < destHeight; ++i ) { - memset( (uint8_t*)pData + i*pitch, 0, destWidth*4 ); + memset( (uint8_t*)pData + i * pitch, 0, destWidth * 4 ); } for( auto it = m_committedRenderData.begin(); it != m_committedRenderData.end(); ++it ) @@ -629,7 +631,7 @@ void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, if( sbit->format == 1 ) { // Top as 1 being the bottom line! - for( int l = sbitTop; l < sbitBottom; ++l ) + for( int l = sbitTop; l < sbitBottom; ++l ) { int destLine = top + l; uint32_t* pDestLine = (uint32_t*)( (char*)pData + destLine * pitch ); @@ -655,7 +657,7 @@ void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, else { // Top as 1 being the bottom line! - for( int l = sbitTop; l < sbitBottom; ++l ) + for( int l = sbitTop; l < sbitBottom; ++l ) { int destLine = top + l; uint32_t* pDestLine = (uint32_t*)( (char*)pData + destLine * pitch ); @@ -673,7 +675,7 @@ void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, int destColumn = left + c; uint32_t destColor = rd->color & 0x00ffffff; - uint8_t a = (gray * (alphaFromColor + 1)) >> 8; + uint8_t a = ( gray * ( alphaFromColor + 1 ) ) >> 8; destColor |= a << 24; uint32_t* dp = pDestLine + destColumn; @@ -691,8 +693,8 @@ void Tr2FontMeasurer::DrawToBuffer( uint32_t destWidth, Underline_To_RGBABuffer( pData, - destWidth, - destHeight, + destWidth, + destHeight, pitch, cbit.x, destHeight - cbit.y + rd->underlinePosition, @@ -738,18 +740,17 @@ int Tr2FontMeasurer::GetFontSize() const return m_fontSize; } -void Tr2FontMeasurer::PrepareSprites( Tr2Sprite2dScene* renderer, const Vector2& translation, const Color& color, Tr2SpriteObjectEffect sfx, Tr2SpriteObjectBlendMode blendMode, Tr2SpriteTarget target, - float glowBrightness, bool dropShadow, const Vector2& shadowOffset, const Color& shadowColor, Tr2SpriteObjectEffect shadowSfx ) +void Tr2FontMeasurer::PrepareSprites( Tr2Sprite2dScene* renderer, const Vector2& translation, const Color& color, Tr2SpriteObjectEffect sfx, Tr2SpriteObjectBlendMode blendMode, Tr2SpriteTarget target, float glowBrightness, bool dropShadow, const Vector2& shadowOffset, const Color& shadowColor, Tr2SpriteObjectEffect shadowSfx ) { CCP_STATS_ZONE( __FUNCTION__ ); if( m_vertices ) { - CCP_DELETE [] m_vertices; + CCP_DELETE[] m_vertices; m_vertices = nullptr; m_vertexCount = 0; - CCP_DELETE [] m_indices; + CCP_DELETE[] m_indices; m_indices = nullptr; m_indexCount = 0; } @@ -1116,7 +1117,7 @@ void Tr2FontMeasurer::SubmitSprites( Tr2Sprite2dScene* renderer ) if( adjustedIndices ) { - CCP_DELETE [] adjustedIndices; + CCP_DELETE[] adjustedIndices; } } } @@ -1125,11 +1126,11 @@ void Tr2FontMeasurer::ClearSprites() { if( m_vertices ) { - CCP_DELETE [] m_vertices; + CCP_DELETE[] m_vertices; m_vertices = nullptr; m_vertexCount = 0; - CCP_DELETE [] m_indices; + CCP_DELETE[] m_indices; m_indices = nullptr; m_indexCount = 0; } @@ -1186,13 +1187,13 @@ void Tr2FontMeasurer::NotifyListenersOfChange() { for( auto it = m_changeListeners.begin(); it != m_changeListeners.end(); ++it ) { - (*it)->FontMeasurerChanged( this ); + ( *it )->FontMeasurerChanged( this ); } } float Tr2FontMeasurer::CalcAlphaForHorizontal( float x ) { - if( (m_fadeLeftStart > 0.0f) && (x < m_fadeLeftStart) ) + if( ( m_fadeLeftStart > 0.0f ) && ( x < m_fadeLeftStart ) ) { return 0.0f; } @@ -1202,19 +1203,19 @@ float Tr2FontMeasurer::CalcAlphaForHorizontal( float x ) return 0.0f; } - if( (x >= m_fadeLeftEnd) && (x <= m_fadeRightStart) ) + if( ( x >= m_fadeLeftEnd ) && ( x <= m_fadeRightStart ) ) { return 1.0f; } - if( (x >= m_fadeLeftStart) && (x <= m_fadeLeftEnd) ) + if( ( x >= m_fadeLeftStart ) && ( x <= m_fadeLeftEnd ) ) { - return (x - m_fadeLeftStart) / (m_fadeLeftEnd - m_fadeLeftStart); + return ( x - m_fadeLeftStart ) / ( m_fadeLeftEnd - m_fadeLeftStart ); } - if( (x >= m_fadeRightStart) && (x <= m_fadeRightEnd) ) + if( ( x >= m_fadeRightStart ) && ( x <= m_fadeRightEnd ) ) { - return 1.0f - (x - m_fadeRightStart) / (m_fadeRightEnd - m_fadeRightStart); + return 1.0f - ( x - m_fadeRightStart ) / ( m_fadeRightEnd - m_fadeRightStart ); } return 1.0f; @@ -1232,19 +1233,19 @@ float Tr2FontMeasurer::CalcAlphaForVertical( float y ) return 0.0f; } - if( (y >= m_fadeTopEnd) && (y <= m_fadeBottomStart) ) + if( ( y >= m_fadeTopEnd ) && ( y <= m_fadeBottomStart ) ) { return 1.0f; } - if( (y >= m_fadeTopStart) && (y <= m_fadeTopEnd) ) + if( ( y >= m_fadeTopStart ) && ( y <= m_fadeTopEnd ) ) { - return (y - m_fadeTopStart) / (m_fadeTopEnd - m_fadeTopStart); + return ( y - m_fadeTopStart ) / ( m_fadeTopEnd - m_fadeTopStart ); } - if( (y >= m_fadeBottomStart) && (y <= m_fadeBottomEnd) ) + if( ( y >= m_fadeBottomStart ) && ( y <= m_fadeBottomEnd ) ) { - return 1.0f - (y - m_fadeBottomStart) / (m_fadeBottomEnd - m_fadeBottomStart); + return 1.0f - ( y - m_fadeBottomStart ) / ( m_fadeBottomEnd - m_fadeBottomStart ); } return 1.0f; @@ -1360,21 +1361,22 @@ unsigned short* Tr2FontMeasurer::AdjustIndicesIfNeeded( unsigned int startSprite int32_t Tr2FontMeasurer::GetColor() { - return static_cast(m_color); + return static_cast( m_color ); } void Tr2FontMeasurer::SetColor( int32_t color ) { - m_color = static_cast(color); + m_color = static_cast( color ); } //----------------------------------------------------------------------------- // Implementation of buffer copy helpers. //----------------------------------------------------------------------------- -struct RGBA { +struct RGBA +{ - static unsigned char Max(unsigned char l, unsigned char r) + static unsigned char Max( unsigned char l, unsigned char r ) { return l > r ? l : r; } @@ -1420,7 +1422,7 @@ struct RGBA { //this is scaled by 255, we have to divide by 255, but k*a/255 is the same as (k*(a+1))>>8 due to precision static inline int BlendAlpha( int a1, int a2 ) { - return a1 + a2 - ( ( a1 * ( a2 + 1 ) ) >> 8) ; + return a1 + a2 - ( ( a1 * ( a2 + 1 ) ) >> 8 ); } void BlendOverAlpha( const RGBA& other ) @@ -1440,11 +1442,11 @@ struct RGBA { } } - union + union { unsigned int col; unsigned char c[4]; - struct + struct { unsigned char r; unsigned char g; @@ -1455,14 +1457,14 @@ struct RGBA { }; void SBit_To_RGBABuffer( - void *destPtr, - int dWidth, - int dHeight, - int dPitch, - FTC_SBit sbit, - int left, - int top, - int col) + void* destPtr, + int dWidth, + int dHeight, + int dPitch, + FTC_SBit sbit, + int left, + int top, + int col ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -1480,9 +1482,9 @@ void SBit_To_RGBABuffer( if( sbit->format == 1 ) { // Black and white - + // Top as 1 being the bottom line! - for( int l = 0; l < sbit->height; l++ ) + for( int l = 0; l < sbit->height; l++ ) { int dLine = top + l; if( dLine < 0 || dLine >= dHeight ) @@ -1500,7 +1502,7 @@ void SBit_To_RGBABuffer( } int dCol = left + c; - if( dCol<0 || dCol >= dWidth ) + if( dCol < 0 || dCol >= dWidth ) { continue; } @@ -1540,7 +1542,7 @@ void SBit_To_RGBABuffer( } // Top as 1 being the bottom line! - for( int l = sbitTop; l < sbitBottom; ++l ) + for( int l = sbitTop; l < sbitBottom; ++l ) { int dLine = top + l; RGBA* dl = (RGBA*)( (char*)destPtr + dLine * dPitch ); @@ -1564,7 +1566,7 @@ void SBit_To_RGBABuffer( } } -void Underline_To_RGBABuffer(void* destPtr, int dWidth, int dHeight, int dPitch, int left, int top, int width, int thickness, int col) +void Underline_To_RGBABuffer( void* destPtr, int dWidth, int dHeight, int dPitch, int left, int top, int width, int thickness, int col ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -1575,7 +1577,7 @@ void Underline_To_RGBABuffer(void* destPtr, int dWidth, int dHeight, int dPitch, //specify top top-down top = dHeight - top; //Note the absence of the -1 here. FreeType insists on this strange transform, it numbers //top as 1 being the bottom line! - for( int l = 0; l < thickness; l++ ) + for( int l = 0; l < thickness; l++ ) { int dLine = top + l; if( dLine < 0 || dLine >= dHeight ) @@ -1586,7 +1588,7 @@ void Underline_To_RGBABuffer(void* destPtr, int dWidth, int dHeight, int dPitch, for( int pixel = 0; pixel < width; ++pixel ) { int dCol = left + pixel; - if( dCol<0 || dCol >= dWidth ) + if( dCol < 0 || dCol >= dWidth ) { continue; } diff --git a/trinity/Font/Tr2FontMeasurer.h b/trinity/Font/Tr2FontMeasurer.h index 454acf761..4c1c08a07 100644 --- a/trinity/Font/Tr2FontMeasurer.h +++ b/trinity/Font/Tr2FontMeasurer.h @@ -66,8 +66,7 @@ class Tr2FontMeasurer : public IRoot // Prepares sprites based on the current contents of the measurer for later // rendering with SubmitSprites. - void PrepareSprites( Tr2Sprite2dScene* renderer, const Vector2& translation, const Color& color, Tr2SpriteObjectEffect sfx, Tr2SpriteObjectBlendMode blendMode, Tr2SpriteTarget target, float glowBrightness, - bool dropShadow, const Vector2& shadowOffset, const Color& shadowColor, Tr2SpriteObjectEffect shadowSfx ); + void PrepareSprites( Tr2Sprite2dScene* renderer, const Vector2& translation, const Color& color, Tr2SpriteObjectEffect sfx, Tr2SpriteObjectBlendMode blendMode, Tr2SpriteTarget target, float glowBrightness, bool dropShadow, const Vector2& shadowOffset, const Color& shadowColor, Tr2SpriteObjectEffect shadowSfx ); // Submits sprites previously prepared with PrepareSprites for rendering. void SubmitSprites( Tr2Sprite2dScene* renderer ); @@ -82,28 +81,28 @@ class Tr2FontMeasurer : public IRoot int GetFontSize() const; float GetFadeLeftStart() const; - void SetFadeLeftStart(float val); + void SetFadeLeftStart( float val ); float GetFadeLeftEnd() const; - void SetFadeLeftEnd(float val); + void SetFadeLeftEnd( float val ); float GetFadeRightStart() const; - void SetFadeRightStart(float val); + void SetFadeRightStart( float val ); float GetFadeRightEnd() const; - void SetFadeRightEnd(float val); + void SetFadeRightEnd( float val ); float GetFadeTopStart() const; - void SetFadeTopStart(float val); + void SetFadeTopStart( float val ); float GetFadeTopEnd() const; - void SetFadeTopEnd(float val); + void SetFadeTopEnd( float val ); float GetFadeBottomStart() const; - void SetFadeBottomStart(float val); + void SetFadeBottomStart( float val ); float GetFadeBottomEnd() const; - void SetFadeBottomEnd(float val); + void SetFadeBottomEnd( float val ); unsigned int GetVertexCount() const; @@ -126,7 +125,7 @@ class Tr2FontMeasurer : public IRoot int m_cursorY; int m_letterSpace; int m_limit; - + // Ascender value for the current line (reset on CommitText) int m_ascender; @@ -141,7 +140,7 @@ class Tr2FontMeasurer : public IRoot uint32_t m_color; int32_t GetColor(); - void SetColor(int32_t color); + void SetColor( int32_t color ); bool m_underline; @@ -149,7 +148,7 @@ class Tr2FontMeasurer : public IRoot float m_fadeLeftEnd; float m_fadeRightStart; float m_fadeRightEnd; - + float m_fadeTopStart; float m_fadeTopEnd; float m_fadeBottomStart; diff --git a/trinity/Font/Tr2FontMeasurer_Blue.cpp b/trinity/Font/Tr2FontMeasurer_Blue.cpp index dc9432ec9..59a09c854 100644 --- a/trinity/Font/Tr2FontMeasurer_Blue.cpp +++ b/trinity/Font/Tr2FontMeasurer_Blue.cpp @@ -12,176 +12,143 @@ const Be::ClassInfo* Tr2FontMeasurer::ExposeToBlue() { EXPOSURE_BEGIN( Tr2FontMeasurer, "Tr2FontMeasurer is used for measuring and rendering fonts." ) MAP_INTERFACE( Tr2FontMeasurer ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "cursorX", m_cursorX, "Current x-position of cursor.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "cursorY", m_cursorY, "Current y-position of cursor.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "letterSpace", m_letterSpace, "Letter spacing, in pixels", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "ascender", m_ascender, "Ascender value, in pixels", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "asc", m_ascender, "Same as ascender (for backwards compatibility)", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "descender", m_descender, "Descender value, in pixels", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "des", m_descender, "Same as descender (for backwards compatibility)", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "limit", m_limit, "Maximum width allowed when adding text", - Be::READWRITE - ) + Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "color", GetColor, SetColor, "Color of the text when drawn to a texture. Can be set explicitly\n" - "or passed in via params to AddText" - ) + "or passed in via params to AddText" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "underline", m_underline, "Should text be underlined when drawn to a texture? Can be set explicitly\n" "or passed in via params to AddText", - Be::READWRITE - ) + Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "font", - GetFont, SetFont, - "Name of font file to use" - ) + GetFont, + SetFont, + "Name of font file to use" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fontSize", - GetFontSize, SetFontSize, - "Size of font, in pixels" - ) + GetFontSize, + SetFontSize, + "Size of font, in pixels" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "letterSpace", m_letterSpace, "Spacing between letters, in pixels", - Be::READWRITE - ) + Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeLeftStart", - GetFadeLeftStart, SetFadeLeftStart, + GetFadeLeftStart, + SetFadeLeftStart, "Distance (in pixels) from the left edge where letters begin to fade in." - "\nAny text to the left of this value will be invisible." - ) + "\nAny text to the left of this value will be invisible." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeLeftEnd", - GetFadeLeftEnd, SetFadeLeftEnd, + GetFadeLeftEnd, + SetFadeLeftEnd, "Distance (in pixels) from the left edge where letters finish fading in." "\nAny text to the right of this value will be fully opaque, until fadeRightStart" - "\nis reached." - ) + "\nis reached." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeRightStart", - GetFadeRightStart, SetFadeRightStart, - "Distance (in pixels) from the left edge where letters begin to fade out." - ) + GetFadeRightStart, + SetFadeRightStart, + "Distance (in pixels) from the left edge where letters begin to fade out." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeRightEnd", - GetFadeRightEnd, SetFadeRightEnd, + GetFadeRightEnd, + SetFadeRightEnd, "Distance (in pixels) from the left edge where letters finish fading out." - "\nAny text to the right of this value will be invisible." - ) + "\nAny text to the right of this value will be invisible." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeTopStart", - GetFadeTopStart, SetFadeTopStart, + GetFadeTopStart, + SetFadeTopStart, "Distance (in pixels) from the top edge where letters begin to fade in." - "\nAny text above this value will be invisible." - ) + "\nAny text above this value will be invisible." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeTopEnd", - GetFadeTopEnd, SetFadeTopEnd, + GetFadeTopEnd, + SetFadeTopEnd, "Distance (in pixels) from the top edge where letters finish fading in." "\nAny text below this value will be fully opaque, until fadeBottomStart" - "\nis reached." - ) + "\nis reached." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeBottomStart", - GetFadeBottomStart, SetFadeBottomStart, - "Distance (in pixels) from the top edge where letters begin to fade out." - ) + GetFadeBottomStart, + SetFadeBottomStart, + "Distance (in pixels) from the top edge where letters begin to fade out." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fadeBottomEnd", - GetFadeBottomEnd, SetFadeBottomEnd, + GetFadeBottomEnd, + SetFadeBottomEnd, "Distance (in pixels) from the top edge where letters finish fading out." - "\nAny text below this value will be invisible." - ) + "\nAny text below this value will be invisible." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "AddText", AddText, "n = AddText(text)" @@ -191,11 +158,9 @@ const Be::ClassInfo* Tr2FontMeasurer::ExposeToBlue() "\n:param text: unicode string to be added" "\n\n:returns:" "\n the number of characters added. May be less the length of the given" - "\n text if a limit is set on the measurer." - ) + "\n text if a limit is set on the measurer." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CommitText", CommitText, "CommitText(shiftX, shiftY)" @@ -203,71 +168,55 @@ const Be::ClassInfo* Tr2FontMeasurer::ExposeToBlue() "\ngiven x,y coordinates." "\nText can also be canceled with CancelLastText." "\n:param shiftX: amount in pixels that text to commit is shifted by horizontally" - "\n:param shiftY: amount in pixels that text to commit is shifted by vertically" - ) + "\n:param shiftY: amount in pixels that text to commit is shifted by vertically" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CancelLastText", CancelLastText, "CancelLastText()" "\nCancels the last added text. Can be called repeatedly to undo" - "\nmultiple AddText calls. Text that has been committed cannot be canceled." - ) + "\nmultiple AddText calls. Text that has been committed cannot be canceled." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasCommittedText", HasCommittedText, "HasCommittedText()" - "\nReturns true if text has been added and committed." - ) + "\nReturns true if text has been added and committed." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasUncommittedText", HasUncommittedText, "HasUncommittedText()" - "\nReturns true if text has been added and not yet committed." - ) + "\nReturns true if text has been added and not yet committed." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Reset", Reset, "Reset()" - "\nClears any text added and resets the cursor." - ) + "\nClears any text added and resets the cursor." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "DrawToAtlasTexture", DrawToAtlasTexture, "DrawToAtlasTexture(atlasTexture)" "\nDraws all committed text to the atlas texture." - "\n:param atlasTexture: a Tr2AtlasTexture object" - ) + "\n:param atlasTexture: a Tr2AtlasTexture object" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "DrawToTexture", DrawToTexture, "DrawToTexture(texture)" "\nDraws all committed text to the texture." - "\n:param texture: a TriTextureRes object" - ) + "\n:param texture: a TriTextureRes object" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "DrawToHostBitmap", DrawToHostBitmap, "DrawToHostBitmap(hostBitmap)" "\nDraws all committed text to the hostBitmap." - "\n:param hostBitmap: a Tr2HostBitmap object" - ) + "\n:param hostBitmap: a Tr2HostBitmap object" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetIndexAtPos", GetIndexAtPos, "ix = GetIndexAtPos(x)" @@ -275,17 +224,14 @@ const Be::ClassInfo* Tr2FontMeasurer::ExposeToBlue() "\nfor single line text." "\n:param x: position being queried" "\n\n:returns:" - "\n index into the string that corresponds to the x position." - ) + "\n index into the string that corresponds to the x position." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetWidthAtIndex", GetWidthAtIndex, "x = GetWidthAtIndex(ix)" "\nReturns the width of the string at the given index." "\n:param ix: index into the string" - "\n\n:returns: the width of the string at the given index." - ) + "\n\n:returns: the width of the string at the given index." ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Font/Tr2SBit.cpp b/trinity/Font/Tr2SBit.cpp index 2762dcc78..5dc8fef25 100644 --- a/trinity/Font/Tr2SBit.cpp +++ b/trinity/Font/Tr2SBit.cpp @@ -41,16 +41,16 @@ void Tr2SBitWrapper::ToBuffer( PyObject* dest, int width, int height, int pitch, { void* data = nullptr; #if PY_MAJOR_VERSION == 2 - if ( !GetBuf( &data, dest ) ) + if( !GetBuf( &data, dest ) ) { return; } #else - Py_buffer buf; - if(PyObject_GetBuffer(dest, &buf, PyBUF_SIMPLE) == -1) - { - return; - } + Py_buffer buf; + if( PyObject_GetBuffer( dest, &buf, PyBUF_SIMPLE ) == -1 ) + { + return; + } ON_BLOCK_EXIT( [&] { PyBuffer_Release( &buf ); } ); data = buf.buf; #endif @@ -67,10 +67,10 @@ void Tr2SBitWrapper::ToBufferWithUnderline( PyObject* dest, int width, int heigh } #else Py_buffer buf; - if(PyObject_GetBuffer(dest, &buf, PyBUF_SIMPLE) == -1) - { - return; - } + if( PyObject_GetBuffer( dest, &buf, PyBUF_SIMPLE ) == -1 ) + { + return; + } ON_BLOCK_EXIT( [&] { PyBuffer_Release( &buf ); } ); data = buf.buf; #endif @@ -85,10 +85,8 @@ void Tr2SBitWrapper::ToBufferWithUnderline( PyObject* dest, int width, int heigh } SBit_To_RGBABuffer( - data, width, height, pitch, - sbit, x, y, color ); - Underline_To_RGBABuffer( - data, width, height, pitch, - x, y + underlinePosition, sbit->xadvance + extraSpace, underlineThickness, color ); + data, width, height, pitch, sbit, x, y, color ); + Underline_To_RGBABuffer( + data, width, height, pitch, x, y + underlinePosition, sbit->xadvance + extraSpace, underlineThickness, color ); } #endif diff --git a/trinity/Font/Tr2SBit.h b/trinity/Font/Tr2SBit.h index 71a57d6d7..6a591e3ba 100644 --- a/trinity/Font/Tr2SBit.h +++ b/trinity/Font/Tr2SBit.h @@ -16,8 +16,7 @@ void Underline_To_RGBABuffer( void* destPtr, int dWidth, int dHeight, int dPitch BLUE_DECLARE( Tr2SBitWrapper ); -class Tr2SBitWrapper : - public IRoot +class Tr2SBitWrapper : public IRoot { public: EXPOSE_TO_BLUE(); @@ -25,20 +24,49 @@ class Tr2SBitWrapper : Tr2SBitWrapper( IRoot* lockobj = NULL ); ~Tr2SBitWrapper(); - int GetWidth() { return sbit->width; } - int GetHeight() { return sbit->height; } - int GetXOffset() { return sbit->left; } - int GetYOffset() { return sbit->top; } - int GetXAdvance() { return sbit->xadvance; } - int GetYAdvance() { return sbit->yadvance; } + int GetWidth() + { + return sbit->width; + } + int GetHeight() + { + return sbit->height; + } + int GetXOffset() + { + return sbit->left; + } + int GetYOffset() + { + return sbit->top; + } + int GetXAdvance() + { + return sbit->xadvance; + } + int GetYAdvance() + { + return sbit->yadvance; + } #if BLUE_WITH_PYTHON - void ToBuffer( - PyObject* dest, int width, int height, int pitch, - int x, int y, int32_t color ); - void ToBufferWithUnderline( - PyObject* dest, int width, int height, int pitch, - int x, int y, int32_t color, int extraSpace ); + void ToBuffer( + PyObject* dest, + int width, + int height, + int pitch, + int x, + int y, + int32_t color ); + void ToBufferWithUnderline( + PyObject* dest, + int width, + int height, + int pitch, + int x, + int y, + int32_t color, + int extraSpace ); #endif diff --git a/trinity/Font/Tr2Sbit_Blue.cpp b/trinity/Font/Tr2Sbit_Blue.cpp index 3ecbaa145..583255351 100644 --- a/trinity/Font/Tr2Sbit_Blue.cpp +++ b/trinity/Font/Tr2Sbit_Blue.cpp @@ -5,105 +5,84 @@ BLUE_DEFINE( Tr2SBitWrapper ); -const Be::ClassInfo* Tr2SBitWrapper::ExposeToBlue() -{ +const Be::ClassInfo* Tr2SBitWrapper::ExposeToBlue() { EXPOSURE_BEGIN( Tr2SBitWrapper, "" ) MAP_INTERFACE( Tr2SBitWrapper ) - MAP_ATTRIBUTE - ( - "x", - x, - "x position of this glyph", - Be::READ - ) - - MAP_ATTRIBUTE - ( - "y", - y, - "y position of this glyph", - Be::READ - ) - - MAP_PROPERTY_READONLY - ( - "xOffset", - GetXOffset, - "x offset of bitmap for this glyph" - ) - - MAP_PROPERTY_READONLY - ( - "yOffset", - GetYOffset, - "y offset of bitmap for this glyph" - ) - - MAP_PROPERTY_READONLY - ( - "width", - GetWidth, - "Width of the bitmap for this glyph" - ) - - MAP_PROPERTY_READONLY - ( - "height", - GetHeight, - "Height of the bitmap for this glyph" - ) - - MAP_PROPERTY_READONLY - ( - "xadvance", - GetXAdvance, - "xadvance indicates how much to advance the cursor in the x direction" - "\nwhen rendering this glyph horizontally." - ) - - MAP_PROPERTY_READONLY - ( - "yadvance", - GetYAdvance, - "yadvance indicates how much to advance the cursor in the y direction" - "\nwhen rendering this glyph vertically." - ) + MAP_ATTRIBUTE( + "x", + x, + "x position of this glyph", + Be::READ ) + + MAP_ATTRIBUTE( + "y", + y, + "y position of this glyph", + Be::READ ) + + MAP_PROPERTY_READONLY( + "xOffset", + GetXOffset, + "x offset of bitmap for this glyph" ) + + MAP_PROPERTY_READONLY( + "yOffset", + GetYOffset, + "y offset of bitmap for this glyph" ) + + MAP_PROPERTY_READONLY( + "width", + GetWidth, + "Width of the bitmap for this glyph" ) + + MAP_PROPERTY_READONLY( + "height", + GetHeight, + "Height of the bitmap for this glyph" ) + + MAP_PROPERTY_READONLY( + "xadvance", + GetXAdvance, + "xadvance indicates how much to advance the cursor in the x direction" + "\nwhen rendering this glyph horizontally." ) + + MAP_PROPERTY_READONLY( + "yadvance", + GetYAdvance, + "yadvance indicates how much to advance the cursor in the y direction" + "\nwhen rendering this glyph vertically." ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP - ( - "ToBuffer", - ToBuffer, - "ToBuffer(dest, width, height, pitch, x, y, color)" - "\nCopies the glyph bitmap to the destination buffer." - "\n:param dest: the destination buffer" - "\n:param width: width of the destination buffer" - "\n:param height: height of the destination buffer" - "\n:param pitch: pitch of the destination buffer" - "\n:param x: where to draw the bitmap within the destination buffer" - "\n:param y: where to draw the bitmap within the destination buffer" - "\n:param color: color to apply to the bitmap" - ) - - MAP_METHOD_AND_WRAP - ( - "ToBufferWithUnderline", - ToBufferWithUnderline, - "ToBufferWithUnderline(dest, width, height, pitch, x, y, color)" - "\nCopies the glyph bitmap to the destination buffer, with an added underline." - "\n:param dest: the destination buffer" - "\n:param width: width of the destination buffer" - "\n:param height: height of the destination buffer" - "\n:param pitch: pitch of the destination buffer" - "\n:param x: where to draw the bitmap within the destination buffer" - "\n:param y: where to draw the bitmap within the destination buffer" - "\n:param color: color to apply to the bitmap" - "\n:param letterspace: extra space after this letter" - ) + MAP_METHOD_AND_WRAP( + "ToBuffer", + ToBuffer, + "ToBuffer(dest, width, height, pitch, x, y, color)" + "\nCopies the glyph bitmap to the destination buffer." + "\n:param dest: the destination buffer" + "\n:param width: width of the destination buffer" + "\n:param height: height of the destination buffer" + "\n:param pitch: pitch of the destination buffer" + "\n:param x: where to draw the bitmap within the destination buffer" + "\n:param y: where to draw the bitmap within the destination buffer" + "\n:param color: color to apply to the bitmap" ) + + MAP_METHOD_AND_WRAP( + "ToBufferWithUnderline", + ToBufferWithUnderline, + "ToBufferWithUnderline(dest, width, height, pitch, x, y, color)" + "\nCopies the glyph bitmap to the destination buffer, with an added underline." + "\n:param dest: the destination buffer" + "\n:param width: width of the destination buffer" + "\n:param height: height of the destination buffer" + "\n:param pitch: pitch of the destination buffer" + "\n:param x: where to draw the bitmap within the destination buffer" + "\n:param y: where to draw the bitmap within the destination buffer" + "\n:param color: color to apply to the bitmap" + "\n:param letterspace: extra space after this letter" ) #endif - EXPOSURE_END() + EXPOSURE_END() }; \ No newline at end of file diff --git a/trinity/GrannyBoneOffset.cpp b/trinity/GrannyBoneOffset.cpp index aae293dbd..f7ea9e73f 100644 --- a/trinity/GrannyBoneOffset.cpp +++ b/trinity/GrannyBoneOffset.cpp @@ -5,9 +5,8 @@ #include "GrannyBoneOffset.h" -GrannyBoneOffset::GrannyBoneOffset( IRoot* /*lockobj*/ ) -: m_transforms( "GrannyBoneOffset/m_transforms" ) -, m_riggedTransforms( "GrannyBoneOffset/m_riggedTransforms" ) +GrannyBoneOffset::GrannyBoneOffset( IRoot* /*lockobj*/ ) : + m_transforms( "GrannyBoneOffset/m_transforms" ), m_riggedTransforms( "GrannyBoneOffset/m_riggedTransforms" ) { } @@ -29,7 +28,7 @@ bool GrannyBoneOffset::HaveTransforms() const // check if the number of bones has changed since the last rebind. // Arguments: // numBones - number of bones in the current animation rig. -bool GrannyBoneOffset::NeedRebind ( unsigned numBones ) const +bool GrannyBoneOffset::NeedRebind( unsigned numBones ) const { // yes if we have transforms and the skeleton rig doesn't match up return m_riggedTransforms.size() != numBones && HaveTransforms(); @@ -55,25 +54,25 @@ void GrannyBoneOffset::ClearTransforms() // parentMatrix - collapsed parent transform of the joint, 16 floats // Return Value: // true if there was an offset/rotation, and targetMatrix has been filled in properly. -// false otherwise and then it's up to the caller to make sure targetMatrix is set up. +// false otherwise and then it's up to the caller to make sure targetMatrix is set up. bool GrannyBoneOffset::Apply( float* targetMatrix, unsigned joint, const float* boneMatrix, const float* parentMatrix ) { - if( const float* const t = m_riggedTransforms[ joint ] ) + if( const float* const t = m_riggedTransforms[joint] ) { // apply the rotation in bone space, so eg. the head tilts instead of swerving around the origin in bind pose space // so, pre-multiply, before the animation transform float m[16]; - for( unsigned j = 0; j != 3; ++j ) // 3 rows only + for( unsigned j = 0; j != 3; ++j ) // 3 rows only { for( unsigned i = 0; i != 4; ++i ) { float f = 0; for( unsigned k = 0; k != 4; ++k ) { - f += t[j*4+k] * boneMatrix[k*4+i]; + f += t[j * 4 + k] * boneMatrix[k * 4 + i]; } - m[j*4+i] = f; + m[j * 4 + i] = f; } } @@ -89,14 +88,14 @@ bool GrannyBoneOffset::Apply( float* targetMatrix, unsigned joint, const float* float f = 0; for( unsigned k = 0; k != 4; ++k ) { - f += m[j*4+k] * parentMatrix[k*4+i]; + f += m[j * 4 + k] * parentMatrix[k * 4 + i]; } - targetMatrix[j*4+i] = f; + targetMatrix[j * 4 + i] = f; } } return true; } - + return false; } @@ -105,7 +104,7 @@ bool GrannyBoneOffset::Apply( float* targetMatrix, unsigned joint, const float* // Arguments: // bones - pointer to exactly numBones strings // numBones - number of bones in this rig -void GrannyBoneOffset::BindToRig( const std::string * bones, size_t numBones ) +void GrannyBoneOffset::BindToRig( const std::string* bones, size_t numBones ) { if( !bones || !numBones ) { @@ -130,15 +129,15 @@ void GrannyBoneOffset::BindToRig( const std::string * bones, size_t numBones ) // r, i, j, k - Rotation quaternion; applied before the animation's transform. // SeeAlso: // SetOffset -void GrannyBoneOffset::SetRotation( const std::string &bone, float r, float i, float j, float k ) +void GrannyBoneOffset::SetRotation( const std::string& bone, float r, float i, float j, float k ) { if( bone.empty() ) { return; } - float *m = m_transforms[ bone ].m; - + float* m = m_transforms[bone].m; + Matrix mq; Quaternion q; q.x = r; @@ -148,7 +147,7 @@ void GrannyBoneOffset::SetRotation( const std::string &bone, float r, float i, f mq = RotationMatrix( q ); memcpy( m, &mq.m[0][0], 64 ); - + ClearRigBindings(); } @@ -159,7 +158,7 @@ void GrannyBoneOffset::SetRotation( const std::string &bone, float r, float i, f // x, y, z - Displacement; applied in the local coordinate frame of the parent bone, after the animation's transform. // SeeAlso: // SetRotation -void GrannyBoneOffset::SetOffset( const std::string & bone, float x, float y, float z ) +void GrannyBoneOffset::SetOffset( const std::string& bone, float x, float y, float z ) { if( bone.empty() ) { @@ -169,13 +168,13 @@ void GrannyBoneOffset::SetOffset( const std::string & bone, float x, float y, fl TransformsMap::iterator it = m_transforms.find( bone ); if( it == m_transforms.end() ) { - float *m = m_transforms[ bone ].m; - memset( m, 0, 16*4 ); + float* m = m_transforms[bone].m; + memset( m, 0, 16 * 4 ); m[0] = m[5] = m[10] = m[15] = 1.0f; it = m_transforms.find( bone ); } - float *m = m_transforms[bone].m; + float* m = m_transforms[bone].m; m[12] = x; m[13] = y; m[14] = z; diff --git a/trinity/GrannyBoneOffset.h b/trinity/GrannyBoneOffset.h index 39c7c1602..1a2fe5010 100644 --- a/trinity/GrannyBoneOffset.h +++ b/trinity/GrannyBoneOffset.h @@ -12,45 +12,46 @@ // Branched off from MorphemeBoneOffset, not much code worth sharing once the individual matrix transforms have // been changed to work with the native types of the SDKs (NMP::Matrix34 vs granny_local_transform). // See Also: MorphemeBoneOffset -BLUE_CLASS( GrannyBoneOffset ) : public IInitialize +BLUE_CLASS( GrannyBoneOffset ) : + public IInitialize { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using IInitialize::Lock; - using IInitialize::Unlock; + using IInitialize::Unlock; ///////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - GrannyBoneOffset( IRoot* lockobj = 0 ); + GrannyBoneOffset( IRoot* lockobj = 0 ); virtual ~GrannyBoneOffset(); - // Set or replace the additional translation for this bone. - void SetOffset ( const std::string & bone, float x, float y, float z ); + // Set or replace the additional translation for this bone. + void SetOffset( const std::string& bone, float x, float y, float z ); // Set or replace the additional rotation for this bone. - void SetRotation( const std::string & bone, float r, float i, float j, float k ); + void SetRotation( const std::string& bone, float r, float i, float j, float k ); - // Map bone strings to joint indices using this skeleton - void BindToRig( const std::string * bones, size_t numBones ); - - // Apply stored offset and/or rotation to specific bone whose rig index is joint. - bool Apply ( float* targetMatrix4x4, unsigned joint, const float* boneMatrix4x4, const float* parentMatrix4x4 ); + // Map bone strings to joint indices using this skeleton + void BindToRig( const std::string* bones, size_t numBones ); + + // Apply stored offset and/or rotation to specific bone whose rig index is joint. + bool Apply( float* targetMatrix4x4, unsigned joint, const float* boneMatrix4x4, const float* parentMatrix4x4 ); // Return Value: // true if there are any transforms at all - bool HaveTransforms() const; - + bool HaveTransforms() const; + // check if the number of bones has changed since the last rebind. - bool NeedRebind( unsigned numBones ) const; + bool NeedRebind( unsigned numBones ) const; // Undo the link between the offsets and the skeleton; use when the skeleton has changed - void ClearRigBindings(); + void ClearRigBindings(); // Clear the offsets alltogether, ie forget all settings - void ClearTransforms(); + void ClearTransforms(); bool ApplyToLocal( unsigned joint, Quaternion& rotation, Vector3& position ) const; @@ -59,16 +60,15 @@ BLUE_CLASS( GrannyBoneOffset ) : public IInitialize { float m[16]; }; - typedef TrackableStdMap TransformsMap; - + typedef TrackableStdMap TransformsMap; + // bone name -> full transform - TransformsMap m_transforms; + TransformsMap m_transforms; // For every bone in the rig, an optional pointer into m_transforms specifying the transform to apply on this bone. Exactly numbones of these, in order. - TrackableStdVector m_riggedTransforms; + TrackableStdVector m_riggedTransforms; }; TYPEDEF_BLUECLASS( GrannyBoneOffset ); #endif // GrannyBoneOffset_h_ - diff --git a/trinity/GrannyBoneOffset_Blue.cpp b/trinity/GrannyBoneOffset_Blue.cpp index c3d28746a..380e378c3 100644 --- a/trinity/GrannyBoneOffset_Blue.cpp +++ b/trinity/GrannyBoneOffset_Blue.cpp @@ -9,38 +9,35 @@ BLUE_DEFINE( GrannyBoneOffset ); const Be::ClassInfo* GrannyBoneOffset::ExposeToBlue() { - EXPOSURE_BEGIN( GrannyBoneOffset, "" ) + EXPOSURE_BEGIN( GrannyBoneOffset, "" ) MAP_INTERFACE( GrannyBoneOffset ) MAP_INTERFACE( IInitialize ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "SetOffset", SetOffset, - "Set an offset for the bone with the given name\n" + "Set an offset for the bone with the given name\n" ":param boneName: Name of the bone; not existing in the current skeleton is OK\n" ":param x: x offset in bindpose/worldspace coordinates (ie. post-animation)\n" ":param y: y offset in bindpose/worldspace coordinates (ie. post-animation)\n" - ":param z: z offset in bindpose/worldspace coordinates (ie. post-animation)\n" - ) + ":param z: z offset in bindpose/worldspace coordinates (ie. post-animation)\n" ) - MAP_METHOD_AND_WRAP( - "SetRotation", + MAP_METHOD_AND_WRAP( + "SetRotation", SetRotation, - "Set a quaternion rotation offset for the bone with the given name\n" + "Set a quaternion rotation offset for the bone with the given name\n" ":param boneName: Name of the bone; not existing in the current skeleton is OK\n" ":param r: 1-st component of the rotation quaternion\n" ":param i: 2-nd component of the rotation quaternion\n" ":param j: 3-rd component of the rotation quaternion\n" - ":param k: 4-th component of the rotation quaternion\n" - ) + ":param k: 4-th component of the rotation quaternion\n" ) - MAP_METHOD_AND_WRAP( - "ClearTransforms", + MAP_METHOD_AND_WRAP( + "ClearTransforms", ClearTransforms, - "Clear out all offsets and rotations" - "\n" - ) - EXPOSURE_END() + "Clear out all offsets and rotations" + "\n" ) + EXPOSURE_END() } #endif /* GAMEWORLD_64 */ diff --git a/trinity/ITr2AttributeGenerator.h b/trinity/ITr2AttributeGenerator.h index 155fdc46a..8bd38cbbc 100644 --- a/trinity/ITr2AttributeGenerator.h +++ b/trinity/ITr2AttributeGenerator.h @@ -8,12 +8,13 @@ // -------------------------------------------------------------------------------------- // Description: -// ITr2AttributeGenerator is an interface for particle system attribute generators. +// ITr2AttributeGenerator is an interface for particle system attribute generators. // Used by particle emitters to generate each new particle component. // See Also: // Tr2DynamicEmitter, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2AttributeGenerator ): public IRoot +BLUE_INTERFACE( ITr2AttributeGenerator ) : + public IRoot { // -------------------------------------------------------------------------------------- // Description: @@ -25,7 +26,7 @@ BLUE_INTERFACE( ITr2AttributeGenerator ): public IRoot // velocity - Velocity of the "parent" particle (if the emitter owning this generator // is "emit during life" or "emit on death" emitter and parent particle has // velocity element); otherwise is nullptr. - // paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. + // paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator is responsible for filling only portions of this data where // particle elements it is assigned to reside. // -------------------------------------------------------------------------------------- @@ -33,20 +34,20 @@ BLUE_INTERFACE( ITr2AttributeGenerator ): public IRoot // -------------------------------------------------------------------------------------- // Description: - // "Binds" generator to a particle system. This is a chance for generator to find + // "Binds" generator to a particle system. This is a chance for generator to find // buffer types, offsets, etc. of particle elements it is supposed to generate. // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will - // be filling by adding their declaration names to this set. Emitter uses this set + // be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator - // is responsible for checking if its elements are overwritten by some other + // is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- - virtual bool Bind( const Tr2ParticleElementDataMap& declaration, + virtual bool Bind( const Tr2ParticleElementDataMap& declaration, std::set& boundElements ) = 0; }; diff --git a/trinity/ITr2CurveSetOwner.h b/trinity/ITr2CurveSetOwner.h index 514a0e309..8fa8ccd5b 100644 --- a/trinity/ITr2CurveSetOwner.h +++ b/trinity/ITr2CurveSetOwner.h @@ -6,7 +6,8 @@ BLUE_DECLARE( TriCurveSet ); -BLUE_INTERFACE( ITr2CurveSetOwner ): public IRoot +BLUE_INTERFACE( ITr2CurveSetOwner ) : + public IRoot { virtual void PlayCurveSet( const std::string& name, const std::string& rangeName ) = 0; virtual void StopCurveSet( const std::string& name ) = 0; diff --git a/trinity/ITr2DynamicBindingOwner.h b/trinity/ITr2DynamicBindingOwner.h index 238ed26db..aca9333fe 100644 --- a/trinity/ITr2DynamicBindingOwner.h +++ b/trinity/ITr2DynamicBindingOwner.h @@ -2,7 +2,8 @@ #pragma once -BLUE_INTERFACE( ITr2DynamicBindingOwner ) : public IRoot +BLUE_INTERFACE( ITr2DynamicBindingOwner ) : + public IRoot { virtual std::unordered_map GetParameterMap() const = 0; }; diff --git a/trinity/ITr2EffectValue.h b/trinity/ITr2EffectValue.h index ee67bdaa1..929f12c73 100644 --- a/trinity/ITr2EffectValue.h +++ b/trinity/ITr2EffectValue.h @@ -4,7 +4,8 @@ #ifndef ITR2EFFECTVALUE_H #define ITR2EFFECTVALUE_H -BLUE_INTERFACE( ITr2EffectValue ) : public IRoot +BLUE_INTERFACE( ITr2EffectValue ) : + public IRoot { // ---------------------------------------------------------------------------------- // Description: @@ -12,9 +13,9 @@ BLUE_INTERFACE( ITr2EffectValue ) : public IRoot // ---------------------------------------------------------------------------------- enum ResourceFlags { - RESOURCE_FLAG_NONE = 0, + RESOURCE_FLAG_NONE = 0, // Resource needs to be applied as sRGB texture - RESOURCE_FLAG_SRGB = 1, + RESOURCE_FLAG_SRGB = 1, }; // Copy the value to the effect using 'destHandle'. For basic types 'destHandle' @@ -24,16 +25,16 @@ BLUE_INTERFACE( ITr2EffectValue ) : public IRoot // might use only a 2x2 portion of it. The fxc compiler is clever enough to only // give 2 constants to the variable in that case. // The size is in bytes. - virtual void CopyValueToEffect( + virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const + Tr2RenderContext& renderContext ) const { } virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const @@ -42,17 +43,16 @@ BLUE_INTERFACE( ITr2EffectValue ) : public IRoot } virtual bool ApplyUav( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const { return false; } - virtual void AddUsedTexture( Tr2BindlessResourcesAL& usedTextures ) const + virtual void AddUsedTexture( Tr2BindlessResourcesAL & usedTextures ) const { } - }; TYPEDEF_BLUECLASS( ITr2EffectValue ); diff --git a/trinity/ITr2GeometryProvider.h b/trinity/ITr2GeometryProvider.h index 4e198e608..e6418abd1 100644 --- a/trinity/ITr2GeometryProvider.h +++ b/trinity/ITr2GeometryProvider.h @@ -6,9 +6,10 @@ class Tr2RenderContext; -BLUE_INTERFACE( ITr2GeometryProvider ) : public IRoot +BLUE_INTERFACE( ITr2GeometryProvider ) : + public IRoot { - virtual void SubmitGeometry( Tr2RenderContext& renderContext ) = 0; + virtual void SubmitGeometry( Tr2RenderContext & renderContext ) = 0; }; diff --git a/trinity/ITr2MeshMorph.h b/trinity/ITr2MeshMorph.h index f912a975b..26ee4b11b 100644 --- a/trinity/ITr2MeshMorph.h +++ b/trinity/ITr2MeshMorph.h @@ -8,7 +8,7 @@ BLUE_INTERFACE( ITr2MeshMorph ) : public IRoot { - virtual bool UpdateMeshMorphs( Tr2RenderContext& renderContext ) = 0; + virtual bool UpdateMeshMorphs( Tr2RenderContext & renderContext ) = 0; }; REGISTER_COMPONENT_TYPE( "MeshMorph", ITr2MeshMorph ); diff --git a/trinity/ITr2PickableScene.cpp b/trinity/ITr2PickableScene.cpp index 4067cf433..a1c1691c3 100644 --- a/trinity/ITr2PickableScene.cpp +++ b/trinity/ITr2PickableScene.cpp @@ -20,16 +20,16 @@ // -------------------------------------------------------------------------------------- // Description: -// Picks an object and its properties in the given pixel. +// Picks an object and its properties in the given pixel. // Arguments: // renderContext - Current render context // x - X viewport coordinate of the pixel to perform picking in // y - Y viewport coordinate of the pixel to perform picking in -// proj - Current projection transform -// view - Current view transform +// proj - Current projection transform +// view - Current view transform // viewport - Current viewport // results - (in/out) Results of the picking operation. The results.componets field -// as an input determines what properties of the object needs to be picked. On the +// as an input determines what properties of the object needs to be picked. On the // output the results.componets is modified to contain only properties that were // successfully picked (for scenes that might not have support for picking some // of the properties). @@ -73,9 +73,9 @@ void ITr2PickableScene::PickObject( Tr2RenderContext& renderContext, int x, int const std::vector& visibleObjects = GetPickingObjectsToRender( dirWorld ); // Collect vector of objects to render - std::vector pickableObjects; + std::vector pickableObjects; for( std::vector::const_iterator it = visibleObjects.begin(); it != visibleObjects.end(); ++it ) - { + { ITr2PickablePtr pickedObj( BlueCastPtr( *it ) ); if( pickedObj ) { @@ -166,12 +166,12 @@ void ITr2PickableScene::PickObject( Tr2RenderContext& renderContext, int x, int // -------------------------------------------------------------------------------------- // Description: -// Sets view and projection transform to be used for picking. +// Sets view and projection transform to be used for picking. // Arguments: // fx - X offset of the frustum in post-projected space // fy - Y offset of the frustum in post-projected space -// proj - Current projection transform -// view - Current view transform +// proj - Current projection transform +// view - Current view transform // viewport - Current viewport // -------------------------------------------------------------------------------------- void ITr2PickableScene::SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport ) @@ -184,8 +184,8 @@ void ITr2PickableScene::SetupTransformsForPicking( float fx, float fy, TriProjec // translate the projection so that we center around the pick ray origin, // while remembering to scale this value as well: Vector2 translation; - translation.x = -fx*scaling.x; - translation.y = -fy*scaling.y; + translation.x = -fx * scaling.x; + translation.y = -fy * scaling.y; Tr2Renderer::AdjustProjection( scaling, translation ); // We do NOT set the viewport here. It will get set automatically when SetRenderTarget is called. @@ -193,23 +193,23 @@ void ITr2PickableScene::SetupTransformsForPicking( float fx, float fy, TriProjec // -------------------------------------------------------------------------------------- // Description: -// Collects opaque and picking batches from given objects. +// Collects opaque and picking batches from given objects. // Arguments: // pickableObjects - Vector of potentially visible objects for picking // pOpaquePickingBatches - (out) Opaque batch accumulator // pPickingBatches - (out) Picking batch accumulator // -------------------------------------------------------------------------------------- void ITr2PickableScene::GetBatches( std::vector const& pickableObjects, - ITriRenderBatchAccumulator*& pOpaquePickingBatches, - ITriRenderBatchAccumulator*& pPickingBatches ) + ITriRenderBatchAccumulator*& pOpaquePickingBatches, + ITriRenderBatchAccumulator*& pPickingBatches ) { - TriPoolAllocator* allocator = Tr2Renderer::GetPoolAllocator(); - CCP_ASSERT( allocator ); + TriPoolAllocator* allocator = Tr2Renderer::GetPoolAllocator(); + CCP_ASSERT( allocator ); - // Get the picking batches from opaque areas to be overridden in the PS - pOpaquePickingBatches = GetOpaquePickingBatchAccumulator(); - // Get the dedicated picking areas - pPickingBatches = GetPickingBatchAccumulator(); + // Get the picking batches from opaque areas to be overridden in the PS + pOpaquePickingBatches = GetOpaquePickingBatchAccumulator(); + // Get the dedicated picking areas + pPickingBatches = GetPickingBatchAccumulator(); CCP_ASSERT( pOpaquePickingBatches && pOpaquePickingBatches->GetBatchCount() == 0 ); if( !pOpaquePickingBatches ) @@ -222,45 +222,45 @@ void ITr2PickableScene::GetBatches( std::vector const& pickable CCP_ASSERT( pPickingBatches->GetBatchCount() == 0 ); } - for( unsigned int i = 0; i < pickableObjects.size(); ++i ) - { - // We cannot rely on the object data to be up-to-date because this would assume that all - // objects in the picked list were rendered on the previous frame and that is tooooo much of an assumption. - // - Tr2PerObjectData* perObjectData = pickableObjects[i]->GetPerObjectData( pOpaquePickingBatches ); - if( perObjectData ) - { - perObjectData->SetUserData( i ); - - size_t curBatchCount = pOpaquePickingBatches->GetBatchCount(); - pickableObjects[i]->GetBatches( pOpaquePickingBatches, TRIBATCHTYPE_OPAQUE, perObjectData ); - size_t newBatchCount = pOpaquePickingBatches->GetBatchCount(); - - // Fall back to opaque prepass batches if there were no opaque batches - if( curBatchCount == newBatchCount ) - { - pickableObjects[i]->GetBatches( pOpaquePickingBatches, TRIBATCHTYPE_OPAQUE_PREPASS, perObjectData ); - } - - // Dedicated picking areas do not support UV picking (and it doesn't really make sense) - if( pPickingBatches ) - { - pickableObjects[i]->GetBatches( pPickingBatches, TRIBATCHTYPE_PICKING, perObjectData ); - } - } - } - - pOpaquePickingBatches->Finalize(); - - if( pPickingBatches ) - { - pPickingBatches->Finalize(); + for( unsigned int i = 0; i < pickableObjects.size(); ++i ) + { + // We cannot rely on the object data to be up-to-date because this would assume that all + // objects in the picked list were rendered on the previous frame and that is tooooo much of an assumption. + // + Tr2PerObjectData* perObjectData = pickableObjects[i]->GetPerObjectData( pOpaquePickingBatches ); + if( perObjectData ) + { + perObjectData->SetUserData( i ); + + size_t curBatchCount = pOpaquePickingBatches->GetBatchCount(); + pickableObjects[i]->GetBatches( pOpaquePickingBatches, TRIBATCHTYPE_OPAQUE, perObjectData ); + size_t newBatchCount = pOpaquePickingBatches->GetBatchCount(); + + // Fall back to opaque prepass batches if there were no opaque batches + if( curBatchCount == newBatchCount ) + { + pickableObjects[i]->GetBatches( pOpaquePickingBatches, TRIBATCHTYPE_OPAQUE_PREPASS, perObjectData ); + } + + // Dedicated picking areas do not support UV picking (and it doesn't really make sense) + if( pPickingBatches ) + { + pickableObjects[i]->GetBatches( pPickingBatches, TRIBATCHTYPE_PICKING, perObjectData ); + } + } + } + + pOpaquePickingBatches->Finalize(); + + if( pPickingBatches ) + { + pPickingBatches->Finalize(); } } // -------------------------------------------------------------------------------------- // Description: -// Renders picking batches into the picking buffer. +// Renders picking batches into the picking buffer. // Arguments: // pOpaquePickingBatches - Opaque batch accumulator // pPickingBatches - Picking batch accumulator @@ -270,86 +270,75 @@ void ITr2PickableScene::GetBatches( std::vector const& pickable // false On error // -------------------------------------------------------------------------------------- bool ITr2PickableScene::RenderPicking( ITriRenderBatchAccumulator* pOpaquePickingBatches, - ITriRenderBatchAccumulator* pPickingBatches, - PickComponents pass ) + ITriRenderBatchAccumulator* pPickingBatches, + PickComponents pass ) { - USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO + USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO // Use a shader variable for identifying which components are expected. // We can't use situations here because the flags might change during a single // frame. - Vector4 componentsParam = Vector4( - ( pass & PICK_OBJECT ) ? 1.0f : 0.0f, - ( pass & PICK_AREA ) ? 1.0f : 0.0f, - ( pass & PICK_POSITION ) ? 1.0f : 0.0f, + Vector4 componentsParam = Vector4( + ( pass & PICK_OBJECT ) ? 1.0f : 0.0f, + ( pass & PICK_AREA ) ? 1.0f : 0.0f, + ( pass & PICK_POSITION ) ? 1.0f : 0.0f, ( pass & PICK_UV ) ? 1.0f : 0.0f ); GlobalStore().RegisterVariable( "PickingComponents", componentsParam ); - float initialDepth = ( HUGE_NUMBER - Tr2Renderer::GetFrontClip() ) / ( Tr2Renderer::GetBackClip() - Tr2Renderer::GetFrontClip() ); - initialDepth = std::max( 0.0f, std::min( 1.0f, initialDepth ) ); + float initialDepth = ( HUGE_NUMBER - Tr2Renderer::GetFrontClip() ) / ( Tr2Renderer::GetBackClip() - Tr2Renderer::GetFrontClip() ); + initialDepth = std::max( 0.0f, std::min( 1.0f, initialDepth ) ); - // Get the pick buffer - Tr2PickBuffer& pickBuffer = GetPickBuffer(); + // Get the pick buffer + Tr2PickBuffer& pickBuffer = GetPickBuffer(); - if( !pickBuffer.BeginRendering( initialDepth, renderContext ) ) - { - return false; - } + if( !pickBuffer.BeginRendering( initialDepth, renderContext ) ) + { + return false; + } - if( pOpaquePickingBatches->GetBatchCount() ) - { + if( pOpaquePickingBatches->GetBatchCount() ) + { pOpaquePickingBatches->Finalize(); - renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); - renderContext.RenderBatchesForPicking( pOpaquePickingBatches, BlueSharedString( "Picking" ) ); - } + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); + renderContext.RenderBatchesForPicking( pOpaquePickingBatches, BlueSharedString( "Picking" ) ); + } - if( pPickingBatches && RenderPickingAreasForComponents( pass ) ) - { - pPickingBatches->Finalize(); + if( pPickingBatches && RenderPickingAreasForComponents( pass ) ) + { + pPickingBatches->Finalize(); - renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); renderContext.RenderBatchesForPicking( pPickingBatches, DEFAULT_TECHNIQUE ); - } + } - if( !pickBuffer.EndRendering( renderContext ) ) - { - return false; - } + if( !pickBuffer.EndRendering( renderContext ) ) + { + return false; + } - return true; + return true; } namespace { -Be::VarChooser Tr2PickTypeChooser[] = -{ - { - "PICK_TYPE_PICKING", - BeCast( PICK_TYPE_PICKING ), - "Authored picking areas" - }, - { - "PICK_TYPE_OPAQUE", - BeCast( PICK_TYPE_OPAQUE ), - "Opaque objects" - }, - { - "PICK_TYPE_TRANSPARENT", - BeCast( PICK_TYPE_TRANSPARENT ), - "Transparent objects" - }, - { - "PICK_TYPE_ATTACHMENTS", - BeCast( PICK_TYPE_ATTACHMENTS ), - "Object attachments (decals, blinkies, etc.)" - }, - { - "PICK_TYPE_LOCATORS", - BeCast( PICK_TYPE_LOCATORS ), - "Object locators" - }, +Be::VarChooser Tr2PickTypeChooser[] = { + { "PICK_TYPE_PICKING", + BeCast( PICK_TYPE_PICKING ), + "Authored picking areas" }, + { "PICK_TYPE_OPAQUE", + BeCast( PICK_TYPE_OPAQUE ), + "Opaque objects" }, + { "PICK_TYPE_TRANSPARENT", + BeCast( PICK_TYPE_TRANSPARENT ), + "Transparent objects" }, + { "PICK_TYPE_ATTACHMENTS", + BeCast( PICK_TYPE_ATTACHMENTS ), + "Object attachments (decals, blinkies, etc.)" }, + { "PICK_TYPE_LOCATORS", + BeCast( PICK_TYPE_LOCATORS ), + "Object locators" }, { 0 } }; } diff --git a/trinity/ITr2PickableScene.h b/trinity/ITr2PickableScene.h index 53aced225..c1ea1b3d3 100644 --- a/trinity/ITr2PickableScene.h +++ b/trinity/ITr2PickableScene.h @@ -16,7 +16,7 @@ BLUE_DECLARE( Tr2Material ); // -------------------------------------------------------------------------------------- // Description: -// ITr2PickableScene is an interface for scenes that support GPU mouse picking. The +// ITr2PickableScene is an interface for scenes that support GPU mouse picking. The // interface has a few defined function helpers to do the actual work associated with // picking. ITr2PickableScene descendants only need to implement a few abstract // scene-dependant functions. @@ -33,13 +33,13 @@ struct ITr2PickableScene enum PickComponent { // Object pointer (IRoot) - PICK_OBJECT = 1, + PICK_OBJECT = 1, // Mesh and area indexes - PICK_AREA = 2, + PICK_AREA = 2, // World position - PICK_POSITION = 4, + PICK_POSITION = 4, // Object UV coordinates - PICK_UV = 8, + PICK_UV = 8, }; // Union of PickComponent typedef unsigned int PickComponents; @@ -65,6 +65,7 @@ struct ITr2PickableScene }; void PickObject( Tr2RenderContext& renderContext, int x, int y, TriProjection* proj, TriView* view, TriViewport* viewport, PickResults& results ); + protected: // ------------------------------------------------------------- // Description: @@ -84,11 +85,11 @@ struct ITr2PickableScene // Maximum number of picking passes static const unsigned int MAX_PICK_PASSES = 4; - - typedef std::vector ITr2RenderableArray; - typedef unsigned short ObjectIdType; - virtual void SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport ); + typedef std::vector ITr2RenderableArray; + typedef unsigned short ObjectIdType; + + virtual void SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport ); // ------------------------------------------------------------- // Description: @@ -128,7 +129,7 @@ struct ITr2PickableScene // Opaque render batch accumulator // ------------------------------------------------------------- virtual ITriRenderBatchAccumulator* GetOpaquePickingBatchAccumulator( void ) = 0; - + // ------------------------------------------------------------- // Description: // Returns a render batch accumulator to use for picking object @@ -141,7 +142,7 @@ struct ITr2PickableScene // ------------------------------------------------------------- // Description: // Returns an array of passes that need to be rendered in order - // to get all picking components. + // to get all picking components. // Arguments: // requestedComponents - Components requested for picking operation // (union of PickComponent). @@ -157,7 +158,7 @@ struct ITr2PickableScene // ------------------------------------------------------------- // Description: // Checks if the picking areas need to be rendered during the - // given pass. + // given pass. // Arguments: // pass - union of PickComponent that are to be queried during // this pass. @@ -170,12 +171,12 @@ struct ITr2PickableScene // ------------------------------------------------------------- // Description: - // Decodes results in the picking buffer after the given pass. + // Decodes results in the picking buffer after the given pass. // Arguments: // pBuffer - contents of the picking buffer. // pass - union of PickComponent that are to be queried during // this pass. - // results - (out) results decoded from the buffer (the + // results - (out) results decoded from the buffer (the // function only needs to set fields turned on in the pass // argument). // ------------------------------------------------------------- @@ -184,22 +185,20 @@ struct ITr2PickableScene // ------------------------------------------------------------- // Description: - // Returns picking buffer to use for picking. + // Returns picking buffer to use for picking. // Return Value: // Picking buffer to use for picking // ------------------------------------------------------------- virtual Tr2PickBuffer& GetPickBuffer( void ) = 0; virtual bool RenderPicking( ITriRenderBatchAccumulator* pOpaquePickingBatches, - ITriRenderBatchAccumulator* pPickingBatches, - PickComponents pass ); + ITriRenderBatchAccumulator* pPickingBatches, + PickComponents pass ); + private: - // Do-all combo method. If pickedUV is not none, this switches to UV - // picking and pickedObject and area are no longer filled in. - void PickObject( int x, int y, TriProjection* proj, TriView* view, - TriViewport* viewport, IRoot** pickedObject, - Vector3* outWorldPosition, unsigned int* outArea, - Vector2* pickedUV ); + // Do-all combo method. If pickedUV is not none, this switches to UV + // picking and pickedObject and area are no longer filled in. + void PickObject( int x, int y, TriProjection* proj, TriView* view, TriViewport* viewport, IRoot** pickedObject, Vector3* outWorldPosition, unsigned int* outArea, Vector2* pickedUV ); void GetBatches( std::vector const& pickableObjects, ITriRenderBatchAccumulator*& pOpaquePickingBatches, diff --git a/trinity/ITr2Renderable.h b/trinity/ITr2Renderable.h index 64ef87acf..3c08d247f 100644 --- a/trinity/ITr2Renderable.h +++ b/trinity/ITr2Renderable.h @@ -48,23 +48,23 @@ BLUE_INTERFACE( ITr2Renderable ) : { return true; } - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) = 0; + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ) = 0; virtual bool HasTransparentBatches() = 0; - virtual float GetSortValue() = 0; + virtual float GetSortValue() = 0; - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) = 0; + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ) = 0; }; REGISTER_COMPONENT_TYPE( "ReflectionRenderable", ITr2Renderable ); struct ITr2RenderableEntry { - ITr2Renderable* m_object; - float m_distance; - bool operator<( const ITr2RenderableEntry& other ) const - { - return m_distance < other.m_distance; - } + ITr2Renderable* m_object; + float m_distance; + bool operator<( const ITr2RenderableEntry& other ) const + { + return m_distance < other.m_distance; + } bool operator<=( const ITr2RenderableEntry& other ) const { return m_distance <= other.m_distance; @@ -85,10 +85,11 @@ enum Tr2PickType typedef uint32_t Tr2PickTypes; -BLUE_INTERFACE( ITr2Pickable ) : public IRoot +BLUE_INTERFACE( ITr2Pickable ) : + public IRoot { - virtual IRoot* GetID( uint16_t areaId ) = 0; - virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) = 0; + virtual IRoot* GetID( uint16_t areaId ) = 0; + virtual void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ) = 0; }; BLUE_DECLARE_INTERFACE( ITr2Pickable ); diff --git a/trinity/ITr2SkinnedObject.h b/trinity/ITr2SkinnedObject.h index 1ca77a9c9..09c373457 100644 --- a/trinity/ITr2SkinnedObject.h +++ b/trinity/ITr2SkinnedObject.h @@ -4,11 +4,12 @@ #ifndef ITR2SKINNEDOBJECT_H #define ITR2SKINNEDOBJECT_H -BLUE_INTERFACE( ITr2SkinnedObject ) : public IRoot +BLUE_INTERFACE( ITr2SkinnedObject ) : + public IRoot { - virtual const Vector3 GetScaling() const = 0; - virtual const Quaternion GetRotation() const = 0; - virtual const Vector3& GetPosition() const = 0; + virtual const Vector3 GetScaling() const = 0; + virtual const Quaternion GetRotation() const = 0; + virtual const Vector3& GetPosition() const = 0; }; #endif // TR2SKINNEDOBJECT_H \ No newline at end of file diff --git a/trinity/ITr2SoundEmitterOwner.h b/trinity/ITr2SoundEmitterOwner.h index 93c49cb41..027392297 100644 --- a/trinity/ITr2SoundEmitterOwner.h +++ b/trinity/ITr2SoundEmitterOwner.h @@ -6,7 +6,8 @@ BLUE_DECLARE_INTERFACE( ITr2AudEmitter ); BLUE_DECLARE( TriObserverLocal ); -BLUE_INTERFACE( ITr2SoundEmitterOwner ): public IRoot +BLUE_INTERFACE( ITr2SoundEmitterOwner ) : + public IRoot { virtual ITr2AudEmitterPtr FindSoundEmitter( const char* name ) = 0; virtual void AddObserver( TriObserverLocalPtr observer ) {}; diff --git a/trinity/ITr2TextureProvider.h b/trinity/ITr2TextureProvider.h index a7447007d..5e8a8e21c 100644 --- a/trinity/ITr2TextureProvider.h +++ b/trinity/ITr2TextureProvider.h @@ -8,7 +8,8 @@ #include "Tr2Event.h" -BLUE_INTERFACE( ITr2TextureProvider ) : public IRoot +BLUE_INTERFACE( ITr2TextureProvider ) : + public IRoot { using OnTextureChangeEvent = Tr2Event<>; virtual Tr2TextureAL* GetTexture() = 0; diff --git a/trinity/ITr2VisualizationModeRenderer.h b/trinity/ITr2VisualizationModeRenderer.h index f8d326325..654179f95 100644 --- a/trinity/ITr2VisualizationModeRenderer.h +++ b/trinity/ITr2VisualizationModeRenderer.h @@ -6,19 +6,20 @@ // ------------------------------------------------------------- // Description: -// Objects implementing ITr2VisualizationModeRenderer are -// supposed to have an ability to render using different +// Objects implementing ITr2VisualizationModeRenderer are +// supposed to have an ability to render using different // debug visualization modes. // SeeAlso: // TriStepSetVisualizationMode // ------------------------------------------------------------- -BLUE_INTERFACE( ITr2VisualizationModeRenderer ) : public IRoot +BLUE_INTERFACE( ITr2VisualizationModeRenderer ) : + public IRoot { // ------------------------------------------------------------- // Description: // Sets the new visualization mode for the object. // Arguments: - // visualizationMode - new visualization mode (semantics of + // visualizationMode - new visualization mode (semantics of // modes is implementation-specific). // ------------------------------------------------------------- virtual void SetVisualizationMode( int visualizationMode ) = 0; diff --git a/trinity/ITr2WorldTransformUpdater.h b/trinity/ITr2WorldTransformUpdater.h index eafee9fe1..f16775944 100644 --- a/trinity/ITr2WorldTransformUpdater.h +++ b/trinity/ITr2WorldTransformUpdater.h @@ -4,9 +4,10 @@ #ifndef ITr2WorldTransformUpdater_H #define ITr2WorldTransformUpdater_H -BLUE_INTERFACE( ITr2WorldTransformUpdater ) : public IRoot +BLUE_INTERFACE( ITr2WorldTransformUpdater ) : + public IRoot { - virtual void UpdateTransform( Be::Time time, Matrix* transform ) = 0; + virtual void UpdateTransform( Be::Time time, Matrix * transform ) = 0; }; diff --git a/trinity/ITriReroutable.h b/trinity/ITriReroutable.h index a47768994..6f9af0e4e 100644 --- a/trinity/ITriReroutable.h +++ b/trinity/ITriReroutable.h @@ -5,12 +5,13 @@ class TriValueBinding; -BLUE_INTERFACE( ITriReroutable ) : public IRoot +BLUE_INTERFACE( ITriReroutable ) : + public IRoot { virtual void SetDestination( void* dest, size_t size ) = 0; virtual void GetDestination( void*& dest, size_t& size ) = 0; - virtual void RegisterBinding( TriValueBinding* vb ) = 0; - virtual void UnregisterBinding( TriValueBinding* vb ) = 0; + virtual void RegisterBinding( TriValueBinding * vb ) = 0; + virtual void UnregisterBinding( TriValueBinding * vb ) = 0; virtual bool IsRerouted() const = 0; }; diff --git a/trinity/IWorldPosition.h b/trinity/IWorldPosition.h index 26a688281..df9522ae4 100644 --- a/trinity/IWorldPosition.h +++ b/trinity/IWorldPosition.h @@ -3,12 +3,13 @@ #ifndef IWorldPosition_H #define IWorldPosition_H -// Forward declaration. +// Forward declaration. // Can't include these in interfaces. struct Vector3; -BLUE_INTERFACE(IWorldPosition) : IRoot -{ +BLUE_INTERFACE( IWorldPosition ) : + IRoot +{ virtual Vector3 GetWorldPosition() = 0; virtual Quaternion GetWorldRotation() = 0; }; diff --git a/trinity/Include/IEveBallpark.h b/trinity/Include/IEveBallpark.h index 5f8fdd9df..e552018c1 100644 --- a/trinity/Include/IEveBallpark.h +++ b/trinity/Include/IEveBallpark.h @@ -5,30 +5,27 @@ #include "IEveReferencePoint.h" -// Forward declarations. +// Forward declarations. // Can't include these in interfaces. struct Vector3; struct Vector3d; -BLUE_INTERFACE(IEveBallpark) : IEveReferencePoint -{ +BLUE_INTERFACE( IEveBallpark ) : + IEveReferencePoint +{ virtual void Delta( - Vector3* ref, - Vector3* refSmooth, - Be::Time time - ) = 0; + Vector3 * ref, + Vector3 * refSmooth, + Be::Time time ) = 0; virtual void DeltaVel( - Vector3* vel, - Be::Time time - ) = 0; + Vector3 * vel, + Be::Time time ) = 0; - virtual float GetUnitBase( - ) = 0; + virtual float GetUnitBase() = 0; - virtual void SetUnitBase( - float unit - ) = 0; + virtual void SetUnitBase( + float unit ) = 0; }; #endif \ No newline at end of file diff --git a/trinity/Include/IEveReferencePoint.h b/trinity/Include/IEveReferencePoint.h index d9095134f..3345625a1 100644 --- a/trinity/Include/IEveReferencePoint.h +++ b/trinity/Include/IEveReferencePoint.h @@ -3,13 +3,14 @@ #ifndef IEveReferencePoint_H #define IEveReferencePoint_H -// Forward declaration. +// Forward declaration. // Can't include these in interfaces. struct Vector3d; -BLUE_INTERFACE(IEveReferencePoint) : IRoot -{ - virtual Vector3d* GetReferencePoint(Vector3d* out, Be::Time time) = 0; +BLUE_INTERFACE( IEveReferencePoint ) : + IRoot +{ + virtual Vector3d* GetReferencePoint( Vector3d * out, Be::Time time ) = 0; }; #endif diff --git a/trinity/Include/ITr2AnimationUpdater.h b/trinity/Include/ITr2AnimationUpdater.h index 49674e82a..904c445bb 100644 --- a/trinity/Include/ITr2AnimationUpdater.h +++ b/trinity/Include/ITr2AnimationUpdater.h @@ -4,13 +4,14 @@ #ifndef ITr2AnimationUpdater_H #define ITr2AnimationUpdater_H -BLUE_INTERFACE( ITr2AnimationUpdater ) : public IRoot +BLUE_INTERFACE( ITr2AnimationUpdater ) : + public IRoot { - virtual void PrePhysicsAnimation( Be::Time time, const Matrix &modelTransform ) = 0; - virtual void PostPhysicsAnimation( Be::Time time, const Matrix &modelTransform ) = 0; + virtual void PrePhysicsAnimation( Be::Time time, const Matrix& modelTransform ) = 0; + virtual void PostPhysicsAnimation( Be::Time time, const Matrix& modelTransform ) = 0; virtual const Matrix* GetAnimationTransforms() = 0; - virtual const std::string *GetAnimationBoneList( unsigned int& numBones ) const = 0; + virtual const std::string* GetAnimationBoneList( unsigned int& numBones ) const = 0; }; diff --git a/trinity/Include/ITr2AudioEmitter.h b/trinity/Include/ITr2AudioEmitter.h index 4590bbdaf..fd23fc544 100644 --- a/trinity/Include/ITr2AudioEmitter.h +++ b/trinity/Include/ITr2AudioEmitter.h @@ -4,7 +4,8 @@ struct Matrix; -BLUE_INTERFACE( ITr2AudioEmitter ) : public IRoot +BLUE_INTERFACE( ITr2AudioEmitter ) : + public IRoot { virtual void SendEvent() = 0; virtual void SetTransform( const Matrix& worldTransform ) = 0; diff --git a/trinity/Include/ITr2BoundingBox.h b/trinity/Include/ITr2BoundingBox.h index f5fbb3ad6..0a54ce568 100644 --- a/trinity/Include/ITr2BoundingBox.h +++ b/trinity/Include/ITr2BoundingBox.h @@ -7,9 +7,10 @@ struct Vector3; -BLUE_INTERFACE( ITr2BoundingBox ) : IRoot +BLUE_INTERFACE( ITr2BoundingBox ) : + IRoot { - virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const = 0; + virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const = 0; virtual bool IsBoundingBoxReady( void ) const = 0; }; diff --git a/trinity/Include/ITr2DebugRenderer.h b/trinity/Include/ITr2DebugRenderer.h index 83837e150..68752005a 100644 --- a/trinity/Include/ITr2DebugRenderer.h +++ b/trinity/Include/ITr2DebugRenderer.h @@ -5,7 +5,8 @@ #include "Rect.h" -BLUE_INTERFACE( ITr2DebugRenderer ) : IRoot +BLUE_INTERFACE( ITr2DebugRenderer ) : + IRoot { virtual void DrawPointCloud( int numPoints, float* points, int stride ) = 0; @@ -18,7 +19,7 @@ BLUE_INTERFACE( ITr2DebugRenderer ) : IRoot virtual void DrawCylinder( const Vector3& start, const Vector3& end, float radius, int segments, uint32_t color = 0xffffffff ) = 0; virtual void DrawCone( const Vector3& start, const Vector3& end, float radius, int segments, uint32_t color = 0xffffffff ) = 0; virtual void DrawPlane( const Vector4& planeEquation, int segments, uint32_t color = 0xffffffff ) = 0; - + // Draw axis lines, red for x, green for y, blue for z for the coordinate system defined by the given // transform. The axes are rendered as one unit, optionally scaled by the given scale factor on top // of any scaling in the transform. diff --git a/trinity/Include/ITr2DebugRenderer2.h b/trinity/Include/ITr2DebugRenderer2.h index 3725c94cd..190094d44 100644 --- a/trinity/Include/ITr2DebugRenderer2.h +++ b/trinity/Include/ITr2DebugRenderer2.h @@ -4,7 +4,7 @@ // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. // The file version in the older blue versions had diverged from this one is incompatible. -// There is already an outdated interface for ITr2DebugRenderer that needs to be +// There is already an outdated interface for ITr2DebugRenderer that needs to be // there atm for legacy reasons. Thus why this is nr.2 (okt 2019) #pragma once @@ -59,40 +59,40 @@ struct Tr2DebugColor return c; } - Tr2DebugColor( uint32_t color ) - :m_color( color ), + Tr2DebugColor( uint32_t color ) : + m_color( color ), m_zFailColor( 0u ), m_colorSelected( GetAutoSelectedColor( color ) ), m_zFailColorSelected( 0u ) { } - Tr2DebugColor( const Color& color ) - :m_color( color ), + Tr2DebugColor( const Color& color ) : + m_color( color ), m_zFailColor( 0u ), m_colorSelected( GetAutoSelectedColor( color ) ), m_zFailColorSelected( 0u ) { } - Tr2DebugColor( uint32_t color, uint32_t zFailColor ) - :m_color( color ), + Tr2DebugColor( uint32_t color, uint32_t zFailColor ) : + m_color( color ), m_zFailColor( zFailColor ), m_colorSelected( GetAutoSelectedColor( color ) ), m_zFailColorSelected( GetAutoSelectedColor( zFailColor ) ) { } - Tr2DebugColor( const Color& color, const Color& zFailColor ) - :m_color( color ), + Tr2DebugColor( const Color& color, const Color& zFailColor ) : + m_color( color ), m_zFailColor( zFailColor ), m_colorSelected( GetAutoSelectedColor( color ) ), m_zFailColorSelected( GetAutoSelectedColor( zFailColor ) ) { } - Tr2DebugColor( const Color& color, const Color& zFailColor, const Color& selectedColor, const Color& zFailSelectedColor ) - :m_color( color ), + Tr2DebugColor( const Color& color, const Color& zFailColor, const Color& selectedColor, const Color& zFailSelectedColor ) : + m_color( color ), m_zFailColor( zFailColor ), m_colorSelected( selectedColor ), m_zFailColorSelected( zFailSelectedColor ) @@ -106,15 +106,15 @@ struct Tr2DebugObjectReference uint32_t m_area; template - Tr2DebugObjectReference( T* object ) - :m_object( object->GetRawRoot() ), + Tr2DebugObjectReference( T* object ) : + m_object( object->GetRawRoot() ), m_area( 0 ) { } template - Tr2DebugObjectReference( T* object, uint32_t area ) - : m_object( object->GetRawRoot() ), + Tr2DebugObjectReference( T* object, uint32_t area ) : + m_object( object->GetRawRoot() ), m_area( area ) { } @@ -128,7 +128,8 @@ struct Tr2DebugObjectReference bool operator!=( const Tr2DebugObjectReference& other ) const; }; -BLUE_INTERFACE( ITr2DebugRenderer2 ) : public IRoot +BLUE_INTERFACE( ITr2DebugRenderer2 ) : + public IRoot { enum Effect { @@ -138,13 +139,13 @@ BLUE_INTERFACE( ITr2DebugRenderer2 ) : public IRoot }; template - bool HasOption( T* owner, const char* option ) const + bool HasOption( T * owner, const char* option ) const { return this->HasOption( owner->GetRawRoot(), option ); } - virtual bool HasOption( IRoot* owner, const char* option ) const = 0; - virtual bool IsSelected( IRoot* owner ) const = 0; + virtual bool HasOption( IRoot * owner, const char* option ) const = 0; + virtual bool IsSelected( IRoot * owner ) const = 0; virtual bool IsSelected( Tr2DebugObjectReference owner ) const = 0; virtual void DrawLine( Tr2DebugObjectReference owner, const Vector3& from, const Vector3& to, Tr2DebugColor color ) = 0; @@ -166,9 +167,9 @@ BLUE_INTERFACE( ITr2DebugRenderer2 ) : public IRoot virtual void DrawCone( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ) = 0; virtual void DrawCone( Tr2DebugObjectReference owner, const Vector3& base, const Vector3& focal, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ) = 0; - + virtual void DrawCone( Tr2DebugObjectReference owner, const Matrix& transform, float height, float angle, uint32_t segments, uint32_t coneSegments, Effect effect, Tr2DebugColor color ) = 0; - + virtual void DrawCapsule( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ) = 0; virtual void DrawCapsule( Tr2DebugObjectReference owner, const Vector3& cap0, const Vector3& cap1, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ) = 0; @@ -189,11 +190,12 @@ BLUE_INTERFACE( ITr2DebugRenderer2 ) : public IRoot virtual void DrawAudioSpeaker( Tr2DebugObjectReference owner, const Matrix& transform, float size, uint32_t segments, Effect effect, Tr2DebugColor color ) = 0; }; -BLUE_INTERFACE( ITr2DebugRenderable ) : public IRoot +BLUE_INTERFACE( ITr2DebugRenderable ) : + public IRoot { virtual void GetDebugOptions( Tr2DebugRendererOptions & options ) = 0; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer ) = 0; + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer ) = 0; }; #endif diff --git a/trinity/Include/ITr2GpuBuffer.h b/trinity/Include/ITr2GpuBuffer.h index b24851358..bd0981c61 100644 --- a/trinity/Include/ITr2GpuBuffer.h +++ b/trinity/Include/ITr2GpuBuffer.h @@ -10,7 +10,8 @@ // See Also: // Tr2GpuBuffer, TriGeometryRes, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2GpuBuffer ): public IRoot +BLUE_INTERFACE( ITr2GpuBuffer ) : + public IRoot { // ---------------------------------------------------------------------------------- // Description: diff --git a/trinity/Include/ITr2InstanceData.h b/trinity/Include/ITr2InstanceData.h index f824c6b25..941b6b81b 100644 --- a/trinity/Include/ITr2InstanceData.h +++ b/trinity/Include/ITr2InstanceData.h @@ -10,14 +10,15 @@ BLUE_DECLARE_INTERFACE( ITr2InstanceData ); // -------------------------------------------------------------------------------------- // Description: -// ITr2InstanceData is an interface for instance data provider that is intended to +// ITr2InstanceData is an interface for instance data provider that is intended to // work with Tr2InstancedMesh class. Classes implementing ITr2InstanceData interface // are able to provide vertex buffers and declarations to be used as instance stream // for instanced rendering. // See Also: // Tr2InstancedMesh, TriGeometryRes, Tr2SpriteParticleSystem // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2InstanceData ) : public IRoot +BLUE_INTERFACE( ITr2InstanceData ) : + public IRoot { // -------------------------------------------------------------------------------------- // Description: diff --git a/trinity/Include/ITr2Interior.h b/trinity/Include/ITr2Interior.h index bfea51c02..9f2f8f2df 100644 --- a/trinity/Include/ITr2Interior.h +++ b/trinity/Include/ITr2Interior.h @@ -24,33 +24,35 @@ enum CullResult BLUE_DECLARE( Tr2ApexScene ); -BLUE_INTERFACE( ITr2InteriorCullable ) : public IRoot +BLUE_INTERFACE( ITr2InteriorCullable ) : + public IRoot { virtual bool IsInFrustum( const TriFrustum& frustum, Matrix& objectToWorld ) const = 0; }; -BLUE_INTERFACE( ITr2Interior ) : public ITr2InteriorCullable +BLUE_INTERFACE( ITr2Interior ) : + public ITr2InteriorCullable { // Per-object data for instanced lighting - virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( - ITriRenderBatchAccumulator* accumulator, - Tr2InteriorLightSet* lightSet, - const Matrix& objectToWorldMatrix - ) = 0; + virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( + ITriRenderBatchAccumulator * accumulator, + Tr2InteriorLightSet * lightSet, + const Matrix& objectToWorldMatrix ) = 0; }; BLUE_DECLARE_IVECTOR( ITr2Interior ); -BLUE_INTERFACE( ITr2InteriorDynamic ) : public ITr2Interior +BLUE_INTERFACE( ITr2InteriorDynamic ) : + public ITr2Interior { - virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const = 0; + virtual bool GetWorldBoundingBox( Vector3 & min, Vector3 & max ) const = 0; virtual bool IsBoundingBoxReady( void ) const = 0; // Spherical harmonics update virtual void PrePhysicsUpdate( Be::Time time ) = 0; - virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene ) = 0; + virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene * apexScene ) = 0; // Scene add/remove - virtual bool AddToScene( Tr2ApexScene* apexScene ) = 0; + virtual bool AddToScene( Tr2ApexScene * apexScene ) = 0; virtual void RemoveFromScene( void ) = 0; // LOD @@ -61,10 +63,11 @@ BLUE_DECLARE_IVECTOR( ITr2InteriorDynamic ); // ------------------------------------------------------------- // Description: -// ITr2InteriorLight represents light source for interior +// ITr2InteriorLight represents light source for interior // scene. // ------------------------------------------------------------- -BLUE_INTERFACE( ITr2InteriorLight ) : public ITr2InteriorCullable +BLUE_INTERFACE( ITr2InteriorLight ) : + public ITr2InteriorCullable { // Helper structure for determining shadow caster importance @@ -102,7 +105,7 @@ BLUE_INTERFACE( ITr2InteriorLight ) : public ITr2InteriorCullable // Arguments: // lightData - Per-object light data // ------------------------------------------------------------- - virtual void PopulateLightData( Tr2InteriorPerObjectLightData* lightData ) const = 0; + virtual void PopulateLightData( Tr2InteriorPerObjectLightData * lightData ) const = 0; // ------------------------------------------------------------- // Description: diff --git a/trinity/Include/ITr2MultiPassScene.h b/trinity/Include/ITr2MultiPassScene.h index 4409b08a6..b996b8e24 100644 --- a/trinity/Include/ITr2MultiPassScene.h +++ b/trinity/Include/ITr2MultiPassScene.h @@ -13,7 +13,8 @@ class Tr2RenderContext; // SeeAlso: // ITr2Scene // ------------------------------------------------------------- -BLUE_INTERFACE( ITr2MultiPassScene ) : public IRoot +BLUE_INTERFACE( ITr2MultiPassScene ) : + public IRoot { enum RenderPassResult { @@ -31,7 +32,7 @@ BLUE_INTERFACE( ITr2MultiPassScene ) : public IRoot RP_END_RENDER, RP_BACKGROUND_RENDER, RP_MAIN_RENDER, - RP_REFLECTION_RENDER , + RP_REFLECTION_RENDER, RP_DEPTH_PASS, RP_SET_PERFRAME_DATA, RP_RENDER_UI, @@ -39,7 +40,7 @@ BLUE_INTERFACE( ITr2MultiPassScene ) : public IRoot }; // Renders a given pass - virtual RenderPassResult RenderPass( PassType pass, Tr2RenderContext& renderContext ) = 0; + virtual RenderPassResult RenderPass( PassType pass, Tr2RenderContext & renderContext ) = 0; }; #endif // ITr2MultiPassScene_H diff --git a/trinity/Include/ITr2Scene.h b/trinity/Include/ITr2Scene.h index 92830fd8c..d56c67609 100644 --- a/trinity/Include/ITr2Scene.h +++ b/trinity/Include/ITr2Scene.h @@ -8,10 +8,11 @@ class Tr2RenderContext; -BLUE_INTERFACE( ITr2Scene ) : public ITr2Updateable +BLUE_INTERFACE( ITr2Scene ) : + public ITr2Updateable { - virtual void Render( Tr2RenderContext& renderContext ) = 0; - virtual void RenderDebugInfo( Tr2RenderContext& renderContext ) = 0; + virtual void Render( Tr2RenderContext & renderContext ) = 0; + virtual void RenderDebugInfo( Tr2RenderContext & renderContext ) = 0; }; #endif // ITr2Scene_H \ No newline at end of file diff --git a/trinity/Include/ITr2Updateable.h b/trinity/Include/ITr2Updateable.h index 584334c00..20c613846 100644 --- a/trinity/Include/ITr2Updateable.h +++ b/trinity/Include/ITr2Updateable.h @@ -4,7 +4,8 @@ #ifndef ITr2Updatable_H #define ITr2Updatable_H -BLUE_INTERFACE( ITr2Updateable ) : public IRoot +BLUE_INTERFACE( ITr2Updateable ) : + public IRoot { virtual void Update( Be::Time realTime, Be::Time simTime ) = 0; }; diff --git a/trinity/Include/ITr2ValueBinding.h b/trinity/Include/ITr2ValueBinding.h index 613ab2eb0..90f329ffe 100644 --- a/trinity/Include/ITr2ValueBinding.h +++ b/trinity/Include/ITr2ValueBinding.h @@ -4,7 +4,8 @@ #ifndef ITr2ValueBinding_H #define ITr2ValueBinding_H -BLUE_INTERFACE( ITr2ValueBinding ) : public IRoot +BLUE_INTERFACE( ITr2ValueBinding ) : + public IRoot { virtual void CopyValue() = 0; }; diff --git a/trinity/Include/ITriColor.h b/trinity/Include/ITriColor.h index 56a327a2a..80518733e 100644 --- a/trinity/Include/ITriColor.h +++ b/trinity/Include/ITriColor.h @@ -7,53 +7,46 @@ struct ITriVector; -BLUE_INTERFACE( ITriColor ) : public IRoot +BLUE_INTERFACE( ITriColor ) : + public IRoot { // Construction and data access virtual void SetRGB( - float r, - float g, + float r, + float g, float b, - float a - ) = 0; + float a ) = 0; // if 'alpha' is TRICOLOR_NOALPHA, it's left as is virtual void SetHSV( - float hue, - float saturation, - float value, - float alpha - ) = 0; + float hue, + float saturation, + float value, + float alpha ) = 0; virtual void SetColor( - const Color* c - ) = 0; + const Color* c ) = 0; - virtual const ::Color* GetColor( - ) const =0; + virtual const ::Color* GetColor() const = 0; virtual ::Color* CopyColor( - ::Color* in - ) const =0; + ::Color * in ) const = 0; + + virtual ::Color* Color() = 0; - virtual ::Color* Color( - ) = 0; - // if 'alpha' is NULL then nothing is done to that pointer virtual void GetHSV( - float* hue, - float* saturation, - float* value, - float* alpha - ) = 0; + float* hue, + float* saturation, + float* value, + float* alpha ) = 0; // Math functions virtual void Scale( - float s - ) = 0; + float s ) = 0; - // Turns a normalized vector into RGBA form. Used to encode vectors into a height map. + // Turns a normalized vector into RGBA form. Used to encode vectors into a height map. //virtual void SetVector( // ITriVector* vec, // float height diff --git a/trinity/Include/ITriDevice.h b/trinity/Include/ITriDevice.h index cc3648aa4..1b5268605 100644 --- a/trinity/Include/ITriDevice.h +++ b/trinity/Include/ITriDevice.h @@ -25,31 +25,30 @@ enum Tr2DeviceCallbackTime // See also: // ITriDevice // -------------------------------------------------------------------------------------- -typedef void (*Tr2DeviceCallback)( ITriDevice* device, void* userData ); +typedef void ( *Tr2DeviceCallback )( ITriDevice* device, void* userData ); -BLUE_INTERFACE(ITriDevice) : public IRoot +BLUE_INTERFACE( ITriDevice ) : + public IRoot { // !!! NOTE, all objects are returned // without any addrefing - + // D3D rendering objects - + virtual float AspectRatio() = 0; virtual void ScreenToProjection( int x, int y, float* fx, - float* fy - ) = 0; + float* fy ) = 0; - virtual bool SetPresentation ( + virtual bool SetPresentation( int adapter, - const Tr2PresentParametersAL* d3dpp - ) = 0; + const Tr2PresentParametersAL* d3dpp ) = 0; virtual bool ChangeDevice( - uint32_t adapter, Tr2WindowHandle hWnd, const Tr2PresentParametersAL *pp) = 0; + uint32_t adapter, Tr2WindowHandle hWnd, const Tr2PresentParametersAL* pp ) = 0; }; #endif \ No newline at end of file diff --git a/trinity/Include/ITriDuration.h b/trinity/Include/ITriDuration.h index 073adde66..7456721d4 100644 --- a/trinity/Include/ITriDuration.h +++ b/trinity/Include/ITriDuration.h @@ -6,24 +6,23 @@ #include "ITriConstants.h" // This interface ties together the properties that are shared by curves, but not all functions -BLUE_INTERFACE(ITriDuration): public IRoot +BLUE_INTERFACE( ITriDuration ) : + public IRoot { virtual Be::Time Start() = 0; - virtual void SetStartTime(Be::Time startTime) = 0; + virtual void SetStartTime( Be::Time startTime ) = 0; // Required, because Scaling time will not resort virtual void Sort() = 0; virtual void ScaleTime( - float s - ) = 0; + float s ) = 0; virtual void Reverse() = 0; virtual void ScaleValue( - float s - ) = 0; + float s ) = 0; - virtual float Length() = 0; + virtual float Length() = 0; virtual TRIEXTRAPOLATION Extrapolation() = 0; }; diff --git a/trinity/Include/ITriEffectParameter.h b/trinity/Include/ITriEffectParameter.h index 9823befab..25bf80c66 100644 --- a/trinity/Include/ITriEffectParameter.h +++ b/trinity/Include/ITriEffectParameter.h @@ -7,11 +7,12 @@ BLUE_DECLARE( Tr2Shader ); -BLUE_INTERFACE(ITriEffectParameter) : public ITr2EffectValue +BLUE_INTERFACE( ITriEffectParameter ) : + public ITr2EffectValue { virtual const char* GetParameterName() const = 0; - virtual void RebuildEffectHandles( Tr2Shader* effectRes ) = 0; + virtual void RebuildEffectHandles( Tr2Shader * effectRes ) = 0; virtual unsigned GetHashValue( unsigned startingHash ) const = 0; @@ -24,11 +25,10 @@ BLUE_DECLARE_IVECTOR( ITriEffectParameter ); typedef BlueDict ITriEffectParameterDict; TYPEDEF_BLUECLASS( ITriEffectParameterDict ); -BLUE_INTERFACE(ITriEffectResourceParameter) : public ITriEffectParameter -{ - virtual void OnAddedToMaterial( Tr2Material* material ) {} - virtual void OnRemovedFromMaterial( Tr2Material* material ) {} -}; +BLUE_INTERFACE( ITriEffectResourceParameter ) : + public ITriEffectParameter{ + virtual void OnAddedToMaterial( Tr2Material * material ){} virtual void OnRemovedFromMaterial( Tr2Material * material ){} + }; BLUE_DECLARE_IVECTOR( ITriEffectResourceParameter ); BLUE_INTERFACE( ITriEffectTextureParameter ) : diff --git a/trinity/Include/ITriMatrix.h b/trinity/Include/ITriMatrix.h index 7e19bc917..643e32b2b 100644 --- a/trinity/Include/ITriMatrix.h +++ b/trinity/Include/ITriMatrix.h @@ -3,31 +3,24 @@ #ifndef _ITRIMATRIX_H_ #define _ITRIMATRIX_H_ -BLUE_INTERFACE( ITriMatrix ) : public IRoot +BLUE_INTERFACE( ITriMatrix ) : + public IRoot { // Construction and data access virtual void SetPivots( - float _11, float _12, float _13, float _14, - float _21, float _22, float _23, float _24, - float _31, float _32, float _33, float _34, - float _41, float _42, float _43, float _44 - ) = 0; + float _11, float _12, float _13, float _14, float _21, float _22, float _23, float _24, float _31, float _32, float _33, float _34, float _41, float _42, float _43, float _44 ) = 0; virtual void SetMatrix( - const Matrix* m - ) = 0; + const Matrix* m ) = 0; - virtual const Matrix* GetMatrix( - ) const =0; + virtual const Matrix* GetMatrix() const = 0; virtual Matrix* CopyMatrix( - Matrix* in - ) const =0; + Matrix * in ) const = 0; // Math functions - virtual void Identity( - ) = 0; + virtual void Identity() = 0; }; #endif \ No newline at end of file diff --git a/trinity/Include/ITriQuaternion.h b/trinity/Include/ITriQuaternion.h index 67f0a555b..549525eef 100644 --- a/trinity/Include/ITriQuaternion.h +++ b/trinity/Include/ITriQuaternion.h @@ -6,89 +6,73 @@ struct Quaternion; struct Vector3; -BLUE_INTERFACE( ITriQuaternion ) : public IRoot -{ +BLUE_INTERFACE( ITriQuaternion ) : + public IRoot +{ // Construction and data access virtual void SetXYZW( - float x, - float y, + float x, + float y, float z, - float w - ) = 0; + float w ) = 0; virtual void SetQuaternion( - const Quaternion* ar - ) = 0; + const Quaternion* ar ) = 0; - virtual const ::Quaternion* GetQuaternion( - ) const =0; + virtual const ::Quaternion* GetQuaternion() const = 0; virtual ::Quaternion* CopyQuaternion( - Quaternion* in - ) const =0; + Quaternion * in ) const = 0; - virtual ::Quaternion* Quaternion( - ) = 0; + virtual ::Quaternion* Quaternion() = 0; // Math functions - virtual void SetIdentity( - ) = 0; + virtual void SetIdentity() = 0; virtual void SetRotationAxis( - const Vector3* axis, - float angle - ) = 0; + const Vector3* axis, + float angle ) = 0; virtual void GetRotationAxis( - Vector3* axis, - float* angle - ) const = 0; - + Vector3 * axis, + float* angle ) const = 0; + virtual void SetYawPitchRoll( - float yaw, - float pitch, - float roll - ) = 0; + float yaw, + float pitch, + float roll ) = 0; virtual void GetYawPitchRoll( - float* yaw, - float* pitch, - float* roll - ) const = 0; + float* yaw, + float* pitch, + float* roll ) const = 0; virtual void IncreaseYawPitchRoll( - float yaw, - float pitch, - float roll - ) = 0; + float yaw, + float pitch, + float roll ) = 0; virtual void IncreaseLocalYawPitchRoll( - float yaw, - float pitch, - float roll - ) = 0; + float yaw, + float pitch, + float roll ) = 0; virtual void SetRotationArc( const Vector3* v0, - const Vector3* v1 - ) = 0; + const Vector3* v1 ) = 0; virtual void MultiplyQuaternion( - const ::Quaternion* in - ) = 0; + const ::Quaternion* in ) = 0; virtual void SetSLERP( const ::Quaternion* q1, const ::Quaternion* q2, - const float t - ) = 0; + const float t ) = 0; - virtual void Normalize( - ) = 0; + virtual void Normalize() = 0; - virtual float Length( - ) const = 0; + virtual float Length() const = 0; }; #endif \ No newline at end of file diff --git a/trinity/Include/ITriTargetable.h b/trinity/Include/ITriTargetable.h index 41991a98e..504588ab5 100644 --- a/trinity/Include/ITriTargetable.h +++ b/trinity/Include/ITriTargetable.h @@ -3,7 +3,8 @@ #ifndef _ITRITARGETABLE_H_ #define _ITRITARGETABLE_H_ -BLUE_INTERFACE(ITriTargetable): IRoot +BLUE_INTERFACE( ITriTargetable ) : + IRoot { enum ImpactConfiguration { @@ -15,17 +16,22 @@ BLUE_INTERFACE(ITriTargetable): IRoot virtual unsigned int GetDamageLocatorCount() const = 0; virtual int GetClosestDamageLocatorIndex( const Vector3* position ) = 0; - virtual bool GetDamageLocatorPosition( Vector3* out, int index, bool inWorldSpace ) = 0; - virtual bool GetDamageLocatorDirection( Vector3* out, int index, bool inWorldSpace ) = 0; + virtual bool GetDamageLocatorPosition( Vector3 * out, int index, bool inWorldSpace ) = 0; + virtual bool GetDamageLocatorDirection( Vector3 * out, int index, bool inWorldSpace ) = 0; virtual void GetMissPosition( const Vector3* hit, const Vector3* source, Vector3* out ) = 0; virtual int GetGoodDamageLocatorIndex( const Vector3& position ) = 0; virtual float GetRadius() const = 0; virtual int CreateImpact( int damageLocatorIndex, const Vector3& direction, float lifeTime, float size ) = 0; - virtual bool UpdateImpact( Vector3& out, const Vector3& direction, int impactIndex ) = 0; - virtual ImpactConfiguration GetImpactConfiguration() const { return ImpactConfiguration::IMPACT_INVALID; } - virtual bool GetImpactPosition( Vector3& out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ) = 0; + virtual bool UpdateImpact( Vector3 & out, const Vector3& direction, int impactIndex ) = 0; + virtual ImpactConfiguration GetImpactConfiguration() const + { + return ImpactConfiguration::IMPACT_INVALID; + } + virtual bool GetImpactPosition( Vector3 & out, int locator, const Vector3& posPrev, const Vector3& posNow, float epsilon ) = 0; virtual bool HasImpactConfigurationShield() const = 0; - virtual void SetLastDamageLocatorHit( unsigned int locator ) {} + virtual void SetLastDamageLocatorHit( unsigned int locator ) + { + } }; diff --git a/trinity/Include/ITriTextureRes.h b/trinity/Include/ITriTextureRes.h index bb96a0a04..c5d0434f5 100644 --- a/trinity/Include/ITriTextureRes.h +++ b/trinity/Include/ITriTextureRes.h @@ -3,7 +3,7 @@ #ifndef _ITRITEXTURERES_H_ #define _ITRITEXTURERES_H_ -BLUE_INTERFACE(ITriTextureRes) : +BLUE_INTERFACE( ITriTextureRes ) : public IRoot { virtual unsigned int GetWidth() const = 0; @@ -14,11 +14,14 @@ BLUE_INTERFACE(ITriTextureRes) : virtual void SetName( const char* name ) = 0; virtual const char* GetName() const = 0; - virtual long UpdateSubresource( unsigned left, unsigned top, unsigned right, unsigned bottom, const void* source, unsigned sourcePitch ) { return -1; } - virtual void SetAverageColor( float red, float green, float blue, float alpha ) {} + virtual long UpdateSubresource( unsigned left, unsigned top, unsigned right, unsigned bottom, const void* source, unsigned sourcePitch ) + { + return -1; + } + virtual void SetAverageColor( float red, float green, float blue, float alpha ) + { + } }; #endif - - diff --git a/trinity/Include/ITriVector.h b/trinity/Include/ITriVector.h index ffe1ffda6..f2a80efdf 100644 --- a/trinity/Include/ITriVector.h +++ b/trinity/Include/ITriVector.h @@ -6,52 +6,42 @@ struct Vector3; struct Quaternion; -BLUE_INTERFACE( ITriVector ) : public IRoot +BLUE_INTERFACE( ITriVector ) : + public IRoot { // Construction and data access virtual void SetXYZ( - float x, - float y, - float z - ) = 0; + float x, + float y, + float z ) = 0; virtual void SetVector( - const Vector3* v - ) = 0; + const Vector3* v ) = 0; - virtual const Vector3* GetVector( - ) const =0; + virtual const Vector3* GetVector() const = 0; virtual Vector3* CopyVector( - Vector3* in - ) const =0; + Vector3 * in ) const = 0; - virtual Vector3* Vector( - ) = 0; + virtual Vector3* Vector() = 0; // Math functions - virtual float Length( - ) const = 0; + virtual float Length() const = 0; virtual void Scale( - float s - ) = 0; + float s ) = 0; - virtual void Normalize( - ) = 0; + virtual void Normalize() = 0; virtual void SetCrossProduct( const Vector3* v1, - const Vector3* v2 - ) = 0; + const Vector3* v2 ) = 0; virtual float DotProduct( - const Vector3* v1 - ) = 0; + const Vector3* v1 ) = 0; virtual void TransformQuaternion( - const Quaternion* in - ) = 0; + const Quaternion* in ) = 0; }; #endif \ No newline at end of file diff --git a/trinity/Include/Tr2Curve.h b/trinity/Include/Tr2Curve.h index a94febe34..0ac43378e 100644 --- a/trinity/Include/Tr2Curve.h +++ b/trinity/Include/Tr2Curve.h @@ -8,8 +8,8 @@ #include #ifdef _WIN32 -#define isnan(x) _isnan(x) -#define isinf(x) !_finite(x) +#define isnan( x ) _isnan( x ) +#define isinf( x ) !_finite( x ) #endif enum Interpolation @@ -26,18 +26,16 @@ template class Tr2Key { public: - float m_time; - T m_value; + float m_time; + T m_value; Interpolation m_interpolation; }; template -class Tr2CurveBase: - public IInitialize, - public ITriCurveLength +class Tr2CurveBase : public IInitialize, + public ITriCurveLength { public: - Tr2CurveBase( IRoot* lockobj = NULL ); ////////////////////////////////////////////////////////////////////////// @@ -46,7 +44,10 @@ class Tr2CurveBase: ////////////////////////////////////////////////////////////////////////// // ITriCurveLength - float Length() { return m_length; } + float Length() + { + return m_length; + } bool m_reversed; bool m_cycle; @@ -59,9 +60,9 @@ class Tr2CurveBase: // internal time scale float m_timeScale; - KeyValue m_startValue; - KeyValue m_currentValue; - KeyValue m_endValue; + KeyValue m_startValue; + KeyValue m_currentValue; + KeyValue m_endValue; unsigned int m_interpolation; KeyList m_keys; @@ -71,11 +72,14 @@ class Tr2CurveBase: Key* m_lastKey; Key* m_nextKey; float m_startOfSegment; - float m_endOfSegment; + float m_endOfSegment; // Value access - KeyValue GetValue( double time ) { return GetValueAt( time ); } - KeyValue GetValueAt( double time ); + KeyValue GetValue( double time ) + { + return GetValueAt( time ); + } + KeyValue GetValueAt( double time ); const KeyValue& GetKeyValue( unsigned int idx ); void SetKeyValue( unsigned int idx, const KeyValue& value ); @@ -85,7 +89,10 @@ class Tr2CurveBase: unsigned int GetKeyInterpolation( unsigned int idx ); void SetKeyInterpolation( unsigned int idx, unsigned int interp ); - unsigned int GetKeyCount() const { return (unsigned int)m_keys.size(); } + unsigned int GetKeyCount() const + { + return (unsigned int)m_keys.size(); + } // String access std::string GetName() const; @@ -94,21 +101,21 @@ class Tr2CurveBase: // Key manipulation int AddKey( float time, const KeyValue& value ); void RemoveKey( unsigned int idx ); - virtual void Sort( ) = 0; + virtual void Sort() = 0; virtual KeyValue* Interpolate( KeyValue* out, Key* startKey, Key* endKey ) = 0; + private: virtual void AddKey_( float time, const KeyValue& value ) = 0; }; template -class Tr2Curve : - public Tr2CurveBase, - public ITriFunction +class Tr2Curve : public Tr2CurveBase, + public ITriFunction { public: - Tr2Curve( IRoot* lockobj = NULL ) - :Tr2CurveBase( lockobj ) + Tr2Curve( IRoot* lockobj = NULL ) : + Tr2CurveBase( lockobj ) { } @@ -123,14 +130,14 @@ class Tr2Curve : ///////////////////////////////////////////////////////////////////////////// // IInitialize template -bool Tr2CurveBase::Initialize( ) +bool Tr2CurveBase::Initialize() { Sort(); return true; } template -Tr2CurveBase::Tr2CurveBase( ::IRoot* lockobj ): +Tr2CurveBase::Tr2CurveBase( ::IRoot* lockobj ) : PARENTLOCK2( m_keys, IInitialize ) { m_lastKey = NULL; @@ -149,7 +156,7 @@ Tr2CurveBase::Tr2CurveBase( ::IRoot* lockobj ): } template -std::string Tr2CurveBase::GetName( ) const +std::string Tr2CurveBase::GetName() const { return m_name; } @@ -164,7 +171,7 @@ template void Tr2CurveBase::RemoveKey( unsigned int idx ) { size_t numKeys = m_keys.size(); - if ( numKeys && idx < numKeys) + if( numKeys && idx < numKeys ) { m_keys.Remove( idx ); Sort(); @@ -202,9 +209,9 @@ int Tr2CurveBase::AddKey( float time, const KeyValue& va // to the new value. if( m_keys.empty() ) { - if ( time > m_length ) + if( time > m_length ) { - if ( m_length > 0.0f ) + if( m_length > 0.0f ) { // Need to create a new key here using the current endpoint value AddKey_( m_length, m_endValue ); @@ -217,11 +224,11 @@ int Tr2CurveBase::AddKey( float time, const KeyValue& va m_length = time; m_endValue = value; - // If keyIndex == -1 => + // If keyIndex == -1 => // We got a time value > 0 for a curve of zero length - // Thus, we have shifted the length to that time value + // Thus, we have shifted the length to that time value // and updated the end value accordingly. - if ( keyIndex == -1 ) + if( keyIndex == -1 ) { return keyIndex; } @@ -232,7 +239,6 @@ int Tr2CurveBase::AddKey( float time, const KeyValue& va AddKey_( time, value ); return 0; } - } else { @@ -267,7 +273,7 @@ int Tr2CurveBase::AddKey( float time, const KeyValue& va template const KeyValue& Tr2CurveBase::GetKeyValue( unsigned int idx ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { return m_keys[idx]->m_value; } @@ -277,7 +283,7 @@ const KeyValue& Tr2CurveBase::GetKeyValue( unsigned int template void Tr2CurveBase::SetKeyValue( unsigned int idx, const KeyValue& value ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { m_keys[idx]->m_value = value; } @@ -286,7 +292,7 @@ void Tr2CurveBase::SetKeyValue( unsigned int idx, const template float Tr2CurveBase::GetKeyTime( unsigned int idx ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { return m_keys[idx]->m_time; } @@ -296,7 +302,7 @@ float Tr2CurveBase::GetKeyTime( unsigned int idx ) template void Tr2CurveBase::SetKeyTime( unsigned int idx, float time ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { m_keys[idx]->m_time = time; } @@ -306,7 +312,7 @@ void Tr2CurveBase::SetKeyTime( unsigned int idx, float t template unsigned int Tr2CurveBase::GetKeyInterpolation( unsigned int idx ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { return (unsigned int)m_keys[idx]->m_interpolation; } @@ -316,7 +322,7 @@ unsigned int Tr2CurveBase::GetKeyInterpolation( unsigned template void Tr2CurveBase::SetKeyInterpolation( unsigned int idx, unsigned int interp ) { - if ( idx < m_keys.size() ) + if( idx < m_keys.size() ) { m_keys[idx]->m_interpolation = (Interpolation)interp; } @@ -334,20 +340,20 @@ KeyValue Tr2CurveBase::GetValueAt( double time ) time = time / (double)m_timeScale - (double)m_timeOffset; - if ( m_length <= 0.0f || time <= 0.0 ) + if( m_length <= 0.0f || time <= 0.0 ) { return m_startValue; } - if ( time > m_length ) + if( time > m_length ) { - if ( m_cycle ) + if( m_cycle ) { - time = fmod(time, (double)m_length); + time = fmod( time, (double)m_length ); } else { - if ( m_reversed ) + if( m_reversed ) { return m_startValue; } @@ -356,23 +362,23 @@ KeyValue Tr2CurveBase::GetValueAt( double time ) return m_endValue; } } - } + } - if ( m_reversed ) + if( m_reversed ) { time = (double)m_length - time; } m_localTime = (float)time; - if ( !m_keys.size() ) + if( !m_keys.size() ) { Interpolate( &result, NULL, NULL ); } else - { + { // If the current time is within our cached segment - if ( ( m_lastKey || m_nextKey ) && time > m_startOfSegment && time <= m_endOfSegment ) + if( ( m_lastKey || m_nextKey ) && time > m_startOfSegment && time <= m_endOfSegment ) { Interpolate( &result, m_lastKey, m_nextKey ); } @@ -380,7 +386,7 @@ KeyValue Tr2CurveBase::GetValueAt( double time ) { Key* startKey = m_keys[0]; Key* endKey = m_keys.back(); - if ( time <= startKey->m_time ) // We are between the start of the curve and the first key + if( time <= startKey->m_time ) // We are between the start of the curve and the first key { m_startOfSegment = 0.0f; m_endOfSegment = startKey->m_time; @@ -389,7 +395,7 @@ KeyValue Tr2CurveBase::GetValueAt( double time ) m_nextKey = startKey; Interpolate( &result, NULL, startKey ); } - else if ( time >= endKey->m_time ) // We are between the last key and the end of the curve + else if( time >= endKey->m_time ) // We are between the last key and the end of the curve { m_startOfSegment = endKey->m_time; m_endOfSegment = m_length; @@ -399,19 +405,19 @@ KeyValue Tr2CurveBase::GetValueAt( double time ) Interpolate( &result, endKey, NULL ); } else - { + { startKey = m_keys[m_currentKeyIdx]; // If the caching is wrong, start from the beginning - if ( startKey->m_time > time ) - { + if( startKey->m_time > time ) + { startKey = m_keys[0]; m_currentKeyIdx = 0; } endKey = m_keys[m_currentKeyIdx + 1]; - for ( size_t i = m_currentKeyIdx; i < (m_keys.size()-1); ++i ) + for( size_t i = m_currentKeyIdx; i < ( m_keys.size() - 1 ); ++i ) { - if ( startKey->m_time <= time && endKey->m_time > time ) + if( startKey->m_time <= time && endKey->m_time > time ) { break; } diff --git a/trinity/Include/Tr2WindowHandle.h b/trinity/Include/Tr2WindowHandle.h index f0514dd7e..ec4a785cd 100644 --- a/trinity/Include/Tr2WindowHandle.h +++ b/trinity/Include/Tr2WindowHandle.h @@ -8,7 +8,7 @@ typedef HWND Tr2WindowHandle; -#elif defined(__APPLE__) +#elif defined( __APPLE__ ) #include typedef id Tr2WindowHandle; diff --git a/trinity/Include/TriColor.h b/trinity/Include/TriColor.h index a58216e12..438069756 100644 --- a/trinity/Include/TriColor.h +++ b/trinity/Include/TriColor.h @@ -4,95 +4,81 @@ #define _TRICOLOR_H_ #define TRICOLOR_Description \ -"Simple mapping of Color over to Blue, with the addition of HSV \r\n\ + "Simple mapping of Color over to Blue, with the addition of HSV \r\n\ function" #include "ITriColor.h" -#pragma warning (disable: 4275) +#pragma warning( disable : 4275 ) #if BLUE_WITH_PYTHON -class TriColor : - public ITriColor, - public IPythonMethods, - public Color +class TriColor : public ITriColor, + public IPythonMethods, + public Color { public: EXPOSE_TO_BLUE(); - TriColor(IRoot* lockobj = NULL); + TriColor( IRoot* lockobj = NULL ); ~TriColor(); - + ///////////////////////////////////////////////////////////////////////////////////// // ITriColor ///////////////////////////////////////////////////////////////////////////////////// void SetRGB( - float r, - float g, + float r, + float g, float b, - float a = TRICOLOR_NOALPHA - ); + float a = TRICOLOR_NOALPHA ); void SetHSV( - float hue, - float saturation, - float value, - float alpha = TRICOLOR_NOALPHA - ); + float hue, + float saturation, + float value, + float alpha = TRICOLOR_NOALPHA ); void SetVector( const Vector3* in, - float alpha - ); + float alpha ); void GetHSV( - float* hue, - float* saturation, - float* value, - float* alpha = NULL - ); + float* hue, + float* saturation, + float* value, + float* alpha = NULL ); void SetColor( - const ::Color* c - ); + const ::Color* c ); - const ::Color* GetColor( - ) const; + const ::Color* GetColor() const; ::Color* CopyColor( - ::Color* in - ) const; + ::Color* in ) const; - ::Color* Color( - ); + ::Color* Color(); void Scale( - float s - ); - + float s ); + ///////////////////////////////////////////////////////////////////////////////////// // IPythonMethods ///////////////////////////////////////////////////////////////////////////////////// - void Destroy( - ); + void Destroy(); - PyObject* GetAttr( - const char* name, - bool* handled - ); + PyObject* GetAttr( + const char* name, + bool* handled ); bool SetAttr( const char* name, PyObject* v, - bool* handled - ); + bool* handled ); PyObject* Repr( - bool* handled - ); + bool* handled ); public: void Py__init__( float r, float g, float b, float a ); @@ -102,11 +88,10 @@ class TriColor : Vector3 PyGetHSV(); void PyFromInt( int color ); int32_t PyAsInt(); - PyObject* PyAdd( PyObject* args ); + PyObject* PyAdd( PyObject* args ); PyObject* PyLerp( PyObject* args ); }; -TYPEDEF_BLUECLASS(TriColor); +TYPEDEF_BLUECLASS( TriColor ); #endif #endif - diff --git a/trinity/Include/TriMath.h b/trinity/Include/TriMath.h index 6b45d1b7b..e33d03576 100644 --- a/trinity/Include/TriMath.h +++ b/trinity/Include/TriMath.h @@ -41,84 +41,75 @@ bool TriVectorIsIdentical( const Vector3* v1, const Vector3* v2, float epsilon = //Rotate a vector by the quaternion Vector3* TriVectorRotateQuaternion( - Vector3* out, + Vector3* out, const Vector3* v, - const Quaternion* q - ); + const Quaternion* q ); //Rotate a vector by the rotation part of a matrix (ignores translation) Vector3* TriVectorRotateMatrix( - Vector3* out, + Vector3* out, const Vector3* v, - const Matrix* m - ); + const Matrix* m ); //The next two functions are the most common application //of the previous two functions and can be optimized greatly //with our knowledge of the usage -//Rotate a unit vector aligned to one of the axes +//Rotate a unit vector aligned to one of the axes //(defined by xyz) by the quaternion Vector3* TriVectorRotatedBasisQuaternion( - Vector3* out, + Vector3* out, const TRITRANSFORMAXIS xyz, - const Quaternion* q - ); + const Quaternion* q ); -//Rotate a unit vector aligned to one of the axes +//Rotate a unit vector aligned to one of the axes //(defined by xyz) by the matrix Vector3* TriVectorRotatedBasisMatrix( - Vector3* out, + Vector3* out, const TRITRANSFORMAXIS xyz, - const Matrix* m - ); + const Matrix* m ); // -Vector3* TriVectorSpherical( - Vector3* v, +Vector3* TriVectorSpherical( + Vector3* v, float phi, float theta, - float rad - ); + float rad ); -Vector3* TriVectorExponentialDecayInteger( - Vector3* pos, +Vector3* TriVectorExponentialDecayInteger( + Vector3* pos, const Vector3* pos0, const Vector3* vel0, const Vector3* acc0, const float mass, const float drag, - float time - ); + float time ); -Vector3* TriVectorExponentialDecay( - Vector3* vel, +Vector3* TriVectorExponentialDecay( + Vector3* vel, const Vector3* vel0, const Vector3* acc0, const float mass, const float drag, - float time - ); + float time ); -Vector3* TriVectorExponentialDecayInteger( - Vector3* pos, +Vector3* TriVectorExponentialDecayInteger( + Vector3* pos, const Vector3* x, const Vector3* v, const Vector3* a, const float m, const float k, const float t, - const float pow - ); + const float pow ); -Vector3* TriVectorExponentialDecay( - Vector3* vel, +Vector3* TriVectorExponentialDecay( + Vector3* vel, const Vector3* v, const Vector3* a, const float k, - const float pow - ); + const float pow ); // Projects a point onto a plane Vector3 TriVectorProjectOnPlane( const Vector3& point, const Vector3& p0, const Vector3& n ); @@ -148,12 +139,11 @@ float TriFloatRandomGauss( float mu, float deviation ); // Color extensions ///////////////////////////////////////////////////////////////////////////////////////// -// Turns a normalized vector into a color. Used to change directions into color. -Color* TriColorFromVector( +// Turns a normalized vector into a color. Used to change directions into color. +Color* TriColorFromVector( Color* c, - const Vector3* v, - float height = 0.0f - ); + const Vector3* v, + float height = 0.0f ); ///////////////////////////////////////////////////////////////////////////////////////// @@ -171,51 +161,44 @@ Color* TriColorFromVector( // See TriQuaternionRotationArc for an example of use. Quaternion* TriQuaternionSqrt( Quaternion* out, - const Quaternion* q - ); + const Quaternion* q ); // Builds a quaternion that is the rotation between two vectors about the origin Quaternion* TriQuaternionRotationArc( - Quaternion* out, + Quaternion* out, const Vector3* v1, - const Vector3* v2 - ); + const Vector3* v2 ); Quaternion* TriQuaternionArcFromForward( - Quaternion* out, - const Vector3* v - ); + Quaternion* out, + const Vector3* v ); // does something nice, Eggert, please specify.... Quaternion* TriQuaternionAxisHeading( - Quaternion* out, + Quaternion* out, const Quaternion* q, - const Vector3* v - ); + const Vector3* v ); //Takes in a vector, and returns a pure unit quaternion with the same rotation axis as the vectors heading Quaternion* TriQuaternionDirVector( - Quaternion* out, - const Vector3* v - ); + Quaternion* out, + const Vector3* v ); //out = in*length Quaternion* TriQuaternionScale( - Quaternion* out, + Quaternion* out, const Quaternion* in, - float length - ); + float length ); //Pre: q is a unit quaternion //Post: yaw in [0;2*pi[ , pitch in [-pi/2;pi/2]; roll in [-pi; pi] // if you yaw and then pitch and then roll you get the same result as using the quaternion -void TriQuaternionToYawPitchRoll ( - float* yaw, - float* pitch, - float* roll, - const Quaternion* q - ); +void TriQuaternionToYawPitchRoll( + float* yaw, + float* pitch, + float* roll, + const Quaternion* q ); ///////////////////////////////////////////////////////////////////////////////////////// // Matrix extensions @@ -223,43 +206,41 @@ void TriQuaternionToYawPitchRoll ( // advanced matrix transpose: by knowing the size it determines if to transpose a // 4x4 or 4x3 matrix -Matrix* TriMatrixTranspose(Matrix* out, const Matrix* in, unsigned int sizeInBytes); +Matrix* TriMatrixTranspose( Matrix* out, const Matrix* in, unsigned int sizeInBytes ); //These functions are used instead of creating a translation matrix and multiplying by that //The only reason to use these is for optimization purposes //use this to translate by v and then transform by m -//this is 20 times faster than multiplying with a translation matrix -Matrix* TriMatrixTranslate(Matrix* out, const Matrix* m, const Vector3* v); +//this is 20 times faster than multiplying with a translation matrix +Matrix* TriMatrixTranslate( Matrix* out, const Matrix* m, const Vector3* v ); //use this to transform by m and then translate by v -//this is four times faster than multiplying with a translation matrix -Matrix* TriMatrixTranslate(Matrix* out, const Vector3* v, const Matrix* m); +//this is four times faster than multiplying with a translation matrix +Matrix* TriMatrixTranslate( Matrix* out, const Vector3* v, const Matrix* m ); //with these functions we can always use quaternions instead of rotation matrices //which helps comprehension //use this to rotate by q and then transform by m -Matrix* TriMatrixRotate(Matrix* out, const Matrix* m, const Quaternion* q); +Matrix* TriMatrixRotate( Matrix* out, const Matrix* m, const Quaternion* q ); //use this to transform by m and then rotate by q -Matrix* TriMatrixRotate(Matrix* out, const Quaternion* q, const Matrix* m); +Matrix* TriMatrixRotate( Matrix* out, const Quaternion* q, const Matrix* m ); -Matrix* TriMatrixChangeBase(Matrix* out, const Vector3* fwd, const Vector3* up); +Matrix* TriMatrixChangeBase( Matrix* out, const Vector3* fwd, const Vector3* up ); Matrix* TriMatrixRemoveScaling( Matrix* out, const Matrix* in ); Matrix* TriMatrixRemoveTranslation( Matrix* out, const Matrix* in ); Matrix* TriMatrixOverwriteTranslation( Matrix* out, const Matrix* in, const Vector3* t ); Matrix* TriMatrixRotationArc( - Matrix* out, - const Vector3* v1, - const Vector3* v2 - ); + Matrix* out, + const Vector3* v1, + const Vector3* v2 ); Matrix* TriMatrixArcFromForward( - Matrix* out, - const Vector3* v - ); + Matrix* out, + const Vector3* v ); ///////////////////////////////////////////////////////////////////////////////////////// @@ -289,10 +270,9 @@ float Hermite( float v1, float r, float v2, float l, float t, float dt ); float TriLinearize( float min, float max, float v ); //pre: f in [0.0 ; 1.0] -//post: returnvalue in [0.0 ; 1.0] +//post: returnvalue in [0.0 ; 1.0] float SinSmooth( - float f - ); + float f ); float CubicInterpolate( float f0, float f1, float f2, float f3, float s ); @@ -312,11 +292,11 @@ int TriRandGetSeed(); // Constants ///////////////////////////////////////////////////////////////////////////////////////// -const float TRI_PI = 3.141592654f; +const float TRI_PI = 3.141592654f; const float TRI_1BYPI = 0.318309886f; -const float TRI_2PI = 6.283185307f; +const float TRI_2PI = 6.283185307f; const float TRI_PIBY2 = 1.570796327f; -const float TRI_E = 2.718281828f;//45904523536028747135266249775724709369996 +const float TRI_E = 2.718281828f; //45904523536028747135266249775724709369996 const float TRI_SQRT2 = 1.414213562f; const float TRI_SQRT3 = 1.732050807f; diff --git a/trinity/Include/TriMatrix.h b/trinity/Include/TriMatrix.h index 8e27715dd..eb3434803 100644 --- a/trinity/Include/TriMatrix.h +++ b/trinity/Include/TriMatrix.h @@ -4,122 +4,114 @@ #define _TRIMATRIX_H_ #define TRIMATRIX_Description \ -"Simple mapping of Matrix over to Blue so that it can be used in Python" + "Simple mapping of Matrix over to Blue so that it can be used in Python" #include "ITriMatrix.h" -#pragma warning (disable: 4275) // non dll-interface struct 'Matrix' +#pragma warning( disable : 4275 ) // non dll-interface struct 'Matrix' BLUE_INTERFACE( ITriVector ); BLUE_INTERFACE( ITriQuaternion ); -class TriMatrix : - public ITriMatrix, +class TriMatrix : public ITriMatrix, #if BLUE_WITH_PYTHON - public IPythonMethods, + public IPythonMethods, #endif - public Matrix + public Matrix { public: EXPOSE_TO_BLUE(); - TriMatrix(IRoot* lockobj = NULL); + TriMatrix( IRoot* lockobj = NULL ); ~TriMatrix(); ///////////////////////////////////////////////////////////////////////////////////// // ITriMatrix ///////////////////////////////////////////////////////////////////////////////////// void SetPivots( - float _11, float _12, float _13, float _14, - float _21, float _22, float _23, float _24, - float _31, float _32, float _33, float _34, - float _41, float _42, float _43, float _44 - ); + float _11, + float _12, + float _13, + float _14, + float _21, + float _22, + float _23, + float _24, + float _31, + float _32, + float _33, + float _34, + float _41, + float _42, + float _43, + float _44 ); void SetMatrix( - const Matrix* m - ); + const Matrix* m ); - const Matrix* GetMatrix( - ) const; + const Matrix* GetMatrix() const; Matrix* CopyMatrix( - Matrix* in - ) const; + Matrix* in ) const; ///////////////////////////////////////////////////////////////////////////////////// // IMatrix ///////////////////////////////////////////////////////////////////////////////////// - float Determinant( - ); + float Determinant(); - void Identity( - ); + void Identity(); - float Inverse( - ); + float Inverse(); - void LookAtRH( + void LookAtRH( const Vector3* pEye, const Vector3* pAt, - const Vector3* pUp - ); + const Vector3* pUp ); - void Multiply( - const Matrix* pM2 - ); + void Multiply( + const Matrix* pM2 ); - void RotationAxis( + void RotationAxis( const Vector3* pV, - float Angle - ); + float Angle ); - void RotationQuaternion( - const Quaternion* pQ - ); + void RotationQuaternion( + const Quaternion* pQ ); - void RotationX( - float Angle - ); + void RotationX( + float Angle ); void RotationY( - float Angle - ); - + float Angle ); + void RotationYawPitchRoll( float Yaw, float Pitch, - float Roll - ); + float Roll ); void RotationZ( - float Angle - ); + float Angle ); - void Scaling( + void Scaling( float sx, float sy, - float sz - ); + float sz ); - void Transformation( + void Transformation( const Vector3* pScalingCenter, const Quaternion* pScalingRotation, const Vector3* pScaling, const Vector3* pRotationCenter, const Quaternion* pRotation, - const Vector3* pTranslation - ); + const Vector3* pTranslation ); - void Translation( + void Translation( float x, float y, - float z - ); + float z ); - void Transpose( - ); + void Transpose(); @@ -127,23 +119,19 @@ class TriMatrix : ///////////////////////////////////////////////////////////////////////////////////// // IPythonMethods ///////////////////////////////////////////////////////////////////////////////////// - void Destroy( - ); + void Destroy(); - PyObject* GetAttr( - const char* name, - bool* handled - ); + PyObject* GetAttr( + const char* name, + bool* handled ); bool SetAttr( const char* name, PyObject* v, - bool* handled - ); + bool* handled ); PyObject* Repr( - bool* handled - ); + bool* handled ); #endif public: @@ -154,7 +142,7 @@ class TriMatrix : void PyMultiply( ITriMatrix* other ); void PyRotationAxis( ITriVector* axis, float angle ); void PyRotationQuaternion( ITriQuaternion* quaternion ); - void PyTransformation( + void PyTransformation( ITriVector* scalingCenter, ITriQuaternion* scalingRotation, ITriVector* scaling, @@ -162,7 +150,6 @@ class TriMatrix : ITriQuaternion* rotation, ITriVector* translation ); }; -TYPEDEF_BLUECLASS(TriMatrix); +TYPEDEF_BLUECLASS( TriMatrix ); #endif - diff --git a/trinity/Include/TriQuaternion.h b/trinity/Include/TriQuaternion.h index 021e717b1..6ece9741c 100644 --- a/trinity/Include/TriQuaternion.h +++ b/trinity/Include/TriQuaternion.h @@ -4,103 +4,87 @@ #define _TRIQUATERNION_H_ #define TRIQUATERNION_Description \ -"Simple mapping of Quaternion over to Blue." + "Simple mapping of Quaternion over to Blue." #include "ITriQuaternion.h" -#pragma warning (disable: 4275) +#pragma warning( disable : 4275 ) BLUE_DECLARE( TriQuaternion ); BLUE_DECLARE_INTERFACE( ITriVector ); BLUE_DECLARE_INTERFACE( ITriMatrix ); #if BLUE_WITH_PYTHON -class TriQuaternion : - public ITriQuaternion, - public IPythonMethods, - public Quaternion +class TriQuaternion : public ITriQuaternion, + public IPythonMethods, + public Quaternion { -public: +public: EXPOSE_TO_BLUE(); - - TriQuaternion(IRoot* lockobj = NULL); + + TriQuaternion( IRoot* lockobj = NULL ); ~TriQuaternion(); ///////////////////////////////////////////////////////////////////////////////////// // ITriQuaternion ///////////////////////////////////////////////////////////////////////////////////// void SetXYZW( - float x, - float y, + float x, + float y, float z, - float w - ); + float w ); void SetQuaternion( - const ::Quaternion* ar - ); + const ::Quaternion* ar ); - const ::Quaternion* GetQuaternion( - ) const; + const ::Quaternion* GetQuaternion() const; ::Quaternion* CopyQuaternion( - ::Quaternion* in - ) const; + ::Quaternion* in ) const; - ::Quaternion* Quaternion( - ); + ::Quaternion* Quaternion(); - void SetIdentity( - ); + void SetIdentity(); void SetRotationAxis( - const Vector3* axis, - float angle - ); + const Vector3* axis, + float angle ); void GetRotationAxis( - Vector3* axis, - float* angle - ) const; - + Vector3* axis, + float* angle ) const; + void SetYawPitchRoll( - float yaw, - float pitch, - float roll - ); + float yaw, + float pitch, + float roll ); void GetYawPitchRoll( - float* yaw, - float* pitch, - float* roll - ) const; + float* yaw, + float* pitch, + float* roll ) const; void IncreaseYawPitchRoll( - float yaw, - float pitch, - float roll - ); + float yaw, + float pitch, + float roll ); void IncreaseLocalYawPitchRoll( - float yaw, - float pitch, - float roll - ); + float yaw, + float pitch, + float roll ); void SetRotationArc( const Vector3* v0, - const Vector3* v1 - ); + const Vector3* v1 ); void MultiplyQuaternion( - const ::Quaternion* in - ); + const ::Quaternion* in ); void SetSLERP( const ::Quaternion* q1, const ::Quaternion* q2, - const float t - ); + const float t ); void Normalize(); @@ -109,23 +93,19 @@ class TriQuaternion : ///////////////////////////////////////////////////////////////////////////////////// // IPythonMethods ///////////////////////////////////////////////////////////////////////////////////// - void Destroy( - ); + void Destroy(); - PyObject* GetAttr( - const char* name, - bool* handled - ); + PyObject* GetAttr( + const char* name, + bool* handled ); bool SetAttr( const char* name, PyObject* v, - bool* handled - ); + bool* handled ); PyObject* Repr( - bool* handled - ); + bool* handled ); public: @@ -138,10 +118,10 @@ class TriQuaternion : void PyRotationAxis( ITriVector* axis, float angle ); void PySetRotationAxis( ITriVector* axis, float angle ); - Vector3 PyGetYawPitchRoll(); + Vector3 PyGetYawPitchRoll(); void PyScale( float factor ); }; -TYPEDEF_BLUECLASS(TriQuaternion); +TYPEDEF_BLUECLASS( TriQuaternion ); #endif #endif \ No newline at end of file diff --git a/trinity/Include/TriVector.h b/trinity/Include/TriVector.h index 51a4054cb..a50810adb 100644 --- a/trinity/Include/TriVector.h +++ b/trinity/Include/TriVector.h @@ -5,7 +5,7 @@ #include "ITriVector.h" -#pragma warning (disable: 4275) // non dll-interface struct 'Vector3' +#pragma warning( disable : 4275 ) // non dll-interface struct 'Vector3' BLUE_DECLARE( TriVector ); BLUE_DECLARE( TriViewport ); @@ -20,134 +20,114 @@ BLUE_CLASS( TriVector ) : #endif public Vector3 { -public: +public: EXPOSE_TO_BLUE(); using ITriVector::Unlock; - TriVector(IRoot* lockobj = NULL); + TriVector( IRoot* lockobj = NULL ); ~TriVector(); ///////////////////////////////////////////////////////////////////////////////////// // ITriVector ///////////////////////////////////////////////////////////////////////////////////// void SetXYZ( - float x, - float y, - float z - ); + float x, + float y, + float z ); void SetVector( - const Vector3* ar - ); + const Vector3* ar ); + + const Vector3* GetVector() const; - const Vector3* GetVector( - ) const; - Vector3* CopyVector( - Vector3* in - ) const; + Vector3 * in ) const; - Vector3* Vector( - ); + Vector3* Vector(); - float Length( - ) const; + float Length() const; - float LengthSq( - ) const; + float LengthSq() const; void Scale( - float s - ); + float s ); - void Normalize( - ); + void Normalize(); void TransformQuaternion( - const Quaternion* in - ); - + const Quaternion* in ); + void SetCrossProduct( const Vector3* v1, - const Vector3* v2 - ); + const Vector3* v2 ); float DotProduct( - const Vector3* v2 - ); + const Vector3* v2 ); #if BLUE_WITH_PYTHON ///////////////////////////////////////////////////////////////////////////////////// // IPythonMethods ///////////////////////////////////////////////////////////////////////////////////// - void Destroy( - ); + void Destroy(); - PyObject* GetAttr( - const char* name, - bool* handled - ); + PyObject* GetAttr( + const char* name, + bool* handled ); bool SetAttr( const char* name, PyObject* v, - bool* handled - ); + bool* handled ); PyObject* Repr( - bool* handled - ); + bool* handled ); ///////////////////////////////////////////////////////////////////////////////////// // IPythonNumeric ///////////////////////////////////////////////////////////////////////////////////// bool BinaryOp( PYNUMERIC_OPS op, - IRoot* other, - PyObject** retval - ); + IRoot * other, + PyObject * *retval ); bool UnaryOp( PYNUMERIC_OPS op, - PyObject** retval - ); + PyObject * *retval ); void Coercion( - PyObject* from, - PyObject** to - ); + PyObject * from, + PyObject * *to ); #endif public: - void PyAdd( ITriVector* other ); - void PyCross( ITriVector* other ); - float PyDot( ITriVector* other ); - void PyLerp( ITriVector* other, float t ); - void PyMaximize( ITriVector* other ); - void PyMinimize( ITriVector* other ); + void PyAdd( ITriVector * other ); + void PyCross( ITriVector * other ); + float PyDot( ITriVector * other ); + void PyLerp( ITriVector * other, float t ); + void PyMaximize( ITriVector * other ); + void PyMinimize( ITriVector * other ); void PyProject( - TriViewport* vp, - ITriMatrix* project, - ITriMatrix* view, - ITriMatrix* world ); - void PySubtract( ITriVector* other ); - void PyTransformCoord( ITriMatrix* transform ); - void PyTransformNormal( ITriMatrix* transform ); + TriViewport * vp, + ITriMatrix * project, + ITriMatrix * view, + ITriMatrix * world ); + void PySubtract( ITriVector * other ); + void PyTransformCoord( ITriMatrix * transform ); + void PyTransformNormal( ITriMatrix * transform ); void PyUnproject( - TriViewport* vp, - ITriMatrix* project, - ITriMatrix* view, - ITriMatrix* world ); - void PyTransformQuaternion( ITriQuaternion* rotation ); - void PySetCrossProduct( ITriVector* v1, ITriVector* v2 ); - float PyDotProduct( ITriVector* other ); - + TriViewport * vp, + ITriMatrix * project, + ITriMatrix * view, + ITriMatrix * world ); + void PyTransformQuaternion( ITriQuaternion * rotation ); + void PySetCrossProduct( ITriVector * v1, ITriVector * v2 ); + float PyDotProduct( ITriVector * other ); }; -void GetNearestPointOnAABB(Vector3 &out, const Vector3 &p, const Vector3 &min, const Vector3 &max); +void GetNearestPointOnAABB( Vector3& out, const Vector3& p, const Vector3& min, const Vector3& max ); -TYPEDEF_BLUECLASS(TriVector); +TYPEDEF_BLUECLASS( TriVector ); #endif \ No newline at end of file diff --git a/trinity/Interior/Tr2IntSkinnedObject.cpp b/trinity/Interior/Tr2IntSkinnedObject.cpp index d8c51c929..319551702 100644 --- a/trinity/Interior/Tr2IntSkinnedObject.cpp +++ b/trinity/Interior/Tr2IntSkinnedObject.cpp @@ -60,7 +60,7 @@ bool Tr2IntSkinnedObject::OnModified( Be::Var* value ) { return true; } - + m_lod.OnModified( value ); return true; } @@ -83,7 +83,7 @@ void Tr2IntSkinnedObject::PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexSc // -------------------------------------------------------------------------------------- // Description: -// Adds per-cell reflection map to an array of current reflection maps. +// Adds per-cell reflection map to an array of current reflection maps. // Arguments: // texture - Per-cell reflection map // -------------------------------------------------------------------------------------- @@ -117,7 +117,7 @@ void Tr2IntSkinnedObject::AddReflectionMap( TriTextureRes* texture ) // -------------------------------------------------------------------------------------- // Description: -// Removes per-cell reflection map from an array of current reflection maps. +// Removes per-cell reflection map from an array of current reflection maps. // Arguments: // texture - Per-cell reflection map // -------------------------------------------------------------------------------------- @@ -182,9 +182,9 @@ Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectData( ITriRenderBatchAccumula extern int g_maxClothLod; void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches, - TriBatchType batchType, - const Tr2PerObjectData* perObjectData, - Tr2RenderReason reason) + TriBatchType batchType, + const Tr2PerObjectData* perObjectData, + Tr2RenderReason reason ) { if( !DoDisplay() ) { @@ -203,7 +203,7 @@ void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches, center -= Tr2Renderer::GetViewPosition(); float z = std::min( std::max( ( Length( center ) + m_depthOffset ) / maxDepth, 0.f ), 1.f ); - depth = ( unsigned int )( ( float )0xFFFFFFF * ( 1.0f - z ) ); + depth = (unsigned int)( (float)0xFFFFFFF * ( 1.0f - z ) ); } Matrix* pm = batches->Allocate(); @@ -303,7 +303,7 @@ void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches, // -------------------------------------------------------------------------------------- // Description: -// Utility function for populating per-object data with a skinning matrix palette for +// Utility function for populating per-object data with a skinning matrix palette for // GPU-skinning. This uses instanced lighting. // Arguments: // accumulator - The accumulator used to allocate the per-object data @@ -312,7 +312,7 @@ void Tr2IntSkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches, // Return Value: // The allocated per-object data, or NULL if the allocation failed. // -------------------------------------------------------------------------------------- -Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataGpuSkinning( +Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataGpuSkinning( ITriRenderBatchAccumulator* accumulator, Tr2InteriorLightSet* lightSet, const Matrix& objectToWorldMatrix ) @@ -324,7 +324,7 @@ Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataGpuSkinning( if( !data ) { CCP_ASSERT( !"Not enough memory for skinning!" ); - return NULL; // should not happen (allocator out of memory??) but if it does, let's not crash. + return NULL; // should not happen (allocator out of memory??) but if it does, let's not crash. } data->SetSkinningMatrices( m_skinningMatrixCount, GetSkinningMatrices() ); @@ -372,19 +372,19 @@ void Tr2IntSkinnedObject::RemoveFromScene( void ) // -------------------------------------------------------------------------------------- // Description: -// Gets per-object data for the skinned object using a per-instance light-set override -// and an arbitrary object-to-world matrix. +// Gets per-object data for the skinned object using a per-instance light-set override +// and an arbitrary object-to-world matrix. // See Also: // GetPerObjectData, GetPerObjectDataGpuSkinning // Arguments: // accumulator - The batch accumulator used to allocate memory for per-object data // lightSet - The set of lights illuminating this object -// objectToWorldMatrix - The transformation matrix used to position this object +// objectToWorldMatrix - The transformation matrix used to position this object // in world coordinates // Return Value: // The allocated per-object data, or NULL if the memory allocation failed. // -------------------------------------------------------------------------------------- -Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataWithPerInstanceLighting( +Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataWithPerInstanceLighting( ITriRenderBatchAccumulator* accumulator, Tr2InteriorLightSet* lightSet, const Matrix& objectToWorldMatrix ) @@ -397,7 +397,7 @@ Tr2PerObjectData* Tr2IntSkinnedObject::GetPerObjectDataWithPerInstanceLighting( } // ------------------------------------------------------------------------------------------------------ -void Tr2IntSkinnedObject::SetPosition( const Vector3 &pos ) +void Tr2IntSkinnedObject::SetPosition( const Vector3& pos ) { if( ( m_currentPosition != pos ) || !m_positionSet ) { @@ -418,9 +418,9 @@ void Tr2IntSkinnedObject::SetRotation( const Quaternion& rotQuat ) m_currentRotation = rotQuat; m_rotationSet = true; - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( tmpScale, rotQuat, tmpTranslation ); @@ -435,9 +435,9 @@ void Tr2IntSkinnedObject::SetScaling( const Vector3& scaleVec ) m_currentScaling = scaleVec; m_scalingSet = true; - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( scaleVec, tmpRotation, tmpTranslation ); @@ -455,22 +455,22 @@ void Tr2IntSkinnedObject::SetLOD( const TriFrustum* frustum ) // ----------------------------------------------------------------------------------------------------- void Tr2IntSkinnedObject::UpdatePlacement( const Vector3& front, const Vector3& top, const Vector3& pos ) { - // Terrible workaround since the UpdatePlacement takes in a position and a front vector. + // Terrible workaround since the UpdatePlacement takes in a position and a front vector. // We have to work out way back to a quaternion - Vector3 temp = Vector3(front); - if (temp.z >= 1.0f) + Vector3 temp = Vector3( front ); + if( temp.z >= 1.0f ) { temp.z = 1.0f; } - else if (temp.z <= -1.0f) + else if( temp.z <= -1.0f ) { temp.z = -1.0f; } - float yaw = acosf(temp.z); - // This is actually two answers, we need to determine which side of the axis we're on. + float yaw = acosf( temp.z ); + // This is actually two answers, we need to determine which side of the axis we're on. // Correct for the other half of the circle - if (temp.x < 0.0f) + if( temp.x < 0.0f ) { yaw = ( 2 * 3.14159265f ) - yaw; } @@ -479,11 +479,11 @@ void Tr2IntSkinnedObject::UpdatePlacement( const Vector3& front, const Vector3& yaw += 3.14159265f; Quaternion q; - Vector3 up = Vector3(0, 1, 0); + Vector3 up = Vector3( 0, 1, 0 ); q = RotationQuaternion( yaw, 0, 0 ); - SetRotation(q); - SetPosition(pos); + SetRotation( q ); + SetPosition( pos ); } #include "TriFrustum.h" diff --git a/trinity/Interior/Tr2IntSkinnedObject.h b/trinity/Interior/Tr2IntSkinnedObject.h index 3980bbc7a..8cf33afdf 100644 --- a/trinity/Interior/Tr2IntSkinnedObject.h +++ b/trinity/Interior/Tr2IntSkinnedObject.h @@ -22,45 +22,43 @@ BLUE_DECLARE( Tr2IntSkinnedObject ); BLUE_DECLARE_VECTOR( Tr2IntSkinnedObject ); BLUE_DECLARE( Tr2ApexScene ); -class Tr2IntSkinnedObject : - public ITr2InteriorDynamic, - public IInitialize, - public Tr2SkinnedObject, - public ITr2Pickable, - public IBluePlacementObserver, - public ITr2BoundingBox +class Tr2IntSkinnedObject : public ITr2InteriorDynamic, + public IInitialize, + public Tr2SkinnedObject, + public ITr2Pickable, + public IBluePlacementObserver, + public ITr2BoundingBox { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using IInitialize::Lock; using IInitialize::Unlock; - Tr2IntSkinnedObject(IRoot* lockobj = NULL); - ~Tr2IntSkinnedObject(); + Tr2IntSkinnedObject( IRoot* lockobj = NULL ); + ~Tr2IntSkinnedObject(); // Update functions for Tr2SkinnedObject (implements the ITr2InteriorDynamic interface) // virtual void PrePhysicsUpdate( Be::Time time ); virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene ); - ////////////////////////////////////////////////////////////////////////// - // ITr2InteriorCullable + ////////////////////////////////////////////////////////////////////////// + // ITr2InteriorCullable virtual bool IsInFrustum( const TriFrustum& frustum, Matrix& objectToWorld ) const; - ////////////////////////////////////////////////////////////////////////// - // ITr2InteriorDynamic + ////////////////////////////////////////////////////////////////////////// + // ITr2InteriorDynamic virtual bool AddToScene( Tr2ApexScene* apexScene ); virtual void RemoveFromScene( void ); // Per-object data with instanced lighting - virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( + virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( ITriRenderBatchAccumulator* accumulator, Tr2InteriorLightSet* lightSet, - const Matrix& objectToWorldMatrix - ); + const Matrix& objectToWorldMatrix ); - virtual void SetPosition(const Vector3 &pos); + virtual void SetPosition( const Vector3& pos ); virtual void SetRotation( const Quaternion& rotQuat ); virtual void SetScaling( const Vector3& scaleVec ); @@ -75,22 +73,25 @@ class Tr2IntSkinnedObject : ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); ////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ////////////////////////////////////////////////////////////////////////// // ITr2InteriorDynamic - + virtual void SetLOD( const TriFrustum* frustum ); // sizes virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const; virtual bool IsBoundingBoxReady( void ) const; - + // Apex void AddToApexScene( Tr2ApexScene* apexScene ); void RemoveFromApexScene( void ); @@ -102,6 +103,7 @@ class Tr2IntSkinnedObject : protected: void AddReflectionMap( TriTextureRes* texture ); void RemoveReflectionMap( TriTextureRes* texture ); + protected: friend class WodAvatar2Builder; @@ -121,9 +123,9 @@ class Tr2IntSkinnedObject : // Apex bool m_isInApexScene; - Tr2PerObjectData* GetPerObjectDataGpuSkinning( + Tr2PerObjectData* GetPerObjectDataGpuSkinning( ITriRenderBatchAccumulator* accumulator, - Tr2InteriorLightSet* lightSet, + Tr2InteriorLightSet* lightSet, const Matrix& objectToWorldMatrix ); // Per-cell reflection maps diff --git a/trinity/Interior/Tr2IntSkinnedObject_Blue.cpp b/trinity/Interior/Tr2IntSkinnedObject_Blue.cpp index 40cddd588..d24fadee1 100644 --- a/trinity/Interior/Tr2IntSkinnedObject_Blue.cpp +++ b/trinity/Interior/Tr2IntSkinnedObject_Blue.cpp @@ -8,8 +8,8 @@ BLUE_DEFINE( Tr2IntSkinnedObject ); const Be::ClassInfo* Tr2IntSkinnedObject::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2IntSkinnedObject, "" ) - MAP_INTERFACE( Tr2IntSkinnedObject ) + EXPOSURE_BEGIN( Tr2IntSkinnedObject, "" ) + MAP_INTERFACE( Tr2IntSkinnedObject ) MAP_INTERFACE( ITr2InteriorDynamic ) MAP_INTERFACE( ITr2Interior ) MAP_INTERFACE( IInitialize ) @@ -30,4 +30,3 @@ const Be::ClassInfo* Tr2IntSkinnedObject::ExposeToBlue() MAP_ATTRIBUTE( "depthOffset", m_depthOffset, "Depth offset for transparency sorting", Be::READWRITE | Be::PERSIST ) EXPOSURE_CHAINTO( Tr2SkinnedObject ) } - diff --git a/trinity/Interior/Tr2InteriorConstantBufferFormats.h b/trinity/Interior/Tr2InteriorConstantBufferFormats.h index 720eda6f3..79de5745f 100644 --- a/trinity/Interior/Tr2InteriorConstantBufferFormats.h +++ b/trinity/Interior/Tr2InteriorConstantBufferFormats.h @@ -9,7 +9,7 @@ #include "Tr2ConstantBufferFormats.h" // maximum number of pointlights per object -#define MAX_INTERIOR_LIGHTS_PER_OBJECT (10) +#define MAX_INTERIOR_LIGHTS_PER_OBJECT ( 10 ) // interior pointlight data struct Tr2InteriorPerObjectLightData @@ -64,7 +64,7 @@ struct Tr2InteriorPerLightPSData Vector4 shadowRect[6]; Vector4 shadowInfluence[6]; Matrix boundingBox; - Vector4 additionalParameters; // x - specular intensity, yzw - unused + Vector4 additionalParameters; // x - specular intensity, yzw - unused }; struct Tr2PerObjectParticleVSData diff --git a/trinity/Interior/Tr2InteriorLightSet.cpp b/trinity/Interior/Tr2InteriorLightSet.cpp index ad5e54482..8818a6d3d 100644 --- a/trinity/Interior/Tr2InteriorLightSet.cpp +++ b/trinity/Interior/Tr2InteriorLightSet.cpp @@ -30,12 +30,11 @@ Tr2InteriorLightSet::~Tr2InteriorLightSet() // lightSource - The light source to add // viewPosition - The view position, used to determine view importance // -------------------------------------------------------------------------------------- -void Tr2InteriorLightSet::AddLight( ITr2InteriorLight* lightSource, - const Vector3& viewPosition ) +void Tr2InteriorLightSet::AddLight( ITr2InteriorLight* lightSource, + const Vector3& viewPosition ) { // Setup the light instance - InternalLightInstance instance = - { + InternalLightInstance instance = { lightSource, false }; @@ -66,11 +65,11 @@ void Tr2InteriorLightSet::PopulateLightData( Tr2InteriorPerObjectPSData* perObje // set each pointlight data in target array unsigned int i = 0; std::list::const_iterator it = m_lightInstances.begin(); - while( (i < MAX_INTERIOR_LIGHTS_PER_OBJECT) && (it != m_lightInstances.end()) ) + while( ( i < MAX_INTERIOR_LIGHTS_PER_OBJECT ) && ( it != m_lightInstances.end() ) ) { - if (i < 4) + if( i < 4 ) { - perObjectPSData->spotLights[i] = dynamic_cast(it->lightSource)->m_viewProjection; + perObjectPSData->spotLights[i] = dynamic_cast( it->lightSource )->m_viewProjection; } // Put standard lightsource data in target @@ -86,4 +85,3 @@ void Tr2InteriorLightSet::PopulateLightData( Tr2InteriorPerObjectPSData* perObje ++it; } } - diff --git a/trinity/Interior/Tr2InteriorLightSet.h b/trinity/Interior/Tr2InteriorLightSet.h index 29977c896..9208e3bc3 100644 --- a/trinity/Interior/Tr2InteriorLightSet.h +++ b/trinity/Interior/Tr2InteriorLightSet.h @@ -11,8 +11,8 @@ struct Tr2InteriorPerObjectPSData; //--------------------------------------------------------------------------------------- // Description: -// Tr2InteriorLightSet is a collection of ITr2InteriorLights accumulated during -// scene traversal. It can handle ordinary lights as well as light instances. +// Tr2InteriorLightSet is a collection of ITr2InteriorLights accumulated during +// scene traversal. It can handle ordinary lights as well as light instances. // See Also: // Tr2InteriorScene, ITr2InteriorLight //--------------------------------------------------------------------------------------- @@ -30,7 +30,10 @@ class Tr2InteriorLightSet void Clear( void ); // How many light instances are in this set? - unsigned int GetNumOfActiveLights( void ) const { return (unsigned int)m_lightInstances.size(); } + unsigned int GetNumOfActiveLights( void ) const + { + return (unsigned int)m_lightInstances.size(); + } // Populate constant buffer void PopulateLightData( Tr2InteriorPerObjectPSData* perObjectPSData ); diff --git a/trinity/Interior/Tr2InteriorLightSource.cpp b/trinity/Interior/Tr2InteriorLightSource.cpp index 48e3e271c..022837a16 100644 --- a/trinity/Interior/Tr2InteriorLightSource.cpp +++ b/trinity/Interior/Tr2InteriorLightSource.cpp @@ -64,10 +64,10 @@ bool Tr2InteriorLightSource::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Inherited from INotify interface. Allows the light source to respond to parameter -// changes generated in Python. If the light position changes, the regions of influence -// are updated with the new transform matrix & the light is flagged as 'dirty', forcing -// a new round of light-cell intersection tests on the next scene Update. The light is +// Inherited from INotify interface. Allows the light source to respond to parameter +// changes generated in Python. If the light position changes, the regions of influence +// are updated with the new transform matrix & the light is flagged as 'dirty', forcing +// a new round of light-cell intersection tests on the next scene Update. The light is // flagged as dirty. // Arguments: // value - The Blue-exposed parameter that changed @@ -81,7 +81,7 @@ bool Tr2InteriorLightSource::OnModified( Be::Var* value ) { m_worldBoundingBox = AxisAlignedBoundingBox( m_position - Vector3( m_radius, m_radius, m_radius ), m_position + Vector3( m_radius, m_radius, m_radius ) ); } - else if( IsMatch( value, m_radius ) || + else if( IsMatch( value, m_radius ) || IsMatch( value, m_coneAlphaOuter ) || IsMatch( value, m_coneDirection ) ) { @@ -118,7 +118,7 @@ void Tr2InteriorLightSource::PopulateLightData( Tr2InteriorPerObjectLightData* l lightData->shadow0Influence = 0.f; lightData->shadow1Influence = 0.f; - // Spot light values (always populate them, they are basicly pointlights with + // Spot light values (always populate them, they are basicly pointlights with // some non-default values...). First apply some limits float innerAngle = m_coneAlphaInner; float outerAngle = m_coneAlphaOuter; @@ -161,25 +161,25 @@ bool Tr2InteriorLightSource::IsInFrustum( const TriFrustum& frustum, Matrix& obj return frustum.IsBoxVisible( m_worldBoundingBox.m_min, m_worldBoundingBox.m_max ); } -void Tr2InteriorLightSource::GetDebugOptions(Tr2DebugRendererOptions & options) +void Tr2InteriorLightSource::GetDebugOptions( Tr2DebugRendererOptions& options ) { - options.insert("Lights"); + options.insert( "Lights" ); } -void Tr2InteriorLightSource::RenderDebugInfo( ITr2DebugRenderer2& renderer) +void Tr2InteriorLightSource::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if (renderer.HasOption(GetRawRoot(), "Lights")) + if( renderer.HasOption( GetRawRoot(), "Lights" ) ) { - renderer.DrawSphere(this, m_position, 0.05f, 10, Tr2DebugRenderer::Wireframe, 0xff333333); - if (IsSpotLight()) + renderer.DrawSphere( this, m_position, 0.05f, 10, Tr2DebugRenderer::Wireframe, 0xff333333 ); + if( IsSpotLight() ) { - float coneRadius = m_radius * tanf(XMConvertToRadians(m_coneAlphaOuter)); - Vector3 focal = m_position + Normalize(m_coneDirection) * m_radius; - renderer.DrawCone(this, focal, m_position, coneRadius, 8, Tr2DebugRenderer::Wireframe, 0xff444444); + float coneRadius = m_radius * tanf( XMConvertToRadians( m_coneAlphaOuter ) ); + Vector3 focal = m_position + Normalize( m_coneDirection ) * m_radius; + renderer.DrawCone( this, focal, m_position, coneRadius, 8, Tr2DebugRenderer::Wireframe, 0xff444444 ); } else { - renderer.DrawSphere(this, m_position, m_radius, 12, Tr2DebugRenderer::Wireframe, 0xff444444); + renderer.DrawSphere( this, m_position, m_radius, 12, Tr2DebugRenderer::Wireframe, 0xff444444 ); } } } diff --git a/trinity/Interior/Tr2InteriorLightSource.h b/trinity/Interior/Tr2InteriorLightSource.h index 102f82ff1..05ffd3808 100644 --- a/trinity/Interior/Tr2InteriorLightSource.h +++ b/trinity/Interior/Tr2InteriorLightSource.h @@ -19,17 +19,16 @@ class ITriRenderBatchAccumulator; // -------------------------------------------------------------------------------------- // Description: -// Tr2InteriorLightSource represents an interior light, which can behave as either a -// point or spot light, depending on parameters. Lights are managed at the +// Tr2InteriorLightSource represents an interior light, which can behave as either a +// point or spot light, depending on parameters. Lights are managed at the // Tr2InteriorScene level. // See Also: // Tr2InteriorScene, Tr2InteriorLightSet // -------------------------------------------------------------------------------------- -class Tr2InteriorLightSource : - public INotify, - public IInitialize, - public ITr2InteriorLight, - public ITr2DebugRenderable +class Tr2InteriorLightSource : public INotify, + public IInitialize, + public ITr2InteriorLight, + public ITr2DebugRenderable { public: // Constructor @@ -39,17 +38,17 @@ class Tr2InteriorLightSource : EXPOSE_TO_BLUE(); - using IInitialize::Lock; - using IInitialize::Unlock; + using IInitialize::Lock; + using IInitialize::Unlock; // Initialization callback - bool Initialize(); + bool Initialize(); // Value-modified callback bool OnModified( Be::Var* val ); - ////////////////////////////////////////////////////////////////////////// - // ITr2InteriorCullable + ////////////////////////////////////////////////////////////////////////// + // ITr2InteriorCullable virtual bool IsInFrustum( const TriFrustum& frustum, Matrix& objectToWorld ) const; ///////////////////////////////////////////////////////////// @@ -67,10 +66,10 @@ class Tr2InteriorLightSource : // Light position Vector3 m_position; - + // Spotlight direction Vector3 m_coneDirection; - + // Outer spotlight angle float m_coneAlphaOuter; @@ -85,9 +84,12 @@ class Tr2InteriorLightSource : protected: // Is this a spotlight? - bool IsSpotLight() const { return ( m_coneAlphaOuter < 89.f ); } -protected: + bool IsSpotLight() const + { + return ( m_coneAlphaOuter < 89.f ); + } +protected: // Light names std::string m_name; diff --git a/trinity/Interior/Tr2InteriorLightSource_Blue.cpp b/trinity/Interior/Tr2InteriorLightSource_Blue.cpp index af7e7dd31..3fe43ce4a 100644 --- a/trinity/Interior/Tr2InteriorLightSource_Blue.cpp +++ b/trinity/Interior/Tr2InteriorLightSource_Blue.cpp @@ -10,9 +10,9 @@ BLUE_DEFINE( Tr2InteriorLightSource ); const Be::ClassInfo* Tr2InteriorLightSource::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2InteriorLightSource, "" ) - MAP_INTERFACE( Tr2InteriorLightSource ) - MAP_INTERFACE( IInitialize ) + EXPOSURE_BEGIN( Tr2InteriorLightSource, "" ) + MAP_INTERFACE( Tr2InteriorLightSource ) + MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) MAP_INTERFACE( ITr2InteriorLight ) @@ -31,8 +31,7 @@ const Be::ClassInfo* Tr2InteriorLightSource::ExposeToBlue() MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets to animate light attributes", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "IsSpotLight", IsSpotLight, "Returns true if the light is a spot light (cone angle < 90 degrees) ") + MAP_METHOD_AND_WRAP( "IsSpotLight", IsSpotLight, "Returns true if the light is a spot light (cone angle < 90 degrees) " ) EXPOSURE_END() } - diff --git a/trinity/Interior/Tr2InteriorPlaceable.cpp b/trinity/Interior/Tr2InteriorPlaceable.cpp index 473115c37..195c91d67 100644 --- a/trinity/Interior/Tr2InteriorPlaceable.cpp +++ b/trinity/Interior/Tr2InteriorPlaceable.cpp @@ -22,7 +22,7 @@ CCP_STATS_DECLARE( wodInteriorPlaceablesAlive, "Trinity/Tr2InteriorPlaceables", false, CST_COUNTER_LOW, "Count of Tr2InteriorPlaceables alive" ); Tr2InteriorPlaceable::Tr2InteriorPlaceable( IRoot* lockobj ) : - m_display( true ), + m_display( true ), m_isUniqueInstance( false ), PARENTLOCK( m_transform, IInitialize ), m_placeableResPath(), @@ -61,7 +61,7 @@ Tr2InteriorPlaceable::~Tr2InteriorPlaceable() CCP_STATS_DEC( wodInteriorPlaceablesAlive ); } -bool Tr2InteriorPlaceable::AddToScene( Tr2ApexScene *apexScene ) +bool Tr2InteriorPlaceable::AddToScene( Tr2ApexScene* apexScene ) { if( !IsBoundingBoxReady() ) { @@ -137,14 +137,14 @@ bool Tr2InteriorPlaceable::GetWorldBoundingBox( Vector3& min, Vector3& max ) con bool Tr2InteriorPlaceable::IsBoundingBoxReady( void ) const { - return( m_placeableRes && m_placeableRes->IsReady() ); + return ( m_placeableRes && m_placeableRes->IsReady() ); } void Tr2InteriorPlaceable::PrePhysicsUpdate( Be::Time time ) { } -void Tr2InteriorPlaceable::PostPhysicsUpdate( Be::Time time, Tr2ApexScene *apexScene ) +void Tr2InteriorPlaceable::PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene ) { if( m_placeableRes ) { @@ -172,7 +172,7 @@ void Tr2InteriorPlaceable::PostPhysicsUpdate( Be::Time time, Tr2ApexScene *apexS // -------------------------------------------------------------------------------------- // Description: -// Adds per-cell reflection map to an array of current reflection maps. +// Adds per-cell reflection map to an array of current reflection maps. // Arguments: // texture - Per-cell reflection map // -------------------------------------------------------------------------------------- @@ -209,7 +209,7 @@ void Tr2InteriorPlaceable::AddReflectionMap( TriTextureRes* texture ) // -------------------------------------------------------------------------------------- // Description: -// Removes per-cell reflection map from an array of current reflection maps. +// Removes per-cell reflection map from an array of current reflection maps. // Arguments: // texture - Per-cell reflection map // -------------------------------------------------------------------------------------- @@ -241,20 +241,20 @@ void Tr2InteriorPlaceable::SetLOD( const TriFrustum* frustum ) // -------------------------------------------------------------------------------------- bool Tr2InteriorPlaceable::OnModified( Be::Var* value ) { - if( IsMatch( value, m_placeableResPath ) ) - { - LoadPlaceableRes(); - } + if( IsMatch( value, m_placeableResPath ) ) + { + LoadPlaceableRes(); + } else if( IsMatch( value, m_isUniqueInstance ) ) { if( m_placeableRes && m_isUniqueInstance ) { - // not worth doing anything if we don't already have something loaded - // if we do, take a copy of what's currently there + // not worth doing anything if we don't already have something loaded + // if we do, take a copy of what's currently there IRootPtr copyOfOriginal = NULL; BeClasses->CloneTo( m_placeableRes, ©OfOriginal.p ); m_placeableRes.Unlock(); - BlueQIPtrAssign( ( IRoot** )&m_placeableRes.p, copyOfOriginal, BlueInterfaceIID() ); + BlueQIPtrAssign( (IRoot**)&m_placeableRes.p, copyOfOriginal, BlueInterfaceIID() ); } else { @@ -276,19 +276,19 @@ bool Tr2InteriorPlaceable::OnModified( Be::Var* value ) bool Tr2InteriorPlaceable::Initialize( void ) { LoadPlaceableRes(); - return true; + return true; } bool Tr2InteriorPlaceable::HasTransparentBatches( void ) { if( m_placeableRes ) { - return m_placeableRes->HasTransparency(); + return m_placeableRes->HasTransparency(); } return false; } -void Tr2InteriorPlaceable::GetBatches( ITriRenderBatchAccumulator* batches, +void Tr2InteriorPlaceable::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* data, Tr2RenderReason reason ) @@ -324,7 +324,7 @@ void Tr2InteriorPlaceable::GetBatches( ITriRenderBatchAccumulator* batches, continue; } auto lod = geometry->GetMeshLod( mesh->GetMeshIndex(), 0 ); - if( !lod || !lod->m_allocationsValid) + if( !lod || !lod->m_allocationsValid ) { continue; } @@ -362,7 +362,7 @@ void Tr2InteriorPlaceable::GetBatches( ITriRenderBatchAccumulator* batches, center -= Tr2Renderer::GetViewPosition(); float z = std::min( std::max( ( Length( center ) + m_depthOffset ) / maxDepth, 0.f ), 1.f ); - depth = ( unsigned int )( ( float )0xFFFFFFF * ( 1.0f - z ) ); + depth = (unsigned int)( (float)0xFFFFFFF * ( 1.0f - z ) ); } Tr2RenderBatch batch = CreateGeometryBatch( lod, area, data ); @@ -377,7 +377,7 @@ void Tr2InteriorPlaceable::GetBatches( ITriRenderBatchAccumulator* batches, float Tr2InteriorPlaceable::GetSortValue( void ) { - return CalculateCameraDistance(); + return CalculateCameraDistance(); } Tr2PerObjectData* Tr2InteriorPlaceable::GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) @@ -387,12 +387,12 @@ Tr2PerObjectData* Tr2InteriorPlaceable::GetPerObjectData( ITriRenderBatchAccumul std::string Tr2InteriorPlaceable::GetPlaceableResPath( void ) const { - return m_placeableResPath; + return m_placeableResPath; } void Tr2InteriorPlaceable::SetPlaceableResPath( const std::string& val ) { - m_placeableResPath = val; + m_placeableResPath = val; LoadPlaceableRes(); } @@ -411,9 +411,9 @@ void Tr2InteriorPlaceable::SetPosition( const Vector3& pos ) const Quaternion Tr2InteriorPlaceable::GetRotation( void ) const { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); @@ -427,9 +427,9 @@ void Tr2InteriorPlaceable::SetRotation( const Quaternion& rotQuat ) m_currentRotation = rotQuat; m_rotationSet = true; - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( tmpScale, rotQuat, tmpTranslation ); @@ -438,10 +438,10 @@ void Tr2InteriorPlaceable::SetRotation( const Quaternion& rotQuat ) const Vector3 Tr2InteriorPlaceable::GetScaling( void ) const { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; - + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; + Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); return tmpScale; @@ -454,9 +454,9 @@ void Tr2InteriorPlaceable::SetScaling( const Vector3& scaleVec ) m_currentScaling = scaleVec; m_scalingSet = true; - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( scaleVec, tmpRotation, tmpTranslation ); @@ -493,10 +493,10 @@ void Tr2InteriorPlaceable::RebuildVolume( void ) { Vector3 minBounds( FLT_MAX, FLT_MAX, FLT_MAX ), maxBounds( -FLT_MAX, -FLT_MAX, -FLT_MAX ); - if( !IsBoundingBoxReady() ) - { - return; - } + if( !IsBoundingBoxReady() ) + { + return; + } if( m_isBoundingBoxModified ) { @@ -511,27 +511,27 @@ void Tr2InteriorPlaceable::RebuildVolume( void ) // -------------------------------------------------------------------------------------- // Description: -// Gets per-object data for the placeable using a per-instance light-set override and -// an arbitrary object-to-world matrix. Routes the call to helper function +// Gets per-object data for the placeable using a per-instance light-set override and +// an arbitrary object-to-world matrix. Routes the call to helper function // GetPerObjectDataWithLightSet. // See Also: // GetPerObjectData, GetPerObjectDataWithLightSet // Arguments: // accumulator - The batch accumulator used to allocate memory for per-object data // lightSet - The set of lights illuminating this object -// objectToWorldMatrix - The transformation matrix used to position this object +// objectToWorldMatrix - The transformation matrix used to position this object // in world coordinates // Return Value: // The allocated per-object data, or NULL if the memory allocation failed. // -------------------------------------------------------------------------------------- -Tr2PerObjectData* Tr2InteriorPlaceable::GetPerObjectDataWithPerInstanceLighting( +Tr2PerObjectData* Tr2InteriorPlaceable::GetPerObjectDataWithPerInstanceLighting( ITriRenderBatchAccumulator* accumulator, Tr2InteriorLightSet* lightSet, const Matrix& objectToWorldMatrix ) { - return GetPerObjectDataWithLightSet( accumulator, - lightSet, - objectToWorldMatrix ); + return GetPerObjectDataWithLightSet( accumulator, + lightSet, + objectToWorldMatrix ); } // ------------------------------------------------------------------------------------------------------ diff --git a/trinity/Interior/Tr2InteriorPlaceable.h b/trinity/Interior/Tr2InteriorPlaceable.h index 035d2a602..7500f45ac 100644 --- a/trinity/Interior/Tr2InteriorPlaceable.h +++ b/trinity/Interior/Tr2InteriorPlaceable.h @@ -36,88 +36,95 @@ BLUE_DECLARE( Tr2VariableStore ); // but inhabit one or more Tr2InteriorCells, as determined by a // bounding box intersection test. // See Also -// Tr2InteriorStatic, Tr2IntSkinnedObject, Tr2InteriorScene +// Tr2InteriorStatic, Tr2IntSkinnedObject, Tr2InteriorScene // ----------------------------------------------------------------------------------------------------- -class Tr2InteriorPlaceable : - public INotify, - public IInitialize, - public ITr2Renderable, - public ITr2Pickable, - public ITr2InteriorDynamic, - public ITr2BoundingBox +class Tr2InteriorPlaceable : public INotify, + public IInitialize, + public ITr2Renderable, + public ITr2Pickable, + public ITr2InteriorDynamic, + public ITr2BoundingBox { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using IInitialize::Lock; using IInitialize::Unlock; // Constructor/destructor Tr2InteriorPlaceable( IRoot* lockobj = NULL ); - ~Tr2InteriorPlaceable(); + ~Tr2InteriorPlaceable(); ///////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var* value ); ///////////////////////////////////////////////////////////////////////////////////// - // IInitialize - bool Initialize( void ); + // IInitialize + bool Initialize( void ); - ////////////////////////////////////////////////////////////////////////// - // ITr2InteriorCullable + ////////////////////////////////////////////////////////////////////////// + // ITr2InteriorCullable virtual bool IsInFrustum( const TriFrustum& frustum, Matrix& objectToWorld ) const; ///////////////////////////////////////////////////////////////////////////////////// // ITr2InteriorDynamic - virtual bool AddToScene( Tr2ApexScene *apexScene ); + virtual bool AddToScene( Tr2ApexScene* apexScene ); virtual void RemoveFromScene( void ); virtual bool GetLocalBoundingBox( Vector3& min, Vector3& max ) const; virtual bool GetWorldBoundingBox( Vector3& min, Vector3& max ) const; virtual bool IsBoundingBoxReady( void ) const; virtual void PrePhysicsUpdate( Be::Time time ); - virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene *apexScene ); + virtual void PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene ); virtual void SetLOD( const TriFrustum* frustum ); - void BoundingBoxReset(); + void BoundingBoxReset(); void BoundingBoxOverride( Vector3& min, Vector3& max ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - virtual void GetBatches( ITriRenderBatchAccumulator* batches, + virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* data, - Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches( void ); - virtual float GetSortValue( void ); + virtual float GetSortValue( void ); virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); // Per-object data with instanced lighting - virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( + virtual Tr2PerObjectData* GetPerObjectDataWithPerInstanceLighting( ITriRenderBatchAccumulator* accumulator, Tr2InteriorLightSet* lightSet, - const Matrix& objectToWorldMatrix - ); + const Matrix& objectToWorldMatrix ); ////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ///////////////////////////////////////////////////////////////////////////////////// std::string GetPlaceableResPath( void ) const; - void SetPlaceableResPath( const std::string& val ); + void SetPlaceableResPath( const std::string& val ); // Set the placeableRes from the placeableResPath by loading it from disk void LoadPlaceableRes(); - const Matrix& GetTransform( void ) const { return m_transform; } + const Matrix& GetTransform( void ) const + { + return m_transform; + } // Position getter & setter - const Vector3& GetPosition( void ) const { return *(reinterpret_cast(&m_transform._41)); } + const Vector3& GetPosition( void ) const + { + return *( reinterpret_cast( &m_transform._41 ) ); + } void SetPosition( const Vector3& pos ); // Rotation getter & setter @@ -130,7 +137,8 @@ class Tr2InteriorPlaceable : protected: Tr2PerObjectData* GetPerObjectDataWithLightSet( ITriRenderBatchAccumulator* accumulator, - Tr2InteriorLightSet* lightSet, const Matrix& objectToWorldMatrix ); + Tr2InteriorLightSet* lightSet, + const Matrix& objectToWorldMatrix ); private: float CalculateCameraDistance( void ); @@ -143,6 +151,7 @@ class Tr2InteriorPlaceable : void AddReflectionMap( TriTextureRes* texture ); void RemoveReflectionMap( TriTextureRes* texture ); + private: AxisAlignedBoundingBox GetBoundingBoxInLocalSpace() const; AxisAlignedBoundingBox GetBoundingBoxInWorldSpace() const; @@ -152,7 +161,7 @@ class Tr2InteriorPlaceable : bool m_display; // When false, the placeableRes loaded is a shared instance - // When true, the placeableRes is a unique copy that can be modified without + // When true, the placeableRes is a unique copy that can be modified without // effects on other placables loaded from the same path bool m_isUniqueInstance; diff --git a/trinity/Interior/Tr2InteriorPlaceable_Blue.cpp b/trinity/Interior/Tr2InteriorPlaceable_Blue.cpp index 2aab77825..e8ed2ff38 100644 --- a/trinity/Interior/Tr2InteriorPlaceable_Blue.cpp +++ b/trinity/Interior/Tr2InteriorPlaceable_Blue.cpp @@ -11,7 +11,7 @@ BLUE_DEFINE_INTERFACE( ITr2InteriorDynamic ); const Be::ClassInfo* Tr2InteriorPlaceable::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2InteriorPlaceable, "") + EXPOSURE_BEGIN( Tr2InteriorPlaceable, "" ) MAP_INTERFACE( Tr2InteriorPlaceable ) MAP_INTERFACE( ITr2Interior ) MAP_INTERFACE( ITr2InteriorDynamic ) @@ -21,14 +21,12 @@ const Be::ClassInfo* Tr2InteriorPlaceable::ExposeToBlue() MAP_INTERFACE( ITr2Pickable ) MAP_INTERFACE( ITr2BoundingBox ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "Name of this placeable", - Be::READWRITE | Be::PERSIST - ) - + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "placeableResPath", m_placeableResPath, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY, NULL ) MAP_ATTRIBUTE( "isUnique", m_isUniqueInstance, "When true, the placeable res is a copy, rather than a shared instance", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -52,13 +50,12 @@ const Be::ClassInfo* Tr2InteriorPlaceable::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetBoundingBoxInLocalSpace", GetBoundingBoxInLocalSpace, "Gets the bounding box in local space" ) MAP_METHOD_AND_WRAP( "GetBoundingBoxInWorldSpace", GetBoundingBoxInWorldSpace, "Gets the bounding box in world space" ) MAP_METHOD_AND_WRAP( "BoundingBoxReset", BoundingBoxReset, "Resets the bounding box, removing any overrides" ) - MAP_METHOD_AND_WRAP( - "BoundingBoxOverride", - BoundingBoxOverride, + MAP_METHOD_AND_WRAP( + "BoundingBoxOverride", + BoundingBoxOverride, "Override the object's bounding box with the one provided\n" ":param boundsMin: min bounding box corner\n" - ":param boundsMax: max bounding box corner\n" - ) + ":param boundsMax: max bounding box corner\n" ) MAP_ATTRIBUTE( "variableStore", m_variableStore, "Local variable store for this object", Be::READ ) MAP_ATTRIBUTE( "probeOffset", m_probeOffset, "Offset for Enlighten SH probe position (in world space)", Be::READWRITE | Be::PERSIST ) @@ -66,4 +63,3 @@ const Be::ClassInfo* Tr2InteriorPlaceable::ExposeToBlue() EXPOSURE_END() } - diff --git a/trinity/Interior/Tr2InteriorRenderBatch.h b/trinity/Interior/Tr2InteriorRenderBatch.h index 843f15cfc..b8beee32b 100644 --- a/trinity/Interior/Tr2InteriorRenderBatch.h +++ b/trinity/Interior/Tr2InteriorRenderBatch.h @@ -16,11 +16,11 @@ // -------------------------------------------------------------------------------------- enum Tr2InteriorBatchGroup { - WODINTBATCHGROUP_BEGIN, // Batches that must preceed normal geometry batches - WODINTBATCHGROUP_OPAQUE, // Opaque batches (sorted by effect) - WODINTBATCHGROUP_DECAL, // Decal batches (unsorted, artist-specified order) - WODINTBATCHGROUP_BLEND, // Blended batches (sorted by depth) - WODINTBATCHGROUP_END // Batches that must follow the normal geometry batches + WODINTBATCHGROUP_BEGIN, // Batches that must preceed normal geometry batches + WODINTBATCHGROUP_OPAQUE, // Opaque batches (sorted by effect) + WODINTBATCHGROUP_DECAL, // Decal batches (unsorted, artist-specified order) + WODINTBATCHGROUP_BLEND, // Blended batches (sorted by depth) + WODINTBATCHGROUP_END // Batches that must follow the normal geometry batches }; // -------------------------------------------------------------------------------------- @@ -28,7 +28,7 @@ enum Tr2InteriorBatchGroup // Render batch sort key generator for interior render batches. The batches are sorted // using a 64-bit key. The high 16-bits encode the object group (corresponding to a // cell). The next highest 16-bits encode the batch group within the current object -// group, using the Tr2InteriorBatchGroup enum. The low 32-bits encode either the +// group, using the Tr2InteriorBatchGroup enum. The low 32-bits encode either the // effect sort key (for opaque batches) or the depth (for blended batches). // See Also // TriRenderBatchAccumulator, DefaultKeyGenerator, EffectKeyGenerator @@ -58,9 +58,9 @@ struct Tr2IntKeyGenerator } // Get the sort type - need stable_sort so decals stay in artist-specified order - constexpr static RenderBatchSortType GetSortType() - { - return RENDERBATCHSORTTYPE_STABLE_SORT; + constexpr static RenderBatchSortType GetSortType() + { + return RENDERBATCHSORTTYPE_STABLE_SORT; } static constexpr bool ALLOW_GDPR = false; diff --git a/trinity/Interior/Tr2InteriorScene.cpp b/trinity/Interior/Tr2InteriorScene.cpp index a63717f74..6d7c7fc73 100644 --- a/trinity/Interior/Tr2InteriorScene.cpp +++ b/trinity/Interior/Tr2InteriorScene.cpp @@ -35,83 +35,82 @@ BLUE_DEFINE_INTERFACE( ITr2Interior ); namespace { - const char* VISUALIZER_NAME[VM_COUNT] = - { - "", - "Visualizer_White", - "Visualizer_ObjectNormal", - "Visualizer_Tangent", - "Visualizer_Bitangent", - "Visualizer_TexCoord0", - "Visualizer_TexCoord1", - "Visualizer_TexelDensity", - "Visualizer_NormalMap", - "Visualizer_DiffuseMap", - "Visualizer_SpecularMap", - "Visualizer_Overdraw", - "Visualizer_EnlightenOnly", - "Visualizer_Depth", - "Visualizer_AllLighting", - "Visualizer_LightPrePassNormals", - "Visualizer_LightPrePassDepth", - "Visualizer_LightPrePassWorldPosition", - "Visualizer_LightPrePassLighting", - "Visualizer_LightPrePassLightOverdraw", - "Visualizer_LightPrePassLightingDiffuse", - "Visualizer_LightPrePassLightingSpecular", - "Visualizer_White", - }; - - TriVariable* GetSunDirWorldHandle() - { - static TriVariable* s_sunDirWorldHandle = NULL; - - if( s_sunDirWorldHandle == NULL ) - { - s_sunDirWorldHandle = GlobalStore().FindVariable( "Sun.DirWorld" ); - } +const char* VISUALIZER_NAME[VM_COUNT] = { + "", + "Visualizer_White", + "Visualizer_ObjectNormal", + "Visualizer_Tangent", + "Visualizer_Bitangent", + "Visualizer_TexCoord0", + "Visualizer_TexCoord1", + "Visualizer_TexelDensity", + "Visualizer_NormalMap", + "Visualizer_DiffuseMap", + "Visualizer_SpecularMap", + "Visualizer_Overdraw", + "Visualizer_EnlightenOnly", + "Visualizer_Depth", + "Visualizer_AllLighting", + "Visualizer_LightPrePassNormals", + "Visualizer_LightPrePassDepth", + "Visualizer_LightPrePassWorldPosition", + "Visualizer_LightPrePassLighting", + "Visualizer_LightPrePassLightOverdraw", + "Visualizer_LightPrePassLightingDiffuse", + "Visualizer_LightPrePassLightingSpecular", + "Visualizer_White", +}; + +TriVariable* GetSunDirWorldHandle() +{ + static TriVariable* s_sunDirWorldHandle = NULL; - return s_sunDirWorldHandle; + if( s_sunDirWorldHandle == NULL ) + { + s_sunDirWorldHandle = GlobalStore().FindVariable( "Sun.DirWorld" ); } - TriVariable* GetSunDiffuseColorHandle() - { - static TriVariable* s_handle = NULL; + return s_sunDirWorldHandle; +} - if( s_handle == NULL ) - { - s_handle = GlobalStore().FindVariable( "Sun.WodDiffuseColor" ); - } +TriVariable* GetSunDiffuseColorHandle() +{ + static TriVariable* s_handle = NULL; - return s_handle; + if( s_handle == NULL ) + { + s_handle = GlobalStore().FindVariable( "Sun.WodDiffuseColor" ); } - TriVariable* GetSunSpecularColorHandle() - { - static TriVariable* s_handle = NULL; + return s_handle; +} - if( s_handle == NULL ) - { - s_handle = GlobalStore().FindVariable( "Sun.SpecularColor" ); - } +TriVariable* GetSunSpecularColorHandle() +{ + static TriVariable* s_handle = NULL; - return s_handle; + if( s_handle == NULL ) + { + s_handle = GlobalStore().FindVariable( "Sun.SpecularColor" ); } - TriVariable* GetAmbientColorHandle() - { - static TriVariable* s_handle = NULL; + return s_handle; +} - if( s_handle == NULL ) - { - s_handle = GlobalStore().FindVariable( "Scene.AmbientColor" ); - } +TriVariable* GetAmbientColorHandle() +{ + static TriVariable* s_handle = NULL; - return s_handle; + if( s_handle == NULL ) + { + s_handle = GlobalStore().FindVariable( "Scene.AmbientColor" ); } + + return s_handle; +} } -Tr2InteriorScene::Tr2InteriorScene( IRoot* lockobj /*= NULL */ ): +Tr2InteriorScene::Tr2InteriorScene( IRoot* lockobj /*= NULL */ ) : PARENTLOCK( m_lights ), PARENTLOCK( m_dynamics ), PARENTLOCK( m_dynamicsPendingLoad ), @@ -137,7 +136,7 @@ Tr2InteriorScene::Tr2InteriorScene( IRoot* lockobj /*= NULL */ ): m_cameraPosVar( "Camera.eyePosWorld", Vector3( 0.0f, 0.0f, 0.0f ) ), m_optimizeShadows( true ), m_renderShadows( true ), - m_debugRenderShadowMaps(false), + m_debugRenderShadowMaps( false ), m_shadowMap0Var( "SpotlightShadow0", (TriTextureRes*)NULL ), m_shadowMap1Var( "SpotlightShadow1", (TriTextureRes*)NULL ), m_shadowMap2Var( "SpotlightShadow2", (TriTextureRes*)NULL ), @@ -165,21 +164,21 @@ Tr2InteriorScene::Tr2InteriorScene( IRoot* lockobj /*= NULL */ ): XMVector3Normalize( m_sunDirection ), XMVectorReplicate( -1.0f ) ) ); - m_sunDirectionVar.Register( "Sun.DirWorld", dir ); + m_sunDirectionVar.Register( "Sun.DirWorld", dir ); GlobalStore().RegisterVariable( "PickingComponents", Vector4() ); - + m_dynamics.SetNotify( this ); - m_lights.SetNotify(this); + m_lights.SetNotify( this ); PrepareResources(); - BeResMan->GetResource("res:/texture/global/bluenoise32.png", "", m_noiseTexture); + BeResMan->GetResource( "res:/texture/global/bluenoise32.png", "", m_noiseTexture ); m_nDotLTextureHandle = GlobalStore().RegisterVariable( "ColorNdotLLookupMap", static_cast( nullptr ) ); - BeResMan->GetResource("res:/texture/global/noise.png", "", m_noiseTexture); - m_noiseTextureHandle = GlobalStore().RegisterVariable("NoiseMap", static_cast(nullptr)); + BeResMan->GetResource( "res:/texture/global/noise.png", "", m_noiseTexture ); + m_noiseTextureHandle = GlobalStore().RegisterVariable( "NoiseMap", static_cast( nullptr ) ); - BeResMan->GetResource("res:/texture/global/white.dds", "", m_whiteTexture); + BeResMan->GetResource( "res:/texture/global/white.dds", "", m_whiteTexture ); m_shadowMap0Var = m_whiteTexture; m_shadowMap1Var = m_whiteTexture; m_shadowMap2Var = m_whiteTexture; @@ -192,13 +191,12 @@ Tr2InteriorScene::~Tr2InteriorScene() CCP_DELETE( m_pickingBatches ); CCP_DELETE( m_opaquePickingBatches ); - m_pickBuffer.ReleaseResources( TRISTORAGE_ALL ); - - m_shadowMap0Var = static_cast(nullptr); - m_shadowMap1Var = static_cast(nullptr); - m_shadowMap2Var = static_cast(nullptr); - m_shadowMap3Var = static_cast(nullptr); + m_pickBuffer.ReleaseResources( TRISTORAGE_ALL ); + m_shadowMap0Var = static_cast( nullptr ); + m_shadowMap1Var = static_cast( nullptr ); + m_shadowMap2Var = static_cast( nullptr ); + m_shadowMap3Var = static_cast( nullptr ); } bool Tr2InteriorScene::Initialize() @@ -209,7 +207,7 @@ bool Tr2InteriorScene::Initialize() bool Tr2InteriorScene::OnModified( Be::Var* value ) { - if( IsMatch( value, m_backgroundCubeMapPath ) ) + if( IsMatch( value, m_backgroundCubeMapPath ) ) { SetBackgroundCubemapResPath(); } @@ -224,18 +222,18 @@ bool Tr2InteriorScene::OnModified( Be::Var* value ) SetupShadowMaps(); } - return true; + return true; } // --------------------------------------------------------------- void Tr2InteriorScene::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* currvalue, const IList* theList ) { - if (theList == &m_lights) + if( theList == &m_lights ) { SetupShadowMaps(); } - else if (theList == &m_dynamics) + else if( theList == &m_dynamics ) { if( ( event & BELIST_LOADING ) == 0 ) { @@ -284,7 +282,6 @@ void Tr2InteriorScene::OnListModified( long event, ssize_t key, ssize_t key2, IR } } } - } void Tr2InteriorScene::ReleaseResources( TriStorage s ) @@ -301,18 +298,18 @@ bool Tr2InteriorScene::OnPrepareResources() return true; } -void Tr2InteriorScene::MaximizeShadowMapUsage(TriProjection& projection, const TriView* view, TriFrustum* frustum) +void Tr2InteriorScene::MaximizeShadowMapUsage( TriProjection& projection, const TriView* view, TriFrustum* frustum ) { Tr2SkinnedObject* character = nullptr; - for (auto dynamicIt = m_dynamics.begin(); dynamicIt != m_dynamics.end(); dynamicIt++) + for( auto dynamicIt = m_dynamics.begin(); dynamicIt != m_dynamics.end(); dynamicIt++ ) { - ITr2InteriorDynamic* dynamic = (*dynamicIt); - Tr2SkinnedObjectPtr foundCharacter = BlueCastPtr(dynamic); + ITr2InteriorDynamic* dynamic = ( *dynamicIt ); + Tr2SkinnedObjectPtr foundCharacter = BlueCastPtr( dynamic ); - if (foundCharacter) + if( foundCharacter ) { - if (character) + if( character ) { return; } @@ -321,78 +318,82 @@ void Tr2InteriorScene::MaximizeShadowMapUsage(TriProjection& projection, const T } } - if (character) + if( character ) { Vector3 x, y, z, center, sizes; - character->GetClippedWorldBoundingObb(character->GetSkinningTransform(), x, y, z, center, sizes, frustum); + character->GetClippedWorldBoundingObb( character->GetSkinningTransform(), x, y, z, center, sizes, frustum ); - auto GetPoint = [&](int i) -> Vector4 - { + auto GetPoint = [&]( int i ) -> Vector4 { float scale; Vector3 point = center; - if ((i & 1) != 0) scale = sizes[0]; else scale = -sizes[0]; + if( ( i & 1 ) != 0 ) + scale = sizes[0]; + else + scale = -sizes[0]; point += scale * x; - if ((i & 2) != 0) scale = sizes[1]; else scale = -sizes[1]; + if( ( i & 2 ) != 0 ) + scale = sizes[1]; + else + scale = -sizes[1]; point += scale * y; - if ((i & 4) != 0) scale = sizes[2]; else scale = -sizes[2]; + if( ( i & 4 ) != 0 ) + scale = sizes[2]; + else + scale = -sizes[2]; point += scale * z; - return Vector4(point.x, point.y, point.z, 1.0); + return Vector4( point.x, point.y, point.z, 1.0 ); }; float maxX = -1.0; float maxY = -1.0; float minX = 1.0; float minY = 1.0; - - Matrix VP = XMMatrixMultiply(view->GetTransform(), projection.GetTransform()); - auto Constrain = [](float value) -> float - { - value = min(1.0f, value); - value = max(-1.0f, value); + Matrix VP = XMMatrixMultiply( view->GetTransform(), projection.GetTransform() ); + + auto Constrain = []( float value ) -> float { + value = min( 1.0f, value ); + value = max( -1.0f, value ); return value; }; Vector4 clip; - for (int i = 0; i < 8; ++i) + for( int i = 0; i < 8; ++i ) { - clip = GetPoint(i) * VP; - if (clip[3] < 0.0001) + clip = GetPoint( i ) * VP; + if( clip[3] < 0.0001 ) { continue; } - Vector3 p = Vector3(clip.x / clip.w, clip.y / clip.w, clip.z / clip.w); - minX = min(minX, p.x); - minY = min(minY, p.y); - maxX = max(maxX, p.x); - maxY = max(maxY, p.y); + Vector3 p = Vector3( clip.x / clip.w, clip.y / clip.w, clip.z / clip.w ); + minX = min( minX, p.x ); + minY = min( minY, p.y ); + maxX = max( maxX, p.x ); + maxY = max( maxY, p.y ); } - minX = Constrain(minX); - maxX = Constrain(maxX); - minY = Constrain(minY); - maxY = Constrain(maxY); + minX = Constrain( minX ); + maxX = Constrain( maxX ); + minY = Constrain( minY ); + maxY = Constrain( maxY ); - if (minX >= maxX || minY >= maxY) + if( minX >= maxX || minY >= maxY ) { return; } - float scaleX = 2.0f / (maxX - minX); - float scaleY = 2.0f / (maxY - minY); + float scaleX = 2.0f / ( maxX - minX ); + float scaleY = 2.0f / ( maxY - minY ); - float biasX = (minX + maxX) / (minX - maxX); - float biasY = (minY + maxY) / (minY - maxY); + float biasX = ( minX + maxX ) / ( minX - maxX ); + float biasY = ( minY + maxY ) / ( minY - maxY ); - Matrix custom = Matrix(scaleX, 0, 0, 0, - 0, scaleY, 0, 0, - 0, 0, 1, 0, - biasX, biasY, 0, 1); + Matrix custom = Matrix( scaleX, 0, 0, 0, 0, scaleY, 0, 0, 0, 0, 1, 0, biasX, biasY, 0, 1 ); custom = projection.GetTransform() * custom; - projection.CustomProjection(custom); + projection.CustomProjection( custom ); } } @@ -405,7 +406,7 @@ void Tr2InteriorScene::Update( Be::Time realTime, Be::Time simTime ) { CCP_STATS_ZONE( __FUNCTION__ ); - if( simTime == m_lastUpdateTime) + if( simTime == m_lastUpdateTime ) // NB: Multiple calls on the same 'frame' should be ignored, // but are not strictly errors, according to Dan Speed. return; @@ -415,11 +416,11 @@ void Tr2InteriorScene::Update( Be::Time realTime, Be::Time simTime ) XMVector3Normalize( m_sunDirection ), XMVectorReplicate( -1.0f ) ) ); - m_sunDirectionVar = dir; - m_sunDiffuseColorVar = m_sunDiffuseColor; - m_sunSpecularColorVar = m_sunSpecularColor; - m_ambientColorVar = m_ambientColor; - m_cameraPosVar = Tr2Renderer::GetViewPosition(); + m_sunDirectionVar = dir; + m_sunDiffuseColorVar = m_sunDiffuseColor; + m_sunSpecularColorVar = m_sunSpecularColor; + m_ambientColorVar = m_ambientColor; + m_cameraPosVar = Tr2Renderer::GetViewPosition(); { CCP_STATS_ZONE( "UpdateCurves" ); @@ -442,7 +443,8 @@ void Tr2InteriorScene::Update( Be::Time realTime, Be::Time simTime ) } } for( std::vector::iterator it = dynamicsToRemove.begin(); - it != dynamicsToRemove.end(); ++it ) + it != dynamicsToRemove.end(); + ++it ) { ssize_t index = m_dynamicsPendingLoad.FindKey( ( *it ) ); if( index != -1 ) @@ -513,7 +515,7 @@ void Tr2InteriorScene::VisibilityQuery( Tr2VisibilityResults* results, Tr2Render if( !results ) { CCP_LOGERR( "Attempt to issue a visibility query on an interior scene with a NULL " - "result set!" ); + "result set!" ); return; } @@ -526,28 +528,27 @@ void Tr2InteriorScene::VisibilityQuery( Tr2VisibilityResults* results, Tr2Render &Tr2Renderer::GetViewTransform(), &Tr2Renderer::GetViewPosition(), &Tr2Renderer::GetProjectionTransform(), - renderContext.m_esm.GetViewport() - ); + renderContext.m_esm.GetViewport() ); - //this is to assist in tracking down the crash that's been popping up in this function. - //The bools are here just in case logging breaks during the crash - const size_t dynamicsSize = m_dynamics.size(); + //this is to assist in tracking down the crash that's been popping up in this function. + //The bools are here just in case logging breaks during the crash + const size_t dynamicsSize = m_dynamics.size(); for( PITr2InteriorDynamicVector::iterator it = m_dynamics.begin(); it != m_dynamics.end(); ++it ) { - if( dynamicsSize != m_dynamics.size() ) - { - CCP_LOGERR("VisibilityQuery-m_dynamics changed size while we iterated over it! (before setlod)"); - } + if( dynamicsSize != m_dynamics.size() ) + { + CCP_LOGERR( "VisibilityQuery-m_dynamics changed size while we iterated over it! (before setlod)" ); + } if( !*it ) { - CCP_LOGERR("VisibilityQuery-null pointer in m_dynamics"); + CCP_LOGERR( "VisibilityQuery-null pointer in m_dynamics" ); } ( *it )->SetLOD( &frustum ); - if( dynamicsSize != m_dynamics.size() ) - { - CCP_LOGERR("VisibilityQuery-m_dynamics changed size while we iterated over it! (after setlod)"); - } + if( dynamicsSize != m_dynamics.size() ) + { + CCP_LOGERR( "VisibilityQuery-m_dynamics changed size while we iterated over it! (after setlod)" ); + } } m_visibilityQueryType = PRIMARY_QUERY; @@ -561,7 +562,7 @@ void Tr2InteriorScene::ResolveVisibility( const Matrix& view, const Matrix& proj TriFrustum frustum; XMVECTOR det; Matrix viewInv( XMMatrixInverse( &det, view ) ); - frustum.DeriveFrustum( &view, (Vector3*)(&viewInv._41), &projection, viewport ); + frustum.DeriveFrustum( &view, (Vector3*)( &viewInv._41 ), &projection, viewport ); OnQueryBegin(); @@ -589,11 +590,11 @@ void Tr2InteriorScene::RenderFullForward( Tr2RenderContext& renderContext ) D3DPERF_EVENT( L"Tr2InteriorScene::RenderFullForward" ); - renderContext.AddGpuMarker(__FUNCTION__); + renderContext.AddGpuMarker( __FUNCTION__ ); // If we don't have a visibilityResults object (i.e. the VisibilityQuery renderstep // wasn't called), then create one and call VisibilityQuery now. - if (!m_visibilityResults) + if( !m_visibilityResults ) { m_visibilityResults.CreateInstance(); } @@ -602,9 +603,9 @@ void Tr2InteriorScene::RenderFullForward( Tr2RenderContext& renderContext ) m_backgroundCubeMapVar = m_backgroundCubeMapRes; // Render Shadows - RenderShadows(renderContext); + RenderShadows( renderContext ); - VisibilityQuery(m_visibilityResults, renderContext); + VisibilityQuery( m_visibilityResults, renderContext ); // Gather geometry batches GatherFullForwardBatches( m_visibilityResults ); @@ -635,20 +636,20 @@ void Tr2InteriorScene::RenderFullForward( Tr2RenderContext& renderContext ) } // set per-frame data - PopulatePerFramePSData(m_perFramePSData, renderContext ); - PopulatePerFrameVSData(m_perFrameVSData); + PopulatePerFramePSData( m_perFramePSData, renderContext ); + PopulatePerFrameVSData( m_perFrameVSData ); { - D3DPERF_EVENT(L"Set per-frame shader constants"); - FillAndSetConstants(m_perFrameVSBuffer, m_perFrameVSData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext); - FillAndSetConstants(m_perFramePSBuffer, m_perFramePSData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext); + D3DPERF_EVENT( L"Set per-frame shader constants" ); + FillAndSetConstants( m_perFrameVSBuffer, m_perFrameVSData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext ); + FillAndSetConstants( m_perFramePSBuffer, m_perFramePSData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext ); } if( m_renderBackgroundCubeMap && m_backgroundEffect ) { Tr2Renderer::DrawCameraSpaceScreenQuad( renderContext, m_backgroundEffect->GetShaderStateInterface(), m_backgroundEffect ); } - + // Render geometry RenderGeometry( nullptr, renderContext ); @@ -660,52 +661,52 @@ void Tr2InteriorScene::SetupShadowMaps() { m_lightRenderTargets.Clear(); - for (int i = 0; i < (int)(m_lights.size()) && i < m_shadowCount; i++) + for( int i = 0; i < (int)( m_lights.size() ) && i < m_shadowCount; i++ ) { Tr2RenderTargetPtr rt; rt.CreateInstance(); rt->SetName( "ShadowMap" ); - rt->Create(m_shadowSize, m_shadowSize, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT, 1, 0); - m_lightRenderTargets.Append(rt); + rt->Create( m_shadowSize, m_shadowSize, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT, 1, 0 ); + m_lightRenderTargets.Append( rt ); } // Setup depth stencil texture m_lightDepthStencil = Tr2DepthStencilPtr(); m_lightDepthStencil.CreateInstance(); - m_lightDepthStencil->Create(m_shadowSize, m_shadowSize, Tr2RenderContextEnum::DSFMT_D32, 0, 0); + m_lightDepthStencil->Create( m_shadowSize, m_shadowSize, Tr2RenderContextEnum::DSFMT_D32, 0, 0 ); } // -------------------------------------------------------------------------------------- // Description // This function renders shadow maps for each shadow casting light source. // -------------------------------------------------------------------------------------- -void Tr2InteriorScene::RenderShadows(Tr2RenderContext& renderContext) +void Tr2InteriorScene::RenderShadows( Tr2RenderContext& renderContext ) { - CCP_STATS_ZONE(__FUNCTION__); + CCP_STATS_ZONE( __FUNCTION__ ); - if (!m_renderShadows) + if( !m_renderShadows ) { return; } - if (!m_lightDepthStencil) + if( !m_lightDepthStencil ) { SetupShadowMaps(); } - m_noiseTextureHandle = GlobalStore().RegisterVariable("NoiseMap", m_noiseTexture); + m_noiseTextureHandle = GlobalStore().RegisterVariable( "NoiseMap", m_noiseTexture ); Tr2Renderer::PushProjection(); - ON_BLOCK_EXIT(Tr2Renderer::PopProjection); + ON_BLOCK_EXIT( Tr2Renderer::PopProjection ); Tr2Renderer::PushViewTransform(); - ON_BLOCK_EXIT(Tr2Renderer::PopViewTransform); + ON_BLOCK_EXIT( Tr2Renderer::PopViewTransform ); renderContext.m_esm.PushViewport(); ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopViewport(); } ); renderContext.m_esm.PushRenderTarget(); - ON_BLOCK_EXIT([&] { renderContext.m_esm.PopRenderTarget(); }); + ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopRenderTarget(); } ); renderContext.m_esm.PushDepthStencilBuffer( Tr2TextureAL() ); - ON_BLOCK_EXIT([&] { renderContext.m_esm.PopDepthStencilBuffer(); }); + ON_BLOCK_EXIT( [&] { renderContext.m_esm.PopDepthStencilBuffer(); } ); TriViewPtr lightView = CreateInstance(); TriProjectionPtr lightProjection = CreateInstance(); @@ -716,8 +717,7 @@ void Tr2InteriorScene::RenderShadows(Tr2RenderContext& renderContext) &Tr2Renderer::GetViewTransform(), &Tr2Renderer::GetViewPosition(), &Tr2Renderer::GetProjectionTransform(), - renderContext.m_esm.GetViewport() - ); + renderContext.m_esm.GetViewport() ); // Reset the testures to white m_shadowMap0Var = m_whiteTexture; @@ -725,82 +725,83 @@ void Tr2InteriorScene::RenderShadows(Tr2RenderContext& renderContext) m_shadowMap2Var = m_whiteTexture; m_shadowMap3Var = m_whiteTexture; - for( int i = 0; i < (int)(m_lights.size()) && i < m_shadowCount; ++i) + for( int i = 0; i < (int)( m_lights.size() ) && i < m_shadowCount; ++i ) { - if (i >= (int)(m_lightRenderTargets.size())) + if( i >= (int)( m_lightRenderTargets.size() ) ) { // render target might not be created yet. return; } - Tr2InteriorLightSource* light = dynamic_cast(m_lights[i]); + Tr2InteriorLightSource* light = dynamic_cast( m_lights[i] ); - if (light->m_coneAlphaOuter >= 90) + if( light->m_coneAlphaOuter >= 90 ) { continue; } float fov = light->m_coneAlphaOuter * TRI_PI / 90.0f; - lightProjection->PerspectiveFov(fov, 1.0, 0.1, light->m_radius); - lightView->SetLookAtPosition(light->m_position, light->m_position + light->m_coneDirection, Vector3(0.0, 0.0, 1.0)); + lightProjection->PerspectiveFov( fov, 1.0, 0.1, light->m_radius ); + lightView->SetLookAtPosition( light->m_position, light->m_position + light->m_coneDirection, Vector3( 0.0, 0.0, 1.0 ) ); // Fit the light's projection matrix to the character's frustum area to maximize shadowmap usage. - if (m_optimizeShadows) + if( m_optimizeShadows ) { - MaximizeShadowMapUsage(*lightProjection, lightView, &cameraFrustum); + MaximizeShadowMapUsage( *lightProjection, lightView, &cameraFrustum ); } auto rt = m_lightRenderTargets[i]; - renderContext.m_esm.SetRenderTarget(0, rt->GetRenderTarget()); - renderContext.m_esm.SetDepthStencilBuffer(*m_lightDepthStencil); - renderContext.Clear(CLEARFLAGS_TARGET | CLEARFLAGS_ZBUFFER, 0xffffffff, 1.f, 0, 0); + renderContext.m_esm.SetRenderTarget( 0, rt->GetRenderTarget() ); + renderContext.m_esm.SetDepthStencilBuffer( *m_lightDepthStencil ); + renderContext.Clear( CLEARFLAGS_TARGET | CLEARFLAGS_ZBUFFER, 0xffffffff, 1.f, 0, 0 ); - Tr2Renderer::SetProjectionTransform(lightProjection->GetTransform()); - Tr2Renderer::SetViewTransform(lightView->GetTransform()); + Tr2Renderer::SetProjectionTransform( lightProjection->GetTransform() ); + Tr2Renderer::SetViewTransform( lightView->GetTransform() ); // Gather visibility results - VisibilityQuery(m_visibilityResults, renderContext); + VisibilityQuery( m_visibilityResults, renderContext ); // Gather geometry batches - GatherFullForwardBatches(m_visibilityResults); + GatherFullForwardBatches( m_visibilityResults ); // Set per frame data - PopulatePerFramePSData(m_perFramePSData, renderContext ); - PopulatePerFrameVSData(m_perFrameVSData); + PopulatePerFramePSData( m_perFramePSData, renderContext ); + PopulatePerFrameVSData( m_perFrameVSData ); // Plug in the light's radius m_perFramePSData.radius = light->m_radius; - m_perFrameVSData.ViewMat = Transpose(lightView->GetTransform()); - m_perFrameVSData.ProjectionMat = Transpose(lightProjection->GetTransform()); - Matrix VP = XMMatrixMultiply(lightView->GetTransform(), lightProjection->GetTransform()); - m_perFrameVSData.ViewProjectionMat = Transpose(VP); + m_perFrameVSData.ViewMat = Transpose( lightView->GetTransform() ); + m_perFrameVSData.ProjectionMat = Transpose( lightProjection->GetTransform() ); + Matrix VP = XMMatrixMultiply( lightView->GetTransform(), lightProjection->GetTransform() ); + m_perFrameVSData.ViewProjectionMat = Transpose( VP ); Matrix uvAdjust = Matrix( - 0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, -0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f); + 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f ); // Set the VP matrix on the light and [-1, 1] -> [0, 1] - light->m_viewProjection = Transpose(VP * uvAdjust); + light->m_viewProjection = Transpose( VP * uvAdjust ); { - D3DPERF_EVENT(L"Set per-frame shader constants for Shadows"); - FillAndSetConstants(m_perFrameVSBuffer, m_perFrameVSData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext); - FillAndSetConstants(m_perFramePSBuffer, m_perFramePSData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext); + D3DPERF_EVENT( L"Set per-frame shader constants for Shadows" ); + FillAndSetConstants( m_perFrameVSBuffer, m_perFrameVSData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext ); + FillAndSetConstants( m_perFramePSBuffer, m_perFramePSData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext ); } { - D3DPERF_EVENT(L"Primary render batches for Shadows"); + D3DPERF_EVENT( L"Primary render batches for Shadows" ); m_primaryRenderBatches->Finalize(); - renderContext.m_esm.ApplyStandardStates(Tr2EffectStateManager::RM_OPAQUE); - renderContext.RenderBatches(m_primaryRenderBatches, BlueSharedString("Shadow")); + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE ); + renderContext.RenderBatches( m_primaryRenderBatches, BlueSharedString( "Shadow" ) ); } - if (i == 0) m_shadowMap0Var = rt; - if (i == 1) m_shadowMap1Var = rt; - if (i == 2) m_shadowMap2Var = rt; - if (i == 3) m_shadowMap3Var = rt; + if( i == 0 ) + m_shadowMap0Var = rt; + if( i == 1 ) + m_shadowMap1Var = rt; + if( i == 2 ) + m_shadowMap2Var = rt; + if( i == 3 ) + m_shadowMap3Var = rt; // Clear batches m_primaryRenderBatches->Clear(); @@ -829,9 +830,9 @@ void Tr2InteriorScene::RenderGeometry( Tr2Material* overrideEffect, Tr2RenderCon void Tr2InteriorScene::RenderDebugInfo( Tr2RenderContext& renderContext ) { - if (!m_debugRenderer) + if( !m_debugRenderer ) { - if (m_debugRenderShadowMaps) + if( m_debugRenderShadowMaps ) { // Need to create a debug renderer m_debugRenderer = Tr2DebugRendererPtr(); @@ -844,21 +845,21 @@ void Tr2InteriorScene::RenderDebugInfo( Tr2RenderContext& renderContext ) } // Display the debug meshes for the lights - Tr2PerFrameVSDataDebug debugPerFrameData; + Tr2PerFrameVSDataDebug debugPerFrameData; debugPerFrameData.ViewProjectionMat = XMMatrixTranspose( - XMMatrixMultiply(Tr2Renderer::GetViewTransform(),Tr2Renderer::GetProjectionTransform())); + XMMatrixMultiply( Tr2Renderer::GetViewTransform(), Tr2Renderer::GetProjectionTransform() ) ); // attention: need the transposed, but shader also needs column_major, so it is transpose(transpose(m)) == m debugPerFrameData.ViewInverseTransposeMat = Tr2Renderer::GetInverseViewTransform(); - FillAndSetConstants(m_perFrameVSBuffer, debugPerFrameData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext); + FillAndSetConstants( m_perFrameVSBuffer, debugPerFrameData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext ); m_debugRenderer->BeginRender(); auto bkProjection = Tr2Renderer::GetProjectionRawTransform(); - Tr2Renderer::SetProjectionTransform(Tr2Renderer::GetProjectionTransform()); - ON_BLOCK_EXIT([&] { Tr2Renderer::SetProjectionTransform(bkProjection); }); + Tr2Renderer::SetProjectionTransform( Tr2Renderer::GetProjectionTransform() ); + ON_BLOCK_EXIT( [&] { Tr2Renderer::SetProjectionTransform( bkProjection ); } ); for( auto it = m_lights.begin(); it != m_lights.end(); ++it ) { @@ -874,14 +875,14 @@ void Tr2InteriorScene::RenderDebugInfo( Tr2RenderContext& renderContext ) renderable->RenderDebugInfo( *m_debugRenderer ); } } - renderContext.m_esm.ApplyStandardStates(Tr2EffectStateManager::RM_FULLSCREEN); - RenderDebugInfo(*m_debugRenderer); + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN ); + RenderDebugInfo( *m_debugRenderer ); - m_debugRenderer->EndRender(renderContext); - Tr2Renderer::RenderDebugInfo(renderContext); + m_debugRenderer->EndRender( renderContext ); + Tr2Renderer::RenderDebugInfo( renderContext ); } -ITr2MultiPassScene::RenderPassResult Tr2InteriorScene::RenderPass( PassType pass, Tr2RenderContext & renderContext ) +ITr2MultiPassScene::RenderPassResult Tr2InteriorScene::RenderPass( PassType pass, Tr2RenderContext& renderContext ) { switch( pass ) { @@ -949,7 +950,7 @@ void Tr2InteriorScene::RemoveLightSource( ITr2InteriorLight* lightSource ) ssize_t pos = m_lights.FindKey( lightSource ); if( pos == -1 ) { - CCP_LOGERR("Tr2InteriorScenel::RemoveLightSource() - interiorLightSource not found in the scene!" ); + CCP_LOGERR( "Tr2InteriorScenel::RemoveLightSource() - interiorLightSource not found in the scene!" ); return; } @@ -972,7 +973,7 @@ void Tr2InteriorScene::AddDynamic( ITr2InteriorDynamic* dynamic ) // Bail out early if the dynamic is NULL if( !dynamic ) { - CCP_LOGERR(" Attempt to add NULL dynamic to interior scene!" ); + CCP_LOGERR( " Attempt to add NULL dynamic to interior scene!" ); return; } @@ -1022,7 +1023,7 @@ void Tr2InteriorScene::RemoveDynamic( ITr2InteriorDynamic* dynamic ) // -------------------------------------------------------------------------------------- // Description -// This function is called at the beginning of visibility query. +// This function is called at the beginning of visibility query. // See Also: // OnQueryEnd, DoQueryBegin, DoQueryBeginPrePass // -------------------------------------------------------------------------------------- @@ -1115,9 +1116,9 @@ void Tr2InteriorScene::DoInstanceVisible( const Tr2VisibilityEvent& event ) if( m_primaryRenderBatches ) { -#define DO_GET_BATCHES( batches, mode, key, batchType ) \ - batches->SetRenderingMode( Tr2EffectStateManager::mode ); \ - batches->SetUserData( ConstructKey( 0, key ) ); \ +#define DO_GET_BATCHES( batches, mode, key, batchType ) \ + batches->SetRenderingMode( Tr2EffectStateManager::mode ); \ + batches->SetUserData( ConstructKey( 0, key ) ); \ renderable->GetBatches( batches, batchType, perObjectOpaque ); DO_GET_BATCHES( m_primaryRenderBatches, RM_OPAQUE, WODINTBATCHGROUP_OPAQUE, TRIBATCHTYPE_OPAQUE ); @@ -1147,7 +1148,8 @@ void Tr2InteriorScene::GatherFullForwardBatches( Tr2VisibilityResults* results ) const std::vector& events = results->GetEvents(); for( std::vector::const_iterator it = events.begin(); - it != events.end(); ++it ) + it != events.end(); + ++it ) { const Tr2VisibilityEvent& event = *it; @@ -1159,8 +1161,8 @@ void Tr2InteriorScene::GatherFullForwardBatches( Tr2VisibilityResults* results ) case Tr2VisibilityEvent::INSTANCE_VISIBLE: DoInstanceVisible( event ); break; - default: - break; + default: + break; } } } @@ -1176,26 +1178,26 @@ void Tr2InteriorScene::SetupTransformsForPicking( float fx, float fy, TriProject if( Tr2Renderer::GetCurrentProjectionType() == PT_ORTHOGONAL ) { - fx *= (Tr2Renderer::GetOrthoWidth()/2.0f); - fy *= (Tr2Renderer::GetOrthoHeight()/2.0f); - float metersPerPixel = (Tr2Renderer::GetOrthoWidth()/viewport->width)/2.0f; - Tr2Renderer::SetOrthoProjection(fx-metersPerPixel, - fx+metersPerPixel, - fy-metersPerPixel, - fy+metersPerPixel, - Tr2Renderer::GetFrontClip(), - Tr2Renderer::GetBackClip()); + fx *= ( Tr2Renderer::GetOrthoWidth() / 2.0f ); + fy *= ( Tr2Renderer::GetOrthoHeight() / 2.0f ); + float metersPerPixel = ( Tr2Renderer::GetOrthoWidth() / viewport->width ) / 2.0f; + Tr2Renderer::SetOrthoProjection( fx - metersPerPixel, + fx + metersPerPixel, + fy - metersPerPixel, + fy + metersPerPixel, + Tr2Renderer::GetFrontClip(), + Tr2Renderer::GetBackClip() ); } else { // // Projection is set up to scale the image such that the viewport is covered by one pixel. - Vector2 scaling( float(viewport->width), float(viewport->height) ); + Vector2 scaling( float( viewport->width ), float( viewport->height ) ); // translate the projection so that we center around the pick ray origin, // while remembering to scale this value as well: Vector2 translation; - translation.x = -fx*scaling.x; - translation.y = -fy*scaling.y; + translation.x = -fx * scaling.x; + translation.y = -fy * scaling.y; Tr2Renderer::AdjustProjection( scaling, translation ); } } @@ -1243,22 +1245,22 @@ void Tr2InteriorScene::SetPerFrameDataForPicking( Tr2RenderContext& renderContex PopulatePerFramePSData( perFramePS, renderContext ); PopulatePerFrameVSData( perFrameVS ); - Tr2BindPerFramePSData( perFramePS, renderContext ); - Tr2BindPerFrameVSData( perFrameVS, renderContext ); + Tr2BindPerFramePSData( perFramePS, renderContext ); + Tr2BindPerFrameVSData( perFrameVS, renderContext ); } int64_t Tr2InteriorScene::ConstructKey( unsigned int objectGroup, Tr2InteriorBatchGroup batchGroup ) { - int64_t objGroup64 = ( int64_t )objectGroup << 48; + int64_t objGroup64 = (int64_t)objectGroup << 48; - int64_t batchGroup64 = ( int64_t )batchGroup << 32; + int64_t batchGroup64 = (int64_t)batchGroup << 32; - return( objGroup64 | batchGroup64 ); + return ( objGroup64 | batchGroup64 ); } -void Tr2InteriorScene::PopulatePerFrameVSData( Tr2PerFrameVSData &data ) +void Tr2InteriorScene::PopulatePerFrameVSData( Tr2PerFrameVSData& data ) { - Tr2PopulatePerFrameVSDataTransformations( data ); + Tr2PopulatePerFrameVSDataTransformations( data ); // sun Vector3 vec; @@ -1268,7 +1270,7 @@ void Tr2InteriorScene::PopulatePerFrameVSData( Tr2PerFrameVSData &data ) data.sunDirWorld.z = vec.z; } -void Tr2InteriorScene::PopulatePerFramePSData( Tr2PerFramePSData &data, Tr2RenderContext& renderContext ) +void Tr2InteriorScene::PopulatePerFramePSData( Tr2PerFramePSData& data, Tr2RenderContext& renderContext ) { memset( &data, 0, sizeof( Tr2PerFramePSData ) ); @@ -1290,11 +1292,9 @@ void Tr2InteriorScene::PopulatePerFramePSData( Tr2PerFramePSData &data, Tr2Rende XMVECTOR det; data.ViewProjInverse = XMMatrixTranspose( - XMMatrixInverse( &det, XMMatrixMultiply( - Tr2Renderer::GetViewTransform(), - Tr2Renderer::GetProjectionTransform() ) ) ); + XMMatrixInverse( &det, XMMatrixMultiply( Tr2Renderer::GetViewTransform(), Tr2Renderer::GetProjectionTransform() ) ) ); - // sun + // sun GetSunDiffuseColorHandle()->GetValue( data.sunDiffuseColor ); GetSunSpecularColorHandle()->GetValue( data.sunSpecularColor ); GetAmbientColorHandle()->GetValue( data.sceneAmbientColor ); @@ -1361,10 +1361,10 @@ void Tr2InteriorScene::DecodeBufferPixel( const void* pBuffer, PickComponents pa // In the meantime if you make changes here, make sure they end up in WodExteriorPicker::DecodeBufferPixel // helpers: get each channel - float a = *( ( float* )pBuffer + 3 ); - float r = *( ( float* )pBuffer + 2 ); - float g = *( ( float* )pBuffer + 1 ); - float b = *( ( float* )pBuffer + 0 ); + float a = *( (float*)pBuffer + 3 ); + float r = *( (float*)pBuffer + 2 ); + float g = *( (float*)pBuffer + 1 ); + float b = *( (float*)pBuffer + 0 ); // put it "together" results.objectId = (unsigned short)( b + 0.5f ); results.objectId--; @@ -1425,23 +1425,23 @@ void Tr2InteriorScene::UpdateSceneFromScript( Be::Time time ) Update( time, time ); } -void Tr2InteriorScene::GetDebugOptions(Tr2DebugRendererOptions & options) +void Tr2InteriorScene::GetDebugOptions( Tr2DebugRendererOptions& options ) { - options.insert("Shadow Maps"); + options.insert( "Shadow Maps" ); } -void Tr2InteriorScene::RenderDebugInfo( ITr2DebugRenderer2& renderer) +void Tr2InteriorScene::RenderDebugInfo( ITr2DebugRenderer2& renderer ) { - if (renderer.HasOption(GetRawRoot(), "Shadow Maps") || m_debugRenderShadowMaps) + if( renderer.HasOption( GetRawRoot(), "Shadow Maps" ) || m_debugRenderShadowMaps ) { USE_MAIN_THREAD_RENDER_CONTEXT(); renderContext.m_esm.PushViewport(); int i = 0; - for (auto it = m_lightRenderTargets.begin(); it != m_lightRenderTargets.end(); ++it) + for( auto it = m_lightRenderTargets.begin(); it != m_lightRenderTargets.end(); ++it ) { - renderContext.m_esm.SetViewport(200, 200, 10, 10 + i * 210, 0.0, 1.0); - auto tex = dynamic_cast(*it)->GetTexture(); - Tr2Renderer::DrawTexture( renderContext, *tex); + renderContext.m_esm.SetViewport( 200, 200, 10, 10 + i * 210, 0.0, 1.0 ); + auto tex = dynamic_cast( *it )->GetTexture(); + Tr2Renderer::DrawTexture( renderContext, *tex ); i++; } renderContext.m_esm.PopViewport(); diff --git a/trinity/Interior/Tr2InteriorScene.h b/trinity/Interior/Tr2InteriorScene.h index cd2412c24..0e29e2bfa 100644 --- a/trinity/Interior/Tr2InteriorScene.h +++ b/trinity/Interior/Tr2InteriorScene.h @@ -27,31 +27,30 @@ class TriView; class TriViewport; // Blue forward declarations -BLUE_DECLARE(Tr2ApexScene); -BLUE_DECLARE(Tr2InteriorScene); -BLUE_DECLARE(TriGeometryRes); -BLUE_DECLARE(TriTextureRes); -BLUE_DECLARE(Tr2Effect); -BLUE_DECLARE(Tr2VisibilityResults); -BLUE_DECLARE(Tr2TextureAtlas); -BLUE_DECLARE_VECTOR(Tr2TextureAtlas); -BLUE_DECLARE(TriCurveSet); -BLUE_DECLARE_VECTOR(TriCurveSet); -BLUE_DECLARE(Tr2DebugRenderer); -BLUE_DECLARE(Tr2RenderTarget); -BLUE_DECLARE_VECTOR(Tr2RenderTarget); -BLUE_DECLARE(Tr2DepthStencil); - -class Tr2InteriorScene: - public IInitialize, - public INotify, - public IListNotify, - public ITr2Scene, - public ITr2MultiPassScene, - public ITr2PickableScene, - public Tr2DeviceResource, - public ITr2VisualizationModeRenderer, - public ITr2DebugRenderable +BLUE_DECLARE( Tr2ApexScene ); +BLUE_DECLARE( Tr2InteriorScene ); +BLUE_DECLARE( TriGeometryRes ); +BLUE_DECLARE( TriTextureRes ); +BLUE_DECLARE( Tr2Effect ); +BLUE_DECLARE( Tr2VisibilityResults ); +BLUE_DECLARE( Tr2TextureAtlas ); +BLUE_DECLARE_VECTOR( Tr2TextureAtlas ); +BLUE_DECLARE( TriCurveSet ); +BLUE_DECLARE_VECTOR( TriCurveSet ); +BLUE_DECLARE( Tr2DebugRenderer ); +BLUE_DECLARE( Tr2RenderTarget ); +BLUE_DECLARE_VECTOR( Tr2RenderTarget ); +BLUE_DECLARE( Tr2DepthStencil ); + +class Tr2InteriorScene : public IInitialize, + public INotify, + public IListNotify, + public ITr2Scene, + public ITr2MultiPassScene, + public ITr2PickableScene, + public Tr2DeviceResource, + public ITr2VisualizationModeRenderer, + public ITr2DebugRenderable { public: Tr2InteriorScene( IRoot* lockobj = NULL ); @@ -68,7 +67,7 @@ class Tr2InteriorScene: ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var* value ); virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); ////////////////////////////////////////////////////////////////////////// @@ -95,10 +94,9 @@ class Tr2InteriorScene: private: bool OnPrepareResources(); - void MaximizeShadowMapUsage(TriProjection& projectionMatrix, const TriView* view, TriFrustum* frustum); - -public: + void MaximizeShadowMapUsage( TriProjection& projectionMatrix, const TriView* view, TriFrustum* frustum ); +public: ////////////////////////////////////////////////////////////////////////// // ITr2VisualizationModeRenderer virtual void SetVisualizationMode( int visualizationMode ); @@ -126,7 +124,6 @@ class Tr2InteriorScene: bool m_debugRenderShadowMaps; protected: - void OnQueryBegin( void ); void OnInstanceVisible( ITr2InteriorCullable* cullable, const Matrix& ); @@ -148,7 +145,7 @@ class Tr2InteriorScene: void RenderFullForward( Tr2RenderContext& renderContext ); - void RenderShadows(Tr2RenderContext& renderContext); + void RenderShadows( Tr2RenderContext& renderContext ); void SetupShadowMaps(); @@ -210,7 +207,7 @@ class Tr2InteriorScene: Tr2EffectPtr m_backgroundEffect; bool m_renderBackgroundCubeMap; - Tr2ApexScenePtr m_apexScene; + Tr2ApexScenePtr m_apexScene; void SetBackgroundCubemapResPath(); @@ -225,17 +222,23 @@ class Tr2InteriorScene: virtual ITriRenderBatchAccumulator* GetOpaquePickingBatchAccumulator(); virtual ITriRenderBatchAccumulator* GetPickingBatchAccumulator(); - virtual bool RenderPickingAreasForComponents( PickComponents pass ) const { return true; } - virtual Tr2PickBuffer& GetPickBuffer( void ) { return m_pickBuffer; } + virtual bool RenderPickingAreasForComponents( PickComponents pass ) const + { + return true; + } + virtual Tr2PickBuffer& GetPickBuffer( void ) + { + return m_pickBuffer; + } virtual unsigned int GetRequiredPasses( PickComponents requestedComponents, PickComponents* passes ); virtual void DecodeBufferPixel( const void* pBuffer, PickComponents pass, BufferResults& results ) const; // Construct a sort key from object & batch groups - int64_t ConstructKey( unsigned int objectGroup, Tr2InteriorBatchGroup batchGroup ); + int64_t ConstructKey( unsigned int objectGroup, Tr2InteriorBatchGroup batchGroup ); // These should be moved over to a smaller per-frame data at some point without the cruft - void PopulatePerFramePSData( Tr2PerFramePSData &data, Tr2RenderContext& renderContext ); - void PopulatePerFrameVSData( Tr2PerFrameVSData &data ); + void PopulatePerFramePSData( Tr2PerFramePSData& data, Tr2RenderContext& renderContext ); + void PopulatePerFrameVSData( Tr2PerFrameVSData& data ); // This is a python only wrapper function for just picking an object IRoot* PickObjectOnly( int x, int y, TriProjection* proj, TriView* view, TriViewport* vp, Be::Optional ) @@ -297,10 +300,8 @@ class Tr2InteriorScene: // Fog color Color m_fogColor; - Tr2ConstantBufferAL m_perFramePSBuffer; - Tr2ConstantBufferAL m_perFrameVSBuffer; - - + Tr2ConstantBufferAL m_perFramePSBuffer; + Tr2ConstantBufferAL m_perFrameVSBuffer; }; TYPEDEF_BLUECLASS( Tr2InteriorScene ); diff --git a/trinity/Interior/Tr2InteriorScene_Blue.cpp b/trinity/Interior/Tr2InteriorScene_Blue.cpp index 5d2ad3bba..549d7d5fa 100644 --- a/trinity/Interior/Tr2InteriorScene_Blue.cpp +++ b/trinity/Interior/Tr2InteriorScene_Blue.cpp @@ -12,168 +12,112 @@ BLUE_DEFINE( Tr2InteriorScene ); -static Be::VarChooser VisualizerChooser[] = -{ - { - "VM_NONE", - BeCast( VM_NONE ), - "No visualizer - use normal rendering" - }, - { - "VM_WHITE", - BeCast( VM_WHITE ), - "Pixel shader returns white (useful to verify that something is output)" - }, - - { - "VM_OBJECT_NORMAL", - BeCast( VM_OBJECT_NORMAL ), - "Normal from vertices" - }, - { - "VM_TANGENT", - BeCast( VM_TANGENT ), - "Tangent from vertices" - }, - { - "VM_BITANGENT", - BeCast( VM_BITANGENT ), - "Bitangent from vertices" - }, - - { - "VM_TEXCOORD0", - BeCast( VM_TEXCOORD0 ), - "Texture coordinate 0" - }, - { - "VM_TEXCOORD1", - BeCast( VM_TEXCOORD1 ), - "Texture coordinate 0" - }, - - { - "VM_TEXELDENSITY0", - BeCast( VM_TEXELDENSITY0 ), - "Density of texels mapped through texture coordinate 0" - }, - { - "VM_NORMALMAP", - BeCast( VM_NORMALMAP ), - "Tangent space normal from map" - }, - { - "VM_DIFFUSEMAP", - BeCast( VM_DIFFUSEMAP ), - "Diffuse map" - }, - { - "VM_SPECULARMAP", - BeCast( VM_SPECULARMAP ), - "Specular map" - }, - { - "VM_OVERDRAW", - BeCast( VM_OVERDRAW ), - "See the overdraw of the scene" - }, - { - "VM_EN_ONLY", - BeCast( VM_EN_ONLY ), - "Enlighten only)" - }, - { - "VM_DEPTH", - BeCast( VM_DEPTH ), - "See the depth buffer of the scene" - }, - { - "VM_ALL_LIGHTING", - BeCast( VM_ALL_LIGHTING ), - "See cummulative direct and secondary lighting" - }, - { - "VM_LIGHT_PRE_PASS_NORMALS", - BeCast( VM_LIGHT_PRE_PASS_NORMALS ), - "normal in worldspace from light pre-pass texture" - }, - { - "VM_LIGHT_PRE_PASS_DEPTH", - BeCast( VM_LIGHT_PRE_PASS_DEPTH ), - "depth in clip space from light pre-pass texture" - }, - { - "VM_LIGHT_PRE_PASS_WORLD_POSITION", - BeCast( VM_LIGHT_PRE_PASS_WORLD_POSITION ), - "world position from light pre-pass texture" - }, - { - "VM_LIGHT_PRE_PASS_LIGHTING", - BeCast( VM_LIGHT_PRE_PASS_LIGHTING ), - "resulting lighting from pre-pass light accumulation texture" - }, - { - "VM_LIGHT_PRE_PASS_LIGHT_OVERDRAW", - BeCast( VM_LIGHT_PRE_PASS_LIGHT_OVERDRAW ), - "light geometry overdraw during light accumulation pass" - }, - { - "VM_LIGHT_PRE_PASS_DIFFUSE_LIGHTING", - BeCast( VM_LIGHT_PRE_PASS_DIFFUSE_LIGHTING ), - "resulting deffuse lighting from pre-pass light accumulation texture" - }, - { - "VM_LIGHT_PRE_PASS_SPECULAR_LIGHTING", - BeCast( VM_LIGHT_PRE_PASS_SPECULAR_LIGHTING ), - "resulting specular lighting from pre-pass light accumulation texture" - }, - { - "VM_OCCLUSION", - BeCast( VM_OCCLUSION ), - "render occlusion geometry on top of the normal geometry" - }, +static Be::VarChooser VisualizerChooser[] = { + { "VM_NONE", + BeCast( VM_NONE ), + "No visualizer - use normal rendering" }, + { "VM_WHITE", + BeCast( VM_WHITE ), + "Pixel shader returns white (useful to verify that something is output)" }, + + { "VM_OBJECT_NORMAL", + BeCast( VM_OBJECT_NORMAL ), + "Normal from vertices" }, + { "VM_TANGENT", + BeCast( VM_TANGENT ), + "Tangent from vertices" }, + { "VM_BITANGENT", + BeCast( VM_BITANGENT ), + "Bitangent from vertices" }, + + { "VM_TEXCOORD0", + BeCast( VM_TEXCOORD0 ), + "Texture coordinate 0" }, + { "VM_TEXCOORD1", + BeCast( VM_TEXCOORD1 ), + "Texture coordinate 0" }, + + { "VM_TEXELDENSITY0", + BeCast( VM_TEXELDENSITY0 ), + "Density of texels mapped through texture coordinate 0" }, + { "VM_NORMALMAP", + BeCast( VM_NORMALMAP ), + "Tangent space normal from map" }, + { "VM_DIFFUSEMAP", + BeCast( VM_DIFFUSEMAP ), + "Diffuse map" }, + { "VM_SPECULARMAP", + BeCast( VM_SPECULARMAP ), + "Specular map" }, + { "VM_OVERDRAW", + BeCast( VM_OVERDRAW ), + "See the overdraw of the scene" }, + { "VM_EN_ONLY", + BeCast( VM_EN_ONLY ), + "Enlighten only)" }, + { "VM_DEPTH", + BeCast( VM_DEPTH ), + "See the depth buffer of the scene" }, + { "VM_ALL_LIGHTING", + BeCast( VM_ALL_LIGHTING ), + "See cummulative direct and secondary lighting" }, + { "VM_LIGHT_PRE_PASS_NORMALS", + BeCast( VM_LIGHT_PRE_PASS_NORMALS ), + "normal in worldspace from light pre-pass texture" }, + { "VM_LIGHT_PRE_PASS_DEPTH", + BeCast( VM_LIGHT_PRE_PASS_DEPTH ), + "depth in clip space from light pre-pass texture" }, + { "VM_LIGHT_PRE_PASS_WORLD_POSITION", + BeCast( VM_LIGHT_PRE_PASS_WORLD_POSITION ), + "world position from light pre-pass texture" }, + { "VM_LIGHT_PRE_PASS_LIGHTING", + BeCast( VM_LIGHT_PRE_PASS_LIGHTING ), + "resulting lighting from pre-pass light accumulation texture" }, + { "VM_LIGHT_PRE_PASS_LIGHT_OVERDRAW", + BeCast( VM_LIGHT_PRE_PASS_LIGHT_OVERDRAW ), + "light geometry overdraw during light accumulation pass" }, + { "VM_LIGHT_PRE_PASS_DIFFUSE_LIGHTING", + BeCast( VM_LIGHT_PRE_PASS_DIFFUSE_LIGHTING ), + "resulting deffuse lighting from pre-pass light accumulation texture" }, + { "VM_LIGHT_PRE_PASS_SPECULAR_LIGHTING", + BeCast( VM_LIGHT_PRE_PASS_SPECULAR_LIGHTING ), + "resulting specular lighting from pre-pass light accumulation texture" }, + { "VM_OCCLUSION", + BeCast( VM_OCCLUSION ), + "render occlusion geometry on top of the normal geometry" }, { 0 } }; // Register the enum as trinity.Tr2InteriorVisualizerMethod -BLUE_REGISTER_ENUM_EX( "Tr2InteriorVisualizerMethod", - VisualizeMethod, - VisualizerChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE ); - -static Be::VarChooser PickComponentChooser[] = -{ - { - "PICK_OBJECT", - BeCast( ITr2PickableScene::PICK_OBJECT ), - "Return object the mouse is over" - }, - { - "PICK_AREA", - BeCast( ITr2PickableScene::PICK_AREA ), - "Return mesh and area indexes of the object the mouse is over" - }, - { - "PICK_POSITION", - BeCast( ITr2PickableScene::PICK_POSITION ), - "Return world position of the point the mouse is over" - }, - { - "PICK_UV", - BeCast( ITr2PickableScene::PICK_UV ), - "Return object UV coordinates of the point the mouse is over" - }, +BLUE_REGISTER_ENUM_EX( "Tr2InteriorVisualizerMethod", + VisualizeMethod, + VisualizerChooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); + +static Be::VarChooser PickComponentChooser[] = { + { "PICK_OBJECT", + BeCast( ITr2PickableScene::PICK_OBJECT ), + "Return object the mouse is over" }, + { "PICK_AREA", + BeCast( ITr2PickableScene::PICK_AREA ), + "Return mesh and area indexes of the object the mouse is over" }, + { "PICK_POSITION", + BeCast( ITr2PickableScene::PICK_POSITION ), + "Return world position of the point the mouse is over" }, + { "PICK_UV", + BeCast( ITr2PickableScene::PICK_UV ), + "Return object UV coordinates of the point the mouse is over" }, { 0 } }; // Register the enum as trinity.Tr2PickComponent -BLUE_REGISTER_ENUM_EX( "Tr2PickComponent", - ITr2PickableScene::PickComponent, - PickComponentChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE ); +BLUE_REGISTER_ENUM_EX( "Tr2PickComponent", + ITr2PickableScene::PickComponent, + PickComponentChooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); #if BLUE_WITH_PYTHON -static PyObject* PyPick(PyObject* self, PyObject* args) +static PyObject* PyPick( PyObject* self, PyObject* args ) { TriPythonContext pythonCtx; Tr2InteriorScene* pThis = BluePythonCast( self ); @@ -183,14 +127,7 @@ static PyObject* PyPick(PyObject* self, PyObject* args) PyObject* pyViewport = NULL; int x, y, components; - if (!PyArg_ParseTuple(args, "iiOOOi", - &x, - &y, - &pyProjection, - &pyView, - &pyViewport, - &components - )) + if( !PyArg_ParseTuple( args, "iiOOOi", &x, &y, &pyProjection, &pyView, &pyViewport, &components ) ) { return NULL; } @@ -219,7 +156,7 @@ static PyObject* PyPick(PyObject* self, PyObject* args) results.area = 0; USE_MAIN_THREAD_RENDER_CONTEXT(); - pThis->PickObject(renderContext, x, y, projection, view, viewport, results ); + pThis->PickObject( renderContext, x, y, projection, view, viewport, results ); PyObject* result = PyDict_New(); if( results.components & ITr2PickableScene::PICK_OBJECT ) @@ -241,13 +178,13 @@ static PyObject* PyPick(PyObject* self, PyObject* args) } if( results.components & ITr2PickableScene::PICK_AREA ) { - unsigned int areaID = ((1<<8) - 1) & results.area; - unsigned int meshID = (results.area - areaID)>>8; + unsigned int areaID = ( ( 1 << 8 ) - 1 ) & results.area; + unsigned int meshID = ( results.area - areaID ) >> 8; PyObject* key = ToPython( ITr2PickableScene::PICK_AREA ); PyObject* value = PyTuple_New( 2 ); - PyTuple_SET_ITEM( value, 0, PyLong_FromUnsignedLong( meshID ) ); + PyTuple_SET_ITEM( value, 0, PyLong_FromUnsignedLong( meshID ) ); PyTuple_SET_ITEM( value, 1, PyLong_FromUnsignedLong( areaID - 1 ) ); PyDict_SetItem( result, key, value ); @@ -258,7 +195,7 @@ static PyObject* PyPick(PyObject* self, PyObject* args) if( results.components & ITr2PickableScene::PICK_POSITION ) { PyObject* key = ToPython( ITr2PickableScene::PICK_POSITION ); - PyObject* value = Py_BuildValue("(fff)", results.position.x, results.position.y, results.position.z ); + PyObject* value = Py_BuildValue( "(fff)", results.position.x, results.position.y, results.position.z ); PyDict_SetItem( result, key, value ); Py_DECREF( key ); Py_DECREF( value ); @@ -266,7 +203,7 @@ static PyObject* PyPick(PyObject* self, PyObject* args) if( results.components & ITr2PickableScene::PICK_UV ) { PyObject* key = ToPython( ITr2PickableScene::PICK_UV ); - PyObject* value = Py_BuildValue("(ff)", results.uv.x, results.uv.y ); + PyObject* value = Py_BuildValue( "(ff)", results.uv.x, results.uv.y ); PyDict_SetItem( result, key, value ); Py_DECREF( key ); Py_DECREF( value ); @@ -274,7 +211,7 @@ static PyObject* PyPick(PyObject* self, PyObject* args) return result; } -PyObject* PyPickObjectAndArea(PyObject* self, PyObject* args) +PyObject* PyPickObjectAndArea( PyObject* self, PyObject* args ) { TriPythonContext pythonCtx; Tr2InteriorScene* pThis = BluePythonCast( self ); @@ -284,13 +221,7 @@ PyObject* PyPickObjectAndArea(PyObject* self, PyObject* args) PyObject* pyViewport = NULL; int x, y; - if (!PyArg_ParseTuple(args, "iiOOO", - &x, - &y, - &pyProjection, - &pyView, - &pyViewport - )) + if( !PyArg_ParseTuple( args, "iiOOO", &x, &y, &pyProjection, &pyView, &pyViewport ) ) return NULL; TriProjection* projection = NULL; @@ -321,22 +252,22 @@ PyObject* PyPickObjectAndArea(PyObject* self, PyObject* args) if( results.object ) { - PyObject *result = PyTuple_New(2); - PyObject *meshAndArea = PyTuple_New(2); + PyObject* result = PyTuple_New( 2 ); + PyObject* meshAndArea = PyTuple_New( 2 ); - unsigned int areaID = ((1<<8) - 1) & results.area; - unsigned int meshID = (results.area - areaID)>>8; + unsigned int areaID = ( ( 1 << 8 ) - 1 ) & results.area; + unsigned int meshID = ( results.area - areaID ) >> 8; - PyTuple_SET_ITEM(meshAndArea, 0, PyLong_FromUnsignedLong(meshID)); + PyTuple_SET_ITEM( meshAndArea, 0, PyLong_FromUnsignedLong( meshID ) ); // areaID goes from 1 upwards, rebase to 0 - PyTuple_SET_ITEM(meshAndArea, 1, PyLong_FromUnsignedLong(areaID-1)); + PyTuple_SET_ITEM( meshAndArea, 1, PyLong_FromUnsignedLong( areaID - 1 ) ); - PyTuple_SET_ITEM(result, 0, PyOS->WrapBlueObject(results.object)); - PyTuple_SET_ITEM(result, 1, meshAndArea); + PyTuple_SET_ITEM( result, 0, PyOS->WrapBlueObject( results.object ) ); + PyTuple_SET_ITEM( result, 1, meshAndArea ); return result; } - Py_INCREF(Py_None); + Py_INCREF( Py_None ); return Py_None; } @@ -351,13 +282,7 @@ PyObject* PyInteriorPickPointAndObject( PyObject* self, PyObject* args ) PyObject* pyViewport = NULL; int x, y; - if (!PyArg_ParseTuple(args, "iiOOO", - &x, - &y, - &pyProjection, - &pyView, - &pyViewport - )) + if( !PyArg_ParseTuple( args, "iiOOO", &x, &y, &pyProjection, &pyView, &pyViewport ) ) return NULL; TriProjection* projection = NULL; @@ -387,13 +312,13 @@ PyObject* PyInteriorPickPointAndObject( PyObject* self, PyObject* args ) if( results.object ) { - PyObject *result = PyTuple_New(2); - PyTuple_SET_ITEM(result, 0, PyOS->WrapBlueObject(results.object) ); - PyTuple_SET_ITEM(result, 1, Py_BuildValue("(fff)", results.position.x, results.position.y, results.position.z ) ); + PyObject* result = PyTuple_New( 2 ); + PyTuple_SET_ITEM( result, 0, PyOS->WrapBlueObject( results.object ) ); + PyTuple_SET_ITEM( result, 1, Py_BuildValue( "(fff)", results.position.x, results.position.y, results.position.z ) ); return result; } - Py_INCREF(Py_None); + Py_INCREF( Py_None ); return Py_None; } #endif @@ -421,17 +346,17 @@ const Be::ClassInfo* Tr2InteriorScene::ExposeToBlue() MAP_ATTRIBUTE( "backgroundEffect", m_backgroundEffect, "The effect used to render the background behind any objects", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "backgroundCubemapPath", m_backgroundCubeMapPath, "The path used to load the background environment map", Be::READWRITE | Be::PERSIST | Be::NOTIFY, TriTextureChooser ) MAP_ATTRIBUTE( "backgroundCubemapRes", m_backgroundCubeMapRes, "The background environment map", Be::READ ) - + MAP_ATTRIBUTE_WITH_CHOOSER( "visualizeMethod", m_visualizeMethod, "Changes rendering to a visualizing method instead of normal rendering", Be::READWRITE | Be::ENUM | Be::NOTIFY, VisualizerChooser ) - MAP_ATTRIBUTE( "fogColor", m_fogColor, "Fog color", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxFogAmount", m_maxFogAmount, "Maximum fog density amount (from 0 to 1)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "minFogDistance", m_minFogDistance, "Distance where fog density starts to grow from 0", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "maxFogDistance", m_maxFogDistance, "Distance where fog reaches maximum density", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "fogColor", m_fogColor, "Fog color", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxFogAmount", m_maxFogAmount, "Maximum fog density amount (from 0 to 1)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "minFogDistance", m_minFogDistance, "Distance where fog density starts to grow from 0", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxFogDistance", m_maxFogDistance, "Distance where fog reaches maximum density", Be::READWRITE | Be::PERSIST ) - MAP_METHOD( - "Pick", - PyPick, + MAP_METHOD( + "Pick", + PyPick, "Given mouse position and a view setup, can return the object that the mouse is over, the mesh and area indices " "and object\'s texture coordinates" "\n returns dict (pick attribute -> value) or empty dict if nothing pickable was hit by the ray" @@ -447,12 +372,11 @@ const Be::ClassInfo* Tr2InteriorScene::ExposeToBlue() "\n:type viewport: TriViewport" "\n:param components: bitfield for components to pick" "\n:type components: int" - "\n:rtype: dict" - ) + "\n:rtype: dict" ) - MAP_METHOD( - "PickObjectAndArea", - PyPickObjectAndArea, + MAP_METHOD( + "PickObjectAndArea", + PyPickObjectAndArea, "Given mouse position and a view setup, returns the object that the mouse is over, as well as the mesh and area indices" "\n returns (,(,)) or None if nothing pickable was hit by the ray" "\n:param x: integer x coordinate of the mouse over the viewport" @@ -465,12 +389,11 @@ const Be::ClassInfo* Tr2InteriorScene::ExposeToBlue() "\n:type view: TriView" "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" "\n:type viewport: TriViewport" - "\n:rtype: None | tuple" - ) - - MAP_METHOD( - "PickPointAndObject", - PyInteriorPickPointAndObject, + "\n:rtype: None | tuple" ) + + MAP_METHOD( + "PickPointAndObject", + PyInteriorPickPointAndObject, "Given mouse position and a view setup, returns the object that the mouse is over, as well as the mesh and area indices" "\n returns (,(x,y,z)) or None if nothing pickable was hit by the ray" "\n:param x: integer x coordinate of the mouse over the viewport" @@ -483,12 +406,11 @@ const Be::ClassInfo* Tr2InteriorScene::ExposeToBlue() "\n:type view: TriView" "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" "\n:type viewport: TriViewport" - "\n:rtype: None | tuple" - ) - - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "PickObject", - PickObjectOnly, + "\n:rtype: None | tuple" ) + + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "PickObject", + PickObjectOnly, 1, "Given mouse position and a view setup, returns the object that the mouse is over, as well as the mesh and area indices" "\nreturns or None if nothing pickable was hit by the ray" @@ -497,77 +419,73 @@ const Be::ClassInfo* Tr2InteriorScene::ExposeToBlue() "\n:param projection: The TriProjection to use to pick into the scene" "\n:param view: The TriView to use to pick into the scene" "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" - "\n:param filter: Bitfield of pickable object types" - ) + "\n:param filter: Bitfield of pickable object types" ) - MAP_METHOD_AND_WRAP( - "PickObjectUV", - PickObjectUV, + MAP_METHOD_AND_WRAP( + "PickObjectUV", + PickObjectUV, "Given mouse position and a view setup, returns the UV coordinates of the texel the mouse is over." "\nreturns 2-float tuple with UV coordinates" "\n:param x: integer x coordinate of the mouse over the viewport" "\n:param y: integer y coordinate of the mouse over the viewport" "\n:param projection: The TriProjection to use to pick into the scene" "\n:param view: The TriView to use to pick into the scene" - "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" - ) + "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" ) MAP_METHOD_AND_WRAP( "RebuildSceneData", RebuildSceneData, "Rebuilds the internal data in all cells" ) - MAP_METHOD_AND_WRAP( - "AddLightSource", - AddLightSource, + MAP_METHOD_AND_WRAP( + "AddLightSource", + AddLightSource, "Add an interior lightsource to the scene" "\n:param light: The light to add" ) - MAP_METHOD_AND_WRAP( - "RemoveLightSource", - RemoveLightSource, + MAP_METHOD_AND_WRAP( + "RemoveLightSource", + RemoveLightSource, "Remove an interior lightsource from the scene" "\n:param light: The light to remove" ) - MAP_METHOD_AND_WRAP( - "AddDynamic", - AddDynamic, + MAP_METHOD_AND_WRAP( + "AddDynamic", + AddDynamic, "Add an interior dynamic (avatar, placeable, etc.) to the scene" - "\n:param object: The ITr2InteriorDynamic (Tr2InteriorPlaceable or Tr2InteriorAvatar) to add") + "\n:param object: The ITr2InteriorDynamic (Tr2InteriorPlaceable or Tr2InteriorAvatar) to add" ) - MAP_METHOD_AND_WRAP( - "RemoveDynamic", - RemoveDynamic, + MAP_METHOD_AND_WRAP( + "RemoveDynamic", + RemoveDynamic, "Remove an interior dynamic (avatar, placeable, etc.) from the scene" - "\n:param object: The ITr2InteriorDynamic (Tr2InteriorPlaceable or Tr2InteriorAvatar) to remove") + "\n:param object: The ITr2InteriorDynamic (Tr2InteriorPlaceable or Tr2InteriorAvatar) to remove" ) MAP_METHOD_AND_WRAP( - "UpdateScene", - UpdateSceneFromScript, + "UpdateScene", + UpdateSceneFromScript, "Run the scene's update loop\n" ":param time: current time" ) MAP_METHOD_AND_WRAP( "SetupShadowMaps", SetupShadowMaps, - "Set up the shadow render targets") + "Set up the shadow render targets" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "debugRenderer", m_debugRenderer, "Object used for rendering debug information", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "visibilityResults", m_visibilityResults, "Results of the visibility query", Be::READ ) - MAP_ATTRIBUTE( "shadowCount", m_shadowCount, "Amount of shadows allowed", Be::READWRITE | Be::NOTIFY) + MAP_ATTRIBUTE( "shadowCount", m_shadowCount, "Amount of shadows allowed", Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "shadowSize", m_shadowSize, "Size of shadows", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE("shadowSize", m_shadowSize, "Size of shadows", Be::READWRITE | Be::NOTIFY) + MAP_ATTRIBUTE( "optimizeShadows", m_optimizeShadows, "Should we shrink the light frustum to camera view?", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE("optimizeShadows", m_optimizeShadows, "Should we shrink the light frustum to camera view?", Be::READWRITE | Be::NOTIFY) + MAP_ATTRIBUTE( "renderShadows", m_renderShadows, "", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE("renderShadows", m_renderShadows, "", Be::READWRITE | Be::NOTIFY) - - MAP_ATTRIBUTE("debugRenderShadowMaps", m_debugRenderShadowMaps, "", Be::READWRITE | Be::NOTIFY) + MAP_ATTRIBUTE( "debugRenderShadowMaps", m_debugRenderShadowMaps, "", Be::READWRITE | Be::NOTIFY ) EXPOSURE_END() } diff --git a/trinity/Lights/ITr2LightOwner.h b/trinity/Lights/ITr2LightOwner.h index 0b31a1304..6ba26346d 100644 --- a/trinity/Lights/ITr2LightOwner.h +++ b/trinity/Lights/ITr2LightOwner.h @@ -10,8 +10,8 @@ BLUE_DECLARE( Tr2Light ); BLUE_INTERFACE( ITr2LightOwner ) : public IRoot { - virtual void GetLights( Tr2LightManager& lightManager ) const = 0; - virtual void AddLight( Tr2Light* light ) {}; + virtual void GetLights( Tr2LightManager & lightManager ) const = 0; + virtual void AddLight( Tr2Light * light ){}; virtual void ClearLights() {}; }; diff --git a/trinity/Lights/Tr2FactionLight.cpp b/trinity/Lights/Tr2FactionLight.cpp index 7ff15d40f..0386e7d5e 100644 --- a/trinity/Lights/Tr2FactionLight.cpp +++ b/trinity/Lights/Tr2FactionLight.cpp @@ -4,9 +4,9 @@ #include "Tr2FactionLight.h" -Tr2FactionLight::Tr2FactionLight( IRoot* lockobj ): +Tr2FactionLight::Tr2FactionLight( IRoot* lockobj ) : Tr2Light( lockobj ), - m_selectedColor( -1 ), + m_selectedColor( -1 ), m_isSpotlight( false ), m_parentColorSet( nullptr ), m_saturation( 1.0f ) @@ -18,7 +18,7 @@ bool Tr2FactionLight::OnModified( Be::Var* value ) { if( IsMatch( value, m_isSpotlight ) ) { - m_isSpotlight? m_type = SPOT_LIGHT: m_type = POINT_LIGHT; + m_isSpotlight ? m_type = SPOT_LIGHT : m_type = POINT_LIGHT; } if( IsMatch( value, m_selectedColor ) ) @@ -49,11 +49,11 @@ void Tr2FactionLight::SetLightColorFromFactionColor() void Tr2FactionLight::SetInheritProperties( const Color* colorSet ) { - if ( colorSet ) - { + if( colorSet ) + { m_parentColorSet = colorSet; SetLightColorFromFactionColor(); - } + } } Color Tr2FactionLight::GetSelectedColor() const @@ -82,7 +82,6 @@ void Tr2FactionLight::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matri renderer.DrawCone( this, lightMatrix, m_lightData.radius, outerAngle, 15, 15, Tr2DebugRenderer::Solid, Tr2DebugColor( baseColor + colorMod * 2.0f, baseColor ) ); renderer.DrawCone( this, lightMatrix, m_lightData.innerRadius, innerAngle, 15, 15, Tr2DebugRenderer::Solid, Tr2DebugColor( baseColor + colorMod * 3.0f, baseColor + colorMod ) ); - } else { @@ -91,13 +90,13 @@ void Tr2FactionLight::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matri auto selectedColor = baseColor + Color( 0.0, 0.0, 0.0, 0.2 ); Matrix lightMatrix = m_boneTransform; - if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) { + if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) + { TriMatrixCopyFrom3x4( &lightMatrix, &bones[m_lightData.boneIndex] ); } lightMatrix *= worldMatrix; renderer.DrawSphere( this, lightMatrix, m_lightData.position, m_lightData.radius, 10, Tr2DebugRenderer::Solid, Tr2DebugColor( selectedColor, baseColor ) ); - renderer.DrawSphere( this, lightMatrix, m_lightData.position, m_lightData.innerRadius, 10, Tr2DebugRenderer::Solid, Tr2DebugColor( selectedColor, baseColor) ); + renderer.DrawSphere( this, lightMatrix, m_lightData.position, m_lightData.innerRadius, 10, Tr2DebugRenderer::Solid, Tr2DebugColor( selectedColor, baseColor ) ); } } - diff --git a/trinity/Lights/Tr2FactionLight.h b/trinity/Lights/Tr2FactionLight.h index ab047a885..f80e4c52d 100644 --- a/trinity/Lights/Tr2FactionLight.h +++ b/trinity/Lights/Tr2FactionLight.h @@ -7,19 +7,19 @@ class Tr2LightManager; -BLUE_CLASS( Tr2FactionLight ): +BLUE_CLASS( Tr2FactionLight ) : public Tr2Light, public IEveInheritPropertiesOwner { public: EXPOSE_TO_BLUE(); - Tr2FactionLight( IRoot* lockobj = nullptr ); + Tr2FactionLight( IRoot* lockobj = nullptr ); - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; - void SetInheritProperties( const Color* colorSet ) override; - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0) override; - Color GetSelectedColor() const; + void SetInheritProperties( const Color* colorSet ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ) override; + Color GetSelectedColor() const; private: void SetLightColorFromFactionColor(); @@ -27,7 +27,7 @@ BLUE_CLASS( Tr2FactionLight ): float m_saturation; bool m_isSpotlight; const Color* m_parentColorSet; - int m_selectedColor; + int m_selectedColor; }; TYPEDEF_BLUECLASS( Tr2FactionLight ); \ No newline at end of file diff --git a/trinity/Lights/Tr2FactionLight_Blue.cpp b/trinity/Lights/Tr2FactionLight_Blue.cpp index 8e2b74880..fe3dc9c56 100644 --- a/trinity/Lights/Tr2FactionLight_Blue.cpp +++ b/trinity/Lights/Tr2FactionLight_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2FactionLight ); const Be::ClassInfo* Tr2FactionLight::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2FactionLight, "" ) + EXPOSURE_BEGIN( Tr2FactionLight, "" ) MAP_INTERFACE( Tr2FactionLight ) MAP_INTERFACE( IEveInheritPropertiesOwner ) MAP_INTERFACE( Tr2Light ) @@ -24,9 +24,9 @@ const Be::ClassInfo* Tr2FactionLight::ExposeToBlue() MAP_ATTRIBUTE( "innerRadius", m_lightData.innerRadius, "Inner light radius (to mimick a glowing sphere)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "brightness", m_lightData.brightness, "Light brightness (modulates color) for easier animation\n:jessica-group: color", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "saturation", m_saturation,"[0:inf] 0=grayscale 1=normal (output capped so feel free to over-saturate)\n:jessica-group: color", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE_WITH_CHOOSER("factionColor", m_selectedColor, "Light color\n:jessica-group: color", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) - MAP_PROPERTY_READONLY( "selectedColor", GetSelectedColor, "Light color helper\n:jessica-group: color" ) + MAP_ATTRIBUTE( "saturation", m_saturation, "[0:inf] 0=grayscale 1=normal (output capped so feel free to over-saturate)\n:jessica-group: color", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE_WITH_CHOOSER( "factionColor", m_selectedColor, "Light color\n:jessica-group: color", Be::READWRITE | Be::PERSIST | Be::NOTIFY | Be::ENUM, SOFDataFactionColorChooser::EveSOFDataFactionColorSetTypeChooser ) + MAP_PROPERTY_READONLY( "selectedColor", GetSelectedColor, "Light color helper\n:jessica-group: color" ) MAP_ATTRIBUTE( "isSpotlight", m_isSpotlight, "if the light behaves as a spotLight or a pointLight\n:jessica-group: SpotlightOptions", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "rotation", m_lightData.rotation, "Light rotation\n:jessica-group: SpotlightOptions", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Lights/Tr2Light.cpp b/trinity/Lights/Tr2Light.cpp index b97fd8828..20214c932 100644 --- a/trinity/Lights/Tr2Light.cpp +++ b/trinity/Lights/Tr2Light.cpp @@ -30,7 +30,7 @@ LightData::LightData() : LightFeatures::LightFeatures() : parentBrightness( 1.0f ), parentScale( 1.0f ), - profileIndex( 0 ) + profileIndex( 0 ) { } @@ -59,14 +59,12 @@ Tr2LightManager::PerLightData LightData::AsPerPointLightData( CXMMATRIX transfor data.innerAngle = Float_16( 0.0f ); data.projectionPlaneDistance = Float_16( 1.f / tan( TRI_2PI * 45.f / 360.0f ) ); - if ( castsShadows == PerLightShadowSetting::ALWAYS_ENABLED - || (castsShadows == PerLightShadowSetting::ENABLED_ONLY_ON_HIGH_QUALITY && shadowQuality == ShadowQuality::SHADOW_HIGH) - || (castsShadows == PerLightShadowSetting::ENABLED_ONLY_ON_HIGH_QUALITY && shadowQuality == ShadowQuality::SHADOW_RAYTRACED) ) + if( castsShadows == PerLightShadowSetting::ALWAYS_ENABLED || ( castsShadows == PerLightShadowSetting::ENABLED_ONLY_ON_HIGH_QUALITY && shadowQuality == ShadowQuality::SHADOW_HIGH ) || ( castsShadows == PerLightShadowSetting::ENABLED_ONLY_ON_HIGH_QUALITY && shadowQuality == ShadowQuality::SHADOW_RAYTRACED ) ) { data.flags |= Tr2LightManager::FLAG_CASTS_SHADOWS; } data.flags |= isVolumetric ? Tr2LightManager::FLAG_IS_VOLUMETRIC : 0; - + return data; } @@ -97,7 +95,7 @@ void Tr2Light::SetLightData( LightData& baseData ) m_lightData = baseData; } -void Tr2Light::SetBoneMatrix( const Float4x3* bones, size_t boneCount ) +void Tr2Light::SetBoneMatrix( const Float4x3* bones, size_t boneCount ) { if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) { @@ -149,7 +147,7 @@ void Tr2Light::AddLight( Tr2LightManager& lightManager, CXMMATRIX transform, flo lightManager.AddLight( data ); } } - + void Tr2Light::GetLight( Vector3& position, float& radius, Color& color ) { @@ -202,10 +200,8 @@ float Tr2Light::GetBrightnessMultiplier() const void Tr2Light::Update() { - } void Tr2Light::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones, size_t boneCount ) { - } diff --git a/trinity/Lights/Tr2Light.h b/trinity/Lights/Tr2Light.h index 1ad02000d..1a1a605f1 100644 --- a/trinity/Lights/Tr2Light.h +++ b/trinity/Lights/Tr2Light.h @@ -8,7 +8,8 @@ BLUE_DECLARE( Tr2LightProfileRes ); -struct LightFeatures { +struct LightFeatures +{ LightFeatures(); int16_t profileIndex; @@ -23,7 +24,8 @@ enum class PerLightShadowSetting ALWAYS_ENABLED }; -struct LightData { +struct LightData +{ LightData(); Tr2LightManager::PerLightData AsPerPointLightData( CXMMATRIX transform, LightFeatures& features, ShadowQuality shadowQuality ) const; Tr2LightManager::PerLightData AsPerSpotLightData( CXMMATRIX transform, LightFeatures& features, ShadowQuality shadowQuality ) const; @@ -77,13 +79,13 @@ BLUE_CLASS( Tr2Light ) : EXPOSE_TO_BLUE(); Tr2Light( IRoot* lockobj = nullptr ); - void AddLight( Tr2LightManager& lightManager, CXMMATRIX transform, float scale, const Float4x3* bones = nullptr, size_t boneCount = 0 ); - void GetLight( Vector3& position, float& radius, Color& color ); + void AddLight( Tr2LightManager & lightManager, CXMMATRIX transform, float scale, const Float4x3* bones = nullptr, size_t boneCount = 0 ); + void GetLight( Vector3 & position, float& radius, Color& color ); void ChangeLightColor( Color c ); virtual void Update(); - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ); - virtual void SetLightData( LightData& baseData ); + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ); + virtual void SetLightData( LightData & baseData ); void SetBoneMatrix( const Float4x3* bones, size_t boneCount ); void SetBrightnessMultiplier( float multi ); @@ -91,7 +93,7 @@ BLUE_CLASS( Tr2Light ) : bool Initialize() override; // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); const LightData& GetLightData() const; float GetBrightnessMultiplier() const; diff --git a/trinity/Lights/Tr2PointLight.cpp b/trinity/Lights/Tr2PointLight.cpp index 5a440c912..bc0ccb794 100644 --- a/trinity/Lights/Tr2PointLight.cpp +++ b/trinity/Lights/Tr2PointLight.cpp @@ -18,7 +18,8 @@ void Tr2PointLight::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& auto selectedColor = baseColor + Color( 0.0, 0.0, 0.0, 0.2 ); Matrix lightMatrix = m_boneTransform; - if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) { + if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) + { TriMatrixCopyFrom3x4( &lightMatrix, &bones[m_lightData.boneIndex] ); } lightMatrix *= worldMatrix; diff --git a/trinity/Lights/Tr2PointLight.h b/trinity/Lights/Tr2PointLight.h index dad950c11..4dd54a0d4 100644 --- a/trinity/Lights/Tr2PointLight.h +++ b/trinity/Lights/Tr2PointLight.h @@ -12,7 +12,7 @@ BLUE_CLASS( Tr2PointLight ) : EXPOSE_TO_BLUE(); Tr2PointLight( IRoot* lockobj = nullptr ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ) override; }; TYPEDEF_BLUECLASS( Tr2PointLight ); \ No newline at end of file diff --git a/trinity/Lights/Tr2SpotLight.cpp b/trinity/Lights/Tr2SpotLight.cpp index bdd1bff5d..f976c1ba3 100644 --- a/trinity/Lights/Tr2SpotLight.cpp +++ b/trinity/Lights/Tr2SpotLight.cpp @@ -7,28 +7,29 @@ #include "Tr2LightManager.h" #include "Include/TriMath.h" -Tr2SpotLight::Tr2SpotLight( IRoot* lockobj ): +Tr2SpotLight::Tr2SpotLight( IRoot* lockobj ) : Tr2Light( lockobj ) { m_type = SPOT_LIGHT; } -void Tr2SpotLight::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones, size_t boneCount ) +void Tr2SpotLight::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones, size_t boneCount ) { auto baseColor = m_lightData.color * m_lightData.brightness; baseColor.a = 0.025f; auto colorMod = Color( 0.0f, 0.0f, 0.0f, 0.025f ); Matrix boneMatrix = m_boneTransform; - if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) { + if( m_lightData.boneIndex >= 0 && m_lightData.boneIndex < boneCount ) + { TriMatrixCopyFrom3x4( &boneMatrix, &bones[m_lightData.boneIndex] ); } - Matrix lightMatrix = RotationMatrix(m_lightData.rotation) * TranslationMatrix(m_lightData.position) * boneMatrix * worldMatrix; + Matrix lightMatrix = RotationMatrix( m_lightData.rotation ) * TranslationMatrix( m_lightData.position ) * boneMatrix * worldMatrix; float outerAngle = TRI_2PI * m_lightData.outerAngle / 360.f; float innerAngle = TRI_2PI * m_lightData.innerAngle / 360.f; renderer.DrawCone( this, lightMatrix, m_lightData.radius, outerAngle, 15, 15, Tr2DebugRenderer::Solid, Tr2DebugColor( baseColor + colorMod * 2.0f, baseColor ) ); - renderer.DrawCone( this, lightMatrix, m_lightData.innerRadius, innerAngle, 15, 15, Tr2DebugRenderer::Solid, Tr2DebugColor( baseColor + colorMod * 3.0f, baseColor + colorMod ) ); + renderer.DrawCone( this, lightMatrix, m_lightData.innerRadius, innerAngle, 15, 15, Tr2DebugRenderer::Solid, Tr2DebugColor( baseColor + colorMod * 3.0f, baseColor + colorMod ) ); } \ No newline at end of file diff --git a/trinity/Lights/Tr2SpotLight.h b/trinity/Lights/Tr2SpotLight.h index 714895734..6edd18a93 100644 --- a/trinity/Lights/Tr2SpotLight.h +++ b/trinity/Lights/Tr2SpotLight.h @@ -6,7 +6,7 @@ class Tr2LightManager; -BLUE_CLASS( Tr2SpotLight ): +BLUE_CLASS( Tr2SpotLight ) : public Tr2Light { public: @@ -14,7 +14,7 @@ BLUE_CLASS( Tr2SpotLight ): Tr2SpotLight( IRoot* lockobj = nullptr ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ) override; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldMatrix, const Float4x3* bones = nullptr, size_t boneCount = 0 ) override; }; TYPEDEF_BLUECLASS( Tr2SpotLight ); \ No newline at end of file diff --git a/trinity/Lights/Tr2SpotLight_Blue.cpp b/trinity/Lights/Tr2SpotLight_Blue.cpp index 029ec639e..01535c91b 100644 --- a/trinity/Lights/Tr2SpotLight_Blue.cpp +++ b/trinity/Lights/Tr2SpotLight_Blue.cpp @@ -22,10 +22,10 @@ const Be::ClassInfo* Tr2SpotLight::ExposeToBlue() MAP_ATTRIBUTE( "radius", m_lightData.radius, "Outer radius of the spotlight (length)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "innerRadius", m_lightData.innerRadius, "Inner radius of the spotlight (determines fuzzyness)", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "innerAngle", m_lightData.innerAngle, "Inner angle of the spotlight (in degrees)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "outerAngle", m_lightData.outerAngle, "Outer angle of the spotlight (in degrees)", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "color", m_lightData.color, "Light color (in linear space)\n:jessica-tuple-type: linearcolor", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "brightness", m_lightData.brightness, "Light brightness (modulates color) for easier animation", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) diff --git a/trinity/Lights/Tr2TexturedPointLight.cpp b/trinity/Lights/Tr2TexturedPointLight.cpp index c55d46e41..ef7b9adc8 100644 --- a/trinity/Lights/Tr2TexturedPointLight.cpp +++ b/trinity/Lights/Tr2TexturedPointLight.cpp @@ -34,7 +34,8 @@ void Tr2TexturedPointLight::SetTexturePath( std::wstring path ) BeResMan->GetResource( path, L"", m_texture ); } -void Tr2TexturedPointLight::SetSaturation( float saturation ) { +void Tr2TexturedPointLight::SetSaturation( float saturation ) +{ m_saturation = saturation; } @@ -44,7 +45,7 @@ bool Tr2TexturedPointLight::OnModified( Be::Var* value ) { SetTexturePath( m_lightData.texturePath ); } - return Tr2PointLight::OnModified(value); + return Tr2PointLight::OnModified( value ); } void Tr2TexturedPointLight::Update() diff --git a/trinity/Lights/Tr2TexturedPointLight.h b/trinity/Lights/Tr2TexturedPointLight.h index 6c5e57d85..ad6937301 100644 --- a/trinity/Lights/Tr2TexturedPointLight.h +++ b/trinity/Lights/Tr2TexturedPointLight.h @@ -7,7 +7,7 @@ BLUE_DECLARE( TriTextureRes ); -BLUE_CLASS( Tr2TexturedPointLight ): +BLUE_CLASS( Tr2TexturedPointLight ) : public Tr2PointLight { public: @@ -16,12 +16,13 @@ BLUE_CLASS( Tr2TexturedPointLight ): EXPOSE_TO_BLUE(); bool Initialize() override; - bool OnModified( Be::Var* value ) override; - void SetLightData( LightData& data ) override; + bool OnModified( Be::Var * value ) override; + void SetLightData( LightData & data ) override; void SetSaturation( float saturation ); protected: void Update() override; + private: void SetTexturePath( std::wstring path ); TriTextureResPtr m_texture; diff --git a/trinity/Lights/Tr2TexturedPointLight_Blue.cpp b/trinity/Lights/Tr2TexturedPointLight_Blue.cpp index 834ad8714..029a2ed4e 100644 --- a/trinity/Lights/Tr2TexturedPointLight_Blue.cpp +++ b/trinity/Lights/Tr2TexturedPointLight_Blue.cpp @@ -19,10 +19,10 @@ const Be::ClassInfo* Tr2TexturedPointLight::ExposeToBlue() MAP_ATTRIBUTE( "position", m_lightData.position, "Light position", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotation", m_lightData.rotation, "Light rotation", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "boneIndex", m_lightData.boneIndex, "The bone index that this light is connected to\n:jessica-widget: boneindex", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - + MAP_ATTRIBUTE( "radius", m_lightData.radius, "Light radius", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "innerRadius", m_lightData.innerRadius, "Inner light radius (to mimick a glowing sphere)", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "color", m_lightData.color, "Light color (in linear space)\n:jessica-tuple-type: linearcolor", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "brightness", m_lightData.brightness, "Light brightness (modulates color) for easier animation", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) diff --git a/trinity/Particle/ITr2GenericEmitter.h b/trinity/Particle/ITr2GenericEmitter.h index 1c5564087..858402948 100644 --- a/trinity/Particle/ITr2GenericEmitter.h +++ b/trinity/Particle/ITr2GenericEmitter.h @@ -9,19 +9,19 @@ BLUE_DECLARE( Tr2GpuParticleSystem ); // -------------------------------------------------------------------------------------- // Description: -// ITr2GenericEmitter is an interface for particle emitters used with +// ITr2GenericEmitter is an interface for particle emitters used with // Tr2ParticleSystem. // See Also: // Tr2DynamicEmitter, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2GenericEmitter ): +BLUE_INTERFACE( ITr2GenericEmitter ) : public IRoot { // Arguments passed to Update method struct UpdateArguments { - UpdateArguments() - :time( 0 ), + UpdateArguments() : + time( 0 ), system( nullptr ), parentTransform( XMMatrixIdentity() ), originShift( 0.f, 0.f, 0.f ), @@ -29,8 +29,8 @@ BLUE_INTERFACE( ITr2GenericEmitter ): { } - UpdateArguments( Be::Time t, Tr2GpuParticleSystem* gpuSystem, const Matrix& transform, const Vector3& shift, float emitFactor = 1.f ) - :time( t ), + UpdateArguments( Be::Time t, Tr2GpuParticleSystem* gpuSystem, const Matrix& transform, const Vector3& shift, float emitFactor = 1.f ) : + time( t ), system( gpuSystem ), parentTransform( transform ), originShift( shift ), @@ -60,7 +60,7 @@ BLUE_INTERFACE( ITr2GenericEmitter ): // -------------------------------------------------------------------------------------- // Description: - // Spawns new particles. Can be called from Tr2ParticleSystem for "emit during + // Spawns new particles. Can be called from Tr2ParticleSystem for "emit during // lifetime" or "emit on death" emitters. // Arguments: // position - Position of the "parent" particle (if the emitter owning this generator @@ -73,14 +73,14 @@ BLUE_INTERFACE( ITr2GenericEmitter ): // defined value. // -------------------------------------------------------------------------------------- virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3* position = nullptr, - const Vector3* velocity = nullptr, + const Vector3* position = nullptr, + const Vector3* velocity = nullptr, float rateModifier = 1.0f ) = 0; - + // -------------------------------------------------------------------------------------- // Description: - // Spawns new particles. Can be called from Tr2ParticleSystem for "emit during + // Spawns new particles. Can be called from Tr2ParticleSystem for "emit during // lifetime" or "emit on death" emitters. Particle position and velocity values // are provided for both beginning and end of frame, for better distribution. // Arguments: @@ -91,8 +91,10 @@ BLUE_INTERFACE( ITr2GenericEmitter ): // deltaTime - particle simulation delta-time // -------------------------------------------------------------------------------------- virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ) = 0; // -------------------------------------------------------------------------------------- diff --git a/trinity/Particle/ITr2GenericParticleConstraint.h b/trinity/Particle/ITr2GenericParticleConstraint.h index b0ccf756e..d8a31f3ae 100644 --- a/trinity/Particle/ITr2GenericParticleConstraint.h +++ b/trinity/Particle/ITr2GenericParticleConstraint.h @@ -18,7 +18,8 @@ struct ITr2DebugRenderer2; // See Also: // Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2GenericParticleConstraint ) : public IRoot +BLUE_INTERFACE( ITr2GenericParticleConstraint ) : + public IRoot { // ---------------------------------------------------------------------------------- // Description: @@ -26,7 +27,7 @@ BLUE_INTERFACE( ITr2GenericParticleConstraint ) : public IRoot // asyncronously. // Arguments: // arguments - arguments for child emitters - // paticles - Particle data stream: Tr2ParticleElementData::COUNT of float arrays. + // paticles - Particle data stream: Tr2ParticleElementData::COUNT of float arrays. // The constraint can modify any data element of a particle. // strides - Sizes of particle data in each of "particles" arrays (in floats). // count - Number of particles. @@ -36,12 +37,12 @@ BLUE_INTERFACE( ITr2GenericParticleConstraint ) : public IRoot // ---------------------------------------------------------------------------------- // Description: - // A chance for constraint to bind itself to a particle system. Called when + // A chance for constraint to bind itself to a particle system. Called when // constaint is added to the particle system or when system is re-binded. // Arguments: // system - Particle system the constaint is attached to. // ---------------------------------------------------------------------------------- - virtual void Bind( Tr2ParticleSystem* system ) = 0; + virtual void Bind( Tr2ParticleSystem * system ) = 0; virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const { diff --git a/trinity/Particle/ITr2ParticleForce.h b/trinity/Particle/ITr2ParticleForce.h index 342e05467..29f706d7d 100644 --- a/trinity/Particle/ITr2ParticleForce.h +++ b/trinity/Particle/ITr2ParticleForce.h @@ -6,11 +6,12 @@ struct ITr2DebugRenderer2; -BLUE_INTERFACE( ITr2ParticleForce ) : public IRoot +BLUE_INTERFACE( ITr2ParticleForce ) : + public IRoot { virtual void Update( float dt ) = 0; virtual XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ) = 0; - virtual void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const + virtual void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const { } }; diff --git a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.cpp b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.cpp index e0ebb03de..1ff14c240 100644 --- a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.cpp +++ b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.cpp @@ -22,8 +22,8 @@ inline float frand( float a, float b ) // Description: // Tr2CapsuleShapeAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2CapsuleShapeAttributeGenerator::Tr2CapsuleShapeAttributeGenerator() - :m_positionStart( 0.0f, 0.0f, 0.0f ), +Tr2CapsuleShapeAttributeGenerator::Tr2CapsuleShapeAttributeGenerator() : + m_positionStart( 0.0f, 0.0f, 0.0f ), m_positionEnd( 0.0f, 0.0f, 0.0f ), m_rotationStart( 0.f, 0.f, 0.f, 1.f ), m_rotationEnd( 0.f, 0.f, 0.f, 1.f ), @@ -53,35 +53,35 @@ Tr2CapsuleShapeAttributeGenerator::~Tr2CapsuleShapeAttributeGenerator() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates random values for new +// Implements ITr2AttributeGenerator interface. Generates random values for new // particle component (element). // Arguments: // position - Position of the "parent" particle. // velocity - Velocity of the "parent" particle. -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills position and/or velocity of the new particle. // -------------------------------------------------------------------------------------- -void Tr2CapsuleShapeAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, - float** particle ) +void Tr2CapsuleShapeAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, + float** particle ) { if( !m_valid ) { return; } - + float phi = XMConvertToRadians( frand( m_minPhi, m_maxPhi ) ); float theta = XMConvertToRadians( frand( m_minTheta, m_maxTheta ) ); // This is not exactly uniform, but it doesn't matter - XMVECTOR randomVector = XMVectorSet( sin( phi ) * cos( theta ), - -cos( phi ), - sin( phi ) * sin( theta ), + XMVECTOR randomVector = XMVectorSet( sin( phi ) * cos( theta ), + -cos( phi ), + sin( phi ) * sin( theta ), 0.f ); float t = frand( 0.f, 1.f ); XMVECTOR rotation = XMQuaternionSlerp( m_rotationStart, m_rotationEnd, t ); - randomVector = XMQuaternionMultiply( - XMQuaternionMultiply( XMQuaternionConjugate( rotation ), randomVector ), + randomVector = XMQuaternionMultiply( + XMQuaternionMultiply( XMQuaternionConjugate( rotation ), randomVector ), rotation ); if( m_controlVelocity && m_velocityElement.m_offset != -1 ) @@ -90,12 +90,12 @@ void Tr2CapsuleShapeAttributeGenerator::Generate( const Vector3* position, XMVECTOR particleVelocity = XMVectorScale( randomVector, speed ); if( velocity ) { - particleVelocity = XMVectorAdd( - particleVelocity, + particleVelocity = XMVectorAdd( + particleVelocity, XMVectorScale( XMLoadFloat4A( reinterpret_cast( velocity ) ), m_parentVelocityFactor ) ); } - XMStoreFloat4A( - reinterpret_cast( particle[m_velocityElement.m_bufferType] + m_velocityElement.m_offset ), + XMStoreFloat4A( + reinterpret_cast( particle[m_velocityElement.m_bufferType] + m_velocityElement.m_offset ), particleVelocity ); } if( m_positionElement.m_offset != -1 ) @@ -103,20 +103,18 @@ void Tr2CapsuleShapeAttributeGenerator::Generate( const Vector3* position, randomVector = XMVectorScale( randomVector, frand( m_minRadius, m_maxRadius ) ); if( position ) { - randomVector = XMVectorAdd( - randomVector, + randomVector = XMVectorAdd( + randomVector, XMLoadFloat4A( reinterpret_cast( position ) ) ); } - randomVector = XMVectorAdd( - randomVector, + randomVector = XMVectorAdd( + randomVector, XMVectorLerp( XMLoadFloat4( reinterpret_cast( &m_positionStart ) ), XMLoadFloat4( reinterpret_cast( &m_positionEnd ) ), - t - ) - ); - XMStoreFloat4A( - reinterpret_cast( particle[m_positionElement.m_bufferType] + m_positionElement.m_offset ), + t ) ); + XMStoreFloat4A( + reinterpret_cast( particle[m_positionElement.m_bufferType] + m_positionElement.m_offset ), randomVector ); } } @@ -128,17 +126,17 @@ void Tr2CapsuleShapeAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2CapsuleShapeAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2CapsuleShapeAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; m_positionElement.m_offset = -1; @@ -184,7 +182,7 @@ bool Tr2CapsuleShapeAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. @@ -207,11 +205,11 @@ std::string Tr2CapsuleShapeAttributeGenerator::GetName() const // endPosition - Ending emitter position. // endRotation - Ending emitter orientation. // -------------------------------------------------------------------------------------- -void Tr2CapsuleShapeAttributeGenerator::SetPositions( - const Vector3& startPosition, - const Quaternion& startRotation, - const Vector3& endPosition, - const Quaternion& endRotation ) +void Tr2CapsuleShapeAttributeGenerator::SetPositions( + const Vector3& startPosition, + const Quaternion& startRotation, + const Vector3& endPosition, + const Quaternion& endRotation ) { m_positionStart = startPosition; m_rotationStart = startRotation; diff --git a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.h b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.h index 81834971f..e710b9a59 100644 --- a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.h +++ b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator.h @@ -9,12 +9,13 @@ // -------------------------------------------------------------------------------------- // Description: // Particle element generator that generates particle positions and/or velocities as if -// particles are spawned in a moving sphere sector (with velocities pointing from the +// particles are spawned in a moving sphere sector (with velocities pointing from the // sphere center). // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2CapsuleShapeAttributeGenerator ): public ITr2AttributeGenerator +BLUE_CLASS( Tr2CapsuleShapeAttributeGenerator ) : + public ITr2AttributeGenerator { public: EXPOSE_TO_BLUE(); @@ -23,14 +24,15 @@ BLUE_CLASS( Tr2CapsuleShapeAttributeGenerator ): public ITr2AttributeGenerator ~Tr2CapsuleShapeAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ); std::string GetName() const; - void SetPositions( const Vector3& startPosition, + void SetPositions( const Vector3& startPosition, const Quaternion& startRotation, - const Vector3& endPosition, + const Vector3& endPosition, const Quaternion& endRotation ); + private: // Generator positions Vector3 m_positionStart; diff --git a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator_Blue.cpp index 59c72457c..6690f8606 100644 --- a/trinity/Particle/Tr2CapsuleShapeAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2CapsuleShapeAttributeGenerator_Blue.cpp @@ -11,7 +11,7 @@ const Be::ClassInfo* Tr2CapsuleShapeAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2CapsuleShapeAttributeGenerator, "" ) MAP_INTERFACE( Tr2CapsuleShapeAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) MAP_ATTRIBUTE( "positionStart", m_positionStart, "Generator starting position", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "positionEnd", m_positionEnd, "Generator ending position", Be::READWRITE | Be::PERSIST ) @@ -23,17 +23,17 @@ const Be::ClassInfo* Tr2CapsuleShapeAttributeGenerator::ExposeToBlue() MAP_ATTRIBUTE( "maxPhi", m_maxPhi, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minTheta", m_minTheta, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxTheta", m_maxTheta, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "controlVelocity", - m_controlVelocity, - "Does the generator affect particle velocity", + MAP_ATTRIBUTE( + "controlVelocity", + m_controlVelocity, + "Does the generator affect particle velocity", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minSpeed", m_minSpeed, "Minimal particle speed", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxSpeed", m_maxSpeed, "Maximal particle speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "parentVelocityFactor", - m_parentVelocityFactor, - "How much parent particle velocity affects new particle velocity (for emit during lifetime and on deth emitters)", + MAP_ATTRIBUTE( + "parentVelocityFactor", + m_parentVelocityFactor, + "How much parent particle velocity affects new particle velocity (for emit during lifetime and on deth emitters)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "valid", m_valid, "Was the generator successfully bound to particle system", Be::READ ) diff --git a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.cpp b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.cpp index b7c2ac362..69f59a0a8 100644 --- a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.cpp +++ b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.cpp @@ -8,8 +8,8 @@ // Description: // Tr2RandomIntegerAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2ConsecutiveIntegerAttributeGenerator::Tr2ConsecutiveIntegerAttributeGenerator() - :m_name( Tr2ParticleElementDeclarationName::CUSTOM ), +Tr2ConsecutiveIntegerAttributeGenerator::Tr2ConsecutiveIntegerAttributeGenerator() : + m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_minRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_maxRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_valid( false ), @@ -31,17 +31,17 @@ Tr2ConsecutiveIntegerAttributeGenerator::~Tr2ConsecutiveIntegerAttributeGenerato // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates consecutive integer values +// Implements ITr2AttributeGenerator interface. Generates consecutive integer values // for new particle component (element). // Arguments: // position - Position of the "parent" particle (unused). // velocity - Velocity of the "parent" particle (unused). -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills element identified by generator's m_name with random values. // -------------------------------------------------------------------------------------- -void Tr2ConsecutiveIntegerAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, - float** particle ) +void Tr2ConsecutiveIntegerAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, + float** particle ) { if( !m_valid ) { @@ -72,17 +72,17 @@ void Tr2ConsecutiveIntegerAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2ConsecutiveIntegerAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2ConsecutiveIntegerAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; auto i = declaration.find( m_name ); @@ -104,7 +104,7 @@ bool Tr2ConsecutiveIntegerAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. @@ -116,7 +116,7 @@ std::string Tr2ConsecutiveIntegerAttributeGenerator::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Returns bounded particle element dimension or 0 if the generator is not bounded. +// Returns bounded particle element dimension or 0 if the generator is not bounded. // Used for Python exposure. // Return Value: // Bounded particle element dimension or 0 if the generator is not bounded. diff --git a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.h b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.h index e84fac487..f9d8efd92 100644 --- a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.h +++ b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator.h @@ -8,12 +8,12 @@ // -------------------------------------------------------------------------------------- // Description: -// Particle element generator that creates consecutive integer element values in a +// Particle element generator that creates consecutive integer element values in a // specified range. // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ConsecutiveIntegerAttributeGenerator ): +BLUE_CLASS( Tr2ConsecutiveIntegerAttributeGenerator ) : public ITr2AttributeGenerator { public: @@ -23,9 +23,10 @@ BLUE_CLASS( Tr2ConsecutiveIntegerAttributeGenerator ): ~Tr2ConsecutiveIntegerAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, std::set& boundElements ); std::string GetName() const; unsigned GetDimension() const; + private: // Particle element type/name Tr2ParticleElementDeclarationName m_name; diff --git a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator_Blue.cpp index 679a83e11..01fe9dd29 100644 --- a/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2ConsecutiveIntegerAttributeGenerator_Blue.cpp @@ -12,13 +12,13 @@ const Be::ClassInfo* Tr2ConsecutiveIntegerAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2ConsecutiveIntegerAttributeGenerator, "" ) MAP_INTERFACE( Tr2ConsecutiveIntegerAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) MAP_ATTRIBUTE( "customName", m_name.m_name, "Name for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minRange", m_minRange, "Min bound for value range", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Particle/Tr2DynamicEmitter.cpp b/trinity/Particle/Tr2DynamicEmitter.cpp index 010ace9d7..7aeaa9c20 100644 --- a/trinity/Particle/Tr2DynamicEmitter.cpp +++ b/trinity/Particle/Tr2DynamicEmitter.cpp @@ -9,8 +9,8 @@ // Description: // Tr2DynamicEmitter default constructor // -------------------------------------------------------------------------------------- -Tr2DynamicEmitter::Tr2DynamicEmitter( IRoot* lockobj ) - :PARENTLOCK( m_generators ), +Tr2DynamicEmitter::Tr2DynamicEmitter( IRoot* lockobj ) : + PARENTLOCK( m_generators ), m_isValid( false ), m_isThreadSafe( false ), m_declarationHash( 0 ), @@ -53,8 +53,8 @@ bool Tr2DynamicEmitter::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the emitter to respond to parameter changes -// generated in Python. If the particle system changes, the emitter re-binds to it. +// Implements INotify interface. Allows the emitter to respond to parameter changes +// generated in Python. If the particle system changes, the emitter re-binds to it. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -89,7 +89,7 @@ void Tr2DynamicEmitter::SetThreadSafeFlag() // -------------------------------------------------------------------------------------- // Description: -// Returns if the emitter is sucessfully bound to the particle system. +// Returns if the emitter is sucessfully bound to the particle system. // Return Value: // true If the emitter is sucessfully bound to the particle system // false Otherwise @@ -102,7 +102,7 @@ bool Tr2DynamicEmitter::IsValid() const // -------------------------------------------------------------------------------------- // Description: // Implements ITr2GenericEmitter interface. Spawns particles every frame at a constant -// rate. +// rate. // Arguments: // arguments - Update arguments // -------------------------------------------------------------------------------------- @@ -124,7 +124,7 @@ void Tr2DynamicEmitter::Update( const UpdateArguments& arguments ) // -------------------------------------------------------------------------------------- // Description: -// Spawns particles for a frame of given length. +// Spawns particles for a frame of given length. // Arguments: // dt - frame duraction (in seconds) // -------------------------------------------------------------------------------------- @@ -135,7 +135,7 @@ void Tr2DynamicEmitter::UpdateSimulation( float dt ) // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter interface. Spawns particles. +// Implements ITr2GenericEmitter interface. Spawns particles. // Arguments: // arguments - Update arguments // position - Position of the "parent" particle (if the emitter owning this generator @@ -148,8 +148,8 @@ void Tr2DynamicEmitter::UpdateSimulation( float dt ) // defined rate value. // -------------------------------------------------------------------------------------- void Tr2DynamicEmitter::SpawnParticles( const UpdateArguments& arguments, - const Vector3* position, - const Vector3* velocity, + const Vector3* position, + const Vector3* velocity, float rateModifier ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -169,12 +169,12 @@ void Tr2DynamicEmitter::SpawnParticles( const UpdateArguments& arguments, { return; } - m_accumulatedRate += m_rate*rateModifier; + m_accumulatedRate += m_rate * rateModifier; int32_t count = int32_t( m_accumulatedRate ); m_accumulatedRate -= floor( m_accumulatedRate ); if( m_maxParticles >= 0 && int32_t( m_emittedParticles ) + count > m_maxParticles ) { - count = std::max( m_maxParticles - int32_t( m_emittedParticles ), 0 ); + count = std::max( m_maxParticles - int32_t( m_emittedParticles ), 0 ); } m_emittedParticles += count; @@ -211,17 +211,19 @@ void Tr2DynamicEmitter::SpawnParticles( const UpdateArguments& arguments, void Tr2DynamicEmitter::SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, - float deltaTime ) + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, + float deltaTime ) { SpawnParticles( arguments, positionEnd, velocityEnd, deltaTime ); } // -------------------------------------------------------------------------------------- // Description: -// Re-binds the emitter to its particle system. Tries to bind each generator to the -// corresponding element. IsValid can be checked after Rebind to see if the binding +// Re-binds the emitter to its particle system. Tries to bind each generator to the +// corresponding element. IsValid can be checked after Rebind to see if the binding // succeeded. // -------------------------------------------------------------------------------------- void Tr2DynamicEmitter::Rebind() diff --git a/trinity/Particle/Tr2DynamicEmitter.h b/trinity/Particle/Tr2DynamicEmitter.h index 404a8ee8d..43d6217fa 100644 --- a/trinity/Particle/Tr2DynamicEmitter.h +++ b/trinity/Particle/Tr2DynamicEmitter.h @@ -17,9 +17,9 @@ BLUE_DECLARE_IVECTOR( ITr2AttributeGenerator ); // See Also: // ITr2GenericEmitter, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2DynamicEmitter ): +BLUE_CLASS( Tr2DynamicEmitter ) : public ITr2GenericEmitter, - public INotify, + public INotify, public IInitialize { public: @@ -37,18 +37,18 @@ BLUE_CLASS( Tr2DynamicEmitter ): ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2GenericEmitter void Update( const UpdateArguments& arguments ); void SpawnParticles( const UpdateArguments& arguments, const Vector3* position = nullptr, const Vector3* velocity = nullptr, float rateModifier = 1.0f ); - void SpawnParticles( - const UpdateArguments& arguments, - const Vector3 *positionStart, - const Vector3 *positionEnd, - const Vector3 *velocityStart, - const Vector3 *velocityEnd, + void SpawnParticles( + const UpdateArguments& arguments, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ); void SetThreadSafeFlag(); @@ -57,6 +57,7 @@ BLUE_CLASS( Tr2DynamicEmitter ): void ResetEmittedParticleCount(); uint32_t GetEmittedParticleCount() const; + private: void UpdateSimulation( float dt ); // Just a name diff --git a/trinity/Particle/Tr2DynamicEmitter_Blue.cpp b/trinity/Particle/Tr2DynamicEmitter_Blue.cpp index 5a2051044..434a70736 100644 --- a/trinity/Particle/Tr2DynamicEmitter_Blue.cpp +++ b/trinity/Particle/Tr2DynamicEmitter_Blue.cpp @@ -12,8 +12,8 @@ const Be::ClassInfo* Tr2DynamicEmitter::ExposeToBlue() MAP_INTERFACE( ITr2GenericEmitter ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "generators", m_generators, "List of generators for each particle element", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "isValid", m_isValid, "If the emitter successfully bound to the particle system", Be::READ ) MAP_ATTRIBUTE( "particleSystem", m_particleSystem, "Particle system to emit particles to", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) @@ -22,10 +22,10 @@ const Be::ClassInfo* Tr2DynamicEmitter::ExposeToBlue() MAP_PROPERTY_READONLY( "emittedParticles", GetEmittedParticleCount, "Number of particles emitted" ) MAP_METHOD_AND_WRAP( "Rebind", Rebind, "Re-binds emitter to the particle system" ) - MAP_METHOD_AND_WRAP( - "UpdateSimulation", - UpdateSimulation, - "Updates emitter manually.\n" + MAP_METHOD_AND_WRAP( + "UpdateSimulation", + UpdateSimulation, + "Updates emitter manually.\n" ":param dt: time inteval (in seconds)" ) EXPOSURE_END() diff --git a/trinity/Particle/Tr2ElementBlendConstraint.cpp b/trinity/Particle/Tr2ElementBlendConstraint.cpp index 14e326183..71b1bdd9c 100644 --- a/trinity/Particle/Tr2ElementBlendConstraint.cpp +++ b/trinity/Particle/Tr2ElementBlendConstraint.cpp @@ -8,8 +8,8 @@ // Description: // Tr2ElementBlendConstraint default constructor // -------------------------------------------------------------------------------------- -Tr2ElementBlendConstraint::Tr2ElementBlendConstraint( IRoot* lockobj ) - :m_isValid( false ), +Tr2ElementBlendConstraint::Tr2ElementBlendConstraint( IRoot* lockobj ) : + m_isValid( false ), m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_value( 0.f, 0.f, 0.f, 0.f ), m_originalFactor( 1.f ), @@ -51,24 +51,24 @@ void Tr2ElementBlendConstraint::ApplyConstraint( const ITr2GenericEmitter::Updat case 2: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat2( - (XMFLOAT2*)data.Get(), + XMStoreFloat2( + (XMFLOAT2*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat2( (XMFLOAT2*)data.Get() ), originalFactor, value ) ); } break; case 3: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat3( - (XMFLOAT3*)data.Get(), + XMStoreFloat3( + (XMFLOAT3*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat3( (XMFLOAT3*)data.Get() ), originalFactor, value ) ); } break; case 4: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat4( - (XMFLOAT4*)data.Get(), + XMStoreFloat4( + (XMFLOAT4*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat4( (XMFLOAT4*)data.Get() ), originalFactor, value ) ); } break; @@ -81,24 +81,24 @@ void Tr2ElementBlendConstraint::ApplyConstraint( const ITr2GenericEmitter::Updat case 2: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat2( - (XMFLOAT2*)data.Get(), + XMStoreFloat2( + (XMFLOAT2*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat2( (XMFLOAT2*)data.Get() ), originalFactor, value ) ); } break; case 3: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat3( - (XMFLOAT3*)data.Get(), + XMStoreFloat3( + (XMFLOAT3*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat3( (XMFLOAT3*)data.Get() ), originalFactor, value ) ); } break; case 4: for( unsigned i = 0; i < count; ++i, ++data ) { - XMStoreFloat4( - (XMFLOAT4*)data.Get(), + XMStoreFloat4( + (XMFLOAT4*)data.Get(), XMVectorMultiplyAdd( XMLoadFloat4( (XMFLOAT4*)data.Get() ), originalFactor, value ) ); } break; @@ -118,7 +118,7 @@ void Tr2ElementBlendConstraint::Bind( Tr2ParticleSystem* system ) { m_isValid = false; - const Tr2ParticleElementDataMap &declaration = system->GetElementDeclaration(); + const Tr2ParticleElementDataMap& declaration = system->GetElementDeclaration(); auto i = declaration.find( m_name ); if( i == declaration.end() ) { diff --git a/trinity/Particle/Tr2ElementBlendConstraint.h b/trinity/Particle/Tr2ElementBlendConstraint.h index ffd4ade9f..befb0ded0 100644 --- a/trinity/Particle/Tr2ElementBlendConstraint.h +++ b/trinity/Particle/Tr2ElementBlendConstraint.h @@ -9,13 +9,13 @@ // -------------------------------------------------------------------------------------- // Description: -// Tr2ElementBlendConstraint is a constraint that blends particle element value with -// the provided constant value. Can be used to symulate "global" particle systems by +// Tr2ElementBlendConstraint is a constraint that blends particle element value with +// the provided constant value. Can be used to symulate "global" particle systems by // shifting particle positions. // See Also: // Tr2ParticleSystem, ITr2GenericParticleConstraint // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ElementBlendConstraint ): +BLUE_CLASS( Tr2ElementBlendConstraint ) : public ITr2GenericParticleConstraint { public: @@ -26,7 +26,8 @@ BLUE_CLASS( Tr2ElementBlendConstraint ): ///////////////////////////////////////////////////////////// // ITr2ParticleConstraint virtual void ApplyConstraint( const ITr2GenericEmitter::UpdateArguments& arguments, float** particle, unsigned* strides, unsigned count, float dt ); - virtual void Bind( Tr2ParticleSystem* system ); + virtual void Bind( Tr2ParticleSystem * system ); + private: // Is valid flag (for debugging) bool m_isValid; diff --git a/trinity/Particle/Tr2ElementBlendConstraint_Blue.cpp b/trinity/Particle/Tr2ElementBlendConstraint_Blue.cpp index 0e2d3362f..4901d4bac 100644 --- a/trinity/Particle/Tr2ElementBlendConstraint_Blue.cpp +++ b/trinity/Particle/Tr2ElementBlendConstraint_Blue.cpp @@ -10,36 +10,36 @@ BLUE_DEFINE( Tr2ElementBlendConstraint ); const Be::ClassInfo* Tr2ElementBlendConstraint::ExposeToBlue() { EXPOSURE_BEGIN( Tr2ElementBlendConstraint, "" ) - MAP_INTERFACE( Tr2ElementBlendConstraint ) + MAP_INTERFACE( Tr2ElementBlendConstraint ) MAP_INTERFACE( ITr2GenericParticleConstraint ) - MAP_ATTRIBUTE( - "isValid", - m_isValid, - "Is the constraint bound to the particle system", + MAP_ATTRIBUTE( + "isValid", + m_isValid, + "Is the constraint bound to the particle system", Be::READ ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) - MAP_ATTRIBUTE( - "customName", - m_name.m_name, - "Name for custom type element", + MAP_ATTRIBUTE( + "customName", + m_name.m_name, + "Name for custom type element", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "value", - m_value, - "Constant to add to element value", + MAP_ATTRIBUTE( + "value", + m_value, + "Constant to add to element value", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "originalFactor", - m_originalFactor, - "Factor to scale element value", + MAP_ATTRIBUTE( + "originalFactor", + m_originalFactor, + "Factor to scale element value", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() diff --git a/trinity/Particle/Tr2ForceSphereVolume.cpp b/trinity/Particle/Tr2ForceSphereVolume.cpp index 1d8031f3d..18ce1e405 100644 --- a/trinity/Particle/Tr2ForceSphereVolume.cpp +++ b/trinity/Particle/Tr2ForceSphereVolume.cpp @@ -4,16 +4,16 @@ #include "Tr2ForceSphereVolume.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif -Tr2ForceSphereVolume::Tr2ForceSphereVolume( IRoot* lockobj ) - :PARENTLOCK( m_forces ), +Tr2ForceSphereVolume::Tr2ForceSphereVolume( IRoot* lockobj ) : + PARENTLOCK( m_forces ), m_position( 0.f, 0.f, 0.f ), m_radius( 1.f ), m_exponent( 1.f ) @@ -40,23 +40,20 @@ XMVECTOR FASTCALL Tr2ForceSphereVolume::GetForce( FXMVECTOR position, FXMVECTOR XMVECTOR force = XMVectorReplicate( 0.0f ); XMVECTOR distance = XMVector3Length( XMVectorSubtract( position, m_position ) ); XMVECTOR radius = XMVectorReplicate( m_radius ); - + if( XMVectorGetIntX( XMVectorLess( distance, radius ) ) ) { for( auto it = m_forces.begin(); it != m_forces.end(); ++it ) { force = XMVectorAdd( force, ( *it )->GetForce( position, velocity, dt, mass ) ); } - force = XMVectorMultiply( + force = XMVectorMultiply( force, - XMVectorPow( + XMVectorPow( XMVectorSubtract( XMVectorReplicate( 1.f ), - XMVectorMultiply( distance, XMVectorReciprocal( radius ) ) - ), - XMVectorReplicate( m_exponent ) - ) - ); + XMVectorMultiply( distance, XMVectorReciprocal( radius ) ) ), + XMVectorReplicate( m_exponent ) ) ); } return force; } @@ -64,7 +61,7 @@ XMVECTOR FASTCALL Tr2ForceSphereVolume::GetForce( FXMVECTOR position, FXMVECTOR void Tr2ForceSphereVolume::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const { renderer.DrawSphere( this, worldTransform, m_position, m_radius, 20, ITr2DebugRenderer2::Wireframe, 0xffaaaa00 ); - for ( auto& force : m_forces ) + for( auto& force : m_forces ) { force->RenderDebugInfo( renderer, worldTransform, aabb ); } diff --git a/trinity/Particle/Tr2ForceSphereVolume.h b/trinity/Particle/Tr2ForceSphereVolume.h index c11608a1b..7d99d9353 100644 --- a/trinity/Particle/Tr2ForceSphereVolume.h +++ b/trinity/Particle/Tr2ForceSphereVolume.h @@ -8,7 +8,7 @@ BLUE_DECLARE( Tr2ForceSphereVolume ); -class Tr2ForceSphereVolume: public ITr2ParticleForce +class Tr2ForceSphereVolume : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -17,13 +17,15 @@ class Tr2ForceSphereVolume: public ITr2ParticleForce ~Tr2ForceSphereVolume(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; private: // Forces in volume - PITr2ParticleForceVector m_forces; + PITr2ParticleForceVector m_forces; // Sphere origin Vector3 m_position; // Sphere radius diff --git a/trinity/Particle/Tr2GpuParticleSystem.cpp b/trinity/Particle/Tr2GpuParticleSystem.cpp index 5fd289325..594637025 100644 --- a/trinity/Particle/Tr2GpuParticleSystem.cpp +++ b/trinity/Particle/Tr2GpuParticleSystem.cpp @@ -26,7 +26,7 @@ const size_t TEXTURE_METHOD_EMITS_PER_DP = 8; // -------------------------------------------------------------------------------------- // Description: // Finds minim width and height of a rectangle such that width and height are power of -// two values and rectangle area is not less than the given area. +// two values and rectangle area is not less than the given area. // -------------------------------------------------------------------------------------- void GetMinPow2Rectange( uint32_t area, uint32_t& width, uint32_t& height ) { @@ -46,7 +46,7 @@ void GetMinPow2Rectange( uint32_t area, uint32_t& width, uint32_t& height ) // -------------------------------------------------------------------------------------- // Description: -// Checks if the effect is usable. +// Checks if the effect is usable. // -------------------------------------------------------------------------------------- bool CheckEffect( Tr2Effect* effect ) { @@ -56,8 +56,8 @@ bool CheckEffect( Tr2Effect* effect ) } -Tr2GpuParticleSystem::EmitterParamsGpu::EmitterParamsGpu( const EmitterParams& params ) - :minLifeTime( params.minLifeTime ), +Tr2GpuParticleSystem::EmitterParamsGpu::EmitterParamsGpu( const EmitterParams& params ) : + minLifeTime( params.minLifeTime ), maxLifeTime( params.maxLifeTime ), sizeVariance( params.sizeVariance ), textureIndex( float( params.textureIndex ) + std::max( 0.001f, std::min( 0.99f, 1.f - params.colorMidpoint - std::floor( params.colorMidpoint ) ) ) ), @@ -76,8 +76,8 @@ Tr2GpuParticleSystem::EmitterParamsGpu::EmitterParamsGpu( const EmitterParams& p colors[3] = params.colors[3]; } -Tr2GpuParticleSystem::Tr2GpuParticleSystem( IRoot* ) - :m_clearRequested( true ), +Tr2GpuParticleSystem::Tr2GpuParticleSystem( IRoot* ) : + m_clearRequested( true ), m_maxParticles( DEFAULT_MAX_PARTICLES ), m_emitRequests( 64, "Tr2GpuParticleSystem::m_emitRequests" ), m_previousTime( -1 ), @@ -120,7 +120,7 @@ Tr2GpuParticleSystem::~Tr2GpuParticleSystem() // -------------------------------------------------------------------------------------- // Description: -// Creates GPU buffer variables. +// Creates GPU buffer variables. // -------------------------------------------------------------------------------------- void Tr2GpuParticleSystem::InitializeBuffers() { @@ -300,7 +300,7 @@ void Tr2GpuParticleSystem::SetVariableStore( Tr2Effect* effect ) // -------------------------------------------------------------------------------------- // Description: // Public method to remove all particles. The actual clear though happens during next -// Update call. +// Update call. // -------------------------------------------------------------------------------------- void Tr2GpuParticleSystem::Clear() { @@ -358,7 +358,7 @@ void Tr2GpuParticleSystem::Update( Be::Time time, const Vector3& originShift, Tr // no particles left alive return; } - + RunSimulation( dt, originShift, renderContext ); m_liveTime -= dt; @@ -376,7 +376,7 @@ void Tr2GpuParticleSystem::Update( Be::Time time, const Vector3& originShift, Tr // -------------------------------------------------------------------------------------- // Description: -// Updates number of live/visible particles for debugging. +// Updates number of live/visible particles for debugging. // -------------------------------------------------------------------------------------- void Tr2GpuParticleSystem::UpdateLiveCount( Tr2RenderContext& renderContext ) { @@ -585,12 +585,12 @@ void Tr2GpuParticleSystem::EmitParticles( Tr2RenderContext& renderContext ) { cb.emitters[j] = m_emitRequests[i + j].emitter; } - FillAndSetConstants( - m_emitCB, - &cb, - sizeof( EmitterCBPrefix ) + cb.prefix.count * sizeof( EmitterGpu ), - Tr2RenderContextEnum::COMPUTE_SHADER, - Tr2Renderer::GetPerObjectVSStartRegister(), + FillAndSetConstants( + m_emitCB, + &cb, + sizeof( EmitterCBPrefix ) + cb.prefix.count * sizeof( EmitterGpu ), + Tr2RenderContextEnum::COMPUTE_SHADER, + Tr2Renderer::GetPerObjectVSStartRegister(), renderContext ); Tr2Renderer::RunComputeShader( m_emit, cb.prefix.count, 1, 1, renderContext ); @@ -637,20 +637,20 @@ bool Tr2GpuParticleSystem::SortIncremental( uint32_t presorted, Tr2RenderContext { const uint32_t maxSize = m_maxParticles; bool done = maxSize <= presorted * 2; - uint32_t numThreadGroups=0; - + uint32_t numThreadGroups = 0; + if( maxSize > presorted ) - { - uint32_t pow2 = presorted; - while( pow2 < maxSize ) + { + uint32_t pow2 = presorted; + while( pow2 < maxSize ) { pow2 *= 2; } numThreadGroups = pow2 >> 9; - } + } uint32_t mergeSize = presorted * 2; - for( uint32_t mergeSubSize = mergeSize >> 1; mergeSubSize > 256; mergeSubSize = mergeSubSize >> 1 ) + for( uint32_t mergeSubSize = mergeSize >> 1; mergeSubSize > 256; mergeSubSize = mergeSubSize >> 1 ) { struct SortConstants { diff --git a/trinity/Particle/Tr2GpuParticleSystem.h b/trinity/Particle/Tr2GpuParticleSystem.h index 9cb8c5f83..5d3e1dec7 100644 --- a/trinity/Particle/Tr2GpuParticleSystem.h +++ b/trinity/Particle/Tr2GpuParticleSystem.h @@ -18,13 +18,13 @@ BLUE_DECLARE( Tr2RenderTarget ); // -------------------------------------------------------------------------------------- // Description: -// GPU-managed particle system. +// GPU-managed particle system. // See Also: // Tr2GpuSharedEmitter, Tr2GpuUniqueEmitter // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GpuParticleSystem ): - public IInitialize, - public INotify, +BLUE_CLASS( Tr2GpuParticleSystem ) : + public IInitialize, + public INotify, public IRenderCallback, public Tr2DeviceResource { @@ -64,7 +64,7 @@ BLUE_CLASS( Tr2GpuParticleSystem ): // ---------------------------------------------------------------------------------- // Description: - // CPU-side (public) emitter. This structure describes initial values for + // CPU-side (public) emitter. This structure describes initial values for // particle attributes. // See Also: // Tr2GpuParticleSystem::EmitterGpu @@ -95,34 +95,35 @@ BLUE_CLASS( Tr2GpuParticleSystem ): virtual bool Initialize(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); void Update( Be::Time time, const Vector3& originShift, Tr2RenderContext& renderContext ); - void Render( Tr2RenderContext& renderContext ); + void Render( Tr2RenderContext & renderContext ); void Clear(); void Emit( const Emitter& emitter, uintptr_t id, uintptr_t hash, const EmitterParams& params ); bool HasParticles() const; - virtual void SubmitGeometry( Tr2RenderContext& renderContext ); + virtual void SubmitGeometry( Tr2RenderContext & renderContext ); virtual void ReleaseResources( TriStorage s ); + private: virtual bool OnPrepareResources(); void InitializeBuffers(); void RegisterVariables(); - void SetVariableStore( Tr2Effect* effect ); - bool DoClear( Tr2RenderContext& renderContext ); + void SetVariableStore( Tr2Effect * effect ); + bool DoClear( Tr2RenderContext & renderContext ); void RunSimulation( float dt, const Vector3& originShift, Tr2RenderContext& renderContext ); - void UpdateGpuEmitterParams( Tr2RenderContext& renderContext ); + void UpdateGpuEmitterParams( Tr2RenderContext & renderContext ); - void Sort( Tr2RenderContext& renderContext ); + void Sort( Tr2RenderContext & renderContext ); bool SortIncremental( uint32_t presorted, Tr2RenderContext& renderContext ); void SetMaxParticles( uint32_t maxParticles ); void ExpireEmitterParams( float dt ); - void UpdateEmitterParams( Tr2RenderContext& renderContext ); - void EmitParticles( Tr2RenderContext& renderContext ); - void UpdateLiveCount( Tr2RenderContext& renderContext ); + void UpdateEmitterParams( Tr2RenderContext & renderContext ); + void EmitParticles( Tr2RenderContext & renderContext ); + void UpdateLiveCount( Tr2RenderContext & renderContext ); float GetEmitTime(); float GetUpdateTime(); @@ -177,7 +178,9 @@ BLUE_CLASS( Tr2GpuParticleSystem ): typedef Emitter EmitterGpu; struct EmitterParamsGpu { - EmitterParamsGpu() {} + EmitterParamsGpu() + { + } explicit EmitterParamsGpu( const EmitterParams& params ); float minLifeTime; diff --git a/trinity/Particle/Tr2GpuParticleSystem_Blue.cpp b/trinity/Particle/Tr2GpuParticleSystem_Blue.cpp index 20e422855..97c54faef 100644 --- a/trinity/Particle/Tr2GpuParticleSystem_Blue.cpp +++ b/trinity/Particle/Tr2GpuParticleSystem_Blue.cpp @@ -8,122 +8,121 @@ BLUE_DEFINE( Tr2GpuParticleSystem ); const Be::ClassInfo* Tr2GpuParticleSystem::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GpuParticleSystem, "GPU-managed particle system" ) - MAP_INTERFACE( Tr2GpuParticleSystem ) + EXPOSURE_BEGIN( Tr2GpuParticleSystem, "GPU-managed particle system" ) + MAP_INTERFACE( Tr2GpuParticleSystem ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( - "emit", - m_emit, - "Shader for emitting particles", + MAP_ATTRIBUTE( + "emit", + m_emit, + "Shader for emitting particles", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "update", - m_update, - "Shader for updating particles", + MAP_ATTRIBUTE( + "update", + m_update, + "Shader for updating particles", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "render", - m_render, - "Shader for rendering particles", + MAP_ATTRIBUTE( + "render", + m_render, + "Shader for rendering particles", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "clear", - m_clear, - "Shader for clearing particle system", + MAP_ATTRIBUTE( + "clear", + m_clear, + "Shader for clearing particle system", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "setDrawParameters", - m_setDrawParameters, - "Shader to assign draw call parameters", + MAP_ATTRIBUTE( + "setDrawParameters", + m_setDrawParameters, + "Shader to assign draw call parameters", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "setSortParameters", - m_setSortParameters, - "Shader to assign sort dispatch parameters", + MAP_ATTRIBUTE( + "setSortParameters", + m_setSortParameters, + "Shader to assign sort dispatch parameters", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "sort", - m_sort, - "Shader for initial sorting of particles", + MAP_ATTRIBUTE( + "sort", + m_sort, + "Shader for initial sorting of particles", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "sortStep", - m_sortStep, - "Shader for incremental sorting of particles", + MAP_ATTRIBUTE( + "sortStep", + m_sortStep, + "Shader for incremental sorting of particles", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "sortInner", - m_sortInner, - "Shader for incremental sorting of particles (merge phase)", + MAP_ATTRIBUTE( + "sortInner", + m_sortInner, + "Shader for incremental sorting of particles (merge phase)", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "enableEmit", - m_enableEmit, - "Enable/disable emitting new particles (for debugging)", + MAP_ATTRIBUTE( + "enableEmit", + m_enableEmit, + "Enable/disable emitting new particles (for debugging)", Be::READWRITE ) - MAP_ATTRIBUTE( - "enableUpdate", - m_enableUpdate, - "Enable/disable updating existing particles (for debugging)", + MAP_ATTRIBUTE( + "enableUpdate", + m_enableUpdate, + "Enable/disable updating existing particles (for debugging)", Be::READWRITE ) - MAP_ATTRIBUTE( - "enableSort", - m_enableSort, - "Enable/disable sorting of particles (for debugging)", + MAP_ATTRIBUTE( + "enableSort", + m_enableSort, + "Enable/disable sorting of particles (for debugging)", Be::READWRITE ) - MAP_ATTRIBUTE( - "display", - m_enableRender, - "Enable/disable rendering of particles", + MAP_ATTRIBUTE( + "display", + m_enableRender, + "Enable/disable rendering of particles", Be::READWRITE ) - MAP_ATTRIBUTE( - "maxParticles", - m_maxParticles, - "Maximum number of particles in the system", + MAP_ATTRIBUTE( + "maxParticles", + m_maxParticles, + "Maximum number of particles in the system", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_PROPERTY_READONLY( - "emitTime", - GetEmitTime, + MAP_PROPERTY_READONLY( + "emitTime", + GetEmitTime, "GPU emit particles time in milliseconds" ) - MAP_PROPERTY_READONLY( - "updateTime", - GetUpdateTime, + MAP_PROPERTY_READONLY( + "updateTime", + GetUpdateTime, "GPU particle update time in milliseconds" ) - MAP_PROPERTY_READONLY( - "sortTime", - GetSortTime, + MAP_PROPERTY_READONLY( + "sortTime", + GetSortTime, "GPU particle sort time in milliseconds" ) - MAP_PROPERTY_READONLY( - "renderTime", - GetRenderTime, + MAP_PROPERTY_READONLY( + "renderTime", + GetRenderTime, "GPU render time in milliseconds" ) - MAP_ATTRIBUTE( - "updateVisibleCount", - m_updateVisibleCount, - "Enable/disable updating visibleCount attribute (for debug only)", + MAP_ATTRIBUTE( + "updateVisibleCount", + m_updateVisibleCount, + "Enable/disable updating visibleCount attribute (for debug only)", Be::READWRITE ) - MAP_ATTRIBUTE( - "visibleCount", - m_visibleCount, - "Number of visible particles (when updateVisibleCount is on; for debug only)", + MAP_ATTRIBUTE( + "visibleCount", + m_visibleCount, + "Number of visible particles (when updateVisibleCount is on; for debug only)", Be::READ ) - MAP_PROPERTY_READONLY( - "hasParticles", - HasParticles, + MAP_PROPERTY_READONLY( + "hasParticles", + HasParticles, "If the system contains no alive particles; acts as an estimate and can return false positives" ) - MAP_METHOD_AND_WRAP( - "Clear", - Clear, + MAP_METHOD_AND_WRAP( + "Clear", + Clear, "Removes all alive particles from the system" ) EXPOSURE_END() } - diff --git a/trinity/Particle/Tr2GpuSharedEmitter.cpp b/trinity/Particle/Tr2GpuSharedEmitter.cpp index 4e3ca29a1..2c37f32d0 100644 --- a/trinity/Particle/Tr2GpuSharedEmitter.cpp +++ b/trinity/Particle/Tr2GpuSharedEmitter.cpp @@ -8,8 +8,8 @@ namespace const float MAXIMUM_FRAME_TIME = 1.f / 15.f; } -Tr2GpuSharedEmitter::Tr2GpuSharedEmitter( IRoot* lockObj ) - :m_rate( 0 ), +Tr2GpuSharedEmitter::Tr2GpuSharedEmitter( IRoot* lockObj ) : + m_rate( 0 ), m_id( 0 ), m_paramsHash( 0 ), m_previousTime( -1 ), @@ -162,10 +162,12 @@ void Tr2GpuSharedEmitter::SpawnParticles( const UpdateArguments& arguments, cons SpawnParticles( emitter, arguments, pos, pos, vel, vel, 0.f, rateModifier ); } -void Tr2GpuSharedEmitter::SpawnParticles( +void Tr2GpuSharedEmitter::SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ) { if( !arguments.system || !m_enabled ) @@ -188,11 +190,13 @@ void Tr2GpuSharedEmitter::SpawnParticles( m_carryOver = SpawnParticles( emitter, arguments, posStart, posEnd, velStart, velEnd, m_carryOver, std::min( deltaTime, MAXIMUM_FRAME_TIME ) ); } -float Tr2GpuSharedEmitter::SpawnParticles( +float Tr2GpuSharedEmitter::SpawnParticles( Tr2GpuParticleSystem::Emitter& emitter, const UpdateArguments& arguments, - const Vector3& positionStart, const Vector3& positionEnd, - const Vector3& velocityStart, const Vector3& velocityEnd, + const Vector3& positionStart, + const Vector3& positionEnd, + const Vector3& velocityStart, + const Vector3& velocityEnd, float carryOverCount, float deltaTime ) { @@ -229,7 +233,7 @@ float Tr2GpuSharedEmitter::SpawnParticles( return carryOverCount; } -void Tr2GpuSharedEmitter::SpawnOnce( const UpdateArguments& arguments, const Vector3& velocity, float scale, float rateModifier) +void Tr2GpuSharedEmitter::SpawnOnce( const UpdateArguments& arguments, const Vector3& velocity, float scale, float rateModifier ) { if( !arguments.system || !m_enabled ) { diff --git a/trinity/Particle/Tr2GpuSharedEmitter.h b/trinity/Particle/Tr2GpuSharedEmitter.h index b8865441a..c4dd45402 100644 --- a/trinity/Particle/Tr2GpuSharedEmitter.h +++ b/trinity/Particle/Tr2GpuSharedEmitter.h @@ -10,14 +10,14 @@ // -------------------------------------------------------------------------------------- // Description: // Emitter class for GPU particle system. Shared emitters can share persistent particle -// parameters between instances. It is preferable to use shared emitters (as opposed to -// unique emitters) to conserve memory whenever possible. Since shared emitter +// parameters between instances. It is preferable to use shared emitters (as opposed to +// unique emitters) to conserve memory whenever possible. Since shared emitter // persistent parameters are shared they should not be animated. Also shared emitters // lack certain particle features (like attract forces). // See Also: // Tr2GpuParticleSystem, Tr2GpuUniqueEmitter // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GpuSharedEmitter ): +BLUE_CLASS( Tr2GpuSharedEmitter ) : public IInitialize, public INotify, public ITr2GenericEmitter @@ -29,21 +29,25 @@ BLUE_CLASS( Tr2GpuSharedEmitter ): virtual bool Initialize(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); void Enable( bool enable ); virtual void Update( const UpdateArguments& arguments ); virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3* position = nullptr, - const Vector3* velocity = nullptr, + const Vector3* position = nullptr, + const Vector3* velocity = nullptr, float rateModifier = 1.0f ); virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ); void SpawnOnce( const UpdateArguments& arguments, const Vector3& velocity, float scale = 1.f, float rateModifier = 1.f ); - virtual void SetThreadSafeFlag() {} + virtual void SetThreadSafeFlag() + { + } // access void Setup( float rate, const Tr2GpuParticleSystem::Emitter* emitterData, const Tr2GpuParticleSystem::EmitterParams* paramsData ); @@ -57,11 +61,13 @@ BLUE_CLASS( Tr2GpuSharedEmitter ): void UpdateHash(); uintptr_t GetHash( const Tr2GpuParticleSystem::EmitterParams& params ) const; - float SpawnParticles( - Tr2GpuParticleSystem::Emitter& emitter, + float SpawnParticles( + Tr2GpuParticleSystem::Emitter & emitter, const UpdateArguments& arguments, - const Vector3& positionStart, const Vector3& positionEnd, - const Vector3& velocityStart, const Vector3& velocityEnd, + const Vector3& positionStart, + const Vector3& positionEnd, + const Vector3& velocityStart, + const Vector3& velocityEnd, float carryOverCount, float deltaTime ); diff --git a/trinity/Particle/Tr2GpuSharedEmitter_Blue.cpp b/trinity/Particle/Tr2GpuSharedEmitter_Blue.cpp index 6b6603785..6bd21c56d 100644 --- a/trinity/Particle/Tr2GpuSharedEmitter_Blue.cpp +++ b/trinity/Particle/Tr2GpuSharedEmitter_Blue.cpp @@ -8,169 +8,169 @@ BLUE_DEFINE( Tr2GpuSharedEmitter ); const Be::ClassInfo* Tr2GpuSharedEmitter::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GpuSharedEmitter, "Emitter with shared per-instance data for GPU particle systems" ) - MAP_INTERFACE( Tr2GpuSharedEmitter ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) + EXPOSURE_BEGIN( Tr2GpuSharedEmitter, "Emitter with shared per-instance data for GPU particle systems" ) + MAP_INTERFACE( Tr2GpuSharedEmitter ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) MAP_INTERFACE( ITr2GenericEmitter ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "continuousEmitter", - m_continuousEmitter, - "Emit particles continuously while in parent emitter list", - Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( - "rate", - m_rate, - "Number of particles emitted per second", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "emissionDensity", - m_emissionDensity, - "Number of particles emitted per one meter movement of the emitter", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "maxEmissionDensity", - m_maxDensity, - "Maximum number of particles emitted per one meter movement of the emitter in a single frame", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "maxDisplacement", - m_maxDisplacement, - "Maximum emitter displacement in a single frame that turns the emitter off", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "position", - m_position, - "Emitter position", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "direction", - m_direction, - "Emitter primary direction", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "angle", - m_emitter.angle, - "Particle spread angle (in radians) around primary direction; if greater than pi/2, the emitter emits in all directions", + MAP_ATTRIBUTE( + "continuousEmitter", + m_continuousEmitter, + "Emit particles continuously while in parent emitter list", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "innerAngle", - m_emitter.innerAngle, - "Exclude angle (in radians) around primary direction: particles are spawned in a hollow cone between innerAngle and angle", + + MAP_ATTRIBUTE( + "rate", + m_rate, + "Number of particles emitted per second", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "emissionDensity", + m_emissionDensity, + "Number of particles emitted per one meter movement of the emitter", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "maxEmissionDensity", + m_maxDensity, + "Maximum number of particles emitted per one meter movement of the emitter in a single frame", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "maxDisplacement", + m_maxDisplacement, + "Maximum emitter displacement in a single frame that turns the emitter off", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "position", + m_position, + "Emitter position", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "direction", + m_direction, + "Emitter primary direction", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "angle", + m_emitter.angle, + "Particle spread angle (in radians) around primary direction; if greater than pi/2, the emitter emits in all directions", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "innerAngle", + m_emitter.innerAngle, + "Exclude angle (in radians) around primary direction: particles are spawned in a hollow cone between innerAngle and angle", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "radius", - m_emitter.radius, - "Emitter radius", + MAP_ATTRIBUTE( + "radius", + m_emitter.radius, + "Emitter radius", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "inheritVelocity", - m_inheritVelocity, - "Coefficient of how much of emitter velocity is transfered to particle velocities", + MAP_ATTRIBUTE( + "inheritVelocity", + m_inheritVelocity, + "Coefficient of how much of emitter velocity is transfered to particle velocities", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minSpeed", - m_emitter.minSpeed, - "Minimum particle initial speed", + MAP_ATTRIBUTE( + "minSpeed", + m_emitter.minSpeed, + "Minimum particle initial speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "maxSpeed", - m_emitter.maxSpeed, - "Maximum particle initial speed", + MAP_ATTRIBUTE( + "maxSpeed", + m_emitter.maxSpeed, + "Maximum particle initial speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "minLifeTime", - m_params.minLifeTime, + MAP_ATTRIBUTE( + "minLifeTime", + m_params.minLifeTime, "Minimum particle life time in seconds (stored on GPU)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "maxLifeTime", - m_params.maxLifeTime, + MAP_ATTRIBUTE( + "maxLifeTime", + m_params.maxLifeTime, "Maximum particle life time in seconds (stored on GPU)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "sizes", - m_params.sizes, + MAP_ATTRIBUTE( + "sizes", + m_params.sizes, "Particle sizes at 0, 50%, 100% of its age\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "sizeVariance", - m_params.sizeVariance, + MAP_ATTRIBUTE( + "sizeVariance", + m_params.sizeVariance, "Particle size variance (0 to 1)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "color0", - m_params.colors[0], + MAP_ATTRIBUTE( + "color0", + m_params.colors[0], "Particle color at 0% age\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "color1", - m_params.colors[1], + MAP_ATTRIBUTE( + "color1", + m_params.colors[1], "Particle color at 33% age\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "color2", - m_params.colors[2], + MAP_ATTRIBUTE( + "color2", + m_params.colors[2], "Particle color at 66% age\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "color3", - m_params.colors[3], + MAP_ATTRIBUTE( + "color3", + m_params.colors[3], "Particle color at 100% age\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "textureIndex", - m_params.textureIndex, + MAP_ATTRIBUTE( + "textureIndex", + m_params.textureIndex, "Particle atlas texture index (stored on GPU)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "colorMidpoint", - m_params.colorMidpoint, + MAP_ATTRIBUTE( + "colorMidpoint", + m_params.colorMidpoint, "Color curve midpoint from 0 to 1 (stored on GPU)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "velocityStretchRotation", - m_params.velocityStretchRotation, + MAP_ATTRIBUTE( + "velocityStretchRotation", + m_params.velocityStretchRotation, "Particle maximum rotation speed or velocity stretch coefficient if negative (stored on GPU)\n" - ":jessica-group: Particle", + ":jessica-group: Particle", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "drag", - m_params.drag, + MAP_ATTRIBUTE( + "drag", + m_params.drag, "Drag force coefficient (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "turbulenceAmplitude", - m_params.turbulenceAmplitude, + MAP_ATTRIBUTE( + "turbulenceAmplitude", + m_params.turbulenceAmplitude, "Turbulence force amplitude (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "turbulenceFrequency", - m_params.turbulenceFrequency, + MAP_ATTRIBUTE( + "turbulenceFrequency", + m_params.turbulenceFrequency, "Turbulence force frequency (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "gravity", - m_params.gravity, + MAP_ATTRIBUTE( + "gravity", + m_params.gravity, "Gravity force along Y axis (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Particle/Tr2GpuUniqueEmitter.cpp b/trinity/Particle/Tr2GpuUniqueEmitter.cpp index b8b20976d..551e868d2 100644 --- a/trinity/Particle/Tr2GpuUniqueEmitter.cpp +++ b/trinity/Particle/Tr2GpuUniqueEmitter.cpp @@ -3,8 +3,8 @@ #include "StdAfx.h" #include "Tr2GpuUniqueEmitter.h" -Tr2GpuUniqueEmitter::Tr2GpuUniqueEmitter( IRoot* lockObj ) - :Tr2GpuSharedEmitter( lockObj ), +Tr2GpuUniqueEmitter::Tr2GpuUniqueEmitter( IRoot* lockObj ) : + Tr2GpuSharedEmitter( lockObj ), m_attractorPosition( 0.f, 0.f, 0.f ), m_scaledByParent( false ) { @@ -53,9 +53,9 @@ void Tr2GpuUniqueEmitter::Update( const UpdateArguments& arguments ) } void Tr2GpuUniqueEmitter::SpawnParticles( const UpdateArguments& arguments, - const Vector3* position, - const Vector3* velocity, - float rateModifier ) + const Vector3* position, + const Vector3* velocity, + float rateModifier ) { Tr2GpuParticleSystem::Emitter originalEmitter; Tr2GpuParticleSystem::EmitterParams originalParams; @@ -86,9 +86,11 @@ void Tr2GpuUniqueEmitter::SpawnParticles( const UpdateArguments& arguments, void Tr2GpuUniqueEmitter::SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, - float deltaTime ) + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, + float deltaTime ) { Tr2GpuParticleSystem::Emitter originalEmitter; Tr2GpuParticleSystem::EmitterParams originalParams; diff --git a/trinity/Particle/Tr2GpuUniqueEmitter.h b/trinity/Particle/Tr2GpuUniqueEmitter.h index eb66d1231..914a08b86 100644 --- a/trinity/Particle/Tr2GpuUniqueEmitter.h +++ b/trinity/Particle/Tr2GpuUniqueEmitter.h @@ -9,12 +9,13 @@ // -------------------------------------------------------------------------------------- // Description: // Emitter class for GPU particle system. Unique emitters store persistent particle -// parameters for each instance on GPU, so they need to be used with care. It is -// preferable to use shared emitters to conserve memory whenever possible. +// parameters for each instance on GPU, so they need to be used with care. It is +// preferable to use shared emitters to conserve memory whenever possible. // See Also: // Tr2GpuParticleSystem, Tr2GpuUniqueEmitter // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GpuUniqueEmitter ): public Tr2GpuSharedEmitter +BLUE_CLASS( Tr2GpuUniqueEmitter ) : + public Tr2GpuSharedEmitter { public: Tr2GpuUniqueEmitter( IRoot* lockObj = nullptr ); @@ -23,13 +24,16 @@ BLUE_CLASS( Tr2GpuUniqueEmitter ): public Tr2GpuSharedEmitter virtual void Update( const UpdateArguments& arguments ); virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3* position = nullptr, - const Vector3* velocity = nullptr, + const Vector3* position = nullptr, + const Vector3* velocity = nullptr, float rateModifier = 1.0f ); virtual void SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ); + protected: virtual void GenerateID(); diff --git a/trinity/Particle/Tr2GpuUniqueEmitter_Blue.cpp b/trinity/Particle/Tr2GpuUniqueEmitter_Blue.cpp index ca49c8a65..e8467f97b 100644 --- a/trinity/Particle/Tr2GpuUniqueEmitter_Blue.cpp +++ b/trinity/Particle/Tr2GpuUniqueEmitter_Blue.cpp @@ -11,22 +11,22 @@ const Be::ClassInfo* Tr2GpuUniqueEmitter::ExposeToBlue() EXPOSURE_BEGIN( Tr2GpuUniqueEmitter, "Emitter with unique per-instance data for GPU particle systems" ) MAP_INTERFACE( Tr2GpuUniqueEmitter ) - MAP_ATTRIBUTE( - "scaledByParent", - m_scaledByParent, - "Apply parent scaling to particles", - Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "attractorPosition", - m_attractorPosition, + MAP_ATTRIBUTE( + "scaledByParent", + m_scaledByParent, + "Apply parent scaling to particles", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "attractorPosition", + m_attractorPosition, "Attractor force center (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "attractorStrength", - m_params.attractorStrength, + MAP_ATTRIBUTE( + "attractorStrength", + m_params.attractorStrength, "Attractor force coefficient (stored on GPU)\n" - ":jessica-group: Dynamics", + ":jessica-group: Dynamics", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2GpuSharedEmitter ) } diff --git a/trinity/Particle/Tr2ParticleAttractorForce.cpp b/trinity/Particle/Tr2ParticleAttractorForce.cpp index 250a39cb5..e7bdd098f 100644 --- a/trinity/Particle/Tr2ParticleAttractorForce.cpp +++ b/trinity/Particle/Tr2ParticleAttractorForce.cpp @@ -4,15 +4,15 @@ #include "Tr2ParticleAttractorForce.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif -Tr2ParticleAttractorForce::Tr2ParticleAttractorForce( IRoot* lockobj ): +Tr2ParticleAttractorForce::Tr2ParticleAttractorForce( IRoot* lockobj ) : m_magnitude( 1.f ), m_position( 0.f, 0.f, 0.f ) { diff --git a/trinity/Particle/Tr2ParticleAttractorForce.h b/trinity/Particle/Tr2ParticleAttractorForce.h index 507730a2a..d6f67e532 100644 --- a/trinity/Particle/Tr2ParticleAttractorForce.h +++ b/trinity/Particle/Tr2ParticleAttractorForce.h @@ -10,14 +10,13 @@ BLUE_DECLARE( Tr2ParticleAttractorForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. +// A force to apply to particles in a particle system. // Represents a constant magnitude force pointing to a defined // position. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleAttractorForce: - public ITr2ParticleForce +class Tr2ParticleAttractorForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -26,7 +25,9 @@ class Tr2ParticleAttractorForce: ~Tr2ParticleAttractorForce(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2ParticleAttractorForce_Blue.cpp b/trinity/Particle/Tr2ParticleAttractorForce_Blue.cpp index 8a98bd2fa..0c97f9532 100644 --- a/trinity/Particle/Tr2ParticleAttractorForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleAttractorForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2ParticleAttractorForce ); const Be::ClassInfo* Tr2ParticleAttractorForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleAttractorForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleAttractorForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleAttractorForce ) diff --git a/trinity/Particle/Tr2ParticleDirectForce.cpp b/trinity/Particle/Tr2ParticleDirectForce.cpp index 500467345..6c5d5b6f5 100644 --- a/trinity/Particle/Tr2ParticleDirectForce.cpp +++ b/trinity/Particle/Tr2ParticleDirectForce.cpp @@ -4,15 +4,15 @@ #include "Tr2ParticleDirectForce.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif -Tr2ParticleDirectForce::Tr2ParticleDirectForce( IRoot* lockobj ): +Tr2ParticleDirectForce::Tr2ParticleDirectForce( IRoot* lockobj ) : m_force( 1.f, 1.f, 1.f ) { } diff --git a/trinity/Particle/Tr2ParticleDirectForce.h b/trinity/Particle/Tr2ParticleDirectForce.h index 624c85669..e76131179 100644 --- a/trinity/Particle/Tr2ParticleDirectForce.h +++ b/trinity/Particle/Tr2ParticleDirectForce.h @@ -10,13 +10,12 @@ BLUE_DECLARE( Tr2ParticleDirectForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. +// A force to apply to particles in a particle system. // Represents a constant force. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleDirectForce: - public ITr2ParticleForce +class Tr2ParticleDirectForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -25,7 +24,9 @@ class Tr2ParticleDirectForce: ~Tr2ParticleDirectForce(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2ParticleDirectForce_Blue.cpp b/trinity/Particle/Tr2ParticleDirectForce_Blue.cpp index 25c561f58..647b1a2b9 100644 --- a/trinity/Particle/Tr2ParticleDirectForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleDirectForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2ParticleDirectForce ); const Be::ClassInfo* Tr2ParticleDirectForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleDirectForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleDirectForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleDirectForce ) diff --git a/trinity/Particle/Tr2ParticleDragForce.cpp b/trinity/Particle/Tr2ParticleDragForce.cpp index 7d5fe89da..5b7179276 100644 --- a/trinity/Particle/Tr2ParticleDragForce.cpp +++ b/trinity/Particle/Tr2ParticleDragForce.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "Tr2ParticleDragForce.h" -Tr2ParticleDragForce::Tr2ParticleDragForce( IRoot* lockobj ): +Tr2ParticleDragForce::Tr2ParticleDragForce( IRoot* lockobj ) : m_dragConstant( 0.1f ) { } diff --git a/trinity/Particle/Tr2ParticleDragForce.h b/trinity/Particle/Tr2ParticleDragForce.h index f044dd605..a9bf81882 100644 --- a/trinity/Particle/Tr2ParticleDragForce.h +++ b/trinity/Particle/Tr2ParticleDragForce.h @@ -10,14 +10,13 @@ BLUE_DECLARE( Tr2ParticleDragForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. -// Represents a drag force: proportional and opposite to +// A force to apply to particles in a particle system. +// Represents a drag force: proportional and opposite to // particle velocity. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleDragForce: - public ITr2ParticleForce +class Tr2ParticleDragForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -26,7 +25,9 @@ class Tr2ParticleDragForce: ~Tr2ParticleDragForce(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } private: // Drag coefficient diff --git a/trinity/Particle/Tr2ParticleDragForce_Blue.cpp b/trinity/Particle/Tr2ParticleDragForce_Blue.cpp index 147598fbd..2e6382697 100644 --- a/trinity/Particle/Tr2ParticleDragForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleDragForce_Blue.cpp @@ -7,11 +7,11 @@ BLUE_DEFINE( Tr2ParticleDragForce ); const Be::ClassInfo* Tr2ParticleDragForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleDragForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleDragForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleDragForce ) - MAP_ATTRIBUTE( "drag", m_dragConstant, "Applies a drag force: -bV where V is the velocity of a particle", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "drag", m_dragConstant, "Applies a drag force: -bV where V is the velocity of a particle", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Particle/Tr2ParticleElementDeclaration.cpp b/trinity/Particle/Tr2ParticleElementDeclaration.cpp index 135f0c088..2a9651e1c 100644 --- a/trinity/Particle/Tr2ParticleElementDeclaration.cpp +++ b/trinity/Particle/Tr2ParticleElementDeclaration.cpp @@ -9,8 +9,8 @@ // Arguments: // type - Element type to initialize new name with // -------------------------------------------------------------------------------------- -Tr2ParticleElementDeclarationName::Tr2ParticleElementDeclarationName( Type type ) - :m_type( type ) +Tr2ParticleElementDeclarationName::Tr2ParticleElementDeclarationName( Type type ) : + m_type( type ) { } @@ -21,8 +21,8 @@ Tr2ParticleElementDeclarationName::Tr2ParticleElementDeclarationName( Type type // type - Element type to initialize new name with // name - Nameto initialize new name with (in case type is CUSTOM) // -------------------------------------------------------------------------------------- -Tr2ParticleElementDeclarationName::Tr2ParticleElementDeclarationName( Type type, std::string name ) - :m_type( type ), +Tr2ParticleElementDeclarationName::Tr2ParticleElementDeclarationName( Type type, std::string name ) : + m_type( type ), m_name( name ) { } @@ -100,8 +100,8 @@ Tr2VertexDefinition::UsageCode Tr2ParticleElementDeclarationName::GetD3DUsage() // Description: // Tr2ParticleElementDeclaration default constructor // -------------------------------------------------------------------------------------- -Tr2ParticleElementDeclaration::Tr2ParticleElementDeclaration( IRoot* lockobj ) - :m_name( Tr2ParticleElementDeclarationName::CUSTOM ), +Tr2ParticleElementDeclaration::Tr2ParticleElementDeclaration( IRoot* lockobj ) : + m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_dimension( 1 ), m_usageIndex( 0 ), m_usedByGPU( true ) diff --git a/trinity/Particle/Tr2ParticleElementDeclaration.h b/trinity/Particle/Tr2ParticleElementDeclaration.h index 11cffc8d4..57e8ebce4 100644 --- a/trinity/Particle/Tr2ParticleElementDeclaration.h +++ b/trinity/Particle/Tr2ParticleElementDeclaration.h @@ -93,11 +93,11 @@ struct Tr2ParticleElementData // -------------------------------------------------------------------------------------- // Description: // Tr2ParticleStreamIterator is a helper class to manage a stream of typed data. Used -// internally be particle system components. +// internally be particle system components. // See Also: // Tr2ParticleElementDeclaration, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -template +template class Tr2ParticleStreamIterator { public: @@ -105,13 +105,13 @@ class Tr2ParticleStreamIterator // Description: // Constructs an iterator. // Arguments: - // particle - Array of pointers to particle data; number of elements in array is + // particle - Array of pointers to particle data; number of elements in array is // Tr2ParticleElementData::COUNT. // strides - Array of strides (number of floats) per particle in particle arrays. // element - Particle element of interest. // ---------------------------------------------------------------------------------- - Tr2ParticleStreamIterator( float** particle, unsigned* strides, const Tr2ParticleElementData& element ) - :m_data( particle[element.m_bufferType] + element.m_offset ), + Tr2ParticleStreamIterator( float** particle, unsigned* strides, const Tr2ParticleElementData& element ) : + m_data( particle[element.m_bufferType] + element.m_offset ), m_stride( strides[element.m_bufferType] ) { } @@ -175,6 +175,7 @@ class Tr2ParticleStreamIterator { return ( uintptr_t( m_data ) & 15 ) == 0; } + private: // Pointer to the current particle element data float* m_data; @@ -188,8 +189,8 @@ class Tr2ParticleStreamIterator // See Also: // Tr2ParticleSystem // -------------------------------------------------------------------------------------- -typedef std::map - Tr2ParticleElementDataMap; +typedef std::map + Tr2ParticleElementDataMap; // -------------------------------------------------------------------------------------- // Description: @@ -199,7 +200,7 @@ typedef std::map // See Also: // Tr2ParticleSystem // -------------------------------------------------------------------------------------- -class Tr2ParticleElementDeclaration: public IRoot +class Tr2ParticleElementDeclaration : public IRoot { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Particle/Tr2ParticleElementDeclaration_Blue.cpp b/trinity/Particle/Tr2ParticleElementDeclaration_Blue.cpp index e9f2ee902..9e602545f 100644 --- a/trinity/Particle/Tr2ParticleElementDeclaration_Blue.cpp +++ b/trinity/Particle/Tr2ParticleElementDeclaration_Blue.cpp @@ -3,42 +3,30 @@ #include "StdAfx.h" #include "Tr2ParticleElementDeclaration.h" -Be::VarChooser Tr2ParticleElementDeclarationNameTypeChooser[] = -{ - { - "LIFETIME", - BeCast( Tr2ParticleElementDeclarationName::LIFETIME ), - "Particle life time (2D float)" - }, - { - "POSITION", - BeCast( Tr2ParticleElementDeclarationName::POSITION ), - "Particle position (3D vector)" - }, - { - "VELOCITY", - BeCast( Tr2ParticleElementDeclarationName::VELOCITY ), - "Particle velocity (3D vector)" - }, - { - "MASS", - BeCast( Tr2ParticleElementDeclarationName::MASS ), - "Particle mass (1D float)" - }, - { - "CUSTOM", - BeCast( Tr2ParticleElementDeclarationName::CUSTOM ), - "Custom data" - }, +Be::VarChooser Tr2ParticleElementDeclarationNameTypeChooser[] = { + { "LIFETIME", + BeCast( Tr2ParticleElementDeclarationName::LIFETIME ), + "Particle life time (2D float)" }, + { "POSITION", + BeCast( Tr2ParticleElementDeclarationName::POSITION ), + "Particle position (3D vector)" }, + { "VELOCITY", + BeCast( Tr2ParticleElementDeclarationName::VELOCITY ), + "Particle velocity (3D vector)" }, + { "MASS", + BeCast( Tr2ParticleElementDeclarationName::MASS ), + "Particle mass (1D float)" }, + { "CUSTOM", + BeCast( Tr2ParticleElementDeclarationName::CUSTOM ), + "Custom data" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( - "PARTICLE_ELEMENT_TYPE", - Tr2ParticleElementDeclarationName::Type, - Tr2ParticleElementDeclarationNameTypeChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "PARTICLE_ELEMENT_TYPE", + Tr2ParticleElementDeclarationName::Type, + Tr2ParticleElementDeclarationNameTypeChooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( Tr2ParticleElementDeclaration ); @@ -47,18 +35,18 @@ const Be::ClassInfo* Tr2ParticleElementDeclaration::ExposeToBlue() { EXPOSURE_BEGIN( Tr2ParticleElementDeclaration, "" ) MAP_INTERFACE( Tr2ParticleElementDeclaration ) - - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) MAP_ATTRIBUTE( "customName", m_name.m_name, "Name for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "dimension", m_dimension, "Data dimentsion for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "usageIndex", m_usageIndex, "Shader usage index for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "usedByGPU", m_usedByGPU, "Is this element used by shaders", Be::READWRITE | Be::PERSIST ) - + EXPOSURE_END() } diff --git a/trinity/Particle/Tr2ParticleFluidDragForce.cpp b/trinity/Particle/Tr2ParticleFluidDragForce.cpp index f672fe57b..bb1dec232 100644 --- a/trinity/Particle/Tr2ParticleFluidDragForce.cpp +++ b/trinity/Particle/Tr2ParticleFluidDragForce.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "Tr2ParticleFluidDragForce.h" -Tr2ParticleFluidDragForce::Tr2ParticleFluidDragForce( IRoot* lockobj ): +Tr2ParticleFluidDragForce::Tr2ParticleFluidDragForce( IRoot* lockobj ) : m_dragConstant( 1.f ) { } diff --git a/trinity/Particle/Tr2ParticleFluidDragForce.h b/trinity/Particle/Tr2ParticleFluidDragForce.h index f2bce81c9..8c8a90459 100644 --- a/trinity/Particle/Tr2ParticleFluidDragForce.h +++ b/trinity/Particle/Tr2ParticleFluidDragForce.h @@ -10,15 +10,14 @@ BLUE_DECLARE( Tr2ParticleFluidDragForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. -// Represents a drag force in fluids; similar to -// Tr2ParticleDragForce, but depends on a square of particle +// A force to apply to particles in a particle system. +// Represents a drag force in fluids; similar to +// Tr2ParticleDragForce, but depends on a square of particle // speed. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleFluidDragForce: - public ITr2ParticleForce +class Tr2ParticleFluidDragForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -27,7 +26,9 @@ class Tr2ParticleFluidDragForce: ~Tr2ParticleFluidDragForce(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } private: // Drag coefficient diff --git a/trinity/Particle/Tr2ParticleFluidDragForce_Blue.cpp b/trinity/Particle/Tr2ParticleFluidDragForce_Blue.cpp index f9a29b648..9b7acd910 100644 --- a/trinity/Particle/Tr2ParticleFluidDragForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleFluidDragForce_Blue.cpp @@ -7,11 +7,11 @@ BLUE_DEFINE( Tr2ParticleFluidDragForce ); const Be::ClassInfo* Tr2ParticleFluidDragForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleFluidDragForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleFluidDragForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleFluidDragForce ) - MAP_ATTRIBUTE( "drag", m_dragConstant, "Applies a drag force: -bV^2 where V is the velocity of a particle", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "drag", m_dragConstant, "Applies a drag force: -bV^2 where V is the velocity of a particle", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Particle/Tr2ParticleSpring.cpp b/trinity/Particle/Tr2ParticleSpring.cpp index 7b8f7932d..b238723ce 100644 --- a/trinity/Particle/Tr2ParticleSpring.cpp +++ b/trinity/Particle/Tr2ParticleSpring.cpp @@ -4,12 +4,12 @@ #include "Tr2ParticleSpring.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif Tr2ParticleSpring::Tr2ParticleSpring( IRoot* lockobj ) : @@ -20,7 +20,6 @@ Tr2ParticleSpring::Tr2ParticleSpring( IRoot* lockobj ) : Tr2ParticleSpring::~Tr2ParticleSpring() { - } // ------------------------------------------------------------- @@ -38,7 +37,6 @@ XMVECTOR Tr2ParticleSpring::GetForce( FXMVECTOR position, FXMVECTOR velocity, fl { XMVECTOR direction = XMVectorSubtract( position, m_position ); return XMVectorScale( direction, -m_springConstant ); - } void Tr2ParticleSpring::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const diff --git a/trinity/Particle/Tr2ParticleSpring.h b/trinity/Particle/Tr2ParticleSpring.h index 8a90e2897..61b0e1105 100644 --- a/trinity/Particle/Tr2ParticleSpring.h +++ b/trinity/Particle/Tr2ParticleSpring.h @@ -10,23 +10,25 @@ BLUE_DECLARE( Tr2ParticleSpring ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. +// A force to apply to particles in a particle system. // Represents a spring force: proportional to the distance from // particle to a fixed "spring origin". // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleSpring: - public ITr2ParticleForce +class Tr2ParticleSpring : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); - Tr2ParticleSpring( IRoot* lockobj = 0 );; + Tr2ParticleSpring( IRoot* lockobj = 0 ); + ; ~Tr2ParticleSpring(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - virtual void Update( float dt ) {} + virtual void Update( float dt ) + { + } void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2ParticleSpring_Blue.cpp b/trinity/Particle/Tr2ParticleSpring_Blue.cpp index 10d693682..8c05a664c 100644 --- a/trinity/Particle/Tr2ParticleSpring_Blue.cpp +++ b/trinity/Particle/Tr2ParticleSpring_Blue.cpp @@ -7,11 +7,11 @@ BLUE_DEFINE( Tr2ParticleSpring ); const Be::ClassInfo* Tr2ParticleSpring::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleSpring, "" ) + EXPOSURE_BEGIN( Tr2ParticleSpring, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleSpring ) - MAP_ATTRIBUTE( "springConstant", m_springConstant, "Applies a force from or towards a point proportional to the distance to that point", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "springConstant", m_springConstant, "Applies a force from or towards a point proportional to the distance to that point", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() diff --git a/trinity/Particle/Tr2ParticleSystem.cpp b/trinity/Particle/Tr2ParticleSystem.cpp index a52efcf4e..869d3cc50 100644 --- a/trinity/Particle/Tr2ParticleSystem.cpp +++ b/trinity/Particle/Tr2ParticleSystem.cpp @@ -31,8 +31,8 @@ CcpAtomic s_updatedParticleCount( 0 ); // Description: // Tr2ParticleSystem default constructor // -------------------------------------------------------------------------------------- -Tr2ParticleSystem::Tr2ParticleSystem( IRoot* lockobj ) - :PARENTLOCK( m_elements ), +Tr2ParticleSystem::Tr2ParticleSystem( IRoot* lockobj ) : + PARENTLOCK( m_elements ), PARENTLOCK( m_forces ), PARENTLOCK( m_constraints ), m_declaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), @@ -51,7 +51,7 @@ Tr2ParticleSystem::Tr2ParticleSystem( IRoot* lockobj ) m_sortingAllowed( true ), m_isGlobal( false ), m_isValid( false ), - m_AabbMin( 0.0f, 0.0f, 0.0f ), + m_AabbMin( 0.0f, 0.0f, 0.0f ), m_AabbMax( 0.0f, 0.0f, 0.0f ), m_updatePeriod( 1 ), m_updatePeriodClock( 0 ), @@ -72,9 +72,9 @@ Tr2ParticleSystem::Tr2ParticleSystem( IRoot* lockobj ) m_semanticElements[i].m_offset = -1; } - m_sortingReferencePoint = (XMVECTOR*)CCP_ALIGNED_MALLOC( - "Tr2ParticleSystem::m_sortingReferencePoint", - sizeof( XMVECTOR ), + m_sortingReferencePoint = (XMVECTOR*)CCP_ALIGNED_MALLOC( + "Tr2ParticleSystem::m_sortingReferencePoint", + sizeof( XMVECTOR ), 16 ); GetAllSystems().insert( this ); @@ -130,9 +130,9 @@ bool Tr2ParticleSystem::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the system to respond to parameter changes -// generated in Python. Monitors changes to maximum nuber of particles (to resize -// buffers), requiresSorting flag and useSimTimeRebase flag. +// Implements INotify interface. Allows the system to respond to parameter changes +// generated in Python. Monitors changes to maximum nuber of particles (to resize +// buffers), requiresSorting flag and useSimTimeRebase flag. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -142,7 +142,7 @@ bool Tr2ParticleSystem::OnModified( Be::Var* value ) { if( IsMatch( value, m_requiresSorting ) ) { - CCP_DELETE []m_indexes; + CCP_DELETE[] m_indexes; if( m_requiresSorting && m_maxParticleCount ) { m_indexes = CCP_NEW( "Tr2ParticleSystem::m_indexes" ) unsigned[m_maxParticleCount]; @@ -178,8 +178,8 @@ bool Tr2ParticleSystem::OnModified( Be::Var* value ) // -------------------------------------------------------------------------------------- // Description: -// Utility function for setting maxParticleCount of the particle system. This is used -// to setup a Blue property. If there are live particles the particle system buffer +// Utility function for setting maxParticleCount of the particle system. This is used +// to setup a Blue property. If there are live particles the particle system buffer // will be rebuilt and all particles cleared. // Arguments: // maxParticleCount - The new maxParticleCount value @@ -194,7 +194,7 @@ void Tr2ParticleSystem::SetMaxParticleCount( unsigned maxParticleCount ) // -------------------------------------------------------------------------------------- // Description: -// Utility function for getting the particle system's maxParticleCount. This is used +// Utility function for getting the particle system's maxParticleCount. This is used // to setup a Blue property. // Return Value: // The particle system's maxParticleCount. @@ -207,7 +207,7 @@ unsigned Tr2ParticleSystem::GetMaxParticleCount() const // -------------------------------------------------------------------------------------- // Description: -// Implements IListNotify interface. Binds added particle constraints to the system. +// Implements IListNotify interface. Binds added particle constraints to the system. // Arguments: // event - List event type // key - First element index (unused) @@ -222,8 +222,7 @@ void Tr2ParticleSystem::OnListModified( ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ) + const IList* theList ) { if( theList == &m_constraints ) { @@ -233,7 +232,7 @@ void Tr2ParticleSystem::OnListModified( if( value ) { ITr2GenericParticleConstraint* constraint = NULL; - if( value->QueryInterface( BlueInterfaceIID(), ( void** )&constraint ) ) + if( value->QueryInterface( BlueInterfaceIID(), (void**)&constraint ) ) { constraint->Bind( this ); constraint->Unlock(); @@ -245,7 +244,7 @@ void Tr2ParticleSystem::OnListModified( // -------------------------------------------------------------------------------------- // Description: -// Implements Tr2DeviceResource method. Releases vertex buffer and declaration. +// Implements Tr2DeviceResource method. Releases vertex buffer and declaration. // Arguments: // s - Type of video memory to release // -------------------------------------------------------------------------------------- @@ -258,7 +257,7 @@ void Tr2ParticleSystem::ReleaseResources( TriStorage s ) // -------------------------------------------------------------------------------------- // Description: -// Implements Tr2DeviceResource method. Recreates vertex buffer and declaration. +// Implements Tr2DeviceResource method. Recreates vertex buffer and declaration. // -------------------------------------------------------------------------------------- bool Tr2ParticleSystem::OnPrepareResources() { @@ -269,7 +268,7 @@ bool Tr2ParticleSystem::OnPrepareResources() // -------------------------------------------------------------------------------------- // Description: -// Create a vertex buffer for particle data if needed. +// Create a vertex buffer for particle data if needed. // Return value: // true If the buffer was created or is not needed // false On error @@ -280,12 +279,13 @@ bool Tr2ParticleSystem::CreateVertexBuffer() if( m_maxParticleCount > 0 && m_vertexSizes[Tr2ParticleElementData::GPU] > 0 ) { CR_RETURN_VAL( m_vertexBuffer.Create( - m_vertexSizes[Tr2ParticleElementData::GPU] * sizeof( float ), - m_maxParticleCount, - Tr2GpuUsage::VERTEX_BUFFER, - Tr2CpuUsage::WRITE_OFTEN, - nullptr, - renderContext ), false ); + m_vertexSizes[Tr2ParticleElementData::GPU] * sizeof( float ), + m_maxParticleCount, + Tr2GpuUsage::VERTEX_BUFFER, + Tr2CpuUsage::WRITE_OFTEN, + nullptr, + renderContext ), + false ); m_bufferDirty = true; } return true; @@ -356,7 +356,7 @@ void Tr2ParticleSystem::DestroyBuffers() if( m_indexes ) { - CCP_DELETE []m_indexes; + CCP_DELETE[] m_indexes; m_indexes = nullptr; } @@ -368,7 +368,7 @@ void Tr2ParticleSystem::DestroyBuffers() m_buffers[i] = nullptr; } } - + m_vertexBuffer = Tr2BufferAL(); m_aliveCount = 0; @@ -388,7 +388,7 @@ void Tr2ParticleSystem::BuildBuffers() { return; } - + if( !m_isValid ) { return; @@ -413,9 +413,9 @@ void Tr2ParticleSystem::BuildBuffers() for( unsigned i = 0; i < Tr2ParticleElementData::COUNT; ++i ) { - m_buffers[i] = ( float* )CCP_ALIGNED_MALLOC( + m_buffers[i] = (float*)CCP_ALIGNED_MALLOC( "Tr2ParticleSystem::m_buffers", - sizeof( float ) * m_maxParticleCount * m_vertexSizes[i], + sizeof( float ) * m_maxParticleCount * m_vertexSizes[i], 16 ); } if( m_vertexSizes[Tr2ParticleElementData::GPU] > 0 && Tr2Renderer::IsResourceCreationAllowed() ) @@ -500,11 +500,10 @@ void Tr2ParticleSystem::Update( const ITr2GenericEmitter::UpdateArguments& globa { //Save the current data so we have the previous frame's data for motion vectors //This kinda has to be done regardless of if we tick or not, to make sure it's always up to date for rendering... - std::copy( + std::copy( gpuBuffer + i * gpuDataSize, gpuBuffer + i * gpuDataSize + gpuDataHalfSize, - gpuBuffer + i * gpuDataSize + gpuDataHalfSize - ); + gpuBuffer + i * gpuDataSize + gpuDataHalfSize ); } m_previousDataOutdated = false; @@ -529,7 +528,7 @@ void Tr2ParticleSystem::Update( const ITr2GenericEmitter::UpdateArguments& globa m_lastUpdate = arguments.time; //include considerable hysteresis in toggling sorting. - //Things to consider: + //Things to consider: // frametime breakpoints as global constant/setting/per-system? // re-enable a limited number of systems per frame? if( dt > 0.035f && m_sortingAllowed ) @@ -546,8 +545,8 @@ void Tr2ParticleSystem::Update( const ITr2GenericEmitter::UpdateArguments& globa // -------------------------------------------------------------------------------------- // Description: -// Updates per-particle data (age, positions, etc.), removes dead particles, emits new -// particles with "emit during lifetime" and "emit on death" emitters. This function +// Updates per-particle data (age, positions, etc.), removes dead particles, emits new +// particles with "emit during lifetime" and "emit on death" emitters. This function // can be called asyncronously. // Arguments: // arguments - Child emitter update arguments @@ -582,18 +581,18 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume { if( m_emissionOnDeathEmitter ) { - m_emissionOnDeathEmitter->SpawnParticles( arguments, - reinterpret_cast( position ), + m_emissionOnDeathEmitter->SpawnParticles( arguments, + reinterpret_cast( position ), reinterpret_cast( velocity ) ); - } + } m_aliveCount -= 1; if( i < m_aliveCount ) { for( unsigned j = 0; j < Tr2ParticleElementData::COUNT; ++j ) { - std::copy( m_buffers[j] + m_aliveCount * m_vertexSizes[j], - m_buffers[j] + ( m_aliveCount + 1 ) * m_vertexSizes[j], + std::copy( m_buffers[j] + m_aliveCount * m_vertexSizes[j], + m_buffers[j] + ( m_aliveCount + 1 ) * m_vertexSizes[j], m_buffers[j] + i * m_vertexSizes[j] ); } } @@ -622,12 +621,12 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume m_previousDataOutdated = true; } - + s_aliveParticleCount += m_aliveCount; // Calculate forces and update position - if( m_updateSimulation && - HasElement( Tr2ParticleElementDeclarationName::POSITION ) && + if( m_updateSimulation && + HasElement( Tr2ParticleElementDeclarationName::POSITION ) && HasElement( Tr2ParticleElementDeclarationName::VELOCITY ) ) { bool hasForces = m_applyForce && !m_forces.empty(); @@ -648,11 +647,10 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume float* massStart = nullptr; unsigned massStride; GetElementStream( Tr2ParticleElementDeclarationName::MASS, massStart, massStride ); - - Tr2ParallelFor( - Tr2BlockedRange( 0, m_aliveCount, 100 ), - [=]( const Tr2BlockedRange& range ) -> void - { + + Tr2ParallelFor( + Tr2BlockedRange( 0, m_aliveCount, 100 ), + [=]( const Tr2BlockedRange& range ) -> void { float* position = positionStart + range.begin() * positionStride; float* velocity = velocityStart + range.begin() * velocityStride; float* mass = nullptr; @@ -685,23 +683,23 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume { force = XMVectorScale( force, 1.f / particleMass ); } - XMStoreFloat4A( reinterpret_cast( velocity ), + XMStoreFloat4A( reinterpret_cast( velocity ), XMVectorAdd( particleVelocity, XMVectorScale( force, dt ) ) ); } - XMStoreFloat4A( - reinterpret_cast( position ), - XMVectorAdd( - XMLoadFloat4A( reinterpret_cast( position ) ), + XMStoreFloat4A( + reinterpret_cast( position ), + XMVectorAdd( + XMLoadFloat4A( reinterpret_cast( position ) ), XMVectorScale( XMLoadFloat4A( reinterpret_cast( velocity ) ), dt ) ) ); - + if( m_emissionWhileAliveEmitter != nullptr ) { - m_emissionWhileAliveEmitter->SpawnParticles( + m_emissionWhileAliveEmitter->SpawnParticles( arguments, reinterpret_cast( &particlePosition ), - reinterpret_cast( position ), + reinterpret_cast( position ), reinterpret_cast( &particleVelocity ), reinterpret_cast( velocity ), dt ); @@ -731,7 +729,7 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume // Update bounding box if( m_bufferDirty ) { - if( m_aliveCount > 0 && HasElement( Tr2ParticleElementDeclarationName::POSITION ) ) + if( m_aliveCount > 0 && HasElement( Tr2ParticleElementDeclarationName::POSITION ) ) { float* position = nullptr; unsigned positionStride; @@ -760,9 +758,9 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume // If the particles have both position and velocity streams, this will occur during update // and provide additional information to the m_emissionWhileAliveEmitter object // (but only if m_updateSimulation is true) - const bool positionAndVelocity = HasElement( Tr2ParticleElementDeclarationName::POSITION ) && - HasElement( Tr2ParticleElementDeclarationName::VELOCITY ); - if( m_emissionWhileAliveEmitter && !(positionAndVelocity && m_updateSimulation) ) + const bool positionAndVelocity = HasElement( Tr2ParticleElementDeclarationName::POSITION ) && + HasElement( Tr2ParticleElementDeclarationName::VELOCITY ); + if( m_emissionWhileAliveEmitter && !( positionAndVelocity && m_updateSimulation ) ) { float* positionStart = nullptr; unsigned positionStride; @@ -772,10 +770,9 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume unsigned velocityStride; GetElementStream( Tr2ParticleElementDeclarationName::VELOCITY, velocityStart, velocityStride ); - Tr2ParallelFor( - Tr2BlockedRange( 0, m_aliveCount, 100 ), - [=]( const Tr2BlockedRange& range ) -> void - { + Tr2ParallelFor( + Tr2BlockedRange( 0, m_aliveCount, 100 ), + [=]( const Tr2BlockedRange& range ) -> void { float* position = nullptr; if( positionStart ) { @@ -790,9 +787,9 @@ void Tr2ParticleSystem::UpdateSimulation( const ITr2GenericEmitter::UpdateArgume { if( m_emissionWhileAliveEmitter != nullptr ) { - m_emissionWhileAliveEmitter->SpawnParticles( + m_emissionWhileAliveEmitter->SpawnParticles( arguments, - reinterpret_cast( position ), + reinterpret_cast( position ), reinterpret_cast( velocity ), dt ); } @@ -839,7 +836,7 @@ bool Tr2ParticleSystem::CompareParticles( unsigned particle1, unsigned particle2 // -------------------------------------------------------------------------------------- // Description: -// Per-frame update method for all created Tr2ParticleSystem objects. Calls Update +// Per-frame update method for all created Tr2ParticleSystem objects. Calls Update // method of each system asyncronously. // Arguments: // arguments - Child emitter update arguments @@ -860,8 +857,8 @@ void Tr2ParticleSystem::UpdateAllSystems( const ITr2GenericEmitter::UpdateArgume std::set& allSystems = GetAllSystems(); - Tr2ParallelDo( allSystems.begin(), - allSystems.end(), + Tr2ParallelDo( allSystems.begin(), + allSystems.end(), [=]( Tr2ParticleSystem* system ) { system->Update( arguments ); } ); CCP_STATS_SET( statAliveParticleCount, s_aliveParticleCount ); @@ -887,7 +884,7 @@ std::set& Tr2ParticleSystem::GetAllSystems() void Tr2ParticleSystem::RebuildDeclaration() { Tr2VertexDefinition vd; - + for( auto it = m_elementMap.begin(); it != m_elementMap.end(); ++it ) { //Skip things we don't want to upload to the GPU @@ -901,7 +898,7 @@ void Tr2ParticleSystem::RebuildDeclaration() item.m_offset = it->second.m_offset * sizeof( float ); item.m_dataType = static_cast( vd.DT_FLOAT32 + ( ( it->second.m_dimension - 1 ) << vd.DT_SIZE_OFFSET ) ); item.m_usage = it->first.GetD3DUsage(); - + item.m_usageIndex = it->first.m_type == Tr2ParticleElementDeclarationName::CUSTOM ? it->second.m_usageIndex : 0; vd.m_items.push_back( item ); @@ -926,7 +923,7 @@ void Tr2ParticleSystem::RebuildDeclaration() vd.m_nextOffset[0] = std::max( vd.m_nextOffset[0], item.m_offset + vd.GetDataTypeSizeInBytes( item.m_dataType ) ); } } - + m_declaration = Tr2EffectStateManager::GetVertexDeclarationHandle( vd ); } @@ -938,20 +935,20 @@ void Tr2ParticleSystem::RebuildDeclaration() void Tr2ParticleSystem::EnsureAligned() { // Move POSITION and VELOCITY elements into the beginning of their buffers. If they - // are in the same buffer, make the following arrangement: + // are in the same buffer, make the following arrangement: // POSITION pad VELOCITY all_other_stuff // Here pad is 4-byte padding to align VELOCITY. Tr2ParticleElementDeclarationName::Type position = Tr2ParticleElementDeclarationName::POSITION; Tr2ParticleElementDeclarationName::Type velocity = Tr2ParticleElementDeclarationName::VELOCITY; if( m_semanticElements[position].m_offset != -1 ) { - ShiftOffsets( - m_semanticElements[position].m_bufferType, - m_semanticElements[position].m_offset, + ShiftOffsets( + m_semanticElements[position].m_bufferType, + m_semanticElements[position].m_offset, -int( m_semanticElements[position].m_dimension ) ); - ShiftOffsets( - m_semanticElements[position].m_bufferType, - 0, + ShiftOffsets( + m_semanticElements[position].m_bufferType, + 0, 4 ); m_semanticElements[position].m_offset = 0; m_elementMap[position].m_offset = 0; @@ -960,25 +957,25 @@ void Tr2ParticleSystem::EnsureAligned() } if( m_semanticElements[velocity].m_offset != -1 ) { - ShiftOffsets( - m_semanticElements[velocity].m_bufferType, - m_semanticElements[velocity].m_offset, + ShiftOffsets( + m_semanticElements[velocity].m_bufferType, + m_semanticElements[velocity].m_offset, -int( m_semanticElements[velocity].m_dimension ) ); - if( m_semanticElements[position].m_offset != -1 && + if( m_semanticElements[position].m_offset != -1 && m_semanticElements[velocity].m_bufferType == m_semanticElements[position].m_bufferType ) { - ShiftOffsets( - m_semanticElements[velocity].m_bufferType, - 4, + ShiftOffsets( + m_semanticElements[velocity].m_bufferType, + 4, 4 ); m_semanticElements[velocity].m_offset = 4; m_elementMap[velocity].m_offset = 4; } else { - ShiftOffsets( - m_semanticElements[velocity].m_bufferType, - 0, + ShiftOffsets( + m_semanticElements[velocity].m_bufferType, + 0, 4 ); m_semanticElements[velocity].m_offset = 0; m_elementMap[velocity].m_offset = 0; @@ -997,14 +994,14 @@ void Tr2ParticleSystem::EnsureAligned() // start - Offset start // shift - Offset shift // -------------------------------------------------------------------------------------- -void Tr2ParticleSystem::ShiftOffsets( Tr2ParticleElementData::BufferType bufferType, - unsigned start, +void Tr2ParticleSystem::ShiftOffsets( Tr2ParticleElementData::BufferType bufferType, + unsigned start, int shift ) { for( auto it = m_elementMap.begin(); it != m_elementMap.end(); ++it ) { - if( it->second.m_bufferType == bufferType && - it->second.m_offset != -1 && + if( it->second.m_bufferType == bufferType && + it->second.m_offset != -1 && it->second.m_offset >= start ) { it->second.m_offset += shift; @@ -1038,7 +1035,7 @@ void Tr2ParticleSystem::UpdateViewDependentData( const TriFrustum* frustum, cons { return; } - + m_shouldSortVisible = true; m_updatePeriod = 1; if( frustum ) @@ -1079,7 +1076,7 @@ void Tr2ParticleSystem::SortParticles() { return; } - + XMMATRIX invWorldTransform = m_worldTransform; XMVECTOR determinant; invWorldTransform = XMMatrixInverse( &determinant, invWorldTransform ); @@ -1102,22 +1099,21 @@ void Tr2ParticleSystem::SortParticles() m_indexes[i] = i; } - Tr2ParallelSort( - m_indexes, - m_indexes + m_aliveCount, - [=]( unsigned particle1, unsigned particle2 ) -> bool - { - return CompareParticles( particle1, particle2 ); - } ); + Tr2ParallelSort( + m_indexes, + m_indexes + m_aliveCount, + [=]( unsigned particle1, unsigned particle2 ) -> bool { + return CompareParticles( particle1, particle2 ); + } ); if( m_vertexBuffer.IsValid() ) { float* data; CR_RETURN( m_vertexBuffer.MapForWriting( data, renderContext ) ); - ON_BLOCK_EXIT( [&]{ m_vertexBuffer.UnmapForWriting( renderContext ); } ); + ON_BLOCK_EXIT( [&] { m_vertexBuffer.UnmapForWriting( renderContext ); } ); for( unsigned i = 0; i < m_aliveCount; ++i ) { - std::copy( + std::copy( m_buffers[Tr2ParticleElementData::GPU] + m_indexes[i] * m_vertexSizes[Tr2ParticleElementData::GPU], m_buffers[Tr2ParticleElementData::GPU] + ( m_indexes[i] + 1 ) * m_vertexSizes[Tr2ParticleElementData::GPU], data + i * m_vertexSizes[Tr2ParticleElementData::GPU] ); @@ -1128,10 +1124,10 @@ void Tr2ParticleSystem::SortParticles() { float* data; CR_RETURN( m_vertexBuffer.MapForWriting( data, renderContext ) ); - ON_BLOCK_EXIT( [&]{ m_vertexBuffer.UnmapForWriting( renderContext ); } ); - std::copy( - m_buffers[Tr2ParticleElementData::GPU], - m_buffers[Tr2ParticleElementData::GPU] + m_aliveCount * m_vertexSizes[Tr2ParticleElementData::GPU], + ON_BLOCK_EXIT( [&] { m_vertexBuffer.UnmapForWriting( renderContext ); } ); + std::copy( + m_buffers[Tr2ParticleElementData::GPU], + m_buffers[Tr2ParticleElementData::GPU] + m_aliveCount * m_vertexSizes[Tr2ParticleElementData::GPU], data ); } } @@ -1193,10 +1189,10 @@ void Tr2ParticleSystem::UpdateElementDeclaration() { if( ( *it )->m_usageIndex >= USAGE_INDEX_COUNT ) { - CCP_LOGERR( - "Particle declaration element %s usage index %u is out of range (needs to be less than %u)", - ( *it )->GetName().c_str(), - ( *it )->m_usageIndex, + CCP_LOGERR( + "Particle declaration element %s usage index %u is out of range (needs to be less than %u)", + ( *it )->GetName().c_str(), + ( *it )->m_usageIndex, USAGE_INDEX_COUNT ); return; } @@ -1261,7 +1257,7 @@ void Tr2ParticleSystem::UpdateElementDeclaration() // -------------------------------------------------------------------------------------- // Description: -// Returns internal built particle element declaration. Can be used by emitters and +// Returns internal built particle element declaration. Can be used by emitters and // constraints to bind to individual particle elements. // Return Value: // Internal built particle element declaration @@ -1526,7 +1522,7 @@ void Tr2ParticleSystem::SaveToGranny( const char* resPath ) const granny_vertex_data* vertexData = CCP_NEW( "Tr2ParticleSystem::SaveToGranny" ) granny_vertex_data; memset( vertexData, 0, sizeof( granny_vertex_data ) ); vertexData->VertexType = definition; - vertexData->VertexComponentNames = CCP_NEW( "Tr2ParticleSystem::SaveToGranny" ) const char*[m_elementMap.size()]; + vertexData->VertexComponentNames = CCP_NEW( "Tr2ParticleSystem::SaveToGranny" ) const char * [m_elementMap.size()]; for( unsigned i = 0; i < m_elementMap.size(); ++i ) { vertexData->VertexComponentNames[i] = definition[i].Name; @@ -1546,8 +1542,8 @@ void Tr2ParticleSystem::SaveToGranny( const char* resPath ) const { for( auto j = m_elementMap.begin(); j != m_elementMap.end(); ++j ) { - float* element = m_buffers[j->second.m_bufferType] + - i * m_vertexSizes[j->second.m_bufferType] + + float* element = m_buffers[j->second.m_bufferType] + + i * m_vertexSizes[j->second.m_bufferType] + j->second.m_offset; std::copy( element, element + j->second.m_dimension, vertex + offsets[j->first] ); } @@ -1568,42 +1564,42 @@ void Tr2ParticleSystem::SaveToGranny( const char* resPath ) const topology->Indices16[1] = 0; topology->Indices16[2] = 0; - granny_mesh* mesh = CCP_NEW( "Tr2ParticleSystem::SaveToGranny" ) granny_mesh; + granny_mesh* mesh = CCP_NEW( "Tr2ParticleSystem::SaveToGranny" ) granny_mesh; memset( mesh, 0, sizeof( granny_mesh ) ); mesh->Name = m_name.c_str(); - mesh->PrimaryVertexData = vertexData; - mesh->PrimaryTopology = topology; + mesh->PrimaryVertexData = vertexData; + mesh->PrimaryTopology = topology; - granny_file_info info; + granny_file_info info; memset( &info, 0, sizeof( granny_file_info ) ); - info.MeshCount = 1; - info.Meshes = &mesh; - info.VertexDataCount = 1; - info.VertexDatas = &vertexData; - info.TriTopologyCount = 1; - info.TriTopologies = &topology; + info.MeshCount = 1; + info.Meshes = &mesh; + info.VertexDataCount = 1; + info.VertexDatas = &vertexData; + info.TriTopologyCount = 1; + info.TriTopologies = &topology; granny_file_builder* builder = GrannyBeginFile( - 1, - GrannyCurrentGRNStandardTag, - GrannyGRNFileMV_ThisPlatform, - GrannyGetTemporaryDirectory(), - "prefix2" ); - granny_file_data_tree_writer* writer = GrannyBeginFileDataTreeWriting( GrannyFileInfoType, &info, 0, 0 ); - - GrannyWriteDataTreeToFileBuilder( writer, builder ); - GrannyEndFileDataTreeWriting( writer ); - - GrannyEndFile( builder, CW2A( filename.c_str() ) ); + 1, + GrannyCurrentGRNStandardTag, + GrannyGRNFileMV_ThisPlatform, + GrannyGetTemporaryDirectory(), + "prefix2" ); + granny_file_data_tree_writer* writer = GrannyBeginFileDataTreeWriting( GrannyFileInfoType, &info, 0, 0 ); + + GrannyWriteDataTreeToFileBuilder( writer, builder ); + GrannyEndFileDataTreeWriting( writer ); + + GrannyEndFile( builder, CW2A( filename.c_str() ) ); CCP_DELETE mesh; - CCP_DELETE []topology->Indices16; + CCP_DELETE[] topology->Indices16; CCP_DELETE topology; - CCP_DELETE []vertexData->Vertices; - CCP_DELETE []vertexData->VertexComponentNames; + CCP_DELETE[] vertexData->Vertices; + CCP_DELETE[] vertexData->VertexComponentNames; CCP_DELETE vertexData; - CCP_DELETE []definition; + CCP_DELETE[] definition; } #endif @@ -1617,7 +1613,7 @@ void Tr2ParticleSystem::SaveToGranny( const char* resPath ) const // true If the system has valid bounding box // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2ParticleSystem::GetBoundingBox( Vector3 &minBounds, Vector3 &maxBounds ) const +bool Tr2ParticleSystem::GetBoundingBox( Vector3& minBounds, Vector3& maxBounds ) const { if( m_aliveCount > 0 ) { @@ -1653,7 +1649,7 @@ size_t Tr2ParticleSystem::GetGpuStride() const // -------------------------------------------------------------------------------------- // Description: -// Notifies particle system that it needs additional syncronization when inserting +// Notifies particle system that it needs additional syncronization when inserting // particles. Normally called by emitters that are identified to be emitting particles // during particle system updates. // -------------------------------------------------------------------------------------- @@ -1672,7 +1668,7 @@ void Tr2ParticleSystem::GetDebugOptions( Tr2DebugRendererOptions& options ) cons void Tr2ParticleSystem::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform ) const { - if ( !renderer.HasOption( this, "Particle Systems" ) ) + if( !renderer.HasOption( this, "Particle Systems" ) ) { return; } diff --git a/trinity/Particle/Tr2ParticleSystem.h b/trinity/Particle/Tr2ParticleSystem.h index c37dee99f..e2c980731 100644 --- a/trinity/Particle/Tr2ParticleSystem.h +++ b/trinity/Particle/Tr2ParticleSystem.h @@ -9,12 +9,12 @@ #include "ITr2GenericEmitter.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif BLUE_DECLARE_INTERFACE( ITr2ParticleForce ); @@ -30,7 +30,7 @@ class TriFrustum; // See Also: // Tr2SpriteParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ParticleSystem ): +BLUE_CLASS( Tr2ParticleSystem ) : public IInitialize, public INotify, public IListNotify, @@ -54,7 +54,7 @@ BLUE_CLASS( Tr2ParticleSystem ): ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IListNotify @@ -63,8 +63,7 @@ BLUE_CLASS( Tr2ParticleSystem ): ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); ////////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource @@ -73,8 +72,10 @@ BLUE_CLASS( Tr2ParticleSystem ): ////////////////////////////////////////////////////////////////////////////////////////// // ISimTimeRebaseNotify void OnSimClockRebase( Be::Time oldTime, Be::Time newTime ); + private: bool OnPrepareResources(); + public: ////////////////////////////////////////////////////////////////////////// @@ -107,7 +108,7 @@ BLUE_CLASS( Tr2ParticleSystem ): size_t GetGpuStride() const; - bool GetBoundingBox( Vector3 &minBounds, Vector3 &maxBounds ) const; + bool GetBoundingBox( Vector3 & minBounds, Vector3 & maxBounds ) const; void RebindConstraints(); @@ -115,7 +116,10 @@ BLUE_CLASS( Tr2ParticleSystem ): void SortParticles(); void SetMaxParticleCount( unsigned maxParticleCount ); - unsigned GetOriginalMaxParticles() { return m_originalMaxParticles; }; + unsigned GetOriginalMaxParticles() + { + return m_originalMaxParticles; + }; static void UpdateAllSystems( const ITr2GenericEmitter::UpdateArguments& arguments ); void Update( const ITr2GenericEmitter::UpdateArguments& arguments ); @@ -127,14 +131,14 @@ BLUE_CLASS( Tr2ParticleSystem ): m_bufferDirty = true; } - void GetDebugOptions( Tr2DebugRendererOptions& options ) const; - void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform ) const; + void GetDebugOptions( Tr2DebugRendererOptions & options ) const; + void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform ) const; // ---------------------------------------------------------------------------------- // Description: - // A cheap thread-safe lock-free pseudo random number generator based on - // http://www.firstpr.com.au/dsp/rand31/ + // A cheap thread-safe lock-free pseudo random number generator based on + // http://www.firstpr.com.au/dsp/rand31/ // Return Value: // Random integer between 0 and 2^31. // ---------------------------------------------------------------------------------- @@ -149,14 +153,14 @@ BLUE_CLASS( Tr2ParticleSystem ): hi = 16807 * ( seed >> 16 ); lo += ( hi & 0x7fff ) << 16; lo += hi >> 15; - lo = (lo & 0x7FFFFFFF) + (lo >> 31); + lo = ( lo & 0x7FFFFFFF ) + ( lo >> 31 ); globalSeed = static_cast( lo ); return lo; } // ---------------------------------------------------------------------------------- // Description: - // A cheap thread-safe lock-free pseudo random number generator that produces + // A cheap thread-safe lock-free pseudo random number generator that produces // random floats in [0, 1] range. Based on Tr2ParticleSystem::RandCheap. // Return Value: // Random float between 0 and 1. @@ -168,9 +172,13 @@ BLUE_CLASS( Tr2ParticleSystem ): uint32_t r = RandCheap() & 0x7FFFFFFF; return float( r ) / float( 0x7FFFFFFF ); } + private: void UpdateSimulation( const ITr2GenericEmitter::UpdateArguments& arguments, float dt ); - void UpdateSimulationScript( float dt ) { UpdateSimulation( ITr2GenericEmitter::UpdateArguments(), dt ); } + void UpdateSimulationScript( float dt ) + { + UpdateSimulation( ITr2GenericEmitter::UpdateArguments(), dt ); + } void BuildBuffers(); void DestroyBuffers(); void RebuildDeclaration(); diff --git a/trinity/Particle/Tr2ParticleSystem_Blue.cpp b/trinity/Particle/Tr2ParticleSystem_Blue.cpp index 9fbd5e023..516b44b02 100644 --- a/trinity/Particle/Tr2ParticleSystem_Blue.cpp +++ b/trinity/Particle/Tr2ParticleSystem_Blue.cpp @@ -22,73 +22,65 @@ const Be::ClassInfo* Tr2ParticleSystem::ExposeToBlue() MAP_INTERFACE( ITr2GpuBuffer ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "aliveCount", m_aliveCount, "The number of particles currently alive", Be::READ ) - MAP_ATTRIBUTE - ( - "emitParticleOnDeathEmitter", + MAP_ATTRIBUTE( + "emitParticleOnDeathEmitter", m_emissionOnDeathEmitter, - "An emitter that spawns (count) particles when a particle in this system dies.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "emitParticleDuringLifeEmitter", + "An emitter that spawns (count) particles when a particle in this system dies.", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( + "emitParticleDuringLifeEmitter", m_emissionWhileAliveEmitter, "An emitter that spawns particles with a chance based on the rate from the " - "positions of particles in this system during their lifetime.", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "elements", + "positions of particles in this system during their lifetime.", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( + "elements", m_elements, - "", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "isValid", + "", + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "isValid", m_isValid, - "", - Be::READ - ) - - MAP_ATTRIBUTE( - "requiresSorting", - m_requiresSorting, - "If the system requires particles to be sorted relative to the viewer. Not required for additive particles.", + "", + Be::READ ) + + MAP_ATTRIBUTE( + "requiresSorting", + m_requiresSorting, + "If the system requires particles to be sorted relative to the viewer. Not required for additive particles.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "updateSimulation", - m_updateSimulation, - "If simulation of the particles is being run. Typically turned off for static particle clouds.", + MAP_ATTRIBUTE( + "updateSimulation", + m_updateSimulation, + "If simulation of the particles is being run. Typically turned off for static particle clouds.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "applyForce", - m_applyForce, - "If set, forces will be applied to particles.", + MAP_ATTRIBUTE( + "applyForce", + m_applyForce, + "If set, forces will be applied to particles.", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "applyAging", - m_applyAging, - "If set, lifespan will be taken down, so particles can die .", + MAP_ATTRIBUTE( + "applyAging", + m_applyAging, + "If set, lifespan will be taken down, so particles can die .", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "isGlobal", - m_isGlobal, - "If set, this particle system is global i.e. all particles live in world space", + MAP_ATTRIBUTE( + "isGlobal", + m_isGlobal, + "If set, this particle system is global i.e. all particles live in world space", Be::READWRITE | Be::PERSIST ) - - MAP_ATTRIBUTE( - "forces", - m_forces, - "A list of forces to be applied to the particles", + + MAP_ATTRIBUTE( + "forces", + m_forces, + "A list of forces to be applied to the particles", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "constraints", - m_constraints, - "A list of constraints to be applied to the particles", + MAP_ATTRIBUTE( + "constraints", + m_constraints, + "A list of constraints to be applied to the particles", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "aabbMin", m_AabbMin, "Minimum of the AABB", Be::READ ); @@ -96,12 +88,12 @@ const Be::ClassInfo* Tr2ParticleSystem::ExposeToBlue() MAP_ATTRIBUTE( "peakAliveCount", m_peakAliveCount, "Peak live particle count", Be::READ ) - MAP_ATTRIBUTE( - "useSimTimeRebase", - m_useSimTimeRebase, - "Should the particle system rebase time when sim time is rebased", + MAP_ATTRIBUTE( + "useSimTimeRebase", + m_useSimTimeRebase, + "Should the particle system rebase time when sim time is rebased", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - + MAP_ATTRIBUTE( "maxParticleCount", m_maxParticleCount, @@ -114,38 +106,38 @@ const Be::ClassInfo* Tr2ParticleSystem::ExposeToBlue() "The original max particle value. Used for Lodding", Be::READ ) - MAP_PROPERTY( - "maxParticleCount", + MAP_PROPERTY( + "maxParticleCount", GetMaxParticleCount, SetMaxParticleCount, "The maximum number of particles to spawn. Setting this clears the particle system." ) - MAP_PROPERTY_READONLY( - "gpuStride", - GetGpuStride, + MAP_PROPERTY_READONLY( + "gpuStride", + GetGpuStride, "Size of one element in GPU buffer in bytes" ) - + MAP_METHOD_AND_WRAP( "UpdateElementDeclaration", UpdateElementDeclaration, "Updates internal particle element declaration" ) MAP_METHOD_AND_WRAP( "ClearParticles", ClearParticles, "Clear all of the active particles from the system." ) - MAP_METHOD_AND_WRAP( - "SaveToCMF", - SaveToCMF, + MAP_METHOD_AND_WRAP( + "SaveToCMF", + SaveToCMF, "Saves particle data into a CMF file\n" ":param path: res path to CMF file where to save particle data" ) // TODO: intern, call SaveToCMF instead of SaveToGranny in python. #if WITH_GRANNY - MAP_METHOD_AND_WRAP( - "SaveToGranny", - SaveToGranny, + MAP_METHOD_AND_WRAP( + "SaveToGranny", + SaveToGranny, "Saves particle data into a granny file\n" ":param path: res path to granny file where to save particle data" ) #endif MAP_METHOD_AND_WRAP( "RebindConstraints", RebindConstraints, "Rebinds all system constraints." ) - MAP_METHOD_AND_WRAP( - "UpdateSimulation", - UpdateSimulationScript, - "Updates particle system manually.\n" + MAP_METHOD_AND_WRAP( + "UpdateSimulation", + UpdateSimulationScript, + "Updates particle system manually.\n" ":param dt: time inteval (in seconds)" ) EXPOSURE_END() diff --git a/trinity/Particle/Tr2ParticleTurbulenceForce.cpp b/trinity/Particle/Tr2ParticleTurbulenceForce.cpp index 1c0911b27..a466989ba 100644 --- a/trinity/Particle/Tr2ParticleTurbulenceForce.cpp +++ b/trinity/Particle/Tr2ParticleTurbulenceForce.cpp @@ -22,19 +22,19 @@ struct InitializeNoise { InitializeNoise() { - for( int i = 0; i < NOISE_CELL_COUNT; i++ ) + for( int i = 0; i < NOISE_CELL_COUNT; i++ ) { s_noiseLookup[i] = XMFLOAT4A( s_rand(), s_rand(), s_rand(), s_rand() ); s_permutations[i] = i; } int i = NOISE_CELL_COUNT; - while( --i ) + while( --i ) { std::swap( s_permutations[i], s_permutations[rand() % NOISE_CELL_COUNT] ); } - for( int i = 0 ; i < NOISE_CELL_COUNT; i++) + for( int i = 0; i < NOISE_CELL_COUNT; i++ ) { s_permutations[NOISE_CELL_COUNT + i] = s_permutations[i]; s_noiseLookup[NOISE_CELL_COUNT + i] = s_noiseLookup[i]; @@ -46,10 +46,10 @@ struct InitializeNoise InitializeNoise s_initializeNoise; -#if defined(__GNUC__) -#define ALIGN_16 __attribute__((aligned(16))) +#if defined( __GNUC__ ) +#define ALIGN_16 __attribute__( ( aligned( 16 ) ) ) #else -#define ALIGN_16 __declspec(align(16)) +#define ALIGN_16 __declspec( align( 16 ) ) #endif XMVECTOR Noise4D( FXMVECTOR position ) @@ -64,7 +64,7 @@ XMVECTOR Noise4D( FXMVECTOR position ) ALIGN_16 unsigned a[4], b[4]; XMStoreInt4A( a, ipos ); XMStoreInt4A( b, ipos1 ); - + int i = s_permutations[a[0]]; int j = s_permutations[b[0]]; @@ -75,46 +75,46 @@ XMVECTOR Noise4D( FXMVECTOR position ) // Don't see a reason why we'd want force to have continous derivative, so // we simply use linear interpolation - //t = XMVectorMultiply( t, - // XMVectorMultiply( t, + //t = XMVectorMultiply( t, + // XMVectorMultiply( t, // XMVectorSubtract( XMVectorReplicate( 3.f ), XMVectorMultiply( XMVectorReplicate( 2.f ), t ) ) ) ); XMVECTOR x = XMVectorSplatX( t ); - XMVECTOR c00 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b00 + a[2] + a[3]] ), - XMLoadFloat4A( &s_noiseLookup[b10 + a[2] + a[3]] ), + XMVECTOR c00 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b00 + a[2] + a[3]] ), + XMLoadFloat4A( &s_noiseLookup[b10 + a[2] + a[3]] ), x ); - XMVECTOR c10 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b01 + a[2] + a[3]] ), - XMLoadFloat4A( &s_noiseLookup[b11 + a[2] + a[3]] ), + XMVECTOR c10 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b01 + a[2] + a[3]] ), + XMLoadFloat4A( &s_noiseLookup[b11 + a[2] + a[3]] ), x ); - XMVECTOR c01 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b00 + b[2] + a[3]] ), - XMLoadFloat4A( &s_noiseLookup[b10 + b[2] + a[3]] ), + XMVECTOR c01 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b00 + b[2] + a[3]] ), + XMLoadFloat4A( &s_noiseLookup[b10 + b[2] + a[3]] ), x ); - XMVECTOR c11 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b01 + b[2] + a[3]] ), - XMLoadFloat4A( &s_noiseLookup[b11 + b[2] + a[3]] ), + XMVECTOR c11 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b01 + b[2] + a[3]] ), + XMLoadFloat4A( &s_noiseLookup[b11 + b[2] + a[3]] ), x ); XMVECTOR c0 = XMVectorLerpV( c00, c10, XMVectorSplatY( t ) ); XMVECTOR c1 = XMVectorLerpV( c01, c11, XMVectorSplatY( t ) ); XMVECTOR c = XMVectorLerpV( c0, c1, XMVectorSplatZ( t ) ); - c00 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b00 + a[2] + b[3]] ), - XMLoadFloat4A( &s_noiseLookup[b10 + a[2] + b[3]] ), + c00 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b00 + a[2] + b[3]] ), + XMLoadFloat4A( &s_noiseLookup[b10 + a[2] + b[3]] ), x ); - c10 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b01 + a[2] + b[3]] ), - XMLoadFloat4A( &s_noiseLookup[b11 + a[2] + b[3]] ), + c10 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b01 + a[2] + b[3]] ), + XMLoadFloat4A( &s_noiseLookup[b11 + a[2] + b[3]] ), x ); - c01 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b00 + b[2] + b[3]] ), - XMLoadFloat4A( &s_noiseLookup[b10 + b[2] + b[3]] ), + c01 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b00 + b[2] + b[3]] ), + XMLoadFloat4A( &s_noiseLookup[b10 + b[2] + b[3]] ), x ); - c11 = XMVectorLerpV( - XMLoadFloat4A( &s_noiseLookup[b01 + b[2] + b[3]] ), - XMLoadFloat4A( &s_noiseLookup[b11 + b[2] + b[3]] ), + c11 = XMVectorLerpV( + XMLoadFloat4A( &s_noiseLookup[b01 + b[2] + b[3]] ), + XMLoadFloat4A( &s_noiseLookup[b11 + b[2] + b[3]] ), x ); c0 = XMVectorLerpV( c00, c10, XMVectorSplatY( t ) ); c1 = XMVectorLerpV( c01, c11, XMVectorSplatY( t ) ); @@ -124,8 +124,8 @@ XMVECTOR Noise4D( FXMVECTOR position ) } -Tr2ParticleTurbulenceForce::Tr2ParticleTurbulenceForce( IRoot* lockobj ) -: m_amplitude( 1.f, 1.f, 1.f ), +Tr2ParticleTurbulenceForce::Tr2ParticleTurbulenceForce( IRoot* lockobj ) : + m_amplitude( 1.f, 1.f, 1.f ), m_frequency( 1.f, 1.f, 1.f, 1.f ), m_noiseLevel( 3 ), m_noiseRatio( 0.5f ), @@ -188,4 +188,3 @@ void Tr2ParticleTurbulenceForce::Update( float dt ) { m_time += dt; } - diff --git a/trinity/Particle/Tr2ParticleTurbulenceForce.h b/trinity/Particle/Tr2ParticleTurbulenceForce.h index cb35fe8d5..9268dda84 100644 --- a/trinity/Particle/Tr2ParticleTurbulenceForce.h +++ b/trinity/Particle/Tr2ParticleTurbulenceForce.h @@ -10,14 +10,13 @@ BLUE_DECLARE( Tr2ParticleTurbulenceForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. +// A force to apply to particles in a particle system. // Represents a random time/position dependant directional // force. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleTurbulenceForce: - public ITr2ParticleForce +class Tr2ParticleTurbulenceForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Particle/Tr2ParticleTurbulenceForce_Blue.cpp b/trinity/Particle/Tr2ParticleTurbulenceForce_Blue.cpp index 67cf53bd9..9ecf5e401 100644 --- a/trinity/Particle/Tr2ParticleTurbulenceForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleTurbulenceForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2ParticleTurbulenceForce ); const Be::ClassInfo* Tr2ParticleTurbulenceForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleTurbulenceForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleTurbulenceForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleTurbulenceForce ) diff --git a/trinity/Particle/Tr2ParticleVortexForce.cpp b/trinity/Particle/Tr2ParticleVortexForce.cpp index 3ca5acc00..585ea791e 100644 --- a/trinity/Particle/Tr2ParticleVortexForce.cpp +++ b/trinity/Particle/Tr2ParticleVortexForce.cpp @@ -4,15 +4,15 @@ #include "Tr2ParticleVortexForce.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif -Tr2ParticleVortexForce::Tr2ParticleVortexForce( IRoot* lockobj ): +Tr2ParticleVortexForce::Tr2ParticleVortexForce( IRoot* lockobj ) : m_magnitude( 1.f ), m_position( 0.f, 0.f, 0.f ), m_axis( 0.f, 1.f, 0.f ) diff --git a/trinity/Particle/Tr2ParticleVortexForce.h b/trinity/Particle/Tr2ParticleVortexForce.h index 24c78fc35..a7df74c0c 100644 --- a/trinity/Particle/Tr2ParticleVortexForce.h +++ b/trinity/Particle/Tr2ParticleVortexForce.h @@ -10,13 +10,12 @@ BLUE_DECLARE( Tr2ParticleVortexForce ); // ------------------------------------------------------------- // Description: -// A force to apply to particles in a particle system. +// A force to apply to particles in a particle system. // Models a "vortex" tangent force. // SeeAlso: // Tr2SpriteParticleSystem // ------------------------------------------------------------- -class Tr2ParticleVortexForce: - public ITr2ParticleForce +class Tr2ParticleVortexForce : public ITr2ParticleForce { public: EXPOSE_TO_BLUE(); @@ -25,7 +24,9 @@ class Tr2ParticleVortexForce: ~Tr2ParticleVortexForce(); XMVECTOR FASTCALL GetForce( FXMVECTOR position, FXMVECTOR velocity, float dt, float mass ); - void Update( float dt ) {} + void Update( float dt ) + { + } void RenderDebugInfo( ITr2DebugRenderer2& renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2ParticleVortexForce_Blue.cpp b/trinity/Particle/Tr2ParticleVortexForce_Blue.cpp index 865a34d13..8bd6c7e86 100644 --- a/trinity/Particle/Tr2ParticleVortexForce_Blue.cpp +++ b/trinity/Particle/Tr2ParticleVortexForce_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2ParticleVortexForce ); const Be::ClassInfo* Tr2ParticleVortexForce::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2ParticleVortexForce, "" ) + EXPOSURE_BEGIN( Tr2ParticleVortexForce, "" ) MAP_INTERFACE( ITr2ParticleForce ) MAP_INTERFACE( Tr2ParticleVortexForce ) diff --git a/trinity/Particle/Tr2PlaneConstraint.cpp b/trinity/Particle/Tr2PlaneConstraint.cpp index 730a3c168..8604c369b 100644 --- a/trinity/Particle/Tr2PlaneConstraint.cpp +++ b/trinity/Particle/Tr2PlaneConstraint.cpp @@ -7,20 +7,20 @@ #include "ITr2GenericEmitter.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif // -------------------------------------------------------------------------------------- // Description: // Tr2PlaneConstraint default constructor // -------------------------------------------------------------------------------------- -Tr2PlaneConstraint::Tr2PlaneConstraint( IRoot* lockobj ) -: m_plane( 0.f, 1.f, 0.f, 0.f ), +Tr2PlaneConstraint::Tr2PlaneConstraint( IRoot* lockobj ) : + m_plane( 0.f, 1.f, 0.f, 0.f ), m_normalizedPlane( 0.f, 1.f, 0.f, 0.f ), m_friction( 1.f ), m_elasticity( 1.f ), @@ -85,10 +85,9 @@ void Tr2PlaneConstraint::OnListModified( ssize_t, ssize_t, IRoot* value, - const IList* theList - ) + const IList* theList ) { - if( (event & BELIST_LOADING) == 0 && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED && theList == &m_onCollisionEmitters && value ) + if( ( event & BELIST_LOADING ) == 0 && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED && theList == &m_onCollisionEmitters && value ) { ITr2GenericEmitterPtr emitter( BlueCastPtr( value ) ); if( emitter ) @@ -100,14 +99,14 @@ void Tr2PlaneConstraint::OnListModified( // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericParticleConstraint interface. Checks for collision between a +// Implements ITr2GenericParticleConstraint interface. Checks for collision between a // particle and a half-space defined by m_plane. If collision is detected optionally // apply physical response to particle position and/or velocity and run generators // to re-generate particle data components. This method can be called asyncronously. // Arguments: // arguments - Child emitter update arguments -// particles - Particle data: Tr2ParticleElementData::COUNT of float arrays. The -// constraint can modify any data element of a particle. +// particles - Particle data: Tr2ParticleElementData::COUNT of float arrays. The +// constraint can modify any data element of a particle. // strides - Sizes of particle data in each of "particles" arrays (in floats). // count - Number of particles. // dt - (unused) Frame time. @@ -154,9 +153,9 @@ void Tr2PlaneConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgume *velocity = bounce + slide; if( m_reflectionNoise > 0 ) { - Vector3 reflectionNoise( - Tr2ParticleSystem::RandFloat() * 2 - 1, - Tr2ParticleSystem::RandFloat() * 2 - 1, + Vector3 reflectionNoise( + Tr2ParticleSystem::RandFloat() * 2 - 1, + Tr2ParticleSystem::RandFloat() * 2 - 1, Tr2ParticleSystem::RandFloat() * 2 - 1 ); reflectionNoise *= m_reflectionNoise; reflectionNoise -= planeNormal * Dot( reflectionNoise, planeNormal ); @@ -174,15 +173,14 @@ void Tr2PlaneConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgume } for( auto it = m_generators.begin(); it != m_generators.end(); ++it ) { - ( *it )->Generate( position, - m_velocityElement.m_offset != -1 ? static_cast( velocity ) : nullptr, + ( *it )->Generate( position, + m_velocityElement.m_offset != -1 ? static_cast( velocity ) : nullptr, particle ); } } for( auto it = m_onCollisionEmitters.begin(); it != m_onCollisionEmitters.end(); ++it ) { - ( *it )->SpawnParticles( arguments, position, - m_velocityElement.m_offset != -1 ? static_cast( velocity ) : nullptr ); + ( *it )->SpawnParticles( arguments, position, m_velocityElement.m_offset != -1 ? static_cast( velocity ) : nullptr ); } } } @@ -190,8 +188,8 @@ void Tr2PlaneConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgume // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericParticleConstraint interface. A chance for constraint to bind -// itself to a particle system. Called when constaint is added to the particle system +// Implements ITr2GenericParticleConstraint interface. A chance for constraint to bind +// itself to a particle system. Called when constaint is added to the particle system // or when system is re-binded. // Arguments: // system - Particle system the constaint is attached to. @@ -199,7 +197,7 @@ void Tr2PlaneConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgume void Tr2PlaneConstraint::Bind( Tr2ParticleSystem* system ) { m_isValid = false; - const Tr2ParticleElementDataMap &declaration = system->GetElementDeclaration(); + const Tr2ParticleElementDataMap& declaration = system->GetElementDeclaration(); Tr2ParticleElementDeclarationName position( Tr2ParticleElementDeclarationName::POSITION ); auto i = declaration.find( position ); @@ -269,7 +267,7 @@ void Tr2PlaneConstraint::RenderDebugInfo( ITr2DebugRenderer2& renderer, const Ma float radius = std::max( 10.f, Length( aabb.Size() ) * 0.25f ); float step = radius * 0.2f; for( int i = -5; i <= 5; ++i ) - { + { Vector3 p0( float( i ) * step, -radius, 0 ); Vector3 p1( float( i ) * step, radius, 0 ); renderer.DrawLine( this, TransformCoord( p0 + center, world ), TransformCoord( p1 + center, world ), 0xffff4444 ); diff --git a/trinity/Particle/Tr2PlaneConstraint.h b/trinity/Particle/Tr2PlaneConstraint.h index 6f9b6342d..09c04d2b2 100644 --- a/trinity/Particle/Tr2PlaneConstraint.h +++ b/trinity/Particle/Tr2PlaneConstraint.h @@ -20,7 +20,7 @@ BLUE_DECLARE_IVECTOR( ITr2GenericEmitter ); // See Also: // Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2PlaneConstraint ): +BLUE_CLASS( Tr2PlaneConstraint ) : public ITr2GenericParticleConstraint, public INotify, public IInitialize, @@ -31,8 +31,8 @@ BLUE_CLASS( Tr2PlaneConstraint ): EXPOSE_TO_BLUE(); - using IInitialize::Lock; - using IInitialize::Unlock; + using IInitialize::Lock; + using IInitialize::Unlock; ///////////////////////////////////////////////////////////// // IInitialize @@ -40,22 +40,21 @@ BLUE_CLASS( Tr2PlaneConstraint ): ///////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////// // INotify virtual void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const struct IList* theList - ); + const struct IList* theList ); ///////////////////////////////////////////////////////////// // ITr2ParticleConstraint virtual void ApplyConstraint( const ITr2GenericEmitter::UpdateArguments& arguments, float** particle, unsigned* strides, unsigned count, float dt ); - virtual void Bind( Tr2ParticleSystem* system ); + virtual void Bind( Tr2ParticleSystem * system ); void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2PlaneConstraint_Blue.cpp b/trinity/Particle/Tr2PlaneConstraint_Blue.cpp index 1fcbc4d18..6a536a1f4 100644 --- a/trinity/Particle/Tr2PlaneConstraint_Blue.cpp +++ b/trinity/Particle/Tr2PlaneConstraint_Blue.cpp @@ -7,27 +7,27 @@ BLUE_DEFINE( Tr2PlaneConstraint ); const Be::ClassInfo* Tr2PlaneConstraint::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2PlaneConstraint, "" ) + EXPOSURE_BEGIN( Tr2PlaneConstraint, "" ) MAP_INTERFACE( ITr2GenericParticleConstraint ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( Tr2PlaneConstraint ) - MAP_ATTRIBUTE( "plane", m_plane, "Collision plane", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "affectPosition", m_affectPosition, "Apply collision response to particle positions", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "affectVelocity", m_affectVelocity, "Apply collision response to particle velocities", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "friction", m_friction, "Inverse friction coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "elasticity", m_elasticity, "Inverse elasticity coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "reflectionNoise", m_reflectionNoise, "Reflection noise coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "particleRadiusComponent", - m_particleRadiusComponent, - "Name of the particle component that contains particle size (leave blank to have size=0 for all particles)", + MAP_ATTRIBUTE( "plane", m_plane, "Collision plane", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "affectPosition", m_affectPosition, "Apply collision response to particle positions", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "affectVelocity", m_affectVelocity, "Apply collision response to particle velocities", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "friction", m_friction, "Inverse friction coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "elasticity", m_elasticity, "Inverse elasticity coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "reflectionNoise", m_reflectionNoise, "Reflection noise coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "particleRadiusComponent", + m_particleRadiusComponent, + "Name of the particle component that contains particle size (leave blank to have size=0 for all particles)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "particleRadiusCoefficient", - m_particleRadiusCoefficient, - "What to treat as particle surface (0 - center, 1 - sphere with particle radius)", + MAP_ATTRIBUTE( + "particleRadiusCoefficient", + m_particleRadiusCoefficient, + "What to treat as particle surface (0 - center, 1 - sphere with particle radius)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "generators", m_generators, "List of generators that are executed on collision", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "onCollisionEmitters", m_onCollisionEmitters, "List of emitters that are executed on collision", Be::READ | Be::PERSIST ) diff --git a/trinity/Particle/Tr2RandomDirectionAttributeGenerator.cpp b/trinity/Particle/Tr2RandomDirectionAttributeGenerator.cpp index 2380b7284..07ed6650b 100644 --- a/trinity/Particle/Tr2RandomDirectionAttributeGenerator.cpp +++ b/trinity/Particle/Tr2RandomDirectionAttributeGenerator.cpp @@ -9,8 +9,8 @@ // Description: // Tr2RandomDirectionAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2RandomDirectionAttributeGenerator::Tr2RandomDirectionAttributeGenerator() - :m_name( Tr2ParticleElementDeclarationName::CUSTOM ), +Tr2RandomDirectionAttributeGenerator::Tr2RandomDirectionAttributeGenerator() : + m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_valid( false ), m_element() { @@ -26,16 +26,16 @@ Tr2RandomDirectionAttributeGenerator::~Tr2RandomDirectionAttributeGenerator() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates unit-length random vector +// Implements ITr2AttributeGenerator interface. Generates unit-length random vector // for new particle component (element). // Arguments: // position - Position of the "parent" particle (unused). // velocity - Velocity of the "parent" particle (unused). -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills element identified by generator's m_name with random values. // -------------------------------------------------------------------------------------- -void Tr2RandomDirectionAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, +void Tr2RandomDirectionAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, float** particle ) { if( !m_valid ) @@ -73,17 +73,17 @@ void Tr2RandomDirectionAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2RandomDirectionAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2RandomDirectionAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; auto i = declaration.find( m_name ); @@ -105,7 +105,7 @@ bool Tr2RandomDirectionAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. @@ -117,7 +117,7 @@ std::string Tr2RandomDirectionAttributeGenerator::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Returns bounded particle element dimension or 0 if the generator is not bounded. +// Returns bounded particle element dimension or 0 if the generator is not bounded. // Used for Python exposure. // Return Value: // Bounded particle element dimension or 0 if the generator is not bounded. diff --git a/trinity/Particle/Tr2RandomDirectionAttributeGenerator.h b/trinity/Particle/Tr2RandomDirectionAttributeGenerator.h index 83465eae7..c4ae44950 100644 --- a/trinity/Particle/Tr2RandomDirectionAttributeGenerator.h +++ b/trinity/Particle/Tr2RandomDirectionAttributeGenerator.h @@ -12,7 +12,8 @@ // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2RandomDirectionAttributeGenerator ): public ITr2AttributeGenerator +BLUE_CLASS( Tr2RandomDirectionAttributeGenerator ) : + public ITr2AttributeGenerator { public: EXPOSE_TO_BLUE(); @@ -21,9 +22,10 @@ BLUE_CLASS( Tr2RandomDirectionAttributeGenerator ): public ITr2AttributeGenerato ~Tr2RandomDirectionAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, std::set& boundElements ); std::string GetName() const; unsigned GetDimension() const; + private: // Particle element type/name Tr2ParticleElementDeclarationName m_name; diff --git a/trinity/Particle/Tr2RandomDirectionAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2RandomDirectionAttributeGenerator_Blue.cpp index 3d5b9db5a..3d2f62905 100644 --- a/trinity/Particle/Tr2RandomDirectionAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2RandomDirectionAttributeGenerator_Blue.cpp @@ -12,13 +12,13 @@ const Be::ClassInfo* Tr2RandomDirectionAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2RandomDirectionAttributeGenerator, "" ) MAP_INTERFACE( Tr2RandomDirectionAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) MAP_ATTRIBUTE( "customName", m_name.m_name, "Name for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "valid", m_valid, "Was the generator successfully bound to particle system", Be::READ ) diff --git a/trinity/Particle/Tr2RandomIntegerAttributeGenerator.cpp b/trinity/Particle/Tr2RandomIntegerAttributeGenerator.cpp index cd816c953..d049cf0d6 100644 --- a/trinity/Particle/Tr2RandomIntegerAttributeGenerator.cpp +++ b/trinity/Particle/Tr2RandomIntegerAttributeGenerator.cpp @@ -9,8 +9,8 @@ // Description: // Tr2RandomIntegerAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2RandomIntegerAttributeGenerator::Tr2RandomIntegerAttributeGenerator() - :m_name( Tr2ParticleElementDeclarationName::CUSTOM ), +Tr2RandomIntegerAttributeGenerator::Tr2RandomIntegerAttributeGenerator() : + m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_minRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_maxRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_valid( false ), @@ -28,16 +28,16 @@ Tr2RandomIntegerAttributeGenerator::~Tr2RandomIntegerAttributeGenerator() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates random integer values for new +// Implements ITr2AttributeGenerator interface. Generates random integer values for new // particle component (element). // Arguments: // position - Position of the "parent" particle (unused). // velocity - Velocity of the "parent" particle (unused). -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills element identified by generator's m_name with random values. // -------------------------------------------------------------------------------------- -void Tr2RandomIntegerAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, +void Tr2RandomIntegerAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, float** particle ) { if( !m_valid ) @@ -58,17 +58,17 @@ void Tr2RandomIntegerAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2RandomIntegerAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2RandomIntegerAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; auto i = declaration.find( m_name ); @@ -90,7 +90,7 @@ bool Tr2RandomIntegerAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. @@ -102,7 +102,7 @@ std::string Tr2RandomIntegerAttributeGenerator::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Returns bounded particle element dimension or 0 if the generator is not bounded. +// Returns bounded particle element dimension or 0 if the generator is not bounded. // Used for Python exposure. // Return Value: // Bounded particle element dimension or 0 if the generator is not bounded. diff --git a/trinity/Particle/Tr2RandomIntegerAttributeGenerator.h b/trinity/Particle/Tr2RandomIntegerAttributeGenerator.h index ca8bf4145..da6dc2f6e 100644 --- a/trinity/Particle/Tr2RandomIntegerAttributeGenerator.h +++ b/trinity/Particle/Tr2RandomIntegerAttributeGenerator.h @@ -8,12 +8,13 @@ // -------------------------------------------------------------------------------------- // Description: -// Particle element generator that creates random integer element values in a +// Particle element generator that creates random integer element values in a // specified range. // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2RandomIntegerAttributeGenerator ): public ITr2AttributeGenerator +BLUE_CLASS( Tr2RandomIntegerAttributeGenerator ) : + public ITr2AttributeGenerator { public: EXPOSE_TO_BLUE(); @@ -22,9 +23,10 @@ BLUE_CLASS( Tr2RandomIntegerAttributeGenerator ): public ITr2AttributeGenerator ~Tr2RandomIntegerAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, std::set& boundElements ); std::string GetName() const; unsigned GetDimension() const; + private: // Particle element type/name Tr2ParticleElementDeclarationName m_name; diff --git a/trinity/Particle/Tr2RandomIntegerAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2RandomIntegerAttributeGenerator_Blue.cpp index e6c1bf0bb..b9225bf88 100644 --- a/trinity/Particle/Tr2RandomIntegerAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2RandomIntegerAttributeGenerator_Blue.cpp @@ -12,13 +12,13 @@ const Be::ClassInfo* Tr2RandomIntegerAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2RandomIntegerAttributeGenerator, "" ) MAP_INTERFACE( Tr2RandomIntegerAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) MAP_ATTRIBUTE( "customName", m_name.m_name, "Name for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minRange", m_minRange, "Min bound for value range", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Particle/Tr2RandomUniformAttributeGenerator.cpp b/trinity/Particle/Tr2RandomUniformAttributeGenerator.cpp index 69ec50b9a..020370af2 100644 --- a/trinity/Particle/Tr2RandomUniformAttributeGenerator.cpp +++ b/trinity/Particle/Tr2RandomUniformAttributeGenerator.cpp @@ -8,8 +8,8 @@ // Description: // Tr2RandomUniformAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2RandomUniformAttributeGenerator::Tr2RandomUniformAttributeGenerator() - :m_name( Tr2ParticleElementDeclarationName::CUSTOM ), +Tr2RandomUniformAttributeGenerator::Tr2RandomUniformAttributeGenerator() : + m_name( Tr2ParticleElementDeclarationName::CUSTOM ), m_minRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_maxRange( 0.0f, 0.0f, 0.0f, 0.0f ), m_valid( false ), @@ -27,16 +27,16 @@ Tr2RandomUniformAttributeGenerator::~Tr2RandomUniformAttributeGenerator() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates random values for new +// Implements ITr2AttributeGenerator interface. Generates random values for new // particle component (element). // Arguments: // position - Position of the "parent" particle (unused). // velocity - Velocity of the "parent" particle (unused). -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills element identified by generator's m_name with random values. // -------------------------------------------------------------------------------------- -void Tr2RandomUniformAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, +void Tr2RandomUniformAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, float** particle ) { if( !m_valid ) @@ -57,17 +57,17 @@ void Tr2RandomUniformAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2RandomUniformAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2RandomUniformAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; auto i = declaration.find( m_name ); @@ -89,7 +89,7 @@ bool Tr2RandomUniformAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. @@ -101,7 +101,7 @@ std::string Tr2RandomUniformAttributeGenerator::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Returns bounded particle element dimension or 0 if the generator is not bounded. +// Returns bounded particle element dimension or 0 if the generator is not bounded. // Used for Python exposure. // Return Value: // Bounded particle element dimension or 0 if the generator is not bounded. diff --git a/trinity/Particle/Tr2RandomUniformAttributeGenerator.h b/trinity/Particle/Tr2RandomUniformAttributeGenerator.h index 8873178c1..ae4dc5595 100644 --- a/trinity/Particle/Tr2RandomUniformAttributeGenerator.h +++ b/trinity/Particle/Tr2RandomUniformAttributeGenerator.h @@ -12,7 +12,8 @@ // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2RandomUniformAttributeGenerator ): public ITr2AttributeGenerator +BLUE_CLASS( Tr2RandomUniformAttributeGenerator ) : + public ITr2AttributeGenerator { public: EXPOSE_TO_BLUE(); @@ -21,9 +22,10 @@ BLUE_CLASS( Tr2RandomUniformAttributeGenerator ): public ITr2AttributeGenerator ~Tr2RandomUniformAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, std::set& boundElements ); std::string GetName() const; unsigned GetDimension() const; + private: // Particle element type/name Tr2ParticleElementDeclarationName m_name; diff --git a/trinity/Particle/Tr2RandomUniformAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2RandomUniformAttributeGenerator_Blue.cpp index 458828903..741cf537b 100644 --- a/trinity/Particle/Tr2RandomUniformAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2RandomUniformAttributeGenerator_Blue.cpp @@ -12,13 +12,13 @@ const Be::ClassInfo* Tr2RandomUniformAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2RandomUniformAttributeGenerator, "" ) MAP_INTERFACE( Tr2RandomUniformAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "elementType", - m_name.m_type, - "Pre-defined type of particle element", - Be::READWRITE | Be::PERSIST | Be::ENUM, + MAP_ATTRIBUTE_WITH_CHOOSER( + "elementType", + m_name.m_type, + "Pre-defined type of particle element", + Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ParticleElementDeclarationNameTypeChooser ) MAP_ATTRIBUTE( "customName", m_name.m_name, "Name for custom type element", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minRange", m_minRange, "Min bound for value range", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/Particle/Tr2SphereConstraint.cpp b/trinity/Particle/Tr2SphereConstraint.cpp index c13cf2067..268937b2c 100644 --- a/trinity/Particle/Tr2SphereConstraint.cpp +++ b/trinity/Particle/Tr2SphereConstraint.cpp @@ -8,20 +8,20 @@ #include "TbbStub.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif // -------------------------------------------------------------------------------------- // Description: // Tr2SphereConstraint default constructor // -------------------------------------------------------------------------------------- -Tr2SphereConstraint::Tr2SphereConstraint( IRoot* lockobj ) -: m_position( 0.f, 0.f, 0.f ), +Tr2SphereConstraint::Tr2SphereConstraint( IRoot* lockobj ) : + m_position( 0.f, 0.f, 0.f ), m_radius( 1.f ), m_invertSphere( false ), m_friction( 1.f ), @@ -43,7 +43,7 @@ Tr2SphereConstraint::Tr2SphereConstraint( IRoot* lockobj ) // -------------------------------------------------------------------------------------- // Description: -// Implements IInitialize interface. +// Implements IInitialize interface. // Return Value: // true always // -------------------------------------------------------------------------------------- @@ -70,10 +70,9 @@ void Tr2SphereConstraint::OnListModified( ssize_t, ssize_t, IRoot* value, - const IList* theList - ) + const IList* theList ) { - if( (event & BELIST_LOADING) == 0 && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED && theList == &m_onCollisionEmitters && value ) + if( ( event & BELIST_LOADING ) == 0 && ( event & BELIST_EVENTMASK ) == BELIST_INSERTED && theList == &m_onCollisionEmitters && value ) { ITr2GenericEmitterPtr emitter( BlueCastPtr( value ) ); if( emitter ) @@ -85,14 +84,14 @@ void Tr2SphereConstraint::OnListModified( // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericParticleConstraint interface. Checks for collision between a +// Implements ITr2GenericParticleConstraint interface. Checks for collision between a // particle and a sphere. If collision is detected optionally // applies physical response to particle position and/or velocity and run generators // to re-generate particle data components. This method can be called asyncronously. // Arguments: // arguments - Child emitter update arguments -// particles - Particle data: Tr2ParticleElementData::COUNT of float arrays. The -// constraint can modify any data element of a particle. +// particles - Particle data: Tr2ParticleElementData::COUNT of float arrays. The +// constraint can modify any data element of a particle. // strides - Sizes of particle data in each of "particles" arrays (in floats). // count - Number of particles. // dt - Frame time. @@ -104,172 +103,166 @@ void Tr2SphereConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgum return; } - Tr2ParallelFor( - Tr2BlockedRange( 0, count, 100 ), - [=]( const Tr2BlockedRange& range ) -> void - { - XMVECTOR refPosition = m_position; - XMVECTOR refRadius = XMVectorReplicate( m_radius ); - XMVECTOR invert = XMVectorReplicate( m_invertSphere ? -1.f : 1.f ); - XMVECTOR radiusCmp = XMVectorMultiply( invert, XMVectorMultiply( refRadius, refRadius ) ); - XMVECTOR particleRadiusCoefficient = m_particleRadiusCoefficient; + Tr2ParallelFor( + Tr2BlockedRange( 0, count, 100 ), + [=]( const Tr2BlockedRange& range ) -> void { + XMVECTOR refPosition = m_position; + XMVECTOR refRadius = XMVectorReplicate( m_radius ); + XMVECTOR invert = XMVectorReplicate( m_invertSphere ? -1.f : 1.f ); + XMVECTOR radiusCmp = XMVectorMultiply( invert, XMVectorMultiply( refRadius, refRadius ) ); + XMVECTOR particleRadiusCoefficient = m_particleRadiusCoefficient; - Tr2ParticleStreamIterator position( particles, strides, m_positionElement ); - position += int( range.begin() ); - Tr2ParticleStreamIterator radiusStream( particles, strides, m_radiusElement ); - radiusStream += int( range.begin() ); - Tr2ParticleStreamIterator velocity( particles, strides, m_velocityElement ); - velocity += int( range.begin() ); + Tr2ParticleStreamIterator position( particles, strides, m_positionElement ); + position += int( range.begin() ); + Tr2ParticleStreamIterator radiusStream( particles, strides, m_radiusElement ); + radiusStream += int( range.begin() ); + Tr2ParticleStreamIterator velocity( particles, strides, m_velocityElement ); + velocity += int( range.begin() ); - for( auto i = range.begin(); i < range.end(); ++i, ++position, ++radiusStream, ++velocity ) - { - XMVECTOR radius = refRadius; - if( m_radiusElement.m_offset != -1 ) + for( auto i = range.begin(); i < range.end(); ++i, ++position, ++radiusStream, ++velocity ) { - if( m_invertSphere ) - { - radius = XMVectorSubtract( radius, XMVector4Dot( - XMLoadFloat4( radiusStream ), - particleRadiusCoefficient ) ); - } - else + XMVECTOR radius = refRadius; + if( m_radiusElement.m_offset != -1 ) { - radius = XMVectorAdd( radius, XMVector4Dot( - XMLoadFloat4( radiusStream ), - particleRadiusCoefficient ) ); + if( m_invertSphere ) + { + radius = XMVectorSubtract( radius, XMVector4Dot( XMLoadFloat4( radiusStream ), particleRadiusCoefficient ) ); + } + else + { + radius = XMVectorAdd( radius, XMVector4Dot( XMLoadFloat4( radiusStream ), particleRadiusCoefficient ) ); + } } - } - XMVECTOR curPosition = XMLoadFloat3( position ); - XMVECTOR curVelocity = XMLoadFloat3( velocity ); - XMVECTOR offset = XMVectorSubtract( curPosition, refPosition ); - XMVECTOR offsetLengthSq = XMVector3LengthSq( offset ); + XMVECTOR curPosition = XMLoadFloat3( position ); + XMVECTOR curVelocity = XMLoadFloat3( velocity ); + XMVECTOR offset = XMVectorSubtract( curPosition, refPosition ); + XMVECTOR offsetLengthSq = XMVector3LengthSq( offset ); - // Check if the particle is inside the "prohibited space" - if( XMVectorGetIntX( XMVectorLess( XMVectorMultiply( offsetLengthSq, invert ), radiusCmp ) ) ) - { - if( m_affectPosition ) + // Check if the particle is inside the "prohibited space" + if( XMVectorGetIntX( XMVectorLess( XMVectorMultiply( offsetLengthSq, invert ), radiusCmp ) ) ) { - offset = XMVectorMultiply( offset, XMVectorReciprocal( XMVectorSqrt( offsetLengthSq ) ) ); - XMVECTOR newPosition = XMVectorMultiplyAdd( offset, radius, refPosition ); - XMStoreFloat3( position, newPosition ); - - if( m_affectVelocity && m_velocityElement.m_offset != -1 ) + if( m_affectPosition ) { - offset = XMVectorMultiply( offset, invert ); + offset = XMVectorMultiply( offset, XMVectorReciprocal( XMVectorSqrt( offsetLengthSq ) ) ); + XMVECTOR newPosition = XMVectorMultiplyAdd( offset, radius, refPosition ); + XMStoreFloat3( position, newPosition ); - XMVECTOR velocityDot = XMVector3Dot( curVelocity, offset ); - if( XMVectorGetIntX( XMVectorLess( velocityDot, XMVectorZero() ) ) ) + if( m_affectVelocity && m_velocityElement.m_offset != -1 ) { - XMVECTOR bounce = XMVectorMultiply( offset, XMVectorNegate( velocityDot ) ); - XMVECTOR slide = XMVectorAdd( curVelocity, bounce ); - bounce = XMVectorScale( bounce, m_elasticity ); - slide = XMVectorScale( slide, m_friction ); - XMStoreFloat3( velocity, XMVectorAdd( bounce, slide ) ); - if( m_reflectionNoise > 0 ) + offset = XMVectorMultiply( offset, invert ); + + XMVECTOR velocityDot = XMVector3Dot( curVelocity, offset ); + if( XMVectorGetIntX( XMVectorLess( velocityDot, XMVectorZero() ) ) ) { - XMVECTOR reflectionNoise; - reflectionNoise = Vector3( - Tr2ParticleSystem::RandFloat() * 2 - 1, - Tr2ParticleSystem::RandFloat() * 2 - 1, - Tr2ParticleSystem::RandFloat() * 2 - 1 ); - reflectionNoise = XMVectorScale( reflectionNoise, m_reflectionNoise ); - reflectionNoise = XMVectorSubtract( reflectionNoise, XMVectorMultiply( offset, XMVector3Dot( reflectionNoise, offset ) ) ); - XMVECTOR speed = XMVector3LengthEst( XMLoadFloat3( velocity ) ); - reflectionNoise = XMVectorMultiply( reflectionNoise, speed ); - XMStoreFloat3( velocity, reflectionNoise ); + XMVECTOR bounce = XMVectorMultiply( offset, XMVectorNegate( velocityDot ) ); + XMVECTOR slide = XMVectorAdd( curVelocity, bounce ); + bounce = XMVectorScale( bounce, m_elasticity ); + slide = XMVectorScale( slide, m_friction ); + XMStoreFloat3( velocity, XMVectorAdd( bounce, slide ) ); + if( m_reflectionNoise > 0 ) + { + XMVECTOR reflectionNoise; + reflectionNoise = Vector3( + Tr2ParticleSystem::RandFloat() * 2 - 1, + Tr2ParticleSystem::RandFloat() * 2 - 1, + Tr2ParticleSystem::RandFloat() * 2 - 1 ); + reflectionNoise = XMVectorScale( reflectionNoise, m_reflectionNoise ); + reflectionNoise = XMVectorSubtract( reflectionNoise, XMVectorMultiply( offset, XMVector3Dot( reflectionNoise, offset ) ) ); + XMVECTOR speed = XMVector3LengthEst( XMLoadFloat3( velocity ) ); + reflectionNoise = XMVectorMultiply( reflectionNoise, speed ); + XMStoreFloat3( velocity, reflectionNoise ); + } } } } } - } - else if( m_velocityElement.m_offset != -1 ) - { - float a = XMVectorGetX( XMVector3Dot( curVelocity, curVelocity ) ); - float b = XMVectorGetX( XMVector3Dot( curVelocity, offset ) ) * 2.f; - float c = XMVectorGetX( XMVector3Dot( offset, offset ) ) - m_radius * m_radius; - - float det = b * b - 4.f * a * c; - if( det < 0.f || a == 0.f ) - { - continue; - } - float t; - if( m_invertSphere ) - { - t = ( -b + sqrt( det ) ) / ( 2.f * a ); - } - else - { - t = ( -b - sqrt( det ) ) / ( 2.f * a ); - } - if( t > dt || t < 0.f ) + else if( m_velocityElement.m_offset != -1 ) { - continue; - } + float a = XMVectorGetX( XMVector3Dot( curVelocity, curVelocity ) ); + float b = XMVectorGetX( XMVector3Dot( curVelocity, offset ) ) * 2.f; + float c = XMVectorGetX( XMVector3Dot( offset, offset ) ) - m_radius * m_radius; - if( m_affectPosition ) - { - XMVECTOR newPosition = XMVectorMultiplyAdd( curVelocity, XMVectorReplicate( t ), curPosition ); - XMStoreFloat3( position, newPosition ); + float det = b * b - 4.f * a * c; + if( det < 0.f || a == 0.f ) + { + continue; + } + float t; + if( m_invertSphere ) + { + t = ( -b + sqrt( det ) ) / ( 2.f * a ); + } + else + { + t = ( -b - sqrt( det ) ) / ( 2.f * a ); + } + if( t > dt || t < 0.f ) + { + continue; + } - if( m_affectVelocity ) + if( m_affectPosition ) { - offset = XMVectorSubtract( newPosition, m_position ); - offset = XMVector3Normalize( offset ); - offset = XMVectorMultiply( offset, invert ); + XMVECTOR newPosition = XMVectorMultiplyAdd( curVelocity, XMVectorReplicate( t ), curPosition ); + XMStoreFloat3( position, newPosition ); - XMVECTOR velocityDot = XMVector3Dot( curVelocity, offset ); - if( XMVectorGetIntX( XMVectorLess( velocityDot, XMVectorZero() ) ) ) + if( m_affectVelocity ) { - XMVECTOR bounce = XMVectorMultiply( offset, XMVectorNegate( velocityDot ) ); - XMVECTOR slide = XMVectorAdd( curVelocity, bounce ); - bounce = XMVectorScale( bounce, m_elasticity ); - slide = XMVectorScale( slide, m_friction ); - XMStoreFloat3( velocity, XMVectorAdd( bounce, slide ) ); - if( m_reflectionNoise > 0 ) + offset = XMVectorSubtract( newPosition, m_position ); + offset = XMVector3Normalize( offset ); + offset = XMVectorMultiply( offset, invert ); + + XMVECTOR velocityDot = XMVector3Dot( curVelocity, offset ); + if( XMVectorGetIntX( XMVectorLess( velocityDot, XMVectorZero() ) ) ) { - XMVECTOR reflectionNoise; - reflectionNoise = Vector3( - Tr2ParticleSystem::RandFloat() * 2 - 1, - Tr2ParticleSystem::RandFloat() * 2 - 1, - Tr2ParticleSystem::RandFloat() * 2 - 1 ); - reflectionNoise = XMVectorScale( reflectionNoise, m_reflectionNoise ); - reflectionNoise = XMVectorSubtract( reflectionNoise, XMVectorMultiply( offset, XMVector3Dot( reflectionNoise, offset ) ) ); - XMVECTOR speed = XMVector3LengthEst( curVelocity ); - reflectionNoise = XMVectorMultiply( reflectionNoise, speed ); - XMStoreFloat3( velocity, reflectionNoise ); + XMVECTOR bounce = XMVectorMultiply( offset, XMVectorNegate( velocityDot ) ); + XMVECTOR slide = XMVectorAdd( curVelocity, bounce ); + bounce = XMVectorScale( bounce, m_elasticity ); + slide = XMVectorScale( slide, m_friction ); + XMStoreFloat3( velocity, XMVectorAdd( bounce, slide ) ); + if( m_reflectionNoise > 0 ) + { + XMVECTOR reflectionNoise; + reflectionNoise = Vector3( + Tr2ParticleSystem::RandFloat() * 2 - 1, + Tr2ParticleSystem::RandFloat() * 2 - 1, + Tr2ParticleSystem::RandFloat() * 2 - 1 ); + reflectionNoise = XMVectorScale( reflectionNoise, m_reflectionNoise ); + reflectionNoise = XMVectorSubtract( reflectionNoise, XMVectorMultiply( offset, XMVector3Dot( reflectionNoise, offset ) ) ); + XMVECTOR speed = XMVector3LengthEst( curVelocity ); + reflectionNoise = XMVectorMultiply( reflectionNoise, speed ); + XMStoreFloat3( velocity, reflectionNoise ); + } } } } } - } - if( !m_generators.empty() ) - { - float* particle[Tr2ParticleElementData::COUNT]; - for( unsigned j = 0; j < Tr2ParticleElementData::COUNT; ++j ) + if( !m_generators.empty() ) { - particle[j] = particles[j] + strides[j] * i; + float* particle[Tr2ParticleElementData::COUNT]; + for( unsigned j = 0; j < Tr2ParticleElementData::COUNT; ++j ) + { + particle[j] = particles[j] + strides[j] * i; + } + for( auto it = m_generators.begin(); it != m_generators.end(); ++it ) + { + ( *it )->Generate( reinterpret_cast( position.Get() ), + m_velocityElement.m_offset != -1 ? reinterpret_cast( velocity.Get() ) : nullptr, + particle ); + } } - for( auto it = m_generators.begin(); it != m_generators.end(); ++it ) + for( auto it = m_onCollisionEmitters.begin(); it != m_onCollisionEmitters.end(); ++it ) { - ( *it )->Generate( reinterpret_cast( position.Get() ), - m_velocityElement.m_offset != -1 ? reinterpret_cast( velocity.Get() ) : nullptr, - particle ); + ( *it )->SpawnParticles( arguments, reinterpret_cast( position.Get() ), m_velocityElement.m_offset != -1 ? reinterpret_cast( velocity.Get() ) : nullptr ); } } - for( auto it = m_onCollisionEmitters.begin(); it != m_onCollisionEmitters.end(); ++it ) - { - ( *it )->SpawnParticles( arguments, reinterpret_cast( position.Get() ), - m_velocityElement.m_offset != -1 ? reinterpret_cast( velocity.Get() ) : nullptr ); - } - } - } ); + } ); } // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericParticleConstraint interface. A chance for constraint to bind -// itself to a particle system. Called when constaint is added to the particle system +// Implements ITr2GenericParticleConstraint interface. A chance for constraint to bind +// itself to a particle system. Called when constaint is added to the particle system // or when system is re-binded. // Arguments: // system - Particle system the constaint is attached to. @@ -277,7 +270,7 @@ void Tr2SphereConstraint::ApplyConstraint( const ITr2GenericEmitter::UpdateArgum void Tr2SphereConstraint::Bind( Tr2ParticleSystem* system ) { m_isValid = false; - const Tr2ParticleElementDataMap &declaration = system->GetElementDeclaration(); + const Tr2ParticleElementDataMap& declaration = system->GetElementDeclaration(); Tr2ParticleElementDeclarationName position( Tr2ParticleElementDeclarationName::POSITION ); auto i = declaration.find( position ); diff --git a/trinity/Particle/Tr2SphereConstraint.h b/trinity/Particle/Tr2SphereConstraint.h index ae77cf005..bb2847a2e 100644 --- a/trinity/Particle/Tr2SphereConstraint.h +++ b/trinity/Particle/Tr2SphereConstraint.h @@ -20,7 +20,7 @@ BLUE_DECLARE_IVECTOR( ITr2GenericEmitter ); // See Also: // Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2SphereConstraint ): +BLUE_CLASS( Tr2SphereConstraint ) : public ITr2GenericParticleConstraint, public IInitialize, public IListNotify @@ -30,8 +30,8 @@ BLUE_CLASS( Tr2SphereConstraint ): EXPOSE_TO_BLUE(); - using IInitialize::Lock; - using IInitialize::Unlock; + using IInitialize::Lock; + using IInitialize::Unlock; ///////////////////////////////////////////////////////////// // IInitialize @@ -40,17 +40,16 @@ BLUE_CLASS( Tr2SphereConstraint ): ///////////////////////////////////////////////////////////// // INotify virtual void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const struct IList* theList - ); + const struct IList* theList ); ///////////////////////////////////////////////////////////// // ITr2ParticleConstraint virtual void ApplyConstraint( const ITr2GenericEmitter::UpdateArguments& arguments, float** particle, unsigned* strides, unsigned count, float dt ); - virtual void Bind( Tr2ParticleSystem* system ); + virtual void Bind( Tr2ParticleSystem * system ); void RenderDebugInfo( ITr2DebugRenderer2 & renderer, const Matrix& worldTransform, const CcpMath::AxisAlignedBox& aabb ) const override; diff --git a/trinity/Particle/Tr2SphereConstraint_Blue.cpp b/trinity/Particle/Tr2SphereConstraint_Blue.cpp index 9122ef824..88fbabf0e 100644 --- a/trinity/Particle/Tr2SphereConstraint_Blue.cpp +++ b/trinity/Particle/Tr2SphereConstraint_Blue.cpp @@ -7,27 +7,27 @@ BLUE_DEFINE( Tr2SphereConstraint ); const Be::ClassInfo* Tr2SphereConstraint::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2SphereConstraint, "" ) + EXPOSURE_BEGIN( Tr2SphereConstraint, "" ) MAP_INTERFACE( ITr2GenericParticleConstraint ) MAP_INTERFACE( Tr2SphereConstraint ) - MAP_ATTRIBUTE( "position", m_position, "Collision sphere center", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "radius", m_radius, "Collision sphere radius", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "invertSphere", m_invertSphere, "Invert sphere test", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "affectPosition", m_affectPosition, "Apply collision response to particle positions", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "affectVelocity", m_affectVelocity, "Apply collision response to particle velocities", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "friction", m_friction, "Inverse friction coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "elasticity", m_elasticity, "Inverse elasticity coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "reflectionNoise", m_reflectionNoise, "Reflection noise coefficient", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "particleRadiusComponent", - m_particleRadiusComponent, - "Name of the particle component that contains particle size (leave blank to have size=0 for all particles)", + MAP_ATTRIBUTE( "position", m_position, "Collision sphere center", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "radius", m_radius, "Collision sphere radius", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "invertSphere", m_invertSphere, "Invert sphere test", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "affectPosition", m_affectPosition, "Apply collision response to particle positions", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "affectVelocity", m_affectVelocity, "Apply collision response to particle velocities", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "friction", m_friction, "Inverse friction coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "elasticity", m_elasticity, "Inverse elasticity coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "reflectionNoise", m_reflectionNoise, "Reflection noise coefficient", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "particleRadiusComponent", + m_particleRadiusComponent, + "Name of the particle component that contains particle size (leave blank to have size=0 for all particles)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "particleRadiusCoefficient", - m_particleRadiusCoefficient, - "What to treat as particle surface (0 - center, 1 - sphere with particle radius)", + MAP_ATTRIBUTE( + "particleRadiusCoefficient", + m_particleRadiusCoefficient, + "What to treat as particle surface (0 - center, 1 - sphere with particle radius)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "generators", m_generators, "List of generators that are executed on collision", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "onCollisionEmitters", m_onCollisionEmitters, "List of emitters that are executed on collision", Be::READ | Be::PERSIST ) diff --git a/trinity/Particle/Tr2SphereShapeAttributeGenerator.cpp b/trinity/Particle/Tr2SphereShapeAttributeGenerator.cpp index e67c757c8..a31f3462b 100644 --- a/trinity/Particle/Tr2SphereShapeAttributeGenerator.cpp +++ b/trinity/Particle/Tr2SphereShapeAttributeGenerator.cpp @@ -27,8 +27,8 @@ inline float frand( float a, float b, float exponent ) // Description: // Tr2SphereShapeAttributeGenerator default constructor // -------------------------------------------------------------------------------------- -Tr2SphereShapeAttributeGenerator::Tr2SphereShapeAttributeGenerator() - :m_position( 0.0f, 0.0f, 0.0f ), +Tr2SphereShapeAttributeGenerator::Tr2SphereShapeAttributeGenerator() : + m_position( 0.0f, 0.0f, 0.0f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_minPhi( 0.0f ), m_maxPhi( 360.0f ), @@ -58,34 +58,34 @@ Tr2SphereShapeAttributeGenerator::~Tr2SphereShapeAttributeGenerator() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2AttributeGenerator interface. Generates random values for new +// Implements ITr2AttributeGenerator interface. Generates random values for new // particle component (element). // Arguments: // position - Position of the "parent" particle. // velocity - Velocity of the "parent" particle. -// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. +// paticle - (out) New particle data: Tr2ParticleElementData::COUNT of float arrays. // The generator fills position and/or velocity of the new particle. // -------------------------------------------------------------------------------------- -void Tr2SphereShapeAttributeGenerator::Generate( const Vector3* position, - const Vector3* velocity, +void Tr2SphereShapeAttributeGenerator::Generate( const Vector3* position, + const Vector3* velocity, float** particle ) { if( !m_valid || ( !m_controlPosition && !m_controlVelocity ) ) { return; } - + float phi = XMConvertToRadians( frand( m_minPhi, m_maxPhi ) ); float theta = XMConvertToRadians( frand( m_minTheta, m_maxTheta ) ); // This is not exactly uniform, but it doesn't matter - XMVECTOR randomVector = XMVectorSet( sin( phi ) * cos( theta ), - -cos( phi ), - sin( phi ) * sin( theta ), + XMVECTOR randomVector = XMVectorSet( sin( phi ) * cos( theta ), + -cos( phi ), + sin( phi ) * sin( theta ), 0.f ); - randomVector = XMQuaternionMultiply( - XMQuaternionMultiply( XMQuaternionConjugate( m_rotation ), randomVector ), + randomVector = XMQuaternionMultiply( + XMQuaternionMultiply( XMQuaternionConjugate( m_rotation ), randomVector ), m_rotation ); if( m_controlVelocity && m_velocityElement.m_offset != -1 ) @@ -94,12 +94,12 @@ void Tr2SphereShapeAttributeGenerator::Generate( const Vector3* position, XMVECTOR particleVelocity = XMVectorScale( randomVector, speed ); if( velocity ) { - particleVelocity = XMVectorAdd( - particleVelocity, + particleVelocity = XMVectorAdd( + particleVelocity, XMVectorScale( XMLoadFloat4A( reinterpret_cast( velocity ) ), m_parentVelocityFactor ) ); } - XMStoreFloat4A( - reinterpret_cast( particle[m_velocityElement.m_bufferType] + m_velocityElement.m_offset ), + XMStoreFloat4A( + reinterpret_cast( particle[m_velocityElement.m_bufferType] + m_velocityElement.m_offset ), particleVelocity ); } if( m_controlPosition && m_positionElement.m_offset != -1 ) @@ -108,15 +108,15 @@ void Tr2SphereShapeAttributeGenerator::Generate( const Vector3* position, randomVector = XMVectorScale( randomVector, radius ); if( position ) { - randomVector = XMVectorAdd( - randomVector, + randomVector = XMVectorAdd( + randomVector, XMLoadFloat4A( reinterpret_cast( position ) ) ); } - randomVector = XMVectorAdd( - randomVector, + randomVector = XMVectorAdd( + randomVector, XMLoadFloat4( reinterpret_cast( &m_position ) ) ); - XMStoreFloat4A( - reinterpret_cast( particle[m_positionElement.m_bufferType] + m_positionElement.m_offset ), + XMStoreFloat4A( + reinterpret_cast( particle[m_positionElement.m_bufferType] + m_positionElement.m_offset ), randomVector ); } } @@ -128,17 +128,17 @@ void Tr2SphereShapeAttributeGenerator::Generate( const Vector3* position, // Arguments: // declaration - Particle element data coming from particle system. // boundElements - (in/out) The generator is expected to mark particle elements it will -// be filling by adding their declaration names to this set. Emitter uses this set +// be filling by adding their declaration names to this set. Emitter uses this set // to check if all particle elements were bound to some generator. The generator -// is responsible for checking if its elements are overwritten by some other +// is responsible for checking if its elements are overwritten by some other // generator using this set. // Return Value: // true If the generator successfully binds to the particle system // false Otherwise // -------------------------------------------------------------------------------------- -bool Tr2SphereShapeAttributeGenerator::Bind( - const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ) +bool Tr2SphereShapeAttributeGenerator::Bind( + const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ) { m_valid = false; m_positionElement.m_offset = -1; @@ -187,7 +187,7 @@ bool Tr2SphereShapeAttributeGenerator::Bind( // -------------------------------------------------------------------------------------- // Description: -// Returns human-readable name for generator's declaration element. Used for Python +// Returns human-readable name for generator's declaration element. Used for Python // exposure. // Return Value: // Human-readable name of particle declaration element. diff --git a/trinity/Particle/Tr2SphereShapeAttributeGenerator.h b/trinity/Particle/Tr2SphereShapeAttributeGenerator.h index e02da8e22..e782f5555 100644 --- a/trinity/Particle/Tr2SphereShapeAttributeGenerator.h +++ b/trinity/Particle/Tr2SphereShapeAttributeGenerator.h @@ -14,7 +14,8 @@ // See Also: // ITr2AttributeGenerator, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2SphereShapeAttributeGenerator ): public ITr2AttributeGenerator +BLUE_CLASS( Tr2SphereShapeAttributeGenerator ) : + public ITr2AttributeGenerator { public: EXPOSE_TO_BLUE(); @@ -23,12 +24,13 @@ BLUE_CLASS( Tr2SphereShapeAttributeGenerator ): public ITr2AttributeGenerator ~Tr2SphereShapeAttributeGenerator(); void Generate( const Vector3* position, const Vector3* velocity, float** particle ); - bool Bind( const Tr2ParticleElementDataMap& declaration, - std::set &boundElements ); + bool Bind( const Tr2ParticleElementDataMap& declaration, + std::set& boundElements ); std::string GetName() const; - void GetTransform( Vector3& position, Quaternion& rotation ); + void GetTransform( Vector3 & position, Quaternion & rotation ); void SetTransform( const Vector3& position, const Quaternion& rotation ); + private: // Generator position Vector3 m_position; diff --git a/trinity/Particle/Tr2SphereShapeAttributeGenerator_Blue.cpp b/trinity/Particle/Tr2SphereShapeAttributeGenerator_Blue.cpp index 28ec11b73..34c8257dd 100644 --- a/trinity/Particle/Tr2SphereShapeAttributeGenerator_Blue.cpp +++ b/trinity/Particle/Tr2SphereShapeAttributeGenerator_Blue.cpp @@ -11,7 +11,7 @@ const Be::ClassInfo* Tr2SphereShapeAttributeGenerator::ExposeToBlue() EXPOSURE_BEGIN( Tr2SphereShapeAttributeGenerator, "" ) MAP_INTERFACE( Tr2SphereShapeAttributeGenerator ) MAP_INTERFACE( ITr2AttributeGenerator ) - + MAP_PROPERTY_READONLY( "name", GetName, "Element name (composed of type and customName)" ) MAP_ATTRIBUTE( "position", m_position, "Generator position", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotation", m_rotation, "Generator orientation", Be::READWRITE | Be::PERSIST ) @@ -23,21 +23,21 @@ const Be::ClassInfo* Tr2SphereShapeAttributeGenerator::ExposeToBlue() MAP_ATTRIBUTE( "maxTheta", m_maxTheta, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "distributionExponent", m_distributionExponent, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( - "controlPosition", - m_controlPosition, - "Does the generator affect particle position", + "controlPosition", + m_controlPosition, + "Does the generator affect particle position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "controlVelocity", - m_controlVelocity, - "Does the generator affect particle velocity", + MAP_ATTRIBUTE( + "controlVelocity", + m_controlVelocity, + "Does the generator affect particle velocity", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "minSpeed", m_minSpeed, "Minimal particle speed", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "maxSpeed", m_maxSpeed, "Maximal particle speed", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "parentVelocityFactor", - m_parentVelocityFactor, - "How much parent particle velocity affects new particle velocity (for emit during lifetime and on deth emitters)", + MAP_ATTRIBUTE( + "parentVelocityFactor", + m_parentVelocityFactor, + "How much parent particle velocity affects new particle velocity (for emit during lifetime and on deth emitters)", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "valid", m_valid, "Was the generator successfully bound to particle system", Be::READ ) diff --git a/trinity/Particle/Tr2StaticEmitter.cpp b/trinity/Particle/Tr2StaticEmitter.cpp index 8d9754f3f..f8b1fee82 100644 --- a/trinity/Particle/Tr2StaticEmitter.cpp +++ b/trinity/Particle/Tr2StaticEmitter.cpp @@ -11,8 +11,8 @@ // Description: // Tr2StaticEmitter default constructor // -------------------------------------------------------------------------------------- -Tr2StaticEmitter::Tr2StaticEmitter( IRoot* lockobj ) - :m_hasSpawnedParticles( false ), +Tr2StaticEmitter::Tr2StaticEmitter( IRoot* lockobj ) : + m_hasSpawnedParticles( false ), m_meshIndex( 0 ), m_isThreadSafe( false ) { @@ -36,8 +36,8 @@ bool Tr2StaticEmitter::Initialize() { if( !m_geometryResourcePath.empty() ) { - BeResMan->GetResource( m_geometryResourcePath, - "raw", + BeResMan->GetResource( m_geometryResourcePath, + "raw", m_geometryResource ); } if( m_particleSystem && m_isThreadSafe ) @@ -49,9 +49,9 @@ bool Tr2StaticEmitter::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the emitter o respond to parameter changes -// generated in Python. If the particle geometry resource path changes, the emitter -// starts loading new particle data. +// Implements INotify interface. Allows the emitter o respond to parameter changes +// generated in Python. If the particle geometry resource path changes, the emitter +// starts loading new particle data. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -61,8 +61,8 @@ bool Tr2StaticEmitter::OnModified( Be::Var* value ) { if( IsMatch( value, m_geometryResourcePath ) ) { - BeResMan->GetResource( m_geometryResourcePath, - "raw", + BeResMan->GetResource( m_geometryResourcePath, + "raw", m_geometryResource ); } else if( IsMatch( value, m_particleSystem ) ) @@ -91,15 +91,13 @@ void Tr2StaticEmitter::SetThreadSafeFlag() // -------------------------------------------------------------------------------------- // Description: -// Spawns particles from geometry resource if resource is loaded. +// Spawns particles from geometry resource if resource is loaded. // -------------------------------------------------------------------------------------- void Tr2StaticEmitter::DoSpawn() { CCP_STATS_ZONE( __FUNCTION__ ); - auto createDeclarationMap = []( const Tr2VertexDefinition& elements, const Tr2ParticleElementDataMap& particleElements, - const std::string& geometryResourcePath, std::vector& geometryDeclarationMap ) -> bool - { + auto createDeclarationMap = []( const Tr2VertexDefinition& elements, const Tr2ParticleElementDataMap& particleElements, const std::string& geometryResourcePath, std::vector& geometryDeclarationMap ) -> bool { geometryDeclarationMap.clear(); for( auto i = particleElements.begin(); i != particleElements.end(); ++i ) { @@ -158,9 +156,7 @@ void Tr2StaticEmitter::DoSpawn() return true; }; - auto spawnParticles = []( Tr2ParticleSystemPtr particleSystem, const std::vector& geometryDeclarationMap, - uint32_t vertexCount, uint32_t stride, const uint8_t* data ) - { + auto spawnParticles = []( Tr2ParticleSystemPtr particleSystem, const std::vector& geometryDeclarationMap, uint32_t vertexCount, uint32_t stride, const uint8_t* data ) { for( uint32_t i = 0; i < vertexCount; ++i ) { float* particle[Tr2ParticleElementData::COUNT]; @@ -193,7 +189,7 @@ void Tr2StaticEmitter::DoSpawn() } }; - if( m_particleSystem && m_particleSystem->IsValid() && + if( m_particleSystem && m_particleSystem->IsValid() && m_geometryResource && m_geometryResource->IsGood() && Tr2Renderer::IsResourceCreationAllowed() ) { if( m_geometryResource->IsUsingCMF() ) @@ -208,7 +204,7 @@ void Tr2StaticEmitter::DoSpawn() } const cmf::Mesh& meshData = m_geometryResource->GetCMFData()->meshes[m_meshIndex]; - + // Validate geometry vertex declaration against particle system element declaration Tr2VertexDefinition elements = BuildFromCMFVertexDecl( meshData.decl ); const Tr2ParticleElementDataMap& particleElements = m_particleSystem->GetElementDeclaration(); @@ -271,7 +267,7 @@ void Tr2StaticEmitter::DoSpawn() // -------------------------------------------------------------------------------------- // Description: // Implements ITr2GenericEmitter interface. Spawns particles from geometry resource -// if resource is loaded and particles were not alread spawned. +// if resource is loaded and particles were not alread spawned. // Arguments: // arguments - Update arguments // -------------------------------------------------------------------------------------- @@ -285,7 +281,7 @@ void Tr2StaticEmitter::Update( const ITr2GenericEmitter::UpdateArguments& argume // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter interface. Does nothing since this emitter only spawns +// Implements ITr2GenericEmitter interface. Does nothing since this emitter only spawns // particles once during Update method. // Arguments: // arguments - Update arguments @@ -294,17 +290,19 @@ void Tr2StaticEmitter::Update( const ITr2GenericEmitter::UpdateArguments& argume // rateModifier - Modifies the number of particles spawned as opposed to emitter's // defined rate value (unused). // -------------------------------------------------------------------------------------- -void Tr2StaticEmitter::SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, - const Vector3* position, - const Vector3* velocity, +void Tr2StaticEmitter::SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, + const Vector3* position, + const Vector3* velocity, float rateModifier ) { } -void Tr2StaticEmitter::SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, - float deltaTime ) +void Tr2StaticEmitter::SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, + float deltaTime ) { SpawnParticles( arguments, positionEnd, velocityEnd, deltaTime ); } diff --git a/trinity/Particle/Tr2StaticEmitter.h b/trinity/Particle/Tr2StaticEmitter.h index 467b76601..f8e5261b7 100644 --- a/trinity/Particle/Tr2StaticEmitter.h +++ b/trinity/Particle/Tr2StaticEmitter.h @@ -17,9 +17,9 @@ BLUE_DECLARE( TriGrannyRes ); // See Also: // ITr2GenericEmitter, Tr2ParticleSystem // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2StaticEmitter ): +BLUE_CLASS( Tr2StaticEmitter ) : public ITr2GenericEmitter, - public INotify, + public INotify, public IInitialize { public: @@ -37,20 +37,25 @@ BLUE_CLASS( Tr2StaticEmitter ): ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2GenericEmitter void Update( const ITr2GenericEmitter::UpdateArguments& arguments ); - void SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, - const Vector3* position = nullptr, const Vector3* velocity = nullptr, float rateModifier = 1.0f ); - void SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, - const Vector3 *positionStart, const Vector3 *positionEnd, - const Vector3 *velocityStart, const Vector3 *velocityEnd, + void SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, + const Vector3* position = nullptr, + const Vector3* velocity = nullptr, + float rateModifier = 1.0f ); + void SpawnParticles( const ITr2GenericEmitter::UpdateArguments& arguments, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ); void SetThreadSafeFlag(); void Spawn(); + private: // -------------------------------------------------------------------------------------- // Description: diff --git a/trinity/Particle/Tr2StaticEmitter_Blue.cpp b/trinity/Particle/Tr2StaticEmitter_Blue.cpp index 848dfdb97..ed2ff3b7d 100644 --- a/trinity/Particle/Tr2StaticEmitter_Blue.cpp +++ b/trinity/Particle/Tr2StaticEmitter_Blue.cpp @@ -12,27 +12,27 @@ const Be::ClassInfo* Tr2StaticEmitter::ExposeToBlue() MAP_INTERFACE( ITr2GenericEmitter ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) - - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "geometryResourcePath", - m_geometryResourcePath, - "Path to geometry resource with particle data", + + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "geometryResourcePath", + m_geometryResourcePath, + "Path to geometry resource with particle data", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE( - "geometryResource", - m_geometryResource, - "Geometry resource with particle data", + MAP_ATTRIBUTE( + "geometryResource", + m_geometryResource, + "Geometry resource with particle data", Be::READ ) - MAP_ATTRIBUTE( - "particleSystem", - m_particleSystem, - "Particle system to emit particles to", + MAP_ATTRIBUTE( + "particleSystem", + m_particleSystem, + "Particle system to emit particles to", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "meshIndex", - m_meshIndex, - "Mesh index in a geometry resource with particle data", + MAP_ATTRIBUTE( + "meshIndex", + m_meshIndex, + "Mesh index in a geometry resource with particle data", Be::READWRITE | Be::PERSIST ) MAP_METHOD_AND_WRAP( "Spawn", Spawn, "(Re)spawns particles during next update" ) diff --git a/trinity/PostProcess/Effects/Tr2PPBloomEffect.cpp b/trinity/PostProcess/Effects/Tr2PPBloomEffect.cpp index ab57c0013..e88aec1c3 100644 --- a/trinity/PostProcess/Effects/Tr2PPBloomEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPBloomEffect.cpp @@ -14,13 +14,10 @@ Tr2PPBloomEffect::Tr2PPBloomEffect( IRoot* lockobj ) : m_grimeWeight( 0.0f ), m_grimePath( "res:/texture/global/black.dds" ) { - m_stepSizes = { Bloom::DEFAULT_BLOOM_STEP_1_SIZE, Bloom::DEFAULT_BLOOM_STEP_2_SIZE, Bloom::DEFAULT_BLOOM_STEP_3_SIZE, - Bloom::DEFAULT_BLOOM_STEP_4_SIZE, Bloom::DEFAULT_BLOOM_STEP_5_SIZE, Bloom::DEFAULT_BLOOM_STEP_6_SIZE }; - m_stepTints = { Bloom::DEFAULT_BLOOM_STEP_1_TINT, Bloom::DEFAULT_BLOOM_STEP_2_TINT, Bloom::DEFAULT_BLOOM_STEP_3_TINT, - Bloom::DEFAULT_BLOOM_STEP_4_TINT, Bloom::DEFAULT_BLOOM_STEP_5_TINT, Bloom::DEFAULT_BLOOM_STEP_6_TINT }; + m_stepSizes = { Bloom::DEFAULT_BLOOM_STEP_1_SIZE, Bloom::DEFAULT_BLOOM_STEP_2_SIZE, Bloom::DEFAULT_BLOOM_STEP_3_SIZE, Bloom::DEFAULT_BLOOM_STEP_4_SIZE, Bloom::DEFAULT_BLOOM_STEP_5_SIZE, Bloom::DEFAULT_BLOOM_STEP_6_SIZE }; + m_stepTints = { Bloom::DEFAULT_BLOOM_STEP_1_TINT, Bloom::DEFAULT_BLOOM_STEP_2_TINT, Bloom::DEFAULT_BLOOM_STEP_3_TINT, Bloom::DEFAULT_BLOOM_STEP_4_TINT, Bloom::DEFAULT_BLOOM_STEP_5_TINT, Bloom::DEFAULT_BLOOM_STEP_6_TINT }; } Tr2PPBloomEffect::~Tr2PPBloomEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPBloomEffect.h b/trinity/PostProcess/Effects/Tr2PPBloomEffect.h index 830bc689e..0b9dd8d58 100644 --- a/trinity/PostProcess/Effects/Tr2PPBloomEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPBloomEffect.h @@ -6,25 +6,25 @@ namespace Bloom { - const uint32_t MAX_BLOOM_STEPS = 6; - const uint32_t MAX_FILTER_STEPS = 128; - - const float DEFAULT_BLOOM_SIZE_SCALE = 4.0f; - const float DEFAULT_BLOOM_DIRECTIONAL_WEIGHT = 0.0f; - - const float DEFAULT_BLOOM_STEP_1_SIZE = 0.3f; - const float DEFAULT_BLOOM_STEP_2_SIZE = 1.0f; - const float DEFAULT_BLOOM_STEP_3_SIZE = 2.0f; - const float DEFAULT_BLOOM_STEP_4_SIZE = 10.0f; - const float DEFAULT_BLOOM_STEP_5_SIZE = 30.0f; - const float DEFAULT_BLOOM_STEP_6_SIZE = 64.0f; - - const Color DEFAULT_BLOOM_STEP_1_TINT = Color( 0.3465f, 0.3465f, 0.3465f, 0.3465f ); - const Color DEFAULT_BLOOM_STEP_2_TINT = Color( 0.138f, 0.138f, 0.138f, 0.138f ); - const Color DEFAULT_BLOOM_STEP_3_TINT = Color( 0.1176f, 0.1176f, 0.1176f, 0.1176f ); - const Color DEFAULT_BLOOM_STEP_4_TINT = Color( 0.066f, 0.066f, 0.066f, 0.066f ); - const Color DEFAULT_BLOOM_STEP_5_TINT = Color( 0.066f, 0.066f, 0.066f, 0.066f ); - const Color DEFAULT_BLOOM_STEP_6_TINT = Color( 0.061f, 0.061f, 0.061f, 0.061f ); +const uint32_t MAX_BLOOM_STEPS = 6; +const uint32_t MAX_FILTER_STEPS = 128; + +const float DEFAULT_BLOOM_SIZE_SCALE = 4.0f; +const float DEFAULT_BLOOM_DIRECTIONAL_WEIGHT = 0.0f; + +const float DEFAULT_BLOOM_STEP_1_SIZE = 0.3f; +const float DEFAULT_BLOOM_STEP_2_SIZE = 1.0f; +const float DEFAULT_BLOOM_STEP_3_SIZE = 2.0f; +const float DEFAULT_BLOOM_STEP_4_SIZE = 10.0f; +const float DEFAULT_BLOOM_STEP_5_SIZE = 30.0f; +const float DEFAULT_BLOOM_STEP_6_SIZE = 64.0f; + +const Color DEFAULT_BLOOM_STEP_1_TINT = Color( 0.3465f, 0.3465f, 0.3465f, 0.3465f ); +const Color DEFAULT_BLOOM_STEP_2_TINT = Color( 0.138f, 0.138f, 0.138f, 0.138f ); +const Color DEFAULT_BLOOM_STEP_3_TINT = Color( 0.1176f, 0.1176f, 0.1176f, 0.1176f ); +const Color DEFAULT_BLOOM_STEP_4_TINT = Color( 0.066f, 0.066f, 0.066f, 0.066f ); +const Color DEFAULT_BLOOM_STEP_5_TINT = Color( 0.066f, 0.066f, 0.066f, 0.066f ); +const Color DEFAULT_BLOOM_STEP_6_TINT = Color( 0.061f, 0.061f, 0.061f, 0.061f ); } namespace Tr2Bloom @@ -53,7 +53,7 @@ BLUE_CLASS( Tr2PPBloomEffect ) : Tr2PPBloomEffect( IRoot* lockobj = NULL ); ~Tr2PPBloomEffect(); - + float m_luminanceThreshold; float m_luminanceScale; float m_bloomBrightness; diff --git a/trinity/PostProcess/Effects/Tr2PPBloomEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPBloomEffect_Blue.cpp index 0b5ea7243..1016ce598 100644 --- a/trinity/PostProcess/Effects/Tr2PPBloomEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPBloomEffect_Blue.cpp @@ -35,7 +35,4 @@ const Be::ClassInfo* Tr2PPBloomEffect::ExposeToBlue() MAP_ATTRIBUTE( "step6Tint", m_stepTints[5], "step6Tint", Be::READWRITE | Be::PERSIST ) EXPOSURE_CHAINTO( Tr2PPEffect ) - - } - diff --git a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.cpp b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.cpp index 8a4f1268f..3ef0ce1b8 100644 --- a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.cpp @@ -12,10 +12,8 @@ Tr2PPColorCorrectionEffect::Tr2PPColorCorrectionEffect( IRoot* lockobj ) : m_colorGain( Vector3( 1.0f, 1.0f, 1.0f ) ), m_colorOffset( Vector3( 0.0f, 0.0f, 0.0f ) ) { - } Tr2PPColorCorrectionEffect::~Tr2PPColorCorrectionEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.h b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.h index 981197032..b5d524ce1 100644 --- a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect.h @@ -12,7 +12,7 @@ BLUE_CLASS( Tr2PPColorCorrectionEffect ) : Tr2PPColorCorrectionEffect( IRoot* lockobj = NULL ); ~Tr2PPColorCorrectionEffect(); - + float m_whiteTemperature; float m_whiteTint; float m_colorSaturation; diff --git a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect_Blue.cpp index bb882a815..b59de53c3 100644 --- a/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPColorCorrectionEffect_Blue.cpp @@ -20,4 +20,3 @@ const Be::ClassInfo* Tr2PPColorCorrectionEffect::ExposeToBlue() EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.cpp b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.cpp index 216bb4185..2065c9218 100644 --- a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.cpp @@ -4,17 +4,17 @@ #include "Tr2PPDepthOfFieldEffect.h" #include "TriSettingsRegistrar.h" -bool g_postprocessDofEnabled= false; +bool g_postprocessDofEnabled = false; TRI_REGISTER_SETTING( "postprocessDofEnabled", g_postprocessDofEnabled ); Tr2PPDepthOfFieldEffect::Tr2PPDepthOfFieldEffect( IRoot* lockobj ) : m_focalDistance( 0.0f ), - m_focalLength(0.0f), + m_focalLength( 0.0f ), m_scale( 0.0f ), m_cocScale( 1.0f ), m_foregroundBlurNeeded( true ), m_bokehShape( Tr2Bokeh::Disk ), - m_useTAAFriendlyBokeh(true) + m_useTAAFriendlyBokeh( true ) { } diff --git a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.h b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.h index babf76550..113007020 100644 --- a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect.h @@ -5,17 +5,17 @@ #include "Tr2PPEffect.h" namespace Tr2Bokeh { - enum Shape - { - Disk, - Triangle, - Rectangle, - Pentagon, - Hexagon, - Heart - }; - - extern const Be::VarChooser BokehShapeChooser[]; +enum Shape +{ + Disk, + Triangle, + Rectangle, + Pentagon, + Hexagon, + Heart +}; + +extern const Be::VarChooser BokehShapeChooser[]; } extern bool g_postprocessDofEnabled; @@ -25,7 +25,7 @@ BLUE_CLASS( Tr2PPDepthOfFieldEffect ) : { public: EXPOSE_TO_BLUE(); - + Tr2PPDepthOfFieldEffect( IRoot* lockobj = NULL ); ~Tr2PPDepthOfFieldEffect(); diff --git a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect_Blue.cpp index bebb6c2ab..bcace845f 100644 --- a/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPDepthOfFieldEffect_Blue.cpp @@ -7,16 +7,16 @@ BLUE_DEFINE( Tr2PPDepthOfFieldEffect ); namespace Tr2Bokeh { - const Be::VarChooser BokehShapeChooser[] = { - { "Disk", BeCast( Tr2Bokeh::Disk ), "A perfectly circular aperture" }, - { "Triangle", BeCast( Tr2Bokeh::Triangle ), "An aperture with 3 sides" }, - { "Rectangle", BeCast( Tr2Bokeh::Rectangle ), "An aperture with 4 sides" }, - { "Pentagon", BeCast( Tr2Bokeh::Pentagon ), "An aperture with 5 sides" }, - { "Hexagon", BeCast( Tr2Bokeh::Hexagon ), "An aperture with 6 sides" }, - { "Heart", BeCast( Tr2Bokeh::Heart ), "A heart-shaped aperture <3" }, - { 0 } - }; - BLUE_REGISTER_ENUM_EX( "BokehShapeType", Shape, BokehShapeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +const Be::VarChooser BokehShapeChooser[] = { + { "Disk", BeCast( Tr2Bokeh::Disk ), "A perfectly circular aperture" }, + { "Triangle", BeCast( Tr2Bokeh::Triangle ), "An aperture with 3 sides" }, + { "Rectangle", BeCast( Tr2Bokeh::Rectangle ), "An aperture with 4 sides" }, + { "Pentagon", BeCast( Tr2Bokeh::Pentagon ), "An aperture with 5 sides" }, + { "Hexagon", BeCast( Tr2Bokeh::Hexagon ), "An aperture with 6 sides" }, + { "Heart", BeCast( Tr2Bokeh::Heart ), "A heart-shaped aperture <3" }, + { 0 } +}; +BLUE_REGISTER_ENUM_EX( "BokehShapeType", Shape, BokehShapeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); } const Be::ClassInfo* Tr2PPDepthOfFieldEffect::ExposeToBlue() { @@ -30,6 +30,6 @@ const Be::ClassInfo* Tr2PPDepthOfFieldEffect::ExposeToBlue() MAP_ATTRIBUTE( "foregroundBlurNeeded", m_foregroundBlurNeeded, "If foreground is always in focus, we can safely uncheck this", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "bokehShape", m_bokehShape, "What is the shape of the bokeh", Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2Bokeh::BokehShapeChooser ); MAP_ATTRIBUTE( "useTAAFriendlyBokeh", m_useTAAFriendlyBokeh, "Enables a separate Bokeh shader when TAA is enabled that is optimized to reduce flickering", Be::READWRITE ) - + EXPOSURE_CHAINTO( Tr2PPEffect ) } diff --git a/trinity/PostProcess/Effects/Tr2PPDesaturateEffect.cpp b/trinity/PostProcess/Effects/Tr2PPDesaturateEffect.cpp index 3bb95ad69..a1390bfb1 100644 --- a/trinity/PostProcess/Effects/Tr2PPDesaturateEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPDesaturateEffect.cpp @@ -5,12 +5,10 @@ Tr2PPDesaturateEffect::Tr2PPDesaturateEffect( IRoot* lockobj ) : - m_intensity( 1.0f ) + m_intensity( 1.0f ) { - } Tr2PPDesaturateEffect::~Tr2PPDesaturateEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPDesaturateEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPDesaturateEffect_Blue.cpp index 860a8f0fe..b19ded865 100644 --- a/trinity/PostProcess/Effects/Tr2PPDesaturateEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPDesaturateEffect_Blue.cpp @@ -13,8 +13,5 @@ const Be::ClassInfo* Tr2PPDesaturateEffect::ExposeToBlue() MAP_ATTRIBUTE( "intensity", m_intensity, "The intensity of the saturation", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) - - + EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect.h b/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect.h index 9f871a28f..d54424753 100644 --- a/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect.h @@ -28,7 +28,6 @@ BLUE_CLASS( Tr2PPDynamicExposureEffect ) : float m_minExposure; float m_maxExposure; bool m_debug; - }; TYPEDEF_BLUECLASS( Tr2PPDynamicExposureEffect ); diff --git a/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect_Blue.cpp index 88876c994..697c847c9 100644 --- a/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPDynamicExposureEffect_Blue.cpp @@ -23,6 +23,5 @@ const Be::ClassInfo* Tr2PPDynamicExposureEffect::ExposeToBlue() MAP_ATTRIBUTE( "maxExposure", m_maxExposure, "Maximal exposure limit", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "debug", m_debug, "Enable debugging for the exposure", Be::READWRITE ) - EXPOSURE_CHAINTO( Tr2PPEffect ) - + EXPOSURE_CHAINTO( Tr2PPEffect ) } \ No newline at end of file diff --git a/trinity/PostProcess/Effects/Tr2PPEffect.cpp b/trinity/PostProcess/Effects/Tr2PPEffect.cpp index 334cff8c5..c68e2f660 100644 --- a/trinity/PostProcess/Effects/Tr2PPEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPEffect.cpp @@ -3,16 +3,16 @@ #include "StdAfx.h" #include "Tr2PPEffect.h" -Tr2PPEffect::Tr2PPEffect( IRoot* lockobj ) : - m_display(true) +Tr2PPEffect::Tr2PPEffect( IRoot* lockobj ) : + m_display( true ) { - } -Tr2PPEffect::~Tr2PPEffect( ) { - +Tr2PPEffect::~Tr2PPEffect() +{ } -bool Tr2PPEffect::IsActive() { +bool Tr2PPEffect::IsActive() +{ return m_display; } diff --git a/trinity/PostProcess/Effects/Tr2PPEffect.h b/trinity/PostProcess/Effects/Tr2PPEffect.h index d83c83c80..ccfc195a8 100644 --- a/trinity/PostProcess/Effects/Tr2PPEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPEffect.h @@ -6,16 +6,16 @@ namespace PostProcess { - enum Quality - { - LOW, - MEDIUM, - HIGH, +enum Quality +{ + LOW, + MEDIUM, + HIGH, - COUNT - }; + COUNT +}; - extern const Be::VarChooser PostProcessQualityChooser[]; +extern const Be::VarChooser PostProcessQualityChooser[]; } @@ -32,7 +32,6 @@ BLUE_CLASS( Tr2PPEffect ) : protected: bool m_display; - }; TYPEDEF_BLUECLASS( Tr2PPEffect ); diff --git a/trinity/PostProcess/Effects/Tr2PPEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPEffect_Blue.cpp index 61ad5a341..42199d167 100644 --- a/trinity/PostProcess/Effects/Tr2PPEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPEffect_Blue.cpp @@ -4,13 +4,13 @@ #include "Tr2PPEffect.h" namespace PostProcess { - const Be::VarChooser PostProcessQualityChooser[] = { - { "Low", BeCast( Quality::LOW ), "Low Quality" }, - { "Medium", BeCast( Quality::MEDIUM ), "Medium Quality" }, - { "High", BeCast( Quality::HIGH ), "High Quality" }, - { 0 } - }; - BLUE_REGISTER_ENUM_EX( "PostProcessQuality", PostProcess::Quality, PostProcessQualityChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +const Be::VarChooser PostProcessQualityChooser[] = { + { "Low", BeCast( Quality::LOW ), "Low Quality" }, + { "Medium", BeCast( Quality::MEDIUM ), "Medium Quality" }, + { "High", BeCast( Quality::HIGH ), "High Quality" }, + { 0 } +}; +BLUE_REGISTER_ENUM_EX( "PostProcessQuality", PostProcess::Quality, PostProcessQualityChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); } @@ -21,12 +21,10 @@ const Be::ClassInfo* Tr2PPEffect::ExposeToBlue() EXPOSURE_BEGIN( Tr2PPEffect, "" ) MAP_ATTRIBUTE( "display", m_display, "Should this be rendered", Be::READWRITE | Be::NOTIFY ) - MAP_PROPERTY_READONLY( - "active", + MAP_PROPERTY_READONLY( + "active", IsActive, "" ) EXPOSURE_END() - } - diff --git a/trinity/PostProcess/Effects/Tr2PPFadeEffect.cpp b/trinity/PostProcess/Effects/Tr2PPFadeEffect.cpp index 9b303779f..3b7c778ab 100644 --- a/trinity/PostProcess/Effects/Tr2PPFadeEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFadeEffect.cpp @@ -8,14 +8,13 @@ Tr2PPFadeEffect::Tr2PPFadeEffect( IRoot* lockobj ) : m_intensity( 0.0f ), m_color( 0.0, 0.0, 0.0, 0.0 ) { - } Tr2PPFadeEffect::~Tr2PPFadeEffect() { - } -bool Tr2PPFadeEffect::IsActive() { +bool Tr2PPFadeEffect::IsActive() +{ return m_display && m_intensity > 0; } \ No newline at end of file diff --git a/trinity/PostProcess/Effects/Tr2PPFadeEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPFadeEffect_Blue.cpp index 39cbf02b4..d8da56c4c 100644 --- a/trinity/PostProcess/Effects/Tr2PPFadeEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFadeEffect_Blue.cpp @@ -13,8 +13,5 @@ const Be::ClassInfo* Tr2PPFadeEffect::ExposeToBlue() MAP_ATTRIBUTE( "intensity", m_intensity, "The intensity of the fade", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "color", m_color, "The color of the fade", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) - - + EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect.cpp b/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect.cpp index cbe33fa45..937ff1998 100644 --- a/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect.cpp @@ -18,7 +18,6 @@ Tr2PPFilmGrainEffect::Tr2PPFilmGrainEffect( IRoot* lockobj ) : Tr2PPFilmGrainEffect::~Tr2PPFilmGrainEffect() { - } bool Tr2PPFilmGrainEffect::IsActive() diff --git a/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect_Blue.cpp index de4ae2d68..e811941b3 100644 --- a/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFilmGrainEffect_Blue.cpp @@ -19,5 +19,5 @@ const Be::ClassInfo* Tr2PPFilmGrainEffect::ExposeToBlue() MAP_ATTRIBUTE( "grainContrast", m_grainContrast, "Contrast of grains, a higher value produces sharper grain edges. \n:jessica-group: New technique settings", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "brightnessModifier", m_brightnessModifier, "How the brightness of the pixel affects the film grain. Negative values reduce the noise intensity for bright pixels, while positive values increase the noise for bright pixels. \n:jessica-group: New technique settings", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) + EXPOSURE_CHAINTO( Tr2PPEffect ) } diff --git a/trinity/PostProcess/Effects/Tr2PPFogEffect.cpp b/trinity/PostProcess/Effects/Tr2PPFogEffect.cpp index 140b97f3e..8029a11b4 100644 --- a/trinity/PostProcess/Effects/Tr2PPFogEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFogEffect.cpp @@ -33,15 +33,13 @@ Tr2PPFogEffect::Tr2PPFogEffect( IRoot* lockobj ) : m_areaScale( 30.0, 20.0 ), m_areaCenter( -27042.2988281, -633.4446411, 11896.0957031 ) { - } Tr2PPFogEffect::~Tr2PPFogEffect() { - } -bool Tr2PPFogEffect::IsActive() +bool Tr2PPFogEffect::IsActive() { return m_display && m_intensity > 0.0f; } \ No newline at end of file diff --git a/trinity/PostProcess/Effects/Tr2PPFogEffect.h b/trinity/PostProcess/Effects/Tr2PPFogEffect.h index cab2f388a..536238ab4 100644 --- a/trinity/PostProcess/Effects/Tr2PPFogEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPFogEffect.h @@ -46,9 +46,6 @@ BLUE_CLASS( Tr2PPFogEffect ) : Vector3 m_areaSize; Vector2 m_areaScale; Vector3 m_areaCenter; - - - }; TYPEDEF_BLUECLASS( Tr2PPFogEffect ); diff --git a/trinity/PostProcess/Effects/Tr2PPFogEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPFogEffect_Blue.cpp index 8d59e5cc1..7034d8626 100644 --- a/trinity/PostProcess/Effects/Tr2PPFogEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPFogEffect_Blue.cpp @@ -37,7 +37,6 @@ const Be::ClassInfo* Tr2PPFogEffect::ExposeToBlue() MAP_ATTRIBUTE( "areaSize", m_areaSize, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "areaScale", m_areaScale, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "areaCenter", m_areaCenter, "", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_CHAINTO( Tr2PPEffect ) -} + EXPOSURE_CHAINTO( Tr2PPEffect ) +} diff --git a/trinity/PostProcess/Effects/Tr2PPGenericEffect.h b/trinity/PostProcess/Effects/Tr2PPGenericEffect.h index e6bc9c71c..429beeb83 100644 --- a/trinity/PostProcess/Effects/Tr2PPGenericEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPGenericEffect.h @@ -11,7 +11,7 @@ BLUE_CLASS( Tr2PPGenericEffect ) : { public: EXPOSE_TO_BLUE(); - + Tr2PPGenericEffect( IRoot* lockobj = NULL ); Tr2EffectPtr GetEffect() const; diff --git a/trinity/PostProcess/Effects/Tr2PPGenericEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPGenericEffect_Blue.cpp index f615b046a..5b4fa2822 100644 --- a/trinity/PostProcess/Effects/Tr2PPGenericEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPGenericEffect_Blue.cpp @@ -11,17 +11,12 @@ const Be::ClassInfo* Tr2PPGenericEffect::ExposeToBlue() EXPOSURE_BEGIN( Tr2PPGenericEffect, "" ) MAP_INTERFACE( Tr2PPEffect ) MAP_ATTRIBUTE_WITH_CHOOSER( - "quality", m_quality, - "post process quality level and higher where this effect gets rendered", - Be::READWRITE | Be::PERSIST | Be::ENUM, - PostProcess::PostProcessQualityChooser - ) + "quality", m_quality, "post process quality level and higher where this effect gets rendered", Be::READWRITE | Be::PERSIST | Be::ENUM, PostProcess::PostProcessQualityChooser ) MAP_ATTRIBUTE( "effect", m_effect, "The effect to use. The Tr2PostProcessRenderer passes the pre upscaled source into the Blit texture parameter of this effect", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) + EXPOSURE_CHAINTO( Tr2PPEffect ) } diff --git a/trinity/PostProcess/Effects/Tr2PPGodRaysEffect.cpp b/trinity/PostProcess/Effects/Tr2PPGodRaysEffect.cpp index e3b8557f2..60a769a46 100644 --- a/trinity/PostProcess/Effects/Tr2PPGodRaysEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPGodRaysEffect.cpp @@ -22,4 +22,3 @@ bool Tr2PPGodRaysEffect::IsActive() { return m_display && m_intensity > 0.0f; } - diff --git a/trinity/PostProcess/Effects/Tr2PPGodRaysEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPGodRaysEffect_Blue.cpp index cd6ad782d..e398083d0 100644 --- a/trinity/PostProcess/Effects/Tr2PPGodRaysEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPGodRaysEffect_Blue.cpp @@ -15,6 +15,4 @@ const Be::ClassInfo* Tr2PPGodRaysEffect::ExposeToBlue() MAP_ATTRIBUTE( "noiseTexturePath", m_noiseTexturePath, "The noise texture to use", Be::READWRITE | Be::PERSIST ) EXPOSURE_CHAINTO( Tr2PPEffect ) - } - diff --git a/trinity/PostProcess/Effects/Tr2PPLutEffect.cpp b/trinity/PostProcess/Effects/Tr2PPLutEffect.cpp index e822afef2..69a197427 100644 --- a/trinity/PostProcess/Effects/Tr2PPLutEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPLutEffect.cpp @@ -8,12 +8,10 @@ Tr2PPLutEffect::Tr2PPLutEffect( IRoot* lockobj ) : m_influence( 0.0f ), m_path( "res:/dx9/scene/postprocess/LUTdefault.dds" ) { - } Tr2PPLutEffect::~Tr2PPLutEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPLutEffect.h b/trinity/PostProcess/Effects/Tr2PPLutEffect.h index 79f14e5c3..41de74e36 100644 --- a/trinity/PostProcess/Effects/Tr2PPLutEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPLutEffect.h @@ -15,7 +15,7 @@ BLUE_CLASS( Tr2PPLutEffect ) : Tr2PPLutEffect( IRoot* lockobj = NULL ); ~Tr2PPLutEffect(); - + // Tr2PPEffect bool IsActive() override; diff --git a/trinity/PostProcess/Effects/Tr2PPLutEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPLutEffect_Blue.cpp index 67fd94a85..e5532ea9c 100644 --- a/trinity/PostProcess/Effects/Tr2PPLutEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPLutEffect_Blue.cpp @@ -13,8 +13,5 @@ const Be::ClassInfo* Tr2PPLutEffect::ExposeToBlue() MAP_ATTRIBUTE( "influence", m_influence, "The influence of the LUT", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "path", m_path, "The path of the LUT\n:jessica-widget: texturepath", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) - - + EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.cpp b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.cpp index 695c067d4..f7ee2074e 100644 --- a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.cpp @@ -18,6 +18,3 @@ bool Tr2PPSignalLossEffect::IsActive() { return m_display && m_strength > 0.0f; } - - - diff --git a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.h b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.h index dc1f16e39..068353cc3 100644 --- a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect.h @@ -16,7 +16,7 @@ BLUE_CLASS( Tr2PPSignalLossEffect ) : Tr2PPSignalLossEffect( IRoot* lockobj = NULL ); ~Tr2PPSignalLossEffect(); - + // Tr2PPEffect bool IsActive() override; diff --git a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect_Blue.cpp index c66fc470a..058b60dc4 100644 --- a/trinity/PostProcess/Effects/Tr2PPSignalLossEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPSignalLossEffect_Blue.cpp @@ -11,8 +11,6 @@ const Be::ClassInfo* Tr2PPSignalLossEffect::ExposeToBlue() MAP_INTERFACE( Tr2PPEffect ) MAP_ATTRIBUTE( "strength", m_strength, "The strength of the signal loss", Be::READWRITE | Be::PERSIST ) - - EXPOSURE_CHAINTO( Tr2PPEffect ) + EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPTaaEffect.cpp b/trinity/PostProcess/Effects/Tr2PPTaaEffect.cpp index 0ed9663bc..ab2f02c1c 100644 --- a/trinity/PostProcess/Effects/Tr2PPTaaEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPTaaEffect.cpp @@ -13,5 +13,4 @@ Tr2PPTaaEffect::Tr2PPTaaEffect( IRoot* lockobj ) : Tr2PPTaaEffect::~Tr2PPTaaEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPTaaEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPTaaEffect_Blue.cpp index 3b22577f8..78ba6d97f 100644 --- a/trinity/PostProcess/Effects/Tr2PPTaaEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPTaaEffect_Blue.cpp @@ -31,7 +31,6 @@ const Be::ClassInfo* Tr2PPTaaEffect::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "debug", m_debugMode, "Taa Debug", Be::READWRITE | Be::ENUM, Tr2PPTaaEffectDebugChooser ) MAP_ATTRIBUTE( "earlyOutThreshold", m_earlyOutThreshold, "Controls the threshold used to skip calculations when a larger area is close to a flat color", Be::READWRITE ) - + EXPOSURE_CHAINTO( Tr2PPEffect ) } - diff --git a/trinity/PostProcess/Effects/Tr2PPTonemappingEffect.cpp b/trinity/PostProcess/Effects/Tr2PPTonemappingEffect.cpp index b9cd1c530..f688799da 100644 --- a/trinity/PostProcess/Effects/Tr2PPTonemappingEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPTonemappingEffect.cpp @@ -29,5 +29,4 @@ Tr2PPTonemappingEffect::Tr2PPTonemappingEffect( IRoot* lockobj ) Tr2PPTonemappingEffect::~Tr2PPTonemappingEffect() { - } diff --git a/trinity/PostProcess/Effects/Tr2PPTonemappingEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPTonemappingEffect_Blue.cpp index 1d6c16709..b6374aa0c 100644 --- a/trinity/PostProcess/Effects/Tr2PPTonemappingEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPTonemappingEffect_Blue.cpp @@ -19,15 +19,29 @@ const Be::ClassInfo* Tr2PPTonemappingEffect::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "method", m_method, "Which tonemapper should be used?", Be::READWRITE | Be::PERSIST | Be::ENUM, TonemappingEffectMethodChooser ); - MAP_ATTRIBUTE( "slope", m_aces.m_slope, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 3.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "toe", m_aces.m_toe, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 1.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "shoulder", m_aces.m_shoulder, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 1.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blackClip", m_aces.m_blackClip, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 1.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "whiteClip", m_aces.m_whiteClip, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 1.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "scale", m_aces.m_scale, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 3.0)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "blueCorrection", m_aces.m_blueCorrection, ":jessica-group: Aces (new) \n" ":jessica-numeric-range: (0.0, 1.0)", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "slope", m_aces.m_slope, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 3.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "toe", m_aces.m_toe, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 1.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "shoulder", m_aces.m_shoulder, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 1.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blackClip", m_aces.m_blackClip, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 1.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "whiteClip", m_aces.m_whiteClip, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 1.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scale", m_aces.m_scale, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 3.0)", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "blueCorrection", m_aces.m_blueCorrection, ":jessica-group: Aces (new) \n" + ":jessica-numeric-range: (0.0, 1.0)", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "useSweeteners", m_aces.m_useSweeteners, ":jessica-group: Aces (new) \n", Be::READWRITE | Be::PERSIST ) - + MAP_ATTRIBUTE( "shoulderStrength", m_uncharted2.m_shoulderStrength, ":jessica-group: Uncharted 2 (old) \n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "linearStrength", m_uncharted2.m_linearStrength, ":jessica-group: Uncharted 2 (old) \n", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "linearAngle", m_uncharted2.m_linearAngle, ":jessica-group: Uncharted 2 (old) \n", Be::READWRITE | Be::PERSIST ) diff --git a/trinity/PostProcess/Effects/Tr2PPVignetteEffect.cpp b/trinity/PostProcess/Effects/Tr2PPVignetteEffect.cpp index c085cb4af..c08f4f8c2 100644 --- a/trinity/PostProcess/Effects/Tr2PPVignetteEffect.cpp +++ b/trinity/PostProcess/Effects/Tr2PPVignetteEffect.cpp @@ -18,14 +18,13 @@ Tr2PPVignetteEffect::Tr2PPVignetteEffect( IRoot* lockobj ) : m_sineMinimum( 0.0f ), m_sineMaximum( 1.0f ) { - } Tr2PPVignetteEffect::~Tr2PPVignetteEffect() { - } -bool Tr2PPVignetteEffect::IsActive() { +bool Tr2PPVignetteEffect::IsActive() +{ return m_display && m_intensity > 0.0f && m_opacity > 0.0f; } diff --git a/trinity/PostProcess/Effects/Tr2PPVignetteEffect.h b/trinity/PostProcess/Effects/Tr2PPVignetteEffect.h index 447cf7ed5..11d033698 100644 --- a/trinity/PostProcess/Effects/Tr2PPVignetteEffect.h +++ b/trinity/PostProcess/Effects/Tr2PPVignetteEffect.h @@ -30,7 +30,6 @@ BLUE_CLASS( Tr2PPVignetteEffect ) : float m_sineFrequency; float m_sineMinimum; float m_sineMaximum; - }; TYPEDEF_BLUECLASS( Tr2PPVignetteEffect ); diff --git a/trinity/PostProcess/Effects/Tr2PPVignetteEffect_Blue.cpp b/trinity/PostProcess/Effects/Tr2PPVignetteEffect_Blue.cpp index 705b40055..535aa4998 100644 --- a/trinity/PostProcess/Effects/Tr2PPVignetteEffect_Blue.cpp +++ b/trinity/PostProcess/Effects/Tr2PPVignetteEffect_Blue.cpp @@ -23,18 +23,5 @@ const Be::ClassInfo* Tr2PPVignetteEffect::ExposeToBlue() MAP_ATTRIBUTE( "sineMinimum", m_sineMinimum, "sine wave minimum value", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "sineMaximum", m_sineMaximum, "sine wave maximum value", Be::READWRITE | Be::PERSIST ) - EXPOSURE_CHAINTO( Tr2PPEffect ) + EXPOSURE_CHAINTO( Tr2PPEffect ) } - - - - - - - - - - - - - diff --git a/trinity/PostProcess/Tr2PostProcess2.cpp b/trinity/PostProcess/Tr2PostProcess2.cpp index 945a18602..b4a205cfa 100644 --- a/trinity/PostProcess/Tr2PostProcess2.cpp +++ b/trinity/PostProcess/Tr2PostProcess2.cpp @@ -6,11 +6,11 @@ extern int g_dynamicExposureQualityRequirement; -#define RETURN_IF_ACTIVE( effect, currentQuality, minQuality ) \ +#define RETURN_IF_ACTIVE( effect, currentQuality, minQuality ) \ if( effect && effect->IsActive() && currentQuality >= minQuality ) \ - { \ - return effect; \ - } \ + { \ + return effect; \ + } \ return nullptr; Tr2PostProcess2::Tr2PostProcess2( IRoot* lockobj ) : diff --git a/trinity/PostProcess/Tr2PostProcess2.h b/trinity/PostProcess/Tr2PostProcess2.h index 4dc73d354..06a76932c 100644 --- a/trinity/PostProcess/Tr2PostProcess2.h +++ b/trinity/PostProcess/Tr2PostProcess2.h @@ -62,25 +62,25 @@ BLUE_CLASS( Tr2PostProcess2 ) : Tr2PPTonemappingEffectPtr GetTonemappingIfAvailable( PostProcess::Quality qualitySetting = PostProcess::Quality::HIGH ) const; Tr2PPColorCorrectionEffectPtr GetColorCorrectionIfAvailable( PostProcess::Quality qualitySetting = PostProcess::Quality::HIGH ) const; Tr2PPGenericEffectPtr GetGenericEffectIfAvailable( PostProcess::Quality qualitySetting = PostProcess::Quality::HIGH ) const; - + void GetAvilableSortedLuts( std::vector & container, PostProcess::Quality qualitySetting = PostProcess::Quality::HIGH ) const; void ClearLuts(); - void SetSignalLoss(Tr2PPSignalLossEffectPtr effect); - void SetGodRays(Tr2PPGodRaysEffectPtr effect); - void SetBloom(Tr2PPBloomEffectPtr effect); - void SetDynamicExposure(Tr2PPDynamicExposureEffectPtr effect); - void SetFilmGrain(Tr2PPFilmGrainEffectPtr effect); - void SetDesaturate(Tr2PPDesaturateEffectPtr effect); - void SetFade(Tr2PPFadeEffectPtr effect); - void AddLut(Tr2PPLutEffectPtr effect); - void SetVignette(Tr2PPVignetteEffectPtr effect); - void SetFog(Tr2PPFogEffectPtr effect); - void SetTaa(Tr2PPTaaEffectPtr effect); - void SetDepthOfField(Tr2PPDepthOfFieldEffectPtr effect); - void SetTonemapping(Tr2PPTonemappingEffectPtr effect); - void SetColorCorrection(Tr2PPColorCorrectionEffectPtr effect); - void SetGenericEffect(Tr2PPGenericEffectPtr effect); + void SetSignalLoss( Tr2PPSignalLossEffectPtr effect ); + void SetGodRays( Tr2PPGodRaysEffectPtr effect ); + void SetBloom( Tr2PPBloomEffectPtr effect ); + void SetDynamicExposure( Tr2PPDynamicExposureEffectPtr effect ); + void SetFilmGrain( Tr2PPFilmGrainEffectPtr effect ); + void SetDesaturate( Tr2PPDesaturateEffectPtr effect ); + void SetFade( Tr2PPFadeEffectPtr effect ); + void AddLut( Tr2PPLutEffectPtr effect ); + void SetVignette( Tr2PPVignetteEffectPtr effect ); + void SetFog( Tr2PPFogEffectPtr effect ); + void SetTaa( Tr2PPTaaEffectPtr effect ); + void SetDepthOfField( Tr2PPDepthOfFieldEffectPtr effect ); + void SetTonemapping( Tr2PPTonemappingEffectPtr effect ); + void SetColorCorrection( Tr2PPColorCorrectionEffectPtr effect ); + void SetGenericEffect( Tr2PPGenericEffectPtr effect ); // Helper method for scenes to decide on miplodbias float GetMipLodBias() const; @@ -109,8 +109,3 @@ BLUE_CLASS( Tr2PostProcess2 ) : TYPEDEF_BLUECLASS( Tr2PostProcess2 ); #endif // Tr2PostProcess_H - - - - - diff --git a/trinity/PostProcess/Tr2PostProcess2_Blue.cpp b/trinity/PostProcess/Tr2PostProcess2_Blue.cpp index 19118f8c2..63b0703f4 100644 --- a/trinity/PostProcess/Tr2PostProcess2_Blue.cpp +++ b/trinity/PostProcess/Tr2PostProcess2_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2PostProcess2 ); const Be::ClassInfo* Tr2PostProcess2::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2PostProcess2, "" ) + EXPOSURE_BEGIN( Tr2PostProcess2, "" ) MAP_INTERFACE( Tr2PostProcess2 ) @@ -28,5 +28,5 @@ const Be::ClassInfo* Tr2PostProcess2::ExposeToBlue() MAP_ATTRIBUTE( "colorCorrection", m_colorCorrection, "Accesses the color correction effect", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "genericEffect", m_generic, "Accesses the generic effect", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/PostProcess/Tr2PostProcessAttributes.cpp b/trinity/PostProcess/Tr2PostProcessAttributes.cpp index ec86ac39c..7d28aa3e2 100644 --- a/trinity/PostProcess/Tr2PostProcessAttributes.cpp +++ b/trinity/PostProcess/Tr2PostProcessAttributes.cpp @@ -10,7 +10,7 @@ using namespace PriorityBlend; Tr2PostProcessAttributes::Tr2PostProcessAttributes( IRoot* lockobj ) : - intensity(0.0f), + intensity( 0.0f ), priority( PostProcessEnums::Priority::MEDIUM_PRIORITY ), signalLossIntensity( Attribute( 0.0f ) ), bloomBrightness( Attribute( 0.0f ) ), @@ -38,7 +38,7 @@ Tr2PostProcessAttributes::Tr2PostProcessAttributes( IRoot* lockobj ) : vignetteDetail1Size( Attribute( Vector2( 16.0, 16.0 ) ) ), vignetteDetail1Scroll( Attribute( Vector2( 0, 0 ) ) ), vignetteDetail2Size( Attribute( Vector2( 16.0, 16.0 ) ) ), - vignetteDetail2Scroll( Attribute(Vector2( 0, 0 ) ) ), + vignetteDetail2Scroll( Attribute( Vector2( 0, 0 ) ) ), vignetteShapePath( Attribute( BlueSharedString( "" ) ) ), vignetteDetailPath( Attribute( BlueSharedString( "" ) ) ), vignetteSineFrequency( Attribute( 0.0f ) ), @@ -76,7 +76,7 @@ const char* GetAttributeName( T Tr2PostProcessAttributes::* attribute ) template ::Type> -typename Accumulator::ResultType Accumulate( PriorityBlend::Attribute Tr2PostProcessAttributes::*attr, const std::vector& sources, AttributesDebugObserver* observer, Accumulator accumulator = {} ) +typename Accumulator::ResultType Accumulate( PriorityBlend::Attribute Tr2PostProcessAttributes::* attr, const std::vector& sources, AttributesDebugObserver* observer, Accumulator accumulator = {} ) { return PriorityBlend::Accumulate( attr, sources, observer, GetAttributeName( attr ), accumulator ); } @@ -348,7 +348,7 @@ void Tr2PostProcessAttributes::Reset() depthOfFieldFocalLength = Attribute( 0.0f ); depthOfFieldShape = Attribute( Tr2Bokeh::Disk ); - // We enable all color correction options because otherwise it would interpolate from zero to whatever the + // We enable all color correction options because otherwise it would interpolate from zero to whatever the // postprocess volume has set, giving us weird results when entering the volume. whiteTemperature = Attribute( 6500.0f, true ); whiteTint = Attribute( 0.0f, true ); @@ -376,7 +376,7 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po { signalLossIntensity = Attribute( signalLoss->m_strength, true ); } - + if( auto bloom = postProcess->GetBloomIfAvailable() ) { bloomBrightness = Attribute( bloom->m_bloomBrightness, true ); @@ -384,7 +384,7 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po bloomLuminanceThreshold = Attribute( bloom->m_luminanceThreshold, true ); grimeIntensity = Attribute( bloom->m_grimeWeight, true ); grimePath = Attribute( bloom->m_grimePath, true ); - + bloomSizeScale = Attribute( bloom->m_sizeScale, true ); bloomDirectionalWeight = Attribute( bloom->m_directionalWeight, true ); bloomStepSize1 = Attribute( bloom->m_stepSizes[0], true ); @@ -409,7 +409,7 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po filmGrainBrightnessModifier = Attribute( filmGrain->m_brightnessModifier, true ); filmGrainColored = Attribute( filmGrain->m_colored, true ); filmGrainColorAmount = Attribute( filmGrain->m_colorAmount, true ); -} + } if( auto desaturate = postProcess->GetDesaturateIfAvailable() ) { // negative is desaturation, positive is saturation, so move the zero point to 0.0 from 1.0 @@ -419,7 +419,6 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po { fadeIntensity = Attribute( fade->m_intensity, true ); fadeColor = Attribute( fade->m_color, true ); - } if( auto vignette = postProcess->GetVignetteIfAvailable() ) { @@ -435,7 +434,6 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po vignetteSineFrequency = Attribute( vignette->m_sineFrequency, true ); vignetteMinSineFrequency = Attribute( vignette->m_sineMinimum, true ); vignetteMaxSineFrequency = Attribute( vignette->m_sineMaximum, true ); - } if( auto depthOfField = postProcess->GetDepthOfFieldIfAvailable() ) { @@ -443,7 +441,6 @@ void Tr2PostProcessAttributes::FromPostProcess( Tr2PostProcess2* postProcess, Po depthOfFieldFocalDistance = Attribute( depthOfField->m_focalDistance, true ); depthOfFieldFocalLength = Attribute( depthOfField->m_focalLength, true ); depthOfFieldShape = Attribute( depthOfField->m_bokehShape, true ); - } auto luts = std::vector(); diff --git a/trinity/PostProcess/Tr2PostProcessAttributes.h b/trinity/PostProcess/Tr2PostProcessAttributes.h index 953a3b947..09a5a5096 100644 --- a/trinity/PostProcess/Tr2PostProcessAttributes.h +++ b/trinity/PostProcess/Tr2PostProcessAttributes.h @@ -18,11 +18,11 @@ BLUE_CLASS( Tr2PostProcessAttributes ) : Tr2PostProcessAttributes( IRoot* lockobj = NULL ); ~Tr2PostProcessAttributes(); - + void Reset(); - void FromPostProcess( Tr2PostProcess2* postprocess, PostProcessEnums::Priority priority, float intensity ); - + void FromPostProcess( Tr2PostProcess2 * postprocess, PostProcessEnums::Priority priority, float intensity ); + static void MergeInto( Tr2PostProcess2 & postprocess, std::vector & attributes, PriorityBlend::AttributesDebugObserver* debugObserver = nullptr ); // public attributes, so we can access them from the outside @@ -72,7 +72,7 @@ BLUE_CLASS( Tr2PostProcessAttributes ) : PriorityBlend::Attribute lutIntensity; PriorityBlend::Attribute lutPath; - + // a container for the accumulation of luts std::set> prioritizedLuts; diff --git a/trinity/PostProcess/Tr2PostProcessAttributes_Blue.cpp b/trinity/PostProcess/Tr2PostProcessAttributes_Blue.cpp index 8f8759d2c..51ede9e65 100644 --- a/trinity/PostProcess/Tr2PostProcessAttributes_Blue.cpp +++ b/trinity/PostProcess/Tr2PostProcessAttributes_Blue.cpp @@ -6,28 +6,28 @@ namespace PostProcessEnums { - Be::VarChooser Tr2PostProcessPriorityChooser[] = { - - { "UI", - BeCast( Priority::UI_PRIORITY ), - "UI (Top) Priority" }, - { "High", - BeCast( Priority::HIGH_PRIORITY ), - "High Priority" }, - { "Medium", - BeCast( Priority::MEDIUM_PRIORITY ), - "Medium Priority" }, - { "Low", - BeCast( Priority::LOW_PRIORITY ), - "Low Priority" }, - { "SceneDefault", - BeCast( Priority::SCENE_DEFAULT_PRIORITY ), - "Scene Default (lowest) Priority" }, - { 0 } - }; - BLUE_REGISTER_ENUM_EX( "Tr2PostProcessPriority", Priority, Tr2PostProcessPriorityChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +Be::VarChooser Tr2PostProcessPriorityChooser[] = { + + { "UI", + BeCast( Priority::UI_PRIORITY ), + "UI (Top) Priority" }, + { "High", + BeCast( Priority::HIGH_PRIORITY ), + "High Priority" }, + { "Medium", + BeCast( Priority::MEDIUM_PRIORITY ), + "Medium Priority" }, + { "Low", + BeCast( Priority::LOW_PRIORITY ), + "Low Priority" }, + { "SceneDefault", + BeCast( Priority::SCENE_DEFAULT_PRIORITY ), + "Scene Default (lowest) Priority" }, + { 0 } +}; +BLUE_REGISTER_ENUM_EX( "Tr2PostProcessPriority", Priority, Tr2PostProcessPriorityChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); } - + BLUE_DEFINE( Tr2PostProcessAttributes ); @@ -38,11 +38,11 @@ const Be::ClassInfo* Tr2PostProcessAttributes::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "priority", priority, "", Be::READWRITE | Be::PERSIST | Be::ENUM, PostProcessEnums::Tr2PostProcessPriorityChooser ) MAP_ATTRIBUTE( "intensity", intensity, "", Be::READ ) -#define POSTPROCESSATTRIBUTE_DEFINE( NAME, GROUP, DESC ) \ +#define POSTPROCESSATTRIBUTE_DEFINE( NAME, GROUP, DESC ) \ MAP_ATTRIBUTE( #NAME "Enabled", NAME.enabled, "Enables " #NAME " in the postprocess \n:jessica-group: " #GROUP, Be::READWRITE | Be::PERSIST ) \ MAP_ATTRIBUTE( #NAME, NAME.value, "The maximum value of " #NAME " in the postprocess " DESC "\n:jessica-group: " #GROUP, Be::READWRITE | Be::PERSIST ) -#define POSTPROCESSATTRIBUTE_DEFINE_ENUM( NAME, GROUP, DESC, CHOOSER ) \ +#define POSTPROCESSATTRIBUTE_DEFINE_ENUM( NAME, GROUP, DESC, CHOOSER ) \ MAP_ATTRIBUTE( #NAME "Enabled", NAME.enabled, "Enables " #NAME " in the postprocess \n:jessica-group: " #GROUP, Be::READWRITE | Be::PERSIST | Be::PERSIST ) \ MAP_ATTRIBUTE_WITH_CHOOSER( #NAME, NAME.value, DESC "\n:jessica-group: " #GROUP, Be::READWRITE | Be::PERSIST | Be::ENUM, CHOOSER ) diff --git a/trinity/PostProcess/Tr2PostProcessEnums.h b/trinity/PostProcess/Tr2PostProcessEnums.h index d08c9c38d..dab504678 100644 --- a/trinity/PostProcess/Tr2PostProcessEnums.h +++ b/trinity/PostProcess/Tr2PostProcessEnums.h @@ -5,64 +5,65 @@ namespace PostProcessEnums { - enum AttributeType - { - SIGNAL_LOSS_INTENSITY, - BLOOM_BRIGHTNESS, - BLOOM_LUMINANCE_THRESHOLD, - BLOOM_LUMINANCE_SCALE, - GRIME_INTENSITY, - GRIME_PATH, - FILM_GRAIN_INTENSITY, - FILM_GRAIN_SIZE, - FILM_GRAIN_DENSITY, - FILM_GRAIN_CONTRAST, - FILM_GRAIN_BRIGHTNESS_MODIFIER, - FILM_GRAIN_COLORED, - FILM_GRAIN_COLOR_AMOUNT, - SATURATION, - FADE_INTENSITY, - FADE_COLOR, - LUT_INTENSITY, - LUT_PATH, - VIGNETTE_INTENSITY, - VIGNETTE_OPACITY, - VIGNETTE_COLOR, - VIGNETTE_DETAIL1_SIZE, - VIGNETTE_DETAIL1_SCROLL, - VIGNETTE_DETAIL2_SIZE, - VIGNETTE_DETAIL2_SCROLL, - VIGNETTE_SHAPE_PATH, - VIGNETTE_DETAIL_PATH, - VIGNETTE_SINE_FREQUENCY, - VIGNETTE_MIN_SINE_FREQUENCY, - VIGNETTE_MAX_SINE_FREQUENCY, - DEPTH_OF_FIELD_SCALE, - DEPTH_OF_FIELD_FOCAL_DISTANCE, - DEPTH_OF_FIELD_FOCAL_LENGTH, - DEPTH_OF_FIELD_SHAPE, +enum AttributeType +{ + SIGNAL_LOSS_INTENSITY, + BLOOM_BRIGHTNESS, + BLOOM_LUMINANCE_THRESHOLD, + BLOOM_LUMINANCE_SCALE, + GRIME_INTENSITY, + GRIME_PATH, + FILM_GRAIN_INTENSITY, + FILM_GRAIN_SIZE, + FILM_GRAIN_DENSITY, + FILM_GRAIN_CONTRAST, + FILM_GRAIN_BRIGHTNESS_MODIFIER, + FILM_GRAIN_COLORED, + FILM_GRAIN_COLOR_AMOUNT, + SATURATION, + FADE_INTENSITY, + FADE_COLOR, + LUT_INTENSITY, + LUT_PATH, + VIGNETTE_INTENSITY, + VIGNETTE_OPACITY, + VIGNETTE_COLOR, + VIGNETTE_DETAIL1_SIZE, + VIGNETTE_DETAIL1_SCROLL, + VIGNETTE_DETAIL2_SIZE, + VIGNETTE_DETAIL2_SCROLL, + VIGNETTE_SHAPE_PATH, + VIGNETTE_DETAIL_PATH, + VIGNETTE_SINE_FREQUENCY, + VIGNETTE_MIN_SINE_FREQUENCY, + VIGNETTE_MAX_SINE_FREQUENCY, + DEPTH_OF_FIELD_SCALE, + DEPTH_OF_FIELD_FOCAL_DISTANCE, + DEPTH_OF_FIELD_FOCAL_LENGTH, + DEPTH_OF_FIELD_SHAPE, - WHITE_TEMPERATURE, - WHITE_TINT, - COLOR_SATURATION, - COLOR_CONTRAST, - COLOR_GAMMA, - COLOR_GAIN, - COLOR_OFFSET, + WHITE_TEMPERATURE, + WHITE_TINT, + COLOR_SATURATION, + COLOR_CONTRAST, + COLOR_GAMMA, + COLOR_GAIN, + COLOR_OFFSET, - POST_PROCESS_ATTRIBUTE_TYPE_COUNT - }; + POST_PROCESS_ATTRIBUTE_TYPE_COUNT +}; - extern Be::VarChooser Tr2PostProcessAttributeTypeChooser[]; +extern Be::VarChooser Tr2PostProcessAttributeTypeChooser[]; - enum Priority{ - SCENE_DEFAULT_PRIORITY, - LOW_PRIORITY, - MEDIUM_PRIORITY, - HIGH_PRIORITY, - UI_PRIORITY, - PRIORITY_COUNT - }; - extern Be::VarChooser Tr2PostProcessPriorityChooser[]; +enum Priority +{ + SCENE_DEFAULT_PRIORITY, + LOW_PRIORITY, + MEDIUM_PRIORITY, + HIGH_PRIORITY, + UI_PRIORITY, + PRIORITY_COUNT +}; +extern Be::VarChooser Tr2PostProcessPriorityChooser[]; }; \ No newline at end of file diff --git a/trinity/PostProcess/Tr2PostProcessRenderer.cpp b/trinity/PostProcess/Tr2PostProcessRenderer.cpp index 772360e35..18f2f1a9c 100644 --- a/trinity/PostProcess/Tr2PostProcessRenderer.cpp +++ b/trinity/PostProcess/Tr2PostProcessRenderer.cpp @@ -277,13 +277,13 @@ GaussianData CalculateGaussianPassParameters( float radius, float centerWeight, GaussianData data; data.overallWeight = overallWeight; data.count = (uint32_t)taps.size() / 2; - - std::fill( std::begin( data.weightOffset ), std::end( data.weightOffset ), Vector4(0,0,0,0) ); + + std::fill( std::begin( data.weightOffset ), std::end( data.weightOffset ), Vector4( 0, 0, 0, 0 ) ); uint32_t index = 0; // Fill in the data - for( uint32_t i = 0; i < taps.size(); i+=2 ) + for( uint32_t i = 0; i < taps.size(); i += 2 ) { // pack 2 weight and offset into a vector4 float weight1 = taps[i].first / weightSum; @@ -291,14 +291,14 @@ GaussianData CalculateGaussianPassParameters( float radius, float centerWeight, float weight2 = taps[i + 1].first / weightSum; float offset2 = taps[i + 1].second; - data.weightOffset[index++] = Vector4(weight1, offset1, weight2, offset2); + data.weightOffset[index++] = Vector4( weight1, offset1, weight2, offset2 ); } return data; } } -namespace Tonemapping +namespace Tonemapping { void ApplyColorCorrection( const Tr2PPColorCorrectionEffect* colorCorrection, Tr2Effect* tonemappingEffect ) @@ -510,10 +510,10 @@ void ApplyNoTonemappingMethod( Tr2Effect* tonemappingEffect ) namespace AMDSharpening { - Vector4 AsVector( uintfloat4 v ) - { - return Vector4( v.f[0], v.f[1], v.f[2], v.f[3] ); - } +Vector4 AsVector( uintfloat4 v ) +{ + return Vector4( v.f[0], v.f[1], v.f[2], v.f[3] ); +} } Tr2PostProcessRenderer::Tr2PostProcessRenderer( IRoot* lockobj ) : @@ -564,7 +564,7 @@ Tr2PostProcessRenderer::Tr2PostProcessRenderer( IRoot* lockobj ) : m_bloomConstantBuffer = Tr2ConstantBufferAL(); - // dynamic exposure shaders + // dynamic exposure shaders m_dynamicExposureToTextureShader.CreateInstance(); m_dynamicExposureToTextureShader->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/PostProcess/ExposureToTexture.fx" ); @@ -591,7 +591,7 @@ Tr2PostProcessRenderer::Tr2PostProcessRenderer( IRoot* lockobj ) : m_fogCompositeEffect.CreateInstance(); m_fogCompositeEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/PostProcess/EnvironmentFogComposit.fx" ); - + // depth of field shaders m_depthOfFieldBokehBlurShader.CreateInstance(); m_depthOfFieldBokehBlurShader->StartUpdate(); @@ -618,7 +618,7 @@ Tr2PostProcessRenderer::Tr2PostProcessRenderer( IRoot* lockobj ) : // signal loss shader m_signalLossEffect.CreateInstance(); m_signalLossEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/PostProcess/SignalLoss.fx" ); - + // film grain shader m_grainShader.CreateInstance(); m_grainShader->StartUpdate(); @@ -640,20 +640,20 @@ PostProcess::Quality Tr2PostProcessRenderer::GetPostProcessingQuality() const } void Tr2PostProcessRenderer::SetPostProcessingQuality( PostProcess::Quality quality ) -{ +{ m_quality = quality; } -void Tr2PostProcessRenderer::Execute( - const Tr2TextureAL& destination, - Tr2GpuResourcePool::Texture sourceBuffer, - Tr2GpuResourcePool::Texture depthMap, - Tr2GpuResourcePool::Texture velocity, - Tr2GpuResourcePool::Texture opaqueColor, +void Tr2PostProcessRenderer::Execute( + const Tr2TextureAL& destination, + Tr2GpuResourcePool::Texture sourceBuffer, + Tr2GpuResourcePool::Texture depthMap, + Tr2GpuResourcePool::Texture velocity, + Tr2GpuResourcePool::Texture opaqueColor, EveSpaceScene* scene, - Tr2UpscalingContextAL* upscalingContext, - Tr2GpuResourcePool& gpuResourcePool, + Tr2UpscalingContextAL* upscalingContext, + Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -674,7 +674,7 @@ void Tr2PostProcessRenderer::Execute( renderContext.m_esm.PushRenderTarget(); renderContext.m_esm.PushDepthStencilBuffer( Tr2TextureAL() ); - + const auto upscalingInfo = renderContext.GetPrimaryRenderContext().GetUpscalingInfo( upscalingContext ? upscalingContext->GetID() : Tr2UpscalingAL::INVALID_CONTEXT_ID ); auto upscalingEnabled = upscalingInfo.technique != Tr2UpscalingAL::NONE; @@ -695,7 +695,7 @@ void Tr2PostProcessRenderer::Execute( // Always copy auto nonMsaaSource = gpuResourcePool.GetTempTexture( "Pre-upscaling Composite", renderSize, sourceBuffer->GetFormat(), RENDER_TARGET ); sourceBuffer->Resolve( nonMsaaSource, renderContext ); - + Tr2PPDynamicExposureEffect* dynamicExposure = nullptr; Tr2GpuResourcePool::Buffer histogramBuffer; @@ -712,7 +712,7 @@ void Tr2PostProcessRenderer::Execute( } sourceBuffer = {}; - if( auto godrays = postProcess->GetGodRaysIfAvailable (m_quality ) ) + if( auto godrays = postProcess->GetGodRaysIfAvailable( m_quality ) ) { RenderGodRays( nonMsaaSource, depthMap, gpuResourcePool, renderContext, godrays ); } @@ -729,7 +729,7 @@ void Tr2PostProcessRenderer::Execute( if( taa != nullptr && !upscalingInfo.temporal ) { RenderTaa( nonMsaaSource, velocity, opaqueColor, gpuResourcePool, renderContext, taa, dynamicExposure ); - if ( !upscalingContext ) + if( !upscalingContext ) { velocity = {}; opaqueColor = {}; @@ -743,7 +743,7 @@ void Tr2PostProcessRenderer::Execute( if( dynamicExposure ) { histogramBuffer = RenderDynamicExposure( nonMsaaSource, gpuResourcePool, renderContext, dynamicExposure ); - if ( !dynamicExposure->m_debug ) + if( !dynamicExposure->m_debug ) { histogramBuffer = {}; } @@ -768,7 +768,7 @@ void Tr2PostProcessRenderer::Execute( else { upscaledSource = nonMsaaSource; - if ( !upscalingContext ) + if( !upscalingContext ) { depthMap = {}; velocity = {}; @@ -804,12 +804,12 @@ void Tr2PostProcessRenderer::Execute( auto tonemappedOutput = gpuResourcePool.GetTempTexture( "Tonemapping Result", renderSize, destination.GetFormat(), RENDER_TARGET ); RenderTonemapping( tonemappedOutput, postProcess, renderContext ); - + output = RenderUpscaling( tonemappedOutput, depthMap, velocity, opaqueColor, scene->GetReprojectionMatrix(), gpuResourcePool, renderContext, upscalingContext, dynamicExposure ); depthMap = {}; velocity = {}; opaqueColor = {}; - + // need to reset the perframedata so we have the correct viewport size etc scene->ApplyUpscalingToPerFrameData( displaySize.width, displaySize.height, renderContext ); } @@ -853,7 +853,7 @@ void Tr2PostProcessRenderer::SetupExposureConversion( bool enable, float middleV if( enable ) { m_dynamicExposureToTextureShader->SetParameter( MEMOIZED_STRING( "ExposureMiddleValue" ), middleValue ); - } + } } Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderSharpening( bool enable, Tr2GpuResourcePool::Texture& input, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) @@ -1008,7 +1008,7 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP name = "Upsample_Horizontal_" + std::to_string( i ); upsampleHorizontalTexture[i] = gpuResourcePool.GetTempTexture( name.c_str(), size, dest->GetFormat(), RENDER_TARGET ); } - + currentSize *= 0.5f; ++depth; } @@ -1027,18 +1027,17 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP TEMP_PARAM( effect, "BlitCurrent", lastRt ); TEMP_PARAM( effect, "Exposure", GetExposureBuffer( gpuResourcePool ) ); - auto downsampleInfo = DownsampleData - { + auto downsampleInfo = DownsampleData{ invTexelSize }; FillAndSetConstants( m_bloomConstantBuffer, &downsampleInfo, sizeof( downsampleInfo ), Tr2RenderContextEnum::PIXEL_SHADER, Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); - + DrawInto( rt, Tr2LoadAction::DONT_CARE, effect, renderContext ); lastRt = rt; } } - + { // do a two pass downsampling with gaussian blur on the downsampled texture // then the last upsampled texture will be added on top @@ -1047,14 +1046,14 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP float tintScale = ( 1.0f / Bloom::MAX_BLOOM_STEPS ) * bloom->m_bloomBrightness; - Vector2 directionalWeight = Vector2( std::max( bloom->m_directionalWeight, 0.0f ), std::fabsf(bloom->m_directionalWeight) ); + Vector2 directionalWeight = Vector2( std::max( bloom->m_directionalWeight, 0.0f ), std::fabsf( bloom->m_directionalWeight ) ); for( int i = depth - 1; i >= 0; --i ) { lastRt = i == depth - 1 ? black : lastRt; auto currentMip = downsampleTexture[i]; auto currentUpsampled = upsampleTexture[i]; - + if( m_bloomDebugMode != BloomDebugMode::BLOOM_DEBUG_NONE ) { currentUpsampled = upsampleHorizontalTexture[i]; @@ -1087,7 +1086,7 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP float radiusInPixels = std::max( (float)currentMip->GetWidth(), (float)currentMip->GetHeight() ) * bloom->m_sizeScale * bloom->m_stepSizes[i] * 0.01f; auto invTexelSize = Vector2( 1.0f / (float)currentMip->GetWidth(), 1.0f / (float)currentMip->GetHeight() ); - + std::string name = "Vertical Step " + std::to_string( i ); GPU_REGION( renderContext, name.c_str() ); @@ -1100,7 +1099,7 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP FillAndSetConstants( m_bloomConstantBuffer, &gaussianOutput, sizeof( gaussianOutput ), Tr2RenderContextEnum::PIXEL_SHADER, Tr2Renderer::GetPerObjectPSStartRegister(), renderContext ); // draw into the downsample texture, because they will not be used again DrawInto( currentMip, Tr2LoadAction::DONT_CARE, m_upsamplerVertical, renderContext ); - + lastRt = currentMip; } } @@ -1109,17 +1108,17 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourceP { return RenderBloomDebug( downsampleTexture, upsampleTexture, dest, gpuResourcePool, renderContext ); } - + return lastRt; } -Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloomDebug( - std::array& downsample, +Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloomDebug( + std::array& downsample, std::array& upsample, Tr2GpuResourcePool::Texture& blitCurrent, - Tr2GpuResourcePool& gpuResourcePool, + Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) -{ +{ if( m_bloomDebugShader == nullptr ) { m_bloomDebugShader.CreateInstance(); @@ -1175,7 +1174,7 @@ void Tr2PostProcessRenderer::RenderSignalLoss( const Tr2TextureAL& dest, Tr2Rend { GPU_REGION( renderContext, "Signal Loss" ); m_signalLossEffect->SetParameter( MEMOIZED_STRING( "NoiseStrength" ), signalLoss->m_strength ); - + Tr2Renderer::DrawTexture( renderContext, m_signalLossEffect, dest, Vector2( 0, 0 ), Vector2( 1, 1 ) ); } @@ -1189,9 +1188,9 @@ Tr2GpuResourcePool::Buffer Tr2PostProcessRenderer::RenderDynamicExposure( const uint32_t localHistogramCount = tilesX * tilesY * 16; - auto localHistograms = gpuResourcePool.GetTempBuffer( - "LocalHistograms", - Tr2BufferDescriptionAL( Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_UINT, localHistogramCount, Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::UNORDERED_ACCESS, Tr2CpuUsage::NONE ) ); + auto localHistograms = gpuResourcePool.GetTempBuffer( + "LocalHistograms", + Tr2BufferDescriptionAL( Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_UINT, localHistogramCount, Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::UNORDERED_ACCESS, Tr2CpuUsage::NONE ) ); auto histogram = gpuResourcePool.GetTempBuffer( @@ -1285,19 +1284,19 @@ void Tr2PostProcessRenderer::RenderDynamicExposureDebug( Tr2GpuResourcePool& gpu } } -Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderUpscaling( - const Tr2TextureAL& source, - const Tr2TextureAL& depth, - const Tr2TextureAL& velocity, - const Tr2TextureAL& opaqueColor, +Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderUpscaling( + const Tr2TextureAL& source, + const Tr2TextureAL& depth, + const Tr2TextureAL& velocity, + const Tr2TextureAL& opaqueColor, const Matrix& reprojection, - Tr2GpuResourcePool& gpuResourcePool, - Tr2RenderContext& renderContext, - Tr2UpscalingContextAL* upscalingContext, + Tr2GpuResourcePool& gpuResourcePool, + Tr2RenderContext& renderContext, + Tr2UpscalingContextAL* upscalingContext, Tr2PPDynamicExposureEffect* dynamicExposure ) { GPU_REGION( renderContext, "Upscaling" ); - + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN ); uint32_t w, h; upscalingContext->GetDisplayDimensions( w, h ); @@ -1383,7 +1382,7 @@ Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderUpscaling( auto result = upscalingContext->Dispatch( dispatchParameters ); if( result != Tr2UpscalingAL::OK && s_lastUpscalingResult != result ) { - Tr2UpscalingAL::LogResult(result); + Tr2UpscalingAL::LogResult( result ); } s_lastUpscalingResult = result; } @@ -1438,8 +1437,7 @@ void Tr2PostProcessRenderer::RenderTaa( const Tr2TextureAL& dest, const Tr2Textu GPU_REGION( renderContext, "TAA" ); renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN ); - auto Clear = []( const Tr2TextureAL& tex, Tr2RenderContextAL& renderContext ) - { + auto Clear = []( const Tr2TextureAL& tex, Tr2RenderContextAL& renderContext ) { renderContext.SetRenderTarget( tex, 0 ); renderContext.Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0, 1.0f ); }; @@ -1448,12 +1446,12 @@ void Tr2PostProcessRenderer::RenderTaa( const Tr2TextureAL& dest, const Tr2Textu renderContext.ClearUav( tex, 0, zeroes ); }; - auto accumulationBuffer0 = gpuResourcePool.GetPersistentTexture( - "TAA Accumulation 0", - dest.GetWidth(), - dest.GetHeight(), - Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UNORM, - Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE, + auto accumulationBuffer0 = gpuResourcePool.GetPersistentTexture( + "TAA Accumulation 0", + dest.GetWidth(), + dest.GetHeight(), + Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UNORM, + Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE, Clear ); auto accumulationBuffer1 = gpuResourcePool.GetPersistentTexture( "TAA Accumulation 1", @@ -1488,7 +1486,7 @@ void Tr2PostProcessRenderer::RenderTaa( const Tr2TextureAL& dest, const Tr2Textu } - Tr2EffectPtr effects[] = {m_taaEffect, m_taaCopyEffect}; + Tr2EffectPtr effects[] = { m_taaEffect, m_taaCopyEffect }; for( auto& effect : effects ) { if( dynamicExposure ) @@ -1530,10 +1528,10 @@ void Tr2PostProcessRenderer::RenderTaa( const Tr2TextureAL& dest, const Tr2Textu DrawInto( dest, Tr2LoadAction::DONT_CARE, m_taaCopyEffect, renderContext ); } -void Tr2PostProcessRenderer::RenderTonemapping( - const Tr2TextureAL& dest, - Tr2PostProcess2* postprocess, - Tr2RenderContext& renderContext) +void Tr2PostProcessRenderer::RenderTonemapping( + const Tr2TextureAL& dest, + Tr2PostProcess2* postprocess, + Tr2RenderContext& renderContext ) { GPU_REGION( renderContext, "Tonemapping" ); @@ -1545,7 +1543,7 @@ void Tr2PostProcessRenderer::RenderTonemapping( Tonemapping::ApplyVignette( postprocess ? postprocess->GetVignetteIfAvailable( m_quality ) : nullptr, m_tonemappingEffect ); Tonemapping::ApplyDesatureate( postprocess ? postprocess->GetDesaturateIfAvailable( m_quality ) : nullptr, m_tonemappingEffect ); Tonemapping::ApplyFade( postprocess ? postprocess->GetFadeIfAvailable( m_quality ) : nullptr, m_tonemappingEffect ); - + std::vector luts{}; if( postprocess ) { @@ -1603,7 +1601,7 @@ void Tr2PostProcessRenderer::RenderDepthOfField( const Tr2TextureAL& dest, Tr2Gp { renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN ); - + BlueSharedString shape = depthOfField->GetBokehShapeString(); { Tr2GpuResourcePool::Texture coc; @@ -1647,7 +1645,7 @@ void Tr2PostProcessRenderer::RenderDepthOfField( const Tr2TextureAL& dest, Tr2Gp float angle = 0; float samplesPerPixel = 2.0 / 5.0; - if (temporal) + if( temporal ) { //Vary between 4 different rotations, so that it has the same period as the TAA jitter //This allows it to detect some kinds of flickering and remove it. @@ -1702,9 +1700,9 @@ void Tr2PostProcessRenderer::RenderDepthOfField( const Tr2TextureAL& dest, Tr2Gp Tr2GpuResourcePool::Buffer Tr2PostProcessRenderer::GetExposureBuffer( Tr2GpuResourcePool& gpuResourcePool ) const { const float zeroes[8] = {}; - return gpuResourcePool.GetPersistentBuffer( - "Exposure Buffer", - Tr2BufferDescriptionAL( Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT, 8, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ ), + return gpuResourcePool.GetPersistentBuffer( + "Exposure Buffer", + Tr2BufferDescriptionAL( Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT, 8, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ ), zeroes ); } diff --git a/trinity/PostProcess/Tr2PostProcessRenderer.h b/trinity/PostProcess/Tr2PostProcessRenderer.h index d74758026..6c296ade0 100644 --- a/trinity/PostProcess/Tr2PostProcessRenderer.h +++ b/trinity/PostProcess/Tr2PostProcessRenderer.h @@ -14,85 +14,85 @@ BLUE_DECLARE( Tr2Effect ); namespace PostProcessBlur { - // Some blur helpers - enum BlurType - { - BT_Big, - BT_Small - }; +// Some blur helpers +enum BlurType +{ + BT_Big, + BT_Small +}; - enum BlurChannel - { - BC_r, - BC_g, - BC_b, - BC_a, - BC_rgba - }; +enum BlurChannel +{ + BC_r, + BC_g, + BC_b, + BC_a, + BC_rgba +}; - enum BlurProcess - { - BP_None, - BP_Minimum, - BP_Maximum - }; +enum BlurProcess +{ + BP_None, + BP_Minimum, + BP_Maximum +}; - enum BlurFinalize - { - BF_None, - BF_MaxOfAllChannels - }; +enum BlurFinalize +{ + BF_None, + BF_MaxOfAllChannels +}; + +struct BlurContext +{ + BlurType type = BT_Big; + BlurChannel channel = BC_rgba; + BlurProcess process = BP_None; + BlurFinalize finalize = BF_None; - struct BlurContext + uint32_t Hash() const { - BlurType type = BT_Big; - BlurChannel channel = BC_rgba; - BlurProcess process = BP_None; - BlurFinalize finalize = BF_None; - - uint32_t Hash() const - { - return finalize * 1000 + process * 100 + type * 10 + channel; - } - }; + return finalize * 1000 + process * 100 + type * 10 + channel; + } +}; - BlurContext CreateBlurContext( BlurType type = BlurType::BT_Big, BlurChannel channel = BlurChannel::BC_rgba, BlurProcess process = BlurProcess::BP_None, BlurFinalize finalize = BlurFinalize::BF_None ); +BlurContext CreateBlurContext( BlurType type = BlurType::BT_Big, BlurChannel channel = BlurChannel::BC_rgba, BlurProcess process = BlurProcess::BP_None, BlurFinalize finalize = BlurFinalize::BF_None ); - BlueSharedString GetBlurChannelOptionValue( BlurChannel channel ); - BlueSharedString GetBlurTypeOptionValue( BlurType type ); - BlueSharedString GetProcessTypeOptionValue( BlurProcess process); - BlueSharedString GetFinalizeTypeOptionValue( BlurFinalize finalize ); +BlueSharedString GetBlurChannelOptionValue( BlurChannel channel ); +BlueSharedString GetBlurTypeOptionValue( BlurType type ); +BlueSharedString GetProcessTypeOptionValue( BlurProcess process ); +BlueSharedString GetFinalizeTypeOptionValue( BlurFinalize finalize ); } namespace GaussianDistribution { - struct GaussianData - { - Vector3 overallWeight; - uint32_t count; - Vector4 weightOffset[Bloom::MAX_FILTER_STEPS / 2]; - }; +struct GaussianData +{ + Vector3 overallWeight; + uint32_t count; + Vector4 weightOffset[Bloom::MAX_FILTER_STEPS / 2]; +}; - float NormalDistribution( float x, float sigma, float weight ); - GaussianData CalculateGaussianPassParameters( float radius, float centerWeight, float normalizingFactor, Vector3 overallWeight, Vector2 direction ); +float NormalDistribution( float x, float sigma, float weight ); +GaussianData CalculateGaussianPassParameters( float radius, float centerWeight, float normalizingFactor, Vector3 overallWeight, Vector2 direction ); } namespace AMDSharpening { - typedef union - { - uint32_t u[4]; - float f[4]; - } uintfloat4; +typedef union +{ + uint32_t u[4]; + float f[4]; +} uintfloat4; - Vector4 AsVector( uintfloat4 v ); +Vector4 AsVector( uintfloat4 v ); - struct CASConstants - { - uintfloat4 const0 = {}; - uintfloat4 const1 = {}; - }; +struct CASConstants +{ + uintfloat4 const0 = {}; + uintfloat4 const1 = {}; +}; } // ------------------------------------------------------------- @@ -101,7 +101,7 @@ namespace AMDSharpening // SeeAlso: // TriRenderStep // ------------------------------------------------------------- -BLUE_CLASS( Tr2PostProcessRenderer ) : +BLUE_CLASS( Tr2PostProcessRenderer ) : public IRoot { public: @@ -121,22 +121,21 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : BLOOM_DEBUG_STEP6, }; - void Execute( - const Tr2TextureAL& destination, - Tr2GpuResourcePool::Texture source, - Tr2GpuResourcePool::Texture depthMap, - Tr2GpuResourcePool::Texture velocity, - Tr2GpuResourcePool::Texture opaqueColor, + void Execute( + const Tr2TextureAL& destination, + Tr2GpuResourcePool::Texture source, + Tr2GpuResourcePool::Texture depthMap, + Tr2GpuResourcePool::Texture velocity, + Tr2GpuResourcePool::Texture opaqueColor, EveSpaceScene* scene, - Tr2UpscalingContextAL* upscalingContext, - Tr2GpuResourcePool& gpuResourcePool, + Tr2UpscalingContextAL* upscalingContext, + Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); PostProcess::Quality GetPostProcessingQuality() const; void SetPostProcessingQuality( PostProcess::Quality quality ); private: - struct DownsampleData { Vector2 invSourceSize; @@ -144,21 +143,21 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : float _padding2; }; - // exposure texture + // exposure texture void SetupExposureConversion( bool enable, float middleValue ); // optional sharpening Tr2GpuResourcePool::Texture RenderSharpening( bool enable, Tr2GpuResourcePool::Texture& input, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); // bloom - Tr2GpuResourcePool::Texture RenderBloom( Tr2GpuResourcePool::Texture& dest, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPBloomEffect* bloom, Tr2PPDynamicExposureEffect* dynamicExposure ); - Tr2GpuResourcePool::Texture RenderBloomDebug( - std::array& downsample, - std::array& upsample, - Tr2GpuResourcePool::Texture& blitCurrent, - Tr2GpuResourcePool& gpuResourcePool, - Tr2RenderContext& renderContext ); - + Tr2GpuResourcePool::Texture RenderBloom( Tr2GpuResourcePool::Texture & dest, Tr2GpuResourcePool & gpuResourcePool, Tr2RenderContext & renderContext, Tr2PPBloomEffect * bloom, Tr2PPDynamicExposureEffect * dynamicExposure ); + Tr2GpuResourcePool::Texture RenderBloomDebug( + std::array & downsample, + std::array & upsample, + Tr2GpuResourcePool::Texture & blitCurrent, + Tr2GpuResourcePool & gpuResourcePool, + Tr2RenderContext & renderContext ); + Tr2EffectPtr m_downSamplerLuminancePreserve; Tr2EffectPtr m_downSampler; Tr2EffectPtr m_upsamplerHorizontal; @@ -181,7 +180,7 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : // dynamic exposure Tr2GpuResourcePool::Buffer RenderDynamicExposure( const Tr2TextureAL& dest, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPDynamicExposureEffect* dynamicExposure ); - void RenderDynamicExposureDebug( Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPDynamicExposureEffect* dynamicExposure, const Tr2BufferAL& histogramBuffer ); + void RenderDynamicExposureDebug( Tr2GpuResourcePool & gpuResourcePool, Tr2RenderContext & renderContext, Tr2PPDynamicExposureEffect * dynamicExposure, const Tr2BufferAL& histogramBuffer ); Tr2EffectPtr m_dynamicExposureCreateHistogramShader; Tr2EffectPtr m_dynamicExposureMergeHistogramShader; @@ -190,13 +189,13 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : Tr2EffectPtr m_dynamicExposureDebugShader; // depth of field - void RenderDepthOfField( const Tr2TextureAL& dest, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPDepthOfFieldEffect* depthOfField, bool temporal, float upscalingAmount ); + void RenderDepthOfField( const Tr2TextureAL& dest, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPDepthOfFieldEffect* depthOfField, bool temporal, float upscalingAmount ); Tr2EffectPtr m_depthOfFieldCoCShader; Tr2EffectPtr m_depthOfFieldBokehBlurShader; Tr2EffectPtr m_depthOfFieldBokehFillShader; Tr2EffectPtr m_depthOfFieldBokehTAAShader; uint32_t m_bokehFrameCounter; - + // fog void RenderFog( const Tr2TextureAL& dest, const Tr2TextureAL& source, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPFogEffect* fog ); Tr2EffectPtr m_fogColorEffect; @@ -211,15 +210,15 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : void RenderFilmGrain( const Tr2TextureAL& dest, Tr2RenderContext& renderContext, Tr2PPFilmGrainEffect* filmGrain ); Tr2EffectPtr m_grainShader; - Tr2GpuResourcePool::Texture RenderUpscaling( - const Tr2TextureAL& dest, - const Tr2TextureAL& depth, - const Tr2TextureAL& velocity, - const Tr2TextureAL& opaqueColor, + Tr2GpuResourcePool::Texture RenderUpscaling( + const Tr2TextureAL& dest, + const Tr2TextureAL& depth, + const Tr2TextureAL& velocity, + const Tr2TextureAL& opaqueColor, const Matrix& reprojection, - Tr2GpuResourcePool& gpuResourcePool, - Tr2RenderContext& renderContext, - Tr2UpscalingContextAL* upscalingContext, + Tr2GpuResourcePool& gpuResourcePool, + Tr2RenderContext& renderContext, + Tr2UpscalingContextAL* upscalingContext, Tr2PPDynamicExposureEffect* dynamicExposure ); // tonemapping @@ -227,10 +226,10 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : uint8_t m_lutsEnabled; bool m_vignetteEnabled; void RenderTonemapping( - const Tr2TextureAL& dest, + const Tr2TextureAL& dest, Tr2PostProcess2* activePostProcess, - Tr2RenderContext & renderContext ); - + Tr2RenderContext& renderContext ); + void RenderGenericEffect( const Tr2TextureAL& dest, const Tr2TextureAL& src, Tr2RenderContext& renderContext, Tr2PPGenericEffectPtr genericEffect ); // General @@ -242,11 +241,11 @@ BLUE_CLASS( Tr2PostProcessRenderer ) : // transparency mask Tr2EffectPtr m_transparencyMaskEffect; - [[nodiscard]] Tr2GpuResourcePool::Buffer GetExposureBuffer( Tr2GpuResourcePool& gpuResourcePool ) const; + [[nodiscard]] Tr2GpuResourcePool::Buffer GetExposureBuffer( Tr2GpuResourcePool & gpuResourcePool ) const; [[nodiscard]] Tr2GpuResourcePool::Texture GetBlackTexture( Tr2GpuResourcePool & gpuResourcePool ) const; // Common - Tr2GpuResourcePool::Texture Blur( Tr2GpuResourcePool::Texture src, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, const PostProcessBlur::BlurContext& blurContext ); + Tr2GpuResourcePool::Texture Blur( Tr2GpuResourcePool::Texture src, Tr2GpuResourcePool & gpuResourcePool, Tr2RenderContext & renderContext, const PostProcessBlur::BlurContext& blurContext ); Tr2GpuResourcePool::Texture DownSampleDepth( const Tr2TextureAL& depth, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); Tr2EffectPtr m_downsampleDepthEffect; diff --git a/trinity/PostProcess/Tr2PostProcessRenderer_Blue.cpp b/trinity/PostProcess/Tr2PostProcessRenderer_Blue.cpp index 2b7607c5d..4abb07cd1 100644 --- a/trinity/PostProcess/Tr2PostProcessRenderer_Blue.cpp +++ b/trinity/PostProcess/Tr2PostProcessRenderer_Blue.cpp @@ -38,7 +38,7 @@ const Be::ClassInfo* Tr2PostProcessRenderer::ExposeToBlue() MAP_ATTRIBUTE( "bloomDebugShader", m_bloomDebugShader, "The bloom high pass effect", Be::READWRITE ) - MAP_ATTRIBUTE( "depthOfFieldCoCShader", m_depthOfFieldCoCShader, "The DoF Circle of Confusion shader", Be::READWRITE); + MAP_ATTRIBUTE( "depthOfFieldCoCShader", m_depthOfFieldCoCShader, "The DoF Circle of Confusion shader", Be::READWRITE ); MAP_ATTRIBUTE( "depthOfFieldBokehBlurShader", m_depthOfFieldBokehBlurShader, "The bokeh blur shader", Be::READWRITE ); MAP_ATTRIBUTE( "depthOfFieldBokehFillShader", m_depthOfFieldBokehFillShader, "The bokeh fill shader", Be::READWRITE ); MAP_ATTRIBUTE( "dynamicExposureToTextureShader", m_dynamicExposureToTextureShader, "exposure texture", Be::READWRITE ); diff --git a/trinity/PriorityBlend.h b/trinity/PriorityBlend.h index 332c0715a..91fc3782a 100644 --- a/trinity/PriorityBlend.h +++ b/trinity/PriorityBlend.h @@ -8,354 +8,353 @@ namespace PriorityBlend { - template - struct Attribute +template +struct Attribute +{ + T value; + bool enabled; + + Attribute( T value ) : + value( value ), + enabled( false ) { - T value; - bool enabled; + } - Attribute( T value ) : - value( value ), - enabled( false ) - { - } + Attribute( T value, bool enabled ) : + value( value ), + enabled( enabled ) + { + } +}; - Attribute( T value, bool enabled ) : - value( value ), - enabled( enabled ) - { - } - }; +template +T Zero( T ) +{ + return {}; +} + +Vector2 Zero( Vector2 ); +Vector3 Zero( Vector3 ); +Vector4 Zero( Vector4 ); +Color Zero( Color ); +bool Zero( bool ); + +template +class SumAccumulator +{ +public: + using ResultType = T; - template - T Zero( T ) + void Add( const T& value, float weight ) { - return {}; + m_result += value * weight; } - Vector2 Zero( Vector2 ); - Vector3 Zero( Vector3 ); - Vector4 Zero( Vector4 ); - Color Zero( Color ); - bool Zero( bool ); + ResultType GetResult() const + { + return m_result; + } +private: + ResultType m_result = Zero( T() ); +}; - template - class SumAccumulator - { - public: - using ResultType = T; +template +class MaxWeightAccumulator +{ +public: + using ResultType = T; - void Add( const T& value, float weight ) + void Add( const T& value, float weight ) + { + if( weight > m_weight ) { - m_result += value * weight; + m_weight = weight; + m_result = value; } + } - ResultType GetResult() const - { - return m_result; - } + ResultType GetResult() const + { + return m_result; + } - private: - ResultType m_result = Zero( T() ); - }; +private: + ResultType m_result = Zero( T() ); + float m_weight = 0.0f; +}; - template - class MaxWeightAccumulator +template +struct MaxNWeightsAccumulator +{ +public: + struct WeightedValue { - public: - using ResultType = T; + T value = Zero( T() ); + float weight = 0; + }; + struct ResultType + { + std::array values; + size_t count = 0; + }; - void Add( const T& value, float weight ) + void Add( const T& value, float weight ) + { + // if the value is already in the values, update the weight + for( size_t i = 0; i < m_result.count; ++i ) { - if( weight > m_weight ) + if( m_result.values[i].value == value ) { - m_weight = weight; - m_result = value; + m_result.values[i].weight += weight; + return; } } - ResultType GetResult() const - { - return m_result; - } - - private: - ResultType m_result = Zero( T() ); - float m_weight = 0.0f; - }; - template - struct MaxNWeightsAccumulator - { - public: - struct WeightedValue - { - T value = Zero( T() ); - float weight = 0; - }; - struct ResultType + if( m_result.count < N ) { - std::array values; - size_t count = 0; - }; - - void Add( const T& value, float weight ) + m_result.values[m_result.count].value = value; + m_result.values[m_result.count].weight = weight; + ++m_result.count; + std::sort( m_result.values.begin(), m_result.values.end(), []( const WeightedValue& a, const WeightedValue& b ) { return a.weight > b.weight; } ); + } + else { - // if the value is already in the values, update the weight + // insert the new value in the correct place for( size_t i = 0; i < m_result.count; ++i ) { - if( m_result.values[i].value == value ) - { - m_result.values[i].weight += weight; - return; - } - } - - - if( m_result.count < N ) - { - m_result.values[m_result.count].value = value; - m_result.values[m_result.count].weight = weight; - ++m_result.count; - std::sort( m_result.values.begin(), m_result.values.end(), []( const WeightedValue& a, const WeightedValue& b ) { return a.weight > b.weight; } ); - } - else - { - // insert the new value in the correct place - for( size_t i = 0; i < m_result.count; ++i ) + if( weight > m_result.values[i].weight ) { - if( weight > m_result.values[i].weight ) + for( size_t j = N - 1; j > i; --j ) + { + m_result.values[j] = m_result.values[j - 1]; + } + m_result.values[i].value = value; + m_result.values[i].weight = weight; + if( m_result.count < N ) { - for( size_t j = N - 1; j > i; --j ) - { - m_result.values[j] = m_result.values[j - 1]; - } - m_result.values[i].value = value; - m_result.values[i].weight = weight; - if( m_result.count < N ) - { - ++m_result.count; - } - return; + ++m_result.count; } + return; } } } + } - ResultType GetResult() const + ResultType GetResult() const + { + ResultType result = m_result; + float totalWeight = 0; + for( auto& value : result.values ) + { + totalWeight += value.weight; + } + if( totalWeight > 0 ) { - ResultType result = m_result; - float totalWeight = 0; for( auto& value : result.values ) { - totalWeight += value.weight; - } - if( totalWeight > 0 ) - { - for( auto& value : result.values ) - { - value.weight /= totalWeight; - } + value.weight /= totalWeight; } - return result; } - private: - ResultType m_result; - }; + return result; + } +private: + ResultType m_result; +}; - template - struct DefaultAccumulator - { - using Type = SumAccumulator; - }; - template <> - struct DefaultAccumulator - { - using Type = MaxWeightAccumulator; - }; +template +struct DefaultAccumulator +{ + using Type = SumAccumulator; +}; - template <> - struct DefaultAccumulator - { - using Type = MaxWeightAccumulator; - }; +template <> +struct DefaultAccumulator +{ + using Type = MaxWeightAccumulator; +}; + +template <> +struct DefaultAccumulator +{ + using Type = MaxWeightAccumulator; +}; - template - class AttributesDebugObserver +template +class AttributesDebugObserver +{ +public: + AttributesDebugObserver() { - public: - AttributesDebugObserver() - { - m_debugObject = PyDict_New(); - } - ~AttributesDebugObserver() - { - Py_XDECREF( m_debugObject ); - } + m_debugObject = PyDict_New(); + } + ~AttributesDebugObserver() + { + Py_XDECREF( m_debugObject ); + } - void BeginAttribute( const char* name ) - { - m_currentAttribute = PyDict_New(); + void BeginAttribute( const char* name ) + { + m_currentAttribute = PyDict_New(); - auto pyName = BlueWrapReturnValue( {}, name ); - PyDict_SetItemString( m_currentAttribute, "name", pyName ); - Py_XDECREF( pyName ); + auto pyName = BlueWrapReturnValue( {}, name ); + PyDict_SetItemString( m_currentAttribute, "name", pyName ); + Py_XDECREF( pyName ); - m_currentInfluencers = PyList_New( 0 ); - PyDict_SetItemString( m_currentAttribute, "influencers", m_currentInfluencers ); - Py_XDECREF( m_currentInfluencers ); + m_currentInfluencers = PyList_New( 0 ); + PyDict_SetItemString( m_currentAttribute, "influencers", m_currentInfluencers ); + Py_XDECREF( m_currentInfluencers ); - PyDict_SetItemString( m_debugObject, name, m_currentAttribute ); - Py_XDECREF( m_currentAttribute ); - } + PyDict_SetItemString( m_debugObject, name, m_currentAttribute ); + Py_XDECREF( m_currentAttribute ); + } - void Influence( T* attributes, float weight ) - { - auto rec = PyDict_New(); + void Influence( T* attributes, float weight ) + { + auto rec = PyDict_New(); - auto pyAttributes = BlueWrapReturnValue( {}, attributes ); - PyDict_SetItemString( rec, "attributes", pyAttributes ); - Py_XDECREF( pyAttributes ); + auto pyAttributes = BlueWrapReturnValue( {}, attributes ); + PyDict_SetItemString( rec, "attributes", pyAttributes ); + Py_XDECREF( pyAttributes ); - auto pyWeight = BlueWrapReturnValue( {}, weight ); - PyDict_SetItemString( rec, "weight", pyWeight ); - Py_XDECREF( pyWeight ); + auto pyWeight = BlueWrapReturnValue( {}, weight ); + PyDict_SetItemString( rec, "weight", pyWeight ); + Py_XDECREF( pyWeight ); - PyList_Append( m_currentInfluencers, rec ); - Py_XDECREF( rec ); - } + PyList_Append( m_currentInfluencers, rec ); + Py_XDECREF( rec ); + } - void EndAttribute( PyObject* value ) + void EndAttribute( PyObject* value ) + { + if( value && m_currentAttribute ) { - if( value && m_currentAttribute ) - { - PyDict_SetItemString( m_currentAttribute, "value", value ); - } - m_currentAttribute = nullptr; - m_currentInfluencers = nullptr; + PyDict_SetItemString( m_currentAttribute, "value", value ); } + m_currentAttribute = nullptr; + m_currentInfluencers = nullptr; + } - BluePy GetDict() const - { - return BluePy( m_debugObject, true ); - } + BluePy GetDict() const + { + return BluePy( m_debugObject, true ); + } - private: - PyObject* m_debugObject = nullptr; - PyObject* m_currentAttribute = nullptr; - PyObject* m_currentInfluencers = nullptr; - }; +private: + PyObject* m_debugObject = nullptr; + PyObject* m_currentAttribute = nullptr; + PyObject* m_currentInfluencers = nullptr; +}; - template - void EndAttribute( AttributesDebugObserver& observer, const V& value ) +template +void EndAttribute( AttributesDebugObserver& observer, const V& value ) +{ + auto pyValue = BlueWrapReturnValue( {}, value ); + observer.EndAttribute( pyValue ); + Py_DECREF( pyValue ); +} + +template +void EndAttribute( AttributesDebugObserver& observer, const typename MaxNWeightsAccumulator::ResultType& value ) +{ + auto pyList = PyList_New( 0 ); + for( size_t i = 0; i < value.count; ++i ) { - auto pyValue = BlueWrapReturnValue( {}, value ); - observer.EndAttribute( pyValue ); + auto element = PyDict_New(); + auto pyValue = BlueWrapReturnValue( {}, value.values[i].value ); + PyDict_SetItemString( element, "value", pyValue ); Py_DECREF( pyValue ); + + auto pyWeight = BlueWrapReturnValue( {}, value.values[i].weight ); + PyDict_SetItemString( element, "weight", pyWeight ); + Py_DECREF( pyWeight ); + + PyList_Append( pyList, element ); + Py_DECREF( element ); } + observer.EndAttribute( pyList ); + Py_DECREF( pyList ); +} - template - void EndAttribute( AttributesDebugObserver& observer, const typename MaxNWeightsAccumulator::ResultType& value ) - { - auto pyList = PyList_New( 0 ); - for( size_t i = 0; i < value.count; ++i ) - { - auto element = PyDict_New(); - auto pyValue = BlueWrapReturnValue( {}, value.values[i].value ); - PyDict_SetItemString( element, "value", pyValue ); - Py_DECREF( pyValue ); +template ::Type> +typename Accumulator::ResultType Accumulate( const Attribute T::* attr, const std::vector& sources, AttributesDebugObserver* observer, const char* attributeName, Accumulator accumulator = {} ) +{ + // sources are assumed to be sorted by priority: high to low - auto pyWeight = BlueWrapReturnValue( {}, value.values[i].weight ); - PyDict_SetItemString( element, "weight", pyWeight ); - Py_DECREF( pyWeight ); + float remainingWeight = 1.0f; - PyList_Append( pyList, element ); - Py_DECREF( element ); - } - observer.EndAttribute( pyList ); - Py_DECREF( pyList ); - } - - template ::Type> - typename Accumulator::ResultType Accumulate( const Attribute T::*attr, const std::vector& sources, AttributesDebugObserver* observer, const char* attributeName, Accumulator accumulator = {} ) + if( observer ) { - // sources are assumed to be sorted by priority: high to low - - float remainingWeight = 1.0f; + observer->BeginAttribute( attributeName ); + } - if( observer ) + for( auto it = begin( sources ); it != end( sources ); ) + { + // figure out the range of sources with the same priority + auto jt = it; + while( jt != end( sources ) && ( *jt )->priority == ( *it )->priority ) { - observer->BeginAttribute( attributeName ); + ++jt; } - for( auto it = begin( sources ); it != end( sources ); ) + float totalPriorityIntensity = 0.0f; + for( auto kt = it; kt != jt; ++kt ) { - // figure out the range of sources with the same priority - auto jt = it; - while( jt != end( sources ) && ( *jt )->priority == ( *it )->priority ) - { - ++jt; - } - - float totalPriorityIntensity = 0.0f; - for( auto kt = it; kt != jt; ++kt ) - { - if( ( ( **kt ).*attr ).enabled ) - { - totalPriorityIntensity += ( **kt ).intensity; - } - } - if( totalPriorityIntensity == 0.0f ) + if( ( ( **kt ).*attr ).enabled ) { - it = jt; - continue; + totalPriorityIntensity += ( **kt ).intensity; } + } + if( totalPriorityIntensity == 0.0f ) + { + it = jt; + continue; + } - float normalizationFactor = 1.f / std::max( totalPriorityIntensity, 1.0f ) * remainingWeight; + float normalizationFactor = 1.f / std::max( totalPriorityIntensity, 1.0f ) * remainingWeight; - for( auto kt = it; kt != jt; ++kt ) + for( auto kt = it; kt != jt; ++kt ) + { + if( ( ( **kt ).*attr ).enabled ) { - if( ( ( **kt ).*attr ).enabled ) - { - float weight = ( **kt ).intensity * normalizationFactor; + float weight = ( **kt ).intensity * normalizationFactor; - accumulator.Add( ( ( **kt ).*attr ).value, weight ); - if( observer ) - { - observer->Influence( *kt, weight ); - } + accumulator.Add( ( ( **kt ).*attr ).value, weight ); + if( observer ) + { + observer->Influence( *kt, weight ); } } - - remainingWeight -= totalPriorityIntensity; - it = jt; - if( remainingWeight <= 0 ) - { - break; - } } - if( observer ) + + remainingWeight -= totalPriorityIntensity; + it = jt; + if( remainingWeight <= 0 ) { - EndAttribute( *observer, accumulator.GetResult() ); + break; } - - return accumulator.GetResult(); } - - template ::Type> - typename Accumulator::ResultType Accumulate( const Attribute T::*attr, const std::vector& sources, Accumulator accumulator = {} ) + if( observer ) { - return Accumulate( attr, sources, (AttributesDebugObserver*)nullptr, nullptr, accumulator ); + EndAttribute( *observer, accumulator.GetResult() ); } + + return accumulator.GetResult(); } +template ::Type> +typename Accumulator::ResultType Accumulate( const Attribute T::* attr, const std::vector& sources, Accumulator accumulator = {} ) +{ + return Accumulate( attr, sources, (AttributesDebugObserver*)nullptr, nullptr, accumulator ); +} +} diff --git a/trinity/PyVerCompat.h b/trinity/PyVerCompat.h index 279f43aa5..1bde2772d 100644 --- a/trinity/PyVerCompat.h +++ b/trinity/PyVerCompat.h @@ -47,7 +47,7 @@ template inline T FromPython( PyObject* pyObj ) { T result{}; - if ( !BlueExtractArgument( pyObj, result, 0 ) ) + if( !BlueExtractArgument( pyObj, result, 0 ) ) { PyErr_Clear(); } diff --git a/trinity/Raytracing/Tr2RaytracingGeometry.cpp b/trinity/Raytracing/Tr2RaytracingGeometry.cpp index 7e4869bb5..59b448999 100644 --- a/trinity/Raytracing/Tr2RaytracingGeometry.cpp +++ b/trinity/Raytracing/Tr2RaytracingGeometry.cpp @@ -359,7 +359,7 @@ const Tr2RtBottomLevelAccelerationStructureAL& Tr2RaytracingMeshArea::BuildBlas( { return m_blas; } - if( lod->m_areas[m_areaIndex].m_isSkinned || lod->m_areas[m_areaIndex].m_isMorphed ) + if( lod->m_areas[m_areaIndex].m_isSkinned || lod->m_areas[m_areaIndex].m_isMorphed ) { if( m_blas.IsValid() && !m_blasOutdated ) { @@ -384,8 +384,8 @@ const Tr2RtBottomLevelAccelerationStructureAL& Tr2RaytracingMeshArea::BuildBlas( } Tr2RtGeometryAL geometry; - geometry.positions = Tr2RtPositionStreamAL( - *skinnedVB, + geometry.positions = Tr2RtPositionStreamAL( + *skinnedVB, 3 * sizeof( float ), lod->m_vertexCount, mesh.GetSkinnedVertexOffset(), @@ -405,7 +405,7 @@ const Tr2RtBottomLevelAccelerationStructureAL& Tr2RaytracingMeshArea::BuildBlas( if( rebuild ) { - CCP_STATS_ZONE( "BLAS rebuild" ); + CCP_STATS_ZONE( "BLAS rebuild" ); auto capacity = geometry; auto highestLod = mesh.GetHighestLodData(); @@ -467,7 +467,7 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr } std::scoped_lock lock( s_geometryConstantsMutex ); - if ( !lod->m_areas[m_areaIndex].m_rtGeometryConstants.IsValid() ) + if( !lod->m_areas[m_areaIndex].m_rtGeometryConstants.IsValid() ) { if( SUCCEEDED( lod->m_areas[m_areaIndex].m_rtGeometryConstants.Create( sizeof( TriRtGeometryConstants ), renderContext.GetPrimaryRenderContext() ) ) ) { @@ -488,8 +488,7 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->positionType; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT32_3, - "position type has to be FLOAT32_3!" - ); + "position type has to be FLOAT32_3!" ); } if( it->m_usage == Tr2VertexDefinition::NORMAL && it->m_usageIndex == 0 && it->m_stream == 0 ) @@ -500,9 +499,8 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->normalType; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_3 || - type == Tr2VertexDefinition::DataType::FLOAT32_3, - "normal type has to be FLOAT16_3 or FLOAT32_3!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_3, + "normal type has to be FLOAT16_3 or FLOAT32_3!" ); } if( it->m_usage == Tr2VertexDefinition::TANGENT && it->m_usageIndex == 0 && it->m_stream == 0 ) @@ -513,12 +511,11 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->tangentType; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_3 || - type == Tr2VertexDefinition::DataType::FLOAT32_3 || - type == Tr2VertexDefinition::DataType::UBYTE_4_NORM || - type == Tr2VertexDefinition::DataType::USHORT_4_NORM || - type == Tr2VertexDefinition::DataType::SHORT_4_NORM, - "tangent type has to be FLOAT16_3 or FLOAT32_3 or UBYTE_4_NORM or USHORT_4_NORM or SHORT_4_NORM!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_3 || + type == Tr2VertexDefinition::DataType::UBYTE_4_NORM || + type == Tr2VertexDefinition::DataType::USHORT_4_NORM || + type == Tr2VertexDefinition::DataType::SHORT_4_NORM, + "tangent type has to be FLOAT16_3 or FLOAT32_3 or UBYTE_4_NORM or USHORT_4_NORM or SHORT_4_NORM!" ); } if( it->m_usage == Tr2VertexDefinition::BITANGENT && it->m_usageIndex == 0 && it->m_stream == 0 ) @@ -529,9 +526,8 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->bitangentType; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_3 || - type == Tr2VertexDefinition::DataType::FLOAT32_3, - "bitangent type has to be FLOAT16_3 or FLOAT32_3!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_3, + "bitangent type has to be FLOAT16_3 or FLOAT32_3!" ); } if( it->m_usage == Tr2VertexDefinition::TEXCOORD && it->m_usageIndex == 0 && it->m_stream == 0 ) @@ -542,9 +538,8 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->texCoord0Type; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_2 || - type == Tr2VertexDefinition::DataType::FLOAT32_2, - "texCoord0 type has to be FLOAT16_2 or FLOAT32_2!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_2, + "texCoord0 type has to be FLOAT16_2 or FLOAT32_2!" ); } if( it->m_usage == Tr2VertexDefinition::TEXCOORD && it->m_usageIndex == 1 && it->m_stream == 0 ) @@ -555,9 +550,8 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->texCoord1Type; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_2 || - type == Tr2VertexDefinition::DataType::FLOAT32_2, - "texCoord1 type has to be FLOAT16_2 or FLOAT32_2!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_2, + "texCoord1 type has to be FLOAT16_2 or FLOAT32_2!" ); } if( it->m_usage == Tr2VertexDefinition::TEXCOORD && it->m_usageIndex == 2 && it->m_stream == 0 ) @@ -568,9 +562,8 @@ const Tr2ConstantBufferAL* Tr2RaytracingMeshArea::GetGeometryConstants( Tr2Raytr uint32_t type = data->texCoord2Type; CCP_ASSERT_M( type == Tr2VertexDefinition::DataType::FLOAT16_2 || - type == Tr2VertexDefinition::DataType::FLOAT32_2, - "texCoord2 type has to be FLOAT16_2 or FLOAT32_2!" - ); + type == Tr2VertexDefinition::DataType::FLOAT32_2, + "texCoord2 type has to be FLOAT16_2 or FLOAT32_2!" ); } // skipping blending data because we get gpu skinned meshes as input (see SkinVertices.fx), so it shouldn't be required for raytracing shaders @@ -607,8 +600,8 @@ Tr2RaytracingGeometry::Tr2RaytracingGeometry() { m_skinVerticesEffect.CreateInstance(); m_skinVerticesEffect->SetEffectPathName( "res:/graphics/effect/managed/space/system/raytracing/skinvertices.fx" ); - m_skinVerticesEffect->SetParameter( m_inVertexBufferTechniqueName, static_cast( nullptr ) ); - m_skinVerticesEffect->SetParameter( m_outVertexBufferTechniqueName, static_cast( nullptr ) ); + m_skinVerticesEffect->SetParameter( m_inVertexBufferTechniqueName, static_cast( nullptr ) ); + m_skinVerticesEffect->SetParameter( m_outVertexBufferTechniqueName, static_cast( nullptr ) ); } Tr2BufferAL* Tr2RaytracingGeometry::GetGpuBuffer( unsigned ) @@ -793,14 +786,14 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) Tr2RaytracingMesh* mesh = it->mesh; TriGeometryResLodData* lod = mesh->GetCurrentLodData(); - if( lod && ( lod->m_areas[it->area->GetAreaIndex()].m_isSkinned || lod->m_areas[it->area->GetAreaIndex()].m_isMorphed ) ) + if( lod && ( lod->m_areas[it->area->GetAreaIndex()].m_isSkinned || lod->m_areas[it->area->GetAreaIndex()].m_isMorphed ) ) { if( !mesh->GetAndResetDirtyFlag() ) { continue; } - outdatedMeshes.push_back( &(*it) ); + outdatedMeshes.push_back( &( *it ) ); skinnedVertexCount += lod->m_vertexCount; } @@ -831,14 +824,14 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) std::swap( barrier.Transition.StateBefore, barrier.Transition.StateAfter ); - ON_BLOCK_EXIT( [&]{ renderContext.ResourceBarrierDx12( barrier ); } ); + ON_BLOCK_EXIT( [&] { renderContext.ResourceBarrierDx12( barrier ); } ); #endif - CTr2RuntimeGpuBuffer inVB; - CTr2RuntimeGpuBuffer outVB; - - Tr2GeometryBufferParameterPtr inVbParam = BlueCastPtr( m_skinVerticesEffect->GetResourceByName( m_inVertexBufferTechniqueName.c_str() ) ); - Tr2GeometryBufferParameterPtr outVbParam = BlueCastPtr( m_skinVerticesEffect->GetResourceByName( m_outVertexBufferTechniqueName.c_str() ) ); + CTr2RuntimeGpuBuffer inVB; + CTr2RuntimeGpuBuffer outVB; + + Tr2GeometryBufferParameterPtr inVbParam = BlueCastPtr( m_skinVerticesEffect->GetResourceByName( m_inVertexBufferTechniqueName.c_str() ) ); + Tr2GeometryBufferParameterPtr outVbParam = BlueCastPtr( m_skinVerticesEffect->GetResourceByName( m_outVertexBufferTechniqueName.c_str() ) ); if( !outdatedMeshes.empty() ) { @@ -869,7 +862,7 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) #if TRINITY_PLATFORM != TRINITY_DIRECTX12 outVB.m_buffer = m_skinnedVertices; - outVbParam->SetGpuBuffer( &outVB ); + outVbParam->SetGpuBuffer( &outVB ); #endif uint32_t outOffset = 0; @@ -913,7 +906,6 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) constData->morphTargetStride = lod->m_bytesPerMorphTargetVertex >> 2; constData->morphTargetSize = ( lod->m_bytesPerMorphTargetVertex * vertexCount ) >> 2; constData->bakedMorphTargetPositionOffset = ( *it )->bakedMorphOffset; - } m_skinVerticesData.Unlock( renderContext ); @@ -921,7 +913,7 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) #if TRINITY_PLATFORM != TRINITY_DIRECTX12 inVB.m_buffer = lod->m_vertexAllocation.GetBuffer(); - inVbParam->SetGpuBuffer( &inVB ); + inVbParam->SetGpuBuffer( &inVB ); #endif // cheat a bit instead of calling RunComputeShader() to make things more performant if( firstIteration ) @@ -952,8 +944,8 @@ void Tr2RaytracingGeometry::TransformMeshes( Tr2RenderContext& renderContext ) } #if TRINITY_PLATFORM != TRINITY_DIRECTX12 renderContext.SetResourceSet( Tr2ResourceSetAL() ); - inVbParam->SetGpuBuffer( static_cast( nullptr ) ); - outVbParam->SetGpuBuffer( static_cast( nullptr ) ); + inVbParam->SetGpuBuffer( static_cast( nullptr ) ); + outVbParam->SetGpuBuffer( static_cast( nullptr ) ); #endif } @@ -979,7 +971,7 @@ void Tr2RaytracingGeometry::BuildAccelerationStructures( Tr2RenderContext& rende { continue; } - + Tr2RtInstanceAL instance; instance.flags = it->isTransparent ? Tr2RtInstanceAL::FORCE_NON_OPAQUE : Tr2RtInstanceAL::NONE; instance.materialIndex = it->materialIndex; @@ -989,9 +981,9 @@ void Tr2RaytracingGeometry::BuildAccelerationStructures( Tr2RenderContext& rende continue; } - if ( it->worldTransforms ) + if( it->worldTransforms ) { - for ( uint32_t i = 0; i < it->instanceCount; ++i ) + for( uint32_t i = 0; i < it->instanceCount; ++i ) { memcpy( instance.transform, it->worldTransforms + i, sizeof( Float4x3 ) ); instances.push_back( instance ); @@ -1007,18 +999,18 @@ void Tr2RaytracingGeometry::BuildAccelerationStructures( Tr2RenderContext& rende } } - { - CCP_STATS_ZONE( "TLAS update" ); - if( instances.empty() ) - { - m_tlas = Tr2RtTopLevelAccelerationStructureAL(); - } - else if( FAILED( m_tlas.Update( instances.size(), instances.data(), renderContext ) ) ) - { - CCP_STATS_ZONE( "TLAS create" ); - m_tlas.Create( instances.size(), instances.data(), Tr2RtBuildFlags::PREFER_FAST_TRACE, renderContext.GetPrimaryRenderContext() ); - } - } + { + CCP_STATS_ZONE( "TLAS update" ); + if( instances.empty() ) + { + m_tlas = Tr2RtTopLevelAccelerationStructureAL(); + } + else if( FAILED( m_tlas.Update( instances.size(), instances.data(), renderContext ) ) ) + { + CCP_STATS_ZONE( "TLAS create" ); + m_tlas.Create( instances.size(), instances.data(), Tr2RtBuildFlags::PREFER_FAST_TRACE, renderContext.GetPrimaryRenderContext() ); + } + } } void Tr2RaytracingGeometry::AddGeometry( Tr2RaytracingMesh& mesh, Tr2RaytracingMeshArea& area, Tr2Material* material, const Tr2ConstantBufferAL* perObjectData, const Tr2ConstantBufferAL* vertexBufferData, const Matrix& worldTransform, uint32_t bakedMorphOffset ) @@ -1069,7 +1061,7 @@ bool Tr2RaytracingGeometry::HasGeometry() const Tr2RtTopLevelAccelerationStructureAL Tr2RaytracingGeometry::GetTLAS() const { - return m_tlas; + return m_tlas; } const Tr2BindlessResourcesAL& Tr2RaytracingGeometry::GetBindlessResources() const @@ -1130,9 +1122,8 @@ Tr2RaytracingGeometry::VtxOffsets Tr2RaytracingGeometry::FindOffsets( unsigned d void Tr2RaytracingGeometry::ReleaseResources( TriStorage s ) { - if( (s & TRISTORAGE_ALL) == TRISTORAGE_ALL ) + if( ( s & TRISTORAGE_ALL ) == TRISTORAGE_ALL ) { m_skinVerticesData = Tr2ConstantBufferAL(); } } - diff --git a/trinity/Raytracing/Tr2RaytracingGeometry.h b/trinity/Raytracing/Tr2RaytracingGeometry.h index ae082de9a..44aeefcbf 100644 --- a/trinity/Raytracing/Tr2RaytracingGeometry.h +++ b/trinity/Raytracing/Tr2RaytracingGeometry.h @@ -88,9 +88,18 @@ class Tr2RaytracingMeshArea Tr2RaytracingMeshArea( uint32_t index ); const Tr2RtBottomLevelAccelerationStructureAL& BuildBlas( Tr2RaytracingMesh& mesh, Tr2RenderContext& renderContext ); const Tr2ConstantBufferAL* GetGeometryConstants( Tr2RaytracingMesh& mesh, Tr2RenderContext& renderContext ) const; - uint32_t GetAreaIndex(){ return m_areaIndex; } - void MarkBlasOutdated() { m_blasOutdated = true; } - bool IsBlasOutdated() const { return m_blasOutdated || !m_blas.IsValid(); } + uint32_t GetAreaIndex() + { + return m_areaIndex; + } + void MarkBlasOutdated() + { + m_blasOutdated = true; + } + bool IsBlasOutdated() const + { + return m_blasOutdated || !m_blas.IsValid(); + } private: uint32_t m_areaIndex; @@ -99,7 +108,8 @@ class Tr2RaytracingMeshArea bool m_blasOutdated; }; -BLUE_CLASS( Tr2RaytracingGeometry ) : public ITr2GpuBuffer +BLUE_CLASS( Tr2RaytracingGeometry ) : + public ITr2GpuBuffer { public: EXPOSE_TO_BLUE(); @@ -115,11 +125,12 @@ BLUE_CLASS( Tr2RaytracingGeometry ) : public ITr2GpuBuffer bool HasGeometry() const; void ReleaseResources( TriStorage s ); - - Tr2RtTopLevelAccelerationStructureAL GetTLAS() const; + + Tr2RtTopLevelAccelerationStructureAL GetTLAS() const; const Tr2BindlessResourcesAL& GetBindlessResources() const; const BlueSharedString m_rtShadowTechniqueName = BlueSharedString( "RtShadow" ); + private: struct VtxOffsets { @@ -142,17 +153,17 @@ BLUE_CLASS( Tr2RaytracingGeometry ) : public ITr2GpuBuffer bool isTransparent; uint32_t bakedMorphOffset; }; - + const BlueSharedString m_inVertexBufferTechniqueName = BlueSharedString( "InVB" ); const BlueSharedString m_outVertexBufferTechniqueName = BlueSharedString( "OutVB" ); static const uint32_t INVALID_MATERIAL = 0xffffffff; - void PrepareShaderTableDescription( Tr2RenderContext & renderContext, int32_t numRaycasters, Tr2RtShaderTableDescriptionAL * *shaderTableDescs, Tr2RaytracingPipelineStateManager * *pipelineManagers ); - void TransformMeshes( Tr2RenderContext& renderContext ); - void BuildAccelerationStructures(Tr2RenderContext& renderContext); + void PrepareShaderTableDescription( Tr2RenderContext & renderContext, int32_t numRaycasters, Tr2RtShaderTableDescriptionAL** shaderTableDescs, Tr2RaytracingPipelineStateManager** pipelineManagers ); + void TransformMeshes( Tr2RenderContext & renderContext ); + void BuildAccelerationStructures( Tr2RenderContext & renderContext ); VtxOffsets FindOffsets( unsigned declHandle ); - + std::vector m_geometryData; Tr2EnumerableThreadSpecific> m_threadLocalGeometryData; Tr2RtTopLevelAccelerationStructureAL m_tlas; diff --git a/trinity/Raytracing/Tr2RaytracingManager.cpp b/trinity/Raytracing/Tr2RaytracingManager.cpp index d386c8b46..f4efef0fb 100644 --- a/trinity/Raytracing/Tr2RaytracingManager.cpp +++ b/trinity/Raytracing/Tr2RaytracingManager.cpp @@ -10,25 +10,25 @@ namespace { - // for shadow scene - struct ShadowPerFrameData - { - Matrix projectionInverse; - Matrix viewInverse; +// for shadow scene +struct ShadowPerFrameData +{ + Matrix projectionInverse; + Matrix viewInverse; - Vector3 sunDirection; - float sunAngle; + Vector3 sunDirection; + float sunAngle; - CcpMath::Sphere planets[2]; + CcpMath::Sphere planets[2]; - Vector2 resolution; - uint32_t frameIndex; - }; + Vector2 resolution; + uint32_t frameIndex; +}; - const BlueSharedString RtShadowTechniqueName = BlueSharedString( "RtShadow" ); - const BlueSharedString RtShadowMapTechniqueName = BlueSharedString( "RtShadowShadowDest" ); - const BlueSharedString NormalBufferTechniqueName = BlueSharedString( "RtShadowNormalBuffer" ); - const BlueSharedString RtSceneTechniqueName = BlueSharedString( "RtShadowScene" ); +const BlueSharedString RtShadowTechniqueName = BlueSharedString( "RtShadow" ); +const BlueSharedString RtShadowMapTechniqueName = BlueSharedString( "RtShadowShadowDest" ); +const BlueSharedString NormalBufferTechniqueName = BlueSharedString( "RtShadowNormalBuffer" ); +const BlueSharedString RtSceneTechniqueName = BlueSharedString( "RtShadowScene" ); } //*********************************************************** @@ -77,13 +77,13 @@ void Tr2RaytracingManager::ReleaseResources( TriStorage s ) } } -Tr2GpuResourcePool::Texture Tr2RaytracingManager::RenderShadows( - const Tr2TextureAL& depth, - const Tr2TextureAL& normal, - const Vector3& sunDirection, - const CcpMath::Sphere* planets, - size_t planetCount, - float upscaling, +Tr2GpuResourcePool::Texture Tr2RaytracingManager::RenderShadows( + const Tr2TextureAL& depth, + const Tr2TextureAL& normal, + const Vector3& sunDirection, + const CcpMath::Sphere* planets, + size_t planetCount, + float upscaling, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) { @@ -141,7 +141,7 @@ Tr2GpuResourcePool::Texture Tr2RaytracingManager::RenderShadows( { ShadowPerFrameData* data; - m_shadowPerFrameData.Lock( reinterpret_cast(&data), renderContext ); + m_shadowPerFrameData.Lock( reinterpret_cast( &data ), renderContext ); data->projectionInverse = Transpose( Inverse( Tr2Renderer::GetReversedDepthProjectionTransform() ) ); data->viewInverse = Transpose( Tr2Renderer::GetInverseViewTransform() ); @@ -176,7 +176,7 @@ Tr2GpuResourcePool::Texture Tr2RaytracingManager::RenderShadows( renderContext.UseResources( Tr2UseResourceDestination::COMPUTE, Tr2GpuUsage::SHADER_RESOURCE, m_geometry->GetBindlessResources() ); } - renderContext.UseAccelerationStructure( m_geometry->GetTLAS() ); + renderContext.UseAccelerationStructure( m_geometry->GetTLAS() ); renderContext.DispatchRays( pipelineState, m_shadowShaderTable, rayGenName.c_str(), destination->GetWidth(), destination->GetHeight(), 1 ); } if( m_denoiser && m_applyDenoiser ) diff --git a/trinity/Raytracing/Tr2RaytracingManager.h b/trinity/Raytracing/Tr2RaytracingManager.h index f6fa3c9dc..d4204b838 100644 --- a/trinity/Raytracing/Tr2RaytracingManager.h +++ b/trinity/Raytracing/Tr2RaytracingManager.h @@ -10,7 +10,8 @@ class Tr2RtShaderTableAL; BLUE_DECLARE( TriTextureRes ); -BLUE_CLASS( Tr2RaytracingManager ) : public IRoot +BLUE_CLASS( Tr2RaytracingManager ) : + public IRoot { public: Tr2RaytracingManager( IRoot* lockobj = nullptr ); @@ -21,22 +22,22 @@ BLUE_CLASS( Tr2RaytracingManager ) : public IRoot Tr2RaytracingGeometry& GetGeometry(); Tr2GpuResourcePool::Texture RenderShadows( - const Tr2TextureAL& depth, - const Tr2TextureAL& normal, - const Vector3& sunDirection, - const CcpMath::Sphere* planets, - size_t planetCount, - float upscaling, + const Tr2TextureAL& depth, + const Tr2TextureAL& normal, + const Vector3& sunDirection, + const CcpMath::Sphere* planets, + size_t planetCount, + float upscaling, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); - + bool OnPrepareResources(); void ReleaseResources( TriStorage s ); Tr2RaytracingPipelineStateManager m_pipelineManager; Tr2RtShaderTableDescriptionAL m_shaderTableDesc; + private: - Tr2RaytracingGeometryPtr m_geometry; diff --git a/trinity/Raytracing/Tr2RaytracingManager_Blue.cpp b/trinity/Raytracing/Tr2RaytracingManager_Blue.cpp index 943bf41bb..99875188d 100644 --- a/trinity/Raytracing/Tr2RaytracingManager_Blue.cpp +++ b/trinity/Raytracing/Tr2RaytracingManager_Blue.cpp @@ -15,5 +15,5 @@ const Be::ClassInfo* Tr2RaytracingManager::ExposeToBlue() MAP_ATTRIBUTE( "applyDenoiser", m_applyDenoiser, "apply denoiser or not", Be::READWRITE ) MAP_ATTRIBUTE( "denoiser", m_denoiser, "", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/RenderJob/Tr2RenderJobs.cpp b/trinity/RenderJob/Tr2RenderJobs.cpp index 57d7d7254..172f22d8c 100644 --- a/trinity/RenderJob/Tr2RenderJobs.cpp +++ b/trinity/RenderJob/Tr2RenderJobs.cpp @@ -11,16 +11,13 @@ CCP_STATS_DECLARE( deviceRenderJobs, "Trinity/device/RenderJobs", true, CST_TIME CCP_STATS_DECLARE( deviceChainedRenderJobsCount, "Trinity/device/ChainedRenderJobsCount", true, CST_COUNTER_LOW, "Count of scheduled chained render jobs" ); CCP_STATS_DECLARE( deviceOnceRenderJobsCount, "Trinity/device/OnceRenderJobsCount", true, CST_COUNTER_LOW, "Count of scheduled once render jobs" ); -Tr2RenderJobs::Tr2RenderJobs( IRoot* lockobj ) - : PARENTLOCK( m_scheduledOnce ) - , PARENTLOCK( m_scheduledRecurring ) - , PARENTLOCK( m_scheduledChained ) - , PARENTLOCK( m_updateRecurring ) -{ +Tr2RenderJobs::Tr2RenderJobs( IRoot* lockobj ) : + PARENTLOCK( m_scheduledOnce ), PARENTLOCK( m_scheduledRecurring ), PARENTLOCK( m_scheduledChained ), PARENTLOCK( m_updateRecurring ) +{ } Tr2RenderJobs::~Tr2RenderJobs() -{ +{ } void Tr2RenderJobs::Run( Be::Time realTime, Be::Time simTime ) @@ -29,7 +26,7 @@ void Tr2RenderJobs::Run( Be::Time realTime, Be::Time simTime ) CCP_STATS_SET( deviceChainedRenderJobsCount, m_scheduledChained.size() ); CCP_STATS_SET( deviceOnceRenderJobsCount, m_scheduledOnce.size() ); - D3DPERF_EVENT(L"RenderJobs"); + D3DPERF_EVENT( L"RenderJobs" ); USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -44,14 +41,14 @@ void Tr2RenderJobs::Run( Be::Time realTime, Be::Time simTime ) { TriRenderJob* rj = *it; TriRenderJobStatus status = rj->Run( realTime, simTime ); - CCP_ASSERT( status != RJ_FAILED ); + CCP_ASSERT( status != RJ_FAILED ); } - + // Process jobs scheduled for one-off execution. Every job on this list is run, // jobs that are still in progress are continued next frame. copyOfJobs.clear(); copyOfJobs.insert( copyOfJobs.end(), m_scheduledOnce.begin(), m_scheduledOnce.end() ); - + CTriRenderJobVector continuedJobs; for( auto it = copyOfJobs.cbegin(); it != copyOfJobs.cend(); ++it ) { @@ -109,6 +106,6 @@ void Tr2RenderJobs::RunUpdate( Be::Time realTime, Be::Time simTime ) { TriRenderJob* rj = *it; TriRenderJobStatus status = rj->Run( realTime, simTime ); - CCP_ASSERT( status != RJ_FAILED ); + CCP_ASSERT( status != RJ_FAILED ); } } \ No newline at end of file diff --git a/trinity/RenderJob/Tr2RenderJobs.h b/trinity/RenderJob/Tr2RenderJobs.h index 2b33ec8dc..b9addc6d0 100644 --- a/trinity/RenderJob/Tr2RenderJobs.h +++ b/trinity/RenderJob/Tr2RenderJobs.h @@ -11,17 +11,18 @@ BLUE_DECLARE( TriRenderJob ); BLUE_DECLARE_VECTOR( TriRenderJob ); -BLUE_CLASS( Tr2RenderJobs ) : public IRoot +BLUE_CLASS( Tr2RenderJobs ) : + public IRoot { public: EXPOSE_TO_BLUE(); Tr2RenderJobs( IRoot* lockobj = 0 ); ~Tr2RenderJobs(); - + void Run( Be::Time realTime, Be::Time simTime ); void RunUpdate( Be::Time realTime, Be::Time simTime ); - + PTriRenderJobVector m_scheduledRecurring; PTriRenderJobVector m_scheduledOnce; PTriRenderJobVector m_scheduledChained; @@ -31,4 +32,4 @@ BLUE_CLASS( Tr2RenderJobs ) : public IRoot TYPEDEF_BLUECLASS( Tr2RenderJobs ) BLUE_DECLARE_VECTOR( Tr2RenderJobs ) -#endif // Tr2RenderJobs_h_ +#endif // Tr2RenderJobs_h_ diff --git a/trinity/RenderJob/Tr2RenderJobs_Blue.cpp b/trinity/RenderJob/Tr2RenderJobs_Blue.cpp index 39332918e..c43eff260 100644 --- a/trinity/RenderJob/Tr2RenderJobs_Blue.cpp +++ b/trinity/RenderJob/Tr2RenderJobs_Blue.cpp @@ -8,47 +8,38 @@ BLUE_DEFINE( Tr2RenderJobs ); const Be::ClassInfo* Tr2RenderJobs::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2RenderJobs, "" ) + EXPOSURE_BEGIN( Tr2RenderJobs, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( Tr2RenderJobs ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "recurring", m_scheduledRecurring, "Recurring render jobs are run each frame", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "once", m_scheduledOnce, "Render jobs scheduled to run once - every job on this list is given a chance to run." "\nJobs may extend over multiple frames.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "chained", m_scheduledChained, "Render jobs scheduled to run once - jobs are run until the first one returns in progress." "\nJobs may extend over multiple frames.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "updateRecurring", m_updateRecurring, "Update jobs are special jobs that are not supposed to do any rendering, but rather do CPU-intensive" "\ncomputations. They run every frame and are scheduled right before device present to hide stalls" "\nfor GPU-bount cases.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) EXPOSURE_END() } - diff --git a/trinity/RenderJob/TriRenderJob.cpp b/trinity/RenderJob/TriRenderJob.cpp index bc02c3fe8..3bf85ee75 100644 --- a/trinity/RenderJob/TriRenderJob.cpp +++ b/trinity/RenderJob/TriRenderJob.cpp @@ -5,38 +5,35 @@ #include "TriRenderStep.h" -TriRenderJob::TriRenderJob( IRoot* lockobj ) - : PARENTLOCK( m_renderSteps ) - , m_enabled( true ) - , m_status( RJ_INIT ) - , m_stackGuard( true ) +TriRenderJob::TriRenderJob( IRoot* lockobj ) : + PARENTLOCK( m_renderSteps ), m_enabled( true ), m_status( RJ_INIT ), m_stackGuard( true ) { m_currentStep = 0; } -TriRenderJob::~TriRenderJob(void) +TriRenderJob::~TriRenderJob( void ) { } -TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2RenderContext *renderContextPtr ) +TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2RenderContext* renderContextPtr ) { - D3DPERF_EVENT1( L"TriRenderJob::%S", (const wchar_t *)CA2W(m_name.c_str()) ); + D3DPERF_EVENT1( L"TriRenderJob::%S", (const wchar_t*)CA2W( m_name.c_str() ) ); if( !m_enabled ) { return RJ_DONE; } - typedef std::vector RenderStepVector; - - RenderStepVector copyOfSteps( m_renderSteps.size() ); // we need to copy steps because lists can change when executed + typedef std::vector RenderStepVector; + + RenderStepVector copyOfSteps( m_renderSteps.size() ); // we need to copy steps because lists can change when executed for( size_t i = 0; i != m_renderSteps.size(); ++i ) { copyOfSteps[i] = m_renderSteps[i]; } - // Note that we don't always initialize the cursor here - it is persisted + // Note that we don't always initialize the cursor here - it is persisted // across runs, in case a step does not finish its execution. Then we need to // continue where we left off last frame. // Changing the list may however result in an out-of-bounds cursor. @@ -45,9 +42,8 @@ TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2Re m_currentStep = 0; } - Tr2RenderContext &renderContext = - renderContextPtr ? *renderContextPtr - : Tr2RenderContext_GetMainThreadRenderContext(); + Tr2RenderContext& renderContext = + renderContextPtr ? *renderContextPtr : Tr2RenderContext_GetMainThreadRenderContext(); const size_t preRT = renderContext.GetStackSizeRT(); const size_t preDS = renderContext.GetStackSizeDS(); @@ -80,8 +76,8 @@ TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2Re { if( result == RS_OK && m_enabled ) { - CCP_ASSERT( preRT >= renderContext.GetStackSizeRT() && "Push without a Pop (RT)" ); - CCP_ASSERT( preDS >= renderContext.GetStackSizeDS() && "Push without a Pop (DS)"); + CCP_ASSERT( preRT >= renderContext.GetStackSizeRT() && "Push without a Pop (RT)" ); + CCP_ASSERT( preDS >= renderContext.GetStackSizeDS() && "Push without a Pop (DS)" ); } else { @@ -97,32 +93,32 @@ TriRenderJobStatus TriRenderJob::Run( Be::Time realTime, Be::Time simTime, Tr2Re } } - if ( !m_enabled ) + if( !m_enabled ) { return RJ_DONE; } switch( result ) { - case RS_TERMINATE: - m_status = RJ_DONE; - break; + case RS_TERMINATE: + m_status = RJ_DONE; + break; - case RS_OK: - m_status = RJ_DONE; - break; + case RS_OK: + m_status = RJ_DONE; + break; - case RS_FAILED: - m_status = RJ_FAILED; - break; + case RS_FAILED: + m_status = RJ_FAILED; + break; - case RS_IN_PROGRESS: - m_status = RJ_IN_PROGRESS; - break; + case RS_IN_PROGRESS: + m_status = RJ_IN_PROGRESS; + break; - default: - CCP_LOGERR( "TriRenderJob::Run: Invalid TriStepResult" ); - break; + default: + CCP_LOGERR( "TriRenderJob::Run: Invalid TriStepResult" ); + break; } return m_status; @@ -132,10 +128,10 @@ bool TriRenderJob::OnPrepareResources() { #if BLUE_WITH_PYTHON // Perform a callback to a python decorator, if one exists - PyOS->SendEvent( this, - "TriRenderJob::PrepareResources::DoPrepareResources", - "DoPrepareResources", - NULL, + PyOS->SendEvent( this, + "TriRenderJob::PrepareResources::DoPrepareResources", + "DoPrepareResources", + NULL, "()" ); #endif @@ -146,11 +142,11 @@ void TriRenderJob::ReleaseResources( TriStorage s ) { #if BLUE_WITH_PYTHON // Perform a callback to a python decorator, if one exists - PyOS->SendEvent( this, - "TriRenderJob::ReleaseResources::DoReleaseResources", - "DoReleaseResources", - NULL, - "(i)", + PyOS->SendEvent( this, + "TriRenderJob::ReleaseResources::DoReleaseResources", + "DoReleaseResources", + NULL, + "(i)", s ); #endif } \ No newline at end of file diff --git a/trinity/RenderJob/TriRenderJob.h b/trinity/RenderJob/TriRenderJob.h index 255a7badd..01cb63cd9 100644 --- a/trinity/RenderJob/TriRenderJob.h +++ b/trinity/RenderJob/TriRenderJob.h @@ -19,7 +19,7 @@ enum TriRenderJobStatus RJ_FAILED }; -BLUE_CLASS( TriRenderJob ): +BLUE_CLASS( TriRenderJob ) : public IRoot, public Tr2DeviceResource { @@ -27,15 +27,19 @@ BLUE_CLASS( TriRenderJob ): EXPOSE_TO_BLUE(); TriRenderJob( IRoot* lockobj = 0 ); - ~TriRenderJob(void); + ~TriRenderJob( void ); - TriRenderJobStatus Run( Be::Time realTime, Be::Time simTime, Tr2RenderContext *renderContext = nullptr ); + TriRenderJobStatus Run( Be::Time realTime, Be::Time simTime, Tr2RenderContext* renderContext = nullptr ); - TriRenderStepVector& Steps() { return m_renderSteps; } + TriRenderStepVector& Steps() + { + return m_renderSteps; + } // ITriDeviceResource is needed, for cases when people decorate the renderjob class // as a manager for the surfaces and resource that are needed for it virtual void ReleaseResources( TriStorage s ); + private: virtual bool OnPrepareResources(); @@ -47,7 +51,7 @@ BLUE_CLASS( TriRenderJob ): // keep an index instead of an iterator, in case we yield during execution and // modify the list at the same time. What that is supposed to do is debatable, // but at least we don't want to crash pointing at bad memory. - size_t m_currentStep; + size_t m_currentStep; // Check for RT/DS stack depth before and after RJ is run and // assert/repair stack when needed. diff --git a/trinity/RenderJob/TriRenderJob_Blue.cpp b/trinity/RenderJob/TriRenderJob_Blue.cpp index 11a17fcbe..97667a6a4 100644 --- a/trinity/RenderJob/TriRenderJob_Blue.cpp +++ b/trinity/RenderJob/TriRenderJob_Blue.cpp @@ -5,63 +5,52 @@ BLUE_DEFINE( TriRenderJob ); -const Be::VarChooser TriRenderJobStatusChooser[] = -{ +const Be::VarChooser TriRenderJobStatusChooser[] = { // Name Value Docstring - { "RJ_INIT", BeCast( RJ_INIT ), "Render job is in its initial state" }, - { "RJ_IN_PROGRESS", BeCast( RJ_IN_PROGRESS ), "Render job is in progress" }, - { "RJ_DONE", BeCast( RJ_DONE ), "Render job is done" }, - { "RJ_FAILED", BeCast( RJ_FAILED ), "Render job failed" }, - {0} + { "RJ_INIT", BeCast( RJ_INIT ), "Render job is in its initial state" }, + { "RJ_IN_PROGRESS", BeCast( RJ_IN_PROGRESS ), "Render job is in progress" }, + { "RJ_DONE", BeCast( RJ_DONE ), "Render job is done" }, + { "RJ_FAILED", BeCast( RJ_FAILED ), "Render job failed" }, + { 0 } }; BLUE_REGISTER_ENUM( "RENDERJOB_STATUS", TriRenderJobStatus, TriRenderJobStatusChooser ); const Be::ClassInfo* TriRenderJob::ExposeToBlue() { - EXPOSURE_BEGIN(TriRenderJob, "" ) + EXPOSURE_BEGIN( TriRenderJob, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( TriRenderJob ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this render job", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "enabled", - m_enabled, - "Is this job enabled? If not, it does nothing when run", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "stackGuard", - m_stackGuard, - "Check and repair RT/DS stacks when needed", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "status", - m_status, + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this render job", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "enabled", + m_enabled, + "Is this job enabled? If not, it does nothing when run", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "stackGuard", + m_stackGuard, + "Check and repair RT/DS stacks when needed", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "status", + m_status, "Current status of this render job", Be::READWRITE | Be::PERSIST | Be::ENUM, - TriRenderJobStatusChooser - ) - - MAP_ATTRIBUTE - ( - "steps", - m_renderSteps, - "RenderJob steps", - Be::READ | Be::PERSIST - ) + TriRenderJobStatusChooser ) + + MAP_ATTRIBUTE( + "steps", + m_renderSteps, + "RenderJob steps", + Be::READ | Be::PERSIST ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/RenderJob/TriRenderStep.cpp b/trinity/RenderJob/TriRenderStep.cpp index 6fc1387dd..de79de295 100644 --- a/trinity/RenderJob/TriRenderStep.cpp +++ b/trinity/RenderJob/TriRenderStep.cpp @@ -22,8 +22,8 @@ CcpStaticStatisticsEntry* GetOrCreateStatisticsEntry( const std::string& name ) } } -TriRenderStep::TriRenderStep( IRoot* lockobj ) -: m_enabled( true ) +TriRenderStep::TriRenderStep( IRoot* lockobj ) : + m_enabled( true ) { } diff --git a/trinity/RenderJob/TriRenderStep.h b/trinity/RenderJob/TriRenderStep.h index cfdab9d1f..a4c9911f7 100644 --- a/trinity/RenderJob/TriRenderStep.h +++ b/trinity/RenderJob/TriRenderStep.h @@ -16,7 +16,8 @@ enum TriStepResult class Tr2RenderContext; -BLUE_CLASS( TriRenderStep ) : public IRoot +BLUE_CLASS( TriRenderStep ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -25,10 +26,11 @@ BLUE_CLASS( TriRenderStep ) : public IRoot virtual ~TriRenderStep(); bool IsEnabled() const; - virtual TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) = 0; + virtual TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ) = 0; + + void BeginExecute( Tr2RenderContext & renderContext ); + void EndExecute( Tr2RenderContext & renderContext ); - void BeginExecute( Tr2RenderContext& renderContext ); - void EndExecute( Tr2RenderContext& renderContext ); protected: bool GetCaptureGpuTime() const; void SetCaptureGpuTime( bool capture ); diff --git a/trinity/RenderJob/TriRenderStep_Blue.cpp b/trinity/RenderJob/TriRenderStep_Blue.cpp index 57fd77a1b..473ac7f9e 100644 --- a/trinity/RenderJob/TriRenderStep_Blue.cpp +++ b/trinity/RenderJob/TriRenderStep_Blue.cpp @@ -5,13 +5,12 @@ BLUE_DEFINE_ABSTRACT( TriRenderStep ); -const Be::VarChooser TriRenderStepResultChooser[] = -{ +const Be::VarChooser TriRenderStepResultChooser[] = { // Name Value Docstring - { "RS_OK", BeCast( RS_OK ), "Render step succeeded" }, - { "RS_FAILED", BeCast( RS_FAILED ), "Render failed" }, - { "RS_IN_PROGRESS", BeCast( RS_IN_PROGRESS ), "Render is still in progress" }, - {0} + { "RS_OK", BeCast( RS_OK ), "Render step succeeded" }, + { "RS_FAILED", BeCast( RS_FAILED ), "Render failed" }, + { "RS_IN_PROGRESS", BeCast( RS_IN_PROGRESS ), "Render is still in progress" }, + { 0 } }; BLUE_REGISTER_ENUM( "RENDERSTEP_RESULT", TriStepResult, TriRenderStepResultChooser ); @@ -19,64 +18,50 @@ BLUE_REGISTER_ENUM( "RENDERSTEP_RESULT", TriStepResult, TriRenderStepResultChoos const Be::ClassInfo* TriRenderStep::ExposeToBlue() { - EXPOSURE_BEGIN(TriRenderStep, "" ) + EXPOSURE_BEGIN( TriRenderStep, "" ) MAP_INTERFACE( TriRenderStep ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this step (for the benefit of the user)", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this step (for the benefit of the user)", + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "enabled", - m_enabled, - "Enabled/disabled flag: disabled steps are not executed", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "enabled", + m_enabled, + "Enabled/disabled flag: disabled steps are not executed", + Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "debugCaptureGpuTime", GetCaptureGpuTime, SetCaptureGpuTime, - "Enable/disable capturing time it takes to execture the step on GPU" - ) + "Enable/disable capturing time it takes to execture the step on GPU" ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "gpuTime", GpuTime, - "Time it takes to execture the step on GPU in milliseconds (if debugCaptureGpuTime is on)" - ) + "Time it takes to execture the step on GPU in milliseconds (if debugCaptureGpuTime is on)" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "debugCaptureCpuTime", GetCaptureCpuTime, SetCaptureCpuTime, - "Enable/disable capturing time it takes to execture the step on CPU" - ) + "Enable/disable capturing time it takes to execture the step on CPU" ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "cpuTime", CpuTime, - "Time it takes to execture the step on CPU in milliseconds (if debugCaptureGpuTime is on)" - ) + "Time it takes to execture the step on CPU in milliseconds (if debugCaptureGpuTime is on)" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "statName", GetStatName, SetStatName, "Blue statistics stat name for CPU/GPU timers. When set to a non-empty string and capturing\n" - "timing is enabled, the step will post timings to a statistics entry with the same name" - ) + "timing is enabled, the step will post timings to a statistics entry with the same name" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepClear.cpp b/trinity/RenderJob/TriStepClear.cpp index 3ced43372..30dd77f4f 100644 --- a/trinity/RenderJob/TriStepClear.cpp +++ b/trinity/RenderJob/TriStepClear.cpp @@ -12,10 +12,9 @@ TriStepClear::TriStepClear( IRoot* lockobj ) : m_isDepthCleared( true ), m_isStencilCleared( false ) { - } -TriStepClear::~TriStepClear(void) +TriStepClear::~TriStepClear( void ) { } @@ -40,14 +39,13 @@ TriStepResult TriStepClear::Execute( Be::Time realTime, Be::Time simTime, Tr2Ren } uint32_t c = Color( - max(min(m_color.r, 1.0f), 0.0f), - max(min(m_color.g, 1.0f), 0.0f), - max(min(m_color.b, 1.0f), 0.0f), - max(min(m_color.a, 1.0f), 0.0f) - ); + max( min( m_color.r, 1.0f ), 0.0f ), + max( min( m_color.g, 1.0f ), 0.0f ), + max( min( m_color.b, 1.0f ), 0.0f ), + max( min( m_color.a, 1.0f ), 0.0f ) ); HRESULT hr = renderContext.Clear( flags, c, m_depth, m_stencil ); - if(!SUCCEEDED(hr)) + if( !SUCCEEDED( hr ) ) { CCP_LOGERR( "Clear failed" ); } diff --git a/trinity/RenderJob/TriStepClear.h b/trinity/RenderJob/TriStepClear.h index a666795a1..f5479f26a 100644 --- a/trinity/RenderJob/TriStepClear.h +++ b/trinity/RenderJob/TriStepClear.h @@ -7,20 +7,21 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepClear ) : public TriRenderStep +BLUE_CLASS( TriStepClear ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepClear( IRoot* lockobj = 0 ); - ~TriStepClear(void); + ~TriStepClear( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); #if BLUE_WITH_PYTHON // Python __init__ constructor - static PyObject* py__init__( PyObject* self, PyObject* args ); + static PyObject* py__init__( PyObject * self, PyObject * args ); #endif Color m_color; diff --git a/trinity/RenderJob/TriStepClearUav.cpp b/trinity/RenderJob/TriStepClearUav.cpp index 6ea36be9f..3de0ff030 100644 --- a/trinity/RenderJob/TriStepClearUav.cpp +++ b/trinity/RenderJob/TriStepClearUav.cpp @@ -8,8 +8,8 @@ // Description: // TriStepClearUav default constructor // -------------------------------------------------------------------------------------- -TriStepClearUav::TriStepClearUav( IRoot* lockobj ) - :m_clearWithFloat( false ), +TriStepClearUav::TriStepClearUav( IRoot* lockobj ) : + m_clearWithFloat( false ), m_floatValue( 0.f, 0.f, 0.f, 0.f ) { std::fill( std::begin( m_uintValue ), std::end( m_uintValue ), 0 ); @@ -17,7 +17,7 @@ TriStepClearUav::TriStepClearUav( IRoot* lockobj ) // -------------------------------------------------------------------------------------- // Description: -// Implements TriRenderStep. Clears writeable buffer with a set value. +// Implements TriRenderStep. Clears writeable buffer with a set value. // Arguments: // time - Current time // renderContext - Current render context diff --git a/trinity/RenderJob/TriStepClearUav.h b/trinity/RenderJob/TriStepClearUav.h index 35772818b..52021a6da 100644 --- a/trinity/RenderJob/TriStepClearUav.h +++ b/trinity/RenderJob/TriStepClearUav.h @@ -15,19 +15,21 @@ BLUE_DECLARE_INTERFACE( ITr2GpuBuffer ); // See Also: // TriRenderStep // -------------------------------------------------------------------------------------- -BLUE_CLASS( TriStepClearUav ) : public TriRenderStep +BLUE_CLASS( TriStepClearUav ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepClearUav( IRoot* lockobj = 0 ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); + private: #if BLUE_WITH_PYTHON // Python __init__ constructor - static PyObject* py__init__( PyObject* self, PyObject* args ); + static PyObject* py__init__( PyObject * self, PyObject * args ); #endif // Buffer to clear diff --git a/trinity/RenderJob/TriStepClearUav_Blue.cpp b/trinity/RenderJob/TriStepClearUav_Blue.cpp index 91fe52fa7..a70b9b22b 100644 --- a/trinity/RenderJob/TriStepClearUav_Blue.cpp +++ b/trinity/RenderJob/TriStepClearUav_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepClearUav ); #if BLUE_WITH_PYTHON // -------------------------------------------------------------------------------------- // Description: -// Python initializer function for TriStepClearUav. We can't use MAP_METHOD_AND_WRAP +// Python initializer function for TriStepClearUav. We can't use MAP_METHOD_AND_WRAP // because we need to support optional arguments. // Arguments: // self - This pointer @@ -73,7 +73,7 @@ PyObject* TriStepClearUav::py__init__( PyObject* self, PyObject* args ) const Be::ClassInfo* TriStepClearUav::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepClearUav, "" ) + EXPOSURE_BEGIN( TriStepClearUav, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepClearUav ) @@ -87,7 +87,7 @@ const Be::ClassInfo* TriStepClearUav::ExposeToBlue() MAP_ATTRIBUTE( "bitValue3", m_uintValue[3], "na", Be::READWRITE | Be::PERSIST ) MAP_METHOD( - "__init__", + "__init__", py__init__, "Creates a render step that clears a writable UAV buffer with a value.\n" ":param buffer: - Tr2UavBuffer to clear\n" diff --git a/trinity/RenderJob/TriStepClear_Blue.cpp b/trinity/RenderJob/TriStepClear_Blue.cpp index a32ef7a5e..580855e05 100644 --- a/trinity/RenderJob/TriStepClear_Blue.cpp +++ b/trinity/RenderJob/TriStepClear_Blue.cpp @@ -17,7 +17,7 @@ PyObject* TriStepClear::py__init__( PyObject* self, PyObject* args ) PyObject* depth = NULL; PyObject* stencil = NULL; - if( !PyArg_ParseTuple( args, "|OOO", &color, &depth, &stencil) ) + if( !PyArg_ParseTuple( args, "|OOO", &color, &depth, &stencil ) ) { return NULL; } @@ -65,7 +65,7 @@ PyObject* TriStepClear::py__init__( PyObject* self, PyObject* args ) const Be::ClassInfo* TriStepClear::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepClear, "" ) + EXPOSURE_BEGIN( TriStepClear, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepClear ) @@ -78,7 +78,7 @@ const Be::ClassInfo* TriStepClear::ExposeToBlue() MAP_ATTRIBUTE( "isStencilCleared", m_isStencilCleared, "na", Be::READWRITE | Be::PERSIST ) MAP_METHOD( - "__init__", + "__init__", py__init__, "Creates a render step that performs a Clear() on the currently set" "\nRT back-buffer / depth-stencil. When optional arguments are not set" @@ -88,8 +88,7 @@ const Be::ClassInfo* TriStepClear::ExposeToBlue() "\n:param depth: float or None (default None)" "\n:type depth: Optional[float | None]" "\n:param stencil: uint or None (default None)" - "\n:type stencil: Optional[int | None]" - ) + "\n:type stencil: Optional[int | None]" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepCopyRenderTarget.cpp b/trinity/RenderJob/TriStepCopyRenderTarget.cpp index 1cc28f796..8ca22ab7f 100644 --- a/trinity/RenderJob/TriStepCopyRenderTarget.cpp +++ b/trinity/RenderJob/TriStepCopyRenderTarget.cpp @@ -49,7 +49,7 @@ TriStepResult TriStepCopyRenderTarget::Execute( Be::Time realTime, Be::Time simT { const auto& vp = *m_sourceViewport; Tr2TextureSubresource src( 0 ); - src.SetRect( (uint32_t)vp.x, (uint32_t)vp.y, (uint32_t)(vp.x + vp.width), (uint32_t)(vp.y + vp.height) ); + src.SetRect( (uint32_t)vp.x, (uint32_t)vp.y, (uint32_t)( vp.x + vp.width ), (uint32_t)( vp.y + vp.height ) ); if( vp.width <= 0 || vp.height <= 0 ) { return RS_OK; @@ -75,8 +75,7 @@ TriStepResult TriStepCopyRenderTarget::Execute( Be::Time realTime, Be::Time simT hr = m_destinationRT->GetRenderTarget().CopySubresourceRegion( dest, *m_sourceRT, src, renderContext ); } } - else - if( m_destinationTexture && m_destinationTexture->GetTexture() ) + else if( m_destinationTexture && m_destinationTexture->GetTexture() ) { Tr2TextureSubresource destView; destView.m_box.left = destX; @@ -89,7 +88,7 @@ TriStepResult TriStepCopyRenderTarget::Execute( Be::Time realTime, Be::Time simT sourceView.m_box.left = vp.x; sourceView.m_box.top = vp.y; sourceView.m_box.right = vp.x + vp.width; - sourceView.m_box.bottom = vp.y + vp.height; + sourceView.m_box.bottom = vp.y + vp.height; } hr = m_destinationTexture->GetTexture()->CopySubresourceRegion( destView, *m_sourceRT, sourceView, renderContext ); diff --git a/trinity/RenderJob/TriStepCopyRenderTarget.h b/trinity/RenderJob/TriStepCopyRenderTarget.h index 6dbbd0396..676e6b9e3 100644 --- a/trinity/RenderJob/TriStepCopyRenderTarget.h +++ b/trinity/RenderJob/TriStepCopyRenderTarget.h @@ -17,24 +17,25 @@ BLUE_DECLARE( TriViewport ); // SeeAlso: // TriRenderStep // -------------------------------------------------------------------------------- -BLUE_CLASS( TriStepCopyRenderTarget ) : public TriRenderStep +BLUE_CLASS( TriStepCopyRenderTarget ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepCopyRenderTarget( IRoot* lockobj = 0 ); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); private: #if BLUE_WITH_PYTHON - static PyObject* PyInitLowLevel( PyObject* self, PyObject* args ); + static PyObject* PyInitLowLevel( PyObject * self, PyObject * args ); #endif Tr2RenderTargetPtr m_destinationRT; Tr2RenderTargetPtr m_sourceRT; - TriTextureResPtr m_destinationTexture; + TriTextureResPtr m_destinationTexture; TriViewportPtr m_sourceViewport; TriViewportPtr m_destinationViewport; diff --git a/trinity/RenderJob/TriStepCopyRenderTarget_Blue.cpp b/trinity/RenderJob/TriStepCopyRenderTarget_Blue.cpp index 70dfa5b55..db7d517c7 100644 --- a/trinity/RenderJob/TriStepCopyRenderTarget_Blue.cpp +++ b/trinity/RenderJob/TriStepCopyRenderTarget_Blue.cpp @@ -75,7 +75,7 @@ PyObject* TriStepCopyRenderTarget::PyInitLowLevel( PyObject* self, PyObject* arg pThis->m_sourceViewport = viewport; } } - + Py_RETURN_NONE; } @@ -86,24 +86,23 @@ const Be::ClassInfo* TriStepCopyRenderTarget::ExposeToBlue() EXPOSURE_BEGIN( TriStepCopyRenderTarget, "" ) MAP_INTERFACE( TriStepCopyRenderTarget ) - MAP_ATTRIBUTE( "Destination", m_destinationRT, "", Be::READWRITE) - MAP_ATTRIBUTE( "destinationTexture", m_destinationTexture, "", Be::READWRITE) - MAP_ATTRIBUTE( "Source", m_sourceRT, "", Be::READWRITE) - MAP_ATTRIBUTE( "sourceViewport", m_sourceViewport, "", Be::READWRITE) - MAP_ATTRIBUTE( "destinationViewport", m_destinationViewport, "", Be::READWRITE) + MAP_ATTRIBUTE( "Destination", m_destinationRT, "", Be::READWRITE ) + MAP_ATTRIBUTE( "destinationTexture", m_destinationTexture, "", Be::READWRITE ) + MAP_ATTRIBUTE( "Source", m_sourceRT, "", Be::READWRITE ) + MAP_ATTRIBUTE( "sourceViewport", m_sourceViewport, "", Be::READWRITE ) + MAP_ATTRIBUTE( "destinationViewport", m_destinationViewport, "", Be::READWRITE ) - MAP_METHOD( - "__init__", - PyInitLowLevel, - ":param dest: copy destination\n" + MAP_METHOD( + "__init__", + PyInitLowLevel, + ":param dest: copy destination\n" ":type dest: Optional[Tr2RenderTarget | TriTextureRes]\n" - ":param source: copy source\n" + ":param source: copy source\n" ":type source: Optional[Tr2RenderTarget]\n" - ":param destViewport: destination rectangle\n" + ":param destViewport: destination rectangle\n" ":type destViewport: Optional[TriViewport]\n" - ":param sourceViewport: source rectangle\n" - ":type sourceViewport: Optional[TriViewport]\n" - ) + ":param sourceViewport: source rectangle\n" + ":type sourceViewport: Optional[TriViewport]\n" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepEnableWireframeMode.cpp b/trinity/RenderJob/TriStepEnableWireframeMode.cpp index 1288cd9b7..36b2eb824 100644 --- a/trinity/RenderJob/TriStepEnableWireframeMode.cpp +++ b/trinity/RenderJob/TriStepEnableWireframeMode.cpp @@ -4,12 +4,12 @@ #include "TriStepEnableWireframeMode.h" #include "ITr2VisualizationModeRenderer.h" -TriStepEnableWireframeMode::TriStepEnableWireframeMode( IRoot* lockobj ) -: m_enableWireframe( false ) +TriStepEnableWireframeMode::TriStepEnableWireframeMode( IRoot* lockobj ) : + m_enableWireframe( false ) { } -TriStepEnableWireframeMode::~TriStepEnableWireframeMode(void) +TriStepEnableWireframeMode::~TriStepEnableWireframeMode( void ) { } diff --git a/trinity/RenderJob/TriStepEnableWireframeMode.h b/trinity/RenderJob/TriStepEnableWireframeMode.h index 9a19d6381..af55d9ac9 100644 --- a/trinity/RenderJob/TriStepEnableWireframeMode.h +++ b/trinity/RenderJob/TriStepEnableWireframeMode.h @@ -12,20 +12,21 @@ BLUE_DECLARE_INTERFACE( ITr2VisualizationModeRenderer ); // ------------------------------------------------------------- // Description: -// TriStepEnableWireframeMode is a render step that +// TriStepEnableWireframeMode is a render step that // sets the wireframe for a renderjob. // SeeAlso: // TriRenderStep // ------------------------------------------------------------- -BLUE_CLASS( TriStepEnableWireframeMode ) : public TriRenderStep +BLUE_CLASS( TriStepEnableWireframeMode ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); TriStepEnableWireframeMode( IRoot* lockobj = 0 ); - ~TriStepEnableWireframeMode(void); + ~TriStepEnableWireframeMode( void ); - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); protected: void py__init__( bool value ); diff --git a/trinity/RenderJob/TriStepEnableWireframeMode_Blue.cpp b/trinity/RenderJob/TriStepEnableWireframeMode_Blue.cpp index 674580753..d0f570fc6 100644 --- a/trinity/RenderJob/TriStepEnableWireframeMode_Blue.cpp +++ b/trinity/RenderJob/TriStepEnableWireframeMode_Blue.cpp @@ -8,24 +8,21 @@ BLUE_DEFINE( TriStepEnableWireframeMode ); const Be::ClassInfo* TriStepEnableWireframeMode::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepEnableWireframeMode, "" ) + EXPOSURE_BEGIN( TriStepEnableWireframeMode, "" ) MAP_INTERFACE( TriStepEnableWireframeMode ) - MAP_ATTRIBUTE( - "enableWireframe", - m_enableWireframe, - "Enable wireframe for the object", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "enableWireframe", + m_enableWireframe, + "Enable wireframe for the object", + Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 1, "Creates a render step that enables/disables wireframe rendering.\n" - ":param enable: True/False (default False)" - ) + ":param enable: True/False (default False)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepFilterVisibilityResults.cpp b/trinity/RenderJob/TriStepFilterVisibilityResults.cpp index ad84f4a1a..89e80801a 100644 --- a/trinity/RenderJob/TriStepFilterVisibilityResults.cpp +++ b/trinity/RenderJob/TriStepFilterVisibilityResults.cpp @@ -4,23 +4,23 @@ #include "TriStepFilterVisibilityResults.h" #include "Tr2VisibilityResults.h" -TriStepFilterVisibilityResults::TriStepFilterVisibilityResults( IRoot* lockobj ) -: m_eventFilter( -1 ), +TriStepFilterVisibilityResults::TriStepFilterVisibilityResults( IRoot* lockobj ) : + m_eventFilter( -1 ), m_filterType( EXCLUDE_OBJECTS_IN_LIST ), PARENTLOCK( m_objects ) { } -TriStepFilterVisibilityResults::~TriStepFilterVisibilityResults(void) +TriStepFilterVisibilityResults::~TriStepFilterVisibilityResults( void ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- -void TriStepFilterVisibilityResults::py__init__( - Tr2VisibilityResults* input, +void TriStepFilterVisibilityResults::py__init__( + Tr2VisibilityResults* input, Tr2VisibilityResults* output, Be::Optional eventFilter, Be::Optional filter ) @@ -40,7 +40,7 @@ void TriStepFilterVisibilityResults::py__init__( // ------------------------------------------------------------- // Description: // Implements TriRenderStep method. Processes input -// visibility result list to produce a new one filtering +// visibility result list to produce a new one filtering // visibility events. Removes events not present on m_eventFilter // bitfield filter. For events that specifies object instances // does filtering according to filter type and objects list. @@ -88,7 +88,7 @@ TriStepResult TriStepFilterVisibilityResults::Execute( Be::Time realTime, Be::Ti // ------------------------------------------------------------- // Description: -// Sets visibility event type filter. +// Sets visibility event type filter. // Arguments: // eventFilter - Visibility event type filter composed of // Tr2VisibilityEvent::EventType bits. Events that diff --git a/trinity/RenderJob/TriStepFilterVisibilityResults.h b/trinity/RenderJob/TriStepFilterVisibilityResults.h index 72c1bf1e1..de27651e6 100644 --- a/trinity/RenderJob/TriStepFilterVisibilityResults.h +++ b/trinity/RenderJob/TriStepFilterVisibilityResults.h @@ -19,22 +19,23 @@ BLUE_DECLARE_IVECTOR( IRoot ); // SeeAlso: // TriRenderStep, Tr2VisibilityResults // ------------------------------------------------------------- -BLUE_CLASS( TriStepFilterVisibilityResults ) : public TriRenderStep +BLUE_CLASS( TriStepFilterVisibilityResults ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); TriStepFilterVisibilityResults( IRoot* lockobj = 0 ); - ~TriStepFilterVisibilityResults(void); + ~TriStepFilterVisibilityResults( void ); - void py__init__( - Tr2VisibilityResults* input, - Tr2VisibilityResults* output, + void py__init__( + Tr2VisibilityResults * input, + Tr2VisibilityResults * output, Be::Optional eventFilter, Be::Optional filter ); // RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Type of per-object filter enum FilterType @@ -45,11 +46,11 @@ BLUE_CLASS( TriStepFilterVisibilityResults ) : public TriRenderStep EXCLUDE_OBJECTS_IN_LIST, }; - void SetInputResults( Tr2VisibilityResults* results ) + void SetInputResults( Tr2VisibilityResults * results ) { m_inputResults = results; } - void SetOutputResults( Tr2VisibilityResults* results ) + void SetOutputResults( Tr2VisibilityResults * results ) { m_outputResults = results; } diff --git a/trinity/RenderJob/TriStepFilterVisibilityResults_Blue.cpp b/trinity/RenderJob/TriStepFilterVisibilityResults_Blue.cpp index 1977a267e..71fb9454e 100644 --- a/trinity/RenderJob/TriStepFilterVisibilityResults_Blue.cpp +++ b/trinity/RenderJob/TriStepFilterVisibilityResults_Blue.cpp @@ -4,50 +4,48 @@ #include "TriStepFilterVisibilityResults.h" #include "Tr2VisibilityResults.h" -const Be::VarChooser TriVisibilityEventTypeChooser[] = -{ +const Be::VarChooser TriVisibilityEventTypeChooser[] = { // Name Value Docstring - { "TRIVISIBILITY_QUERY_BEGIN", BeCast( Tr2VisibilityEvent::QUERY_BEGIN ), "Begin of visibility query" }, - { "TRIVISIBILITY_QUERY_END", BeCast( Tr2VisibilityEvent::QUERY_END ), "End of visibility query" }, - { "TRIVISIBILITY_PORTAL_ENTER", BeCast( Tr2VisibilityEvent::PORTAL_ENTER ), "Enter a portal or mirror" }, - { "TRIVISIBILITY_PORTAL_EXIT", BeCast( Tr2VisibilityEvent::PORTAL_EXIT ), "Exit a portal or mirror" }, - { "TRIVISIBILITY_PORTAL_PRE_EXIT", BeCast( Tr2VisibilityEvent::PORTAL_PRE_EXIT ), "Before exiting a portal or mirror" }, - { "TRIVISIBILITY_CELL_IMMEDIATE_REPORT", BeCast( Tr2VisibilityEvent::CELL_IMMEDIATE_REPORT ), "Entering a cell" }, - { "TRIVISIBILITY_VIEW_PARAMETERS_CHANGED", BeCast( Tr2VisibilityEvent::VIEW_PARAMETERS_CHANGED ), "View parameters changed" }, - { "TRIVISIBILITY_INSTANCE_VISIBLE", BeCast( Tr2VisibilityEvent::INSTANCE_VISIBLE ), "Object or light instance visible" }, - { "TRIVISIBILITY_REMOVAL_SUGGESTED", BeCast( Tr2VisibilityEvent::REMOVAL_SUGGESTED ), "" }, - { "TRIVISIBILITY_INSTANCE_IMMEDIATE_REPORT", BeCast( Tr2VisibilityEvent::INSTANCE_IMMEDIATE_REPORT ), "" }, - { "TRIVISIBILITY_REGION_OF_INFLUENCE_ACTIVE", BeCast( Tr2VisibilityEvent::REGION_OF_INFLUENCE_ACTIVE ), "Entering a light region of influence" }, - { "TRIVISIBILITY_REGION_OF_INFLUENCE_INACTIVE", BeCast( Tr2VisibilityEvent::REGION_OF_INFLUENCE_INACTIVE ), "Exiting a light region of influence" }, - { "TRIVISIBILITY_STENCIL_MASK", BeCast( Tr2VisibilityEvent::STENCIL_MASK ), "" }, - { "TRIVISIBILITY_TEXT_MESSAGE", BeCast( Tr2VisibilityEvent::TEXT_MESSAGE ), "" }, - { "TRIVISIBILITY_DRAW_LINE_2D", BeCast( Tr2VisibilityEvent::DRAW_LINE_2D ), "" }, - { "TRIVISIBILITY_DRAW_LINE_3D", BeCast( Tr2VisibilityEvent::DRAW_LINE_3D ), "" }, - { "TRIVISIBILITY_DRAW_BUFFER", BeCast( Tr2VisibilityEvent::DRAW_BUFFER ), "" }, - { "TRIVISIBILITY_OCCLUSION_QUERY_BEGIN", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_BEGIN ), "" }, - { "TRIVISIBILITY_OCCLUSION_QUERY_END", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_END ), "" }, - { "TRIVISIBILITY_OCCLUSION_QUERY_GET_RESULT", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_GET_RESULT ), "" }, - { "TRIVISIBILITY_OCCLUSION_QUERY_DRAW_DEPTH_TEST", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_DRAW_DEPTH_TEST ), "" }, - { "TRIVISIBILITY_INSTANCE_DRAW_DEPTH", BeCast( Tr2VisibilityEvent::INSTANCE_DRAW_DEPTH ), "" }, - { "TRIVISIBILITY_FLUSH_DEPTH", BeCast( Tr2VisibilityEvent::FLUSH_DEPTH ), "" }, - { "TRIVISIBILITY_DEPTH_PASS_BEGIN", BeCast( Tr2VisibilityEvent::DEPTH_PASS_BEGIN ), "" }, - { "TRIVISIBILITY_DEPTH_PASS_END", BeCast( Tr2VisibilityEvent::DEPTH_PASS_END ), "" }, - { "TRIVISIBILITY_COLOR_PASS_BEGIN", BeCast( Tr2VisibilityEvent::COLOR_PASS_BEGIN ), "" }, - { "TRIVISIBILITY_COLOR_PASS_END", BeCast( Tr2VisibilityEvent::COLOR_PASS_END ), "" }, - { "TRIVISIBILITY_TILE_BEGIN", BeCast( Tr2VisibilityEvent::TILE_BEGIN ), "" }, - { "TRIVISIBILITY_TILE_END", BeCast( Tr2VisibilityEvent::TILE_END ), "" }, - { "TRIVISIBILITY_FLUSH_GPU_COMMAND_BUFFER", BeCast( Tr2VisibilityEvent::FLUSH_GPU_COMMAND_BUFFER ), "" }, - {0} + { "TRIVISIBILITY_QUERY_BEGIN", BeCast( Tr2VisibilityEvent::QUERY_BEGIN ), "Begin of visibility query" }, + { "TRIVISIBILITY_QUERY_END", BeCast( Tr2VisibilityEvent::QUERY_END ), "End of visibility query" }, + { "TRIVISIBILITY_PORTAL_ENTER", BeCast( Tr2VisibilityEvent::PORTAL_ENTER ), "Enter a portal or mirror" }, + { "TRIVISIBILITY_PORTAL_EXIT", BeCast( Tr2VisibilityEvent::PORTAL_EXIT ), "Exit a portal or mirror" }, + { "TRIVISIBILITY_PORTAL_PRE_EXIT", BeCast( Tr2VisibilityEvent::PORTAL_PRE_EXIT ), "Before exiting a portal or mirror" }, + { "TRIVISIBILITY_CELL_IMMEDIATE_REPORT", BeCast( Tr2VisibilityEvent::CELL_IMMEDIATE_REPORT ), "Entering a cell" }, + { "TRIVISIBILITY_VIEW_PARAMETERS_CHANGED", BeCast( Tr2VisibilityEvent::VIEW_PARAMETERS_CHANGED ), "View parameters changed" }, + { "TRIVISIBILITY_INSTANCE_VISIBLE", BeCast( Tr2VisibilityEvent::INSTANCE_VISIBLE ), "Object or light instance visible" }, + { "TRIVISIBILITY_REMOVAL_SUGGESTED", BeCast( Tr2VisibilityEvent::REMOVAL_SUGGESTED ), "" }, + { "TRIVISIBILITY_INSTANCE_IMMEDIATE_REPORT", BeCast( Tr2VisibilityEvent::INSTANCE_IMMEDIATE_REPORT ), "" }, + { "TRIVISIBILITY_REGION_OF_INFLUENCE_ACTIVE", BeCast( Tr2VisibilityEvent::REGION_OF_INFLUENCE_ACTIVE ), "Entering a light region of influence" }, + { "TRIVISIBILITY_REGION_OF_INFLUENCE_INACTIVE", BeCast( Tr2VisibilityEvent::REGION_OF_INFLUENCE_INACTIVE ), "Exiting a light region of influence" }, + { "TRIVISIBILITY_STENCIL_MASK", BeCast( Tr2VisibilityEvent::STENCIL_MASK ), "" }, + { "TRIVISIBILITY_TEXT_MESSAGE", BeCast( Tr2VisibilityEvent::TEXT_MESSAGE ), "" }, + { "TRIVISIBILITY_DRAW_LINE_2D", BeCast( Tr2VisibilityEvent::DRAW_LINE_2D ), "" }, + { "TRIVISIBILITY_DRAW_LINE_3D", BeCast( Tr2VisibilityEvent::DRAW_LINE_3D ), "" }, + { "TRIVISIBILITY_DRAW_BUFFER", BeCast( Tr2VisibilityEvent::DRAW_BUFFER ), "" }, + { "TRIVISIBILITY_OCCLUSION_QUERY_BEGIN", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_BEGIN ), "" }, + { "TRIVISIBILITY_OCCLUSION_QUERY_END", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_END ), "" }, + { "TRIVISIBILITY_OCCLUSION_QUERY_GET_RESULT", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_GET_RESULT ), "" }, + { "TRIVISIBILITY_OCCLUSION_QUERY_DRAW_DEPTH_TEST", BeCast( Tr2VisibilityEvent::OCCLUSION_QUERY_DRAW_DEPTH_TEST ), "" }, + { "TRIVISIBILITY_INSTANCE_DRAW_DEPTH", BeCast( Tr2VisibilityEvent::INSTANCE_DRAW_DEPTH ), "" }, + { "TRIVISIBILITY_FLUSH_DEPTH", BeCast( Tr2VisibilityEvent::FLUSH_DEPTH ), "" }, + { "TRIVISIBILITY_DEPTH_PASS_BEGIN", BeCast( Tr2VisibilityEvent::DEPTH_PASS_BEGIN ), "" }, + { "TRIVISIBILITY_DEPTH_PASS_END", BeCast( Tr2VisibilityEvent::DEPTH_PASS_END ), "" }, + { "TRIVISIBILITY_COLOR_PASS_BEGIN", BeCast( Tr2VisibilityEvent::COLOR_PASS_BEGIN ), "" }, + { "TRIVISIBILITY_COLOR_PASS_END", BeCast( Tr2VisibilityEvent::COLOR_PASS_END ), "" }, + { "TRIVISIBILITY_TILE_BEGIN", BeCast( Tr2VisibilityEvent::TILE_BEGIN ), "" }, + { "TRIVISIBILITY_TILE_END", BeCast( Tr2VisibilityEvent::TILE_END ), "" }, + { "TRIVISIBILITY_FLUSH_GPU_COMMAND_BUFFER", BeCast( Tr2VisibilityEvent::FLUSH_GPU_COMMAND_BUFFER ), "" }, + { 0 } }; BLUE_REGISTER_ENUM( "TRIVISIBILITY_EVENT_TYPE", Tr2VisibilityEvent::EventType, TriVisibilityEventTypeChooser ); -const Be::VarChooser TriVisibilityResultsFilterTypeChooser[] = -{ +const Be::VarChooser TriVisibilityResultsFilterTypeChooser[] = { // Name Value Docstring - { "TRIVISIBILITY_FILTER_ONLY_OBJECTS_IN_LIST", BeCast( TriStepFilterVisibilityResults::ONLY_OBJECTS_IN_LIST ), "Only allow objects/lights in the objects list" }, - { "TRIVISIBILITY_FILTER_EXCLUDE_OBJECTS_IN_LIST", BeCast( TriStepFilterVisibilityResults::EXCLUDE_OBJECTS_IN_LIST ), "Exclude objects/lights in the objects list" }, - {0} + { "TRIVISIBILITY_FILTER_ONLY_OBJECTS_IN_LIST", BeCast( TriStepFilterVisibilityResults::ONLY_OBJECTS_IN_LIST ), "Only allow objects/lights in the objects list" }, + { "TRIVISIBILITY_FILTER_EXCLUDE_OBJECTS_IN_LIST", BeCast( TriStepFilterVisibilityResults::EXCLUDE_OBJECTS_IN_LIST ), "Exclude objects/lights in the objects list" }, + { 0 } }; BLUE_REGISTER_ENUM( "TRIVISIBILITY_FILTER_TYPE", TriStepFilterVisibilityResults::FilterType, TriVisibilityResultsFilterTypeChooser ); @@ -57,63 +55,51 @@ BLUE_DEFINE( TriStepFilterVisibilityResults ); const Be::ClassInfo* TriStepFilterVisibilityResults::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepFilterVisibilityResults, "Render step for filtering visibility results list" ) + EXPOSURE_BEGIN( TriStepFilterVisibilityResults, "Render step for filtering visibility results list" ) MAP_INTERFACE( TriStepFilterVisibilityResults ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "eventFilter", + MAP_ATTRIBUTE_WITH_CHOOSER( + "eventFilter", m_eventFilter, "Which events are copied to new visibility results", Be::READWRITE | Be::PERSIST, - TriVisibilityEventTypeChooser - ) + TriVisibilityEventTypeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "filterType", + MAP_ATTRIBUTE_WITH_CHOOSER( + "filterType", m_filterType, "Type of per-object filtering to perform on visibility results", Be::READWRITE | Be::PERSIST | Be::ENUM, - TriVisibilityResultsFilterTypeChooser - ) + TriVisibilityResultsFilterTypeChooser ) - MAP_ATTRIBUTE - ( - "objects", + MAP_ATTRIBUTE( + "objects", m_objects, "List of objects to include/exclude from visibility results", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "inputResults", + MAP_ATTRIBUTE( + "inputResults", m_inputResults, "Input visibility results to be filtered", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "outputResults", + MAP_ATTRIBUTE( + "outputResults", m_outputResults, "Output visibility results", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 4, "Create a visibility results filter to exclude objects/events from visibility results\n" ":param source: source visibility results\n" ":param dest: destination visibility results\n" ":param eventFilter: Which events are copied to new visibility results (default is All)\n" - ":param filterType: Type of per-object filtering to perform on visibility results\n" - ) + ":param filterType: Type of per-object filtering to perform on visibility results\n" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepGenerateMipMaps.cpp b/trinity/RenderJob/TriStepGenerateMipMaps.cpp index 07184b95d..cc6a9e042 100644 --- a/trinity/RenderJob/TriStepGenerateMipMaps.cpp +++ b/trinity/RenderJob/TriStepGenerateMipMaps.cpp @@ -8,7 +8,7 @@ TriStepGenerateMipMaps::TriStepGenerateMipMaps( IRoot* lockobj ) { } -TriStepGenerateMipMaps::~TriStepGenerateMipMaps(void) +TriStepGenerateMipMaps::~TriStepGenerateMipMaps( void ) { } diff --git a/trinity/RenderJob/TriStepGenerateMipMaps.h b/trinity/RenderJob/TriStepGenerateMipMaps.h index 1eb062864..a307ad601 100644 --- a/trinity/RenderJob/TriStepGenerateMipMaps.h +++ b/trinity/RenderJob/TriStepGenerateMipMaps.h @@ -8,18 +8,19 @@ #include "TriRenderStep.h" #include "Tr2RenderTarget.h" -BLUE_CLASS( TriStepGenerateMipMaps ) : public TriRenderStep +BLUE_CLASS( TriStepGenerateMipMaps ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepGenerateMipMaps( IRoot* lockobj = 0); - ~TriStepGenerateMipMaps(void); + + TriStepGenerateMipMaps( IRoot* lockobj = 0 ); + ~TriStepGenerateMipMaps( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void py__init__( Tr2RenderTarget* rt ); + void py__init__( Tr2RenderTarget * rt ); protected: Tr2RenderTargetPtr m_renderTarget; diff --git a/trinity/RenderJob/TriStepGenerateMipMaps_Blue.cpp b/trinity/RenderJob/TriStepGenerateMipMaps_Blue.cpp index 825998dbb..2e71383cd 100644 --- a/trinity/RenderJob/TriStepGenerateMipMaps_Blue.cpp +++ b/trinity/RenderJob/TriStepGenerateMipMaps_Blue.cpp @@ -10,22 +10,20 @@ BLUE_DEFINE( TriStepGenerateMipMaps ); const Be::ClassInfo* TriStepGenerateMipMaps::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepGenerateMipMaps, "" ) + EXPOSURE_BEGIN( TriStepGenerateMipMaps, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepGenerateMipMaps ) - MAP_ATTRIBUTE("renderTarget", m_renderTarget, "na", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "renderTarget", m_renderTarget, "na", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Creates a render job that generates mipmaps. Note that the target of a TriStepResolve\n" "generates the mipmaps, so use this only with non-MSAA targets.\n" - ":param renderTarget: a Tr2RenderTarget" - ) + ":param renderTarget: a Tr2RenderTarget" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepPopDepthStencil.cpp b/trinity/RenderJob/TriStepPopDepthStencil.cpp index c7ec0cc50..396873621 100644 --- a/trinity/RenderJob/TriStepPopDepthStencil.cpp +++ b/trinity/RenderJob/TriStepPopDepthStencil.cpp @@ -9,7 +9,7 @@ TriStepPopDepthStencil::TriStepPopDepthStencil( IRoot* lockobj ) { } -TriStepPopDepthStencil::~TriStepPopDepthStencil(void) +TriStepPopDepthStencil::~TriStepPopDepthStencil( void ) { } diff --git a/trinity/RenderJob/TriStepPopDepthStencil.h b/trinity/RenderJob/TriStepPopDepthStencil.h index 2270245b9..e38441f59 100644 --- a/trinity/RenderJob/TriStepPopDepthStencil.h +++ b/trinity/RenderJob/TriStepPopDepthStencil.h @@ -7,16 +7,17 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepPopDepthStencil ) : public TriRenderStep +BLUE_CLASS( TriStepPopDepthStencil ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepPopDepthStencil( IRoot* lockobj = 0); - ~TriStepPopDepthStencil(void); + + TriStepPopDepthStencil( IRoot* lockobj = 0 ); + ~TriStepPopDepthStencil( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPopDepthStencil ); diff --git a/trinity/RenderJob/TriStepPopDepthStencil_Blue.cpp b/trinity/RenderJob/TriStepPopDepthStencil_Blue.cpp index 9c8a52ddb..c9809907f 100644 --- a/trinity/RenderJob/TriStepPopDepthStencil_Blue.cpp +++ b/trinity/RenderJob/TriStepPopDepthStencil_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepPopDepthStencil ); const Be::ClassInfo* TriStepPopDepthStencil::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPopDepthStencil, "" ) + EXPOSURE_BEGIN( TriStepPopDepthStencil, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPopDepthStencil ) diff --git a/trinity/RenderJob/TriStepPopProjection.h b/trinity/RenderJob/TriStepPopProjection.h index 810d73765..29011e8c8 100644 --- a/trinity/RenderJob/TriStepPopProjection.h +++ b/trinity/RenderJob/TriStepPopProjection.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPopProjection ) : public TriRenderStep +BLUE_CLASS( TriStepPopProjection ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPopProjection ); diff --git a/trinity/RenderJob/TriStepPopProjection_Blue.cpp b/trinity/RenderJob/TriStepPopProjection_Blue.cpp index a49db43b6..6bfc3e9eb 100644 --- a/trinity/RenderJob/TriStepPopProjection_Blue.cpp +++ b/trinity/RenderJob/TriStepPopProjection_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPopProjection ); const Be::ClassInfo* TriStepPopProjection::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPopProjection, "" ) + EXPOSURE_BEGIN( TriStepPopProjection, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPopProjection ) diff --git a/trinity/RenderJob/TriStepPopRenderTarget.h b/trinity/RenderJob/TriStepPopRenderTarget.h index 622c9454f..e0b4e6166 100644 --- a/trinity/RenderJob/TriStepPopRenderTarget.h +++ b/trinity/RenderJob/TriStepPopRenderTarget.h @@ -7,15 +7,16 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepPopRenderTarget ) : public TriRenderStep +BLUE_CLASS( TriStepPopRenderTarget ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepPopRenderTarget( IRoot* lockobj = 0); + + TriStepPopRenderTarget( IRoot* lockobj = 0 ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); void py__init__( uint32_t slot = 0 ); diff --git a/trinity/RenderJob/TriStepPopRenderTarget_Blue.cpp b/trinity/RenderJob/TriStepPopRenderTarget_Blue.cpp index 1ab47664f..dadef2726 100644 --- a/trinity/RenderJob/TriStepPopRenderTarget_Blue.cpp +++ b/trinity/RenderJob/TriStepPopRenderTarget_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepPopRenderTarget ); const Be::ClassInfo* TriStepPopRenderTarget::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPopRenderTarget, "" ) + EXPOSURE_BEGIN( TriStepPopRenderTarget, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPopRenderTarget ) diff --git a/trinity/RenderJob/TriStepPopViewTransform.h b/trinity/RenderJob/TriStepPopViewTransform.h index f9eea0f49..b330c8d63 100644 --- a/trinity/RenderJob/TriStepPopViewTransform.h +++ b/trinity/RenderJob/TriStepPopViewTransform.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPopViewTransform ) : public TriRenderStep +BLUE_CLASS( TriStepPopViewTransform ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPopViewTransform ); diff --git a/trinity/RenderJob/TriStepPopViewTransform_Blue.cpp b/trinity/RenderJob/TriStepPopViewTransform_Blue.cpp index 7abe2bf25..23d2269f0 100644 --- a/trinity/RenderJob/TriStepPopViewTransform_Blue.cpp +++ b/trinity/RenderJob/TriStepPopViewTransform_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPopViewTransform ); const Be::ClassInfo* TriStepPopViewTransform::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPopViewTransform, "" ) + EXPOSURE_BEGIN( TriStepPopViewTransform, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPopViewTransform ) diff --git a/trinity/RenderJob/TriStepPopViewport.h b/trinity/RenderJob/TriStepPopViewport.h index e5f065f48..fd3c3e452 100644 --- a/trinity/RenderJob/TriStepPopViewport.h +++ b/trinity/RenderJob/TriStepPopViewport.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPopViewport ) : public TriRenderStep +BLUE_CLASS( TriStepPopViewport ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPopViewport ); diff --git a/trinity/RenderJob/TriStepPopViewport_Blue.cpp b/trinity/RenderJob/TriStepPopViewport_Blue.cpp index 3a14d5915..cb67e371a 100644 --- a/trinity/RenderJob/TriStepPopViewport_Blue.cpp +++ b/trinity/RenderJob/TriStepPopViewport_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPopViewport ); const Be::ClassInfo* TriStepPopViewport::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPopViewport, "" ) + EXPOSURE_BEGIN( TriStepPopViewport, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPopViewport ) diff --git a/trinity/RenderJob/TriStepPresentSwapChain.h b/trinity/RenderJob/TriStepPresentSwapChain.h index ec9509738..65a0eae1b 100644 --- a/trinity/RenderJob/TriStepPresentSwapChain.h +++ b/trinity/RenderJob/TriStepPresentSwapChain.h @@ -9,12 +9,11 @@ BLUE_DECLARE( TriStepPresentSwapChain ); -class TriStepPresentSwapChain: - public TriRenderStep +class TriStepPresentSwapChain : public TriRenderStep { public: - EXPOSE_TO_BLUE(); - TriStepPresentSwapChain( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriStepPresentSwapChain( IRoot* lockobj = NULL ); //IRenderStep TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); diff --git a/trinity/RenderJob/TriStepPresentSwapChain_Blue.cpp b/trinity/RenderJob/TriStepPresentSwapChain_Blue.cpp index 930dbd2ad..31cc1c111 100644 --- a/trinity/RenderJob/TriStepPresentSwapChain_Blue.cpp +++ b/trinity/RenderJob/TriStepPresentSwapChain_Blue.cpp @@ -7,25 +7,21 @@ BLUE_DEFINE( TriStepPresentSwapChain ); const Be::ClassInfo* TriStepPresentSwapChain::ExposeToBlue() { - EXPOSURE_BEGIN( TriStepPresentSwapChain, "" ) - MAP_INTERFACE( TriStepPresentSwapChain ) + EXPOSURE_BEGIN( TriStepPresentSwapChain, "" ) + MAP_INTERFACE( TriStepPresentSwapChain ) MAP_INTERFACE( TriRenderStep ) - MAP_ATTRIBUTE - ( - "swapChain", - m_swapChain, - "The swap chain that the step should set", - Be::READWRITE - ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_ATTRIBUTE( + "swapChain", + m_swapChain, + "The swap chain that the step should set", + Be::READWRITE ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Create a step that will set a swap chain as active on the device.\n" - ":param swapChain: swap chain" - ) + ":param swapChain: swap chain" ) - EXPOSURE_CHAINTO( TriRenderStep ) + EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepPushDepthStencil.cpp b/trinity/RenderJob/TriStepPushDepthStencil.cpp index a33243daf..fb675c1f5 100644 --- a/trinity/RenderJob/TriStepPushDepthStencil.cpp +++ b/trinity/RenderJob/TriStepPushDepthStencil.cpp @@ -6,18 +6,18 @@ #include "Tr2DepthStencil.h" -TriStepPushDepthStencil::TriStepPushDepthStencil( IRoot* lockobj ) - : m_pushCurrent( false ) // need this flag to know the difference between pushing nothing, and pushing None to disable depthStencil +TriStepPushDepthStencil::TriStepPushDepthStencil( IRoot* lockobj ) : + m_pushCurrent( false ) // need this flag to know the difference between pushing nothing, and pushing None to disable depthStencil { } -TriStepPushDepthStencil::~TriStepPushDepthStencil(void) +TriStepPushDepthStencil::~TriStepPushDepthStencil( void ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // Arguments: // depthStencil - Initial value of depth stencil step attribute // -------------------------------------------------------------------------------------- diff --git a/trinity/RenderJob/TriStepPushDepthStencil.h b/trinity/RenderJob/TriStepPushDepthStencil.h index 32c6c9e88..ce9d56a21 100644 --- a/trinity/RenderJob/TriStepPushDepthStencil.h +++ b/trinity/RenderJob/TriStepPushDepthStencil.h @@ -9,21 +9,22 @@ BLUE_DECLARE( Tr2DepthStencil ); -BLUE_CLASS( TriStepPushDepthStencil ) : public TriRenderStep +BLUE_CLASS( TriStepPushDepthStencil ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepPushDepthStencil( IRoot* lockobj = 0); - ~TriStepPushDepthStencil(void); + + TriStepPushDepthStencil( IRoot* lockobj = 0 ); + ~TriStepPushDepthStencil( void ); void py__init__( Be::Optional depthStencil ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - Tr2DepthStencilPtr m_depthStencil; - bool m_pushCurrent; + Tr2DepthStencilPtr m_depthStencil; + bool m_pushCurrent; }; TYPEDEF_BLUECLASS( TriStepPushDepthStencil ); diff --git a/trinity/RenderJob/TriStepPushDepthStencil_Blue.cpp b/trinity/RenderJob/TriStepPushDepthStencil_Blue.cpp index 0d1fcba7e..3663c950d 100644 --- a/trinity/RenderJob/TriStepPushDepthStencil_Blue.cpp +++ b/trinity/RenderJob/TriStepPushDepthStencil_Blue.cpp @@ -9,22 +9,20 @@ BLUE_DEFINE( TriStepPushDepthStencil ); const Be::ClassInfo* TriStepPushDepthStencil::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPushDepthStencil, "" ) + EXPOSURE_BEGIN( TriStepPushDepthStencil, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPushDepthStencil ) - MAP_ATTRIBUTE("depthStencil", m_depthStencil, "na", Be::READWRITE ) - MAP_ATTRIBUTE("pushCurrent", m_pushCurrent, "If depthStencil is None, then push current but leave it bound (True), or actually disable depth testing (False).", Be::READWRITE ) + MAP_ATTRIBUTE( "depthStencil", m_depthStencil, "na", Be::READWRITE ) + MAP_ATTRIBUTE( "pushCurrent", m_pushCurrent, "If depthStencil is None, then push current but leave it bound (True), or actually disable depth testing (False).", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Creates a render job that pushes a depth stencil to the device\n" - ":param depthStencil: a Tr2DepthStencil" - ) + ":param depthStencil: a Tr2DepthStencil" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepPushProjection.h b/trinity/RenderJob/TriStepPushProjection.h index 5bb273acd..0be28b2e1 100644 --- a/trinity/RenderJob/TriStepPushProjection.h +++ b/trinity/RenderJob/TriStepPushProjection.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPushProjection ) : public TriRenderStep +BLUE_CLASS( TriStepPushProjection ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPushProjection ); diff --git a/trinity/RenderJob/TriStepPushProjection_Blue.cpp b/trinity/RenderJob/TriStepPushProjection_Blue.cpp index 864c173d2..845828c7b 100644 --- a/trinity/RenderJob/TriStepPushProjection_Blue.cpp +++ b/trinity/RenderJob/TriStepPushProjection_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPushProjection ); const Be::ClassInfo* TriStepPushProjection::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPushProjection, "" ) + EXPOSURE_BEGIN( TriStepPushProjection, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPushProjection ) diff --git a/trinity/RenderJob/TriStepPushRenderTarget.h b/trinity/RenderJob/TriStepPushRenderTarget.h index a753aca1a..d89c776c2 100644 --- a/trinity/RenderJob/TriStepPushRenderTarget.h +++ b/trinity/RenderJob/TriStepPushRenderTarget.h @@ -8,19 +8,21 @@ #include "TriRenderStep.h" #include "Tr2RenderTarget.h" -BLUE_CLASS( TriStepPushRenderTarget ) : public TriRenderStep +BLUE_CLASS( TriStepPushRenderTarget ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepPushRenderTarget( IRoot* lockobj = 0); + + TriStepPushRenderTarget( IRoot* lockobj = 0 ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); + + void py__init__( Tr2RenderTarget * rt, uint32_t slot = 0 ); - void py__init__( Tr2RenderTarget* rt, uint32_t slot = 0 ); private: - Tr2RenderTargetPtr m_renderTarget; + Tr2RenderTargetPtr m_renderTarget; uint32_t m_slot; }; diff --git a/trinity/RenderJob/TriStepPushRenderTarget_Blue.cpp b/trinity/RenderJob/TriStepPushRenderTarget_Blue.cpp index 88d6f4659..102b2d698 100644 --- a/trinity/RenderJob/TriStepPushRenderTarget_Blue.cpp +++ b/trinity/RenderJob/TriStepPushRenderTarget_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepPushRenderTarget ); const Be::ClassInfo* TriStepPushRenderTarget::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPushRenderTarget, "" ) + EXPOSURE_BEGIN( TriStepPushRenderTarget, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPushRenderTarget ) @@ -17,15 +17,13 @@ const Be::ClassInfo* TriStepPushRenderTarget::ExposeToBlue() MAP_ATTRIBUTE( "renderTarget", m_renderTarget, "na", Be::READWRITE ) MAP_ATTRIBUTE( "slot", m_slot, "", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, - 2, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, + 2, "Creates a render job that pushes a rendertarget to the device\n" ":param renderTarget: a Tr2RenderTarget\n" - ":param slot: render target slot" - ) + ":param slot: render target slot" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepPushViewTransform.h b/trinity/RenderJob/TriStepPushViewTransform.h index f6d80a268..1bf83a7ff 100644 --- a/trinity/RenderJob/TriStepPushViewTransform.h +++ b/trinity/RenderJob/TriStepPushViewTransform.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPushViewTransform ) : public TriRenderStep +BLUE_CLASS( TriStepPushViewTransform ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPushViewTransform ); diff --git a/trinity/RenderJob/TriStepPushViewTransform_Blue.cpp b/trinity/RenderJob/TriStepPushViewTransform_Blue.cpp index ee8e7e2d2..540cbd6bf 100644 --- a/trinity/RenderJob/TriStepPushViewTransform_Blue.cpp +++ b/trinity/RenderJob/TriStepPushViewTransform_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPushViewTransform ); const Be::ClassInfo* TriStepPushViewTransform::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPushViewTransform, "" ) + EXPOSURE_BEGIN( TriStepPushViewTransform, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPushViewTransform ) diff --git a/trinity/RenderJob/TriStepPushViewport.h b/trinity/RenderJob/TriStepPushViewport.h index 43cc40d14..d2b864196 100644 --- a/trinity/RenderJob/TriStepPushViewport.h +++ b/trinity/RenderJob/TriStepPushViewport.h @@ -8,12 +8,13 @@ #include "TriRenderStep.h" /// Wrapper around Tr2Renderer:: -BLUE_CLASS( TriStepPushViewport ) : public TriRenderStep +BLUE_CLASS( TriStepPushViewport ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); }; TYPEDEF_BLUECLASS( TriStepPushViewport ); diff --git a/trinity/RenderJob/TriStepPushViewport_Blue.cpp b/trinity/RenderJob/TriStepPushViewport_Blue.cpp index d19dd712d..53462451e 100644 --- a/trinity/RenderJob/TriStepPushViewport_Blue.cpp +++ b/trinity/RenderJob/TriStepPushViewport_Blue.cpp @@ -8,7 +8,7 @@ BLUE_DEFINE( TriStepPushViewport ); const Be::ClassInfo* TriStepPushViewport::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepPushViewport, "" ) + EXPOSURE_BEGIN( TriStepPushViewport, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepPushViewport ) diff --git a/trinity/RenderJob/TriStepPythonCB.cpp b/trinity/RenderJob/TriStepPythonCB.cpp index 61e0d35ce..fc88810c0 100644 --- a/trinity/RenderJob/TriStepPythonCB.cpp +++ b/trinity/RenderJob/TriStepPythonCB.cpp @@ -14,7 +14,7 @@ TriStepPythonCB::~TriStepPythonCB() { } -void TriStepPythonCB::SetCallback( const BlueScriptCallback& callback ) +void TriStepPythonCB::SetCallback( const BlueScriptCallback& callback ) { m_callback = callback; } @@ -26,16 +26,15 @@ TriStepResult TriStepPythonCB::Execute( Be::Time realTime, Be::Time simTime, Tr2 if( m_callback ) { - D3DPERF_EVENT(L"TriStepPythonCB callback"); - + D3DPERF_EVENT( L"TriStepPythonCB callback" ); + if( !m_callback.CallVoid() ) { #if BLUE_WITH_PYTHON - PyOS->PyFlushError("TriStepPythonCB: Callback failed!"); + PyOS->PyFlushError( "TriStepPythonCB: Callback failed!" ); #endif } } return RS_OK; } - diff --git a/trinity/RenderJob/TriStepPythonCB.h b/trinity/RenderJob/TriStepPythonCB.h index 48cd95101..583602483 100644 --- a/trinity/RenderJob/TriStepPythonCB.h +++ b/trinity/RenderJob/TriStepPythonCB.h @@ -7,26 +7,27 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepPythonCB ) : public TriRenderStep +BLUE_CLASS( TriStepPythonCB ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepPythonCB( IRoot* lockobj = 0 ); - ~TriStepPythonCB( ); + ~TriStepPythonCB(); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); private: BlueScriptCallback m_callback; void SetCallback( const BlueScriptCallback& callback ); - TriStepPythonCB( const TriStepPythonCB &); - TriStepPythonCB& operator=( const TriStepPythonCB &); + TriStepPythonCB( const TriStepPythonCB& ); + TriStepPythonCB& operator=( const TriStepPythonCB& ); }; TYPEDEF_BLUECLASS( TriStepPythonCB ); -#endif // TriStepPythonCB_H +#endif // TriStepPythonCB_H diff --git a/trinity/RenderJob/TriStepPythonCB_Blue.cpp b/trinity/RenderJob/TriStepPythonCB_Blue.cpp index 822d01784..6bd05763f 100644 --- a/trinity/RenderJob/TriStepPythonCB_Blue.cpp +++ b/trinity/RenderJob/TriStepPythonCB_Blue.cpp @@ -12,23 +12,18 @@ const Be::ClassInfo* TriStepPythonCB::ExposeToBlue() MAP_INTERFACE( TriStepPythonCB ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", SetCallback, 1, "Create a render step that issues a Python callback\n" - ":param cb: A Python callable (default None)" - ) - - MAP_METHOD_AND_WRAP - ( + ":param cb: A Python callable (default None)" ) + + MAP_METHOD_AND_WRAP( "SetCallback", - SetCallback, + SetCallback, "Set the callback called when this renderstep executes.\n" - ":param cb: a method which has no arguments." - ) + ":param cb: a method which has no arguments." ) EXPOSURE_CHAINTO( TriRenderStep ) } - diff --git a/trinity/RenderJob/TriStepRemoteSync.cpp b/trinity/RenderJob/TriStepRemoteSync.cpp index 1896029bc..083aee066 100644 --- a/trinity/RenderJob/TriStepRemoteSync.cpp +++ b/trinity/RenderJob/TriStepRemoteSync.cpp @@ -13,13 +13,12 @@ static std::string appendIdToString( const char* str, int id ) return std::string( str ).append( std::string( buffer ) ); } -TriStepRemoteSync::TriStepRemoteSync( IRoot* lockobj ): - m_begin(NULL), - m_end(NULL), - m_init(NULL), +TriStepRemoteSync::TriStepRemoteSync( IRoot* lockobj ) : + m_begin( NULL ), + m_end( NULL ), + m_init( NULL ), m_id( -1 ) { - } TriStepRemoteSync::~TriStepRemoteSync() @@ -38,12 +37,11 @@ TriStepRemoteSync::~TriStepRemoteSync() { CloseHandle( m_init ); } - } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // Arguments: // depthStencil - Initial value of id step attribute // -------------------------------------------------------------------------------------- @@ -56,11 +54,11 @@ TriStepResult TriStepRemoteSync::Execute( Be::Time realTime, Be::Time simTime, T { // An event to stall the beginning of the rendering til set if( m_begin == NULL ) - { + { std::string beginRenderName; if( m_id >= 0 ) - { - beginRenderName = appendIdToString( "Trinity_beginRender", m_id ); + { + beginRenderName = appendIdToString( "Trinity_beginRender", m_id ); } else { @@ -71,14 +69,14 @@ TriStepResult TriStepRemoteSync::Execute( Be::Time realTime, Be::Time simTime, T { return RS_FAILED; } - } + } // An event to indicate that the rendering loop has gone a full rotation if( m_end == NULL ) { - std::string endRenderName; + std::string endRenderName; if( m_id >= 0 ) - { + { endRenderName = appendIdToString( "Trinity_endRender", m_id ); } else @@ -89,15 +87,15 @@ TriStepResult TriStepRemoteSync::Execute( Be::Time realTime, Be::Time simTime, T if( m_end == NULL ) { return RS_FAILED; - } + } } // Fire of a synchronization event indicating that the renderjob has been created and initialized. if( m_init == NULL ) { - std::string initRenderName; + std::string initRenderName; if( m_id >= 0 ) - { + { initRenderName = appendIdToString( "Trinity_initRender", m_id ); } else @@ -108,7 +106,7 @@ TriStepResult TriStepRemoteSync::Execute( Be::Time realTime, Be::Time simTime, T if( m_init != NULL ) { SetEvent( m_init ); - } + } } PulseEvent( m_end ); @@ -118,7 +116,7 @@ TriStepResult TriStepRemoteSync::Execute( Be::Time realTime, Be::Time simTime, T { // } - + return RS_OK; } diff --git a/trinity/RenderJob/TriStepRemoteSync.h b/trinity/RenderJob/TriStepRemoteSync.h index ba896dab5..2038ae53d 100644 --- a/trinity/RenderJob/TriStepRemoteSync.h +++ b/trinity/RenderJob/TriStepRemoteSync.h @@ -6,27 +6,34 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepRemoteSync ): - public TriRenderStep +BLUE_CLASS( TriStepRemoteSync ) : + public TriRenderStep { public: - EXPOSE_TO_BLUE(); - TriStepRemoteSync( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriStepRemoteSync( IRoot* lockobj = NULL ); ~TriStepRemoteSync(); void py__init__( Be::OptionalWithDefaultValue id ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // an id to create access a unique instance of the events - int GetId(){ return m_id; } - void SetId( int id ){ m_id = id; } + int GetId() + { + return m_id; + } + void SetId( int id ) + { + m_id = id; + } + private: - HANDLE m_begin; - HANDLE m_end; - HANDLE m_init; - int m_id; + HANDLE m_begin; + HANDLE m_end; + HANDLE m_init; + int m_id; }; TYPEDEF_BLUECLASS( TriStepRemoteSync ); diff --git a/trinity/RenderJob/TriStepRemoteSync_Blue.cpp b/trinity/RenderJob/TriStepRemoteSync_Blue.cpp index 051e6acea..9a30a98eb 100644 --- a/trinity/RenderJob/TriStepRemoteSync_Blue.cpp +++ b/trinity/RenderJob/TriStepRemoteSync_Blue.cpp @@ -14,13 +14,13 @@ const Be::ClassInfo* TriStepRemoteSync::ExposeToBlue() MAP_INTERFACE( TriStepRemoteSync ) MAP_INTERFACE( TriRenderStep ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - py__init__, - 1, - "Creates a render step that syncs the rendering to a windows event primitive.\n" - "Usefull when needed to sync to an external process like Maya.\n" - ":param id: this id will be appended to the event names if it is >= 0") - EXPOSURE_CHAINTO( TriRenderStep ) + "__init__", + py__init__, + 1, + "Creates a render step that syncs the rendering to a windows event primitive.\n" + "Usefull when needed to sync to an external process like Maya.\n" + ":param id: this id will be appended to the event names if it is >= 0" ) + EXPOSURE_CHAINTO( TriRenderStep ) } #endif diff --git a/trinity/RenderJob/TriStepRemoteUpdate.cpp b/trinity/RenderJob/TriStepRemoteUpdate.cpp index b0a54030d..d663217b5 100644 --- a/trinity/RenderJob/TriStepRemoteUpdate.cpp +++ b/trinity/RenderJob/TriStepRemoteUpdate.cpp @@ -14,7 +14,7 @@ static std::string appendIdToString( const char* str, int id ) return std::string( str ).append( std::string( buffer ) ); } -TriStepRemoteUpdate::TriStepRemoteUpdate( IRoot* lockobj ): +TriStepRemoteUpdate::TriStepRemoteUpdate( IRoot* lockobj ) : m_sharedMemory( NULL ), m_sharedMemoryHandle( NULL ), m_needsHndl( NULL ), @@ -22,18 +22,16 @@ TriStepRemoteUpdate::TriStepRemoteUpdate( IRoot* lockobj ): m_writingHndl( NULL ), m_id( -1 ) { - - } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- -void TriStepRemoteUpdate::py__init__( - TriView* view, - TriProjection* projection, - TriViewport* viewport, +void TriStepRemoteUpdate::py__init__( + TriView* view, + TriProjection* projection, + TriViewport* viewport, Be::OptionalWithDefaultValue id ) { SetData( view, projection, viewport, id ); @@ -42,7 +40,7 @@ void TriStepRemoteUpdate::py__init__( bool TriStepRemoteUpdate::OpenSharedMemoryAndEvents() { // we will store two 4x4 matrices and the dimensions of the viewport - // 16*4+16*4+6*4 + // 16*4+16*4+6*4 int size = 152; std::string sharedMemoryName; @@ -76,12 +74,12 @@ bool TriStepRemoteUpdate::OpenSharedMemoryAndEvents() m_sharedMemory = (const char*)MapViewOfFile( m_sharedMemoryHandle, FILE_MAP_ALL_ACCESS, - 0, 0, - size - ); + 0, + 0, + size ); if( m_sharedMemory == NULL ) - { + { CloseHandle( m_sharedMemoryHandle ); return false; @@ -94,7 +92,7 @@ bool TriStepRemoteUpdate::OpenSharedMemoryAndEvents() return true; } -void TriStepRemoteUpdate::SetData( TriView* view, TriProjection *proj, TriViewport* viewport, int id ) +void TriStepRemoteUpdate::SetData( TriView* view, TriProjection* proj, TriViewport* viewport, int id ) { m_view = view; m_projection = proj; @@ -102,20 +100,20 @@ void TriStepRemoteUpdate::SetData( TriView* view, TriProjection *proj, TriViewpo m_id = id; } -TriStepRemoteUpdate::~TriStepRemoteUpdate(void) +TriStepRemoteUpdate::~TriStepRemoteUpdate( void ) { // Release shared handles // shared memory - + if( m_sharedMemory ) { - UnmapViewOfFile (m_sharedMemory ); + UnmapViewOfFile( m_sharedMemory ); } if( m_sharedMemoryHandle ) { CloseHandle( m_sharedMemoryHandle ); } - + // Events if( m_needsHndl ) { @@ -134,15 +132,15 @@ TriStepRemoteUpdate::~TriStepRemoteUpdate(void) namespace { - struct Dx9Viewport - { - uint32_t X; - uint32_t Y; - uint32_t Width; - uint32_t Height; - float MinZ; - float MaxZ; - }; +struct Dx9Viewport +{ + uint32_t X; + uint32_t Y; + uint32_t Width; + uint32_t Height; + float MinZ; + float MaxZ; +}; } TriStepResult TriStepRemoteUpdate::Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) @@ -156,17 +154,17 @@ TriStepResult TriStepRemoteUpdate::Execute( Be::Time realTime, Be::Time simTime, { ResetEvent( m_readingHndl ); - // Read data + // Read data Matrix projMat; Matrix viewMat; Dx9Viewport viewport; int offset = 0; - memcpy((void*)&projMat, m_sharedMemory, 64); + memcpy( (void*)&projMat, m_sharedMemory, 64 ); offset += 64; - memcpy((void*)&viewMat, m_sharedMemory+offset, 64); + memcpy( (void*)&viewMat, m_sharedMemory + offset, 64 ); offset += 64; - memcpy((void*)&viewport, m_sharedMemory+offset, 24); + memcpy( (void*)&viewport, m_sharedMemory + offset, 24 ); m_projection->CustomProjection( projMat ); m_view->SetTransform( viewMat ); m_viewport->width = viewport.Width; @@ -179,10 +177,10 @@ TriStepResult TriStepRemoteUpdate::Execute( Be::Time realTime, Be::Time simTime, } else { - if( !OpenSharedMemoryAndEvents()) + if( !OpenSharedMemoryAndEvents() ) { - CCP_LOGERR("There is no shared memory to read from"); - } + CCP_LOGERR( "There is no shared memory to read from" ); + } } return RS_OK; diff --git a/trinity/RenderJob/TriStepRemoteUpdate.h b/trinity/RenderJob/TriStepRemoteUpdate.h index ebf27e1d8..20567123d 100644 --- a/trinity/RenderJob/TriStepRemoteUpdate.h +++ b/trinity/RenderJob/TriStepRemoteUpdate.h @@ -10,25 +10,27 @@ #include "TriViewport.h" #include "TriProjection.h" -BLUE_CLASS( TriStepRemoteUpdate ) : public TriRenderStep +BLUE_CLASS( TriStepRemoteUpdate ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); TriStepRemoteUpdate( IRoot* lockobj = 0 ); - ~TriStepRemoteUpdate(void); + ~TriStepRemoteUpdate( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void py__init__( - TriView* view, - TriProjection* projection, - TriViewport* viewport, + void py__init__( + TriView * view, + TriProjection * projection, + TriViewport * viewport, Be::OptionalWithDefaultValue id ); - void SetData( TriView* view, TriProjection *proj, TriViewport* viewport, int id ); + void SetData( TriView * view, TriProjection * proj, TriViewport * viewport, int id ); + private: bool OpenSharedMemoryAndEvents(); @@ -36,12 +38,12 @@ BLUE_CLASS( TriStepRemoteUpdate ) : public TriRenderStep TriViewportPtr m_viewport; TriProjectionPtr m_projection; - HANDLE m_sharedMemoryHandle; - HANDLE m_needsHndl; - HANDLE m_readingHndl; - HANDLE m_writingHndl; - const char* m_sharedMemory; - int m_id; + HANDLE m_sharedMemoryHandle; + HANDLE m_needsHndl; + HANDLE m_readingHndl; + HANDLE m_writingHndl; + const char* m_sharedMemory; + int m_id; }; TYPEDEF_BLUECLASS( TriStepRemoteUpdate ); diff --git a/trinity/RenderJob/TriStepRemoteUpdate_Blue.cpp b/trinity/RenderJob/TriStepRemoteUpdate_Blue.cpp index e764ed3cd..3ca079c93 100644 --- a/trinity/RenderJob/TriStepRemoteUpdate_Blue.cpp +++ b/trinity/RenderJob/TriStepRemoteUpdate_Blue.cpp @@ -11,13 +11,13 @@ BLUE_DEFINE( TriStepRemoteUpdate ); const Be::ClassInfo* TriStepRemoteUpdate::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRemoteUpdate, "" ) + EXPOSURE_BEGIN( TriStepRemoteUpdate, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRemoteUpdate ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", + "__init__", py__init__, 1, "Creates a render step that performs a View/Projection/Viewport update from shared memory\n" @@ -25,7 +25,7 @@ const Be::ClassInfo* TriStepRemoteUpdate::ExposeToBlue() "\n:param view: TriView" "\n:param projection: TriProjection" "\n:param viewport: TriViewport" - "\n:param id: unique identifier") + "\n:param id: unique identifier" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepRenderAtlas.cpp b/trinity/RenderJob/TriStepRenderAtlas.cpp index 9cb180199..da43e3ef4 100644 --- a/trinity/RenderJob/TriStepRenderAtlas.cpp +++ b/trinity/RenderJob/TriStepRenderAtlas.cpp @@ -9,12 +9,10 @@ #include "Shader/Tr2Effect.h" #include "Tr2VariableStore.h" -TriStepRenderAtlas::TriStepRenderAtlas( IRoot *lockobj ) - : m_atlas(NULL), m_focus(NULL), m_tlTexCoord(0.f, 0.f), m_brTexCoord(1.f, 1.f), - m_showFree(false), m_showUsed(true), - m_borderColour(1,1,0,1), m_focusColour(1,0,1,1), m_freeColour(0,0.5f,0,1) +TriStepRenderAtlas::TriStepRenderAtlas( IRoot* lockobj ) : + m_atlas( NULL ), m_focus( NULL ), m_tlTexCoord( 0.f, 0.f ), m_brTexCoord( 1.f, 1.f ), m_showFree( false ), m_showUsed( true ), m_borderColour( 1, 1, 0, 1 ), m_focusColour( 1, 0, 1, 1 ), m_freeColour( 0, 0.5f, 0, 1 ) { - m_simpleOutColourHandle = GlobalStore().RegisterVariable( "simpleOutColour", Vector4(0,0,0,0) ); + m_simpleOutColourHandle = GlobalStore().RegisterVariable( "simpleOutColour", Vector4( 0, 0, 0, 0 ) ); BeClasses->CreateInstance( GetTr2EffectClsid(), BlueInterfaceIID(), (void**)&m_areaEffect ); m_areaEffect->SetEffectPathName( "res:/Graphics/Effect/UI/Simple.fx" ); } @@ -26,7 +24,7 @@ TriStepRenderAtlas::~TriStepRenderAtlas() // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void TriStepRenderAtlas::py__init__( Tr2TextureAtlas* atlas, Tr2AtlasTexture* texture ) { @@ -38,16 +36,16 @@ TriStepResult TriStepRenderAtlas::Execute( Be::Time realTime, Be::Time simTime, { if( m_atlas ) { - const Vector2 scale = m_brTexCoord - m_tlTexCoord; + const Vector2 scale = m_brTexCoord - m_tlTexCoord; const Vector2 offset = Vector2( m_tlTexCoord.x / scale.x, m_tlTexCoord.y / scale.y ); - const float rw = 1.f / float(m_atlas->GetWidth() * scale.x); - const float rh = 1.f / float(m_atlas->GetHeight() * scale.y); + const float rw = 1.f / float( m_atlas->GetWidth() * scale.x ); + const float rh = 1.f / float( m_atlas->GetHeight() * scale.y ); - const int margin = std::max( int(m_atlas->GetMargin()), 1 ); + const int margin = std::max( int( m_atlas->GetMargin() ), 1 ); - if( m_showFree ) + if( m_showFree ) { const auto freeAreas = m_atlas->GetFreeAreas(); const static float borderScale = 0.6f; @@ -60,14 +58,10 @@ TriStepResult TriStepRenderAtlas::Execute( Be::Time realTime, Be::Time simTime, { auto& rect = *i; m_simpleOutColourHandle->SetValue( freeBorderColour ); - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( rect.left * rw, rect.top * rh ) - offset, - Vector2( rect.right * rw, rect.bottom * rh ) - offset ); + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( rect.left * rw, rect.top * rh ) - offset, Vector2( rect.right * rw, rect.bottom * rh ) - offset ); m_simpleOutColourHandle->SetValue( m_freeColour ); - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( (rect.left + margin) * rw, (rect.top + margin) * rh ) - offset, - Vector2( (rect.right - margin) * rw, (rect.bottom - margin) * rh ) - offset ); + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( ( rect.left + margin ) * rw, ( rect.top + margin ) * rh ) - offset, Vector2( ( rect.right - margin ) * rw, ( rect.bottom - margin ) * rh ) - offset ); } } @@ -92,36 +86,27 @@ TriStepResult TriStepRenderAtlas::Execute( Be::Time realTime, Be::Time simTime, } else { - m_simpleOutColourHandle->SetValue( m_borderColour ); + m_simpleOutColourHandle->SetValue( m_borderColour ); } } - - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( rect.left * rw, rect.top * rh ) - offset, - Vector2( (rect.left + margin) * rw, (rect.bottom - margin) * rh ) - offset ); - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( rect.left * rw, (rect.bottom - margin) * rh ) - offset, - Vector2( (rect.right - margin) * rw, rect.bottom * rh ) - offset ); - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( (rect.right - margin) * rw, (rect.top + margin) * rh ) - offset, - Vector2( rect.right * rw, rect.bottom * rh ) - offset ); - Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, - Vector2( (rect.left + margin) * rw, rect.top * rh ) - offset, - Vector2( rect.right * rw, (rect.top + margin) * rh ) - offset ); + + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( rect.left * rw, rect.top * rh ) - offset, Vector2( ( rect.left + margin ) * rw, ( rect.bottom - margin ) * rh ) - offset ); + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( rect.left * rw, ( rect.bottom - margin ) * rh ) - offset, Vector2( ( rect.right - margin ) * rw, rect.bottom * rh ) - offset ); + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( ( rect.right - margin ) * rw, ( rect.top + margin ) * rh ) - offset, Vector2( rect.right * rw, rect.bottom * rh ) - offset ); + Tr2Renderer::DrawScreenQuad( renderContext, m_areaEffect, Vector2( ( rect.left + margin ) * rw, rect.top * rh ) - offset, Vector2( rect.right * rw, ( rect.top + margin ) * rh ) - offset ); } } } return RS_OK; } -void TriStepRenderAtlas::SetAtlas( Tr2TextureAtlas *atlas ) +void TriStepRenderAtlas::SetAtlas( Tr2TextureAtlas* atlas ) { m_atlas = atlas; } -void TriStepRenderAtlas::SetFocus( Tr2AtlasTexture *texture ) +void TriStepRenderAtlas::SetFocus( Tr2AtlasTexture* texture ) { m_focus = texture; } - diff --git a/trinity/RenderJob/TriStepRenderAtlas.h b/trinity/RenderJob/TriStepRenderAtlas.h index 30ad87e34..a8844f143 100644 --- a/trinity/RenderJob/TriStepRenderAtlas.h +++ b/trinity/RenderJob/TriStepRenderAtlas.h @@ -12,29 +12,30 @@ class Tr2AtlasTexture; class Tr2Effect; class TriVariable; -BLUE_CLASS( TriStepRenderAtlas ) : public TriRenderStep +BLUE_CLASS( TriStepRenderAtlas ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderAtlas( IRoot* lockobj = 0 ); ~TriStepRenderAtlas(); - void py__init__( Tr2TextureAtlas* atlas, Tr2AtlasTexture* texture ); + void py__init__( Tr2TextureAtlas * atlas, Tr2AtlasTexture * texture ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void SetAtlas( Tr2TextureAtlas *atlas ); - void SetFocus( Tr2AtlasTexture *texture ); + void SetAtlas( Tr2TextureAtlas * atlas ); + void SetFocus( Tr2AtlasTexture * texture ); private: //TODO FIXME what's up with none of these being smart ptrs? - Tr2Effect *m_areaEffect; + Tr2Effect* m_areaEffect; TriVariable* m_simpleOutColourHandle; - Tr2TextureAtlas *m_atlas; - Tr2AtlasTexture *m_focus; + Tr2TextureAtlas* m_atlas; + Tr2AtlasTexture* m_focus; //really should steal these from a TriStepRenderTexture Vector2 m_tlTexCoord; Vector2 m_brTexCoord; @@ -45,4 +46,4 @@ BLUE_CLASS( TriStepRenderAtlas ) : public TriRenderStep TYPEDEF_BLUECLASS( TriStepRenderAtlas ); -#endif//TriStepRenderAtlas_h +#endif //TriStepRenderAtlas_h diff --git a/trinity/RenderJob/TriStepRenderAtlas_Blue.cpp b/trinity/RenderJob/TriStepRenderAtlas_Blue.cpp index 71b3581a1..ece890a4d 100644 --- a/trinity/RenderJob/TriStepRenderAtlas_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderAtlas_Blue.cpp @@ -10,7 +10,7 @@ BLUE_DEFINE( TriStepRenderAtlas ); const Be::ClassInfo* TriStepRenderAtlas::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderAtlas, "" ) + EXPOSURE_BEGIN( TriStepRenderAtlas, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderAtlas ) @@ -25,16 +25,13 @@ const Be::ClassInfo* TriStepRenderAtlas::ExposeToBlue() MAP_ATTRIBUTE( "focusColour", m_focusColour, "border colour for areas in use and selected (NYI)", Be::READWRITE ) MAP_ATTRIBUTE( "freeColour", m_freeColour, "border colour for free areas", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 2, - "Creates a render step that renders an atlas\n" + "Creates a render step that renders an atlas\n" ":param atlas: an atlas (default None)\n" - ":param texture: texture in the atlas\n" - ) + ":param texture: texture in the atlas\n" ) EXPOSURE_CHAINTO( TriRenderStep ) } - diff --git a/trinity/RenderJob/TriStepRenderDebug.cpp b/trinity/RenderJob/TriStepRenderDebug.cpp index 7f2128644..609028832 100644 --- a/trinity/RenderJob/TriStepRenderDebug.cpp +++ b/trinity/RenderJob/TriStepRenderDebug.cpp @@ -13,14 +13,14 @@ const int NUM_POINTS_MAX = 32000; using namespace Tr2RenderContextEnum; -TriStepRenderDebug::TriStepRenderDebug( IRoot* lockobj ) : +TriStepRenderDebug::TriStepRenderDebug( IRoot* lockobj ) : m_data( NULL ), m_numPrimitives( 0 ), m_lineSet( nullptr ), m_projectedText( "TriStepRenderDebug/m_projectedText" ), m_autoClear( true ) { - m_data = (uint8_t*)CCP_MALLOC( "TriStepRenderDebug/m_data", NUM_POINTS_MAX * (3 * sizeof(float) + sizeof(uint32_t)) ); + m_data = (uint8_t*)CCP_MALLOC( "TriStepRenderDebug/m_data", NUM_POINTS_MAX * ( 3 * sizeof( float ) + sizeof( uint32_t ) ) ); m_curData = m_data; BeClasses->CreateInstance( GetTriLineSetClsid(), BlueInterfaceIID(), (void**)&m_lineSet ); @@ -31,7 +31,7 @@ TriStepRenderDebug::TriStepRenderDebug( IRoot* lockobj ) : m_projectedTextRenderer->PrepareResources(); } -TriStepRenderDebug::~TriStepRenderDebug(void) +TriStepRenderDebug::~TriStepRenderDebug( void ) { if( m_data ) { @@ -70,7 +70,7 @@ TriStepResult TriStepRenderDebug::Execute( Be::Time realTime, Be::Time simTime, Tr2Rect rect; Vector3 screenPos = Tr2Renderer::ProjectWorldToScreen( e.pos, viewport ); - if( (screenPos.z > 0.0f) && (screenPos.z < 1.0f) ) + if( ( screenPos.z > 0.0f ) && ( screenPos.z < 1.0f ) ) { rect.top = (int32_t)screenPos.y; rect.left = (int32_t)screenPos.x; @@ -91,7 +91,7 @@ TriStepResult TriStepRenderDebug::Execute( Be::Time realTime, Be::Time simTime, return RS_OK; } -void TriStepRenderDebug::DrawPointCloud(int numPoints, float *points, int stride) +void TriStepRenderDebug::DrawPointCloud( int numPoints, float* points, int stride ) { if( m_numPrimitives + numPoints < NUM_POINTS_MAX ) { @@ -108,10 +108,10 @@ void TriStepRenderDebug::DrawPointCloud(int numPoints, float *points, int stride ++dst; - src = (float*)((uint8_t*)src + stride); + src = (float*)( (uint8_t*)src + stride ); } - m_curData += numPoints * (3 * sizeof(float) + sizeof(uint32_t)); + m_curData += numPoints * ( 3 * sizeof( float ) + sizeof( uint32_t ) ); m_numPrimitives += numPoints; } } @@ -166,7 +166,7 @@ void TriStepRenderDebug::Printf( const Vector3& pos, uint32_t color, const char* va_start( args, msg ); const int BUFFER_SIZE = 1024; - static char buffer[ BUFFER_SIZE ]; + static char buffer[BUFFER_SIZE]; vsnprintf_s( buffer, BUFFER_SIZE, _TRUNCATE, msg, args ); @@ -198,7 +198,6 @@ void TriStepRenderDebug::DrawCone( const Vector3& start, const Vector3& end, flo void TriStepRenderDebug::DrawPlane( const Vector4& planeEquation, int segments, uint32_t color /*= 0xffffffff */ ) { - } void TriStepRenderDebug::DrawAxes( const Matrix& m, float scale ) @@ -220,7 +219,7 @@ void TriStepRenderDebug::Print2D( int x, int y, uint32_t color, const std::strin void TriStepRenderDebug::Print2Df( int x, int y, int w, int h, uint32_t format, uint32_t color, const std::string& msg ) { - Tr2Rect rect = {x, y, w, h}; + Tr2Rect rect = { x, y, w, h }; Printf( rect, color, format, msg.c_str() ); } diff --git a/trinity/RenderJob/TriStepRenderDebug.h b/trinity/RenderJob/TriStepRenderDebug.h index c15f353c6..4ae2094a1 100644 --- a/trinity/RenderJob/TriStepRenderDebug.h +++ b/trinity/RenderJob/TriStepRenderDebug.h @@ -15,16 +15,15 @@ BLUE_DECLARE( TriLineSet ); class TriDebugTextRenderer; -class TriStepRenderDebug: - public TriRenderStep, - public ITr2DebugRenderer, - public IRenderCallback +class TriStepRenderDebug : public TriRenderStep, + public ITr2DebugRenderer, + public IRenderCallback { public: EXPOSE_TO_BLUE(); - + TriStepRenderDebug( IRoot* lockobj = 0 ); - ~TriStepRenderDebug(void); + ~TriStepRenderDebug( void ); ////////////////////////////////////////////////////////////////////////// // Helper functions for easier Python exposure @@ -55,7 +54,10 @@ class TriStepRenderDebug: void Printf( const Vector3& pos, uint32_t color, const char* msg, ... ); // Need to expose a single draw line for python - void PyDrawLine( const Vector3& from, uint32_t fromColor, const Vector3& to, uint32_t toColor ) { DrawLine( from, fromColor, to, toColor ); }; + void PyDrawLine( const Vector3& from, uint32_t fromColor, const Vector3& to, uint32_t toColor ) + { + DrawLine( from, fromColor, to, toColor ); + }; ////////////////////////////////////////////////////////////////////////// // Tr2Effect::IRenderCallback diff --git a/trinity/RenderJob/TriStepRenderDebug_Blue.cpp b/trinity/RenderJob/TriStepRenderDebug_Blue.cpp index 1056da2f0..01365eb5c 100644 --- a/trinity/RenderJob/TriStepRenderDebug_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderDebug_Blue.cpp @@ -7,113 +7,80 @@ BLUE_DEFINE( TriStepRenderDebug ); const Be::ClassInfo* TriStepRenderDebug::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderDebug, "" ) + EXPOSURE_BEGIN( TriStepRenderDebug, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderDebug ) MAP_INTERFACE( ITr2DebugRenderer ) - MAP_ATTRIBUTE - ( - "autoClear", m_autoClear, - "If set, all draw commands are cleared when the step is executed. Otherwise draw\n" - "commands keep accumulating until Clear is explicitly called.", - Be::READWRITE - ) - MAP_METHOD_AND_WRAP - ( - "Print2D", Print2D, - "prints 'msg' at ('x', 'y') in the viewport, with the given color.\n" - ":param x: horizontal coordinate\n" - ":param y: vertical coordinate\n" - ":param color: text color\n" - ":param msg: message text\n" - ) - MAP_METHOD_AND_WRAP - ( - "Print2Df", Print2Df, - "prints 'msg' formatted into the rectangle with upper-left coordinates of ('x', 'y'),\n" - "width and height of 'w' and 'h', with the given color. The formatting is controlled\n" - "by 'format'.\n" - ":param x: horizontal coordinate\n" - ":param y: vertical coordinate\n" - ":param width: text width\n" - ":param height: text height\n" - ":param format: formating flags\n" - ":param color: text color\n" - ":param msg: message text\n" - ) - MAP_METHOD_AND_WRAP - ( - "Print3D", Print3D, - "Print3D( pos, color, msg ) - prints msg projected from the given 3D coordinate,\n" - "with the given color.\n" - ":param pos: 3D position\n" - ":param color: text color\n" - ":param msg: message text\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawSphere", DrawSphere, - "DrawSphere( center, radius, segments, color ) - draws a sphere as lines.\n" - ":param center: sphere center position\n" - ":param radius: sphere radius\n" - ":param segments: number of segments in the wireframe\n" - ":param color: sphere color\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawBox", DrawBox, - "DrawBox( min, max, color ) - draws a box as lines.\n" - ":param min: coordinates of the min corner\n" - ":param max: coordinates of the max corner\n" - ":param color: sphere color\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawCapsule", DrawCapsule, - "DrawCapsule( start, end, radius, segments, color ) - draws a capsule\n" - "(cylinder with rounded ends) as lines.\n" - ":param start: coordinates of the starting point of the cylinder\n" - ":param end: coordinates of the ending point of the cylinder\n" - ":param radius: capsule radius\n" - ":param segments: number of segments in the wireframe\n" - ":param color: capsule color\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawCylinder", DrawCylinder, - "DrawCylinder( start, end, radius, segments, color ) - draws a cylinder as lines.\n" - ":param start: coordinates of the starting point of the cylinder\n" - ":param end: coordinates of the ending point of the cylinder\n" - ":param radius: cylinder radius\n" - ":param segments: number of segments in the wireframe\n" - ":param color: cylinder color\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawCone", DrawCone, - "DrawCone( start, end, radius, segments, color ) - draws a cone as lines.\n" - ":param start: coordinates of the origin of the cone\n" - ":param end: coordinates of the ending point of the cone\n" - ":param radius: cone radius\n" - ":param segments: number of segments in the wireframe\n" - ":param color: cone color\n" - ) - MAP_METHOD_AND_WRAP - ( - "DrawLine", PyDrawLine, - "DrawLine( from, fromColor, to, toColor ) - draws a line.\n" - ":param fromPos: line segment start\n" - ":param fromColor: color at line segment start\n" - ":param toPos: line segment end\n" - ":param toColor: color at line segment end\n" - ) - MAP_METHOD_AND_WRAP - ( - "Clear", Clear, - "Clears any accumulated draw commands." - ) + MAP_ATTRIBUTE( + "autoClear", m_autoClear, "If set, all draw commands are cleared when the step is executed. Otherwise draw\n" + "commands keep accumulating until Clear is explicitly called.", + Be::READWRITE ) + MAP_METHOD_AND_WRAP( + "Print2D", Print2D, "prints 'msg' at ('x', 'y') in the viewport, with the given color.\n" + ":param x: horizontal coordinate\n" + ":param y: vertical coordinate\n" + ":param color: text color\n" + ":param msg: message text\n" ) + MAP_METHOD_AND_WRAP( + "Print2Df", Print2Df, "prints 'msg' formatted into the rectangle with upper-left coordinates of ('x', 'y'),\n" + "width and height of 'w' and 'h', with the given color. The formatting is controlled\n" + "by 'format'.\n" + ":param x: horizontal coordinate\n" + ":param y: vertical coordinate\n" + ":param width: text width\n" + ":param height: text height\n" + ":param format: formating flags\n" + ":param color: text color\n" + ":param msg: message text\n" ) + MAP_METHOD_AND_WRAP( + "Print3D", Print3D, "Print3D( pos, color, msg ) - prints msg projected from the given 3D coordinate,\n" + "with the given color.\n" + ":param pos: 3D position\n" + ":param color: text color\n" + ":param msg: message text\n" ) + MAP_METHOD_AND_WRAP( + "DrawSphere", DrawSphere, "DrawSphere( center, radius, segments, color ) - draws a sphere as lines.\n" + ":param center: sphere center position\n" + ":param radius: sphere radius\n" + ":param segments: number of segments in the wireframe\n" + ":param color: sphere color\n" ) + MAP_METHOD_AND_WRAP( + "DrawBox", DrawBox, "DrawBox( min, max, color ) - draws a box as lines.\n" + ":param min: coordinates of the min corner\n" + ":param max: coordinates of the max corner\n" + ":param color: sphere color\n" ) + MAP_METHOD_AND_WRAP( + "DrawCapsule", DrawCapsule, "DrawCapsule( start, end, radius, segments, color ) - draws a capsule\n" + "(cylinder with rounded ends) as lines.\n" + ":param start: coordinates of the starting point of the cylinder\n" + ":param end: coordinates of the ending point of the cylinder\n" + ":param radius: capsule radius\n" + ":param segments: number of segments in the wireframe\n" + ":param color: capsule color\n" ) + MAP_METHOD_AND_WRAP( + "DrawCylinder", DrawCylinder, "DrawCylinder( start, end, radius, segments, color ) - draws a cylinder as lines.\n" + ":param start: coordinates of the starting point of the cylinder\n" + ":param end: coordinates of the ending point of the cylinder\n" + ":param radius: cylinder radius\n" + ":param segments: number of segments in the wireframe\n" + ":param color: cylinder color\n" ) + MAP_METHOD_AND_WRAP( + "DrawCone", DrawCone, "DrawCone( start, end, radius, segments, color ) - draws a cone as lines.\n" + ":param start: coordinates of the origin of the cone\n" + ":param end: coordinates of the ending point of the cone\n" + ":param radius: cone radius\n" + ":param segments: number of segments in the wireframe\n" + ":param color: cone color\n" ) + MAP_METHOD_AND_WRAP( + "DrawLine", PyDrawLine, "DrawLine( from, fromColor, to, toColor ) - draws a line.\n" + ":param fromPos: line segment start\n" + ":param fromColor: color at line segment start\n" + ":param toPos: line segment end\n" + ":param toColor: color at line segment end\n" ) + MAP_METHOD_AND_WRAP( + "Clear", Clear, "Clears any accumulated draw commands." ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderEffect.cpp b/trinity/RenderJob/TriStepRenderEffect.cpp index 1d374c097..6bf6a2fb9 100644 --- a/trinity/RenderJob/TriStepRenderEffect.cpp +++ b/trinity/RenderJob/TriStepRenderEffect.cpp @@ -9,13 +9,13 @@ CCP_STATS_DECLARE( rsRenderEffectCount, "Trinity/RenderStep/RenderEffectCount", true, CST_COUNTER_LOW, "Calls to TriStepRenderEffect::Execute per frame" ); -TriStepRenderEffect::TriStepRenderEffect( IRoot* lockobj ) - :m_tlTexCoord( 0.0f, 0.0f ), +TriStepRenderEffect::TriStepRenderEffect( IRoot* lockobj ) : + m_tlTexCoord( 0.0f, 0.0f ), m_brTexCoord( 1.0f, 1.0f ) { } -TriStepRenderEffect::~TriStepRenderEffect(void) +TriStepRenderEffect::~TriStepRenderEffect( void ) { } diff --git a/trinity/RenderJob/TriStepRenderEffect.h b/trinity/RenderJob/TriStepRenderEffect.h index 7edb9c29d..7e31a8b57 100644 --- a/trinity/RenderJob/TriStepRenderEffect.h +++ b/trinity/RenderJob/TriStepRenderEffect.h @@ -10,19 +10,20 @@ BLUE_DECLARE( Tr2Effect ); BLUE_DECLARE( Tr2ShaderBuffer ); -BLUE_CLASS( TriStepRenderEffect ) : public TriRenderStep +BLUE_CLASS( TriStepRenderEffect ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderEffect( IRoot* lockobj = 0 ); - ~TriStepRenderEffect(void); + ~TriStepRenderEffect( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void py__init__( Tr2Effect* effect, Tr2ShaderBuffer* shaderBuffer ); + void py__init__( Tr2Effect * effect, Tr2ShaderBuffer * shaderBuffer ); private: Tr2EffectPtr m_effect; diff --git a/trinity/RenderJob/TriStepRenderEffect_Blue.cpp b/trinity/RenderJob/TriStepRenderEffect_Blue.cpp index 93fe03da5..4659f42df 100644 --- a/trinity/RenderJob/TriStepRenderEffect_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderEffect_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepRenderEffect ); const Be::ClassInfo* TriStepRenderEffect::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderEffect, "" ) + EXPOSURE_BEGIN( TriStepRenderEffect, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderEffect ) @@ -19,15 +19,13 @@ const Be::ClassInfo* TriStepRenderEffect::ExposeToBlue() MAP_ATTRIBUTE( "tlTexCoord", m_tlTexCoord, "top left texture coordinate", Be::READWRITE ) MAP_ATTRIBUTE( "brTexCoord", m_brTexCoord, "bottom right texture coordinate", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 2, "Create a render step that draws a fullscreen quad using a specified effect\n" ":param effect: A Tr2Effect (default None)\n" - ":param shaderBuffer: A Tr2ShaderBuffer (default None)" - ) + ":param shaderBuffer: A Tr2ShaderBuffer (default None)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderFps.cpp b/trinity/RenderJob/TriStepRenderFps.cpp index 4b1003bb8..94319310c 100644 --- a/trinity/RenderJob/TriStepRenderFps.cpp +++ b/trinity/RenderJob/TriStepRenderFps.cpp @@ -53,7 +53,7 @@ const char* GetDate() } #endif -TriStepRenderFps::TriStepRenderFps( IRoot* lockobj ) : +TriStepRenderFps::TriStepRenderFps( IRoot* lockobj ) : m_averageFPS( 0 ), m_sumFPSValues( 0 ), m_averageMSPerFrame( 1 ), @@ -66,27 +66,27 @@ TriStepRenderFps::TriStepRenderFps( IRoot* lockobj ) : m_dpCount( nullptr ) { auto& entries = CcpStatistics::GetEntryArray(); - auto found = std::find_if( - entries.begin(), - entries.end(), - [&]( CcpStaticStatisticsEntry *entry ) { return entry->GetName() == "Trinity/AL/sceneDrawcallCount"; } ); + auto found = std::find_if( + entries.begin(), + entries.end(), + [&]( CcpStaticStatisticsEntry* entry ) { return entry->GetName() == "Trinity/AL/sceneDrawcallCount"; } ); if( found != entries.end() ) { m_dpCount = *found; } } -TriStepRenderFps::~TriStepRenderFps(void) +TriStepRenderFps::~TriStepRenderFps( void ) { } TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) { - // these values are static for this implementation, but it should be considered + // these values are static for this implementation, but it should be considered // to change this in a follwing sprint const float fpsCalculationTime = 0.25f; - + // position of the fps, left top corner Tr2Rect screenFPSPos; const TriViewport& vp = renderContext.m_esm.GetViewport(); @@ -94,7 +94,7 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr screenFPSPos.top = vp.y + m_displayY; screenFPSPos.right = vp.x + vp.width - m_displayX; screenFPSPos.bottom = vp.y + vp.height - m_displayY; - + // this enables access to the fps BeInfo* beOSInfo = BeOS->GetInfo(); @@ -103,27 +103,27 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr // a double where seconds are the first digit before the . double nowTime = TimeAsDouble( beOSInfo->mRealTime ); - // to calculate the average the fps of every frame gets collected + // to calculate the average the fps of every frame gets collected m_FPSValuesCount += 1; m_sumFPSValues += beOSInfo->mFps; // This is not the best timing functionality but it is simple and correct enough // for these purposes (the timing is most likely a few nanoseconds off, due to the // fact that this doesn't check for the exact time) - if( nowTime >= m_nextFPSCalculationTime ) + if( nowTime >= m_nextFPSCalculationTime ) { //timer control m_nextFPSCalculationTime = ( nowTime + fpsCalculationTime ); // calculate the avarege fps and ms - m_averageFPS = m_sumFPSValues/m_FPSValuesCount; - if( m_averageFPS < 1e-5f ) - { + m_averageFPS = m_sumFPSValues / m_FPSValuesCount; + if( m_averageFPS < 1e-5f ) + { m_averageMSPerFrame = 0.0f; } - else + else { - m_averageMSPerFrame = 1.0f/m_averageFPS*1000; + m_averageMSPerFrame = 1.0f / m_averageFPS * 1000; } // clean up for the new average calculation @@ -131,26 +131,26 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr m_FPSValuesCount = 0; } - // Set the print color + // Set the print color // over 60fps green // between 60 and 30 fps orange // under 30 fps red // rgb color calculator http://www.drpeterjones.com/colorcalc/ - if( m_averageFPS > 59.9f ) + if( m_averageFPS > 59.9f ) { textColor = 0xff00ff00; } - else if( m_averageFPS > 29.5f ) + else if( m_averageFPS > 29.5f ) { textColor = 0xffff9900; } - else + else { textColor = 0xffff0000; } // accommodate for release builds, which use `-DCCP_BUILD_FLAVOR=`, e.g. macro without a value -#if ~(~CCP_BUILD_FLAVOR + 0) == 0 && ~(~CCP_BUILD_FLAVOR + 1) == 1 +#if ~( ~CCP_BUILD_FLAVOR + 0 ) == 0 && ~( ~CCP_BUILD_FLAVOR + 1 ) == 1 std::string flavor{ "release" }; #else std::string flavor{ CCP_STRINGIZE( CCP_BUILD_FLAVOR ) }; @@ -159,7 +159,7 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr int dpCount = m_dpCount ? int( m_dpCount->GetValue() ) : 0; int vertCount = static_cast( CCP_STATS_GET( vertexCount ) ); - + uint32_t displayWidth, displayHeight; Tr2UpscalingAL::UpscalingInfo upscalingInfo; { @@ -176,14 +176,14 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr if( upscalingInfo.technique != Tr2UpscalingAL::Technique::NONE ) { - std::string formattedUpscalingText = - " Upscaler: %11s\n" - " Setting: %11s\n" - " Render Res: %11s\n"; - + std::string formattedUpscalingText = + " Upscaler: %11s\n" + " Setting: %11s\n" + " Render Res: %11s\n"; + std::string techniqueName( Tr2UpscalingAL::GetTechniqueName( upscalingInfo.technique ) ); - techniqueName = techniqueName.substr( 0, std::min((size_t)11, techniqueName.length()) ).c_str(); - std::string renderRes = std::to_string( upscalingInfo.renderWidth ) + "x" + std::to_string( upscalingInfo.renderHeight ); + techniqueName = techniqueName.substr( 0, std::min( (size_t)11, techniqueName.length() ) ).c_str(); + std::string renderRes = std::to_string( upscalingInfo.renderWidth ) + "x" + std::to_string( upscalingInfo.renderHeight ); std::string settingName; std::string generatedFrames; switch( upscalingInfo.setting ) @@ -213,16 +213,16 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr if( upscalingInfo.frameGeneration ) { settingName += "/FG"; - float gen = static_cast( CCP_STATS_GET( smoothedGeneratedFrames ) ) ; + float gen = static_cast( CCP_STATS_GET( smoothedGeneratedFrames ) ); sprintf_s( fpsCounterBuffer, "%5.1f/%5.1f", m_averageFPS, gen / 100.0f ); } sprintf_s( upscalingBuffer, formattedUpscalingText.c_str(), - techniqueName.c_str(), + techniqueName.c_str(), settingName.c_str(), - renderRes.c_str() ); - } + renderRes.c_str() ); + } else { sprintf_s( upscalingBuffer, "" ); @@ -249,12 +249,11 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr { str += "\n Wine: %11s"; } - + const int bufferSize = 512; // Make sure to increase this as necessary char fpsBuffer[bufferSize]; - sprintf_s - ( + sprintf_s( fpsBuffer, str.c_str(), GetDate(), @@ -269,10 +268,9 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr dpCount, vertCount, #if __APPLE__ - PDM::IsRosetta() ? "Yes" : "No", + PDM::IsRosetta() ? "Yes" : "No", #endif - PDM::GetWineVersion() - ); + PDM::GetWineVersion() ); uint32_t flags = 0; if( m_alignRight ) @@ -285,6 +283,6 @@ TriStepResult TriStepRenderFps::Execute( Be::Time realTime, Be::Time simTime, Tr } Tr2Renderer::PrintfImmediate( renderContext, TRI_DBG_FONT_LARGE, screenFPSPos, flags, textColor, fpsBuffer ); - + return RS_OK; } diff --git a/trinity/RenderJob/TriStepRenderFps.h b/trinity/RenderJob/TriStepRenderFps.h index 5e2e64c0a..695ffb3f2 100644 --- a/trinity/RenderJob/TriStepRenderFps.h +++ b/trinity/RenderJob/TriStepRenderFps.h @@ -7,32 +7,32 @@ #include "TriRenderStep.h" -BLUE_CLASS( TriStepRenderFps ): public TriRenderStep +BLUE_CLASS( TriStepRenderFps ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderFps( IRoot* lockobj = 0 ); - ~TriStepRenderFps(void); + ~TriStepRenderFps( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); private: double m_sumFPSValues; // collects the differnt fps values to create the avrg int m_FPSValuesCount; // counts how many values are collected for the avrg double m_nextFPSCalculationTime; //the timer for the avrg CcpStaticStatisticsEntry* m_dpCount; - + double m_averageFPS; // average frames per second - double m_averageMSPerFrame; // average milli seconds per frame + double m_averageMSPerFrame; // average milli seconds per frame int m_displayX; int m_displayY; bool m_alignRight; bool m_alignBottom; - }; TYPEDEF_BLUECLASS( TriStepRenderFps ); diff --git a/trinity/RenderJob/TriStepRenderFps_Blue.cpp b/trinity/RenderJob/TriStepRenderFps_Blue.cpp index 4ac1de01b..1e7d68b5e 100644 --- a/trinity/RenderJob/TriStepRenderFps_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderFps_Blue.cpp @@ -9,48 +9,40 @@ BLUE_DEFINE( TriStepRenderFps ); const Be::ClassInfo* TriStepRenderFps::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderFps, "" ) + EXPOSURE_BEGIN( TriStepRenderFps, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderFps ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displayX", m_displayX, "x coordinate of fps numbers on screen. By default this is relative to\n" "the left edge of the viewport - if 'alignRight' is set, then this is\n" "relative to the right edge.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displayY", m_displayY, "y coordinate of fps numbers on screen. By default this is relative to\n" "the top edge of the viewport - if 'alignBottom' is set, then this is\n" "relative to the bottom edge.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "alignRight", m_alignRight, "If set, then the the display of fps numbers is relative to the right edge\n" "of the viewport.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "alignBottom", m_alignBottom, "If set, then the the display of fps numbers is relative to the bottom edge\n" "of the viewport.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepRenderLineGraph.cpp b/trinity/RenderJob/TriStepRenderLineGraph.cpp index fc6d07c57..e127fdb55 100644 --- a/trinity/RenderJob/TriStepRenderLineGraph.cpp +++ b/trinity/RenderJob/TriStepRenderLineGraph.cpp @@ -6,12 +6,12 @@ #include "Tr2Renderer.h" TriStepRenderLineGraph::TriStepRenderLineGraph( IRoot* lockobj ) : -PARENTLOCK( m_lineGraphs ), -m_autoScale( true ), -m_showLegend( true ), -m_maxLegend( 1e12f ), -m_scale( 1.0f ), -m_legendScale( 1.0f ) + PARENTLOCK( m_lineGraphs ), + m_autoScale( true ), + m_showLegend( true ), + m_maxLegend( 1e12f ), + m_scale( 1.0f ), + m_legendScale( 1.0f ) { } @@ -21,10 +21,10 @@ TriStepRenderLineGraph::~TriStepRenderLineGraph() // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- -void TriStepRenderLineGraph::py__init__( - const std::vector& graphs, +void TriStepRenderLineGraph::py__init__( + const std::vector& graphs, Be::Optional legendScale, Be::Optional scale, Be::Optional autoScale ) @@ -127,13 +127,13 @@ TriStepResult TriStepRenderLineGraph::Execute( Be::Time realTime, Be::Time simTi Tr2Viewport viewport; renderContext.GetViewport( viewport ); - + const int kNumLabels = 5; x = (unsigned)viewport.m_width - 20; - int step = ((unsigned)viewport.m_height - 10) / (kNumLabels - 1); + int step = ( (unsigned)viewport.m_height - 10 ) / ( kNumLabels - 1 ); y = (unsigned)viewport.m_height - 10; float label = 0.0f; - float labelStep = 1.0f / (float)(kNumLabels - 1); + float labelStep = 1.0f / (float)( kNumLabels - 1 ); for( int i = 0; i < kNumLabels; ++i ) { float labelValue = label / m_scale * m_legendScale + 0.5f; @@ -141,9 +141,8 @@ TriStepResult TriStepRenderLineGraph::Execute( Be::Time realTime, Be::Time simTi Tr2Renderer::PrintfImmediate( renderContext, x, y, 0xffffffff, TRI_DFS_RIGHT, "%d", intLabelValue ); label += labelStep; y -= step; - } + } } return RS_OK; } - diff --git a/trinity/RenderJob/TriStepRenderLineGraph.h b/trinity/RenderJob/TriStepRenderLineGraph.h index 5f619b412..7c889d30c 100644 --- a/trinity/RenderJob/TriStepRenderLineGraph.h +++ b/trinity/RenderJob/TriStepRenderLineGraph.h @@ -10,16 +10,15 @@ BLUE_DECLARE( TriStepRenderLineGraph ); -class TriStepRenderLineGraph: - public TriRenderStep +class TriStepRenderLineGraph : public TriRenderStep { public: EXPOSE_TO_BLUE(); TriStepRenderLineGraph( IRoot* lockobj = NULL ); ~TriStepRenderLineGraph(); - void py__init__( - const std::vector& graphs, + void py__init__( + const std::vector& graphs, Be::Optional legendScale, Be::Optional scale, Be::Optional autoScale ); diff --git a/trinity/RenderJob/TriStepRenderLineGraph_Blue.cpp b/trinity/RenderJob/TriStepRenderLineGraph_Blue.cpp index ef1bc90ae..b3ac82dcc 100644 --- a/trinity/RenderJob/TriStepRenderLineGraph_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderLineGraph_Blue.cpp @@ -9,75 +9,59 @@ static const char* INIT_DOC_STRING = "Optional arguments are (sequence,float,flo const Be::ClassInfo* TriStepRenderLineGraph::ExposeToBlue() { - EXPOSURE_BEGIN( TriStepRenderLineGraph, "" ) + EXPOSURE_BEGIN( TriStepRenderLineGraph, "" ) MAP_INTERFACE( TriRenderStep ) - MAP_INTERFACE( TriStepRenderLineGraph ) + MAP_INTERFACE( TriStepRenderLineGraph ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "lineGraphs", m_lineGraphs, "", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "autoScale", m_autoScale, "If set, then scale is calculated automatically to fit the data in the line\n" "graphs. If not set, the scale is fixed to whatever is entered in the scale field.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "showLegend", m_showLegend, "If show legend is set, a legend is added. Note that this uses debug rendering" "so it does not work on Mac", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "maxLegend", m_maxLegend, "Maximum scale allowed for auto scale. ", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scale", m_scale, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "legendScale", m_legendScale, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) #if BLUE_WITH_PYTHON - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "scaleChangeCallback", m_scaleChangeCallback, "Optional callback that is called when scale changes with auto scaling enabled", - Be::READWRITE - ) + Be::READWRITE ) #endif - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - py__init__, - 4, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, + 4, ":param graphs: list of graphs\n" ":param legendScale: scale of the legend\n" ":param scale: graph scale\n" - ":param autoScale: use automatic scale to content\n" - ) + ":param autoScale: use automatic scale to content\n" ) - EXPOSURE_CHAINTO( TriRenderStep ) + EXPOSURE_CHAINTO( TriRenderStep ) } - diff --git a/trinity/RenderJob/TriStepRenderObject.cpp b/trinity/RenderJob/TriStepRenderObject.cpp index 8357df259..b4f336aee 100644 --- a/trinity/RenderJob/TriStepRenderObject.cpp +++ b/trinity/RenderJob/TriStepRenderObject.cpp @@ -5,22 +5,21 @@ using namespace Tr2RenderContextEnum; -namespace { - const TriBatchType s_allTypes[] = - { - TRIBATCHTYPE_OPAQUE, - TRIBATCHTYPE_DECAL, - TRIBATCHTYPE_TRANSPARENT, - TRIBATCHTYPE_ADDITIVE - }; +namespace +{ +const TriBatchType s_allTypes[] = { + TRIBATCHTYPE_OPAQUE, + TRIBATCHTYPE_DECAL, + TRIBATCHTYPE_TRANSPARENT, + TRIBATCHTYPE_ADDITIVE +}; - static const Tr2EffectStateManager::RenderingMode s_renderingModes[] = - { - Tr2EffectStateManager::RM_OPAQUE, - Tr2EffectStateManager::RM_DECAL, - Tr2EffectStateManager::RM_ALPHA, - Tr2EffectStateManager::RM_ALPHA_ADDITIVE - }; +static const Tr2EffectStateManager::RenderingMode s_renderingModes[] = { + Tr2EffectStateManager::RM_OPAQUE, + Tr2EffectStateManager::RM_DECAL, + Tr2EffectStateManager::RM_ALPHA, + Tr2EffectStateManager::RM_ALPHA_ADDITIVE +}; } TriStepRenderObject::TriStepRenderObject( IRoot* lockobj ) @@ -28,9 +27,9 @@ TriStepRenderObject::TriStepRenderObject( IRoot* lockobj ) auto allocator = Tr2Renderer::GetPoolAllocator(); for( unsigned i = 0; i != 4; ++i ) { - m_batches[s_allTypes[i]] = CCP_NEW( "TriStepRenderObject/batch" ) TriRenderBatchAccumulator<>( allocator ); + m_batches[s_allTypes[i]] = CCP_NEW( "TriStepRenderObject/batch" ) TriRenderBatchAccumulator<>( allocator ); m_typeEnabled[i] = true; - } + } } TriStepRenderObject::~TriStepRenderObject() @@ -48,7 +47,7 @@ TriStepResult TriStepRenderObject::Execute( Be::Time realTime, Be::Time simTime, return RS_OK; } - ::GetBatchesFromRenderables( &m_renderable, 1, nullptr, m_batches, s_allTypes, 4 ); + ::GetBatchesFromRenderables( &m_renderable, 1, nullptr, m_batches, s_allTypes, 4 ); for( auto it = m_batches.begin(); it != m_batches.end(); ++it ) { diff --git a/trinity/RenderJob/TriStepRenderObject.h b/trinity/RenderJob/TriStepRenderObject.h index c9ca28b44..40f3abb97 100644 --- a/trinity/RenderJob/TriStepRenderObject.h +++ b/trinity/RenderJob/TriStepRenderObject.h @@ -14,24 +14,25 @@ #include "Eve/EveSpaceScene.h" // Render any ITr2Renderable -- just gather its batches and submit. -BLUE_CLASS( TriStepRenderObject ) : public TriRenderStep +BLUE_CLASS( TriStepRenderObject ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderObject( IRoot* lockobj = 0 ); ~TriStepRenderObject(); - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void py__init__( ITr2Renderable* obj ); + void py__init__( ITr2Renderable * obj ); private: - ITr2RenderablePtr m_renderable; - Tr2MaterialPtr m_effectOverride; - EveSpaceScene::BatchMap m_batches; + ITr2RenderablePtr m_renderable; + Tr2MaterialPtr m_effectOverride; + EveSpaceScene::BatchMap m_batches; - bool m_typeEnabled[4]; + bool m_typeEnabled[4]; TriStepRenderObject( const TriStepRenderObject& ); TriStepRenderObject& operator=( const TriStepRenderObject& ); diff --git a/trinity/RenderJob/TriStepRenderObject_Blue.cpp b/trinity/RenderJob/TriStepRenderObject_Blue.cpp index 9e78f293f..d419213ab 100644 --- a/trinity/RenderJob/TriStepRenderObject_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderObject_Blue.cpp @@ -7,41 +7,35 @@ BLUE_DEFINE( TriStepRenderObject ); const Be::ClassInfo* TriStepRenderObject::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderObject, "Render step for rendering a scene" ) + EXPOSURE_BEGIN( TriStepRenderObject, "Render step for rendering a scene" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderObject ) - MAP_ATTRIBUTE - ( - "renderable", + MAP_ATTRIBUTE( + "renderable", m_renderable, "The ITr2Renderable to be rendered", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectOverride", m_effectOverride, "Optional override effect", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE( "renderOpaque" , m_typeEnabled[0], "render opaque batches?", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "renderDecal" , m_typeEnabled[1], "render decal batches?", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "renderTransparent" , m_typeEnabled[2], "render transparent batches?", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "renderAdditive" , m_typeEnabled[3], "render additive batches?", Be::READWRITE | Be::PERSIST ) - - - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "renderOpaque", m_typeEnabled[0], "render opaque batches?", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "renderDecal", m_typeEnabled[1], "render decal batches?", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "renderTransparent", m_typeEnabled[2], "render transparent batches?", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "renderAdditive", m_typeEnabled[3], "render additive batches?", Be::READWRITE | Be::PERSIST ) + + + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 1, "Creates a render step that renders an ITr2Renderable\n" - ":param object: an ITr2Renderable object" - ) + ":param object: an ITr2Renderable object" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderPass.cpp b/trinity/RenderJob/TriStepRenderPass.cpp index 18172cc42..b42322e34 100644 --- a/trinity/RenderJob/TriStepRenderPass.cpp +++ b/trinity/RenderJob/TriStepRenderPass.cpp @@ -4,12 +4,12 @@ #include "TriStepRenderPass.h" -TriStepRenderPass::TriStepRenderPass( IRoot* lockobj ) -: m_pass( ITr2MultiPassScene::RP_BEGIN_RENDER ) +TriStepRenderPass::TriStepRenderPass( IRoot* lockobj ) : + m_pass( ITr2MultiPassScene::RP_BEGIN_RENDER ) { } -TriStepRenderPass::~TriStepRenderPass(void) +TriStepRenderPass::~TriStepRenderPass( void ) { } @@ -29,5 +29,5 @@ TriStepResult TriStepRenderPass::Execute( Be::Time realTime, Be::Time simTime, T void TriStepRenderPass::py__init__( ITr2MultiPassScene* scene, int passType ) { m_scene = scene; - m_pass = ITr2MultiPassScene::PassType(passType); + m_pass = ITr2MultiPassScene::PassType( passType ); } diff --git a/trinity/RenderJob/TriStepRenderPass.h b/trinity/RenderJob/TriStepRenderPass.h index e2ad98159..8ade6d5be 100644 --- a/trinity/RenderJob/TriStepRenderPass.h +++ b/trinity/RenderJob/TriStepRenderPass.h @@ -15,18 +15,20 @@ // SeeAlso: // TriRenderStep, ITr2MultiPassScene // ------------------------------------------------------------- -BLUE_CLASS( TriStepRenderPass ) : public TriRenderStep +BLUE_CLASS( TriStepRenderPass ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderPass( IRoot* lockobj = 0 ); - ~TriStepRenderPass(void); + ~TriStepRenderPass( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); + + void py__init__( ITr2MultiPassScene * scene, int passType ); - void py__init__( ITr2MultiPassScene* scene, int passType ); private: ITr2MultiPassScene::PassType m_pass; ITr2MultiPassScenePtr m_scene; diff --git a/trinity/RenderJob/TriStepRenderPass_Blue.cpp b/trinity/RenderJob/TriStepRenderPass_Blue.cpp index 05b5f8df6..3b4948dd9 100644 --- a/trinity/RenderJob/TriStepRenderPass_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderPass_Blue.cpp @@ -3,22 +3,21 @@ #include "StdAfx.h" #include "TriStepRenderPass.h" -const Be::VarChooser TriMultiPassScenePassTypeChooser[] = -{ +const Be::VarChooser TriMultiPassScenePassTypeChooser[] = { // Name Value Docstring - { "TRIPASS_BEGIN_RENDER", BeCast( ITr2MultiPassScene::RP_BEGIN_RENDER ), "Begin rendering" }, - { "TRIPASS_PRE_PASS", BeCast( ITr2MultiPassScene::RP_PRE_PASS ), "Render prepass (depth, normals, specular)" }, - { "TRIPASS_LIGHT_PASS", BeCast( ITr2MultiPassScene::RP_LIGHT_PASS ), "Render lights" }, - { "TRIPASS_GATHER_PASS", BeCast( ITr2MultiPassScene::RP_GATHER_PASS ), "Render gather pass" }, - { "TRIPASS_FLARE_PASS", BeCast( ITr2MultiPassScene::RP_FLARE_PASS ), "Render flare pass" }, - { "TRIPASS_END_RENDER", BeCast( ITr2MultiPassScene::RP_END_RENDER ), "End rendering" }, - { "TRIPASS_BACKGROUND_RENDER", BeCast( ITr2MultiPassScene::RP_BACKGROUND_RENDER ), "Background rendering" }, - { "TRIPASS_MAIN_RENDER", BeCast( ITr2MultiPassScene::RP_MAIN_RENDER ), "Main rendering" }, - { "TRIPASS_REFLECTION_RENDER", BeCast( ITr2MultiPassScene::RP_REFLECTION_RENDER ), "Reflection rendering" }, - { "TRIPASS_DEPTH_PASS", BeCast( ITr2MultiPassScene::RP_DEPTH_PASS ), "Depth pass" }, - { "TRIPASS_SET_PERFRAME_DATA", BeCast( ITr2MultiPassScene::RP_SET_PERFRAME_DATA ), "Set perframe data to shaders" }, - { "TRIPASS_RENDER_UI", BeCast( ITr2MultiPassScene::RP_RENDER_UI ), "Set perframe data to shaders" }, - {0} + { "TRIPASS_BEGIN_RENDER", BeCast( ITr2MultiPassScene::RP_BEGIN_RENDER ), "Begin rendering" }, + { "TRIPASS_PRE_PASS", BeCast( ITr2MultiPassScene::RP_PRE_PASS ), "Render prepass (depth, normals, specular)" }, + { "TRIPASS_LIGHT_PASS", BeCast( ITr2MultiPassScene::RP_LIGHT_PASS ), "Render lights" }, + { "TRIPASS_GATHER_PASS", BeCast( ITr2MultiPassScene::RP_GATHER_PASS ), "Render gather pass" }, + { "TRIPASS_FLARE_PASS", BeCast( ITr2MultiPassScene::RP_FLARE_PASS ), "Render flare pass" }, + { "TRIPASS_END_RENDER", BeCast( ITr2MultiPassScene::RP_END_RENDER ), "End rendering" }, + { "TRIPASS_BACKGROUND_RENDER", BeCast( ITr2MultiPassScene::RP_BACKGROUND_RENDER ), "Background rendering" }, + { "TRIPASS_MAIN_RENDER", BeCast( ITr2MultiPassScene::RP_MAIN_RENDER ), "Main rendering" }, + { "TRIPASS_REFLECTION_RENDER", BeCast( ITr2MultiPassScene::RP_REFLECTION_RENDER ), "Reflection rendering" }, + { "TRIPASS_DEPTH_PASS", BeCast( ITr2MultiPassScene::RP_DEPTH_PASS ), "Depth pass" }, + { "TRIPASS_SET_PERFRAME_DATA", BeCast( ITr2MultiPassScene::RP_SET_PERFRAME_DATA ), "Set perframe data to shaders" }, + { "TRIPASS_RENDER_UI", BeCast( ITr2MultiPassScene::RP_RENDER_UI ), "Set perframe data to shaders" }, + { 0 } }; BLUE_REGISTER_ENUM( "MULTI_PASS_SCENE_PASS", ITr2MultiPassScene::PassType, TriMultiPassScenePassTypeChooser ); @@ -28,37 +27,31 @@ BLUE_DEFINE( TriStepRenderPass ); const Be::ClassInfo* TriStepRenderPass::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderPass, "Render step for rendering scene passes" ) + EXPOSURE_BEGIN( TriStepRenderPass, "Render step for rendering scene passes" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderPass ) - MAP_ATTRIBUTE - ( - "scene", + MAP_ATTRIBUTE( + "scene", m_scene, "The scene to be rendered", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "passType", + MAP_ATTRIBUTE_WITH_CHOOSER( + "passType", m_pass, "Pass to be rendered", Be::READWRITE | Be::PERSIST | Be::ENUM, - TriMultiPassScenePassTypeChooser - ) + TriMultiPassScenePassTypeChooser ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, - 2, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, + 2, "Create a render step to render a scene with a specific pass\n" ":param scene: ITr2MultiPassScene (default None)\n" - ":param passType: TRIPREPASS pass type (default TRIPREPASS_BEGIN_RENDER)" - ) + ":param passType: TRIPREPASS pass type (default TRIPREPASS_BEGIN_RENDER)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderScene.cpp b/trinity/RenderJob/TriStepRenderScene.cpp index a345655aa..15ecf8a4f 100644 --- a/trinity/RenderJob/TriStepRenderScene.cpp +++ b/trinity/RenderJob/TriStepRenderScene.cpp @@ -8,7 +8,7 @@ TriStepRenderScene::TriStepRenderScene( IRoot* lockobj ) { } -TriStepRenderScene::~TriStepRenderScene(void) +TriStepRenderScene::~TriStepRenderScene( void ) { } diff --git a/trinity/RenderJob/TriStepRenderScene.h b/trinity/RenderJob/TriStepRenderScene.h index 66a9cd7bf..620ddbc45 100644 --- a/trinity/RenderJob/TriStepRenderScene.h +++ b/trinity/RenderJob/TriStepRenderScene.h @@ -9,18 +9,19 @@ #include "include/ITr2Scene.h" -BLUE_CLASS( TriStepRenderScene ) : public TriRenderStep +BLUE_CLASS( TriStepRenderScene ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderScene( IRoot* lockobj = 0 ); - ~TriStepRenderScene(void); + ~TriStepRenderScene( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void py__init__( ITr2Scene* scene ); + void py__init__( ITr2Scene * scene ); ITr2ScenePtr m_scene; }; diff --git a/trinity/RenderJob/TriStepRenderSceneDebug.cpp b/trinity/RenderJob/TriStepRenderSceneDebug.cpp index 63c2fad69..843a7217d 100644 --- a/trinity/RenderJob/TriStepRenderSceneDebug.cpp +++ b/trinity/RenderJob/TriStepRenderSceneDebug.cpp @@ -9,7 +9,7 @@ TriStepRenderSceneDebug::TriStepRenderSceneDebug( IRoot* lockobj ) { } -TriStepRenderSceneDebug::~TriStepRenderSceneDebug(void) +TriStepRenderSceneDebug::~TriStepRenderSceneDebug( void ) { } diff --git a/trinity/RenderJob/TriStepRenderSceneDebug.h b/trinity/RenderJob/TriStepRenderSceneDebug.h index 9aa80c3a1..5ec473dc9 100644 --- a/trinity/RenderJob/TriStepRenderSceneDebug.h +++ b/trinity/RenderJob/TriStepRenderSceneDebug.h @@ -9,19 +9,20 @@ #include "include/ITr2Scene.h" -BLUE_CLASS( TriStepRenderSceneDebug ) : public TriRenderStep +BLUE_CLASS( TriStepRenderSceneDebug ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderSceneDebug( IRoot* lockobj = 0 ); - ~TriStepRenderSceneDebug(void); + ~TriStepRenderSceneDebug( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void py__init__( ITr2Scene* scene ); + void py__init__( ITr2Scene * scene ); private: ITr2ScenePtr m_scene; diff --git a/trinity/RenderJob/TriStepRenderSceneDebug_Blue.cpp b/trinity/RenderJob/TriStepRenderSceneDebug_Blue.cpp index 64cc16a84..df3b53caf 100644 --- a/trinity/RenderJob/TriStepRenderSceneDebug_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderSceneDebug_Blue.cpp @@ -7,21 +7,19 @@ BLUE_DEFINE( TriStepRenderSceneDebug ); const Be::ClassInfo* TriStepRenderSceneDebug::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderSceneDebug, "" ) + EXPOSURE_BEGIN( TriStepRenderSceneDebug, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderSceneDebug ) - MAP_ATTRIBUTE( "scene", m_scene, "na", Be::READWRITE) + MAP_ATTRIBUTE( "scene", m_scene, "na", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Create a render step to render a ITr2Scene with debug rendering\n" - ":param scene: an ITr2Scene (default None)" - ) + ":param scene: an ITr2Scene (default None)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderScene_Blue.cpp b/trinity/RenderJob/TriStepRenderScene_Blue.cpp index f7071ad55..53a991a47 100644 --- a/trinity/RenderJob/TriStepRenderScene_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderScene_Blue.cpp @@ -7,27 +7,23 @@ BLUE_DEFINE( TriStepRenderScene ); const Be::ClassInfo* TriStepRenderScene::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderScene, "Render step for rendering a scene" ) + EXPOSURE_BEGIN( TriStepRenderScene, "Render step for rendering a scene" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderScene ) - MAP_ATTRIBUTE - ( - "scene", + MAP_ATTRIBUTE( + "scene", m_scene, "The scene to be rendered", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 1, "Creates a render step that renders an ITr2Scene\n" - ":param scene: an ITr2Scene object" - ) + ":param scene: an ITr2Scene object" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRenderTexture.cpp b/trinity/RenderJob/TriStepRenderTexture.cpp index 43d01d38e..5beefc59d 100644 --- a/trinity/RenderJob/TriStepRenderTexture.cpp +++ b/trinity/RenderJob/TriStepRenderTexture.cpp @@ -10,7 +10,7 @@ using namespace Tr2RenderContextEnum; -TriStepRenderTexture::TriStepRenderTexture( IRoot* lockobj ) : +TriStepRenderTexture::TriStepRenderTexture( IRoot* lockobj ) : m_textureSize( 0, 0 ), m_failClearColor( 0 ), m_tlTexCoord( 0.0f, 0.0f ), @@ -18,7 +18,7 @@ TriStepRenderTexture::TriStepRenderTexture( IRoot* lockobj ) : { } -TriStepRenderTexture::~TriStepRenderTexture(void) +TriStepRenderTexture::~TriStepRenderTexture( void ) { } @@ -31,13 +31,13 @@ void TriStepRenderTexture::BlankOut() void TriStepRenderTexture::SetTexture( ITr2TextureProvider* tex ) { BlankOut(); - m_texture = tex; + m_texture = tex; } void TriStepRenderTexture::SetTexture( Tr2AtlasTexture* tex ) { BlankOut(); - m_atlasTexture = tex; + m_atlasTexture = tex; } TriStepResult TriStepRenderTexture::ClearIfFail( bool result, Tr2RenderContext& renderContext ) @@ -53,20 +53,20 @@ TriStepResult TriStepRenderTexture::Execute( Be::Time realTime, Be::Time simTime { if( m_texture && m_texture->GetTexture() ) { - return ClearIfFail( Tr2Renderer::DrawTexture( renderContext, *m_texture->GetTexture(), m_tlTexCoord, m_brTexCoord ), renderContext ); + return ClearIfFail( Tr2Renderer::DrawTexture( renderContext, *m_texture->GetTexture(), m_tlTexCoord, m_brTexCoord ), renderContext ); } - + if( m_atlasTexture && m_atlasTexture->GetTexture() ) { - float rectX = m_tlTexCoord.x * m_atlasTexture->GetWidth(); - float rectY = m_tlTexCoord.y * m_atlasTexture->GetHeight(); - float rectWidth = ( m_brTexCoord.x - m_tlTexCoord.x ) * m_atlasTexture->GetWidth(); - float rectHeight = ( m_brTexCoord.y - m_tlTexCoord.y ) * m_atlasTexture->GetHeight(); + float rectX = m_tlTexCoord.x * m_atlasTexture->GetWidth(); + float rectY = m_tlTexCoord.y * m_atlasTexture->GetHeight(); + float rectWidth = ( m_brTexCoord.x - m_tlTexCoord.x ) * m_atlasTexture->GetWidth(); + float rectHeight = ( m_brTexCoord.y - m_tlTexCoord.y ) * m_atlasTexture->GetHeight(); Vector4 tw; m_atlasTexture->CalcSubTextureWindow( tw, rectX, rectY, rectWidth, rectHeight ); - - return ClearIfFail( Tr2Renderer::DrawTexture( renderContext, *m_texture->GetTexture(), Vector2( tw.x, tw.y ), Vector2( tw.x + tw.z, tw.y + tw.w ) ), renderContext ); + + return ClearIfFail( Tr2Renderer::DrawTexture( renderContext, *m_texture->GetTexture(), Vector2( tw.x, tw.y ), Vector2( tw.x + tw.z, tw.y + tw.w ) ), renderContext ); } return RS_OK; diff --git a/trinity/RenderJob/TriStepRenderTexture.h b/trinity/RenderJob/TriStepRenderTexture.h index 0c4c8db05..c8f9eee41 100644 --- a/trinity/RenderJob/TriStepRenderTexture.h +++ b/trinity/RenderJob/TriStepRenderTexture.h @@ -11,21 +11,22 @@ BLUE_DECLARE( Tr2AtlasTexture ); BLUE_DECLARE( Tr2RenderTarget ); BLUE_DECLARE( Tr2DepthStencil ); -BLUE_DECLARE( TriTextureRes ); +BLUE_DECLARE( TriTextureRes ); -BLUE_CLASS( TriStepRenderTexture ) : public TriRenderStep +BLUE_CLASS( TriStepRenderTexture ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRenderTexture( IRoot* lockobj = 0 ); - ~TriStepRenderTexture(void); + ~TriStepRenderTexture( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void SetTexture( ITr2TextureProvider* tex ); - void SetTexture( Tr2AtlasTexture* tex ); + void SetTexture( ITr2TextureProvider * tex ); + void SetTexture( Tr2AtlasTexture * tex ); private: void BlankOut(); @@ -36,7 +37,6 @@ BLUE_CLASS( TriStepRenderTexture ) : public TriRenderStep Vector2 m_brTexCoord; Vector2 m_textureSize; unsigned m_failClearColor; - }; TYPEDEF_BLUECLASS( TriStepRenderTexture ); diff --git a/trinity/RenderJob/TriStepRenderTexture_Blue.cpp b/trinity/RenderJob/TriStepRenderTexture_Blue.cpp index 6c56d15fd..3eda0a0ac 100644 --- a/trinity/RenderJob/TriStepRenderTexture_Blue.cpp +++ b/trinity/RenderJob/TriStepRenderTexture_Blue.cpp @@ -60,14 +60,14 @@ static PyObject* py__init__( PyObject* self, PyObject* args ) const Be::ClassInfo* TriStepRenderTexture::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRenderTexture, "" ) + EXPOSURE_BEGIN( TriStepRenderTexture, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRenderTexture ) - MAP_ATTRIBUTE( "texture", m_texture,"TriTextureRes that will be rendered", Be::READWRITE ) - MAP_ATTRIBUTE( "renderTarget", m_texture,"Tr2RenderTarget that will be rendered", Be::READWRITE ) - MAP_ATTRIBUTE( "depthStencil", m_texture,"Tr2DepthStencil that will be rendered", Be::READWRITE ) + MAP_ATTRIBUTE( "texture", m_texture, "TriTextureRes that will be rendered", Be::READWRITE ) + MAP_ATTRIBUTE( "renderTarget", m_texture, "Tr2RenderTarget that will be rendered", Be::READWRITE ) + MAP_ATTRIBUTE( "depthStencil", m_texture, "Tr2DepthStencil that will be rendered", Be::READWRITE ) MAP_ATTRIBUTE( "tlTexCoord", m_tlTexCoord, "top left texture coordinate", Be::READWRITE ) MAP_ATTRIBUTE( "brTexCoord", m_brTexCoord, "bottom right texture coordinate", Be::READWRITE ) @@ -75,14 +75,12 @@ const Be::ClassInfo* TriStepRenderTexture::ExposeToBlue() MAP_ATTRIBUTE( "failClearColor", m_failClearColor, "color to use when clearing due to a failed blit", Be::READWRITE ) - MAP_METHOD - ( - "__init__", - py__init__, - "Creates a render step that renders a texture\n" + MAP_METHOD( + "__init__", + py__init__, + "Creates a render step that renders a texture\n" ":param texture: texture to render\n" - ":type texture: Optional[ITr2TextureProvider | Tr2AtlasTexture]" - ) + ":type texture: Optional[ITr2TextureProvider | Tr2AtlasTexture]" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepResolve.cpp b/trinity/RenderJob/TriStepResolve.cpp index 18ae5f9b9..989cce6c4 100644 --- a/trinity/RenderJob/TriStepResolve.cpp +++ b/trinity/RenderJob/TriStepResolve.cpp @@ -5,8 +5,8 @@ #include "Tr2RenderTarget.h" -TriStepResolve::TriStepResolve( IRoot* lockobj ) -: m_generateMipmap( false ) +TriStepResolve::TriStepResolve( IRoot* lockobj ) : + m_generateMipmap( false ) { } diff --git a/trinity/RenderJob/TriStepResolve.h b/trinity/RenderJob/TriStepResolve.h index 930af1685..be7551970 100644 --- a/trinity/RenderJob/TriStepResolve.h +++ b/trinity/RenderJob/TriStepResolve.h @@ -9,22 +9,23 @@ BLUE_DECLARE( Tr2RenderTarget ); -BLUE_CLASS( TriStepResolve ) : public TriRenderStep +BLUE_CLASS( TriStepResolve ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepResolve( IRoot* lockobj = 0 ); - + //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void py__init__( Tr2RenderTarget* destination, Tr2RenderTarget* source ); + void py__init__( Tr2RenderTarget * destination, Tr2RenderTarget * source ); private: - Tr2RenderTargetPtr m_source; - Tr2RenderTargetPtr m_destination; - bool m_generateMipmap; + Tr2RenderTargetPtr m_source; + Tr2RenderTargetPtr m_destination; + bool m_generateMipmap; }; TYPEDEF_BLUECLASS( TriStepResolve ); diff --git a/trinity/RenderJob/TriStepResolve_Blue.cpp b/trinity/RenderJob/TriStepResolve_Blue.cpp index 45c8e573c..ec9f1457b 100644 --- a/trinity/RenderJob/TriStepResolve_Blue.cpp +++ b/trinity/RenderJob/TriStepResolve_Blue.cpp @@ -8,25 +8,23 @@ BLUE_DEFINE( TriStepResolve ); const Be::ClassInfo* TriStepResolve::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepResolve, "" ) + EXPOSURE_BEGIN( TriStepResolve, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepResolve ) - MAP_ATTRIBUTE( "source", m_source, "Source of the resolve", Be::READWRITE ) - MAP_ATTRIBUTE( "destination", m_destination, "Target of the resolve", Be::READWRITE ) - MAP_ATTRIBUTE( "generateMipmap", m_generateMipmap, "Generate mipmaps in destination after the resolve?", Be::READWRITE ) + MAP_ATTRIBUTE( "source", m_source, "Source of the resolve", Be::READWRITE ) + MAP_ATTRIBUTE( "destination", m_destination, "Target of the resolve", Be::READWRITE ) + MAP_ATTRIBUTE( "generateMipmap", m_generateMipmap, "Generate mipmaps in destination after the resolve?", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 2, "Creates a render step that resolves source into destination rendertargets. If source is not MSAA,\n" "this is a copy (but formats and dimensions must still match exactly).\n" ":param destination: Tr2RenderTarget\n" - ":param source: Tr2RenderTarget" - ) + ":param source: Tr2RenderTarget" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepRunComputeShader.cpp b/trinity/RenderJob/TriStepRunComputeShader.cpp index 651137e85..4e485b6ab 100644 --- a/trinity/RenderJob/TriStepRunComputeShader.cpp +++ b/trinity/RenderJob/TriStepRunComputeShader.cpp @@ -7,25 +7,22 @@ #include "Tr2Renderer.h" -#include "Tr2ConstantBufferFormats.h" // hack +#include "Tr2ConstantBufferFormats.h" // hack using namespace Tr2RenderContextEnum; CCP_STATS_DECLARE( rsRunComputeShaderCount, "Trinity/RenderStep/RunComputeShaderCount", true, CST_COUNTER_LOW, "Calls to TriStepRunComputeShader::Execute per frame" ); -TriStepRunComputeShader::TriStepRunComputeShader( IRoot* lockobj ) - : m_groupDimX( 1 ) - , m_groupDimY( 1 ) - , m_groupDimZ( 1 ) - , m_offsetForArgs( 0 ) +TriStepRunComputeShader::TriStepRunComputeShader( IRoot* lockobj ) : + m_groupDimX( 1 ), m_groupDimY( 1 ), m_groupDimZ( 1 ), m_offsetForArgs( 0 ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- -void TriStepRunComputeShader::py__init__( +void TriStepRunComputeShader::py__init__( Tr2Material* effect, Be::OptionalWithDefaultValue groupDimX, Be::OptionalWithDefaultValue groupDimY, diff --git a/trinity/RenderJob/TriStepRunComputeShader.h b/trinity/RenderJob/TriStepRunComputeShader.h index 24cf62c29..6272f2ef6 100644 --- a/trinity/RenderJob/TriStepRunComputeShader.h +++ b/trinity/RenderJob/TriStepRunComputeShader.h @@ -10,22 +10,23 @@ BLUE_DECLARE( Tr2Material ); BLUE_DECLARE_INTERFACE( ITr2GpuBuffer ); -BLUE_CLASS( TriStepRunComputeShader ) : public TriRenderStep +BLUE_CLASS( TriStepRunComputeShader ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRunComputeShader( IRoot* lockobj = 0 ); - void py__init__( - Tr2Material* effect, + void py__init__( + Tr2Material * effect, Be::OptionalWithDefaultValue groupDimX, Be::OptionalWithDefaultValue groupDimY, Be::OptionalWithDefaultValue groupDimZ ); - + //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); - + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); + Tr2MaterialPtr m_effect; unsigned m_groupDimX; unsigned m_groupDimY; diff --git a/trinity/RenderJob/TriStepRunComputeShader_Blue.cpp b/trinity/RenderJob/TriStepRunComputeShader_Blue.cpp index 6927514c7..e848a62ce 100644 --- a/trinity/RenderJob/TriStepRunComputeShader_Blue.cpp +++ b/trinity/RenderJob/TriStepRunComputeShader_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( TriStepRunComputeShader ); const Be::ClassInfo* TriStepRunComputeShader::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepRunComputeShader, "" ) + EXPOSURE_BEGIN( TriStepRunComputeShader, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepRunComputeShader ) @@ -18,21 +18,19 @@ const Be::ClassInfo* TriStepRunComputeShader::ExposeToBlue() MAP_ATTRIBUTE( "groupDimX", m_groupDimX, "Dispatch group dimension.X", Be::READWRITE ) MAP_ATTRIBUTE( "groupDimY", m_groupDimY, "Dispatch group dimension.Y", Be::READWRITE ) MAP_ATTRIBUTE( "groupDimZ", m_groupDimZ, "Dispatch group dimension.Z", Be::READWRITE ) - + MAP_ATTRIBUTE( "indirectionBuffer", m_indirectionBuffer, "If set, use DispatchIndirect with this buffer holding the arguments", Be::READWRITE ) MAP_ATTRIBUTE( "offsetForArgs", m_offsetForArgs, "The argument offset in indirectionBuffer for an indirect dispatch.", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 4, "Run a compute shader in renderStep.Execute\n" "\n:param effect: A Tr2Effect containing a compute shader (default None)" "\n:param dimX: unsigned int, dispatch group dimension.X, default 1" "\n:param dimY: unsigned int, dispatch group dimension.Y, default 1" - "\n:param dimZ: unsigned int, dispatch group dimension.Z, default 1" - ) + "\n:param dimZ: unsigned int, dispatch group dimension.Z, default 1" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepRunJob.cpp b/trinity/RenderJob/TriStepRunJob.cpp index 75c200aac..10f43d224 100644 --- a/trinity/RenderJob/TriStepRunJob.cpp +++ b/trinity/RenderJob/TriStepRunJob.cpp @@ -6,10 +6,9 @@ TriStepRunJob::TriStepRunJob( IRoot* lockobj ) { - } -TriStepRunJob::~TriStepRunJob(void) +TriStepRunJob::~TriStepRunJob( void ) { } @@ -26,18 +25,18 @@ TriStepResult TriStepRunJob::Execute( Be::Time realTime, Be::Time simTime, Tr2Re switch( status ) { - case RJ_DONE: - return RS_OK; + case RJ_DONE: + return RS_OK; - case RJ_IN_PROGRESS: - return RS_IN_PROGRESS; + case RJ_IN_PROGRESS: + return RS_IN_PROGRESS; - case RJ_FAILED: - return RS_FAILED; + case RJ_FAILED: + return RS_FAILED; - default: - CCP_LOGERR( "TriStepRunJob::Execute: Unexpected return value from running render job (%d)", status ); - return RS_FAILED; + default: + CCP_LOGERR( "TriStepRunJob::Execute: Unexpected return value from running render job (%d)", status ); + return RS_FAILED; } } diff --git a/trinity/RenderJob/TriStepRunJob.h b/trinity/RenderJob/TriStepRunJob.h index 14f15f4bb..36117b4e9 100644 --- a/trinity/RenderJob/TriStepRunJob.h +++ b/trinity/RenderJob/TriStepRunJob.h @@ -10,18 +10,19 @@ BLUE_DECLARE( TriRenderJob ); -BLUE_CLASS( TriStepRunJob ) : public TriRenderStep +BLUE_CLASS( TriStepRunJob ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepRunJob( IRoot* lockobj = 0 ); - ~TriStepRunJob(void); + ~TriStepRunJob( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void SetRenderJob( TriRenderJob* job ); + void SetRenderJob( TriRenderJob * job ); private: TriRenderJobPtr m_job; diff --git a/trinity/RenderJob/TriStepRunJob_Blue.cpp b/trinity/RenderJob/TriStepRunJob_Blue.cpp index f5923931f..26395c70e 100644 --- a/trinity/RenderJob/TriStepRunJob_Blue.cpp +++ b/trinity/RenderJob/TriStepRunJob_Blue.cpp @@ -11,22 +11,18 @@ const Be::ClassInfo* TriStepRunJob::ExposeToBlue() EXPOSURE_BEGIN( TriStepRunJob, "" ) MAP_INTERFACE( TriStepRunJob ) - MAP_ATTRIBUTE - ( - "job", - m_job, - "The render job to run", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "job", + m_job, + "The render job to run", + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", SetRenderJob, 1, "Creates a render job that runs another renderjob\n" - ":param renderJob: the TriRenderJob to run" - ) + ":param renderJob: the TriRenderJob to run" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetDebugRenderer.cpp b/trinity/RenderJob/TriStepSetDebugRenderer.cpp index 7cadcae00..bbd4c5ec9 100644 --- a/trinity/RenderJob/TriStepSetDebugRenderer.cpp +++ b/trinity/RenderJob/TriStepSetDebugRenderer.cpp @@ -8,7 +8,7 @@ TriStepSetDebugRenderer::TriStepSetDebugRenderer( IRoot* lockobj ) { } -TriStepSetDebugRenderer::~TriStepSetDebugRenderer(void) +TriStepSetDebugRenderer::~TriStepSetDebugRenderer( void ) { } diff --git a/trinity/RenderJob/TriStepSetDebugRenderer.h b/trinity/RenderJob/TriStepSetDebugRenderer.h index e3059ed1e..ed5f1a208 100644 --- a/trinity/RenderJob/TriStepSetDebugRenderer.h +++ b/trinity/RenderJob/TriStepSetDebugRenderer.h @@ -11,23 +11,25 @@ BLUE_DECLARE_INTERFACE( ITr2DebugRenderer ); // ------------------------------------------------------------- // Description: -// TriStepSetDebugRenderer is a render step that assigns the +// TriStepSetDebugRenderer is a render step that assigns the // given debug renderer to the global debug renderer variable. // SeeAlso: // TriRenderStep // ------------------------------------------------------------- -BLUE_CLASS( TriStepSetDebugRenderer ) : public TriRenderStep +BLUE_CLASS( TriStepSetDebugRenderer ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepSetDebugRenderer( IRoot* lockobj = 0 ); - ~TriStepSetDebugRenderer(void); + ~TriStepSetDebugRenderer( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); + + void SetDebugRenderer( ITr2DebugRenderer * renderer ); - void SetDebugRenderer( ITr2DebugRenderer* renderer ); private: ITr2DebugRendererPtr m_debugRenderer; }; diff --git a/trinity/RenderJob/TriStepSetDebugRenderer_Blue.cpp b/trinity/RenderJob/TriStepSetDebugRenderer_Blue.cpp index 434b71e95..77c833cd2 100644 --- a/trinity/RenderJob/TriStepSetDebugRenderer_Blue.cpp +++ b/trinity/RenderJob/TriStepSetDebugRenderer_Blue.cpp @@ -8,14 +8,14 @@ BLUE_DEFINE( TriStepSetDebugRenderer ); const Be::ClassInfo* TriStepSetDebugRenderer::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetDebugRenderer, "" ) + EXPOSURE_BEGIN( TriStepSetDebugRenderer, "" ) MAP_INTERFACE( TriStepSetDebugRenderer ) - MAP_ATTRIBUTE( "renderer", m_debugRenderer, "Debug renderer to set as global debug renderer", Be::READWRITE) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - SetDebugRenderer, - 1, + MAP_ATTRIBUTE( "renderer", m_debugRenderer, "Debug renderer to set as global debug renderer", Be::READWRITE ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + SetDebugRenderer, + 1, ":param renderer: debug renderer" ) EXPOSURE_CHAINTO( TriRenderStep ) diff --git a/trinity/RenderJob/TriStepSetDepthStencil.cpp b/trinity/RenderJob/TriStepSetDepthStencil.cpp index d528ee20a..7c6dd6c75 100644 --- a/trinity/RenderJob/TriStepSetDepthStencil.cpp +++ b/trinity/RenderJob/TriStepSetDepthStencil.cpp @@ -11,7 +11,7 @@ TriStepSetDepthStencil::TriStepSetDepthStencil( IRoot* lockobj ) { } -TriStepSetDepthStencil::~TriStepSetDepthStencil(void) +TriStepSetDepthStencil::~TriStepSetDepthStencil( void ) { } diff --git a/trinity/RenderJob/TriStepSetDepthStencil.h b/trinity/RenderJob/TriStepSetDepthStencil.h index fb1386f08..091d4047b 100644 --- a/trinity/RenderJob/TriStepSetDepthStencil.h +++ b/trinity/RenderJob/TriStepSetDepthStencil.h @@ -9,22 +9,26 @@ BLUE_DECLARE( Tr2DepthStencil ); -BLUE_CLASS( TriStepSetDepthStencil ) : public TriRenderStep +BLUE_CLASS( TriStepSetDepthStencil ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetDepthStencil( IRoot* lockobj = 0); - ~TriStepSetDepthStencil(void); + + TriStepSetDepthStencil( IRoot* lockobj = 0 ); + ~TriStepSetDepthStencil( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void SetDepthStencil( Tr2DepthStencil* depthStencil ) { m_depthStencil = depthStencil; } + void SetDepthStencil( Tr2DepthStencil * depthStencil ) + { + m_depthStencil = depthStencil; + } private: - Tr2DepthStencilPtr m_depthStencil; + Tr2DepthStencilPtr m_depthStencil; }; TYPEDEF_BLUECLASS( TriStepSetDepthStencil ); diff --git a/trinity/RenderJob/TriStepSetDepthStencil_Blue.cpp b/trinity/RenderJob/TriStepSetDepthStencil_Blue.cpp index e2bb99bd8..228cb3651 100644 --- a/trinity/RenderJob/TriStepSetDepthStencil_Blue.cpp +++ b/trinity/RenderJob/TriStepSetDepthStencil_Blue.cpp @@ -10,21 +10,19 @@ BLUE_DEFINE( TriStepSetDepthStencil ); const Be::ClassInfo* TriStepSetDepthStencil::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetDepthStencil, "" ) + EXPOSURE_BEGIN( TriStepSetDepthStencil, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetDepthStencil ) MAP_ATTRIBUTE( "depthStencil", m_depthStencil, "Tr2DepthStencil set by this step", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", SetDepthStencil, 1, "Creates a render job that sets a depth stencil surface to the device\n" - ":param depthStencil: a Tr2DepthStencil" - ) + ":param depthStencil: a Tr2DepthStencil" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetProjection.cpp b/trinity/RenderJob/TriStepSetProjection.cpp index 6550dcdfa..e2b11223c 100644 --- a/trinity/RenderJob/TriStepSetProjection.cpp +++ b/trinity/RenderJob/TriStepSetProjection.cpp @@ -8,7 +8,7 @@ TriStepSetProjection::TriStepSetProjection( IRoot* lockobj ) { } -TriStepSetProjection::~TriStepSetProjection(void) +TriStepSetProjection::~TriStepSetProjection( void ) { } diff --git a/trinity/RenderJob/TriStepSetProjection.h b/trinity/RenderJob/TriStepSetProjection.h index 3ea511a78..3e3ad6537 100644 --- a/trinity/RenderJob/TriStepSetProjection.h +++ b/trinity/RenderJob/TriStepSetProjection.h @@ -8,19 +8,20 @@ #include "TriRenderStep.h" #include "TriProjection.h" -BLUE_CLASS( TriStepSetProjection ) : public TriRenderStep +BLUE_CLASS( TriStepSetProjection ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetProjection( IRoot* lockobj = 0); - ~TriStepSetProjection(void); + + TriStepSetProjection( IRoot* lockobj = 0 ); + ~TriStepSetProjection( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void SetProjection( TriProjection* projection ); + void SetProjection( TriProjection * projection ); private: TriProjectionPtr m_projection; diff --git a/trinity/RenderJob/TriStepSetProjection_Blue.cpp b/trinity/RenderJob/TriStepSetProjection_Blue.cpp index e31dbc50e..c6fa44c9f 100644 --- a/trinity/RenderJob/TriStepSetProjection_Blue.cpp +++ b/trinity/RenderJob/TriStepSetProjection_Blue.cpp @@ -8,21 +8,19 @@ BLUE_DEFINE( TriStepSetProjection ); const Be::ClassInfo* TriStepSetProjection::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetProjection, "" ) + EXPOSURE_BEGIN( TriStepSetProjection, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetProjection ) - MAP_ATTRIBUTE("projection", m_projection, "na", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "projection", m_projection, "na", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", - SetProjection, + SetProjection, 1, "Create a render step to set the projection to the device\n" - ":param projection: a TriProjection to set (default None)" - ) + ":param projection: a TriProjection to set (default None)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetRenderState.cpp b/trinity/RenderJob/TriStepSetRenderState.cpp index 9cc051db6..de6d95dac 100644 --- a/trinity/RenderJob/TriStepSetRenderState.cpp +++ b/trinity/RenderJob/TriStepSetRenderState.cpp @@ -4,8 +4,8 @@ #include "TriStepSetRenderState.h" -TriStepSetRenderState::TriStepSetRenderState( IRoot* lockobj ) - :m_state( static_cast( 0 ) ), +TriStepSetRenderState::TriStepSetRenderState( IRoot* lockobj ) : + m_state( static_cast( 0 ) ), m_value( 0 ) { } diff --git a/trinity/RenderJob/TriStepSetRenderState.h b/trinity/RenderJob/TriStepSetRenderState.h index cc0c0aefc..4350c47b8 100644 --- a/trinity/RenderJob/TriStepSetRenderState.h +++ b/trinity/RenderJob/TriStepSetRenderState.h @@ -9,12 +9,11 @@ BLUE_DECLARE( TriStepSetRenderState ); -class TriStepSetRenderState: - public TriRenderStep +class TriStepSetRenderState : public TriRenderStep { public: - EXPOSE_TO_BLUE(); - TriStepSetRenderState( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriStepSetRenderState( IRoot* lockobj = NULL ); //IRenderStep TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); diff --git a/trinity/RenderJob/TriStepSetRenderState_Blue.cpp b/trinity/RenderJob/TriStepSetRenderState_Blue.cpp index 01c504bac..71eb536ab 100644 --- a/trinity/RenderJob/TriStepSetRenderState_Blue.cpp +++ b/trinity/RenderJob/TriStepSetRenderState_Blue.cpp @@ -22,7 +22,7 @@ static PyObject* py__init__( PyObject* self, PyObject* args ) if( pyState && pyStateValue ) { unsigned int state = 0; - if( !BlueExtractArgument( pyState, state, 0 )) + if( !BlueExtractArgument( pyState, state, 0 ) ) { return NULL; } @@ -51,25 +51,22 @@ static PyObject* py__init__( PyObject* self, PyObject* args ) const Be::ClassInfo* TriStepSetRenderState::ExposeToBlue() { - EXPOSURE_BEGIN( TriStepSetRenderState, "" ) - MAP_INTERFACE( TriStepSetRenderState ) + EXPOSURE_BEGIN( TriStepSetRenderState, "" ) + MAP_INTERFACE( TriStepSetRenderState ) MAP_INTERFACE( TriRenderStep ) MAP_ATTRIBUTE_WITH_CHOOSER( "state", m_state, "", Be::READWRITE | Be::PERSIST | Be::ENUM, TriD3DRenderState ) MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD - ( - "__init__", - py__init__, + MAP_METHOD( + "__init__", + py__init__, "Creates a render step to set a specific D3D state" "\nIf one of the optional arguments is set, then both must be" "\n:param state: A TriD3DRenderState value (unsigned int)" "\n:type state: int" "\n:param stateValue: A valid value to set (unsigned int)" - "\n:type stateValue: int" - ) + "\n:type stateValue: int" ) EXPOSURE_CHAINTO( TriRenderStep ) - } diff --git a/trinity/RenderJob/TriStepSetRenderTarget.cpp b/trinity/RenderJob/TriStepSetRenderTarget.cpp index 37c06d40c..3f7cf7ccc 100644 --- a/trinity/RenderJob/TriStepSetRenderTarget.cpp +++ b/trinity/RenderJob/TriStepSetRenderTarget.cpp @@ -9,13 +9,13 @@ TriStepSetRenderTarget::TriStepSetRenderTarget( IRoot* lockobj ) { } -TriStepSetRenderTarget::~TriStepSetRenderTarget(void) +TriStepSetRenderTarget::~TriStepSetRenderTarget( void ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void TriStepSetRenderTarget::py__init__( Tr2RenderTarget* renderTarget ) { diff --git a/trinity/RenderJob/TriStepSetRenderTarget.h b/trinity/RenderJob/TriStepSetRenderTarget.h index 5081ad815..e2bc6bf51 100644 --- a/trinity/RenderJob/TriStepSetRenderTarget.h +++ b/trinity/RenderJob/TriStepSetRenderTarget.h @@ -8,20 +8,21 @@ #include "TriRenderStep.h" #include "Tr2RenderTarget.h" -BLUE_CLASS( TriStepSetRenderTarget ) : public TriRenderStep +BLUE_CLASS( TriStepSetRenderTarget ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetRenderTarget( IRoot* lockobj = 0); - ~TriStepSetRenderTarget(void); - void py__init__( Tr2RenderTarget* renderTarget ); + TriStepSetRenderTarget( IRoot* lockobj = 0 ); + ~TriStepSetRenderTarget( void ); + + void py__init__( Tr2RenderTarget * renderTarget ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - Tr2RenderTargetPtr m_renderTarget; + Tr2RenderTargetPtr m_renderTarget; }; TYPEDEF_BLUECLASS( TriStepSetRenderTarget ); diff --git a/trinity/RenderJob/TriStepSetRenderTarget_Blue.cpp b/trinity/RenderJob/TriStepSetRenderTarget_Blue.cpp index 604b22ef7..cb62a7070 100644 --- a/trinity/RenderJob/TriStepSetRenderTarget_Blue.cpp +++ b/trinity/RenderJob/TriStepSetRenderTarget_Blue.cpp @@ -9,21 +9,19 @@ BLUE_DEFINE( TriStepSetRenderTarget ); const Be::ClassInfo* TriStepSetRenderTarget::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetRenderTarget, "" ) + EXPOSURE_BEGIN( TriStepSetRenderTarget, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetRenderTarget ) - MAP_ATTRIBUTE("renderTarget", m_renderTarget, "na", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "renderTarget", m_renderTarget, "na", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Creates a render job that sets a depth stencil to the device\n" - ":param renderTarget: a Tr2RenderTarget" - ) + ":param renderTarget: a Tr2RenderTarget" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetStandardRenderStates.cpp b/trinity/RenderJob/TriStepSetStandardRenderStates.cpp index 6fd49227f..50d27b88d 100644 --- a/trinity/RenderJob/TriStepSetStandardRenderStates.cpp +++ b/trinity/RenderJob/TriStepSetStandardRenderStates.cpp @@ -17,7 +17,7 @@ TriStepResult TriStepSetStdRndStates::Execute( Be::Time realTime, Be::Time simTi // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void TriStepSetStdRndStates::py__init__( Be::Optional state ) { diff --git a/trinity/RenderJob/TriStepSetStandardRenderStates.h b/trinity/RenderJob/TriStepSetStandardRenderStates.h index 882ab7d8a..ac32c68fd 100644 --- a/trinity/RenderJob/TriStepSetStandardRenderStates.h +++ b/trinity/RenderJob/TriStepSetStandardRenderStates.h @@ -12,12 +12,11 @@ BLUE_DECLARE( TriStepSetStdRndStates ); // Note: This class should be renamed once we've lifted the 24 character // limit on class names -class TriStepSetStdRndStates: - public TriRenderStep +class TriStepSetStdRndStates : public TriRenderStep { public: - EXPOSE_TO_BLUE(); - TriStepSetStdRndStates( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriStepSetStdRndStates( IRoot* lockobj = NULL ); void py__init__( Be::Optional state ); diff --git a/trinity/RenderJob/TriStepSetStandardRenderStates_Blue.cpp b/trinity/RenderJob/TriStepSetStandardRenderStates_Blue.cpp index c35f26dbd..054673d08 100644 --- a/trinity/RenderJob/TriStepSetStandardRenderStates_Blue.cpp +++ b/trinity/RenderJob/TriStepSetStandardRenderStates_Blue.cpp @@ -6,18 +6,17 @@ BLUE_DEFINE( TriStepSetStdRndStates ); -const Be::VarChooser TriRMChooser[] = -{ +const Be::VarChooser TriRMChooser[] = { // Name Value Docstring - { "RM_OPAQUE", BeCast( Tr2EffectStateManager::RM_OPAQUE ), "Opaque rendering" }, - { "RM_DECAL", BeCast( Tr2EffectStateManager::RM_DECAL ), "Decal rendering" }, - { "RM_DECAL_NO_DEPTH", BeCast( Tr2EffectStateManager::RM_DECAL_NO_DEPTH ), "Decal rendering (Normals Only)" }, - { "RM_ALPHA", BeCast( Tr2EffectStateManager::RM_ALPHA ), "Alpha-blended rendering" }, - { "RM_ALPHA_ADDITIVE", BeCast( Tr2EffectStateManager::RM_ALPHA_ADDITIVE ), "Additive rendering" }, - { "RM_DEPTH_ONLY", BeCast( Tr2EffectStateManager::RM_DEPTH_ONLY ), "Depth-only rendering" }, - { "RM_PICKING", BeCast( Tr2EffectStateManager::RM_PICKING ), "Rendering for picking" }, - { "RM_FULLSCREEN", BeCast( Tr2EffectStateManager::RM_FULLSCREEN ), "Full-screen effects (2D) rendering" }, - { "RM_SPRITE2D", BeCast( Tr2EffectStateManager::RM_SPRITE2D ), "2D sprite rendering" }, + { "RM_OPAQUE", BeCast( Tr2EffectStateManager::RM_OPAQUE ), "Opaque rendering" }, + { "RM_DECAL", BeCast( Tr2EffectStateManager::RM_DECAL ), "Decal rendering" }, + { "RM_DECAL_NO_DEPTH", BeCast( Tr2EffectStateManager::RM_DECAL_NO_DEPTH ), "Decal rendering (Normals Only)" }, + { "RM_ALPHA", BeCast( Tr2EffectStateManager::RM_ALPHA ), "Alpha-blended rendering" }, + { "RM_ALPHA_ADDITIVE", BeCast( Tr2EffectStateManager::RM_ALPHA_ADDITIVE ), "Additive rendering" }, + { "RM_DEPTH_ONLY", BeCast( Tr2EffectStateManager::RM_DEPTH_ONLY ), "Depth-only rendering" }, + { "RM_PICKING", BeCast( Tr2EffectStateManager::RM_PICKING ), "Rendering for picking" }, + { "RM_FULLSCREEN", BeCast( Tr2EffectStateManager::RM_FULLSCREEN ), "Full-screen effects (2D) rendering" }, + { "RM_SPRITE2D", BeCast( Tr2EffectStateManager::RM_SPRITE2D ), "2D sprite rendering" }, { 0 } }; @@ -25,20 +24,18 @@ BLUE_REGISTER_ENUM( "RENDERING_MODE", Tr2EffectStateManager::RenderingMode, TriR const Be::ClassInfo* TriStepSetStdRndStates::ExposeToBlue() { - EXPOSURE_BEGIN( TriStepSetStdRndStates, "" ) - MAP_INTERFACE( TriStepSetStdRndStates ) + EXPOSURE_BEGIN( TriStepSetStdRndStates, "" ) + MAP_INTERFACE( TriStepSetStdRndStates ) MAP_INTERFACE( TriRenderStep ) MAP_ATTRIBUTE_WITH_CHOOSER( "renderingMode", m_renderingMode, "", Be::READWRITE | Be::PERSIST | Be::ENUM, TriRMChooser ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 1, "Creates a render step that sets a set of standard render states\n" - ":param renderMode: a value from the RM_ enumeration" - ) + ":param renderMode: a value from the RM_ enumeration" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepSetVariableStore.cpp b/trinity/RenderJob/TriStepSetVariableStore.cpp index 4f87e7a05..8ed49d646 100644 --- a/trinity/RenderJob/TriStepSetVariableStore.cpp +++ b/trinity/RenderJob/TriStepSetVariableStore.cpp @@ -5,15 +5,14 @@ #include "Tr2DepthStencil.h" #include "Tr2RenderTarget.h" -TriStepSetVariableStore::TriStepSetVariableStore( IRoot* lockobj ) -: m_type( TRIVARIABLE_INVALID ) +TriStepSetVariableStore::TriStepSetVariableStore( IRoot* lockobj ) : + m_type( TRIVARIABLE_INVALID ) { memset( m_data, 0, sizeof( m_data ) ); } -TriStepSetVariableStore::~TriStepSetVariableStore(void) +TriStepSetVariableStore::~TriStepSetVariableStore( void ) { - } TriStepResult TriStepSetVariableStore::Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) diff --git a/trinity/RenderJob/TriStepSetVariableStore.h b/trinity/RenderJob/TriStepSetVariableStore.h index 5325e27ce..bc8ed6890 100644 --- a/trinity/RenderJob/TriStepSetVariableStore.h +++ b/trinity/RenderJob/TriStepSetVariableStore.h @@ -20,20 +20,20 @@ BLUE_DECLARE( TriTextureRes ); // SeeAlso: // TriRenderStep, Tr2VariableStore // ------------------------------------------------------------- -BLUE_CLASS( TriStepSetVariableStore ): +BLUE_CLASS( TriStepSetVariableStore ) : public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetVariableStore( IRoot* lockobj = 0); - ~TriStepSetVariableStore(void); + + TriStepSetVariableStore( IRoot* lockobj = 0 ); + ~TriStepSetVariableStore( void ); #if BLUE_WITH_PYTHON - void py__init__( Be::Optional name, PyObject* value ); + void py__init__( Be::Optional name, PyObject * value ); #endif - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); void SetName( const std::string& newName ) { @@ -42,7 +42,7 @@ BLUE_CLASS( TriStepSetVariableStore ): #if BLUE_WITH_PYTHON PyObject* GetValue(); - void SetValue( PyObject* val ); + void SetValue( PyObject * val ); #endif private: @@ -51,7 +51,7 @@ BLUE_CLASS( TriStepSetVariableStore ): IRootPtr m_object; ITr2TextureProviderPtr m_texture; ITr2GpuBufferPtr m_gpuBuffer; - char m_data[ sizeof(float) * 16 ]; + char m_data[sizeof( float ) * 16]; }; TYPEDEF_BLUECLASS( TriStepSetVariableStore ); diff --git a/trinity/RenderJob/TriStepSetVariableStore_Blue.cpp b/trinity/RenderJob/TriStepSetVariableStore_Blue.cpp index 5f79b5c7b..d18a92a97 100644 --- a/trinity/RenderJob/TriStepSetVariableStore_Blue.cpp +++ b/trinity/RenderJob/TriStepSetVariableStore_Blue.cpp @@ -11,7 +11,7 @@ BLUE_DEFINE( TriStepSetVariableStore ); // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- #if BLUE_WITH_PYTHON void TriStepSetVariableStore::py__init__( Be::Optional name, PyObject* value ) @@ -117,21 +117,19 @@ void TriStepSetVariableStore::SetValue( PyObject* valueArg ) const Be::ClassInfo* TriStepSetVariableStore::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetVariableStore, "Render step for setting a variable in variable store" ) + EXPOSURE_BEGIN( TriStepSetVariableStore, "Render step for setting a variable in variable store" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetVariableStore ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", py__init__, 2, "Create a render step that sets a variable value to the variable store" "\n:param name: string name of the variable" - "\n:param value: a valid python object to set" - ) + "\n:param value: a valid python object to set" ) #endif MAP_ATTRIBUTE( "variableName", m_variableName, "The name of the Tr2VariableStore variable to set", Be::READWRITE | Be::PERSIST ) #if BLUE_WITH_PYTHON diff --git a/trinity/RenderJob/TriStepSetView.cpp b/trinity/RenderJob/TriStepSetView.cpp index 06d83e19b..3c7396a8b 100644 --- a/trinity/RenderJob/TriStepSetView.cpp +++ b/trinity/RenderJob/TriStepSetView.cpp @@ -9,7 +9,7 @@ TriStepSetView::TriStepSetView( IRoot* lockobj ) { } -TriStepSetView::~TriStepSetView(void) +TriStepSetView::~TriStepSetView( void ) { } diff --git a/trinity/RenderJob/TriStepSetView.h b/trinity/RenderJob/TriStepSetView.h index d726a76d9..59a70ca21 100644 --- a/trinity/RenderJob/TriStepSetView.h +++ b/trinity/RenderJob/TriStepSetView.h @@ -10,19 +10,20 @@ // forwards BLUE_DECLARE( EveCamera ); -BLUE_CLASS( TriStepSetView ) : public TriRenderStep +BLUE_CLASS( TriStepSetView ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetView( IRoot* lockobj = 0); - ~TriStepSetView(void); + + TriStepSetView( IRoot* lockobj = 0 ); + ~TriStepSetView( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void SetViewCameraParent( TriView* view, EveCamera* camera ); + void SetViewCameraParent( TriView * view, EveCamera * camera ); private: TriViewPtr m_view; diff --git a/trinity/RenderJob/TriStepSetView_Blue.cpp b/trinity/RenderJob/TriStepSetView_Blue.cpp index c87d142a6..6e4673c03 100644 --- a/trinity/RenderJob/TriStepSetView_Blue.cpp +++ b/trinity/RenderJob/TriStepSetView_Blue.cpp @@ -9,22 +9,20 @@ BLUE_DEFINE( TriStepSetView ); const Be::ClassInfo* TriStepSetView::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetView, "" ) + EXPOSURE_BEGIN( TriStepSetView, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetView ) - MAP_ATTRIBUTE( "view", m_view, "", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "view", m_view, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "camera", m_camera, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - SetViewCameraParent, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + SetViewCameraParent, 2, "Creates a render step that sets the view to the device" "\n:param view: TriView (default None)" - "\n:param camera: an EveCamera (default None)" - ) + "\n:param camera: an EveCamera (default None)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetViewport.cpp b/trinity/RenderJob/TriStepSetViewport.cpp index 850fd6093..6b30fc955 100644 --- a/trinity/RenderJob/TriStepSetViewport.cpp +++ b/trinity/RenderJob/TriStepSetViewport.cpp @@ -9,7 +9,7 @@ TriStepSetViewport::TriStepSetViewport( IRoot* lockobj ) { } -TriStepSetViewport::~TriStepSetViewport(void) +TriStepSetViewport::~TriStepSetViewport( void ) { } diff --git a/trinity/RenderJob/TriStepSetViewport.h b/trinity/RenderJob/TriStepSetViewport.h index b25b6f767..7b8b3e3cd 100644 --- a/trinity/RenderJob/TriStepSetViewport.h +++ b/trinity/RenderJob/TriStepSetViewport.h @@ -7,20 +7,21 @@ #include "TriRenderStep.h" -BLUE_DECLARE(TriViewport); +BLUE_DECLARE( TriViewport ); -BLUE_CLASS( TriStepSetViewport ) : public TriRenderStep +BLUE_CLASS( TriStepSetViewport ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - - TriStepSetViewport( IRoot* lockobj = 0); - ~TriStepSetViewport(void); + + TriStepSetViewport( IRoot* lockobj = 0 ); + ~TriStepSetViewport( void ); //IRenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void SetViewport( TriViewport* viewport ); + void SetViewport( TriViewport * viewport ); private: TriViewportPtr m_viewport; diff --git a/trinity/RenderJob/TriStepSetViewport_Blue.cpp b/trinity/RenderJob/TriStepSetViewport_Blue.cpp index 273a4632c..927bb9297 100644 --- a/trinity/RenderJob/TriStepSetViewport_Blue.cpp +++ b/trinity/RenderJob/TriStepSetViewport_Blue.cpp @@ -9,21 +9,19 @@ BLUE_DEFINE( TriStepSetViewport ); const Be::ClassInfo* TriStepSetViewport::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetViewport, "" ) + EXPOSURE_BEGIN( TriStepSetViewport, "" ) MAP_INTERFACE( TriRenderStep ) MAP_INTERFACE( TriStepSetViewport ) - MAP_ATTRIBUTE( "viewport", m_viewport, "na", Be::READWRITE | Be::PERSIST) + MAP_ATTRIBUTE( "viewport", m_viewport, "na", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - SetViewport, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + SetViewport, 1, "Creates a render step that sets a viewport to the device\n" - ":param viewport: the TriViewport to set (default None)" - ) + ":param viewport: the TriViewport to set (default None)" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepSetVisualizationMode.cpp b/trinity/RenderJob/TriStepSetVisualizationMode.cpp index 796dc5593..ffef0d67f 100644 --- a/trinity/RenderJob/TriStepSetVisualizationMode.cpp +++ b/trinity/RenderJob/TriStepSetVisualizationMode.cpp @@ -4,18 +4,18 @@ #include "TriStepSetVisualizationMode.h" #include "ITr2VisualizationModeRenderer.h" -TriStepSetVisualizationMode::TriStepSetVisualizationMode( IRoot* lockobj ) -: m_mode( 0 ) +TriStepSetVisualizationMode::TriStepSetVisualizationMode( IRoot* lockobj ) : + m_mode( 0 ) { } -TriStepSetVisualizationMode::~TriStepSetVisualizationMode(void) +TriStepSetVisualizationMode::~TriStepSetVisualizationMode( void ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void TriStepSetVisualizationMode::py__init__( ITr2VisualizationModeRenderer* object, int mode ) { diff --git a/trinity/RenderJob/TriStepSetVisualizationMode.h b/trinity/RenderJob/TriStepSetVisualizationMode.h index e1e6f0d31..62c6e762f 100644 --- a/trinity/RenderJob/TriStepSetVisualizationMode.h +++ b/trinity/RenderJob/TriStepSetVisualizationMode.h @@ -11,26 +11,28 @@ BLUE_DECLARE_INTERFACE( ITr2VisualizationModeRenderer ); // ------------------------------------------------------------- // Description: -// TriStepSetVisualizationMode is a render step that +// TriStepSetVisualizationMode is a render step that // sets scene's debug visualization mode. // SeeAlso: // TriRenderStep // ------------------------------------------------------------- -BLUE_CLASS( TriStepSetVisualizationMode ) : public TriRenderStep +BLUE_CLASS( TriStepSetVisualizationMode ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepSetVisualizationMode( IRoot* lockobj = 0 ); - ~TriStepSetVisualizationMode(void); + ~TriStepSetVisualizationMode( void ); - void py__init__( ITr2VisualizationModeRenderer* object, int mode ); + void py__init__( ITr2VisualizationModeRenderer * object, int mode ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); - void SetObject( ITr2VisualizationModeRenderer* object ); + void SetObject( ITr2VisualizationModeRenderer * object ); void SetVisualizationMode( int mode ); + private: ITr2VisualizationModeRendererPtr m_object; int m_mode; diff --git a/trinity/RenderJob/TriStepSetVisualizationMode_Blue.cpp b/trinity/RenderJob/TriStepSetVisualizationMode_Blue.cpp index f66e69afe..c72133fb4 100644 --- a/trinity/RenderJob/TriStepSetVisualizationMode_Blue.cpp +++ b/trinity/RenderJob/TriStepSetVisualizationMode_Blue.cpp @@ -8,18 +8,17 @@ BLUE_DEFINE( TriStepSetVisualizationMode ); const Be::ClassInfo* TriStepSetVisualizationMode::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepSetVisualizationMode, "" ) + EXPOSURE_BEGIN( TriStepSetVisualizationMode, "" ) MAP_INTERFACE( TriStepSetVisualizationMode ) - MAP_ATTRIBUTE( "object", m_object, "The object to set visualization mode for", Be::READWRITE) - MAP_ATTRIBUTE( "mode", m_mode, "Visualization mode for the object", Be::READWRITE) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - py__init__, - 2, + MAP_ATTRIBUTE( "object", m_object, "The object to set visualization mode for", Be::READWRITE ) + MAP_ATTRIBUTE( "mode", m_mode, "Visualization mode for the object", Be::READWRITE ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, + 2, ":param obj: The object to set visualization mode for\n" - ":param mode: Visualization mode for the object" - ) + ":param mode: Visualization mode for the object" ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepTestBlocking.cpp b/trinity/RenderJob/TriStepTestBlocking.cpp index 712453b41..3aacedeea 100644 --- a/trinity/RenderJob/TriStepTestBlocking.cpp +++ b/trinity/RenderJob/TriStepTestBlocking.cpp @@ -6,10 +6,9 @@ TriStepTestBlocking::TriStepTestBlocking( IRoot* lockobj ) : m_inProgress( true ) { - } -TriStepTestBlocking::~TriStepTestBlocking(void) +TriStepTestBlocking::~TriStepTestBlocking( void ) { } diff --git a/trinity/RenderJob/TriStepTestBlocking.h b/trinity/RenderJob/TriStepTestBlocking.h index 65fa48b5d..2b45c067d 100644 --- a/trinity/RenderJob/TriStepTestBlocking.h +++ b/trinity/RenderJob/TriStepTestBlocking.h @@ -8,16 +8,17 @@ #include "TriRenderStep.h" #include "include/TriColor.h" -BLUE_CLASS( TriStepTestBlocking ) : public TriRenderStep +BLUE_CLASS( TriStepTestBlocking ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepTestBlocking( IRoot* lockobj = 0 ); - ~TriStepTestBlocking(void); + ~TriStepTestBlocking( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); private: bool m_inProgress; diff --git a/trinity/RenderJob/TriStepTestBlocking_Blue.cpp b/trinity/RenderJob/TriStepTestBlocking_Blue.cpp index 2453924e8..94c3ac3da 100644 --- a/trinity/RenderJob/TriStepTestBlocking_Blue.cpp +++ b/trinity/RenderJob/TriStepTestBlocking_Blue.cpp @@ -11,13 +11,11 @@ const Be::ClassInfo* TriStepTestBlocking::ExposeToBlue() EXPOSURE_BEGIN( TriStepTestBlocking, "" ) MAP_INTERFACE( TriStepTestBlocking ) - MAP_ATTRIBUTE - ( - "inProgress", - m_inProgress, - "This render step will return in progress while this is set", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "inProgress", + m_inProgress, + "This render step will return in progress while this is set", + Be::READWRITE | Be::PERSIST ) EXPOSURE_CHAINTO( TriRenderStep ) } \ No newline at end of file diff --git a/trinity/RenderJob/TriStepToggleCubemap.cpp b/trinity/RenderJob/TriStepToggleCubemap.cpp index 43c65761d..897de1f28 100644 --- a/trinity/RenderJob/TriStepToggleCubemap.cpp +++ b/trinity/RenderJob/TriStepToggleCubemap.cpp @@ -6,18 +6,18 @@ #include "ITr2VisualizationModeRenderer.h" #include "Interior/Tr2InteriorScene.h" -TriStepToggleCubemap::TriStepToggleCubemap( IRoot* lockobj ) -: m_showCubemap( true ), m_scene( NULL ) +TriStepToggleCubemap::TriStepToggleCubemap( IRoot* lockobj ) : + m_showCubemap( true ), m_scene( NULL ) { } -TriStepToggleCubemap::~TriStepToggleCubemap(void) +TriStepToggleCubemap::~TriStepToggleCubemap( void ) { } // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void TriStepToggleCubemap::py__init__( Be::OptionalWithDefaultValue showCubemap, Tr2InteriorScene* scene ) { @@ -37,10 +37,9 @@ void TriStepToggleCubemap::py__init__( Be::OptionalWithDefaultValue TriStepResult TriStepToggleCubemap::Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ) { if( this->m_scene ) - { + { this->m_scene->SetRenderBackgroundCubeMap( m_showCubemap ); } - + return RS_OK; } - diff --git a/trinity/RenderJob/TriStepToggleCubemap.h b/trinity/RenderJob/TriStepToggleCubemap.h index a5766cf07..87947759c 100644 --- a/trinity/RenderJob/TriStepToggleCubemap.h +++ b/trinity/RenderJob/TriStepToggleCubemap.h @@ -13,26 +13,27 @@ BLUE_DECLARE_INTERFACE( ITr2VisualizationModeRenderer ); // ------------------------------------------------------------- // Description: -// TriStepToggleCubemap is a render step that +// TriStepToggleCubemap is a render step that // either toggles the background cubemap on or off // SeeAlso: // TriRenderStep // ------------------------------------------------------------- -BLUE_CLASS( TriStepToggleCubemap ) : public TriRenderStep +BLUE_CLASS( TriStepToggleCubemap ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); TriStepToggleCubemap( IRoot* lockobj = 0 ); - ~TriStepToggleCubemap(void); + ~TriStepToggleCubemap( void ); - void py__init__( Be::OptionalWithDefaultValue showCubemap, Tr2InteriorScene* scene ); + void py__init__( Be::OptionalWithDefaultValue showCubemap, Tr2InteriorScene * scene ); - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); private: bool m_showCubemap; - Tr2InteriorScene *m_scene; + Tr2InteriorScene* m_scene; }; TYPEDEF_BLUECLASS( TriStepToggleCubemap ); diff --git a/trinity/RenderJob/TriStepToggleCubemap_Blue.cpp b/trinity/RenderJob/TriStepToggleCubemap_Blue.cpp index 397313c0b..cbf98a049 100644 --- a/trinity/RenderJob/TriStepToggleCubemap_Blue.cpp +++ b/trinity/RenderJob/TriStepToggleCubemap_Blue.cpp @@ -10,23 +10,21 @@ BLUE_DEFINE( TriStepToggleCubemap ); const Be::ClassInfo* TriStepToggleCubemap::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepToggleCubemap, "" ) + EXPOSURE_BEGIN( TriStepToggleCubemap, "" ) MAP_INTERFACE( TriStepToggleCubemap ) - MAP_ATTRIBUTE( - "m_showCubemap", - m_showCubemap, - "Toggle the cubemap for the scene", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "m_showCubemap", + m_showCubemap, + "Toggle the cubemap for the scene", + Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - py__init__, - 2, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, + 2, ":param show: show/hide cubemap\n" - ":param scene: cubemap scene" - ) + ":param scene: cubemap scene" ) EXPOSURE_CHAINTO( TriRenderStep ) } diff --git a/trinity/RenderJob/TriStepUpdate.cpp b/trinity/RenderJob/TriStepUpdate.cpp index afb736f0e..0e371195e 100644 --- a/trinity/RenderJob/TriStepUpdate.cpp +++ b/trinity/RenderJob/TriStepUpdate.cpp @@ -7,7 +7,7 @@ TriStepUpdate::TriStepUpdate( IRoot* lockobj ) { } -TriStepUpdate::~TriStepUpdate(void) +TriStepUpdate::~TriStepUpdate( void ) { } diff --git a/trinity/RenderJob/TriStepUpdate.h b/trinity/RenderJob/TriStepUpdate.h index b0cf5d0d9..24c6a378e 100644 --- a/trinity/RenderJob/TriStepUpdate.h +++ b/trinity/RenderJob/TriStepUpdate.h @@ -9,19 +9,20 @@ #include "include/ITr2Scene.h" -BLUE_CLASS( TriStepUpdate ) : public TriRenderStep +BLUE_CLASS( TriStepUpdate ) : + public TriRenderStep { public: EXPOSE_TO_BLUE(); - + TriStepUpdate( IRoot* lockobj = 0 ); - ~TriStepUpdate(void); + ~TriStepUpdate( void ); //RenderStep - TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext& renderContext ); + TriStepResult Execute( Be::Time realTime, Be::Time simTime, Tr2RenderContext & renderContext ); // Python __init__ constructor - void SetUpdateable( ITr2Updateable* obj ); + void SetUpdateable( ITr2Updateable * obj ); private: ITr2UpdateablePtr m_object; diff --git a/trinity/RenderJob/TriStepUpdate_Blue.cpp b/trinity/RenderJob/TriStepUpdate_Blue.cpp index 52f121f43..2511a0729 100644 --- a/trinity/RenderJob/TriStepUpdate_Blue.cpp +++ b/trinity/RenderJob/TriStepUpdate_Blue.cpp @@ -7,14 +7,14 @@ BLUE_DEFINE( TriStepUpdate ); const Be::ClassInfo* TriStepUpdate::ExposeToBlue() { - EXPOSURE_BEGIN(TriStepUpdate, "" ) + EXPOSURE_BEGIN( TriStepUpdate, "" ) MAP_INTERFACE( TriStepUpdate ) - MAP_ATTRIBUTE( "object", m_object, "The object to be updated", Be::READWRITE) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - SetUpdateable, - 1, + MAP_ATTRIBUTE( "object", m_object, "The object to be updated", Be::READWRITE ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + SetUpdateable, + 1, ":param obj: The object to be updated" ) EXPOSURE_CHAINTO( TriRenderStep ) diff --git a/trinity/Resources/Procedural/Base64Encoding.cpp b/trinity/Resources/Procedural/Base64Encoding.cpp index 16015f8e9..380ee2a7e 100644 --- a/trinity/Resources/Procedural/Base64Encoding.cpp +++ b/trinity/Resources/Procedural/Base64Encoding.cpp @@ -46,7 +46,7 @@ std::vector Decode( const std::string_view& str ) return {}; } q++; - if ( q == 4 ) + if( q == 4 ) { q = 0; result.push_back( ( ( quad[0] << 2 ) | ( quad[1] >> 4 ) ) & 0xFF ); @@ -54,7 +54,7 @@ std::vector Decode( const std::string_view& str ) result.push_back( ( ( quad[2] & 0x03 ) << 6 ) | quad[3] ); } } - if ( q > 0 ) + if( q > 0 ) { for( size_t i = q; i < 4; i++ ) { diff --git a/trinity/Resources/Procedural/GradientTexture.cpp b/trinity/Resources/Procedural/GradientTexture.cpp index 34601e02b..213f2581e 100644 --- a/trinity/Resources/Procedural/GradientTexture.cpp +++ b/trinity/Resources/Procedural/GradientTexture.cpp @@ -195,9 +195,9 @@ bool IsGradientTexturePath( const wchar_t* path ) } -MAP_FUNCTION_AND_WRAP( - "GradientPathToCurve", - GradientPathToCurve, +MAP_FUNCTION_AND_WRAP( + "GradientPathToCurve", + GradientPathToCurve, "Constructs a Tr2CurveColor object with curves set up to represent the given dynamic:/gradient_1d/... res path.\n" "Returns either a tuple with Tr2CurveColor object and texture width or (None, 0) if the path is malformed.\n\n" ":param path: dynamic:/gradient_1d/... res path\n" ); diff --git a/trinity/Resources/TexturePipeline/ITr2TexturePipelineStep.h b/trinity/Resources/TexturePipeline/ITr2TexturePipelineStep.h index 516efe302..60e9478bf 100644 --- a/trinity/Resources/TexturePipeline/ITr2TexturePipelineStep.h +++ b/trinity/Resources/TexturePipeline/ITr2TexturePipelineStep.h @@ -7,17 +7,18 @@ struct Tr2TexturePipelineParams uint32_t maxWidth; uint32_t maxHeight; - Tr2TexturePipelineParams( uint32_t _maxWidth = 0, uint32_t _maxHeight = 0 ) - :maxWidth( _maxWidth ), + Tr2TexturePipelineParams( uint32_t _maxWidth = 0, uint32_t _maxHeight = 0 ) : + maxWidth( _maxWidth ), maxHeight( _maxHeight ) { } }; -BLUE_INTERFACE( ITr2TexturePipelineStep ): public IRoot +BLUE_INTERFACE( ITr2TexturePipelineStep ) : + public IRoot { - virtual void GetResourceDependencies( std::set& resources ) const {}; - virtual bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const = 0; + virtual void GetResourceDependencies( std::set & resources ) const {}; + virtual bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const = 0; }; BLUE_DECLARE_IVECTOR( ITr2TexturePipelineStep ); diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp index 88570361c..7b3a37a77 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp @@ -6,8 +6,8 @@ #include "Tr2HostBitmap.h" -Tr2TexturePipeline::Tr2TexturePipeline( IRoot* lockobj ) - :PARENTLOCK( m_steps ), +Tr2TexturePipeline::Tr2TexturePipeline( IRoot* lockobj ) : + PARENTLOCK( m_steps ), m_inputs( "Tr2TexturePipeline::m_inputs" ) { } diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipeline.h b/trinity/Resources/TexturePipeline/Tr2TexturePipeline.h index 2fe3821b8..85bd5dc9a 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipeline.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipeline.h @@ -7,15 +7,17 @@ BLUE_DECLARE( Tr2HostBitmap ); BLUE_DECLARE( TriTextureRes ); -BLUE_CLASS( Tr2TexturePipeline ): public IRoot +BLUE_CLASS( Tr2TexturePipeline ) : + public IRoot { public: Tr2TexturePipeline( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - void GetResourceDependencies( std::set& resources ) const; - bool Execute( ImageIO::HostBitmap& result, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + void GetResourceDependencies( std::set & resources ) const; + bool Execute( ImageIO::HostBitmap & result, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + private: std::vector GetResourceDependenciesFromScript() const; Be::Result ExecuteFromScript( uint32_t maxWidth, uint32_t maxHeight, Tr2HostBitmapPtr& result ) const; diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp index cc8821eaf..33998f2ad 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp @@ -4,8 +4,8 @@ #include "Tr2TexturePipelineStepCompress.h" #include "Tr2HostBitmap.h" -Tr2TexturePipelineStepCompress::Tr2TexturePipelineStepCompress( IRoot* ) - :m_format( Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM ), +Tr2TexturePipelineStepCompress::Tr2TexturePipelineStepCompress( IRoot* ) : + m_format( Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM ), m_rWeight( 1 ), m_gWeight( 1 ), m_bWeight( 1 ) diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.h b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.h index 19b06c50c..3ca1b3fb0 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.h @@ -4,14 +4,16 @@ #include "ITr2TexturePipelineStep.h" -BLUE_CLASS( Tr2TexturePipelineStepCompress ): public ITr2TexturePipelineStep +BLUE_CLASS( Tr2TexturePipelineStepCompress ) : + public ITr2TexturePipelineStep { public: Tr2TexturePipelineStepCompress( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + private: Tr2RenderContextEnum::PixelFormat m_format; float m_rWeight; diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepGenerateMips.h b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepGenerateMips.h index 87e45a2cc..6782491b1 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepGenerateMips.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepGenerateMips.h @@ -4,12 +4,13 @@ #include "ITr2TexturePipelineStep.h" -BLUE_CLASS( Tr2TexturePipelineStepGenerateMips ): public ITr2TexturePipelineStep +BLUE_CLASS( Tr2TexturePipelineStepGenerateMips ) : + public ITr2TexturePipelineStep { public: EXPOSE_TO_BLUE(); - bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; }; TYPEDEF_BLUECLASS( Tr2TexturePipelineStepGenerateMips ); \ No newline at end of file diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp index 70bfa46fc..3c9d3a30f 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp @@ -3,8 +3,8 @@ #include "StdAfx.h" #include "Tr2TexturePipelineStepLimitSize.h" -Tr2TexturePipelineStepLimitSize::Tr2TexturePipelineStepLimitSize( IRoot* ) - :m_maxWidth( 0 ), +Tr2TexturePipelineStepLimitSize::Tr2TexturePipelineStepLimitSize( IRoot* ) : + m_maxWidth( 0 ), m_maxHeight( 0 ) { } diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.h b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.h index e654d7a7d..8346216ad 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.h @@ -4,16 +4,18 @@ #include "ITr2TexturePipelineStep.h" -BLUE_CLASS( Tr2TexturePipelineStepLimitSize ) : public ITr2TexturePipelineStep +BLUE_CLASS( Tr2TexturePipelineStepLimitSize ) : + public ITr2TexturePipelineStep { public: Tr2TexturePipelineStepLimitSize( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + + static bool LimitSize( ImageIO::HostBitmap & bitmap, uint32_t maxWidth, uint32_t maxHeight ); - static bool LimitSize( ImageIO::HostBitmap& bitmap, uint32_t maxWidth, uint32_t maxHeight ); private: uint32_t m_maxWidth; uint32_t m_maxHeight; diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.h b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.h index 15748bb36..f15141dbb 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.h @@ -4,13 +4,15 @@ #include "ITr2TexturePipelineStep.h" -BLUE_CLASS( Tr2TexturePipelineStepLoad ): public ITr2TexturePipelineStep +BLUE_CLASS( Tr2TexturePipelineStepLoad ) : + public ITr2TexturePipelineStep { public: EXPOSE_TO_BLUE(); - virtual void GetResourceDependencies( std::set& resources ) const; - virtual bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + virtual void GetResourceDependencies( std::set & resources ) const; + virtual bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + private: std::wstring m_path; }; diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp index f7f8473ec..6c5d6fd0e 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp @@ -7,37 +7,34 @@ using namespace Tr2RenderContextEnum; namespace { - uint32_t SwapRedBlue( uint8_t channel ) +uint32_t SwapRedBlue( uint8_t channel ) +{ + switch( channel ) { - switch( channel ) - { - case 0: - return 2; - case 2: - return 0; - default: - return channel; - } + case 0: + return 2; + case 2: + return 0; + default: + return channel; } } +} -Tr2TexturePackChannel::Tr2TexturePackChannel( IRoot* ) - :m_channel( 0 ), +Tr2TexturePackChannel::Tr2TexturePackChannel( IRoot* ) : + m_channel( 0 ), m_fill( 0 ) { - } -Tr2TexturePipelineStepPack::Tr2TexturePipelineStepPack( IRoot* lockobj ): +Tr2TexturePipelineStepPack::Tr2TexturePipelineStepPack( IRoot* lockobj ) : m_format( PIXEL_FORMAT_B8G8R8A8_UNORM ), PARENTLOCK( m_r ), PARENTLOCK( m_g ), PARENTLOCK( m_b ), PARENTLOCK( m_a ) { - - } void Tr2TexturePipelineStepPack::GetResourceDependencies( std::set& resources ) const diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.h b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.h index ec662d3c5..ca9853e5c 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.h +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.h @@ -6,12 +6,14 @@ BLUE_DECLARE( Tr2TexturePipelineStepPack ); -BLUE_CLASS( Tr2TexturePackChannel ): public IRoot +BLUE_CLASS( Tr2TexturePackChannel ) : + public IRoot { public: Tr2TexturePackChannel( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); + private: std::wstring m_path; uint8_t m_channel; @@ -23,15 +25,17 @@ BLUE_CLASS( Tr2TexturePackChannel ): public IRoot TYPEDEF_BLUECLASS( Tr2TexturePackChannel ); -BLUE_CLASS( Tr2TexturePipelineStepPack ): public ITr2TexturePipelineStep +BLUE_CLASS( Tr2TexturePipelineStepPack ) : + public ITr2TexturePipelineStep { public: Tr2TexturePipelineStepPack( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - virtual void GetResourceDependencies( std::set& resources ) const; - virtual bool Execute( ImageIO::HostBitmap& bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + virtual void GetResourceDependencies( std::set & resources ) const; + virtual bool Execute( ImageIO::HostBitmap & bitmap, const std::unordered_map& inputs, const Tr2TexturePipelineParams& params ) const; + private: struct BitmapSource { @@ -40,7 +44,7 @@ BLUE_CLASS( Tr2TexturePipelineStepPack ): public ITr2TexturePipelineStep uint32_t rowStride; }; - static void Pack( ImageIO::HostBitmap& bitmap, BitmapSource* channels, uint32_t channelCount, uint32_t mip ); + static void Pack( ImageIO::HostBitmap & bitmap, BitmapSource * channels, uint32_t channelCount, uint32_t mip ); Tr2RenderContextEnum::PixelFormat m_format; PTr2TexturePackChannel m_r; diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack_Blue.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack_Blue.cpp index 57103a85f..3997de84f 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack_Blue.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack_Blue.cpp @@ -6,45 +6,35 @@ namespace { - Be::VarChooser ChannelChooser[] = - { - { - "RED", - BeCast( 2 ), - "" - }, - { - "GREEN", - BeCast( 1 ), - "" - }, - { - "BLUE", - BeCast( 0 ), - "" - }, - { - "ALPHA", - BeCast( 3 ), - "" - }, - { 0 } - }; +Be::VarChooser ChannelChooser[] = { + { "RED", + BeCast( 2 ), + "" }, + { "GREEN", + BeCast( 1 ), + "" }, + { "BLUE", + BeCast( 0 ), + "" }, + { "ALPHA", + BeCast( 3 ), + "" }, + { 0 } +}; } BLUE_DEFINE( Tr2TexturePackChannel ); -const Be::ClassInfo* Tr2TexturePackChannel::ExposeToBlue() -{ +const Be::ClassInfo* Tr2TexturePackChannel::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2TexturePackChannel, "" ) MAP_INTERFACE( Tr2TexturePackChannel ) - MAP_ATTRIBUTE( "path", m_path, "Res path to the input texture", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "channel", m_channel, "Channel to take from the input texture", Be::READWRITE | Be::PERSIST | Be::ENUM, ChannelChooser ) - MAP_ATTRIBUTE( "fill", m_fill, "Constant color fill when no input texture is provided", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "path", m_path, "Res path to the input texture", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "channel", m_channel, "Channel to take from the input texture", Be::READWRITE | Be::PERSIST | Be::ENUM, ChannelChooser ) + MAP_ATTRIBUTE( "fill", m_fill, "Constant color fill when no input texture is provided", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } BLUE_DEFINE( Tr2TexturePipelineStepPack ); diff --git a/trinity/Resources/TexturePipeline/Tr2TexturePipeline_Blue.cpp b/trinity/Resources/TexturePipeline/Tr2TexturePipeline_Blue.cpp index fb888f0c9..69b6edd61 100644 --- a/trinity/Resources/TexturePipeline/Tr2TexturePipeline_Blue.cpp +++ b/trinity/Resources/TexturePipeline/Tr2TexturePipeline_Blue.cpp @@ -27,8 +27,7 @@ const Be::ClassInfo* Tr2TexturePipeline::ExposeToBlue() 2, "Executes the pipeline and returns the resulting bitmap.\n" ":param maxWidth: Max resulting texture width\n" - ":param maxHeight: Max resulting texture width\n" - ) + ":param maxHeight: Max resulting texture width\n" ) EXPOSURE_END() } diff --git a/trinity/Resources/Tr2AsyncSave.cpp b/trinity/Resources/Tr2AsyncSave.cpp index 1027c52ad..107dfaf3f 100644 --- a/trinity/Resources/Tr2AsyncSave.cpp +++ b/trinity/Resources/Tr2AsyncSave.cpp @@ -6,18 +6,14 @@ using namespace Tr2RenderContextEnum; -Tr2AsyncSave::Tr2AsyncSave() - : m_isSaving( false ) - , m_isSavePrepared( false ) - , m_saveSucceeded( false ) - , m_saveCbId( 0 ) - , m_prepareSaveCbId( 0 ) -{ +Tr2AsyncSave::Tr2AsyncSave() : + m_isSaving( false ), m_isSavePrepared( false ), m_saveSucceeded( false ), m_saveCbId( 0 ), m_prepareSaveCbId( 0 ) +{ } Tr2AsyncSave::~Tr2AsyncSave() { - CleanupAsyncSave( false, true ); + CleanupAsyncSave( false, true ); } void Tr2AsyncSave::WaitForSave( void ) const @@ -39,7 +35,7 @@ bool Tr2AsyncSave::StartAsyncSave( const wchar_t* filename ) } m_saveFilename = filename; - + m_isSaving = TRUE; m_saveSucceeded = FALSE; m_isSavePrepared = FALSE; @@ -51,14 +47,14 @@ bool Tr2AsyncSave::StartAsyncSave( const wchar_t* filename ) void Tr2AsyncSave::StaticPrepare( void* pContext ) { - Tr2AsyncSave* pThis = static_cast(pContext); + Tr2AsyncSave* pThis = static_cast( pContext ); pThis->PrepareSave(); } void Tr2AsyncSave::PrepareSave() { // Clear out the prepare task ID, even if this fails, so we can try again in the future. - ON_BLOCK_EXIT( [&]{ m_prepareSaveCbId = 0; } ); + ON_BLOCK_EXIT( [&] { m_prepareSaveCbId = 0; } ); if( !DoPrepareAsyncSave() ) { @@ -75,13 +71,13 @@ void Tr2AsyncSave::PrepareSave() void Tr2AsyncSave::StaticSave( void* pContext ) { - Tr2AsyncSave* pThis = static_cast(pContext); + Tr2AsyncSave* pThis = static_cast( pContext ); pThis->DoSave(); } void Tr2AsyncSave::DoSave() { - const bool OK = DoExecuteAsyncSave(); + const bool OK = DoExecuteAsyncSave(); m_saveCbId = 0; CleanupAsyncSave( !OK ); } @@ -104,7 +100,7 @@ void Tr2AsyncSave::CleanupAsyncSave( bool failed, bool fromDestructor ) BeResMan->CancelFromQueue( BRMQ_MAIN, prepareSaveCbId ); m_prepareSaveCbId = 0; } - + if( saveInProgress ) { CCP_LOGERR( "Save canceled for '%S'", m_saveFilename.c_str() ); diff --git a/trinity/Resources/Tr2AsyncSave.h b/trinity/Resources/Tr2AsyncSave.h index 3407a37b0..86f483b81 100644 --- a/trinity/Resources/Tr2AsyncSave.h +++ b/trinity/Resources/Tr2AsyncSave.h @@ -7,12 +7,21 @@ class Tr2AsyncSave { public: - Tr2AsyncSave(); + Tr2AsyncSave(); - bool IsSaving() const { return m_isSavePrepared || m_saveCbId || m_prepareSaveCbId; } - bool IsSaveCompleted() const { return !m_isSaving; } - bool IsSaveSucceeded() const { return m_saveSucceeded != 0; } - void WaitForSave() const; + bool IsSaving() const + { + return m_isSavePrepared || m_saveCbId || m_prepareSaveCbId; + } + bool IsSaveCompleted() const + { + return !m_isSaving; + } + bool IsSaveSucceeded() const + { + return m_saveSucceeded != 0; + } + void WaitForSave() const; protected: // Main entry point for classes that inherit from Tr2AsyncSave: call this to start the whole @@ -22,7 +31,7 @@ class Tr2AsyncSave void CleanupAsyncSave( bool failed, bool fromDestructor = false ); std::wstring m_saveFilename; - + private: // Do preparation work on the main thread virtual bool DoPrepareAsyncSave() = 0; @@ -43,9 +52,9 @@ class Tr2AsyncSave CcpAtomic m_isSaving; CcpAtomic m_isSavePrepared; CcpAtomic m_saveSucceeded; - - CcpAtomic m_saveCbId; /// When set, save has been scheduled on the background thread - CcpAtomic m_prepareSaveCbId; /// When set, D3D texture lock/unlock has been scheduled on the main thread + + CcpAtomic m_saveCbId; /// When set, save has been scheduled on the background thread + CcpAtomic m_prepareSaveCbId; /// When set, D3D texture lock/unlock has been scheduled on the main thread protected: ~Tr2AsyncSave(); diff --git a/trinity/Resources/Tr2EffectRes.cpp b/trinity/Resources/Tr2EffectRes.cpp index 809f412ee..d4b6db6a8 100644 --- a/trinity/Resources/Tr2EffectRes.cpp +++ b/trinity/Resources/Tr2EffectRes.cpp @@ -41,7 +41,7 @@ Tr2EffectRes::Tr2EffectRes( IRoot* lockobj ) : m_offsets( nullptr ), m_permutations( "Tr2EffectRes::m_permutations" ), m_shaders( "Tr2EffectRes::m_shaders" ) -{ +{ } Tr2EffectRes::~Tr2EffectRes() @@ -175,33 +175,33 @@ BlueAsyncRes::LoadingResult Tr2EffectRes::DoLoad() const uint8_t* buffer = reinterpret_cast( m_data.get() ); const uint8_t* bufferEnd = buffer + dataSize; -#define SKIP( storeType ) \ - if( buffer + sizeof( storeType ) > bufferEnd ) \ - { \ - CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \ - return LR_FAILED; \ - } \ +#define SKIP( storeType ) \ + if( buffer + sizeof( storeType ) > bufferEnd ) \ + { \ + CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \ + return LR_FAILED; \ + } \ buffer += sizeof( storeType ); -#define READ( storeType, valueType, value ) \ - if( buffer + sizeof( storeType ) > bufferEnd ) \ - { \ - CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \ - return LR_FAILED; \ - } \ - value = valueType( *reinterpret_cast( buffer ) ); \ +#define READ( storeType, valueType, value ) \ + if( buffer + sizeof( storeType ) > bufferEnd ) \ + { \ + CCP_LOGERR( "Unexpected end of file while reading effect \"%S\"", GetPath() ); \ + return LR_FAILED; \ + } \ + value = valueType( *reinterpret_cast( buffer ) ); \ buffer += sizeof( storeType ); -#define READ_STRING( value ) \ - { \ - uint32_t offset; \ - READ( uint32_t, uint32_t, offset ); \ - if( offset >= m_stringTableSize ) \ - { \ - CCP_LOGERR( "Invalid string offset in effect \"%S\"", GetPath() ); \ - return LR_FAILED; \ - } \ - value = m_stringTable + offset; \ +#define READ_STRING( value ) \ + { \ + uint32_t offset; \ + READ( uint32_t, uint32_t, offset ); \ + if( offset >= m_stringTableSize ) \ + { \ + CCP_LOGERR( "Invalid string offset in effect \"%S\"", GetPath() ); \ + return LR_FAILED; \ + } \ + value = m_stringTable + offset; \ } READ( uint32_t, uint32_t, m_version ); @@ -282,7 +282,7 @@ BlueAsyncRes::LoadingResult Tr2EffectRes::DoLoad() uint32_t count; READ( uint8_t, uint32_t, count ); - for( uint32_t j = 0; j < count;++ j ) + for( uint32_t j = 0; j < count; ++j ) { std::string name; READ_STRING( name ); @@ -327,7 +327,7 @@ bool Tr2EffectRes::DoPrepare() void Tr2EffectRes::ReleaseResources( TriStorage s ) { - if( (s & TRISTORAGE_ALL) == TRISTORAGE_ALL ) + if( ( s & TRISTORAGE_ALL ) == TRISTORAGE_ALL ) { SetGood( false ); SetPrepared( false ); @@ -347,7 +347,7 @@ bool Tr2EffectRes::OnPrepareResources() } USE_MAIN_THREAD_RENDER_CONTEXT(); - if ( !renderContext.IsValid() ) + if( !renderContext.IsValid() ) { // It's possible to get a PrepareResources when there's no valid render context return false; diff --git a/trinity/Resources/Tr2EffectRes.h b/trinity/Resources/Tr2EffectRes.h index 0c373247b..665ef8b31 100644 --- a/trinity/Resources/Tr2EffectRes.h +++ b/trinity/Resources/Tr2EffectRes.h @@ -24,7 +24,7 @@ struct Tr2ShaderPermutation uint8_t type; }; -BLUE_CLASS( Tr2EffectRes ): +BLUE_CLASS( Tr2EffectRes ) : public BlueAsyncRes, public ICacheable, public Tr2DeviceResource @@ -47,7 +47,7 @@ BLUE_CLASS( Tr2EffectRes ): // ITriDeviceResource void ReleaseResources( TriStorage s ); #if TRINITYDEV - virtual void GetDescription( std::string& desc ); + virtual void GetDescription( std::string & desc ); #endif private: bool OnPrepareResources(); @@ -66,7 +66,7 @@ BLUE_CLASS( Tr2EffectRes ): struct FileRecord { uint32_t index; - // Compiled code offset into the file + // Compiled code offset into the file uint32_t offset; // Compiled code size uint32_t size; diff --git a/trinity/Resources/Tr2EffectRes_Blue.cpp b/trinity/Resources/Tr2EffectRes_Blue.cpp index 66efa0b3d..5ce69ba5e 100644 --- a/trinity/Resources/Tr2EffectRes_Blue.cpp +++ b/trinity/Resources/Tr2EffectRes_Blue.cpp @@ -81,8 +81,7 @@ const Be::ClassInfo* Tr2EffectRes::ExposeToBlue() "GetPermutationDescription", GetPermutationDescription, "Returns a description of effect permutations as a tuple of dictionaries.\n" - "Each dictionary contains a tuple \"options\" of permutation options, \"default\" value index and \"description\"." - ) + "Each dictionary contains a tuple \"options\" of permutation options, \"default\" value index and \"description\"." ) #endif EXPOSURE_CHAINTO( BlueAsyncRes ) diff --git a/trinity/Resources/Tr2GrannyStateRes.cpp b/trinity/Resources/Tr2GrannyStateRes.cpp index b026cc255..5606f7229 100644 --- a/trinity/Resources/Tr2GrannyStateRes.cpp +++ b/trinity/Resources/Tr2GrannyStateRes.cpp @@ -8,7 +8,7 @@ #include "Utilities/GeometryUtils.h" -Tr2GrannyStateRes::Tr2GrannyStateRes( IRoot* lockobj ): +Tr2GrannyStateRes::Tr2GrannyStateRes( IRoot* lockobj ) : m_characterFile( nullptr ), m_data( nullptr ), m_dataSize( 0 ), @@ -22,9 +22,9 @@ Tr2GrannyStateRes::Tr2GrannyStateRes( IRoot* lockobj ): Tr2GrannyStateRes::~Tr2GrannyStateRes() { Cleanup(); - if (m_characterFile) + if( m_characterFile ) { - GrannyFreeFile(m_characterFile); + GrannyFreeFile( m_characterFile ); m_characterFile = NULL; } } @@ -36,9 +36,9 @@ bool Tr2GrannyStateRes::IsMemoryUsageKnown() size_t Tr2GrannyStateRes::GetMemoryUsage() { - if (m_characterFile) + if( m_characterFile ) { - return m_dataSize + sizeof(m_characterFile); + return m_dataSize + sizeof( m_characterFile ); } else { @@ -49,9 +49,9 @@ size_t Tr2GrannyStateRes::GetMemoryUsage() BlueAsyncRes::LoadingResult Tr2GrannyStateRes::DoLoad() { - CCP_STATS_ZONE(__FUNCTION__); + CCP_STATS_ZONE( __FUNCTION__ ); - if (!m_dataStream->LockData(&m_data, 0)) + if( !m_dataStream->LockData( &m_data, 0 ) ) { return LR_FAILED; } @@ -59,16 +59,16 @@ BlueAsyncRes::LoadingResult Tr2GrannyStateRes::DoLoad() m_dataSize = m_dataStream->GetSize(); { - if (m_characterFile) + if( m_characterFile ) { - GrannyFreeFile(m_characterFile); + GrannyFreeFile( m_characterFile ); m_characterFile = NULL; } CCP_STATS_ZONE( "Tr2GrannyStateRes::DoLoad reading Granny file" ); - m_characterFile = ProtectedGrannyReadEntireFileFromMemory(m_path.c_str(), (uint32_t)m_dataSize, m_data); + m_characterFile = ProtectedGrannyReadEntireFileFromMemory( m_path.c_str(), (uint32_t)m_dataSize, m_data ); } - if (!m_characterFile) + if( !m_characterFile ) { return LR_FAILED; } @@ -77,66 +77,66 @@ BlueAsyncRes::LoadingResult Tr2GrannyStateRes::DoLoad() } -std::string GetFullAnimPath(std::string SourceFilenameString, std::string dir_path) +std::string GetFullAnimPath( std::string SourceFilenameString, std::string dir_path ) { - auto last_delimiter_pos = dir_path.find_last_of("/\\"); - dir_path.erase(last_delimiter_pos, dir_path.length() - last_delimiter_pos); + auto last_delimiter_pos = dir_path.find_last_of( "/\\" ); + dir_path.erase( last_delimiter_pos, dir_path.length() - last_delimiter_pos ); - while (SourceFilenameString.substr(0, 2) == "..") + while( SourceFilenameString.substr( 0, 2 ) == ".." ) { - SourceFilenameString.erase(0, 3); - last_delimiter_pos = dir_path.find_last_of("/\\"); - dir_path.erase(last_delimiter_pos, dir_path.length() - last_delimiter_pos); + SourceFilenameString.erase( 0, 3 ); + last_delimiter_pos = dir_path.find_last_of( "/\\" ); + dir_path.erase( last_delimiter_pos, dir_path.length() - last_delimiter_pos ); } - if (SourceFilenameString.substr(0, 1) == ".") + if( SourceFilenameString.substr( 0, 1 ) == "." ) { - SourceFilenameString.erase(0, 2); + SourceFilenameString.erase( 0, 2 ); } dir_path += "/"; dir_path += SourceFilenameString; SourceFilenameString = dir_path; - std::replace(SourceFilenameString.begin(), SourceFilenameString.end(), '\\', '/'); + std::replace( SourceFilenameString.begin(), SourceFilenameString.end(), '\\', '/' ); return SourceFilenameString; } -granny_file_info* GStateAnimationBindingCallback(gstate_character_info *BindingInfo, - char const* SourceFilename, - void* UserData) +granny_file_info* GStateAnimationBindingCallback( gstate_character_info* BindingInfo, + char const* SourceFilename, + void* UserData ) { - auto callbackData = *(static_cast(UserData)); - std::map *gStateAnimFilesPtr = callbackData.anim_map_pointer; + auto callbackData = *( static_cast( UserData ) ); + std::map* gStateAnimFilesPtr = callbackData.anim_map_pointer; // Animation granny files are relative to the parent directory of the .gsf file std::string SourceFilenameString = SourceFilename; std::string dir_path = callbackData.gsf_path; - SourceFilenameString = GetFullAnimPath(SourceFilenameString, dir_path); + SourceFilenameString = GetFullAnimPath( SourceFilenameString, dir_path ); TriGrannyResPtr result_granny_res = nullptr; - for ( auto it = gStateAnimFilesPtr->begin(); it != gStateAnimFilesPtr->end(); it++ ) + for( auto it = gStateAnimFilesPtr->begin(); it != gStateAnimFilesPtr->end(); it++ ) { - + std::string iter_file_name = it->first; - std::replace(iter_file_name.begin(), iter_file_name.end(), '\\', '/'); + std::replace( iter_file_name.begin(), iter_file_name.end(), '\\', '/' ); - if ( iter_file_name == SourceFilenameString ) + if( iter_file_name == SourceFilenameString ) { result_granny_res = it->second; } } - if ( result_granny_res != nullptr ) + if( result_granny_res != nullptr ) { return result_granny_res->ValidateFileInfo(); } - CCP_LOGERR("GState Binding Step: '%s' is required by the GState file and is not loaded", SourceFilenameString.c_str()); + CCP_LOGERR( "GState Binding Step: '%s' is required by the GState file and is not loaded", SourceFilenameString.c_str() ); return nullptr; } @@ -147,12 +147,12 @@ bool Tr2GrannyStateRes::IsAllAnimGood() bool all_anim_good = true; auto anim_files = GetGStateAnimFileRefPaths(); - if ( anim_files.size() != m_gStateAnimFiles.size() ) + if( anim_files.size() != m_gStateAnimFiles.size() ) { return false; } - for ( auto it = m_gStateAnimFiles.begin() ; it != m_gStateAnimFiles.end(); it++ ) + for( auto it = m_gStateAnimFiles.begin(); it != m_gStateAnimFiles.end(); it++ ) { all_anim_good = all_anim_good && it->second->IsGood(); } @@ -174,9 +174,9 @@ bool Tr2GrannyStateRes::IsFullyLoaded() const gstate_character_info* Tr2GrannyStateRes::GetCharacterInfo() const { - if (m_characterFile) + if( m_characterFile ) { - return GStateGetCharacterInfo(m_characterFile); + return GStateGetCharacterInfo( m_characterFile ); } return NULL; } @@ -184,33 +184,32 @@ gstate_character_info* Tr2GrannyStateRes::GetCharacterInfo() const void Tr2GrannyStateRes::RebuildCachedData( BlueAsyncRes* p ) { - for ( auto it = m_gStateAnimFiles.begin(); it != m_gStateAnimFiles.end(); it++ ) + for( auto it = m_gStateAnimFiles.begin(); it != m_gStateAnimFiles.end(); it++ ) { - if ( p == it->second ) - { - if ( it->second && !it->second->GetGrannyFile() ) + if( p == it->second ) + { + if( it->second && !it->second->GetGrannyFile() ) { - CCP_LOGERR("'%s' not found or not a valid Granny file", it->first.c_str()); + CCP_LOGERR( "'%s' not found or not a valid Granny file", it->first.c_str() ); } continue; } } - if ( IsAllAnimGood() ) + if( IsAllAnimGood() ) { - m_callbackData.gsf_path = CW2A(m_path.c_str()); + m_callbackData.gsf_path = CW2A( m_path.c_str() ); m_callbackData.anim_map_pointer = &m_gStateAnimFiles; - gstate_character_info *character_info = GetCharacterInfo(); + gstate_character_info* character_info = GetCharacterInfo(); - if (!GStateBindCharacterFileReferences(character_info, static_cast(GStateAnimationBindingCallback), static_cast(&m_callbackData))) + if( !GStateBindCharacterFileReferences( character_info, static_cast( GStateAnimationBindingCallback ), static_cast( &m_callbackData ) ) ) { - CCP_LOGERR("'%ls' Granny State file refers to invalid or unavailable animation.", m_path.c_str()); + CCP_LOGERR( "'%ls' Granny State file refers to invalid or unavailable animation.", m_path.c_str() ); } m_anim_bound = true; } - } void Tr2GrannyStateRes::ReleaseCachedData( BlueAsyncRes* p ) @@ -222,11 +221,11 @@ void Tr2GrannyStateRes::ReleaseCachedData( BlueAsyncRes* p ) void Tr2GrannyStateRes::Cleanup() { m_anim_bound = false; - if ( !m_gStateAnimFiles.empty() ) + if( !m_gStateAnimFiles.empty() ) { - for ( auto it = m_gStateAnimFiles.begin(); it != m_gStateAnimFiles.end(); it++ ) + for( auto it = m_gStateAnimFiles.begin(); it != m_gStateAnimFiles.end(); it++ ) { - it->second->RemoveNotifyTarget(this); + it->second->RemoveNotifyTarget( this ); it->second.Unlock(); } } @@ -238,14 +237,15 @@ const std::vector Tr2GrannyStateRes::GetGStateAnimFileRefPaths() co { std::vector path_list; - gstate_character_info *character_info = GetCharacterInfo(); + gstate_character_info* character_info = GetCharacterInfo(); granny_int32x num_anim_sets = GStateGetNumAnimationSets( character_info ); - for ( int Idx = 0; Idx < num_anim_sets; Idx++ ) + for( int Idx = 0; Idx < num_anim_sets; Idx++ ) { granny_int32x num_source_files = GStateGetNumSourceFileReferencesFromSetIndex( character_info, Idx ); - for ( int ref_idx = 0; ref_idx < num_source_files; ref_idx++ ) { + for( int ref_idx = 0; ref_idx < num_source_files; ref_idx++ ) + { path_list.push_back( std::string( GStateGetSourceFileReferenceFromIndex( character_info, Idx, ref_idx ) ) ); } } @@ -259,31 +259,31 @@ void Tr2GrannyStateRes::LoadAnimResources() { m_anim_bound = false; auto file_list = GetGStateAnimFileRefPaths(); - for ( auto it = file_list.begin(); it != file_list.end(); ++it ) + for( auto it = file_list.begin(); it != file_list.end(); ++it ) { - std::string anim_res_path = GetFullAnimPath(*it, static_cast(CW2A( m_path.c_str() ))); - LoadAnimResPath(anim_res_path); + std::string anim_res_path = GetFullAnimPath( *it, static_cast( CW2A( m_path.c_str() ) ) ); + LoadAnimResPath( anim_res_path ); } } void Tr2GrannyStateRes::LoadAnimResPath( const std::string& val ) { - auto it = m_gStateAnimFiles.find(val); - if ( it != m_gStateAnimFiles.end() ) + auto it = m_gStateAnimFiles.find( val ); + if( it != m_gStateAnimFiles.end() ) { - it->second->RemoveNotifyTarget(this); + it->second->RemoveNotifyTarget( this ); it->second.Unlock(); } TriGrannyResPtr granny_res; BeResMan->GetResource( val.c_str(), "raw", BlueInterfaceIID(), (void**)&granny_res ); - m_gStateAnimFiles[ val ] = granny_res; + m_gStateAnimFiles[val] = granny_res; - if ( granny_res ) + if( granny_res ) { - granny_res->AddNotifyTarget(this); + granny_res->AddNotifyTarget( this ); } } diff --git a/trinity/Resources/Tr2GrannyStateRes.h b/trinity/Resources/Tr2GrannyStateRes.h index 61b5e1269..7bfee7033 100644 --- a/trinity/Resources/Tr2GrannyStateRes.h +++ b/trinity/Resources/Tr2GrannyStateRes.h @@ -17,7 +17,7 @@ BLUE_DECLARE( Tr2GrannyStateRes ); struct GStateBindingCallbackData { std::string gsf_path; - std::map *anim_map_pointer; + std::map* anim_map_pointer; GStateBindingCallbackData() : gsf_path( "" ), anim_map_pointer( nullptr ) @@ -25,16 +25,16 @@ struct GStateBindingCallbackData } }; -std::string GetFullAnimPath(std::string SourceFilenameString, std::string dir_path); +std::string GetFullAnimPath( std::string SourceFilenameString, std::string dir_path ); -BLUE_CLASS( Tr2GrannyStateRes ): +BLUE_CLASS( Tr2GrannyStateRes ) : public BlueAsyncRes, public ICacheable, public IBlueAsyncResNotifyTarget { public: EXPOSE_TO_BLUE(); - Tr2GrannyStateRes(IRoot* lockobj = NULL); + Tr2GrannyStateRes( IRoot* lockobj = NULL ); ~Tr2GrannyStateRes(); ////////////////////////////////////////////////////////////////////////// @@ -45,17 +45,20 @@ BLUE_CLASS( Tr2GrannyStateRes ): // ////////////////////////////////////////////////////////////////////////// - granny_file* GetCharacterFile() const { return m_characterFile; } - gstate_character_info *GetCharacterInfo() const; + granny_file* GetCharacterFile() const + { + return m_characterFile; + } + gstate_character_info* GetCharacterInfo() const; const std::vector GetGStateAnimFileRefPaths() const; bool IsFullyLoaded() const; ////////////////////////////////////////////////////////////////////////// // IAsyncLoadedResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); - void Cleanup(); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); + void Cleanup(); protected: virtual LoadingResult DoLoad(); @@ -67,8 +70,8 @@ BLUE_CLASS( Tr2GrannyStateRes ): void* m_data; bool m_anim_bound; GStateBindingCallbackData m_callbackData; - granny_file *m_characterFile; - std::map m_gStateAnimFiles; + granny_file* m_characterFile; + std::map m_gStateAnimFiles; void LoadAnimResPath( const std::string& val ); void LoadAnimResources(); bool IsAllAnimGood(); diff --git a/trinity/Resources/Tr2GrannyStateRes_Blue.cpp b/trinity/Resources/Tr2GrannyStateRes_Blue.cpp index 8fdb4b299..23ae4a096 100644 --- a/trinity/Resources/Tr2GrannyStateRes_Blue.cpp +++ b/trinity/Resources/Tr2GrannyStateRes_Blue.cpp @@ -8,26 +8,26 @@ BLUE_DEFINE( Tr2GrannyStateRes ); -IBlueResource* CreateTr2GrannyStateRes(const wchar_t* name) +IBlueResource* CreateTr2GrannyStateRes( const wchar_t* name ) { Tr2GrannyStateResPtr p; p.CreateInstance(); return p.Detach(); } -BLUE_REGISTER_RESOURCE_EXTENSION(L"gsfraw", CreateTr2GrannyStateRes); +BLUE_REGISTER_RESOURCE_EXTENSION( L"gsfraw", CreateTr2GrannyStateRes ); const Be::ClassInfo* Tr2GrannyStateRes::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2GrannyStateRes, "") + EXPOSURE_BEGIN( Tr2GrannyStateRes, "" ) - MAP_INTERFACE(Tr2GrannyStateRes) - MAP_INTERFACE(IBlueResource) - MAP_INTERFACE(ICacheable) + MAP_INTERFACE( Tr2GrannyStateRes ) + MAP_INTERFACE( IBlueResource ) + MAP_INTERFACE( ICacheable ) MAP_ICACHEABLE_METHODS() - EXPOSURE_CHAINTO(BlueAsyncRes) + EXPOSURE_CHAINTO( BlueAsyncRes ) } #endif \ No newline at end of file diff --git a/trinity/Resources/Tr2ImageRes.cpp b/trinity/Resources/Tr2ImageRes.cpp index 77ca4c112..7d1baadeb 100644 --- a/trinity/Resources/Tr2ImageRes.cpp +++ b/trinity/Resources/Tr2ImageRes.cpp @@ -98,7 +98,7 @@ Color Tr2ImageRes::GetPixelColor( int x, int y ) const // TODO: Support different formats Tr2RenderContextEnum::PixelFormat format = m_bitmap.GetFormat(); - if( format != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM && + if( format != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM && format != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM ) { CCP_LOGERR( "Tr2ImageRes::GetPixelColor currently only supports PIXEL_FORMAT_B8G8R8A8_UNORM or PIXEL_FORMAT_B8G8R8X8_UNORM" ); diff --git a/trinity/Resources/Tr2ImageRes.h b/trinity/Resources/Tr2ImageRes.h index 186b56721..572491990 100644 --- a/trinity/Resources/Tr2ImageRes.h +++ b/trinity/Resources/Tr2ImageRes.h @@ -13,13 +13,13 @@ BLUE_DECLARE( Tr2ImageRes ); // GetResource call to get a Tr2ImageRes rather than a TriTextureRes instance. // Tr2ImageRes does not create any D3D resources - it is meant to be used when // the raw image data is needed on the CPU. -BLUE_CLASS( Tr2ImageRes ): - public BlueAsyncRes, - public ICacheable +BLUE_CLASS( Tr2ImageRes ) : + public BlueAsyncRes, + public ICacheable { public: - EXPOSE_TO_BLUE(); - Tr2ImageRes( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2ImageRes( IRoot* lockobj = NULL ); ~Tr2ImageRes(); ////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Resources/Tr2ImageRes_Blue.cpp b/trinity/Resources/Tr2ImageRes_Blue.cpp index 4ca8a6e4c..8f7d64c28 100644 --- a/trinity/Resources/Tr2ImageRes_Blue.cpp +++ b/trinity/Resources/Tr2ImageRes_Blue.cpp @@ -19,43 +19,35 @@ BLUE_REGISTER_RESOURCE_EXTENSION( L"tgaraw", CreateTr2ImageRes ); const Be::ClassInfo* Tr2ImageRes::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ImageRes, "" ) + EXPOSURE_BEGIN( Tr2ImageRes, "" ) MAP_INTERFACE( Tr2ImageRes ) MAP_INTERFACE( IBlueResource ) MAP_INTERFACE( ICacheable ) MAP_ICACHEABLE_METHODS() - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "width", GetWidth, - "Width of the image (in pixels)" - ) + "Width of the image (in pixels)" ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "height", GetHeight, - "Height of the image (in pixels)" - ) + "Height of the image (in pixels)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "IsPixelOpaque", IsPixelOpaque, "Returns true if the alpha value for the given pixel is > 0.5." "\n:param x: x-coordinate of pixel" - "\n:param y: y-coordinate of pixel" - ) + "\n:param y: y-coordinate of pixel" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetPixelColor", GetPixelColor, "Returns the color value of the given pixel." "\n:param x: x-coordinate of pixel" - "\n:param y: y-coordinate of pixel" - ) - EXPOSURE_CHAINTO( BlueAsyncRes ) + "\n:param y: y-coordinate of pixel" ) + EXPOSURE_CHAINTO( BlueAsyncRes ) } diff --git a/trinity/Resources/Tr2LightProfileRes.h b/trinity/Resources/Tr2LightProfileRes.h index a1c81558c..7be62ad01 100644 --- a/trinity/Resources/Tr2LightProfileRes.h +++ b/trinity/Resources/Tr2LightProfileRes.h @@ -30,7 +30,7 @@ BLUE_CLASS( Tr2LightProfileRes ) : private: bool ParseIes(); - static bool ParseIes( const std::string& contents, ImageIO::HostBitmap & bitmap ); + static bool ParseIes( const std::string& contents, ImageIO::HostBitmap& bitmap ); ImageIO::HostBitmap m_bitmap; Tr2TextureArrayElement m_element; diff --git a/trinity/Resources/Tr2LightProfileRes_Blue.cpp b/trinity/Resources/Tr2LightProfileRes_Blue.cpp index b1477ed44..ce27ece9d 100644 --- a/trinity/Resources/Tr2LightProfileRes_Blue.cpp +++ b/trinity/Resources/Tr2LightProfileRes_Blue.cpp @@ -26,24 +26,22 @@ BLUE_REGISTER_RESOURCE_EXTENSION( L"ddslp", CreateTr2LightProfileRes ); BLUE_REGISTER_RESOURCE_EXTENSION( L"ieslp", CreateTr2LightProfileRes ); -const Be::ClassInfo* Tr2LightProfileRes::ExposeToBlue() -{ +const Be::ClassInfo* Tr2LightProfileRes::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2LightProfileRes, "" ) MAP_INTERFACE( Tr2LightProfileRes ) - MAP_INTERFACE( IBlueResource ) - MAP_INTERFACE( ICacheable ) - MAP_ICACHEABLE_METHODS() - - MAP_METHOD_AND_WRAP( - "GetThumbnail", - GetThumbnail, - "Generates a thumbnail for the profile. Should only be used for tools.\n" - ":param width: thumbnail width\n" - ":param height: thumbnail height" - ) - - EXPOSURE_CHAINTO( BlueAsyncRes ) + MAP_INTERFACE( IBlueResource ) + MAP_INTERFACE( ICacheable ) + MAP_ICACHEABLE_METHODS() + + MAP_METHOD_AND_WRAP( + "GetThumbnail", + GetThumbnail, + "Generates a thumbnail for the profile. Should only be used for tools.\n" + ":param width: thumbnail width\n" + ":param height: thumbnail height" ) + + EXPOSURE_CHAINTO( BlueAsyncRes ) } diff --git a/trinity/Resources/Tr2LodResource.h b/trinity/Resources/Tr2LodResource.h index bb9e94ade..6f67df68d 100644 --- a/trinity/Resources/Tr2LodResource.h +++ b/trinity/Resources/Tr2LodResource.h @@ -4,9 +4,10 @@ #ifndef Tr2LodResource_h #define Tr2LodResource_h -enum Tr2Lod { +enum Tr2Lod +{ TR2_LOD_UNSPECIFIED = -1, - + TR2_LOD_LOW = 0, TR2_LOD_MEDIUM, TR2_LOD_HIGH, diff --git a/trinity/Resources/Tr2MaterialRes.cpp b/trinity/Resources/Tr2MaterialRes.cpp index fc83a2208..422b8d05f 100644 --- a/trinity/Resources/Tr2MaterialRes.cpp +++ b/trinity/Resources/Tr2MaterialRes.cpp @@ -4,8 +4,8 @@ #include "Tr2MaterialRes.h" //================================================================ -Tr2MaterialMesh::Tr2MaterialMesh( IRoot* lockobj ): -PARENTLOCK( m_areas ) +Tr2MaterialMesh::Tr2MaterialMesh( IRoot* lockobj ) : + PARENTLOCK( m_areas ) { } @@ -16,8 +16,8 @@ Tr2MaterialMesh::~Tr2MaterialMesh() //================================================================ -Tr2MaterialRes::Tr2MaterialRes( IRoot* lockobj ): -PARENTLOCK( m_meshes ) +Tr2MaterialRes::Tr2MaterialRes( IRoot* lockobj ) : + PARENTLOCK( m_meshes ) { } diff --git a/trinity/Resources/Tr2MaterialRes.h b/trinity/Resources/Tr2MaterialRes.h index 3c6fabf33..6ed471d83 100644 --- a/trinity/Resources/Tr2MaterialRes.h +++ b/trinity/Resources/Tr2MaterialRes.h @@ -16,31 +16,29 @@ BLUE_DECLARE( Tr2MaterialParameterStore ); //================================================================ -class Tr2MaterialArea: - public IRoot +class Tr2MaterialArea : public IRoot { public: - Tr2MaterialArea( IRoot* lockobj = NULL ){}; - virtual ~Tr2MaterialArea(){}; + Tr2MaterialArea( IRoot* lockobj = NULL ) {}; + virtual ~Tr2MaterialArea() {}; EXPOSE_TO_BLUE(); protected: // The name of the metamaterial to use for this area - std::string m_metaType; + std::string m_metaType; // The material overrides applied to this area - Tr2MaterialParameterStorePtr m_material; + Tr2MaterialParameterStorePtr m_material; }; TYPEDEF_BLUECLASS( Tr2MaterialArea ); -typedef BlueDict< Tr2MaterialArea > Tr2MaterialAreaDict; +typedef BlueDict Tr2MaterialAreaDict; TYPEDEF_BLUECLASS( Tr2MaterialAreaDict ); //================================================================ -class Tr2MaterialMesh: - public IRoot +class Tr2MaterialMesh : public IRoot { public: EXPOSE_TO_BLUE(); @@ -55,18 +53,17 @@ class Tr2MaterialMesh: TYPEDEF_BLUECLASS( Tr2MaterialMesh ); BLUE_DECLARE_VECTOR( Tr2MaterialMesh ); -typedef BlueDict< Tr2MaterialMesh > Tr2MaterialMeshDict; +typedef BlueDict Tr2MaterialMeshDict; TYPEDEF_BLUECLASS( Tr2MaterialMeshDict ); //================================================================ -class Tr2MaterialRes: - public IRoot +class Tr2MaterialRes : public IRoot { public: EXPOSE_TO_BLUE(); - Tr2MaterialRes( IRoot* lockobj = NULL ); + Tr2MaterialRes( IRoot* lockobj = NULL ); virtual ~Tr2MaterialRes(); public: @@ -79,4 +76,3 @@ TYPEDEF_BLUECLASS( Tr2MaterialRes ); BLUE_DECLARE_VECTOR( Tr2MaterialRes ); #endif - diff --git a/trinity/Resources/Tr2MaterialRes_Blue.cpp b/trinity/Resources/Tr2MaterialRes_Blue.cpp index 0e2cd55ad..7aa5fec69 100644 --- a/trinity/Resources/Tr2MaterialRes_Blue.cpp +++ b/trinity/Resources/Tr2MaterialRes_Blue.cpp @@ -5,26 +5,24 @@ BLUE_DEFINE( Tr2MaterialRes ); -const Be::ClassInfo* Tr2MaterialRes::ExposeToBlue() -{ +const Be::ClassInfo* Tr2MaterialRes::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2MaterialRes, "" ) MAP_INTERFACE( IRoot ) - MAP_INTERFACE( Tr2MaterialRes ) - MAP_ATTRIBUTE( "name", m_name, "The name of the res", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "meshes", m_meshes, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( Tr2MaterialRes ) + MAP_ATTRIBUTE( "name", m_name, "The name of the res", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "meshes", m_meshes, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } BLUE_DEFINE( Tr2MaterialMesh ); -const Be::ClassInfo* Tr2MaterialMesh::ExposeToBlue() -{ +const Be::ClassInfo* Tr2MaterialMesh::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2MaterialMesh, "" ) MAP_INTERFACE( IRoot ) - MAP_INTERFACE( Tr2MaterialMesh ) - MAP_ATTRIBUTE( "areas", m_areas, "", Be::READ | Be::PERSIST ) - EXPOSURE_END() + MAP_INTERFACE( Tr2MaterialMesh ) + MAP_ATTRIBUTE( "areas", m_areas, "", Be::READ | Be::PERSIST ) + EXPOSURE_END() } @@ -32,13 +30,13 @@ BLUE_DEFINE( Tr2MaterialArea ); const Be::ClassInfo* Tr2MaterialArea::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2MaterialArea, "" ) + EXPOSURE_BEGIN( Tr2MaterialArea, "" ) - MAP_INTERFACE( IRoot ) - MAP_INTERFACE( Tr2MaterialArea ) + MAP_INTERFACE( IRoot ) + MAP_INTERFACE( Tr2MaterialArea ) - MAP_ATTRIBUTE( "metatype", m_metaType, "The metamaterial used to render this area", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "material", m_material, "The materialstore containing our overrides", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "metatype", m_metaType, "The metamaterial used to render this area", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "material", m_material, "The materialstore containing our overrides", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Resources/Tr2TextureLodManager.h b/trinity/Resources/Tr2TextureLodManager.h index 4960cfbc2..668556e1c 100644 --- a/trinity/Resources/Tr2TextureLodManager.h +++ b/trinity/Resources/Tr2TextureLodManager.h @@ -15,7 +15,7 @@ struct Tr2TextureLodUpdateRequest BLUE_CLASS( Tr2TextureLodManager ) : - public IRoot, + public IRoot, public IBlueEvents { public: diff --git a/trinity/Resources/Tr2TextureLodManager_Blue.cpp b/trinity/Resources/Tr2TextureLodManager_Blue.cpp index 0977702ac..943a4823d 100644 --- a/trinity/Resources/Tr2TextureLodManager_Blue.cpp +++ b/trinity/Resources/Tr2TextureLodManager_Blue.cpp @@ -32,5 +32,4 @@ Tr2TextureLodManagerPtr GetTextureLodManager() MAP_FUNCTION_AND_WRAP( "GetTextureLodManager", GetTextureLodManager, - "Returns a global instance of the texture LOD manager" -); + "Returns a global instance of the texture LOD manager" ); diff --git a/trinity/Resources/TriGeometryRes.cpp b/trinity/Resources/TriGeometryRes.cpp index 57b90c4fb..1014150f9 100644 --- a/trinity/Resources/TriGeometryRes.cpp +++ b/trinity/Resources/TriGeometryRes.cpp @@ -75,47 +75,39 @@ static void CopyGrannyName( std::string& dest, const char* src ) } -static void ConvertDataToVector3( Tr2VertexDefinition::DataType elementType, const void * src, Vector3 * dest) +static void ConvertDataToVector3( Tr2VertexDefinition::DataType elementType, const void* src, Vector3* dest ) { - switch(elementType) + switch( elementType ) { - case Tr2VertexDefinition::FLOAT16_4: - { - *reinterpret_cast( dest ) = *static_cast( src ); - break; - } - case Tr2VertexDefinition::FLOAT32_3: - { - memcpy( dest, src, 3 * sizeof(float)); - break; - } - case Tr2VertexDefinition::FLOAT32_4: - { - memcpy( dest, src, 3 * sizeof(float)); - break; - } - case Tr2VertexDefinition::SHORT_4: - { - ConvertShort4ToVector3( src, dest ); - break; - } - - case Tr2VertexDefinition::UBYTE_4: - { - ConvertUByte4ToVector3(src, dest ); - break; - } - - default: - { - dest->x = 0.0f; - dest->y = 0.0f; - dest->z = 0.0f; - } + case Tr2VertexDefinition::FLOAT16_4: { + *reinterpret_cast( dest ) = *static_cast( src ); + break; + } + case Tr2VertexDefinition::FLOAT32_3: { + memcpy( dest, src, 3 * sizeof( float ) ); + break; + } + case Tr2VertexDefinition::FLOAT32_4: { + memcpy( dest, src, 3 * sizeof( float ) ); + break; + } + case Tr2VertexDefinition::SHORT_4: { + ConvertShort4ToVector3( src, dest ); + break; + } + case Tr2VertexDefinition::UBYTE_4: { + ConvertUByte4ToVector3( src, dest ); + break; } + default: { + dest->x = 0.0f; + dest->y = 0.0f; + dest->z = 0.0f; + } + } } @@ -189,7 +181,7 @@ uint32_t GetPrimitiveCount( const TriGeometryResLodData& lod, uint32_t index, ui namespace { #if WITH_GRANNY -ALResult ReverseIndexBuffer( TriGeometryResLodData& lod, granny_mesh& grannyMesh, Tr2RenderContext& renderContext ) +ALResult ReverseIndexBuffer( TriGeometryResLodData& lod, granny_mesh& grannyMesh, Tr2RenderContext& renderContext ) { uint32_t bytesPerIndex = 2; auto indexCount = grannyMesh.PrimaryTopology->Index16Count; @@ -228,7 +220,7 @@ ALResult ReverseIndexBuffer( TriGeometryResLodData& lod, const void* ibData, con { uint32_t bytesPerIndex = cmfMeshLod.ib.stride; auto indexCount = cmf::GetStreamElementCount( cmfMeshLod.ib ); - + std::vector tempBuffer( indexCount * bytesPerIndex ); memcpy( tempBuffer.data(), ibData, indexCount * bytesPerIndex ); @@ -306,7 +298,7 @@ unsigned int TriGeometryRes::GetAnimationCount() const { if( IsGood() && m_cmfContents ) { - return (int) m_cmfContents.GetData()->animations.size(); + return (int)m_cmfContents.GetData()->animations.size(); } } #if WITH_GRANNY @@ -504,7 +496,7 @@ unsigned int TriGeometryRes::GetAreaCount( unsigned int meshIx ) const { return 0; } - + //Get the first LOD. auto& lod = mesh->m_lods[0]; @@ -543,7 +535,7 @@ bool TriGeometryRes::OnPrepareResources() void TriGeometryRes::ReleaseResources( TriStorage s ) { - if ( s & TRISTORAGE_MANAGEDMEMORY ) + if( s & TRISTORAGE_MANAGEDMEMORY ) { CancelPendingLoad(); @@ -626,7 +618,7 @@ BlueAsyncRes::LoadingResult TriGeometryRes::DoLoad() } #endif } - + return LR_FAILED; } @@ -708,7 +700,7 @@ void TriGeometryRes::DetermineAreaBoundsAndVertCount( TriGeometryResAreaData& ar // Assume that position is the first component // set up some data for the vertex fetcher. - unsigned int positionOffset; + unsigned int positionOffset; Tr2VertexDefinition::DataType positionType; GetVertexPositionOffsetAndType( grannyMesh, positionOffset, positionType ); @@ -733,7 +725,7 @@ void TriGeometryRes::DetermineAreaBoundsAndVertCount( TriGeometryResAreaData& ar // vertices are NOT GUARENTEED to be float3 or fp16_4, so this helps with that. Vector3 vertexPosition; - GetMeshVertexPosition(grannyMesh, index, vertexPosition, (unsigned int) bytesPerVertex, positionOffset, positionType); + GetMeshVertexPosition( grannyMesh, index, vertexPosition, (unsigned int)bytesPerVertex, positionOffset, positionType ); BoundingBoxUpdate( area.m_minBounds, area.m_maxBounds, vertexPosition ); } @@ -793,7 +785,7 @@ bool TriGeometryRes::IsAreaSkinned( TriGeometryResAreaData& area, granny_mesh* g uint8_t* pBoneIndex1 = (uint8_t*)grannyMesh->PrimaryVertexData->Vertices + boneIndexOffset + 1; uint8_t* pBoneIndex2 = (uint8_t*)grannyMesh->PrimaryVertexData->Vertices + boneIndexOffset + 2; uint8_t* pBoneIndex3 = (uint8_t*)grannyMesh->PrimaryVertexData->Vertices + boneIndexOffset + 3; - + // cycle thorugh all vertices of this area and collect bone indices for( int vIx = 0; vIx < area.m_primitiveCount * 3; ++vIx ) { @@ -809,10 +801,10 @@ bool TriGeometryRes::IsAreaSkinned( TriGeometryResAreaData& area, granny_mesh* g } // bones - uint8_t boneIndex0 = *(pBoneIndex0 + index * bytesPerVertex); - uint8_t boneIndex1 = *(pBoneIndex1 + index * bytesPerVertex); - uint8_t boneIndex2 = *(pBoneIndex2 + index * bytesPerVertex); - uint8_t boneIndex3 = *(pBoneIndex3 + index * bytesPerVertex); + uint8_t boneIndex0 = *( pBoneIndex0 + index * bytesPerVertex ); + uint8_t boneIndex1 = *( pBoneIndex1 + index * bytesPerVertex ); + uint8_t boneIndex2 = *( pBoneIndex2 + index * bytesPerVertex ); + uint8_t boneIndex3 = *( pBoneIndex3 + index * bytesPerVertex ); if( boneIndex0 != *rootBoneIndex || boneIndex1 != *rootBoneIndex || boneIndex2 != *rootBoneIndex || boneIndex3 != *rootBoneIndex ) { @@ -890,7 +882,7 @@ bool TriGeometryRes::SetupMeshes( const cmf::Data& cmfData ) Tr2VertexDefinition vertexDefinition = BuildFromCMFVertexDecl( cmfMesh.decl ); const uint32_t vertexDeclarationHandle = Tr2EffectStateManager::GetVertexDeclarationHandle( vertexDefinition ); unsigned int bytesPerVertex = cmfMesh.lods[0].vb.stride; - + TriGeometryResMeshData* mesh = new TriGeometryResMeshData(); mesh->m_name = cmf::ToStdString( cmfMesh.name ); @@ -1114,7 +1106,7 @@ bool TriGeometryRes::SetupMeshes( granny_file_info* gi ) { lod->m_uvDensities.assign( mbi->uvDensities, mbi->uvDensities + mbi->uvDensityCount ); } - + if( mainLod ) { Vector3 meshMin = *reinterpret_cast( &mbi->bounds.min[0] ); @@ -1124,7 +1116,7 @@ bool TriGeometryRes::SetupMeshes( granny_file_info* gi ) } - + lod->m_areas.resize( grannyMesh->PrimaryTopology->GroupCount ); for( int groupIndex = 0; groupIndex < grannyMesh->PrimaryTopology->GroupCount; ++groupIndex ) @@ -1294,22 +1286,22 @@ bool TriGeometryRes::ReadGrannyFile() CCP_STATS_ZONE( __FUNCTION__ ); m_useCMF = false; - + void* data; if( !m_dataStream->LockData( &data, 0 ) ) { return false; } - + m_pGrannyFile = ProtectedGrannyReadEntireFileFromMemory( m_path.c_str(), uint32_t( m_dataStream->GetSize() ), data ); - + if( !m_pGrannyFile ) { return false; } granny_file_info* gi = GrannyGetFileInfo( m_pGrannyFile ); - + // BeResMan->AddGeometryDataRead( m_dataSize ); // m_pGrannyFile is freed in CreateD3DMeshFromGranny once the D3D @@ -1319,9 +1311,9 @@ bool TriGeometryRes::ReadGrannyFile() { return false; } - + SetupSkeletons( gi ); - + return true; } #endif @@ -1334,7 +1326,7 @@ void TriGeometryRes::PrepareFromGrannyRes( TriGrannyRes* g ) if( g->IsUsingCMF() ) { const cmf::Data* cmfData = g->GetCMFData(); - + if( !cmfData ) { return; @@ -1357,7 +1349,7 @@ void TriGeometryRes::PrepareFromGrannyRes( TriGrannyRes* g ) granny_file_info* gi = GrannyGetFileInfo( f ); m_useCMF = false; - + SetupMeshes( gi ); SetupSkeletons( gi ); CreateMeshesFromGrannyFile( gi, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, renderContext ); @@ -1391,7 +1383,7 @@ void TriGeometryRes::RecalculateBoundingSphere() auto& lod = mesh->m_lods[0]; - //Get the vertex data of the + //Get the vertex data of the const uint8_t* pVertices; if( !lod->m_allocationsValid || FAILED( lod->m_vertexAllocation.MapForReading( pVertices, renderContext ) ) ) @@ -1429,7 +1421,7 @@ void CalcBoundingBox( void* context, const Vector3& p1, const Vector3& p2, const v[1] = Vector4( p2.x, p2.y, p2.z, 1.0f ); v[2] = Vector4( p3.x, p3.y, p3.z, 1.0f ); - for( int i=0; i<3; ++i ) + for( int i = 0; i < 3; ++i ) { v[i] = Transform( v[i], ctx->transform ); v[i] /= v[i].w; @@ -1444,15 +1436,12 @@ void CalcBoundingBox( void* context, const Vector3& p1, const Vector3& p2, const } } -static void ConvertTriangleData( Tr2VertexDefinition::DataType elementType, unsigned int vertexByteSize, const uint8_t * vertexBase, - unsigned int index1, unsigned int index2,unsigned int index3, - Vector3 * v1, Vector3 * v2, Vector3 * v3) +static void ConvertTriangleData( Tr2VertexDefinition::DataType elementType, unsigned int vertexByteSize, const uint8_t* vertexBase, unsigned int index1, unsigned int index2, unsigned int index3, Vector3* v1, Vector3* v2, Vector3* v3 ) { - ConvertDataToVector3(elementType, vertexBase + index1 * vertexByteSize, v1); - ConvertDataToVector3(elementType, vertexBase + index2 * vertexByteSize, v2); - ConvertDataToVector3(elementType, vertexBase + index3 * vertexByteSize, v3); - + ConvertDataToVector3( elementType, vertexBase + index1 * vertexByteSize, v1 ); + ConvertDataToVector3( elementType, vertexBase + index2 * vertexByteSize, v2 ); + ConvertDataToVector3( elementType, vertexBase + index3 * vertexByteSize, v3 ); } void TriGeometryRes::ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, void* cbContext ) @@ -1494,10 +1483,10 @@ void TriGeometryRes::ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, v const uint16_t* pShortIndices = (uint16_t*)pIndices; const uint32_t* pLongIndices = (uint32_t*)pIndices; - + Tr2VertexDefinition decl; - if ( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh->m_vertexDeclarationHandle, decl ) ) + if( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh->m_vertexDeclarationHandle, decl ) ) { return; } @@ -1511,7 +1500,7 @@ void TriGeometryRes::ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, v Tr2VertexDefinition::DataType declType = foundPosition->m_dataType; int numPrim = lod->m_primitiveCount; - for ( int j = 0; j < numPrim; j++ ) + for( int j = 0; j < numPrim; j++ ) { unsigned int index1 = 0; unsigned int index2 = 0; @@ -1521,20 +1510,20 @@ void TriGeometryRes::ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, v Vector3 p3; if( lod->m_indexAllocation.GetStride() == 2 ) { - index1 = pShortIndices[j*3]; - index2 = pShortIndices[(j*3)+1]; - index3 = pShortIndices[(j*3)+2]; + index1 = pShortIndices[j * 3]; + index2 = pShortIndices[( j * 3 ) + 1]; + index3 = pShortIndices[( j * 3 ) + 2]; } else { - index1 = pLongIndices[j*3]; - index2 = pLongIndices[(j*3)+1]; - index3 = pLongIndices[(j*3)+2]; + index1 = pLongIndices[j * 3]; + index2 = pLongIndices[( j * 3 ) + 1]; + index3 = pLongIndices[( j * 3 ) + 2]; } - ConvertTriangleData(declType, vertSize, pVertices + positionByteOffset , index1, index2, index3, &p1, &p2, &p3); + ConvertTriangleData( declType, vertSize, pVertices + positionByteOffset, index1, index2, index3, &p1, &p2, &p3 ); - (*cb)( cbContext, p1, p2, p3 ); + ( *cb )( cbContext, p1, p2, p3 ); } } @@ -1560,17 +1549,17 @@ Be::Result TriGeometryRes::GetAreaIntersectionPointNormalBoneFromSc Vector3 hitpoint( 0.0f, 0.0f, 0.0f ); Vector3 normal( 0.0f, 0.0f, 0.0f ); int boneIndex; - + if( areaIx < -1 ) { // -1 is a special case handled to maintain legacy behavior. - return Be::Result("Invalid area index"); + return Be::Result( "Invalid area index" ); } // In Python 3, passing a signed value to an unsigned C exposed attribute is an error. // In order to maintain backwards compatible behavior with Python 2 // this method got changed to accept signed integers and cast them to unsigned. - auto unsignedAreaIndex = static_cast(areaIx); + auto unsignedAreaIndex = static_cast( areaIx ); bool success = GetIntersectionPointNormalBone( &pos, &dir, &hitpoint, &normal, &boneIndex, unsignedAreaIndex ); result = std::make_pair( success, std::make_pair( boneIndex, std::make_pair( hitpoint, normal ) ) ); @@ -1596,9 +1585,9 @@ static bool IntersectTri( const Vector3* p2, const Vector3* rayPos, const Vector3* rayDir, - float *u, - float *v, - float *dist ) + float* u, + float* v, + float* dist ) { Matrix m; Vector4 vec; @@ -1645,7 +1634,7 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d CCP_STATS_ZONE( __FUNCTION__ ); USE_MAIN_THREAD_RENDER_CONTEXT(); - + *boneIndexFar = *boneIndexNear = -1; int boneIndex = 0; float minDist = FLT_MAX; @@ -1672,16 +1661,16 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d } ON_BLOCK_EXIT( [&] { lod->m_vertexAllocation.UnmapForReading( renderContext ); } ); if( FAILED( lod->m_indexAllocation.MapForReading( pIndices, renderContext ) ) ) - { + { return false; } ON_BLOCK_EXIT( [&] { lod->m_indexAllocation.UnmapForReading( renderContext ); } ); - + const uint16_t* pShortIndices = (uint16_t*)pIndices; const uint32_t* pLongIndices = (uint32_t*)pIndices; - + Tr2VertexDefinition decl; - if ( !Tr2EffectStateManager::GetVertexDeclarationElements( m_meshes[i]->m_vertexDeclarationHandle, decl ) ) + if( !Tr2EffectStateManager::GetVertexDeclarationElements( m_meshes[i]->m_vertexDeclarationHandle, decl ) ) { return false; } @@ -1690,13 +1679,13 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d { return false; } - + const Tr2VertexDefinition::Item* const blendIndices = decl.Find( decl.BLENDINDICES ); int numPrim = lod->m_primitiveCount; auto currentIndex = 0; - if ( areaIx != -1 ) + if( areaIx != -1 ) { - if ( areaIx >= lod->m_areas.size() ) + if( areaIx >= lod->m_areas.size() ) { continue; } @@ -1704,7 +1693,7 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d numPrim = lod->m_areas[areaIx].m_primitiveCount; } - for ( int j = 0; j < numPrim; j++ ) + for( int j = 0; j < numPrim; j++ ) { unsigned int index1 = 0; unsigned int index2 = 0; @@ -1728,14 +1717,14 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d ConvertTriangleData( position->m_dataType, vertSize, pVertices, index1, index2, index3, &p1, &p2, &p3 ); - if ( IntersectTri(&p1, &p2, &p3, pos, dir, &pu, &pv, &dist ) ) + if( IntersectTri( &p1, &p2, &p3, pos, dir, &pu, &pv, &dist ) ) { - float v1 = 1.0f - (pu + pv); + float v1 = 1.0f - ( pu + pv ); Vector3 avec = p2 - p1; Vector3 bvec = p3 - p1; - if ( minDist > dist ) + if( minDist > dist ) { - *hitpointNear = p1*v1 + p2*pu + p3*pv; + *hitpointNear = p1 * v1 + p2 * pu + p3 * pv; *hitpointNearNormal = Normalize( Cross( avec, bvec ) ); minDist = dist; if( blendIndices && GetBoneIndex( blendIndices->m_dataType, pVertices + index1 * vertSize + blendIndices->m_offset, boneIndex ) ) @@ -1743,9 +1732,9 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d *boneIndexNear = boneIndex; } } - if ( maxDist < dist ) + if( maxDist < dist ) { - *hitpointFar = p1*v1 + p2*pu + p3*pv; + *hitpointFar = p1 * v1 + p2 * pu + p3 * pv; *hitpointFarNormal = Normalize( Cross( avec, bvec ) ); maxDist = dist; if( blendIndices && GetBoneIndex( blendIndices->m_dataType, pVertices + index1 * vertSize + blendIndices->m_offset, boneIndex ) ) @@ -1755,18 +1744,17 @@ bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* d } result = true; } - } } - if ( minDist == FLT_MAX ) + if( minDist == FLT_MAX ) { *hitpointNear = *hitpointFar; *hitpointNearNormal = *hitpointFarNormal; *boneIndexNear = *boneIndexFar; } - if ( maxDist == FLT_MIN ) + if( maxDist == FLT_MIN ) { *hitpointFar = *hitpointNear; *hitpointFarNormal = *hitpointNearNormal; @@ -1857,8 +1845,8 @@ TriGeometryResLodData::TriGeometryResLodData() : m_primitiveCount( 0 ), m_areas( "TriGeometryResMeshData/m_areas" ), m_morphVertexDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), - m_allocationsValid(false), - m_reversedIndicesValid(false), + m_allocationsValid( false ), + m_reversedIndicesValid( false ), m_uvDensities(), m_bytesPerMorphTargetVertex( 0 ) { @@ -1880,7 +1868,7 @@ void TriGeometryRes::RequestReversedIndexBuffers() { return; } - if ( m_reversedIndexBuffersRequested ) + if( m_reversedIndexBuffersRequested ) { return; } @@ -1951,25 +1939,25 @@ bool TriGeometryRes::RenderAreas( unsigned int meshIx, unsigned int areaIx, unsi bool TriGeometryRes::RenderAreas( float screenSize, unsigned int meshIx, unsigned int areaIx, unsigned int areaCount, Tr2RenderContext& renderContext, bool reversed ) { - if( !m_isGood ) - { - return false; - } + if( !m_isGood ) + { + return false; + } - if( meshIx >= m_meshes.size() ) - { - return false; - } + if( meshIx >= m_meshes.size() ) + { + return false; + } - TriGeometryResMeshData* mesh = m_meshes[meshIx].get(); + TriGeometryResMeshData* mesh = m_meshes[meshIx].get(); if( !mesh ) - { - return false; - } + { + return false; + } TriGeometryResLodData* lod = GetMeshLod( meshIx, screenSize ); - unsigned int primCount = GetPrimitiveCount( *lod, areaIx, areaCount ); + unsigned int primCount = GetPrimitiveCount( *lod, areaIx, areaCount ); if( primCount ) { @@ -1999,49 +1987,47 @@ bool TriGeometryRes::RenderAreas( float screenSize, unsigned int meshIx, unsigne } } - return true; + return true; } namespace { - TriMorphTargetGeometryConstants CreateMorphGeometryConstants( const Tr2VertexDefinition& vertexDefinition, uint32_t stride, uint32_t vertexCount, Tr2RenderContext& renderContext ) +TriMorphTargetGeometryConstants CreateMorphGeometryConstants( const Tr2VertexDefinition& vertexDefinition, uint32_t stride, uint32_t vertexCount, Tr2RenderContext& renderContext ) +{ + TriMorphTargetGeometryConstants data = TriMorphTargetGeometryConstants{}; + for( const auto& item : vertexDefinition.m_items ) { - TriMorphTargetGeometryConstants data = TriMorphTargetGeometryConstants{}; - for( const auto& item : vertexDefinition.m_items ) + if( item.m_usage == Tr2VertexDefinition::POSITION && item.m_usageIndex == 0 && item.m_stream == 0 ) { - if( item.m_usage == Tr2VertexDefinition::POSITION && item.m_usageIndex == 0 && item.m_stream == 0 ) - { - data.positionOffset = item.m_offset; - data.positionType = item.m_dataType; - - uint32_t type = data.positionType; - CCP_ASSERT_M( - type == Tr2VertexDefinition::DataType::FLOAT32_3, - "position type has to be FLOAT32_3!" - ); - } + data.positionOffset = item.m_offset; + data.positionType = item.m_dataType; - if( item.m_usage == Tr2VertexDefinition::TANGENT && item.m_usageIndex == 0 && item.m_stream == 0 ) - { - data.tangentOffset = item.m_offset; - data.tangentType = item.m_dataType; + uint32_t type = data.positionType; + CCP_ASSERT_M( + type == Tr2VertexDefinition::DataType::FLOAT32_3, + "position type has to be FLOAT32_3!" ); + } + + if( item.m_usage == Tr2VertexDefinition::TANGENT && item.m_usageIndex == 0 && item.m_stream == 0 ) + { + data.tangentOffset = item.m_offset; + data.tangentType = item.m_dataType; - uint32_t type = data.tangentType; - CCP_ASSERT_M( - type == Tr2VertexDefinition::DataType::FLOAT16_3 || + uint32_t type = data.tangentType; + CCP_ASSERT_M( + type == Tr2VertexDefinition::DataType::FLOAT16_3 || type == Tr2VertexDefinition::DataType::FLOAT32_3 || type == Tr2VertexDefinition::DataType::UBYTE_4_NORM || type == Tr2VertexDefinition::DataType::USHORT_4_NORM || type == Tr2VertexDefinition::DataType::SHORT_4_NORM, - "tangent type has to be FLOAT16_3 or FLOAT32_3 or UBYTE_4_NORM or USHORT_4_NORM or SHORT_4_NORM!" - ); - } + "tangent type has to be FLOAT16_3 or FLOAT32_3 or UBYTE_4_NORM or USHORT_4_NORM or SHORT_4_NORM!" ); } - - data.vertexBufferStride = stride; - data.vertexCount = vertexCount; - return data; } + + data.vertexBufferStride = stride; + data.vertexCount = vertexCount; + return data; +} } #if WITH_GRANNY @@ -2135,13 +2121,12 @@ bool TriGeometryRes::CreateLodFromCMFMesh( Tr2CmfContents& cmfContents, const cm uint32_t morphTargetBufferSize = (uint32_t)( morphDataSize * cmfMesh.morphTargets.targets.size() + sizeof( TriMorphTargetGeometryConstants ) ); CR_RETURN_VAL( g_sharedBuffer.Allocate( - 4, - morphTargetBufferSize >> 2, - nullptr, - renderContext, - lod->m_morphTargetAllocation ), - false - ); + 4, + morphTargetBufferSize >> 2, + nullptr, + renderContext, + lod->m_morphTargetAllocation ), + false ); TriMorphTargetGeometryConstants morphTargetConstants = CreateMorphGeometryConstants( morphTargetVertexDefinition, @@ -2204,7 +2189,7 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet } const int kVertexComponentMaxCount = 13; - + granny_data_type_definition* grannyVertexDecl = grannyMesh->PrimaryVertexData->VertexType; Tr2VertexDefinition vertexDefinition = BuildFromGrannyVertexDecl( grannyVertexDecl ); @@ -2241,7 +2226,7 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet } CR_RETURN_VAL( g_sharedBuffer.Allocate( bytesPerVertex, vertexCount, pSrc, renderContext, lod->m_vertexAllocation ), false ); - + // create d3d index buffer, this one is shared, either for dynamic or static geometry int ibSize = indexCount * bytesPerIndex; @@ -2254,10 +2239,10 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet if( FAILED( hr ) ) { g_sharedBuffer.Free( lod->m_vertexAllocation ); - return false; + return false; } - if ( m_reversedIndexBuffersRequested ) + if( m_reversedIndexBuffersRequested ) { if( bytesPerIndex == 2 ) { @@ -2276,7 +2261,6 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet } lod->m_reversedIndicesValid = true; } - } lod->m_morphVertexDeclaration = -1; @@ -2290,21 +2274,19 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet uint32_t morphDataSize = firstMorphTarget.VertexData->VertexCount * lod->m_bytesPerMorphTargetVertex; uint32_t morphTargetBufferSize = ( morphDataSize * grannyMesh->MorphTargetCount + sizeof( TriMorphTargetGeometryConstants ) ); - CR_RETURN_VAL( g_sharedBuffer.Allocate( - 4, - morphTargetBufferSize >> 2, - nullptr, - renderContext, - lod->m_morphTargetAllocation ), - false - ); - - TriMorphTargetGeometryConstants morphTargetConstants = CreateMorphGeometryConstants( - firstMorphTargetVertexDefinition, - lod->m_bytesPerMorphTargetVertex, - firstMorphTarget.VertexData->VertexCount, - renderContext - ); + CR_RETURN_VAL( g_sharedBuffer.Allocate( + 4, + morphTargetBufferSize >> 2, + nullptr, + renderContext, + lod->m_morphTargetAllocation ), + false ); + + TriMorphTargetGeometryConstants morphTargetConstants = CreateMorphGeometryConstants( + firstMorphTargetVertexDefinition, + lod->m_bytesPerMorphTargetVertex, + firstMorphTarget.VertexData->VertexCount, + renderContext ); lod->m_morphTargetAllocation.Update( &morphTargetConstants, 0, sizeof( TriMorphTargetGeometryConstants ), renderContext ); @@ -2324,22 +2306,21 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet // By convention (due to the exporter), the morph target name ends with "Shape". std::string morphTargetName( morphTarget.ScalarName ); - if ( nameLength > 5 && strcmp( morphTarget.ScalarName + nameLength - 5, "Shape" ) == 0 ) + if( nameLength > 5 && strcmp( morphTarget.ScalarName + nameLength - 5, "Shape" ) == 0 ) { morphTargetName = std::string( morphTarget.ScalarName, nameLength - 5 ); } - + lod->m_morphTargetNames.push_back( morphTargetName ); lod->m_isBakedMorphTarget.push_back( false ); void* pMorphSrc = GrannyGetMeshMorphVertices( grannyMesh, i ); - lod->m_morphTargetAllocation.Update( - pMorphSrc, - morphDataSize * i + sizeof( TriMorphTargetGeometryConstants ), - morphDataSize, - renderContext - ); + lod->m_morphTargetAllocation.Update( + pMorphSrc, + morphDataSize * i + sizeof( TriMorphTargetGeometryConstants ), + morphDataSize, + renderContext ); float deformationAmount = CalculateMorphDeformationAmount( morphTarget.DataIsDeltas, vertexCount, (uint8_t*)pMorphSrc, morphTargetVertexDefinition, (uint8_t*)pSrc, vertexDefinition ); lod->m_morphTargetDeformationAmounts.push_back( deformationAmount ); @@ -2356,7 +2337,7 @@ bool TriGeometryRes::CreateLodFromGrannyMesh( granny_mesh* grannyMesh, TriGeomet { m_memoryUse += ibSize; } - + return true; } #endif @@ -2569,7 +2550,7 @@ bool TriGeometryRes::SaveMeshToCMFFile( TriGeometryResMeshData& mesh, const char } ON_BLOCK_EXIT( [&] { lod->m_indexAllocation.UnmapForReading( renderContext ); } ); - + cmf::Data cmfData; cmfData.meshes = allocator.AllocateSpan( 1 ); @@ -2602,7 +2583,7 @@ bool TriGeometryRes::SaveMeshToCMFFile( TriGeometryResMeshData& mesh, const char for( int32_t j = 0; j < lod->m_areas[i].m_jointBindings.size(); j++ ) { - cmfMeshArea.bones[j] = (uint16_t) lod->m_areas[i].m_jointBindings[j]; + cmfMeshArea.bones[j] = (uint16_t)lod->m_areas[i].m_jointBindings[j]; } cmf::LodMeshArea& lodMeshArea = cmfMeshLod.areas[i]; @@ -2659,14 +2640,14 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c } granny_data_type_definition grannyVertexDecl[16]; - + Tr2VertexDefinition decl; if( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh.m_vertexDeclarationHandle, decl ) ) { return false; } - - if( !ConvertVertexDeclToGranny( decl, grannyVertexDecl, sizeof(grannyVertexDecl)/sizeof(grannyVertexDecl[0]) ) ) + + if( !ConvertVertexDeclToGranny( decl, grannyVertexDecl, sizeof( grannyVertexDecl ) / sizeof( grannyVertexDecl[0] ) ) ) { return false; } @@ -2707,7 +2688,7 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c } myTopology.GroupCount = (granny_int32)lod->m_areas.size(); - myTopology.Groups = CCP_NEW("myTopology.Groups") granny_tri_material_group[myTopology.GroupCount]; + myTopology.Groups = CCP_NEW( "myTopology.Groups" ) granny_tri_material_group[myTopology.GroupCount]; if( myTopology.Groups ) { for( int i = 0; i < myTopology.GroupCount; ++i ) @@ -2728,7 +2709,7 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c grannyMesh.PrimaryVertexData = &myVertexData; grannyMesh.PrimaryTopology = &myTopology; - granny_file_info fileInfo; + granny_file_info fileInfo; memset( &fileInfo, 0, sizeof( fileInfo ) ); granny_mesh* meshes[] = { &grannyMesh }; @@ -2745,14 +2726,14 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c fileInfo.TriTopologies = topologies; fileInfo.MaterialCount = (granny_int32)lod->m_areas.size(); - fileInfo.Materials = CCP_NEW("fileInfo.Materials") granny_material*[fileInfo.MaterialCount]; + fileInfo.Materials = CCP_NEW( "fileInfo.Materials" ) granny_material * [fileInfo.MaterialCount]; if( fileInfo.Materials == nullptr ) { fileInfo.MaterialCount = 0; } grannyMesh.MaterialBindingCount = fileInfo.MaterialCount; - grannyMesh.MaterialBindings = CCP_NEW("grannyMesh.MaterialBindings") granny_material_binding[fileInfo.MaterialCount]; + grannyMesh.MaterialBindings = CCP_NEW( "grannyMesh.MaterialBindings" ) granny_material_binding[fileInfo.MaterialCount]; if( grannyMesh.MaterialBindings == nullptr ) { grannyMesh.MaterialBindingCount = 0; @@ -2761,7 +2742,7 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c granny_material* pMaterials = nullptr; if( fileInfo.MaterialCount ) { - pMaterials = CCP_NEW("pMaterials") granny_material[fileInfo.MaterialCount]; + pMaterials = CCP_NEW( "pMaterials" ) granny_material[fileInfo.MaterialCount]; if( pMaterials ) { memset( pMaterials, 0, sizeof( granny_material ) * fileInfo.MaterialCount ); @@ -2774,10 +2755,10 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c } } } - + // Bones grannyMesh.BoneBindingCount = (granny_int32)mesh.m_jointBindings.size(); - grannyMesh.BoneBindings = CCP_NEW("grannyMesh.BoneBindings") granny_bone_binding[grannyMesh.BoneBindingCount]; + grannyMesh.BoneBindings = CCP_NEW( "grannyMesh.BoneBindings" ) granny_bone_binding[grannyMesh.BoneBindingCount]; if( grannyMesh.BoneBindings == nullptr ) { grannyMesh.BoneBindingCount = 0; @@ -2798,23 +2779,20 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c } - granny_file_builder *Builder = GrannyBeginFile(1, GrannyCurrentGRNStandardTag, - GrannyGRNFileMV_32Bit_LittleEndian, - GrannyGetTemporaryDirectory(), - "GRNFileTemp"); - granny_file_data_tree_writer *Writer = - GrannyBeginFileDataTreeWriting(GrannyFileInfoType, &fileInfo, 0, 0); - GrannyWriteDataTreeToFileBuilder(Writer, Builder); - GrannyEndFileDataTreeWriting(Writer); + granny_file_builder* Builder = GrannyBeginFile( 1, GrannyCurrentGRNStandardTag, GrannyGRNFileMV_32Bit_LittleEndian, GrannyGetTemporaryDirectory(), "GRNFileTemp" ); + granny_file_data_tree_writer* Writer = + GrannyBeginFileDataTreeWriting( GrannyFileInfoType, &fileInfo, 0, 0 ); + GrannyWriteDataTreeToFileBuilder( Writer, Builder ); + GrannyEndFileDataTreeWriting( Writer ); std::wstring filenameW = (const wchar_t*)CA2W( filename ); std::wstring fullPath = BePaths->ResolvePathForWritingW( filenameW ); GrannyEndFile( Builder, CW2A( fullPath.c_str() ) ); - CCP_DELETE [] pMaterials; - CCP_DELETE [] grannyMesh.MaterialBindings; - CCP_DELETE [] grannyMesh.BoneBindings; - CCP_DELETE [] fileInfo.Materials; + CCP_DELETE[] pMaterials; + CCP_DELETE[] grannyMesh.MaterialBindings; + CCP_DELETE[] grannyMesh.BoneBindings; + CCP_DELETE[] fileInfo.Materials; return true; } @@ -2822,8 +2800,8 @@ bool TriGeometryRes::SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const c // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2InstanceData interface. Query if the instance data is ready to be -// used, i.e. if the resource is good. +// Implements ITr2InstanceData interface. Query if the instance data is ready to be +// used, i.e. if the resource is good. // Return Value: // true if data is ready to be used // false otherwise @@ -2842,7 +2820,7 @@ ITr2InstanceData::InstanceData TriGeometryRes::GetInstanceData( unsigned int buf static Tr2BufferAL nullVB; return { nullVB }; } - + auto lod = GetMeshLod( bufferIndex, screenSize ); return { lod->m_vertexAllocation.GetBuffer(), lod->m_vertexAllocation.GetOffset(), mesh->m_bytesPerVertex, lod->m_vertexCount @@ -2851,7 +2829,7 @@ ITr2InstanceData::InstanceData TriGeometryRes::GetInstanceData( unsigned int buf // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2InstanceData interface. Returns returns vertex declaration handle +// Implements ITr2InstanceData interface. Returns returns vertex declaration handle // for the given instance buffer index. // Arguments: // bufferIndex - instance buffer index @@ -2917,7 +2895,7 @@ Be::Result TriGeometryRes::GetMeshAreaName( unsigned int meshIx, un //Get the first LOD. auto& lod = mesh->m_lods[0]; - if (areaIx < 0 || areaIx >= lod->m_areas.size()) + if( areaIx < 0 || areaIx >= lod->m_areas.size() ) { return Be::Result( "Area index out of range" ); } @@ -2977,7 +2955,7 @@ Be::Result TriGeometryRes::CalculateBoundingBoxFromTransform( unsig } CalcBoundingBoxContext ctx; - ctx.min = Vector3( FLT_MAX, FLT_MAX, FLT_MAX ); + ctx.min = Vector3( FLT_MAX, FLT_MAX, FLT_MAX ); ctx.max = Vector3( -FLT_MAX, -FLT_MAX, -FLT_MAX ); ctx.transform = transform; @@ -3006,7 +2984,7 @@ BlueStdResult TriGeometryRes::GetMeshVertexElements( size_t meshIndex, std::vect auto& mesh = m_meshes[meshIndex]; Tr2VertexDefinition decl; - if ( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh->m_vertexDeclarationHandle, decl ) ) + if( !Tr2EffectStateManager::GetVertexDeclarationElements( mesh->m_vertexDeclarationHandle, decl ) ) { return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not retrieve vertex declaration" ); } diff --git a/trinity/Resources/TriGeometryRes.h b/trinity/Resources/TriGeometryRes.h index 1f670fcb1..6516a7e56 100644 --- a/trinity/Resources/TriGeometryRes.h +++ b/trinity/Resources/TriGeometryRes.h @@ -130,7 +130,10 @@ struct AudioGeometryResData Vector3 m_minBounds; Vector3 m_maxBounds; - AudioGeometryResData() : m_id( s_nextId++ ) {} + AudioGeometryResData() : + m_id( s_nextId++ ) + { + } private: static std::atomic s_nextId; @@ -176,10 +179,10 @@ struct TriGeometryResLodData struct TriGeometryResMeshData { - TriGeometryResMeshData(); + TriGeometryResMeshData(); std::string m_name; - + unsigned int m_vertexDeclarationHandle; unsigned int m_bytesPerVertex; @@ -215,7 +218,7 @@ struct TriGeometryResSkeletonData TrackableStdVector m_joints; }; -BLUE_CLASS( TriGeometryRes ): +BLUE_CLASS( TriGeometryRes ) : public BlueAsyncRes, public ICacheable, public Tr2DeviceResource, @@ -224,7 +227,7 @@ BLUE_CLASS( TriGeometryRes ): public: EXPOSE_TO_BLUE(); - TriGeometryRes(IRoot* lockobj = NULL); + TriGeometryRes( IRoot* lockobj = NULL ); virtual ~TriGeometryRes(); void RecalculateBoundingBox(); @@ -252,35 +255,35 @@ BLUE_CLASS( TriGeometryRes ): unsigned int GetAnimationCount() const; - #if WITH_GRANNY +#if WITH_GRANNY // query vertex component int GetVertexComponentOffset( const granny_mesh* myMesh, const char* componentName ) const; - #endif +#endif // Render multiple consecutive areas, starting at 'areaIx' bool RenderAreas( unsigned int meshIx, unsigned int areaIx, unsigned int areaCount, Tr2RenderContext& renderContext, bool reversed = false ); bool RenderAreas( float screenSize, unsigned int meshIx, unsigned int areaIx, unsigned int areaCount, Tr2RenderContext& renderContext, bool reversed = false ); void RebuildCachedData(); - - bool GetIntersectionPoints( - const Vector3* pos, - const Vector3* dir, - Vector3* hitpointNear, - Vector3* hitpointNearNormal, - Vector3* hitpointFar, + + bool GetIntersectionPoints( + const Vector3* pos, + const Vector3* dir, + Vector3* hitpointNear, + Vector3* hitpointNearNormal, + Vector3* hitpointFar, Vector3* hitpointFarNormal, int* boneIndexNear, int* boneIndexFar, - unsigned int areaIx=-1 ); + unsigned int areaIx = -1 ); - bool GetIntersectionPointNormalBone( - const Vector3* pos, - const Vector3* dir, - Vector3* hitpoint, + bool GetIntersectionPointNormalBone( + const Vector3* pos, + const Vector3* dir, + Vector3* hitpoint, Vector3* normal, int* boneIndex, - unsigned int areaIx=-1 ); + unsigned int areaIx = -1 ); std::pair>> GetIntersectionPointNormalBoneFromScript( const Vector3& pos, const Vector3& dir ); Be::Result GetAreaIntersectionPointNormalBoneFromScript( const Vector3& pos, const Vector3& dir, int areaIx, std::pair>>& result ); @@ -291,7 +294,7 @@ BLUE_CLASS( TriGeometryRes ): bool GetBoundingSphere( unsigned int meshIx, Vector4& sphere ) const; Be::Result GetBoundingSphereFromScript( unsigned int meshIx, std::pair& bounds ) const; - void PrepareFromGrannyRes( TriGrannyRes* g ); + void PrepareFromGrannyRes( TriGrannyRes * g ); BlueStdResult GetMeshVertexElements( size_t meshIndex, std::vector>& elements ) const; @@ -322,12 +325,13 @@ BLUE_CLASS( TriGeometryRes ): // ITriDeviceResource private: bool OnPrepareResources(); -public: + +public: void ReleaseResources( TriStorage s ); void ReleaseResourcesHelper(); #if TRINITYDEV - virtual void GetDescription( std::string& desc ); + virtual void GetDescription( std::string & desc ); #endif #if WITH_GRANNY @@ -335,12 +339,12 @@ BLUE_CLASS( TriGeometryRes ): #endif #if WITH_GRANNY - static bool SaveMeshToGrannyFile( TriGeometryResMeshData& mesh, const char* filename ); + static bool SaveMeshToGrannyFile( TriGeometryResMeshData & mesh, const char* filename ); #endif - static bool SaveMeshToCMFFile( TriGeometryResMeshData& mesh, const char* filename ); + static bool SaveMeshToCMFFile( TriGeometryResMeshData & mesh, const char* filename ); // Iterator functions for processing mesh data - typedef void( *PerTriangleCallback )( void* context, const Vector3& p1, const Vector3& p2, const Vector3& p3 ); + typedef void ( *PerTriangleCallback )( void* context, const Vector3& p1, const Vector3& p2, const Vector3& p3 ); void ProcessMeshTriangles( int meshIx, PerTriangleCallback cb, void* cbContext ); void RequestReversedIndexBuffers(); @@ -378,21 +382,21 @@ BLUE_CLASS( TriGeometryRes ): // The async management itself is done in TriAsyncLoadedResource. virtual LoadingResult DoLoad(); virtual bool DoPrepare(); - + #if WITH_GRANNY // Read granny file, keep data in m_pGrannyFile bool ReadGrannyFile(); void ClearGrannyData(); - bool SetupMeshes( granny_file_info* gi ); - void SetupSkeletons( granny_file_info* gi ); - void DetermineAreaBoundsAndVertCount( TriGeometryResAreaData& area, granny_mesh* grannyMesh, int bytesPerVertex ); - bool IsAreaSkinned( TriGeometryResAreaData& area, granny_mesh* grannyMesh, granny_file_info* gi, int bytesPerVertex ); - bool IsAreaMorphed( TriGeometryResAreaData& area, granny_mesh* myMesh, granny_file_info* gi ); - + bool SetupMeshes( granny_file_info * gi ); + void SetupSkeletons( granny_file_info * gi ); + void DetermineAreaBoundsAndVertCount( TriGeometryResAreaData & area, granny_mesh * grannyMesh, int bytesPerVertex ); + bool IsAreaSkinned( TriGeometryResAreaData & area, granny_mesh * grannyMesh, granny_file_info * gi, int bytesPerVertex ); + bool IsAreaMorphed( TriGeometryResAreaData & area, granny_mesh * myMesh, granny_file_info * gi ); + // Create D3D mesh from data in m_pGrannyFile - bool CreateMeshesFromGrannyFile( granny_file_info* gi, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext& renderContext ); - bool CreateLodFromGrannyMesh( granny_mesh* myMesh, TriGeometryResLodData* pMesh, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext& renderContext, void* pVBOverride = NULL ); + bool CreateMeshesFromGrannyFile( granny_file_info * gi, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext & renderContext ); + bool CreateLodFromGrannyMesh( granny_mesh * myMesh, TriGeometryResLodData * pMesh, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext & renderContext, void* pVBOverride = NULL ); // Extract audio geometry from lowest LOD for Wwise spatial audio void ExtractAudioGeometry( TriGeometryResMeshData * mesh, granny_mesh * grannyMesh ); @@ -403,10 +407,10 @@ BLUE_CLASS( TriGeometryRes ): bool SetupMeshes( const cmf::Data& cmfData ); void SetupSkeletons( const cmf::Data& cmfData ); - bool CreateMeshesFromCMFFile( Tr2CmfContents& cmfContents, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext& renderContext ); - bool CreateLodFromCMFMesh( Tr2CmfContents& cmfContents, const cmf::Mesh& cmfMesh, const cmf::MeshLod& cmfMeshLod, TriGeometryResLodData* pMesh, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext& renderContext ); + bool CreateMeshesFromCMFFile( Tr2CmfContents & cmfContents, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext & renderContext ); + bool CreateLodFromCMFMesh( Tr2CmfContents & cmfContents, const cmf::Mesh& cmfMesh, const cmf::MeshLod& cmfMeshLod, TriGeometryResLodData* pMesh, Tr2CpuUsage::Type cpuUsage, Tr2PrimaryRenderContext& renderContext ); }; -TYPEDEF_BLUECLASS_WR_SHUTDOWN(TriGeometryRes); +TYPEDEF_BLUECLASS_WR_SHUTDOWN( TriGeometryRes ); #endif diff --git a/trinity/Resources/TriGeometryRes_Blue.cpp b/trinity/Resources/TriGeometryRes_Blue.cpp index 862533fd0..132692aca 100644 --- a/trinity/Resources/TriGeometryRes_Blue.cpp +++ b/trinity/Resources/TriGeometryRes_Blue.cpp @@ -23,165 +23,135 @@ BLUE_REGISTER_RESOURCE_EXTENSION( L"cmf", CreateStaticGeometryResource ); const Be::ClassInfo* TriGeometryRes::ExposeToBlue() { - EXPOSURE_BEGIN( TriGeometryRes, "" ) - MAP_INTERFACE( TriGeometryRes ) + EXPOSURE_BEGIN( TriGeometryRes, "" ) + MAP_INTERFACE( TriGeometryRes ) MAP_INTERFACE( IBlueResource ) MAP_INTERFACE( ICacheable ) MAP_INTERFACE( ITr2InstanceData ) MAP_ICACHEABLE_METHODS() - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "meshCount", GetMeshCount, - "Gets the count of meshes in this geometry resource" - ) - MAP_PROPERTY_READONLY - ( + "Gets the count of meshes in this geometry resource" ) + MAP_PROPERTY_READONLY( "animationCount", GetAnimationCount, - "Gets the count of animations in this geometry resource" - ) + "Gets the count of animations in this geometry resource" ) MAP_ATTRIBUTE( "name", m_name, "Name for debugging/logging", Be::READWRITE ) MAP_ATTRIBUTE( "forceLod", m_forceLod, "Force geometry to use a specific LOD\n:jessica-group: Debug", Be::READWRITE ) MAP_ATTRIBUTE( "forcedLodIndex", m_forcedLodIndex, "LOD index to use when forceLod is on\n:jessica-group: Debug", Be::READWRITE ) - MAP_METHOD_AND_WRAP - ( - "GetMeshCount", - GetMeshCount, - "Gets the count of meshes" - ) - - MAP_METHOD_AND_WRAP - ( - "GetMeshName", - GetMeshName, + MAP_METHOD_AND_WRAP( + "GetMeshCount", + GetMeshCount, + "Gets the count of meshes" ) + + MAP_METHOD_AND_WRAP( + "GetMeshName", + GetMeshName, "Gets the name of the indexed mesh\n" - ":param idx: mesh index" - ) + ":param idx: mesh index" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetMeshAreaCount", - GetMeshAreaCount, + GetMeshAreaCount, "Gets the count of areas within the indexed mesh\n" - ":param idx: mesh index" - ) + ":param idx: mesh index" ) - MAP_METHOD_AND_WRAP - ( - "GetMeshAreaName", - GetMeshAreaName, + MAP_METHOD_AND_WRAP( + "GetMeshAreaName", + GetMeshAreaName, "Gets the name of the indexed area within the indexed mesh\n" ":param meshIdx: mesh index\n" - ":param areaIdx: area index\n" - ) + ":param areaIdx: area index\n" ) - MAP_METHOD_AND_WRAP - ( - "GetAreaBoundingBox", - GetAreaBoundingBoxFromScript, + MAP_METHOD_AND_WRAP( + "GetAreaBoundingBox", + GetAreaBoundingBoxFromScript, "Get the bounding box of the specified area within the mesh\n" ":param meshIdx: mesh index\n" - ":param areaIdx: area index\n" - ) + ":param areaIdx: area index\n" ) - MAP_METHOD_AND_WRAP - ( - "GetBoundingBox", - GetBoundingBoxFromScript, + MAP_METHOD_AND_WRAP( + "GetBoundingBox", + GetBoundingBoxFromScript, "Get the bounding box of the specified mesh\n" - ":param meshIdx: mesh index\n" - ) + ":param meshIdx: mesh index\n" ) MAP_METHOD_AND_WRAP( - "GetBoundingSphere", + "GetBoundingSphere", GetBoundingSphereFromScript, "Get the bounding sphere of the specified area\n" - ":param meshIdx: mesh index\n" - ) - MAP_METHOD_AND_WRAP - ( - "CalculateBoundingBoxFromTransform", - CalculateBoundingBoxFromTransform, + ":param meshIdx: mesh index\n" ) + MAP_METHOD_AND_WRAP( + "CalculateBoundingBoxFromTransform", + CalculateBoundingBoxFromTransform, "Get the mesh's bounding box with all points transformed using transform.\n" ":param meshIdx: mesh index\n" - ":param transform: transform matrix\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param transform: transform matrix\n" ) + MAP_METHOD_AND_WRAP( "RecalculateBoundingSphere", RecalculateBoundingSphere, - "Rebuild bounding sphere info for these meshes" - ) - - MAP_METHOD_AND_WRAP - ( - "Reload", - Reload, - "Forces a reload from disk" - ) - - MAP_METHOD_AND_WRAP - ( - "GetIntersectionPointNormalBone", + "Rebuild bounding sphere info for these meshes" ) + + MAP_METHOD_AND_WRAP( + "Reload", + Reload, + "Forces a reload from disk" ) + + MAP_METHOD_AND_WRAP( + "GetIntersectionPointNormalBone", GetIntersectionPointNormalBoneFromScript, "( pos, dir ) ->( near, far )\nGet the near intersection points and the normal between a ray and the geometry.\n" ":param pos: ray origin\n" - ":param direction: ray direction\n" - ) + ":param direction: ray direction\n" ) - MAP_METHOD_AND_WRAP - ( - "GetAreaIntersectionPointNormalBone", + MAP_METHOD_AND_WRAP( + "GetAreaIntersectionPointNormalBone", GetAreaIntersectionPointNormalBoneFromScript, "( pos, dir ) ->( near, far )\nGet the near intersection points and the normal between a ray and the geometry.\n" ":param pos: ray origin\n" ":param direction: ray direction\n" - ":param areaIx: the mesh area index\n" - ) + ":param areaIx: the mesh area index\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetMeshVertexElements", GetMeshVertexElements, "Returns a list of (usage, usage index) tuples for vertex layout of the specified mesh.\n" - ":param idx: mesh index" - ) + ":param idx: mesh index" ) MAP_METHOD_AND_WRAP( "SaveMesh", SaveMesh, "Save mesh data to a granny file\n" ":param path: desctination file path\n" - ":param mesh: index of the mesh to save" - ) - EXPOSURE_CHAINTO( BlueAsyncRes ) + ":param mesh: index of the mesh to save" ) + EXPOSURE_CHAINTO( BlueAsyncRes ) } namespace { - std::pair BoundingSphereFromPointsScript( const std::vector& points ) +std::pair BoundingSphereFromPointsScript( const std::vector& points ) +{ + Vector4 sphere( 0, 0, 0, 0 ); + if( points.empty() ) { - Vector4 sphere( 0, 0, 0, 0 ); - if( points.empty() ) - { - ::BoundingSphereFromPoints( sphere, nullptr, 0 ); - } - else + ::BoundingSphereFromPoints( sphere, nullptr, 0 ); + } + else + { + std::vector pointers; + pointers.reserve( points.size() ); + for( const auto& p : points ) { - std::vector pointers; - pointers.reserve( points.size() ); - for( const auto& p : points ) - { - pointers.push_back( &p ); - } - ::BoundingSphereFromPoints( sphere, &pointers[0], points.size() ); + pointers.push_back( &p ); } - return std::make_pair( Vector3( sphere.x, sphere.y, sphere.z ), sphere.w ); + ::BoundingSphereFromPoints( sphere, &pointers[0], points.size() ); } + return std::make_pair( Vector3( sphere.x, sphere.y, sphere.z ), sphere.w ); +} } MAP_FUNCTION_AND_WRAP( diff --git a/trinity/Resources/TriGrannyRes.cpp b/trinity/Resources/TriGrannyRes.cpp index ea634363b..c666ef5d1 100644 --- a/trinity/Resources/TriGrannyRes.cpp +++ b/trinity/Resources/TriGrannyRes.cpp @@ -22,8 +22,7 @@ CmfVertexReader::CmfVertexReader( cmf::Span decl ) pkdLegElem = cmf::FindElement( decl, cmf::Usage::PackedTangentLegacy ); } -void ReadCmfVertexAttributes( const CmfVertexReader& reader, const uint8_t* data, uint32_t vertexCount, uint32_t stride, - std::vector& positions, std::vector& normals, std::vector* tangents, std::vector* binormals ) +void ReadCmfVertexAttributes( const CmfVertexReader& reader, const uint8_t* data, uint32_t vertexCount, uint32_t stride, std::vector& positions, std::vector& normals, std::vector* tangents, std::vector* binormals ) { std::optional> posStream; std::optional> normStream; @@ -128,8 +127,8 @@ Tr2GrannyIntersectionResult::Tr2GrannyIntersectionResult( IRoot* ) { } -Tr2GrannyIntersectionResult::Result::Result() - :position( 0, 0, 0 ), +Tr2GrannyIntersectionResult::Result::Result() : + position( 0, 0, 0 ), normal( 0, 0, 0 ), uv( 0, 0 ), meshIndex( -1 ), @@ -158,10 +157,10 @@ TriGrannyRes::TriGrannyRes( IRoot* lockobj ) : TriGrannyRes::~TriGrannyRes() { #if WITH_GRANNY - if( m_grannyFile ) - { - GrannyFreeFile( m_grannyFile ); - } + if( m_grannyFile ) + { + GrannyFreeFile( m_grannyFile ); + } if( m_grannyArena ) { @@ -271,7 +270,7 @@ BlueAsyncRes::LoadingResult TriGrannyRes::DoLoad() bool TriGrannyRes::DoPrepare() { - return true; + return true; } #if WITH_GRANNY @@ -310,7 +309,7 @@ granny_data_type_definition* TriGrannyRes::GetGrannyVertexType( int meshIx ) con CCP_LOGERR( "TriGrannyRes::GetGrannyVertexType: Invalid mesh index" ); return NULL; } - + return mesh->PrimaryVertexData->VertexType; } #endif @@ -383,7 +382,7 @@ granny_skeleton* TriGrannyRes::GetGrannySkeleton( int skeletonIx ) const int TriGrannyRes::GetVertexComponentOffset( int meshIx, const char* componentName ) const { CCP_ASSERT_M( !m_useCMF, "This should never be called on a cmf codepath!" ); - + const granny_mesh* mesh = GetGrannyMesh( meshIx ); if( !mesh ) { @@ -429,7 +428,7 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector { CCP_ASSERT_M( !nameToWeight, "TriGrannyRes::BakeBlendshape: intern messed up and thought nameToWeight was not being used anymore." ); CCP_ASSERT_M( !deltaOnly, "TriGrannyRes::BakeBlendshape: intern messed up and thought deltaOnly was not being used anymore." ); - + if( meshIx >= m_cmfContents.GetData()->meshes.size() ) { CCP_LOGERR( "TriGrannyRes::BakeBlendshape: Invalid mesh index" ); @@ -562,7 +561,7 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector pVertexData.Update( result.data(), renderContext ); } - + return true; } #if WITH_GRANNY @@ -633,13 +632,13 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector { blendVertexFormat = mesh->MorphTargets[0].VertexData->VertexType; } - + // Copy base data from original vertex buffer. Deltas will be applied on top of this (if any are found) void* pSrc = GrannyGetMeshVertices( mesh ); if( !blendVertexFormat ) { - pVertexData.Update( pSrc, renderContext); + pVertexData.Update( pSrc, renderContext ); CCP_LOG( "BakeBlendshape called on %S but it has no blendshapes", GetPath() ); return true; } @@ -653,7 +652,10 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector struct DatatypeInfo { - DatatypeInfo() : offset( 0xffffffff ), isHalfPrecision( false ) {} + DatatypeInfo() : + offset( 0xffffffff ), isHalfPrecision( false ) + { + } unsigned int offset; bool isHalfPrecision; @@ -661,7 +663,9 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector enum DatatypesOfInterest { - DOI_POS, DOI_NORMAL, DOI_COUNT + DOI_POS, + DOI_NORMAL, + DOI_COUNT }; DatatypeInfo typeInfos[DOI_COUNT]; @@ -720,7 +724,7 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector for( unsigned int j = 0; j < numBlends; ++j ) { float weight_ = 0.0f; - + if( !nameToWeight ) { weight_ = weights[j]; @@ -732,18 +736,18 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector { continue; } - int scan = (int)name.size()-1; + int scan = (int)name.size() - 1; while( scan > 0 && isdigit( name[scan] ) ) { --scan; } - name.erase( scan+1, name.size()-scan-1 ); + name.erase( scan + 1, name.size() - scan - 1 ); std::transform( name.begin(), name.end(), name.begin(), tolower ); NameToWeightMap::const_iterator it = nameToWeight->find( name ); if( it != nameToWeight->end() ) { weight_ = it->second; - } + } } @@ -765,13 +769,13 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector const uint8_t* const pMorphVerts = mesh->PrimaryVertexData->VertexAnnotationSets[j].VertexAnnotations; const granny_int32* const blendIndices = mesh->PrimaryVertexData->VertexAnnotationSets[j].VertexAnnotationIndices; - + if( deltaOnly ) { - const uint8_t* __restrict pDelta = pMorphVerts + blendTypeInfos[ DOI_POS ].offset; - const int * __restrict vertexIx = blendIndices; + const uint8_t* __restrict pDelta = pMorphVerts + blendTypeInfos[DOI_POS].offset; + const int* __restrict vertexIx = blendIndices; - if( blendTypeInfos[ DOI_POS ].isHalfPrecision ) + if( blendTypeInfos[DOI_POS].isHalfPrecision ) { for( int i = 0; i < blendIndexCount; ++i, ++vertexIx, pDelta += blendBytesPerVertex ) { @@ -805,15 +809,15 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector } const uint8_t* __restrict pDelta = pMorphVerts + blendTypeInfos[componentIx].offset; - const int * __restrict vertexIx = blendIndices; + const int* __restrict vertexIx = blendIndices; uint8_t* const __restrict pComponentBase = reinterpret_cast( &localVertexData[0] ) + typeInfos[componentIx].offset; - if( typeInfos[ componentIx ].isHalfPrecision && blendTypeInfos[ componentIx ].isHalfPrecision ) + if( typeInfos[componentIx].isHalfPrecision && blendTypeInfos[componentIx].isHalfPrecision ) { for( int i = 0; i < blendIndexCount; ++i, ++vertexIx, pDelta += blendBytesPerVertex ) { - uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; + uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; Vector3 base = *reinterpret_cast( pBase ); Vector3 delta = *reinterpret_cast( pDelta ); @@ -823,27 +827,25 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector *reinterpret_cast( pBase ) = Vector3_16( base ); } } - else - if( typeInfos[ componentIx ].isHalfPrecision ) + else if( typeInfos[componentIx].isHalfPrecision ) { for( int i = 0; i < blendIndexCount; ++i, ++vertexIx, pDelta += blendBytesPerVertex ) { - uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; + uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; Vector3 base = *reinterpret_cast( pBase ); - const Vector3 &delta = *reinterpret_cast( pDelta ); - + const Vector3& delta = *reinterpret_cast( pDelta ); + base += weight * delta; *reinterpret_cast( pBase ) = Vector3_16( base ); } } - else - if( blendTypeInfos[ componentIx ].isHalfPrecision ) + else if( blendTypeInfos[componentIx].isHalfPrecision ) { for( int i = 0; i < blendIndexCount; ++i, ++vertexIx, pDelta += blendBytesPerVertex ) { - uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; + uint8_t* const __restrict pBase = pComponentBase + *vertexIx * bytesPerVertex; Vector3& base = *reinterpret_cast( pBase ); @@ -884,9 +886,9 @@ bool TriGrannyRes::BakeBlendshape( unsigned int meshIx, const std::vector for( int i = 0; i < vertexCount; ++i ) { - uint8_t* pDelta = pMV + blendTypeInfos[ DOI_POS ].offset; + uint8_t* pDelta = pMV + blendTypeInfos[DOI_POS].offset; - if( blendTypeInfos[ DOI_POS ].isHalfPrecision ) + if( blendTypeInfos[DOI_POS].isHalfPrecision ) { Vector3 delta = *reinterpret_cast( pDelta ); @@ -1054,7 +1056,7 @@ Be::Result TriGrannyRes::GetMeshAreaCount( unsigned int meshIx, int } } #endif - + return Be::Result(); } @@ -1087,7 +1089,7 @@ Be::Result TriGrannyRes::GetMeshName( unsigned int meshIx, std::str name = fi->Meshes[meshIx]->Name ? fi->Meshes[meshIx]->Name : ""; // for reference, see CopyGrannyName } #endif - + return Be::Result(); } @@ -1251,7 +1253,7 @@ Be::Result TriGrannyRes::GetMeshMorphCount( unsigned int meshIx, in } } #endif - + return Be::Result(); } @@ -1310,7 +1312,7 @@ Be::Result TriGrannyRes::GetMeshMorphName( unsigned int meshIx, uns } } #endif - + return Be::Result(); } @@ -1499,7 +1501,7 @@ std::string TriGrannyRes::GetEventTrackName( int groupIdx, int trackIdx ) } } -int TriGrannyRes::GetTrackGroupCount( ) +int TriGrannyRes::GetTrackGroupCount() { if( IsUsingCMF() ) { @@ -1651,7 +1653,7 @@ granny_file_info* TriGrannyRes::ValidateAnimationIx( int ix ) return 0; } - if( (ix < 0) || (ix >= fi->AnimationCount) ) + if( ( ix < 0 ) || ( ix >= fi->AnimationCount ) ) { CCP_LOGERR( "Animation index out of bounds" ); return NULL; @@ -1792,7 +1794,7 @@ Be::Result TriGrannyRes::BakeBlendshapeFromScript( unsigned int mes bool success = BakeBlendshape( meshIx, weights, lod->m_vertexAllocation, renderContext, lod->m_vertexCount * lod->m_mesh->m_bytesPerVertex ); - return success ? Be::Result() : Be::Result( " TriGrannyRes::BakeBlendshape encountered problems. "); + return success ? Be::Result() : Be::Result( " TriGrannyRes::BakeBlendshape encountered problems. " ); } bool TriGrannyRes::IsUsingCMF() const @@ -2232,7 +2234,7 @@ Tr2GrannyIntersectionResultPtr TriGrannyRes::RayIntersection( const Vector3& pos for( uint32_t areaIdx = 0; areaIdx < areaCount; areaIdx++ ) { auto area = mesh.lods[0].areas[areaIdx + areaOffset]; - + for( uint32_t elementIdx = area.firstElement; elementIdx < area.firstElement + area.elementCount; elementIdx++ ) { uint32_t triangleIndices[3]; diff --git a/trinity/Resources/TriGrannyRes.h b/trinity/Resources/TriGrannyRes.h index 09b4e95a9..70e924be2 100644 --- a/trinity/Resources/TriGrannyRes.h +++ b/trinity/Resources/TriGrannyRes.h @@ -22,7 +22,8 @@ struct CmfVertexReader void ReadCmfVertexAttributes( const CmfVertexReader& reader, const uint8_t* data, uint32_t vertexCount, uint32_t stride, std::vector& positions, std::vector& normals, std::vector* tangents, std::vector* binormals ); -BLUE_CLASS( Tr2GrannyIntersectionResult ): public IRoot +BLUE_CLASS( Tr2GrannyIntersectionResult ) : + public IRoot { public: Tr2GrannyIntersectionResult( IRoot* lockobj = nullptr ); @@ -56,25 +57,28 @@ BLUE_DECLARE( TriGrannyRes ); // TriGrannyRes is used to load Granny files 'raw' - i.e. they are loaded without creating // any D3D resources. This is used, for example, when final geometry is constructed from // blendshapes. -BLUE_CLASS( TriGrannyRes ): +BLUE_CLASS( TriGrannyRes ) : public BlueAsyncRes, public ICacheable { public: EXPOSE_TO_BLUE(); - TriGrannyRes( IRoot* lockobj = NULL ); - ~TriGrannyRes(); + TriGrannyRes( IRoot* lockobj = NULL ); + ~TriGrannyRes(); ////////////////////////////////////////////////////////////////////////// // ICacheable bool IsMemoryUsageKnown(); size_t GetMemoryUsage(); - bool Load( const std::string& path ); + bool Load( const std::string& path ); #if WITH_GRANNY - granny_file* GetGrannyFile() const { return m_grannyFile; } + granny_file* GetGrannyFile() const + { + return m_grannyFile; + } granny_skeleton* GetGrannySkeleton( int skeletonIx ) const; const granny_mesh* GetGrannyMesh( int meshIx ) const; @@ -128,7 +132,7 @@ BLUE_CLASS( TriGrannyRes ): Tr2GrannyIntersectionResultPtr RayIntersection( const Vector3& pos, const Vector3& dir, int32_t meshIndex, int32_t areaIndex ); - Be::Result CreateGeometryRes( TriGeometryRes** result ); + Be::Result CreateGeometryRes( TriGeometryRes * *result ); Be::Result BakeBlendshapeFromScript( unsigned int meshIx, const std::vector& weights, TriGeometryRes* geom ); bool IsUsingCMF() const; @@ -146,9 +150,9 @@ BLUE_CLASS( TriGrannyRes ): Be::Result ValidateMeshIndex( unsigned int meshIx ); // Provide the functions that do the actual work of loading and preparing. - // The async management itself is done in TriAsyncLoadedResource. - virtual LoadingResult DoLoad(); - virtual bool DoPrepare(); + // The async management itself is done in TriAsyncLoadedResource. + virtual LoadingResult DoLoad(); + virtual bool DoPrepare(); bool BakeBlendshape( unsigned int meshIx, const std::vector& weights, Tr2SuballocatedBuffer::Allocation& pVertexData, Tr2RenderContextAL& renderContext, unsigned int vertexDataSize, const NameToWeightMap* nameToWeight, bool deltaOnly ); @@ -157,8 +161,8 @@ BLUE_CLASS( TriGrannyRes ): #if WITH_GRANNY size_t m_dataSize; void* m_data; - granny_file* m_grannyFile; - granny_memory_arena *m_grannyArena; + granny_file* m_grannyFile; + granny_memory_arena* m_grannyArena; #endif Tr2CmfContents m_cmfContents; bool m_useCMF; diff --git a/trinity/Resources/TriGrannyRes_Blue.cpp b/trinity/Resources/TriGrannyRes_Blue.cpp index d4d9bd811..5c743f672 100644 --- a/trinity/Resources/TriGrannyRes_Blue.cpp +++ b/trinity/Resources/TriGrannyRes_Blue.cpp @@ -8,199 +8,169 @@ BLUE_DEFINE( Tr2GrannyIntersectionResult ); -const Be::ClassInfo* Tr2GrannyIntersectionResult::ExposeToBlue() -{ +const Be::ClassInfo* Tr2GrannyIntersectionResult::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2GrannyIntersectionResult, "" ) MAP_ATTRIBUTE( "position", m_result.position, "", Be::READWRITE ) - MAP_ATTRIBUTE( "hasPosition", m_result.hasPosition, "", Be::READWRITE ) - MAP_ATTRIBUTE( "normal", m_result.normal, "", Be::READWRITE ) - MAP_ATTRIBUTE( "hasNormal", m_result.hasNormal, "", Be::READWRITE ) - MAP_ATTRIBUTE( "uv", m_result.uv, "", Be::READWRITE ) - MAP_ATTRIBUTE( "hasUv", m_result.hasUv, "", Be::READWRITE ) - MAP_ATTRIBUTE( "boneIndex", m_result.boneIndex, "", Be::READWRITE ) - MAP_ATTRIBUTE( "hasBoneIndex", m_result.hasBoneIndex, "", Be::READWRITE ) - MAP_ATTRIBUTE( "meshIndex", m_result.meshIndex, "", Be::READWRITE ) - MAP_ATTRIBUTE( "areaIndex", m_result.areaIndex, "", Be::READWRITE ) - EXPOSURE_END() + MAP_ATTRIBUTE( "hasPosition", m_result.hasPosition, "", Be::READWRITE ) + MAP_ATTRIBUTE( "normal", m_result.normal, "", Be::READWRITE ) + MAP_ATTRIBUTE( "hasNormal", m_result.hasNormal, "", Be::READWRITE ) + MAP_ATTRIBUTE( "uv", m_result.uv, "", Be::READWRITE ) + MAP_ATTRIBUTE( "hasUv", m_result.hasUv, "", Be::READWRITE ) + MAP_ATTRIBUTE( "boneIndex", m_result.boneIndex, "", Be::READWRITE ) + MAP_ATTRIBUTE( "hasBoneIndex", m_result.hasBoneIndex, "", Be::READWRITE ) + MAP_ATTRIBUTE( "meshIndex", m_result.meshIndex, "", Be::READWRITE ) + MAP_ATTRIBUTE( "areaIndex", m_result.areaIndex, "", Be::READWRITE ) + EXPOSURE_END() } BLUE_DEFINE( TriGrannyRes ); -const Be::ClassInfo* TriGrannyRes::ExposeToBlue() -{ - EXPOSURE_BEGIN( TriGrannyRes, "" ) - MAP_INTERFACE( TriGrannyRes ) - MAP_INTERFACE( IBlueResource ) - MAP_INTERFACE( ICacheable ) - MAP_ICACHEABLE_METHODS() +const Be::ClassInfo* TriGrannyRes::ExposeToBlue(){ + EXPOSURE_BEGIN( TriGrannyRes, "" ) + MAP_INTERFACE( TriGrannyRes ) + MAP_INTERFACE( IBlueResource ) + MAP_INTERFACE( ICacheable ) + MAP_ICACHEABLE_METHODS() - MAP_METHOD_AND_WRAP - ( - "CreateGeometryRes", - CreateGeometryRes, - "y = x.CreateGeometryRes()\n" - "Create a TriGeometryRes from this resource. Useful for baking blendshapes, for example." - ) + MAP_METHOD_AND_WRAP( + "CreateGeometryRes", + CreateGeometryRes, + "y = x.CreateGeometryRes()\n" + "Create a TriGeometryRes from this resource. Useful for baking blendshapes, for example." ) - MAP_METHOD_AND_WRAP - ( - "BakeBlendshape", - BakeBlendshapeFromScript, - "x.BakeBlendshape( mesh, weights, geom )\n" - "Bake a blendshape with the given weights, using the resulting vertex buffer to replace the vertex buffer of the given TriGeometryRes.\n" - ":param mesh: index of the mesh.\n" - ":param weights: a list with weights as floating point numbers.\n" - ":param geom: a TriGeometryRes object that receives the resulting vertex buffer. Note that it should have been created with a call to x.CreateGeometryRes().\n" - ) - MAP_PROPERTY_READONLY - ( - "modelCount", GetModelCount, - "Gets the count of models in the Granny file" - ) - MAP_METHOD_AND_WRAP - ( - "GetModelName", GetModelName, - "s = x.GetModelName( ix )\n" - "Gets the name of the model with index 'ix'\n" - ":param ix: index of the model\n" - ) - MAP_PROPERTY_READONLY - ( - "meshCount", GetMeshCount, - "Gets the count of meshes in this Granny file." - ) - MAP_METHOD_AND_WRAP - ( - "GetMeshCount", GetMeshCount, - "Gets the count of meshes in this Granny file." - ) - MAP_METHOD_AND_WRAP - ( - "GetMeshAreaCount", GetMeshAreaCount, - "Gets the count of areas within a specified meshID in this Granny file.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP - ( - "GetMeshName", GetMeshName, - "Gets the name of the mesh with the given index.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP( - "GetMeshBoneBindings", - GetMeshBoneBindings, - "Gets the bone bindings of the mesh with the given index.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP( - "GetMeshVertexElements", - GetMeshVertexElements, - "Gets the vertex declaration elements (list of (usage, usageIndex) tuples) of the mesh with the given index.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP( - "GetMeshTriangleCount", - GetMeshTriangleCount, - "Gets the triangle count of the mesh with the given index.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP - ( - "GetMeshMorphCount", GetMeshMorphCount, - "Gets the count of morph targets available for the given mesh.\n" - ":param meshIdx: mesh index" - ) - MAP_METHOD_AND_WRAP - ( - "GetMeshMorphName", GetMeshMorphName, - "Gets the name of given morph target index for the given mesh.\n" - ":param meshIdx: mesh index\n" - ":param morphIdx: morph index" - ) - MAP_METHOD_AND_WRAP - ( - "GetAllMeshMorphNamesNoDigits", - GetAllMeshMorphNamesNoDigits, - "Returns a list containing the names of all the morph targets,\n" - "all converted to lowercase and stripped of any digits. Specialized\n" - "method to get answers in a format that python wants in a single call.\n" - ":param meshIdx: mesh index\n" - ) - MAP_PROPERTY_READONLY - ( - "animationCount", GetAnimationCount, - "Gets the count of animation in the Granny file" - ) - MAP_METHOD_AND_WRAP - ( - "GetAnimationName", GetAnimationName, - "Gets the name of the animation with index 'ix'\n" - ":param ix: index of the animation\n" - ) - MAP_METHOD_AND_WRAP - ( - "GetAnimationDuration", GetAnimationDuration, - "Gets the duration of the animation with index 'ix'\n" - ":param ix: index of the animation\n" - ) + MAP_METHOD_AND_WRAP( + "BakeBlendshape", + BakeBlendshapeFromScript, + "x.BakeBlendshape( mesh, weights, geom )\n" + "Bake a blendshape with the given weights, using the resulting vertex buffer to replace the vertex buffer of the given TriGeometryRes.\n" + ":param mesh: index of the mesh.\n" + ":param weights: a list with weights as floating point numbers.\n" + ":param geom: a TriGeometryRes object that receives the resulting vertex buffer. Note that it should have been created with a call to x.CreateGeometryRes().\n" ) + MAP_PROPERTY_READONLY( + "modelCount", + GetModelCount, + "Gets the count of models in the Granny file" ) + MAP_METHOD_AND_WRAP( + "GetModelName", + GetModelName, + "s = x.GetModelName( ix )\n" + "Gets the name of the model with index 'ix'\n" + ":param ix: index of the model\n" ) + MAP_PROPERTY_READONLY( + "meshCount", + GetMeshCount, + "Gets the count of meshes in this Granny file." ) + MAP_METHOD_AND_WRAP( + "GetMeshCount", + GetMeshCount, + "Gets the count of meshes in this Granny file." ) + MAP_METHOD_AND_WRAP( + "GetMeshAreaCount", + GetMeshAreaCount, + "Gets the count of areas within a specified meshID in this Granny file.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshName", + GetMeshName, + "Gets the name of the mesh with the given index.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshBoneBindings", + GetMeshBoneBindings, + "Gets the bone bindings of the mesh with the given index.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshVertexElements", + GetMeshVertexElements, + "Gets the vertex declaration elements (list of (usage, usageIndex) tuples) of the mesh with the given index.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshTriangleCount", + GetMeshTriangleCount, + "Gets the triangle count of the mesh with the given index.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshMorphCount", + GetMeshMorphCount, + "Gets the count of morph targets available for the given mesh.\n" + ":param meshIdx: mesh index" ) + MAP_METHOD_AND_WRAP( + "GetMeshMorphName", + GetMeshMorphName, + "Gets the name of given morph target index for the given mesh.\n" + ":param meshIdx: mesh index\n" + ":param morphIdx: morph index" ) + MAP_METHOD_AND_WRAP( + "GetAllMeshMorphNamesNoDigits", + GetAllMeshMorphNamesNoDigits, + "Returns a list containing the names of all the morph targets,\n" + "all converted to lowercase and stripped of any digits. Specialized\n" + "method to get answers in a format that python wants in a single call.\n" + ":param meshIdx: mesh index\n" ) + MAP_PROPERTY_READONLY( + "animationCount", + GetAnimationCount, + "Gets the count of animation in the Granny file" ) + MAP_METHOD_AND_WRAP( + "GetAnimationName", + GetAnimationName, + "Gets the name of the animation with index 'ix'\n" + ":param ix: index of the animation\n" ) + MAP_METHOD_AND_WRAP( + "GetAnimationDuration", + GetAnimationDuration, + "Gets the duration of the animation with index 'ix'\n" + ":param ix: index of the animation\n" ) #if WITH_GRANNY - MAP_METHOD_AND_WRAP( "GetTrackGroupCount", GetTrackGroupCount, "Get the number of track groups" ) - MAP_METHOD_AND_WRAP( - "GetTrackGroupName", - GetTrackGroupName, - "Get the name of the track group at index\n" - ":param groupIdx: track group index" - ) - MAP_METHOD_AND_WRAP( - "GetVectorTrackCount", - GetVectorTrackCount, - "Get the number of transform tracks under a track group\n" - ":param groupIdx: track group index\n" - ) - MAP_METHOD_AND_WRAP( - "GetVectorTrackName", - GetVectorTrackName, - "Get the name of the transform track\n" - ":param groupIdx: track group index\n" - ":param trackIdx: track index\n" - ) - MAP_METHOD_AND_WRAP( - "GetEventTrackCount", - GetEventTrackCount, - "Get the number of event (text) tracks under a track group\n" - ":param groupIdx: track group index\n" - ) - MAP_METHOD_AND_WRAP( - "GetEventTrackName", - GetEventTrackName, - "Get the name of the event (text) track\n" - ":param groupIdx: track group index\n" - ":param trackIdx: track index\n" - ) + MAP_METHOD_AND_WRAP( "GetTrackGroupCount", GetTrackGroupCount, "Get the number of track groups" ) + MAP_METHOD_AND_WRAP( + "GetTrackGroupName", + GetTrackGroupName, + "Get the name of the track group at index\n" + ":param groupIdx: track group index" ) + MAP_METHOD_AND_WRAP( + "GetVectorTrackCount", + GetVectorTrackCount, + "Get the number of transform tracks under a track group\n" + ":param groupIdx: track group index\n" ) + MAP_METHOD_AND_WRAP( + "GetVectorTrackName", + GetVectorTrackName, + "Get the name of the transform track\n" + ":param groupIdx: track group index\n" + ":param trackIdx: track index\n" ) + MAP_METHOD_AND_WRAP( + "GetEventTrackCount", + GetEventTrackCount, + "Get the number of event (text) tracks under a track group\n" + ":param groupIdx: track group index\n" ) + MAP_METHOD_AND_WRAP( + "GetEventTrackName", + GetEventTrackName, + "Get the name of the event (text) track\n" + ":param groupIdx: track group index\n" + ":param trackIdx: track index\n" ) #endif - MAP_METHOD_AND_WRAP - ( - "RayIntersection", - RayIntersection, - "Returns ray intersection" - ":param position: ray position\n" - ":param direction: ray direction\n" - ":param meshIndex: mesh index, intersect with all meshes if <0\n" - ":param areaIndex: area index, intersect with all areas if <0\n" - ) + MAP_METHOD_AND_WRAP( + "RayIntersection", + RayIntersection, + "Returns ray intersection" + ":param position: ray position\n" + ":param direction: ray direction\n" + ":param meshIndex: mesh index, intersect with all meshes if <0\n" + ":param areaIndex: area index, intersect with all areas if <0\n" ) - MAP_METHOD_AND_WRAP( - "LoadForTools", - Load, - "Loads geometry resource immediately blocking the thread/tasklet. Shoud only be used by tools, never in the client.\n\n" - ":param path: path to the resource to load\n" - ":return: true if loading succeeded, false otherwise\n" - ) + MAP_METHOD_AND_WRAP( + "LoadForTools", + Load, + "Loads geometry resource immediately blocking the thread/tasklet. Shoud only be used by tools, never in the client.\n\n" + ":param path: path to the resource to load\n" + ":return: true if loading succeeded, false otherwise\n" ) - EXPOSURE_CHAINTO( BlueAsyncRes ) + EXPOSURE_CHAINTO( BlueAsyncRes ) } #if WITH_GRANNY @@ -212,6 +182,5 @@ MAP_FUNCTION_AND_WRAP( ":param position: ray position\n" ":param direction: ray direction\n" ":param meshIndex: mesh index, intersect with all meshes if <0\n" - ":param areaIndex: area index, intersect with all areas if <0\n" -); + ":param areaIndex: area index, intersect with all areas if <0\n" ); #endif diff --git a/trinity/Resources/TriTextureRes.cpp b/trinity/Resources/TriTextureRes.cpp index 43b9f592f..474d0da36 100644 --- a/trinity/Resources/TriTextureRes.cpp +++ b/trinity/Resources/TriTextureRes.cpp @@ -33,7 +33,8 @@ static uint32_t s_diskLatencySimulation = 0; TRI_REGISTER_SETTING( "textureLodSimulateDiskLatency", s_diskLatencySimulation ); -namespace { +namespace +{ IBlueResource* CreateTextureResource( const wchar_t* name ) { @@ -127,7 +128,7 @@ void AtomicMinUpdate( std::atomic& a, uint32_t b ) -TriTextureRes::TriTextureRes(): +TriTextureRes::TriTextureRes() : m_isTextureLoadDisabled( false ), m_texture( nullptr ), m_memoryUse( 0 ), @@ -172,7 +173,7 @@ unsigned TriTextureRes::ComputeMipSkipCount() if( m_isTextureResizable && gTriDev ) { return gTriDev->GetMipLevelSkipCount(); - } + } return 0; } @@ -214,7 +215,7 @@ void TriTextureRes::Initialize( const wchar_t* name, const wchar_t* ext ) { m_pipelineFence.Cancel(); CancelPendingLoad(); - CleanupAsyncSave(false); + CleanupAsyncSave( false ); m_pipeline = nullptr; m_pipelineInputs.clear(); @@ -294,7 +295,7 @@ void TriTextureRes::Initialize( const wchar_t* name, const wchar_t* ext ) void TriTextureRes::ResourcePrepFinished() { - if( m_pipeline != nullptr) + if( m_pipeline != nullptr ) { m_isLoading = false; m_isPrepared = true; @@ -324,10 +325,7 @@ void TriTextureRes::ResourcePrepFinished() Tr2TextureAL face; USE_MAIN_THREAD_RENDER_CONTEXT(); uint32_t memoryUse; - if( !Tr2ImageIOHelpers::CreateTexture( result, m_ownTexture, - memoryUse, - renderContext, - USAGE_IMMUTABLE ) ) + if( !Tr2ImageIOHelpers::CreateTexture( result, m_ownTexture, memoryUse, renderContext, USAGE_IMMUTABLE ) ) { CCP_LOGWARN( "Tr2ImageHandler failed to create texture '%S'", GetPath() ); return; @@ -371,14 +369,14 @@ void TriTextureRes::ReleaseResources( TriStorage s ) return; } - if( (s & TRISTORAGE_MANAGEDMEMORY) || ((s & TRISTORAGE_VIDEOMEMORY) && m_texture->GetMemoryClass() == AL_MEMORY_VIDEO ) ) + if( ( s & TRISTORAGE_MANAGEDMEMORY ) || ( ( s & TRISTORAGE_VIDEOMEMORY ) && m_texture->GetMemoryClass() == AL_MEMORY_VIDEO ) ) { CCP_STATS_ADD( textureResBytes, -(int)m_memoryUse ); m_memoryUse = 0; m_originalMemoryUse = 0; CancelPendingLoad(); - CleanupAsyncSave(false); + CleanupAsyncSave( false ); m_ownTexture = Tr2TextureAL(); m_texture = nullptr; @@ -397,7 +395,7 @@ Tr2TextureAL* TriTextureRes::GetTexture() { if( m_wrappedRenderTarget ) { - if( (!m_texture || !m_texture->IsValid()) && m_wrappedRenderTarget->GetRenderTarget().IsValid() ) + if( ( !m_texture || !m_texture->IsValid() ) && m_wrappedRenderTarget->GetRenderTarget().IsValid() ) { SetTexture( m_wrappedRenderTarget->GetRenderTarget() ); } @@ -444,10 +442,10 @@ void TriTextureRes::CleanupLoadData() { if( m_loadedBitmap ) { - m_cutoutX = m_metadata.cutout.x; - m_cutoutY = m_metadata.cutout.y; - m_cutoutWidth = m_metadata.cutout.width; - m_cutoutHeight = m_metadata.cutout.height; + m_cutoutX = m_metadata.cutout.x; + m_cutoutY = m_metadata.cutout.y; + m_cutoutWidth = m_metadata.cutout.width; + m_cutoutHeight = m_metadata.cutout.height; } } @@ -479,17 +477,17 @@ bool TriTextureRes::Save( const wchar_t* filename ) CCP_LOGERR( "Texture save failed - only 2d and cubemap textures can be saved" ); return false; } - + if( !ImageIO::IsSaveSupported( filename, *this ) ) { CCP_LOGERR( "Unsupported format for saving (%S)", filename ); return false; } - + Tr2HostBitmapPtr saveBitmap; if( !saveBitmap.CreateInstance() || - !saveBitmap->CreateFromBitmapDimensions( *this ) || + !saveBitmap->CreateFromBitmapDimensions( *this ) || !saveBitmap->CopyFromTextureRes( *this, renderContext ) ) { return false; @@ -511,7 +509,7 @@ bool TriTextureRes::SaveAsync( const wchar_t* filename ) CCP_LOGERR( "Texture save failed - only 2d and cubemap textures can be saved" ); return false; } - + return StartAsyncSave( filename ); } @@ -519,7 +517,7 @@ bool TriTextureRes::DoPrepareAsyncSave( void ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - if( !m_asyncSaveImage) + if( !m_asyncSaveImage ) { CCP_LOGERR( "Unsupported extension for saving (%S)", m_saveFilename.c_str() ); return false; @@ -529,9 +527,9 @@ bool TriTextureRes::DoPrepareAsyncSave( void ) CCP_LOGERR( "Unsupported format for saving (%S)", m_saveFilename.c_str() ); return false; } - - if( !m_asyncSaveBitmap.CreateInstance() || - !m_asyncSaveBitmap->CreateFromBitmapDimensions( *this ) || + + if( !m_asyncSaveBitmap.CreateInstance() || + !m_asyncSaveBitmap->CreateFromBitmapDimensions( *this ) || !m_asyncSaveBitmap->CopyFromTextureRes( *this, renderContext ) ) { CCP_LOGERR( "Failed to save (%S)", m_saveFilename.c_str() ); @@ -585,11 +583,11 @@ BlueAsyncRes::LoadingResult TriTextureRes::DoLoad() } // check if this is a cube map texture or not - if( m_path.find( L"_cube") != m_path.npos ) + if( m_path.find( L"_cube" ) != m_path.npos ) { m_type = TEX_TYPE_CUBE; } - else if( m_path.find( L"_volume") != m_path.npos ) + else if( m_path.find( L"_volume" ) != m_path.npos ) { m_type = TEX_TYPE_3D; } @@ -690,10 +688,7 @@ bool TriTextureRes::DoPrepare() Tr2TextureAL face; USE_MAIN_THREAD_RENDER_CONTEXT(); uint32_t memoryUse; - if( !Tr2ImageIOHelpers::CreateTexture( *m_loadedBitmap, m_ownTexture, - memoryUse, - renderContext, - USAGE_IMMUTABLE ) ) + if( !Tr2ImageIOHelpers::CreateTexture( *m_loadedBitmap, m_ownTexture, memoryUse, renderContext, USAGE_IMMUTABLE ) ) { CCP_LOGWARN( "Tr2ImageHandler failed to create texture '%S'", GetPath() ); return false; @@ -705,7 +700,7 @@ bool TriTextureRes::DoPrepare() } m_ownTexture.SetName( CW2A( GetPath() ) ); - + isOK = true; SetTexture( m_ownTexture ); } @@ -721,7 +716,7 @@ void TriTextureRes::RequestResolution( const uint32_t requestedLod ) return; } m_hadLodRequests = true; - + AtomicMinUpdate( m_requestedMip, requestedLod ); } @@ -890,7 +885,7 @@ bool TriTextureRes::SetTextureFromRT( Tr2RenderTarget* renderTarget ) if( renderTarget && renderTarget->IsValid() ) { m_isTextureResizable = false; - SetTexture( renderTarget->GetRenderTarget() ); + SetTexture( renderTarget->GetRenderTarget() ); } return true; @@ -913,19 +908,20 @@ bool TriTextureRes::CreateAndCopyFromRenderTarget( Tr2RenderTarget* renderTarget auto width = rt.GetWidth(); auto height = rt.GetHeight(); - + // With mipmaps there may be staging resources involved, so just defer the problem to Tr2TextureAL::CopySubresourcRegion if( rt.GetMipCount() != 1 ) - { - Tr2BitmapDimensions bd( width, height, 0, rt.GetFormat() ); // use this to compute true mipcount of new texture + { + Tr2BitmapDimensions bd( width, height, 0, rt.GetFormat() ); // use this to compute true mipcount of new texture { USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( m_ownTexture.Create( - Tr2BitmapDimensions( width, height, bd.GetTrueMipCount(), rt.GetFormat() ), - Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, - Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, - renderContext ), false ); + CR_RETURN_VAL( m_ownTexture.Create( + Tr2BitmapDimensions( width, height, bd.GetTrueMipCount(), rt.GetFormat() ), + Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, + Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, + renderContext ), + false ); } Tr2TextureSubresource dst; @@ -945,19 +941,20 @@ bool TriTextureRes::CreateAndCopyFromRenderTarget( Tr2RenderTarget* renderTarget return false; } ON_BLOCK_EXIT( [&] { rt.UnmapForReading( renderContext ); } ); - + srd.m_sysMemSlicePitch = rt.GetHeight() * srd.m_sysMemPitch; - CR_RETURN_VAL( m_ownTexture.Create( - Tr2BitmapDimensions( width, height, 1, rt.GetFormat() ), - Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, - Tr2CpuUsage::READ, - &srd, - renderContext ), false ); + CR_RETURN_VAL( m_ownTexture.Create( + Tr2BitmapDimensions( width, height, 1, rt.GetFormat() ), + Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, + Tr2CpuUsage::READ, + &srd, + renderContext ), + false ); } m_isTextureResizable = false; - return true; + return true; } bool TriTextureRes::CreateFromHostBitmap( Tr2HostBitmap* bitmap ) @@ -978,7 +975,7 @@ bool TriTextureRes::CreateFromHostBitmap( Tr2HostBitmap* bitmap ) } m_isTextureResizable = false; SetTexture( m_ownTexture ); - return true; + return true; } bool TriTextureRes::CreateEmptyTexture( uint32_t width, uint32_t height, uint32_t mipCount, Tr2RenderContextEnum::PixelFormat format ) @@ -1053,27 +1050,27 @@ BlueStdResult TriTextureRes::CreateFromTexture( TriTextureRes* texture ) auto height = other.GetHeight(); USE_MAIN_THREAD_RENDER_CONTEXT(); - + Tr2BitmapDimensions bd( other.GetDesc() ); - CR_RETURN_VAL( m_ownTexture.Create( - Tr2BitmapDimensions( width, height, other.GetTrueMipCount(), other.GetFormat() ), - Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, - Tr2CpuUsage::READ, - renderContext ), - BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not create a texture" ) ); + CR_RETURN_VAL( m_ownTexture.Create( + Tr2BitmapDimensions( width, height, other.GetTrueMipCount(), other.GetFormat() ), + Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::COPY_DESTINATION, + Tr2CpuUsage::READ, + renderContext ), + BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not create a texture" ) ); - CR_RETURN_VAL( + CR_RETURN_VAL( m_ownTexture.CopySubresourceRegion( Tr2TextureSubresource(), other, Tr2TextureSubresource(), renderContext ), BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "could not copy a texture" ) ); m_isTextureResizable = false; return BLUE_STD_RESULT_OK; } -bool TriTextureRes::Create( uint32_t width, - uint32_t height, - uint32_t mipCount, - PixelFormat format, +bool TriTextureRes::Create( uint32_t width, + uint32_t height, + uint32_t mipCount, + PixelFormat format, BufferUsageFlags usage, Tr2PrimaryRenderContext& renderContext ) { @@ -1107,11 +1104,12 @@ bool TriTextureRes::Create( uint32_t width, gpuUsage = gpuUsage | Tr2GpuUsage::SHARED; } - CR_RETURN_VAL( m_ownTexture.Create( - Tr2BitmapDimensions( width, height, mipCount, format ), - gpuUsage, - cpuUsage, - renderContext ), false ); + CR_RETURN_VAL( m_ownTexture.Create( + Tr2BitmapDimensions( width, height, mipCount, format ), + gpuUsage, + cpuUsage, + renderContext ), + false ); *static_cast( this ) = m_ownTexture.GetDesc(); @@ -1166,7 +1164,7 @@ bool TriTextureRes::SetTexture( Tr2TextureAL& texture ) m_memoryUse = 0; } - if( !texture.IsValid() ) + if( !texture.IsValid() ) { m_texture = nullptr; SetPrepared( false ); @@ -1180,7 +1178,7 @@ bool TriTextureRes::SetTexture( Tr2TextureAL& texture ) *static_cast( this ) = texture.GetDesc(); m_texture = &texture; - + // Estimate memory use for the resource cache. m_memoryUse = 0; auto mipCount = GetTrueMipCount(); diff --git a/trinity/Resources/TriTextureRes.h b/trinity/Resources/TriTextureRes.h index ccd111ec4..0cff58dc7 100644 --- a/trinity/Resources/TriTextureRes.h +++ b/trinity/Resources/TriTextureRes.h @@ -1,6 +1,6 @@ // Copyright © 2000 CCP ehf. -#if !defined(_TriTextureRes_H_) +#if !defined( _TriTextureRes_H_ ) #define _TriTextureRes_H_ #include "include/ITriTextureRes.h" @@ -43,55 +43,73 @@ BLUE_CLASS( TriTextureRes ) : ///////////////////////////////////////////////////////////////////////////////////// // ITriTextureRes Tr2TextureAL* GetTexture(); - unsigned GetWidth() const { return Tr2BitmapDimensions::GetWidth(); } - unsigned GetHeight() const { return Tr2BitmapDimensions::GetHeight(); } - unsigned GetMipLevelCount() const { return Tr2BitmapDimensions::GetMipCount(); } + unsigned GetWidth() const + { + return Tr2BitmapDimensions::GetWidth(); + } + unsigned GetHeight() const + { + return Tr2BitmapDimensions::GetHeight(); + } + unsigned GetMipLevelCount() const + { + return Tr2BitmapDimensions::GetMipCount(); + } uint32_t GetMsaaType() const; uint32_t GetMsaaQuality() const; - Color GetAverageColor() const{ return m_averageColor; } - bool IsValid() const { return IsGood(); } - Tr2RenderContextEnum::TextureType GetType() const { return Tr2BitmapDimensions::GetType(); } + Color GetAverageColor() const + { + return m_averageColor; + } + bool IsValid() const + { + return IsGood(); + } + Tr2RenderContextEnum::TextureType GetType() const + { + return Tr2BitmapDimensions::GetType(); + } long UpdateSubresource( unsigned left, unsigned top, unsigned right, unsigned bottom, const void* source, unsigned sourcePitch ); void SetAverageColor( float red, float green, float blue, float alpha ) override; const Tr2TextureAL* GetTexture() const; OnTextureChangeEvent& OnTextureChange() override; - - bool SetTextureFromRT( Tr2RenderTarget* renderTarget ); - + + bool SetTextureFromRT( Tr2RenderTarget * renderTarget ); + // Make a TriTextureRes that takes a copy of the renderTarget contents and sticks with it (not a live view). bool CreateAndCopyFromRenderTarget( Tr2RenderTarget * renderTarget ); // Make an immutable TriTextureRes that takes a copy of the hostBitmap contents and sticks with it (not a live view). - bool CreateFromHostBitmap( Tr2HostBitmap* bitmap ); + bool CreateFromHostBitmap( Tr2HostBitmap * bitmap ); bool CreateEmptyTexture( uint32_t width, uint32_t height, uint32_t mipCount, Tr2RenderContextEnum::PixelFormat format ); - BlueStdResult CreateFromTexture( TriTextureRes* texture ); + BlueStdResult CreateFromTexture( TriTextureRes * texture ); // Create a new TriTextureRes with undefined contents. It's implied that the usage is dynamic. - bool Create( uint32_t width, - uint32_t height, - uint32_t mipCount, - Tr2RenderContextEnum::PixelFormat format, - Tr2RenderContextEnum::BufferUsageFlags usage, - Tr2PrimaryRenderContext& renderContext ); + bool Create( uint32_t width, + uint32_t height, + uint32_t mipCount, + Tr2RenderContextEnum::PixelFormat format, + Tr2RenderContextEnum::BufferUsageFlags usage, + Tr2PrimaryRenderContext& renderContext ); ALResult OpenShared( uintptr_t handle ); bool SaveAsync( const wchar_t* filename ); - bool Save( const wchar_t* filename ); // synchronous + bool Save( const wchar_t* filename ); // synchronous Tr2TexturePipeline* GetPipeline() const; void RequestResolution( const uint32_t requestedLod ); - void UpdateLodRequest( Tr2TextureLodUpdateRequest& request, Tr2TextureLodManager & manager ); + void UpdateLodRequest( Tr2TextureLodUpdateRequest & request, Tr2TextureLodManager & manager ); void ProcessLodRequest( const Tr2TextureLodUpdateRequest& request, Tr2TextureLodManager& manager ); uint32_t GetOriginalResolution() const; float GetOriginalResolutionAsFloat() const; - + ////////////////////////////////////////////////////////////////////////// // IBlueResource // @@ -104,11 +122,12 @@ BLUE_CLASS( TriTextureRes ) : // ITriDeviceResource private: bool OnPrepareResources(); -public: + +public: void ReleaseResources( TriStorage s ); #if TRINITYDEV - virtual void GetDescription( std::string& desc ); + virtual void GetDescription( std::string & desc ); #endif ////////////////////////////////////////////////////////////////////////// @@ -135,9 +154,9 @@ BLUE_CLASS( TriTextureRes ) : void OnWrappedRenderTargetChanged(); void RasterizeProceduralTexture( const wchar_t* data, void ( *Rastrization )( const std::string_view&, ImageIO::HostBitmap& ) ); - Tr2TextureAL *m_texture; + Tr2TextureAL* m_texture; Tr2TextureAL m_ownTexture; - Tr2RenderTargetPtr m_wrappedRenderTarget; + Tr2RenderTargetPtr m_wrappedRenderTarget; OnTextureChangeEvent m_onTextureChange; unsigned ComputeMipSkipCount(); @@ -145,18 +164,18 @@ BLUE_CLASS( TriTextureRes ) : unsigned int m_memoryUse; size_t m_originalMemoryUse; // Memory usage for non-LODed version (for stats) - float m_cutoutX; - float m_cutoutY; - float m_cutoutWidth; - float m_cutoutHeight; + float m_cutoutX; + float m_cutoutY; + float m_cutoutWidth; + float m_cutoutHeight; ImageIO::Metadata m_metadata; std::unique_ptr m_loadedBitmap; - unsigned m_mipLevelMaxCount; - bool m_isTextureLoadDisabled : 1; - bool m_isTextureResizable : 1; // do we listen to the global mipskip setting? + unsigned m_mipLevelMaxCount; + bool m_isTextureLoadDisabled : 1; + bool m_isTextureResizable : 1; // do we listen to the global mipskip setting? std::atomic m_hadLodRequests; bool m_lodEnabled; @@ -168,10 +187,10 @@ BLUE_CLASS( TriTextureRes ) : uint32_t m_gpuMip; uint32_t m_requestedLoadMip; - Color m_averageColor; - + Color m_averageColor; + private: - bool SetTexture( Tr2TextureAL& texture ); + bool SetTexture( Tr2TextureAL & texture ); bool HasALObject( int type, size_t object ); void TrimLods( uint32_t startLod, Tr2TextureLodManager& manager ); @@ -199,7 +218,7 @@ BLUE_CLASS( TriTextureRes ) : void ResourcePrepFinished(); - Tr2HostBitmapPtr m_asyncSaveBitmap; + Tr2HostBitmapPtr m_asyncSaveBitmap; std::shared_ptr m_asyncSaveImage; Tr2LoadPrepareFence m_pipelineFence; @@ -212,9 +231,8 @@ BLUE_CLASS( TriTextureRes ) : ///////////////////////////////////////// // Python thunkers typedef TriTextureRes _Class; - }; -TYPEDEF_BLUECLASS_WR_SHUTDOWN(TriTextureRes); +TYPEDEF_BLUECLASS_WR_SHUTDOWN( TriTextureRes ); #endif diff --git a/trinity/Resources/TriTextureRes_Blue.cpp b/trinity/Resources/TriTextureRes_Blue.cpp index b91417991..5e461edd2 100644 --- a/trinity/Resources/TriTextureRes_Blue.cpp +++ b/trinity/Resources/TriTextureRes_Blue.cpp @@ -34,12 +34,12 @@ static PyObject* PyInit( PyObject* self, PyObject* args ) if( width && height && mipCount && format ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - pThis->Create( width, - height, - mipCount, - static_cast( format ), - static_cast( usage ), - renderContext ); + pThis->Create( width, + height, + mipCount, + static_cast( format ), + static_cast( usage ), + renderContext ); } Py_RETURN_NONE; } @@ -84,7 +84,7 @@ static PyObject* PythonSave( PyObject* self, PyObject* args, bool async ) return nullptr; } - std::wstring wcstr; + std::wstring wcstr; std::string cstr; bool OK = false; if( PyUnicode_Check( file ) && BlueExtractArgument( file, wcstr, 1 ) ) @@ -134,86 +134,67 @@ static PyObject* PySave( PyObject* self, PyObject* args ) const Be::ClassInfo* TriTextureRes::ExposeToBlue() { - EXPOSURE_BEGIN( TriTextureRes, "" ) - MAP_INTERFACE(ITriTextureRes) - MAP_INTERFACE(TriTextureRes) + EXPOSURE_BEGIN( TriTextureRes, "" ) + MAP_INTERFACE( ITriTextureRes ) + MAP_INTERFACE( TriTextureRes ) MAP_INTERFACE( ITr2TextureProvider ) MAP_INTERFACE( IBlueResource ) MAP_INTERFACE( ICacheable ) MAP_ICACHEABLE_METHODS() - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "Name for logging/debugging", - Be::READ | Be::WRITE - ) - - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "type", - m_type, - "", - Be::READ | Be::PERSIST | Be::ENUM, - Tr2RenderContextEnum_TextureType_Chooser - ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + Be::READ | Be::WRITE ) + + MAP_ATTRIBUTE_WITH_CHOOSER( + "type", + m_type, + "", + Be::READ | Be::PERSIST | Be::ENUM, + Tr2RenderContextEnum_TextureType_Chooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "format", m_format, "Platform independent Pixel format (trinity.PIXEL_FORMAT.foo)", Be::READ | Be::ENUM, - Tr2RenderContextEnum_PixelFormat_Chooser - ) - MAP_ATTRIBUTE - ( - "width", - m_width, - "Width of loaded image in pixels.", - Be::READ - ) - MAP_ATTRIBUTE - ( - "height", - m_height, - "Height of loaded image in pixels.", - Be::READ - ) - MAP_ATTRIBUTE - ( + Tr2RenderContextEnum_PixelFormat_Chooser ) + MAP_ATTRIBUTE( + "width", + m_width, + "Width of loaded image in pixels.", + Be::READ ) + MAP_ATTRIBUTE( + "height", + m_height, + "Height of loaded image in pixels.", + Be::READ ) + MAP_ATTRIBUTE( "depth", m_volumeDepth, "Depth of loaded image in pixels.", - Be::READ - ) - MAP_PROPERTY_READONLY - ( - "mipCount", + Be::READ ) + MAP_PROPERTY_READONLY( + "mipCount", GetTrueMipCount, - "Number of mip levels in this resource" - ) - MAP_ATTRIBUTE - ( - "arraySize", - m_arraySize, - "Number of elements in texture array.", - Be::READ - ) - MAP_PROPERTY_READONLY - ( + "Number of mip levels in this resource" ) + MAP_ATTRIBUTE( + "arraySize", + m_arraySize, + "Number of elements in texture array.", + Be::READ ) + MAP_PROPERTY_READONLY( "mipCount", GetTrueMipCount, - "Number of mip levels in this resource" - ) + "Number of mip levels in this resource" ) MAP_PROPERTY_READONLY( "multiSampleType", GetMsaaType, "" ); MAP_PROPERTY_READONLY( "multiSampleQuality", GetMsaaQuality, "" ); MAP_ATTRIBUTE( "averageColor", m_averageColor, "Average color of the image", - Be::READ - ) + Be::READ ) MAP_ATTRIBUTE( "lodEnabled", m_lodEnabled, "Is LOD enabled for this texture\n:jessica-group: LOD", Be::READ ) MAP_PROPERTY_READONLY( "hadLodRequests", HadLodRequests, "If the textued received any LOD requests\n:jessica-group: LOD" ) @@ -222,9 +203,8 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() MAP_ATTRIBUTE( "cpuMip", m_cpuMip, "Largest mip level loaded into CPU memory\n:jessica-group: LOD", Be::READ ) - MAP_METHOD - ( - "SaveAsync", + MAP_METHOD( + "SaveAsync", PySaveAsync, "Asynchronously save the contents of this TriTextureRes.\n" "Use WaitForSave if you want to wait -- or use the synchronous\n" @@ -232,28 +212,25 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() ":para path: absolute system file path and name with extension.\n" " The format will be decided from the extension (dds, jpg, ...)\n" ":type path: basestring\n" - ":rtype: bool" - ) + ":rtype: bool" ) - MAP_METHOD - ( - "Save", + MAP_METHOD( + "Save", PySave, "Save the contents of this TriTextureRes.\n" ":param path: absolute system file path and name with extension.\n" " The format will be decided from the extension (dds, jpg, ...)\n" ":type path: basestring\n" - ":rtype: bool" - ) + ":rtype: bool" ) - MAP_METHOD_AND_WRAP( "PrepareResources", PrepareResources, "Initiates load of resources from disk. Returns immediately.") - MAP_METHOD_AND_WRAP( "IsPrepared", IsPrepared, "True if preparation has completed (not necessarily successfully)" ) - MAP_METHOD_AND_WRAP( "IsLoading", IsLoading, "True if the resource is in the process of loading" ) - MAP_METHOD_AND_WRAP( "IsGood", IsGood, "True if preparation completed successfully" ) - MAP_METHOD_AND_WRAP( "IsSaving", IsSaving, "Is an asynchronous save in progress?" ); - MAP_METHOD_AND_WRAP( "IsSaveCompleted", IsSaveCompleted, "True if the save operation is completed" ) - MAP_METHOD_AND_WRAP( "IsSaveSucceeded", IsSaveSucceeded, "True if the save operation completed successfully" ) - MAP_METHOD_AND_WRAP( "WaitForSave", WaitForSave, "Waits for SaveAsync() to complete. Alternatively use Save()") + MAP_METHOD_AND_WRAP( "PrepareResources", PrepareResources, "Initiates load of resources from disk. Returns immediately." ) + MAP_METHOD_AND_WRAP( "IsPrepared", IsPrepared, "True if preparation has completed (not necessarily successfully)" ) + MAP_METHOD_AND_WRAP( "IsLoading", IsLoading, "True if the resource is in the process of loading" ) + MAP_METHOD_AND_WRAP( "IsGood", IsGood, "True if preparation completed successfully" ) + MAP_METHOD_AND_WRAP( "IsSaving", IsSaving, "Is an asynchronous save in progress?" ); + MAP_METHOD_AND_WRAP( "IsSaveCompleted", IsSaveCompleted, "True if the save operation is completed" ) + MAP_METHOD_AND_WRAP( "IsSaveSucceeded", IsSaveSucceeded, "True if the save operation completed successfully" ) + MAP_METHOD_AND_WRAP( "WaitForSave", WaitForSave, "Waits for SaveAsync() to complete. Alternatively use Save()" ) #if 0 MAP_METHOD_AND_WRAP @@ -263,33 +240,29 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() "" ) #endif - - MAP_ATTRIBUTE( "cutoutX", m_cutoutX, "X coordinate of cutout rectangle, range 0...1", Be::READWRITE ) - MAP_ATTRIBUTE( "cutoutY", m_cutoutY, "Y coordinate of cutout rectangle, range 0...1", Be::READWRITE ) - MAP_ATTRIBUTE( "cutoutWidth", m_cutoutWidth, "width of cutout rectangle, range 0...1", Be::READWRITE ) - MAP_ATTRIBUTE( "cutoutHeight", m_cutoutHeight, "height of cutout rectangle, range 0...1", Be::READWRITE ) - + + MAP_ATTRIBUTE( "cutoutX", m_cutoutX, "X coordinate of cutout rectangle, range 0...1", Be::READWRITE ) + MAP_ATTRIBUTE( "cutoutY", m_cutoutY, "Y coordinate of cutout rectangle, range 0...1", Be::READWRITE ) + MAP_ATTRIBUTE( "cutoutWidth", m_cutoutWidth, "width of cutout rectangle, range 0...1", Be::READWRITE ) + MAP_ATTRIBUTE( "cutoutHeight", m_cutoutHeight, "height of cutout rectangle, range 0...1", Be::READWRITE ) + MAP_ATTRIBUTE( "wrappedRenderTarget", m_wrappedRenderTarget, "Live view renderTarget being wrapped with SetFromRenderTarget", Be::READ ); MAP_PROPERTY_READONLY( "srvIndex", GetSrvIndexInHeap, "" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetFromRenderTarget", SetTextureFromRT, "Set a texture from a renderTarget. User needs to keep the RT alive.\n" "The TriTextureRes will now represent a live view on the RT to be textured from.\n" - "\n:param rt: render target" - ) + "\n:param rt: render target" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CreateAndCopyFromRenderTarget", CreateAndCopyFromRenderTarget, "Create a new TriTextureRes with the dimensions and pixelFormat from the specified\n" "renderTarget. A copy of the contents is made.\n" - "\n:param rt: render target" - ) + "\n:param rt: render target" ) MAP_METHOD_AND_WRAP( "CreateEmptyTexture", @@ -300,37 +273,30 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() ":param mipCount: number of mip levels\n" ":param format: pixel format (trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CreateFromHostBitmap", CreateFromHostBitmap, "Creates a new TriTextureRes width the dimensionts and pixelFormat from specified\n" "host bitmap and copies the contents of the host bitmap into the texture.\n" - ":param hostBitmap: valid Tr2HostBitmap" - ) + ":param hostBitmap: valid Tr2HostBitmap" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CreateFromTexture", CreateFromTexture, "Creates a new TriTextureRes with a copy of provided TriTextureRes argument.\n" - ":param texture: valid TriTextureRes" - ) + ":param texture: valid TriTextureRes" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasALObject", HasALObject, "Returns True iff TriTextureRes contains a reference to passed AL object ID.\n" "Used for debugging along with trinity.GetLiveALResources.\n" ":param alType: AL object type (trinity.AL_OBJECT_TYPE)\n" - ":param alObject: AL object ID" - ) + ":param alObject: AL object ID" ) - MAP_METHOD - ( - "__init__", - PyInit, + MAP_METHOD( + "__init__", + PyInit, "Constructs a new texture. There are three possible overrides:\n" "(1) TriTextureRes() - constructs an empty texture\n" "(2) TriTextureRes(other) - wraps existing render target\n" @@ -344,8 +310,7 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() ":param format: pixel format (trinity.PIXEL_FORMAT)\n" ":type format: Optional[int]\n" ":param usage: texture usage (trinity.BUFFER_USAGE_FLAGS)\n" - ":type usage: Optional[int]\n" - ) + ":type usage: Optional[int]\n" ) MAP_METHOD_AND_WRAP( "GetPipeline", GetPipeline, "Returns pipeline associated with this texture if any" ) @@ -355,21 +320,20 @@ const Be::ClassInfo* TriTextureRes::ExposeToBlue() namespace { - ALResult OpenSharedTexture( uint32_t handle, TriTextureRes*& result ) - { - result = nullptr; +ALResult OpenSharedTexture( uint32_t handle, TriTextureRes*& result ) +{ + result = nullptr; - TriTextureResPtr ptr; - ptr.CreateInstance(); - CR_RETURN_HR( ptr->OpenShared( handle ) ); - result = ptr.Detach(); - return ALResult( S_OK ); - } + TriTextureResPtr ptr; + ptr.CreateInstance(); + CR_RETURN_HR( ptr->OpenShared( handle ) ); + result = ptr.Detach(); + return ALResult( S_OK ); +} } -MAP_FUNCTION_AND_WRAP( - "OpenSharedTexture", - OpenSharedTexture, - "Creates a TriTextureRes object that has access to a previously created shared texture.\n" - ":param handle: shared handle of the texture\n" -); +MAP_FUNCTION_AND_WRAP( + "OpenSharedTexture", + OpenSharedTexture, + "Creates a TriTextureRes object that has access to a previously created shared texture.\n" + ":param handle: shared handle of the texture\n" ); diff --git a/trinity/Shader/IShaderConfigurer.h b/trinity/Shader/IShaderConfigurer.h index ee9f17e15..fd8ca80b8 100644 --- a/trinity/Shader/IShaderConfigurer.h +++ b/trinity/Shader/IShaderConfigurer.h @@ -2,8 +2,8 @@ #pragma once -BLUE_INTERFACE( IShaderConfigurer ) : public IRoot +BLUE_INTERFACE( IShaderConfigurer ) : + public IRoot { virtual void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ) = 0; }; - diff --git a/trinity/Shader/Parameter/Tr2FloatParameter.cpp b/trinity/Shader/Parameter/Tr2FloatParameter.cpp index ebf72b3b5..611a3b6c9 100644 --- a/trinity/Shader/Parameter/Tr2FloatParameter.cpp +++ b/trinity/Shader/Parameter/Tr2FloatParameter.cpp @@ -5,7 +5,7 @@ #include "TriValueBinding.h" #include "Shader/Tr2Shader.h" -Tr2FloatParameter::Tr2FloatParameter(IRoot* lockobj): +Tr2FloatParameter::Tr2FloatParameter( IRoot* lockobj ) : m_value( 1.0f ), m_name(), m_isUsedByEffect( false ), @@ -29,19 +29,19 @@ unsigned Tr2FloatParameter::GetHashValue( unsigned startingHash ) const return CcpHashFNV1( &name, sizeof( name ), CcpHashFNV1( &m_value, sizeof( m_value ), startingHash ) ); } -void Tr2FloatParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void Tr2FloatParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { // We need this to work even when the effect we're copying this to isn't the one that we're bound to if( m_reroutedValue ) { - memcpy( destHandle, m_reroutedValue, size < sizeof(m_value) ? size : sizeof(m_value) ); + memcpy( destHandle, m_reroutedValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else { - memcpy( destHandle, &m_value, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_value, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } } diff --git a/trinity/Shader/Parameter/Tr2FloatParameter.h b/trinity/Shader/Parameter/Tr2FloatParameter.h index 28b20abba..8c4b1815a 100644 --- a/trinity/Shader/Parameter/Tr2FloatParameter.h +++ b/trinity/Shader/Parameter/Tr2FloatParameter.h @@ -9,7 +9,7 @@ BLUE_DECLARE( Tr2FloatParameter ); BLUE_CLASS_ALLOW_DELAYED_DELETE( Tr2FloatParameter ); -BLUE_CLASS( Tr2FloatParameter ): +BLUE_CLASS( Tr2FloatParameter ) : public ITriEffectParameter, public ITriReroutable, public IInitialize @@ -18,7 +18,7 @@ BLUE_CLASS( Tr2FloatParameter ): public: EXPOSE_TO_BLUE(); - Tr2FloatParameter(IRoot* lockobj = NULL); + Tr2FloatParameter( IRoot* lockobj = NULL ); ~Tr2FloatParameter(); using ITriEffectParameter::Lock; @@ -28,20 +28,20 @@ BLUE_CLASS( Tr2FloatParameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const; + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); unsigned GetHashValue( unsigned startingHash ) const; ///////////////////////////////////////////////////////////////////////////////////// // ITriReroutable void SetDestination( void* dest, size_t size ); void GetDestination( void*& dest, size_t& size ); - void RegisterBinding( TriValueBinding* vb ); - void UnregisterBinding( TriValueBinding* vb ); + void RegisterBinding( TriValueBinding * vb ); + void UnregisterBinding( TriValueBinding * vb ); bool IsRerouted() const; ////////////////////////////////////////////////////////////////////////// @@ -50,6 +50,7 @@ BLUE_CLASS( Tr2FloatParameter ): BlueSharedString m_name; float m_value; + protected: // If this parameter is bound to a curve we have to inform the binding of the // destination value the effect sets when the parameters are mapped to shader @@ -59,10 +60,11 @@ BLUE_CLASS( Tr2FloatParameter ): float* m_reroutedValue; bool m_isUsedByEffect; + public: float GetValue(); void SetValue( float val ); }; TYPEDEF_BLUECLASS( Tr2FloatParameter ); -#endif +#endif diff --git a/trinity/Shader/Parameter/Tr2FloatParameter_Blue.cpp b/trinity/Shader/Parameter/Tr2FloatParameter_Blue.cpp index 48f651f11..266be9caf 100644 --- a/trinity/Shader/Parameter/Tr2FloatParameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2FloatParameter_Blue.cpp @@ -12,14 +12,12 @@ const Be::ClassInfo* Tr2FloatParameter::ExposeToBlue() MAP_INTERFACE( ITriReroutable ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE( "value", m_value, "", Be::PERSISTONLY ) + MAP_ATTRIBUTE( + "name", + m_name, + "", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "value", m_value, "", Be::PERSISTONLY ) MAP_PROPERTY( "value", GetValue, SetValue, "Value of this parameter" ) MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "Is the parent effect using this parameter", Be::READ ) EXPOSURE_END() diff --git a/trinity/Shader/Parameter/Tr2GeometryBufferParameter.cpp b/trinity/Shader/Parameter/Tr2GeometryBufferParameter.cpp index 130d5f803..1864eadc5 100644 --- a/trinity/Shader/Parameter/Tr2GeometryBufferParameter.cpp +++ b/trinity/Shader/Parameter/Tr2GeometryBufferParameter.cpp @@ -9,8 +9,8 @@ // Description: // Tr2GeometryBufferParameter default constructor // -------------------------------------------------------------------------------------- -Tr2GeometryBufferParameter::Tr2GeometryBufferParameter( IRoot* lockobj ) - :m_meshIndex( 0 ), +Tr2GeometryBufferParameter::Tr2GeometryBufferParameter( IRoot* lockobj ) : + m_meshIndex( 0 ), m_isUsedByEffect( false ) { } @@ -41,8 +41,8 @@ bool Tr2GeometryBufferParameter::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the object to respond to parameter changes -// generated in Python. Reloads geometry if geometry path has changed. +// Implements INotify interface. Allows the object to respond to parameter changes +// generated in Python. Reloads geometry if geometry path has changed. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -91,7 +91,7 @@ void Tr2GeometryBufferParameter::RebuildEffectHandles( Tr2Shader* effectRes ) { m_cachedEffect = effectRes; - if ( m_name.empty() || !effectRes || !effectRes->GetResource( m_name.c_str() ) ) + if( m_name.empty() || !effectRes || !effectRes->GetResource( m_name.c_str() ) ) { m_isUsedByEffect = false; return; diff --git a/trinity/Shader/Parameter/Tr2GeometryBufferParameter.h b/trinity/Shader/Parameter/Tr2GeometryBufferParameter.h index 54e5a0936..fa8cc2512 100644 --- a/trinity/Shader/Parameter/Tr2GeometryBufferParameter.h +++ b/trinity/Shader/Parameter/Tr2GeometryBufferParameter.h @@ -14,36 +14,36 @@ BLUE_DECLARE( Tr2Shader ); // See Also: // ITriEffectResourceParameter // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GeometryBufferParameter ): +BLUE_CLASS( Tr2GeometryBufferParameter ) : public ITriEffectResourceParameter, public IInitialize, public INotify { public: - Tr2GeometryBufferParameter(IRoot* lockobj = NULL); + Tr2GeometryBufferParameter( IRoot* lockobj = NULL ); ~Tr2GeometryBufferParameter(); ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); unsigned GetHashValue( unsigned startingHash ) const; ////////////////////////////////////////////////////////////////////////// // ITriEffectResourceParameter virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const; virtual bool ApplyUav( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const; ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -52,10 +52,11 @@ BLUE_CLASS( Tr2GeometryBufferParameter ): bool IsValid() const; - void SetGpuBuffer( ITr2GpuBuffer* buffer ); + void SetGpuBuffer( ITr2GpuBuffer * buffer ); ITr2GpuBufferPtr GetGpuBuffer() const; BlueSharedString m_name; + protected: // Path to geometry resource std::wstring m_resourcePath; @@ -70,6 +71,7 @@ BLUE_CLASS( Tr2GeometryBufferParameter ): // Owner effect Tr2ShaderPtr m_cachedEffect; + public: EXPOSE_TO_BLUE(); }; diff --git a/trinity/Shader/Parameter/Tr2GeometryBufferParameter_Blue.cpp b/trinity/Shader/Parameter/Tr2GeometryBufferParameter_Blue.cpp index 6cffbfc93..a3a8d689a 100644 --- a/trinity/Shader/Parameter/Tr2GeometryBufferParameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2GeometryBufferParameter_Blue.cpp @@ -13,48 +13,35 @@ const Be::ClassInfo* Tr2GeometryBufferParameter::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Parameter name", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "resourcePath", - m_resourcePath, - "Resource path to granny file", + MAP_ATTRIBUTE( + "name", + m_name, + "Parameter name", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "resourcePath", + m_resourcePath, + "Resource path to granny file", Be::READWRITE | Be::NOTIFY | Be::PERSIST, - NULL - ) - MAP_ATTRIBUTE - ( - "meshIndex", - m_meshIndex, - "Mesh index in granny file", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_PROPERTY_READONLY - ( + NULL ) + MAP_ATTRIBUTE( + "meshIndex", + m_meshIndex, + "Mesh index in granny file", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_PROPERTY_READONLY( "isValid", IsValid, - "Is the geometry loaded and mesh is a shader resource" - ) - MAP_ATTRIBUTE - ( + "Is the geometry loaded and mesh is a shader resource" ) + MAP_ATTRIBUTE( "gpuBuffer", m_gpuBuffer, "GPU buffer (can be specified instead of geometry res path)", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "usedByCurrentEffect", - m_isUsedByEffect, - "If the parameter is actually used by the effect", - Be::READ - ) - EXPOSURE_END( ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "usedByCurrentEffect", + m_isUsedByEffect, + "If the parameter is actually used by the effect", + Be::READ ) + EXPOSURE_END() } - diff --git a/trinity/Shader/Parameter/Tr2Matrix4Parameter.cpp b/trinity/Shader/Parameter/Tr2Matrix4Parameter.cpp index 37de15c4a..ed6ecb746 100644 --- a/trinity/Shader/Parameter/Tr2Matrix4Parameter.cpp +++ b/trinity/Shader/Parameter/Tr2Matrix4Parameter.cpp @@ -5,12 +5,9 @@ #include "TriValueBinding.h" #include "Shader/Tr2Shader.h" -Tr2Matrix4Parameter::Tr2Matrix4Parameter(IRoot* lockobj): +Tr2Matrix4Parameter::Tr2Matrix4Parameter( IRoot* lockobj ) : m_isUsedByEffect( false ), - m_value( 1.0f, 0, 0, 0, - 0, 1.0f, 0, 0, - 0, 0, 1.0f, 0, - 0, 0, 0, 1.0f ), + m_value( 1.0f, 0, 0, 0, 0, 1.0f, 0, 0, 0, 0, 1.0f, 0, 0, 0, 0, 1.0f ), m_reroutedValue( NULL ), m_bindings( "Tr2Matrix4Parameter/m_bindings" ) { @@ -27,33 +24,33 @@ unsigned Tr2Matrix4Parameter::GetHashValue( unsigned startingHash ) const return CcpHashFNV1( &name, sizeof( name ), CcpHashFNV1( &m_value, sizeof( m_value ), startingHash ) ); } -void Tr2Matrix4Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void Tr2Matrix4Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { // We need this to work even when the effect we're copying this to isn't the one that we're bound to if( m_reroutedValue ) { - memcpy( destHandle, m_reroutedValue, size < sizeof(m_value) ? size : sizeof(m_value) ); + memcpy( destHandle, m_reroutedValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else { - memcpy( destHandle, &m_value, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_value, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } } -Matrix Tr2Matrix4Parameter::GetValue() +Matrix Tr2Matrix4Parameter::GetValue() { if( m_reroutedValue ) { - memcpy( &m_value, m_reroutedValue, sizeof( m_value ) ); + memcpy( &m_value, m_reroutedValue, sizeof( m_value ) ); } return m_value; } -void Tr2Matrix4Parameter::SetValue( const Matrix & value ) +void Tr2Matrix4Parameter::SetValue( const Matrix& value ) { m_value = value; @@ -78,7 +75,7 @@ void Tr2Matrix4Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( m_reroutedValue ); + ( *it )->RerouteDestination( m_reroutedValue ); } } else @@ -87,7 +84,7 @@ void Tr2Matrix4Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( &m_value ); + ( *it )->RerouteDestination( &m_value ); } } } @@ -109,7 +106,7 @@ void Tr2Matrix4Parameter::RegisterBinding( TriValueBinding* vb ) { CCP_ASSERT( vb ); - // Note that this is a weak reference - adding a reference here would + // Note that this is a weak reference - adding a reference here would // create a circular reference. m_bindings.push_back( vb ); } @@ -137,13 +134,13 @@ void Tr2Matrix4Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) SetDestination( NULL, 0 ); } - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { m_isUsedByEffect = false; return; } - if ( !effectRes || !effectRes->GetConstant( m_name.c_str() ) ) + if( !effectRes || !effectRes->GetConstant( m_name.c_str() ) ) { m_isUsedByEffect = false; } diff --git a/trinity/Shader/Parameter/Tr2Matrix4Parameter.h b/trinity/Shader/Parameter/Tr2Matrix4Parameter.h index 95d4d0012..c784fe09f 100644 --- a/trinity/Shader/Parameter/Tr2Matrix4Parameter.h +++ b/trinity/Shader/Parameter/Tr2Matrix4Parameter.h @@ -17,7 +17,7 @@ BLUE_CLASS_ALLOW_DELAYED_DELETE( Tr2Matrix4Parameter ); // SeeAlso: // Tr2Effect // ----------------------------------------------------------------------------------- -BLUE_CLASS( Tr2Matrix4Parameter ): +BLUE_CLASS( Tr2Matrix4Parameter ) : public ITriEffectParameter, public ITriReroutable { @@ -25,13 +25,13 @@ BLUE_CLASS( Tr2Matrix4Parameter ): public: EXPOSE_TO_BLUE(); - Tr2Matrix4Parameter(IRoot* lockobj = NULL); + Tr2Matrix4Parameter( IRoot* lockobj = NULL ); using ITriEffectParameter::Lock; using ITriEffectParameter::Unlock; // 4x4 matrix mapping hlsl float4x4 - Matrix m_value; + Matrix m_value; // hlsl attribute name BlueSharedString m_name; @@ -42,24 +42,24 @@ BLUE_CLASS( Tr2Matrix4Parameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); unsigned GetHashValue( unsigned startingHash ) const; ///////////////////////////////////////////////////////////////////////////////////// // ITriReroutable void SetDestination( void* dest, size_t size ); void GetDestination( void*& dest, size_t& size ); - void RegisterBinding( TriValueBinding* vb ); - void UnregisterBinding( TriValueBinding* vb ); + void RegisterBinding( TriValueBinding * vb ); + void UnregisterBinding( TriValueBinding * vb ); bool IsRerouted() const; - Matrix GetValue(); - void SetValue( const Matrix & ); + Matrix GetValue(); + void SetValue( const Matrix& ); private: // If this parameter is bound to a curve we have to inform the binding of the @@ -68,10 +68,8 @@ BLUE_CLASS( Tr2Matrix4Parameter ): typedef TrackableStdVector BindingVector_t; BindingVector_t m_bindings; float* m_reroutedValue; - }; TYPEDEF_BLUECLASS( Tr2Matrix4Parameter ); -#endif // Tr2Matrix4Parameter_H_ - +#endif // Tr2Matrix4Parameter_H_ diff --git a/trinity/Shader/Parameter/Tr2Matrix4Parameter_Blue.cpp b/trinity/Shader/Parameter/Tr2Matrix4Parameter_Blue.cpp index 60f45c0d6..563bdc3ec 100644 --- a/trinity/Shader/Parameter/Tr2Matrix4Parameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2Matrix4Parameter_Blue.cpp @@ -7,22 +7,20 @@ BLUE_DEFINE( Tr2Matrix4Parameter ); const Be::ClassInfo* Tr2Matrix4Parameter::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2Matrix4Parameter, "" ) + EXPOSURE_BEGIN( Tr2Matrix4Parameter, "" ) MAP_INTERFACE( ITriEffectParameter ) MAP_INTERFACE( Tr2Matrix4Parameter ) MAP_INTERFACE( ITriReroutable ) //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - m_name, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// MAP_ATTRIBUTE( "value", m_value, "", Be::PERSISTONLY ) - MAP_PROPERTY ( "value", GetValue, SetValue, "4x4 Matrix" ) + MAP_PROPERTY( "value", GetValue, SetValue, "4x4 Matrix" ) //////////////////////////////////////////////////////////////////////////// MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) diff --git a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.cpp b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.cpp index b5c2f2b5e..a37dd7903 100644 --- a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.cpp +++ b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.cpp @@ -8,8 +8,8 @@ #include "Tr2Renderer.h" // -------------------------------------------------------------------------------------- -Tr2RuntimeTextureParameter::Tr2RuntimeTextureParameter( IRoot* lockobj ) - :m_resourceType( Tr2EffectResource::TEXTURE_TYPELESS ), +Tr2RuntimeTextureParameter::Tr2RuntimeTextureParameter( IRoot* lockobj ) : + m_resourceType( Tr2EffectResource::TEXTURE_TYPELESS ), m_uavMipLevel( 0 ) { } diff --git a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.h b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.h index 7b865d50f..3d0541597 100644 --- a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.h +++ b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter.h @@ -6,37 +6,39 @@ BLUE_DECLARE_INTERFACE( ITr2TextureProvider ); -BLUE_CLASS( Tr2RuntimeTextureParameter ): public ITriEffectResourceParameter, public INotify +BLUE_CLASS( Tr2RuntimeTextureParameter ) : + public ITriEffectResourceParameter, public INotify { public: Tr2RuntimeTextureParameter( IRoot* lockobj = nullptr ); EXPOSE_TO_BLUE(); - bool OnModified( Be::Var* value ) override; + bool OnModified( Be::Var * value ) override; virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const; virtual bool ApplyUav( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const; void AddUsedTexture( Tr2BindlessResourcesAL & usedTextures ) const override; virtual const char* GetParameterName() const; - virtual void RebuildEffectHandles( Tr2Shader* effectRes ); + virtual void RebuildEffectHandles( Tr2Shader * effectRes ); virtual unsigned GetHashValue( unsigned startingHash ) const; void Create( const BlueSharedString& name, ITr2TextureProvider* texture, uint32_t uavMipLevel = 0 ); - void SetTextureProvider( ITr2TextureProvider* texture ); + void SetTextureProvider( ITr2TextureProvider * texture ); ITr2TextureProviderPtr GetTextureProvider() const; void SetUavMipLevel( uint32_t mipLevel ); + private: - void OnAddedToMaterial( Tr2Material* material ) override; - void OnRemovedFromMaterial( Tr2Material* material ) override; + void OnAddedToMaterial( Tr2Material * material ) override; + void OnRemovedFromMaterial( Tr2Material * material ) override; BlueSharedString m_name; ITr2TextureProviderPtr m_texture; diff --git a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter_Blue.cpp b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter_Blue.cpp index 93a6f04e2..9f0982c8c 100644 --- a/trinity/Shader/Parameter/Tr2RuntimeTextureParameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2RuntimeTextureParameter_Blue.cpp @@ -18,14 +18,13 @@ const Be::ClassInfo* Tr2RuntimeTextureParameter::ExposeToBlue() MAP_ATTRIBUTE( "texture", m_texture, "", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "uavMipLevel", m_uavMipLevel, "", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", Create, 3, ":param name: parameter name\n" ":param texture: texture associated with the parameter\n" - ":param mip: UAV mip level" - ) + ":param mip: UAV mip level" ) EXPOSURE_END() } diff --git a/trinity/Shader/Parameter/Tr2Vector2Parameter.cpp b/trinity/Shader/Parameter/Tr2Vector2Parameter.cpp index e79ed42f9..86fc27ace 100644 --- a/trinity/Shader/Parameter/Tr2Vector2Parameter.cpp +++ b/trinity/Shader/Parameter/Tr2Vector2Parameter.cpp @@ -10,7 +10,7 @@ // Description: // Constructor. Initializes member variables to defaults. // -------------------------------------------------------------------------------------- -Tr2Vector2Parameter::Tr2Vector2Parameter(IRoot* lockobj) : +Tr2Vector2Parameter::Tr2Vector2Parameter( IRoot* lockobj ) : m_isUsedByEffect( false ), m_isSrgb( false ), m_value( 1.0f, 1.0f ), @@ -44,28 +44,27 @@ unsigned Tr2Vector2Parameter::GetHashValue( unsigned startingHash ) const // destHandle - Pointer to the destination buffer // size - Number of bytes to copy (could differ from the size of a vector2) // -------------------------------------------------------------------------------------- -void Tr2Vector2Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void Tr2Vector2Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { - // We need this to work even when the effect we're copying this to isn't the one + // We need this to work even when the effect we're copying this to isn't the one // that we're bound to if( m_reroutedValue ) { - memcpy( - destHandle, - m_reroutedValue, - size < sizeof(m_value) ? size : sizeof(m_value) - ); + memcpy( + destHandle, + m_reroutedValue, + size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else if( m_isSrgb ) { - memcpy( destHandle, &m_linearValue, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_linearValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else { - memcpy( destHandle, &m_value, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_value, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } } @@ -139,7 +138,7 @@ void Tr2Vector2Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( m_reroutedValue ); + ( *it )->RerouteDestination( m_reroutedValue ); } } else @@ -153,7 +152,7 @@ void Tr2Vector2Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( &m_value ); + ( *it )->RerouteDestination( &m_value ); } } } @@ -188,7 +187,7 @@ void Tr2Vector2Parameter::RegisterBinding( TriValueBinding* vb ) { CCP_ASSERT( vb ); - // Note that this is a weak reference - adding a reference here would + // Note that this is a weak reference - adding a reference here would // create a circular reference. m_bindings.push_back( vb ); } @@ -231,7 +230,7 @@ void Tr2Vector2Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) SetDestination( NULL, 0 ); } - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { m_isUsedByEffect = false; return; @@ -239,7 +238,7 @@ void Tr2Vector2Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) const Tr2EffectConstant* constant = effectRes->GetConstant( m_name.c_str() ); - if ( !constant ) + if( !constant ) { m_isUsedByEffect = false; return; @@ -248,7 +247,7 @@ void Tr2Vector2Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) m_isUsedByEffect = true; m_isSrgb = constant->isSRGB; - + if( m_isSrgb ) { SetDestination( NULL, 0 ); @@ -349,5 +348,4 @@ bool Tr2Vector2Parameter::Initialize() } return true; - } diff --git a/trinity/Shader/Parameter/Tr2Vector2Parameter.h b/trinity/Shader/Parameter/Tr2Vector2Parameter.h index 2241cf957..fbfd6c172 100644 --- a/trinity/Shader/Parameter/Tr2Vector2Parameter.h +++ b/trinity/Shader/Parameter/Tr2Vector2Parameter.h @@ -12,10 +12,9 @@ BLUE_DECLARE( Tr2Vector2Parameter ); BLUE_CLASS_ALLOW_DELAYED_DELETE( Tr2Vector2Parameter ); -class Tr2Vector2Parameter : - public ITriEffectParameter, - public ITriReroutable, - public IInitialize +class Tr2Vector2Parameter : public ITriEffectParameter, + public ITriReroutable, + public IInitialize { public: @@ -39,10 +38,10 @@ class Tr2Vector2Parameter : ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; void RebuildEffectHandles( Tr2Shader* effectRes ); unsigned GetHashValue( unsigned startingHash ) const; diff --git a/trinity/Shader/Parameter/Tr2Vector2Parameter_Blue.cpp b/trinity/Shader/Parameter/Tr2Vector2Parameter_Blue.cpp index 51c98d5ea..fa4b7e819 100644 --- a/trinity/Shader/Parameter/Tr2Vector2Parameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2Vector2Parameter_Blue.cpp @@ -8,70 +8,56 @@ BLUE_DEFINE( Tr2Vector2Parameter ); const Be::ClassInfo* Tr2Vector2Parameter::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2Vector2Parameter, "" ) + EXPOSURE_BEGIN( Tr2Vector2Parameter, "" ) MAP_INTERFACE( ITriEffectParameter ) MAP_INTERFACE( Tr2Vector2Parameter ) MAP_INTERFACE( ITriReroutable ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Parameter name", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "Parameter name", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "value", m_value, "", - Be::PERSISTONLY - ) + Be::PERSISTONLY ) - MAP_PROPERTY - ( - "value", - GetValue, - SetValue, - "Value of the Vector2 parameter" - ) + MAP_PROPERTY( + "value", + GetValue, + SetValue, + "Value of the Vector2 parameter" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "x", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "y", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v1", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v2", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_ATTRIBUTE("usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) - MAP_ATTRIBUTE("usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Shader/Parameter/Tr2Vector3Parameter.cpp b/trinity/Shader/Parameter/Tr2Vector3Parameter.cpp index 275fcdc9b..cfa80072a 100644 --- a/trinity/Shader/Parameter/Tr2Vector3Parameter.cpp +++ b/trinity/Shader/Parameter/Tr2Vector3Parameter.cpp @@ -10,7 +10,7 @@ // Description: // Constructor. Initializes member variables to defaults. // -------------------------------------------------------------------------------------- -Tr2Vector3Parameter::Tr2Vector3Parameter(IRoot* lockobj) : +Tr2Vector3Parameter::Tr2Vector3Parameter( IRoot* lockobj ) : m_isUsedByEffect( false ), m_isSrgb( false ), m_value( 1.0f, 1.0f, 1.0f ), @@ -44,28 +44,27 @@ unsigned Tr2Vector3Parameter::GetHashValue( unsigned startingHash ) const // destHandle - Pointer to the destination buffer // size - Number of bytes to copy (could differ from the size of a vector3) // -------------------------------------------------------------------------------------- -void Tr2Vector3Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void Tr2Vector3Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { - // We need this to work even when the effect we're copying this to isn't the one + // We need this to work even when the effect we're copying this to isn't the one // that we're bound to if( m_reroutedValue ) { - memcpy( - destHandle, - m_reroutedValue, - size < sizeof(m_value) ? size : sizeof(m_value) - ); + memcpy( + destHandle, + m_reroutedValue, + size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else if( m_isSrgb ) { - memcpy( destHandle, &m_linearValue, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_linearValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else { - memcpy( destHandle, &m_value, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_value, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } } @@ -142,7 +141,7 @@ void Tr2Vector3Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( m_reroutedValue ); + ( *it )->RerouteDestination( m_reroutedValue ); } } else @@ -156,7 +155,7 @@ void Tr2Vector3Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( &m_value ); + ( *it )->RerouteDestination( &m_value ); } } } @@ -191,7 +190,7 @@ void Tr2Vector3Parameter::RegisterBinding( TriValueBinding* vb ) { CCP_ASSERT( vb ); - // Note that this is a weak reference - adding a reference here would + // Note that this is a weak reference - adding a reference here would // create a circular reference. m_bindings.push_back( vb ); } @@ -234,7 +233,7 @@ void Tr2Vector3Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) SetDestination( NULL, 0 ); } - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { m_isUsedByEffect = false; return; @@ -242,7 +241,7 @@ void Tr2Vector3Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) const Tr2EffectConstant* constant = effectRes->GetConstant( m_name.c_str() ); - if ( !constant ) + if( !constant ) { m_isUsedByEffect = false; return; diff --git a/trinity/Shader/Parameter/Tr2Vector3Parameter.h b/trinity/Shader/Parameter/Tr2Vector3Parameter.h index 9140c28ee..28b853d54 100644 --- a/trinity/Shader/Parameter/Tr2Vector3Parameter.h +++ b/trinity/Shader/Parameter/Tr2Vector3Parameter.h @@ -12,10 +12,9 @@ BLUE_DECLARE( Tr2Vector3Parameter ); BLUE_CLASS_ALLOW_DELAYED_DELETE( Tr2Vector3Parameter ); -class Tr2Vector3Parameter : - public ITriEffectParameter, - public ITriReroutable, - public IInitialize +class Tr2Vector3Parameter : public ITriEffectParameter, + public ITriReroutable, + public IInitialize { public: @@ -39,10 +38,10 @@ class Tr2Vector3Parameter : ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; void RebuildEffectHandles( Tr2Shader* effectRes ); unsigned GetHashValue( unsigned startingHash ) const; @@ -80,4 +79,4 @@ class Tr2Vector3Parameter : TYPEDEF_BLUECLASS( Tr2Vector3Parameter ); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/trinity/Shader/Parameter/Tr2Vector3Parameter_Blue.cpp b/trinity/Shader/Parameter/Tr2Vector3Parameter_Blue.cpp index 3d2869148..fe772718a 100644 --- a/trinity/Shader/Parameter/Tr2Vector3Parameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2Vector3Parameter_Blue.cpp @@ -8,86 +8,68 @@ BLUE_DEFINE( Tr2Vector3Parameter ); const Be::ClassInfo* Tr2Vector3Parameter::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2Vector3Parameter, "" ) + EXPOSURE_BEGIN( Tr2Vector3Parameter, "" ) MAP_INTERFACE( ITriEffectParameter ) MAP_INTERFACE( Tr2Vector3Parameter ) MAP_INTERFACE( ITriReroutable ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Parameter name", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "Parameter name", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "value", m_value, "", - Be::PERSISTONLY - ) + Be::PERSISTONLY ) - MAP_PROPERTY - ( - "value", - GetValue, - SetValue, - "Value of the Vector3 parameter" - ) + MAP_PROPERTY( + "value", + GetValue, + SetValue, + "Value of the Vector3 parameter" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "x", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "y", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "z", GetZ, SetZ, - "Z component value" - ) + "Z component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v1", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v2", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v3", GetZ, SetZ, - "Z component value" - ) + "Z component value" ) - MAP_ATTRIBUTE("usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) - MAP_ATTRIBUTE("usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Shader/Parameter/Tr2Vector4Parameter.cpp b/trinity/Shader/Parameter/Tr2Vector4Parameter.cpp index ad578bf6f..5670dd400 100644 --- a/trinity/Shader/Parameter/Tr2Vector4Parameter.cpp +++ b/trinity/Shader/Parameter/Tr2Vector4Parameter.cpp @@ -5,10 +5,10 @@ #include "TriValueBinding.h" #include "Shader/Tr2Shader.h" -Tr2Vector4Parameter::Tr2Vector4Parameter(IRoot* lockobj): +Tr2Vector4Parameter::Tr2Vector4Parameter( IRoot* lockobj ) : m_isUsedByEffect( false ), m_isSrgb( false ), - m_value(1.0f, 1.0f, 1.0f, 1.0f), + m_value( 1.0f, 1.0f, 1.0f, 1.0f ), m_linearValue( 1.0f, 1.0f, 1.0f, 1.0f ), m_reroutedValue( NULL ), m_bindings( "Tr2Vector4Parameter/m_bindings" ) @@ -26,23 +26,23 @@ unsigned Tr2Vector4Parameter::GetHashValue( unsigned startingHash ) const return CcpHashFNV1( &name, sizeof( name ), CcpHashFNV1( &m_value, sizeof( m_value ), startingHash ) ); } -void Tr2Vector4Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void Tr2Vector4Parameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { // We need this to work even when the effect we're copying this to isn't the one that we're bound to if( m_reroutedValue ) { - memcpy( destHandle, m_reroutedValue, size < sizeof(m_value) ? size : sizeof(m_value) ); + memcpy( destHandle, m_reroutedValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else if( m_isSrgb ) { - memcpy( destHandle, &m_linearValue, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_linearValue, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } else { - memcpy( destHandle, &m_value, size < sizeof(m_value) ? size : sizeof( m_value ) ); + memcpy( destHandle, &m_value, size < sizeof( m_value ) ? size : sizeof( m_value ) ); } } @@ -270,7 +270,7 @@ void Tr2Vector4Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( m_reroutedValue ); + ( *it )->RerouteDestination( m_reroutedValue ); } } else @@ -284,7 +284,7 @@ void Tr2Vector4Parameter::SetDestination( void* dest, size_t size ) for( BindingVector_t::iterator it = m_bindings.begin(); it != m_bindings.end(); ++it ) { - (*it)->RerouteDestination( &m_value ); + ( *it )->RerouteDestination( &m_value ); } } } @@ -306,7 +306,7 @@ void Tr2Vector4Parameter::RegisterBinding( TriValueBinding* vb ) { CCP_ASSERT( vb ); - // Note that this is a weak reference - adding a reference here would + // Note that this is a weak reference - adding a reference here would // create a circular reference. m_bindings.push_back( vb ); } @@ -335,7 +335,7 @@ void Tr2Vector4Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) SetDestination( NULL, 0 ); } - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { m_isUsedByEffect = false; return; @@ -343,7 +343,7 @@ void Tr2Vector4Parameter::RebuildEffectHandles( Tr2Shader* effectRes ) const Tr2EffectConstant* constant = effectRes->GetConstant( m_name.c_str() ); - if ( !constant ) + if( !constant ) { m_isUsedByEffect = false; return; diff --git a/trinity/Shader/Parameter/Tr2Vector4Parameter.h b/trinity/Shader/Parameter/Tr2Vector4Parameter.h index c98294a7b..a02155cfc 100644 --- a/trinity/Shader/Parameter/Tr2Vector4Parameter.h +++ b/trinity/Shader/Parameter/Tr2Vector4Parameter.h @@ -10,7 +10,7 @@ BLUE_DECLARE( Tr2Vector4Parameter ); BLUE_CLASS_ALLOW_DELAYED_DELETE( Tr2Vector4Parameter ); -BLUE_CLASS( Tr2Vector4Parameter ): +BLUE_CLASS( Tr2Vector4Parameter ) : public ITriEffectParameter, public ITriReroutable, public IInitialize @@ -19,7 +19,7 @@ BLUE_CLASS( Tr2Vector4Parameter ): public: EXPOSE_TO_BLUE(); - Tr2Vector4Parameter(IRoot* lockobj = NULL); + Tr2Vector4Parameter( IRoot* lockobj = NULL ); using ITriEffectParameter::Lock; using ITriEffectParameter::Unlock; @@ -37,20 +37,20 @@ BLUE_CLASS( Tr2Vector4Parameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); unsigned GetHashValue( unsigned startingHash ) const; ///////////////////////////////////////////////////////////////////////////////////// // ITriReroutable void SetDestination( void* dest, size_t size ); void GetDestination( void*& dest, size_t& size ); - void RegisterBinding( TriValueBinding* vb ); - void UnregisterBinding( TriValueBinding* vb ); + void RegisterBinding( TriValueBinding * vb ); + void UnregisterBinding( TriValueBinding * vb ); bool IsRerouted() const; ////////////////////////////////////////////////////////////////////////// @@ -81,4 +81,4 @@ BLUE_CLASS( Tr2Vector4Parameter ): TYPEDEF_BLUECLASS( Tr2Vector4Parameter ); -#endif +#endif diff --git a/trinity/Shader/Parameter/Tr2Vector4Parameter_Blue.cpp b/trinity/Shader/Parameter/Tr2Vector4Parameter_Blue.cpp index 3b8ab77f6..715beb5a9 100644 --- a/trinity/Shader/Parameter/Tr2Vector4Parameter_Blue.cpp +++ b/trinity/Shader/Parameter/Tr2Vector4Parameter_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2Vector4Parameter ); const Be::ClassInfo* Tr2Vector4Parameter::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2Vector4Parameter, "" ) + EXPOSURE_BEGIN( Tr2Vector4Parameter, "" ) MAP_INTERFACE( ITriEffectParameter ) MAP_INTERFACE( Tr2Vector4Parameter ) MAP_INTERFACE( ITriReroutable ) @@ -15,99 +15,77 @@ const Be::ClassInfo* Tr2Vector4Parameter::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - m_name, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "value", m_value, "", - Be::PERSISTONLY - ) - - MAP_PROPERTY - ( - "value", - GetValue, - SetValue, - "Value of the Vector3 parameter" - ) - - MAP_PROPERTY - ( + Be::PERSISTONLY ) + + MAP_PROPERTY( + "value", + GetValue, + SetValue, + "Value of the Vector3 parameter" ) + + MAP_PROPERTY( "x", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "y", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "z", GetZ, SetZ, - "Z component value" - ) + "Z component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "w", GetW, SetW, - "W component value" - ) + "W component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v1", GetX, SetX, - "X component value" - ) + "X component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v2", GetY, SetY, - "Y component value" - ) + "Y component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v3", GetZ, SetZ, - "Z component value" - ) + "Z component value" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "v4", GetW, SetW, - "W component value" - ) + "W component value" ) //////////////////////////////////////////////////////////////////////////// MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) MAP_ATTRIBUTE( "isSrgb", m_isSrgb, "indicates if (rgb) values will be converted to linear space", Be::READ ) - + EXPOSURE_END() } diff --git a/trinity/Shader/Parameter/TriFloatArrayParameter.cpp b/trinity/Shader/Parameter/TriFloatArrayParameter.cpp index f86b84b86..00fa132e5 100644 --- a/trinity/Shader/Parameter/TriFloatArrayParameter.cpp +++ b/trinity/Shader/Parameter/TriFloatArrayParameter.cpp @@ -13,14 +13,13 @@ TriVector4::TriVector4( IRoot* lockobj ) : // ------------------------------------------------------------------------------------------------------ TriVector4::~TriVector4() { - } // ------------------------------------------------------------------------------------------------------ -TriFloatArrayParameter::TriFloatArrayParameter( IRoot* lockobj ): +TriFloatArrayParameter::TriFloatArrayParameter( IRoot* lockobj ) : PARENTLOCK( m_value ), m_isUsedByEffect( false ) { @@ -57,16 +56,16 @@ unsigned TriFloatArrayParameter::GetHashValue( unsigned startingHash ) const } // ------------------------------------------------------------------------------------------------------ -void TriFloatArrayParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, +void TriFloatArrayParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const + Tr2RenderContext& renderContext ) const { unsigned char* pDst = destHandle; size_t bytesCopied = 0; for( PTriVector4Vector::const_iterator it = m_value.begin(); it != m_value.end(); ++it ) { - memcpy( pDst, &((*it)->m_data), sizeof( Vector4 ) ); + memcpy( pDst, &( ( *it )->m_data ), sizeof( Vector4 ) ); pDst += sizeof( Vector4 ); bytesCopied += sizeof( Vector4 ); if( bytesCopied >= size ) @@ -80,7 +79,7 @@ void TriFloatArrayParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType void TriFloatArrayParameter::RebuildEffectHandles( Tr2Shader* effectRes ) { m_cachedEffect = effectRes; - if ( m_name.empty() || !effectRes || !effectRes->GetConstant( m_name.c_str() ) ) + if( m_name.empty() || !effectRes || !effectRes->GetConstant( m_name.c_str() ) ) { m_isUsedByEffect = false; return; diff --git a/trinity/Shader/Parameter/TriFloatArrayParameter.h b/trinity/Shader/Parameter/TriFloatArrayParameter.h index 00fd1be29..ec4eb26af 100644 --- a/trinity/Shader/Parameter/TriFloatArrayParameter.h +++ b/trinity/Shader/Parameter/TriFloatArrayParameter.h @@ -10,7 +10,8 @@ BLUE_DECLARE( Tr2Shader ); //-------------------------------------------------------------------------------------------------- // vector4 - is content of the parameter array, TODO: make it more flexible content // -BLUE_CLASS( TriVector4 ) : public IRoot +BLUE_CLASS( TriVector4 ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -18,8 +19,8 @@ BLUE_CLASS( TriVector4 ) : public IRoot TriVector4( IRoot* lockobj = 0 ); ~TriVector4(); - using IRoot::Lock; - using IRoot::Unlock; + using IRoot::Lock; + using IRoot::Unlock; // the actuall data Vector4 m_data; @@ -30,7 +31,7 @@ BLUE_DECLARE_VECTOR( TriVector4 ); //-------------------------------------------------------------------------------------------------- // float array parameter // -BLUE_CLASS( TriFloatArrayParameter ): +BLUE_CLASS( TriFloatArrayParameter ) : public ITriEffectParameter, public INotify, public IInitialize @@ -38,7 +39,7 @@ BLUE_CLASS( TriFloatArrayParameter ): public: EXPOSE_TO_BLUE(); - TriFloatArrayParameter(IRoot* lockobj = NULL); + TriFloatArrayParameter( IRoot* lockobj = NULL ); ~TriFloatArrayParameter(); using ITriEffectParameter::Lock; @@ -52,21 +53,24 @@ BLUE_CLASS( TriFloatArrayParameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter - void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); unsigned GetHashValue( unsigned startingHash ) const; ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize - bool Initialize() { return true; }; + bool Initialize() + { + return true; + }; // This is just here to prevent us from getting an "on modified" call while blue is still reading the member table private: @@ -76,4 +80,4 @@ BLUE_CLASS( TriFloatArrayParameter ): BLUE_CLASS_ALLOW_DELAYED_DELETE( TriFloatArrayParameter ); TYPEDEF_BLUECLASS( TriFloatArrayParameter ); -#endif +#endif diff --git a/trinity/Shader/Parameter/TriFloatArrayParameter_Blue.cpp b/trinity/Shader/Parameter/TriFloatArrayParameter_Blue.cpp index 7d79747ea..ab09c7a8e 100644 --- a/trinity/Shader/Parameter/TriFloatArrayParameter_Blue.cpp +++ b/trinity/Shader/Parameter/TriFloatArrayParameter_Blue.cpp @@ -5,13 +5,12 @@ BLUE_DEFINE( TriVector4 ); -const Be::ClassInfo* TriVector4::ExposeToBlue() -{ +const Be::ClassInfo* TriVector4::ExposeToBlue(){ EXPOSURE_BEGIN( TriVector4, "" ) - MAP_INTERFACE( TriVector4 ) + MAP_INTERFACE( TriVector4 ) - MAP_ATTRIBUTE( "data", m_data, "na", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + MAP_ATTRIBUTE( "data", m_data, "na", Be::READWRITE | Be::PERSIST ) + EXPOSURE_END() } diff --git a/trinity/Shader/Parameter/TriTextureParameter.cpp b/trinity/Shader/Parameter/TriTextureParameter.cpp index 36c5eb7b1..b913d4beb 100644 --- a/trinity/Shader/Parameter/TriTextureParameter.cpp +++ b/trinity/Shader/Parameter/TriTextureParameter.cpp @@ -9,7 +9,7 @@ #include "Resources/TriTextureRes.h" -TriTextureParameter::TriTextureParameter(IRoot* lockobj): +TriTextureParameter::TriTextureParameter( IRoot* lockobj ) : m_resourceType( Tr2EffectResource::TEXTURE_TYPELESS ), m_uavMipLevel( 0 ), m_isUsedByEffect( false ), @@ -137,7 +137,7 @@ void TriTextureParameter::DisableTextureLoding() m_textureLodEnabled = false; } -bool TriTextureParameter::OnModified( Be::Var* val ) +bool TriTextureParameter::OnModified( Be::Var* val ) { if( m_resource ) { @@ -162,7 +162,7 @@ void TriTextureParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, unsigned char* destHandle, size_t size, - Tr2RenderContext& renderContext) const + Tr2RenderContext& renderContext ) const { uint32_t value = m_cachedSrvIndex[m_bindlessColorSpace]; memcpy( destHandle, &value, std::min( size, sizeof( value ) ) ); @@ -292,8 +292,8 @@ ITr2TextureProvider* TriTextureParameter::GetResource() const // Description: // Copies any resource that was dynamically assigned to the parameter to the new copy // -------------------------------------------------------------------------------------- -bool TriTextureParameter::AssignTo( ICopierCustomAssignment* other, - ICopier* copier ) +bool TriTextureParameter::AssignTo( ICopierCustomAssignment* other, + ICopier* copier ) { if( m_resourcePath.empty() && m_resource ) { @@ -319,7 +319,7 @@ void TriTextureParameter::RebuildEffectHandles( Tr2Shader* effectRes ) m_cachedEffect = effectRes; m_isUsedByEffect = false; - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { return; } diff --git a/trinity/Shader/Parameter/TriTextureParameter.h b/trinity/Shader/Parameter/TriTextureParameter.h index 6ae1ec2af..2810e4b0b 100644 --- a/trinity/Shader/Parameter/TriTextureParameter.h +++ b/trinity/Shader/Parameter/TriTextureParameter.h @@ -1,7 +1,7 @@ // Copyright © 2006 CCP ehf. #pragma once -#if !defined( _TriTextureParameter_H_) +#if !defined( _TriTextureParameter_H_ ) #define _TriTextureParameter_H_ #include "include/ITriEffectParameter.h" @@ -14,7 +14,7 @@ BLUE_CLASS_ALLOW_DELAYED_DELETE( TriTextureParameter ); BLUE_DECLARE( TriTextureRes ); -BLUE_CLASS( TriTextureParameter ): +BLUE_CLASS( TriTextureParameter ) : public ITriEffectTextureParameter, public IInitialize, public INotify, @@ -22,7 +22,7 @@ BLUE_CLASS( TriTextureParameter ): { public: - TriTextureParameter(IRoot* lockobj = NULL); + TriTextureParameter( IRoot* lockobj = NULL ); ~TriTextureParameter(); EXPOSE_TO_BLUE(); @@ -30,7 +30,7 @@ BLUE_CLASS( TriTextureParameter ): ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter const char* GetParameterName() const; - void RebuildEffectHandles( Tr2Shader* effectRes ); + void RebuildEffectHandles( Tr2Shader * effectRes ); ////////////////////////////////////////////////////////////////////////// // ITriEffectTextureParameter @@ -40,15 +40,15 @@ BLUE_CLASS( TriTextureParameter ): size_t size, Tr2RenderContext& renderContext ) const override; virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const; virtual bool ApplyUav( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const; - void AddUsedTexture( Tr2BindlessResourcesAL& usedTextures ) const override; + void AddUsedTexture( Tr2BindlessResourcesAL & usedTextures ) const override; unsigned GetHashValue( unsigned startingHash ) const; bool SupportsDirtyNotification() const override; @@ -56,12 +56,12 @@ BLUE_CLASS( TriTextureParameter ): void EnableTextureLoding( const std::array& uvDensityScale ) override; void DisableTextureLoding() override; - void OnAddedToMaterial( Tr2Material* material ) override; - void OnRemovedFromMaterial( Tr2Material* material ) override; + void OnAddedToMaterial( Tr2Material * material ) override; + void OnRemovedFromMaterial( Tr2Material * material ) override; ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -72,15 +72,14 @@ BLUE_CLASS( TriTextureParameter ): // ICopierCustomAssignment ///////////////////////////////////////////////////////////////////////////////////// virtual bool AssignTo( - ICopierCustomAssignment* other, - ICopier* copier - ); + ICopierCustomAssignment * other, + ICopier * copier ); // access resource - void SetResource( ITr2TextureProvider* newRes ); - + void SetResource( ITr2TextureProvider * newRes ); + virtual ITr2TextureProvider* GetResource() const; - + // access strings void SetParameterName( const BlueSharedString& name ); const wchar_t* GetResourcePath() const; @@ -115,5 +114,5 @@ BLUE_CLASS( TriTextureParameter ): std::string m_resourcePath; }; -TYPEDEF_BLUECLASS(TriTextureParameter); -#endif +TYPEDEF_BLUECLASS( TriTextureParameter ); +#endif diff --git a/trinity/Shader/Parameter/TriTextureParameter_Blue.cpp b/trinity/Shader/Parameter/TriTextureParameter_Blue.cpp index 109980fc8..81c72cd0c 100644 --- a/trinity/Shader/Parameter/TriTextureParameter_Blue.cpp +++ b/trinity/Shader/Parameter/TriTextureParameter_Blue.cpp @@ -22,31 +22,26 @@ const Be::ClassInfo* TriTextureParameter::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - m_name, - "na", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "na", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // resource path (texture / buffer) // TODO: Add valid chooser - MAP_ATTRIBUTE_WITH_CHOOSER( - "resourcePath", - m_resourcePath, - "Resource path to .x file", + MAP_ATTRIBUTE_WITH_CHOOSER( + "resourcePath", + m_resourcePath, + "Resource path to .x file", Be::READWRITE | Be::NOTIFY | Be::PERSIST, - NULL - ) + NULL ) //////////////////////////////////////////////////////////////////////////// - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "resource", m_resource, "na", - Be::READ - ) + Be::READ ) MAP_ATTRIBUTE( "uavMipLevel", m_uavMipLevel, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "positionScale", m_uvDensityScale[0], "Model position sampling density scale modifier for texture LOD\n:jessica-group: LOD", Be::READ ) @@ -56,17 +51,15 @@ const Be::ClassInfo* TriTextureParameter::ExposeToBlue() MAP_ATTRIBUTE( "uvDensityScale3", m_uvDensityScale[4], "UV3 density scale modifier for texture LOD\n:jessica-group: LOD", Be::READ ) //////////////////////////////////////////////////////////////////////////// - MAP_ATTRIBUTE("usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ) - MAP_ATTRIBUTE("usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ) + MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) - MAP_METHOD_AND_WRAP( - "SetResource", - SetResource, + MAP_METHOD_AND_WRAP( + "SetResource", + SetResource, "Takes a TriTextureRes and sets it directly, without using a resourcePath.\n" - ":param resource: new texture resource" - ) + ":param resource: new texture resource" ) MAP_METHOD_AND_WRAP( "GetResourcePath", GetResourcePath, "Returns the respath to the currently used texture. Might be LOD dependent." ) - EXPOSURE_END( ) + EXPOSURE_END() } - diff --git a/trinity/Shader/Parameter/TriTransformParameter.cpp b/trinity/Shader/Parameter/TriTransformParameter.cpp index 265c427e1..41b0cf9c4 100644 --- a/trinity/Shader/Parameter/TriTransformParameter.cpp +++ b/trinity/Shader/Parameter/TriTransformParameter.cpp @@ -5,7 +5,7 @@ #include "Tr2Renderer.h" #include "include/TriMath.h" -TriTransformParameter::TriTransformParameter(IRoot* lockobj): +TriTransformParameter::TriTransformParameter( IRoot* lockobj ) : m_scaling( 1.0f, 1.0f, 1.0f ), m_rotationCenter( 0.0f, 0.0f, 0.0f ), m_rotation( 0.0f, 0.0f, 0.0f, 1.0f ), @@ -18,24 +18,22 @@ TriTransformParameter::TriTransformParameter(IRoot* lockobj): unsigned TriTransformParameter::GetHashValue( unsigned startingHash ) const { auto name = m_name.c_str(); - return CcpHashFNV1( &name, sizeof( name ), - CcpHashFNV1( &m_transformBase, sizeof( TRITRANSFORMBASE ) + 3 * sizeof( Vector3 ) + sizeof( Quaternion ) + sizeof( Matrix ), startingHash ) ); + return CcpHashFNV1( &name, sizeof( name ), CcpHashFNV1( &m_transformBase, sizeof( TRITRANSFORMBASE ) + 3 * sizeof( Vector3 ) + sizeof( Quaternion ) + sizeof( Matrix ), startingHash ) ); } -void TriTransformParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* dest, - size_t size, - Tr2RenderContext &renderContext ) const +void TriTransformParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* dest, + size_t size, + Tr2RenderContext& renderContext ) const { - // Calculate transform - this code is based on TriTexture and emulates old Trinity: + // Calculate transform - this code is based on TriTexture and emulates old Trinity: Matrix original = TransformationMatrix( NULL, NULL, &m_scaling, &m_rotationCenter, &m_rotation, - &m_translation - ); + &m_translation ); Matrix texTransform; if( m_transformBase == TRITB_FIXED ) @@ -45,17 +43,17 @@ void TriTransformParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType else { texTransform = Tr2Renderer::GetInverseViewTransform(); - texTransform._41 = texTransform._42 = texTransform._43 = 0.0f; + texTransform._41 = texTransform._42 = texTransform._43 = 0.0f; if( m_transformBase == TRITB_OBJECT ) { // this is maybe a bit un orthodox. What is done here is that the inverse - // of the rotation part of the view matrix is taken to make the - // texture move against the camera (this is neccesary to project + // of the rotation part of the view matrix is taken to make the + // texture move against the camera (this is neccesary to project // cube maps correctly, strange why this is needed to be this explicit should // be the default behariour, well). Then the rotation part of the object // is also taken to make the texture rotatio with the object. Translation - // is not used because it is difficould to having make sense (only scenario I can + // is not used because it is difficould to having make sense (only scenario I can // think of is some kind of cube spot lights, or something) // Later it turned out that this could be used to perfectly bumpmap // rotating asteroids. @@ -67,12 +65,11 @@ void TriTransformParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType mat._41 = mat._42 = mat._43 = 0.0f; texTransform = texTransform * mat; } - else if( (m_transformBase == TRITB_CAMERA_ROTATION) - ||(m_transformBase == TRITB_CAMERA_ROTATION_ALIGNED) ) + else if( ( m_transformBase == TRITB_CAMERA_ROTATION ) || ( m_transformBase == TRITB_CAMERA_ROTATION_ALIGNED ) ) { // Note that this has to be from the scenes camera as the UI will not get // rotation effects if the view matrix is used. - texTransform._41 = texTransform._42 = texTransform._43 = 0.0f; + texTransform._41 = texTransform._42 = texTransform._43 = 0.0f; } texTransform *= original; diff --git a/trinity/Shader/Parameter/TriTransformParameter.h b/trinity/Shader/Parameter/TriTransformParameter.h index c52593cd7..f981a9f9e 100644 --- a/trinity/Shader/Parameter/TriTransformParameter.h +++ b/trinity/Shader/Parameter/TriTransformParameter.h @@ -12,13 +12,11 @@ BLUE_DECLARE( TriTransformParameter ); BLUE_CLASS_ALLOW_DELAYED_DELETE( TriTransformParameter ); -class TriTransformParameter: - public ITriEffectParameter +class TriTransformParameter : public ITriEffectParameter { public: - - TriTransformParameter(IRoot* lockobj = NULL); + TriTransformParameter( IRoot* lockobj = NULL ); ~TriTransformParameter() {}; using ITriEffectParameter::Lock; @@ -27,11 +25,14 @@ class TriTransformParameter: ///////////////////////////////////////////////////////////////////////////////////// // ITriEffectParameter ///////////////////////////////////////////////////////////////////////////////////// - virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; - const char* GetParameterName() const { return m_name.c_str(); } + Tr2RenderContext& renderContext ) const; + const char* GetParameterName() const + { + return m_name.c_str(); + } // The following methods are potentially used by the old scene. This parameter will // never be used there so I'm simply going to stub them out. void RebuildEffectHandles( Tr2Shader* effectRes ) {}; @@ -43,7 +44,7 @@ class TriTransformParameter: private: BlueSharedString m_name; - TRITRANSFORMBASE m_transformBase; + TRITRANSFORMBASE m_transformBase; Vector3 m_scaling; Vector3 m_rotationCenter; Quaternion m_rotation; @@ -51,6 +52,6 @@ class TriTransformParameter: Matrix m_worldTransform; }; -TYPEDEF_BLUECLASS(TriTransformParameter); +TYPEDEF_BLUECLASS( TriTransformParameter ); -#endif +#endif diff --git a/trinity/Shader/Parameter/TriTransformParameter_Blue.cpp b/trinity/Shader/Parameter/TriTransformParameter_Blue.cpp index 3260934ff..0f5b4c1e9 100644 --- a/trinity/Shader/Parameter/TriTransformParameter_Blue.cpp +++ b/trinity/Shader/Parameter/TriTransformParameter_Blue.cpp @@ -16,14 +16,11 @@ const Be::ClassInfo* TriTransformParameter::ExposeToBlue() MAP_ATTRIBUTE( "rotationCenter", m_rotationCenter, "Center of rotation in transform", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rotation", m_rotation, "Rotation in transform", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "translation", m_translation, "Translation in transform", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, - "World transform. This needs to be filled in from the outside,\n" - "for example with a TriValueBinding from the worldTransform of the\n" - "object holding the effect this is used in.", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "World transform. This needs to be filled in from the outside,\n" + "for example with a TriValueBinding from the worldTransform of the\n" + "object holding the effect this is used in.", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "transformBase", m_transformBase, "Funky transform base from old Trinity", Be::READWRITE | Be::PERSIST | Be::ENUM, TriTransformBase ) EXPOSURE_END() } - diff --git a/trinity/Shader/Parameter/TriVariableParameter.cpp b/trinity/Shader/Parameter/TriVariableParameter.cpp index 72104ecd0..31d996368 100644 --- a/trinity/Shader/Parameter/TriVariableParameter.cpp +++ b/trinity/Shader/Parameter/TriVariableParameter.cpp @@ -5,7 +5,7 @@ #include "Tr2VariableStore.h" #include "Shader/Tr2Shader.h" -TriVariableParameter::TriVariableParameter(IRoot* lockobj): +TriVariableParameter::TriVariableParameter( IRoot* lockobj ) : m_isUsedByEffect( false ), m_variable( NULL ) { @@ -46,12 +46,12 @@ bool TriVariableParameter::Initialize() { if( !m_variableName.empty() ) { - m_variable = GlobalStore().GetVariable( m_variableName.c_str() ); + m_variable = GlobalStore().GetVariable( m_variableName.c_str() ); } - else - { + else + { m_variable = NULL; - } + } return true; } @@ -82,10 +82,10 @@ bool TriVariableParameter::ApplyUav( return resourceDesc.SetUav( stage, registerIndex, Tr2TextureAL() ); } -void TriVariableParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void TriVariableParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { if( m_variable ) { @@ -94,8 +94,8 @@ void TriVariableParameter::CopyValueToEffect( Tr2RenderContextEnum::ShaderType i } int TriVariableParameter::GetVariableType() const -{ - return m_variable ? m_variable->GetType() : TRIVARIABLE_INVALID; +{ + return m_variable ? m_variable->GetType() : TRIVARIABLE_INVALID; } void TriVariableParameter::RebuildEffectHandles( Tr2Shader* effectRes ) @@ -104,14 +104,14 @@ void TriVariableParameter::RebuildEffectHandles( Tr2Shader* effectRes ) m_isUsedByEffect = false; - if ( m_name.empty() || !effectRes ) + if( m_name.empty() || !effectRes ) { return; } if( m_variable ) { - if( m_variable->GetType() == TRIVARIABLE_TEXTURE_RES ) + if( m_variable->GetType() == TRIVARIABLE_TEXTURE_RES ) { if( !effectRes->GetResource( m_name.c_str() ) ) { diff --git a/trinity/Shader/Parameter/TriVariableParameter.h b/trinity/Shader/Parameter/TriVariableParameter.h index 2cb6b5b32..fd2bfc449 100644 --- a/trinity/Shader/Parameter/TriVariableParameter.h +++ b/trinity/Shader/Parameter/TriVariableParameter.h @@ -12,16 +12,15 @@ BLUE_CLASS_ALLOW_DELAYED_DELETE( TriVariableParameter ); BLUE_DECLARE( Tr2Shader ); -class TriVariableParameter: - public ITriEffectParameter, - public INotify, - public IInitialize +class TriVariableParameter : public ITriEffectParameter, + public INotify, + public IInitialize { public: EXPOSE_TO_BLUE(); - TriVariableParameter(IRoot* lockobj = NULL); + TriVariableParameter( IRoot* lockobj = NULL ); ~TriVariableParameter(); using ITriEffectParameter::Lock; @@ -46,10 +45,10 @@ class TriVariableParameter: Tr2ResourceSetDescriptionAL& resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const; - virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const; + virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const; const char* GetParameterName() const; void RebuildEffectHandles( Tr2Shader* effectRes ); unsigned GetHashValue( unsigned startingHash ) const; @@ -65,10 +64,10 @@ class TriVariableParameter: bool Initialize(); private: - int GetVariableType() const; + int GetVariableType() const; Tr2ShaderPtr m_cachedEffect; }; -TYPEDEF_BLUECLASS(TriVariableParameter); +TYPEDEF_BLUECLASS( TriVariableParameter ); -#endif +#endif diff --git a/trinity/Shader/Parameter/TriVariableParameter_Blue.cpp b/trinity/Shader/Parameter/TriVariableParameter_Blue.cpp index 199f36211..f5073abf0 100644 --- a/trinity/Shader/Parameter/TriVariableParameter_Blue.cpp +++ b/trinity/Shader/Parameter/TriVariableParameter_Blue.cpp @@ -14,29 +14,25 @@ const Be::ClassInfo* TriVariableParameter::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - m_name, - "Effect parameter name from .fx file", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "Effect parameter name from .fx file", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// - MAP_ATTRIBUTE( - "variableName", - m_variableName, - "Name of variable managed by TriDevice", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + MAP_ATTRIBUTE( + "variableName", + m_variableName, + "Name of variable managed by TriDevice", + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// - MAP_PROPERTY_READONLY( - "variableType", - GetVariableType, - "Type of variable (0 is invalid)" - ) + MAP_PROPERTY_READONLY( + "variableType", + GetVariableType, + "Type of variable (0 is invalid)" ) //////////////////////////////////////////////////////////////////////////// - MAP_ATTRIBUTE("usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ) - MAP_ATTRIBUTE("usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ) + MAP_ATTRIBUTE( "usedByCurrentTechnique", m_isUsedByEffect, "na", Be::READ ) + MAP_ATTRIBUTE( "usedByCurrentEffect", m_isUsedByEffect, "na", Be::READ ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Shader/Tr2Effect.cpp b/trinity/Shader/Tr2Effect.cpp index 7b629d54e..ec59b317a 100644 --- a/trinity/Shader/Tr2Effect.cpp +++ b/trinity/Shader/Tr2Effect.cpp @@ -24,89 +24,64 @@ BLUE_DEFINE_INTERFACE( ITr2EffectValue ); BLUE_DEFINE_INTERFACE( ITr2ScreenSizeAwareValue ); -#define INVALID_PARAMETER_HASH (~0) +#define INVALID_PARAMETER_HASH ( ~0 ) using namespace Tr2RenderContextEnum; bool GetBool( const Tr2Shader* shaderState, const char* paramName, const char* annotationName, bool defaultValue = false ); -static BlueStructureDefinition Tr2EffectParameterStructureDef[] = -{ - { "name", Be::SHAREDSTRING_1, 0 }, - { "value", Be::FLOAT32_4, 8 }, - {0} +static BlueStructureDefinition Tr2EffectParameterStructureDef[] = { + { "name", Be::SHAREDSTRING_1, 0 }, + { "value", Be::FLOAT32_4, 8 }, + { 0 } }; -Be::VarChooser SamplerStateChooser_AddressMode[] = -{ - { - "Wrap", - BeCast( Tr2RenderContextEnum::TA_WRAP ), - "Texture is wrapped" - }, - { - "Clamp", - BeCast( Tr2RenderContextEnum::TA_CLAMP ), - "Texture is clamped" - }, - { - "Mirror", - BeCast( Tr2RenderContextEnum::TA_MIRROR ), - "Texture is mirrored" - }, +Be::VarChooser SamplerStateChooser_AddressMode[] = { + { "Wrap", + BeCast( Tr2RenderContextEnum::TA_WRAP ), + "Texture is wrapped" }, + { "Clamp", + BeCast( Tr2RenderContextEnum::TA_CLAMP ), + "Texture is clamped" }, + { "Mirror", + BeCast( Tr2RenderContextEnum::TA_MIRROR ), + "Texture is mirrored" }, { 0 } }; -Be::VarChooser SamplerStateChooser_FilterMode[] = -{ - { - "Point", - BeCast( Tr2RenderContextEnum::TF_POINT ), - "Texture is not filtered" - }, - { - "Linear", - BeCast( Tr2RenderContextEnum::TF_LINEAR ), - "Texture is filtered: linear" - }, - { - "Anisotropic", - BeCast( Tr2RenderContextEnum::TF_ANISOTROPIC ), - "Texture is filtered: anisotropic" - }, +Be::VarChooser SamplerStateChooser_FilterMode[] = { + { "Point", + BeCast( Tr2RenderContextEnum::TF_POINT ), + "Texture is not filtered" }, + { "Linear", + BeCast( Tr2RenderContextEnum::TF_LINEAR ), + "Texture is filtered: linear" }, + { "Anisotropic", + BeCast( Tr2RenderContextEnum::TF_ANISOTROPIC ), + "Texture is filtered: anisotropic" }, { 0 } }; -Be::VarChooser SamplerStateChooser_MipFilterMode[] = -{ - { - "None", - BeCast( Tr2RenderContextEnum::TF_NONE ), - "Disable Mipmaps" - }, - { - "Point", - BeCast( Tr2RenderContextEnum::TF_POINT ), - "Mipmaps are not filtered" - }, - { - "Linear", - BeCast( Tr2RenderContextEnum::TF_LINEAR ), - "Mipmaps are filtered: linear" - }, - { - "Anisotropic", - BeCast( Tr2RenderContextEnum::TF_ANISOTROPIC ), - "Mipmaps are filtered: anisotropic" - }, +Be::VarChooser SamplerStateChooser_MipFilterMode[] = { + { "None", + BeCast( Tr2RenderContextEnum::TF_NONE ), + "Disable Mipmaps" }, + { "Point", + BeCast( Tr2RenderContextEnum::TF_POINT ), + "Mipmaps are not filtered" }, + { "Linear", + BeCast( Tr2RenderContextEnum::TF_LINEAR ), + "Mipmaps are filtered: linear" }, + { "Anisotropic", + BeCast( Tr2RenderContextEnum::TF_ANISOTROPIC ), + "Mipmaps are filtered: anisotropic" }, { 0 } }; namespace { -BlueStructureDefinition Tr2SamplerOverrideStructureDef[] = -{ +BlueStructureDefinition Tr2SamplerOverrideStructureDef[] = { { "name", Be::SHAREDSTRING_1, offsetof( Tr2SamplerOverride, name ) }, { "addressU", Be::UINT32_1, offsetof( Tr2SamplerOverride, addressU ), SamplerStateChooser_AddressMode }, { "addressV", Be::UINT32_1, offsetof( Tr2SamplerOverride, addressV ), SamplerStateChooser_AddressMode }, @@ -116,7 +91,7 @@ BlueStructureDefinition Tr2SamplerOverrideStructureDef[] = { "lodBias", Be::FLOAT32_1, offsetof( Tr2SamplerOverride, lodBias ) }, { "maxMipLevel", Be::UINT32_1, offsetof( Tr2SamplerOverride, maxMipLevel ) }, { "maxAnisotropy", Be::UINT32_1, offsetof( Tr2SamplerOverride, maxAnisotropy ) }, - {0} + { 0 } }; Tr2SamplerOverride s_defaultValue = { @@ -132,11 +107,10 @@ Tr2SamplerOverride s_defaultValue = { }; -BlueStructureDefinition Tr2ShaderOptionStructureDef[] = -{ +BlueStructureDefinition Tr2ShaderOptionStructureDef[] = { { "name", Be::SHAREDSTRING_1, offsetof( Tr2ShaderOption, name ) }, { "value", Be::SHAREDSTRING_1, offsetof( Tr2ShaderOption, value ) }, - {0} + { 0 } }; @@ -149,8 +123,8 @@ BlueStructureDefinition Tr2ShaderOptionStructureDef[] = // adder - callback function that's in charge of actually adding the newly created parameter // -------------------------------------------------------------------------------------- void ConvertEffectConstant( const Tr2EffectConstant& constant, - const char* constantValues, - std::function adder ) + const char* constantValues, + std::function adder ) { if( constant.type != Tr2EffectConstant::FLOAT ) { @@ -159,7 +133,7 @@ void ConvertEffectConstant( const Tr2EffectConstant& constant, if( constant.elements > 1 ) { // create new paramater - OTriFloatArrayParameter* newFloatArray = new OTriFloatArrayParameter(); // Creates object with 1 lock + OTriFloatArrayParameter* newFloatArray = new OTriFloatArrayParameter(); // Creates object with 1 lock newFloatArray->m_name = BlueSharedString( constant.name ); // create an instance for each vector4 for( unsigned int e = 0; e < constant.elements; ++e ) @@ -194,7 +168,7 @@ void ConvertEffectConstant( const Tr2EffectConstant& constant, } else if( constant.dimension == 2 ) { - OTr2Vector2Parameter* newVector2 = new OTr2Vector2Parameter(); // Creates object with 1 lock + OTr2Vector2Parameter* newVector2 = new OTr2Vector2Parameter(); // Creates object with 1 lock newVector2->m_name = BlueSharedString( constant.name ); newVector2->m_value = *reinterpret_cast( constantValues + constant.offset ); adder( newVector2 ); @@ -202,7 +176,7 @@ void ConvertEffectConstant( const Tr2EffectConstant& constant, } else if( constant.dimension == 3 ) { - OTr2Vector3Parameter* newVector3 = new OTr2Vector3Parameter(); // Creates object with 1 lock + OTr2Vector3Parameter* newVector3 = new OTr2Vector3Parameter(); // Creates object with 1 lock newVector3->m_name = BlueSharedString( constant.name ); newVector3->m_value = *reinterpret_cast( constantValues + constant.offset ); adder( newVector3 ); @@ -210,7 +184,7 @@ void ConvertEffectConstant( const Tr2EffectConstant& constant, } else if( constant.dimension > 1 ) { - OTr2Vector4Parameter* newVector4 = new OTr2Vector4Parameter(); // Creates object with 1 lock + OTr2Vector4Parameter* newVector4 = new OTr2Vector4Parameter(); // Creates object with 1 lock newVector4->m_name = BlueSharedString( constant.name ); newVector4->m_value = *reinterpret_cast( constantValues + constant.offset ); adder( newVector4 ); @@ -235,8 +209,8 @@ void ConvertEffectConstant( const Tr2EffectConstant& constant, // resourceAdder - callback function that's in charge of actually adding any newly created resources // -------------------------------------------------------------------------------------- void ConvertEffectResource( const Tr2EffectResource& resource, - std::function paramAdder, - std::function resourceAdder ) + std::function paramAdder, + std::function resourceAdder ) { switch( resource.type ) { @@ -244,16 +218,14 @@ void ConvertEffectResource( const Tr2EffectResource& resource, case Tr2EffectResource::TEXTURE_1D: case Tr2EffectResource::TEXTURE_2D: case Tr2EffectResource::TEXTURE_3D: - case Tr2EffectResource::TEXTURE_TYPELESS: - { + case Tr2EffectResource::TEXTURE_TYPELESS: { OTriTextureParameter* newTex2D = new OTriTextureParameter(); newTex2D->SetParameterName( BlueSharedString( resource.name ) ); resourceAdder( newTex2D ); newTex2D->Unlock(); // Remove the original lock created by 'new'. } break; - default: - { + default: { OTr2GeometryBufferParameter* newBuffer = new OTr2GeometryBufferParameter(); newBuffer->m_name = BlueSharedString( resource.name ); resourceAdder( newBuffer ); @@ -266,14 +238,14 @@ void ConvertEffectResource( const Tr2EffectResource& resource, } // --------------------------------------------------------------- -Tr2Effect::Tr2Effect(IRoot* lockobj) : - #if TRINITYDEV - m_insideBegin( false ), - m_insideBeginPass( false ), - #endif +Tr2Effect::Tr2Effect( IRoot* lockobj ) : +#if TRINITYDEV + m_insideBegin( false ), + m_insideBeginPass( false ), +#endif m_insideStartUpdate( false ), - PARENTLOCK(m_parameters), - PARENTLOCK(m_resources), + PARENTLOCK( m_parameters ), + PARENTLOCK( m_resources ), PARENTLOCK( m_constParameters ), PARENTLOCK( m_samplerOverrides ), PARENTLOCK( m_options ), @@ -320,7 +292,7 @@ void Tr2Effect::ReleaseResources( TriStorage s ) stage.m_constantBuffer = Tr2ConstantBufferAL(); } } - for (auto& library : technique.libraries) + for( auto& library : technique.libraries ) { library->m_globalInput.m_constantBuffer = Tr2ConstantBufferAL(); library->m_localInput.m_constantBuffer = Tr2ConstantBufferAL(); @@ -351,7 +323,7 @@ static bool ConvertEffectPath( const std::string& path, std::string& actualPath if( i > 8 && strcmp( str + i - 7, "/effect/" ) == 0 ) { --i; - static const char* s_platformName = "." TRINITY_PLATFORM_NAME "/"; + static const char* s_platformName = "." TRINITY_PLATFORM_NAME "/"; for( const char* src = s_platformName; *src; ++src ) { actualPath[++i] = *src; @@ -393,7 +365,7 @@ static bool ConvertEffectPath( const std::string& path, std::string& actualPath { actualPath[dot++] = *sm++; } - actualPath.resize(actualPath.find( '\0' )); + actualPath.resize( actualPath.find( '\0' ) ); return true; } @@ -579,7 +551,7 @@ void Tr2Effect::SetOption( const BlueSharedString& name, const BlueSharedString& { if( it->name == name ) { - if( !(it->value == value ) ) + if( !( it->value == value ) ) { it->value = value; RebuildCachedDataInternal(); @@ -636,8 +608,7 @@ static Tr2SamplerDescription CreateSamplerDescription( const Tr2SamplerOverride& Tr2RenderContextEnum::CMP_NEVER, &color.r, float( samplerOverride.maxMipLevel ), - FLT_MAX - ); + FLT_MAX ); } void Tr2Effect::RebuildSamplerOverrides() @@ -649,12 +620,11 @@ void Tr2Effect::RebuildSamplerOverrides() USE_MAIN_THREAD_RENDER_CONTEXT(); - auto UpdateSamplers = [&]( ShaderType shaderType, const Tr2EffectStageInput& stage, Tr2ResourceSetDescriptionAL& resourceSetDesc ) - { + auto UpdateSamplers = [&]( ShaderType shaderType, const Tr2EffectStageInput& stage, Tr2ResourceSetDescriptionAL& resourceSetDesc ) { bool modified = false; for( auto& samplerOverride : m_samplerOverrides ) { - if( auto sampler = FindSamplerByName(stage.samplers, samplerOverride.name.c_str()) ) + if( auto sampler = FindSamplerByName( stage.samplers, samplerOverride.name.c_str() ) ) { modified |= resourceSetDesc.SetSampler( shaderType, sampler->first, samplerOverride.sampler ); } @@ -708,14 +678,14 @@ void Tr2Effect::RebuildCachedDataInternal() m_compatibleWithGdr = true; if( m_effectResource ) - { + { m_shader = m_effectResource->GetShader( m_options.empty() ? nullptr : &m_options[0], m_options.size() ); if( m_shader ) { CCP_STATS_ZONE( __FUNCTION__ ); USE_MAIN_THREAD_RENDER_CONTEXT(); - for ( auto& over : m_samplerOverrides ) + for( auto& over : m_samplerOverrides ) { over.sampler.Create( CreateSamplerDescription( over ), renderContext ); } @@ -844,11 +814,10 @@ void Tr2Effect::RebuildCachedDataInternal() m_parameters[i]->RebuildEffectHandles( m_shader ); } - for( size_t i = 0; i != m_resources.size(); ++i) + for( size_t i = 0; i != m_resources.size(); ++i ) { m_resources[i]->RebuildEffectHandles( m_shader ); } - } void Tr2Effect::RebuildCachedData( BlueAsyncRes* p ) @@ -885,12 +854,12 @@ void Tr2Effect::ReleaseCachedData( BlueAsyncRes* p ) // realize that they're not in use by a NULL technique etc. // It's important to notify parameters of the fact that the effect // has been reset - for (int i = 0; i < numParameters; i++) + for( int i = 0; i < numParameters; i++ ) { m_parameters[i]->RebuildEffectHandles( nullptr ); } - for (int i = 0; i < numResources; i++) + for( int i = 0; i < numResources; i++ ) { m_resources[i]->RebuildEffectHandles( nullptr ); } @@ -933,38 +902,38 @@ void Tr2Effect::OnListModified( long event, ssize_t key, ssize_t key2, IRoot* cu { CCP_STATS_ZONE( __FUNCTION__ ); - if( (event & BELIST_LOADING) == 0 ) + if( ( event & BELIST_LOADING ) == 0 ) { switch( event & BELIST_EVENTMASK ) { - case BELIST_REMOVED: - if( ITriReroutablePtr rp = BlueCastPtr( currvalue ) ) - { - rp->SetDestination( NULL, 0 ); - } - if( ITriEffectResourceParameterPtr res = BlueCastPtr( currvalue ) ) - { - res->OnRemovedFromMaterial( this ); - } - RebuildCachedDataInternal(); - break; + case BELIST_REMOVED: + if( ITriReroutablePtr rp = BlueCastPtr( currvalue ) ) + { + rp->SetDestination( NULL, 0 ); + } + if( ITriEffectResourceParameterPtr res = BlueCastPtr( currvalue ) ) + { + res->OnRemovedFromMaterial( this ); + } + RebuildCachedDataInternal(); + break; - case BELIST_INSERTED: - if( ITriEffectResourceParameterPtr res = BlueCastPtr( currvalue ) ) - { - res->OnAddedToMaterial( this ); - } - case BELIST_SWAPPED: - case BELIST_MOVED: - RebuildCachedDataInternal(); - break; + case BELIST_INSERTED: + if( ITriEffectResourceParameterPtr res = BlueCastPtr( currvalue ) ) + { + res->OnAddedToMaterial( this ); + } + case BELIST_SWAPPED: + case BELIST_MOVED: + RebuildCachedDataInternal(); + break; } } } // --------------------------------------------------------------- // PopulateParameters -// +// // Populates the list of parameters on the mesh using the effect file // Visibility annotations default to false, so you need to specifically // expose stuff. @@ -973,24 +942,21 @@ bool Tr2Effect::PopulateParameters() { CCP_STATS_ZONE( __FUNCTION__ ); - if (!m_shader) + if( !m_shader ) { CCP_LOGERR( "Tr2Effect::PopulateParameters: no effect resource loaded." ); return false; } - auto paramAdder = [&]( ITriEffectParameter* p ) - { - m_parameters.Insert( -1, p ); - }; + auto paramAdder = [&]( ITriEffectParameter* p ) { + m_parameters.Insert( -1, p ); + }; - auto resourceAdder = [&]( ITriEffectResourceParameter* p ) - { - m_resources.Insert( -1, p ); - }; + auto resourceAdder = [&]( ITriEffectResourceParameter* p ) { + m_resources.Insert( -1, p ); + }; - auto hasParameter = [&]( const char* name ) -> bool - { + auto hasParameter = [&]( const char* name ) -> bool { if( GetParameterByName( name ) ) { return true; @@ -1104,7 +1070,7 @@ bool Tr2Effect::PopulateParameters() // --------------------------------------------------------------- // PruneParameters -// +// // Removes any parameters from the object that do not exist in the // effect file // --------------------------------------------------------------- @@ -1112,7 +1078,7 @@ bool Tr2Effect::PruneParameters() { CCP_STATS_ZONE( __FUNCTION__ ); - if (!m_shader) + if( !m_shader ) { CCP_LOGERR( "Tr2Effect::PruneParameters: no effect resource loaded." ); return false; @@ -1120,11 +1086,11 @@ bool Tr2Effect::PruneParameters() // Prune Effects Parameters int y = 0; - while (y < m_parameters.GetSize()) + while( y < m_parameters.GetSize() ) { std::string pName = m_parameters[y]->GetParameterName(); bool removeParameter = !GetBool( m_shader, pName.c_str(), "SasUiVisible" ); - const Tr2EffectConstant *constant = m_shader->GetConstant( pName.c_str() ); + const Tr2EffectConstant* constant = m_shader->GetConstant( pName.c_str() ); if( constant == nullptr && !removeParameter ) { removeParameter = true; @@ -1147,9 +1113,9 @@ bool Tr2Effect::PruneParameters() } } } - if (removeParameter) + if( removeParameter ) { - m_parameters.Remove(y); + m_parameters.Remove( y ); } else { @@ -1163,12 +1129,12 @@ bool Tr2Effect::PruneParameters() { const char* pName = m_constParameters[it].name.c_str(); bool removeParameter = !GetBool( m_shader, pName, "SasUiVisible" ); - const Tr2EffectConstant *constant = m_shader->GetConstant( pName ); + const Tr2EffectConstant* constant = m_shader->GetConstant( pName ); if( constant == nullptr && !removeParameter ) { removeParameter = true; } - if (removeParameter) + if( removeParameter ) { m_constParameters.Remove( it ); } @@ -1180,11 +1146,11 @@ bool Tr2Effect::PruneParameters() // Prune Effects Resources y = 0; - while (y < m_resources.GetSize()) + while( y < m_resources.GetSize() ) { std::string pName = m_resources[y]->GetParameterName(); bool removeParameter = !GetBool( m_shader, pName.c_str(), "SasUiVisible" ); - const Tr2EffectConstant *constant = m_shader->GetConstant( pName.c_str() ); + const Tr2EffectConstant* constant = m_shader->GetConstant( pName.c_str() ); if( constant == nullptr && !removeParameter ) { removeParameter = true; @@ -1207,9 +1173,9 @@ bool Tr2Effect::PruneParameters() } } } - if (removeParameter) + if( removeParameter ) { - m_resources.Remove(y); + m_resources.Remove( y ); } else { @@ -1222,7 +1188,7 @@ bool Tr2Effect::PruneParameters() bool Tr2Effect::IsParameterUsedByTechnique( const std::string& parameterName ) { - if (!GetShaderStateInterface()) + if( !GetShaderStateInterface() ) { CCP_LOGERR( "Tr2Effect::IsParameterUsedByTechnique: no effect resource loaded." ); return false; @@ -1260,7 +1226,7 @@ ITriEffectParameter* Tr2Effect::GetParameterByName( const char* name ) const ITriEffectParameter* result = FindParameterByName( name ); - if ( !result ) + if( !result ) { result = GetResourceByName( name ); } @@ -1270,7 +1236,7 @@ ITriEffectParameter* Tr2Effect::GetParameterByName( const char* name ) const // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2ShaderMaterial interface. Returns an array of constant effect +// Implements ITr2ShaderMaterial interface. Returns an array of constant effect // parameters. // Arguments: // count - (out) Number of constant parameters @@ -1366,7 +1332,7 @@ std::optional GetUvScaleFromAnnotation( const char* paramName, const Tr2E if( c == '.' ) { bool isId = false; - for( size_t j = i; j > 0; --j) + for( size_t j = i; j > 0; --j ) { auto pc = expr[j - 1]; if( isdigit( pc ) ) @@ -1411,8 +1377,7 @@ bool ExtractLodingAnnotations( std::array(p); - if( vp - && vp->m_variable - && ( vp->m_variable->GetType() == TRIVARIABLE_TEXTURE_RES || - vp->m_variable->GetType() == TRIVARIABLE_GPUBUFFER ) ) + TriVariableParameter* vp = dynamic_cast( p ); + if( vp && vp->m_variable && ( vp->m_variable->GetType() == TRIVARIABLE_TEXTURE_RES || vp->m_variable->GetType() == TRIVARIABLE_GPUBUFFER ) ) { compatibleWithGdr = false; param.m_sourceValue = p; } - } // Fallback to variable store else if( TriVariable* v = GetVariableStore().FindVariable( name ) ) { - if( v->GetType() == TRIVARIABLE_TEXTURE_RES || + if( v->GetType() == TRIVARIABLE_TEXTURE_RES || v->GetType() == TRIVARIABLE_GPUBUFFER || ss.isAutoregister ) { @@ -1515,7 +1476,7 @@ void Tr2Effect::MapPassResources( const Tr2EffectResourceMap& resources, Tr2Effe { param.m_sourceValue = GetVariableStore().GetVariable( name ); } - + if( param.m_sourceValue ) { param.m_sourceName = ss.name; @@ -1548,12 +1509,11 @@ void Tr2Effect::Render( IRenderCallback* cb, Tr2RenderContext& renderContext ) ApplyMaterialDataForPass( 0, passIx, renderContext ); cb->SubmitGeometry( renderContext ); } - } // -------------------------------------------------------------------------------------- // Description: -// This method computes a hash value for the effect based on its path name and +// This method computes a hash value for the effect based on its path name and // parameters. It is not without faults: the method doen't check which parameters are // actually used by the effect, doesn't do anything with values coming from a variable // store. The method is not light-weight and should not be called every frame. @@ -1709,13 +1669,11 @@ bool GetBool( const Tr2Shader* shaderState, const char* paramName, const char* a { CCP_STATS_ZONE( __FUNCTION__ ); - return ( shaderState && paramName ) - ? GetBool( shaderState->GetParameterAnnotations( paramName ), annotationName, defaultValue ) - : defaultValue; + return ( shaderState && paramName ) ? GetBool( shaderState->GetParameterAnnotations( paramName ), annotationName, defaultValue ) : defaultValue; } -bool GetBindlessFallbackTextureIndex( const Tr2EffectDescription& desc, const Tr2EffectConstant& c, uint32_t& result) +bool GetBindlessFallbackTextureIndex( const Tr2EffectDescription& desc, const Tr2EffectConstant& c, uint32_t& result ) { //Bindless are always 1D uint parameters, so filter out everything else if( c.type != Tr2EffectConstant::UINT || c.dimension != 1 ) @@ -1761,7 +1719,7 @@ bool GetBindlessFallbackTextureIndex( const Tr2EffectDescription& desc, const Tr // Description: // Maps the parameters for a pass to indices in the constant mirror. // -------------------------------------------------------------------------------------- -void Tr2Effect::MapPassParameters( +void Tr2Effect::MapPassParameters( Tr2RenderContextEnum::ShaderType stage, Tr2MaterialStageInput& stageInput, PassParametersOwner& ppOwner, @@ -1840,13 +1798,15 @@ void Tr2Effect::MapPassParameters( //This has to be done even if the constant isn't set, as the shader may still sample it and expect //to get some kind of default (usually zero). constantSize = max( constantSize, constantIx->offset + constantIx->size ); - + // It's illegal to pass the perObjectStart if the effect has the block if( foundConstant && constantIx->offset >= perObjectStart ) { CCP_ASSERT_M( false, "Register is mapped beyond valid range" ); - CCP_LOGERR( "Effect maps parameter '%s' beyond limit (target is c%d, limit is c%d)", - constantIx->name.c_str(), constantIx->offset, perObjectStart ); + CCP_LOGERR( "Effect maps parameter '%s' beyond limit (target is c%d, limit is c%d)", + constantIx->name.c_str(), + constantIx->offset, + perObjectStart ); // We must ignore this parameter! constIndexes[index - 1] = -1; @@ -1916,7 +1876,7 @@ void Tr2Effect::MapPassParameters( auto& c = constants[i]; uint32_t srvIndex; - if (GetBindlessFallbackTextureIndex(descriptionDesc, c, srvIndex)) + if( GetBindlessFallbackTextureIndex( descriptionDesc, c, srvIndex ) ) { memcpy( mirror.get() + c.offset, &srvIndex, 4 ); } @@ -2061,7 +2021,6 @@ void Tr2Effect::MapPassParameters( memcpy( dest, &srvIndex, 4 ); } } - } } } @@ -2297,7 +2256,7 @@ void Tr2Effect::SetParameter( const BlueSharedString& name, const Tr2BufferAL& v void Tr2Effect::SetResourceTexture2D( const BlueSharedString& name, const char* path ) { - auto existing = GetResourceByName( name.c_str() ); + auto existing = GetResourceByName( name.c_str() ); if( TriTextureParameterPtr resource = BlueCastPtr( existing ) ) { resource->SetResourcePath( path ); diff --git a/trinity/Shader/Tr2Effect.h b/trinity/Shader/Tr2Effect.h index 9ef68d8ef..a2aeb33f3 100644 --- a/trinity/Shader/Tr2Effect.h +++ b/trinity/Shader/Tr2Effect.h @@ -58,13 +58,13 @@ BLUE_CLASS( Tr2Effect ) : public IBlueAsyncResNotifyTarget, public Tr2DeviceResource { -public: +public: using IRoot::Lock; using IRoot::Unlock; EXPOSE_TO_BLUE(); - Tr2Effect(IRoot* lockobj = NULL); + Tr2Effect( IRoot* lockobj = NULL ); virtual ~Tr2Effect(); // Utility Functions @@ -74,14 +74,14 @@ BLUE_CLASS( Tr2Effect ) : // Suppress notification to changed lists void StartUpdate(); void EndUpdate(); - + // gets Tr2EffectRes* GetEffectRes() const; const char* GetName() const; // sets & adds & clears void SetEffectPathName( const char* path ); - bool AddResource( ITriEffectParameter* param ); + bool AddResource( ITriEffectParameter * param ); bool AddResourceTexture2D( const BlueSharedString& name, const char* resPath ); bool AddSamplerOverride( const BlueSharedString& name, Tr2RenderContextEnum::TextureAddressMode addressModeU, Tr2RenderContextEnum::TextureAddressMode addressModeV ); bool AddParameterVector4( const BlueSharedString& name, const Vector4* value ); @@ -94,8 +94,8 @@ BLUE_CLASS( Tr2Effect ) : void SetParameter( const BlueSharedString& name, ITr2TextureProvider* texture, uint32_t uavMipLevel = 0 ); void SetParameter( const BlueSharedString& name, uint32_t value ); void SetParameter( const BlueSharedString& name, float value ); - void SetParameter( const BlueSharedString& name, const Vector2& value ); - void SetParameter( const BlueSharedString& name, const Vector3& value ); + void SetParameter( const BlueSharedString& name, const Vector2& value ); + void SetParameter( const BlueSharedString& name, const Vector3& value ); void SetParameter( const BlueSharedString& name, const Vector4& value ); void SetParameter( const BlueSharedString& name, const Matrix& matrix ); void SetParameter( const BlueSharedString& name, const Tr2TextureAL& texture, uint32_t uavMipLevel = 0 ); @@ -113,7 +113,7 @@ BLUE_CLASS( Tr2Effect ) : bool HasSamplerOverride( const char* name ) const; bool HasParameter( const char* name ) const; - void Render( IRenderCallback* cb, Tr2RenderContext& renderContext ); + void Render( IRenderCallback * cb, Tr2RenderContext & renderContext ); unsigned GetHashValue() const; @@ -123,7 +123,7 @@ BLUE_CLASS( Tr2Effect ) : ///////////////////////////////////////////////////////////////////////////////////// // INotify ///////////////////////////////////////////////////////////////////////////////////// - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -138,26 +138,25 @@ BLUE_CLASS( Tr2Effect ) : ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); ///////////////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget ///////////////////////////////////////////////////////////////////////////////////// - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); void RebuildCachedData(); - void SetVariableStore( Tr2VariableStore* variableStore ); + void SetVariableStore( Tr2VariableStore * variableStore ); Tr2VariableStore& GetVariableStore(); protected: void RebuildCachedDataInternal(); std::string m_name; - std::string m_effectFilePath; // Path to the effect file as set by user - std::string m_actualEffectFilePath; // Path to effect file, adjusted for shader model + std::string m_effectFilePath; // Path to the effect file as set by user + std::string m_actualEffectFilePath; // Path to effect file, adjusted for shader model unsigned int m_parameterHash; bool m_display; @@ -166,12 +165,14 @@ BLUE_CLASS( Tr2Effect ) : virtual void ReleaseResources( TriStorage s ); virtual bool OnPrepareResources(); + private: void RebuildSamplerOverrides(); + public: // TODO: make this private - need to change EveBoosterSet2... // Our list of ITr2EffectParameters typedef PITriEffectParameterVector EffectParameterList; - EffectParameterList m_parameters; + EffectParameterList m_parameters; // Effect Resources. These need some more care than normal parameters. typedef PITriEffectResourceParameterVector EffectResourceList; @@ -193,18 +194,18 @@ BLUE_CLASS( Tr2Effect ) : bool m_insideStartUpdate; protected: - void MapPassResources( - const Tr2EffectResourceMap& resources, - Tr2EffectParamVector &pv, + void MapPassResources( + const Tr2EffectResourceMap& resources, + Tr2EffectParamVector& pv, bool& compatibleWithGdr ); void MapPassParameters( Tr2RenderContextEnum::ShaderType stage, - Tr2MaterialStageInput& stageInput, - PassParametersOwner& ppOwner, + Tr2MaterialStageInput & stageInput, + PassParametersOwner & ppOwner, const Tr2EffectStageInput& stageInputDesc, const Tr2EffectDescription& descriptionDesc, Tr2RenderContext& renderContext ); - void AddLoddable( ITriEffectParameter* param, const char* name ); + void AddLoddable( ITriEffectParameter * param, const char* name ); // Python bool IsParameterUsedByTechnique( const std::string& parameterName ); @@ -212,7 +213,7 @@ BLUE_CLASS( Tr2Effect ) : // Utility ITriEffectParameter* FindParameterByName( const char* name ) const; }; -TYPEDEF_BLUECLASS(Tr2Effect); +TYPEDEF_BLUECLASS( Tr2Effect ); BLUE_DECLARE_VECTOR( Tr2Effect ); #endif diff --git a/trinity/Shader/Tr2EffectDescription.cpp b/trinity/Shader/Tr2EffectDescription.cpp index 2d267a01c..33b5bf635 100644 --- a/trinity/Shader/Tr2EffectDescription.cpp +++ b/trinity/Shader/Tr2EffectDescription.cpp @@ -10,21 +10,14 @@ const BlueSharedString DEFAULT_TECHNIQUE = BlueSharedString( "Main" ); const BlueSharedString ANY_TECHNIQUE = BlueSharedString(); -Tr2EffectStageInput::Tr2EffectStageInput() - : m_exists( false ) - , samplers( "Tr2EffectStageInput::samplers" ) - , resources( "Tr2EffectStageInput::resources" ) - , uavs( "Tr2EffectStageInput::uavs" ) - , constants( "Tr2EffectStageInput::constants" ) - , annotation( "Tr2EffectStageInput::annotation" ) - , m_shader( INVALID ) - , m_constantValueSize( 0 ) +Tr2EffectStageInput::Tr2EffectStageInput() : + m_exists( false ), samplers( "Tr2EffectStageInput::samplers" ), resources( "Tr2EffectStageInput::resources" ), uavs( "Tr2EffectStageInput::uavs" ), constants( "Tr2EffectStageInput::constants" ), annotation( "Tr2EffectStageInput::annotation" ), m_shader( INVALID ), m_constantValueSize( 0 ) { constantValues[0] = 0; } -Tr2EffectDescription::Tr2EffectDescription() - : techniques( "Tr2EffectDescription::techniques" ), +Tr2EffectDescription::Tr2EffectDescription() : + techniques( "Tr2EffectDescription::techniques" ), annotations( "Tr2EffectDescription::annotations" ) { } @@ -32,460 +25,460 @@ Tr2EffectDescription::Tr2EffectDescription() namespace { - template - T1 SanityCheck( T1 value, T2 limit ) +template +T1 SanityCheck( T1 value, T2 limit ) +{ + if( value > limit ) + { + throw std::runtime_error( "Unexpected value" ); + } + return value; +} + +class EffectStream +{ +public: + EffectStream( const void* data, size_t dataSize, const char* stringTable, size_t stringTableSize ) : + m_current( static_cast( data ) ), + m_end( static_cast( data ) + dataSize ), + m_stringTable( stringTable ), + m_tableSize( stringTableSize ) { - if( value > limit ) + } + + void ReadRaw( void* dest, size_t size ) + { + if( m_current + size > m_end ) { - throw std::runtime_error( "Unexpected value" ); + throw std::runtime_error( "Unexpected end of file while" ); } - return value; + memcpy( dest, m_current, size ); + m_current += size; } - class EffectStream + const void* ReadRaw( size_t size ) { - public: - EffectStream( const void* data, size_t dataSize, const char* stringTable, size_t stringTableSize ) - :m_current( static_cast(data) ), - m_end( static_cast(data) + dataSize ), - m_stringTable( stringTable ), - m_tableSize( stringTableSize ) + if( m_current + size > m_end ) { + throw std::runtime_error( "Unexpected end of file while" ); } + auto result = m_current; + m_current += size; + return result; + } - void ReadRaw( void* dest, size_t size ) + const char* ReadString( size_t sizeHint = 0 ) + { + uint32_t offset = Read(); + if( offset + sizeHint > m_tableSize ) { - if( m_current + size > m_end ) - { - throw std::runtime_error( "Unexpected end of file while" ); - } - memcpy( dest, m_current, size ); - m_current += size; + throw std::runtime_error( "Invalid string offset" ); } + return m_stringTable + offset; + } - const void* ReadRaw( size_t size ) + const char* ReadStringOptional( size_t length ) + { + if( length == 0 ) { - if( m_current + size > m_end ) - { - throw std::runtime_error( "Unexpected end of file while" ); - } - auto result = m_current; - m_current += size; - return result; + Read(); + return nullptr; } - - const char* ReadString( size_t sizeHint = 0 ) + else { - uint32_t offset = Read(); - if( offset + sizeHint > m_tableSize ) - { - throw std::runtime_error( "Invalid string offset" ); - } - return m_stringTable + offset; + return ReadString( length ); } + } + + template + void Read( StoreType& dest ) + { + dest = *static_cast( ReadRaw( sizeof( StoreType ) ) ); + } + + template + StoreType Read() + { + return *static_cast( ReadRaw( sizeof( StoreType ) ) ); + } + +private: + const uint8_t* m_current; + const uint8_t* m_end; + + const char* m_stringTable; + size_t m_tableSize; +}; + + +void ReadAnnotations( Tr2EffectParameterAnnotationMap& annotationMap, EffectStream& stream ) +{ + uint8_t annotationCount = stream.Read(); + annotationMap.resize( annotationCount ); + + for( int annotationIx = 0; annotationIx < annotationCount; ++annotationIx ) + { + Tr2EffectParameterAnnotation& annotation = annotationMap[annotationIx]; + annotation.name = stream.ReadString(); + annotation.type = Tr2EffectParameterAnnotation::Type( stream.Read() ); - const char* ReadStringOptional( size_t length ) + if( annotation.type == Tr2EffectParameterAnnotation::STRING ) { - if( length == 0 ) - { - Read(); - return nullptr; - } - else - { - return ReadString( length ); - } + annotation.stringValue = stream.ReadString(); } - - template - void Read( StoreType& dest ) + else { - dest = *static_cast(ReadRaw( sizeof( StoreType ) )); + annotation.intValue = int( stream.Read() ); } + } +} - template - StoreType Read() +Tr2EffectConstant ReadConstant( EffectStream& stream, unsigned version ) +{ + Tr2EffectConstant constant; + constant.name = BlueSharedString( stream.ReadString() ); + constant.offset = stream.Read(); + constant.size = stream.Read(); + if( version < 11 ) + { + uint8_t oldType = stream.Read(); + switch( oldType ) { - return *static_cast(ReadRaw( sizeof( StoreType ) )); + case 0: + constant.type = Tr2EffectConstant::FLOAT; + break; + case 1: + constant.type = Tr2EffectConstant::INT; + break; + case 2: + constant.type = Tr2EffectConstant::BOOL; + break; + default: + constant.type = Tr2EffectConstant::OTHER; + break; } + } + else + { + constant.type = Tr2EffectConstant::Type( stream.Read() ); + } + constant.dimension = stream.Read(); + constant.elements = stream.Read(); + constant.isSRGB = stream.Read() != 0; + constant.isAutoregister = stream.Read() != 0; + return constant; +} - private: - const uint8_t* m_current; - const uint8_t* m_end; +Tr2EffectResource ReadResource( EffectStream& stream, unsigned version ) +{ + Tr2EffectResource resource; + resource.name = stream.ReadString(); + resource.type = Tr2EffectResource::Type( stream.Read() ); + // CHECK IS IT IN RIGHT FUNCTION? + if( version >= 13 ) + { + stream.Read( resource.arrayElements ); + } + else + { + resource.arrayElements = 1; + } + resource.isSRGB = stream.Read() != 0; + resource.isAutoregister = stream.Read() != 0; - const char* m_stringTable; - size_t m_tableSize; - }; + return resource; +} +Tr2SamplerDescription ReadSampler( EffectStream& stream ) +{ + bool comparison = stream.Read() != 0; + + auto minFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + auto magFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + auto mipFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + + auto addressU = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + auto addressV = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + auto addressW = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + + float mipLODBias = stream.Read(); + unsigned maxAnisotropy = stream.Read(); + + auto comparisonFunc = Tr2RenderContextEnum::CompareFunc( stream.Read() ); + + Color borderColor; + stream.Read( borderColor.r ); + stream.Read( borderColor.g ); + stream.Read( borderColor.b ); + stream.Read( borderColor.a ); + + float minLOD = stream.Read(); + float maxLOD = stream.Read(); + + return Tr2SamplerDescription( + minFilter, + magFilter, + mipFilter, + comparison, + addressU, + addressV, + addressW, + mipLODBias, + maxAnisotropy, + comparisonFunc, + &borderColor.r, + minLOD, + maxLOD ); +} - void ReadAnnotations( Tr2EffectParameterAnnotationMap& annotationMap, EffectStream& stream ) +void ReadPipelineInputs( std::vector& pipelineInputs, EffectStream& stream, unsigned version ) +{ + uint8_t inputCount = SanityCheck( stream.Read(), 64 ); + pipelineInputs.resize( inputCount ); + for( int inputIx = 0; inputIx < inputCount; ++inputIx ) { - uint8_t annotationCount = stream.Read(); - annotationMap.resize( annotationCount ); - - for( int annotationIx = 0; annotationIx < annotationCount; ++annotationIx ) + auto& element = pipelineInputs[inputIx]; + element.usage = Tr2VertexDefinition::UsageCode( stream.Read() ); + element.registerIndex = stream.Read(); + element.usageIndex = stream.Read(); + element.usedMask = stream.Read(); + if( version > 10 ) { - Tr2EffectParameterAnnotation& annotation = annotationMap[annotationIx]; - annotation.name = stream.ReadString(); - annotation.type = Tr2EffectParameterAnnotation::Type( stream.Read() ); - - if( annotation.type == Tr2EffectParameterAnnotation::STRING ) - { - annotation.stringValue = stream.ReadString(); - } - else - { - annotation.intValue = int( stream.Read() ); - } + element.type = Tr2ShaderPipelineInputAL::Type( stream.Read() ); + element.dimension = stream.Read(); + } + else + { + element.type = element.usage == Tr2VertexDefinition::BLENDINDICES ? Tr2ShaderPipelineInputAL::UINT : Tr2ShaderPipelineInputAL::FLOAT; + element.dimension = 4; } } - - Tr2EffectConstant ReadConstant( EffectStream& stream, unsigned version ) +} +// CHECK +void ReadRegisters( Tr2ShaderSignatureAL& signature, EffectStream& stream, unsigned version, uint32_t type ) +{ + auto inputCount = stream.Read(); + signature.registers.resize( inputCount ); + for( int inputIx = 0; inputIx < inputCount; ++inputIx ) { - Tr2EffectConstant constant; - constant.name = BlueSharedString( stream.ReadString() ); - constant.offset = stream.Read(); - constant.size = stream.Read(); - if( version < 11 ) + auto& element = signature.registers[inputIx]; + + if( version > 9 ) { - uint8_t oldType = stream.Read(); - switch( oldType ) + element.registerType = Tr2ShaderRegisterAL::RegisterType( stream.Read() ); + } + else + { + uint8_t oldRegisterType = stream.Read(); + switch( oldRegisterType ) { case 0: - constant.type = Tr2EffectConstant::FLOAT; + element.registerType = Tr2ShaderRegisterAL::CONSTANT_BUFFER; break; case 1: - constant.type = Tr2EffectConstant::INT; + element.registerType = Tr2ShaderRegisterAL::SRV_TEXTURE2D; // best guess break; case 2: - constant.type = Tr2EffectConstant::BOOL; + element.registerType = Tr2ShaderRegisterAL::UAV_TEXTURE2D; // best guess break; - default: - constant.type = Tr2EffectConstant::OTHER; + case 3: + element.registerType = Tr2ShaderRegisterAL::SAMPLER; break; + default: + CCP_ASSERT( false ); + element.registerType = Tr2ShaderRegisterAL::SRV_TEXTURE2D; } } - else - { - constant.type = Tr2EffectConstant::Type( stream.Read() ); - } - constant.dimension = stream.Read(); - constant.elements = stream.Read(); - constant.isSRGB = stream.Read() != 0; - constant.isAutoregister = stream.Read() != 0; - return constant; - } + element.registerIndex = stream.Read(); - Tr2EffectResource ReadResource( EffectStream& stream, unsigned version ) - { - Tr2EffectResource resource; - resource.name = stream.ReadString(); - resource.type = Tr2EffectResource::Type( stream.Read() ); - // CHECK IS IT IN RIGHT FUNCTION? - if( version >= 13 ) + //stream.Read( element.registerIndex ); + if( version > 12 ) { - stream.Read( resource.arrayElements ); + stream.Read( element.arrayCount ); + element.registerSpace = stream.Read(); } else { - resource.arrayElements = 1; + element.arrayCount = 1; + element.registerSpace = type; } - resource.isSRGB = stream.Read() != 0; - resource.isAutoregister = stream.Read() != 0; - - return resource; - } - - Tr2SamplerDescription ReadSampler( EffectStream& stream ) - { - bool comparison = stream.Read() != 0; - - auto minFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - auto magFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - auto mipFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - - auto addressU = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - auto addressV = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - auto addressW = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - - float mipLODBias = stream.Read(); - unsigned maxAnisotropy = stream.Read(); - - auto comparisonFunc = Tr2RenderContextEnum::CompareFunc( stream.Read() ); - - Color borderColor; - stream.Read( borderColor.r ); - stream.Read( borderColor.g ); - stream.Read( borderColor.b ); - stream.Read( borderColor.a ); - - float minLOD = stream.Read(); - float maxLOD = stream.Read(); - - return Tr2SamplerDescription( - minFilter, - magFilter, - mipFilter, - comparison, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - &borderColor.r, - minLOD, - maxLOD ); - } - - void ReadPipelineInputs( std::vector& pipelineInputs, EffectStream& stream, unsigned version ) - { - uint8_t inputCount = SanityCheck( stream.Read(), 64 ); - pipelineInputs.resize( inputCount ); - for( int inputIx = 0; inputIx < inputCount; ++inputIx ) + bool dynamic = true; + if( element.registerType == Tr2ShaderRegisterAL::CONSTANT_BUFFER ) { - auto& element = pipelineInputs[inputIx]; - element.usage = Tr2VertexDefinition::UsageCode( stream.Read() ); - element.registerIndex = stream.Read(); - element.usageIndex = stream.Read(); - element.usedMask = stream.Read(); - if( version > 10 ) + if( type == Tr2RenderContextEnum::ShaderType::VERTEX_SHADER && element.registerIndex == Tr2Renderer::GetPerFrameVSStartRegister() ) { - element.type = Tr2ShaderPipelineInputAL::Type( stream.Read() ); - element.dimension = stream.Read(); + dynamic = false; } - else + if( type == Tr2RenderContextEnum::ShaderType::PIXEL_SHADER && element.registerIndex == Tr2Renderer::GetPerFramePSStartRegister() ) { - element.type = element.usage == Tr2VertexDefinition::BLENDINDICES ? Tr2ShaderPipelineInputAL::UINT : Tr2ShaderPipelineInputAL::FLOAT; - element.dimension = 4; + dynamic = false; } } + element.dynamic = dynamic; } - // CHECK - void ReadRegisters( Tr2ShaderSignatureAL& signature, EffectStream& stream, unsigned version, uint32_t type ) + + if( version > 12 ) { - auto inputCount = stream.Read(); - signature.registers.resize( inputCount ); + stream.Read( inputCount ); + signature.samplers.resize( inputCount ); for( int inputIx = 0; inputIx < inputCount; ++inputIx ) { - auto& element = signature.registers[inputIx]; - - if (version > 9) - { - element.registerType = Tr2ShaderRegisterAL::RegisterType( stream.Read() ); - } - else - { - uint8_t oldRegisterType = stream.Read(); - switch( oldRegisterType ) - { - case 0: - element.registerType = Tr2ShaderRegisterAL::CONSTANT_BUFFER; - break; - case 1: - element.registerType = Tr2ShaderRegisterAL::SRV_TEXTURE2D; // best guess - break; - case 2: - element.registerType = Tr2ShaderRegisterAL::UAV_TEXTURE2D; // best guess - break; - case 3: - element.registerType = Tr2ShaderRegisterAL::SAMPLER; - break; - default: - CCP_ASSERT( false ); - element.registerType = Tr2ShaderRegisterAL::SRV_TEXTURE2D; - } - } - element.registerIndex = stream.Read(); - - //stream.Read( element.registerIndex ); - if( version > 12 ) + auto& element = signature.samplers[inputIx]; + stream.Read( element.registerIndex ); + element.registerSpace = stream.Read(); + element.sampler.m_isComparisonFilter = stream.Read(); + element.sampler.m_minFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + element.sampler.m_magFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + element.sampler.m_mipFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); + element.sampler.m_addressU = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + element.sampler.m_addressV = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + element.sampler.m_addressW = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); + stream.Read( element.sampler.m_mipLODBias ); + element.sampler.m_maxAnisotropy = stream.Read(); + element.sampler.m_comparisonFunc = Tr2RenderContextEnum::CompareFunc( stream.Read() ); + + uint8_t borderColor; + stream.Read( borderColor ); + switch( borderColor ) { - stream.Read( element.arrayCount ); - element.registerSpace = stream.Read(); - } - else - { - element.arrayCount = 1; - element.registerSpace = type; - } - bool dynamic = true; - if( element.registerType == Tr2ShaderRegisterAL::CONSTANT_BUFFER ) - { - if( type == Tr2RenderContextEnum::ShaderType::VERTEX_SHADER && element.registerIndex == Tr2Renderer::GetPerFrameVSStartRegister() ) - { - dynamic = false; - } - if( type == Tr2RenderContextEnum::ShaderType::PIXEL_SHADER && element.registerIndex == Tr2Renderer::GetPerFramePSStartRegister() ) - { - dynamic = false; - } + case 1: + element.sampler.m_borderColor[0] = 0; + element.sampler.m_borderColor[1] = 0; + element.sampler.m_borderColor[2] = 0; + element.sampler.m_borderColor[3] = 1; + break; + case 2: + element.sampler.m_borderColor[0] = 1; + element.sampler.m_borderColor[1] = 1; + element.sampler.m_borderColor[2] = 1; + element.sampler.m_borderColor[3] = 1; + break; + default: + element.sampler.m_borderColor[0] = 0; + element.sampler.m_borderColor[1] = 0; + element.sampler.m_borderColor[2] = 0; + element.sampler.m_borderColor[3] = 0; + break; } - element.dynamic = dynamic; + stream.Read( element.sampler.m_minLOD ); + stream.Read( element.sampler.m_maxLOD ); } - - if( version > 12 ) + } +} + +void ReadInput( Tr2EffectStageInput& input, EffectStream& stream, unsigned version, Tr2RenderContextEnum::ShaderType stage, Tr2RenderContext& renderContext ) +{ + uint32_t constantCount = stream.Read(); + input.constants.resize( constantCount ); + for( unsigned constantIx = 0; constantIx < constantCount; ++constantIx ) + { + input.constants[constantIx] = ReadConstant( stream, version ); + } + + unsigned constantValueSize = stream.Read(); + + input.m_constantValueSize = constantValueSize; + if( constantValueSize > SHADER_CONSTANTS_MAX ) + { + input.m_constantValueSize = SHADER_CONSTANTS_MAX; + } + if( version < 5 ) + { + if( constantValueSize ) { - stream.Read( inputCount ); - signature.samplers.resize( inputCount ); - for( int inputIx = 0; inputIx < inputCount; ++inputIx ) - { - auto& element = signature.samplers[inputIx]; - stream.Read( element.registerIndex ); - element.registerSpace = stream.Read(); - element.sampler.m_isComparisonFilter = stream.Read(); - element.sampler.m_minFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - element.sampler.m_magFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - element.sampler.m_mipFilter = Tr2RenderContextEnum::TextureFilter( stream.Read() ); - element.sampler.m_addressU = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - element.sampler.m_addressV = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - element.sampler.m_addressW = Tr2RenderContextEnum::TextureAddressMode( stream.Read() ); - stream.Read( element.sampler.m_mipLODBias ); - element.sampler.m_maxAnisotropy = stream.Read(); - element.sampler.m_comparisonFunc = Tr2RenderContextEnum::CompareFunc( stream.Read() ); - - uint8_t borderColor; - stream.Read( borderColor ); - switch( borderColor ) - { - case 1: - element.sampler.m_borderColor[0] = 0; - element.sampler.m_borderColor[1] = 0; - element.sampler.m_borderColor[2] = 0; - element.sampler.m_borderColor[3] = 1; - break; - case 2: - element.sampler.m_borderColor[0] = 1; - element.sampler.m_borderColor[1] = 1; - element.sampler.m_borderColor[2] = 1; - element.sampler.m_borderColor[3] = 1; - break; - default: - element.sampler.m_borderColor[0] = 0; - element.sampler.m_borderColor[1] = 0; - element.sampler.m_borderColor[2] = 0; - element.sampler.m_borderColor[3] = 0; - break; - } - stream.Read( element.sampler.m_minLOD ); - stream.Read( element.sampler.m_maxLOD ); - } + memcpy( input.constantValues, stream.ReadRaw( constantValueSize ), input.m_constantValueSize ); } } + else + { + memcpy( input.constantValues, stream.ReadStringOptional( constantValueSize ), input.m_constantValueSize ); + } - void ReadInput( Tr2EffectStageInput& input, EffectStream& stream, unsigned version, Tr2RenderContextEnum::ShaderType stage, Tr2RenderContext& renderContext ) + uint8_t textureCount = SanityCheck( stream.Read(), 64u ); + for( int textureIx = 0; textureIx < textureCount; ++textureIx ) { - uint32_t constantCount = stream.Read(); - input.constants.resize( constantCount ); - for( unsigned constantIx = 0; constantIx < constantCount; ++constantIx ) + uint8_t registerIndex = stream.Read(); + input.resources[registerIndex] = ReadResource( stream, version ); + } + + uint8_t samplerCount = SanityCheck( stream.Read(), 64 ); + for( int samplerIx = 0; samplerIx < samplerCount; ++samplerIx ) + { + uint8_t registerIndex = stream.Read(); + + Tr2SamplerSetup samplerSetup; + + if( version >= 4 ) + { + samplerSetup.name = stream.ReadString(); + } + else { - input.constants[constantIx] = ReadConstant( stream, version ); + samplerSetup.name = nullptr; } - unsigned constantValueSize = stream.Read(); + Tr2SamplerDescription sampler = ReadSampler( stream ); - input.m_constantValueSize = constantValueSize; - if( constantValueSize > SHADER_CONSTANTS_MAX ) + if( version < 4 ) { - input.m_constantValueSize = SHADER_CONSTANTS_MAX; + stream.Read(); // isSRGBTexture } - if( version < 5 ) + if( version > 12 ) { - if( constantValueSize ) + bool isDynamic = true; + isDynamic = stream.Read(); + if( !isDynamic ) { - memcpy( input.constantValues, stream.ReadRaw( constantValueSize ), input.m_constantValueSize ); + samplerSetup.name = nullptr; } } - else - { - memcpy( input.constantValues, stream.ReadStringOptional( constantValueSize ), input.m_constantValueSize ); - } - uint8_t textureCount = SanityCheck( stream.Read(), 64u ); - for( int textureIx = 0; textureIx < textureCount; ++textureIx ) - { - uint8_t registerIndex = stream.Read(); - input.resources[registerIndex] = ReadResource( stream, version ); - } + samplerSetup.sampler.Create( sampler, renderContext.GetPrimaryRenderContext() ); - uint8_t samplerCount = SanityCheck( stream.Read(), 64 ); - for( int samplerIx = 0; samplerIx < samplerCount; ++samplerIx ) + input.samplers[registerIndex] = samplerSetup; + } + + if( version >= 3 ) + { + uint8_t uavCount = SanityCheck( stream.Read(), 64 ); + + for( int uavIx = 0; uavIx < uavCount; ++uavIx ) { uint8_t registerIndex = stream.Read(); - Tr2SamplerSetup samplerSetup; + Tr2EffectResource resource; + resource.isSRGB = false; + resource.name = stream.ReadString(); + resource.type = Tr2EffectResource::Type( stream.Read() ); - if( version >= 4 ) + if( version >= 13 ) { - samplerSetup.name = stream.ReadString(); + stream.Read( resource.arrayElements ); } else { - samplerSetup.name = nullptr; + resource.arrayElements = 1; } - Tr2SamplerDescription sampler = ReadSampler( stream ); + resource.isAutoregister = stream.Read() != 0; - if( version < 4 ) - { - stream.Read(); // isSRGBTexture - } - if( version > 12 ) - { - bool isDynamic = true; - isDynamic = stream.Read(); - if( !isDynamic ) - { - samplerSetup.name = nullptr; - } - } - - samplerSetup.sampler.Create( sampler, renderContext.GetPrimaryRenderContext() ); - - input.samplers[registerIndex] = samplerSetup; + input.uavs[registerIndex] = resource; } - - if( version >= 3 ) + if( version >= 8 ) { - uint8_t uavCount = SanityCheck( stream.Read(), 64 ); - - for( int uavIx = 0; uavIx < uavCount; ++uavIx ) - { - uint8_t registerIndex = stream.Read(); - - Tr2EffectResource resource; - resource.isSRGB = false; - resource.name = stream.ReadString(); - resource.type = Tr2EffectResource::Type( stream.Read() ); - - if( version >= 13 ) - { - stream.Read( resource.arrayElements ); - } - else - { - resource.arrayElements = 1; - } - - resource.isAutoregister = stream.Read() != 0; - - input.uavs[registerIndex] = resource; - } - if( version >= 8 ) - { - ReadAnnotations( input.annotation, stream ); - } + ReadAnnotations( input.annotation, stream ); } } +} } bool Tr2EffectDescription::Read( const void* data, - size_t dataSize, - unsigned version, - const char* stringTable, - size_t stringTableSize, - const char* effectName ) + size_t dataSize, + unsigned version, + const char* stringTable, + size_t stringTableSize, + const char* effectName ) { USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -560,7 +553,7 @@ bool Tr2EffectDescription::Read( const void* data, stream.Read( shaderSize ); shaderCode = stream.ReadRaw( shaderSize ); - stream.ReadRaw( stream.Read() ); // shadow shader + stream.ReadRaw( stream.Read() ); // shadow shader } else { @@ -583,7 +576,7 @@ bool Tr2EffectDescription::Read( const void* data, stream.Read( pass.stageInputs[type].signature.threadGroupSize.z ); } // CHECK - if( version >= 14 ) + if( version >= 14 ) { ReadPipelineInputs( pass.stageInputs[type].signature.pipelineInputs, stream, version ); ReadRegisters( pass.stageInputs[type].signature, stream, version, type ); @@ -601,7 +594,7 @@ bool Tr2EffectDescription::Read( const void* data, if( pass.stageInputs[type].m_shader == unsigned( -1 ) ) { const char* stageName; - switch (type) + switch( type ) { case Tr2RenderContextEnum::VERTEX_SHADER: stageName = "vertex"; @@ -633,7 +626,7 @@ bool Tr2EffectDescription::Read( const void* data, if( auto sampler = FindSamplerByName( pass.stageInputs[type].samplers, c.name.c_str() ) ) { - if ( c.offset + c.size > pass.stageInputs[type].m_constantValueSize ) + if( c.offset + c.size > pass.stageInputs[type].m_constantValueSize ) { std::fill( pass.stageInputs[type].constantValues + pass.stageInputs[type].m_constantValueSize, pass.stageInputs[type].constantValues + c.offset + c.size, 0 ); pass.stageInputs[type].m_constantValueSize = c.offset + c.size; @@ -642,7 +635,7 @@ bool Tr2EffectDescription::Read( const void* data, } } } - + pass.resourceSetDesc = Tr2ResourceSetDescriptionAL( Tr2RegisterMapAL( shaderTypes.data(), signatures.data(), signatures.size() ) ); for( uint32_t stageIx = 0; stageIx < Tr2RenderContextEnum::SHADER_TYPE_COUNT; ++stageIx ) { @@ -674,7 +667,7 @@ bool Tr2EffectDescription::Read( const void* data, techniques[technique].shaderTypeMask |= pass.shaderTypeMask; } - // raytracing + // raytracing if( version > 13 ) { uint8_t librariesCount = stream.Read(); @@ -696,23 +689,23 @@ bool Tr2EffectDescription::Read( const void* data, switch( exportType ) { case 0: - library.rayGenName = BlueSharedStringW( static_cast(CA2W( name )) ); + library.rayGenName = BlueSharedStringW( static_cast( CA2W( name ) ) ); break; case 1: - library.missName = BlueSharedStringW( static_cast(CA2W( name )) ); + library.missName = BlueSharedStringW( static_cast( CA2W( name ) ) ); break; case 2: - library.closestHitName = BlueSharedStringW( static_cast(CA2W( name )) ); + library.closestHitName = BlueSharedStringW( static_cast( CA2W( name ) ) ); break; case 3: - library.anyHitName = BlueSharedStringW( static_cast(CA2W( name )) ); + library.anyHitName = BlueSharedStringW( static_cast( CA2W( name ) ) ); break; case 4: - library.intersectionName = BlueSharedStringW( static_cast(CA2W( name )) ); + library.intersectionName = BlueSharedStringW( static_cast( CA2W( name ) ) ); break; } } - library.hitGroupName = BlueSharedStringW( static_cast(CA2W( stream.ReadString() )) ); + library.hitGroupName = BlueSharedStringW( static_cast( CA2W( stream.ReadString() ) ) ); auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; ReadRegisters( library.globalInput.signature, stream, version, shaderType ); @@ -742,7 +735,6 @@ bool Tr2EffectDescription::Read( const void* data, CCP_LOGERR( "%s in effect \"%s\".", exc.what(), effectName ); techniques.clear(); return false; - } auto IsHeapView = [&]( const char* name ) { @@ -796,7 +788,7 @@ bool Tr2EffectDescription::Read( const void* data, uint32_t type = 0; for( auto& stage : pass.stageInputs ) { - if (stage.m_exists) + if( stage.m_exists ) { for( auto& res : stage.resources ) { diff --git a/trinity/Shader/Tr2EffectDescription.h b/trinity/Shader/Tr2EffectDescription.h index e69500973..70f4d789a 100644 --- a/trinity/Shader/Tr2EffectDescription.h +++ b/trinity/Shader/Tr2EffectDescription.h @@ -74,7 +74,7 @@ struct Tr2EffectResource TEXTURE_2D = Tr2RenderContextEnum::TEX_TYPE_2D, TEXTURE_3D = Tr2RenderContextEnum::TEX_TYPE_3D, TEXTURE_CUBE = Tr2RenderContextEnum::TEX_TYPE_CUBE, - TEXTURE_TYPELESS = Tr2RenderContextEnum::TEX_TYPE_TYPELESS, // valid but unknown dimensions + TEXTURE_TYPELESS = Tr2RenderContextEnum::TEX_TYPE_TYPELESS, // valid but unknown dimensions BUFFER, STRUCTURED_BUFFER, @@ -137,7 +137,7 @@ struct Tr2EffectParameterAnnotation }; // Annotation name (string is managed by the owner of string table: Tr2EffectRes or - // Tr2HighLevelShader) + // Tr2HighLevelShader) const char* name; Type type; union @@ -167,7 +167,10 @@ struct Tr2EffectStageInput { Tr2EffectStageInput(); - enum { INVALID = 0xffFFffFFu }; + enum + { + INVALID = 0xffFFffFFu + }; // If the stage was loaded from effect file bool m_exists; @@ -229,8 +232,8 @@ struct Tr2EffectLibrary struct Tr2EffectTechnique { - Tr2EffectTechnique() - :passes( "Tr2EffectTechnique::passes" ), + Tr2EffectTechnique() : + passes( "Tr2EffectTechnique::passes" ), shaderTypeMask( 0 ) { } @@ -249,10 +252,10 @@ struct Tr2EffectDescription { Tr2EffectDescription(); - bool Read( const void* data, + bool Read( const void* data, size_t dataSize, unsigned version, - const char* stringTable, + const char* stringTable, size_t stringTableSize, const char* effectName ); diff --git a/trinity/Shader/Tr2EffectStateManager.cpp b/trinity/Shader/Tr2EffectStateManager.cpp index 549659746..1532d1a7e 100644 --- a/trinity/Shader/Tr2EffectStateManager.cpp +++ b/trinity/Shader/Tr2EffectStateManager.cpp @@ -11,252 +11,403 @@ using namespace Tr2RenderContextEnum; -namespace { - - // These are shared across managers. - - typedef std::vector> VertexLayoutMap_t; - VertexLayoutMap_t s_vertexLayoutMap; - std::mutex s_vertexLayoutMutex; - - std::vector s_shaders; - std::vector s_shaderLibraries; - std::vector>> s_shaderPrograms; - - typedef std::vector TRenderStateKeyValues; - - static uint32_t opaquePairs[] = - { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, TRUE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t decalPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, TRUE, - RS_ALPHAFUNC, CMP_GREATER, - RS_ALPHAREF, 127, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, TRUE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - - static uint32_t decalNoDepthPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, TRUE, - RS_ALPHAFUNC, CMP_GREATER, - RS_ALPHAREF, 127, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t alphaPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, TRUE, - RS_SRCBLEND, BM_SRCALPHA, - RS_DESTBLEND, BM_INVSRCALPHA, - RS_BLENDOP, BO_ADD, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_ALPHATESTENABLE, FALSE, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t alphaAdditivePairs[] = { - RS_FILLMODE, FM_SOLID, - RS_CULLMODE, CULLMODE_NONE, - RS_ALPHABLENDENABLE, TRUE, - RS_SRCBLEND, BM_ONE, - RS_DESTBLEND, BM_ONE, - RS_BLENDOP, BO_ADD, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_ALPHATESTENABLE, FALSE, - RS_COLORWRITEENABLE, 0x7, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t depthOnlyPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, TRUE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_COLORWRITEENABLE, 0, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t pickingPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, TRUE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_FILLMODE, FM_SOLID, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t fullscreenPairs[] = { - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_CULLMODE, CULLMODE_NONE, - RS_ZENABLE, FALSE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_ALWAYS, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - }; - - static uint32_t sprite2dPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, TRUE, - RS_SRCBLEND, BM_ONE, - RS_DESTBLEND, BM_INVSRCALPHA, - RS_BLENDOP, BO_ADD, - RS_ALPHATESTENABLE, FALSE, - RS_CULLMODE, CULLMODE_NONE, - RS_ZENABLE, FALSE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_ALWAYS, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - static uint32_t cullPairs[] = { - RS_CULLMODE, CULLMODE_CW, - }; - - static uint32_t lightPairs[] = { - RS_FILLMODE, FM_SOLID, - RS_CULLMODE, CULLMODE_NONE, - RS_ALPHABLENDENABLE, TRUE, - RS_SRCBLEND, BM_ONE, - RS_DESTBLEND, BM_ONE, - RS_BLENDOP, BO_ADD, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_LESSEQUAL, - RS_ZENABLE, TRUE, - RS_ALPHATESTENABLE, FALSE, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, TRUE, - RS_BLENDOPALPHA, BO_ADD, - RS_SRCBLENDALPHA, BM_ONE, - RS_DESTBLENDALPHA, BM_ONE, - }; - - static uint32_t erasePairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, TRUE, - RS_ZFUNC, CMP_ALWAYS, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - }; - - static uint32_t prepassColorPairs[] = { - RS_CULLMODE, CULLMODE_CW, - RS_FILLMODE, FM_SOLID, - RS_ALPHABLENDENABLE, FALSE, - RS_ALPHATESTENABLE, FALSE, - RS_ZENABLE, TRUE, - RS_ZWRITEENABLE, FALSE, - RS_ZFUNC, CMP_EQUAL, - RS_COLORWRITEENABLE, 0x0f, - RS_DEPTHBIAS, 0, - RS_SLOPESCALEDEPTHBIAS, 0, - RS_SEPARATEALPHABLENDENABLE, FALSE, - }; - - struct ModeList - { - uint32_t* list; - uint32_t count; - }; - - static ModeList const modePairs[Tr2EffectStateManager::RM_COUNT] = - { - { nullptr, 0 }, - { opaquePairs, sizeof( opaquePairs ) / sizeof( uint32_t ) }, - { decalPairs, sizeof( decalPairs ) / sizeof( uint32_t ) }, - { decalNoDepthPairs, sizeof( decalNoDepthPairs ) / sizeof( uint32_t ) }, - { alphaPairs, sizeof( alphaPairs ) / sizeof( uint32_t ) }, - { alphaAdditivePairs, sizeof( alphaAdditivePairs ) / sizeof( uint32_t ) }, - { depthOnlyPairs, sizeof( depthOnlyPairs ) / sizeof( uint32_t ) }, - { pickingPairs, sizeof( pickingPairs ) / sizeof( uint32_t ) }, - { fullscreenPairs, sizeof( fullscreenPairs ) / sizeof( uint32_t ) }, - { sprite2dPairs, sizeof( sprite2dPairs ) / sizeof( uint32_t ) }, - { cullPairs, sizeof( cullPairs ) / sizeof( uint32_t ) }, - { lightPairs, sizeof( lightPairs ) / sizeof( uint32_t ) }, - { erasePairs, sizeof( erasePairs ) / sizeof( uint32_t ) }, - { prepassColorPairs, sizeof( prepassColorPairs ) / sizeof( uint32_t ) }, - }; - +namespace +{ - struct RenderStateSetups: public std::vector +// These are shared across managers. + +typedef std::vector> VertexLayoutMap_t; +VertexLayoutMap_t s_vertexLayoutMap; +std::mutex s_vertexLayoutMutex; + +std::vector s_shaders; +std::vector s_shaderLibraries; +std::vector>> s_shaderPrograms; + +typedef std::vector TRenderStateKeyValues; + +static uint32_t opaquePairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + TRUE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t decalPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + TRUE, + RS_ALPHAFUNC, + CMP_GREATER, + RS_ALPHAREF, + 127, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + TRUE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + + +static uint32_t decalNoDepthPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + TRUE, + RS_ALPHAFUNC, + CMP_GREATER, + RS_ALPHAREF, + 127, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t alphaPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + TRUE, + RS_SRCBLEND, + BM_SRCALPHA, + RS_DESTBLEND, + BM_INVSRCALPHA, + RS_BLENDOP, + BO_ADD, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_ALPHATESTENABLE, + FALSE, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t alphaAdditivePairs[] = { + RS_FILLMODE, + FM_SOLID, + RS_CULLMODE, + CULLMODE_NONE, + RS_ALPHABLENDENABLE, + TRUE, + RS_SRCBLEND, + BM_ONE, + RS_DESTBLEND, + BM_ONE, + RS_BLENDOP, + BO_ADD, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_ALPHATESTENABLE, + FALSE, + RS_COLORWRITEENABLE, + 0x7, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t depthOnlyPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + TRUE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_COLORWRITEENABLE, + 0, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t pickingPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + TRUE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_FILLMODE, + FM_SOLID, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t fullscreenPairs[] = { + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_CULLMODE, + CULLMODE_NONE, + RS_ZENABLE, + FALSE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_ALWAYS, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, +}; + +static uint32_t sprite2dPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + TRUE, + RS_SRCBLEND, + BM_ONE, + RS_DESTBLEND, + BM_INVSRCALPHA, + RS_BLENDOP, + BO_ADD, + RS_ALPHATESTENABLE, + FALSE, + RS_CULLMODE, + CULLMODE_NONE, + RS_ZENABLE, + FALSE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_ALWAYS, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +static uint32_t cullPairs[] = { + RS_CULLMODE, + CULLMODE_CW, +}; + +static uint32_t lightPairs[] = { + RS_FILLMODE, + FM_SOLID, + RS_CULLMODE, + CULLMODE_NONE, + RS_ALPHABLENDENABLE, + TRUE, + RS_SRCBLEND, + BM_ONE, + RS_DESTBLEND, + BM_ONE, + RS_BLENDOP, + BO_ADD, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_LESSEQUAL, + RS_ZENABLE, + TRUE, + RS_ALPHATESTENABLE, + FALSE, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + TRUE, + RS_BLENDOPALPHA, + BO_ADD, + RS_SRCBLENDALPHA, + BM_ONE, + RS_DESTBLENDALPHA, + BM_ONE, +}; + +static uint32_t erasePairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + TRUE, + RS_ZFUNC, + CMP_ALWAYS, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, +}; + +static uint32_t prepassColorPairs[] = { + RS_CULLMODE, + CULLMODE_CW, + RS_FILLMODE, + FM_SOLID, + RS_ALPHABLENDENABLE, + FALSE, + RS_ALPHATESTENABLE, + FALSE, + RS_ZENABLE, + TRUE, + RS_ZWRITEENABLE, + FALSE, + RS_ZFUNC, + CMP_EQUAL, + RS_COLORWRITEENABLE, + 0x0f, + RS_DEPTHBIAS, + 0, + RS_SLOPESCALEDEPTHBIAS, + 0, + RS_SEPARATEALPHABLENDENABLE, + FALSE, +}; + +struct ModeList +{ + uint32_t* list; + uint32_t count; +}; + +static ModeList const modePairs[Tr2EffectStateManager::RM_COUNT] = { + { nullptr, 0 }, + { opaquePairs, sizeof( opaquePairs ) / sizeof( uint32_t ) }, + { decalPairs, sizeof( decalPairs ) / sizeof( uint32_t ) }, + { decalNoDepthPairs, sizeof( decalNoDepthPairs ) / sizeof( uint32_t ) }, + { alphaPairs, sizeof( alphaPairs ) / sizeof( uint32_t ) }, + { alphaAdditivePairs, sizeof( alphaAdditivePairs ) / sizeof( uint32_t ) }, + { depthOnlyPairs, sizeof( depthOnlyPairs ) / sizeof( uint32_t ) }, + { pickingPairs, sizeof( pickingPairs ) / sizeof( uint32_t ) }, + { fullscreenPairs, sizeof( fullscreenPairs ) / sizeof( uint32_t ) }, + { sprite2dPairs, sizeof( sprite2dPairs ) / sizeof( uint32_t ) }, + { cullPairs, sizeof( cullPairs ) / sizeof( uint32_t ) }, + { lightPairs, sizeof( lightPairs ) / sizeof( uint32_t ) }, + { erasePairs, sizeof( erasePairs ) / sizeof( uint32_t ) }, + { prepassColorPairs, sizeof( prepassColorPairs ) / sizeof( uint32_t ) }, +}; + + +struct RenderStateSetups : public std::vector +{ +public: + RenderStateSetups() { - public: - RenderStateSetups() + resize( Tr2EffectStateManager::RM_COUNT ); + for( int i = 0; i < Tr2EffectStateManager::RM_COUNT; ++i ) { - resize( Tr2EffectStateManager::RM_COUNT ); - for( int i = 0; i < Tr2EffectStateManager::RM_COUNT; ++i ) - { - at( i ).assign( modePairs[i].list, modePairs[i].list + modePairs[i].count ); - } + at( i ).assign( modePairs[i].list, modePairs[i].list + modePairs[i].count ); } - }; + } +}; - RenderStateSetups s_renderStateSetups; +RenderStateSetups s_renderStateSetups; } @@ -279,8 +430,8 @@ void Tr2EffectStateManager::CurrentValues::Reset() } } -Tr2EffectStateManager::Tr2EffectStateManager( Tr2RenderContext &renderContext ) - : m_renderContext( renderContext ), +Tr2EffectStateManager::Tr2EffectStateManager( Tr2RenderContext& renderContext ) : + m_renderContext( renderContext ), m_isManagedRendering( false ), m_renderTargetWidth( 0 ), m_renderTargetHeight( 0 ) @@ -297,7 +448,7 @@ uint32_t Tr2EffectStateManager::RegisterRenderStateSetup( const Tr2RenderStateSe kv.push_back( it->first ); kv.push_back( it->second ); } - + for( uint32_t i = 0; i != s_renderStateSetups.size(); ++i ) { if( kv == s_renderStateSetups[i] ) @@ -309,14 +460,14 @@ uint32_t Tr2EffectStateManager::RegisterRenderStateSetup( const Tr2RenderStateSe // New setup, add it s_renderStateSetups.push_back( kv ); - return (uint32_t)s_renderStateSetups.size()-1; + return (uint32_t)s_renderStateSetups.size() - 1; } -uint32_t Tr2EffectStateManager::RegisterShader( - ShaderType type, +uint32_t Tr2EffectStateManager::RegisterShader( + ShaderType type, const Tr2ShaderBytecodeAL& bytecode, const Tr2ShaderSignatureAL& signature, - const char* shaderPath) + const char* shaderPath ) { for( size_t i = 0; i != s_shaders.size(); ++i ) { @@ -348,13 +499,13 @@ uint32_t Tr2EffectStateManager::RegisterShader( // New shader, add it; created using the primary rendercontext. std::unique_ptr shader( new Tr2ShaderAL ); USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( shader->Create( - type, - bytecode, - signature, - shaderPath, - renderContext ) - , UNKNOWN ); + CR_RETURN_VAL( shader->Create( + type, + bytecode, + signature, + shaderPath, + renderContext ), + UNKNOWN ); s_shaders.push_back( shader.release() ); @@ -509,14 +660,14 @@ void Tr2EffectStateManager::Shutdown() for( auto it = s_shaderLibraries.begin(); it != s_shaderLibraries.end(); ++it ) { //delete[]( *it )->bytecode; - delete* it; + delete *it; } s_shaderLibraries.clear(); } void Tr2EffectStateManager::BeginManagedRendering( Tr2RenderContextEnum::CullMode cullmode ) { - D3DPERF_EVENT(L"Tr2EffectStateManager::BeginManagedRendering"); + D3DPERF_EVENT( L"Tr2EffectStateManager::BeginManagedRendering" ); m_currentValues.Reset(); @@ -544,7 +695,7 @@ void Tr2EffectStateManager::BeginManagedRendering( Tr2RenderContextEnum::CullMod void Tr2EffectStateManager::EndManagedRendering() { - D3DPERF_EVENT(L"Tr2EffectStateManager::EndManagedRendering"); + D3DPERF_EVENT( L"Tr2EffectStateManager::EndManagedRendering" ); m_isManagedRendering = false; } @@ -682,8 +833,8 @@ bool Tr2EffectStateManager::IsCullModeInverted( void ) void Tr2EffectStateManager::SetInvertedDepthTest( bool b ) { - static const uint32_t overrides[] = { - 0, + static const uint32_t overrides[] = { + 0, CMP_NEVER, CMP_GREATER, CMP_EQUAL, @@ -691,7 +842,8 @@ void Tr2EffectStateManager::SetInvertedDepthTest( bool b ) CMP_LESS, CMP_NOTEQUAL, CMP_LESSEQUAL, - CMP_ALWAYS }; + CMP_ALWAYS + }; if( b ) { @@ -731,7 +883,7 @@ void Tr2EffectStateManager::ApplyVertexDeclaration( uint32_t declaration ) return; } - + CCP_ASSERT( declaration != UNINITIALIZED_DECLARATION ); if( declaration == NULL_DECLARATION ) @@ -749,7 +901,7 @@ void Tr2EffectStateManager::ApplyVertexDeclaration( uint32_t declaration ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - hvl.Create( s_vertexLayoutMap[declaration].first, renderContext ); + hvl.Create( s_vertexLayoutMap[declaration].first, renderContext ); } m_renderContext.SetVertexLayout( hvl ); } @@ -764,7 +916,7 @@ bool Tr2EffectStateManager::GetVertexDeclarationElements( uint32_t declaration, CCP_ASSERT( declaration < s_vertexLayoutMap.size() || declaration == UNINITIALIZED_DECLARATION ); if( declaration < s_vertexLayoutMap.size() ) { - definition = s_vertexLayoutMap[ declaration ].first; + definition = s_vertexLayoutMap[declaration].first; return true; } return false; @@ -777,12 +929,12 @@ void Tr2EffectStateManager::ApplyStreamSource( uint32_t stream, const Tr2Suballo void Tr2EffectStateManager::ApplyStreamSource( uint32_t stream, const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ) { - + if( m_isManagedRendering ) { - if( buffer == m_currentValues.m_streams[stream].m_vertexBuffer && - offset == m_currentValues.m_streams[stream].m_offset && - stride == m_currentValues.m_streams[stream].m_stride ) + if( buffer == m_currentValues.m_streams[stream].m_vertexBuffer && + offset == m_currentValues.m_streams[stream].m_offset && + stride == m_currentValues.m_streams[stream].m_stride ) { return; } @@ -812,7 +964,7 @@ void Tr2EffectStateManager::ApplyIndexBuffer( const Tr2BufferAL& indices, const { CCP_LOGWARN( "Oh no! This is a big bug!" ); } - + if( m_isManagedRendering ) { if( indices == m_currentValues.m_indexBuffer && stride == m_currentValues.m_indexStride ) @@ -831,7 +983,7 @@ void Tr2EffectStateManager::ReleaseDeviceResources( TriStorage s ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - if( (s & TRISTORAGE_ALL) == TRISTORAGE_ALL ) + if( ( s & TRISTORAGE_ALL ) == TRISTORAGE_ALL ) { if( renderContext.IsValid() ) { @@ -856,7 +1008,7 @@ void Tr2EffectStateManager::ReleaseDeviceResources( TriStorage s ) for( auto it = s_shaderLibraries.begin(); it != s_shaderLibraries.end(); ++it ) { //delete[]( *it )->bytecode; - delete* it; + delete *it; } s_shaderLibraries.clear(); @@ -1013,7 +1165,7 @@ bool Tr2EffectStateManager::SetDepthStencilBuffer( const Tr2TextureAL& ds ) void Tr2EffectStateManager::SetupContextResources() { // Create all HW vertex layouts here to avoid creating those during multithreaded rendering - for( auto& it: s_vertexLayoutMap ) + for( auto& it : s_vertexLayoutMap ) { Tr2VertexLayoutAL& hvl = *it.second; if( !hvl.IsValid() ) @@ -1031,10 +1183,10 @@ void Tr2EffectStateManager::AssignFrom( const Tr2EffectStateManager& other ) { EndManagedRendering(); } - + m_renderStates = other.m_renderStates; std::copy( std::begin( other.m_renderStateOverrides ), std::end( other.m_renderStateOverrides ), m_renderStateOverrides ); - + ApplyStandardStates( other.m_currentValues.m_renderingMode ); } @@ -1079,7 +1231,7 @@ void Tr2EffectStateManager::SetupViewport() m_viewportOnDevice.m_x = std::max( (float)x0, 0.0f ); m_viewportOnDevice.m_y = std::max( (float)y0, 0.0f ); - // Viewport width and height must be greater than zero. Using zero edge + // Viewport width and height must be greater than zero. Using zero edge // length causes dx error. m_viewportOnDevice.m_width = (float)std::max( std::min( x1, m_renderTargetWidth ) - int( m_viewportOnDevice.m_x ), 1 ); m_viewportOnDevice.m_height = (float)std::max( std::min( y1, m_renderTargetHeight ) - int( m_viewportOnDevice.m_y ), 1 ); diff --git a/trinity/Shader/Tr2EffectStateManager.h b/trinity/Shader/Tr2EffectStateManager.h index 84cc51a0f..e9284d039 100644 --- a/trinity/Shader/Tr2EffectStateManager.h +++ b/trinity/Shader/Tr2EffectStateManager.h @@ -51,14 +51,14 @@ class Tr2EffectStateManager enum { // 16 textures/samplers per shader - SAMPLER_MAX_COUNT = 16, + SAMPLER_MAX_COUNT = 16, VERTEX_STREAM_MAX_COUNT = 4, - UNKNOWN = 0XFFFFFFFFu + UNKNOWN = 0XFFFFFFFFu }; enum RenderingMode { - RM_ANY, // Don't care about the render state + RM_ANY, // Don't care about the render state RM_OPAQUE, RM_DECAL, RM_DECAL_NO_DEPTH, @@ -70,14 +70,14 @@ class Tr2EffectStateManager RM_SPRITE2D, RM_CULL, RM_LIGHT, - RM_ERASE, - RM_PREPASS_COLOR, + RM_ERASE, + RM_PREPASS_COLOR, RM_COUNT }; - enum - { + enum + { UNINITIALIZED_DECLARATION = ~0u, NULL_DECLARATION = ~0u - 1 }; @@ -91,7 +91,7 @@ class Tr2EffectStateManager void ApplyStreamSource( uint32_t stream, const Tr2SuballocatedBuffer::Allocation& vertices ); - void ApplyStreamSource( uint32_t stream, const Tr2BufferAL & buffer, uint32_t offset, uint32_t stride ); + void ApplyStreamSource( uint32_t stream, const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ); void ApplyIndexBuffer( const Tr2BufferAL& indices ); void ApplyIndexBuffer( const Tr2SuballocatedBuffer::Allocation& indices ); @@ -104,8 +104,8 @@ class Tr2EffectStateManager typedef std::map Tr2RenderStateSetup; - static uint32_t RegisterShader( - Tr2RenderContextEnum::ShaderType type, + static uint32_t RegisterShader( + Tr2RenderContextEnum::ShaderType type, const Tr2ShaderBytecodeAL& bytecode, const Tr2ShaderSignatureAL& signature, const char* shaderPath ); @@ -115,7 +115,7 @@ class Tr2EffectStateManager static uint32_t RegisterShaderLibrary( const Tr2ShaderBytecodeAL& bytecode ); static const Tr2ShaderBytecodeAL* GetShaderLibraryCode( uint32_t handle ); - static uint32_t RegisterRenderStateSetup( + static uint32_t RegisterRenderStateSetup( const Tr2RenderStateSetup& rss ); void SetWireframeRendering( bool b ); @@ -141,20 +141,21 @@ class Tr2EffectStateManager unsigned int GetRenderTargetWidth(); unsigned int GetRenderTargetHeight(); - void PushRenderTarget( unsigned slot = 0 ); // does not set any RT, just stores the current one so it can be safely changed later + void PushRenderTarget( unsigned slot = 0 ); // does not set any RT, just stores the current one so it can be safely changed later void PushRenderTarget( const Tr2TextureAL& rt, unsigned slot = 0 ); void PopRenderTarget( unsigned slot = 0 ); bool SetRenderTarget( unsigned int index, const Tr2TextureAL& rt, bool updateViewport = true, uint32_t slice = 0 ); - bool PushDepthStencilBuffer(); // does not set a DS, just stores it so it can be safely changed later + bool PushDepthStencilBuffer(); // does not set a DS, just stores it so it can be safely changed later bool PushDepthStencilBuffer( const Tr2TextureAL& ds ); void PopDepthStencilBuffer(); bool SetDepthStencilBuffer( const Tr2TextureAL& ds ); - + void SetupContextResources(); void AssignFrom( const Tr2EffectStateManager& other ); void UpdateRenderTargetViewport( unsigned width, unsigned height ); + private: friend class Tr2EffectRes; friend class Tr2LowLevelShader; @@ -162,15 +163,15 @@ class Tr2EffectStateManager void SetRenderStateOverride( Tr2RenderContextEnum::RenderState state, const uint32_t* overrides ); void DoApplyRenderStates( uint32_t ix ); - Tr2RenderContext& m_renderContext; + Tr2RenderContext& m_renderContext; // used by SetPerObjectDataToDevice - Tr2ConstantBufferAL m_perObjectConstantBuffers[ Tr2RenderContextEnum::CBUFFER_COUNT ]; - + Tr2ConstantBufferAL m_perObjectConstantBuffers[Tr2RenderContextEnum::CBUFFER_COUNT]; + struct CurrentValues { void Reset(); - + uint32_t m_shaderProgram; uint32_t m_vertexDeclaration; @@ -195,8 +196,8 @@ class Tr2EffectStateManager struct RenderStates { - RenderStates() - :dirty( true ) + RenderStates() : + dirty( true ) { } @@ -222,8 +223,8 @@ class Tr2EffectStateManager void SetupViewport(); - Tr2EffectStateManager( const Tr2EffectStateManager & ); - Tr2EffectStateManager& operator=( const Tr2EffectStateManager & ); + Tr2EffectStateManager( const Tr2EffectStateManager& ); + Tr2EffectStateManager& operator=( const Tr2EffectStateManager& ); }; #endif //Tr2EffectStateManager_h diff --git a/trinity/Shader/Tr2Effect_Blue.cpp b/trinity/Shader/Tr2Effect_Blue.cpp index ddcadaabd..b4198808c 100644 --- a/trinity/Shader/Tr2Effect_Blue.cpp +++ b/trinity/Shader/Tr2Effect_Blue.cpp @@ -11,7 +11,7 @@ BLUE_DEFINE( Tr2Effect ); // --------------------------------------------------------------- // PyGetParameterAnnotations -// +// // Gets a python dict of the parameter annotations, using a parameter object or string for the name // --------------------------------------------------------------- static PyObject* PyGetParameterAnnotations( PyObject* self, PyObject* args ) @@ -44,7 +44,7 @@ static PyObject* PyGetParameterAnnotations( PyObject* self, PyObject* args ) } else { - Py_INCREF(Py_None); + Py_INCREF( Py_None ); return Py_None; } } @@ -55,7 +55,7 @@ static PyObject* PyGetParameterAnnotations( PyObject* self, PyObject* args ) auto annotations = pThis->GetShaderStateInterface()->GetParameterAnnotations( parameterNameString.c_str() ); if( annotations == nullptr ) { - Py_INCREF(Py_None); + Py_INCREF( Py_None ); return Py_None; } for( auto annotation = annotations->begin(); annotation != annotations->end(); ++annotation ) @@ -83,20 +83,17 @@ static PyObject* PyGetParameterAnnotations( PyObject* self, PyObject* args ) tmpValue = ToPython( annotation->stringValue ); PyDict_SetItemString( annotationDict, annotation->name, tmpValue ); Py_DECREF( tmpValue ); - } + } } return annotationDict; } #endif -Be::VarChooser EffectFileChooser[] = -{ - { - "SELECT_EFFECT", - BeCast(0), - "Effect source (.fx)|*.fx|All Files (*.*)|*.*" - }, +Be::VarChooser EffectFileChooser[] = { + { "SELECT_EFFECT", + BeCast( 0 ), + "Effect source (.fx)|*.fx|All Files (*.*)|*.*" }, { 0 } }; @@ -112,101 +109,82 @@ const Be::ClassInfo* Tr2Effect::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - m_name, - "A name to describe the effect. Not used by the engine, an authoring convenience.", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + m_name, + "A name to describe the effect. Not used by the engine, an authoring convenience.", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Effect Resource Blue File - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "effectFilePath", m_effectFilePath, "The shader file to use", Be::READWRITE | Be::PERSIST | Be::NOTIFY, - EffectFileChooser - ) + EffectFileChooser ) - MAP_ATTRIBUTE( - "actualEffectFilePath", - m_actualEffectFilePath, + MAP_ATTRIBUTE( + "actualEffectFilePath", + m_actualEffectFilePath, "Path to compiled effect, after shader model mangling", - Be::READ - ) + Be::READ ) //////////////////////////////////////////////////////////////////////////// // The currently loaded effect resource - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectResource", m_effectResource, "na", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "options", m_options, "", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // - MAP_ATTRIBUTE - ( - "parameters", + MAP_ATTRIBUTE( + "parameters", m_parameters, - "Effect Parameters", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "constParameters", + "Effect Parameters", + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "constParameters", m_constParameters, - "Constant Effect Parameters", - Be::READ | Be::PERSIST - ) + "Constant Effect Parameters", + Be::READ | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // - MAP_ATTRIBUTE - ( - "resources", + MAP_ATTRIBUTE( + "resources", m_resources, - "Effect Resources", - Be::READ | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "samplerOverrides", + "Effect Resources", + Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( + "samplerOverrides", m_samplerOverrides, - "Sampler state overrides", - Be::READ | Be::PERSIST - ) + "Sampler state overrides", + Be::READ | Be::PERSIST ) - MAP_METHOD( - "GetParameterAnnotations", - PyGetParameterAnnotations, + MAP_METHOD( + "GetParameterAnnotations", + PyGetParameterAnnotations, "Gets the annotations on a parameter\n" ":param parameter: either parameter name or an effect parameter object\n" ":type parameter: str | ITriEffectParameter\n" - ":rtype: dict" - ) + ":rtype: dict" ) MAP_METHOD_AND_WRAP( "PopulateParameters", PopulateParameters, "Populates the parameter list with the appropriate parameters" ) MAP_METHOD_AND_WRAP( "PruneParameters", PruneParameters, "Removes parameters from the parameter list that are not used by the effect" ) - MAP_METHOD_AND_WRAP( - "IsParameterUsedByTechnique", - IsParameterUsedByTechnique, + MAP_METHOD_AND_WRAP( + "IsParameterUsedByTechnique", + IsParameterUsedByTechnique, "Returns True if the parameter name is used by the current technique\n" - ":param name: parameter name" - ) + ":param name: parameter name" ) MAP_METHOD_AND_WRAP( "RebuildCachedData", RebuildCachedDataInternal, "Call this after adding/removing parameters/resources" ) - MAP_METHOD_AND_WRAP( "StartUpdate" , StartUpdate, "Temporarily block list notifications from causing a data rebuild" ) - MAP_METHOD_AND_WRAP( "EndUpdate" , EndUpdate , "Reactivate list notifications, and do a data rebuild" ) + MAP_METHOD_AND_WRAP( "StartUpdate", StartUpdate, "Temporarily block list notifications from causing a data rebuild" ) + MAP_METHOD_AND_WRAP( "EndUpdate", EndUpdate, "Reactivate list notifications, and do a data rebuild" ) EXPOSURE_END() } diff --git a/trinity/Shader/Tr2Material.cpp b/trinity/Shader/Tr2Material.cpp index 8059cee8e..b79f91723 100644 --- a/trinity/Shader/Tr2Material.cpp +++ b/trinity/Shader/Tr2Material.cpp @@ -54,7 +54,7 @@ std::pair Tr2SharedConstantB return std::make_pair( Key(), Tr2ConstantBufferAL() ); } } - + value.refCount = 1; auto copy = new uint8_t[size]; @@ -96,8 +96,8 @@ Tr2MaterialStageInput::~Tr2MaterialStageInput() g_sharedConstantBuffers.ReleaseBuffer( m_sharedBufferKey ); } -Tr2EffectLibraryParameters::Tr2EffectLibraryParameters() - :m_globalResourceSetDirty( true ) +Tr2EffectLibraryParameters::Tr2EffectLibraryParameters() : + m_globalResourceSetDirty( true ) { } @@ -117,8 +117,8 @@ void Tr2EffectLibraryParameters::AddReroutable( ITriReroutable* reroutable ) } -Tr2EffectPassParameters::Tr2EffectPassParameters() - :m_resourceSetDirty( true ), +Tr2EffectPassParameters::Tr2EffectPassParameters() : + m_resourceSetDirty( true ), m_compatibleWithGdr( true ), m_resourceSetHash( 0 ) { @@ -303,7 +303,7 @@ bool Tr2Material::ApplyShaderInputs( Tr2EffectPassParameters& pp, Tr2RenderConte return UpdateResourceSetDesc( shaderType, input, pp.m_resourceSetDesc ); } -void Tr2Material::ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext) const +void Tr2Material::ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const { auto& cb = input.m_constantBuffer; if( cb.GetSize() ) @@ -349,7 +349,7 @@ void Tr2Material::UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, } } -bool Tr2Material::UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2ResourceSetDescriptionAL & desc ) const +bool Tr2Material::UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2ResourceSetDescriptionAL& desc ) const { bool descChanged = false; for( auto it = input.m_textures.cbegin(); it != input.m_textures.cend(); ++it ) @@ -434,7 +434,7 @@ void Tr2Material::MarkConstantBuffersDirty() } } } - for ( auto& library : technique.libraries ) + for( auto& library : technique.libraries ) { if( !library->m_globalInput.m_shaderParametersWithNotification.empty() ) { diff --git a/trinity/Shader/Tr2Material.h b/trinity/Shader/Tr2Material.h index b82d541f8..7ca7760ec 100644 --- a/trinity/Shader/Tr2Material.h +++ b/trinity/Shader/Tr2Material.h @@ -25,7 +25,7 @@ class Tr2EffectParam unsigned int m_registerCount; }; -typedef std::vector Tr2EffectParamVector; +typedef std::vector Tr2EffectParamVector; struct Tr2SamplerOverrideData { @@ -109,10 +109,11 @@ struct Tr2MaterialStageInput void GetSharedConstantBuffer( const void* contents, uint32_t size ); }; -class PassParametersOwner { +class PassParametersOwner +{ public: - virtual ~PassParametersOwner() {}; + virtual ~PassParametersOwner() {}; virtual void AddUsedResource( ITr2EffectValuePtr resource ) = 0; virtual void AddReroutable( ITriReroutable* reroutable ) = 0; }; @@ -179,15 +180,17 @@ struct Tr2EffectTechniqueInputs std::swap( passes, other.passes ); std::swap( libraries, other.libraries ); } - ~Tr2EffectTechniqueInputs(){} - + ~Tr2EffectTechniqueInputs() + { + } + Tr2EffectTechniqueInputs& operator=( Tr2EffectTechniqueInputs&& other ) { std::swap( passes, other.passes ); std::swap( libraries, other.libraries ); return *this; } - + std::vector> passes; std::vector> libraries; }; @@ -197,7 +200,7 @@ typedef std::vector Tr2EffectTechniqueParametersVector //typedef std::vector> Tr2EffectPassParametersVector; //typedef std::vector Tr2EffectTechniqueParametersVector; -BLUE_CLASS( Tr2Material ): +BLUE_CLASS( Tr2Material ) : public IRoot { public: @@ -214,7 +217,9 @@ BLUE_CLASS( Tr2Material ): Tr2Shader* GetShaderStateInterface() const; - virtual void SetOption( const BlueSharedString& name, const BlueSharedString& value ) {} + virtual void SetOption( const BlueSharedString& name, const BlueSharedString& value ) + { + } Tr2EffectPassParameters* GetPassDescription( uint32_t techniqueIndex, uint32_t passIndex ); @@ -232,11 +237,11 @@ BLUE_CLASS( Tr2Material ): protected: bool ApplyShaderInputs( uint32_t techniqueIndex, unsigned int passIndex, Tr2RenderContextEnum::ShaderType shaderType, Tr2RenderContext& renderContext ) const; - bool ApplyShaderInputs( Tr2EffectPassParameters& pp, Tr2RenderContextEnum::ShaderType shaderType, Tr2RenderContext& renderContext ) const; + bool ApplyShaderInputs( Tr2EffectPassParameters & pp, Tr2RenderContextEnum::ShaderType shaderType, Tr2RenderContext & renderContext ) const; - void ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const; - void UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, bool hasReroutables, Tr2RenderContext& renderContext ) const; - bool UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput& input, Tr2ResourceSetDescriptionAL& desc ) const; + void ApplyConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, bool hasReroutables, Tr2RenderContext& renderContext ) const; + void UpdateConstants( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, bool hasReroutables, Tr2RenderContext& renderContext ) const; + bool UpdateResourceSetDesc( Tr2RenderContextEnum::ShaderType shaderType, Tr2MaterialStageInput & input, Tr2ResourceSetDescriptionAL & desc ) const; Tr2ShaderPtr m_shader; diff --git a/trinity/Shader/Tr2Shader.cpp b/trinity/Shader/Tr2Shader.cpp index d9b570bfb..0392681a5 100644 --- a/trinity/Shader/Tr2Shader.cpp +++ b/trinity/Shader/Tr2Shader.cpp @@ -11,10 +11,10 @@ using namespace Tr2RenderContextEnum; // Description: // Constructor. Initializes members to default values. // -------------------------------------------------------------------------------------- -Tr2Shader::Tr2Shader( IRoot* lockobj ) - :m_sortValue( 0 ), +Tr2Shader::Tr2Shader( IRoot* lockobj ) : + m_sortValue( 0 ), m_hasVertexBufferAccessInRtShadow( false ) -{ +{ } // -------------------------------------------------------------------------------------- @@ -139,7 +139,7 @@ const Tr2EffectResource* Tr2Shader::GetResource( const char* name ) const // -------------------------------------------------------------------------------------- // Description: // Returns map of effect annotations for a given parameter or nullptr if the parameter -// is not found or it doesn't contain any annotations. +// is not found or it doesn't contain any annotations. // Arguments: // parameterName - Name of the effect parameter // Return Value: @@ -158,7 +158,7 @@ const Tr2EffectDescription& Tr2Shader::GetEffectDescription() const } // -------------------------------------------------------------------------------------- -void Tr2Shader::ApplyAllStateForPass( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext &renderContext ) const +void Tr2Shader::ApplyAllStateForPass( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext& renderContext ) const { auto& technique = m_effect.techniques[techniqueIndex]; @@ -181,7 +181,7 @@ uint32_t Tr2Shader::ApplyShaderOverride( uint32_t techniqueIndex, uint32_t passI } // -------------------------------------------------------------------------------------- -void Tr2Shader::ApplyRenderStates( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext &renderContext ) const +void Tr2Shader::ApplyRenderStates( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext& renderContext ) const { auto& technique = m_effect.techniques[techniqueIndex]; auto& pass = technique.passes[passIndex]; @@ -237,7 +237,7 @@ void Tr2Shader::ProcessEffect() unsigned int states = technique.passes[0].renderStates & 0x3ff; unsigned int numPasses = technique.passes.size() & 0x3; - m_sortValue = (numPasses << 30) | (ps << 20) | (vs << 10) | states; + m_sortValue = ( numPasses << 30 ) | ( ps << 20 ) | ( vs << 10 ) | states; } #if TRINITY_PLATFORM == TRINITY_DIRECTX12 || TRINITY_PLATFORM == TRINITY_METAL @@ -258,7 +258,7 @@ void Tr2Shader::ProcessEffect() const BlueSharedString techniqueName = BlueSharedString( "RtShadow" ); auto effect = GetEffect(); uint32_t techniqueIndex; - if ( GetTechniqueIndex( techniqueName, techniqueIndex ) ) + if( GetTechniqueIndex( techniqueName, techniqueIndex ) ) { for( const auto& library : effect.techniques[techniqueIndex].libraries ) { diff --git a/trinity/Shader/Tr2Shader.h b/trinity/Shader/Tr2Shader.h index 062c24ff7..51ffcf20d 100644 --- a/trinity/Shader/Tr2Shader.h +++ b/trinity/Shader/Tr2Shader.h @@ -10,7 +10,8 @@ extern const BlueSharedString DEFAULT_TECHNIQUE; extern const BlueSharedString ANY_TECHNIQUE; -BLUE_CLASS( Tr2Shader ) : public IRoot +BLUE_CLASS( Tr2Shader ) : + public IRoot { public: Tr2Shader( IRoot* lockobj = NULL ); @@ -21,10 +22,10 @@ BLUE_CLASS( Tr2Shader ) : public IRoot bool GetTechniqueIndex( const BlueSharedString& name, uint32_t& index ) const; uint32_t GetPassCount( uint32_t techniqueIndex ) const; - void ApplyAllStateForPass( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext &renderContext ) const; + void ApplyAllStateForPass( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext& renderContext ) const; - void ApplyRenderStates( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext &renderContext ) const; - uint32_t ApplyShaderOverride( uint32_t techniqueIndex, uint32_t passIndex, const Tr2Shader& overrideShader, uint32_t overridePassIndex, Tr2RenderContext &renderContext ) const; + void ApplyRenderStates( uint32_t techniqueIndex, uint32_t passIndex, Tr2RenderContext& renderContext ) const; + uint32_t ApplyShaderOverride( uint32_t techniqueIndex, uint32_t passIndex, const Tr2Shader& overrideShader, uint32_t overridePassIndex, Tr2RenderContext& renderContext ) const; uint32_t GetShaderTypeMask( uint32_t techniqueIndex ) const; diff --git a/trinity/Shader/Tr2ShaderBuffer.cpp b/trinity/Shader/Tr2ShaderBuffer.cpp index cb5f363de..410243309 100644 --- a/trinity/Shader/Tr2ShaderBuffer.cpp +++ b/trinity/Shader/Tr2ShaderBuffer.cpp @@ -5,7 +5,7 @@ #include "Tr2Renderer.h" #include "Tr2RenderContext.h" -Tr2ShaderBuffer::Tr2ShaderBuffer( IRoot* lockobj ): +Tr2ShaderBuffer::Tr2ShaderBuffer( IRoot* lockobj ) : m_data( nullptr ), m_size( 0 ), m_shaderType( Tr2RenderContextEnum::PIXEL_SHADER ) diff --git a/trinity/Shader/Tr2ShaderBuffer.h b/trinity/Shader/Tr2ShaderBuffer.h index 92995b444..db4c1ae84 100644 --- a/trinity/Shader/Tr2ShaderBuffer.h +++ b/trinity/Shader/Tr2ShaderBuffer.h @@ -8,19 +8,22 @@ BLUE_DECLARE( Tr2ShaderBuffer ); BLUE_DECLARE( Tr2RenderContext ); -BLUE_CLASS( Tr2ShaderBuffer ): +BLUE_CLASS( Tr2ShaderBuffer ) : public IRoot { public: EXPOSE_TO_BLUE(); - - Tr2ShaderBuffer( IRoot* lockobj = NULL ); + + Tr2ShaderBuffer( IRoot* lockobj = NULL ); ~Tr2ShaderBuffer(); - void ApplyBuffer( Tr2RenderContext& renderContext ); + void ApplyBuffer( Tr2RenderContext & renderContext ); void SetData( void* data, int size ); void SetDataFromScript( const char* data, int size ); - void SetShaderType( Tr2RenderContextEnum::ShaderType shaderType ) { m_shaderType = shaderType; } + void SetShaderType( Tr2RenderContextEnum::ShaderType shaderType ) + { + m_shaderType = shaderType; + } private: void* m_data; diff --git a/trinity/Shader/Tr2ShaderBuffer_Blue.cpp b/trinity/Shader/Tr2ShaderBuffer_Blue.cpp index c9c783b34..bb9175c47 100644 --- a/trinity/Shader/Tr2ShaderBuffer_Blue.cpp +++ b/trinity/Shader/Tr2ShaderBuffer_Blue.cpp @@ -7,23 +7,20 @@ BLUE_DEFINE( Tr2ShaderBuffer ); const Be::ClassInfo* Tr2ShaderBuffer::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ShaderBuffer, "" ) - MAP_INTERFACE( Tr2ShaderBuffer ) + EXPOSURE_BEGIN( Tr2ShaderBuffer, "" ) + MAP_INTERFACE( Tr2ShaderBuffer ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "size", m_size, "", - Be::READ - ) + Be::READ ) MAP_METHOD_AND_WRAP( "SetData", SetDataFromScript, ":param data: data string\n" - ":param size: size of the data" - ) + ":param size: size of the data" ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Shader/Tr2Shader_Blue.cpp b/trinity/Shader/Tr2Shader_Blue.cpp index 0ad14205e..717be214e 100644 --- a/trinity/Shader/Tr2Shader_Blue.cpp +++ b/trinity/Shader/Tr2Shader_Blue.cpp @@ -9,7 +9,7 @@ BLUE_DEFINE( Tr2Shader ); const Be::ClassInfo* Tr2Shader::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Shader, "" ) - MAP_INTERFACE( Tr2Shader ) + EXPOSURE_BEGIN( Tr2Shader, "" ) + MAP_INTERFACE( Tr2Shader ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Shader/Utils/Tr2DataTextureManager.cpp b/trinity/Shader/Utils/Tr2DataTextureManager.cpp index ea7cae802..6b1fd5777 100644 --- a/trinity/Shader/Utils/Tr2DataTextureManager.cpp +++ b/trinity/Shader/Utils/Tr2DataTextureManager.cpp @@ -65,7 +65,7 @@ bool Tr2DataTextureManager::OnPrepareResources() // create the data texture here, prefill it with zeros std::vector t( m_textureWidth * m_textureHeight, Vector4( 0.f, 0.f, 0.f, 0.f ) ); - Tr2SubresourceData init = { &t[0], m_textureWidth * uint32_t(sizeof(Vector4)), m_textureWidth * m_textureHeight * uint32_t(sizeof(Vector4)) }; + Tr2SubresourceData init = { &t[0], m_textureWidth * uint32_t( sizeof( Vector4 ) ), m_textureWidth * m_textureHeight * uint32_t( sizeof( Vector4 ) ) }; if( FAILED( m_dataTexture->GetTexture()->Create( Tr2BitmapDimensions( m_textureWidth, m_textureHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, &init, renderContext ) ) ) { m_dataTexture->OnTextureChange().Broadcast(); @@ -128,12 +128,12 @@ void Tr2DataTextureManager::Update( EveUpdateContext& updateContext ) } // save pixeloffset - m_dataTextureOffsets[ blockID ] = pixelOffset; + m_dataTextureOffsets[blockID] = pixelOffset; // header for( uint32_t y = 0; y < m_textureHeight; ++y ) { - memcpy( &mem[ y * pitch ], &block->header[ y ], sizeof( Vector4 ) ); + memcpy( &mem[y * pitch], &block->header[y], sizeof( Vector4 ) ); } // data @@ -142,7 +142,7 @@ void Tr2DataTextureManager::Update( EveUpdateContext& updateContext ) { for( uint32_t x = 0; x < block->blockLength; ++x ) { - memcpy( &mem[ y * pitch + x * sizeof( Vector4 )], &block->data[ x * m_textureHeight + y ], sizeof( Vector4 ) ); + memcpy( &mem[y * pitch + x * sizeof( Vector4 )], &block->data[x * m_textureHeight + y], sizeof( Vector4 ) ); } } @@ -194,10 +194,10 @@ int32_t Tr2DataTextureManager::RequestBlockData( const Vector4* headerData, uint } // insert it into the map - m_blockData[ m_blockDataNextIdx ] = bd; + m_blockData[m_blockDataNextIdx] = bd; // and insert it into the priority map, keeps it sorted! - m_blockPriority[ priority ] = m_blockDataNextIdx; + m_blockPriority[priority] = m_blockDataNextIdx; return m_blockDataNextIdx++; } @@ -218,11 +218,3 @@ int32_t Tr2DataTextureManager::GetTextureOffset( int32_t blockID ) const } return finder->second; } - - - - - - - - diff --git a/trinity/Shader/Utils/Tr2DataTextureManager.h b/trinity/Shader/Utils/Tr2DataTextureManager.h index c907a254f..c5d1feee9 100644 --- a/trinity/Shader/Utils/Tr2DataTextureManager.h +++ b/trinity/Shader/Utils/Tr2DataTextureManager.h @@ -32,16 +32,18 @@ BLUE_CLASS( Tr2DataTextureManager ) : ///////////////////////////////////////////////////////////// // Tr2DeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); + public: #if TRINITYDEV - void GetDescription( std::string& desc ); + void GetDescription( std::string & desc ); #endif ///////////////////////////////////////////////////////////////////////////////////// // Update - void Update( EveUpdateContext& updateContext ); + void Update( EveUpdateContext & updateContext ); // access block IDs int32_t RequestBlockData( const Vector4* headerData, uint32_t blockLength, const Vector4* blockData, float priority ); @@ -51,7 +53,7 @@ BLUE_CLASS( Tr2DataTextureManager ) : // set variables to the variable store void SetVariables(); - + private: // general data BlueSharedString m_name; diff --git a/trinity/Shader/Utils/Tr2DataTextureManager_Blue.cpp b/trinity/Shader/Utils/Tr2DataTextureManager_Blue.cpp index 85782466d..d9ff28235 100644 --- a/trinity/Shader/Utils/Tr2DataTextureManager_Blue.cpp +++ b/trinity/Shader/Utils/Tr2DataTextureManager_Blue.cpp @@ -7,15 +7,15 @@ BLUE_DEFINE( Tr2DataTextureManager ); const Be::ClassInfo* Tr2DataTextureManager::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2DataTextureManager, "" ) - MAP_INTERFACE( Tr2DataTextureManager ) + EXPOSURE_BEGIN( Tr2DataTextureManager, "" ) + MAP_INTERFACE( Tr2DataTextureManager ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "textureWidth", m_textureWidth, "", Be::READ ) MAP_ATTRIBUTE( "textureHeight", m_textureHeight, "", Be::READ ) MAP_ATTRIBUTE( "blockDataNextIdx", m_blockDataNextIdx, "", Be::READ ) MAP_ATTRIBUTE( "maxBlockCount", m_maxBlockCount, "", Be::READ ) MAP_ATTRIBUTE( "maxPixelCount", m_maxPixelCount, "", Be::READ ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Sprite2d/ITr2Sprite2dRenderer.h b/trinity/Sprite2d/ITr2Sprite2dRenderer.h index 196b72ea5..648a481e8 100644 --- a/trinity/Sprite2d/ITr2Sprite2dRenderer.h +++ b/trinity/Sprite2d/ITr2Sprite2dRenderer.h @@ -31,27 +31,27 @@ enum class Tr2SpriteTarget enum Tr2SpriteObjectEffect { TR2_SFX_NO_TEXTURE, - TR2_SFX_FILL = TR2_SFX_NO_TEXTURE, // No texture - only vertex colors + TR2_SFX_FILL = TR2_SFX_NO_TEXTURE, // No texture - only vertex colors - TR2_SFX_FILL_AA, // Anti-aliased lines + TR2_SFX_FILL_AA, // Anti-aliased lines TR2_SFX_ONE_TEXTURE = 32, - TR2_SFX_COPY = TR2_SFX_ONE_TEXTURE, // Primary texture modulated with vertex colors - TR2_SFX_DOT, // Primary texture used in dot product against light vector - TR2_SFX_NOALPHA, // Primary texture as a Bink video texture - TR2_SFX_DROPSHADOW, // Primary texture modulated with vertex colors plus a drop shadow - TR2_SFX_OUTLINE, // Primary texture modulated with vertex colors plus an outline - TR2_SFX_COLOROVERLAY, // Primary texture colorized with overlay effect (http://en.wikipedia.org/wiki/Blend_modes#Overlay) - TR2_SFX_SOFTLIGHT, // Primary texture colorized with a soft light effect (http://en.wikipedia.org/wiki/Blend_modes#Soft_Light) - TR2_SFX_BLUR, // Primary texture is blurred - TR2_SFX_BLURBACKGROUNDCOLORED, // Primary texture is blurred, uvs are calculated from screen coords - TR2_SFX_BLURBACKGROUND, // Primary texture is blurred, uvs are calculated from screen coords - TR2_SFX_GLOW, // Primary texture is blurred, to be used for glow effects - TR2_SFX_FONT, // Primary texture is a glyph rendered by FreeType + TR2_SFX_COPY = TR2_SFX_ONE_TEXTURE, // Primary texture modulated with vertex colors + TR2_SFX_DOT, // Primary texture used in dot product against light vector + TR2_SFX_NOALPHA, // Primary texture as a Bink video texture + TR2_SFX_DROPSHADOW, // Primary texture modulated with vertex colors plus a drop shadow + TR2_SFX_OUTLINE, // Primary texture modulated with vertex colors plus an outline + TR2_SFX_COLOROVERLAY, // Primary texture colorized with overlay effect (http://en.wikipedia.org/wiki/Blend_modes#Overlay) + TR2_SFX_SOFTLIGHT, // Primary texture colorized with a soft light effect (http://en.wikipedia.org/wiki/Blend_modes#Soft_Light) + TR2_SFX_BLUR, // Primary texture is blurred + TR2_SFX_BLURBACKGROUNDCOLORED, // Primary texture is blurred, uvs are calculated from screen coords + TR2_SFX_BLURBACKGROUND, // Primary texture is blurred, uvs are calculated from screen coords + TR2_SFX_GLOW, // Primary texture is blurred, to be used for glow effects + TR2_SFX_FONT, // Primary texture is a glyph rendered by FreeType TR2_SFX_TWO_TEXTURES = 64, - TR2_SFX_MODULATE = TR2_SFX_TWO_TEXTURES, // Primary and secondary textures modulated, then again with vertex colors - TR2_SFX_MASK, // Primary texture with secondary texture alpha as mask + TR2_SFX_MODULATE = TR2_SFX_TWO_TEXTURES, // Primary and secondary textures modulated, then again with vertex colors + TR2_SFX_MASK, // Primary texture with secondary texture alpha as mask TR2_SFX_COPY_DOT, TR2_SFX_COUNT, @@ -61,9 +61,13 @@ enum Tr2SpriteObjectEffect struct Tr2Sprite2dClipRect { - Tr2Sprite2dClipRect() {} + Tr2Sprite2dClipRect() + { + } Tr2Sprite2dClipRect( float l, float t, float r, float b ) : - left( l ), top( t ), right( r ), bottom( b ) {} + left( l ), top( t ), right( r ), bottom( b ) + { + } float left; float top; @@ -101,12 +105,12 @@ enum Tr2Sprite2dRenderEffect enum Tr2Sprite2dTextureSettings { - S2D_TS_NONE = 0x00, - S2D_TS_FORCEOPAQUE = 0x01, - S2D_TS_REPEAT_MIRROR = 0x02, - S2D_TS_REPEAT_CLAMP = 0x04, - S2D_TS_TILE_X = 0x08, - S2D_TS_TILE_Y = 0x10, + S2D_TS_NONE = 0x00, + S2D_TS_FORCEOPAQUE = 0x01, + S2D_TS_REPEAT_MIRROR = 0x02, + S2D_TS_REPEAT_CLAMP = 0x04, + S2D_TS_TILE_X = 0x08, + S2D_TS_TILE_Y = 0x10, }; extern Be::VarChooser Tr2Sprite2dRenderEffectChooser[]; diff --git a/trinity/Sprite2d/ITr2Sprite2dTexture.h b/trinity/Sprite2d/ITr2Sprite2dTexture.h index 2b431c4f1..4327ee62f 100644 --- a/trinity/Sprite2d/ITr2Sprite2dTexture.h +++ b/trinity/Sprite2d/ITr2Sprite2dTexture.h @@ -17,9 +17,10 @@ class ITr2Sprite2dTextureNotifyTarget virtual void Sprite2dTextureChanged( ITr2Sprite2dTexture* p ) = 0; }; -BLUE_INTERFACE( ITr2Sprite2dTexture ) : public IRoot +BLUE_INTERFACE( ITr2Sprite2dTexture ) : + public IRoot { - virtual void Apply( Tr2Sprite2dScene* renderer, unsigned int ix ) = 0; + virtual void Apply( Tr2Sprite2dScene * renderer, unsigned int ix ) = 0; virtual unsigned int GetWidth() const = 0; virtual unsigned int GetHeight() const = 0; @@ -30,8 +31,8 @@ BLUE_INTERFACE( ITr2Sprite2dTexture ) : public IRoot virtual bool IsLoading() const = 0; virtual bool IsGood() const = 0; - virtual void RegisterForChangeNotification( ITr2Sprite2dTextureNotifyTarget* p ) = 0; - virtual void UnregisterForChangeNotification( ITr2Sprite2dTextureNotifyTarget* p ) = 0; + virtual void RegisterForChangeNotification( ITr2Sprite2dTextureNotifyTarget * p ) = 0; + virtual void UnregisterForChangeNotification( ITr2Sprite2dTextureNotifyTarget * p ) = 0; }; #endif diff --git a/trinity/Sprite2d/ITr2SpriteObject.h b/trinity/Sprite2d/ITr2SpriteObject.h index 02775a8e3..5fcf6ff5e 100644 --- a/trinity/Sprite2d/ITr2SpriteObject.h +++ b/trinity/Sprite2d/ITr2SpriteObject.h @@ -7,13 +7,14 @@ class Tr2Sprite2dScene; -BLUE_INTERFACE( ITr2SpriteObject ) : public IRoot +BLUE_INTERFACE( ITr2SpriteObject ) : + public IRoot { - virtual void GatherSprites( Tr2Sprite2dScene* renderer ) = 0; + virtual void GatherSprites( Tr2Sprite2dScene * renderer ) = 0; virtual ITr2SpriteObject* PickPoint( float x, float y, Tr2Sprite2dScene* renderer ) = 0; - virtual void SetParent( ITr2SpriteObject* parent ) = 0; + virtual void SetParent( ITr2SpriteObject * parent ) = 0; virtual void SetDirty() = 0; - virtual void SetChildDirty( ITr2SpriteObject* child ) = 0; + virtual void SetChildDirty( ITr2SpriteObject * child ) = 0; virtual bool IsAuxMouseover() = 0; }; diff --git a/trinity/Sprite2d/Tr2Sprite2d.cpp b/trinity/Sprite2d/Tr2Sprite2d.cpp index c5058d713..895af9050 100644 --- a/trinity/Sprite2d/Tr2Sprite2d.cpp +++ b/trinity/Sprite2d/Tr2Sprite2d.cpp @@ -7,10 +7,25 @@ #include "Tr2Sprite2dPickingMask.h" -static unsigned short s_spriteIndices[18] = { - 0, 1, 3, 3, 1, 2, - 4, 5, 7, 7, 5, 6, - 8, 9, 11, 11, 9, 10 +static unsigned short s_spriteIndices[18] = { + 0, + 1, + 3, + 3, + 1, + 2, + 4, + 5, + 7, + 7, + 5, + 6, + 8, + 9, + 11, + 11, + 9, + 10 }; Tr2Sprite2d::Tr2Sprite2d( IRoot* lockobj ) : @@ -38,7 +53,7 @@ Tr2Sprite2d::~Tr2Sprite2d() void Tr2Sprite2d::GatherSprites( Tr2Sprite2dScene* renderer ) { - if( !m_display || (m_spriteEffect == TR2_SFX_NONE) ) + if( !m_display || ( m_spriteEffect == TR2_SFX_NONE ) ) { return; } @@ -91,7 +106,7 @@ void Tr2Sprite2d::GatherSprites( Tr2Sprite2dScene* renderer ) renderer->PrepareSpriteVerts( &m_vertices[4], m_translation, displayWidth, displayHeight, m_spriteEffect ); - if( m_spriteEffect < TR2_SFX_TWO_TEXTURES && (m_spriteEffect != TR2_SFX_BLUR) && (m_spriteEffect != TR2_SFX_GLOW) && (m_spriteEffect != TR2_SFX_OUTLINE) ) + if( m_spriteEffect < TR2_SFX_TWO_TEXTURES && ( m_spriteEffect != TR2_SFX_BLUR ) && ( m_spriteEffect != TR2_SFX_GLOW ) && ( m_spriteEffect != TR2_SFX_OUTLINE ) ) { for( int i = 4; i < 8; ++i ) { @@ -100,7 +115,7 @@ void Tr2Sprite2d::GatherSprites( Tr2Sprite2dScene* renderer ) } } - if( (m_glowFactor != 0.0f) || (m_glowExpand != 0.0f) ) + if( ( m_glowFactor != 0.0f ) || ( m_glowExpand != 0.0f ) ) { m_vertexCount += 4; SetGlowRenderState( renderer ); @@ -122,7 +137,7 @@ void Tr2Sprite2d::GatherSprites( Tr2Sprite2dScene* renderer ) SetValidatedTextures( renderer ); - int indexCount = (m_vertexCount / 4) * 6; + int indexCount = ( m_vertexCount / 4 ) * 6; renderer->RenderTriangleVerts( &m_vertices[m_firstVertex], m_vertexCount, s_spriteIndices, indexCount ); } @@ -143,7 +158,7 @@ ITr2SpriteObject* Tr2Sprite2d::PickPoint( float x, float y, Tr2Sprite2dScene* re } } } - + return NULL; } @@ -161,7 +176,7 @@ unsigned int Tr2Sprite2d::GetVertexCount() { vertexCount += 4; } - if( (m_glowFactor != 0.0f) || (m_glowExpand != 0.0f) ) + if( ( m_glowFactor != 0.0f ) || ( m_glowExpand != 0.0f ) ) { vertexCount += 4; } @@ -173,4 +188,3 @@ unsigned int Tr2Sprite2d::GetVertexCount() return m_vertexCount; } } - diff --git a/trinity/Sprite2d/Tr2Sprite2d.h b/trinity/Sprite2d/Tr2Sprite2d.h index 58a3832ad..4e32693f0 100644 --- a/trinity/Sprite2d/Tr2Sprite2d.h +++ b/trinity/Sprite2d/Tr2Sprite2d.h @@ -13,12 +13,11 @@ BLUE_DECLARE( Tr2Sprite2d ); BLUE_DECLARE( Tr2Sprite2dTexture ); BLUE_DECLARE_INTERFACE( ITr2Sprite2dTexture ); -class Tr2Sprite2d: - public Tr2TexturedSpriteObject +class Tr2Sprite2d : public Tr2TexturedSpriteObject { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2d( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2d( IRoot* lockobj = NULL ); ~Tr2Sprite2d(); ////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Sprite2d/Tr2Sprite2dArc.cpp b/trinity/Sprite2d/Tr2Sprite2dArc.cpp index 21d876f8a..bc13e3d10 100644 --- a/trinity/Sprite2d/Tr2Sprite2dArc.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dArc.cpp @@ -17,7 +17,6 @@ Tr2Sprite2dArc::Tr2Sprite2dArc( IRoot* lockobj /*= NULL */ ) : m_renderVertexCount( 0 ), m_renderIndices( "Tr2Sprite2dArc/m_renderIndices" ) { - } Tr2Sprite2dArc::~Tr2Sprite2dArc() @@ -29,7 +28,7 @@ unsigned int Tr2Sprite2dArc::GetVertexCount() { unsigned int numVerts = 0; - float arcLength = (m_endAngle - m_startAngle) * m_radius; + float arcLength = ( m_endAngle - m_startAngle ) * m_radius; unsigned int numSteps = (unsigned int)arcLength / 4; if( m_lineWidth > 0 ) { @@ -51,7 +50,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) { CCP_STATS_ZONE( __FUNCTION__ ); - if( !m_display || (m_spriteEffect == TR2_SFX_NONE) || (m_radius == 0.0f) || (m_startAngle >= m_endAngle) ) + if( !m_display || ( m_spriteEffect == TR2_SFX_NONE ) || ( m_radius == 0.0f ) || ( m_startAngle >= m_endAngle ) ) { if( m_renderVertices ) { @@ -73,7 +72,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) // Don't draw if we're still loading (or failed) return; } - m_texturePrimary->Apply( renderer, 0 ); + m_texturePrimary->Apply( renderer, 0 ); } else { @@ -81,7 +80,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) return; } - if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) + if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) { if( m_textureSecondary ) { @@ -90,7 +89,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) // Don't draw if we're still loading (or failed) return; } - m_textureSecondary->Apply( renderer, 1 ); + m_textureSecondary->Apply( renderer, 1 ); } else { @@ -100,7 +99,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) } } - // Anti-aliased lines are rendered with a quad that is larger. This is then + // Anti-aliased lines are rendered with a quad that is larger. This is then // compensated for in the pixel shader, using the extra pixels to fill in // alpha values to do the anti-aliasing @@ -111,14 +110,14 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) SetRegularRenderState( renderer ); m_renderVertexCapacity = GetVertexCount(); - m_renderVertices = static_cast( CCP_MALLOC( - "Tr2Sprite2dArc/m_renderVertices", + m_renderVertices = static_cast( CCP_MALLOC( + "Tr2Sprite2dArc/m_renderVertices", m_renderVertexCapacity * sizeof( Tr2Sprite2dD3DVertex ) ) ); m_renderVertexCount = 0; - float arcLength = (m_endAngle - m_startAngle) * m_radius; + float arcLength = ( m_endAngle - m_startAngle ) * m_radius; unsigned int numSteps = (unsigned int)arcLength / 4; - float stepSize = (m_endAngle - m_startAngle) / (float)numSteps; + float stepSize = ( m_endAngle - m_startAngle ) / (float)numSteps; ++numSteps; if( m_lineWidth > 0.0f ) @@ -131,7 +130,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) { innerRadius -= 2.0f; outerRadius += 2.0f; - pixelWidthInTexels = 1.0f / (m_lineWidth + 4.0f); + pixelWidthInTexels = 1.0f / ( m_lineWidth + 4.0f ); } float a = m_startAngle; @@ -158,10 +157,10 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) v0.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, m_lineWidth ); v1.texCoord[1] = Vector2( -pixelWidthInTexels, m_lineWidth ); } - renderer->PrepareTriangleVerts( - m_renderVertices + m_renderVertexCount, - verts, - sizeof( Tr2Sprite2dVertexBase ), + renderer->PrepareTriangleVerts( + m_renderVertices + m_renderVertexCount, + verts, + sizeof( Tr2Sprite2dVertexBase ), 2 ); if( i < numSteps - 1 ) @@ -192,14 +191,14 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) if( isAA ) { innerRadius += 2.0f; - pixelWidthInTexels = 1.0f / (innerRadius + 4.0f); + pixelWidthInTexels = 1.0f / ( innerRadius + 4.0f ); float angleDelta = 0.5f / m_radius; startAngle += angleDelta * 0.5f; endAngle -= angleDelta * 0.5f; - arcLength = (endAngle - startAngle) * m_radius; + arcLength = ( endAngle - startAngle ) * m_radius; numSteps = (unsigned int)arcLength / 4; - stepSize = (endAngle - startAngle) / (float)numSteps; + stepSize = ( endAngle - startAngle ) / (float)numSteps; ++numSteps; } @@ -210,8 +209,8 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) { fillVertCount += 8; } - Tr2Sprite2dVertexBase* verts = static_cast( CCP_MALLOC( - "Tr2Sprite2dArc/verts", + Tr2Sprite2dVertexBase* verts = static_cast( CCP_MALLOC( + "Tr2Sprite2dArc/verts", fillVertCount * sizeof( Tr2Sprite2dVertexBase ) ) ); unsigned int centerPointIx = m_renderVertexCount; @@ -237,8 +236,8 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) { Vector2 from = m_translation; Vector2 to; - to.x = cos( m_startAngle ) * (innerRadius - 2.0f) + m_translation.x; - to.y = sin( m_startAngle ) * (innerRadius - 2.0f) + m_translation.y; + to.x = cos( m_startAngle ) * ( innerRadius - 2.0f ) + m_translation.x; + to.y = sin( m_startAngle ) * ( innerRadius - 2.0f ) + m_translation.y; Vector2 d = Normalize( from - to ); @@ -250,42 +249,42 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) float halfWidth = 1.5f; Vector2 aaOffset = normal * 2.0f; - float pixelWidthInTexels = 1.0f / (1.0f + 4.0f); + float pixelWidthInTexels = 1.0f / ( 1.0f + 4.0f ); Tr2Sprite2dVertexBase& v0 = *currentVertex++; - v0.position.x = from.x - normal.x*halfWidth - aaOffset.x; - v0.position.y = from.y - normal.y*halfWidth - aaOffset.y; + v0.position.x = from.x - normal.x * halfWidth - aaOffset.x; + v0.position.y = from.y - normal.y * halfWidth - aaOffset.y; v0.position.z = m_depth; v0.color = m_color; v0.texCoord[1] = Vector2( -pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v1 = *currentVertex++; - v1.position.x = from.x + normal.x*halfWidth + aaOffset.x; - v1.position.y = from.y + normal.y*halfWidth + aaOffset.y; + v1.position.x = from.x + normal.x * halfWidth + aaOffset.x; + v1.position.y = from.y + normal.y * halfWidth + aaOffset.y; v1.position.z = m_depth; v1.color = m_color; v1.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v2 = *currentVertex++; - v2.position.x = to.x + normal.x*halfWidth + aaOffset.x; - v2.position.y = to.y + normal.y*halfWidth + aaOffset.y; + v2.position.x = to.x + normal.x * halfWidth + aaOffset.x; + v2.position.y = to.y + normal.y * halfWidth + aaOffset.y; v2.position.z = m_depth; v2.color = m_color; v2.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v3 = *currentVertex++; - v3.position.x = to.x - normal.x*halfWidth - aaOffset.x; - v3.position.y = to.y - normal.y*halfWidth - aaOffset.y; + v3.position.x = to.x - normal.x * halfWidth - aaOffset.x; + v3.position.y = to.y - normal.y * halfWidth - aaOffset.y; v3.position.z = m_depth; v3.color = m_color; v3.texCoord[1] = Vector2( -pixelWidthInTexels, 1.0f ); - m_renderIndices.push_back( 0 + m_renderVertexCount ); - m_renderIndices.push_back( 1 + m_renderVertexCount ); - m_renderIndices.push_back( 3 + m_renderVertexCount ); - m_renderIndices.push_back( 3 + m_renderVertexCount ); - m_renderIndices.push_back( 1 + m_renderVertexCount ); - m_renderIndices.push_back( 2 + m_renderVertexCount ); + m_renderIndices.push_back( 0 + m_renderVertexCount ); + m_renderIndices.push_back( 1 + m_renderVertexCount ); + m_renderIndices.push_back( 3 + m_renderVertexCount ); + m_renderIndices.push_back( 3 + m_renderVertexCount ); + m_renderIndices.push_back( 1 + m_renderVertexCount ); + m_renderIndices.push_back( 2 + m_renderVertexCount ); m_renderVertexCount += 4; CCP_ASSERT( m_renderVertexCount <= m_renderVertexCapacity ); @@ -293,8 +292,8 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) { Vector2 from = m_translation; Vector2 to; - to.x = cos( m_endAngle ) * (innerRadius - 2.0f) + m_translation.x; - to.y = sin( m_endAngle ) * (innerRadius - 2.0f) + m_translation.y; + to.x = cos( m_endAngle ) * ( innerRadius - 2.0f ) + m_translation.x; + to.y = sin( m_endAngle ) * ( innerRadius - 2.0f ) + m_translation.y; Vector2 d = Normalize( from - to ); @@ -306,42 +305,42 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) float halfWidth = 1.5f; Vector2 aaOffset = normal * 2.0f; - float pixelWidthInTexels = 1.0f / (1.0f + 4.0f); + float pixelWidthInTexels = 1.0f / ( 1.0f + 4.0f ); Tr2Sprite2dVertexBase& v0 = *currentVertex++; - v0.position.x = from.x - normal.x*halfWidth - aaOffset.x; - v0.position.y = from.y - normal.y*halfWidth - aaOffset.y; + v0.position.x = from.x - normal.x * halfWidth - aaOffset.x; + v0.position.y = from.y - normal.y * halfWidth - aaOffset.y; v0.position.z = m_depth; v0.color = m_color; v0.texCoord[1] = Vector2( -pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v1 = *currentVertex++; - v1.position.x = from.x + normal.x*halfWidth + aaOffset.x; - v1.position.y = from.y + normal.y*halfWidth + aaOffset.y; + v1.position.x = from.x + normal.x * halfWidth + aaOffset.x; + v1.position.y = from.y + normal.y * halfWidth + aaOffset.y; v1.position.z = m_depth; v1.color = m_color; v1.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v2 = *currentVertex++; - v2.position.x = to.x + normal.x*halfWidth + aaOffset.x; - v2.position.y = to.y + normal.y*halfWidth + aaOffset.y; + v2.position.x = to.x + normal.x * halfWidth + aaOffset.x; + v2.position.y = to.y + normal.y * halfWidth + aaOffset.y; v2.position.z = m_depth; v2.color = m_color; v2.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, 1.0f ); Tr2Sprite2dVertexBase& v3 = *currentVertex++; - v3.position.x = to.x - normal.x*halfWidth - aaOffset.x; - v3.position.y = to.y - normal.y*halfWidth - aaOffset.y; + v3.position.x = to.x - normal.x * halfWidth - aaOffset.x; + v3.position.y = to.y - normal.y * halfWidth - aaOffset.y; v3.position.z = m_depth; v3.color = m_color; v3.texCoord[1] = Vector2( -pixelWidthInTexels, 1.0f ); - m_renderIndices.push_back( 0 + m_renderVertexCount ); - m_renderIndices.push_back( 1 + m_renderVertexCount ); - m_renderIndices.push_back( 3 + m_renderVertexCount ); - m_renderIndices.push_back( 3 + m_renderVertexCount ); - m_renderIndices.push_back( 1 + m_renderVertexCount ); - m_renderIndices.push_back( 2 + m_renderVertexCount ); + m_renderIndices.push_back( 0 + m_renderVertexCount ); + m_renderIndices.push_back( 1 + m_renderVertexCount ); + m_renderIndices.push_back( 3 + m_renderVertexCount ); + m_renderIndices.push_back( 3 + m_renderVertexCount ); + m_renderIndices.push_back( 1 + m_renderVertexCount ); + m_renderIndices.push_back( 2 + m_renderVertexCount ); m_renderVertexCount += 4; CCP_ASSERT( m_renderVertexCount <= m_renderVertexCapacity ); @@ -366,7 +365,7 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) if( i > 0 ) { m_renderIndices.push_back( -1 + m_renderVertexCount ); - m_renderIndices.push_back( 0 + m_renderVertexCount ); + m_renderIndices.push_back( 0 + m_renderVertexCount ); m_renderIndices.push_back( centerPointIx ); } @@ -376,14 +375,13 @@ void Tr2Sprite2dArc::GatherSprites( Tr2Sprite2dScene* renderer ) CCP_ASSERT( m_renderVertexCount <= m_renderVertexCapacity ); } - renderer->PrepareTriangleVerts( - m_renderVertices + centerPointIx, - verts, - sizeof( Tr2Sprite2dVertexBase ), + renderer->PrepareTriangleVerts( + m_renderVertices + centerPointIx, + verts, + sizeof( Tr2Sprite2dVertexBase ), fillVertCount ); CCP_FREE( verts ); - } m_isDirty = false; diff --git a/trinity/Sprite2d/Tr2Sprite2dArc.h b/trinity/Sprite2d/Tr2Sprite2dArc.h index 1a8a45d9e..f5ac307da 100644 --- a/trinity/Sprite2d/Tr2Sprite2dArc.h +++ b/trinity/Sprite2d/Tr2Sprite2dArc.h @@ -10,8 +10,7 @@ BLUE_DECLARE( Tr2Sprite2dArc ); BLUE_DECLARE_INTERFACE( ITr2Sprite2dTexture ); -class Tr2Sprite2dArc : - public Tr2SpriteObject +class Tr2Sprite2dArc : public Tr2SpriteObject { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Sprite2d/Tr2Sprite2dArc_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dArc_Blue.cpp index 3e36db0b8..8bdd07198 100644 --- a/trinity/Sprite2d/Tr2Sprite2dArc_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dArc_Blue.cpp @@ -7,72 +7,55 @@ BLUE_DEFINE( Tr2Sprite2dArc ); const Be::ClassInfo* Tr2Sprite2dArc::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dArc, "" ) - MAP_INTERFACE( Tr2Sprite2dArc ) + EXPOSURE_BEGIN( Tr2Sprite2dArc, "" ) + MAP_INTERFACE( Tr2Sprite2dArc ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "radius", m_radius, "Radius", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "Width of line rendered", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "lineColor", m_lineColor, "Color of line rendered", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "startAngle", m_startAngle, "Start angle of the arc", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "endAngle", m_endAngle, "Ending angle of the arc", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "fill", m_fill, "If set, the arc is filled - otherwise only a line is drawn", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "texturePrimary", m_texturePrimary, "Primary texture for this object", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureSecondary", m_textureSecondary, "Secondary texture for this object", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2SpriteObject ) } - diff --git a/trinity/Sprite2d/Tr2Sprite2dContainer.cpp b/trinity/Sprite2d/Tr2Sprite2dContainer.cpp index b4c81b952..b52b3037c 100644 --- a/trinity/Sprite2d/Tr2Sprite2dContainer.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dContainer.cpp @@ -21,14 +21,14 @@ Tr2Sprite2dContainerBase::~Tr2Sprite2dContainerBase() { if( *it ) { - (*it)->SetParent( nullptr ); + ( *it )->SetParent( nullptr ); } } for( auto it = m_children.begin(); it != m_children.end(); ++it ) { if( *it ) { - (*it)->SetParent( nullptr ); + ( *it )->SetParent( nullptr ); } } } @@ -45,41 +45,38 @@ void Tr2Sprite2dContainerBase::OnListModified( long event, /* BLUELISTEVENT valu { switch( event ) { - case BELIST_INSERTED: + case BELIST_INSERTED: { + ITr2SpriteObjectPtr spriteObj( BlueCastPtr( value ) ); + if( spriteObj ) { - ITr2SpriteObjectPtr spriteObj( BlueCastPtr( value ) ); - if( spriteObj ) - { - spriteObj->SetParent( this ); - SetChildDirty( spriteObj ); - } + spriteObj->SetParent( this ); + SetChildDirty( spriteObj ); } - break; + } + break; - case BELIST_REMOVED: + case BELIST_REMOVED: { + ITr2SpriteObjectPtr spriteObj( BlueCastPtr( value ) ); + if( spriteObj ) { - ITr2SpriteObjectPtr spriteObj( BlueCastPtr( value ) ); - if( spriteObj ) - { - spriteObj->SetParent( nullptr ); - SetChildDirty( spriteObj ); - } + spriteObj->SetParent( nullptr ); + SetChildDirty( spriteObj ); } - break; + } + break; - case BELIST_UNLOADSTART: + case BELIST_UNLOADSTART: { + ssize_t size = theList->GetSize(); + for( ssize_t i = 0; i < size; ++i ) { - ssize_t size = theList->GetSize(); - for( ssize_t i = 0; i < size; ++i ) + ITr2SpriteObjectPtr child = BlueCastPtr( theList->GetAt( i ) ); + if( child ) { - ITr2SpriteObjectPtr child = BlueCastPtr( theList->GetAt( i ) ); - if( child ) - { - child->SetParent( nullptr ); - } + child->SetParent( nullptr ); } } - break; + } + break; } } @@ -110,7 +107,7 @@ Tr2Sprite2dContainer::~Tr2Sprite2dContainer() void Tr2Sprite2dContainer::GatherSprites( Tr2Sprite2dScene* renderer ) { - if( !m_display || (m_children.empty() && m_background.empty()) ) + if( !m_display || ( m_children.empty() && m_background.empty() ) ) { return; } @@ -201,7 +198,7 @@ void Tr2Sprite2dContainer::GatherSprites( Tr2Sprite2dScene* renderer ) } else { - GatherSpritesHelper(renderer); + GatherSpritesHelper( renderer ); m_isDirty = false; } } @@ -311,11 +308,11 @@ void Tr2Sprite2dContainer::GatherSpritesHelper( Tr2Sprite2dScene* renderer ) for( ITr2SpriteObjectVector::reverse_iterator it = m_background.rbegin(); it != m_background.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } for( ITr2SpriteObjectVector::reverse_iterator it = m_children.rbegin(); it != m_children.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } if( m_clip ) @@ -332,4 +329,3 @@ void Tr2Sprite2dContainer::GatherSpritesHelper( Tr2Sprite2dScene* renderer ) renderer->PopTransformAbsolute(); } } - diff --git a/trinity/Sprite2d/Tr2Sprite2dContainer.h b/trinity/Sprite2d/Tr2Sprite2dContainer.h index d7ee257de..1ed6216d3 100644 --- a/trinity/Sprite2d/Tr2Sprite2dContainer.h +++ b/trinity/Sprite2d/Tr2Sprite2dContainer.h @@ -11,9 +11,8 @@ BLUE_DECLARE( Tr2Sprite2dContainer ); BLUE_DECLARE_IVECTOR( ITr2SpriteObject ); -class Tr2Sprite2dContainerBase: - public Tr2SpriteObjectBase, - public IListNotify +class Tr2Sprite2dContainerBase : public Tr2SpriteObjectBase, + public IListNotify { public: EXPOSE_TO_BLUE(); @@ -27,27 +26,24 @@ class Tr2Sprite2dContainerBase: ////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); protected: float m_opacity; PITr2SpriteObjectVector m_children; PITr2SpriteObjectVector m_background; - }; -class Tr2Sprite2dContainer: - public Tr2Sprite2dContainerBase +class Tr2Sprite2dContainer : public Tr2Sprite2dContainerBase { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2dContainer( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2dContainer( IRoot* lockobj = NULL ); ~Tr2Sprite2dContainer(); ////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Sprite2d/Tr2Sprite2dContainer_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dContainer_Blue.cpp index 49bb5f5fa..bfc588889 100644 --- a/trinity/Sprite2d/Tr2Sprite2dContainer_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dContainer_Blue.cpp @@ -8,104 +8,84 @@ BLUE_DEFINE( Tr2Sprite2dContainer ); const Be::ClassInfo* Tr2Sprite2dContainerBase::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dContainerBase, "" ) + EXPOSURE_BEGIN( Tr2Sprite2dContainerBase, "" ) MAP_INTERFACE( ITr2SpriteObject ) MAP_INTERFACE( IListNotify ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "children", m_children, "Children of this container", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "background", m_background, "Background objects of this container. Background objects don't get alignment,\n" "but always fill the extent of the container. They are never considered for\n" "picking, either.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "opacity", m_opacity, "Opacity of this container (and it's children)", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2SpriteObjectBase ) } const Be::ClassInfo* Tr2Sprite2dContainer::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dContainer, "" ) + EXPOSURE_BEGIN( Tr2Sprite2dContainer, "" ) - MAP_ATTRIBUTE - ( - "depthMin", - m_depthMin, + MAP_ATTRIBUTE( + "depthMin", + m_depthMin, "Minimum depth for children of this container. This is relative to parent" "\ndepth, a value from -1 to 1 (inclusive).", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "depthMax", - m_depthMax, + MAP_ATTRIBUTE( + "depthMax", + m_depthMax, "Maximum depth for children of this container. This is relative to parent" "\ndepth, a value from -1 to 1 (inclusive).", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "absoluteCoordinates", m_absoluteCoordinates, "Used for absolute alignment - resets the transforms applied by parent to identity.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "clip", m_clip, "If set, the children are clipped to fit within the clip rectangle of the container", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "pickRadius", m_pickRadius, "Radius to use when picking. If radius is 0 the container is treated as" "\na rectangular area.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "cacheContents", m_cacheContentsHint, "Should contents of this container be cached? This can drastically improve\n" "render performance of containers with static contents. This flag is only\n" "a hint, the container uses caching when it doesn't change too often.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isCachingContents", m_cacheContents, "Is the contents of this container currently cached. Use cacheContents to\n" "turn caching on/off.", - Be::READ - ) + Be::READ ) EXPOSURE_CHAINTO( Tr2Sprite2dContainerBase ) } diff --git a/trinity/Sprite2d/Tr2Sprite2dDisplayList.cpp b/trinity/Sprite2d/Tr2Sprite2dDisplayList.cpp index a0287aa9e..3504c0894 100644 --- a/trinity/Sprite2d/Tr2Sprite2dDisplayList.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dDisplayList.cpp @@ -7,9 +7,9 @@ using namespace Tr2RenderContextEnum; -CCP_STATS_DECLARE( displayListCount, "Trinity/SpriteScene/displayListCount", false, CST_COUNTER_LOW, "Number of cached display lists."); -CCP_STATS_DECLARE( displayListVertexBufferSize, "Trinity/SpriteScene/displayListVertexBufferSize", false, CST_COUNTER_HIGH, "Total size of vertex buffers used by cached display lists."); -CCP_STATS_DECLARE( displayListIndexBufferSize, "Trinity/SpriteScene/displayListIndexBufferSize", false, CST_COUNTER_HIGH, "Total size of index buffers used by cached display lists."); +CCP_STATS_DECLARE( displayListCount, "Trinity/SpriteScene/displayListCount", false, CST_COUNTER_LOW, "Number of cached display lists." ); +CCP_STATS_DECLARE( displayListVertexBufferSize, "Trinity/SpriteScene/displayListVertexBufferSize", false, CST_COUNTER_HIGH, "Total size of vertex buffers used by cached display lists." ); +CCP_STATS_DECLARE( displayListIndexBufferSize, "Trinity/SpriteScene/displayListIndexBufferSize", false, CST_COUNTER_HIGH, "Total size of index buffers used by cached display lists." ); Tr2Sprite2dDisplayList::Tr2Sprite2dDisplayList( ITr2SpriteObject* owner ) : m_owner( owner ) @@ -66,9 +66,9 @@ void Tr2Sprite2dDisplayList::Entry::SubmitGeometry( Tr2RenderContext& renderCont } FillAndSetConstants( - *m_uiTransformsCb, + *m_uiTransformsCb, transposedMatrixes, - sizeof( transposedMatrixes[0] ) * TR2_SS_MAX_TRANSFORM_COUNT, + sizeof( transposedMatrixes[0] ) * TR2_SS_MAX_TRANSFORM_COUNT, VERTEX_SHADER, Tr2Renderer::GetPerObjectVSGUIStartRegister(), renderContext ); diff --git a/trinity/Sprite2d/Tr2Sprite2dDisplayList.h b/trinity/Sprite2d/Tr2Sprite2dDisplayList.h index 1e655166a..c8799c2f9 100644 --- a/trinity/Sprite2d/Tr2Sprite2dDisplayList.h +++ b/trinity/Sprite2d/Tr2Sprite2dDisplayList.h @@ -15,8 +15,7 @@ BLUE_DECLARE( TriRenderJob ); BLUE_DECLARE( Tr2AtlasTexture ); BLUE_DECLARE( Tr2Effect ); -struct Tr2Sprite2dDisplayList: - public Tr2DeviceResource +struct Tr2Sprite2dDisplayList : public Tr2DeviceResource { Tr2BufferAL vertexBuffer; Tr2BufferAL indexBuffer; @@ -35,7 +34,7 @@ struct Tr2Sprite2dDisplayList: Tr2AtlasTexturePtr texture1; Tr2EffectPtr effect; //hardcoded due to need for CB slot//Tr2EffectConstant transformsHandle; - Matrix transformArray[ TR2_SS_MAX_TRANSFORM_COUNT ]; + Matrix transformArray[TR2_SS_MAX_TRANSFORM_COUNT]; Tr2ConstantBufferAL* m_uiTransformsCb; ////////////////////////////////////////////////////////////////////////// @@ -51,6 +50,7 @@ struct Tr2Sprite2dDisplayList: ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ) override; + private: bool OnPrepareResources(); diff --git a/trinity/Sprite2d/Tr2Sprite2dFrame.cpp b/trinity/Sprite2d/Tr2Sprite2dFrame.cpp index b588fb25c..076408f82 100644 --- a/trinity/Sprite2d/Tr2Sprite2dFrame.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dFrame.cpp @@ -9,32 +9,68 @@ // All frames can use the same indices - the layout of the frame is always the same. static unsigned short s_frameIndices[] = { - 0, 4, 5, - 0, 5, 1, - 1, 5, 6, - 1, 6, 2, - 2, 6, 7, - 2, 7, 3, - 4, 8, 9, - 4, 9, 5, - 6, 10, 11, - 6, 11, 7, - 8, 12, 13, - 8, 13, 9, - 9, 13, 14, - 9, 14, 10, - 10, 14, 15, - 10, 15, 11, + 0, + 4, + 5, + 0, + 5, + 1, + 1, + 5, + 6, + 1, + 6, + 2, + 2, + 6, + 7, + 2, + 7, + 3, + 4, + 8, + 9, + 4, + 9, + 5, + 6, + 10, + 11, + 6, + 11, + 7, + 8, + 12, + 13, + 8, + 13, + 9, + 9, + 13, + 14, + 9, + 14, + 10, + 10, + 14, + 15, + 10, + 15, + 11, // The two triangles in the center are kept last - then we can skip the // center by sending fewer triangles. - 5, 9, 10, - 5, 10, 6, + 5, + 9, + 10, + 5, + 10, + 6, }; static const Color WHITE( 1.0f, 1.0f, 1.0f, 1.0f ); -Tr2Sprite2dFrame::Tr2Sprite2dFrame( IRoot* lockobj ) : +Tr2Sprite2dFrame::Tr2Sprite2dFrame( IRoot* lockobj ) : m_cornerSize( 0 ), m_cornerScale( 1.f ), m_offset( 0 ), @@ -130,7 +166,7 @@ void Tr2Sprite2dFrame::GatherSprites( Tr2Sprite2dScene* renderer ) unsigned int triangleCount = m_fillCenter ? 18 : 16; unsigned int indexCount = triangleCount * 3; - + if( m_shadowOffset.x != 0.0f || m_shadowOffset.y != 0.0f ) { renderer->RenderTriangleVerts( &m_vertices[0], 16, &s_frameIndices[0], indexCount ); diff --git a/trinity/Sprite2d/Tr2Sprite2dFrame.h b/trinity/Sprite2d/Tr2Sprite2dFrame.h index 0a562dd66..99b9fcd95 100644 --- a/trinity/Sprite2d/Tr2Sprite2dFrame.h +++ b/trinity/Sprite2d/Tr2Sprite2dFrame.h @@ -13,20 +13,19 @@ BLUE_DECLARE( Tr2Sprite2dFrame ); BLUE_DECLARE( Tr2Sprite2dTexture ); ////////////////////////////////////////////////////////////////////////// -// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the +// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the // Tr2Sprite2dScene to render 2D scenes. // -// It renders a frame by cutting a texture in nine pieces and stretching them +// It renders a frame by cutting a texture in nine pieces and stretching them // appropriately according to the dimensions of the frame. // // See http://carbon/wiki/Tr2Sprite2dFrame for more details. ////////////////////////////////////////////////////////////////////////// -class Tr2Sprite2dFrame: - public Tr2TexturedSpriteObject +class Tr2Sprite2dFrame : public Tr2TexturedSpriteObject { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2dFrame( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2dFrame( IRoot* lockobj = NULL ); ////////////////////////////////////////////////////////////////////////// // ITr2SpriteObject diff --git a/trinity/Sprite2d/Tr2Sprite2dFrame_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dFrame_Blue.cpp index 49a59d82e..a59a013ca 100644 --- a/trinity/Sprite2d/Tr2Sprite2dFrame_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dFrame_Blue.cpp @@ -8,24 +8,20 @@ BLUE_DEFINE( Tr2Sprite2dFrame ); const Be::ClassInfo* Tr2Sprite2dFrame::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dFrame, "" ) - MAP_INTERFACE( Tr2Sprite2dFrame ) + EXPOSURE_BEGIN( Tr2Sprite2dFrame, "" ) + MAP_INTERFACE( Tr2Sprite2dFrame ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "offset", m_offset, "Offset the frame. Positive values will make it smaller, and negative bigger.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "cornerSize", - m_cornerSize, - "Size of the corner of the frame", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "cornerSize", + m_cornerSize, + "Size of the corner of the frame", + Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "cornerScale", @@ -33,13 +29,11 @@ const Be::ClassInfo* Tr2Sprite2dFrame::ExposeToBlue() "Corner size scaling when rendering the frame; used for UI scaling", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "fillCenter", m_fillCenter, "If set, the center of the frame is filled (this is the default).", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } diff --git a/trinity/Sprite2d/Tr2Sprite2dLayer.cpp b/trinity/Sprite2d/Tr2Sprite2dLayer.cpp index 5f1471693..49a27200c 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLayer.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLayer.cpp @@ -6,7 +6,7 @@ using namespace Tr2RenderContextEnum; -CCP_STATS_DECLARE( spriteSceneLayerMemoryUse, "Trinity/SpriteScene/LayerMemoryUse", false, CST_MEMORY, "Memory used for layer render targets" ); +CCP_STATS_DECLARE( spriteSceneLayerMemoryUse, "Trinity/SpriteScene/LayerMemoryUse", false, CST_MEMORY, "Memory used for layer render targets" ); Tr2Sprite2dLayer::Tr2Sprite2dLayer( IRoot* lockobj ) : Tr2Sprite2dContainer( lockobj ), @@ -66,11 +66,11 @@ void Tr2Sprite2dLayer::GatherSprites( Tr2Sprite2dScene* renderer ) for( ITr2SpriteObjectVector::reverse_iterator it = m_background.rbegin(); it != m_background.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } for( ITr2SpriteObjectVector::reverse_iterator it = m_children.rbegin(); it != m_children.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } m_isDirty = false; @@ -92,12 +92,12 @@ bool Tr2Sprite2dLayer::OnPrepareResources() } USE_MAIN_THREAD_RENDER_CONTEXT(); - HRESULT hr = m_renderTarget.Create( - Tr2BitmapDimensions( (uint32_t)m_displayWidth, (uint32_t)m_displayHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), + HRESULT hr = m_renderTarget.Create( + Tr2BitmapDimensions( (uint32_t)m_displayWidth, (uint32_t)m_displayHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::RENDER_TARGET, Tr2CpuUsage::READ, renderContext ); - + if( FAILED( hr ) ) { CCP_LOGERR( "Tr2Sprite2dLayer::AllocateRenderTarget failed to create a render target" ); @@ -116,13 +116,13 @@ void Tr2Sprite2dLayer::ReleaseResources( TriStorage s ) void Tr2Sprite2dLayer::AllocateRenderTarget() { - if( m_renderTarget.IsValid() && ((uint32_t)m_displayWidth == m_renderTarget.GetWidth() ) && ((uint32_t)m_displayHeight == m_renderTarget.GetHeight() ) ) + if( m_renderTarget.IsValid() && ( (uint32_t)m_displayWidth == m_renderTarget.GetWidth() ) && ( (uint32_t)m_displayHeight == m_renderTarget.GetHeight() ) ) { return; } m_isDirty = true; - + FreeRenderTarget(); PrepareResources(); @@ -139,7 +139,6 @@ unsigned int Tr2Sprite2dLayer::GetVertexCount() { CCP_ASSERT_M( false, "Tr2Sprite2dLayer::GetVertexCount not implemented" ); return 0; - } void Tr2Sprite2dLayer::SetTextureSecondary( ITr2Sprite2dTexture* t ) @@ -168,4 +167,3 @@ void Tr2Sprite2dLayer::Sprite2dTextureChanged( ITr2Sprite2dTexture* p ) { SetDirty(); } - diff --git a/trinity/Sprite2d/Tr2Sprite2dLayer.h b/trinity/Sprite2d/Tr2Sprite2dLayer.h index 46a4a2538..3452eaedf 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLayer.h +++ b/trinity/Sprite2d/Tr2Sprite2dLayer.h @@ -13,10 +13,9 @@ BLUE_DECLARE( Tr2Sprite2dLayer ); BLUE_DECLARE_IVECTOR( ITr2SpriteObject ); BLUE_DECLARE( Tr2Effect ); -class Tr2Sprite2dLayer: - public Tr2Sprite2dContainer, - public Tr2DeviceResource, - public ITr2Sprite2dTextureNotifyTarget +class Tr2Sprite2dLayer : public Tr2Sprite2dContainer, + public Tr2DeviceResource, + public ITr2Sprite2dTextureNotifyTarget { public: EXPOSE_TO_BLUE(); @@ -36,6 +35,7 @@ class Tr2Sprite2dLayer: ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); @@ -47,7 +47,7 @@ class Tr2Sprite2dLayer: private: Tr2TextureAL m_renderTarget; - + // If m_clearBackground is set, background is cleared to this color Color m_backgroundColor; diff --git a/trinity/Sprite2d/Tr2Sprite2dLayer_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dLayer_Blue.cpp index b0b16ff5c..186aa3bbf 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLayer_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLayer_Blue.cpp @@ -7,65 +7,52 @@ BLUE_DEFINE( Tr2Sprite2dLayer ); const Be::ClassInfo* Tr2Sprite2dLayer::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dLayer, "" ) - MAP_INTERFACE( Tr2Sprite2dLayer ) - - MAP_ATTRIBUTE - ( - "backgroundColor", - m_backgroundColor, - "Background color for this layer", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( - "color", - m_color, - "Color for this layer", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + EXPOSURE_BEGIN( Tr2Sprite2dLayer, "" ) + MAP_INTERFACE( Tr2Sprite2dLayer ) + + MAP_ATTRIBUTE( + "backgroundColor", + m_backgroundColor, + "Background color for this layer", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( + "color", + m_color, + "Color for this layer", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + + MAP_ATTRIBUTE( "clearBackground", m_clearBackground, "If set, background is cleared to 'backgroundColor'", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "blendMode", m_blendMode, "Blendmode controls how the object blends with the background", Be::READWRITE | Be::ENUM | Be::NOTIFY, - Tr2SpriteObjectBlendModeChooser - ) + Tr2SpriteObjectBlendModeChooser ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "spriteEffect", m_spriteEffect, "Sprite effect controls how textures are used to render the object", Be::READWRITE | Be::ENUM | Be::NOTIFY, - Tr2SpriteObjectEffectChooser - ) + Tr2SpriteObjectEffectChooser ) - MAP_PROPERTY - ( + MAP_PROPERTY( "textureSecondary", - GetTextureSecondary, SetTextureSecondary, - "Secondary texture for this sprite" - ) + GetTextureSecondary, + SetTextureSecondary, + "Secondary texture for this sprite" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "children", m_children, "Children of this Layer", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) EXPOSURE_CHAINTO( Tr2Sprite2dContainer ) } diff --git a/trinity/Sprite2d/Tr2Sprite2dLine.cpp b/trinity/Sprite2d/Tr2Sprite2dLine.cpp index 84da7be4b..ece8b02dc 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLine.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLine.cpp @@ -5,8 +5,13 @@ #include "Tr2Sprite2dTexture.h" #include "Tr2Sprite2dScene.h" -static unsigned short s_spriteIndices[6] = { - 0, 1, 3, 3, 1, 2 +static unsigned short s_spriteIndices[6] = { + 0, + 1, + 3, + 3, + 1, + 2 }; Tr2Sprite2dLine::Tr2Sprite2dLine( IRoot* lockobj /*= NULL */ ) : @@ -14,11 +19,11 @@ Tr2Sprite2dLine::Tr2Sprite2dLine( IRoot* lockobj /*= NULL */ ) : m_translationTo( 0.0f, 0.0f ), m_widthFrom( 0.0f ), m_widthTo( 0.0f ), - m_colorFrom( 1.0f, 1.0f, 1.0f, 1.0f), - m_colorTo( 1.0f, 1.0f, 1.0f, 1.0f), - m_textureWidth(1.0), - m_textureOffsetBase(0.0), - m_textureOffset(0.0) + m_colorFrom( 1.0f, 1.0f, 1.0f, 1.0f ), + m_colorTo( 1.0f, 1.0f, 1.0f, 1.0f ), + m_textureWidth( 1.0 ), + m_textureOffsetBase( 0.0 ), + m_textureOffset( 0.0 ) { std::fill( std::begin( m_vertices ), std::end( m_vertices ), Tr2Sprite2dD3DVertex() ); } @@ -27,7 +32,7 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) { CCP_STATS_ZONE( __FUNCTION__ ); - if( !m_display || (m_spriteEffect == TR2_SFX_NONE) ) + if( !m_display || ( m_spriteEffect == TR2_SFX_NONE ) ) { return; } @@ -40,7 +45,7 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) } renderer->SetSpriteEffect( m_spriteEffect ); - renderer->SetTileMode( S2D_TS_TILE_X | S2D_TS_TILE_Y); + renderer->SetTileMode( S2D_TS_TILE_X | S2D_TS_TILE_Y ); SetRegularRenderState( renderer ); @@ -56,10 +61,10 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) normal.x = d.y; normal.y = -d.x; - float halfWidthFrom = 0.5f*m_widthFrom; - float halfWidthTo = 0.5f*m_widthTo; + float halfWidthFrom = 0.5f * m_widthFrom; + float halfWidthTo = 0.5f * m_widthTo; - // Anti-aliased lines are rendered with a quad that is larger. This is then + // Anti-aliased lines are rendered with a quad that is larger. This is then // compensated for in the pixel shader, using the extra pixels to fill in // alpha values to do the anti-aliasing @@ -71,18 +76,18 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) halfWidthFrom += 2.0f; halfWidthTo += 2.0f; - pixelWidthFromInTexels = 1.0f / (m_widthFrom + 4.0f); - pixelWidthToInTexels = 1.0f / (m_widthTo + 4.0f); + pixelWidthFromInTexels = 1.0f / ( m_widthFrom + 4.0f ); + pixelWidthToInTexels = 1.0f / ( m_widthTo + 4.0f ); } - + float texOffset1 = m_textureOffsetBase - m_textureOffset; float texOffset2 = m_textureOffsetBase + segmentLength / m_textureWidth - m_textureOffset; Tr2Sprite2dVertexBase verts[4]; Tr2Sprite2dVertexBase& v0 = verts[0]; - v0.position.x = from.x - normal.x*halfWidthFrom; - v0.position.y = from.y - normal.y*halfWidthFrom; + v0.position.x = from.x - normal.x * halfWidthFrom; + v0.position.y = from.y - normal.y * halfWidthFrom; v0.position.z = m_depth; v0.color = m_colorFrom; v0.texCoord[0] = Vector2( texOffset1, 0.0f ); @@ -97,8 +102,8 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) } Tr2Sprite2dVertexBase& v1 = verts[1]; - v1.position.x = from.x + normal.x*halfWidthFrom; - v1.position.y = from.y + normal.y*halfWidthFrom; + v1.position.x = from.x + normal.x * halfWidthFrom; + v1.position.y = from.y + normal.y * halfWidthFrom; v1.position.z = m_depth; v1.color = m_colorFrom; v1.texCoord[0] = Vector2( texOffset1, 1.0f ); @@ -112,8 +117,8 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) } Tr2Sprite2dVertexBase& v2 = verts[2]; - v2.position.x = to.x + normal.x*halfWidthTo; - v2.position.y = to.y + normal.y*halfWidthTo; + v2.position.x = to.x + normal.x * halfWidthTo; + v2.position.y = to.y + normal.y * halfWidthTo; v2.position.z = m_depth; v2.color = m_colorTo; v2.texCoord[0] = Vector2( texOffset2, 1.0f ); @@ -127,8 +132,8 @@ void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer ) } Tr2Sprite2dVertexBase& v3 = verts[3]; - v3.position.x = to.x - normal.x*halfWidthTo; - v3.position.y = to.y - normal.y*halfWidthTo; + v3.position.x = to.x - normal.x * halfWidthTo; + v3.position.y = to.y - normal.y * halfWidthTo; v3.position.z = m_depth; v3.color = m_colorTo; v3.texCoord[0] = Vector2( texOffset2, 0.0f ); diff --git a/trinity/Sprite2d/Tr2Sprite2dLine.h b/trinity/Sprite2d/Tr2Sprite2dLine.h index b89d27b06..79dce2a22 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLine.h +++ b/trinity/Sprite2d/Tr2Sprite2dLine.h @@ -10,8 +10,7 @@ BLUE_DECLARE( Tr2Sprite2dLine ); BLUE_DECLARE_INTERFACE( ITr2Sprite2dTexture ); -class Tr2Sprite2dLine : - public Tr2TexturedSpriteObject +class Tr2Sprite2dLine : public Tr2TexturedSpriteObject { public: EXPOSE_TO_BLUE(); @@ -24,7 +23,6 @@ class Tr2Sprite2dLine : ITr2SpriteObject* PickPoint( float x, float y, Tr2Sprite2dScene* renderer ); private: - Tr2Sprite2dD3DVertex m_vertices[4]; Vector2 m_translationFrom; diff --git a/trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp b/trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp index 138c6f975..740e711bb 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp @@ -8,13 +8,13 @@ Tr2Sprite2dLineTraceVertex::Tr2Sprite2dLineTraceVertex( IRoot* lockobj /*= NULL */ ) : -m_position( 0.0f, 0.0f ), + m_position( 0.0f, 0.0f ), m_color( 1.0f, 1.0f, 1.0f, 1.0f ) { } Tr2Sprite2dLineTrace::Tr2Sprite2dLineTrace( IRoot* lockobj /*= NULL */ ) : -PARENTLOCK( m_vertices ), + PARENTLOCK( m_vertices ), m_lineWidth( 1.0f ), m_length( 0.0f ), m_start( 0.0f ), @@ -23,7 +23,7 @@ PARENTLOCK( m_vertices ), m_renderIndices( "Tr2Sprite2dLineTrace/m_renderIndices" ), m_renderVertices( "Tr2Sprite2dLineTrace/m_renderVertices" ), m_drawCalls( "Tr2Sprite2dLineTrace/m_drawCalls" ), - m_textureWidth( 1.0f), + m_textureWidth( 1.0f ), m_textureOffset( 0.0f ), m_textureOffsetAccum( 0.0f ), m_cornerType( CORNERTYPE_MITER ) @@ -40,7 +40,7 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) { CCP_STATS_ZONE( __FUNCTION__ ); - if( !m_display || m_vertices.empty() || (m_end <= m_start) || (m_spriteEffect == TR2_SFX_NONE) ) + if( !m_display || m_vertices.empty() || ( m_end <= m_start ) || ( m_spriteEffect == TR2_SFX_NONE ) ) { if( !m_renderVertices.empty() ) { @@ -64,7 +64,7 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) } renderer->SetSpriteEffect( m_spriteEffect ); - renderer->SetTileMode( S2D_TS_TILE_X | S2D_TS_TILE_Y); + renderer->SetTileMode( S2D_TS_TILE_X | S2D_TS_TILE_Y ); SetRegularRenderState( renderer ); @@ -81,7 +81,7 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) float lastRelativeLength = 0.0f; float length = 0.0f; - bool hasReachedStart = (m_start == 0.0f); + bool hasReachedStart = ( m_start == 0.0f ); bool hasReachedEnd = false; Vector2 fromPos = m_vertices[0]->m_position; @@ -99,8 +99,8 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) auto it = m_vertices.begin() + 1; while( !hasReachedEnd ) { - const Vector2& toPos = (*it)->m_position; - const Color& toColor = (*it)->m_color; + const Vector2& toPos = ( *it )->m_position; + const Color& toColor = ( *it )->m_color; Vector2 d = toPos - fromPos; float curLength = Length( d ); @@ -110,13 +110,13 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) Vector2 adjustedFromPos; Color adjustedFromColor; - if( !hasReachedStart && (relativeLength > m_start) ) + if( !hasReachedStart && ( relativeLength > m_start ) ) { // Line is starting - adjust fromPos float linePortionOfTotal = curLength / m_length; - float portionOfLineToRender = (m_start - lastRelativeLength) / linePortionOfTotal; - adjustedFromPos = toPos*portionOfLineToRender + fromPos*(1.0f - portionOfLineToRender); - adjustedFromColor = toColor*portionOfLineToRender + fromColor*(1.0f - portionOfLineToRender); + float portionOfLineToRender = ( m_start - lastRelativeLength ) / linePortionOfTotal; + adjustedFromPos = toPos * portionOfLineToRender + fromPos * ( 1.0f - portionOfLineToRender ); + adjustedFromColor = toColor * portionOfLineToRender + fromColor * ( 1.0f - portionOfLineToRender ); hasReachedStart = true; } else @@ -131,10 +131,10 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) { // Line is ending - adjust toPos float linePortionOfTotal = curLength / m_length; - float portionOfLineToRender = (m_end - lastRelativeLength) / linePortionOfTotal; - Vector2 adjustedToPos = toPos*portionOfLineToRender + fromPos*(1.0f - portionOfLineToRender); - Color adjustedToColor = toColor*portionOfLineToRender + fromColor*(1.0f - portionOfLineToRender); - AddSegment( renderer, adjustedFromPos, adjustedFromColor, prevCapAngle, adjustedToPos, adjustedToColor, 0.0f); + float portionOfLineToRender = ( m_end - lastRelativeLength ) / linePortionOfTotal; + Vector2 adjustedToPos = toPos * portionOfLineToRender + fromPos * ( 1.0f - portionOfLineToRender ); + Color adjustedToColor = toColor * portionOfLineToRender + fromColor * ( 1.0f - portionOfLineToRender ); + AddSegment( renderer, adjustedFromPos, adjustedFromColor, prevCapAngle, adjustedToPos, adjustedToColor, 0.0f ); hasReachedEnd = true; } else @@ -150,13 +150,13 @@ void Tr2Sprite2dLineTrace::GatherSprites( Tr2Sprite2dScene* renderer ) if( nextIt != m_vertices.end() ) { - const Vector2& toPos2 = (*nextIt)->m_position; + const Vector2& toPos2 = ( *nextIt )->m_position; Vector2 d2 = toPos2 - toPos; d = Normalize( d ); d2 = Normalize( d2 ); - capAngleTo = atan2(d2.y,d2.x) - atan2(d.y,d.x); + capAngleTo = atan2( d2.y, d2.x ) - atan2( d.y, d.x ); } } AddSegment( renderer, adjustedFromPos, adjustedFromColor, prevCapAngle, toPos, toColor, capAngleTo ); @@ -256,7 +256,7 @@ float Tr2Sprite2dLineTrace::CalcLength() for( auto it = m_vertices.begin() + 1; it != m_vertices.end(); ++it ) { - const Vector2& toPos = (*it)->m_position; + const Vector2& toPos = ( *it )->m_position; Vector2 d = toPos - fromPos; length += Length( d ); @@ -285,13 +285,13 @@ unsigned int Tr2Sprite2dLineTrace::GetEstimatedVertexCount() return vertsNeeded; } -void Tr2Sprite2dLineTrace::AddSegment( - Tr2Sprite2dScene* renderer, - const Vector2& from, - const Color& fromColor, +void Tr2Sprite2dLineTrace::AddSegment( + Tr2Sprite2dScene* renderer, + const Vector2& from, + const Color& fromColor, float capAngleFrom, - const Vector2& to, - const Color& toColor, + const Vector2& to, + const Color& toColor, float capAngleTo ) { Vector2 d = to - from; @@ -303,7 +303,7 @@ void Tr2Sprite2dLineTrace::AddSegment( m_textureOffsetAccum += segmentLength; float texOffset2 = m_textureOffsetAccum / m_textureWidth - m_textureOffset; - // Anti-aliased lines are rendered with a quad that is larger. This is then + // Anti-aliased lines are rendered with a quad that is larger. This is then // compensated for in the pixel shader, using the extra pixels to fill in // alpha values to do the anti-aliasing @@ -315,15 +315,15 @@ void Tr2Sprite2dLineTrace::AddSegment( if( isAA ) { halfWidth += 2.0f; - pixelWidthInTexels = 1.0f / (m_lineWidth + 4.0f); + pixelWidthInTexels = 1.0f / ( m_lineWidth + 4.0f ); } - capAngleFrom = ClampAngle(capAngleFrom); - capAngleTo = ClampAngle(capAngleTo); + capAngleFrom = ClampAngle( capAngleFrom ); + capAngleTo = ClampAngle( capAngleTo ); // Shorten lines to account for corners Vector2 adjustedFrom, adjustedTo; - if ( m_cornerType != CORNERTYPE_NONE ) + if( m_cornerType != CORNERTYPE_NONE ) { float shorteningForCap = halfWidth * tan( std::abs( capAngleTo ) * 0.5f ); adjustedTo = to - shorteningForCap * d; @@ -338,15 +338,15 @@ void Tr2Sprite2dLineTrace::AddSegment( } // Rotate 90 degrees - Vector2 normal(d.y, -d.x); + Vector2 normal( d.y, -d.x ); uint32_t totalVertexCount = uint32_t( m_renderVertices.size() ) - m_drawCalls.back().vertexOffset; uint32_t totalIndexCount = uint32_t( m_renderIndices.size() ) - m_drawCalls.back().indexOffset; uint32_t segmentVertices = 4; uint32_t segmentIndices = 6; - if( capAngleTo != 0.0f) + if( capAngleTo != 0.0f ) { - if ( m_cornerType == CORNERTYPE_MITER ) + if( m_cornerType == CORNERTYPE_MITER ) { segmentVertices += 1 + 2; segmentIndices += 6; @@ -368,7 +368,7 @@ void Tr2Sprite2dLineTrace::AddSegment( if( numSteps < 2 ) numSteps = 2; ++numSteps; - + if( numSteps > jointWidth ) { numSteps = (unsigned int)m_lineWidth; @@ -435,18 +435,18 @@ void Tr2Sprite2dLineTrace::AddSegment( // v0 - top left Tr2Sprite2dVertexBase& v0 = verts[0]; - v0.position.x = adjustedFrom.x - normal.x*halfWidth; - v0.position.y = adjustedFrom.y - normal.y*halfWidth; + v0.position.x = adjustedFrom.x - normal.x * halfWidth; + v0.position.y = adjustedFrom.y - normal.y * halfWidth; v0.position.z = m_depth; v0.color = fromColor; v0.texCoord[0] = Vector2( texOffset1, 0.0f ); - if( isAA ) + if( isAA ) v0.texCoord[1] = Vector2( -pixelWidthInTexels, m_lineWidth ); // v1 - bottom left Tr2Sprite2dVertexBase& v1 = verts[1]; - v1.position.x = adjustedFrom.x + normal.x*halfWidth; - v1.position.y = adjustedFrom.y + normal.y*halfWidth; + v1.position.x = adjustedFrom.x + normal.x * halfWidth; + v1.position.y = adjustedFrom.y + normal.y * halfWidth; v1.position.z = m_depth; v1.color = fromColor; v1.texCoord[0] = Vector2( texOffset1, 1.0f ); @@ -455,8 +455,8 @@ void Tr2Sprite2dLineTrace::AddSegment( // v2 - bottom right Tr2Sprite2dVertexBase& v2 = verts[2]; - v2.position.x = adjustedTo.x + normal.x*halfWidth; - v2.position.y = adjustedTo.y + normal.y*halfWidth; + v2.position.x = adjustedTo.x + normal.x * halfWidth; + v2.position.y = adjustedTo.y + normal.y * halfWidth; v2.position.z = m_depth; v2.color = toColor; v2.texCoord[0] = Vector2( texOffset2, 1.0f ); @@ -465,8 +465,8 @@ void Tr2Sprite2dLineTrace::AddSegment( // v3 - top right Tr2Sprite2dVertexBase& v3 = verts[3]; - v3.position.x = adjustedTo.x - normal.x*halfWidth; - v3.position.y = adjustedTo.y - normal.y*halfWidth; + v3.position.x = adjustedTo.x - normal.x * halfWidth; + v3.position.y = adjustedTo.y - normal.y * halfWidth; v3.position.z = m_depth; v3.color = toColor; v3.texCoord[0] = Vector2( texOffset2, 0.0f ); @@ -477,10 +477,10 @@ void Tr2Sprite2dLineTrace::AddSegment( uint32_t oldSize = (uint32_t)m_renderVertices.size(); m_renderVertices.resize( oldSize + 4 ); - renderer->PrepareTriangleVerts( - &m_renderVertices[oldSize], - verts, - sizeof( Tr2Sprite2dVertexBase ), + renderer->PrepareTriangleVerts( + &m_renderVertices[oldSize], + verts, + sizeof( Tr2Sprite2dVertexBase ), 4 ); // Update index buffer @@ -493,9 +493,9 @@ void Tr2Sprite2dLineTrace::AddSegment( m_renderIndices.push_back( uint16_t( 2 + oldSize - indexOffset ) ); // Construct joint - if( capAngleTo != 0.0f) + if( capAngleTo != 0.0f ) { - if ( m_cornerType == CORNERTYPE_MITER ) + if( m_cornerType == CORNERTYPE_MITER ) { AddMiterJoint( renderer, @@ -503,13 +503,12 @@ void Tr2Sprite2dLineTrace::AddSegment( v2, v3, normal, - toColor, + toColor, isAA, pixelWidthInTexels, - halfWidth - ); + halfWidth ); } - else if (m_cornerType == CORNERTYPE_ROUND) + else if( m_cornerType == CORNERTYPE_ROUND ) { AddRoundJoint( renderer, @@ -520,22 +519,21 @@ void Tr2Sprite2dLineTrace::AddSegment( toColor, isAA, pixelWidthInTexels, - halfWidth - ); + halfWidth ); } } } void Tr2Sprite2dLineTrace::AddRoundJoint( Tr2Sprite2dScene* renderer, - float capAngleTo, - Tr2Sprite2dVertexBase v2, - Tr2Sprite2dVertexBase v3, - Vector2 normal, - Color color, - bool isAA, + float capAngleTo, + Tr2Sprite2dVertexBase v2, + Tr2Sprite2dVertexBase v3, + Vector2 normal, + Color color, + bool isAA, float pixelWidthInTexels, - float halfWidth) + float halfWidth ) { uint16_t fanBase; Vector2 fanBaseTranslation( 0, 0 ); @@ -569,23 +567,23 @@ void Tr2Sprite2dLineTrace::AddRoundJoint( numSteps = 2; float stepSize = angleDiff / (float)numSteps; ++numSteps; - + if( numSteps > jointWidth ) { numSteps = (unsigned int)m_lineWidth; - stepSize = angleDiff / (float)(numSteps - 1); + stepSize = angleDiff / (float)( numSteps - 1 ); } // Create verticies - Tr2Sprite2dVertexBase* fanVerts = static_cast( CCP_MALLOC( - "Tr2Sprite2dLineTrace/fanVerts", + Tr2Sprite2dVertexBase* fanVerts = static_cast( CCP_MALLOC( + "Tr2Sprite2dLineTrace/fanVerts", numSteps * sizeof( Tr2Sprite2dVertexBase ) ) ); Tr2Sprite2dVertexBase* currentVertex = fanVerts; // Construct outer joint vertexes float a = startAngle; uint16_t vertexCount = (uint16_t)m_renderVertices.size(); - + auto indexOffset = m_drawCalls.back().vertexOffset; for( unsigned int i = 0; i < numSteps; ++i ) { @@ -606,7 +604,7 @@ void Tr2Sprite2dLineTrace::AddRoundJoint( } else { - m_textureOffsetAccum += std::abs(arcLength) / float(numSteps); + m_textureOffsetAccum += std::abs( arcLength ) / float( numSteps ); float texOffset = m_textureOffsetAccum / m_textureWidth - m_textureOffset; if( sign > 0.0f ) v.texCoord[0] = Vector2( texOffset, 1.0f ); @@ -618,7 +616,7 @@ void Tr2Sprite2dLineTrace::AddRoundJoint( if( i > 0 ) { m_renderIndices.push_back( -1 + vertexCount - indexOffset ); - m_renderIndices.push_back( 0 + vertexCount - indexOffset ); + m_renderIndices.push_back( 0 + vertexCount - indexOffset ); m_renderIndices.push_back( fanBase - indexOffset ); } @@ -627,10 +625,10 @@ void Tr2Sprite2dLineTrace::AddRoundJoint( } m_renderVertices.resize( vertexCount ); - renderer->PrepareTriangleVerts( - &m_renderVertices[fanVertexBase], - fanVerts, - sizeof( Tr2Sprite2dVertexBase ), + renderer->PrepareTriangleVerts( + &m_renderVertices[fanVertexBase], + fanVerts, + sizeof( Tr2Sprite2dVertexBase ), numSteps ); CCP_FREE( fanVerts ); @@ -638,14 +636,14 @@ void Tr2Sprite2dLineTrace::AddRoundJoint( void Tr2Sprite2dLineTrace::AddMiterJoint( Tr2Sprite2dScene* renderer, - float capAngleTo, - Tr2Sprite2dVertexBase v2, - Tr2Sprite2dVertexBase v3, - Vector2 normal, - Color color, - bool isAA, + float capAngleTo, + Tr2Sprite2dVertexBase v2, + Tr2Sprite2dVertexBase v3, + Vector2 normal, + Color color, + bool isAA, float pixelWidthInTexels, - float halfWidth) + float halfWidth ) { uint16_t fanBase; Vector2 basePoint, topPoint; @@ -672,17 +670,17 @@ void Tr2Sprite2dLineTrace::AddMiterJoint( float endAngle = startAngle + capAngleTo; // Create vertexes - Tr2Sprite2dVertexBase* fanVerts = static_cast( CCP_MALLOC( - "Tr2Sprite2dLineTrace/fanVerts", + Tr2Sprite2dVertexBase* fanVerts = static_cast( CCP_MALLOC( + "Tr2Sprite2dLineTrace/fanVerts", sizeof( Tr2Sprite2dVertexBase ) ) ); Tr2Sprite2dVertexBase* currentVertex = fanVerts; - + // Construct outer joint vertexes uint16_t vertexCount = (uint16_t)m_renderVertices.size(); - + // Create vertex Tr2Sprite2dVertexBase& v = *currentVertex++; - Vector2 p = GetMiterPoint(halfWidth, basePoint, startAngle, endAngle, sign); + Vector2 p = GetMiterPoint( halfWidth, basePoint, startAngle, endAngle, sign ); v.position.x = p.x; v.position.y = p.y; v.position.z = m_depth; @@ -697,10 +695,10 @@ void Tr2Sprite2dLineTrace::AddMiterJoint( v.texCoord[1] = Vector2( -pixelWidthInTexels, m_lineWidth ); } else - { + { float arcLength; - XMStoreFloat(&arcLength, XMVector2Length(p - topPoint)); - m_textureOffsetAccum += std::abs(arcLength); + XMStoreFloat( &arcLength, XMVector2Length( p - topPoint ) ); + m_textureOffsetAccum += std::abs( arcLength ); float texOffset = m_textureOffsetAccum / m_textureWidth - m_textureOffset; if( sign > 0.0f ) v.texCoord[0] = Vector2( texOffset, 1.0f ); @@ -710,21 +708,21 @@ void Tr2Sprite2dLineTrace::AddMiterJoint( // Update render index auto indexOffset = m_drawCalls.back().vertexOffset; - if (sign == 1.0) + if( sign == 1.0 ) { m_renderIndices.push_back( -2 + vertexCount - indexOffset ); m_renderIndices.push_back( fanBase - indexOffset ); - m_renderIndices.push_back( 0 + vertexCount - indexOffset ); + m_renderIndices.push_back( 0 + vertexCount - indexOffset ); m_renderIndices.push_back( 2 + vertexCount - indexOffset ); m_renderIndices.push_back( fanBase - indexOffset ); - m_renderIndices.push_back( 0 + vertexCount - indexOffset ); + m_renderIndices.push_back( 0 + vertexCount - indexOffset ); } else { m_renderIndices.push_back( -1 + vertexCount - indexOffset ); m_renderIndices.push_back( fanBase - indexOffset ); - m_renderIndices.push_back( 0 + vertexCount - indexOffset ); + m_renderIndices.push_back( 0 + vertexCount - indexOffset ); m_renderIndices.push_back( 1 + vertexCount - indexOffset ); m_renderIndices.push_back( fanBase - indexOffset ); @@ -732,35 +730,35 @@ void Tr2Sprite2dLineTrace::AddMiterJoint( } m_renderVertices.resize( vertexCount + 1 ); - renderer->PrepareTriangleVerts( - &m_renderVertices[fanVertexBase], + renderer->PrepareTriangleVerts( + &m_renderVertices[fanVertexBase], fanVerts, - sizeof( Tr2Sprite2dVertexBase ), + sizeof( Tr2Sprite2dVertexBase ), 1 ); CCP_FREE( fanVerts ); } -Vector2 Tr2Sprite2dLineTrace::GetMiterPoint(float halfWidth, Vector2 basePoint, float startAngle, float endAngle, float sign) +Vector2 Tr2Sprite2dLineTrace::GetMiterPoint( float halfWidth, Vector2 basePoint, float startAngle, float endAngle, float sign ) { // Returns the outer intersection point of the two line segments for a miter joint Vector2 ret, p1, p2, v1, v2; float k = halfWidth * 2.0f * sign; - v1 = Vector2(cos(startAngle) * k, sin(startAngle) * k); + v1 = Vector2( cos( startAngle ) * k, sin( startAngle ) * k ); p1 = basePoint + v1; - v2 = Vector2(cos(endAngle) * k, sin(endAngle) * k); + v2 = Vector2( cos( endAngle ) * k, sin( endAngle ) * k ); p2 = basePoint + v2; - ret = XMVector2IntersectLine(p1, p1 - Vector2(-v1.y, v1.x), p2, p2 - Vector2(-v2.y, v2.x)); + ret = XMVector2IntersectLine( p1, p1 - Vector2( -v1.y, v1.x ), p2, p2 - Vector2( -v2.y, v2.x ) ); return ret; } -float Tr2Sprite2dLineTrace::ClampAngle(float angle) +float Tr2Sprite2dLineTrace::ClampAngle( float angle ) { - if (angle < -XM_PI) + if( angle < -XM_PI ) { return angle + 2 * XM_PI; } - else if (angle > XM_PI) + else if( angle > XM_PI ) { return angle - 2 * XM_PI; } @@ -781,7 +779,7 @@ void Tr2Sprite2dLineTrace::ClearVertices() void Tr2Sprite2dLineTrace::OnListModified( long event, /* BLUELISTEVENT values */ ssize_t key, ssize_t key2, IRoot* value, const IList* theList ) { switch( event ) - { + { case BELIST_INSERTED: case BELIST_REMOVED: case BELIST_UNLOADSTART: diff --git a/trinity/Sprite2d/Tr2Sprite2dLineTrace.h b/trinity/Sprite2d/Tr2Sprite2dLineTrace.h index a4c7908ee..2df8fc6a1 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLineTrace.h +++ b/trinity/Sprite2d/Tr2Sprite2dLineTrace.h @@ -29,9 +29,8 @@ BLUE_CLASS( Tr2Sprite2dLineTraceVertex ) : TYPEDEF_BLUECLASS( Tr2Sprite2dLineTraceVertex ); -class Tr2Sprite2dLineTrace : - public Tr2TexturedSpriteObject, - public IListNotify +class Tr2Sprite2dLineTrace : public Tr2TexturedSpriteObject, + public IListNotify { public: EXPOSE_TO_BLUE(); @@ -48,50 +47,55 @@ class Tr2Sprite2dLineTrace : ////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); - - enum CornerType { CORNERTYPE_MITER, CORNERTYPE_ROUND, CORNERTYPE_NONE }; + const IList* theList ); + + enum CornerType + { + CORNERTYPE_MITER, + CORNERTYPE_ROUND, + CORNERTYPE_NONE + }; private: void ClearVertices(); float CalcLength(); - void AddSegment( - Tr2Sprite2dScene* renderer, - const Vector2& from, - const Color& fromColor, + void AddSegment( + Tr2Sprite2dScene* renderer, + const Vector2& from, + const Color& fromColor, float capAngleFrom, - const Vector2& to, - const Color& toColor, - float capAngleTo); - void AddVertex(Tr2Sprite2dVertexBase& v, float xOffset, float yOffset, float halfWidth, bool isAA, float texOffset1, Color color); + const Vector2& to, + const Color& toColor, + float capAngleTo ); + void AddVertex( Tr2Sprite2dVertexBase& v, float xOffset, float yOffset, float halfWidth, bool isAA, float texOffset1, Color color ); void AddRoundJoint( Tr2Sprite2dScene* renderer, - float capAngleTo, - Tr2Sprite2dVertexBase v2, - Tr2Sprite2dVertexBase v3, - Vector2 normal, - Color modulatedToColor, - bool isAA, + float capAngleTo, + Tr2Sprite2dVertexBase v2, + Tr2Sprite2dVertexBase v3, + Vector2 normal, + Color modulatedToColor, + bool isAA, float pixelWidthInTexels, - float halfWidth); - float ClampAngle(float angle); + float halfWidth ); + float ClampAngle( float angle ); unsigned int GetEstimatedVertexCount(); - void AddMiterJoint( - Tr2Sprite2dScene* renderer, - float capAngleTo, - Tr2Sprite2dVertexBase v2, - Tr2Sprite2dVertexBase v3, - Vector2 normal, - Color modulatedToColor, - bool isAA, - float pixelWidthInTexels, - float halfWidth); - Vector2 GetMiterPoint(float halfWidth, Vector2 basePoint, float startAngle, float endAngle, float sign); + void AddMiterJoint( + Tr2Sprite2dScene* renderer, + float capAngleTo, + Tr2Sprite2dVertexBase v2, + Tr2Sprite2dVertexBase v3, + Vector2 normal, + Color modulatedToColor, + bool isAA, + float pixelWidthInTexels, + float halfWidth ); + Vector2 GetMiterPoint( float halfWidth, Vector2 basePoint, float startAngle, float endAngle, float sign ); + private: #if BLUE_WITH_PYTHON static PyObject* PyAppendVertices( PyObject* self, PyObject* args ); diff --git a/trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp index b1afdab4c..4b997861f 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLineTrace_Blue.cpp @@ -54,7 +54,7 @@ PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args PyObject* pyColors = nullptr; PyObject* pyNames = nullptr; - if ( !PyArg_ParseTuple( args, "OOO|O", &pyPositions, &pyTransform, &pyColors, &pyNames ) ) + if( !PyArg_ParseTuple( args, "OOO|O", &pyPositions, &pyTransform, &pyColors, &pyNames ) ) { return nullptr; } @@ -68,37 +68,37 @@ PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args { transform = XMMatrixIdentity(); } - else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) + else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) { - PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); + PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); return nullptr; } bool constPosition = ToFloatTuple( pyPositions, 2, &position.x ); if( !constPosition && !PySequence_Check( pyPositions ) ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } bool constColor = ToFloatTuple( pyColors, 4, &color.r ); if( !constColor && !PySequence_Check( pyColors ) ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } if( pyNames ) { if( !PySequence_Check( pyNames ) ) { - PyErr_SetString( PyExc_TypeError, "names parameter must be a sequence of strings" ); + PyErr_SetString( PyExc_TypeError, "names parameter must be a sequence of strings" ); return nullptr; } } - for( ssize_t index = 0; ; ++index ) + for( ssize_t index = 0;; ++index ) { if( !constPosition ) { @@ -112,7 +112,7 @@ PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -128,7 +128,7 @@ PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -142,7 +142,7 @@ PyObject* Tr2Sprite2dLineTrace::PyAppendVertices( PyObject* self, PyObject* args } if( !PyVerCompat::IsPyString( item ) ) { - PyErr_SetString( PyExc_TypeError, "names parameter must be a sequence of strings" ); + PyErr_SetString( PyExc_TypeError, "names parameter must be a sequence of strings" ); return nullptr; } name = FromPython( item ); @@ -173,7 +173,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) PyObject* pyColors = nullptr; PyObject* pyNames = nullptr; - if ( !PyArg_ParseTuple( args, "O|OOO", &pyPositions, &pyTransform, &pyColors, &pyNames ) ) + if( !PyArg_ParseTuple( args, "O|OOO", &pyPositions, &pyTransform, &pyColors, &pyNames ) ) { return nullptr; } @@ -200,12 +200,12 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) { transform = XMMatrixIdentity(); } - else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) + else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) { - PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); + PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); return nullptr; } @@ -215,7 +215,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) constPosition = ToFloatTuple( pyPositions, 2, &position.x ); if( !constPosition && !PySequence_Check( pyPositions ) ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -225,7 +225,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) constColor = ToFloatTuple( pyColors, 4, &color.r ); if( !constColor && !PySequence_Check( pyColors ) ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -235,7 +235,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) constName = PyVerCompat::IsPyString( pyNames ); if( !constName && !PySequence_Check( pyNames ) ) { - PyErr_SetString( PyExc_TypeError, "names parameter must be a string or a sequence of strings" ); + PyErr_SetString( PyExc_TypeError, "names parameter must be a string or a sequence of strings" ); return nullptr; } } @@ -257,7 +257,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -277,7 +277,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -296,7 +296,7 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) if( !PyVerCompat::IsPyString( item ) ) { Py_DECREF( item ); - PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } name = FromPython( item ); @@ -313,76 +313,59 @@ PyObject* Tr2Sprite2dLineTrace::PySetVertices( PyObject* self, PyObject* args ) const Be::ClassInfo* Tr2Sprite2dLineTrace::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dLineTrace, "" ) - MAP_INTERFACE( Tr2Sprite2dLineTrace ) - - MAP_ATTRIBUTE - ( - "vertices", - m_vertices, - "Vertices used to render line trace", - Be::READ | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + EXPOSURE_BEGIN( Tr2Sprite2dLineTrace, "" ) + MAP_INTERFACE( Tr2Sprite2dLineTrace ) + + MAP_ATTRIBUTE( + "vertices", + m_vertices, + "Vertices used to render line trace", + Be::READ | Be::NOTIFY ) + + MAP_ATTRIBUTE( "lineWidth", m_lineWidth, "Width of line rendered", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureWidth", m_textureWidth, "Width of the texture along the line", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureOffset", m_textureOffset, "Offset of the texture along the line. Can be used for animations", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "start", m_start, "Relative start of line trace - from 0 to 1", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "end", m_end, "Relative end of line trace - from 0 to 1", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "isLoop", m_isLoop, "If set, the line trace is treated as a closed loop", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "cornerType", m_cornerType, "Determines the shapes of corners connecting the line segments", - Be::READWRITE | Be::NOTIFY - ) - + Be::READWRITE | Be::NOTIFY ) + #if BLUE_WITH_PYTHON - MAP_METHOD - ( + MAP_METHOD( "AppendVertices", PyAppendVertices, "Adds vertices to the line.\n" @@ -394,10 +377,8 @@ const Be::ClassInfo* Tr2Sprite2dLineTrace::ExposeToBlue() ":type colors: sequence[(float, float, float, float)]|(float, float, float, float)\n" ":param names: optional sequence of string names\n" ":type names: sequence[str]\n" - ":rtype: None" - ) - MAP_METHOD - ( + ":rtype: None" ) + MAP_METHOD( "SetVertices", PySetVertices, "Changes line vertices.\n" @@ -409,8 +390,7 @@ const Be::ClassInfo* Tr2Sprite2dLineTrace::ExposeToBlue() ":type colors: None|sequence[(float, float, float, float)]|(float, float, float, float)\n" ":param names: optional sequence of string names\n" ":type names: sequence[str]\n" - ":rtype: None" - ) + ":rtype: None" ) #endif EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } @@ -418,31 +398,25 @@ const Be::ClassInfo* Tr2Sprite2dLineTrace::ExposeToBlue() const Be::ClassInfo* Tr2Sprite2dLineTraceVertex::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dLineTraceVertex, "" ) - MAP_INTERFACE( Tr2Sprite2dLineTraceVertex ) - - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this vertex", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "position", - m_position, - "Position of the vertex", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "color", - m_color, - "Color of the vertex", - Be::READWRITE | Be::PERSIST - ) + EXPOSURE_BEGIN( Tr2Sprite2dLineTraceVertex, "" ) + MAP_INTERFACE( Tr2Sprite2dLineTraceVertex ) + + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this vertex", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "position", + m_position, + "Position of the vertex", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "color", + m_color, + "Color of the vertex", + Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Sprite2d/Tr2Sprite2dLine_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dLine_Blue.cpp index 985036e95..f2fb509ca 100644 --- a/trinity/Sprite2d/Tr2Sprite2dLine_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dLine_Blue.cpp @@ -8,83 +8,62 @@ BLUE_DEFINE( Tr2Sprite2dLine ); const Be::ClassInfo* Tr2Sprite2dLine::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dLine, "" ) - MAP_INTERFACE( Tr2Sprite2dLine ) + EXPOSURE_BEGIN( Tr2Sprite2dLine, "" ) + MAP_INTERFACE( Tr2Sprite2dLine ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translationFrom", m_translationFrom, "Coordinate of starting point", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "translationTo", m_translationTo, "Coordinate of ending point", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( - "widthFrom", - m_widthFrom, - "Width of this line at the starting point", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( - "colorFrom", - m_colorFrom, - "Color of this line at the starting point", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( + "widthFrom", + m_widthFrom, + "Width of this line at the starting point", + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( + "colorFrom", + m_colorFrom, + "Color of this line at the starting point", + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "widthTo", - m_widthTo, - "Width of this line at the ending point", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "widthTo", + m_widthTo, + "Width of this line at the ending point", + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureWidth", m_textureWidth, "Width of the texture along the line", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureOffsetBase", m_textureOffsetBase, "Base offset of the texture along the line. Can be used to reduce seam effect between textured lines", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textureOffset", m_textureOffset, "Offset of the texture along the line. Can be used for animations", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "colorTo", - m_colorTo, - "Color of this line at the ending point", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "colorTo", + m_colorTo, + "Color of this line at the ending point", + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } - - - diff --git a/trinity/Sprite2d/Tr2Sprite2dPickingMask.h b/trinity/Sprite2d/Tr2Sprite2dPickingMask.h index b65847e74..710dfd677 100644 --- a/trinity/Sprite2d/Tr2Sprite2dPickingMask.h +++ b/trinity/Sprite2d/Tr2Sprite2dPickingMask.h @@ -6,7 +6,7 @@ BLUE_DECLARE( Tr2ImageRes ); BLUE_CLASS_IMPL( Tr2Sprite2dPickingMask ); -class Tr2Sprite2dPickingMask: public IRoot +class Tr2Sprite2dPickingMask : public IRoot { public: explicit Tr2Sprite2dPickingMask( IRoot* lockobj = nullptr ); @@ -17,6 +17,7 @@ class Tr2Sprite2dPickingMask: public IRoot void SetMaskPath( const wchar_t* path ); bool SampleMask( const Vector2& point, const Vector2& topLeft, float width, float height ) const; + private: std::wstring m_maskPath; Tr2ImageResPtr m_mask; diff --git a/trinity/Sprite2d/Tr2Sprite2dPolygon.h b/trinity/Sprite2d/Tr2Sprite2dPolygon.h index 5920d9fd1..937187253 100644 --- a/trinity/Sprite2d/Tr2Sprite2dPolygon.h +++ b/trinity/Sprite2d/Tr2Sprite2dPolygon.h @@ -48,13 +48,12 @@ BLUE_CLASS( Tr2Sprite2dTriangle ) : TYPEDEF_BLUECLASS( Tr2Sprite2dTriangle ); -class Tr2Sprite2dPolygon: - public Tr2TexturedSpriteObject, - public IListNotify +class Tr2Sprite2dPolygon : public Tr2TexturedSpriteObject, + public IListNotify { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2dPolygon( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2dPolygon( IRoot* lockobj = NULL ); ~Tr2Sprite2dPolygon(); Color GetColor() const; @@ -69,12 +68,11 @@ class Tr2Sprite2dPolygon: ////////////////////////////////////////////////////////////////////////// // IListNotify void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); private: #if BLUE_WITH_PYTHON diff --git a/trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp index f3f5ddbe6..0823cebce 100644 --- a/trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dPolygon_Blue.cpp @@ -56,7 +56,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) PyObject* pyTexCoord0 = nullptr; PyObject* pyTexCoord1 = nullptr; - if ( !PyArg_ParseTuple( args, "OOO|OO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) ) + if( !PyArg_ParseTuple( args, "OOO|OO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) ) { return nullptr; } @@ -71,25 +71,25 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) { transform = XMMatrixIdentity(); } - else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) + else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) { - PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); + PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); return nullptr; } bool constPosition = ToFloatTuple( pyPositions, 2, &position.x ); if( !constPosition && !PySequence_Check( pyPositions ) ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } bool constColor = ToFloatTuple( pyColors, 4, &color.r ); if( !constColor && !PySequence_Check( pyColors ) ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } bool constTexcoord0 = true; @@ -98,7 +98,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) constTexcoord0 = ToFloatTuple( pyTexCoord0, 2, &texcoord0.x ); if( !constTexcoord0 && !PySequence_Check( pyTexCoord0 ) ) { - PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -113,7 +113,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) constTexcoord1 = ToFloatTuple( pyTexCoord1, 2, &texcoord1.x ); if( !constTexcoord1 && !PySequence_Check( pyTexCoord1 ) ) { - PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -123,7 +123,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) texcoord1[1] = 0.f; } - for( ssize_t index = 0; ; ++index ) + for( ssize_t index = 0;; ++index ) { if( !constPosition ) { @@ -137,7 +137,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -153,7 +153,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -169,7 +169,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -185,7 +185,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -218,7 +218,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) PyObject* pyTexCoord0 = nullptr; PyObject* pyTexCoord1 = nullptr; - if ( !PyArg_ParseTuple( args, "O|OOOO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) ) + if( !PyArg_ParseTuple( args, "O|OOOO", &pyPositions, &pyTransform, &pyColors, &pyTexCoord0, &pyTexCoord1 ) ) { return nullptr; } @@ -250,12 +250,12 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) { transform = XMMatrixIdentity(); } - else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || - !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) + else if( !PyTuple_Check( pyTransform ) || PyTuple_GET_SIZE( pyTransform ) != 3 || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 0 ), 3, &transform._11 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 1 ), 3, &transform._21 ) || + !ToFloatTuple( PyTuple_GET_ITEM( pyTransform, 2 ), 3, &transform._41 ) ) { - PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); + PyErr_SetString( PyExc_TypeError, "positionTransform parameter must be a 3x3 matrix or None" ); return nullptr; } @@ -265,7 +265,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) constPosition = ToFloatTuple( pyPositions, 2, &position.x ); if( !constPosition && !PySequence_Check( pyPositions ) ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -275,7 +275,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) constColor = ToFloatTuple( pyColors, 4, &color.r ); if( !constColor && !PySequence_Check( pyColors ) ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -285,7 +285,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) constTexcoord0 = ToFloatTuple( pyTexCoord0, 2, &texcoord0.x ); if( !constTexcoord0 && !PySequence_Check( pyTexCoord0 ) ) { - PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -300,7 +300,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) constTexcoord1 = ToFloatTuple( pyTexCoord1, 2, &texcoord1.x ); if( !constTexcoord1 && !PySequence_Check( pyTexCoord1 ) ) { - PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -327,7 +327,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "positions parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -347,7 +347,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); + PyErr_SetString( PyExc_TypeError, "colors parameter must be a 4-tuple or a sequence of 4-tuples" ); return nullptr; } } @@ -367,7 +367,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords0 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -387,7 +387,7 @@ PyObject* Tr2Sprite2dPolygon::PySetVertices( PyObject* self, PyObject* args ) Py_DECREF( item ); if( !success ) { - PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); + PyErr_SetString( PyExc_TypeError, "texCoords1 parameter must be a 2-tuple or a sequence of 2-tuples" ); return nullptr; } } @@ -403,18 +403,18 @@ PyObject* Tr2Sprite2dPolygon::PyAppendTriangles( PyObject* self, PyObject* args auto pThis = BluePythonCast( self ); PyObject* pyTriangles = nullptr; - if ( !PyArg_ParseTuple( args, "O", &pyTriangles ) ) + if( !PyArg_ParseTuple( args, "O", &pyTriangles ) ) { return nullptr; } if( !PySequence_Check( pyTriangles ) ) { - PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); + PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); return nullptr; } - for( ssize_t index = 0; ; ++index ) + for( ssize_t index = 0;; ++index ) { auto item = PySequence_GetItem( pyTriangles, index ); if( !item ) @@ -426,7 +426,7 @@ PyObject* Tr2Sprite2dPolygon::PyAppendTriangles( PyObject* self, PyObject* args !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 0 ) ) || !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 1 ) ) || !PyVerCompat::IsPyInt( PyTuple_GET_ITEM( item, 2 ) ) ) { Py_DECREF( item ); - PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); + PyErr_SetString( PyExc_TypeError, "triangles parameter must be a sequence of 3-tuples" ); return nullptr; } Tr2Sprite2dTrianglePtr triangle; @@ -448,28 +448,23 @@ PyObject* Tr2Sprite2dPolygon::PyAppendTriangles( PyObject* self, PyObject* args const Be::ClassInfo* Tr2Sprite2dPolygon::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dPolygon, "" ) - MAP_INTERFACE( Tr2Sprite2dPolygon ) - - MAP_ATTRIBUTE - ( - "vertices", - m_vertices, - "Vertices used to render polygon", - Be::READ - ) - - MAP_ATTRIBUTE - ( - "triangles", - m_triangles, - "Triangles used to render polygon", - Be::READ - ) + EXPOSURE_BEGIN( Tr2Sprite2dPolygon, "" ) + MAP_INTERFACE( Tr2Sprite2dPolygon ) + + MAP_ATTRIBUTE( + "vertices", + m_vertices, + "Vertices used to render polygon", + Be::READ ) + + MAP_ATTRIBUTE( + "triangles", + m_triangles, + "Triangles used to render polygon", + Be::READ ) #if BLUE_WITH_PYTHON - MAP_METHOD - ( + MAP_METHOD( "AppendVertices", PyAppendVertices, "Adds vertices to the polygon.\n" @@ -483,10 +478,8 @@ const Be::ClassInfo* Tr2Sprite2dPolygon::ExposeToBlue() ":type texCoords0: sequence[(float, float)]|(float, float)\n" ":param texCoords1: optional sequence of 2-tuples with the second texture coordinates or a single 2-tuple\n" ":type texCoords1: sequence[(float, float)]|(float, float)\n" - ":rtype: None" - ) - MAP_METHOD - ( + ":rtype: None" ) + MAP_METHOD( "SetVertices", PySetVertices, "Changes poly vertices.\n" @@ -500,17 +493,14 @@ const Be::ClassInfo* Tr2Sprite2dPolygon::ExposeToBlue() ":type texCoords0: None|sequence[(float, float)]|(float, float)\n" ":param texCoords1: optional sequence of 2-tuples with the second texture coordinates or a single 2-tuple\n" ":type texCoords1: None|sequence[(float, float)]|(float, float)\n" - ":rtype: None" - ) - MAP_METHOD - ( + ":rtype: None" ) + MAP_METHOD( "AppendTriangles", PyAppendTriangles, "Adds triangle indices to the polygon.\n" ":param triangles: a sequence of 3-tuples with triangle indices\n" ":type positions: sequence[(int, int, int)]\n" - ":rtype: None" - ) + ":rtype: None" ) #endif EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) @@ -519,32 +509,28 @@ const Be::ClassInfo* Tr2Sprite2dPolygon::ExposeToBlue() const Be::ClassInfo* Tr2Sprite2dVertex::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dVertex, "" ) - MAP_INTERFACE( Tr2Sprite2dVertex ) + EXPOSURE_BEGIN( Tr2Sprite2dVertex, "" ) + MAP_INTERFACE( Tr2Sprite2dVertex ) - MAP_ATTRIBUTE - ( - "position", - position, - "Position of the vertex", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "position", + position, + "Position of the vertex", + Be::READWRITE | Be::PERSIST ) MAP_PROPERTY( "color", GetColor, SetColor, "vertex colour" ) - MAP_METHOD_AND_WRAP( - "GetTexCoord", - GetTexCoord, + MAP_METHOD_AND_WRAP( + "GetTexCoord", + GetTexCoord, "returns indexed texture coordinate\n" + ":param idx: texture coordinates index" ) + MAP_METHOD_AND_WRAP( + "SetTexCoord", + SetTexCoord, + "sets indexed texture coordinate\n" ":param idx: texture coordinates index" - ) - MAP_METHOD_AND_WRAP( - "SetTexCoord", - SetTexCoord, - "sets indexed texture coordinate\n" - ":param idx: texture coordinates index" - ":param uv: texture coordinates" - ) + ":param uv: texture coordinates" ) EXPOSURE_END() } @@ -554,26 +540,20 @@ const Be::ClassInfo* Tr2Sprite2dTriangle::ExposeToBlue() EXPOSURE_BEGIN( Tr2Sprite2dTriangle, "" ) MAP_INTERFACE( Tr2Sprite2dTriangle ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "index0", m_index[0], "Index of first vertex in this triangle", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "index1", m_index[1], "Index of second vertex in this triangle", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "index2", m_index[2], "Index of third vertex in this triangle", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Sprite2d/Tr2Sprite2dRenderJob.cpp b/trinity/Sprite2d/Tr2Sprite2dRenderJob.cpp index 1479353a7..c6303e687 100644 --- a/trinity/Sprite2d/Tr2Sprite2dRenderJob.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dRenderJob.cpp @@ -12,7 +12,6 @@ Tr2Sprite2dRenderJob::Tr2Sprite2dRenderJob( IRoot* lockobj /*= NULL */ ) Tr2Sprite2dRenderJob::~Tr2Sprite2dRenderJob() { - } void Tr2Sprite2dRenderJob::GatherSprites( Tr2Sprite2dScene* renderer ) diff --git a/trinity/Sprite2d/Tr2Sprite2dRenderJob.h b/trinity/Sprite2d/Tr2Sprite2dRenderJob.h index 468186574..faed03f67 100644 --- a/trinity/Sprite2d/Tr2Sprite2dRenderJob.h +++ b/trinity/Sprite2d/Tr2Sprite2dRenderJob.h @@ -10,8 +10,7 @@ BLUE_DECLARE( TriRenderJob ); BLUE_DECLARE( Tr2Sprite2dRenderJob ); -class Tr2Sprite2dRenderJob : - public Tr2SpriteObjectBase +class Tr2Sprite2dRenderJob : public Tr2SpriteObjectBase { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Sprite2d/Tr2Sprite2dRenderJob_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dRenderJob_Blue.cpp index 3d6d61a93..2b398aff5 100644 --- a/trinity/Sprite2d/Tr2Sprite2dRenderJob_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dRenderJob_Blue.cpp @@ -11,12 +11,10 @@ const Be::ClassInfo* Tr2Sprite2dRenderJob::ExposeToBlue() MAP_INTERFACE( ITr2SpriteObject ) MAP_INTERFACE( Tr2Sprite2dRenderJob ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "renderJob", m_renderJob, "The render job to be executed", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_CHAINTO( Tr2SpriteObjectBase ) } \ No newline at end of file diff --git a/trinity/Sprite2d/Tr2Sprite2dScene.cpp b/trinity/Sprite2d/Tr2Sprite2dScene.cpp index d8a4e276a..29d9c2f12 100644 --- a/trinity/Sprite2d/Tr2Sprite2dScene.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dScene.cpp @@ -22,22 +22,22 @@ using namespace Tr2RenderContextEnum; -CCP_STATS_DECLARE( spriteSceneDrawCallCount, "Trinity/SpriteScene/DrawCallCount", true, CST_COUNTER_LOW, "Count of drawcalls for sprites" ); -CCP_STATS_DECLARE( spriteSceneDrawCallEmpty, "Trinity/SpriteScene/DrawCallEmpty", true, CST_COUNTER_LOW, "Count of empty drawcalls for sprites" ); -CCP_STATS_DECLARE( spriteSceneDrawCallTexture, "Trinity/SpriteScene/DrawCallTexture", true, CST_COUNTER_LOW, "Count of drawcalls caused by texture changing" ); -CCP_STATS_DECLARE( spriteSceneDrawCallEffect, "Trinity/SpriteScene/DrawCallEffect", true, CST_COUNTER_LOW, "Count of drawcalls caused by sprite effect changing" ); +CCP_STATS_DECLARE( spriteSceneDrawCallCount, "Trinity/SpriteScene/DrawCallCount", true, CST_COUNTER_LOW, "Count of drawcalls for sprites" ); +CCP_STATS_DECLARE( spriteSceneDrawCallEmpty, "Trinity/SpriteScene/DrawCallEmpty", true, CST_COUNTER_LOW, "Count of empty drawcalls for sprites" ); +CCP_STATS_DECLARE( spriteSceneDrawCallTexture, "Trinity/SpriteScene/DrawCallTexture", true, CST_COUNTER_LOW, "Count of drawcalls caused by texture changing" ); +CCP_STATS_DECLARE( spriteSceneDrawCallEffect, "Trinity/SpriteScene/DrawCallEffect", true, CST_COUNTER_LOW, "Count of drawcalls caused by sprite effect changing" ); -CCP_STATS_DECLARE( spriteSceneTextureCount, "Trinity/SpriteScene/TextureCount", true, CST_COUNTER_LOW, "Textures used per frame" ); -CCP_STATS_DECLARE( spriteSceneTextureNotReady, "Trinity/SpriteScene/TextureNotReady", true, CST_COUNTER_LOW, "Sprites skipped due to its textures not being ready" ); +CCP_STATS_DECLARE( spriteSceneTextureCount, "Trinity/SpriteScene/TextureCount", true, CST_COUNTER_LOW, "Textures used per frame" ); +CCP_STATS_DECLARE( spriteSceneTextureNotReady, "Trinity/SpriteScene/TextureNotReady", true, CST_COUNTER_LOW, "Sprites skipped due to its textures not being ready" ); -CCP_STATS_DECLARE( spriteSceneCount, "Trinity/SpriteScene/Count", true, CST_COUNTER_HIGH, "Count of sprites rendered per frame" ); -CCP_STATS_DECLARE( spriteSceneSpriteArea, "Trinity/SpriteScene/SpriteArea", true, CST_COUNTER_HIGH, "Area of sprites rendered per frame" ); +CCP_STATS_DECLARE( spriteSceneCount, "Trinity/SpriteScene/Count", true, CST_COUNTER_HIGH, "Count of sprites rendered per frame" ); +CCP_STATS_DECLARE( spriteSceneSpriteArea, "Trinity/SpriteScene/SpriteArea", true, CST_COUNTER_HIGH, "Area of sprites rendered per frame" ); -CCP_STATS_DECLARE( spriteSceneTransforms, "Trinity/SpriteScene/Transforms", true, CST_COUNTER_HIGH, "Count of nontrivial transform matrices per frame" ); -CCP_STATS_DECLARE( spriteSceneTransformSplits, "Trinity/SpriteScene/TransformSplits", true, CST_COUNTER_HIGH, "Number of times active transform count caused additional draw calls" ); +CCP_STATS_DECLARE( spriteSceneTransforms, "Trinity/SpriteScene/Transforms", true, CST_COUNTER_HIGH, "Count of nontrivial transform matrices per frame" ); +CCP_STATS_DECLARE( spriteSceneTransformSplits, "Trinity/SpriteScene/TransformSplits", true, CST_COUNTER_HIGH, "Number of times active transform count caused additional draw calls" ); -CCP_STATS_DECLARE( spriteSceneDisplayListsCreated, "Trinity/SpriteScene/DisplayListsCreated", true, CST_COUNTER_HIGH, "Number of display lists generated per frame" ); -CCP_STATS_DECLARE( spriteSceneDisplayListsUsed, "Trinity/SpriteScene/DisplayListsUsed", true, CST_COUNTER_HIGH, "Number of display lists used per frame" ); +CCP_STATS_DECLARE( spriteSceneDisplayListsCreated, "Trinity/SpriteScene/DisplayListsCreated", true, CST_COUNTER_HIGH, "Number of display lists generated per frame" ); +CCP_STATS_DECLARE( spriteSceneDisplayListsUsed, "Trinity/SpriteScene/DisplayListsUsed", true, CST_COUNTER_HIGH, "Number of display lists used per frame" ); CCP_STATS_DECLARED_ELSEWHERE( displayListVertexBufferSize ); CCP_STATS_DECLARED_ELSEWHERE( displayListIndexBufferSize ); @@ -49,8 +49,8 @@ static Tr2VertexDefinition s_vertexDesc; static const int SPRITE_COUNT_MAX = 65535 / 4; -static const char* EFFECT_UBERSHADER_RESPATH = "res:/Graphics/Effect/UI/UberShader.fx"; -static const char* EFFECT_RENDER_UBERSHADER_RESPATH_3D = "res:/Graphics/Effect/UI/UberShader3d.fx"; +static const char* EFFECT_UBERSHADER_RESPATH = "res:/Graphics/Effect/UI/UberShader.fx"; +static const char* EFFECT_RENDER_UBERSHADER_RESPATH_3D = "res:/Graphics/Effect/UI/UberShader3d.fx"; static const unsigned int VB_ALIGNMENT = 16; static const unsigned int IB_ALIGNMENT = 16; @@ -96,10 +96,10 @@ Tr2Sprite2dScene::Tr2Sprite2dScene( IRoot* lockobj ) : m_is2dRender( true ), m_is2dPick( true ), m_is2dRenderContext( true ), - m_stackOfStacks( "Tr2Sprite2dScene/m_stackOfStacks"), + m_stackOfStacks( "Tr2Sprite2dScene/m_stackOfStacks" ), m_defaultTextureFlash( 0 ), m_defaultTextureUpdates( false ), - m_transformCurrent(0), + m_transformCurrent( 0 ), m_itemsRendered( 0 ), m_maxItemsToRender( 0xffffffff ), m_drawCallsRendered( 0 ), @@ -158,7 +158,7 @@ Tr2Sprite2dScene::Tr2Sprite2dScene( IRoot* lockobj ) : m_texelSizeVar[i].Register( name, Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) ); } - for( int j=0; j<2; ++j ) + for( int j = 0; j < 2; ++j ) { m_textureSettings[j].useTransform = false; } @@ -203,15 +203,15 @@ void Tr2Sprite2dScene::Update( Be::Time realTime, Be::Time simTime ) } Vector3 tmp = Tr2Renderer::GetViewLookAt(); - Quaternion tweak(0.332621f,0.332621f,0.000000,0.882455f); - TriVectorRotateQuaternion(&tmp, &tmp, &tweak); + Quaternion tweak( 0.332621f, 0.332621f, 0.000000, 0.882455f ); + TriVectorRotateQuaternion( &tmp, &tmp, &tweak ); Vector4 tmpw( tmp.x, tmp.y, tmp.z, 1.0f ); m_dotVectorVar = tmpw; for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( realTime, simTime ); + ( *it )->Update( realTime, simTime ); } if( m_clearFinishedCurveSets ) @@ -265,18 +265,18 @@ void Tr2Sprite2dScene::Render( Tr2RenderContext& renderContext ) for( ITr2SpriteObjectVector::reverse_iterator it = m_background.rbegin(); it != m_background.rend(); ++it ) { - (*it)->GatherSprites( this ); + ( *it )->GatherSprites( this ); } for( ITr2SpriteObjectVector::reverse_iterator it = m_children.rbegin(); it != m_children.rend(); ++it ) { - (*it)->GatherSprites( this ); + ( *it )->GatherSprites( this ); } CCP_ASSERT( !m_captureDisplayList ); IssueDrawCall(); - PrepareRenderContextAfterRendering(renderContext); + PrepareRenderContextAfterRendering( renderContext ); CleanUpStacksAfterRender(); @@ -300,7 +300,7 @@ ITr2SpriteObject* Tr2Sprite2dScene::PickObject( int x, int y, const TriProjectio float finalY; if( !m_is2dPick ) { - float fx,fy; + float fx, fy; Vector3 startWorld; Vector3 dirWorld; @@ -322,11 +322,11 @@ ITr2SpriteObject* Tr2Sprite2dScene::PickObject( int x, int y, const TriProjectio Vector3 rayEnd = TransformCoord( Vector3( fx, fy, 0.5f ), invWorldViewProjectionTransform ); - float slopeX = (rayEnd.z - rayStart.z) / (rayEnd.x - rayStart.x); - finalX = (slopeX * rayStart.x - rayStart.z) / slopeX; + float slopeX = ( rayEnd.z - rayStart.z ) / ( rayEnd.x - rayStart.x ); + finalX = ( slopeX * rayStart.x - rayStart.z ) / slopeX; - float slopeY = (rayEnd.z - rayStart.z) / (rayEnd.y - rayStart.y); - finalY = (slopeY * rayStart.y - rayStart.z) / slopeY; + float slopeY = ( rayEnd.z - rayStart.z ) / ( rayEnd.y - rayStart.y ); + finalY = ( slopeY * rayStart.y - rayStart.z ) / slopeY; finalY = 1.0f - finalY; @@ -353,7 +353,6 @@ ITr2SpriteObject* Tr2Sprite2dScene::PickObject( int x, int y, const TriProjectio g_debugRenderer->Printf( 50, 70, 0xffffffff, "%4.2f, %4.2f, %4.2f", rayEnd.x, rayEnd.y, rayEnd.z ); g_debugRenderer->Printf( 50, 80, 0xffffffff, "%4.4f, %4.4f - %4.2f, %4.2f", fx, fy, finalX, finalY ); } - } else { @@ -369,7 +368,7 @@ ITr2SpriteObject* Tr2Sprite2dScene::PickObject( int x, int y, const TriProjectio for( ITr2SpriteObjectVector::iterator it = m_children.begin(); it != m_children.end(); ++it ) { - obj = (*it)->PickPoint( finalX, finalY, this ); + obj = ( *it )->PickPoint( finalX, finalY, this ); CCP_ASSERT( m_transformStack->empty() ); if( obj ) { @@ -382,7 +381,6 @@ ITr2SpriteObject* Tr2Sprite2dScene::PickObject( int x, int y, const TriProjectio void Tr2Sprite2dScene::RenderDebugInfo( Tr2RenderContext& renderContext ) { - } void Tr2Sprite2dScene::PushTranslation( const Vector2& t ) @@ -462,8 +460,8 @@ void Tr2Sprite2dScene::PushDepthRange( float depthMin, float depthMax ) CCP_ASSERT( !m_depthStack->empty() ); // Relative range is from -1 to 1 - float normDepthMin = 0.5f*(depthMin + 1.0f); - float normDepthMax = 0.5f*(depthMax + 1.0f); + float normDepthMin = 0.5f * ( depthMin + 1.0f ); + float normDepthMax = 0.5f * ( depthMax + 1.0f ); const Vector2& currentDepthValues = m_depthStack->back(); float depthRange = currentDepthValues.y - currentDepthValues.x; @@ -495,8 +493,8 @@ void Tr2Sprite2dScene::SetDepth( float depth ) const Vector2& currentDepthValues = m_depthStack->back(); float depthRange = currentDepthValues.y - currentDepthValues.x; - float normDepth = 0.5f*(depth + 1.0f); - m_depth = currentDepthValues.x + normDepth*depthRange; + float normDepth = 0.5f * ( depth + 1.0f ); + m_depth = currentDepthValues.x + normDepth * depthRange; } void Tr2Sprite2dScene::PushTransform( const Matrix& m ) @@ -583,18 +581,19 @@ void Tr2Sprite2dScene::PushClipRectangle( float x, float y, float width, float h if( top.isTranslationOnly ) { - rect.left = (x + top.translation.x); - rect.top = (y + top.translation.y); - rect.right = (rect.left + width); - rect.bottom = (rect.top + height); + rect.left = ( x + top.translation.x ); + rect.top = ( y + top.translation.y ); + rect.right = ( rect.left + width ); + rect.bottom = ( rect.top + height ); } else { const Matrix& transform = top.transform; Vector4 corners[4]; - for( int i=0; i<4; ++i ) { - corners[i] = Vector4(0.f,0.f,0.f,1.f); + for( int i = 0; i < 4; ++i ) + { + corners[i] = Vector4( 0.f, 0.f, 0.f, 1.f ); } corners[0].x = x; @@ -648,8 +647,8 @@ void Tr2Sprite2dScene::PushClipRectangle( float x, float y, float width, float h { rect.left = x; rect.top = y; - rect.right = (rect.left + width); - rect.bottom = (rect.top + height); + rect.right = ( rect.left + width ); + rect.bottom = ( rect.top + height ); } if( !m_clipStack->empty() ) @@ -771,12 +770,12 @@ void Tr2Sprite2dScene::SetTexture( unsigned ix, Tr2AtlasTexturePtr tex, Tr2Sprit texSettings.textureWindow = Vector4( 0.0f, 0.0f, 1.0f, 1.0f ); } - texSettings.repeatMode = (settings & S2D_TS_REPEAT_CLAMP) ? Tr2Sprite2dScene::TextureSetting::TR_Clamp : - (settings & S2D_TS_REPEAT_MIRROR) ? Tr2Sprite2dScene::TextureSetting::TR_Mirror : Tr2Sprite2dScene::TextureSetting::TR_Tile; - - texSettings.tileX = (settings & S2D_TS_TILE_X) != 0; - texSettings.tileY = (settings & S2D_TS_TILE_Y) != 0; + texSettings.repeatMode = ( settings & S2D_TS_REPEAT_CLAMP ) ? Tr2Sprite2dScene::TextureSetting::TR_Clamp : + ( settings & S2D_TS_REPEAT_MIRROR ) ? Tr2Sprite2dScene::TextureSetting::TR_Mirror : + Tr2Sprite2dScene::TextureSetting::TR_Tile; + texSettings.tileX = ( settings & S2D_TS_TILE_X ) != 0; + texSettings.tileY = ( settings & S2D_TS_TILE_Y ) != 0; } void Tr2Sprite2dScene::SetTextureWindow( unsigned int ix, float x, float y, float width, float height ) @@ -831,8 +830,7 @@ bool Tr2Sprite2dScene::PrepareSpriteVerts( const Vector2& pos, float width, float height, - Tr2SpriteObjectEffect sfx - ) + Tr2SpriteObjectEffect sfx ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -859,7 +857,7 @@ bool Tr2Sprite2dScene::PrepareSpriteVerts( }; - if( (sfx == TR2_SFX_BLUR) || (sfx == TR2_SFX_GLOW) ) + if( ( sfx == TR2_SFX_BLUR ) || ( sfx == TR2_SFX_GLOW ) ) { float textureWidthReciprocal = 1.f; float textureHeightReciprocal = 1.f; @@ -892,7 +890,7 @@ bool Tr2Sprite2dScene::PrepareSpriteVerts( { //CCP_STATS_ZONE( __FUNCTION__ " vertices" ); - for( int i=0; i<4; ++ i ) + for( int i = 0; i < 4; ++i ) { Tr2Sprite2dD3DVertex& vertex = destVerts[i]; vertex.position.x = verts[i].x; @@ -900,7 +898,7 @@ bool Tr2Sprite2dScene::PrepareSpriteVerts( vertex.position.z = m_depth; vertex.color = m_color; vertex.texCoord[0] = uv[0][i]; - if( (sfx == TR2_SFX_BLUR) || (sfx == TR2_SFX_GLOW) || (sfx == TR2_SFX_OUTLINE) ) + if( ( sfx == TR2_SFX_BLUR ) || ( sfx == TR2_SFX_GLOW ) || ( sfx == TR2_SFX_OUTLINE ) ) { vertex.texCoord[1] = uvInitial[0][( i + 2 ) % 4]; } @@ -908,7 +906,7 @@ bool Tr2Sprite2dScene::PrepareSpriteVerts( { vertex.texCoord[1] = uv[1][i]; } - if (sfx == TR2_SFX_OUTLINE) + if( sfx == TR2_SFX_OUTLINE ) { vertex.outlineColor = m_outlineColor; vertex.outlineThreshold = m_outlineThreshold; @@ -993,7 +991,7 @@ bool Tr2Sprite2dScene::PrepareTriangleVerts( Tr2Sprite2dD3DVertex* destVerts, Tr destVerts->transformIndex = 0; ++destVerts; - curVertex = (Tr2Sprite2dVertexBase*)((uint8_t*)curVertex + stride); + curVertex = (Tr2Sprite2dVertexBase*)( (uint8_t*)curVertex + stride ); } return true; @@ -1001,7 +999,7 @@ bool Tr2Sprite2dScene::PrepareTriangleVerts( Tr2Sprite2dD3DVertex* destVerts, Tr void Tr2Sprite2dScene::RenderTriangleVerts( Tr2Sprite2dD3DVertex* verticesSrc, unsigned int vertexCount, unsigned short* indices, unsigned short indexCount ) { - if( m_transformCurrent >= TR2_SS_MAX_TRANSFORM_COUNT-1 ) + if( m_transformCurrent >= TR2_SS_MAX_TRANSFORM_COUNT - 1 ) { // Buffers are full, kick off what we've got IssueDrawCall(); @@ -1084,7 +1082,7 @@ void Tr2Sprite2dScene::IssueDrawCall() entry.effect = m_effect; m_texelSizeVar[0].GetValue( entry.texelSize0 ); m_texelSizeVar[1].GetValue( entry.texelSize1 ); - + //entry.vsConstantTable = m_vsConstantTable; //entry.transformsHandle = m_transformsHandle; entry.m_uiTransformsCb = &m_uiTransformsCb; @@ -1102,55 +1100,55 @@ void Tr2Sprite2dScene::IssueDrawCall() ++m_drawCallsRendered; - if( effectOK && (m_drawCallsRendered < m_maxDrawCallsToRender) ) + if( effectOK && ( m_drawCallsRendered < m_maxDrawCallsToRender ) ) { renderContext.AddGpuMarker( "Tr2Sprite2dScene::IssueDrawCall Direct" ); uint32_t vertexBufferOffset; - if( FAILED( m_vertexBuffer.PutData( - m_vertexBufferData.get(), - m_vertexCount * sizeof( Tr2Sprite2dD3DVertex ), - vertexBufferOffset, - renderContext ) ) ) + if( FAILED( m_vertexBuffer.PutData( + m_vertexBufferData.get(), + m_vertexCount * sizeof( Tr2Sprite2dD3DVertex ), + vertexBufferOffset, + renderContext ) ) ) { CCP_LOGERR( "Failed to update stream vertex buffer for UI" ); } else { - if( FAILED( m_indexBuffer.PutData( - m_indexBufferData.get(), - m_indexCount * sizeof( uint32_t ), - m_drawCallStartIndex, - renderContext ) ) ) + if( FAILED( m_indexBuffer.PutData( + m_indexBufferData.get(), + m_indexCount * sizeof( uint32_t ), + m_drawCallStartIndex, + renderContext ) ) ) { CCP_LOGERR( "Failed to update stream index buffer for UI" ); } else { - if( auto desc = m_effect->GetPassDescription( 0, 0 ) ) - { - for( uint32_t i = 0; i < 2; ++i ) - { - Tr2TextureAL* texAL = nullptr; - if( m_texture[i] ) - { - texAL = m_texture[i]->GetTexture(); - if( !texAL ) - { - if( m_texture[i]->GetRenderTarget() ) - { - texAL = m_texture[i]->GetRenderTarget(); - } - } - } - auto colorSpace = m_useLinearColorSpace ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; - desc->m_resourceSetDirty |= desc->m_resourceSetDesc.SetSrv( PIXEL_SHADER, m_textureRegisters[i], texAL ? *texAL : Tr2TextureAL(), colorSpace ); - } - } + if( auto desc = m_effect->GetPassDescription( 0, 0 ) ) + { + for( uint32_t i = 0; i < 2; ++i ) + { + Tr2TextureAL* texAL = nullptr; + if( m_texture[i] ) + { + texAL = m_texture[i]->GetTexture(); + if( !texAL ) + { + if( m_texture[i]->GetRenderTarget() ) + { + texAL = m_texture[i]->GetRenderTarget(); + } + } + } + auto colorSpace = m_useLinearColorSpace ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; + desc->m_resourceSetDirty |= desc->m_resourceSetDesc.SetSrv( PIXEL_SHADER, m_textureRegisters[i], texAL ? *texAL : Tr2TextureAL(), colorSpace ); + } + } m_drawCallStartIndex /= sizeof( uint32_t ); renderContext.m_esm.ApplyStreamSource( 0, m_vertexBuffer.GetBuffer(), vertexBufferOffset, sizeof( Tr2Sprite2dD3DVertex ) ); - renderContext.m_esm.ApplyIndexBuffer( m_indexBuffer.GetBuffer() ); + renderContext.m_esm.ApplyIndexBuffer( m_indexBuffer.GetBuffer() ); m_effect->Render( this, renderContext ); m_indexBuffer.DoneUsingData( renderContext ); } @@ -1177,13 +1175,13 @@ void Tr2Sprite2dScene::SubmitGeometry( Tr2RenderContext& renderContext ) transposedMatrixes[i] = Transpose( m_transformArray[i] ); } - bool result = FillAndSetConstants( - m_uiTransformsCb, - transposedMatrixes, - sizeof( transposedMatrixes[0] ) * TR2_SS_MAX_TRANSFORM_COUNT, - VERTEX_SHADER, - Tr2Renderer::GetPerObjectVSGUIStartRegister(), - renderContext ); + bool result = FillAndSetConstants( + m_uiTransformsCb, + transposedMatrixes, + sizeof( transposedMatrixes[0] ) * TR2_SS_MAX_TRANSFORM_COUNT, + VERTEX_SHADER, + Tr2Renderer::GetPerObjectVSGUIStartRegister(), + renderContext ); if( !result ) { @@ -1248,7 +1246,7 @@ bool Tr2Sprite2dScene::OnPrepareResources() unsigned int indexCount = m_maxSpriteCount * 6; unsigned int ibSize = indexCount * sizeof( uint32_t ); - unsigned int vbSize = m_maxSpriteCount * 4 * sizeof(Tr2Sprite2dD3DVertex); + unsigned int vbSize = m_maxSpriteCount * 4 * sizeof( Tr2Sprite2dD3DVertex ); if( !m_vertexBuffer.Create( vbSize ) ) { @@ -1296,12 +1294,11 @@ bool Tr2Sprite2dScene::OnPrepareResources() if( m_defaultTexture ) { //Make a little tiny deliberately ugly checker pattern - void *data = NULL; + void* data = NULL; unsigned pitch = 0; if( m_defaultTexture->LockBuffer( data, pitch ) ) { - static const unsigned char defaultPixels[2][8] = - { + static const unsigned char defaultPixels[2][8] = { { 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff }, { 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00 } }; @@ -1385,7 +1382,7 @@ bool Tr2Sprite2dScene::IsInside( const Vector2& pointIn, const Vector2& topLeft, // untransformed bounding rectangle Matrix inv = Inverse( transform ); - TransformPoint(point, point, inv); + TransformPoint( point, point, inv ); } } @@ -1408,15 +1405,15 @@ bool Tr2Sprite2dScene::IsInside( const Vector2& pointIn, const Vector2& topLeft, if( radius != 0.0f ) { - float centerX = 0.5f * (right - left) + left; - float centerY = 0.5f * (bottom - top) + top; + float centerX = 0.5f * ( right - left ) + left; + float centerY = 0.5f * ( bottom - top ) + top; float dX = centerX - point.x; float dY = centerY - point.y; if( radius > 0.0f ) { - if( dX*dX + dY*dY > radius*radius ) + if( dX * dX + dY * dY > radius * radius ) { return false; } @@ -1438,7 +1435,7 @@ bool Tr2Sprite2dScene::IsInside( const Vector2& pointIn, const Vector2& topLeft, b = rwidth * 0.5f; } - if( dX*dX/(a*a) + dY*dY/(b*b) > 1.0f ) + if( dX * dX / ( a * a ) + dY * dY / ( b * b ) > 1.0f ) { return false; } @@ -1480,8 +1477,8 @@ bool Tr2Sprite2dScene::IsInsideLineSegment( const Vector2& pointIn, const Vector { const Matrix& transform = topEntry.transform; - TransformPoint(startTransformed, start, transform ); - TransformPoint(endTransformed, end, transform ); + TransformPoint( startTransformed, start, transform ); + TransformPoint( endTransformed, end, transform ); } } @@ -1490,13 +1487,13 @@ bool Tr2Sprite2dScene::IsInsideLineSegment( const Vector2& pointIn, const Vector float dx = endTransformed.x - startTransformed.x; float dy = endTransformed.y - startTransformed.y; - float den = sqrtf(dx*dx + dy*dy); + float den = sqrtf( dx * dx + dy * dy ); if( den < FLT_EPSILON ) { return false; } - float nom = fabs( dy*pointIn.x - dx*pointIn.y - startTransformed.x*endTransformed.y + startTransformed.y*endTransformed.x ); + float nom = fabs( dy * pointIn.x - dx * pointIn.y - startTransformed.x * endTransformed.y + startTransformed.y * endTransformed.x ); float distance = nom / den; if( distance > lineWidth ) @@ -1506,9 +1503,9 @@ bool Tr2Sprite2dScene::IsInsideLineSegment( const Vector2& pointIn, const Vector // Check that we are between the end points of the segment - Vector2 centerPoint = 0.5f * (startTransformed + endTransformed); + Vector2 centerPoint = 0.5f * ( startTransformed + endTransformed ); Vector2 pointToCenter = pointIn - centerPoint; - float distanceFromCenter = sqrtf( pointToCenter.x*pointToCenter.x + pointToCenter.y*pointToCenter.y ); + float distanceFromCenter = sqrtf( pointToCenter.x * pointToCenter.x + pointToCenter.y * pointToCenter.y ); if( distanceFromCenter > den * 0.5f ) { return false; @@ -1519,17 +1516,17 @@ bool Tr2Sprite2dScene::IsInsideLineSegment( const Vector2& pointIn, const Vector static float Sign( const Vector2& v1, const Vector2& v2, const Vector2& v3 ) { - return (v1.x - v3.x) * (v2.y - v3.y) - (v2.x - v3.x) * (v1.y - v3.y); + return ( v1.x - v3.x ) * ( v2.y - v3.y ) - ( v2.x - v3.x ) * ( v1.y - v3.y ); } static bool IsDegenerateTriangle( const Vector2& v0, const Vector2& v1, const Vector2& v2 ) { - if( (fabs( v0.x - v1.x) < FLT_EPSILON) && (fabs( v0.y - v1.y) < FLT_EPSILON) ) + if( ( fabs( v0.x - v1.x ) < FLT_EPSILON ) && ( fabs( v0.y - v1.y ) < FLT_EPSILON ) ) { return true; } - if( (fabs( v0.x - v2.x) < FLT_EPSILON) && (fabs( v0.y - v2.y) < FLT_EPSILON) ) + if( ( fabs( v0.x - v2.x ) < FLT_EPSILON ) && ( fabs( v0.y - v2.y ) < FLT_EPSILON ) ) { return true; } @@ -1774,23 +1771,23 @@ void Tr2Sprite2dScene::RunJob( TriRenderJob* job ) entry.primitiveCount = 0; entry.texture0 = nullptr; entry.texture1 = nullptr; - entry.texelSize0 = Vector4( 0,0,0,0 ); - entry.texelSize1 = Vector4( 0,0,0,0 ); + entry.texelSize0 = Vector4( 0, 0, 0, 0 ); + entry.texelSize1 = Vector4( 0, 0, 0, 0 ); m_captureDisplayList->entries.push_back( entry ); } else { - RunJobHelper(job); + RunJobHelper( job ); // The render job may have set different textures - clear // our state for texture settings - for( unsigned int i=0; i < s_textureMax; ++i ) + for( unsigned int i = 0; i < s_textureMax; ++i ) { m_texture[i] = nullptr; } - renderContext.m_esm.ApplyIndexBuffer( m_indexBuffer.GetBuffer() ); + renderContext.m_esm.ApplyIndexBuffer( m_indexBuffer.GetBuffer() ); } } @@ -1856,7 +1853,7 @@ void Tr2Sprite2dScene::ProcessVertices( Tr2Sprite2dD3DVertex* verticesSrc, unsig transformIndex = ++m_transformCurrent; const Matrix& transform = top.transform; CCP_STATS_INC( spriteSceneTransforms ); - m_transformArray[ transformIndex ] = transform; + m_transformArray[transformIndex] = transform; pos = Vector2( 0.0f, 0.0f ); } } @@ -1864,7 +1861,7 @@ void Tr2Sprite2dScene::ProcessVertices( Tr2Sprite2dD3DVertex* verticesSrc, unsig memcpy( m_currentVertexData, verticesSrc, vertexCount * sizeof( Tr2Sprite2dD3DVertex ) ); - if( (pos.x != 0.0f) || (pos.y != 0.0f) ) + if( ( pos.x != 0.0f ) || ( pos.y != 0.0f ) ) { for( unsigned int i = 0; i < vertexCount; ++i ) { @@ -1963,11 +1960,11 @@ bool Tr2Sprite2dScene::StartCapture( ITr2SpriteObject* owner ) CCP_ASSERT( m_currentVertexData ); m_preCaptureVertexData = m_currentVertexData; - m_currentVertexData = reinterpret_cast(m_captureVertexData.get()); + m_currentVertexData = reinterpret_cast( m_captureVertexData.get() ); CCP_ASSERT( m_currentIndexData ); m_preCaptureIndexData = m_currentIndexData; - m_currentIndexData = reinterpret_cast(m_captureIndexData.get()); + m_currentIndexData = reinterpret_cast( m_captureIndexData.get() ); m_captureStartIndex = 0; @@ -2005,16 +2002,15 @@ Tr2Sprite2dDisplayList* Tr2Sprite2dScene::EndCapture( Tr2Sprite2dDisplayList* pr { bool reusedVb = false; - if( previousDisplayList && previousDisplayList->vertexBuffer.IsValid() && + if( previousDisplayList && previousDisplayList->vertexBuffer.IsValid() && previousDisplayList->vertexBuffer.GetSize() >= vbSize && previousDisplayList->vertexBuffer.GetSize() / 2 <= vbSize ) { if( SUCCEEDED( previousDisplayList->vertexBuffer.UpdateBuffer( 0, vbSize, m_captureVertexData.get(), renderContext ) ) ) - { - m_captureDisplayList->vertexBuffer = previousDisplayList->vertexBuffer; - previousDisplayList->vertexBuffer = Tr2BufferAL(); - reusedVb = true; - } - + { + m_captureDisplayList->vertexBuffer = previousDisplayList->vertexBuffer; + previousDisplayList->vertexBuffer = Tr2BufferAL(); + reusedVb = true; + } } if( !reusedVb ) { @@ -2036,16 +2032,15 @@ Tr2Sprite2dDisplayList* Tr2Sprite2dScene::EndCapture( Tr2Sprite2dDisplayList* pr { bool reusedIb = false; - if( previousDisplayList && previousDisplayList->indexBuffer.IsValid() && + if( previousDisplayList && previousDisplayList->indexBuffer.IsValid() && previousDisplayList->indexBuffer.GetSize() >= ibSize && previousDisplayList->indexBuffer.GetSize() / 2 <= ibSize ) { if( SUCCEEDED( previousDisplayList->indexBuffer.UpdateBuffer( 0, ibSize, m_captureIndexData.get(), renderContext ) ) ) - { - m_captureDisplayList->indexBuffer = previousDisplayList->indexBuffer; - previousDisplayList->indexBuffer = Tr2BufferAL(); - reusedIb = true; - } - + { + m_captureDisplayList->indexBuffer = previousDisplayList->indexBuffer; + previousDisplayList->indexBuffer = Tr2BufferAL(); + reusedIb = true; + } } if( !reusedIb ) { @@ -2069,7 +2064,7 @@ Tr2Sprite2dDisplayList* Tr2Sprite2dScene::EndCapture( Tr2Sprite2dDisplayList* pr Tr2Sprite2dDisplayList* dl = m_captureDisplayList; m_captureDisplayList = nullptr; - + ResetCapture(); return dl; @@ -2121,14 +2116,14 @@ void Tr2Sprite2dScene::ReplayCapture( Tr2Sprite2dDisplayList* dl ) auto colorSpace = m_useLinearColorSpace ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; desc->m_resourceSetDirty |= desc->m_resourceSetDesc.SetSrv( PIXEL_SHADER, m_textureRegisters[0], ( entry.texture0 && entry.texture0->GetTexture() ) ? *entry.texture0->GetTexture() : Tr2TextureAL(), colorSpace ); desc->m_resourceSetDirty |= desc->m_resourceSetDesc.SetSrv( PIXEL_SHADER, m_textureRegisters[1], ( entry.texture1 && entry.texture1->GetTexture() ) ? *entry.texture1->GetTexture() : Tr2TextureAL(), colorSpace ); - + CCP_STATS_INC( spriteSceneDrawCallCount ); entry.effect->Render( &entry, renderContext ); } } - for( unsigned int i=0; i < s_textureMax; ++i ) + for( unsigned int i = 0; i < s_textureMax; ++i ) { m_texture[i] = nullptr; } @@ -2245,7 +2240,7 @@ void Tr2Sprite2dScene::FlashDefaultTexture() uint32_t* pixels = (uint32_t*)data; pixels[0] = pixelValue; pixels[1] = pixelValue; - data = (void*)((uint8_t*)data + pitch); + data = (void*)( (uint8_t*)data + pitch ); pixels = (uint32_t*)data; pixels[0] = pixelValue; pixels[1] = pixelValue; @@ -2356,7 +2351,7 @@ void Tr2Sprite2dScene::DetermineWorldTransform() Tr2Renderer::SetWorldTransform( worldTransform ); } -void Tr2Sprite2dScene::PrepareRenderContextForRendering( Tr2RenderContext &renderContext ) +void Tr2Sprite2dScene::PrepareRenderContextForRendering( Tr2RenderContext& renderContext ) { renderContext.m_esm.BeginManagedRendering(); renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_SPRITE2D ); @@ -2372,7 +2367,7 @@ void Tr2Sprite2dScene::PrepareRenderContextForRendering( Tr2RenderContext &rende renderContext.m_esm.ApplyIndexBuffer( m_indexBuffer.GetBuffer() ); } -void Tr2Sprite2dScene::PrepareRenderContextAfterRendering( Tr2RenderContext &renderContext ) +void Tr2Sprite2dScene::PrepareRenderContextAfterRendering( Tr2RenderContext& renderContext ) { renderContext.m_esm.EndManagedRendering(); renderContext.m_esm.SetWireframeRendering( false ); @@ -2390,7 +2385,7 @@ void Tr2Sprite2dScene::PrepareStacksBeforeRender() CCP_ASSERT( m_clipStack->empty() ); CCP_ASSERT( m_transformStack->empty() ); - m_depthStack->push_back( Vector2 ( m_depthMin, m_depthMax ) ); + m_depthStack->push_back( Vector2( m_depthMin, m_depthMax ) ); m_clipStack->push_back( Tr2Sprite2dClipRect( -FLT_MAX, -FLT_MAX, FLT_MAX, FLT_MAX ) ); } @@ -2406,12 +2401,12 @@ void Tr2Sprite2dScene::CleanUpStacksAfterRender() void Tr2Sprite2dScene::SetSpriteVerticesUVs( Vector2 uv[2][4], float width, float height ) { - for( int i=0; i < m_numTexturesUsed; ++i ) + for( int i = 0; i < m_numTexturesUsed; ++i ) { const TextureSetting& texSetting = m_textureSettings[i]; uv[i][0] = Vector2( 0.0f, 0.0f ); - uv[i][1] = Vector2( 1.0f, 0.0f); + uv[i][1] = Vector2( 1.0f, 0.0f ); uv[i][2] = Vector2( 1.0f, 1.0f ); uv[i][3] = Vector2( 0.0f, 1.0f ); @@ -2421,7 +2416,7 @@ void Tr2Sprite2dScene::SetSpriteVerticesUVs( Vector2 uv[2][4], float width, floa // TexturesReady at the start guarantees that at is not null float rTexWidth = at->GetWidthReciprocal(); - for( int j=0; j<4; ++j ) + for( int j = 0; j < 4; ++j ) { uv[i][j].x *= width * rTexWidth; } @@ -2432,7 +2427,7 @@ void Tr2Sprite2dScene::SetSpriteVerticesUVs( Vector2 uv[2][4], float width, floa // TexturesReady at the start guarantees that at is not null float rTexHeight = at->GetHeightReciprocal(); - for( int j=0; j<4; ++j ) + for( int j = 0; j < 4; ++j ) { uv[i][j].y *= height * rTexHeight; } @@ -2440,7 +2435,7 @@ void Tr2Sprite2dScene::SetSpriteVerticesUVs( Vector2 uv[2][4], float width, floa if( texSetting.useTransform ) { - for( int j=0; j<4; ++j ) + for( int j = 0; j < 4; ++j ) { Vector4 uvT( uv[i][j].x, uv[i][j].y, 0.f, 1.f ); uvT = Transform( uvT, texSetting.transform ); @@ -2477,7 +2472,7 @@ void Tr2Sprite2dScene::GrowCaptureVertexBuffer( unsigned int vertexCount ) size_t vbSize = m_captureVertexDataCapacity * sizeof( Tr2Sprite2dD3DVertex ); m_captureVertexData.resize( "Tr2Sprite2dScene/m_captureVertexData", vbSize ); - + CCP_ASSERT( m_captureVertexData ); } @@ -2513,7 +2508,7 @@ void Tr2Sprite2dScene::CopyIndicesWithOffset( unsigned short* indices, unsigned m_indexCount += indexCount; } -bool Tr2Sprite2dScene::EnsureBufferSpace( unsigned int vertexCount, unsigned short indexCount, int &vertexOffset ) +bool Tr2Sprite2dScene::EnsureBufferSpace( unsigned int vertexCount, unsigned short indexCount, int& vertexOffset ) { if( m_captureDisplayList ) { @@ -2529,7 +2524,7 @@ bool Tr2Sprite2dScene::EnsureBufferSpace( unsigned int vertexCount, unsigned sho return false; } - m_currentVertexData = reinterpret_cast(m_captureVertexData.get()) + m_captureVertexDataSize; + m_currentVertexData = reinterpret_cast( m_captureVertexData.get() ) + m_captureVertexDataSize; } // Index count is estimated, allow the index buffer to grow as needed. @@ -2542,7 +2537,7 @@ bool Tr2Sprite2dScene::EnsureBufferSpace( unsigned int vertexCount, unsigned sho return false; } - m_currentIndexData = reinterpret_cast(m_captureIndexData.get()) + m_captureIndexDataSize; + m_currentIndexData = reinterpret_cast( m_captureIndexData.get() ) + m_captureIndexDataSize; } vertexOffset = m_captureVertexDataSize; @@ -2559,13 +2554,13 @@ bool Tr2Sprite2dScene::EnsureBufferSpace( unsigned int vertexCount, unsigned sho return false; } - if( (m_vertexCount + vertexCount >= m_maxSpriteCount * 4) || (m_indexCount + indexCount >= m_maxSpriteCount * 6) ) + if( ( m_vertexCount + vertexCount >= m_maxSpriteCount * 4 ) || ( m_indexCount + indexCount >= m_maxSpriteCount * 6 ) ) { // Buffers are full, kick off what we've got IssueDrawCall(); } - CCP_ASSERT( (m_vertexCount + vertexCount <= m_maxSpriteCount * 4) && (m_indexCount + indexCount <= m_maxSpriteCount * 6) ); + CCP_ASSERT( ( m_vertexCount + vertexCount <= m_maxSpriteCount * 4 ) && ( m_indexCount + indexCount <= m_maxSpriteCount * 6 ) ); if( ( m_vertexCount + vertexCount > m_maxSpriteCount * 4 ) || ( m_indexCount + indexCount > m_maxSpriteCount * 6 ) ) { return false; @@ -2650,7 +2645,7 @@ void Tr2Sprite2dScene::SetUseLinearColorSpace( bool use ) m_uberShader3d->SetOption( BlueSharedString( "COLOR_SPACE" ), BlueSharedString( m_useLinearColorSpace ? "COLOR_SPACE_LINEAR" : "COLOR_SPACE_SRGB" ) ); } } -void Tr2Sprite2dScene::SetGammaCorrectText( bool use) +void Tr2Sprite2dScene::SetGammaCorrectText( bool use ) { m_isGammaCorrectingText = use; m_uberShader2d->SetOption( BlueSharedString( "FONT_GAMMACORRECT" ), BlueSharedString( m_isGammaCorrectingText ? "ENABLED" : "DISABLED" ) ); @@ -2660,4 +2655,3 @@ bool Tr2Sprite2dScene::IsGammaCorrectingText() { return m_isGammaCorrectingText; } - diff --git a/trinity/Sprite2d/Tr2Sprite2dScene.h b/trinity/Sprite2d/Tr2Sprite2dScene.h index b42a3de5f..c40bb229d 100644 --- a/trinity/Sprite2d/Tr2Sprite2dScene.h +++ b/trinity/Sprite2d/Tr2Sprite2dScene.h @@ -26,15 +26,14 @@ BLUE_DECLARE( Tr2Effect ); class TriProjection; class TriView; -class Tr2Sprite2dScene: - public ITr2Scene, - public INotify, - public IRenderCallback, - public Tr2DeviceResource +class Tr2Sprite2dScene : public ITr2Scene, + public INotify, + public IRenderCallback, + public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2dScene( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2dScene( IRoot* lockobj = NULL ); Tr2Sprite2dScene( const Tr2Sprite2dScene& ) = delete; Tr2Sprite2dScene& operator=( const Tr2Sprite2dScene& ) = delete; ~Tr2Sprite2dScene(); @@ -97,36 +96,34 @@ class Tr2Sprite2dScene: Vector2 InverseTransformPoint( const Vector2& point ) const; - bool PrepareSpriteVerts( + bool PrepareSpriteVerts( Tr2Sprite2dD3DVertex* destVerts, const Vector2& pos, float width, float height, - Tr2SpriteObjectEffect sfx - ); + Tr2SpriteObjectEffect sfx ); void SetSpriteVerticesUVs( Vector2 uv[2][4], float width, float height ); bool PrepareTriangleVerts( Tr2Sprite2dD3DVertex* destVerts, - Tr2Sprite2dVertexBase* verts, - unsigned int stride, - unsigned int vertexCount - ); + Tr2Sprite2dVertexBase* verts, + unsigned int stride, + unsigned int vertexCount ); - void RenderTriangleVerts( - Tr2Sprite2dD3DVertex* verticesSrc, + void RenderTriangleVerts( + Tr2Sprite2dD3DVertex* verticesSrc, unsigned int vertexCount, - unsigned short* indices, + unsigned short* indices, unsigned short indexCount ); - void RenderTriangleVerts( - Tr2BufferAL& verticesSrc, + void RenderTriangleVerts( + Tr2BufferAL& verticesSrc, unsigned int vertexCount, - Tr2BufferAL& indices, + Tr2BufferAL& indices, unsigned short indexCount ); - bool EnsureBufferSpace( unsigned int vertexCount, unsigned short indexCount, int &vertexOffset ); + bool EnsureBufferSpace( unsigned int vertexCount, unsigned short indexCount, int& vertexOffset ); bool IsCapturing() const; bool StartCapture( ITr2SpriteObject* owner ); @@ -147,6 +144,7 @@ class Tr2Sprite2dScene: ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); bool SelectEffect(); @@ -167,8 +165,8 @@ class Tr2Sprite2dScene: void DetermineWorldTransform(); void DetermineViewportSize(); void SetViewportSizeToVariableStore( float displayWidth, float displayHeight ); - void PrepareRenderContextAfterRendering( Tr2RenderContext &renderContext ); - void PrepareRenderContextForRendering( Tr2RenderContext &renderContext ); + void PrepareRenderContextAfterRendering( Tr2RenderContext& renderContext ); + void PrepareRenderContextForRendering( Tr2RenderContext& renderContext ); void CleanUpStacksAfterRender(); void PrepareStacksBeforeRender(); void GrowCaptureIndexBuffer( unsigned short indexCount ); @@ -225,9 +223,9 @@ class Tr2Sprite2dScene: struct TransformStackEntry { bool isTranslationOnly; - + // Keep track of whether the action that set this was translation only - bool isTranslationOnlySet; + bool isTranslationOnlySet; Vector2 translation; Matrix transform; @@ -255,7 +253,7 @@ class Tr2Sprite2dScene: // If set, fill mode is set to wire frame while rendering. bool m_drawWireFrame; - + // Is the scene fullscreen? If so, m_displayWidth/m_displayHeight // are set every frame to match the fullscreen viewport. Note // that this is normally done by uilib when used for ui rendering. @@ -321,12 +319,12 @@ class Tr2Sprite2dScene: const static unsigned s_textureMax = 2; Tr2AtlasTexturePtr m_texture[s_textureMax]; Tr2Variable m_texelSizeVar[s_textureMax]; - + struct TextureSetting { // Cached texture window, set when texture (or explicit texture window) is set Vector4 textureWindow; - + bool useTransform; Matrix transform; @@ -334,7 +332,8 @@ class Tr2Sprite2dScene: bool tileY; //repetition - enum TextureRepeat { + enum TextureRepeat + { TR_Tile = 0x0, TR_Mirror = 0x1, TR_Clamp = 0x2 @@ -344,7 +343,7 @@ class Tr2Sprite2dScene: TextureSetting m_textureSettings[s_textureMax]; - Matrix m_transformArray[ TR2_SS_MAX_TRANSFORM_COUNT ]; + Matrix m_transformArray[TR2_SS_MAX_TRANSFORM_COUNT]; unsigned m_transformCurrent; Tr2Sprite2dDisplayList* m_captureDisplayList; @@ -353,7 +352,7 @@ class Tr2Sprite2dScene: Tr2Sprite2dD3DVertex* m_preCaptureVertexData; unsigned int m_captureVertexDataSize; unsigned int m_captureVertexDataCapacity; - + unsigned int* m_preCaptureIndexData; CcpAlignedMallocBuffer m_captureIndexData; unsigned int m_captureIndexDataSize; @@ -365,7 +364,7 @@ class Tr2Sprite2dScene: unsigned int m_drawCallsRendered; unsigned int m_maxDrawCallsToRender; - Tr2ConstantBufferAL m_uiTransformsCb; + Tr2ConstantBufferAL m_uiTransformsCb; unsigned int m_maxSpriteCount; }; diff --git a/trinity/Sprite2d/Tr2Sprite2dScene_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dScene_Blue.cpp index 7de7d0fa8..e7797fcc1 100644 --- a/trinity/Sprite2d/Tr2Sprite2dScene_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dScene_Blue.cpp @@ -9,23 +9,16 @@ BLUE_DEFINE_INTERFACE( ITr2SpriteObject ); BLUE_DEFINE( Tr2Sprite2dScene ); -Be::VarChooser Tr2Sprite2dRenderEffectChooser[] = -{ - { - "S2D_RFX_COPY", - BeCast( S2D_RFX_COPY ), - "Copy primary texture" - }, - { - "S2D_RFX_BLUR", - BeCast( S2D_RFX_BLUR ), - "Blurring" - }, - { - "S2D_RFX_MODULATE", - BeCast( S2D_RFX_MODULATE ), - "Multiply primary and secondary textures" - }, +Be::VarChooser Tr2Sprite2dRenderEffectChooser[] = { + { "S2D_RFX_COPY", + BeCast( S2D_RFX_COPY ), + "Copy primary texture" }, + { "S2D_RFX_BLUR", + BeCast( S2D_RFX_BLUR ), + "Blurring" }, + { "S2D_RFX_MODULATE", + BeCast( S2D_RFX_MODULATE ), + "Multiply primary and secondary textures" }, { 0 } }; @@ -33,286 +26,220 @@ BLUE_REGISTER_ENUM( "Tr2Sprite2dRenderEffect", Tr2Sprite2dRenderEffect, Tr2Sprit const Be::ClassInfo* Tr2Sprite2dScene::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dScene, "" ) - MAP_INTERFACE( Tr2Sprite2dScene ) + EXPOSURE_BEGIN( Tr2Sprite2dScene, "" ) + MAP_INTERFACE( Tr2Sprite2dScene ) MAP_INTERFACE( ITr2Scene ) MAP_INTERFACE( ITr2Updateable ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "The name of this scene.", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "display", m_display, "If true, object is displayed. If false, the object is not displayed.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "drawWireFrame", m_drawWireFrame, "If set, the scene is rendered in wire frame", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "ignoreClip", m_ignoreClip, "If set, clipping is ignored (helps with performance analysis", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "lastPickPos", m_lastPickPos, "Position of last pick", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isFullscreen", m_isFullscreen, "Is the scene fullscreen? If so, displayWidth and displayHeight" "\nare set every frame to match the fullscreen viewport", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "is2dRender", m_is2dRender, "If set, the scene is rendered full screen in 2D", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "is2dPick", m_is2dPick, "If set, the scene is rendered full screen in 2D", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "translation", m_translation, "Translation used to render this scene in 3D space", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "displayX", - m_translation.x, - "X-coordinate of this object", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "displayY", - m_translation.y, - "Y-coordinate of this object", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "displayX", + m_translation.x, + "X-coordinate of this object", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "displayY", + m_translation.y, + "Y-coordinate of this object", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "rotation", m_rotation, "Rotation used to render this scene in 3D space", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "scaling", m_scaling, "Scaling used to render this scene in 3D space", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displayWidth", m_displayWidth, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "displayHeight", m_displayHeight, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "depthMin", - m_depthMin, + MAP_ATTRIBUTE( + "depthMin", + m_depthMin, "Minimum depth for objects in the scene.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( - "depthMax", - m_depthMax, + MAP_ATTRIBUTE( + "depthMax", + m_depthMax, "Maximum depth for objects in the scene.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "pickState", m_pickState, "This state controls how the object responds to picking", Be::READWRITE | Be::PERSIST | Be::ENUM, - Tr2SpriteObjectPickStateChooser - ) + Tr2SpriteObjectPickStateChooser ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "clearBackground", m_clearBackground, "If set, render target is cleared to backgroundColor before rendering the scene", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "backgroundColor", - m_backgroundColor, - "Background color for this layer", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "backgroundColor", + m_backgroundColor, + "Background color for this layer", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "children", m_children, "Sprites contained in this scene", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "background", m_background, "Background objects of this scene. Background objects don't get alignment,\n" "but always fill the extent of the scene. They are never considered for\n" "picking, either.", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "clearFinishedCurveSets", m_clearFinishedCurveSets, "If set, curve sets are cleared once finished", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets used in this scene", - Be::READ | Be::PERSIST - ) + Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "ubershader2d", m_uberShader2d, "", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "ubershader3d", m_uberShader3d, "", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "defaultTextureUpdates", m_defaultTextureUpdates, "Whether or not to flash the default texture, causing extra texture locks every frame", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxItemsToRender", m_maxItemsToRender, "The maximum number of sprites (and other items) to render - this can be used for\n" "debugging the scene to see individual sprites being rendered.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxDrawCallsToRender", m_maxDrawCallsToRender, "The maximum number of draw calls to render - this can be used for\n" "debugging the scene to see individual draw calls being rendered.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxSpriteCount", m_maxSpriteCount, "Maximum number of sprites that are rendered in one draw call. This\n" "does not apply for cached containers.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "captureIndexDataCapacity", m_captureIndexDataCapacity, "Capacity of buffer used for indices while capturing display lists.\n" "This buffer grows automatically as needed - this is the number of\n" "indices, not byte size.", - Be::READ - ) + Be::READ ) - MAP_PROPERTY - ( + MAP_PROPERTY( "useLinearColorSpace", IsUsingLinearColorSpace, SetUseLinearColorSpace, - "For TESTING sRGB vs linear color math" - ) + "For TESTING sRGB vs linear color math" ) MAP_PROPERTY( "gammaCorrectText", IsGammaCorrectingText, SetGammaCorrectText, - "For TESTING sRGB vs linear color math" - ) - + "For TESTING sRGB vs linear color math" ) + - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "PickObject", PickObject, 1, @@ -322,8 +249,7 @@ const Be::ClassInfo* Tr2Sprite2dScene::ExposeToBlue() ":param proj: Projection transform\n" ":param view: View transform\n" ":param vp: Viewport\n" - ":param pickFilter: object types to pick (unused)\n" - ) + ":param pickFilter: object types to pick (unused)\n" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Sprite2d/Tr2Sprite2dStretch.cpp b/trinity/Sprite2d/Tr2Sprite2dStretch.cpp index c45169ddc..f5499ca01 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretch.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dStretch.cpp @@ -9,20 +9,32 @@ // All frames can use the same indices - the layout of the sprite is always the same. static unsigned short s_frameIndices[] = { - 0, 4, 5, - 0, 5, 1, - 2, 6, 7, - 2, 7, 3, + 0, + 4, + 5, + 0, + 5, + 1, + 2, + 6, + 7, + 2, + 7, + 3, // The two triangles in the center are kept last - then we can skip the // center by sending fewer triangles. - 1, 5, 6, - 1, 6, 2, + 1, + 5, + 6, + 1, + 6, + 2, }; static const Color WHITE( 1.0f, 1.0f, 1.0f, 1.0f ); -Tr2Sprite2dStretch::Tr2Sprite2dStretch( IRoot* lockobj ) : +Tr2Sprite2dStretch::Tr2Sprite2dStretch( IRoot* lockobj ) : m_leftEdgeSize( 0 ), m_rightEdgeSize( 0 ), m_edgeScale( 1.f ), diff --git a/trinity/Sprite2d/Tr2Sprite2dStretch.h b/trinity/Sprite2d/Tr2Sprite2dStretch.h index 687e6ceab..2b29f998c 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretch.h +++ b/trinity/Sprite2d/Tr2Sprite2dStretch.h @@ -19,14 +19,13 @@ enum Tr2StretchScaleBehavior }; ////////////////////////////////////////////////////////////////////////// -// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the +// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the // Tr2Sprite2dScene to render 2D scenes. // -// It renders a sprite by cutting a texture into three pieces and stretching the +// It renders a sprite by cutting a texture into three pieces and stretching the // center piece appropriately according to the dimensions of the sprite. ////////////////////////////////////////////////////////////////////////// -class Tr2Sprite2dStretch: - public Tr2TexturedSpriteObject +class Tr2Sprite2dStretch : public Tr2TexturedSpriteObject { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Sprite2d/Tr2Sprite2dStretchVertical.cpp b/trinity/Sprite2d/Tr2Sprite2dStretchVertical.cpp index 9d9a0904f..bf6e68c04 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretchVertical.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dStretchVertical.cpp @@ -9,20 +9,32 @@ // All frames can use the same indices - the layout of the sprite is always the same. static unsigned short s_frameIndices[] = { - 0, 2, 3, - 0, 3, 1, - 4, 6, 7, - 4, 7, 5, + 0, + 2, + 3, + 0, + 3, + 1, + 4, + 6, + 7, + 4, + 7, + 5, // The two triangles in the center are kept last - then we can skip the // center by sending fewer triangles. - 2, 4, 5, - 2, 5, 3, + 2, + 4, + 5, + 2, + 5, + 3, }; static const Color WHITE( 1.0f, 1.0f, 1.0f, 1.0f ); -Tr2Sprite2dStretchVertical::Tr2Sprite2dStretchVertical( IRoot* lockobj ) : +Tr2Sprite2dStretchVertical::Tr2Sprite2dStretchVertical( IRoot* lockobj ) : m_topEdgeSize( 0 ), m_bottomEdgeSize( 0 ), m_edgeScale( 1.f ), @@ -100,7 +112,7 @@ void Tr2Sprite2dStretchVertical::GatherSprites( Tr2Sprite2dScene* renderer ) SetValidatedTextures( renderer ); renderer->PushTranslation( m_translation ); - + unsigned int triangleCount = m_fillCenter ? 6 : 4; unsigned int indexCount = triangleCount * 3; if( m_shadowOffset.x != 0.0f || m_shadowOffset.y != 0.0f ) @@ -236,7 +248,7 @@ void Tr2Sprite2dStretchVertical::PrepareVertices( Tr2Sprite2dVertexBase* v, floa // // Fourth line - // + // // Vertex 6 v->position.x = 0.0f + vertOffset.x; v->position.y = scaledHeight + vertOffset.y; diff --git a/trinity/Sprite2d/Tr2Sprite2dStretchVertical.h b/trinity/Sprite2d/Tr2Sprite2dStretchVertical.h index 59da616d3..ede464c02 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretchVertical.h +++ b/trinity/Sprite2d/Tr2Sprite2dStretchVertical.h @@ -12,14 +12,13 @@ BLUE_DECLARE( Tr2Sprite2dStretchVertical ); BLUE_DECLARE( Tr2Sprite2dTexture ); ////////////////////////////////////////////////////////////////////////// -// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the +// Tr2Sprite2dFrame implements the ITr2SpriteObject interface and is used with the // Tr2Sprite2dScene to render 2D scenes. // -// It renders a sprite by cutting a texture into three pieces and stretching the +// It renders a sprite by cutting a texture into three pieces and stretching the // center piece appropriately according to the dimensions of the sprite. ////////////////////////////////////////////////////////////////////////// -class Tr2Sprite2dStretchVertical: - public Tr2TexturedSpriteObject +class Tr2Sprite2dStretchVertical : public Tr2TexturedSpriteObject { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Sprite2d/Tr2Sprite2dStretchVertical_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dStretchVertical_Blue.cpp index 261e1bae0..08c0df97d 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretchVertical_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dStretchVertical_Blue.cpp @@ -7,24 +7,20 @@ BLUE_DEFINE( Tr2Sprite2dStretchVertical ); const Be::ClassInfo* Tr2Sprite2dStretchVertical::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dStretchVertical, "" ) - MAP_INTERFACE( Tr2Sprite2dStretchVertical ) - - MAP_ATTRIBUTE - ( - "topEdgeSize", - m_topEdgeSize, - "Number of fixed pixels on the top edge of the texture", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( - "bottomEdgeSize", - m_bottomEdgeSize, - "Number of fixed pixels on the bottom edge of the texture", - Be::READWRITE | Be::NOTIFY - ) + EXPOSURE_BEGIN( Tr2Sprite2dStretchVertical, "" ) + MAP_INTERFACE( Tr2Sprite2dStretchVertical ) + + MAP_ATTRIBUTE( + "topEdgeSize", + m_topEdgeSize, + "Number of fixed pixels on the top edge of the texture", + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( + "bottomEdgeSize", + m_bottomEdgeSize, + "Number of fixed pixels on the bottom edge of the texture", + Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "edgeScale", @@ -32,29 +28,23 @@ const Be::ClassInfo* Tr2Sprite2dStretchVertical::ExposeToBlue() "Edge size scaling when rendering the stretch; used for UI scaling", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "fillCenter", m_fillCenter, "If set, the center of the sprite is filled (this is the default).", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "saturation", m_saturation, "Saturation factor, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectOpacity", m_effectOpacity, "Effect opacity, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } diff --git a/trinity/Sprite2d/Tr2Sprite2dStretch_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dStretch_Blue.cpp index 574ee49de..061dd2ab8 100644 --- a/trinity/Sprite2d/Tr2Sprite2dStretch_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dStretch_Blue.cpp @@ -5,50 +5,39 @@ BLUE_DEFINE( Tr2Sprite2dStretch ); -Be::VarChooser Tr2Sprite2dStretchDpiScaleBehaviorChooser[] = -{ - { - "S2D_SSC_ALIGN_BOTTOMRIGHT", - BeCast( S2D_SSC_ALIGN_BOTTOMRIGHT ), - "Align to bottom/right (texture is not stretched vertically for horizontal stretch sprites" - "or horizontally for vertical stretch sprites)" - }, - { - "S2D_SSC_ALIGN_TOPLEFT", - BeCast( S2D_SSC_ALIGN_TOPLEFT ), - "Align to top/left (texture is not stretched vertically for horizontal stretch sprites" - "or horizontally for vertical stretch sprites)" - }, - { - "S2D_SSC_SCALE", - BeCast( S2D_SSC_SCALE ), - "Texture scales in both directions" - }, - { 0 } +Be::VarChooser Tr2Sprite2dStretchDpiScaleBehaviorChooser[] = { + { "S2D_SSC_ALIGN_BOTTOMRIGHT", + BeCast( S2D_SSC_ALIGN_BOTTOMRIGHT ), + "Align to bottom/right (texture is not stretched vertically for horizontal stretch sprites" + "or horizontally for vertical stretch sprites)" }, + { "S2D_SSC_ALIGN_TOPLEFT", + BeCast( S2D_SSC_ALIGN_TOPLEFT ), + "Align to top/left (texture is not stretched vertically for horizontal stretch sprites" + "or horizontally for vertical stretch sprites)" }, + { "S2D_SSC_SCALE", + BeCast( S2D_SSC_SCALE ), + "Texture scales in both directions" }, + { 0 } }; BLUE_REGISTER_ENUM( "Tr2Sprite2dStretchDpiScaleBehaviorChooser", Tr2StretchScaleBehavior, Tr2Sprite2dStretchDpiScaleBehaviorChooser ); const Be::ClassInfo* Tr2Sprite2dStretch::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dStretch, "" ) - MAP_INTERFACE( Tr2Sprite2dStretch ) + EXPOSURE_BEGIN( Tr2Sprite2dStretch, "" ) + MAP_INTERFACE( Tr2Sprite2dStretch ) - MAP_ATTRIBUTE - ( - "leftEdgeSize", - m_leftEdgeSize, - "Number of fixed pixels on the left edge of the texture", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "leftEdgeSize", + m_leftEdgeSize, + "Number of fixed pixels on the left edge of the texture", + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "rightEdgeSize", - m_rightEdgeSize, - "Number of fixed pixels on the right edge of the texture", - Be::READWRITE | Be::NOTIFY - ) + MAP_ATTRIBUTE( + "rightEdgeSize", + m_rightEdgeSize, + "Number of fixed pixels on the right edge of the texture", + Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "edgeScale", @@ -56,47 +45,37 @@ const Be::ClassInfo* Tr2Sprite2dStretch::ExposeToBlue() "Edge size scaling when rendering the stretch; used for UI scaling", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "offset", m_offset, "Offset the sprite. Positive values will make it smaller horizontally,\n" "and negative bigger. The sprite is shifted vertically by this offset.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "fillCenter", m_fillCenter, "If set, the center of the sprite is filled (this is the default).", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "saturation", m_saturation, "Saturation factor, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectOpacity", m_effectOpacity, "Effect opacity, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "dpiScaleBehavior", m_dpiScaleBehavior, "Controls how the stretch behaves with dpi scaling.", Be::READWRITE | Be::PERSIST | Be::ENUM, - Tr2Sprite2dStretchDpiScaleBehaviorChooser - ) + Tr2Sprite2dStretchDpiScaleBehaviorChooser ) EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } diff --git a/trinity/Sprite2d/Tr2Sprite2dTextObject.cpp b/trinity/Sprite2d/Tr2Sprite2dTextObject.cpp index a8c79e45e..fb5c5de05 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTextObject.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTextObject.cpp @@ -27,7 +27,7 @@ Tr2Sprite2dTextObject::~Tr2Sprite2dTextObject() void Tr2Sprite2dTextObject::GatherSprites( Tr2Sprite2dScene* renderer ) { - if( !m_display || (m_textWidth <= 0.0f) || (m_textHeight <= 0.0f) ) + if( !m_display || ( m_textWidth <= 0.0f ) || ( m_textHeight <= 0.0f ) ) { return; } @@ -56,7 +56,7 @@ void Tr2Sprite2dTextObject::GatherSprites( Tr2Sprite2dScene* renderer ) auto top = m_translation.y + std::min( m_shadowOffset.y, 0.f ); auto width = m_textWidth + abs( m_shadowOffset.x ); auto height = m_textHeight + abs( m_shadowOffset.x ); - if( (m_spriteEffect == TR2_SFX_BLUR) || (m_spriteEffect == TR2_SFX_GLOW) ) + if( ( m_spriteEffect == TR2_SFX_BLUR ) || ( m_spriteEffect == TR2_SFX_GLOW ) ) { renderer->PushClipRectangle( m_translation.x - 1 + std::min( m_shadowOffset.x, 0.f ), m_translation.y - 1 + std::min( m_shadowOffset.y, 0.f ), m_textWidth + 2 + abs( m_shadowOffset.x ), m_textHeight + 2 + abs( m_shadowOffset.y ) ); } @@ -76,14 +76,14 @@ ITr2SpriteObject* Tr2Sprite2dTextObject::PickPoint( float x, float y, Tr2Sprite2 return nullptr; } - if( m_pickState == TR2_SPS_ON || m_hasAuxiliaryTooltip) + if( m_pickState == TR2_SPS_ON || m_hasAuxiliaryTooltip ) { if( renderer->IsInside( Vector2( x, y ), m_translation, m_displayWidth, m_displayHeight, m_pickRadius ) ) { return this; } } - + return nullptr; } @@ -133,7 +133,7 @@ void Tr2Sprite2dTextObject::SetFontMeasurer( Tr2FontMeasurer* m ) bool Tr2Sprite2dTextObject::IsAuxMouseover() { // Return true if the label is not pickable and is a localization tooltip - return (m_pickState != TR2_SPS_ON && m_hasAuxiliaryTooltip); + return ( m_pickState != TR2_SPS_ON && m_hasAuxiliaryTooltip ); } diff --git a/trinity/Sprite2d/Tr2Sprite2dTextObject.h b/trinity/Sprite2d/Tr2Sprite2dTextObject.h index fb0f938a7..4e4451ac4 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTextObject.h +++ b/trinity/Sprite2d/Tr2Sprite2dTextObject.h @@ -12,10 +12,9 @@ BLUE_DECLARE( Tr2Sprite2dTextObject ); BLUE_DECLARE( Tr2FontMeasurer ); BLUE_DECLARE_INTERFACE( ITr2Sprite2dTexture ); -class Tr2Sprite2dTextObject : - public Tr2SpriteObject, - public Tr2DeviceResource, - public ITr2FontMeasurerNotifyTarget +class Tr2Sprite2dTextObject : public Tr2SpriteObject, + public Tr2DeviceResource, + public ITr2FontMeasurerNotifyTarget { public: EXPOSE_TO_BLUE(); @@ -36,6 +35,7 @@ class Tr2Sprite2dTextObject : ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); diff --git a/trinity/Sprite2d/Tr2Sprite2dTextObject_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dTextObject_Blue.cpp index d99b422fa..e55639dbd 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTextObject_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTextObject_Blue.cpp @@ -9,53 +9,42 @@ BLUE_DEFINE( Tr2Sprite2dTextObject ); const Be::ClassInfo* Tr2Sprite2dTextObject::ExposeToBlue() { EXPOSURE_BEGIN( Tr2Sprite2dTextObject, "Tr2Sprite2dTextObject is used for rendering text." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "fontMeasurer", - GetFontMeasurer, SetFontMeasurer, - "Font measurer to use for working with text" - ) + GetFontMeasurer, + SetFontMeasurer, + "Font measurer to use for working with text" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "pickRadius", m_pickRadius, "Radius to use when picking. If radius is 0 the text object is treated as" "\na rectangular area.", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE ) + + MAP_ATTRIBUTE( "texturePrimary", m_texturePrimary, "Primary texture for this sprite", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "useSizeFromTexture", m_useSizeFromTexture, "If set, displayWidth/Height are ignored and size of primary texture is used instead.", - Be::READWRITE| Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textWidth", m_textWidth, "Width of clip rectangle to put around text", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "textHeight", m_textHeight, "Height of clip rectangle to put around text", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE_WITH_CHOOSER( "shadowSpriteEffect", @@ -72,13 +61,11 @@ const Be::ClassInfo* Tr2Sprite2dTextObject::ExposeToBlue() ":jessica-group: Shadow", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "hasAuxiliaryTooltip", m_hasAuxiliaryTooltip, "Denotes that this label has auxiliary tooltips that should be passed back to the client when picking.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_CHAINTO( Tr2SpriteObject ); } \ No newline at end of file diff --git a/trinity/Sprite2d/Tr2Sprite2dTexture.cpp b/trinity/Sprite2d/Tr2Sprite2dTexture.cpp index 10d017fd0..89f2e5283 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTexture.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTexture.cpp @@ -70,12 +70,12 @@ void Tr2Sprite2dTexture::SetResPath( const std::string& path ) m_atlasTexture.Unlock(); BeResMan->GetResource( m_resPath.c_str(), "atlas", m_atlasTexture ); - + if( m_atlasTexture ) { m_atlasTexture->RegisterForChangeNotification( this ); } - + SetDirty(); } @@ -207,17 +207,17 @@ void Tr2Sprite2dTexture::SetSrcHeight( float srcHeight ) void Tr2Sprite2dTexture::CheckTextureWindow() { - if( (m_srcX == 0.0f) && (m_srcY == 0.0f) && (m_srcWidth == 0.0f) && (m_srcHeight == 0.0f) ) + if( ( m_srcX == 0.0f ) && ( m_srcY == 0.0f ) && ( m_srcWidth == 0.0f ) && ( m_srcHeight == 0.0f ) ) { m_hasTextureWindow = false; return; } if( m_atlasTexture && - (m_srcX == 0.0f) && - (m_srcY == 0.0f) && - (m_srcWidth == m_atlasTexture->GetWidth()) && - (m_srcHeight == m_atlasTexture->GetHeight() ) ) + ( m_srcX == 0.0f ) && + ( m_srcY == 0.0f ) && + ( m_srcWidth == m_atlasTexture->GetWidth() ) && + ( m_srcHeight == m_atlasTexture->GetHeight() ) ) { m_hasTextureWindow = false; return; @@ -228,14 +228,14 @@ void Tr2Sprite2dTexture::CheckTextureWindow() int Tr2Sprite2dTexture::GetTextureRepeatMode() const { - int repeatMode = m_settings & (S2D_TS_REPEAT_MIRROR | S2D_TS_REPEAT_CLAMP); + int repeatMode = m_settings & ( S2D_TS_REPEAT_MIRROR | S2D_TS_REPEAT_CLAMP ); return repeatMode >> 1; } void Tr2Sprite2dTexture::SetTextureRepeatMode( int repeatMode ) { - int rest = m_settings & ~(S2D_TS_REPEAT_MIRROR | S2D_TS_REPEAT_CLAMP); - m_settings = (Tr2Sprite2dTextureSettings)(rest | repeatMode); + int rest = m_settings & ~( S2D_TS_REPEAT_MIRROR | S2D_TS_REPEAT_CLAMP ); + m_settings = (Tr2Sprite2dTextureSettings)( rest | repeatMode ); SetDirty(); } @@ -300,7 +300,7 @@ void Tr2Sprite2dTexture::SetDirty() { for( auto it = m_changeListeners.begin(); it != m_changeListeners.end(); ++it ) { - (*it)->Sprite2dTextureChanged( this ); + ( *it )->Sprite2dTextureChanged( this ); } } @@ -308,4 +308,3 @@ void Tr2Sprite2dTexture::AtlasTextureChanged( Tr2AtlasTexture* p ) { SetDirty(); } - diff --git a/trinity/Sprite2d/Tr2Sprite2dTexture.h b/trinity/Sprite2d/Tr2Sprite2dTexture.h index 978b13b16..6b913796a 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTexture.h +++ b/trinity/Sprite2d/Tr2Sprite2dTexture.h @@ -14,11 +14,10 @@ BLUE_DECLARE( Tr2AtlasTexture ); // The Tr2Sprite2dTexture wraps an atlas texture resource. It holds // the resource path name and settings such as rectangle to use from // the texture, filter and dot product flags. -class Tr2Sprite2dTexture: - public ITr2Sprite2dTexture, - public IInitialize, - public INotify, - public ITr2AtlasTextureNotifyTarget +class Tr2Sprite2dTexture : public ITr2Sprite2dTexture, + public IInitialize, + public INotify, + public ITr2AtlasTextureNotifyTarget { public: EXPOSE_TO_BLUE(); @@ -59,7 +58,7 @@ class Tr2Sprite2dTexture: void SetSrcHeight( float srcHeight ); Matrix* GetTransform(); - + int GetTextureRepeatMode() const; void SetTextureRepeatMode( int repeatMode ); diff --git a/trinity/Sprite2d/Tr2Sprite2dTexture_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dTexture_Blue.cpp index 21f30baa5..064927c0f 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTexture_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTexture_Blue.cpp @@ -9,139 +9,111 @@ BLUE_DEFINE( Tr2Sprite2dTexture ); const Be::ClassInfo* Tr2Sprite2dTexture::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dTexture, "" ) - MAP_INTERFACE( ITr2Sprite2dTexture ) + EXPOSURE_BEGIN( Tr2Sprite2dTexture, "" ) + MAP_INTERFACE( ITr2Sprite2dTexture ) MAP_INTERFACE( Tr2Sprite2dTexture ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this texture object", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this texture object", + Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "resPath", GetResPath, SetResPath, - "Resource path for texture" - ) - - MAP_PROPERTY - ( - "srcX", - GetSrcX, SetSrcX, - "X-coordinate of top-left of source rectangle for this texture" - ) - - MAP_PROPERTY - ( - "srcY", - GetSrcY, SetSrcY, - "Y-coordinate of top-left of source rectangle for this texture" - ) - MAP_PROPERTY - ( - "srcWidth", - GetSrcWidth, SetSrcWidth, - "Width of source rectangle for this texture" - ) - - MAP_PROPERTY - ( - "srcHeight", - GetSrcHeight, SetSrcHeight, - "Height of source rectangle for this texture" - ) - - MAP_PROPERTY - ( + "Resource path for texture" ) + + MAP_PROPERTY( + "srcX", + GetSrcX, + SetSrcX, + "X-coordinate of top-left of source rectangle for this texture" ) + + MAP_PROPERTY( + "srcY", + GetSrcY, + SetSrcY, + "Y-coordinate of top-left of source rectangle for this texture" ) + MAP_PROPERTY( + "srcWidth", + GetSrcWidth, + SetSrcWidth, + "Width of source rectangle for this texture" ) + + MAP_PROPERTY( + "srcHeight", + GetSrcHeight, + SetSrcHeight, + "Height of source rectangle for this texture" ) + + MAP_PROPERTY( "tileX", - GetTileX, SetTileX, - "If set, the texture is tiled along the x-axis rather than stretching" - ) + GetTileX, + SetTileX, + "If set, the texture is tiled along the x-axis rather than stretching" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "tileY", - GetTileY, SetTileY, - "If set, the texture is tiled along the y-axis rather than stretching" - ) + GetTileY, + SetTileY, + "If set, the texture is tiled along the y-axis rather than stretching" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "repeatMode", - GetTextureRepeatMode, SetTextureRepeatMode, + GetTextureRepeatMode, + SetTextureRepeatMode, "0 - default, tiled\n" "1 - mirrored\n" - "2 - clamp" - ) + "2 - clamp" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "atlasTexture", GetAtlasTexture, SetAtlasTexture, - "Atlas texture held by this texture object" - ) + "Atlas texture held by this texture object" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "useTransform", m_useTransform, "If set, the texture is transformed by the translation, rotation and scaling values.\n" "Otherwise no transformation takes place.", - Be::READWRITE | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + + MAP_ATTRIBUTE( "translation", m_translation, "Translation applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "rotationCenter", m_rotationCenter, "Center point for rotation applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "rotation", m_rotation, "Rotation applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "scalingCenter", m_scalingCenter, "Center point for scale applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "scalingRotation", m_scalingRotation, "Scaling rotation factor for scale applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "scale", m_scale, "Scale applied to texture coordinates", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_END() } - diff --git a/trinity/Sprite2d/Tr2Sprite2dTransform.cpp b/trinity/Sprite2d/Tr2Sprite2dTransform.cpp index 024f9fe65..cce612eef 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTransform.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTransform.cpp @@ -30,11 +30,11 @@ void Tr2Sprite2dTransform::GatherSprites( Tr2Sprite2dScene* renderer ) for( ITr2SpriteObjectVector::reverse_iterator it = m_background.rbegin(); it != m_background.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } for( ITr2SpriteObjectVector::reverse_iterator it = m_children.rbegin(); it != m_children.rend(); ++it ) { - (*it)->GatherSprites( renderer ); + ( *it )->GatherSprites( renderer ); } renderer->SetAccumulatedAlpha( oldOpacity ); @@ -64,13 +64,13 @@ ITr2SpriteObject* Tr2Sprite2dTransform::PickPoint( float x, float y, Tr2Sprite2d { return NULL; } - + ITr2SpriteObject* obj = NULL; renderer->PushTransform( GetTransformationMatrix() ); for( ITr2SpriteObjectVector::iterator it = m_children.begin(); it != m_children.end(); ++it ) { - obj = (*it)->PickPoint( x, y, renderer ); + obj = ( *it )->PickPoint( x, y, renderer ); if( obj ) { break; @@ -81,13 +81,13 @@ ITr2SpriteObject* Tr2Sprite2dTransform::PickPoint( float x, float y, Tr2Sprite2d if( m_pickState == TR2_SPS_ON ) { this->m_auxMouseover = NULL; - if ( !obj ) + if( !obj ) { obj = this; } else { - if ( obj->IsAuxMouseover() ) + if( obj->IsAuxMouseover() ) { // The auxiliary mouseover can add content to the mouseover text or context menu this->m_auxMouseover = obj; @@ -110,7 +110,7 @@ Matrix Tr2Sprite2dTransform::GetTransformationMatrix() return m; } -Vector2 Tr2Sprite2dTransform::TransformPoint(float x, float y) +Vector2 Tr2Sprite2dTransform::TransformPoint( float x, float y ) { Matrix m; // Rounding the results here helps with ensuring pixel perfect sprites with 90 degree rotations @@ -118,7 +118,7 @@ Vector2 Tr2Sprite2dTransform::TransformPoint(float x, float y) Vector2 absRotationCenter( floor( m_rotationCenter.x * m_displayWidth + 0.5f ), floor( m_rotationCenter.y * m_displayHeight + 0.5f ) ); m = Transformation2DMatrix( &absScalingCenter, m_scalingRotation, &m_scale, &absRotationCenter, m_rotation, NULL ); - Vector2 vec = Vector2(x, y); + Vector2 vec = Vector2( x, y ); Vector4 ret = Transform( vec, m ); - return Vector2(ret.x, ret.y); + return Vector2( ret.x, ret.y ); } diff --git a/trinity/Sprite2d/Tr2Sprite2dTransform.h b/trinity/Sprite2d/Tr2Sprite2dTransform.h index 635d55335..68f2d52b8 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTransform.h +++ b/trinity/Sprite2d/Tr2Sprite2dTransform.h @@ -11,19 +11,18 @@ BLUE_DECLARE( Tr2Sprite2dTransform ); BLUE_DECLARE_IVECTOR( ITr2SpriteObject ); -class Tr2Sprite2dTransform: - public Tr2Sprite2dContainerBase +class Tr2Sprite2dTransform : public Tr2Sprite2dContainerBase { public: - EXPOSE_TO_BLUE(); - Tr2Sprite2dTransform( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Sprite2dTransform( IRoot* lockobj = NULL ); ////////////////////////////////////////////////////////////////////////// // ITr2SpriteObject void GatherSprites( Tr2Sprite2dScene* renderer ); ITr2SpriteObject* PickPoint( float x, float y, Tr2Sprite2dScene* renderer ); - Vector2 TransformPoint(float x, float y); + Vector2 TransformPoint( float x, float y ); private: // Center of rotation as relative coordinates - (0,0) is top-left, (0.5,0.5) is diff --git a/trinity/Sprite2d/Tr2Sprite2dTransform_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2dTransform_Blue.cpp index 6a4b4d33d..95762bb4b 100644 --- a/trinity/Sprite2d/Tr2Sprite2dTransform_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2dTransform_Blue.cpp @@ -10,56 +10,44 @@ extern Be::VarChooser Tr2SpriteObjectPickStateChooser[]; const Be::ClassInfo* Tr2Sprite2dTransform::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2dTransform, "" ) + EXPOSURE_BEGIN( Tr2Sprite2dTransform, "" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "rotationCenter", m_rotationCenter, "Center point for rotation applied to children of this transform", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "rotation", m_rotation, "Rotation applied to children of this transform", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "scalingCenter", m_scalingCenter, "Center point for scale applied to children of this transform", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "scalingRotation", m_scalingRotation, "Scaling rotation factor for scale applied to children of this transform", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "scale", m_scale, "Scale applied to children of this transform", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "TransformPoint", TransformPoint, "Get transformed result of point x, y\n" ":param x: horizontal coordinate\n" - ":param y: vertical coordinate\n" - ) + ":param y: vertical coordinate\n" ) EXPOSURE_CHAINTO( Tr2Sprite2dContainerBase ) } diff --git a/trinity/Sprite2d/Tr2Sprite2d_Blue.cpp b/trinity/Sprite2d/Tr2Sprite2d_Blue.cpp index 5c22a17b7..9a050a707 100644 --- a/trinity/Sprite2d/Tr2Sprite2d_Blue.cpp +++ b/trinity/Sprite2d/Tr2Sprite2d_Blue.cpp @@ -8,44 +8,33 @@ BLUE_DEFINE( Tr2Sprite2d ); const Be::ClassInfo* Tr2Sprite2d::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Sprite2d, "" ) - MAP_INTERFACE( Tr2Sprite2d ) + EXPOSURE_BEGIN( Tr2Sprite2d, "" ) + MAP_INTERFACE( Tr2Sprite2d ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "pickRadius", m_pickRadius, "Radius to use when picking. If radius is 0 the sprite is treated as" "\na rectangular area.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "useSizeFromTexture", m_useSizeFromTexture, "If set, displayWidth/Height are ignored and size of primary texture is used instead.", - Be::READWRITE| Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "saturation", m_saturation, "Saturation factor, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "effectOpacity", m_effectOpacity, "Effect opacity, used when TR2_SFX_COLOROVERLAY or TR2_SFX_SOFTLIGHT is used.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2TexturedSpriteObject ) } - - - diff --git a/trinity/Sprite2d/Tr2SpriteObject.cpp b/trinity/Sprite2d/Tr2SpriteObject.cpp index f80587156..247d4ed49 100644 --- a/trinity/Sprite2d/Tr2SpriteObject.cpp +++ b/trinity/Sprite2d/Tr2SpriteObject.cpp @@ -5,7 +5,7 @@ #include "Tr2Sprite2dScene.h" -Tr2SpriteObjectBase::Tr2SpriteObjectBase() : +Tr2SpriteObjectBase::Tr2SpriteObjectBase() : m_isDirty( true ), m_parent( nullptr ), m_auxMouseover( nullptr ), @@ -15,7 +15,8 @@ Tr2SpriteObjectBase::Tr2SpriteObjectBase() : m_display( true ), m_pickState( TR2_SPS_ON ) #if BLUE_WITH_PYTHON - , m_associatedObject( nullptr ) + , + m_associatedObject( nullptr ) #endif { } @@ -227,7 +228,6 @@ void Tr2SpriteObject::SetColor( Color val ) Tr2TexturedSpriteObject::Tr2TexturedSpriteObject( IRoot* lockobj /*= NULL */ ) { - } Tr2TexturedSpriteObject::~Tr2TexturedSpriteObject() @@ -302,7 +302,7 @@ bool Tr2TexturedSpriteObject::ValidateAndSetTextures( Tr2Sprite2dScene* renderer // Don't draw if we're still loading (or failed) return false; } - m_texturePrimary->Apply( renderer, 0 ); + m_texturePrimary->Apply( renderer, 0 ); } else { @@ -310,7 +310,7 @@ bool Tr2TexturedSpriteObject::ValidateAndSetTextures( Tr2Sprite2dScene* renderer return false; } - if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) + if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) { if( m_textureSecondary ) { @@ -319,7 +319,7 @@ bool Tr2TexturedSpriteObject::ValidateAndSetTextures( Tr2Sprite2dScene* renderer // Don't draw if we're still loading (or failed) return false; } - m_textureSecondary->Apply( renderer, 1 ); + m_textureSecondary->Apply( renderer, 1 ); } else { @@ -339,12 +339,11 @@ void Tr2TexturedSpriteObject::SetValidatedTextures( Tr2Sprite2dScene* renderer ) // we would have been flagged dirty so the check is always done there. if( m_spriteEffect >= TR2_SFX_ONE_TEXTURE ) { - m_texturePrimary->Apply( renderer, 0 ); + m_texturePrimary->Apply( renderer, 0 ); - if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) + if( m_spriteEffect >= TR2_SFX_TWO_TEXTURES ) { - m_textureSecondary->Apply( renderer, 1 ); + m_textureSecondary->Apply( renderer, 1 ); } } } - diff --git a/trinity/Sprite2d/Tr2SpriteObject.h b/trinity/Sprite2d/Tr2SpriteObject.h index 40292207d..de8957add 100644 --- a/trinity/Sprite2d/Tr2SpriteObject.h +++ b/trinity/Sprite2d/Tr2SpriteObject.h @@ -20,9 +20,8 @@ extern Be::VarChooser Tr2SpriteObjectEffectChooser[]; extern Be::VarChooser Tr2SpriteObjectBlendModeChooser[]; extern Be::VarChooser Tr2SpriteTargetChooser[]; -class Tr2SpriteObjectBase : - public ITr2SpriteObject, - public INotify +class Tr2SpriteObjectBase : public ITr2SpriteObject, + public INotify { public: EXPOSE_TO_BLUE(); @@ -31,7 +30,7 @@ class Tr2SpriteObjectBase : ~Tr2SpriteObjectBase(); bool GetDisplay() const; - void SetDisplay ( bool val ); + void SetDisplay( bool val ); float GetDisplayX() const; void SetDisplayX( float val ); @@ -81,11 +80,9 @@ class Tr2SpriteObjectBase : #if BLUE_WITH_PYTHON PyObject* m_associatedObject; #endif - }; -class Tr2SpriteObject : - public Tr2SpriteObjectBase +class Tr2SpriteObject : public Tr2SpriteObjectBase { public: EXPOSE_TO_BLUE(); @@ -120,9 +117,8 @@ class Tr2SpriteObject : TYPEDEF_BLUECLASS( Tr2SpriteObject ); -class Tr2TexturedSpriteObject : - public Tr2SpriteObject, - public ITr2Sprite2dTextureNotifyTarget +class Tr2TexturedSpriteObject : public Tr2SpriteObject, + public ITr2Sprite2dTextureNotifyTarget { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Sprite2d/Tr2SpriteObject_Blue.cpp b/trinity/Sprite2d/Tr2SpriteObject_Blue.cpp index c1cb963c0..8c8257f71 100644 --- a/trinity/Sprite2d/Tr2SpriteObject_Blue.cpp +++ b/trinity/Sprite2d/Tr2SpriteObject_Blue.cpp @@ -7,20 +7,18 @@ BLUE_DEFINE_ABSTRACT( Tr2SpriteObjectBase ); BLUE_DEFINE_ABSTRACT( Tr2SpriteObject ); BLUE_DEFINE_ABSTRACT( Tr2TexturedSpriteObject ); -Be::VarChooser Tr2SpriteObjectPickStateChooser[] = -{ - { "TR2_SPS_OFF", BeCast( TR2_SPS_OFF ), "Picking is disabled" }, - { "TR2_SPS_ON", BeCast( TR2_SPS_ON ), "Picking is enabled" }, - { "TR2_SPS_CHILDREN", BeCast( TR2_SPS_CHILDREN ), "Only children are pickable" }, +Be::VarChooser Tr2SpriteObjectPickStateChooser[] = { + { "TR2_SPS_OFF", BeCast( TR2_SPS_OFF ), "Picking is disabled" }, + { "TR2_SPS_ON", BeCast( TR2_SPS_ON ), "Picking is enabled" }, + { "TR2_SPS_CHILDREN", BeCast( TR2_SPS_CHILDREN ), "Only children are pickable" }, { 0 } }; -Be::VarChooser Tr2SpriteObjectBlendModeChooser[] = -{ - { "TR2_SBM_NONE", BeCast( TR2_SBM_NONE ), "No blending" }, - { "TR2_SBM_BLEND", BeCast( TR2_SBM_BLEND ), "Regular alpha blending" }, - { "TR2_SBM_ADD", BeCast( TR2_SBM_ADD ), "Additive blending" }, - { "TR2_SBM_ADDX2", BeCast( TR2_SBM_ADDX2 ), "Additive blending, x2 brightness" }, +Be::VarChooser Tr2SpriteObjectBlendModeChooser[] = { + { "TR2_SBM_NONE", BeCast( TR2_SBM_NONE ), "No blending" }, + { "TR2_SBM_BLEND", BeCast( TR2_SBM_BLEND ), "Regular alpha blending" }, + { "TR2_SBM_ADD", BeCast( TR2_SBM_ADD ), "Additive blending" }, + { "TR2_SBM_ADDX2", BeCast( TR2_SBM_ADDX2 ), "Additive blending, x2 brightness" }, { 0 } }; @@ -31,26 +29,25 @@ Be::VarChooser Tr2SpriteTargetChooser[] = { { 0 } }; -Be::VarChooser Tr2SpriteObjectEffectChooser[] = -{ - { "TR2_SFX_FILL", BeCast( TR2_SFX_FILL ), "No texture - simple fill" }, - { "TR2_SFX_FILL_AA", BeCast( TR2_SFX_FILL_AA ), "No texture - simple fill, with anti-aliasing" }, - { "TR2_SFX_COPY", BeCast( TR2_SFX_COPY ), "Primary texture copied" }, - { "TR2_SFX_FONT", BeCast( TR2_SFX_FONT ), "Font rendered by FreeType" }, - { "TR2_SFX_DOT", BeCast( TR2_SFX_DOT ), "Dot product of primary texture and direction vector" }, - { "TR2_SFX_DROPSHADOW", BeCast( TR2_SFX_DROPSHADOW ), "Primary texture copied, plus a drop shadow" }, - { "TR2_SFX_OUTLINE", BeCast( TR2_SFX_OUTLINE ), "Primary texture copied, plus an outline" }, - { "TR2_SFX_MODULATE", BeCast( TR2_SFX_MODULATE ), "Primary and secondary textures modulated (multiplied)" }, - { "TR2_SFX_MASK", BeCast( TR2_SFX_MASK ), "Alpha channel of secondary used as mask for primary" }, - { "TR2_SFX_NOALPHA", BeCast( TR2_SFX_NOALPHA ), "Primary texture copied, alpha forced to 1.0" }, - { "TR2_SFX_COLOROVERLAY", BeCast( TR2_SFX_COLOROVERLAY ), "Primary texture colorized with an overlay effect" }, - { "TR2_SFX_SOFTLIGHT", BeCast( TR2_SFX_SOFTLIGHT ), "Primary texture colorized with a softlight effect" }, - { "TR2_SFX_BLUR", BeCast( TR2_SFX_BLUR ), "Primary texture is blurred" }, - { "TR2_SFX_BLURBACKGROUNDCOLORED", BeCast( TR2_SFX_BLURBACKGROUNDCOLORED ), "Primary texture is blurred, uvs are calculated from screen coords" }, - { "TR2_SFX_BLURBACKGROUND", BeCast( TR2_SFX_BLURBACKGROUND ), "Primary texture is blurred, uvs are calculated from screen coords" }, - { "TR2_SFX_GLOW", BeCast( TR2_SFX_GLOW ), "Primary texture is blurred, used for glow effects" }, - - { "TR2_SFX_NONE", BeCast( TR2_SFX_NONE ), "Nothing is rendered" }, +Be::VarChooser Tr2SpriteObjectEffectChooser[] = { + { "TR2_SFX_FILL", BeCast( TR2_SFX_FILL ), "No texture - simple fill" }, + { "TR2_SFX_FILL_AA", BeCast( TR2_SFX_FILL_AA ), "No texture - simple fill, with anti-aliasing" }, + { "TR2_SFX_COPY", BeCast( TR2_SFX_COPY ), "Primary texture copied" }, + { "TR2_SFX_FONT", BeCast( TR2_SFX_FONT ), "Font rendered by FreeType" }, + { "TR2_SFX_DOT", BeCast( TR2_SFX_DOT ), "Dot product of primary texture and direction vector" }, + { "TR2_SFX_DROPSHADOW", BeCast( TR2_SFX_DROPSHADOW ), "Primary texture copied, plus a drop shadow" }, + { "TR2_SFX_OUTLINE", BeCast( TR2_SFX_OUTLINE ), "Primary texture copied, plus an outline" }, + { "TR2_SFX_MODULATE", BeCast( TR2_SFX_MODULATE ), "Primary and secondary textures modulated (multiplied)" }, + { "TR2_SFX_MASK", BeCast( TR2_SFX_MASK ), "Alpha channel of secondary used as mask for primary" }, + { "TR2_SFX_NOALPHA", BeCast( TR2_SFX_NOALPHA ), "Primary texture copied, alpha forced to 1.0" }, + { "TR2_SFX_COLOROVERLAY", BeCast( TR2_SFX_COLOROVERLAY ), "Primary texture colorized with an overlay effect" }, + { "TR2_SFX_SOFTLIGHT", BeCast( TR2_SFX_SOFTLIGHT ), "Primary texture colorized with a softlight effect" }, + { "TR2_SFX_BLUR", BeCast( TR2_SFX_BLUR ), "Primary texture is blurred" }, + { "TR2_SFX_BLURBACKGROUNDCOLORED", BeCast( TR2_SFX_BLURBACKGROUNDCOLORED ), "Primary texture is blurred, uvs are calculated from screen coords" }, + { "TR2_SFX_BLURBACKGROUND", BeCast( TR2_SFX_BLURBACKGROUND ), "Primary texture is blurred, uvs are calculated from screen coords" }, + { "TR2_SFX_GLOW", BeCast( TR2_SFX_GLOW ), "Primary texture is blurred, used for glow effects" }, + + { "TR2_SFX_NONE", BeCast( TR2_SFX_NONE ), "Nothing is rendered" }, { 0 } }; @@ -65,99 +62,78 @@ const Be::ClassInfo* Tr2SpriteObjectBase::ExposeToBlue() MAP_INTERFACE( ITr2SpriteObject ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this sprite", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "auxMouseover", - m_auxMouseover, - "The auxiliary mouseover object", - Be::READ - ) - - MAP_PROPERTY - ( + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this sprite", + Be::READWRITE ) + + MAP_ATTRIBUTE( + "auxMouseover", + m_auxMouseover, + "The auxiliary mouseover object", + Be::READ ) + + MAP_PROPERTY( "display", - GetDisplay, SetDisplay, - "If true, object is displayed. If false, the object is not displayed." - ) + GetDisplay, + SetDisplay, + "If true, object is displayed. If false, the object is not displayed." ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "isDirty", m_isDirty, "Has something changed since last render?", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( - "displayX", + MAP_ATTRIBUTE( + "displayX", m_translation.x, "X-coordinate of this sprite", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "displayY", + MAP_ATTRIBUTE( + "displayY", m_translation.y, "Y-coordinate of this sprite", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "displayWidth", + MAP_ATTRIBUTE( + "displayWidth", m_displayWidth, "Width of this sprite", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( - "displayHeight", + MAP_ATTRIBUTE( + "displayHeight", m_displayHeight, "Height of this sprite", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "pickState", m_pickState, "This state controls how the object responds to picking", Be::READWRITE | Be::PERSIST | Be::ENUM, - Tr2SpriteObjectPickStateChooser - ) + Tr2SpriteObjectPickStateChooser ) MAP_ATTRIBUTE( "pickingMask", m_pickingMask, "Mouse picking mask", - Be::READWRITE - ) + Be::READWRITE ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetDirty", SetDirty, - "Marks this object as dirty and informs its parent" - ) + "Marks this object as dirty and informs its parent" ) #if BLUE_WITH_PYTHON - MAP_PROPERTY - ( + MAP_PROPERTY( "associatedObject", - GetAssociatedObject, SetAssociatedObject, - "Weak reference to a Python object associated with this sprite object." - ) + GetAssociatedObject, + SetAssociatedObject, + "Weak reference to a Python object associated with this sprite object." ) #endif EXPOSURE_END() @@ -167,14 +143,12 @@ const Be::ClassInfo* Tr2SpriteObject::ExposeToBlue() { EXPOSURE_BEGIN( Tr2SpriteObject, "" ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "blendMode", m_blendMode, "Blendmode controls how the object blends with the background", Be::READWRITE | Be::ENUM | Be::NOTIFY, - Tr2SpriteObjectBlendModeChooser - ) + Tr2SpriteObjectBlendModeChooser ) MAP_ATTRIBUTE_WITH_CHOOSER( "spriteTarget", @@ -187,96 +161,75 @@ const Be::ClassInfo* Tr2SpriteObject::ExposeToBlue() "glowBrightness", m_glowBrightness, "Full-screen glow effect brightness factor for this sprite object. See spriteTarget.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "spriteEffect", m_spriteEffect, "Sprite effect controls how textures are used to render the object", Be::READWRITE | Be::ENUM | Be::NOTIFY, - Tr2SpriteObjectEffectChooser - ) + Tr2SpriteObjectEffectChooser ) - MAP_ATTRIBUTE - ( - "color", + MAP_ATTRIBUTE( + "color", m_color, "Color of the sprite object", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "depth", m_depth, "Depth value to use when rendered in 3d - relative to parent.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "shadowOffset", m_shadowOffset, "Optional shadow offset. If this is non-zero, a second copy of this\n" "object is rendered with 'shadowColor' before the regular rendering.\n\n" ":jessica-group: Shadow", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "shadowColor", m_shadowColor, "Shadow color - see 'shadowOffset'\n" ":jessica-group: Shadow", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "glowFactor", m_glowFactor, "Optional glow factor - if this is non-zero, a second copy of this\n" "object is rendered, blurred with glowFactor, after the regular rendering.\n" "'glowExpand' determines if this copy is expanded as well.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "glowExpand", m_glowExpand, "If non-zero, a second copy of this object is rendered after the regular\n" "rendering, expanded by this factor. 'glowFactor' determines if this copy\n" "is blurred as well.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "glowColor", m_glowColor, "Glow color - see 'shadowOffset'", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "outlineColor", m_outlineColor, "Outline color", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "outlineThreshold", m_outlineThreshold, "Outline threshold - how high of a alpha tolerance the outline checks for (alpha - threshold > epsilon)", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) EXPOSURE_CHAINTO( Tr2SpriteObjectBase ) } @@ -284,19 +237,17 @@ const Be::ClassInfo* Tr2SpriteObject::ExposeToBlue() const Be::ClassInfo* Tr2TexturedSpriteObject::ExposeToBlue() { EXPOSURE_BEGIN( Tr2TexturedSpriteObject, "" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "texturePrimary", - GetTexturePrimary, SetTexturePrimary, - "Primary texture for this sprite" - ) + GetTexturePrimary, + SetTexturePrimary, + "Primary texture for this sprite" ) - MAP_PROPERTY - ( + MAP_PROPERTY( "textureSecondary", - GetTextureSecondary, SetTextureSecondary, - "Secondary texture for this sprite" - ) + GetTextureSecondary, + SetTextureSecondary, + "Secondary texture for this sprite" ) EXPOSURE_CHAINTO( Tr2SpriteObject ) } diff --git a/trinity/StdAfx.cpp b/trinity/StdAfx.cpp index 21f78375f..1ea5ab194 100644 --- a/trinity/StdAfx.cpp +++ b/trinity/StdAfx.cpp @@ -12,12 +12,12 @@ #include _STD_BEGIN -_CRTIMP2 _Prhand _Raise_handler = 0; // define raise handler pointer as null +_CRTIMP2 _Prhand _Raise_handler = 0; // define raise handler pointer as null -_CRTIMP2 void __cdecl _Throw(const exception& ex) - { // report error and die - CCP_ASSERT(0); - } +_CRTIMP2 void __cdecl _Throw( const exception& ex ) +{ // report error and die + CCP_ASSERT( 0 ); +} _STD_END #endif #endif diff --git a/trinity/StdAfx.h b/trinity/StdAfx.h index 612f13deb..d3e5d32f7 100644 --- a/trinity/StdAfx.h +++ b/trinity/StdAfx.h @@ -21,9 +21,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #ifndef NOMINMAX - #define NOMINMAX //don't want that evil microsoft macro +#define NOMINMAX //don't want that evil microsoft macro #endif -#include +#include // for CComPtr support #include @@ -66,7 +66,7 @@ using std::max; // here we define the directInput version we are going to use // If this is not defined here manually there is a build warning -// which is very weird the dinput.h file should really define +// which is very weird the dinput.h file should really define // this, as is done in D3D but I guess we'll just have to do it #define DIRECTINPUT_VERSION 0x0800 @@ -112,7 +112,7 @@ using std::max; #endif -#if (_MSC_VER >= 1400 || _DLL) +#if ( _MSC_VER >= 1400 || _DLL ) #ifdef _HAS_EXCEPTIONS #undef _HAS_EXCEPTIONS #endif @@ -120,7 +120,7 @@ using std::max; #endif #ifndef EVALUATION_SDKS_ENABLED - #define EVALUATION_SDKS_ENABLED 1 +#define EVALUATION_SDKS_ENABLED 1 #endif #if WITH_GRANNY @@ -130,12 +130,12 @@ using std::max; #endif #ifndef _WIN32 - #ifndef TRUE - #define TRUE 1 - #endif - #ifndef FALSE - #define FALSE 0 - #endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif #endif diff --git a/trinity/TbbStub.h b/trinity/TbbStub.h index 24c3cc735..918c6446b 100644 --- a/trinity/TbbStub.h +++ b/trinity/TbbStub.h @@ -32,8 +32,8 @@ struct Tr2SpinMutex template struct Tr2BlockedRange { - Tr2BlockedRange( T begin, T end, T step = 1 ) - :m_begin( begin ), + Tr2BlockedRange( T begin, T end, T step = 1 ) : + m_begin( begin ), m_end( end ), m_step( step ) { @@ -67,8 +67,8 @@ template class Tr2EnumerableThreadSpecific { public: - Tr2EnumerableThreadSpecific() - :m_data() + Tr2EnumerableThreadSpecific() : + m_data() { } @@ -86,6 +86,7 @@ class Tr2EnumerableThreadSpecific { return ( &m_data ) + 1; } + private: T m_data; }; diff --git a/trinity/Tr2AddSafeGrowableBuffer.h b/trinity/Tr2AddSafeGrowableBuffer.h index b0cf38ebb..8dfdfe85c 100644 --- a/trinity/Tr2AddSafeGrowableBuffer.h +++ b/trinity/Tr2AddSafeGrowableBuffer.h @@ -8,11 +8,11 @@ // -------------------------------------------------------------------------------------- // Description: -// Helper class to store a growable array of objects. A super-limited version of +// Helper class to store a growable array of objects. A super-limited version of // std::vector, but it allows appending new objects in parallel. All other operations // are not thread safe. // -------------------------------------------------------------------------------------- -template +template class Tr2AddSafeGrowableBuffer { public: @@ -29,6 +29,7 @@ class Tr2AddSafeGrowableBuffer T* begin(); const T* end() const; T* end(); + private: CcpMallocBuffer m_data; Tr2SpinMutex m_mutex; @@ -63,22 +64,21 @@ T* end( Tr2AddSafeGrowableBuffer& buffer ) - -template -Tr2AddSafeGrowableBuffer::Tr2AddSafeGrowableBuffer( uint32_t initialCount, const char* allocationName ) - :m_capacity( initialCount ), +template +Tr2AddSafeGrowableBuffer::Tr2AddSafeGrowableBuffer( uint32_t initialCount, const char* allocationName ) : + m_capacity( initialCount ), m_count( 0 ) { m_data.resize( allocationName, m_capacity * sizeof( T ) ); } -template +template void Tr2AddSafeGrowableBuffer::Clear() { m_count = 0; } -template +template bool Tr2AddSafeGrowableBuffer::Add( const T& element, const char* allocationName ) { Tr2SpinMutex::scoped_lock lock( m_mutex ); @@ -98,56 +98,56 @@ bool Tr2AddSafeGrowableBuffer::Add( const T& element, const char* allocationN return true; } -template +template uint32_t Tr2AddSafeGrowableBuffer::GetCount() const { return m_count; } -template +template const T* Tr2AddSafeGrowableBuffer::GetData() const { return reinterpret_cast( m_data.get() ); } -template +template T* Tr2AddSafeGrowableBuffer::GetData() { return reinterpret_cast( m_data.get() ); } -template +template const T& Tr2AddSafeGrowableBuffer::operator[]( size_t index ) const { return this->GetData()[index]; } -template +template T& Tr2AddSafeGrowableBuffer::operator[]( size_t index ) { return this->GetData()[index]; } -template +template const T* Tr2AddSafeGrowableBuffer::begin() const { return this->GetData(); } -template +template T* Tr2AddSafeGrowableBuffer::begin() { return this->GetData(); } -template +template const T* Tr2AddSafeGrowableBuffer::end() const { // cppcheck-suppress arithOperationsOnVoidPointer return this->GetData() + this->GetCount(); } -template +template T* Tr2AddSafeGrowableBuffer::end() { // cppcheck-suppress arithOperationsOnVoidPointer diff --git a/trinity/Tr2AtlasTexture.cpp b/trinity/Tr2AtlasTexture.cpp index a674d3cf5..f74ce9a6d 100644 --- a/trinity/Tr2AtlasTexture.cpp +++ b/trinity/Tr2AtlasTexture.cpp @@ -11,7 +11,7 @@ using namespace Tr2RenderContextEnum; -Tr2AtlasTexture::Tr2AtlasTexture( IRoot* lockobj ) : +Tr2AtlasTexture::Tr2AtlasTexture( IRoot* lockobj ) : m_x( 0 ), m_y( 0 ), m_width( 0 ), @@ -28,7 +28,7 @@ Tr2AtlasTexture::Tr2AtlasTexture( IRoot* lockobj ) : m_renderTarget( nullptr ), m_memoryUsage( 0 ), m_isLocked( false ), - m_isStandAlone( false ), + m_isStandAlone( false ), m_changeListeners( "Tr2AtlasTexture/m_changeListeners" ) { } @@ -129,9 +129,9 @@ void Tr2AtlasTexture::CalcSubTextureWindow( Vector4& tw, float rectX, float rect { rectHeight = (float)m_height; } - - tw.x = (float)(m_x + rectX) * m_textureWidthReciprocal; - tw.y = (float)(m_y + rectY) * m_textureHeightReciprocal; + + tw.x = (float)( m_x + rectX ) * m_textureWidthReciprocal; + tw.y = (float)( m_y + rectY ) * m_textureHeightReciprocal; tw.z = (float)rectWidth * m_textureWidthReciprocal; tw.w = (float)rectHeight * m_textureHeightReciprocal; } @@ -171,7 +171,7 @@ void Tr2AtlasTexture::ReleaseResources( TriStorage s ) if( texture && texture->GetMemoryClass() & s ) { // When managed memory is freed, both standalone textures and the - // ones resident in an atlas are purged. + // ones resident in an atlas are purged. CancelPendingLoad(); m_texture = Tr2TextureAL(); @@ -328,15 +328,16 @@ bool Tr2AtlasTexture::LockBuffer( void*& pData, unsigned int& pitch ) if( m_isLocked ) { - CCP_LOGERR( "Tr2AtlasTexture::LockBuffer failed - texture is already locked"); + CCP_LOGERR( "Tr2AtlasTexture::LockBuffer failed - texture is already locked" ); return false; } - long hr = texture->MapForWriting( - Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x ), uint32_t( m_y ), uint32_t( m_x + m_width ), uint32_t( m_y + m_height ) ), - pData, - pitch, - renderContext ).GetResult(); + long hr = texture->MapForWriting( + Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x ), uint32_t( m_y ), uint32_t( m_x + m_width ), uint32_t( m_y + m_height ) ), + pData, + pitch, + renderContext ) + .GetResult(); if( FAILED( hr ) ) { @@ -349,7 +350,7 @@ bool Tr2AtlasTexture::LockBuffer( void*& pData, unsigned int& pitch ) return true; } -bool Tr2AtlasTexture::LockBufferAndMargin( void *&data, unsigned &pitch, unsigned &margin ) +bool Tr2AtlasTexture::LockBufferAndMargin( void*& data, unsigned& pitch, unsigned& margin ) { USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -370,11 +371,12 @@ bool Tr2AtlasTexture::LockBufferAndMargin( void *&data, unsigned &pitch, unsigne } margin = m_textureAtlas->GetMargin(); - long hr = texture->MapForWriting( - Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x - margin ), uint32_t( m_y - margin ), uint32_t( m_x + m_width + margin ), uint32_t( m_y + m_height + margin ) ), - data, - pitch, - renderContext ).GetResult(); + long hr = texture->MapForWriting( + Tr2TextureSubresource( 0 ).SetRect( uint32_t( m_x - margin ), uint32_t( m_y - margin ), uint32_t( m_x + m_width + margin ), uint32_t( m_y + m_height + margin ) ), + data, + pitch, + renderContext ) + .GetResult(); if( FAILED( hr ) ) { @@ -391,7 +393,7 @@ void Tr2AtlasTexture::UnlockBuffer() { if( !m_isLocked ) { - CCP_LOGWARN( "Tr2AtlasTexture::UnlockBuffer failed - texture is not locked"); + CCP_LOGWARN( "Tr2AtlasTexture::UnlockBuffer failed - texture is not locked" ); return; } @@ -490,11 +492,11 @@ void Tr2AtlasTexture::NotifyListenersOfChange() { for( auto it = m_changeListeners.begin(); it != m_changeListeners.end(); ++it ) { - (*it)->AtlasTextureChanged( this ); + ( *it )->AtlasTextureChanged( this ); } } -void Tr2AtlasTexture::SetTargetAtlasBeforeLoad( Tr2TextureAtlas *atlas ) +void Tr2AtlasTexture::SetTargetAtlasBeforeLoad( Tr2TextureAtlas* atlas ) { if( m_textureAtlas ) { diff --git a/trinity/Tr2AtlasTexture.h b/trinity/Tr2AtlasTexture.h index f1a975b00..b799b3d1a 100644 --- a/trinity/Tr2AtlasTexture.h +++ b/trinity/Tr2AtlasTexture.h @@ -26,30 +26,30 @@ class ITr2AtlasTextureNotifyTarget // still being associated with a texture atlas. This can happen if the atlas was // full at the time of creation - the texture may be pulled into the atlas at a later // point. -BLUE_CLASS( Tr2AtlasTexture ): +BLUE_CLASS( Tr2AtlasTexture ) : public BlueAsyncRes, public ICacheable, public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); using BlueAsyncRes::Lock; using BlueAsyncRes::Unlock; - Tr2AtlasTexture( IRoot* lockobj = NULL ); + Tr2AtlasTexture( IRoot* lockobj = NULL ); ~Tr2AtlasTexture(); // Get the D3D texture behind the atlas texture. Use GetTextureWindow // to get the uv-offsets to apply when rendering. Tr2TextureAL* GetTexture(); Tr2TextureAL* GetRenderTarget(); - void SetRenderTarget( Tr2TextureAL* rt ); + void SetRenderTarget( Tr2TextureAL * rt ); // Get texture window for rendering this texture out of the atlas - void GetTextureWindow( Vector4& tw ); + void GetTextureWindow( Vector4 & tw ); // Calculate the texture coordinates for a region within this atlas texture. - void CalcSubTextureWindow( Vector4& tw, float rectX, float rectY, float rectWidth, float rectHeight ); + void CalcSubTextureWindow( Vector4 & tw, float rectX, float rectY, float rectWidth, float rectHeight ); unsigned int GetX() const; unsigned int GetY() const; @@ -62,13 +62,13 @@ BLUE_CLASS( Tr2AtlasTexture ): // Lock the rectangle in the D3D texture that corresponds to this atlas texture. bool LockBuffer( void*& pData, unsigned int& pitch ); - bool LockBufferAndMargin( void *&data, unsigned &pitch, unsigned &margin ); + bool LockBufferAndMargin( void*& data, unsigned& pitch, unsigned& margin ); // Unlock a rectangle previously locked with LockBuffer. void UnlockBuffer(); - void RegisterForChangeNotification( ITr2AtlasTextureNotifyTarget* p ); - void UnregisterForChangeNotification( ITr2AtlasTextureNotifyTarget* p ); + void RegisterForChangeNotification( ITr2AtlasTextureNotifyTarget * p ); + void UnregisterForChangeNotification( ITr2AtlasTextureNotifyTarget * p ); // A stand-alone atlas texture is really not an atlas texture - it's a permanent outsider. // This is to support textures that need texture transformations - clamping and repeat @@ -88,9 +88,10 @@ BLUE_CLASS( Tr2AtlasTexture ): ///////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); - + // For general use, we want to be able to load directly to a target atlas - void SetTargetAtlasBeforeLoad( Tr2TextureAtlas *atlas ); + void SetTargetAtlasBeforeLoad( Tr2TextureAtlas * atlas ); + private: bool OnPrepareResources(); @@ -112,7 +113,7 @@ BLUE_CLASS( Tr2AtlasTexture ): // Calculate reciprocals for width/height void CalcReciprocals(); - void SetTextureRes( TriTextureRes* p ); + void SetTextureRes( TriTextureRes * p ); TriTextureRes* GetTextureRes(); private: @@ -137,7 +138,7 @@ BLUE_CLASS( Tr2AtlasTexture ): // It is ok to have raw pointer to Tr2AtlasTexture::m_renderTarget since // since T2AtlasTexture lifetime is bound to it. - Tr2TextureAL *m_renderTarget; + Tr2TextureAL* m_renderTarget; // Bounds of this texture within the D3D texture unsigned int m_x; @@ -159,7 +160,7 @@ BLUE_CLASS( Tr2AtlasTexture ): Tr2TextureAtlasPtr m_textureAtlas; struct Tr2TextureAtlasArea* m_atlasArea; - + unsigned int m_memoryUsage; bool m_isStandAlone; diff --git a/trinity/Tr2AtlasTexture_Blue.cpp b/trinity/Tr2AtlasTexture_Blue.cpp index c87be1175..d360e5f34 100644 --- a/trinity/Tr2AtlasTexture_Blue.cpp +++ b/trinity/Tr2AtlasTexture_Blue.cpp @@ -31,9 +31,10 @@ static PyObject* PyLockBuffer( PyObject* self, PyObject* args ) if( pThis->LockBuffer( pData, pitch ) ) { PyObject* buffer = PyVerCompat::MemoryViewRW( pData, pThis->GetHeight() * pitch ); - PyObject *result = PyTuple_New(4); - if (!result) { - Py_DECREF(buffer); + PyObject* result = PyTuple_New( 4 ); + if( !result ) + { + Py_DECREF( buffer ); return nullptr; } PyTuple_SET_ITEM( result, 0, buffer ); @@ -61,9 +62,10 @@ static PyObject* PyLockBufferAndMargin( PyObject* self, PyObject* args ) const int width = pThis->GetWidth() + margin * 2; PyObject* buffer = PyVerCompat::MemoryViewRW( data, height * pitch ); - PyObject *result = PyTuple_New(5); - if (!result) { - Py_DECREF(buffer); + PyObject* result = PyTuple_New( 5 ); + if( !result ) + { + Py_DECREF( buffer ); return nullptr; } PyTuple_SET_ITEM( result, 0, buffer ); @@ -81,125 +83,99 @@ static PyObject* PyLockBufferAndMargin( PyObject* self, PyObject* args ) const Be::ClassInfo* Tr2AtlasTexture::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2AtlasTexture, "" ) - MAP_INTERFACE( Tr2AtlasTexture ) + EXPOSURE_BEGIN( Tr2AtlasTexture, "" ) + MAP_INTERFACE( Tr2AtlasTexture ) MAP_INTERFACE( IBlueResource ) MAP_INTERFACE( ICacheable ) MAP_ICACHEABLE_METHODS() - MAP_METHOD - ( + MAP_METHOD( "LockBuffer", PyLockBuffer, "Locks the surface behind the atlas texture.\n" "Returns a tuple with (address, width, height, pitch)\n" - ":rtype: (buffer, int, int, int)" - ) - - MAP_METHOD - ( + ":rtype: (buffer, int, int, int)" ) + + MAP_METHOD( "LockBufferAndMargin", PyLockBufferAndMargin, "Locks the surface behind the atlas texture, including margin.\n" "Returns a tuple with (address, width, height, pitch, margin)\n" - ":rtype: (buffer, int, int, int, int)" - ) + ":rtype: (buffer, int, int, int, int)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "UnlockBuffer", UnlockBuffer, - "Unlocks the surface previously locked with LockBuffer" - ) - - MAP_ATTRIBUTE - ( - "name", - m_name, - "Name of this texture atlas entry", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "resPath", - m_resPath, - "Resource path behind this texture atlas entry.", - Be::READ - ) - - MAP_ATTRIBUTE - ( + "Unlocks the surface previously locked with LockBuffer" ) + + MAP_ATTRIBUTE( + "name", + m_name, + "Name of this texture atlas entry", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "resPath", + m_resPath, + "Resource path behind this texture atlas entry.", + Be::READ ) + + MAP_ATTRIBUTE( "width", m_width, "Width of this texture.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "height", m_height, "Height of this texture.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "atlasWidth", m_textureWidth, - "Width of the entire atlas this texture is a part of.", - Be::READ - ) + "Width of the entire atlas this texture is a part of.", + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "atlasHeight", m_textureHeight, "Height of the entire atlas this texture is a part of.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "x", m_x, "x coordinate offset into the atlas.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "y", m_y, "y coordinate offset into the atlas.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "atlas", m_textureAtlas, "Texture atlas containing this texture", - Be::READ - ) + Be::READ ) - MAP_PROPERTY - ( + MAP_PROPERTY( "isStandAlone", - IsStandAlone, SetStandAlone, + IsStandAlone, + SetStandAlone, "A stand-alone atlas texture is really not an atlas texture - it's a permanent outsider.\n" "This is to support textures that need texture transformations - clamping and repeat\n" - "is currently too expensive to support for atlas textures." - ) + "is currently too expensive to support for atlas textures." ) - MAP_PROPERTY - ( + MAP_PROPERTY( "textureRes", - GetTextureRes, SetTextureRes, - "Sets a texture res directly - use for dynamic textures" - ) + GetTextureRes, + SetTextureRes, + "Sets a texture res directly - use for dynamic textures" ) - EXPOSURE_CHAINTO( BlueAsyncRes ) + EXPOSURE_CHAINTO( BlueAsyncRes ) } diff --git a/trinity/Tr2BindingVector3.h b/trinity/Tr2BindingVector3.h index aa34a9f8c..9ce8cc50d 100644 --- a/trinity/Tr2BindingVector3.h +++ b/trinity/Tr2BindingVector3.h @@ -9,10 +9,13 @@ // Tr2BindingVector3 is a simple blue-exposed class that contains a Vector3 value. Used // for bindings. // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2BindingVector3 ): public IRoot +BLUE_CLASS( Tr2BindingVector3 ) : + public IRoot { public: - Tr2BindingVector3( IRoot* = nullptr ) {} + Tr2BindingVector3( IRoot* = nullptr ) + { + } EXPOSE_TO_BLUE(); diff --git a/trinity/Tr2BindingVector3_Blue.cpp b/trinity/Tr2BindingVector3_Blue.cpp index 22188c6e6..3b72e55a2 100644 --- a/trinity/Tr2BindingVector3_Blue.cpp +++ b/trinity/Tr2BindingVector3_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2BindingVector3 ); const Be::ClassInfo* Tr2BindingVector3::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2BindingVector3, "" ) + EXPOSURE_BEGIN( Tr2BindingVector3, "" ) MAP_INTERFACE( Tr2BindingVector3 ) MAP_ATTRIBUTE( "value", m_value, "Vector3 value", Be::READWRITE | Be::PERSIST ) EXPOSURE_END() diff --git a/trinity/Tr2Blitter.cpp b/trinity/Tr2Blitter.cpp index 2636b30ab..29336ffd8 100644 --- a/trinity/Tr2Blitter.cpp +++ b/trinity/Tr2Blitter.cpp @@ -6,7 +6,7 @@ #include "Shader/Tr2Shader.h" #include "Tr2TextureReference.h" -#include "TriDevice.h" //TODO gTriDev/ScreenVertexDecl. +#include "TriDevice.h" //TODO gTriDev/ScreenVertexDecl. static const char* BLIT_EFFECT_PATH = "res:/Graphics/Effect/Managed/space/system/Blit.fx"; static const char* BLIT_FILTERED_EFFECT_PATH = "res:/Graphics/Effect/Managed/space/system/BlitFiltered.fx"; @@ -14,9 +14,8 @@ static const char* BLITCUBE_EFFECT_PATH = "res:/Graphics/Effect/Managed/space/sy using namespace Tr2RenderContextEnum; -Tr2Blitter::Tr2Blitter() - : m_screenVertexDecl( -1 ) - , m_mipLevelVar( "mipLevel", 0.f ) +Tr2Blitter::Tr2Blitter() : + m_screenVertexDecl( -1 ), m_mipLevelVar( "mipLevel", 0.f ) { GlobalStore().RegisterVariable( "BlitSource", static_cast( nullptr ) ); @@ -35,12 +34,9 @@ Tr2Blitter::~Tr2Blitter() GlobalStore().UnregisterVariable( "mipLevel" ); } -bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, - const Vector2& tlTexCoord, const Vector2& brTexCoord, - const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) +bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) { - return DrawHelper( renderContext, effect->GetShaderStateInterface(), effect, nullptr, false, tlTexCoord, brTexCoord, - tlVertexCoord, brVertexCoord ); + return DrawHelper( renderContext, effect->GetShaderStateInterface(), effect, nullptr, false, tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord ); } bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, Filtering filter ) @@ -55,12 +51,9 @@ bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& text return false; } -bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& texture, - const Vector2& tlTexCoord, const Vector2& brTexCoord, - const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) +bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) { - return DrawHelper( renderContext, m_blitEffect->GetShaderStateInterface(), m_blitEffect, &texture, false, - tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord ); + return DrawHelper( renderContext, m_blitEffect->GetShaderStateInterface(), m_blitEffect, &texture, false, tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord ); } bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture ) @@ -73,12 +66,9 @@ bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, con return DrawHelper( renderContext, effect->GetShaderStateInterface(), effect, &texture, false, tlTexCoord, brTexCoord ); } -bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, - const Vector2& tlTexCoord, const Vector2& brTexCoord, - const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) +bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) { - return DrawHelper( renderContext, effect->GetShaderStateInterface(), effect, &texture, false, tlTexCoord, brTexCoord, - tlVertexCoord, brVertexCoord ); + return DrawHelper( renderContext, effect->GetShaderStateInterface(), effect, &texture, false, tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord ); } // -------------------------------------------------------------------------------------- // Description: @@ -89,7 +79,7 @@ bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* effect, con // true if success, false if there is an error. // See Also: Tr2Renderer::DrawFullScreenWithShader() // -------------------------------------------------------------------------------------- -bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* material) +bool Tr2Blitter::Draw( Tr2RenderContext& renderContext, Tr2Material* material ) { auto shader = material->GetShaderStateInterface(); @@ -108,10 +98,7 @@ bool Tr2Blitter::DrawInCameraSpace( Tr2RenderContext& renderContext, Tr2Shader* return DrawHelper( renderContext, shader, material, NULL, true ); } -bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, Tr2Material* material, const Tr2TextureAL* halTexture, - bool isCameraSpace, - const Vector2& tlTexCoord, const Vector2& brTexCoord, - const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) +bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, Tr2Material* material, const Tr2TextureAL* halTexture, bool isCameraSpace, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) { CCP_ASSERT( material ); if( !material ) @@ -135,8 +122,8 @@ bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, if( isCameraSpace ) { - CCP_ASSERT( tlVertexCoord[0] == 0.0f && tlVertexCoord[1] == 0.0f ); - CCP_ASSERT( brVertexCoord[0] == 1.0f && brVertexCoord[1] == 1.0f ); + CCP_ASSERT( tlVertexCoord[0] == 0.0f && tlVertexCoord[1] == 0.0f ); + CCP_ASSERT( brVertexCoord[0] == 1.0f && brVertexCoord[1] == 1.0f ); SetupScreenQuadInCameraSpace( quad ); } @@ -172,7 +159,7 @@ bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, } textureReference.SetTexture( nullptr ); - GlobalStore().GetVariable( "BlitSource" )->Clear(); + GlobalStore().GetVariable( "BlitSource" )->Clear(); return true; } diff --git a/trinity/Tr2Blitter.h b/trinity/Tr2Blitter.h index f4acff86c..7aeab259d 100644 --- a/trinity/Tr2Blitter.h +++ b/trinity/Tr2Blitter.h @@ -32,11 +32,11 @@ class Tr2Blitter : public Tr2DeviceResource bool Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& texture, const Vector2& tlTexCoord = Vector2( 0.0f, 0.0f ), const Vector2& brTexCoord = Vector2( 1.0f, 1.0f ), Filtering filter = FILTER_POINT ); bool Draw( Tr2RenderContext& renderContext, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ); - + bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture ); bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord ); bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ); - + bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect ); bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Vector2& tlTexCoord, const Vector2& brTexCoord ); bool Draw( Tr2RenderContext& renderContext, Tr2Material* effect, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ); @@ -44,20 +44,21 @@ class Tr2Blitter : public Tr2DeviceResource ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); - + private: - bool DrawHelper( + bool DrawHelper( Tr2RenderContext& renderContext, - Tr2Shader* shader, + Tr2Shader* shader, Tr2Material* material, const Tr2TextureAL* halTexture, bool isCameraSpace, - const Vector2& tlTexCoord = Vector2( 0.0f, 0.0f ), + const Vector2& tlTexCoord = Vector2( 0.0f, 0.0f ), const Vector2& brTexCoord = Vector2( 1.0f, 1.0f ), - const Vector2& tlVertexCoord = Vector2( 0.0f, 0.0f ), - const Vector2& brVertexCoord = Vector2( 1.0f, 1.0f ) ); + const Vector2& tlVertexCoord = Vector2( 0.0f, 0.0f ), + const Vector2& brVertexCoord = Vector2( 1.0f, 1.0f ) ); unsigned int m_screenVertexDecl; Tr2BufferAL m_vertexBuffer; diff --git a/trinity/Tr2BoundingLineSet.cpp b/trinity/Tr2BoundingLineSet.cpp index ebf620edf..0950e7c3a 100644 --- a/trinity/Tr2BoundingLineSet.cpp +++ b/trinity/Tr2BoundingLineSet.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "Tr2BoundingLineSet.h" -Tr2BoundingLineSet::Tr2BoundingLineSet( IRoot* lockobj ): +Tr2BoundingLineSet::Tr2BoundingLineSet( IRoot* lockobj ) : Tr2LineSet( lockobj ), m_minBounds( 0.0f, 0.0f, 0.0f ), m_maxBounds( 0.0f, 0.0f, 0.0f ) @@ -12,7 +12,7 @@ Tr2BoundingLineSet::Tr2BoundingLineSet( IRoot* lockobj ): ///////////////////////////////////////////////////////////////////////////// // INotify -bool Tr2BoundingLineSet::OnModified( Be::Var * value ) +bool Tr2BoundingLineSet::OnModified( Be::Var* value ) { if( IsMatch( value, m_minBounds ) || IsMatch( value, m_maxBounds ) ) { @@ -23,7 +23,7 @@ bool Tr2BoundingLineSet::OnModified( Be::Var * value ) SubmitChanges(); } - return Tr2PrimitiveSet::OnModified( value ); + return Tr2PrimitiveSet::OnModified( value ); } void Tr2BoundingLineSet::UpdateBounds( const Vector3& min, const Vector3& max ) @@ -40,12 +40,12 @@ void Tr2BoundingLineSet::UpdateBounds( const Vector3& min, const Vector3& max ) void Tr2BoundingLineSet::AddBox( const Vector3& min, const Vector3& max, const Vector4& color ) { - Vector3 minA(max.x, min.y, min.z); - Vector3 minB(min.x, max.y, min.z); - Vector3 minC(max.x, max.y, min.z); - Vector3 maxA(max.x, min.y, max.z); - Vector3 maxB(min.x, max.y, max.z); - Vector3 maxC(min.x, min.y, max.z); + Vector3 minA( max.x, min.y, min.z ); + Vector3 minB( min.x, max.y, min.z ); + Vector3 minC( max.x, max.y, min.z ); + Vector3 maxA( max.x, min.y, max.z ); + Vector3 maxB( min.x, max.y, max.z ); + Vector3 maxC( min.x, min.y, max.z ); AddLine( min, color, minA, color ); AddLine( min, color, minB, color ); @@ -65,19 +65,19 @@ void Tr2BoundingLineSet::AddBox( const Vector3& min, const Vector3& max, const V void Tr2BoundingLineSet::AddPickingBox( const Vector3& min, const Vector3& max ) { - Vector3 minA(max.x, min.y, min.z); - Vector3 minB(min.x, max.y, min.z); - Vector3 minC(max.x, max.y, min.z); - Vector3 maxA(max.x, min.y, max.z); - Vector3 maxB(min.x, max.y, max.z); - Vector3 maxC(min.x, min.y, max.z); + Vector3 minA( max.x, min.y, min.z ); + Vector3 minB( min.x, max.y, min.z ); + Vector3 minC( max.x, max.y, min.z ); + Vector3 maxA( max.x, min.y, max.z ); + Vector3 maxB( min.x, max.y, max.z ); + Vector3 maxC( min.x, min.y, max.z ); AddPickingTriangle( maxA, max, maxB ); - AddPickingTriangle( maxA, maxB, maxC); + AddPickingTriangle( maxA, maxB, maxC ); AddPickingTriangle( maxC, maxB, min ); AddPickingTriangle( min, maxB, minB ); AddPickingTriangle( min, minB, minA ); - AddPickingTriangle( minA, minB, minC); + AddPickingTriangle( minA, minB, minC ); AddPickingTriangle( minA, minC, max ); AddPickingTriangle( minA, max, maxA ); AddPickingTriangle( maxA, min, minA ); diff --git a/trinity/Tr2BoundingLineSet.h b/trinity/Tr2BoundingLineSet.h index 83405f923..e190314e6 100644 --- a/trinity/Tr2BoundingLineSet.h +++ b/trinity/Tr2BoundingLineSet.h @@ -7,16 +7,16 @@ #include "Tr2LineSet.h" // A primitive specially made for bounding boxes -BLUE_CLASS( Tr2BoundingLineSet ): +BLUE_CLASS( Tr2BoundingLineSet ) : public Tr2LineSet { public: - EXPOSE_TO_BLUE(); - Tr2BoundingLineSet( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2BoundingLineSet( IRoot* lockobj = NULL ); ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); private: void AddBox( const Vector3& min, const Vector3& max, const Vector4& color ); diff --git a/trinity/Tr2BoundingLineSet_Blue.cpp b/trinity/Tr2BoundingLineSet_Blue.cpp index 2879fb6f4..3a9863f9a 100644 --- a/trinity/Tr2BoundingLineSet_Blue.cpp +++ b/trinity/Tr2BoundingLineSet_Blue.cpp @@ -7,21 +7,13 @@ BLUE_DEFINE( Tr2BoundingLineSet ); const Be::ClassInfo* Tr2BoundingLineSet::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2BoundingLineSet, "" ) - MAP_INTERFACE( Tr2BoundingLineSet ) - MAP_ATTRIBUTE( "minBounds", m_minBounds, - "Minimum bounds of the box", - Be::READWRITE| Be::NOTIFY| Be::PERSIST - ) - MAP_ATTRIBUTE( "maxBounds", m_maxBounds, - "Maximum bounds of the box", - Be::READWRITE| Be::NOTIFY| Be::PERSIST - ) - MAP_METHOD_AND_WRAP( "UpdateBounds", UpdateBounds, - "( min, max )\n" - "Update the bounding volume\n" - ":param boundsMin: min values for bounding box\n" - ":param boundsMax: max values for bounding box\n" - ) - EXPOSURE_CHAINTO( Tr2LineSet ) + EXPOSURE_BEGIN( Tr2BoundingLineSet, "" ) + MAP_INTERFACE( Tr2BoundingLineSet ) + MAP_ATTRIBUTE( "minBounds", m_minBounds, "Minimum bounds of the box", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "maxBounds", m_maxBounds, "Maximum bounds of the box", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_METHOD_AND_WRAP( "UpdateBounds", UpdateBounds, "( min, max )\n" + "Update the bounding volume\n" + ":param boundsMin: min values for bounding box\n" + ":param boundsMax: max values for bounding box\n" ) + EXPOSURE_CHAINTO( Tr2LineSet ) } diff --git a/trinity/Tr2ConstantBufferFormats.cpp b/trinity/Tr2ConstantBufferFormats.cpp index 3d8eeab3a..40d810b86 100644 --- a/trinity/Tr2ConstantBufferFormats.cpp +++ b/trinity/Tr2ConstantBufferFormats.cpp @@ -6,45 +6,49 @@ #include "TriDevice.h" // Check the sizes of the objects. These must fill float4 registers. -static_assert( sizeof( Tr2PerFrameVSData ) % ( 4*sizeof( float ) ) == 0, "Size of per-frame data needs to be a multiple of Vector4" ); -static_assert( sizeof( Tr2PerFramePSData ) % ( 4*sizeof( float ) ) == 0, "Size of per-frame data needs to be a multiple of Vector4" ); -static_assert( sizeof( Tr2PerObjectPerPixelPointLightData ) % ( 4*sizeof( float ) ) == 0, "Size of per-object light data needs to be a multiple of Vector4" ); +static_assert( sizeof( Tr2PerFrameVSData ) % ( 4 * sizeof( float ) ) == 0, "Size of per-frame data needs to be a multiple of Vector4" ); +static_assert( sizeof( Tr2PerFramePSData ) % ( 4 * sizeof( float ) ) == 0, "Size of per-frame data needs to be a multiple of Vector4" ); +static_assert( sizeof( Tr2PerObjectPerPixelPointLightData ) % ( 4 * sizeof( float ) ) == 0, "Size of per-object light data needs to be a multiple of Vector4" ); -void Tr2PopulatePerFrameVSDataTransformations( Tr2PerFrameVSData &data ) +void Tr2PopulatePerFrameVSDataTransformations( Tr2PerFrameVSData& data ) { - // 0 - memset( &data, 0, sizeof( Tr2PerFrameVSData ) ); + // 0 + memset( &data, 0, sizeof( Tr2PerFrameVSData ) ); - // column_major for shaders - data.ViewMat = XMMatrixTranspose( Tr2Renderer::GetViewTransform() ); - data.ProjectionMat = XMMatrixTranspose( Tr2Renderer::GetProjectionTransform() ); + // column_major for shaders + data.ViewMat = XMMatrixTranspose( Tr2Renderer::GetViewTransform() ); + data.ProjectionMat = XMMatrixTranspose( Tr2Renderer::GetProjectionTransform() ); - data.ViewProjectionMat = XMMatrixTranspose( - XMMatrixMultiply( - Tr2Renderer::GetViewTransform(), - Tr2Renderer::GetProjectionTransform() ) ); + data.ViewProjectionMat = XMMatrixTranspose( + XMMatrixMultiply( + Tr2Renderer::GetViewTransform(), + Tr2Renderer::GetProjectionTransform() ) ); - // attention: need the transposed, but shader also needs column_major, so it is transpose(transpose(m)) == m - data.ViewInverseTransposeMat = Tr2Renderer::GetInverseViewTransform(); + // attention: need the transposed, but shader also needs column_major, so it is transpose(transpose(m)) == m + data.ViewInverseTransposeMat = Tr2Renderer::GetInverseViewTransform(); } -namespace { +namespace +{ - Tr2ConstantBufferAL s_perFrameVSData; - Tr2ConstantBufferAL s_perFramePSData; +Tr2ConstantBufferAL s_perFrameVSData; +Tr2ConstantBufferAL s_perFramePSData; - struct Destroyer : Tr2DeviceResource +struct Destroyer : Tr2DeviceResource +{ + virtual void ReleaseResources( TriStorage s ) { - virtual void ReleaseResources( TriStorage s ) - { - s_perFrameVSData = Tr2ConstantBufferAL(); - s_perFramePSData = Tr2ConstantBufferAL(); - } + s_perFrameVSData = Tr2ConstantBufferAL(); + s_perFramePSData = Tr2ConstantBufferAL(); + } - virtual bool OnPrepareResources() { return true; } - }; + virtual bool OnPrepareResources() + { + return true; + } +}; - Destroyer s_destroyer; +Destroyer s_destroyer; } void Tr2BindPerFrameVSData( Tr2PerFrameVSData& data, Tr2RenderContext& renderContext ) diff --git a/trinity/Tr2ConstantBufferFormats.h b/trinity/Tr2ConstantBufferFormats.h index 51cbf4e36..4ff4b9531 100644 --- a/trinity/Tr2ConstantBufferFormats.h +++ b/trinity/Tr2ConstantBufferFormats.h @@ -45,7 +45,7 @@ struct Tr2PerObjectPSData float farFadeDistance; float nearFadeDistance; Vector2 padding; - Vector4 highlightColor; + Vector4 highlightColor; Tr2PerObjectPerPixelPointLightData pointLights[8]; }; @@ -87,7 +87,7 @@ struct Tr2PerFramePSData float shadowCount; float invShadowSize; float radius; - Vector4 viewPort; // xy - viewport width/height, zw - viewport offset + Vector4 viewPort; // xy - viewport width/height, zw - viewport offset Matrix ViewProjInverse; }; diff --git a/trinity/Tr2CurveLineSet.cpp b/trinity/Tr2CurveLineSet.cpp index b959cee80..9325f8a8c 100644 --- a/trinity/Tr2CurveLineSet.cpp +++ b/trinity/Tr2CurveLineSet.cpp @@ -15,7 +15,7 @@ static const char* CURVE_PICK_EFFECT_PATH = "res:/Graphics/Effect/Managed/Space/ CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); -Tr2CurveLineSet::Tr2CurveLineSet( IRoot* lockobj ): +Tr2CurveLineSet::Tr2CurveLineSet( IRoot* lockobj ) : m_scaling( 1.f, 1.f, 1.f ), m_rotation( 0.f, 0.f, 0.f, 1.f ), m_translation( 0.f, 0.f, 0.f ), @@ -41,8 +41,8 @@ Tr2CurveLineSet::~Tr2CurveLineSet() // ------------------------------------------------------------- // Description: -// Implements INotify method. Is called when exposed member -// variable is modified. If line width factor is modified - +// Implements INotify method. Is called when exposed member +// variable is modified. If line width factor is modified - // recreate the line set. // Arguments: // val - Value being modified @@ -94,7 +94,7 @@ bool Tr2CurveLineSet::OnPrepareResources() tvd.Add( tvd.UBYTE_4_NORM, tvd.COLOR, 0 ); tvd.Add( tvd.UBYTE_4_NORM, tvd.COLOR, 1 ); - tvd.Add( tvd.UBYTE_4_NORM, tvd.COLOR, 2 ); + tvd.Add( tvd.UBYTE_4_NORM, tvd.COLOR, 2 ); } m_vertexDeclHandle = Tr2EffectStateManager::GetVertexDeclarationHandle( s_curveLineDataVertexDecl ); @@ -103,7 +103,7 @@ bool Tr2CurveLineSet::OnPrepareResources() return false; } } - + // always fill it (this will also create a vertexbuffer) return FillVertexBuffer(); } @@ -161,7 +161,7 @@ bool Tr2CurveLineSet::isValidLineID( unsigned int id ) const // ------------------------------------------------------------------------------------------------------ inline unsigned SwizzleColor( unsigned color ) { - return ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); + return ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); } // ------------------------------------------------------------------------------------------------------ @@ -179,16 +179,16 @@ inline unsigned SwizzleColor( unsigned color ) // posNext - end position of the next segment // buffer - the vertex buffer // ------------------------------------------------------------------------------------------------------ -void Tr2CurveLineSet::WriteLineVerticesToBuffer( - const Vector3& pos1, - const Color& col1, - float length1, - const Vector3& pos2, - const Color& col2, - float length2, - const Vector3& posPrev, - const Vector3& posNext, - unsigned int lineID, +void Tr2CurveLineSet::WriteLineVerticesToBuffer( + const Vector3& pos1, + const Color& col1, + float length1, + const Vector3& pos2, + const Color& col2, + float length2, + const Vector3& posPrev, + const Vector3& posNext, + unsigned int lineID, LineVertex* buffer ) { // line info @@ -279,14 +279,14 @@ void Tr2CurveLineSet::WriteLineVerticesToBuffer( // lineID - the line's id // buffer - the vertex buffer // ------------------------------------------------------------------------------------------------------ -void Tr2CurveLineSet::WriteParticleVerticesToBuffer( - const Vector3& pos1, - const Color& col1, - float length1, - const Vector3& pos2, - const Color& col2, - float length2, - unsigned int lineID, +void Tr2CurveLineSet::WriteParticleVerticesToBuffer( + const Vector3& pos1, + const Color& col1, + float length1, + const Vector3& pos2, + const Color& col2, + float length2, + unsigned int lineID, LineVertex* buffer ) { // line info @@ -379,7 +379,7 @@ bool Tr2CurveLineSet::FillVertexBuffer() USE_MAIN_THREAD_RENDER_CONTEXT(); Tr2CpuUsage::Type cpuUsage = m_dynamic ? Tr2CpuUsage::WRITE_OFTEN : Tr2CpuUsage::WRITE; - + CR_RETURN_VAL( m_vertexBuffer.Create( sizeof( LineVertex ), @@ -387,8 +387,8 @@ bool Tr2CurveLineSet::FillVertexBuffer() Tr2GpuUsage::VERTEX_BUFFER, cpuUsage, nullptr, - renderContext ) - , false ); + renderContext ), + false ); m_vertexBufferSize = currentNumOfLines; } @@ -404,186 +404,183 @@ bool Tr2CurveLineSet::FillVertexBuffer() case LINETYPE_INVALID: break; - case LINETYPE_STRAIGHT: + case LINETYPE_STRAIGHT: { + // put some verts into buffer + WriteLineVerticesToBuffer( + m_lines[i].position1, + m_lines[i].color1, + 0.f, + m_lines[i].position2, + m_lines[i].color2, + 1.f, + m_lines[i].position1 - ( m_lines[i].position2 - m_lines[i].position1 ), + m_lines[i].position2 + ( m_lines[i].position2 - m_lines[i].position1 ), + i, + vertexBuffer ); + vertexBuffer += 6; + + // add to bounding sphere + BoundingSphereUpdate( m_lines[i].position1, m_boundingSphere ); + BoundingSphereUpdate( m_lines[i].position2, m_boundingSphere ); + // add to bounding box + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position1 ); + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position2 ); + + // one straight line more + m_currentSubmittedLineCount++; + } + break; + + case LINETYPE_SPHERED: { + // create rotation matrix to rotate each segment further to target vector + Vector3 rotationAxis, startDirNrm, endDirNrm; + // directional vectors + Vector3 startDir = m_lines[i].position1 - m_lines[i].intermediatePosition; + Vector3 endDir = m_lines[i].position2 - m_lines[i].intermediatePosition; + startDirNrm = Normalize( startDir ); + endDirNrm = Normalize( endDir ); + // matrix + Matrix rotationMatrix; + rotationAxis = Cross( startDir, endDir ); + float fullAngle = acosf( Dot( startDirNrm, endDirNrm ) ); + float segmentAngle = fullAngle / (float)m_lines[i].numOfSegments; + + // run through all segmens and create lines + rotationMatrix = RotationMatrix( rotationAxis, -segmentAngle ); + + Vector3 dir0 = TransformNormal( startDir, rotationMatrix ); + + rotationMatrix = RotationMatrix( rotationAxis, segmentAngle ); + + Vector3 dir1 = startDir; + Vector3 dir2 = TransformNormal( dir1, rotationMatrix ); + ; + Vector3 dir3 = startDir; + // also interpolate color across all the segments + Color col1 = m_lines[i].color1; + Color col2 = m_lines[i].color2; + for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) { + float segmentFactor = (float)( s + 1 ) / (float)m_lines[i].numOfSegments; + + // rotate end dir of this segment + dir3 = TransformNormal( dir2, rotationMatrix ); + + // interpolate color + col2 = Lerp( m_lines[i].color1, m_lines[i].color2, segmentFactor ); + // put some verts into buffer - WriteLineVerticesToBuffer( - m_lines[i].position1, - m_lines[i].color1, - 0.f, - m_lines[i].position2, - m_lines[i].color2, - 1.f, - m_lines[i].position1 - ( m_lines[i].position2 - m_lines[i].position1 ), - m_lines[i].position2 + ( m_lines[i].position2 - m_lines[i].position1 ), - i, + WriteLineVerticesToBuffer( + dir1 + m_lines[i].intermediatePosition, + col1, + (float)s / (float)m_lines[i].numOfSegments, + dir2 + m_lines[i].intermediatePosition, + col2, + segmentFactor, + dir0 + m_lines[i].intermediatePosition, + dir3 + m_lines[i].intermediatePosition, + i, vertexBuffer ); + vertexBuffer += 6; // add to bounding sphere - BoundingSphereUpdate( m_lines[i].position1, m_boundingSphere ); - BoundingSphereUpdate( m_lines[i].position2, m_boundingSphere ); + BoundingSphereUpdate( dir1 + m_lines[i].intermediatePosition, m_boundingSphere ); + BoundingSphereUpdate( dir2 + m_lines[i].intermediatePosition, m_boundingSphere ); // add to bounding box - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position1 ); - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position2 ); - - // one straight line more - m_currentSubmittedLineCount++; + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].intermediatePosition ); + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].intermediatePosition ); + + // next segment + dir0 = dir1; + dir1 = dir2; + dir2 = dir3; + col1 = col2; } - break; - case LINETYPE_SPHERED: + // several straight lines more + m_currentSubmittedLineCount += m_lines[i].numOfSegments; + } + break; + + case LINETYPE_CURVED: { + // use intermediate point to generate tangents for hermite spline + Vector3 tangent1 = m_lines[i].intermediatePosition - m_lines[i].position1; + Vector3 tangent2 = m_lines[i].intermediatePosition - m_lines[i].position2; + tangent2 *= -1.f; + // run through all segmens and create lines + Vector3 pos0 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, -1.0f / m_lines[i].numOfSegments ); + Vector3 pos1 = m_lines[i].position1; + Vector3 pos2 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, 1.0f / m_lines[i].numOfSegments ); + Vector3 pos3 = m_lines[i].position1; + // also interpolate color across all the segments + Color col1 = m_lines[i].color1; + Color col2 = m_lines[i].color2; + for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) { - // create rotation matrix to rotate each segment further to target vector - Vector3 rotationAxis, startDirNrm, endDirNrm; - // directional vectors - Vector3 startDir = m_lines[i].position1 - m_lines[i].intermediatePosition; - Vector3 endDir = m_lines[i].position2 - m_lines[i].intermediatePosition; - startDirNrm = Normalize( startDir ); - endDirNrm = Normalize( endDir ); - // matrix - Matrix rotationMatrix; - rotationAxis = Cross( startDir, endDir ); - float fullAngle = acosf( Dot( startDirNrm, endDirNrm ) ); - float segmentAngle = fullAngle / (float)m_lines[i].numOfSegments; - - // run through all segmens and create lines - rotationMatrix = RotationMatrix( rotationAxis, -segmentAngle ); - - Vector3 dir0 = TransformNormal( startDir, rotationMatrix ); - - rotationMatrix = RotationMatrix( rotationAxis, segmentAngle ); - - Vector3 dir1 = startDir; - Vector3 dir2 = TransformNormal( dir1, rotationMatrix );; - Vector3 dir3 = startDir; - // also interpolate color across all the segments - Color col1 = m_lines[i].color1; - Color col2 = m_lines[i].color2; - for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) - { - float segmentFactor = (float)( s + 1 ) / (float)m_lines[i].numOfSegments; - - // rotate end dir of this segment - dir3 = TransformNormal( dir2, rotationMatrix ); - - // interpolate color - col2 = Lerp( m_lines[i].color1, m_lines[i].color2, segmentFactor ); - - // put some verts into buffer - WriteLineVerticesToBuffer( - dir1 + m_lines[i].intermediatePosition, - col1, - (float)s / (float)m_lines[i].numOfSegments, - dir2 + m_lines[i].intermediatePosition, - col2, - segmentFactor, - dir0 + m_lines[i].intermediatePosition, - dir3 + m_lines[i].intermediatePosition, - i, - vertexBuffer ); - - vertexBuffer += 6; - - // add to bounding sphere - BoundingSphereUpdate( dir1 + m_lines[i].intermediatePosition, m_boundingSphere ); - BoundingSphereUpdate( dir2 + m_lines[i].intermediatePosition, m_boundingSphere ); - // add to bounding box - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].intermediatePosition ); - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].intermediatePosition ); - - // next segment - dir0 = dir1; - dir1 = dir2; - dir2 = dir3; - col1 = col2; - } - - // several straight lines more - m_currentSubmittedLineCount += m_lines[i].numOfSegments; - } - break; + float segmentFactor = (float)( s + 1 ) / (float)m_lines[i].numOfSegments; + float segmentFactor2 = (float)( s + 2 ) / (float)m_lines[i].numOfSegments; + pos3 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, segmentFactor2 ); - case LINETYPE_CURVED: - { - // use intermediate point to generate tangents for hermite spline - Vector3 tangent1 = m_lines[i].intermediatePosition - m_lines[i].position1; - Vector3 tangent2 = m_lines[i].intermediatePosition - m_lines[i].position2; - tangent2 *= -1.f; - // run through all segmens and create lines - Vector3 pos0 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, -1.0f / m_lines[i].numOfSegments ); - Vector3 pos1 = m_lines[i].position1; - Vector3 pos2 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, 1.0f / m_lines[i].numOfSegments ); - Vector3 pos3 = m_lines[i].position1; - // also interpolate color across all the segments - Color col1 = m_lines[i].color1; - Color col2 = m_lines[i].color2; - for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) - { - float segmentFactor = (float)( s + 1 ) / (float)m_lines[i].numOfSegments; - float segmentFactor2 = (float)( s + 2 ) / (float)m_lines[i].numOfSegments; - pos3 = Hermite( m_lines[i].position1, tangent1, m_lines[i].position2, tangent2, segmentFactor2 ); - - // interpolate color - col2 = Lerp( m_lines[i].color1, m_lines[i].color2, segmentFactor ); - - // put some verts into buffer - WriteLineVerticesToBuffer( - pos1, - col1, - (float)s / (float)m_lines[i].numOfSegments, - pos2, - col2, - segmentFactor, - pos0, - pos3, - i, - vertexBuffer ); - vertexBuffer += 6; - - // add to bounding sphere - BoundingSphereUpdate( pos1, m_boundingSphere ); - BoundingSphereUpdate( pos2, m_boundingSphere ); - // add to bounding box - BoundingBoxUpdate( m_minBounds, m_maxBounds, pos1 ); - BoundingBoxUpdate( m_minBounds, m_maxBounds, pos2 ); - - // next segment - pos0 = pos1; - pos1 = pos2; - pos2 = pos3; - col1 = col2; - } - - // several straight lines more - m_currentSubmittedLineCount += m_lines[i].numOfSegments; - } - break; + // interpolate color + col2 = Lerp( m_lines[i].color1, m_lines[i].color2, segmentFactor ); - case LINETYPE_PARTICLE: - { - // just add segements as particles - for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) - { - // length - float segmentFactor = (float)s / (float)m_lines[i].numOfSegments; - - // put some verts into buffer - WriteParticleVerticesToBuffer( m_lines[i].position1, m_lines[i].color1, segmentFactor, m_lines[i].position2, m_lines[i].color2, segmentFactor, i, vertexBuffer ); - vertexBuffer += 6; - } + // put some verts into buffer + WriteLineVerticesToBuffer( + pos1, + col1, + (float)s / (float)m_lines[i].numOfSegments, + pos2, + col2, + segmentFactor, + pos0, + pos3, + i, + vertexBuffer ); + vertexBuffer += 6; // add to bounding sphere - BoundingSphereUpdate( m_lines[i].position1, m_boundingSphere ); - BoundingSphereUpdate( m_lines[i].position2, m_boundingSphere ); + BoundingSphereUpdate( pos1, m_boundingSphere ); + BoundingSphereUpdate( pos2, m_boundingSphere ); // add to bounding box - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position1 ); - BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position2 ); + BoundingBoxUpdate( m_minBounds, m_maxBounds, pos1 ); + BoundingBoxUpdate( m_minBounds, m_maxBounds, pos2 ); + + // next segment + pos0 = pos1; + pos1 = pos2; + pos2 = pos3; + col1 = col2; + } + + // several straight lines more + m_currentSubmittedLineCount += m_lines[i].numOfSegments; + } + break; - // several straight lines more - m_currentSubmittedLineCount += m_lines[i].numOfSegments; + case LINETYPE_PARTICLE: { + // just add segements as particles + for( unsigned int s = 0; s < m_lines[i].numOfSegments; ++s ) + { + // length + float segmentFactor = (float)s / (float)m_lines[i].numOfSegments; + + // put some verts into buffer + WriteParticleVerticesToBuffer( m_lines[i].position1, m_lines[i].color1, segmentFactor, m_lines[i].position2, m_lines[i].color2, segmentFactor, i, vertexBuffer ); + vertexBuffer += 6; } - break; + + // add to bounding sphere + BoundingSphereUpdate( m_lines[i].position1, m_boundingSphere ); + BoundingSphereUpdate( m_lines[i].position2, m_boundingSphere ); + // add to bounding box + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position1 ); + BoundingBoxUpdate( m_minBounds, m_maxBounds, m_lines[i].position2 ); + + // several straight lines more + m_currentSubmittedLineCount += m_lines[i].numOfSegments; + } + break; } } @@ -617,8 +614,8 @@ bool Tr2CurveLineSet::HasTransparentBatches() // batchType - Type of batches to gather // data - Per-object data // ------------------------------------------------------------- -void Tr2CurveLineSet::GetBatches( ITriRenderBatchAccumulator* accumulator, - TriBatchType batchType, +void Tr2CurveLineSet::GetBatches( ITriRenderBatchAccumulator* accumulator, + TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason ) { @@ -661,7 +658,7 @@ float Tr2CurveLineSet::GetSortValue() // ------------------------------------------------------------- // Description: -// Implements ITr2Renderable method. Does nothing. Derived +// Implements ITr2Renderable method. Does nothing. Derived // classes need to supply their own per-object data. // Arguments: // accumulator - Render batch accumulator @@ -956,7 +953,7 @@ void Tr2CurveLineSet::ChangeLinePositionSph( unsigned int id, const Vector3& pos // id - The line ID returned by a previous call to AddXXX() // intermediatePosition - The new intermediate position of the line on the surface of the sphere in 3d cartesian space // ------------------------------------------------------------- -void Tr2CurveLineSet::ChangeLineIntermediateCrt(unsigned int id, const Vector3& intermediatePosition ) +void Tr2CurveLineSet::ChangeLineIntermediateCrt( unsigned int id, const Vector3& intermediatePosition ) { if( isValidLineID( id ) ) { @@ -973,7 +970,7 @@ void Tr2CurveLineSet::ChangeLineIntermediateCrt(unsigned int id, const Vector3& // intermediatePosition - The new intermediate position of the line on the surface of the sphere in 3d spherical coordinates (phi, theta, radius)" // center - The center of the sphere the spherical coordinates are based on in 3d cartesian spac // ------------------------------------------------------------- -void Tr2CurveLineSet::ChangeLineIntermediateSph(unsigned int id, const Vector3& intermediatePosition, const Vector3& center ) +void Tr2CurveLineSet::ChangeLineIntermediateSph( unsigned int id, const Vector3& intermediatePosition, const Vector3& center ) { // sphericals stored in vec3 float phi = intermediatePosition.x; @@ -989,13 +986,13 @@ void Tr2CurveLineSet::ChangeLineIntermediateSph(unsigned int id, const Vector3& // ------------------------------------------------------------- // Description: -// Changes only the intermediate position of a line, no matter what type of line. +// Changes only the intermediate position of a line, no matter what type of line. // Requires a call to SubmitChanges before being updated on the video card.eing updated on the video card. // Arguments: // id - The line ID returned by a previous call to AddXXX() // width - The new width of the line // ------------------------------------------------------------- -void Tr2CurveLineSet::ChangeLineWidth(unsigned int id, float width ) +void Tr2CurveLineSet::ChangeLineWidth( unsigned int id, float width ) { if( isValidLineID( id ) ) { @@ -1006,7 +1003,7 @@ void Tr2CurveLineSet::ChangeLineWidth(unsigned int id, float width ) // ------------------------------------------------------------- // Description: -// Changes the multicolor settings of a line, so it will have a seperate color until a border. +// Changes the multicolor settings of a line, so it will have a seperate color until a border. // Requires a call to SubmitChanges before being updated on the video card. // Arguments: // id - The line ID returned by a previous call to AddXXX() @@ -1025,7 +1022,7 @@ void Tr2CurveLineSet::ChangeLineMultiColor( unsigned int id, const Vector4& colo // ------------------------------------------------------------- // Description: -// Changes the animation settings of a line. +// Changes the animation settings of a line. // Requires a call to SubmitChanges before being updated on the video card. // Arguments: // id - The line ID returned by a previous call to AddXXX() @@ -1046,8 +1043,8 @@ void Tr2CurveLineSet::ChangeLineAnimation( unsigned int id, const Vector4& color // ------------------------------------------------------------- // Description: -// Changes the number of segments a curved line is made of. -// Does not work with straight lines! +// Changes the number of segments a curved line is made of. +// Does not work with straight lines! // Requires a call to SubmitChanges before being updated on the video card. // Arguments: // id - The line ID returned by a previous call to AddXXX() @@ -1068,7 +1065,7 @@ void Tr2CurveLineSet::ChangeLineSegmentation( unsigned int id, unsigned int numO // ------------------------------------------------------------- // Description: -// Clears all lines. +// Clears all lines. // Requires a call to SubmitChanges before being updated on the video card. // ------------------------------------------------------------- void Tr2CurveLineSet::ClearLines() diff --git a/trinity/Tr2CurveLineSet.h b/trinity/Tr2CurveLineSet.h index 6cb83225f..f73b71ddd 100644 --- a/trinity/Tr2CurveLineSet.h +++ b/trinity/Tr2CurveLineSet.h @@ -16,16 +16,15 @@ BLUE_DECLARE( Tr2Material ); // Derived classes need to implement their own and // GetPerObjectData methods. // ------------------------------------------------------------- -class Tr2CurveLineSet : - public ITr2Renderable, - public Tr2DeviceResource, - public ITr2Pickable, - public INotify +class Tr2CurveLineSet : public ITr2Renderable, + public Tr2DeviceResource, + public ITr2Pickable, + public INotify { public: EXPOSE_TO_BLUE(); - Tr2CurveLineSet(IRoot* lockobj = NULL); + Tr2CurveLineSet( IRoot* lockobj = NULL ); ~Tr2CurveLineSet(); ///////////////////////////////////////////////////////////////////////////////////// @@ -35,13 +34,17 @@ class Tr2CurveLineSet : ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: +public: ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ///////////////////////////////////////////////////////////////////////////////////// @@ -102,19 +105,19 @@ class Tr2CurveLineSet : // base incoming line data struct LineData { - LineType type; // straight, curved, etc. - Vector3 position1; // start position - Color color1; // color at start - Vector3 position2; // end position - Color color2; // color at end - Vector3 intermediatePosition; // special position for cruved lines: gives "curve" - float width; // width of lin in screen pixels - Color multiColor; // "override" color - float multiColorBorder; // "override" color until here - Color overlayColor; // color of the overlay animation layer - float animationSpeed; // speed of animation crawling along line - float animationScale; // scale of texture along line - unsigned int numOfSegments; // number of straight lines forming a curved line + LineType type; // straight, curved, etc. + Vector3 position1; // start position + Color color1; // color at start + Vector3 position2; // end position + Color color2; // color at end + Vector3 intermediatePosition; // special position for cruved lines: gives "curve" + float width; // width of lin in screen pixels + Color multiColor; // "override" color + float multiColorBorder; // "override" color until here + Color overlayColor; // color of the overlay animation layer + float animationSpeed; // speed of animation crawling along line + float animationScale; // scale of texture along line + unsigned int numOfSegments; // number of straight lines forming a curved line }; // line draw shader @@ -127,7 +130,7 @@ class Tr2CurveLineSet : Vector3 m_scaling; Quaternion m_rotation; Vector3 m_translation; - + // name std::string m_name; @@ -145,21 +148,21 @@ class Tr2CurveLineSet : // indicates if line bounds have changed bool m_boundsDirty; - + unsigned int m_currentSubmittedLineCount; -private: +private: // vertex struct LineVertex { - Vector3 position; // position in 3D - Vector4 lineDir; // [xyz] = offset to next/previous line segment, [w] = width (incl. -1.f to indicate direction) - Vector4 beginEnd; // [x] = 0 or 1 for begin/end, [y] = uniform scalar from 0 to 1 across length of line segment, [z] = override color border, [w] = length of vert in uniform scalar - Vector3 animationData; // [x] = animation speed, [y] = animation scale, [z] = lineID - Vector3 nextLineDir; // one after next/previous line segment position - unsigned int color; // [xyzw] = main color - unsigned int overrideColor; // [xyzw] = override color - unsigned int overlayColor; // [xyzw] = overlay color + Vector3 position; // position in 3D + Vector4 lineDir; // [xyz] = offset to next/previous line segment, [w] = width (incl. -1.f to indicate direction) + Vector4 beginEnd; // [x] = 0 or 1 for begin/end, [y] = uniform scalar from 0 to 1 across length of line segment, [z] = override color border, [w] = length of vert in uniform scalar + Vector3 animationData; // [x] = animation speed, [y] = animation scale, [z] = lineID + Vector3 nextLineDir; // one after next/previous line segment position + unsigned int color; // [xyzw] = main color + unsigned int overrideColor; // [xyzw] = override color + unsigned int overlayColor; // [xyzw] = overlay color }; // Helper function to allocate batches and set the correct effect @@ -174,16 +177,16 @@ class Tr2CurveLineSet : // fill vertex buffer bool FillVertexBuffer(); // helper - void WriteLineVerticesToBuffer( - const Vector3& pos1, - const Color& col1, - float length1, - const Vector3& pos2, - const Color& col2, - float length2, - const Vector3& posPrev, - const Vector3& posNext, - unsigned int lineID, + void WriteLineVerticesToBuffer( + const Vector3& pos1, + const Color& col1, + float length1, + const Vector3& pos2, + const Color& col2, + float length2, + const Vector3& posPrev, + const Vector3& posNext, + unsigned int lineID, LineVertex* buffer ); void WriteParticleVerticesToBuffer( const Vector3& pos1, const Color& col1, float length1, const Vector3& pos2, const Color& col2, float length2, unsigned int lineID, LineVertex* buffer ); diff --git a/trinity/Tr2CurveLineSet_Blue.cpp b/trinity/Tr2CurveLineSet_Blue.cpp index d4204fa8d..5634ef8f0 100644 --- a/trinity/Tr2CurveLineSet_Blue.cpp +++ b/trinity/Tr2CurveLineSet_Blue.cpp @@ -40,7 +40,7 @@ const Be::ClassInfo* Tr2CurveLineSet::ExposeToBlue() AddCurvedLineCrt, 1, "Adds a curved line (based on splines) to the line set using cartesian coordinates, but does not submit it" - "\n" + "\n" "\n:param startPosition: The start position of the line in 3d cartesian space" "\n:param startColor: The color of the line at start position" "\n:param endPosition: The end position of the line in 3d cartesian space" diff --git a/trinity/Tr2DebugRenderer.cpp b/trinity/Tr2DebugRenderer.cpp index de4b87a91..d0c04267d 100644 --- a/trinity/Tr2DebugRenderer.cpp +++ b/trinity/Tr2DebugRenderer.cpp @@ -67,14 +67,14 @@ uint32_t GetAutoSelectedColor( uint32_t color ) } -Tr2DebugObjectReference::Tr2DebugObjectReference( IRoot* object ) - :m_object( object ), +Tr2DebugObjectReference::Tr2DebugObjectReference( IRoot* object ) : + m_object( object ), m_area( 0 ) { } -Tr2DebugObjectReference::Tr2DebugObjectReference( IRoot* object, uint32_t area ) - :m_object( object ), +Tr2DebugObjectReference::Tr2DebugObjectReference( IRoot* object, uint32_t area ) : + m_object( object ), m_area( area ) { } @@ -113,8 +113,8 @@ Tr2DebugRenderer::Vertex::Vertex() { } -Tr2DebugRenderer::Vertex::Vertex( const Vector3& position, Tr2DebugColor color, bool selected, size_t objectIndex ) - :m_position( position ), +Tr2DebugRenderer::Vertex::Vertex( const Vector3& position, Tr2DebugColor color, bool selected, size_t objectIndex ) : + m_position( position ), m_normal( 0, 0, 0 ), m_color( selected ? color.m_colorSelected : color.m_color ), m_zFailColor( selected ? color.m_zFailColorSelected : color.m_zFailColor ), @@ -123,8 +123,8 @@ Tr2DebugRenderer::Vertex::Vertex( const Vector3& position, Tr2DebugColor color, m_object = float( objectIndex + 1 ); } -Tr2DebugRenderer::Vertex::Vertex( const Vector3& position, const Vector3& normal, Tr2DebugColor color, bool selected, size_t objectIndex ) - :m_position( position ), +Tr2DebugRenderer::Vertex::Vertex( const Vector3& position, const Vector3& normal, Tr2DebugColor color, bool selected, size_t objectIndex ) : + m_position( position ), m_normal( XMVector3Normalize( normal ) ), m_color( selected ? color.m_colorSelected : color.m_color ), m_zFailColor( selected ? color.m_zFailColorSelected : color.m_zFailColor ), @@ -172,14 +172,14 @@ void Tr2DebugRenderer::DrawLine( Tr2DebugObjectReference owner, const Vector3& f m_lines.push_back( Vertex( to, color, IsSelected( owner ), m_objectLineOffsets.size() - 1 ) ); } -void Tr2DebugRenderer::DrawTriangle( - Tr2DebugObjectReference owner, - const Vector3& vertex1, - const Vector3& normal1, - const Vector3& vertex2, - const Vector3& normal2, - const Vector3& vertex3, - const Vector3& normal3, +void Tr2DebugRenderer::DrawTriangle( + Tr2DebugObjectReference owner, + const Vector3& vertex1, + const Vector3& normal1, + const Vector3& vertex2, + const Vector3& normal2, + const Vector3& vertex3, + const Vector3& normal3, Tr2DebugColor color ) { if( m_objectTriangleOffsets.empty() || m_objectTriangleOffsets.back().first != owner ) @@ -191,12 +191,12 @@ void Tr2DebugRenderer::DrawTriangle( m_triangles.push_back( Vertex( vertex3, normal3, color, IsSelected( owner ), m_objectTriangleOffsets.size() - 1 ) ); } -void Tr2DebugRenderer::DrawTriangle( - Tr2DebugObjectReference owner, - const Vector3& vertex1, - const Vector3& vertex2, - const Vector3& vertex3, - const Vector3& normal, +void Tr2DebugRenderer::DrawTriangle( + Tr2DebugObjectReference owner, + const Vector3& vertex1, + const Vector3& vertex2, + const Vector3& vertex3, + const Vector3& normal, Tr2DebugColor color ) { DrawTriangle( owner, vertex1, normal, vertex2, normal, vertex3, normal, color ); @@ -230,7 +230,7 @@ void Tr2DebugRenderer::DrawBox( Tr2DebugObjectReference owner, const Matrix& tra DrawLine( owner, v001, v011, color ); DrawLine( owner, v111, v011, color ); DrawLine( owner, v111, v101, color ); - + DrawLine( owner, v000, v001, color ); DrawLine( owner, v100, v101, color ); DrawLine( owner, v010, v011, color ); @@ -300,8 +300,7 @@ void Tr2DebugRenderer::DrawSphere( Tr2DebugObjectReference owner, const Matrix& segments = 4; } - auto Coords = [&]( float alpha, float betta )->Vector3 - { + auto Coords = [&]( float alpha, float betta ) -> Vector3 { Vector3 v; v.y = sin( alpha - XM_PI / 2 ); float ca = cos( alpha - XM_PI / 2 ); @@ -328,51 +327,51 @@ void Tr2DebugRenderer::DrawSphere( Tr2DebugObjectReference owner, const Matrix& switch( effect ) { case Wireframe: - DrawLine( - owner, - Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), + DrawLine( + owner, + Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), color ); - DrawLine( - owner, - Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), + DrawLine( + owner, + Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), color ); break; case Solid: - DrawTriangle( - owner, - Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), - Vector3( 0, 0, 0 ), + DrawTriangle( + owner, + Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), + Vector3( 0, 0, 0 ), color ); - DrawTriangle( - owner, - Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p11 * radius + center, transform ) ), - Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), - Vector3( 0, 0, 0 ), + DrawTriangle( + owner, + Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p11 * radius + center, transform ) ), + Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), + Vector3( 0, 0, 0 ), color ); break; default: - DrawTriangle( - owner, - Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p00, transform ) ), - Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p10, transform ) ), - Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p01, transform ) ), + DrawTriangle( + owner, + Vector3( XMVector3TransformCoord( p00 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p00, transform ) ), + Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p10, transform ) ), + Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p01, transform ) ), color ); - DrawTriangle( - owner, - Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p10, transform ) ), - Vector3( XMVector3TransformCoord( p11 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p11, transform ) ), - Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), - Vector3( XMVector3TransformNormal( p01, transform ) ), + DrawTriangle( + owner, + Vector3( XMVector3TransformCoord( p10 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p10, transform ) ), + Vector3( XMVector3TransformCoord( p11 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p11, transform ) ), + Vector3( XMVector3TransformCoord( p01 * radius + center, transform ) ), + Vector3( XMVector3TransformNormal( p01, transform ) ), color ); } } @@ -417,7 +416,7 @@ void Tr2DebugRenderer::DrawCone( Tr2DebugObjectReference owner, const Vector3& b void Tr2DebugRenderer::DrawCone( Tr2DebugObjectReference owner, const Matrix& transform, float height, float angle, uint32_t segments, uint32_t coneSegments, Effect effect, Tr2DebugColor color ) { coneSegments = std::max( coneSegments, (uint32_t)3 ); - + std::vector vertices; vertices.reserve( coneSegments + 1 ); @@ -427,17 +426,17 @@ void Tr2DebugRenderer::DrawCone( Tr2DebugObjectReference owner, const Matrix& tr vertices.push_back( tip ); normals.push_back( Vector2( -1, 0 ) ); - for( uint32_t i = 0; i < coneSegments; ++i) + for( uint32_t i = 0; i < coneSegments; ++i ) { - float alpha = (coneSegments - 1 - float( i )) / float( coneSegments - 1 ) * angle; + float alpha = ( coneSegments - 1 - float( i ) ) / float( coneSegments - 1 ) * angle; vertices.push_back( Vector2( -cos( alpha ) * height, sin( alpha ) * height ) + tip ); - normals.push_back( Vector2( -cos( alpha ), sin( alpha ) ) ); - if( i != coneSegments-1 ) + normals.push_back( Vector2( -cos( alpha ), sin( alpha ) ) ); + if( i != coneSegments - 1 ) { normals.push_back( Vector2( -cos( alpha ), sin( alpha ) ) ); } } - + DrawExtrusionShape( owner, RotationXMatrix( -XM_PIDIV2 ) * transform, &vertices[0], &normals[0], uint32_t( vertices.size() ), segments, effect, color ); } @@ -493,34 +492,43 @@ void Tr2DebugRenderer::DrawArrow( Tr2DebugObjectReference owner, const Vector3& { radius = length * pointerLength * 0.15f; - const Vector2 vertices[] = { - Vector2( length / 2 - pointerLength * length, 0 ), - Vector2( length / 2 - pointerLength * length, radius * 2 ), - Vector2( length / 2, 0 ) }; + const Vector2 vertices[] = { + Vector2( length / 2 - pointerLength * length, 0 ), + Vector2( length / 2 - pointerLength * length, radius * 2 ), + Vector2( length / 2, 0 ) + }; Vector2 n = LineNormal( vertices[1], vertices[2] ); - const Vector2 normals[] = { - Vector2( -1, 0 ), - Vector2( -1, 0 ), n, - n }; + const Vector2 normals[] = { + Vector2( -1, 0 ), + Vector2( -1, 0 ), + n, + n + }; DrawExtrusionShape( owner, transform, vertices, normals, sizeof( vertices ) / sizeof( vertices[0] ), segments, effect, color ); DrawLine( owner, start, start + transform.GetY() * length * ( 1 - pointerLength ), color ); } else { - const Vector2 vertices[] = { - Vector2( -length / 2, 0 ), - Vector2( -length / 2, radius ), - Vector2( length / 2 - pointerLength * length, radius ), - Vector2( length / 2 - pointerLength * length, radius * 2 ), - Vector2( length / 2, 0 ) }; + const Vector2 vertices[] = { + Vector2( -length / 2, 0 ), + Vector2( -length / 2, radius ), + Vector2( length / 2 - pointerLength * length, radius ), + Vector2( length / 2 - pointerLength * length, radius * 2 ), + Vector2( length / 2, 0 ) + }; Vector2 n = LineNormal( vertices[2], vertices[3] ); - const Vector2 normals[] = { - Vector2( -1, 0 ), - Vector2( -1, 0 ), Vector2( 0, 1 ), - Vector2( 0, 1 ), Vector2( 0, 1 ), - Vector2( 0, 1 ), Vector2( -1, 0 ), - Vector2( -1, 0 ), n, - n }; + const Vector2 normals[] = { + Vector2( -1, 0 ), + Vector2( -1, 0 ), + Vector2( 0, 1 ), + Vector2( 0, 1 ), + Vector2( 0, 1 ), + Vector2( 0, 1 ), + Vector2( -1, 0 ), + Vector2( -1, 0 ), + n, + n + }; DrawExtrusionShape( owner, transform, vertices, normals, sizeof( vertices ) / sizeof( vertices[0] ), segments, effect, color ); } } @@ -535,48 +543,60 @@ void Tr2DebugRenderer::DrawDoubleArrow( Tr2DebugObjectReference owner, const Vec { radius = length * pointerLength * 0.15f; - const Vector2 vertices0[] = { - Vector2( -length / 2, 0 ), - Vector2( -length / 2 + length * pointerLength, radius * 2 ), - Vector2( -length / 2 + length * pointerLength, 0 ) }; + const Vector2 vertices0[] = { + Vector2( -length / 2, 0 ), + Vector2( -length / 2 + length * pointerLength, radius * 2 ), + Vector2( -length / 2 + length * pointerLength, 0 ) + }; Vector2 n0 = LineNormal( vertices0[0], vertices0[1] ); - const Vector2 normals0[] = { + const Vector2 normals0[] = { n0, - n0, Vector2( 1, 0 ), - Vector2( 1, 0 ) }; + n0, + Vector2( 1, 0 ), + Vector2( 1, 0 ) + }; DrawExtrusionShape( owner, transform, vertices0, normals0, sizeof( vertices0 ) / sizeof( vertices0[0] ), segments, effect, color ); - const Vector2 vertices1[] = { - Vector2( length / 2 - length * pointerLength, 0 ), - Vector2( length / 2 - length * pointerLength, radius * 2 ), - Vector2( length / 2, 0 ) }; + const Vector2 vertices1[] = { + Vector2( length / 2 - length * pointerLength, 0 ), + Vector2( length / 2 - length * pointerLength, radius * 2 ), + Vector2( length / 2, 0 ) + }; Vector2 n1 = LineNormal( vertices1[1], vertices1[2] ); - const Vector2 normals1[] = { + const Vector2 normals1[] = { + Vector2( -1, 0 ), Vector2( -1, 0 ), - Vector2( -1, 0 ), n1, - n1 }; + n1, + n1 + }; DrawExtrusionShape( owner, transform, vertices1, normals1, sizeof( vertices1 ) / sizeof( vertices1[0] ), segments, effect, color ); DrawLine( owner, start + transform.GetY() * length * pointerLength, start + transform.GetY() * length * ( 1 - pointerLength ), color ); } else { - const Vector2 vertices[] = { - Vector2( -length / 2, 0 ), - Vector2( -length / 2 + length * pointerLength, radius * 2 ), - Vector2( -length / 2 + length * pointerLength, radius ), - Vector2( length / 2 - pointerLength * length, radius ), - Vector2( length / 2 - pointerLength * length, radius * 2 ), - Vector2( length / 2, 0 ) }; + const Vector2 vertices[] = { + Vector2( -length / 2, 0 ), + Vector2( -length / 2 + length * pointerLength, radius * 2 ), + Vector2( -length / 2 + length * pointerLength, radius ), + Vector2( length / 2 - pointerLength * length, radius ), + Vector2( length / 2 - pointerLength * length, radius * 2 ), + Vector2( length / 2, 0 ) + }; Vector2 n0 = LineNormal( vertices[0], vertices[1] ); Vector2 n1 = LineNormal( vertices[4], vertices[5] ); - const Vector2 normals[] = { + const Vector2 normals[] = { + n0, n0, - n0, Vector2( 1, 0 ), - Vector2( 1, 0 ), Vector2( 0, 1 ), - Vector2( 0, 1 ), Vector2( -1, 0 ), - Vector2( -1, 0 ), n1, - n1 }; + Vector2( 1, 0 ), + Vector2( 1, 0 ), + Vector2( 0, 1 ), + Vector2( 0, 1 ), + Vector2( -1, 0 ), + Vector2( -1, 0 ), + n1, + n1 + }; DrawExtrusionShape( owner, transform, vertices, normals, sizeof( vertices ) / sizeof( vertices[0] ), segments, effect, color ); } } @@ -622,7 +642,7 @@ void Tr2DebugRenderer::DrawSphereArrow( Tr2DebugObjectReference owner, const Vec normals.push_back( Vector2( 0, 1 ) ); vertices.push_back( Vector2( 2 * radius, arrowRadius ) ); normals.push_back( Vector2( 0, 1 ) ); - + normals.push_back( Vector2( -1, 0 ) ); vertices.push_back( Vector2( 2 * radius, 2 * arrowRadius ) ); normals.push_back( Vector2( -1, 0 ) ); @@ -649,8 +669,7 @@ void Tr2DebugRenderer::DrawExtrusionShape( Tr2DebugObjectReference owner, const segments = 3; } - auto Coords = [&]( float alpha, const Vector2& e )->Vector3 - { + auto Coords = [&]( float alpha, const Vector2& e ) -> Vector3 { Vector3 v; v.y = e.x; v.x = sin( alpha ) * e.y; @@ -666,7 +685,7 @@ void Tr2DebugRenderer::DrawExtrusionShape( Tr2DebugObjectReference owner, const { float alpha0 = float( i ) / float( segments ) * 2 * XM_PI; float alpha1 = float( i + 1 ) / float( segments ) * 2 * XM_PI; - + Vector3 p00( XMVector3TransformCoord( Coords( alpha0, e0 ), transform ) ); Vector3 p10( XMVector3TransformCoord( Coords( alpha1, e0 ), transform ) ); Vector3 p01( XMVector3TransformCoord( Coords( alpha0, e1 ), transform ) ); @@ -702,7 +721,7 @@ void Tr2DebugRenderer::DrawExtrusionShape( Tr2DebugObjectReference owner, const void Tr2DebugRenderer::DrawText( TriDebugFont font, const Vector3& pos, const Color& color, const char* msg, ... ) { va_list args; - va_start( args, msg ); + va_start( args, msg ); Tr2Rect rect; USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -711,7 +730,7 @@ void Tr2DebugRenderer::DrawText( TriDebugFont font, const Vector3& pos, const Co Vector3 screenPos = Tr2Renderer::ProjectWorldToScreen( pos, vp ); - if( (screenPos.z > 0.0f) && (screenPos.z < 1.0f) ) + if( ( screenPos.z > 0.0f ) && ( screenPos.z < 1.0f ) ) { rect.top = (int32_t)screenPos.y; rect.left = (int32_t)screenPos.x; @@ -954,67 +973,64 @@ std::vector Tr2DebugRenderer::GetDefaultOptions() const void Tr2DebugRenderer::DrawAudioSpeaker( Tr2DebugObjectReference owner, const Matrix& transform, float size, uint32_t segments, Effect effect, Tr2DebugColor color ) { - if( segments < 3 ) - { - segments = 3; - } - - const float coneWidth = size * 0.3f; - const float coneHeight = size * 0.5f; - const float waveOffset = size * 0.6f; - const float waveSpacing = size * 0.2f; - const float halfConeHeight = coneHeight * 0.5f; - const float coneWidthNarrow = coneWidth * 0.3f; - - const Vector2 coneVertices[] = { - Vector2( -halfConeHeight, coneWidthNarrow ), // Back narrow end - Vector2( -halfConeHeight, coneWidthNarrow ), - Vector2( halfConeHeight, coneWidth ), // Front wide end - Vector2( halfConeHeight, coneWidth ) - }; - const Vector2 coneNormals[] = { - Vector2( -1, 0 ), Vector2( -1, 0 ), - Vector2( 0, 1 ), Vector2( 0, 1 ) - }; - - DrawExtrusionShape( owner, transform, coneVertices, coneNormals, - sizeof( coneVertices ) / sizeof( coneVertices[0] ), segments, effect, color ); - - static const uint32_t MAX_WAVE_SEGMENTS = 32; - uint32_t waveSegments = std::min( std::max( segments / 2, 8u ), MAX_WAVE_SEGMENTS); - - static const float arcAngle = XM_PI * 0.6f; // 108 degrees total arc - static const float halfArcAngle = arcAngle * 0.5f; - const float arcStep = arcAngle / float( waveSegments ); - - const Vector3 waveBasePoint( halfConeHeight, 0, 0 ); - const Vector3 transformedWaveBase = Vector3( XMVector3TransformCoord( waveBasePoint, transform ) ); - - for( int wave = 0; wave < 3; ++wave ) - { - float waveRadius = waveOffset + ( float )wave * waveSpacing; - Vector3 arcPoints[MAX_WAVE_SEGMENTS + 1]; - uint32_t arcCount = waveSegments + 1; - - for( uint32_t i = 0; i < arcCount; ++i ) - { - float angle = -halfArcAngle + ( float )i * arcStep; - float cosAngle = cos( angle ); - float sinAngle = sin( angle ); - - Vector3 localOffset( - 0, - cosAngle * waveRadius, - sinAngle * waveRadius - ); - - Vector3 transformedOffset = Vector3( XMVector3TransformNormal( localOffset, transform ) ); - arcPoints[i] = transformedWaveBase + transformedOffset; - } - - for( uint32_t i = 0; i < waveSegments; ++i ) - { - DrawLine( owner, arcPoints[i], arcPoints[i + 1], color ); - } - } + if( segments < 3 ) + { + segments = 3; + } + + const float coneWidth = size * 0.3f; + const float coneHeight = size * 0.5f; + const float waveOffset = size * 0.6f; + const float waveSpacing = size * 0.2f; + const float halfConeHeight = coneHeight * 0.5f; + const float coneWidthNarrow = coneWidth * 0.3f; + + const Vector2 coneVertices[] = { + Vector2( -halfConeHeight, coneWidthNarrow ), // Back narrow end + Vector2( -halfConeHeight, coneWidthNarrow ), + Vector2( halfConeHeight, coneWidth ), // Front wide end + Vector2( halfConeHeight, coneWidth ) + }; + const Vector2 coneNormals[] = { + Vector2( -1, 0 ), Vector2( -1, 0 ), Vector2( 0, 1 ), Vector2( 0, 1 ) + }; + + DrawExtrusionShape( owner, transform, coneVertices, coneNormals, sizeof( coneVertices ) / sizeof( coneVertices[0] ), segments, effect, color ); + + static const uint32_t MAX_WAVE_SEGMENTS = 32; + uint32_t waveSegments = std::min( std::max( segments / 2, 8u ), MAX_WAVE_SEGMENTS ); + + static const float arcAngle = XM_PI * 0.6f; // 108 degrees total arc + static const float halfArcAngle = arcAngle * 0.5f; + const float arcStep = arcAngle / float( waveSegments ); + + const Vector3 waveBasePoint( halfConeHeight, 0, 0 ); + const Vector3 transformedWaveBase = Vector3( XMVector3TransformCoord( waveBasePoint, transform ) ); + + for( int wave = 0; wave < 3; ++wave ) + { + float waveRadius = waveOffset + (float)wave * waveSpacing; + Vector3 arcPoints[MAX_WAVE_SEGMENTS + 1]; + uint32_t arcCount = waveSegments + 1; + + for( uint32_t i = 0; i < arcCount; ++i ) + { + float angle = -halfArcAngle + (float)i * arcStep; + float cosAngle = cos( angle ); + float sinAngle = sin( angle ); + + Vector3 localOffset( + 0, + cosAngle * waveRadius, + sinAngle * waveRadius ); + + Vector3 transformedOffset = Vector3( XMVector3TransformNormal( localOffset, transform ) ); + arcPoints[i] = transformedWaveBase + transformedOffset; + } + + for( uint32_t i = 0; i < waveSegments; ++i ) + { + DrawLine( owner, arcPoints[i], arcPoints[i + 1], color ); + } + } } diff --git a/trinity/Tr2DebugRenderer.h b/trinity/Tr2DebugRenderer.h index a71f55d9e..292869c88 100644 --- a/trinity/Tr2DebugRenderer.h +++ b/trinity/Tr2DebugRenderer.h @@ -5,12 +5,12 @@ #include "TriDebugTextRenderer.h" #include "Tr2PickBuffer.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif #include "TriDebugTextRenderer.h" #include "Eve/EvePicking.h" @@ -24,43 +24,43 @@ BLUE_CLASS( Tr2DebugRenderer ) : EXPOSE_TO_BLUE(); template - bool HasOption( T* owner, const char* option ) const + bool HasOption( T * owner, const char* option ) const { return this->HasOption( owner->GetRawRoot(), option ); } - bool HasOption( IRoot* owner, const char* option ) const; - bool IsSelected( IRoot* owner ) const; + bool HasOption( IRoot * owner, const char* option ) const; + bool IsSelected( IRoot * owner ) const; bool IsSelected( Tr2DebugObjectReference owner ) const; - void DrawLine( Tr2DebugObjectReference owner, const Vector3& from, const Vector3& to, Tr2DebugColor color ); - void DrawTriangle( - Tr2DebugObjectReference owner, - const Vector3& vertex1, - const Vector3& normal1, - const Vector3& vertex2, - const Vector3& normal2, - const Vector3& vertex3, - const Vector3& normal3, + void DrawLine( Tr2DebugObjectReference owner, const Vector3& from, const Vector3& to, Tr2DebugColor color ); + void DrawTriangle( + Tr2DebugObjectReference owner, + const Vector3& vertex1, + const Vector3& normal1, + const Vector3& vertex2, + const Vector3& normal2, + const Vector3& vertex3, + const Vector3& normal3, Tr2DebugColor color ); - void DrawTriangle( - Tr2DebugObjectReference owner, - const Vector3& vertex1, - const Vector3& vertex2, - const Vector3& vertex3, - const Vector3& normal, + void DrawTriangle( + Tr2DebugObjectReference owner, + const Vector3& vertex1, + const Vector3& vertex2, + const Vector3& vertex3, + const Vector3& normal, Tr2DebugColor color ); - void DrawBox( Tr2DebugObjectReference owner, const Vector3& min, const Vector3& max, Effect effect, Tr2DebugColor color ); - void DrawBox( Tr2DebugObjectReference owner, const Matrix& transform, const Vector3& min, const Vector3& max, Effect effect, Tr2DebugColor color ); + void DrawBox( Tr2DebugObjectReference owner, const Vector3& min, const Vector3& max, Effect effect, Tr2DebugColor color ); + void DrawBox( Tr2DebugObjectReference owner, const Matrix& transform, const Vector3& min, const Vector3& max, Effect effect, Tr2DebugColor color ); - void DrawSphere( Tr2DebugObjectReference owner, const Vector4& sphere, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawSphere( Tr2DebugObjectReference owner, const Vector3& center, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, const Vector3& center, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphere( Tr2DebugObjectReference owner, const Vector4& sphere, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphere( Tr2DebugObjectReference owner, const Vector3& center, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphere( Tr2DebugObjectReference owner, const Matrix& transform, const Vector3& center, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawCylinder( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawCylinder( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawCylinder( Tr2DebugObjectReference owner, const Vector3& cap0, const Vector3& cap1, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawCylinder( Tr2DebugObjectReference owner, const Matrix& transform, const Vector3& cap0, const Vector3& cap1, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); @@ -69,35 +69,35 @@ BLUE_CLASS( Tr2DebugRenderer ) : void DrawCone( Tr2DebugObjectReference owner, const Matrix& transform, float height, float angle, uint32_t segments, uint32_t coneSegments, Effect effect, Tr2DebugColor color ); - void DrawCapsule( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawCapsule( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawCapsule( Tr2DebugObjectReference owner, const Vector3& cap0, const Vector3& cap1, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawArrow( Tr2DebugObjectReference owner, const Vector3& start, const Vector3& end, float radius, float pointerLength, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawDoubleArrow( Tr2DebugObjectReference owner, const Vector3& start, const Vector3& end, float radius, float pointerLength, uint32_t segments, Effect effect, Tr2DebugColor color ); - void DrawSphereArrow( Tr2DebugObjectReference owner, const Vector3& center, const Vector3& direction, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); + void DrawSphereArrow( Tr2DebugObjectReference owner, const Vector3& center, const Vector3& direction, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ); void DrawAxis( Tr2DebugObjectReference owner, const Matrix& transform, Effect effect ); void DrawExtrusionShape( Tr2DebugObjectReference owner, const Matrix& transform, const Vector2* vertices, const Vector2* normals, uint32_t vertexCount, uint32_t segments, Effect effect, Tr2DebugColor color ); - // Draw a speaker like cone with sound waves emanating from it + // Draw a speaker like cone with sound waves emanating from it void DrawAudioSpeaker( Tr2DebugObjectReference owner, const Matrix& transform, float size, uint32_t segments, Effect effect, Tr2DebugColor color ); - + void DrawText( TriDebugFont font, const Vector3& pos, const Color& color, const char* msg, ... ); - + // needs to be called every frame before any Draw method - void BeginRender(); + void BeginRender(); // needs to be called every frame after all Draw methods - void EndRender( Tr2RenderContext& renderContext ); + void EndRender( Tr2RenderContext & renderContext ); void Pick( EvePendingPickingReadback & readback, bool synchronize, Tr2RenderContext& renderContext ); - - void SetSelectedObjects( const std::vector>& objects ); - void SetOptions( IRoot* owner, std::vector& options ); - std::vector GetOptions( IRoot* owner ) const; - void SetDefaultOptions( const std::vector& options ); + + void SetSelectedObjects( const std::vector>& objects ); + void SetOptions( IRoot * owner, std::vector & options ); + std::vector GetOptions( IRoot * owner ) const; + void SetDefaultOptions( const std::vector& options ); std::vector GetDefaultOptions() const; bool GetColorForOption( Color & color, const Tr2DebugRendererOption& option ) const; diff --git a/trinity/Tr2DebugRenderer_Blue.cpp b/trinity/Tr2DebugRenderer_Blue.cpp index 8ad445826..6578dd81e 100644 --- a/trinity/Tr2DebugRenderer_Blue.cpp +++ b/trinity/Tr2DebugRenderer_Blue.cpp @@ -23,66 +23,57 @@ std::vector GetDebugRenderOptions( IRoot* object ) BLUE_DEFINE( Tr2DebugRenderer ); -const Be::ClassInfo* Tr2DebugRenderer::ExposeToBlue() -{ - EXPOSURE_BEGIN( Tr2DebugRenderer, "" ) +const Be::ClassInfo* Tr2DebugRenderer::ExposeToBlue(){ + EXPOSURE_BEGIN( Tr2DebugRenderer, "" ) MAP_INTERFACE( Tr2DebugRenderer ) - MAP_METHOD_AND_WRAP( - "SetSelectedObjects", - SetSelectedObjects, - "Assign a set of selected objects. Object may render differently in selected mode\n" - ":param objects: selected objects, as a list of tuples (object, sub-object id)\n" - ) - MAP_METHOD_AND_WRAP( - "GetOptions", - GetOptions, - "Returns a list of currently enabled options for an object\n" - ":param obj: object\n" - ) - MAP_METHOD_AND_WRAP( - "SetOptions", - SetOptions, - "Assign a set of visualization options for a single object\n" - ":param obj: object\n" - ":param options: set of visualization options\n" - ) - MAP_METHOD_AND_WRAP( - "GetDefaultOptions", - GetDefaultOptions, - "Returns a list of fallback visualization options\n" - ) - MAP_METHOD_AND_WRAP( - "SetDefaultOptions", - SetDefaultOptions, - "Assign a list of fallback visualization options\n" - ":param options: set of visualization options\n" - ) - MAP_METHOD ( - "GetColorForOption", - PyGetColorForOption, - "Get color assigned to visulization option globally\n" - ":param option: the visualization option\n" - ":type: option: str\n" - ":returns: RGBA tuple each entry in range 0-1\n" - ":rtype: tuple[float, float, float, float]" - ) - MAP_METHOD_AND_WRAP( - "SetColorForOption", - SetColorForOption, - "Set color assigned to visulization option globally\n" - ":param option: the visualization option\n" - ":type: option: str\n" - ":param color: the color as a RGBA tuple each entry in range 0-1\n" - ":type: color: tuple[float, float, float, float]\n" - ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP( + "SetSelectedObjects", + SetSelectedObjects, + "Assign a set of selected objects. Object may render differently in selected mode\n" + ":param objects: selected objects, as a list of tuples (object, sub-object id)\n" ) + MAP_METHOD_AND_WRAP( + "GetOptions", + GetOptions, + "Returns a list of currently enabled options for an object\n" + ":param obj: object\n" ) + MAP_METHOD_AND_WRAP( + "SetOptions", + SetOptions, + "Assign a set of visualization options for a single object\n" + ":param obj: object\n" + ":param options: set of visualization options\n" ) + MAP_METHOD_AND_WRAP( + "GetDefaultOptions", + GetDefaultOptions, + "Returns a list of fallback visualization options\n" ) + MAP_METHOD_AND_WRAP( + "SetDefaultOptions", + SetDefaultOptions, + "Assign a list of fallback visualization options\n" + ":param options: set of visualization options\n" ) + MAP_METHOD( + "GetColorForOption", + PyGetColorForOption, + "Get color assigned to visulization option globally\n" + ":param option: the visualization option\n" + ":type: option: str\n" + ":returns: RGBA tuple each entry in range 0-1\n" + ":rtype: tuple[float, float, float, float]" ) + MAP_METHOD_AND_WRAP( + "SetColorForOption", + SetColorForOption, + "Set color assigned to visulization option globally\n" + ":param option: the visualization option\n" + ":type: option: str\n" + ":param color: the color as a RGBA tuple each entry in range 0-1\n" + ":type: color: tuple[float, float, float, float]\n" ) + EXPOSURE_END() } -MAP_FUNCTION_AND_WRAP( +MAP_FUNCTION_AND_WRAP( "GetDebugRenderOptions", GetDebugRenderOptions, "Returns possible debug rendering options for an object\n" ":param obj: any blue-exposed object\n" - ":returns: list of option names that can be set with Tr2DebugRenderer" - ); \ No newline at end of file + ":returns: list of option names that can be set with Tr2DebugRenderer" ); \ No newline at end of file diff --git a/trinity/Tr2DepthStencil.cpp b/trinity/Tr2DepthStencil.cpp index 299fe052f..5f5e135ec 100644 --- a/trinity/Tr2DepthStencil.cpp +++ b/trinity/Tr2DepthStencil.cpp @@ -5,12 +5,12 @@ using namespace Tr2RenderContextEnum; -Tr2DepthStencil::Tr2DepthStencil( IRoot* ) - :m_width( 0 ), +Tr2DepthStencil::Tr2DepthStencil( IRoot* ) : + m_width( 0 ), m_height( 0 ), m_format( Tr2RenderContextEnum::DSFMT_AUTO ), m_flags( Tr2RenderContextEnum::EX_NONE ) -{ +{ } Tr2DepthStencil::~Tr2DepthStencil() @@ -30,20 +30,20 @@ std::string Tr2DepthStencil::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- void Tr2DepthStencil::py__init__( - Be::OptionalWithDefaultValue width, - Be::OptionalWithDefaultValue height, - Be::OptionalWithDefaultValue format, - Be::OptionalWithDefaultValue msaaType, - Be::OptionalWithDefaultValue msaaQuality, - Be::OptionalWithDefaultValue flags ) + Be::OptionalWithDefaultValue width, + Be::OptionalWithDefaultValue height, + Be::OptionalWithDefaultValue format, + Be::OptionalWithDefaultValue msaaType, + Be::OptionalWithDefaultValue msaaQuality, + Be::OptionalWithDefaultValue flags ) { if( width && height && format ) { - Create( width, height, format, msaaType, msaaQuality, flags ); - } + Create( width, height, format, msaaType, msaaQuality, flags ); + } } long Tr2DepthStencil::Create( unsigned width, unsigned height, DepthStencilFormat dsFormat, unsigned msaaType, unsigned msaaQuality, Tr2RenderContextEnum::ExFlag flags ) @@ -77,7 +77,7 @@ Tr2TextureAL* Tr2DepthStencil::GetTexture() { if( m_depthStencil.IsValid() && Tr2GpuUsage::HasFlag( m_depthStencil.GetGpuUsage(), Tr2GpuUsage::SHADER_RESOURCE ) ) { - return &m_depthStencil; + return &m_depthStencil; } return nullptr; } @@ -95,7 +95,7 @@ bool Tr2DepthStencil::IsReadable() const bool Tr2DepthStencil::IsValid() const { return m_depthStencil.IsValid(); -} +} void Tr2DepthStencil::Destroy() { @@ -161,9 +161,9 @@ uint32_t Tr2DepthStencil::GetMsaaQuality() const return m_depthStencil.GetMsaaDesc().quality; } -uint32_t Tr2DepthStencil::GetMipCount() const -{ - return 1; +uint32_t Tr2DepthStencil::GetMipCount() const +{ + return 1; } // -------------------------------------------------------------------------------------- diff --git a/trinity/Tr2DepthStencil.h b/trinity/Tr2DepthStencil.h index 183a2d1ab..3ad0d56b4 100644 --- a/trinity/Tr2DepthStencil.h +++ b/trinity/Tr2DepthStencil.h @@ -16,14 +16,14 @@ BLUE_DECLARE( Tr2DepthStencil ); // This class replaces TriSurface for those use-cases where the // surface was just a depth stencil surface. // ------------------------------------------------------------- -BLUE_CLASS( Tr2DepthStencil ) : +BLUE_CLASS( Tr2DepthStencil ) : public ITr2TextureProvider, public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); - Tr2DepthStencil( IRoot* = 0 ); + Tr2DepthStencil( IRoot* = 0 ); ~Tr2DepthStencil(); virtual Tr2TextureAL* GetTexture(); @@ -37,12 +37,12 @@ BLUE_CLASS( Tr2DepthStencil ) : Be::OptionalWithDefaultValue msaaQuality, Be::OptionalWithDefaultValue flags ); - long Create( - unsigned width, - unsigned height, - Tr2RenderContextEnum::DepthStencilFormat format, - unsigned msaaType, - unsigned msaaQuality, + long Create( + unsigned width, + unsigned height, + Tr2RenderContextEnum::DepthStencilFormat format, + unsigned msaaType, + unsigned msaaQuality, Tr2RenderContextEnum::ExFlag flags = Tr2RenderContextEnum::EX_NONE ); bool IsValid() const; @@ -60,15 +60,22 @@ BLUE_CLASS( Tr2DepthStencil ) : Tr2TextureAL m_depthStencil; - operator Tr2TextureAL&() { return m_depthStencil; } // avoid m_depthStencil->m_depthStencil all over the place - operator const Tr2TextureAL&() const { return m_depthStencil; } + operator Tr2TextureAL&() + { + return m_depthStencil; + } // avoid m_depthStencil->m_depthStencil all over the place + operator const Tr2TextureAL&() const + { + return m_depthStencil; + } void SetName( const char* name ); std::string GetName() const; - + protected: virtual void ReleaseResources( TriStorage s ); virtual bool OnPrepareResources(); + private: bool HasALObject( int type, size_t object ); diff --git a/trinity/Tr2DepthStencil_Blue.cpp b/trinity/Tr2DepthStencil_Blue.cpp index 808ca2caa..011965bfa 100644 --- a/trinity/Tr2DepthStencil_Blue.cpp +++ b/trinity/Tr2DepthStencil_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( Tr2DepthStencil ); const Be::ClassInfo* Tr2DepthStencil::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2DepthStencil, "" ) + EXPOSURE_BEGIN( Tr2DepthStencil, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( Tr2DepthStencil ) @@ -23,11 +23,9 @@ const Be::ClassInfo* Tr2DepthStencil::ExposeToBlue() ":param format: buffer format (trinity.DEPTH_STENCIL_FORMAT)\n" ":param msaaType: sample count\n" ":param msaaQuality: MSAA quality\n" - ":param flags: combination of trinity.EX_FLAG" - ); + ":param flags: combination of trinity.EX_FLAG" ); - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "Create", Create, 1, @@ -37,8 +35,7 @@ const Be::ClassInfo* Tr2DepthStencil::ExposeToBlue() ":param format: buffer format (trinity.DEPTH_STENCIL_FORMAT)\n" ":param msaaType: sample count\n" ":param msaaQuality: MSAA quality" - ":param flags: trinity.EX_FLAG" - ) + ":param flags: trinity.EX_FLAG" ) MAP_ATTRIBUTE( "name", m_name, "", Be::PERSISTONLY ); MAP_PROPERTY( "name", GetName, SetName, "" ) @@ -55,21 +52,18 @@ const Be::ClassInfo* Tr2DepthStencil::ExposeToBlue() MAP_PROPERTY_READONLY( "isValid", IsValid, "is the graphics object successfully creaed" ); MAP_PROPERTY_READONLY( "isReadable", IsReadable, "can the DS be used as a texture" ); - MAP_METHOD_AND_WRAP( - "sharedHandle", - GetSharedHandle, - "sharedHandle" - ); + MAP_METHOD_AND_WRAP( + "sharedHandle", + GetSharedHandle, + "sharedHandle" ); - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasALObject", HasALObject, "Returns True iff Tr2DepthStencil contains a reference to passed AL object ID.\n" "Used for debugging along with trinity.GetLiveALResources.\n" ":param alType: AL object type (trinity.AL_OBJECT_TYPE)\n" - ":param alObject: AL object ID" - ) + ":param alObject: AL object ID" ) EXPOSURE_END() } diff --git a/trinity/Tr2DeviceResource.cpp b/trinity/Tr2DeviceResource.cpp index 339c3b4e6..3e2881c69 100644 --- a/trinity/Tr2DeviceResource.cpp +++ b/trinity/Tr2DeviceResource.cpp @@ -9,12 +9,12 @@ Tr2DeviceResource::Tr2DeviceResource() { - TriDevice::RegisterResource(this); + TriDevice::RegisterResource( this ); } Tr2DeviceResource::~Tr2DeviceResource() { - TriDevice::UnregisterResource(this); + TriDevice::UnregisterResource( this ); } @@ -31,5 +31,3 @@ bool Tr2DeviceResource::PrepareResources() return true; } - - diff --git a/trinity/Tr2DeviceResource.h b/trinity/Tr2DeviceResource.h index 1a963badc..44ed8b8d7 100644 --- a/trinity/Tr2DeviceResource.h +++ b/trinity/Tr2DeviceResource.h @@ -8,9 +8,9 @@ typedef unsigned int TriStorage; enum TriStorageFlags { - TRISTORAGE_VIDEOMEMORY = 1 << 0, // release all resources created on video card memory (D3DPOOL_DEFAULT) for device->Reset + TRISTORAGE_VIDEOMEMORY = 1 << 0, // release all resources created on video card memory (D3DPOOL_DEFAULT) for device->Reset TRISTORAGE_MANAGEDMEMORY = 1 << 1, // release all resources created in device memory (D3DPOOL_MANAGED) - TRISTORAGE_ALL = (1 << 2) - 1, + TRISTORAGE_ALL = ( 1 << 2 ) - 1, TRISTORAGE_FORCE_UINT = 0xFFFFFFFFu }; @@ -20,7 +20,7 @@ enum TriStorageFlags // encapsulated by one implementation of this interface. For instance, TriDevice contains multiple D3D // resources that need management. The most elegant solution is to have TriDevice implement this // interface and thus handle multiple D3D resources within each interface method. The complications from -// this are minimal and are easily outweighed by the convenience. +// this are minimal and are easily outweighed by the convenience. // When D3D resources need to be released, the TriDevice will use the interface below to properly handle it. // Note that this interface is not a proper Blue interface - it does not inherit from IRoot. Do not put // this as the first interface to inherit from in a class - Blue won't like it. @@ -31,29 +31,32 @@ class Tr2DeviceResource virtual ~Tr2DeviceResource(); #if TRINITYDEV - virtual void GetDescription( std::string& desc ) { desc = ""; } + virtual void GetDescription( std::string& desc ) + { + desc = ""; + } #endif - // This method will be called by the device when it needs to release resources. - // - TRISTORAGE_DEVICEMEMORY | TRISTORAGE_VIDEOMEMORY is used when the device itself is about to be + // This method will be called by the device when it needs to release resources. + // - TRISTORAGE_DEVICEMEMORY | TRISTORAGE_VIDEOMEMORY is used when the device itself is about to be // released. In this case all D3D resources should be released and their pointers set to NULL. - // - TRISTORAGE_VIDEOMEMORY is used when the device is being reset and all its resources in video - // memory need to be evicted. + // - TRISTORAGE_VIDEOMEMORY is used when the device is being reset and all its resources in video + // memory need to be evicted. virtual void ReleaseResources( TriStorage s ) = 0; - // This method is called to prepare all D3D resources for usage. - // - It should be used even the first time the Trinity class is created; to prepare the D3D resources. - // - If a Trinity class needs other 'child' objects to be prepared _before_ being able to _prepare_ - // itself then it should call PrepareResource on these child objects. This is always safe since - // preparation is only done for non-NULL D3D resources and repeatedly calling PrepareResource is + // This method is called to prepare all D3D resources for usage. + // - It should be used even the first time the Trinity class is created; to prepare the D3D resources. + // - If a Trinity class needs other 'child' objects to be prepared _before_ being able to _prepare_ + // itself then it should call PrepareResource on these child objects. This is always safe since + // preparation is only done for non-NULL D3D resources and repeatedly calling PrepareResource is // thus non-lethal. - bool PrepareResources(); + bool PrepareResources(); private: // This function should prepare any resources that are in the D3DPOOL_DEFAULT (or would prevent a device reset) // It should NEVER be called directly, other than from PrepareResources - // - When implementing this method only NULL valued D3D resources should be created and initialized. - // This is because a) a previous call to ReleaseResource might only have released resources in + // - When implementing this method only NULL valued D3D resources should be created and initialized. + // This is because a) a previous call to ReleaseResource might only have released resources in // VIDEOMEMORY, leaving other resources intact (and thus non-NULL), b) multiple call sites in one // frame. virtual bool OnPrepareResources() = 0; diff --git a/trinity/Tr2DirectInstanceData.cpp b/trinity/Tr2DirectInstanceData.cpp index de7a6a532..dd6355269 100644 --- a/trinity/Tr2DirectInstanceData.cpp +++ b/trinity/Tr2DirectInstanceData.cpp @@ -9,7 +9,7 @@ using namespace Tr2RenderContextEnum; // Description: // Tr2DirectInstanceData default constructor // -------------------------------------------------------------------------------------- -Tr2DirectInstanceData::Tr2DirectInstanceData(IRoot* lockobj) : +Tr2DirectInstanceData::Tr2DirectInstanceData( IRoot* lockobj ) : m_count( 0 ), m_stride( 0 ), m_vertexDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), @@ -19,7 +19,7 @@ Tr2DirectInstanceData::Tr2DirectInstanceData(IRoot* lockobj) : // -------------------------------------------------------------------------------------- // Description: -// Inherited from ITriDeviceResource interface. Invalidates vertex declaration, and +// Inherited from ITriDeviceResource interface. Invalidates vertex declaration, and // resets buffer to an invalid state. // -------------------------------------------------------------------------------------- void Tr2DirectInstanceData::ReleaseResources( TriStorage s ) @@ -123,9 +123,9 @@ unsigned Tr2DirectInstanceData::GetCount() const // -------------------------------------------------------------------------------------- // Description: -// Invalidates vertex buffer, prepares instance data for a new vertex format, -// ensures vertex declaration matches the layout provided, and that all attributes -// come from stream 0. +// Invalidates vertex buffer, prepares instance data for a new vertex format, +// ensures vertex declaration matches the layout provided, and that all attributes +// come from stream 0. // -------------------------------------------------------------------------------------- void Tr2DirectInstanceData::SetLayout( const Tr2VertexDefinition& layout ) { @@ -205,7 +205,7 @@ void* Tr2DirectInstanceData::GetData( unsigned count ) // -------------------------------------------------------------------------------------- // Description: -// Unmaps the vertex buffer that was mapped for writing, making data available to the GPU, +// Unmaps the vertex buffer that was mapped for writing, making data available to the GPU, // with an early exit if buffer is invalid. Should be called after data is modified. // -------------------------------------------------------------------------------------- void Tr2DirectInstanceData::UpdateData() diff --git a/trinity/Tr2DirectInstanceData.h b/trinity/Tr2DirectInstanceData.h index b3b5f2c8d..216bff64c 100644 --- a/trinity/Tr2DirectInstanceData.h +++ b/trinity/Tr2DirectInstanceData.h @@ -10,8 +10,8 @@ // -------------------------------------------------------------------------------------- // Description: -// Tr2DirectInstanceData is an instance data provider. Unlike Tr2RuntimeInstanceData, -// it does not maintain a CPU copy and uses direct GPU buffer access for write-often +// Tr2DirectInstanceData is an instance data provider. Unlike Tr2RuntimeInstanceData, +// it does not maintain a CPU copy and uses direct GPU buffer access for write-often // scenarios. // See Also: // Tr2RuntimeInstanceData @@ -24,6 +24,7 @@ BLUE_CLASS( Tr2DirectInstanceData ) : EXPOSE_TO_BLUE(); Tr2DirectInstanceData( IRoot* lockobj = 0 ); void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); diff --git a/trinity/Tr2DirectInstanceData_Blue.cpp b/trinity/Tr2DirectInstanceData_Blue.cpp index f9697c3a7..9db0e6ca3 100644 --- a/trinity/Tr2DirectInstanceData_Blue.cpp +++ b/trinity/Tr2DirectInstanceData_Blue.cpp @@ -15,14 +15,12 @@ const Be::ClassInfo* Tr2DirectInstanceData::ExposeToBlue() MAP_PROPERTY_READONLY( "count", GetCount, - "Number of instances" - ) + "Number of instances" ) MAP_METHOD_AND_WRAP( "SetBoundingBox", SetBoundingBox, - "Assign a bounding box explicitly" - ) + "Assign a bounding box explicitly" ) MAP_ATTRIBUTE( "aabbMin", m_aabb.m_min, "Minimum of the AABB", Be::READ ) diff --git a/trinity/Tr2DxtCompressor.cpp b/trinity/Tr2DxtCompressor.cpp index fc18c6f18..3627d88b8 100644 --- a/trinity/Tr2DxtCompressor.cpp +++ b/trinity/Tr2DxtCompressor.cpp @@ -5,16 +5,16 @@ #include "Tr2DxtCompressor.h" #include -typedef unsigned short word; -typedef unsigned int dword; +typedef unsigned short word; +typedef unsigned int dword; -#define INSET_COLOR_SHIFT 4 // inset color bounding box -#define INSET_ALPHA_SHIFT 5 // inset alpha bounding box +#define INSET_COLOR_SHIFT 4 // inset color bounding box +#define INSET_ALPHA_SHIFT 5 // inset alpha bounding box -#define C565_5_MASK 0xF8 // 0xFF minus last three bits -#define C565_6_MASK 0xFC // 0xFF minus last two bits +#define C565_5_MASK 0xF8 // 0xFF minus last three bits +#define C565_6_MASK 0xFC // 0xFF minus last two bits -#define NVIDIA_G7X_HARDWARE_BUG_FIX // keep the colors sorted as: max, min +#define NVIDIA_G7X_HARDWARE_BUG_FIX // keep the colors sorted as: max, min /* RGB <-> YCoCg @@ -29,54 +29,81 @@ B = [ 1 -1 -1] [Cg] */ -#define RGB_TO_YCOCG_Y( r, g, b ) ( ( ( r + (g<<1) + b ) + 2 ) >> 2 ) -#define RGB_TO_YCOCG_CO( r, g, b ) ( ( ( (r<<1) - (b<<1) ) + 2 ) >> 2 ) -#define RGB_TO_YCOCG_CG( r, g, b ) ( ( ( - r + (g<<1) - b ) + 2 ) >> 2 ) - -#define COCG_TO_R( co, cg ) ( co - cg ) -#define COCG_TO_G( co, cg ) ( cg ) -#define COCG_TO_B( co, cg ) ( - co - cg ) - -uint8_t CLAMP_BYTE( int x ) { return ( (x) < 0 ? (0) : ( (x) > 255 ? 255 : (x) ) ); } - -void ConvertRGBToCoCg_Y( uint8_t *image, int width, int height ) { - for ( int i = 0; i < width * height; i++ ) { - int r = image[i*4+0]; - int g = image[i*4+1]; - int b = image[i*4+2]; - int a = image[i*4+3]; - image[i*4+0] = CLAMP_BYTE( RGB_TO_YCOCG_CO( r, g, b ) + 128 ); - image[i*4+1] = CLAMP_BYTE( RGB_TO_YCOCG_CG( r, g, b ) + 128 ); - image[i*4+2] = a; - image[i*4+3] = CLAMP_BYTE( RGB_TO_YCOCG_Y( r, g, b ) ); +#define RGB_TO_YCOCG_Y( r, g, b ) ( ( ( r + ( g << 1 ) + b ) + 2 ) >> 2 ) +#define RGB_TO_YCOCG_CO( r, g, b ) ( ( ( ( r << 1 ) - ( b << 1 ) ) + 2 ) >> 2 ) +#define RGB_TO_YCOCG_CG( r, g, b ) ( ( ( -r + ( g << 1 ) - b ) + 2 ) >> 2 ) + +#define COCG_TO_R( co, cg ) ( co - cg ) +#define COCG_TO_G( co, cg ) ( cg ) +#define COCG_TO_B( co, cg ) ( -co - cg ) + +uint8_t CLAMP_BYTE( int x ) +{ + return ( ( x ) < 0 ? ( 0 ) : ( ( x ) > 255 ? 255 : ( x ) ) ); +} + +void ConvertRGBToCoCg_Y( uint8_t* image, int width, int height ) +{ + for( int i = 0; i < width * height; i++ ) + { + int r = image[i * 4 + 0]; + int g = image[i * 4 + 1]; + int b = image[i * 4 + 2]; + int a = image[i * 4 + 3]; + image[i * 4 + 0] = CLAMP_BYTE( RGB_TO_YCOCG_CO( r, g, b ) + 128 ); + image[i * 4 + 1] = CLAMP_BYTE( RGB_TO_YCOCG_CG( r, g, b ) + 128 ); + image[i * 4 + 2] = a; + image[i * 4 + 3] = CLAMP_BYTE( RGB_TO_YCOCG_Y( r, g, b ) ); } } -void ConvertCoCg_YToRGB( uint8_t *image, int width, int height ) { - for ( int i = 0; i < width * height; i++ ) { - int y = image[i*4+3]; - int co = image[i*4+0] - 128; - int cg = image[i*4+1] - 128; - int a = image[i*4+2]; - image[i*4+0] = CLAMP_BYTE( y + COCG_TO_R( co, cg ) ); - image[i*4+1] = CLAMP_BYTE( y + COCG_TO_G( co, cg ) ); - image[i*4+2] = CLAMP_BYTE( y + COCG_TO_B( co, cg ) ); - image[i*4+3] = a; +void ConvertCoCg_YToRGB( uint8_t* image, int width, int height ) +{ + for( int i = 0; i < width * height; i++ ) + { + int y = image[i * 4 + 3]; + int co = image[i * 4 + 0] - 128; + int cg = image[i * 4 + 1] - 128; + int a = image[i * 4 + 2]; + image[i * 4 + 0] = CLAMP_BYTE( y + COCG_TO_R( co, cg ) ); + image[i * 4 + 1] = CLAMP_BYTE( y + COCG_TO_G( co, cg ) ); + image[i * 4 + 2] = CLAMP_BYTE( y + COCG_TO_B( co, cg ) ); + image[i * 4 + 3] = a; } } -void GetMinMaxColors( const uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { +void GetMinMaxColors( const uint8_t* colorBlock, uint8_t* minColor, uint8_t* maxColor ) +{ int i; uint8_t inset[3]; minColor[0] = minColor[1] = minColor[2] = 255; maxColor[0] = maxColor[1] = maxColor[2] = 0; - for ( i = 0; i < 16; i++ ) { - if ( colorBlock[i*4+0] < minColor[0] ) { minColor[0] = colorBlock[i*4+0]; } - if ( colorBlock[i*4+1] < minColor[1] ) { minColor[1] = colorBlock[i*4+1]; } - if ( colorBlock[i*4+2] < minColor[2] ) { minColor[2] = colorBlock[i*4+2]; } - if ( colorBlock[i*4+0] > maxColor[0] ) { maxColor[0] = colorBlock[i*4+0]; } - if ( colorBlock[i*4+1] > maxColor[1] ) { maxColor[1] = colorBlock[i*4+1]; } - if ( colorBlock[i*4+2] > maxColor[2] ) { maxColor[2] = colorBlock[i*4+2]; } + for( i = 0; i < 16; i++ ) + { + if( colorBlock[i * 4 + 0] < minColor[0] ) + { + minColor[0] = colorBlock[i * 4 + 0]; + } + if( colorBlock[i * 4 + 1] < minColor[1] ) + { + minColor[1] = colorBlock[i * 4 + 1]; + } + if( colorBlock[i * 4 + 2] < minColor[2] ) + { + minColor[2] = colorBlock[i * 4 + 2]; + } + if( colorBlock[i * 4 + 0] > maxColor[0] ) + { + maxColor[0] = colorBlock[i * 4 + 0]; + } + if( colorBlock[i * 4 + 1] > maxColor[1] ) + { + maxColor[1] = colorBlock[i * 4 + 1]; + } + if( colorBlock[i * 4 + 2] > maxColor[2] ) + { + maxColor[2] = colorBlock[i * 4 + 2]; + } } inset[0] = ( maxColor[0] - minColor[0] ) >> INSET_COLOR_SHIFT; inset[1] = ( maxColor[1] - minColor[1] ) >> INSET_COLOR_SHIFT; @@ -89,20 +116,46 @@ void GetMinMaxColors( const uint8_t *colorBlock, uint8_t *minColor, uint8_t *max maxColor[2] = ( maxColor[2] >= inset[2] ) ? maxColor[2] - inset[2] : 0; } -void GetMinMaxColorsWithAlpha( const uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { +void GetMinMaxColorsWithAlpha( const uint8_t* colorBlock, uint8_t* minColor, uint8_t* maxColor ) +{ int i; uint8_t inset[4]; minColor[0] = minColor[1] = minColor[2] = minColor[3] = 255; maxColor[0] = maxColor[1] = maxColor[2] = maxColor[3] = 0; - for ( i = 0; i < 16; i++ ) { - if ( colorBlock[i*4+0] < minColor[0] ) { minColor[0] = colorBlock[i*4+0]; } - if ( colorBlock[i*4+1] < minColor[1] ) { minColor[1] = colorBlock[i*4+1]; } - if ( colorBlock[i*4+2] < minColor[2] ) { minColor[2] = colorBlock[i*4+2]; } - if ( colorBlock[i*4+3] < minColor[3] ) { minColor[3] = colorBlock[i*4+3]; } - if ( colorBlock[i*4+0] > maxColor[0] ) { maxColor[0] = colorBlock[i*4+0]; } - if ( colorBlock[i*4+1] > maxColor[1] ) { maxColor[1] = colorBlock[i*4+1]; } - if ( colorBlock[i*4+2] > maxColor[2] ) { maxColor[2] = colorBlock[i*4+2]; } - if ( colorBlock[i*4+3] > maxColor[3] ) { maxColor[3] = colorBlock[i*4+3]; } + for( i = 0; i < 16; i++ ) + { + if( colorBlock[i * 4 + 0] < minColor[0] ) + { + minColor[0] = colorBlock[i * 4 + 0]; + } + if( colorBlock[i * 4 + 1] < minColor[1] ) + { + minColor[1] = colorBlock[i * 4 + 1]; + } + if( colorBlock[i * 4 + 2] < minColor[2] ) + { + minColor[2] = colorBlock[i * 4 + 2]; + } + if( colorBlock[i * 4 + 3] < minColor[3] ) + { + minColor[3] = colorBlock[i * 4 + 3]; + } + if( colorBlock[i * 4 + 0] > maxColor[0] ) + { + maxColor[0] = colorBlock[i * 4 + 0]; + } + if( colorBlock[i * 4 + 1] > maxColor[1] ) + { + maxColor[1] = colorBlock[i * 4 + 1]; + } + if( colorBlock[i * 4 + 2] > maxColor[2] ) + { + maxColor[2] = colorBlock[i * 4 + 2]; + } + if( colorBlock[i * 4 + 3] > maxColor[3] ) + { + maxColor[3] = colorBlock[i * 4 + 3]; + } } inset[0] = ( maxColor[0] - minColor[0] ) >> INSET_COLOR_SHIFT; inset[1] = ( maxColor[1] - minColor[1] ) >> INSET_COLOR_SHIFT; @@ -118,44 +171,51 @@ void GetMinMaxColorsWithAlpha( const uint8_t *colorBlock, uint8_t *minColor, uin maxColor[3] = ( maxColor[3] >= inset[3] ) ? maxColor[3] - inset[3] : 0; } -word ColorTo565( const uint8_t *color ) { +word ColorTo565( const uint8_t* color ) +{ // BGR - return ( ( color[ 2 ] >> 3 ) << 11 ) | ( ( color[ 1 ] >> 2 ) << 5 ) | ( color[ 0 ] >> 3 ); + return ( ( color[2] >> 3 ) << 11 ) | ( ( color[1] >> 2 ) << 5 ) | ( color[0] >> 3 ); } -word NormalYTo565( uint8_t y ) { +word NormalYTo565( uint8_t y ) +{ return ( ( y >> 2 ) << 5 ); } -void EmitByte( uint8_t b, uint8_t** outBuff ) { +void EmitByte( uint8_t b, uint8_t** outBuff ) +{ **outBuff = b; *outBuff += 1; } -void EmitWord( word s, uint8_t** outBuff ) { - **outBuff = ( s >> 0 ) & 255; - *(*outBuff+1) = ( s >> 8 ) & 255; +void EmitWord( word s, uint8_t** outBuff ) +{ + **outBuff = ( s >> 0 ) & 255; + *( *outBuff + 1 ) = ( s >> 8 ) & 255; *outBuff += 2; } -void EmitDoubleWord( dword i, uint8_t** outBuff ) { - **outBuff = ( i >> 0 ) & 255; - *(*outBuff+1) = ( i >> 8 ) & 255; - *(*outBuff+2) = ( i >> 16 ) & 255; - *(*outBuff+3) = ( i >> 24 ) & 255; +void EmitDoubleWord( dword i, uint8_t** outBuff ) +{ + **outBuff = ( i >> 0 ) & 255; + *( *outBuff + 1 ) = ( i >> 8 ) & 255; + *( *outBuff + 2 ) = ( i >> 16 ) & 255; + *( *outBuff + 3 ) = ( i >> 24 ) & 255; *outBuff += 4; } -void ExtractBlock( const uint8_t *inPtr, const int width, uint8_t *colorBlock ) { - for ( int j = 0; j < 4; j++ ) { - memcpy( &colorBlock[j*4*4], inPtr, 4*4 ); +void ExtractBlock( const uint8_t* inPtr, const int width, uint8_t* colorBlock ) +{ + for( int j = 0; j < 4; j++ ) + { + memcpy( &colorBlock[j * 4 * 4], inPtr, 4 * 4 ); inPtr += width * 4; } } // Extract a block, but blank out blue, and swap red and alpha, on the fly. -void ExtractBlockDXT5N( const uint8_t *inPtr, const int width, uint8_t *colorBlock ) -{ +void ExtractBlockDXT5N( const uint8_t* inPtr, const int width, uint8_t* colorBlock ) +{ for( int j = 0; j != 4; ++j ) { const uint8_t* src = inPtr; @@ -166,52 +226,66 @@ void ExtractBlockDXT5N( const uint8_t *inPtr, const int width, uint8_t *colorBlo *colorBlock++ = src[3]; *colorBlock++ = src[2]; } - + inPtr += width * 4; } } -void GetMinMaxYCoCg( uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { +void GetMinMaxYCoCg( uint8_t* colorBlock, uint8_t* minColor, uint8_t* maxColor ) +{ minColor[0] = minColor[1] = minColor[2] = minColor[3] = 255; maxColor[0] = maxColor[1] = maxColor[2] = maxColor[3] = 0; - for ( int i = 0; i < 16; i++ ) { - if ( colorBlock[i*4+0] < minColor[0] ) { - minColor[0] = colorBlock[i*4+0]; + for( int i = 0; i < 16; i++ ) + { + if( colorBlock[i * 4 + 0] < minColor[0] ) + { + minColor[0] = colorBlock[i * 4 + 0]; } - if ( colorBlock[i*4+1] < minColor[1] ) { - minColor[1] = colorBlock[i*4+1]; + if( colorBlock[i * 4 + 1] < minColor[1] ) + { + minColor[1] = colorBlock[i * 4 + 1]; } - if ( colorBlock[i*4+2] < minColor[2] ) { - minColor[2] = colorBlock[i*4+2]; + if( colorBlock[i * 4 + 2] < minColor[2] ) + { + minColor[2] = colorBlock[i * 4 + 2]; } - if ( colorBlock[i*4+3] < minColor[3] ) { - minColor[3] = colorBlock[i*4+3]; + if( colorBlock[i * 4 + 3] < minColor[3] ) + { + minColor[3] = colorBlock[i * 4 + 3]; } - if ( colorBlock[i*4+0] > maxColor[0] ) { - maxColor[0] = colorBlock[i*4+0]; + if( colorBlock[i * 4 + 0] > maxColor[0] ) + { + maxColor[0] = colorBlock[i * 4 + 0]; } - if ( colorBlock[i*4+1] > maxColor[1] ) { - maxColor[1] = colorBlock[i*4+1]; + if( colorBlock[i * 4 + 1] > maxColor[1] ) + { + maxColor[1] = colorBlock[i * 4 + 1]; } - if ( colorBlock[i*4+2] > maxColor[2] ) { - maxColor[2] = colorBlock[i*4+2]; + if( colorBlock[i * 4 + 2] > maxColor[2] ) + { + maxColor[2] = colorBlock[i * 4 + 2]; } - if ( colorBlock[i*4+3] > maxColor[3] ) { - maxColor[3] = colorBlock[i*4+3]; + if( colorBlock[i * 4 + 3] > maxColor[3] ) + { + maxColor[3] = colorBlock[i * 4 + 3]; } } } -void ScaleYCoCg( uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { +void ScaleYCoCg( uint8_t* colorBlock, uint8_t* minColor, uint8_t* maxColor ) +{ int m0 = abs( minColor[0] - 128 ); int m1 = abs( minColor[1] - 128 ); int m2 = abs( maxColor[0] - 128 ); int m3 = abs( maxColor[1] - 128 ); - if ( m1 > m0 ) m0 = m1; - if ( m3 > m2 ) m2 = m3; - if ( m2 > m0 ) m0 = m2; + if( m1 > m0 ) + m0 = m1; + if( m3 > m2 ) + m2 = m3; + if( m2 > m0 ) + m0 = m2; const int s0 = 128 / 2 - 1; const int s1 = 128 / 4 - 1; @@ -228,20 +302,22 @@ void ScaleYCoCg( uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { maxColor[1] = ( maxColor[1] - 128 ) * scale + 128; maxColor[2] = ( scale - 1 ) << 3; - for ( int i = 0; i < 16; i++ ) { - colorBlock[i*4+0] = ( colorBlock[i*4+0] - 128 ) * scale + 128; - colorBlock[i*4+1] = ( colorBlock[i*4+1] - 128 ) * scale + 128; + for( int i = 0; i < 16; i++ ) + { + colorBlock[i * 4 + 0] = ( colorBlock[i * 4 + 0] - 128 ) * scale + 128; + colorBlock[i * 4 + 1] = ( colorBlock[i * 4 + 1] - 128 ) * scale + 128; } } -void InsetYCoCgBBox( uint8_t *minColor, uint8_t *maxColor ) { +void InsetYCoCgBBox( uint8_t* minColor, uint8_t* maxColor ) +{ int inset[4]; int mini[4]; int maxi[4]; - inset[0] = ( maxColor[0] - minColor[0] ) - ((1<<(INSET_COLOR_SHIFT-1))-1); - inset[1] = ( maxColor[1] - minColor[1] ) - ((1<<(INSET_COLOR_SHIFT-1))-1); - inset[3] = ( maxColor[3] - minColor[3] ) - ((1<<(INSET_ALPHA_SHIFT-1))-1); + inset[0] = ( maxColor[0] - minColor[0] ) - ( ( 1 << ( INSET_COLOR_SHIFT - 1 ) ) - 1 ); + inset[1] = ( maxColor[1] - minColor[1] ) - ( ( 1 << ( INSET_COLOR_SHIFT - 1 ) ) - 1 ); + inset[3] = ( maxColor[3] - minColor[3] ) - ( ( 1 << ( INSET_ALPHA_SHIFT - 1 ) ) - 1 ); mini[0] = ( ( minColor[0] << INSET_COLOR_SHIFT ) + inset[0] ) >> INSET_COLOR_SHIFT; mini[1] = ( ( minColor[1] << INSET_COLOR_SHIFT ) + inset[1] ) >> INSET_COLOR_SHIFT; @@ -268,14 +344,16 @@ void InsetYCoCgBBox( uint8_t *minColor, uint8_t *maxColor ) { maxColor[3] = maxi[3]; } -void SelectYCoCgDiagonal( const uint8_t *colorBlock, uint8_t *minColor, uint8_t *maxColor ) { - uint8_t mid0 = ( (int) minColor[0] + maxColor[0] + 1 ) >> 1; - uint8_t mid1 = ( (int) minColor[1] + maxColor[1] + 1 ) >> 1; +void SelectYCoCgDiagonal( const uint8_t* colorBlock, uint8_t* minColor, uint8_t* maxColor ) +{ + uint8_t mid0 = ( (int)minColor[0] + maxColor[0] + 1 ) >> 1; + uint8_t mid1 = ( (int)minColor[1] + maxColor[1] + 1 ) >> 1; uint8_t side = 0; - for ( int i = 0; i < 16; i++ ) { - uint8_t b0 = colorBlock[i*4+0] >= mid0; - uint8_t b1 = colorBlock[i*4+1] >= mid1; + for( int i = 0; i < 16; i++ ) + { + uint8_t b0 = colorBlock[i * 4 + 0] >= mid0; + uint8_t b1 = colorBlock[i * 4 + 1] >= mid1; side += ( b0 ^ b1 ); } @@ -287,7 +365,7 @@ void SelectYCoCgDiagonal( const uint8_t *colorBlock, uint8_t *minColor, uint8_t uint8_t c0 = minColor[1]; uint8_t c1 = maxColor[1]; - + c0 ^= c1; mask &= c0; c1 ^= mask; @@ -297,7 +375,8 @@ void SelectYCoCgDiagonal( const uint8_t *colorBlock, uint8_t *minColor, uint8_t maxColor[1] = c1; } -void EmitAlphaIndices( const uint8_t *colorBlock, const uint8_t minAlpha, const uint8_t maxAlpha, uint8_t** outBuff ) { +void EmitAlphaIndices( const uint8_t* colorBlock, const uint8_t minAlpha, const uint8_t maxAlpha, uint8_t** outBuff ) +{ CCP_ASSERT( maxAlpha >= minAlpha ); @@ -316,8 +395,9 @@ void EmitAlphaIndices( const uint8_t *colorBlock, const uint8_t minAlpha, const ab6 = ( 2 * maxAlpha + 5 * minAlpha ) / ALPHA_RANGE + mid; ab7 = ( 1 * maxAlpha + 6 * minAlpha ) / ALPHA_RANGE + mid; - for ( int i = 0; i < 16; i++ ) { - uint8_t a = colorBlock[i*4+3]; + for( int i = 0; i < 16; i++ ) + { + uint8_t a = colorBlock[i * 4 + 3]; int b1 = ( a <= ab1 ); int b2 = ( a <= ab2 ); int b3 = ( a <= ab3 ); @@ -329,16 +409,17 @@ void EmitAlphaIndices( const uint8_t *colorBlock, const uint8_t minAlpha, const indexes[i] = index ^ ( 2 > index ); } - EmitByte( (indexes[ 0] >> 0) | (indexes[ 1] << 3) | (indexes[ 2] << 6), outBuff ); - EmitByte( (indexes[ 2] >> 2) | (indexes[ 3] << 1) | (indexes[ 4] << 4) | (indexes[ 5] << 7), outBuff ); - EmitByte( (indexes[ 5] >> 1) | (indexes[ 6] << 2) | (indexes[ 7] << 5), outBuff ); + EmitByte( ( indexes[0] >> 0 ) | ( indexes[1] << 3 ) | ( indexes[2] << 6 ), outBuff ); + EmitByte( ( indexes[2] >> 2 ) | ( indexes[3] << 1 ) | ( indexes[4] << 4 ) | ( indexes[5] << 7 ), outBuff ); + EmitByte( ( indexes[5] >> 1 ) | ( indexes[6] << 2 ) | ( indexes[7] << 5 ), outBuff ); - EmitByte( (indexes[ 8] >> 0) | (indexes[ 9] << 3) | (indexes[10] << 6), outBuff ); - EmitByte( (indexes[10] >> 2) | (indexes[11] << 1) | (indexes[12] << 4) | (indexes[13] << 7), outBuff ); - EmitByte( (indexes[13] >> 1) | (indexes[14] << 2) | (indexes[15] << 5), outBuff ); + EmitByte( ( indexes[8] >> 0 ) | ( indexes[9] << 3 ) | ( indexes[10] << 6 ), outBuff ); + EmitByte( ( indexes[10] >> 2 ) | ( indexes[11] << 1 ) | ( indexes[12] << 4 ) | ( indexes[13] << 7 ), outBuff ); + EmitByte( ( indexes[13] >> 1 ) | ( indexes[14] << 2 ) | ( indexes[15] << 5 ), outBuff ); } -void EmitColorIndices( const uint8_t *colorBlock, const uint8_t *minColor, const uint8_t *maxColor, uint8_t** outBuff ) { +void EmitColorIndices( const uint8_t* colorBlock, const uint8_t* minColor, const uint8_t* maxColor, uint8_t** outBuff ) +{ word colors[4][4]; dword result = 0; colors[0][0] = ( maxColor[0] & C565_5_MASK ) | ( maxColor[0] >> 5 ); @@ -353,10 +434,11 @@ void EmitColorIndices( const uint8_t *colorBlock, const uint8_t *minColor, const colors[3][0] = ( 1 * colors[0][0] + 2 * colors[1][0] ) / 3; colors[3][1] = ( 1 * colors[0][1] + 2 * colors[1][1] ) / 3; colors[3][2] = ( 1 * colors[0][2] + 2 * colors[1][2] ) / 3; - for ( int i = 15; i >= 0; i-- ) { - int c0 = colorBlock[i*4+0]; - int c1 = colorBlock[i*4+1]; - int c2 = colorBlock[i*4+2]; + for( int i = 15; i >= 0; i-- ) + { + int c0 = colorBlock[i * 4 + 0]; + int c1 = colorBlock[i * 4 + 1]; + int c2 = colorBlock[i * 4 + 2]; int d0 = abs( colors[0][0] - c0 ) + abs( colors[0][1] - c1 ) + abs( colors[0][2] - c2 ); int d1 = abs( colors[1][0] - c0 ) + abs( colors[1][1] - c1 ) + abs( colors[1][2] - c2 ); int d2 = abs( colors[2][0] - c0 ) + abs( colors[2][1] - c1 ) + abs( colors[2][2] - c2 ); @@ -373,34 +455,41 @@ void EmitColorIndices( const uint8_t *colorBlock, const uint8_t *minColor, const } EmitDoubleWord( result, outBuff ); } -void GetMinMaxNormalsBBox( const uint8_t *block, uint8_t *minNormal, uint8_t *maxNormal ) { +void GetMinMaxNormalsBBox( const uint8_t* block, uint8_t* minNormal, uint8_t* maxNormal ) +{ minNormal[0] = minNormal[1] = 255; maxNormal[0] = maxNormal[1] = 0; - for ( int i = 0; i < 16; i++ ) { - if ( block[i*4+2] < minNormal[0] ) { - minNormal[0] = block[i*4+2]; + for( int i = 0; i < 16; i++ ) + { + if( block[i * 4 + 2] < minNormal[0] ) + { + minNormal[0] = block[i * 4 + 2]; } - if ( block[i*4+1] < minNormal[1] ) { - minNormal[1] = block[i*4+1]; + if( block[i * 4 + 1] < minNormal[1] ) + { + minNormal[1] = block[i * 4 + 1]; } - if ( block[i*4+2] > maxNormal[0] ) { - maxNormal[0] = block[i*4+2]; + if( block[i * 4 + 2] > maxNormal[0] ) + { + maxNormal[0] = block[i * 4 + 2]; } - if ( block[i*4+1] > maxNormal[1] ) { - maxNormal[1] = block[i*4+1]; + if( block[i * 4 + 1] > maxNormal[1] ) + { + maxNormal[1] = block[i * 4 + 1]; } } } -void InsetNormalsBBoxDXT5( uint8_t *minNormal, uint8_t *maxNormal ) { +void InsetNormalsBBoxDXT5( uint8_t* minNormal, uint8_t* maxNormal ) +{ int inset[4]; int mini[4]; int maxi[4]; - inset[0] = ( maxNormal[0] - minNormal[0] ) - ((1<<(INSET_ALPHA_SHIFT-1))-1); - inset[1] = ( maxNormal[1] - minNormal[1] ) - ((1<<(INSET_COLOR_SHIFT-1))-1); + inset[0] = ( maxNormal[0] - minNormal[0] ) - ( ( 1 << ( INSET_ALPHA_SHIFT - 1 ) ) - 1 ); + inset[1] = ( maxNormal[1] - minNormal[1] ) - ( ( 1 << ( INSET_COLOR_SHIFT - 1 ) ) - 1 ); mini[0] = ( ( minNormal[0] << INSET_ALPHA_SHIFT ) + inset[0] ) >> INSET_ALPHA_SHIFT; mini[1] = ( ( minNormal[1] << INSET_COLOR_SHIFT ) + inset[1] ) >> INSET_COLOR_SHIFT; @@ -421,13 +510,14 @@ void InsetNormalsBBoxDXT5( uint8_t *minNormal, uint8_t *maxNormal ) { maxNormal[1] = ( maxi[1] & C565_6_MASK ) | ( maxi[1] >> 6 ); } -void InsetNormalsBBox3Dc( uint8_t *minNormal, uint8_t *maxNormal ) { +void InsetNormalsBBox3Dc( uint8_t* minNormal, uint8_t* maxNormal ) +{ int inset[4]; int mini[4]; int maxi[4]; - inset[0] = ( maxNormal[0] - minNormal[0] ) - ((1<<(INSET_ALPHA_SHIFT-1))-1); - inset[1] = ( maxNormal[1] - minNormal[1] ) - ((1<<(INSET_ALPHA_SHIFT-1))-1); + inset[0] = ( maxNormal[0] - minNormal[0] ) - ( ( 1 << ( INSET_ALPHA_SHIFT - 1 ) ) - 1 ); + inset[1] = ( maxNormal[1] - minNormal[1] ) - ( ( 1 << ( INSET_ALPHA_SHIFT - 1 ) ) - 1 ); mini[0] = ( ( minNormal[0] << INSET_ALPHA_SHIFT ) + inset[0] ) >> INSET_ALPHA_SHIFT; mini[1] = ( ( minNormal[1] << INSET_ALPHA_SHIFT ) + inset[1] ) >> INSET_ALPHA_SHIFT; @@ -448,7 +538,8 @@ void InsetNormalsBBox3Dc( uint8_t *minNormal, uint8_t *maxNormal ) { maxNormal[1] = maxi[1]; } -void EmitAlphaIndicesForNormals( const uint8_t *block, const int offset, const uint8_t minAlpha, const uint8_t maxAlpha, uint8_t** outBuff ) { +void EmitAlphaIndicesForNormals( const uint8_t* block, const int offset, const uint8_t minAlpha, const uint8_t maxAlpha, uint8_t** outBuff ) +{ uint8_t mid = ( maxAlpha - minAlpha ) / ( 2 * 7 ); uint8_t ab1 = maxAlpha - mid; @@ -462,8 +553,9 @@ void EmitAlphaIndicesForNormals( const uint8_t *block, const int offset, const u block += offset; uint8_t indices[16]; - for ( int i = 0; i < 16; i++ ) { - uint8_t a = block[i*4]; + for( int i = 0; i < 16; i++ ) + { + uint8_t a = block[i * 4]; int b1 = ( a >= ab1 ); int b2 = ( a >= ab2 ); int b3 = ( a >= ab3 ); @@ -475,16 +567,17 @@ void EmitAlphaIndicesForNormals( const uint8_t *block, const int offset, const u indices[i] = index ^ ( 2 > index ); } - EmitByte( (indices[ 0] >> 0) | (indices[ 1] << 3) | (indices[ 2] << 6), outBuff ); - EmitByte( (indices[ 2] >> 2) | (indices[ 3] << 1) | (indices[ 4] << 4) | (indices[ 5] << 7), outBuff ); - EmitByte( (indices[ 5] >> 1) | (indices[ 6] << 2) | (indices[ 7] << 5), outBuff ); + EmitByte( ( indices[0] >> 0 ) | ( indices[1] << 3 ) | ( indices[2] << 6 ), outBuff ); + EmitByte( ( indices[2] >> 2 ) | ( indices[3] << 1 ) | ( indices[4] << 4 ) | ( indices[5] << 7 ), outBuff ); + EmitByte( ( indices[5] >> 1 ) | ( indices[6] << 2 ) | ( indices[7] << 5 ), outBuff ); - EmitByte( (indices[ 8] >> 0) | (indices[ 9] << 3) | (indices[10] << 6), outBuff ); - EmitByte( (indices[10] >> 2) | (indices[11] << 1) | (indices[12] << 4) | (indices[13] << 7), outBuff ); - EmitByte( (indices[13] >> 1) | (indices[14] << 2) | (indices[15] << 5), outBuff ); + EmitByte( ( indices[8] >> 0 ) | ( indices[9] << 3 ) | ( indices[10] << 6 ), outBuff ); + EmitByte( ( indices[10] >> 2 ) | ( indices[11] << 1 ) | ( indices[12] << 4 ) | ( indices[13] << 7 ), outBuff ); + EmitByte( ( indices[13] >> 1 ) | ( indices[14] << 2 ) | ( indices[15] << 5 ), outBuff ); } -void EmitGreenIndices( const uint8_t *block, const int offset, const uint8_t minGreen, const uint8_t maxGreen, uint8_t** outBuff ) { +void EmitGreenIndices( const uint8_t* block, const int offset, const uint8_t minGreen, const uint8_t maxGreen, uint8_t** outBuff ) +{ uint8_t mid = ( maxGreen - minGreen ) / ( 2 * 3 ); uint8_t gb1 = maxGreen - mid; @@ -494,9 +587,10 @@ void EmitGreenIndices( const uint8_t *block, const int offset, const uint8_t min block += offset; unsigned int result = 0; - for ( int i = 15; i >= 0; i-- ) { + for( int i = 15; i >= 0; i-- ) + { result <<= 2; - uint8_t g = block[i*4]; + uint8_t g = block[i * 4]; int b1 = ( g >= gb1 ); int b2 = ( g >= gb2 ); int b3 = ( g >= gb3 ); @@ -508,19 +602,22 @@ void EmitGreenIndices( const uint8_t *block, const int offset, const uint8_t min EmitDoubleWord( result, outBuff ); } -void CompressYCoCgDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) { +void CompressYCoCgDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) +{ uint8_t block[64]; uint8_t minColor[4]; uint8_t maxColor[4]; uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlock( inBuf + i * 4, width, block ); @@ -544,17 +641,17 @@ void CompressYCoCgDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, int he outputBytes = *outData - outBuf; } -void CompressImageSquish( const uint8_t* inBuf, - unsigned width, - unsigned height, - uint8_t* outBuf, - size_t outputPitch, - int squish_flags, - volatile const bool& cancel ) +void CompressImageSquish( const uint8_t* inBuf, + unsigned width, + unsigned height, + uint8_t* outBuf, + size_t outputPitch, + int squish_flags, + volatile const bool& cancel ) { - uint8_t block[64]; - const unsigned outDx = ( squish_flags & squish::kDxt1 ) ? 8 : 16; - for( unsigned j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + uint8_t block[64]; + const unsigned outDx = ( squish_flags & squish::kDxt1 ) ? 8 : 16; + for( unsigned j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) { uint8_t* outData = outBuf + ( j / 4 ) * outputPitch; @@ -563,14 +660,14 @@ void CompressImageSquish( const uint8_t* inBuf, return; } - for( unsigned i = 0; i < width; i += 4 ) + for( unsigned i = 0; i < width; i += 4 ) { ExtractBlock( inBuf + i * 4, width, block ); // Swap the R and B // Squish wants RGB but our format is BGR - for ( int k = 0; k < 16; ++k ) + for( int k = 0; k < 16; ++k ) { - std::swap( block[k*4], block[k*4 + 2] ); + std::swap( block[k * 4], block[k * 4 + 2] ); } squish::Compress( block, outData, squish_flags ); outData += outDx; @@ -578,17 +675,20 @@ void CompressImageSquish( const uint8_t* inBuf, } } -void CompressImageDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) { +void CompressImageDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) +{ uint8_t block[64]; uint8_t minColor[4]; uint8_t maxColor[4]; uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlock( inBuf + i * 4, width, block ); GetMinMaxColorsWithAlpha( block, minColor, maxColor ); EmitByte( maxColor[3], outData ); @@ -602,18 +702,20 @@ void CompressImageDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, int he outputBytes = *outData - outBuf; } -void CompressNormalMapDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) +void CompressNormalMapDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) { uint8_t block[64]; uint8_t minColor[4]; uint8_t maxColor[4]; uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlockDXT5N( inBuf + i * 4, width, block ); GetMinMaxColorsWithAlpha( block, minColor, maxColor ); EmitByte( maxColor[3], outData ); @@ -627,17 +729,20 @@ void CompressNormalMapDXT5( const uint8_t *inBuf, uint8_t *outBuf, int width, in outputBytes = *outData - outBuf; } -void CompressImageDXT1( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) { +void CompressImageDXT1( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) +{ uint8_t block[64]; uint8_t minColor[4]; uint8_t maxColor[4]; uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlock( inBuf + i * 4, width, block ); GetMinMaxColors( block, minColor, maxColor ); EmitWord( ColorTo565( maxColor ), outData ); @@ -649,19 +754,22 @@ void CompressImageDXT1( const uint8_t *inBuf, uint8_t *outBuf, int width, int he } // below works fine, but doesn't support a material id in the alpha channel -void CompressNormalMapDXT5NoAlpha( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) { +void CompressNormalMapDXT5NoAlpha( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) +{ uint8_t block[64]; uint8_t normalMin[4]; uint8_t normalMax[4]; uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlock( inBuf + i * 4, width, block ); @@ -684,19 +792,22 @@ void CompressNormalMapDXT5NoAlpha( const uint8_t *inBuf, uint8_t *outBuf, int wi outputBytes = *outData - outBuf; } -void CompressNormalMap3Dc( const uint8_t *inBuf, uint8_t *outBuf, int width, int height, ptrdiff_t &outputBytes, volatile const bool& cancel ) { +void CompressNormalMap3Dc( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel ) +{ uint8_t block[64]; uint8_t normalMin[4]; uint8_t normalMax[4]; - uint8_t **outData = &outBuf; + uint8_t** outData = &outBuf; - for ( int j = 0; j < height; j += 4, inBuf += width * 4*4 ) { + for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 ) + { if( cancel ) { return; } - for ( int i = 0; i < width; i += 4 ) { + for( int i = 0; i < width; i += 4 ) + { ExtractBlock( inBuf + i * 4, width, block ); @@ -718,11 +829,11 @@ void CompressNormalMap3Dc( const uint8_t *inBuf, uint8_t *outBuf, int width, int outputBytes = *outData - outBuf; } -bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, +bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, const uint8_t* inBuf, unsigned width, unsigned height, - uint8_t* outBuf, + uint8_t* outBuf, size_t outputPitch, volatile const bool& cancel, Tr2DxtCompressionSquishQuality squishQualityEnum ) @@ -746,64 +857,64 @@ bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, case TR2DXT_COMPRESS_SQ_RANGE_FIT: squishQuality = squish::kColourRangeFit; break; - default: - break; + default: + break; } switch( eCompressFmt ) { case TR2DXT_COMPRESS_RT_DXT1: - CompressImageDXT1( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); - break; + CompressImageDXT1( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); + break; case TR2DXT_COMPRESS_RT_DXT5: - CompressImageDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); - break; + CompressImageDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); + break; case TR2DXT_COMPRESS_RT_DXT5N: - CompressNormalMapDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); - break; + CompressNormalMapDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); + break; case TR2DXT_COMPRESS_RT_YCOCGDXT5: - ConvertRGBToCoCg_Y( (uint8_t*)inBuf, width, height ); - CompressYCoCgDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); - break; + ConvertRGBToCoCg_Y( (uint8_t*)inBuf, width, height ); + CompressYCoCgDXT5( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); + break; case TR2DXT_COMPRESS_RT_3DC: - CompressNormalMap3Dc( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); - break; + CompressNormalMap3Dc( (const uint8_t*)inBuf, (uint8_t*)outBuf, width, height, outputBytes, cancel ); + break; case TR2DXT_COMPRESS_SQUISH_DXT1: - CompressImageSquish( (const uint8_t*)inBuf, - width, - height, - (uint8_t*)outBuf, - outputPitch, - squish::kDxt1 | squishQuality, - cancel ); - return true; + CompressImageSquish( (const uint8_t*)inBuf, + width, + height, + (uint8_t*)outBuf, + outputPitch, + squish::kDxt1 | squishQuality, + cancel ); + return true; case TR2DXT_COMPRESS_SQUISH_DXT3: - CompressImageSquish( (const uint8_t*)inBuf, - width, - height, - (uint8_t*)outBuf, - outputPitch, - squish::kDxt3 | squishQuality, - cancel ); - return true; + CompressImageSquish( (const uint8_t*)inBuf, + width, + height, + (uint8_t*)outBuf, + outputPitch, + squish::kDxt3 | squishQuality, + cancel ); + return true; case TR2DXT_COMPRESS_SQUISH_DXT5: - CompressImageSquish( (const uint8_t*)inBuf, - width, - height, - (uint8_t*)outBuf, - outputPitch, - squish::kDxt5 | squishQuality, - cancel ); - return true; - - default: + CompressImageSquish( (const uint8_t*)inBuf, + width, + height, + (uint8_t*)outBuf, + outputPitch, + squish::kDxt5 | squishQuality, + cancel ); + return true; + + default: return false; } return true; @@ -812,10 +923,8 @@ bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, BLUE_DECLARE( BlueCallbackMan ); IBlueCallbackManPtr s_wodBackgroundCompressor; -Tr2DxtCompressControl::Tr2DxtCompressControl() - : m_cancel( false ) - , m_isDone( false ) - , m_id( -1 ) +Tr2DxtCompressControl::Tr2DxtCompressControl() : + m_cancel( false ), m_isDone( false ), m_id( -1 ) { } @@ -835,7 +944,7 @@ void Tr2DxtCompressControl::Cancel() // -------------------------------------------------------------------------------------- // Description: -// Query if the compression is finished. +// Query if the compression is finished. // Return Value: // true if compression is finished // false otherwise @@ -847,7 +956,7 @@ bool Tr2DxtCompressControl::IsDone() const // -------------------------------------------------------------------------------------- // Description: -// Query if the compression is requested to be canceled. +// Query if the compression is requested to be canceled. // Return Value: // true if compression is requested to be canceled // false otherwise @@ -869,42 +978,42 @@ void Tr2DxtCompressControl::Done() struct Tr2DxtCompressSurfaceAsyncData { - Tr2DxtCompressControl* control; - bool succeeded; + Tr2DxtCompressControl* control; + bool succeeded; Tr2DxtCompressionFormat eCompressFmt; - const uint8_t* inBuf; - unsigned width; - unsigned height; + const uint8_t* inBuf; + unsigned width; + unsigned height; - uint8_t* outBuf; - - size_t outputPitch; - int squishQuality; + uint8_t* outBuf; + + size_t outputPitch; + int squishQuality; }; static void Tr2DxtCompressSurfaceAsyncHelper( void* context ) { Tr2DxtCompressSurfaceAsyncData* data = static_cast( context ); - data->succeeded = Tr2DxtCompressSurface( data->eCompressFmt, - data->inBuf, - data->width, - data->height, - data->outBuf, - data->outputPitch, - data->control->IsCanceling(), - static_cast( data->squishQuality ) ); + data->succeeded = Tr2DxtCompressSurface( data->eCompressFmt, + data->inBuf, + data->width, + data->height, + data->outBuf, + data->outputPitch, + data->control->IsCanceling(), + static_cast( data->squishQuality ) ); data->control->Done(); } -bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, - const unsigned char *inBuf, - unsigned width, - unsigned height, - unsigned char *outBuf, - size_t outputPitch, - Tr2DxtCompressControl *control, - int squishQuality ) +bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, + const unsigned char* inBuf, + unsigned width, + unsigned height, + unsigned char* outBuf, + size_t outputPitch, + Tr2DxtCompressControl* control, + int squishQuality ) { #if BLUE_WITH_PYTHON if( !PyOS->CanYield() ) @@ -951,8 +1060,8 @@ bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, } const bool result = data->succeeded; - + CCP_DELETE data; - + return result; } diff --git a/trinity/Tr2DxtCompressor.h b/trinity/Tr2DxtCompressor.h index 662289e50..5962ca71a 100644 --- a/trinity/Tr2DxtCompressor.h +++ b/trinity/Tr2DxtCompressor.h @@ -6,25 +6,25 @@ enum Tr2DxtCompressionFormat { - TR2DXT_COMPRESS_RT_DXT1 = 0, - TR2DXT_COMPRESS_RT_DXT5 = 1, - TR2DXT_COMPRESS_RT_DXT5N = 2, - TR2DXT_COMPRESS_RT_YCOCGDXT5 = 3, - TR2DXT_COMPRESS_RT_3DC = 4, - TR2DXT_COMPRESS_SQUISH_DXT1 = 5, - TR2DXT_COMPRESS_SQUISH_DXT3 = 6, - TR2DXT_COMPRESS_SQUISH_DXT5 = 7, - TR2DXT_COMPRESS_SQUISH_KBC4 = 8, - TR2DXT_COMPRESS_SQUISH_KBC5 = 9, + TR2DXT_COMPRESS_RT_DXT1 = 0, + TR2DXT_COMPRESS_RT_DXT5 = 1, + TR2DXT_COMPRESS_RT_DXT5N = 2, + TR2DXT_COMPRESS_RT_YCOCGDXT5 = 3, + TR2DXT_COMPRESS_RT_3DC = 4, + TR2DXT_COMPRESS_SQUISH_DXT1 = 5, + TR2DXT_COMPRESS_SQUISH_DXT3 = 6, + TR2DXT_COMPRESS_SQUISH_DXT5 = 7, + TR2DXT_COMPRESS_SQUISH_KBC4 = 8, + TR2DXT_COMPRESS_SQUISH_KBC5 = 9, TR2DXT_COMPRESS_COUNT }; enum Tr2DxtCompressionSquishQuality { - TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT = 0, - TR2DXT_COMPRESS_SQ_CLUSTER_FIT = 1, - TR2DXT_COMPRESS_SQ_RANGE_FIT = 2, + TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT = 0, + TR2DXT_COMPRESS_SQ_CLUSTER_FIT = 1, + TR2DXT_COMPRESS_SQ_RANGE_FIT = 2, TR2DXT_COMPRESS_SQ_COUNT }; @@ -47,14 +47,15 @@ class Tr2DxtCompressControl const bool& IsCanceling() const; void Done(); - friend bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, - const unsigned char *inBuf, + friend bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, + const unsigned char* inBuf, unsigned width, unsigned height, - unsigned char *outBuf, + unsigned char* outBuf, size_t outputPitch, - Tr2DxtCompressControl *control, + Tr2DxtCompressControl* control, int squishQuality ); + private: // A flag to cancel compression bool m_cancel; @@ -64,24 +65,27 @@ class Tr2DxtCompressControl CcpAtomic m_id; }; -enum { COMPRESS_SQUISH_QUALITY_DEFAULT = -1 }; +enum +{ + COMPRESS_SQUISH_QUALITY_DEFAULT = -1 +}; -bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, - const uint8_t* inBuf, - unsigned width, - unsigned height, - uint8_t* outBuf, - size_t outputPitch, - volatile const bool& cancel, - Tr2DxtCompressionSquishQuality squishQuality ); +bool Tr2DxtCompressSurface( Tr2DxtCompressionFormat eCompressFmt, + const uint8_t* inBuf, + unsigned width, + unsigned height, + uint8_t* outBuf, + size_t outputPitch, + volatile const bool& cancel, + Tr2DxtCompressionSquishQuality squishQuality ); -bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, - const uint8_t* inBuf, - unsigned width, - unsigned height, - uint8_t* outBuf, - size_t outputPitch, - Tr2DxtCompressControl *control, - int squishQuality ); +bool Tr2DxtCompressSurfaceAsync( Tr2DxtCompressionFormat eCompressFmt, + const uint8_t* inBuf, + unsigned width, + unsigned height, + uint8_t* outBuf, + size_t outputPitch, + Tr2DxtCompressControl* control, + int squishQuality ); #endif // tr2dxtcompressor_h \ No newline at end of file diff --git a/trinity/Tr2DxtCompressor_Blue.cpp b/trinity/Tr2DxtCompressor_Blue.cpp index 99e63df20..434695309 100644 --- a/trinity/Tr2DxtCompressor_Blue.cpp +++ b/trinity/Tr2DxtCompressor_Blue.cpp @@ -4,29 +4,27 @@ #include "Tr2DxtCompressor.h" -const Be::VarChooser Tr2DxtCompressionChooser[] = -{ +const Be::VarChooser Tr2DxtCompressionChooser[] = { // Name Value Docstring - { "TR2DXT_COMPRESS_RT_DXT1", BeCast( TR2DXT_COMPRESS_RT_DXT1 ), "Real time dxt1 compression" }, - { "TR2DXT_COMPRESS_RT_DXT5", BeCast( TR2DXT_COMPRESS_RT_DXT5 ), "Real time dxt5 compression" }, - { "TR2DXT_COMPRESS_RT_DXT5N", BeCast( TR2DXT_COMPRESS_RT_DXT5N ), "Real time dxt5 compression for normal maps" }, - { "TR2DXT_COMPRESS_RT_YCOCGDXT5", BeCast( TR2DXT_COMPRESS_RT_YCOCGDXT5 ), "High quality dxt5 compression" }, - { "TR2DXT_COMPRESS_RT_3DC", BeCast( TR2DXT_COMPRESS_RT_3DC ), "Real time normal map compression" }, - { "TR2DXT_COMPRESS_SQUISH_DXT1", BeCast( TR2DXT_COMPRESS_SQUISH_DXT1 ), "High quality squish dxt1 compression" }, - { "TR2DXT_COMPRESS_SQUISH_DXT3", BeCast( TR2DXT_COMPRESS_SQUISH_DXT3 ), "High quality squish dxt3 compression" }, - { "TR2DXT_COMPRESS_SQUISH_DXT5", BeCast( TR2DXT_COMPRESS_SQUISH_DXT5 ), "High quality squish dxt5 compression" }, - { "TR2DXT_COMPRESS_SQUISH_KBC4", BeCast( TR2DXT_COMPRESS_SQUISH_KBC4 ), "High quality squish kbc4 compression" }, - { "TR2DXT_COMPRESS_SQUISH_KBC5", BeCast( TR2DXT_COMPRESS_SQUISH_KBC5 ), "High quality squish kbc5 compression" }, - {0} + { "TR2DXT_COMPRESS_RT_DXT1", BeCast( TR2DXT_COMPRESS_RT_DXT1 ), "Real time dxt1 compression" }, + { "TR2DXT_COMPRESS_RT_DXT5", BeCast( TR2DXT_COMPRESS_RT_DXT5 ), "Real time dxt5 compression" }, + { "TR2DXT_COMPRESS_RT_DXT5N", BeCast( TR2DXT_COMPRESS_RT_DXT5N ), "Real time dxt5 compression for normal maps" }, + { "TR2DXT_COMPRESS_RT_YCOCGDXT5", BeCast( TR2DXT_COMPRESS_RT_YCOCGDXT5 ), "High quality dxt5 compression" }, + { "TR2DXT_COMPRESS_RT_3DC", BeCast( TR2DXT_COMPRESS_RT_3DC ), "Real time normal map compression" }, + { "TR2DXT_COMPRESS_SQUISH_DXT1", BeCast( TR2DXT_COMPRESS_SQUISH_DXT1 ), "High quality squish dxt1 compression" }, + { "TR2DXT_COMPRESS_SQUISH_DXT3", BeCast( TR2DXT_COMPRESS_SQUISH_DXT3 ), "High quality squish dxt3 compression" }, + { "TR2DXT_COMPRESS_SQUISH_DXT5", BeCast( TR2DXT_COMPRESS_SQUISH_DXT5 ), "High quality squish dxt5 compression" }, + { "TR2DXT_COMPRESS_SQUISH_KBC4", BeCast( TR2DXT_COMPRESS_SQUISH_KBC4 ), "High quality squish kbc4 compression" }, + { "TR2DXT_COMPRESS_SQUISH_KBC5", BeCast( TR2DXT_COMPRESS_SQUISH_KBC5 ), "High quality squish kbc5 compression" }, + { 0 } }; -const Be::VarChooser Tr2DxtCompressionSquishQualityChooser[] = -{ +const Be::VarChooser Tr2DxtCompressionSquishQualityChooser[] = { // Name Value Docstring - { "TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT", BeCast( TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT ), "Use a very slow but very high quality colour compressor." }, - { "TR2DXT_COMPRESS_SQ_CLUSTER_FIT", BeCast( TR2DXT_COMPRESS_SQ_CLUSTER_FIT ), "Use a slow but high quality colour compressor." }, - { "TR2DXT_COMPRESS_SQ_RANGE_FIT", BeCast( TR2DXT_COMPRESS_SQ_RANGE_FIT ), "Use a fast but low quality colour compressor." }, - {0} + { "TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT", BeCast( TR2DXT_COMPRESS_SQ_ITER_CLUSTER_FIT ), "Use a very slow but very high quality colour compressor." }, + { "TR2DXT_COMPRESS_SQ_CLUSTER_FIT", BeCast( TR2DXT_COMPRESS_SQ_CLUSTER_FIT ), "Use a slow but high quality colour compressor." }, + { "TR2DXT_COMPRESS_SQ_RANGE_FIT", BeCast( TR2DXT_COMPRESS_SQ_RANGE_FIT ), "Use a fast but low quality colour compressor." }, + { 0 } }; diff --git a/trinity/Tr2DynamicBinding.cpp b/trinity/Tr2DynamicBinding.cpp index cf3def22a..4949c5327 100644 --- a/trinity/Tr2DynamicBinding.cpp +++ b/trinity/Tr2DynamicBinding.cpp @@ -9,165 +9,164 @@ namespace { - std::pair FindEntry( IRoot* object, const char* name ) +std::pair FindEntry( IRoot* object, const char* name ) +{ + if( !object ) { - if( !object ) - { - return std::make_pair( nullptr, nullptr ); - } - auto type = object->ClassType(); - ssize_t offs = 0; - // Loop over all entries - this double loop covers chaining - for( ; type; offs += type->mOffsetToParent, type = type->mParentClassInfo ) + return std::make_pair( nullptr, nullptr ); + } + auto type = object->ClassType(); + ssize_t offs = 0; + // Loop over all entries - this double loop covers chaining + for( ; type; offs += type->mOffsetToParent, type = type->mParentClassInfo ) + { + for( const Be::VarEntry* entry = type->mMemberTable; entry->mName; entry++ ) { - for( const Be::VarEntry* entry = type->mMemberTable; entry->mName; entry++ ) + if( !entry->mGetProperty && strcmp( entry->mName, name ) == 0 ) { - if( !entry->mGetProperty && strcmp( entry->mName, name ) == 0 ) - { - return std::make_pair( entry, BLUEMAPMEMBEROFFSET( object, entry, type, offs ) ); - } + return std::make_pair( entry, BLUEMAPMEMBEROFFSET( object, entry, type, offs ) ); } } - return std::make_pair( nullptr, nullptr ); } + return std::make_pair( nullptr, nullptr ); +} - IRoot* GetIRootAttribute( IRoot* object, const std::string& name ) +IRoot* GetIRootAttribute( IRoot* object, const std::string& name ) +{ + auto entry = FindEntry( object, name.c_str() ); + if( !entry.second ) { - auto entry = FindEntry( object, name.c_str() ); - if( !entry.second ) + return nullptr; + } + if( entry.first->mSize && ( entry.first->mType == Be::IROOT || entry.first->mType == Be::IROOTPTR ) ) + { + if( entry.first->mType == Be::IROOTPTR ) { - return nullptr; + return entry.second->mIRootPtr; } - if( entry.first->mSize && ( entry.first->mType == Be::IROOT || entry.first->mType == Be::IROOTPTR ) ) + else { - if( entry.first->mType == Be::IROOTPTR ) - { - return entry.second->mIRootPtr; - } - else - { - return reinterpret_cast( entry.second ); - } + return reinterpret_cast( entry.second ); } - return nullptr; } + return nullptr; +} + +bool GetStringAttribute( IRoot* object, const std::string& name, std::string& value ) +{ + auto entry = FindEntry( object, name.c_str() ); + if( !entry.second ) + { + return false; + } + switch( entry.first->mType ) + { + case Be::CHARARRAY: + value = reinterpret_cast( entry.second ); + return true; + case Be::CSTRING: + value = reinterpret_cast( entry.second->mCharPtr ); + return true; + case Be::STDSTRING: + value = *reinterpret_cast( entry.second ); + return true; + case Be::SHAREDSTRING: + value = reinterpret_cast( entry.second )->c_str(); + return true; + default: + return false; + } +} - bool GetStringAttribute( IRoot* object, const std::string& name, std::string& value ) +IRoot* GetListElement( IRoot* object, ssize_t index ) +{ + if( IListPtr list = BlueCastPtr( object ) ) { - auto entry = FindEntry( object, name.c_str() ); - if( !entry.second ) + if( index < 0 ) { - return false; + index += int( list->GetSize() ); } - switch( entry.first->mType ) + if( index >= 0 && index < list->GetSize() ) { - case Be::CHARARRAY: - value = reinterpret_cast( entry.second ); - return true; - case Be::CSTRING: - value = reinterpret_cast( entry.second->mCharPtr ); - return true; - case Be::STDSTRING: - value = *reinterpret_cast( entry.second ); - return true; - case Be::SHAREDSTRING: - value = reinterpret_cast( entry.second )->c_str(); - return true; - default: - return false; + return list->GetAt( index ); } } + return nullptr; +} - IRoot* GetListElement( IRoot* object, ssize_t index ) +IRoot* GetListElement( IRoot* object, const std::string& name ) +{ + if( IListPtr list = BlueCastPtr( object ) ) { - if( IListPtr list = BlueCastPtr( object ) ) + auto size = list->GetSize(); + for( ssize_t i = 0; i < size; ++i ) { - if( index < 0 ) + auto element = list->GetAt( i ); + std::string elementName; + if( GetStringAttribute( element, "name", elementName ) && elementName == name ) { - index += int( list->GetSize() ); - } - if( index >= 0 && index < list->GetSize() ) - { - return list->GetAt( index ); + return element; } } - return nullptr; } + return nullptr; +} - IRoot* GetListElement( IRoot* object, const std::string& name ) +IRoot* ResolveReference( const std::string& reference, const std::unordered_map& roots ) +{ + if( reference.empty() ) { - if( IListPtr list = BlueCastPtr( object ) ) - { - auto size = list->GetSize(); - for( ssize_t i = 0; i < size; ++i ) - { - auto element = list->GetAt( i ); - std::string elementName; - if( GetStringAttribute( element, "name", elementName ) && elementName == name ) - { - return element; - } - } + return nullptr; + } - } + static const std::regex tokens( "((\\.[a-zA-Z_][a-zA-Z_0-9]*)|(\\[-?[0-9]+\\])|(\\[\"[^\"]*\"\\])).*" ); + static const std::regex root( "([a-zA-Z_][a-zA-Z_0-9]*).*" ); + + auto start = begin( reference ); + auto finish = end( reference ); + std::smatch match; + if( !std::regex_match( start, finish, match, root ) ) + { return nullptr; } + auto found = roots.find( match[1].str() ); + if( found == roots.end() ) + { + return nullptr; + } + auto object = found->second; + start += match[1].length(); - IRoot* ResolveReference( const std::string& reference, const std::unordered_map& roots ) + while( object && start != finish ) { - if( reference.empty() ) + if( !std::regex_match( start, finish, match, tokens ) ) { return nullptr; } - - static const std::regex tokens( "((\\.[a-zA-Z_][a-zA-Z_0-9]*)|(\\[-?[0-9]+\\])|(\\[\"[^\"]*\"\\])).*" ); - static const std::regex root( "([a-zA-Z_][a-zA-Z_0-9]*).*" ); - - auto start = begin( reference ); - auto finish = end( reference ); - std::smatch match; - if( !std::regex_match( start, finish, match, root ) ) + if( match[2].length() ) { - return nullptr; + auto attrName = match[2].str().substr( 1 ); + object = GetIRootAttribute( object, attrName ); } - auto found = roots.find( match[1].str() ); - if( found == roots.end() ) + else if( match[3].length() ) { - return nullptr; + auto index = std::atoi( match[3].str().c_str() + 1 ); + object = GetListElement( object, ssize_t( index ) ); } - auto object = found->second; - start += match[1].length(); - - while( object && start != finish ) + else if( match[4].length() ) { - if( !std::regex_match( start, finish, match, tokens ) ) - { - return nullptr; - } - if( match[2].length() ) - { - auto attrName = match[2].str().substr( 1 ); - object = GetIRootAttribute( object, attrName ); - } - else if( match[3].length() ) - { - auto index = std::atoi( match[3].str().c_str() + 1 ); - object = GetListElement( object, ssize_t( index ) ); - } - else if( match[4].length() ) - { - auto name = match[4].str(); - name = name.substr( 2, name.length() - 4 ); - object = GetListElement( object, name ); - } - else - { - object = nullptr; - } - start += match[1].length(); + auto name = match[4].str(); + name = name.substr( 2, name.length() - 4 ); + object = GetListElement( object, name ); + } + else + { + object = nullptr; } - return object; + start += match[1].length(); } + return object; +} } @@ -248,7 +247,7 @@ void Tr2DynamicBinding::Link() { m_bindingTime = BeOS->GetCurrentFrameTime() + TimeFromMS( m_bindingDelay ); } - } + } } void Tr2DynamicBinding::Unlink() @@ -259,7 +258,7 @@ void Tr2DynamicBinding::Unlink() m_bindingTime = 0; } -void Tr2DynamicBinding::SetOwner( ITr2DynamicBindingOwner* owner) +void Tr2DynamicBinding::SetOwner( ITr2DynamicBindingOwner* owner ) { m_owner = owner; } diff --git a/trinity/Tr2DynamicBinding.h b/trinity/Tr2DynamicBinding.h index 9f015d14d..1d2f54602 100644 --- a/trinity/Tr2DynamicBinding.h +++ b/trinity/Tr2DynamicBinding.h @@ -21,7 +21,7 @@ BLUE_CLASS( Tr2DynamicBinding ) : void Link(); void Unlink(); - void SetOwner( ITr2DynamicBindingOwner* owner ); + void SetOwner( ITr2DynamicBindingOwner * owner ); void Update( Be::Time time ); virtual void OnSimClockRebase( Be::Time oldTime, Be::Time newTime ); @@ -30,13 +30,13 @@ BLUE_CLASS( Tr2DynamicBinding ) : ////////////////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); private: BlueSharedString m_name; BlueSharedString m_destinationObjectPath; - BlueSharedString m_destinationObjectAttribute; + BlueSharedString m_destinationObjectAttribute; BlueWeakRef m_destination; BlueSharedString m_sourceObjectPath; diff --git a/trinity/Tr2DynamicBinding_Blue.cpp b/trinity/Tr2DynamicBinding_Blue.cpp index f4666db43..16e9ecf7a 100644 --- a/trinity/Tr2DynamicBinding_Blue.cpp +++ b/trinity/Tr2DynamicBinding_Blue.cpp @@ -19,12 +19,12 @@ const Be::ClassInfo* Tr2DynamicBinding::ExposeToBlue() MAP_ATTRIBUTE( "sourceObjectPath", m_sourceObjectPath, "Path to the source object", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "sourceObjectAttribute", m_sourceObjectAttribute, "Path to the source object attribute", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "source", m_source, "source object", Be::READ ) - MAP_ATTRIBUTE( "scale", m_scale, "scale of the source value", Be::READWRITE| Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "scale", m_scale, "scale of the source value", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "bindingDelay", m_bindingDelay, "delay in ms until binding starts", Be::READWRITE | Be::PERSIST ) - + MAP_PROPERTY_READONLY( "isSourceValid", IsSourceValid, "Is source parameter valid" ) MAP_ATTRIBUTE( "binding", m_binding, "The binding", Be::READ ) - EXPOSURE_END(); + EXPOSURE_END(); } \ No newline at end of file diff --git a/trinity/Tr2DynamicRingBuffer.cpp b/trinity/Tr2DynamicRingBuffer.cpp index 98c3c2336..36c6a28d8 100644 --- a/trinity/Tr2DynamicRingBuffer.cpp +++ b/trinity/Tr2DynamicRingBuffer.cpp @@ -14,8 +14,8 @@ uint32_t Align( uint32_t offset, uint32_t alignment ) } } -Tr2DynamicRingBuffer::Tr2DynamicRingBuffer() - :m_regions( "Tr2DynamicRingBuffer::m_regions" ), +Tr2DynamicRingBuffer::Tr2DynamicRingBuffer() : + m_regions( "Tr2DynamicRingBuffer::m_regions" ), m_sizeIncrement( 0 ), m_lastPutSucceeded( false ), m_bufferSize( 0 ), @@ -31,7 +31,7 @@ Tr2DynamicRingBuffer::~Tr2DynamicRingBuffer() // -------------------------------------------------------------------------------------- // Description: // Puts new data into the buffer. If the data size is larget than the buffer size, the -// buffer is resized. +// buffer is resized. // Arguments: // data - Pointer to data // size - Size of data in bytes @@ -44,16 +44,16 @@ ALResult Tr2DynamicRingBuffer::PutData( const void* data, uint32_t size, uint32_t& offset, - Tr2RenderContext& renderContext) + Tr2RenderContext& renderContext ) { return PutData( data, size, 4, offset, renderContext ); } -ALResult Tr2DynamicRingBuffer::PutData( - const void* data, - uint32_t size, +ALResult Tr2DynamicRingBuffer::PutData( + const void* data, + uint32_t size, uint32_t alignment, - uint32_t& bufferOffset, + uint32_t& bufferOffset, Tr2RenderContext& renderContext ) { m_lastPutSucceeded = false; @@ -123,7 +123,7 @@ ALResult Tr2DynamicRingBuffer::PutData( // -------------------------------------------------------------------------------------- // Description: // Notifies the object that the data updated with the previous call to PutData is no -// longer needed. +// longer needed. // Arguments: // renderContext - current render context // -------------------------------------------------------------------------------------- @@ -142,7 +142,7 @@ void Tr2DynamicRingBuffer::DoneUsingData( Tr2RenderContext& renderContext ) // -------------------------------------------------------------------------------------- // Description: -// Checks if the given region is still used by GPU. +// Checks if the given region is still used by GPU. // Arguments: // region - Buffer region // renderContext - current render context @@ -158,12 +158,12 @@ bool Tr2DynamicRingBuffer::IsRegionUsedByGpu( BufferRegion& region, Tr2RenderCon } bool isReached = false; - return FAILED( region.fence->IsReached( isReached, renderContext) ) || !isReached; + return FAILED( region.fence->IsReached( isReached, renderContext ) ) || !isReached; } // -------------------------------------------------------------------------------------- // Description: -// Removes regions no longer used by GPU from m_regions vector. +// Removes regions no longer used by GPU from m_regions vector. // Arguments: // renderContext - current render context // -------------------------------------------------------------------------------------- @@ -369,10 +369,10 @@ Tr2BufferAL& Tr2DynamicRingBuffer::GetBuffer() // Return Value: // AL result code // -------------------------------------------------------------------------------------- -ALResult Tr2DynamicRingBuffer::UpdateBuffer( - const void* data, - uint32_t offset, - uint32_t size, +ALResult Tr2DynamicRingBuffer::UpdateBuffer( + const void* data, + uint32_t offset, + uint32_t size, Tr2RenderContext& renderContext ) { uint8_t* bufferData = nullptr; @@ -414,18 +414,18 @@ bool Tr2RingVertexBuffer::Create( uint32_t bufferSize ) ALResult Tr2RingVertexBuffer::CreateBuffer( uint32_t size ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - return m_buffer.Create( - 1, - size, - Tr2GpuUsage::VERTEX_BUFFER, - Tr2CpuUsage::WRITE_OFTEN | Tr2CpuUsage::NON_SYNCRONIZED_WRITE, - nullptr, + return m_buffer.Create( + 1, + size, + Tr2GpuUsage::VERTEX_BUFFER, + Tr2CpuUsage::WRITE_OFTEN | Tr2CpuUsage::NON_SYNCRONIZED_WRITE, + nullptr, renderContext ); } -Tr2RingIndexBuffer::Tr2RingIndexBuffer() - :m_indexSize( 4 ) +Tr2RingIndexBuffer::Tr2RingIndexBuffer() : + m_indexSize( 4 ) { } @@ -459,11 +459,11 @@ bool Tr2RingIndexBuffer::Create( uint32_t numberOfIndices, uint32_t indexSize ) ALResult Tr2RingIndexBuffer::CreateBuffer( uint32_t size ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - return m_buffer.Create( + return m_buffer.Create( m_indexSize, size / m_indexSize, - Tr2GpuUsage::INDEX_BUFFER, - Tr2CpuUsage::WRITE_OFTEN | Tr2CpuUsage::NON_SYNCRONIZED_WRITE, - nullptr, + Tr2GpuUsage::INDEX_BUFFER, + Tr2CpuUsage::WRITE_OFTEN | Tr2CpuUsage::NON_SYNCRONIZED_WRITE, + nullptr, renderContext ); } diff --git a/trinity/Tr2DynamicRingBuffer.h b/trinity/Tr2DynamicRingBuffer.h index f52787a05..b04a72539 100644 --- a/trinity/Tr2DynamicRingBuffer.h +++ b/trinity/Tr2DynamicRingBuffer.h @@ -6,9 +6,9 @@ // -------------------------------------------------------------------------------------- // Description: -// A base class for index/vertex ring buffers. Ring buffers are used in case when -// dynamic data needs to be passed multiple times per frame for rendering and is -// discared right after rendering. With a ring buffer we can avoid excessive discard +// A base class for index/vertex ring buffers. Ring buffers are used in case when +// dynamic data needs to be passed multiple times per frame for rendering and is +// discared right after rendering. With a ring buffer we can avoid excessive discard // locks one would need for use. The basic patter of using this class is: // 1. collect data for the buffer>\ // 2. call ringBuffer.PutData to put data into the buffer @@ -19,16 +19,16 @@ // See Also: // Tr2Sprite2dScene, Tr2StreamVertexBuffer, Tr2StreamIndexBuffer // -------------------------------------------------------------------------------------- -class Tr2DynamicRingBuffer: public Tr2DeviceResource +class Tr2DynamicRingBuffer : public Tr2DeviceResource { public: Tr2DynamicRingBuffer(); ~Tr2DynamicRingBuffer(); - - ALResult PutData( - const void* data, - uint32_t size, - uint32_t& offset, + + ALResult PutData( + const void* data, + uint32_t size, + uint32_t& offset, Tr2RenderContext& renderContext ); ALResult PutData( const void* data, @@ -50,6 +50,7 @@ class Tr2DynamicRingBuffer: public Tr2DeviceResource ////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + protected: virtual ALResult CreateBuffer( uint32_t size ) = 0; ALResult UpdateBuffer( const void* data, uint32_t offset, uint32_t size, Tr2RenderContext& renderContext ); @@ -57,6 +58,7 @@ class Tr2DynamicRingBuffer: public Tr2DeviceResource // Size of buffer in bytes uint32_t m_bufferSize; + private: // Represents a continuous region in buffer used by GPU struct BufferRegion @@ -99,10 +101,11 @@ class Tr2DynamicRingBuffer: public Tr2DeviceResource // See Also: // Tr2DynamicRingBuffer // -------------------------------------------------------------------------------------- -class Tr2RingVertexBuffer: public Tr2DynamicRingBuffer +class Tr2RingVertexBuffer : public Tr2DynamicRingBuffer { public: bool Create( uint32_t bufferSize ); + protected: virtual ALResult CreateBuffer( uint32_t size ); }; @@ -113,14 +116,16 @@ class Tr2RingVertexBuffer: public Tr2DynamicRingBuffer // See Also: // Tr2DynamicRingBuffer // -------------------------------------------------------------------------------------- -class Tr2RingIndexBuffer: public Tr2DynamicRingBuffer +class Tr2RingIndexBuffer : public Tr2DynamicRingBuffer { public: Tr2RingIndexBuffer(); bool Create( uint32_t numberOfIndices, uint32_t indexSize ); + protected: virtual ALResult CreateBuffer( uint32_t size ); + private: uint32_t m_indexSize; }; diff --git a/trinity/Tr2ExpressionTermInfo.h b/trinity/Tr2ExpressionTermInfo.h index 5c7166103..55829e582 100644 --- a/trinity/Tr2ExpressionTermInfo.h +++ b/trinity/Tr2ExpressionTermInfo.h @@ -3,7 +3,8 @@ #pragma once -BLUE_CLASS( Tr2ExpressionTermInfo ) : public IRoot +BLUE_CLASS( Tr2ExpressionTermInfo ) : + public IRoot { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Tr2ExternalParameter.cpp b/trinity/Tr2ExternalParameter.cpp index 7f2e9d61a..6d7e1c277 100644 --- a/trinity/Tr2ExternalParameter.cpp +++ b/trinity/Tr2ExternalParameter.cpp @@ -27,8 +27,8 @@ const Be::VarEntry* FindEntry( const char* name, const Be::ClassInfo* type, ssiz } -Tr2ExternalParameter::Tr2ExternalParameter( IRoot* lockobj ) - :m_destination( nullptr ), +Tr2ExternalParameter::Tr2ExternalParameter( IRoot* lockobj ) : + m_destination( nullptr ), m_destinationEntry( nullptr ), m_destItemOffset( 0 ), m_valid( false ), diff --git a/trinity/Tr2ExternalParameter.h b/trinity/Tr2ExternalParameter.h index c6b5fa57e..9f64ea65d 100644 --- a/trinity/Tr2ExternalParameter.h +++ b/trinity/Tr2ExternalParameter.h @@ -11,13 +11,13 @@ BLUE_DECLARE( TriValueBinding ); // -------------------------------------------------------------------------------------- // Description: // Tr2ExternalParameter is a special binding that doesn't have a source, but only a -// destination. The SetValue method can be used to change destination value from -// script. Tr2ExternalParameter can be used to expose internal values in an object tree +// destination. The SetValue method can be used to change destination value from +// script. Tr2ExternalParameter can be used to expose internal values in an object tree // to the script in a nice way. // See Also: // EveSpaceScene, EveSpaceObject2 // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ExternalParameter ): +BLUE_CLASS( Tr2ExternalParameter ) : public IInitialize, public INotify { @@ -28,15 +28,15 @@ BLUE_CLASS( Tr2ExternalParameter ): EXPOSE_TO_BLUE(); virtual bool Initialize(); - virtual bool OnModified( Be::Var* value ); - + virtual bool OnModified( Be::Var * value ); + const char* GetName() const; void SetName( const std::string& name ); - void SetDestinationObject( IRoot* destination ); + void SetDestinationObject( IRoot * destination ); void SetDestinationAttribute( const std::string& attributeName ); BlueStdResult SetValue( BlueScriptValue value ); - BlueStdResult GetValue( BlueScriptValue& value ) const; + BlueStdResult GetValue( BlueScriptValue & value ) const; Be::Var* GetDestination() const; const Be::VarEntry* GetDestinationEntry() const; @@ -44,6 +44,7 @@ BLUE_CLASS( Tr2ExternalParameter ): // Creates a binding from this Tr2ExternalParameter. The new binding has the same destination object/attribute. TriValueBindingPtr CreateBinding() const; + private: // parameter name std::string m_name; diff --git a/trinity/Tr2ExternalParameter_Blue.cpp b/trinity/Tr2ExternalParameter_Blue.cpp index ca0e4357d..b19064fa3 100644 --- a/trinity/Tr2ExternalParameter_Blue.cpp +++ b/trinity/Tr2ExternalParameter_Blue.cpp @@ -7,25 +7,25 @@ BLUE_DEFINE( Tr2ExternalParameter ); const Be::ClassInfo* Tr2ExternalParameter::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ExternalParameter, "" ) - MAP_INTERFACE( Tr2ExternalParameter ) - MAP_INTERFACE( IInitialize ) - MAP_INTERFACE( INotify ) + EXPOSURE_BEGIN( Tr2ExternalParameter, "" ) + MAP_INTERFACE( Tr2ExternalParameter ) + MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( INotify ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "destinationObject", m_destinationObject, "Destination blue object", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "destinationAttribute", m_destinationAttribute, "Destination object\'s attribute name", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "valid", m_valid, "Is the parameter valid", Be::READ ) - MAP_METHOD_AND_WRAP( - "GetValue", - GetValue, + MAP_METHOD_AND_WRAP( + "GetValue", + GetValue, "Returns current value of the parameter.\n" ":raises RuntimeError: if parameter is invalid" ) - MAP_METHOD_AND_WRAP( - "SetValue", - SetValue, - "Sets new value for the parameter.\n" + MAP_METHOD_AND_WRAP( + "SetValue", + SetValue, + "Sets new value for the parameter.\n" ":param value: value to set\n" ":raises RuntimeError: if parameter is invalid\n" ":raises TypeError: if value is of incorrect type" ) diff --git a/trinity/Tr2FFXDenoiser.h b/trinity/Tr2FFXDenoiser.h index d3a98d99d..4c9b4082f 100644 --- a/trinity/Tr2FFXDenoiser.h +++ b/trinity/Tr2FFXDenoiser.h @@ -13,7 +13,6 @@ BLUE_CLASS( Tr2FidelityFXDenoiser ) : private: bool m_enable; - }; TYPEDEF_BLUECLASS( Tr2FidelityFXDenoiser ); \ No newline at end of file diff --git a/trinity/Tr2FidelityFXDenoiser.cpp b/trinity/Tr2FidelityFXDenoiser.cpp index 87b97390c..da8f328cb 100644 --- a/trinity/Tr2FidelityFXDenoiser.cpp +++ b/trinity/Tr2FidelityFXDenoiser.cpp @@ -1,2 +1 @@ -// Copyright © 2023 CCP ehf. - \ No newline at end of file +// Copyright © 2023 CCP ehf. diff --git a/trinity/Tr2FidelityFXDenoiser.h b/trinity/Tr2FidelityFXDenoiser.h index 373367ab7..275341b9a 100644 --- a/trinity/Tr2FidelityFXDenoiser.h +++ b/trinity/Tr2FidelityFXDenoiser.h @@ -3,4 +3,3 @@ #pragma once // here include "ffx_denoiser.h" blah // FidelityFX headers - diff --git a/trinity/Tr2FidelityFXDenoiser_Blue.cpp b/trinity/Tr2FidelityFXDenoiser_Blue.cpp index 87b97390c..da8f328cb 100644 --- a/trinity/Tr2FidelityFXDenoiser_Blue.cpp +++ b/trinity/Tr2FidelityFXDenoiser_Blue.cpp @@ -1,2 +1 @@ -// Copyright © 2023 CCP ehf. - \ No newline at end of file +// Copyright © 2023 CCP ehf. diff --git a/trinity/Tr2GStateAnimation.cpp b/trinity/Tr2GStateAnimation.cpp index a6b1fe8f3..1b9ea1903 100644 --- a/trinity/Tr2GStateAnimation.cpp +++ b/trinity/Tr2GStateAnimation.cpp @@ -97,7 +97,7 @@ void Tr2GStateAnimation::LoadGrannyRes() if( !m_geometryRes && !m_resPath.empty() ) { - BeResMan->GetResource( m_resPath.c_str(), "raw", BlueInterfaceIID(), (void**)&m_grannyRes ); + BeResMan->GetResource( m_resPath.c_str(), "raw", BlueInterfaceIID(), (void**)&m_grannyRes ); } if( m_grannyRes ) @@ -1297,7 +1297,7 @@ void Tr2GStateAnimation::ClearScrub() void Tr2GStateAnimation::PlayFromScrub() { - if ( !m_scrubbing ) + if( !m_scrubbing ) { return; } @@ -1316,7 +1316,7 @@ void Tr2GStateAnimation::StopPlayFromScrub() if( !m_scrub_playing ) { - return; + return; } m_scrub_offset = GetAnimationTime() - m_scrub_time; @@ -1325,7 +1325,7 @@ void Tr2GStateAnimation::StopPlayFromScrub() } -void Tr2GStateAnimation::SetScrubOffset(float scrub_offset) +void Tr2GStateAnimation::SetScrubOffset( float scrub_offset ) { if( !m_scrubbing ) { diff --git a/trinity/Tr2GpuBuffer.cpp b/trinity/Tr2GpuBuffer.cpp index d78cd14de..ded752095 100644 --- a/trinity/Tr2GpuBuffer.cpp +++ b/trinity/Tr2GpuBuffer.cpp @@ -9,8 +9,8 @@ using namespace Tr2RenderContextEnum; // Description: // Tr2GpuBuffer default constructor // -------------------------------------------------------------------------------------- -Tr2GpuBuffer::Tr2GpuBuffer( IRoot* ) - :m_count( 0 ), +Tr2GpuBuffer::Tr2GpuBuffer( IRoot* ) : + m_count( 0 ), m_format( PIXEL_FORMAT_UNKNOWN ), m_creationFlags( 0 ) { @@ -53,7 +53,7 @@ bool Tr2GpuBuffer::OnModified( Be::Var* value ) // -------------------------------------------------------------------------------------- // Description: -// Script-exposed initializer function. Assigns new values to buffer parameters and +// Script-exposed initializer function. Assigns new values to buffer parameters and // constructs AL buffer. Can be called with either 0, 2, 3 or 4 arguments. // Arguments: // count - Number of elements in the buffer @@ -65,9 +65,9 @@ bool Tr2GpuBuffer::OnModified( Be::Var* value ) // true If AL buffer is successfully created // false Otherwise // -------------------------------------------------------------------------------------- -ALResult Tr2GpuBuffer::__init__( - Be::Optional count, - Be::Optional format, +ALResult Tr2GpuBuffer::__init__( + Be::Optional count, + Be::Optional format, CreationFlags creationFlags ) { if( count.IsAssigned() && !format.IsAssigned() ) @@ -97,9 +97,9 @@ ALResult Tr2GpuBuffer::__init__( // true If AL buffer is successfully created // false Otherwise // -------------------------------------------------------------------------------------- -ALResult Tr2GpuBuffer::Create( uint32_t count, - Tr2RenderContextEnum::PixelFormat format, - CreationFlags creationFlags ) +ALResult Tr2GpuBuffer::Create( uint32_t count, + Tr2RenderContextEnum::PixelFormat format, + CreationFlags creationFlags ) { m_count = count; m_format = format; @@ -160,11 +160,11 @@ ALResult Tr2GpuBuffer::CreateBuffer() { gpuUsage = gpuUsage | Tr2GpuUsage::DRAW_INDIRECT_ARGS; } - + USE_MAIN_THREAD_RENDER_CONTEXT(); - auto hr = m_buffer.Create( - static_cast( m_format ), - m_count, + auto hr = m_buffer.Create( + static_cast( m_format ), + m_count, gpuUsage, cpuUsage, nullptr, diff --git a/trinity/Tr2GpuBuffer.h b/trinity/Tr2GpuBuffer.h index b3c6404d3..067d290bc 100644 --- a/trinity/Tr2GpuBuffer.h +++ b/trinity/Tr2GpuBuffer.h @@ -14,7 +14,7 @@ // See Also: // Tr2BufferAL // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GpuBuffer ): +BLUE_CLASS( Tr2GpuBuffer ) : public ITr2GpuBuffer, public INotify, public IInitialize, @@ -29,21 +29,21 @@ BLUE_CLASS( Tr2GpuBuffer ): enum CreationFlag { // Can the buffer be locked with write-only access - CPU_WRITABLE = 1, + CPU_WRITABLE = 1, // Is the buffer used for GPU write access - GPU_WRITABLE = 2, + GPU_WRITABLE = 2, // Is the buffer used for indirect draw calls - DRAW_INDIRECT = 4, + DRAW_INDIRECT = 4, }; typedef uint32_t CreationFlags; - Tr2GpuBuffer( IRoot* = 0 ); + Tr2GpuBuffer( IRoot* = 0 ); ~Tr2GpuBuffer(); bool Initialize(); - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); Tr2BufferAL* GetGpuBuffer( unsigned index ); @@ -53,12 +53,22 @@ BLUE_CLASS( Tr2GpuBuffer ): void SetName( const char* name ); - Tr2RenderContextEnum::PixelFormat GetFormat() const { return m_format; } + Tr2RenderContextEnum::PixelFormat GetFormat() const + { + return m_format; + } - operator Tr2BufferAL&() { return m_buffer; } - operator const Tr2BufferAL&() const { return m_buffer; } + operator Tr2BufferAL&() + { + return m_buffer; + } + operator const Tr2BufferAL&() const + { + return m_buffer; + } virtual void ReleaseResources( TriStorage s ); + private: virtual bool OnPrepareResources(); ALResult __init__( Be::Optional count, Be::Optional format, CreationFlags m_creationFlags ); @@ -66,7 +76,7 @@ BLUE_CLASS( Tr2GpuBuffer ): ALResult CreateBuffer(); // AL buffer - Tr2BufferAL m_buffer; + Tr2BufferAL m_buffer; // Number of elements in the buffer uint32_t m_count; diff --git a/trinity/Tr2GpuBuffer_Blue.cpp b/trinity/Tr2GpuBuffer_Blue.cpp index c8283908b..468f7e93c 100644 --- a/trinity/Tr2GpuBuffer_Blue.cpp +++ b/trinity/Tr2GpuBuffer_Blue.cpp @@ -6,30 +6,23 @@ BLUE_DEFINE_INTERFACE( ITr2GpuBuffer ); BLUE_DEFINE( Tr2GpuBuffer ); -Be::VarChooser Tr2GpuBufferCreationFlagChooser[] = -{ - { - "CPU_WRITABLE", - BeCast( Tr2GpuBuffer::CPU_WRITABLE ), - "Can the buffer be locked with write-only access" - }, - { - "GPU_WRITABLE", - BeCast( Tr2GpuBuffer::GPU_WRITABLE ), - "Is the buffer used for GPU write access" - }, - { - "DRAW_INDIRECT", - BeCast( Tr2GpuBuffer::DRAW_INDIRECT ), - "Is the buffer used for indirect draw calls" - }, +Be::VarChooser Tr2GpuBufferCreationFlagChooser[] = { + { "CPU_WRITABLE", + BeCast( Tr2GpuBuffer::CPU_WRITABLE ), + "Can the buffer be locked with write-only access" }, + { "GPU_WRITABLE", + BeCast( Tr2GpuBuffer::GPU_WRITABLE ), + "Is the buffer used for GPU write access" }, + { "DRAW_INDIRECT", + BeCast( Tr2GpuBuffer::DRAW_INDIRECT ), + "Is the buffer used for indirect draw calls" }, { 0 } }; -BLUE_REGISTER_ENUM_EX( - "Tr2GpuBufferFlags", - Tr2GpuBuffer::CreationFlag, - Tr2GpuBufferCreationFlagChooser, +BLUE_REGISTER_ENUM_EX( + "Tr2GpuBufferFlags", + Tr2GpuBuffer::CreationFlag, + Tr2GpuBufferCreationFlagChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); #if BLUE_WITH_PYTHON @@ -39,45 +32,45 @@ using namespace Tr2RenderContextEnum; namespace { - PyObject* PyGetData( PyObject* self, PyObject* args ) +PyObject* PyGetData( PyObject* self, PyObject* args ) +{ + if( !PyArg_ParseTuple( args, "" ) ) + { + return nullptr; + } + + Tr2GpuBuffer* pThis = BluePythonCast( self ); + if( !pThis ) + { + return nullptr; + } + if( !pThis->IsValid() ) + { + PyErr_SetString( PyExc_RuntimeError, "buffer is not valid" ); + return nullptr; + } + + auto buffer = pThis->GetGpuBuffer( 0 ); + + USE_MAIN_THREAD_RENDER_CONTEXT(); + + const void* data = nullptr; + auto hr = buffer->MapForReading( data, renderContext ); + if( FAILED( hr ) ) { - if( !PyArg_ParseTuple( args, "" ) ) - { - return nullptr; - } - - Tr2GpuBuffer* pThis = BluePythonCast( self ); - if( !pThis ) - { - return nullptr; - } - if( !pThis->IsValid() ) - { - PyErr_SetString( PyExc_RuntimeError, "buffer is not valid" ); - return nullptr; - } - - auto buffer = pThis->GetGpuBuffer( 0 ); - - USE_MAIN_THREAD_RENDER_CONTEXT(); - - const void* data = nullptr; - auto hr = buffer->MapForReading( data, renderContext ); - if( FAILED( hr ) ) - { - PyErr_SetString( BeGetException( hr ), BeGetErrorMessage( hr ) ); - return nullptr; - } - ON_BLOCK_EXIT( [&]() { buffer->UnmapForReading( renderContext ); } ); - - return PyVerCompat::ToPyBytes( static_cast( data ), buffer->GetSize() ); + PyErr_SetString( BeGetException( hr ), BeGetErrorMessage( hr ) ); + return nullptr; } + ON_BLOCK_EXIT( [&]() { buffer->UnmapForReading( renderContext ); } ); + + return PyVerCompat::ToPyBytes( static_cast( data ), buffer->GetSize() ); +} } #endif const Be::ClassInfo* Tr2GpuBuffer::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GpuBuffer, "" ) + EXPOSURE_BEGIN( Tr2GpuBuffer, "" ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) @@ -91,24 +84,24 @@ const Be::ClassInfo* Tr2GpuBuffer::ExposeToBlue() ":param count: number of elements in the buffer\n" ":param format: buffer pixel format (trinity.PIXEL_FORMAT.foo)\n" ":param creationFlags: combination of trinity.Tr2GpuBufferFlags\n" ) - MAP_ATTRIBUTE( - "count", - m_count, - "Number of elements in the buffer", + MAP_ATTRIBUTE( + "count", + m_count, + "Number of elements in the buffer", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE_WITH_CHOOSER( "format", m_format, "Buffer pixel format (trinity.PIXEL_FORMAT.foo)", - Be::READWRITE | Be::ENUM | Be::PERSIST | Be::NOTIFY, + Be::READWRITE | Be::ENUM | Be::PERSIST | Be::NOTIFY, Tr2RenderContextEnum_PixelFormat_Chooser ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "creationFlags", - m_creationFlags, - "Miscellaneous for creating a buffer", - Be::READWRITE | Be::PERSIST | Be::NOTIFY, + MAP_ATTRIBUTE_WITH_CHOOSER( + "creationFlags", + m_creationFlags, + "Miscellaneous for creating a buffer", + Be::READWRITE | Be::PERSIST | Be::NOTIFY, Tr2GpuBufferCreationFlagChooser ) - MAP_PROPERTY_READONLY( + MAP_PROPERTY_READONLY( "isValid", IsValid, "Is the underlying GPU object valid" ) diff --git a/trinity/Tr2GpuLight.h b/trinity/Tr2GpuLight.h index b1ee36781..e0801cda0 100644 --- a/trinity/Tr2GpuLight.h +++ b/trinity/Tr2GpuLight.h @@ -6,26 +6,26 @@ struct Tr2GpuLight { - Vector4 xyzr; - Vector4 dirxyzL; - Vector4 rgbX; + Vector4 xyzr; + Vector4 dirxyzL; + Vector4 rgbX; }; -inline void MakePointLight( const Vector3 xyz, +inline void MakePointLight( const Vector3 xyz, const float radius, const Vector3 rgb, Tr2GpuLight& out ) { out.xyzr = Vector4( xyz.x, xyz.y, xyz.z, radius ); - out.dirxyzL = Vector4( 0,0,0,0 ); + out.dirxyzL = Vector4( 0, 0, 0, 0 ); out.rgbX = Vector4( rgb.x, rgb.y, rgb.z, 0 ); } -inline void MakeLineSegment(const Vector3 from, - const Vector3 to, - const float radius, - const Vector3 rgb, - Tr2GpuLight& out ) +inline void MakeLineSegment( const Vector3 from, + const Vector3 to, + const float radius, + const Vector3 rgb, + Tr2GpuLight& out ) { out.xyzr = Vector4( from.x, from.y, from.z, radius ); Vector3 dir = to - from; @@ -37,7 +37,7 @@ inline void MakeLineSegment(const Vector3 from, } else { - out.dirxyzL = Vector4( 0,0,0,0 ); + out.dirxyzL = Vector4( 0, 0, 0, 0 ); } out.rgbX = Vector4( rgb.x, rgb.y, rgb.z, 0 ); } diff --git a/trinity/Tr2GpuProfiler.cpp b/trinity/Tr2GpuProfiler.cpp index f3784864d..0910d8117 100644 --- a/trinity/Tr2GpuProfiler.cpp +++ b/trinity/Tr2GpuProfiler.cpp @@ -167,7 +167,6 @@ BlueScriptValue Tr2GpuProfiler::GetRegionReport( size_t& index ) auto value = PyFloat_FromDouble( zone.timer.GetTime( renderContext ) ); PyDict_SetItemString( stats, "GPU Time", value ); Py_DecRef( value ); - } Tr2PipelineStatsDataAL data; if( SUCCEEDED( zone.query.GetStats( data, renderContext ) ) ) diff --git a/trinity/Tr2GpuProfiler.h b/trinity/Tr2GpuProfiler.h index f87ebce8b..4a97f668f 100644 --- a/trinity/Tr2GpuProfiler.h +++ b/trinity/Tr2GpuProfiler.h @@ -5,7 +5,7 @@ BLUE_DECLARE( Tr2GpuProfiler ); BLUE_CLASS_IMPL( Tr2GpuProfiler ); -class Tr2GpuProfiler: public IRoot +class Tr2GpuProfiler : public IRoot { public: EXPOSE_TO_BLUE(); @@ -31,6 +31,7 @@ class Tr2GpuProfiler: public IRoot bool IsDataReady(); BlueScriptValue GetFrameReport(); void ClearData(); + private: struct Zone { @@ -49,7 +50,7 @@ class Tr2GpuProfiler: public IRoot std::vector m_zones; std::vector m_stack; - + Tr2FenceAL m_frameFence; bool m_pendingCapture; bool m_capturing; @@ -63,6 +64,7 @@ class Tr2GpuProfilerZone Tr2GpuProfilerZone( const Tr2GpuProfilerZone& ) = delete; Tr2GpuProfilerZone& operator=( const Tr2GpuProfilerZone& ) = delete; ~Tr2GpuProfilerZone(); + private: Tr2RenderContextAL& context; }; diff --git a/trinity/Tr2GpuProfiler_Blue.cpp b/trinity/Tr2GpuProfiler_Blue.cpp index f032b92a4..280c07253 100644 --- a/trinity/Tr2GpuProfiler_Blue.cpp +++ b/trinity/Tr2GpuProfiler_Blue.cpp @@ -25,9 +25,9 @@ const Be::ClassInfo* Tr2GpuProfiler::ExposeToBlue() MAP_INTERFACE( Tr2GpuProfiler ) MAP_METHOD_AND_WRAP( "Capture", Capture, "Requests profile capture for the next frame" ) - MAP_METHOD_AND_WRAP( - "GetFrameReport", - GetFrameReport, + MAP_METHOD_AND_WRAP( + "GetFrameReport", + GetFrameReport, "Returns captured data for zone tree. The data returned is a tree with each node\n" "being a tuple (owner, label, stats, children) where:\n" "owner - zone\'s owner object or None,\n" @@ -35,11 +35,9 @@ const Be::ClassInfo* Tr2GpuProfiler::ExposeToBlue() "stats - a dict with captured stats,\n" "children - a list of child zone data (same tuple format).\n" "If the data is not ready the function raises a RuntimeError.\n" - ":rtype: (blue.IRoot|None, str, dict, list)\n" - ) + ":rtype: (blue.IRoot|None, str, dict, list)\n" ) MAP_METHOD_AND_WRAP( "IsReportReady", IsDataReady, "Check if the captured data is ready to be queried with GetFrameReport method" ) MAP_METHOD_AND_WRAP( "ClearData", ClearData, "Clears any captured data" ) - - EXPOSURE_END(); + EXPOSURE_END(); } \ No newline at end of file diff --git a/trinity/Tr2GpuResourcePool.cpp b/trinity/Tr2GpuResourcePool.cpp index 6b1c86916..2f7109567 100644 --- a/trinity/Tr2GpuResourcePool.cpp +++ b/trinity/Tr2GpuResourcePool.cpp @@ -78,8 +78,8 @@ std::string ToString( const Tr2BitmapDimensions& desc ) } -Tr2GpuResourcePool::Tr2GpuResourcePool( Tr2GpuResourcePool* outer ) - : m_outer( outer ) +Tr2GpuResourcePool::Tr2GpuResourcePool( Tr2GpuResourcePool* outer ) : + m_outer( outer ) { AllGpuResourcePools().push_back( this ); } @@ -117,7 +117,7 @@ Tr2GpuResourcePool::Texture Tr2GpuResourcePool::GetTempTexture( const char* name } auto found = find_if( begin( m_tempTextures ), end( m_tempTextures ), [&]( const auto& x ) { - if ( m_debugMode ) + if( m_debugMode ) { return x->lockCount == 0 && x->resource.GetDesc() == desc && x->resource.GetGpuUsage() == gpuUsage && x->name == name; } @@ -172,7 +172,7 @@ Tr2GpuResourcePool::Texture Tr2GpuResourcePool::GetPersistentTexture( const char return Texture(); } tex->resource.SetName( name ); - if( auto initFunc = std::get_if < std::function>( &initializer ) ) + if( auto initFunc = std::get_if>( &initializer ) ) { ( *initFunc )( tex->resource, renderContext ); } @@ -187,7 +187,7 @@ Tr2GpuResourcePool::Texture Tr2GpuResourcePool::GetPersistentTexture( const char Tr2GpuResourcePool::Buffer Tr2GpuResourcePool::GetTempBuffer( const char* name, const Tr2BufferDescriptionAL& desc ) { - if ( m_outer && !m_debugMode ) + if( m_outer && !m_debugMode ) { return m_outer->GetTempBuffer( name, desc ); } @@ -197,7 +197,7 @@ Tr2GpuResourcePool::Buffer Tr2GpuResourcePool::GetTempBuffer( const char* name, return {}; } auto found = find_if( begin( m_tempBuffers ), end( m_tempBuffers ), [&]( const auto& x ) { - if ( m_debugMode ) + if( m_debugMode ) { return x->lockCount == 0 && CompatibleDescriptions( x->resource.GetDesc(), desc ) && x->name == name; } @@ -244,7 +244,7 @@ Tr2GpuResourcePool::Buffer Tr2GpuResourcePool::GetPersistentBuffer( const char* return Buffer(); } buf->resource.SetName( name ); - if( auto initFunc = std::get_if>( &initializer ) ) + if( auto initFunc = std::get_if>( &initializer ) ) { ( *initFunc )( buf->resource, renderContext ); } diff --git a/trinity/Tr2GpuStructuredBuffer.cpp b/trinity/Tr2GpuStructuredBuffer.cpp index 6ff5ba489..65e978d1b 100644 --- a/trinity/Tr2GpuStructuredBuffer.cpp +++ b/trinity/Tr2GpuStructuredBuffer.cpp @@ -9,8 +9,8 @@ using namespace Tr2RenderContextEnum; // Description: // Tr2GpuStructuredBuffer default constructor // -------------------------------------------------------------------------------------- -Tr2GpuStructuredBuffer::Tr2GpuStructuredBuffer( IRoot* ) - :m_count( 0 ), +Tr2GpuStructuredBuffer::Tr2GpuStructuredBuffer( IRoot* ) : + m_count( 0 ), m_stride( 0 ), m_creationFlags( 0 ) { @@ -26,7 +26,7 @@ Tr2GpuStructuredBuffer::~Tr2GpuStructuredBuffer() // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- ALResult Tr2GpuStructuredBuffer::py__init__( uint32_t count, uint32_t stride, CreationFlags creationFlags ) { @@ -132,14 +132,14 @@ ALResult Tr2GpuStructuredBuffer::CreateBuffer() { cpuUsage = Tr2CpuUsage::WRITE_OFTEN; } - + USE_MAIN_THREAD_RENDER_CONTEXT(); - auto hr = m_buffer.Create( + auto hr = m_buffer.Create( m_stride, m_count, gpuUsage, cpuUsage, - nullptr, + nullptr, renderContext ); if( !m_name.empty() && SUCCEEDED( hr ) ) { diff --git a/trinity/Tr2GpuStructuredBuffer.h b/trinity/Tr2GpuStructuredBuffer.h index 4d7f99ccf..28ce35c21 100644 --- a/trinity/Tr2GpuStructuredBuffer.h +++ b/trinity/Tr2GpuStructuredBuffer.h @@ -9,13 +9,13 @@ // -------------------------------------------------------------------------------------- // Description: -// A Blue-exposed wrapper around Tr2BufferAL class for structured buffers, i.e. -// buffers containing structures as elements. The creation parameters for the class are +// A Blue-exposed wrapper around Tr2BufferAL class for structured buffers, i.e. +// buffers containing structures as elements. The creation parameters for the class are // persisted, but the contents of the buffer is not. // See Also: // Tr2BufferAL // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2GpuStructuredBuffer ): +BLUE_CLASS( Tr2GpuStructuredBuffer ) : public ITr2GpuBuffer, public INotify, public IInitialize, @@ -30,9 +30,9 @@ BLUE_CLASS( Tr2GpuStructuredBuffer ): enum CreationFlag { // Can the buffer be locked with write-only access - CPU_WRITABLE = 1, + CPU_WRITABLE = 1, // Is the buffer used for GPU write access - GPU_WRITABLE = 2, + GPU_WRITABLE = 2, }; typedef uint32_t CreationFlags; @@ -44,7 +44,7 @@ BLUE_CLASS( Tr2GpuStructuredBuffer ): bool Initialize(); - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); Tr2BufferAL* GetGpuBuffer( unsigned index ); @@ -54,16 +54,23 @@ BLUE_CLASS( Tr2GpuStructuredBuffer ): void SetName( const char* name ); - operator Tr2BufferAL&() { return m_buffer; } - operator const Tr2BufferAL&() const { return m_buffer; } + operator Tr2BufferAL&() + { + return m_buffer; + } + operator const Tr2BufferAL&() const + { + return m_buffer; + } virtual void ReleaseResources( TriStorage s ); + private: virtual bool OnPrepareResources(); ALResult CreateBuffer(); // AL buffer - Tr2BufferAL m_buffer; + Tr2BufferAL m_buffer; std::string m_name; diff --git a/trinity/Tr2GpuStructuredBuffer_Blue.cpp b/trinity/Tr2GpuStructuredBuffer_Blue.cpp index 4a4a0d15f..41d7e3165 100644 --- a/trinity/Tr2GpuStructuredBuffer_Blue.cpp +++ b/trinity/Tr2GpuStructuredBuffer_Blue.cpp @@ -12,45 +12,45 @@ using namespace Tr2RenderContextEnum; namespace { - PyObject* PyGetData( PyObject* self, PyObject* args ) +PyObject* PyGetData( PyObject* self, PyObject* args ) +{ + if( !PyArg_ParseTuple( args, "" ) ) { - if( !PyArg_ParseTuple( args, "" ) ) - { - return nullptr; - } - - Tr2GpuStructuredBuffer* pThis = BluePythonCast( self ); - if( !pThis ) - { - return nullptr; - } - if( !pThis->IsValid() ) - { - PyErr_SetString( PyExc_RuntimeError, "buffer is not valid" ); - return nullptr; - } + return nullptr; + } - auto buffer = pThis->GetGpuBuffer( 0 ); + Tr2GpuStructuredBuffer* pThis = BluePythonCast( self ); + if( !pThis ) + { + return nullptr; + } + if( !pThis->IsValid() ) + { + PyErr_SetString( PyExc_RuntimeError, "buffer is not valid" ); + return nullptr; + } - USE_MAIN_THREAD_RENDER_CONTEXT(); + auto buffer = pThis->GetGpuBuffer( 0 ); - const void* data = nullptr; - auto hr = buffer->MapForReading( data, renderContext ); - if( FAILED( hr ) ) - { - PyErr_SetString( BeGetException( hr ), BeGetErrorMessage( hr ) ); - return nullptr; - } - ON_BLOCK_EXIT( [&]() { buffer->UnmapForReading( renderContext ); } ); + USE_MAIN_THREAD_RENDER_CONTEXT(); - return PyVerCompat::ToPyBytes( static_cast( data ), buffer->GetSize() ); + const void* data = nullptr; + auto hr = buffer->MapForReading( data, renderContext ); + if( FAILED( hr ) ) + { + PyErr_SetString( BeGetException( hr ), BeGetErrorMessage( hr ) ); + return nullptr; } + ON_BLOCK_EXIT( [&]() { buffer->UnmapForReading( renderContext ); } ); + + return PyVerCompat::ToPyBytes( static_cast( data ), buffer->GetSize() ); +} } #endif const Be::ClassInfo* Tr2GpuStructuredBuffer::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GpuStructuredBuffer, "" ) + EXPOSURE_BEGIN( Tr2GpuStructuredBuffer, "" ) MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) @@ -64,22 +64,22 @@ const Be::ClassInfo* Tr2GpuStructuredBuffer::ExposeToBlue() ":param count: number of elements in the buffer\n" ":param stride: size of buffer element in bytes\n" ":param cpuWritable: if CPU should have write access to the buffer\n" ) - MAP_ATTRIBUTE( - "count", - m_count, - "Number of elements in the buffer", + MAP_ATTRIBUTE( + "count", + m_count, + "Number of elements in the buffer", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "stride", - m_stride, - "Size of buffer element in bytes", + MAP_ATTRIBUTE( + "stride", + m_stride, + "Size of buffer element in bytes", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( - "creationFlags", - m_creationFlags, - "If CPU should have write access to the buffer", + MAP_ATTRIBUTE( + "creationFlags", + m_creationFlags, + "If CPU should have write access to the buffer", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_PROPERTY_READONLY( + MAP_PROPERTY_READONLY( "isValid", IsValid, "Is the underlying GPU object valid" ) @@ -92,5 +92,5 @@ const Be::ClassInfo* Tr2GpuStructuredBuffer::ExposeToBlue() "WARNING: the method is slow and should not be used for anything but debugging.\n" ":rtype: str" ) #endif - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2GrannyAnimation.cpp b/trinity/Tr2GrannyAnimation.cpp index eaff42536..0dbe67aa5 100644 --- a/trinity/Tr2GrannyAnimation.cpp +++ b/trinity/Tr2GrannyAnimation.cpp @@ -21,46 +21,46 @@ TRI_REGISTER_SETTING( "debugBoneLabelFont", g_debugBoneLabelFont ); namespace Tr2GrannyAnimationUtils { - bool GetBoneList( Tr2GrannyAnimation* animationUpdater, const Float4x3*& bones, size_t& boneCount ) +bool GetBoneList( Tr2GrannyAnimation* animationUpdater, const Float4x3*& bones, size_t& boneCount ) +{ + if( animationUpdater && animationUpdater->IsInitialized() ) { - if( animationUpdater && animationUpdater->IsInitialized() ) + boneCount = size_t( animationUpdater->GetMeshBoneCount() ); + if( boneCount ) { - boneCount = size_t( animationUpdater->GetMeshBoneCount() ); - if( boneCount ) - { - bones = animationUpdater->GetMeshBoneMatrixList(); - return true; - } - else - { - bones = nullptr; - } + bones = animationUpdater->GetMeshBoneMatrixList(); + return true; } else { - boneCount = 0; bones = nullptr; } - return false; } - - std::vector CreateMapping( const cmf::Skeleton& skeleton, cmf::Span boneBindings, uint32_t meshBoneCount ) + else { - std::vector mapping( meshBoneCount, -1 ); - for( uint32_t meshBoneIndex = 0; meshBoneIndex < meshBoneCount; ++meshBoneIndex ) - { - const auto boundBoneName = boneBindings[meshBoneIndex].name; + boneCount = 0; + bones = nullptr; + } + return false; +} - auto foundBone = std::find_if( skeleton.bones.begin(), skeleton.bones.end(), [boundBoneName]( cmf::String boneName ) { - return boundBoneName == boneName; - } ); - if( foundBone != skeleton.bones.end() ) - { - mapping[meshBoneIndex] = (int32_t)std::distance( skeleton.bones.begin(), foundBone ); - } +std::vector CreateMapping( const cmf::Skeleton& skeleton, cmf::Span boneBindings, uint32_t meshBoneCount ) +{ + std::vector mapping( meshBoneCount, -1 ); + for( uint32_t meshBoneIndex = 0; meshBoneIndex < meshBoneCount; ++meshBoneIndex ) + { + const auto boundBoneName = boneBindings[meshBoneIndex].name; + + auto foundBone = std::find_if( skeleton.bones.begin(), skeleton.bones.end(), [boundBoneName]( cmf::String boneName ) { + return boundBoneName == boneName; + } ); + if( foundBone != skeleton.bones.end() ) + { + mapping[meshBoneIndex] = (int32_t)std::distance( skeleton.bones.begin(), foundBone ); } - return mapping; } + return mapping; +} }; static const int MAX_JOINT_COUNT = 254; @@ -107,10 +107,10 @@ Tr2GrannyAnimation::~Tr2GrannyAnimation() { m_grannyRes->RemoveNotifyTarget( this ); } - - for ( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) + + for( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) { - if ( it->second ) + if( it->second ) { it->second->RemoveNotifyTarget( this ); } @@ -118,18 +118,17 @@ Tr2GrannyAnimation::~Tr2GrannyAnimation() } #if WITH_GRANNY -int AnimNameToIndex( const granny_file_info* fi, const char *name ) +int AnimNameToIndex( const granny_file_info* fi, const char* name ) { int index = fi->AnimationCount; - for( int i = 0; i < fi->AnimationCount ; ++i ) + for( int i = 0; i < fi->AnimationCount; ++i ) { if( strcmp( fi->Animations[i]->Name, name ) == 0 ) { index = i; break; } - } return index; @@ -154,7 +153,7 @@ const cmf::Data* GetSecondaryCMFFileInfo( const std::string& cmfResPath, const T #if WITH_GRANNY granny_file_info* GetSecondaryFileInfo( const std::string& grannyResPath, const TriGrannyResPtr grannyPtr ) { - if ( !grannyPtr || !grannyPtr->IsPrepared() ) + if( !grannyPtr || !grannyPtr->IsPrepared() ) { return nullptr; } @@ -224,18 +223,18 @@ granny_animation* Tr2GrannyAnimation::FindGrannyAnimationByName( const char* nam return fi->Animations[animIx]; } - for ( auto it=m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); ++it ) + for( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); ++it ) { - if ( !it->second ) + if( !it->second ) { continue; } fi = GetSecondaryFileInfo( it->first, it->second ); - if (!fi) + if( !fi ) { continue; } - + animIx = AnimNameToIndex( fi, name ); if( animIx != fi->AnimationCount ) @@ -326,7 +325,7 @@ bool Tr2GrannyAnimation::Initialize() m_grannyRes->RemoveNotifyTarget( this ); m_grannyRes.Unlock(); } - + if( !m_geometryRes && !m_resPath.empty() ) { BeResMan->GetResource( m_resPath.c_str(), "raw", BlueInterfaceIID(), (void**)&m_grannyRes ); @@ -338,21 +337,21 @@ bool Tr2GrannyAnimation::Initialize() } m_boneBounds.clear(); - + return true; } void Tr2GrannyAnimation::LoadSecondaryResPath( const std::string& val ) { - if ( m_secondaryGrannyRes[val] ) + if( m_secondaryGrannyRes[val] ) { m_secondaryGrannyRes[val]->RemoveNotifyTarget( this ); m_secondaryGrannyRes[val].Unlock(); } - BeResMan->GetResource( val.c_str(), "raw", BlueInterfaceIID(), (void**)&m_secondaryGrannyRes[val]); + BeResMan->GetResource( val.c_str(), "raw", BlueInterfaceIID(), (void**)&m_secondaryGrannyRes[val] ); - if ( m_secondaryGrannyRes[val] ) + if( m_secondaryGrannyRes[val] ) { m_secondaryGrannyRes[val]->AddNotifyTarget( this ); } @@ -384,7 +383,7 @@ granny_file_info* Tr2GrannyAnimation::GetFileInfo() const { return m_geometryRes->GetGrannyInfo(); } - + return nullptr; } #endif @@ -705,9 +704,9 @@ void Tr2GrannyAnimation::RebuildCachedData( BlueAsyncRes* p ) if( m_useMeshBinding ) { m_modelIndex = -1; - for( int i = 0; i < fi->ModelCount ; ++i ) + for( int i = 0; i < fi->ModelCount; ++i ) { - for( int j = 0; j < fi->Models[i]->MeshBindingCount ; ++j ) + for( int j = 0; j < fi->Models[i]->MeshBindingCount; ++j ) { if( fi->Models[i]->MeshBindings[j].Mesh == fi->Meshes[0] ) { @@ -727,7 +726,7 @@ void Tr2GrannyAnimation::RebuildCachedData( BlueAsyncRes* p ) // A named model is specified - look for its index m_modelIndex = -1; - for( int i = 0; i < fi->ModelCount ; ++i ) + for( int i = 0; i < fi->ModelCount; ++i ) { if( m_model == fi->Models[i]->Name ) { @@ -736,7 +735,7 @@ void Tr2GrannyAnimation::RebuildCachedData( BlueAsyncRes* p ) } } } - + if( m_modelIndex != -1 ) { m_baseLayer.InitializeAnimationLayer( this ); @@ -755,7 +754,7 @@ void Tr2GrannyAnimation::RebuildCachedData( BlueAsyncRes* p ) if( m_meshBindingIndex != -1 ) { - m_meshBinding = GrannyNewMeshBinding ( fi->Models[ m_modelIndex ]->MeshBindings[ m_meshBindingIndex ].Mesh, m_skeleton, m_skeleton ); + m_meshBinding = GrannyNewMeshBinding( fi->Models[m_modelIndex]->MeshBindings[m_meshBindingIndex].Mesh, m_skeleton, m_skeleton ); } else { @@ -787,11 +786,11 @@ void Tr2GrannyAnimation::RebuildCachedData( BlueAsyncRes* p ) } } else - { - m_skeleton = nullptr; - m_worldPose = nullptr; - m_localPose = nullptr; - m_compositePose = nullptr; + { + m_skeleton = nullptr; + m_worldPose = nullptr; + m_localPose = nullptr; + m_compositePose = nullptr; m_baseLayer.Cleanup(); for( auto it = m_animationLayers.begin(); it != m_animationLayers.end(); it++ ) @@ -872,8 +871,7 @@ bool Tr2GrannyAnimation::InitializeBoundingInfo() for( int boneIdx = 0; boneIdx < skeleton.bones.size(); boneIdx++ ) { auto name = skeleton.bones[boneIdx]; - auto boneBinding = std::find_if( boneBindings.begin(), boneBindings.end(), [name]( const cmf::BoneBinding& bb ) - { + auto boneBinding = std::find_if( boneBindings.begin(), boneBindings.end(), [name]( const cmf::BoneBinding& bb ) { return name == bb.name; } ); if( boneBinding != boneBindings.end() ) @@ -893,7 +891,7 @@ bool Tr2GrannyAnimation::InitializeBoundingInfo() m_boneBounds.push_back( bounds ); } } - + return true; } #if WITH_GRANNY @@ -952,7 +950,7 @@ bool Tr2GrannyAnimation::InitializeBoundingInfo() #endif } -bool Tr2GrannyAnimation::GetDynamicBounds( Vector4& boundingSphere, Vector3 &aabbMin, Vector3 &aabbMax ) +bool Tr2GrannyAnimation::GetDynamicBounds( Vector4& boundingSphere, Vector3& aabbMin, Vector3& aabbMax ) { if( IsUsingCMF() ) { @@ -1256,8 +1254,8 @@ void Tr2GrannyAnimation::SetResPath( const std::string& val ) void Tr2GrannyAnimation::AddSecondaryResPath( const std::string& val ) { - auto fi=m_secondaryGrannyRes.find( val ); - if ( fi == m_secondaryGrannyRes.end() ) + auto fi = m_secondaryGrannyRes.find( val ); + if( fi == m_secondaryGrannyRes.end() ) { m_secondaryGrannyRes[val] = nullptr; LoadSecondaryResPath( val ); @@ -1266,10 +1264,10 @@ void Tr2GrannyAnimation::AddSecondaryResPath( const std::string& val ) const std::string Tr2GrannyAnimation::GetSecondaryAnimationName( const std::string& resPath, int index ) const { - auto fi=m_secondaryGrannyRes.find( resPath ); - if ( fi != m_secondaryGrannyRes.end() ) + auto fi = m_secondaryGrannyRes.find( resPath ); + if( fi != m_secondaryGrannyRes.end() ) { - auto animName = fi->second->GetAnimationName(index); + auto animName = fi->second->GetAnimationName( index ); return animName; } return ""; @@ -1309,49 +1307,49 @@ bool Tr2GrannyAnimation::CalculateSkinnedBoundingBoxFromTransform( const Matrix& return false; } - // Known input and output vertex format - granny_mesh* mesh = fi->Models[ m_modelIndex ]->MeshBindings[ m_meshBindingIndex ].Mesh; - granny_int32x vertCount = GrannyGetMeshVertexCount( mesh ); + // Known input and output vertex format + granny_mesh* mesh = fi->Models[m_modelIndex]->MeshBindings[m_meshBindingIndex].Mesh; + granny_int32x vertCount = GrannyGetMeshVertexCount( mesh ); - std::vector sourceVerts( vertCount ); - std::vector deformedVerts( vertCount ); + std::vector sourceVerts( vertCount ); + std::vector deformedVerts( vertCount ); - GrannyCopyMeshVertices(mesh, GrannyPWN313VertexType, &sourceVerts[0]); + GrannyCopyMeshVertices( mesh, GrannyPWN313VertexType, &sourceVerts[0] ); - granny_mesh_deformer* deformer = GrannyNewMeshDeformer(GrannyPWN313VertexType, - GrannyPN33VertexType, - GrannyDeformPositionNormal, - GrannyDontAllowUncopiedTail); + granny_mesh_deformer* deformer = GrannyNewMeshDeformer( GrannyPWN313VertexType, + GrannyPN33VertexType, + GrannyDeformPositionNormal, + GrannyDontAllowUncopiedTail ); if( !deformer ) { return false; } - GrannyDeformVertices(deformer, GrannyGetMeshBindingFromBoneIndices( m_meshBinding ), - (granny_real32*)GrannyGetWorldPoseComposite4x4Array( m_worldPose ), vertCount, &sourceVerts[0], &deformedVerts[0] ); + GrannyDeformVertices( deformer, GrannyGetMeshBindingFromBoneIndices( m_meshBinding ), (granny_real32*)GrannyGetWorldPoseComposite4x4Array( m_worldPose ), vertCount, &sourceVerts[0], &deformedVerts[0] ); // Get the transformed bounding box - bbMin = Vector3( FLT_MAX, FLT_MAX, FLT_MAX ); + bbMin = Vector3( FLT_MAX, FLT_MAX, FLT_MAX ); bbMax = Vector3( -FLT_MAX, -FLT_MAX, -FLT_MAX ); - for (int v = 0; v < vertCount; ++v) - { - Vector4 pos( - deformedVerts[v].Position[0] + fi->Models[ m_modelIndex ]->InitialPlacement.Position[0], - deformedVerts[v].Position[1] + fi->Models[ m_modelIndex ]->InitialPlacement.Position[1], - deformedVerts[v].Position[2] + fi->Models[ m_modelIndex ]->InitialPlacement.Position[2], 1 ); + for( int v = 0; v < vertCount; ++v ) + { + Vector4 pos( + deformedVerts[v].Position[0] + fi->Models[m_modelIndex]->InitialPlacement.Position[0], + deformedVerts[v].Position[1] + fi->Models[m_modelIndex]->InitialPlacement.Position[1], + deformedVerts[v].Position[2] + fi->Models[m_modelIndex]->InitialPlacement.Position[2], + 1 ); pos = Transform( pos, transform ); pos /= pos.w; - bbMin.x = min(bbMin.x, pos.x); - bbMax.x = max(bbMax.x, pos.x); - - bbMin.y = min(bbMin.y, pos.y); - bbMax.y = max(bbMax.y, pos.y); - - bbMin.z = min(bbMin.z, pos.z); - bbMax.z = max(bbMax.z, pos.z); - } + bbMin.x = min( bbMin.x, pos.x ); + bbMax.x = max( bbMax.x, pos.x ); + + bbMin.y = min( bbMin.y, pos.y ); + bbMax.y = max( bbMax.y, pos.y ); + + bbMin.z = min( bbMin.z, pos.z ); + bbMax.z = max( bbMax.z, pos.z ); + } return true; } @@ -1374,26 +1372,25 @@ Vector4 Tr2GrannyAnimation::CalculateSkinnedBoundingSphere( granny_file_info* fi return Vector4( 0.f, 0.f, 0.f, -1.f ); } - // Known input and output vertex format - granny_mesh* mesh = fi->Models[ m_modelIndex ]->MeshBindings[ m_meshBindingIndex ].Mesh; - granny_int32x vertCount = GrannyGetMeshVertexCount( mesh ); + // Known input and output vertex format + granny_mesh* mesh = fi->Models[m_modelIndex]->MeshBindings[m_meshBindingIndex].Mesh; + granny_int32x vertCount = GrannyGetMeshVertexCount( mesh ); - std::vector sourceVerts( vertCount ); - std::vector deformedVerts( vertCount ); + std::vector sourceVerts( vertCount ); + std::vector deformedVerts( vertCount ); - GrannyCopyMeshVertices( mesh, GrannyPWN313VertexType, &sourceVerts[0] ); + GrannyCopyMeshVertices( mesh, GrannyPWN313VertexType, &sourceVerts[0] ); - granny_mesh_deformer* deformer = GrannyNewMeshDeformer(GrannyPWN313VertexType, - GrannyPN33VertexType, - GrannyDeformPositionNormal, - GrannyDontAllowUncopiedTail); + granny_mesh_deformer* deformer = GrannyNewMeshDeformer( GrannyPWN313VertexType, + GrannyPN33VertexType, + GrannyDeformPositionNormal, + GrannyDontAllowUncopiedTail ); if( !deformer ) { return Vector4( 0.f, 0.f, 0.f, -1.f ); } - GrannyDeformVertices(deformer, GrannyGetMeshBindingFromBoneIndices( m_meshBinding ), - (granny_real32*)GrannyGetWorldPoseComposite4x4Array( m_worldPose ), vertCount, &sourceVerts[0], &deformedVerts[0] ); + GrannyDeformVertices( deformer, GrannyGetMeshBindingFromBoneIndices( m_meshBinding ), (granny_real32*)GrannyGetWorldPoseComposite4x4Array( m_worldPose ), vertCount, &sourceVerts[0], &deformedVerts[0] ); // Gather a list of pointers to the positions std::vector points( vertCount ); @@ -1405,7 +1402,7 @@ Vector4 Tr2GrannyAnimation::CalculateSkinnedBoundingSphere( granny_file_info* fi // Calculate the bounding sphere Vector4 boundingSphere; BoundingSphereFromPoints( boundingSphere, &points[0], points.size() ); - + return boundingSphere; } #endif @@ -1422,7 +1419,7 @@ const cmf::Skeleton* Tr2GrannyAnimation::GetSkeleton() const return nullptr; } -const std::vector& Tr2GrannyAnimation::GetWorldTransforms() const +const std::vector& Tr2GrannyAnimation::GetWorldTransforms() const { return this->m_worldTransforms; } @@ -1460,29 +1457,29 @@ bool Tr2GrannyAnimation::PlayLayerAnimationByName( const char* layerName, const } bool secondaryGrannyResPrepared = true; - for ( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) + for( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) { secondaryGrannyResPrepared = secondaryGrannyResPrepared && it->second->IsPrepared(); } - if( ( !m_grannyRes && !m_geometryRes ) || - ( m_grannyRes && !m_grannyRes->IsPrepared() ) || - ( m_geometryRes && !m_geometryRes->IsPrepared() ) || - !secondaryGrannyResPrepared ) + if( ( !m_grannyRes && !m_geometryRes ) || + ( m_grannyRes && !m_grannyRes->IsPrepared() ) || + ( m_geometryRes && !m_geometryRes->IsPrepared() ) || + !secondaryGrannyResPrepared ) { layer->QueueAnimation( animName, replace, loopCount, delay, speed, clearWhenDone ); return true; } bool secondaryGrannyResGood = true; - for ( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) + for( auto it = m_secondaryGrannyRes.begin(); it != m_secondaryGrannyRes.end(); it++ ) { secondaryGrannyResGood = secondaryGrannyResGood && it->second->IsGood(); } if( ( ( m_grannyRes && !m_grannyRes->IsGood() ) || - ( m_geometryRes && !m_geometryRes->IsGood() ) || - !secondaryGrannyResGood ) ) + ( m_geometryRes && !m_geometryRes->IsGood() ) || + !secondaryGrannyResGood ) ) { CCP_LOGERR( "Animation resource failed to load!" ); return false; @@ -1502,7 +1499,7 @@ void Tr2GrannyAnimation::ClearAnimations() m_baseLayer.ClearAnimations(); } -void Tr2GrannyAnimation::ApplyBoneOffsets(unsigned i) +void Tr2GrannyAnimation::ApplyBoneOffsets( unsigned i ) { if( IsUsingCMF() ) { @@ -1804,7 +1801,7 @@ void Tr2GrannyAnimation::PostPhysicsAnimation( Be::Time time, const Matrix& mode return; } -const std::string * Tr2GrannyAnimation::GetAnimationBoneList( unsigned int& numBones ) const +const std::string* Tr2GrannyAnimation::GetAnimationBoneList( unsigned int& numBones ) const { numBones = (unsigned int)m_boneList.size(); if( numBones ) @@ -1859,24 +1856,25 @@ void Tr2GrannyAnimation::Cleanup() m_worldTransforms.clear(); #if WITH_GRANNY - if ( m_localPose ) { + if( m_localPose ) + { GrannyFreeLocalPose( m_localPose ); m_localPose = nullptr; } - - if ( m_compositePose ) + + if( m_compositePose ) { GrannyFreeLocalPose( m_compositePose ); m_compositePose = nullptr; } - if ( m_worldPose ) + if( m_worldPose ) { GrannyFreeWorldPose( m_worldPose ); m_worldPose = nullptr; } - if ( m_meshBinding ) + if( m_meshBinding ) { GrannyFreeMeshBinding( m_meshBinding ); m_meshBinding = nullptr; @@ -1887,7 +1885,7 @@ void Tr2GrannyAnimation::Cleanup() m_boneList.clear(); - if ( m_meshBoneMatrixList ) + if( m_meshBoneMatrixList ) { CCP_ALIGNED_FREE( m_meshBoneMatrixList ); m_meshBoneMatrixList = nullptr; @@ -1971,7 +1969,7 @@ void Tr2GrannyAnimation::ChainAnimationEx( const char* animName, int loopCount, float Tr2GrannyAnimation::GetAnimationTime() { - if ( m_paused ) + if( m_paused ) { return m_pauseTime; } @@ -1980,13 +1978,13 @@ float Tr2GrannyAnimation::GetAnimationTime() void Tr2GrannyAnimation::TogglePauseAnimations( bool pause ) { - if ( m_paused && !pause ) + if( m_paused && !pause ) { m_paused = false; m_totalPauseOffset = Tr2Renderer::GetAnimationTime() - m_pauseTime; m_pauseTime = 0.0; } - else if ( !m_paused && pause ) + else if( !m_paused && pause ) { m_paused = true; m_pauseTime = Tr2Renderer::GetAnimationTime() - m_totalPauseOffset; @@ -2054,9 +2052,9 @@ void Tr2GrannyAnimation::AddAnimationLayer( const char* layerName, float layerWe GetAnimationLayer( layerName )->InitializeAnimationLayer( this ); } -float Tr2GrannyAnimation::GetLayerWeight(const char* layerName) +float Tr2GrannyAnimation::GetLayerWeight( const char* layerName ) { - if ( GetAnimationLayer( layerName ) ) + if( GetAnimationLayer( layerName ) ) { return GetAnimationLayer( layerName )->GetLayerWeight(); } @@ -2065,7 +2063,7 @@ float Tr2GrannyAnimation::GetLayerWeight(const char* layerName) void Tr2GrannyAnimation::SetLayerWeight( const char* layerName, float layerWeight ) { - if ( GetAnimationLayer( layerName ) ) + if( GetAnimationLayer( layerName ) ) { return GetAnimationLayer( layerName )->SetLayerWeight( layerWeight ); } @@ -2075,17 +2073,17 @@ void Tr2GrannyAnimation::SetLayerControlParam( const char* layerName, float cont { const char* base_name_string = ""; - if ( !layerName || !strcmp(layerName, base_name_string) ) + if( !layerName || !strcmp( layerName, base_name_string ) ) { GetAnimationLayer( nullptr )->SetControlParam( controlParam ); } else { auto animLayer = GetAnimationLayer( layerName ); - if ( !animLayer ) + if( !animLayer ) { - CCP_LOGERR( "SetLayerControlParam: Layer name '%s' not found.", layerName ); - return; + CCP_LOGERR( "SetLayerControlParam: Layer name '%s' not found.", layerName ); + return; } animLayer->SetControlParam( controlParam ); } @@ -2094,12 +2092,12 @@ void Tr2GrannyAnimation::SetLayerControlParam( const char* layerName, float cont void Tr2GrannyAnimation::SetLayerControlParamSkewRate( const char* layerName, float skewRate ) { const char* base_name_string = ""; - Tr2GrannyAnimationLayer *layer; + Tr2GrannyAnimationLayer* layer; - if ( !strcmp(layerName, base_name_string) ) + if( !strcmp( layerName, base_name_string ) ) { layer = GetAnimationLayer( nullptr ); - if ( !layer ) + if( !layer ) { return; } @@ -2108,7 +2106,7 @@ void Tr2GrannyAnimation::SetLayerControlParamSkewRate( const char* layerName, fl else { layer = GetAnimationLayer( layerName ); - if ( !layer ) + if( !layer ) { return; } @@ -2124,7 +2122,7 @@ void Tr2GrannyAnimation::AimBone( const char* boneName, float target_x, float ta m_aimBoneOrientation[0] = target_x; m_aimBoneOrientation[1] = target_y; m_aimBoneOrientation[2] = target_z; - + m_aimAxis[0] = axis_x; m_aimAxis[1] = axis_y; m_aimAxis[2] = axis_z; @@ -2189,7 +2187,7 @@ void Tr2GrannyAnimation::AddAnimationLayerWithTrackMask( const char* layerName, void Tr2GrannyAnimation::AddAnimationLayerBone( const char* layerName, const char* boneName ) { Tr2GrannyAnimationLayer* layer; - if ( !strcmp(layerName, "") ) + if( !strcmp( layerName, "" ) ) { layer = GetAnimationLayer( nullptr ); } @@ -2210,7 +2208,7 @@ void Tr2GrannyAnimation::AddAnimationLayerBone( const char* layerName, const cha void Tr2GrannyAnimation::AddAnimationLayerAllBones( const char* layerName ) { Tr2GrannyAnimationLayer* layer; - if ( !strcmp(layerName, "") ) + if( !strcmp( layerName, "" ) ) { layer = GetAnimationLayer( nullptr ); } @@ -2231,7 +2229,7 @@ void Tr2GrannyAnimation::AddAnimationLayerAllBones( const char* layerName ) void Tr2GrannyAnimation::RemoveAnimationLayerBone( const char* layerName, const char* boneName ) { Tr2GrannyAnimationLayer* layer; - if ( !strcmp(layerName, "") ) + if( !strcmp( layerName, "" ) ) { layer = GetAnimationLayer( nullptr ); } @@ -2374,13 +2372,13 @@ std::pair Tr2AnimationMeshBinding::GetBoneTransforms() { if( m_animation->IsUsingCMF() ) { - if( !m_cmfSkeleton || !m_boneTransforms ) + if( !m_cmfSkeleton || !m_boneTransforms ) { return std::make_pair( nullptr, 0 ); } auto boneCount = m_geometryRes->GetCMFData()->meshes[m_meshIndex].boneBindings.size(); - + if( m_boneTransforms && m_bindBoneIndices.size() && boneCount ) { auto& worldTransforms = m_animation->GetWorldTransforms(); diff --git a/trinity/Tr2GrannyAnimation.h b/trinity/Tr2GrannyAnimation.h index e9d2955ba..90ade9265 100644 --- a/trinity/Tr2GrannyAnimation.h +++ b/trinity/Tr2GrannyAnimation.h @@ -16,8 +16,8 @@ class Tr2AnimationMeshBinding; namespace Tr2GrannyAnimationUtils { - bool GetBoneList( Tr2GrannyAnimation* animationUpdater, const Float4x3*& bones, size_t& boneCount ); - std::vector CreateMapping( const cmf::Skeleton& skeleton, cmf::Span boneBindings, uint32_t meshBoneCount ); +bool GetBoneList( Tr2GrannyAnimation* animationUpdater, const Float4x3*& bones, size_t& boneCount ); +std::vector CreateMapping( const cmf::Skeleton& skeleton, cmf::Span boneBindings, uint32_t meshBoneCount ); }; struct GrannyBoneBindingBounds @@ -34,50 +34,53 @@ BLUE_INTERFACE( ITr2GrannyAnimationOwner ) : }; -BLUE_CLASS( Tr2GrannyAnimation ): - public IInitialize, - public ITr2AnimationUpdater, - public IBlueAsyncResNotifyTarget +BLUE_CLASS( Tr2GrannyAnimation ) : + public IInitialize, + public ITr2AnimationUpdater, + public IBlueAsyncResNotifyTarget { public: - EXPOSE_TO_BLUE(); - Tr2GrannyAnimation( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2GrannyAnimation( IRoot* lockobj = NULL ); ~Tr2GrannyAnimation(); const std::string& GetResPath() const; void SetResPath( const std::string& val ); - + void AddSecondaryResPath( const std::string& val ); const std::string GetSecondaryAnimationName( const std::string& resPath, int index ) const; bool IsAnimationEnabled() const; void SetAnimationEnabled( bool enabled ); - void SetSharedGeometryRes( TriGeometryResPtr res ); + void SetSharedGeometryRes( TriGeometryResPtr res ); TriGeometryRes* GetSharedGeometryRes() const; - void SetUseMeshBinding( bool enable ) { m_useMeshBinding = enable; } + void SetUseMeshBinding( bool enable ) + { + m_useMeshBinding = enable; + } const std::string& GetModel() const; - void SetModel( const std::string& val); + void SetModel( const std::string& val ); const cmf::Skeleton* GetSkeleton() const; const std::vector& GetWorldTransforms() const; - + #if WITH_GRANNY granny_model* GetGrannyModel() const; #endif bool IsInitialized() const; - bool PlayAnimation( const char* animName, bool replace, int loopCount, float delay, float speed, bool clearWhenDone=true ); - bool PlayLayerAnimationByName( const char* layer, const char* animName, bool replace, int loopCount, float delay, float speed, bool clearWhenDone ); - void EndAnimation(); - void ClearAnimations(); - float GetAnimationChainCompleteTime(); + bool PlayAnimation( const char* animName, bool replace, int loopCount, float delay, float speed, bool clearWhenDone = true ); + bool PlayLayerAnimationByName( const char* layer, const char* animName, bool replace, int loopCount, float delay, float speed, bool clearWhenDone ); + void EndAnimation(); + void ClearAnimations(); + float GetAnimationChainCompleteTime(); Tr2GrannyAnimationLayer* GetAnimationLayer( const char* name ); - void AddAnimationLayer( const char* layerName, float layerWeight=1.0f ); + void AddAnimationLayer( const char* layerName, float layerWeight = 1.0f ); void ClearAnimationLayers(); void AddAnimationLayerBone( const char* layerName, const char* boneName ); void AddAnimationLayerAllBones( const char* layerName ); @@ -85,9 +88,9 @@ BLUE_CLASS( Tr2GrannyAnimation ): void AddAnimationLayerWithTrackMask( const char* layerName, const char* trackMask ); float GetAnimationChainCompleteTimeForLayer( const char* layerName ); float GetLayerWeight( const char* layerName ); - void SetLayerWeight ( const char* layerName, float layerWeight ); - void SetLayerControlParam ( const char* layerName, float controlParam ); - void SetLayerControlParamSkewRate ( const char* layerName, float skewRate ); + void SetLayerWeight( const char* layerName, float layerWeight ); + void SetLayerControlParam( const char* layerName, float controlParam ); + void SetLayerControlParamSkewRate( const char* layerName, float skewRate ); void AimBone( const char* boneName, float target_x, float target_y, float target_z, float axis_x, float axis_y, float axis_z ); void DisableAimBone(); @@ -101,12 +104,12 @@ BLUE_CLASS( Tr2GrannyAnimation ): void TogglePauseAnimations( bool pause ); - bool GetDynamicBounds( Vector4& boundingSphere, Vector3 &aabbMin, Vector3 &aabbMax ); + bool GetDynamicBounds( Vector4 & boundingSphere, Vector3 & aabbMin, Vector3 & aabbMax ); void RenderDynamicBounds( const Matrix& modelTransform ); #if WITH_GRANNY - Vector4 CalculateSkinnedBoundingSphere( granny_file_info* fi=nullptr ); - bool CalculateSkinnedBoundingBoxFromTransform( const Matrix& transform, Vector3& bbMin, Vector3& bbMax, granny_file_info* fi=nullptr ); + Vector4 CalculateSkinnedBoundingSphere( granny_file_info* fi = nullptr ); + bool CalculateSkinnedBoundingBoxFromTransform( const Matrix& transform, Vector3& bbMin, Vector3& bbMax, granny_file_info* fi = nullptr ); #endif void RenderBones( const Matrix& modelTransform, const Tr2AnimationMeshBinding* meshBinding = nullptr ); @@ -115,7 +118,7 @@ BLUE_CLASS( Tr2GrannyAnimation ): const Float4x3* GetMeshBoneMatrixList() const; std::vector GetAnimationNames() const; - + ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); @@ -123,23 +126,23 @@ BLUE_CLASS( Tr2GrannyAnimation ): ////////////////////////////////////////////////////////////////////////// // ITr2AnimationUpdater void PrePhysicsAnimation( Be::Time time, const Matrix& modelTransform ); - void PostPhysicsAnimation( Be::Time time, const Matrix &modelTransform ); + void PostPhysicsAnimation( Be::Time time, const Matrix& modelTransform ); const Matrix* GetAnimationTransforms(); - const std::string *GetAnimationBoneList( unsigned int& numBones ) const; + const std::string* GetAnimationBoneList( unsigned int& numBones ) const; ////////////////////////////////////////////////////////////////////////// // IAsyncLoadedResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); - bool FindBoneByName( const char* name, unsigned int& ix ) const; + bool FindBoneByName( const char* name, unsigned int& ix ) const; const cmf::Animation* FindCMFAnimationByName( const char* name ) const; #if WITH_GRANNY granny_animation* FindGrannyAnimationByName( const char* name ) const; #endif float FindAnimationDurationByName( const char* name ) const; - void Cleanup(); + void Cleanup(); void AddNotifyTarget( IBlueAsyncResNotifyTarget * p ); void RemoveNotifyTarget( IBlueAsyncResNotifyTarget * p ); @@ -147,9 +150,9 @@ BLUE_CLASS( Tr2GrannyAnimation ): const std::unordered_map& GetMorphAnimations() const; #if WITH_GRANNY - granny_skeleton *m_skeleton; - granny_world_pose *m_worldPose; - granny_mesh_binding *m_meshBinding; + granny_skeleton* m_skeleton; + granny_world_pose* m_worldPose; + granny_mesh_binding* m_meshBinding; #endif bool IsUsingCMF() const; @@ -163,12 +166,12 @@ BLUE_CLASS( Tr2GrannyAnimation ): bool GetBoneWorldTransform( const char* boneName, Matrix& transform ) const; private: - std::string m_name; - std::string m_resPath; - std::string m_model; - TriGrannyResPtr m_grannyRes; - std::map m_secondaryGrannyRes; - TriGeometryResPtr m_geometryRes; + std::string m_name; + std::string m_resPath; + std::string m_model; + TriGrannyResPtr m_grannyRes; + std::map m_secondaryGrannyRes; + TriGeometryResPtr m_geometryRes; bool m_boneBoundsInitialized; std::vector m_boneBounds; @@ -184,8 +187,8 @@ BLUE_CLASS( Tr2GrannyAnimation ): PGrannyBoneOffset m_boneOffset; #if WITH_GRANNY - granny_local_pose *m_localPose; - granny_local_pose *m_compositePose; + granny_local_pose* m_localPose; + granny_local_pose* m_compositePose; #endif cmf::SkeletonPose m_pose; cmf::SkeletonPose m_tmpPose; @@ -216,7 +219,7 @@ BLUE_CLASS( Tr2GrannyAnimation ): Vector3 m_aimBoneOrientation; Vector3 m_aimAxis; - bool m_useMeshBinding; + bool m_useMeshBinding; bool m_animationEnabled; bool m_additiveMode; @@ -231,8 +234,8 @@ BLUE_CLASS( Tr2GrannyAnimation ): #endif void LoadSecondaryResPath( const std::string& val ); - void ApplyBoneOffsets ( unsigned i ); - + void ApplyBoneOffsets( unsigned i ); + IBlueEventListenerPtr m_eventListener; std::vector m_notifyTargets; }; diff --git a/trinity/Tr2GrannyAnimationLayer.cpp b/trinity/Tr2GrannyAnimationLayer.cpp index 4875d31aa..3458c5d6a 100644 --- a/trinity/Tr2GrannyAnimationLayer.cpp +++ b/trinity/Tr2GrannyAnimationLayer.cpp @@ -182,7 +182,7 @@ void Tr2GrannyAnimationLayer::QueueAnimation( const char* animName, bool replace float Tr2GrannyAnimationLayer::GetLayerAnimationTime() { - if ( m_paused ) + if( m_paused ) { return m_pauseTime; } @@ -192,13 +192,13 @@ float Tr2GrannyAnimationLayer::GetLayerAnimationTime() void Tr2GrannyAnimationLayer::TogglePauseAnimation( bool pause ) { - if ( m_paused && !pause ) + if( m_paused && !pause ) { m_paused = false; m_totalPauseOffset = Tr2Renderer::GetAnimationTime() - m_pauseTime; m_pauseTime = 0.0; } - else if ( !m_paused && pause ) + else if( !m_paused && pause ) { m_paused = true; m_pauseTime = Tr2Renderer::GetAnimationTime() - m_totalPauseOffset; @@ -232,8 +232,7 @@ bool Tr2GrannyAnimationLayer::PlayAnimation( const Tr2GrannyAnimation* grannyAni if( !replace ) { float maxRemaining = 0.0f; - m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { int loopCount = max( 0, player->GetLoopIndex( GetLayerAnimationTime() ) ); int newLoopCount = loopCount + 1; @@ -259,7 +258,7 @@ bool Tr2GrannyAnimationLayer::PlayAnimation( const Tr2GrannyAnimation* grannyAni { player->SetStopTime( GetLayerAnimationTime() + player->GetDurationLeft( GetLayerAnimationTime() ) + delay ); } - + RegisterMorphTracks( player.get(), animation ); if( m_controlParamEnabled ) @@ -397,7 +396,7 @@ void Tr2GrannyAnimationLayer::RegisterMorphTracks( granny_control* control, cons { for( int trackIdx = 0; trackIdx < trackGroup->VectorTrackCount; trackIdx++ ) { - if ( trackGroup->VectorTracks[trackIdx].Dimension == 1 ) + if( trackGroup->VectorTracks[trackIdx].Dimension == 1 ) { m_controlMorphTracks[control].push_back( MorphTrack( &trackGroup->VectorTracks[trackIdx] ) ); } @@ -424,7 +423,7 @@ void Tr2GrannyAnimationLayer::EndAnimation() if( m_modelInstance ) { m_animationQueue.clear(); - + for( granny_model_control_binding* binding = GrannyModelControlsBegin( m_modelInstance ); binding != GrannyModelControlsEnd( m_modelInstance ); binding = GrannyModelControlsNext( binding ) ) @@ -437,7 +436,7 @@ void Tr2GrannyAnimationLayer::EndAnimation() } } #endif - + FreeCompletedControls(); } @@ -459,7 +458,7 @@ void Tr2GrannyAnimationLayer::ClearMorphTracks( granny_control* control ) #endif void Tr2GrannyAnimationLayer::ClearAnimations() -{ +{ m_animationQueue.clear(); if( m_sequencer ) @@ -540,7 +539,7 @@ float MorphTrack::SampleTrack( float time, float duration ) const void Tr2GrannyAnimationLayer::SampleTextTracks( IBlueEventListener* listener ) { CCP_ASSERT_M( !IsUsingCMF(), "Tr2GrannyAnimationLayer::SampleTextTracks: CMF does not have text tracks!" ); - + if( !listener ) { return; @@ -580,7 +579,7 @@ void Tr2GrannyAnimationLayer::SampleMorphTracks( std::unordered_mapSampleTrack( t, duration ) * m_layerWeight; auto entry = morphAnimations.find( trackIt->m_grannyTrack->Name ); - if ( entry != morphAnimations.end() ) + if( entry != morphAnimations.end() ) { entry->second = additive ? entry->second + trackValue : trackValue; } @@ -633,10 +632,9 @@ void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, cmf::Skeleto if( m_controlParamEnabled ) { UpdateControlParam( animationTime ); - + cmf::RestPose( *resultPose, m_sequencer->GetSkeleton() ); - m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { player->SampleAtLocalTime( *resultPose, m_controlParam * player->GetLoopDuration() ); } ); } @@ -657,8 +655,7 @@ void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, cmf::Skeleto if( additive ) { std::shared_ptr animation; - m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { if( animation ) { return; @@ -704,50 +701,48 @@ void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, cmf::Skeleto } #if WITH_GRANNY -void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, granny_local_pose* resultPose, IBlueEventListener* listener, - std::unordered_map& morphAnimations ) +void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, granny_local_pose* resultPose, IBlueEventListener* listener, std::unordered_map& morphAnimations ) { GrannySetModelClock( m_modelInstance, animationTime ); SampleTextTracks( listener ); SampleMorphTracks( morphAnimations ); FreeCompletedControls(); - if ( m_controlParamEnabled ) + if( m_controlParamEnabled ) { UpdateControlParam( animationTime ); } GrannySampleModelAnimations( m_modelInstance, 0, m_boneCount, resultPose ); } -void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, granny_local_pose* compositePose, granny_local_pose* resultPose, - IBlueEventListener* listener, std::unordered_map& morphAnimations, bool additive ) +void Tr2GrannyAnimationLayer::SampleAnimation( float animationTime, granny_local_pose* compositePose, granny_local_pose* resultPose, IBlueEventListener* listener, std::unordered_map& morphAnimations, bool additive ) { GrannySetModelClock( m_modelInstance, animationTime ); SampleTextTracks( listener ); SampleMorphTracks( morphAnimations, additive ); FreeCompletedControls(); - if ( m_controlParamEnabled ) + if( m_controlParamEnabled ) { UpdateControlParam( animationTime ); } - if ( additive ) + if( additive ) { - if ( !m_basePose ) + if( !m_basePose ) { m_basePose = GrannyNewLocalPose( m_boneCount ); } - granny_model_control_binding *binding = GrannyModelControlsBegin( m_modelInstance ); + granny_model_control_binding* binding = GrannyModelControlsBegin( m_modelInstance ); - if ( binding == GrannyModelControlsEnd( m_modelInstance ) ) + if( binding == GrannyModelControlsEnd( m_modelInstance ) ) { // no bindings return; } - + // Construct the m_basePose from raw local clock 0 for the first control. - granny_control *control = GrannyGetControlFromBinding( binding ); - - if ( !control ) + granny_control* control = GrannyGetControlFromBinding( binding ); + + if( !control ) { return; } @@ -772,21 +767,20 @@ void Tr2GrannyAnimationLayer::FreeCompletedControls() { if( m_sequencer ) { - m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { if( !player->IsActive( GetLayerAnimationTime() ) ) { ClearMorphTracks( player.get() ); } } ); } - + #if WITH_GRANNY if( m_modelInstance ) { - for( granny_model_control_binding *binding = GrannyModelControlsBegin( m_modelInstance ); binding != GrannyModelControlsEnd( m_modelInstance ); ) + for( granny_model_control_binding* binding = GrannyModelControlsBegin( m_modelInstance ); binding != GrannyModelControlsEnd( m_modelInstance ); ) { - granny_control *control = GrannyGetControlFromBinding( binding ); + granny_control* control = GrannyGetControlFromBinding( binding ); binding = GrannyModelControlsNext( binding ); if( GrannyFreeControlIfComplete( control ) ) { @@ -814,8 +808,7 @@ float Tr2GrannyAnimationLayer::GetAnimationRemainingTime() } float maxRemaining = 0.0f; - m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) - { + m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr& player ) { int loopCount = max( 0, player->GetLoopIndex( GetLayerAnimationTime() ) ); int newLoopCount = loopCount + 1; int loopsTotal = player->GetLoopCount(); @@ -886,7 +879,7 @@ void Tr2GrannyAnimationLayer::Cleanup() m_trackMask = nullptr; } - if ( m_basePose ) + if( m_basePose ) { GrannyFreeLocalPose( m_basePose ); m_basePose = nullptr; @@ -946,8 +939,8 @@ void Tr2GrannyAnimationLayer::AddAllBones( const Tr2GrannyAnimation* grannyAnima CCP_ASSERT( grannyAnimation->IsUsingCMF() == m_useCMF ); unsigned int bone_count; - const std::string *boneList = grannyAnimation->GetAnimationBoneList( bone_count ); - for (unsigned int i=0; i < bone_count; i++) + const std::string* boneList = grannyAnimation->GetAnimationBoneList( bone_count ); + for( unsigned int i = 0; i < bone_count; i++ ) { AddBone( grannyAnimation, boneList[i].c_str() ); } diff --git a/trinity/Tr2GrannyAnimationLayer.h b/trinity/Tr2GrannyAnimationLayer.h index a62e2ff42..a4e902862 100644 --- a/trinity/Tr2GrannyAnimationLayer.h +++ b/trinity/Tr2GrannyAnimationLayer.h @@ -20,7 +20,10 @@ class Tr2GrannyAnimation; #if WITH_GRANNY struct TextEventTrack { - TextEventTrack( granny_text_track* grannyTrack ) : m_grannyTrack( grannyTrack ), m_lastIndex(-1), m_lastLoop(-1) {} + TextEventTrack( granny_text_track* grannyTrack ) : + m_grannyTrack( grannyTrack ), m_lastIndex( -1 ), m_lastLoop( -1 ) + { + } const char* SampleTrack( float time, int loop ); @@ -35,11 +38,14 @@ struct TextEventTrack struct MorphTrack { #if WITH_GRANNY - MorphTrack( granny_vector_track* grannyTrack ) : m_grannyTrack( grannyTrack ) {} + MorphTrack( granny_vector_track* grannyTrack ) : + m_grannyTrack( grannyTrack ) + { + } #endif MorphTrack( const cmf::AnimationChannel* cmfChannel, const cmf::AnimationCurve* cmfCurve ) : - m_cmfChannel( cmfChannel ), - m_cmfCurve( cmfCurve ), + m_cmfChannel( cmfChannel ), + m_cmfCurve( cmfCurve ), m_cmfTargetName( cmf::ToStdString( cmfChannel->target ) ) { } @@ -88,7 +94,7 @@ class Tr2GrannyAnimationLayer void SetControlParamSkewRate( float skewRate ); void TogglePauseAnimation( bool pause ); - + std::string m_name; #if WITH_GRANNY @@ -145,7 +151,7 @@ class Tr2GrannyAnimationLayer bool m_controlParamEnabled; float m_lastControlUpdateTime; #if WITH_GRANNY - granny_local_pose *m_basePose; + granny_local_pose* m_basePose; #endif cmf::SkeletonPose m_cmfBasePose; float m_skewRate; diff --git a/trinity/Tr2GrannyAnimation_Blue.cpp b/trinity/Tr2GrannyAnimation_Blue.cpp index eacdbaab8..35192d6a8 100644 --- a/trinity/Tr2GrannyAnimation_Blue.cpp +++ b/trinity/Tr2GrannyAnimation_Blue.cpp @@ -13,8 +13,8 @@ BLUE_DEFINE( Tr2GrannyAnimation ); const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GrannyAnimation, "" ) - MAP_INTERFACE( Tr2GrannyAnimation ) + EXPOSURE_BEGIN( Tr2GrannyAnimation, "" ) + MAP_INTERFACE( Tr2GrannyAnimation ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( ITr2AnimationUpdater ) @@ -24,38 +24,25 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() MAP_PROPERTY( "model", GetModel, SetModel, "" ) MAP_ATTRIBUTE( "model_", m_model, "", Be::PERSISTONLY ) - MAP_ATTRIBUTE - ( - "debugRenderSkeleton", m_debugRenderSkeleton, - "If set, and a debug renderer is set, then the skeleton is rendered with lines connecting\n" - "the joints of the skeleton.", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "debugRenderSkeleton", m_debugRenderSkeleton, "If set, and a debug renderer is set, then the skeleton is rendered with lines connecting\n" + "the joints of the skeleton.", + Be::READWRITE ) - MAP_ATTRIBUTE - ( - "debugRenderJointNames", m_debugRenderJointNames, - "If set, and a debug renderer is set, then the names of the joints in the skeleton\n" - "are displayed at their projected locations.", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "debugRenderJointNames", m_debugRenderJointNames, "If set, and a debug renderer is set, then the names of the joints in the skeleton\n" + "are displayed at their projected locations.", + Be::READWRITE ) - MAP_ATTRIBUTE - ( - "animationEnabled", m_animationEnabled, - "Enable/disable animation update", - Be::READWRITE - ) + MAP_ATTRIBUTE( + "animationEnabled", m_animationEnabled, "Enable/disable animation update", Be::READWRITE ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "PlayAnimation", PlayAnimationOnce, "PlayAnimation( animName )\n\nPlays the given animation, replacing whatever animation was playing before.\n" - ":param animName: animation name" - ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + ":param animName: animation name" ) + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "PlayAnimationEx", PlayAnimationEx, 1, @@ -65,18 +52,14 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() ":param loopCount: can be 0 to loop forever.\n" ":param delay: time (in seconds) from now before animation should start playing.\n" ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" - ":param clearWhenDone: boolean True to clear animation when done, boolean False to keep it playing. Defaults to True\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param clearWhenDone: boolean True to clear animation when done, boolean False to keep it playing. Defaults to True\n" ) + MAP_METHOD_AND_WRAP( "ChainAnimation", ChainAnimation, "ChainAnimation( animName )\n\nPlays the given animation, starting when currently playing animation finishes.\n" "If it is looping then it is replaced at the end of the current loop.\n" - ":param animName: animation name\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param animName: animation name\n" ) + MAP_METHOD_AND_WRAP( "ChainAnimationEx", ChainAnimationEx, "ChainAnimationEx( animName, loopCount, delay, speed )\n\n" @@ -85,33 +68,25 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() ":param animName: animation name\n" ":param loopCount: can be 0 to loop forever.\n" ":param delay: time (in seconds) from now before animation should start playing.\n" - ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" ) + MAP_METHOD_AND_WRAP( "TogglePauseAnimations", TogglePauseAnimations, "TogglePauseAnimations( pause )\n\n" "Pauses/unpauses animation playback." - ":param pause: boolean True for pause, boolean False to unpause" - ) - MAP_METHOD_AND_WRAP - ( + ":param pause: boolean True for pause, boolean False to unpause" ) + MAP_METHOD_AND_WRAP( "EndAnimation", EndAnimation, "EndAnimation()\n\n" - "Stops currently playing animation at the end of the current loop iteration." - ) - MAP_METHOD_AND_WRAP - ( + "Stops currently playing animation at the end of the current loop iteration." ) + MAP_METHOD_AND_WRAP( "ClearAnimations", ClearAnimations, "ClearAnimations()\n\n" - "Abruptly ends all animations." - ) - - MAP_METHOD_AND_WRAP - ( + "Abruptly ends all animations." ) + + MAP_METHOD_AND_WRAP( "PlayLayerAnimation", PlayLayerAnimationByName, "PlayLayerAnimation( layerName, animationName, replace, loops, delay, speed, clearWhenFinished )\n\n" @@ -122,53 +97,41 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() ":param loops: can be 0 to loop forever.\n" ":param delay: time (in seconds) from now before animation should start playing.\n" ":param speed: can be used speed up or slow down playback - use negative values to play backwards.\n" - ":param clearWhenFinished: \n" - ) - MAP_METHOD_AND_WRAP - ( + ":param clearWhenFinished: \n" ) + MAP_METHOD_AND_WRAP( "AddAnimationLayer", AddAnimationLayer, "AddAnimationLayer( layerName[, layerWeight=1.0] )\n\n" "Creates a new animation layer for this granny animation.\n" ":param layerName: layer name\n" - ":param layerWeight: layer weight\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param layerWeight: layer weight\n" ) + MAP_METHOD_AND_WRAP( "AddAnimationLayerBone", AddAnimationLayerBone, "AddAnimationLayerBone( layerName, boneName )\n\n" "Add the specified bone to this animation layer.\n" ":param layerName: layer name\n" - ":param boneName: bone name\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param boneName: bone name\n" ) + MAP_METHOD_AND_WRAP( "AddAnimationLayerAllBones", AddAnimationLayerAllBones, "AddAnimationLayerAllBones( layerName )\n\n" "Add all bones to this animation layer.\n" - ":param layerName: layer name\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param layerName: layer name\n" ) + MAP_METHOD_AND_WRAP( "GetLayerWeight", GetLayerWeight, "GetLayerWeight( layerName )\n\n" "Returns a scalar float weight for the named layer.\n" - ":param layerName: layer name\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param layerName: layer name\n" ) + MAP_METHOD_AND_WRAP( "SetLayerWeight", SetLayerWeight, "SetLayerWeight( layerName, layerWeight )\n\n" "Sets layer blend weight for an existing layer.\n" ":param layerName: layer name\n" - ":param layerWeight: layer weight\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param layerWeight: layer weight\n" ) + MAP_METHOD_AND_WRAP( "SetLayerControlParam", SetLayerControlParam, "SetLayerControlParam( layerName, controlParam )\n\n" @@ -177,10 +140,8 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() "The animation layer's frame will be selected by multiplying the controlParam by the duration of\n" "the animation, so a value of 0.0 will be the first frame and 1.0 will be the last.\n" ":param layerName: layer name\n" - ":param controlParam: layer control parameter\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param controlParam: layer control parameter\n" ) + MAP_METHOD_AND_WRAP( "SetLayerControlParamSkewRate", SetLayerControlParamSkewRate, "SetLayerControlParam( layerName, skewRate )\n\n" @@ -189,10 +150,8 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() "The animation layer's frame will be selected by multiplying the controlParam by the duration of\n" "the animation, so a value of 0.0 will be the first frame and 1.0 will be the last.\n" ":param layerName: layer name\n" - ":param skewRate: layer control parameter maximum rate of change (for smoothing)\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param skewRate: layer control parameter maximum rate of change (for smoothing)\n" ) + MAP_METHOD_AND_WRAP( "AimBone", AimBone, "AimBone( bone_name, target_x, target_y, target_z, axis_x, axis_y, axis_z )\n\n" @@ -203,74 +162,57 @@ const Be::ClassInfo* Tr2GrannyAnimation::ExposeToBlue() ":param target_z: world-space target z coord\n" ":param axis_x: align axis x coord\n" ":param axis_y: align axis y coord\n" - ":param axis_z: align axis z coord\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param axis_z: align axis z coord\n" ) + MAP_METHOD_AND_WRAP( "DisableAimBone", DisableAimBone, "DisableAimBone()\n\n" - "Disables bone aim constraint.\n" - ) - MAP_METHOD_AND_WRAP - ( + "Disables bone aim constraint.\n" ) + MAP_METHOD_AND_WRAP( "SetAdditiveBlendMode", SetAdditiveBlendMode, "SetAdditiveBlendMode( additive )\n\n" "When the additive blend mode is set, blending will use addition rather than averaging to combine layer poses." - ":param additive: additive on or off\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param additive: additive on or off\n" ) + MAP_METHOD_AND_WRAP( "GetAdditiveBlendMode", GetAdditiveBlendMode, "GetAdditiveBlendMode( )\n\n" - "Returns current state of additive blending. When the additive blend mode is set, blending will use addition rather than averaging to combine layer poses." - ) - MAP_METHOD_AND_WRAP - ( + "Returns current state of additive blending. When the additive blend mode is set, blending will use addition rather than averaging to combine layer poses." ) + MAP_METHOD_AND_WRAP( "RemoveAnimationLayerBone", RemoveAnimationLayerBone, "RemoveAnimationLayerBone( layerName, boneName )\n\n" "Remove the specified bone to from the animation layer.\n" ":param layerName: layer name\n" - ":param boneName: bone name\n" - ) - MAP_METHOD_AND_WRAP - ( + ":param boneName: bone name\n" ) + MAP_METHOD_AND_WRAP( "ClearAnimationLayers", ClearAnimationLayers, - "Clears all animation layers from this granny animation controller\n" - ) + "Clears all animation layers from this granny animation controller\n" ) MAP_ATTRIBUTE( "boneOffset", m_boneOffset, "Per-bone post animation offsets.", Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "eventListener", m_eventListener, "An event listener that's triggered by granny text track events.", - Be::READWRITE - ) - - MAP_METHOD_AND_WRAP - ( + Be::READWRITE ) + + MAP_METHOD_AND_WRAP( "AddSecondaryResPath", AddSecondaryResPath, "AddSecondaryResPath adds another file to the list of files that are searched for animations played by name. Joint\n" "names must match those in the normal res file.\n" - ":param val: Path to secondary res file." - ) - - MAP_METHOD_AND_WRAP - ( + ":param val: Path to secondary res file." ) + + MAP_METHOD_AND_WRAP( "GetSecondaryAnimationName", GetSecondaryAnimationName, "GetSecondaryAnimationName( resPath, index )\n\n" "Returns the name of the animation of the given index in the given res file.\n" ":param resPath: Path to secondary res file.\n" - ":param index: Index of selected animation in res file." - ) + ":param index: Index of selected animation in res file." ) MAP_METHOD_AND_WRAP( "GetAnimationNames", GetAnimationNames, "Returns all animation names" ) EXPOSURE_END() diff --git a/trinity/Tr2GrannyPrimitiveSet.cpp b/trinity/Tr2GrannyPrimitiveSet.cpp index 39599c245..be2772288 100644 --- a/trinity/Tr2GrannyPrimitiveSet.cpp +++ b/trinity/Tr2GrannyPrimitiveSet.cpp @@ -10,7 +10,7 @@ using namespace Tr2RenderContextEnum; const char* g_pickingMeshName = "picking"; -Tr2GrannyPrimitiveSet::Tr2GrannyPrimitiveSet( IRoot* lockobj /*= NULL*/ ): +Tr2GrannyPrimitiveSet::Tr2GrannyPrimitiveSet( IRoot* lockobj /*= NULL*/ ) : Tr2PrimitiveSet( lockobj ), m_renderSolid( FALSE ), m_primitiveCount( 0 ), @@ -80,18 +80,18 @@ bool Tr2GrannyPrimitiveSet::OnPrepareResources() Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, - renderContext ) - , false ); + renderContext ), + false ); } TriangleVertex* vertexBuffer; CR_RETURN_VAL( m_vertexBuffer.MapForWriting( vertexBuffer, renderContext ), false ); - memcpy( vertexBuffer, &m_points[0], sizeof( TriangleVertex ) * m_points.size() ); + memcpy( vertexBuffer, &m_points[0], sizeof( TriangleVertex ) * m_points.size() ); Vector3 center( 0.0f, 0.0f, 0.0f ); float radius = 0.0f; - ComputeBoundingSphere( &vertexBuffer[0].m_position, (unsigned int)m_points.size(), sizeof(TriangleVertex), center, radius ); + ComputeBoundingSphere( &vertexBuffer[0].m_position, (unsigned int)m_points.size(), sizeof( TriangleVertex ), center, radius ); m_boundingSphere.x = center.x; m_boundingSphere.y = center.y; @@ -104,29 +104,29 @@ bool Tr2GrannyPrimitiveSet::OnPrepareResources() if( m_triangleIndices.size() ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( - m_triangleIndexBuffer.Create( + CR_RETURN_VAL( + m_triangleIndexBuffer.Create( 4, - (unsigned int)m_triangleIndices.size(), + (unsigned int)m_triangleIndices.size(), Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::NONE, &m_triangleIndices[0], - renderContext ) - , false ); + renderContext ), + false ); } if( m_lineIndices.size() ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( + CR_RETURN_VAL( m_lineIndexBuffer.Create( 4, - (unsigned int)m_lineIndices.size(), + (unsigned int)m_lineIndices.size(), Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::NONE, &m_lineIndices[0], - renderContext ) - , false ); + renderContext ), + false ); } return true; @@ -174,8 +174,8 @@ void Tr2GrannyPrimitiveSet::GetBatchesImpl( ITriRenderBatchAccumulator* accumula bool Tr2GrannyPrimitiveSet::OnModified( Be::Var* value ) { if( IsMatch( value, m_grannyResPath ) ) - { - SetGrannyResource(); + { + SetGrannyResource(); } return Tr2PrimitiveSet::OnModified( value ); @@ -192,7 +192,7 @@ void Tr2GrannyPrimitiveSet::ReleaseCachedData( BlueAsyncRes* p ) void Tr2GrannyPrimitiveSet::RebuildCachedData( BlueAsyncRes* p ) { - if ( p == m_grannyRes && p->IsGood() ) + if( p == m_grannyRes && p->IsGood() ) { CleanUp(); CreatePrimitive(); @@ -208,7 +208,7 @@ void Tr2GrannyPrimitiveSet::CleanUp( void ) m_primitiveCount = 0; m_pickingPrimitiveCount = 0; m_pickingIndexOffset = 0; - ReleaseResources(TRISTORAGE_ALL); + ReleaseResources( TRISTORAGE_ALL ); } void Tr2GrannyPrimitiveSet::SetGrannyResource() @@ -222,7 +222,7 @@ void Tr2GrannyPrimitiveSet::SetGrannyResource() if( !m_grannyResPath.empty() ) { BeResMan->GetResource( m_grannyResPath.c_str(), "raw", m_grannyRes ); - } + } else { ReleaseCachedData( m_grannyRes ); @@ -277,7 +277,7 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromCMF() for( int32_t meshIx = 0; meshIx < cmfData->meshes.size(); meshIx++ ) { auto mesh = cmfData->meshes[meshIx]; - + uint32_t meshIndexCount = cmf::GetStreamElementCount( mesh.lods[0].ib ); uint32_t meshTriangleCount = meshIndexCount / 3; @@ -323,7 +323,7 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromCMF() std::vector positions( meshVertexCount, Vector3( 0.f, 0.f, 0.f ) ); std::vector normals( meshVertexCount, Vector3( 0.f, 0.f, 0.f ) ); ReadCmfVertexAttributes( reader, vbData, meshVertexCount, vb.stride, positions, normals, nullptr, nullptr ); - + for( uint32_t i = 0; i < meshVertexCount; i++ ) { TriangleVertex newVertex; @@ -376,9 +376,9 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() return; } - granny_file_info* info = GrannyGetFileInfo(file); - if ( !info ) - { + granny_file_info* info = GrannyGetFileInfo( file ); + if( !info ) + { CCP_LOGERR( "Tr2GrannyLineSet::CreatePrimitive: unable to obtain a granny_file_info from the input file\n" ); return; } @@ -386,7 +386,7 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() // reset the counters granny_int32x numVertices = 0; granny_int32x numIndices = 0; - std::vector meshIndices; + std::vector meshIndices; int pickingIndex = -1; // Sorting the meshes so the picking mesh is processed last for( granny_int32x meshIx = 0; meshIx < info->MeshCount; ++meshIx ) @@ -397,7 +397,7 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() return; } - granny_int32x const meshIndexCount = GrannyGetMeshIndexCount( mesh ); + granny_int32x const meshIndexCount = GrannyGetMeshIndexCount( mesh ); granny_int32x const meshTriangleCount = GrannyGetMeshTriangleCount( mesh ); if( mesh->Name && strncmp( mesh->Name, g_pickingMeshName, strlen( g_pickingMeshName ) ) == 0 ) @@ -426,7 +426,7 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() return; } - granny_int32x const meshIndexCount = GrannyGetMeshIndexCount( mesh ); + granny_int32x const meshIndexCount = GrannyGetMeshIndexCount( mesh ); granny_int32x const meshVertexCount = GrannyGetMeshVertexCount( mesh ); granny_int32x const meshTriangleCount = GrannyGetMeshTriangleCount( mesh ); m_primitiveCount += meshTriangleCount; @@ -445,33 +445,33 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() { if( isHalfPrecision ) { - granny_real16* posPtr = (granny_real16*)((uint8_t*)vertices +(i*bytesPerVertex) + pointOffset); - granny_real16* normalPtr = (granny_real16*)((uint8_t*)vertices +(i*bytesPerVertex) + normalOffset); + granny_real16* posPtr = (granny_real16*)( (uint8_t*)vertices + ( i * bytesPerVertex ) + pointOffset ); + granny_real16* normalPtr = (granny_real16*)( (uint8_t*)vertices + ( i * bytesPerVertex ) + normalOffset ); TriangleVertex newVertex; - GrannyReal16ToReal32( *(posPtr), &newVertex.m_position.x ); - GrannyReal16ToReal32( *(posPtr+1), &newVertex.m_position.y ); - GrannyReal16ToReal32( *(posPtr+2), &newVertex.m_position.z ); + GrannyReal16ToReal32( *( posPtr ), &newVertex.m_position.x ); + GrannyReal16ToReal32( *( posPtr + 1 ), &newVertex.m_position.y ); + GrannyReal16ToReal32( *( posPtr + 2 ), &newVertex.m_position.z ); GrannyReal16ToReal32( *normalPtr, &newVertex.m_normal.x ); - GrannyReal16ToReal32( *( normalPtr +1), &newVertex.m_normal.y ); - GrannyReal16ToReal32( *( normalPtr +2), &newVertex.m_normal.z ); + GrannyReal16ToReal32( *( normalPtr + 1 ), &newVertex.m_normal.y ); + GrannyReal16ToReal32( *( normalPtr + 2 ), &newVertex.m_normal.z ); newVertex.m_color = m_color; m_points.push_back( newVertex ); } else { - granny_real32* const posPtr = (granny_real32*)((uint8_t*)vertices +(i*bytesPerVertex) + pointOffset); - granny_real32* const normalPtr = (granny_real32*)((uint8_t*)vertices +(i*bytesPerVertex) + normalOffset); + granny_real32* const posPtr = (granny_real32*)( (uint8_t*)vertices + ( i * bytesPerVertex ) + pointOffset ); + granny_real32* const normalPtr = (granny_real32*)( (uint8_t*)vertices + ( i * bytesPerVertex ) + normalOffset ); TriangleVertex newVertex; newVertex.m_position.x = *posPtr; - newVertex.m_position.y = *(posPtr+1); - newVertex.m_position.z = *(posPtr+2); + newVertex.m_position.y = *( posPtr + 1 ); + newVertex.m_position.z = *( posPtr + 2 ); newVertex.m_normal.x = *normalPtr; - newVertex.m_normal.y = *(normalPtr+1); - newVertex.m_normal.z = *(normalPtr+2); + newVertex.m_normal.y = *( normalPtr + 1 ); + newVertex.m_normal.z = *( normalPtr + 2 ); newVertex.m_color = m_color; m_points.push_back( newVertex ); } @@ -482,31 +482,31 @@ void Tr2GrannyPrimitiveSet::CreatePrimitiveFromGranny() if( mesh->PrimaryTopology->Indices ) { m_triangleIndices.push_back( mesh->PrimaryTopology->Indices[i] + numVertices ); - } + } else { m_triangleIndices.push_back( mesh->PrimaryTopology->Indices16[i] + numVertices ); } } // the lines just trace through each polygon, 1 - 2, 2 - 3, 3 - 1 - for( int i = 0; i < meshIndexCount; i+=3 ) + for( int i = 0; i < meshIndexCount; i += 3 ) { if( mesh->PrimaryTopology->Indices ) { m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i+1] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i+1] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i+2] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i+2] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i + 1] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i + 1] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i + 2] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i + 2] + numVertices ); m_lineIndices.push_back( mesh->PrimaryTopology->Indices[i] + numVertices ); - } + } else { m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i+1] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i+1] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i+2] + numVertices ); - m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i+2] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i + 1] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i + 1] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i + 2] + numVertices ); + m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i + 2] + numVertices ); m_lineIndices.push_back( mesh->PrimaryTopology->Indices16[i] + numVertices ); } } diff --git a/trinity/Tr2GrannyPrimitiveSet.h b/trinity/Tr2GrannyPrimitiveSet.h index f37c033e3..b9ea85ec3 100644 --- a/trinity/Tr2GrannyPrimitiveSet.h +++ b/trinity/Tr2GrannyPrimitiveSet.h @@ -16,23 +16,23 @@ struct TriangleVertex Color m_color; }; -BLUE_CLASS( Tr2GrannyPrimitiveSet ): +BLUE_CLASS( Tr2GrannyPrimitiveSet ) : public IInitialize, - public Tr2PrimitiveSet, + public Tr2PrimitiveSet, public Tr2DeviceResource, public IBlueAsyncResNotifyTarget { public: - EXPOSE_TO_BLUE(); - Tr2GrannyPrimitiveSet( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2GrannyPrimitiveSet( IRoot* lockobj = NULL ); ~Tr2GrannyPrimitiveSet(); using IInitialize::Lock; using IInitialize::Unlock; ////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); ////////////////////////////////////////////////////////////////////////// // IInitialize @@ -40,14 +40,17 @@ BLUE_CLASS( Tr2GrannyPrimitiveSet ): ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); #if TRINITYDEV - virtual void GetDescription( std::string& desc ) { desc = ""; } + virtual void GetDescription( std::string & desc ) + { + desc = ""; + } #endif void SetGrannyResource(); @@ -60,21 +63,21 @@ BLUE_CLASS( Tr2GrannyPrimitiveSet ): private: virtual bool OnPrepareResources(); - void SetCurrentColor( Color& val ); + void SetCurrentColor( Color & val ); #if WITH_GRANNY void CreatePrimitiveFromGranny(); #endif void CreatePrimitiveFromCMF(); - - // We use indices to draw the solids and the lines, + + // We use indices to draw the solids and the lines, // because we want to use the same vertex buffer - Tr2BufferAL m_triangleIndexBuffer; + Tr2BufferAL m_triangleIndexBuffer; Tr2BufferAL m_lineIndexBuffer; // How do we want to render this granny res - bool m_renderSolid; - + bool m_renderSolid; + // The gr2 data std::string m_grannyResPath; TriGrannyResPtr m_grannyRes; diff --git a/trinity/Tr2GrannyPrimitiveSet_Blue.cpp b/trinity/Tr2GrannyPrimitiveSet_Blue.cpp index 9dfa6aa38..73176cabc 100644 --- a/trinity/Tr2GrannyPrimitiveSet_Blue.cpp +++ b/trinity/Tr2GrannyPrimitiveSet_Blue.cpp @@ -8,22 +8,12 @@ BLUE_DEFINE( Tr2GrannyPrimitiveSet ); const Be::ClassInfo* Tr2GrannyPrimitiveSet::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2GrannyPrimitiveSet, "" ) - MAP_INTERFACE( Tr2GrannyPrimitiveSet ) + EXPOSURE_BEGIN( Tr2GrannyPrimitiveSet, "" ) + MAP_INTERFACE( Tr2GrannyPrimitiveSet ) MAP_INTERFACE( IInitialize ) - MAP_ATTRIBUTE_WITH_CHOOSER( "grannyResPath", m_grannyResPath, - "A res path to the granny resource", - Be::READWRITE | Be::PERSIST | Be::NOTIFY, - TriGR2Chooser - ) - MAP_ATTRIBUTE( "grannyRes", m_grannyRes, - "The granny resource holding the curves", - Be::READ - ) - MAP_ATTRIBUTE( "renderSolid", m_renderSolid, - "Should we render the triangles? If not, we will render as lines.", - Be::READWRITE | Be::PERSIST - ) - EXPOSURE_CHAINTO( Tr2PrimitiveSet ) + MAP_ATTRIBUTE_WITH_CHOOSER( "grannyResPath", m_grannyResPath, "A res path to the granny resource", Be::READWRITE | Be::PERSIST | Be::NOTIFY, TriGR2Chooser ) + MAP_ATTRIBUTE( "grannyRes", m_grannyRes, "The granny resource holding the curves", Be::READ ) + MAP_ATTRIBUTE( "renderSolid", m_renderSolid, "Should we render the triangles? If not, we will render as lines.", Be::READWRITE | Be::PERSIST ) + EXPOSURE_CHAINTO( Tr2PrimitiveSet ) } diff --git a/trinity/Tr2HostBitmap.cpp b/trinity/Tr2HostBitmap.cpp index 6ca94d349..6150d91d7 100644 --- a/trinity/Tr2HostBitmap.cpp +++ b/trinity/Tr2HostBitmap.cpp @@ -9,12 +9,13 @@ #include "Tr2DxtCompressor.h" #pragma warning( push, 4 ) -#pragma warning( disable: 4189 ) // Scopeguard +#pragma warning( disable : 4189 ) // Scopeguard using namespace Tr2RenderContextEnum; Tr2HostBitmap::Tr2HostBitmap( IRoot* ) -{} +{ +} Tr2HostBitmap::~Tr2HostBitmap() { @@ -75,7 +76,7 @@ bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::Cubema int top = 0; int right = rtAL.GetWidth(); int bottom = rtAL.GetHeight(); - + if( srcRect ) { left = max( left, srcRect[0] ); @@ -84,7 +85,7 @@ bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::Cubema bottom = min( bottom, srcRect[3] ); } if( offsetX < 0 ) - { + { left = max( left, -offsetX ); right = min( right, int( rtAL.GetWidth() ) + offsetX ); } @@ -96,16 +97,15 @@ bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::Cubema offsetX += left; offsetY += top; - if( left >= right || + if( left >= right || top >= bottom || int( m_width ) < offsetX || - int( m_height ) < offsetY - ) + int( m_height ) < offsetY ) { return true; } - unsigned width = min( unsigned( right - left ), m_width - offsetX ); + unsigned width = min( unsigned( right - left ), m_width - offsetX ); unsigned height = min( unsigned( bottom - top ), m_height - offsetY ); const unsigned mipCount = std::min( GetTrueMipCount(), rtAL.GetTrueMipCount() ); @@ -120,20 +120,20 @@ bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::Cubema return false; } - uint8_t* dst = (uint8_t*)GetMipRawData( mipLevel, face ); + uint8_t* dst = (uint8_t*)GetMipRawData( mipLevel, face ); const uint8_t* src = (uint8_t*)data; - const unsigned dstPitch = GetMipPitch( mipLevel ); + const unsigned dstPitch = GetMipPitch( mipLevel ); dst += GetBytesPerPixel( m_format ) * offsetX + dstPitch * offsetY; src += GetBytesPerPixel( m_format ) * left + srcPitch * top; - + if( alphaConvert ) { for( unsigned j = 0; j != height; ++j, src += srcPitch, dst += dstPitch ) { - const uint8_t* in = src; - uint8_t* out = dst; + const uint8_t* in = src; + uint8_t* out = dst; for( unsigned i = 0; i != width; ++i ) { *out++ = *in++; @@ -157,9 +157,9 @@ bool Tr2HostBitmap::SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::Cubema height = max( height / 2, 1u ); offsetX /= 2; offsetY /= 2; - left /= 2; - top /= 2; - + left /= 2; + top /= 2; + rtAL.UnmapForReading( renderContext ); } return true; @@ -265,7 +265,7 @@ bool Tr2HostBitmap::CopyFromTexture( Tr2TextureAL& texture, Tr2RenderContext& re return true; } -bool Tr2HostBitmap::CopyFromTextureRes ( TriTextureRes& res, Tr2RenderContext& renderContext ) +bool Tr2HostBitmap::CopyFromTextureRes( TriTextureRes& res, Tr2RenderContext& renderContext ) { if( !res.GetTexture() ) { @@ -294,7 +294,7 @@ bool Tr2HostBitmap::CopyFromTextureRes ( TriTextureRes& res, Tr2RenderContext& r } } - const uint32_t mipCount = std::min( GetTrueMipCount(), res.GetTrueMipCount() ); + const uint32_t mipCount = std::min( GetTrueMipCount(), res.GetTrueMipCount() ); const uint32_t faceCount = GetArraySize(); @@ -302,7 +302,7 @@ bool Tr2HostBitmap::CopyFromTextureRes ( TriTextureRes& res, Tr2RenderContext& r { for( uint32_t mipLevel = 0; mipLevel != mipCount; ++mipLevel ) { - const void* srcData = nullptr; + const void* srcData = nullptr; uint32_t srcPitch = 0; HRESULT hr = E_FAIL; @@ -325,15 +325,15 @@ bool Tr2HostBitmap::CopyFromTextureRes ( TriTextureRes& res, Tr2RenderContext& r uint8_t* dst = (uint8_t*)GetMipRawData( mipLevel, face ); const uint8_t* src = (uint8_t*)srcData; - const uint32_t dstPitch = GetMipPitch( mipLevel ); + const uint32_t dstPitch = GetMipPitch( mipLevel ); if( alphaConvert ) { - const uint32_t width = GetMipWidth ( mipLevel ); + const uint32_t width = GetMipWidth( mipLevel ); const uint32_t height = GetMipHeight( mipLevel ); for( uint32_t j = 0; j != height; ++j, src += srcPitch, dst += dstPitch ) { - const uint8_t* in = src; + const uint8_t* in = src; uint8_t* out = dst; for( uint32_t i = 0; i != width; ++i ) { @@ -391,13 +391,13 @@ bool Tr2HostBitmap::PopulateMargin( unsigned margin ) return false; } - const unsigned bytesPerPixel = GetBytesPerPixel( GetFormat() ); + const unsigned bytesPerPixel = GetBytesPerPixel( GetFormat() ); const unsigned bytesPerMargin = bytesPerPixel * margin; - const unsigned width = GetWidth() - 2 * margin; + const unsigned width = GetWidth() - 2 * margin; const unsigned height = GetHeight() - 2 * margin; - + //top margin const char* src = GetRawData( margin, margin ); for( unsigned i = 0; i != margin; ++i ) @@ -408,18 +408,18 @@ bool Tr2HostBitmap::PopulateMargin( unsigned margin ) //bottom margin src = GetRawData( margin, height + margin - 1 ); - for( unsigned i = 0; i != margin; ++i ) + for( unsigned i = 0; i != margin; ++i ) { char* dst = GetRawData( margin, height + margin + i ); memcpy( dst, src, bytesPerPixel * width ); } - + for( unsigned y = 0; y != height; ++y ) { //left margin src = GetRawData( margin, y + margin ); char* dst = GetRawData( 0, y + margin ); - for( unsigned i = 0; i != margin; ++i ) + for( unsigned i = 0; i != margin; ++i ) { for( unsigned j = 0; j != bytesPerPixel; ++j ) { @@ -430,7 +430,7 @@ bool Tr2HostBitmap::PopulateMargin( unsigned margin ) //right margin src += ( width - 1 ) * bytesPerPixel; dst += width * bytesPerPixel + bytesPerMargin; - for( unsigned i = 0; i != margin; ++i ) + for( unsigned i = 0; i != margin; ++i ) { for( unsigned j = 0; j != bytesPerPixel; ++j ) { @@ -438,7 +438,7 @@ bool Tr2HostBitmap::PopulateMargin( unsigned margin ) } } } - + return true; } @@ -459,7 +459,7 @@ bool Tr2HostBitmap::Save( const wchar_t* path ) CCP_LOGWARN( "Tr2HostBitmap::Save failed to open Blue stream (%S)", path ); return false; } - ON_BLOCK_EXIT( [&]{ stream->Close(); } ); + ON_BLOCK_EXIT( [&] { stream->Close(); } ); return ImageIO::SaveImage( path, *this, *stream ); } @@ -516,35 +516,34 @@ bool Tr2HostBitmap::Compress( unsigned compressionFormat, unsigned qualityLevel, return false; } - static const PixelFormat format[ TR2DXT_COMPRESS_COUNT ] = - { - PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_RT_DXT1 = 0, - PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_DXT5 = 1, - PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_DXT5N = 2, - PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_YCOCGDXT5 = 3, - PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_3DC = 4, - PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT1 = 5, - PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT3 = 6, - PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT5 = 7, - PIXEL_FORMAT_BC4_UNORM, // TR2DXT_COMPRESS_SQUISH_KBC4 = 8, - PIXEL_FORMAT_BC5_UNORM, // TR2DXT_COMPRESS_SQUISH_KBC5 = 9, + static const PixelFormat format[TR2DXT_COMPRESS_COUNT] = { + PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_RT_DXT1 = 0, + PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_DXT5 = 1, + PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_DXT5N = 2, + PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_YCOCGDXT5 = 3, + PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_RT_3DC = 4, + PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT1 = 5, + PIXEL_FORMAT_BC1_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT3 = 6, + PIXEL_FORMAT_BC3_UNORM, // TR2DXT_COMPRESS_SQUISH_DXT5 = 7, + PIXEL_FORMAT_BC4_UNORM, // TR2DXT_COMPRESS_SQUISH_KBC4 = 8, + PIXEL_FORMAT_BC5_UNORM, // TR2DXT_COMPRESS_SQUISH_KBC5 = 9, }; { - unsigned pitch = ( m_width + 3 ) / 4 * Tr2RenderContextEnum::GetBlockByteSize( format[ compressionFormat ] ); + unsigned pitch = ( m_width + 3 ) / 4 * Tr2RenderContextEnum::GetBlockByteSize( format[compressionFormat] ); CcpMallocBuffer destination( "Tr2HostBitmap::Compress", pitch * ( m_height + 3 ) / 4 ); Tr2DxtCompressControl* control = CCP_NEW( "TriDevice::CompressSurface/control" ) Tr2DxtCompressControl; - ON_BLOCK_EXIT( [&]{ CCP_DELETE( control ); } ); - - if( !Tr2DxtCompressSurfaceAsync( (Tr2DxtCompressionFormat)compressionFormat, - (uint8_t*)GetRawData(), - m_width, - m_height, - (uint8_t*)destination.get(), - pitch, - control, - qualityLevel ) ) + ON_BLOCK_EXIT( [&] { CCP_DELETE( control ); } ); + + if( !Tr2DxtCompressSurfaceAsync( (Tr2DxtCompressionFormat)compressionFormat, + (uint8_t*)GetRawData(), + m_width, + m_height, + (uint8_t*)destination.get(), + pitch, + control, + qualityLevel ) ) { return false; } @@ -576,7 +575,7 @@ uint32_t Tr2HostBitmap::CountPixelsOfValue( const std::string& channels, uint32_ { // Count the number of pixels for which all rgba channels listed in "channels" param match value. - if( !IsValid() || GetBytesPerPixel(m_format) != 4 || IsCompressed() ) + if( !IsValid() || GetBytesPerPixel( m_format ) != 4 || IsCompressed() ) { return 0; } @@ -595,17 +594,17 @@ uint32_t Tr2HostBitmap::CountPixelsOfValue( const std::string& channels, uint32_ { matches &= check_chan_value( 0xFF000000, 24, pixval, value ); } - + if( chan_selected( channels, 'r' ) ) { matches &= check_chan_value( 0x00FF0000, 16, pixval, value ); } - - if( chan_selected( channels, 'g') ) + + if( chan_selected( channels, 'g' ) ) { matches &= check_chan_value( 0x0000FF00, 8, pixval, value ); } - + if( chan_selected( channels, 'b' ) ) { matches &= check_chan_value( 0x000000FF, 0, pixval, value ); @@ -650,7 +649,7 @@ bool Tr2HostBitmap::IsMonochrome() const return true; } -bool Tr2HostBitmap::SetPixel( int x, int y, const void *data ) +bool Tr2HostBitmap::SetPixel( int x, int y, const void* data ) { if( !IsValid() || GetBytesPerPixel( m_format ) != 4 || IsCompressed() ) { @@ -661,13 +660,13 @@ bool Tr2HostBitmap::SetPixel( int x, int y, const void *data ) { return false; } - - char *dest = m_data.get() + y * m_width * 4 + x * 4; + + char* dest = m_data.get() + y * m_width * 4 + x * 4; memcpy( dest, data, 4 ); return true; } -bool Tr2HostBitmap::GetPixel( int x, int y, void *data ) const +bool Tr2HostBitmap::GetPixel( int x, int y, void* data ) const { if( !IsValid() || GetBytesPerPixel( m_format ) != 4 || IsCompressed() ) { @@ -679,27 +678,27 @@ bool Tr2HostBitmap::GetPixel( int x, int y, void *data ) const return false; } - char *src = m_data.get() + y * m_width * 4 + x * 4; + char* src = m_data.get() + y * m_width * 4 + x * 4; memcpy( data, src, 4 ); return true; } #if BLUE_WITH_PYTHON -bool Tr2HostBitmap::SetPixelPy( PyObject *tuple ) +bool Tr2HostBitmap::SetPixelPy( PyObject* tuple ) { static_assert( sizeof( int ) == 4, "Assuming that RGBA8 fits in int" ); int x, y, val; - if(!PyArg_ParseTuple( tuple, "iii", &x, &y, &val ) ) + if( !PyArg_ParseTuple( tuple, "iii", &x, &y, &val ) ) { return false; } - + return SetPixel( x, y, &val ); } -PyObject * Tr2HostBitmap::GetPixelPy( PyObject *tuple ) +PyObject* Tr2HostBitmap::GetPixelPy( PyObject* tuple ) { - int x, y, val=0; + int x, y, val = 0; if( !PyArg_ParseTuple( tuple, "ii", &x, &y ) || !GetPixel( x, y, &val ) ) { @@ -713,14 +712,14 @@ PyObject* Tr2HostBitmap::PySetPixel( PyObject* args ) if( PyTuple_Size( args ) != 1 ) { SetPixelPy( args ); - } - else + } + else { - PyObject *list; + PyObject* list; PyArg_ParseTuple( args, "O", &list ); if( !PySequence_Check( list ) ) { - PyErr_SetString(PyExc_TypeError, "Expected sequence of tuples"); + PyErr_SetString( PyExc_TypeError, "Expected sequence of tuples" ); return nullptr; } Py_ssize_t len = PySequence_Size( list ); @@ -740,20 +739,20 @@ PyObject* Tr2HostBitmap::PyGetPixel( PyObject* args ) { if( PyTuple_Size( args ) != 1 ) { - return GetPixelPy(args); - } - else + return GetPixelPy( args ); + } + else { - PyObject *list; + PyObject* list; PyArg_ParseTuple( args, "O", &list ); if( !PySequence_Check( list ) ) { - PyErr_SetString(PyExc_TypeError, "Expected sequence of tuples"); + PyErr_SetString( PyExc_TypeError, "Expected sequence of tuples" ); return nullptr; } Py_ssize_t len = PySequence_Size( list ); BluePyTuple res( len ); - for( Py_ssize_t i = 0; i< len; i++ ) + for( Py_ssize_t i = 0; i < len; i++ ) { BluePy tuple( PySequence_GetItem( list, i ) ); if( !tuple ) @@ -771,7 +770,7 @@ PyObject* Tr2HostBitmap::PyGetPixel( PyObject* args ) } } -PyObject *Tr2HostBitmap::PySetPixels( PyObject *args ) +PyObject* Tr2HostBitmap::PySetPixels( PyObject* args ) { // legacy method for cramming some pixels into a simple RGBA8 blob from python if( !IsValid() || GetBytesPerPixel( GetFormat() ) != 4 || GetType() != TEX_TYPE_2D || GetTrueMipCount() != 1 ) @@ -779,18 +778,18 @@ PyObject *Tr2HostBitmap::PySetPixels( PyObject *args ) Py_RETURN_NONE; } - int background = 0; - PyObject *pixelsO = 0; - PyObject *discard = 0; - if( !PyArg_ParseTuple( args, "i|OO:SetPixels", &background, &pixelsO, &discard ) ) + int background = 0; + PyObject* pixelsO = 0; + PyObject* discard = 0; + if( !PyArg_ParseTuple( args, "i|OO:SetPixels", &background, &pixelsO, &discard ) ) { - return 0; + return 0; } - BluePy fast( PySequence_Fast( pixelsO, "Expected sequence of tuples" ) ); - if( pixelsO && !fast ) + BluePy fast( PySequence_Fast( pixelsO, "Expected sequence of tuples" ) ); + if( pixelsO && !fast ) { - return 0; + return 0; } for( unsigned y = 0; y != m_height; ++y ) @@ -800,25 +799,25 @@ PyObject *Tr2HostBitmap::PySetPixels( PyObject *args ) *(int*)GetRawData( x, y ) = background; } } - - Py_ssize_t size = PySequence_Fast_GET_SIZE( ( PyObject* )fast ); - for( Py_ssize_t i = 0; i < size; i++ ) + + Py_ssize_t size = PySequence_Fast_GET_SIZE( (PyObject*)fast ); + for( Py_ssize_t i = 0; i < size; i++ ) { - PyObject *tuple = PySequence_Fast_GET_ITEM( ( PyObject* )fast, i ); + PyObject* tuple = PySequence_Fast_GET_ITEM( (PyObject*)fast, i ); int x = 0, y = 0; unsigned val; - if( !PyArg_ParseTuple( tuple, "iiI:SetPixel", &x, &y, &val ) ) + if( !PyArg_ParseTuple( tuple, "iiI:SetPixel", &x, &y, &val ) ) { return 0; } - if( x >= 0 && (unsigned)x < m_width && + if( x >= 0 && (unsigned)x < m_width && y >= 0 && (unsigned)y < m_height ) { *(unsigned*)GetRawData( x, y ) = val; - } - } + } + } - Py_RETURN_NONE; + Py_RETURN_NONE; } // -------------------------------------------------------------------------------------- @@ -836,14 +835,14 @@ PyObject *Tr2HostBitmap::PySetPixels( PyObject *args ) // -------------------------------------------------------------------------------------- bool Tr2HostBitmap::CreateFromHeightData( const std::vector& data, int32_t width, int32_t height ) { - float scaleX = float( width - 1) / float( m_width ); - float scaleY = float( height - 1) / float( m_height ); + float scaleX = float( width - 1 ) / float( m_width ); + float scaleY = float( height - 1 ) / float( m_height ); int32_t yIndex[4]; float yValues[4]; int components = GetBytesPerPixel( m_format ); - if( !IsValid() || !( components == 4 || components == 1 ) || IsCompressed() ) + if( !IsValid() || !( components == 4 || components == 1 ) || IsCompressed() ) { return false; } @@ -870,15 +869,15 @@ bool Tr2HostBitmap::CreateFromHeightData( const std::vector& data, int32_ { int32_t index = dataX + i - 1; // Wrap the x axis - int32_t xIdx = index < 0 ? width - ((-index) % width): index % width; + int32_t xIdx = index < 0 ? width - ( ( -index ) % width ) : index % width; yValues[i] = CubicInterpolate( data[yIndex[0] + xIdx], data[yIndex[1] + xIdx], data[yIndex[2] + xIdx], data[yIndex[3] + xIdx], sy ); } uint8_t value = uint8_t( TriClamp( CubicInterpolate( yValues[0], yValues[1], yValues[2], yValues[3], sx ), 0.f, 1.f ) * 255 ); if( components == 4 ) { - uint32_t d = (value << 24) + (value << 16) + (value << 8) + value; - char *dest = m_data.get() + y * m_width * 4 + x * 4; + uint32_t d = ( value << 24 ) + ( value << 16 ) + ( value << 8 ) + value; + char* dest = m_data.get() + y * m_width * 4 + x * 4; memcpy( dest, &d, 4 ); } else diff --git a/trinity/Tr2HostBitmap.h b/trinity/Tr2HostBitmap.h index b944d7f4e..228c125bf 100644 --- a/trinity/Tr2HostBitmap.h +++ b/trinity/Tr2HostBitmap.h @@ -18,21 +18,22 @@ class Tr2ImageHandler; // A class wrapping a bunch of pixels on the CPU plus width, height, // pixelformat. Replaces the old DX9 specific "offscreen surface". // ------------------------------------------------------------- -BLUE_CLASS( Tr2HostBitmap ) : public IRoot, public ImageIO::HostBitmap, public Tr2AsyncSave +BLUE_CLASS( Tr2HostBitmap ) : + public IRoot, public ImageIO::HostBitmap, public Tr2AsyncSave { public: EXPOSE_TO_BLUE(); - Tr2HostBitmap( IRoot* = 0 ); + Tr2HostBitmap( IRoot* = 0 ); ~Tr2HostBitmap(); virtual void Destroy(); - bool CopyFromRenderTarget( Tr2TextureAL& rt, Tr2RenderContext& renderContext ); - bool CopyFromRenderTarget( Tr2TextureAL& rt, const int* srcRect, int offsetX, int offsetY, Tr2RenderContext& renderContext ); - bool CopyFaceFromRenderTarget( Tr2RenderContextEnum::CubemapFace face, Tr2TextureAL& rt, Tr2RenderContext& renderContext ); - bool CopyFromTexture( Tr2TextureAL& texture, Tr2RenderContext& renderContext ); - bool CopyFromTextureRes ( TriTextureRes& res, Tr2RenderContext& renderContext ); + bool CopyFromRenderTarget( Tr2TextureAL & rt, Tr2RenderContext & renderContext ); + bool CopyFromRenderTarget( Tr2TextureAL & rt, const int* srcRect, int offsetX, int offsetY, Tr2RenderContext& renderContext ); + bool CopyFaceFromRenderTarget( Tr2RenderContextEnum::CubemapFace face, Tr2TextureAL & rt, Tr2RenderContext & renderContext ); + bool CopyFromTexture( Tr2TextureAL & texture, Tr2RenderContext & renderContext ); + bool CopyFromTextureRes( TriTextureRes & res, Tr2RenderContext & renderContext ); bool CreateFromHeightData( const std::vector& data, int32_t width, int32_t height ); bool PopulateMargin( unsigned margin ); bool Save( const wchar_t* destFile ); @@ -45,36 +46,36 @@ BLUE_CLASS( Tr2HostBitmap ) : public IRoot, public ImageIO::HostBitmap, public T bool IsMonochrome() const; // Ugly methods to support old code that does ugly things. - bool SetPixel( int width, int height, const void* val ); - bool GetPixel( int width, int height, void* val ) const; + bool SetPixel( int width, int height, const void* val ); + bool GetPixel( int width, int height, void* val ) const; ALResult ChangeFormatFromScript( Tr2RenderContextEnum::PixelFormat format ); private: - bool CopyFromRenderTargetPython( Tr2RenderTarget* rt ); - bool CopyFromRenderTargetRegionPython( Tr2RenderTarget* rt, int left, int top, int right, int bottom, unsigned offsetX, unsigned offsetY ); + bool CopyFromRenderTargetPython( Tr2RenderTarget * rt ); + bool CopyFromRenderTargetRegionPython( Tr2RenderTarget * rt, int left, int top, int right, int bottom, unsigned offsetX, unsigned offsetY ); #if BLUE_WITH_PYTHON - bool SetPixelPy(PyObject *tuple); - PyObject* GetPixelPy(PyObject *typle); - PyObject* PySetPixel( PyObject* args ); - PyObject* PyGetPixel( PyObject* args ); - PyObject* PySetPixels( PyObject* args ); + bool SetPixelPy( PyObject * tuple ); + PyObject* GetPixelPy( PyObject * typle ); + PyObject* PySetPixel( PyObject * args ); + PyObject* PyGetPixel( PyObject * args ); + PyObject* PySetPixels( PyObject * args ); #endif bool CopyFaceFromRenderTargetPython( unsigned face, Tr2RenderTarget* rt ); - bool CopyFromTextureResPython( TriTextureRes* tr ); + bool CopyFromTextureResPython( TriTextureRes * tr ); - bool SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::CubemapFace face, Tr2TextureAL& rt, const int* srcRect, int offsetX, int offsetY, Tr2RenderContext& renderContext ); + bool SharedCopyFaceFromRenderTarget( Tr2RenderContextEnum::CubemapFace face, Tr2TextureAL & rt, const int* srcRect, int offsetX, int offsetY, Tr2RenderContext& renderContext ); #if BLUE_WITH_PYTHON - PyObject* PyApplyConvFilter ( PyObject* args ); - static PyObject* PyGetRawData( PyObject* self, PyObject* args ); - static PyObject* PyGetMipRawData( PyObject* self, PyObject* args ); - static PyObject* PySetMipRawData( PyObject* self, PyObject* args ); + PyObject* PyApplyConvFilter( PyObject * args ); + static PyObject* PyGetRawData( PyObject * self, PyObject * args ); + static PyObject* PyGetMipRawData( PyObject * self, PyObject * args ); + static PyObject* PySetMipRawData( PyObject * self, PyObject * args ); #endif #if BLUE_WITH_PYTHON - PyObject* PyCreateFromFile( PyObject* args ); + PyObject* PyCreateFromFile( PyObject * args ); #endif // Tr2AsyncSave diff --git a/trinity/Tr2HostBitmap_Blue.cpp b/trinity/Tr2HostBitmap_Blue.cpp index 46d554cf7..23d7a5f92 100644 --- a/trinity/Tr2HostBitmap_Blue.cpp +++ b/trinity/Tr2HostBitmap_Blue.cpp @@ -16,7 +16,7 @@ static PyObject* PyInit( PyObject* self, PyObject* args ) Tr2HostBitmap* pThis = BluePythonCast( self ); PyObject* pyBlueObject = nullptr; - unsigned dummy1 = 0, dummy2 = 0, dummy3 = 0; // make sure the signature is still up to 4 elements, else blue binding doesn't work with constructor 'overloading' :( + unsigned dummy1 = 0, dummy2 = 0, dummy3 = 0; // make sure the signature is still up to 4 elements, else blue binding doesn't work with constructor 'overloading' :( if( PyArg_ParseTuple( args, "|Oiii", &pyBlueObject, &dummy1, &dummy2, &dummy3 ) && pyBlueObject && !dummy1 && !dummy2 && !dummy3 ) { Tr2RenderTarget* renderTarget = nullptr; @@ -39,7 +39,7 @@ static PyObject* PyInit( PyObject* self, PyObject* args ) // ...and with Tr2TextureAtlas Tr2TextureAtlas* textureAtlas = nullptr; - if( BluePythonCast( pyBlueObject ) && BlueExtractArgument( pyBlueObject, textureAtlas, 1 ) && + if( BluePythonCast( pyBlueObject ) && BlueExtractArgument( pyBlueObject, textureAtlas, 1 ) && textureAtlas && textureAtlas->GetTexture() && textureAtlas->GetTexture()->IsValid() ) { auto& texture = *textureAtlas->GetTexture(); @@ -75,10 +75,10 @@ PyObject* Tr2HostBitmap::PyGetRawData( PyObject* self, PyObject* args ) { PyObject* buffer = PyVerCompat::MemoryViewRW( pThis->GetRawData(), pThis->GetHeight() * pThis->GetPitch() ); - PyObject *result = PyTuple_New(4); - if ( !result ) + PyObject* result = PyTuple_New( 4 ); + if( !result ) { - Py_DECREF(buffer); + Py_DECREF( buffer ); Py_RETURN_FALSE; } PyTuple_SET_ITEM( result, 0, buffer ); @@ -100,15 +100,15 @@ PyObject* Tr2HostBitmap::PyGetMipRawData( PyObject* self, PyObject* args ) { // requested miplevel is provided via function arguement unsigned int mipLevel = 0; - if( !PyArg_ParseTuple( args, "i", &mipLevel )) + if( !PyArg_ParseTuple( args, "i", &mipLevel ) ) Py_RETURN_FALSE; - PyObject* buffer = PyVerCompat::MemoryViewRW( pThis->GetMipRawData( mipLevel ), pThis->GetMipHeight( mipLevel ) * pThis->GetMipPitch( mipLevel ) ); + PyObject* buffer = PyVerCompat::MemoryViewRW( pThis->GetMipRawData( mipLevel ), pThis->GetMipHeight( mipLevel ) * pThis->GetMipPitch( mipLevel ) ); - PyObject *result = PyTuple_New(4); - if ( !result ) + PyObject* result = PyTuple_New( 4 ); + if( !result ) { - Py_DECREF(buffer); + Py_DECREF( buffer ); Py_RETURN_FALSE; } PyTuple_SET_ITEM( result, 0, buffer ); @@ -126,7 +126,7 @@ PyObject* Tr2HostBitmap::PySetMipRawData( PyObject* self, PyObject* args ) { unsigned int mipLevel = 0; Py_buffer buffer; - if( !PyArg_ParseTuple( args, "iw*", &mipLevel, &buffer )) + if( !PyArg_ParseTuple( args, "iw*", &mipLevel, &buffer ) ) return nullptr; ON_BLOCK_EXIT( [&] { PyBuffer_Release( &buffer ); } ); @@ -164,10 +164,10 @@ PyObject* Tr2HostBitmap::PyCreateFromFile( PyObject* args ) return nullptr; } - std::wstring wcstr; + std::wstring wcstr; std::string cstr; if( PyUnicode_Check( file ) && BlueExtractArgument( file, wcstr, 1 ) ) - { + { CreateFromFile( wcstr ); } #if PY_MAJOR_VERSION == 2 @@ -186,15 +186,22 @@ PyObject* Tr2HostBitmap::PyCreateFromFile( PyObject* args ) { Py_RETURN_NONE; } - - return Py_BuildValue("{sisisisisisisi}", - "Width", GetWidth(), - "Height", GetHeight(), - "Depth", GetDepth(), - "MipLevels", GetMipCount(), - "Format", GetFormat(), - "ResourceType", 0, - "ImageFileFormat", 0 ); + + return Py_BuildValue( "{sisisisisisisi}", + "Width", + GetWidth(), + "Height", + GetHeight(), + "Depth", + GetDepth(), + "MipLevels", + GetMipCount(), + "Format", + GetFormat(), + "ResourceType", + 0, + "ImageFileFormat", + 0 ); } static PyObject* PythonSave( PyObject* self, PyObject* args, bool async ) @@ -209,7 +216,7 @@ static PyObject* PythonSave( PyObject* self, PyObject* args, bool async ) return nullptr; } - std::wstring wcstr; + std::wstring wcstr; std::string cstr; bool OK = false; if( PyUnicode_Check( file ) && BlueExtractArgument( file, wcstr, 1 ) ) @@ -300,29 +307,28 @@ static PyObject* PyCompareBitmaps( PyObject* self, PyObject* args ) return NULL; } - if( img1->GetWidth() != img2->GetWidth() || - img1->GetHeight() != img2->GetHeight() || - img1->GetFormat() != img2->GetFormat() || - img1->GetMipCount() != img2->GetMipCount() || - img1->GetType() != TEX_TYPE_2D || - img2->GetType() != TEX_TYPE_2D - ) + if( img1->GetWidth() != img2->GetWidth() || + img1->GetHeight() != img2->GetHeight() || + img1->GetFormat() != img2->GetFormat() || + img1->GetMipCount() != img2->GetMipCount() || + img1->GetType() != TEX_TYPE_2D || + img2->GetType() != TEX_TYPE_2D ) { char buffer[2048]; - sprintf_s( buffer, - "CompareBitmaps only works between identical layout 2D bitmaps. " - " image1: %ux%ux%u %i %i image2: %ux%ux%u %i %i", - unsigned( img1->GetWidth() ), - unsigned( img1->GetHeight() ), - unsigned( img1->GetMipCount() ), - int( img1->GetFormat() ), - int( img1->GetType() ), - unsigned( img2->GetWidth() ), - unsigned( img2->GetHeight() ), - unsigned( img2->GetMipCount() ), - int( img2->GetFormat() ), - int( img2->GetType() ) ); - + sprintf_s( buffer, + "CompareBitmaps only works between identical layout 2D bitmaps. " + " image1: %ux%ux%u %i %i image2: %ux%ux%u %i %i", + unsigned( img1->GetWidth() ), + unsigned( img1->GetHeight() ), + unsigned( img1->GetMipCount() ), + int( img1->GetFormat() ), + int( img1->GetType() ), + unsigned( img2->GetWidth() ), + unsigned( img2->GetHeight() ), + unsigned( img2->GetMipCount() ), + int( img2->GetFormat() ), + int( img2->GetType() ) ); + PyErr_SetString( PyExc_TypeError, buffer ); return NULL; } @@ -335,7 +341,7 @@ static PyObject* PyCompareBitmaps( PyObject* self, PyObject* args ) uint32_t count = 0; for( unsigned mip = 0; mip != img1->GetTrueMipCount(); ++mip ) { - uint32_t size = img1->GetMipSize(mip); + uint32_t size = img1->GetMipSize( mip ); while( size-- ) { if( *d1++ != *d2++ ) @@ -358,7 +364,7 @@ static PyObject* PyCompareBitmaps( PyObject* self, PyObject* args ) } unsigned count = 0; - + const uint8_t* d1 = (const uint8_t*)img1->GetRawData(); const uint8_t* d2 = (const uint8_t*)img2->GetRawData(); uint8_t* d3 = nullptr; @@ -429,65 +435,52 @@ const Be::ClassInfo* Tr2HostBitmap::ExposeToBlue() { ///////////////////////////////////////// // Blue class info - EXPOSURE_BEGIN( Tr2HostBitmap, "" ) + EXPOSURE_BEGIN( Tr2HostBitmap, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( Tr2HostBitmap ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "IsValid", IsValid, - "No arguments" - ) + "No arguments" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "IsCompressed", IsCompressed, - "No arguments" - ) + "No arguments" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Create", Create, ":param width: bitmap width\n" ":param height: bitmap height\n" ":param mipCount: number of mip levels\n" - ":param format: pixel format (trinity.PIXEL_FORMAT)" - ) + ":param format: pixel format (trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CreateCube", CreateCube, ":param width: bitmap width\n" ":param mipCount: number of mip levels\n" - ":param format: pixel format (trinity.PIXEL_FORMAT)" - ) + ":param format: pixel format (trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CreateVolume", CreateVolume, ":param width: bitmap width\n" ":param height: bitmap height\n" ":param depth: bitmap depth\n" ":param mipCount: number of mip levels\n" - ":param format: pixel format (trinity.PIXEL_FORMAT)" - ) + ":param format: pixel format (trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CopyFromRenderTarget", CopyFromRenderTargetPython, "Copy a non-MSAA renderTarget back to the CPU host.\n" - ":param source: Tr2RenderTarget of the same pixelFormat, and correct width/height\n" - ) + ":param source: Tr2RenderTarget of the same pixelFormat, and correct width/height\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CopyFromRenderTargetRegion", CopyFromRenderTargetRegionPython, "Copy a non-MSAA renderTarget back to the CPU host.\n" @@ -497,90 +490,75 @@ const Be::ClassInfo* Tr2HostBitmap::ExposeToBlue() ":param right: Source rectangle right offset in pixels\n" ":param bottom: Source rectangle bottom offset in pixels\n" ":param x: X offset in the bitmap in pixels\n" - ":param y: Y offset in the bitmap in pixels" - ) + ":param y: Y offset in the bitmap in pixels" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CopyFaceFromRenderTarget", CopyFaceFromRenderTargetPython, "Copy a non-MSAA renderTarget back to the CPU host.\n" ":param face: cube map face\n" - ":param source: Tr2RenderTarget of the same pixelFormat, and correct width/height\n" - ) + ":param source: Tr2RenderTarget of the same pixelFormat, and correct width/height\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CopyFromTextureRes", CopyFromTextureResPython, "Copy a TriTextureRes back to the CPU host.\n" - ":param source: TriTextureRes of the same pixelFormat, and correct width/height\n" - ) - - MAP_METHOD_AND_WRAP - ( + ":param source: TriTextureRes of the same pixelFormat, and correct width/height\n" ) + + MAP_METHOD_AND_WRAP( "CreateFromHeightData", CreateFromHeightData, "Creates a height map by scaling up source data to fill the bitmap.\n" ":param data: source data, values from 0 to 1\n" ":param width: width of the source data\n" - ":param height: height of the source data\n" - ) + ":param height: height of the source data\n" ) - MAP_METHOD - ( + MAP_METHOD( "GetRawData", - PyGetRawData, + PyGetRawData, "Returns a tuple with (raw data pointer, width, height, pitch in bytes)\n" - ":rtype: bool | (buffer, int, int, int)" - ) + ":rtype: bool | (buffer, int, int, int)" ) - MAP_METHOD - ( + MAP_METHOD( "GetMipRawData", - PyGetMipRawData, + PyGetMipRawData, "Returns a tuple with (raw data pointer, width, height, pitch in bytes) of the specified mip level\n" ":param level: mip level\n" ":type level: int\n" - ":rtype: bool | (buffer, int, int, int)" - ) + ":rtype: bool | (buffer, int, int, int)" ) - MAP_METHOD - ( + MAP_METHOD( "SetMipRawData", - PySetMipRawData, + PySetMipRawData, "Copies raw mip data to the bitmap\n" ":param mip: mip level index\n" ":type mip: int\n" ":param data: single-segment buffer\n" ":type data: buffer\n" - ":rtype: None" - ) + ":rtype: None" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "PopulateMargin", PopulateMargin, "Assume that the bitmap has a margin-wide border around it, and clamp the border contents of\n" "(margin,margin)...(width-margin,height-margin) into this border.\n" - ":param margin: unsigned, must be less than min(width/2, height/2)" - ) + ":param margin: unsigned, must be less than min(width/2, height/2)" ) - MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); + MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ); - MAP_ATTRIBUTE( "width" , m_width, "", Be::READ ); - MAP_ATTRIBUTE( "height", m_height, "", Be::READ ); - MAP_ATTRIBUTE( "mipCount", m_mipCount, "", Be::READ ); + MAP_ATTRIBUTE( "width", m_width, "", Be::READ ); + MAP_ATTRIBUTE( "height", m_height, "", Be::READ ); + MAP_ATTRIBUTE( "mipCount", m_mipCount, "", Be::READ ); MAP_ATTRIBUTE( "imageType", m_type, "", Be::READ ); - MAP_ATTRIBUTE_WITH_CHOOSER( "format", m_format, "", Be::READ, Tr2RenderContextEnum_PixelFormat_Chooser ); + MAP_ATTRIBUTE_WITH_CHOOSER( "format", m_format, "", Be::READ, Tr2RenderContextEnum_PixelFormat_Chooser ); - MAP_PROPERTY_READONLY( "isValid", IsValid, "IsValid" ); + MAP_PROPERTY_READONLY( "isValid", IsValid, "IsValid" ); - MAP_METHOD( - "__init__", - PyInit, + MAP_METHOD( + "__init__", + PyInit, "Has three possible overloads:\n" "(1) Tr2HostBitmap() - creates an empty bitmap, call Create later\n" "(2) Tr2HostBitmap(source) - creates a bitmap and copies data from source (RT, texture)\n" @@ -592,101 +570,78 @@ const Be::ClassInfo* Tr2HostBitmap::ExposeToBlue() ":param mipCount: number of mip levels\n" ":type mipCount: Optional[int]\n" ":param format: pixel format (trinity.PIXEL_FORMAT)\n" - ":type format: Optional[int]\n" - ) + ":type format: Optional[int]\n" ) - MAP_METHOD - ( + MAP_METHOD( "Save", PySave, "Save to a file\n" ":param path: full path (not a res path)\n" ":type path: basestring\n" - ":rtype: bool" - ) + ":rtype: bool" ) - MAP_METHOD - ( + MAP_METHOD( "SaveAsync", PySaveAsync, "Asynchronous save to a file\n" ":param path: full path (not a res path)\n" ":type path: basestring\n" - ":rtype: bool" - ) + ":rtype: bool" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CountPixelsOfValue", CountPixelsOfValue, "Count number of pixels that have a specific value in selected channels.\n" ":param channels: String containing one or more of 'r', 'g', 'b', 'a' characters.\n" - ":param value: Value to count for masked pixels" - ) + ":param value: Value to count for masked pixels" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "IsMonochrome", IsMonochrome, - "Return boolean value representing whether image contains same values in R, G, B channels for all pixels.\n" - ) + "Return boolean value representing whether image contains same values in R, G, B channels for all pixels.\n" ) - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "CreateFromFile", PyCreateFromFile, "Create a hostbitmap with the contents of this image file.\n" - ":param path: full path or res path of an image supported by Trinity" - ) + ":param path: full path or res path of an image supported by Trinity" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Compress", Compress, "Compress the contents of the hostbitmap into a TriTextureRes.\n" ":param compressionFormat: see SquishLib\n" ":param compressionQuality: see SquishLib\n" - ":param output: an empty TriTextureRes" - ) + ":param output: an empty TriTextureRes" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Downsample2x2", Downsample2x2, - "Do a destructive, in-place downsampling with a simple 2x2 box filter." - ) + "Do a destructive, in-place downsampling with a simple 2x2 box filter." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Crop", Crop, "Crop a single miplevel 2D bitmap in uncompressed format to a specified rectangle.\n" ":param left: left coordinate of crop rectangle\n" ":param top: top coordinate of crop rectangle\n" ":param right: right coordinate of crop rectangle\n" - ":param bottom: bottom coordinate of crop rectangle" - ) + ":param bottom: bottom coordinate of crop rectangle" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "ConvertToVolume", ConvertToVolume, - "Special function to convert a 2d representation of a 3d bitmap into a real 3d bitmap." - ) + "Special function to convert a 2d representation of a 3d bitmap into a real 3d bitmap." ) - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "SetPixel", - PySetPixel, - "[DEPRECATED] Sets a pixel at arg1, arg2 to arg3" - ) - - MAP_METHOD_AS_METHOD - ( + PySetPixel, + "[DEPRECATED] Sets a pixel at arg1, arg2 to arg3" ) + + MAP_METHOD_AS_METHOD( "GetPixel", - PyGetPixel, - "[DEPRECATED] Returns the pixel at arg1, arg2" - ) + PyGetPixel, + "[DEPRECATED] Returns the pixel at arg1, arg2" ) MAP_METHOD_AND_WRAP( "IsSaving", IsSaving, "Is an asynchronous save in progress?" ); @@ -694,9 +649,9 @@ const Be::ClassInfo* Tr2HostBitmap::ExposeToBlue() MAP_METHOD_AND_WRAP( "IsSaveSucceeded", IsSaveSucceeded, "Did an asynchronous save succeed?" ); MAP_METHOD_AND_WRAP( "WaitForSave", WaitForSave, "Block until an asynchronous save completed." ); - MAP_METHOD_AND_WRAP( - "ChangeFormat", - ChangeFormatFromScript, + MAP_METHOD_AND_WRAP( + "ChangeFormat", + ChangeFormatFromScript, "Changes pixel format of a valid bitmap. Both the old and the new format must be\n" "uncompressed and BPP of the new format must be the same as for the old one.\n" "The function simply changes the format and doesn't do any image conversion.\n" @@ -707,10 +662,9 @@ const Be::ClassInfo* Tr2HostBitmap::ExposeToBlue() #if BLUE_WITH_PYTHON -MAP_FUNCTION -( - "CompareBitmaps", - PyCompareBitmaps, +MAP_FUNCTION( + "CompareBitmaps", + PyCompareBitmaps, "Compares two bitmaps and returns the number of pixel elements (not pixels) that exceed\n" "a given threshold.\n" "count = CompareBitmaps(img1, img2, tolerance, diff)\n\n" @@ -725,17 +679,14 @@ MAP_FUNCTION ":returns: Number of pixel elements that exceed a given threshold.\n" " If diff is passed in, its pixels are set to difference between levels of corresponding pixels\n" " of both bitmaps.\n" - ":rtype: int" -); + ":rtype: int" ); -MAP_FUNCTION -( +MAP_FUNCTION( "BgraToRgb", PyBgraToRgb, "Converts a buffer containing B8G8R8A8 pixel values to R8G8B8 buffer\n" ":param pixels: readable buffer with pixel color values\n" ":type pixels: buffer | str\n" - ":rtype: str" -); + ":rtype: str" ); #endif diff --git a/trinity/Tr2ImageIOHelpers.cpp b/trinity/Tr2ImageIOHelpers.cpp index 1174f979a..23b75e805 100644 --- a/trinity/Tr2ImageIOHelpers.cpp +++ b/trinity/Tr2ImageIOHelpers.cpp @@ -9,9 +9,7 @@ using namespace Tr2RenderContextEnum; namespace { -bool CreateCubeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext& renderContext ) +bool CreateCubeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& out, uint32_t& memoryUse, Tr2PrimaryRenderContext& renderContext ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -21,17 +19,17 @@ bool CreateCubeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, } const unsigned trueMipLevelCount = bitmap.GetTrueMipCount(); - + std::vector initData; - for( unsigned face = 0; face != 6 ; ++face ) - { + for( unsigned face = 0; face != 6; ++face ) + { for( unsigned i = 0; i != trueMipLevelCount; ++i ) { Tr2SubresourceData srd; - srd.m_sysMem = const_cast( bitmap.GetMipRawData( i, CubemapFace( face ) ) ); - srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ); - srd.m_sysMemPitch = bitmap.GetMipPitch( i ); + srd.m_sysMem = const_cast( bitmap.GetMipRawData( i, CubemapFace( face ) ) ); + srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ); + srd.m_sysMemPitch = bitmap.GetMipPitch( i ); if( !srd.m_sysMem ) { @@ -44,13 +42,10 @@ bool CreateCubeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, } } - return !FAILED( out.Create( bitmap, Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, &initData[0], renderContext ) - ); + return !FAILED( out.Create( bitmap, Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, &initData[0], renderContext ) ); } -bool CreateVolumeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext &renderContext ) +bool CreateVolumeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& out, uint32_t& memoryUse, Tr2PrimaryRenderContext& renderContext ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -72,9 +67,9 @@ bool CreateVolumeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, { Tr2SubresourceData srd; - srd.m_sysMem = const_cast( bitmap.GetMipRawData( i ) ); - srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ) / std::max( bitmap.GetMipDepth( i ), 1u ); - srd.m_sysMemPitch = bitmap.GetMipPitch( i ); + srd.m_sysMem = const_cast( bitmap.GetMipRawData( i ) ); + srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ) / std::max( bitmap.GetMipDepth( i ), 1u ); + srd.m_sysMemPitch = bitmap.GetMipPitch( i ); if( !srd.m_sysMem ) { @@ -96,10 +91,7 @@ bool CreateVolumeTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, namespace Tr2ImageIOHelpers { -bool Create2DTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext &renderContext, - Tr2RenderContextEnum::BufferUsage usage ) +bool Create2DTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& out, uint32_t& memoryUse, Tr2PrimaryRenderContext& renderContext, Tr2RenderContextEnum::BufferUsage usage ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -120,9 +112,9 @@ bool Create2DTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, { Tr2SubresourceData& srd = initData[i + j * trueMipLevelCount]; - srd.m_sysMem = const_cast( bitmap.GetMipRawData( i, j ) ); - srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ); - srd.m_sysMemPitch = bitmap.GetMipPitch( i ); + srd.m_sysMem = const_cast( bitmap.GetMipRawData( i, j ) ); + srd.m_sysMemSlicePitch = bitmap.GetMipSize( i ); + srd.m_sysMemPitch = bitmap.GetMipPitch( i ); if( !srd.m_sysMem ) { @@ -133,14 +125,10 @@ bool Create2DTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, } } - return !FAILED( out.Create( bitmap, Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, &initData[0], renderContext ) - ); + return !FAILED( out.Create( bitmap, Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, &initData[0], renderContext ) ); } -bool CreateTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext &renderContext, - Tr2RenderContextEnum::BufferUsage usage ) +bool CreateTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& out, uint32_t& memoryUse, Tr2PrimaryRenderContext& renderContext, Tr2RenderContextEnum::BufferUsage usage ) { if( !bitmap.IsValid() ) { @@ -191,7 +179,7 @@ bool CopyToTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& texture, unsigned { CCP_LOGERR( "Tr2ImageHandler::CopyToTexture - UpdateSubresource failed [no margin]: %08x", result.GetResult() ); } - return SUCCEEDED(result); + return SUCCEEDED( result ); } // Can't expect the Hal to support updating a subresource with automatic replication of border pixels, so do this ourselves in a chunk @@ -206,16 +194,17 @@ bool CopyToTexture( ImageIO::HostBitmap& bitmap, Tr2TextureAL& texture, unsigned { CCP_LOGERR( "Tr2ImageHandler::CopyToTexture - UpdateSubresource failed [margin]: %08x", result.GetResult() ); } - return SUCCEEDED(result); + return SUCCEEDED( result ); } -void AddMargin( const Tr2RenderContextEnum::PixelFormat format, +void AddMargin( const Tr2RenderContextEnum::PixelFormat format, const unsigned char* source, - const unsigned width, const unsigned height, + const unsigned width, + const unsigned height, const unsigned margin, - std::vector &output, - unsigned &outputPitch ) + std::vector& output, + unsigned& outputPitch ) { const unsigned char* src = source; @@ -224,16 +213,16 @@ void AddMargin( const Tr2RenderContextEnum::PixelFormat format, const unsigned blockByteSize = Tr2RenderContextEnum::GetBlockByteSize( format ); const unsigned blockPixelSize = 4; CCP_ASSERT( blockByteSize != 0 && margin % blockPixelSize == 0 ); - const unsigned blockMargin = margin / blockPixelSize; - const unsigned blocksX = width / blockPixelSize; - const unsigned blocksY = height / blockPixelSize; + const unsigned blockMargin = margin / blockPixelSize; + const unsigned blocksX = width / blockPixelSize; + const unsigned blocksY = height / blockPixelSize; //technically the block contents need to be mirrored in the margin to get nice filtering, // but that's somewhat fiddly. //textures which are intended to be used in a tiled fashion could also use the block from // the opposite edge. //maybe we need a usage hint here to inform this decision. - + outputPitch = ( blocksX + 2 * blockMargin ) * blockByteSize; output.resize( ( blockMargin + blocksY + blockMargin ) * outputPitch ); unsigned char* dst = &output[0]; @@ -246,24 +235,24 @@ void AddMargin( const Tr2RenderContextEnum::PixelFormat format, } // Have to copy one line at a time since the target area is not linearly laid out. - + for( unsigned line = 0; line < height; line += blockPixelSize ) { //left margin - for( unsigned i = 0; i != blockMargin; ++i ) + for( unsigned i = 0; i != blockMargin; ++i ) { memcpy( dst + i * blockByteSize, src, blockByteSize ); } - + memcpy( dst + blockMargin * blockByteSize, src, blocksX * blockByteSize ); - + //right margin - for( unsigned i = 0; i != blockMargin; ++i ) + for( unsigned i = 0; i != blockMargin; ++i ) { - memcpy( dst + (blocksX+blockMargin+i) * blockByteSize, src + (blocksX-1) * blockByteSize, blockByteSize ); + memcpy( dst + ( blocksX + blockMargin + i ) * blockByteSize, src + ( blocksX - 1 ) * blockByteSize, blockByteSize ); } - if( line < height-1 ) + if( line < height - 1 ) { src += blocksX * blockByteSize; } @@ -284,7 +273,7 @@ void AddMargin( const Tr2RenderContextEnum::PixelFormat format, const unsigned byteCount = GetBytesPerPixel( format ); // Align srcPitch to 4 bytes. - unsigned int srcPitch = 4 * ((width * byteCount + 3) / 4); + unsigned int srcPitch = 4 * ( ( width * byteCount + 3 ) / 4 ); outputPitch = ( width + 2 * margin ) * byteCount; @@ -304,20 +293,20 @@ void AddMargin( const Tr2RenderContextEnum::PixelFormat format, for( unsigned line = 0; line != height; ++line ) { //left margin - for( unsigned i = 0; i != margin; ++i ) + for( unsigned i = 0; i != margin; ++i ) { memcpy( dst + i * byteCount, src, byteCount ); } memcpy( dst + margin * byteCount, src, width * byteCount ); - + //right margin - for( unsigned i = 0; i != margin; ++i ) + for( unsigned i = 0; i != margin; ++i ) { - memcpy( dst + ( width + margin + i ) * byteCount, src + ( width-1 ) * byteCount, byteCount ); + memcpy( dst + ( width + margin + i ) * byteCount, src + ( width - 1 ) * byteCount, byteCount ); } - if( line < height-1 ) + if( line < height - 1 ) { src += srcPitch; } diff --git a/trinity/Tr2ImageIOHelpers.h b/trinity/Tr2ImageIOHelpers.h index 704fb15f1..f3c09e9a3 100644 --- a/trinity/Tr2ImageIOHelpers.h +++ b/trinity/Tr2ImageIOHelpers.h @@ -9,34 +9,35 @@ class Tr2ImageHandler; namespace Tr2ImageIOHelpers { -bool CreateTexture( - ImageIO::HostBitmap& ih, - Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext &renderContext, +bool CreateTexture( + ImageIO::HostBitmap& ih, + Tr2TextureAL& out, + uint32_t& memoryUse, + Tr2PrimaryRenderContext& renderContext, Tr2RenderContextEnum::BufferUsage usage = Tr2RenderContextEnum::USAGE_CPU_READ ); -bool Create2DTexture( - ImageIO::HostBitmap& ih, - Tr2TextureAL &out, - uint32_t &memoryUse, - Tr2PrimaryRenderContext &renderContext, +bool Create2DTexture( + ImageIO::HostBitmap& ih, + Tr2TextureAL& out, + uint32_t& memoryUse, + Tr2PrimaryRenderContext& renderContext, Tr2RenderContextEnum::BufferUsage usage = Tr2RenderContextEnum::USAGE_CPU_READ ); -bool CopyToTexture( - ImageIO::HostBitmap& ih, - Tr2TextureAL& texture, - unsigned int x, - unsigned int y, - unsigned int margin, +bool CopyToTexture( + ImageIO::HostBitmap& ih, + Tr2TextureAL& texture, + unsigned int x, + unsigned int y, + unsigned int margin, Tr2RenderContext& renderContext ); -void AddMargin( const Tr2RenderContextEnum::PixelFormat format, +void AddMargin( const Tr2RenderContextEnum::PixelFormat format, const unsigned char* source, - const unsigned width, const unsigned height, + const unsigned width, + const unsigned height, const unsigned margin, - std::vector &output, - unsigned &outputPitch ); + std::vector& output, + unsigned& outputPitch ); } #endif \ No newline at end of file diff --git a/trinity/Tr2ImpostorManager.cpp b/trinity/Tr2ImpostorManager.cpp index b35b57faa..c843f357d 100644 --- a/trinity/Tr2ImpostorManager.cpp +++ b/trinity/Tr2ImpostorManager.cpp @@ -23,8 +23,8 @@ struct ImposterVertex } -Tr2ImpostorManager::ImpostorAtlas::ImpostorAtlas() - :m_free( "Tr2ImpostorManager::ImpostorAtlas::m_free" ) +Tr2ImpostorManager::ImpostorAtlas::ImpostorAtlas() : + m_free( "Tr2ImpostorManager::ImpostorAtlas::m_free" ) { } @@ -86,8 +86,8 @@ void Tr2ImpostorManager::ImpostorAtlas::Drop( Vector2_16 coord ) } -Tr2ImpostorManager::Tr2ImpostorManager() - :m_width( 1024 ), +Tr2ImpostorManager::Tr2ImpostorManager() : + m_width( 1024 ), m_height( 1024 ), m_itemWidth( 32 ), m_itemHeight( 32 ), @@ -101,7 +101,7 @@ Tr2ImpostorManager::Tr2ImpostorManager() Tr2Variable altas( "ImposterAtlasMap", m_rt ); Tr2Variable itemSizeVar( "ImposterItemSize", Vector4() ); - + m_effect.CreateInstance(); m_effect->SetEffectPathName( "res:/graphics/effect/managed/space/system/impostor.fx" ); @@ -135,7 +135,7 @@ bool Tr2ImpostorManager::Initialize() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Resets the manager after attribute changes. +// Implements INotify interface. Resets the manager after attribute changes. // Return Value: // true always // -------------------------------------------------------------------------------------- @@ -147,7 +147,7 @@ bool Tr2ImpostorManager::OnModified( Be::Var* ) // -------------------------------------------------------------------------------------- // Description: -// Implements Tr2DeviceResource method. Doesn't really do anything. +// Implements Tr2DeviceResource method. Doesn't really do anything. // -------------------------------------------------------------------------------------- void Tr2ImpostorManager::ReleaseResources( TriStorage ) { @@ -155,7 +155,7 @@ void Tr2ImpostorManager::ReleaseResources( TriStorage ) // -------------------------------------------------------------------------------------- // Description: -// Implements Tr2DeviceResource method. Creates rendering resources. +// Implements Tr2DeviceResource method. Creates rendering resources. // Return Value: // true always // -------------------------------------------------------------------------------------- @@ -177,11 +177,11 @@ bool Tr2ImpostorManager::OnPrepareResources() // itemWidth - Billboard width // itemHeight - Billboard height // -------------------------------------------------------------------------------------- -void Tr2ImpostorManager::Create( - Be::OptionalWithDefaultValue width, - Be::OptionalWithDefaultValue height, - Be::OptionalWithDefaultValue itemWidth, - Be::OptionalWithDefaultValue itemHeight ) +void Tr2ImpostorManager::Create( + Be::OptionalWithDefaultValue width, + Be::OptionalWithDefaultValue height, + Be::OptionalWithDefaultValue itemWidth, + Be::OptionalWithDefaultValue itemHeight ) { m_width = width; m_height = height; @@ -213,7 +213,7 @@ void Tr2ImpostorManager::SetItemSize( uint32_t width, uint32_t height ) // -------------------------------------------------------------------------------------- // Description: -// Resets the manager: deletes all billboards. +// Resets the manager: deletes all billboards. // -------------------------------------------------------------------------------------- void Tr2ImpostorManager::Reset() { @@ -340,7 +340,7 @@ void Tr2ImpostorManager::EndUpdate() Tr2Variable altas( "ImposterAtlasMap", m_rt ); Vector4 itemSize( float( m_itemWidth ) / float( m_width ), float( m_itemHeight ) / float( m_height ), 0.f, 0.f ); Tr2Variable itemSizeVar( "ImposterItemSize", itemSize ); -} +} // -------------------------------------------------------------------------------------- // Description: @@ -356,7 +356,7 @@ size_t Tr2ImpostorManager::GetRenderQueueLength() const // -------------------------------------------------------------------------------------- // Description: -// Static comparison of impostor rendering priorities used for sorting. +// Static comparison of impostor rendering priorities used for sorting. // Arguments: // item1 - First impostor // item2 - Second impostor @@ -374,7 +374,7 @@ bool Tr2ImpostorManager::CompareImpostors( const std::pair& batches ) = 0; // Evaluates rendering priority based on current and old hashes virtual float GetRenderPriority( const ImpostorHash& oldHash, const ImpostorHash& newHash ) const = 0; // Returns object bounding sphere - virtual bool GetImpostorBoundingSphere( Vector4& sphere ) const = 0; + virtual bool GetImpostorBoundingSphere( Vector4 & sphere ) const = 0; // Returns object last frame bounding sphere virtual void GetLastImpostorBoundingSphere( Vector4 & sphere ) const = 0; }; @@ -43,7 +43,7 @@ BLUE_INTERFACE( ITr2ImpostorSource ) // -------------------------------------------------------------------------------------- // Description: -// Tr2ImpostorManager class manages impostor billboards for objects. It uses quad +// Tr2ImpostorManager class manages impostor billboards for objects. It uses quad // renderer to render billboards. Its usage is roughly the following: // BeginUpdate() // Add() ... Add() ... @@ -57,7 +57,8 @@ BLUE_INTERFACE( ITr2ImpostorSource ) // See Also: // Tr2QuadRenderer // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2DeviceResource +BLUE_CLASS( Tr2ImpostorManager ) : + public IInitialize, public INotify, public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); @@ -66,19 +67,19 @@ BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2 virtual bool Initialize(); - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); virtual void ReleaseResources( TriStorage s ); - void Create( - Be::OptionalWithDefaultValue width, - Be::OptionalWithDefaultValue height, - Be::OptionalWithDefaultValue itemWidth, + void Create( + Be::OptionalWithDefaultValue width, + Be::OptionalWithDefaultValue height, + Be::OptionalWithDefaultValue itemWidth, Be::OptionalWithDefaultValue itemHeigh ); void SetItemSize( uint32_t width, uint32_t height ); - bool Add( ITr2ImpostorSource* object, const ITr2ImpostorSource::ImpostorHash& hash ); + bool Add( ITr2ImpostorSource * object, const ITr2ImpostorSource::ImpostorHash& hash ); void BeginUpdate(); void EndUpdate(); @@ -87,8 +88,8 @@ BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2 void Render() const; - void BeginUpdateAtlas( Tr2RenderContext& renderContext ); - void EndUpdateAtlas( Tr2RenderContext& renderContext ); + void BeginUpdateAtlas( Tr2RenderContext & renderContext ); + void EndUpdateAtlas( Tr2RenderContext & renderContext ); ITr2ImpostorSource* BeginImpostorUpdate( size_t index, Tr2RenderContext& renderContext ); void EndImpostorUpdate( size_t index, Tr2RenderContext& renderContext ); @@ -98,7 +99,7 @@ BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2 Tr2DepthStencil* GetItemDepthStencil() const; size_t GetImpostorCount() const; - + private: // Per-impostor data struct Impostor @@ -125,6 +126,7 @@ BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2 void Resize( uint32_t width, uint32_t height, uint32_t itemWidth, uint32_t itemHeight ); bool Reserve( Vector2_16& coord ); void Drop( Vector2_16 coord ); + private: // Free (unoccupied) texcoords TrackableStdVector m_free; @@ -163,7 +165,7 @@ BLUE_CLASS( Tr2ImpostorManager ): public IInitialize, public INotify, public Tr2 std::unordered_map m_objects; // Queue of objects to re-render in current frame std::vector m_renderQueue; - + bool m_atlasDirty; }; diff --git a/trinity/Tr2ImpostorManager_Blue.cpp b/trinity/Tr2ImpostorManager_Blue.cpp index 4bc815914..7af17999e 100644 --- a/trinity/Tr2ImpostorManager_Blue.cpp +++ b/trinity/Tr2ImpostorManager_Blue.cpp @@ -23,15 +23,14 @@ const Be::ClassInfo* Tr2ImpostorManager::ExposeToBlue() MAP_ATTRIBUTE( "effect", m_effect, "Effect used to render impostors", Be::READ ); MAP_PROPERTY_READONLY( "count", GetImpostorCount, "Current number of impostors" ); - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - Create, - 4, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + Create, + 4, "Creates the manager.\n" ":param width: optional atlas width\n" ":param height: optional atlas height\n" ":param itemWidth: optional billboard width\n" - ":param itemHeight: optional billboard width" - ); + ":param itemHeight: optional billboard width" ); EXPOSURE_END() } diff --git a/trinity/Tr2IndirectDrawBuffer.cpp b/trinity/Tr2IndirectDrawBuffer.cpp index d56d6ac9e..576e451f2 100644 --- a/trinity/Tr2IndirectDrawBuffer.cpp +++ b/trinity/Tr2IndirectDrawBuffer.cpp @@ -6,12 +6,13 @@ #include "../trinityal/metal/Tr2ShaderProgramALMetal.h" -CCP_STATS_DECLARE( sceneExecuteIndirectCount, "Trinity/AL/sceneExecuteIndirectCount", true, CST_COUNTER_LOW, "Number of ExecuteIndirect calls." ); -CCP_STATS_DECLARE( sceneIndirectDrawCount , "Trinity/AL/sceneIndirectDrawCount" , true, CST_COUNTER_LOW, "Number of indirect draw calls." ); +CCP_STATS_DECLARE( sceneExecuteIndirectCount, "Trinity/AL/sceneExecuteIndirectCount", true, CST_COUNTER_LOW, "Number of ExecuteIndirect calls." ); +CCP_STATS_DECLARE( sceneIndirectDrawCount, "Trinity/AL/sceneIndirectDrawCount", true, CST_COUNTER_LOW, "Number of indirect draw calls." ); Tr2IndirectDrawBufferLayout::Tr2IndirectDrawBufferLayout( const Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ) #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - :m_shaderProgram( program ) + : + m_shaderProgram( program ) #endif { #if TRINITY_PLATFORM == TRINITY_DIRECTX12 @@ -41,11 +42,11 @@ Tr2IndirectDrawBufferLayout::Tr2IndirectDrawBufferLayout( const Tr2ShaderProgram } } #elif TRINITY_PLATFORM == TRINITY_METAL - auto masks = program.TrinityALImpl_GetObject()->GetResourceMasks(); - m_hasMaterialData[0] = masks[Tr2RenderContextEnum::VERTEX_SHADER].constantBufferMask & ( 1 << METAL_CONST_BUFFER_OFFSET ); - m_hasMaterialData[1] = masks[Tr2RenderContextEnum::PIXEL_SHADER].constantBufferMask & ( 1 << METAL_CONST_BUFFER_OFFSET ); - m_hasPerObjectData[0] = masks[Tr2RenderContextEnum::VERTEX_SHADER].constantBufferMask & ( 1 << ( METAL_CONST_BUFFER_OFFSET + Tr2Renderer::GetPerObjectVSStartRegister() ) ); - m_hasPerObjectData[1] = masks[Tr2RenderContextEnum::PIXEL_SHADER].constantBufferMask & ( 1 << ( METAL_CONST_BUFFER_OFFSET + Tr2Renderer::GetPerObjectPSStartRegister() ) ); + auto masks = program.TrinityALImpl_GetObject()->GetResourceMasks(); + m_hasMaterialData[0] = masks[Tr2RenderContextEnum::VERTEX_SHADER].constantBufferMask & ( 1 << METAL_CONST_BUFFER_OFFSET ); + m_hasMaterialData[1] = masks[Tr2RenderContextEnum::PIXEL_SHADER].constantBufferMask & ( 1 << METAL_CONST_BUFFER_OFFSET ); + m_hasPerObjectData[0] = masks[Tr2RenderContextEnum::VERTEX_SHADER].constantBufferMask & ( 1 << ( METAL_CONST_BUFFER_OFFSET + Tr2Renderer::GetPerObjectVSStartRegister() ) ); + m_hasPerObjectData[1] = masks[Tr2RenderContextEnum::PIXEL_SHADER].constantBufferMask & ( 1 << ( METAL_CONST_BUFFER_OFFSET + Tr2Renderer::GetPerObjectPSStartRegister() ) ); #endif } @@ -59,53 +60,53 @@ Tr2IndirectDrawBufferWriter::Tr2IndirectDrawBufferWriter( Tr2IndirectDrawBuffer& m_allocation = buffer.Allocate( layout.m_stride * commands ); m_buffer = static_cast( m_allocation.address ); #elif TRINITY_PLATFORM == TRINITY_METAL - m_allocation = buffer.Allocate( commands ); - m_buffer = m_allocation.address; + m_allocation = buffer.Allocate( commands ); + m_buffer = m_allocation.address; #endif } void Tr2IndirectDrawBufferWriter::SetMaterialConstants( Tr2RenderContextEnum::ShaderType stage, const Tr2ConstantBufferAL& buffer ) { - if( !HasMaterialConstants( stage ) ) - { - return; - } + if( !HasMaterialConstants( stage ) ) + { + return; + } #if TRINITY_PLATFORM == TRINITY_DIRECTX12 auto addr = m_renderContext.UploadConstants( buffer ); *reinterpret_cast( m_buffer + m_layout.m_materialOffsets[stage] ) = addr; #elif TRINITY_PLATFORM == TRINITY_METAL - auto addr = m_renderContext.UploadConstants( buffer ); - m_buffer->material[stage] = addr; + auto addr = m_renderContext.UploadConstants( buffer ); + m_buffer->material[stage] = addr; #endif } void Tr2IndirectDrawBufferWriter::SetPerObjectData( Tr2RenderContextEnum::ShaderType stage, const Tr2ConstantBufferAL& buffer ) { - if( !HasPerObjectData( stage ) ) - { - return; - } + if( !HasPerObjectData( stage ) ) + { + return; + } #if TRINITY_PLATFORM == TRINITY_DIRECTX12 auto addr = m_renderContext.UploadConstants( buffer ); *reinterpret_cast( m_buffer + m_layout.m_perObjectDataOffsets[stage] ) = addr; #elif TRINITY_PLATFORM == TRINITY_METAL - auto addr = m_renderContext.UploadConstants( buffer ); - m_buffer->perObject[stage] = addr; + auto addr = m_renderContext.UploadConstants( buffer ); + m_buffer->perObject[stage] = addr; #endif } void Tr2IndirectDrawBufferWriter::SetPerObjectData( Tr2RenderContextEnum::ShaderType stage, const void* data, size_t size ) { - if( !HasPerObjectData( stage ) ) - { - return; - } + if( !HasPerObjectData( stage ) ) + { + return; + } #if TRINITY_PLATFORM == TRINITY_DIRECTX12 auto addr = m_renderContext.UploadConstants( data, uint32_t( size ) ); *reinterpret_cast( m_buffer + m_layout.m_perObjectDataOffsets[stage] ) = addr; #elif TRINITY_PLATFORM == TRINITY_METAL - auto addr = m_renderContext.UploadConstants( data, size ); - m_buffer->perObject[stage] = addr; + auto addr = m_renderContext.UploadConstants( data, size ); + m_buffer->perObject[stage] = addr; #endif } @@ -115,11 +116,11 @@ void Tr2IndirectDrawBufferWriter::DrawIndexed( uint32_t indexCountPerInstance, u D3D12_DRAW_INDEXED_ARGUMENTS args = { indexCountPerInstance, instanceCount, startIndexLocation, int32_t( baseVertexLocation ), startInstanceLocation }; *reinterpret_cast( m_buffer + m_layout.m_drawOffset ) = args; #elif TRINITY_PLATFORM == TRINITY_METAL - m_buffer->indexCountPerInstance = indexCountPerInstance; - m_buffer->instanceCount = instanceCount; - m_buffer->startIndexLocation = startIndexLocation; - m_buffer->baseVertexLocation = baseVertexLocation; - m_buffer->startInstanceLocation = startInstanceLocation; + m_buffer->indexCountPerInstance = indexCountPerInstance; + m_buffer->instanceCount = instanceCount; + m_buffer->startIndexLocation = startIndexLocation; + m_buffer->baseVertexLocation = baseVertexLocation; + m_buffer->startInstanceLocation = startInstanceLocation; #endif } @@ -129,8 +130,8 @@ void Tr2IndirectDrawBufferWriter::Next() m_buffer += m_layout.m_stride; ++m_commandCount; #elif TRINITY_PLATFORM == TRINITY_METAL - m_buffer++; - ++m_commandCount; + m_buffer++; + ++m_commandCount; #endif } @@ -139,7 +140,7 @@ bool Tr2IndirectDrawBufferWriter::HasMaterialConstants( Tr2RenderContextEnum::Sh #if TRINITY_PLATFORM == TRINITY_DIRECTX12 return m_layout.m_materialOffsets[stage] != 0xffffffff; #elif TRINITY_PLATFORM == TRINITY_METAL - return m_layout.m_hasMaterialData[stage]; + return m_layout.m_hasMaterialData[stage]; #else return false; #endif @@ -150,7 +151,7 @@ bool Tr2IndirectDrawBufferWriter::HasPerObjectData( Tr2RenderContextEnum::Shader #if TRINITY_PLATFORM == TRINITY_DIRECTX12 return m_layout.m_perObjectDataOffsets[stage] != 0xffffffff; #elif TRINITY_PLATFORM == TRINITY_METAL - return m_layout.m_hasPerObjectData[stage]; + return m_layout.m_hasPerObjectData[stage]; #else return false; #endif @@ -175,7 +176,7 @@ bool Tr2IndirectDrawBuffer::IsValid() const #if TRINITY_PLATFORM == TRINITY_DIRECTX12 return m_uploadBuffer != nullptr; #elif TRINITY_PLATFORM == TRINITY_METAL - return true; + return true; #else return false; #endif @@ -186,7 +187,7 @@ void Tr2IndirectDrawBuffer::Create( uint32_t size ) #if TRINITY_PLATFORM == TRINITY_DIRECTX12 Resize( size ); #elif TRINITY_PLATFORM == TRINITY_METAL - m_pageSize = size; + m_pageSize = size; #endif } @@ -242,19 +243,18 @@ Tr2IndirectDrawBuffer::Allocation Tr2IndirectDrawBuffer::Allocate( uint32_t size return { buffer, m_cpuAddr, result }; #elif TRINITY_PLATFORM == TRINITY_METAL - if( m_pageOffset + size >= m_pageSize ) - { - ++m_page; - m_pageOffset = 0; - } - if( m_page >= m_pages.size() ) - { - m_pages.push_back( std::unique_ptr( new DP[m_pageSize])); - - } - auto buffer = m_pages[m_page].get() + m_pageOffset; - m_pageOffset += size; - return { buffer }; + if( m_pageOffset + size >= m_pageSize ) + { + ++m_page; + m_pageOffset = 0; + } + if( m_page >= m_pages.size() ) + { + m_pages.push_back( std::unique_ptr( new DP[m_pageSize] ) ); + } + auto buffer = m_pages[m_page].get() + m_pageOffset; + m_pageOffset += size; + return { buffer }; #else return {}; #endif @@ -268,7 +268,7 @@ void Tr2IndirectDrawBuffer::CopyArguments() #if TRINITY_PLATFORM == TRINITY_DIRECTX12 USE_MAIN_THREAD_RENDER_CONTEXT(); - + /* * Because we use a ring buffer for the arguments, we get a discontinuity in the copies * if we end up wrapping around. This code batches the copy operations into up to 2 @@ -376,8 +376,8 @@ void Tr2IndirectDrawBuffer::SetFrameNumbers( uint64_t recordingFrame, uint64_t c } } #elif TRINITY_PLATFORM == TRINITY_METAL - m_page = 0; - m_pageOffset = 0; + m_page = 0; + m_pageOffset = 0; #endif } @@ -392,90 +392,90 @@ void Tr2IndirectDrawBuffer::Submit( const Tr2IndirectDrawBufferWriter& writer ) CCP_STATS_ADD( sceneIndirectDrawCount, writer.m_commandCount ); } #elif TRINITY_PLATFORM == TRINITY_METAL - - auto encoder = writer.m_renderContext.GetMetalWorkQueue()->GetRenderEncoder(); - if( writer.m_renderContext.GetMetalWorkQueue()->EmitRenderEncoderState() ) - { - auto& allocator = writer.m_renderContext.GetMetalContext()->GetConstantBufferAllocator(); - auto& layout = writer.m_layout; - auto perObjectVS = Tr2Renderer::GetPerObjectVSStartRegister(); - auto perObjectPS = Tr2Renderer::GetPerObjectPSStartRegister(); - auto materialPageVS = 0xffffffff; - auto materialPagePS = 0xffffffff; - auto perObjectPageVS = 0xffffffff; - auto perObjectPagePS = 0xffffffff; - - for( uint32_t i = 0; i < writer.m_commandCount; ++i ) - { - auto& dp = writer.m_allocation.address[i]; - if( layout.m_hasMaterialData[0] ) - { - auto page = uint32_t( dp.material[0] >> 32 ); - auto offset = uint32_t( dp.material[0] & 0xffffffff ); - if( page != materialPageVS ) - { - [encoder setVertexBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; - materialPageVS = page; - } - else - { - [encoder setVertexBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; - } - } - if( layout.m_hasPerObjectData[0] ) - { - auto page = uint32_t( dp.perObject[0] >> 32 ); - auto offset = uint32_t( dp.perObject[0] & 0xffffffff ); - if( page != perObjectPageVS ) - { - [encoder setVertexBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectVS]; - perObjectPageVS = page; - } - else - { - [encoder setVertexBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectVS]; - } - } - if( layout.m_hasMaterialData[1] ) - { - auto page = uint32_t( dp.material[1] >> 32 ); - auto offset = uint32_t( dp.material[1] & 0xffffffff ); - if( page != materialPagePS ) - { - [encoder setFragmentBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; - materialPagePS = page; - } - else - { - [encoder setFragmentBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; - } - } - if( layout.m_hasPerObjectData[1] ) - { - auto page = uint32_t( dp.perObject[1] >> 32 ); - auto offset = uint32_t( dp.perObject[1] & 0xffffffff ); - if( page != perObjectPagePS ) - { - [encoder setFragmentBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectPS]; - perObjectPagePS = page; - } - else - { - [encoder setFragmentBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectPS]; - } - } - [encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle - indexCount:dp.indexCountPerInstance - indexType:writer.m_renderContext.m_metalIndexType - indexBuffer:writer.m_renderContext.m_metalIndexBuffer - indexBufferOffset:dp.startIndexLocation * ( writer.m_renderContext.m_metalIndexType == MTLIndexTypeUInt16 ? 2 : 4 ) - instanceCount:dp.instanceCount - baseVertex:dp.baseVertexLocation - baseInstance:dp.startInstanceLocation]; - } - writer.m_renderContext.GetMetalWorkQueue()->MarkConstantBuffersDirty(); - } - writer.m_renderContext.GetMetalWorkQueue()->ReleaseEncoder( false ); + + auto encoder = writer.m_renderContext.GetMetalWorkQueue()->GetRenderEncoder(); + if( writer.m_renderContext.GetMetalWorkQueue()->EmitRenderEncoderState() ) + { + auto& allocator = writer.m_renderContext.GetMetalContext()->GetConstantBufferAllocator(); + auto& layout = writer.m_layout; + auto perObjectVS = Tr2Renderer::GetPerObjectVSStartRegister(); + auto perObjectPS = Tr2Renderer::GetPerObjectPSStartRegister(); + auto materialPageVS = 0xffffffff; + auto materialPagePS = 0xffffffff; + auto perObjectPageVS = 0xffffffff; + auto perObjectPagePS = 0xffffffff; + + for( uint32_t i = 0; i < writer.m_commandCount; ++i ) + { + auto& dp = writer.m_allocation.address[i]; + if( layout.m_hasMaterialData[0] ) + { + auto page = uint32_t( dp.material[0] >> 32 ); + auto offset = uint32_t( dp.material[0] & 0xffffffff ); + if( page != materialPageVS ) + { + [encoder setVertexBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; + materialPageVS = page; + } + else + { + [encoder setVertexBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; + } + } + if( layout.m_hasPerObjectData[0] ) + { + auto page = uint32_t( dp.perObject[0] >> 32 ); + auto offset = uint32_t( dp.perObject[0] & 0xffffffff ); + if( page != perObjectPageVS ) + { + [encoder setVertexBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectVS]; + perObjectPageVS = page; + } + else + { + [encoder setVertexBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectVS]; + } + } + if( layout.m_hasMaterialData[1] ) + { + auto page = uint32_t( dp.material[1] >> 32 ); + auto offset = uint32_t( dp.material[1] & 0xffffffff ); + if( page != materialPagePS ) + { + [encoder setFragmentBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; + materialPagePS = page; + } + else + { + [encoder setFragmentBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET]; + } + } + if( layout.m_hasPerObjectData[1] ) + { + auto page = uint32_t( dp.perObject[1] >> 32 ); + auto offset = uint32_t( dp.perObject[1] & 0xffffffff ); + if( page != perObjectPagePS ) + { + [encoder setFragmentBuffer:allocator.GetPage( page ) offset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectPS]; + perObjectPagePS = page; + } + else + { + [encoder setFragmentBufferOffset:offset atIndex:METAL_CONST_BUFFER_OFFSET + perObjectPS]; + } + } + [encoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle + indexCount:dp.indexCountPerInstance + indexType:writer.m_renderContext.m_metalIndexType + indexBuffer:writer.m_renderContext.m_metalIndexBuffer + indexBufferOffset:dp.startIndexLocation * ( writer.m_renderContext.m_metalIndexType == MTLIndexTypeUInt16 ? 2 : 4 ) + instanceCount:dp.instanceCount + baseVertex:dp.baseVertexLocation + baseInstance:dp.startInstanceLocation]; + } + writer.m_renderContext.GetMetalWorkQueue()->MarkConstantBuffersDirty(); + } + writer.m_renderContext.GetMetalWorkQueue()->ReleaseEncoder( false ); #endif } @@ -486,12 +486,12 @@ void Tr2IndirectDrawBuffer::ReleaseResources( TriStorage s ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - if (m_uploadBuffer) + if( m_uploadBuffer ) { renderContext.ReleaseLater( m_uploadBuffer ); m_uploadBuffer = nullptr; } - if (m_defaultBuffer) + if( m_defaultBuffer ) { renderContext.ReleaseLater( m_defaultBuffer ); m_defaultBuffer = nullptr; @@ -521,7 +521,7 @@ void Tr2IndirectDrawBuffer::Resize( uint32_t newSize ) if( m_uploadBuffer ) { //Make sure we copy all pending arguments before we release them! - CopyArguments(); + CopyArguments(); renderContext.ReleaseLater( m_uploadBuffer ); m_uploadBuffer = nullptr; @@ -537,7 +537,7 @@ void Tr2IndirectDrawBuffer::Resize( uint32_t newSize ) D3D12_HEAP_PROPERTIES heap = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 1, 1 }; D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER, 0, UINT64( newSize ), 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_NONE }; - HRESULT result = renderContext.m_device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&uploadBuffer)); + HRESULT result = renderContext.m_device->CreateCommittedResource( &heap, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS( &uploadBuffer ) ); if( FAILED( result ) ) { CCP_LOGERR( "Failed to create indirect draw upload buffer (hr=0x%x)", result ); @@ -545,14 +545,14 @@ void Tr2IndirectDrawBuffer::Resize( uint32_t newSize ) } D3D12_RANGE range = { 0, 0 }; - uploadBuffer->Map(0, &range, (void**)&m_cpuAddr); + uploadBuffer->Map( 0, &range, (void**)&m_cpuAddr ); } { D3D12_HEAP_PROPERTIES heap = { D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 1, 1 }; D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER, 0, UINT64( newSize ), 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_NONE }; - HRESULT result = renderContext.m_device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, nullptr, IID_PPV_ARGS(&defaultBuffer)); + HRESULT result = renderContext.m_device->CreateCommittedResource( &heap, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT, nullptr, IID_PPV_ARGS( &defaultBuffer ) ); if( FAILED( result ) ) { CCP_LOGERR( "Failed to create indirect draw buffer (hr=0x%x)", result ); diff --git a/trinity/Tr2IndirectDrawBuffer.h b/trinity/Tr2IndirectDrawBuffer.h index 4e5412434..86ae49bc2 100644 --- a/trinity/Tr2IndirectDrawBuffer.h +++ b/trinity/Tr2IndirectDrawBuffer.h @@ -17,8 +17,8 @@ struct Tr2IndirectDrawBufferLayout uint32_t m_drawOffset = 0; uint32_t m_stride = 0; #elif TRINITY_PLATFORM == TRINITY_METAL - bool m_hasMaterialData[2]; - bool m_hasPerObjectData[2]; + bool m_hasMaterialData[2]; + bool m_hasPerObjectData[2]; #endif }; @@ -38,26 +38,26 @@ class Tr2IndirectDrawBuffer : public Tr2DeviceResource void Create( uint32_t size ); #if TRINITY_PLATFORM == TRINITY_METAL - struct DP - { - uint64_t material[2]; - uint64_t perObject[2]; - uint32_t indexCountPerInstance; - uint32_t instanceCount; - uint32_t startIndexLocation; - uint32_t baseVertexLocation; - uint32_t startInstanceLocation; - }; + struct DP + { + uint64_t material[2]; + uint64_t perObject[2]; + uint32_t indexCountPerInstance; + uint32_t instanceCount; + uint32_t startIndexLocation; + uint32_t baseVertexLocation; + uint32_t startInstanceLocation; + }; #endif struct Allocation { #if TRINITY_PLATFORM == TRINITY_DIRECTX12 CComPtr buffer; - void* baseAddress; - void* address; + void* baseAddress; + void* address; #elif TRINITY_PLATFORM == TRINITY_METAL - DP* address; + DP* address; #endif }; Allocation Allocate( uint32_t size ); @@ -92,10 +92,10 @@ class Tr2IndirectDrawBuffer : public Tr2DeviceResource std::vector m_regions; #elif TRINITY_PLATFORM == TRINITY_METAL - std::vector> m_pages; - uint32_t m_page = 0; - uint32_t m_pageOffset = 0; - uint32_t m_pageSize = 1024; + std::vector> m_pages; + uint32_t m_page = 0; + uint32_t m_pageOffset = 0; + uint32_t m_pageSize = 1024; #endif }; @@ -123,8 +123,8 @@ class Tr2IndirectDrawBufferWriter Tr2IndirectDrawBuffer::Allocation m_allocation; uint8_t* m_buffer; #elif TRINITY_PLATFORM == TRINITY_METAL - Tr2IndirectDrawBuffer::Allocation m_allocation; - Tr2IndirectDrawBuffer::DP* m_buffer; + Tr2IndirectDrawBuffer::Allocation m_allocation; + Tr2IndirectDrawBuffer::DP* m_buffer; #endif friend class Tr2IndirectDrawBuffer; }; diff --git a/trinity/Tr2InstancedMesh.cpp b/trinity/Tr2InstancedMesh.cpp index 8653b76cf..5c6475ca3 100644 --- a/trinity/Tr2InstancedMesh.cpp +++ b/trinity/Tr2InstancedMesh.cpp @@ -14,10 +14,10 @@ CCP_STATS_DECLARED_ELSEWHERE( sceneDrawcallCount ); CCP_STATS_DECLARE( instancesRendered, "Trinity/instancesRendered", true, CST_COUNTER_HIGH, "Number of instances rendered with Tr2InstancedMesh" ); #if CCP_STATS_ENABLED -# define CCP_STATS_INC_PTR( name ) g_ccpStatistics_##name->Inc() +#define CCP_STATS_INC_PTR( name ) g_ccpStatistics_##name->Inc() // Allow external code (such as shadow cubemap) to change the counter used for counting draw calls, // so we get more refined results than just one scene-wide "you had this many drawcalls in the _entire_ frame". -extern CcpStaticStatisticsEntry * g_ccpStatistics_drawcallCount; +extern CcpStaticStatisticsEntry* g_ccpStatistics_drawcallCount; #else #define CCP_STATS_INC_PTR( name ) #endif @@ -28,8 +28,8 @@ extern bool g_brokenMacOSNvidiaDrivers; // Description: // Tr2InstancedMesh default constructor // -------------------------------------------------------------------------------------- -Tr2InstancedMesh::Tr2InstancedMesh( IRoot* lockobj ) - :Tr2Mesh( lockobj ), +Tr2InstancedMesh::Tr2InstancedMesh( IRoot* lockobj ) : + Tr2Mesh( lockobj ), m_instanceMeshIndex( 0 ), m_vertexDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_instanceDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), @@ -51,7 +51,7 @@ Tr2InstancedMesh::~Tr2InstancedMesh() // -------------------------------------------------------------------------------------- // Description: -// Implements IInitialize interface. Starts loading instance geometry resource if +// Implements IInitialize interface. Starts loading instance geometry resource if // mesh has non-empty path and loading is not deferred. Also initializes Tr2Mesh. // Return Value: // true If initialization is successfull @@ -94,9 +94,9 @@ bool Tr2InstancedMesh::OnPrepareResources() // -------------------------------------------------------------------------------------- // Description: -// Implements INotify interface. Allows the mesh to respond to parameter +// Implements INotify interface. Allows the mesh to respond to parameter // changes generated in Python. Loads instance geometry resource when geometry path -// is modified or when deferred flag is reset. Passes control to Tr2Mesh. +// is modified or when deferred flag is reset. Passes control to Tr2Mesh. // Arguments: // value - The Blue-exposed parameter that changed // Return Value: @@ -137,7 +137,7 @@ bool Tr2InstancedMesh::OnModified( Be::Var* value ) // -------------------------------------------------------------------------------------- // Description: -// Implements IAsyncLoadedResNotifyTarget interface. Resets combined vertex +// Implements IAsyncLoadedResNotifyTarget interface. Resets combined vertex // declarations. // Arguments: // p - Resource that being unloaded @@ -150,7 +150,7 @@ void Tr2InstancedMesh::ReleaseCachedData( BlueAsyncRes* p ) // -------------------------------------------------------------------------------------- // Description: -// Implements IAsyncLoadedResNotifyTarget interface. Creates combined vertex +// Implements IAsyncLoadedResNotifyTarget interface. Creates combined vertex // declarations when geometry is loaded. // Arguments: // p - Resource that being loaded @@ -172,13 +172,13 @@ ITr2InstanceData* Tr2InstancedMesh::GetInstanceGeometryResource() const // -------------------------------------------------------------------------------------- // Description: -// Set a new instance geometry path from the outside. This will trigger an initialize +// Set a new instance geometry path from the outside. This will trigger an initialize // of the new geometry resource! // Arguments: // path - gr2 res path // -------------------------------------------------------------------------------------- void Tr2InstancedMesh::SetInstanceMeshResPath( const char* path ) -{ +{ m_instanceGeometryResPath = path; // trigger change, this will automatically be triggered when set through python @@ -222,7 +222,7 @@ void Tr2InstancedMesh::GetBatches( ITriRenderBatchAccumulator* batches, void Tr2InstancedMesh::GetBatches( ITriRenderBatchAccumulator* batches, const Tr2MeshAreaVector* areas, const Tr2PerObjectData* data, - float screenSize, + float screenSize, bool reverseAreas ) const { if( !GetDisplay() || g_brokenMacOSNvidiaDrivers ) @@ -268,7 +268,7 @@ void Tr2InstancedMesh::GetBatches( ITriRenderBatchAccumulator* batches, { Tr2MeshArea* area = *it; - if( !area->GetDisplay()) + if( !area->GetDisplay() ) { continue; } @@ -344,7 +344,7 @@ CcpMath::AxisAlignedBox Tr2InstancedMesh::GetBounds( const Matrix* boneTransform { return aabb; } - + auto instanceSize = m_maxInstanceSize; if( m_boundsMethod == DYNAMIC_SCALED ) { @@ -382,21 +382,20 @@ CcpMath::Sphere Tr2InstancedMesh::GetInstanceBoundsClosestToPoint( const Vector3 { case Tr2InstancedMesh::DYNAMIC: break; - case Tr2InstancedMesh::DYNAMIC_SCALED: - { - float radius = 0; - GetInstanceBounds().EnumerateVertices( [&radius]( const Vector3& vtx ) { - radius = std::max( radius, LengthSq( vtx ) ); - } ); - instanceSize *= sqrt( radius ); - break; - } + case Tr2InstancedMesh::DYNAMIC_SCALED: { + float radius = 0; + GetInstanceBounds().EnumerateVertices( [&radius]( const Vector3& vtx ) { + radius = std::max( radius, LengthSq( vtx ) ); + } ); + instanceSize *= sqrt( radius ); + break; + } default: return {}; } auto outerBounds = GetBounds(); outerBounds.Grow( -instanceSize ); - + Vector3 closestPoint = ClosestPointToBoundingBox( outerBounds.m_min, outerBounds.m_max, point ); return CcpMath::Sphere( closestPoint, instanceSize ); @@ -462,16 +461,16 @@ static bool GetMeshVertexDeclaration( TriGeometryRes* geometryRes, int meshIndex // -------------------------------------------------------------------------------------- // Description: // Combines two vertex declarations into a single multi-stream declaration. Usage indexes -// for instanced declaration are shifted by 8, so shader would expect POSITION8, etc. +// for instanced declaration are shifted by 8, so shader would expect POSITION8, etc. // for instance data. // Arguments: -// meshVD - Vertex definition of the base mesh -// instanceVD - Vertex definition of the instance data +// meshVD - Vertex definition of the base mesh +// instanceVD - Vertex definition of the instance data // Return value: // Handle for combined vertex definition (renderContext version) or Tr2EffectStateManager:: // UNINITIALIZED_DECLARATION on failure // -------------------------------------------------------------------------------------- -static unsigned int MergeVertexDeclarations( const Tr2VertexDefinition& meshVD, +static unsigned int MergeVertexDeclarations( const Tr2VertexDefinition& meshVD, const Tr2VertexDefinition& instanceVD ) { const unsigned usageOffset = 8; @@ -497,7 +496,7 @@ static unsigned int MergeVertexDeclarations( const Tr2VertexDefinition& meshVD, // -------------------------------------------------------------------------------------- // Description: -// Creates a combined vertex declaration for base mesh and instance data. +// Creates a combined vertex declaration for base mesh and instance data. // -------------------------------------------------------------------------------------- void Tr2InstancedMesh::CreateVertexDeclaration() const { @@ -508,7 +507,7 @@ void Tr2InstancedMesh::CreateVertexDeclaration() const { return; } - + if( !GetInstanceGeometryResource() || !GetInstanceGeometryResource()->IsInstanceDataReady() ) { return; @@ -553,7 +552,7 @@ void Tr2InstancedMesh::RenderDebugInfo( const Matrix& worldTransform, ITr2DebugR } else { - auto parentBounds = GetBounds(); + auto parentBounds = GetBounds(); if( parentBounds ) { if( m_instanceGeometryResource ) @@ -567,7 +566,6 @@ void Tr2InstancedMesh::RenderDebugInfo( const Matrix& worldTransform, ITr2DebugR } renderer.DrawBox( this, worldTransform, parentBounds.m_min, parentBounds.m_max, Tr2DebugRenderer::Wireframe, Tr2DebugColor( 0xff888888, 0x22888888 ) ); } - } } } diff --git a/trinity/Tr2InstancedMesh.h b/trinity/Tr2InstancedMesh.h index 478b20ff5..9157df723 100644 --- a/trinity/Tr2InstancedMesh.h +++ b/trinity/Tr2InstancedMesh.h @@ -19,7 +19,7 @@ BLUE_DECLARE_INTERFACE( ITr2GpuBuffer ); // See Also: // Tr2Mesh // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2InstancedMesh ): +BLUE_CLASS( Tr2InstancedMesh ) : public Tr2Mesh, public Tr2DeviceResource { @@ -42,16 +42,21 @@ BLUE_CLASS( Tr2InstancedMesh ): ///////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: + +public: #if TRINITYDEV - void GetDescription( std::string& desc ) { desc = "Tr2InstancedMesh"; } + void GetDescription( std::string & desc ) + { + desc = "Tr2InstancedMesh"; + } #endif ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -59,20 +64,26 @@ BLUE_CLASS( Tr2InstancedMesh ): ///////////////////////////////////////////////////////////////////////////////////// // IAsyncLoadedResNotifyTarget - void ReleaseCachedData( BlueAsyncRes* p ); - void RebuildCachedData( BlueAsyncRes* p ); + void ReleaseCachedData( BlueAsyncRes * p ); + void RebuildCachedData( BlueAsyncRes * p ); ///////////////////////////////////////////////////////////////////////////////////// // Tr2Mesh - const char* GetInstanceMeshResPath() { return m_instanceGeometryResPath.c_str(); } + const char* GetInstanceMeshResPath() + { + return m_instanceGeometryResPath.c_str(); + } void SetInstanceMeshResPath( const char* path ); - int GetInstanceMeshIndex() const { return m_instanceMeshIndex; }; + int GetInstanceMeshIndex() const + { + return m_instanceMeshIndex; + }; ITr2InstanceData* GetInstanceGeometryResource() const; - void SetInstanceGeometryRes( ITr2InstanceData* res ); + void SetInstanceGeometryRes( ITr2InstanceData * res ); - void GetBatches( ITriRenderBatchAccumulator* batches, - const Tr2MeshAreaVector* areas, + void GetBatches( ITriRenderBatchAccumulator * batches, + const Tr2MeshAreaVector* areas, const Tr2PerObjectData* data, float screenSize = std::numeric_limits::max() ) const override; @@ -85,13 +96,13 @@ BLUE_CLASS( Tr2InstancedMesh ): CcpMath::AxisAlignedBox GetBounds( const Matrix* boneTransforms = nullptr, const int32_t* meshBindingIndices = nullptr, size_t boneCount = 0, const Tr2MorphTargetAnimationData* morphTargets = nullptr, size_t morphTargetsCount = 0 ) const override; CcpMath::AxisAlignedBox GetAreaBounds( unsigned int areaIx, const Matrix* boneTransforms = nullptr ) const override; - CcpMath::AxisAlignedBox GetInstanceBounds( ) const; + CcpMath::AxisAlignedBox GetInstanceBounds() const; CcpMath::Sphere GetInstanceBoundsClosestToPoint( const Vector3& point ) const; void SetBoundingBox( const Vector3& min, const Vector3& max ); bool IsLoading() const; - void GetDebugOptions( Tr2DebugRendererOptions& options ) override; + void GetDebugOptions( Tr2DebugRendererOptions & options ) override; void RenderDebugInfo( const Matrix& worldTransform, ITr2DebugRenderer2& renderer, const Matrix* boneTransforms = nullptr, const int32_t* meshBindingIndices = nullptr, size_t boneCount = 0, const Tr2MorphTargetAnimationData* morphTargets = nullptr, size_t morphTargetsCount = 0 ) override; void SetDynamicBounds( float maxInstanceSize ); @@ -100,7 +111,6 @@ BLUE_CLASS( Tr2InstancedMesh ): unsigned int GetVertexDeclaration() const; private: - void CreateVertexDeclaration() const; // Path to instance geometry resource diff --git a/trinity/Tr2InstancedMesh_Blue.cpp b/trinity/Tr2InstancedMesh_Blue.cpp index 29527169c..d8f6830a1 100644 --- a/trinity/Tr2InstancedMesh_Blue.cpp +++ b/trinity/Tr2InstancedMesh_Blue.cpp @@ -10,33 +10,30 @@ BLUE_DEFINE_INTERFACE( ITr2InstanceData ); namespace { - Be::VarChooser BoundsMethodChooser[] = - { - { "STATIC", BeCast( Tr2InstancedMesh::STATIC ), "Bounds are defined explicitely on the mesh" }, - { "DYNAMIC", BeCast( Tr2InstancedMesh::DYNAMIC ), "Bounds are defined by instance geometry and max instance size" }, - { "DYNAMIC_SCALED", BeCast( Tr2InstancedMesh::DYNAMIC_SCALED ), "Bounds are defined by instance geometry and max instance size; instance size is scaled by geometry size" }, - { 0 } - }; +Be::VarChooser BoundsMethodChooser[] = { + { "STATIC", BeCast( Tr2InstancedMesh::STATIC ), "Bounds are defined explicitely on the mesh" }, + { "DYNAMIC", BeCast( Tr2InstancedMesh::DYNAMIC ), "Bounds are defined by instance geometry and max instance size" }, + { "DYNAMIC_SCALED", BeCast( Tr2InstancedMesh::DYNAMIC_SCALED ), "Bounds are defined by instance geometry and max instance size; instance size is scaled by geometry size" }, + { 0 } +}; } BLUE_REGISTER_ENUM_EX( "Tr2InstanceMeshBoundsMethod", Tr2InstancedMesh::BoundsMethod, BoundsMethodChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); const Be::ClassInfo* Tr2InstancedMesh::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2InstancedMesh, "" ) + EXPOSURE_BEGIN( Tr2InstancedMesh, "" ) MAP_INTERFACE( Tr2InstancedMesh ) - MAP_ATTRIBUTE( "instanceGeometryResource", m_instanceGeometryResource, "na", Be::PERSISTONLY ) + MAP_ATTRIBUTE( "instanceGeometryResource", m_instanceGeometryResource, "na", Be::PERSISTONLY ) MAP_PROPERTY( "instanceGeometryResource", GetInstanceGeometryResource, SetInstanceGeometryRes, "na" ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "instanceGeometryResPath", - m_instanceGeometryResPath, - "Resource path to granny file containing instance data", - Be::READWRITE | Be::NOTIFY | Be::PERSIST, - TriGR2Chooser - ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "instanceGeometryResPath", + m_instanceGeometryResPath, + "Resource path to granny file containing instance data", + Be::READWRITE | Be::NOTIFY | Be::PERSIST, + TriGR2Chooser ) MAP_ATTRIBUTE( "instanceMeshIndex", m_instanceMeshIndex, "The index of the mesh within the instance granny file to use", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE_WITH_CHOOSER( "boundsMethod", m_boundsMethod, "Method for measuring mesh bounding box\n:jessica-group: Bounds", Be::READWRITE | Be::PERSIST | Be::ENUM, BoundsMethodChooser ) @@ -46,4 +43,3 @@ const Be::ClassInfo* Tr2InstancedMesh::ExposeToBlue() EXPOSURE_CHAINTO( Tr2Mesh ) } - diff --git a/trinity/Tr2KelvinColor.cpp b/trinity/Tr2KelvinColor.cpp index c90ac2760..f56d62cb4 100644 --- a/trinity/Tr2KelvinColor.cpp +++ b/trinity/Tr2KelvinColor.cpp @@ -24,9 +24,9 @@ Vector3d XYZToRGB( const Vector3d& xyz ) { // Using CIE 1931 (2-deg Standard Observer) return Vector3d( - 0.41866 * xyz.x - 0.15866 * xyz.y - 0.08283 * xyz.z, + 0.41866 * xyz.x - 0.15866 * xyz.y - 0.08283 * xyz.z, -0.09117 * xyz.x + 0.25243 * xyz.y + 0.01571 * xyz.z, - 0.00092 * xyz.x - 0.00255 * xyz.y + 0.17860 * xyz.z ); + 0.00092 * xyz.x - 0.00255 * xyz.y + 0.17860 * xyz.z ); } Vector2 Tr2StandardIlluminantToCCT( Tr2StandardIlluminant illuminant ) @@ -106,55 +106,55 @@ Vector3d TriColorFromKelvin( float temperature, float tint, Tr2StandardIlluminan return Vector3d( 0.0, 0.0, 0.0 ); } - + if( T >= 1000.0f && T <= 4000.0f ) { xc = -0.2661239 * ( 1000000000.0 / ( T * T * T ) ) - - 0.2343580 * ( 1000000.0 / ( T * T ) ) + - 0.8776956 * ( 1000.0 / T ) + - 0.179910; + 0.2343580 * ( 1000000.0 / ( T * T ) ) + + 0.8776956 * ( 1000.0 / T ) + + 0.179910; } else { xc = -3.0258469 * ( 1000000000.0 / ( T * T * T ) ) + - 2.1070379 * ( 1000000.0 / ( T * T ) ) + - 0.2226347 * ( 1000.0 / T ) + - 0.24039; + 2.1070379 * ( 1000000.0 / ( T * T ) ) + + 0.2226347 * ( 1000.0 / T ) + + 0.24039; } if( T >= 1000.0f && T <= 2222.0f ) { yc = -1.1063814 * ( xc * xc * xc ) - - 1.3481102 * ( xc * xc ) + - 2.1855583 * xc - - 0.20219683; + 1.3481102 * ( xc * xc ) + + 2.1855583 * xc - + 0.20219683; } else if( T > 2222.0f && T <= 4000.0 ) { yc = -0.9549476 * ( xc * xc * xc ) - - 1.3741859 * ( xc * xc ) + - 2.09137015 * xc - - 0.16748867; + 1.3741859 * ( xc * xc ) + + 2.09137015 * xc - + 0.16748867; } else { yc = 3.081758 * ( xc * xc * xc ) - - 5.8733867 * ( xc * xc ) + - 3.75112997 * xc - - 0.37001483; + 5.8733867 * ( xc * xc ) + + 3.75112997 * xc - + 0.37001483; } // Compute base correlated color temperature const double X = ( Y / yc ) * xc; const double Z = ( Y / yc ) * ( 1.0 - xc - yc ); const Vector3d cctXYZ( X, Y, Z ); - + // Compute white balance const double wbY = 0.54; Vector2 wbCoeff = Tr2StandardIlluminantToCCT( whitePoint ); const double wbX = ( wbY / (double)wbCoeff.y ) * (double)wbCoeff.x; - const double wbZ = ( wbY / (double)wbCoeff.y ) * - (1.0 - (double)wbCoeff.x - (double)wbCoeff.y ); + const double wbZ = ( wbY / (double)wbCoeff.y ) * + ( 1.0 - (double)wbCoeff.x - (double)wbCoeff.y ); const Vector3d wbXYZ( wbX, wbY, wbZ ); // Convert to RGB @@ -169,13 +169,13 @@ Vector3d TriColorFromKelvin( float temperature, float tint, Tr2StandardIlluminan // Apply tint const Vector3d tintedRGB( - (1.0 - tint) * balancedRGB.x, + ( 1.0 - tint ) * balancedRGB.x, tint * balancedRGB.y, - (1.0 - tint) * balancedRGB.z ); + ( 1.0 - tint ) * balancedRGB.z ); // Scale to (0.0,1.0) range const double componentMax = std::max( tintedRGB.x, - std::max( tintedRGB.y, tintedRGB.z ) ); + std::max( tintedRGB.y, tintedRGB.z ) ); // Final color const Vector3d finalColor( diff --git a/trinity/Tr2KelvinColor.h b/trinity/Tr2KelvinColor.h index 84c34ead5..d29fa13c2 100644 --- a/trinity/Tr2KelvinColor.h +++ b/trinity/Tr2KelvinColor.h @@ -33,7 +33,8 @@ enum Tr2StandardIlluminant // Converts kelvin color temperature to RGB Vector3d TriColorFromKelvin( float temperature, float tint, Tr2StandardIlluminant whiteBalance ); -BLUE_CLASS( Tr2KelvinColor ) : public IInitialize +BLUE_CLASS( Tr2KelvinColor ) : + public IInitialize { public: Tr2KelvinColor( IRoot* lockobj = NULL ); @@ -49,17 +50,26 @@ BLUE_CLASS( Tr2KelvinColor ) : public IInitialize virtual bool Initialize(); // Gets the current Kelvin color temperature - float GetTemperature( void ) const { return m_temperature; } + float GetTemperature( void ) const + { + return m_temperature; + } // Gets the current tint value - float GetTint( void ) const { return m_tint; } + float GetTint( void ) const + { + return m_tint; + } // Gets the current white balance reference - Tr2StandardIlluminant GetWhiteBalance( void ) const { return m_whiteBalance; } + Tr2StandardIlluminant GetWhiteBalance( void ) const + { + return m_whiteBalance; + } // Converts the color temperature to RGB - Color AsRGB( void ) const - { + Color AsRGB( void ) const + { Vector3d col = TriColorFromKelvin( m_temperature, m_tint, m_whiteBalance ); - return Color( + return Color( static_cast( col.x ), static_cast( col.y ), static_cast( col.z ), diff --git a/trinity/Tr2KelvinColor_Blue.cpp b/trinity/Tr2KelvinColor_Blue.cpp index 7a86aa1b6..9586a1ba9 100644 --- a/trinity/Tr2KelvinColor_Blue.cpp +++ b/trinity/Tr2KelvinColor_Blue.cpp @@ -9,105 +9,68 @@ BLUE_DEFINE( Tr2KelvinColor ); static const float MIN_KELVIN = 1000.0f; static const float MAX_KELVIN = 10000.0f; -static Be::VarChooser Tr2StandardIlluminantChooser[] = -{ - { - "CIE_A", - BeCast( TR2STANDARDILLUMINANT_A ), - "(CIE A) Incandescent / Tungsten" - }, - { - "CIE_D50", - BeCast( TR2STANDARDILLUMINANT_D50 ), - "(CIE D50) Horizon Light" - }, - { - "CIE_D55", - BeCast( TR2STANDARDILLUMINANT_D55 ), - "(CIE D55) Mid-Morning / Mid-Afternoon Daylight" - }, - { - "CIE_D65", - BeCast( TR2STANDARDILLUMINANT_D65 ), - "(CIE D65) Noon Daylight" - }, - { - "CIE_D75", - BeCast( TR2STANDARDILLUMINANT_D75 ), - "(CIE D75) North Sky Daylight" - }, - { - "CIE_E", - BeCast( TR2STANDARDILLUMINANT_E ), - "(CIE E) Equal Energy" - }, - { - "CIE_F1", - BeCast( TR2STANDARDILLUMINANT_F1 ), - "(CIE F1) Daylight Fluorescent" - }, - { - "CIE_F2", - BeCast( TR2STANDARDILLUMINANT_F2 ), - "(CIE F2) Cool White Fluorescent" - }, - { - "CIE_F3", - BeCast( TR2STANDARDILLUMINANT_F3 ), - "(CIE F3) White Fluorescent" - }, - { - "CIE_F4", - BeCast( TR2STANDARDILLUMINANT_F4 ), - "(CIE F4) Warm White Fluorescent" - }, - { - "CIE_F5", - BeCast( TR2STANDARDILLUMINANT_F5 ), - "(CIE F5) Daylight Fluorescent" - }, - { - "CIE_F6", - BeCast( TR2STANDARDILLUMINANT_F6 ), - "(CIE F6) Lite White Fluorescent" - }, - { - "CIE_F7", - BeCast( TR2STANDARDILLUMINANT_F7 ), - "(CIE F7) D65 Fluorescent Simulator" - }, - { - "CIE_F8", - BeCast( TR2STANDARDILLUMINANT_F8 ), - "(CIE F8) D50 Fluorescent Simulator" - }, - { - "CIE_F9", - BeCast( TR2STANDARDILLUMINANT_F9 ), - "(CIE F9) Cool White Deluxe Fluorescent" - }, - { - "CIE_F10", - BeCast( TR2STANDARDILLUMINANT_F10 ), - "(CIE F10) Philips TL85, Ultralume 50" - }, - { - "CIE_F11", - BeCast( TR2STANDARDILLUMINANT_F11 ), - "(CIE F11) Philips TL84, Ultralume 40" - }, - { - "CIE_F12", - BeCast( TR2STANDARDILLUMINANT_F12 ), - "(CIE F12) Philips TL83, Ultralume 30" - }, +static Be::VarChooser Tr2StandardIlluminantChooser[] = { + { "CIE_A", + BeCast( TR2STANDARDILLUMINANT_A ), + "(CIE A) Incandescent / Tungsten" }, + { "CIE_D50", + BeCast( TR2STANDARDILLUMINANT_D50 ), + "(CIE D50) Horizon Light" }, + { "CIE_D55", + BeCast( TR2STANDARDILLUMINANT_D55 ), + "(CIE D55) Mid-Morning / Mid-Afternoon Daylight" }, + { "CIE_D65", + BeCast( TR2STANDARDILLUMINANT_D65 ), + "(CIE D65) Noon Daylight" }, + { "CIE_D75", + BeCast( TR2STANDARDILLUMINANT_D75 ), + "(CIE D75) North Sky Daylight" }, + { "CIE_E", + BeCast( TR2STANDARDILLUMINANT_E ), + "(CIE E) Equal Energy" }, + { "CIE_F1", + BeCast( TR2STANDARDILLUMINANT_F1 ), + "(CIE F1) Daylight Fluorescent" }, + { "CIE_F2", + BeCast( TR2STANDARDILLUMINANT_F2 ), + "(CIE F2) Cool White Fluorescent" }, + { "CIE_F3", + BeCast( TR2STANDARDILLUMINANT_F3 ), + "(CIE F3) White Fluorescent" }, + { "CIE_F4", + BeCast( TR2STANDARDILLUMINANT_F4 ), + "(CIE F4) Warm White Fluorescent" }, + { "CIE_F5", + BeCast( TR2STANDARDILLUMINANT_F5 ), + "(CIE F5) Daylight Fluorescent" }, + { "CIE_F6", + BeCast( TR2STANDARDILLUMINANT_F6 ), + "(CIE F6) Lite White Fluorescent" }, + { "CIE_F7", + BeCast( TR2STANDARDILLUMINANT_F7 ), + "(CIE F7) D65 Fluorescent Simulator" }, + { "CIE_F8", + BeCast( TR2STANDARDILLUMINANT_F8 ), + "(CIE F8) D50 Fluorescent Simulator" }, + { "CIE_F9", + BeCast( TR2STANDARDILLUMINANT_F9 ), + "(CIE F9) Cool White Deluxe Fluorescent" }, + { "CIE_F10", + BeCast( TR2STANDARDILLUMINANT_F10 ), + "(CIE F10) Philips TL85, Ultralume 50" }, + { "CIE_F11", + BeCast( TR2STANDARDILLUMINANT_F11 ), + "(CIE F11) Philips TL84, Ultralume 40" }, + { "CIE_F12", + BeCast( TR2STANDARDILLUMINANT_F12 ), + "(CIE F12) Philips TL83, Ultralume 30" }, { 0 } }; // Register the standard illuminant enum as trinity.Tr2StandardIlluminant -BLUE_REGISTER_ENUM_EX( "Tr2StandardIlluminant", - Tr2StandardIlluminant, - Tr2StandardIlluminantChooser, +BLUE_REGISTER_ENUM_EX( "Tr2StandardIlluminant", + Tr2StandardIlluminant, + Tr2StandardIlluminantChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); #if BLUE_WITH_PYTHON @@ -143,10 +106,10 @@ static PyObject* PyGetKelvinTemperatureBuffer( PyObject* self, PyObject* args ) } Tr2StandardIlluminant stdIllum = (Tr2StandardIlluminant)intWhiteBalance; - char* buffer = CCP_NEW("PyGetKelvinTemperatureBuffer") char[3 * width * height]; + char* buffer = CCP_NEW( "PyGetKelvinTemperatureBuffer" ) char[3 * width * height]; const float startK = MIN_KELVIN; - const float deltaK = (MAX_KELVIN - MIN_KELVIN) / (static_cast(width) - 1.0f); + const float deltaK = ( MAX_KELVIN - MIN_KELVIN ) / ( static_cast( width ) - 1.0f ); float curK = startK; // Render one row of the bitmap @@ -154,21 +117,21 @@ static PyObject* PyGetKelvinTemperatureBuffer( PyObject* self, PyObject* args ) for( int i = 0; i < width; ++i ) { Vector3d rgb = TriColorFromKelvin( curK, 0.5f, stdIllum ); - ptr[3*i] = static_cast( rgb.x * 255.0 ); - ptr[3*i+1] = static_cast( rgb.y * 255.0 ); - ptr[3*i+2] = static_cast( rgb.z * 255.0 ); + ptr[3 * i] = static_cast( rgb.x * 255.0 ); + ptr[3 * i + 1] = static_cast( rgb.y * 255.0 ); + ptr[3 * i + 2] = static_cast( rgb.z * 255.0 ); curK += deltaK; } // Copy the row into the rest of the buffer for( int i = 1; i < height; ++i ) { - memcpy( buffer + i*3*width, buffer, 3*width ); + memcpy( buffer + i * 3 * width, buffer, 3 * width ); } PyObject* ret = NULL; - ret = PyByteArray_FromStringAndSize( buffer, 3*width*height ); - CCP_DELETE[] buffer; + ret = PyByteArray_FromStringAndSize( buffer, 3 * width * height ); + CCP_DELETE[] buffer; return ret; } @@ -180,63 +143,57 @@ static PyObject* PyGetKelvinTintBuffer( PyObject* self, PyObject* args ) return NULL; } - char* buffer = CCP_NEW("PyGetKelvinTintBuffer") char[3 * width * height]; + char* buffer = CCP_NEW( "PyGetKelvinTintBuffer" ) char[3 * width * height]; - const float deltaT = 1.0f / (static_cast(width) - 1.0f); + const float deltaT = 1.0f / ( static_cast( width ) - 1.0f ); float curT = 0.0f; // Render one row of the bitmap char* ptr = buffer; for( int i = 0; i < width; ++i ) { - ptr[3*i] = static_cast( (1.0f - curT) * 255.0 ); - ptr[3*i+1] = static_cast( curT * 255.0 ); - ptr[3*i+2] = static_cast( (1.0f - curT) * 255.0 ); + ptr[3 * i] = static_cast( ( 1.0f - curT ) * 255.0 ); + ptr[3 * i + 1] = static_cast( curT * 255.0 ); + ptr[3 * i + 2] = static_cast( ( 1.0f - curT ) * 255.0 ); curT += deltaT; } // Copy the row into the rest of the buffer for( int i = 1; i < height; ++i ) { - memcpy( buffer + i*3*width, buffer, 3*width ); + memcpy( buffer + i * 3 * width, buffer, 3 * width ); } PyObject* ret = NULL; - ret = PyByteArray_FromStringAndSize( buffer, 3*width*height ); - CCP_DELETE[] buffer; + ret = PyByteArray_FromStringAndSize( buffer, 3 * width * height ); + CCP_DELETE[] buffer; return ret; } -MAP_FUNCTION( "TriColorFromKelvin", PyTriColorFromKelvin, - "Converts a Kelvin color temperature to an RGBA color.\n\n" - ":param temperature: Kelvin color temperature,\n" - ":type temperature: float\n" - ":param tint: a tint value (not used),\n" - ":type tint: float\n" - ":param whiteBalance: white balance standard illuminant" - ":type whiteBalance: int\n" - ":rtype: (float, float, float, float)" - ); - -MAP_FUNCTION( "GetKelvinTemperatureBuffer", PyGetKelvinTemperatureBuffer, - "Generates a buffer of Kelvin temperatures.\n\n" - ":param width: width of the buffer in pixels,\n" - ":type width: int\n" - ":param height: height of the buffer in pixels,\n" - ":type height: int\n" - ":param whiteBalance: white balance standard illuminant\n" - ":type whiteBalance: int\n" - ":rtype: bytearray" - ); - -MAP_FUNCTION( "GetKelvinTintBuffer", PyGetKelvinTintBuffer, - "Generates a buffer of Kelvin tint values.\n\n" - ":param width: width of the buffer in pixels,\n" - ":type width: int\n" - ":param height: height of the buffer in pixels,\n" - ":type height: int\n" - ":rtype: bytearray" - ); +MAP_FUNCTION( "TriColorFromKelvin", PyTriColorFromKelvin, "Converts a Kelvin color temperature to an RGBA color.\n\n" + ":param temperature: Kelvin color temperature,\n" + ":type temperature: float\n" + ":param tint: a tint value (not used),\n" + ":type tint: float\n" + ":param whiteBalance: white balance standard illuminant" + ":type whiteBalance: int\n" + ":rtype: (float, float, float, float)" ); + +MAP_FUNCTION( "GetKelvinTemperatureBuffer", PyGetKelvinTemperatureBuffer, "Generates a buffer of Kelvin temperatures.\n\n" + ":param width: width of the buffer in pixels,\n" + ":type width: int\n" + ":param height: height of the buffer in pixels,\n" + ":type height: int\n" + ":param whiteBalance: white balance standard illuminant\n" + ":type whiteBalance: int\n" + ":rtype: bytearray" ); + +MAP_FUNCTION( "GetKelvinTintBuffer", PyGetKelvinTintBuffer, "Generates a buffer of Kelvin tint values.\n\n" + ":param width: width of the buffer in pixels,\n" + ":type width: int\n" + ":param height: height of the buffer in pixels,\n" + ":type height: int\n" + ":rtype: bytearray" ); #endif diff --git a/trinity/Tr2LabelTextParser.cpp b/trinity/Tr2LabelTextParser.cpp index 853b07228..d791fd2eb 100644 --- a/trinity/Tr2LabelTextParser.cpp +++ b/trinity/Tr2LabelTextParser.cpp @@ -8,15 +8,15 @@ enum States { - STATE_ROOT, - STATE_GENERAL_TEXT, - STATE_TAG, - STATE_CLOSE_TAG, + STATE_ROOT, + STATE_GENERAL_TEXT, + STATE_TAG, + STATE_CLOSE_TAG, - // Detection of & and the like - STATE_GT_AMPSTART, + // Detection of & and the like + STATE_GT_AMPSTART, - STATE_TERMINATE + STATE_TERMINATE }; #if BLUE_WITH_PYTHON @@ -45,228 +45,228 @@ PyObject* ToPyUnicode( const wchar_t* str ) // Returns Py_None if you're pointing at > already (no attributes) // Returns a dict of attributes on success. // -PyObject* ParseAttribs( wchar_t *&curPos, const wchar_t *keyAlreadyParsed = NULL ) +PyObject* ParseAttribs( wchar_t*& curPos, const wchar_t* keyAlreadyParsed = NULL ) { - if( *curPos == L'>' ) - { - // Well, that was easy, there aren't any. - curPos++; - Py_INCREF( Py_None ); - return Py_None; - } - - enum attribStates - { - ASTATE_KEY, - ASTATE_VALUE, - ASTATE_WHITEOREND, - ASTATE_WHITESPACE, - ASTATE_TERMINATE - }; - - attribStates astate; - const wchar_t* key = nullptr; - PyObject* result = PyDict_New(); - - if( keyAlreadyParsed ) - { - key = keyAlreadyParsed; - astate = ASTATE_VALUE; - } - else - { - astate = ASTATE_WHITESPACE; - } - - while( astate != ASTATE_TERMINATE ) - { - switch( astate ) - { - case ASTATE_WHITEOREND: - if( *curPos == L'>' ) - { - curPos++; - astate = ASTATE_TERMINATE; - break; - } - // Fall through - case ASTATE_WHITESPACE: - { - bool matched = false; - bool wasWhite = true; - - while( wasWhite ) - { - wchar_t next = *curPos; - if( next == L' ' || next == L'\t' ) - { - curPos++; - matched = true; - } - else if( next == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) - { - curPos += 6; - matched = true; - } - else - { - wasWhite = false; - } - } - - if( !matched ) - { - // There wasn't any whitespace where there should be. We're hosed. - goto error; - } - else - { - astate = ASTATE_KEY; - } - } - break; - case ASTATE_KEY: - { - key = curPos; - // March along until we find = - // - or error cases like > and EOF - // - or odd but handleable cases like whitespace - - wchar_t curChar = *curPos; - while( curChar != L'=' ) - { - if( curChar == L'>' ) - { - goto error; - } - if( curChar == L'\0' ) - { - goto error; - } - - if( curChar == L' ' || curChar == L'\t' ) - { - // We just passed over a word, but whatever. - key = curPos + 1; - } - - if( curChar == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) - { - key = curPos + 6; - curPos += 5; // Only 5 'cause we're about to do another ++. - } - - curPos++; - curChar = *curPos; - } - - // We made it without error - we're now pointing at an =, which we're going to turn into a null - // so we can use key as a null-term string. - *curPos = '\0'; - curPos++; - astate = ASTATE_VALUE; - } - break; - case ASTATE_VALUE: - { - PyObject* value = nullptr; - if( *curPos == L'\'' || *curPos == L'"' ) - { - // Sweet, it's a quoted string, we just zoom to the end of the quote and that's that. - wchar_t* endOfValue = wcschr( curPos + 1, *curPos ); - if( !endOfValue ) - { - goto error; - } - // Get string value without begin/end quotes then advance the current position after the end quote. - value = ToPyUnicode( curPos + 1, endOfValue - curPos - 1 ); - curPos = endOfValue + 1; + if( *curPos == L'>' ) + { + // Well, that was easy, there aren't any. + curPos++; + Py_INCREF( Py_None ); + return Py_None; + } + + enum attribStates + { + ASTATE_KEY, + ASTATE_VALUE, + ASTATE_WHITEOREND, + ASTATE_WHITESPACE, + ASTATE_TERMINATE + }; + + attribStates astate; + const wchar_t* key = nullptr; + PyObject* result = PyDict_New(); + + if( keyAlreadyParsed ) + { + key = keyAlreadyParsed; + astate = ASTATE_VALUE; + } + else + { + astate = ASTATE_WHITESPACE; + } + + while( astate != ASTATE_TERMINATE ) + { + switch( astate ) + { + case ASTATE_WHITEOREND: + if( *curPos == L'>' ) + { + curPos++; + astate = ASTATE_TERMINATE; + break; + } + // Fall through + case ASTATE_WHITESPACE: { + bool matched = false; + bool wasWhite = true; + + while( wasWhite ) + { + wchar_t next = *curPos; + if( next == L' ' || next == L'\t' ) + { + curPos++; + matched = true; + } + else if( next == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) + { + curPos += 6; + matched = true; + } + else + { + wasWhite = false; + } + } + + if( !matched ) + { + // There wasn't any whitespace where there should be. We're hosed. + goto error; + } + else + { + astate = ASTATE_KEY; + } + } + break; + case ASTATE_KEY: { + key = curPos; + // March along until we find = + // - or error cases like > and EOF + // - or odd but handleable cases like whitespace + + wchar_t curChar = *curPos; + while( curChar != L'=' ) + { + if( curChar == L'>' ) + { + goto error; } - else - { - // Not a quoted string...go until we find > or whitespace. - wchar_t* startOfValue = curPos; - bool done = false; - while( !done ) - { - wchar_t curChar = *curPos; - - if( curChar == L' ' || curChar == L'\t' || curChar == L'>' || - ( curChar == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) ) - { - done = true; - } - else if( curChar == L'\0' ) - { - goto error; - } - else - { - curPos++; - } - } - - value = ToPyUnicode( startOfValue, curPos - startOfValue ); + if( curChar == L'\0' ) + { + goto error; } - PyObject* keyThunked = ToPyUnicode( key ); - PyDict_SetItem( result, keyThunked, value ); + if( curChar == L' ' || curChar == L'\t' ) + { + // We just passed over a word, but whatever. + key = curPos + 1; + } - astate = ASTATE_WHITEOREND; - } - break; - default: - break; - } - } + if( curChar == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) + { + key = curPos + 6; + curPos += 5; // Only 5 'cause we're about to do another ++. + } + curPos++; + curChar = *curPos; + } + + // We made it without error - we're now pointing at an =, which we're going to turn into a null + // so we can use key as a null-term string. + *curPos = '\0'; + curPos++; + astate = ASTATE_VALUE; + } + break; + case ASTATE_VALUE: { + PyObject* value = nullptr; + if( *curPos == L'\'' || *curPos == L'"' ) + { + // Sweet, it's a quoted string, we just zoom to the end of the quote and that's that. + wchar_t* endOfValue = wcschr( curPos + 1, *curPos ); + if( !endOfValue ) + { + goto error; + } + // Get string value without begin/end quotes then advance the current position after the end quote. + value = ToPyUnicode( curPos + 1, endOfValue - curPos - 1 ); + curPos = endOfValue + 1; + } + else + { + // Not a quoted string...go until we find > or whitespace. + wchar_t* startOfValue = curPos; + bool done = false; + while( !done ) + { + wchar_t curChar = *curPos; + + if( curChar == L' ' || curChar == L'\t' || curChar == L'>' || + ( curChar == L'&' && _wcsnicmp( curPos + 1, L"nbsp;", 5 ) == 0 ) ) + { + done = true; + } + else if( curChar == L'\0' ) + { + goto error; + } + else + { + curPos++; + } + } - return result; + value = ToPyUnicode( startOfValue, curPos - startOfValue ); + } + + PyObject* keyThunked = ToPyUnicode( key ); + PyDict_SetItem( result, keyThunked, value ); + + astate = ASTATE_WHITEOREND; + } + break; + default: + break; + } + } + + + return result; error: - // We've hit an unknown spot. Try to fast forward to an > and barring that, the end of the string. - wchar_t *closeTag = wcschr(curPos, L'>'); - if (closeTag) { - curPos = closeTag + 1; - } else { - //curPos = wcschr(curPos, L'\0'); - // Sure, we could zoom forward to the natural NULL, but since we can slice - // and dice up the input as we like, let's just put one where we are. - *curPos = '\0'; - } - Py_DECREF(result); // He isn't going anywhere, so toss him out. - return NULL; + // We've hit an unknown spot. Try to fast forward to an > and barring that, the end of the string. + wchar_t* closeTag = wcschr( curPos, L'>' ); + if( closeTag ) + { + curPos = closeTag + 1; + } + else + { + //curPos = wcschr(curPos, L'\0'); + // Sure, we could zoom forward to the natural NULL, but since we can slice + // and dice up the input as we like, let's just put one where we are. + *curPos = '\0'; + } + Py_DECREF( result ); // He isn't going anywhere, so toss him out. + return NULL; } // A little helper function (well, define, but it's a minor difference) to consume whatever // text we've accumulated up to this point. // #define CONSUME_TEXT \ -{ /* Consume the text up to this point into a text-element */ \ - PyObject* textTuple = PyTuple_New( 2 ); \ - PyTuple_SetItem( textTuple, 0, ToPython( 0 ) ); \ - PyObject* newString; \ + { /* Consume the text up to this point into a text-element */ \ + PyObject* textTuple = PyTuple_New( 2 ); \ + PyTuple_SetItem( textTuple, 0, ToPython( 0 ) ); \ + PyObject* newString; \ \ - if( stringBeingBuilt.empty( ) ) \ - { \ - /* Simple case, we haven't done any substitutions. */ \ - newString = ToPyUnicode( marker, ( curPos - marker ) ); \ - } \ - else \ - { \ - /* We did some string manip, so finish it off then make a new thunked-string for it. */ \ - if( curPos != marker ) \ - { \ - stringBeingBuilt.append( marker, curPos - marker ); \ - } \ - newString = ToPyUnicode( stringBeingBuilt.c_str(), stringBeingBuilt.size() ); \ - stringBeingBuilt.clear( ); \ - } \ + if( stringBeingBuilt.empty() ) \ + { \ + /* Simple case, we haven't done any substitutions. */ \ + newString = ToPyUnicode( marker, ( curPos - marker ) ); \ + } \ + else \ + { \ + /* We did some string manip, so finish it off then make a new thunked-string for it. */ \ + if( curPos != marker ) \ + { \ + stringBeingBuilt.append( marker, curPos - marker ); \ + } \ + newString = ToPyUnicode( stringBeingBuilt.c_str(), stringBeingBuilt.size() ); \ + stringBeingBuilt.clear(); \ + } \ \ - PyTuple_SetItem( textTuple, 1, newString ); \ - PyList_Append( currentTab, textTuple ); \ - Py_DECREF( textTuple ); \ -} + PyTuple_SetItem( textTuple, 1, newString ); \ + PyList_Append( currentTab, textTuple ); \ + Py_DECREF( textTuple ); \ + } static PyObject* PyParseLabelText( PyObject* self, PyObject* args ) { @@ -279,777 +279,775 @@ static PyObject* PyParseLabelText( PyObject* self, PyObject* args ) size_t stringLength = wcslen( paramString ); #else - PyObject* paramObject; - if( !PyArg_ParseTuple( args, "U", ¶mObject ) ) - { - return nullptr; - } - Py_ssize_t stringLength; - wchar_t* paramString = PyUnicode_AsWideCharString(paramObject, &stringLength ); - if( !paramString ) - { - return nullptr; - } + PyObject* paramObject; + if( !PyArg_ParseTuple( args, "U", ¶mObject ) ) + { + return nullptr; + } + Py_ssize_t stringLength; + wchar_t* paramString = PyUnicode_AsWideCharString( paramObject, &stringLength ); + if( !paramString ) + { + return nullptr; + } #endif - wchar_t* inString = CCP_NEW("ParseLabelText") wchar_t[stringLength + 1]; - wcscpy_s(inString, stringLength + 1, paramString); - - PyObject* listOfLines = PyList_New( 0 ); - - PyObject* currentLine = PyList_New( 0 ); - PyObject* currentTab = PyList_New( 0 ); - PyList_Append( listOfLines, currentLine ); - PyList_Append( currentLine, currentTab ); - + wchar_t* inString = CCP_NEW( "ParseLabelText" ) wchar_t[stringLength + 1]; + wcscpy_s( inString, stringLength + 1, paramString ); + + PyObject* listOfLines = PyList_New( 0 ); + + PyObject* currentLine = PyList_New( 0 ); + PyObject* currentTab = PyList_New( 0 ); + PyList_Append( listOfLines, currentLine ); + PyList_Append( currentLine, currentTab ); + // The list now owns the references Py_DECREF( currentLine ); Py_DECREF( currentTab ); - wchar_t* curPos = inString; - wchar_t* marker = curPos; - - std::wstring stringBeingBuilt; // Can't just copy straight over 'cause we sometimes do text replacements, like & - - States state = STATE_ROOT; - - while( state != STATE_TERMINATE ) - { - switch( state ) - { - case STATE_ROOT: // Very simple state for starting out, we're either at a tag or we aren't. - if ( *curPos == L'<' ) - { - marker = curPos; - curPos++; - state = STATE_TAG; - } - else if( *curPos == L'\0' ) - { - state = STATE_TERMINATE; - } - else - { - marker = curPos; - state = STATE_GENERAL_TEXT; - } - break; - - case STATE_GENERAL_TEXT: - switch( *curPos ) - { - case L'<': - CONSUME_TEXT; - curPos++; - state = STATE_TAG; - break; - - case L'&': - state = STATE_GT_AMPSTART; - break; - - case L'\t': - *curPos = L' '; // Single character replacements are easy! - curPos++; - break; - - case L'\0': - CONSUME_TEXT; - state = STATE_TERMINATE; - break; - - case L'\n': - CONSUME_TEXT; - curPos++; - - // Start up a new line - currentLine = PyList_New( 0 ); - currentTab = PyList_New( 0 ); - PyList_Append( listOfLines, currentLine ); - PyList_Append( currentLine, currentTab ); + wchar_t* curPos = inString; + wchar_t* marker = curPos; + + std::wstring stringBeingBuilt; // Can't just copy straight over 'cause we sometimes do text replacements, like & + + States state = STATE_ROOT; + + while( state != STATE_TERMINATE ) + { + switch( state ) + { + case STATE_ROOT: // Very simple state for starting out, we're either at a tag or we aren't. + if( *curPos == L'<' ) + { + marker = curPos; + curPos++; + state = STATE_TAG; + } + else if( *curPos == L'\0' ) + { + state = STATE_TERMINATE; + } + else + { + marker = curPos; + state = STATE_GENERAL_TEXT; + } + break; + + case STATE_GENERAL_TEXT: + switch( *curPos ) + { + case L'<': + CONSUME_TEXT; + curPos++; + state = STATE_TAG; + break; + + case L'&': + state = STATE_GT_AMPSTART; + break; + + case L'\t': + *curPos = L' '; // Single character replacements are easy! + curPos++; + break; + + case L'\0': + CONSUME_TEXT; + state = STATE_TERMINATE; + break; + + case L'\n': + CONSUME_TEXT; + curPos++; + + // Start up a new line + currentLine = PyList_New( 0 ); + currentTab = PyList_New( 0 ); + PyList_Append( listOfLines, currentLine ); + PyList_Append( currentLine, currentTab ); // The list now owns the references Py_DECREF( currentLine ); Py_DECREF( currentTab ); - state = STATE_ROOT; - break; - - case L'\r': - if( *(curPos + 1) == L'\n' ) - { - CONSUME_TEXT; - curPos += 2; - - // Start up a new line - currentLine = PyList_New( 0 ); - currentTab = PyList_New( 0 ); - PyList_Append( listOfLines, currentLine ); - PyList_Append( currentLine, currentTab ); + state = STATE_ROOT; + break; + + case L'\r': + if( *( curPos + 1 ) == L'\n' ) + { + CONSUME_TEXT; + curPos += 2; + + // Start up a new line + currentLine = PyList_New( 0 ); + currentTab = PyList_New( 0 ); + PyList_Append( listOfLines, currentLine ); + PyList_Append( currentLine, currentTab ); // The list now owns the references Py_DECREF( currentLine ); Py_DECREF( currentTab ); - state = STATE_ROOT; - } - else - { - curPos++; - } - break; - - default: - // Just advance on past, we'll copy the text from marker to curPos when we need to. - curPos++; - break; - } - - break; - case STATE_TAG: - { - // This one's going to be a bit complex... - // We're pointing at right after the open < - - if( *curPos == L'/' ) - { - // Whoops, we're in a close tag, not an open tag! - curPos++; - state = STATE_CLOSE_TAG; - break; - } - - bool matched = false; - wchar_t next; - - switch( *curPos ) - { - case L'a': // - case L'A': - { - // Matched , assuming we match attributes... - curPos++; - PyObject* attribs = ParseAttribs( curPos ); - if( attribs ) - { - matched = true; - - PyObject* tagTuple = PyTuple_New( 3 ); - PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 6 ) ); - PyTuple_SetItem( tagTuple, 2, attribs ); - PyList_Append( currentTab, tagTuple ); - Py_DECREF( tagTuple ); - } - } - break; - - case L'b': //
(and all forms) and - case L'B': - next = *(curPos + 1); - if( next == L'r' || next == L'R' ) - { - // We can now eat whitespace if we want. - wchar_t* wsEater = curPos + 2; - - bool wsExhausted = false; - while( !wsExhausted ) - { - next = *wsEater; - if( next == L' ' || next == L'\t' ) - { - wsEater++; - continue; - } - - // Is it our good friend,  ? - if( next == L'&' ) - { - if( _wcsnicmp( wsEater+1, L"nbsp;", 5 ) == 0 ) - { - wsEater += 6; // omnomnom - continue; - } - } - - // Well, no matches, let's term. - wsExhausted = true; - } - - // We now match either "/>" or ">" - next = *(wsEater); - if( next == L'>' ) - { - curPos = wsEater + 1; - matched = true; - } - else if( next == L'/' && *(wsEater+1) == L'>' ) - { - curPos = wsEater + 2; - matched = true; - } - - if( matched ) - { - // Start up a new line - currentLine = PyList_New( 0 ); - currentTab = PyList_New( 0 ); - PyList_Append( listOfLines, currentLine ); - PyList_Append( currentLine, currentTab ); - - // The list now owns the references - Py_DECREF( currentLine ); - Py_DECREF( currentTab ); - } - } - else if( next == L'>' ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + state = STATE_ROOT; + } + else + { + curPos++; + } + break; + + default: + // Just advance on past, we'll copy the text from marker to curPos when we need to. + curPos++; + break; + } + + break; + case STATE_TAG: { + // This one's going to be a bit complex... + // We're pointing at right after the open < + + if( *curPos == L'/' ) + { + // Whoops, we're in a close tag, not an open tag! + curPos++; + state = STATE_CLOSE_TAG; + break; + } + + bool matched = false; + wchar_t next; + + switch( *curPos ) + { + case L'a': //
+ case L'A': { + // Matched , assuming we match attributes... + curPos++; + PyObject* attribs = ParseAttribs( curPos ); + if( attribs ) + { + matched = true; + + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 6 ) ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + } + } + break; + + case L'b': //
(and all forms) and + case L'B': + next = *( curPos + 1 ); + if( next == L'r' || next == L'R' ) + { + // We can now eat whitespace if we want. + wchar_t* wsEater = curPos + 2; + + bool wsExhausted = false; + while( !wsExhausted ) + { + next = *wsEater; + if( next == L' ' || next == L'\t' ) + { + wsEater++; + continue; + } + + // Is it our good friend,  ? + if( next == L'&' ) + { + if( _wcsnicmp( wsEater + 1, L"nbsp;", 5 ) == 0 ) + { + wsEater += 6; // omnomnom + continue; + } + } + + // Well, no matches, let's term. + wsExhausted = true; + } + + // We now match either "/>" or ">" + next = *( wsEater ); + if( next == L'>' ) + { + curPos = wsEater + 1; + matched = true; + } + else if( next == L'/' && *( wsEater + 1 ) == L'>' ) + { + curPos = wsEater + 2; + matched = true; + } + + if( matched ) + { + // Start up a new line + currentLine = PyList_New( 0 ); + currentTab = PyList_New( 0 ); + PyList_Append( listOfLines, currentLine ); + PyList_Append( currentLine, currentTab ); + + // The list now owns the references + Py_DECREF( currentLine ); + Py_DECREF( currentTab ); + } + } + else if( next == L'>' ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 5 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + curPos += 2; + } + break; + + case L'c': //
, ", 5 ) == 0 ) + { + // Matched
+ matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 5 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 1, ToPython( 102 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - curPos += 2; - } - break; - - case L'c': //
, ", 5 ) == 0 ) - { - // Matched
- matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + curPos += 7; + } + } + else if( next == L'o' || next == L'O' ) + { + if( _wcsnicmp( curPos + 2, L"lor=", 4 ) == 0 ) + { + // We have ourselves an attrib-tag! See if we parse attribs... + curPos += 6; + PyObject* attribs = ParseAttribs( curPos, L"color" ); + if( attribs ) + { + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 102 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 1, ToPython( -0xBEEF ) ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - curPos += 7; - } - } - else if( next == L'o' || next == L'O' ) - { - if( _wcsnicmp( curPos + 2, L"lor=", 4 ) == 0 ) - { - // We have ourselves an attrib-tag! See if we parse attribs... - curPos += 6; - PyObject* attribs = ParseAttribs( curPos, L"color" ); - if( attribs ) - { - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + } + } + } + break; + + case L'f': // , , , try to match attribs. - curPos += 4; - PyObject* attribs = ParseAttribs( curPos ); - if( attribs ) - { - matched = true; - - PyObject* tagTuple = PyTuple_New( 3 ); - PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 2, attribs ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - } - } - } - break; - - case L'h': // , try to match attribs. + curPos += 4; + PyObject* attribs = ParseAttribs( curPos ); + if( attribs ) + { + matched = true; + + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( -0xBEEF ) ); - PyTuple_SetItem( tagTuple, 2, attribs ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 1, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - } - } - break; - - case L'i': // - case L'I': - if( *(curPos + 1) == L'>' ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + } + } + } + break; + + case L'h': // , , ", 3 ) == 0 ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + } + } + break; + + case L'i': // + case L'I': + if( *( curPos + 1 ) == L'>' ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 4 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + curPos += 2; + } + break; + + case L'l': // , , ", 3 ) == 0 ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 100 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + curPos += 5; + } + else if( _wcsnicmp( curPos + 2, L"tterspace=", 10 ) == 0 ) + { + // Matching letterspace attribtag? + curPos += 12; + PyObject* attribs = ParseAttribs( curPos, L"letterspace" ); + if( attribs ) + { + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 100 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 1, ToPython( -0xBEEF ) ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - curPos += 5; - } - else if( _wcsnicmp( curPos + 2, L"tterspace=", 10 ) == 0 ) - { - // Matching letterspace attribtag? - curPos += 12; - PyObject* attribs = ParseAttribs( curPos, L"letterspace" ); - if( attribs ) - { - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + } + } + } + break; + + case L'r': // + case L'R': + if( _wcsnicmp( curPos + 1, L"ight>", 5 ) == 0 ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 101 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + curPos += 6; + } + break; + + case L't': // + case L'T': + if( *( curPos + 1 ) == L'>' ) + { + // Matched + matched = true; + curPos += 2; + + // start up a new tab + currentTab = PyList_New( 0 ); + PyList_Append( currentLine, currentTab ); + Py_DECREF( currentTab ); + } + break; + + case L'u': // , , ' ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); + PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); + PyTuple_SetItem( tagTuple, 1, ToPython( 2 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); + Py_DECREF( tagTuple ); + curPos += 2; + } + else if( next == L'r' || next == L'R' ) + { + next = *( curPos + 2 ); + if( next == L'l' || next == L'L' ) + { + if( *( curPos + 3 ) == L':' ) + { + // Kill this wicked syntax! + curPos[3] = L'='; + } + if( *( curPos + 3 ) == L'=' ) + { + // Possible match for url= attribtag (and url:, 'cause we just munged that) + curPos += 4; + PyObject* attribs = ParseAttribs( curPos, L"url" ); + if( attribs ) + { + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); PyTuple_SetItem( tagTuple, 1, ToPython( -0xBEEF ) ); - PyTuple_SetItem( tagTuple, 2, attribs ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 2, attribs ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - } - } - } - break; - - case L'r': // - case L'R': - if( _wcsnicmp( curPos + 1, L"ight>", 5 ) == 0 ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); - PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 101 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); - Py_DECREF( tagTuple ); - curPos += 6; - } - break; - - case L't': // - case L'T': - if( *(curPos + 1) == L'>' ) - { - // Matched - matched = true; - curPos += 2; - - // start up a new tab - currentTab = PyList_New( 0 ); - PyList_Append( currentLine, currentTab ); - Py_DECREF( currentTab ); - } - break; - - case L'u': // , , ' ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); + } + } + } + } + else if( next == L'p' || next == L'P' ) + { + if( _wcsnicmp( curPos + 2, L"percase>", 8 ) == 0 ) + { + // Matched + matched = true; + PyObject* tagTuple = PyTuple_New( 3 ); PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 2 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); + PyTuple_SetItem( tagTuple, 1, ToPython( 3 ) ); + Py_INCREF( Py_None ); + PyTuple_SetItem( tagTuple, 2, Py_None ); + PyList_Append( currentTab, tagTuple ); Py_DECREF( tagTuple ); - curPos += 2; - } - else if( next == L'r' || next == L'R' ) - { - next = *(curPos + 2); - if( next == L'l' || next == L'L' ) - { - if( *(curPos + 3) == L':' ) - { - // Kill this wicked syntax! - curPos[3] = L'='; - } - if( *(curPos + 3) == L'=' ) - { - // Possible match for url= attribtag (and url:, 'cause we just munged that) - curPos += 4; - PyObject* attribs = ParseAttribs( curPos, L"url" ); - if( attribs ) - { - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); - PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( -0xBEEF ) ); - PyTuple_SetItem( tagTuple, 2, attribs ); - PyList_Append( currentTab, tagTuple ); - Py_DECREF( tagTuple ); - } - } - } - } - else if( next == L'p' || next == L'P' ) - { - if( _wcsnicmp( curPos + 2, L"percase>", 8 ) == 0 ) - { - // Matched - matched = true; - PyObject* tagTuple = PyTuple_New( 3 ); - PyTuple_SetItem( tagTuple, 0, ToPython( 1 ) ); - PyTuple_SetItem( tagTuple, 1, ToPython( 3 ) ); - Py_INCREF( Py_None ); - PyTuple_SetItem( tagTuple, 2, Py_None ); - PyList_Append( currentTab, tagTuple ); - Py_DECREF( tagTuple ); - curPos += 10; - } - } - - break; - } - - if( !matched ) - { - wchar_t* closeTag = wcschr( curPos, L'>' ); - if( closeTag ) - { - PyObject* unknownTag = PyTuple_New( 2 ); - PyTuple_SetItem( unknownTag, 0, ToPython( 3 ) ); - PyTuple_SetItem( unknownTag, 1, ToPyUnicode( curPos, closeTag - curPos ) ); - PyList_Append( currentTab, unknownTag ); - Py_DECREF( unknownTag ); - - curPos = closeTag + 1; - - state = STATE_ROOT; // Don't know if we're rockin' text or a tag or whatnot next. - } - else - { - // Mismatched <>, TODO: report this somehow. - state = STATE_TERMINATE; - } - } - else - { - state = STATE_ROOT; // Don't know if we're rockin' text or a tag or whatnot next. - } - } - break; - case STATE_CLOSE_TAG: - { - int closeTagID = -1; - switch( *curPos ) - { - case L'a': - case L'A': - if( *(curPos + 1) == L'>' ) - { - closeTagID = 6; - curPos += 2; - } - break; - case L'b': - case L'B': - if( *(curPos + 1) == L'>' ) - { - closeTagID = 5; - curPos += 2; - } - break; - case L'c': - case L'C': - if( _wcsnicmp( curPos + 1, L"olor>", 5 ) == 0 ) - { - closeTagID = 200; - curPos += 6; - } - break; - case L'f': - case L'F': - if( _wcsnicmp( curPos + 1, L"ont", 3 ) == 0 ) - { - if( *(curPos + 4) == L'>' ) - { - closeTagID = 1; - curPos += 5; - } - else if( _wcsnicmp( curPos + 4, L"size>", 5 ) == 0 ) - { - closeTagID = 201; - curPos += 9; - } - } - break; - case L'h': - case L'H': - if( _wcsnicmp( curPos + 1, L"int>", 4 ) == 0 ) - { - closeTagID = 203; - curPos += 5; - } - break; - case L'i': - case L'I': - if( *(curPos + 1) == L'>' ) - { - closeTagID = 4; - curPos += 2; - } - break; - case L'l': - case L'L': - if( _wcsnicmp( curPos + 1, L"etterspace>", 11 ) == 0 ) - { - closeTagID = 202; - curPos += 12; - } - else if( _wcsnicmp( curPos + 1, L"ocalized>", 9 ) == 0 ) - { - closeTagID = 7; - curPos += 10; - } - break; - case L'u': - case L'U': - if( *(curPos + 1) == L'>' ) - { - closeTagID = 2; - curPos += 2; - } - else if( _wcsnicmp( curPos + 1, L"rl>", 3 ) == 0 ) - { - closeTagID = 204; - curPos += 4; - } - else if( _wcsnicmp( curPos + 1, L"ppercase>", 9 ) == 0 ) - { - closeTagID = 3; - curPos += 10; - } - break; - } - - if( closeTagID != -1 ) - { - PyObject* closeTuple = PyTuple_New( 2 ); - PyTuple_SetItem( closeTuple, 0, ToPython( 2 ) ); - PyTuple_SetItem( closeTuple, 1, ToPython( closeTagID ) ); - PyList_Append( currentTab, closeTuple ); - Py_DECREF( closeTuple ); - } - else - { - // We didn't match a close tag...just march on to > and carry on. - wchar_t* closeTag = wcschr( curPos, L'>' ); - if( closeTag ) - { - curPos = closeTag + 1; - } - else - { - //curPos = wcschr(curPos, L'\0'); - // Sure, we could zoom forward to the natural NULL, but since we can slice - // and dice up the input as we like, let's just put one where we are. - *curPos = '\0'; - } - } - - state = STATE_ROOT; // What's next? Who knows! - } - break; - case STATE_GT_AMPSTART: - // Inside of a general text, we have an amp. Let's see if we need to do anything with it. - // Note, we're currently pointing at the amp. - { - bool matched = false; - wchar_t next; - switch( *(curPos + 1) ) - { - case L'a': - case L'A': - if( _wcsnicmp( curPos+2, L"mp;", 3 ) == 0 ) - { - // We matched & - // Copy up from the marker to here into the building-string - // then emit an & and off we go. - if( marker != curPos ) - { - stringBeingBuilt.append( marker, curPos - marker ); - } - stringBeingBuilt.append( (size_t) 1, L'&' ); - curPos += 5; - marker = curPos; - matched = true; - } - break; - case L'l': - case L'L': - next = *(curPos + 2); - if( next == L't' || next == L'T' ) - { - next = *(curPos + 3); - if( next == L';' ) - { - // We matched < - // Copy up from the marker to here into the building-string - // then emit an & and off we go. - if( marker != curPos ) - { - stringBeingBuilt.append( marker, curPos - marker ); - } - stringBeingBuilt.append( 1, L'<' ); - curPos += 4; - marker = curPos; - matched = true; - } - } - break; - case L'g': - case L'G': - next = *(curPos + 2); - if( next == L't' || next == L'T' ) - { - next = *(curPos + 3); - if( next == L';' ) - { - // We matched > - // Copy up from the marker to here into the building-string - // then emit an & and off we go. - if( marker != curPos ) - { - stringBeingBuilt.append( marker, curPos - marker ); - } - stringBeingBuilt.append( 1, L'>' ); - curPos += 4; - marker = curPos; - matched = true; - } - } - break; - case L'n': - case L'N': - if( _wcsnicmp( curPos+2, L"bsp;", 4 ) == 0 ) - { - // We matched   - // Copy up from the marker to here into the building-string - // then emit an & and off we go. - if( marker != curPos ) - { - stringBeingBuilt.append( marker, curPos - marker ); - } - stringBeingBuilt.append( 1, L' ' ); - curPos += 6; - marker = curPos; - matched = true; - } - break; - default: - break; - } - if( !matched ) - { - // Well, didn't match any of our patterns, just carry on like nothing happened. - curPos++; - } - // In any case, back to gen text with us. - state = STATE_GENERAL_TEXT; - } - break; - default: - break; - } - } - - CCP_DELETE[] inString; - return listOfLines; + curPos += 10; + } + } + + break; + } + + if( !matched ) + { + wchar_t* closeTag = wcschr( curPos, L'>' ); + if( closeTag ) + { + PyObject* unknownTag = PyTuple_New( 2 ); + PyTuple_SetItem( unknownTag, 0, ToPython( 3 ) ); + PyTuple_SetItem( unknownTag, 1, ToPyUnicode( curPos, closeTag - curPos ) ); + PyList_Append( currentTab, unknownTag ); + Py_DECREF( unknownTag ); + + curPos = closeTag + 1; + + state = STATE_ROOT; // Don't know if we're rockin' text or a tag or whatnot next. + } + else + { + // Mismatched <>, TODO: report this somehow. + state = STATE_TERMINATE; + } + } + else + { + state = STATE_ROOT; // Don't know if we're rockin' text or a tag or whatnot next. + } + } + break; + case STATE_CLOSE_TAG: { + int closeTagID = -1; + switch( *curPos ) + { + case L'a': + case L'A': + if( *( curPos + 1 ) == L'>' ) + { + closeTagID = 6; + curPos += 2; + } + break; + case L'b': + case L'B': + if( *( curPos + 1 ) == L'>' ) + { + closeTagID = 5; + curPos += 2; + } + break; + case L'c': + case L'C': + if( _wcsnicmp( curPos + 1, L"olor>", 5 ) == 0 ) + { + closeTagID = 200; + curPos += 6; + } + break; + case L'f': + case L'F': + if( _wcsnicmp( curPos + 1, L"ont", 3 ) == 0 ) + { + if( *( curPos + 4 ) == L'>' ) + { + closeTagID = 1; + curPos += 5; + } + else if( _wcsnicmp( curPos + 4, L"size>", 5 ) == 0 ) + { + closeTagID = 201; + curPos += 9; + } + } + break; + case L'h': + case L'H': + if( _wcsnicmp( curPos + 1, L"int>", 4 ) == 0 ) + { + closeTagID = 203; + curPos += 5; + } + break; + case L'i': + case L'I': + if( *( curPos + 1 ) == L'>' ) + { + closeTagID = 4; + curPos += 2; + } + break; + case L'l': + case L'L': + if( _wcsnicmp( curPos + 1, L"etterspace>", 11 ) == 0 ) + { + closeTagID = 202; + curPos += 12; + } + else if( _wcsnicmp( curPos + 1, L"ocalized>", 9 ) == 0 ) + { + closeTagID = 7; + curPos += 10; + } + break; + case L'u': + case L'U': + if( *( curPos + 1 ) == L'>' ) + { + closeTagID = 2; + curPos += 2; + } + else if( _wcsnicmp( curPos + 1, L"rl>", 3 ) == 0 ) + { + closeTagID = 204; + curPos += 4; + } + else if( _wcsnicmp( curPos + 1, L"ppercase>", 9 ) == 0 ) + { + closeTagID = 3; + curPos += 10; + } + break; + } + + if( closeTagID != -1 ) + { + PyObject* closeTuple = PyTuple_New( 2 ); + PyTuple_SetItem( closeTuple, 0, ToPython( 2 ) ); + PyTuple_SetItem( closeTuple, 1, ToPython( closeTagID ) ); + PyList_Append( currentTab, closeTuple ); + Py_DECREF( closeTuple ); + } + else + { + // We didn't match a close tag...just march on to > and carry on. + wchar_t* closeTag = wcschr( curPos, L'>' ); + if( closeTag ) + { + curPos = closeTag + 1; + } + else + { + //curPos = wcschr(curPos, L'\0'); + // Sure, we could zoom forward to the natural NULL, but since we can slice + // and dice up the input as we like, let's just put one where we are. + *curPos = '\0'; + } + } + + state = STATE_ROOT; // What's next? Who knows! + } + break; + case STATE_GT_AMPSTART: + // Inside of a general text, we have an amp. Let's see if we need to do anything with it. + // Note, we're currently pointing at the amp. + { + bool matched = false; + wchar_t next; + switch( *( curPos + 1 ) ) + { + case L'a': + case L'A': + if( _wcsnicmp( curPos + 2, L"mp;", 3 ) == 0 ) + { + // We matched & + // Copy up from the marker to here into the building-string + // then emit an & and off we go. + if( marker != curPos ) + { + stringBeingBuilt.append( marker, curPos - marker ); + } + stringBeingBuilt.append( (size_t)1, L'&' ); + curPos += 5; + marker = curPos; + matched = true; + } + break; + case L'l': + case L'L': + next = *( curPos + 2 ); + if( next == L't' || next == L'T' ) + { + next = *( curPos + 3 ); + if( next == L';' ) + { + // We matched < + // Copy up from the marker to here into the building-string + // then emit an & and off we go. + if( marker != curPos ) + { + stringBeingBuilt.append( marker, curPos - marker ); + } + stringBeingBuilt.append( 1, L'<' ); + curPos += 4; + marker = curPos; + matched = true; + } + } + break; + case L'g': + case L'G': + next = *( curPos + 2 ); + if( next == L't' || next == L'T' ) + { + next = *( curPos + 3 ); + if( next == L';' ) + { + // We matched > + // Copy up from the marker to here into the building-string + // then emit an & and off we go. + if( marker != curPos ) + { + stringBeingBuilt.append( marker, curPos - marker ); + } + stringBeingBuilt.append( 1, L'>' ); + curPos += 4; + marker = curPos; + matched = true; + } + } + break; + case L'n': + case L'N': + if( _wcsnicmp( curPos + 2, L"bsp;", 4 ) == 0 ) + { + // We matched   + // Copy up from the marker to here into the building-string + // then emit an & and off we go. + if( marker != curPos ) + { + stringBeingBuilt.append( marker, curPos - marker ); + } + stringBeingBuilt.append( 1, L' ' ); + curPos += 6; + marker = curPos; + matched = true; + } + break; + default: + break; + } + if( !matched ) + { + // Well, didn't match any of our patterns, just carry on like nothing happened. + curPos++; + } + // In any case, back to gen text with us. + state = STATE_GENERAL_TEXT; + } + break; + default: + break; + } + } + + CCP_DELETE[] inString; + return listOfLines; } -MAP_FUNCTION( - "ParseLabelText", - PyParseLabelText, +MAP_FUNCTION( + "ParseLabelText", + PyParseLabelText, "This is used by the UI's Label to parse our custom HTML-ish language very quickly. It is almost surely not useful for any other purpose.\n" ":param text: input text\n" ":type text: unicode\n" - ":rtype: list" - ); + ":rtype: list" ); #endif diff --git a/trinity/Tr2LightManager.cpp b/trinity/Tr2LightManager.cpp index 61d22b788..ae20b7c3f 100644 --- a/trinity/Tr2LightManager.cpp +++ b/trinity/Tr2LightManager.cpp @@ -60,7 +60,7 @@ struct PerFrameData uint32_t tilesY; uint32_t lightCount; uint32_t indexBufferSize; - // cppcheck-suppress unusedStructMember + // cppcheck-suppress unusedStructMember uint32_t _padding[2]; }; @@ -223,7 +223,7 @@ void Tr2LightManager::Clear( Tr2RenderContext& renderContext ) m_indexBufferVariable = m_indexBuffer; ClearLightIndices( renderContext ); - for ( auto& data : m_tlsLightData ) + for( auto& data : m_tlsLightData ) { data.clear(); } @@ -231,7 +231,7 @@ void Tr2LightManager::Clear( Tr2RenderContext& renderContext ) m_shadowCastingLights.clear(); m_volumetricLights.clear(); - m_ShadowMap.m_atlasNodes.resize(1); + m_ShadowMap.m_atlasNodes.resize( 1 ); m_ShadowMap.m_atlasNodes[0].x = 0; m_ShadowMap.m_atlasNodes[0].y = 0; m_ShadowMap.m_atlasNodes[0].width = m_ShadowMap.m_atlasSettings.size; @@ -254,16 +254,16 @@ void Tr2LightManager::AdjustLightCutoff( float lodFactor ) // This entire thing is annoyingly complex for what should be a simple thing... // The reason why it's such a mess is because we have multiple eve space scenes with different // shadow qualities, but want to share resources across them. But we also don't have a way -// of getting all eve space scenes, so we have to collect the qualities during a frame +// of getting all eve space scenes, so we have to collect the qualities during a frame // and based on that decide which resources are needed for the next frame. -// In addition we have different ways of rendering shadows: Shadowmapped with different +// In addition we have different ways of rendering shadows: Shadowmapped with different // atlas resolutions and raytraced shadows. // On top of that we don't want to use any resources when the feature flag is false. void Tr2LightManager::SetShadowQuality( ShadowQuality shadowQuality, uint64_t frameCounter ) { m_currentSpaceSceneShadowQuality = shadowQuality; - if ( m_currentFrameCounter != frameCounter ) + if( m_currentFrameCounter != frameCounter ) { if( !g_useDynamicLightsShadows ) { @@ -271,7 +271,7 @@ void Tr2LightManager::SetShadowQuality( ShadowQuality shadowQuality, uint64_t fr } // there must be a more elegant way of doing this... - if ( nextFrameShadowQuality & ( 1 << ( uint32_t)ShadowQuality::SHADOW_HIGH ) ) + if( nextFrameShadowQuality & ( 1 << (uint32_t)ShadowQuality::SHADOW_HIGH ) ) { m_ShadowMap.m_qualityUsedByAtlas = ShadowQuality::SHADOW_HIGH; } @@ -357,7 +357,7 @@ void Tr2LightManager::AddLight( PerLightData& data ) data.color.z *= data.radius * dimming; bool usingShadowMap = m_currentSpaceSceneShadowQuality == ShadowQuality::SHADOW_LOW || m_currentSpaceSceneShadowQuality == ShadowQuality::SHADOW_HIGH; - if( m_currentSpaceSceneShadowQuality == ShadowQuality::SHADOW_DISABLED || + if( m_currentSpaceSceneShadowQuality == ShadowQuality::SHADOW_DISABLED || ( usingShadowMap && m_ShadowMap.m_qualityUsedByAtlas == ShadowQuality::SHADOW_DISABLED ) || !g_useDynamicLightsShadows ) { @@ -647,7 +647,7 @@ void Tr2LightManager::ReleaseResources( TriStorage s ) // light manager does not release all sorts of buffers/effects. raytracing manager on the other hand does. // probably because raytracing manager expects to get destroyed, unlike light manager, which is a singleton...? - + if( ( s & TRISTORAGE_ALL ) == TRISTORAGE_ALL ) { m_Raytracing.m_perFrameData = Tr2ConstantBufferAL(); @@ -728,7 +728,7 @@ uint32_t Tr2LightManager::InsertAtlasNode( std::vector& atlasNodes, u return InsertAtlasNode( atlasNodes, atlasNodes[nodeId].children[1], lightIndex, width, height ); } else - { + { if( atlasNodes[nodeId].lightIndex != -1 ) { return -1; @@ -742,19 +742,19 @@ uint32_t Tr2LightManager::InsertAtlasNode( std::vector& atlasNodes, u atlasNodes[nodeId].lightIndex = lightIndex; return nodeId; } - - atlasNodes.insert( atlasNodes.end(), 2, AtlasNode() ); + + atlasNodes.insert( atlasNodes.end(), 2, AtlasNode() ); atlasNodes[nodeId].children[0] = uint32_t( atlasNodes.size() - 2 ); atlasNodes[nodeId].children[1] = uint32_t( atlasNodes.size() - 1 ); AtlasNode& child0 = atlasNodes[atlasNodes[nodeId].children[0]]; AtlasNode& child1 = atlasNodes[atlasNodes[nodeId].children[1]]; - - int32_t deltaWidth = atlasNodes[nodeId].width - width; + + int32_t deltaWidth = atlasNodes[nodeId].width - width; int32_t deltaHeight = atlasNodes[nodeId].height - height; - - if (deltaWidth > deltaHeight) + + if( deltaWidth > deltaHeight ) { child0.x = atlasNodes[nodeId].x; child0.y = atlasNodes[nodeId].y; @@ -765,7 +765,7 @@ uint32_t Tr2LightManager::InsertAtlasNode( std::vector& atlasNodes, u child1.width = atlasNodes[nodeId].width - width; child1.height = atlasNodes[nodeId].height; } - else + else { child0.x = atlasNodes[nodeId].x; child0.y = atlasNodes[nodeId].y; @@ -814,13 +814,13 @@ void Tr2LightManager::GetUnpackedShadowMapData( const PerLightData& lightData, u shadowMapOffsetY = lightData.ShadowMapping.shadowMapOffsetY << m_ShadowMap.m_atlasSettings.entryMinSizeLog2; } -Tr2GpuResourcePool::Texture Tr2LightManager::RenderRaytracedShadows( - Tr2RaytracingGeometry* geometry, - const Tr2TextureAL& depth, - const Tr2TextureAL& normal, - const CcpMath::Sphere* planets, - size_t planetCount, - Tr2GpuResourcePool& gpuResourcePool, +Tr2GpuResourcePool::Texture Tr2LightManager::RenderRaytracedShadows( + Tr2RaytracingGeometry* geometry, + const Tr2TextureAL& depth, + const Tr2TextureAL& normal, + const CcpMath::Sphere* planets, + size_t planetCount, + Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) { renderContext.AddGpuMarker( __FUNCTION__ ); diff --git a/trinity/Tr2LightManager.h b/trinity/Tr2LightManager.h index 8fcd62809..d89b55156 100644 --- a/trinity/Tr2LightManager.h +++ b/trinity/Tr2LightManager.h @@ -43,10 +43,10 @@ enum class ShadowQuality // lightManager.ResolveLightData(); // lightManager.UpdateLists(); // renderYourStuff(); -// Light manager GPU buffers are accessed through variable store with names +// Light manager GPU buffers are accessed through variable store with names // "LightBuffer" and "LightIndexBuffer". // -------------------------------------------------------------------------------------- -class Tr2LightManager: public Tr2DeviceResource +class Tr2LightManager : public Tr2DeviceResource { public: Tr2LightManager( const char* effectPath ); @@ -82,12 +82,11 @@ class Tr2LightManager: public Tr2DeviceResource uint16_t padding; } Raytracing; }; - }; struct ShadowMapAtlasSettings { - uint32_t actualTextureSize; // only updated once per frame. might be larger than size, as multiple eve space scenes might request different shadow qualities + uint32_t actualTextureSize; // only updated once per frame. might be larger than size, as multiple eve space scenes might request different shadow qualities uint32_t sizeLog2; uint32_t size; uint32_t entryMinSizeLog2; @@ -113,7 +112,7 @@ class Tr2LightManager: public Tr2DeviceResource ALResult UpdateLists( const Tr2TextureAL& depthMap, Tr2RenderContext& renderContext ); void SetVariableStore(); void AdjustLightCutoff( float lodFactor ); - + void SetShadowQuality( ShadowQuality shadowQuality, uint64_t frameCounter ); virtual void ReleaseResources( TriStorage s ); @@ -135,13 +134,13 @@ class Tr2LightManager: public Tr2DeviceResource ShadowQuality GetCurrentSpaceSceneShadowQuality(); - Tr2GpuResourcePool::Texture RenderRaytracedShadows( - Tr2RaytracingGeometry* geometry, - const Tr2TextureAL& depth, - const Tr2TextureAL& normal, - const CcpMath::Sphere* planets, - size_t planetCount, - Tr2GpuResourcePool& gpuResourcePool, + Tr2GpuResourcePool::Texture RenderRaytracedShadows( + Tr2RaytracingGeometry* geometry, + const Tr2TextureAL& depth, + const Tr2TextureAL& normal, + const CcpMath::Sphere* planets, + size_t planetCount, + Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); Tr2RaytracingPipelineStateManager* GetRaytracingPipelineManager(); Tr2RtShaderTableDescriptionAL* GetRaytracingShaderTableDesc(); @@ -194,7 +193,7 @@ class Tr2LightManager: public Tr2DeviceResource float m_adjustedCutoff; - uint32_t nextFrameShadowQuality; // bitmask, collecting ShadowQualities during the current frame + uint32_t nextFrameShadowQuality; // bitmask, collecting ShadowQualities during the current frame ShadowQuality m_currentSpaceSceneShadowQuality; uint64_t m_currentFrameCounter; @@ -205,7 +204,7 @@ class Tr2LightManager: public Tr2DeviceResource ShadowQuality m_qualityUsedByAtlas; } m_ShadowMap; - struct + struct { Tr2RaytracingPipelineStateManager m_pipelineManager; Tr2RtShaderTableDescriptionAL m_shaderTableDesc; diff --git a/trinity/Tr2LineGraph.cpp b/trinity/Tr2LineGraph.cpp index b7ba258df..2122cfbff 100644 --- a/trinity/Tr2LineGraph.cpp +++ b/trinity/Tr2LineGraph.cpp @@ -70,13 +70,14 @@ bool Tr2LineGraph::OnPrepareResources() if( vbSize ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN_VAL( m_vertexBuffer.Create( - 1, - vbSize, - Tr2GpuUsage::VERTEX_BUFFER, - Tr2CpuUsage::WRITE_OFTEN, - nullptr, - renderContext ), true ); + CR_RETURN_VAL( m_vertexBuffer.Create( + 1, + vbSize, + Tr2GpuUsage::VERTEX_BUFFER, + Tr2CpuUsage::WRITE_OFTEN, + nullptr, + renderContext ), + true ); } } @@ -88,7 +89,7 @@ bool Tr2LineGraph::OnPrepareResources() s_lineGraphEffect.CreateInstance(); s_lineGraphEffect->SetEffectPathName( LINEGRAPH_EFFECT_PATH ); } - + if( !m_vertexBuffer.IsValid() || m_vertexDeclaration == Tr2EffectStateManager::UNINITIALIZED_DECLARATION || !s_lineGraphEffect ) { return true; @@ -126,7 +127,7 @@ void Tr2LineGraph::Add( float value ) { if( !m_markers.empty() ) { - for( MarkerList_t::iterator it = m_markers.begin(); it != m_markers.end(); ) + for( MarkerList_t::iterator it = m_markers.begin(); it != m_markers.end(); ) { --it->m_ticksLeft; if( it->m_ticksLeft == 0 ) @@ -194,8 +195,8 @@ void Tr2LineGraph::Render( float scale, Tr2RenderContext& renderContext ) LineGraphVertex* pVertsEnd = pVerts + m_primitiveCount * 2; unsigned int count = (unsigned int)m_data.size(); - - float step = 2.0f / ((float)count - 1.0f); + + float step = 2.0f / ( (float)count - 1.0f ); float x = -1.0f; @@ -216,7 +217,7 @@ void Tr2LineGraph::Render( float scale, Tr2RenderContext& renderContext ) ++pVerts; pVerts->pos.x = x + step; - pVerts->pos.y = *(p + 1); + pVerts->pos.y = *( p + 1 ); ++pVerts; ++p; @@ -253,7 +254,7 @@ void Tr2LineGraph::Render( float scale, Tr2RenderContext& renderContext ) ++pVerts; pVerts->pos.x = x + step; - pVerts->pos.y = *(p + 1); + pVerts->pos.y = *( p + 1 ); ++pVerts; ++p; @@ -268,16 +269,16 @@ void Tr2LineGraph::Render( float scale, Tr2RenderContext& renderContext ) { Tr2Viewport viewport; renderContext.GetViewport( viewport ); - - int yiTop = (int)( 0.1f*(float)viewport.m_height ); - int yiBottom = (int)( 0.95f*(float)viewport.m_height ); + + int yiTop = (int)( 0.1f * (float)viewport.m_height ); + int yiBottom = (int)( 0.95f * (float)viewport.m_height ); int yi = yiTop; for( MarkerList_t::iterator it = m_markers.begin(); it != m_markers.end(); ++it ) { - float x = -1.0f + (float)(it->m_ticksLeft)*step; + float x = -1.0f + (float)( it->m_ticksLeft ) * step; - int xi = (int)( (x + 1.0f)*0.5f*(float)viewport.m_width ); + int xi = (int)( ( x + 1.0f ) * 0.5f * (float)viewport.m_width ); for( std::list::iterator valueIt = it->m_values.begin(); valueIt != it->m_values.end(); ++valueIt ) { Tr2Renderer::PrintfImmediate( renderContext, xi, yi, m_color, TRI_DFS_LEFT, valueIt->c_str() ); diff --git a/trinity/Tr2LineGraph.h b/trinity/Tr2LineGraph.h index b0f2e4f7e..8dabdc1d4 100644 --- a/trinity/Tr2LineGraph.h +++ b/trinity/Tr2LineGraph.h @@ -10,13 +10,12 @@ BLUE_DECLARE( Tr2LineGraph ); BLUE_DECLARE_VECTOR( Tr2LineGraph ); -class Tr2LineGraph: - public ICcpStatisticsAccumulator, - public Tr2DeviceResource +class Tr2LineGraph : public ICcpStatisticsAccumulator, + public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); - Tr2LineGraph( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2LineGraph( IRoot* lockobj = NULL ); virtual ~Tr2LineGraph(); // For saving stats out @@ -26,7 +25,7 @@ class Tr2LineGraph: void SetSize( unsigned int size ); const Color& GetColor() const; - void SetColor( const Color& val); + void SetColor( const Color& val ); const std::string& GetName() const; @@ -41,9 +40,9 @@ class Tr2LineGraph: // ICcpStatisticsAccumulator void Add( double value ); - ///////////////////////////////////////////////////////////////////////////// - // ITriDeviceResource - void ReleaseResources( TriStorage s ); + ///////////////////////////////////////////////////////////////////////////// + // ITriDeviceResource + void ReleaseResources( TriStorage s ); private: bool OnPrepareResources(); diff --git a/trinity/Tr2LineGraph_Blue.cpp b/trinity/Tr2LineGraph_Blue.cpp index cd01c2e38..0e6b855f5 100644 --- a/trinity/Tr2LineGraph_Blue.cpp +++ b/trinity/Tr2LineGraph_Blue.cpp @@ -7,39 +7,33 @@ BLUE_DEFINE( Tr2LineGraph ); const Be::ClassInfo* Tr2LineGraph::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2LineGraph, "" ) + EXPOSURE_BEGIN( Tr2LineGraph, "" ) MAP_INTERFACE( Tr2LineGraph ) MAP_INTERFACE( ICcpStatisticsAccumulator ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "name", m_name, "", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "color", m_color, "", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "AddMarker", - AddMarker, + MAP_METHOD_AND_WRAP( + "AddMarker", + AddMarker, "Adds a marker to the graph\n" - ":param name: marker name" - ); - MAP_METHOD_AND_WRAP( - "SetSize", - SetSize, - "Sets the size of the buffer of statistics\n" - ":param size: buffer size" - ) + ":param name: marker name" ); + MAP_METHOD_AND_WRAP( + "SetSize", + SetSize, + "Sets the size of the buffer of statistics\n" + ":param size: buffer size" ) MAP_METHOD_AND_WRAP( "GetStatsHistory", GetStatsHistory, "Gets a list of the statistics in the buffer" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2LineSet.cpp b/trinity/Tr2LineSet.cpp index eb6299652..37e8b638c 100644 --- a/trinity/Tr2LineSet.cpp +++ b/trinity/Tr2LineSet.cpp @@ -8,7 +8,7 @@ CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); using namespace Tr2RenderContextEnum; -Tr2LineSet::Tr2LineSet( IRoot* lockobj /*= NULL*/ ): +Tr2LineSet::Tr2LineSet( IRoot* lockobj /*= NULL*/ ) : Tr2PrimitiveSet( lockobj ), m_pickingVertexDeclHandle( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_maxCurrentTriangleCount( 0 ), @@ -90,8 +90,8 @@ bool Tr2LineSet::OnPrepareResources() Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, - renderContext ) - , false ); + renderContext ), + false ); m_currentSubmittedLineCount = (unsigned int)m_lines.size(); } @@ -102,7 +102,7 @@ bool Tr2LineSet::OnPrepareResources() void* vertexBuffer; CR_RETURN_VAL( m_vertexBuffer.MapForWriting( vertexBuffer, renderContext ), false ); - memcpy( vertexBuffer, &m_lines[0], sizeof( LineData ) * m_lines.size() ); + memcpy( vertexBuffer, &m_lines[0], sizeof( LineData ) * m_lines.size() ); m_vertexBuffer.UnmapForWriting( renderContext ); m_boundingSphere.x = center.x; @@ -111,10 +111,10 @@ bool Tr2LineSet::OnPrepareResources() m_boundingSphere.w = radius; } - + if( m_triangles.size() ) { - if( !m_pickingVertexBuffer.IsValid() || (m_currentSubmittedTriangleCount < m_triangles.size()) ) + if( !m_pickingVertexBuffer.IsValid() || ( m_currentSubmittedTriangleCount < m_triangles.size() ) ) { USE_MAIN_THREAD_RENDER_CONTEXT(); CR_RETURN_VAL( @@ -124,13 +124,13 @@ bool Tr2LineSet::OnPrepareResources() Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, - renderContext ) - , false ); + renderContext ), + false ); m_currentSubmittedTriangleCount = (unsigned int)m_triangles.size(); } void* vertexBuffer; CR_RETURN_VAL( m_pickingVertexBuffer.MapForWriting( vertexBuffer, renderContext ), false ); - memcpy( vertexBuffer, &m_triangles[0], sizeof( Triangle )*m_triangles.size() ); + memcpy( vertexBuffer, &m_triangles[0], sizeof( Triangle ) * m_triangles.size() ); m_pickingVertexBuffer.UnmapForWriting( renderContext ); } @@ -205,7 +205,7 @@ bool Tr2LineSet::SubmitChanges() { if( m_lines.size() > m_maxCurrentLineCount ) { - // increase the size of the buffer + // increase the size of the buffer m_maxCurrentLineCount = (unsigned int)m_lines.capacity(); if( m_triangles.size() > m_maxCurrentTriangleCount ) { @@ -221,7 +221,7 @@ bool Tr2LineSet::SubmitChanges() void Tr2LineSet::SetCurrentColor( Color& val ) { - for ( unsigned int i = 0; i < m_lines.size(); i++ ) + for( unsigned int i = 0; i < m_lines.size(); i++ ) { m_lines[i].m_color1 = val; m_lines[i].m_color2 = val; diff --git a/trinity/Tr2LineSet.h b/trinity/Tr2LineSet.h index ecd67f2e7..14e294790 100644 --- a/trinity/Tr2LineSet.h +++ b/trinity/Tr2LineSet.h @@ -23,9 +23,9 @@ struct Triangle Vector3 m_position3; }; -BLUE_CLASS( Tr2LineSet ): +BLUE_CLASS( Tr2LineSet ) : public IInitialize, - public Tr2PrimitiveSet, + public Tr2PrimitiveSet, public Tr2DeviceResource { public: @@ -37,12 +37,15 @@ BLUE_CLASS( Tr2LineSet ): ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); #if TRINITYDEV - virtual void GetDescription( std::string& desc ) { desc = ""; } + virtual void GetDescription( std::string & desc ) + { + desc = ""; + } #endif protected: @@ -51,24 +54,26 @@ BLUE_CLASS( Tr2LineSet ): std::vector m_lines; unsigned int m_maxCurrentLineCount; unsigned int m_currentSubmittedLineCount; - + // Picking geometry unsigned int m_pickingVertexDeclHandle; Tr2BufferAL m_pickingVertexBuffer; std::vector m_triangles; unsigned int m_maxCurrentTriangleCount; unsigned int m_currentSubmittedTriangleCount; + public: void AddPickingTriangle( const Vector3& position1, const Vector3& position2, const Vector3& position3 ); void AddLine( const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2 ); - void SetCurrentColor( Color& val ); + void SetCurrentColor( Color & val ); void ClearLines(); void ClearPickingTriangles(); bool SubmitChanges(); + private: virtual bool OnPrepareResources(); }; -TYPEDEF_BLUECLASS(Tr2LineSet); +TYPEDEF_BLUECLASS( Tr2LineSet ); #endif diff --git a/trinity/Tr2LineSet_Blue.cpp b/trinity/Tr2LineSet_Blue.cpp index fce0d8f40..f545bcc6c 100644 --- a/trinity/Tr2LineSet_Blue.cpp +++ b/trinity/Tr2LineSet_Blue.cpp @@ -14,30 +14,20 @@ const Be::ClassInfo* Tr2LineSet::ExposeToBlue() MAP_INTERFACE( Tr2PrimitiveSet ) MAP_INTERFACE( ITr2Pickable ) - MAP_METHOD_AND_WRAP( "AddPickingTriangle", AddPickingTriangle, - "(pos1, pos2, pos3)\n" - "Add a triangle to serve as a picking area for the lineset\n" - ":param pos1: \n" - ":param pos2: \n" - ":param pos3: \n" - ) - MAP_METHOD_AND_WRAP( "AddLine", AddLine, - "( startPosition, startColor, endPosition, endColor )\n" - "Adds a line to the line set, but does not submit it.\n" - ":param startPosition: line start position\n" - ":param startColor: line color at startPosition\n" - ":param endPosition: line end position\n" - ":param endColor: line color at endPosition\n" - ) - MAP_METHOD_AND_WRAP( "ClearLines", ClearLines, - "Clears all lines. Requires a call to SubmitChanges to complete." - ) - MAP_METHOD_AND_WRAP( "ClearPickingTriangles", ClearPickingTriangles, - "Clears all picking triangles. Requires a call to SubmitChanges to complete." - ) - MAP_METHOD_AND_WRAP( "SubmitChanges", SubmitChanges, - "Submits changes to the vertex buffer" - ) - - EXPOSURE_CHAINTO( Tr2PrimitiveSet ) + MAP_METHOD_AND_WRAP( "AddPickingTriangle", AddPickingTriangle, "(pos1, pos2, pos3)\n" + "Add a triangle to serve as a picking area for the lineset\n" + ":param pos1: \n" + ":param pos2: \n" + ":param pos3: \n" ) + MAP_METHOD_AND_WRAP( "AddLine", AddLine, "( startPosition, startColor, endPosition, endColor )\n" + "Adds a line to the line set, but does not submit it.\n" + ":param startPosition: line start position\n" + ":param startColor: line color at startPosition\n" + ":param endPosition: line end position\n" + ":param endColor: line color at endPosition\n" ) + MAP_METHOD_AND_WRAP( "ClearLines", ClearLines, "Clears all lines. Requires a call to SubmitChanges to complete." ) + MAP_METHOD_AND_WRAP( "ClearPickingTriangles", ClearPickingTriangles, "Clears all picking triangles. Requires a call to SubmitChanges to complete." ) + MAP_METHOD_AND_WRAP( "SubmitChanges", SubmitChanges, "Submits changes to the vertex buffer" ) + + EXPOSURE_CHAINTO( Tr2PrimitiveSet ) } \ No newline at end of file diff --git a/trinity/Tr2ManipulationTool.cpp b/trinity/Tr2ManipulationTool.cpp index 3307b1577..4c5cdbfb5 100644 --- a/trinity/Tr2ManipulationTool.cpp +++ b/trinity/Tr2ManipulationTool.cpp @@ -11,12 +11,12 @@ const Vector4 v4Blue( 0.01f, 0.01f, 1.0f, 1.0f ); const Vector4 v4Cyan( 0.0f, 1.0f, 1.0f, 1.0f ); const Vector4 v4Yellow( 1.0f, 1.0f, 0.01f, 1.0f ); const Vector4 v4LightGray( 0.5f, 0.5f, 0.5f, 1.0f ); -const Vector3 v3Zero(0.0f, 0.0f, 0.0f); -const Vector3 v3X(1.0f, 0.0f, 0.0f); -const Vector3 v3Y(0.0f, 1.0f, 0.0f); -const Vector3 v3Z(0.0f, 0.0f, 1.0f); +const Vector3 v3Zero( 0.0f, 0.0f, 0.0f ); +const Vector3 v3X( 1.0f, 0.0f, 0.0f ); +const Vector3 v3Y( 0.0f, 1.0f, 0.0f ); +const Vector3 v3Z( 0.0f, 0.0f, 1.0f ); -Tr2ManipulationTool::Tr2ManipulationTool( IRoot* lockobj ): +Tr2ManipulationTool::Tr2ManipulationTool( IRoot* lockobj ) : PARENTLOCK( m_primitives ), #if BLUE_WITH_PYTHON m_pythonUserData( NULL ), @@ -44,7 +44,7 @@ bool Tr2ManipulationTool::OnMoveCallback( Matrix& currentTransform, Matrix& next if( m_callback ) { - // Pass in the current and next position of the tools so the + // Pass in the current and next position of the tools so the // user can choose if that is a legal move m_callback.Call( returnValue, currentTransform, nextTransform ); } @@ -58,7 +58,7 @@ void Tr2ManipulationTool::GetBaseVectors( Vector3& x, Vector3& y, Vector3& z ) z = Normalize( Vector3( m_localTransform._31, m_localTransform._32, m_localTransform._33 ) ); } -Vector3 Tr2ManipulationTool::GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMatrix) +Vector3 Tr2ManipulationTool::GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMatrix ) { // What is the best plane to work on when moving the tool // Since the eye could lie on one of the valid planes @@ -66,47 +66,47 @@ Vector3 Tr2ManipulationTool::GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMa Vector3 yAxis; Vector3 zAxis; GetBaseVectors( xAxis, yAxis, zAxis ); - if( m_selectedAxis == "x") + if( m_selectedAxis == "x" ) { - // We dont care on wich side we are.. just the distance - float ydot = fabs( Dot( ray, yAxis ) ); // XZ plane - float zdot = fabs( Dot( ray, zAxis ) ); // XY plane + // We dont care on wich side we are.. just the distance + float ydot = fabs( Dot( ray, yAxis ) ); // XZ plane + float zdot = fabs( Dot( ray, zAxis ) ); // XY plane - if( zdot > ydot ) + if( zdot > ydot ) { - return zAxis; + return zAxis; } else { - return yAxis; + return yAxis; } } - else if( m_selectedAxis == "y") + else if( m_selectedAxis == "y" ) { - float zdot = fabs( Dot( ray, zAxis ) ); // YX plane - float xdot = fabs( Dot( ray, xAxis ) ); // YZ plane + float zdot = fabs( Dot( ray, zAxis ) ); // YX plane + float xdot = fabs( Dot( ray, xAxis ) ); // YZ plane - if( zdot > xdot ) + if( zdot > xdot ) { - return zAxis; + return zAxis; } else { - return xAxis; + return xAxis; } } - else if( m_selectedAxis == "z") + else if( m_selectedAxis == "z" ) { - float xdot = fabs( Dot( ray, xAxis ) ); // ZY plane - float ydot = fabs( Dot( ray, yAxis ) ); // ZX plane + float xdot = fabs( Dot( ray, xAxis ) ); // ZY plane + float ydot = fabs( Dot( ray, yAxis ) ); // ZX plane - if( xdot > ydot ) + if( xdot > ydot ) { - return xAxis; + return xAxis; } else { - return yAxis; + return yAxis; } } else @@ -138,17 +138,17 @@ int Tr2ManipulationTool::RayToSphereIntersection( Vector3& spCenter, float radiu Vector3 pMinusC = startPoint - spCenter; float dotA = Dot( ray, ray ); float dotB = 2.0f * Dot( ray, pMinusC ); - float dotC = Dot( pMinusC, pMinusC ) - (radius*radius); - float discrim = dotB*dotB - 4.0f * dotA * dotC; + float dotC = Dot( pMinusC, pMinusC ) - ( radius * radius ); + float discrim = dotB * dotB - 4.0f * dotA * dotC; if( discrim > 0.0f ) { - outValues.x = ( -dotB + sqrt( discrim ) )/( 2.0f * dotA ); - outValues.y = ( -dotB - sqrt( discrim ) )/( 2.0f * dotA ); + outValues.x = ( -dotB + sqrt( discrim ) ) / ( 2.0f * dotA ); + outValues.y = ( -dotB - sqrt( discrim ) ) / ( 2.0f * dotA ); return 2; } - else if ( discrim == 0.0f ) + else if( discrim == 0.0f ) { - outValues.x = -dotB /( 2.0f * dotA ); + outValues.x = -dotB / ( 2.0f * dotA ); outValues.y = 0.0f; return 1; } @@ -158,7 +158,7 @@ int Tr2ManipulationTool::RayToSphereIntersection( Vector3& spCenter, float radiu } } -Vector3 Tr2ManipulationTool::RayToPlaneIntersection(Vector3& P, Vector3& d, Vector3& Q, Vector3& n) +Vector3 Tr2ManipulationTool::RayToPlaneIntersection( Vector3& P, Vector3& d, Vector3& Q, Vector3& n ) { float denom = Dot( n, d ); if( fabs( denom ) < FLT_EPSILON ) @@ -180,9 +180,9 @@ void Tr2ManipulationTool::ScreenCoordinatesToRay( int x, int y, Vector3& outRay, XMMATRIX invP = XMMatrixInverse( &det, projectionMatrix ); XMMATRIX invV = XMMatrixInverse( &det, viewMatrix ); - Vector3 start ( 2.0f * float( x - viewport.m_x ) / viewport.m_width - 1.0f, - -2.0f * float( y - viewport.m_y ) / viewport.m_height + 1.0f, - 0 ); + Vector3 start( 2.0f * float( x - viewport.m_x ) / viewport.m_width - 1.0f, + -2.0f * float( y - viewport.m_y ) / viewport.m_height + 1.0f, + 0 ); XMVECTOR vStart = XMVector3TransformCoord( start, invP ); outStart = XMVector3TransformCoord( vStart, invV ); @@ -203,8 +203,8 @@ void Tr2ManipulationTool::PointToScreenCoordinates( Vector3& inPoint, Vector2& o Vector4 out = Vector4( inPoint.x, inPoint.y, inPoint.z, 1 ) * viewMatrix; out = out * projectionMatrix; - - outPoint.x = viewport.m_x + viewport.m_width * ( 0.5f + 0.5f * out.x / out.w ); + + outPoint.x = viewport.m_x + viewport.m_width * ( 0.5f + 0.5f * out.x / out.w ); outPoint.y = viewport.m_y + viewport.m_height * ( 0.5f - 0.5f * out.y / out.w ); } @@ -213,38 +213,38 @@ void Tr2ManipulationTool::SelectAxis( std::string axisName ) bool validName = false; for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == axisName ) + if( ( *it )->m_name == axisName ) { validName = true; } } - if(!validName) + if( !validName ) return; ResetPrimitiveColors(); for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == axisName ) + if( ( *it )->m_name == axisName ) { - (*it)->SetCurrentColor((Color&)v4Yellow); + ( *it )->SetCurrentColor( (Color&)v4Yellow ); } } m_selectedAxis = axisName; } // Utility functions for creating geometry to either render or to act as a collision geometry -Vector3* Tr2ManipulationTool::GetTrianglesAroundLine( const Vector3 &start, const Vector3 &end, float radius, int* numVectors ) +Vector3* Tr2ManipulationTool::GetTrianglesAroundLine( const Vector3& start, const Vector3& end, float radius, int* numVectors ) { Vector3* outTriangles = new Vector3[18]; *numVectors = 18; - float rad = XM_PI*2.0f/3.0f; - Vector3 triangle1[3] = {Vector3( radius, 0.0f, 0.0f ), - Vector3( cos( rad ) * radius, sin( rad ) * radius, 0.0f ), - Vector3( cos( 2.0f * rad ) * radius, sin( 2.0f * rad ) * radius, 0.0f )}; + float rad = XM_PI * 2.0f / 3.0f; + Vector3 triangle1[3] = { Vector3( radius, 0.0f, 0.0f ), + Vector3( cos( rad ) * radius, sin( rad ) * radius, 0.0f ), + Vector3( cos( 2.0f * rad ) * radius, sin( 2.0f * rad ) * radius, 0.0f ) }; Vector3 dirOfLine; - Vector3 zDir(0.0f, 0.0f, 1.0f); + Vector3 zDir( 0.0f, 0.0f, 1.0f ); Quaternion rotation = IdentityQuaternion(); Vector3 temp; dirOfLine = Normalize( start - end ); @@ -259,10 +259,10 @@ Vector3* Tr2ManipulationTool::GetTrianglesAroundLine( const Vector3 &start, cons rot = RotationMatrix( rotation ); t1 = TranslationMatrix( start ); t2 = TranslationMatrix( end ); - + compA = rot * t1; compB = rot * t2; - + Vector3 startTri[3]; Vector3 endTri[3]; @@ -299,19 +299,19 @@ Vector3* Tr2ManipulationTool::GetTrianglesAroundLine( const Vector3 &start, cons Vector3* Tr2ManipulationTool::GetConeTriangles( float height, float width, int subd, int* numVectors ) { Vector3 top( 0.0f, height, 0.0f ); - float rad = XM_PI/(subd*0.5f); - int numVerts = subd*6; + float rad = XM_PI / ( subd * 0.5f ); + int numVerts = subd * 6; Vector3* triangles = new Vector3[numVerts]; *numVectors = numVerts; for( int i = 0; i < subd; i++ ) { - int offset = 6*i; + int offset = 6 * i; triangles[offset] = top; - triangles[offset+1] = Vector3( cos( ( i + 1 ) * rad ) * width, 0.0f, sin( ( i + 1 ) * rad ) * width ); - triangles[offset+2] = Vector3( cos( i * rad ) * width, 0.0f, sin( i * rad ) * width ); - triangles[offset+3] = Vector3( cos( ( i + 1 ) * rad ) * width, 0.0f, sin( ( i + 1 ) * rad ) * width ); - triangles[offset+4] = Vector3( 0.0f, 0.0f, 0.0f ); - triangles[offset+5] = Vector3( cos( i * rad ) * width, 0.0f, sin( i * rad ) * width ); + triangles[offset + 1] = Vector3( cos( ( i + 1 ) * rad ) * width, 0.0f, sin( ( i + 1 ) * rad ) * width ); + triangles[offset + 2] = Vector3( cos( i * rad ) * width, 0.0f, sin( i * rad ) * width ); + triangles[offset + 3] = Vector3( cos( ( i + 1 ) * rad ) * width, 0.0f, sin( ( i + 1 ) * rad ) * width ); + triangles[offset + 4] = Vector3( 0.0f, 0.0f, 0.0f ); + triangles[offset + 5] = Vector3( cos( i * rad ) * width, 0.0f, sin( i * rad ) * width ); } return triangles; } @@ -326,18 +326,42 @@ Vector3* Tr2ManipulationTool::GetBoxTriangles( const Vector3& min, const Vector3 Vector3 maxC( min.x, min.y, max.z ); Vector3* triangles = new Vector3[36]; *numVectors = 36; - triangles[0] = maxA;triangles[1] = max;triangles[2] = maxB; - triangles[3] = maxA;triangles[4] = maxB;triangles[5] = maxC; - triangles[6] = maxC;triangles[7] = maxB;triangles[8] = min; - triangles[9] = min;triangles[10] = maxB;triangles[11] = minB; - triangles[12] = min;triangles[13] = minB;triangles[14] = minA; - triangles[15] = minA;triangles[16] = minB;triangles[17] = minC; - triangles[18] = minA;triangles[19] = minC;triangles[20] = max; - triangles[21] = minA;triangles[22] = max;triangles[23] = maxA; - triangles[24] = maxA;triangles[25] = min;triangles[26] = minA; - triangles[27] = maxA;triangles[28] = maxC;triangles[29] = min; - triangles[30] = max;triangles[31] = minC;triangles[32] = minB; - triangles[33] = max;triangles[34] = minB;triangles[35] = maxB; + triangles[0] = maxA; + triangles[1] = max; + triangles[2] = maxB; + triangles[3] = maxA; + triangles[4] = maxB; + triangles[5] = maxC; + triangles[6] = maxC; + triangles[7] = maxB; + triangles[8] = min; + triangles[9] = min; + triangles[10] = maxB; + triangles[11] = minB; + triangles[12] = min; + triangles[13] = minB; + triangles[14] = minA; + triangles[15] = minA; + triangles[16] = minB; + triangles[17] = minC; + triangles[18] = minA; + triangles[19] = minC; + triangles[20] = max; + triangles[21] = minA; + triangles[22] = max; + triangles[23] = maxA; + triangles[24] = maxA; + triangles[25] = min; + triangles[26] = minA; + triangles[27] = maxA; + triangles[28] = maxC; + triangles[29] = min; + triangles[30] = max; + triangles[31] = minC; + triangles[32] = minB; + triangles[33] = max; + triangles[34] = minB; + triangles[35] = maxB; return triangles; } @@ -345,39 +369,39 @@ Vector3* Tr2ManipulationTool::GetBoxTriangles( const Vector3& min, const Vector3 Vector3* Tr2ManipulationTool::GetCircleTriangles( float radius, int subd, int* numVectors ) { Vector3 top( radius, 0.0f, 0.0f ); - float rad = XM_PI/(subd*0.5f); - int numVerts = subd*3; + float rad = XM_PI / ( subd * 0.5f ); + int numVerts = subd * 3; Vector3* verts = new Vector3[numVerts]; *numVectors = numVerts; for( int i = 0; i < subd; i++ ) { - int offset = 3*i; + int offset = 3 * i; verts[offset] = top; - verts[offset+1] = Vector3( cos( i * rad ) * radius, sin( i * rad ) * radius, 0.0f ); - verts[offset+2] = Vector3( cos( ( i + 1 ) * rad ) * radius, sin( ( i + 1 ) * rad ) * radius, 0.0f ); + verts[offset + 1] = Vector3( cos( i * rad ) * radius, sin( i * rad ) * radius, 0.0f ); + verts[offset + 2] = Vector3( cos( ( i + 1 ) * rad ) * radius, sin( ( i + 1 ) * rad ) * radius, 0.0f ); } return verts; } Vector3* Tr2ManipulationTool::GetCirclePoints( float radius, int subd, int* numVectors ) { - float rad = XM_PI/(subd*0.5f); - int numVerts = subd*2; + float rad = XM_PI / ( subd * 0.5f ); + int numVerts = subd * 2; Vector3* verts = new Vector3[numVerts]; *numVectors = numVerts; for( int i = 0; i < subd; i++ ) { - int offset = 2*i; + int offset = 2 * i; verts[offset] = Vector3( cos( i * rad ) * radius, sin( i * rad ) * radius, 0.0f ); - verts[offset+1] = Vector3( cos( ( i + 1 ) * rad ) * radius, sin( ( i + 1 ) * rad ) * radius, 0.0f ); + verts[offset + 1] = Vector3( cos( ( i + 1 ) * rad ) * radius, sin( ( i + 1 ) * rad ) * radius, 0.0f ); } return verts; } -void Tr2ManipulationTool::PyMove( - int x, - int y, - int dx, +void Tr2ManipulationTool::PyMove( + int x, + int y, + int dx, int dy, TriViewport* viewport, Matrix view, @@ -389,12 +413,12 @@ void Tr2ManipulationTool::PyMove( } Tr2Viewport d3dviewport; - d3dviewport.m_x = (float)viewport->x; - d3dviewport.m_y = (float)viewport->y; - d3dviewport.m_width = (float)viewport->width; - d3dviewport.m_height = (float)viewport->height; - d3dviewport.m_minZ = viewport->minZ; - d3dviewport.m_maxZ = viewport->maxZ; + d3dviewport.m_x = (float)viewport->x; + d3dviewport.m_y = (float)viewport->y; + d3dviewport.m_width = (float)viewport->width; + d3dviewport.m_height = (float)viewport->height; + d3dviewport.m_minZ = viewport->minZ; + d3dviewport.m_maxZ = viewport->maxZ; Move( x, y, dx, dy, d3dviewport, view, proj ); } diff --git a/trinity/Tr2ManipulationTool.h b/trinity/Tr2ManipulationTool.h index 36f0caa1c..02cdb04a7 100644 --- a/trinity/Tr2ManipulationTool.h +++ b/trinity/Tr2ManipulationTool.h @@ -21,28 +21,28 @@ extern const Vector3 v3X; extern const Vector3 v3Y; extern const Vector3 v3Z; -BLUE_CLASS( Tr2ManipulationTool ): - public IRoot +BLUE_CLASS( Tr2ManipulationTool ) : + public IRoot { public: - EXPOSE_TO_BLUE(); - Tr2ManipulationTool( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2ManipulationTool( IRoot* lockobj = NULL ); ~Tr2ManipulationTool(); // typedef to shorten the iterator declaration typedef Tr2PrimitiveSetVector::const_iterator PrimitiveIterator; PTr2PrimitiveSetVector m_primitives; - // The actual interface all the tools must impliment + // The actual interface all the tools must impliment virtual void Update() = 0; virtual void GenLineSets() = 0; virtual void ResetPrimitiveColors() = 0; - virtual std::vector& GetPrimitivesToRender( ) = 0; + virtual std::vector& GetPrimitivesToRender() = 0; virtual void Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ) = 0; // Callback for when the gizmo is being moved ( currentValue, nextValue ) BlueScriptCallback m_callback; - bool OnMoveCallback( Matrix& currentTransform, Matrix& nextTransform ); + bool OnMoveCallback( Matrix & currentTransform, Matrix & nextTransform ); // An optional pivot that controls the center point Vector3 m_pivot; @@ -52,41 +52,44 @@ BLUE_CLASS( Tr2ManipulationTool ): // Intermediate output Vector3 m_movement; - bool m_moved; + bool m_moved; #if BLUE_WITH_PYTHON // for latching on any python objects that might be of use to the programmers - PyObject* m_pythonUserData; + PyObject* m_pythonUserData; #endif // What is selected - std::string m_selectedAxis; - void SelectAxis( std::string axisName ); + std::string m_selectedAxis; + void SelectAxis( std::string axisName ); // Captured - bool m_captured; + bool m_captured; // The vector of primitives to actually render std::vector m_visibleObjects; - virtual void Init( Matrix& initialTransform ) { m_localTransform = initialTransform; } + virtual void Init( Matrix & initialTransform ) + { + m_localTransform = initialTransform; + } // Utility functions - virtual Vector3 GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMatrix ); - void GetBaseVectors( Vector3& x, Vector3& y, Vector3& z ); + virtual Vector3 GetDesiredPlaneNormal( Vector3 & ray, Matrix & viewMatrix ); + void GetBaseVectors( Vector3 & x, Vector3 & y, Vector3 & z ); Vector3 MovePointOnPlane( int mx1, int my1, int mx2, int my2, Vector3& pointOnPlane, Vector3& planeNormal, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); - int RayToSphereIntersection( Vector3& spCenter, float radius, Vector3& startPoint, Vector3& ray, Vector3& outValues ); - Vector3 RayToPlaneIntersection(Vector3& P, Vector3& d, Vector3& Q, Vector3& n); + int RayToSphereIntersection( Vector3 & spCenter, float radius, Vector3& startPoint, Vector3& ray, Vector3& outValues ); + Vector3 RayToPlaneIntersection( Vector3 & P, Vector3 & d, Vector3 & Q, Vector3 & n ); void ScreenCoordinatesToRay( int x, int y, Vector3& outRay, Vector3& outStart, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); - void PointToScreenCoordinates( Vector3& inPoint, Vector2& outPoint, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); - - static Vector3* GetTrianglesAroundLine( const Vector3 &start, const Vector3 &end, float radius, int* numVectors ); - static Vector3* GetConeTriangles( float height, float width, int subd, int* numVectors); + void PointToScreenCoordinates( Vector3 & inPoint, Vector2 & outPoint, Tr2Viewport & viewport, Matrix & viewMatrix, Matrix & projectionMatrix ); + + static Vector3* GetTrianglesAroundLine( const Vector3& start, const Vector3& end, float radius, int* numVectors ); + static Vector3* GetConeTriangles( float height, float width, int subd, int* numVectors ); static Vector3* GetBoxTriangles( const Vector3& min, const Vector3& max, int* numVectors ); static Vector3* GetCircleTriangles( float radius, int subd, int* numVectors ); static Vector3* GetCirclePoints( float radius, int subd, int* numVectors ); - void PyMove( - int x, - int y, - int dx, + void PyMove( + int x, + int y, + int dx, int dy, TriViewport* viewport, Matrix view, diff --git a/trinity/Tr2ManipulationTool_Blue.cpp b/trinity/Tr2ManipulationTool_Blue.cpp index 5336097c4..01d56d026 100644 --- a/trinity/Tr2ManipulationTool_Blue.cpp +++ b/trinity/Tr2ManipulationTool_Blue.cpp @@ -8,60 +8,34 @@ BLUE_DEFINE_ABSTRACT( Tr2ManipulationTool ); const Be::ClassInfo* Tr2ManipulationTool::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ManipulationTool, "" ) - MAP_INTERFACE( Tr2ManipulationTool ) - MAP_METHOD_AND_WRAP( "Init", Init, - "( transform )\n" - "Initilize the tool to the defaults and apply the base transform to work with.\n" - "Also the starting mouse position which is needed for the trackball rotation.\n" - ":param transform: transform matrix" - ) - MAP_ATTRIBUTE( "captured", m_captured, - "Is the tool captured. Being used", - Be::READWRITE - ) - MAP_ATTRIBUTE( "pivot", m_pivot, - "The manipulation tools pivot", - Be::READWRITE - ) - MAP_ATTRIBUTE( "localTransform", m_localTransform, - "The manipulation tools local transform", - Be::READWRITE| Be::PERSIST - ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, - "The manipulation tools world transform", - Be::READ - ) - MAP_ATTRIBUTE( "primitives", m_primitives, - "List of primitives this tool will render", - Be::READ - ) + EXPOSURE_BEGIN( Tr2ManipulationTool, "" ) + MAP_INTERFACE( Tr2ManipulationTool ) + MAP_METHOD_AND_WRAP( "Init", Init, "( transform )\n" + "Initilize the tool to the defaults and apply the base transform to work with.\n" + "Also the starting mouse position which is needed for the trackball rotation.\n" + ":param transform: transform matrix" ) + MAP_ATTRIBUTE( "captured", m_captured, "Is the tool captured. Being used", Be::READWRITE ) + MAP_ATTRIBUTE( "pivot", m_pivot, "The manipulation tools pivot", Be::READWRITE ) + MAP_ATTRIBUTE( "localTransform", m_localTransform, "The manipulation tools local transform", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "The manipulation tools world transform", Be::READ ) + MAP_ATTRIBUTE( "primitives", m_primitives, "List of primitives this tool will render", Be::READ ) #if BLUE_WITH_PYTHON - MAP_ATTRIBUTE( "_userData", m_pythonUserData, - "Pure python user data attached to the primitive set", - Be::READWRITE - ) + MAP_ATTRIBUTE( "_userData", m_pythonUserData, "Pure python user data attached to the primitive set", Be::READWRITE ) #endif - MAP_METHOD_AND_WRAP( "SelectAxis", SelectAxis, - "( name )\n" - "Set a particular primitive or axis as selected\n" - ":param name: axis name" - ) - MAP_METHOD_AND_WRAP( "Move", PyMove, - "( x, y, dx, dy, viewport, viewmatrix, projectionmatrix )\n" - "Move the manipulator based on mouse and mouse delta values and matrices\n" - ":param x: \n" - ":param y: \n" - ":param dx: \n" - ":param dy: \n" - ":param viewport: \n" - ":param view: \n" - ":param projection: \n" - ) - MAP_METHOD_AND_WRAP( "SetMoveCallback", SetMoveCallback, - "( callable )\n" - "Add a python callable that accepts two arguments.\n" - ":param cb: callback function" - ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP( "SelectAxis", SelectAxis, "( name )\n" + "Set a particular primitive or axis as selected\n" + ":param name: axis name" ) + MAP_METHOD_AND_WRAP( "Move", PyMove, "( x, y, dx, dy, viewport, viewmatrix, projectionmatrix )\n" + "Move the manipulator based on mouse and mouse delta values and matrices\n" + ":param x: \n" + ":param y: \n" + ":param dx: \n" + ":param dy: \n" + ":param viewport: \n" + ":param view: \n" + ":param projection: \n" ) + MAP_METHOD_AND_WRAP( "SetMoveCallback", SetMoveCallback, "( callable )\n" + "Add a python callable that accepts two arguments.\n" + ":param cb: callback function" ) + EXPOSURE_END() } diff --git a/trinity/Tr2MaterialParameterStore.cpp b/trinity/Tr2MaterialParameterStore.cpp index 8ef4217be..c4cef4ed7 100644 --- a/trinity/Tr2MaterialParameterStore.cpp +++ b/trinity/Tr2MaterialParameterStore.cpp @@ -5,7 +5,7 @@ #include "Tr2MaterialParameterStore.h" // -------------------------------------------------------------------------------------- -Tr2MaterialParameterStore::Tr2MaterialParameterStore( IRoot* lockobj ): +Tr2MaterialParameterStore::Tr2MaterialParameterStore( IRoot* lockobj ) : PARENTLOCK( m_parameters ) { } @@ -41,12 +41,11 @@ void Tr2MaterialParameterStore::LoadParentResource() m_parentStore.Unlock(); m_parentStore = NULL; - - if (m_parentPath.size() > 0) + + if( m_parentPath.size() > 0 ) { m_parentStore = BeResMan->LoadObject( m_parentPath.c_str() ); } - } // -------------------------------------------------------------------------------------- @@ -55,7 +54,7 @@ void Tr2MaterialParameterStore::LoadParentResource() // -------------------------------------------------------------------------------------- ITriEffectParameter* Tr2MaterialParameterStore::FindParameter( const char* name ) { - Tr2MaterialParameterStore *currentStore = this; + Tr2MaterialParameterStore* currentStore = this; while( currentStore != NULL ) { diff --git a/trinity/Tr2MaterialParameterStore.h b/trinity/Tr2MaterialParameterStore.h index cdb7b27ab..0ea417394 100644 --- a/trinity/Tr2MaterialParameterStore.h +++ b/trinity/Tr2MaterialParameterStore.h @@ -15,9 +15,8 @@ BLUE_DECLARE( Tr2MaterialParameterStore ); // a parent's selection of material parameters // -------------------------------------------------------------------------------------- -class Tr2MaterialParameterStore: - public IInitialize, - public INotify +class Tr2MaterialParameterStore : public IInitialize, + public INotify { public: Tr2MaterialParameterStore( IRoot* lockobj = NULL ); @@ -25,11 +24,11 @@ class Tr2MaterialParameterStore: EXPOSE_TO_BLUE(); - ITriEffectParameter* FindParameter( const char* name ); - + ITriEffectParameter* FindParameter( const char* name ); - using IInitialize::Lock; - using IInitialize::Unlock; + + using IInitialize::Lock; + using IInitialize::Unlock; ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -44,20 +43,19 @@ class Tr2MaterialParameterStore: protected: // The name of this material - std::string m_name; + std::string m_name; // Optionally the path to a parent material we derive from - std::string m_parentPath; + std::string m_parentPath; // The pointer to the parent material, if loaded - Tr2MaterialParameterStorePtr m_parentStore; + Tr2MaterialParameterStorePtr m_parentStore; // Our local overrides - PITriEffectParameterDict m_parameters; + PITriEffectParameterDict m_parameters; }; TYPEDEF_BLUECLASS( Tr2MaterialParameterStore ); BLUE_DECLARE_VECTOR( Tr2MaterialParameterStore ); #endif - diff --git a/trinity/Tr2MaterialParameterStore_Blue.cpp b/trinity/Tr2MaterialParameterStore_Blue.cpp index 96ef86d2d..618ab6f1a 100644 --- a/trinity/Tr2MaterialParameterStore_Blue.cpp +++ b/trinity/Tr2MaterialParameterStore_Blue.cpp @@ -11,16 +11,15 @@ const Be::ClassInfo* Tr2MaterialParameterStore::ExposeToBlue() MAP_INTERFACE( INotify ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( Tr2MaterialParameterStore ) - MAP_ATTRIBUTE( "name", m_name, "The name of the material", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "parentPath", m_parentPath, "The path to our parent material", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "parent", m_parentStore, "The materialStore we derive from", Be::READ ) + MAP_ATTRIBUTE( "name", m_name, "The name of the material", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "parentPath", m_parentPath, "The path to our parent material", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "parent", m_parentStore, "The materialStore we derive from", Be::READ ) MAP_ATTRIBUTE( "parameters", m_parameters, "The shader parameters of this instance", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "FindParameter", - FindParameter, - "Finds the parameter in this or the parent's store. Returns None if not found\n" - ":param name: parameter name" - ) + MAP_METHOD_AND_WRAP( + "FindParameter", + FindParameter, + "Finds the parameter in this or the parent's store. Returns None if not found\n" + ":param name: parameter name" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2Mesh.cpp b/trinity/Tr2Mesh.cpp index 3acdb9409..88f181f50 100644 --- a/trinity/Tr2Mesh.cpp +++ b/trinity/Tr2Mesh.cpp @@ -49,7 +49,7 @@ bool Tr2Mesh::OnModified( Be::Var* value ) Initialize(); } } - else if ( IsMatch(value, m_meshIndex) ) + else if( IsMatch( value, m_meshIndex ) ) { InitializeMorphTargets(); } @@ -155,7 +155,7 @@ void Tr2Mesh::InitializeMorphTargets() std::vector& morphTargetNames = *names; bool clearSerializedData = false; - if ( morphTargetNames.size() == m_serializedMorphAnimations.size() ) + if( morphTargetNames.size() == m_serializedMorphAnimations.size() ) { for( int32_t i = 0; i < morphTargetNames.size(); i++ ) { @@ -170,7 +170,7 @@ void Tr2Mesh::InitializeMorphTargets() { clearSerializedData = true; } - if ( clearSerializedData ) + if( clearSerializedData ) { m_serializedMorphAnimations.Clear(); for( int32_t i = 0; i < morphTargetNames.size(); i++ ) @@ -182,7 +182,7 @@ void Tr2Mesh::InitializeMorphTargets() m_serializedMorphAnimations.Append( serializedWeight ); } } - + for( int32_t i = 0; i < morphTargetNames.size(); i++ ) { m_morphAnimations[morphTargetNames[i]] = Tr2MorphTargetAnimationData( i, m_serializedMorphAnimations[i]->m_weight ); @@ -323,7 +323,7 @@ void Tr2Mesh::SetBakedMorphTarget( const char* name, bool isBaked ) for( int i = 0; i < mesh->m_morphTargetNames.size(); i++ ) { - if(mesh->m_morphTargetNames[i] == name) + if( mesh->m_morphTargetNames[i] == name ) { mesh->m_isBakedMorphTarget[i] = isBaked; return; diff --git a/trinity/Tr2Mesh.h b/trinity/Tr2Mesh.h index b7f4f08dc..d0797b40a 100644 --- a/trinity/Tr2Mesh.h +++ b/trinity/Tr2Mesh.h @@ -16,8 +16,9 @@ BLUE_CLASS( Tr2SerializedMorphAnimation ) : public: EXPOSE_TO_BLUE(); - Tr2SerializedMorphAnimation( IRoot* lockobj = NULL ) : m_weight( 0.f ) {}; - ~Tr2SerializedMorphAnimation() {}; + Tr2SerializedMorphAnimation( IRoot* lockobj = NULL ) : + m_weight( 0.f ){}; + ~Tr2SerializedMorphAnimation(){}; std::string m_name; float m_weight; @@ -27,7 +28,7 @@ TYPEDEF_BLUECLASS( Tr2SerializedMorphAnimation ); BLUE_DECLARE_VECTOR( Tr2SerializedMorphAnimation ); -BLUE_CLASS( Tr2Mesh ): +BLUE_CLASS( Tr2Mesh ) : public Tr2MeshBase, public IInitialize, public INotify, @@ -41,22 +42,25 @@ BLUE_CLASS( Tr2Mesh ): using IInitialize::Lock; using IInitialize::Unlock; - - const char* GetMeshResPath() const { return m_meshResPath.c_str(); } + + const char* GetMeshResPath() const + { + return m_meshResPath.c_str(); + } void SetMeshResPath( const char* path ); const char* GetLowResMeshResPath() const; void SetLowResMeshResPath( const char* path ); TriGeometryRes* GetGeometryResource() const override; - void SetGeometryRes( TriGeometryRes* res ); + void SetGeometryRes( TriGeometryRes * res ); bool IsLoading() const override; void ReverseIndexBuffers() override; ///////////////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ///////////////////////////////////////////////////////////////////////////////////// // IInitialize @@ -64,8 +68,8 @@ BLUE_CLASS( Tr2Mesh ): ///////////////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget - virtual void ReleaseCachedData( BlueAsyncRes* p ); - virtual void RebuildCachedData( BlueAsyncRes* p ); + virtual void ReleaseCachedData( BlueAsyncRes * p ); + virtual void RebuildCachedData( BlueAsyncRes * p ); std::vector* GetMorphTargetNames() const override; bool IsBakedMorph( int index ) const override; @@ -81,7 +85,7 @@ BLUE_CLASS( Tr2Mesh ): void InitializeMorphTargets(); - void PySetGeometryRes( TriGeometryRes* geometryRes ); + void PySetGeometryRes( TriGeometryRes * geometryRes ); int GetAreasCount() const; void SetLowResGeometryRes( TriGeometryRes * res ); diff --git a/trinity/Tr2MeshArea.cpp b/trinity/Tr2MeshArea.cpp index 7069d3389..d4b456bf5 100644 --- a/trinity/Tr2MeshArea.cpp +++ b/trinity/Tr2MeshArea.cpp @@ -8,10 +8,10 @@ #include "ITr2TextureProvider.h" #include "Tr2Renderer.h" -Tr2MeshArea::Tr2MeshArea( IRoot* lockobj ): +Tr2MeshArea::Tr2MeshArea( IRoot* lockobj ) : m_display( true ), m_index( 0 ), - m_count( 1 ), + m_count( 1 ), m_reversed( false ), m_useSHLighting( false ), m_generateDepthArea( false ), diff --git a/trinity/Tr2MeshArea.h b/trinity/Tr2MeshArea.h index e9a290675..dfd48b7e4 100644 --- a/trinity/Tr2MeshArea.h +++ b/trinity/Tr2MeshArea.h @@ -12,7 +12,7 @@ BLUE_DECLARE( Tr2Material ); BLUE_DECLARE( Tr2MeshBase ); class Tr2RaytracingMeshArea; -BLUE_CLASS ( Tr2MeshArea ) : +BLUE_CLASS( Tr2MeshArea ) : public IRoot { public: @@ -27,11 +27,11 @@ BLUE_CLASS ( Tr2MeshArea ) : int GetIndex() const; void SetIndex( int ix ); - int GetCount() const; - void SetCount( int n ); + int GetCount() const; + void SetCount( int n ); - bool GetReversed() const; - void SetReversed( bool reversed ); + bool GetReversed() const; + void SetReversed( bool reversed ); bool GetDisplay() const; void SetDisplay( bool display ); @@ -57,7 +57,7 @@ BLUE_CLASS ( Tr2MeshArea ) : bool HasVertexBufferAccessInRtShadow(); unsigned int* GetJointMappingAnimRig() const; - + // the provided array is NOT owned by this instance, it is owned by the parent mesh! // each mesharea gets a pointer on the same array void SetJointMappingAnimRig( unsigned int* val ); @@ -69,6 +69,7 @@ BLUE_CLASS ( Tr2MeshArea ) : Tr2RaytracingMeshArea* GetOrCreateRtMeshArea(); Tr2RaytracingMeshArea* GetRtMeshArea() const; + private: Tr2EffectPtr m_material; std::string m_name; @@ -83,7 +84,7 @@ BLUE_CLASS ( Tr2MeshArea ) : std::unique_ptr m_rtMeshArea; bool m_display; - // Request reversed order of rendering triangles and reversed cull order + // Request reversed order of rendering triangles and reversed cull order bool m_reversed; // Does this are require SH lighting instead of "normal" direct lighting bool m_useSHLighting; diff --git a/trinity/Tr2MeshArea_Blue.cpp b/trinity/Tr2MeshArea_Blue.cpp index c93284996..537b4a542 100644 --- a/trinity/Tr2MeshArea_Blue.cpp +++ b/trinity/Tr2MeshArea_Blue.cpp @@ -17,10 +17,10 @@ const Be::ClassInfo* Tr2MeshArea::ExposeToBlue() MAP_ATTRIBUTE( "name", m_name, "na", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Toggle visibility", Be::READWRITE ) MAP_ATTRIBUTE( "index", m_index, "Start index of the area within the mesh to bind to this effect", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "count", m_count, "Number of areas within the mesh to bind to this effect", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "reversed", m_reversed, "Render mesh triangles in reverse order and with reversed culling order", Be::PERSISTONLY ) + MAP_ATTRIBUTE( "count", m_count, "Number of areas within the mesh to bind to this effect", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "reversed", m_reversed, "Render mesh triangles in reverse order and with reversed culling order", Be::PERSISTONLY ) MAP_PROPERTY( "reversed", IsReversed, SetReversed, "Render mesh triangles in reverse order and with reversed culling order" ) - MAP_ATTRIBUTE( "useSHLighting", m_useSHLighting, "Use SH lighting instead of full-forward lighting", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useSHLighting", m_useSHLighting, "Use SH lighting instead of full-forward lighting", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "effect", m_material, "Shader or Material effect", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) diff --git a/trinity/Tr2MeshBase.cpp b/trinity/Tr2MeshBase.cpp index 636b1c025..247ffec7f 100644 --- a/trinity/Tr2MeshBase.cpp +++ b/trinity/Tr2MeshBase.cpp @@ -25,8 +25,8 @@ Tr2MeshBase::Tr2MeshBase( IRoot* lockobj ) : PARENTLOCK( m_distortionAreas ), m_display( true ), m_meshIndex( 0 ), - m_pBoneList(NULL), - m_numBones(0) + m_pBoneList( NULL ), + m_numBones( 0 ) { m_opaqueAreas.SetNotify( this ); m_decalAreas.SetNotify( this ); @@ -35,30 +35,30 @@ Tr2MeshBase::Tr2MeshBase( IRoot* lockobj ) : m_additiveAreas.SetNotify( this ); m_pickableAreas.SetNotify( this ); m_mirrorAreas.SetNotify( this ); - m_depthNormalAreas.SetNotify( this ); - m_opaquePrepassAreas.SetNotify( this ); - m_decalPrepassAreas.SetNotify( this ); - m_geometryEraserAreas.SetNotify( this ); - m_distortionAreas.SetNotify( this ); + m_depthNormalAreas.SetNotify( this ); + m_opaquePrepassAreas.SetNotify( this ); + m_decalPrepassAreas.SetNotify( this ); + m_geometryEraserAreas.SetNotify( this ); + m_distortionAreas.SetNotify( this ); for( int i = 0; i < TRIBATCHTYPE_COUNT_OF_BATCH_TYPES; ++i ) { - m_areaLookupArray[ i ] = NULL; - } - - m_areaLookupArray[ TRIBATCHTYPE_OPAQUE ] = &m_opaqueAreas; - m_areaLookupArray[ TRIBATCHTYPE_DECAL ] = &m_decalAreas; - m_areaLookupArray[ TRIBATCHTYPE_TRANSPARENT ] = &m_transparentAreas; - m_areaLookupArray[ TRIBATCHTYPE_DEPTH ] = &m_depthAreas; - m_areaLookupArray[ TRIBATCHTYPE_ADDITIVE ] = &m_additiveAreas; - m_areaLookupArray[ TRIBATCHTYPE_PICKING ] = &m_pickableAreas; - m_areaLookupArray[ TRIBATCHTYPE_MIRROR ] = &m_mirrorAreas; - m_areaLookupArray[ TRIBATCHTYPE_DECALNORMAL ] = &m_decalNormalAreas; - m_areaLookupArray[ TRIBATCHTYPE_DEPTHNORMAL ] = &m_depthNormalAreas; - m_areaLookupArray[ TRIBATCHTYPE_OPAQUE_PREPASS ] = &m_opaquePrepassAreas; - m_areaLookupArray[ TRIBATCHTYPE_DECAL_PREPASS ] = &m_decalPrepassAreas; - m_areaLookupArray[ TRIBATCHTYPE_GEOMETRY_ERASER ] = &m_geometryEraserAreas; - m_areaLookupArray[ TRIBATCHTYPE_FLARE ] = &m_flareAreas; - m_areaLookupArray[ TRIBATCHTYPE_DISTORTION ] = &m_distortionAreas; + m_areaLookupArray[i] = NULL; + } + + m_areaLookupArray[TRIBATCHTYPE_OPAQUE] = &m_opaqueAreas; + m_areaLookupArray[TRIBATCHTYPE_DECAL] = &m_decalAreas; + m_areaLookupArray[TRIBATCHTYPE_TRANSPARENT] = &m_transparentAreas; + m_areaLookupArray[TRIBATCHTYPE_DEPTH] = &m_depthAreas; + m_areaLookupArray[TRIBATCHTYPE_ADDITIVE] = &m_additiveAreas; + m_areaLookupArray[TRIBATCHTYPE_PICKING] = &m_pickableAreas; + m_areaLookupArray[TRIBATCHTYPE_MIRROR] = &m_mirrorAreas; + m_areaLookupArray[TRIBATCHTYPE_DECALNORMAL] = &m_decalNormalAreas; + m_areaLookupArray[TRIBATCHTYPE_DEPTHNORMAL] = &m_depthNormalAreas; + m_areaLookupArray[TRIBATCHTYPE_OPAQUE_PREPASS] = &m_opaquePrepassAreas; + m_areaLookupArray[TRIBATCHTYPE_DECAL_PREPASS] = &m_decalPrepassAreas; + m_areaLookupArray[TRIBATCHTYPE_GEOMETRY_ERASER] = &m_geometryEraserAreas; + m_areaLookupArray[TRIBATCHTYPE_FLARE] = &m_flareAreas; + m_areaLookupArray[TRIBATCHTYPE_DISTORTION] = &m_distortionAreas; } @@ -78,8 +78,7 @@ void Tr2MeshBase::OnListModified( ssize_t key, ssize_t key2, IRoot* value, - const IList* list - ) + const IList* list ) { switch( event & BELIST_EVENTMASK ) { @@ -87,7 +86,7 @@ void Tr2MeshBase::OnListModified( if( Tr2MeshAreaPtr area = BlueCastPtr( value ) ) { area->AddOwnerMesh( this ); - if ( area->IsReversed() ) + if( area->IsReversed() ) { ReverseIndexBuffers(); } @@ -173,12 +172,12 @@ bool Tr2MeshBase::BindToRig( const std::string* boneList, const int numBones, Tr forceRebind |= m_forcedRebind; m_forcedRebind = false; - if( !GetGeometryResource() || !GetGeometryResource()->IsPrepared() ) + if( !GetGeometryResource() || !GetGeometryResource()->IsPrepared() ) { return false; } - if( (m_pBoneList == boneList) && (m_renderRig == renderRig) && (m_numBones == numBones) && !forceRebind ) + if( ( m_pBoneList == boneList ) && ( m_renderRig == renderRig ) && ( m_numBones == numBones ) && !forceRebind ) { return true; } @@ -201,10 +200,10 @@ bool Tr2MeshBase::BindToRig( const std::string* boneList, const int numBones, Tr m_jointMappingAnimRig[j] = FindJoint( boneList, numBones, name ); - while (m_jointMappingAnimRig[j] == 0xffffffff) + while( m_jointMappingAnimRig[j] == 0xffffffff ) { - unsigned int renderIndex = renderRig->FindJoint(name); - if( renderIndex != 0xffffffff) + unsigned int renderIndex = renderRig->FindJoint( name ); + if( renderIndex != 0xffffffff ) { unsigned int parentIndex = renderRig->m_joints[renderIndex].m_parentJoint; if( parentIndex != 0xffffffff ) @@ -212,11 +211,15 @@ bool Tr2MeshBase::BindToRig( const std::string* boneList, const int numBones, Tr const char* parentName = renderRig->m_joints[parentIndex].m_name.c_str(); m_jointMappingAnimRig[j] = FindJoint( boneList, numBones, parentName ); name = parentName; - } else { + } + else + { CCP_LOGWARN( "Resource %s - attempted to bind a joint that was not found on the render rig: %s", meshData->m_name.c_str(), name ); break; } - } else { + } + else + { CCP_LOGWARN( "Resource %s - attempted to bind a joint that was not found on the render rig: %s", meshData->m_name.c_str(), name ); break; } @@ -225,12 +228,12 @@ bool Tr2MeshBase::BindToRig( const std::string* boneList, const int numBones, Tr for( int i = 0; i < TRIBATCHTYPE_COUNT_OF_BATCH_TYPES; ++i ) { - if( m_areaLookupArray[ i ] ) + if( m_areaLookupArray[i] ) { - for( PTr2MeshAreaVector::iterator it = m_areaLookupArray[ i ]->begin(); it != m_areaLookupArray[ i ]->end(); ++it ) + for( PTr2MeshAreaVector::iterator it = m_areaLookupArray[i]->begin(); it != m_areaLookupArray[i]->end(); ++it ) { - (*it)->SetJointMappingAnimRig( &m_jointMappingAnimRig[0] ); - (*it)->SetJointCount( n ); + ( *it )->SetJointMappingAnimRig( &m_jointMappingAnimRig[0] ); + ( *it )->SetJointCount( n ); } } } @@ -252,7 +255,7 @@ CcpMath::AxisAlignedBox Tr2MeshBase::GetBounds( const Matrix* boneTransforms, co TriGeometryResMeshData* meshData = geometry->GetMeshData( m_meshIndex ); TriGeometryResLodData* lod = geometry->GetMeshLod( m_meshIndex, 0 ); - if ( !m_jointMappingAnimRig.empty() ) + if( !m_jointMappingAnimRig.empty() ) { // for old character stuff boneCount = m_jointMappingAnimRig.size(); @@ -266,7 +269,7 @@ CcpMath::AxisAlignedBox Tr2MeshBase::GetBounds( const Matrix* boneTransforms, co { auto& joint = meshData->m_jointBindings[i]; auto& m = boneTransforms[meshBindingIndices[i]]; - + Vector3 rightMin = m.GetX() * joint.m_obbMin.x; Vector3 upMin = m.GetY() * joint.m_obbMin.y; Vector3 forwardMin = m.GetZ() * joint.m_obbMin.z; @@ -422,10 +425,10 @@ Tr2RenderBatch CreateGeometryBatch( TriGeometryResLodData* lod, Tr2MeshArea* are -void Tr2MeshBase::GetBatches( ITriRenderBatchAccumulator* batches, - const Tr2MeshAreaVector* areas, - const Tr2PerObjectData* data, - float screenSize ) const +void Tr2MeshBase::GetBatches( ITriRenderBatchAccumulator* batches, + const Tr2MeshAreaVector* areas, + const Tr2PerObjectData* data, + float screenSize ) const { if( !GetDisplay() ) { @@ -471,26 +474,26 @@ const wchar_t* Tr2MeshBase::GetGeometryResPath() const // ------------------------------------------------------------- // Description: -// Gets the mesh area vector, depending on the batch type +// Gets the mesh area vector, depending on the batch type // requested. Defaults to NULL if there is no vector for the given batch type. // Arguments: // areaType - the TriBatchType as enumerated in ITr2Renderable // ------------------------------------------------------------- Tr2MeshAreaVector* Tr2MeshBase::GetAreas( TriBatchType areaType ) { - return m_areaLookupArray[ areaType ]; + return m_areaLookupArray[areaType]; } // ------------------------------------------------------------- // Description: -// Gets the mesh area vector, depending on the batch type +// Gets the mesh area vector, depending on the batch type // requested. Defaults to NULL if there is no vector for the given batch type. // Arguments: // areaType - the TriBatchType as enumerated in ITr2Renderable // ------------------------------------------------------------- const Tr2MeshAreaVector* Tr2MeshBase::GetAreas( TriBatchType areaType ) const { - return m_areaLookupArray[ areaType ]; + return m_areaLookupArray[areaType]; } // ------------------------------------------------------------- @@ -512,7 +515,7 @@ void Tr2MeshBase::CollectAreaBlocks( std::vector& colle // (for example scaffolding + build effect) continue; } - TriRenderBatchAreaBlock ab( std::max( 0, (*a)->GetIndex() ), std::max( 0, (*a)->GetCount() ) ); + TriRenderBatchAreaBlock ab( std::max( 0, ( *a )->GetIndex() ), std::max( 0, ( *a )->GetCount() ) ); collector.push_back( ab ); } } @@ -534,16 +537,16 @@ void Tr2MeshBase::CollectAreaBlocksWithSharedMaterials( std::vectorGetHashValue() == ( *a )->GetMaterialInterface()->GetHashValue() ) { break; } } - if ( i == collectors.size() ) + if( i == collectors.size() ) { auto entry = TriRenderBatchAreaBlocksWithSharedMaterial(); entry.m_shaderMaterial = ( *a )->GetMaterialInterface(); @@ -558,15 +561,15 @@ void Tr2MeshBase::CollectAreaBlocksWithSharedMaterials( std::vector( i ); const auto area = GetAreas( tribatchType ); - for ( auto itInner = area->begin(); itInner != area->end(); ++itInner ) + for( auto itInner = area->begin(); itInner != area->end(); ++itInner ) { - const Tr2MeshArea *area = *itInner; + const Tr2MeshArea* area = *itInner; const auto material = area->GetMaterialInterface(); - if ( nullptr != material ) + if( nullptr != material ) { material->SetOption( name, value ); } @@ -614,7 +617,7 @@ void Tr2MeshBase::SetMaterialBoundsAdjustment( const Tr2MaterialBoundsAdjustment void Tr2MeshBase::UseWithScreenSize( float screenSize, float worldRadius ) const { - if (auto geometry = GetGeometryResource() ) + if( auto geometry = GetGeometryResource() ) { if( auto lod = geometry->GetMeshLod( m_meshIndex, screenSize ) ) { diff --git a/trinity/Tr2MeshBase.h b/trinity/Tr2MeshBase.h index 0a11f593c..d7dd0e692 100644 --- a/trinity/Tr2MeshBase.h +++ b/trinity/Tr2MeshBase.h @@ -21,7 +21,7 @@ struct TriGeometryResLodData; class TriRenderBatch; class Tr2RaytracingMesh; -BLUE_CLASS( Tr2MeshBase ): +BLUE_CLASS( Tr2MeshBase ) : public IListNotify { public: @@ -30,20 +30,23 @@ BLUE_CLASS( Tr2MeshBase ): Tr2MeshBase( IRoot* lockobj = NULL ); ~Tr2MeshBase(); - virtual void GetBatches( ITriRenderBatchAccumulator* batches, - const Tr2MeshAreaVector* areas, - const Tr2PerObjectData* data, - float screenSize = std::numeric_limits::max() ) const; + virtual void GetBatches( ITriRenderBatchAccumulator * batches, + const Tr2MeshAreaVector* areas, + const Tr2PerObjectData* data, + float screenSize = std::numeric_limits::max() ) const; Tr2MeshAreaVector* GetAreas( TriBatchType areaType ); const Tr2MeshAreaVector* GetAreas( TriBatchType areaType ) const; - void CollectAreaBlocks( std::vector& areaBlockVector, TriBatchType areaType ) const; + void CollectAreaBlocks( std::vector & areaBlockVector, TriBatchType areaType ) const; void CollectAreaBlocksWithSharedMaterials( std::vector & collectors, TriBatchType areaType ) const; void SetShaderOption( const BlueSharedString& name, const BlueSharedString& value ); - int GetMeshIndex() const { return m_meshIndex; }; + int GetMeshIndex() const + { + return m_meshIndex; + }; virtual CcpMath::AxisAlignedBox GetBounds( const Matrix* boneTransforms = nullptr, const int32_t* meshBindingIndices = nullptr, size_t boneCount = 0, const Tr2MorphTargetAnimationData* morphTargets = nullptr, size_t morphTargetsCount = 0 ) const; virtual CcpMath::AxisAlignedBox GetAreaBounds( unsigned int areaIx, const Matrix* boneTransforms = nullptr ) const; @@ -54,7 +57,10 @@ BLUE_CLASS( Tr2MeshBase ): virtual bool IsLoading() const = 0; - const char* GetName() const { return m_name.c_str(); } + const char* GetName() const + { + return m_name.c_str(); + } const wchar_t* GetGeometryResPath() const; bool GetDisplay() const; @@ -78,8 +84,7 @@ BLUE_CLASS( Tr2MeshBase ): ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); virtual void GetDebugOptions( Tr2DebugRendererOptions & options ); virtual void RenderDebugInfo( const Matrix& worldTransform, ITr2DebugRenderer2& renderer, const Matrix* boneTransforms = nullptr, const int32_t* meshBindingIndices = nullptr, size_t boneCount = 0, const Tr2MorphTargetAnimationData* morphTargets = nullptr, size_t morphTargetsCount = 0 ); @@ -104,7 +109,7 @@ BLUE_CLASS( Tr2MeshBase ): protected: std::string m_name; bool m_display; - int32_t m_meshIndex; + int32_t m_meshIndex; PTr2MeshAreaVector m_opaqueAreas; PTr2MeshAreaVector m_decalAreas; @@ -121,15 +126,15 @@ BLUE_CLASS( Tr2MeshBase ): PTr2MeshAreaVector m_flareAreas; PTr2MeshAreaVector m_distortionAreas; - PTr2MeshAreaVector* m_areaLookupArray[ TRIBATCHTYPE_COUNT_OF_BATCH_TYPES ]; + PTr2MeshAreaVector* m_areaLookupArray[TRIBATCHTYPE_COUNT_OF_BATCH_TYPES]; // skeleton/bone data std::vector m_jointMappingAnimRig; - const std::string *m_pBoneList; + const std::string* m_pBoneList; int m_numBones; TriGeometryResSkeletonData* m_renderRig; - bool m_forcedRebind; + bool m_forcedRebind; CcpMath::AxisAlignedBox m_cachedBounds; Tr2MaterialBoundsAdjustment m_boundsAdjustment; diff --git a/trinity/Tr2MeshBase_Blue.cpp b/trinity/Tr2MeshBase_Blue.cpp index 6f4eba3a8..2f4f9e1f1 100644 --- a/trinity/Tr2MeshBase_Blue.cpp +++ b/trinity/Tr2MeshBase_Blue.cpp @@ -34,12 +34,11 @@ const Be::ClassInfo* Tr2MeshBase::ExposeToBlue() MAP_METHOD_AND_WRAP( "GetAllAreas", GetAllAreas, "Returns a list of all areas (from all area type lists)" ) MAP_METHOD_AND_WRAP( "GetMaterialBoundsAdjustment", GetMaterialBoundsAdjustment, "Returns material bounds adjustment parameters" ) - MAP_METHOD_AND_WRAP( - "SetMaterialBoundsAdjustment", - SetMaterialBoundsAdjustment, + MAP_METHOD_AND_WRAP( + "SetMaterialBoundsAdjustment", + SetMaterialBoundsAdjustment, "Assigns material bounds adjustment parameters. Normally set by the publisher\n" - ":param adjustment: adjustment values extracted from shaders" - ) - - EXPOSURE_END() + ":param adjustment: adjustment values extracted from shaders" ) + + EXPOSURE_END() } diff --git a/trinity/Tr2Mesh_Blue.cpp b/trinity/Tr2Mesh_Blue.cpp index b2de799ca..b7505ddef 100644 --- a/trinity/Tr2Mesh_Blue.cpp +++ b/trinity/Tr2Mesh_Blue.cpp @@ -10,13 +10,12 @@ BLUE_DEFINE( Tr2SerializedMorphAnimation ); -const Be::ClassInfo* Tr2SerializedMorphAnimation::ExposeToBlue() -{ +const Be::ClassInfo* Tr2SerializedMorphAnimation::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2SerializedMorphAnimation, "" ) MAP_INTERFACE( Tr2SerializedMorphAnimation ) - MAP_ATTRIBUTE( "name", m_name, "", Be::PERSISTONLY ) - MAP_ATTRIBUTE( "weight", m_weight, "", Be::PERSISTONLY ) - EXPOSURE_END() + MAP_ATTRIBUTE( "name", m_name, "", Be::PERSISTONLY ) + MAP_ATTRIBUTE( "weight", m_weight, "", Be::PERSISTONLY ) + EXPOSURE_END() } @@ -26,77 +25,71 @@ BLUE_DEFINE( Tr2Mesh ); static PyObject* PyGetAreas( PyObject* self, PyObject* args ) { - Tr2Mesh* pThis = BluePythonCast( self ); - if( !pThis ) - { - return NULL; - } + Tr2Mesh* pThis = BluePythonCast( self ); + if( !pThis ) + { + return NULL; + } - int areaIndex; + int areaIndex; - if( !PyArg_ParseTuple( args, "i", &areaIndex ) ) - { - PyErr_SetString( PyExc_TypeError, "Arguments must be (i)." ); - return 0; - } + if( !PyArg_ParseTuple( args, "i", &areaIndex ) ) + { + PyErr_SetString( PyExc_TypeError, "Arguments must be (i)." ); + return 0; + } - TriBatchType type( static_cast( areaIndex ) ); + TriBatchType type( static_cast( areaIndex ) ); - Tr2MeshAreaVector* areas( pThis->GetAreas( type ) ); + Tr2MeshAreaVector* areas( pThis->GetAreas( type ) ); - if( !areas ) - { - Py_RETURN_NONE; - } + if( !areas ) + { + Py_RETURN_NONE; + } - return PyOS->WrapBlueObject( areas->GetRawRoot() ); + return PyOS->WrapBlueObject( areas->GetRawRoot() ); } #endif const Be::ClassInfo* Tr2Mesh::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Mesh, "" ) + EXPOSURE_BEGIN( Tr2Mesh, "" ) MAP_INTERFACE( Tr2Mesh ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "geometry", m_geometryResource, "na", Be::READ ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "geometryResPath", - m_meshResPath, - "Resource path to granny file", - Be::READWRITE | Be::NOTIFY | Be::PERSIST, - TriGR2Chooser - ) + MAP_ATTRIBUTE( "geometry", m_geometryResource, "na", Be::READ ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "geometryResPath", + m_meshResPath, + "Resource path to granny file", + Be::READWRITE | Be::NOTIFY | Be::PERSIST, + TriGR2Chooser ) MAP_ATTRIBUTE( "deferGeometryLoad", m_deferGeometryLoad, "Defers geometry load when loading mesh objects", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_PROPERTY_READONLY - ( - "isLoading", - IsLoading, - "If set, mesh resources might still be loading" - ) - - MAP_METHOD_AND_WRAP( - "SetGeometryRes", - PySetGeometryRes, + MAP_PROPERTY_READONLY( + "isLoading", + IsLoading, + "If set, mesh resources might still be loading" ) + + MAP_METHOD_AND_WRAP( + "SetGeometryRes", + PySetGeometryRes, "Set the geometry resource used by this mesh - bypassing the regular method of setting a resource name.\n" "This is used for geometry resources that require special handling, such as pre-baked blendshapes.\n" - ":param geometry: new geometry resource" - ) + ":param geometry: new geometry resource" ) - MAP_METHOD( - "GetAreas", - PyGetAreas, - "Returns mesh area list\n" + MAP_METHOD( + "GetAreas", + PyGetAreas, + "Returns mesh area list\n" ":param areaType: area type\n" ":type areaType: int\n" - ":rtype: None | List" - ); + ":rtype: None | List" ); MAP_METHOD_AND_WRAP( "GetAreasCount", GetAreasCount, "" ); MAP_ATTRIBUTE( "serializedMorphAnimations", m_serializedMorphAnimations, "", Be::PERSISTONLY ) - EXPOSURE_CHAINTO( Tr2MeshBase ) + EXPOSURE_CHAINTO( Tr2MeshBase ) } diff --git a/trinity/Tr2Model.cpp b/trinity/Tr2Model.cpp index c6ca061f2..68f53a7f3 100644 --- a/trinity/Tr2Model.cpp +++ b/trinity/Tr2Model.cpp @@ -8,15 +8,13 @@ #include "Resources/TriGeometryRes.h" -Tr2Model::Tr2Model( IRoot* lockobj ): +Tr2Model::Tr2Model( IRoot* lockobj ) : PARENTLOCK( m_meshes, IRoot ) { - } Tr2Model::~Tr2Model() { - } bool Tr2Model::HasTransparency() const @@ -34,17 +32,17 @@ bool Tr2Model::HasTransparency() const void Tr2Model::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Matrix& m, + const Matrix& m, const Tr2PerObjectData* data ) { - Matrix* pm = batches->Allocate(); - + Matrix* pm = batches->Allocate(); + CCP_ASSERT_M( pm, "No memory available for opaque batches." ); - if ( pm == NULL ) + if( pm == NULL ) { return; } - *pm = m; + *pm = m; // Transparent batches are sorted by the mesh bounding box order if( batchType == TRIBATCHTYPE_TRANSPARENT ) @@ -72,8 +70,8 @@ void Tr2Model::GetBatches( ITriRenderBatchAccumulator* batches, std::sort( meshesToSort.begin(), meshesToSort.end() ); // Now get the batches in order - for( Tr2MeshItemList::iterator meshIt = meshesToSort.begin(); - meshIt != meshesToSort.end(); + for( Tr2MeshItemList::iterator meshIt = meshesToSort.begin(); + meshIt != meshesToSort.end(); ++meshIt ) { Tr2Mesh* mesh = meshIt->m_mesh; @@ -83,8 +81,8 @@ void Tr2Model::GetBatches( ITriRenderBatchAccumulator* batches, else { // In all other cases, we just get the batches in order - for( Tr2MeshVector::iterator meshIt = m_meshes.begin(); - meshIt != m_meshes.end(); + for( Tr2MeshVector::iterator meshIt = m_meshes.begin(); + meshIt != m_meshes.end(); ++meshIt ) { Tr2Mesh* mesh = *meshIt; @@ -107,39 +105,39 @@ bool Tr2Model::GetBoundingBox( Vector3& min, Vector3& max ) return false; } - CcpMath::AxisAlignedBox aabb; + CcpMath::AxisAlignedBox aabb; - for( Tr2MeshVector::iterator meshIt = m_meshes.begin(); meshIt != m_meshes.end(); ++meshIt ) - { - Tr2Mesh* mesh = *meshIt; + for( Tr2MeshVector::iterator meshIt = m_meshes.begin(); meshIt != m_meshes.end(); ++meshIt ) + { + Tr2Mesh* mesh = *meshIt; - auto meshAabb = mesh->GetBounds(); + auto meshAabb = mesh->GetBounds(); - if( !meshAabb ) - { - return false; - } + if( !meshAabb ) + { + return false; + } aabb.Include( meshAabb ); - } + } - min = aabb.m_min; + min = aabb.m_min; max = aabb.m_max; - return true; + return true; } bool Tr2Model::IsLoading() const { - for( Tr2MeshVector::const_iterator meshIt = m_meshes.begin(); meshIt != m_meshes.end(); ++meshIt ) - { - Tr2Mesh* mesh = *meshIt; + for( Tr2MeshVector::const_iterator meshIt = m_meshes.begin(); meshIt != m_meshes.end(); ++meshIt ) + { + Tr2Mesh* mesh = *meshIt; // if one mesh is still loading, this model is not yet ready... if( mesh->IsLoading() ) { return true; } - } + } return false; } @@ -147,14 +145,14 @@ bool Tr2Model::IsLoading() const // ------------------------------------------------------------- // Description: // This is a helper function for Tr2Model to separate the code for -// +// // Arguments: // areaType - the TriBatchType as enumerated in ITr2Renderable // ------------------------------------------------------------- -void Tr2Model::GetBatchesFromMesh( Tr2Mesh* mesh, - TriBatchType batchType, - ITriRenderBatchAccumulator* batches, - Matrix* pm, +void Tr2Model::GetBatchesFromMesh( Tr2Mesh* mesh, + TriBatchType batchType, + ITriRenderBatchAccumulator* batches, + Matrix* pm, const Tr2PerObjectData* data ) { if( !mesh->GetDisplay() ) @@ -210,7 +208,7 @@ Be::Result Tr2Model::GetBoundingBoxInLocalSpace( std::pairGetBounds(); + auto meshAabb = GetMesh( i )->GetBounds(); if( meshAabb ) { diff --git a/trinity/Tr2Model.h b/trinity/Tr2Model.h index 54a7edf67..d27ff7815 100644 --- a/trinity/Tr2Model.h +++ b/trinity/Tr2Model.h @@ -15,30 +15,38 @@ class Tr2PerObjectData; class Tr2MeshArea; -class Tr2Model: - public IRoot +class Tr2Model : public IRoot { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); Tr2Model( IRoot* lockobj = NULL ); ~Tr2Model(); virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Matrix& m, - const Tr2PerObjectData* data ); + const Matrix& m, + const Tr2PerObjectData* data ); virtual bool HasTransparency() const; virtual bool GetBoundingBox( Vector3& min, Vector3& max ); - unsigned int GetNumOfMeshes() { return (unsigned int)m_meshes.size(); } - Tr2MeshPtr GetMesh( unsigned int ix ) { return m_meshes[ix]; } - const PTr2MeshVector& GetMeshes( void ) const { return m_meshes; } - - // Allows model to be constructed by hand from C++ code. - void AddMesh( Tr2Mesh* mesh ); + unsigned int GetNumOfMeshes() + { + return (unsigned int)m_meshes.size(); + } + Tr2MeshPtr GetMesh( unsigned int ix ) + { + return m_meshes[ix]; + } + const PTr2MeshVector& GetMeshes( void ) const + { + return m_meshes; + } + + // Allows model to be constructed by hand from C++ code. + void AddMesh( Tr2Mesh* mesh ); bool IsLoading() const; @@ -47,15 +55,15 @@ class Tr2Model: protected: friend class Tr2SkinnedModelBuilder; - std::string m_name; + std::string m_name; PTr2MeshVector m_meshes; private: // This is a helper function for GetBatches to separate it from the mesh sorting required for transparent areas - void GetBatchesFromMesh( Tr2Mesh* mesh, - TriBatchType batchType, - ITriRenderBatchAccumulator* batches, - Matrix* pm, + void GetBatchesFromMesh( Tr2Mesh* mesh, + TriBatchType batchType, + ITriRenderBatchAccumulator* batches, + Matrix* pm, const Tr2PerObjectData* data ); }; diff --git a/trinity/Tr2Model_Blue.cpp b/trinity/Tr2Model_Blue.cpp index 855ebe633..6b7d16208 100644 --- a/trinity/Tr2Model_Blue.cpp +++ b/trinity/Tr2Model_Blue.cpp @@ -7,19 +7,17 @@ BLUE_DEFINE( Tr2Model ); const Be::ClassInfo* Tr2Model::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Model, "" ) + EXPOSURE_BEGIN( Tr2Model, "" ) MAP_INTERFACE( Tr2Model ) MAP_ATTRIBUTE( "name", m_name, "Name of this model", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "meshes", m_meshes, "Meshes are sorted relative to the center of their granny mesh when getting transparent batches", Be::READ | Be::PERSIST ) + MAP_ATTRIBUTE( "meshes", m_meshes, "Meshes are sorted relative to the center of their granny mesh when getting transparent batches", Be::READ | Be::PERSIST ) - MAP_METHOD_AND_WRAP - ( - "GetBoundingBoxInLocalSpace", - GetBoundingBoxInLocalSpace, - "Gets the bounding box in local space" - ) + MAP_METHOD_AND_WRAP( + "GetBoundingBoxInLocalSpace", + GetBoundingBoxInLocalSpace, + "Gets the bounding box in local space" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2PerObjectData.cpp b/trinity/Tr2PerObjectData.cpp index 641898b68..1fa545cea 100644 --- a/trinity/Tr2PerObjectData.cpp +++ b/trinity/Tr2PerObjectData.cpp @@ -15,18 +15,18 @@ Tr2PerObjectData::~Tr2PerObjectData() // -------------------------------------------------------------------------------------- // Description: // Set the perObject data to the device. -// The function should use the provided buffer(s) to first map them and fill them up -// with per object data, _and_ then set the buffer to the renderContext at the correct +// The function should use the provided buffer(s) to first map them and fill them up +// with per object data, _and_ then set the buffer to the renderContext at the correct // register. // Arguments: -// buffers - points to an array of SHADER_TYPE_COUNT constant buffers; the elements in -// the array are pointers to make it easy to mix-and-match "global" buffers -// (that are shared) and buffers that specific objects hold on to because -// they know for sure that the data isn't changing (eg static placeables). +// buffers - points to an array of SHADER_TYPE_COUNT constant buffers; the elements in +// the array are pointers to make it easy to mix-and-match "global" buffers +// (that are shared) and buffers that specific objects hold on to because +// they know for sure that the data isn't changing (eg static placeables). // Each pointer is guaranteed to be non-null. // renderContext - current render context // -------------------------------------------------------------------------------------- -void Tr2PerObjectData::SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, +void Tr2PerObjectData::SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const { @@ -39,8 +39,8 @@ void Tr2PerObjectData::ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer // cppcheck-suppress uninitMemberVar -Tr2PerObjectDataStandard::Tr2PerObjectDataStandard() - : m_vertexShaderFloatBufferSize( 0 ) +Tr2PerObjectDataStandard::Tr2PerObjectDataStandard() : + m_vertexShaderFloatBufferSize( 0 ) { } @@ -53,17 +53,17 @@ void Tr2PerObjectDataStandard::SetPerObjectDataToDevice( Tr2ConstantBufferAL** b SHADER_TYPE_EXISTS( HULL_SHADER ) | SHADER_TYPE_EXISTS( DOMAIN_SHADER ); FillAndSetConstants( *buffers[VERTEX_SHADER], - m_vertexShaderFloatConstantBuffer, - m_vertexShaderFloatBufferSize, - perFrameVsMask & constantTypeMask, - Tr2Renderer::GetPerObjectVSStartRegister(), - renderContext ); + m_vertexShaderFloatConstantBuffer, + m_vertexShaderFloatBufferSize, + perFrameVsMask & constantTypeMask, + Tr2Renderer::GetPerObjectVSStartRegister(), + renderContext ); FillAndSetConstants( *buffers[PIXEL_SHADER], - m_pixelShaderFloatConstantBuffer, - m_pixelShaderFloatBufferSize, - PIXEL_SHADER, - Tr2Renderer::GetPerObjectPSStartRegister(), - renderContext ); + m_pixelShaderFloatConstantBuffer, + m_pixelShaderFloatBufferSize, + PIXEL_SHADER, + Tr2Renderer::GetPerObjectPSStartRegister(), + renderContext ); } void Tr2PerObjectDataStandard::ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const @@ -77,11 +77,11 @@ void Tr2PerObjectDataSkinned::SetPerObjectDataToDevice( Tr2ConstantBufferAL** bu if( ( constantTypeMask & ( 1 << PIXEL_SHADER ) ) != 0 ) { FillAndSetConstants( *buffers[PIXEL_SHADER], - m_pixelShaderFloatConstantBuffer, - m_pixelShaderFloatBufferSize, - PIXEL_SHADER, - Tr2Renderer::GetPerObjectPSStartRegister(), - renderContext ); + m_pixelShaderFloatConstantBuffer, + m_pixelShaderFloatBufferSize, + PIXEL_SHADER, + Tr2Renderer::GetPerObjectPSStartRegister(), + renderContext ); } const unsigned perFrameVsMask = SHADER_TYPE_EXISTS( VERTEX_SHADER ) | @@ -140,7 +140,7 @@ void Tr2PerObjectDataSkinned::SetSkinningMatrices( unsigned int n, float* data ) float* Tr2PerObjectDataSkinned::GetSkinningMatrix( unsigned int ix ) const { - return &m_data[ix*3*4]; + return &m_data[ix * 3 * 4]; } void Tr2PerAreaDataSkinned::SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const @@ -208,5 +208,5 @@ void Tr2PerAreaDataSkinned::SetJointTransform( unsigned int ix, float* data ) { CCP_ASSERT( ix < TR2_MAX_BONES_PER_MESHAREA ); - memcpy( &m_jointTransforms[ix*3*4], data, 3*4 * sizeof( float ) ); + memcpy( &m_jointTransforms[ix * 3 * 4], data, 3 * 4 * sizeof( float ) ); } diff --git a/trinity/Tr2PerObjectData.h b/trinity/Tr2PerObjectData.h index 05470a246..fe3d099df 100644 --- a/trinity/Tr2PerObjectData.h +++ b/trinity/Tr2PerObjectData.h @@ -9,8 +9,8 @@ class Tr2PerObjectData { public: - Tr2PerObjectData() - :m_userData( 0 ) + Tr2PerObjectData() : + m_userData( 0 ) { } @@ -20,8 +20,14 @@ class Tr2PerObjectData virtual void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const; - unsigned int GetUserData() const { return m_userData; } - void SetUserData(unsigned int val) { m_userData = val; } + unsigned int GetUserData() const + { + return m_userData; + } + void SetUserData( unsigned int val ) + { + m_userData = val; + } private: unsigned int m_userData; @@ -37,64 +43,65 @@ class Tr2PerObjectDataPSBuffer : public Tr2PerObjectData { public: // cppcheck-suppress uninitMemberVar - Tr2PerObjectDataPSBuffer() - : m_pixelShaderFloatBufferSize( 0 ) + Tr2PerObjectDataPSBuffer() : + m_pixelShaderFloatBufferSize( 0 ) { memset( m_pixelShaderFloatConstantBuffer, 0, sizeof( m_pixelShaderFloatConstantBuffer ) ); } - - template void CopyToPSFloatBuffer( const T& objectRef ) + + template + void CopyToPSFloatBuffer( const T& objectRef ) { // In-place buffer must be large enough to contain the data in the type being set - static_assert( sizeof(T) <= sizeof(m_pixelShaderFloatConstantBuffer), "Size of per-object data is too large" ); + static_assert( sizeof( T ) <= sizeof( m_pixelShaderFloatConstantBuffer ), "Size of per-object data is too large" ); // Size of the data being set must fill registers (float4s) - static_assert( sizeof(T) % (sizeof(float)*4) == 0, "Size of per-object data must be a multiple of Vector4" ); + static_assert( sizeof( T ) % ( sizeof( float ) * 4 ) == 0, "Size of per-object data must be a multiple of Vector4" ); // Object is a pointer ( please resolve possible NULL pointers yourself ) - static_assert( (!std::is_pointer::value), "Need to pass reference to the data" ); + static_assert( ( !std::is_pointer::value ), "Need to pass reference to the data" ); - m_pixelShaderFloatBufferSize = sizeof(T); - memcpy( &m_pixelShaderFloatConstantBuffer[0], (float*)&objectRef, sizeof(T) ); + m_pixelShaderFloatBufferSize = sizeof( T ); + memcpy( &m_pixelShaderFloatConstantBuffer[0], (float*)&objectRef, sizeof( T ) ); } protected: - float m_pixelShaderFloatConstantBuffer[80*4]; + float m_pixelShaderFloatConstantBuffer[80 * 4]; unsigned int m_pixelShaderFloatBufferSize; }; class Tr2PerObjectDataStandard : public Tr2PerObjectDataPSBuffer { public: - Tr2PerObjectDataStandard(); virtual void SetPerObjectDataToDevice( Tr2ConstantBufferAL** buffers, unsigned constantTypeMask, Tr2RenderContext& renderContext ) const; void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override; - template void CopyToVSFloatBuffer( const T& objectRef ) + template + void CopyToVSFloatBuffer( const T& objectRef ) { // In-place buffer must be large enough to contain the data in the type being set - static_assert( sizeof(T) <= sizeof(m_vertexShaderFloatConstantBuffer), "Size of per-object data is too large" ); + static_assert( sizeof( T ) <= sizeof( m_vertexShaderFloatConstantBuffer ), "Size of per-object data is too large" ); // Size of the data being set must fill registers (float4s) - static_assert( sizeof(T) % (sizeof(float)*4) == 0, "Size of per-object data must be a multiple of Vector4" ); + static_assert( sizeof( T ) % ( sizeof( float ) * 4 ) == 0, "Size of per-object data must be a multiple of Vector4" ); // Object is a pointer ( please resolve possible NULL pointers yourself ) - static_assert( (!std::is_pointer::value), "Need to pass reference to the data" ); + static_assert( ( !std::is_pointer::value ), "Need to pass reference to the data" ); - m_vertexShaderFloatBufferSize = sizeof(T); - memcpy( &m_vertexShaderFloatConstantBuffer[0], (float*)&objectRef, sizeof(T) ); + m_vertexShaderFloatBufferSize = sizeof( T ); + memcpy( &m_vertexShaderFloatConstantBuffer[0], (float*)&objectRef, sizeof( T ) ); } protected: - float m_vertexShaderFloatConstantBuffer[40*4]; + float m_vertexShaderFloatConstantBuffer[40 * 4]; unsigned int m_vertexShaderFloatBufferSize; }; -#define TR2_MAX_BONES_PER_MESHAREA (69) +#define TR2_MAX_BONES_PER_MESHAREA ( 69 ) class Tr2PerObjectDataSkinned : public Tr2PerObjectDataPSBuffer { public: - Tr2PerObjectDataSkinned() - :m_jointCount( 0 ), + Tr2PerObjectDataSkinned() : + m_jointCount( 0 ), m_data( nullptr ), m_worldMat( IdentityMatrix() ), m_mirrorMatrix( IdentityMatrix() ), @@ -106,14 +113,29 @@ class Tr2PerObjectDataSkinned : public Tr2PerObjectDataPSBuffer void ApplyConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const override; void ApplyPsConstantBuffers( Tr2IndirectDrawBufferWriter& writer, Tr2RenderContext& renderContext ) const; - + void SetSkinningMatrices( unsigned int n, float* data ); - float* GetSkinningMatrices() const { return m_data; } + float* GetSkinningMatrices() const + { + return m_data; + } float* GetSkinningMatrix( unsigned int ix ) const; - void SetWorldMatrix( const Matrix& worldMat ) { m_worldMat = worldMat; } - void SetMirrorMatrix( const Matrix& mirrorMat ) { m_mirrorMatrix = mirrorMat; } - const Matrix& GetMirrorMatrix() const { return m_mirrorMatrix; } - void SetWorldPosition( const Vector3& worldPos ) { m_worldPos = Vector4( worldPos.x, worldPos.y, worldPos.z, 0.0f ); } + void SetWorldMatrix( const Matrix& worldMat ) + { + m_worldMat = worldMat; + } + void SetMirrorMatrix( const Matrix& mirrorMat ) + { + m_mirrorMatrix = mirrorMat; + } + const Matrix& GetMirrorMatrix() const + { + return m_mirrorMatrix; + } + void SetWorldPosition( const Vector3& worldPos ) + { + m_worldPos = Vector4( worldPos.x, worldPos.y, worldPos.z, 0.0f ); + } void UpdateVertexShaderCBMirror( void* destination, Tr2RenderContext& renderContext ) const; @@ -130,9 +152,8 @@ class Tr2PerObjectDataSkinned : public Tr2PerObjectDataPSBuffer class Tr2PerAreaDataSkinned : public Tr2PerObjectData { public: - // cppcheck-suppress uninitMemberVar - Tr2PerAreaDataSkinned() : + Tr2PerAreaDataSkinned() : m_jointCount( 0 ), m_perObjectDataPtr( NULL ) { @@ -144,11 +165,20 @@ class Tr2PerAreaDataSkinned : public Tr2PerObjectData void SetJointCount( unsigned int n ); void SetJointTransform( unsigned int ix, float* data ); - void SetPerObjectData( const Tr2PerObjectDataSkinned& perObjectData ) { m_perObjectDataPtr = &perObjectData; }; - - const unsigned GetJointCount() const { return m_jointCount; } - const float* GetMatrices() const { return (const float*)m_jointTransforms; } - + void SetPerObjectData( const Tr2PerObjectDataSkinned& perObjectData ) + { + m_perObjectDataPtr = &perObjectData; + }; + + const unsigned GetJointCount() const + { + return m_jointCount; + } + const float* GetMatrices() const + { + return (const float*)m_jointTransforms; + } + private: unsigned int m_jointCount; float m_jointTransforms[TR2_MAX_BONES_PER_MESHAREA * ( 3 * 4 )]; diff --git a/trinity/Tr2PersistentPerObjectData.h b/trinity/Tr2PersistentPerObjectData.h index 3d9eadd9c..874074f83 100644 --- a/trinity/Tr2PersistentPerObjectData.h +++ b/trinity/Tr2PersistentPerObjectData.h @@ -10,9 +10,9 @@ // -------------------------------------------------------------------------------------- // Description: // Helper class that allows storing per-object data constant buffer with the owner -// object for DX11. This in turn allows filling this constant buffer once per frame +// object for DX11. This in turn allows filling this constant buffer once per frame // only. For other platforms this class does not store a constant buffer, but rather -// fills the one provided. To fill the buffer the object calls methods +// fills the one provided. To fill the buffer the object calls methods // GetPerObjectDataSize and UpdatePerObjectBuffer of the owner object. // See Also: // Tr2PerObjectDataWithPersistentBuffers, Tr2PerObjectData @@ -22,54 +22,54 @@ class Tr2PersistentPerObjectData : public Tr2DeviceResource { public: - Tr2PersistentPerObjectData() - :m_bufferDirty( true ) + Tr2PersistentPerObjectData() : + m_bufferDirty( true ) { } // ---------------------------------------------------------------------------------- // Description: - // Invalidates dirty flag for the object. Next time it is requested to apply its + // Invalidates dirty flag for the object. Next time it is requested to apply its // constant buffer, the object fill re-fill it with new data. // ---------------------------------------------------------------------------------- void InvalidateBufferData() { m_bufferDirty = true; } - - void UpdateBuffer( Owner& owner, Tr2RenderContextEnum::ShaderType shaderType ) - { + + void UpdateBuffer( Owner& owner, Tr2RenderContextEnum::ShaderType shaderType ) + { #if TRINITY_PLATFORM != TRINITY_DIRECTX11 - if( !m_bufferDirty ) - { - return; - } - uint32_t size = owner.GetPerObjectDataSize( shaderType ); - if( size > 0 ) - { - USE_MAIN_THREAD_RENDER_CONTEXT(); - - auto& buffer = m_constantBuffer; - if( !buffer.IsValid() || size > buffer.GetSize() ) - { - CR_RETURN( buffer.Create( size, renderContext.GetPrimaryRenderContext() ) ); - } - void* data = nullptr; + if( !m_bufferDirty ) + { + return; + } + uint32_t size = owner.GetPerObjectDataSize( shaderType ); + if( size > 0 ) + { + USE_MAIN_THREAD_RENDER_CONTEXT(); - if( SUCCEEDED( buffer.Lock( &data, renderContext ) ) && data ) - { - owner.UpdatePerObjectBuffer( shaderType, size, data ); - buffer.Unlock( renderContext ); - } - } - m_bufferDirty = false; + auto& buffer = m_constantBuffer; + if( !buffer.IsValid() || size > buffer.GetSize() ) + { + CR_RETURN( buffer.Create( size, renderContext.GetPrimaryRenderContext() ) ); + } + void* data = nullptr; + + if( SUCCEEDED( buffer.Lock( &data, renderContext ) ) && data ) + { + owner.UpdatePerObjectBuffer( shaderType, size, data ); + buffer.Unlock( renderContext ); + } + } + m_bufferDirty = false; #endif - } + } Tr2ConstantBufferAL& UpdateBuffer( Owner& owner, Tr2RenderContextEnum::ShaderType shaderType, - Tr2RenderContext& renderContext) + Tr2RenderContext& renderContext ) { if( m_bufferDirty ) { @@ -99,7 +99,7 @@ class Tr2PersistentPerObjectData // Applies constant buffer to the render context filling it if needed. // Arguments: // owner - Owner object - // buffers - Array of transient constant buffers (usually provided by + // buffers - Array of transient constant buffers (usually provided by // Tr2EffectStateManager); not used in DX11 as we have our own buffer in this case // renderContext - Current render context // ---------------------------------------------------------------------------------- @@ -118,8 +118,8 @@ class Tr2PersistentPerObjectData if( !m_bufferDirty ) { renderContext.SetConstants( m_constantBuffer, - shaderType, - Tr2Renderer::GetPerObjectStartRegister( shaderType ) ); + shaderType, + Tr2Renderer::GetPerObjectStartRegister( shaderType ) ); return; } uint32_t size = owner.GetPerObjectDataSize( shaderType ); @@ -153,11 +153,13 @@ class Tr2PersistentPerObjectData m_bufferDirty = true; } } + protected: virtual bool OnPrepareResources() { return true; } + private: Tr2ConstantBufferAL m_constantBuffer; bool m_bufferDirty; @@ -166,7 +168,7 @@ class Tr2PersistentPerObjectData // -------------------------------------------------------------------------------------- // Description: // Per-object data composed of two Tr2PersistentPerObjectData objects: one for vertex -// stage and one for pixel stage. +// stage and one for pixel stage. // See Also: // Tr2PersistentPerObjectData, Tr2PerObjectData // -------------------------------------------------------------------------------------- @@ -177,8 +179,8 @@ class Tr2PerObjectDataWithPersistentBuffers : public Tr2PerObjectData typedef Tr2PersistentPerObjectData PerObjectDataVs; typedef Tr2PersistentPerObjectData PerObjectDataPs; - Tr2PerObjectDataWithPersistentBuffers() - :m_owner( nullptr ), + Tr2PerObjectDataWithPersistentBuffers() : + m_owner( nullptr ), m_perObjectDataVs( nullptr ), m_perObjectDataPs( nullptr ) { @@ -189,28 +191,28 @@ class Tr2PerObjectDataWithPersistentBuffers : public Tr2PerObjectData // Initializes the object. // Arguments: // owner - Owner object, cannot be NULL - // perObjectDataVs - Per-object constant buffer for vertex stage, can be NULL if VS + // perObjectDataVs - Per-object constant buffer for vertex stage, can be NULL if VS // is not expecting per-object data - // perObjectDataPs - Per-object constant buffer for vertex stage, can be NULL if PS + // perObjectDataPs - Per-object constant buffer for vertex stage, can be NULL if PS // is not expecting per-object data // ---------------------------------------------------------------------------------- - void Initialize( - Owner* owner, - PerObjectDataVs* perObjectDataVs, + void Initialize( + Owner* owner, + PerObjectDataVs* perObjectDataVs, PerObjectDataPs* perObjectDataPs ) { m_owner = owner; m_perObjectDataVs = perObjectDataVs; - m_perObjectDataVs->UpdateBuffer( *owner, Tr2RenderContextEnum::VERTEX_SHADER ); + m_perObjectDataVs->UpdateBuffer( *owner, Tr2RenderContextEnum::VERTEX_SHADER ); m_perObjectDataPs = perObjectDataPs; - m_perObjectDataPs->UpdateBuffer( *owner, Tr2RenderContextEnum::PIXEL_SHADER ); + m_perObjectDataPs->UpdateBuffer( *owner, Tr2RenderContextEnum::PIXEL_SHADER ); } // ---------------------------------------------------------------------------------- // Description: // Initializes the object. // Arguments: - // buffers - Array of transient constant buffers (usually provided by + // buffers - Array of transient constant buffers (usually provided by // Tr2EffectStateManager) // constantTypeMask - Mask with pipeline stages that are expected by the shader // renderContext - Current render context @@ -221,7 +223,7 @@ class Tr2PerObjectDataWithPersistentBuffers : public Tr2PerObjectData { m_perObjectDataVs->SetPerObjectDataToDevice( *m_owner, Tr2RenderContextEnum::VERTEX_SHADER, buffers, renderContext ); } - if( SHADER_TYPE_EXISTS( Tr2RenderContextEnum::GEOMETRY_SHADER ) && + if( SHADER_TYPE_EXISTS( Tr2RenderContextEnum::GEOMETRY_SHADER ) && ( constantTypeMask & ( 1 << Tr2RenderContextEnum::GEOMETRY_SHADER ) ) && m_perObjectDataVs ) { m_perObjectDataVs->SetPerObjectDataToDevice( *m_owner, Tr2RenderContextEnum::GEOMETRY_SHADER, buffers, renderContext ); diff --git a/trinity/Tr2PickBuffer.cpp b/trinity/Tr2PickBuffer.cpp index 377f1d015..c2d46f631 100644 --- a/trinity/Tr2PickBuffer.cpp +++ b/trinity/Tr2PickBuffer.cpp @@ -37,7 +37,7 @@ void Tr2PickBuffer::ReleaseResources( TriStorage s ) // ------------------------------------------------------------------------------------------------------ bool Tr2PickBuffer::OnPrepareResources() { - int const size( std::max( m_size, 1 ) ); + int const size( std::max( m_size, 1 ) ); // create the pixel buffer as a rendertarget USE_MAIN_THREAD_RENDER_CONTEXT(); diff --git a/trinity/Tr2PickBuffer.h b/trinity/Tr2PickBuffer.h index c90694e50..035f461d3 100644 --- a/trinity/Tr2PickBuffer.h +++ b/trinity/Tr2PickBuffer.h @@ -8,8 +8,7 @@ // Forward declarations class Tr2Effect; -class Tr2PickBuffer : - public Tr2DeviceResource +class Tr2PickBuffer : public Tr2DeviceResource { public: Tr2PickBuffer( IRoot* lockobj = 0, Tr2RenderContextEnum::PixelFormat format = Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN, int size = 1 ); @@ -18,17 +17,28 @@ class Tr2PickBuffer : ///////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: + +public: #ifdef TRINITYDEV - void GetDescription( std::string& desc ) { desc = "Tr2PickBuffer"; } + void GetDescription( std::string& desc ) + { + desc = "Tr2PickBuffer"; + } #endif // Change picking behavior void SetSize( int size ); - unsigned int GetSize() const { return m_size; } - void SetClearColor( uint32_t val ) { m_clearColor = val; }; + unsigned int GetSize() const + { + return m_size; + } + void SetClearColor( uint32_t val ) + { + m_clearColor = val; + }; // Rendering bool BeginRendering( float initialDepth, Tr2RenderContext& renderContext ); @@ -38,9 +48,9 @@ class Tr2PickBuffer : void UnmapForReading( Tr2RenderContext& renderContext ); protected: - int m_size; // Pickbuffer size - Tr2RenderContextEnum::PixelFormat m_format; // Pickbuffer format - uint32_t m_clearColor; // Pickbuffer "nothing there" color + int m_size; // Pickbuffer size + Tr2RenderContextEnum::PixelFormat m_format; // Pickbuffer format + uint32_t m_clearColor; // Pickbuffer "nothing there" color // Pick buffers Tr2TextureAL m_pickTarget; diff --git a/trinity/Tr2PlatformInfo.cpp b/trinity/Tr2PlatformInfo.cpp index 6216eee27..823077180 100644 --- a/trinity/Tr2PlatformInfo.cpp +++ b/trinity/Tr2PlatformInfo.cpp @@ -16,16 +16,20 @@ uint32_t Tr2PlatformInfo::GetPlatformID() const bool Tr2PlatformInfo::GetStaticCap( StaticCap cap ) const { -#define HANDLE_PLATFORM_CAP(x) case x: return TRINITY_PLATFORM_SUPPORTS_##x != 0; -#define HANDLE_APPLICATION_CAP(x) case x: return TRINITY_SUPPORTS_##x != 0; +#define HANDLE_PLATFORM_CAP( x ) \ + case x: \ + return TRINITY_PLATFORM_SUPPORTS_##x != 0; +#define HANDLE_APPLICATION_CAP( x ) \ + case x: \ + return TRINITY_SUPPORTS_##x != 0; switch( cap ) { - HANDLE_PLATFORM_CAP( BUFFER_SHADER_RESOURCES ); - HANDLE_PLATFORM_CAP( UNORDERED_ACCESS ); - HANDLE_PLATFORM_CAP( COMPUTE ); - HANDLE_PLATFORM_CAP( TEXTURE_ARRAYS ); - HANDLE_PLATFORM_CAP( MSAA_SAMPLE ); + HANDLE_PLATFORM_CAP( BUFFER_SHADER_RESOURCES ); + HANDLE_PLATFORM_CAP( UNORDERED_ACCESS ); + HANDLE_PLATFORM_CAP( COMPUTE ); + HANDLE_PLATFORM_CAP( TEXTURE_ARRAYS ); + HANDLE_PLATFORM_CAP( MSAA_SAMPLE ); default: return false; diff --git a/trinity/Tr2PlatformInfo.h b/trinity/Tr2PlatformInfo.h index 261217a63..c72427794 100644 --- a/trinity/Tr2PlatformInfo.h +++ b/trinity/Tr2PlatformInfo.h @@ -2,7 +2,8 @@ #pragma once -BLUE_CLASS( Tr2PlatformInfo ): public IRoot +BLUE_CLASS( Tr2PlatformInfo ) : + public IRoot { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Tr2PlatformInfo_Blue.cpp b/trinity/Tr2PlatformInfo_Blue.cpp index 0a1d27201..feb89085b 100644 --- a/trinity/Tr2PlatformInfo_Blue.cpp +++ b/trinity/Tr2PlatformInfo_Blue.cpp @@ -5,44 +5,29 @@ BLUE_DEFINE( Tr2PlatformInfo ); -Be::VarChooser Tr2PlatformInfoStaticCapChooser[] = -{ - { - "NON_SYNCHRONIZED_LOCKS", - BeCast( Tr2PlatformInfo::NON_SYNCHRONIZED_LOCKS ), - "Can map buffers without plaform synchronization" - }, - { - "BUFFER_SHADER_RESOURCES", - BeCast( Tr2PlatformInfo::BUFFER_SHADER_RESOURCES ), - "Can access buffers as shader resources" - }, - { - "UNORDERED_ACCESS", - BeCast( Tr2PlatformInfo::UNORDERED_ACCESS ), - "Can write to textures and buffers from shaders using unordered access views" - }, - { - "COMPUTE", - BeCast( Tr2PlatformInfo::COMPUTE ), - "Has compute shader support" - }, - { - "TEXTURE_ARRAYS", - BeCast( Tr2PlatformInfo::TEXTURE_ARRAYS ), - "Supports texture arrays" - }, - { - "MSAA_SAMPLE", - BeCast( Tr2PlatformInfo::MSAA_SAMPLE ), - "Supports sampling MSAA textures" - }, - - { - "TAA", - BeCast( Tr2PlatformInfo::TAA ), - "Space scenes support TAA" - }, +Be::VarChooser Tr2PlatformInfoStaticCapChooser[] = { + { "NON_SYNCHRONIZED_LOCKS", + BeCast( Tr2PlatformInfo::NON_SYNCHRONIZED_LOCKS ), + "Can map buffers without plaform synchronization" }, + { "BUFFER_SHADER_RESOURCES", + BeCast( Tr2PlatformInfo::BUFFER_SHADER_RESOURCES ), + "Can access buffers as shader resources" }, + { "UNORDERED_ACCESS", + BeCast( Tr2PlatformInfo::UNORDERED_ACCESS ), + "Can write to textures and buffers from shaders using unordered access views" }, + { "COMPUTE", + BeCast( Tr2PlatformInfo::COMPUTE ), + "Has compute shader support" }, + { "TEXTURE_ARRAYS", + BeCast( Tr2PlatformInfo::TEXTURE_ARRAYS ), + "Supports texture arrays" }, + { "MSAA_SAMPLE", + BeCast( Tr2PlatformInfo::MSAA_SAMPLE ), + "Supports sampling MSAA textures" }, + + { "TAA", + BeCast( Tr2PlatformInfo::TAA ), + "Space scenes support TAA" }, { 0 } }; @@ -50,8 +35,7 @@ BLUE_REGISTER_ENUM_EX( "PlatformStaticCap", Tr2PlatformInfo::StaticCap, Tr2PlatformInfoStaticCapChooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); + ENUM_REG_ENUM_OBJECT_ON_MODULE ); @@ -64,11 +48,10 @@ const Be::ClassInfo* Tr2PlatformInfo::ExposeToBlue() MAP_PROPERTY_READONLY( "platformID", GetPlatformID, "AL platform id" ) MAP_PROPERTY_READONLY( "isLowPerformance", IsLowPerformance, "Is the AL platform low-end" ) - MAP_METHOD_AND_WRAP( - "GetStaticCap", + MAP_METHOD_AND_WRAP( + "GetStaticCap", GetStaticCap, "Returns AL platform capability flag value.\n" - ":param cap: capability name (see trinity.PlatformStaticCap)\n" - ) + ":param cap: capability name (see trinity.PlatformStaticCap)\n" ) EXPOSURE_END() } diff --git a/trinity/Tr2PostProcess.cpp b/trinity/Tr2PostProcess.cpp index 5c374107c..6024a5c6e 100644 --- a/trinity/Tr2PostProcess.cpp +++ b/trinity/Tr2PostProcess.cpp @@ -17,5 +17,5 @@ Tr2PostProcess::~Tr2PostProcess() bool Tr2PostProcess::Initialize() { - return true; + return true; } diff --git a/trinity/Tr2PostProcess.h b/trinity/Tr2PostProcess.h index 586a2e634..9c2986fa8 100644 --- a/trinity/Tr2PostProcess.h +++ b/trinity/Tr2PostProcess.h @@ -10,8 +10,7 @@ BLUE_DECLARE( Tr2Effect ); BLUE_DECLARE_VECTOR( Tr2Effect ); class TriVariable; -class Tr2PostProcess : - public IInitialize +class Tr2PostProcess : public IInitialize { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Tr2PostProcess_Blue.cpp b/trinity/Tr2PostProcess_Blue.cpp index 5023a1813..cc9c6d27c 100644 --- a/trinity/Tr2PostProcess_Blue.cpp +++ b/trinity/Tr2PostProcess_Blue.cpp @@ -7,17 +7,15 @@ BLUE_DEFINE( Tr2PostProcess ); const Be::ClassInfo* Tr2PostProcess::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2PostProcess, "" ) + EXPOSURE_BEGIN( Tr2PostProcess, "" ) MAP_INTERFACE( Tr2PostProcess ) - MAP_ATTRIBUTE - ( - "stages", + MAP_ATTRIBUTE( + "stages", m_stages, - "Post processing stages", - Be::READ | Be::PERSIST - ) + "Post processing stages", + Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2PrimitiveScene.cpp b/trinity/Tr2PrimitiveScene.cpp index df3666f8b..12c84518b 100644 --- a/trinity/Tr2PrimitiveScene.cpp +++ b/trinity/Tr2PrimitiveScene.cpp @@ -29,10 +29,10 @@ Tr2PrimitiveScene::Tr2PrimitiveScene( IRoot* lockobj ) : PARENTLOCK( m_textLabels ), m_pickBuffer( NULL, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT, 1 ) { - m_pickBuffer.PrepareResources(); - m_allocator = CCP_NEW( "Tr2PrimitiveScene/m_allocator" ) TriPoolAllocator(); + m_pickBuffer.PrepareResources(); + m_allocator = CCP_NEW( "Tr2PrimitiveScene/m_allocator" ) TriPoolAllocator(); m_opaqueBatches = CCP_NEW( "Tr2PrimitiveScene/m_opaqueBatches" ) TriRenderBatchAccumulator<>( m_allocator ); - m_pickingBatches = CCP_NEW( "Tr2PrimitiveScene/m_pickingBatches" ) TriRenderBatchAccumulator<>( m_allocator ); + m_pickingBatches = CCP_NEW( "Tr2PrimitiveScene/m_pickingBatches" ) TriRenderBatchAccumulator<>( m_allocator ); } Tr2PrimitiveScene::~Tr2PrimitiveScene() @@ -49,13 +49,13 @@ Tr2PrimitiveScene::~Tr2PrimitiveScene() // -------------------------------------------------------------------------------------- void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) { - std::vector visibleRenderObjects; - // We render everything since it is so cheap - visibleRenderObjects.clear(); + std::vector visibleRenderObjects; + // We render everything since it is so cheap + visibleRenderObjects.clear(); for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - (*it)->UpdateTransform(); - visibleRenderObjects.push_back((*it)); + ( *it )->UpdateTransform(); + visibleRenderObjects.push_back( ( *it ) ); } if( m_manipulator != NULL ) @@ -63,8 +63,8 @@ void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) m_manipulator->Update(); std::vector manipPrims = m_manipulator->GetPrimitivesToRender(); for( RenderableIterator it = manipPrims.begin(); it != manipPrims.end(); ++it ) - { - visibleRenderObjects.push_back((*it)); + { + visibleRenderObjects.push_back( ( *it ) ); } } @@ -73,9 +73,9 @@ void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) for( RenderableIterator it = visibleRenderObjects.begin(); it != visibleRenderObjects.end(); ++it ) { ITr2RenderableEntry entry; - entry.m_object = (*it); - entry.m_distance = (*it)->GetSortValue(); - sortList.push_back( entry ); + entry.m_object = ( *it ); + entry.m_distance = ( *it )->GetSortValue(); + sortList.push_back( entry ); } std::sort( sortList.begin(), sortList.end() ); // sort the primitives back to front @@ -84,12 +84,13 @@ void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) SetupPerFrameData( renderContext ); renderContext.m_esm.BeginManagedRendering(); - for( Tr2RenderableSortList::iterator it = sortList.begin(); - it != sortList.end(); ++it ) - { - ITr2RenderablePtr obj = (*it).m_object; - Tr2PerObjectData* perObject = obj->GetPerObjectData( m_opaqueBatches ); - obj->GetBatches( m_opaqueBatches, TRIBATCHTYPE_OPAQUE, perObject ); + for( Tr2RenderableSortList::iterator it = sortList.begin(); + it != sortList.end(); + ++it ) + { + ITr2RenderablePtr obj = ( *it ).m_object; + Tr2PerObjectData* perObject = obj->GetPerObjectData( m_opaqueBatches ); + obj->GetBatches( m_opaqueBatches, TRIBATCHTYPE_OPAQUE, perObject ); } m_opaqueBatches->Finalize(); @@ -106,7 +107,7 @@ void Tr2PrimitiveScene::Render( Tr2RenderContext& renderContext ) for( auto it = m_textLabels.begin(); it != m_textLabels.end(); it++ ) { - (*it)->Render(); + ( *it )->Render(); } Tr2Renderer::RenderDebugInfo( renderContext ); } @@ -153,29 +154,29 @@ void Tr2PrimitiveScene::SetupTransformsForPicking( float fx, float fy, TriProjec Tr2Renderer::SetViewTransform( view->GetTransform() ); proj->SetProjection(); - + if( Tr2Renderer::GetCurrentProjectionType() == PT_ORTHOGONAL ) - { - fx *= (Tr2Renderer::GetOrthoWidth()/2.0f); - fy *= (Tr2Renderer::GetOrthoHeight()/2.0f); - float metersPerPixel = (Tr2Renderer::GetOrthoWidth()/viewport->width)/2.0f; - Tr2Renderer::SetOrthoProjection(fx-metersPerPixel, - fx+metersPerPixel, - fy-metersPerPixel, - fy+metersPerPixel, - Tr2Renderer::GetFrontClip(), - Tr2Renderer::GetBackClip()); + { + fx *= ( Tr2Renderer::GetOrthoWidth() / 2.0f ); + fy *= ( Tr2Renderer::GetOrthoHeight() / 2.0f ); + float metersPerPixel = ( Tr2Renderer::GetOrthoWidth() / viewport->width ) / 2.0f; + Tr2Renderer::SetOrthoProjection( fx - metersPerPixel, + fx + metersPerPixel, + fy - metersPerPixel, + fy + metersPerPixel, + Tr2Renderer::GetFrontClip(), + Tr2Renderer::GetBackClip() ); } else { // // Projection is set up to scale the image such that the viewport is covered by one pixel. - Vector2 scaling( float(viewport->width), float(viewport->height) ); + Vector2 scaling( float( viewport->width ), float( viewport->height ) ); // translate the projection so that we center around the pick ray origin, // while remembering to scale this value as well: Vector2 translation; - translation.x = -fx*scaling.x; - translation.y = -fy*scaling.y; + translation.x = -fx * scaling.x; + translation.y = -fy * scaling.y; Tr2Renderer::AdjustProjection( scaling, translation ); } } @@ -193,7 +194,7 @@ void Tr2PrimitiveScene::SetupPerFrameData( Tr2RenderContext& renderContext ) Matrix proj = Tr2Renderer::GetReversedDepthProjectionTransform(); data.ProjectionMat = XMMatrixTranspose( proj ); - data.ViewProjectionMat = XMMatrixTranspose( + data.ViewProjectionMat = XMMatrixTranspose( XMMatrixMultiply( Tr2Renderer::GetViewTransform(), proj ) ); FillAndSetConstants( m_vertexConstants, data, Tr2RenderContextEnum::VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext ); @@ -204,7 +205,7 @@ void Tr2PrimitiveScene::SetPerFrameDataForPicking( Tr2RenderContext& renderConte SetupPerFrameData( renderContext ); } -bool Tr2PrimitiveScene::RenderPicking( +bool Tr2PrimitiveScene::RenderPicking( ITriRenderBatchAccumulator* pOpaquePickingBatches, ITriRenderBatchAccumulator* pPickingBatches, PickComponents pass ) @@ -216,55 +217,55 @@ bool Tr2PrimitiveScene::RenderPicking( // Use a shader variable for identifying which components are expected. // We can't use situations here because the flags might change during a single // frame. - Vector4 componentsParam = Vector4( - ( pass & PICK_OBJECT ) ? 1.0f : 0.0f, - ( pass & PICK_AREA ) ? 1.0f : 0.0f, - ( pass & PICK_POSITION ) ? 1.0f : 0.0f, + Vector4 componentsParam = Vector4( + ( pass & PICK_OBJECT ) ? 1.0f : 0.0f, + ( pass & PICK_AREA ) ? 1.0f : 0.0f, + ( pass & PICK_POSITION ) ? 1.0f : 0.0f, ( pass & PICK_UV ) ? 1.0f : 0.0f ); GlobalStore().RegisterVariable( "PickingComponents", componentsParam ); - // Get the pick buffer - Tr2PickBuffer& pickBuffer = GetPickBuffer(); + // Get the pick buffer + Tr2PickBuffer& pickBuffer = GetPickBuffer(); - if( !pickBuffer.BeginRendering( 0, renderContext ) ) - { - return false; - } + if( !pickBuffer.BeginRendering( 0, renderContext ) ) + { + return false; + } - if( pPickingBatches && RenderPickingAreasForComponents( pass ) ) - { - pPickingBatches->Finalize(); + if( pPickingBatches && RenderPickingAreasForComponents( pass ) ) + { + pPickingBatches->Finalize(); - renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); + renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_PICKING ); renderContext.RenderBatchesForPicking( pPickingBatches, DEFAULT_TECHNIQUE ); - } + } - if( !pickBuffer.EndRendering( renderContext ) ) - { - return false; - } + if( !pickBuffer.EndRendering( renderContext ) ) + { + return false; + } - return true; + return true; } const std::vector& Tr2PrimitiveScene::GetPickingObjectsToRender( const Vector3& dirWorld ) { m_pickingObjects.clear(); for( auto it = m_primitives.begin(); it != m_primitives.end(); ++it ) - { - ((Tr2PrimitiveSet*)(*it))->UpdateTransform(); - m_pickingObjects.push_back((*it)); + { + ( (Tr2PrimitiveSet*)( *it ) )->UpdateTransform(); + m_pickingObjects.push_back( ( *it ) ); + } + if( m_manipulator != NULL ) + { + m_manipulator->Update(); + std::vector manipPrims = m_manipulator->GetPrimitivesToRender(); + for( RenderableIterator it = manipPrims.begin(); it != manipPrims.end(); ++it ) + { + m_pickingObjects.push_back( ( *it ) ); + } } - if (m_manipulator != NULL) - { - m_manipulator->Update(); - std::vector manipPrims = m_manipulator->GetPrimitivesToRender(); - for (RenderableIterator it = manipPrims.begin(); it != manipPrims.end(); ++it) - { - m_pickingObjects.push_back((*it)); - } - } return m_pickingObjects; } @@ -289,7 +290,7 @@ ITriRenderBatchAccumulator* Tr2PrimitiveScene::GetPickingBatchAccumulator( void // ------------------------------------------------------------- // Description: // Returns an array of passes that need to be rendered in order -// to get all picking components. +// to get all picking components. // Arguments: // requestedComponents - Components requested for picking operation // (union of PickComponent). @@ -331,10 +332,10 @@ unsigned int Tr2PrimitiveScene::GetRequiredPasses( PickComponents requestedCompo void Tr2PrimitiveScene::DecodeBufferPixel( const void* pBuffer, PickComponents pass, BufferResults& results ) const { // helpers: get each channel - float a = *((float*)pBuffer + 3); - float r = *((float*)pBuffer + 2); - float g = *((float*)pBuffer + 1); - float b = *((float*)pBuffer + 0); + float a = *( (float*)pBuffer + 3 ); + float r = *( (float*)pBuffer + 2 ); + float g = *( (float*)pBuffer + 1 ); + float b = *( (float*)pBuffer + 0 ); if( pass & PICK_UV ) { results.uv.x = b; @@ -348,7 +349,7 @@ void Tr2PrimitiveScene::DecodeBufferPixel( const void* pBuffer, PickComponents p results.objectId--; results.depth = r; // If alpha values are set to 1.0. We did not pick anything - if ( a == 1.0f ) + if( a == 1.0f ) { results.objectId = -1; } diff --git a/trinity/Tr2PrimitiveScene.h b/trinity/Tr2PrimitiveScene.h index faff288de..8ca817ccf 100644 --- a/trinity/Tr2PrimitiveScene.h +++ b/trinity/Tr2PrimitiveScene.h @@ -26,7 +26,7 @@ BLUE_DECLARE_VECTOR( Tr2PrimitiveText ); // SeeAlso: // Tr2PrimitiveSet, TriLineSet // ------------------------------------------------------------- -BLUE_CLASS( Tr2PrimitiveScene ) : +BLUE_CLASS( Tr2PrimitiveScene ) : public ITr2Scene, public ITr2PickableScene, public Tr2DeviceResource @@ -37,15 +37,17 @@ BLUE_CLASS( Tr2PrimitiveScene ) : EXPOSE_TO_BLUE(); - void Render( Tr2RenderContext& renderContext ); - void RenderDebugInfo( Tr2RenderContext& renderContext ); + void Render( Tr2RenderContext & renderContext ); + void RenderDebugInfo( Tr2RenderContext & renderContext ); void Update( Be::Time realTime, Be::Time simTime ); - + virtual void ReleaseResources( TriStorage s ); + protected: virtual bool OnPrepareResources(); + private: - ITriRenderBatchAccumulator* m_opaqueBatches; + ITriRenderBatchAccumulator* m_opaqueBatches; ITriRenderBatchAccumulator* m_pickingBatches; TriPoolAllocator* m_allocator; @@ -59,9 +61,9 @@ BLUE_CLASS( Tr2PrimitiveScene ) : return results.object; } void SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport ); - void SetupPerFrameData( Tr2RenderContext& renderContext ); + void SetupPerFrameData( Tr2RenderContext & renderContext ); - void SetPerFrameDataForPicking( Tr2RenderContext& renderContext ); + void SetPerFrameDataForPicking( Tr2RenderContext & renderContext ); const std::vector& GetPickingObjectsToRender( const Vector3& dirWorld ); const std::vector& GetPickingObjectsToRender( const Vector3& dirWorld, float fov, float aspect ); @@ -71,16 +73,20 @@ BLUE_CLASS( Tr2PrimitiveScene ) : // If you need special behaviour for picking, these batches are rendered without a picking override ITriRenderBatchAccumulator* GetPickingBatchAccumulator( void ); - bool RenderPickingAreasForComponents( PickComponents pass ) const { return true; } - unsigned int GetRequiredPasses( PickComponents requestedComponents, PickComponents* passes ); + bool RenderPickingAreasForComponents( PickComponents pass ) const + { + return true; + } + unsigned int GetRequiredPasses( PickComponents requestedComponents, PickComponents * passes ); void DecodeBufferPixel( const void* pBuffer, PickComponents pass, BufferResults& results ) const; Tr2PickBuffer& GetPickBuffer( void ); - virtual bool RenderPicking( ITriRenderBatchAccumulator* pOpaquePickingBatches, - ITriRenderBatchAccumulator* pPickingBatches, - PickComponents pass ); + virtual bool RenderPicking( ITriRenderBatchAccumulator * pOpaquePickingBatches, + ITriRenderBatchAccumulator * pPickingBatches, + PickComponents pass ); + private: // typedef to shorten the iterator declaration typedef Tr2PrimitiveSetVector::const_iterator PrimitiveIterator; @@ -95,7 +101,7 @@ BLUE_CLASS( Tr2PrimitiveScene ) : // Pick buffer Tr2PickBuffer m_pickBuffer; - Tr2ConstantBufferAL m_vertexConstants; + Tr2ConstantBufferAL m_vertexConstants; }; TYPEDEF_BLUECLASS( Tr2PrimitiveScene ); diff --git a/trinity/Tr2PrimitiveScene_Blue.cpp b/trinity/Tr2PrimitiveScene_Blue.cpp index 290a5522c..42078b91b 100644 --- a/trinity/Tr2PrimitiveScene_Blue.cpp +++ b/trinity/Tr2PrimitiveScene_Blue.cpp @@ -20,13 +20,7 @@ static PyObject* PyPickPointAndObject( PyObject* self, PyObject* args ) PyObject* pyViewport = NULL; int x, y; - if (!PyArg_ParseTuple(args, "iiOOO", - &x, - &y, - &pyProjection, - &pyView, - &pyViewport - )) + if( !PyArg_ParseTuple( args, "iiOOO", &x, &y, &pyProjection, &pyView, &pyViewport ) ) return NULL; TriProjection* projection = NULL; @@ -56,13 +50,13 @@ static PyObject* PyPickPointAndObject( PyObject* self, PyObject* args ) if( results.object ) { - PyObject *result = PyTuple_New(2); - PyTuple_SET_ITEM(result, 0, PyOS->WrapBlueObject(results.object) ); - PyTuple_SET_ITEM(result, 1, Py_BuildValue("(fff)", results.position.x, results.position.y, results.position.z ) ); + PyObject* result = PyTuple_New( 2 ); + PyTuple_SET_ITEM( result, 0, PyOS->WrapBlueObject( results.object ) ); + PyTuple_SET_ITEM( result, 1, Py_BuildValue( "(fff)", results.position.x, results.position.y, results.position.z ) ); return result; } - Py_INCREF(Py_None); + Py_INCREF( Py_None ); return Py_None; } #endif @@ -70,16 +64,16 @@ static PyObject* PyPickPointAndObject( PyObject* self, PyObject* args ) const Be::ClassInfo* Tr2PrimitiveScene::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2PrimitiveScene, "" ) - MAP_INTERFACE( Tr2PrimitiveScene ) + EXPOSURE_BEGIN( Tr2PrimitiveScene, "" ) + MAP_INTERFACE( Tr2PrimitiveScene ) MAP_INTERFACE( ITr2Scene ) MAP_ATTRIBUTE( "primitives", m_primitives, "A list of primitive sets to render for this scene", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "textLabels", m_textLabels, "A list of text labels to render for this scene", Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "manipulator", m_manipulator, "The active manipulator working for the scene", Be::READWRITE ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "PickObject", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "PickObject", PickObjectOnly, 1, "Given mouse position and a view setup, returns the object that the mouse is over, as well as the mesh and area indices" @@ -90,12 +84,11 @@ const Be::ClassInfo* Tr2PrimitiveScene::ExposeToBlue() "\n:param projection: The TriProjection to use to pick into the scene" "\n:param view: The TriView to use to pick into the scene" "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" - "\n:param pickFlags: unused\n" - ) + "\n:param pickFlags: unused\n" ) - MAP_METHOD( - "PickPointAndObject", - PyPickPointAndObject, + MAP_METHOD( + "PickPointAndObject", + PyPickPointAndObject, "Given mouse position and a view setup, returns the object that the mouse is over, as well as the mesh and area indices" "\n returns (,(x,y,z)) or None if nothing pickable was hit by the ray" "\n" @@ -109,8 +102,7 @@ const Be::ClassInfo* Tr2PrimitiveScene::ExposeToBlue() "\n:type view: TriView" "\n:param viewport: The TriViewport of the viewport to use to pick into the scene" "\n:type viewport: TriViewport" - "\n:rtype: None | (blue.IRoot, (float, float, float))" - ) + "\n:rtype: None | (blue.IRoot, (float, float, float))" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2PrimitiveSet.cpp b/trinity/Tr2PrimitiveSet.cpp index 06b3d7b6a..cba58a2f1 100644 --- a/trinity/Tr2PrimitiveSet.cpp +++ b/trinity/Tr2PrimitiveSet.cpp @@ -17,12 +17,12 @@ struct PerObjectPSData Matrix WorldMat; }; -// A global multiplier for allowing artists or other to scale all the +// A global multiplier for allowing artists or other to scale all the // fixed scale primitives on screen. -float g_primitiveDistanceScaleMultiplier = 1.0f/7.0f; +float g_primitiveDistanceScaleMultiplier = 1.0f / 7.0f; TRI_REGISTER_SETTING( "primitiveDistanceScaleMultiplier", g_primitiveDistanceScaleMultiplier ); -Tr2PrimitiveSet::Tr2PrimitiveSet( IRoot* lockobj ): +Tr2PrimitiveSet::Tr2PrimitiveSet( IRoot* lockobj ) : m_scaleByDistanceToView( false ), m_scale( 1.0f ), #if BLUE_WITH_PYTHON @@ -48,10 +48,10 @@ bool Tr2PrimitiveSet::HasTransparentBatches() return true; } -void Tr2PrimitiveSet::GetBatches( ITriRenderBatchAccumulator* accumulator, - TriBatchType batchType, - const Tr2PerObjectData* perObjectData, - Tr2RenderReason reason ) +void Tr2PrimitiveSet::GetBatches( ITriRenderBatchAccumulator* accumulator, + TriBatchType batchType, + const Tr2PerObjectData* perObjectData, + Tr2RenderReason reason ) { // Is only rendered as transparent or additive. if( batchType == TRIBATCHTYPE_OPAQUE && m_effect ) @@ -65,22 +65,22 @@ void Tr2PrimitiveSet::GetBatches( ITriRenderBatchAccumulator* accumulator, } float Tr2PrimitiveSet::GetSortValue() -{/* +{ /* Primitives are sorted by the distance to the bounding sphere */ Vector4 bound = GetBoundingSphere(); - Vector3 d = Tr2Renderer::GetViewPosition() - Vector3(bound.x, bound.y, bound.z); + Vector3 d = Tr2Renderer::GetViewPosition() - Vector3( bound.x, bound.y, bound.z ); float distance = Length( d ) - bound.w; return distance; } Vector4 Tr2PrimitiveSet::GetBoundingSphere( void ) -{/* +{ /* The primitives bounding sphere needs to be scaled along with the model */ Vector4 boundingCenter; boundingCenter.GetXYZ() = TransformCoord( m_boundingSphere.GetXYZ(), m_worldTransform ); - boundingCenter.w = (m_boundingSphere.w*m_scale); + boundingCenter.w = ( m_boundingSphere.w * m_scale ); return boundingCenter; } @@ -118,7 +118,7 @@ void Tr2PrimitiveSet::UpdateTransform( void ) Vector3 viewPos = Tr2Renderer::GetViewPosition(); Vector3 lineSetPos = Vector3( m_localTransform._41, m_localTransform._42, m_localTransform._43 ); Vector3 normal = Vector3( view._13, view._23, view._33 ); - Vector3 dir(viewPos - lineSetPos); + Vector3 dir( viewPos - lineSetPos ); m_scale = fabs( Dot( dir, normal ) * g_primitiveDistanceScaleMultiplier * Tr2Renderer::GetFieldOfView() ); scale_mat = ScalingMatrix( m_scale, m_scale, m_scale ); finalTransform = scale_mat * m_localTransform; @@ -128,7 +128,7 @@ void Tr2PrimitiveSet::UpdateTransform( void ) m_scale = 1.0f; } - if ( m_viewOriented ) + if( m_viewOriented ) { // The primitives need to be oriented in such a way // as you were drawing on a x,y plane @@ -167,7 +167,7 @@ void Tr2PrimitiveSet::UpdateTransform( void ) ///////////////////////////////////////////////////////////////////////////// // INotify -bool Tr2PrimitiveSet::OnModified( Be::Var * value ) +bool Tr2PrimitiveSet::OnModified( Be::Var* value ) { // SetCurrentColor is overwritten by any class that inherits if( IsMatch( value, m_color ) ) diff --git a/trinity/Tr2PrimitiveSet.h b/trinity/Tr2PrimitiveSet.h index f6f2c0036..289759b20 100644 --- a/trinity/Tr2PrimitiveSet.h +++ b/trinity/Tr2PrimitiveSet.h @@ -16,35 +16,43 @@ BLUE_DECLARE( Tr2Effect ); Jessica and other authoring tools. */ -BLUE_CLASS( Tr2PrimitiveSet ): - public ITr2Renderable, // An interface for batches, per user data and sorting - public ITr2Pickable, // Make this a pickable object - public INotify // We want to be able to monitor edits through python +BLUE_CLASS( Tr2PrimitiveSet ) : + public ITr2Renderable, // An interface for batches, per user data and sorting + public ITr2Pickable, // Make this a pickable object + public INotify // We want to be able to monitor edits through python { public: EXPOSE_TO_BLUE(); Tr2PrimitiveSet( IRoot* lockobj = NULL ); virtual ~Tr2PrimitiveSet(); - virtual const Matrix& GetWorldTransform( void ) const { return m_worldTransform; } + virtual const Matrix& GetWorldTransform( void ) const + { + return m_worldTransform; + } virtual Vector4 GetBoundingSphere( void ); virtual void UpdateTransform( void ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Pickable - virtual IRoot* GetID( uint16_t ) { return this->GetRawRoot(); } - virtual void GetPickingBatches( ITriRenderBatchAccumulator* batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); + virtual IRoot* GetID( uint16_t ) + { + return this->GetRawRoot(); + } + virtual void GetPickingBatches( ITriRenderBatchAccumulator * batches, Tr2PickTypes pickTypes, const Tr2PerObjectData* perObjectData ); ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* value ); + virtual bool OnModified( Be::Var * value ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches(); virtual float GetSortValue(); - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ); - virtual void SetCurrentColor( Color& val ) { } + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator * accumulator ); + virtual void SetCurrentColor( Color & val ) + { + } enum class GetBatchesReason { @@ -54,31 +62,31 @@ BLUE_CLASS( Tr2PrimitiveSet ): virtual void GetBatchesImpl( ITriRenderBatchAccumulator * accumulator, const Tr2PerObjectData* perObjectData, Tr2Material* effect, GetBatchesReason reason ) = 0; // keeps score of the current scale that is applied to the model - float m_scale; + float m_scale; // should we keep the size of the primitive always the same on screen - bool m_scaleByDistanceToView; + bool m_scaleByDistanceToView; // Should we orient the primitive towards the view - bool m_viewOriented; + bool m_viewOriented; // -- - Vector4 m_boundingSphere; + Vector4 m_boundingSphere; // the end result of the internal calculations - Matrix m_worldTransform; + Matrix m_worldTransform; // for positioning and rotating the view - Matrix m_localTransform; + Matrix m_localTransform; #if BLUE_WITH_PYTHON // for latching on any python objects that might be of use to the programmers - PyObject* m_pythonUserData; + PyObject* m_pythonUserData; #endif // What is the main solid color of our primitive - Color m_color; + Color m_color; // Just a name to help identify the primitive - std::string m_name; + std::string m_name; // Vertex buffer and effects - unsigned int m_vertexDeclHandle; + unsigned int m_vertexDeclHandle; Tr2BufferAL m_vertexBuffer; Tr2EffectPtr m_effect; Tr2EffectPtr m_pickEffect; diff --git a/trinity/Tr2PrimitiveSet_Blue.cpp b/trinity/Tr2PrimitiveSet_Blue.cpp index 60060ce35..eaa646fe2 100644 --- a/trinity/Tr2PrimitiveSet_Blue.cpp +++ b/trinity/Tr2PrimitiveSet_Blue.cpp @@ -7,58 +7,27 @@ BLUE_DEFINE_ABSTRACT( Tr2PrimitiveSet ); const Be::ClassInfo* Tr2PrimitiveSet::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2PrimitiveSet, "" ) + EXPOSURE_BEGIN( Tr2PrimitiveSet, "" ) MAP_INTERFACE( Tr2PrimitiveSet ) MAP_INTERFACE( ITr2Renderable ) MAP_INTERFACE( ITr2Pickable ) - MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "effect", m_effect, - "The effect to use to draw the primitive", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE( "pickEffect", m_pickEffect, - "The effect used to pick the primitive", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE( "name", m_name, - "The name of the primitive", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( "viewOriented", m_viewOriented, - "Rotate the lineset towards the camera\n" - "It assumes that the lineset is setup in a way,\n" - "that the normal of it is the world z and the up vector the world Y.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( "scaleByDistanceToView", m_scaleByDistanceToView, - "Scale the primitive dependent on the distance to the view position", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( "scale", m_scale, - "The current scale of the primitive", - Be::READ - ) - MAP_ATTRIBUTE( "color", m_color, - "The color of the primitive", - Be::READWRITE| Be::NOTIFY| Be::PERSIST - ) - MAP_ATTRIBUTE( "localTransform", m_localTransform, - "primitive sets local transform", - Be::READWRITE| Be::PERSIST - ) - MAP_ATTRIBUTE( "worldTransform", m_worldTransform, - "primitive sets world transform", - Be::READ - ) + MAP_INTERFACE( INotify ) + MAP_ATTRIBUTE( "effect", m_effect, "The effect to use to draw the primitive", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "pickEffect", m_pickEffect, "The effect used to pick the primitive", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "name", m_name, "The name of the primitive", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "viewOriented", m_viewOriented, "Rotate the lineset towards the camera\n" + "It assumes that the lineset is setup in a way,\n" + "that the normal of it is the world z and the up vector the world Y.", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scaleByDistanceToView", m_scaleByDistanceToView, "Scale the primitive dependent on the distance to the view position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "scale", m_scale, "The current scale of the primitive", Be::READ ) + MAP_ATTRIBUTE( "color", m_color, "The color of the primitive", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "localTransform", m_localTransform, "primitive sets local transform", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "worldTransform", m_worldTransform, "primitive sets world transform", Be::READ ) #if BLUE_WITH_PYTHON - MAP_ATTRIBUTE( "_userData", m_pythonUserData, - "Pure python user data attached to the primitive set", - Be::READWRITE - ) + MAP_ATTRIBUTE( "_userData", m_pythonUserData, "Pure python user data attached to the primitive set", Be::READWRITE ) #endif - MAP_METHOD_AND_WRAP( "SetCurrentColor", SetCurrentColor, - "( color )\nSets the color of the primitive\n" - ":param color: primitive color" - ) + MAP_METHOD_AND_WRAP( "SetCurrentColor", SetCurrentColor, "( color )\nSets the color of the primitive\n" + ":param color: primitive color" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2PrimitiveText.h b/trinity/Tr2PrimitiveText.h index 0826ef7ba..40320c6b8 100644 --- a/trinity/Tr2PrimitiveText.h +++ b/trinity/Tr2PrimitiveText.h @@ -16,6 +16,7 @@ BLUE_CLASS( Tr2PrimitiveText ) : ~Tr2PrimitiveText(); void Render(); + private: std::string m_text; Color m_color; diff --git a/trinity/Tr2PrimitiveText_Blue.cpp b/trinity/Tr2PrimitiveText_Blue.cpp index faf0fd266..a436ea3d3 100644 --- a/trinity/Tr2PrimitiveText_Blue.cpp +++ b/trinity/Tr2PrimitiveText_Blue.cpp @@ -6,24 +6,23 @@ BLUE_DEFINE( Tr2PrimitiveText ); -Be::VarChooser TriDebugFontChooser[] = -{ - { "FontSmall", BeCast( TRI_DBG_FONT_SMALL ), "Small debug font" }, - { "FontMedium", BeCast( TRI_DBG_FONT_MEDIUM ), "Medium debug font" }, - { "FontLarge", BeCast( TRI_DBG_FONT_LARGE ), "Larget debug font" }, +Be::VarChooser TriDebugFontChooser[] = { + { "FontSmall", BeCast( TRI_DBG_FONT_SMALL ), "Small debug font" }, + { "FontMedium", BeCast( TRI_DBG_FONT_MEDIUM ), "Medium debug font" }, + { "FontLarge", BeCast( TRI_DBG_FONT_LARGE ), "Larget debug font" }, { 0 } }; BLUE_REGISTER_ENUM_EX( "TriDebugFont", TriDebugFont, TriDebugFontChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); const Be::ClassInfo* Tr2PrimitiveText::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2PrimitiveText, "" ) - MAP_INTERFACE( Tr2PrimitiveText ) + EXPOSURE_BEGIN( Tr2PrimitiveText, "" ) + MAP_INTERFACE( Tr2PrimitiveText ) MAP_ATTRIBUTE( "text", m_text, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "position", m_position, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE_WITH_CHOOSER( "font", m_font, "", Be::READWRITE | Be::PERSIST | Be::ENUM, TriDebugFontChooser ) - EXPOSURE_END() + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2ProceduralResources.cpp b/trinity/Tr2ProceduralResources.cpp index bad95eeab..6e1629408 100644 --- a/trinity/Tr2ProceduralResources.cpp +++ b/trinity/Tr2ProceduralResources.cpp @@ -7,62 +7,64 @@ namespace { - template - class Tr2ProceduralResourceRegistry: public Tr2DeviceResource +template +class Tr2ProceduralResourceRegistry : public Tr2DeviceResource +{ +public: + const typename T::ResourceType* GetResource( const BlueSharedString& name, typename T::FactoryFunction factory ) { - public: - const typename T::ResourceType* GetResource( const BlueSharedString& name, typename T::FactoryFunction factory ) + auto found = m_resources.find( name ); + if( found != m_resources.end() ) { - auto found = m_resources.find( name ); - if( found != m_resources.end() ) - { - return &found->second->resource; - } - auto resource = new Resource; - resource->factory = factory; - if( Tr2Renderer::IsResourceCreationAllowed() ) - { - USE_MAIN_THREAD_RENDER_CONTEXT(); - resource->factory( resource->resource, renderContext ); - } - m_resources[name] = resource; - return &resource->resource; + return &found->second->resource; } - protected: - void ReleaseResources( TriStorage ) override + auto resource = new Resource; + resource->factory = factory; + if( Tr2Renderer::IsResourceCreationAllowed() ) { + USE_MAIN_THREAD_RENDER_CONTEXT(); + resource->factory( resource->resource, renderContext ); } + m_resources[name] = resource; + return &resource->resource; + } + +protected: + void ReleaseResources( TriStorage ) override + { + } - bool OnPrepareResources() override + bool OnPrepareResources() override + { + USE_MAIN_THREAD_RENDER_CONTEXT(); + for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) { - USE_MAIN_THREAD_RENDER_CONTEXT(); - for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) + if( !it->second->resource.IsValid() ) { - if( !it->second->resource.IsValid() ) - { - it->second->factory( it->second->resource, renderContext ); - } + it->second->factory( it->second->resource, renderContext ); } - return true; } - private: - struct Resource - { - typename T::ResourceType resource; - typename T::FactoryFunction factory; - }; - std::map m_resources; - }; + return true; + } - Tr2ProceduralResourceRegistry& GetBuffers() +private: + struct Resource { - static Tr2ProceduralResourceRegistry instance; - return instance; - } + typename T::ResourceType resource; + typename T::FactoryFunction factory; + }; + std::map m_resources; +}; + +Tr2ProceduralResourceRegistry& GetBuffers() +{ + static Tr2ProceduralResourceRegistry instance; + return instance; +} } -Tr2ProceduralBuffer::Tr2ProceduralBuffer( const BlueSharedString& name, FactoryFunction factory ) - :m_resource( GetBuffers().GetResource( name, factory ) ) +Tr2ProceduralBuffer::Tr2ProceduralBuffer( const BlueSharedString& name, FactoryFunction factory ) : + m_resource( GetBuffers().GetResource( name, factory ) ) { } diff --git a/trinity/Tr2ProfileTimer.cpp b/trinity/Tr2ProfileTimer.cpp index c1108fbbd..c1880506d 100644 --- a/trinity/Tr2ProfileTimer.cpp +++ b/trinity/Tr2ProfileTimer.cpp @@ -5,30 +5,29 @@ namespace { - CcpStaticStatisticsEntry* GetOrCreateStatisticsEntry( const std::string& name ) +CcpStaticStatisticsEntry* GetOrCreateStatisticsEntry( const std::string& name ) +{ + auto& entries = CcpStatistics::GetEntryArray(); + for( auto it = entries.begin(); it != entries.end(); ++it ) { - auto& entries = CcpStatistics::GetEntryArray(); - for( auto it = entries.begin(); it != entries.end(); ++it ) + if( ( *it )->GetName() == name ) { - if( ( *it )->GetName() == name ) - { - return *it; - } + return *it; } - return BlueStatistics::CreateDynamicEntry( name.c_str(), false, CST_TIME, "" ); } + return BlueStatistics::CreateDynamicEntry( name.c_str(), false, CST_TIME, "" ); +} } // ------------------------------------------------------------- -Tr2ProfileTimer::Tr2ProfileTimer() - :m_captureGpuTime( false ), +Tr2ProfileTimer::Tr2ProfileTimer() : + m_captureGpuTime( false ), m_captureCpuTime( false ), m_beginTime( 0 ), m_cpuTime( -1.f ), m_statEntryCpu( nullptr ), m_statEntryGpu( nullptr ) { - } // ------------------------------------------------------------- diff --git a/trinity/Tr2ProfileTimer.h b/trinity/Tr2ProfileTimer.h index 3e464fa2a..7e0c087e4 100644 --- a/trinity/Tr2ProfileTimer.h +++ b/trinity/Tr2ProfileTimer.h @@ -4,7 +4,7 @@ #include "Tr2DeviceResource.h" -class Tr2ProfileTimer: public Tr2DeviceResource +class Tr2ProfileTimer : public Tr2DeviceResource { public: Tr2ProfileTimer(); @@ -23,6 +23,7 @@ class Tr2ProfileTimer: public Tr2DeviceResource const std::string& GetStatName() const; void SetStatName( const char* name ); + private: virtual void ReleaseResources( TriStorage ); virtual bool OnPrepareResources(); diff --git a/trinity/Tr2ProjectBoundingBoxBracket.cpp b/trinity/Tr2ProjectBoundingBoxBracket.cpp index aaba9777f..3c6bb5893 100644 --- a/trinity/Tr2ProjectBoundingBoxBracket.cpp +++ b/trinity/Tr2ProjectBoundingBoxBracket.cpp @@ -58,7 +58,7 @@ void Tr2ProjectBoundingBoxBracket::UpdateValue( double time ) return; } - Vector3 center = (bbMax + bbMin) * 0.5f; + Vector3 center = ( bbMax + bbMin ) * 0.5f; Vector3 projectedCenter; Matrix viewProj; projectedCenter = TransformCoord( center, Tr2Renderer::GetViewTransform() ); @@ -73,13 +73,12 @@ void Tr2ProjectBoundingBoxBracket::UpdateValue( double time ) Vector3 d = Tr2Renderer::GetViewPosition() - center; m_cameraDistance = Length( d ); - BoundingBoxProject( - bbMin, - bbMax, + BoundingBoxProject( + bbMin, + bbMax, Tr2Renderer::GetViewTransform(), - Tr2Renderer::GetProjectionTransform(), - Tr2Renderer::GetViewport() - ); + Tr2Renderer::GetProjectionTransform(), + Tr2Renderer::GetViewport() ); if( bbMin.z <= 0.0f || bbMax.z >= 1.0f ) { @@ -87,13 +86,13 @@ void Tr2ProjectBoundingBoxBracket::UpdateValue( double time ) return; } - m_projectedZ = std::min(bbMin.z, bbMax.z); + m_projectedZ = std::min( bbMin.z, bbMax.z ); unsigned int screenWidth; unsigned int screenHeight; Tr2Renderer::GetBackBufferDimensions( screenWidth, screenHeight ); - if( (bbMin.x > screenWidth) || (bbMax.x < 0.0f) || (bbMin.y > screenHeight) || (bbMax.y < 0.0f) ) + if( ( bbMin.x > screenWidth ) || ( bbMax.x < 0.0f ) || ( bbMin.y > screenHeight ) || ( bbMax.y < 0.0f ) ) { SetEmptyProjection(); return; @@ -155,8 +154,8 @@ void Tr2ProjectBoundingBoxBracket::UpdateValue( double time ) else { // Unbounded brackets are centered around the center of the projected bounding box - centerX = (bbMin.x + bbMax.x) * 0.5f; - centerY = (bbMin.y + bbMax.y) * 0.5f; + centerX = ( bbMin.x + bbMax.x ) * 0.5f; + centerY = ( bbMin.y + bbMax.y ) * 0.5f; } m_projectedX = centerX - m_projectedWidth * 0.5f; m_projectedY = centerY - m_projectedHeight * 0.5f; diff --git a/trinity/Tr2ProjectBoundingBoxBracket.h b/trinity/Tr2ProjectBoundingBoxBracket.h index 17d14f428..6cb1bab0d 100644 --- a/trinity/Tr2ProjectBoundingBoxBracket.h +++ b/trinity/Tr2ProjectBoundingBoxBracket.h @@ -11,8 +11,7 @@ BLUE_DECLARE( Tr2ProjectBoundingBoxBracket ); BLUE_DECLARE( Tr2Sprite2dContainer ); BLUE_DECLARE_INTERFACE( ITr2BoundingBox ); -class Tr2ProjectBoundingBoxBracket : - public ITriFunction +class Tr2ProjectBoundingBoxBracket : public ITriFunction { public: EXPOSE_TO_BLUE(); diff --git a/trinity/Tr2ProjectBoundingBoxBracket_Blue.cpp b/trinity/Tr2ProjectBoundingBoxBracket_Blue.cpp index 2a544c15c..0976638a4 100644 --- a/trinity/Tr2ProjectBoundingBoxBracket_Blue.cpp +++ b/trinity/Tr2ProjectBoundingBoxBracket_Blue.cpp @@ -12,131 +12,99 @@ const Be::ClassInfo* Tr2ProjectBoundingBoxBracket::ExposeToBlue() EXPOSURE_BEGIN( Tr2ProjectBoundingBoxBracket, "Projects a 3D bounding box to 2D for brackets \n:jessica-deprecated: True" ) MAP_INTERFACE( ITriFunction ) MAP_INTERFACE( Tr2ProjectBoundingBoxBracket ) - - MAP_ATTRIBUTE - ( + + MAP_ATTRIBUTE( "name", m_name, "Name of this object", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( + Be::READWRITE ) + + MAP_ATTRIBUTE( "object", m_object, "Object to track", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "bracket", m_bracket, "The sprite container to receive the projected position", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "parent", m_parent, "Parent of the sprite container", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "minProjectedWidth", m_minProjectedWidth, "Minimum width after projection", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "minProjectedHeight", m_minProjectedHeight, "Minimum height after projection", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxProjectedWidth", m_maxProjectedWidth, "Maximum width after projection", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "maxProjectedHeight", m_maxProjectedHeight, "Maximum height after projection", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "projectedX", m_projectedX, "x-coordinate after projection", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "projectedY", m_projectedY, "y-coordinate after projection", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "projectedZ", m_projectedZ, "z-coordinate after projection", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "projectedWidth", m_projectedWidth, "Width after projection", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "projectedHeight", m_projectedHeight, "Height after projection", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "cameraDistance", m_cameraDistance, "Distance of the object from the camera, as determined by the\n" "center of the bounding box.", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "integerCoordinates", m_integerCoordinates, "If set, projected x, y, width and height are rounded to the nearest integer.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "screenMargin", m_screenMargin, "Brackets are never projected outside the screen - this controls the margin from" "\nthe edges of the screen.", - Be::READWRITE - ) + Be::READWRITE ) EXPOSURE_END() } diff --git a/trinity/Tr2PushPopDS.cpp b/trinity/Tr2PushPopDS.cpp index b2befdcf5..d89dd9bb0 100644 --- a/trinity/Tr2PushPopDS.cpp +++ b/trinity/Tr2PushPopDS.cpp @@ -4,28 +4,28 @@ #include "Tr2PushPopDS.h" #include "Tr2Renderer.h" -Tr2PushPopDS::Tr2PushPopDS() -: m_renderContext( nullptr ) +Tr2PushPopDS::Tr2PushPopDS() : + m_renderContext( nullptr ) { USE_MAIN_THREAD_RENDER_CONTEXT(); renderContext.m_esm.PushDepthStencilBuffer(); } -Tr2PushPopDS::Tr2PushPopDS( const Tr2TextureAL& ds ) -: m_renderContext( nullptr ) +Tr2PushPopDS::Tr2PushPopDS( const Tr2TextureAL& ds ) : + m_renderContext( nullptr ) { USE_MAIN_THREAD_RENDER_CONTEXT(); renderContext.m_esm.PushDepthStencilBuffer( ds ); } -Tr2PushPopDS::Tr2PushPopDS( Tr2RenderContext& renderContext ) -: m_renderContext( &renderContext ) +Tr2PushPopDS::Tr2PushPopDS( Tr2RenderContext& renderContext ) : + m_renderContext( &renderContext ) { renderContext.m_esm.PushDepthStencilBuffer(); } -Tr2PushPopDS::Tr2PushPopDS( const Tr2TextureAL& ds, Tr2RenderContext& renderContext ) -: m_renderContext( &renderContext ) +Tr2PushPopDS::Tr2PushPopDS( const Tr2TextureAL& ds, Tr2RenderContext& renderContext ) : + m_renderContext( &renderContext ) { renderContext.m_esm.PushDepthStencilBuffer( ds ); } diff --git a/trinity/Tr2PushPopDS.h b/trinity/Tr2PushPopDS.h index a13bf1367..1a31ad780 100644 --- a/trinity/Tr2PushPopDS.h +++ b/trinity/Tr2PushPopDS.h @@ -43,4 +43,4 @@ struct Tr2PushPopDS Tr2PushPopDS& operator=( Tr2PushPopDS& ); }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/trinity/Tr2PushPopRT.cpp b/trinity/Tr2PushPopRT.cpp index bb9069a0a..865a1c638 100644 --- a/trinity/Tr2PushPopRT.cpp +++ b/trinity/Tr2PushPopRT.cpp @@ -4,32 +4,28 @@ #include "Tr2PushPopRT.h" #include "Tr2Renderer.h" -Tr2PushPopRT::Tr2PushPopRT( uint32_t slot ) -: m_renderContext( nullptr ) -, m_slot( slot ) +Tr2PushPopRT::Tr2PushPopRT( uint32_t slot ) : + m_renderContext( nullptr ), m_slot( slot ) { USE_MAIN_THREAD_RENDER_CONTEXT(); renderContext.m_esm.PushRenderTarget( slot ); } -Tr2PushPopRT::Tr2PushPopRT( const Tr2TextureAL& rt, uint32_t slot ) -: m_renderContext( nullptr ) -, m_slot( slot ) +Tr2PushPopRT::Tr2PushPopRT( const Tr2TextureAL& rt, uint32_t slot ) : + m_renderContext( nullptr ), m_slot( slot ) { USE_MAIN_THREAD_RENDER_CONTEXT(); renderContext.m_esm.PushRenderTarget( rt, slot ); } -Tr2PushPopRT::Tr2PushPopRT( Tr2RenderContext& renderContext, uint32_t slot ) -: m_renderContext( &renderContext ) -, m_slot( slot ) +Tr2PushPopRT::Tr2PushPopRT( Tr2RenderContext& renderContext, uint32_t slot ) : + m_renderContext( &renderContext ), m_slot( slot ) { renderContext.m_esm.PushRenderTarget( slot ); } -Tr2PushPopRT::Tr2PushPopRT( const Tr2TextureAL& rt, Tr2RenderContext& renderContext, uint32_t slot ) -: m_renderContext( &renderContext ) -, m_slot( slot ) +Tr2PushPopRT::Tr2PushPopRT( const Tr2TextureAL& rt, Tr2RenderContext& renderContext, uint32_t slot ) : + m_renderContext( &renderContext ), m_slot( slot ) { renderContext.m_esm.PushRenderTarget( rt, slot ); } diff --git a/trinity/Tr2PushPopRT.h b/trinity/Tr2PushPopRT.h index df7213300..5408b332b 100644 --- a/trinity/Tr2PushPopRT.h +++ b/trinity/Tr2PushPopRT.h @@ -39,7 +39,7 @@ struct Tr2PushPopRT private: Tr2RenderContext* m_renderContext; - uint32_t m_slot; + uint32_t m_slot; Tr2PushPopRT( Tr2PushPopRT& ); Tr2PushPopRT& operator=( Tr2PushPopRT& ); diff --git a/trinity/Tr2PyValueBinding.cpp b/trinity/Tr2PyValueBinding.cpp index 06ae91df6..be4ce528d 100644 --- a/trinity/Tr2PyValueBinding.cpp +++ b/trinity/Tr2PyValueBinding.cpp @@ -6,8 +6,8 @@ #include "Tr2PyValueBinding.h" -Tr2PyValueBinding::Tr2PyValueBinding( IRoot* lockobj ) - :m_isValid( false ) +Tr2PyValueBinding::Tr2PyValueBinding( IRoot* lockobj ) : + m_isValid( false ) { m_sourceObject = Py_None; Py_INCREF( m_sourceObject ); @@ -44,10 +44,7 @@ void Tr2PyValueBinding::Initialize() { m_isValid = false; - if( m_sourceObject != Py_None - && m_destinationObject != Py_None - && !m_sourceAttribute.empty() - && !m_destinationAttribute.empty() ) + if( m_sourceObject != Py_None && m_destinationObject != Py_None && !m_sourceAttribute.empty() && !m_destinationAttribute.empty() ) { // We have valid Python objects and attributes have been specified. // We don't check here if attributes are valid - this may change and diff --git a/trinity/Tr2PyValueBinding.h b/trinity/Tr2PyValueBinding.h index 26bef42f8..8a519d552 100644 --- a/trinity/Tr2PyValueBinding.h +++ b/trinity/Tr2PyValueBinding.h @@ -9,14 +9,13 @@ BLUE_DECLARE( Tr2PyValueBinding ); -class Tr2PyValueBinding: - public INotify, - public ITr2ValueBinding +class Tr2PyValueBinding : public INotify, + public ITr2ValueBinding { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); - Tr2PyValueBinding( IRoot* lockobj = NULL ); + Tr2PyValueBinding( IRoot* lockobj = NULL ); ~Tr2PyValueBinding(); ////////////////////////////////////////////////////////////////////////// diff --git a/trinity/Tr2PyValueBinding_Blue.cpp b/trinity/Tr2PyValueBinding_Blue.cpp index 2a512a451..972f12f0b 100644 --- a/trinity/Tr2PyValueBinding_Blue.cpp +++ b/trinity/Tr2PyValueBinding_Blue.cpp @@ -10,58 +10,46 @@ BLUE_DEFINE( Tr2PyValueBinding ); const Be::ClassInfo* Tr2PyValueBinding::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2PyValueBinding,"" ) - MAP_INTERFACE( Tr2PyValueBinding ) + EXPOSURE_BEGIN( Tr2PyValueBinding, "" ) + MAP_INTERFACE( Tr2PyValueBinding ) MAP_INTERFACE( ITr2ValueBinding ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "name", - m_name, + MAP_ATTRIBUTE( + "name", + m_name, "Name of this value binding.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "isValid", m_isValid, "True if this binding is valid, i.e. source object, source attribute\n" "destination object and destination attribute are all set.", - Be::READ - ) - MAP_ATTRIBUTE - ( - "sourceObject", - m_sourceObject, - "Object providing the source value.", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( - "sourceAttribute", - m_sourceAttribute, + Be::READ ) + MAP_ATTRIBUTE( + "sourceObject", + m_sourceObject, + "Object providing the source value.", + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( + "sourceAttribute", + m_sourceAttribute, "Attribute of the source object. The value of this is copied to the" "named attribute of the destination object", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE( "destinationObject", m_destinationObject, "Destination object.", - Be::READWRITE | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "destinationAttribute", m_destinationAttribute, "Attribute of the destination object. The value coming from the" "source object is copied to here", - Be::READWRITE | Be::NOTIFY | Be::PERSIST - ) + Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } #endif diff --git a/trinity/Tr2QuadRenderer.cpp b/trinity/Tr2QuadRenderer.cpp index 9d677ae82..da8046d9d 100644 --- a/trinity/Tr2QuadRenderer.cpp +++ b/trinity/Tr2QuadRenderer.cpp @@ -23,8 +23,8 @@ uint32_t Align( uint32_t offset, uint32_t alignment ) } -Tr2QuadRenderer::Tr2QuadRenderer( IRoot* ) - :m_vertexBufferOffset( -1 ), +Tr2QuadRenderer::Tr2QuadRenderer( IRoot* ) : + m_vertexBufferOffset( -1 ), m_buffer( "Tr2QuadRenderer::m_buffer", 1024, 128 ), m_effects( "Tr2QuadRenderer::m_effects" ), m_bufferSize( 0 ), @@ -58,12 +58,12 @@ Tr2QuadRenderer* Tr2QuadRenderer::Instance() // definition - vertex definition for instance data // effect - effect to use for rendering // -------------------------------------------------------------------------------------- -void Tr2QuadRenderer::RegisterEffect( - EffectKey key, +void Tr2QuadRenderer::RegisterEffect( + EffectKey key, TriBatchType batchType, - uint32_t instanceSize, - uint32_t quadCount, - const Tr2VertexDefinition& definition, + uint32_t instanceSize, + uint32_t quadCount, + const Tr2VertexDefinition& definition, Tr2Material* effect ) { auto found = m_effects.find( key ); @@ -85,7 +85,7 @@ void Tr2QuadRenderer::RegisterEffect( // -------------------------------------------------------------------------------------- // Description: -// Needs to be called after all renderer batches were submitted and before new +// Needs to be called after all renderer batches were submitted and before new // instances are added. // -------------------------------------------------------------------------------------- void Tr2QuadRenderer::DoneRendering( Tr2RenderContext& renderContext ) @@ -114,8 +114,8 @@ void Tr2QuadRenderer::AddQuads( EffectKey effectKey, const void* sprites, size_t auto size = count * record->instanceSize; if( tls.buffer.size() < tls.addedSize + size ) { - tls.buffer.resize( - "Tr2InstancePool::buffer", + tls.buffer.resize( + "Tr2InstancePool::buffer", std::max( tls.buffer.size() * 2, tls.buffer.size() + std::max( count, size_t( 512 ) ) * record->instanceSize ) ); } memcpy( tls.buffer.get() + tls.addedSize, sprites, size ); @@ -236,7 +236,7 @@ void Tr2QuadRenderer::RecreateQuadBuffers( uint32_t quadCount ) // -------------------------------------------------------------------------------------- // Description: -// Needs to be called after all instance data was added to the renderer, but before +// Needs to be called after all instance data was added to the renderer, but before // GetBatches call. // Arguments: // renderContext - current render context @@ -270,7 +270,7 @@ void Tr2QuadRenderer::ReleaseResources( TriStorage s ) // -------------------------------------------------------------------------------------- // Description: -// Implements Tr2DeviceResource method. Re-creates vertex declarations for registered +// Implements Tr2DeviceResource method. Re-creates vertex declarations for registered // effects. // Return value: // true always diff --git a/trinity/Tr2QuadRenderer.h b/trinity/Tr2QuadRenderer.h index e1d548137..49b3f6a2b 100644 --- a/trinity/Tr2QuadRenderer.h +++ b/trinity/Tr2QuadRenderer.h @@ -19,23 +19,24 @@ BLUE_DECLARE( Tr2Material ); // See Also: // EveSpaceScene, EveSpriteSet // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2QuadRenderer ): public IRoot, public Tr2DeviceResource +BLUE_CLASS( Tr2QuadRenderer ) : + public IRoot, public Tr2DeviceResource { public: Tr2QuadRenderer( IRoot* parent = nullptr ); EXPOSE_TO_BLUE(); - typedef uint64_t EffectKey; + typedef uint64_t EffectKey; void RegisterEffect( EffectKey key, TriBatchType batchType, uint32_t instanceSize, uint32_t quadCount, const Tr2VertexDefinition& definition, Tr2Material* effect ); void UnregisterEffect( EffectKey key ); void AddQuads( EffectKey effectKey, const void* sprites, size_t count ); - void BeginRendering( Tr2RenderContext& renderContext ); - void DoneRendering( Tr2RenderContext& renderContext ); + void BeginRendering( Tr2RenderContext & renderContext ); + void DoneRendering( Tr2RenderContext & renderContext ); - void GetBatches( TriBatchType batchType, ITriRenderBatchAccumulator* accumulator ); + void GetBatches( TriBatchType batchType, ITriRenderBatchAccumulator * accumulator ); virtual void ReleaseResources( TriStorage s ); @@ -43,11 +44,12 @@ BLUE_CLASS( Tr2QuadRenderer ): public IRoot, public Tr2DeviceResource uint32_t GetInstanceDataSize() const; static Tr2QuadRenderer* Instance(); + private: struct PerThreadData { - PerThreadData() - :addedSize( 0 ) + PerThreadData() : + addedSize( 0 ) { } @@ -82,7 +84,7 @@ BLUE_CLASS( Tr2QuadRenderer ): public IRoot, public Tr2DeviceResource virtual bool OnPrepareResources(); uint32_t MergeBuffers(); - void UpdateInstanceBuffer( Tr2RenderContext& renderContext ); + void UpdateInstanceBuffer( Tr2RenderContext & renderContext ); void RecreateQuadBuffers( uint32_t quadCount ); // Map of registered effects diff --git a/trinity/Tr2QuadRenderer_Blue.cpp b/trinity/Tr2QuadRenderer_Blue.cpp index 66df95279..2de44eb7f 100644 --- a/trinity/Tr2QuadRenderer_Blue.cpp +++ b/trinity/Tr2QuadRenderer_Blue.cpp @@ -11,19 +11,15 @@ const Be::ClassInfo* Tr2QuadRenderer::ExposeToBlue() EXPOSURE_BEGIN( Tr2QuadRenderer, "" ) MAP_INTERFACE( Tr2QuadRenderer ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "instanceBufferSize", GetInstanceBufferSize, - "Current size of the instance buffer" - ) + "Current size of the instance buffer" ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "instanceDataSize", GetInstanceDataSize, - "Size of the instance data last frame" - ) + "Size of the instance data last frame" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2ReflectionProbe.cpp b/trinity/Tr2ReflectionProbe.cpp index 110d54491..3b7224ce3 100644 --- a/trinity/Tr2ReflectionProbe.cpp +++ b/trinity/Tr2ReflectionProbe.cpp @@ -96,7 +96,7 @@ uint8_t Tr2ReflectionProbe::GetEndFace() const } -void Tr2ReflectionProbe::InitRenderPass( Tr2RenderContext &renderContext ) +void Tr2ReflectionProbe::InitRenderPass( Tr2RenderContext& renderContext ) { if( !m_lockPosition ) { @@ -113,15 +113,15 @@ void Tr2ReflectionProbe::InitRenderPass( Tr2RenderContext &renderContext ) // Square projection matrix, with near and far clip planes from the current projection Matrix newProjection = IdentityMatrix(); - const Matrix ¤tProjection = Tr2Renderer::GetProjectionTransform(); + const Matrix& currentProjection = Tr2Renderer::GetProjectionTransform(); newProjection.m[2][2] = currentProjection.m[2][2]; newProjection.m[2][3] = -1.0f; newProjection.m[3][2] = currentProjection.m[3][2]; newProjection.m[3][3] = 0.0f; - + Tr2Renderer::SetProjectionTransform( newProjection ); - // We need to invert cull-mode because of the left-handed coordinates of the cube rendertarget + // We need to invert cull-mode because of the left-handed coordinates of the cube rendertarget m_prevCullInversion = renderContext.m_esm.IsCullModeInverted(); renderContext.m_esm.SetInvertedCullMode( true ); @@ -144,38 +144,37 @@ Tr2TextureAL Tr2ReflectionProbe::GetDepthBuffer( unsigned face ) return m_stencilMaps[face]; } -void Tr2ReflectionProbe::StartRenderFace( unsigned face, Tr2RenderContext &renderContext ) +void Tr2ReflectionProbe::StartRenderFace( unsigned face, Tr2RenderContext& renderContext ) { renderContext.RenderPassHint( { Tr2LoadAction::CLEAR, Tr2StoreAction::STORE, 0 }, { Tr2LoadAction::CLEAR, Tr2StoreAction::DONT_CARE, 0.F } ); renderContext.m_esm.SetRenderTarget( 0, *m_renderTargets[face] ); renderContext.m_esm.SetDepthStencilBuffer( m_stencilMaps[face] ); - static const Vector3 faceDirections[] = - { + static const Vector3 faceDirections[] = { Vector3( 0, 1, 0 ), Vector3( 1, 0, 0 ), //+X - Vector3( 0, 1, 0 ), Vector3(-1, 0, 0 ), //-X - Vector3( 0, 0,-1 ), Vector3( 0, 1, 0 ), //+Y - Vector3( 0, 0, 1 ), Vector3( 0,-1, 0 ), //-Y - Vector3( 0, 1, 0 ), Vector3( 0, 0, 1 ), //+Z - Vector3( 0, 1, 0 ), Vector3( 0, 0,-1 ), //-Z + Vector3( 0, 1, 0 ), + Vector3( -1, 0, 0 ), //-X + Vector3( 0, 0, -1 ), + Vector3( 0, 1, 0 ), //+Y + Vector3( 0, 0, 1 ), + Vector3( 0, -1, 0 ), //-Y + Vector3( 0, 1, 0 ), + Vector3( 0, 0, 1 ), //+Z + Vector3( 0, 1, 0 ), + Vector3( 0, 0, -1 ), //-Z }; // We need to invert the X-axis because of the left-handed coordinates of the cube rendertarget - static const Matrix xInverter = Matrix - ( - -1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ); - - const Vector3 &up = faceDirections[ face * 2 ]; - const Vector3 &at = faceDirections[ face * 2 + 1 ]; + static const Matrix xInverter = Matrix( + -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ); + + const Vector3& up = faceDirections[face * 2]; + const Vector3& at = faceDirections[face * 2 + 1]; Tr2Renderer::SetViewTransform( LookAtMatrix( m_position, m_position + at, up ) * xInverter ); } -void Tr2ReflectionProbe::EndRenderPass( Tr2RenderContext &renderContext ) +void Tr2ReflectionProbe::EndRenderPass( Tr2RenderContext& renderContext ) { { GPU_REGION( renderContext, "Reflection RT Copy" ); @@ -197,7 +196,7 @@ void Tr2ReflectionProbe::EndRenderPass( Tr2RenderContext &renderContext ) Filter( renderContext ); m_hasData = true; m_onePassDone = true; - + if( m_renderFrequency != ALL_SIDES_PER_FRAME ) { m_currentFrame = ( m_currentFrame + 1 ) % 6; @@ -278,7 +277,7 @@ bool Tr2ReflectionProbe::DoPrepareResources( ImageIO::PixelFormat rtFormat, Tr2P { m_filterEffect->SetEffectPathName( "res:/graphics/effect/managed/space/System/Reflection/ReflectionFilterActivision128.fx" ); m_preFilterEffect->SetEffectPathName( "res:/graphics/effect/managed/space/System/Reflection/ReflectionFilterActivisionPre.fx" ); - auto source = dynamic_cast< ITr2TextureProvider* >( m_customSourceTexture.p ); + auto source = dynamic_cast( m_customSourceTexture.p ); m_preFilterEffect->SetParameter( BlueSharedString( "tex_hi_res" ), source ? source : static_cast( m_renderTargetCube ) ); m_preFilterEffect->SetParameter( BlueSharedString( "tex_lo_res" ), m_preFilterTarget ); @@ -345,7 +344,7 @@ void Tr2ReflectionProbe::DestroyRenderTargets() m_currentFrame = 0; } -void Tr2ReflectionProbe::Filter( Tr2RenderContext &renderContext ) +void Tr2ReflectionProbe::Filter( Tr2RenderContext& renderContext ) { if( !IsValid() ) return; @@ -396,6 +395,6 @@ bool Tr2ReflectionProbe::IsHollyWoodModeOn() const bool Tr2ReflectionProbe::ReadyForDynamicObjectReflections() const { - // We need to have initialized the cubemap, before we start using it for rendering reflections (otherwise we just get garbage!) - return m_onePassDone; + // We need to have initialized the cubemap, before we start using it for rendering reflections (otherwise we just get garbage!) + return m_onePassDone; } diff --git a/trinity/Tr2ReflectionProbe.h b/trinity/Tr2ReflectionProbe.h index aff92e1cc..ba1883391 100644 --- a/trinity/Tr2ReflectionProbe.h +++ b/trinity/Tr2ReflectionProbe.h @@ -33,9 +33,9 @@ BLUE_CLASS( Tr2ReflectionProbe ) : bool IsValid(); bool HasData() const; - void InitRenderPass( Tr2RenderContext &renderContext ); - void StartRenderFace( unsigned face, Tr2RenderContext &renderContext ); - void EndRenderPass( Tr2RenderContext &renderContext ); + void InitRenderPass( Tr2RenderContext & renderContext ); + void StartRenderFace( unsigned face, Tr2RenderContext& renderContext ); + void EndRenderPass( Tr2RenderContext & renderContext ); Tr2TextureAL GetDepthBuffer( unsigned face ); TriFrustum GetFrustum( unsigned face, Tr2RenderContext& renderContext ); @@ -44,10 +44,10 @@ BLUE_CLASS( Tr2ReflectionProbe ) : void SetPosition( Vector3 position ); void SetBackLightColor( Color color ); - void SetIntensity( float intensity); + void SetIntensity( float intensity ); void SetBackLightContrast( float contrast ); - bool OnModified( Be::Var* value ); + bool OnModified( Be::Var * value ); bool IsHollyWoodModeOn() const; bool ReadyForDynamicObjectReflections() const; @@ -62,8 +62,8 @@ BLUE_CLASS( Tr2ReflectionProbe ) : private: void RunFilter(); - void Filter( Tr2RenderContext &renderContext ); - bool DoPrepareResources( ImageIO::PixelFormat targetFormat, Tr2PrimaryRenderContext& renderContext ); + void Filter( Tr2RenderContext & renderContext ); + bool DoPrepareResources( ImageIO::PixelFormat targetFormat, Tr2PrimaryRenderContext & renderContext ); void DestroyRenderTargets(); bool m_initialized; diff --git a/trinity/Tr2ReflectionProbe_Blue.cpp b/trinity/Tr2ReflectionProbe_Blue.cpp index 52237229d..323d953a9 100644 --- a/trinity/Tr2ReflectionProbe_Blue.cpp +++ b/trinity/Tr2ReflectionProbe_Blue.cpp @@ -24,7 +24,7 @@ const Be::ClassInfo* Tr2ReflectionProbe::ExposeToBlue() MAP_ATTRIBUTE( "position", m_position, "Origin for the reflection", Be::READWRITE ) MAP_ATTRIBUTE( "lockPosition", m_lockPosition, "Lock the position of the reflection", Be::READWRITE ) MAP_ATTRIBUTE( "reflectionSize", m_intermediateSize, "Size for the unfiltered reflection map", Be::READWRITE | Be::NOTIFY ) - MAP_ATTRIBUTE( "customSourceTexture", m_customSourceTexture, "A custom texture for filtering", Be::READWRITE | Be::NOTIFY) + MAP_ATTRIBUTE( "customSourceTexture", m_customSourceTexture, "A custom texture for filtering", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "hdrOutput", m_hdrOutput, "Generate HDR reflection texture", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE_WITH_CHOOSER( "renderFrequency", m_renderFrequency, "", Be::READWRITE | Be::NOTIFY | Be::ENUM, RenderFrequencyChooser ) MAP_ATTRIBUTE( "currentFrame", m_currentFrame, "", Be::READ ) diff --git a/trinity/Tr2RenderContext.cpp b/trinity/Tr2RenderContext.cpp index cc8b6dea3..7eb2abbf3 100644 --- a/trinity/Tr2RenderContext.cpp +++ b/trinity/Tr2RenderContext.cpp @@ -199,7 +199,7 @@ uint32_t Tr2RenderContext::BeginParallelEncoding( uint32_t count ) context.CreateInstance(); m_parallelContexts.push_back( context ); } - + for( uint32_t i = 0; i < available; ++i ) { PrepareParallelContext( i, *m_parallelContexts[i] ); @@ -647,23 +647,23 @@ void Tr2RenderContextBase::RenderGdprBatches( ITriRenderBatchAccumulator* batche { CCP_STATS_ZONE( "Prepare" ); - uint32_t size = uint32_t( gdprBatches.size() ); - uint32_t endIndex = 0; - for( uint32_t firstIndex = 0; firstIndex < size; firstIndex = endIndex ) - { - auto& firstBatch = gdprBatches[firstIndex]; - endIndex = firstIndex + firstBatch.m_groupCount; + uint32_t size = uint32_t( gdprBatches.size() ); + uint32_t endIndex = 0; + for( uint32_t firstIndex = 0; firstIndex < size; firstIndex = endIndex ) + { + auto& firstBatch = gdprBatches[firstIndex]; + endIndex = firstIndex + firstBatch.m_groupCount; - uint32_t technique; + uint32_t technique; if( !firstBatch.m_shader->GetTechniqueIndex( techniqueName, technique ) ) - { - continue; - } + { + continue; + } const uint32_t passCount = firstBatch.m_shader->GetPassCount( technique ); - if( passCount == 0 ) - { - continue; - } + if( passCount == 0 ) + { + continue; + } for( uint32_t passIx = 0; passIx < passCount; ++passIx ) { @@ -735,7 +735,7 @@ void Tr2RenderContextBase::RenderGdprBatches( ITriRenderBatchAccumulator* batche renderContext->SetAllState(); renderContext->FlushGraphicsBarriersDx12(); #elif TRINITY_PLATFORM == TRINITY_METAL - renderContext->CheckDrawResources(); + renderContext->CheckDrawResources(); #endif } s_buffer.Submit( bin.writer ); diff --git a/trinity/Tr2RenderContext.h b/trinity/Tr2RenderContext.h index caaf8b5bb..b167de145 100644 --- a/trinity/Tr2RenderContext.h +++ b/trinity/Tr2RenderContext.h @@ -15,14 +15,14 @@ BLUE_DECLARE( Tr2RenderContext ); BLUE_DECLARE( Tr2RenderTarget ); struct Tr2RenderBatch; - // -------------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------------- // Description: -// Common part of Tr2RenderContext and Tr2PrimaryRenderContext. Contains +// Common part of Tr2RenderContext and Tr2PrimaryRenderContext. Contains // Tr2EffectStateManager instance and local variable store. // See Also: // Tr2RenderContext, Tr2PrimaryRenderContext // -------------------------------------------------------------------------------------- -struct Tr2RenderContextBase: public IRoot, public ITr2RenderContextEvents +struct Tr2RenderContextBase : public IRoot, public ITr2RenderContextEvents { Tr2RenderContextBase( Tr2RenderContext& renderContext ); @@ -53,33 +53,37 @@ struct Tr2RenderContextBase: public IRoot, public ITr2RenderContextEvents static bool TechniqueInBatch( const std::vector& batches, const BlueSharedString& techniqueName = DEFAULT_TECHNIQUE ); - Tr2ConstantBufferAL* GetConstantBuffer( int buffer ) { return &m_perObjectConstantBuffers[buffer]; } + Tr2ConstantBufferAL* GetConstantBuffer( int buffer ) + { + return &m_perObjectConstantBuffers[buffer]; + } + protected: - Tr2ConstantBufferAL m_perObjectConstantBuffers[ Tr2RenderContextEnum::CBUFFER_COUNT ]; + Tr2ConstantBufferAL m_perObjectConstantBuffers[Tr2RenderContextEnum::CBUFFER_COUNT]; private: void RenderGdprBatches( ITriRenderBatchAccumulator* batches, const BlueSharedString& techniqueName ); void RenderBatchGroup( std::vector::const_iterator startBatch, const BlueSharedString& techniqueName, Tr2ConstantBufferAL** buffers, Tr2RenderContext& renderContext ); void RenderSortedBatches( const std::vector& batches, const BlueSharedString& techniqueName, Tr2RenderContext& renderContext ); - + #if !TRINITY_PLATFORM_HAS_PRIMARY_CONTEXT Tr2RenderTargetPtr m_backBuffer; #endif - TriVariable *m_objectIdVariable; - TriVariable *m_areaIdVariable; + TriVariable* m_objectIdVariable; + TriVariable* m_areaIdVariable; }; // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed render context. Usually it is passed as a parameter. DX11 can have -// multiple secondary render contexts. In DX9 and OpenGL there is only one +// Blue-exposed render context. Usually it is passed as a parameter. DX11 can have +// multiple secondary render contexts. In DX9 and OpenGL there is only one // Tr2RenderContext which is the main render context. // See Also: // Tr2RenderContextAL // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2RenderContext ) -: public Tr2RenderContextBase, +BLUE_CLASS( Tr2RenderContext ) : + public Tr2RenderContextBase, public Tr2RenderContextAL { public: @@ -88,14 +92,15 @@ BLUE_CLASS( Tr2RenderContext ) EXPOSE_TO_BLUE(); static void DestroyMainThreadRenderContext(); - + uint32_t BeginParallelEncoding( uint32_t requestedEncodersCount ); Tr2RenderContext* Fork(); - void Join( Tr2RenderContext* context ); + void Join( Tr2RenderContext * context ); void EndParallelEncoding(); + private: void PrepareParallelContext( uint32_t index, Tr2RenderContext& context ); - + // persistent list of created parallel contexts std::vector m_parallelContexts; // pool of available parallel contexts (is reset every time Begin/End parallel rendering is called) @@ -113,23 +118,25 @@ TYPEDEF_BLUECLASS( Tr2RenderContext ); // DX11-only blue-exposed primary render context. Primary render context is used for // creating GPU resources. There is only one primary render context. The way to get it // is through USE_MAIN_THREAD_RENDER_CONTEXT() macro. -// This class contains a casting operator to Tr2RenderContext (which does a plain +// This class contains a casting operator to Tr2RenderContext (which does a plain // C-style cast). In order for it to work Tr2PrimaryRenderContext and Tr2RenderContext // should be identical except for the last base class. // See Also: // Tr2RenderContext, Tr2PrimaryRenderContextAL // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2PrimaryRenderContext ): public Tr2RenderContextBase, public Tr2PrimaryRenderContextAL +BLUE_CLASS( Tr2PrimaryRenderContext ) : + public Tr2RenderContextBase, public Tr2PrimaryRenderContextAL { public: Tr2PrimaryRenderContext(); EXPOSE_TO_BLUE(); - void OnContextCreated( Tr2PrimaryRenderContextAL& renderContext ); + void OnContextCreated( Tr2PrimaryRenderContextAL & renderContext ); operator Tr2RenderContext&(); Tr2RenderTargetPtr GetBackBuffer(); + private: Tr2RenderTargetPtr m_backBuffer; }; @@ -137,7 +144,7 @@ TYPEDEF_BLUECLASS( Tr2PrimaryRenderContext ); #else -#define Tr2PrimaryRenderContext Tr2RenderContext +#define Tr2PrimaryRenderContext Tr2RenderContext #endif @@ -154,7 +161,7 @@ Tr2PrimaryRenderContext& Tr2RenderContext_GetMainThreadRenderContext(); // function for details. // The name 'renderContext' is intentionally looking like a local, not the global that it really points at, // to make it easy to upgrade the code later on to take a Tr2RenderContext& renderContext by parameter. -#define USE_MAIN_THREAD_RENDER_CONTEXT() Tr2PrimaryRenderContext& renderContext = Tr2RenderContext_GetMainThreadRenderContext(); +#define USE_MAIN_THREAD_RENDER_CONTEXT() Tr2PrimaryRenderContext& renderContext = Tr2RenderContext_GetMainThreadRenderContext(); extern const Be::VarChooser Tr2RenderContextEnum_ConstantType_Chooser[]; extern const Be::VarChooser Tr2RenderContextEnum_ClearFlags_Chooser[]; diff --git a/trinity/Tr2RenderContext_Blue.cpp b/trinity/Tr2RenderContext_Blue.cpp index da4e2f2ef..9cd8dcf13 100644 --- a/trinity/Tr2RenderContext_Blue.cpp +++ b/trinity/Tr2RenderContext_Blue.cpp @@ -6,308 +6,285 @@ #include "Tr2RenderTarget.h" #include "TriSettingsRegistrar.h" -#pragma warning(push, 4) +#pragma warning( push, 4 ) using namespace Tr2RenderContextEnum; using namespace Tr2UpscalingAL; -const Be::VarChooser Tr2RenderContextEnum_ObjectType_Chooser[] = -{ -#define OP_ITEM(x) { #x, BeCast( OT_ ## x ), #x " AL object type" }, +const Be::VarChooser Tr2RenderContextEnum_ObjectType_Chooser[] = { +#define OP_ITEM( x ) { #x, BeCast( OT_##x ), #x " AL object type" }, OP_ITEM( CONSTANT_BUFFER ) - OP_ITEM( RENDER_CONTEXT ) - OP_ITEM( SHADER ) - OP_ITEM( SAMPLER_STATE ) - OP_ITEM( TEXTURE ) - OP_ITEM( VERTEX_LAYOUT ) - OP_ITEM( OCCLUSION_QUERY ) - OP_ITEM( SWAP_CHAIN ) - OP_ITEM( FENCE ) - OP_ITEM( TIMER ) - OP_ITEM( RESOURCE_SET ) - OP_ITEM( BUFFER ) + OP_ITEM( RENDER_CONTEXT ) + OP_ITEM( SHADER ) + OP_ITEM( SAMPLER_STATE ) + OP_ITEM( TEXTURE ) + OP_ITEM( VERTEX_LAYOUT ) + OP_ITEM( OCCLUSION_QUERY ) + OP_ITEM( SWAP_CHAIN ) + OP_ITEM( FENCE ) + OP_ITEM( TIMER ) + OP_ITEM( RESOURCE_SET ) + OP_ITEM( BUFFER ) #undef OP_ITEM - {0} + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "AL_OBJECT_TYPE", - ObjectType, - Tr2RenderContextEnum_ObjectType_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "AL_OBJECT_TYPE", + ObjectType, + Tr2RenderContextEnum_ObjectType_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::VarChooser Tr2RenderContextEnum_ConstantType_Chooser[] = -{ +const Be::VarChooser Tr2RenderContextEnum_ConstantType_Chooser[] = { // Name Value Docstring - { "VERTEX_SHADER", BeCast( VERTEX_SHADER ), "Bind the constants to the vertex shader" }, - { "PIXEL_SHADER" , BeCast( PIXEL_SHADER ), "Bind the constants to the pixel shader" }, - {0} + { "VERTEX_SHADER", BeCast( VERTEX_SHADER ), "Bind the constants to the vertex shader" }, + { "PIXEL_SHADER", BeCast( PIXEL_SHADER ), "Bind the constants to the pixel shader" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "CONSTANT_TYPE", - ShaderType, - Tr2RenderContextEnum_ConstantType_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "CONSTANT_TYPE", + ShaderType, + Tr2RenderContextEnum_ConstantType_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::VarChooser Tr2RenderContextEnum_ClearFlags_Chooser[] = -{ +const Be::VarChooser Tr2RenderContextEnum_ClearFlags_Chooser[] = { // Name Value Docstring - { "TARGET" , BeCast( CLEARFLAGS_TARGET ), "Clear rendertarget" }, - { "ZBUFFER" , BeCast( CLEARFLAGS_ZBUFFER ), "Clear depth" }, - { "STENCIL" , BeCast( CLEARFLAGS_STENCIL ), "Clear stencil" }, - {0} + { "TARGET", BeCast( CLEARFLAGS_TARGET ), "Clear rendertarget" }, + { "ZBUFFER", BeCast( CLEARFLAGS_ZBUFFER ), "Clear depth" }, + { "STENCIL", BeCast( CLEARFLAGS_STENCIL ), "Clear stencil" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "CLEAR_FLAGS", - ClearFlags, - Tr2RenderContextEnum_ClearFlags_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "CLEAR_FLAGS", + ClearFlags, + Tr2RenderContextEnum_ClearFlags_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::VarChooser Tr2RenderContextEnum_DepthStencilFormat_Chooser[] = -{ -#define DS_ITEM(x) { #x, BeCast( DSFMT_ ## x ), #x " depthStencil format" }, +const Be::VarChooser Tr2RenderContextEnum_DepthStencilFormat_Chooser[] = { +#define DS_ITEM( x ) { #x, BeCast( DSFMT_##x ), #x " depthStencil format" }, - DS_ITEM(D24S8) - DS_ITEM(D24X8) - DS_ITEM(D24FS8) - DS_ITEM(D32F) - DS_ITEM(D32) - DS_ITEM(READABLE) + DS_ITEM( D24S8 ) + DS_ITEM( D24X8 ) + DS_ITEM( D24FS8 ) + DS_ITEM( D32F ) + DS_ITEM( D32 ) + DS_ITEM( READABLE ) - DS_ITEM(AUTO) + DS_ITEM( AUTO ) - DS_ITEM(D16_LOCKABLE) - DS_ITEM(D15S1) - DS_ITEM(D24X4S4) - DS_ITEM(D16) - DS_ITEM(D32F_LOCKABLE) - DS_ITEM(D24FS8) + DS_ITEM( D16_LOCKABLE ) + DS_ITEM( D15S1 ) + DS_ITEM( D24X4S4 ) + DS_ITEM( D16 ) + DS_ITEM( D32F_LOCKABLE ) + DS_ITEM( D24FS8 ) - {0} + { 0 } #undef DS_ITEM }; -BLUE_REGISTER_ENUM_EX( - "DEPTH_STENCIL_FORMAT", - DepthStencilFormat, - Tr2RenderContextEnum_DepthStencilFormat_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); - -const Be::VarChooser Tr2RenderContextEnum_TextureType_Chooser[] = -{ - { "TEX_TYPE_1D", BeCast( TEX_TYPE_1D ), "1D texture" }, - { "TEX_TYPE_2D", BeCast( TEX_TYPE_2D ), "2D texture" }, - { "TEX_TYPE_3D", BeCast( TEX_TYPE_3D ), "3D texture" }, - { "TEX_TYPE_CUBE", BeCast( TEX_TYPE_CUBE ), "Cube texture" }, - { "TEX_TYPE_INVALID", BeCast( TEX_TYPE_INVALID ), "Invalid texture" }, - {0} +BLUE_REGISTER_ENUM_EX( + "DEPTH_STENCIL_FORMAT", + DepthStencilFormat, + Tr2RenderContextEnum_DepthStencilFormat_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); + +const Be::VarChooser Tr2RenderContextEnum_TextureType_Chooser[] = { + { "TEX_TYPE_1D", BeCast( TEX_TYPE_1D ), "1D texture" }, + { "TEX_TYPE_2D", BeCast( TEX_TYPE_2D ), "2D texture" }, + { "TEX_TYPE_3D", BeCast( TEX_TYPE_3D ), "3D texture" }, + { "TEX_TYPE_CUBE", BeCast( TEX_TYPE_CUBE ), "Cube texture" }, + { "TEX_TYPE_INVALID", BeCast( TEX_TYPE_INVALID ), "Invalid texture" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "TEXTURE_TYPE", - TextureType, - Tr2RenderContextEnum_TextureType_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); - -const Be::VarChooser Tr2RenderContextEnum_BufferUsageFlags_Chooser[] = -{ - { "CPU_READ", BeCast( USAGE_CPU_READ ), "USAGE_CPU_READ" }, - { "CPU_WRITE", BeCast( USAGE_CPU_WRITE ), "USAGE_CPU_WRITE" }, - { "LOCK_FREQUENTLY", BeCast( USAGE_LOCK_FREQUENTLY ), "USAGE_LOCK_FREQUENTLY" }, - { "IMMUTABLE", BeCast( USAGE_IMMUTABLE ), "USAGE_IMMUTABLE" }, - { "HINT_MANAGED", BeCast( TEX_TYPE_INVALID ), "USAGE_HINT_MANAGED" }, - {0} +BLUE_REGISTER_ENUM_EX( + "TEXTURE_TYPE", + TextureType, + Tr2RenderContextEnum_TextureType_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); + +const Be::VarChooser Tr2RenderContextEnum_BufferUsageFlags_Chooser[] = { + { "CPU_READ", BeCast( USAGE_CPU_READ ), "USAGE_CPU_READ" }, + { "CPU_WRITE", BeCast( USAGE_CPU_WRITE ), "USAGE_CPU_WRITE" }, + { "LOCK_FREQUENTLY", BeCast( USAGE_LOCK_FREQUENTLY ), "USAGE_LOCK_FREQUENTLY" }, + { "IMMUTABLE", BeCast( USAGE_IMMUTABLE ), "USAGE_IMMUTABLE" }, + { "HINT_MANAGED", BeCast( TEX_TYPE_INVALID ), "USAGE_HINT_MANAGED" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "BUFFER_USAGE_FLAGS", - BufferUsageFlags, - Tr2RenderContextEnum_BufferUsageFlags_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "BUFFER_USAGE_FLAGS", + BufferUsageFlags, + Tr2RenderContextEnum_BufferUsageFlags_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::VarChooser Tr2RenderContextEnum_ExFlag_Chooser[] = -{ - { "CREATE_SHARED", BeCast( EX_CREATE_SHARED ), "" }, - { "BIND_UNORDERED_ACCESS", BeCast( EX_BIND_UNORDERED_ACCESS ), "" }, - { "DRAW_INDIRECT", BeCast( EX_DRAW_INDIRECT ), "" }, - {0} +const Be::VarChooser Tr2RenderContextEnum_ExFlag_Chooser[] = { + { "CREATE_SHARED", BeCast( EX_CREATE_SHARED ), "" }, + { "BIND_UNORDERED_ACCESS", BeCast( EX_BIND_UNORDERED_ACCESS ), "" }, + { "DRAW_INDIRECT", BeCast( EX_DRAW_INDIRECT ), "" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "EX_FLAG", - ExFlag, - Tr2RenderContextEnum_ExFlag_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); - - -#define VAL(x) { #x, BeCast( PIXEL_FORMAT_ ## x ), #x }, - -const Be::VarChooser Tr2RenderContextEnum_PixelFormat_Chooser[] = -{ - VAL(UNKNOWN) - VAL(R32G32B32A32_TYPELESS) - VAL(R32G32B32A32_FLOAT) - VAL(R32G32B32A32_UINT) - VAL(R32G32B32A32_SINT) - VAL(R32G32B32_TYPELESS) - VAL(R32G32B32_FLOAT) - VAL(R32G32B32_UINT) - VAL(R32G32B32_SINT) - VAL(R16G16B16A16_TYPELESS) - VAL(R16G16B16A16_FLOAT) - VAL(R16G16B16A16_UNORM) - VAL(R16G16B16A16_UINT) - VAL(R16G16B16A16_SNORM) - VAL(R16G16B16A16_SINT) - VAL(R32G32_TYPELESS) - VAL(R32G32_FLOAT) - VAL(R32G32_UINT) - VAL(R32G32_SINT) - VAL(R32G8X24_TYPELESS) - VAL(D32_FLOAT_S8X24_UINT) - VAL(R32_FLOAT_X8X24_TYPELESS) - VAL(X32_TYPELESS_G8X24_UINT) - VAL(R10G10B10A2_TYPELESS) - VAL(R10G10B10A2_UNORM) - VAL(R10G10B10A2_UINT) - VAL(R11G11B10_FLOAT) - VAL(R8G8B8A8_TYPELESS) - VAL(R8G8B8A8_UNORM) - VAL(R8G8B8A8_UNORM_SRGB) - VAL(R8G8B8A8_UINT) - VAL(R8G8B8A8_SNORM) - VAL(R8G8B8A8_SINT) - VAL(R16G16_TYPELESS) - VAL(R16G16_FLOAT) - VAL(R16G16_UNORM) - VAL(R16G16_UINT) - VAL(R16G16_SNORM) - VAL(R16G16_SINT) - VAL(R32_TYPELESS) - VAL(D32_FLOAT) - VAL(R32_FLOAT) - VAL(R32_UINT) - VAL(R32_SINT) - VAL(R24G8_TYPELESS) - VAL(D24_UNORM_S8_UINT) - VAL(R24_UNORM_X8_TYPELESS) - VAL(X24_TYPELESS_G8_UINT) - VAL(R8G8_TYPELESS) - VAL(R8G8_UNORM) - VAL(R8G8_UINT) - VAL(R8G8_SNORM) - VAL(R8G8_SINT) - VAL(R16_TYPELESS) - VAL(R16_FLOAT) - VAL(D16_UNORM) - VAL(R16_UNORM) - VAL(R16_UINT) - VAL(R16_SNORM) - VAL(R16_SINT) - VAL(R8_TYPELESS) - VAL(R8_UNORM) - VAL(R8_UINT) - VAL(R8_SNORM) - VAL(R8_SINT) - VAL(A8_UNORM) - VAL(R1_UNORM) - VAL(R9G9B9E5_SHAREDEXP) - VAL(R8G8_B8G8_UNORM) - VAL(G8R8_G8B8_UNORM) - VAL(BC1_TYPELESS) - VAL(BC1_UNORM) - VAL(BC1_UNORM_SRGB) - VAL(BC2_TYPELESS) - VAL(BC2_UNORM) - VAL(BC2_UNORM_SRGB) - VAL(BC3_TYPELESS) - VAL(BC3_UNORM) - VAL(BC3_UNORM_SRGB) - VAL(BC4_TYPELESS) - VAL(BC4_UNORM) - VAL(BC4_SNORM) - VAL(BC5_TYPELESS) - VAL(BC5_UNORM) - VAL(BC5_SNORM) - VAL(B5G6R5_UNORM) - VAL(B5G5R5A1_UNORM) - VAL(B8G8R8A8_UNORM) - VAL(B8G8R8X8_UNORM) - VAL(R10G10B10_XR_BIAS_A2_UNORM) - VAL(B8G8R8A8_TYPELESS) - VAL(B8G8R8A8_UNORM_SRGB) - VAL(B8G8R8X8_TYPELESS) - VAL(B8G8R8X8_UNORM_SRGB) - VAL(BC6H_TYPELESS) - VAL(BC6H_UF16) - VAL(BC6H_SF16) - VAL(BC7_TYPELESS) - VAL(BC7_UNORM) - VAL(BC7_UNORM_SRGB) - {0} +BLUE_REGISTER_ENUM_EX( + "EX_FLAG", + ExFlag, + Tr2RenderContextEnum_ExFlag_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); + + +#define VAL( x ) { #x, BeCast( PIXEL_FORMAT_##x ), #x }, + +const Be::VarChooser Tr2RenderContextEnum_PixelFormat_Chooser[] = { + VAL( UNKNOWN ) + VAL( R32G32B32A32_TYPELESS ) + VAL( R32G32B32A32_FLOAT ) + VAL( R32G32B32A32_UINT ) + VAL( R32G32B32A32_SINT ) + VAL( R32G32B32_TYPELESS ) + VAL( R32G32B32_FLOAT ) + VAL( R32G32B32_UINT ) + VAL( R32G32B32_SINT ) + VAL( R16G16B16A16_TYPELESS ) + VAL( R16G16B16A16_FLOAT ) + VAL( R16G16B16A16_UNORM ) + VAL( R16G16B16A16_UINT ) + VAL( R16G16B16A16_SNORM ) + VAL( R16G16B16A16_SINT ) + VAL( R32G32_TYPELESS ) + VAL( R32G32_FLOAT ) + VAL( R32G32_UINT ) + VAL( R32G32_SINT ) + VAL( R32G8X24_TYPELESS ) + VAL( D32_FLOAT_S8X24_UINT ) + VAL( R32_FLOAT_X8X24_TYPELESS ) + VAL( X32_TYPELESS_G8X24_UINT ) + VAL( R10G10B10A2_TYPELESS ) + VAL( R10G10B10A2_UNORM ) + VAL( R10G10B10A2_UINT ) + VAL( R11G11B10_FLOAT ) + VAL( R8G8B8A8_TYPELESS ) + VAL( R8G8B8A8_UNORM ) + VAL( R8G8B8A8_UNORM_SRGB ) + VAL( R8G8B8A8_UINT ) + VAL( R8G8B8A8_SNORM ) + VAL( R8G8B8A8_SINT ) + VAL( R16G16_TYPELESS ) + VAL( R16G16_FLOAT ) + VAL( R16G16_UNORM ) + VAL( R16G16_UINT ) + VAL( R16G16_SNORM ) + VAL( R16G16_SINT ) + VAL( R32_TYPELESS ) + VAL( D32_FLOAT ) + VAL( R32_FLOAT ) + VAL( R32_UINT ) + VAL( R32_SINT ) + VAL( R24G8_TYPELESS ) + VAL( D24_UNORM_S8_UINT ) + VAL( R24_UNORM_X8_TYPELESS ) + VAL( X24_TYPELESS_G8_UINT ) + VAL( R8G8_TYPELESS ) + VAL( R8G8_UNORM ) + VAL( R8G8_UINT ) + VAL( R8G8_SNORM ) + VAL( R8G8_SINT ) + VAL( R16_TYPELESS ) + VAL( R16_FLOAT ) + VAL( D16_UNORM ) + VAL( R16_UNORM ) + VAL( R16_UINT ) + VAL( R16_SNORM ) + VAL( R16_SINT ) + VAL( R8_TYPELESS ) + VAL( R8_UNORM ) + VAL( R8_UINT ) + VAL( R8_SNORM ) + VAL( R8_SINT ) + VAL( A8_UNORM ) + VAL( R1_UNORM ) + VAL( R9G9B9E5_SHAREDEXP ) + VAL( R8G8_B8G8_UNORM ) + VAL( G8R8_G8B8_UNORM ) + VAL( BC1_TYPELESS ) + VAL( BC1_UNORM ) + VAL( BC1_UNORM_SRGB ) + VAL( BC2_TYPELESS ) + VAL( BC2_UNORM ) + VAL( BC2_UNORM_SRGB ) + VAL( BC3_TYPELESS ) + VAL( BC3_UNORM ) + VAL( BC3_UNORM_SRGB ) + VAL( BC4_TYPELESS ) + VAL( BC4_UNORM ) + VAL( BC4_SNORM ) + VAL( BC5_TYPELESS ) + VAL( BC5_UNORM ) + VAL( BC5_SNORM ) + VAL( B5G6R5_UNORM ) + VAL( B5G5R5A1_UNORM ) + VAL( B8G8R8A8_UNORM ) + VAL( B8G8R8X8_UNORM ) + VAL( R10G10B10_XR_BIAS_A2_UNORM ) + VAL( B8G8R8A8_TYPELESS ) + VAL( B8G8R8A8_UNORM_SRGB ) + VAL( B8G8R8X8_TYPELESS ) + VAL( B8G8R8X8_UNORM_SRGB ) + VAL( BC6H_TYPELESS ) + VAL( BC6H_UF16 ) + VAL( BC6H_SF16 ) + VAL( BC7_TYPELESS ) + VAL( BC7_UNORM ) + VAL( BC7_UNORM_SRGB ){ 0 } }; -BLUE_REGISTER_ENUM_EX( - "PIXEL_FORMAT", - PixelFormat, - Tr2RenderContextEnum_PixelFormat_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); - -const Be::VarChooser Tr2RenderContextEnum_ScanlineOrdering_Chooser[] = -{ - { "UNSPECIFIED", BeCast( SCANLINE_ORDER_UNSPECIFIED ), "" }, - { "PROGRESSIVE", BeCast( SCANLINE_ORDER_PROGRESSIVE ), "" }, - { "UPPER_FIELD_FIRST", BeCast( SCANLINE_ORDER_UPPER_FIELD_FIRST ), "" }, - { "LOWER_FIELD_FIRST", BeCast( SCANLINE_ORDER_LOWER_FIELD_FIRST ), "" }, - {0} +BLUE_REGISTER_ENUM_EX( + "PIXEL_FORMAT", + PixelFormat, + Tr2RenderContextEnum_PixelFormat_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); + +const Be::VarChooser Tr2RenderContextEnum_ScanlineOrdering_Chooser[] = { + { "UNSPECIFIED", BeCast( SCANLINE_ORDER_UNSPECIFIED ), "" }, + { "PROGRESSIVE", BeCast( SCANLINE_ORDER_PROGRESSIVE ), "" }, + { "UPPER_FIELD_FIRST", BeCast( SCANLINE_ORDER_UPPER_FIELD_FIRST ), "" }, + { "LOWER_FIELD_FIRST", BeCast( SCANLINE_ORDER_LOWER_FIELD_FIRST ), "" }, + { 0 } }; -const Be::VarChooser Tr2RenderContextEnum_DisplayScaling_Chooser[] = -{ - { "UNSPECIFIED", BeCast( DISPLAY_SCALING_UNSPECIFIED ), "" }, - { "CENTERED", BeCast( DISPLAY_SCALING_CENTERED ), "" }, - { "STRETCHED", BeCast( DISPLAY_SCALING_STRETCHED ), "" }, - {0} +const Be::VarChooser Tr2RenderContextEnum_DisplayScaling_Chooser[] = { + { "UNSPECIFIED", BeCast( DISPLAY_SCALING_UNSPECIFIED ), "" }, + { "CENTERED", BeCast( DISPLAY_SCALING_CENTERED ), "" }, + { "STRETCHED", BeCast( DISPLAY_SCALING_STRETCHED ), "" }, + { 0 } }; -const Be::VarChooser Tr2RenderContextEnum_SwapEffect_Chooser[] = -{ - { "DISCARD", BeCast( SWAP_EFFECT_DISCARD ), "" }, - { "SEQUENTIAL", BeCast( SWAP_EFFECT_SEQUENTIAL ), "" }, - {0} +const Be::VarChooser Tr2RenderContextEnum_SwapEffect_Chooser[] = { + { "DISCARD", BeCast( SWAP_EFFECT_DISCARD ), "" }, + { "SEQUENTIAL", BeCast( SWAP_EFFECT_SEQUENTIAL ), "" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "SWAP_EFFECT", - SwapEffect, - Tr2RenderContextEnum_SwapEffect_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "SWAP_EFFECT", + SwapEffect, + Tr2RenderContextEnum_SwapEffect_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); -const Be::VarChooser Tr2RenderContextEnum_PresentInterval_Chooser[] = -{ - { "IMMEDIATE", BeCast( PRESENT_INTERVAL_IMMEDIATE ), "" }, - { "ONE", BeCast( PRESENT_INTERVAL_ONE ), "" }, - {0} +const Be::VarChooser Tr2RenderContextEnum_PresentInterval_Chooser[] = { + { "IMMEDIATE", BeCast( PRESENT_INTERVAL_IMMEDIATE ), "" }, + { "ONE", BeCast( PRESENT_INTERVAL_ONE ), "" }, + { 0 } }; -BLUE_REGISTER_ENUM_EX( - "PRESENT_INTERVAL", - PresentInterval, - Tr2RenderContextEnum_PresentInterval_Chooser, - ENUM_REG_ENUM_OBJECT_ON_MODULE -); +BLUE_REGISTER_ENUM_EX( + "PRESENT_INTERVAL", + PresentInterval, + Tr2RenderContextEnum_PresentInterval_Chooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); BLUE_DEFINE( Tr2RenderContext ); @@ -330,10 +307,10 @@ const Be::ClassInfo* Tr2RenderContext::ExposeToBlue() { ///////////////////////////////////////// // Blue class info - EXPOSURE_BEGIN( Tr2RenderContext, "" ) + EXPOSURE_BEGIN( Tr2RenderContext, "" ) MAP_INTERFACE( IRoot ) - MAP_INTERFACE( Tr2RenderContext ) + MAP_INTERFACE( Tr2RenderContext ) #if TRINITY_PLATFORM_HAS_PRIMARY_CONTEXT EXPOSURE_END() @@ -343,26 +320,22 @@ const Be::ClassInfo* Tr2PrimaryRenderContext::ExposeToBlue() { ///////////////////////////////////////// // Blue class info - EXPOSURE_BEGIN( Tr2PrimaryRenderContext, "" ) + EXPOSURE_BEGIN( Tr2PrimaryRenderContext, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( Tr2PrimaryRenderContext ) //MAP_INTERFACE( Tr2RenderContext ) #endif - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetDefaultBackBuffer", GetBackBuffer, - "Returns a Tr2RenderTarget representing the default back buffer" - ) + "Returns a Tr2RenderTarget representing the default back buffer" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetBackBufferFormat", GetBackBufferFormat, - "Returns the PixelFormat of the default back buffer" - ) + "Returns the PixelFormat of the default back buffer" ) EXPOSURE_END() } @@ -372,69 +345,67 @@ const Be::ClassInfo* Tr2PrimaryRenderContext::ExposeToBlue() namespace { - PyObject* result; +PyObject* result; - void GetDesc( Tr2ALMemoryType, const Tr2DeviceResourceDescriptionAL& description ) +void GetDesc( Tr2ALMemoryType, const Tr2DeviceResourceDescriptionAL& description ) +{ + std::string key = ""; + auto found = description.find( "type" ); + if( found != end( description ) ) { - std::string key = ""; - auto found = description.find( "type" ); - if( found != end( description ) ) - { - key = found->second; - } - PyObject* list = PyDict_GetItemString( result, key.c_str() ); - if( !list ) - { - list = PyList_New( 0 ); - PyDict_SetItemString( result, key.c_str(), list ); - Py_DECREF( list ); - } + key = found->second; + } + PyObject* list = PyDict_GetItemString( result, key.c_str() ); + if( !list ) + { + list = PyList_New( 0 ); + PyDict_SetItemString( result, key.c_str(), list ); + Py_DECREF( list ); + } - PyObject* item = PyDict_New(); - if( item ) + PyObject* item = PyDict_New(); + if( item ) + { + for( auto it = description.begin(); it != description.end(); ++it ) { - for( auto it = description.begin(); it != description.end(); ++it ) - { - PyObject* value = ToPython( it->second.c_str() ); - PyDict_SetItemString( item, it->first.c_str(), value ); - Py_DECREF( value ); - } - PyList_Append( list, item ); - Py_DECREF( item ); + PyObject* value = ToPython( it->second.c_str() ); + PyDict_SetItemString( item, it->first.c_str(), value ); + Py_DECREF( value ); } - }; - - // -------------------------------------------------------------------------------------- - // Description: - // Returns all live AL resources as Python structure. - // Arguments: - // self - Python self reference (unused) - // args - Python call arguments (unused) - // Return value: - // Python dictionary describing live AL objects - // -------------------------------------------------------------------------------------- - PyObject* PyGetLiveResources( PyObject* /*self*/, PyObject* /*args*/ ) - { - result = PyDict_New(); - DescribeDeviceResources( GetDesc ); - return result; + PyList_Append( list, item ); + Py_DECREF( item ); } +}; + +// -------------------------------------------------------------------------------------- +// Description: +// Returns all live AL resources as Python structure. +// Arguments: +// self - Python self reference (unused) +// args - Python call arguments (unused) +// Return value: +// Python dictionary describing live AL objects +// -------------------------------------------------------------------------------------- +PyObject* PyGetLiveResources( PyObject* /*self*/, PyObject* /*args*/ ) +{ + result = PyDict_New(); + DescribeDeviceResources( GetDesc ); + return result; +} } -MAP_FUNCTION( - "GetLiveALResources", - PyGetLiveResources, +MAP_FUNCTION( + "GetLiveALResources", + PyGetLiveResources, "Returns a per-AL-type dictionary of lists of live AL objects. The function\n" "is expensive and is not supposed to be used every frame.\n" - ":rtype: dict[str, list[dict[str, str]]]" - ); + ":rtype: dict[str, list[dict[str, str]]]" ); #endif -MAP_FUNCTION_AND_WRAP( - "GetPixelFormatSize", - GetBytesPerPixel, +MAP_FUNCTION_AND_WRAP( + "GetPixelFormatSize", + GetBytesPerPixel, "Returns size of pixel (or block for compressed formats) in bytes of a given\n" "pixel format.\n" - ":param pixelFormat: pixel format (member of trinity.PIXEL_FORMAT)" - ); + ":param pixelFormat: pixel format (member of trinity.PIXEL_FORMAT)" ); diff --git a/trinity/Tr2RenderNodeEffect_Blue.cpp b/trinity/Tr2RenderNodeEffect_Blue.cpp index ececc08d4..512deee30 100644 --- a/trinity/Tr2RenderNodeEffect_Blue.cpp +++ b/trinity/Tr2RenderNodeEffect_Blue.cpp @@ -55,10 +55,10 @@ const Be::ClassInfo* Tr2RenderNodeEffect::ExposeToBlue() ":param source: The input node to add.\n" ":param outputName: Optional name of the output for the node (DepthMap, etc.). Pass an empty string for the default output." ) - MAP_ATTRIBUTE( - "inputNodes", - m_inputNodes, - "Input nodes added as sources to this effect. Do not modify this attribute directly; use AddSource() instead.", + MAP_ATTRIBUTE( + "inputNodes", + m_inputNodes, + "Input nodes added as sources to this effect. Do not modify this attribute directly; use AddSource() instead.", Be::READ | Be::PERSIST ) EXPOSURE_END() } diff --git a/trinity/Tr2RenderTarget.cpp b/trinity/Tr2RenderTarget.cpp index 6c0c6f64a..d1d6e9942 100644 --- a/trinity/Tr2RenderTarget.cpp +++ b/trinity/Tr2RenderTarget.cpp @@ -8,33 +8,33 @@ using namespace Tr2RenderContextEnum; namespace { - void GetUsage( uint32_t msaaType, Tr2RenderContextEnum::ExFlag flags, Tr2GpuUsage::Type& gpuUsage, Tr2CpuUsage::Type& cpuUsage ) +void GetUsage( uint32_t msaaType, Tr2RenderContextEnum::ExFlag flags, Tr2GpuUsage::Type& gpuUsage, Tr2CpuUsage::Type& cpuUsage ) +{ + gpuUsage = Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE; + cpuUsage = Tr2CpuUsage::READ; + if( msaaType > 1 ) + { + cpuUsage = Tr2CpuUsage::NONE; + } + else if( ( flags & Tr2RenderContextEnum::EX_BIND_UNORDERED_ACCESS ) != 0 ) { - gpuUsage = Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE; - cpuUsage = Tr2CpuUsage::READ; - if( msaaType > 1 ) - { - cpuUsage = Tr2CpuUsage::NONE; - } - else if( ( flags & Tr2RenderContextEnum::EX_BIND_UNORDERED_ACCESS ) != 0 ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; - } - if( ( flags & Tr2RenderContextEnum::EX_CREATE_SHARED ) != 0 ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::SHARED; - } + gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; } + if( ( flags & Tr2RenderContextEnum::EX_CREATE_SHARED ) != 0 ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::SHARED; + } +} } -Tr2RenderTarget::Tr2RenderTarget( IRoot* ) - :m_width( 0 ), +Tr2RenderTarget::Tr2RenderTarget( IRoot* ) : + m_width( 0 ), m_height( 0 ), m_mipCount( 0 ), m_format( PIXEL_FORMAT_UNKNOWN ), m_flags( EX_NONE ), m_type( TEX_TYPE_INVALID ) -{ +{ } Tr2RenderTarget::~Tr2RenderTarget() @@ -54,29 +54,29 @@ std::string Tr2RenderTarget::GetName() const // -------------------------------------------------------------------------------------- // Description: -// Blue-exposed initializer. +// Blue-exposed initializer. // -------------------------------------------------------------------------------------- -void Tr2RenderTarget::py__init__( - unsigned width, - unsigned height, - unsigned mipCount, +void Tr2RenderTarget::py__init__( + unsigned width, + unsigned height, + unsigned mipCount, Tr2RenderContextEnum::PixelFormat format, - unsigned msaaType, + unsigned msaaType, unsigned msaaQuality, Tr2RenderContextEnum::ExFlag flags, Tr2RenderContextEnum::TextureType type ) { if( width && height && format ) { - CCP_ASSERT( msaaType <= 1 || mipCount <= 1 ); // can't have msaa and mips at the same time. + CCP_ASSERT( msaaType <= 1 || mipCount <= 1 ); // can't have msaa and mips at the same time. Create( width, height, mipCount, format, msaaType, msaaQuality, flags, type ); - } + } } -int32_t Tr2RenderTarget::Create( - unsigned width, - unsigned height, - unsigned mipLevelCount, +int32_t Tr2RenderTarget::Create( + unsigned width, + unsigned height, + unsigned mipLevelCount, Tr2RenderContextEnum::PixelFormat format, unsigned msaaType, unsigned msaaQuality, @@ -99,12 +99,13 @@ int32_t Tr2RenderTarget::Create( } auto hr = m_renderTarget.Create( - Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount ), - Tr2MsaaDesc( msaaType, msaaQuality ), - gpuUsage, - cpuUsage, - nullptr, - renderContext ).GetResult(); + Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount ), + Tr2MsaaDesc( msaaType, msaaQuality ), + gpuUsage, + cpuUsage, + nullptr, + renderContext ) + .GetResult(); if( SUCCEEDED( hr ) ) { m_width = width; @@ -157,7 +158,7 @@ int32_t Tr2RenderTarget::CreateArray( auto hr = m_renderTarget.Create( Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount, arraySize ), - Tr2MsaaDesc( ), + Tr2MsaaDesc(), gpuUsage, cpuUsage, nullptr, @@ -170,7 +171,7 @@ int32_t Tr2RenderTarget::CreateArray( m_arraySize = arraySize; m_mipCount = mipLevelCount; m_format = format; - m_msaa = Tr2MsaaDesc( ); + m_msaa = Tr2MsaaDesc(); m_flags = ExFlag( flags ); m_type = type; m_cpuUsage = cpuUsage; @@ -185,9 +186,9 @@ int32_t Tr2RenderTarget::CreateArray( } int32_t Tr2RenderTarget::CreateManual( - unsigned width, - unsigned height, - unsigned mipLevelCount, + unsigned width, + unsigned height, + unsigned mipLevelCount, Tr2RenderContextEnum::PixelFormat format, unsigned msaaType, unsigned msaaQuality, @@ -204,12 +205,13 @@ int32_t Tr2RenderTarget::CreateManual( } auto hr = m_renderTarget.Create( - Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount ), - Tr2MsaaDesc( msaaType, msaaQuality ), - gpuUsage, - cpuUsage, - nullptr, - renderContext ).GetResult(); + Tr2BitmapDimensions( type, format, width, height, 1, mipLevelCount ), + Tr2MsaaDesc( msaaType, msaaQuality ), + gpuUsage, + cpuUsage, + nullptr, + renderContext ) + .GetResult(); if( SUCCEEDED( hr ) ) { m_width = width; @@ -237,7 +239,7 @@ Tr2TextureAL* Tr2RenderTarget::GetTexture() auto& rt = GetRenderTarget(); if( rt.IsValid() && Tr2GpuUsage::HasFlag( rt.GetGpuUsage(), Tr2GpuUsage::SHADER_RESOURCE ) ) { - return &rt; + return &rt; } return nullptr; } @@ -250,8 +252,8 @@ Tr2RenderTarget::OnTextureChangeEvent& Tr2RenderTarget::OnTextureChange() // -------------------------------------------------------------------------------------- // Description: // Attaches this object to existing AL render target. Attached Tr2RenderTarget doesn't -// own the AL object, but only references it. Used for attaching to special render -// targets (swap chain back buffers). +// own the AL object, but only references it. Used for attaching to special render +// targets (swap chain back buffers). // Arguments: // renderTarget - AL render target // owner - Render target owner object: Tr2RenderTarget locks it so that AL renderTarget @@ -284,7 +286,7 @@ void Tr2RenderTarget::Detach() // -------------------------------------------------------------------------------------- // Description: -// Checks if the referenced AL render target is attached (with Attach method) or owned. +// Checks if the referenced AL render target is attached (with Attach method) or owned. // Return Value: // true if referenced AL render target is attached // false if referenced AL render target is owned by this object @@ -296,9 +298,9 @@ bool Tr2RenderTarget::IsAttached() const // -------------------------------------------------------------------------------------- // Description: -// Returns referenced render target (either owned or attached). +// Returns referenced render target (either owned or attached). // Return Value: -// Referenced render target +// Referenced render target // -------------------------------------------------------------------------------------- Tr2TextureAL& Tr2RenderTarget::GetRenderTarget() { @@ -311,9 +313,9 @@ Tr2TextureAL& Tr2RenderTarget::GetRenderTarget() // -------------------------------------------------------------------------------------- // Description: -// Returns referenced render target (either owned or attached). +// Returns referenced render target (either owned or attached). // Return Value: -// Referenced render target +// Referenced render target // -------------------------------------------------------------------------------------- const Tr2TextureAL& Tr2RenderTarget::GetRenderTarget() const { diff --git a/trinity/Tr2RenderTarget.h b/trinity/Tr2RenderTarget.h index 902ff833e..1a9280fbf 100644 --- a/trinity/Tr2RenderTarget.h +++ b/trinity/Tr2RenderTarget.h @@ -15,32 +15,32 @@ BLUE_DECLARE( Tr2RenderTarget ); // a renderTarget. // This class replaces TriSurface and TriTextureRes. // ------------------------------------------------------------- -BLUE_CLASS( Tr2RenderTarget ) : +BLUE_CLASS( Tr2RenderTarget ) : public ITr2TextureProvider, public Tr2DeviceResource { public: EXPOSE_TO_BLUE(); - Tr2RenderTarget( IRoot* = 0 ); + Tr2RenderTarget( IRoot* = 0 ); ~Tr2RenderTarget(); - void py__init__( - unsigned width, - unsigned height, - unsigned mipCount, + void py__init__( + unsigned width, + unsigned height, + unsigned mipCount, Tr2RenderContextEnum::PixelFormat format, - unsigned msaaType, + unsigned msaaType, unsigned msaaQuality, Tr2RenderContextEnum::ExFlag flags, Tr2RenderContextEnum::TextureType type ); - int32_t Create( - unsigned width, - unsigned height, + int32_t Create( + unsigned width, + unsigned height, unsigned mipLevelCount, Tr2RenderContextEnum::PixelFormat format, - unsigned msaaType = 1, + unsigned msaaType = 1, unsigned msaaQuality = 0, Tr2RenderContextEnum::ExFlag flags = Tr2RenderContextEnum::EX_NONE, Tr2RenderContextEnum::TextureType type = Tr2RenderContextEnum::TEX_TYPE_2D ); @@ -55,8 +55,8 @@ BLUE_CLASS( Tr2RenderTarget ) : Tr2RenderContextEnum::TextureType type = Tr2RenderContextEnum::TEX_TYPE_2D ); int32_t CreateManual( - unsigned width, - unsigned height, + unsigned width, + unsigned height, unsigned mipLevelCount, Tr2RenderContextEnum::PixelFormat format, unsigned msaaType, @@ -87,22 +87,29 @@ BLUE_CLASS( Tr2RenderTarget ) : Tr2RenderContextEnum::TextureType GetType() const; long GenerateMipMaps(); - long Resolve( Tr2RenderTarget* destination ); - + long Resolve( Tr2RenderTarget * destination ); + Tr2TextureAL& GetRenderTarget(); const Tr2TextureAL& GetRenderTarget() const; - operator Tr2TextureAL&() { return GetRenderTarget(); } - operator const Tr2TextureAL&() const { return GetRenderTarget(); } + operator Tr2TextureAL&() + { + return GetRenderTarget(); + } + operator const Tr2TextureAL&() const + { + return GetRenderTarget(); + } uintptr_t GetSharedHandle() const; void SetName( const char* name ); std::string GetName() const; - + protected: virtual void ReleaseResources( TriStorage s ); virtual bool OnPrepareResources(); + private: Tr2TextureAL m_renderTarget; Tr2TextureAL m_attachedRenderTarget; @@ -119,7 +126,7 @@ BLUE_CLASS( Tr2RenderTarget ) : Tr2CpuUsage::Type m_cpuUsage; Tr2GpuUsage::Type m_gpuUsage; std::string m_name; - OnTextureChangeEvent m_onTextureChange; + OnTextureChangeEvent m_onTextureChange; bool HasALObject( int type, size_t object ); }; diff --git a/trinity/Tr2RenderTarget_Blue.cpp b/trinity/Tr2RenderTarget_Blue.cpp index b9788a6cd..754366106 100644 --- a/trinity/Tr2RenderTarget_Blue.cpp +++ b/trinity/Tr2RenderTarget_Blue.cpp @@ -9,7 +9,7 @@ const Be::ClassInfo* Tr2RenderTarget::ExposeToBlue() { ///////////////////////////////////////// // Blue class info - EXPOSURE_BEGIN( Tr2RenderTarget, "" ) + EXPOSURE_BEGIN( Tr2RenderTarget, "" ) MAP_INTERFACE( IRoot ) MAP_INTERFACE( Tr2RenderTarget ) @@ -28,12 +28,10 @@ const Be::ClassInfo* Tr2RenderTarget::ExposeToBlue() ":param msaaType: number of samples\n" ":param msaaQuality: MSAA quality\n" ":param flags: trinity.EX_FLAG\n" - ":param type: texture type (2D or CUBE)" - ) + ":param type: texture type (2D or CUBE)" ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "Create", Create, 4, @@ -46,8 +44,7 @@ const Be::ClassInfo* Tr2RenderTarget::ExposeToBlue() ":param msaaType: number of samples\n" ":param msaaQuality: MSAA quality\n" ":param flags: trinity.EX_FLAG\n" - ":param type: texture type (2D or CUBE)" - ) + ":param type: texture type (2D or CUBE)" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "CreateArray", @@ -62,53 +59,46 @@ const Be::ClassInfo* Tr2RenderTarget::ExposeToBlue() ":param flags: trinity.EX_FLAG\n" ":param type: texture type (2D or CUBE)" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GenerateMipMaps", GenerateMipMaps, - "Generate mipmaps, if any" - ) - - MAP_METHOD_AND_WRAP - ( + "Generate mipmaps, if any" ) + + MAP_METHOD_AND_WRAP( "Resolve", Resolve, "Resolve a renderTarget (typically MSAA ) into another RT (typically non-MSAA).\n" "May also work for just copying non-MSAA to non-MSAA, I'm not sure :P\n" - ":param destination: Tr2RenderTarget" - ) + ":param destination: Tr2RenderTarget" ) MAP_ATTRIBUTE( "name", m_name, "", Be::PERSISTONLY ); MAP_PROPERTY( "name", GetName, SetName, "" ) MAP_PROPERTY_READONLY( "width", GetWidth, "" ); - MAP_PROPERTY_READONLY( "height", GetHeight, "" ); + MAP_PROPERTY_READONLY( "height", GetHeight, "" ); MAP_PROPERTY_READONLY( "mipCount", GetMipCount, "" ); MAP_PROPERTY_READONLY( "multiSampleType", GetMsaaType, "" ); MAP_PROPERTY_READONLY( "multiSampleQuality", GetMsaaQuality, "" ); MAP_PROPERTY_READONLY( "arraySize", GetArraySize, "" ); - MAP_PROPERTY_READONLY( "format", GetFormat, "" ); + MAP_PROPERTY_READONLY( "format", GetFormat, "" ); MAP_PROPERTY_READONLY( "type", GetType, "" ); MAP_PROPERTY_READONLY( "isValid", IsValid, "is the graphics object successfully creaed" ); MAP_PROPERTY_READONLY( "isReadable", IsReadable, "can the RT be used as a texture" ); - MAP_METHOD_AND_WRAP( - "sharedHandle", - GetSharedHandle, - "sharedHandle" - ); + MAP_METHOD_AND_WRAP( + "sharedHandle", + GetSharedHandle, + "sharedHandle" ); - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasALObject", HasALObject, "Returns True iff Tr2RenderTarget contains a reference to passed AL object ID.\n" "Used for debugging along with trinity.GetLiveALResources.\n" ":param alType: AL object type (trinity.AL_OBJECT_TYPE)\n" - ":param alObject: AL object ID" - ) + ":param alObject: AL object ID" ) EXPOSURE_END() } diff --git a/trinity/Tr2RenderUtils.cpp b/trinity/Tr2RenderUtils.cpp index c28e072c6..54b1ce05b 100644 --- a/trinity/Tr2RenderUtils.cpp +++ b/trinity/Tr2RenderUtils.cpp @@ -8,30 +8,30 @@ using namespace Tr2RenderContextEnum; #include "Tr2Renderer.h" #include "TriViewport.h" -void SetupScreenQuad( Tr2ScreenVertex quad[4], - const Vector2& tlTexCoord, - const Vector2& brTexCoord, - const Vector2& tlVertexCoord, - const Vector2& brVertexCoord ) +void SetupScreenQuad( Tr2ScreenVertex quad[4], + const Vector2& tlTexCoord, + const Vector2& brTexCoord, + const Vector2& tlVertexCoord, + const Vector2& brVertexCoord ) { const TriViewport& viewport = Tr2Renderer::GetViewport(); - Vector2 tlScreen( tlVertexCoord[0] * 2.0f - 1.0f, -(tlVertexCoord[1] * 2.0f - 1.0f) ); - Vector2 brScreen( brVertexCoord[0] * 2.0f - 1.0f, -(brVertexCoord[1] * 2.0f - 1.0f) ); + Vector2 tlScreen( tlVertexCoord[0] * 2.0f - 1.0f, -( tlVertexCoord[1] * 2.0f - 1.0f ) ); + Vector2 brScreen( brVertexCoord[0] * 2.0f - 1.0f, -( brVertexCoord[1] * 2.0f - 1.0f ) ); const float z = 1.0f; const float w = 1.0f; int edge1 = 1; int edge2 = 2; - USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! pass it in so we look at actual current cull mode + USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! pass it in so we look at actual current cull mode if( !renderContext.m_esm.IsCullModeInverted() ) { - // Flip the interior edge direction in the quad which produces a correctly + // Flip the interior edge direction in the quad which produces a correctly // oriented strip of two triangles edge1 = 2; edge2 = 1; - } + } // Top Left quad[0].p = Vector4( tlScreen.x, tlScreen.y, z, w ); @@ -53,29 +53,29 @@ void SetupScreenQuad( Tr2ScreenVertex quad[4], void SetupScreenQuadInCameraSpace( Tr2ScreenVertex quad[4], int width, int height ) { const TriViewport& viewport = Tr2Renderer::GetViewport(); - + // Top-left and bottom-right in projection space: // See explanation in SetupScreenQuad for pixel offsets - Vector3 tl( -1.0f, 1.0f, 1.0f ); - Vector3 br( 1.0f, -1.0f, 1.0f ); + Vector3 tl( -1.0f, 1.0f, 1.0f ); + Vector3 br( 1.0f, -1.0f, 1.0f ); // Transform to view space: const Matrix& projectionRaw = Tr2Renderer::GetProjectionRawTransform(); Matrix proj2view = Inverse( projectionRaw ); tl = TransformCoord( tl, proj2view ); br = TransformCoord( br, proj2view ); - + int edge1 = 1; int edge2 = 2; - USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! pass it in for cull mode + USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! pass it in for cull mode if( !renderContext.m_esm.IsCullModeInverted() ) { - // Flip the interior edge direction in the quad which produces a correctly + // Flip the interior edge direction in the quad which produces a correctly // oriented strip of two triangles edge1 = 2; edge2 = 1; - } + } // The vertex shader should ensure that the z coordinate is pushed to w Vector2 tlTC( 0.0f, 0.0f ); @@ -131,7 +131,7 @@ void SetConstants( Tr2ConstantBufferAL& buffer, unsigned constantTypeMask, const { if( constantTypeMask & ( 1 << i ) ) { - renderContext.SetConstants( buffer, static_cast(i), registerIndex ); + renderContext.SetConstants( buffer, static_cast( i ), registerIndex ); constantTypeMask &= ~( 1 << i ); } } diff --git a/trinity/Tr2RenderUtils.h b/trinity/Tr2RenderUtils.h index b39d7c6fb..29f40426d 100644 --- a/trinity/Tr2RenderUtils.h +++ b/trinity/Tr2RenderUtils.h @@ -20,12 +20,11 @@ struct Tr2ScreenVertex // width and height of the target. If 0 is given for width/height, the current render target // is assumed. The verts are set up in clip space, with proper offsets applied to get perfect // pixel/texel alignment. -void SetupScreenQuad( Tr2ScreenVertex quad[4], - const Vector2& tlTexCoord = Vector2( 0.0f, 0.0f ), - const Vector2& brTexCoord = Vector2( 1.0f, 1.0f ), - const Vector2& tlVertexCoord = Vector2( 0.0f, 0.0f ), - const Vector2& brVertexCoord = Vector2( 1.0f, 1.0f ) - ); +void SetupScreenQuad( Tr2ScreenVertex quad[4], + const Vector2& tlTexCoord = Vector2( 0.0f, 0.0f ), + const Vector2& brTexCoord = Vector2( 1.0f, 1.0f ), + const Vector2& tlVertexCoord = Vector2( 0.0f, 0.0f ), + const Vector2& brVertexCoord = Vector2( 1.0f, 1.0f ) ); // Same as SetupScreenQuad except in camera space. void SetupScreenQuadInCameraSpace( Tr2ScreenVertex quad[4], int width = 0, int height = 0 ); @@ -33,47 +32,53 @@ void SetupScreenQuadInCameraSpace( Tr2ScreenVertex quad[4], int width = 0, int h -bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, - const void* const data, const size_t dataSize, - const unsigned constantTypeMask, - const unsigned registerIndex, - Tr2RenderContext& renderContext ); +bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, + const void* const data, + const size_t dataSize, + const unsigned constantTypeMask, + const unsigned registerIndex, + Tr2RenderContext& renderContext ); // Helper function to take care of a repeating pattern: // - if needed, create a constant buffer with this dataSize // - lock it, copy the given data to it if OK, and unlock it again // - set it to the context at registerIndex. -inline bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, - const void* const data, const size_t dataSize, - const Tr2RenderContextEnum::ShaderType constantType, - const unsigned registerIndex, - Tr2RenderContext& renderContext ) -{ return FillAndSetConstants( buffer, data, dataSize, 1 << constantType, registerIndex, renderContext ); } +inline bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, + const void* const data, + const size_t dataSize, + const Tr2RenderContextEnum::ShaderType constantType, + const unsigned registerIndex, + Tr2RenderContext& renderContext ) +{ + return FillAndSetConstants( buffer, data, dataSize, 1 << constantType, registerIndex, renderContext ); +} // Helper function to take care of a repeating pattern: // - if needed, create a constant buffer with that can fit 'data' // - lock it, copy the given data to it if OK, and unlock it again // - set it to the context at registerIndex. -template -bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, - const T& data, - const Tr2RenderContextEnum::ShaderType constantType, - const unsigned registerIndex, - Tr2RenderContext& renderContext ) -{ return FillAndSetConstants( buffer, &data, sizeof( data ), constantType, registerIndex, renderContext ); } +template +bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, + const T& data, + const Tr2RenderContextEnum::ShaderType constantType, + const unsigned registerIndex, + Tr2RenderContext& renderContext ) +{ + return FillAndSetConstants( buffer, &data, sizeof( data ), constantType, registerIndex, renderContext ); +} // inhibit this -template -bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, - const T*& data, - const Tr2RenderContextEnum::ShaderType constantType, - const unsigned registerIndex, - Tr2RenderContext& renderContext ); - -void SetConstants( Tr2ConstantBufferAL& buffer, - const unsigned constantTypeMask, - const unsigned registerIndex, - Tr2RenderContext& renderContext ); - - +template +bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, + const T*& data, + const Tr2RenderContextEnum::ShaderType constantType, + const unsigned registerIndex, + Tr2RenderContext& renderContext ); + +void SetConstants( Tr2ConstantBufferAL& buffer, + const unsigned constantTypeMask, + const unsigned registerIndex, + Tr2RenderContext& renderContext ); + + #endif // Tr2RenderUtils_h_ diff --git a/trinity/Tr2Renderer.cpp b/trinity/Tr2Renderer.cpp index e231f45e4..18a183819 100644 --- a/trinity/Tr2Renderer.cpp +++ b/trinity/Tr2Renderer.cpp @@ -13,10 +13,10 @@ using namespace Tr2RenderContextEnum; -bool Tr2Renderer::m_disableGeometryLoad = false; -bool Tr2Renderer::m_disableTextureLoad = false; -bool Tr2Renderer::m_disableEffectLoad = false; -bool Tr2Renderer::m_disableAsyncLoad = false; +bool Tr2Renderer::m_disableGeometryLoad = false; +bool Tr2Renderer::m_disableTextureLoad = false; +bool Tr2Renderer::m_disableEffectLoad = false; +bool Tr2Renderer::m_disableAsyncLoad = false; extern unsigned long long g_currentFrameCounter; @@ -28,305 +28,307 @@ Tr2Variable s_renderTimeVar; namespace { - // This flag is used to prevent code from inadvertently creating device resources in the middle of a device reset/invalidate attempt - bool s_isResourceCreationAllowed = true; +// This flag is used to prevent code from inadvertently creating device resources in the middle of a device reset/invalidate attempt +bool s_isResourceCreationAllowed = true; - TR2SHADERMODEL s_shaderModel = TR2SM_3_0_HI; - TR2SHADERMODEL s_prevShaderModel = TR2SM_3_0_HI; +TR2SHADERMODEL s_shaderModel = TR2SM_3_0_HI; +TR2SHADERMODEL s_prevShaderModel = TR2SM_3_0_HI; - // these are actually constant buffer indices - unsigned int s_perFrameVSStartRegister = 1; - unsigned int s_perFramePSStartRegister = 2; - unsigned int s_perObjectVSStartRegister = 3; - unsigned int s_perObjectPSStartRegister = 4; - unsigned int s_perObjectRTVertexBufferDataRegister = 5; - unsigned int s_perObjectVSGUIStartRegister = 6; +// these are actually constant buffer indices +unsigned int s_perFrameVSStartRegister = 1; +unsigned int s_perFramePSStartRegister = 2; +unsigned int s_perObjectVSStartRegister = 3; +unsigned int s_perObjectPSStartRegister = 4; +unsigned int s_perObjectRTVertexBufferDataRegister = 5; +unsigned int s_perObjectVSGUIStartRegister = 6; - uint32_t s_upscalingContextID = Tr2UpscalingAL::INVALID_CONTEXT_ID; +uint32_t s_upscalingContextID = Tr2UpscalingAL::INVALID_CONTEXT_ID; - TriPoolAllocator* s_poolAllocator = NULL; - // keep an array of directories which are to exclude from texture-sizing - std::vector s_dirsToExclude; +TriPoolAllocator* s_poolAllocator = NULL; +// keep an array of directories which are to exclude from texture-sizing +std::vector s_dirsToExclude; - PROJECTION_TYPE s_currentProjectionType = PT_PERSPECTIVE; +PROJECTION_TYPE s_currentProjectionType = PT_PERSPECTIVE; - Matrix s_projectionTransform; - Matrix s_projectionRawTransform; - Matrix s_inverseProjectionTransform; - Matrix s_viewport2projectionAdjustment; +Matrix s_projectionTransform; +Matrix s_projectionRawTransform; +Matrix s_inverseProjectionTransform; +Matrix s_viewport2projectionAdjustment; - Matrix s_viewTransform; - Matrix s_inverseViewTransform; +Matrix s_viewTransform; +Matrix s_inverseViewTransform; - Matrix s_viewProjectionTransform; +Matrix s_viewProjectionTransform; - float s_frontClip = 0.0f; - float s_backClip = 0.0f; - float s_frustumRadius = 0.0f; - float s_aspectRatio = 0.0f; - float s_fieldOfView = 0.0f; - float s_orthoWidth = 0.0f; - float s_orthoHeight = 0.0f; +float s_frontClip = 0.0f; +float s_backClip = 0.0f; +float s_frustumRadius = 0.0f; +float s_aspectRatio = 0.0f; +float s_fieldOfView = 0.0f; +float s_orthoWidth = 0.0f; +float s_orthoHeight = 0.0f; - void UpdateProjectionParameters( const Matrix& proj ) - { - // Use the fact that: - // aspect = m_22 / m_11; - // m_33 = z_f/(z_f-z_n), m_43 = -z_n*z_f/(z_f-z_n) - // => front = z_n = -m_43/m_33 - // => back = z_f = -m_43/(1+m_43/z_n) - // m_22 = cotan(fov/2) = 1 / tan(fov/2) - // => fov = 2*tan(1/m_22) - s_aspectRatio = ( proj._11 ? proj._22 / proj._11 : 0.0f ); - s_fieldOfView = ( proj._22 ? 2.0f*atan( 1.0f / proj._22 ) : 0.0f ); - s_frontClip = ( proj._33 ? proj._43 / proj._33 : 0.0f ); - s_backClip = proj._43 / ( 1.0f + proj._33 ); - } +void UpdateProjectionParameters( const Matrix& proj ) +{ + // Use the fact that: + // aspect = m_22 / m_11; + // m_33 = z_f/(z_f-z_n), m_43 = -z_n*z_f/(z_f-z_n) + // => front = z_n = -m_43/m_33 + // => back = z_f = -m_43/(1+m_43/z_n) + // m_22 = cotan(fov/2) = 1 / tan(fov/2) + // => fov = 2*tan(1/m_22) + s_aspectRatio = ( proj._11 ? proj._22 / proj._11 : 0.0f ); + s_fieldOfView = ( proj._22 ? 2.0f * atan( 1.0f / proj._22 ) : 0.0f ); + s_frontClip = ( proj._33 ? proj._43 / proj._33 : 0.0f ); + s_backClip = proj._43 / ( 1.0f + proj._33 ); +} - Matrix s_worldTransform; - Matrix s_inverseWorldTransform; +Matrix s_worldTransform; +Matrix s_inverseWorldTransform; - float s_pickingOffsetX = 0.0f; - float s_pickingOffsetY = 0.0f; - float s_pickingWidth = 0.0f; - float s_pickingHeight = 0.0f; +float s_pickingOffsetX = 0.0f; +float s_pickingOffsetY = 0.0f; +float s_pickingWidth = 0.0f; +float s_pickingHeight = 0.0f; - TriDebugTextRenderer* s_debugTextRenderer = NULL; +TriDebugTextRenderer* s_debugTextRenderer = NULL; - TriLineSet* s_debugLineSet = NULL; +TriLineSet* s_debugLineSet = NULL; - // shared vertex/index buffers - Tr2BufferAL s_quadVertexBuffer; - Tr2SuballocatedBuffer::Allocation s_quadListIndexBuffer; - uint32_t s_quadListSize = 0; +// shared vertex/index buffers +Tr2BufferAL s_quadVertexBuffer; +Tr2SuballocatedBuffer::Allocation s_quadListIndexBuffer; +uint32_t s_quadListSize = 0; - Tr2TextureAL s_fallbackTextures[2][3]; - bool s_debugFallbackTexture = false; +Tr2TextureAL s_fallbackTextures[2][3]; +bool s_debugFallbackTexture = false; - std::list> s_projectionStack; - std::list s_viewTransformStack; +std::list> s_projectionStack; +std::list s_viewTransformStack; - Tr2Variable s_projectionMatrixVar; - Tr2Variable s_viewMatrixVar; - Tr2Variable s_projectionMatrixInvVar; - Tr2Variable s_viewMatrixInvVar; - Tr2Variable s_viewProjectionMatrixVar; - Tr2Variable s_worldMatrixVar; - Tr2Variable s_frustumPlanes[6]; +Tr2Variable s_projectionMatrixVar; +Tr2Variable s_viewMatrixVar; +Tr2Variable s_projectionMatrixInvVar; +Tr2Variable s_viewMatrixInvVar; +Tr2Variable s_viewProjectionMatrixVar; +Tr2Variable s_worldMatrixVar; +Tr2Variable s_frustumPlanes[6]; - typedef std::set EffectSet; - EffectSet& GetEffectSet() - { - static NeverEndingSingleton effectSet; - return effectSet.GetInstance(); - } +typedef std::set EffectSet; +EffectSet& GetEffectSet() +{ + static NeverEndingSingleton effectSet; + return effectSet.GetInstance(); +} - void ReloadShaders() - { - typedef std::set EffectResSet; - EffectResSet effectResources; +void ReloadShaders() +{ + typedef std::set EffectResSet; + EffectResSet effectResources; - EffectSet& l = GetEffectSet(); - for( EffectSet::iterator i = l.begin(), end = l.end(); i != end; ++i ) - { - Tr2Effect* effect( *i ); - Tr2EffectRes* effectResource = effect->GetEffectRes(); - - if( effectResource && - effectResources.find( effectResource ) == effectResources.end() ) - { - effectResources.insert( effectResource ); - } - } + EffectSet& l = GetEffectSet(); + for( EffectSet::iterator i = l.begin(), end = l.end(); i != end; ++i ) + { + Tr2Effect* effect( *i ); + Tr2EffectRes* effectResource = effect->GetEffectRes(); - for( EffectResSet::iterator i = effectResources.begin(), - end = effectResources.end(); i != end; ++i ) + if( effectResource && + effectResources.find( effectResource ) == effectResources.end() ) { - Tr2EffectRes* effectResource( *i ); - effectResource->Reload(); - } - } - - void UpdateViewProjectionTransform() - { - s_viewProjectionTransform = s_viewTransform * s_projectionTransform; - s_viewProjectionMatrixVar = s_viewProjectionTransform; - - s_frustumPlanes[0] = Vector4( s_viewProjectionTransform._13, - s_viewProjectionTransform._23, - s_viewProjectionTransform._33, - s_viewProjectionTransform._43 ); - s_frustumPlanes[1] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._11, - s_viewProjectionTransform._24 + s_viewProjectionTransform._21, - s_viewProjectionTransform._34 + s_viewProjectionTransform._31, - s_viewProjectionTransform._44 + s_viewProjectionTransform._41 ); - s_frustumPlanes[2] = Vector4( s_viewProjectionTransform._14 - s_viewProjectionTransform._12, - s_viewProjectionTransform._24 - s_viewProjectionTransform._22, - s_viewProjectionTransform._34 - s_viewProjectionTransform._32, - s_viewProjectionTransform._44 - s_viewProjectionTransform._42 ); - s_frustumPlanes[3] = Vector4( s_viewProjectionTransform._14 - s_viewProjectionTransform._11, - s_viewProjectionTransform._24 - s_viewProjectionTransform._21, - s_viewProjectionTransform._34 - s_viewProjectionTransform._31, - s_viewProjectionTransform._44 - s_viewProjectionTransform._41 ); - s_frustumPlanes[4] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._12, - s_viewProjectionTransform._24 + s_viewProjectionTransform._22, - s_viewProjectionTransform._34 + s_viewProjectionTransform._32, - s_viewProjectionTransform._44 + s_viewProjectionTransform._42 ); - s_frustumPlanes[5] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._13, - s_viewProjectionTransform._24 + s_viewProjectionTransform._23, - s_viewProjectionTransform._34 + s_viewProjectionTransform._33, - s_viewProjectionTransform._44 + s_viewProjectionTransform._43 ); - } - - void SetProjectionDerivedValues() - { - s_projectionRawTransform = s_projectionTransform; - - // Apply scaling and offset to projection matrix. If the viewport extends - // the render target we need to clip the viewport and thus scale+offset the - // projection. - s_projectionTransform = s_projectionTransform * s_viewport2projectionAdjustment; - - // Cache inverse projection matrix - s_inverseProjectionTransform = Inverse( s_projectionTransform ); - - Vector4 corner( 1.f, 1.f, 1.f, 1.f ); - corner = Transform( corner, s_inverseProjectionTransform ); - Vector3 viewCorner( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w ); - s_frustumRadius = Length( viewCorner ); - - // Ensure TriVariable store is aware of the projection transform. Used by some debugging shaders. - s_projectionMatrixVar = s_projectionTransform; - s_projectionMatrixInvVar = s_inverseProjectionTransform; - UpdateViewProjectionTransform(); - } - - - void CreateFallbackTexturesWithColor( uint32_t color, Tr2TextureAL* outputTextures, Tr2PrimaryRenderContext& renderContext ) - { - bool tex0Valid = outputTextures[0].IsValid(); - bool tex1Valid = outputTextures[1].IsValid(); - bool tex2Valid = outputTextures[2].IsValid(); - - // only rebuild the textures if they are not valid - if( tex0Valid && tex1Valid && tex2Valid ) - { - return; + effectResources.insert( effectResource ); } + } - Tr2SubresourceData initialData[CUBEMAP_FACE_COUNT]; - for( int i = 0; i < CUBEMAP_FACE_COUNT; ++i ) - { - initialData[i].m_sysMemPitch = 4; - initialData[i].m_sysMemSlicePitch = 4; - initialData[i].m_sysMem = &color; - } - if( !tex0Valid ) - { - outputTextures[0].Create( Tr2BitmapDimensions( 1, 1, 1, PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, initialData, renderContext ); - } - if( !tex1Valid ) - { - outputTextures[1].Create( Tr2BitmapDimensions( TEX_TYPE_3D, PIXEL_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1 ), Tr2GpuUsage::SHADER_RESOURCE, initialData, renderContext ); - } - if( !tex2Valid ) - { - outputTextures[2].Create( Tr2BitmapDimensions( TEX_TYPE_CUBE, PIXEL_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1 ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, initialData, renderContext ); - } + for( EffectResSet::iterator i = effectResources.begin(), + end = effectResources.end(); + i != end; + ++i ) + { + Tr2EffectRes* effectResource( *i ); + effectResource->Reload(); } +} + +void UpdateViewProjectionTransform() +{ + s_viewProjectionTransform = s_viewTransform * s_projectionTransform; + s_viewProjectionMatrixVar = s_viewProjectionTransform; - void DestroyFallbackTextures( Tr2TextureAL* fallbackTextures ) + s_frustumPlanes[0] = Vector4( s_viewProjectionTransform._13, + s_viewProjectionTransform._23, + s_viewProjectionTransform._33, + s_viewProjectionTransform._43 ); + s_frustumPlanes[1] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._11, + s_viewProjectionTransform._24 + s_viewProjectionTransform._21, + s_viewProjectionTransform._34 + s_viewProjectionTransform._31, + s_viewProjectionTransform._44 + s_viewProjectionTransform._41 ); + s_frustumPlanes[2] = Vector4( s_viewProjectionTransform._14 - s_viewProjectionTransform._12, + s_viewProjectionTransform._24 - s_viewProjectionTransform._22, + s_viewProjectionTransform._34 - s_viewProjectionTransform._32, + s_viewProjectionTransform._44 - s_viewProjectionTransform._42 ); + s_frustumPlanes[3] = Vector4( s_viewProjectionTransform._14 - s_viewProjectionTransform._11, + s_viewProjectionTransform._24 - s_viewProjectionTransform._21, + s_viewProjectionTransform._34 - s_viewProjectionTransform._31, + s_viewProjectionTransform._44 - s_viewProjectionTransform._41 ); + s_frustumPlanes[4] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._12, + s_viewProjectionTransform._24 + s_viewProjectionTransform._22, + s_viewProjectionTransform._34 + s_viewProjectionTransform._32, + s_viewProjectionTransform._44 + s_viewProjectionTransform._42 ); + s_frustumPlanes[5] = Vector4( s_viewProjectionTransform._14 + s_viewProjectionTransform._13, + s_viewProjectionTransform._24 + s_viewProjectionTransform._23, + s_viewProjectionTransform._34 + s_viewProjectionTransform._33, + s_viewProjectionTransform._44 + s_viewProjectionTransform._43 ); +} + +void SetProjectionDerivedValues() +{ + s_projectionRawTransform = s_projectionTransform; + + // Apply scaling and offset to projection matrix. If the viewport extends + // the render target we need to clip the viewport and thus scale+offset the + // projection. + s_projectionTransform = s_projectionTransform * s_viewport2projectionAdjustment; + + // Cache inverse projection matrix + s_inverseProjectionTransform = Inverse( s_projectionTransform ); + + Vector4 corner( 1.f, 1.f, 1.f, 1.f ); + corner = Transform( corner, s_inverseProjectionTransform ); + Vector3 viewCorner( corner.x / corner.w, corner.y / corner.w, corner.z / corner.w ); + s_frustumRadius = Length( viewCorner ); + + // Ensure TriVariable store is aware of the projection transform. Used by some debugging shaders. + s_projectionMatrixVar = s_projectionTransform; + s_projectionMatrixInvVar = s_inverseProjectionTransform; + UpdateViewProjectionTransform(); +} + + +void CreateFallbackTexturesWithColor( uint32_t color, Tr2TextureAL* outputTextures, Tr2PrimaryRenderContext& renderContext ) +{ + bool tex0Valid = outputTextures[0].IsValid(); + bool tex1Valid = outputTextures[1].IsValid(); + bool tex2Valid = outputTextures[2].IsValid(); + + // only rebuild the textures if they are not valid + if( tex0Valid && tex1Valid && tex2Valid ) { - // this may cause a device hung since the texture index may be used in a constant buffer somewhere and therefore may be in use - fallbackTextures[0] = Tr2TextureAL(); - fallbackTextures[1] = Tr2TextureAL(); - fallbackTextures[2] = Tr2TextureAL(); + return; } - void CreateFallbackTextures( Tr2PrimaryRenderContext& renderContext ) + Tr2SubresourceData initialData[CUBEMAP_FACE_COUNT]; + for( int i = 0; i < CUBEMAP_FACE_COUNT; ++i ) { - if( s_debugFallbackTexture ) - { - CreateFallbackTexturesWithColor( 0xffff00ff, s_fallbackTextures[0], renderContext ); - CreateFallbackTexturesWithColor( 0x8800ff00, s_fallbackTextures[1], renderContext ); - } - else - { - CreateFallbackTexturesWithColor( 0, s_fallbackTextures[0], renderContext ); - DestroyFallbackTextures( s_fallbackTextures[1] ); - } + initialData[i].m_sysMemPitch = 4; + initialData[i].m_sysMemSlicePitch = 4; + initialData[i].m_sysMem = &color; + } + if( !tex0Valid ) + { + outputTextures[0].Create( Tr2BitmapDimensions( 1, 1, 1, PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, initialData, renderContext ); } + if( !tex1Valid ) + { + outputTextures[1].Create( Tr2BitmapDimensions( TEX_TYPE_3D, PIXEL_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1 ), Tr2GpuUsage::SHADER_RESOURCE, initialData, renderContext ); + } + if( !tex2Valid ) + { + outputTextures[2].Create( Tr2BitmapDimensions( TEX_TYPE_CUBE, PIXEL_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1 ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ, initialData, renderContext ); + } +} - // To deal with the adjusted viewport that D3D9 forces us to create when viewport - // extends beyond the screen - void AdjustTextureCoordsToViewport( Tr2RenderContext& renderContext, Vector2& topLeft, Vector2& bottomRight ) +void DestroyFallbackTextures( Tr2TextureAL* fallbackTextures ) +{ + // this may cause a device hung since the texture index may be used in a constant buffer somewhere and therefore may be in use + fallbackTextures[0] = Tr2TextureAL(); + fallbackTextures[1] = Tr2TextureAL(); + fallbackTextures[2] = Tr2TextureAL(); +} + +void CreateFallbackTextures( Tr2PrimaryRenderContext& renderContext ) +{ + if( s_debugFallbackTexture ) + { + CreateFallbackTexturesWithColor( 0xffff00ff, s_fallbackTextures[0], renderContext ); + CreateFallbackTexturesWithColor( 0x8800ff00, s_fallbackTextures[1], renderContext ); + } + else { - Vector2 tlTexCoordAdjusted = topLeft; + CreateFallbackTexturesWithColor( 0, s_fallbackTextures[0], renderContext ); + DestroyFallbackTextures( s_fallbackTextures[1] ); + } +} - auto& viewportOnDevice = renderContext.m_esm.GetDeviceViewport(); - auto& viewport = renderContext.m_esm.GetViewport(); +// To deal with the adjusted viewport that D3D9 forces us to create when viewport +// extends beyond the screen +void AdjustTextureCoordsToViewport( Tr2RenderContext& renderContext, Vector2& topLeft, Vector2& bottomRight ) +{ + Vector2 tlTexCoordAdjusted = topLeft; - int deltaX = (int)viewportOnDevice.m_x - viewport.x; - int deltaY = (int)viewportOnDevice.m_y - viewport.y; + auto& viewportOnDevice = renderContext.m_esm.GetDeviceViewport(); + auto& viewport = renderContext.m_esm.GetViewport(); - float xOffset = float( deltaX ) / viewport.width; - float yOffset = float( deltaY ) / viewport.height; + int deltaX = (int)viewportOnDevice.m_x - viewport.x; + int deltaY = (int)viewportOnDevice.m_y - viewport.y; - tlTexCoordAdjusted.x += xOffset * bottomRight.x; - tlTexCoordAdjusted.y += yOffset * bottomRight.y; + float xOffset = float( deltaX ) / viewport.width; + float yOffset = float( deltaY ) / viewport.height; - Vector2 brTexCoordAdjusted; - brTexCoordAdjusted = bottomRight; - brTexCoordAdjusted.x *= float( viewportOnDevice.m_width + deltaX ) / viewport.width; - brTexCoordAdjusted.y *= float( viewportOnDevice.m_height + deltaY ) / viewport.height; + tlTexCoordAdjusted.x += xOffset * bottomRight.x; + tlTexCoordAdjusted.y += yOffset * bottomRight.y; - topLeft = tlTexCoordAdjusted; - bottomRight = brTexCoordAdjusted; - } + Vector2 brTexCoordAdjusted; + brTexCoordAdjusted = bottomRight; + brTexCoordAdjusted.x *= float( viewportOnDevice.m_width + deltaX ) / viewport.width; + brTexCoordAdjusted.y *= float( viewportOnDevice.m_height + deltaY ) / viewport.height; - - template - bool CreateIndexBuffer( T count, Tr2SuballocatedBuffer::Allocation& buffer ) - { - USE_MAIN_THREAD_RENDER_CONTEXT(); - // Re-create the index buffer with the correct type + topLeft = tlTexCoordAdjusted; + bottomRight = brTexCoordAdjusted; +} - std::vector indices( count * 6 ); - T* pInds = indices.data(); - for( T i = 0; i < count; ++i ) - { - pInds[0] = 0 + 4 * i; - pInds[1] = 2 + 4 * i; - pInds[2] = 1 + 4 * i; - pInds[3] = 0 + 4 * i; - pInds[4] = 3 + 4 * i; - pInds[5] = 2 + 4 * i; - pInds += 6; - } - if( buffer.IsValid() ) - { - g_sharedBuffer.Free( buffer ); - } - auto hr = g_sharedBuffer.Allocate( sizeof( T ), count * 6, indices.data(), renderContext, buffer ); - if( FAILED( hr ) ) - { - CCP_LOGERR( "CreateIndexBuffer failed to create an index buffer for %d quads with HRESULT=0x(%X)", count, hr.GetResult() ); - return false; - } - return true; +template +bool CreateIndexBuffer( T count, Tr2SuballocatedBuffer::Allocation& buffer ) +{ + USE_MAIN_THREAD_RENDER_CONTEXT(); + // Re-create the index buffer with the correct type + + std::vector indices( count * 6 ); + T* pInds = indices.data(); + for( T i = 0; i < count; ++i ) + { + pInds[0] = 0 + 4 * i; + pInds[1] = 2 + 4 * i; + pInds[2] = 1 + 4 * i; + pInds[3] = 0 + 4 * i; + pInds[4] = 3 + 4 * i; + pInds[5] = 2 + 4 * i; + pInds += 6; + } + if( buffer.IsValid() ) + { + g_sharedBuffer.Free( buffer ); } + auto hr = g_sharedBuffer.Allocate( sizeof( T ), count * 6, indices.data(), renderContext, buffer ); + + if( FAILED( hr ) ) + { + CCP_LOGERR( "CreateIndexBuffer failed to create an index buffer for %d quads with HRESULT=0x(%X)", count, hr.GetResult() ); + return false; + } + return true; +} } bool Tr2Renderer::Initialize() { s_debugTextRenderer = CCP_NEW( "Tr2Renderer/s_debugTextRenderer" ) TriDebugTextRenderer; - s_renderTimeVar .Register( "Time", Vector4(0.0f, 0.0f, 0.0f, 0.0f) ); - s_worldMatrixVar .Register( "WorldMat", s_worldTransform ); + s_renderTimeVar.Register( "Time", Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) ); + s_worldMatrixVar.Register( "WorldMat", s_worldTransform ); s_viewMatrixVar.Register( "ViewMat", s_viewTransform ); s_viewMatrixInvVar.Register( "ViewInvMat", s_viewTransform ); s_projectionMatrixVar.Register( "ProjectionMat", s_projectionTransform ); @@ -342,7 +344,7 @@ bool Tr2Renderer::Initialize() s_poolAllocator = CCP_NEW( "Tr2Renderer/s_poolAllocator" ) TriPoolAllocator(); - USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! + USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! renderContext.m_esm.Initialize(); s_viewport2projectionAdjustment = IdentityMatrix(); @@ -353,7 +355,7 @@ bool Tr2Renderer::Initialize() void Tr2Renderer::Shutdown() { GlobalStore().UnregisterVariable( "Time" ); - USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! + USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! renderContext.m_esm.Shutdown(); CCP_DELETE s_blitter; @@ -369,18 +371,18 @@ void Tr2Renderer::Shutdown() void Tr2Renderer::GetBackBufferDimensions( unsigned int& w, unsigned int& h ) { - w = unsigned( gTriDev->mWidth ); - h = unsigned( gTriDev->mHeight ); + w = unsigned( gTriDev->mWidth ); + h = unsigned( gTriDev->mHeight ); } -MAP_FUNCTION_AND_WRAP( "ReloadShaders", ReloadShaders, "Forces Trinity to reload all shaders."); +MAP_FUNCTION_AND_WRAP( "ReloadShaders", ReloadShaders, "Forces Trinity to reload all shaders." ); static bool IsRightHanded() { return true; } -MAP_FUNCTION_AND_WRAP( "IsRightHanded", IsRightHanded, "Returns true if Trinity rendering uses a right-handed coordinate system."); +MAP_FUNCTION_AND_WRAP( "IsRightHanded", IsRightHanded, "Returns true if Trinity rendering uses a right-handed coordinate system." ); void Tr2Renderer::AdjustProjection( const Vector2& scaling, const Vector2& translation ) { @@ -388,8 +390,8 @@ void Tr2Renderer::AdjustProjection( const Vector2& scaling, const Vector2& trans Matrix& proj = s_projectionTransform; proj._11 *= scaling.x; proj._22 *= scaling.y; - proj._31 = scaling.x*proj._31 + proj._34*translation.x; - proj._32 = scaling.y*proj._32 + proj._34*translation.y; + proj._31 = scaling.x * proj._31 + proj._34 * translation.x; + proj._32 = scaling.y * proj._32 + proj._34 * translation.y; SetProjectionDerivedValues(); } @@ -496,8 +498,8 @@ Vector3 Tr2Renderer::ProjectWorldToScreen( const Vector3& worldPos, const Tr2Vie } return Vector3( vp.m_x + vp.m_width * ( 0.5f + 0.5f * p.x ), - vp.m_y + vp.m_height* ( 0.5f - 0.5f * p.y ), - vp.m_minZ + p.z * vp.m_maxZ ); + vp.m_y + vp.m_height * ( 0.5f - 0.5f * p.y ), + vp.m_minZ + p.z * vp.m_maxZ ); } const Matrix& Tr2Renderer::GetInverseProjectionTransform() @@ -547,7 +549,7 @@ float Tr2Renderer::GetOrthoHeight() void Tr2Renderer::SetWorldTransform( const Matrix& m ) { - s_worldTransform = m; + s_worldTransform = m; // Ensure variable store is aware of the change s_worldMatrixVar = s_worldTransform; @@ -608,8 +610,8 @@ void Tr2Renderer::SetUpscalingContextID( uint32_t upscalingContextID ) Vector4 ColorToVec4( uint32_t color ) { uint8_t r = ( color >> 16 ) & 0xffu; - uint8_t g = ( color >> 8 ) & 0xffu; - uint8_t b = ( color >> 0 ) & 0xffu; + uint8_t g = ( color >> 8 ) & 0xffu; + uint8_t b = ( color >> 0 ) & 0xffu; uint8_t a = ( color >> 24 ) & 0xffu; return Vector4( r, g, b, a ) / 255.0f; } @@ -644,7 +646,7 @@ void Tr2Renderer::PrintfImmediate( Tr2RenderContext& renderContext, int x, int y Tr2Viewport viewport; renderContext.GetViewport( viewport ); - + Tr2Rect rect; if( format & TRI_DFS_RIGHT ) { @@ -670,9 +672,9 @@ void Tr2Renderer::Printf( TriDebugFont font, const Tr2Rect& rect, uint32_t forma return; } - va_list args; - va_start( args, msg ); - s_debugTextRenderer->Vprintf( font, rect, format, ColorToVec4( color ), msg, args ); + va_list args; + va_start( args, msg ); + s_debugTextRenderer->Vprintf( font, rect, format, ColorToVec4( color ), msg, args ); } void Tr2Renderer::PrintfImmediate( Tr2RenderContext& renderContext, TriDebugFont font, const Tr2Rect& rect, uint32_t format, uint32_t color, const char* msg, ... ) @@ -695,7 +697,7 @@ void Tr2Renderer::Printf( TriDebugFont font, const Vector3& pos, uint32_t color, } va_list args; - va_start( args, msg ); + va_start( args, msg ); Tr2Rect rect; USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -704,7 +706,7 @@ void Tr2Renderer::Printf( TriDebugFont font, const Vector3& pos, uint32_t color, Vector3 screenPos = ProjectWorldToScreen( pos, vp ); - if( (screenPos.z > 0.0f) && (screenPos.z < 1.0f) ) + if( ( screenPos.z > 0.0f ) && ( screenPos.z < 1.0f ) ) { rect.top = (int32_t)screenPos.y; rect.left = (int32_t)screenPos.x; @@ -723,7 +725,7 @@ void Tr2Renderer::Printf( TriDebugFont font, int fontStyle, const Vector3& pos, } va_list args; - va_start( args, msg ); + va_start( args, msg ); Tr2Rect rect; USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -732,7 +734,7 @@ void Tr2Renderer::Printf( TriDebugFont font, int fontStyle, const Vector3& pos, Vector3 screenPos = ProjectWorldToScreen( pos, vp ); - if( !( (screenPos.z > 0.0f) && (screenPos.z < 1.0f) ) ) + if( !( ( screenPos.z > 0.0f ) && ( screenPos.z < 1.0f ) ) ) { return; } @@ -756,14 +758,14 @@ bool Tr2Renderer::DrawTexture( Tr2RenderContext& renderContext, Tr2Material* eff // -------------------------------------------------------------------------------------- // Description: -// draws a unit quad with the given shader +// draws a unit quad with the given shader // Arguments: // shader - the ShaderMaterial to use. // Return Value: // true if success, false if no blitter available. // -------------------------------------------------------------------------------------- -bool Tr2Renderer::DrawFullScreenWithShader( Tr2RenderContext& renderContext, Tr2Material * shader ) +bool Tr2Renderer::DrawFullScreenWithShader( Tr2RenderContext& renderContext, Tr2Material* shader ) { if( s_blitter ) { @@ -811,29 +813,24 @@ bool Tr2Renderer::DrawTexture( Tr2RenderContext& renderContext, Tr2Material* eff return false; } -bool Tr2Renderer::DrawTexture( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, - const Vector2& tlTexCoord, const Vector2& brTexCoord, - const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) +bool Tr2Renderer::DrawTexture( Tr2RenderContext& renderContext, Tr2Material* effect, const Tr2TextureAL& texture, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) { - if( s_blitter ) - { - Vector2 tlTexCoordAdjusted = tlTexCoord; - Vector2 brTexCoordAdjusted = brTexCoord; - AdjustTextureCoordsToViewport( renderContext, tlTexCoordAdjusted, brTexCoordAdjusted ); + if( s_blitter ) + { + Vector2 tlTexCoordAdjusted = tlTexCoord; + Vector2 brTexCoordAdjusted = brTexCoord; + AdjustTextureCoordsToViewport( renderContext, tlTexCoordAdjusted, brTexCoordAdjusted ); - if( effect ) - { - return s_blitter->Draw( renderContext, effect, texture, - tlTexCoordAdjusted, brTexCoordAdjusted, - tlVertexCoord, brVertexCoord ); - } - else - { - return s_blitter->Draw( renderContext, texture, tlTexCoordAdjusted, brTexCoordAdjusted, - tlVertexCoord, brVertexCoord ); - } - } - return false; + if( effect ) + { + return s_blitter->Draw( renderContext, effect, texture, tlTexCoordAdjusted, brTexCoordAdjusted, tlVertexCoord, brVertexCoord ); + } + else + { + return s_blitter->Draw( renderContext, texture, tlTexCoordAdjusted, brTexCoordAdjusted, tlVertexCoord, brVertexCoord ); + } + } + return false; } // -------------------------------------------------------------------------------------- @@ -849,9 +846,9 @@ bool Tr2Renderer::DrawTexture( Tr2RenderContext& renderContext, Tr2Material* eff // false On failure // -------------------------------------------------------------------------------------- bool Tr2Renderer::RunComputeShader( Tr2Material* effect, - unsigned groupDimX, - unsigned groupDimY, - unsigned groupDimZ, + unsigned groupDimX, + unsigned groupDimY, + unsigned groupDimZ, Tr2RenderContext& renderContext ) { if( !effect ) @@ -885,7 +882,7 @@ bool Tr2Renderer::RunComputeShader( Tr2Material* effect, } // -------------------------------------------------------------------------------------- -bool Tr2Renderer::RunComputeShader( +bool Tr2Renderer::RunComputeShader( Tr2Material* effect, const BlueSharedString& techniqueName, unsigned groupDimX, @@ -931,7 +928,7 @@ bool Tr2Renderer::RunComputeShader( // -------------------------------------------------------------------------------------- // Description: // Execute compute shaders in all passes of the specified effect. Group drid dimensions -// are taken from indirectParams GPU buffer. The function will unset bound UAVs after +// are taken from indirectParams GPU buffer. The function will unset bound UAVs after // each pass. // Arguments: // effect - Effect containing compute shaders @@ -1014,11 +1011,11 @@ void Tr2Renderer::DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Material* } } -void Tr2Renderer::DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Effect* effect, const Vector2 &topLeft, const Vector2 &bottomRight ) +void Tr2Renderer::DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Effect* effect, const Vector2& topLeft, const Vector2& bottomRight ) { if( s_blitter ) { - s_blitter->Draw( renderContext, effect, Vector2(0,0), Vector2(1,1), topLeft, bottomRight ); + s_blitter->Draw( renderContext, effect, Vector2( 0, 0 ), Vector2( 1, 1 ), topLeft, bottomRight ); } } @@ -1047,8 +1044,8 @@ void Tr2Renderer::BeginFrame() Vector4 timeData; timeData.x = GetAnimationTime(); - timeData.y = timeData.x - floorf(timeData.x); - timeData.z = static_cast(GetCurrentFrameCounter()); + timeData.y = timeData.x - floorf( timeData.x ); + timeData.z = static_cast( GetCurrentFrameCounter() ); timeData.w = timeDataOld.x; s_renderTimeVar = timeData; } @@ -1064,7 +1061,6 @@ void Tr2Renderer::EndFrame() { s_debugLineSet->Clear(); } - } HRESULT Tr2Renderer::BeginRenderContext() @@ -1115,7 +1111,7 @@ void Tr2Renderer::ReinitializeRegisteredEffects() EffectSet& l = GetEffectSet(); for( EffectSet::iterator it = l.begin(); it != l.end(); ++it ) { - (*it)->Initialize(); + ( *it )->Initialize(); } } @@ -1155,8 +1151,7 @@ TR2SHADERMODEL Tr2Renderer::GetShaderModel() const char* Tr2Renderer::GetShaderModelString( TR2SHADERMODEL sm ) { - static const char* smStrings[] = - { + static const char* smStrings[] = { "SM_1_1", "SM_2_0_LO", "SM_2_0_HI", @@ -1170,32 +1165,32 @@ const char* Tr2Renderer::GetShaderModelString( TR2SHADERMODEL sm ) return smStrings[sm]; } -void Tr2Renderer::AddMipLevelSkipExclusionDirectory(const char* path) +void Tr2Renderer::AddMipLevelSkipExclusionDirectory( const char* path ) { // make it upper-case, so all future comparing can be done with upper-case std::string checkDir( path ); - std::transform(checkDir.begin(), checkDir.end(), checkDir.begin(), toupper); + std::transform( checkDir.begin(), checkDir.end(), checkDir.begin(), toupper ); // add to array - s_dirsToExclude.push_back(checkDir); + s_dirsToExclude.push_back( checkDir ); } -bool Tr2Renderer::IsTextureToResize(const char* filename) +bool Tr2Renderer::IsTextureToResize( const char* filename ) { // convert to upper case std::string checkFilename( filename ); - std::transform(checkFilename.begin(), checkFilename.end(), checkFilename.begin(), toupper); + std::transform( checkFilename.begin(), checkFilename.end(), checkFilename.begin(), toupper ); // check it with all dirs in the array - for(std::vector::const_iterator it = s_dirsToExclude.begin(); it != s_dirsToExclude.end(); it++) + for( std::vector::const_iterator it = s_dirsToExclude.begin(); it != s_dirsToExclude.end(); it++ ) { // compare first part of filename against dir-array - if(strncmp(it->c_str(), checkFilename.c_str(), it->length()) == 0) + if( strncmp( it->c_str(), checkFilename.c_str(), it->length() ) == 0 ) return false; } // not found, so can do a resize! return true; } -bool Tr2Renderer::IsLowQuality(void) +bool Tr2Renderer::IsLowQuality( void ) { // is this low quality rendering? Decide here return ( GetShaderModel() <= TR2SM_3_0_LO ); @@ -1444,7 +1439,7 @@ const Tr2TextureAL& Tr2Renderer::GetFallbackTexture( Tr2EffectResource::Type tex uint32_t textureSet = 0; if( s_debugFallbackTexture ) { - textureSet = uint32_t( GetAnimationTime() * 20 ) % 2; + textureSet = uint32_t( GetAnimationTime() * 20 ) % 2; if( strlen( debugContext ) > 0 ) { @@ -1501,66 +1496,8 @@ bool Tr2Renderer::GetGeometryShaderSupport() FXC.exe /T gs_5_0 /E main /Fh gs.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv */ - const BYTE bytecode[] = - { - 68, 88, 66, 67, 131, 74, - 180, 213, 103, 95, 109, 18, - 214, 138, 181, 45, 155, 163, - 12, 252, 1, 0, 0, 0, - 92, 1, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 96, 0, 0, 0, 152, 0, - 0, 0, 73, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 83, 86, 95, 80, 111, 115, - 105, 116, 105, 111, 110, 0, - 79, 83, 71, 53, 48, 0, - 0, 0, 1, 0, 0, 0, - 8, 0, 0, 0, 0, 0, - 0, 0, 36, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 111, 115, 105, 116, 105, 111, - 110, 0, 83, 72, 69, 88, - 188, 0, 0, 0, 80, 0, - 2, 0, 47, 0, 0, 0, - 106, 8, 0, 1, 97, 0, - 0, 5, 242, 16, 32, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 93, 24, 0, 1, 143, 0, - 0, 3, 0, 0, 17, 0, - 0, 0, 0, 0, 92, 40, - 0, 1, 103, 0, 0, 4, - 242, 32, 16, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 94, 0, 0, 2, 3, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 117, 0, 0, 3, - 0, 0, 17, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 32, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 117, 0, 0, 3, - 0, 0, 17, 0, 0, 0, - 0, 0, 54, 0, 0, 6, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 32, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 117, 0, 0, 3, - 0, 0, 17, 0, 0, 0, - 0, 0, 62, 0, 0, 1 + const BYTE bytecode[] = { + 68, 88, 66, 67, 131, 74, 180, 213, 103, 95, 109, 18, 214, 138, 181, 45, 155, 163, 12, 252, 1, 0, 0, 0, 92, 1, 0, 0, 3, 0, 0, 0, 44, 0, 0, 0, 96, 0, 0, 0, 152, 0, 0, 0, 73, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 15, 0, 0, 83, 86, 95, 80, 111, 115, 105, 116, 105, 111, 110, 0, 79, 83, 71, 53, 48, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 80, 111, 115, 105, 116, 105, 111, 110, 0, 83, 72, 69, 88, 188, 0, 0, 0, 80, 0, 2, 0, 47, 0, 0, 0, 106, 8, 0, 1, 97, 0, 0, 5, 242, 16, 32, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 93, 24, 0, 1, 143, 0, 0, 3, 0, 0, 17, 0, 0, 0, 0, 0, 92, 40, 0, 1, 103, 0, 0, 4, 242, 32, 16, 0, 0, 0, 0, 0, 1, 0, 0, 0, 94, 0, 0, 2, 3, 0, 0, 0, 54, 0, 0, 6, 242, 32, 16, 0, 0, 0, 0, 0, 70, 30, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 3, 0, 0, 17, 0, 0, 0, 0, 0, 54, 0, 0, 6, 242, 32, 16, 0, 0, 0, 0, 0, 70, 30, 32, 0, 1, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 3, 0, 0, 17, 0, 0, 0, 0, 0, 54, 0, 0, 6, 242, 32, 16, 0, 0, 0, 0, 0, 70, 30, 32, 0, 2, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 3, 0, 0, 17, 0, 0, 0, 0, 0, 62, 0, 0, 1 }; Tr2ShaderAL shader; diff --git a/trinity/Tr2Renderer.h b/trinity/Tr2Renderer.h index 0fd096c1e..fbbb3a452 100644 --- a/trinity/Tr2Renderer.h +++ b/trinity/Tr2Renderer.h @@ -61,7 +61,7 @@ class Tr2Renderer static unsigned int GetPerObjectVSGUIStartRegister(); - template + template static unsigned int GetPerObjectStartRegister() { if( shaderType == Tr2RenderContextEnum::PIXEL_SHADER ) @@ -80,11 +80,26 @@ class Tr2Renderer return GetPerObjectVSStartRegister(); } - static void DisableResourceLoad( bool flag ) { m_disableGeometryLoad = m_disableTextureLoad = m_disableEffectLoad = flag; } - static bool IsGeometryLoadDisabled() { return m_disableGeometryLoad; } - static bool IsTextureLoadDisabled() { return m_disableTextureLoad; } - static bool IsEffectLoadDisabled() { return m_disableEffectLoad; } - static bool IsAsyncLoadDisabled() { return m_disableAsyncLoad; } + static void DisableResourceLoad( bool flag ) + { + m_disableGeometryLoad = m_disableTextureLoad = m_disableEffectLoad = flag; + } + static bool IsGeometryLoadDisabled() + { + return m_disableGeometryLoad; + } + static bool IsTextureLoadDisabled() + { + return m_disableTextureLoad; + } + static bool IsEffectLoadDisabled() + { + return m_disableEffectLoad; + } + static bool IsAsyncLoadDisabled() + { + return m_disableAsyncLoad; + } static bool m_disableGeometryLoad; static bool m_disableTextureLoad; @@ -117,8 +132,8 @@ class Tr2Renderer static HRESULT BeginRenderContext(); static HRESULT EndRenderContext(); - static void GetBackBufferDimensions( unsigned int& w, unsigned int& h ); - + static void GetBackBufferDimensions( unsigned int& w, unsigned int& h ); + // Sets up a perspective projection transform based on the field of view, front/back plane and aspect ratio static void SetPerspectiveProjection( float fov, float front, float back, float asp, const Matrix& viewportAdjustment = IdentityMatrix() ); @@ -140,34 +155,34 @@ class Tr2Renderer // extracted from this - use only for special purpose projection, such as in picking. static void SetProjectionTransform( const Matrix& proj, const Matrix& viewportAdjustment = IdentityMatrix() ); - static const Matrix& GetProjectionTransform(); + static const Matrix& GetProjectionTransform(); static Matrix GetReversedDepthProjectionTransform(); static const Matrix& GetProjectionRawTransform(); - static const Matrix& GetInverseProjectionTransform(); + static const Matrix& GetInverseProjectionTransform(); static const PROJECTION_TYPE GetCurrentProjectionType(); static Vector3 ProjectWorldToScreen( const Vector3& worldPos, const Tr2Viewport& vp ); static const TriViewport& GetViewport(); - - static float GetFrontClip(); - static float GetBackClip(); + + static float GetFrontClip(); + static float GetBackClip(); static float GetFrustumRadius(); static void GetFrustumPlane( size_t index, Vector4& plane ); - static float GetFieldOfView(); - static float GetAspectRatio(); + static float GetFieldOfView(); + static float GetAspectRatio(); static float GetOrthoWidth(); static float GetOrthoHeight(); - - static void SetWorldTransform( const Matrix& m ); - static const Matrix& GetWorldTransform(); - static void SetViewTransform( const Matrix& m ); - static const Matrix& GetViewTransform(); - static const Matrix& GetInverseViewTransform(); - - static const Vector3& GetViewPosition(); - static Vector3 GetViewLookAt(); + static void SetWorldTransform( const Matrix& m ); + static const Matrix& GetWorldTransform(); + + static void SetViewTransform( const Matrix& m ); + static const Matrix& GetViewTransform(); + static const Matrix& GetInverseViewTransform(); + + static const Vector3& GetViewPosition(); + static Vector3 GetViewLookAt(); static float GetAnimationTime(); static float GetAnimationTimeElapsed( float startTime ); @@ -180,8 +195,8 @@ class Tr2Renderer // This allows calls to Printf outside the rendering phase. static void Printf( int x, int y, uint32_t color, const char* msg, ... ); static void Printf( TriDebugFont font, const Tr2Rect& rect, uint32_t format, uint32_t color, const char* msg, ... ); - static void Printf( TriDebugFont font, const Vector3& pos, uint32_t color, const char* msg, ... ); - static void Printf( TriDebugFont font, int fontStyle, const Vector3& pos, Vector4 color, const char* msg, ... ); + static void Printf( TriDebugFont font, const Vector3& pos, uint32_t color, const char* msg, ... ); + static void Printf( TriDebugFont font, int fontStyle, const Vector3& pos, Vector4 color, const char* msg, ... ); // Text output for debugging purposes. // Text is rendered immediately so these functions can only be called within @@ -209,9 +224,9 @@ class Tr2Renderer static bool DrawTexture( Tr2RenderContext& renderContext, Tr2Material* effect, const Vector2& tlTexCoord, const Vector2& brTexCoord ); static void DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Material* effect ); - static void DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Effect* effect, const Vector2 &topLeft, const Vector2 &bottomRight ); + static void DrawScreenQuad( Tr2RenderContext& renderContext, Tr2Effect* effect, const Vector2& topLeft, const Vector2& bottomRight ); static void DrawCameraSpaceScreenQuad( Tr2RenderContext& renderContext, Tr2Shader* shader, Tr2Material* material ); - static bool DrawFullScreenWithShader( Tr2RenderContext& renderContext, Tr2Material * material ); + static bool DrawFullScreenWithShader( Tr2RenderContext& renderContext, Tr2Material* material ); static bool RunComputeShader( Tr2Material* effect, unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ, Tr2RenderContext& renderContext ); static bool RunComputeShader( Tr2Material* effect, const BlueSharedString& technique, unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ, Tr2RenderContext& renderContext ); @@ -233,12 +248,11 @@ class Tr2Renderer static void InitializeSystemShaderOptions(); static bool GetGeometryShaderSupport(); -private: +private: static void SetResourceCreationAllowed( bool isAllowed ); friend class TriDevice; - }; #endif // Tr2Renderer_H \ No newline at end of file diff --git a/trinity/Tr2Renderer_Blue.cpp b/trinity/Tr2Renderer_Blue.cpp index fabedb87d..0a747cbe7 100644 --- a/trinity/Tr2Renderer_Blue.cpp +++ b/trinity/Tr2Renderer_Blue.cpp @@ -7,48 +7,43 @@ #include "TriPythonContext.h" static void SetViewTransform( const Matrix& m ) -{ +{ Tr2Renderer::SetViewTransform( m ); } -MAP_FUNCTION_AND_WRAP( "SetViewTransform", SetViewTransform, - "Sets the view matrix for rendering.\n\n" - ":param matrix: 4-tuple of 4-tuples representing a D3D view matrix" ); +MAP_FUNCTION_AND_WRAP( "SetViewTransform", SetViewTransform, "Sets the view matrix for rendering.\n\n" + ":param matrix: 4-tuple of 4-tuples representing a D3D view matrix" ); static Matrix GetViewTransform() -{ +{ return Tr2Renderer::GetViewTransform(); } -MAP_FUNCTION_AND_WRAP( "GetViewTransform", GetViewTransform, - "Returns the view matrix used for rendering.\n" - "The matrix is a 4-tuple of 4-tuples representing a D3D view matrix" ); +MAP_FUNCTION_AND_WRAP( "GetViewTransform", GetViewTransform, "Returns the view matrix used for rendering.\n" + "The matrix is a 4-tuple of 4-tuples representing a D3D view matrix" ); static void SetPerspectiveProjection( float fov, float front, float back, float asp ) { Tr2Renderer::SetPerspectiveProjection( fov, front, back, asp ); } -MAP_FUNCTION_AND_WRAP( "SetPerspectiveProjection", SetPerspectiveProjection, - "Sets the perspective projection for rendering.\n\n" - ":param fov: field of view on the y-axis, in radians,\n" - ":param front: z-value of the near view plane,\n" - ":param back: z-value of the far view plane,\n" - ":param asp: aspect ratio, defined as view space width divided by height." ); +MAP_FUNCTION_AND_WRAP( "SetPerspectiveProjection", SetPerspectiveProjection, "Sets the perspective projection for rendering.\n\n" + ":param fov: field of view on the y-axis, in radians,\n" + ":param front: z-value of the near view plane,\n" + ":param back: z-value of the far view plane,\n" + ":param asp: aspect ratio, defined as view space width divided by height." ); static Vector3 GetViewPosition() { return Tr2Renderer::GetViewPosition(); } -MAP_FUNCTION_AND_WRAP( "GetViewPosition", GetViewPosition, - "Returns the view (camera) position as a tuple of 3 floats." ); +MAP_FUNCTION_AND_WRAP( "GetViewPosition", GetViewPosition, "Returns the view (camera) position as a tuple of 3 floats." ); static Matrix GetProjectionTransform() { return Tr2Renderer::GetProjectionTransform(); } -MAP_FUNCTION_AND_WRAP( "GetProjectionTransform", GetProjectionTransform, - "Returns the projection matrix used for rendering.\n" - "The matrix is a 4x4 tuple of floats." ); +MAP_FUNCTION_AND_WRAP( "GetProjectionTransform", GetProjectionTransform, "Returns the projection matrix used for rendering.\n" + "The matrix is a 4x4 tuple of floats." ); static float GetFrontClip() { @@ -79,14 +74,13 @@ static void SetPerspectiveProjectionOffCenter( float left, float right, float bo { Tr2Renderer::SetPerspectiveProjection( left, right, bottom, top, front, back ); } -MAP_FUNCTION_AND_WRAP( "SetPerspectiveProjectionOffCenter", SetPerspectiveProjectionOffCenter, - "This method allows an off-center projection to be set for the renderer.\n\n" - ":param left: minimum x-value of the view volume,\n" - ":param right: maximum x-value of the view volume,\n" - ":param bottom: minimum y-value of the view volume,\n" - ":param top: maximum y-value of the view volume,\n" - ":param front: minimum z-value of the view volume,\n" - ":param back: maximum z-value of the view volume." ); +MAP_FUNCTION_AND_WRAP( "SetPerspectiveProjectionOffCenter", SetPerspectiveProjectionOffCenter, "This method allows an off-center projection to be set for the renderer.\n\n" + ":param left: minimum x-value of the view volume,\n" + ":param right: maximum x-value of the view volume,\n" + ":param bottom: minimum y-value of the view volume,\n" + ":param top: maximum y-value of the view volume,\n" + ":param front: minimum z-value of the view volume,\n" + ":param back: maximum z-value of the view volume." ); #if BLUE_WITH_PYTHON static PyObject* PySetShaderModel( PyObject* self, PyObject* args ) @@ -106,9 +100,9 @@ static PyObject* PySetShaderModel( PyObject* self, PyObject* args ) const char* name = 0; - if( !PyArg_ParseTuple( args, "s", &name )) + if( !PyArg_ParseTuple( args, "s", &name ) ) { - isShaderModelChanging = false; + isShaderModelChanging = false; return NULL; } @@ -130,31 +124,29 @@ static PyObject* PySetShaderModel( PyObject* self, PyObject* args ) else { PyErr_SetString( PyExc_ValueError, "Shader model not recognized." ); - isShaderModelChanging = false; + isShaderModelChanging = false; return NULL; } isShaderModelChanging = false; Py_RETURN_NONE; } -MAP_FUNCTION( "SetShaderModel", PySetShaderModel, - "Sets the shader model to use for rendering in Trinity.\n" - "This is a combination of the D3D shader model to use, and a high/low fidelity version\n" - "within that model. This value affects what .fx files are loaded by Tr2Effect objects.\n" - "Currently supported values are (as strings):\n" - " SM_1_1\n" - " SM_2_0_LO\n" - " SM_2_0_HI\n" - " SM_3_0_LO\n" - " SM_3_0_HI\n" - " SM_3_0_DEPTH\n" - " SM_AUTHORING\n" - "May raise a trinity.D3DERR_INVALIDCALL if a device reset is already in progress" - "\n\n" - ":param sm: shader model name\n" - ":type sm: str\n" - ":rtype: None" - ); +MAP_FUNCTION( "SetShaderModel", PySetShaderModel, "Sets the shader model to use for rendering in Trinity.\n" + "This is a combination of the D3D shader model to use, and a high/low fidelity version\n" + "within that model. This value affects what .fx files are loaded by Tr2Effect objects.\n" + "Currently supported values are (as strings):\n" + " SM_1_1\n" + " SM_2_0_LO\n" + " SM_2_0_HI\n" + " SM_3_0_LO\n" + " SM_3_0_HI\n" + " SM_3_0_DEPTH\n" + " SM_AUTHORING\n" + "May raise a trinity.D3DERR_INVALIDCALL if a device reset is already in progress" + "\n\n" + ":param sm: shader model name\n" + ":type sm: str\n" + ":rtype: None" ); #endif static const char* GetShaderModel() @@ -171,16 +163,14 @@ MAP_FUNCTION_AND_WRAP( "GetCurrentFrameCounter", GetCurrentFrameCounter, "Gets t static void AddMipLevelSkipExclusionDirectory( const char* name ) { - Tr2Renderer::AddMipLevelSkipExclusionDirectory(name); + Tr2Renderer::AddMipLevelSkipExclusionDirectory( name ); } -MAP_FUNCTION_AND_WRAP( "AddMipLevelSkipExclusionDirectory", AddMipLevelSkipExclusionDirectory, - "Adds a resource directory to internal list. All textures in that directory are\n" - "not downsized due to graphics quality.\n" - "example: AddMipLevelSkipExclusionDirectory(\"res:/ui/\")\n" - "To clear the internal directory-list, use ::ClearMipLevelSkipExclusionDirectories()\n" - ":param name: directory res path" - ); +MAP_FUNCTION_AND_WRAP( "AddMipLevelSkipExclusionDirectory", AddMipLevelSkipExclusionDirectory, "Adds a resource directory to internal list. All textures in that directory are\n" + "not downsized due to graphics quality.\n" + "example: AddMipLevelSkipExclusionDirectory(\"res:/ui/\")\n" + "To clear the internal directory-list, use ::ClearMipLevelSkipExclusionDirectories()\n" + ":param name: directory res path" ); static void EnableFallbackTextureDebugging() { diff --git a/trinity/Tr2RingBuffer.cpp b/trinity/Tr2RingBuffer.cpp index 46e2e6ae6..dcb428ff7 100644 --- a/trinity/Tr2RingBuffer.cpp +++ b/trinity/Tr2RingBuffer.cpp @@ -130,7 +130,7 @@ Tr2RingBuffer& Tr2RingBuffer::GetInstance() void Tr2RingBuffer::SetName( const std::string& name ) { this->m_name = name; - if ( m_buffer.IsValid() ) + if( m_buffer.IsValid() ) { m_buffer.SetName( m_name.c_str() ); } diff --git a/trinity/Tr2RingBuffer.h b/trinity/Tr2RingBuffer.h index 5c17d3d33..8807a7abf 100644 --- a/trinity/Tr2RingBuffer.h +++ b/trinity/Tr2RingBuffer.h @@ -21,16 +21,16 @@ BLUE_CLASS( Tr2RingBuffer ) : public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); template uint32_t UploadTransforms( const T* data, uint32_t matrixCount ); - void PrepareBuffer( Tr2RenderContext& renderContext ); + void PrepareBuffer( Tr2RenderContext & renderContext ); void SetFrameNumbers( uint64_t recordingFrame, uint64_t completedFrame ); Tr2BufferAL* GetGpuBuffer( unsigned index ) override; - template + template static Tr2RingBuffer& GetInstance(); void SetName( const std::string& name ); @@ -83,8 +83,8 @@ class Tr2RingBufferOffsets void AdvanceFrame(); static const uint32_t INVALID_OFFSET = 0xffffffff; -private: +private: uint32_t m_currentFrameOffset = INVALID_OFFSET; uint32_t m_previousFrameOffset = INVALID_OFFSET; }; diff --git a/trinity/Tr2RotationTool.cpp b/trinity/Tr2RotationTool.cpp index 9a83c64d0..87b01f8f1 100644 --- a/trinity/Tr2RotationTool.cpp +++ b/trinity/Tr2RotationTool.cpp @@ -6,8 +6,8 @@ #include "Tr2LineSet.h" #include "Shader/Tr2Effect.h" -Tr2RotationTool::Tr2RotationTool( IRoot* lockobj ) - :m_precision( 1 ), +Tr2RotationTool::Tr2RotationTool( IRoot* lockobj ) : + m_precision( 1 ), m_rotation( IdentityQuaternion() ), m_angle( 0.0f ) { @@ -22,7 +22,7 @@ void Tr2RotationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYD Vector3 normal; Vector3 ray; Vector3 startPos; - + pos.x = m_localTransform._41; pos.y = m_localTransform._42; pos.z = m_localTransform._43; @@ -34,7 +34,7 @@ void Tr2RotationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYD normal = GetDesiredPlaneNormal( ray, viewMatrix ); // Tracking a point in 3d space based on the screen positions - ScreenCoordinatesToRay( mouseX-mouseXDelta, mouseY-mouseYDelta, ray, startPos, viewport, viewMatrix, projectionMatrix ); + ScreenCoordinatesToRay( mouseX - mouseXDelta, mouseY - mouseYDelta, ray, startPos, viewport, viewMatrix, projectionMatrix ); Vector3 startPlanePos = RayToPlaneIntersection( startPos, ray, pos, normal ); ScreenCoordinatesToRay( mouseX, mouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); @@ -45,15 +45,15 @@ void Tr2RotationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYD end = Normalize( endPlanePos - pos ); float dot = Dot( start, end ); - - if(( 1.0f - dot ) < FLT_EPSILON) + + if( ( 1.0f - dot ) < FLT_EPSILON ) { return; } float angleSign = 1.0f; Vector3 dnormal = Cross( start, end ); - + Vector3 xAxis; Vector3 yAxis; Vector3 zAxis; @@ -81,11 +81,11 @@ void Tr2RotationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYD else if( m_selectedAxis == "ww" ) { Vector3 curP = Hemisphere( mouseX, mouseY, viewport, viewMatrix, projectionMatrix ); - Vector3 preP = Hemisphere( mouseX-mouseXDelta, mouseY-mouseYDelta, viewport, viewMatrix, projectionMatrix ); + Vector3 preP = Hemisphere( mouseX - mouseXDelta, mouseY - mouseYDelta, viewport, viewMatrix, projectionMatrix ); // Get the target rotation axis Vector3 norm = Cross( preP, curP ); - // Since the hemisphere vectors are in view space we have to make sure - // the translation of camera is undone + // Since the hemisphere vectors are in view space we have to make sure + // the translation of camera is undone Matrix invView = Inverse( viewMatrix ); norm = TransformNormal( norm, invView ); Matrix worldInv = Inverse( m_localTransform ); @@ -116,7 +116,7 @@ void Tr2RotationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYD tmp = zAxis; m_movement = untransformedZAxis; } - + // Reverse the axis if the cross product of the start and end vectors is pointing away from the target rotation axis // dnormal is in world, so axis must be too if( Dot( dnormal, tmp ) < 0.0f ) @@ -162,21 +162,21 @@ Vector3 Tr2RotationTool::GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMatrix axis = zAxis; } norm = axis; - if( Dot( view, norm ) > 0.0f ) + if( Dot( view, norm ) > 0.0f ) { norm = -norm; } - } + } norm = Normalize( norm ); return norm; } -std::vector& Tr2RotationTool::GetPrimitivesToRender( ) +std::vector& Tr2RotationTool::GetPrimitivesToRender() { m_visibleObjects.clear(); for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - m_visibleObjects.push_back((*it)); + m_visibleObjects.push_back( ( *it ) ); } return m_visibleObjects; } @@ -185,25 +185,25 @@ void Tr2RotationTool::ResetPrimitiveColors() { for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == "x" ) + if( ( *it )->m_name == "x" ) { - (*it)->SetCurrentColor((Color&)v4Red); + ( *it )->SetCurrentColor( (Color&)v4Red ); } - else if((*it)->m_name == "y" ) + else if( ( *it )->m_name == "y" ) { - (*it)->SetCurrentColor((Color&)v4Green); + ( *it )->SetCurrentColor( (Color&)v4Green ); } - else if((*it)->m_name == "z" ) + else if( ( *it )->m_name == "z" ) { - (*it)->SetCurrentColor((Color&)v4Blue); + ( *it )->SetCurrentColor( (Color&)v4Blue ); } - else if((*it)->m_name == "w" ) + else if( ( *it )->m_name == "w" ) { - (*it)->SetCurrentColor((Color&)v4Cyan); + ( *it )->SetCurrentColor( (Color&)v4Cyan ); } - else if((*it)->m_name == "ww" ) + else if( ( *it )->m_name == "ww" ) { - (*it)->SetCurrentColor((Color&)v4LightGray); + ( *it )->SetCurrentColor( (Color&)v4LightGray ); } } } @@ -227,36 +227,36 @@ void Tr2RotationTool::GenLineSets() Tr2EffectPtr pEffect; - if( !m_xLine .CreateInstance() || - !m_yLine .CreateInstance() || - !m_zLine .CreateInstance() || - !m_wLine .CreateInstance() || - !m_wwLine .CreateInstance() || - !mLineEffect.CreateInstance() || + if( !m_xLine.CreateInstance() || + !m_yLine.CreateInstance() || + !m_zLine.CreateInstance() || + !m_wLine.CreateInstance() || + !m_wwLine.CreateInstance() || + !mLineEffect.CreateInstance() || !mSPHLineEffect.CreateInstance() || - !pEffect .CreateInstance() ) + !pEffect.CreateInstance() ) { return; } - mSPHLineEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/LinesRotationTool.fx"); - mLineEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx"); - pEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); + mSPHLineEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/LinesRotationTool.fx" ); + mLineEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx" ); + pEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); // wwLine - c_tris = Tr2ManipulationTool::GetCirclePoints(1.0f, 60, &numVectors); - for( int i = 0; i < numVectors/2; i++ ) + c_tris = Tr2ManipulationTool::GetCirclePoints( 1.0f, 60, &numVectors ); + for( int i = 0; i < numVectors / 2; i++ ) { - m_wwLine->AddLine( c_tris[i*2], v4LightGray, c_tris[i*2+1], v4LightGray ); + m_wwLine->AddLine( c_tris[i * 2], v4LightGray, c_tris[i * 2 + 1], v4LightGray ); } - delete [] c_tris; + delete[] c_tris; - c_tris = Tr2ManipulationTool::GetCircleTriangles(1.0f, 60, &numVectors); - for( int i = 0; i < numVectors/3; i++ ) + c_tris = Tr2ManipulationTool::GetCircleTriangles( 1.0f, 60, &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - m_wwLine->AddPickingTriangle( c_tris[i*3], c_tris[i*3+1], c_tris[i*3+2] ); + m_wwLine->AddPickingTriangle( c_tris[i * 3], c_tris[i * 3 + 1], c_tris[i * 3 + 2] ); } - delete [] c_tris; + delete[] c_tris; m_wwLine->SubmitChanges(); m_wwLine->m_name = "ww"; m_wwLine->m_scaleByDistanceToView = true; @@ -265,19 +265,19 @@ void Tr2RotationTool::GenLineSets() m_wwLine->m_viewOriented = true; // wLine - c_tris = Tr2ManipulationTool::GetCirclePoints(1.2f, 60, &numVectors); - for( int i = 0; i < numVectors/2; i++ ) + c_tris = Tr2ManipulationTool::GetCirclePoints( 1.2f, 60, &numVectors ); + for( int i = 0; i < numVectors / 2; i++ ) { - m_wLine->AddLine( c_tris[i*2], v4Cyan, c_tris[i*2+1], v4Cyan ); + m_wLine->AddLine( c_tris[i * 2], v4Cyan, c_tris[i * 2 + 1], v4Cyan ); int numVectorsB = 0; - p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i*2], c_tris[i*2+1], 0.08f, &numVectorsB); - for( int i = 0; i < numVectorsB/3; i++ ) + p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i * 2], c_tris[i * 2 + 1], 0.08f, &numVectorsB ); + for( int i = 0; i < numVectorsB / 3; i++ ) { - m_wLine->AddPickingTriangle( p_tris[i*3], p_tris[i*3+1], p_tris[i*3+2] ); - } - delete [] p_tris; - } - delete [] c_tris; + m_wLine->AddPickingTriangle( p_tris[i * 3], p_tris[i * 3 + 1], p_tris[i * 3 + 2] ); + } + delete[] p_tris; + } + delete[] c_tris; m_wLine->SubmitChanges(); @@ -288,22 +288,22 @@ void Tr2RotationTool::GenLineSets() m_wLine->m_viewOriented = true; // xLine - c_tris = Tr2ManipulationTool::GetCirclePoints(1.0f, 60, &numVectors); + c_tris = Tr2ManipulationTool::GetCirclePoints( 1.0f, 60, &numVectors ); rotateMat = RotationYMatrix( XM_PI / 2.0f ); TransformCoords( c_tris, numVectors, rotateMat ); - for( int i = 0; i < numVectors/2; i++ ) + for( int i = 0; i < numVectors / 2; i++ ) { - m_xLine->AddLine( c_tris[i*2], v4Red, c_tris[i*2+1], v4Red ); + m_xLine->AddLine( c_tris[i * 2], v4Red, c_tris[i * 2 + 1], v4Red ); int numVectorsB = 0; - p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i*2], c_tris[i*2+1], 0.08f, &numVectorsB); - for( int i = 0; i < numVectorsB/3; i++ ) + p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i * 2], c_tris[i * 2 + 1], 0.08f, &numVectorsB ); + for( int i = 0; i < numVectorsB / 3; i++ ) { - m_xLine->AddPickingTriangle( p_tris[i*3], p_tris[i*3+1], p_tris[i*3+2] ); - } - delete [] p_tris; - } - delete [] c_tris; + m_xLine->AddPickingTriangle( p_tris[i * 3], p_tris[i * 3 + 1], p_tris[i * 3 + 2] ); + } + delete[] p_tris; + } + delete[] c_tris; m_xLine->SubmitChanges(); @@ -313,21 +313,21 @@ void Tr2RotationTool::GenLineSets() m_xLine->m_pickEffect = pEffect; // yLine - c_tris = Tr2ManipulationTool::GetCirclePoints(1.0f, 60, &numVectors); + c_tris = Tr2ManipulationTool::GetCirclePoints( 1.0f, 60, &numVectors ); rotateMat = RotationXMatrix( XM_PI / 2.0f ); TransformCoords( c_tris, numVectors, rotateMat ); - for( int i = 0; i < numVectors/2; i++ ) + for( int i = 0; i < numVectors / 2; i++ ) { - m_yLine->AddLine( c_tris[i*2], v4Green, c_tris[i*2+1], v4Green ); + m_yLine->AddLine( c_tris[i * 2], v4Green, c_tris[i * 2 + 1], v4Green ); int numVectorsB = 0; - p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i*2], c_tris[i*2+1], 0.08f, &numVectorsB); - for( int i = 0; i < numVectorsB/3; i++ ) + p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i * 2], c_tris[i * 2 + 1], 0.08f, &numVectorsB ); + for( int i = 0; i < numVectorsB / 3; i++ ) { - m_yLine->AddPickingTriangle( p_tris[i*3], p_tris[i*3+1], p_tris[i*3+2] ); - } - delete [] p_tris; - } - delete [] c_tris; + m_yLine->AddPickingTriangle( p_tris[i * 3], p_tris[i * 3 + 1], p_tris[i * 3 + 2] ); + } + delete[] p_tris; + } + delete[] c_tris; m_yLine->SubmitChanges(); @@ -337,19 +337,19 @@ void Tr2RotationTool::GenLineSets() m_yLine->m_pickEffect = pEffect; // zLine - c_tris = Tr2ManipulationTool::GetCirclePoints(1.0f, 60, &numVectors); - for( int i = 0; i < numVectors/2; i++ ) + c_tris = Tr2ManipulationTool::GetCirclePoints( 1.0f, 60, &numVectors ); + for( int i = 0; i < numVectors / 2; i++ ) { - m_zLine->AddLine( c_tris[i*2], v4Blue, c_tris[i*2+1], v4Blue ); + m_zLine->AddLine( c_tris[i * 2], v4Blue, c_tris[i * 2 + 1], v4Blue ); int numVectorsB = 0; - p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i*2], c_tris[i*2+1], 0.08f, &numVectorsB); - for( int i = 0; i < numVectorsB/3; i++ ) + p_tris = Tr2ManipulationTool::GetTrianglesAroundLine( c_tris[i * 2], c_tris[i * 2 + 1], 0.08f, &numVectorsB ); + for( int i = 0; i < numVectorsB / 3; i++ ) { - m_zLine->AddPickingTriangle( p_tris[i*3], p_tris[i*3+1], p_tris[i*3+2] ); - } - delete [] p_tris; - } - delete [] c_tris; + m_zLine->AddPickingTriangle( p_tris[i * 3], p_tris[i * 3 + 1], p_tris[i * 3 + 2] ); + } + delete[] p_tris; + } + delete[] c_tris; m_zLine->SubmitChanges(); @@ -358,11 +358,11 @@ void Tr2RotationTool::GenLineSets() m_zLine->m_effect = mSPHLineEffect; m_zLine->m_pickEffect = pEffect; - m_primitives.Insert( -1, m_wwLine->GetRawRoot()); - m_primitives.Insert( -1, m_wLine->GetRawRoot()); - m_primitives.Insert( -1, m_xLine->GetRawRoot()); - m_primitives.Insert( -1, m_yLine->GetRawRoot()); - m_primitives.Insert( -1, m_zLine->GetRawRoot()); + m_primitives.Insert( -1, m_wwLine->GetRawRoot() ); + m_primitives.Insert( -1, m_wLine->GetRawRoot() ); + m_primitives.Insert( -1, m_xLine->GetRawRoot() ); + m_primitives.Insert( -1, m_yLine->GetRawRoot() ); + m_primitives.Insert( -1, m_zLine->GetRawRoot() ); } void Tr2RotationTool::Update() @@ -374,7 +374,7 @@ void Tr2RotationTool::Update() temp = rotation * m_localTransform; // Check the move callback for if we should be moving or not - if( OnMoveCallback( m_localTransform, temp )) + if( OnMoveCallback( m_localTransform, temp ) ) { m_localTransform = temp; m_rotation = RotationQuaternion( temp ); @@ -388,8 +388,8 @@ void Tr2RotationTool::Update() m_worldTransform = m_localTransform * translation; for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - (*it)->m_localTransform = m_localTransform; - (*it)->UpdateTransform(); + ( *it )->m_localTransform = m_localTransform; + ( *it )->UpdateTransform(); } } @@ -397,16 +397,15 @@ Vector3 Tr2RotationTool::Hemisphere( int mouseX, int mouseY, Tr2Viewport& viewpo { Matrix viewProj = viewMatrix * projectionMatrix; - auto project = [&]( Vector3 in ) -> Vector2 - { + auto project = [&]( Vector3 in ) -> Vector2 { Vector4 out = Vector4( in.x, in.y, in.z, 1 ) * viewProj; - - return Vector2( viewport.m_x + viewport.m_width * ( 0.5f + 0.5f * out.x / out.w ), - viewport.m_y + viewport.m_height * ( 0.5f - 0.5f * out.y / out.w ) ); + + return Vector2( viewport.m_x + viewport.m_width * ( 0.5f + 0.5f * out.x / out.w ), + viewport.m_y + viewport.m_height * ( 0.5f - 0.5f * out.y / out.w ) ); }; float radius = m_wwLine->m_scale; - + Vector3 center, viewSide; center.x = m_worldTransform._41; center.y = m_worldTransform._42; @@ -417,22 +416,22 @@ Vector3 Tr2RotationTool::Hemisphere( int mouseX, int mouseY, Tr2Viewport& viewpo viewSide.z = viewMatrix._31 * radius; Vector3 side = center - viewSide; - + Vector2 screenCenter = project( center ); - Vector2 screenSide = project( side ); - + Vector2 screenSide = project( side ); + Vector2 dxy = screenCenter - screenSide; - float radius_pixels = sqrtf( dxy.x * dxy.x + dxy.y * dxy.y ) + 16; // add the width of the cursor + float radius_pixels = sqrtf( dxy.x * dxy.x + dxy.y * dxy.y ) + 16; // add the width of the cursor - float px = (mouseX - screenCenter.x) / radius_pixels; - float py = (screenCenter.y - mouseY) / radius_pixels; - float d = sqrt( px*px + py*py ); + float px = ( mouseX - screenCenter.x ) / radius_pixels; + float py = ( screenCenter.y - mouseY ) / radius_pixels; + float d = sqrt( px * px + py * py ); float z = 0.0f; - if( d <= 1.0f ) + if( d <= 1.0f ) { - z = 1.0f - d; - } + z = 1.0f - d; + } Vector3 result( px, py, z ); diff --git a/trinity/Tr2RotationTool.h b/trinity/Tr2RotationTool.h index c4ba3605e..a2f5fa7b5 100644 --- a/trinity/Tr2RotationTool.h +++ b/trinity/Tr2RotationTool.h @@ -7,20 +7,20 @@ BLUE_DECLARE( Tr2LineSet ); -BLUE_CLASS( Tr2RotationTool ): - public Tr2ManipulationTool +BLUE_CLASS( Tr2RotationTool ) : + public Tr2ManipulationTool { public: - EXPOSE_TO_BLUE(); - Tr2RotationTool( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2RotationTool( IRoot* lockobj = NULL ); void GenLineSets(); void Update(); void ResetPrimitiveColors(); - std::vector& GetPrimitivesToRender( ); + std::vector& GetPrimitivesToRender(); void Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); - void GetUnTransformedBaseVectors( Vector3& x, Vector3& y, Vector3& z ); + void GetUnTransformedBaseVectors( Vector3 & x, Vector3 & y, Vector3 & z ); Vector3 Hemisphere( int mouseX, int mouseY, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ) const; - Vector3 GetDesiredPlaneNormal( Vector3& ray, Matrix& viewMatrix ); + Vector3 GetDesiredPlaneNormal( Vector3 & ray, Matrix & viewMatrix ); float m_angle; float m_precision; @@ -30,7 +30,7 @@ BLUE_CLASS( Tr2RotationTool ): Tr2LineSetPtr m_yLine; Tr2LineSetPtr m_zLine; Tr2LineSetPtr m_wLine; - Tr2LineSetPtr m_wwLine; + Tr2LineSetPtr m_wwLine; }; TYPEDEF_BLUECLASS( Tr2RotationTool ); diff --git a/trinity/Tr2RotationTool_Blue.cpp b/trinity/Tr2RotationTool_Blue.cpp index 47491cc75..e7d691cf7 100644 --- a/trinity/Tr2RotationTool_Blue.cpp +++ b/trinity/Tr2RotationTool_Blue.cpp @@ -8,16 +8,10 @@ BLUE_DEFINE( Tr2RotationTool ); const Be::ClassInfo* Tr2RotationTool::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2RotationTool, "" ) - MAP_INTERFACE( Tr2RotationTool ) + EXPOSURE_BEGIN( Tr2RotationTool, "" ) + MAP_INTERFACE( Tr2RotationTool ) MAP_INTERFACE( Tr2ManipulationTool ) - MAP_ATTRIBUTE( "rotation", m_rotation, - "The output rotation value", - Be::READ - ) - MAP_ATTRIBUTE( "precision", m_precision, - "Rotation precision", - Be::READWRITE - ) + MAP_ATTRIBUTE( "rotation", m_rotation, "The output rotation value", Be::READ ) + MAP_ATTRIBUTE( "precision", m_precision, "Rotation precision", Be::READWRITE ) EXPOSURE_CHAINTO( Tr2ManipulationTool ) } diff --git a/trinity/Tr2RuntimeInstanceData.cpp b/trinity/Tr2RuntimeInstanceData.cpp index 26c742d33..fb7ede25f 100644 --- a/trinity/Tr2RuntimeInstanceData.cpp +++ b/trinity/Tr2RuntimeInstanceData.cpp @@ -13,8 +13,8 @@ using namespace Tr2RenderContextEnum; // Description: // Tr2RuntimeInstanceData default constructor // -------------------------------------------------------------------------------------- -Tr2RuntimeInstanceData::Tr2RuntimeInstanceData( IRoot* lockobj ) - :m_count( 0 ), +Tr2RuntimeInstanceData::Tr2RuntimeInstanceData( IRoot* lockobj ) : + m_count( 0 ), m_stride( 0 ), m_vertexDeclaration( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_aabb( Vector3( 0, 0, 0 ), Vector3( 0, 0, 0 ) ), @@ -56,7 +56,7 @@ void Tr2RuntimeInstanceData::SaveToCMF( const char* resPath ) const uint32_t vertexBufferStride = m_stride; uint32_t vertexBufferSize = vertexBufferStride * m_count; - + cmf::Data cmfData; cmfData.meshes = allocator.AllocateSpan( 1 ); @@ -118,7 +118,7 @@ void Tr2RuntimeInstanceData::SaveToGranny( const char* resPath ) const granny_vertex_data* vertexData = CCP_NEW( "Tr2RuntimeInstanceData::SaveToGranny" ) granny_vertex_data; memset( vertexData, 0, sizeof( granny_vertex_data ) ); vertexData->VertexType = definition; - vertexData->VertexComponentNames = CCP_NEW( "Tr2RuntimeInstanceData::SaveToGranny" ) const char*[m_layout.m_items.size()]; + vertexData->VertexComponentNames = CCP_NEW( "Tr2RuntimeInstanceData::SaveToGranny" ) const char * [m_layout.m_items.size()]; for( unsigned i = 0; i < m_layout.m_items.size(); ++i ) { vertexData->VertexComponentNames[i] = definition[i].Name; @@ -143,42 +143,42 @@ void Tr2RuntimeInstanceData::SaveToGranny( const char* resPath ) const topology->Indices16[1] = 0; topology->Indices16[2] = 0; - granny_mesh* mesh = CCP_NEW( "Tr2RuntimeInstanceData::SaveToGranny" ) granny_mesh; + granny_mesh* mesh = CCP_NEW( "Tr2RuntimeInstanceData::SaveToGranny" ) granny_mesh; memset( mesh, 0, sizeof( granny_mesh ) ); mesh->Name = m_name.c_str(); - mesh->PrimaryVertexData = vertexData; - mesh->PrimaryTopology = topology; + mesh->PrimaryVertexData = vertexData; + mesh->PrimaryTopology = topology; - granny_file_info info; + granny_file_info info; memset( &info, 0, sizeof( granny_file_info ) ); - info.MeshCount = 1; - info.Meshes = &mesh; - info.VertexDataCount = 1; - info.VertexDatas = &vertexData; - info.TriTopologyCount = 1; - info.TriTopologies = &topology; + info.MeshCount = 1; + info.Meshes = &mesh; + info.VertexDataCount = 1; + info.VertexDatas = &vertexData; + info.TriTopologyCount = 1; + info.TriTopologies = &topology; granny_file_builder* builder = GrannyBeginFile( - 1, - GrannyCurrentGRNStandardTag, - GrannyGRNFileMV_ThisPlatform, - GrannyGetTemporaryDirectory(), - "prefix2" ); - granny_file_data_tree_writer* writer = GrannyBeginFileDataTreeWriting( GrannyFileInfoType, &info, 0, 0 ); - - GrannyWriteDataTreeToFileBuilder( writer, builder ); - GrannyEndFileDataTreeWriting( writer ); - - GrannyEndFile( builder, CW2A( filename.c_str() ) ); + 1, + GrannyCurrentGRNStandardTag, + GrannyGRNFileMV_ThisPlatform, + GrannyGetTemporaryDirectory(), + "prefix2" ); + granny_file_data_tree_writer* writer = GrannyBeginFileDataTreeWriting( GrannyFileInfoType, &info, 0, 0 ); + + GrannyWriteDataTreeToFileBuilder( writer, builder ); + GrannyEndFileDataTreeWriting( writer ); + + GrannyEndFile( builder, CW2A( filename.c_str() ) ); CCP_DELETE mesh; - CCP_DELETE []topology->Indices16; + CCP_DELETE[] topology->Indices16; CCP_DELETE topology; - CCP_DELETE []vertexData->Vertices; - CCP_DELETE []vertexData->VertexComponentNames; + CCP_DELETE[] vertexData->Vertices; + CCP_DELETE[] vertexData->VertexComponentNames; CCP_DELETE vertexData; - CCP_DELETE []definition; + CCP_DELETE[] definition; } #endif @@ -230,7 +230,7 @@ bool Tr2RuntimeInstanceData::OnPrepareResources() // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2InstanceData interface. Query if instance data is available for +// Implements ITr2InstanceData interface. Query if instance data is available for // rendering. // Return value: // true If instance data is available @@ -250,7 +250,7 @@ ITr2InstanceData::InstanceData Tr2RuntimeInstanceData::GetInstanceData( unsigned // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2InstanceData interface. Returns vertex declaration handle for +// Implements ITr2InstanceData interface. Returns vertex declaration handle for // instance buffer. // Arguments: // bufferIndex - (unused) instance buffer index @@ -282,7 +282,7 @@ Tr2BufferAL* Tr2RuntimeInstanceData::GetGpuBuffer( unsigned bufferIndex ) // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits +// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits // particles on demand. // Arguments: // arguments - (unused) update arguments @@ -293,7 +293,7 @@ void Tr2RuntimeInstanceData::Update( const UpdateArguments& arguments ) // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits +// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits // particles on demand. // Arguments: // arguments - (unused) update arguments @@ -302,15 +302,15 @@ void Tr2RuntimeInstanceData::Update( const UpdateArguments& arguments ) // rateModifier - (unused) emit rate modifier // -------------------------------------------------------------------------------------- void Tr2RuntimeInstanceData::SpawnParticles( const UpdateArguments& arguments, - const Vector3* position, - const Vector3* velocity, + const Vector3* position, + const Vector3* velocity, float rateModifier ) { } // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits +// Implements ITr2GenericEmitter interface. Does nothing as this emitter only emits // particles on demand. // Arguments: // arguments - (unused) update arguments @@ -321,17 +321,17 @@ void Tr2RuntimeInstanceData::SpawnParticles( const UpdateArguments& arguments, // deltaTime - (unused) frame time // -------------------------------------------------------------------------------------- void Tr2RuntimeInstanceData::SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, - const Vector3 *positionEnd, - const Vector3 *velocityStart, - const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ) { } // -------------------------------------------------------------------------------------- // Description: -// Implements ITr2GenericEmitter. Notify the emitter that it's spawn functions are going +// Implements ITr2GenericEmitter. Notify the emitter that it's spawn functions are going // to be called in multi-threaded scenario (during particle system update). Since this // "emitter" does not emit with SpawnParticles methods we don't need to do anything here. // -------------------------------------------------------------------------------------- @@ -377,7 +377,7 @@ void Tr2RuntimeInstanceData::SetLayout( const Tr2VertexDefinition& layout ) // -------------------------------------------------------------------------------------- // Description: -// Returns current vertex layout for instance data. +// Returns current vertex layout for instance data. // Return value: // Current vertex layout // -------------------------------------------------------------------------------------- @@ -388,7 +388,7 @@ const Tr2VertexDefinition& Tr2RuntimeInstanceData::GetLayout() const // -------------------------------------------------------------------------------------- // Description: -// Returns current instance data (read-only). +// Returns current instance data (read-only). // Return value: // Current instance data // -------------------------------------------------------------------------------------- @@ -399,7 +399,7 @@ const void* Tr2RuntimeInstanceData::GetData() const // -------------------------------------------------------------------------------------- // Description: -// Allocates memory for instance data (if passed instance count is different from +// Allocates memory for instance data (if passed instance count is different from // previous one) and returns it. // Arguments: // count - Number of instances @@ -427,7 +427,7 @@ void* Tr2RuntimeInstanceData::GetData( unsigned count ) { return nullptr; } - + return m_data.get(); } @@ -470,8 +470,8 @@ void Tr2RuntimeInstanceData::UpdateBoundingBox() unsigned positionOffset = -1; for( auto it = m_layout.m_items.begin(); it != m_layout.m_items.end(); ++it ) { - if( it->m_usage == Tr2VertexDefinition::POSITION && - it->m_usageIndex == 0 && + if( it->m_usage == Tr2VertexDefinition::POSITION && + it->m_usageIndex == 0 && Tr2VertexDefinition::GetDataTypeSizeInMembers( it->m_dataType ) >= 3 ) { positionOffset = it->m_offset; @@ -483,7 +483,7 @@ void Tr2RuntimeInstanceData::UpdateBoundingBox() { for( unsigned i = 0; i < m_count; ++i ) { - const Vector3* pos = + const Vector3* pos = reinterpret_cast( m_data.get() + positionOffset + m_stride * i ); m_aabb.Include( *pos ); } @@ -559,11 +559,11 @@ void Tr2RuntimeInstanceData::Spawn() { CCP_STATS_ZONE( __FUNCTION__ ); - if( m_particleSystem && m_particleSystem->IsValid() && + if( m_particleSystem && m_particleSystem->IsValid() && !m_layout.m_items.empty() && m_data ) { // Validate geometry vertex declaration against particle system element declaration - const Tr2ParticleElementDataMap &particleElements = m_particleSystem->GetElementDeclaration(); + const Tr2ParticleElementDataMap& particleElements = m_particleSystem->GetElementDeclaration(); std::vector geometryDeclarationMap; for( auto i = particleElements.begin(); i != particleElements.end(); ++i ) { @@ -582,25 +582,25 @@ void Tr2RuntimeInstanceData::Spawn() mapping.buffer = i->second.m_bufferType; mapping.offset = i->second.m_offset; mapping.length = i->second.m_dimension; - - if( item.m_dataType >= m_layout.FLOAT32_1 + int( i->second.m_dimension ) - 1 && + + if( item.m_dataType >= m_layout.FLOAT32_1 + int( i->second.m_dimension ) - 1 && item.m_dataType <= m_layout.FLOAT32_4 ) { mapping.isFloat16 = false; } - else if( ( item.m_dataType == m_layout.FLOAT16_2 && i->second.m_dimension <= 2 ) || + else if( ( item.m_dataType == m_layout.FLOAT16_2 && i->second.m_dimension <= 2 ) || item.m_dataType == m_layout.FLOAT16_4 ) { - CCP_LOGWARN( - "Particle elements \"%s\" has FLOAT16 type in Tr2RuntimeInstanceData \"%s\", this degrades emitter performance", - i->first.GetName().c_str(), + CCP_LOGWARN( + "Particle elements \"%s\" has FLOAT16 type in Tr2RuntimeInstanceData \"%s\", this degrades emitter performance", + i->first.GetName().c_str(), m_name.c_str() ); mapping.isFloat16 = true; } else { - CCP_LOGERR( "Incompatible type for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", - i->first.GetName().c_str(), + CCP_LOGERR( "Incompatible type for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", + i->first.GetName().c_str(), m_name.c_str() ); return; } @@ -611,8 +611,8 @@ void Tr2RuntimeInstanceData::Spawn() } if( !found ) { - CCP_LOGERR( "No data for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", - i->first.GetName().c_str(), + CCP_LOGERR( "No data for particle elements \"%s\" in Tr2RuntimeInstanceData \"%s\"", + i->first.GetName().c_str(), m_name.c_str() ); return; } @@ -631,16 +631,16 @@ void Tr2RuntimeInstanceData::Spawn() { if( j->isFloat16 ) { - std::copy( + std::copy( static_cast( static_cast( data + j->inOffset ) ), static_cast( static_cast( data + j->inOffset ) ) + j->length, particle[j->buffer] + j->offset ); } else { - std::copy( - static_cast( static_cast( data + j->inOffset ) ), - static_cast( static_cast( data + j->inOffset ) ) + j->length, + std::copy( + static_cast( static_cast( data + j->inOffset ) ), + static_cast( static_cast( data + j->inOffset ) ) + j->length, particle[j->buffer] + j->offset ); } } diff --git a/trinity/Tr2RuntimeInstanceData.h b/trinity/Tr2RuntimeInstanceData.h index 6cc35b3d2..30e847f93 100644 --- a/trinity/Tr2RuntimeInstanceData.h +++ b/trinity/Tr2RuntimeInstanceData.h @@ -20,7 +20,7 @@ BLUE_DECLARE( Tr2ParticleSystem ); // See Also: // Tr2InstancedMesh // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2RuntimeInstanceData ): +BLUE_CLASS( Tr2RuntimeInstanceData ) : public ITr2InstanceData, public ITr2GenericEmitter, public Tr2DeviceResource, @@ -35,10 +35,11 @@ BLUE_CLASS( Tr2RuntimeInstanceData ): ////////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); -public: +public: ///////////////////////////////////////////////////////////////////////////////////// // ITr2InstanceData bool IsInstanceDataReady() const override; @@ -53,17 +54,17 @@ BLUE_CLASS( Tr2RuntimeInstanceData ): ///////////////////////////////////////////////////////////////////////////////////// // ITr2GenericEmitter void Update( const UpdateArguments& arguments ); - void SpawnParticles( + void SpawnParticles( const UpdateArguments& arguments, - const Vector3* position = nullptr, - const Vector3* velocity = nullptr, + const Vector3* position = nullptr, + const Vector3* velocity = nullptr, float rateModifier = 1.0f ); - void SpawnParticles( + void SpawnParticles( const UpdateArguments& arguments, - const Vector3 *positionStart, - const Vector3 *positionEnd, - const Vector3 *velocityStart, - const Vector3 *velocityEnd, + const Vector3* positionStart, + const Vector3* positionEnd, + const Vector3* velocityStart, + const Vector3* velocityEnd, float deltaTime ); void SetThreadSafeFlag(); @@ -74,11 +75,12 @@ BLUE_CLASS( Tr2RuntimeInstanceData ): void* GetData( unsigned count ); void UpdateData(); void UpdateBoundingBox(); - bool GetBoundingBox( Vector3& minAabb, Vector3& maxAabb ) const; + bool GetBoundingBox( Vector3 & minAabb, Vector3 & maxAabb ) const; void SetBoundingBox( const CcpMath::AxisAlignedBox& aabb ); void DestroyData(); unsigned GetStride() const; void Spawn(); + private: void CreateDeclaration(); diff --git a/trinity/Tr2RuntimeInstanceData_Blue.cpp b/trinity/Tr2RuntimeInstanceData_Blue.cpp index bc43c9c77..6a9bf86da 100644 --- a/trinity/Tr2RuntimeInstanceData_Blue.cpp +++ b/trinity/Tr2RuntimeInstanceData_Blue.cpp @@ -13,7 +13,7 @@ static PyObject* PySetElementLayout( PyObject* self, PyObject* args ) Tr2RuntimeInstanceData* pThis = BluePythonCast( self ); PyObject* pyDecl; - if ( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pyDecl ) ) + if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pyDecl ) ) { return nullptr; } @@ -63,8 +63,8 @@ static PyObject* PySetElementLayout( PyObject* self, PyObject* args ) PyErr_SetString( PyExc_TypeError, "Invalid element type" ); return nullptr; } - - def.Add( + + def.Add( Tr2VertexDefinition::DataType( Tr2VertexDefinition::DT_FLOAT32 | ( ( type - 1 ) << Tr2VertexDefinition::DT_SIZE_OFFSET ) ), Tr2ParticleElementDeclarationName( Tr2ParticleElementDeclarationName::Type( usage ) ).GetD3DUsage(), usageIndex ); @@ -79,7 +79,7 @@ static PyObject* PySetData( PyObject* self, PyObject* args ) Tr2RuntimeInstanceData* pThis = BluePythonCast( self ); PyObject* pyData; - if ( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pyData ) ) + if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &pyData ) ) { return nullptr; } @@ -153,7 +153,7 @@ static PyObject* PyGetItem( PyObject* self, PyObject* args ) Tr2RuntimeInstanceData* pThis = BluePythonCast( self ); unsigned index; - if ( !PyArg_ParseTuple( args, "I", &index ) ) + if( !PyArg_ParseTuple( args, "I", &index ) ) { return nullptr; } @@ -201,7 +201,7 @@ static PyObject* PySetItem( PyObject* self, PyObject* args ) unsigned index; PyObject* item; - if ( !PyArg_ParseTuple( args, "IO!", &index, &PyTuple_Type, &item ) ) + if( !PyArg_ParseTuple( args, "IO!", &index, &PyTuple_Type, &item ) ) { return nullptr; } @@ -279,7 +279,7 @@ static PyObject* PyGetItemElement( PyObject* self, PyObject* args ) Tr2RuntimeInstanceData* pThis = BluePythonCast( self ); unsigned index, elementIndex; - if ( !PyArg_ParseTuple( args, "II", &index, &elementIndex ) ) + if( !PyArg_ParseTuple( args, "II", &index, &elementIndex ) ) { return nullptr; } @@ -328,7 +328,7 @@ static PyObject* PySetItemElement( PyObject* self, PyObject* args ) unsigned index; unsigned elementIndex; PyObject* element; - if ( !PyArg_ParseTuple( args, "IIO", &index, &elementIndex, &element ) ) + if( !PyArg_ParseTuple( args, "IIO", &index, &elementIndex, &element ) ) { return nullptr; } @@ -398,69 +398,56 @@ static PyObject* PySetItemElement( PyObject* self, PyObject* args ) const Be::ClassInfo* Tr2RuntimeInstanceData::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2RuntimeInstanceData, "" ) + EXPOSURE_BEGIN( Tr2RuntimeInstanceData, "" ) MAP_INTERFACE( Tr2RuntimeInstanceData ) MAP_INTERFACE( ITr2InstanceData ) MAP_INTERFACE( ITr2GenericEmitter ) MAP_INTERFACE( ITr2GpuBuffer ) - MAP_ATTRIBUTE - ( - "name", - m_name, - "", - Be::READWRITE | Be::PERSIST - ) - - MAP_ATTRIBUTE - ( - "particleSystem", - m_particleSystem, - "", - Be::READWRITE | Be::PERSIST - ) - - MAP_PROPERTY_READONLY - ( + MAP_ATTRIBUTE( + "name", + m_name, + "", + Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( + "particleSystem", + m_particleSystem, + "", + Be::READWRITE | Be::PERSIST ) + + MAP_PROPERTY_READONLY( "count", - GetCount, - "Number of instances" - ) + GetCount, + "Number of instances" ) - MAP_METHOD - ( + MAP_METHOD( "SetElementLayout", PySetElementLayout, "Assign instance element data layout. Invalidates data for the object.\n" ":param layout: list of 3-tuples (usage - trinity.PARTICLE_ELEMENT_TYPE, usageIndex, elementCount)\n" " describing each data element\n" ":type layout: list[(int, int, int)]\n" - ":rtype: None" - ) + ":rtype: None" ) - MAP_METHOD - ( + MAP_METHOD( "SetData", PySetData, "Assign instance data.\n" ":param data: list of tuples; each list element describes one instance; each tuple element describes\n" " one element according to SetElementLayout and is either a float an n-tuple of floats\n" ":type data: list\n" - ":rtype: None" - ) + ":rtype: None" ) - MAP_METHOD - ( + MAP_METHOD( "GetItem", PyGetItem, "Returns instance data for given instance index.\n" ":param idx: instance index\n" ":type idx: int\n" - ":rtype: tuple" - ) + ":rtype: tuple" ) - MAP_METHOD - ( + MAP_METHOD( "SetItem", PySetItem, "Set instance data for given instance index.\n" @@ -468,11 +455,9 @@ const Be::ClassInfo* Tr2RuntimeInstanceData::ExposeToBlue() ":type idx: int\n" ":param data: a tuple that describes one instance; each tuple element describes\n" " one element according to SetElementLayout and is either a float an n-tuple of floats\n" - ":rtype: None" - ) + ":rtype: None" ) - MAP_METHOD - ( + MAP_METHOD( "GetItemElement", PyGetItemElement, "Returns one element of instance data for given instance index.\n" @@ -480,11 +465,9 @@ const Be::ClassInfo* Tr2RuntimeInstanceData::ExposeToBlue() ":type idx: int\n" ":param elementIndex: data element index\n" ":type elementIndex: int\n" - ":rtype: float | tuple" - ) + ":rtype: float | tuple" ) - MAP_METHOD - ( + MAP_METHOD( "SetItemElement", PySetItemElement, "Set one element of instance data for given instance index.\n" @@ -494,53 +477,41 @@ const Be::ClassInfo* Tr2RuntimeInstanceData::ExposeToBlue() ":type elementIndex: int\n" ":param data: a tuple or float that describes one element of instance data\n" ":type data: float | tuple\n" - ":rtype: None" - ) + ":rtype: None" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "UpdateData", UpdateData, - "Uploads modified data to GPU" - ) + "Uploads modified data to GPU" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "UpdateBoundingBox", UpdateBoundingBox, - "Updates bounding box after instance data was modified" - ) + "Updates bounding box after instance data was modified" ) MAP_METHOD_AND_WRAP( "SetBoundingBox", SetBoundingBox, "Assign a bounding box explicitely (in case instance data contains no positions, for example)\n" - ":param box: axis aligned bounding box for instance data" - ) + ":param box: axis aligned bounding box for instance data" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Spawn", Spawn, - "Spawns particles into the particle system" - ) - - MAP_METHOD_AND_WRAP - ( + "Spawns particles into the particle system" ) + + MAP_METHOD_AND_WRAP( "SaveToCMF", SaveToCMF, "Saves vertex data to a CMF file\n" - ":param path: path to the CMF file" - ) + ":param path: path to the CMF file" ) // TODO: intern, call SaveToCMF instead of SaveToGranny in python. #if WITH_GRANNY - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SaveToGranny", SaveToGranny, "Saves vertex data to a granny file\n" - ":param path: path to the granny file" - ) + ":param path: path to the granny file" ) #endif MAP_ATTRIBUTE( "aabbMin", m_aabb.m_min, "Minimum of the AABB", Be::READ ) diff --git a/trinity/Tr2SSAO.cpp b/trinity/Tr2SSAO.cpp index 049003494..10fd04d75 100644 --- a/trinity/Tr2SSAO.cpp +++ b/trinity/Tr2SSAO.cpp @@ -48,7 +48,7 @@ FFX_CACAO_Settings GetSettings( bool useDownsampledSSAO, bool generateNormals, S { unsigned settingsIndex = static_cast( quality ) + useDownsampledSSAO * ( static_cast( SSAOQuality::LOWEST ) + 1 ); FFX_CACAO_Settings settings = FFX_CACAO_PRESETS[settingsIndex].settings; - + settings.generateNormals = generateNormals; // Set fade out to something large to disable it @@ -93,7 +93,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::Filter( const Tr2TextureAL& depthBuffer, co if( m_cortaoEnabled ) { //Lazily initialize CORTAO, as EVE currently doesn't use it, so it doesn't have the shaders/lookup table for it. - if (!m_cortaoInitialized) + if( !m_cortaoInitialized ) { m_cortaoEffect.CreateInstance(); m_cortaoEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/System/CORTAO/CORTAO.fx" ); @@ -114,8 +114,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::Filter( const Tr2TextureAL& depthBuffer, co GPU_REGION( renderContext, "CORTAO" ); return ComputeCORTAO( depthBuffer, normalBuffer, gpuResourcePool, renderContext, temporal ); - - } + } else { GPU_REGION( renderContext, "CACAO" ); @@ -148,17 +147,41 @@ Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2T { XMFLOAT4X4 p; XMMATRIX xProj = Tr2Renderer::GetReversedDepthProjectionTransform(); - XMStoreFloat4x4(&p, xProj); - proj.elements[0][0] = p._11; proj.elements[0][1] = p._12; proj.elements[0][2] = p._13; proj.elements[0][3] = p._14; - proj.elements[1][0] = p._21; proj.elements[1][1] = p._22; proj.elements[1][2] = p._23; proj.elements[1][3] = p._24; - proj.elements[2][0] = p._31; proj.elements[2][1] = p._32; proj.elements[2][2] = p._33; proj.elements[2][3] = p._34; - proj.elements[3][0] = p._41; proj.elements[3][1] = p._42; proj.elements[3][2] = p._43; proj.elements[3][3] = p._44; - XMMATRIX xNormalsWorldToView = XMMATRIX(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1) * Tr2Renderer::GetInverseViewTransform(); // should be transpose(inverse(view)), but XMM is row-major and HLSL is column-major - XMStoreFloat4x4(&p, xNormalsWorldToView); - normalsWorldToView.elements[0][0] = p._11; normalsWorldToView.elements[0][1] = p._12; normalsWorldToView.elements[0][2] = p._13; normalsWorldToView.elements[0][3] = p._14; - normalsWorldToView.elements[1][0] = p._21; normalsWorldToView.elements[1][1] = p._22; normalsWorldToView.elements[1][2] = p._23; normalsWorldToView.elements[1][3] = p._24; - normalsWorldToView.elements[2][0] = p._31; normalsWorldToView.elements[2][1] = p._32; normalsWorldToView.elements[2][2] = p._33; normalsWorldToView.elements[2][3] = p._34; - normalsWorldToView.elements[3][0] = p._41; normalsWorldToView.elements[3][1] = p._42; normalsWorldToView.elements[3][2] = p._43; normalsWorldToView.elements[3][3] = p._44; + XMStoreFloat4x4( &p, xProj ); + proj.elements[0][0] = p._11; + proj.elements[0][1] = p._12; + proj.elements[0][2] = p._13; + proj.elements[0][3] = p._14; + proj.elements[1][0] = p._21; + proj.elements[1][1] = p._22; + proj.elements[1][2] = p._23; + proj.elements[1][3] = p._24; + proj.elements[2][0] = p._31; + proj.elements[2][1] = p._32; + proj.elements[2][2] = p._33; + proj.elements[2][3] = p._34; + proj.elements[3][0] = p._41; + proj.elements[3][1] = p._42; + proj.elements[3][2] = p._43; + proj.elements[3][3] = p._44; + XMMATRIX xNormalsWorldToView = XMMATRIX( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 ) * Tr2Renderer::GetInverseViewTransform(); // should be transpose(inverse(view)), but XMM is row-major and HLSL is column-major + XMStoreFloat4x4( &p, xNormalsWorldToView ); + normalsWorldToView.elements[0][0] = p._11; + normalsWorldToView.elements[0][1] = p._12; + normalsWorldToView.elements[0][2] = p._13; + normalsWorldToView.elements[0][3] = p._14; + normalsWorldToView.elements[1][0] = p._21; + normalsWorldToView.elements[1][1] = p._22; + normalsWorldToView.elements[1][2] = p._23; + normalsWorldToView.elements[1][3] = p._24; + normalsWorldToView.elements[2][0] = p._31; + normalsWorldToView.elements[2][1] = p._32; + normalsWorldToView.elements[2][2] = p._33; + normalsWorldToView.elements[2][3] = p._34; + normalsWorldToView.elements[3][0] = p._41; + normalsWorldToView.elements[3][1] = p._42; + normalsWorldToView.elements[3][2] = p._43; + normalsWorldToView.elements[3][3] = p._44; } proj.elements[3][2] /= layer.zoomLevel; @@ -175,25 +198,25 @@ Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2T settings.sharpness = layer.settings.sharpness; settings.detailShadowStrength = layer.settings.detailShadowStrength; - auto GetTempTexture = [&gpuResourcePool]( auto name, auto dim, auto usage ) { + auto GetTempTexture = [&gpuResourcePool]( auto name, auto dim, auto usage ) { #if __APPLE__ - return gpuResourcePool.GetPersistentTexture( name, dim, usage, []( auto& tex, auto& rc ) {} ); + return gpuResourcePool.GetPersistentTexture( name, dim, usage, []( auto& tex, auto& rc ) {} ); #else - return gpuResourcePool.GetTempTexture( name, dim, usage ); + return gpuResourcePool.GetTempTexture( name, dim, usage ); #endif - }; + }; auto deinterleavedDepthTarget = GetTempTexture( - "ssao_deinterleaved_depth", - Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R32_FLOAT, size.deinterleavedDepthBufferWidth, size.deinterleavedDepthBufferHeight, 1, settings.qualityLevel >= FFX_CACAO_QUALITY_MEDIUM ? 4 : 1, SSAO_PASS_COUNT ), + "ssao_deinterleaved_depth", + Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R32_FLOAT, size.deinterleavedDepthBufferWidth, size.deinterleavedDepthBufferHeight, 1, settings.qualityLevel >= FFX_CACAO_QUALITY_MEDIUM ? 4 : 1, SSAO_PASS_COUNT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE ); auto deinterleavedNormalTarget = GetTempTexture( - "ssao_deinterleaved_normal", - Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R8G8B8A8_SNORM, size.deinterleavedDepthBufferWidth, size.deinterleavedDepthBufferHeight, 1, 1, SSAO_PASS_COUNT ), + "ssao_deinterleaved_normal", + Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R8G8B8A8_SNORM, size.deinterleavedDepthBufferWidth, size.deinterleavedDepthBufferHeight, 1, 1, SSAO_PASS_COUNT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE ); auto ssaoWorkerTargetA = GetTempTexture( "ssao_worker_a", - Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R8G8_UNORM, size.ssaoBufferWidth, size.ssaoBufferHeight, 1, 1, SSAO_PASS_COUNT ), + Tr2BitmapDimensions( TEX_TYPE_2D, PIXEL_FORMAT_R8G8_UNORM, size.ssaoBufferWidth, size.ssaoBufferHeight, 1, 1, SSAO_PASS_COUNT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE ); auto ssaoWorkerTargetB = GetTempTexture( "ssao_worker_b", @@ -221,9 +244,9 @@ Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2T Tr2GpuResourcePool::Buffer loadCounterBuffer; if( m_detail.quality == SSAOQuality::HIGHEST ) { - loadCounterBuffer = gpuResourcePool.GetTempBuffer( - "ssao_load_counter", - Tr2BufferDescriptionAL(PIXEL_FORMAT_R32_UINT, 1, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE ) ); + loadCounterBuffer = gpuResourcePool.GetTempBuffer( + "ssao_load_counter", + Tr2BufferDescriptionAL( PIXEL_FORMAT_R32_UINT, 1, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE ) ); } layer.effect->SetParameter( BlueSharedString( "g_DepthIn" ), depthBuffer ); @@ -297,7 +320,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2T CR_RETURN_VAL( ApplyConstBuffer( SSAO_PASS_COUNT, renderContext ), {} ); - if( settings.qualityLevel == FFX_CACAO_QUALITY_LOWEST) + if( settings.qualityLevel == FFX_CACAO_QUALITY_LOWEST ) { std::string shader = layer.downsampled ? "PrepareDownsampledDepthsHalf" : "PrepareNativeDepthsHalf"; @@ -403,8 +426,8 @@ Tr2GpuResourcePool::Texture Tr2SSAO::PerformPass( const Layer& layer, const Tr2T if( settings.blurPassCount ) { GPU_REGION( renderContext, "Edge sensitive blur" ); - - unsigned dimX = DispatchSize( 4 * FFX_CACAO_BLUR_WIDTH - 2 * settings.blurPassCount, size.ssaoBufferWidth ); + + unsigned dimX = DispatchSize( 4 * FFX_CACAO_BLUR_WIDTH - 2 * settings.blurPassCount, size.ssaoBufferWidth ); unsigned dimY = DispatchSize( 3 * FFX_CACAO_BLUR_HEIGHT - 2 * settings.blurPassCount, size.ssaoBufferHeight ); for( unsigned i = 0; i < SSAO_PASS_COUNT; i++ ) @@ -518,7 +541,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf { uint32_t width = depthBuffer.GetWidth(); uint32_t height = depthBuffer.GetHeight(); - + Tr2GpuResourcePool::Texture packedBuffer; { uint32_t mipLevels = 1; @@ -547,38 +570,36 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf Matrix viewMatrix = Tr2Renderer::GetViewTransform(); Matrix projectionMatrix = Tr2Renderer::GetProjectionTransform(); - Matrix inverseProjectionMatrix = Inverse( projectionMatrix ); + Matrix inverseProjectionMatrix = Inverse( projectionMatrix ); float nearPlane = Tr2Renderer::GetBackClip(); float farPlane = Tr2Renderer::GetFrontClip(); data->resolution = Vector4( (float)width, (float)height, 1.0f / (float)width, 1.0f / (float)height ); - + data->projectionParams = Vector4( +0.5f * projectionMatrix._11, -0.5f * projectionMatrix._22, -0.5f + projectionMatrix._31 * +0.5f, - -0.5f + projectionMatrix._32 * -0.5f - ); + -0.5f + projectionMatrix._32 * -0.5f ); data->unprojectParams = Vector4( +2.0f * inverseProjectionMatrix._11, -2.0f * inverseProjectionMatrix._22, -inverseProjectionMatrix._11 + inverseProjectionMatrix._41, - +inverseProjectionMatrix._22 - inverseProjectionMatrix._42 - ); - + +inverseProjectionMatrix._22 - inverseProjectionMatrix._42 ); + data->depthParams = Vector2( ( nearPlane - farPlane ) / ( nearPlane * farPlane ), 1.0f / nearPlane ); - + data->radius = m_cortaoRadius; data->normalBias = inverseProjectionMatrix._11 * sqrtf( 2.0f ) / width; - float maxApparentCircleRadius = m_cortaoMaxBlockerSearchRadius * 2.0f * fminf( inverseProjectionMatrix._11, inverseProjectionMatrix._22 ); + float maxApparentCircleRadius = m_cortaoMaxBlockerSearchRadius * 2.0f * fminf( inverseProjectionMatrix._11, inverseProjectionMatrix._22 ); data->maxApparentCircleRadiusCoefficient = maxApparentCircleRadius / sqrtf( maxApparentCircleRadius * maxApparentCircleRadius + 1.0f ); - float circleBias = log2f( projectionMatrix._11 * width * 0.5f ); + float circleBias = log2f( projectionMatrix._11 * width * 0.5f ); data->mipBias = m_cortaoMipBias + circleBias; data->radiusMultiplier = m_cortaoStrength; data->lookupOccluderRadiusScale = 1.0f; @@ -607,7 +628,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf normalMatrix._43 = 0.0f; //bias matrix to convert from [0, 1] to [-1, +1] - Matrix biasMatrix = ScalingMatrix( 2.0f, 2.0f, 2.0f ) * TranslationMatrix( -1.0f, -1.0f, -1.0f ); + Matrix biasMatrix = ScalingMatrix( 2.0f, 2.0f, 2.0f ) * TranslationMatrix( -1.0f, -1.0f, -1.0f ); data->normalMatrix = Transpose( biasMatrix * normalMatrix ); @@ -622,7 +643,7 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf PixelFormat outputFormat = m_cortaoBentNormal ? PixelFormat::PIXEL_FORMAT_R8G8B8A8_SNORM : PixelFormat::PIXEL_FORMAT_R8_UNORM; auto outputTarget = gpuResourcePool.GetTempTexture( "cortao_output", width, height, outputFormat, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE ); - + const char* const SAMPLE_COUNTS[] = { "SAMPLE_COUNT_16", "SAMPLE_COUNT_12", @@ -632,14 +653,14 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf }; m_cortaoEffect->SetOption( BlueSharedString( "SAMPLE_COUNT" ), BlueSharedString( SAMPLE_COUNTS[static_cast( m_detail.quality )] ) ); m_cortaoEffect->SetOption( BlueSharedString( "BENT_NORMAL" ), BlueSharedString( m_cortaoBentNormal ? "BENT_NORMAL_ENABLED" : "BENT_NORMAL_DISABLED" ) ); - + m_cortaoEffect->SetParameter( BlueSharedString( "NormalBuffer" ), normalBuffer ); m_cortaoEffect->SetParameter( BlueSharedString( "DepthBuffer" ), depthBuffer ); //Set all mip levels to ensure no warnings produced by unset resources. for( uint32_t i = 0; i < 8; i++ ) { - std::string parameterName = std::string("PackedOutputBuffer") + std::to_string( i ); + std::string parameterName = std::string( "PackedOutputBuffer" ) + std::to_string( i ); m_cortaoEffect->SetParameter( BlueSharedString( parameterName.c_str() ), packedBuffer, std::min( i, packedBuffer->GetMipCount() - 1 ) ); } @@ -688,8 +709,6 @@ Tr2GpuResourcePool::Texture Tr2SSAO::ComputeCORTAO( const Tr2TextureAL& depthBuf Tr2Renderer::RunComputeShader( m_cortaoBlurEffect, BlueSharedString( "Blur" ), ( width + blurWorkGroupSize - 1 ) / blurWorkGroupSize, ( height + blurWorkGroupSize - 1 ) / blurWorkGroupSize, 1, renderContext ); } } - - } return outputTarget; } diff --git a/trinity/Tr2SSAO.h b/trinity/Tr2SSAO.h index 1438fb905..94f2fb3a1 100644 --- a/trinity/Tr2SSAO.h +++ b/trinity/Tr2SSAO.h @@ -41,7 +41,7 @@ BLUE_CLASS( Tr2SSAO ) : SSAOQuality quality; bool downsampled; float zoomLevel; - + FFX_CACAO_Settings settings; Tr2EffectPtr effect; }; @@ -95,7 +95,7 @@ BLUE_CLASS( Tr2SSAO ) : bool m_cortaoEnabled; bool m_cortaoBentNormal; - + bool m_cortaoInitialized; Tr2EffectPtr m_cortaoEffect; Tr2EffectPtr m_cortaoBlurEffect; @@ -112,10 +112,9 @@ BLUE_CLASS( Tr2SSAO ) : uint32_t m_cortaoRandSeeds[4]; - uint32_t Hash(uint32_t n); + uint32_t Hash( uint32_t n ); Tr2GpuResourcePool::Texture ComputeCORTAO( const Tr2TextureAL& depthBuffer, const Tr2TextureAL& normalBuffer, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, bool temporal ); - }; TYPEDEF_BLUECLASS( Tr2SSAO ); diff --git a/trinity/Tr2SSAO_Blue.cpp b/trinity/Tr2SSAO_Blue.cpp index 5463ea8d2..553871ef4 100644 --- a/trinity/Tr2SSAO_Blue.cpp +++ b/trinity/Tr2SSAO_Blue.cpp @@ -6,10 +6,10 @@ BLUE_DEFINE( Tr2SSAO ); const Be::VarChooser SSAOQualityChooser[] = { - { "Lowest", BeCast( SSAOQuality::LOWEST ), "Lowest quality" }, - { "Low", BeCast( SSAOQuality::LOW ), "Low quality" }, - { "Medium", BeCast( SSAOQuality::MEDIUM ), "Medium quality" }, - { "High", BeCast( SSAOQuality::HIGH ), "High quality" }, + { "Lowest", BeCast( SSAOQuality::LOWEST ), "Lowest quality" }, + { "Low", BeCast( SSAOQuality::LOW ), "Low quality" }, + { "Medium", BeCast( SSAOQuality::MEDIUM ), "Medium quality" }, + { "High", BeCast( SSAOQuality::HIGH ), "High quality" }, { "Highest", BeCast( SSAOQuality::HIGHEST ), "Highest (adaptive) quality" }, {} }; diff --git a/trinity/Tr2SSSSS.cpp b/trinity/Tr2SSSSS.cpp index 9b448430d..23879a066 100644 --- a/trinity/Tr2SSSSS.cpp +++ b/trinity/Tr2SSSSS.cpp @@ -18,27 +18,27 @@ using namespace Tr2RenderContextEnum; namespace { - Vector3 gaussian( float variance, float r ) - { - /** +Vector3 gaussian( float variance, float r ) +{ + /** * We use a falloff to modulate the shape of the profile. Big falloffs * spreads the shape making it wider, while small falloffs make it * narrower. */ - Vector3 falloff = Vector3( 1.0f, 0.37f, 0.3f ); + Vector3 falloff = Vector3( 1.0f, 0.37f, 0.3f ); - Vector3 g; - for( int i = 0; i < 3; i++ ) - { - float rr = r / ( 0.001f + falloff[i] ); - g[i] = exp( ( -( rr * rr ) ) / ( 2.0f * variance ) ) / ( 2.0f * 3.14f * variance ); - } - return g; + Vector3 g; + for( int i = 0; i < 3; i++ ) + { + float rr = r / ( 0.001f + falloff[i] ); + g[i] = exp( ( -( rr * rr ) ) / ( 2.0f * variance ) ) / ( 2.0f * 3.14f * variance ); } + return g; +} - Vector3 profile( float r ) - { - /** +Vector3 profile( float r ) +{ + /** * We used the red channel of the original skin profile defined in * [d'Eon07] for all three channels. We noticed it can be used for green * and blue channels (scaled using the falloff parameter) without @@ -46,22 +46,21 @@ namespace * the profile. For example, it allows to create blue SSS gradients, which * could be useful in case of rendering blue creatures. */ - return // 0.233f * gaussian(0.0064f, r) + /* We consider this one to be directly bounced light, accounted by the strength parameter (see @STRENGTH) */ - gaussian( 0.0484f, r ) * 0.100f + - gaussian( 0.187f, r ) * 0.118f + - gaussian( 0.567f, r ) * 0.113f + - gaussian( 1.99f, r ) * 0.358f + - gaussian( 7.41f, r ) * 0.078f; - } + return // 0.233f * gaussian(0.0064f, r) + /* We consider this one to be directly bounced light, accounted by the strength parameter (see @STRENGTH) */ + gaussian( 0.0484f, r ) * 0.100f + + gaussian( 0.187f, r ) * 0.118f + + gaussian( 0.567f, r ) * 0.113f + + gaussian( 1.99f, r ) * 0.358f + + gaussian( 7.41f, r ) * 0.078f; +} } -Tr2SSSSS::Tr2SSSSS( IRoot* lockobj ) : +Tr2SSSSS::Tr2SSSSS( IRoot* lockobj ) : m_enabled( true ), m_hasSSSSSInScene( true ), m_subSurfaceScatteringWidth( 0.1277f ), m_subSurfaceFrontScatterColor( Color( 1, 1, 1, 1 ) ) { - } void Tr2SSSSS::SetupScreenSpaceSubSurfaceScattering( Tr2RenderContext& renderContext, ITriRenderBatchAccumulator* batches, const Tr2TextureAL& colorMap, const Tr2TextureAL& opaqueColorMap, const Tr2TextureAL& depthMap, Tr2GpuResourcePool& gpuResourcePool ) @@ -231,7 +230,7 @@ void Tr2SSSSS::UpdateSubSurfaceFrontScatterData( Tr2RenderContext& renderContext // Calculate the sum of the weights, we will need to normalize them below Vector3 sum = Vector3( 0.0f, 0.0f, 0.0f ); - for (int i = 0; i < nSamples; i++) + for( int i = 0; i < nSamples; i++ ) { sum += Vector3( kernel[i].x, kernel[i].y, kernel[i].z ); } diff --git a/trinity/Tr2SSSSS.h b/trinity/Tr2SSSSS.h index ffe79b26e..5a2bbfdb3 100644 --- a/trinity/Tr2SSSSS.h +++ b/trinity/Tr2SSSSS.h @@ -33,7 +33,6 @@ BLUE_CLASS( Tr2SSSSS ) : void UpdateSubSurfaceFrontScatterData( Tr2RenderContext & renderContext ); private: - bool m_enabled; bool m_hasSSSSSInScene; diff --git a/trinity/Tr2SSSSS_Blue.cpp b/trinity/Tr2SSSSS_Blue.cpp index 606eecbd3..9b3ccf6c1 100644 --- a/trinity/Tr2SSSSS_Blue.cpp +++ b/trinity/Tr2SSSSS_Blue.cpp @@ -12,12 +12,16 @@ const Be::ClassInfo* Tr2SSSSS::ExposeToBlue() MAP_ATTRIBUTE( "enabled", m_enabled, "Test setting\n:jessica-group: Settings", Be::READWRITE ) - - MAP_ATTRIBUTE( "subSurfaceScatteringWidth", m_subSurfaceScatteringWidth, "How wide of a sample radius for the sub surface blur\n" ":jessica-group: Settings",Be::READWRITE ) - MAP_ATTRIBUTE( "subSurfaceFrontScatterColor", m_subSurfaceFrontScatterColor, "Defines what the scene level sub surface front scatter color should be\n" ":jessica-group: Settings", Be::READWRITE | Be::PERSIST ) + + MAP_ATTRIBUTE( "subSurfaceScatteringWidth", m_subSurfaceScatteringWidth, "How wide of a sample radius for the sub surface blur\n" + ":jessica-group: Settings", + Be::READWRITE ) + MAP_ATTRIBUTE( "subSurfaceFrontScatterColor", m_subSurfaceFrontScatterColor, "Defines what the scene level sub surface front scatter color should be\n" + ":jessica-group: Settings", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "hasSSSSSInScene", m_hasSSSSSInScene, "Shows if a SSSSS object is in the scene", Be::READ ) - + EXPOSURE_END() } diff --git a/trinity/Tr2ScalingTool.cpp b/trinity/Tr2ScalingTool.cpp index a5ecc889d..e81cf6c3d 100644 --- a/trinity/Tr2ScalingTool.cpp +++ b/trinity/Tr2ScalingTool.cpp @@ -16,7 +16,7 @@ Vector3 TransformPoint( const Vector3& localCenter, Tr2SolidSet* solid, Matrix& { XMVECTOR det; Matrix viewInv( XMMatrixInverse( &det, viewMatrix ) ); - + Vector3 viewPos = viewInv.GetTranslation(); Vector3 lineSetPos = Vector3( solid->m_localTransform._41, solid->m_localTransform._42, solid->m_localTransform._43 ); Vector3 normal = Vector3( viewMatrix._13, viewMatrix._23, viewMatrix._33 ); @@ -32,16 +32,15 @@ Vector3 TransformPoint( const Vector3& localCenter, Tr2SolidSet* solid, Matrix& } -Tr2ScalingTool::Tr2ScalingTool( IRoot* lockobj ) - :m_initialLength( 1.0f ), +Tr2ScalingTool::Tr2ScalingTool( IRoot* lockobj ) : + m_initialLength( 1.0f ), m_scale( 1.0f, 1.0f, 1.0f ), m_initialScale( 1.0f, 1.0f, 1.0f ) { GenLineSets(); - SelectAxis("w"); - - Init(m_localTransform); + SelectAxis( "w" ); + Init( m_localTransform ); } void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ) @@ -55,12 +54,12 @@ void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDe pos.y = m_localTransform._42; pos.z = m_localTransform._43; - + if( m_initialLength < 0.0 ) { - Vector3 vecResult; - Vector3 vecCenterOfMass = TransformPoint( Vector3( 1, 0, 0 ), m_xBox, viewMatrix ); - float tmpInitialLength = Length( pos - vecCenterOfMass ); + Vector3 vecResult; + Vector3 vecCenterOfMass = TransformPoint( Vector3( 1, 0, 0 ), m_xBox, viewMatrix ); + float tmpInitialLength = Length( pos - vecCenterOfMass ); // the initiallength could not have been set up... m_initialLength = tmpInitialLength; } @@ -73,15 +72,15 @@ void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDe GetBaseVectors( xAxis, yAxis, zAxis ); // Get the location of the tool on screen - PointToScreenCoordinates(pos, screenPos, viewport, viewMatrix, projectionMatrix ); + PointToScreenCoordinates( pos, screenPos, viewport, viewMatrix, projectionMatrix ); int curMouseX = int( screenPos.x ); int curMouseY = int( screenPos.y ); // Get the pick ray from the tools screen location - ScreenCoordinatesToRay(curMouseX, curMouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); + ScreenCoordinatesToRay( curMouseX, curMouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); // Get the normal for the best plane to use normal = GetDesiredPlaneNormal( ray, viewMatrix ); - Vector3 delta = MovePointOnPlane(curMouseX, curMouseY, curMouseX+mouseXDelta, curMouseY+mouseYDelta, pos, normal, viewport, viewMatrix, projectionMatrix ); + Vector3 delta = MovePointOnPlane( curMouseX, curMouseY, curMouseX + mouseXDelta, curMouseY + mouseYDelta, pos, normal, viewport, viewMatrix, projectionMatrix ); Vector3 translate; if( m_selectedAxis == "w" ) @@ -168,9 +167,9 @@ void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDe Vector3 nextScale = m_scale; - nextScale.x = ( m_initialScale.x*scale ); - nextScale.y = ( m_initialScale.y*scale ); - nextScale.z = ( m_initialScale.z*scale ); + nextScale.x = ( m_initialScale.x * scale ); + nextScale.y = ( m_initialScale.y * scale ); + nextScale.z = ( m_initialScale.z * scale ); scaleB = ScalingMatrix( nextScale.x, nextScale.y, nextScale.z ); // Check the move callback for if we should be moving or not @@ -229,15 +228,15 @@ void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDe Vector3 nextScale = m_scale; if( m_selectedAxis == "x" ) { - nextScale.x = ( m_initialScale.x*scale ); + nextScale.x = ( m_initialScale.x * scale ); } else if( m_selectedAxis == "y" ) { - nextScale.y = ( m_initialScale.y*scale ); + nextScale.y = ( m_initialScale.y * scale ); } else if( m_selectedAxis == "z" ) { - nextScale.z = ( m_initialScale.z*scale ); + nextScale.z = ( m_initialScale.z * scale ); } scaleB = ScalingMatrix( nextScale.x, nextScale.y, nextScale.z ); @@ -255,7 +254,7 @@ void Tr2ScalingTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDe } } -std::vector& Tr2ScalingTool::GetPrimitivesToRender( ) +std::vector& Tr2ScalingTool::GetPrimitivesToRender() { // Depending on the mode of the tool. We want to control which parts of it will // be rendered @@ -264,7 +263,7 @@ std::vector& Tr2ScalingTool::GetPrimitivesToRender( ) { for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - m_visibleObjects.push_back((*it)); + m_visibleObjects.push_back( ( *it ) ); } } else @@ -273,12 +272,11 @@ std::vector& Tr2ScalingTool::GetPrimitivesToRender( ) // ring for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == "w" || (*it)->m_name == m_selectedAxis - || (*it)->m_name == "_"+m_selectedAxis ) + if( ( *it )->m_name == "w" || ( *it )->m_name == m_selectedAxis || ( *it )->m_name == "_" + m_selectedAxis ) { - m_visibleObjects.push_back((*it)); - } - } + m_visibleObjects.push_back( ( *it ) ); + } + } } return m_visibleObjects; } @@ -287,21 +285,21 @@ void Tr2ScalingTool::ResetPrimitiveColors() { for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == "x" ) + if( ( *it )->m_name == "x" ) { - (*it)->SetCurrentColor((Color&)v4Red); + ( *it )->SetCurrentColor( (Color&)v4Red ); } - else if((*it)->m_name == "y" ) + else if( ( *it )->m_name == "y" ) { - (*it)->SetCurrentColor((Color&)v4Green); + ( *it )->SetCurrentColor( (Color&)v4Green ); } - else if((*it)->m_name == "z" ) + else if( ( *it )->m_name == "z" ) { - (*it)->SetCurrentColor((Color&)v4Blue); + ( *it )->SetCurrentColor( (Color&)v4Blue ); } - else if((*it)->m_name == "w" ) + else if( ( *it )->m_name == "w" ) { - (*it)->SetCurrentColor((Color&)v4Cyan); + ( *it )->SetCurrentColor( (Color&)v4Cyan ); } } } @@ -316,33 +314,33 @@ void Tr2ScalingTool::GenLineSets() Tr2EffectPtr mLineEffect; Tr2EffectPtr pEffect; - if( !m_xLine .CreateInstance() || - !m_yLine .CreateInstance() || - !m_zLine .CreateInstance() || - !m_xBox .CreateInstance() || - !m_yBox .CreateInstance() || - !m_zBox .CreateInstance() || - !m_wBox .CreateInstance() || - !mLineEffect.CreateInstance() || - !mSolidEffect.CreateInstance() || - !pEffect .CreateInstance() ) + if( !m_xLine.CreateInstance() || + !m_yLine.CreateInstance() || + !m_zLine.CreateInstance() || + !m_xBox.CreateInstance() || + !m_yBox.CreateInstance() || + !m_zBox.CreateInstance() || + !m_wBox.CreateInstance() || + !mLineEffect.CreateInstance() || + !mSolidEffect.CreateInstance() || + !pEffect.CreateInstance() ) { return; } - - mLineEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx"); - mSolidEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/SolidsNoZ.fx"); - pEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); - m_xLine->AddLine( v3Zero, v4LightGray, v3X, v4LightGray ); + mLineEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx" ); + mSolidEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/SolidsNoZ.fx" ); + pEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); + + m_xLine->AddLine( v3Zero, v4LightGray, v3X, v4LightGray ); m_xLine->SubmitChanges(); m_xLine->m_name = "_x"; - m_yLine->AddLine( v3Zero, v4LightGray, v3Y, v4LightGray ); + m_yLine->AddLine( v3Zero, v4LightGray, v3Y, v4LightGray ); m_yLine->SubmitChanges(); m_yLine->m_name = "_y"; - m_zLine->AddLine( v3Zero, v4LightGray, v3Z, v4LightGray ); + m_zLine->AddLine( v3Zero, v4LightGray, v3Z, v4LightGray ); m_zLine->SubmitChanges(); m_zLine->m_name = "_z"; @@ -351,15 +349,15 @@ void Tr2ScalingTool::GenLineSets() m_xLine->m_pickEffect = m_yLine->m_pickEffect = m_zLine->m_pickEffect = pEffect; //xBox - c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ),Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); + c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ), Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); translationMat = TranslationMatrix( 1.0f, 0.0f, 0.0f ); TransformCoords( c_tris, numVectors, translationMat ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - m_xBox->AddTriangle(c_tris[i*3], v4Red, c_tris[i*3+1], v4Red, c_tris[i*3+2], v4Red ); - } - delete [] c_tris; + m_xBox->AddTriangle( c_tris[i * 3], v4Red, c_tris[i * 3 + 1], v4Red, c_tris[i * 3 + 2], v4Red ); + } + delete[] c_tris; m_xBox->SubmitChanges(); m_xBox->m_name = "x"; @@ -368,15 +366,15 @@ void Tr2ScalingTool::GenLineSets() m_xBox->m_pickEffect = pEffect; //yBox - c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ),Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); + c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ), Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); translationMat = TranslationMatrix( 0.0f, 1.0f, 0.0f ); TransformCoords( c_tris, numVectors, translationMat ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - m_yBox->AddTriangle(c_tris[i*3], v4Green, c_tris[i*3+1], v4Green, c_tris[i*3+2], v4Green ); - } - delete [] c_tris; + m_yBox->AddTriangle( c_tris[i * 3], v4Green, c_tris[i * 3 + 1], v4Green, c_tris[i * 3 + 2], v4Green ); + } + delete[] c_tris; m_yBox->SubmitChanges(); m_yBox->m_name = "y"; @@ -385,15 +383,15 @@ void Tr2ScalingTool::GenLineSets() m_yBox->m_pickEffect = pEffect; //yBox - c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ),Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); + c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ), Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); translationMat = TranslationMatrix( 0.0f, 0.0f, 1.0f ); TransformCoords( c_tris, numVectors, translationMat ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - m_zBox->AddTriangle(c_tris[i*3], v4Blue, c_tris[i*3+1], v4Blue, c_tris[i*3+2], v4Blue ); - } - delete [] c_tris; + m_zBox->AddTriangle( c_tris[i * 3], v4Blue, c_tris[i * 3 + 1], v4Blue, c_tris[i * 3 + 2], v4Blue ); + } + delete[] c_tris; m_zBox->SubmitChanges(); m_zBox->m_name = "z"; @@ -402,12 +400,12 @@ void Tr2ScalingTool::GenLineSets() m_zBox->m_pickEffect = pEffect; //wBox - c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ),Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); - for( int i = 0; i < numVectors/3; i++ ) + c_tris = Tr2ManipulationTool::GetBoxTriangles( Vector3( -0.075f, -0.075f, -0.075f ), Vector3( 0.075f, 0.075f, 0.075f ), &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - m_wBox->AddTriangle(c_tris[i*3], v4Cyan, c_tris[i*3+1], v4Cyan, c_tris[i*3+2], v4Cyan ); - } - delete [] c_tris; + m_wBox->AddTriangle( c_tris[i * 3], v4Cyan, c_tris[i * 3 + 1], v4Cyan, c_tris[i * 3 + 2], v4Cyan ); + } + delete[] c_tris; m_wBox->SubmitChanges(); m_wBox->m_name = "w"; @@ -415,14 +413,14 @@ void Tr2ScalingTool::GenLineSets() m_wBox->m_effect = mSolidEffect; m_wBox->m_pickEffect = pEffect; - m_primitives.Insert( -1, m_xLine->GetRawRoot()); - m_primitives.Insert( -1, m_yLine->GetRawRoot()); - m_primitives.Insert( -1, m_zLine->GetRawRoot()); + m_primitives.Insert( -1, m_xLine->GetRawRoot() ); + m_primitives.Insert( -1, m_yLine->GetRawRoot() ); + m_primitives.Insert( -1, m_zLine->GetRawRoot() ); - m_primitives.Insert( -1, m_xBox->GetRawRoot()); - m_primitives.Insert( -1, m_yBox->GetRawRoot()); - m_primitives.Insert( -1, m_zBox->GetRawRoot()); - m_primitives.Insert( -1, m_wBox->GetRawRoot()); + m_primitives.Insert( -1, m_xBox->GetRawRoot() ); + m_primitives.Insert( -1, m_yBox->GetRawRoot() ); + m_primitives.Insert( -1, m_zBox->GetRawRoot() ); + m_primitives.Insert( -1, m_wBox->GetRawRoot() ); } void Tr2ScalingTool::Update() @@ -431,7 +429,7 @@ void Tr2ScalingTool::Update() m_worldTransform = m_localTransform * translation; for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - (*it)->UpdateTransform(); + ( *it )->UpdateTransform(); } UpdateLines(); @@ -442,34 +440,35 @@ void Tr2ScalingTool::UpdateLines() Vector3 wCenter = m_wBox->GetCenterOfMass(); // x m_xLine->ClearLines(); - m_xLine->AddLine( wCenter, - v4LightGray, - m_xBox->GetCenterOfMass(), - v4LightGray ); + m_xLine->AddLine( wCenter, + v4LightGray, + m_xBox->GetCenterOfMass(), + v4LightGray ); m_xLine->SubmitChanges(); // y m_yLine->ClearLines(); - m_yLine->AddLine( wCenter, - v4LightGray, - m_yBox->GetCenterOfMass(), - v4LightGray ); + m_yLine->AddLine( wCenter, + v4LightGray, + m_yBox->GetCenterOfMass(), + v4LightGray ); m_yLine->SubmitChanges(); // z m_zLine->ClearLines(); - m_zLine->AddLine( wCenter, - v4LightGray, - m_zBox->GetCenterOfMass(), - v4LightGray ); + m_zLine->AddLine( wCenter, + v4LightGray, + m_zBox->GetCenterOfMass(), + v4LightGray ); m_zLine->SubmitChanges(); } -void Tr2ScalingTool::ResetPrimitives(){ +void Tr2ScalingTool::ResetPrimitives() +{ for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - (*it)->m_localTransform = m_localTransform; - (*it)->UpdateTransform(); + ( *it )->m_localTransform = m_localTransform; + ( *it )->UpdateTransform(); } m_xLine->m_localTransform = IdentityMatrix(); m_yLine->m_localTransform = IdentityMatrix(); @@ -483,7 +482,7 @@ void Tr2ScalingTool::Init( Matrix& initialTransform ) { // Extract the scaling and translation Vector3 scaling; - Vector3 pos; + Vector3 pos; Quaternion rotation; Matrix rotationMatrix; Decompose( scaling, rotation, pos, initialTransform ); @@ -497,7 +496,7 @@ void Tr2ScalingTool::Init( Matrix& initialTransform ) ResetPrimitives(); // Compute initial length when captured Vector3 vecA, vecB, vecC; - vecA.x = m_worldTransform._41; + vecA.x = m_worldTransform._41; vecA.y = m_worldTransform._42; vecA.z = m_worldTransform._43; vecB = m_xBox->GetCenterOfMass(); @@ -505,5 +504,4 @@ void Tr2ScalingTool::Init( Matrix& initialTransform ) m_initialLength = -1; m_scale = scaling; m_initialScale = scaling; - } diff --git a/trinity/Tr2ScalingTool.h b/trinity/Tr2ScalingTool.h index dd4758311..99c06dacd 100644 --- a/trinity/Tr2ScalingTool.h +++ b/trinity/Tr2ScalingTool.h @@ -9,24 +9,24 @@ BLUE_DECLARE( Tr2LineSet ); BLUE_DECLARE( Tr2SolidSet ); -BLUE_CLASS( Tr2ScalingTool ): - public Tr2ManipulationTool +BLUE_CLASS( Tr2ScalingTool ) : + public Tr2ManipulationTool { public: - EXPOSE_TO_BLUE(); - Tr2ScalingTool( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2ScalingTool( IRoot* lockobj = NULL ); void GenLineSets(); void Update(); void ResetPrimitiveColors(); void ResetPrimitives(); - std::vector& GetPrimitivesToRender( ); + std::vector& GetPrimitivesToRender(); void Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); Vector3 m_scale; Vector3 m_initialScale; - float m_initialLength; - void Init( Matrix& initialTransform ); + float m_initialLength; + void Init( Matrix & initialTransform ); Tr2SolidSetPtr m_xBox; Tr2SolidSetPtr m_yBox; diff --git a/trinity/Tr2ScalingTool_Blue.cpp b/trinity/Tr2ScalingTool_Blue.cpp index 53c4b8b98..3771cdc03 100644 --- a/trinity/Tr2ScalingTool_Blue.cpp +++ b/trinity/Tr2ScalingTool_Blue.cpp @@ -12,13 +12,9 @@ const Be::ClassInfo* Tr2ScalingTool::ExposeToBlue() MAP_INTERFACE( Tr2ScalingTool ) MAP_INTERFACE( Tr2ManipulationTool ) - MAP_METHOD_AND_WRAP( "ResetPrimitives", ResetPrimitives, - "Resets the primitives of the Scaling tool") + MAP_METHOD_AND_WRAP( "ResetPrimitives", ResetPrimitives, "Resets the primitives of the Scaling tool" ) - MAP_ATTRIBUTE( "scale", m_scale, - "The output scale value", - Be::READ - ) + MAP_ATTRIBUTE( "scale", m_scale, "The output scale value", Be::READ ) - EXPOSURE_CHAINTO( Tr2ManipulationTool ) + EXPOSURE_CHAINTO( Tr2ManipulationTool ) } diff --git a/trinity/Tr2ShLightingManager.cpp b/trinity/Tr2ShLightingManager.cpp index 77dc26818..e8c7dba01 100644 --- a/trinity/Tr2ShLightingManager.cpp +++ b/trinity/Tr2ShLightingManager.cpp @@ -13,7 +13,7 @@ namespace // Imeratively chosen threshold for distance/radius*intensity value to decide if the light affects a sample static const float s_cutoffRadiusRatio = 0.045f * 7.f; -template +template class ShSolver { }; @@ -22,7 +22,7 @@ class ShSolver // Description: // ShSolver class evaluates L1 SH coefficients for spherical light sources. // -------------------------------------------------------------------------------------- -template<> +template <> class ShSolver { public: @@ -30,7 +30,7 @@ class ShSolver FXMVECTOR direction, float distance, float radius, - float *result ) + float* result ) { float o0, o1; if( distance <= radius ) @@ -73,6 +73,7 @@ class ShSolver } static const size_t ORDER = 2; + private: static const float s_packCoefficient0; static const float s_packCoefficient1; @@ -93,15 +94,15 @@ const float ShSolver::s_normalizationCoefficients[4] = // Description: // ShSolver class evaluates L2 SH coefficients for spherical light sources. // -------------------------------------------------------------------------------------- -template<> +template <> class ShSolver { public: - inline static void SHEvalSphericalLight( + inline static void SHEvalSphericalLight( FXMVECTOR direction, float distance, float radius, - float *result ) + float* result ) { float sinAngle, cosAngle; if( distance <= radius ) @@ -146,17 +147,17 @@ class ShSolver inline static void PackCoefficients( XMVECTOR* coefficients, Vector4* packedCoefficients ) { - for( int i = 0; i < 3; i++ ) - { - packedCoefficients[i].x = -s_packCoefficient1 * XMVectorGetByIndex( coefficients[3], i ); - packedCoefficients[i].y = -s_packCoefficient1 * XMVectorGetByIndex( coefficients[1], i ); - packedCoefficients[i].z = s_packCoefficient1 * XMVectorGetByIndex( coefficients[2], i ); - packedCoefficients[i].w = s_packCoefficient0 * XMVectorGetByIndex( coefficients[0], i ) - - s_packCoefficient3 * XMVectorGetByIndex( coefficients[6], i ); - } - - for( int i = 0; i < 3; i++ ) - { + for( int i = 0; i < 3; i++ ) + { + packedCoefficients[i].x = -s_packCoefficient1 * XMVectorGetByIndex( coefficients[3], i ); + packedCoefficients[i].y = -s_packCoefficient1 * XMVectorGetByIndex( coefficients[1], i ); + packedCoefficients[i].z = s_packCoefficient1 * XMVectorGetByIndex( coefficients[2], i ); + packedCoefficients[i].w = s_packCoefficient0 * XMVectorGetByIndex( coefficients[0], i ) - + s_packCoefficient3 * XMVectorGetByIndex( coefficients[6], i ); + } + + for( int i = 0; i < 3; i++ ) + { packedCoefficients[i + 3].x = s_packCoefficient2 * XMVectorGetByIndex( coefficients[4], i ); packedCoefficients[i + 3].y = -s_packCoefficient2 * XMVectorGetByIndex( coefficients[5], i ); packedCoefficients[i + 3].z = 3.0f * s_packCoefficient3 * XMVectorGetByIndex( coefficients[6], i ); @@ -168,6 +169,7 @@ class ShSolver } static const size_t ORDER = 3; + private: inline static void ComputeCapInt( float sinAngle, float cosAngle, float angularCoefficients[3] ) { @@ -219,8 +221,8 @@ const float ShSolver::s_normalizationCoefficients[9] = } -Tr2ShLightingManager::Tr2ShLightingManager( IRoot* lockobj ) - :m_sources( "Tr2ShLightingManager.m_sources" ), +Tr2ShLightingManager::Tr2ShLightingManager( IRoot* lockobj ) : + m_sources( "Tr2ShLightingManager.m_sources" ), m_sourceData( "Tr2ShLightingManager.m_sourceData", sizeof( SourceData ) * 8, 16 ), m_sourceCount( 0 ), m_primaryIntensity( 1.f ), @@ -258,7 +260,7 @@ void Tr2ShLightingManager::RegisterSecondaryLightSource( const Vector3* position // -------------------------------------------------------------------------------------- // Description: -// Unregisters a secondary light source previously registered with +// Unregisters a secondary light source previously registered with // RegisterSecondaryLightSource call. // Arguments: // position - Pointer to source position vector @@ -294,14 +296,14 @@ void Tr2ShLightingManager::UpdateWithDirectionalLight( const Vector3& direction, // -------------------------------------------------------------------------------------- // Description: -// Helper function that calculates SH lighting coefficient for the given sample +// Helper function that calculates SH lighting coefficient for the given sample // position using specified SH order (template parameter). // Arguments: // position - Sample position // intensity - Lighting intensity factor // lightingCoefficients - (out) SH lighting coefficients (8 for L2 and 4 for L1) // -------------------------------------------------------------------------------------- -template +template void Tr2ShLightingManager::CalculateSecondaryLighting( const Vector3& position, float intensity, float cutoffRadius, Vector4* lightingCoefficients ) { XMVECTOR lightDirection = m_sunDirection; @@ -327,12 +329,12 @@ void Tr2ShLightingManager::CalculateSecondaryLighting( const Vector3& position, XMVECTOR distance = XMVector3LengthEst( toSource ); XMVECTOR oneOverDistance = XMVectorReciprocalEst( distance ); XMVECTOR dir = XMVectorMultiply( toSource, oneOverDistance ); - - XMVECTOR condition = XMVectorOrInt( XMVectorOrInt( - XMVectorIsInfinite( distance ), - XMVectorLess( XMVectorMultiply( XMVectorMultiply( sourcePos, oneOverDistance ), XMLoadFloat4A( reinterpret_cast( &source->emissive ) ) ), - XMVectorReplicate( s_cutoffRadiusRatio ) ) ), - XMVectorLess( distance, g_XMOne ) ); + + XMVECTOR condition = XMVectorOrInt( XMVectorOrInt( + XMVectorIsInfinite( distance ), + XMVectorLess( XMVectorMultiply( XMVectorMultiply( sourcePos, oneOverDistance ), XMLoadFloat4A( reinterpret_cast( &source->emissive ) ) ), + XMVectorReplicate( s_cutoffRadiusRatio ) ) ), + XMVectorLess( distance, g_XMOne ) ); if( XMVectorGetIntW( condition ) ) { continue; diff --git a/trinity/Tr2ShLightingManager.h b/trinity/Tr2ShLightingManager.h index cced4e000..343155080 100644 --- a/trinity/Tr2ShLightingManager.h +++ b/trinity/Tr2ShLightingManager.h @@ -12,13 +12,14 @@ BLUE_DECLARE_VECTOR( TriCurveSet ); // -------------------------------------------------------------------------------------- // Description: -// Tr2ShLightingManager is a class for computing SH coefficients to approximate. +// Tr2ShLightingManager is a class for computing SH coefficients to approximate. // Currently it only deals with secondary lighting: lighting from a single primary // light source reflected from "secondary light sources", i.e. spheres with set albedo // color and radius. Additionally these "secondary light sources" can have a self- // emissive color. // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ShLightingManager ): public IRoot +BLUE_CLASS( Tr2ShLightingManager ) : + public IRoot { public: Tr2ShLightingManager( IRoot* lockobj = NULL ); @@ -36,10 +37,10 @@ BLUE_CLASS( Tr2ShLightingManager ): public IRoot L2, }; - void RegisterSecondaryLightSource( - const Vector3* position, - const float* radius, - const Color* albedo, + void RegisterSecondaryLightSource( + const Vector3* position, + const float* radius, + const Color* albedo, const Color* emissive ); void UnregisterSecondaryLightSource( const Vector3* position ); @@ -48,6 +49,7 @@ BLUE_CLASS( Tr2ShLightingManager ): public IRoot void UpdateWithDirectionalLight( const Vector3& direction, const Vector3& color ); static const size_t PACKED_COEFFICIENT_COUNT = 7; + private: struct Source { @@ -67,7 +69,8 @@ BLUE_CLASS( Tr2ShLightingManager ): public IRoot }; void UpdateSourceData(); - template void CalculateSecondaryLighting( const Vector3& position, float intensity, float cutoffRadius, Vector4* lightingCoefficients ); + template + void CalculateSecondaryLighting( const Vector3& position, float intensity, float cutoffRadius, Vector4* lightingCoefficients ); // Registered secondary light sources TrackableStdVector m_sources; @@ -96,10 +99,11 @@ TYPEDEF_BLUECLASS( Tr2ShLightingManager ); // -------------------------------------------------------------------------------------- // Description: -// Helper interface for secondary light sources that can be used with +// Helper interface for secondary light sources that can be used with // Tr2ShLightingManager. // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2SecondaryLightSource ): public IRoot +BLUE_INTERFACE( ITr2SecondaryLightSource ) : + public IRoot { virtual void RegisterSecondaryLightSource( Tr2ShLightingManager& ) = 0; virtual void UnregisterSecondaryLightSource( Tr2ShLightingManager& ) = 0; @@ -107,10 +111,11 @@ BLUE_INTERFACE( ITr2SecondaryLightSource ): public IRoot // -------------------------------------------------------------------------------------- // Description: -// Helper interface for secondary light receiver that can be used with +// Helper interface for secondary light receiver that can be used with // Tr2ShLightingManager. // -------------------------------------------------------------------------------------- -BLUE_INTERFACE( ITr2ShLightingReceiver ): public IRoot +BLUE_INTERFACE( ITr2ShLightingReceiver ) : + public IRoot { virtual void UpdateShLighting( Tr2ShLightingManager&, const EveUpdateContext& ) = 0; virtual void ClearShLighting() = 0; diff --git a/trinity/Tr2ShLightingManager_Blue.cpp b/trinity/Tr2ShLightingManager_Blue.cpp index 551d6aa8a..96691337d 100644 --- a/trinity/Tr2ShLightingManager_Blue.cpp +++ b/trinity/Tr2ShLightingManager_Blue.cpp @@ -7,40 +7,39 @@ BLUE_DEFINE_INTERFACE( ITr2SecondaryLightSource ); BLUE_DEFINE_INTERFACE( ITr2ShLightingReceiver ); BLUE_DEFINE( Tr2ShLightingManager ); -const Be::VarChooser Tr2ShLightingManagerQualityChooser[] = -{ - { "L1", BeCast( Tr2ShLightingManager::L1 ), "" }, - { "L2", BeCast( Tr2ShLightingManager::L2 ), "" }, - {0} +const Be::VarChooser Tr2ShLightingManagerQualityChooser[] = { + { "L1", BeCast( Tr2ShLightingManager::L1 ), "" }, + { "L2", BeCast( Tr2ShLightingManager::L2 ), "" }, + { 0 } }; BLUE_REGISTER_ENUM( "ShQuality", Tr2ShLightingManager::Quality, Tr2ShLightingManagerQualityChooser ); const Be::ClassInfo* Tr2ShLightingManager::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2ShLightingManager, "" ) - MAP_INTERFACE( Tr2ShLightingManager ) + EXPOSURE_BEGIN( Tr2ShLightingManager, "" ) + MAP_INTERFACE( Tr2ShLightingManager ) - MAP_ATTRIBUTE( - "primaryIntensity", - m_primaryIntensity, - "Overall intensity for primary SH lighting (from a list of point lights)", + MAP_ATTRIBUTE( + "primaryIntensity", + m_primaryIntensity, + "Overall intensity for primary SH lighting (from a list of point lights)", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( - "secondaryIntensity", - m_secondaryIntensity, - "Overall intensity for secondary SH lighting", + MAP_ATTRIBUTE( + "secondaryIntensity", + m_secondaryIntensity, + "Overall intensity for secondary SH lighting", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( - "quality", - m_quality, - "Lighting quality (SH order)", + MAP_ATTRIBUTE_WITH_CHOOSER( + "quality", + m_quality, + "Lighting quality (SH order)", Be::READWRITE | Be::PERSIST | Be::ENUM, Tr2ShLightingManagerQualityChooser ) - MAP_ATTRIBUTE( - "lights", - m_lights, - "Additional lights", + MAP_ATTRIBUTE( + "lights", + m_lights, + "Additional lights", Be::READ | Be::PERSIST ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2ShadowMap.cpp b/trinity/Tr2ShadowMap.cpp index 0957b7f52..9042b1d02 100644 --- a/trinity/Tr2ShadowMap.cpp +++ b/trinity/Tr2ShadowMap.cpp @@ -117,7 +117,7 @@ void Tr2ShadowMap::UpdateSplitValues( float nearClip, float farClip ) } } -AxisAlignedBoundingBox Tr2ShadowMap::CalculateAABB( Matrix projection, Matrix invViewTransform, Matrix lightView, Vector3 (&corners)[8] ) +AxisAlignedBoundingBox Tr2ShadowMap::CalculateAABB( Matrix projection, Matrix invViewTransform, Matrix lightView, Vector3 ( &corners )[8] ) { AxisAlignedBoundingBox aabb; for( unsigned int i = 0; i < 8; ++i ) @@ -138,17 +138,16 @@ AxisAlignedBoundingBox Tr2ShadowMap::CalculateAABB( Matrix projection, Matrix in } // -------------------------------------------------------------------------------- // Description: -// Go through all i count of frustum splits. Calculate the corresponding +// Go through all i count of frustum splits. Calculate the corresponding // bounding box based on zNear and zFar values. // -------------------------------------------------------------------------------- -ShadowMap::SplitSetup Tr2ShadowMap::SetupShadowSplit( int splitIndex, Matrix invViewTransform, const Vector3 lightDirection, - float zNear, float leftDivNear, float rightDivNear, float topDivNear, float bottomDivNear ) +ShadowMap::SplitSetup Tr2ShadowMap::SetupShadowSplit( int splitIndex, Matrix invViewTransform, const Vector3 lightDirection, float zNear, float leftDivNear, float rightDivNear, float topDivNear, float bottomDivNear ) { CCP_STATS_ZONE( __FUNCTION__ ); ShadowMap::SplitSetup splitSetup; - if(splitIndex == 0 ) + if( splitIndex == 0 ) { // reset this value m_oldZFar = zNear; @@ -198,7 +197,7 @@ ShadowMap::SplitSetup Tr2ShadowMap::SetupShadowSplit( int splitIndex, Matrix inv Vector3 shipPos = Vector3( 0.0, 0.0, 0.0 ); Vector3 center = aabb.Center(); // rounding up - float texelSize = (radius * 2.0f) / m_size; + float texelSize = ( radius * 2.0f ) / m_size; center.x = std::floor( center.x / texelSize + 0.5f ) * texelSize; center.y = std::floor( center.y / texelSize + 0.5f ) * texelSize; @@ -208,19 +207,19 @@ ShadowMap::SplitSetup Tr2ShadowMap::SetupShadowSplit( int splitIndex, Matrix inv // pull the aabb towards the sun //aabb.m_max.z += 250000.f; splitSetup.aabb = aabb; - + splitSetup.lightViewProjection = lightView * OrthoOffCenterMatrix( aabb.m_max.x, aabb.m_min.x, aabb.m_max.y, aabb.m_min.y, -aabb.m_max.z, -aabb.m_min.z ); m_perSplitData.CascadeRanges[splitIndex] = Vector4( aabb.m_max.x - aabb.m_min.x, aabb.m_max.y - aabb.m_min.y, aabb.m_max.z - aabb.m_min.z, 0 ); // 4th element of shadowMatrix is always the same m_perSplitData.ShadowMatrixVal[splitIndex] = Transpose( splitSetup.lightViewProjection ); - + // create shadow frustum out from lightView, aabb.min, aabb.max TriFrustumOrtho shadowFrustum; shadowFrustum.DeriveFrustum( lightView, aabb.m_min, aabb.m_max ); splitSetup.shadowFrustum = shadowFrustum; - + return splitSetup; } diff --git a/trinity/Tr2ShadowMap.h b/trinity/Tr2ShadowMap.h index a35782bef..35cb71390 100644 --- a/trinity/Tr2ShadowMap.h +++ b/trinity/Tr2ShadowMap.h @@ -39,22 +39,23 @@ BLUE_DECLARE_INTERFACE( ITriTextureRes ); namespace ShadowMap { - ///////////////////////////////////////////////////////////// - // Shadow functions - struct SplitSetup - { - TriFrustumOrtho shadowFrustum; - Matrix lightViewProjection; - Matrix invViewProj; - AxisAlignedBoundingBox aabb; - }; +///////////////////////////////////////////////////////////// +// Shadow functions +struct SplitSetup +{ + TriFrustumOrtho shadowFrustum; + Matrix lightViewProjection; + Matrix invViewProj; + AxisAlignedBoundingBox aabb; +}; } // -------------------------------------------------------------------------------- // Description: // This class holds a cascaded shadow map and takes care of splitting the frustum // // -------------------------------------------------------------------------------- -BLUE_CLASS( Tr2ShadowMap ) : public INotify +BLUE_CLASS( Tr2ShadowMap ) : + public INotify { public: EXPOSE_TO_BLUE(); @@ -65,14 +66,14 @@ BLUE_CLASS( Tr2ShadowMap ) : public INotify ////////////////////////////////////////////////////////////////////////// // INotify - bool OnModified( Be::Var* val ); + bool OnModified( Be::Var * val ); ShadowMap::SplitSetup SetupShadowSplit( int splitIndex, Matrix invViewTransform, const Vector3 lightDirection, float zNear, float leftDivNear, float rightDivNear, float topDivNear, float bottomDivNear ); - Tr2GpuResourcePool::Texture PrepareShadowRendering( Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ); - void BeginShadowRendering( Tr2RenderContext& renderContext, int splitIndex ); - void EndShadowRendering( Tr2RenderContext& renderContext ); - Tr2GpuResourcePool::Texture DrawToShadowMapResult( Tr2RenderContext& renderContext, Tr2GpuResourcePool& gpuResourcePool, const Tr2TextureAL& depthMap, const Tr2TextureAL& cascadedShadowDepth, float upscaling ); + Tr2GpuResourcePool::Texture PrepareShadowRendering( Tr2GpuResourcePool & gpuResourcePool, Tr2RenderContext & renderContext ); + void BeginShadowRendering( Tr2RenderContext & renderContext, int splitIndex ); + void EndShadowRendering( Tr2RenderContext & renderContext ); + Tr2GpuResourcePool::Texture DrawToShadowMapResult( Tr2RenderContext & renderContext, Tr2GpuResourcePool & gpuResourcePool, const Tr2TextureAL& depthMap, const Tr2TextureAL& cascadedShadowDepth, float upscaling ); const unsigned int GetShadowSplitCount() const; const unsigned int GetShadowMapSize() const; @@ -104,16 +105,15 @@ BLUE_CLASS( Tr2ShadowMap ) : public INotify DYNAMIC, MANUAL }; - static AxisAlignedBoundingBox CalculateAABB( Matrix projection, Matrix invViewTransform, Matrix lightView, Vector3 (&corners)[8] ); + static AxisAlignedBoundingBox CalculateAABB( Matrix projection, Matrix invViewTransform, Matrix lightView, Vector3( &corners )[8] ); private: - private: void SetStaticShadowSplits(); // width and height of shadow map unsigned int m_size; // texture res - unsigned int m_width; // splits on x axis + unsigned int m_width; // splits on x axis unsigned int m_height; // splits on y axis unsigned int m_splitCount; float m_oldZFar; diff --git a/trinity/Tr2ShadowMap_Blue.cpp b/trinity/Tr2ShadowMap_Blue.cpp index 5908f7208..2bf0b0371 100644 --- a/trinity/Tr2ShadowMap_Blue.cpp +++ b/trinity/Tr2ShadowMap_Blue.cpp @@ -43,11 +43,11 @@ const Be::ClassInfo* Tr2ShadowMap::ExposeToBlue() "Effect used for calculating which split the pixel belongs to and determing the shadow factor.", Be::READWRITE ) - - MAP_ATTRIBUTE( - "denoiser", - m_denoiser, - "", + + MAP_ATTRIBUTE( + "denoiser", + m_denoiser, + "", Be::READWRITE ) MAP_ATTRIBUTE( diff --git a/trinity/Tr2SkinnedModel.cpp b/trinity/Tr2SkinnedModel.cpp index 93b34848f..453586d01 100644 --- a/trinity/Tr2SkinnedModel.cpp +++ b/trinity/Tr2SkinnedModel.cpp @@ -10,13 +10,13 @@ static const unsigned int NO_SKELETON = 0xffffffff; -Tr2SkinnedModel::Tr2SkinnedModel( IRoot* lockobj ) : +Tr2SkinnedModel::Tr2SkinnedModel( IRoot* lockobj ) : Tr2Model( lockobj ), m_areAllMeshesBound( false ), m_skeletonIx( NO_SKELETON ), m_skinScale( 1.f, 1.f, 1.f ), - m_pBoneList( NULL ), - m_numBones( 0 ) + m_pBoneList( NULL ), + m_numBones( 0 ) { } @@ -103,9 +103,9 @@ void Tr2SkinnedModel::GetBatchesForArea( Tr2MeshAreaVector* areas, Tr2Mesh* mesh } } -void Tr2SkinnedModel::GetBatches( ITriRenderBatchAccumulator* batches, - TriBatchType batchType, - const Matrix& m, +void Tr2SkinnedModel::GetBatches( ITriRenderBatchAccumulator* batches, + TriBatchType batchType, + const Matrix& m, const Tr2PerObjectData* data ) { Matrix* pm = batches->Allocate(); @@ -131,7 +131,6 @@ void Tr2SkinnedModel::GetBatches( ITriRenderBatchAccumulator* batches, } } } - } bool Tr2SkinnedModel::HasTransparency() const @@ -161,7 +160,7 @@ bool Tr2SkinnedModel::GetBoundingBox( Vector3& min, Vector3& max ) return Tr2Model::GetBoundingBox( min, max ); } -void Tr2SkinnedModel::BindToRig( const std::string* boneList, const int numBones, bool forceRebind ) +void Tr2SkinnedModel::BindToRig( const std::string* boneList, const int numBones, bool forceRebind ) { if( !forceRebind && ( boneList == m_pBoneList ) && m_areAllMeshesBound ) { @@ -182,12 +181,12 @@ void Tr2SkinnedModel::BindToRig( const std::string* boneList, const int numBone TriGeometryResSkeletonData* skel = m_geometryRes->GetSkeletonData( m_skeletonIx ); - forceRebind |= !m_areAllMeshesBound; // if a reset was requested, make sure every mesh honors that + forceRebind |= !m_areAllMeshesBound; // if a reset was requested, make sure every mesh honors that m_areAllMeshesBound = true; for( PTr2MeshVector::const_iterator meshIt = m_meshes.begin(); meshIt != m_meshes.end(); ++meshIt ) { Tr2Mesh* mesh = *meshIt; - if( !mesh->BindToRig( boneList, numBones, skel, forceRebind ) ) + if( !mesh->BindToRig( boneList, numBones, skel, forceRebind ) ) { m_areAllMeshesBound = false; } diff --git a/trinity/Tr2SkinnedModel.h b/trinity/Tr2SkinnedModel.h index 0c09589fc..6c9ae62de 100644 --- a/trinity/Tr2SkinnedModel.h +++ b/trinity/Tr2SkinnedModel.h @@ -15,15 +15,14 @@ BLUE_DECLARE_VECTOR( Tr2MeshArea ); namespace MR { - class Rig; +class Rig; } -class Tr2SkinnedModel: - public Tr2Model, - public IInitialize, - public INotify, - public IListNotify, - public IBlueAsyncResNotifyTarget +class Tr2SkinnedModel : public Tr2Model, + public IInitialize, + public INotify, + public IListNotify, + public IBlueAsyncResNotifyTarget { public: EXPOSE_TO_BLUE(); @@ -38,14 +37,14 @@ class Tr2SkinnedModel: virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Matrix& m, + const Matrix& m, const Tr2PerObjectData* data ); - + virtual bool HasTransparency() const; virtual bool GetBoundingBox( Vector3& min, Vector3& max ); void ResetBindings(); - void BindToRig( const std::string* boneList, const int numBones, bool forceRebind ); + void BindToRig( const std::string* boneList, const int numBones, bool forceRebind ); ////////////////////////////////////////////////////////////////////////// // IBlueAsyncResNotifyTarget @@ -59,27 +58,35 @@ class Tr2SkinnedModel: ////////////////////////////////////////////////////////////////////////// // IListNotify virtual void OnListModified( - long event, // BLUELISTEVENT values + long event, // BLUELISTEVENT values ssize_t key, ssize_t key2, IRoot* value, - const IList* theList - ); + const IList* theList ); ////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); // set - void SetGeometryResPath( const char* path ) { m_geometryResPath = path; } - const char* GetGeometryResPath() { return m_geometryResPath.c_str(); } - void SetSkeletonName( const char* name ) { m_skeletonName = name; } + void SetGeometryResPath( const char* path ) + { + m_geometryResPath = path; + } + const char* GetGeometryResPath() + { + return m_geometryResPath.c_str(); + } + void SetSkeletonName( const char* name ) + { + m_skeletonName = name; + } bool GetDynamicBoundingBox( const Matrix* boneTransforms, Vector3& minBounds, Vector3& maxBounds ) const; protected: - const std::string *m_pBoneList; - int m_numBones; + const std::string* m_pBoneList; + int m_numBones; //MR::Rig* m_boundRig; bool m_areAllMeshesBound; diff --git a/trinity/Tr2SkinnedModel_Blue.cpp b/trinity/Tr2SkinnedModel_Blue.cpp index b778a4a2c..ba813fbfe 100644 --- a/trinity/Tr2SkinnedModel_Blue.cpp +++ b/trinity/Tr2SkinnedModel_Blue.cpp @@ -7,21 +7,21 @@ BLUE_DEFINE( Tr2SkinnedModel ); const Be::ClassInfo* Tr2SkinnedModel::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2SkinnedModel, "" ) + EXPOSURE_BEGIN( Tr2SkinnedModel, "" ) MAP_INTERFACE( Tr2SkinnedModel ) MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( "geometryRes", m_geometryRes, "na", Be::READ ) + MAP_ATTRIBUTE( "geometryRes", m_geometryRes, "na", Be::READ ) MAP_ATTRIBUTE_WITH_CHOOSER( "geometryResPath", m_geometryResPath, "Resource path to geometry resource containing skeleton", Be::READWRITE | Be::NOTIFY | Be::PERSIST, NULL ) MAP_ATTRIBUTE( "skeletonName", m_skeletonName, "Name of skeleton to use", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) MAP_ATTRIBUTE( "skinScale", m_skinScale, "This is a scaling factor that is applied only to the skin. This is a workaround for an issue with rigs being built to a different scale from the meshes - will hopefully be fixed before too long", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "ResetAnimationBindings", - ResetBindings, - "ResetAnimationBindings()\n" - "Reset the animation bindings to update binding to meshes on the object." ) + MAP_METHOD_AND_WRAP( "ResetAnimationBindings", + ResetBindings, + "ResetAnimationBindings()\n" + "Reset the animation bindings to update binding to meshes on the object." ) - EXPOSURE_CHAINTO( Tr2Model ) + EXPOSURE_CHAINTO( Tr2Model ) } diff --git a/trinity/Tr2SkinnedObject.cpp b/trinity/Tr2SkinnedObject.cpp index c636f9e7e..fbcd22e4f 100644 --- a/trinity/Tr2SkinnedObject.cpp +++ b/trinity/Tr2SkinnedObject.cpp @@ -13,8 +13,8 @@ #include "Include/ITr2AnimationUpdater.h" #include "ITr2WorldTransformUpdater.h" -Tr2SkinnedObject::Tr2SkinnedObject(IRoot* lockobj) : - PARENTLOCK( m_transform ), +Tr2SkinnedObject::Tr2SkinnedObject( IRoot* lockobj ) : + PARENTLOCK( m_transform ), PARENTLOCK( m_curveSets ), m_skinningMatrixFrameDelay( 0 ), m_skinningMatrixQueueIndex( 0 ), @@ -22,7 +22,7 @@ Tr2SkinnedObject::Tr2SkinnedObject(IRoot* lockobj) : m_skinningMatrixCount( 0 ), m_skinningMatrixQueue( "Tr2SkinnedObject/m_skinningMatrixQueue" ), m_worldTransformsQueue( "Tr2SkinnedObject/m_worldTransformsQueue" ), - m_accumulatedTransformsQueue( "Tr2SkinnedObject/m_accumulatedTransformQueue"), + m_accumulatedTransformsQueue( "Tr2SkinnedObject/m_accumulatedTransformQueue" ), m_skinningMatrixQueueNeedsPriming( true ), m_display( true ), m_animRigToRenderRigMapping( NULL ), @@ -48,11 +48,12 @@ Tr2SkinnedObject::Tr2SkinnedObject(IRoot* lockobj) : Tr2SkinnedObject::~Tr2SkinnedObject() { - CCP_DELETE [] m_animRigToRenderRigMapping;; - CCP_DELETE [] m_renderRigToAnimRigMapping; + CCP_DELETE[] m_animRigToRenderRigMapping; + ; + CCP_DELETE[] m_renderRigToAnimRigMapping; m_animRigToRenderRigMapping = NULL; m_renderRigToAnimRigMapping = NULL; - + FreeSkinningMatrices(); } @@ -60,22 +61,22 @@ void Tr2SkinnedObject::PrePhysicsUpdate( Be::Time time ) { CCP_STATS_ZONE( __FUNCTION__ ); - const Be::Time deltaTime = time - m_lastUpdateTime; + const Be::Time deltaTime = time - m_lastUpdateTime; if( TimeAsFloat( deltaTime ) < m_updatePeriod ) { return; } if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL ) - { - return; - } + { + return; + } - if( m_animationUpdater != NULL ) - { + if( m_animationUpdater != NULL ) + { m_animationUpdater->PrePhysicsAnimation( time, m_transform ); } - + return; } @@ -83,7 +84,7 @@ void Tr2SkinnedObject::PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene { CCP_STATS_ZONE( __FUNCTION__ ); - const Be::Time deltaTime = time - m_lastUpdateTime; + const Be::Time deltaTime = time - m_lastUpdateTime; if( TimeAsFloat( deltaTime ) < m_updatePeriod ) { return; @@ -93,21 +94,21 @@ void Tr2SkinnedObject::PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( TimeAsDouble( time ) ); + ( *it )->Update( TimeAsDouble( time ) ); } - if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL ) - { - return; - } + if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL ) + { + return; + } if( m_animationUpdater != NULL ) - { + { m_animationUpdater->PostPhysicsAnimation( time, m_transform ); } UpdateBones( time, apexScene ); - + // Update the translation if we have a worldtranslation updater if( m_worldTransformUpdater != NULL ) @@ -116,7 +117,7 @@ void Tr2SkinnedObject::PostPhysicsUpdate( Be::Time time, Tr2ApexScene* apexScene } // Check LOD - + if( m_lod.UnloadLodIfNeeded( time, deltaTime ) ) { @@ -132,30 +133,30 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) m_hasDynamicBounds = false; - if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL ) - { - return; - } + if( m_visualModel == NULL || m_visualModel->GetSkeleton() == NULL ) + { + return; + } unsigned numBones = 0; bool isAnimRig = false; const std::string* boneList = NULL; - bool rebuildMapping = false; - TriGeometryResSkeletonData* skel = m_visualModel->GetSkeleton(); + bool rebuildMapping = false; + TriGeometryResSkeletonData* skel = m_visualModel->GetSkeleton(); if( m_animationUpdater != NULL ) - { - boneList = m_animationUpdater->GetAnimationBoneList( numBones ); + { + boneList = m_animationUpdater->GetAnimationBoneList( numBones ); if( boneList ) - { - rebuildMapping = ( numBones != m_skinningMatrixCount ); + { + rebuildMapping = ( numBones != m_skinningMatrixCount ); isAnimRig = numBones > 0; - } - } + } + } - if( boneList == NULL && skel != NULL ) - { + if( boneList == NULL && skel != NULL ) + { CCP_STATS_ZONE( "UpdateBones_BuildRenderRigBoneList" ); // Either the animationUpdater is NULL or it hasn't been set up fully yet, @@ -163,46 +164,44 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) // of a skinned model without an animation playing - it'll be static in // the bind pose. unsigned int numRenderRigBones = (unsigned int)skel->m_joints.size(); - if( m_numRenderRigBones != numRenderRigBones ) - { + if( m_numRenderRigBones != numRenderRigBones ) + { // Recreate mapping if the number of renderRigBones has changed, this is definitely hacky - m_numRenderRigBones = numRenderRigBones; - m_renderRigBoneList.resize(numRenderRigBones); - for(unsigned int i = 0; i < numRenderRigBones; ++i) - { - m_renderRigBoneList[i] = skel->m_joints[i].m_name; - } - rebuildMapping = true; - } + m_numRenderRigBones = numRenderRigBones; + m_renderRigBoneList.resize( numRenderRigBones ); + for( unsigned int i = 0; i < numRenderRigBones; ++i ) + { + m_renderRigBoneList[i] = skel->m_joints[i].m_name; + } + rebuildMapping = true; + } if( m_numRenderRigBones == 0 ) { // Guard against an empty skeleton - shouldn't happen but can // if assets are bad. - CCP_LOGERR - ( + CCP_LOGERR( "Tr2SkinnedObject '%s' has an empty skeleton in visual model from '%s'", m_name.c_str(), - m_visualModel->GetGeometryResPath() - ); + m_visualModel->GetGeometryResPath() ); m_renderRigBoneList.push_back( "Render_rig_missing" ); m_numRenderRigBones = 1; } - boneList = &m_renderRigBoneList[0]; - numBones = m_numRenderRigBones; - } + boneList = &m_renderRigBoneList[0]; + numBones = m_numRenderRigBones; + } if( boneList != m_boneList ) { rebuildMapping = true; - } + } // Cache the bone list pointer so we can determine when to rebuild mappings. m_boneList = boneList; m_visualModel->BindToRig( boneList, numBones, rebuildMapping ); - + if( rebuildMapping && skel != NULL ) { CCP_STATS_ZONE( "UpdateBones_RebuildMapping" ); @@ -213,8 +212,8 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) AllocateSkinningMatrices( numBones ); m_visualModel->ResetBindings(); - CCP_DELETE [] m_animRigToRenderRigMapping; - CCP_DELETE [] m_renderRigToAnimRigMapping; + CCP_DELETE[] m_animRigToRenderRigMapping; + CCP_DELETE[] m_renderRigToAnimRigMapping; m_animRigToRenderRigMapping = CCP_NEW( "Tr2SkinnedObject/m_animRigToRenderRigMapping" ) unsigned int[numBones]; m_renderRigToAnimRigMapping = CCP_NEW( "Tr2SkinnedObject/m_renderRigToAnimRigMapping" ) unsigned int[skel->m_joints.size()]; @@ -241,7 +240,7 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) ++m_skinningMatrixQueueIndex; m_skinningMatrixQueueIndex %= m_skinningMatrixQueue.size(); - const Matrix *accumulatedTransforms = NULL; + const Matrix* accumulatedTransforms = NULL; if( m_animationUpdater != NULL ) { @@ -282,7 +281,7 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) // refer to that joint. Matrix final; - if(accumulatedTransforms) + if( accumulatedTransforms ) { const Matrix& invBind = skel->m_joints[renderRigIx].m_inverseWorldTransform; @@ -293,7 +292,7 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) final = IdentityMatrix(); } - float* p = &dst[transformIx * 3*4]; + float* p = &dst[transformIx * 3 * 4]; *p++ = final._11; *p++ = final._21; *p++ = final._31; @@ -321,9 +320,9 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) unsigned int n = (unsigned int)m_skinningMatrixQueue.size() - 1; for( unsigned int ix = 0; ix < n; ++ix ) { - unsigned int queueIx = (m_skinningMatrixQueueIndex + ix) % m_skinningMatrixQueue.size(); + unsigned int queueIx = ( m_skinningMatrixQueueIndex + ix ) % m_skinningMatrixQueue.size(); float* copyDst = m_skinningMatrixQueue[queueIx]; - memcpy( copyDst, dst, m_skinningMatrixCount * sizeof(float)*3*4 ); + memcpy( copyDst, dst, m_skinningMatrixCount * sizeof( float ) * 3 * 4 ); m_worldTransformsQueue[queueIx] = m_transform; } @@ -333,7 +332,7 @@ void Tr2SkinnedObject::UpdateBones( Be::Time time, Tr2ApexScene* apexScene ) } } -unsigned Tr2SkinnedObject::GetBoneIndex( const std::string & boneName ) const +unsigned Tr2SkinnedObject::GetBoneIndex( const std::string& boneName ) const { if( !m_animationUpdater ) { @@ -381,7 +380,7 @@ void Tr2SkinnedObject::PrintAllBones() if( skel && !skel->m_joints.empty() ) { CCP_LOG( "RenderRig bones:" ); - for(unsigned int i = 0; i < skel->m_joints.size(); ++i) + for( unsigned int i = 0; i < skel->m_joints.size(); ++i ) { CCP_LOG( "%d - %s", i, skel->m_joints[i].m_name.c_str() ); } @@ -393,13 +392,13 @@ unsigned Tr2SkinnedObject::GetSkeletonTag() const return m_skeletonTag; } -const Matrix * Tr2SkinnedObject::GetBoneTransform( unsigned joint ) const +const Matrix* Tr2SkinnedObject::GetBoneTransform( unsigned joint ) const { if( joint >= m_skinningMatrixCount ) { return NULL; } - + return &m_accumulatedTransformsQueue[m_skinningMatrixQueueIndex][joint]; } @@ -415,14 +414,14 @@ Vector3 Tr2SkinnedObject::GetBonePosition( unsigned joint ) const return Vector3( 0, 0, 0 ); } - if( const Matrix* m = GetBoneTransform( joint )) + if( const Matrix* m = GetBoneTransform( joint ) ) { return Vector3( m->_41, m->_42, m->_43 ); } return Vector3( 0, 0, 0 ); } -void Tr2SkinnedObject::SetPosition(const Vector3 &pos) +void Tr2SkinnedObject::SetPosition( const Vector3& pos ) { m_transform._41 = pos.x; m_transform._42 = pos.y; @@ -431,9 +430,9 @@ void Tr2SkinnedObject::SetPosition(const Vector3 &pos) const Quaternion Tr2SkinnedObject::GetRotation() const { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); @@ -442,10 +441,10 @@ const Quaternion Tr2SkinnedObject::GetRotation() const void Tr2SkinnedObject::SetRotation( const Quaternion& rotQuat ) { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; - + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; + Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( tmpScale, rotQuat, tmpTranslation ); @@ -454,10 +453,10 @@ void Tr2SkinnedObject::SetRotation( const Quaternion& rotQuat ) const Vector3 Tr2SkinnedObject::GetScaling() const { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; - + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; + Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); return tmpScale; @@ -465,9 +464,9 @@ const Vector3 Tr2SkinnedObject::GetScaling() const void Tr2SkinnedObject::SetScaling( const Vector3& scaleVec ) { - Vector3 tmpScale; - Quaternion tmpRotation; - Vector3 tmpTranslation; + Vector3 tmpScale; + Quaternion tmpRotation; + Vector3 tmpTranslation; Decompose( tmpScale, tmpRotation, tmpTranslation, m_transform ); static_cast( m_transform ) = TransformationMatrix( scaleVec, tmpRotation, tmpTranslation ); @@ -588,7 +587,6 @@ void Tr2SkinnedObject::RenderDebugInfo( ITr2DebugRenderer2& renderer ) } } } - } void Tr2SkinnedObject::GetBatches( ITriRenderBatchAccumulator* batches, @@ -631,7 +629,7 @@ bool Tr2SkinnedObject::GetLocalBoundingBox( Vector3& min, Vector3& max ) const return true; } - // pass down to + // pass down to if( m_visualModel ) { return m_visualModel->GetBoundingBox( min, max ); @@ -684,7 +682,7 @@ void Tr2SkinnedObject::AllocateSkinningMatrices( unsigned int numBones ) unsigned int numToAllocate = m_skinningMatrixFrameDelay + 1; - float* p = CCP_NEW( "Tr2SkinnedObject/m_skinningMatrices" ) float[numBones * 3*4]; + float* p = CCP_NEW( "Tr2SkinnedObject/m_skinningMatrices" ) float[numBones * 3 * 4]; m_skinningMatrixQueue.push_back( p ); m_worldTransformsQueue.push_back( IdentityMatrix() ); @@ -699,14 +697,14 @@ void Tr2SkinnedObject::FreeSkinningMatrices() { for( SkinningMatrixQueue_t::iterator it = m_skinningMatrixQueue.begin(); it != m_skinningMatrixQueue.end(); ++it ) { - CCP_DELETE [] *it; + CCP_DELETE[] * it; } m_skinningMatrixQueue.clear(); m_worldTransformsQueue.clear(); for( AccumulatedTransforms_t::iterator it = m_accumulatedTransformsQueue.begin(); it != m_accumulatedTransformsQueue.end(); ++it ) { - CCP_DELETE [] *it; + CCP_DELETE[] * it; } m_accumulatedTransformsQueue.clear(); m_skinningMatrixQueueIndex = 0; @@ -727,7 +725,7 @@ float* Tr2SkinnedObject::GetSkinningMatrices() return NULL; } - unsigned int ix = (m_skinningMatrixQueueIndex - m_skinningMatrixFrameDelay + (unsigned int)m_skinningMatrixQueue.size()) % m_skinningMatrixQueue.size(); + unsigned int ix = ( m_skinningMatrixQueueIndex - m_skinningMatrixFrameDelay + (unsigned int)m_skinningMatrixQueue.size() ) % m_skinningMatrixQueue.size(); return m_skinningMatrixQueue[ix]; } @@ -738,7 +736,7 @@ const Matrix& Tr2SkinnedObject::GetSkinningTransform() const return m_transform; } - unsigned int ix = (m_skinningMatrixQueueIndex - m_skinningMatrixFrameDelay + (unsigned int)m_worldTransformsQueue.size()) % m_worldTransformsQueue.size(); + unsigned int ix = ( m_skinningMatrixQueueIndex - m_skinningMatrixFrameDelay + (unsigned int)m_worldTransformsQueue.size() ) % m_worldTransformsQueue.size(); return m_worldTransformsQueue[ix]; } @@ -761,7 +759,7 @@ bool Tr2SkinnedObject::OnModified( Be::Var* value ) void Tr2SkinnedObject::SetHighDetailModel( Tr2SkinnedModel* model ) { - m_lod.SetHighDetailModel( model ); + m_lod.SetHighDetailModel( model ); } void Tr2SkinnedObject::SetMediumDetailModel( Tr2SkinnedModel* model ) @@ -769,7 +767,7 @@ void Tr2SkinnedObject::SetMediumDetailModel( Tr2SkinnedModel* model ) m_lod.SetMediumDetailModel( model ); } -void Tr2SkinnedObject::SetLowDetailModel( Tr2SkinnedModel * model ) +void Tr2SkinnedObject::SetLowDetailModel( Tr2SkinnedModel* model ) { m_lod.SetLowDetailModel( model ); } @@ -782,11 +780,10 @@ void Tr2SkinnedObject::SetLOD( const TriFrustum* frustum ) } Vector4 boundingSphere; - if( GetBoundingSphere( boundingSphere ) - && frustum->IsSphereVisible( &boundingSphere, true ) ) + if( GetBoundingSphere( boundingSphere ) && frustum->IsSphereVisible( &boundingSphere, true ) ) { const float estimate = frustum->GetPixelSizeAccross( &boundingSphere ); - if( estimate >= 0.0f && estimate < 1000000.0f ) // block off any remaining silliness + if( estimate >= 0.0f && estimate < 1000000.0f ) // block off any remaining silliness { m_estimatedPixelDiameter = estimate; } @@ -795,10 +792,10 @@ void Tr2SkinnedObject::SetLOD( const TriFrustum* frustum ) Tr2SkinnedModel* model = m_lod.SetLOD( frustum, m_estimatedPixelDiameter ); // lod change? - if( model && model != m_visualModel ) // don't just compare lod numbers, actual model of a given lod might change as well (dynamic builders) + if( model && model != m_visualModel ) // don't just compare lod numbers, actual model of a given lod might change as well (dynamic builders) { m_visualModel = model; - + // this invalidates the rig-bindings, cause we switched to a new skeleton and therefore have to rebuild m_skinningMatrixCount = 0; diff --git a/trinity/Tr2SkinnedObject.h b/trinity/Tr2SkinnedObject.h index 632efb33b..6b358973d 100644 --- a/trinity/Tr2SkinnedObject.h +++ b/trinity/Tr2SkinnedObject.h @@ -3,7 +3,7 @@ #ifndef TR2SKINNEDOBJECT_H #define TR2SKINNEDOBJECT_H - + #include "ITr2Renderable.h" #include "ITr2SkinnedObject.h" #include "Tr2SkinnedModel.h" @@ -24,13 +24,12 @@ BLUE_DECLARE( Tr2ApexScene ); class TriFrustum; -class Tr2SkinnedObject: - public ITr2Renderable, - public ITr2SkinnedObject, - public IWorldPosition, - public IListNotify, - public INotify, - public ITr2DebugRenderable +class Tr2SkinnedObject : public ITr2Renderable, + public ITr2SkinnedObject, + public IWorldPosition, + public IListNotify, + public INotify, + public ITr2DebugRenderable { public: EXPOSE_TO_BLUE(); @@ -38,7 +37,7 @@ class Tr2SkinnedObject: using ITr2Renderable::Lock; using ITr2Renderable::Unlock; - Tr2SkinnedObject(IRoot* lockobj = NULL); + Tr2SkinnedObject( IRoot* lockobj = NULL ); ~Tr2SkinnedObject(); virtual void PrePhysicsUpdate( Be::Time time ); @@ -55,59 +54,86 @@ class Tr2SkinnedObject: void ResetAnimationBindings(); - const Matrix& GetTransform() const { return *m_transform.GetMatrix(); } + const Matrix& GetTransform() const + { + return *m_transform.GetMatrix(); + } - const Vector3& GetPosition() const { return *(reinterpret_cast(&m_transform._41)); } - virtual void SetPosition(const Vector3 &pos); + const Vector3& GetPosition() const + { + return *( reinterpret_cast( &m_transform._41 ) ); + } + virtual void SetPosition( const Vector3& pos ); const Quaternion GetRotation() const; - virtual void SetRotation( const Quaternion &rotQuat ); + virtual void SetRotation( const Quaternion& rotQuat ); const Vector3 GetScaling() const; - virtual void SetScaling( const Vector3 &scaleVec ); - + virtual void SetScaling( const Vector3& scaleVec ); + bool GetLocalBoundingBox( Vector3& min, Vector3& max ) const; bool GetClippedWorldBoundingObb( const Matrix& localToWorld, Vector3& x, Vector3& y, Vector3& z, Vector3& center, Vector3& sizes, TriFrustum* cameraFrustum ); unsigned int GetSkinningMatrixFrameDelay() const; - void SetSkinningMatrixFrameDelay(unsigned int val); + void SetSkinningMatrixFrameDelay( unsigned int val ); // lod virtual void SetLOD( const TriFrustum* frustum ); void SetHighDetailModel( Tr2SkinnedModel* model ); void SetMediumDetailModel( Tr2SkinnedModel* model ); void SetLowDetailModel( Tr2SkinnedModel* model ); - int GetCurrentLod() const { return m_lod.GetCurrentLod(); } + int GetCurrentLod() const + { + return m_lod.GetCurrentLod(); + } // for lod, used to estimate projected pixel size and hence lod. - virtual bool GetBoundingSphere( Vector4& /*sphere*/ ) const { return false; } - virtual bool GetWorldBoundingBox( Vector3& /*min*/, Vector3& /*max*/ ) const { return false; } + virtual bool GetBoundingSphere( Vector4& /*sphere*/ ) const + { + return false; + } + virtual bool GetWorldBoundingBox( Vector3& /*min*/, Vector3& /*max*/ ) const + { + return false; + } ////////////////////////////////////////////////////////////////////////// // IWorldPosition - virtual Vector3 GetWorldPosition() { return GetPosition(); } - virtual Quaternion GetWorldRotation() { return GetRotation(); } + virtual Vector3 GetWorldPosition() + { + return GetPosition(); + } + virtual Quaternion GetWorldRotation() + { + return GetRotation(); + } ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable - virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); + virtual void GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, const Tr2PerObjectData* perObjectData, Tr2RenderReason reason = TR2RENDERREASON_NORMAL ); virtual bool HasTransparentBatches(); - virtual float GetSortValue() { return 0.0f; }; + virtual float GetSortValue() + { + return 0.0f; + }; - virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) { return NULL; }; + virtual Tr2PerObjectData* GetPerObjectData( ITriRenderBatchAccumulator* accumulator ) + { + return NULL; + }; ////////////////////////////////////////////////////////////////////////// // IListNotify - virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); + virtual void OnListModified( long event, ssize_t key, ssize_t key2, IRoot* value, const IList* theList ); ///////////////////////////////////////////////////////////////////////////////////// // INotify bool OnModified( Be::Var* val ); - + // find the bone with this name in the animation rig - virtual unsigned GetBoneIndex( const std::string & boneName ) const; - virtual const Matrix * GetBoneTransform( unsigned joint ) const; + virtual unsigned GetBoneIndex( const std::string& boneName ) const; + virtual const Matrix* GetBoneTransform( unsigned joint ) const; /// \return a number that increases anytime the bone bindings get invalidated (ie due to lod) virtual unsigned GetSkeletonTag() const; /// simpler version for python use @@ -124,24 +150,27 @@ class Tr2SkinnedObject: void UpdatePerObjectData(); protected: - ITr2AnimationUpdaterPtr m_animationUpdater; - ITr2WorldTransformUpdaterPtr m_worldTransformUpdater; + ITr2AnimationUpdaterPtr m_animationUpdater; + ITr2WorldTransformUpdaterPtr m_worldTransformUpdater; - void ClearBoneInfo(); + void ClearBoneInfo(); AxisAlignedBoundingBox GetBoundingBoxInLocalSpace() const; // Utility function to determine whether to accumulate render batches for this object - virtual bool DoDisplay( void ) const { return m_display; } + virtual bool DoDisplay( void ) const + { + return m_display; + } std::string m_name; // Transform that simply represents position, scale and rotation // as a 4x4 matrix. - PTriMatrix m_transform; + PTriMatrix m_transform; Tr2SkinnedModelPtr m_visualModel; - unsigned m_skeletonTag; + unsigned m_skeletonTag; // Cloth simulation is based off the skinning matrices // but can introduce a frame delay of 1-3 frames. To @@ -153,7 +182,7 @@ class Tr2SkinnedObject: typedef TrackableStdVector SkinningMatrixQueue_t; typedef TrackableStdVector AccumulatedTransforms_t; typedef TrackableStdVector WorldTransforms_t; - + // Queue of matrices used for skinning SkinningMatrixQueue_t m_skinningMatrixQueue; @@ -172,8 +201,8 @@ class Tr2SkinnedObject: unsigned int* m_animRigToRenderRigMapping; unsigned int* m_renderRigToAnimRigMapping; - TrackableStdVector m_renderRigBoneList; - unsigned int m_numRenderRigBones; + TrackableStdVector m_renderRigBoneList; + unsigned int m_numRenderRigBones; // This is set when the frame queue is initialized. In the first // animation update the queue is then primed with copies of the @@ -186,7 +215,7 @@ class Tr2SkinnedObject: Vector3 m_lastTranslation; // LOD selection - Tr2SkinnedObjectLod m_lod; + Tr2SkinnedObjectLod m_lod; float m_estimatedPixelDiameter; // remember the time from the last Update call Be::Time m_lastUpdateTime; @@ -203,7 +232,7 @@ class Tr2SkinnedObject: Vector3 m_minBounds; Vector3 m_maxBounds; - float m_updatePeriod; + float m_updatePeriod; }; TYPEDEF_BLUECLASS( Tr2SkinnedObject ); diff --git a/trinity/Tr2SkinnedObjectLOD.cpp b/trinity/Tr2SkinnedObjectLOD.cpp index 9a83603c3..e8c7d787c 100644 --- a/trinity/Tr2SkinnedObjectLOD.cpp +++ b/trinity/Tr2SkinnedObjectLOD.cpp @@ -12,7 +12,7 @@ float g_skinnedMediumDetailThreshold = 500.0f; float g_unloadLODMaxFrametime = 0.1f; float g_skinnedHighMediumMargin = 0.0f; -float g_skinnedMediumLowMargin = 0.0f; +float g_skinnedMediumLowMargin = 0.0f; bool g_debugLODShader = false; TRI_REGISTER_SETTING( "debugLODShader", g_debugLODShader ); @@ -20,19 +20,19 @@ TRI_REGISTER_SETTING( "debugLODShader", g_debugLODShader ); // lod resource unloading static const double AVATAR_RESOURCE_UNLOADING_TIME_THRESHOLD = 10.0; -TRI_REGISTER_SETTING( "skinnedLowDetailThreshold", g_skinnedLowDetailThreshold ); -TRI_REGISTER_SETTING( "skinnedMediumDetailThreshold", g_skinnedMediumDetailThreshold ); -TRI_REGISTER_SETTING( "skinnedHighMediumMargin", g_skinnedHighMediumMargin ); -TRI_REGISTER_SETTING( "skinnedMediumLowMargin", g_skinnedMediumLowMargin ); -TRI_REGISTER_SETTING( "unloadLODMaxFrametime", g_unloadLODMaxFrametime ); +TRI_REGISTER_SETTING( "skinnedLowDetailThreshold", g_skinnedLowDetailThreshold ); +TRI_REGISTER_SETTING( "skinnedMediumDetailThreshold", g_skinnedMediumDetailThreshold ); +TRI_REGISTER_SETTING( "skinnedHighMediumMargin", g_skinnedHighMediumMargin ); +TRI_REGISTER_SETTING( "skinnedMediumLowMargin", g_skinnedMediumLowMargin ); +TRI_REGISTER_SETTING( "unloadLODMaxFrametime", g_unloadLODMaxFrametime ); -CCP_STATS_DECLARE( countSkinnedLowLOD, "Trinity/SkinnedObject/LowLOD", true, CST_COUNTER_LOW, "Skinned object count in Low LOD."); -CCP_STATS_DECLARE( countSkinnedMediumLOD, "Trinity/SkinnedObject/MediumLOD", true, CST_COUNTER_LOW, "Skinned object count in Medium LOD."); -CCP_STATS_DECLARE( countSkinnedHighLOD, "Trinity/SkinnedObject/HighLOD", true, CST_COUNTER_LOW, "Skinned object count in High LOD."); -CCP_STATS_DECLARE( countUnderConstructionLOD, "Trinity/SkinnedObject/UnderConstructionLOD", true, CST_COUNTER_LOW, "Skinned object whose LOD is under construction."); +CCP_STATS_DECLARE( countSkinnedLowLOD, "Trinity/SkinnedObject/LowLOD", true, CST_COUNTER_LOW, "Skinned object count in Low LOD." ); +CCP_STATS_DECLARE( countSkinnedMediumLOD, "Trinity/SkinnedObject/MediumLOD", true, CST_COUNTER_LOW, "Skinned object count in Medium LOD." ); +CCP_STATS_DECLARE( countSkinnedHighLOD, "Trinity/SkinnedObject/HighLOD", true, CST_COUNTER_LOW, "Skinned object count in High LOD." ); +CCP_STATS_DECLARE( countUnderConstructionLOD, "Trinity/SkinnedObject/UnderConstructionLOD", true, CST_COUNTER_LOW, "Skinned object whose LOD is under construction." ); -Tr2SkinnedObjectLod::Tr2SkinnedObjectLod(/*IRoot* lockobj*/) : +Tr2SkinnedObjectLod::Tr2SkinnedObjectLod( /*IRoot* lockobj*/ ) : m_allowLodSelection( false ), m_currentLod( -1 ) { @@ -55,7 +55,7 @@ bool Tr2SkinnedObjectLod::OnModified( Be::Var* value ) void Tr2SkinnedObjectLod::PopulateLods() { // More clear and explicit to have some LODs available, some not, and then - // be smart about where visualModel can point at + // be smart about where visualModel can point at if( m_highDetailProxy || m_mediumDetailProxy || m_lowDetailProxy ) { m_allowLodSelection = true; @@ -63,7 +63,7 @@ void Tr2SkinnedObjectLod::PopulateLods() } else { - m_allowLodSelection = false; + m_allowLodSelection = false; } } @@ -82,15 +82,15 @@ bool Tr2SkinnedObjectLod::UnloadLodIfNeeded( const Be::Time time, const Be::Time // Never unload the currently used proxy if( m_highDetailProxy ) { - m_highDetailProxy->Update( time, (m_currentLod == 0) ? 0 : timeout ); + m_highDetailProxy->Update( time, ( m_currentLod == 0 ) ? 0 : timeout ); } if( m_mediumDetailProxy ) { - m_mediumDetailProxy->Update( time, (m_currentLod == 1) ? 0 : timeout ); + m_mediumDetailProxy->Update( time, ( m_currentLod == 1 ) ? 0 : timeout ); } if( m_lowDetailProxy ) { - m_lowDetailProxy->Update( time, (m_currentLod == 2) ? 0 : timeout ); + m_lowDetailProxy->Update( time, ( m_currentLod == 2 ) ? 0 : timeout ); } return false; @@ -98,17 +98,17 @@ bool Tr2SkinnedObjectLod::UnloadLodIfNeeded( const Be::Time time, const Be::Time Tr2SkinnedModel* Tr2SkinnedObjectLod::GetHighDetailModel() { - return m_highDetailProxy ? dynamic_cast( m_highDetailProxy->GetObject( ) ) : 0; + return m_highDetailProxy ? dynamic_cast( m_highDetailProxy->GetObject() ) : 0; } Tr2SkinnedModel* Tr2SkinnedObjectLod::GetMediumDetailModel() { - return m_mediumDetailProxy ? dynamic_cast( m_mediumDetailProxy->GetObject( ) ) : 0; + return m_mediumDetailProxy ? dynamic_cast( m_mediumDetailProxy->GetObject() ) : 0; } Tr2SkinnedModel* Tr2SkinnedObjectLod::GetLowDetailModel() { - return m_lowDetailProxy ? dynamic_cast( m_lowDetailProxy->GetObject( ) ) : 0; + return m_lowDetailProxy ? dynamic_cast( m_lowDetailProxy->GetObject() ) : 0; } void Tr2SkinnedObjectLod::OnModelChanged( Tr2SkinnedModel* model ) @@ -177,7 +177,7 @@ void Tr2SkinnedObjectLod::SetMediumDetailModel( Tr2SkinnedModel* model ) } } -void Tr2SkinnedObjectLod::SetLowDetailModel( Tr2SkinnedModel * model ) +void Tr2SkinnedObjectLod::SetLowDetailModel( Tr2SkinnedModel* model ) { if( !m_lowDetailProxy ) { @@ -217,26 +217,25 @@ Tr2SkinnedModel* Tr2SkinnedObjectLod::SetLOD( const TriFrustum* frustum, float e } } - const int high = 0; - const int medium = 1; - const int low = 2; + const int high = 0; + const int medium = 1; + const int low = 2; - int choice[3] = { high, medium, low }; // order of preferred LOD. set up for high lod by default + int choice[3] = { high, medium, low }; // order of preferred LOD. set up for high lod by default - if( stickyLod == 2 || + if( stickyLod == 2 || // small enough for low lod? - ( m_currentLod >= 2 && estimatedPixelDiameter <= g_skinnedLowDetailThreshold + g_skinnedMediumLowMargin ) || // before going up, add some margin - ( m_currentLod < 2 && estimatedPixelDiameter <= g_skinnedLowDetailThreshold - g_skinnedMediumLowMargin ) ) + ( m_currentLod >= 2 && estimatedPixelDiameter <= g_skinnedLowDetailThreshold + g_skinnedMediumLowMargin ) || // before going up, add some margin + ( m_currentLod < 2 && estimatedPixelDiameter <= g_skinnedLowDetailThreshold - g_skinnedMediumLowMargin ) ) { choice[0] = low; choice[1] = medium; choice[2] = high; } - else - if( stickyLod == 1 || - // medium lod? - ( m_currentLod >= 1 && estimatedPixelDiameter <= g_skinnedMediumDetailThreshold + g_skinnedHighMediumMargin ) || // before going up, add some margin - ( m_currentLod < 1 && estimatedPixelDiameter <= g_skinnedMediumDetailThreshold - g_skinnedHighMediumMargin ) ) + else if( stickyLod == 1 || + // medium lod? + ( m_currentLod >= 1 && estimatedPixelDiameter <= g_skinnedMediumDetailThreshold + g_skinnedHighMediumMargin ) || // before going up, add some margin + ( m_currentLod < 1 && estimatedPixelDiameter <= g_skinnedMediumDetailThreshold - g_skinnedHighMediumMargin ) ) { choice[0] = medium; choice[1] = low; @@ -252,14 +251,14 @@ Tr2SkinnedModel* Tr2SkinnedObjectLod::SetLOD( const TriFrustum* frustum, float e Tr2SkinnedModel* model = NULL; bool modelIsTemporary = true; - for (unsigned i = 0; i != 3; ++i) + for( unsigned i = 0; i != 3; ++i ) { const int lod = choice[i]; if( proxy[lod] ) - if ( !model || + if( !model || ( modelIsTemporary && proxy[lod]->IsResident() ) ) { - model = dynamic_cast( proxy[lod]->GetObject( ) ); + model = dynamic_cast( proxy[lod]->GetObject() ); selectedLod = lod; modelIsTemporary = proxy[lod]->IsTemporary(); } @@ -274,18 +273,18 @@ Tr2SkinnedModel* Tr2SkinnedObjectLod::SetLOD( const TriFrustum* frustum, float e #if CCP_STATS_ENABLED switch( m_currentLod ) { - case high: - CCP_STATS_INC( countSkinnedHighLOD ); - break; - case medium: - CCP_STATS_INC( countSkinnedMediumLOD ); - break; - case low: - CCP_STATS_INC( countSkinnedLowLOD ); - break; - - default: - CCP_STATS_INC( countSkinnedHighLOD ); + case high: + CCP_STATS_INC( countSkinnedHighLOD ); + break; + case medium: + CCP_STATS_INC( countSkinnedMediumLOD ); + break; + case low: + CCP_STATS_INC( countSkinnedLowLOD ); + break; + + default: + CCP_STATS_INC( countSkinnedHighLOD ); } #endif diff --git a/trinity/Tr2SkinnedObjectLOD.h b/trinity/Tr2SkinnedObjectLOD.h index 27070ba0a..41b4f1a7b 100644 --- a/trinity/Tr2SkinnedObjectLOD.h +++ b/trinity/Tr2SkinnedObjectLOD.h @@ -15,13 +15,13 @@ class TriFrustum; class Tr2SkinnedObjectLod { public: - //EXPOSE_TO_BLUE(); + //EXPOSE_TO_BLUE(); //using IInitialize::Lock; //using IInitialize::Unlock; - Tr2SkinnedObjectLod(/*IRoot* lockobj = NULL*/); - ~Tr2SkinnedObjectLod(); + Tr2SkinnedObjectLod( /*IRoot* lockobj = NULL*/ ); + ~Tr2SkinnedObjectLod(); ///////////////////////////////////////////////////////////////////////////////////// // INotify @@ -29,18 +29,27 @@ class Tr2SkinnedObjectLod Tr2SkinnedModel* SetLOD( const TriFrustum* frustum, float estimatedPixelDiameter ); // note: these are legacy from the old LOD in WoD, they actually create a proxy if there isn't one. - void SetHighDetailModel ( Tr2SkinnedModel* model ); + void SetHighDetailModel( Tr2SkinnedModel* model ); void SetMediumDetailModel( Tr2SkinnedModel* model ); - void SetLowDetailModel ( Tr2SkinnedModel* model ); + void SetLowDetailModel( Tr2SkinnedModel* model ); /// \param time current time /// \param deltaTime time since the last update; used to avoid unloading data due to framerate spikes / freezing up, where unload/load could only make it worse. /// \return true if the current lod was being unloaded, and the user should clear its visual model pointer - bool UnloadLodIfNeeded ( Be::Time time, Be::Time deltaTime ); + bool UnloadLodIfNeeded( Be::Time time, Be::Time deltaTime ); // SetLOD computes a best fit; use SetCurrentLod to just set a number directly. Used for cloth trickery. - void SetCurrentLod(int lod) { m_currentLod = lod; } - int GetCurrentLod() const { return m_currentLod; } - bool HaveLodSetup() const { return m_allowLodSelection; } + void SetCurrentLod( int lod ) + { + m_currentLod = lod; + } + int GetCurrentLod() const + { + return m_currentLod; + } + bool HaveLodSetup() const + { + return m_allowLodSelection; + } void PopulateLods(); @@ -51,19 +60,18 @@ class Tr2SkinnedObjectLod bool IsSimulatingCloth( const int maxClothLod ) const; void OnModelChanged( Tr2SkinnedModel* model ); - -private: +private: Tr2SkinnedModel* GetHighDetailModel(); Tr2SkinnedModel* GetMediumDetailModel(); Tr2SkinnedModel* GetLowDetailModel(); // LOD selection ok? only true if at least one model/proxy is available bool m_allowLodSelection; - // + // int m_currentLod; -public: // public for blue exposure in the wrapper +public: // public for blue exposure in the wrapper IBlueObjectProxyPtr m_highDetailProxy; IBlueObjectProxyPtr m_lowDetailProxy; IBlueObjectProxyPtr m_mediumDetailProxy; diff --git a/trinity/Tr2SkinnedObject_Blue.cpp b/trinity/Tr2SkinnedObject_Blue.cpp index 74fd006e7..8c15157d5 100644 --- a/trinity/Tr2SkinnedObject_Blue.cpp +++ b/trinity/Tr2SkinnedObject_Blue.cpp @@ -9,37 +9,31 @@ BLUE_DEFINE_ABSTRACT( Tr2SkinnedObject ); const Be::ClassInfo* Tr2SkinnedObject::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2SkinnedObject, "" ) + EXPOSURE_BEGIN( Tr2SkinnedObject, "" ) MAP_INTERFACE( Tr2SkinnedObject ) MAP_INTERFACE( ITr2Renderable ) - MAP_INTERFACE( IWorldPosition ) + MAP_INTERFACE( IWorldPosition ) MAP_INTERFACE( IListNotify ) MAP_ATTRIBUTE( "name", m_name, "Name of this object", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "display", m_display, "Whether or not to display the object", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "skinningMatrixCount", m_skinningMatrixCount, "Size of skeleton used for skinning", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "renderRigBoneCount", m_numRenderRigBones, "Size of skeleton in the visual model", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( - "curveSets", - m_curveSets, - "Curvesets for animating things", - Be::READ | Be::PERSIST - ) + MAP_ATTRIBUTE( + "curveSets", + m_curveSets, + "Curvesets for animating things", + Be::READ | Be::PERSIST ) MAP_ATTRIBUTE( "animationUpdater", m_animationUpdater, "Object that implements ITr2AnimationUpdater interface that provides bone transforms and bone names", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "worldTransformUpdater", m_worldTransformUpdater, "Object that implements ITr2WorldTransformUpdater to update this objects transform for rendering", Be::READWRITE | Be::PERSIST ) @@ -52,69 +46,61 @@ const Be::ClassInfo* Tr2SkinnedObject::ExposeToBlue() // lod MAP_ATTRIBUTE( "estimatedPixelDiameter", m_estimatedPixelDiameter, "value for LOD selection", Be::READ ) MAP_PROPERTY_READONLY( "currentLod", GetCurrentLod, "the current LOD" ) - MAP_ATTRIBUTE( "lowDetailModel", m_lod.m_lowDetailProxy, "Proxy for a skinned model used for rendering in low detail." , Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "mediumDetailModel", m_lod.m_mediumDetailProxy, "Proxy for a skinned model used for rendering in medium detail.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) - MAP_ATTRIBUTE( "highDetailModel", m_lod.m_highDetailProxy, "Proxy for a skinned model used for rendering in high detail.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "lowDetailModel", m_lod.m_lowDetailProxy, "Proxy for a skinned model used for rendering in low detail.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "mediumDetailModel", m_lod.m_mediumDetailProxy, "Proxy for a skinned model used for rendering in medium detail.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "highDetailModel", m_lod.m_highDetailProxy, "Proxy for a skinned model used for rendering in high detail.", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "useDynamicBounds", m_useDynamicBounds, "Use bounds from animated bones rather than bouds of meshes in binding pose.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "useExplicitBounds", m_useExplicitBounds, "Use explicitely specified bounding box or the one coming from visualModel.", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "explicitMinBounds", + m_minBounds, + "Explicitely set min bounds of an object in local space (only used when useExplicitBounds is True).", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( + "explicitMaxBounds", + m_maxBounds, + "Explicitely set max bounds of an object in local space (only used when useExplicitBounds is True).", + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( - "explicitMinBounds", - m_minBounds, - "Explicitely set min bounds of an object in local space (only used when useExplicitBounds is True).", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE( - "explicitMaxBounds", - m_maxBounds, - "Explicitely set max bounds of an object in local space (only used when useExplicitBounds is True).", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - - MAP_ATTRIBUTE - ( - "frameDelay", + "frameDelay", m_skinningMatrixFrameDelay, "Cloth simulation can introduce a frame delay between animation update and\n" "rendering. Changing the 'parallelPhysxMeshSkinning' and 'parallelMeshMeshSkinning'\n" "flags affects the frame delay.", - Be::READ - ) + Be::READ ) MAP_METHOD_AND_WRAP( "GetBoundingBoxInLocalSpace", - GetBoundingBoxInLocalSpace, - "Gets the bounding box in local space" ) - - MAP_METHOD_AND_WRAP( "ResetAnimationBindings", - ResetAnimationBindings, - "ResetAnimationBindings()\n" - "Reset the animation bindings to update binding to meshes on the object." ) - - MAP_METHOD_AND_WRAP( "PrintAllBones" , PrintAllBones , "send a list of all bones in the current animation skeleton and render rig to LOGRELEASE" ) - - MAP_METHOD_AND_WRAP( - "GetBoneIndex" , - GetBoneIndex , - "returns the joint index in the anim rig of this bone\n" - ":param name: bone name" - ) - MAP_METHOD_AND_WRAP( "GetSkeletonTag" , GetSkeletonTag , "returns a counter that goes up every time the skeleton rig got invalidated" ) - MAP_METHOD_AND_WRAP( - "GetBonePosition" , - GetBonePosition , + GetBoundingBoxInLocalSpace, + "Gets the bounding box in local space" ) + + MAP_METHOD_AND_WRAP( "ResetAnimationBindings", + ResetAnimationBindings, + "ResetAnimationBindings()\n" + "Reset the animation bindings to update binding to meshes on the object." ) + + MAP_METHOD_AND_WRAP( "PrintAllBones", PrintAllBones, "send a list of all bones in the current animation skeleton and render rig to LOGRELEASE" ) + + MAP_METHOD_AND_WRAP( + "GetBoneIndex", + GetBoneIndex, + "returns the joint index in the anim rig of this bone\n" + ":param name: bone name" ) + MAP_METHOD_AND_WRAP( "GetSkeletonTag", GetSkeletonTag, "returns a counter that goes up every time the skeleton rig got invalidated" ) + MAP_METHOD_AND_WRAP( + "GetBonePosition", + GetBonePosition, "returns the position of this bone in world space\n" - ":param idx: bone index" - ) + ":param idx: bone index" ) MAP_ATTRIBUTE( "updatePeriod", m_updatePeriod, "How much time should elapse before the animation is updated?", Be::READWRITE ) diff --git a/trinity/Tr2SolidSet.cpp b/trinity/Tr2SolidSet.cpp index 955c3e630..56062564d 100644 --- a/trinity/Tr2SolidSet.cpp +++ b/trinity/Tr2SolidSet.cpp @@ -8,7 +8,7 @@ CCP_STATS_DECLARED_ELSEWHERE( primitiveCount ); using namespace Tr2RenderContextEnum; -Tr2SolidSet::Tr2SolidSet( IRoot* lockobj /*= NULL*/ ): +Tr2SolidSet::Tr2SolidSet( IRoot* lockobj /*= NULL*/ ) : Tr2PrimitiveSet( lockobj ), m_currentSubmittedTriangleCount( 0 ), m_maxCurrentTriangleCount( 0 ) @@ -58,7 +58,7 @@ bool Tr2SolidSet::OnPrepareResources() if( m_triangles.size() ) { - if( !m_vertexBuffer.IsValid() || (m_currentSubmittedTriangleCount < m_triangles.size()) ) + if( !m_vertexBuffer.IsValid() || ( m_currentSubmittedTriangleCount < m_triangles.size() ) ) { USE_MAIN_THREAD_RENDER_CONTEXT(); CR_RETURN_VAL( @@ -68,34 +68,34 @@ bool Tr2SolidSet::OnPrepareResources() Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, - renderContext ) - , false ); + renderContext ), + false ); m_currentSubmittedTriangleCount = (unsigned int)m_triangles.size(); } std::vector vertexBuffer( m_triangles.size() * 3 ); - + // Copy our user data to the buffer unsigned int j = 0; - for( unsigned int i = 0; i < m_triangles.size(); i++,j+=3 ) - { + for( unsigned int i = 0; i < m_triangles.size(); i++, j += 3 ) + { vertexBuffer[j].m_color = m_triangles[i].m_color1; vertexBuffer[j].m_position = m_triangles[i].m_position1; vertexBuffer[j].m_normal = m_triangles[i].m_normal; - vertexBuffer[j+1].m_color = m_triangles[i].m_color2; - vertexBuffer[j+1].m_position = m_triangles[i].m_position2; - vertexBuffer[j+1].m_normal = m_triangles[i].m_normal; + vertexBuffer[j + 1].m_color = m_triangles[i].m_color2; + vertexBuffer[j + 1].m_position = m_triangles[i].m_position2; + vertexBuffer[j + 1].m_normal = m_triangles[i].m_normal; - vertexBuffer[j+2].m_color = m_triangles[i].m_color3; - vertexBuffer[j+2].m_position = m_triangles[i].m_position3; - vertexBuffer[j+2].m_normal = m_triangles[i].m_normal; + vertexBuffer[j + 2].m_color = m_triangles[i].m_color3; + vertexBuffer[j + 2].m_position = m_triangles[i].m_position3; + vertexBuffer[j + 2].m_normal = m_triangles[i].m_normal; } - + // Create a bounding sphere Vector3 center( 0.0f, 0.0f, 0.0f ); float radius = 0.0f; - ComputeBoundingSphere( &vertexBuffer[0].m_position, (unsigned int)m_triangles.size()*3, sizeof(TriangleVertex), center, radius ); + ComputeBoundingSphere( &vertexBuffer[0].m_position, (unsigned int)m_triangles.size() * 3, sizeof( TriangleVertex ), center, radius ); TriangleVertex* data; CR_RETURN_VAL( m_vertexBuffer.MapForWriting( data, renderContext ), false ); @@ -113,7 +113,7 @@ bool Tr2SolidSet::OnPrepareResources() Vector3 Tr2SolidSet::GetCenterOfMass( void ) { Vector3 result = Vector3( 0.0f, 0.0f, 0.0f ); - for( unsigned int i = 0; i < m_triangles.size(); i ++ ) + for( unsigned int i = 0; i < m_triangles.size(); i++ ) { result.x += m_triangles[i].m_position1.x; result.x += m_triangles[i].m_position2.x; @@ -126,9 +126,9 @@ Vector3 Tr2SolidSet::GetCenterOfMass( void ) result.z += m_triangles[i].m_position3.z; } - result.x /= (m_triangles.size()*3); - result.y /= (m_triangles.size()*3); - result.z /= (m_triangles.size()*3); + result.x /= ( m_triangles.size() * 3 ); + result.y /= ( m_triangles.size() * 3 ); + result.z /= ( m_triangles.size() * 3 ); result = TransformCoord( result, m_worldTransform ); return result; } @@ -155,7 +155,7 @@ void Tr2SolidSet::GetBatchesImpl( ITriRenderBatchAccumulator* accumulator, const accumulator->Commit( batch ); } -void Tr2SolidSet::AddTriangle( const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2, const Vector3& position3, const Vector4& color3 ) +void Tr2SolidSet::AddTriangle( const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2, const Vector3& position3, const Vector4& color3 ) { TriangleData newTriangle; @@ -166,8 +166,8 @@ void Tr2SolidSet::AddTriangle( const Vector3& position1, const Vector4& color1, newTriangle.m_position3 = position3; newTriangle.m_color3 = color3; - Vector3 dir13(position1 - position3); - Vector3 dir21(position2 - position1); + Vector3 dir13( position1 - position3 ); + Vector3 dir21( position2 - position1 ); newTriangle.m_normal = Cross( dir13, dir21 ); @@ -179,7 +179,7 @@ bool Tr2SolidSet::SubmitChanges() { if( m_triangles.size() > m_maxCurrentTriangleCount ) { - // increase the size of the buffer + // increase the size of the buffer m_maxCurrentTriangleCount = (unsigned int)m_triangles.capacity(); ReleaseResources( TRISTORAGE_ALL ); } @@ -193,7 +193,7 @@ bool Tr2SolidSet::SubmitChanges() void Tr2SolidSet::SetCurrentColor( Color& val ) { - for ( unsigned int i = 0; i < m_triangles.size(); i++ ) + for( unsigned int i = 0; i < m_triangles.size(); i++ ) { m_triangles[i].m_color1 = val; m_triangles[i].m_color2 = val; diff --git a/trinity/Tr2SolidSet.h b/trinity/Tr2SolidSet.h index 0a0ec31b8..217a0ce88 100644 --- a/trinity/Tr2SolidSet.h +++ b/trinity/Tr2SolidSet.h @@ -26,9 +26,9 @@ struct TriangleVertex Color m_color; }; -BLUE_CLASS( Tr2SolidSet ): +BLUE_CLASS( Tr2SolidSet ) : public IInitialize, - public Tr2PrimitiveSet, + public Tr2PrimitiveSet, public Tr2DeviceResource { public: @@ -40,15 +40,18 @@ BLUE_CLASS( Tr2SolidSet ): ////////////////////////////////////////////////////////////////////////////////////// // IInitialize bool Initialize(); - + ////////////////////////////////////////////////////////////////////////////////////// // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); #if TRINITYDEV - virtual void GetDescription( std::string& desc ) { desc = ""; } + virtual void GetDescription( std::string & desc ) + { + desc = ""; + } #endif - + Vector3 GetCenterOfMass( void ); protected: @@ -56,19 +59,20 @@ BLUE_CLASS( Tr2SolidSet ): private: virtual bool OnPrepareResources(); - + // Hold on to the submitted triangles and the current count std::vector m_triangles; unsigned int m_maxCurrentTriangleCount; unsigned int m_currentSubmittedTriangleCount; + public: // Python interface void AddTriangle( const Vector3& position1, const Vector4& color1, const Vector3& position2, const Vector4& color2, const Vector3& position3, const Vector4& color3 ); void ClearTriangles(); - void SetCurrentColor( Color& val ); + void SetCurrentColor( Color & val ); bool SubmitChanges(); }; -TYPEDEF_BLUECLASS(Tr2SolidSet); +TYPEDEF_BLUECLASS( Tr2SolidSet ); #endif diff --git a/trinity/Tr2SolidSet_Blue.cpp b/trinity/Tr2SolidSet_Blue.cpp index 6e217e243..d748426f2 100644 --- a/trinity/Tr2SolidSet_Blue.cpp +++ b/trinity/Tr2SolidSet_Blue.cpp @@ -7,26 +7,20 @@ BLUE_DEFINE( Tr2SolidSet ); const Be::ClassInfo* Tr2SolidSet::ExposeToBlue() { - EXPOSURE_BEGIN(Tr2SolidSet, "no comment") + EXPOSURE_BEGIN( Tr2SolidSet, "no comment" ) MAP_INTERFACE( Tr2SolidSet ) - MAP_INTERFACE( IInitialize ) + MAP_INTERFACE( IInitialize ) MAP_INTERFACE( Tr2PrimitiveSet ) - MAP_METHOD_AND_WRAP( "AddTriangle", AddTriangle, - "( pos1, color1, pos2, color2, pos3, color3 )\n" - "Adds a triangle to the triangle set, but does not submit it.\n" - ":param pos1: \n" - ":param color1: \n" - ":param pos2: \n" - ":param color2: \n" - ":param pos3: \n" - ":param color3: \n" - ) - MAP_METHOD_AND_WRAP( "ClearTriangles", ClearTriangles, - "Clears all triangles. Requires a call to SubmitChanges to complete." - ) - MAP_METHOD_AND_WRAP( "SubmitChanges", SubmitChanges, - "Submits changes to the vertex buffer" - ) + MAP_METHOD_AND_WRAP( "AddTriangle", AddTriangle, "( pos1, color1, pos2, color2, pos3, color3 )\n" + "Adds a triangle to the triangle set, but does not submit it.\n" + ":param pos1: \n" + ":param color1: \n" + ":param pos2: \n" + ":param color2: \n" + ":param pos3: \n" + ":param color3: \n" ) + MAP_METHOD_AND_WRAP( "ClearTriangles", ClearTriangles, "Clears all triangles. Requires a call to SubmitChanges to complete." ) + MAP_METHOD_AND_WRAP( "SubmitChanges", SubmitChanges, "Submits changes to the vertex buffer" ) EXPOSURE_CHAINTO( Tr2PrimitiveSet ) } diff --git a/trinity/Tr2StreamingBitmapSaver.cpp b/trinity/Tr2StreamingBitmapSaver.cpp index 032220817..76cb05cf6 100644 --- a/trinity/Tr2StreamingBitmapSaver.cpp +++ b/trinity/Tr2StreamingBitmapSaver.cpp @@ -9,8 +9,8 @@ // Description: // Tr2StreamingBitmapSaver default constructor // -------------------------------------------------------------------------------------- -Tr2StreamingBitmapSaver::Tr2StreamingBitmapSaver( IRoot* /* lockobj */ ) - :m_width( 0 ), +Tr2StreamingBitmapSaver::Tr2StreamingBitmapSaver( IRoot* /* lockobj */ ) : + m_width( 0 ), m_height( 0 ), m_format( Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ), m_bytesPerPixel( 0 ), @@ -33,7 +33,7 @@ Tr2StreamingBitmapSaver::~Tr2StreamingBitmapSaver() // -------------------------------------------------------------------------------------- // Description: -// Starts saving TGA image. Opens a file and writes out a header. +// Starts saving TGA image. Opens a file and writes out a header. // Arguments: // path - Res or physical path to output TGA image // width - Width of the image @@ -42,10 +42,10 @@ Tr2StreamingBitmapSaver::~Tr2StreamingBitmapSaver() // Return Value: // AL result of operation // -------------------------------------------------------------------------------------- -ALResult Tr2StreamingBitmapSaver::StartSaving( - const wchar_t* path, - uint32_t width, - uint32_t height, +ALResult Tr2StreamingBitmapSaver::StartSaving( + const wchar_t* path, + uint32_t width, + uint32_t height, Tr2RenderContextEnum::PixelFormat pixelFormat ) { if( IsSaving() ) @@ -55,17 +55,17 @@ ALResult Tr2StreamingBitmapSaver::StartSaving( if( !ImageIO::Tga::IsSaveSupported( m_format ) ) { - CCP_LOGWARN( - "Tr2StreamingBitmapSaver::StartSaving unsupported image format (%i)", + CCP_LOGWARN( + "Tr2StreamingBitmapSaver::StartSaving unsupported image format (%i)", pixelFormat ); return E_INVALIDARG; } if( !width || !height ) { - CCP_LOGWARN( - "Tr2StreamingBitmapSaver::StartSaving invalid image dimensions (%u x %u)", - width, + CCP_LOGWARN( + "Tr2StreamingBitmapSaver::StartSaving invalid image dimensions (%u x %u)", + width, height ); return E_INVALIDARG; } @@ -74,16 +74,16 @@ ALResult Tr2StreamingBitmapSaver::StartSaving( IResFilePtr stream( resFileClsid ); if( !( stream->FileExistsW( path ) ? stream->OpenW( path, false ) : stream->CreateW( path ) ) ) { - CCP_LOGWARN( - "Tr2StreamingBitmapSaver::StartSaving failed to open Blue stream (%ls)", + CCP_LOGWARN( + "Tr2StreamingBitmapSaver::StartSaving failed to open Blue stream (%ls)", path ); return E_FAIL; } if( !ImageIO::Tga::SaveHeader( width, height, pixelFormat, *stream ) ) { - CCP_LOGWARN( - "Tr2StreamingBitmapSaver::StartSaving failed to write TGA header (%ls)", + CCP_LOGWARN( + "Tr2StreamingBitmapSaver::StartSaving failed to write TGA header (%ls)", path ); return E_FAIL; } @@ -101,7 +101,7 @@ ALResult Tr2StreamingBitmapSaver::StartSaving( // -------------------------------------------------------------------------------------- // Description: -// Starts next batch (slice) of an image. Batch is a region of image spanning the +// Starts next batch (slice) of an image. Batch is a region of image spanning the // entire image width with a set height. The Tr2StreamingBitmapSaver object allocates // data to store contents of the slice in memory. This operation shifts saving window // inside the image upwards. @@ -154,13 +154,13 @@ ALResult Tr2StreamingBitmapSaver::StartBatch( uint32_t rowsPerBatch ) // Return Value: // AL result of operation // -------------------------------------------------------------------------------------- -ALResult Tr2StreamingBitmapSaver::CopyFromRenderTargetRegion( - Tr2RenderTarget* rt, - int left, - int top, - int right, - int bottom, - int offsetX, +ALResult Tr2StreamingBitmapSaver::CopyFromRenderTargetRegion( + Tr2RenderTarget* rt, + int left, + int top, + int right, + int bottom, + int offsetX, int offsetY ) { if( !rt || !rt->IsValid() || !m_output || !m_rowsPerBatch ) @@ -191,17 +191,16 @@ ALResult Tr2StreamingBitmapSaver::CopyFromRenderTargetRegion( offsetY += top; offsetY -= m_currentOffset; - if( left >= right || + if( left >= right || top >= bottom || int( m_width ) < offsetX || - int( m_rowsPerBatch ) < offsetY - ) + int( m_rowsPerBatch ) < offsetY ) { // source rectangle is empty return S_OK; } - unsigned width = min( unsigned( right - left ), m_width - offsetX ); + unsigned width = min( unsigned( right - left ), m_width - offsetX ); unsigned height = min( unsigned( bottom - top ), m_rowsPerBatch - offsetY ); USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -222,7 +221,7 @@ ALResult Tr2StreamingBitmapSaver::CopyFromRenderTargetRegion( dst += m_bytesPerPixel * offsetX + dstPitch * offsetY; src += m_bytesPerPixel * left + srcPitch * top; - + const unsigned pitch = width * m_bytesPerPixel; for( unsigned j = 0; j != height; ++j, src += srcPitch, dst += dstPitch ) { @@ -296,4 +295,3 @@ bool Tr2StreamingBitmapSaver::HasStartedBatch() const { return m_rowsPerBatch != 0; } - diff --git a/trinity/Tr2StreamingBitmapSaver.h b/trinity/Tr2StreamingBitmapSaver.h index 2ffaab5fb..10d08bce5 100644 --- a/trinity/Tr2StreamingBitmapSaver.h +++ b/trinity/Tr2StreamingBitmapSaver.h @@ -13,7 +13,8 @@ BLUE_DECLARE( Tr2RenderTarget ); // See Also: // Tr2HostBitmap // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2StreamingBitmapSaver ): public IRoot +BLUE_CLASS( Tr2StreamingBitmapSaver ) : + public IRoot { public: Tr2StreamingBitmapSaver( IRoot* lockobj = nullptr ); @@ -23,12 +24,13 @@ BLUE_CLASS( Tr2StreamingBitmapSaver ): public IRoot ALResult StartSaving( const wchar_t* path, uint32_t width, uint32_t height, Tr2RenderContextEnum::PixelFormat pixelFormat ); ALResult StartBatch( uint32_t rowsPerBatch ); - ALResult CopyFromRenderTargetRegion( Tr2RenderTarget* rt, int left, int top, int right, int bottom, int offsetX, int offsetY ); + ALResult CopyFromRenderTargetRegion( Tr2RenderTarget * rt, int left, int top, int right, int bottom, int offsetX, int offsetY ); ALResult FlushBatch(); ALResult EndSaving(); bool IsSaving() const; bool HasStartedBatch() const; + private: uint32_t m_width; uint32_t m_height; diff --git a/trinity/Tr2StreamingBitmapSaver_Blue.cpp b/trinity/Tr2StreamingBitmapSaver_Blue.cpp index dcfc529e6..9ba817ffb 100644 --- a/trinity/Tr2StreamingBitmapSaver_Blue.cpp +++ b/trinity/Tr2StreamingBitmapSaver_Blue.cpp @@ -12,14 +12,14 @@ const Be::ClassInfo* Tr2StreamingBitmapSaver::ExposeToBlue() EXPOSURE_BEGIN( Tr2StreamingBitmapSaver, "" ) MAP_INTERFACE( Tr2StreamingBitmapSaver ) - MAP_METHOD_AND_WRAP( - "StartBatch", - StartBatch, + MAP_METHOD_AND_WRAP( + "StartBatch", + StartBatch, "Starts a batch of image data advancing Y offset in the resulting image\n" ":param height: number of rows in the batch" ); - MAP_METHOD_AND_WRAP( - "CopyFromRenderTargetRegion", - CopyFromRenderTargetRegion, + MAP_METHOD_AND_WRAP( + "CopyFromRenderTargetRegion", + CopyFromRenderTargetRegion, "Copies data from a readable render target into the bitmap\n" ":param source: Tr2RenderTarget of the same pixelFormat, and correct width/height\n" ":param left: Source rectangle left offset in pixels\n" @@ -28,13 +28,13 @@ const Be::ClassInfo* Tr2StreamingBitmapSaver::ExposeToBlue() ":param bottom: Source rectangle bottom offset in pixels\n" ":param x: X offset in the bitmap in pixels\n" ":param y: Y offset in the bitmap in pixels" ); - MAP_METHOD_AND_WRAP( - "FlushBatch", - FlushBatch, + MAP_METHOD_AND_WRAP( + "FlushBatch", + FlushBatch, "Flushes current batch to the disk" ); - MAP_METHOD_AND_WRAP( - "EndSaving", - EndSaving, + MAP_METHOD_AND_WRAP( + "EndSaving", + EndSaving, "Finishes saving an image" ); MAP_ATTRIBUTE( "width", m_width, "Image width", Be::READ ); MAP_ATTRIBUTE( "height", m_height, "Image height", Be::READ ); @@ -47,7 +47,7 @@ const Be::ClassInfo* Tr2StreamingBitmapSaver::ExposeToBlue() namespace { -ALResult StartStreamingBitmap( const wchar_t* path, uint32_t width, uint32_t height, int/*Tr2RenderContextEnum::PixelFormat*/ pixelFormat, Tr2StreamingBitmapSaver** result ) +ALResult StartStreamingBitmap( const wchar_t* path, uint32_t width, uint32_t height, int /*Tr2RenderContextEnum::PixelFormat*/ pixelFormat, Tr2StreamingBitmapSaver** result ) { *result = nullptr; @@ -60,9 +60,9 @@ ALResult StartStreamingBitmap( const wchar_t* path, uint32_t width, uint32_t hei } -MAP_FUNCTION_AND_WRAP( - "StartStreamingBitmap", - StartStreamingBitmap, +MAP_FUNCTION_AND_WRAP( + "StartStreamingBitmap", + StartStreamingBitmap, "Starts streaming large bitmap to disk.\n" ":param path: path to TGA file to write\n" ":param width: image width\n" diff --git a/trinity/Tr2SuballocatedBuffer.cpp b/trinity/Tr2SuballocatedBuffer.cpp index 179b13605..7801bd435 100644 --- a/trinity/Tr2SuballocatedBuffer.cpp +++ b/trinity/Tr2SuballocatedBuffer.cpp @@ -1,6 +1,6 @@ // Copyright © 2023 CCP ehf. -#include "StdAfx.h" +#include "StdAfx.h" #include "Tr2SuballocatedBuffer.h" @@ -12,10 +12,6 @@ CCP_STATS_DECLARE( suballocatedBufferCapacity, "Trinity/SuballocatedBuffer/Capac - - - - Tr2SuballocatedBuffer::Tr2SuballocatedBuffer( const char* name, const Tr2GpuUsage::Type gpuUsage, const uint32_t blockSize, const uint32_t maxSize ) : m_name( name ), m_gpuUsage( gpuUsage ), @@ -40,10 +36,10 @@ ALResult Tr2SuballocatedBuffer::Allocate( uint32_t stride, uint32_t count, void* Tr2VirtualAllocator::VirtualAllocation allocation = {}; if( m_allocator.Allocate( size, stride, allocation ) ) { - result.m_offset = static_cast(allocation.offset); - result.m_size = static_cast(size); + result.m_offset = static_cast( allocation.offset ); + result.m_size = static_cast( size ); - result.m_stride = static_cast(stride); + result.m_stride = static_cast( stride ); result.m_allocation = allocation; result.m_parent = this; @@ -113,7 +109,7 @@ bool Tr2SuballocatedBuffer::OnPrepareResources() USE_MAIN_THREAD_RENDER_CONTEXT(); - uint32_t bufferSize = static_cast(m_allocator.GetCurrentSize()); + uint32_t bufferSize = static_cast( m_allocator.GetCurrentSize() ); Tr2BufferAL buffer; Tr2BufferDescriptionAL desc( 4, bufferSize / 4, m_gpuUsage, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE ); @@ -129,7 +125,7 @@ ALResult Tr2SuballocatedBuffer::Expand() USE_MAIN_THREAD_RENDER_CONTEXT(); //We have reached the allocator's max size. This probably means we're leaking a lot of memory. - if (m_allocator.GetCurrentSize() == m_allocator.GetMaxSize()) + if( m_allocator.GetCurrentSize() == m_allocator.GetMaxSize() ) { CCP_LOGERR( "Max size reached for buffer '%s'. This probably means we're leaking a lot of memory.", m_name.c_str() ); return E_OUTOFMEMORY; @@ -170,7 +166,7 @@ ALResult Tr2SuballocatedBuffer::ReadBuffer( std::unique_ptr& dest, ui { const void* data = nullptr; CR_RETURN_HR( m_buffer.MapForReading( data, offset, size, renderContext ) ); - if ( data == nullptr ) + if( data == nullptr ) { return E_FAIL; } diff --git a/trinity/Tr2SwapChain.cpp b/trinity/Tr2SwapChain.cpp index b4b659880..8a734df8b 100644 --- a/trinity/Tr2SwapChain.cpp +++ b/trinity/Tr2SwapChain.cpp @@ -5,8 +5,8 @@ #include "Tr2DepthStencil.h" #include "Tr2RenderTarget.h" -Tr2SwapChain::Tr2SwapChain( IRoot* lockobj ) - :m_windowHandle( 0 ) +Tr2SwapChain::Tr2SwapChain( IRoot* lockobj ) : + m_windowHandle( 0 ) { } diff --git a/trinity/Tr2SwapChain.h b/trinity/Tr2SwapChain.h index baff2fe04..8fd5f21a7 100644 --- a/trinity/Tr2SwapChain.h +++ b/trinity/Tr2SwapChain.h @@ -13,12 +13,11 @@ BLUE_DECLARE( Tr2DepthStencil ); BLUE_DECLARE( Tr2SwapChain ); -class Tr2SwapChain: - public IRoot, - public Tr2DeviceResource +class Tr2SwapChain : public IRoot, + public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); Tr2SwapChain( IRoot* lockobj = NULL ); @@ -28,9 +27,10 @@ class Tr2SwapChain: int GetWidth() const; int GetHeight() const; - ///////////////////////////////////////////////////////////////////////////// - // ITriDeviceResource - void ReleaseResources( TriStorage s ); + ///////////////////////////////////////////////////////////////////////////// + // ITriDeviceResource + void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); diff --git a/trinity/Tr2SwapChain_Blue.cpp b/trinity/Tr2SwapChain_Blue.cpp index f51706147..159654765 100644 --- a/trinity/Tr2SwapChain_Blue.cpp +++ b/trinity/Tr2SwapChain_Blue.cpp @@ -9,8 +9,8 @@ BLUE_DEFINE( Tr2SwapChain ); const Be::ClassInfo* Tr2SwapChain::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2SwapChain, "" ) - MAP_INTERFACE( Tr2SwapChain ) + EXPOSURE_BEGIN( Tr2SwapChain, "" ) + MAP_INTERFACE( Tr2SwapChain ) MAP_ATTRIBUTE( "backBuffer", m_backBuffer, "Render target for the swap chain.", Be::READ ); MAP_ATTRIBUTE( "depthStencilBuffer", m_depthStencil, "Depth-stencil target for the swap chain; can be None.", Be::READ ); @@ -18,12 +18,11 @@ const Be::ClassInfo* Tr2SwapChain::ExposeToBlue() MAP_PROPERTY_READONLY( "width", GetWidth, "Width of the backBuffer" ) MAP_PROPERTY_READONLY( "height", GetHeight, "Height of the backBuffer" ) - MAP_METHOD_AND_WRAP( - "CreateForWindow", - CreateForWindow, + MAP_METHOD_AND_WRAP( + "CreateForWindow", + CreateForWindow, "Creates a swap chain and associates with the given window\n" - ":param hwnd: window handle" - ) + ":param hwnd: window handle" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2TextureAnimation_Blue.cpp b/trinity/Tr2TextureAnimation_Blue.cpp index 6e57c42ab..1e8f9c1b8 100644 --- a/trinity/Tr2TextureAnimation_Blue.cpp +++ b/trinity/Tr2TextureAnimation_Blue.cpp @@ -13,11 +13,11 @@ const Be::ClassInfo* Tr2TextureAnimation::ExposeToBlue() MAP_INTERFACE( IInitialize ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE( - "resPath", - m_filename, + MAP_ATTRIBUTE( + "resPath", + m_filename, "Path to the animation file\n" - ":jessica-file-filter: Texture animations (*.vta)|*.vta", + ":jessica-file-filter: Texture animations (*.vta)|*.vta", Be::READWRITE | Be::PERSIST | Be::NOTIFY ) MAP_ATTRIBUTE( "fps", m_fps, "Animation speed: frames per second", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "time", m_time, "Current animation time", Be::READ ) diff --git a/trinity/Tr2TextureArray.cpp b/trinity/Tr2TextureArray.cpp index 8b3d5ab27..25ee12da8 100644 --- a/trinity/Tr2TextureArray.cpp +++ b/trinity/Tr2TextureArray.cpp @@ -24,7 +24,7 @@ Tr2TextureArrayElement Tr2TextureArray::AddElement( const ImageIO::HostBitmap& b if( m_dimensions.GetType() != Tr2RenderContextEnum::TEX_TYPE_INVALID ) { - if( m_dimensions.GetType() != bitmap.GetType() || + if( m_dimensions.GetType() != bitmap.GetType() || m_dimensions.GetFormat() != bitmap.GetFormat() || m_dimensions.GetWidth() != bitmap.GetWidth() || m_dimensions.GetHeight() != bitmap.GetHeight() || @@ -148,7 +148,7 @@ Tr2TextureAL Tr2TextureArray::CreateTexture() const USE_MAIN_THREAD_RENDER_CONTEXT(); std::vector initialData; Tr2SubresourceData filler; - bool validFiller = false; + bool validFiller = false; auto mipCount = m_dimensions.GetTrueMipCount(); for( auto& element : m_elements ) { @@ -157,7 +157,7 @@ Tr2TextureAL Tr2TextureArray::CreateTexture() const filler = { element.GetMipRawData( 0 ), element.GetMipPitch( 0 ), element.GetMipSize( 0 ) }; - validFiller = true; + validFiller = true; for( uint32_t i = 0; i < mipCount; ++i ) { initialData.push_back( { element.GetMipRawData( i ), element.GetMipPitch( i ), element.GetMipSize( i ) } ); @@ -179,21 +179,21 @@ Tr2TextureAL Tr2TextureArray::CreateTexture() const } } - Tr2TextureAL newTexture; - if( validFiller ) - { - for( auto& data : initialData ) - { - if( !data.m_sysMem ) - { - data = filler; - } - } - newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, initialData.data(), renderContext ); - } + Tr2TextureAL newTexture; + if( validFiller ) + { + for( auto& data : initialData ) + { + if( !data.m_sysMem ) + { + data = filler; + } + } + newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, initialData.data(), renderContext ); + } else { - newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, nullptr, renderContext ); + newTexture.Create( m_dimensions, Tr2MsaaDesc(), m_gpuUsage, m_cpuUsage, nullptr, renderContext ); } return newTexture; diff --git a/trinity/Tr2TextureAtlas.cpp b/trinity/Tr2TextureAtlas.cpp index 8cd982653..9e89c9576 100644 --- a/trinity/Tr2TextureAtlas.cpp +++ b/trinity/Tr2TextureAtlas.cpp @@ -21,7 +21,7 @@ Tr2TextureAtlas::Tr2TextureAtlas( IRoot* lockobj ) : m_createOutsiders( true ), m_margin( 2 ), m_maxTextureArea( 512 * 512 ), - m_freeMaxWidth( -1 ), + m_freeMaxWidth( -1 ), m_freeMaxHeight( -1 ), m_optimizationWarranted( false ), m_areasFreedSinceLastCollapse( 0 ), @@ -48,16 +48,16 @@ void Tr2TextureAtlas::Initialize( PixelFormat fmt, unsigned int width, unsigned void Tr2TextureAtlas::ReleaseResources( TriStorage s ) { - if( s & TRISTORAGE_MANAGEDMEMORY ) + if( s & TRISTORAGE_MANAGEDMEMORY ) { m_texture = Tr2TextureAL(); for( AreaList_t::iterator it = m_freeAreas.begin(); it != m_freeAreas.end(); ++it ) { - CCP_DELETE *it; + CCP_DELETE* it; } m_freeAreas.clear(); - for ( auto [freeArea, _] : m_pendingFreeAreas ) + for( auto [freeArea, _] : m_pendingFreeAreas ) { CCP_DELETE freeArea; } @@ -75,7 +75,7 @@ bool Tr2TextureAtlas::OnPrepareResources() { return true; } - + HRESULT hr; do @@ -84,16 +84,16 @@ bool Tr2TextureAtlas::OnPrepareResources() { return false; } - - m_mipLevels = m_hasMipMaps ? unsigned( 0.5 + log(double(std::max(m_height, m_width))) / log(2.0) ) : 1; + + m_mipLevels = m_hasMipMaps ? unsigned( 0.5 + log( double( std::max( m_height, m_width ) ) ) / log( 2.0 ) ) : 1; USE_MAIN_THREAD_RENDER_CONTEXT(); hr = m_texture.Create( - Tr2BitmapDimensions( m_width, m_height, m_mipLevels, m_format ), + Tr2BitmapDimensions( m_width, m_height, m_mipLevels, m_format ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, renderContext ); - if( FAILED(hr) ) + if( FAILED( hr ) ) { if( m_width > m_height ) { @@ -104,7 +104,7 @@ bool Tr2TextureAtlas::OnPrepareResources() m_height /= 2; } } - } while( FAILED(hr) ); + } while( FAILED( hr ) ); Tr2TextureAtlasArea* area = CCP_NEW( "Tr2TextureAtlas/Area" ) Tr2TextureAtlasArea; area->type = Tr2TextureAtlasArea::FREE; @@ -167,14 +167,14 @@ bool Tr2TextureAtlas::DoPrepare( Tr2AtlasTexture* tex ) Tr2ImageIOHelpers::CopyToTexture( *tex->m_loadedBitmap, m_texture, area->rect.left, area->rect.top, m_margin, renderContext ); - if( m_hasMipMaps ) + if( m_hasMipMaps ) { m_dirtyMipRegions.push_back( area->rect ); } RegisterInsider( tex ); - return true; + return true; } // Register an atlas texture that lives inside the atlas @@ -199,11 +199,11 @@ void Tr2TextureAtlas::RemoveFromAtlas( Tr2AtlasTexture* tex ) Tr2TextureAtlasArea* area = tex->m_atlasArea; if( area ) { - m_freeTexels += (area->rect.bottom - area->rect.top) * (area->rect.right - area->rect.left); + m_freeTexels += ( area->rect.bottom - area->rect.top ) * ( area->rect.right - area->rect.left ); tex->m_atlasArea = NULL; area->type = Tr2TextureAtlasArea::FREE; - FreeArea( area ); + FreeArea( area ); PaintEmptyArea( area ); @@ -231,16 +231,19 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() return; } - struct Squareness { - static float Metric( const Tr2Rect& a ) { + struct Squareness + { + static float Metric( const Tr2Rect& a ) + { const int w = a.right - a.left; const int h = a.bottom - a.top; - if( w == 0 || h == 0 ) return 0.f; - const float d = float(w - h); + if( w == 0 || h == 0 ) + return 0.f; + const float d = float( w - h ); return d * d / float( w * h ); } }; - + bool restartLoop = true; while( restartLoop ) @@ -248,16 +251,16 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() restartLoop = false; for( AreaList_t::iterator i = m_freeAreas.begin(); i != m_freeAreas.end(); ++i ) { - const auto& rect_i = (*i)->rect; + const auto& rect_i = ( *i )->rect; const float square_i = Squareness::Metric( rect_i ); AreaList_t::iterator j = i; for( ++j; j != m_freeAreas.end(); ++j ) { - const auto& rect_j = (*j)->rect; + const auto& rect_j = ( *j )->rect; const float square_j = Squareness::Metric( rect_j ); const float squareStart = square_i + square_j; - + if( rect_i.bottom == rect_i.top || rect_i.top == rect_j.bottom ) { @@ -271,10 +274,10 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() sum.right = rect_i.right; sum.top = std::min( rect_i.top, rect_j.top ); sum.bottom = std::max( rect_i.bottom, rect_j.bottom ); - - CCP_DELETE (*j); + + CCP_DELETE( *j ); j = m_freeAreas.erase( j ); - (*i)->rect = sum; + ( *i )->rect = sum; PaintEmptyArea( *i ); @@ -283,7 +286,7 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() else if( rect_i.right == rect_j.right ) { //areas are right aligned, can rotate the splitting plane - Tr2Rect l,r; + Tr2Rect l, r; l.left = std::min( rect_i.left, rect_j.left ); l.right = std::max( rect_i.left, rect_j.left ); r.left = l.right; @@ -308,8 +311,8 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() if( squareNew < squareStart ) { restartLoop = true; - (*i)->rect = l; - (*j)->rect = r; + ( *i )->rect = l; + ( *j )->rect = r; PaintEmptyArea( *i ); PaintEmptyArea( *j ); } @@ -317,7 +320,7 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() else if( rect_i.left == rect_j.left ) { //left aligned, can rotate the splitting plane - Tr2Rect l,r; + Tr2Rect l, r; r.left = std::min( rect_i.right, rect_j.right ); r.right = std::max( rect_i.right, rect_j.right ); l.left = rect_i.left; @@ -342,8 +345,8 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() if( squareNew < squareStart ) { restartLoop = true; - (*i)->rect = l; - (*j)->rect = r; + ( *i )->rect = l; + ( *j )->rect = r; PaintEmptyArea( *i ); PaintEmptyArea( *j ); } @@ -351,7 +354,6 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() else { //neither left nor right aligned, can split this into three areas or just skip it - } } else if( rect_i.left == rect_j.right || @@ -362,14 +364,14 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() if( rect_i.top == rect_j.top ) { //areas are top aligned, can rotate the splitting plane - Tr2Rect t,b; + Tr2Rect t, b; t.top = rect_i.top; t.bottom = std::min( rect_i.bottom, rect_j.bottom ); t.left = std::min( rect_i.left, rect_i.bottom ); t.right = std::max( rect_i.right, rect_j.right ); b.top = t.bottom; b.bottom = std::max( rect_i.bottom, rect_j.bottom ); - + if( rect_i.bottom > rect_j.bottom ) { b.left = rect_i.left; @@ -388,8 +390,8 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() if( squareNew < squareStart ) { restartLoop = true; - (*i)->rect = t; - (*j)->rect = b; + ( *i )->rect = t; + ( *j )->rect = b; PaintEmptyArea( *i ); PaintEmptyArea( *j ); } @@ -397,14 +399,14 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() else if( rect_i.bottom == rect_j.bottom ) { //bottom aligned, can rotate the splitting plane - Tr2Rect t,b; + Tr2Rect t, b; t.top = std::min( rect_i.top, rect_j.top ); t.bottom = std::max( rect_i.top, rect_j.top ); b.left = std::min( rect_i.left, rect_i.bottom ); b.right = std::max( rect_i.right, rect_j.right ); b.top = t.bottom; b.bottom = rect_i.bottom; - + if( rect_i.top < rect_j.top ) { t.left = rect_i.left; @@ -423,8 +425,8 @@ void Tr2TextureAtlas::ConsolidateFreeAreas() if( squareNew < squareStart ) { restartLoop = true; - (*i)->rect = t; - (*j)->rect = b; + ( *i )->rect = t; + ( *j )->rect = b; PaintEmptyArea( *i ); PaintEmptyArea( *j ); } @@ -491,7 +493,7 @@ void Tr2TextureAtlas::CollapseFreeAreas() { return; } - + m_optimizationWarranted = false; m_areasFreedSinceLastCollapse = 0; @@ -525,7 +527,7 @@ void Tr2TextureAtlas::CollapseFreeAreas() Tr2Rect newRect; bool isAdjacent = false; - if( (area1->rect.top == area2->rect.top) && (area1->rect.bottom == area2->rect.bottom) ) + if( ( area1->rect.top == area2->rect.top ) && ( area1->rect.bottom == area2->rect.bottom ) ) { // Top/bottom matches, see if areas are adjacent left or right if( area1->rect.right == area2->rect.left ) @@ -586,7 +588,7 @@ void Tr2TextureAtlas::CollapseFreeAreas() Tr2Rect newRect; bool isAdjacent = false; - if( (area1->rect.left == area2->rect.left) && (area1->rect.right == area2->rect.right) ) + if( ( area1->rect.left == area2->rect.left ) && ( area1->rect.right == area2->rect.right ) ) { // Left/right matches, see if areas are adjacent top or bottom if( area1->rect.bottom == area2->rect.top ) @@ -633,7 +635,7 @@ bool Tr2TextureAtlas::CollapseAreas( Tr2TextureAtlasArea* area1, Tr2TextureAtlas Tr2Rect newRect; bool isAdjacent = false; - if( (area1->rect.left == area2->rect.left) && (area1->rect.right == area2->rect.right) ) + if( ( area1->rect.left == area2->rect.left ) && ( area1->rect.right == area2->rect.right ) ) { // Left/right matches, see if areas are adjacent top or bottom if( area1->rect.bottom == area2->rect.top ) @@ -653,7 +655,7 @@ bool Tr2TextureAtlas::CollapseAreas( Tr2TextureAtlasArea* area1, Tr2TextureAtlas isAdjacent = true; } } - else if( (area1->rect.top == area2->rect.top) && (area1->rect.bottom == area2->rect.bottom) ) + else if( ( area1->rect.top == area2->rect.top ) && ( area1->rect.bottom == area2->rect.bottom ) ) { // Top/bottom matches, see if areas are adjacent left or right if( area1->rect.right == area2->rect.left ) @@ -696,32 +698,32 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned ReleasePendingFreeAreas(); // Align to 8pixels to prevent thin slivers as free areas - width = (width + 7) & ~7; - height = (height + 7) & ~7; + width = ( width + 7 ) & ~7; + height = ( height + 7 ) & ~7; // First search through free areas. // Keep track of an area that fits, but keep looking for a perfect fit. AreaList_t::iterator anyFit = m_freeAreas.end(); AreaList_t::iterator perfectFit = m_freeAreas.end(); - int bestPrimaryMetric = m_width+m_height; - int bestSecondaryMetric = m_width+m_height; + int bestPrimaryMetric = m_width + m_height; + int bestSecondaryMetric = m_width + m_height; for( AreaList_t::iterator it = m_freeAreas.begin(); it != m_freeAreas.end(); ++it ) { Tr2TextureAtlasArea* area = *it; unsigned int candidateWidth = area->rect.right - area->rect.left; unsigned int candidateHeight = area->rect.bottom - area->rect.top; - if( (width == candidateWidth) && (height == candidateHeight) ) + if( ( width == candidateWidth ) && ( height == candidateHeight ) ) { perfectFit = it; break; } - if( (width <= candidateWidth) && (height <= candidateHeight) ) + if( ( width <= candidateWidth ) && ( height <= candidateHeight ) ) { int metric = std::min( candidateWidth - width, candidateHeight - height ); int altMetric = std::max( candidateWidth - width, candidateHeight - height ); - if( metric < bestPrimaryMetric || (bestPrimaryMetric == metric && altMetric < bestSecondaryMetric) ) + if( metric < bestPrimaryMetric || ( bestPrimaryMetric == metric && altMetric < bestSecondaryMetric ) ) { bestPrimaryMetric = metric; bestSecondaryMetric = altMetric; @@ -735,19 +737,19 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned { // Found a perfect fit Tr2TextureAtlasArea* freeArea = *perfectFit; - m_freeTexels -= (freeArea->rect.bottom - freeArea->rect.top) * (freeArea->rect.right - freeArea->rect.left); + m_freeTexels -= ( freeArea->rect.bottom - freeArea->rect.top ) * ( freeArea->rect.right - freeArea->rect.left ); m_freeAreas.erase( perfectFit ); //update cached largest free area - if( (freeArea->rect.right - freeArea->rect.left) >= m_freeMaxWidth || - (freeArea->rect.bottom - freeArea->rect.top) >= m_freeMaxHeight ) + if( ( freeArea->rect.right - freeArea->rect.left ) >= m_freeMaxWidth || + ( freeArea->rect.bottom - freeArea->rect.top ) >= m_freeMaxHeight ) { UpdateFreeMaxima(); } return freeArea; } - + if( anyFit != m_freeAreas.end() ) { Tr2TextureAtlasArea* freeArea = *anyFit; @@ -758,7 +760,7 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned //if we're allocating a small bit out of a large area, first split it into squares const unsigned minNewRegion = 128 + m_margin * 4; - + if( height < minNewRegion && width < minNewRegion ) { //(if we've found a small region, it is already within a square so no need to do this) @@ -789,7 +791,7 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned freeArea->rect.right = freeArea->rect.left + minNewRegion; } } - + // Must split the area if( candidateWidth == width ) { @@ -838,8 +840,8 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned } //update cached largest free area (freeArea not yet resized but has been erased from free list) - if( (freeArea->rect.right - freeArea->rect.left) >= m_freeMaxWidth || - (freeArea->rect.bottom - freeArea->rect.top) >= m_freeMaxHeight ) + if( ( freeArea->rect.right - freeArea->rect.left ) >= m_freeMaxWidth || + ( freeArea->rect.bottom - freeArea->rect.top ) >= m_freeMaxHeight ) { UpdateFreeMaxima(); } @@ -847,15 +849,14 @@ Tr2TextureAtlasArea* Tr2TextureAtlas::GetFreeArea( unsigned int width, unsigned freeArea->rect.right = freeArea->rect.left + width; freeArea->rect.bottom = freeArea->rect.top + height; - m_freeTexels -= (freeArea->rect.bottom - freeArea->rect.top) * (freeArea->rect.right - freeArea->rect.left); + m_freeTexels -= ( freeArea->rect.bottom - freeArea->rect.top ) * ( freeArea->rect.right - freeArea->rect.left ); return freeArea; } - + // Couldn't find anything! return NULL; - } Tr2RenderContextEnum::PixelFormat Tr2TextureAtlas::GetFormat() const @@ -878,15 +879,15 @@ void Tr2TextureAtlas::PaintEmptyArea( Tr2TextureAtlasArea* area ) return; } - const bool isValidArea = - area->rect.left >= 0 && - area->rect.top >= 0 && - area->rect.right >= 0 && - area->rect.bottom >= 0 && - area->rect.right >= area->rect.left && - area->rect.bottom >= area->rect.top && - uint32_t( area->rect.right ) <= m_texture.GetWidth() && - uint32_t( area->rect.bottom) <= m_texture.GetHeight(); + const bool isValidArea = + area->rect.left >= 0 && + area->rect.top >= 0 && + area->rect.right >= 0 && + area->rect.bottom >= 0 && + area->rect.right >= area->rect.left && + area->rect.bottom >= area->rect.top && + uint32_t( area->rect.right ) <= m_texture.GetWidth() && + uint32_t( area->rect.bottom ) <= m_texture.GetHeight(); CCP_ASSERT( isValidArea ); if( !isValidArea ) @@ -898,15 +899,15 @@ void Tr2TextureAtlas::PaintEmptyArea( Tr2TextureAtlasArea* area ) void* rgba = nullptr; uint32_t pitch = 0; CR_RETURN( m_texture.MapForWriting( Tr2TextureSubresource( 0 ), rgba, pitch, renderContext ) ); - ON_BLOCK_EXIT( [&]{ m_texture.UnmapForWriting( renderContext ); } ); + ON_BLOCK_EXIT( [&] { m_texture.UnmapForWriting( renderContext ); } ); - uint8_t *dst = (uint8_t*)rgba; + uint8_t* dst = (uint8_t*)rgba; static unsigned int s_fillValue = 0; s_fillValue += 0xabcdef; s_fillValue &= 0xffffff; - const uint32_t width = uint32_t( area->rect.right - area->rect.left ); + const uint32_t width = uint32_t( area->rect.right - area->rect.left ); const uint32_t height = uint32_t( area->rect.bottom - area->rect.top ); if( IsCompressedFormat( m_format ) ) @@ -964,24 +965,24 @@ int Tr2TextureAtlas::GetTexturesOutsideAtlasCount() } void Tr2TextureAtlas::PullInOutsiders( bool optimiseInsertion ) -{ - std::list< Tr2AtlasTexture * > sorted( m_texturesOutsideAtlas.begin(), m_texturesOutsideAtlas.end() ); +{ + std::list sorted( m_texturesOutsideAtlas.begin(), m_texturesOutsideAtlas.end() ); if( optimiseInsertion ) { //todo: implement more options for sorting the list (squareness, power-of-two pref.) - struct SmallestFirst + struct SmallestFirst { - bool operator()( const Tr2AtlasTexture *a, const Tr2AtlasTexture *b ) + bool operator()( const Tr2AtlasTexture* a, const Tr2AtlasTexture* b ) { const int widthA = a->m_width; const int heightA = a->m_height; const int widthB = b->m_width; const int heightB = b->m_height; - return (widthA * heightA) < (widthB * heightB); + return ( widthA * heightA ) < ( widthB * heightB ); } - }; + }; SmallestFirst smallestFirst; sorted.sort( smallestFirst ); @@ -1001,7 +1002,7 @@ void Tr2TextureAtlas::PullInOutsiders( bool optimiseInsertion ) CCP_ASSERT( !tex->m_atlasArea ); - Tr2TextureAtlasArea* area = GetFreeArea( tex->m_width + m_margin*2, tex->m_height + m_margin*2 ); + Tr2TextureAtlasArea* area = GetFreeArea( tex->m_width + m_margin * 2, tex->m_height + m_margin * 2 ); if( area ) { area->tex = tex; @@ -1016,10 +1017,10 @@ void Tr2TextureAtlas::PullInOutsiders( bool optimiseInsertion ) tex->m_y = area->rect.top + m_margin; tex->m_textureWidth = m_width; tex->m_textureHeight = m_height; - + tex->FinalizePrepare(); - m_texturesOutsideAtlas.erase( tex ); + m_texturesOutsideAtlas.erase( tex ); m_texturesInAtlas.insert( tex ); } else @@ -1044,7 +1045,7 @@ bool Tr2TextureAtlas::CopyTextureIntoAtlas( Tr2AtlasTexture* tex ) CCP_LOGERR( "CopyTextureIntoAtlas failed, target or source textures invalid" ); return false; } - + const auto& r = tex->m_atlasArea->rect; if( !m_margin ) @@ -1063,15 +1064,15 @@ bool Tr2TextureAtlas::CopyTextureIntoAtlas( Tr2AtlasTexture* tex ) const void* srcData = nullptr; unsigned srcPitch = 0; CR_RETURN_VAL( tex->GetTexture()->MapForReading( Tr2TextureSubresource( 0 ), srcData, srcPitch, renderContext ), false ); - ON_BLOCK_EXIT( [&]{ tex->GetTexture()->UnmapForReading( renderContext ); } ); + ON_BLOCK_EXIT( [&] { tex->GetTexture()->UnmapForReading( renderContext ); } ); std::vector pixels; unsigned pitch = 0; Tr2ImageIOHelpers::AddMargin( m_texture.GetFormat(), (const unsigned char*)srcData, tex->GetWidth(), tex->GetHeight(), m_margin, pixels, pitch ); // Area may be larger than texture due to alignment - uint32_t right = r.left + tex->GetWidth() + 2*m_margin; - uint32_t bottom = r.top + tex->GetHeight() + 2*m_margin; + uint32_t right = r.left + tex->GetWidth() + 2 * m_margin; + uint32_t bottom = r.top + tex->GetHeight() + 2 * m_margin; return SUCCEEDED( m_texture.UpdateSubresource( Tr2TextureSubresource( 0 ).SetRect( r.left, r.top, right, bottom ), &pixels[0], pitch, 0, renderContext ) ); } @@ -1082,15 +1083,15 @@ ALResult Tr2TextureAtlas::CreateTexture( unsigned int width, unsigned int height tex->m_textureAtlas = this; Tr2TextureAtlasArea* area = NULL; - + if( type == ATT_DEFAULT && !IsLargeTexture( width, height ) ) { - area = GetFreeArea( width + m_margin*2, height + m_margin*2 ); + area = GetFreeArea( width + m_margin * 2, height + m_margin * 2 ); if( !area && m_optimizationWarranted ) { CollapseFreeAreas(); - area = GetFreeArea( width + m_margin*2, height + m_margin*2 ); + area = GetFreeArea( width + m_margin * 2, height + m_margin * 2 ); } } @@ -1122,10 +1123,11 @@ ALResult Tr2TextureAtlas::CreateTexture( unsigned int width, unsigned int height USE_MAIN_THREAD_RENDER_CONTEXT(); HRESULT hr = tex->m_texture.Create( - Tr2BitmapDimensions( width, height, 1, m_format ), - Tr2GpuUsage::SHADER_RESOURCE, - Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, - renderContext ).GetResult(); + Tr2BitmapDimensions( width, height, 1, m_format ), + Tr2GpuUsage::SHADER_RESOURCE, + Tr2CpuUsage::READ | Tr2CpuUsage::WRITE, + renderContext ) + .GetResult(); if( FAILED( hr ) ) { *result = nullptr; @@ -1170,7 +1172,7 @@ PyObject* Tr2TextureAtlas::GetTexturesInAtlas() int i; for( i = 0, it = m_texturesInAtlas.begin(); it != m_texturesInAtlas.end(); ++i, ++it ) { - PyList_SET_ITEM( list, i, PyOS->WrapBlueObject( (*it)->GetRawRoot() ) ); + PyList_SET_ITEM( list, i, PyOS->WrapBlueObject( ( *it )->GetRawRoot() ) ); } return list; @@ -1184,7 +1186,7 @@ PyObject* Tr2TextureAtlas::GetTexturesOutsideAtlas() int i; for( i = 0, it = m_texturesOutsideAtlas.begin(); it != m_texturesOutsideAtlas.end(); ++i, ++it ) { - PyList_SET_ITEM( list, i, PyOS->WrapBlueObject( (*it)->GetRawRoot() ) ); + PyList_SET_ITEM( list, i, PyOS->WrapBlueObject( ( *it )->GetRawRoot() ) ); } return list; @@ -1214,9 +1216,9 @@ void Tr2TextureAtlas::SetMaxTextureArea( unsigned int maxTextureArea ) std::list Tr2TextureAtlas::GetFreeAreas() const { std::list areas; - for( AreaList_t::const_iterator i = m_freeAreas.begin(); i != m_freeAreas.end(); ++i ) + for( AreaList_t::const_iterator i = m_freeAreas.begin(); i != m_freeAreas.end(); ++i ) { - areas.push_back( (*i)->rect ); + areas.push_back( ( *i )->rect ); } for( auto i = m_pendingFreeAreas.begin(); i != m_pendingFreeAreas.end(); ++i ) { @@ -1228,9 +1230,9 @@ std::list Tr2TextureAtlas::GetFreeAreas() const std::list Tr2TextureAtlas::GetUsedAreas() const { std::list areas; - for( Tr2AtlasTextureSet_t::const_iterator i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ++i ) + for( Tr2AtlasTextureSet_t::const_iterator i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ++i ) { - Tr2AtlasTexture *t = *i; + Tr2AtlasTexture* t = *i; // After a device reset, the texture may not have a valid area. Texture is still // registered with the atlas, but it might be in the queue for reloading. @@ -1238,7 +1240,6 @@ std::list Tr2TextureAtlas::GetUsedAreas() const { areas.push_back( t->m_atlasArea->rect ); } - } return areas; } @@ -1247,16 +1248,18 @@ std::list Tr2TextureAtlas::GetUsedAreas() const void Tr2TextureAtlas::UpdateFreeMaxima() const { m_freeMaxWidth = m_freeMaxHeight = 0; - for( AreaList_t::const_iterator i = m_freeAreas.begin(); i != m_freeAreas.end(); ++i ) + for( AreaList_t::const_iterator i = m_freeAreas.begin(); i != m_freeAreas.end(); ++i ) { - const int w = (*i)->rect.right - (*i)->rect.left; - const int h = (*i)->rect.bottom - (*i)->rect.top; - if( w > m_freeMaxWidth ) m_freeMaxWidth = w; - if( h > m_freeMaxHeight ) m_freeMaxHeight = h; + const int w = ( *i )->rect.right - ( *i )->rect.left; + const int h = ( *i )->rect.bottom - ( *i )->rect.top; + if( w > m_freeMaxWidth ) + m_freeMaxWidth = w; + if( h > m_freeMaxHeight ) + m_freeMaxHeight = h; } } -bool Tr2TextureAtlas::EjectTexture( Tr2AtlasTexture *tex ) +bool Tr2TextureAtlas::EjectTexture( Tr2AtlasTexture* tex ) { CCP_ASSERT( tex ); @@ -1265,11 +1268,11 @@ bool Tr2TextureAtlas::EjectTexture( Tr2AtlasTexture *tex ) return false; } - if( EjectTextureHelper( tex) ) + if( EjectTextureHelper( tex ) ) { - for( auto i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ++i ) + for( auto i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ++i ) { - Tr2AtlasTexture *t = *i; + Tr2AtlasTexture* t = *i; if( t == tex ) { m_texturesInAtlas.erase( i ); @@ -1281,7 +1284,7 @@ bool Tr2TextureAtlas::EjectTexture( Tr2AtlasTexture *tex ) return false; } -bool Tr2TextureAtlas::EjectTextureHelper( Tr2AtlasTexture *tex ) +bool Tr2TextureAtlas::EjectTextureHelper( Tr2AtlasTexture* tex ) { USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -1292,9 +1295,9 @@ bool Tr2TextureAtlas::EjectTextureHelper( Tr2AtlasTexture *tex ) } CCP_ASSERT( tex->m_textureAtlas == this ); CCP_ASSERT( tex->m_atlasArea ); - - Tr2TextureAtlasArea *texArea = tex->m_atlasArea; - + + Tr2TextureAtlasArea* texArea = tex->m_atlasArea; + Tr2Rect copyRect; copyRect.left = texArea->rect.left + m_margin; copyRect.top = texArea->rect.top + m_margin; @@ -1336,8 +1339,8 @@ bool Tr2TextureAtlas::EjectTextureHelper( Tr2AtlasTexture *tex ) tex->FinalizePrepare(); - // Instead of immediately freeing the area, we put it in a pending free list with the current frame number. - // This is a workaround for a driver bug where the driver may schedule a new texture upload into the same area + // Instead of immediately freeing the area, we put it in a pending free list with the current frame number. + // This is a workaround for a driver bug where the driver may schedule a new texture upload into the same area // before the GPU has finished reading from it for copying. m_pendingFreeAreas.push_back( { texArea, renderContext.GetRecordingFrameNumber() } ); @@ -1348,18 +1351,18 @@ bool Tr2TextureAtlas::EjectTextureHelper( Tr2AtlasTexture *tex ) { tex->m_texture = Tr2TextureAL(); } - - return false; + + return false; } void Tr2TextureAtlas::EjectAllTextures() { - for( auto i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ) + for( auto i = m_texturesInAtlas.begin(); i != m_texturesInAtlas.end(); ) { - Tr2AtlasTexture *t = *i; + Tr2AtlasTexture* t = *i; if( EjectTextureHelper( t ) ) { - i = m_texturesInAtlas.erase(i); + i = m_texturesInAtlas.erase( i ); } else { @@ -1385,7 +1388,6 @@ void Tr2TextureAtlas::EjectAllTextures() { CollapseFreeAreas(); } - } void Tr2TextureAtlas::ReleasePendingFreeAreas() @@ -1412,15 +1414,15 @@ void Tr2TextureAtlas::ReleasePendingFreeAreas() } } -void Tr2TextureAtlas::FreeArea( Tr2TextureAtlasArea *area ) +void Tr2TextureAtlas::FreeArea( Tr2TextureAtlasArea* area ) { - if( area == NULL || - (area->rect.right - area->rect.left) == 0 || - (area->rect.bottom - area->rect.top) == 0 ) + if( area == NULL || + ( area->rect.right - area->rect.left ) == 0 || + ( area->rect.bottom - area->rect.top ) == 0 ) { return; } - + area->type = Tr2TextureAtlasArea::FREE; area->tex = NULL; m_freeAreas.push_back( area ); @@ -1444,7 +1446,7 @@ bool Tr2TextureAtlas::IsLargeTexture( unsigned int width, unsigned int height ) } //Call this manually to update mipmaps when appropriate -void Tr2TextureAtlas::UpdateMipMaps( Tr2RenderContext& renderContext ) +void Tr2TextureAtlas::UpdateMipMaps( Tr2RenderContext& renderContext ) { CCP_STATS_ZONE( __FUNCTION__ ); @@ -1452,14 +1454,14 @@ void Tr2TextureAtlas::UpdateMipMaps( Tr2RenderContext& renderContext ) { return; } - if( m_format != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ) + if( m_format != Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ) { - CCP_LOGERR( "Texture format not supported for mipmapped atlases: %08x [%d]", int(m_format), int(m_format) ); + CCP_LOGERR( "Texture format not supported for mipmapped atlases: %08x [%d]", int( m_format ), int( m_format ) ); m_dirtyMipRegions.clear(); return; } - if( !m_texture.IsValid() ) + if( !m_texture.IsValid() ) { m_dirtyMipRegions.clear(); return; @@ -1496,38 +1498,38 @@ void Tr2TextureAtlas::UpdateMipMaps( Tr2RenderContext& renderContext ) // Construct next mip level data for dirty regions using previous mip level copy in system memory // and update rectangles in the texture bool updated = false; - for( auto it = m_dirtyMipRegions.begin(); it != m_dirtyMipRegions.end(); ++it ) + for( auto it = m_dirtyMipRegions.begin(); it != m_dirtyMipRegions.end(); ++it ) { const Tr2Rect source = { it->left >> ( i - 1 ), it->top >> ( i - 1 ), it->right >> ( i - 1 ), it->bottom >> ( i - 1 ) }; Tr2Rect dest = { it->left >> i, it->top >> i, it->right >> i, it->bottom >> i }; const int height = dest.bottom - dest.top; const int width = dest.right - dest.left; - if( height == 0 || width == 0 ) + if( height == 0 || width == 0 ) { continue; } - const unsigned char *src = &( *prevMip )[0]; + const unsigned char* src = &( *prevMip )[0]; src += sourcePitch * source.top + source.left * 4; - unsigned char *dst = &( *nextMip )[0]; + unsigned char* dst = &( *nextMip )[0]; dst += destPitch * dest.top + dest.left * 4; uint32_t sysDestPitch; void* destData; if( SUCCEEDED( m_texture.MapForWriting( Tr2TextureSubresource( i ).SetRect( reinterpret_cast( &dest ) ), destData, sysDestPitch, renderContext ) ) ) { - unsigned char *dstRow = reinterpret_cast( destData ); + unsigned char* dstRow = reinterpret_cast( destData ); - for( int y = 0; y < height; ++y ) + for( int y = 0; y < height; ++y ) { - for( int x = 0; x < width; ++x ) + for( int x = 0; x < width; ++x ) { - for( int ch = 0; ch < 4; ++ch ) + for( int ch = 0; ch < 4; ++ch ) { unsigned s00 = src[y * 2 * sourcePitch + x * 2 * 4 + ch]; - unsigned s01 = src[y * 2 * sourcePitch + (x * 2 + 1) * 4 + ch]; - unsigned s10 = src[(y * 2 + 1) * sourcePitch + x * 2 * 4 + ch]; - unsigned s11 = src[(y * 2 + 1) * sourcePitch + (x * 2 + 1) * 4 + ch]; - dst[x * 4 + ch] = (unsigned char)( (s00 + s01 + s10 + s11) >> 2 ); + unsigned s01 = src[y * 2 * sourcePitch + ( x * 2 + 1 ) * 4 + ch]; + unsigned s10 = src[( y * 2 + 1 ) * sourcePitch + x * 2 * 4 + ch]; + unsigned s11 = src[( y * 2 + 1 ) * sourcePitch + ( x * 2 + 1 ) * 4 + ch]; + dst[x * 4 + ch] = (unsigned char)( ( s00 + s01 + s10 + s11 ) >> 2 ); dstRow[x * 4 + ch] = dst[x * 4 + ch]; } } @@ -1577,12 +1579,12 @@ bool Tr2TextureAtlas::HasALObject( int type, size_t object ) return false; } -uint32_t Tr2TextureAtlas::GetMsaaSamples() const -{ - return 1; +uint32_t Tr2TextureAtlas::GetMsaaSamples() const +{ + return 1; } -uint32_t Tr2TextureAtlas::GetMsaaQuality() const -{ - return 0; +uint32_t Tr2TextureAtlas::GetMsaaQuality() const +{ + return 0; } diff --git a/trinity/Tr2TextureAtlas.h b/trinity/Tr2TextureAtlas.h index ab1fafd23..8e2cd267e 100644 --- a/trinity/Tr2TextureAtlas.h +++ b/trinity/Tr2TextureAtlas.h @@ -16,9 +16,9 @@ struct Tr2TextureAtlasArea { enum Type { - FREE, // Area is free - IN_USE, // Area is in active use - IN_USE_NO_REF // Area was in use and still contains data, but there are no references to it + FREE, // Area is free + IN_USE, // Area is in active use + IN_USE_NO_REF // Area was in use and still contains data, but there are no references to it }; // Type of this area @@ -31,13 +31,13 @@ struct Tr2TextureAtlasArea Tr2AtlasTexture* tex; }; -BLUE_CLASS( Tr2TextureAtlas ): - public ITr2TextureProvider, - public Tr2DeviceResource +BLUE_CLASS( Tr2TextureAtlas ) : + public ITr2TextureProvider, + public Tr2DeviceResource { public: - EXPOSE_TO_BLUE(); - Tr2TextureAtlas( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2TextureAtlas( IRoot* lockobj = NULL ); ~Tr2TextureAtlas(); void Initialize( Tr2RenderContextEnum::PixelFormat fmt, unsigned int width, unsigned int height ); @@ -71,9 +71,18 @@ BLUE_CLASS( Tr2TextureAtlas ): // ITriDeviceResource virtual void ReleaseResources( TriStorage s ); - unsigned GetWidth() const { return m_width; } - unsigned GetHeight() const { return m_height; } - unsigned GetMargin() const { return m_margin; } + unsigned GetWidth() const + { + return m_width; + } + unsigned GetHeight() const + { + return m_height; + } + unsigned GetMargin() const + { + return m_margin; + } void SetMargin( unsigned int margin ); void SetPaintEmptyAreas( bool paintEmptyAreas ); @@ -93,44 +102,56 @@ BLUE_CLASS( Tr2TextureAtlas ): private: friend class Tr2AtlasTexture; - bool DoPrepare( Tr2AtlasTexture* tex ); + bool DoPrepare( Tr2AtlasTexture * tex ); - void RegisterInsider( Tr2AtlasTexture* tex ); - void RegisterOutsider( Tr2AtlasTexture* tex ); + void RegisterInsider( Tr2AtlasTexture * tex ); + void RegisterOutsider( Tr2AtlasTexture * tex ); - void RemoveFromAtlas( Tr2AtlasTexture* tex ); + void RemoveFromAtlas( Tr2AtlasTexture * tex ); - void PaintEmptyArea( Tr2TextureAtlasArea* area ); - bool CopyTextureIntoAtlas( Tr2AtlasTexture* tex ); + void PaintEmptyArea( Tr2TextureAtlasArea * area ); + bool CopyTextureIntoAtlas( Tr2AtlasTexture * tex ); Tr2TextureAtlasArea* GetFreeArea( unsigned int width, unsigned int height ); // Collapse areas into area1 if they are adjacent. Returns true if areas were collapsed. - bool CollapseAreas( Tr2TextureAtlasArea* area1, Tr2TextureAtlasArea* area2 ); + bool CollapseAreas( Tr2TextureAtlasArea * area1, Tr2TextureAtlasArea * area2 ); bool HasALObject( int type, size_t object ); public: - int GetFreeTexels() const { return m_freeTexels; } - float GetFreeTexelPercentage() const { return m_freeTexels / float(m_width*m_height); } - int GetFreeMaxWidth() const { return m_freeMaxWidth; } - int GetFreeMaxHeight() const { return m_freeMaxHeight; } + int GetFreeTexels() const + { + return m_freeTexels; + } + float GetFreeTexelPercentage() const + { + return m_freeTexels / float( m_width * m_height ); + } + int GetFreeMaxWidth() const + { + return m_freeMaxWidth; + } + int GetFreeMaxHeight() const + { + return m_freeMaxHeight; + } //kick all the insiders out of the atlas! void EjectAllTextures(); //kick a texture out of the atlas - bool EjectTexture( Tr2AtlasTexture *tex ); + bool EjectTexture( Tr2AtlasTexture * tex ); private: // Returns true if dimensions are deemed large, thus unsuitable for atlasing. bool IsLargeTexture( unsigned int width, unsigned int height ); // Internal version of EjectTexture - does not remove the texture from the m_texturesInsideAtlas - bool EjectTextureHelper( Tr2AtlasTexture* tex ); + bool EjectTextureHelper( Tr2AtlasTexture * tex ); - void FreeArea( Tr2TextureAtlasArea * ); + void FreeArea( Tr2TextureAtlasArea* ); void ReleasePendingFreeAreas(); typedef TrackableStdList AreaList_t; @@ -144,7 +165,7 @@ BLUE_CLASS( Tr2TextureAtlas ): Tr2RenderContextEnum::PixelFormat m_format; unsigned int m_width; unsigned int m_height; - + typedef TrackableStdSet Tr2AtlasTextureSet_t; Tr2AtlasTextureSet_t m_texturesInAtlas; @@ -168,9 +189,10 @@ BLUE_CLASS( Tr2TextureAtlas ): bool m_hasMipMaps; unsigned m_mipLevels; std::vector m_dirtyMipRegions; + public: //call manually to calculate lower mips - void UpdateMipMaps( Tr2RenderContext& renderContext ); + void UpdateMipMaps( Tr2RenderContext & renderContext ); //add a dirty region after changing the top level void DirtyRegion( const Tr2Rect& rect ); }; diff --git a/trinity/Tr2TextureAtlasMan.cpp b/trinity/Tr2TextureAtlasMan.cpp index 72e2ffd41..bf8932cb3 100644 --- a/trinity/Tr2TextureAtlasMan.cpp +++ b/trinity/Tr2TextureAtlasMan.cpp @@ -23,7 +23,7 @@ Tr2TextureAtlas* Tr2TextureAtlasMan::FindAtlas( Tr2RenderContextEnum::PixelForma for( auto it = m_atlases.begin(); it != m_atlases.end(); ++it ) { - if( (*it)->GetFormat() == fmt ) + if( ( *it )->GetFormat() == fmt ) { return *it; } @@ -59,7 +59,7 @@ void Tr2TextureAtlasMan::RemoveAtlas( Tr2RenderContextEnum::PixelFormat fmt ) ssize_t ix = 0; for( auto it = m_atlases.begin(); it != m_atlases.end(); ++it, ++ix ) { - if( (*it)->GetFormat() == fmt ) + if( ( *it )->GetFormat() == fmt ) { m_atlases.Remove( ix ); break; diff --git a/trinity/Tr2TextureAtlasMan.h b/trinity/Tr2TextureAtlasMan.h index 57fa6a968..e32c7953a 100644 --- a/trinity/Tr2TextureAtlasMan.h +++ b/trinity/Tr2TextureAtlasMan.h @@ -16,12 +16,11 @@ extern Tr2TextureAtlasMan* g_textureAtlasMan; // A Tr2TextureAtlasMan holds Tr2TextureAtlas objects. It acts as // centralized depository for finding an atlas for a given texture // format. -class Tr2TextureAtlasMan: - public IRoot +class Tr2TextureAtlasMan : public IRoot { public: - EXPOSE_TO_BLUE(); - Tr2TextureAtlasMan( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2TextureAtlasMan( IRoot* lockobj = NULL ); void AddAtlas( Tr2RenderContextEnum::PixelFormat fmt, unsigned int width, unsigned int height ); void RemoveAtlas( Tr2RenderContextEnum::PixelFormat fmt ); @@ -33,7 +32,7 @@ class Tr2TextureAtlasMan: private: PTr2TextureAtlasVectorRO m_atlases; - + // FindAtlas may be called on a background thread. We need to protect // access to the m_atlases vector in case an atlas is added as // we're looking for an atlas. diff --git a/trinity/Tr2TextureAtlasMan_Blue.cpp b/trinity/Tr2TextureAtlasMan_Blue.cpp index f748e4c1f..1c51b0a2f 100644 --- a/trinity/Tr2TextureAtlasMan_Blue.cpp +++ b/trinity/Tr2TextureAtlasMan_Blue.cpp @@ -7,35 +7,29 @@ BLUE_DEFINE( Tr2TextureAtlasMan ); const Be::ClassInfo* Tr2TextureAtlasMan::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2TextureAtlasMan, "" ) - MAP_INTERFACE( Tr2TextureAtlasMan ) + EXPOSURE_BEGIN( Tr2TextureAtlasMan, "" ) + MAP_INTERFACE( Tr2TextureAtlasMan ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "atlases", m_atlases, "List of atlases provided, each with a different texture format", - Be::READ - ) + Be::READ ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "AddAtlas", AddAtlasWrap, "Add a texture atlas with the given format and dimensions.\n\n" "Arguments:\n" ":param fmt: The texture format (trinity.PIXEL_FORMAT)\n" ":param width: The width of the texture atlas\n" - ":param height: The height of the texture atlas" - ) + ":param height: The height of the texture atlas" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RemoveAtlas", RemoveAtlasWrap, "Removes a texture atlas with the given format.\n\n" - ":param fmt: The texture format" - ) + ":param fmt: The texture format" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2TextureAtlas_Blue.cpp b/trinity/Tr2TextureAtlas_Blue.cpp index 92c5b88eb..0c762e7d7 100644 --- a/trinity/Tr2TextureAtlas_Blue.cpp +++ b/trinity/Tr2TextureAtlas_Blue.cpp @@ -9,165 +9,127 @@ BLUE_DEFINE( Tr2TextureAtlas ); const Be::ClassInfo* Tr2TextureAtlas::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2TextureAtlas, "" ) - MAP_INTERFACE( Tr2TextureAtlas ) + EXPOSURE_BEGIN( Tr2TextureAtlas, "" ) + MAP_INTERFACE( Tr2TextureAtlas ) MAP_INTERFACE( ITr2TextureProvider ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + MAP_ATTRIBUTE_WITH_CHOOSER( "format", m_format, "Texture format", Be::READ | Be::ENUM, - Tr2RenderContextEnum_PixelFormat_Chooser - ) + Tr2RenderContextEnum_PixelFormat_Chooser ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "width", m_width, "Width of the texture used for the atlas", - Be::READ - ) + Be::READ ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "height", m_height, "Height of the texture used for the atlas", - Be::READ - ) + Be::READ ) MAP_ATTRIBUTE( "mipCount", m_mipLevels, "", Be::READ ); MAP_PROPERTY_READONLY( "multiSampleType", GetMsaaSamples, "" ); MAP_PROPERTY_READONLY( "multiSampleQuality", GetMsaaQuality, "" ); - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "optimizeOnRemoval", m_optimizeOnRemoval, "If true, the atlas attempts to collapse free areas and pull in outsiders\n" "whenever free space opens up in the atlas.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "paintEmptyAreas", m_paintEmptyAreas, "If true, empty areas are painted in unique colors. This is useful for visualizing\n" "fragmentation in the atlas.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "margin", m_margin, "Margin for each texture in the atlas, in pixels.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "texturesInAtlasCount", GetTexturesInAtlasCount, - "How many textures are in the atlas texture?" - ) + "How many textures are in the atlas texture?" ) - MAP_PROPERTY_READONLY - ( + MAP_PROPERTY_READONLY( "texturesOutsideAtlasCount", GetTexturesOutsideAtlasCount, - "How many textures are registered with the atlas but didn't fit?" - ) + "How many textures are registered with the atlas but didn't fit?" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetFreeTexels", GetFreeTexels, - "How many texels are not assigned to a texture in the atlas" - ) + "How many texels are not assigned to a texture in the atlas" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetFreeTexelPercentage", GetFreeTexelPercentage, - "Percentage of the atlas that is unused" - ) + "Percentage of the atlas that is unused" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "CollapseFreeAreas", CollapseFreeAreas, - "Collapses adjacent free areas where possible to make room for larger textures" - ) + "Collapses adjacent free areas where possible to make room for larger textures" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "ConsolidateFreeAreas", ConsolidateFreeAreas, - "Tries to consolidate adjacent free areas, improving the 'squareness' of free regions" - ) + "Tries to consolidate adjacent free areas, improving the 'squareness' of free regions" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "PullInOutsiders", PullInOutsiders, "Moves any textures that were registered with the atlas and left outside\n" "into the atlas, as much as free space allows\n" - ":param optimizeInsertion: \n" - ) + ":param optimizeInsertion: \n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetFreeMaxWidth", GetFreeMaxWidth, - "Get the width of the largest free area in the atlas" - ) + "Get the width of the largest free area in the atlas" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetFreeMaxHeight", GetFreeMaxHeight, - "Get the height of the largest free area in the atlas" - ) + "Get the height of the largest free area in the atlas" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "EjectAllTextures", EjectAllTextures, - "Eject all textures from the atlas" - ) + "Eject all textures from the atlas" ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "CreateTexture", CreateTexture, 1, "Creates a texture of the given dimensions in the atlas.\n\n" ":param width: Width of the texture\n" ":param height: Height of the texture\n" - ":param textureType: Texture type" - ) + ":param textureType: Texture type" ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetTexturesOutsideAtlas", GetTexturesOutsideAtlas, "Returns a list of all textures that were registered with the atlas\n" - "and left outside." - ) + "and left outside." ) #endif - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "HasALObject", HasALObject, "Returns True iff Tr2TextureAtlas contains a reference to passed AL object ID.\n" "Used for debugging along with trinity.GetLiveALResources.\n" ":param alType: AL object type (trinity.AL_OBJECT_TYPE)\n" - ":param alObject: AL object ID" - ) + ":param alObject: AL object ID" ) EXPOSURE_END() } diff --git a/trinity/Tr2TextureReference.cpp b/trinity/Tr2TextureReference.cpp index 6da3af621..524ca489f 100644 --- a/trinity/Tr2TextureReference.cpp +++ b/trinity/Tr2TextureReference.cpp @@ -103,8 +103,8 @@ std::string Tr2TextureReference::GetName() const return name ? name : ""; } -Tr2TransientTextureReference::Tr2TransientTextureReference( IRoot* ) - :m_texture( nullptr ) +Tr2TransientTextureReference::Tr2TransientTextureReference( IRoot* ) : + m_texture( nullptr ) { } diff --git a/trinity/Tr2TextureReference.h b/trinity/Tr2TextureReference.h index 05b858150..ec299353b 100644 --- a/trinity/Tr2TextureReference.h +++ b/trinity/Tr2TextureReference.h @@ -14,7 +14,8 @@ // counting. It also allows using internal engine textures // with variable stores. // ------------------------------------------------------------- -BLUE_CLASS( Tr2TextureReference ): public ITr2TextureProvider +BLUE_CLASS( Tr2TextureReference ) : + public ITr2TextureProvider { public: EXPOSE_TO_BLUE(); @@ -45,11 +46,12 @@ TYPEDEF_BLUECLASS( Tr2TextureReference ); // ------------------------------------------------------------- // Description: -// Similar to Tr2TextureReference, but stores a pointer to -// Tr2TextureAL. The user of this object needs to store +// Similar to Tr2TextureReference, but stores a pointer to +// Tr2TextureAL. The user of this object needs to store // Tr2TextureAL object and manage lifetime. // ------------------------------------------------------------- -BLUE_CLASS( Tr2TransientTextureReference ) : public ITr2TextureProvider +BLUE_CLASS( Tr2TransientTextureReference ) : + public ITr2TextureProvider { public: EXPOSE_TO_BLUE(); @@ -59,7 +61,8 @@ BLUE_CLASS( Tr2TransientTextureReference ) : public ITr2TextureProvider virtual Tr2TextureAL* GetTexture(); OnTextureChangeEvent& OnTextureChange() override; - void SetTexture( Tr2TextureAL* texture ); + void SetTexture( Tr2TextureAL * texture ); + private: Tr2TextureAL* m_texture; OnTextureChangeEvent m_onTextureChange; diff --git a/trinity/Tr2TextureReference_Blue.cpp b/trinity/Tr2TextureReference_Blue.cpp index 99865d747..bf672864d 100644 --- a/trinity/Tr2TextureReference_Blue.cpp +++ b/trinity/Tr2TextureReference_Blue.cpp @@ -6,28 +6,26 @@ BLUE_DEFINE( Tr2TextureReference ); -const Be::ClassInfo* Tr2TextureReference::ExposeToBlue() -{ - EXPOSURE_BEGIN( Tr2TextureReference, "" ) - MAP_INTERFACE( Tr2TextureReference ) - MAP_INTERFACE( ITr2TextureProvider ) - - MAP_PROPERTY_READONLY( "width", GetWidth, "Texture width" ) - MAP_PROPERTY_READONLY( "height", GetHeight, "Texture height" ) - MAP_PROPERTY_READONLY( "depth", GetDepth, "Texture depth" ) - MAP_PROPERTY_READONLY( "type", GetType, "Texture type" ) - MAP_PROPERTY_READONLY( "mipCount", GetMipCount, "Number of mip levels" ) - MAP_PROPERTY_READONLY( "format", GetFormat, "Texture pixel format" ) - MAP_PROPERTY_READONLY( "arraySize", GetArraySize, "Number of textures in the array" ) - MAP_PROPERTY_READONLY( "name", GetName, "Texture name" ) - - MAP_METHOD_AND_WRAP( - "Save", - Save, - "Saves referenced texture to disk.\n" - ":param path: res path to the file" - ) - EXPOSURE_END() +const Be::ClassInfo* Tr2TextureReference::ExposeToBlue(){ + EXPOSURE_BEGIN( Tr2TextureReference, "" ) + MAP_INTERFACE( Tr2TextureReference ) + MAP_INTERFACE( ITr2TextureProvider ) + + MAP_PROPERTY_READONLY( "width", GetWidth, "Texture width" ) + MAP_PROPERTY_READONLY( "height", GetHeight, "Texture height" ) + MAP_PROPERTY_READONLY( "depth", GetDepth, "Texture depth" ) + MAP_PROPERTY_READONLY( "type", GetType, "Texture type" ) + MAP_PROPERTY_READONLY( "mipCount", GetMipCount, "Number of mip levels" ) + MAP_PROPERTY_READONLY( "format", GetFormat, "Texture pixel format" ) + MAP_PROPERTY_READONLY( "arraySize", GetArraySize, "Number of textures in the array" ) + MAP_PROPERTY_READONLY( "name", GetName, "Texture name" ) + + MAP_METHOD_AND_WRAP( + "Save", + Save, + "Saves referenced texture to disk.\n" + ":param path: res path to the file" ) + EXPOSURE_END() } diff --git a/trinity/Tr2Transform.cpp b/trinity/Tr2Transform.cpp index 86db63c66..ac65bb113 100644 --- a/trinity/Tr2Transform.cpp +++ b/trinity/Tr2Transform.cpp @@ -32,10 +32,10 @@ void Tr2Transform::Update( Be::Time time ) { return; } - + for( TriCurveSetVector::const_iterator it = m_curveSets.begin(); it != m_curveSets.end(); ++it ) { - (*it)->Update( TimeAsDouble( time ) ); + ( *it )->Update( TimeAsDouble( time ) ); } } @@ -53,12 +53,12 @@ void Tr2Transform::UpdateViewDependentData( const TriFrustum& frustum, const Mat //fovHeight is the thing to multiply with to let the object //always keep the same height on screen - const float fovHeight = sinf(fov/2.0f) * dist ; + const float fovHeight = sinf( fov / 2.0f ) * dist; //this is the number we want to reduce it by - const float scaler = m_distanceBasedScaleArg1/powf( fovHeight, m_distanceBasedScaleArg2 ); - const float scale = scaler*fovHeight; - + const float scaler = m_distanceBasedScaleArg1 / powf( fovHeight, m_distanceBasedScaleArg2 ); + const float scale = scaler * fovHeight; + finalScale = m_scaling * scale; } else @@ -71,187 +71,179 @@ void Tr2Transform::UpdateViewDependentData( const TriFrustum& frustum, const Mat switch( m_modifier ) { - case TR2TM_BILLBOARD: - case TR2TM_SIMPLE_HALO: - { - float parentScaleX = Length( parentTransform.GetX() ); - float parentScaleY = Length( parentTransform.GetY() ); - float parentScaleZ = Length( parentTransform.GetZ() ); - finalScale.x *= parentScaleX; - finalScale.y *= parentScaleY; - finalScale.z *= parentScaleZ; - - if( m_modifier == TR2TM_SIMPLE_HALO ) - { - const Vector3& myPos = m_worldTransform.GetTranslation(); - const Vector3& camPos = Tr2Renderer::GetViewPosition(); - Vector3 d = camPos - myPos; - - Vector3 backward; - - float scale = Dot( - Normalize( d ), - Normalize( *TriVectorRotatedBasisMatrix( &backward, TRITA_Z, &m_worldTransform ) ) - ); - - if( scale < 0.0f ) - { - scale = 0.0f; - } - - finalScale *= scale*scale; - } - - const Matrix& invView = Tr2Renderer::GetInverseViewTransform(); - m_worldTransform._11 = invView._11 * finalScale.x; - m_worldTransform._12 = invView._12 * finalScale.x; - m_worldTransform._13 = invView._13 * finalScale.x; - m_worldTransform._21 = invView._21 * finalScale.y; - m_worldTransform._22 = invView._22 * finalScale.y; - m_worldTransform._23 = invView._23 * finalScale.y; - m_worldTransform._31 = invView._31 * finalScale.z; - m_worldTransform._32 = invView._32 * finalScale.z; - m_worldTransform._33 = invView._33 * finalScale.z; - } - break; + case TR2TM_BILLBOARD: + case TR2TM_SIMPLE_HALO: { + float parentScaleX = Length( parentTransform.GetX() ); + float parentScaleY = Length( parentTransform.GetY() ); + float parentScaleZ = Length( parentTransform.GetZ() ); + finalScale.x *= parentScaleX; + finalScale.y *= parentScaleY; + finalScale.z *= parentScaleZ; + + if( m_modifier == TR2TM_SIMPLE_HALO ) + { + const Vector3& myPos = m_worldTransform.GetTranslation(); + const Vector3& camPos = Tr2Renderer::GetViewPosition(); + Vector3 d = camPos - myPos; - case TR2TM_EVE_CAMERA_ROTATION: - { - // apply the parent transform ONLY to the translation! - Vector3 newTranslation = TransformCoord( m_translation, parentTransform ); - m_localTransform = TransformationMatrix( finalScale, m_rotation, newTranslation ); - Vector3 temp( m_localTransform._41, m_localTransform._42, m_localTransform._43 ); - m_worldTransform = m_localTransform * Tr2Renderer::GetInverseViewTransform(); - m_worldTransform._41 = temp.x; - m_worldTransform._42 = temp.y; - m_worldTransform._43 = temp.z; + Vector3 backward; - } - break; - case TR2TM_EVE_CAMERA_ROTATION_ALIGNED: - case TR2TM_EVE_BOOSTER: - case TR2TM_EVE_SIMPLE_HALO: + float scale = Dot( + Normalize( d ), + Normalize( *TriVectorRotatedBasisMatrix( &backward, TRITA_Z, &m_worldTransform ) ) ); + + if( scale < 0.0f ) { - Matrix translationTransform = TranslationMatrix( m_translation ); + scale = 0.0f; + } - m_worldTransform = translationTransform * parentTransform; + finalScale *= scale * scale; + } - const Vector3& myPos = m_worldTransform.GetTranslation(); - const Vector3& camPos = Tr2Renderer::GetViewPosition(); - Vector3 d = camPos - myPos; + const Matrix& invView = Tr2Renderer::GetInverseViewTransform(); + m_worldTransform._11 = invView._11 * finalScale.x; + m_worldTransform._12 = invView._12 * finalScale.x; + m_worldTransform._13 = invView._13 * finalScale.x; + m_worldTransform._21 = invView._21 * finalScale.y; + m_worldTransform._22 = invView._22 * finalScale.y; + m_worldTransform._23 = invView._23 * finalScale.y; + m_worldTransform._31 = invView._31 * finalScale.z; + m_worldTransform._32 = invView._32 * finalScale.z; + m_worldTransform._33 = invView._33 * finalScale.z; + } + break; + + case TR2TM_EVE_CAMERA_ROTATION: { + // apply the parent transform ONLY to the translation! + Vector3 newTranslation = TransformCoord( m_translation, parentTransform ); + m_localTransform = TransformationMatrix( finalScale, m_rotation, newTranslation ); + Vector3 temp( m_localTransform._41, m_localTransform._42, m_localTransform._43 ); + m_worldTransform = m_localTransform * Tr2Renderer::GetInverseViewTransform(); + m_worldTransform._41 = temp.x; + m_worldTransform._42 = temp.y; + m_worldTransform._43 = temp.z; + } + break; + case TR2TM_EVE_CAMERA_ROTATION_ALIGNED: + case TR2TM_EVE_BOOSTER: + case TR2TM_EVE_SIMPLE_HALO: { + Matrix translationTransform = TranslationMatrix( m_translation ); - Vector3 camFwd = d; - Matrix parentT = Transpose( parentTransform ); - TriVectorRotateMatrix(&camFwd, &camFwd, &parentT); + m_worldTransform = translationTransform * parentTransform; + const Vector3& myPos = m_worldTransform.GetTranslation(); + const Vector3& camPos = Tr2Renderer::GetViewPosition(); + Vector3 d = camPos - myPos; - float lengthSq = LengthSq( parentTransform.GetX() ); - camFwd.x /= lengthSq; - lengthSq = LengthSq( parentTransform.GetY() ); - camFwd.y /= lengthSq; - lengthSq = LengthSq( parentTransform.GetZ() ); - camFwd.z /= lengthSq; + Vector3 camFwd = d; + Matrix parentT = Transpose( parentTransform ); + TriVectorRotateMatrix( &camFwd, &camFwd, &parentT ); - float distCenter = Length( camFwd ); - camFwd = Normalize( camFwd ); - const Matrix& viewMatrix = Tr2Renderer::GetViewTransform(); - Vector3 right( viewMatrix._11, viewMatrix._21, viewMatrix._31 ); - TriVectorRotateMatrix(&right, &right, &parentT); - - Vector3 up = Normalize( Cross( camFwd, right ) ); + float lengthSq = LengthSq( parentTransform.GetX() ); + camFwd.x /= lengthSq; + lengthSq = LengthSq( parentTransform.GetY() ); + camFwd.y /= lengthSq; + lengthSq = LengthSq( parentTransform.GetZ() ); + camFwd.z /= lengthSq; - Matrix alignMat; - TriMatrixChangeBase( &alignMat, &camFwd, &up ); - TriMatrixRotate( &alignMat, &m_rotation, &alignMat ); + float distCenter = Length( camFwd ); + camFwd = Normalize( camFwd ); + const Matrix& viewMatrix = Tr2Renderer::GetViewTransform(); + Vector3 right( viewMatrix._11, viewMatrix._21, viewMatrix._31 ); + TriVectorRotateMatrix( &right, &right, &parentT ); - if( m_modifier == TR2TM_EVE_SIMPLE_HALO ) - { - Vector3 forward; + Vector3 up = Normalize( Cross( camFwd, right ) ); - forward = Normalize( *TriVectorRotatedBasisMatrix( &forward, TRITA_Z, &m_worldTransform ) ); - Vector3 backward = -forward; + Matrix alignMat; + TriMatrixChangeBase( &alignMat, &camFwd, &up ); + TriMatrixRotate( &alignMat, &m_rotation, &alignMat ); - float scale = Dot( Normalize( d ), backward ); - if( scale < 0.0f ) - { - scale = 0.0f; - } + if( m_modifier == TR2TM_EVE_SIMPLE_HALO ) + { + Vector3 forward; - Matrix scalingTransform = ScalingMatrix( m_scaling * scale ); + forward = Normalize( *TriVectorRotatedBasisMatrix( &forward, TRITA_Z, &m_worldTransform ) ); + Vector3 backward = -forward; - m_worldTransform = scalingTransform * alignMat * m_worldTransform; - } - else if( m_modifier == TR2TM_EVE_BOOSTER ) - { - float radius = 0.5f; - float B = sqrtf(distCenter*distCenter - radius*radius); - float scale = B/distCenter; - float trans = -radius*radius/(distCenter*scale); + float scale = Dot( Normalize( d ), backward ); - scale *= m_scaling.x; + if( scale < 0.0f ) + { + scale = 0.0f; + } - Matrix scalingTransform = ScalingMatrix( scale, scale, scale ); + Matrix scalingTransform = ScalingMatrix( m_scaling * scale ); - Matrix translationTransform = TranslationMatrix( 0.0f, 0.0f, trans ); + m_worldTransform = scalingTransform * alignMat * m_worldTransform; + } + else if( m_modifier == TR2TM_EVE_BOOSTER ) + { + float radius = 0.5f; + float B = sqrtf( distCenter * distCenter - radius * radius ); + float scale = B / distCenter; + float trans = -radius * radius / ( distCenter * scale ); - m_worldTransform = translationTransform * alignMat * scalingTransform * m_worldTransform; - } - else // TR2TM_EVE_CAMERA_ROTATION_ALIGNED - { - m_worldTransform = alignMat * m_worldTransform; + scale *= m_scaling.x; - Matrix scalingTransform = ScalingMatrix( finalScale ); + Matrix scalingTransform = ScalingMatrix( scale, scale, scale ); - m_worldTransform = scalingTransform * m_worldTransform; - } - } - break; + Matrix translationTransform = TranslationMatrix( 0.0f, 0.0f, trans ); - case TR2TM_LOOK_AT_CAMERA: - { - Matrix invView; - const Vector3& pos = m_worldTransform.GetTranslation(); - const Vector3& camPos = Tr2Renderer::GetViewPosition(); - invView = Transpose( LookAtMatrix( camPos, pos, Vector3( 0.0f, 1.0f, 0.0f ) ) ); - - float parentScaleX = Length( parentTransform.GetX() ); - float parentScaleY = Length( parentTransform.GetY() ); - float parentScaleZ = Length( parentTransform.GetZ() ); - finalScale.x *= parentScaleX; - finalScale.y *= parentScaleY; - finalScale.z *= parentScaleZ; - - m_worldTransform._11 = invView._11 * finalScale.x; - m_worldTransform._12 = invView._12 * finalScale.x; - m_worldTransform._13 = invView._13 * finalScale.x; - m_worldTransform._21 = invView._21 * finalScale.y; - m_worldTransform._22 = invView._22 * finalScale.y; - m_worldTransform._23 = invView._23 * finalScale.y; - m_worldTransform._31 = invView._31 * finalScale.z; - m_worldTransform._32 = invView._32 * finalScale.z; - m_worldTransform._33 = invView._33 * finalScale.z; - } - break; - - case TR2TM_TRANSLATE_WITH_CAMERA: - { - Vector3& pos = m_worldTransform.GetTranslation(); - pos = Tr2Renderer::GetViewPosition(); + m_worldTransform = translationTransform * alignMat * scalingTransform * m_worldTransform; } - break; - - case TR2TM_PRE_TRANSLATE_WITH_CAMERA: + else // TR2TM_EVE_CAMERA_ROTATION_ALIGNED { - m_localTransform = TransformationMatrix( finalScale, m_rotation, Tr2Renderer::GetViewPosition() + m_translation ); - m_worldTransform = m_localTransform * parentTransform; + m_worldTransform = alignMat * m_worldTransform; + + Matrix scalingTransform = ScalingMatrix( finalScale ); + + m_worldTransform = scalingTransform * m_worldTransform; } - break; + } + break; - default: - break; + case TR2TM_LOOK_AT_CAMERA: { + Matrix invView; + const Vector3& pos = m_worldTransform.GetTranslation(); + const Vector3& camPos = Tr2Renderer::GetViewPosition(); + invView = Transpose( LookAtMatrix( camPos, pos, Vector3( 0.0f, 1.0f, 0.0f ) ) ); + + float parentScaleX = Length( parentTransform.GetX() ); + float parentScaleY = Length( parentTransform.GetY() ); + float parentScaleZ = Length( parentTransform.GetZ() ); + finalScale.x *= parentScaleX; + finalScale.y *= parentScaleY; + finalScale.z *= parentScaleZ; + + m_worldTransform._11 = invView._11 * finalScale.x; + m_worldTransform._12 = invView._12 * finalScale.x; + m_worldTransform._13 = invView._13 * finalScale.x; + m_worldTransform._21 = invView._21 * finalScale.y; + m_worldTransform._22 = invView._22 * finalScale.y; + m_worldTransform._23 = invView._23 * finalScale.y; + m_worldTransform._31 = invView._31 * finalScale.z; + m_worldTransform._32 = invView._32 * finalScale.z; + m_worldTransform._33 = invView._33 * finalScale.z; + } + break; + + case TR2TM_TRANSLATE_WITH_CAMERA: { + Vector3& pos = m_worldTransform.GetTranslation(); + pos = Tr2Renderer::GetViewPosition(); + } + break; + + case TR2TM_PRE_TRANSLATE_WITH_CAMERA: { + m_localTransform = TransformationMatrix( finalScale, m_rotation, Tr2Renderer::GetViewPosition() + m_translation ); + m_worldTransform = m_localTransform * parentTransform; + } + break; + + default: + break; } } @@ -259,7 +251,7 @@ bool Tr2Transform::HasTransparentBatches() { if( m_display && m_mesh ) { - return !(m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty()); + return !( m_mesh->GetAreas( TRIBATCHTYPE_TRANSPARENT )->empty() ); } return false; diff --git a/trinity/Tr2Transform.h b/trinity/Tr2Transform.h index 7f737ab97..bb7d3f8ad 100644 --- a/trinity/Tr2Transform.h +++ b/trinity/Tr2Transform.h @@ -37,12 +37,11 @@ enum Tr2TransformModifier class ITriRenderBatchAccumulator; -class Tr2Transform: - public ITr2Renderable +class Tr2Transform : public ITr2Renderable { public: - EXPOSE_TO_BLUE(); - Tr2Transform( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2Transform( IRoot* lockobj = NULL ); ///////////////////////////////////////////////////////////////////////////////////// // ITr2Renderable @@ -51,9 +50,18 @@ class Tr2Transform: virtual bool HasTransparentBatches(); virtual float GetSortValue(); - void SetScaling( Vector3 scaling ) { m_scaling = scaling; }; - void SetRotation( Quaternion rotation ) { m_rotation = rotation; }; - void SetTranslation( Vector3 translation ) { m_translation = translation; }; + void SetScaling( Vector3 scaling ) + { + m_scaling = scaling; + }; + void SetRotation( Quaternion rotation ) + { + m_rotation = rotation; + }; + void SetTranslation( Vector3 translation ) + { + m_translation = translation; + }; Tr2MeshBasePtr GetMesh() const; @@ -67,7 +75,7 @@ class Tr2Transform: // Update everything that's camera dependent, such as billboards. Is called for every render, to support // multiple camera's looking at the same scene. // For now, this is called from any code that has a Tr2Transform, from inside GetRenderables; this way things - // such as a view dependent m_worldTransform are set up properly for GetSortValue and GetPerObjectData to work right. + // such as a view dependent m_worldTransform are set up properly for GetSortValue and GetPerObjectData to work right. virtual void UpdateViewDependentData( const TriFrustum& frustum, const Matrix& parentTransform ); protected: diff --git a/trinity/Tr2Transform_Blue.cpp b/trinity/Tr2Transform_Blue.cpp index f79f2c906..a1ba58c1e 100644 --- a/trinity/Tr2Transform_Blue.cpp +++ b/trinity/Tr2Transform_Blue.cpp @@ -5,91 +5,65 @@ BLUE_DEFINE_ABSTRACT( Tr2Transform ); -Be::VarChooser ModifierChooser[] = -{ - { - "None", - BeCast( TR2TM_NONE ), - "No modifier on transform" - }, - { - "Billboard", - BeCast( TR2TM_BILLBOARD ), - "Aligned with the camera - useful for sprites" - }, - { - "Translate with camera", - BeCast( TR2TM_TRANSLATE_WITH_CAMERA ), - "Translates with the camera, rotation is not affected" - }, - { - "Look at camera", - BeCast( TR2TM_LOOK_AT_CAMERA ), - "Aligned with the camera - similar to Billboard, but works for 3D objects" - }, - { - "Simple halo", - BeCast( TR2TM_SIMPLE_HALO ), - "Aligned with the camera, scales with angle to camera - useful for light glows" - }, - { - "Pre-translate with camera", - BeCast( TR2TM_PRE_TRANSLATE_WITH_CAMERA ), - "Translates with the camera, preserving local transform" - }, - { - "EVE Camera rotation aligned", - BeCast( TR2TM_EVE_CAMERA_ROTATION_ALIGNED ), - "Do not use in new content! Similar to billboard - used for converted content." - }, - { - "Booster", - BeCast( TR2TM_EVE_BOOSTER ), - "Do not use in new content! Something old..." - }, - { - "EVE Simple halo", - BeCast( TR2TM_EVE_SIMPLE_HALO ), - "Do not use in new content! Similar to simple halo - used for converted content." - }, - { - "EVE Camera rotation", - BeCast( TR2TM_EVE_CAMERA_ROTATION ), - "Do not use in new content! Similar to billboard - used for converted content." - }, +Be::VarChooser ModifierChooser[] = { + { "None", + BeCast( TR2TM_NONE ), + "No modifier on transform" }, + { "Billboard", + BeCast( TR2TM_BILLBOARD ), + "Aligned with the camera - useful for sprites" }, + { "Translate with camera", + BeCast( TR2TM_TRANSLATE_WITH_CAMERA ), + "Translates with the camera, rotation is not affected" }, + { "Look at camera", + BeCast( TR2TM_LOOK_AT_CAMERA ), + "Aligned with the camera - similar to Billboard, but works for 3D objects" }, + { "Simple halo", + BeCast( TR2TM_SIMPLE_HALO ), + "Aligned with the camera, scales with angle to camera - useful for light glows" }, + { "Pre-translate with camera", + BeCast( TR2TM_PRE_TRANSLATE_WITH_CAMERA ), + "Translates with the camera, preserving local transform" }, + { "EVE Camera rotation aligned", + BeCast( TR2TM_EVE_CAMERA_ROTATION_ALIGNED ), + "Do not use in new content! Similar to billboard - used for converted content." }, + { "Booster", + BeCast( TR2TM_EVE_BOOSTER ), + "Do not use in new content! Something old..." }, + { "EVE Simple halo", + BeCast( TR2TM_EVE_SIMPLE_HALO ), + "Do not use in new content! Similar to simple halo - used for converted content." }, + { "EVE Camera rotation", + BeCast( TR2TM_EVE_CAMERA_ROTATION ), + "Do not use in new content! Similar to billboard - used for converted content." }, { 0 } }; const Be::ClassInfo* Tr2Transform::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2Transform,"" ) - MAP_INTERFACE( Tr2Transform ) + EXPOSURE_BEGIN( Tr2Transform, "" ) + MAP_INTERFACE( Tr2Transform ) MAP_INTERFACE( ITr2Renderable ) - MAP_ATTRIBUTE_WITH_CHOOSER( "modifier", - m_modifier, - "Modifier on the transform for special effects like camera facing", - Be::READWRITE | Be::PERSIST | Be::ENUM, - ModifierChooser - ) - MAP_ATTRIBUTE( "display", m_display, - "If set, this transform hierarchy is displayed.\n" - "Note that turning off display does not automatically turn\n" - "off update.", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE_WITH_CHOOSER( "modifier", + m_modifier, + "Modifier on the transform for special effects like camera facing", + Be::READWRITE | Be::PERSIST | Be::ENUM, + ModifierChooser ) + MAP_ATTRIBUTE( "display", m_display, "If set, this transform hierarchy is displayed.\n" + "Note that turning off display does not automatically turn\n" + "off update.", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "sortValueMultiplier", m_sortValueMultiplier, "Multiplier on the camera distance returned as the sort value. This can be used to affect\n" "the sorting of individual objects in the same transform hierarchy.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE( "useDistanceBasedScale", - m_useDistanceBasedScale, - "If set, additional scaling is done based on distance from camera.", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "useDistanceBasedScale", + m_useDistanceBasedScale, + "If set, additional scaling is done based on distance from camera.", + Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "name", m_name, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "update", m_update, "If set, this transform hierarchy is updated every frame.", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "scaling", m_scaling, "", Be::READWRITE | Be::PERSIST ) @@ -102,5 +76,5 @@ const Be::ClassInfo* Tr2Transform::ExposeToBlue() MAP_ATTRIBUTE( "mesh", m_mesh, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curvesets for animating things", Be::READ | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/Tr2TranslationTool.cpp b/trinity/Tr2TranslationTool.cpp index 52ffe2e5e..9bbdf9381 100644 --- a/trinity/Tr2TranslationTool.cpp +++ b/trinity/Tr2TranslationTool.cpp @@ -7,54 +7,54 @@ #include "Tr2LineSet.h" #include "Shader/Tr2Effect.h" -Tr2TranslationTool::Tr2TranslationTool( IRoot* lockobj ): +Tr2TranslationTool::Tr2TranslationTool( IRoot* lockobj ) : Tr2ManipulationTool( lockobj ) { GenLineSets(); - SelectAxis("w"); + SelectAxis( "w" ); m_translation.x = 0.0f; m_translation.y = 0.0f; m_translation.z = 0.0f; } - + void Tr2TranslationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ) -{ +{ /* The movement is always based on the delta mouse changes and the current translation tools screen coordinates. We first project the tools location to screen coordinates, then we use that as the relative screen point for the mouse movement. If there is a move callback we check the return value to see if the movement was legal or not. */ - // + // Vector3 pos; Vector2 screenPos; Vector3 normal; Vector3 ray; Vector3 startPos; - + pos.x = m_localTransform._41; pos.y = m_localTransform._42; pos.z = m_localTransform._43; - + // We might be in world or local Vector3 xAxis; Vector3 yAxis; Vector3 zAxis; GetBaseVectors( xAxis, yAxis, zAxis ); - + // Get the location of the tool on screen - PointToScreenCoordinates(pos, screenPos, viewport, viewMatrix, projectionMatrix ); + PointToScreenCoordinates( pos, screenPos, viewport, viewMatrix, projectionMatrix ); int curMouseX = (int)screenPos.x; int curMouseY = (int)screenPos.y; // Get the pick ray from the tools screen location - ScreenCoordinatesToRay(curMouseX, curMouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); + ScreenCoordinatesToRay( curMouseX, curMouseY, ray, startPos, viewport, viewMatrix, projectionMatrix ); // Get the normal for the best plane to use normal = GetDesiredPlaneNormal( ray, viewMatrix ); - - Vector3 delta = MovePointOnPlane(curMouseX, curMouseY, curMouseX+mouseXDelta, curMouseY+mouseYDelta, pos, normal, viewport, viewMatrix, projectionMatrix ); - + + Vector3 delta = MovePointOnPlane( curMouseX, curMouseY, curMouseX + mouseXDelta, curMouseY + mouseYDelta, pos, normal, viewport, viewMatrix, projectionMatrix ); + Vector3 translate; m_moved = true; if( m_selectedAxis == "w" ) @@ -67,12 +67,12 @@ void Tr2TranslationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mous translate = xAxis * scale; } else if( m_selectedAxis == "y" ) - { + { float scale = Dot( delta, yAxis ); translate = yAxis * scale; } else if( m_selectedAxis == "z" ) - { + { float scale = Dot( delta, zAxis ); translate = zAxis * scale; } @@ -86,7 +86,7 @@ void Tr2TranslationTool::Move( int mouseX, int mouseY, int mouseXDelta, int mous m_movement.z += translate.z; } -std::vector& Tr2TranslationTool::GetPrimitivesToRender( ) +std::vector& Tr2TranslationTool::GetPrimitivesToRender() { // Depending on the mode of the tool. We want to control which parts of it will // be rendered @@ -97,9 +97,9 @@ std::vector& Tr2TranslationTool::GetPrimitivesToRender( ) // ring for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == "w" || (*it)->m_name == m_selectedAxis ) + if( ( *it )->m_name == "w" || ( *it )->m_name == m_selectedAxis ) { - m_visibleObjects.push_back((*it)); + m_visibleObjects.push_back( ( *it ) ); } } } @@ -107,8 +107,8 @@ std::vector& Tr2TranslationTool::GetPrimitivesToRender( ) { for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - m_visibleObjects.push_back((*it)); - } + m_visibleObjects.push_back( ( *it ) ); + } } return m_visibleObjects; } @@ -117,21 +117,21 @@ void Tr2TranslationTool::ResetPrimitiveColors() { for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - if((*it)->m_name == "x" ) + if( ( *it )->m_name == "x" ) { - (*it)->SetCurrentColor((Color&)v4Red); + ( *it )->SetCurrentColor( (Color&)v4Red ); } - else if((*it)->m_name == "y" ) + else if( ( *it )->m_name == "y" ) { - (*it)->SetCurrentColor((Color&)v4Green); + ( *it )->SetCurrentColor( (Color&)v4Green ); } - else if((*it)->m_name == "z" ) + else if( ( *it )->m_name == "z" ) { - (*it)->SetCurrentColor((Color&)v4Blue); + ( *it )->SetCurrentColor( (Color&)v4Blue ); } - else if((*it)->m_name == "w" ) + else if( ( *it )->m_name == "w" ) { - (*it)->SetCurrentColor((Color&)v4Cyan); + ( *it )->SetCurrentColor( (Color&)v4Cyan ); } } } @@ -163,52 +163,52 @@ void Tr2TranslationTool::GenLineSets() Tr2EffectPtr mLineEffect; Tr2EffectPtr pEffect; - if( !xCone .CreateInstance() || - !yCone .CreateInstance() || - !zCone .CreateInstance() || - !xLine .CreateInstance() || - !yLine .CreateInstance() || - !zLine .CreateInstance() || - !wLine .CreateInstance() || - !pEffect .CreateInstance() || - !mLineEffect.CreateInstance() || + if( !xCone.CreateInstance() || + !yCone.CreateInstance() || + !zCone.CreateInstance() || + !xLine.CreateInstance() || + !yLine.CreateInstance() || + !zLine.CreateInstance() || + !wLine.CreateInstance() || + !pEffect.CreateInstance() || + !mLineEffect.CreateInstance() || !mSolidEffect.CreateInstance() ) { return; } - - mSolidEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/SolidsNoZ.fx"); - mLineEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx"); - pEffect->SetEffectPathName("res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); - - xLine->AddLine( v3Zero, v4Red, v3X, v4Red ); - c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3(0.3f, 0.0f, 0.0f), (Vector3&)v3X, 0.08f, &numVectors); - for( int i = 0; i < numVectors/3; i++ ) + + mSolidEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/SolidsNoZ.fx" ); + mLineEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/LinesNoZ.fx" ); + pEffect->SetEffectPathName( "res:/Graphics/Effect/Managed/Utility/PrimitivePicking.fx" ); + + xLine->AddLine( v3Zero, v4Red, v3X, v4Red ); + c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3( 0.3f, 0.0f, 0.0f ), (Vector3&)v3X, 0.08f, &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - xLine->AddPickingTriangle( c_tris[i*3], c_tris[i*3+1], c_tris[i*3+2] ); + xLine->AddPickingTriangle( c_tris[i * 3], c_tris[i * 3 + 1], c_tris[i * 3 + 2] ); } - delete [] c_tris; + delete[] c_tris; xLine->SubmitChanges(); xLine->m_name = "x"; - yLine->AddLine( v3Zero, v4Green, v3Y, v4Green ); - c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3(0.0f, 0.3f, 0.0f), (Vector3&)v3Y, 0.08f, &numVectors); - for( int i = 0; i < numVectors/3; i++ ) + yLine->AddLine( v3Zero, v4Green, v3Y, v4Green ); + c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3( 0.0f, 0.3f, 0.0f ), (Vector3&)v3Y, 0.08f, &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - yLine->AddPickingTriangle( c_tris[i*3], c_tris[i*3+1], c_tris[i*3+2] ); + yLine->AddPickingTriangle( c_tris[i * 3], c_tris[i * 3 + 1], c_tris[i * 3 + 2] ); } - delete [] c_tris; + delete[] c_tris; yLine->SubmitChanges(); yLine->m_name = "y"; - zLine->AddLine( v3Zero, v4Blue, v3Z, v4Blue ); - c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3(0.0f, 0.0f, 0.3f), (Vector3&)v3Z, 0.08f, &numVectors); - for( int i = 0; i < numVectors/3; i++ ) + zLine->AddLine( v3Zero, v4Blue, v3Z, v4Blue ); + c_tris = Tr2ManipulationTool::GetTrianglesAroundLine( Vector3( 0.0f, 0.0f, 0.3f ), (Vector3&)v3Z, 0.08f, &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - zLine->AddPickingTriangle( c_tris[i*3], c_tris[i*3+1], c_tris[i*3+2] ); + zLine->AddPickingTriangle( c_tris[i * 3], c_tris[i * 3 + 1], c_tris[i * 3 + 2] ); } - delete [] c_tris; + delete[] c_tris; zLine->SubmitChanges(); zLine->m_name = "z"; @@ -217,32 +217,32 @@ void Tr2TranslationTool::GenLineSets() xLine->m_pickEffect = yLine->m_pickEffect = zLine->m_pickEffect = pEffect; //xCone - c_tris = Tr2ManipulationTool::GetConeTriangles(0.25f, 0.075f, subDivisions, &numVectors); + c_tris = Tr2ManipulationTool::GetConeTriangles( 0.25f, 0.075f, subDivisions, &numVectors ); TransformCoords( c_tris, numVectors, transform ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - xCone->AddTriangle(c_tris[i*3], v4Red,c_tris[i*3+1], v4Red, c_tris[i*3+2], v4Red ); - } - delete [] c_tris; + xCone->AddTriangle( c_tris[i * 3], v4Red, c_tris[i * 3 + 1], v4Red, c_tris[i * 3 + 2], v4Red ); + } + delete[] c_tris; xCone->SubmitChanges(); xCone->m_name = "x"; xCone->m_scaleByDistanceToView = true; xCone->m_effect = mSolidEffect; - xCone->m_pickEffect = pEffect; - - m_primitives.Insert( -1, xCone->GetRawRoot()); + xCone->m_pickEffect = pEffect; + + m_primitives.Insert( -1, xCone->GetRawRoot() ); - //yCone - c_tris = Tr2ManipulationTool::GetConeTriangles(0.25f, 0.075f, subDivisions, &numVectors); + //yCone + c_tris = Tr2ManipulationTool::GetConeTriangles( 0.25f, 0.075f, subDivisions, &numVectors ); TransformCoords( c_tris, numVectors, translation ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - yCone->AddTriangle( c_tris[i*3],v4Green, c_tris[i*3+1], v4Green, c_tris[i*3+2], v4Green ); - } - delete [] c_tris; + yCone->AddTriangle( c_tris[i * 3], v4Green, c_tris[i * 3 + 1], v4Green, c_tris[i * 3 + 2], v4Green ); + } + delete[] c_tris; yCone->SubmitChanges(); yCone->m_name = "y"; @@ -250,19 +250,19 @@ void Tr2TranslationTool::GenLineSets() yCone->m_effect = mSolidEffect; yCone->m_pickEffect = pEffect; - m_primitives.Insert( -1, yCone->GetRawRoot()); + m_primitives.Insert( -1, yCone->GetRawRoot() ); //zCone - c_tris = Tr2ManipulationTool::GetConeTriangles(0.25f, 0.075f, subDivisions, &numVectors); + c_tris = Tr2ManipulationTool::GetConeTriangles( 0.25f, 0.075f, subDivisions, &numVectors ); rotateMat = RotationXMatrix( XM_PI / 2.0f ); transform = translation * rotateMat; TransformCoords( c_tris, numVectors, transform ); - for( int i = 0; i < numVectors/3; i++ ) + for( int i = 0; i < numVectors / 3; i++ ) { - zCone->AddTriangle( c_tris[i*3],v4Blue, c_tris[i*3+1], v4Blue, c_tris[i*3+2], v4Blue ); - } - delete [] c_tris; + zCone->AddTriangle( c_tris[i * 3], v4Blue, c_tris[i * 3 + 1], v4Blue, c_tris[i * 3 + 2], v4Blue ); + } + delete[] c_tris; zCone->SubmitChanges(); zCone->m_name = "z"; @@ -270,22 +270,22 @@ void Tr2TranslationTool::GenLineSets() zCone->m_effect = mSolidEffect; zCone->m_pickEffect = pEffect; - m_primitives.Insert( -1, zCone->GetRawRoot()); + m_primitives.Insert( -1, zCone->GetRawRoot() ); // wLines - c_tris = Tr2ManipulationTool::GetCirclePoints(0.25f, subDivisions, &numVectors); - for( int i = 0; i < numVectors/2; i++ ) + c_tris = Tr2ManipulationTool::GetCirclePoints( 0.25f, subDivisions, &numVectors ); + for( int i = 0; i < numVectors / 2; i++ ) { - wLine->AddLine( c_tris[i*2], v4Cyan, c_tris[i*2+1], v4Cyan ); + wLine->AddLine( c_tris[i * 2], v4Cyan, c_tris[i * 2 + 1], v4Cyan ); } - delete [] c_tris; + delete[] c_tris; - c_tris = Tr2ManipulationTool::GetCircleTriangles(0.25f, subDivisions, &numVectors); - for( int i = 0; i < numVectors/3; i++ ) + c_tris = Tr2ManipulationTool::GetCircleTriangles( 0.25f, subDivisions, &numVectors ); + for( int i = 0; i < numVectors / 3; i++ ) { - wLine->AddPickingTriangle( c_tris[i*3], c_tris[i*3+1], c_tris[i*3+2] ); + wLine->AddPickingTriangle( c_tris[i * 3], c_tris[i * 3 + 1], c_tris[i * 3 + 2] ); } - delete [] c_tris; + delete[] c_tris; wLine->SubmitChanges(); wLine->m_name = "w"; wLine->m_scaleByDistanceToView = true; @@ -293,10 +293,10 @@ void Tr2TranslationTool::GenLineSets() wLine->m_pickEffect = pEffect; wLine->m_viewOriented = true; - m_primitives.Insert( -1, wLine->GetRawRoot()); - m_primitives.Insert( -1, xLine->GetRawRoot()); - m_primitives.Insert( -1, yLine->GetRawRoot()); - m_primitives.Insert( -1, zLine->GetRawRoot()); + m_primitives.Insert( -1, wLine->GetRawRoot() ); + m_primitives.Insert( -1, xLine->GetRawRoot() ); + m_primitives.Insert( -1, yLine->GetRawRoot() ); + m_primitives.Insert( -1, zLine->GetRawRoot() ); } void Tr2TranslationTool::Update() @@ -307,7 +307,7 @@ void Tr2TranslationTool::Update() Matrix translation = TranslationMatrix( m_movement ); temp = m_localTransform * translation; // Check the move callback for if we should be moving or not - if( OnMoveCallback( m_localTransform, temp )) + if( OnMoveCallback( m_localTransform, temp ) ) { m_localTransform = temp; m_translation.x = m_localTransform._41; @@ -324,9 +324,7 @@ void Tr2TranslationTool::Update() m_worldTransform = m_localTransform * translation; for( PrimitiveIterator it = m_primitives.begin(); it != m_primitives.end(); ++it ) { - (*it)->m_localTransform = m_localTransform; - (*it)->UpdateTransform(); + ( *it )->m_localTransform = m_localTransform; + ( *it )->UpdateTransform(); } - } - diff --git a/trinity/Tr2TranslationTool.h b/trinity/Tr2TranslationTool.h index b0a441598..b06ce3a67 100644 --- a/trinity/Tr2TranslationTool.h +++ b/trinity/Tr2TranslationTool.h @@ -5,17 +5,17 @@ #define Tr2TranslationTool_h #include "Tr2ManipulationTool.h" -BLUE_CLASS( Tr2TranslationTool ): - public Tr2ManipulationTool +BLUE_CLASS( Tr2TranslationTool ) : + public Tr2ManipulationTool { public: - EXPOSE_TO_BLUE(); - Tr2TranslationTool( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + Tr2TranslationTool( IRoot* lockobj = NULL ); void GenLineSets(); void Update(); void ResetPrimitiveColors(); - std::vector& GetPrimitivesToRender( ); + std::vector& GetPrimitivesToRender(); void Move( int mouseX, int mouseY, int mouseXDelta, int mouseYDelta, Tr2Viewport& viewport, Matrix& viewMatrix, Matrix& projectionMatrix ); Vector3 m_translation; diff --git a/trinity/Tr2TranslationTool_Blue.cpp b/trinity/Tr2TranslationTool_Blue.cpp index fba61bf30..0ccb02868 100644 --- a/trinity/Tr2TranslationTool_Blue.cpp +++ b/trinity/Tr2TranslationTool_Blue.cpp @@ -8,12 +8,9 @@ BLUE_DEFINE( Tr2TranslationTool ); const Be::ClassInfo* Tr2TranslationTool::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2TranslationTool, "" ) - MAP_INTERFACE( Tr2TranslationTool ) + EXPOSURE_BEGIN( Tr2TranslationTool, "" ) + MAP_INTERFACE( Tr2TranslationTool ) MAP_INTERFACE( Tr2ManipulationTool ) - MAP_ATTRIBUTE( "translation", m_translation, - "The output translation value", - Be::READ - ) - EXPOSURE_CHAINTO( Tr2ManipulationTool ) + MAP_ATTRIBUTE( "translation", m_translation, "The output translation value", Be::READ ) + EXPOSURE_CHAINTO( Tr2ManipulationTool ) } diff --git a/trinity/Tr2Variable.h b/trinity/Tr2Variable.h index 4b2582bbe..96664ec86 100644 --- a/trinity/Tr2Variable.h +++ b/trinity/Tr2Variable.h @@ -15,46 +15,49 @@ class Tr2Variable { private: //Tr2VariableStore *m_store; - TriVariable *m_variable; + TriVariable* m_variable; Tr2Variable( const Tr2Variable& ); Tr2Variable& operator=( const Tr2Variable& ); public: - Tr2Variable() - : /*m_store( nullptr ) - , */m_variable( nullptr ) - {} + Tr2Variable() : + /*m_store( nullptr ) + , */ + m_variable( nullptr ) + { + } - explicit Tr2Variable( TriVariable* variable ) - : m_variable( variable ) - {} + explicit Tr2Variable( TriVariable* variable ) : + m_variable( variable ) + { + } - template - Tr2Variable( const char *name, TYPE value ) + template + Tr2Variable( const char* name, TYPE value ) { Register( name, value, GlobalStore() ); } - template - Tr2Variable( const char *name, TYPE value, Tr2VariableStore &store ) + template + Tr2Variable( const char* name, TYPE value, Tr2VariableStore& store ) { Register( name, value, store ); } - template - void Register( const char *name, TYPE value ) + template + void Register( const char* name, TYPE value ) { Register( name, value, GlobalStore() ); } - template - void Register( const char *name, TYPE value, Tr2VariableStore &store ) + template + void Register( const char* name, TYPE value, Tr2VariableStore& store ) { m_variable = store.RegisterVariable( name, value ); } - - template + + template void GetValue( TYPE& value ) { if( m_variable ) @@ -63,7 +66,7 @@ class Tr2Variable } } - template + template void operator=( const TYPE& value ) { if( m_variable ) @@ -72,8 +75,11 @@ class Tr2Variable } } - TriVariable* GetVariable() const { return m_variable; } - + TriVariable* GetVariable() const + { + return m_variable; + } + TriVariableContentType GetType() const { return m_variable ? m_variable->GetType() : TRIVARIABLE_INVALID; diff --git a/trinity/Tr2VariableStore.cpp b/trinity/Tr2VariableStore.cpp index 6970898bf..7d9d741be 100644 --- a/trinity/Tr2VariableStore.cpp +++ b/trinity/Tr2VariableStore.cpp @@ -5,8 +5,8 @@ #include "Tr2TextureReference.h" -Tr2VariableStore::Tr2VariableStore( IRoot* lockobj ) - :m_variableMap( "Tr2VariableStore::m_variableMap" ) +Tr2VariableStore::Tr2VariableStore( IRoot* lockobj ) : + m_variableMap( "Tr2VariableStore::m_variableMap" ) { SetParentVariableStore( &GlobalStore() ); } @@ -18,8 +18,8 @@ Tr2VariableStore::Tr2VariableStore( IRoot* lockobj ) // See also: // Tr2GlobalVariableStore // ------------------------------------------------------------- -Tr2VariableStore::Tr2VariableStore( IRoot* lockobj, int ) - :m_variableMap( "Tr2VariableStore::m_variableMap" ) +Tr2VariableStore::Tr2VariableStore( IRoot* lockobj, int ) : + m_variableMap( "Tr2VariableStore::m_variableMap" ) { } @@ -29,7 +29,7 @@ Tr2VariableStore::~Tr2VariableStore() // ------------------------------------------------------------- // Description: -// Returns the parent variable store used during variable +// Returns the parent variable store used during variable // search. GlobalStore() is the default parent of new // variable store objects. // Return Value: @@ -42,11 +42,11 @@ Tr2VariableStore* Tr2VariableStore::GetParentVariableStore() const // ------------------------------------------------------------- // Description: -// Assigns a parent to the variable store. +// Assigns a parent to the variable store. // Arguments: // variableStore - New parent of the variable store // ------------------------------------------------------------- -void Tr2VariableStore::SetParentVariableStore(Tr2VariableStore* variableStore) +void Tr2VariableStore::SetParentVariableStore( Tr2VariableStore* variableStore ) { if( this == &GlobalStore() ) { @@ -55,7 +55,7 @@ void Tr2VariableStore::SetParentVariableStore(Tr2VariableStore* variableStore) #if TRINITYDEV // Check if we don't assign a child as a parent - Tr2VariableStore *store = variableStore; + Tr2VariableStore* store = variableStore; while( store ) { CCP_ASSERT( store != this ); @@ -194,7 +194,7 @@ TriVariable* Tr2VariableStore::RegisterVariable( const char* name, const Color& // ------------------------------------------------------------- // Description: -// Registers a placeholder for a variable. +// Registers a placeholder for a variable. // Arguments: // name - Name of the new variable // value - Value for the new variable @@ -272,12 +272,12 @@ bool Tr2VariableStore::UnregisterLocalVariable( const char* name ) return false; } auto it = m_variableMap.find( name ); - if( it != m_variableMap.end() ) - { + if( it != m_variableMap.end() ) + { it->second->Invalidate(); - m_variableMap.erase( it ); + m_variableMap.erase( it ); return true; - } + } return false; } @@ -320,7 +320,7 @@ TriVariable* Tr2VariableStore::FindLocalVariable( const char* name ) const { return nullptr; } - auto it = m_variableMap.find( name ); + auto it = m_variableMap.find( name ); return it != m_variableMap.end() ? it->second : nullptr; } @@ -357,7 +357,7 @@ TriVariable* Tr2VariableStore::GetVariable( const char* name ) // ------------------------------------------------------------- // Description: -// Searches for a variable the given name in this store. If the +// Searches for a variable the given name in this store. If the // variable is not found the function registers // it in this store (with type TRIVARIABLE_INVALID). // Arguments: @@ -371,12 +371,12 @@ TriVariable* Tr2VariableStore::GetLocalVariable( const char* name ) { return nullptr; } - auto it = m_variableMap.find( name ); - if( it != m_variableMap.end() ) - { + auto it = m_variableMap.find( name ); + if( it != m_variableMap.end() ) + { return it->second; } - + TriVariablePtr var; var.CreateInstance(); var->m_type = TRIVARIABLE_INVALID; @@ -408,7 +408,7 @@ TriVariable* Tr2VariableStore::RegisterVariableType( const char* name, TriVariab TriVariableContentType existingType = var->GetType(); if( existingType == TRIVARIABLE_INVALID ) { - // Variable was just reserved, switch it to this type, + // Variable was just reserved, switch it to this type, // it has enough allocated space var->m_type = type; } @@ -419,8 +419,7 @@ TriVariable* Tr2VariableStore::RegisterVariableType( const char* name, TriVariab else if( type != existingType ) { // Variable exists under a different type - CCP_LOGERR( "Attempting to register variable '%s' as '%s', already registered as '%s'", name, - TriVariable::GetTypeName( type ), TriVariable::GetTypeName( existingType ) ); + CCP_LOGERR( "Attempting to register variable '%s' as '%s', already registered as '%s'", name, TriVariable::GetTypeName( type ), TriVariable::GetTypeName( existingType ) ); CCP_ASSERT( false ); var = NULL; } @@ -448,13 +447,12 @@ std::vector Tr2VariableStore::GetLocalNames() const return result; } -class Tr2GlobalVariableStore: public Tr2VariableStore +class Tr2GlobalVariableStore : public Tr2VariableStore { public: - Tr2GlobalVariableStore( IRoot* lockobj = nullptr ) - :Tr2VariableStore( lockobj, 0 ) + Tr2GlobalVariableStore( IRoot* lockobj = nullptr ) : + Tr2VariableStore( lockobj, 0 ) { - } }; diff --git a/trinity/Tr2VariableStore.h b/trinity/Tr2VariableStore.h index 589da4217..c5d89943c 100644 --- a/trinity/Tr2VariableStore.h +++ b/trinity/Tr2VariableStore.h @@ -18,7 +18,8 @@ BLUE_DECLARE_INTERFACE( ITr2GpuBuffer ); // SeeAlso: // TriVariable // ------------------------------------------------------------- -BLUE_CLASS( Tr2VariableStore ) : public IRoot +BLUE_CLASS( Tr2VariableStore ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -27,30 +28,31 @@ BLUE_CLASS( Tr2VariableStore ) : public IRoot ~Tr2VariableStore(); Tr2VariableStore* GetParentVariableStore() const; - void SetParentVariableStore(Tr2VariableStore* variableStore); + void SetParentVariableStore( Tr2VariableStore * variableStore ); - TriVariable* RegisterVariable( const char* name, float value ); + TriVariable* RegisterVariable( const char* name, float value ); TriVariable* RegisterVariable( const char* name, int value ); TriVariable* RegisterVariable( const char* name, const Vector2& value ); TriVariable* RegisterVariable( const char* name, const Vector3& value ); - TriVariable* RegisterVariable( const char* name, const Vector4& value ); - TriVariable* RegisterVariable( const char* name, const Matrix& value ); - TriVariable* RegisterVariable( const char* name, const Color& value ); + TriVariable* RegisterVariable( const char* name, const Vector4& value ); + TriVariable* RegisterVariable( const char* name, const Matrix& value ); + TriVariable* RegisterVariable( const char* name, const Color& value ); TriVariable* RegisterVariable( const char* name ); TriVariable* RegisterVariable( const char* name, ITr2TextureProvider* value ); TriVariable* RegisterVariable( const char* name, ITr2GpuBuffer* value ); TriVariable* RegisterVariable( const char* name, const Tr2TextureAL& value ); - void UnregisterVariable( const char* name ); + void UnregisterVariable( const char* name ); bool UnregisterLocalVariable( const char* name ); - TriVariable* FindVariable( const char* name ) const; - TriVariable* FindLocalVariable( const char* name ) const; + TriVariable* FindVariable( const char* name ) const; + TriVariable* FindLocalVariable( const char* name ) const; TriVariable* GetVariable( const char* name ); TriVariable* GetLocalVariable( const char* name ); protected: - Tr2VariableStore( IRoot* lockobj, int ); + Tr2VariableStore( IRoot * lockobj, int ); + private: std::vector GetLocalNames() const; @@ -64,17 +66,17 @@ BLUE_CLASS( Tr2VariableStore ) : public IRoot // name - Name of the new variable // value - Value for the new variable // ------------------------------------------------------------- - template< typename U > - TriVariable* RegisterVariableInternal( const char* name, const U& value ) - { - TriVariableContentType type = GetVariableType( value ); + template + TriVariable* RegisterVariableInternal( const char* name, const U& value ) + { + TriVariableContentType type = GetVariableType( value ); TriVariable* var = RegisterVariableType( name, type ); if( var ) { var->SetValue( value ); } return var; - } + } // Pointer to the parent variable store // used to resolve variables diff --git a/trinity/Tr2VariableStore_Blue.cpp b/trinity/Tr2VariableStore_Blue.cpp index c6189ab05..0e85088ba 100644 --- a/trinity/Tr2VariableStore_Blue.cpp +++ b/trinity/Tr2VariableStore_Blue.cpp @@ -14,89 +14,79 @@ static PyObject* PyWrapVariable( TriVariable* variable ) { if( variable == NULL ) { - PyErr_SetString(PyExc_KeyError, "Variable store variable is not set."); + PyErr_SetString( PyExc_KeyError, "Variable store variable is not set." ); return NULL; } switch( variable->GetType() ) { case TRIVARIABLE_INVALID: - case TRIVARIABLE_UNKNOWN_FLOAT: - { - Py_RETURN_NONE; - } - case TRIVARIABLE_TEXTURE_RES: - { - ITr2TextureProvider* res = NULL; - variable->GetValue( res ); + case TRIVARIABLE_UNKNOWN_FLOAT: { + Py_RETURN_NONE; + } + case TRIVARIABLE_TEXTURE_RES: { + ITr2TextureProvider* res = NULL; + variable->GetValue( res ); - return PyOS->WrapBlueObject( res ); - } - case TRIVARIABLE_GPUBUFFER: - { - ITr2GpuBuffer* res = NULL; - variable->GetValue( res ); + return PyOS->WrapBlueObject( res ); + } + case TRIVARIABLE_GPUBUFFER: { + ITr2GpuBuffer* res = NULL; + variable->GetValue( res ); - return PyOS->WrapBlueObject( res ); - } - case TRIVARIABLE_INT: - { - int value; - variable->GetValue( value ); - return Py_BuildValue( "i", value ); - } - case TRIVARIABLE_FLOAT: - { - float value; - variable->GetValue( value ); - return Py_BuildValue( "f", value ); - } - case TRIVARIABLE_FLOAT2: - { - Vector2 value; - variable->GetValue( value ); - return Py_BuildValue( "ff", value.x, value.y ); - } - case TRIVARIABLE_FLOAT3: - { - Vector3 value; - variable->GetValue( value ); - return Py_BuildValue( "(fff)", value.x, value.y, value.z ); - } - case TRIVARIABLE_FLOAT4: - { - Vector4 value; - variable->GetValue( value ); - return Py_BuildValue( "(ffff)", value.x, value.y, value.z, value.w ); - } - case TRIVARIABLE_FLOAT4X4: - { - Matrix value; - variable->GetValue( value ); + return PyOS->WrapBlueObject( res ); + } + case TRIVARIABLE_INT: { + int value; + variable->GetValue( value ); + return Py_BuildValue( "i", value ); + } + case TRIVARIABLE_FLOAT: { + float value; + variable->GetValue( value ); + return Py_BuildValue( "f", value ); + } + case TRIVARIABLE_FLOAT2: { + Vector2 value; + variable->GetValue( value ); + return Py_BuildValue( "ff", value.x, value.y ); + } + case TRIVARIABLE_FLOAT3: { + Vector3 value; + variable->GetValue( value ); + return Py_BuildValue( "(fff)", value.x, value.y, value.z ); + } + case TRIVARIABLE_FLOAT4: { + Vector4 value; + variable->GetValue( value ); + return Py_BuildValue( "(ffff)", value.x, value.y, value.z, value.w ); + } + case TRIVARIABLE_FLOAT4X4: { + Matrix value; + variable->GetValue( value ); - PyObject* ret = PyTuple_New( 4 ); + PyObject* ret = PyTuple_New( 4 ); - // Start of floating point of array so we can iterate simply over the data - const float* array = &value._11; - for( int i = 0; i < 4; ++i ) + // Start of floating point of array so we can iterate simply over the data + const float* array = &value._11; + for( int i = 0; i < 4; ++i ) + { + PyObject* tuple = PyTuple_New( 4 ); + // Marshall row 'i' in the array as a 4-tuple + for( int k = 0; k < 4; ++k ) { - PyObject* tuple = PyTuple_New( 4 ); - // Marshall row 'i' in the array as a 4-tuple - for( int k = 0; k < 4; ++k ) - { - PyTuple_SET_ITEM( tuple, k, PyFloat_FromDouble( array[4*i + k ] ) ); - } - // Collect the tuple into a tuple of rows - PyTuple_SET_ITEM( ret, i, tuple ); + PyTuple_SET_ITEM( tuple, k, PyFloat_FromDouble( array[4 * i + k] ) ); } - - return ret; - } - case TRIVARIABLE_COLOR: - { - Color value; - variable->GetValue( value ); - return Py_BuildValue( "(ffff)", value.r, value.g, value.b, value.a ); + // Collect the tuple into a tuple of rows + PyTuple_SET_ITEM( ret, i, tuple ); } + + return ret; + } + case TRIVARIABLE_COLOR: { + Color value; + variable->GetValue( value ); + return Py_BuildValue( "(ffff)", value.r, value.g, value.b, value.a ); + } default: return NULL; } @@ -221,7 +211,7 @@ static PyObject* PyGetLocalVariable( PyObject* self, PyObject* args ) static PyObject* PyGetVariableStore( PyObject* self, PyObject* args ) { PyObject* ret = PyOS->WrapBlueObject( &GlobalStore() ); - return ret; + return ret; } MAP_FUNCTION( "GetVariableStore", PyGetVariableStore, "Gets the global variable store\n:type: Tr2VariableStore" ); @@ -229,69 +219,63 @@ MAP_FUNCTION( "GetVariableStore", PyGetVariableStore, "Gets the global variable const Be::ClassInfo* Tr2VariableStore::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2VariableStore, "Variable map used by shaders to get parameters" ) + EXPOSURE_BEGIN( Tr2VariableStore, "Variable map used by shaders to get parameters" ) MAP_INTERFACE( Tr2VariableStore ) MAP_PROPERTY( "parentStore", GetParentVariableStore, SetParentVariableStore, "Parent variable store" ) - MAP_METHOD( - "RegisterVariable", - PyRegisterVariable, - "Registers a new variable in this store." + MAP_METHOD( + "RegisterVariable", + PyRegisterVariable, + "Registers a new variable in this store." "\n" "\n:param name: Name of the variable" "\n:type name: str" "\nvalue - Value for the new variable" ) - MAP_METHOD( - "FindVariable", - PyFindVariable, - "Returns a variable in the local store or its parents. Throws an exception if the variable is not found." + MAP_METHOD( + "FindVariable", + PyFindVariable, + "Returns a variable in the local store or its parents. Throws an exception if the variable is not found." "\n" - "\n:param name: Name of the variable" - "\n:type name: str" - ) - MAP_METHOD( - "FindLocalVariable", - PyFindLocalVariable, - "Returns a variable in the local store. Throws an exception if the variable is not found." + "\n:param name: Name of the variable" + "\n:type name: str" ) + MAP_METHOD( + "FindLocalVariable", + PyFindLocalVariable, + "Returns a variable in the local store. Throws an exception if the variable is not found." "\n" - "\n:param name: Name of the variable" - "\n:type name: str" - ) - MAP_METHOD( - "GetVariable", - PyGetVariable, + "\n:param name: Name of the variable" + "\n:type name: str" ) + MAP_METHOD( + "GetVariable", + PyGetVariable, "Returns a variable in the local store or its parents. If the variable is not found the function creates" - " a new variable in this store." + " a new variable in this store." "\n" - "\n:param name: Name of the variable" - "\n:type name: str" - ) - MAP_METHOD( - "GetLocalVariable", - PyGetLocalVariable, + "\n:param name: Name of the variable" + "\n:type name: str" ) + MAP_METHOD( + "GetLocalVariable", + PyGetLocalVariable, "Returns a variable in the local store. If the variable is not found the function creates" - " a new variable in this store." + " a new variable in this store." "\n" - "\n:param name: Name of the variable" - "\n:type name: str" - ) - MAP_METHOD_AND_WRAP( - "UnregisterVariable", - UnregisterVariable, - "Unregisters an existing variable. Looks for the variable in this store and its parents." + "\n:param name: Name of the variable" + "\n:type name: str" ) + MAP_METHOD_AND_WRAP( + "UnregisterVariable", + UnregisterVariable, + "Unregisters an existing variable. Looks for the variable in this store and its parents." "\n" - "\n:param name: Name of the variable" - ) - MAP_METHOD_AND_WRAP( - "UnregisterLocalVariable", - UnregisterLocalVariable, - "Unregisters an existing variable. Looks for the variable only in this store." + "\n:param name: Name of the variable" ) + MAP_METHOD_AND_WRAP( + "UnregisterLocalVariable", + UnregisterLocalVariable, + "Unregisters an existing variable. Looks for the variable only in this store." "\n" - "\n:param name: Name of the variable" - ) - MAP_METHOD_AND_WRAP( - "GetLocalNames", - GetLocalNames, + "\n:param name: Name of the variable" ) + MAP_METHOD_AND_WRAP( + "GetLocalNames", + GetLocalNames, "Returns a list of names of all local variables in the store." ) EXPOSURE_END() } diff --git a/trinity/Tr2VectorFunctionModifier.cpp b/trinity/Tr2VectorFunctionModifier.cpp index 6d5eb155d..70a1764e1 100644 --- a/trinity/Tr2VectorFunctionModifier.cpp +++ b/trinity/Tr2VectorFunctionModifier.cpp @@ -6,22 +6,21 @@ namespace { - float CheckedDoubleToFloat( double value ) - { - const double maxFloat = static_cast( std::numeric_limits::max() ); - CCP_ASSERT_M( std::isfinite( value ) && value < maxFloat && value > -maxFloat, "System coordinate overflow converting double to float" ); +float CheckedDoubleToFloat( double value ) +{ + const double maxFloat = static_cast( std::numeric_limits::max() ); + CCP_ASSERT_M( std::isfinite( value ) && value < maxFloat && value > -maxFloat, "System coordinate overflow converting double to float" ); - return static_cast( value ); - } + return static_cast( value ); +} - Vector3 ToVector3( Vector3d in ) - { - return Vector3( - CheckedDoubleToFloat( in.x ), - CheckedDoubleToFloat( in.y ), - CheckedDoubleToFloat( in.z ) - ); - } +Vector3 ToVector3( Vector3d in ) +{ + return Vector3( + CheckedDoubleToFloat( in.x ), + CheckedDoubleToFloat( in.y ), + CheckedDoubleToFloat( in.z ) ); +} } diff --git a/trinity/Tr2VectorFunctionModifier.h b/trinity/Tr2VectorFunctionModifier.h index a37eaacca..2b9bfc888 100644 --- a/trinity/Tr2VectorFunctionModifier.h +++ b/trinity/Tr2VectorFunctionModifier.h @@ -56,7 +56,7 @@ class Tr2VectorFunctionModifier : public ITriVectorFunction // if true, the m_offsetPosition is transformed to view space bool m_useViewSpace; - + // if true, uses system coordinates instead of ship coordinates bool m_useSystemCoordinates; }; diff --git a/trinity/Tr2VectorFunctionModifier_Blue.cpp b/trinity/Tr2VectorFunctionModifier_Blue.cpp index 368f7f4c2..06141f4c4 100644 --- a/trinity/Tr2VectorFunctionModifier_Blue.cpp +++ b/trinity/Tr2VectorFunctionModifier_Blue.cpp @@ -6,7 +6,7 @@ BLUE_DEFINE( Tr2VectorFunctionModifier ); const Be::ClassInfo* Tr2VectorFunctionModifier::ExposeToBlue() { - EXPOSURE_BEGIN( Tr2VectorFunctionModifier, "Wrapper object for ITriVectorFunction implementer that adds world or view space offset and scaling") + EXPOSURE_BEGIN( Tr2VectorFunctionModifier, "Wrapper object for ITriVectorFunction implementer that adds world or view space offset and scaling" ) MAP_INTERFACE( ITriVectorFunction ) MAP_INTERFACE( Tr2VectorFunctionModifier ) @@ -33,9 +33,9 @@ const Be::ClassInfo* Tr2VectorFunctionModifier::ExposeToBlue() m_useViewSpace, "Calcuates offset in view space", Be::READWRITE ) - - MAP_ATTRIBUTE( - "useSystemCoordinates", + + MAP_ATTRIBUTE( + "useSystemCoordinates", m_useSystemCoordinates, "Whether to use the system coordinates for the given position or the default of ship coordinates", Be::READWRITE ) diff --git a/trinity/Tr2VertexDefinitionUtilities.cpp b/trinity/Tr2VertexDefinitionUtilities.cpp index fcdc286e9..e1d1ca8d8 100644 --- a/trinity/Tr2VertexDefinitionUtilities.cpp +++ b/trinity/Tr2VertexDefinitionUtilities.cpp @@ -6,7 +6,7 @@ #if WITH_GRANNY // -------------------------------------------------------------------------------------- // Description: -// Converts Granny data type definition to Trinity vertex type. +// Converts Granny data type definition to Trinity vertex type. // Arguments: // src - Granny data type definition // Return Value: @@ -16,7 +16,7 @@ Tr2VertexDefinition::DataType ConvertGrannyTypeToDataType( const granny_data_typ { unsigned type = 0; - switch (src.Type) + switch( src.Type ) { case GrannyInt8Member: type = Tr2VertexDefinition::DT_INT8; @@ -55,12 +55,12 @@ Tr2VertexDefinition::DataType ConvertGrannyTypeToDataType( const granny_data_typ unsigned size = std::max( 1, src.ArrayWidth ) - 1; type |= size << Tr2VertexDefinition::DT_SIZE_OFFSET; - return static_cast(type); + return static_cast( type ); } // -------------------------------------------------------------------------------------- // Description: -// Converts Granny vertex definition to Trinity vertex definition. +// Converts Granny vertex definition to Trinity vertex definition. // Arguments: // grannyVertexDecl - Granny vertex definition // Return Value: @@ -78,29 +78,29 @@ Tr2VertexDefinition BuildFromGrannyVertexDecl( const granny_data_type_definition item.m_stream = 0; item.m_offset = vd.m_nextOffset[0]; - item.m_dataType = ConvertGrannyTypeToDataType(src); + item.m_dataType = ConvertGrannyTypeToDataType( src ); item.m_usageIndex = 0; - vd.m_nextOffset[0] += vd.GetDataTypeSizeInBytes(item.m_dataType); + vd.m_nextOffset[0] += vd.GetDataTypeSizeInBytes( item.m_dataType ); if( !strncmp( src.Name, GrannyVertexPositionName, strlen( GrannyVertexPositionName ) ) ) { item.m_usage = vd.POSITION; - char C = src.Name[ strlen( GrannyVertexPositionName ) ]; + char C = src.Name[strlen( GrannyVertexPositionName )]; item.m_usageIndex = C ? unsigned( C - '0' ) : 0; } else if( !strncmp( src.Name, GrannyVertexDiffuseColorName, strlen( GrannyVertexDiffuseColorName ) ) ) { item.m_usage = vd.COLOR; - char C = src.Name[ strlen( GrannyVertexDiffuseColorName ) ]; + char C = src.Name[strlen( GrannyVertexDiffuseColorName )]; item.m_usageIndex = C ? unsigned( C - '0' ) : 0; } else if( !strncmp( src.Name, GrannyVertexNormalName, strlen( GrannyVertexNormalName ) ) ) { item.m_usage = vd.NORMAL; - char C = src.Name[ strlen( GrannyVertexNormalName ) ]; + char C = src.Name[strlen( GrannyVertexNormalName )]; item.m_usageIndex = C ? unsigned( C - '0' ) : 0; - } + } else if( !strncmp( src.Name, GrannyVertexTangentName, strlen( GrannyVertexTangentName ) ) ) { item.m_usage = vd.TANGENT; @@ -116,9 +116,9 @@ Tr2VertexDefinition BuildFromGrannyVertexDecl( const granny_data_type_definition else if( !strncmp( src.Name, GrannyVertexTextureCoordinatesName, strlen( GrannyVertexTextureCoordinatesName ) ) ) { item.m_usage = vd.TEXCOORD; - char C = src.Name[ strlen( GrannyVertexTextureCoordinatesName ) ]; + char C = src.Name[strlen( GrannyVertexTextureCoordinatesName )]; item.m_usageIndex = C ? unsigned( C - '0' ) : 0; - } + } else if( !strcmp( src.Name, GrannyVertexBoneIndicesName ) ) { item.m_usage = vd.BLENDINDICES; @@ -136,7 +136,7 @@ Tr2VertexDefinition BuildFromGrannyVertexDecl( const granny_data_type_definition // -------------------------------------------------------------------------------------- // Description: -// Convert Trinity vertex definition back to a granny layout. +// Convert Trinity vertex definition back to a granny layout. // Arguments: // vd - input definition // grannyVertexDecl - pointer to at least maxSize elements @@ -149,7 +149,7 @@ bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definit { // Note: This function assumes the D3D vertex layout is described in increasing offset order // ... so make sure. - std::sort( begin( vd.m_items ), end( vd.m_items ) ); + std::sort( begin( vd.m_items ), end( vd.m_items ) ); // shorten the namespace... typedef Tr2VertexDefinition tvd; @@ -157,44 +157,41 @@ bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definit for( size_t i = 0; i != std::min( maxSize, (unsigned int)vd.m_items.size() ); ++i ) { const auto& src = vd.m_items[i]; - + granny_data_type_definition& dst = grannyVertexDecl[i]; - dst.ArrayWidth = ( ( src.m_dataType & tvd::DT_SIZE_MASK ) >> tvd::DT_SIZE_OFFSET ) + 1; - const bool isUnsigned = ( src.m_dataType & tvd::DT_UNSIGNED_BIT ) != 0; - const bool isNormalized = ( src.m_dataType & tvd::DT_NORMALIZED_BIT ) != 0; + dst.ArrayWidth = ( ( src.m_dataType & tvd::DT_SIZE_MASK ) >> tvd::DT_SIZE_OFFSET ) + 1; + const bool isUnsigned = ( src.m_dataType & tvd::DT_UNSIGNED_BIT ) != 0; + const bool isNormalized = ( src.m_dataType & tvd::DT_NORMALIZED_BIT ) != 0; switch( src.m_dataType & tvd::DT_TYPE_MASK ) { - case tvd::DT_INT8: - dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt8Member : GrannyUInt8Member - : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt8Member; - break; - - case tvd::DT_INT16: - dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt16Member : GrannyUInt16Member - : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt16Member; - break; - - case tvd::DT_INT32: - dst.Type = isUnsigned ? GrannyUInt32Member : GrannyInt16Member; - break; - - case tvd::DT_FLOAT16: - dst.Type = GrannyReal16Member; - break; - - case tvd::DT_FLOAT32: - dst.Type = GrannyReal32Member; - break; - - default: - CCP_ASSERT( false && "Missing datatype support in granny conversion" ); - return false; + case tvd::DT_INT8: + dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt8Member : GrannyUInt8Member : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt8Member; + break; + + case tvd::DT_INT16: + dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt16Member : GrannyUInt16Member : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt16Member; + break; + + case tvd::DT_INT32: + dst.Type = isUnsigned ? GrannyUInt32Member : GrannyInt16Member; + break; + + case tvd::DT_FLOAT16: + dst.Type = GrannyReal16Member; + break; + + case tvd::DT_FLOAT32: + dst.Type = GrannyReal32Member; + break; + + default: + CCP_ASSERT( false && "Missing datatype support in granny conversion" ); + return false; } - static const char * grannyTexcoordNames[8]= - { + static const char* grannyTexcoordNames[8] = { GrannyVertexTextureCoordinatesName "0", GrannyVertexTextureCoordinatesName "1", GrannyVertexTextureCoordinatesName "2", @@ -205,16 +202,14 @@ bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definit GrannyVertexTextureCoordinatesName "7", }; - static const char * grannyPositionNames[4]= - { + static const char* grannyPositionNames[4] = { GrannyVertexPositionName, GrannyVertexPositionName "1", GrannyVertexPositionName "2", GrannyVertexPositionName "3", }; - static const char * grannyNormalNames[4]= - { + static const char* grannyNormalNames[4] = { GrannyVertexNormalName, GrannyVertexNormalName "1", GrannyVertexNormalName "2", @@ -225,11 +220,11 @@ bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definit { case tvd::POSITION: CCP_ASSERT( src.m_usageIndex < 4 ); - dst.Name = grannyPositionNames[ src.m_usageIndex ]; + dst.Name = grannyPositionNames[src.m_usageIndex]; break; case tvd::NORMAL: CCP_ASSERT( src.m_usageIndex < 4 ); - dst.Name = grannyNormalNames[ src.m_usageIndex ]; + dst.Name = grannyNormalNames[src.m_usageIndex]; break; case tvd::TANGENT: dst.Name = GrannyVertexTangentName; @@ -239,7 +234,7 @@ bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definit break; case tvd::TEXCOORD: CCP_ASSERT( src.m_usageIndex < 8 ); - dst.Name = grannyTexcoordNames[ src.m_usageIndex ]; //GrannyVertexTextureCoordinatesName; + dst.Name = grannyTexcoordNames[src.m_usageIndex]; //GrannyVertexTextureCoordinatesName; break; case tvd::BLENDINDICES: dst.Name = GrannyVertexBoneIndicesName; @@ -339,7 +334,7 @@ Tr2VertexDefinition BuildFromCMFVertexDecl( const cmf::Span& vd.m_nextOffset[0] += vd.GetDataTypeSizeInBytes( item.m_dataType ); - switch ( src.usage ) + switch( src.usage ) { case cmf::Usage::Position: item.m_usage = Tr2VertexDefinition::POSITION; @@ -409,14 +404,14 @@ bool ConvertVertexDeclToCMF( Tr2VertexDefinition vd, cmf::Span g_D3DCreatedHeaps; using namespace Tr2RenderContextEnum; -Tr2VideoAdapters::Tr2VideoAdapters() - :DEFAULT_ADAPTER( Tr2VideoAdapterInfo::DEFAULT_ADAPTER ) +Tr2VideoAdapters::Tr2VideoAdapters() : + DEFAULT_ADAPTER( Tr2VideoAdapterInfo::DEFAULT_ADAPTER ) { } @@ -77,7 +77,7 @@ ALResult Tr2VideoAdapters::GetCurrentDisplayMode( unsigned adapterIndex, // -------------------------------------------------------------------------------------- // Description: -// Get number of available display modes supported by display adapter for the given +// Get number of available display modes supported by display adapter for the given // back buffer format. // Arguments: // adapterIndex - index of display adapter (from 0 to GetAdapterCount) @@ -111,8 +111,7 @@ ALResult Tr2VideoAdapters::GetDisplayMode( unsigned adapterIndex, { *mode = nullptr; Tr2DisplayModeInfo info; - CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterMode( adapterIndex, PixelFormat( backBufferFormat ), modeIndex, info ) ) - ; + CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterMode( adapterIndex, PixelFormat( backBufferFormat ), modeIndex, info ) ); Tr2DisplayModePtr result; result.CreateInstance(); result->m_mode = info; @@ -191,30 +190,30 @@ std::string Tr2VideoAdapter::GetDeviceIdentifierString() const { #ifdef _WIN32 LPOLESTR guidstr; - if ( SUCCEEDED( StringFromCLSID( *reinterpret_cast( &m_info.deviceIdentifier ), &guidstr ) ) ) + if( SUCCEEDED( StringFromCLSID( *reinterpret_cast( &m_info.deviceIdentifier ), &guidstr ) ) ) { CW2A str( guidstr ); CoTaskMemFree( guidstr ); - return ( const char* )str; + return (const char*)str; } #else - char buffer[128]; - snprintf( - buffer, - 128, - "%08x-%04x-%04x-%02xhh%02xhh-%02xhh%02xhh%02xhh%02xhh%02xhh%02xhh", - unsigned( m_info.deviceIdentifier.data1 ), - unsigned( m_info.deviceIdentifier.data2 ), - unsigned( m_info.deviceIdentifier.data3 ), - m_info.deviceIdentifier.data4[0], - m_info.deviceIdentifier.data4[1], - m_info.deviceIdentifier.data4[2], - m_info.deviceIdentifier.data4[3], - m_info.deviceIdentifier.data4[4], - m_info.deviceIdentifier.data4[5], - m_info.deviceIdentifier.data4[6], - m_info.deviceIdentifier.data4[7] ); - return buffer; + char buffer[128]; + snprintf( + buffer, + 128, + "%08x-%04x-%04x-%02xhh%02xhh-%02xhh%02xhh%02xhh%02xhh%02xhh%02xhh", + unsigned( m_info.deviceIdentifier.data1 ), + unsigned( m_info.deviceIdentifier.data2 ), + unsigned( m_info.deviceIdentifier.data3 ), + m_info.deviceIdentifier.data4[0], + m_info.deviceIdentifier.data4[1], + m_info.deviceIdentifier.data4[2], + m_info.deviceIdentifier.data4[3], + m_info.deviceIdentifier.data4[4], + m_info.deviceIdentifier.data4[5], + m_info.deviceIdentifier.data4[6], + m_info.deviceIdentifier.data4[7] ); + return buffer; #endif return ""; } @@ -230,7 +229,7 @@ std::string Tr2VideoAdapter::GetDeviceIdentifierString() const ALResult Tr2VideoAdapter::GetDriverInfo( Tr2VideoDriver** info ) { *info = nullptr; - + Tr2VideoDriverInfo driverInfo; FORWARD_HR( Tr2DriverUtilities::GetDriverVersion( m_info.deviceID, driverInfo ) ); @@ -240,4 +239,3 @@ ALResult Tr2VideoAdapter::GetDriverInfo( Tr2VideoDriver** info ) *info = result.Detach(); return S_OK; } - diff --git a/trinity/Tr2VideoAdapters.h b/trinity/Tr2VideoAdapters.h index ea5c2b855..977fc1d52 100644 --- a/trinity/Tr2VideoAdapters.h +++ b/trinity/Tr2VideoAdapters.h @@ -5,9 +5,9 @@ #define Tr2VideoAdapters_H -BLUE_DECLARE ( Tr2VideoAdapter ); -BLUE_DECLARE ( Tr2DisplayMode ); -BLUE_DECLARE ( Tr2VideoDriver ); +BLUE_DECLARE( Tr2VideoAdapter ); +BLUE_DECLARE( Tr2DisplayMode ); +BLUE_DECLARE( Tr2VideoDriver ); // -------------------------------------------------------------------------------------- // Description: @@ -15,7 +15,8 @@ BLUE_DECLARE ( Tr2VideoDriver ); // See Also: // Tr2VideoAdapterInfo // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2VideoAdapters ): public IRoot +BLUE_CLASS( Tr2VideoAdapters ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -46,7 +47,7 @@ BLUE_CLASS( Tr2VideoAdapters ): public IRoot const unsigned DEFAULT_ADAPTER; }; -TYPEDEF_BLUECLASS ( Tr2VideoAdapters ); +TYPEDEF_BLUECLASS( Tr2VideoAdapters ); // -------------------------------------------------------------------------------------- @@ -56,7 +57,8 @@ TYPEDEF_BLUECLASS ( Tr2VideoAdapters ); // See Also: // Tr2AdapterInfo // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2VideoAdapter ): public IRoot +BLUE_CLASS( Tr2VideoAdapter ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -67,10 +69,10 @@ BLUE_CLASS( Tr2VideoAdapter ): public IRoot std::string GetDeviceIdentifierString() const; - ALResult GetDriverInfo( Tr2VideoDriver** info ); + ALResult GetDriverInfo( Tr2VideoDriver * *info ); }; -TYPEDEF_BLUECLASS ( Tr2VideoAdapter ); +TYPEDEF_BLUECLASS( Tr2VideoAdapter ); // -------------------------------------------------------------------------------------- @@ -80,7 +82,8 @@ TYPEDEF_BLUECLASS ( Tr2VideoAdapter ); // See Also: // Tr2DisplayModeInfo // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2DisplayMode ): public IRoot +BLUE_CLASS( Tr2DisplayMode ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -88,7 +91,7 @@ BLUE_CLASS( Tr2DisplayMode ): public IRoot Tr2DisplayModeInfo m_mode; }; -TYPEDEF_BLUECLASS ( Tr2DisplayMode ); +TYPEDEF_BLUECLASS( Tr2DisplayMode ); // -------------------------------------------------------------------------------------- @@ -98,7 +101,8 @@ TYPEDEF_BLUECLASS ( Tr2DisplayMode ); // See Also: // Tr2VideoDriverInfo // -------------------------------------------------------------------------------------- -BLUE_CLASS( Tr2VideoDriver ): public IRoot +BLUE_CLASS( Tr2VideoDriver ) : + public IRoot { public: EXPOSE_TO_BLUE(); @@ -106,6 +110,6 @@ BLUE_CLASS( Tr2VideoDriver ): public IRoot Tr2VideoDriverInfo m_info; }; -TYPEDEF_BLUECLASS ( Tr2VideoDriver ); +TYPEDEF_BLUECLASS( Tr2VideoDriver ); #endif // Tr2VideoAdapters_H diff --git a/trinity/Tr2VideoAdapters_Blue.cpp b/trinity/Tr2VideoAdapters_Blue.cpp index c05f8e6cb..2695574bc 100644 --- a/trinity/Tr2VideoAdapters_Blue.cpp +++ b/trinity/Tr2VideoAdapters_Blue.cpp @@ -14,7 +14,7 @@ const Be::ClassInfo* Tr2VideoAdapter::ExposeToBlue() { EXPOSURE_BEGIN( Tr2VideoAdapter, "" ) MAP_INTERFACE( Tr2VideoAdapter ) - + MAP_ATTRIBUTE( "index", m_index, "Video adapter index", Be::READ ) MAP_ATTRIBUTE( "driver", m_info.driver, "Video driver names", Be::READ ) MAP_ATTRIBUTE( "description", m_info.description, "Human-readable adapter name", Be::READ ) @@ -33,7 +33,7 @@ const Be::ClassInfo* Tr2DisplayMode::ExposeToBlue() { EXPOSURE_BEGIN( Tr2DisplayMode, "" ) MAP_INTERFACE( Tr2DisplayMode ) - + MAP_ATTRIBUTE( "width", m_mode.width, "Back buffer width", Be::READ ) MAP_ATTRIBUTE( "height", m_mode.height, "Back buffer height", Be::READ ) MAP_ATTRIBUTE( "refreshRateNumerator", m_mode.refreshRateNumerator, "Refresh rate numenator", Be::READ ) @@ -48,7 +48,7 @@ const Be::ClassInfo* Tr2VideoDriver::ExposeToBlue() { EXPOSURE_BEGIN( Tr2VideoDriver, "" ) MAP_INTERFACE( Tr2VideoDriver ) - + MAP_ATTRIBUTE( "driverVersion", m_info.driverVersion, "Driver version as a 64 bit number", Be::READ ) MAP_ATTRIBUTE( "driverVersionString", m_info.driverVersionString, "Driver version as a string", Be::READ ) MAP_ATTRIBUTE( "driverVendor", m_info.driverVendor, "Driver vendor company", Be::READ ) @@ -64,64 +64,64 @@ const Be::ClassInfo* Tr2VideoAdapters::ExposeToBlue() MAP_INTERFACE( Tr2VideoAdapters ) MAP_ATTRIBUTE( "DEFAULT_ADAPTER", DEFAULT_ADAPTER, "Index of default video adapter", Be::READ ) - - MAP_METHOD_AND_WRAP( - "GetAdapterCount", - GetAdapterCount, + + MAP_METHOD_AND_WRAP( + "GetAdapterCount", + GetAdapterCount, "Returns number of video adapters in the system" ) - MAP_METHOD_AND_WRAP( - "GetAdapterInfo", - GetAdapterInfo, + MAP_METHOD_AND_WRAP( + "GetAdapterInfo", + GetAdapterInfo, "Returns video adapter information (as a Tr2VideoAdapter)." "\n" "\n:param idx: Video adapter index" ) - MAP_METHOD_AND_WRAP( - "GetCurrentDisplayMode", - GetCurrentDisplayMode, + MAP_METHOD_AND_WRAP( + "GetCurrentDisplayMode", + GetCurrentDisplayMode, "Returns current display mode information (as a Tr2DisplayMode) for video adapter." "\n" "\n:param idx: Video adapter index" ) - MAP_METHOD_AND_WRAP( - "GetDisplayModeCount", - GetDisplayModeCount, + MAP_METHOD_AND_WRAP( + "GetDisplayModeCount", + GetDisplayModeCount, "Returns number of supported display modes for video adapter and given back buffer format." "\n" "\n:param idx: Video adapter index" "\n:param format: Back buffer format (member of trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP( - "GetDisplayMode", - GetDisplayMode, + MAP_METHOD_AND_WRAP( + "GetDisplayMode", + GetDisplayMode, "Returns display mode information for video adapter and given back buffer format." "\n" "\n:param idx: Video adapter index" "\n:param format: Back buffer format (member of trinity.PIXEL_FORMAT)" "\n:param modeIndex: Display mode index" ) - MAP_METHOD_AND_WRAP( - "SupportsBackBufferFormat", - SupportsBackBufferFormat, + MAP_METHOD_AND_WRAP( + "SupportsBackBufferFormat", + SupportsBackBufferFormat, "Returns if the video adapter supports given back buffer format when running" "\nin fullscreen or windowed mode." "\n" "\n:param idx: Video adapter index" "\n:param backBufferFormat: Back buffer format (member of trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP( - "SupportsRenderTargetFormat", - SupportsRenderTargetFormat, + MAP_METHOD_AND_WRAP( + "SupportsRenderTargetFormat", + SupportsRenderTargetFormat, "Returns if the video adapter supports given render target format when running" "\nwith the given back buffer format." "\n" "\n:param idx: Video adapter index" "\n:param format: Render target format (member of trinity.PIXEL_FORMAT)" ) - MAP_METHOD_AND_WRAP( - "GetMaxTextureSize", - GetMaxTextureSize, + MAP_METHOD_AND_WRAP( + "GetMaxTextureSize", + GetMaxTextureSize, "Returns maximum texture size (width or height) supported by video adapter." "\n" "\n:param idx: Video adapter index" ) - MAP_METHOD_AND_WRAP( - "Refresh", - RefreshData, + MAP_METHOD_AND_WRAP( + "Refresh", + RefreshData, "Refreshes adapter information." ) EXPOSURE_END() } diff --git a/trinity/Tr2VirtualAllocator.cpp b/trinity/Tr2VirtualAllocator.cpp index 3e5f39935..73ba35793 100644 --- a/trinity/Tr2VirtualAllocator.cpp +++ b/trinity/Tr2VirtualAllocator.cpp @@ -7,7 +7,7 @@ #define VMA_STATIC_VULKAN_FUNCTIONS 0 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 0 #define VMA_VULKAN_VERSION 1000000 -#define VMA_STATS_STRING_ENABLED 0 +#define VMA_STATS_STRING_ENABLED 0 #define VMA_IMPLEMENTATION #include "vk_mem_alloc.h" @@ -50,7 +50,7 @@ Tr2VirtualAllocator::Tr2VirtualAllocator( size_t blockSize, size_t maxSize, size std::reverse( m_reservedBlocks.begin(), m_reservedBlocks.end() ); //Free reserved blocks until we reach the required initial size. - while (m_currentSize < initialSize) + while( m_currentSize < initialSize ) { Expand(); } @@ -72,7 +72,7 @@ bool Tr2VirtualAllocator::Expand() //Free the lowest offset reserved block to grow the allocatable range m_currentSize += m_blockSize; - Free(m_reservedBlocks.back()); + Free( m_reservedBlocks.back() ); m_reservedBlocks.pop_back(); return true; @@ -117,7 +117,6 @@ void Tr2VirtualAllocator::Free( VirtualAllocation allocation ) m_allocatedMemory -= allocation.size; CCP_LOG( "Freed %zu bytes at offset %zu from %p. Memory usage: %f / %zu MBs", allocation.size, allocation.offset, block, (float)GetAllocatedMemory() / float( 1024 * 1024 ), m_currentSize / size_t( 1024 * 1024 ) ); - } size_t Tr2VirtualAllocator::GetBlockSize() const diff --git a/trinity/Tr2VirtualAllocator.h b/trinity/Tr2VirtualAllocator.h index c78fc423a..2c4025bd1 100644 --- a/trinity/Tr2VirtualAllocator.h +++ b/trinity/Tr2VirtualAllocator.h @@ -13,7 +13,6 @@ class Tr2VirtualAllocator { public: - struct VirtualAllocation { void* allocation; @@ -32,7 +31,7 @@ class Tr2VirtualAllocator bool Allocate( size_t size, size_t alignment, VirtualAllocation& result ); void Free( VirtualAllocation allocation ); - + size_t GetBlockSize() const; size_t GetMaxSize() const; size_t GetCurrentSize() const; diff --git a/trinity/Tr2VisibilityResults.h b/trinity/Tr2VisibilityResults.h index 74a618de9..7416ff22f 100644 --- a/trinity/Tr2VisibilityResults.h +++ b/trinity/Tr2VisibilityResults.h @@ -9,7 +9,8 @@ struct Tr2VisibilityEvent; -BLUE_CLASS( Tr2VisibilityResults ) : public IRoot +BLUE_CLASS( Tr2VisibilityResults ) : + public IRoot { public: Tr2VisibilityResults( IRoot* lockobj = 0 ); @@ -20,11 +21,17 @@ BLUE_CLASS( Tr2VisibilityResults ) : public IRoot // Adds a visibility event to the set void AddVisibilityEvent( const Tr2VisibilityEvent& event ); // Gets the number of visibility events in the set - size_t GetNumVisibilityEvents( void ) const { return m_events.size(); } + size_t GetNumVisibilityEvents( void ) const + { + return m_events.size(); + } // Clears the result set void Clear( void ); // Get the list of events - const std::vector& GetEvents( void ) const { return m_events; } + const std::vector& GetEvents( void ) const + { + return m_events; + } private: typedef std::vector EventVector; @@ -36,36 +43,36 @@ struct Tr2VisibilityEvent { enum EventType { - QUERY_BEGIN = 1 << 0, - QUERY_END = 1 << 1, - PORTAL_ENTER = 1 << 2, - PORTAL_EXIT = 1 << 3, - PORTAL_PRE_EXIT = 1 << 4, - CELL_IMMEDIATE_REPORT = 1 << 5, - VIEW_PARAMETERS_CHANGED = 1 << 6, - INSTANCE_VISIBLE = 1 << 7, - REMOVAL_SUGGESTED = 1 << 8, - INSTANCE_IMMEDIATE_REPORT = 1 << 9, - REGION_OF_INFLUENCE_ACTIVE = 1 << 10, - REGION_OF_INFLUENCE_INACTIVE = 1 << 11, - STENCIL_MASK = 1 << 12, - TEXT_MESSAGE = 1 << 13, - DRAW_LINE_2D = 1 << 14, - DRAW_LINE_3D = 1 << 15, - DRAW_BUFFER = 1 << 16, - OCCLUSION_QUERY_BEGIN = 1 << 17, - OCCLUSION_QUERY_END = 1 << 18, - OCCLUSION_QUERY_GET_RESULT = 1 << 19, - OCCLUSION_QUERY_DRAW_DEPTH_TEST = 1 << 20, - INSTANCE_DRAW_DEPTH = 1 << 21, - FLUSH_DEPTH = 1 << 22, - DEPTH_PASS_BEGIN = 1 << 23, - DEPTH_PASS_END = 1 << 24, - COLOR_PASS_BEGIN = 1 << 25, - COLOR_PASS_END = 1 << 26, - TILE_BEGIN = 1 << 27, - TILE_END = 1 << 28, - FLUSH_GPU_COMMAND_BUFFER = 1 << 29 + QUERY_BEGIN = 1 << 0, + QUERY_END = 1 << 1, + PORTAL_ENTER = 1 << 2, + PORTAL_EXIT = 1 << 3, + PORTAL_PRE_EXIT = 1 << 4, + CELL_IMMEDIATE_REPORT = 1 << 5, + VIEW_PARAMETERS_CHANGED = 1 << 6, + INSTANCE_VISIBLE = 1 << 7, + REMOVAL_SUGGESTED = 1 << 8, + INSTANCE_IMMEDIATE_REPORT = 1 << 9, + REGION_OF_INFLUENCE_ACTIVE = 1 << 10, + REGION_OF_INFLUENCE_INACTIVE = 1 << 11, + STENCIL_MASK = 1 << 12, + TEXT_MESSAGE = 1 << 13, + DRAW_LINE_2D = 1 << 14, + DRAW_LINE_3D = 1 << 15, + DRAW_BUFFER = 1 << 16, + OCCLUSION_QUERY_BEGIN = 1 << 17, + OCCLUSION_QUERY_END = 1 << 18, + OCCLUSION_QUERY_GET_RESULT = 1 << 19, + OCCLUSION_QUERY_DRAW_DEPTH_TEST = 1 << 20, + INSTANCE_DRAW_DEPTH = 1 << 21, + FLUSH_DEPTH = 1 << 22, + DEPTH_PASS_BEGIN = 1 << 23, + DEPTH_PASS_END = 1 << 24, + COLOR_PASS_BEGIN = 1 << 25, + COLOR_PASS_END = 1 << 26, + TILE_BEGIN = 1 << 27, + TILE_END = 1 << 28, + FLUSH_GPU_COMMAND_BUFFER = 1 << 29 }; Tr2VisibilityEvent() : @@ -79,7 +86,8 @@ struct Tr2VisibilityEvent m_eventType( INSTANCE_VISIBLE ), m_useClipPlane( false ), m_isMirroredInLeftHandedSpace( false ) - {} + { + } IRootPtr m_userData; Matrix m_objectToWorldMatrix; diff --git a/trinity/Tr2VisibilityResults_Blue.cpp b/trinity/Tr2VisibilityResults_Blue.cpp index 7e1b8d45e..931aa6a6b 100644 --- a/trinity/Tr2VisibilityResults_Blue.cpp +++ b/trinity/Tr2VisibilityResults_Blue.cpp @@ -13,11 +13,10 @@ const Be::ClassInfo* Tr2VisibilityResults::ExposeToBlue() MAP_METHOD_AND_WRAP( "Clear", Clear, "Clears the result set" ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "GetNumVisibilityEvents", GetNumVisibilityEvents, - "Gets the number of visibility events in the result set" - ) + "Gets the number of visibility events in the result set" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/Tr2VolumetricsRenderer.cpp b/trinity/Tr2VolumetricsRenderer.cpp index 7842afae0..064451f31 100644 --- a/trinity/Tr2VolumetricsRenderer.cpp +++ b/trinity/Tr2VolumetricsRenderer.cpp @@ -74,7 +74,7 @@ Tr2VolumetricsRenderer::Tr2VolumetricsRenderer( IRoot* ) : m_gameBackClip = 1E6f; //must match what the actual game uses; not what Graphite is currently set to, as the user can change the back clip. - + int noiseResolution = 64; { USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -153,7 +153,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderVolumetrics( const EveComponentRegistry& registry, const TriFrustum& frustum, const Tr2TextureAL& sceneDepth, - const Tr2TextureAL& froxelFog, + const Tr2TextureAL& froxelFog, const Vector3& sunDirection, const float depthSlices[4], bool raytracingEnabled, @@ -175,8 +175,8 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderVolumetrics( if( width == m_lastRequestedWidth && height == m_lastRequestedHeight ) { // Keep the real volume slice texture alive in case we need it again soon. - (void)gpuResourcePool.GetTempTexture( - "VolumetricSlices", + (void)gpuResourcePool.GetTempTexture( + "VolumetricSlices", Tr2BitmapDimensions( Tr2RenderContextEnum::TEX_TYPE_2D, Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT, @@ -195,9 +195,9 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderVolumetrics( renderContext.AddGpuMarker( __FUNCTION__ ); GPU_REGION( renderContext, "Volumetrics" ); - - GlobalStore().RegisterVariable( "EveSceneFroxelFogMap", froxelFog ); - ON_BLOCK_EXIT( []{ GlobalStore().RegisterVariable( "EveSceneFroxelFogMap", Tr2TextureAL{} ); } ); + + GlobalStore().RegisterVariable( "EveSceneFroxelFogMap", froxelFog ); + ON_BLOCK_EXIT( [] { GlobalStore().RegisterVariable( "EveSceneFroxelFogMap", Tr2TextureAL{} ); } ); ITr2VolumetricRenderable::SceneInformation sceneInfo; @@ -210,15 +210,15 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderVolumetrics( sceneInfo.castShadows = m_castShadows; sceneInfo.raytracedShadows = raytracingEnabled; - registry.ProcessComponents( [&sceneInfo] ( ITr2VolumetricRenderable* volumetric ) -> void { + registry.ProcessComponents( [&sceneInfo]( ITr2VolumetricRenderable* volumetric ) -> void { volumetric->SetSceneInformation( sceneInfo ); - } ); + } ); { GPU_REGION( renderContext, "Lightmaps" ); - registry.ProcessComponentsUntil( [&renderContext] ( ITr2VolumetricRenderable* volumetric ) -> bool { + registry.ProcessComponentsUntil( [&renderContext]( ITr2VolumetricRenderable* volumetric ) -> bool { return volumetric->UpdateVolumetricLightmap( renderContext ); - } ); + } ); } auto volumeSlices = gpuResourcePool.GetTempTexture( @@ -275,9 +275,9 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderVolumetrics( std::vector> renderables; renderables.reserve( volumetricsCount ); - registry.ProcessComponents( [&renderables, &frustum] ( ITr2VolumetricRenderable* renderable ) -> void { + registry.ProcessComponents( [&renderables, &frustum]( ITr2VolumetricRenderable* renderable ) -> void { renderables.push_back( { renderable, renderable->GetSortValue( frustum ) } ); - } ); + } ); std::stable_sort( begin( renderables ), end( renderables ), []( auto x, auto y ) { return x.second > y.second; } ); @@ -345,7 +345,6 @@ void Tr2VolumetricsRenderer::UpdateFogSettings( const EveComponentRegistry& regi double logBlendingSmoothness = m_logBlendingSmoothness; registry.ProcessComponents( [&overrides, logBlendingSmoothness]( ITr2FroxelFogSettings* component ) -> void { - ITr2FroxelFogSettings::FroxelFogSettings* fogSettings = component->GetFroxelFogSettings(); //Compute log(1 + thickness * m_logBlendingSmoothness) for each fog @@ -382,7 +381,7 @@ void Tr2VolumetricsRenderer::UpdateFogSettings( const EveComponentRegistry& regi FROXEL_ACCUMULATE( fogNoiseFrequency ); FROXEL_ACCUMULATE( fogNoiseMovementSpeed ); - if (m_logBlending) + if( m_logBlending ) { //Replace the thickness with a logarithmically interpolated one, making the transition from 0 thickness more graceful. FROXEL_ACCUMULATE( logThickness ); @@ -391,13 +390,11 @@ void Tr2VolumetricsRenderer::UpdateFogSettings( const EveComponentRegistry& regi float delta = updateContext.GetDeltaT(); - m_godRayNoiseAnimation += m_froxelFogSettings.godRayNoiseAnimationSpeed.value * (delta / m_froxel3DNoise->GetDepth()); + m_godRayNoiseAnimation += m_froxelFogSettings.godRayNoiseAnimationSpeed.value * ( delta / m_froxel3DNoise->GetDepth() ); m_godRayNoiseAnimation -= floor( m_godRayNoiseAnimation ); float fogFrequency = exp2f( -m_froxelFogSettings.fogNoiseFrequency.value ); m_fogNoiseMovement += m_froxelFogSettings.fogNoiseMovementSpeed.value * delta; - - } bool Tr2VolumetricsRenderer::HasFog() const @@ -473,7 +470,7 @@ void Tr2VolumetricsRenderer::UpdateFogEnvironmentMap( Tr2RenderContext& renderCo m_environmentRandom += g; m_environmentRandom = m_environmentRandom - floor( m_environmentRandom ); - + float lightG = -std::clamp( m_froxelFogSettings.lightDirectionality.value, 0.001f, 0.999f ); float environmentG = -std::clamp( m_froxelFogSettings.environmentDirectionality.value, 0.001f, 0.999f ); @@ -563,7 +560,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( uint32_t originalHeight, Tr2ShadowMap* cascadedShadowMap, Tr2RaytracingGeometryPtr raytracingGeometry, - ShadowQuality shadowQuality, + ShadowQuality shadowQuality, const Vector3& sunDirection, const Color& sunColor, const Vector3d origin, @@ -577,7 +574,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( // Figure out the resolution we need. uint32_t width = 1; uint32_t height = 1; - uint32_t depth = 1; + uint32_t depth = 1; bool froxelsEnabled = m_froxelFogSettings.thickness.value > 0.0f; if( froxelsEnabled ) @@ -586,7 +583,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( float scale; uint32_t numLayers; - switch (m_quality) + switch( m_quality ) { case Tr2VolumerticQuality::Ultra: scale = 1 / 6.0; @@ -619,12 +616,12 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( auto temporalFog = resources.useTemporalFroxels; - if (!froxelsEnabled) + if( !froxelsEnabled ) { return {}; } - + GPU_REGION( renderContext, "Froxel Fog" ); @@ -663,7 +660,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( resources.froxelJitter.z -= floor( resources.froxelJitter.z ); } - + if( !m_fogConstantBuffer.IsValid() ) { m_fogConstantBuffer.Create( uint32_t( sizeof( FogPerObjectData ) ), renderContext.GetPrimaryRenderContext() ); @@ -746,7 +743,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( else { //Otherwise, just use a plain compute shader. - resources.calculateFroxels->SetOption( BlueSharedString( "SHADOWS" ), BlueSharedString( shadowType == SHADOWS_CASCADED ? "SHADOWS_ENABLED" : "SHADOWS_DISABLED" ) ); + resources.calculateFroxels->SetOption( BlueSharedString( "SHADOWS" ), BlueSharedString( shadowType == SHADOWS_CASCADED ? "SHADOWS_ENABLED" : "SHADOWS_DISABLED" ) ); resources.calculateFroxels->SetOption( BlueSharedString( "GOD_RAY_NOISE" ), BlueSharedString( m_froxelFogSettings.godRayNoiseIntensity.value > 0.0f ? "GOD_RAY_NOISE_ENABLED" : "GOD_RAY_NOISE_DISABLED" ) ); resources.calculateFroxels->SetOption( BlueSharedString( "FOG_NOISE" ), BlueSharedString( m_froxelFogSettings.fogNoiseIntensity.value > 0.0f ? "FOG_NOISE_ENABLED" : "FOG_NOISE_DISABLED" ) ); @@ -761,9 +758,9 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( { GPU_REGION( renderContext, "Temporal filter" ); - auto temporalFroxels0 = gpuResourcePool.GetPersistentTexture( - "TemporalFroxelFog0", - dimensions, + auto temporalFroxels0 = gpuResourcePool.GetPersistentTexture( + "TemporalFroxelFog0", + dimensions, Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, []( auto& texture, auto& renderCtx ) { const float clearValue[] = { 0.0f, 0.0f, 0.0f, 1.0f }; @@ -790,7 +787,7 @@ Tr2GpuResourcePool::Texture Tr2VolumetricsRenderer::RenderFog( resources.raymarchFroxels->SetParameter( BlueSharedString( "InputTexture" ), temporalOutput ); } - + { GPU_REGION( renderContext, "Raymarch" ); resources.raymarchFroxels->SetParameter( BlueSharedString( "OutputTexture" ), fogFroxels ); @@ -1127,8 +1124,7 @@ void Tr2VolumetricsRenderer::RenderShadows( } auto accumulator = m_batches.get(); - registry.ProcessComponents( [&accumulator] ( ITr2VolumetricRenderable* volumetric ) { - volumetric->GetVolumetricShadowBatches( accumulator ); } ); + registry.ProcessComponents( [&accumulator]( ITr2VolumetricRenderable* volumetric ) { volumetric->GetVolumetricShadowBatches( accumulator ); } ); if( m_batches->GetBatchCount() ) { diff --git a/trinity/Tr2VolumetricsRenderer.h b/trinity/Tr2VolumetricsRenderer.h index 3edc4fc49..6127d3eae 100644 --- a/trinity/Tr2VolumetricsRenderer.h +++ b/trinity/Tr2VolumetricsRenderer.h @@ -13,7 +13,7 @@ struct Vector3d; - BLUE_DECLARE( Tr2Effect ); +BLUE_DECLARE( Tr2Effect ); BLUE_DECLARE( Tr2TextureReference ); BLUE_DECLARE( Tr2DepthStencil ); BLUE_DECLARE( EveComponentRegistry ); @@ -50,7 +50,6 @@ BLUE_INTERFACE( ITr2FroxelFogSettings ) : PriorityBlend::Attribute fogNoiseMovementSpeed = Vector3( 0.0f, 0.0f, 0.0f ); PriorityBlend::Attribute logThickness = 0.0; - }; virtual FroxelFogSettings* GetFroxelFogSettings() = 0; }; @@ -68,7 +67,7 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : const EveComponentRegistry& registry, const TriFrustum& frustum, const Tr2TextureAL& sceneDepth, - const Tr2TextureAL& froxelFog, + const Tr2TextureAL& froxelFog, const Vector3& sunDirection, const float depthSlices[4], bool raytracingEnabled, @@ -79,31 +78,31 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : void UpdateFogSettings( const EveComponentRegistry& registry, const EveUpdateContext& updateContext ); bool HasFog() const; - Tr2GpuResourcePool::Texture RenderFog( - Tr2RenderContext & renderContext, + Tr2GpuResourcePool::Texture RenderFog( + Tr2RenderContext & renderContext, Tr2GpuResourcePool & gpuResourcePool, - uint32_t width, - uint32_t height, - Tr2ShadowMap* cascadedShadowMap, + uint32_t width, + uint32_t height, + Tr2ShadowMap* cascadedShadowMap, Tr2RaytracingGeometryPtr raytracingGeometry, ShadowQuality shadowQuality, - const Vector3& sunDirection, - const Color& sunColor, + const Vector3& sunDirection, + const Color& sunColor, const Vector3d origin, const Vector3d originShift, - const Matrix& view, - const Matrix& projection, - const Matrix& viewLast, + const Matrix& view, + const Matrix& projection, + const Matrix& viewLast, const Matrix& projectionLast ); - Tr2GpuResourcePool::Texture RenderFogIntoReflectionMap( - Tr2RenderContext& renderContext, + Tr2GpuResourcePool::Texture RenderFogIntoReflectionMap( + Tr2RenderContext & renderContext, Tr2GpuResourcePool & gpuResourcePool, - uint32_t width, - uint32_t height, - const Vector3& sunDirection, - const Color& sunColor, + uint32_t width, + uint32_t height, + const Vector3& sunDirection, + const Color& sunColor, const Vector3d origin, - const Matrix& view, + const Matrix& view, const Matrix& projection ); static Tr2GpuResourcePool::Texture GetEmptyFogTexture( Tr2GpuResourcePool & gpuResourcePool ); void UpdateFogEnvironmentMap( Tr2RenderContext & renderContext ); @@ -135,7 +134,7 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : CcpMath::Sphere planets[2]; }; - void PopulatePerFrameData( FroxelPerFrameData& data ); + void PopulatePerFrameData( FroxelPerFrameData & data ); void SetQuality( Tr2VolumerticQuality quality ); @@ -160,24 +159,24 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : bool useTemporalFroxels; bool currentTemporalFroxels; }; - - Tr2GpuResourcePool::Texture RenderFog( - FogViewDependentResources& resources, - Tr2RenderContext& renderContext, + + Tr2GpuResourcePool::Texture RenderFog( + FogViewDependentResources & resources, + Tr2RenderContext & renderContext, Tr2GpuResourcePool & gpuResourcePool, - uint32_t originalWidth, - uint32_t originalHeight, - Tr2ShadowMap* cascadedShadowMap, + uint32_t originalWidth, + uint32_t originalHeight, + Tr2ShadowMap* cascadedShadowMap, Tr2RaytracingGeometryPtr raytracingGeometry, ShadowQuality shadowQuality, - const Vector3& sunDirection, - const Color& sunColor, + const Vector3& sunDirection, + const Color& sunColor, const Vector3d origin, const Vector3d originShift, - const Matrix& view, - const Matrix& projection, - const Matrix& viewLast, + const Matrix& view, + const Matrix& projection, + const Matrix& viewLast, const Matrix& projectionLast ); Tr2EffectPtr m_volumeBlit; @@ -187,10 +186,9 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : uint32_t m_lastRequestedWidth = 0; uint32_t m_lastRequestedHeight = 0; - - - + + Tr2TextureReferencePtr m_mieEnvironmentMap; float m_environmentRandom; @@ -273,19 +271,19 @@ BLUE_CLASS( Tr2VolumetricsRenderer ) : Vector4 ShadowMapValues[4]; // x = zFar value[0], y = zFar value[1], z = zFar value[2], w = zFar value[3]..etc Matrix ShadowMatrix[16]; // Matrix that takes a coordinate from view space all the way to the packed cascades Vector4 SplitInfo; // x = NrOfSplits, y = , z = , w = - + Tr2LightManager::PerLightData DynamicLights[16]; - + CcpMath::Sphere planets[2]; }; - void UpdatePerObjectData( FogPerObjectData* data, const Matrix& view, const Matrix& projection, const Matrix& viewLast, const Matrix& projectionLast, const Vector3d& origin, const Vector3d& originShift, const Vector3& sunDirection, const Color& sunColor, uint32_t width, uint32_t height, uint32_t depth, const Vector3& jitter, const Tr2ShadowMap* cascadedShadowMap ); + void UpdatePerObjectData( FogPerObjectData * data, const Matrix& view, const Matrix& projection, const Matrix& viewLast, const Matrix& projectionLast, const Vector3d& origin, const Vector3d& originShift, const Vector3& sunDirection, const Color& sunColor, uint32_t width, uint32_t height, uint32_t depth, const Vector3& jitter, const Tr2ShadowMap* cascadedShadowMap ); Tr2ConstantBufferAL m_fogConstantBuffer; - + std::unique_ptr m_batches; - + Tr2ConstantBufferAL m_shadowPerFrameVSBuffer; Tr2VolumerticQuality m_quality; float m_scaleFactor; diff --git a/trinity/Tr2VolumetricsRenderer_Blue.cpp b/trinity/Tr2VolumetricsRenderer_Blue.cpp index 6b821fd35..268eb0ccd 100644 --- a/trinity/Tr2VolumetricsRenderer_Blue.cpp +++ b/trinity/Tr2VolumetricsRenderer_Blue.cpp @@ -160,7 +160,6 @@ const Be::ClassInfo* Tr2VolumetricsRenderer::ExposeToBlue() - MAP_ATTRIBUTE( "mieEnvironmentMap", m_mieEnvironmentMap, diff --git a/trinity/TriColor.cpp b/trinity/TriColor.cpp index 31d432c83..3ba898a74 100644 --- a/trinity/TriColor.cpp +++ b/trinity/TriColor.cpp @@ -9,54 +9,60 @@ // h = [0,360], s = [0,1], v = [0,1] // if s == 0, then h = -1 (undefined) static void HSVtoRGB( - float *r, float *g, float *b, float h, float s, float v - ) + float* r, + float* g, + float* b, + float h, + float s, + float v ) { int i; float f, p, q, t; - if( s == 0 ) { + if( s == 0 ) + { s = 0.000000001f; // achromatic (grey) //*r = *g = *b = v; //return; } - h /= 60; // sector 0 to 5 + h /= 60; // sector 0 to 5 i = (int)floor( h ); - f = h - i; // factorial part of h + f = h - i; // factorial part of h p = v * ( 1 - s ); q = v * ( 1 - s * f ); t = v * ( 1 - s * ( 1 - f ) ); - switch( i ) { - case 0: - *r = v; - *g = t; - *b = p; - break; - case 1: - *r = q; - *g = v; - *b = p; - break; - case 2: - *r = p; - *g = v; - *b = t; - break; - case 3: - *r = p; - *g = q; - *b = v; - break; - case 4: - *r = t; - *g = p; - *b = v; - break; - default: // case 5: - *r = v; - *g = p; - *b = q; - break; + switch( i ) + { + case 0: + *r = v; + *g = t; + *b = p; + break; + case 1: + *r = q; + *g = v; + *b = p; + break; + case 2: + *r = p; + *g = v; + *b = t; + break; + case 3: + *r = p; + *g = q; + *b = v; + break; + case 4: + *r = t; + *g = p; + *b = v; + break; + default: // case 5: + *r = v; + *g = p; + *b = q; + break; } } @@ -65,19 +71,25 @@ static void HSVtoRGB( // r,g,b values are from 0 to 1 // h = [0,360], s = [0,1], v = [0,1] // if s == 0, then h = -1 (undefined) -#define c_MAX(a,b,c) a > b ? (a > c ? a : c) : b > c ? b : c; -#define c_MIN(a,b,c) a < b ? (a < c ? a : c) : b < c ? b : c; +#define c_MAX( a, b, c ) a > b ? ( a > c ? a : c ) : b > c ? b : \ + c; +#define c_MIN( a, b, c ) a < b ? ( a < c ? a : c ) : b < c ? b : \ + c; static void RGBtoHSV( - float r, float g, float b, float *h, float *s, float *v - ) + float r, + float g, + float b, + float* h, + float* s, + float* v ) { float min, max, delta; min = c_MIN( r, g, b ); max = c_MAX( r, g, b ); - *v = max; // v + *v = max; // v delta = max - min; - if (delta == 0.0) + if( delta == 0.0 ) { *h = 0.0; *s = 0.0; @@ -85,7 +97,7 @@ static void RGBtoHSV( } else if( max != 0 ) { - *s = delta / max; // s + *s = delta / max; // s } else { @@ -96,12 +108,12 @@ static void RGBtoHSV( } if( r == max ) - *h = ( g - b ) / delta; // between yellow & magenta + *h = ( g - b ) / delta; // between yellow & magenta else if( g == max ) - *h = 2 + ( b - r ) / delta; // between cyan & yellow + *h = 2 + ( b - r ) / delta; // between cyan & yellow else - *h = 4 + ( r - g ) / delta; // between magenta & cyan - *h *= 60; // degrees + *h = 4 + ( r - g ) / delta; // between magenta & cyan + *h *= 60; // degrees if( *h < 0 ) *h += 360; } @@ -112,39 +124,35 @@ static void RGBtoHSV( ///////////////////////////////////////////////////////////////////////////////////////// #if BLUE_WITH_PYTHON -void TriColor::Destroy( - ) +void TriColor::Destroy() { //delete this; } -PyObject* TriColor::GetAttr( - const char* name, - bool* handled - ) +PyObject* TriColor::GetAttr( + const char* name, + bool* handled ) { return 0; } bool TriColor::SetAttr( - const char* name, - PyObject* v, - bool* handled - ) + const char* name, + PyObject* v, + bool* handled ) { return true; } PyObject* TriColor::Repr( - bool* handled - ) + bool* handled ) { *handled = true; char buf[120]; - sprintf_s(buf, "", r, g, b, a); + sprintf_s( buf, "", r, g, b, a ); return ToPython( buf ); } @@ -153,8 +161,8 @@ PyObject* TriColor::Repr( // TriColor ///////////////////////////////////////////////////////////////////////////////////////// -TriColor::TriColor(IRoot* lockobj) : - ::Color(0.0f, 0.0f, 0.0f, 0.0f) +TriColor::TriColor( IRoot* lockobj ) : + ::Color( 0.0f, 0.0f, 0.0f, 0.0f ) { } @@ -169,97 +177,88 @@ TriColor::~TriColor() ///////////////////////////////////////////////////////////////////////////////////////// void TriColor::SetRGB( - float _r, - float _g, - float _b, - float _a - ) + float _r, + float _g, + float _b, + float _a ) { r = _r; g = _g; b = _b; - - if (_a != TRICOLOR_NOALPHA) + + if( _a != TRICOLOR_NOALPHA ) a = _a; } void TriColor::SetHSV( - float h, - float s, - float v, - float _a - ) + float h, + float s, + float v, + float _a ) { - HSVtoRGB(&r, &g, &b, h, s, v); + HSVtoRGB( &r, &g, &b, h, s, v ); - if (_a != TRICOLOR_NOALPHA) + if( _a != TRICOLOR_NOALPHA ) a = _a; } void TriColor::SetVector( const Vector3* in, - float alpha - ) + float alpha ) { - TriColorFromVector(this, in, alpha); + TriColorFromVector( this, in, alpha ); } void TriColor::GetHSV( - float* h, - float* s, - float* v, - float* _a - ) + float* h, + float* s, + float* v, + float* _a ) { - RGBtoHSV(r, g, b, h, s, v); + RGBtoHSV( r, g, b, h, s, v ); - if (_a) + if( _a ) *_a = a; } void TriColor::SetColor( - const ::Color* ar - ) + const ::Color* ar ) { r = ar->r; g = ar->g; b = ar->b; - - if (ar->a != TRICOLOR_NOALPHA) + + if( ar->a != TRICOLOR_NOALPHA ) a = ar->a; } -const ::Color* TriColor::GetColor( - ) const +const ::Color* TriColor::GetColor() const { - return this; + return this; } ::Color* TriColor::CopyColor( - ::Color* in - ) const + ::Color* in ) const { // would this work? //return &(*in = *this); - + *in = *this; return in; } -::Color* TriColor::Color( - ) +::Color* TriColor::Color() { return this; } void TriColor::Scale( - float s - ) + float s ) { *static_cast<::Color*>( this ) = *this * s; } @@ -269,7 +268,7 @@ void TriColor::Scale( // Python thunkers for ITriColor interface ///////////////////////////////////////////////////////////////////////////////////////// void TriColor::Py__init__( float _r, float _g, float _b, float _a ) -{ +{ r = _r; g = _g; b = _b; @@ -277,13 +276,13 @@ void TriColor::Py__init__( float _r, float _g, float _b, float _a ) } void TriColor::PySetRGB( float r, float g, float b, Be::Optional a ) -{ +{ SetRGB( r, g, b, a.IsAssigned() ? float( a ) : TRICOLOR_NOALPHA ); } void TriColor::PySetHSV( float hue, float saturation, float value, Be::Optional a ) -{ +{ SetHSV( hue, saturation, value, a.IsAssigned() ? float( a ) : TRICOLOR_NOALPHA ); } @@ -302,8 +301,8 @@ Vector3 TriColor::PyGetHSV() void TriColor::PyFromInt( int32_t color ) { // For legacy reasons, Python expects a signed integer value - uint32_t unsignedColor = static_cast(color); - ::Color t(unsignedColor); + uint32_t unsignedColor = static_cast( color ); + ::Color t( unsignedColor ); r = t.r; g = t.g; b = t.b; @@ -312,23 +311,21 @@ void TriColor::PyFromInt( int32_t color ) int32_t TriColor::PyAsInt() { - return static_cast(*this); + return static_cast( *this ); } PyObject* TriColor::PyAdd( - PyObject* args - ) -{ - Py_INCREF(Py_None); + PyObject* args ) +{ + Py_INCREF( Py_None ); return Py_None; } PyObject* TriColor::PyLerp( - PyObject* args - ) -{ - Py_INCREF(Py_None); + PyObject* args ) +{ + Py_INCREF( Py_None ); return Py_None; } diff --git a/trinity/TriColor_Blue.cpp b/trinity/TriColor_Blue.cpp index 784c1ec77..2b5884a54 100644 --- a/trinity/TriColor_Blue.cpp +++ b/trinity/TriColor_Blue.cpp @@ -9,84 +9,71 @@ BLUE_DEFINE( TriColor ); const Be::ClassInfo* TriColor::ExposeToBlue() { - EXPOSURE_BEGIN(TriColor, TRICOLOR_Description) - MAP_INTERFACE(ITriColor) - MAP_INTERFACE(IPythonMethods) + EXPOSURE_BEGIN( TriColor, TRICOLOR_Description ) + MAP_INTERFACE( ITriColor ) + MAP_INTERFACE( IPythonMethods ) //////////////////////////////////////////////////////////////////////////// // r - MAP_ATTRIBUTE - ( - "r", - r, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "r", + r, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // g - MAP_ATTRIBUTE - ( - "g", - g, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "g", + g, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // b - MAP_ATTRIBUTE - ( - "b", - b, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "b", + b, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // a - MAP_ATTRIBUTE - ( - "a", - a, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "a", + a, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // __init__ - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", - Py__init__, + Py__init__, 4, - "Constructor arguments\n" + "Constructor arguments\n" ":param r: red\n" ":param g: green\n" ":param b: blue\n" - ":param a: alpha\n" - ) + ":param a: alpha\n" ) //////////////////////////////////////////////////////////////////////////// // SetRGB - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "SetRGB", - PySetRGB, + PySetRGB, 4, - "Sets the RGB values of the color\n" + "Sets the RGB values of the color\n" ":param r: red\n" ":param g: green\n" ":param b: blue\n" - ":param a: alpha\n" - ) + ":param a: alpha\n" ) //////////////////////////////////////////////////////////////////////////// // SetHSV - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "SetHSV", - PySetHSV, + PySetHSV, 4, "Sets the HSV values of the color \r\n" "h = [0,360], s = [0,1], v = [0,1]\n" @@ -94,81 +81,65 @@ const Be::ClassInfo* TriColor::ExposeToBlue() ":param hue: \n" ":param saturation: \n" ":param value: \n" - ":param alpha: \n" - ) + ":param alpha: \n" ) //////////////////////////////////////////////////////////////////////////// // SetVector - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "SetVector", - PySetVector, + PySetVector, 1, - "Finds the color of the vector and uses that.\n" + "Finds the color of the vector and uses that.\n" ":param vec: vector\n" - ":param alpha: alpha" - ) + ":param alpha: alpha" ) //////////////////////////////////////////////////////////////////////////// // GetHSV - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetHSV", - PyGetHSV, - "Returns the HSV values of the color\r\n" + PyGetHSV, + "Returns the HSV values of the color\r\n" "h = [0,360], s = [0,1], v = [0,1]\r\n" - "if s == 0, then h = -1 (undefined)" - ) + "if s == 0, then h = -1 (undefined)" ) //////////////////////////////////////////////////////////////////////////// // FromInt - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "FromInt", - PyFromInt, - "Changes thie color to the one reprecented by the integer\n" - ":param color: " - ) + PyFromInt, + "Changes thie color to the one reprecented by the integer\n" + ":param color: " ) //////////////////////////////////////////////////////////////////////////// // AsInt - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "AsInt", - PyAsInt, - "Returns an integer reprecenting the color" - ) + PyAsInt, + "Returns an integer reprecenting the color" ) //////////////////////////////////////////////////////////////////////////// // Add - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "Add", - PyAdd, - "BROKEN! Adds a color to this color.\n" - ":rtype: None" - ) + PyAdd, + "BROKEN! Adds a color to this color.\n" + ":rtype: None" ) //////////////////////////////////////////////////////////////////////////// // Lerp - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "Lerp", - PyLerp, - "BROKEN! Uses linear interpolation to modify this color value\n" - ":rtype: None" - ) + PyLerp, + "BROKEN! Uses linear interpolation to modify this color value\n" + ":rtype: None" ) //////////////////////////////////////////////////////////////////////////// // Scale - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Scale", - Scale, - "Scales the value of the color.\n" - ":param s: scale" - ) + Scale, + "Scales the value of the color.\n" + ":param s: scale" ) EXPOSURE_END() - } #endif diff --git a/trinity/TriConstants.cpp b/trinity/TriConstants.cpp index e494f0cf3..dbc570c25 100644 --- a/trinity/TriConstants.cpp +++ b/trinity/TriConstants.cpp @@ -10,17 +10,16 @@ using namespace Tr2RenderContextEnum; #if BLUE_WITH_PYTHON -void AddTriConstants(PyObject* d) +void AddTriConstants( PyObject* d ) { - const Be::VarChooser* const triConstants [] = - { + const Be::VarChooser* const triConstants[] = { #if DEPRECATED_ENABLED TriTextureAddress, #endif - + TriBlendOp, TriBlend, - TriTextureChooser, + TriTextureChooser, TriExtrapolation, TriOperator, TriTransformBase, @@ -28,15 +27,15 @@ void AddTriConstants(PyObject* d) TriD3DRenderState, }; - for (int i = 0; i < sizeof triConstants / sizeof triConstants[0]; i++) + for( int i = 0; i < sizeof triConstants / sizeof triConstants[0]; i++ ) { - for (const Be::VarChooser* j = triConstants[i]; j->mKey; j++) + for( const Be::VarChooser* j = triConstants[i]; j->mKey; j++ ) { // this obviously assumes that all values are LONG // later perhaps call BlueToPython to convert types // correctly - PyObject *value = ToPython( j->mValue.mLong ); - PyDict_SetItemString(d, const_cast( j->mKey ), value ); + PyObject* value = ToPython( j->mValue.mLong ); + PyDict_SetItemString( d, const_cast( j->mKey ), value ); Py_DECREF( value ); } } @@ -44,11 +43,11 @@ void AddTriConstants(PyObject* d) #endif -const char* KeyFromVal(const Be::VarChooser* i, long val) +const char* KeyFromVal( const Be::VarChooser* i, long val ) { - while (i->mKey) + while( i->mKey ) { - if(i->mValue.mLong == val) + if( i->mValue.mLong == val ) return i->mKey; i++; } @@ -58,374 +57,263 @@ const char* KeyFromVal(const Be::VarChooser* i, long val) -#define VAL(v) BeCast(v) +#define VAL( v ) BeCast( v ) #define KV( name, doc ) \ -{ \ -#name, \ - VAL( name ), \ - doc \ -} + { \ + #name, \ + VAL( name ), \ + doc \ + } -#define KV_RC( name, doc ) \ -{ \ - "D3D" #name, \ - VAL( Tr2RenderContextEnum::name ), \ - doc \ -} +#define KV_RC( name, doc ) \ + { \ + "D3D" #name, \ + VAL( Tr2RenderContextEnum::name ), \ + doc \ + } -#define VAL_RC(v) BeCast(Tr2RenderContextEnum:: v) +#define VAL_RC( v ) BeCast( Tr2RenderContextEnum::v ) -const Be::VarChooser TriTextureChooser[] = -{ - { - "SELECT_TEXTURE", - VAL(0), - "Texture (.dds, .tga, .bmp)|*.dds;*.tga;*.bmp;|All Files (*.*)|*.*" - }, - {0} +const Be::VarChooser TriTextureChooser[] = { + { "SELECT_TEXTURE", + VAL( 0 ), + "Texture (.dds, .tga, .bmp)|*.dds;*.tga;*.bmp;|All Files (*.*)|*.*" }, + { 0 } }; -const Be::VarChooser TriGR2Chooser[] = -{ - { - "SELECT_GR2MODEL", - VAL(0), - "Granny/CMF file(.gr2, .cmf)|*.GR2;*.CMF|All Files (*.*)|*.*" - }, - {0} +const Be::VarChooser TriGR2Chooser[] = { + { "SELECT_GR2MODEL", + VAL( 0 ), + "Granny/CMF file(.gr2, .cmf)|*.GR2;*.CMF|All Files (*.*)|*.*" }, + { 0 } }; -const Be::VarChooser TriExtrapolation[] = -{ - { - "TRIEXT_NONE", - VAL(TRIEXT_NONE), - "no comment" - }, - { - "TRIEXT_CONSTANT", - VAL(TRIEXT_CONSTANT), - "no comment" - }, - { - "TRIEXT_GRADIENT", - VAL(TRIEXT_GRADIENT), - "no comment" - }, - { - "TRIEXT_CYCLE", - VAL(TRIEXT_CYCLE), - "no comment" - }, - {0} +const Be::VarChooser TriExtrapolation[] = { + { "TRIEXT_NONE", + VAL( TRIEXT_NONE ), + "no comment" }, + { "TRIEXT_CONSTANT", + VAL( TRIEXT_CONSTANT ), + "no comment" }, + { "TRIEXT_GRADIENT", + VAL( TRIEXT_GRADIENT ), + "no comment" }, + { "TRIEXT_CYCLE", + VAL( TRIEXT_CYCLE ), + "no comment" }, + { 0 } }; -const Be::VarChooser TriTransformBase[] = -{ - { - "TRITB_OBJECT", - VAL(TRITB_OBJECT), - "This makes TriTransforms build hierachies as expected, that is a child inherits " - "its parent transforms.\r\n." - "For TriTextures this is mosly usefull for projecting textures from objects" - }, - { - "TRITB_CAMERA_ROTATION", - VAL(TRITB_CAMERA_ROTATION), - "This sets the inverted rotation part of the camera matrix as the base for the" - "transformations be they texture or transforms, good for environment maps and" - "normal projected cubemaps." - }, - { - "TRITB_CAMERA_TRANSLATION", - VAL(TRITB_CAMERA_TRANSLATION), - "This sets the inverted translation part of the camera matrix as the base for the" - "transformations be they texture or transforms, good for geometry that is locked," - "to the camera, like nebulas and starfields, etc." - }, - { - "TRITB_CAMERA", - VAL(TRITB_CAMERA), - "This sets the inverted camera matrix as the base for the transformations" - "be they texture or geometry transforms, basically the same, as " - "TRITB_CAMERA_ROTATION except the translation is taken also" - "" - }, - { - "TRITB_CAMERA_ROTATION_ALIGNED", - VAL(TRITB_CAMERA_ROTATION_ALIGNED), - "Makes the transform face the camera at all times, used for billboarding." - "The up direction of the billboard is preserved." - }, - { - "TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY", - VAL(TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY), - "Makes the transform face the camera at all times, used for billboarding," - "the rotation around the axis to the camera is not corrected, hence this" - "should only be used for rotationally symmetric billboards." - }, - { - "TRITB_CAMERA_ROTATION_FALLOFF", - VAL(TRITB_CAMERA_ROTATION_FALLOFF), - "Same as TRITB_CAMERA_ROTATION_ALIGNED, except the billboard is scaled" - "by distance. This is useful for lights that are not rotationally symmetric." - }, - { - "TRITB_CAMERA_ROTATION_FALLOFF_SYMMETRY", - VAL(TRITB_CAMERA_ROTATION_FALLOFF_SYMMETRY), - "Same as TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY, except the billboard is scaled" - "by distance. This is useful for lights that are rotationally symmetric." - }, - { - "TRITB_BOOSTER", - VAL(TRITB_BOOSTER), - "Makes the sprite behave as if it were an ellipsoid" - }, - { - "TRITB_SIMPLE_HALO", - VAL(TRITB_SIMPLE_HALO), - "Ask Torfi" - }, - { - "TRITB_SIMPLE_HALO_FALLOFF", - VAL(TRITB_SIMPLE_HALO_FALLOFF), - "Ask Torfi" - }, - { - "TRITB_SIMPLE_HALO_SYMMETRY", - VAL(TRITB_SIMPLE_HALO_SYMMETRY), - "Ask Torfi" - }, - { - "TRITB_SIMPLE_SPRITE", - VAL(TRITB_SIMPLE_SPRITE), - "Ask Torfi" - }, - { - "TRITB_SIMPLE_SPRITE_FALLOFF", - VAL(TRITB_SIMPLE_SPRITE_FALLOFF), - "Ask Torfi" - }, - { - "TRITB_SIMPLE_SPRITE_CONSTANT", - VAL(TRITB_SIMPLE_SPRITE_CONSTANT), - "Don't ask Torfi" - }, - { - "TRITB_FIXED", - VAL(TRITB_FIXED), - "This placed traditionally called world-space, the transform is considered to " - "be in the world cordinate system (object hierarchies are ignored)" - "This leves the texture space untouched (set to the identity matrix)." - }, - { - "TRITB_BOOSTER_FALLOFF", - VAL(TRITB_BOOSTER_FALLOFF), - "Makes the sprite behave as if it were an ellipsoid, includes falloff" - }, - { - "TRITB_WORLD", - VAL(TRITB_WORLD), - "Transforms the object relative to the world zero " - }, - {0} +const Be::VarChooser TriTransformBase[] = { + { "TRITB_OBJECT", + VAL( TRITB_OBJECT ), + "This makes TriTransforms build hierachies as expected, that is a child inherits " + "its parent transforms.\r\n." + "For TriTextures this is mosly usefull for projecting textures from objects" }, + { "TRITB_CAMERA_ROTATION", + VAL( TRITB_CAMERA_ROTATION ), + "This sets the inverted rotation part of the camera matrix as the base for the" + "transformations be they texture or transforms, good for environment maps and" + "normal projected cubemaps." }, + { "TRITB_CAMERA_TRANSLATION", + VAL( TRITB_CAMERA_TRANSLATION ), + "This sets the inverted translation part of the camera matrix as the base for the" + "transformations be they texture or transforms, good for geometry that is locked," + "to the camera, like nebulas and starfields, etc." }, + { "TRITB_CAMERA", + VAL( TRITB_CAMERA ), + "This sets the inverted camera matrix as the base for the transformations" + "be they texture or geometry transforms, basically the same, as " + "TRITB_CAMERA_ROTATION except the translation is taken also" + "" }, + { "TRITB_CAMERA_ROTATION_ALIGNED", + VAL( TRITB_CAMERA_ROTATION_ALIGNED ), + "Makes the transform face the camera at all times, used for billboarding." + "The up direction of the billboard is preserved." }, + { "TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY", + VAL( TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY ), + "Makes the transform face the camera at all times, used for billboarding," + "the rotation around the axis to the camera is not corrected, hence this" + "should only be used for rotationally symmetric billboards." }, + { "TRITB_CAMERA_ROTATION_FALLOFF", + VAL( TRITB_CAMERA_ROTATION_FALLOFF ), + "Same as TRITB_CAMERA_ROTATION_ALIGNED, except the billboard is scaled" + "by distance. This is useful for lights that are not rotationally symmetric." }, + { "TRITB_CAMERA_ROTATION_FALLOFF_SYMMETRY", + VAL( TRITB_CAMERA_ROTATION_FALLOFF_SYMMETRY ), + "Same as TRITB_CAMERA_ROTATION_ALIGNED_SYMMETRY, except the billboard is scaled" + "by distance. This is useful for lights that are rotationally symmetric." }, + { "TRITB_BOOSTER", + VAL( TRITB_BOOSTER ), + "Makes the sprite behave as if it were an ellipsoid" }, + { "TRITB_SIMPLE_HALO", + VAL( TRITB_SIMPLE_HALO ), + "Ask Torfi" }, + { "TRITB_SIMPLE_HALO_FALLOFF", + VAL( TRITB_SIMPLE_HALO_FALLOFF ), + "Ask Torfi" }, + { "TRITB_SIMPLE_HALO_SYMMETRY", + VAL( TRITB_SIMPLE_HALO_SYMMETRY ), + "Ask Torfi" }, + { "TRITB_SIMPLE_SPRITE", + VAL( TRITB_SIMPLE_SPRITE ), + "Ask Torfi" }, + { "TRITB_SIMPLE_SPRITE_FALLOFF", + VAL( TRITB_SIMPLE_SPRITE_FALLOFF ), + "Ask Torfi" }, + { "TRITB_SIMPLE_SPRITE_CONSTANT", + VAL( TRITB_SIMPLE_SPRITE_CONSTANT ), + "Don't ask Torfi" }, + { "TRITB_FIXED", + VAL( TRITB_FIXED ), + "This placed traditionally called world-space, the transform is considered to " + "be in the world cordinate system (object hierarchies are ignored)" + "This leves the texture space untouched (set to the identity matrix)." }, + { "TRITB_BOOSTER_FALLOFF", + VAL( TRITB_BOOSTER_FALLOFF ), + "Makes the sprite behave as if it were an ellipsoid, includes falloff" }, + { "TRITB_WORLD", + VAL( TRITB_WORLD ), + "Transforms the object relative to the world zero " }, + { 0 } }; -const Be::VarChooser TriOperator[] = -{ - { - "TRIOP_MULTIPLY", - VAL(TRIOP_MULTIPLY), - "multiply" - }, - { - "TRIOP_ADD", - VAL(TRIOP_ADD), - "add" - }, - { - "TRIOP_AVERAGE", - VAL(TRIOP_AVERAGE), - "average" - }, - {0} +const Be::VarChooser TriOperator[] = { + { "TRIOP_MULTIPLY", + VAL( TRIOP_MULTIPLY ), + "multiply" }, + { "TRIOP_ADD", + VAL( TRIOP_ADD ), + "add" }, + { "TRIOP_AVERAGE", + VAL( TRIOP_AVERAGE ), + "average" }, + { 0 } }; -const Be::VarChooser TriBlendOp[] = -{ - { - "TRIBLENDOP_DISABLE", - VAL(Tr2RenderContextEnum::BO_DISABLE), - "No blending\n" - }, - { - "TRIBLENDOP_ADD", - VAL(Tr2RenderContextEnum::BO_ADD), - "The result is the destination added to the source.\n" - "Result = Source + Destination" - }, - { - "TRIBLENDOP_SUBTRACT", - VAL(Tr2RenderContextEnum::BO_SUBTRACT), - "The result is the destination subtracted from to the source.\n" - "Result = Source - Destination" - }, - { - "TRIBLENDOP_REVSUBTRACT", - VAL(Tr2RenderContextEnum::BO_REVSUBTRACT), - "The result is the source subtracted from the destination.\n" - "Result = Destination - Source" - }, - { - "TRIBLENDOP_MIN", - VAL(Tr2RenderContextEnum::BO_MIN), - "The result is the minimum of the source and destination.\n" - "Result = MIN(Source, Destination)" - }, - { - "TRIBLENDOP_MAX", - VAL(Tr2RenderContextEnum::BO_MAX), - "The result is the maximum of the source and destination.\n" - "Result = MAX(Source, Destination)" - }, - {0} +const Be::VarChooser TriBlendOp[] = { + { "TRIBLENDOP_DISABLE", + VAL( Tr2RenderContextEnum::BO_DISABLE ), + "No blending\n" }, + { "TRIBLENDOP_ADD", + VAL( Tr2RenderContextEnum::BO_ADD ), + "The result is the destination added to the source.\n" + "Result = Source + Destination" }, + { "TRIBLENDOP_SUBTRACT", + VAL( Tr2RenderContextEnum::BO_SUBTRACT ), + "The result is the destination subtracted from to the source.\n" + "Result = Source - Destination" }, + { "TRIBLENDOP_REVSUBTRACT", + VAL( Tr2RenderContextEnum::BO_REVSUBTRACT ), + "The result is the source subtracted from the destination.\n" + "Result = Destination - Source" }, + { "TRIBLENDOP_MIN", + VAL( Tr2RenderContextEnum::BO_MIN ), + "The result is the minimum of the source and destination.\n" + "Result = MIN(Source, Destination)" }, + { "TRIBLENDOP_MAX", + VAL( Tr2RenderContextEnum::BO_MAX ), + "The result is the maximum of the source and destination.\n" + "Result = MAX(Source, Destination)" }, + { 0 } }; -const Be::VarChooser TriBlend[] = -{ - { - "TRIBLEND_ZERO", - VAL(Tr2RenderContextEnum::BM_ZERO), - "Blend factor is (0, 0, 0, 0)." - }, - { - "TRIBLEND_ONE", - VAL(Tr2RenderContextEnum::BM_ONE), - "Blend factor is (1, 1, 1, 1)." - }, - { - "TRIBLEND_SRCCOLOR", - VAL(Tr2RenderContextEnum::BM_SRCCOLOR), - "Blend factor is (Rs, Gs, Bs, As)." - }, - { - "TRIBLEND_INVSRCCOLOR", - VAL(Tr2RenderContextEnum::BM_INVSRCCOLOR), - "Blend factor is (1-Rs, 1-Gs, 1-Bs, 1-As)." - }, - { - "TRIBLEND_SRCALPHA", - VAL(Tr2RenderContextEnum::BM_SRCALPHA), - "Blend factor is (As, As, As, As)." - }, - { - "TRIBLEND_INVSRCALPHA", - VAL(Tr2RenderContextEnum::BM_INVSRCALPHA), - "Blend factor is (1-As, 1-As, 1-As, 1-As)." - }, - { - "TRIBLEND_DESTALPHA", - VAL(Tr2RenderContextEnum::BM_DESTALPHA), - "Blend factor is (Ad, Ad, Ad, Ad)." - }, - { - "TRIBLEND_INVDESTALPHA", - VAL(Tr2RenderContextEnum::BM_INVDESTALPHA), - "Blend factor is (1-Ad, 1-Ad, 1-Ad, 1-Ad)." - }, - { - "TRIBLEND_DESTCOLOR", - VAL(Tr2RenderContextEnum::BM_DESTCOLOR), - "Blend factor is (Rd, Gd, Bd, Ad)." - }, - { - "TRIBLEND_INVDESTCOLOR", - VAL(Tr2RenderContextEnum::BM_INVDESTCOLOR), - "Blend factor is (1-Rd, 1-Gd, 1-Bd, 1-Ad)." - }, - { - "TRIBLEND_SRCALPHASAT", - VAL(Tr2RenderContextEnum::BM_SRCALPHASAT), - "Blend factor is (f, f, f, 1); f = min(As, 1-Ad)." - }, - { - "TRIBLEND_BOTHINVSRCALPHA", - VAL(Tr2RenderContextEnum::BM_BOTHINVSRCALPHA), - "Source blend factor is (1-As, 1-As, 1-As, 1-As), and destination blend factor is " - "(As, As, As, As); the destination blend selection is overridden. This blend mode is " - "supported only for the D3DRS_SRCBLEND render state." - }, - {0} +const Be::VarChooser TriBlend[] = { + { "TRIBLEND_ZERO", + VAL( Tr2RenderContextEnum::BM_ZERO ), + "Blend factor is (0, 0, 0, 0)." }, + { "TRIBLEND_ONE", + VAL( Tr2RenderContextEnum::BM_ONE ), + "Blend factor is (1, 1, 1, 1)." }, + { "TRIBLEND_SRCCOLOR", + VAL( Tr2RenderContextEnum::BM_SRCCOLOR ), + "Blend factor is (Rs, Gs, Bs, As)." }, + { "TRIBLEND_INVSRCCOLOR", + VAL( Tr2RenderContextEnum::BM_INVSRCCOLOR ), + "Blend factor is (1-Rs, 1-Gs, 1-Bs, 1-As)." }, + { "TRIBLEND_SRCALPHA", + VAL( Tr2RenderContextEnum::BM_SRCALPHA ), + "Blend factor is (As, As, As, As)." }, + { "TRIBLEND_INVSRCALPHA", + VAL( Tr2RenderContextEnum::BM_INVSRCALPHA ), + "Blend factor is (1-As, 1-As, 1-As, 1-As)." }, + { "TRIBLEND_DESTALPHA", + VAL( Tr2RenderContextEnum::BM_DESTALPHA ), + "Blend factor is (Ad, Ad, Ad, Ad)." }, + { "TRIBLEND_INVDESTALPHA", + VAL( Tr2RenderContextEnum::BM_INVDESTALPHA ), + "Blend factor is (1-Ad, 1-Ad, 1-Ad, 1-Ad)." }, + { "TRIBLEND_DESTCOLOR", + VAL( Tr2RenderContextEnum::BM_DESTCOLOR ), + "Blend factor is (Rd, Gd, Bd, Ad)." }, + { "TRIBLEND_INVDESTCOLOR", + VAL( Tr2RenderContextEnum::BM_INVDESTCOLOR ), + "Blend factor is (1-Rd, 1-Gd, 1-Bd, 1-Ad)." }, + { "TRIBLEND_SRCALPHASAT", + VAL( Tr2RenderContextEnum::BM_SRCALPHASAT ), + "Blend factor is (f, f, f, 1); f = min(As, 1-Ad)." }, + { "TRIBLEND_BOTHINVSRCALPHA", + VAL( Tr2RenderContextEnum::BM_BOTHINVSRCALPHA ), + "Source blend factor is (1-As, 1-As, 1-As, 1-As), and destination blend factor is " + "(As, As, As, As); the destination blend selection is overridden. This blend mode is " + "supported only for the D3DRS_SRCBLEND render state." }, + { 0 } }; #if DEPRECATED_ENABLED -const Be::VarChooser TriTextureAddress [] = -{ - { - "TRITADDRESS_WRAP", - VAL(Tr2RenderContextEnum::TA_WRAP), - "Tile the texture at every integer junction. For example, " - "for u values between 0 and 3, the texture is repeated three " - "times; no mirroring is performed. " - }, - { - "TRITADDRESS_MIRROR", - VAL( Tr2RenderContextEnum::TA_MIRROR), - "Similar to D3DTADDRESS_WRAP, except that the texture is flipped at " - "every integer junction. For u values between 0 and 1, for example, the " - "texture is addressed normally; between 1 and 2, the texture is flipped " - "(mirrored); between 2 and 3, the texture is normal again, and so on. " - }, - { - "TRITADDRESS_CLAMP", - VAL( Tr2RenderContextEnum::TA_CLAMP ), - "Texture coordinates outside the range [0.0, 1.0] are set to " - "the texture color at 0.0 or 1.0, respectively. " - }, - { - "TRITADDRESS_BORDER", - VAL( Tr2RenderContextEnum::TA_BORDER ), - "Texture coordinates outside the range [0.0, 1.0] are set " - "to the border color." - }, - { - "TRITADDRESS_MIRRORONCE", - VAL( Tr2RenderContextEnum::TA_MIRROR_ONCE ), - "Similar to D3DTADDRESS_MIRROR and D3DTADDRESS_CLAMP. Takes the " - "absolute value of the texture coordinate (thus, mirroring around 0), and " - "then clamps to the maximum value. The most common usage is for volume textures, " - "where support for the full D3DTADDRESS_MIRRORONCE texture-addressing mode is not " - "necessary, but the data is symmetric around the one axis. " - }, - {0} +const Be::VarChooser TriTextureAddress[] = { + { "TRITADDRESS_WRAP", + VAL( Tr2RenderContextEnum::TA_WRAP ), + "Tile the texture at every integer junction. For example, " + "for u values between 0 and 3, the texture is repeated three " + "times; no mirroring is performed. " }, + { "TRITADDRESS_MIRROR", + VAL( Tr2RenderContextEnum::TA_MIRROR ), + "Similar to D3DTADDRESS_WRAP, except that the texture is flipped at " + "every integer junction. For u values between 0 and 1, for example, the " + "texture is addressed normally; between 1 and 2, the texture is flipped " + "(mirrored); between 2 and 3, the texture is normal again, and so on. " }, + { "TRITADDRESS_CLAMP", + VAL( Tr2RenderContextEnum::TA_CLAMP ), + "Texture coordinates outside the range [0.0, 1.0] are set to " + "the texture color at 0.0 or 1.0, respectively. " }, + { "TRITADDRESS_BORDER", + VAL( Tr2RenderContextEnum::TA_BORDER ), + "Texture coordinates outside the range [0.0, 1.0] are set " + "to the border color." }, + { "TRITADDRESS_MIRRORONCE", + VAL( Tr2RenderContextEnum::TA_MIRROR_ONCE ), + "Similar to D3DTADDRESS_MIRROR and D3DTADDRESS_CLAMP. Takes the " + "absolute value of the texture coordinate (thus, mirroring around 0), and " + "then clamps to the maximum value. The most common usage is for volume textures, " + "where support for the full D3DTADDRESS_MIRRORONCE texture-addressing mode is not " + "necessary, but the data is symmetric around the one axis. " }, + { 0 } }; #endif -const Be::VarChooser TriD3DRenderState[] = -{ - KV_RC( +const Be::VarChooser TriD3DRenderState[] = { + KV_RC( RS_ZENABLE, "Depth-buffering state as one member of the ZBUFFERTYPE enumerated type.\n" "Set this state to ZB_TRUE to enable z-buffering, ZB_USEW to enable\n" "w-buffering, or ZB_FALSE to disable depth buffering. The default value\n" "for this render state is ZB_TRUE if a depth stencil was created along\n" "with the swap chain by setting the EnableAutoDepthStencil member of the\n" - "PRESENT_PARAMETERS structure to TRUE, and ZB_FALSE otherwise." - ), - KV_RC( - RS_FILLMODE, + "PRESENT_PARAMETERS structure to TRUE, and ZB_FALSE otherwise." ), + KV_RC( + RS_FILLMODE, "One or more members of the FILLMODE enumerated type.\n" - "The default value is FILL_SOLID." - ), + "The default value is FILL_SOLID." ), KV_RC( RS_ZWRITEENABLE, "" ), KV_RC( RS_SRCBLEND, "" ), KV_RC( RS_DESTBLEND, "" ), @@ -455,5 +343,5 @@ const Be::VarChooser TriD3DRenderState[] = KV_RC( RS_DESTBLENDALPHA, "" ), KV_RC( RS_BLENDOPALPHA, "" ), - {0} + { 0 } }; diff --git a/trinity/TriConstants.h b/trinity/TriConstants.h index f54c799ef..2dbe0e40a 100644 --- a/trinity/TriConstants.h +++ b/trinity/TriConstants.h @@ -3,9 +3,9 @@ #ifndef _TRICONSTANTS_H_ #define _TRICONSTANTS_H_ -const char* KeyFromVal(const Be::VarChooser* i, long val); +const char* KeyFromVal( const Be::VarChooser* i, long val ); #if BLUE_WITH_PYTHON -void AddTriConstants(PyObject *d); +void AddTriConstants( PyObject* d ); #endif extern const Be::VarChooser TriTextureChooser[]; @@ -19,4 +19,3 @@ extern const Be::VarChooser TriTextureAddress[]; extern const Be::VarChooser TriD3DRenderState[]; #endif - diff --git a/trinity/TriDebugResourceHelper.cpp b/trinity/TriDebugResourceHelper.cpp index 2b0d2fcc7..4405bc779 100644 --- a/trinity/TriDebugResourceHelper.cpp +++ b/trinity/TriDebugResourceHelper.cpp @@ -9,8 +9,8 @@ static const char* DEBUG_LINE_EFFECT_PATH = "res:/Graphics/Effect/Managed/Utilit TriDebugResourceHelper g_debugResourceHelper; -TriDebugResourceHelper::TriDebugResourceHelper() - :m_vertexPosColorDecl( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), +TriDebugResourceHelper::TriDebugResourceHelper() : + m_vertexPosColorDecl( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ), m_vertexPosDecl( Tr2EffectStateManager::UNINITIALIZED_DECLARATION ) { } @@ -31,14 +31,14 @@ bool TriDebugResourceHelper::OnPrepareResources() { Tr2VertexDefinition vd; vd.Add( vd.FLOAT32_3, vd.POSITION ); - vd.Add( vd.UBYTE_4_NORM , vd.COLOR ); + vd.Add( vd.UBYTE_4_NORM, vd.COLOR ); m_vertexPosColorDecl = Tr2EffectStateManager::GetVertexDeclarationHandle( vd ); } return true; } -void TriDebugResourceHelper::ReleaseResources(TriStorage s) +void TriDebugResourceHelper::ReleaseResources( TriStorage s ) { m_vertexPosDecl = 0; m_vertexPosColorDecl = 0; diff --git a/trinity/TriDebugResourceHelper.h b/trinity/TriDebugResourceHelper.h index 62c2b3ec9..780d94e41 100644 --- a/trinity/TriDebugResourceHelper.h +++ b/trinity/TriDebugResourceHelper.h @@ -9,8 +9,7 @@ BLUE_DECLARE( Tr2Effect ); -class TriDebugResourceHelper : - public Tr2DeviceResource +class TriDebugResourceHelper : public Tr2DeviceResource { public: TriDebugResourceHelper(); @@ -20,11 +19,16 @@ class TriDebugResourceHelper : // ITriDeviceResource ////////////////////////////////////////////////////////////////////////////////////////////// void ReleaseResources( TriStorage s ); + private: bool OnPrepareResources(); + public: #ifdef TRINITYDEV - void GetDescription( std::string& desc ) { desc = "TriDebugResourceHelper"; } + void GetDescription( std::string& desc ) + { + desc = "TriDebugResourceHelper"; + } #endif Tr2Effect* GetEffect(); diff --git a/trinity/TriDebugTextRenderer.cpp b/trinity/TriDebugTextRenderer.cpp index 554b11160..e629d037c 100644 --- a/trinity/TriDebugTextRenderer.cpp +++ b/trinity/TriDebugTextRenderer.cpp @@ -15,7 +15,8 @@ CCP_STATS_DECLARE( triDebugTextRenderersAlive, "Trinity/TriDebugTextRenderer", f TriDebugTextRenderer::TriDebugTextRenderer() : m_entries( "TriDebugTextRenderer/m_entries" ) #ifdef _WIN32 - , m_bitmapData( nullptr ), + , + m_bitmapData( nullptr ), m_bitmapWidth( 0 ), m_bitmapHeight( 0 ), m_bitmap( nullptr ) @@ -25,8 +26,8 @@ TriDebugTextRenderer::TriDebugTextRenderer() : const char* font = PDM::IsWine() ? "Menlo" : "Lucida Console"; const char* fallbackFont = "Courier New"; for( int i = 0; i < 3; ++i ) - { - static int heights[3] = { -9, -12, -16 }; + { + static int heights[3] = { -9, -12, -16 }; m_dcFonts[i] = CreateFont( heights[i], 0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, NONANTIALIASED_QUALITY, 0, font ); if( m_dcFonts[i] == NULL ) { @@ -37,7 +38,7 @@ TriDebugTextRenderer::TriDebugTextRenderer() : CCP_LOGERR( "Could not create debug text renderer font: %s or %s, %d", font, fallbackFont, heights[i] ); } } - } + } HDC screenDC = GetDC( NULL ); m_dc = CreateCompatibleDC( screenDC ); ReleaseDC( NULL, screenDC ); @@ -47,16 +48,16 @@ TriDebugTextRenderer::TriDebugTextRenderer() : TriDebugTextRenderer::~TriDebugTextRenderer() { - CCP_STATS_DEC( triDebugTextRenderersAlive ); + CCP_STATS_DEC( triDebugTextRenderersAlive ); #ifdef _WIN32 - for( int i = 0; i < 3; ++i ) - { - DeleteObject( m_dcFonts[i] ); - } + for( int i = 0; i < 3; ++i ) + { + DeleteObject( m_dcFonts[i] ); + } - DeleteDC( m_dc ); - DeleteObject( m_bitmap ); + DeleteDC( m_dc ); + DeleteObject( m_bitmap ); #endif } @@ -66,7 +67,7 @@ void TriDebugTextRenderer::Vprintf( TriDebugFont font, const Tr2Rect& rect, uint static char buffer[BUFFER_SIZE]; vsnprintf_s( buffer, BUFFER_SIZE, _TRUNCATE, msg, args ); - + TextEntry e; e.m_font = font; e.m_rect = rect; @@ -88,10 +89,10 @@ void TriDebugTextRenderer::VprintfImmediate( Tr2RenderContext& renderContext, Tr void TriDebugTextRenderer::Printf( TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, ... ) { - va_list args; - va_start( args, msg ); + va_list args; + va_start( args, msg ); - Vprintf( font, rect, format, color, msg, args ); + Vprintf( font, rect, format, color, msg, args ); va_end( args ); } @@ -107,19 +108,19 @@ void TriDebugTextRenderer::PrintfImmediate( Tr2RenderContext& renderContext, Tri void TriDebugTextRenderer::Render( Tr2RenderContext& renderContext ) { - for( TrackableStdList::iterator it = m_entries.begin(); it != m_entries.end(); ++it ) - { - DrawText( renderContext, it->m_font, it->m_text, it->m_rect, it->m_format, it->m_color ); + for( TrackableStdList::iterator it = m_entries.begin(); it != m_entries.end(); ++it ) + { + DrawText( renderContext, it->m_font, it->m_text, it->m_rect, it->m_format, it->m_color ); } } void TriDebugTextRenderer::Clear() { - for( TrackableStdList::iterator it = m_entries.begin(); it != m_entries.end(); ++it ) - { - CCP_FREE( (void*)it->m_text ); - } - m_entries.clear(); + for( TrackableStdList::iterator it = m_entries.begin(); it != m_entries.end(); ++it ) + { + CCP_FREE( (void*)it->m_text ); + } + m_entries.clear(); } void TriDebugTextRenderer::ReleaseResources( TriStorage s ) @@ -129,12 +130,12 @@ void TriDebugTextRenderer::ReleaseResources( TriStorage s ) bool TriDebugTextRenderer::OnPrepareResources() { - return true; + return true; } // -------------------------------------------------------------------------------------- // Description: -// Draws text into current render target. +// Draws text into current render target. // Arguments: // font - Font to use // string - NULL-terminated string to render @@ -142,10 +143,10 @@ bool TriDebugTextRenderer::OnPrepareResources() // format - Bitfield of TRI_DFS_... constants // color - Color to use for rendering (alpha component is ignored) // -------------------------------------------------------------------------------------- -void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFont font, const char* string, const Tr2Rect& rect, uint32_t format, const Vector4& vecColor) +void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFont font, const char* string, const Tr2Rect& rect, uint32_t format, const Vector4& vecColor ) { uint32_t color = Color( vecColor.x, vecColor.y, vecColor.z, vecColor.w ); - + if( !Tr2Renderer::IsResourceCreationAllowed() ) { return; @@ -156,7 +157,7 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo { return; } - + // Measure actual text size HGDIOBJ oldFont = SelectObject( m_dc, m_dcFonts[font] ); ON_BLOCK_EXIT( [&] { SelectObject( m_dc, oldFont ); } ); @@ -182,15 +183,15 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo BITMAPINFO info; memset( &info, 0, sizeof( info ) ); info.bmiHeader.biSize = sizeof( info ); - info.bmiHeader.biWidth = m_bitmapWidth; - info.bmiHeader.biHeight = -int( m_bitmapHeight ); - info.bmiHeader.biPlanes = 1; - info.bmiHeader.biBitCount = 32; - info.bmiHeader.biCompression = BI_RGB; - info.bmiHeader.biSizeImage = 0; - info.bmiHeader.biXPelsPerMeter = 0; - info.bmiHeader.biYPelsPerMeter = 0; - info.bmiHeader.biClrUsed = 0; + info.bmiHeader.biWidth = m_bitmapWidth; + info.bmiHeader.biHeight = -int( m_bitmapHeight ); + info.bmiHeader.biPlanes = 1; + info.bmiHeader.biBitCount = 32; + info.bmiHeader.biCompression = BI_RGB; + info.bmiHeader.biSizeImage = 0; + info.bmiHeader.biXPelsPerMeter = 0; + info.bmiHeader.biYPelsPerMeter = 0; + info.bmiHeader.biClrUsed = 0; info.bmiHeader.biClrImportant = 0; m_bitmap = CreateDIBSection( screenDC, &info, DIB_RGB_COLORS, (void**)&m_bitmapData, nullptr, 0 ); @@ -211,7 +212,7 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo // Render into offscreen GDI bitmap HGDIOBJ bkBitmap = SelectObject( m_dc, m_bitmap ); - FillRect( m_dc, &size, (HBRUSH) GetStockObject( BLACK_BRUSH ) ); + FillRect( m_dc, &size, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); SetTextColor( m_dc, RGB( 255, 255, 255 ) ); SetBkMode( m_dc, TRANSPARENT ); ::DrawText( m_dc, string, -1, &size, format ); @@ -220,13 +221,13 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo // Flush GDI commands before accessing bitmap data GdiFlush(); - if( !m_texture.IsValid() || - m_texture.GetWidth() < m_bitmapWidth || + if( !m_texture.IsValid() || + m_texture.GetWidth() < m_bitmapWidth || m_texture.GetHeight() < m_bitmapHeight ) { USE_MAIN_THREAD_RENDER_CONTEXT(); - CR_RETURN( m_texture.Create( - Tr2BitmapDimensions( m_bitmapWidth, m_bitmapHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), + CR_RETURN( m_texture.Create( + Tr2BitmapDimensions( m_bitmapWidth, m_bitmapHeight, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, renderContext ) ); @@ -279,8 +280,8 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo size.right = rowWidth; } - if( !m_texture.IsValid() || - m_texture.GetWidth() < unsigned( size.right ) || + if( !m_texture.IsValid() || + m_texture.GetWidth() < unsigned( size.right ) || m_texture.GetHeight() < unsigned( size.bottom ) ) { USE_MAIN_THREAD_RENDER_CONTEXT(); @@ -339,7 +340,7 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo } else if( format & TRI_DFS_CENTER ) { - x = ( rect.right + rect.left - size.right ) / 2; + x = ( rect.right + rect.left - size.right ) / 2; } else { @@ -351,7 +352,7 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo } else if( format & TRI_DFS_VCENTER ) { - y = ( rect.bottom + rect.top - size.bottom ) / 2; + y = ( rect.bottom + rect.top - size.bottom ) / 2; } else { @@ -365,4 +366,3 @@ void TriDebugTextRenderer::DrawText( Tr2RenderContext& renderContext, TriDebugFo Tr2Renderer::DrawTexture( renderContext, m_texture, Vector2( 0.f, 0.f ), Vector2( float( size.right ) / m_texture.GetWidth(), float( size.bottom ) / m_texture.GetHeight() ) ); renderContext.m_esm.PopViewport(); } - diff --git a/trinity/TriDebugTextRenderer.h b/trinity/TriDebugTextRenderer.h index 9bf55e49b..cbdaf712b 100644 --- a/trinity/TriDebugTextRenderer.h +++ b/trinity/TriDebugTextRenderer.h @@ -7,33 +7,35 @@ #include "Tr2DeviceResource.h" #include "include/Rect.h" #ifdef BLUE_USE_LOCAL_ITr2DebugRenderer2 - // This is only needed for py2 as the file now belongs in blue. - // Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. - // The file version in the older blue versions had diverged from this one is incompatible. - #include "Include/ITr2DebugRenderer2.h" +// This is only needed for py2 as the file now belongs in blue. +// Unfortunatly the blue py2 branch cannot be updated at present due to security vulnerability work. +// The file version in the older blue versions had diverged from this one is incompatible. +#include "Include/ITr2DebugRenderer2.h" #else - #include +#include #endif class TriDebugTextRenderer : public Tr2DeviceResource { public: - TriDebugTextRenderer(); - ~TriDebugTextRenderer(); + TriDebugTextRenderer(); + ~TriDebugTextRenderer(); - void Printf( TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, ... ); + void Printf( TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, ... ); void PrintfImmediate( Tr2RenderContext& renderContext, TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, ... ); void Vprintf( TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, va_list args ); void VprintfImmediate( Tr2RenderContext& renderContext, TriDebugFont font, const Tr2Rect& rect, uint32_t format, const Vector4& color, const char* msg, va_list args ); - void Render( Tr2RenderContext& renderContext ); - void Clear(); + void Render( Tr2RenderContext& renderContext ); + void Clear(); + + ////////////////////////////////////////////////////////////////////////////////////// + // ITriDeviceResource + void ReleaseResources( TriStorage s ); - ////////////////////////////////////////////////////////////////////////////////////// - // ITriDeviceResource - void ReleaseResources( TriStorage s ); private: bool OnPrepareResources(); + public: #ifdef TRINITYDEV void GetDescription( std::string& desc ) @@ -43,22 +45,22 @@ class TriDebugTextRenderer : public Tr2DeviceResource #endif private: - void DrawText( Tr2RenderContext& renderContext, TriDebugFont font, const char* string, const Tr2Rect& rect, uint32_t format, const Vector4& color ); + void DrawText( Tr2RenderContext& renderContext, TriDebugFont font, const char* string, const Tr2Rect& rect, uint32_t format, const Vector4& color ); private: - struct TextEntry - { - TriDebugFont m_font; + struct TextEntry + { + TriDebugFont m_font; Tr2Rect m_rect; - uint32_t m_format; - Vector4 m_color; - const char* m_text; - }; + uint32_t m_format; + Vector4 m_color; + const char* m_text; + }; - TrackableStdList m_entries; + TrackableStdList m_entries; #ifdef _WIN32 - // Memory DC for GDI rendering + // Memory DC for GDI rendering HDC m_dc; // Offscreen GDI bitmap HBITMAP m_bitmap; @@ -66,11 +68,11 @@ class TriDebugTextRenderer : public Tr2DeviceResource uint8_t* m_bitmapData; // Fonts (correspond to TriDebugFont) HFONT m_dcFonts[3]; - // Current m_bitmap width + // Current m_bitmap width unsigned m_bitmapWidth; // Current m_bitmap height unsigned m_bitmapHeight; -#endif +#endif // Temporary texture Tr2TextureAL m_texture; }; diff --git a/trinity/TriDebugTextRendererBitmaps.h b/trinity/TriDebugTextRendererBitmaps.h index 2334ad418..98600cc06 100644 --- a/trinity/TriDebugTextRendererBitmaps.h +++ b/trinity/TriDebugTextRendererBitmaps.h @@ -1,2407 +1,30628 @@ // Copyright © 2013 CCP ehf. -static const int s_charOffsets[3][128] = { +static const int s_charOffsets[3][128] = { { - 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, - 16, 16, 18, 20, 20, 22, 24, 26, 28, 30, - 32, 34, 36, 38, 40, 42, 44, 46, 48, 48, - 48, 48, 48, 53, 58, 63, 68, 73, 73, 73, - 78, 83, 88, 93, 98, 103, 108, 113, 118, 123, - 128, 133, 138, 143, 148, 153, 158, 163, 168, 173, - 178, 183, 188, 193, 198, 203, 208, 213, 218, 223, - 228, 233, 238, 243, 248, 253, 258, 263, 268, 273, - 278, 283, 288, 293, 298, 303, 308, 313, 318, 323, - 328, 333, 338, 343, 348, 353, 358, 363, 368, 373, - 378, 383, 388, 393, 398, 403, 408, 413, 418, 423, - 428, 433, 438, 443, 448, 453, 458, 463, 468, 473, - 478, 483, 488, 493, 498, 503, 508, 513, + 0, + 0, + 2, + 4, + 6, + 8, + 10, + 12, + 14, + 16, + 16, + 16, + 18, + 20, + 20, + 22, + 24, + 26, + 28, + 30, + 32, + 34, + 36, + 38, + 40, + 42, + 44, + 46, + 48, + 48, + 48, + 48, + 48, + 53, + 58, + 63, + 68, + 73, + 73, + 73, + 78, + 83, + 88, + 93, + 98, + 103, + 108, + 113, + 118, + 123, + 128, + 133, + 138, + 143, + 148, + 153, + 158, + 163, + 168, + 173, + 178, + 183, + 188, + 193, + 198, + 203, + 208, + 213, + 218, + 223, + 228, + 233, + 238, + 243, + 248, + 253, + 258, + 263, + 268, + 273, + 278, + 283, + 288, + 293, + 298, + 303, + 308, + 313, + 318, + 323, + 328, + 333, + 338, + 343, + 348, + 353, + 358, + 363, + 368, + 373, + 378, + 383, + 388, + 393, + 398, + 403, + 408, + 413, + 418, + 423, + 428, + 433, + 438, + 443, + 448, + 453, + 458, + 463, + 468, + 473, + 478, + 483, + 488, + 493, + 498, + 503, + 508, + 513, }, { - 0, 0, 3, 6, 9, 12, 15, 18, 21, 24, - 24, 24, 27, 30, 30, 33, 36, 39, 42, 45, - 48, 51, 54, 57, 60, 63, 66, 69, 72, 72, - 72, 72, 72, 79, 86, 93, 100, 107, 107, 107, - 114, 121, 128, 135, 142, 149, 156, 163, 170, 177, - 184, 191, 198, 205, 212, 219, 226, 233, 240, 247, - 254, 261, 268, 275, 282, 289, 296, 303, 310, 317, - 324, 331, 338, 345, 352, 359, 366, 373, 380, 387, - 394, 401, 408, 415, 422, 429, 436, 443, 450, 457, - 464, 471, 478, 485, 492, 499, 506, 513, 520, 527, - 534, 541, 548, 555, 562, 569, 576, 583, 590, 597, - 604, 611, 618, 625, 632, 639, 646, 653, 660, 667, - 674, 681, 688, 695, 702, 709, 716, 723, + 0, + 0, + 3, + 6, + 9, + 12, + 15, + 18, + 21, + 24, + 24, + 24, + 27, + 30, + 30, + 33, + 36, + 39, + 42, + 45, + 48, + 51, + 54, + 57, + 60, + 63, + 66, + 69, + 72, + 72, + 72, + 72, + 72, + 79, + 86, + 93, + 100, + 107, + 107, + 107, + 114, + 121, + 128, + 135, + 142, + 149, + 156, + 163, + 170, + 177, + 184, + 191, + 198, + 205, + 212, + 219, + 226, + 233, + 240, + 247, + 254, + 261, + 268, + 275, + 282, + 289, + 296, + 303, + 310, + 317, + 324, + 331, + 338, + 345, + 352, + 359, + 366, + 373, + 380, + 387, + 394, + 401, + 408, + 415, + 422, + 429, + 436, + 443, + 450, + 457, + 464, + 471, + 478, + 485, + 492, + 499, + 506, + 513, + 520, + 527, + 534, + 541, + 548, + 555, + 562, + 569, + 576, + 583, + 590, + 597, + 604, + 611, + 618, + 625, + 632, + 639, + 646, + 653, + 660, + 667, + 674, + 681, + 688, + 695, + 702, + 709, + 716, + 723, }, { - 0, 0, 4, 8, 12, 16, 20, 24, 28, 32, - 32, 32, 36, 40, 40, 44, 48, 52, 56, 60, - 64, 68, 72, 76, 80, 84, 88, 92, 96, 96, - 96, 96, 96, 106, 116, 126, 136, 146, 146, 146, - 156, 166, 176, 186, 196, 206, 216, 226, 236, 246, - 256, 266, 276, 286, 296, 306, 316, 326, 336, 346, - 356, 366, 376, 386, 396, 406, 416, 426, 436, 446, - 456, 466, 476, 486, 496, 506, 516, 526, 536, 546, - 556, 566, 576, 586, 596, 606, 616, 626, 636, 646, - 656, 666, 676, 686, 696, 706, 716, 726, 736, 746, - 756, 766, 776, 786, 796, 806, 816, 826, 836, 846, - 856, 866, 876, 886, 896, 906, 916, 926, 936, 946, - 956, 966, 976, 986, 996, 1006, 1016, 1026, + 0, + 0, + 4, + 8, + 12, + 16, + 20, + 24, + 28, + 32, + 32, + 32, + 36, + 40, + 40, + 44, + 48, + 52, + 56, + 60, + 64, + 68, + 72, + 76, + 80, + 84, + 88, + 92, + 96, + 96, + 96, + 96, + 96, + 106, + 116, + 126, + 136, + 146, + 146, + 146, + 156, + 166, + 176, + 186, + 196, + 206, + 216, + 226, + 236, + 246, + 256, + 266, + 276, + 286, + 296, + 306, + 316, + 326, + 336, + 346, + 356, + 366, + 376, + 386, + 396, + 406, + 416, + 426, + 436, + 446, + 456, + 466, + 476, + 486, + 496, + 506, + 516, + 526, + 536, + 546, + 556, + 566, + 576, + 586, + 596, + 606, + 616, + 626, + 636, + 646, + 656, + 666, + 676, + 686, + 696, + 706, + 716, + 726, + 736, + 746, + 756, + 766, + 776, + 786, + 796, + 806, + 816, + 826, + 836, + 846, + 856, + 866, + 876, + 886, + 896, + 906, + 916, + 926, + 936, + 946, + 956, + 966, + 976, + 986, + 996, + 1006, + 1016, + 1026, } }; static const int s_charWidths[3][128] = { { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 0, - 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, - 0, 0, 5, 5, 5, 5, 5, 0, 0, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 2, + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 0, + 0, + 2, + 2, + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 0, + 0, + 0, + 0, + 5, + 5, + 5, + 5, + 5, + 0, + 0, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 5, + 2, }, { - 0, 3, 3, 3, 3, 3, 3, 3, 3, 0, - 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, - 0, 0, 7, 7, 7, 7, 7, 0, 0, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 3, + 0, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 0, + 0, + 3, + 3, + 0, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 3, + 0, + 0, + 0, + 0, + 7, + 7, + 7, + 7, + 7, + 0, + 0, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 7, + 3, }, { - 0, 4, 4, 4, 4, 4, 4, 4, 4, 0, - 0, 4, 4, 0, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, - 0, 0, 10, 10, 10, 10, 10, 0, 0, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 4, + 0, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 0, + 0, + 4, + 4, + 0, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 4, + 0, + 0, + 0, + 0, + 10, + 10, + 10, + 10, + 10, + 0, + 0, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 10, + 4, } - }; +}; static const int s_charHeight[3] = { 9, 12, 16 }; static const uint8_t s_charPixelsSmall[] = { - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - }; + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, +}; static const uint8_t s_charPixelsMedium[] = { - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, - }; + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, +}; static const uint8_t s_charPixelsLarge[] = { - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, - 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0xfe, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xfe, 0xfe, 0xfe, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - }; + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0xfe, + 0xfe, + 0xfe, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, +}; static const uint8_t* s_charPixels[3] = { s_charPixelsSmall, s_charPixelsMedium, s_charPixelsLarge }; static const size_t s_charPixelsArraySizes[3] = { sizeof( s_charPixelsSmall ), sizeof( s_charPixelsMedium ), sizeof( s_charPixelsLarge ) }; diff --git a/trinity/TriDevice.cpp b/trinity/TriDevice.cpp index b26b278c8..76e3c3efe 100644 --- a/trinity/TriDevice.cpp +++ b/trinity/TriDevice.cpp @@ -11,7 +11,7 @@ #include "Curves/TriCurveSet.h" #include "Include/TriMath.h" #include "Tr2SyncToGpu.h" -#include "TriSettingsRegistrar.h" +#include "TriSettingsRegistrar.h" #include "Tr2GpuResourcePool.h" #include #include "ContinueOnMainThread.h" @@ -22,24 +22,24 @@ #if TBB_ENABLED - #include +#include - size_t g_currentThreadCount = tbb::info::default_concurrency(); - tbb::global_control* g_threadCountControl = new tbb::global_control( tbb::global_control::max_allowed_parallelism, g_currentThreadCount ); +size_t g_currentThreadCount = tbb::info::default_concurrency(); +tbb::global_control* g_threadCountControl = new tbb::global_control( tbb::global_control::max_allowed_parallelism, g_currentThreadCount ); - void SetThreadCount( size_t newThreadCount ) +void SetThreadCount( size_t newThreadCount ) +{ + if( g_currentThreadCount != newThreadCount ) { - if( g_currentThreadCount != newThreadCount ) - { - CCP_LOGNOTICE( "Thread count changed from %zu to %zu.", g_currentThreadCount, newThreadCount ); - g_currentThreadCount = newThreadCount; - delete g_threadCountControl; - g_threadCountControl = new tbb::global_control( tbb::global_control::max_allowed_parallelism, newThreadCount ); - } + CCP_LOGNOTICE( "Thread count changed from %zu to %zu.", g_currentThreadCount, newThreadCount ); + g_currentThreadCount = newThreadCount; + delete g_threadCountControl; + g_threadCountControl = new tbb::global_control( tbb::global_control::max_allowed_parallelism, newThreadCount ); } +} -#endif +#endif using namespace Tr2RenderContextEnum; @@ -47,62 +47,62 @@ using namespace Tr2RenderContextEnum; extern std::vector g_D3DCreatedHeaps; #endif -#if defined(__ANDROID__) +#if defined( __ANDROID__ ) extern int g_windowResized; #endif namespace { - HRESULT CreateDeviceInt( - uint32_t Adapter, - Tr2WindowHandle hFocusWindow, - const Tr2PresentParametersAL& pPresentationParameters ) - { - USE_MAIN_THREAD_RENDER_CONTEXT(); - +HRESULT CreateDeviceInt( + uint32_t Adapter, + Tr2WindowHandle hFocusWindow, + const Tr2PresentParametersAL& pPresentationParameters ) +{ + USE_MAIN_THREAD_RENDER_CONTEXT(); + #ifdef _WIN32 - HANDLE heapsBefore[256]; - const uint32_t countBefore = ::GetProcessHeaps( 256, heapsBefore ); + HANDLE heapsBefore[256]; + const uint32_t countBefore = ::GetProcessHeaps( 256, heapsBefore ); #endif - - const HRESULT hr = renderContext.CreateDevice( Adapter, hFocusWindow, pPresentationParameters ); -#if defined(__ANDROID__) - while( !g_windowResized ) - { - } + const HRESULT hr = renderContext.CreateDevice( Adapter, hFocusWindow, pPresentationParameters ); + +#if defined( __ANDROID__ ) + while( !g_windowResized ) + { + } #endif - + #ifdef _WIN32 - HANDLE heapsAfter[256]; - const uint32_t countAfter = ::GetProcessHeaps( 256, heapsAfter ); + HANDLE heapsAfter[256]; + const uint32_t countAfter = ::GetProcessHeaps( 256, heapsAfter ); - if( countAfter > countBefore ) - { - const int count = countAfter - countBefore; - CCP_LOG( "Direct3D::CreateDevice created %d heaps", count ); + if( countAfter > countBefore ) + { + const int count = countAfter - countBefore; + CCP_LOG( "Direct3D::CreateDevice created %d heaps", count ); - for( uint32_t i = countBefore; i != countAfter; ++i ) - { - g_D3DCreatedHeaps.push_back( heapsAfter[i] ); - } + for( uint32_t i = countBefore; i != countAfter; ++i ) + { + g_D3DCreatedHeaps.push_back( heapsAfter[i] ); } + } #endif - Tr2Renderer::InitializeSystemShaderOptions(); + Tr2Renderer::InitializeSystemShaderOptions(); - return hr; - } + return hr; +} - BlueStructureDefinition Tr2UpscalingTechniqueInfoDefinition[] = { - { "technique", Be::UINT32_1, 0, Tr2UpsclaingAL_UpscalingTechnique_Chooser }, - { "supportedSettings", Be::UINT32_1, 4, Tr2UpsclaingAL_UpscalingSetting_Chooser }, - { "framegeneration", Be::BOOL8_1, 8 }, - { 0 } - }; +BlueStructureDefinition Tr2UpscalingTechniqueInfoDefinition[] = { + { "technique", Be::UINT32_1, 0, Tr2UpsclaingAL_UpscalingTechnique_Chooser }, + { "supportedSettings", Be::UINT32_1, 4, Tr2UpsclaingAL_UpscalingSetting_Chooser }, + { "framegeneration", Be::BOOL8_1, 8 }, + { 0 } +}; - const Tr2UpscalingTechniqueInfo s_defaultUpscalingTechniqueInfo = { Tr2UpscalingAL::Technique::NONE, 0, false }; +const Tr2UpscalingTechniqueInfo s_defaultUpscalingTechniqueInfo = { Tr2UpscalingAL::Technique::NONE, 0, false }; } @@ -110,16 +110,16 @@ namespace CCP_STATS_DECLARE( deviceOnTick, "Trinity/device/OnTick", true, CST_TIME, "Time spent in TriDevice::OnTick" ); CCP_STATS_DECLARE( fpsRaw, "FPSRaw", false, CST_COUNTER_LOW, "Raw frames per second" ); -CCP_STATS_DECLARE( fps, "FPS", false, CST_COUNTER_LOW, "Frames per second"); -CCP_STATS_DECLARE( smoothedFrameTime, "Trinity/SmoothedFrameTime", false, CST_TIME, "Frame time smoothed over a number of frames"); +CCP_STATS_DECLARE( fps, "FPS", false, CST_COUNTER_LOW, "Frames per second" ); +CCP_STATS_DECLARE( smoothedFrameTime, "Trinity/SmoothedFrameTime", false, CST_TIME, "Frame time smoothed over a number of frames" ); CCP_STATS_DECLARE( frameTime, "Trinity/FrameTime", false, CST_TIME, "Frame time" ); CCP_STATS_DECLARE( frameTimeMin, "Trinity/FrameTime/Min", false, CST_TIME, "Frame time (min)" ); CCP_STATS_DECLARE( frameTimeMax, "Trinity/FrameTime/Max", false, CST_TIME, "Frame time (max)" ); -CCP_STATS_DECLARE( frameTimeAbove100ms, "Trinity/FrameTimeAbove100ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 100ms (but below 200)"); -CCP_STATS_DECLARE( frameTimeAbove200ms, "Trinity/FrameTimeAbove200ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 200ms (but below 300)"); -CCP_STATS_DECLARE( frameTimeAbove300ms, "Trinity/FrameTimeAbove300ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 300ms (but below 400)"); -CCP_STATS_DECLARE( frameTimeAbove400ms, "Trinity/FrameTimeAbove400ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 400ms (but below 500)"); -CCP_STATS_DECLARE( frameTimeAbove500ms, "Trinity/FrameTimeAbove500ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 500ms"); +CCP_STATS_DECLARE( frameTimeAbove100ms, "Trinity/FrameTimeAbove100ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 100ms (but below 200)" ); +CCP_STATS_DECLARE( frameTimeAbove200ms, "Trinity/FrameTimeAbove200ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 200ms (but below 300)" ); +CCP_STATS_DECLARE( frameTimeAbove300ms, "Trinity/FrameTimeAbove300ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 300ms (but below 400)" ); +CCP_STATS_DECLARE( frameTimeAbove400ms, "Trinity/FrameTimeAbove400ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 400ms (but below 500)" ); +CCP_STATS_DECLARE( frameTimeAbove500ms, "Trinity/FrameTimeAbove500ms", false, CST_COUNTER_LOW, "Number of frames where the frame time was above 500ms" ); CCP_STATS_DECLARE( presentTime, "Trinity/PresentTime", true, CST_TIME, "Time spent in Present call" ); CCP_STATS_DECLARE( activeFrameTime, "Trinity/ActiveFrameTime", true, CST_TIME, "Frame time not counting persent or throttle time" ); CCP_STATS_DECLARE( throttleTime, "Trinity/ThrottleTime", true, CST_TIME, "Time spent throttling" ); @@ -131,18 +131,18 @@ bool g_newUpscalersEnabled = true; TRI_REGISTER_SETTING( "newUpscalersEnabled", g_newUpscalersEnabled ); extern uint32_t g_streamlineAppID; -TRI_REGISTER_SETTING( "streamlineAppID", g_streamlineAppID ); +TRI_REGISTER_SETTING( "streamlineAppID", g_streamlineAppID ); bool g_raytracingEnabled = true; TRI_REGISTER_SETTING( "raytracingEnabled", g_raytracingEnabled ); - // NOTE: This is a global pointer to a ROT object, initialized by it +// NOTE: This is a global pointer to a ROT object, initialized by it // We never want this rot object to die, so we hold a reference here. BlueBasicPtr gTriDev; unsigned long long g_currentFrameCounter = 0; -TriDevice::ResourceSet TriDevice::s_resourcesToBeRemoved; +TriDevice::ResourceSet TriDevice::s_resourcesToBeRemoved; bool TriDevice::s_iteratingForRelease = false; const char* TRINITY = "Trinity"; //cookie for the tick @@ -174,21 +174,21 @@ TriDevice::TriDevice( IRoot* lockobj ) : m_upscalingWithFrameGeneration( false ), m_minimumModelLOD( 0 ) -{ - +{ + m_supportedUpscalingTechniques.SetStructureDefinition( Tr2UpscalingTechniqueInfoDefinition ); m_supportedUpscalingTechniques.SetDefaultValue( &s_defaultUpscalingTechniqueInfo ); - Tr2DisplayModeInfo empty = {0}; + Tr2DisplayModeInfo empty = { 0 }; mDisplayMode = empty; - // At this point, in the constructor, we are just setting defaults. We really + // At this point, in the constructor, we are just setting defaults. We really // don't know if the device will require an adapter or not (in the case of // software rendering an adapter is not necessary). - ALResult ignoreThisResult = + ALResult ignoreThisResult = Tr2VideoAdapterInfo::GetAdapterDisplayMode( mAdapter, mDisplayMode ); - // In the case where an adapter wouldn't be required (we don't know yet) it + // In the case where an adapter wouldn't be required (we don't know yet) it // is fine for the method above to fail so we must explicitly ignore the result - // of calling the method (otherwise the results checking, when enabled, would + // of calling the method (otherwise the results checking, when enabled, would // complain). ignoreThisResult.GetResult(); @@ -200,14 +200,14 @@ TriDevice::TriDevice( IRoot* lockobj ) : mPresentParam.mode.format = PIXEL_FORMAT_UNKNOWN; mPresentParam.mode.scaling = DISPLAY_SCALING_UNSPECIFIED; mPresentParam.mode.scanlineOrdering = SCANLINE_ORDER_UNSPECIFIED; - mPresentParam.backBufferCount = mBackBufferCount; + mPresentParam.backBufferCount = mBackBufferCount; - mPresentParam.msaaType = 0; - mPresentParam.msaaQuality = 0; + mPresentParam.msaaType = 0; + mPresentParam.msaaQuality = 0; - mPresentParam.swapEffect = mSwapEffect; - mPresentParam.outputWindow = 0; - mPresentParam.windowed = true; + mPresentParam.swapEffect = mSwapEffect; + mPresentParam.outputWindow = 0; + mPresentParam.windowed = true; mPresentParam.presentInterval = PRESENT_INTERVAL_ONE; @@ -217,13 +217,13 @@ TriDevice::TriDevice( IRoot* lockobj ) : SetProcessDPIAware(); #endif - BeClasses->CreateInstanceFromName("BlueCallbackMan", BlueInterfaceIID(), (void**)&m_postUpdateCallbacks ); + BeClasses->CreateInstanceFromName( "BlueCallbackMan", BlueInterfaceIID(), (void**)&m_postUpdateCallbacks ); } TriDevice::~TriDevice() { - m_scene = (ITr2Scene*)NULL; + m_scene = (ITr2Scene*)NULL; BeOS->UnregisterForSimTimeRebase( this ); } @@ -231,7 +231,7 @@ bool TriDevice::CreateSimpleDevice( Tr2WindowHandle hwnd, unsigned int width, unsigned int height, - DeviceScreenType type, + DeviceScreenType type, Tr2RenderContextEnum::PresentInterval presentInterval, unsigned int adapter ) { @@ -240,12 +240,12 @@ bool TriDevice::CreateSimpleDevice( // Build a windowd device: Tr2PresentParametersAL pp = mPresentParam; - + //Create the device, using those creation parameters present in the device. - pp.mode.width = width; + pp.mode.width = width; pp.mode.height = height; pp.outputWindow = hwnd; - pp.software = (m_deviceType == TriDevice::DEVICE_TYPE_SOFTWARE); + pp.software = ( m_deviceType == TriDevice::DEVICE_TYPE_SOFTWARE ); pp.windowed = false; if( type == FULLSCREEN ) @@ -307,7 +307,7 @@ bool TriDevice::CreateSimpleDevice( } PrepareDeviceResources(); - BeOS->RegisterForTicks(this, (void*)TRINITY); + BeOS->RegisterForTicks( this, (void*)TRINITY ); return true; } @@ -321,37 +321,33 @@ bool TriDevice::InitD3DDevice() return false; } - if( ( mPresentParam.outputWindow || !mPresentParam.software ) - && FAILED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( - Tr2VideoAdapterInfo::DEFAULT_ADAPTER, - mDisplayMode ) ) - ) + if( ( mPresentParam.outputWindow || !mPresentParam.software ) && FAILED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, mDisplayMode ) ) ) { return false; } - - mViewport.x = 0; - mViewport.y = 0; - mViewport.width = int( mWidth ); - mViewport.height = int( mHeight ); - mViewport.minZ = 0; - mViewport.maxZ = 1.0f; + + mViewport.x = 0; + mViewport.y = 0; + mViewport.width = int( mWidth ); + mViewport.height = int( mHeight ); + mViewport.minZ = 0; + mViewport.maxZ = 1.0f; mDeviceLost = false; return true; } bool TriDevice::ChangeDevice( - uint32_t adapter, - Tr2WindowHandle hWnd, - const Tr2PresentParametersAL* pp ) + uint32_t adapter, + Tr2WindowHandle hWnd, + const Tr2PresentParametersAL* pp ) { bool resetOnly = true; bool adaptersChanged = Tr2VideoAdapterInfo::AreAdaptersDifferent( adapter, mAdapter ); - if( !DeviceExists() || hWnd != mHwnd || adaptersChanged ) + if( !DeviceExists() || hWnd != mHwnd || adaptersChanged ) { - resetOnly = false; // reset is not enough, we need to recreate the device. + resetOnly = false; // reset is not enough, we need to recreate the device. } if( !pp ) @@ -361,7 +357,7 @@ bool TriDevice::ChangeDevice( if( resetOnly && ResetDevice( adapter, pp ) ) { - return true; // reset was enough. + return true; // reset was enough. } // Okay, we are creating a new device. @@ -370,7 +366,7 @@ bool TriDevice::ChangeDevice( if( DeviceExists() ) { ReleaseDeviceResources( TRISTORAGE_ALL ); - Tr2RenderContext::DestroyMainThreadRenderContext(); + Tr2RenderContext::DestroyMainThreadRenderContext(); } Tr2SyncToGpu::GetInstance().Flush(); @@ -395,7 +391,7 @@ bool TriDevice::ChangeDevice( { return false; } - + if( !SetPresentParameters( mAdapter, mPresentParam ) ) { return false; @@ -411,14 +407,38 @@ bool TriDevice::ChangeDevice( return true; } -void TriDevice::SetGeometryLoadDisabled( bool value ) { Tr2Renderer::m_disableGeometryLoad = value; } -void TriDevice::SetTextureLoadDisabled( bool value ) { Tr2Renderer::m_disableTextureLoad = value; } -void TriDevice::SetEffectLoadDisabled( bool value ) { Tr2Renderer::m_disableEffectLoad = value; } -void TriDevice::SetAsyncLoadDisabled( bool value ) { Tr2Renderer::m_disableAsyncLoad = value; } -bool TriDevice::GetGeometryLoadDisabled() { return Tr2Renderer::m_disableGeometryLoad; } -bool TriDevice::GetTextureLoadDisabled() { return Tr2Renderer::m_disableTextureLoad; } -bool TriDevice::GetEffectLoadDisabled() { return Tr2Renderer::m_disableEffectLoad; } -bool TriDevice::GetAsyncLoadDisabled() { return Tr2Renderer::m_disableAsyncLoad; } +void TriDevice::SetGeometryLoadDisabled( bool value ) +{ + Tr2Renderer::m_disableGeometryLoad = value; +} +void TriDevice::SetTextureLoadDisabled( bool value ) +{ + Tr2Renderer::m_disableTextureLoad = value; +} +void TriDevice::SetEffectLoadDisabled( bool value ) +{ + Tr2Renderer::m_disableEffectLoad = value; +} +void TriDevice::SetAsyncLoadDisabled( bool value ) +{ + Tr2Renderer::m_disableAsyncLoad = value; +} +bool TriDevice::GetGeometryLoadDisabled() +{ + return Tr2Renderer::m_disableGeometryLoad; +} +bool TriDevice::GetTextureLoadDisabled() +{ + return Tr2Renderer::m_disableTextureLoad; +} +bool TriDevice::GetEffectLoadDisabled() +{ + return Tr2Renderer::m_disableEffectLoad; +} +bool TriDevice::GetAsyncLoadDisabled() +{ + return Tr2Renderer::m_disableAsyncLoad; +} void TriDevice::Update( Be::Time realTime, Be::Time simTime ) @@ -434,13 +454,13 @@ void TriDevice::Update( Be::Time realTime, Be::Time simTime ) CTriCurveSetVector curveSets; for( auto it = m_curveSets.cbegin(); it != m_curveSets.cend(); ++it ) { - curveSets.Insert( -1, (*it)->GetRawRoot() ); + curveSets.Insert( -1, ( *it )->GetRawRoot() ); } for( auto it = curveSets.cbegin(); it != curveSets.cend(); ++it ) { - (*it)->Update( realTime, simTime ); + ( *it )->Update( realTime, simTime ); } - curveSets.Remove(-1); + curveSets.Remove( -1 ); // Remember, m_curveSets is a BlueList, must use Remove to get ref-count right. for( ssize_t i = 0; i < m_curveSets.GetSize(); ) @@ -461,8 +481,8 @@ void TriDevice::DestroyRenderContext() { if( DeviceExists() ) { - ReleaseDeviceResources( TRISTORAGE_ALL ); //we are about to release device. - Tr2RenderContext::DestroyMainThreadRenderContext(); + ReleaseDeviceResources( TRISTORAGE_ALL ); //we are about to release device. + Tr2RenderContext::DestroyMainThreadRenderContext(); } } @@ -479,12 +499,11 @@ void TriDevice::ReleaseDeviceResources( TriStorage s ) s_iteratingForRelease = true; for( auto it = rs.begin(); it != rs.end(); ++it ) { - if( !*it ) + if( !*it ) { CCP_LOGWARN( "NULL TriDeviceResource found in resource set during TriDevice::ReleaseDeviceResources!" ); } - else - if( s_resourcesToBeRemoved.find( *it ) != s_resourcesToBeRemoved.end() ) + else if( s_resourcesToBeRemoved.find( *it ) != s_resourcesToBeRemoved.end() ) { // ignore, was Unregistered while iterating. We could erase() right here and now, // but then we could leave an object dangling until the next reset: happens if we already @@ -493,8 +512,8 @@ void TriDevice::ReleaseDeviceResources( TriStorage s ) } else { - (*it)->ReleaseResources( s ); - } + ( *it )->ReleaseResources( s ); + } } s_iteratingForRelease = false; for( auto it = s_resourcesToBeRemoved.cbegin(); it != s_resourcesToBeRemoved.cend(); ++it ) @@ -548,7 +567,7 @@ void TriDevice::ReleaseDeviceResources( TriStorage s ) } if( !PyIter_Check( keys.o ) ) { - CCP_LOGERR("Could not iterate through resource set keys in \"ReleaseDeviceResources\""); + CCP_LOGERR( "Could not iterate through resource set keys in \"ReleaseDeviceResources\"" ); return; } @@ -560,7 +579,7 @@ void TriDevice::ReleaseDeviceResources( TriStorage s ) // OnInvalidate method is optional, often not needed continue; } - BluePy result( PyOS->CallMethodWithTrap( item, "OnInvalidate", "OnInvalidate", "(i)", (int)s) ); + BluePy result( PyOS->CallMethodWithTrap( item, "OnInvalidate", "OnInvalidate", "(i)", (int)s ) ); if( !result ) { PyOS->PyError(); @@ -607,13 +626,13 @@ void TriDevice::RebuildDeviceResourcesInPython() if( !keys ) { - CCP_LOGERR("keys() method failed on resource set in \"RebuildDeviceResourcesInPython\"."); + CCP_LOGERR( "keys() method failed on resource set in \"RebuildDeviceResourcesInPython\"." ); PyOS->PyError(); return; } if( !PyIter_Check( keys.o ) ) { - CCP_LOGERR("Could not iterate through resource set keys in \"RebuildDeviceResourcesInPython\"."); + CCP_LOGERR( "Could not iterate through resource set keys in \"RebuildDeviceResourcesInPython\"." ); return; } @@ -636,10 +655,10 @@ float TriDevice::AspectRatio() { if( mViewport.height == 0 ) { - CCP_ASSERT(0); // should never get here, programmer or usage error it ir happens + CCP_ASSERT( 0 ); // should never get here, programmer or usage error it ir happens return 0.0f; } - + return (float)mViewport.width / (float)mViewport.height; } @@ -656,9 +675,9 @@ bool TriDevice::SetPresentation( int adapter, const Tr2PresentParametersAL* d3dp mHwnd = d3dpp->outputWindow; mWidth = d3dpp->mode.width; mHeight = d3dpp->mode.height; - BeOS->RegisterForTicks(this, (void*)TRINITY); - } - else + BeOS->RegisterForTicks( this, (void*)TRINITY ); + } + else { InvalidateAndUnregisterForTicks(); } @@ -668,7 +687,7 @@ bool TriDevice::SetPresentation( int adapter, const Tr2PresentParametersAL* d3dp void TriDevice::InvalidateAndUnregisterForTicks() { DestroyRenderContext(); - BeOS->UnregisterForTicks(this, (void*)TRINITY); + BeOS->UnregisterForTicks( this, (void*)TRINITY ); mHwnd = 0; mWidth = mHeight = 0; } @@ -682,7 +701,7 @@ void TriDevice::OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) // Start with statistics on frame time static BeTimer s_frameTimer; static const int s_fpsValuesCount = 64; - static double s_frameTimeValues[s_fpsValuesCount] = {0.0}; + static double s_frameTimeValues[s_fpsValuesCount] = { 0.0 }; static double s_generatedFrames[s_fpsValuesCount] = { 0 }; static double s_frameTimeSum = 0.0; @@ -759,7 +778,7 @@ void TriDevice::OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) s_generatedFrames[s_currentFpsValue] = 0; s_generatedFpsSum = 0; } - + s_frameTimeSum -= s_frameTimeValues[s_currentFpsValue]; s_frameTimeValues[s_currentFpsValue] = frameTime; s_frameTimeSum += frameTime; @@ -796,13 +815,13 @@ void TriDevice::OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) { delta = 0L; } - float fDelta = (float)((double)delta / 10000000.0); + float fDelta = (float)( (double)delta / 10000000.0 ); if( fDelta > 1.0f ) { fDelta = 1.0f; } m_animationTime += fDelta * m_animationTimeScale; - + if( m_animationTime > ANIMATION_TIME_MAX ) { m_animationTime -= ANIMATION_TIME_MAX; @@ -818,7 +837,7 @@ void TriDevice::OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) #endif m_simTime = simTime; m_realTime = realTime; - + Update( realTime, simTime ); HandleRenderTick( realTime, simTime ); @@ -874,7 +893,7 @@ bool TriDevice::ResetDevice( unsigned adapter, const Tr2PresentParametersAL* pp return false; } - if (!pp) + if( !pp ) { pp = &mPresentParam; } @@ -884,14 +903,13 @@ bool TriDevice::ResetDevice( unsigned adapter, const Tr2PresentParametersAL* pp return false; } - // success! + // success! mWidth = pp->mode.width; mHeight = pp->mode.height; mPresentParam = *pp; - + // We may have changed display modes - if( ( mPresentParam.outputWindow || !mPresentParam.software ) - && FAILED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( mAdapter, mDisplayMode ) ) ) + if( ( mPresentParam.outputWindow || !mPresentParam.software ) && FAILED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( mAdapter, mDisplayMode ) ) ) { CCP_LOGNOTICE( "Device Reset: Adapter Display Mode Changed" ); Tr2Renderer::SetResourceCreationAllowed( true ); @@ -931,43 +949,43 @@ PyObject* TriDevice::PythonCreateDeviceHelper( PyObject* args, DeviceScreenType return nullptr; } - width = std::max( 0, width ); + width = std::max( 0, width ); height = std::max( 0, height ); #if __APPLE__ void* hwndAsPtr = (void*)hwnd; - bool OK = CreateSimpleDevice( (__bridge Tr2WindowHandle)( hwndAsPtr ), width, height, screenType, Tr2RenderContextEnum::PresentInterval( presentInterval ), adapter ); + bool OK = CreateSimpleDevice( ( __bridge Tr2WindowHandle )( hwndAsPtr ), width, height, screenType, Tr2RenderContextEnum::PresentInterval( presentInterval ), adapter ); #else bool OK = CreateSimpleDevice( reinterpret_cast( hwnd ), width, height, screenType, Tr2RenderContextEnum::PresentInterval( presentInterval ), adapter ); #endif - + if( !OK ) { return nullptr; } - Py_RETURN_NONE; + Py_RETURN_NONE; } PyObject* TriDevice::PyCreateWindowedDevice( PyObject* args ) { - return PythonCreateDeviceHelper( args, WINDOWED ); + return PythonCreateDeviceHelper( args, WINDOWED ); } PyObject* TriDevice::PyCreateFullScreenDevice( PyObject* args ) { - return PythonCreateDeviceHelper( args, FULLSCREEN ); + return PythonCreateDeviceHelper( args, FULLSCREEN ); } PyObject* TriDevice::PyCreateWindowlessDevice( PyObject* args ) { - return PythonCreateDeviceHelper( args, NO_ADAPTER ); + return PythonCreateDeviceHelper( args, NO_ADAPTER ); } -PyObject *TriDevice::PyRegisterResource( PyObject *args ) +PyObject* TriDevice::PyRegisterResource( PyObject* args ) { - PyObject *obj; - if (!PyArg_ParseTuple(args, "O:RegisterResource", &obj)) + PyObject* obj; + if( !PyArg_ParseTuple( args, "O:RegisterResource", &obj ) ) { return nullptr; } @@ -980,9 +998,9 @@ PyObject *TriDevice::PyRegisterResource( PyObject *args ) { return nullptr; } - m_pyResourceSet = BluePy( PyObject_CallMethod( module, const_cast("WeakKeyDictionary"), 0 ) ); + m_pyResourceSet = BluePy( PyObject_CallMethod( module, const_cast( "WeakKeyDictionary" ), 0 ) ); if( !m_pyResourceSet ) - { + { return nullptr; } } @@ -994,7 +1012,7 @@ PyObject *TriDevice::PyRegisterResource( PyObject *args ) } //Add the object as a key in the dictionary - return PyObject_CallMethod( m_pyResourceSet, const_cast("__setitem__"), const_cast("OO"), obj, Py_None ); + return PyObject_CallMethod( m_pyResourceSet, const_cast( "__setitem__" ), const_cast( "OO" ), obj, Py_None ); } #endif @@ -1011,7 +1029,7 @@ bool TriDevice::SetPresentParameters( unsigned adapter, const Tr2PresentParamete if( FAILED( hr ) ) { LogAllLiveResources( TRISTORAGE_VIDEOMEMORY ); - CCP_LOGERR( "Device Reset failed: 0x%X", unsigned( hr.GetResult() ) ); + CCP_LOGERR( "Device Reset failed: 0x%X", unsigned( hr.GetResult() ) ); return false; } return true; @@ -1021,7 +1039,7 @@ void TriDevice::PrepareDeviceResources() { // Rebuild C++ device resources const ResourceSet& rs = GetResourcesRegistered(); - for( auto i = rs.cbegin(); i!= rs.cend(); ++i ) + for( auto i = rs.cbegin(); i != rs.cend(); ++i ) { Tr2DeviceResource* resource = *i; if( resource ) @@ -1035,7 +1053,7 @@ void TriDevice::PrepareDeviceResources() } Tr2Renderer::PrepareDeviceResources(); - + // Rebuild Python device resources RebuildDeviceResourcesInPython(); } @@ -1048,9 +1066,9 @@ TriDevice::ResourceSet& TriDevice::GetResourcesRegistered() #if BLUE_WITH_PYTHON void TriDevice::PyRender() -{ +{ TriPythonContext pythonCtx; - Render(); + Render(); } #endif @@ -1083,7 +1101,7 @@ void TriDevice::UnregisterResource( Tr2DeviceResource* resource ) } else { - s_resourcesToBeRemoved.insert( resource) ; + s_resourcesToBeRemoved.insert( resource ); } } @@ -1108,18 +1126,15 @@ void TriDevice::GetPickRayFromViewport( int x, int y, TriViewport* viewport, con float xp, yp; ScreenToProjection( x, y, &xp, &yp, viewport ); - ConvertProjectionCoordToWorldPickRay( xp, yp, &proj, &view, &startWorld, &rayWorld ); + ConvertProjectionCoordToWorldPickRay( xp, yp, &proj, &view, &startWorld, &rayWorld ); } -void TriDevice::ScreenToProjection( int x, int y, - float* fx, float* fy ) +void TriDevice::ScreenToProjection( int x, int y, float* fx, float* fy ) { ScreenToProjection( x, y, fx, fy, &mViewport ); } -void TriDevice::ScreenToProjection( int x, int y, - float* fx, float* fy, - const TriViewport* viewport ) +void TriDevice::ScreenToProjection( int x, int y, float* fx, float* fy, const TriViewport* viewport ) { x = x - viewport->x; y = y - viewport->y; @@ -1128,14 +1143,14 @@ void TriDevice::ScreenToProjection( int x, int y, //DX maps viewport pixel _centres_ to the view space. So, for four pixels, pixel no 3 maps to 1 and no 0 to -1 //(some other implementations map pixel _edges_ to the screen, this would give different results. - *fx = (float)(2*x)/(w-1) - 1.0f; - *fy = (float)(2*y)/(h-1) - 1.0f; + *fx = (float)( 2 * x ) / ( w - 1 ) - 1.0f; + *fy = (float)( 2 * y ) / ( h - 1 ) - 1.0f; *fy = -*fy; } bool TriDevice::Render() { - D3DPERF_EVENT(L"TriDevice::Render"); + D3DPERF_EVENT( L"TriDevice::Render" ); // We need to throttle the client right after Present call, so that GPU can have a break Throttle(); @@ -1152,20 +1167,20 @@ bool TriDevice::Render() renderContext.SetViewport( vp ); Tr2GpuProfiler::GetProfiler().BeginFrame( Tr2Renderer::GetCurrentFrameCounter() ); - + // start rendering Tr2Renderer::BeginFrame(); Tr2Renderer::BeginRenderContext(); - + Tr2Renderer::ReserveQuadListIndexBuffer( 0 ); if( m_renderJobs ) - { + { m_renderJobs->Run( m_realTime, m_simTime ); } - Tr2GpuProfiler::GetProfiler().EndFrame(); + Tr2GpuProfiler::GetProfiler().EndFrame(); Tr2Renderer::EndRenderContext(); Tr2Renderer::EndFrame(); @@ -1179,19 +1194,19 @@ void TriDevice::AddPostUpdateCallback( IBlueCallbackMan::CallbackFunc cb, void* namespace { - void LogObject( Tr2ALMemoryType memoryType, const Tr2DeviceResourceDescriptionAL& description ) +void LogObject( Tr2ALMemoryType memoryType, const Tr2DeviceResourceDescriptionAL& description ) +{ + std::string message; + for( auto it = description.begin(); it != description.end(); ++it ) { - std::string message; - for( auto it = description.begin(); it != description.end(); ++it ) - { - message += it->first; - message += ": "; - message += it->second; - message += ", "; - } + message += it->first; + message += ": "; + message += it->second; + message += ", "; + } - CCP_LOGERR( "%s", message.c_str() ); - }; + CCP_LOGERR( "%s", message.c_str() ); +}; } void TriDevice::LogAllLiveResources( Tr2ALMemoryTypes flags ) @@ -1291,7 +1306,7 @@ void TriDevice::UpdateAvailableUpscalingTechniques() g_force_fsr1_availability = !g_newUpscalersEnabled; if( !g_newUpscalersEnabled ) { - // only allow FSR1 + // only allow FSR1 Tr2UpscalingTechniqueInfo technique = { Tr2UpscalingAL::FSR1, Tr2UpscalingAL::Setting::PERFORMANCE | Tr2UpscalingAL::Setting::BALANCED | Tr2UpscalingAL::Setting::QUALITY | Tr2UpscalingAL::Setting::ULTRA_QUALITY, @@ -1300,8 +1315,8 @@ void TriDevice::UpdateAvailableUpscalingTechniques() m_supportedUpscalingTechniques.Append( &technique ); return; } - - // this method needs to be called after a device has been called + + // this method needs to be called after a device has been called USE_MAIN_THREAD_RENDER_CONTEXT(); for( auto& techInfo : renderContext.GetSupportedUpscalingTechniques( mAdapter ) ) @@ -1338,11 +1353,11 @@ void TriDevice::SetUpscaling( Tr2UpscalingAL::Technique technique, Tr2UpscalingA uint32_t TriDevice::CreateUpscalingContext( uint32_t displayWidth, uint32_t displayHeight, Tr2RenderContextEnum::PixelFormat sourceFormat, Tr2RenderContextEnum::DepthStencilFormat depthFormat, bool allowFramegen, Be::Optional existingContext ) { - CCP_STATS_ZONE( __FUNCTION__ ); - + CCP_STATS_ZONE( __FUNCTION__ ); + USE_MAIN_THREAD_RENDER_CONTEXT(); - Tr2UpscalingAL::UpscalingContextParams params = Tr2UpscalingAL::UpscalingContextParams(renderContext); + Tr2UpscalingAL::UpscalingContextParams params = Tr2UpscalingAL::UpscalingContextParams( renderContext ); params.allowFramegen = allowFramegen; params.displayWidth = displayWidth; params.displayHeight = displayHeight; @@ -1403,11 +1418,11 @@ PyObject* TriDevice::PyGetUpscalingInfo( PyObject* args ) bool temporal; USE_MAIN_THREAD_RENDER_CONTEXT(); - renderContext.GetUpscalingSetup(technique, setting, frameGeneration, temporal); + renderContext.GetUpscalingSetup( technique, setting, frameGeneration, temporal ); auto result = PyDict_New(); - auto value = ToPython( Tr2UpscalingAL::GetTechniqueName(technique) ); + auto value = ToPython( Tr2UpscalingAL::GetTechniqueName( technique ) ); PyDict_SetItemString( result, "techniqueName", value ); Py_DecRef( value ); @@ -1435,7 +1450,7 @@ PyObject* TriDevice::PyGetUpscalingInfo( PyObject* args ) { auto info = renderContext.GetUpscalingInfo( contextId ); auto contextInfo = PyDict_New(); - + value = PyLong_FromSize_t( contextId ); PyDict_SetItemString( contextInfo, "id", value ); Py_DecRef( value ); @@ -1455,7 +1470,7 @@ PyObject* TriDevice::PyGetUpscalingInfo( PyObject* args ) value = PyLong_FromSize_t( info.renderHeight ); PyDict_SetItemString( contextInfo, "renderHeight", value ); Py_DecRef( value ); - + value = PyBool_FromLong( info.hasSharpening ); PyDict_SetItemString( contextInfo, "hasSharpening", value ); Py_DecRef( value ); @@ -1498,9 +1513,9 @@ void TriDevice::SetMinimumModelLOD( int minimumModelLOD ) m_minimumModelLOD = minimumModelLOD; CcpAutoMutex guard( GetResourcesRegisteredMutex() ); - + auto& rs = GetResourcesRegistered(); - for (auto it = rs.begin(); it != rs.end(); ++it) + for( auto it = rs.begin(); it != rs.end(); ++it ) { TriGeometryRes* geometry = dynamic_cast( *it ); if( !geometry ) diff --git a/trinity/TriDevice.h b/trinity/TriDevice.h index d09f82171..f135be908 100644 --- a/trinity/TriDevice.h +++ b/trinity/TriDevice.h @@ -30,12 +30,12 @@ extern Be::VarChooser Tr2UpsclaingAL_UpscalingTechnique_Chooser[]; extern Be::VarChooser Tr2UpsclaingAL_UpscalingSetting_Chooser[]; extern const Be::VarChooser TriDeviceTypeChooser[]; -BLUE_CLASS( TriDevice ): +BLUE_CLASS( TriDevice ) : public ITriDevice, public IBlueEvents, public ISimTimeRebaseNotify { -public: +public: using ITriDevice::Lock; using ITriDevice::Unlock; @@ -46,9 +46,9 @@ BLUE_CLASS( TriDevice ): THERMAL_STATE = 1 << 2, }; - ITr2ScenePtr m_scene; + ITr2ScenePtr m_scene; - Tr2WindowHandle mHwnd; + Tr2WindowHandle mHwnd; int32_t mWidth; int32_t mHeight; @@ -77,26 +77,23 @@ BLUE_CLASS( TriDevice ): void SetThrottling( ThrottlingReason reason, bool on ); bool GetThrottling( ThrottlingReason reason ) const; - // Window handling + // Window handling bool SetPresentation( int adapter, const Tr2PresentParametersAL* d3dpp ); //Transform screen (viewport) coordinates into projection coordinates (clip). - void ScreenToProjection( int x, int y, - float* fx, float* fy ); - - void ScreenToProjection( int x, int y, - float* fx, float* fy, - const TriViewport* viewport ); - - void GetPickRayFromViewport( - int x, // screen coordinates - int y, - TriViewport* viewport, // Viewport - const Matrix& view, // View matrix - const Matrix& proj, // Projection matrix - Vector3& rayWorld, // Out: The ray in world coordinates - Vector3& startWorld // Out: Starting point in world coordinates - ); + void ScreenToProjection( int x, int y, float* fx, float* fy ); + + void ScreenToProjection( int x, int y, float* fx, float* fy, const TriViewport* viewport ); + + void GetPickRayFromViewport( + int x, // screen coordinates + int y, + TriViewport* viewport, // Viewport + const Matrix& view, // View matrix + const Matrix& proj, // Projection matrix + Vector3& rayWorld, // Out: The ray in world coordinates + Vector3& startWorld // Out: Starting point in world coordinates + ); bool ChangeDevice( uint32_t adapter, @@ -116,11 +113,11 @@ BLUE_CLASS( TriDevice ): DEVICE_TYPE_SOFTWARE, }; - bool CreateSimpleDevice( - Tr2WindowHandle hwnd, - unsigned int width, - unsigned int height, - DeviceScreenType type, + bool CreateSimpleDevice( + Tr2WindowHandle hwnd, + unsigned int width, + unsigned int height, + DeviceScreenType type, Tr2RenderContextEnum::PresentInterval presentInterval, unsigned int adapter = Tr2VideoAdapterInfo::DEFAULT_ADAPTER ); @@ -135,18 +132,21 @@ BLUE_CLASS( TriDevice ): void ApplicationActivated( ApplicationActivation activated ); - static void RegisterResource(Tr2DeviceResource *resource); - static void UnregisterResource(Tr2DeviceResource *resource); + static void RegisterResource( Tr2DeviceResource * resource ); + static void UnregisterResource( Tr2DeviceResource * resource ); // Temporary function created during re-factoring. This method contains common code // that is now re-used in a couple of places through this method. Yay! Now, the difference - // between this method and 'Shutdown' is subtle and until we determine exactly what is + // between this method and 'Shutdown' is subtle and until we determine exactly what is // needed I'm going to refrain from combining those into one (even though this makes - // sense architecturally and should be possible). + // sense architecturally and should be possible). void InvalidateAndUnregisterForTicks(); // Time in seconds, recentered regularly (once per hour) - float GetAnimationTime() { return m_animationTime; } + float GetAnimationTime() + { + return m_animationTime; + } float GetAnimationTimeElapsed( float startTime ); @@ -156,23 +156,22 @@ BLUE_CLASS( TriDevice ): void OnTick( Be::Time realTime, Be::Time simTime, - void* cookie - ); + void* cookie ); - TriDevice(IRoot* lockobj = NULL); + TriDevice( IRoot* lockobj = NULL ); ~TriDevice(); Be::Time m_realTime; Be::Time m_simTime; - void SetRenderJobs( Tr2RenderJobs* renderJobs ); + void SetRenderJobs( Tr2RenderJobs * renderJobs ); // Textures and methods for HDR rendering (we use surface level 0 as draw buffer). In order // to use the hardware to perform image processing on these buffers we must be able to texture - // from them. This is why we create them as textures (textures can be used as surfaces but not + // from them. This is why we create them as textures (textures can be used as surfaces but not // vice versa in D3D). - + void SetGeometryLoadDisabled( bool value ); void SetTextureLoadDisabled( bool value ); @@ -183,13 +182,19 @@ BLUE_CLASS( TriDevice ): bool GetEffectLoadDisabled(); bool GetAsyncLoadDisabled(); - // Set the number of mip levels that are chopped of the front of the mip + // Set the number of mip levels that are chopped of the front of the mip // chain. I.e. the number of high detail mip levels that are skipped // while loading the file. Default is 0. - unsigned int GetMipLevelSkipCount() const { return m_mipLevelSkipCount; } + unsigned int GetMipLevelSkipCount() const + { + return m_mipLevelSkipCount; + } + + bool IsDeviceLost() const + { + return mDeviceLost; + } - bool IsDeviceLost() const { return mDeviceLost; } - ///////////////////////////////////////////////////////////////////////////////////// // ISimTimeRebaseNotify ///////////////////////////////////////////////////////////////////////////////////// @@ -197,7 +202,10 @@ BLUE_CLASS( TriDevice ): bool ResetDevice(); - int GetAdapter() { return mAdapter; } + int GetAdapter() + { + return mAdapter; + } bool DeviceExists(); // Add a callback to be processed after update render jobs are processed. This @@ -212,7 +220,7 @@ BLUE_CLASS( TriDevice ): int GetMinimumModelLOD(); private: - bool InitD3DDevice(); //call when a new device has been set + bool InitD3DDevice(); //call when a new device has been set void DestroyRenderContext(); void DoReleaseDevice(); @@ -221,15 +229,15 @@ BLUE_CLASS( TriDevice ): void HandleRenderTick( Be::Time realTime, Be::Time simTime ); - void UpdateAvailableUpscalingTechniques( ); + void UpdateAvailableUpscalingTechniques(); void CreateUpscalingTechnique( uint32_t adapter ); void SetUpscaling( Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration ); uint32_t CreateUpscalingContext( uint32_t displayWidth, uint32_t displayHeight, Tr2RenderContextEnum::PixelFormat sourceFormat, Tr2RenderContextEnum::DepthStencilFormat depthFormat, bool allowFramegen, Be::Optional existingContext ); void DeleteUpscalingContext( uint32_t contextID ); #if BLUE_WITH_PYTHON - PyObject* PyGetUpscalingInfo( PyObject* args ); -#endif + PyObject* PyGetUpscalingInfo( PyObject * args ); +#endif Vector2 GetRenderResolution( uint32_t upscalingContextId ); PTr2UpscalingTechniqueInfoStructureList m_supportedUpscalingTechniques; @@ -248,26 +256,26 @@ BLUE_CLASS( TriDevice ): BlueScriptCallback m_onDeviceRemoved; DeviceType m_deviceType; - - int mAdapter; + + int mAdapter; Tr2PresentParametersAL mPresentParam; // We must use a container class that can survive insertions during iteration without invalidating // the iterator. std::set is such a container and offers fast insertion/removal. - typedef std::set ResourceSet; + typedef std::set ResourceSet; static ResourceSet& GetResourcesRegistered(); - static ResourceSet s_resourcesToBeRemoved; - static bool s_iteratingForRelease; - - //A dict of blue devices, that will get + static ResourceSet s_resourcesToBeRemoved; + static bool s_iteratingForRelease; + + //A dict of blue devices, that will get #if BLUE_WITH_PYTHON - BluePy m_pyResourceSet; //weakkeydict + BluePy m_pyResourceSet; //weakkeydict #endif //Free memory on adapter, as required before a device can be Reset. void ReleaseDeviceResources( TriStorage s ); void PrepareDeviceResources(); - void RebuildDeviceResourcesInPython(); + void RebuildDeviceResourcesInPython(); bool mDeviceLost; @@ -275,7 +283,7 @@ BLUE_CLASS( TriDevice ): Tr2UpscalingAL::Technique m_upscalingTechnique; Tr2UpscalingAL::Setting m_upscalingSetting; bool m_upscalingWithFrameGeneration; - + int m_minimumModelLOD; @@ -300,7 +308,7 @@ BLUE_CLASS( TriDevice ): // For python code it already looks like Tr2RenderJobs is on the trinity module, but on // the C++ side we keep it in TriDevice for now to make sure its lifetime is still tied // to the lifetime of g_d3dDev, until we figure out what to do with this. - Tr2RenderJobsPtr m_renderJobs; + Tr2RenderJobsPtr m_renderJobs; IBlueCallbackManPtr m_postUpdateCallbacks; @@ -311,29 +319,29 @@ BLUE_CLASS( TriDevice ): ///////////////////////////////////////// // Python thunkers #if BLUE_WITH_PYTHON - PyObject* PyCreateWindowedDevice ( PyObject* args ); - PyObject* PyCreateFullScreenDevice ( PyObject* args ); - PyObject* PyCreateWindowlessDevice ( PyObject* args ); - + PyObject* PyCreateWindowedDevice( PyObject * args ); + PyObject* PyCreateFullScreenDevice( PyObject * args ); + PyObject* PyCreateWindowlessDevice( PyObject * args ); + void PyRender(); - PyObject* PyRegisterResource ( PyObject* args ); - PyObject* PyGetPickRayFromViewport ( PyObject* args ); + PyObject* PyRegisterResource( PyObject * args ); + PyObject* PyGetPickRayFromViewport( PyObject * args ); void RefreshDeviceResources(); - PyObject* PythonCreateDeviceHelper( PyObject* args, DeviceScreenType screenType ); + PyObject* PythonCreateDeviceHelper( PyObject * args, DeviceScreenType screenType ); #endif //--bpe stupid hack until I can figure out how to export trinity.renderContext similar to trinity.device Tr2RenderContext* GetRenderContext(); - unsigned GetRenderingPlatformID(); + unsigned GetRenderingPlatformID(); }; /////////////////////////////////////////////////////////////////////// -// Global pointer so that all nodes don't have to +// Global pointer so that all nodes don't have to // be passed a TriDevice pointer /////////////////////////////////////////////////////////////////////// extern BlueBasicPtr gTriDev; @@ -343,7 +351,7 @@ extern BlueBasicPtr gTriDev; //be done with the final implementation, when the Lock() / Unlock() virtual functions //have been created. It's not possible to do so in the virtual class TriDevice //So, we do it here. -#pragma warning (disable:4624) //disable warning about destructor +#pragma warning( disable : 4624 ) //disable warning about destructor class TriDeviceLock : public RootRefLock { public: diff --git a/trinity/TriDevice11.cpp b/trinity/TriDevice11.cpp index e225d8288..6c4026d62 100644 --- a/trinity/TriDevice11.cpp +++ b/trinity/TriDevice11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "TriDevice.h" #include "RenderJob/Tr2RenderJobs.h" @@ -11,13 +11,13 @@ #include "TriSettingsRegistrar.h" bool g_emulateDriverReset = false; bool g_fixFullscreenBehaviorForOldWindows = false; -TRI_REGISTER_SETTING( "emulateDriverReset", g_emulateDriverReset ); +TRI_REGISTER_SETTING( "emulateDriverReset", g_emulateDriverReset ); TRI_REGISTER_SETTING( "fixFullscreenBehaviorForOldWindows", g_fixFullscreenBehaviorForOldWindows ); CCP_STATS_DECLARED_ELSEWHERE( presentTime ); -void TriDevice::HandleRenderTick( Be::Time realTime, Be::Time simTime ) +void TriDevice::HandleRenderTick( Be::Time realTime, Be::Time simTime ) { #if BLUE_WITH_PYTHON AutoTasklet _at( PyOS->GetTaskletTimer(), "TriDevice::HandleRenderTick" ); @@ -119,7 +119,7 @@ void TriDevice::HandleRenderTick( Be::Time realTime, Be::Time simTime ) return; } - + if( mDeviceLost ) { return; @@ -160,9 +160,9 @@ bool TriDevice::DeviceExists() // -------------------------------------------------------------------------------------- // Description: -// A chance for device to respond to application window being activated/deactivated. +// A chance for device to respond to application window being activated/deactivated. // For DX11 platform we minimize fullscreen window when user alt-tabs from application -// and restore it back when he returns. This makes DX11 window behavior being +// and restore it back when he returns. This makes DX11 window behavior being // consistent with DX9. // Arguments: // activated - true if application was activated; false otherwise @@ -170,7 +170,7 @@ bool TriDevice::DeviceExists() void TriDevice::ApplicationActivated( ApplicationActivation activated ) { CCP_STATS_ZONE( __FUNCTION__ ); - + if( !mPresentParam.windowed && mHwnd ) { USE_MAIN_THREAD_RENDER_CONTEXT(); diff --git a/trinity/TriDevice12.cpp b/trinity/TriDevice12.cpp index b45c6024a..cded55596 100644 --- a/trinity/TriDevice12.cpp +++ b/trinity/TriDevice12.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if TRINITY_PLATFORM==TRINITY_DIRECTX12 +#if TRINITY_PLATFORM == TRINITY_DIRECTX12 #include "TriDevice.h" #include "RenderJob/Tr2RenderJobs.h" @@ -371,9 +371,9 @@ bool TriDevice::DeviceExists() // -------------------------------------------------------------------------------------- // Description: -// A chance for device to respond to application window being activated/deactivated. +// A chance for device to respond to application window being activated/deactivated. // For DX11 platform we minimize fullscreen window when user alt-tabs from application -// and restore it back when he returns. This makes DX11 window behavior being +// and restore it back when he returns. This makes DX11 window behavior being // consistent with DX9. // Arguments: // activated - true if application was activated; false otherwise diff --git a/trinity/TriDeviceMetal.cpp b/trinity/TriDeviceMetal.cpp index 500428431..7e1c884ef 100644 --- a/trinity/TriDeviceMetal.cpp +++ b/trinity/TriDeviceMetal.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "TriDevice.h" @@ -28,41 +28,41 @@ void TriDevice::HandleRenderTick( Be::Time realTime, Be::Time simTime ) return; } - if( m_upscalingChanged ) - { - CCP_LOGNOTICE( "Resetting device - Upscaler changed" ); - CreateUpscalingTechnique(mAdapter); - ResetDevice(); - return; - } - + if( m_upscalingChanged ) + { + CCP_LOGNOTICE( "Resetting device - Upscaler changed" ); + CreateUpscalingTechnique( mAdapter ); + ResetDevice(); + return; + } + if( mDeviceLost ) { return; - } - Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_UPDATE_STARTED ); + } + Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_UPDATE_STARTED ); if( m_renderJobs ) { m_renderJobs->RunUpdate( realTime, simTime ); } - Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_UPDATE_FINISHED ); + Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_UPDATE_FINISHED ); m_postUpdateCallbacks->Update(); { - Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_PRESENT_STARTED ); + Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_PRESENT_STARTED ); CCP_STATS_SCOPED_TIME( presentTime ); CR_RETURN( renderContext.Present() ); - Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_PRESENT_FINISHED ); + Tr2RenderContext_GetMainThreadRenderContext().MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_PRESENT_FINISHED ); } - renderContext.MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_RENDERING_STARTED ); - if( !Render() ) - { - CCP_LOGERR( "Failed to render a frame" ); - } - renderContext.MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_RENDERING_FINISHED ); + renderContext.MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_RENDERING_STARTED ); + if( !Render() ) + { + CCP_LOGERR( "Failed to render a frame" ); + } + renderContext.MarkFrameEvent( Tr2RenderContextEnum::FRAME_EVENT_RENDERING_FINISHED ); } // -- Smaller helpers to enable big methods like TriDevice::Render to be mostly API neutral. @@ -87,4 +87,3 @@ void TriDevice::ApplicationActivated( ApplicationActivation ) } #endif - diff --git a/trinity/TriDeviceStub.cpp b/trinity/TriDeviceStub.cpp index c7d82a5a5..3308040c0 100644 --- a/trinity/TriDeviceStub.cpp +++ b/trinity/TriDeviceStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "TriDevice.h" @@ -39,7 +39,7 @@ bool TriDevice::DeviceExists() // -------------------------------------------------------------------------------------- // Description: -// A chance for device to respond to application window being activated/deactivated. +// A chance for device to respond to application window being activated/deactivated. // Not implemented for DX9 - we are happy with how windows behaves in DX9. // Arguments: // activated - true if application was activated; false otherwise diff --git a/trinity/TriDevice_Blue.cpp b/trinity/TriDevice_Blue.cpp index 0232c4503..6a766e831 100644 --- a/trinity/TriDevice_Blue.cpp +++ b/trinity/TriDevice_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE( TriDevice ); #define TRIDEVICE_Description \ -"TriDevice has been a bit of a trash can through the development of Trinity. Now \r\n\ + "TriDevice has been a bit of a trash can through the development of Trinity. Now \r\n\ it only handles the assosiation of scenes and the actual D3D Device. Methods \r\n\ such as picking into the scene etc. will probably be added here." @@ -22,17 +22,17 @@ void TriDevice::RefreshDeviceResources() PyObject* BuildTuple( const Vector3& v ) { PyObject* tuple = PyTuple_New( 3 ); - PyTuple_SET_ITEM(tuple, 0, PyFloat_FromDouble( v.x ) ); - PyTuple_SET_ITEM(tuple, 1, PyFloat_FromDouble( v.y ) ); - PyTuple_SET_ITEM(tuple, 2, PyFloat_FromDouble( v.z ) ); + PyTuple_SET_ITEM( tuple, 0, PyFloat_FromDouble( v.x ) ); + PyTuple_SET_ITEM( tuple, 1, PyFloat_FromDouble( v.y ) ); + PyTuple_SET_ITEM( tuple, 2, PyFloat_FromDouble( v.z ) ); return tuple; } PyObject* TriDevice::PyGetPickRayFromViewport( PyObject* args ) -{ +{ // Check the arguments - int x,y; + int x, y; PyObject* viewportObj; PyObject* viewObj; PyObject* projObj; @@ -62,14 +62,14 @@ PyObject* TriDevice::PyGetPickRayFromViewport( PyObject* args ) // Call the C++ counterpart Vector3 pRay; Vector3 pStart; - GetPickRayFromViewport( x, y, viewport, view, proj, pRay, pStart); + GetPickRayFromViewport( x, y, viewport, view, proj, pRay, pStart ); // Wrap the results a tuple - PyObject *r = PyTuple_New(2); - PyTuple_SET_ITEM(r, 0, BuildTuple( pRay ) ); - PyTuple_SET_ITEM(r, 1, BuildTuple( pStart ) ); + PyObject* r = PyTuple_New( 2 ); + PyTuple_SET_ITEM( r, 0, BuildTuple( pRay ) ); + PyTuple_SET_ITEM( r, 1, BuildTuple( pStart ) ); return r; } @@ -161,9 +161,10 @@ const Be::VarChooser TriDeviceThrottlingReasonChooser[] = { { 0 } }; -BLUE_REGISTER_ENUM_EX( "TriDeviceType", - TriDevice::DeviceType, - TriDeviceTypeChooser, ENUM_REG_ENUM_OBJECT_ON_MODULE ); +BLUE_REGISTER_ENUM_EX( "TriDeviceType", + TriDevice::DeviceType, + TriDeviceTypeChooser, + ENUM_REG_ENUM_OBJECT_ON_MODULE ); Be::VarChooser Tr2UpsclaingAL_UpscalingTechnique_Chooser[] = { @@ -204,63 +205,55 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() { ///////////////////////////////////////// // Blue class info - EXPOSURE_BEGIN( TriDevice, "" ) + EXPOSURE_BEGIN( TriDevice, "" ) - MAP_INTERFACE(ITriDevice) + MAP_INTERFACE( ITriDevice ) - MAP_ATTRIBUTE_WITH_CHOOSER( "swapEffect", mSwapEffect, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST | Be::ENUM, Tr2RenderContextEnum_SwapEffect_Chooser ) - MAP_ATTRIBUTE( "multiSampleType", mPresentParam.msaaType, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "presentationInterval", mPresentParam.presentInterval, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST | Be::ENUM, Tr2RenderContextEnum_PresentInterval_Chooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "swapEffect", mSwapEffect, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST | Be::ENUM, Tr2RenderContextEnum_SwapEffect_Chooser ) + MAP_ATTRIBUTE( "multiSampleType", mPresentParam.msaaType, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) + MAP_ATTRIBUTE_WITH_CHOOSER( "presentationInterval", mPresentParam.presentInterval, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST | Be::ENUM, Tr2RenderContextEnum_PresentInterval_Chooser ) - MAP_ATTRIBUTE( "adapterWidth", mDisplayMode.width, "na", Be::READ ) + MAP_ATTRIBUTE( "adapterWidth", mDisplayMode.width, "na", Be::READ ) MAP_ATTRIBUTE( "adapterHeight", mDisplayMode.height, "na", Be::READ ) MAP_ATTRIBUTE( "adapterRefreshRate", mDisplayMode.refreshRateDenominator, "na", Be::READ ) - MAP_ATTRIBUTE( "adapter", mAdapter, "na", Be::READ ) - + MAP_ATTRIBUTE( "adapter", mAdapter, "na", Be::READ ) + MAP_ATTRIBUTE( "multiSampleQuality", mPresentParam.msaaQuality, "na", Be::READWRITE | Be::NOTIFY | Be::PERSIST ) - MAP_ATTRIBUTE ( "scene", m_scene, "na", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "scene", m_scene, "na", Be::READWRITE | Be::NOTIFY ) - //MAP_ATTRIBUTE( "ui", mUi, "na", Be::READ ) + //MAP_ATTRIBUTE( "ui", mUi, "na", Be::READ ) MAP_ATTRIBUTE( "width", mWidth, "na", Be::READ ) MAP_ATTRIBUTE( "height", mHeight, "na", Be::READ ) MAP_ATTRIBUTE( "viewport", mViewport, "na", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE_WITH_CHOOSER( "deviceType", m_deviceType, "Hardware/Software device", Be::READWRITE| Be::ENUM, TriDeviceTypeChooser ) + MAP_ATTRIBUTE_WITH_CHOOSER( "deviceType", m_deviceType, "Hardware/Software device", Be::READWRITE | Be::ENUM, TriDeviceTypeChooser ) - MAP_ATTRIBUTE( "backBufferCount", mBackBufferCount, "na", Be::READWRITE | Be::NOTIFY ) + MAP_ATTRIBUTE( "backBufferCount", mBackBufferCount, "na", Be::READWRITE | Be::NOTIFY ) MAP_ATTRIBUTE( "tickInterval", mTickInterval, "na", Be::READWRITE ) MAP_ATTRIBUTE_WITH_CHOOSER( "throttlingState", m_throttlingState, "", Be::READ, TriDeviceThrottlingReasonChooser ) MAP_ATTRIBUTE( "allowThrottling", m_allowThrottling, "", Be::READWRITE ) - MAP_PROPERTY - ( + MAP_PROPERTY( "disableGeometryLoad", GetGeometryLoadDisabled, SetGeometryLoadDisabled, - "Set to true to disable loading of external geometry - useful for batch processing of blue files" - ) - MAP_PROPERTY - ( + "Set to true to disable loading of external geometry - useful for batch processing of blue files" ) + MAP_PROPERTY( "disableTextureLoad", GetTextureLoadDisabled, SetTextureLoadDisabled, - "Set to true to disable loading of external textures - useful for batch processing of blue files" - ) - MAP_PROPERTY - ( + "Set to true to disable loading of external textures - useful for batch processing of blue files" ) + MAP_PROPERTY( "disableAsyncLoad", GetAsyncLoadDisabled, SetAsyncLoadDisabled, - "Set to true to make resource loads synchronous" - ) - MAP_ATTRIBUTE - ( - "mipLevelSkipCount", - m_mipLevelSkipCount, + "Set to true to make resource loads synchronous" ) + MAP_ATTRIBUTE( + "mipLevelSkipCount", + m_mipLevelSkipCount, "Number of high detail mip levels we skip, i.e. chop of the front of the mip chain.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "upscalingTechnique", @@ -297,13 +290,13 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() - MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets that are update each frame. Finished curve sets are removed automatically.", Be::READ | Be::PERSIST ) - - MAP_ATTRIBUTE( "animationTime", m_animationTime, "Time (in seconds) used for animations", Be::READWRITE ) - MAP_ATTRIBUTE ( "animationTimeScale", m_animationTimeScale, "Scale on animation time. Set to 0 to freeze all animations", Be::READWRITE ) + MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets that are update each frame. Finished curve sets are removed automatically.", Be::READ | Be::PERSIST ) + + MAP_ATTRIBUTE( "animationTime", m_animationTime, "Time (in seconds) used for animations", Be::READWRITE ) + MAP_ATTRIBUTE( "animationTimeScale", m_animationTimeScale, "Scale on animation time. Set to 0 to freeze all animations", Be::READWRITE ) - MAP_ATTRIBUTE( - "onDeviceRemoved", + MAP_ATTRIBUTE( + "onDeviceRemoved", m_onDeviceRemoved, "Callback function that is called when a GPU device is removed (driver crash, etc.).\n" "The function is called with arguments (hr, hrMessage, removedCount, marker) where:\n" @@ -311,14 +304,12 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() "hrMessage - HRESULT message string\n" "lostCount - number of device removed events since the process started\n" "maker - GPU marker name last seen before device removal (may not always be available)", - Be::READWRITE - ) + Be::READWRITE ) - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "CreateWindowedDevice", - PyCreateWindowedDevice, - "Create a simple windowed device.\n" + PyCreateWindowedDevice, + "Create a simple windowed device.\n" ":param hwnd: A window handle\n" ":type hwnd: int\n" ":param width: window area width\n" @@ -331,13 +322,11 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() ":type presentInterval: Optional[int]\n" ":param adapter: video adapter index\n" ":type adapter: Optional[int]\n" - ":rtype: None" - ) - MAP_METHOD_AS_METHOD - ( + ":rtype: None" ) + MAP_METHOD_AS_METHOD( "CreateFullScreenDevice", - PyCreateFullScreenDevice, - "Create a simple full screen device.\n" + PyCreateFullScreenDevice, + "Create a simple full screen device.\n" ":param hwnd: A window handle\n" ":type hwnd: int\n" ":param width: window area width\n" @@ -348,25 +337,19 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() ":type height: Optional[int]\n" ":param presentInterval: presentation interval" ":type presentInterval: Optional[int]\n" - ":rtype: None" - ) - MAP_METHOD_AS_METHOD - ( + ":rtype: None" ) + MAP_METHOD_AS_METHOD( "CreateWindowlessDevice", - PyCreateWindowlessDevice, - "Create a simple device with no swap chain.\n" - ":rtype: None" - ) + PyCreateWindowlessDevice, + "Create a simple device with no swap chain.\n" + ":rtype: None" ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Render", PyRender, - "Renders the device." - ) + "Renders the device." ) - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "RegisterResource", PyRegisterResource, "Register a Python device resource which will get" @@ -377,10 +360,8 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() "\nno unregister call because the object will automatically unregister" "\nitself when it is destroyed in Python.\n" ":param resource: resource object\n" - ":rtype: None" - ) - MAP_METHOD_AS_METHOD - ( + ":rtype: None" ) + MAP_METHOD_AS_METHOD( "GetPickRayFromViewport", PyGetPickRayFromViewport, "Get a ray for picking in world coordinates from screen space, using the given viewport\n" @@ -395,106 +376,90 @@ const Be::ClassInfo* TriDevice::ExposeToBlue() ":type view: tuple[tuple[float]]\n" ":param proj: projection transform\n" ":type proj: tuple[tuple[float]]\n" - ":rtype: ((float, float, float), (float, float, float))" - ) + ":rtype: ((float, float, float), (float, float, float))" ) #endif - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "DoesD3DDeviceExist", DeviceExists, - "Returns true if TriDevice currently has a valid D3D Device." - ) + "Returns true if TriDevice currently has a valid D3D Device." ) #if BLUE_WITH_PYTHON - MAP_METHOD_AND_WRAP( - "RefreshDeviceResources", + MAP_METHOD_AND_WRAP( + "RefreshDeviceResources", RefreshDeviceResources, - "Releases all D3D resources from memory and recreates them from source." - ) + "Releases all D3D resources from memory and recreates them from source." ) #endif MAP_METHOD_AND_WRAP( "GetRenderContext", GetRenderContext, "TODO DEBUG" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetRenderingPlatformID", GetRenderingPlatformID, - "Returns an ID identifying the current rendering backend." - ) + "Returns an ID identifying the current rendering backend." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetRenderJobs", SetRenderJobs, "Set the Tr2RenderJobs objects on the device -- debug helper until we sort this out.\n" - ":param renderJobs: render jobs object" - ) + ":param renderJobs: render jobs object" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SupportsRenderTargetFormat", SupportsRenderTargetFormat, "Returns True if the device support render targets with the given pixel format\n" - ":param format: render target pixel format" - ) + ":param format: render target pixel format" ) MAP_METHOD_AND_WRAP( "IsVariableRefreshRateSupported", IsVariableRefreshRateSupported, - "Returns True if the device support variable refresh rate (gsync, freesync)" - ) + "Returns True if the device support variable refresh rate (gsync, freesync)" ) MAP_METHOD_AND_WRAP( "SetUpscaling", SetUpscaling, "Sets an upscaling technique on the device with the requested setting and framegeneration\n" - ":param technique: the technique to use (type Tr2UpscalingAL::Technique)\n" - ":param setting: the setting to use (type Tr2UpscalingAL::Setting)\n" - ":param frameGeneration: framegeneration on/off (type bool)" - ) + ":param technique: the technique to use (type Tr2UpscalingAL::Technique)\n" + ":param setting: the setting to use (type Tr2UpscalingAL::Setting)\n" + ":param frameGeneration: framegeneration on/off (type bool)" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "CreateUpscalingContext", CreateUpscalingContext, - 1, + 1, "Creates an upscaling context for the display resolution, if there is upscaling enabled\n" ":param displayWidth: the width of the display\n" - ":param displayHeight: the height of the display\n" - ":param pixelFormat: pixel format for the render target\n" - ":param depthFormat: pixel format for the depth buffer\n" - ":param existingContext: ID of the existing context to try to reuse for the new one. If it is not possible to\n" - " reuse the existing context it will be deleted before the new context is created\n" - ) + ":param displayHeight: the height of the display\n" + ":param pixelFormat: pixel format for the render target\n" + ":param depthFormat: pixel format for the depth buffer\n" + ":param existingContext: ID of the existing context to try to reuse for the new one. If it is not possible to\n" + " reuse the existing context it will be deleted before the new context is created\n" ) MAP_METHOD_AND_WRAP( "DeleteUpscalingContext", DeleteUpscalingContext, "Deletes an upscaling context \n" - ":param upscalingContextID: the id of the context to delete\n") + ":param upscalingContextID: the id of the context to delete\n" ) MAP_METHOD_AND_WRAP( "UpdateAvailableUpscalingTechniques", UpdateAvailableUpscalingTechniques, - "Updates the available upscaling techniques") + "Updates the available upscaling techniques" ) #if BLUE_WITH_PYTHON MAP_METHOD_AS_METHOD( "GetUpscalingInfo", PyGetUpscalingInfo, "Gets the upscaling context info for an upscaling id\n" - ":param upscalingContextID: the id of the context" - ) + ":param upscalingContextID: the id of the context" ) #endif MAP_METHOD_AND_WRAP( "GetRenderResolution", GetRenderResolution, "Gets the render resolution for the provided display resolution\n" - ":param displayWidth: the width of the display\n" - ":param displayHeight: the height of the display\n" - ) + ":param displayWidth: the width of the display\n" + ":param displayHeight: the height of the display\n" ) MAP_METHOD_AND_WRAP( "SupportsRaytracing", SupportsRaytracing, - "Returns True if the device supports raytracing" - ) + "Returns True if the device supports raytracing" ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/TriFloat.h b/trinity/TriFloat.h index ee6a1dfa9..dba40d27b 100644 --- a/trinity/TriFloat.h +++ b/trinity/TriFloat.h @@ -13,12 +13,12 @@ // a circular reference (stretch->curve set->binding->stretch). // Separating the length into its own object breaks the circle. -BLUE_CLASS( TriFloat ): - public IRoot +BLUE_CLASS( TriFloat ) : + public IRoot { public: - EXPOSE_TO_BLUE(); - TriFloat( IRoot* lockobj = NULL ); + EXPOSE_TO_BLUE(); + TriFloat( IRoot* lockobj = NULL ); float m_value; }; diff --git a/trinity/TriFloat_Blue.cpp b/trinity/TriFloat_Blue.cpp index 82d769c69..5143d72ff 100644 --- a/trinity/TriFloat_Blue.cpp +++ b/trinity/TriFloat_Blue.cpp @@ -7,10 +7,10 @@ BLUE_DEFINE( TriFloat ); const Be::ClassInfo* TriFloat::ExposeToBlue() { - EXPOSURE_BEGIN( TriFloat, "" ) - MAP_INTERFACE( TriFloat ) + EXPOSURE_BEGIN( TriFloat, "" ) + MAP_INTERFACE( TriFloat ) MAP_ATTRIBUTE( "value", m_value, "", Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/TriFrustum.cpp b/trinity/TriFrustum.cpp index ea4a2afcc..6c6be915d 100644 --- a/trinity/TriFrustum.cpp +++ b/trinity/TriFrustum.cpp @@ -9,8 +9,8 @@ bool g_frustumCullingDisabled = false; TRI_REGISTER_SETTING( "frustumCullingDisabled", g_frustumCullingDisabled ); -TriFrustum::TriFrustum() - :m_halfWidthProjection( 0 ), +TriFrustum::TriFrustum() : + m_halfWidthProjection( 0 ), m_zNear( 0 ), m_zFar( 0 ), m_aspectRatio( 1.0f ), @@ -36,12 +36,12 @@ void TriFrustum::DeriveFrustum( const Matrix* view, const Vector3* campos, const } void TriFrustum::ExtractFrustum( const Matrix* proj ) -{/** +{ /** proj - The projection matrix to extract a frustum from. */ #ifdef TRINITYDEV - if ( m_frustumTestCounter != 0 ) - m_frustumCullingRatio = (float)m_frustumRejectionCounter/(float)m_frustumTestCounter; + if( m_frustumTestCounter != 0 ) + m_frustumCullingRatio = (float)m_frustumRejectionCounter / (float)m_frustumTestCounter; m_frustumRejectionCounter = 0; m_frustumTestCounter = 0; #endif @@ -52,18 +52,18 @@ void TriFrustum::ExtractFrustum( const Matrix* proj ) // X->( (1/tan(fov/2))/aspectratio, 0, 0 ). You need to scale all the input values by the 1/tan, because when the 'fov' changes you want to see more. // We also want to make sure that the values are not stretched when the screen is not a perfect square. That is why // we like to scale the x values by the 1/aspectRatio. - // Y->( 0 1/tan(fov/2), 0 ) The Y values need scaling to, but they do not have to be changed by the aspect ratio because the aspect ratio is a scale relating the + // Y->( 0 1/tan(fov/2), 0 ) The Y values need scaling to, but they do not have to be changed by the aspect ratio because the aspect ratio is a scale relating the // size of 'Y' to x values. x/Y. // // Z->( 0, 0, dRatio, -near*dRatio ) The depth values get mapped to the z-buffer between the ranges of 0.0 - 1.0. To ensure that no values get divided by zero - // we use the near plane and store the actual z value in the w member of the output vector. No value get projected to 2D space before + // we use the near plane and store the actual z value in the w member of the output vector. No value get projected to 2D space before // the z-buffer test, so the projection matrix does not project anything. It basically just scales the values so they can be projected // in a simple homogeneous fashion, x/w, y/w, z/w by a frustum with a 90 degree fov. - // To map the depth values correctly to the z-buffer and make sure we don't divide by zero we subtract the near plane from the z-value, so - // if the z-value was behind the near plane the sign of the value would switch. Then we need to scale it back to where it was to get the + // To map the depth values correctly to the z-buffer and make sure we don't divide by zero we subtract the near plane from the z-value, so + // if the z-value was behind the near plane the sign of the value would switch. Then we need to scale it back to where it was to get the // correct z-buffer value. We want all our values to be mapped correctly between 0.0 - 1.0 where 0.0 is our near plane and 1.0 is our far plane. // So we can't just subtract the nearplane then divide that by the distance between the near and far plane, because than the depth values that - // would lie on or behind the farplane(by distance equal to the nearplane) would get drawn. So the value we need to scale the value back into place + // would lie on or behind the farplane(by distance equal to the nearplane) would get drawn. So the value we need to scale the value back into place // after we have subtracted the nearplane is the ratio between the distance to the farplane and the distance between the near and far plane. // *)dRatio = farplane/ (farplane - nearplane ) // *)zbuffer = z - nearplane*dRatio @@ -73,8 +73,8 @@ void TriFrustum::ExtractFrustum( const Matrix* proj ) // // W->( 0, 0, 1.0, 0 ) All this does is copy the depth value to the w member of the output vector. // - // So to extract the frustums we only need to add and subtract column vectors to get the normals. - + // So to extract the frustums we only need to add and subtract column vectors to get the normals. + // front // The normal of the near plane is the same as the w-component in the projection matrix m_planes[PLANE_FRONT].a = ( proj->_13 ); @@ -91,7 +91,7 @@ void TriFrustum::ExtractFrustum( const Matrix* proj ) m_planes[PLANE_TOP].b = ( proj->_24 - proj->_22 ); m_planes[PLANE_TOP].c = ( proj->_34 - proj->_32 ); m_planes[PLANE_TOP].d = ( proj->_44 - proj->_42 ); - //right + //right m_planes[PLANE_RIGHT].a = ( proj->_14 - proj->_11 ); m_planes[PLANE_RIGHT].b = ( proj->_24 - proj->_21 ); m_planes[PLANE_RIGHT].c = ( proj->_34 - proj->_31 ); @@ -111,8 +111,8 @@ void TriFrustum::ExtractFrustum( const Matrix* proj ) // The m33 component is the value that will scale the 'z' value back to correct place between 0 - farplane, after the distance to the nearplane has been subtracted from it. // The m33 tells us how much larger the distance of the farplane to the origin is compared to the distance from the farplane to the frontplane. m_planes[PLANE_BACK].d = ( proj->_44 - proj->_43 ); - - for (int i = 0; i < PLANE_COUNT; i++) + + for( int i = 0; i < PLANE_COUNT; i++ ) { m_planes[i] = Normalize( m_planes[i] ); } @@ -134,9 +134,9 @@ bool TriFrustum::IsSphereVisible( const Vector3& center, float radius, bool cull m_frustumTestCounter++; #endif // For some reason the old code ignored the back plane. I don't know why!! - for( int i = 0; i < (PLANE_COUNT - 1) + cullBackPlane; i++ ) + for( int i = 0; i < ( PLANE_COUNT - 1 ) + cullBackPlane; i++ ) { - if( DotCoord( m_planes[i], center ) < -radius ) + if( DotCoord( m_planes[i], center ) < -radius ) { #ifdef TRINITYDEV m_frustumRejectionCounter++; @@ -166,7 +166,7 @@ TriFrustumTestResult TriFrustum::SphereTest( const CcpMath::Sphere& sphere ) con } bool TriFrustum::IsPointVisible( const Vector3* point ) const -{/** +{ /** Wrapping the sphere visible with a radius of zero. */ Vector4 boundingSphere( *point, 0.f ); @@ -175,50 +175,50 @@ bool TriFrustum::IsPointVisible( const Vector3* point ) const // ------------------------------------------------------------- // Description: -// Tests for frustum-AABB intersection. May return false +// Tests for frustum-AABB intersection. May return false // positive answers. // Arguments: // boundsMin - Min bounds of AABB // boundsMax - Max bounds of AABB // Return Value: -// true If AABB intersects / is inside frustum +// true If AABB intersects / is inside frustum // false If AABB is outside frustum // ------------------------------------------------------------- bool TriFrustum::IsBoxVisible( const Vector3& boundsMin, const Vector3& boundsMax ) const { - Vector3 vmax; + Vector3 vmax; - for( int i = 0; i < 6; ++i ) - { - if( m_planes[i].a > 0 ) - { - vmax.x = boundsMax.x; + for( int i = 0; i < 6; ++i ) + { + if( m_planes[i].a > 0 ) + { + vmax.x = boundsMax.x; + } + else + { + vmax.x = boundsMin.x; + } + if( m_planes[i].b > 0 ) + { + vmax.y = boundsMax.y; + } + else + { + vmax.y = boundsMin.y; + } + if( m_planes[i].c > 0 ) + { + vmax.z = boundsMax.z; } - else - { - vmax.x = boundsMin.x; - } - if( m_planes[i].b > 0 ) - { - vmax.y = boundsMax.y; + else + { + vmax.z = boundsMin.z; } - else - { - vmax.y = boundsMin.y; - } - if( m_planes[i].c > 0 ) - { - vmax.z = boundsMax.z; - } - else - { - vmax.z = boundsMin.z; - } if( DotCoord( m_planes[i], vmax ) < 0 ) { - return false; + return false; } - } + } return true; } @@ -253,15 +253,15 @@ float TriFrustum::GetPixelSizeAccross( const Vector3& center, float radius ) con return std::numeric_limits::max(); } - float depth = m_viewDir.x*d.x + m_viewDir.y*d.y + m_viewDir.z*d.z; + float depth = m_viewDir.x * d.x + m_viewDir.y * d.y + m_viewDir.z * d.z; // clamp values close to zero and below const float epsilon = 1e-5f; - if ( depth < epsilon ) + if( depth < epsilon ) { depth = epsilon; } - if ( radius < epsilon ) + if( radius < epsilon ) { return 0.0f; } @@ -288,7 +288,7 @@ float TriFrustum::GetPixelSizeAccrossEst( const Vector3& center, float radius ) } //adjusted distance based on the visible part of the sphere, that properly goes to infinity as you enter the sphere. - float distance = sqrt( lengthSqrd - radiusSqrd ); + float distance = sqrt( lengthSqrd - radiusSqrd ); return ( radius / distance * m_halfWidthProjection * 2.0f ); } diff --git a/trinity/TriFrustum.h b/trinity/TriFrustum.h index 6390a94fc..8c5e1f3e6 100644 --- a/trinity/TriFrustum.h +++ b/trinity/TriFrustum.h @@ -16,7 +16,6 @@ enum class TriFrustumTestResult class TriFrustum { public: - enum { PLANE_FRONT = 0, @@ -27,11 +26,11 @@ class TriFrustum PLANE_BACK, PLANE_COUNT }; - - Plane m_planes[ PLANE_COUNT ]; + + Plane m_planes[PLANE_COUNT]; Matrix m_projectionMatrix; - Vector3 m_viewPos; + Vector3 m_viewPos; Vector3 m_viewDir; float m_halfWidthProjection; @@ -40,15 +39,15 @@ class TriFrustum float m_aspectRatio, m_fov; #ifdef TRINITYDEV - mutable int m_frustumTestCounter; - mutable int m_frustumRejectionCounter; + mutable int m_frustumTestCounter; + mutable int m_frustumRejectionCounter; float m_frustumCullingRatio; #endif TriFrustum(); // Extract frustum planes from the view and projection matrix in world coordinates void DeriveFrustum( const Matrix* view, const Vector3* campos, const Matrix* projection, const TriViewport& viewport ); - + // Returns true if any part of the sphere is inside the frustum bool IsSphereVisible( const Vector4* sphere, bool cullBackPlane = false ) const; bool IsSphereVisible( const Vector3& center, float radius, bool cullBackPlane = false ) const; diff --git a/trinity/TriFrustumOrtho.cpp b/trinity/TriFrustumOrtho.cpp index d0c7ae1e5..5106cfb2a 100644 --- a/trinity/TriFrustumOrtho.cpp +++ b/trinity/TriFrustumOrtho.cpp @@ -42,15 +42,15 @@ bool TriFrustumOrtho::IsSphereVisibleAndInsideNearPlane( const Vector3& center, if( pCenter[i] < pMin[i] ) { float a = pCenter[i] - pMin[i]; - d += a*a; + d += a * a; } else if( pCenter[i] > pMax[i] ) { float a = pCenter[i] - pMax[i]; - d += a*a; + d += a * a; } } - + float r2 = radius * radius; if( d > r2 ) { diff --git a/trinity/TriLineSet.cpp b/trinity/TriLineSet.cpp index e0bce9ef8..bab6933d3 100644 --- a/trinity/TriLineSet.cpp +++ b/trinity/TriLineSet.cpp @@ -5,7 +5,7 @@ #include "Shader/Tr2Effect.h" #include "Tr2Renderer.h" -#if !defined(D3DTARGET) || D3DTARGET == 9 +#if !defined( D3DTARGET ) || D3DTARGET == 9 // ------------------------------------------------------------------------------------------------------ // Description: @@ -17,17 +17,17 @@ // ------------------------------------------------------------------------------------------------------ inline unsigned SwizzleColor( unsigned color ) { - return ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); + return ( ( color & 0xff0000 ) >> 16 ) | ( color & 0xff00ff00 ) | ( ( color & 0xff ) << 16 ); } -TriLineSet::TriLineSet( IRoot* lockobj ) : +TriLineSet::TriLineSet( IRoot* lockobj ) : m_defaultColor( 0xffffffff ), m_zEnable( true ), m_transform( IdentityMatrix() ) { } -void TriLineSet::AddDefaultColor(const Vector3 &from, const Vector3 &to) +void TriLineSet::AddDefaultColor( const Vector3& from, const Vector3& to ) { size_t newSize = m_vertices.size() + 2; if( newSize > 100000 ) @@ -46,7 +46,7 @@ void TriLineSet::AddDefaultColor(const Vector3 &from, const Vector3 &to) vTo.m_color = SwizzleColor( m_defaultColor ); } -void TriLineSet::Add(const Vector3 &from, uint32_t colorFrom, const Vector3 &to, uint32_t colorTo ) +void TriLineSet::Add( const Vector3& from, uint32_t colorFrom, const Vector3& to, uint32_t colorTo ) { size_t newSize = m_vertices.size() + 2; if( newSize > 100000 ) @@ -55,7 +55,7 @@ void TriLineSet::Add(const Vector3 &from, uint32_t colorFrom, const Vector3 &to, } m_vertices.resize( newSize ); - + TriDebugResourceHelper::VertexPosColor& vFrom = m_vertices[newSize - 2]; vFrom.m_pos = from; vFrom.m_color = SwizzleColor( colorFrom ); @@ -86,7 +86,7 @@ void TriLineSet::AddSphere( const Vector3& center, float radius, int segments, u ++segments; } - float step = (XM_PI * 2.0f) / (float)segments; + float step = ( XM_PI * 2.0f ) / (float)segments; float halfStep = step * 0.5f; float curRadius = 0.0f; @@ -135,7 +135,6 @@ void TriLineSet::AddSphere( const Vector3& center, float radius, int segments, u nextTo.y = center.y + nextY; Add( from, color, nextTo, color ); - } curRadius = nextRadius; @@ -193,11 +192,11 @@ void TriLineSet::AddCylinder( const Vector3& start, const Vector3& end, float ra ++segments; } - float step = (XM_PI * 2.0f) / (float)segments; + float step = ( XM_PI * 2.0f ) / (float)segments; for( int i = 0; i < segments; ++i ) { - float x = cosf( i*step ); - float y = sinf( i*step ); + float x = cosf( i * step ); + float y = sinf( i * step ); Vector3 from( x, y, 0.0f ); Vector3 to( x, y, 1.0f ); @@ -209,8 +208,8 @@ void TriLineSet::AddCylinder( const Vector3& start, const Vector3& end, float ra Add( from, color, end, color ); Add( to, color, start, color ); - float x2 = cosf( i*step + step ); - float y2 = sinf( i*step + step); + float x2 = cosf( i * step + step ); + float y2 = sinf( i * step + step ); Vector3 from2( x2, y2, 0.0f ); Vector3 to2( x2, y2, 1.0f ); @@ -273,11 +272,11 @@ void TriLineSet::AddCone( const Vector3& start, const Vector3& end, float radius ++segments; } - float step = (XM_PI * 2.0f) / (float)segments; + float step = ( XM_PI * 2.0f ) / (float)segments; for( int i = 0; i < segments; ++i ) { - float x = cosf( i*step ); - float y = sinf( i*step ); + float x = cosf( i * step ); + float y = sinf( i * step ); Vector3 from( x, y, 0.0f ); Vector3 to( 0.0f, 0.0f, 1.0f ); @@ -289,8 +288,8 @@ void TriLineSet::AddCone( const Vector3& start, const Vector3& end, float radius Add( from, color, end, color ); Add( to, color, start, color ); - float x2 = cosf( i*step + step ); - float y2 = sinf( i*step + step); + float x2 = cosf( i * step + step ); + float y2 = sinf( i * step + step ); Vector3 from2( x2, y2, 0.0f ); Vector3 to2( 0.0f, 0.0f, 1.0f ); @@ -305,12 +304,12 @@ void TriLineSet::AddCone( const Vector3& start, const Vector3& end, float radius void TriLineSet::AddBox( const Vector3& min, const Vector3& max, uint32_t color ) { - Vector3 minA(max.x, min.y, min.z); - Vector3 minB(min.x, max.y, min.z); - Vector3 minC(max.x, max.y, min.z); - Vector3 maxA(max.x, min.y, max.z); - Vector3 maxB(min.x, max.y, max.z); - Vector3 maxC(min.x, min.y, max.z); + Vector3 minA( max.x, min.y, min.z ); + Vector3 minB( min.x, max.y, min.z ); + Vector3 minC( max.x, max.y, min.z ); + Vector3 maxA( max.x, min.y, max.z ); + Vector3 maxB( min.x, max.y, max.z ); + Vector3 maxC( min.x, min.y, max.z ); Add( min, color, minA, color ); Add( min, color, minB, color ); @@ -321,7 +320,7 @@ void TriLineSet::AddBox( const Vector3& min, const Vector3& max, uint32_t color Add( max, color, maxB, color ); Add( maxC, color, maxB, color ); Add( maxA, color, maxC, color ); - + Add( min, color, maxC, color ); Add( max, color, minC, color ); Add( minB, color, maxB, color ); @@ -330,12 +329,12 @@ void TriLineSet::AddBox( const Vector3& min, const Vector3& max, uint32_t color void TriLineSet::AddOrientedBox( const Matrix& transform, const Vector3& min, const Vector3& max, uint32_t color ) { - Vector3 minA(max.x, min.y, min.z); - Vector3 minB(min.x, max.y, min.z); - Vector3 minC(max.x, max.y, min.z); - Vector3 maxA(max.x, min.y, max.z); - Vector3 maxB(min.x, max.y, max.z); - Vector3 maxC(min.x, min.y, max.z); + Vector3 minA( max.x, min.y, min.z ); + Vector3 minB( min.x, max.y, min.z ); + Vector3 minC( max.x, max.y, min.z ); + Vector3 maxA( max.x, min.y, max.z ); + Vector3 maxB( min.x, max.y, max.z ); + Vector3 maxC( min.x, min.y, max.z ); AddTransformed( transform, min, color, minA, color ); AddTransformed( transform, min, color, minB, color ); @@ -346,7 +345,7 @@ void TriLineSet::AddOrientedBox( const Matrix& transform, const Vector3& min, co AddTransformed( transform, max, color, maxB, color ); AddTransformed( transform, maxC, color, maxB, color ); AddTransformed( transform, maxA, color, maxC, color ); - + AddTransformed( transform, min, color, maxC, color ); AddTransformed( transform, max, color, minC, color ); AddTransformed( transform, minB, color, maxB, color ); @@ -355,20 +354,20 @@ void TriLineSet::AddOrientedBox( const Matrix& transform, const Vector3& min, co void TriLineSet::AddOrientedBox( const Matrix& boxMatrix, uint32_t color ) { - Vector3 min ( -1.f, -1.f, -1.f ); - Vector3 minA( 1.f, -1.f, -1.f ); - Vector3 minB( -1.f, 1.f, -1.f ); - Vector3 minC( 1.f, 1.f, -1.f ); - Vector3 maxA( 1.f, -1.f, 1.f ); - Vector3 maxB( -1.f, 1.f, 1.f ); - Vector3 maxC( -1.f, -1.f, 1.f ); - Vector3 max ( 1.f, 1.f, 1.f ); - - min = TransformCoord( min, boxMatrix ); + Vector3 min( -1.f, -1.f, -1.f ); + Vector3 minA( 1.f, -1.f, -1.f ); + Vector3 minB( -1.f, 1.f, -1.f ); + Vector3 minC( 1.f, 1.f, -1.f ); + Vector3 maxA( 1.f, -1.f, 1.f ); + Vector3 maxB( -1.f, 1.f, 1.f ); + Vector3 maxC( -1.f, -1.f, 1.f ); + Vector3 max( 1.f, 1.f, 1.f ); + + min = TransformCoord( min, boxMatrix ); minA = TransformCoord( minA, boxMatrix ); minB = TransformCoord( minB, boxMatrix ); minC = TransformCoord( minC, boxMatrix ); - max = TransformCoord( max, boxMatrix ); + max = TransformCoord( max, boxMatrix ); maxA = TransformCoord( maxA, boxMatrix ); maxB = TransformCoord( maxB, boxMatrix ); maxC = TransformCoord( maxC, boxMatrix ); @@ -382,7 +381,7 @@ void TriLineSet::AddOrientedBox( const Matrix& boxMatrix, uint32_t color ) Add( max, color, maxB, color ); Add( maxC, color, maxB, color ); Add( maxA, color, maxC, color ); - + Add( min, color, maxC, color ); Add( max, color, minC, color ); Add( minB, color, maxB, color ); @@ -398,7 +397,7 @@ void TriLineSet::SetCurrentColor( uint32_t val ) { size_t numPoints = m_vertices.size(); val = SwizzleColor( val ); - for ( size_t i = 0; i < numPoints; i++ ) + for( size_t i = 0; i < numPoints; i++ ) { m_vertices[i].m_color = val; } diff --git a/trinity/TriLineSet.h b/trinity/TriLineSet.h index c969aa8b1..17c471551 100644 --- a/trinity/TriLineSet.h +++ b/trinity/TriLineSet.h @@ -14,7 +14,9 @@ BLUE_CLASS( TriLineSet ) : EXPOSE_TO_BLUE(); TriLineSet( IRoot* lockobj = 0 ); - ~TriLineSet(){} + ~TriLineSet() + { + } void AddDefaultColor( const Vector3& from, const Vector3& to ); void Add( const Vector3& from, uint32_t fromColor, const Vector3& to, uint32_t toColor ); @@ -33,25 +35,30 @@ BLUE_CLASS( TriLineSet ) : void Clear(); - void Render( Tr2RenderContext& renderContext ); + void Render( Tr2RenderContext & renderContext ); void RenderFromScript(); - void SubmitGeometry( Tr2RenderContext& renderContext ); - void SetDefaultColor( uint32_t val ) { m_defaultColor = val; } + void SubmitGeometry( Tr2RenderContext & renderContext ); + void SetDefaultColor( uint32_t val ) + { + m_defaultColor = val; + } void SetCurrentColor( uint32_t val ); - Matrix GetWorldTransform( void ) const { return m_transform; } + Matrix GetWorldTransform( void ) const + { + return m_transform; + } private: Matrix m_transform; uint32_t m_defaultColor; - bool m_zEnable; + bool m_zEnable; std::vector m_vertices; #if BLUE_WITH_PYTHON - PyObject* PyRender( PyObject* args ); + PyObject* PyRender( PyObject * args ); #endif }; -TYPEDEF_BLUECLASS(TriLineSet); -BLUE_DECLARE_VECTOR(TriLineSet); +TYPEDEF_BLUECLASS( TriLineSet ); +BLUE_DECLARE_VECTOR( TriLineSet ); #endif - diff --git a/trinity/TriLineSet_Blue.cpp b/trinity/TriLineSet_Blue.cpp index e550b284a..19740ed12 100644 --- a/trinity/TriLineSet_Blue.cpp +++ b/trinity/TriLineSet_Blue.cpp @@ -8,58 +8,42 @@ BLUE_DEFINE( TriLineSet ); const Be::ClassInfo* TriLineSet::ExposeToBlue() { - EXPOSURE_BEGIN(TriLineSet, "no comment") - MAP_INTERFACE(TriLineSet) - - MAP_METHOD_AND_WRAP("Add", Add, - "Add( to, tcolor, from, fcolor )\n" - ":param to: start position in world space.\n" - ":param color: integer value describing the color of the start of the line.\n" - ":param from_: end position in world space.\n" - ":param fcolor: integer value describing the color of the end of the line." - ) - - MAP_METHOD_AND_WRAP("AddLines", AddLines, - "AddLines(lines)\n" - "Add a list of lines to be drawn.\n" - ":param lines: The length of the list must be a multiple of two." - ) - - MAP_METHOD_AND_WRAP("AddSphere", AddSphere, - "AddSphere( center, radius, segments, color )\n" - ":param center: location in worldspace.\n" - ":param radius: float.\n" - ":param segments: how many longitude and latitude lines to draw.\n" - ":param color: integer value describing the color." - ) - - MAP_METHOD_AND_WRAP("AddBox", AddBox, - "AddBox( min, max, color )\n" - ":param min: minimum bounds in world space.\n" - ":param max: maximum bounds in world space.\n" - ":param color: integer value describing the color." - ) - - MAP_METHOD_AND_WRAP("Clear", Clear, - "Clear()\n" - "Clear all the lines from the render list." - ) - - MAP_METHOD_AND_WRAP("Render", RenderFromScript, - "Render()\n" - "Render all the lines in the render list.\n" - "This must Be called in a render callback." - ) - - MAP_METHOD_AND_WRAP("SetDefaultColor", SetDefaultColor, - "SetDefaultColor( color )\n" - ":param color: The default Color to use when none is specified." - ) - - MAP_METHOD_AND_WRAP("SetCurrentColor", SetCurrentColor, - "SetCurrentColor( color )\n" - ":param color: The current color of the lines." - ) + EXPOSURE_BEGIN( TriLineSet, "no comment" ) + MAP_INTERFACE( TriLineSet ) + + MAP_METHOD_AND_WRAP( "Add", Add, "Add( to, tcolor, from, fcolor )\n" + ":param to: start position in world space.\n" + ":param color: integer value describing the color of the start of the line.\n" + ":param from_: end position in world space.\n" + ":param fcolor: integer value describing the color of the end of the line." ) + + MAP_METHOD_AND_WRAP( "AddLines", AddLines, "AddLines(lines)\n" + "Add a list of lines to be drawn.\n" + ":param lines: The length of the list must be a multiple of two." ) + + MAP_METHOD_AND_WRAP( "AddSphere", AddSphere, "AddSphere( center, radius, segments, color )\n" + ":param center: location in worldspace.\n" + ":param radius: float.\n" + ":param segments: how many longitude and latitude lines to draw.\n" + ":param color: integer value describing the color." ) + + MAP_METHOD_AND_WRAP( "AddBox", AddBox, "AddBox( min, max, color )\n" + ":param min: minimum bounds in world space.\n" + ":param max: maximum bounds in world space.\n" + ":param color: integer value describing the color." ) + + MAP_METHOD_AND_WRAP( "Clear", Clear, "Clear()\n" + "Clear all the lines from the render list." ) + + MAP_METHOD_AND_WRAP( "Render", RenderFromScript, "Render()\n" + "Render all the lines in the render list.\n" + "This must Be called in a render callback." ) + + MAP_METHOD_AND_WRAP( "SetDefaultColor", SetDefaultColor, "SetDefaultColor( color )\n" + ":param color: The default Color to use when none is specified." ) + + MAP_METHOD_AND_WRAP( "SetCurrentColor", SetCurrentColor, "SetCurrentColor( color )\n" + ":param color: The current color of the lines." ) MAP_ATTRIBUTE( "transform", m_transform, "Transform to place and orient this lineset in the world", Be::READWRITE ) MAP_ATTRIBUTE( "zEnable", m_zEnable, "Enable z-test for rendering.", Be::READWRITE ) diff --git a/trinity/TriMath.cpp b/trinity/TriMath.cpp index 2daf92d75..424827e69 100644 --- a/trinity/TriMath.cpp +++ b/trinity/TriMath.cpp @@ -27,10 +27,9 @@ bool TriVectorIsIdentical( const Vector3* v1, const Vector3* v2, float epsilon ) } Vector3* TriVectorRotateQuaternion( - Vector3* out, + Vector3* out, const Vector3* v, - const Quaternion* q - ) + const Quaternion* q ) { // q*v*qcomplement, where we treat v as a pure quaternion @@ -49,9 +48,9 @@ Vector3* TriVectorRotateQuaternion( float zz = q->z * q->z; Vector3 temp; - temp.x = v->x*(ww + xx - yy - zz) + 2.0f*(v->y*(xy - wz) + v->z*(xz + wy)); - temp.y = v->y*(ww - xx + yy - zz) + 2.0f*(v->x*(xy + wz) + v->z*(yz - wx)); - temp.z = v->z*(ww - xx - yy + zz) + 2.0f*(v->x*(xz - wy) + v->y*(yz + wx)); + temp.x = v->x * ( ww + xx - yy - zz ) + 2.0f * ( v->y * ( xy - wz ) + v->z * ( xz + wy ) ); + temp.y = v->y * ( ww - xx + yy - zz ) + 2.0f * ( v->x * ( xy + wz ) + v->z * ( yz - wx ) ); + temp.z = v->z * ( ww - xx - yy + zz ) + 2.0f * ( v->x * ( xz - wy ) + v->y * ( yz + wx ) ); *out = temp; return out; } @@ -80,132 +79,124 @@ Vector3 TriVectorRotateToPlane( const Vector3& point, const Vector3& p0, const V } Vector3* TriVectorRotateMatrix( - Vector3* out, + Vector3* out, const Vector3* v, - const Matrix* m - ) + const Matrix* m ) { // can be optimized quite a lot by skipping the matrix op // that have to do with translation instead of cancelling them out Vector3 temp; - temp.x = v->x*m->_11 + v->y*m->_21 + v->z*m->_31; - temp.y = v->x*m->_12 +v->y*m->_22 +v->z*m->_32; - temp.z = v->x*m->_13 +v->y*m->_23 +v->z*m->_33; + temp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31; + temp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32; + temp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33; *out = temp; return out; } -//Rotate a unit vector aligned to one of the axes +//Rotate a unit vector aligned to one of the axes //(defined by xyz) by the quaternion //to understand this code, refer to TriVectorRotateQuaternion //10 multis, 11 adds opposed to 22 multis, 21 adds //the weird arrays are so we don't have to do switch-statements Vector3* TriVectorRotatedBasisQuaternion( - Vector3* out, + Vector3* out, const TRITRANSFORMAXIS xyz, - const Quaternion* q - ) + const Quaternion* q ) { float ww = q->w * q->w; //[-xx, -yy, -zz] - float SQ[] = {- q->x * q->x, - q->y * q->y, - q->z * q->z}; + float SQ[] = { -q->x * q->x, -q->y * q->y, -q->z * q->z }; //extend with q.x, q.y so we don't have to do modulo thingies with xyz - float QUAT[] = {q->x, q->y, q->z, q->x, q->y}; + float QUAT[] = { q->x, q->y, q->z, q->x, q->y }; //ok this is directly from TriVectorRotateQuaternion, just //substitute 1 into xyz and 0 into the other basis SQ[xyz] = -SQ[xyz]; float basis0 = ww + SQ[0] + SQ[1] + SQ[2]; - float basis1 = 2.0f*(QUAT[xyz]*QUAT[xyz+1] + q->w*QUAT[xyz+2]); - float basis2 = 2.0f*(QUAT[xyz]*QUAT[xyz+2] - q->w*QUAT[xyz+1]); + float basis1 = 2.0f * ( QUAT[xyz] * QUAT[xyz + 1] + q->w * QUAT[xyz + 2] ); + float basis2 = 2.0f * ( QUAT[xyz] * QUAT[xyz + 2] - q->w * QUAT[xyz + 1] ); //finally we have to select the correct axises into the correct components //reversed and extended so we don't have to do modulo thingies with xyz - float RET[] = {basis2, basis1, basis0, basis2, basis1}; - out->x = RET[xyz + 2]; + float RET[] = { basis2, basis1, basis0, basis2, basis1 }; + out->x = RET[xyz + 2]; out->y = RET[xyz + 1]; out->z = RET[xyz]; return out; } -//Rotate a unit vector aligned to one of the axes +//Rotate a unit vector aligned to one of the axes //(defined by xyz) by the matrix Vector3* TriVectorRotatedBasisMatrix( - Vector3* out, + Vector3* out, const TRITRANSFORMAXIS xyz, - const Matrix* m - ) + const Matrix* m ) { - *out = Vector3(m->m[xyz][0], m->m[xyz][1],m->m[xyz][2]); + *out = Vector3( m->m[xyz][0], m->m[xyz][1], m->m[xyz][2] ); return out; } -Vector3* TriVectorSpherical( - Vector3* v, +Vector3* TriVectorSpherical( + Vector3* v, float phi, float theta, - float rad - ) + float rad ) { - v->x = rad * sinf( phi ); - v->z = v->x * sinf( theta); - v->x *= cosf(theta); - v->y = rad * cosf( phi ); + v->x = rad * sinf( phi ); + v->z = v->x * sinf( theta ); + v->x *= cosf( theta ); + v->y = rad * cosf( phi ); return v; } -Vector3* TriVectorExponentialDecayInteger( - Vector3* pos, +Vector3* TriVectorExponentialDecayInteger( + Vector3* pos, const Vector3* x, const Vector3* v, const Vector3* a, const float m, const float k, - float t - ) -{ - *pos = *x + *a*t/k + m*(*v*k-*a)/(k*k)*(1.0f - powf(TRI_E, -k*t/m)); + float t ) +{ + *pos = *x + *a * t / k + m * ( *v * k - *a ) / ( k * k ) * ( 1.0f - powf( TRI_E, -k * t / m ) ); return pos; } -Vector3* TriVectorExponentialDecay( - Vector3* vel, +Vector3* TriVectorExponentialDecay( + Vector3* vel, const Vector3* v, const Vector3* a, const float m, const float k, - const float t - ) -{ - *vel = *a/k + (*v - *a/k)*(powf(TRI_E, -k*t/m)); + const float t ) +{ + *vel = *a / k + ( *v - *a / k ) * ( powf( TRI_E, -k * t / m ) ); return vel; } -Vector3* TriVectorExponentialDecayInteger( - Vector3* pos, +Vector3* TriVectorExponentialDecayInteger( + Vector3* pos, const Vector3* x, const Vector3* v, const Vector3* a, const float m, const float k, const float t, - const float pow - ) -{ - *pos = *x + *a*t/k + m*(*v*k-*a)/(k*k)*(1.0f - pow); + const float pow ) +{ + *pos = *x + *a * t / k + m * ( *v * k - *a ) / ( k * k ) * ( 1.0f - pow ); return pos; } -Vector3* TriVectorExponentialDecay( - Vector3* vel, +Vector3* TriVectorExponentialDecay( + Vector3* vel, const Vector3* v, const Vector3* a, const float k, - const float pow - ) -{ - *vel = *a/k + (*v - *a/k)*(pow); + const float pow ) +{ + *vel = *a / k + ( *v - *a / k ) * ( pow ); return vel; } @@ -244,23 +235,22 @@ float TriFloatRandomGauss( float mu, float deviation ) } rand1 = -2.f * log( rand1 ); float rand2 = TriFloatRandom01() * TRI_2PI; - return mu + deviation * pow( rand1, 0.75f ) * cos( rand2 ); + return mu + deviation * pow( rand1, 0.75f ) * cos( rand2 ); } ///////////////////////////////////////////////////////////////////////////////////////// // Color extensions ///////////////////////////////////////////////////////////////////////////////////////// -Color* TriColorFromVector( +Color* TriColorFromVector( Color* c, - const Vector3* v, - float height - ) + const Vector3* v, + float height ) { c->r = 0.5f * v->x + 0.5f; - c->g = 0.5f * v->y + 0.5f; - c->b = 0.5f * v->z + 0.5f; - c->a = height; + c->g = 0.5f * v->y + 0.5f; + c->b = 0.5f * v->z + 0.5f; + c->a = height; return c; } @@ -270,46 +260,43 @@ Color* TriColorFromVector( ///////////////////////////////////////////////////////////////////////////////////////// Quaternion* TriQuaternionDirVector( - Quaternion* out, - const Vector3* v - ) + Quaternion* out, + const Vector3* v ) { Vector3 nv = Normalize( *v ); - *out = Quaternion(nv.x, nv.y, nv.z, 0.0f); + *out = Quaternion( nv.x, nv.y, nv.z, 0.0f ); return out; } Quaternion* TriQuaternionScale( - Quaternion* out, + Quaternion* out, const Quaternion* in, - float length - ) + float length ) { - if (length == 1.0f) + if( length == 1.0f ) { *out = *in; return out; } - out->x = in->x*length; - out->y = in->y*length; - out->z = in->z*length; - out->w = in->w*length; + out->x = in->x * length; + out->y = in->y * length; + out->z = in->z * length; + out->w = in->w * length; return out; } Quaternion* TriQuaternionSqrt( - Quaternion* out, - const Quaternion* q1 - ) + Quaternion* out, + const Quaternion* q1 ) { Quaternion test = *q1; *out = *q1; float magic1 = out->w; float magic = 0.99999f; float magic2 = magic1 + magic; - if ( 0.0f > magic2) + if( 0.0f > magic2 ) { - Vector3 axis(out->x, out->y, out->z); + Vector3 axis( out->x, out->y, out->z ); axis *= 1000000.0f; axis = Normalize( axis ); if( LengthSq( axis ) < 0.5 ) @@ -339,145 +326,161 @@ Quaternion* TriQuaternionSqrt( } Quaternion* TriQuaternionRotationArc( - Quaternion* out, - const Vector3* v1, - const Vector3* v2 - ) + Quaternion* out, + const Vector3* v1, + const Vector3* v2 ) { - TriQuaternionDirVector(out,v1); + TriQuaternionDirVector( out, v1 ); Quaternion q1; - TriQuaternionDirVector(&q1,v2); + TriQuaternionDirVector( &q1, v2 ); q1 = Conjugate( q1 ); *out = *out * q1; - return TriQuaternionSqrt(out, out); + return TriQuaternionSqrt( out, out ); } Quaternion* TriQuaternionArcFromForward( - Quaternion* out, - const Vector3* v - ) + Quaternion* out, + const Vector3* v ) { Vector3 temp = Normalize( *v ); - if (temp.z < 0.99999f) + if( temp.z < 0.99999f ) { temp.z = 1.0f - temp.z; - temp.z = sqrtf(temp.z); - float div = 0.707106781187f/temp.z; - *out = Quaternion(temp.y*div, -temp.x*div, 0.0f, 0.707106781187f*temp.z); + temp.z = sqrtf( temp.z ); + float div = 0.707106781187f / temp.z; + *out = Quaternion( temp.y * div, -temp.x * div, 0.0f, 0.707106781187f * temp.z ); return out; } - *out = Quaternion(1.0f, 0.0f, 0.0f, 0.0f); + *out = Quaternion( 1.0f, 0.0f, 0.0f, 0.0f ); return out; - } -void TriQuaternionToYawPitchRoll ( - float* yaw, - float* pitch, - float* roll, - const Quaternion* q - ) +void TriQuaternionToYawPitchRoll( + float* yaw, + float* pitch, + float* roll, + const Quaternion* q ) { - + static float invSqrtOf2 = 0.70710678118654752440084436210485f; - //equivalent to q * (0,0,-1,0) * q^-1 - float y = 2.0f*(q->x*q->w - q->z*q->y); + //equivalent to q * (0,0,-1,0) * q^-1 + float y = 2.0f * ( q->x * q->w - q->z * q->y ); float w; { - float temp = 1.0f - y*y; - if (temp < 0.0f) temp = 0.0f; - w = sqrtf(temp); + float temp = 1.0f - y * y; + if( temp < 0.0f ) + temp = 0.0f; + w = sqrtf( temp ); } //precalculate for speed - float gamma = invSqrtOf2/sqrtf(w+1.0f); + float gamma = invSqrtOf2 / sqrtf( w + 1.0f ); - // q = qYaw*qPitch*qRoll + // q = qYaw*qPitch*qRoll // let qPitch be the quaternion that satisfies // a) y = z = 0 // b) qPitch * (0,0,-1,0) * qPitch^-1 = (0,0,y,0) //boring pre for asinf - if (fabs(y) < 1.0f){} - else if (y - 1.0f > 0.0f) y = 1.0f; - else if (y + 1.0f < 0.0f) y = -1.0f; - float phi = asinf(y); //unambigous + if( fabs( y ) < 1.0f ) + { + } + else if( y - 1.0f > 0.0f ) + y = 1.0f; + else if( y + 1.0f < 0.0f ) + y = -1.0f; + float phi = asinf( y ); //unambigous Quaternion qPitch; - qPitch.x = y*gamma; + qPitch.x = y * gamma; qPitch.y = 0.0f; qPitch.z = 0.0f; - qPitch.w = (w+1.0f)*gamma; + qPitch.w = ( w + 1.0f ) * gamma; //remove the pitch // ie get qYaw*qRoll Quaternion yawRoll; - //hmmm stuff gets messed up in denominator if y == +-1.0f + //hmmm stuff gets messed up in denominator if y == +-1.0f // well if y == +-1.0f we can take a short cut.... - if (fabs(fabs(y) - 1.0f) < 0.00001f) + if( fabs( fabs( y ) - 1.0f ) < 0.00001f ) { Quaternion combinedRoll; //use as temp combinedRoll = Conjugate( qPitch ); - combinedRoll = *q*combinedRoll; + combinedRoll = *q * combinedRoll; //boring pre for acos - if (fabs(combinedRoll.w) < 1.0f){} - else if (combinedRoll.w - 1.0f > 0.0f) combinedRoll.w = 1.0f; - else if (combinedRoll.w + 1.0f < 0.0f) combinedRoll.w = -1.0f; - float psi = 2.0f*acosf(combinedRoll.w); - if (psi > XM_PI) psi -= XM_PI*2.0f; - //sign(rollConZ) = -sign(yawRoll.z) - if (combinedRoll.z > 0.0f) - psi = - psi; + if( fabs( combinedRoll.w ) < 1.0f ) + { + } + else if( combinedRoll.w - 1.0f > 0.0f ) + combinedRoll.w = 1.0f; + else if( combinedRoll.w + 1.0f < 0.0f ) + combinedRoll.w = -1.0f; + float psi = 2.0f * acosf( combinedRoll.w ); + if( psi > XM_PI ) + psi -= XM_PI * 2.0f; + //sign(rollConZ) = -sign(yawRoll.z) + if( combinedRoll.z > 0.0f ) + psi = -psi; *yaw = 0.0f; *pitch = phi; *roll = -psi; return; } - float denominator = 1.0f/(qPitch.x*qPitch.x - qPitch.w*qPitch.w); - yawRoll.x = (q->w*qPitch.x - q->x*qPitch.w)*denominator; - yawRoll.y = -(q->z*qPitch.x + q->y*qPitch.w)*denominator; - yawRoll.z = -(q->z*qPitch.w + q->y*qPitch.x)*denominator; - yawRoll.w = (q->x*qPitch.x - q->w*qPitch.w)*denominator; + float denominator = 1.0f / ( qPitch.x * qPitch.x - qPitch.w * qPitch.w ); + yawRoll.x = ( q->w * qPitch.x - q->x * qPitch.w ) * denominator; + yawRoll.y = -( q->z * qPitch.x + q->y * qPitch.w ) * denominator; + yawRoll.z = -( q->z * qPitch.w + q->y * qPitch.x ) * denominator; + yawRoll.w = ( q->x * qPitch.x - q->w * qPitch.w ) * denominator; -/*************************************************************************************************/ + /*************************************************************************************************/ // Nonni this was causing div by Zero erros // I added handler which uses 0.0 in that case, please check - float divByZero = sqrtf(yawRoll.w*yawRoll.w + yawRoll.z*yawRoll.z); - float rollGamma = divByZero == 0.0 ? 0.0f : 1.0f/divByZero; -/*************************************************************************************************/ + float divByZero = sqrtf( yawRoll.w * yawRoll.w + yawRoll.z * yawRoll.z ); + float rollGamma = divByZero == 0.0 ? 0.0f : 1.0f / divByZero; + /*************************************************************************************************/ // this is the w part of qRoll // we don't need anything else - float rollConW = yawRoll.w*rollGamma; + float rollConW = yawRoll.w * rollGamma; //boring pre for acos - if (fabs(rollConW) < 1.0f){} - else if (rollConW - 1.0f > 0.0f) rollConW = 1.0f; - else if (rollConW + 1.0f < 0.0f) rollConW = -1.0f; - float psi = 2.0f*acosf(rollConW); - if (psi > XM_PI) psi -= XM_PI*2.0f; - //sign(rollConZ) = -sign(yawRoll.z) - if (yawRoll.z < 0.0f) - psi = - psi; + if( fabs( rollConW ) < 1.0f ) + { + } + else if( rollConW - 1.0f > 0.0f ) + rollConW = 1.0f; + else if( rollConW + 1.0f < 0.0f ) + rollConW = -1.0f; + float psi = 2.0f * acosf( rollConW ); + if( psi > XM_PI ) + psi -= XM_PI * 2.0f; + //sign(rollConZ) = -sign(yawRoll.z) + if( yawRoll.z < 0.0f ) + psi = -psi; //Now we are multiplying qYaw*qRoll with qRoll^-1 from the left //Leaving us with the qYaw - //yawRoll.y must be calculated before yawRoll.w because the original + //yawRoll.y must be calculated before yawRoll.w because the original //yawRoll.w is used in the calculation - yawRoll.y = (yawRoll.x*yawRoll.z + yawRoll.y*yawRoll.w)*rollGamma; - yawRoll.w = (yawRoll.z*yawRoll.z + yawRoll.w*yawRoll.w)*rollGamma; + yawRoll.y = ( yawRoll.x * yawRoll.z + yawRoll.y * yawRoll.w ) * rollGamma; + yawRoll.w = ( yawRoll.z * yawRoll.z + yawRoll.w * yawRoll.w ) * rollGamma; //boring pre for asin - if (fabs(yawRoll.y) < 1.0f){} - else if (yawRoll.y - 1.0f > 0.0f) yawRoll.y = 1.0f; - else if (yawRoll.y + 1.0f < 0.0f) yawRoll.y = -1.0f; - float theta = asinf(yawRoll.y); - if (yawRoll.w < 0.0f ) - theta = XM_PI - theta; - if (theta < 0.0f) theta += XM_PI; - - *yaw = theta*2.0f; + if( fabs( yawRoll.y ) < 1.0f ) + { + } + else if( yawRoll.y - 1.0f > 0.0f ) + yawRoll.y = 1.0f; + else if( yawRoll.y + 1.0f < 0.0f ) + yawRoll.y = -1.0f; + float theta = asinf( yawRoll.y ); + if( yawRoll.w < 0.0f ) + theta = XM_PI - theta; + if( theta < 0.0f ) + theta += XM_PI; + + *yaw = theta * 2.0f; *pitch = phi; *roll = psi; /* @@ -520,23 +523,40 @@ void TriQuaternionToYawPitchRoll ( // Matrix extensions ///////////////////////////////////////////////////////////////////////////////////////// -Matrix* TriMatrixTranspose(Matrix* out, const Matrix* in, unsigned int sizeInBytes) +Matrix* TriMatrixTranspose( Matrix* out, const Matrix* in, unsigned int sizeInBytes ) { float f; // transpose 2x2 parts out->_11 = in->_11; out->_22 = in->_22; - f = in->_12; out->_12 = in->_21; out->_21 = f; + f = in->_12; + out->_12 = in->_21; + out->_21 = f; // transpose 3x3 parts, but check if allowed to store! - f = in->_13; out->_13 = in->_31; if( sizeInBytes > 32 ) out->_31 = f; - f = in->_23; out->_23 = in->_32; if( sizeInBytes > 32 ) out->_32 = f; - f = in->_14; out->_14 = in->_41; if( sizeInBytes > 48 ) out->_41 = f; - f = in->_24; out->_24 = in->_42; if( sizeInBytes > 48 ) out->_42 = f; + f = in->_13; + out->_13 = in->_31; + if( sizeInBytes > 32 ) + out->_31 = f; + f = in->_23; + out->_23 = in->_32; + if( sizeInBytes > 32 ) + out->_32 = f; + f = in->_14; + out->_14 = in->_41; + if( sizeInBytes > 48 ) + out->_41 = f; + f = in->_24; + out->_24 = in->_42; + if( sizeInBytes > 48 ) + out->_42 = f; if( sizeInBytes > 32 ) { out->_33 = in->_33; - f = in->_34; out->_34 = in->_43; if( sizeInBytes > 48 ) out->_43 = f; + f = in->_34; + out->_34 = in->_43; + if( sizeInBytes > 48 ) + out->_43 = f; if( sizeInBytes > 48 ) { out->_44 = in->_44; @@ -547,7 +567,7 @@ Matrix* TriMatrixTranspose(Matrix* out, const Matrix* in, unsigned int sizeInByt } -Matrix* TriMatrixRotationArc( Matrix* out, const Vector3* v1, const Vector3* v2 ) +Matrix* TriMatrixRotationArc( Matrix* out, const Vector3* v1, const Vector3* v2 ) { // re-route it through quaternions Quaternion rotQuat; @@ -558,39 +578,39 @@ Matrix* TriMatrixRotationArc( Matrix* out, const Vector3* v1, const Vector3* v2 Matrix* TriMatrixArcFromForward( - Matrix* out, - const Vector3* v - ) + Matrix* out, + const Vector3* v ) { Vector3 norm = Normalize( *v ); *out = IdentityMatrix(); - if (norm.z < -0.99999f) + if( norm.z < -0.99999f ) { return out; } - if (norm.z > 0.99999f) + if( norm.z > 0.99999f ) { out->_22 = -1.0f; out->_33 = -1.0f; return out; } - const float h = (1.0f + norm.z)/(norm.x*norm.x + norm.y*norm.y); - out->_11 = h*norm.y*norm.y - norm.z; - out->_12 = -h*norm.x*norm.y; + const float h = ( 1.0f + norm.z ) / ( norm.x * norm.x + norm.y * norm.y ); + out->_11 = h * norm.y * norm.y - norm.z; + out->_12 = -h * norm.x * norm.y; out->_13 = norm.x; out->_21 = out->_12; - out->_22 = h*norm.x*norm.x - norm.z; + out->_22 = h * norm.x * norm.x - norm.z; out->_23 = norm.y; out->_31 = -norm.x; out->_32 = -norm.y; - out->_33 = -norm.z;; + out->_33 = -norm.z; + ; //*out = tempMat; return out; } -Matrix* TriMatrixTranslate(Matrix* out, const Matrix* m, const Vector3* v) +Matrix* TriMatrixTranslate( Matrix* out, const Matrix* m, const Vector3* v ) { *out = *m; out->_41 += v->x; @@ -599,16 +619,16 @@ Matrix* TriMatrixTranslate(Matrix* out, const Matrix* m, const Vector3* v) return out; } -Matrix* TriMatrixTranslate(Matrix* out, const Vector3* v, const Matrix* m) +Matrix* TriMatrixTranslate( Matrix* out, const Vector3* v, const Matrix* m ) { *out = *m; - out->_41 += v->x*out->_11 + v->y*out->_21 + v->z*out->_31; - out->_42 += v->x*out->_12 + v->y*out->_22 + v->z*out->_32; - out->_43 += v->x*out->_13 + v->y*out->_23 + v->z*out->_33; + out->_41 += v->x * out->_11 + v->y * out->_21 + v->z * out->_31; + out->_42 += v->x * out->_12 + v->y * out->_22 + v->z * out->_32; + out->_43 += v->x * out->_13 + v->y * out->_23 + v->z * out->_33; return out; } -Matrix* TriMatrixRotate(Matrix* out, const Matrix* m, const Quaternion* q) +Matrix* TriMatrixRotate( Matrix* out, const Matrix* m, const Quaternion* q ) { //we might be able to use a niftier way to do this later Matrix tmpResult = RotationMatrix( *q ); @@ -616,7 +636,7 @@ Matrix* TriMatrixRotate(Matrix* out, const Matrix* m, const Quaternion* q) return out; } -Matrix* TriMatrixRotate(Matrix* out, const Quaternion* q, const Matrix* m) +Matrix* TriMatrixRotate( Matrix* out, const Quaternion* q, const Matrix* m ) { //we might be able to use a niftier way to do this later Matrix tmpResult = RotationMatrix( *q ); @@ -624,7 +644,7 @@ Matrix* TriMatrixRotate(Matrix* out, const Quaternion* q, const Matrix* m) return out; } -Matrix* TriMatrixChangeBase(Matrix* out, const Vector3* fwd, const Vector3* up) +Matrix* TriMatrixChangeBase( Matrix* out, const Vector3* fwd, const Vector3* up ) { Vector3 cross = Cross( *up, *fwd ); out->_11 = cross.x; @@ -723,7 +743,8 @@ double* Matrix4dInvert( double* result, const double* mat ) double src[16]; /* array of transpose source matrix */ double det; /* determinant */ /* transpose matrix */ - for (int i = 0; i < 4; i++) { + for( int i = 0; i < 4; i++ ) + { src[i] = mat[i * 4]; src[i + 4] = mat[i * 4 + 1]; src[i + 8] = mat[i * 4 + 2]; @@ -743,57 +764,57 @@ double* Matrix4dInvert( double* result, const double* mat ) tmp[10] = src[8] * src[13]; tmp[11] = src[9] * src[12]; /* calculate first 8 elements (cofactors) */ - result[0] = tmp[0]*src[5] + tmp[3]*src[6] + tmp[4]*src[7]; - result[0] -= tmp[1]*src[5] + tmp[2]*src[6] + tmp[5]*src[7]; - result[1] = tmp[1]*src[4] + tmp[6]*src[6] + tmp[9]*src[7]; - result[1] -= tmp[0]*src[4] + tmp[7]*src[6] + tmp[8]*src[7]; - result[2] = tmp[2]*src[4] + tmp[7]*src[5] + tmp[10]*src[7]; - result[2] -= tmp[3]*src[4] + tmp[6]*src[5] + tmp[11]*src[7]; - result[3] = tmp[5]*src[4] + tmp[8]*src[5] + tmp[11]*src[6]; - result[3] -= tmp[4]*src[4] + tmp[9]*src[5] + tmp[10]*src[6]; - result[4] = tmp[1]*src[1] + tmp[2]*src[2] + tmp[5]*src[3]; - result[4] -= tmp[0]*src[1] + tmp[3]*src[2] + tmp[4]*src[3]; - result[5] = tmp[0]*src[0] + tmp[7]*src[2] + tmp[8]*src[3]; - result[5] -= tmp[1]*src[0] + tmp[6]*src[2] + tmp[9]*src[3]; - result[6] = tmp[3]*src[0] + tmp[6]*src[1] + tmp[11]*src[3]; - result[6] -= tmp[2]*src[0] + tmp[7]*src[1] + tmp[10]*src[3]; - result[7] = tmp[4]*src[0] + tmp[9]*src[1] + tmp[10]*src[2]; - result[7] -= tmp[5]*src[0] + tmp[8]*src[1] + tmp[11]*src[2]; + result[0] = tmp[0] * src[5] + tmp[3] * src[6] + tmp[4] * src[7]; + result[0] -= tmp[1] * src[5] + tmp[2] * src[6] + tmp[5] * src[7]; + result[1] = tmp[1] * src[4] + tmp[6] * src[6] + tmp[9] * src[7]; + result[1] -= tmp[0] * src[4] + tmp[7] * src[6] + tmp[8] * src[7]; + result[2] = tmp[2] * src[4] + tmp[7] * src[5] + tmp[10] * src[7]; + result[2] -= tmp[3] * src[4] + tmp[6] * src[5] + tmp[11] * src[7]; + result[3] = tmp[5] * src[4] + tmp[8] * src[5] + tmp[11] * src[6]; + result[3] -= tmp[4] * src[4] + tmp[9] * src[5] + tmp[10] * src[6]; + result[4] = tmp[1] * src[1] + tmp[2] * src[2] + tmp[5] * src[3]; + result[4] -= tmp[0] * src[1] + tmp[3] * src[2] + tmp[4] * src[3]; + result[5] = tmp[0] * src[0] + tmp[7] * src[2] + tmp[8] * src[3]; + result[5] -= tmp[1] * src[0] + tmp[6] * src[2] + tmp[9] * src[3]; + result[6] = tmp[3] * src[0] + tmp[6] * src[1] + tmp[11] * src[3]; + result[6] -= tmp[2] * src[0] + tmp[7] * src[1] + tmp[10] * src[3]; + result[7] = tmp[4] * src[0] + tmp[9] * src[1] + tmp[10] * src[2]; + result[7] -= tmp[5] * src[0] + tmp[8] * src[1] + tmp[11] * src[2]; /* calculate pairs for second 8 elements (cofactors) */ - tmp[0] = src[2]*src[7]; - tmp[1] = src[3]*src[6]; - tmp[2] = src[1]*src[7]; - tmp[3] = src[3]*src[5]; - tmp[4] = src[1]*src[6]; - tmp[5] = src[2]*src[5]; - tmp[6] = src[0]*src[7]; - tmp[7] = src[3]*src[4]; - tmp[8] = src[0]*src[6]; - tmp[9] = src[2]*src[4]; - tmp[10] = src[0]*src[5]; - tmp[11] = src[1]*src[4]; + tmp[0] = src[2] * src[7]; + tmp[1] = src[3] * src[6]; + tmp[2] = src[1] * src[7]; + tmp[3] = src[3] * src[5]; + tmp[4] = src[1] * src[6]; + tmp[5] = src[2] * src[5]; + tmp[6] = src[0] * src[7]; + tmp[7] = src[3] * src[4]; + tmp[8] = src[0] * src[6]; + tmp[9] = src[2] * src[4]; + tmp[10] = src[0] * src[5]; + tmp[11] = src[1] * src[4]; /* calculate second 8 elements (cofactors) */ - result[8] = tmp[0]*src[13] + tmp[3]*src[14] + tmp[4]*src[15]; - result[8] -= tmp[1]*src[13] + tmp[2]*src[14] + tmp[5]*src[15]; - result[9] = tmp[1]*src[12] + tmp[6]*src[14] + tmp[9]*src[15]; - result[9] -= tmp[0]*src[12] + tmp[7]*src[14] + tmp[8]*src[15]; - result[10] = tmp[2]*src[12] + tmp[7]*src[13] + tmp[10]*src[15]; - result[10]-= tmp[3]*src[12] + tmp[6]*src[13] + tmp[11]*src[15]; - result[11] = tmp[5]*src[12] + tmp[8]*src[13] + tmp[11]*src[14]; - result[11]-= tmp[4]*src[12] + tmp[9]*src[13] + tmp[10]*src[14]; - result[12] = tmp[2]*src[10] + tmp[5]*src[11] + tmp[1]*src[9]; - result[12]-= tmp[4]*src[11] + tmp[0]*src[9] + tmp[3]*src[10]; - result[13] = tmp[8]*src[11] + tmp[0]*src[8] + tmp[7]*src[10]; - result[13]-= tmp[6]*src[10] + tmp[9]*src[11] + tmp[1]*src[8]; - result[14] = tmp[6]*src[9] + tmp[11]*src[11] + tmp[3]*src[8]; - result[14]-= tmp[10]*src[11] + tmp[2]*src[8] + tmp[7]*src[9]; - result[15] = tmp[10]*src[10] + tmp[4]*src[8] + tmp[9]*src[9]; - result[15]-= tmp[8]*src[9] + tmp[11]*src[10] + tmp[5]*src[8]; + result[8] = tmp[0] * src[13] + tmp[3] * src[14] + tmp[4] * src[15]; + result[8] -= tmp[1] * src[13] + tmp[2] * src[14] + tmp[5] * src[15]; + result[9] = tmp[1] * src[12] + tmp[6] * src[14] + tmp[9] * src[15]; + result[9] -= tmp[0] * src[12] + tmp[7] * src[14] + tmp[8] * src[15]; + result[10] = tmp[2] * src[12] + tmp[7] * src[13] + tmp[10] * src[15]; + result[10] -= tmp[3] * src[12] + tmp[6] * src[13] + tmp[11] * src[15]; + result[11] = tmp[5] * src[12] + tmp[8] * src[13] + tmp[11] * src[14]; + result[11] -= tmp[4] * src[12] + tmp[9] * src[13] + tmp[10] * src[14]; + result[12] = tmp[2] * src[10] + tmp[5] * src[11] + tmp[1] * src[9]; + result[12] -= tmp[4] * src[11] + tmp[0] * src[9] + tmp[3] * src[10]; + result[13] = tmp[8] * src[11] + tmp[0] * src[8] + tmp[7] * src[10]; + result[13] -= tmp[6] * src[10] + tmp[9] * src[11] + tmp[1] * src[8]; + result[14] = tmp[6] * src[9] + tmp[11] * src[11] + tmp[3] * src[8]; + result[14] -= tmp[10] * src[11] + tmp[2] * src[8] + tmp[7] * src[9]; + result[15] = tmp[10] * src[10] + tmp[4] * src[8] + tmp[9] * src[9]; + result[15] -= tmp[8] * src[9] + tmp[11] * src[10] + tmp[5] * src[8]; /* calculate determinant */ - det=src[0]*result[0]+src[1]*result[1]+src[2]*result[2]+src[3]*result[3]; + det = src[0] * result[0] + src[1] * result[1] + src[2] * result[2] + src[3] * result[3]; /* calculate matrix inverse */ - det = 1.0 /det; - for (int j = 0; j < 16; j++) + det = 1.0 / det; + for( int j = 0; j < 16; j++ ) { result[j] *= det; } @@ -807,7 +828,7 @@ double* Matrix4dMultiply( double* result, double* m0, double* m1 ) { for( int c = 0; c < 4; c++ ) { - result[r*4 + c] = m0[r*4] * m1[c] + m0[r*4+1] * m1[c+4] + m0[r*4+2] * m1[c+8] + m0[r*4+3] * m1[c+12]; + result[r * 4 + c] = m0[r * 4] * m1[c] + m0[r * 4 + 1] * m1[c + 4] + m0[r * 4 + 2] * m1[c + 8] + m0[r * 4 + 3] * m1[c + 12]; } } return result; @@ -825,8 +846,7 @@ Vector4d Matrix4dTransform( Vector4d point, double* mat ) point.x * mat[0] + point.y * mat[4] + point.z * mat[8] + point.w * mat[12], point.x * mat[1] + point.y * mat[5] + point.z * mat[9] + point.w * mat[13], point.x * mat[2] + point.y * mat[6] + point.z * mat[10] + point.w * mat[14], - point.x * mat[3] + point.y * mat[7] + point.z * mat[11] + point.w * mat[15] - ); + point.x * mat[3] + point.y * mat[7] + point.z * mat[11] + point.w * mat[15] ); } @@ -837,7 +857,7 @@ Matrix Matrix4dToMatrix( double* mat ) { for( int c = 0; c < 4; c++ ) { - m.m[r][c] = (float)mat[r*4 + c]; + m.m[r][c] = (float)mat[r * 4 + c]; } } return m; @@ -850,7 +870,7 @@ double* Matrix4dFromMatrix( double* result, const Matrix& mat ) { for( int c = 0; c < 4; c++ ) { - result[r*4 + c] = mat.m[r][c]; + result[r * 4 + c] = mat.m[r][c]; } } return result; @@ -863,9 +883,9 @@ double* Matrix4dFromMatrix( double* result, const Matrix& mat ) ///////////////////////////////////////////////////////////////////////////////////////// bool IsFinite( float value ) { - return value == value && - value != std::numeric_limits::infinity() && - value != -std::numeric_limits::infinity(); + return value == value && + value != std::numeric_limits::infinity() && + value != -std::numeric_limits::infinity(); } bool IsFinite( const Vector3& vec ) @@ -876,8 +896,7 @@ bool IsFinite( const Vector3& vec ) float TriClamp( float f, float min, - float max - ) + float max ) { return ( f < min ) ? min : ( ( f > max ) ? max : f ); } @@ -885,8 +904,7 @@ float TriClamp( int32_t ClampInt( int32_t f, int32_t min, - int32_t max - ) + int32_t max ) { return ( f < min ) ? min : ( ( f > max ) ? max : f ); } @@ -900,12 +918,11 @@ uint32_t ClampUInt( } float Lerp( - float min, - float max, - float s - ) + float min, + float max, + float s ) { - return min + s * (max - min); + return min + s * ( max - min ); } float Hermite( @@ -914,22 +931,21 @@ float Hermite( float v2, float l, float t, - float dt - ) + float dt ) { // minimize number of math operations for max speed: - float _1_T = 1.0f / dt; - float _1_T2 = _1_T * _1_T; - float t2 = t * t; - float t2_T = t2 * _1_T; - float t3_T2 = t2 * t * _1_T2; - float _2t3_T3 = 2.0f * t3_T2 * _1_T; - float _3t2_T2 = 3.0f * t2 * _1_T2; - - return ( v1 * ( _2t3_T3 - _3t2_T2 + 1.0f ) + - v2 * ( - _2t3_T3 + _3t2_T2 ) + - r * ( t3_T2 - t2_T - t2_T + t ) + - l * ( t3_T2 - t2_T ) ); + float _1_T = 1.0f / dt; + float _1_T2 = _1_T * _1_T; + float t2 = t * t; + float t2_T = t2 * _1_T; + float t3_T2 = t2 * t * _1_T2; + float _2t3_T3 = 2.0f * t3_T2 * _1_T; + float _3t2_T2 = 3.0f * t2 * _1_T2; + + return ( v1 * ( _2t3_T3 - _3t2_T2 + 1.0f ) + + v2 * ( -_2t3_T3 + _3t2_T2 ) + + r * ( t3_T2 - t2_T - t2_T + t ) + + l * ( t3_T2 - t2_T ) ); } float TriLinearize( float min, float max, float v ) @@ -938,16 +954,15 @@ float TriLinearize( float min, float max, float v ) } float SinSmooth( - float f - ) + float f ) { - float ret = f*XM_PI - XM_PI/2.0f; - return sinf(ret)/2.0f + 0.5f; + float ret = f * XM_PI - XM_PI / 2.0f; + return sinf( ret ) / 2.0f + 0.5f; } float CubicInterpolate( float pm1, float p0, float p1, float p2, float s ) -{ - return p0 + 0.5f * s*(p1 - pm1 + s*(2.f*pm1 - 5.f*p0 + 4.f*p1 - p2 + s*(3.f*(p0 - p1) + p2 - pm1))); +{ + return p0 + 0.5f * s * ( p1 - pm1 + s * ( 2.f * pm1 - 5.f * p0 + 4.f * p1 - p2 + s * ( 3.f * ( p0 - p1 ) + p2 - pm1 ) ) ); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -956,7 +971,7 @@ float CubicInterpolate( float pm1, float p0, float p1, float p2, float s ) uint32_t jran = 1234; void TriSrand( Be::Time seed ) { - jran = uint32_t(seed) % 714025; + jran = uint32_t( seed ) % 714025; }; void TriSrand( uint32_t seed ) @@ -969,23 +984,23 @@ float TriRand() jran <<= 12; jran += 150889; jran %= 714025; - return float(jran)/714025.0f; + return float( jran ) / 714025.0f; }; -int TriRandInt(int hi) +int TriRandInt( int hi ) { jran <<= 12; jran += 150889; jran %= 714025; - return (hi*jran)/714025; + return ( hi * jran ) / 714025; }; -int TriRandInt(int lo, int hi) +int TriRandInt( int lo, int hi ) { jran <<= 12; jran += 150889; jran %= 714025; - return ((hi - lo)*jran)/714025 + lo; + return ( ( hi - lo ) * jran ) / 714025 + lo; }; int TriRandGetSeed() @@ -1085,4 +1100,3 @@ bool ConvertProjectionCoordToWorldPickRay( float x, float y, const Matrix* projM return true; } - diff --git a/trinity/TriMatrix.cpp b/trinity/TriMatrix.cpp index ea51ba957..e9d16d0a5 100644 --- a/trinity/TriMatrix.cpp +++ b/trinity/TriMatrix.cpp @@ -11,49 +11,56 @@ // IPythonMethods Impl ///////////////////////////////////////////////////////////////////////////////////////// -void TriMatrix::Destroy( - ) +void TriMatrix::Destroy() { //delete this; } -PyObject* TriMatrix::GetAttr( - const char* name, - bool* handled - ) +PyObject* TriMatrix::GetAttr( + const char* name, + bool* handled ) { return 0; } bool TriMatrix::SetAttr( - const char* name, - PyObject* v, - bool* handled - ) + const char* name, + PyObject* v, + bool* handled ) { return true; } PyObject* TriMatrix::Repr( - bool* handled - ) + bool* handled ) { *handled = true; char buf[256]; - sprintf_s(buf, "", - _11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44 - ); - return ToPython(buf); + sprintf_s( buf, "", + _11, + _12, + _13, + _14, + _21, + _22, + _23, + _24, + _31, + _32, + _33, + _34, + _41, + _42, + _43, + _44 ); + return ToPython( buf ); } #endif @@ -62,12 +69,24 @@ PyObject* TriMatrix::Repr( // TriMatrix ///////////////////////////////////////////////////////////////////////////////////////// -TriMatrix::TriMatrix(IRoot* lockobj) : +TriMatrix::TriMatrix( IRoot* lockobj ) : Matrix( - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f) + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + 1.0f ) { } @@ -82,104 +101,126 @@ TriMatrix::~TriMatrix() ///////////////////////////////////////////////////////////////////////////////////////// void TriMatrix::SetPivots( - float _11_, float _12_, float _13_, float _14_, - float _21_, float _22_, float _23_, float _24_, - float _31_, float _32_, float _33_, float _34_, - float _41_, float _42_, float _43_, float _44_ - ) + float _11_, + float _12_, + float _13_, + float _14_, + float _21_, + float _22_, + float _23_, + float _24_, + float _31_, + float _32_, + float _33_, + float _34_, + float _41_, + float _42_, + float _43_, + float _44_ ) { - _11 = _11_; _12 = _12_; _13 = _13_; _14 = _14_; - _21 = _21_; _22 = _22_; _23 = _23_; _24 = _24_; - _31 = _31_; _32 = _32_; _33 = _33_; _34 = _34_; - _41 = _41_; _42 = _42_; _43 = _43_; _44 = _44_; + _11 = _11_; + _12 = _12_; + _13 = _13_; + _14 = _14_; + _21 = _21_; + _22 = _22_; + _23 = _23_; + _24 = _24_; + _31 = _31_; + _32 = _32_; + _33 = _33_; + _34 = _34_; + _41 = _41_; + _42 = _42_; + _43 = _43_; + _44 = _44_; } void TriMatrix::SetMatrix( - const Matrix* m - ) + const Matrix* m ) { - _11 = m->_11; _12 = m->_12; _13 = m->_13; _14 = m->_14; - _21 = m->_21; _22 = m->_22; _23 = m->_23; _24 = m->_24; - _31 = m->_31; _32 = m->_32; _33 = m->_33; _34 = m->_34; - _41 = m->_41; _42 = m->_42; _43 = m->_43; _44 = m->_44; - + _11 = m->_11; + _12 = m->_12; + _13 = m->_13; + _14 = m->_14; + _21 = m->_21; + _22 = m->_22; + _23 = m->_23; + _24 = m->_24; + _31 = m->_31; + _32 = m->_32; + _33 = m->_33; + _34 = m->_34; + _41 = m->_41; + _42 = m->_42; + _43 = m->_43; + _44 = m->_44; } -const Matrix* TriMatrix::GetMatrix( - ) const +const Matrix* TriMatrix::GetMatrix() const { return this; } Matrix* TriMatrix::CopyMatrix( - Matrix* in - ) const + Matrix* in ) const { *in = *this; return in; } -float TriMatrix::Determinant( - ) +float TriMatrix::Determinant() { return ::Determinant( *this ); } -void TriMatrix::Identity( -) +void TriMatrix::Identity() { static_cast( *this ) = IdentityMatrix(); } -float TriMatrix::Inverse( - ) +float TriMatrix::Inverse() { float ret; ::Inverse( *this, ret, Matrix( *this ) ); return ret; } -void TriMatrix::LookAtRH( +void TriMatrix::LookAtRH( const Vector3* pEye, const Vector3* pAt, - const Vector3* pUp - ) + const Vector3* pUp ) { *static_cast( this ) = LookAtMatrix( *pEye, *pAt, *pUp ); } -void TriMatrix::Multiply( - const Matrix* pM2 - ) +void TriMatrix::Multiply( + const Matrix* pM2 ) { *static_cast( this ) = *this * *pM2; } -void TriMatrix::RotationAxis( +void TriMatrix::RotationAxis( const Vector3* pV, - float Angle - ) + float Angle ) { *static_cast( this ) = RotationMatrix( *pV, Angle ); } -void TriMatrix::RotationQuaternion( - const Quaternion* pQ - ) +void TriMatrix::RotationQuaternion( + const Quaternion* pQ ) { *static_cast( this ) = RotationMatrix( *pQ ); } -void TriMatrix::RotationX( - float Angle - ) +void TriMatrix::RotationX( + float Angle ) { *static_cast( this ) = RotationXMatrix( Angle ); } void TriMatrix::RotationY( - float Angle - ) + float Angle ) { *static_cast( this ) = RotationYMatrix( Angle ); } @@ -187,36 +228,32 @@ void TriMatrix::RotationY( void TriMatrix::RotationYawPitchRoll( float Yaw, float Pitch, - float Roll - ) + float Roll ) { *static_cast( this ) = RotationMatrix( ::RotationQuaternion( Yaw, Pitch, Roll ) ); } void TriMatrix::RotationZ( - float Angle - ) + float Angle ) { *static_cast( this ) = RotationZMatrix( Angle ); } -void TriMatrix::Scaling( +void TriMatrix::Scaling( float sx, float sy, - float sz - ) + float sz ) { *static_cast( this ) = ScalingMatrix( sx, sy, sz ); } -void TriMatrix::Transformation( +void TriMatrix::Transformation( const Vector3* pScalingCenter, const Quaternion* pScalingRotation, const Vector3* pScaling, const Vector3* pRotationCenter, const Quaternion* pRotation, - const Vector3* pTranslation - ) + const Vector3* pTranslation ) { *static_cast( this ) = TransformationMatrix( pScalingCenter, @@ -224,20 +261,18 @@ void TriMatrix::Transformation( pScaling, pRotationCenter, pRotation, - pTranslation); + pTranslation ); } -void TriMatrix::Translation( +void TriMatrix::Translation( float x, float y, - float z - ) + float z ) { *static_cast( this ) = TranslationMatrix( x, y, z ); } -void TriMatrix::Transpose( - ) +void TriMatrix::Transpose() { *static_cast( this ) = ::Transpose( *this ); } @@ -249,23 +284,18 @@ void TriMatrix::Transpose( ///////////////////////////////////////////////////////////////////////////////////////// PyObject* TriMatrix::Py__init__( - PyObject* args - ) -{ - if (!PyArg_ParseTuple(args, "|ffffffffffffffff", - &_11, &_12, &_13, &_14, - &_21, &_22, &_23, &_24, - &_31, &_32, &_33, &_34, - &_41, &_42, &_43, &_44)) - return NULL; - - Py_INCREF(Py_None); + PyObject* args ) +{ + if( !PyArg_ParseTuple( args, "|ffffffffffffffff", &_11, &_12, &_13, &_14, &_21, &_22, &_23, &_24, &_31, &_32, &_33, &_34, &_41, &_42, &_43, &_44 ) ) + return NULL; + + Py_INCREF( Py_None ); return Py_None; } #endif -void TriMatrix::PyLookAtRH( ITriVector* eye, ITriVector* at, ITriVector* up ) +void TriMatrix::PyLookAtRH( ITriVector* eye, ITriVector* at, ITriVector* up ) { LookAtRH( eye->GetVector(), @@ -288,7 +318,7 @@ void TriMatrix::PyRotationQuaternion( ITriQuaternion* quaternion ) RotationQuaternion( quaternion->GetQuaternion() ); } -void TriMatrix::PyTransformation( +void TriMatrix::PyTransformation( ITriVector* scalingCenter, ITriQuaternion* scalingRotation, ITriVector* scaling, @@ -302,5 +332,5 @@ void TriMatrix::PyTransformation( scaling->GetVector(), rotationCenter->GetVector(), rotation->GetQuaternion(), - translation->GetVector() ); + translation->GetVector() ); } diff --git a/trinity/TriMatrix_Blue.cpp b/trinity/TriMatrix_Blue.cpp index 27f70629d..c99351411 100644 --- a/trinity/TriMatrix_Blue.cpp +++ b/trinity/TriMatrix_Blue.cpp @@ -9,10 +9,10 @@ BLUE_DEFINE( TriMatrix ); const Be::ClassInfo* TriMatrix::ExposeToBlue() { - EXPOSURE_BEGIN(TriMatrix, TRIMATRIX_Description) - MAP_INTERFACE(ITriMatrix) + EXPOSURE_BEGIN( TriMatrix, TRIMATRIX_Description ) + MAP_INTERFACE( ITriMatrix ) #if BLUE_WITH_PYTHON - MAP_INTERFACE(IPythonMethods) + MAP_INTERFACE( IPythonMethods ) #endif MAP_ATTRIBUTE( "_11", _11, "", Be::READWRITE | Be::PERSIST ) @@ -34,147 +34,114 @@ const Be::ClassInfo* TriMatrix::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // __init__ - MAP_METHOD_AS_METHOD - ( + MAP_METHOD_AS_METHOD( "__init__", - Py__init__, - "Constructor arguments" - ) + Py__init__, + "Constructor arguments" ) //////////////////////////////////////////////////////////////////////////// // Determinant - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Determinant", - Determinant, - "" - ) + Determinant, + "" ) //////////////////////////////////////////////////////////////////////////// // Identity - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Identity", - Identity, - "" - ) + Identity, + "" ) //////////////////////////////////////////////////////////////////////////// // Inverse - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Inverse", - Inverse, - "" - ) + Inverse, + "" ) //////////////////////////////////////////////////////////////////////////// // LookAtRH - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "LookAtRH", - PyLookAtRH, + PyLookAtRH, ":param eye: \n" ":param at: \n" - ":param up: \n" - ) + ":param up: \n" ) //////////////////////////////////////////////////////////////////////////// // Multiply - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Multiply", - PyMultiply, - ":param other: \n" - ) + PyMultiply, + ":param other: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationAxis - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationAxis", - PyRotationAxis, + PyRotationAxis, ":param axis: \n" - ":param angle: \n" - )//////////////////////////////////////////////////////////////////////////// + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationQuaternion - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationQuaternion", - PyRotationQuaternion, - ":param quaternion: \n" - ) + PyRotationQuaternion, + ":param quaternion: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationX - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationX", - RotationX, - ":param angle: \n" - ) + RotationX, + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationY - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationY", - RotationY, - ":param angle: \n" - ) + RotationY, + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationYawPitchRoll - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationYawPitchRoll", - RotationYawPitchRoll, + RotationYawPitchRoll, ":param yaw: \n" ":param pitch: \n" - ":param roll: \n" - ) + ":param roll: \n" ) //////////////////////////////////////////////////////////////////////////// // RotationZ - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "RotationZ", - RotationZ, - ":param angle: \n" - ) + RotationZ, + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // Scaling - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Scaling", - Scaling, + Scaling, ":param sx: \n" ":param sy: \n" - ":param sz: \n" - ) + ":param sz: \n" ) //////////////////////////////////////////////////////////////////////////// // Transformation - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Transformation", - PyTransformation, + PyTransformation, ":param scalingCenter: \n" ":param scalingRotation: \n" ":param scaling: \n" ":param rotationCenter: \n" ":param rotation: \n" - ":param translation: \n" - ) + ":param translation: \n" ) //////////////////////////////////////////////////////////////////////////// // Translation - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Translation", - Translation, + Translation, ":param x: \n" ":param y: \n" - ":param z: \n" - ) + ":param z: \n" ) //////////////////////////////////////////////////////////////////////////// // Transpose - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Transpose", - Transpose, - "" - ) + Transpose, + "" ) EXPOSURE_END() - } diff --git a/trinity/TriObserverLocal.cpp b/trinity/TriObserverLocal.cpp index bf61a1d31..b3a29bf18 100644 --- a/trinity/TriObserverLocal.cpp +++ b/trinity/TriObserverLocal.cpp @@ -68,7 +68,7 @@ bool TriObserverLocal::GetMute() void TriObserverLocal::SetMute( bool isMute ) { - if ( m_mute == isMute ) + if( m_mute == isMute ) { return; } diff --git a/trinity/TriObserverLocal.h b/trinity/TriObserverLocal.h index 92a3af31b..0c43b5282 100644 --- a/trinity/TriObserverLocal.h +++ b/trinity/TriObserverLocal.h @@ -12,7 +12,8 @@ struct Vector3; struct Matrix; -BLUE_CLASS( TriObserverLocal ) : public ITriObserverLocal +BLUE_CLASS( TriObserverLocal ) : + public ITriObserverLocal { public: TriObserverLocal( IRoot* lockobj = NULL ); @@ -24,7 +25,7 @@ BLUE_CLASS( TriObserverLocal ) : public ITriObserverLocal // ITriObserverLocal IBluePlacementObserver* GetObserver(); - void SetObserver( IBluePlacementObserver* obs ); + void SetObserver( IBluePlacementObserver * obs ); void SetPosition( Vector3 pos ); void SetFront( const Vector3& front ); @@ -33,13 +34,14 @@ BLUE_CLASS( TriObserverLocal ) : public ITriObserverLocal // INotify virtual bool OnModified( Be::Var * val ); - + // debug - void GetDebugOptions( Tr2DebugRendererOptions& options ); - void RenderDebugInfo( ITr2DebugRenderer2& renderer ); + void GetDebugOptions( Tr2DebugRendererOptions & options ); + void RenderDebugInfo( ITr2DebugRenderer2 & renderer ); std::string m_name; + private: bool m_mute; Vector3 m_front; diff --git a/trinity/TriObserverLocal_Blue.cpp b/trinity/TriObserverLocal_Blue.cpp index 3ae2aa223..554f18c1e 100644 --- a/trinity/TriObserverLocal_Blue.cpp +++ b/trinity/TriObserverLocal_Blue.cpp @@ -16,7 +16,7 @@ const Be::ClassInfo* TriObserverLocal::ExposeToBlue() MAP_ATTRIBUTE( "front", m_front, "", Be::READWRITE | Be::PERSIST ) MAP_PROPERTY( "mute", GetMute, SetMute, "" ) MAP_ATTRIBUTE( "observer", m_observer, "", Be::READWRITE | Be::PERSIST ) - - + + EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/TriPoolAllocator.cpp b/trinity/TriPoolAllocator.cpp index 7558886ad..d9809e71e 100644 --- a/trinity/TriPoolAllocator.cpp +++ b/trinity/TriPoolAllocator.cpp @@ -9,7 +9,7 @@ TriPoolAllocator::TriPoolAllocator() : m_pool( NULL ), m_poolEnd( NULL ), m_poolCurrent( NULL ), - m_chunkSize( 256*1024 ) + m_chunkSize( 256 * 1024 ) { } diff --git a/trinity/TriPoolAllocator.h b/trinity/TriPoolAllocator.h index 47e3a3813..42b81069f 100644 --- a/trinity/TriPoolAllocator.h +++ b/trinity/TriPoolAllocator.h @@ -16,7 +16,7 @@ class TriPoolAllocator void* Allocate( size_t size ); // Allocates an object of type T, aligned to 16 bytes - template < class T > + template T* Allocate() { void* p = Allocate( sizeof( T ) ); @@ -47,7 +47,6 @@ class TriPoolAllocator typedef std::list ChunkList_t; ChunkList_t m_previousPools; - }; diff --git a/trinity/TriProjection.cpp b/trinity/TriProjection.cpp index 7bf65c9f4..ac64f6e67 100644 --- a/trinity/TriProjection.cpp +++ b/trinity/TriProjection.cpp @@ -4,8 +4,8 @@ #include "TriProjection.h" #include "Tr2Renderer.h" -TriProjection::TriProjection( IRoot* lockobj ) - :m_projectionType( 0 ), +TriProjection::TriProjection( IRoot* lockobj ) : + m_projectionType( 0 ), m_fov( 0 ), m_aspect( 0 ), m_zn( 0 ), @@ -17,7 +17,7 @@ TriProjection::TriProjection( IRoot* lockobj ) { } -TriProjection::~TriProjection(void) +TriProjection::~TriProjection( void ) { } @@ -65,7 +65,7 @@ void TriProjection::CustomProjection( const Matrix& mat ) int TriProjection::GetProjectionType() { // Casting to int for Python exposure - return int(m_projectionType); + return int( m_projectionType ); } void TriProjection::SetProjection( Tr2RenderContext& renderContext ) @@ -131,22 +131,22 @@ void TriProjection::GetMatrixWithoutViewAdjustment( Matrix& proj ) const { // This constructs the projection matrix. Note that this is not necessarily the // same matrix that SetProjection would set to the device. That is because - // Tr2Renderer::SetPerspectiveProjection may skew/offset the projection if the + // Tr2Renderer::SetPerspectiveProjection may skew/offset the projection if the // viewport is partly off screen. - switch (m_projectionType) + switch( m_projectionType ) { - case TRIPROJECTION_FOV: - proj = PerspectiveFovMatrix( m_fov, m_aspect, m_zn, m_zf ); - break; - case TRIPROJECTION_OFF_CENTER: - proj = PerspectiveOffCenterMatrix( m_left, m_right, m_bottom, m_top, m_zn, m_zf ); - break; - case TRIPROJECTION_ORTHO: - proj = OrthoMatrix( m_left, m_top, m_zn, m_zf ); - break; - case TRIPROJECTION_CUSTOM: - proj = m_customTransform; - break; + case TRIPROJECTION_FOV: + proj = PerspectiveFovMatrix( m_fov, m_aspect, m_zn, m_zf ); + break; + case TRIPROJECTION_OFF_CENTER: + proj = PerspectiveOffCenterMatrix( m_left, m_right, m_bottom, m_top, m_zn, m_zf ); + break; + case TRIPROJECTION_ORTHO: + proj = OrthoMatrix( m_left, m_top, m_zn, m_zf ); + break; + case TRIPROJECTION_CUSTOM: + proj = m_customTransform; + break; } } diff --git a/trinity/TriProjection.h b/trinity/TriProjection.h index eeb8cd88e..ed4be197f 100644 --- a/trinity/TriProjection.h +++ b/trinity/TriProjection.h @@ -10,23 +10,24 @@ const char TRIPROJECTION_OFF_CENTER = 2; const char TRIPROJECTION_ORTHO = 3; const char TRIPROJECTION_CUSTOM = 4; -BLUE_CLASS( TriProjection ) : public IRoot +BLUE_CLASS( TriProjection ) : + public IRoot { public: EXPOSE_TO_BLUE(); - + TriProjection( IRoot* lockobj = NULL ); - ~TriProjection(void); + ~TriProjection( void ); - void PerspectiveFov( float fov, float aspect, float zn, float zf); - void PerspectiveOffCenter( float left, float right, float bottom, float top, float zn, float zf); - void PerspectiveOrthographic( float witdth, float height, float front, float back); + void PerspectiveFov( float fov, float aspect, float zn, float zf ); + void PerspectiveOffCenter( float left, float right, float bottom, float top, float zn, float zf ); + void PerspectiveOrthographic( float witdth, float height, float front, float back ); void CustomProjection( const Matrix& mat ); int GetProjectionType(); void SetProjection(); - void SetProjection( Tr2RenderContext& renderContext ); - void GetMatrixWithoutViewAdjustment( Matrix& proj ) const; + void SetProjection( Tr2RenderContext & renderContext ); + void GetMatrixWithoutViewAdjustment( Matrix & proj ) const; Matrix GetTransform() const; diff --git a/trinity/TriProjection_Blue.cpp b/trinity/TriProjection_Blue.cpp index 3e80b771c..3a28dce24 100644 --- a/trinity/TriProjection_Blue.cpp +++ b/trinity/TriProjection_Blue.cpp @@ -7,49 +7,45 @@ BLUE_DEFINE( TriProjection ); const Be::ClassInfo* TriProjection::ExposeToBlue() { - EXPOSURE_BEGIN(TriProjection, "" ) + EXPOSURE_BEGIN( TriProjection, "" ) MAP_INTERFACE( TriProjection ) MAP_INTERFACE( IRoot ) - MAP_METHOD_AND_WRAP( - "PerspectiveFov", - PerspectiveFov, + MAP_METHOD_AND_WRAP( + "PerspectiveFov", + PerspectiveFov, "Set the transform to a Field of View perspective (LH)\n" ":param fov: field of view angle\n" ":param aspect: aspect ratio\n" ":param zn: near plane distance\n" - ":param zf: far plane distance\n" - ) - MAP_METHOD_AND_WRAP( - "PerspectiveOffCenter", - PerspectiveOffCenter, + ":param zf: far plane distance\n" ) + MAP_METHOD_AND_WRAP( + "PerspectiveOffCenter", + PerspectiveOffCenter, "Set the transform to an off center perspective view (LH)\n" ":param left: left plane\n" ":param right: right plane\n" ":param bottom: bottom plane\n" ":param top: top plane\n" ":param zn: near plane distance\n" - ":param zf: far plane distance\n" - ) - MAP_METHOD_AND_WRAP( - "PerspectiveOrthographic", + ":param zf: far plane distance\n" ) + MAP_METHOD_AND_WRAP( + "PerspectiveOrthographic", PerspectiveOrthographic, "Set the transform to an orthographic perspective view (LH)\n" ":param width: projection width\n" ":param height: projection height\n" ":param zn: near plane distance\n" - ":param zf: far plane distance\n" - ) - MAP_METHOD_AND_WRAP( "GetProjectionType", GetProjectionType, "1=Fov, 2=OffCenter, 3=Ortho, 4=Custom") - MAP_METHOD_AND_WRAP( - "CustomProjection", - CustomProjection, + ":param zf: far plane distance\n" ) + MAP_METHOD_AND_WRAP( "GetProjectionType", GetProjectionType, "1=Fov, 2=OffCenter, 3=Ortho, 4=Custom" ) + MAP_METHOD_AND_WRAP( + "CustomProjection", + CustomProjection, "Set a transform directly from a matrix\n" - ":param proj: projection transform matrix" - ) + ":param proj: projection transform matrix" ) - MAP_PROPERTY_READONLY( "transform", GetTransform, "Gets the transformation matrix according to current settings.") + MAP_PROPERTY_READONLY( "transform", GetTransform, "Gets the transformation matrix according to current settings." ) EXPOSURE_END() } diff --git a/trinity/TriPythonContext.cpp b/trinity/TriPythonContext.cpp index 5e2f6b0ef..f87a2f9ea 100644 --- a/trinity/TriPythonContext.cpp +++ b/trinity/TriPythonContext.cpp @@ -5,4 +5,3 @@ // Initialize m_active (count) to in-active int TriPythonContext::m_active = 0; - diff --git a/trinity/TriPythonThunkers.cpp b/trinity/TriPythonThunkers.cpp index 62785fc0a..a2455732a 100644 --- a/trinity/TriPythonThunkers.cpp +++ b/trinity/TriPythonThunkers.cpp @@ -14,49 +14,47 @@ ///////////////////////////////////////////////////////////////////////////////////////// -PyObject* ITriScalarFunction_Thunk::PyUpdateScalar(PyObject* args) -{ - PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) +PyObject* ITriScalarFunction_Thunk::PyUpdateScalar( PyObject* args ) +{ + PyObject* t; + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - - if (PyLong_Check(t)) + + if( PyLong_Check( t ) ) { - return PyFloat_FromDouble(Update(Be::Time(PyLong_AsLongLong(t)))); + return PyFloat_FromDouble( Update( Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { - return PyFloat_FromDouble(Update(PyFloat_AS_DOUBLE(t))); + return PyFloat_FromDouble( Update( PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } + } } -PyObject* ITriScalarFunction_Thunk::PyGetScalarAt(PyObject* args) -{ - PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) +PyObject* ITriScalarFunction_Thunk::PyGetScalarAt( PyObject* args ) +{ + PyObject* t; + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - - if (PyLong_Check(t)) + + if( PyLong_Check( t ) ) { - return PyFloat_FromDouble(GetValueAt(Be::Time(PyLong_AsLongLong(t)))); + return PyFloat_FromDouble( GetValueAt( Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { - return PyFloat_FromDouble(GetValueAt(PyFloat_AS_DOUBLE(t))); + return PyFloat_FromDouble( GetValueAt( PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } + } } @@ -64,61 +62,59 @@ PyObject* ITriScalarFunction_Thunk::PyGetScalarAt(PyObject* args) // ITriColorFunction ///////////////////////////////////////////////////////////////////////////////////////// -PyObject* ITriColorFunction_Thunk::PyUpdateColor(PyObject* args) -{ +PyObject* ITriColorFunction_Thunk::PyUpdateColor( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) - return NULL; + if( !PyArg_ParseTuple( args, "O", &t ) ) + return NULL; ITriColorPtr q; - q.Attach(new OTriColor); - - if (PyLong_Check(t)) - { + q.Attach( new OTriColor ); + + if( PyLong_Check( t ) ) + { Color tmpResult; - q->SetColor( Update( &tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetColor( Update( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Color tmpResult; - q->SetColor( Update( &tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetColor( Update( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } -PyObject* ITriColorFunction_Thunk::PyGetColorAt(PyObject* args) -{ +PyObject* ITriColorFunction_Thunk::PyGetColorAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - + ITriColorPtr q; - q.Attach(new OTriColor); - - if (PyLong_Check(t)) - { + q.Attach( new OTriColor ); + + if( PyLong_Check( t ) ) + { Color tmpResult; - q->SetColor( GetValueAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetColor( GetValueAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Color tmpResult; - q->SetColor( GetValueAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetColor( GetValueAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; } - return PyOS->WrapBlueObject(q); + return PyOS->WrapBlueObject( q ); } @@ -127,117 +123,113 @@ PyObject* ITriColorFunction_Thunk::PyGetColorAt(PyObject* args) ///////////////////////////////////////////////////////////////////////////////////////// -PyObject* ITriVectorFunction_Thunk::PyUpdateVector(PyObject* args) -{ +PyObject* ITriVectorFunction_Thunk::PyUpdateVector( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - + ITriVectorPtr q; - q.Attach(new OTriVector); - - if (PyLong_Check(t)) - { + q.Attach( new OTriVector ); + + if( PyLong_Check( t ) ) + { Vector3 tmpResult; - q->SetVector( GetValueAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetVector( GetValueAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Vector3 tmpResult; - q->SetVector( GetValueAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetVector( GetValueAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; } - return PyOS->WrapBlueObject(q); + return PyOS->WrapBlueObject( q ); } -PyObject* ITriVectorFunction_Thunk::PyGetVectorAt(PyObject* args) -{ +PyObject* ITriVectorFunction_Thunk::PyGetVectorAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - + ITriVectorPtr q; - q.Attach(new OTriVector); - - if (PyLong_Check(t)) - { + q.Attach( new OTriVector ); + + if( PyLong_Check( t ) ) + { Vector3 tmpResult( 0, 0, 0 ); - q->SetVector( GetValueAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetVector( GetValueAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Vector3 tmpResult( 0, 0, 0 ); - q->SetVector( GetValueAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetVector( GetValueAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; } - return PyOS->WrapBlueObject(q); + return PyOS->WrapBlueObject( q ); } -PyObject* ITriVectorFunction_Thunk::PyGetVectorDotAt(PyObject* args) -{ +PyObject* ITriVectorFunction_Thunk::PyGetVectorDotAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; ITriVectorPtr q; - q.Attach(new OTriVector); - - if (PyLong_Check(t)) - { + q.Attach( new OTriVector ); + + if( PyLong_Check( t ) ) + { Vector3 tmpResult; - q->SetVector( GetValueDotAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetVector( GetValueDotAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Vector3 tmpResult; - q->SetVector( GetValueDotAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetVector( GetValueDotAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } -PyObject* ITriVectorFunction_Thunk::PyGetVectorDoubleDotAt(PyObject* args) -{ +PyObject* ITriVectorFunction_Thunk::PyGetVectorDoubleDotAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; ITriVectorPtr q; - q.Attach(new OTriVector); - - if (PyLong_Check(t)) - { + q.Attach( new OTriVector ); + + if( PyLong_Check( t ) ) + { Vector3 tmpResult; - q->SetVector( GetValueDoubleDotAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetVector( GetValueDoubleDotAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Vector3 tmpResult; - q->SetVector( GetValueDoubleDotAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetVector( GetValueDoubleDotAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } @@ -246,123 +238,118 @@ PyObject* ITriVectorFunction_Thunk::PyGetVectorDoubleDotAt(PyObject* args) // ITriQuaternionFunction ///////////////////////////////////////////////////////////////////////////////////////// -PyObject* ITriQuaternionFunction_Thunk::PyUpdateQuaternion(PyObject* args) -{ +PyObject* ITriQuaternionFunction_Thunk::PyUpdateQuaternion( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) - return NULL; + if( !PyArg_ParseTuple( args, "O", &t ) ) + return NULL; ITriQuaternionPtr q; - q.Attach(new OTriQuaternion); + q.Attach( new OTriQuaternion ); - if (PyLong_Check(t)) - { + if( PyLong_Check( t ) ) + { Quaternion tmpResult; - q->SetQuaternion( Update( &tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetQuaternion( Update( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Quaternion tmpResult; - q->SetQuaternion( Update( &tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetQuaternion( Update( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } -PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionAt(PyObject* args) -{ +PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; - + ITriQuaternionPtr q; - q.Attach(new OTriQuaternion); - - if (PyLong_Check(t)) - { + q.Attach( new OTriQuaternion ); + + if( PyLong_Check( t ) ) + { Quaternion tmpResult; - q->SetQuaternion( GetValueAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetQuaternion( GetValueAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Quaternion tmpResult; - q->SetQuaternion( GetValueAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetQuaternion( GetValueAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; } - return PyOS->WrapBlueObject(q); + return PyOS->WrapBlueObject( q ); } -PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionDotAt(PyObject* args) -{ +PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionDotAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; ITriQuaternionPtr q; - q.Attach(new OTriQuaternion); - - if (PyLong_Check(t)) - { + q.Attach( new OTriQuaternion ); + + if( PyLong_Check( t ) ) + { Quaternion tmpResult; - q->SetQuaternion( GetValueDotAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetQuaternion( GetValueDotAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Quaternion tmpResult; - q->SetQuaternion( GetValueDotAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetQuaternion( GetValueDotAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } -PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionDoubleDotAt(PyObject* args) -{ +PyObject* ITriQuaternionFunction_Thunk::PyGetQuaternionDoubleDotAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; ITriQuaternionPtr q; - q.Attach(new OTriQuaternion); - - if (PyLong_Check(t)) - { + q.Attach( new OTriQuaternion ); + + if( PyLong_Check( t ) ) + { Quaternion tmpResult; - q->SetQuaternion( GetValueDoubleDotAt(&tmpResult, Be::Time(PyLong_AsLongLong(t))) ); + q->SetQuaternion( GetValueDoubleDotAt( &tmpResult, Be::Time( PyLong_AsLongLong( t ) ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { Quaternion tmpResult; - q->SetQuaternion( GetValueDoubleDotAt(&tmpResult, PyFloat_AS_DOUBLE(t)) ); + q->SetQuaternion( GetValueDoubleDotAt( &tmpResult, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } - #endif diff --git a/trinity/TriPythonThunkers.h b/trinity/TriPythonThunkers.h index 1d8dce262..18d33a8bf 100644 --- a/trinity/TriPythonThunkers.h +++ b/trinity/TriPythonThunkers.h @@ -11,7 +11,6 @@ class ITriScalarFunction_Thunk : public ITriScalarFunction { public: - typedef ITriScalarFunction_Thunk _Class; typedef ITriScalarFunction _Interface; @@ -25,24 +24,19 @@ class ITriScalarFunction_Thunk : public ITriScalarFunction return ClassType()->mClassId; } - static const PyMethodDef* Defs() - { + static const PyMethodDef* Defs(){ THUNKER_BEGIN() - MAPPYTHON - ( - UpdateScalar, - "use: f = curve.Update( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'curve.value' is now 'f' which is the value at time 't'." - ) - MAPPYTHON - ( - GetScalarAt, - "use: f = curve.GetValueAt( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'f' is the value of 'curve' at time 't'." - ) -/* MAPPYTHON + MAPPYTHON( + UpdateScalar, + "use: f = curve.Update( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'curve.value' is now 'f' which is the value at time 't'." ) + MAPPYTHON( + GetScalarAt, + "use: f = curve.GetValueAt( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'f' is the value of 'curve' at time 't'." ) + /* MAPPYTHON ( GetValueDotAt, "Get the value of the of the differential function" @@ -58,8 +52,8 @@ class ITriScalarFunction_Thunk : public ITriScalarFunction // compatible python methods DECLARE_PYMETHODTHUNK( UpdateScalar ); DECLARE_PYMETHODTHUNK( GetScalarAt ); -// DECLARE_PYMETHODTHUNK( GetValueDotAt ); -// DECLARE_PYMETHODTHUNK( GetValueDoubleDotAt ); + // DECLARE_PYMETHODTHUNK( GetValueDotAt ); + // DECLARE_PYMETHODTHUNK( GetValueDoubleDotAt ); }; @@ -70,7 +64,6 @@ class ITriScalarFunction_Thunk : public ITriScalarFunction class ITriColorFunction_Thunk : public ITriColorFunction { public: - typedef ITriColorFunction_Thunk _Class; typedef ITriColorFunction _Interface; @@ -84,28 +77,23 @@ class ITriColorFunction_Thunk : public ITriColorFunction return ClassType()->mClassId; } - static const PyMethodDef* Defs() - { + static const PyMethodDef* Defs(){ THUNKER_BEGIN() - MAPPYTHON - ( - UpdateColor, - "use: f = curve.Update( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'curve.value' is now 'f' which is the value at time 't'." - ) - MAPPYTHON - ( - GetColorAt, - "use: f = curve.GetValueAt( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'f' is the value of 'curve' at time 't'." - ) - THUNKER_END() + MAPPYTHON( + UpdateColor, + "use: f = curve.Update( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'curve.value' is now 'f' which is the value at time 't'." ) + MAPPYTHON( + GetColorAt, + "use: f = curve.GetValueAt( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'f' is the value of 'curve' at time 't'." ) + THUNKER_END() } // compatible python methods - DECLARE_PYMETHODTHUNK( UpdateColor ); + DECLARE_PYMETHODTHUNK( UpdateColor ); DECLARE_PYMETHODTHUNK( GetColorAt ); }; @@ -116,7 +104,6 @@ class ITriColorFunction_Thunk : public ITriColorFunction class ITriVectorFunction_Thunk : public ITriVectorFunction { public: - typedef ITriVectorFunction_Thunk _Class; typedef ITriVectorFunction _Interface; @@ -130,34 +117,25 @@ class ITriVectorFunction_Thunk : public ITriVectorFunction return ClassType()->mClassId; } - static const PyMethodDef* Defs() - { + static const PyMethodDef* Defs(){ THUNKER_BEGIN() - MAPPYTHON - ( - UpdateVector, - "use: f = curve.Update( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'curve.value' is now 'f' which is the value at time 't'." - ) - MAPPYTHON - ( - GetVectorAt, - "use: f = curve.GetValueAt( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'f' is the value of 'curve' at time 't'." - ) - MAPPYTHON - ( - GetVectorDotAt, - "Get the value of the of the differential function" - ) - MAPPYTHON - ( - GetVectorDoubleDotAt, - "Get the value of the of the double differential function" - ) - THUNKER_END() + MAPPYTHON( + UpdateVector, + "use: f = curve.Update( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'curve.value' is now 'f' which is the value at time 't'." ) + MAPPYTHON( + GetVectorAt, + "use: f = curve.GetValueAt( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'f' is the value of 'curve' at time 't'." ) + MAPPYTHON( + GetVectorDotAt, + "Get the value of the of the differential function" ) + MAPPYTHON( + GetVectorDoubleDotAt, + "Get the value of the of the double differential function" ) + THUNKER_END() } // compatible python methods @@ -175,7 +153,6 @@ class ITriVectorFunction_Thunk : public ITriVectorFunction class ITriQuaternionFunction_Thunk : public ITriQuaternionFunction { public: - typedef ITriQuaternionFunction_Thunk _Class; typedef ITriQuaternionFunction _Interface; @@ -189,34 +166,25 @@ class ITriQuaternionFunction_Thunk : public ITriQuaternionFunction return ClassType()->mClassId; } - static const PyMethodDef* Defs() - { + static const PyMethodDef* Defs(){ THUNKER_BEGIN() - MAPPYTHON - ( - UpdateQuaternion, - "use: f = curve.Update( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'curve.value' is now 'f' which is the value at time 't'." - ) - MAPPYTHON - ( - GetQuaternionAt, - "use: f = curve.GetValueAt( t )\r\n" - "pre: 't' is of type double or Be::Time.\r\n" - "post: 'f' is the value of 'curve' at time 't'." - ) - MAPPYTHON - ( - GetQuaternionDotAt, - "Get the value of the of the differential function" - ) - MAPPYTHON - ( - GetQuaternionDoubleDotAt, - "Get the value of the of the double differential function" - ) - THUNKER_END() + MAPPYTHON( + UpdateQuaternion, + "use: f = curve.Update( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'curve.value' is now 'f' which is the value at time 't'." ) + MAPPYTHON( + GetQuaternionAt, + "use: f = curve.GetValueAt( t )\r\n" + "pre: 't' is of type double or Be::Time.\r\n" + "post: 'f' is the value of 'curve' at time 't'." ) + MAPPYTHON( + GetQuaternionDotAt, + "Get the value of the of the differential function" ) + MAPPYTHON( + GetQuaternionDoubleDotAt, + "Get the value of the of the double differential function" ) + THUNKER_END() } // compatible python methods @@ -229,5 +197,4 @@ class ITriQuaternionFunction_Thunk : public ITriQuaternionFunction - #endif \ No newline at end of file diff --git a/trinity/TriQuaternion.cpp b/trinity/TriQuaternion.cpp index 8752e6018..607db188f 100644 --- a/trinity/TriQuaternion.cpp +++ b/trinity/TriQuaternion.cpp @@ -13,40 +13,36 @@ #if BLUE_WITH_PYTHON -void TriQuaternion::Destroy( - ) +void TriQuaternion::Destroy() { //delete this; } -PyObject* TriQuaternion::GetAttr( - const char* name, - bool* handled - ) +PyObject* TriQuaternion::GetAttr( + const char* name, + bool* handled ) { return 0; } bool TriQuaternion::SetAttr( - const char* name, - PyObject* v, - bool* handled - ) + const char* name, + PyObject* v, + bool* handled ) { return true; } PyObject* TriQuaternion::Repr( - bool* handled - ) + bool* handled ) { *handled = true; char buf[120]; - sprintf_s(buf, "(%f,%f,%f,%f)", x, y, z,w); - return ToPython(buf); + sprintf_s( buf, "(%f,%f,%f,%f)", x, y, z, w ); + return ToPython( buf ); } @@ -54,8 +50,8 @@ PyObject* TriQuaternion::Repr( // TriQuaternion ///////////////////////////////////////////////////////////////////////////////////////// -TriQuaternion::TriQuaternion(IRoot* lockobj) : -::Quaternion(0.0f, 0.0f, 0.0f, 1.0f) +TriQuaternion::TriQuaternion( IRoot* lockobj ) : + ::Quaternion( 0.0f, 0.0f, 0.0f, 1.0f ) { } @@ -70,11 +66,10 @@ TriQuaternion::~TriQuaternion() ///////////////////////////////////////////////////////////////////////////////////////// void TriQuaternion::SetXYZW( - float _x, - float _y, - float _z, - float _w - ) + float _x, + float _y, + float _z, + float _w ) { x = _x; y = _y; @@ -84,8 +79,7 @@ void TriQuaternion::SetXYZW( void TriQuaternion::SetQuaternion( - const ::Quaternion* ar - ) + const ::Quaternion* ar ) { x = ar->x; y = ar->y; @@ -94,27 +88,24 @@ void TriQuaternion::SetQuaternion( } -const ::Quaternion* TriQuaternion::GetQuaternion( - ) const +const ::Quaternion* TriQuaternion::GetQuaternion() const { - return this; + return this; } ::Quaternion* TriQuaternion::CopyQuaternion( - ::Quaternion* in - ) const + ::Quaternion* in ) const { // would this work? //return &(*in = *this); - + *in = *this; return in; } -::Quaternion* TriQuaternion::Quaternion( - ) +::Quaternion* TriQuaternion::Quaternion() { return this; } @@ -123,22 +114,20 @@ ::Quaternion* TriQuaternion::Quaternion( void TriQuaternion::SetIdentity() { *static_cast<::Quaternion*>( this ) = IdentityQuaternion(); -} +} void TriQuaternion::SetRotationAxis( - const Vector3* axis, - float angle - ) + const Vector3* axis, + float angle ) { *static_cast<::Quaternion*>( this ) = RotationQuaternion( *axis, angle ); } void TriQuaternion::GetRotationAxis( - Vector3* axis, - float* angle - ) const + Vector3* axis, + float* angle ) const { auto result = GetAxisAngle( *this ); *axis = result.first; @@ -147,56 +136,51 @@ void TriQuaternion::GetRotationAxis( void TriQuaternion::SetYawPitchRoll( - float yaw, - float pitch, - float roll - ) + float yaw, + float pitch, + float roll ) { *static_cast<::Quaternion*>( this ) = RotationQuaternion( yaw, pitch, roll ); } -void TriQuaternion::GetYawPitchRoll ( - float* yaw, - float* pitch, - float* roll - ) const +void TriQuaternion::GetYawPitchRoll( + float* yaw, + float* pitch, + float* roll ) const { - TriQuaternionToYawPitchRoll( yaw, pitch, roll, this); + TriQuaternionToYawPitchRoll( yaw, pitch, roll, this ); } - + void TriQuaternion::IncreaseYawPitchRoll( - float yaw, - float pitch, - float roll - ) + float yaw, + float pitch, + float roll ) { - float yawCurr; - float pitchCurr; + float yawCurr; + float pitchCurr; float rollCurr; - TriQuaternionToYawPitchRoll(&yawCurr, &pitchCurr, &rollCurr, this); - + TriQuaternionToYawPitchRoll( &yawCurr, &pitchCurr, &rollCurr, this ); + yawCurr += yaw; pitchCurr -= pitch; - if(pitchCurr < -1.5f) + if( pitchCurr < -1.5f ) pitchCurr = -1.5f; - if(pitchCurr > 1.5f) + if( pitchCurr > 1.5f ) pitchCurr = 1.5f; rollCurr += roll; - + *static_cast<::Quaternion*>( this ) = RotationQuaternion( yawCurr, pitchCurr, rollCurr ); return; - } void TriQuaternion::IncreaseLocalYawPitchRoll( - float yaw, - float pitch, - float roll - ) + float yaw, + float pitch, + float roll ) { ::Quaternion diff = RotationQuaternion( yaw, pitch, roll ); *static_cast<::Quaternion*>( this ) = diff * *this; @@ -204,17 +188,15 @@ void TriQuaternion::IncreaseLocalYawPitchRoll( void TriQuaternion::SetRotationArc( - const Vector3* v1, - const Vector3* v2 - ) + const Vector3* v1, + const Vector3* v2 ) { - TriQuaternionRotationArc(this, v1, v2); + TriQuaternionRotationArc( this, v1, v2 ); } void TriQuaternion::MultiplyQuaternion( - const ::Quaternion* in - ) + const ::Quaternion* in ) { *static_cast<::Quaternion*>( this ) = *in * *this; } @@ -222,8 +204,7 @@ void TriQuaternion::MultiplyQuaternion( void TriQuaternion::SetSLERP( const ::Quaternion* q1, const ::Quaternion* q2, - const float t - ) + const float t ) { *static_cast<::Quaternion*>( this ) = Slerp( *q1, *q2, t ); } @@ -265,7 +246,7 @@ void TriQuaternion::PyInverse() float TriQuaternion::PyLength() { - return ::Length( *this ); + return ::Length( *this ); } @@ -281,31 +262,28 @@ void TriQuaternion::PyNormalize() } void TriQuaternion::PyRotationAxis( ITriVector* axis, float angle ) -{ +{ *static_cast<::Quaternion*>( this ) = RotationQuaternion( *axis->GetVector(), angle ); } void TriQuaternion::PySetRotationAxis( ITriVector* axis, float angle ) -{ +{ SetRotationAxis( axis->GetVector(), angle ); } Vector3 TriQuaternion::PyGetYawPitchRoll() -{ +{ Vector3 ypr; GetYawPitchRoll( &ypr.x, &ypr.y, &ypr.z ); return ypr; - } void TriQuaternion::PyScale( float factor ) -{ +{ TriQuaternionScale( this, this, factor ); } - - #endif diff --git a/trinity/TriQuaternion_Blue.cpp b/trinity/TriQuaternion_Blue.cpp index 36d642843..eb5295a3b 100644 --- a/trinity/TriQuaternion_Blue.cpp +++ b/trinity/TriQuaternion_Blue.cpp @@ -10,164 +10,141 @@ BLUE_DEFINE( TriQuaternion ); const Be::ClassInfo* TriQuaternion::ExposeToBlue() { - EXPOSURE_BEGIN(TriQuaternion, TRIQUATERNION_Description) - MAP_INTERFACE(ITriQuaternion) - MAP_INTERFACE(IPythonMethods) + EXPOSURE_BEGIN( TriQuaternion, TRIQUATERNION_Description ) + MAP_INTERFACE( ITriQuaternion ) + MAP_INTERFACE( IPythonMethods ) //////////////////////////////////////////////////////////////////////////// // x - MAP_ATTRIBUTE - ( - "x", - x, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "x", + x, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // y - MAP_ATTRIBUTE - ( - "y", - y, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "y", + y, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // z - MAP_ATTRIBUTE - ( - "z", - z, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "z", + z, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // w - MAP_ATTRIBUTE - ( - "w", - w, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "w", + w, + "", + Be::READWRITE | Be::PERSIST ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", - Py__init__, + Py__init__, 4, "Constructor arguments\n" ":param x: \n" ":param y: \n" ":param z: \n" - ":param w: \n" - ) + ":param w: \n" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "SetXYZW", - SetXYZW, + SetXYZW, "sets the quaternion\n" ":param x: \n" ":param y: \n" ":param z: \n" - ":param w: \n" - ) + ":param w: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Identity", - PyIdentity, - "Makes the quaternion an identity quaternion") + PyIdentity, + "Makes the quaternion an identity quaternion" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Length", - PyLength, - "Returns the length of a quaternion") + PyLength, + "Returns the length of a quaternion" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Multiply", - PyMultiply, + PyMultiply, "Multiplies a quaternion with this quaternion\n" - ":param other: \n" - ) - - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + ":param other: \n" ) + + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Normalize", - PyNormalize, + PyNormalize, "Normalizes this quaternion" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "RotationAxis", - PyRotationAxis, + PyRotationAxis, "Set the rotation of the quaternion\n" ":param axis: \n" - ":param angle: \n" - ) + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // SetIdentity - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetIdentity", - SetIdentity, - "Sets quaternion to identity quaternion" - ) + SetIdentity, + "Sets quaternion to identity quaternion" ) //////////////////////////////////////////////////////////////////////////// // SetRotationAxis - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetRotationAxis", - PySetRotationAxis, - "Set the rotation of the quaternion\n" + PySetRotationAxis, + "Set the rotation of the quaternion\n" ":param axis: \n" - ":param angle: \n" - ) + ":param angle: \n" ) //////////////////////////////////////////////////////////////////////////// // SetYawPitchRoll - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetYawPitchRoll", - SetYawPitchRoll, - "Set the yaw pitch roll of the quaternion\n" + SetYawPitchRoll, + "Set the yaw pitch roll of the quaternion\n" ":param yaw: \n" ":param pitch: \n" - ":param roll: \n" - ) + ":param roll: \n" ) //////////////////////////////////////////////////////////////////////////// // GetYawPitchRoll - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetYawPitchRoll", - PyGetYawPitchRoll, - "Get the yaw pitch roll of the quaternion\n" - ":rtype: (float, float, float)" - ) + PyGetYawPitchRoll, + "Get the yaw pitch roll of the quaternion\n" + ":rtype: (float, float, float)" ) //////////////////////////////////////////////////////////////////////////// // Scale - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "Scale", - PyScale, - "Scales the quaternion\n" - ":param scale: \n" - ) + PyScale, + "Scales the quaternion\n" + ":param scale: \n" ) EXPOSURE_END() - } #endif diff --git a/trinity/TriRect.cpp b/trinity/TriRect.cpp index 8554b31db..ce3759fff 100644 --- a/trinity/TriRect.cpp +++ b/trinity/TriRect.cpp @@ -13,7 +13,7 @@ void TriRect::Destroy() //delete this; } -PyObject* TriRect::GetAttr( const char* name, bool* handled ) +PyObject* TriRect::GetAttr( const char* name, bool* handled ) { return 0; } @@ -27,14 +27,14 @@ PyObject* TriRect::Repr( bool* handled ) { *handled = true; char buf[120]; - sprintf_s(buf, "", left, top, right, bottom); - return ToPython(buf); + sprintf_s( buf, "", left, top, right, bottom ); + return ToPython( buf ); } -TriRect::TriRect(IRoot* lockobj) +TriRect::TriRect( IRoot* lockobj ) { - SetDimentions(0,0,0,0); + SetDimentions( 0, 0, 0, 0 ); } TriRect::~TriRect() @@ -45,7 +45,7 @@ void TriRect::SetDimentions( int32_t _left, int32_t _top, int32_t _right, int32_ { left = _left; top = _top; - right = _right; + right = _right; bottom = _bottom; } @@ -53,7 +53,7 @@ void TriRect::SetRect( const ::Tr2Rect* c ) { left = c->left; top = c->top; - right = c->right; + right = c->right; bottom = c->bottom; } @@ -75,7 +75,7 @@ ::Tr2Rect* TriRect::Rect() return this; } -void TriRect::PySetRect( Be::Optional l, Be::Optional t, Be::Optional r, Be::Optional b ) +void TriRect::PySetRect( Be::Optional l, Be::Optional t, Be::Optional r, Be::Optional b ) { if( l.IsAssigned() ) { diff --git a/trinity/TriRect.h b/trinity/TriRect.h index aafeb76ea..ead278a87 100644 --- a/trinity/TriRect.h +++ b/trinity/TriRect.h @@ -14,7 +14,7 @@ BLUE_CLASS( TriRect ) : public: EXPOSE_TO_BLUE(); - TriRect(IRoot* lockobj = NULL); + TriRect( IRoot* lockobj = NULL ); ~TriRect(); ///////////////////////////////////////////////////////////////////////////////////// @@ -27,10 +27,10 @@ BLUE_CLASS( TriRect ) : void SetDimentions( int32_t _left, int32_t _top, int32_t _right, int32_t _bottom ); void SetRect( const ::Tr2Rect* c ); const ::Tr2Rect* GetRect() const; - ::Tr2Rect* CopyRect( ::Tr2Rect* in ) const; + ::Tr2Rect* CopyRect( ::Tr2Rect * in ) const; ::Tr2Rect* Rect(); - void PySetRect(Be::Optional l, Be::Optional t, Be::Optional r, Be::Optional b ); + void PySetRect( Be::Optional l, Be::Optional t, Be::Optional r, Be::Optional b ); }; TYPEDEF_BLUECLASS( TriRect ); diff --git a/trinity/TriRect_Blue.cpp b/trinity/TriRect_Blue.cpp index a7fe06cf5..773c8ed83 100644 --- a/trinity/TriRect_Blue.cpp +++ b/trinity/TriRect_Blue.cpp @@ -14,69 +14,56 @@ const Be::ClassInfo* TriRect::ExposeToBlue() //////////////////////////////////////////////////////////////////////////// // left - MAP_ATTRIBUTE - ( - "left", - left, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "left", + left, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // top - MAP_ATTRIBUTE - ( - "top", - top, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "top", + top, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // right - MAP_ATTRIBUTE - ( - "right", - right, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "right", + right, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // bottom - MAP_ATTRIBUTE - ( - "bottom", - bottom, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "bottom", + bottom, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // __init__ - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "__init__", - SetDimentions, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + SetDimentions, 4, - "Constructor arguments\n" + "Constructor arguments\n" ":param left: \n" ":param top: \n" ":param right: \n" - ":param bottom: \n" - ) + ":param bottom: \n" ) //////////////////////////////////////////////////////////////////////////// // SetRect - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS - ( - "SetRect", + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "SetRect", PySetRect, 4, ":param left: \n" ":param top: \n" ":param right: \n" - ":param bottom: \n" - ) + ":param bottom: \n" ) EXPOSURE_END() - } #endif diff --git a/trinity/TriRenderBatch.cpp b/trinity/TriRenderBatch.cpp index 3e634c4d5..b728084cc 100644 --- a/trinity/TriRenderBatch.cpp +++ b/trinity/TriRenderBatch.cpp @@ -18,7 +18,7 @@ void TriRenderBatchAreaBlock::Optimize( std::vector& areaBlockVector ) { // turn area block list into a std::set, so we get sorting and remove duplicates - std::set< unsigned int > overlayHullAreas; + std::set overlayHullAreas; for( auto it = areaBlockVector.begin(); it != areaBlockVector.end(); ++it ) { for( unsigned n = 0; n < it->m_count; ++n ) @@ -216,7 +216,7 @@ bool CanBeBinned( Tr2RenderBatch& batch1, const Tr2RenderBatch& batch2 ) bool Compare( const Tr2RenderBatch& batch1, const Tr2RenderBatch& batch2 ) { - if ( batch1.m_priority != batch2.m_priority ) + if( batch1.m_priority != batch2.m_priority ) { return batch1.m_priority < batch2.m_priority; } diff --git a/trinity/TriRenderBatch.h b/trinity/TriRenderBatch.h index 7bff317b1..4b51598bf 100644 --- a/trinity/TriRenderBatch.h +++ b/trinity/TriRenderBatch.h @@ -23,8 +23,13 @@ class Tr2PerObjectData; class TriRenderBatchAreaBlock { public: - TriRenderBatchAreaBlock() {} - TriRenderBatchAreaBlock( unsigned int startIndex, unsigned int count ) : m_startIndex( startIndex ), m_count( count ) {} + TriRenderBatchAreaBlock() + { + } + TriRenderBatchAreaBlock( unsigned int startIndex, unsigned int count ) : + m_startIndex( startIndex ), m_count( count ) + { + } // optimizing lists static void Optimize( std::vector& areaBlockVector ); @@ -42,7 +47,6 @@ class TriRenderBatchAreaBlocksWithSharedMaterial : public TriRenderBatchAreaBloc Tr2EffectPtr m_shaderMaterial; std::vector m_areaBlockVector; - }; // -------------------------------------------------------------------------------------- // Description @@ -50,9 +54,9 @@ class TriRenderBatchAreaBlocksWithSharedMaterial : public TriRenderBatchAreaBloc // -------------------------------------------------------------------------------------- enum RenderBatchSortType { - RENDERBATCHSORTTYPE_NONE, // Don't sort - RENDERBATCHSORTTYPE_SORT, // Use std::sort - RENDERBATCHSORTTYPE_STABLE_SORT // Use std::stable_sort + RENDERBATCHSORTTYPE_NONE, // Don't sort + RENDERBATCHSORTTYPE_SORT, // Use std::sort + RENDERBATCHSORTTYPE_STABLE_SORT // Use std::stable_sort }; @@ -229,7 +233,9 @@ class ITriRenderBatchAccumulator } // Destructor - virtual ~ITriRenderBatchAccumulator() {} + virtual ~ITriRenderBatchAccumulator() + { + } // Allocate memory block of the given size void* Allocate( size_t size ) @@ -256,7 +262,7 @@ class ITriRenderBatchAccumulator virtual void Finalize( void ) = 0; // Get the number of batches - virtual size_t GetBatchCount( void ) const = 0; + virtual size_t GetBatchCount( void ) const = 0; // Are batches sorted by effect? virtual bool IsChainedByEffect( void ) const = 0; @@ -264,13 +270,22 @@ class ITriRenderBatchAccumulator virtual void TransferFrom( ITriRenderBatchAccumulator* source ) = 0; // Set userdata - void SetUserData( int64_t userData ) { m_userData = userData; } + void SetUserData( int64_t userData ) + { + m_userData = userData; + } // Set rendering mode - void SetRenderingMode( Tr2EffectStateManager::RenderingMode mode ) { m_renderingMode = mode; } + void SetRenderingMode( Tr2EffectStateManager::RenderingMode mode ) + { + m_renderingMode = mode; + } // Get rendering mode - Tr2EffectStateManager::RenderingMode GetRenderingMode() const { return m_renderingMode; } + Tr2EffectStateManager::RenderingMode GetRenderingMode() const + { + return m_renderingMode; + } protected: int64_t m_userData; @@ -293,20 +308,20 @@ template class TriRenderBatchAccumulator : public ITriRenderBatchAccumulator { public: - // Construct an accumulator, associating it with the given allocator. - TriRenderBatchAccumulator( TriPoolAllocator* allocator ) : + // Construct an accumulator, associating it with the given allocator. + TriRenderBatchAccumulator( TriPoolAllocator* allocator ) : ITriRenderBatchAccumulator( allocator ), m_keyGen() { } - virtual ~TriRenderBatchAccumulator() + virtual ~TriRenderBatchAccumulator() { } - // Clears the accumulator, resetting to initial state. Note that the + // Clears the accumulator, resetting to initial state. Note that the // allocator must be cleared separately as it may be shared with other things. - virtual void Clear( void ) + virtual void Clear( void ) { m_userData = 0x0; m_renderingMode = Tr2EffectStateManager::RM_ANY; @@ -364,8 +379,8 @@ class TriRenderBatchAccumulator : public ITriRenderBatchAccumulator return m_batches; } - // Call this after committing the last batch. - virtual void Finalize( void ) + // Call this after committing the last batch. + virtual void Finalize( void ) { if constexpr( KeyGenerator::GetSortType() == RENDERBATCHSORTTYPE_SORT ) { @@ -394,10 +409,16 @@ class TriRenderBatchAccumulator : public ITriRenderBatchAccumulator } // Get the batch count - virtual size_t GetBatchCount() const { return m_gdprBatches.size() + m_batches.size(); } + virtual size_t GetBatchCount() const + { + return m_gdprBatches.size() + m_batches.size(); + } // Are the batches sorted by effect? - virtual bool IsChainedByEffect() const { return m_keyGen.GetSortType() != RENDERBATCHSORTTYPE_NONE; } + virtual bool IsChainedByEffect() const + { + return m_keyGen.GetSortType() != RENDERBATCHSORTTYPE_NONE; + } private: KeyGenerator m_keyGen; diff --git a/trinity/TriRigidOrientation.cpp b/trinity/TriRigidOrientation.cpp index a18024c4a..430209f1d 100644 --- a/trinity/TriRigidOrientation.cpp +++ b/trinity/TriRigidOrientation.cpp @@ -6,22 +6,22 @@ #include "include/TriVector.h" #include "Include/TriMath.h" -TriTorque::TriTorque(IRoot* lockobj) : - mTime( 0.0f ), +TriTorque::TriTorque( IRoot* lockobj ) : + mTime( 0.0f ), mRot0( 0.0f, 0.0f, 0.0f, 1.0f ), mOmega0( 0.0f, 0.0f, 0.0f ), mTorque( 0.0f, 0.0f, 0.0f ) { } -TriRigidOrientation::TriRigidOrientation(IRoot* lockobj) : - mStart ( 0 ), - mI ( 1.0f ), - mDrag ( 1.0f ), - mCurrKey ( 0 ), - PARENTLOCK( mStates, IRoot ), +TriRigidOrientation::TriRigidOrientation( IRoot* lockobj ) : + mStart( 0 ), + mI( 1.0f ), + mDrag( 1.0f ), + mCurrKey( 0 ), + PARENTLOCK( mStates, IRoot ), mValue( 0.0f, 0.0f, 0.0f, 1.0f ) -{ +{ } @@ -35,20 +35,18 @@ TriRigidOrientation::~TriRigidOrientation() Quaternion* TriRigidOrientation::Update( Quaternion* in, - Be::Time t - ) -{ - GetValueAt(&mValue, t); + Be::Time t ) +{ + GetValueAt( &mValue, t ); *in = mValue; return in; } Quaternion* TriRigidOrientation::Update( Quaternion* in, - double t - ) + double t ) { - GetValueAt(&mValue, t); + GetValueAt( &mValue, t ); *in = mValue; return in; } @@ -56,33 +54,32 @@ Quaternion* TriRigidOrientation::Update( Quaternion* TriRigidOrientation::GetValueAt( Quaternion* in, - Be::Time now - ) -{ - return GetValueAt(in, TimeAsDouble(now - mStart)); + Be::Time now ) +{ + return GetValueAt( in, TimeAsDouble( now - mStart ) ); } Quaternion* TriRigidOrientation::GetValueAt( Quaternion* in, - double t - ) -{ - if ((mStates.GetSize() == 0) ||(t < 0.0) || (t < (mStates[0]->mTime))) - {// there are no keys, the curve hasn't begun or t is before the first key + double t ) +{ + if( ( mStates.GetSize() == 0 ) || ( t < 0.0 ) || ( t < ( mStates[0]->mTime ) ) ) + { // there are no keys, the curve hasn't begun or t is before the first key *in = mValue; return in; - } - Seek(t); - Vector3 ZeroVec(0.0f, 0.0f, 0.0f); + } + Seek( t ); + Vector3 ZeroVec( 0.0f, 0.0f, 0.0f ); TriVectorExponentialDecayInteger( &mTauVector, - &ZeroVec, - &mStates[mCurrKey]->mOmega0, - &mStates[mCurrKey]->mTorque, - mI, mDrag, - (float)(t - mStates[mCurrKey]->mTime)); - mTauConverter.x = mTauVector.x; + &ZeroVec, + &mStates[mCurrKey]->mOmega0, + &mStates[mCurrKey]->mTorque, + mI, + mDrag, + (float)( t - mStates[mCurrKey]->mTime ) ); + mTauConverter.x = mTauVector.x; mTauConverter.y = mTauVector.y; mTauConverter.z = mTauVector.z; mTauConverter.w = 0.0f; @@ -93,36 +90,34 @@ Quaternion* TriRigidOrientation::GetValueAt( Vector3* TriRigidOrientation::GetValueDotAt( Vector3* in, - Be::Time now - ) -{ - return GetValueDotAt(in, TimeAsDouble(now - mStart)); + Be::Time now ) +{ + return GetValueDotAt( in, TimeAsDouble( now - mStart ) ); } Vector3* TriRigidOrientation::GetValueDotAt( - Vector3* in, - double t - ) -{ - if ((mStates.GetSize() == 0) || (t < 0.0) || (t < (mStates[0]->mTime))) - {// there are no keys, the curve hasn't begun or t is before the first key - *in = Vector3(0.0f, 0.0f, 0.0f); + Vector3* in, + double t ) +{ + if( ( mStates.GetSize() == 0 ) || ( t < 0.0 ) || ( t < ( mStates[0]->mTime ) ) ) + { // there are no keys, the curve hasn't begun or t is before the first key + *in = Vector3( 0.0f, 0.0f, 0.0f ); return in; - } - Seek(t); + } + Seek( t ); - return TriVectorExponentialDecay(in, - &mStates[mCurrKey]->mOmega0, - &mStates[mCurrKey]->mTorque, - mI, mDrag, - float(t - mStates[mCurrKey]->mTime)); + return TriVectorExponentialDecay( in, + &mStates[mCurrKey]->mOmega0, + &mStates[mCurrKey]->mTorque, + mI, + mDrag, + float( t - mStates[mCurrKey]->mTime ) ); } Quaternion* TriRigidOrientation::GetValueDotAt( Quaternion* in, - Be::Time time - ) + Be::Time time ) { return in; } @@ -130,8 +125,7 @@ Quaternion* TriRigidOrientation::GetValueDotAt( Quaternion* TriRigidOrientation::GetValueDotAt( Quaternion* in, - double time - ) + double time ) { return in; } @@ -139,8 +133,7 @@ Quaternion* TriRigidOrientation::GetValueDotAt( Quaternion* TriRigidOrientation::GetValueDoubleDotAt( Quaternion* in, - Be::Time time - ) + Be::Time time ) { return in; } @@ -148,79 +141,80 @@ Quaternion* TriRigidOrientation::GetValueDoubleDotAt( Quaternion* TriRigidOrientation::GetValueDoubleDotAt( Quaternion* in, - double time - ) + double time ) { return in; } void TriRigidOrientation::Seek( - double t - ) -{ + double t ) +{ int n = (int)mStates.GetSize(); - if(t >= mStates.back()->mTime) + if( t >= mStates.back()->mTime ) { - mCurrKey = n-1; + mCurrKey = n - 1; return; } - else if (mCurrKey == n-1) + else if( mCurrKey == n - 1 ) mCurrKey = 0; - - if( (t < mStates[mCurrKey]->mTime) || - (t >= mStates[mCurrKey+1]->mTime)) + + if( ( t < mStates[mCurrKey]->mTime ) || + ( t >= mStates[mCurrKey + 1]->mTime ) ) { - for(mCurrKey=0; mCurrKey < n-1;mCurrKey++) + for( mCurrKey = 0; mCurrKey < n - 1; mCurrKey++ ) { - if( (t >= mStates[mCurrKey]->mTime) && - (t < mStates[mCurrKey+1]->mTime)) + if( ( t >= mStates[mCurrKey]->mTime ) && + ( t < mStates[mCurrKey + 1]->mTime ) ) break; } - } + } } ///////////////////////////////////////////////////////////////////////////////////////// // compare function ///////////////////////////////////////////////////////////////////////////////////////// -static bool CompareKeys(IRoot* context, TriTorque* a, TriTorque* b) +static bool CompareKeys( IRoot* context, TriTorque* a, TriTorque* b ) { return a->mTime < b->mTime; } -void TriRigidOrientation::Sort( - ) +void TriRigidOrientation::Sort() { - mStates.Sort((IList::CompareFn)CompareKeys, NULL); + mStates.Sort( (IList::CompareFn)CompareKeys, NULL ); mCurrKey = 0; // go over all the keys and set the correct // initial states by extrapolating from the state before - for(int i = 1; i < mStates.GetSize(); i++) - { + for( int i = 1; i < mStates.GetSize(); i++ ) + { TriTorque* cs = mStates[i]; - TriTorque* cs_1 = mStates[i-1]; + TriTorque* cs_1 = mStates[i - 1]; float time = cs->mTime - cs_1->mTime; TriVectorExponentialDecay( - &cs->mOmega0, - &cs_1->mOmega0, - &cs_1->mTorque, - mI, mDrag, time); - Vector3 ZeroVec(0.0f, 0.0f, 0.0f); + &cs->mOmega0, + &cs_1->mOmega0, + &cs_1->mTorque, + mI, + mDrag, + time ); + Vector3 ZeroVec( 0.0f, 0.0f, 0.0f ); TriVectorExponentialDecayInteger( &mTauVector, - &ZeroVec, - &cs_1->mOmega0, - &cs_1->mTorque, - mI, mDrag, time); - mTauConverter.x = mTauVector.x; + &ZeroVec, + &cs_1->mOmega0, + &cs_1->mTorque, + mI, + mDrag, + time ); + mTauConverter.x = mTauVector.x; mTauConverter.y = mTauVector.y; mTauConverter.z = mTauVector.z; mTauConverter.w = 0.0f; mTauConverter = Exp( mTauConverter ); cs->mRot0 = cs_1->mRot0 * mTauConverter; } - if (mStates.GetSize() > 0) + if( mStates.GetSize() > 0 ) { mValue = mStates[0]->mRot0; } diff --git a/trinity/TriRigidOrientation.h b/trinity/TriRigidOrientation.h index 58656e806..76232d5ad 100644 --- a/trinity/TriRigidOrientation.h +++ b/trinity/TriRigidOrientation.h @@ -4,36 +4,34 @@ #define _TRIRIGIDORIENTATION_H_ #define TRIRIGIDORIENTATION_Description \ -"To be written" + "To be written" #include -class TriTorque: - public IRoot +class TriTorque : public IRoot { -public: +public: EXPOSE_TO_BLUE(); float mTime; Quaternion mRot0; Vector3 mOmega0; - Vector3 mTorque; - - TriTorque(IRoot* lockobj = NULL); + Vector3 mTorque; + + TriTorque( IRoot* lockobj = NULL ); public: }; -TYPEDEF_BLUECLASS(TriTorque); +TYPEDEF_BLUECLASS( TriTorque ); BLUE_DECLARE_VECTOR( TriTorque ); -class TriRigidOrientation: - public ITriQuaternionFunction +class TriRigidOrientation : public ITriQuaternionFunction { -public: +public: EXPOSE_TO_BLUE(); - std::wstring mName; + std::wstring mName; Be::Time mStart; float mI; float mDrag; @@ -41,82 +39,75 @@ class TriRigidOrientation: PTriTorqueVector mStates; int mCurrKey; - + ///////////////////////////////////////////////////////////////////////////////////// // ITriFunction ///////////////////////////////////////////////////////////////////////////////////// - void UpdateValue( double time ) { Quaternion q; Update( &q, time ); } + void UpdateValue( double time ) + { + Quaternion q; + Update( &q, time ); + } ///////////////////////////////////////////////////////////////////////////////////// // ITriVectorFunction ///////////////////////////////////////////////////////////////////////////////////// - + Quaternion* Update( Quaternion* in, - Be::Time time - ); + Be::Time time ); Quaternion* Update( Quaternion* in, - double time - ); - + double time ); + Quaternion* GetValueAt( Quaternion* in, - Be::Time time - ); + Be::Time time ); Quaternion* GetValueAt( Quaternion* in, - double time - ); + double time ); Quaternion* GetValueDotAt( Quaternion* in, - Be::Time time - ); + Be::Time time ); Quaternion* GetValueDotAt( Quaternion* in, - double time - ); + double time ); Quaternion* GetValueDoubleDotAt( Quaternion* in, - Be::Time time - ); + Be::Time time ); Quaternion* GetValueDoubleDotAt( Quaternion* in, - double time - ); + double time ); ///////////////////////////////////////////////////////////////////////////////////// // Other :-) ///////////////////////////////////////////////////////////////////////////////////// - + Vector3* GetValueDotAt( Vector3* in, - Be::Time time - ); + Be::Time time ); Vector3* GetValueDotAt( Vector3* in, - double time - ); + double time ); - void Sort( - ); + void Sort(); - TriRigidOrientation(IRoot* lockobj = NULL); + TriRigidOrientation( IRoot* lockobj = NULL ); ~TriRigidOrientation(); + private: Vector3 mTauVector; Quaternion mTauConverter; void Seek( - double t - ); + double t ); }; -TYPEDEF_BLUECLASS(TriRigidOrientation); +TYPEDEF_BLUECLASS( TriRigidOrientation ); #endif \ No newline at end of file diff --git a/trinity/TriRigidOrientation_Blue.cpp b/trinity/TriRigidOrientation_Blue.cpp index 797d9c1e5..8a397b4cf 100644 --- a/trinity/TriRigidOrientation_Blue.cpp +++ b/trinity/TriRigidOrientation_Blue.cpp @@ -8,9 +8,9 @@ BLUE_DEFINE( TriRigidOrientation ); const Be::ClassInfo* TriTorque::ExposeToBlue() { - EXPOSURE_BEGIN(TriTorque, "no comment") + EXPOSURE_BEGIN( TriTorque, "no comment" ) - MAP_ATTRIBUTE( "time", mTime, "na", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "time", mTime, "na", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "rot0", mRot0, "na", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "omega0", mOmega0, "na", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "torque", mTorque, "na", Be::READWRITE | Be::PERSIST ) @@ -20,80 +20,64 @@ const Be::ClassInfo* TriTorque::ExposeToBlue() const Be::ClassInfo* TriRigidOrientation::ExposeToBlue() { - EXPOSURE_BEGIN(TriRigidOrientation, "no comment\n:jessica-deprecated:") - MAP_INTERFACE(ITriFunction) - MAP_INTERFACE(ITriQuaternionFunction) + EXPOSURE_BEGIN( TriRigidOrientation, "no comment\n:jessica-deprecated:" ) + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( ITriQuaternionFunction ) //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - mName, - "Yes you can name your rigid rotation", - Be::READWRITE | Be::PERSIST - ) - + MAP_ATTRIBUTE( + "name", + mName, + "Yes you can name your rigid rotation", + Be::READWRITE | Be::PERSIST ) + //////////////////////////////////////////////////////////////////////////// // I - MAP_ATTRIBUTE - ( - "I", - mI, - "moment of inertia", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "I", + mI, + "moment of inertia", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // drag - MAP_ATTRIBUTE - ( - "drag", - mDrag, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "drag", + mDrag, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // value - MAP_ATTRIBUTE - ( - "value", - mValue, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "value", + mValue, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // start - MAP_ATTRIBUTE - ( - "start", - mStart, - "", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "start", + mStart, + "", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // forces - MAP_ATTRIBUTE - ( - "states", - mStates, - "na", - Be::READ | Be::PERSIST - ) + MAP_ATTRIBUTE( + "states", + mStates, + "na", + Be::READ | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // Sort - MAP_METHOD_AND_WRAP - ( - "Sort", + MAP_METHOD_AND_WRAP( + "Sort", Sort, - "Sorts the force list, based on time" - ) + "Sorts the force list, based on time" ) EXPOSURE_END() - } - diff --git a/trinity/TriSequencer.cpp b/trinity/TriSequencer.cpp index 8f92a017e..4a6cbb1af 100644 --- a/trinity/TriSequencer.cpp +++ b/trinity/TriSequencer.cpp @@ -27,12 +27,12 @@ static inline void FunctionLength( ITriFunctionPtr curve, float& maxDuration ) } -TriVectorSequencer::TriVectorSequencer(IRoot* lockobj) : - mStart ( 0 ), +TriVectorSequencer::TriVectorSequencer( IRoot* lockobj ) : + mStart( 0 ), mOperator( TRIOP_MULTIPLY ), mValue( 0.0f, 0.0f, 0.0f ), - PARENTLOCK(mFunctions, ITriVectorFunction) -{ + PARENTLOCK( mFunctions, ITriVectorFunction ) +{ } TriVectorSequencer::~TriVectorSequencer() @@ -44,47 +44,43 @@ TriVectorSequencer::~TriVectorSequencer() ///////////////////////////////////////////////////////////////////////////////////// Vector3* TriVectorSequencer::Update( Vector3* in, - Be::Time t - ) -{ - GetValueAt(in, t); + Be::Time t ) +{ + GetValueAt( in, t ); mValue = *in; return in; } Vector3* TriVectorSequencer::Update( Vector3* in, - double t - ) + double t ) { - GetValueAt(in, t); + GetValueAt( in, t ); mValue = *in; return in; } Vector3* TriVectorSequencer::GetValueAt( Vector3* in, - Be::Time now - ) -{ - if (mOperator == TRIOP_MULTIPLY) - return GetValueAtMult(in, now); - else if(mOperator == TRIOP_ADD) - return GetValueAtAdd(in, now); + Be::Time now ) +{ + if( mOperator == TRIOP_MULTIPLY ) + return GetValueAtMult( in, now ); + else if( mOperator == TRIOP_ADD ) + return GetValueAtAdd( in, now ); else - return GetValueAtAverage(in, now); + return GetValueAtAverage( in, now ); } Vector3* TriVectorSequencer::GetValueAtMult( Vector3* in, - Be::Time now - ) + Be::Time now ) { - *in = Vector3(1.0f, 1.0f, 1.0f); + *in = Vector3( 1.0f, 1.0f, 1.0f ); Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, now); + mFunctions[i]->GetValueAt( &temp, now ); in->x *= temp.x; in->y *= temp.y; in->z *= temp.z; @@ -94,15 +90,14 @@ Vector3* TriVectorSequencer::GetValueAtMult( Vector3* TriVectorSequencer::GetValueAtAverage( Vector3* in, - Be::Time now - ) + Be::Time now ) { - *in = Vector3(0.0f, 0.0f, 0.0f); + *in = Vector3( 0.0f, 0.0f, 0.0f ); Vector3 temp; float multiplier = 1.f / (float)mFunctions.GetSize(); - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, now); + mFunctions[i]->GetValueAt( &temp, now ); *in += temp * multiplier; } return in; @@ -110,14 +105,13 @@ Vector3* TriVectorSequencer::GetValueAtAverage( Vector3* TriVectorSequencer::GetValueAtAdd( Vector3* in, - Be::Time now - ) + Be::Time now ) { - *in = Vector3(0.0f, 0.0f, 0.0f); + *in = Vector3( 0.0f, 0.0f, 0.0f ); Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, now); + mFunctions[i]->GetValueAt( &temp, now ); *in += temp; } return in; @@ -125,27 +119,25 @@ Vector3* TriVectorSequencer::GetValueAtAdd( Vector3* TriVectorSequencer::GetValueAt( Vector3* in, - double pos - ) + double pos ) { - if (mOperator == TRIOP_MULTIPLY) - return GetValueAtMult(in, pos); - else if(mOperator == TRIOP_ADD) - return GetValueAtAdd(in, pos); + if( mOperator == TRIOP_MULTIPLY ) + return GetValueAtMult( in, pos ); + else if( mOperator == TRIOP_ADD ) + return GetValueAtAdd( in, pos ); else - return GetValueAtAverage(in, pos); + return GetValueAtAverage( in, pos ); } Vector3* TriVectorSequencer::GetValueAtMult( Vector3* in, - double pos - ) + double pos ) { - *in = Vector3(1.0f, 1.0f, 1.0f); + *in = Vector3( 1.0f, 1.0f, 1.0f ); Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, pos); + mFunctions[i]->GetValueAt( &temp, pos ); in->x *= temp.x; in->y *= temp.y; in->z *= temp.z; @@ -155,14 +147,13 @@ Vector3* TriVectorSequencer::GetValueAtMult( Vector3* TriVectorSequencer::GetValueAtAdd( Vector3* in, - double pos - ) + double pos ) { - *in = Vector3(0.0f, 0.0f, 0.0f); + *in = Vector3( 0.0f, 0.0f, 0.0f ); Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, pos); + mFunctions[i]->GetValueAt( &temp, pos ); *in += temp; } return in; @@ -170,15 +161,14 @@ Vector3* TriVectorSequencer::GetValueAtAdd( Vector3* TriVectorSequencer::GetValueAtAverage( Vector3* in, - double pos - ) + double pos ) { - *in = Vector3(0.0f, 0.0f, 0.0f); + *in = Vector3( 0.0f, 0.0f, 0.0f ); Vector3 temp; float multiplier = 1.f / (float)mFunctions.GetSize(); - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueAt(&temp, pos); + mFunctions[i]->GetValueAt( &temp, pos ); *in += temp * multiplier; } return in; @@ -186,14 +176,15 @@ Vector3* TriVectorSequencer::GetValueAtAverage( Vector3* TriVectorSequencer::GetValueDotAt( Vector3* in, - Be::Time now - ) -{ - in->x = 0.0f; in->y = 0.0f; in->z = 0.0f; + Be::Time now ) +{ + in->x = 0.0f; + in->y = 0.0f; + in->z = 0.0f; Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueDotAt(&temp, now); + mFunctions[i]->GetValueDotAt( &temp, now ); *in += temp; } return in; @@ -202,14 +193,15 @@ Vector3* TriVectorSequencer::GetValueDotAt( Vector3* TriVectorSequencer::GetValueDotAt( Vector3* in, - double pos - ) + double pos ) { - in->x = 0.0f; in->y = 0.0f; in->z = 0.0f; + in->x = 0.0f; + in->y = 0.0f; + in->z = 0.0f; Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueDotAt(&temp, pos); + mFunctions[i]->GetValueDotAt( &temp, pos ); *in += temp; } return in; @@ -217,14 +209,15 @@ Vector3* TriVectorSequencer::GetValueDotAt( Vector3* TriVectorSequencer::GetValueDoubleDotAt( Vector3* in, - Be::Time now - ) -{ - in->x = 0.0f; in->y = 0.0f; in->z = 0.0f; + Be::Time now ) +{ + in->x = 0.0f; + in->y = 0.0f; + in->z = 0.0f; Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueDoubleDotAt(&temp, now); + mFunctions[i]->GetValueDoubleDotAt( &temp, now ); *in += temp; } return in; @@ -233,14 +226,15 @@ Vector3* TriVectorSequencer::GetValueDoubleDotAt( Vector3* TriVectorSequencer::GetValueDoubleDotAt( Vector3* in, - double pos - ) + double pos ) { - in->x = 0.0f; in->y = 0.0f; in->z = 0.0f; + in->x = 0.0f; + in->y = 0.0f; + in->z = 0.0f; Vector3 temp; - for(int i = 0; i < mFunctions.GetSize(); i++) + for( int i = 0; i < mFunctions.GetSize(); i++ ) { - mFunctions[i]->GetValueDoubleDotAt(&temp, pos); + mFunctions[i]->GetValueDoubleDotAt( &temp, pos ); *in += temp; } return in; @@ -248,32 +242,31 @@ Vector3* TriVectorSequencer::GetValueDoubleDotAt( #if BLUE_WITH_PYTHON -PyObject* TriVectorSequencer::PyGetValueDoubleDotAt(PyObject* args) -{ +PyObject* TriVectorSequencer::PyGetValueDoubleDotAt( PyObject* args ) +{ PyObject* t; - if (!PyArg_ParseTuple(args, "O", &t)) + if( !PyArg_ParseTuple( args, "O", &t ) ) return NULL; ITriVectorPtr q; - q.Attach(new OTriVector); - - if (PyLong_Check(t)) + q.Attach( new OTriVector ); + + if( PyLong_Check( t ) ) { - Vector3 temp; - q->SetVector( GetValueDoubleDotAt(&temp, (Be::Time)PyLong_AsLongLong(t)) ); + Vector3 temp; + q->SetVector( GetValueDoubleDotAt( &temp, (Be::Time)PyLong_AsLongLong( t ) ) ); } - else if (PyFloat_Check(t)) + else if( PyFloat_Check( t ) ) { - Vector3 temp; - q->SetVector( GetValueDoubleDotAt(&temp, PyFloat_AS_DOUBLE(t)) ); + Vector3 temp; + q->SetVector( GetValueDoubleDotAt( &temp, PyFloat_AS_DOUBLE( t ) ) ); } else { - BeOS->SetError(BEDEF, Clsid(), - "arg must be of type LongLong (Be::Time) or float"); + BeOS->SetError( BEDEF, Clsid(), "arg must be of type LongLong (Be::Time) or float" ); return nullptr; - } - return PyOS->WrapBlueObject(q); + } + return PyOS->WrapBlueObject( q ); } #endif @@ -281,12 +274,12 @@ PyObject* TriVectorSequencer::PyGetValueDoubleDotAt(PyObject* args) //Color -TriColorSequencer::TriColorSequencer(IRoot* lockobj) : - mStart ( 0 ), - mOperator( TRIOP_MULTIPLY ), - mValue( 0.0f, 0.0f, 0.0f, 0.0f ), - PARENTLOCK(mFunctions, ITriColorFunction) -{ +TriColorSequencer::TriColorSequencer( IRoot* lockobj ) : + mStart( 0 ), + mOperator( TRIOP_MULTIPLY ), + mValue( 0.0f, 0.0f, 0.0f, 0.0f ), + PARENTLOCK( mFunctions, ITriColorFunction ) +{ } TriColorSequencer::~TriColorSequencer() @@ -309,116 +302,106 @@ float TriColorSequencer::Length() } Color* TriColorSequencer::Update( - Color* in, - Be::Time t - ) -{ - GetValueAt(in, t); - mValue = *in; - return in; + Color* in, + Be::Time t ) +{ + GetValueAt( in, t ); + mValue = *in; + return in; } Color* TriColorSequencer::Update( - Color* in, - double t - ) + Color* in, + double t ) { - GetValueAt(in, t); + GetValueAt( in, t ); mValue = *in; - return in; + return in; } Color* TriColorSequencer::GetValueAt( - Color* in, - Be::Time now - ) -{ - if (mOperator == TRIOP_MULTIPLY) - return GetValueAtMult(in, now); - else - return GetValueAtAdd(in, now); + Color* in, + Be::Time now ) +{ + if( mOperator == TRIOP_MULTIPLY ) + return GetValueAtMult( in, now ); + else + return GetValueAtAdd( in, now ); } Color* TriColorSequencer::GetValueAtMult( - Color* in, - Be::Time now - ) -{ - *in = Color(1.0f, 1.0f, 1.0f,1.0f); - Color temp; - for(int i = 0; i < mFunctions.GetSize(); i++) - { - mFunctions[i]->GetValueAt(&temp, now); - in->r *= temp.r; - in->g *= temp.g; - in->b *= temp.b; + Color* in, + Be::Time now ) +{ + *in = Color( 1.0f, 1.0f, 1.0f, 1.0f ); + Color temp; + for( int i = 0; i < mFunctions.GetSize(); i++ ) + { + mFunctions[i]->GetValueAt( &temp, now ); + in->r *= temp.r; + in->g *= temp.g; + in->b *= temp.b; in->a *= temp.a; - - } - return in; + } + return in; } Color* TriColorSequencer::GetValueAtAdd( - Color* in, - Be::Time now - ) + Color* in, + Be::Time now ) { - *in = Color(0.0f, 0.0f, 0.0f,0.0f); + *in = Color( 0.0f, 0.0f, 0.0f, 0.0f ); - Color temp; - for(int i = 0; i < mFunctions.GetSize(); i++) - { - mFunctions[i]->GetValueAt(&temp, now); - *in += temp; - } - return in; + Color temp; + for( int i = 0; i < mFunctions.GetSize(); i++ ) + { + mFunctions[i]->GetValueAt( &temp, now ); + *in += temp; + } + return in; } Color* TriColorSequencer::GetValueAt( - Color* in, - double pos - ) + Color* in, + double pos ) { - if (mOperator == TRIOP_MULTIPLY) - return GetValueAtMult(in, pos); - else - return GetValueAtAdd(in, pos); + if( mOperator == TRIOP_MULTIPLY ) + return GetValueAtMult( in, pos ); + else + return GetValueAtAdd( in, pos ); } Color* TriColorSequencer::GetValueAtMult( - Color* in, - double pos - ) -{ - *in = Color(1.0f, 1.0f, 1.0f,1.0f); - - Color temp; - for(int i = 0; i < mFunctions.GetSize(); i++) - { - mFunctions[i]->GetValueAt(&temp, pos); - in->r *= temp.r; - in->g *= temp.g; - in->b *= temp.b; - in->a *= temp.a; + Color* in, + double pos ) +{ + *in = Color( 1.0f, 1.0f, 1.0f, 1.0f ); - } - return in; + Color temp; + for( int i = 0; i < mFunctions.GetSize(); i++ ) + { + mFunctions[i]->GetValueAt( &temp, pos ); + in->r *= temp.r; + in->g *= temp.g; + in->b *= temp.b; + in->a *= temp.a; + } + return in; } Color* TriColorSequencer::GetValueAtAdd( - Color* in, - double pos - ) + Color* in, + double pos ) { - *in = Color(1.0f, 1.0f, 1.0f,1.0f); + *in = Color( 1.0f, 1.0f, 1.0f, 1.0f ); - Color temp; - for(int i = 0; i < mFunctions.GetSize(); i++) - { - mFunctions[i]->GetValueAt(&temp, pos); - *in += temp; - } - return in; + Color temp; + for( int i = 0; i < mFunctions.GetSize(); i++ ) + { + mFunctions[i]->GetValueAt( &temp, pos ); + *in += temp; + } + return in; } @@ -427,24 +410,24 @@ Color* TriColorSequencer::GetValueAtAdd( -TriPerlinCurve::TriPerlinCurve(IRoot* lockobj) : - mValue ( 0.0f ), - mAlpha ( 1.1f), - mBeta ( 2.0f), - mSpeed ( 1.0f), - mScale ( 1.0f), - mOffset ( 0.0f), - mN ( 3 ), - mLastUpdated(-1.0), - mStart (0) +TriPerlinCurve::TriPerlinCurve( IRoot* lockobj ) : + mValue( 0.0f ), + mAlpha( 1.1f ), + mBeta( 2.0f ), + mSpeed( 1.0f ), + mScale( 1.0f ), + mOffset( 0.0f ), + mN( 3 ), + mLastUpdated( -1.0 ), + mStart( 0 ) { - // time is set automatically so that the algorithm doesn't try to calculate the + // time is set automatically so that the algorithm doesn't try to calculate the // curve many years forward (from time 0), resulting in floating point error jitteriness // Downside is that if a client runs without restart for several years, floating point errors occur. // I'll take the risk! //mStart = BeOS->GetActualTime(); - mStartOffset = TriRandInt((int)10000000000); + mStartOffset = TriRandInt( (int)10000000000 ); } TriPerlinCurve::~TriPerlinCurve() @@ -455,40 +438,41 @@ TriPerlinCurve::~TriPerlinCurve() // ITriFunction ///////////////////////////////////////////////////////////////////////////////////// float TriPerlinCurve::Update( - Be::Time t - ) + Be::Time t ) { - if (mLastUpdated == TimeAsDouble(t)){ + if( mLastUpdated == TimeAsDouble( t ) ) + { return mValue; } - else{ - mLastUpdated = TimeAsDouble(t); - return mValue = GetValueAt(t); + else + { + mLastUpdated = TimeAsDouble( t ); + return mValue = GetValueAt( t ); } } float TriPerlinCurve::Update( - double t - ) + double t ) { - if (mLastUpdated == t){ + if( mLastUpdated == t ) + { return mValue; } - else{ + else + { mLastUpdated = t; - return mValue = GetValueAt(t); + return mValue = GetValueAt( t ); } } float TriPerlinCurve::GetValueAt( - Be::Time now - ) + Be::Time now ) { - if (mStart == 0.0) - mStart = TimeAsDouble(now); + if( mStart == 0.0 ) + mStart = TimeAsDouble( now ); - double pos = TimeAsDouble(now) - mStart; + double pos = TimeAsDouble( now ) - mStart; if( g_expressionCurveFakeRandom ) { pos = pos * mSpeed + 0.21f; @@ -498,19 +482,18 @@ float TriPerlinCurve::GetValueAt( pos += mStartOffset; pos *= mSpeed; } - double ret = ((PerlinNoise1D(pos, mAlpha, mBeta, mN) + 1.0) / 2.0 ) * mScale + mOffset; + double ret = ( ( PerlinNoise1D( pos, mAlpha, mBeta, mN ) + 1.0 ) / 2.0 ) * mScale + mOffset; return (float)ret; } float TriPerlinCurve::GetValueAt( - double pos - ) + double pos ) { -// if (mStart == 0.0) -// mStart = pos; -// -// pos -= mStart; + // if (mStart == 0.0) + // mStart = pos; + // + // pos -= mStart; if( g_expressionCurveFakeRandom ) { @@ -521,13 +504,12 @@ float TriPerlinCurve::GetValueAt( pos += mStartOffset; pos *= mSpeed; } - return (((float)PerlinNoise1D( pos, mAlpha, mBeta, mN) + 1.0f ) / 2.0f) * mScale + mOffset; + return ( ( (float)PerlinNoise1D( pos, mAlpha, mBeta, mN ) + 1.0f ) / 2.0f ) * mScale + mOffset; } void TriPerlinCurve::ScaleTime( - float s - ) + float s ) { mScale = s; } diff --git a/trinity/TriSequencer.h b/trinity/TriSequencer.h index 551465f87..0ce2b57d7 100644 --- a/trinity/TriSequencer.h +++ b/trinity/TriSequencer.h @@ -26,74 +26,75 @@ BLUE_CLASS( TriVectorSequencer ) : public: EXPOSE_TO_BLUE(); - std::wstring mName; + std::wstring mName; Be::Time mStart; - Vector3 mValue; - TRIOPERATOR mOperator; + Vector3 mValue; + TRIOPERATOR mOperator; ///////////////////////////////////////////////////////////////////////////////////// // ITriFunction ///////////////////////////////////////////////////////////////////////////////////// - void UpdateValue( double time ) { Vector3 v; Update( &v, time ); } + void UpdateValue( double time ) + { + Vector3 v; + Update( &v, time ); + } ///////////////////////////////////////////////////////////////////////////////////// // ITriVectorFunction ///////////////////////////////////////////////////////////////////////////////////// Vector3* Update( - Vector3* in, - Be::Time time - ); + Vector3 * in, + Be::Time time ); Vector3* Update( - Vector3* in, - double time - ); + Vector3 * in, + double time ); Vector3* GetValueAt( - Vector3* in, - Be::Time time - ); + Vector3 * in, + Be::Time time ); Vector3* GetValueAt( - Vector3* in, - double time - ); + Vector3 * in, + double time ); Vector3* GetValueDotAt( - Vector3* in, - Be::Time time - ); + Vector3 * in, + Be::Time time ); Vector3* GetValueDotAt( - Vector3* in, - double time - ); + Vector3 * in, + double time ); Vector3* GetValueDoubleDotAt( - Vector3* in, - Be::Time time - ); + Vector3 * in, + Be::Time time ); Vector3* GetValueDoubleDotAt( - Vector3* in, - double time - ); - Vector3d* InterpolatedPosition(Vector3d* out, Be::Time) {return out;}; + Vector3 * in, + double time ); + Vector3d* InterpolatedPosition( Vector3d * out, Be::Time ) + { + return out; + }; PITriVectorFunctionVector mFunctions; - TriVectorSequencer(IRoot* lockobj = NULL); + TriVectorSequencer( IRoot* lockobj = NULL ); ~TriVectorSequencer(); + private: - Vector3* GetValueAtMult(Vector3* in, double pos); - Vector3* GetValueAtAdd(Vector3* in, double pos); - Vector3* GetValueAtAverage(Vector3* in, double pos); - Vector3* GetValueAtMult(Vector3* in, Be::Time now); - Vector3* GetValueAtAdd(Vector3* in, Be::Time now); - Vector3* GetValueAtAverage(Vector3* in, Be::Time now); + Vector3* GetValueAtMult( Vector3 * in, double pos ); + Vector3* GetValueAtAdd( Vector3 * in, double pos ); + Vector3* GetValueAtAverage( Vector3 * in, double pos ); + Vector3* GetValueAtMult( Vector3 * in, Be::Time now ); + Vector3* GetValueAtAdd( Vector3 * in, Be::Time now ); + Vector3* GetValueAtAverage( Vector3 * in, Be::Time now ); + public: #if BLUE_WITH_PYTHON - PyObject* PyGetValueDoubleDotAt( PyObject* args ); + PyObject* PyGetValueDoubleDotAt( PyObject * args ); #endif }; TYPEDEF_BLUECLASS( TriVectorSequencer ); @@ -105,56 +106,57 @@ TYPEDEF_BLUECLASS( TriVectorSequencer ); BLUE_CLASS( TriColorSequencer ) : - public ITriColorFunction, - public ITriCurveLength + public ITriColorFunction, + public ITriCurveLength { public: EXPOSE_TO_BLUE(); - std::wstring mName; - Be::Time mStart; - Color mValue; - TRIOPERATOR mOperator; - - ///////////////////////////////////////////////////////////////////////////////////// - // ITriFunction - ///////////////////////////////////////////////////////////////////////////////////// - void UpdateValue( double time ) { Color c; Update( &c, time ); } - - ///////////////////////////////////////////////////////////////////////////////////// - // ITriColorFunction - ///////////////////////////////////////////////////////////////////////////////////// - Color* Update( - Color* in, - Be::Time time - ); - - Color* Update( - Color* in, - double time - ); - - Color* GetValueAt( - Color* in, - Be::Time time - ); - - Color* GetValueAt( - Color* in, - double time - ); + std::wstring mName; + Be::Time mStart; + Color mValue; + TRIOPERATOR mOperator; + + ///////////////////////////////////////////////////////////////////////////////////// + // ITriFunction + ///////////////////////////////////////////////////////////////////////////////////// + void UpdateValue( double time ) + { + Color c; + Update( &c, time ); + } + + ///////////////////////////////////////////////////////////////////////////////////// + // ITriColorFunction + ///////////////////////////////////////////////////////////////////////////////////// + Color* Update( + Color * in, + Be::Time time ); + + Color* Update( + Color * in, + double time ); + + Color* GetValueAt( + Color * in, + Be::Time time ); + + Color* GetValueAt( + Color * in, + double time ); float Length(); PITriColorFunctionVector mFunctions; - TriColorSequencer(IRoot* lockobj = NULL); - ~TriColorSequencer(); + TriColorSequencer( IRoot* lockobj = NULL ); + ~TriColorSequencer(); + private: - Color* GetValueAtMult(Color* in, double pos); - Color* GetValueAtAdd(Color* in, double pos); - Color* GetValueAtMult(Color* in, Be::Time now); - Color* GetValueAtAdd(Color* in, Be::Time now); + Color* GetValueAtMult( Color * in, double pos ); + Color* GetValueAtAdd( Color * in, double pos ); + Color* GetValueAtMult( Color * in, Be::Time now ); + Color* GetValueAtAdd( Color * in, Be::Time now ); }; TYPEDEF_BLUECLASS( TriColorSequencer ); @@ -166,55 +168,53 @@ TYPEDEF_BLUECLASS( TriColorSequencer ); BLUE_CLASS( TriPerlinCurve ) : - public ITriScalarFunction + public ITriScalarFunction { public: EXPOSE_TO_BLUE(); - std::wstring mName; - double mStart; - float mValue; - float mSpeed; - float mAlpha; - float mBeta; + std::wstring mName; + double mStart; + float mValue; + float mSpeed; + float mAlpha; + float mBeta; float mOffset; float mScale; double mLastUpdated; long mStartOffset; - int32_t mN; + int32_t mN; - ///////////////////////////////////////////////////////////////////////////////////// - // ITriFunction - ///////////////////////////////////////////////////////////////////////////////////// - void UpdateValue( double time ) { Update( time ); } + ///////////////////////////////////////////////////////////////////////////////////// + // ITriFunction + ///////////////////////////////////////////////////////////////////////////////////// + void UpdateValue( double time ) + { + Update( time ); + } - ///////////////////////////////////////////////////////////////////////////////////// - // ITriScalarFunction - ///////////////////////////////////////////////////////////////////////////////////// - float Update( - Be::Time time - ); + ///////////////////////////////////////////////////////////////////////////////////// + // ITriScalarFunction + ///////////////////////////////////////////////////////////////////////////////////// + float Update( + Be::Time time ); - float Update( - double time - ); + float Update( + double time ); - float GetValueAt( - Be::Time time - ); + float GetValueAt( + Be::Time time ); - float GetValueAt( - double time - ); + float GetValueAt( + double time ); void ScaleTime( - float s - ); + float s ); - TriPerlinCurve(IRoot* lockobj = NULL); - ~TriPerlinCurve(); + TriPerlinCurve( IRoot* lockobj = NULL ); + ~TriPerlinCurve(); public: }; @@ -222,4 +222,3 @@ TYPEDEF_BLUECLASS( TriPerlinCurve ); #endif - diff --git a/trinity/TriSequencer_Blue.cpp b/trinity/TriSequencer_Blue.cpp index 4c3ef1d01..7bb0e6c6b 100644 --- a/trinity/TriSequencer_Blue.cpp +++ b/trinity/TriSequencer_Blue.cpp @@ -10,208 +10,170 @@ BLUE_DEFINE( TriPerlinCurve ); const Be::ClassInfo* TriVectorSequencer::ExposeToBlue() { - EXPOSURE_BEGIN(TriVectorSequencer, "no comment\n:jessica-deprecated:") - MAP_INTERFACE(ITriFunction) - MAP_INTERFACE(ITriVectorFunction) + EXPOSURE_BEGIN( TriVectorSequencer, "no comment\n:jessica-deprecated:" ) + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( ITriVectorFunction ) //////////////////////////////////////////////////////////////////////////// // name - MAP_ATTRIBUTE - ( - "name", - mName, - "Yes you can name your sequencer", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "name", + mName, + "Yes you can name your sequencer", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // start - MAP_ATTRIBUTE - ( - "start", - mStart, - "The time at which the sequence should begin", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "start", + mStart, + "The time at which the sequence should begin", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // value - MAP_ATTRIBUTE - ( - "value", - mValue, - "na", - Be::READWRITE | Be::PERSIST - ) + MAP_ATTRIBUTE( + "value", + mValue, + "na", + Be::READWRITE | Be::PERSIST ) //////////////////////////////////////////////////////////////////////////// // operator - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "operator", - mOperator, - "na", - Be::READWRITE | Be::PERSIST | Be::ENUM, - TriOperator - ) + MAP_ATTRIBUTE_WITH_CHOOSER( + "operator", + mOperator, + "na", + Be::READWRITE | Be::PERSIST | Be::ENUM, + TriOperator ) //////////////////////////////////////////////////////////////////////////// // functions - MAP_ATTRIBUTE - ( - "functions", + MAP_ATTRIBUTE( + "functions", mFunctions, - "These are the functions, whose values are added together", - Be::READ | Be::PERSIST - ) + "These are the functions, whose values are added together", + Be::READ | Be::PERSIST ) EXPOSURE_END() - } const Be::ClassInfo* TriColorSequencer::ExposeToBlue() { - EXPOSURE_BEGIN(TriColorSequencer, "Add or Multiply Color Curves \n:jessica-deprecated: True") - MAP_INTERFACE(ITriFunction) - MAP_INTERFACE(ITriColorFunction) - MAP_INTERFACE(ITriCurveLength) - - //////////////////////////////////////////////////////////////////////////// - // name - MAP_ATTRIBUTE - ( - "name", - mName, - "Yes you can name your sequencer", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // start - MAP_ATTRIBUTE - ( - "start", - mStart, - "The time at which the sequence should begin", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "value", - mValue, - "na", - Be::READWRITE | Be::PERSIST - ) - //////////////////////////////////////////////////////////////////////////// - // operator - MAP_ATTRIBUTE_WITH_CHOOSER - ( - "operator", - mOperator, - "na", - Be::READWRITE | Be::PERSIST | Be::ENUM, - TriOperator - ) - //////////////////////////////////////////////////////////////////////////// - // functions - MAP_ATTRIBUTE - ( - "functions", - mFunctions, - "These are the functions, whose values are added together", - Be::READ | Be::PERSIST - ) + EXPOSURE_BEGIN( TriColorSequencer, "Add or Multiply Color Curves \n:jessica-deprecated: True" ) + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( ITriColorFunction ) + MAP_INTERFACE( ITriCurveLength ) - EXPOSURE_END() + //////////////////////////////////////////////////////////////////////////// + // name + MAP_ATTRIBUTE( + "name", + mName, + "Yes you can name your sequencer", + Be::READWRITE | Be::PERSIST ) + //////////////////////////////////////////////////////////////////////////// + // start + MAP_ATTRIBUTE( + "start", + mStart, + "The time at which the sequence should begin", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "value", + mValue, + "na", + Be::READWRITE | Be::PERSIST ) + //////////////////////////////////////////////////////////////////////////// + // operator + MAP_ATTRIBUTE_WITH_CHOOSER( + "operator", + mOperator, + "na", + Be::READWRITE | Be::PERSIST | Be::ENUM, + TriOperator ) + //////////////////////////////////////////////////////////////////////////// + // functions + MAP_ATTRIBUTE( + "functions", + mFunctions, + "These are the functions, whose values are added together", + Be::READ | Be::PERSIST ) + + EXPOSURE_END() } const Be::ClassInfo* TriPerlinCurve::ExposeToBlue() { - EXPOSURE_BEGIN(TriPerlinCurve, "A scalar function that generates Perlin noise") - MAP_INTERFACE(ITriFunction) - MAP_INTERFACE(ITriScalarFunction) - - //////////////////////////////////////////////////////////////////////////// - // name - MAP_ATTRIBUTE - ( - "name", - mName, - "Yes you can name your sequencer", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "value", - mValue, - "The last value of the curve, can be set externally, wont be changed on Update() if lenght is 0", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "offset", - mOffset, - "The result of the perlin function is offset by this value. The default value is 0.0.", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "scale", - mScale, - "The result of the perlin function is multiplied by this value. The default value is 1.0.", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "alpha", - mAlpha, - "Alpha value. 1.0 is rough but larger numbers yield smoother curves. Values lower than 1.0 will give scalar values over beyond the range of 0.0 to 1.0, which is the intended range of the function.", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "speed", - mSpeed, - "Time multiplier. Higher numbers are faster. 1.0 is default", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "beta", - mBeta, - "beta is the harmonic scaling/spacing, typically 2", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - // value - MAP_ATTRIBUTE - ( - "N", - mN, - "N is the iteration count ( grain resolution ). Keep values in the range 1 to 4. Values higher than 4 are hardly noticable under regular circumstances.", - Be::READWRITE | Be::PERSIST - ) - - EXPOSURE_END() + EXPOSURE_BEGIN( TriPerlinCurve, "A scalar function that generates Perlin noise" ) + MAP_INTERFACE( ITriFunction ) + MAP_INTERFACE( ITriScalarFunction ) + + //////////////////////////////////////////////////////////////////////////// + // name + MAP_ATTRIBUTE( + "name", + mName, + "Yes you can name your sequencer", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "value", + mValue, + "The last value of the curve, can be set externally, wont be changed on Update() if lenght is 0", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "offset", + mOffset, + "The result of the perlin function is offset by this value. The default value is 0.0.", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "scale", + mScale, + "The result of the perlin function is multiplied by this value. The default value is 1.0.", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "alpha", + mAlpha, + "Alpha value. 1.0 is rough but larger numbers yield smoother curves. Values lower than 1.0 will give scalar values over beyond the range of 0.0 to 1.0, which is the intended range of the function.", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "speed", + mSpeed, + "Time multiplier. Higher numbers are faster. 1.0 is default", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "beta", + mBeta, + "beta is the harmonic scaling/spacing, typically 2", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + // value + MAP_ATTRIBUTE( + "N", + mN, + "N is the iteration count ( grain resolution ). Keep values in the range 1 to 4. Values higher than 4 are hardly noticable under regular circumstances.", + Be::READWRITE | Be::PERSIST ) + + EXPOSURE_END() } diff --git a/trinity/TriSettings.h b/trinity/TriSettings.h index 6294ed921..8e9329cbb 100644 --- a/trinity/TriSettings.h +++ b/trinity/TriSettings.h @@ -11,34 +11,34 @@ class TriSettings : public IRoot public: EXPOSE_TO_BLUE(); - template void RegisterSetting( const char* name, T* value ) - { + template + void RegisterSetting( const char* name, T* value ) + { Be::VARTYPE type = BlueTypeTraits::VARTYPE_VALUE; - RegisterSettingHelper( name, value, type, sizeof(T) ); + RegisterSettingHelper( name, value, type, sizeof( T ) ); } struct Setting { - Be::VARTYPE m_type; - size_t m_size; - Be::Var* m_var; + Be::VARTYPE m_type; + size_t m_size; + Be::Var* m_var; }; - typedef std::map SettingMap; + typedef std::map SettingMap; SettingMap m_map; Setting* FindSetting( const char* name ) { - SettingMap::iterator it = m_map.find( std::string(name) ); + SettingMap::iterator it = m_map.find( std::string( name ) ); if( it != m_map.end() ) { - return &(*it).second; + return &( *it ).second; } else { return NULL; } - } std::string GetReprString() @@ -72,11 +72,10 @@ class TriSettings : public IRoot s.m_size = size; s.m_var = (Be::Var*)value; - m_map[ name ] = s; - } - + m_map[name] = s; + } }; -TYPEDEF_BLUECLASS(TriSettings) +TYPEDEF_BLUECLASS( TriSettings ) #endif // TriSettings_H \ No newline at end of file diff --git a/trinity/TriSettingsRegistrar.h b/trinity/TriSettingsRegistrar.h index af82bfea0..3111b942f 100644 --- a/trinity/TriSettingsRegistrar.h +++ b/trinity/TriSettingsRegistrar.h @@ -16,7 +16,8 @@ class TriSettingsRegistrar { public: - template TriSettingsRegistrar( const char* name, T* value ) + template + TriSettingsRegistrar( const char* name, T* value ) { Tr2Renderer::GetSettings().RegisterSetting( name, value ); } diff --git a/trinity/TriSettings_Blue.cpp b/trinity/TriSettings_Blue.cpp index 6757eca68..546eb4699 100644 --- a/trinity/TriSettings_Blue.cpp +++ b/trinity/TriSettings_Blue.cpp @@ -7,7 +7,7 @@ BLUE_DEFINE_ABSTRACT( TriSettings ); std::string TriSettings::GetSettingReprString( const TriSettings::Setting* s ) { - char buff[ 512 ]; + char buff[512]; switch( s->m_type ) { case Be::LONG: @@ -16,27 +16,24 @@ std::string TriSettings::GetSettingReprString( const TriSettings::Setting* s ) case Be::BOOL: sprintf_s( buff, *(bool*)s->m_var ? "True" : "False" ); break; - case Be::FLOAT: - { - double d = *(float*)s->m_var; - sprintf_s( buff, "%f", d ); - } - break; + case Be::FLOAT: { + double d = *(float*)s->m_var; + sprintf_s( buff, "%f", d ); + } + break; case Be::DOUBLE: sprintf_s( buff, "%f", *(double*)s->m_var ); break; - case Be::SHORT: - { - int d = *(short*)s->m_var; - sprintf_s( buff, "%d", d ); - } - break; - case Be::CSTRING: - { - const char* string = *(const char**)s->m_var; - sprintf_s( buff, "'%s'", string ? string : "" ); - } - break; + case Be::SHORT: { + int d = *(short*)s->m_var; + sprintf_s( buff, "%d", d ); + } + break; + case Be::CSTRING: { + const char* string = *(const char**)s->m_var; + sprintf_s( buff, "'%s'", string ? string : "" ); + } + break; default: sprintf_s( buff, "NOT IMPLEMENTED YET! DO IT!" ); break; @@ -48,7 +45,7 @@ std::string TriSettings::GetSettingReprString( const TriSettings::Setting* s ) #if BLUE_WITH_PYTHON PyObject* PyRepr( PyObject* self, PyObject* args ) { - TriSettings* pThis = BluePythonCast(self); + TriSettings* pThis = BluePythonCast( self ); // the cast above will always succeed std::string repr = pThis->GetReprString(); @@ -57,10 +54,10 @@ PyObject* PyRepr( PyObject* self, PyObject* args ) static PyObject* PyGetValue( PyObject* self, PyObject* args ) { - TriSettings* pThis = BluePythonCast(self); + TriSettings* pThis = BluePythonCast( self ); // the cast above will always succeed - const char* key; + const char* key; if( !PyArg_ParseTuple( args, "s", &key ) ) { PyErr_SetString( PyExc_TypeError, "Function accepts one string argument!" ); @@ -84,10 +81,10 @@ static PyObject* PyGetValue( PyObject* self, PyObject* args ) static PyObject* PySetValue( PyObject* self, PyObject* args ) { - TriSettings* pThis = BluePythonCast(self); + TriSettings* pThis = BluePythonCast( self ); // the cast above will always succeed - const char* key; + const char* key; PyObject* value; if( !PyArg_ParseTuple( args, "sO", &key, &value ) ) { @@ -125,28 +122,25 @@ const Be::ClassInfo* TriSettings::ExposeToBlue() CTriSettings s; s.RegisterSetting( "bingo", &bingo ); EXPOSURE_BEGIN( TriSettings, "Encapsulates settings for Trinity" ) - MAP_INTERFACE(TriSettings) + MAP_INTERFACE( TriSettings ) - MAP_METHOD( - "GetValue", - PyGetValue, - "Returns a copy of the value assigned to the string key passed in\n" + MAP_METHOD( + "GetValue", + PyGetValue, + "Returns a copy of the value assigned to the string key passed in\n" ":param name: setting name\n" - ":type name: str\n" - ) - MAP_METHOD( - "SetValue", - PySetValue, - "Sets the string key to the value passed in\n" + ":type name: str\n" ) + MAP_METHOD( + "SetValue", + PySetValue, + "Sets the string key to the value passed in\n" ":param name: setting name\n" ":type name: str\n" - ":param value: setting value\n" - ) + ":param value: setting value\n" ) MAP_METHOD( "__repr__", PyRepr, - "Returns a string representation for the object" - ) + "Returns a string representation for the object" ) EXPOSURE_END() } diff --git a/trinity/TriUtil.h b/trinity/TriUtil.h index 507fc986c..fcaea050b 100644 --- a/trinity/TriUtil.h +++ b/trinity/TriUtil.h @@ -5,26 +5,27 @@ #ifndef TRIUTIL_H #define TRIUTIL_H -#define D3DPERF_EVENT(n) -#define D3DPERF_EVENTC(n,c) -#define D3DPERF_EVENT1(n,a1) -#define D3DPERF_MARKER(n) -#define D3DPERF_MARKERC(n,c) +#define D3DPERF_EVENT( n ) +#define D3DPERF_EVENTC( n, c ) +#define D3DPERF_EVENT1( n, a1 ) +#define D3DPERF_MARKER( n ) +#define D3DPERF_MARKERC( n, c ) // Use this nifty class template to create a singleton that never executes the destructor // on the templated type - thus allowing the object to remain intact until the program is // completely dead. -template class NeverEndingSingleton +template +class NeverEndingSingleton { private: - char m_buffer[sizeof(T)]; + char m_buffer[sizeof( T )]; T* m_instance; public: NeverEndingSingleton() { - // Placement new to initialize instance in the memory (we don't want to involve the + // Placement new to initialize instance in the memory (we don't want to involve the // dynamic memory manager) m_instance = new( m_buffer ) T; } @@ -39,6 +40,7 @@ template class NeverEndingSingleton { return *m_instance; } + private: NeverEndingSingleton( const NeverEndingSingleton& ) /* = delete */; NeverEndingSingleton& operator=( const NeverEndingSingleton& ) /* = delete */; @@ -67,7 +69,7 @@ inline float TriLinearToGamma( float value ) // Return value: // value in gamma 2.2 color space // ------------------------------------------------------------- -inline Vector2 TriLinearToGamma( const Vector2 &value ) +inline Vector2 TriLinearToGamma( const Vector2& value ) { return Vector2( XMVectorPow( value, XMVectorReplicate( 0.454545f ) ) ); } @@ -81,7 +83,7 @@ inline Vector2 TriLinearToGamma( const Vector2 &value ) // Return value: // value in gamma 2.2 color space // ------------------------------------------------------------- -inline Vector3 TriLinearToGamma( const Vector3 &value ) +inline Vector3 TriLinearToGamma( const Vector3& value ) { return Vector3( XMVectorPow( value, XMVectorReplicate( 0.454545f ) ) ); } @@ -89,14 +91,14 @@ inline Vector3 TriLinearToGamma( const Vector3 &value ) // ------------------------------------------------------------- // Description: // Converts value from linear color space to gamma 2.2 color -// space. Does not check if the value is denormalized. W +// space. Does not check if the value is denormalized. W // component is left unmodified. // Arguments: // value - value in linear color space // Return value: // value in gamma 2.2 color space // ------------------------------------------------------------- -inline Vector4 TriLinearToGamma( const Vector4 &value ) +inline Vector4 TriLinearToGamma( const Vector4& value ) { Vector4 result = Vector4( XMVectorPow( value, Vector4( 0.454545f, 0.454545f, 0.454545f, 1.f ) ) ); // Copy W component to guarantee that it is not changed by power function @@ -114,7 +116,7 @@ inline Vector4 TriLinearToGamma( const Vector4 &value ) // Return value: // value in gamma 2.2 color space // ------------------------------------------------------------- -inline Color TriLinearToGamma( const Color &value ) +inline Color TriLinearToGamma( const Color& value ) { Vector4 result = Vector4( XMVectorPow( XMLoadFloat4( (XMFLOAT4*)&value ), Vector4( 0.454545f, 0.454545f, 0.454545f, 1.f ) ) ); // Copy alpha component to guarantee that it is not changed by power function @@ -145,7 +147,7 @@ inline float TriGammaToLinear( float value ) // Return value: // value in linear color space // ------------------------------------------------------------- -inline Vector2 TriGammaToLinear( const Vector2 &value ) +inline Vector2 TriGammaToLinear( const Vector2& value ) { return Vector2( XMVectorPow( value, XMVectorReplicate( 2.2f ) ) ); } @@ -159,7 +161,7 @@ inline Vector2 TriGammaToLinear( const Vector2 &value ) // Return value: // value in linear color space // ------------------------------------------------------------- -inline Vector3 TriGammaToLinear( const Vector3 &value ) +inline Vector3 TriGammaToLinear( const Vector3& value ) { return Vector3( XMVectorPow( value, XMVectorReplicate( 2.2f ) ) ); } @@ -167,14 +169,14 @@ inline Vector3 TriGammaToLinear( const Vector3 &value ) // ------------------------------------------------------------- // Description: // Converts value from gamma 2.2 color space to linear color -// space. Does not check if the value is denormalized. W +// space. Does not check if the value is denormalized. W // component is left unmodified. // Arguments: // value - value in gamma 2.2 color space // Return value: // value in linear color space // ------------------------------------------------------------- -inline Vector4 TriGammaToLinear( const Vector4 &value ) +inline Vector4 TriGammaToLinear( const Vector4& value ) { Vector4 result = Vector4( XMVectorPow( value, XMVectorReplicate( 2.2f ) ) ); result.w = value.w; @@ -191,7 +193,7 @@ inline Vector4 TriGammaToLinear( const Vector4 &value ) // Return value: // value in linear color space // ------------------------------------------------------------- -inline Color TriGammaToLinear( const Color &value ) +inline Color TriGammaToLinear( const Color& value ) { Vector4 result = Vector4( XMVectorPow( XMLoadFloat4( (XMFLOAT4*)&value ), XMVectorReplicate( 2.2f ) ) ); result.w = value.a; @@ -200,35 +202,35 @@ inline Color TriGammaToLinear( const Color &value ) inline bool IsMatch( Be::Var* value, const Vector3& t ) { - return ( Be::Var* )&t == value; + return (Be::Var*)&t == value; } // -------------------------------------------------------------------------------------- inline bool IsMatch( Be::Var* value, const Vector4& t ) { - return ( Be::Var* )&t == value; + return (Be::Var*)&t == value; } // -------------------------------------------------------------------------------------- inline bool IsMatch( Be::Var* value, const Matrix& t ) { - return ( Be::Var* )&t == value; + return (Be::Var*)&t == value; } // -------------------------------------------------------------------------------------- inline bool IsMatch( Be::Var* value, const Color& t ) { - return ( Be::Var* )&t == value; + return (Be::Var*)&t == value; } // -------------------------------------------------------------------------------------- inline bool IsMatch( Be::Var* value, const Quaternion& t ) { - return ( Be::Var* )&t == value; + return (Be::Var*)&t == value; } // -------------------------------------------------------------------------------------- -template<> +template <> inline void BlueGetNullValue( Quaternion& resultRef ) { resultRef = IdentityQuaternion(); diff --git a/trinity/TriValueBinding.h b/trinity/TriValueBinding.h index 7ac37ad85..8217b964a 100644 --- a/trinity/TriValueBinding.h +++ b/trinity/TriValueBinding.h @@ -10,14 +10,14 @@ BLUE_DECLARE( TriValueBinding ); BLUE_DECLARE_VECTOR( TriValueBinding ); -BLUE_CLASS( TriValueBinding ): - public INotify, - public ITr2ValueBinding +BLUE_CLASS( TriValueBinding ) : + public INotify, + public ITr2ValueBinding { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); - TriValueBinding( IRoot* lockobj = NULL ); + TriValueBinding( IRoot* lockobj = NULL ); ~TriValueBinding(); virtual void Initialize(); @@ -26,7 +26,7 @@ BLUE_CLASS( TriValueBinding ): ////////////////////////////////////////////////////////////////////////// // INotify - virtual bool OnModified( Be::Var* val ); + virtual bool OnModified( Be::Var * val ); ////////////////////////////////////////////////////////////////////////// // ITr2ValueBinding @@ -43,7 +43,7 @@ BLUE_CLASS( TriValueBinding ): void SetDestination( const std::string& destAttribute, IRootPtr destination ); void SetScale( float scale ); - void CreateWeakBinding( IRoot* source, const char* sourceAttr, IRoot* dest, const char* destAttr, float scale = 1.0f, const Vector4& offset = Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) ); + void CreateWeakBinding( IRoot * source, const char* sourceAttr, IRoot* dest, const char* destAttr, float scale = 1.0f, const Vector4& offset = Vector4( 0.0f, 0.0f, 0.0f, 0.0f ) ); bool IsValid() const; @@ -52,10 +52,10 @@ BLUE_CLASS( TriValueBinding ): IRoot* GetCurrentDestinationObject() const; IRootPtr GetSourceObject() const; - void SetSourceObject( IRoot* sourceObject ); + void SetSourceObject( IRoot * sourceObject ); IRootPtr GetDestinationObject() const; - void SetDestinationObject( IRoot* destinationObject ); + void SetDestinationObject( IRoot * destinationObject ); std::string m_name; IRootPtr m_sourceObject; @@ -82,12 +82,12 @@ BLUE_CLASS( TriValueBinding ): Vector4 m_offset; INotify* m_notifyPtr; - typedef bool (*CopyFunc)( void* srcVar, void* dstVar, float scale, const Vector4& offset ); + typedef bool ( *CopyFunc )( void* srcVar, void* dstVar, float scale, const Vector4& offset ); CopyFunc m_copyFunc; BlueScriptCallback m_copyValueCallable; - virtual size_t DetermineCopyFunc( const Be::VarEntry* srcEntry, const Be::VarEntry* dstEntry, size_t dataSize, bool sourceFloatArrayAsFloat, bool destFloatArrayAsFloat ); + virtual size_t DetermineCopyFunc( const Be::VarEntry* srcEntry, const Be::VarEntry* dstEntry, size_t dataSize, bool sourceFloatArrayAsFloat, bool destFloatArrayAsFloat ); }; TYPEDEF_BLUECLASS( TriValueBinding ); diff --git a/trinity/TriValueBinding_Blue.cpp b/trinity/TriValueBinding_Blue.cpp index b02d62188..8adc68df8 100644 --- a/trinity/TriValueBinding_Blue.cpp +++ b/trinity/TriValueBinding_Blue.cpp @@ -9,109 +9,83 @@ BLUE_DEFINE_INTERFACE( ITr2ValueBinding ); const Be::ClassInfo* TriValueBinding::ExposeToBlue() { - EXPOSURE_BEGIN( TriValueBinding,"" ) - MAP_INTERFACE( TriValueBinding ) + EXPOSURE_BEGIN( TriValueBinding, "" ) + MAP_INTERFACE( TriValueBinding ) MAP_INTERFACE( ITr2ValueBinding ) MAP_INTERFACE( INotify ) - MAP_ATTRIBUTE - ( - "name", - m_name, + MAP_ATTRIBUTE( + "name", + m_name, "Name of this value binding.", - Be::READWRITE | Be::PERSIST - ) - MAP_PROPERTY_READONLY - ( + Be::READWRITE | Be::PERSIST ) + MAP_PROPERTY_READONLY( "isValid", IsValid, "True if this binding is valid, i.e. source object, source attribute\n" "destination object and destination attribute are all valid and if the\n" - "source and destination are of compatible types." - ) - MAP_ATTRIBUTE - ( + "source and destination are of compatible types." ) + MAP_ATTRIBUTE( "isWeak", m_isWeak, "True if this binding was set up to have weak references to the source and\n" "destination objects. Can only be set up for specific bindings in C++.", - Be::READ - ) - MAP_ATTRIBUTE - ( + Be::READ ) + MAP_ATTRIBUTE( "isEnabled", m_isEnabled, "If false the binding is disabled and will not update the destination\n" "attribute with the source attribute.\n", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "sourceObject", m_sourceObject, "Object providing the source value.", - Be::PERSISTONLY - ) - MAP_PROPERTY - ( - "sourceObject", - GetSourceObject, + Be::PERSISTONLY ) + MAP_PROPERTY( + "sourceObject", + GetSourceObject, SetSourceObject, - "Object providing the source value." - ) - MAP_ATTRIBUTE - ( - "sourceAttribute", - m_sourceAttribute, + "Object providing the source value." ) + MAP_ATTRIBUTE( + "sourceAttribute", + m_sourceAttribute, "Attribute of the source object. The value of this is copied to the" "named attribute of the destination object", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "destinationObject", m_destinationObject, "Destination object.", - Be::PERSISTONLY - ) - MAP_PROPERTY - ( + Be::PERSISTONLY ) + MAP_PROPERTY( "destinationObject", GetDestinationObject, SetDestinationObject, - "Destination object." - ) - MAP_ATTRIBUTE - ( + "Destination object." ) + MAP_ATTRIBUTE( "destinationAttribute", m_destinationAttribute, "Attribute of the destination object. The value coming from the" "source object is copied to here", - Be::READWRITE | Be::PERSIST | Be::NOTIFY - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST | Be::NOTIFY ) + MAP_ATTRIBUTE( "scale", m_scale, "Scale of source value before being applied to destination", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "offset", m_offset, "Offset of source value, added to it after the scaling, before being applied to destination", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) #if BLUE_WITH_PYTHON - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "copyValueCallable", m_copyValueCallable, "Python callable to handle CopyValue.", - Be::READWRITE | Be::NOTIFY - ) + Be::READWRITE | Be::NOTIFY ) #endif - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/TriVariable.cpp b/trinity/TriVariable.cpp index 8d4130ad7..4db1c2902 100644 --- a/trinity/TriVariable.cpp +++ b/trinity/TriVariable.cpp @@ -30,8 +30,7 @@ bool TriVariable::CopyToResourceSet( { switch( m_type ) { - case TRIVARIABLE_TEXTURE_RES: - { + case TRIVARIABLE_TEXTURE_RES: { auto colorSpace = ( flags & RESOURCE_FLAG_SRGB ) != 0 ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR; Tr2TextureAL* tex = nullptr; if( m_texture ) @@ -47,8 +46,7 @@ bool TriVariable::CopyToResourceSet( return resourceDesc.SetSrv( stage, registerIndex, Tr2TextureAL(), colorSpace ); } } - case TRIVARIABLE_GPUBUFFER: - { + case TRIVARIABLE_GPUBUFFER: { Tr2BufferAL* buffer = nullptr; if( m_gpuBuffer ) { @@ -75,8 +73,7 @@ bool TriVariable::ApplyUav( { switch( m_type ) { - case TRIVARIABLE_TEXTURE_RES: - { + case TRIVARIABLE_TEXTURE_RES: { Tr2TextureAL* tex = nullptr; if( m_texture ) { @@ -92,8 +89,7 @@ bool TriVariable::ApplyUav( } break; } - case TRIVARIABLE_GPUBUFFER: - { + case TRIVARIABLE_GPUBUFFER: { Tr2BufferAL* buffer = nullptr; if( m_gpuBuffer ) { @@ -115,10 +111,10 @@ bool TriVariable::ApplyUav( return resourceDesc.SetUav( stage, registerIndex, Tr2BufferAL() ); } -void TriVariable::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, - size_t size, - Tr2RenderContext &renderContext ) const +void TriVariable::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, + unsigned char* destHandle, + size_t size, + Tr2RenderContext& renderContext ) const { switch( m_type ) { @@ -128,21 +124,19 @@ void TriVariable::CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, case TRIVARIABLE_GPUBUFFER: // Do Nothing break; - case TRIVARIABLE_FLOAT4X4: - { - size_t ts = GetTypeSize(); - // column_major for shaders, pay attention to size of registers - TriMatrixTranspose( - reinterpret_cast( destHandle ), - reinterpret_cast( m_value ), - (unsigned int)(size < ts ? size : ts) ); - break; - } - default: - { - size_t ts = GetTypeSize(); - memcpy( destHandle, m_value, size < ts ? size : ts ); - } + case TRIVARIABLE_FLOAT4X4: { + size_t ts = GetTypeSize(); + // column_major for shaders, pay attention to size of registers + TriMatrixTranspose( + reinterpret_cast( destHandle ), + reinterpret_cast( m_value ), + (unsigned int)( size < ts ? size : ts ) ); + break; + } + default: { + size_t ts = GetTypeSize(); + memcpy( destHandle, m_value, size < ts ? size : ts ); + } } } @@ -154,7 +148,7 @@ void TriVariable::Invalidate() void TriVariable::Clear() { - m_texture = nullptr; + m_texture = nullptr; m_gpuBuffer = nullptr; memset( m_value, 0, GetTypeSize() ); diff --git a/trinity/TriVariable.h b/trinity/TriVariable.h index 9154bb9cb..aa15f9852 100644 --- a/trinity/TriVariable.h +++ b/trinity/TriVariable.h @@ -13,16 +13,16 @@ enum TriVariableContentType { TRIVARIABLE_INVALID, TRIVARIABLE_UNKNOWN_FLOAT, - TRIVARIABLE_TEXTURE_RES, - TRIVARIABLE_INT, + TRIVARIABLE_TEXTURE_RES, + TRIVARIABLE_INT, TRIVARIABLE_FLOAT, TRIVARIABLE_FLOAT2, - TRIVARIABLE_FLOAT3, - TRIVARIABLE_FLOAT4, - TRIVARIABLE_FLOAT4X4, - TRIVARIABLE_COLOR, - TRIVARIABLE_GPUBUFFER, - TRIVARIABLE_COUNT, + TRIVARIABLE_FLOAT3, + TRIVARIABLE_FLOAT4, + TRIVARIABLE_FLOAT4X4, + TRIVARIABLE_COLOR, + TRIVARIABLE_GPUBUFFER, + TRIVARIABLE_COUNT, }; inline TriVariableContentType GetVariableType( const ITr2TextureProvider* const ) @@ -42,12 +42,12 @@ inline TriVariableContentType GetVariableType( const int& ) inline TriVariableContentType GetVariableType( const float& ) { - return TRIVARIABLE_FLOAT; + return TRIVARIABLE_FLOAT; } inline TriVariableContentType GetVariableType( const Matrix& ) { - return TRIVARIABLE_FLOAT4X4; + return TRIVARIABLE_FLOAT4X4; } inline TriVariableContentType GetVariableType( const Vector2& ) @@ -57,104 +57,106 @@ inline TriVariableContentType GetVariableType( const Vector2& ) inline TriVariableContentType GetVariableType( const Vector3& ) { - return TRIVARIABLE_FLOAT3; + return TRIVARIABLE_FLOAT3; } inline TriVariableContentType GetVariableType( const Vector4& ) { - return TRIVARIABLE_FLOAT4; + return TRIVARIABLE_FLOAT4; } inline TriVariableContentType GetVariableType( const Color& ) { - return TRIVARIABLE_COLOR; + return TRIVARIABLE_COLOR; } -BLUE_CLASS( TriVariable ) : public ITr2EffectValue +BLUE_CLASS( TriVariable ) : + public ITr2EffectValue { public: // This class is not actually exposed EXPOSE_TO_BLUE(); static const char* GetTypeName( TriVariableContentType t ) - { - static const char* typeNames[TRIVARIABLE_COUNT] = - { + { + static const char* typeNames[TRIVARIABLE_COUNT] = { "INVALID TYPE!", // A float variable type of some sort. May be converted into any known float type "TRIVARIABLE_UNKNOWN_FLOAT", - "TRIVARIABLE_TEXTURE_RES", + "TRIVARIABLE_TEXTURE_RES", "TRIVARIABLE_INT", - "TRIVARIABLE_FLOAT", + "TRIVARIABLE_FLOAT", "TRIVARIABLE_FLOAT2", - "TRIVARIABLE_FLOAT3", - "TRIVARIABLE_FLOAT4", - "TRIVARIABLE_FLOAT4X4", - "TRIVARIABLE_COLOR", - "TRIVARIABLE_GPUBUFFER" - }; - - return typeNames[t]; - } + "TRIVARIABLE_FLOAT3", + "TRIVARIABLE_FLOAT4", + "TRIVARIABLE_FLOAT4X4", + "TRIVARIABLE_COLOR", + "TRIVARIABLE_GPUBUFFER" + }; + + return typeNames[t]; + } static size_t GetTypeSize( TriVariableContentType t ) { - static size_t typeSizes[TRIVARIABLE_COUNT] = - { - sizeof(float)*16, // INVALID may be converted to another type, must register as largest type - sizeof(float)*16, // UNKNOWN_FLOAT may be converted to another type, must register as largest type - sizeof(ITr2TextureProvider*), - sizeof(int), - sizeof(float), - sizeof(float)*2, - sizeof(float)*3, - sizeof(float)*4, - sizeof(float)*16, - sizeof(Color), - sizeof(ITr2GpuBuffer*), - }; - + static size_t typeSizes[TRIVARIABLE_COUNT] = { + sizeof( float ) * 16, // INVALID may be converted to another type, must register as largest type + sizeof( float ) * 16, // UNKNOWN_FLOAT may be converted to another type, must register as largest type + sizeof( ITr2TextureProvider* ), + sizeof( int ), + sizeof( float ), + sizeof( float ) * 2, + sizeof( float ) * 3, + sizeof( float ) * 4, + sizeof( float ) * 16, + sizeof( Color ), + sizeof( ITr2GpuBuffer* ), + }; + return typeSizes[t]; } - const std::string& GetName() const { return m_name; } + const std::string& GetName() const + { + return m_name; + } private: - template - void GetValue_( T& value ) const + template + void GetValue_( T & value ) const { CCP_ASSERT( m_type == GetVariableType( value ) ); value = *(T*)m_value; } - void GetValueTextureRes( ITr2TextureProvider*& value ) const + void GetValueTextureRes( ITr2TextureProvider * &value ) const { CCP_ASSERT( m_type == GetVariableType( value ) ); value = m_texture; } - void GetValueGpuBuffer( ITr2GpuBuffer*& value ) const + void GetValueGpuBuffer( ITr2GpuBuffer * &value ) const { CCP_ASSERT( m_type == GetVariableType( value ) ); value = m_gpuBuffer; } - template + template void SetValue_( const T& value ) { CCP_ASSERT( m_type == GetVariableType( value ) ); - *(T*)m_value = value; + *(T*)m_value = value; } - // Storing a texture res pointer - void SetValueTextureRes( ITr2TextureProvider*& value ) + // Storing a texture res pointer + void SetValueTextureRes( ITr2TextureProvider * &value ) { CCP_ASSERT( m_type == GetVariableType( value ) ); m_texture = value; m_type = TRIVARIABLE_TEXTURE_RES; } - void SetValueGpuBuffer( ITr2GpuBuffer*& value ) + void SetValueGpuBuffer( ITr2GpuBuffer * &value ) { CCP_ASSERT( m_type == GetVariableType( value ) ); m_gpuBuffer = value; @@ -163,8 +165,8 @@ BLUE_CLASS( TriVariable ) : public ITr2EffectValue // Variables contain their payload starting at 'value'[0]. No size is // stored since 'type' is enough. - TriVariableContentType m_type; - std::string m_name; + TriVariableContentType m_type; + std::string m_name; ITr2TextureProviderPtr m_texture; ITr2GpuBufferPtr m_gpuBuffer; @@ -174,10 +176,10 @@ BLUE_CLASS( TriVariable ) : public ITr2EffectValue uint8_t m_value[sizeof( Matrix )]; protected: - // We intentionally disallow construction - only Tr2VariableStore can + // We intentionally disallow construction - only Tr2VariableStore can // create instances! - TriVariable() - :m_type( TRIVARIABLE_INVALID ) + TriVariable() : + m_type( TRIVARIABLE_INVALID ) { m_value[0] = 0; } @@ -198,15 +200,42 @@ BLUE_CLASS( TriVariable ) : public ITr2EffectValue return GetTypeSize( m_type ); } - void GetValue( float& value ) const { GetValue_( value ); } - void GetValue( int& value ) const { GetValue_( value ); } - void GetValue( Vector2& value ) const { GetValue_( value ); } - void GetValue( Vector3& value ) const { GetValue_( value ); } - void GetValue( Vector4& value ) const { GetValue_( value ); } - void GetValue( Color& value ) const { GetValue_( value ); } - void GetValue( Matrix& value ) const { GetValue_( value ); } - void GetValue( ITr2TextureProvider*& value ) const { GetValueTextureRes( value ); } - void GetValue( ITr2GpuBuffer*& value ) const { GetValueGpuBuffer( value ); } + void GetValue( float& value ) const + { + GetValue_( value ); + } + void GetValue( int& value ) const + { + GetValue_( value ); + } + void GetValue( Vector2 & value ) const + { + GetValue_( value ); + } + void GetValue( Vector3 & value ) const + { + GetValue_( value ); + } + void GetValue( Vector4 & value ) const + { + GetValue_( value ); + } + void GetValue( Color & value ) const + { + GetValue_( value ); + } + void GetValue( Matrix & value ) const + { + GetValue_( value ); + } + void GetValue( ITr2TextureProvider * &value ) const + { + GetValueTextureRes( value ); + } + void GetValue( ITr2GpuBuffer * &value ) const + { + GetValueGpuBuffer( value ); + } ///////////////////////////////////////////// // ITr2EffectValue methods @@ -217,31 +246,58 @@ BLUE_CLASS( TriVariable ) : public ITr2EffectValue } virtual bool CopyToResourceSet( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, ResourceFlags flags ) const; virtual bool ApplyUav( - Tr2ResourceSetDescriptionAL& resourceDesc, + Tr2ResourceSetDescriptionAL & resourceDesc, Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ) const; - virtual void CopyValueToEffect( + virtual void CopyValueToEffect( Tr2RenderContextEnum::ShaderType inputType, - unsigned char* destHandle, + unsigned char* destHandle, size_t size, - Tr2RenderContext &renderContext ) const; + Tr2RenderContext& renderContext ) const; // ///////////////////////////////////////////// - void SetValue( float value ) { SetValue_( value ); } - void SetValue( int value ) { SetValue_( value ); } - void SetValue( const Vector2& value ) { SetValue_( value ); } - void SetValue( const Vector3& value ) { SetValue_( value ); } - void SetValue( const Vector4& value ) { SetValue_( value ); } - void SetValue( const Color& value ) { SetValue_( value ); } - void SetValue( const Matrix& value ) { SetValue_( value ); } - void SetValue( ITr2TextureProvider* value ) { SetValueTextureRes( value ); } - void SetValue( ITr2GpuBuffer* value ) { SetValueGpuBuffer( value ); } + void SetValue( float value ) + { + SetValue_( value ); + } + void SetValue( int value ) + { + SetValue_( value ); + } + void SetValue( const Vector2& value ) + { + SetValue_( value ); + } + void SetValue( const Vector3& value ) + { + SetValue_( value ); + } + void SetValue( const Vector4& value ) + { + SetValue_( value ); + } + void SetValue( const Color& value ) + { + SetValue_( value ); + } + void SetValue( const Matrix& value ) + { + SetValue_( value ); + } + void SetValue( ITr2TextureProvider * value ) + { + SetValueTextureRes( value ); + } + void SetValue( ITr2GpuBuffer * value ) + { + SetValueGpuBuffer( value ); + } // Invalidate the variable void Invalidate(); diff --git a/trinity/TriVector.cpp b/trinity/TriVector.cpp index c7a544b5d..f85f8ebda 100644 --- a/trinity/TriVector.cpp +++ b/trinity/TriVector.cpp @@ -7,46 +7,46 @@ #include "Include/TriMath.h" #include "TriViewport.h" -void GetNearestPointOnAABB(Vector3 &out, const Vector3 &p, const Vector3 &min, const Vector3 &max) -{ - if(p.x < min.x) - { - out.x = min.x; - } - else if(p.x > max.x) - { - out.x = max.x; - } - else - { - out.x = p.x; - } - - if(p.y < min.y) - { - out.y = min.y; - } - else if(p.y > max.y) - { - out.y = max.y; - } - else - { - out.y = p.y; - } - - if(p.z < min.z) - { - out.z = min.z; - } - else if(p.z > max.z) - { - out.z = max.z; - } - else - { - out.z = p.z; - } +void GetNearestPointOnAABB( Vector3& out, const Vector3& p, const Vector3& min, const Vector3& max ) +{ + if( p.x < min.x ) + { + out.x = min.x; + } + else if( p.x > max.x ) + { + out.x = max.x; + } + else + { + out.x = p.x; + } + + if( p.y < min.y ) + { + out.y = min.y; + } + else if( p.y > max.y ) + { + out.y = max.y; + } + else + { + out.y = p.y; + } + + if( p.z < min.z ) + { + out.z = min.z; + } + else if( p.z > max.z ) + { + out.z = max.z; + } + else + { + out.z = p.z; + } } ///////////////////////////////////////////////////////////////////////////////////////// @@ -60,33 +60,30 @@ void TriVector::Destroy() } -PyObject* TriVector::GetAttr( - const char* name, - bool* handled - ) +PyObject* TriVector::GetAttr( + const char* name, + bool* handled ) { return 0; } bool TriVector::SetAttr( - const char* name, - PyObject* v, - bool* handled - ) + const char* name, + PyObject* v, + bool* handled ) { return true; } PyObject* TriVector::Repr( - bool* handled - ) + bool* handled ) { *handled = true; char buf[120]; - sprintf_s(buf, "(%.3f, %.3f, %.3f)", x, y, z); - return ToPython(buf); + sprintf_s( buf, "(%.3f, %.3f, %.3f)", x, y, z ); + return ToPython( buf ); } @@ -97,8 +94,7 @@ PyObject* TriVector::Repr( bool TriVector::BinaryOp( PYNUMERIC_OPS op, IRoot* other, - PyObject** retval - ) + PyObject** retval ) { // The return value TriVectorPtr retvec; @@ -114,7 +110,7 @@ bool TriVector::BinaryOp( // is converted to TriVector, vec2 from 'other' can be // an instance from such conversion. - switch(op) + switch( op ) { case PYOP_ADD: *retvec += *vec2; @@ -136,49 +132,45 @@ bool TriVector::BinaryOp( return false; } - *retval = PyOS->WrapBlueObject(retvec->GetRawRoot()); + *retval = PyOS->WrapBlueObject( retvec->GetRawRoot() ); return true; } bool TriVector::UnaryOp( PYNUMERIC_OPS op, - PyObject** retval - ) + PyObject** retval ) { // The return value ITriVectorPtr retvec; - retvec.Attach(new OTriVector); + retvec.Attach( new OTriVector ); - switch (op) + switch( op ) { - case PYOP_NEG: - { - Vector3 tmp = -(*this); - retvec->SetVector( &tmp ); - } - break; + case PYOP_NEG: { + Vector3 tmp = -( *this ); + retvec->SetVector( &tmp ); + } + break; - case PYOP_POS: - { - Vector3 tmp = +(*this); - retvec->SetVector( &tmp ); - } - break; + case PYOP_POS: { + Vector3 tmp = +( *this ); + retvec->SetVector( &tmp ); + } + break; default: // free the 'retvec' return false; } - *retval = PyOS->WrapBlueObject(retvec); + *retval = PyOS->WrapBlueObject( retvec ); return true; } void TriVector::Coercion( PyObject* from, - PyObject** to - ) + PyObject** to ) { // check for None first - never coerce this type! if( from == Py_None ) @@ -187,19 +179,19 @@ void TriVector::Coercion( } // convert from any standard numeric value - PyObject* pyfloat = PyNumber_Float(from); + PyObject* pyfloat = PyNumber_Float( from ); - if (!pyfloat) + if( !pyfloat ) return; - float f = (float)PyFloat_AS_DOUBLE(pyfloat); - Py_DECREF(pyfloat); + float f = (float)PyFloat_AS_DOUBLE( pyfloat ); + Py_DECREF( pyfloat ); // the return value ITriVectorPtr vec; - vec.Attach(new OTriVector); - vec->SetXYZ(f, f, f); - *to = PyOS->WrapBlueObject(vec); + vec.Attach( new OTriVector ); + vec->SetXYZ( f, f, f ); + *to = PyOS->WrapBlueObject( vec ); } #endif @@ -208,8 +200,8 @@ void TriVector::Coercion( // TriVector ///////////////////////////////////////////////////////////////////////////////////////// -TriVector::TriVector(IRoot* lockobj) : - Vector3(0.0f, 0.0f,0.0f) +TriVector::TriVector( IRoot* lockobj ) : + Vector3( 0.0f, 0.0f, 0.0f ) { } @@ -224,10 +216,9 @@ TriVector::~TriVector() ///////////////////////////////////////////////////////////////////////////////////////// void TriVector::SetXYZ( - float _x, - float _y, - float _z - ) + float _x, + float _y, + float _z ) { x = _x; y = _y; @@ -236,8 +227,7 @@ void TriVector::SetXYZ( void TriVector::SetVector( - const Vector3* ar - ) + const Vector3* ar ) { x = ar->x; y = ar->y; @@ -245,80 +235,70 @@ void TriVector::SetVector( } -const Vector3* TriVector::GetVector( - ) const +const Vector3* TriVector::GetVector() const { - return this; + return this; } Vector3* TriVector::CopyVector( - Vector3* in - ) const + Vector3* in ) const { // would this work? //return &(*in = *this); - + *in = *this; return in; } -Vector3* TriVector::Vector( - ) +Vector3* TriVector::Vector() { return this; } void TriVector::SetCrossProduct( - const Vector3* v1, - const Vector3* v2 - ) + const Vector3* v1, + const Vector3* v2 ) { *static_cast( this ) = Cross( *v1, *v2 ); } -float TriVector::Length( - ) const +float TriVector::Length() const { return ::Length( *this ); } -float TriVector::LengthSq( - ) const +float TriVector::LengthSq() const { return ::LengthSq( *this ); } void TriVector::Scale( - float s - ) + float s ) { *static_cast( this ) *= s; } -void TriVector::Normalize( - ) +void TriVector::Normalize() { *static_cast( this ) = ::Normalize( *this ); } void TriVector::TransformQuaternion( - const Quaternion* in - ) + const Quaternion* in ) { - TriVectorRotateQuaternion(this, this, in); + TriVectorRotateQuaternion( this, this, in ); } float TriVector::DotProduct( - const Vector3* v2 - ) + const Vector3* v2 ) { return Dot( *this, *v2 ); } @@ -372,12 +352,12 @@ void TriVector::PySubtract( ITriVector* other ) void TriVector::PyTransformCoord( ITriMatrix* transform ) { - *static_cast( this ) = TransformCoord( *this, *transform->GetMatrix() ); + *static_cast( this ) = TransformCoord( *this, *transform->GetMatrix() ); } void TriVector::PyTransformNormal( ITriMatrix* transform ) { - *static_cast( this ) = TransformNormal( *this, *transform->GetMatrix() ); + *static_cast( this ) = TransformNormal( *this, *transform->GetMatrix() ); } void TriVector::PyUnproject( @@ -386,14 +366,14 @@ void TriVector::PyUnproject( ITriMatrix* view, ITriMatrix* world ) { - Vector3 preViewport; - x = 2.0f * ( x - vp->x ) / vp->width - 1.0f; - y = 1.0f - 2.0f * ( y - vp->y ) / vp->height; - z = ( z - vp->minZ ) / ( vp->maxZ - vp->minZ ); - - Matrix worldViewProjInv = Inverse( *world->GetMatrix() * *view->GetMatrix() * *project->GetMatrix() ); - - *static_cast( this ) = TransformCoord( *this, worldViewProjInv ); + Vector3 preViewport; + x = 2.0f * ( x - vp->x ) / vp->width - 1.0f; + y = 1.0f - 2.0f * ( y - vp->y ) / vp->height; + z = ( z - vp->minZ ) / ( vp->maxZ - vp->minZ ); + + Matrix worldViewProjInv = Inverse( *world->GetMatrix() * *view->GetMatrix() * *project->GetMatrix() ); + + *static_cast( this ) = TransformCoord( *this, worldViewProjInv ); } void TriVector::PyTransformQuaternion( ITriQuaternion* rotation ) diff --git a/trinity/TriVector_Blue.cpp b/trinity/TriVector_Blue.cpp index 6162fb501..80b8d3515 100644 --- a/trinity/TriVector_Blue.cpp +++ b/trinity/TriVector_Blue.cpp @@ -10,204 +10,180 @@ BLUE_DEFINE( TriVector ); const Be::ClassInfo* TriVector::ExposeToBlue() { - EXPOSURE_BEGIN(TriVector, "A 3-float vector.") - MAP_INTERFACE(ITriVector) + EXPOSURE_BEGIN( TriVector, "A 3-float vector." ) + MAP_INTERFACE( ITriVector ) #if BLUE_WITH_PYTHON - MAP_INTERFACE(IPythonMethods) - MAP_INTERFACE(IPythonNumeric) + MAP_INTERFACE( IPythonMethods ) + MAP_INTERFACE( IPythonNumeric ) #endif //////////////////////////////////////////////////////////////////////////// // x - MAP_ATTRIBUTE - ( - "x", - x, - "", - Be::READWRITE | Be::PERSIST - ) - + MAP_ATTRIBUTE( + "x", + x, + "", + Be::READWRITE | Be::PERSIST ) + //////////////////////////////////////////////////////////////////////////// // y - MAP_ATTRIBUTE - ( - "y", - y, - "", - Be::READWRITE | Be::PERSIST - ) - + MAP_ATTRIBUTE( + "y", + y, + "", + Be::READWRITE | Be::PERSIST ) + //////////////////////////////////////////////////////////////////////////// // z - MAP_ATTRIBUTE - ( - "z", - z, - "", - Be::READWRITE | Be::PERSIST - ) - - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + MAP_ATTRIBUTE( + "z", + z, + "", + Be::READWRITE | Be::PERSIST ) + + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( "__init__", - SetXYZ, + SetXYZ, 3, "Constructor arguments\n" ":param x: \n" ":param y: \n" - ":param z: \n" - ) + ":param z: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "SetXYZ", - SetXYZ, - "sets the vector\n" + SetXYZ, + "sets the vector\n" ":param x: \n" ":param y: \n" - ":param z: \n" - ) - - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + ":param z: \n" ) + + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Add", PyAdd, "Accepts one argument, a vector, which is added to this vector\n" - ":param other: \n" - ) + ":param other: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Cross", - PyCross, + PyCross, "Accepts one argument, a vector. The result is a Cross product of this vector" - "and argument 1\n" - ":param other: \n" - ) + "and argument 1\n" + ":param other: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Dot", - PyDot, + PyDot, "Accepts one argument, a vector. The result is a Dot product of this vector" - "and argument 1\n" - ":param other: \n" - ) + "and argument 1\n" + ":param other: \n" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "Length", - Length, + Length, "Returns the length on the vector" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "LengthSq", - LengthSq, + LengthSq, "Returns the square of the length of a 3-D vector." ) - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Lerp", - PyLerp, + PyLerp, ":param other: \n" - ":param t: \n" - ) + ":param t: \n" ) - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Maximize", - PyMaximize, - ":param other: \n" - ) + PyMaximize, + ":param other: \n" ) - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Minimize", - PyMinimize, - ":param other: \n" - ) + PyMinimize, + ":param other: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Normalize", - Normalize, + Normalize, "Normalizes the vector" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "Project", - PyProject, + PyProject, ":param viewport: \n" ":param projection: \n" ":param view: \n" - ":param world: \n" - ) + ":param world: \n" ) - //////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Scale", - Scale, + Scale, "Scales the vector by a factor\n" - ":param scale: \n" - ) + ":param scale: \n" ) //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Subtract", - PySubtract, - ":param other: \n" - ) + PySubtract, + ":param other: \n" ) //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "TransformCoord", - PyTransformCoord, - ":param matrix: \n" - ) + PyTransformCoord, + ":param matrix: \n" ) - //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + //////////////////////////////////////////////////////////////////////////// + MAP_METHOD_AND_WRAP( "TransformNormal", - PyTransformNormal, - ":param matrix: \n" - ) + PyTransformNormal, + ":param matrix: \n" ) //////////////////////////////////////////////////////////////////////////// MAP_METHOD_AND_WRAP( "Unproject", - PyUnproject, + PyUnproject, ":param viewport: \n" ":param projection: \n" ":param view: \n" - ":param world: \n" - ) + ":param world: \n" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "SetCrossProduct", - PySetCrossProduct, + PySetCrossProduct, "Sets this vector to a crossproduct of two vectors\n" ":param v1: \n" - ":param v2: \n" - ) + ":param v2: \n" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "DotProduct", - PyDotProduct, - "Get the dotproduct of two vectors\n" - ":param other: \n" - ) + PyDotProduct, + "Get the dotproduct of two vectors\n" + ":param other: \n" ) //////////////////////////////////////////////////////////////////////////// - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "TransformQuaternion", - PyTransformQuaternion, - "Transforms this vector by the quaternion\n" - ":param rotation: \n" - ) + PyTransformQuaternion, + "Transforms this vector by the quaternion\n" + ":param rotation: \n" ) EXPOSURE_END() - } diff --git a/trinity/TriView.cpp b/trinity/TriView.cpp index 1dded516f..a763e7f7d 100644 --- a/trinity/TriView.cpp +++ b/trinity/TriView.cpp @@ -8,7 +8,7 @@ // Description: // Constructor. Initializes the view matrix to the identity. // -------------------------------------------------------------------------------------- -TriView::TriView(void) : +TriView::TriView( void ) : m_transform( XMMatrixIdentity() ) { } diff --git a/trinity/TriView.h b/trinity/TriView.h index 3f6f664f4..0d167c289 100644 --- a/trinity/TriView.h +++ b/trinity/TriView.h @@ -11,11 +11,12 @@ // See Also: // TriProjection // -------------------------------------------------------------------------------------- -BLUE_CLASS( TriView ) : public IRoot +BLUE_CLASS( TriView ) : + public IRoot { public: // Constructor - TriView(void); + TriView( void ); EXPOSE_TO_BLUE(); diff --git a/trinity/TriView_Blue.cpp b/trinity/TriView_Blue.cpp index 0144806b8..6a6a6d33e 100644 --- a/trinity/TriView_Blue.cpp +++ b/trinity/TriView_Blue.cpp @@ -7,20 +7,19 @@ BLUE_DEFINE( TriView ); const Be::ClassInfo* TriView::ExposeToBlue() { - EXPOSURE_BEGIN(TriView, "" ) + EXPOSURE_BEGIN( TriView, "" ) MAP_INTERFACE( TriView ) - MAP_ATTRIBUTE("transform", m_transform, "Transformation matrix", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "transform", m_transform, "Transformation matrix", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( - "SetLookAtPosition", - SetLookAtPosition, + MAP_METHOD_AND_WRAP( + "SetLookAtPosition", + SetLookAtPosition, "Builds a view transform. Takes (eyePosition, atPosition, upDirection) vectors as parameters.\n" ":param eye: camera position\n" ":param at: camera focus position\n" - ":param up: camera up direction\n" - ) + ":param up: camera up direction\n" ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/TriViewport.h b/trinity/TriViewport.h index e8bb74e31..55aca4efa 100644 --- a/trinity/TriViewport.h +++ b/trinity/TriViewport.h @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. -// This is the refactored TriViewport class - it does not expose any D3D internals and has -// been changed so that +// This is the refactored TriViewport class - it does not expose any D3D internals and has +// been changed so that // // 1. it is compatible with D3D10 and OpenGL // 2. it uses Blue 2.0 exposure @@ -27,11 +27,15 @@ class TriViewport : public IRoot float minZ; float maxZ; - TriViewport(IRoot* lockobj = NULL) : x(0),y(0),width(1),height(1),minZ(0.0f),maxZ(1.0f) - {} - virtual ~TriViewport(){} + TriViewport( IRoot* lockobj = NULL ) : + x( 0 ), y( 0 ), width( 1 ), height( 1 ), minZ( 0.0f ), maxZ( 1.0f ) + { + } + virtual ~TriViewport() + { + } - void py__init__( + void py__init__( int32_t _x, int32_t _y, Be::OptionalWithDefaultValue _width, @@ -53,8 +57,11 @@ class TriViewport : public IRoot maxZ = 1.0f; } } - - float GetAspectRatio() { return float(width)/height; } + + float GetAspectRatio() + { + return float( width ) / height; + } void ConvertToTr2Viewport( Tr2Viewport& viewport ) const { @@ -69,7 +76,7 @@ class TriViewport : public IRoot EXPOSE_TO_BLUE(); }; -TYPEDEF_BLUECLASS(TriViewport); +TYPEDEF_BLUECLASS( TriViewport ); inline void Vec3TransformByViewport( Vector3& vec, const TriViewport& viewport ) { @@ -79,4 +86,3 @@ inline void Vec3TransformByViewport( Vector3& vec, const TriViewport& viewport ) } #endif - diff --git a/trinity/TriViewport_Blue.cpp b/trinity/TriViewport_Blue.cpp index 12877ab67..2f4657909 100644 --- a/trinity/TriViewport_Blue.cpp +++ b/trinity/TriViewport_Blue.cpp @@ -8,56 +8,44 @@ BLUE_DEFINE( TriViewport ); const Be::ClassInfo* TriViewport::ExposeToBlue() { EXPOSURE_BEGIN( TriViewport, "Encapsulates the concept of a rendering viewport" ) - MAP_INTERFACE(TriViewport) + MAP_INTERFACE( TriViewport ) - MAP_ATTRIBUTE - ( - "x", - x, + MAP_ATTRIBUTE( + "x", + x, "Left horizontal starting location for rasterization, " - "measured in pixels from left edge of render target.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "y", - y, + "measured in pixels from left edge of render target.", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "y", + y, "Top vertical starting location for rasterization, " - "meastured in pixels from top edge of render target.", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "width", - width, - "Number of pixels horizontally rasterized by the viewport", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "height", - height, - "Number of pixels vertically rasterized by the viewport", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "minZ", - minZ, - "Minimum depth of the viewport, must be between 0 and 1", - Be::READWRITE | Be::PERSIST - ) - MAP_ATTRIBUTE - ( - "maxZ", - maxZ, - "Maximum depth of the viewport, must be between 0 and 1", - Be::READWRITE | Be::PERSIST - ) + "meastured in pixels from top edge of render target.", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "width", + width, + "Number of pixels horizontally rasterized by the viewport", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "height", + height, + "Number of pixels vertically rasterized by the viewport", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "minZ", + minZ, + "Minimum depth of the viewport, must be between 0 and 1", + Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( + "maxZ", + maxZ, + "Maximum depth of the viewport, must be between 0 and 1", + Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", - py__init__, + MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( + "__init__", + py__init__, 6, "Optional arguments are (int,int,int,int,float,float)\n" ":param x: \n" @@ -65,14 +53,12 @@ const Be::ClassInfo* TriViewport::ExposeToBlue() ":param width: \n" ":param height: \n" ":param zn: \n" - ":param zf: \n" - ) + ":param zf: \n" ) - MAP_METHOD_AND_WRAP( - "GetAspectRatio", - GetAspectRatio, - "Returns the aspect ratio for this viewport" - ) + MAP_METHOD_AND_WRAP( + "GetAspectRatio", + GetAspectRatio, + "Returns the aspect ratio for this viewport" ) EXPOSURE_END() } diff --git a/trinity/UI/IUILib.h b/trinity/UI/IUILib.h index a8244412a..ab12ec325 100644 --- a/trinity/UI/IUILib.h +++ b/trinity/UI/IUILib.h @@ -9,7 +9,7 @@ ////////////////////////////////////////////////////////////////////// // // The numerous enums -// +// ////////////////////////////////////////////////////////////////////// @@ -18,14 +18,14 @@ //-------------------------------------------------------------------- enum UIALIGN { - UI_ALNONE = 0, - UI_ALLEFT = 1, - UI_ALRIGHT = 2, - UI_ALTOP = 3, - UI_ALBOTTOM = 4, - UI_ALCLIENT = 5, - UI_ALABSOLUTE = 6, - _UI_ALLAST = 7, + UI_ALNONE = 0, + UI_ALLEFT = 1, + UI_ALRIGHT = 2, + UI_ALTOP = 3, + UI_ALBOTTOM = 4, + UI_ALCLIENT = 5, + UI_ALABSOLUTE = 6, + _UI_ALLAST = 7, }; @@ -36,11 +36,11 @@ enum UIANCHOR { // When anchored the control's position is fixed with respect to the // anchored edge of it's parent. - - UI_ANCHTOP = 0x1, - UI_ANCHLEFT = 0x2, - UI_ANCHRIGHT = 0x4, - UI_ANCHBOTTOM = 0x8, + + UI_ANCHTOP = 0x1, + UI_ANCHLEFT = 0x2, + UI_ANCHRIGHT = 0x4, + UI_ANCHBOTTOM = 0x8, }; @@ -48,14 +48,14 @@ enum UIANCHOR // UID - Those are the same values as Win32 dialog box command id's. //-------------------------------------------------------------------- enum UID -{ - ID_NONE = 0, - ID_OK = 1, - ID_CANCEL = 2, - ID_YES = 6, - ID_NO = 7, - ID_CLOSE = 8, - ID_HELP = 9, +{ + ID_NONE = 0, + ID_OK = 1, + ID_CANCEL = 2, + ID_YES = 6, + ID_NO = 7, + ID_CLOSE = 8, + ID_HELP = 9, }; @@ -68,26 +68,26 @@ enum UID enum UIBOX { - OK = 0, - OKCANCEL = 1, - YESNOCANCEL = 2, - YESNO = 3, - - INFO = 0, - WARNING = 1, - QUESTION = 2, - ERROR = 3, - FATAL = 4, + OK = 0, + OKCANCEL = 1, + YESNOCANCEL = 2, + YESNO = 3, + + INFO = 0, + WARNING = 1, + QUESTION = 2, + ERROR = 3, + FATAL = 4, }; // UISTATE //-------------------------------------------------------------------- enum UISTATE { - UI_NORMAL = 0x00, - UI_DISABLED = 0x01, //not pickable - UI_HIDDEN = 0x02, //not visible. ignored completely - UI_PICKCHILDREN = 0x03, //not pickable, but children are. + UI_NORMAL = 0x00, + UI_DISABLED = 0x01, //not pickable + UI_HIDDEN = 0x02, //not visible. ignored completely + UI_PICKCHILDREN = 0x03, //not pickable, but children are. }; @@ -96,24 +96,24 @@ enum UISTATE //-------------------------------------------------------------------- enum UIINITPOS { - // The form appears positioned on the screen and with the same + // The form appears positioned on the screen and with the same // height and width as it had at design time. - UI_POSDESIGNED = 0, + UI_POSDESIGNED = 0, - // The form appears in a position on the screen and with a height - // and width determined by UILib. Each time you create the window, - // the form moves slightly down and to the right. The right side - // of the form is always near the far right side of the screen, and - // the bottom of the form is always near the bottom of the screen, + // The form appears in a position on the screen and with a height + // and width determined by UILib. Each time you create the window, + // the form moves slightly down and to the right. The right side + // of the form is always near the far right side of the screen, and + // the bottom of the form is always near the bottom of the screen, // regardless of the screen's resolution. - UI_POSDEFAULT = 1, + UI_POSDEFAULT = 1, - // The form remains the size you left it at design time, but is + // The form remains the size you left it at design time, but is // positioned in the center of the screen. - UI_POSCENTER = 2, + UI_POSCENTER = 2, // Same as above, but moved just a tad upwards (ca. 10%) - UI_POSCENTER2 = 3, + UI_POSCENTER2 = 3, }; @@ -122,8 +122,8 @@ enum UIINITPOS //-------------------------------------------------------------------- enum UIHITAREA { - UIHIT_CLIENT = 1, // In a client area. - UIHIT_CAPTION = 2, // In a title bar. + UIHIT_CLIENT = 1, // In a client area. + UIHIT_CAPTION = 2, // In a title bar. }; @@ -132,11 +132,11 @@ enum UIHITAREA //-------------------------------------------------------------------- enum UICONTROLTYPE { - UI_IMAGE = 0, // No behaviour - act normal - UI_PUSHBTN = 1, // Behave as push button - UI_RADIOBTN = 2, // Behave as radio button - UI_CHECKBTN = 3, // Behave as check box - UI_IMAGEBTN = 4, // Does UV coord. adjustments + UI_IMAGE = 0, // No behaviour - act normal + UI_PUSHBTN = 1, // Behave as push button + UI_RADIOBTN = 2, // Behave as radio button + UI_CHECKBTN = 3, // Behave as check box + UI_IMAGEBTN = 4, // Does UV coord. adjustments // see Button Styles in Win32: // mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2000OCT\1033\winui.chm::/hh/winui/buttons_34c3.htm @@ -148,10 +148,10 @@ enum UICONTROLTYPE //-------------------------------------------------------------------- enum UIMESSAGE { - UI_INVALID = -1, + UI_INVALID = -1, // only 'mEvent' member is valid - UI_RAW = 0, + UI_RAW = 0, ////////////////////////////////////////// @@ -177,17 +177,17 @@ enum UIMESSAGE ////////////////////////////////////////// // mouse events ////////////////////////////////////////// - UI_MOUSE_FIRST = 100, - + UI_MOUSE_FIRST = 100, + // mouse movements UI_MOUSEMOVE, UI_MOUSEWHEEL, - + // mouse button stuff, 'mParam' is valid: // 0=left, 1=right, 2=middle, 3=x button 1, 4=x button 2, ... - UI_MOUSEDOWN, // + UI_MOUSEDOWN, // UI_MOUSEUP, // translated events @@ -207,11 +207,11 @@ enum UIMESSAGE ////////////////////////////////////////// // keyboard events ////////////////////////////////////////// - UI_KDB_FIRST = 200, + UI_KDB_FIRST = 200, - UI_CHAR, // 'mWChar' is valid - UI_KEYDOWN, // 'mEvent' is valid - UI_KEYUP, // 'mEvent' is valid + UI_CHAR, // 'mWChar' is valid + UI_KEYDOWN, // 'mEvent' is valid + UI_KEYUP, // 'mEvent' is valid UI_SETFOCUS, UI_KILLFOCUS, @@ -228,7 +228,7 @@ enum UIMESSAGE UI_OTHER_FIRST = 300, UI_SETTEXT, - + // Target bracket fiff UI_TRACKINGCHANGE, @@ -257,10 +257,10 @@ enum INPUTTYPE //-------------------------------------------------------------------- enum UIFONTSIZE { - UIFONT_6X10 = 0, - UIFONT_9X12 = 1, - UIFONT_9X17 = 2, - _UIFONT_LAST = 3, + UIFONT_6X10 = 0, + UIFONT_9X12 = 1, + UIFONT_9X17 = 2, + _UIFONT_LAST = 3, }; @@ -269,10 +269,10 @@ enum UIFONTSIZE //-------------------------------------------------------------------- enum UIFONTSTYLE { - UIFONT_NORMAL = 0, - UIFONT_DROPSHADOW = 1, - UIFONT_HIGHLIGHTED = 2, - _UIFONTSTYLE_LAST = 3, + UIFONT_NORMAL = 0, + UIFONT_DROPSHADOW = 1, + UIFONT_HIGHLIGHTED = 2, + _UIFONTSTYLE_LAST = 3, }; @@ -281,15 +281,15 @@ enum UIFONTSTYLE //-------------------------------------------------------------------- enum UICURSOR { - UICURSOR_DEFAULT = -1, - UICURSOR_CROSS = 0, - UICURSOR_SELECT = 1, - UICURSOR_SELECTDOWN = 2, - UICURSOR_DRAGGABLE = 3, - UICURSOR_TARGET1 = 4, - UICURSOR_TARGETDOWN = 5, - UICURSOR_TARGET2 = 6, - UICURSOR_IBEAM = 7, + UICURSOR_DEFAULT = -1, + UICURSOR_CROSS = 0, + UICURSOR_SELECT = 1, + UICURSOR_SELECTDOWN = 2, + UICURSOR_DRAGGABLE = 3, + UICURSOR_TARGET1 = 4, + UICURSOR_TARGETDOWN = 5, + UICURSOR_TARGET2 = 6, + UICURSOR_IBEAM = 7, }; //-------------------------------------------------------------------- diff --git a/trinity/UI/Scancodes.cpp b/trinity/UI/Scancodes.cpp index dcc418970..faf10bd48 100644 --- a/trinity/UI/Scancodes.cpp +++ b/trinity/UI/Scancodes.cpp @@ -3,204 +3,203 @@ #include "StdAfx.h" #include "Scancodes.h" -#define CODE(vk, desc) {vk, #vk, desc} - - -const UIScancode SCANCODES[] = -{ - CODE(VK_LBUTTON, "Left mouse button"), - CODE(VK_RBUTTON, "Right mouse button"), - CODE(VK_CANCEL, "Control-break processing"), - CODE(VK_MBUTTON, "Middle mouse button (three-button mouse)"), - CODE(VK_XBUTTON1, "Windows 2000/XP: X1 mouse button"), - CODE(VK_XBUTTON2, "Windows 2000/XP: X2 mouse button"), - CODE(VK_BACK, "BACKSPACE key"), - CODE(VK_TAB, "TAB key"), - CODE(VK_CLEAR, "CLEAR key"), - CODE(VK_RETURN, "ENTER key"), - CODE(VK_SHIFT, "SHIFT key"), - CODE(VK_CONTROL, "CTRL key"), - CODE(VK_MENU, "ALT key"), - CODE(VK_PAUSE, "PAUSE key"), - CODE(VK_CAPITAL, "CAPS LOCK key"), - CODE(VK_KANA, "Input Method Editor (IME) Kana mode"), +#define CODE( vk, desc ) { vk, #vk, desc } + + +const UIScancode SCANCODES[] = { + CODE( VK_LBUTTON, "Left mouse button" ), + CODE( VK_RBUTTON, "Right mouse button" ), + CODE( VK_CANCEL, "Control-break processing" ), + CODE( VK_MBUTTON, "Middle mouse button (three-button mouse)" ), + CODE( VK_XBUTTON1, "Windows 2000/XP: X1 mouse button" ), + CODE( VK_XBUTTON2, "Windows 2000/XP: X2 mouse button" ), + CODE( VK_BACK, "BACKSPACE key" ), + CODE( VK_TAB, "TAB key" ), + CODE( VK_CLEAR, "CLEAR key" ), + CODE( VK_RETURN, "ENTER key" ), + CODE( VK_SHIFT, "SHIFT key" ), + CODE( VK_CONTROL, "CTRL key" ), + CODE( VK_MENU, "ALT key" ), + CODE( VK_PAUSE, "PAUSE key" ), + CODE( VK_CAPITAL, "CAPS LOCK key" ), + CODE( VK_KANA, "Input Method Editor (IME) Kana mode" ), //CODE(VK_HANGUEL, "IME Hanguel mode (maintained for compatibility; use VK_HANGUL)"), - CODE(VK_HANGUL, "IME Hangul mode"), - CODE(VK_JUNJA, "IME Junja mode"), - CODE(VK_FINAL, "IME final mode"), - CODE(VK_HANJA, "IME Hanja mode"), - CODE(VK_KANJI, "IME Kanji mode"), - CODE(VK_ESCAPE, "ESC key"), - CODE(VK_CONVERT, "IME convert"), - CODE(VK_NONCONVERT, "IME nonconvert"), - CODE(VK_ACCEPT, "IME accept"), - CODE(VK_MODECHANGE, "IME mode change request"), - CODE(VK_SPACE, "SPACEBAR"), - CODE(VK_PRIOR, "PAGE UP key"), - CODE(VK_NEXT, "PAGE DOWN key"), - CODE(VK_END, "END key"), - CODE(VK_HOME, "HOME key"), - CODE(VK_LEFT, "LEFT ARROW key"), - CODE(VK_UP, "UP ARROW key"), - CODE(VK_RIGHT, "RIGHT ARROW key"), - CODE(VK_DOWN, "DOWN ARROW key"), - CODE(VK_SELECT, "SELECT key"), - CODE(VK_PRINT, "PRINT key"), - CODE(VK_EXECUTE, "EXECUTE key"), - CODE(VK_SNAPSHOT, "PRINT SCREEN key"), - CODE(VK_INSERT, "INS key"), - CODE(VK_DELETE, "DEL key"), - CODE(VK_HELP, "HELP key"), - CODE(VK_0, "0 key"), - CODE(VK_1, "1 key"), - CODE(VK_2, "2 key"), - CODE(VK_3, "3 key"), - CODE(VK_4, "4 key"), - CODE(VK_5, "5 key"), - CODE(VK_6, "6 key"), - CODE(VK_7, "7 key"), - CODE(VK_8, "8 key"), - CODE(VK_9, "9 key"), - CODE(VK_A, "A key"), - CODE(VK_B, "B key"), - CODE(VK_C, "C key"), - CODE(VK_D, "D key"), - CODE(VK_E, "E key"), - CODE(VK_F, "F key"), - CODE(VK_G, "G key"), - CODE(VK_H, "H key"), - CODE(VK_I, "I key"), - CODE(VK_J, "J key"), - CODE(VK_K, "K key"), - CODE(VK_L, "L key"), - CODE(VK_M, "M key"), - CODE(VK_N, "N key"), - CODE(VK_O, "O key"), - CODE(VK_P, "P key"), - CODE(VK_Q, "Q key"), - CODE(VK_R, "R key"), - CODE(VK_S, "S key"), - CODE(VK_T, "T key"), - CODE(VK_U, "U key"), - CODE(VK_V, "V key"), - CODE(VK_W, "W key"), - CODE(VK_X, "X key"), - CODE(VK_Y, "Y key"), - CODE(VK_Z, "Z key"), - CODE(VK_LWIN, "Left Windows key (Microsoft Natural keyboard) "), - CODE(VK_RWIN, "Right Windows key (Natural keyboard)"), - CODE(VK_APPS, "Applications key (Natural keyboard)"), - CODE(VK_SLEEP, "Computer Sleep key"), - CODE(VK_NUMPAD0, "Numeric keypad 0 key"), - CODE(VK_NUMPAD1, "Numeric keypad 1 key"), - CODE(VK_NUMPAD2, "Numeric keypad 2 key"), - CODE(VK_NUMPAD3, "Numeric keypad 3 key"), - CODE(VK_NUMPAD4, "Numeric keypad 4 key"), - CODE(VK_NUMPAD5, "Numeric keypad 5 key"), - CODE(VK_NUMPAD6, "Numeric keypad 6 key"), - CODE(VK_NUMPAD7, "Numeric keypad 7 key"), - CODE(VK_NUMPAD8, "Numeric keypad 8 key"), - CODE(VK_NUMPAD9, "Numeric keypad 9 key"), - CODE(VK_MULTIPLY, "Multiply key"), - CODE(VK_ADD, "Add key"), - CODE(VK_SEPARATOR, "Separator key"), - CODE(VK_SUBTRACT, "Subtract key"), - CODE(VK_DECIMAL, "Decimal key"), - CODE(VK_DIVIDE, "Divide key"), - CODE(VK_F1, "F1 key"), - CODE(VK_F2, "F2 key"), - CODE(VK_F3, "F3 key"), - CODE(VK_F4, "F4 key"), - CODE(VK_F5, "F5 key"), - CODE(VK_F6, "F6 key"), - CODE(VK_F7, "F7 key"), - CODE(VK_F8, "F8 key"), - CODE(VK_F9, "F9 key"), - CODE(VK_F10, "F10 key"), - CODE(VK_F11, "F11 key"), - CODE(VK_F12, "F12 key"), - CODE(VK_F13, "F13 key"), - CODE(VK_F14, "F14 key"), - CODE(VK_F15, "F15 key"), - CODE(VK_F16, "F16 key"), - CODE(VK_F17, "F17 key"), - CODE(VK_F18, "F18 key"), - CODE(VK_F19, "F19 key"), - CODE(VK_F20, "F20 key"), - CODE(VK_F21, "F21 key"), - CODE(VK_F22, "F22 key"), - CODE(VK_F23, "F23 key"), - CODE(VK_F24, "F24 key"), - CODE(VK_NUMLOCK, "NUM LOCK key"), - CODE(VK_SCROLL, "SCROLL LOCK key"), - CODE(VK_LSHIFT, "Left SHIFT key"), - CODE(VK_RSHIFT, "Right SHIFT key"), - CODE(VK_LCONTROL, "Left CONTROL key"), - CODE(VK_RCONTROL, "Right CONTROL key"), - CODE(VK_LMENU, "Left MENU key"), - CODE(VK_RMENU, "Right MENU key"), - CODE(VK_BROWSER_BACK, "Windows 2000/XP: Browser Back key"), - CODE(VK_BROWSER_FORWARD, "Windows 2000/XP: Browser Forward key"), - CODE(VK_BROWSER_REFRESH, "Windows 2000/XP: Browser Refresh key"), - CODE(VK_BROWSER_STOP, "Windows 2000/XP: Browser Stop key"), - CODE(VK_BROWSER_SEARCH, "Windows 2000/XP: Browser Search key "), - CODE(VK_BROWSER_FAVORITES, "Windows 2000/XP: Browser Favorites key"), - CODE(VK_BROWSER_HOME, "Windows 2000/XP: Browser Start and Home key"), - CODE(VK_VOLUME_MUTE, "Windows 2000/XP: Volume Mute key"), - CODE(VK_VOLUME_DOWN, "Windows 2000/XP: Volume Down key"), - CODE(VK_VOLUME_UP, "Windows 2000/XP: Volume Up key"), - CODE(VK_MEDIA_NEXT_TRACK, "Windows 2000/XP: Next Track key"), - CODE(VK_MEDIA_PREV_TRACK, "Windows 2000/XP: Previous Track key"), - CODE(VK_MEDIA_STOP, "Windows 2000/XP: Stop Media key"), - CODE(VK_MEDIA_PLAY_PAUSE, "Windows 2000/XP: Play/Pause Media key"), - CODE(VK_LAUNCH_MAIL, "Windows 2000/XP: Start Mail key"), - CODE(VK_LAUNCH_MEDIA_SELECT, "Windows 2000/XP: Select Media key"), - CODE(VK_LAUNCH_APP1, "Windows 2000/XP: Start Application 1 key"), - CODE(VK_LAUNCH_APP2, "Windows 2000/XP: Start Application 2 key"), - CODE(VK_OEM_1, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key"), - CODE(VK_OEM_PLUS, "Windows 2000/XP: For any country/region, the '+' key"), - CODE(VK_OEM_COMMA, "Windows 2000/XP: For any country/region, the ',' key"), - CODE(VK_OEM_MINUS, "Windows 2000/XP: For any country/region, the '-' key"), - CODE(VK_OEM_PERIOD, "Windows 2000/XP: For any country/region, the '.' key"), - CODE(VK_OEM_2, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key "), - CODE(VK_OEM_3, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key "), - CODE(VK_OEM_4, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key"), - CODE(VK_OEM_5, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\\|' key"), - CODE(VK_OEM_6, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key"), - CODE(VK_OEM_7, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key"), - CODE(VK_OEM_8, "Used for miscellaneous characters; it can vary by keyboard."), - CODE(VK_OEM_102, "Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard"), - CODE(VK_PROCESSKEY, "Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key"), - CODE(VK_PACKET, "Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP"), - CODE(VK_ATTN, "Attn key"), - CODE(VK_CRSEL, "CrSel key"), - CODE(VK_EXSEL, "ExSel key"), - CODE(VK_EREOF, "Erase EOF key"), - CODE(VK_PLAY, "Play key"), - CODE(VK_ZOOM, "Zoom key"), - CODE(VK_NONAME, "Reserved for future use"), - CODE(VK_PA1, "PA1 key"), - CODE(VK_OEM_CLEAR, "Clear key"), + CODE( VK_HANGUL, "IME Hangul mode" ), + CODE( VK_JUNJA, "IME Junja mode" ), + CODE( VK_FINAL, "IME final mode" ), + CODE( VK_HANJA, "IME Hanja mode" ), + CODE( VK_KANJI, "IME Kanji mode" ), + CODE( VK_ESCAPE, "ESC key" ), + CODE( VK_CONVERT, "IME convert" ), + CODE( VK_NONCONVERT, "IME nonconvert" ), + CODE( VK_ACCEPT, "IME accept" ), + CODE( VK_MODECHANGE, "IME mode change request" ), + CODE( VK_SPACE, "SPACEBAR" ), + CODE( VK_PRIOR, "PAGE UP key" ), + CODE( VK_NEXT, "PAGE DOWN key" ), + CODE( VK_END, "END key" ), + CODE( VK_HOME, "HOME key" ), + CODE( VK_LEFT, "LEFT ARROW key" ), + CODE( VK_UP, "UP ARROW key" ), + CODE( VK_RIGHT, "RIGHT ARROW key" ), + CODE( VK_DOWN, "DOWN ARROW key" ), + CODE( VK_SELECT, "SELECT key" ), + CODE( VK_PRINT, "PRINT key" ), + CODE( VK_EXECUTE, "EXECUTE key" ), + CODE( VK_SNAPSHOT, "PRINT SCREEN key" ), + CODE( VK_INSERT, "INS key" ), + CODE( VK_DELETE, "DEL key" ), + CODE( VK_HELP, "HELP key" ), + CODE( VK_0, "0 key" ), + CODE( VK_1, "1 key" ), + CODE( VK_2, "2 key" ), + CODE( VK_3, "3 key" ), + CODE( VK_4, "4 key" ), + CODE( VK_5, "5 key" ), + CODE( VK_6, "6 key" ), + CODE( VK_7, "7 key" ), + CODE( VK_8, "8 key" ), + CODE( VK_9, "9 key" ), + CODE( VK_A, "A key" ), + CODE( VK_B, "B key" ), + CODE( VK_C, "C key" ), + CODE( VK_D, "D key" ), + CODE( VK_E, "E key" ), + CODE( VK_F, "F key" ), + CODE( VK_G, "G key" ), + CODE( VK_H, "H key" ), + CODE( VK_I, "I key" ), + CODE( VK_J, "J key" ), + CODE( VK_K, "K key" ), + CODE( VK_L, "L key" ), + CODE( VK_M, "M key" ), + CODE( VK_N, "N key" ), + CODE( VK_O, "O key" ), + CODE( VK_P, "P key" ), + CODE( VK_Q, "Q key" ), + CODE( VK_R, "R key" ), + CODE( VK_S, "S key" ), + CODE( VK_T, "T key" ), + CODE( VK_U, "U key" ), + CODE( VK_V, "V key" ), + CODE( VK_W, "W key" ), + CODE( VK_X, "X key" ), + CODE( VK_Y, "Y key" ), + CODE( VK_Z, "Z key" ), + CODE( VK_LWIN, "Left Windows key (Microsoft Natural keyboard) " ), + CODE( VK_RWIN, "Right Windows key (Natural keyboard)" ), + CODE( VK_APPS, "Applications key (Natural keyboard)" ), + CODE( VK_SLEEP, "Computer Sleep key" ), + CODE( VK_NUMPAD0, "Numeric keypad 0 key" ), + CODE( VK_NUMPAD1, "Numeric keypad 1 key" ), + CODE( VK_NUMPAD2, "Numeric keypad 2 key" ), + CODE( VK_NUMPAD3, "Numeric keypad 3 key" ), + CODE( VK_NUMPAD4, "Numeric keypad 4 key" ), + CODE( VK_NUMPAD5, "Numeric keypad 5 key" ), + CODE( VK_NUMPAD6, "Numeric keypad 6 key" ), + CODE( VK_NUMPAD7, "Numeric keypad 7 key" ), + CODE( VK_NUMPAD8, "Numeric keypad 8 key" ), + CODE( VK_NUMPAD9, "Numeric keypad 9 key" ), + CODE( VK_MULTIPLY, "Multiply key" ), + CODE( VK_ADD, "Add key" ), + CODE( VK_SEPARATOR, "Separator key" ), + CODE( VK_SUBTRACT, "Subtract key" ), + CODE( VK_DECIMAL, "Decimal key" ), + CODE( VK_DIVIDE, "Divide key" ), + CODE( VK_F1, "F1 key" ), + CODE( VK_F2, "F2 key" ), + CODE( VK_F3, "F3 key" ), + CODE( VK_F4, "F4 key" ), + CODE( VK_F5, "F5 key" ), + CODE( VK_F6, "F6 key" ), + CODE( VK_F7, "F7 key" ), + CODE( VK_F8, "F8 key" ), + CODE( VK_F9, "F9 key" ), + CODE( VK_F10, "F10 key" ), + CODE( VK_F11, "F11 key" ), + CODE( VK_F12, "F12 key" ), + CODE( VK_F13, "F13 key" ), + CODE( VK_F14, "F14 key" ), + CODE( VK_F15, "F15 key" ), + CODE( VK_F16, "F16 key" ), + CODE( VK_F17, "F17 key" ), + CODE( VK_F18, "F18 key" ), + CODE( VK_F19, "F19 key" ), + CODE( VK_F20, "F20 key" ), + CODE( VK_F21, "F21 key" ), + CODE( VK_F22, "F22 key" ), + CODE( VK_F23, "F23 key" ), + CODE( VK_F24, "F24 key" ), + CODE( VK_NUMLOCK, "NUM LOCK key" ), + CODE( VK_SCROLL, "SCROLL LOCK key" ), + CODE( VK_LSHIFT, "Left SHIFT key" ), + CODE( VK_RSHIFT, "Right SHIFT key" ), + CODE( VK_LCONTROL, "Left CONTROL key" ), + CODE( VK_RCONTROL, "Right CONTROL key" ), + CODE( VK_LMENU, "Left MENU key" ), + CODE( VK_RMENU, "Right MENU key" ), + CODE( VK_BROWSER_BACK, "Windows 2000/XP: Browser Back key" ), + CODE( VK_BROWSER_FORWARD, "Windows 2000/XP: Browser Forward key" ), + CODE( VK_BROWSER_REFRESH, "Windows 2000/XP: Browser Refresh key" ), + CODE( VK_BROWSER_STOP, "Windows 2000/XP: Browser Stop key" ), + CODE( VK_BROWSER_SEARCH, "Windows 2000/XP: Browser Search key " ), + CODE( VK_BROWSER_FAVORITES, "Windows 2000/XP: Browser Favorites key" ), + CODE( VK_BROWSER_HOME, "Windows 2000/XP: Browser Start and Home key" ), + CODE( VK_VOLUME_MUTE, "Windows 2000/XP: Volume Mute key" ), + CODE( VK_VOLUME_DOWN, "Windows 2000/XP: Volume Down key" ), + CODE( VK_VOLUME_UP, "Windows 2000/XP: Volume Up key" ), + CODE( VK_MEDIA_NEXT_TRACK, "Windows 2000/XP: Next Track key" ), + CODE( VK_MEDIA_PREV_TRACK, "Windows 2000/XP: Previous Track key" ), + CODE( VK_MEDIA_STOP, "Windows 2000/XP: Stop Media key" ), + CODE( VK_MEDIA_PLAY_PAUSE, "Windows 2000/XP: Play/Pause Media key" ), + CODE( VK_LAUNCH_MAIL, "Windows 2000/XP: Start Mail key" ), + CODE( VK_LAUNCH_MEDIA_SELECT, "Windows 2000/XP: Select Media key" ), + CODE( VK_LAUNCH_APP1, "Windows 2000/XP: Start Application 1 key" ), + CODE( VK_LAUNCH_APP2, "Windows 2000/XP: Start Application 2 key" ), + CODE( VK_OEM_1, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key" ), + CODE( VK_OEM_PLUS, "Windows 2000/XP: For any country/region, the '+' key" ), + CODE( VK_OEM_COMMA, "Windows 2000/XP: For any country/region, the ',' key" ), + CODE( VK_OEM_MINUS, "Windows 2000/XP: For any country/region, the '-' key" ), + CODE( VK_OEM_PERIOD, "Windows 2000/XP: For any country/region, the '.' key" ), + CODE( VK_OEM_2, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key " ), + CODE( VK_OEM_3, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key " ), + CODE( VK_OEM_4, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key" ), + CODE( VK_OEM_5, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\\|' key" ), + CODE( VK_OEM_6, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key" ), + CODE( VK_OEM_7, "Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key" ), + CODE( VK_OEM_8, "Used for miscellaneous characters; it can vary by keyboard." ), + CODE( VK_OEM_102, "Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard" ), + CODE( VK_PROCESSKEY, "Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key" ), + CODE( VK_PACKET, "Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP" ), + CODE( VK_ATTN, "Attn key" ), + CODE( VK_CRSEL, "CrSel key" ), + CODE( VK_EXSEL, "ExSel key" ), + CODE( VK_EREOF, "Erase EOF key" ), + CODE( VK_PLAY, "Play key" ), + CODE( VK_ZOOM, "Zoom key" ), + CODE( VK_NONAME, "Reserved for future use" ), + CODE( VK_PA1, "PA1 key" ), + CODE( VK_OEM_CLEAR, "Clear key" ), }; #if BLUE_WITH_PYTHON -void AddScancodesToDict(PyObject* dict) +void AddScancodesToDict( PyObject* dict ) { - for (int i = 0; i < sizeof SCANCODES / sizeof SCANCODES[0]; i++) + for( int i = 0; i < sizeof SCANCODES / sizeof SCANCODES[0]; i++ ) { PyObject* value = ToPython( SCANCODES[i].mDIK ); - PyDict_SetItemString(dict, (char*)SCANCODES[i].mName, value); - Py_DECREF(value); + PyDict_SetItemString( dict, (char*)SCANCODES[i].mName, value ); + Py_DECREF( value ); } } #endif -const UIScancode* GetUIScancode(unsigned char scancode) +const UIScancode* GetUIScancode( unsigned char scancode ) { - for (int i = 0; i < sizeof SCANCODES / sizeof SCANCODES[0]; i++) + for( int i = 0; i < sizeof SCANCODES / sizeof SCANCODES[0]; i++ ) { - if (SCANCODES[i].mDIK == scancode) + if( SCANCODES[i].mDIK == scancode ) return SCANCODES + i; } @@ -213,156 +212,158 @@ const UIScancode* GetUIScancode(unsigned char scancode) namespace { /* ISO keyboards only*/ -enum { - kVK_ISO_Section = 0x0A +enum +{ + kVK_ISO_Section = 0x0A }; /* JIS keyboards only*/ -enum { - kVK_JIS_Yen = 0x5D, - kVK_JIS_Underscore = 0x5E, - kVK_JIS_KeypadComma = 0x5F, - kVK_JIS_Eisu = 0x66, - kVK_JIS_Kana = 0x68 +enum +{ + kVK_JIS_Yen = 0x5D, + kVK_JIS_Underscore = 0x5E, + kVK_JIS_KeypadComma = 0x5F, + kVK_JIS_Eisu = 0x66, + kVK_JIS_Kana = 0x68 }; struct KeyDesc { - uint16_t winCode; - uint16_t macCode; - const char* text; + uint16_t winCode; + uint16_t macCode; + const char* text; }; const KeyDesc s_keyCodes[] = { - { VK_BACK, kVK_Delete, "Backspace" }, - { VK_TAB, kVK_Tab, "Tab" }, - { VK_CLEAR, kVK_ANSI_KeypadClear, "Clear" }, - { VK_RETURN, kVK_Return, "Enter" }, - // VK_PAUSE? - { VK_CAPITAL, kVK_CapsLock, "Caps Lock" }, - { VK_KANA, kVK_JIS_Kana, "Kana" }, - // IME weird things like VK_JUNJA? - { VK_ESCAPE, kVK_Escape, "Esc" }, - { VK_SPACE, kVK_Space, "Space" }, - { VK_PRIOR, kVK_PageUp, "Page Up" }, - { VK_NEXT, kVK_PageDown, "Page Down" }, - { VK_END, kVK_End, "End" }, - { VK_HOME, kVK_Home, "Home" }, - { VK_LEFT, kVK_LeftArrow, "Left" }, - { VK_UP, kVK_UpArrow, "Up" }, - { VK_RIGHT, kVK_RightArrow, "Right" }, - { VK_DOWN, kVK_DownArrow, "Down" }, - // VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT? - { VK_INSERT, kVK_Function, "Fn" }, - { VK_DELETE, kVK_ForwardDelete, "Delete" }, - - { VK_0, kVK_ANSI_0, "0" }, - { VK_1, kVK_ANSI_1, "1" }, - { VK_2, kVK_ANSI_2, "2" }, - { VK_3, kVK_ANSI_3, "3" }, - { VK_4, kVK_ANSI_4, "4" }, - { VK_5, kVK_ANSI_5, "5" }, - { VK_6, kVK_ANSI_6, "6" }, - { VK_7, kVK_ANSI_7, "7" }, - { VK_8, kVK_ANSI_8, "8" }, - { VK_9, kVK_ANSI_9, "9" }, - - { VK_A, kVK_ANSI_A, "A" }, - { VK_B, kVK_ANSI_B, "B" }, - { VK_C, kVK_ANSI_C, "C" }, - { VK_D, kVK_ANSI_D, "D" }, - { VK_E, kVK_ANSI_E, "E" }, - { VK_F, kVK_ANSI_F, "F" }, - { VK_G, kVK_ANSI_G, "G" }, - { VK_H, kVK_ANSI_H, "H" }, - { VK_I, kVK_ANSI_I, "I" }, - { VK_J, kVK_ANSI_J, "J" }, - { VK_K, kVK_ANSI_K, "K" }, - { VK_L, kVK_ANSI_L, "L" }, - { VK_M, kVK_ANSI_M, "M" }, - { VK_N, kVK_ANSI_N, "N" }, - { VK_O, kVK_ANSI_O, "O" }, - { VK_P, kVK_ANSI_P, "P" }, - { VK_Q, kVK_ANSI_Q, "Q" }, - { VK_R, kVK_ANSI_R, "R" }, - { VK_S, kVK_ANSI_S, "S" }, - { VK_T, kVK_ANSI_T, "T" }, - { VK_U, kVK_ANSI_U, "U" }, - { VK_V, kVK_ANSI_V, "V" }, - { VK_W, kVK_ANSI_W, "W" }, - { VK_X, kVK_ANSI_X, "X" }, - { VK_Y, kVK_ANSI_Y, "Y" }, - { VK_Z, kVK_ANSI_Z, "Z" }, - - { VK_NUMPAD0, kVK_ANSI_Keypad0, "Num 0" }, - { VK_NUMPAD1, kVK_ANSI_Keypad1, "Num 1" }, - { VK_NUMPAD2, kVK_ANSI_Keypad2, "Num 2" }, - { VK_NUMPAD3, kVK_ANSI_Keypad3, "Num 3" }, - { VK_NUMPAD4, kVK_ANSI_Keypad4, "Num 4" }, - { VK_NUMPAD5, kVK_ANSI_Keypad5, "Num 5" }, - { VK_NUMPAD6, kVK_ANSI_Keypad6, "Num 6" }, - { VK_NUMPAD7, kVK_ANSI_Keypad7, "Num 7" }, - { VK_NUMPAD8, kVK_ANSI_Keypad8, "Num 8" }, - { VK_NUMPAD9, kVK_ANSI_Keypad9, "Num 9" }, - + { VK_BACK, kVK_Delete, "Backspace" }, + { VK_TAB, kVK_Tab, "Tab" }, + { VK_CLEAR, kVK_ANSI_KeypadClear, "Clear" }, + { VK_RETURN, kVK_Return, "Enter" }, + // VK_PAUSE? + { VK_CAPITAL, kVK_CapsLock, "Caps Lock" }, + { VK_KANA, kVK_JIS_Kana, "Kana" }, + // IME weird things like VK_JUNJA? + { VK_ESCAPE, kVK_Escape, "Esc" }, + { VK_SPACE, kVK_Space, "Space" }, + { VK_PRIOR, kVK_PageUp, "Page Up" }, + { VK_NEXT, kVK_PageDown, "Page Down" }, + { VK_END, kVK_End, "End" }, + { VK_HOME, kVK_Home, "Home" }, + { VK_LEFT, kVK_LeftArrow, "Left" }, + { VK_UP, kVK_UpArrow, "Up" }, + { VK_RIGHT, kVK_RightArrow, "Right" }, + { VK_DOWN, kVK_DownArrow, "Down" }, + // VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT? + { VK_INSERT, kVK_Function, "Fn" }, + { VK_DELETE, kVK_ForwardDelete, "Delete" }, + + { VK_0, kVK_ANSI_0, "0" }, + { VK_1, kVK_ANSI_1, "1" }, + { VK_2, kVK_ANSI_2, "2" }, + { VK_3, kVK_ANSI_3, "3" }, + { VK_4, kVK_ANSI_4, "4" }, + { VK_5, kVK_ANSI_5, "5" }, + { VK_6, kVK_ANSI_6, "6" }, + { VK_7, kVK_ANSI_7, "7" }, + { VK_8, kVK_ANSI_8, "8" }, + { VK_9, kVK_ANSI_9, "9" }, + + { VK_A, kVK_ANSI_A, "A" }, + { VK_B, kVK_ANSI_B, "B" }, + { VK_C, kVK_ANSI_C, "C" }, + { VK_D, kVK_ANSI_D, "D" }, + { VK_E, kVK_ANSI_E, "E" }, + { VK_F, kVK_ANSI_F, "F" }, + { VK_G, kVK_ANSI_G, "G" }, + { VK_H, kVK_ANSI_H, "H" }, + { VK_I, kVK_ANSI_I, "I" }, + { VK_J, kVK_ANSI_J, "J" }, + { VK_K, kVK_ANSI_K, "K" }, + { VK_L, kVK_ANSI_L, "L" }, + { VK_M, kVK_ANSI_M, "M" }, + { VK_N, kVK_ANSI_N, "N" }, + { VK_O, kVK_ANSI_O, "O" }, + { VK_P, kVK_ANSI_P, "P" }, + { VK_Q, kVK_ANSI_Q, "Q" }, + { VK_R, kVK_ANSI_R, "R" }, + { VK_S, kVK_ANSI_S, "S" }, + { VK_T, kVK_ANSI_T, "T" }, + { VK_U, kVK_ANSI_U, "U" }, + { VK_V, kVK_ANSI_V, "V" }, + { VK_W, kVK_ANSI_W, "W" }, + { VK_X, kVK_ANSI_X, "X" }, + { VK_Y, kVK_ANSI_Y, "Y" }, + { VK_Z, kVK_ANSI_Z, "Z" }, + + { VK_NUMPAD0, kVK_ANSI_Keypad0, "Num 0" }, + { VK_NUMPAD1, kVK_ANSI_Keypad1, "Num 1" }, + { VK_NUMPAD2, kVK_ANSI_Keypad2, "Num 2" }, + { VK_NUMPAD3, kVK_ANSI_Keypad3, "Num 3" }, + { VK_NUMPAD4, kVK_ANSI_Keypad4, "Num 4" }, + { VK_NUMPAD5, kVK_ANSI_Keypad5, "Num 5" }, + { VK_NUMPAD6, kVK_ANSI_Keypad6, "Num 6" }, + { VK_NUMPAD7, kVK_ANSI_Keypad7, "Num 7" }, + { VK_NUMPAD8, kVK_ANSI_Keypad8, "Num 8" }, + { VK_NUMPAD9, kVK_ANSI_Keypad9, "Num 9" }, + { VK_RETURN, kVK_ANSI_KeypadEnter, "Enter" }, - { VK_MULTIPLY, kVK_ANSI_KeypadMultiply, "Num *" }, - { VK_ADD, kVK_ANSI_KeypadPlus, "Num +" }, - // VK_SEPARATOR? - { VK_SUBTRACT, kVK_ANSI_KeypadMinus, "Num -" }, - { VK_DECIMAL, kVK_ANSI_KeypadDecimal, "Num ," }, - { VK_DIVIDE, kVK_ANSI_KeypadDivide, "Num /" }, - { VK_F1, kVK_F1, "F1" }, - { VK_F2, kVK_F2, "F2" }, - { VK_F3, kVK_F3, "F3" }, - { VK_F4, kVK_F4, "F4" }, - { VK_F5, kVK_F5, "F5" }, - { VK_F6, kVK_F6, "F6" }, - { VK_F7, kVK_F7, "F7" }, - { VK_F8, kVK_F8, "F8" }, - { VK_F9, kVK_F9, "F9" }, - { VK_F10, kVK_F10, "F10" }, - { VK_F11, kVK_F11, "F11" }, - { VK_F12, kVK_F12, "F12" }, - { VK_F13, kVK_F13, "F13" }, - { VK_F14, kVK_F14, "F14" }, - { VK_F15, kVK_F15, "F15" }, - { VK_F16, kVK_F16, "F16" }, - { VK_F17, kVK_F17, "F17" }, - { VK_F18, kVK_F18, "F18" }, - { VK_F19, kVK_F19, "F19" }, - { VK_F20, kVK_F20, "F20" }, - - { VK_LSHIFT, kVK_Shift, "Shift" }, - { VK_RSHIFT, kVK_RightShift, "Shift" }, - { VK_SHIFT, kVK_Shift, "Shift" }, - + { VK_MULTIPLY, kVK_ANSI_KeypadMultiply, "Num *" }, + { VK_ADD, kVK_ANSI_KeypadPlus, "Num +" }, + // VK_SEPARATOR? + { VK_SUBTRACT, kVK_ANSI_KeypadMinus, "Num -" }, + { VK_DECIMAL, kVK_ANSI_KeypadDecimal, "Num ," }, + { VK_DIVIDE, kVK_ANSI_KeypadDivide, "Num /" }, + { VK_F1, kVK_F1, "F1" }, + { VK_F2, kVK_F2, "F2" }, + { VK_F3, kVK_F3, "F3" }, + { VK_F4, kVK_F4, "F4" }, + { VK_F5, kVK_F5, "F5" }, + { VK_F6, kVK_F6, "F6" }, + { VK_F7, kVK_F7, "F7" }, + { VK_F8, kVK_F8, "F8" }, + { VK_F9, kVK_F9, "F9" }, + { VK_F10, kVK_F10, "F10" }, + { VK_F11, kVK_F11, "F11" }, + { VK_F12, kVK_F12, "F12" }, + { VK_F13, kVK_F13, "F13" }, + { VK_F14, kVK_F14, "F14" }, + { VK_F15, kVK_F15, "F15" }, + { VK_F16, kVK_F16, "F16" }, + { VK_F17, kVK_F17, "F17" }, + { VK_F18, kVK_F18, "F18" }, + { VK_F19, kVK_F19, "F19" }, + { VK_F20, kVK_F20, "F20" }, + + { VK_LSHIFT, kVK_Shift, "Shift" }, + { VK_RSHIFT, kVK_RightShift, "Shift" }, + { VK_SHIFT, kVK_Shift, "Shift" }, + { VK_LCONTROL, kVK_Control, "Ctrl" }, { VK_RCONTROL, kVK_RightControl, "Ctrl" }, { VK_CONTROL, kVK_Control, "Ctrl" }, - + { VK_LWIN, kVK_Command, "Cmd" }, { VK_RWIN, kVK_RightCommand, "Cmd" }, - { VK_LMENU, kVK_Option, "Alt" }, - { VK_RMENU, kVK_RightOption, "Alt" }, - { VK_MENU, kVK_Option, "Alt" }, - - { VK_OEM_1, kVK_ANSI_Semicolon, ";" }, - { VK_OEM_PLUS, kVK_ANSI_Equal, "=" }, - { VK_OEM_COMMA, kVK_ANSI_Comma, "," }, - { VK_OEM_MINUS, kVK_ANSI_Minus, "-" }, - { VK_OEM_PERIOD, kVK_ANSI_Period, "." }, - { VK_OEM_2, kVK_ANSI_Slash, "/" }, - { VK_OEM_3, kVK_ANSI_Grave, "`" }, - - { VK_OEM_4, kVK_ANSI_LeftBracket, "[" }, - { VK_OEM_5, kVK_ANSI_Backslash, "\\" }, - { VK_OEM_6, kVK_ANSI_RightBracket, "]" }, - { VK_OEM_7, kVK_ANSI_Quote, "\'" }, - { VK_OEM_102, 10, "<>" }, // This is not 100% accurate as this character is either "<>" or "\|" on RT 102-key kbd. + { VK_LMENU, kVK_Option, "Alt" }, + { VK_RMENU, kVK_RightOption, "Alt" }, + { VK_MENU, kVK_Option, "Alt" }, + + { VK_OEM_1, kVK_ANSI_Semicolon, ";" }, + { VK_OEM_PLUS, kVK_ANSI_Equal, "=" }, + { VK_OEM_COMMA, kVK_ANSI_Comma, "," }, + { VK_OEM_MINUS, kVK_ANSI_Minus, "-" }, + { VK_OEM_PERIOD, kVK_ANSI_Period, "." }, + { VK_OEM_2, kVK_ANSI_Slash, "/" }, + { VK_OEM_3, kVK_ANSI_Grave, "`" }, + + { VK_OEM_4, kVK_ANSI_LeftBracket, "[" }, + { VK_OEM_5, kVK_ANSI_Backslash, "\\" }, + { VK_OEM_6, kVK_ANSI_RightBracket, "]" }, + { VK_OEM_7, kVK_ANSI_Quote, "\'" }, + { VK_OEM_102, 10, "<>" }, // This is not 100% accurate as this character is either "<>" or "\|" on RT 102-key kbd. }; bool s_keysDown[256] = { false }; @@ -375,74 +376,74 @@ namespace KeyboardHelpers const AppKey INVALID_APP_KEY = 0xffff; const AppKey INVALID_PLATFORM_KEY = 0xffff; - + CGKeyCode ApplyKeyboardLayout( CGKeyCode keyCode ); CGKeyCode UnapplyKeyboardLayout( CGKeyCode keyCode ); std::string CreateStringForKey( CGKeyCode keyCode ); PlatformKey AppKeyToPlatformKey( AppKey appCode ) { - for( auto& desc : s_keyCodes ) - { - if( desc.winCode == appCode ) - { - return UnapplyKeyboardLayout( desc.macCode ); - } - } - return INVALID_PLATFORM_KEY; + for( auto& desc : s_keyCodes ) + { + if( desc.winCode == appCode ) + { + return UnapplyKeyboardLayout( desc.macCode ); + } + } + return INVALID_PLATFORM_KEY; } AppKey PlatformKeyToAppKey( PlatformKey platformCode ) { platformCode = ApplyKeyboardLayout( platformCode ); - for( auto& desc : s_keyCodes ) - { - if( desc.macCode == platformCode ) - { - return desc.winCode; - } - } - return INVALID_APP_KEY; + for( auto& desc : s_keyCodes ) + { + if( desc.macCode == platformCode ) + { + return desc.winCode; + } + } + return INVALID_APP_KEY; } std::string GetAppKeyName( AppKey appCode ) { - for( auto& desc : s_keyCodes ) - { - if( desc.winCode == appCode ) - { + for( auto& desc : s_keyCodes ) + { + if( desc.winCode == appCode ) + { auto str = CreateStringForKey( UnapplyKeyboardLayout( desc.macCode ) ); if( !str.empty() ) { return str; } - return desc.text; - } - } - return ""; + return desc.text; + } + } + return ""; } bool IsAppKeyPressed( AppKey appCode ) { - return IsPlatformKeyPressed( AppKeyToPlatformKey( appCode ) ); + return IsPlatformKeyPressed( AppKeyToPlatformKey( appCode ) ); } bool IsPlatformKeyPressed( PlatformKey platformCode ) { - if( platformCode > 255 ) - { - return false; - } - return s_keysDown[platformCode]; + if( platformCode > 255 ) + { + return false; + } + return s_keysDown[platformCode]; } void PlatformKeyChanged( PlatformKey platformCode, bool pressed ) { - if( platformCode > 255 ) - { - return; - } - s_keysDown[platformCode] = pressed; + if( platformCode > 255 ) + { + return; + } + s_keysDown[platformCode] = pressed; } } @@ -458,63 +459,62 @@ const AppKey INVALID_PLATFORM_KEY = 0; PlatformKey AppKeyToPlatformKey( AppKey appCode ) { - return appCode; + return appCode; } AppKey PlatformKeyToAppKey( PlatformKey platformCode ) { - return platformCode; + return platformCode; } std::string GetAppKeyName( AppKey keyCode ) { - auto scanCode = ::MapVirtualKeyA( keyCode, MAPVK_VK_TO_VSC ) << 16; - - // Set the extended keyboard bit for the following virtual keys - switch( keyCode ) - { - case VK_LEFT: - case VK_UP: - case VK_RIGHT: - case VK_DOWN: - case VK_PRIOR: - case VK_NEXT: - case VK_END: - case VK_HOME: - case VK_INSERT: - case VK_DELETE: - case VK_DIVIDE: - case VK_NUMLOCK: - { - scanCode |= ( 1 << 24 ); - } - } - - // Make no distinction between left and right control keys - scanCode |= ( 1 << 25 ); - - const int bufferSize = 64; - char buffer[bufferSize]; - - // Lookup the key name and return true if it succeeds - if( ::GetKeyNameTextA( scanCode, buffer, bufferSize ) ) - { - return buffer; - } - else - { - return ""; - } + auto scanCode = ::MapVirtualKeyA( keyCode, MAPVK_VK_TO_VSC ) << 16; + + // Set the extended keyboard bit for the following virtual keys + switch( keyCode ) + { + case VK_LEFT: + case VK_UP: + case VK_RIGHT: + case VK_DOWN: + case VK_PRIOR: + case VK_NEXT: + case VK_END: + case VK_HOME: + case VK_INSERT: + case VK_DELETE: + case VK_DIVIDE: + case VK_NUMLOCK: { + scanCode |= ( 1 << 24 ); + } + } + + // Make no distinction between left and right control keys + scanCode |= ( 1 << 25 ); + + const int bufferSize = 64; + char buffer[bufferSize]; + + // Lookup the key name and return true if it succeeds + if( ::GetKeyNameTextA( scanCode, buffer, bufferSize ) ) + { + return buffer; + } + else + { + return ""; + } } bool IsAppKeyPressed( AppKey appCode ) { - return IsPlatformKeyPressed( appCode ); + return IsPlatformKeyPressed( appCode ); } bool IsPlatformKeyPressed( PlatformKey platformCode ) { - return ( GetKeyState( platformCode ) & 0x8000 ) ? 1 : 0; + return ( GetKeyState( platformCode ) & 0x8000 ) ? 1 : 0; } void PlatformKeyChanged( PlatformKey, bool ) diff --git a/trinity/UI/Scancodes.h b/trinity/UI/Scancodes.h index c0bb80f31..db83b0d00 100644 --- a/trinity/UI/Scancodes.h +++ b/trinity/UI/Scancodes.h @@ -5,161 +5,161 @@ #ifndef _WIN32 -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_CANCEL 0x03 -#define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */ -#define VK_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */ -#define VK_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */ -#define VK_BACK 0x08 -#define VK_TAB 0x09 -#define VK_CLEAR 0x0C -#define VK_RETURN 0x0D -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 -#define VK_KANA 0x15 -#define VK_HANGEUL 0x15 /* old name - should be here for compatibility */ -#define VK_HANGUL 0x15 -#define VK_JUNJA 0x17 -#define VK_FINAL 0x18 -#define VK_HANJA 0x19 -#define VK_KANJI 0x19 -#define VK_ESCAPE 0x1B -#define VK_CONVERT 0x1C -#define VK_NONCONVERT 0x1D -#define VK_ACCEPT 0x1E -#define VK_MODECHANGE 0x1F -#define VK_SPACE 0x20 -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SELECT 0x29 -#define VK_PRINT 0x2A -#define VK_EXECUTE 0x2B -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E -#define VK_HELP 0x2F -#define VK_LWIN 0x5B -#define VK_RWIN 0x5C -#define VK_APPS 0x5D -#define VK_SLEEP 0x5F -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 -#define VK_MULTIPLY 0x6A -#define VK_ADD 0x6B -#define VK_SEPARATOR 0x6C -#define VK_SUBTRACT 0x6D -#define VK_DECIMAL 0x6E -#define VK_DIVIDE 0x6F -#define VK_F1 0x70 -#define VK_F2 0x71 -#define VK_F3 0x72 -#define VK_F4 0x73 -#define VK_F5 0x74 -#define VK_F6 0x75 -#define VK_F7 0x76 -#define VK_F8 0x77 -#define VK_F9 0x78 -#define VK_F10 0x79 -#define VK_F11 0x7A -#define VK_F12 0x7B -#define VK_F13 0x7C -#define VK_F14 0x7D -#define VK_F15 0x7E -#define VK_F16 0x7F -#define VK_F17 0x80 -#define VK_F18 0x81 -#define VK_F19 0x82 -#define VK_F20 0x83 -#define VK_F21 0x84 -#define VK_F22 0x85 -#define VK_F23 0x86 -#define VK_F24 0x87 -#define VK_NUMLOCK 0x90 -#define VK_SCROLL 0x91 -#define VK_LSHIFT 0xA0 -#define VK_RSHIFT 0xA1 -#define VK_LCONTROL 0xA2 -#define VK_RCONTROL 0xA3 -#define VK_LMENU 0xA4 -#define VK_RMENU 0xA5 -#define VK_BROWSER_BACK 0xA6 -#define VK_BROWSER_FORWARD 0xA7 -#define VK_BROWSER_REFRESH 0xA8 -#define VK_BROWSER_STOP 0xA9 -#define VK_BROWSER_SEARCH 0xAA -#define VK_BROWSER_FAVORITES 0xAB -#define VK_BROWSER_HOME 0xAC +#define VK_LBUTTON 0x01 +#define VK_RBUTTON 0x02 +#define VK_CANCEL 0x03 +#define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */ +#define VK_XBUTTON1 0x05 /* NOT contiguous with L & RBUTTON */ +#define VK_XBUTTON2 0x06 /* NOT contiguous with L & RBUTTON */ +#define VK_BACK 0x08 +#define VK_TAB 0x09 +#define VK_CLEAR 0x0C +#define VK_RETURN 0x0D +#define VK_SHIFT 0x10 +#define VK_CONTROL 0x11 +#define VK_MENU 0x12 +#define VK_PAUSE 0x13 +#define VK_CAPITAL 0x14 +#define VK_KANA 0x15 +#define VK_HANGEUL 0x15 /* old name - should be here for compatibility */ +#define VK_HANGUL 0x15 +#define VK_JUNJA 0x17 +#define VK_FINAL 0x18 +#define VK_HANJA 0x19 +#define VK_KANJI 0x19 +#define VK_ESCAPE 0x1B +#define VK_CONVERT 0x1C +#define VK_NONCONVERT 0x1D +#define VK_ACCEPT 0x1E +#define VK_MODECHANGE 0x1F +#define VK_SPACE 0x20 +#define VK_PRIOR 0x21 +#define VK_NEXT 0x22 +#define VK_END 0x23 +#define VK_HOME 0x24 +#define VK_LEFT 0x25 +#define VK_UP 0x26 +#define VK_RIGHT 0x27 +#define VK_DOWN 0x28 +#define VK_SELECT 0x29 +#define VK_PRINT 0x2A +#define VK_EXECUTE 0x2B +#define VK_SNAPSHOT 0x2C +#define VK_INSERT 0x2D +#define VK_DELETE 0x2E +#define VK_HELP 0x2F +#define VK_LWIN 0x5B +#define VK_RWIN 0x5C +#define VK_APPS 0x5D +#define VK_SLEEP 0x5F +#define VK_NUMPAD0 0x60 +#define VK_NUMPAD1 0x61 +#define VK_NUMPAD2 0x62 +#define VK_NUMPAD3 0x63 +#define VK_NUMPAD4 0x64 +#define VK_NUMPAD5 0x65 +#define VK_NUMPAD6 0x66 +#define VK_NUMPAD7 0x67 +#define VK_NUMPAD8 0x68 +#define VK_NUMPAD9 0x69 +#define VK_MULTIPLY 0x6A +#define VK_ADD 0x6B +#define VK_SEPARATOR 0x6C +#define VK_SUBTRACT 0x6D +#define VK_DECIMAL 0x6E +#define VK_DIVIDE 0x6F +#define VK_F1 0x70 +#define VK_F2 0x71 +#define VK_F3 0x72 +#define VK_F4 0x73 +#define VK_F5 0x74 +#define VK_F6 0x75 +#define VK_F7 0x76 +#define VK_F8 0x77 +#define VK_F9 0x78 +#define VK_F10 0x79 +#define VK_F11 0x7A +#define VK_F12 0x7B +#define VK_F13 0x7C +#define VK_F14 0x7D +#define VK_F15 0x7E +#define VK_F16 0x7F +#define VK_F17 0x80 +#define VK_F18 0x81 +#define VK_F19 0x82 +#define VK_F20 0x83 +#define VK_F21 0x84 +#define VK_F22 0x85 +#define VK_F23 0x86 +#define VK_F24 0x87 +#define VK_NUMLOCK 0x90 +#define VK_SCROLL 0x91 +#define VK_LSHIFT 0xA0 +#define VK_RSHIFT 0xA1 +#define VK_LCONTROL 0xA2 +#define VK_RCONTROL 0xA3 +#define VK_LMENU 0xA4 +#define VK_RMENU 0xA5 +#define VK_BROWSER_BACK 0xA6 +#define VK_BROWSER_FORWARD 0xA7 +#define VK_BROWSER_REFRESH 0xA8 +#define VK_BROWSER_STOP 0xA9 +#define VK_BROWSER_SEARCH 0xAA +#define VK_BROWSER_FAVORITES 0xAB +#define VK_BROWSER_HOME 0xAC -#define VK_VOLUME_MUTE 0xAD -#define VK_VOLUME_DOWN 0xAE -#define VK_VOLUME_UP 0xAF -#define VK_MEDIA_NEXT_TRACK 0xB0 -#define VK_MEDIA_PREV_TRACK 0xB1 -#define VK_MEDIA_STOP 0xB2 -#define VK_MEDIA_PLAY_PAUSE 0xB3 -#define VK_LAUNCH_MAIL 0xB4 +#define VK_VOLUME_MUTE 0xAD +#define VK_VOLUME_DOWN 0xAE +#define VK_VOLUME_UP 0xAF +#define VK_MEDIA_NEXT_TRACK 0xB0 +#define VK_MEDIA_PREV_TRACK 0xB1 +#define VK_MEDIA_STOP 0xB2 +#define VK_MEDIA_PLAY_PAUSE 0xB3 +#define VK_LAUNCH_MAIL 0xB4 #define VK_LAUNCH_MEDIA_SELECT 0xB5 -#define VK_LAUNCH_APP1 0xB6 -#define VK_LAUNCH_APP2 0xB7 -#define VK_OEM_1 0xBA // ';:' for US -#define VK_OEM_PLUS 0xBB // '+' any country -#define VK_OEM_COMMA 0xBC // ',' any country -#define VK_OEM_MINUS 0xBD // '-' any country -#define VK_OEM_PERIOD 0xBE // '.' any country -#define VK_OEM_2 0xBF // '/?' for US -#define VK_OEM_3 0xC0 // '`~' for US -#define VK_OEM_4 0xDB // '[{' for US -#define VK_OEM_5 0xDC // '\|' for US -#define VK_OEM_6 0xDD // ']}' for US -#define VK_OEM_7 0xDE // ''"' for US -#define VK_OEM_8 0xDF -#define VK_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd -#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. -#define VK_ICO_HELP 0xE3 // Help key on ICO -#define VK_ICO_00 0xE4 // 00 key on ICO -#define VK_PROCESSKEY 0xE5 -#define VK_ICO_CLEAR 0xE6 -#define VK_PACKET 0xE7 -#define VK_OEM_RESET 0xE9 -#define VK_OEM_JUMP 0xEA -#define VK_OEM_PA1 0xEB -#define VK_OEM_PA2 0xEC -#define VK_OEM_PA3 0xED -#define VK_OEM_WSCTRL 0xEE -#define VK_OEM_CUSEL 0xEF -#define VK_OEM_ATTN 0xF0 -#define VK_OEM_FINISH 0xF1 -#define VK_OEM_COPY 0xF2 -#define VK_OEM_AUTO 0xF3 -#define VK_OEM_ENLW 0xF4 -#define VK_OEM_BACKTAB 0xF5 -#define VK_ATTN 0xF6 -#define VK_CRSEL 0xF7 -#define VK_EXSEL 0xF8 -#define VK_EREOF 0xF9 -#define VK_PLAY 0xFA -#define VK_ZOOM 0xFB -#define VK_NONAME 0xFC -#define VK_PA1 0xFD -#define VK_OEM_CLEAR 0xFE +#define VK_LAUNCH_APP1 0xB6 +#define VK_LAUNCH_APP2 0xB7 +#define VK_OEM_1 0xBA // ';:' for US +#define VK_OEM_PLUS 0xBB // '+' any country +#define VK_OEM_COMMA 0xBC // ',' any country +#define VK_OEM_MINUS 0xBD // '-' any country +#define VK_OEM_PERIOD 0xBE // '.' any country +#define VK_OEM_2 0xBF // '/?' for US +#define VK_OEM_3 0xC0 // '`~' for US +#define VK_OEM_4 0xDB // '[{' for US +#define VK_OEM_5 0xDC // '\|' for US +#define VK_OEM_6 0xDD // ']}' for US +#define VK_OEM_7 0xDE // ''"' for US +#define VK_OEM_8 0xDF +#define VK_OEM_AX 0xE1 // 'AX' key on Japanese AX kbd +#define VK_OEM_102 0xE2 // "<>" or "\|" on RT 102-key kbd. +#define VK_ICO_HELP 0xE3 // Help key on ICO +#define VK_ICO_00 0xE4 // 00 key on ICO +#define VK_PROCESSKEY 0xE5 +#define VK_ICO_CLEAR 0xE6 +#define VK_PACKET 0xE7 +#define VK_OEM_RESET 0xE9 +#define VK_OEM_JUMP 0xEA +#define VK_OEM_PA1 0xEB +#define VK_OEM_PA2 0xEC +#define VK_OEM_PA3 0xED +#define VK_OEM_WSCTRL 0xEE +#define VK_OEM_CUSEL 0xEF +#define VK_OEM_ATTN 0xF0 +#define VK_OEM_FINISH 0xF1 +#define VK_OEM_COPY 0xF2 +#define VK_OEM_AUTO 0xF3 +#define VK_OEM_ENLW 0xF4 +#define VK_OEM_BACKTAB 0xF5 +#define VK_ATTN 0xF6 +#define VK_CRSEL 0xF7 +#define VK_EXSEL 0xF8 +#define VK_EREOF 0xF9 +#define VK_PLAY 0xFA +#define VK_ZOOM 0xFB +#define VK_NONAME 0xFC +#define VK_PA1 0xFD +#define VK_OEM_CLEAR 0xFE #endif #define VK_0 '0' @@ -203,124 +203,126 @@ #ifdef __APPLE__ // Cannot properly include Carbon/Carbon.h with virtual key code constants, so // inlining them here -enum { - kVK_ANSI_A = 0x00, - kVK_ANSI_S = 0x01, - kVK_ANSI_D = 0x02, - kVK_ANSI_F = 0x03, - kVK_ANSI_H = 0x04, - kVK_ANSI_G = 0x05, - kVK_ANSI_Z = 0x06, - kVK_ANSI_X = 0x07, - kVK_ANSI_C = 0x08, - kVK_ANSI_V = 0x09, - kVK_ANSI_B = 0x0B, - kVK_ANSI_Q = 0x0C, - kVK_ANSI_W = 0x0D, - kVK_ANSI_E = 0x0E, - kVK_ANSI_R = 0x0F, - kVK_ANSI_Y = 0x10, - kVK_ANSI_T = 0x11, - kVK_ANSI_1 = 0x12, - kVK_ANSI_2 = 0x13, - kVK_ANSI_3 = 0x14, - kVK_ANSI_4 = 0x15, - kVK_ANSI_6 = 0x16, - kVK_ANSI_5 = 0x17, - kVK_ANSI_Equal = 0x18, - kVK_ANSI_9 = 0x19, - kVK_ANSI_7 = 0x1A, - kVK_ANSI_Minus = 0x1B, - kVK_ANSI_8 = 0x1C, - kVK_ANSI_0 = 0x1D, - kVK_ANSI_RightBracket = 0x1E, - kVK_ANSI_O = 0x1F, - kVK_ANSI_U = 0x20, - kVK_ANSI_LeftBracket = 0x21, - kVK_ANSI_I = 0x22, - kVK_ANSI_P = 0x23, - kVK_ANSI_L = 0x25, - kVK_ANSI_J = 0x26, - kVK_ANSI_Quote = 0x27, - kVK_ANSI_K = 0x28, - kVK_ANSI_Semicolon = 0x29, - kVK_ANSI_Backslash = 0x2A, - kVK_ANSI_Comma = 0x2B, - kVK_ANSI_Slash = 0x2C, - kVK_ANSI_N = 0x2D, - kVK_ANSI_M = 0x2E, - kVK_ANSI_Period = 0x2F, - kVK_ANSI_Grave = 0x32, - kVK_ANSI_KeypadDecimal = 0x41, - kVK_ANSI_KeypadMultiply = 0x43, - kVK_ANSI_KeypadPlus = 0x45, - kVK_ANSI_KeypadClear = 0x47, - kVK_ANSI_KeypadDivide = 0x4B, - kVK_ANSI_KeypadEnter = 0x4C, - kVK_ANSI_KeypadMinus = 0x4E, - kVK_ANSI_KeypadEquals = 0x51, - kVK_ANSI_Keypad0 = 0x52, - kVK_ANSI_Keypad1 = 0x53, - kVK_ANSI_Keypad2 = 0x54, - kVK_ANSI_Keypad3 = 0x55, - kVK_ANSI_Keypad4 = 0x56, - kVK_ANSI_Keypad5 = 0x57, - kVK_ANSI_Keypad6 = 0x58, - kVK_ANSI_Keypad7 = 0x59, - kVK_ANSI_Keypad8 = 0x5B, - kVK_ANSI_Keypad9 = 0x5C +enum +{ + kVK_ANSI_A = 0x00, + kVK_ANSI_S = 0x01, + kVK_ANSI_D = 0x02, + kVK_ANSI_F = 0x03, + kVK_ANSI_H = 0x04, + kVK_ANSI_G = 0x05, + kVK_ANSI_Z = 0x06, + kVK_ANSI_X = 0x07, + kVK_ANSI_C = 0x08, + kVK_ANSI_V = 0x09, + kVK_ANSI_B = 0x0B, + kVK_ANSI_Q = 0x0C, + kVK_ANSI_W = 0x0D, + kVK_ANSI_E = 0x0E, + kVK_ANSI_R = 0x0F, + kVK_ANSI_Y = 0x10, + kVK_ANSI_T = 0x11, + kVK_ANSI_1 = 0x12, + kVK_ANSI_2 = 0x13, + kVK_ANSI_3 = 0x14, + kVK_ANSI_4 = 0x15, + kVK_ANSI_6 = 0x16, + kVK_ANSI_5 = 0x17, + kVK_ANSI_Equal = 0x18, + kVK_ANSI_9 = 0x19, + kVK_ANSI_7 = 0x1A, + kVK_ANSI_Minus = 0x1B, + kVK_ANSI_8 = 0x1C, + kVK_ANSI_0 = 0x1D, + kVK_ANSI_RightBracket = 0x1E, + kVK_ANSI_O = 0x1F, + kVK_ANSI_U = 0x20, + kVK_ANSI_LeftBracket = 0x21, + kVK_ANSI_I = 0x22, + kVK_ANSI_P = 0x23, + kVK_ANSI_L = 0x25, + kVK_ANSI_J = 0x26, + kVK_ANSI_Quote = 0x27, + kVK_ANSI_K = 0x28, + kVK_ANSI_Semicolon = 0x29, + kVK_ANSI_Backslash = 0x2A, + kVK_ANSI_Comma = 0x2B, + kVK_ANSI_Slash = 0x2C, + kVK_ANSI_N = 0x2D, + kVK_ANSI_M = 0x2E, + kVK_ANSI_Period = 0x2F, + kVK_ANSI_Grave = 0x32, + kVK_ANSI_KeypadDecimal = 0x41, + kVK_ANSI_KeypadMultiply = 0x43, + kVK_ANSI_KeypadPlus = 0x45, + kVK_ANSI_KeypadClear = 0x47, + kVK_ANSI_KeypadDivide = 0x4B, + kVK_ANSI_KeypadEnter = 0x4C, + kVK_ANSI_KeypadMinus = 0x4E, + kVK_ANSI_KeypadEquals = 0x51, + kVK_ANSI_Keypad0 = 0x52, + kVK_ANSI_Keypad1 = 0x53, + kVK_ANSI_Keypad2 = 0x54, + kVK_ANSI_Keypad3 = 0x55, + kVK_ANSI_Keypad4 = 0x56, + kVK_ANSI_Keypad5 = 0x57, + kVK_ANSI_Keypad6 = 0x58, + kVK_ANSI_Keypad7 = 0x59, + kVK_ANSI_Keypad8 = 0x5B, + kVK_ANSI_Keypad9 = 0x5C }; /* keycodes for keys that are independent of keyboard layout*/ -enum { - kVK_Return = 0x24, - kVK_Tab = 0x30, - kVK_Space = 0x31, - kVK_Delete = 0x33, - kVK_Escape = 0x35, - kVK_Command = 0x37, - kVK_Shift = 0x38, - kVK_CapsLock = 0x39, - kVK_Option = 0x3A, - kVK_Control = 0x3B, - kVK_RightCommand = 0x36, - kVK_RightShift = 0x3C, - kVK_RightOption = 0x3D, - kVK_RightControl = 0x3E, - kVK_Function = 0x3F, - kVK_F17 = 0x40, - kVK_VolumeUp = 0x48, - kVK_VolumeDown = 0x49, - kVK_Mute = 0x4A, - kVK_F18 = 0x4F, - kVK_F19 = 0x50, - kVK_F20 = 0x5A, - kVK_F5 = 0x60, - kVK_F6 = 0x61, - kVK_F7 = 0x62, - kVK_F3 = 0x63, - kVK_F8 = 0x64, - kVK_F9 = 0x65, - kVK_F11 = 0x67, - kVK_F13 = 0x69, - kVK_F16 = 0x6A, - kVK_F14 = 0x6B, - kVK_F10 = 0x6D, - kVK_F12 = 0x6F, - kVK_F15 = 0x71, - kVK_Help = 0x72, - kVK_Home = 0x73, - kVK_PageUp = 0x74, - kVK_ForwardDelete = 0x75, - kVK_F4 = 0x76, - kVK_End = 0x77, - kVK_F2 = 0x78, - kVK_PageDown = 0x79, - kVK_F1 = 0x7A, - kVK_LeftArrow = 0x7B, - kVK_RightArrow = 0x7C, - kVK_DownArrow = 0x7D, - kVK_UpArrow = 0x7E +enum +{ + kVK_Return = 0x24, + kVK_Tab = 0x30, + kVK_Space = 0x31, + kVK_Delete = 0x33, + kVK_Escape = 0x35, + kVK_Command = 0x37, + kVK_Shift = 0x38, + kVK_CapsLock = 0x39, + kVK_Option = 0x3A, + kVK_Control = 0x3B, + kVK_RightCommand = 0x36, + kVK_RightShift = 0x3C, + kVK_RightOption = 0x3D, + kVK_RightControl = 0x3E, + kVK_Function = 0x3F, + kVK_F17 = 0x40, + kVK_VolumeUp = 0x48, + kVK_VolumeDown = 0x49, + kVK_Mute = 0x4A, + kVK_F18 = 0x4F, + kVK_F19 = 0x50, + kVK_F20 = 0x5A, + kVK_F5 = 0x60, + kVK_F6 = 0x61, + kVK_F7 = 0x62, + kVK_F3 = 0x63, + kVK_F8 = 0x64, + kVK_F9 = 0x65, + kVK_F11 = 0x67, + kVK_F13 = 0x69, + kVK_F16 = 0x6A, + kVK_F14 = 0x6B, + kVK_F10 = 0x6D, + kVK_F12 = 0x6F, + kVK_F15 = 0x71, + kVK_Help = 0x72, + kVK_Home = 0x73, + kVK_PageUp = 0x74, + kVK_ForwardDelete = 0x75, + kVK_F4 = 0x76, + kVK_End = 0x77, + kVK_F2 = 0x78, + kVK_PageDown = 0x79, + kVK_F1 = 0x7A, + kVK_LeftArrow = 0x7B, + kVK_RightArrow = 0x7C, + kVK_DownArrow = 0x7D, + kVK_UpArrow = 0x7E }; #endif @@ -335,9 +337,9 @@ struct UIScancode extern const UIScancode SCANCODES[]; #if BLUE_WITH_PYTHON -void AddScancodesToDict(PyObject* dict); +void AddScancodesToDict( PyObject* dict ); #endif -const UIScancode* GetUIScancode(unsigned char scancode); +const UIScancode* GetUIScancode( unsigned char scancode ); namespace KeyboardHelpers diff --git a/trinity/UI/Scancodes.mm b/trinity/UI/Scancodes.mm index 7508a5fde..947ef9a63 100644 --- a/trinity/UI/Scancodes.mm +++ b/trinity/UI/Scancodes.mm @@ -31,8 +31,7 @@ { 'x', 'X' }, // kVK_ANSI_X { 'c', 'C' }, // kVK_ANSI_C { 'v', 'V' }, // kVK_ANSI_V - { 0, 0 }, - { 'b', 'B' }, // kVK_ANSI_B + { 0, 0 }, { 'b', 'B' }, // kVK_ANSI_B { 'q', 'Q' }, // kVK_ANSI_Q { 'w', 'W' }, // kVK_ANSI_W { 'e', 'E' }, // kVK_ANSI_E @@ -57,8 +56,7 @@ { '[', '{' }, // kVK_ANSI_LeftBracket { 'i', 'I' }, // kVK_ANSI_I { 'p', 'P' }, // kVK_ANSI_P - { 0, 0 }, - { 'l', 'L' }, // kVK_ANSI_L + { 0, 0 }, { 'l', 'L' }, // kVK_ANSI_L { 'j', 'J' }, // kVK_ANSI_J { '\'', '\"' }, // kVK_ANSI_Quote { 'k', 'K' }, // kVK_ANSI_K @@ -69,11 +67,9 @@ { 'n', 'N' }, // kVK_ANSI_N { 'm', 'M' }, // kVK_ANSI_M { '.', '>' }, // kVK_ANSI_Period - { 0, 0 }, - { 0, 0 }, - { '`', '~' }, // kVK_ANSI_Grave + { 0, 0 }, { 0, 0 }, { '`', '~' }, // kVK_ANSI_Grave }; - + class KeyReversedLookup { public: @@ -89,15 +85,16 @@ } } } - + uint32_t operator[]( char c ) const { return m_keyForChar[int( (uint8_t)c )]; } + private: uint32_t m_keyForChar[256]; }; - + static KeyReversedLookup s_ansiKeyForChar = KeyReversedLookup( false ); // A list of ANSI key codes - the ones that can be re-assigned in the keyboard layout @@ -150,7 +147,7 @@ kVK_ANSI_Period, kVK_ANSI_Grave, - 10 // OEM 102 + 10 // OEM 102 }; CGKeyCode s_physicalToVirtual[0xff]; @@ -166,43 +163,44 @@ void ProcessKeyboardLayout() CFRelease( currentKeyboard ); return; } - + if( s_activeKeyboard ) { CFRelease( s_activeKeyboard ); s_activeKeyboard = nullptr; } s_activeKeyboard = currentKeyboard; - + for( int keyCode = 0; keyCode < 0xff; ++keyCode ) { s_physicalToVirtual[keyCode] = CGKeyCode( keyCode ); s_virtualToPhysical[keyCode] = CGKeyCode( keyCode ); } s_keyLabels.clear(); - - if( CFDataRef layoutData = (CFDataRef)TISGetInputSourceProperty( currentKeyboard, kTISPropertyUnicodeKeyLayoutData ) ) + + if( CFDataRef layoutData = + (CFDataRef)TISGetInputSourceProperty( currentKeyboard, kTISPropertyUnicodeKeyLayoutData ) ) { - const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr( layoutData ); + const UCKeyboardLayout* keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr( layoutData ); UInt32 keysDown = 0; UniChar chars[4]; UniCharCount realLength; - + for( auto keyCode : s_ansiKeys ) { // For each of re-assignable keys, we query it's label (what would account for the // keyboard layout. Given this label, we find the key in ANSI layout that corresponds to // that label. This gives us the corresponding "virtual" key for the physical key. - UCKeyTranslate(keyboardLayout, - keyCode, - kUCKeyActionDisplay, - 0, - LMGetKbdType(), - kUCKeyTranslateNoDeadKeysBit, - &keysDown, - sizeof( chars ) / sizeof( chars[0] ), - &realLength, - chars); + UCKeyTranslate( keyboardLayout, + keyCode, + kUCKeyActionDisplay, + 0, + LMGetKbdType(), + kUCKeyTranslateNoDeadKeysBit, + &keysDown, + sizeof( chars ) / sizeof( chars[0] ), + &realLength, + chars ); if( chars[0] > 31 && chars[0] < 256 ) { uint32_t key = s_ansiKeyForChar[char( chars[0] )]; @@ -215,23 +213,23 @@ void ProcessKeyboardLayout() if( !str ) { CCP_LOGWARN( "ProcessKeyboardLayout: Failed to create string for character %u", keyCode ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [str release]; #endif continue; } - const char* utf8_str = [ [str localizedUppercaseString] UTF8String ]; + const char* utf8_str = [[str localizedUppercaseString] UTF8String]; if( !str ) { CCP_LOGWARN( "ProcessKeyboardLayout: Failed to create utf-8 string for character %u", keyCode ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [str release]; #endif continue; } - s_keyLabels[keyCode] = std::string(utf8_str); + s_keyLabels[keyCode] = std::string( utf8_str ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [str release]; #endif } @@ -255,11 +253,11 @@ CGKeyCode UnapplyKeyboardLayout( CGKeyCode keyCode ) ProcessKeyboardLayout(); return s_virtualToPhysical[keyCode]; } - + std::string CreateStringForKey( CGKeyCode keyCode ) { ProcessKeyboardLayout(); - auto it = s_keyLabels.find(keyCode); + auto it = s_keyLabels.find( keyCode ); if( it != s_keyLabels.end() ) { return it->second; diff --git a/trinity/UI/TouchBar.h b/trinity/UI/TouchBar.h index 85ec49b1d..686b5c83a 100644 --- a/trinity/UI/TouchBar.h +++ b/trinity/UI/TouchBar.h @@ -16,8 +16,8 @@ // There is a "Control Strip" on the right that has some standard stuff like Siri, // that we have no control over from the application perspective. @interface TouchBar : NSObject -- (id) initWithWindow: (Tr2MainWindow *) pMainWindow; -- (NSTouchBar *) makeFunctionKeyTouchBar; +- (id)initWithWindow:(Tr2MainWindow*)pMainWindow; +- (NSTouchBar*)makeFunctionKeyTouchBar; @end #endif // __APPLE__ diff --git a/trinity/UI/TouchBar.mm b/trinity/UI/TouchBar.mm index 298e6f1e1..142ec3642 100644 --- a/trinity/UI/TouchBar.mm +++ b/trinity/UI/TouchBar.mm @@ -11,136 +11,167 @@ @implementation TouchBar { - Tr2MainWindow * m_mainWindow; -} - -- (id) initWithWindow: (Tr2MainWindow *) pMainWindow -{ - self = [super init]; - if(self) - { - m_mainWindow = pMainWindow; - } - return self; -} - -- (NSTouchBar *) makeFunctionKeyTouchBar -{ - NSTouchBar* bar = [[NSTouchBar alloc] init]; - - NSCustomTouchBarItem* itemF1 = [self addToolBarButton:@"F1" itemIdentifier:@"F1CustomTouchBarItem" action:@selector(pressF1)]; - NSCustomTouchBarItem* itemF2 = [self addToolBarButton:@"F2" itemIdentifier:@"F2CustomTouchBarItem" action:@selector(pressF2)]; - NSCustomTouchBarItem* itemF3 = [self addToolBarButton:@"F3" itemIdentifier:@"F3CustomTouchBarItem" action:@selector(pressF3)]; - NSCustomTouchBarItem* itemF4 = [self addToolBarButton:@"F4" itemIdentifier:@"F4CustomTouchBarItem" action:@selector(pressF4)]; + Tr2MainWindow* m_mainWindow; +} + +- (id)initWithWindow:(Tr2MainWindow*)pMainWindow +{ + self = [super init]; + if( self ) + { + m_mainWindow = pMainWindow; + } + return self; +} + +- (NSTouchBar*)makeFunctionKeyTouchBar +{ + NSTouchBar* bar = [[NSTouchBar alloc] init]; + + NSCustomTouchBarItem* itemF1 = [self addToolBarButton:@"F1" + itemIdentifier:@"F1CustomTouchBarItem" + action:@selector( pressF1 )]; + NSCustomTouchBarItem* itemF2 = [self addToolBarButton:@"F2" + itemIdentifier:@"F2CustomTouchBarItem" + action:@selector( pressF2 )]; + NSCustomTouchBarItem* itemF3 = [self addToolBarButton:@"F3" + itemIdentifier:@"F3CustomTouchBarItem" + action:@selector( pressF3 )]; + NSCustomTouchBarItem* itemF4 = [self addToolBarButton:@"F4" + itemIdentifier:@"F4CustomTouchBarItem" + action:@selector( pressF4 )]; - NSCustomTouchBarItem* itemF5 = [self addToolBarButton:@"F5" itemIdentifier:@"F5CustomTouchBarItem" action:@selector(pressF5)]; - NSCustomTouchBarItem* itemF6 = [self addToolBarButton:@"F6" itemIdentifier:@"F6CustomTouchBarItem" action:@selector(pressF6)]; - NSCustomTouchBarItem* itemF7 = [self addToolBarButton:@"F7" itemIdentifier:@"F7CustomTouchBarItem" action:@selector(pressF7)]; - NSCustomTouchBarItem* itemF8 = [self addToolBarButton:@"F8" itemIdentifier:@"F8CustomTouchBarItem" action:@selector(pressF8)]; + NSCustomTouchBarItem* itemF5 = [self addToolBarButton:@"F5" + itemIdentifier:@"F5CustomTouchBarItem" + action:@selector( pressF5 )]; + NSCustomTouchBarItem* itemF6 = [self addToolBarButton:@"F6" + itemIdentifier:@"F6CustomTouchBarItem" + action:@selector( pressF6 )]; + NSCustomTouchBarItem* itemF7 = [self addToolBarButton:@"F7" + itemIdentifier:@"F7CustomTouchBarItem" + action:@selector( pressF7 )]; + NSCustomTouchBarItem* itemF8 = [self addToolBarButton:@"F8" + itemIdentifier:@"F8CustomTouchBarItem" + action:@selector( pressF8 )]; - NSCustomTouchBarItem* itemF9 = [self addToolBarButton:@"F9" itemIdentifier:@"F9CustomTouchBarItem" action:@selector(pressF9)]; - NSCustomTouchBarItem* itemF10 = [self addToolBarButton:@"F10" itemIdentifier:@"F10CustomTouchBarItem" action:@selector(pressF10)]; - NSCustomTouchBarItem* itemF11 = [self addToolBarButton:@"F11" itemIdentifier:@"F11CustomTouchBarItem" action:@selector(pressF11)]; - NSCustomTouchBarItem* itemF12 = [self addToolBarButton:@"F12" itemIdentifier:@"F12CustomTouchBarItem" action:@selector(pressF12)]; + NSCustomTouchBarItem* itemF9 = [self addToolBarButton:@"F9" + itemIdentifier:@"F9CustomTouchBarItem" + action:@selector( pressF9 )]; + NSCustomTouchBarItem* itemF10 = [self addToolBarButton:@"F10" + itemIdentifier:@"F10CustomTouchBarItem" + action:@selector( pressF10 )]; + NSCustomTouchBarItem* itemF11 = [self addToolBarButton:@"F11" + itemIdentifier:@"F11CustomTouchBarItem" + action:@selector( pressF11 )]; + NSCustomTouchBarItem* itemF12 = [self addToolBarButton:@"F12" + itemIdentifier:@"F12CustomTouchBarItem" + action:@selector( pressF12 )]; - bar.templateItems = [NSSet setWithArray:@[ - itemF1, itemF2, itemF3, itemF4, - itemF5, itemF6, itemF7, itemF8, - itemF9, itemF10, itemF11, itemF12, - ]]; + bar.templateItems = [NSSet setWithArray:@[ + itemF1, + itemF2, + itemF3, + itemF4, + itemF5, + itemF6, + itemF7, + itemF8, + itemF9, + itemF10, + itemF11, + itemF12, + ]]; - bar.defaultItemIdentifiers = @[ - @"F1CustomTouchBarItem", - @"F2CustomTouchBarItem", - @"F3CustomTouchBarItem", - @"F4CustomTouchBarItem", - @"F5CustomTouchBarItem", - @"F6CustomTouchBarItem", - @"F7CustomTouchBarItem", - @"F8CustomTouchBarItem", - @"F9CustomTouchBarItem", - @"F10CustomTouchBarItem", - @"F11CustomTouchBarItem", - @"F12CustomTouchBarItem", - ]; + bar.defaultItemIdentifiers = @[ + @"F1CustomTouchBarItem", + @"F2CustomTouchBarItem", + @"F3CustomTouchBarItem", + @"F4CustomTouchBarItem", + @"F5CustomTouchBarItem", + @"F6CustomTouchBarItem", + @"F7CustomTouchBarItem", + @"F8CustomTouchBarItem", + @"F9CustomTouchBarItem", + @"F10CustomTouchBarItem", + @"F11CustomTouchBarItem", + @"F12CustomTouchBarItem", + ]; - return bar; + return bar; } -- (NSCustomTouchBarItem *) addToolBarButton: (NSString *) title - itemIdentifier: (NSString *) itemIdentifier - action: (SEL) action +- (NSCustomTouchBarItem*)addToolBarButton:(NSString*)title itemIdentifier:(NSString*)itemIdentifier action:(SEL)action { - NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:itemIdentifier]; - NSButton* b = [NSButton buttonWithTitle:title target:self action:action]; - item.view = b; - return item; + NSCustomTouchBarItem* item = [[NSCustomTouchBarItem alloc] initWithIdentifier:itemIdentifier]; + NSButton* b = [NSButton buttonWithTitle:title target:self action:action]; + item.view = b; + return item; } -- (void) pressKey:(int32_t) key +- (void)pressKey:(int32_t)key { - m_mainWindow->OnKey_MacOS(true, key); - m_mainWindow->OnKey_MacOS(false, key); + m_mainWindow->OnKey_MacOS( true, key ); + m_mainWindow->OnKey_MacOS( false, key ); } -- (void) pressF1 +- (void)pressF1 { - [self pressKey: kVK_F1]; + [self pressKey:kVK_F1]; } -- (void) pressF2 +- (void)pressF2 { - [self pressKey: kVK_F2]; + [self pressKey:kVK_F2]; } -- (void) pressF3 +- (void)pressF3 { - [self pressKey: kVK_F3]; + [self pressKey:kVK_F3]; } -- (void) pressF4 +- (void)pressF4 { - [self pressKey: kVK_F4]; + [self pressKey:kVK_F4]; } -- (void) pressF5 +- (void)pressF5 { - [self pressKey: kVK_F5]; + [self pressKey:kVK_F5]; } -- (void) pressF6 +- (void)pressF6 { - [self pressKey: kVK_F6]; + [self pressKey:kVK_F6]; } -- (void) pressF7 +- (void)pressF7 { - [self pressKey: kVK_F7]; + [self pressKey:kVK_F7]; } -- (void) pressF8 +- (void)pressF8 { - [self pressKey: kVK_F8]; + [self pressKey:kVK_F8]; } -- (void) pressF9 +- (void)pressF9 { - [self pressKey: kVK_F9]; + [self pressKey:kVK_F9]; } -- (void) pressF10 +- (void)pressF10 { - [self pressKey: kVK_F10]; + [self pressKey:kVK_F10]; } -- (void) pressF11 +- (void)pressF11 { - [self pressKey: kVK_F11]; + [self pressKey:kVK_F11]; } -- (void) pressF12 +- (void)pressF12 { - [self pressKey: kVK_F12]; + [self pressKey:kVK_F12]; } @end diff --git a/trinity/UI/Tr2MainWindow.cpp b/trinity/UI/Tr2MainWindow.cpp index d6fc25640..423dc2ce0 100644 --- a/trinity/UI/Tr2MainWindow.cpp +++ b/trinity/UI/Tr2MainWindow.cpp @@ -14,120 +14,119 @@ CcpStdDevStatisticsEntry g_activeFrametimeStdDev; namespace { - const Tr2RenderContextEnum::PixelFormat BACK_BUFFER_FORMAT = Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM; +const Tr2RenderContextEnum::PixelFormat BACK_BUFFER_FORMAT = Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM; - ALResult PopulatePresentParams( Tr2PresentParametersAL& presentParams, Tr2WindowMode::Type windowMode, uint32_t adapter, uint32_t width, uint32_t height, Tr2RenderContextEnum::PresentInterval presentInterval ) +ALResult PopulatePresentParams( Tr2PresentParametersAL& presentParams, Tr2WindowMode::Type windowMode, uint32_t adapter, uint32_t width, uint32_t height, Tr2RenderContextEnum::PresentInterval presentInterval ) +{ + unsigned adapterCount; + CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterCount( adapterCount ) ); + if( adapter >= adapterCount ) { - unsigned adapterCount; - CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterCount( adapterCount ) ); - if( adapter >= adapterCount ) - { - return E_INVALIDARG; - } + return E_INVALIDARG; + } - presentParams.backBufferCount = 1; - presentParams.presentInterval = presentInterval; - presentParams.msaaType = 1; - presentParams.msaaQuality = 0; - presentParams.software = false; - presentParams.windowed = windowMode != Tr2WindowMode::FULL_SCREEN; - presentParams.swapEffect = Tr2RenderContextEnum::SWAP_EFFECT_DISCARD; + presentParams.backBufferCount = 1; + presentParams.presentInterval = presentInterval; + presentParams.msaaType = 1; + presentParams.msaaQuality = 0; + presentParams.software = false; + presentParams.windowed = windowMode != Tr2WindowMode::FULL_SCREEN; + presentParams.swapEffect = Tr2RenderContextEnum::SWAP_EFFECT_DISCARD; - if( windowMode == Tr2WindowMode::FULL_SCREEN ) + if( windowMode == Tr2WindowMode::FULL_SCREEN ) + { + bool found = false; + unsigned modeCount; + CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterModeCount( adapter, BACK_BUFFER_FORMAT, modeCount ) ); + for( unsigned i = 0; i < modeCount; ++i ) { - bool found = false; - unsigned modeCount; - CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterModeCount( adapter, BACK_BUFFER_FORMAT, modeCount ) ); - for( unsigned i = 0; i < modeCount; ++i ) + Tr2DisplayModeInfo info; + CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterMode( adapter, BACK_BUFFER_FORMAT, i, info ) ); + if( info.width == width && info.height == height ) { - Tr2DisplayModeInfo info; - CR_RETURN_HR( Tr2VideoAdapterInfo::GetAdapterMode( adapter, BACK_BUFFER_FORMAT, i, info ) ); - if( info.width == width && info.height == height ) - { - presentParams.mode = info; - found = true; - break; - } - } - if( !found ) - { - return E_INVALIDARG; + presentParams.mode = info; + found = true; + break; } } - else + if( !found ) { - presentParams.mode = Tr2DisplayModeInfo(); - presentParams.mode.format = BACK_BUFFER_FORMAT; - presentParams.mode.width = width; - presentParams.mode.height = height; + return E_INVALIDARG; } - return S_OK; } - - std::string ToString( Tr2WindowMode::Type windowMode ) + else { - switch( windowMode ) - { - case Tr2WindowMode::FULL_SCREEN: - return "full screen"; - case Tr2WindowMode::WINDOWED: - return "windowed"; - case Tr2WindowMode::FIXED_WINDOW: - return "fixed window"; - default: - return "INVALID WINDOW MODE"; - } + presentParams.mode = Tr2DisplayModeInfo(); + presentParams.mode.format = BACK_BUFFER_FORMAT; + presentParams.mode.width = width; + presentParams.mode.height = height; } + return S_OK; +} - std::string ToString( Tr2WindowShowState::Type windowShowState ) +std::string ToString( Tr2WindowMode::Type windowMode ) +{ + switch( windowMode ) { - switch( windowShowState ) - { - case Tr2WindowShowState::NORMAL: - return "normal"; - case Tr2WindowShowState::MAXIMIZED: - return "maximized"; - case Tr2WindowShowState::MINIMIZED: - return "minimized"; - default: - return "INVALID WINDOW SHOW STATE"; - } + case Tr2WindowMode::FULL_SCREEN: + return "full screen"; + case Tr2WindowMode::WINDOWED: + return "windowed"; + case Tr2WindowMode::FIXED_WINDOW: + return "fixed window"; + default: + return "INVALID WINDOW MODE"; } +} + +std::string ToString( Tr2WindowShowState::Type windowShowState ) +{ + switch( windowShowState ) + { + case Tr2WindowShowState::NORMAL: + return "normal"; + case Tr2WindowShowState::MAXIMIZED: + return "maximized"; + case Tr2WindowShowState::MINIMIZED: + return "minimized"; + default: + return "INVALID WINDOW SHOW STATE"; + } +} - std::string ToString( Tr2RenderContextEnum::PresentInterval presentInterval ) +std::string ToString( Tr2RenderContextEnum::PresentInterval presentInterval ) +{ + switch( presentInterval ) { - switch( presentInterval ) - { - case Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE: - return "immediate"; - case Tr2RenderContextEnum::PRESENT_INTERVAL_ONE: - return "one"; - default: - return "INVALID PRESENT INTERVAL"; - } + case Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE: + return "immediate"; + case Tr2RenderContextEnum::PRESENT_INTERVAL_ONE: + return "one"; + default: + return "INVALID PRESENT INTERVAL"; } +} - class SetupActiveFrameTimeStats +class SetupActiveFrameTimeStats +{ +public: + SetupActiveFrameTimeStats() { - public: - - SetupActiveFrameTimeStats() - { - g_activeFrametimeMean.SetName( "Trinity/FrameTime/ActiveMean" ); - CcpStatistics::RegisterDerived( &g_activeFrametimeMean ); + g_activeFrametimeMean.SetName( "Trinity/FrameTime/ActiveMean" ); + CcpStatistics::RegisterDerived( &g_activeFrametimeMean ); - g_activeFrametimeStdDev.SetName( "Trinity/FrameTime/ActiveStdDev" ); - CcpStatistics::RegisterDerived( &g_activeFrametimeStdDev ); - } - }; + g_activeFrametimeStdDev.SetName( "Trinity/FrameTime/ActiveStdDev" ); + CcpStatistics::RegisterDerived( &g_activeFrametimeStdDev ); + } +}; - static SetupActiveFrameTimeStats s_setupActiveFrameTimeStats; +static SetupActiveFrameTimeStats s_setupActiveFrameTimeStats; } -Tr2MainWindowState::State::State() - :windowMode( Tr2WindowMode::FULL_SCREEN ), +Tr2MainWindowState::State::State() : + windowMode( Tr2WindowMode::FULL_SCREEN ), adapter( 0 ), width( 0 ), height( 0 ), @@ -196,10 +195,10 @@ std::string Tr2MainWindowState::ToString() const -Tr2MainWindow::Tr2MainWindow() - :m_hwnd(), +Tr2MainWindow::Tr2MainWindow() : + m_hwnd(), m_isResizing( false ), - m_inSetState( false ) + m_inSetState( false ) { m_minimumSize.width = m_minimumSize.height = 100; BeOS->RegisterForTicks( this, nullptr ); @@ -214,28 +213,28 @@ Tr2MainWindow::~Tr2MainWindow() ALResult Tr2MainWindow::SetState( bool adjustWindow, const Tr2MainWindowState::State& newState ) { - m_inSetState = true; - ON_BLOCK_EXIT( [&]{ m_inSetState = false; } ); - + m_inSetState = true; + ON_BLOCK_EXIT( [&] { m_inSetState = false; } ); + Tr2MainWindowState::State state = newState; SanitizeState( state ); - if( state == m_state ) - { - return S_OK; - } - - if( HasWindow() && gTriDev->DeviceExists() && !m_state.RequiresDeviceReset( state ) ) - { - if( adjustWindow ) - { - AdjustWindow( state ); - } + if( state == m_state ) + { + return S_OK; + } + + if( HasWindow() && gTriDev->DeviceExists() && !m_state.RequiresDeviceReset( state ) ) + { + if( adjustWindow ) + { + AdjustWindow( state ); + } gTriDev->SetThrottling( TriDevice::WINDOW_HIDDEN, state.showState == Tr2WindowShowState::MINIMIZED ); - m_state = state; - m_onWindowStateChange.CallVoid( state.WrapCopy() ); - return S_OK; - } + m_state = state; + m_onWindowStateChange.CallVoid( state.WrapCopy() ); + return S_OK; + } if( gTriDev->DeviceExists() ) { @@ -266,7 +265,7 @@ ALResult Tr2MainWindow::SetState( bool adjustWindow, const Tr2MainWindowState::S #endif #else - else if( adjustWindow ) + else if( adjustWindow ) #endif { AdjustWindow( state ); @@ -290,7 +289,7 @@ ALResult Tr2MainWindow::SetState( bool adjustWindow, const Tr2MainWindowState::S AdjustWindow( state ); } #else - (void)justCreatedWindow; + (void)justCreatedWindow; #endif m_isResizing = false; @@ -304,7 +303,7 @@ ALResult Tr2MainWindow::SetState( bool adjustWindow, const Tr2MainWindowState::S return S_OK; } -ALResult Tr2MainWindow::SetState( const Tr2MainWindowState::State& state ) +ALResult Tr2MainWindow::SetState( const Tr2MainWindowState::State& state ) { return SetState( true, state ); } @@ -355,8 +354,7 @@ std::vector> Tr2MainWindow::GetWindowSizeOptions( std::vector> result; SanitizeAdapter( adapter ); - auto Insert = [&result]( const std::pair& candidate ) - { + auto Insert = [&result]( const std::pair& candidate ) { if( std::find( begin( result ), end( result ), candidate ) == end( result ) ) { result.push_back( candidate ); @@ -539,16 +537,14 @@ Tr2MainWindowStatePtr Tr2MainWindow::GetDefaultState( Tr2WindowMode::Type mode ) switch( mode ) { case Tr2WindowMode::FULL_SCREEN: - case Tr2WindowMode::FIXED_WINDOW: - { + case Tr2WindowMode::FIXED_WINDOW: { Tr2DisplayModeInfo mi; Tr2VideoAdapterInfo::GetAdapterDisplayMode( result.adapter, mi ); result.width = mi.width; result.height = mi.height; break; } - case Tr2WindowMode::WINDOWED: - { + case Tr2WindowMode::WINDOWED: { Tr2DisplayModeInfo mi; Tr2VideoAdapterInfo::GetAdapterDisplayMode( result.adapter, mi ); @@ -571,15 +567,15 @@ Tr2MainWindowStatePtr Tr2MainWindow::GetDefaultState( Tr2WindowMode::Type mode ) void Tr2MainWindow::StoreStateSettings( const Tr2MainWindowState* state ) { - if( state ) - { - m_storedStates[state->m_state.windowMode] = state->m_state; - } + if( state ) + { + m_storedStates[state->m_state.windowMode] = state->m_state; + } } #ifdef __APPLE__ id Tr2MainWindow::GetWindowID() const { - return (id)m_hwnd; + return (id)m_hwnd; } #endif diff --git a/trinity/UI/Tr2MainWindow.h b/trinity/UI/Tr2MainWindow.h index 4528d2d62..87366d326 100644 --- a/trinity/UI/Tr2MainWindow.h +++ b/trinity/UI/Tr2MainWindow.h @@ -12,42 +12,42 @@ BLUE_DECLARE( Tr2MouseCursor ); namespace Tr2WindowMode { - enum Type - { - FULL_SCREEN = 0, - WINDOWED = 1, - FIXED_WINDOW = 2, - - _COUNT, - }; +enum Type +{ + FULL_SCREEN = 0, + WINDOWED = 1, + FIXED_WINDOW = 2, + + _COUNT, +}; } namespace Tr2WindowShowState { - enum Type - { - NORMAL = 0, - MAXIMIZED = 1, - MINIMIZED = 2, - }; +enum Type +{ + NORMAL = 0, + MAXIMIZED = 1, + MINIMIZED = 2, +}; } #ifdef __APPLE__ namespace Tr2ImeState_MacOS { - enum Type - { - DISABLED = 0, - READY = 1, - BLOCKING = 2, - }; +enum Type +{ + DISABLED = 0, + READY = 1, + BLOCKING = 2, +}; } #endif BLUE_CLASS_IMPL( Tr2MainWindowState ); -class Tr2MainWindowState: public IRoot +class Tr2MainWindowState : public IRoot { public: EXPOSE_TO_BLUE(); @@ -130,12 +130,15 @@ class Tr2MainWindow : public IRoot, public IBlueEvents std::vector> GetWindowSizeOptions( uint32_t adapter, Tr2WindowMode::Type windowMode ) const; bool ProcessMessages(); + protected: - void OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) override; + void OnTick( Be::Time realTime, Be::Time simTime, void* cookie ) override; + public: bool IsKeyToggled( uint32_t keyCode ) const; bool IsKeyPressed( uint32_t keyCode ) const; std::string GetKeyName( uint32_t keyCode ) const; + private: ALResult SetState( bool adjustWindow, const Tr2MainWindowState::State& state ); @@ -143,8 +146,9 @@ class Tr2MainWindow : public IRoot, public IBlueEvents void SanitizeFullScreenResolution( Tr2MainWindowState::State& state ) const; void SanitizeWindowedResolution( Tr2MainWindowState::State& state ) const; void SanitizeWindowPosition( Tr2MainWindowState::State& state ) const; - - void StoreStateSettings( const Tr2MainWindowState* state ); + + void StoreStateSettings( const Tr2MainWindowState* state ); + private: struct Size { @@ -168,14 +172,14 @@ class Tr2MainWindow : public IRoot, public IBlueEvents Size GetWindowSize( const Size& clientSize, Tr2WindowMode::Type mode ) const; Size GetClientSize( const Size& windowSize, Tr2WindowMode::Type mode ) const; bool SupportsFullscreen() const; - Size GetLargestWindowSize( uint32_t adapter, Tr2WindowMode::Type mode ) const; - - uintptr_t GetHwnd() const; + Size GetLargestWindowSize( uint32_t adapter, Tr2WindowMode::Type mode ) const; + + uintptr_t GetHwnd() const; Tr2WindowHandle GetOutputWindow() const; Tr2MainWindowState::State m_state; - - Tr2MainWindowState::State m_storedStates[Tr2WindowMode::_COUNT]; + + Tr2MainWindowState::State m_storedStates[Tr2WindowMode::_COUNT]; std::wstring m_title; Tr2MouseCursorPtr m_cursor; @@ -187,6 +191,7 @@ class Tr2MainWindow : public IRoot, public IBlueEvents BlueScriptCallback m_onWindowStateChange; BlueScriptCallback m_onBeforeSwapChainChange; BlueScriptCallback m_onSwapChainChange; + private: BlueScriptCallback m_onMouseMove; BlueScriptCallback m_onMouseDown; @@ -199,6 +204,7 @@ class Tr2MainWindow : public IRoot, public IBlueEvents BlueScriptCallback m_onFocusChange; BlueScriptCallback m_onClose; + private: #ifdef _WIN32 static LRESULT CALLBACK StaticWndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ); @@ -212,36 +218,37 @@ class Tr2MainWindow : public IRoot, public IBlueEvents std::unordered_set m_messageFilter; bool m_hasMessageFilter = true; #elif defined( __APPLE__ ) - id GetWindowID() const; - + id GetWindowID() const; + //IME BlueScriptCallback m_onInsertTextIME_MacOS; BlueScriptCallback m_onSetMarkedTextIME_MacOS; BlueScriptCallback m_onKeyboardLayoutChange_MacOS; + public: - bool OnClose_MacOS(); - void OnWindowStartedResizing_MacOS(); - void OnWindowFnishedResizing_MacOS(); - void OnWindowResized_MacOS(); - void OnWinowMoved_MacOS(); - void OnWindowChangedKey_MacOS( bool isKey ); - void OnWindowDidChangeBackingProperties_MacOS(); - void OnWindowFullscreenChanged_MacOS( bool fullscreen ); + bool OnClose_MacOS(); + void OnWindowStartedResizing_MacOS(); + void OnWindowFnishedResizing_MacOS(); + void OnWindowResized_MacOS(); + void OnWinowMoved_MacOS(); + void OnWindowChangedKey_MacOS( bool isKey ); + void OnWindowDidChangeBackingProperties_MacOS(); + void OnWindowFullscreenChanged_MacOS( bool fullscreen ); void OnWindowOcclusionChanged_MacOS(); - void OnMouseButton_MacOS( int32_t button, bool down, float left, float top ); - void OnMouseMove_MacOS( float left, float top ); - void OnMouseWheel_MacOS( float delta ); + void OnMouseButton_MacOS( int32_t button, bool down, float left, float top ); + void OnMouseMove_MacOS( float left, float top ); + void OnMouseWheel_MacOS( float delta ); + + void OnKey_MacOS( bool isDown, int32_t key, bool repeat = false ); + void OnChar_MacOS( wchar_t charCode ); + + void OnUpdateCursor_MacOS(); - void OnKey_MacOS( bool isDown, int32_t key, bool repeat = false ); - void OnChar_MacOS( wchar_t charCode ); - - void OnUpdateCursor_MacOS(); - //IME void OnInsertTextIME_MacOS( const std::wstring& string ); void OnSetMarkedTextIME_MacOS( const std::wstring& string, uint64_t selectedLocation, uint64_t selectedLength ); - void OnKeyboardLayoutChange_MacOS(); + void OnKeyboardLayoutChange_MacOS(); Tr2ImeState_MacOS::Type m_imeState_MacOS = Tr2ImeState_MacOS::DISABLED; #endif diff --git a/trinity/UI/Tr2MainWindow_Blue.cpp b/trinity/UI/Tr2MainWindow_Blue.cpp index 2061127fb..292ad13ba 100644 --- a/trinity/UI/Tr2MainWindow_Blue.cpp +++ b/trinity/UI/Tr2MainWindow_Blue.cpp @@ -6,65 +6,44 @@ namespace { - Be::VarChooser Tr2WindowModeChooser[] = - { - { - "FULL_SCREEN", - BeCast( Tr2WindowMode::FULL_SCREEN ), - "" - }, - { - "WINDOWED", - BeCast( Tr2WindowMode::WINDOWED ), - "" - }, - { - "FIXED_WINDOW", - BeCast( Tr2WindowMode::FIXED_WINDOW ), - "" - }, - { 0 } - }; - - Be::VarChooser Tr2WindowShowStateChooser[] = - { - { - "NORMAL", - BeCast( Tr2WindowShowState::NORMAL ), - "" - }, - { - "MAXIMIZED", - BeCast( Tr2WindowShowState::MAXIMIZED ), - "" - }, - { - "MINIMIZED", - BeCast( Tr2WindowShowState::MINIMIZED ), - "" - }, - { 0 } - }; +Be::VarChooser Tr2WindowModeChooser[] = { + { "FULL_SCREEN", + BeCast( Tr2WindowMode::FULL_SCREEN ), + "" }, + { "WINDOWED", + BeCast( Tr2WindowMode::WINDOWED ), + "" }, + { "FIXED_WINDOW", + BeCast( Tr2WindowMode::FIXED_WINDOW ), + "" }, + { 0 } +}; + +Be::VarChooser Tr2WindowShowStateChooser[] = { + { "NORMAL", + BeCast( Tr2WindowShowState::NORMAL ), + "" }, + { "MAXIMIZED", + BeCast( Tr2WindowShowState::MAXIMIZED ), + "" }, + { "MINIMIZED", + BeCast( Tr2WindowShowState::MINIMIZED ), + "" }, + { 0 } +}; #if __APPLE__ - Be::VarChooser Tr2ImeStateChooser_MacOS[] = - { - { - "DISABLED", - BeCast( Tr2ImeState_MacOS::DISABLED ), - "" - }, - { - "READY", - BeCast( Tr2ImeState_MacOS::READY ), - "" - }, - { - "BLOCKING", - BeCast( Tr2ImeState_MacOS::BLOCKING ), - "" - }, - { 0 } - }; +Be::VarChooser Tr2ImeStateChooser_MacOS[] = { + { "DISABLED", + BeCast( Tr2ImeState_MacOS::DISABLED ), + "" }, + { "READY", + BeCast( Tr2ImeState_MacOS::READY ), + "" }, + { "BLOCKING", + BeCast( Tr2ImeState_MacOS::BLOCKING ), + "" }, + { 0 } +}; #endif } @@ -77,25 +56,24 @@ BLUE_REGISTER_ENUM_EX( "Tr2ImeState_MacOS", Tr2ImeState_MacOS::Type, Tr2ImeState BLUE_DEFINE( Tr2MainWindowState ); -const Be::ClassInfo* Tr2MainWindowState::ExposeToBlue() -{ +const Be::ClassInfo* Tr2MainWindowState::ExposeToBlue(){ EXPOSURE_BEGIN( Tr2MainWindowState, "" ) MAP_INTERFACE( Tr2MainWindowState ) - MAP_ATTRIBUTE( "windowMode", m_state.windowMode, "Window state, one of trinity.Tr2WindowState", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "adapter", m_state.adapter, "Adapter index", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "width", m_state.width, "Window client width", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "height", m_state.height, "Window client height", Be::READWRITE | Be::PERSIST ) - //MAP_ATTRIBUTE( "backBufferWidth", m_state.backBufferWidth, "Back buffer width", Be::READWRITE | Be::PERSIST ) - //MAP_ATTRIBUTE( "backBufferHeight", m_state.backBufferHeight, "Back buffer height", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "presentInterval", m_state.presentInterval, "Present interval, one of trinity.PRESENT_INTERVAL", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "windowMode", m_state.windowMode, "Window state, one of trinity.Tr2WindowState", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "adapter", m_state.adapter, "Adapter index", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "width", m_state.width, "Window client width", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "height", m_state.height, "Window client height", Be::READWRITE | Be::PERSIST ) + //MAP_ATTRIBUTE( "backBufferWidth", m_state.backBufferWidth, "Back buffer width", Be::READWRITE | Be::PERSIST ) + //MAP_ATTRIBUTE( "backBufferHeight", m_state.backBufferHeight, "Back buffer height", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "presentInterval", m_state.presentInterval, "Present interval, one of trinity.PRESENT_INTERVAL", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "left", m_state.left, "Window left position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "top", m_state.top, "Window top position", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "showState", m_state.showState, "Window show (frame) state, one of trinity.Tr2WindowShowState", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "top", m_state.top, "Window top position", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "showState", m_state.showState, "Window show (frame) state, one of trinity.Tr2WindowShowState", Be::READWRITE | Be::PERSIST ) - MAP_METHOD_AND_WRAP( "__str__", ToString, "" ) - EXPOSURE_END() + MAP_METHOD_AND_WRAP( "__str__", ToString, "" ) + EXPOSURE_END() } @@ -112,69 +90,59 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() SetStateScript, "Assigns new state for the window. This may trigger a device change, window resizing, etc.\n" "The first time it is called, the OS window is created.\n" - ":param state: new window state" - ) + ":param state: new window state" ) MAP_METHOD_AND_WRAP( "GetWindowState", GetStateScript, - "Returns a current window state." - ) + "Returns a current window state." ) MAP_METHOD_AND_WRAP( "SanitizeState", SanitizeStateScript, "Sanitizes state attributes, based on the current HW, etc. Changes the parameters in place.\n" - ":param state: state to sanitize" - ) + ":param state: state to sanitize" ) MAP_METHOD_AND_WRAP( "GetDefaultState", GetDefaultState, "Returns the default window state for a given window mode.\n" - ":param mode: window mode, one of trinity.Tr2WindowMode" - ) + ":param mode: window mode, one of trinity.Tr2WindowMode" ) MAP_METHOD_AND_WRAP( "HasFocus", HasFocus, - "Returns True iff the window has focus (is active)." - ) + "Returns True iff the window has focus (is active)." ) MAP_METHOD_AND_WRAP( "IsActive", HasFocus, - ":jessica-deprecated: use HasFocus" - ) + ":jessica-deprecated: use HasFocus" ) - MAP_METHOD_AND_WRAP( - "SetMinimumSize", - SetMinimumSize, + MAP_METHOD_AND_WRAP( + "SetMinimumSize", + SetMinimumSize, "Assigns minimum client size for the window. Should ideally be called before SetWindwoState as\n" "this function does not resize the window if it is smalleer than the minimum size.\n" ":param width: minimum window client width\n" - ":param height: minimum window client height" - ) + ":param height: minimum window client height" ) MAP_METHOD_AND_WRAP( "GetWindowTitle", GetWindowTitle, - "Returns current window title" - ) + "Returns current window title" ) MAP_METHOD_AND_WRAP( "SetWindowTitle", SetWindowTitle, "Sets new window title.\n" - ":param title: new window title" - ) + ":param title: new window title" ) MAP_METHOD_AND_WRAP( "GetBackBufferFormat", GetBackBufferFormat, "Returns format of the back buffer for the given adapter.\n" - ":param adapter: video adapter index" - ) + ":param adapter: video adapter index" ) MAP_METHOD_AND_WRAP( "GetWindowSizeOptions", @@ -183,16 +151,14 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() "this list would correspond to available display resolutions, for window mode it would also contain\n" "a size that covers the entire desktop.\n" ":param adapter: video adapter index\n" - ":param windowMode: window mode (see trinity.Tr2WindowMode)" - ) + ":param windowMode: window mode (see trinity.Tr2WindowMode)" ) - MAP_METHOD_AND_WRAP( - "StoreStateSettings", - StoreStateSettings, - "Store settings for the given mode. They may be used when a window switches to this mode using\n" - "means other than Python (enter full screen menu on macOS for example).\n" - ":param state: window state to store" - ) + MAP_METHOD_AND_WRAP( + "StoreStateSettings", + StoreStateSettings, + "Store settings for the given mode. They may be used when a window switches to this mode using\n" + "means other than Python (enter full screen menu on macOS for example).\n" + ":param state: window state to store" ) MAP_PROPERTY_READONLY( "width", GetBackBufferWidth, "Current window back buffer width" ) MAP_PROPERTY_READONLY( "height", GetBackBufferHeight, "Current window back buffer height" ) @@ -201,28 +167,22 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() MAP_METHOD_AND_WRAP( "IsHidden", IsMinimized, - "Returns True if the window is minimized" - ) + "Returns True if the window is minimized" ) MAP_PROPERTY( "mouseCursor", GetMouseCursor, SetMouseCursor, "Cursor to use when mouse is over the window" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetCursorPos", GetCursorPos, - "Returns current mouse cursor position in window client area coordinates" - ) - MAP_METHOD_AND_WRAP - ( + "Returns current mouse cursor position in window client area coordinates" ) + MAP_METHOD_AND_WRAP( "SetCursorPos", SetCursorPos, "Set cursor position\n" ":param x: horizontal cursor coordinate (window client space)\n" - ":param y: vertical cursor coordinate (window client space)\n" - ) + ":param y: vertical cursor coordinate (window client space)\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "ClipCursor", ClipCursor, "Confines the cursor to a rectangular area on the screen. If a subsequent cursor position\n" @@ -232,45 +192,34 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() ":param left: left rect coordinate (window client space)\n" ":param top: top rect coordinate (window client space)\n" ":param right: right rect coordinate (window client space)\n" - ":param bottom: bottom rect coordinate (window client space)\n" - ) + ":param bottom: bottom rect coordinate (window client space)\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "UnclipCursor", UnclipCursor, - "Lifts the confinement set on the cursor with ClipCursor." - ) + "Lifts the confinement set on the cursor with ClipCursor." ) - MAP_METHOD_AND_WRAP - ( - "Key", - IsKeyPressed, + MAP_METHOD_AND_WRAP( + "Key", + IsKeyPressed, "Returns True if the specified key is pressed\n" - ":param key: key code" - ) - MAP_METHOD_AND_WRAP - ( - "IsKeyToggled", - IsKeyToggled, + ":param key: key code" ) + MAP_METHOD_AND_WRAP( + "IsKeyToggled", + IsKeyToggled, "Returns True if the specified key is toggled on\n" - ":param key: key code" - ) - MAP_METHOD_AND_WRAP - ( + ":param key: key code" ) + MAP_METHOD_AND_WRAP( "GetKeyNameText", GetKeyName, "Returns the name of the secified key\n" - ":param key: virtual key code\n" - ) + ":param key: virtual key code\n" ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "ProcessMessages", ProcessMessages, "Processes all accumulared OS messages. Returns false if quit message was processed.\n" - "Should not be used when running exefile as the processing there happens in blue." - ) + "Should not be used when running exefile as the processing there happens in blue." ) MAP_ATTRIBUTE( @@ -278,24 +227,21 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() m_onWindowStateChange, "Called whenever window state changes. This includes, for example, window movement.\n" "Called with (state: trinity.Tr2MainWindowState) parameter", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onBeforeSwapChainChange", m_onBeforeSwapChainChange, "Called before window state change triggers swap chain or device change.\n" "Called with (state: trinity.Tr2MainWindowState) parameter", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onSwapChainChange", m_onSwapChainChange, "Called after swap chain / device change.\n" "Called with (state: trinity.Tr2MainWindowState) parameter", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( @@ -303,8 +249,7 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() m_onMouseMove, "Called when mouse is moved over the window.\n" "Called with (left: int, top: int) parameters", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onMouseDown", @@ -312,8 +257,7 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() "Called when mouse button is pressed.\n" "Called with (button: int, left: int, top: int) parameters. Button parameter is 0 for left button,\n" "1 for right, 2 for middle and >2 for other mouse buttons.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onMouseUp", @@ -321,40 +265,35 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() "Called when mouse button is depressed.\n" "Called with (button: int, left: int, top: int) parameters. Button parameter is 0 for left button,\n" "1 for right, 2 for middle and >2 for other mouse buttons.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onMouseWheel", m_onMouseWheel, "Called when mouse wheel is rotated.\n" "Called with (delta: int) parameters.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onKeyDown", m_onKeyDown, "Called when a key is pressed on the keyboard.\n" "Called with (key: int, flags: int) parameters.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onKeyUp", m_onKeyUp, "Called when a key is released on the keyboard.\n" "Called with (key: int, flags: int) parameters.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onChar", m_onChar, "Called when key press results in a typed character, or when a \"dead\" character is registered.\n" "Called with (key: int, flags: int, isDead: boolean) parameters.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( @@ -362,24 +301,20 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() m_onFocusChange, "Called when the window looses or receives focus.\n" "Called with (inFocus: boolean) parameters.", - Be::READWRITE - ) + Be::READWRITE ) MAP_ATTRIBUTE( "onClose", m_onClose, "Called when the window is requested to close. Called with no parameters and is supposed to return a boolean value.\n" "If return value of the callback is True, the window will close, otherwise it stays open.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_PROPERTY_READONLY( "hwnd", GetHwnd, "Returns managed window handle") - MAP_METHOD_AND_WRAP - ( - "GetHwndAsLong", - GetHwnd, - "Returns managed window handle" - ) + MAP_PROPERTY_READONLY( "hwnd", GetHwnd, "Returns managed window handle" ) + MAP_METHOD_AND_WRAP( + "GetHwndAsLong", + GetHwnd, + "Returns managed window handle" ) #if _WIN32 MAP_ATTRIBUTE( @@ -389,58 +324,45 @@ const Be::ClassInfo* Tr2MainWindow::ExposeToBlue() "Called with (msg: int, wParam: int, lParam: int) parameters, and is supposed to return a tuple\n" "(retValue: int, handled: boolean). If handled is True, the default window proc is not called and\n" "window procedure returns retValue for handled message. Otherwise it calls default window proc.", - Be::READWRITE - ) + Be::READWRITE ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "GetWindowsMessageFilter", GetWindowsMessageFilter, "Returns message filter for onWindowsMessage callback. Returns a pair (enabled, messages). If enabled is False,\n" - "onWindowsMessage is called for all messages, otherwise only for messages in the set \"messages\"." - ) + "onWindowsMessage is called for all messages, otherwise only for messages in the set \"messages\"." ) - MAP_METHOD_AND_WRAP - ( + MAP_METHOD_AND_WRAP( "SetWindowsMessageFilter", SetWindowsMessageFilter, "Changes message filter for onWindowsMessage callback.\n" ":param enabled: if False, onWindowsMessage is called for all messages, otherwise only for messages in the set \"messages\".\n" - ":param messages: set of message types, for which onWindowMessage needs to be called (if \"enabled\" is True)" - ) + ":param messages: set of message types, for which onWindowMessage needs to be called (if \"enabled\" is True)" ) #elif __APPLE__ - - MAP_ATTRIBUTE - ( - "onInsertTextIME_MacOS", - m_onInsertTextIME_MacOS, - "This callback prompts insertion of text by the IME.", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "onSetMarkedTextIME_MacOS", - m_onSetMarkedTextIME_MacOS, - "This callback prompts replacement of the selected text by the IME", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "imeState_MacOS", - m_imeState_MacOS, - "Controls the ime state on macOS. Blocking state indicates active IME, and will block normal key events.", - Be::READWRITE - ) - - MAP_ATTRIBUTE - ( - "onKeyboardLayoutChange_MacOS", - m_onKeyboardLayoutChange_MacOS, - "This callback gets called macOS when the user changes their keyboard layout.", - Be::READWRITE - ) + + MAP_ATTRIBUTE( + "onInsertTextIME_MacOS", + m_onInsertTextIME_MacOS, + "This callback prompts insertion of text by the IME.", + Be::READWRITE ) + + MAP_ATTRIBUTE( + "onSetMarkedTextIME_MacOS", + m_onSetMarkedTextIME_MacOS, + "This callback prompts replacement of the selected text by the IME", + Be::READWRITE ) + + MAP_ATTRIBUTE( + "imeState_MacOS", + m_imeState_MacOS, + "Controls the ime state on macOS. Blocking state indicates active IME, and will block normal key events.", + Be::READWRITE ) + + MAP_ATTRIBUTE( + "onKeyboardLayoutChange_MacOS", + m_onKeyboardLayoutChange_MacOS, + "This callback gets called macOS when the user changes their keyboard layout.", + Be::READWRITE ) #endif EXPOSURE_END() diff --git a/trinity/UI/Tr2MainWindow_MacOS.mm b/trinity/UI/Tr2MainWindow_MacOS.mm index 0594d3c6d..e6a74ae5f 100644 --- a/trinity/UI/Tr2MainWindow_MacOS.mm +++ b/trinity/UI/Tr2MainWindow_MacOS.mm @@ -18,23 +18,23 @@ CCP_STATS_DECLARED_ELSEWHERE( frameTime ); -@interface CcpApplication : NSApplication +@interface CcpApplication : NSApplication - (void)clipCursor:(NSRect)rect; - (void)unclipCursor; @end -@interface CcpWindow : NSWindow +@interface CcpWindow : NSWindow - (void)initialize:(Tr2MainWindow*)mainWindow; - (BOOL)isFullscreen; - (BOOL)isInFullscreenTransition; @end -@interface CcpContentView : NSView +@interface CcpContentView : NSView { - Tr2MainWindow* m_mainWindow; - NSTrackingArea* m_trackingArea; - TouchBar* m_touchBar; + Tr2MainWindow* m_mainWindow; + NSTrackingArea* m_trackingArea; + TouchBar* m_touchBar; } - (instancetype)initWithWindow:(Tr2MainWindow*)initWindow; - (void)updateDrawableSize; @@ -51,88 +51,84 @@ - (void)textInputContextKeyboardSelectionDidChange:(NSNotification*)notification void CreateMenuBar() { - NSString* appName = [NSRunningApplication currentApplication].localizedName; - - NSMenu* bar = [[NSMenu alloc] init]; - [NSApp setMainMenu:bar]; - - NSMenu* appMenu = [[NSMenu alloc] initWithTitle:appName]; - [[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""] setSubmenu:appMenu]; - - NSMenu* servicesMenu = [[NSMenu alloc] init]; - [NSApp setServicesMenu:servicesMenu]; - [[appMenu addItemWithTitle:@"Services" - action:NULL - keyEquivalent:@""] setSubmenu:servicesMenu]; - - [appMenu addItem:[NSMenuItem separatorItem]]; - [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] - action:@selector(hide:) - keyEquivalent:@""]; - [[appMenu addItemWithTitle:@"Hide Others" - action:@selector(hideOtherApplications:) - keyEquivalent:@""] - setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand]; - [appMenu addItemWithTitle:@"Show All" - action:@selector(unhideAllApplications:) - keyEquivalent:@""]; - [appMenu addItem:[NSMenuItem separatorItem]]; - [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName] - action:@selector(terminate:) - keyEquivalent:@""]; + NSString* appName = [NSRunningApplication currentApplication].localizedName; + + NSMenu* bar = [[NSMenu alloc] init]; + [NSApp setMainMenu:bar]; + + NSMenu* appMenu = [[NSMenu alloc] initWithTitle:appName]; + [[bar addItemWithTitle:@"" action:NULL keyEquivalent:@""] setSubmenu:appMenu]; + + NSMenu* servicesMenu = [[NSMenu alloc] init]; + [NSApp setServicesMenu:servicesMenu]; + [[appMenu addItemWithTitle:@"Services" action:NULL keyEquivalent:@""] setSubmenu:servicesMenu]; + + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName] + action:@selector( hide: ) + keyEquivalent:@""]; + [[appMenu addItemWithTitle:@"Hide Others" action:@selector( hideOtherApplications: ) keyEquivalent:@""] + setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand]; + [appMenu addItemWithTitle:@"Show All" action:@selector( unhideAllApplications: ) keyEquivalent:@""]; + [appMenu addItem:[NSMenuItem separatorItem]]; + [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName] + action:@selector( terminate: ) + keyEquivalent:@""]; } NSWindowStyleMask GetWindowStyleMask( Tr2WindowMode::Type windowMode ) { - if( windowMode == Tr2WindowMode::WINDOWED ) - { - return NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; - } - else - { - return NSWindowStyleMaskBorderless; - } + if( windowMode == Tr2WindowMode::WINDOWED ) + { + return NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | + NSWindowStyleMaskResizable; + } + else + { + return NSWindowStyleMaskBorderless; + } } void SetWindowTitle( NSWindow* window, const std::wstring& title ) { - NSString* nsTitle = [[NSString alloc] initWithBytes: title.c_str() - length: sizeof(wchar_t) * title.length() - encoding: NSUTF32LittleEndianStringEncoding]; - [window setTitle:nsTitle]; + NSString* nsTitle = [[NSString alloc] initWithBytes:title.c_str() + length:sizeof( wchar_t ) * title.length() + encoding:NSUTF32LittleEndianStringEncoding]; + [window setTitle:nsTitle]; } NSUInteger KeyCodeToModifierFlag( uint16_t key ) { - switch( key ) - { - case kVK_Shift: - case kVK_RightShift: - return NSEventModifierFlagShift; - case kVK_Control: - case kVK_RightControl: - return NSEventModifierFlagControl; - case kVK_Option: - case kVK_RightOption: - return NSEventModifierFlagOption; - case kVK_Command: - case kVK_RightCommand: - return NSEventModifierFlagCommand; - case kVK_CapsLock: - return NSEventModifierFlagCapsLock; - } - return 0; + switch( key ) + { + case kVK_Shift: + case kVK_RightShift: + return NSEventModifierFlagShift; + case kVK_Control: + case kVK_RightControl: + return NSEventModifierFlagControl; + case kVK_Option: + case kVK_RightOption: + return NSEventModifierFlagOption; + case kVK_Command: + case kVK_RightCommand: + return NSEventModifierFlagCommand; + case kVK_CapsLock: + return NSEventModifierFlagCapsLock; + } + return 0; } NSDictionary* GetFullScreenModeOptions() { - return [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, - [NSNumber numberWithInt:NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar], NSFullScreenModeApplicationPresentationOptions, - nil]; - + return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], + NSFullScreenModeAllScreens, + [NSNumber numberWithInt:NSApplicationPresentationHideDock | + NSApplicationPresentationHideMenuBar], + NSFullScreenModeApplicationPresentationOptions, + nil]; } - + void HandleThermalState() { if( gTriDev ) @@ -161,121 +157,131 @@ void HandleThermalState() bool DisableScreensaver() { IOPMAssertionID assertionID; - IOReturn success = IOPMAssertionCreateWithName( - kIOPMAssertionTypeNoDisplaySleep, - kIOPMAssertionLevelOn, - static_cast( @"Prevent sleep" ), - &assertionID ); + IOReturn success = IOPMAssertionCreateWithName( kIOPMAssertionTypeNoDisplaySleep, + kIOPMAssertionLevelOn, + static_cast( @"Prevent sleep" ), + &assertionID ); return success == kIOReturnSuccess; } void FixUpRedScreen() { - if( auto mainWindow = [NSApp mainWindow] ) - { - [mainWindow setDelegate:nil]; - [mainWindow close]; - @autoreleasepool - { - while( true ) - { - NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - if (event == nil) - { - break; - } - [NSApp sendEvent:event]; - } - } - } + if( auto mainWindow = [NSApp mainWindow] ) + { + [mainWindow setDelegate:nil]; + [mainWindow close]; + @autoreleasepool + { + while( true ) + { + NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if( event == nil ) + { + break; + } + [NSApp sendEvent:event]; + } + } + } } void InitializeApplication() { - if( s_applicationInitialized ) - { - return; - } + if( s_applicationInitialized ) + { + return; + } - [CcpApplication sharedApplication]; - [NSApp setDelegate:[CcpApplication sharedApplication]]; + [CcpApplication sharedApplication]; + [NSApp setDelegate:[CcpApplication sharedApplication]]; - [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"ApplePressAndHoldEnabled":@NO}]; + [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"ApplePressAndHoldEnabled": @NO}]; - if (![[NSRunningApplication currentApplication] isFinishedLaunching]) - { - [NSApp run]; - } - - BeOS->RegisterIndispensableTerminationStep( &FixUpRedScreen ); + if( ![[NSRunningApplication currentApplication] isFinishedLaunching] ) + { + [NSApp run]; + } - HandleThermalState(); - [NSNotificationCenter.defaultCenter addObserverForName:@"NSProcessInfoThermalStateDidChangeNotification" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - HandleThermalState(); - }]; - - DisableScreensaver(); + BeOS->RegisterIndispensableTerminationStep( &FixUpRedScreen ); - if (@available(macOS 10.15, *)) - { - [NSNotificationCenter.defaultCenter addObserverForName:GCControllerDidConnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - GCController* controller = note.object; - CCP_LOG("Game controller connected: %s", controller.vendorName.UTF8String); - }]; + HandleThermalState(); + [NSNotificationCenter.defaultCenter addObserverForName:@"NSProcessInfoThermalStateDidChangeNotification" + object:nil + queue:nil + usingBlock:^( NSNotification* _Nonnull note ) { + HandleThermalState(); + }]; + + DisableScreensaver(); - [NSNotificationCenter.defaultCenter addObserverForName:GCControllerDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { - GCController* controller = note.object; - CCP_LOG("Game controller disconnected: %s", controller.vendorName.UTF8String); - }]; - } + if( @available( macOS 10.15, * ) ) + { + [NSNotificationCenter.defaultCenter + addObserverForName:GCControllerDidConnectNotification + object:nil + queue:nil + usingBlock:^( NSNotification* _Nonnull note ) { + GCController* controller = note.object; + CCP_LOG( "Game controller connected: %s", controller.vendorName.UTF8String ); + }]; + + [NSNotificationCenter.defaultCenter + addObserverForName:GCControllerDidDisconnectNotification + object:nil + queue:nil + usingBlock:^( NSNotification* _Nonnull note ) { + GCController* controller = note.object; + CCP_LOG( "Game controller disconnected: %s", controller.vendorName.UTF8String ); + }]; + } - s_applicationInitialized = true; + s_applicationInitialized = true; } NSScreen* GetAdapterScreen( uint32_t adapter ) { - void* monitor; - if( FAILED( Tr2VideoAdapterInfo::GetAdapterMonitor( adapter , monitor ) ) ) - { - return nullptr; - } - auto displayID = CGDirectDisplayID( reinterpret_cast( monitor ) ); + void* monitor; + if( FAILED( Tr2VideoAdapterInfo::GetAdapterMonitor( adapter, monitor ) ) ) + { + return nullptr; + } + auto displayID = CGDirectDisplayID( reinterpret_cast( monitor ) ); CCP_LOG( "Looking for screen with display ID %u for adapter %u", unsigned( displayID ), unsigned( adapter ) ); - for( id screen in [NSScreen screens] ) - { - CGDirectDisplayID did = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + for( id screen in [NSScreen screens] ) + { + CGDirectDisplayID did = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; CCP_LOG( "Found screen with display ID %u", unsigned( did ) ); - if( did == displayID ) - { - return screen; - } - } + if( did == displayID ) + { + return screen; + } + } CCP_LOGWARN( "Could not find screen with display ID %u. Falling back to the main screen", unsigned( displayID ) ); - return [NSScreen mainScreen]; + return [NSScreen mainScreen]; } uint32_t GetScreenAdapter( NSScreen* screen ) { - CGDirectDisplayID did = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; - uint32_t count = 0; - Tr2VideoAdapterInfo::GetAdapterCount( count ); - for( uint32_t i = 0; i < count; ++i ) - { - void* monitor; - if( FAILED( Tr2VideoAdapterInfo::GetAdapterMonitor( i , monitor ) ) ) - { - continue; - } - auto displayID = CGDirectDisplayID( reinterpret_cast( monitor ) ); - if( did == displayID ) - { - return i; - } - } - return 0; + CGDirectDisplayID did = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + uint32_t count = 0; + Tr2VideoAdapterInfo::GetAdapterCount( count ); + for( uint32_t i = 0; i < count; ++i ) + { + void* monitor; + if( FAILED( Tr2VideoAdapterInfo::GetAdapterMonitor( i, monitor ) ) ) + { + continue; + } + auto displayID = CGDirectDisplayID( reinterpret_cast( monitor ) ); + if( did == displayID ) + { + return i; + } + } + return 0; } // Helper class for emulating ClipCursor functionality on macOS. For clipping a mouse cursor (i.e. @@ -289,9 +295,10 @@ uint32_t GetScreenAdapter( NSScreen* screen ) public: CursorClipper( const NSRect& clipScreenRect ); ~CursorClipper(); - + NSRect GetRect() const; NSEvent* ProcessEvent( NSEvent* event ); + private: struct WarpRec { @@ -299,17 +306,16 @@ uint32_t GetScreenAdapter( NSScreen* screen ) CGFloat deltaY; NSTimeInterval timestamp; }; - + bool IsMouseEvent( NSEvent* event ) const; NSPoint AdjustMouseDeltas( const NSPoint& delta, NSTimeInterval timestamp ); - + std::vector m_warps; NSPoint m_mouseLocation; NSRect m_clipRect; }; -CursorClipper::CursorClipper( const NSRect& clipScreenRect ) -: m_clipRect( clipScreenRect ) +CursorClipper::CursorClipper( const NSRect& clipScreenRect ) : m_clipRect( clipScreenRect ) { m_mouseLocation = [NSEvent mouseLocation]; CGAssociateMouseAndMouseCursorPosition( false ); @@ -331,19 +337,24 @@ uint32_t GetScreenAdapter( NSScreen* screen ) { return event; } - + auto delta = AdjustMouseDeltas( NSMakePoint( event.deltaX, -event.deltaY ), event.timestamp ); m_mouseLocation.x += delta.x; m_mouseLocation.y += delta.y; - m_mouseLocation.x = std::min( std::max( m_mouseLocation.x, m_clipRect.origin.x ), m_clipRect.origin.x + m_clipRect.size.width ); - m_mouseLocation.y = std::min( std::max( m_mouseLocation.y, m_clipRect.origin.y ), m_clipRect.origin.y + m_clipRect.size.height ); + m_mouseLocation.x = + std::min( std::max( m_mouseLocation.x, m_clipRect.origin.x ), m_clipRect.origin.x + m_clipRect.size.width ); + m_mouseLocation.y = + std::min( std::max( m_mouseLocation.y, m_clipRect.origin.y ), m_clipRect.origin.y + m_clipRect.size.height ); auto currentLocation = [NSEvent mouseLocation]; - - CGWarpMouseCursorPosition( CGPointMake( m_mouseLocation.x, NSHeight( NSScreen.screens[0].frame ) - m_mouseLocation.y ) ); - - WarpRec warpRec = { m_mouseLocation.x - currentLocation.x, m_mouseLocation.y - currentLocation.y, [NSProcessInfo processInfo].systemUptime }; + + CGWarpMouseCursorPosition( + CGPointMake( m_mouseLocation.x, NSHeight( NSScreen.screens[0].frame ) - m_mouseLocation.y ) ); + + WarpRec warpRec = { m_mouseLocation.x - currentLocation.x, + m_mouseLocation.y - currentLocation.y, + [NSProcessInfo processInfo].systemUptime }; m_warps.push_back( warpRec ); auto location = [event.window convertPointFromScreen:m_mouseLocation]; @@ -372,8 +383,8 @@ uint32_t GetScreenAdapter( NSScreen* screen ) auto modifiedX = deltaX - rec.deltaX; auto modifiedY = deltaY - rec.deltaY; // fence in the deltas so they don't change signs! - deltaX = deltaX == 0.0f || signbit(deltaX) != signbit(modifiedX) ? 0.0f : modifiedX; - deltaY = deltaY == 0.0f || signbit(deltaY) != signbit(modifiedY) ? 0.0f : modifiedY; + deltaX = deltaX == 0.0f || signbit( deltaX ) != signbit( modifiedX ) ? 0.0f : modifiedX; + deltaY = deltaY == 0.0f || signbit( deltaY ) != signbit( modifiedY ) ? 0.0f : modifiedY; ++consumed; } else @@ -419,7 +430,7 @@ - (void)clipCursor:(NSRect)rect delete m_cursorClipper; m_cursorClipper = nullptr; } - + m_cursorClipper = new CursorClipper( rect ); } @@ -432,62 +443,63 @@ - (void)unclipCursor } } -- (void)sendEvent:(NSEvent *)event +- (void)sendEvent:(NSEvent*)event { if( m_cursorClipper ) { event = m_cursorClipper->ProcessEvent( event ); } - - if( [event type] == NSEventTypeKeyUp && ( [event modifierFlags] & NSEventModifierFlagCommand ) ) - { - [[self keyWindow] sendEvent:event]; - } - else if( [event type] == NSEventTypeKeyDown && event.keyCode == kVK_Tab && ( [event modifierFlags] & NSEventModifierFlagControl ) ) + + if( [event type] == NSEventTypeKeyUp && ( [event modifierFlags] & NSEventModifierFlagCommand ) ) + { + [[self keyWindow] sendEvent:event]; + } + else if( [event type] == NSEventTypeKeyDown && event.keyCode == kVK_Tab && + ( [event modifierFlags] & NSEventModifierFlagControl ) ) { [self.keyWindow.contentView keyDown:event]; [super sendEvent:event]; } - else - { - [super sendEvent:event]; - } + else + { + [super sendEvent:event]; + } } -- (void)applicationWillResignActive:(NSNotification *)notification +- (void)applicationWillResignActive:(NSNotification*)notification { [self unclipCursor]; } -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender { - s_quitRequested = true; - return NSTerminateCancel; + s_quitRequested = true; + return NSTerminateCancel; } -- (void)applicationWillFinishLaunching:(NSNotification *)notification +- (void)applicationWillFinishLaunching:(NSNotification*)notification { - CreateMenuBar(); + CreateMenuBar(); } -- (void)applicationDidFinishLaunching:(NSNotification *)notification +- (void)applicationDidFinishLaunching:(NSNotification*)notification { - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - [NSApp stop:nil]; + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp stop:nil]; - @autoreleasepool - { - NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined - location:NSMakePoint( 0, 0 ) - modifierFlags:0 - timestamp:0 - windowNumber:0 - context:nil - subtype:0 - data1:0 - data2:0]; - [NSApp postEvent:event atStart:YES]; - } + @autoreleasepool + { + NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined + location:NSMakePoint( 0, 0 ) + modifierFlags:0 + timestamp:0 + windowNumber:0 + context:nil + subtype:0 + data1:0 + data2:0]; + [NSApp postEvent:event atStart:YES]; + } } @end @@ -495,48 +507,48 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification @implementation CcpWindow { - Tr2MainWindow* m_mainWindow; - BOOL m_isFullscreen; - BOOL m_inFullscreenTransition; + Tr2MainWindow* m_mainWindow; + BOOL m_isFullscreen; + BOOL m_inFullscreenTransition; } - (BOOL)canBecomeKeyWindow { - return YES; + return YES; } - (BOOL)canBecomeMainWindow { - return YES; + return YES; } - (void)initialize:(Tr2MainWindow*)mainWindow { - m_mainWindow = mainWindow; - m_isFullscreen = NO; + m_mainWindow = mainWindow; + m_isFullscreen = NO; } - (BOOL)isFullscreen { - return m_isFullscreen; + return m_isFullscreen; } - (BOOL)isInFullscreenTransition { - return m_inFullscreenTransition; + return m_inFullscreenTransition; } - (BOOL)windowShouldClose:(id)sender { - return m_mainWindow->OnClose_MacOS() ? YES : NO; + return m_mainWindow->OnClose_MacOS() ? YES : NO; } -- (void)windowWillStartLiveResize:(NSNotification *)notification +- (void)windowWillStartLiveResize:(NSNotification*)notification { - m_mainWindow->OnWindowStartedResizing_MacOS(); + m_mainWindow->OnWindowStartedResizing_MacOS(); } -- (void)windowDidEndLiveResize:(NSNotification *)notification +- (void)windowDidEndLiveResize:(NSNotification*)notification { if( !m_inFullscreenTransition ) { @@ -544,7 +556,7 @@ - (void)windowDidEndLiveResize:(NSNotification *)notification } } -- (void)windowDidResize:(NSNotification *)notification +- (void)windowDidResize:(NSNotification*)notification { if( !m_inFullscreenTransition ) { @@ -552,7 +564,7 @@ - (void)windowDidResize:(NSNotification *)notification } } -- (void)windowDidMove:(NSNotification *)notification +- (void)windowDidMove:(NSNotification*)notification { if( !m_inFullscreenTransition ) { @@ -560,17 +572,17 @@ - (void)windowDidMove:(NSNotification *)notification } } -- (void)windowDidMiniaturize:(NSNotification *)notification +- (void)windowDidMiniaturize:(NSNotification*)notification { m_mainWindow->OnWindowResized_MacOS(); } -- (void)windowDidDeminiaturize:(NSNotification *)notification +- (void)windowDidDeminiaturize:(NSNotification*)notification { m_mainWindow->OnWindowResized_MacOS(); } -- (void)windowDidBecomeKey:(NSNotification *)notification +- (void)windowDidBecomeKey:(NSNotification*)notification { KeyboardHelpers::PlatformKeyChanged( kVK_Shift, false ); KeyboardHelpers::PlatformKeyChanged( kVK_RightShift, false ); @@ -583,228 +595,234 @@ - (void)windowDidBecomeKey:(NSNotification *)notification auto flags = CGEventSourceFlagsState( kCGEventSourceStateHIDSystemState ); KeyboardHelpers::PlatformKeyChanged( kVK_CapsLock, ( kCGEventFlagMaskAlphaShift & flags ) != 0 ); - m_mainWindow->OnWindowChangedKey_MacOS( true ); + m_mainWindow->OnWindowChangedKey_MacOS( true ); } -- (void)windowDidResignKey:(NSNotification *)notification +- (void)windowDidResignKey:(NSNotification*)notification { - m_mainWindow->OnWindowChangedKey_MacOS( false ); + m_mainWindow->OnWindowChangedKey_MacOS( false ); } -- (void)windowDidChangeBackingProperties:(NSNotification *)notification +- (void)windowDidChangeBackingProperties:(NSNotification*)notification { - m_mainWindow->OnWindowDidChangeBackingProperties_MacOS(); + m_mainWindow->OnWindowDidChangeBackingProperties_MacOS(); } -- (void)windowWillExitFullScreen:(NSNotification *)notification +- (void)windowWillExitFullScreen:(NSNotification*)notification { - m_inFullscreenTransition = YES; + m_inFullscreenTransition = YES; } -- (void)windowWillEnterFullScreen:(NSNotification *)notification +- (void)windowWillEnterFullScreen:(NSNotification*)notification { - m_inFullscreenTransition = YES; + m_inFullscreenTransition = YES; } -- (void)windowDidEnterFullScreen:(NSNotification *)notification +- (void)windowDidEnterFullScreen:(NSNotification*)notification { - m_isFullscreen = YES; - m_inFullscreenTransition = NO; - m_mainWindow->OnWindowFullscreenChanged_MacOS( true ); + m_isFullscreen = YES; + m_inFullscreenTransition = NO; + m_mainWindow->OnWindowFullscreenChanged_MacOS( true ); } -- (void)windowDidExitFullScreen:(NSNotification *)notification +- (void)windowDidExitFullScreen:(NSNotification*)notification { - m_isFullscreen = NO; - m_inFullscreenTransition = NO; - m_mainWindow->OnWindowFullscreenChanged_MacOS( false ); + m_isFullscreen = NO; + m_inFullscreenTransition = NO; + m_mainWindow->OnWindowFullscreenChanged_MacOS( false ); } -- (void)windowDidFailToEnterFullScreen:(NSWindow *)window +- (void)windowDidFailToEnterFullScreen:(NSWindow*)window { - m_inFullscreenTransition = NO; + m_inFullscreenTransition = NO; } -- (void)windowDidFailToExitFullScreen:(NSWindow *)window +- (void)windowDidFailToExitFullScreen:(NSWindow*)window { - m_inFullscreenTransition = NO; + m_inFullscreenTransition = NO; } -- (void)windowDidChangeOcclusionState:(NSNotification *)notification +- (void)windowDidChangeOcclusionState:(NSNotification*)notification { m_mainWindow->OnWindowOcclusionChanged_MacOS(); } -- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions +- (NSApplicationPresentationOptions)window:(NSWindow*)window + willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions { - return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | + NSApplicationPresentationHideMenuBar; } @end @implementation CcpContentView -static const NSRange kEmptyRange = {NSNotFound, 0}; +static const NSRange kEmptyRange = { NSNotFound, 0 }; - (instancetype)initWithWindow:(Tr2MainWindow*)initWindow { - self = [super init]; - if (self != nil) - { - m_mainWindow = initWindow; - } - self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; - m_trackingArea = nil; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(textInputContextKeyboardSelectionDidChange:) - name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" - object:nil]; - return self; + self = [super init]; + if( self != nil ) + { + m_mainWindow = initWindow; + } + self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + m_trackingArea = nil; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector( textInputContextKeyboardSelectionDidChange: ) + name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" + object:nil]; + return self; } -- (BOOL)acceptsFirstMouse:(NSEvent *)event +- (BOOL)acceptsFirstMouse:(NSEvent*)event { return YES; } -- (CALayer *)makeBackingLayer +- (CALayer*)makeBackingLayer { - return [CAMetalLayer layer]; + return [CAMetalLayer layer]; } - (BOOL)wantsLayer { - return YES; + return YES; } - (BOOL)canBecomeKeyView { - return YES; + return YES; } - (BOOL)acceptsFirstResponder { - return YES; + return YES; } - (void)viewDidChangeBackingProperties { - [super viewDidChangeBackingProperties]; - [self updateDrawableSize]; + [super viewDidChangeBackingProperties]; + [self updateDrawableSize]; } - (void)setFrame:(NSRect)frame { - [super setFrame:frame]; - [self updateDrawableSize]; + [super setFrame:frame]; + [self updateDrawableSize]; } - (void)updateDrawableSize { - if( !self.window ) - { - return; - } - CGFloat scale = self.window.backingScaleFactor; - CGSize drawableSize = self.bounds.size; - drawableSize.width *= scale; - drawableSize.height *= scale; - self.layer.contentsScale = scale; - ((CAMetalLayer*)self.layer).drawableSize = drawableSize; + if( !self.window ) + { + return; + } + CGFloat scale = self.window.backingScaleFactor; + CGSize drawableSize = self.bounds.size; + drawableSize.width *= scale; + drawableSize.height *= scale; + self.layer.contentsScale = scale; + ( (CAMetalLayer*)self.layer ).drawableSize = drawableSize; } - (void)textInputContextKeyboardSelectionDidChange:(NSNotification*)notification { - m_mainWindow->OnKeyboardLayoutChange_MacOS(); + m_mainWindow->OnKeyboardLayoutChange_MacOS(); } - (NSPoint)eventViewPos:(NSEvent*)event { - return [self viewPos:[event locationInWindow]]; + return [self viewPos:[event locationInWindow]]; } - (NSPoint)viewPos:(NSPoint)point { - auto location = [self convertPoint:point fromView:nil]; - auto height = [self frame].size.height; - location.y = height - location.y; - return location; + auto location = [self convertPoint:point fromView:nil]; + auto height = [self frame].size.height; + location.y = height - location.y; + return location; } - (void)updateTrackingAreas { - [super updateTrackingAreas]; - if( m_trackingArea ) - { - [self removeTrackingArea: m_trackingArea]; - } - m_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:(NSTrackingCursorUpdate | NSTrackingMouseMoved | NSTrackingActiveAlways | NSTrackingInVisibleRect) owner:self userInfo:nil]; - [self addTrackingArea:m_trackingArea]; + [super updateTrackingAreas]; + if( m_trackingArea ) + { + [self removeTrackingArea:m_trackingArea]; + } + m_trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] + options:( NSTrackingCursorUpdate | NSTrackingMouseMoved | + NSTrackingActiveAlways | NSTrackingInVisibleRect ) + owner:self + userInfo:nil]; + [self addTrackingArea:m_trackingArea]; } -- (void)cursorUpdate:(NSEvent *)event +- (void)cursorUpdate:(NSEvent*)event { - m_mainWindow->OnUpdateCursor_MacOS(); + m_mainWindow->OnUpdateCursor_MacOS(); } -- (void)mouseDown:(NSEvent *)event +- (void)mouseDown:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( 0, true, location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( 0, true, location.x, location.y ); } -- (void)mouseUp:(NSEvent *)event +- (void)mouseUp:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( 0, false, location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( 0, false, location.x, location.y ); } -- (void)rightMouseDown:(NSEvent *)event +- (void)rightMouseDown:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( 1, true, location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( 1, true, location.x, location.y ); } -- (void)rightMouseUp:(NSEvent *)event +- (void)rightMouseUp:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( 1, false, location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( 1, false, location.x, location.y ); } -- (void)otherMouseDown:(NSEvent *)event +- (void)otherMouseDown:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( int32_t( [event buttonNumber] ), true, location.x , location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( int32_t( [event buttonNumber] ), true, location.x, location.y ); } -- (void)otherMouseUp:(NSEvent *)event +- (void)otherMouseUp:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseButton_MacOS( int32_t( [event buttonNumber] ), false, location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseButton_MacOS( int32_t( [event buttonNumber] ), false, location.x, location.y ); } -- (void)mouseMoved:(NSEvent *)event +- (void)mouseMoved:(NSEvent*)event { - auto location = [self eventViewPos:event]; - m_mainWindow->OnMouseMove_MacOS( location.x, location.y ); + auto location = [self eventViewPos:event]; + m_mainWindow->OnMouseMove_MacOS( location.x, location.y ); } -- (void)mouseDragged:(NSEvent *)event +- (void)mouseDragged:(NSEvent*)event { - [self mouseMoved:event]; + [self mouseMoved:event]; } -- (void)rightMouseDragged:(NSEvent *)event +- (void)rightMouseDragged:(NSEvent*)event { - [self mouseMoved:event]; + [self mouseMoved:event]; } -- (void)otherMouseDragged:(NSEvent *)event +- (void)otherMouseDragged:(NSEvent*)event { - [self mouseMoved:event]; + [self mouseMoved:event]; } -- (void)scrollWheel:(NSEvent *)event +- (void)scrollWheel:(NSEvent*)event { auto dy = event.scrollingDeltaY; if( !event.hasPreciseScrollingDeltas ) @@ -823,94 +841,94 @@ - (void)scrollWheel:(NSEvent *)event { dy *= 6; } - m_mainWindow->OnMouseWheel_MacOS( float( dy ) ); -} - -- (void)keyDown:(NSEvent *)event -{ - auto modifierFlags = int32_t( [event modifierFlags] ); - - KeyboardHelpers::PlatformKey modifiers[] = { kVK_Shift, kVK_Control, kVK_Option, kVK_Command }; - for( auto m : modifiers ) - { - auto down = ( modifierFlags & KeyCodeToModifierFlag( m ) ) != 0; - if( KeyboardHelpers::IsPlatformKeyPressed( m ) != down ) - { - KeyboardHelpers::PlatformKeyChanged( m, down ); - m_mainWindow->OnKey_MacOS( down, m ); - } - } - - int32_t keyCode = event.keyCode; - if (![event isARepeat]) - { - KeyboardHelpers::PlatformKeyChanged( keyCode, true ); - } - if( m_mainWindow->m_imeState_MacOS != Tr2ImeState_MacOS::BLOCKING ) - { - m_mainWindow->OnKey_MacOS( true, keyCode, event.isARepeat ); - } - const NSUInteger LEFT_OPT = 524576; - if( ( event.modifierFlags & NSEventModifierFlagCommand ) == 0 ) - { - if( ( event.modifierFlags & LEFT_OPT ) != LEFT_OPT ) - { - if( m_mainWindow->m_imeState_MacOS == Tr2ImeState_MacOS::DISABLED ) - { - [self insertText:event.characters]; - } - else - { - [self interpretKeyEvents:@[event]]; - } - } - } -} - -- (void)keyUp:(NSEvent *)event -{ - int32_t keyCode = event.keyCode; - KeyboardHelpers::PlatformKeyChanged( keyCode, false ); - m_mainWindow->OnKey_MacOS( false, keyCode ); + m_mainWindow->OnMouseWheel_MacOS( float( dy ) ); +} + +- (void)keyDown:(NSEvent*)event +{ + auto modifierFlags = int32_t( [event modifierFlags] ); + + KeyboardHelpers::PlatformKey modifiers[] = { kVK_Shift, kVK_Control, kVK_Option, kVK_Command }; + for( auto m : modifiers ) + { + auto down = ( modifierFlags & KeyCodeToModifierFlag( m ) ) != 0; + if( KeyboardHelpers::IsPlatformKeyPressed( m ) != down ) + { + KeyboardHelpers::PlatformKeyChanged( m, down ); + m_mainWindow->OnKey_MacOS( down, m ); + } + } + + int32_t keyCode = event.keyCode; + if( ![event isARepeat] ) + { + KeyboardHelpers::PlatformKeyChanged( keyCode, true ); + } + if( m_mainWindow->m_imeState_MacOS != Tr2ImeState_MacOS::BLOCKING ) + { + m_mainWindow->OnKey_MacOS( true, keyCode, event.isARepeat ); + } + const NSUInteger LEFT_OPT = 524576; + if( ( event.modifierFlags & NSEventModifierFlagCommand ) == 0 ) + { + if( ( event.modifierFlags & LEFT_OPT ) != LEFT_OPT ) + { + if( m_mainWindow->m_imeState_MacOS == Tr2ImeState_MacOS::DISABLED ) + { + [self insertText:event.characters]; + } + else + { + [self interpretKeyEvents:@[event]]; + } + } + } +} + +- (void)keyUp:(NSEvent*)event +{ + int32_t keyCode = event.keyCode; + KeyboardHelpers::PlatformKeyChanged( keyCode, false ); + m_mainWindow->OnKey_MacOS( false, keyCode ); } - (void)insertText:(id)string { - NSStringEncoding encoding; - if( sizeof( wchar_t ) == 2 ) - { - encoding = NSUTF16LittleEndianStringEncoding; - } - else - { - encoding = NSUTF32LittleEndianStringEncoding; - } - NSData* data = [string dataUsingEncoding:encoding]; - int32_t length = int32_t( [data length] ) / sizeof( wchar_t ); - auto characters = reinterpret_cast( [data bytes] ); - for( int32_t i = 0; i < length; ++i ) - { - m_mainWindow->OnChar_MacOS( characters[i] ); - } -} - -- (void)flagsChanged:(NSEvent *)event -{ - auto key = int32_t( [event keyCode] ); - auto modifierFlags = int32_t( [event modifierFlags] ); - if (key == 0 && modifierFlags == 256) - { - // We just got focus after losing it for a while and no modifier flags are active currently. - KeyboardHelpers::PlatformKeyChanged( kVK_Shift, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_RightShift, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_Control, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_RightControl, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_Option, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_RightOption, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_Command, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_RightCommand, false ); - KeyboardHelpers::PlatformKeyChanged( kVK_CapsLock, false ); - } + NSStringEncoding encoding; + if( sizeof( wchar_t ) == 2 ) + { + encoding = NSUTF16LittleEndianStringEncoding; + } + else + { + encoding = NSUTF32LittleEndianStringEncoding; + } + NSData* data = [string dataUsingEncoding:encoding]; + int32_t length = int32_t( [data length] ) / sizeof( wchar_t ); + auto characters = reinterpret_cast( [data bytes] ); + for( int32_t i = 0; i < length; ++i ) + { + m_mainWindow->OnChar_MacOS( characters[i] ); + } +} + +- (void)flagsChanged:(NSEvent*)event +{ + auto key = int32_t( [event keyCode] ); + auto modifierFlags = int32_t( [event modifierFlags] ); + if( key == 0 && modifierFlags == 256 ) + { + // We just got focus after losing it for a while and no modifier flags are active currently. + KeyboardHelpers::PlatformKeyChanged( kVK_Shift, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_RightShift, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_Control, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_RightControl, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_Option, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_RightOption, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_Command, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_RightCommand, false ); + KeyboardHelpers::PlatformKeyChanged( kVK_CapsLock, false ); + } if( key != kVK_Function ) { KeyboardHelpers::PlatformKeyChanged( key, ( modifierFlags & KeyCodeToModifierFlag( key ) ) != 0 ); @@ -922,25 +940,27 @@ - (void)flagsChanged:(NSEvent *)event void Tr2MainWindow::OnInsertTextIME_MacOS( const std::wstring& string ) { - m_onInsertTextIME_MacOS.CallVoid( string ); + m_onInsertTextIME_MacOS.CallVoid( string ); } -void Tr2MainWindow::OnSetMarkedTextIME_MacOS( const std::wstring& string, uint64_t selectedLocation, uint64_t selectedLength) +void Tr2MainWindow::OnSetMarkedTextIME_MacOS( const std::wstring& string, + uint64_t selectedLocation, + uint64_t selectedLength ) { - m_onSetMarkedTextIME_MacOS.CallVoid( string, selectedLocation, selectedLength ); + m_onSetMarkedTextIME_MacOS.CallVoid( string, selectedLocation, selectedLength ); } void Tr2MainWindow::OnKeyboardLayoutChange_MacOS() { - m_onKeyboardLayoutChange_MacOS.CallVoid(); + m_onKeyboardLayoutChange_MacOS.CallVoid(); } std::wstring NSStringToWString( id string ) { - NSString* str = [string isKindOfClass: [NSAttributedString class]] ? [string string] : string; - NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding( NSUTF32LittleEndianStringEncoding ); - NSData* pSData = [str dataUsingEncoding: pEncode]; - return std::wstring ( static_cast( [pSData bytes] ), [pSData length] / sizeof( wchar_t ) ); + NSString* str = [string isKindOfClass:[NSAttributedString class]] ? [string string] : string; + NSStringEncoding pEncode = CFStringConvertEncodingToNSStringEncoding( NSUTF32LittleEndianStringEncoding ); + NSData* pSData = [str dataUsingEncoding:pEncode]; + return std::wstring( static_cast( [pSData bytes] ), [pSData length] / sizeof( wchar_t ) ); } @@ -948,8 +968,9 @@ - (void)flagsChanged:(NSEvent *)event // NSResponder // ---------------------------------------------------------------- -- (void) insertNewline: (id) sender { - [self insertText: @"\r\n"]; +- (void)insertNewline:(id)sender +{ + [self insertText:@"\r\n"]; } // ---------------------------------------------------------------- @@ -959,134 +980,135 @@ - (void) insertNewline: (id) sender { // require proper implementation to get the IME working. The rest // are stubbed out because they are required by the framework -- (void) doCommandBySelector: (SEL) selector +- (void)doCommandBySelector:(SEL)selector { - if( selector == @selector(insertNewline:) ) + if( selector == @selector( insertNewline: ) ) { - [self insertText: @"\r\n"]; + [self insertText:@"\r\n"]; } - else if( selector == @selector(deleteBackward:) ) + else if( selector == @selector( deleteBackward: ) ) { m_mainWindow->OnChar_MacOS( VK_BACK ); } } -- (void) unmarkText +- (void)unmarkText { } -- (BOOL) hasMarkedText +- (BOOL)hasMarkedText { - return false; + return false; } -- (NSRange) markedRange +- (NSRange)markedRange { - return NSMakeRange(NSNotFound, 1); + return NSMakeRange( NSNotFound, 1 ); } -- (NSRange) selectedRange +- (NSRange)selectedRange { - return kEmptyRange; + return kEmptyRange; } -- (void) insertText: (id) string replacementRange: (NSRange) replacementRange +- (void)insertText:(id)string replacementRange:(NSRange)replacementRange { m_mainWindow->OnInsertTextIME_MacOS( NSStringToWString( string ) ); } -- (NSUInteger) characterIndexForPoint: (NSPoint) thePoint +- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { - return 0; + return 0; } -- (NSArray *) validAttributesForMarkedText +- (NSArray*)validAttributesForMarkedText { - return @[]; + return @[]; } -- (void) setMarkedText: (id) string selectedRange: (NSRange) selectedRange replacementRange: (NSRange) replacementRange +- (void)setMarkedText:(id)string selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { m_mainWindow->OnSetMarkedTextIME_MacOS( NSStringToWString( string ), selectedRange.location, selectedRange.length ); } -- (NSAttributedString *) attributedSubstringForProposedRange: (NSRange) aRange actualRange: (NSRangePointer) actualRange +- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { return nullptr; } -- (NSRect) firstRectForCharacterRange: (NSRange) aRange actualRange: (NSRangePointer) actualRange +- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange { return NSZeroRect; } -- (NSAttributedString *) attributedString +- (NSAttributedString*)attributedString { return nullptr; } // /ime -- (NSTouchBar *) makeTouchBar { - m_touchBar = [[TouchBar alloc] initWithWindow:m_mainWindow]; - return [m_touchBar makeFunctionKeyTouchBar]; +- (NSTouchBar*)makeTouchBar +{ + m_touchBar = [[TouchBar alloc] initWithWindow:m_mainWindow]; + return [m_touchBar makeFunctionKeyTouchBar]; } @end void Tr2MainWindow::SetWindowTitle( const wchar_t* title ) { - m_title = title; - if( HasWindow() ) - { - ::SetWindowTitle( (NSWindow*)GetWindowID(), m_title ); - } + m_title = title; + if( HasWindow() ) + { + ::SetWindowTitle( (NSWindow*)GetWindowID(), m_title ); + } } bool Tr2MainWindow::HasFocus() const { - if( !HasWindow() ) - { - return false; - } - auto window = (NSWindow*)GetWindowID(); - return [window isKeyWindow] && [NSApp isActive]; + if( !HasWindow() ) + { + return false; + } + auto window = (NSWindow*)GetWindowID(); + return [window isKeyWindow] && [NSApp isActive]; } bool Tr2MainWindow::HasWindow() const { - return m_hwnd != 0; + return m_hwnd != 0; } void Tr2MainWindow::CreateOSWindow( Tr2MainWindowState::State& state ) { - if( HasWindow() ) - { - return; - } - InitializeApplication(); + if( HasWindow() ) + { + return; + } + InitializeApplication(); + + auto style = GetWindowStyleMask( state.windowMode ); + NSRect frame = NSMakeRect( state.left, state.top, state.width, state.height ); - auto style = GetWindowStyleMask( state.windowMode ); - NSRect frame = NSMakeRect(state.left, state.top, state.width, state.height); + CcpWindow* window = [[CcpWindow alloc] initWithContentRect:frame + styleMask:style + backing:NSBackingStoreBuffered + defer:NO + screen:nil]; + [window initialize:this]; + ::SetWindowTitle( window, m_title ); - CcpWindow* window = [[CcpWindow alloc] initWithContentRect:frame - styleMask:style - backing:NSBackingStoreBuffered - defer:NO - screen:nil - ]; - [window initialize:this]; - ::SetWindowTitle( window, m_title ); + [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorManaged | + NSWindowCollectionBehaviorFullScreenDisallowsTiling]; - [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorFullScreenDisallowsTiling]; + auto view = [[CcpContentView alloc] initWithWindow:this]; + [window setContentView:view]; - auto view = [[CcpContentView alloc] initWithWindow:this]; - [window setContentView:view]; + [window makeKeyAndOrderFront:nil]; + [window makeFirstResponder:[window contentView]]; - [window makeKeyAndOrderFront:nil]; - [window makeFirstResponder:[window contentView]]; - if( state.windowMode == Tr2WindowMode::WINDOWED ) { window.level = NSNormalWindowLevel; @@ -1096,72 +1118,72 @@ - (NSTouchBar *) makeTouchBar { window.level = NSMainMenuWindowLevel + 1; } - if( state.windowMode == Tr2WindowMode::FULL_SCREEN ) - { - auto screen = GetAdapterScreen( state.adapter ); - if( screen != [window screen] ) - { - [window setFrameOrigin:screen.visibleFrame.origin]; - } - [window setFrame:screen.visibleFrame display:YES]; + if( state.windowMode == Tr2WindowMode::FULL_SCREEN ) + { + auto screen = GetAdapterScreen( state.adapter ); + if( screen != [window screen] ) + { + [window setFrameOrigin:screen.visibleFrame.origin]; + } + [window setFrame:screen.visibleFrame display:YES]; - auto factor = [window screen].backingScaleFactor; - [window setContentMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; + auto factor = [window screen].backingScaleFactor; + [window setContentMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; [window setDelegate:window]; - [window toggleFullScreen:nullptr]; - } - else - { - // this call will move the window to correct display - [window setFrameOrigin:frame.origin]; - // after the window is on the correct screen, we can set its size - auto factor = [window screen].backingScaleFactor; - [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; - [window setContentMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; - // and this call will finally set window position to what we requested. isn't that fun - [window setFrameOrigin:frame.origin]; - - if( state.showState == Tr2WindowShowState::MAXIMIZED ) - { - [window zoom:window]; - } + [window toggleFullScreen:nullptr]; + } + else + { + // this call will move the window to correct display + [window setFrameOrigin:frame.origin]; + // after the window is on the correct screen, we can set its size + auto factor = [window screen].backingScaleFactor; + [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; + [window setContentMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; + // and this call will finally set window position to what we requested. isn't that fun + [window setFrameOrigin:frame.origin]; + + if( state.showState == Tr2WindowShowState::MAXIMIZED ) + { + [window zoom:window]; + } - auto size = [window contentView].frame.size; - state.width = uint32_t( size.width * factor ); - state.height = uint32_t( size.height * factor ); - [window setDelegate:window]; - } + auto size = [window contentView].frame.size; + state.width = uint32_t( size.width * factor ); + state.height = uint32_t( size.height * factor ); + [window setDelegate:window]; + } - [NSApp activateIgnoringOtherApps:YES]; + [NSApp activateIgnoringOtherApps:YES]; - // need to flush events, so that the window is fully created after this call - ProcessMessages(); + // need to flush events, so that the window is fully created after this call + ProcessMessages(); - // somehow Cocoa messes up drawable size after attaching the view, so we need to update it here - [view updateDrawableSize]; + // somehow Cocoa messes up drawable size after attaching the view, so we need to update it here + [view updateDrawableSize]; - m_hwnd = window; + m_hwnd = window; } void Tr2MainWindow::DestroyOSWindow() { - if( !HasWindow() ) - { - return; - } - auto window = (NSWindow*)GetWindowID(); - [window close]; - m_hwnd = 0; + if( !HasWindow() ) + { + return; + } + auto window = (NSWindow*)GetWindowID(); + [window close]; + m_hwnd = 0; } void Tr2MainWindow::AdjustWindow( Tr2MainWindowState::State& state ) { - if( !HasWindow() ) - { - return; - } - auto window = (CcpWindow*)GetWindowID(); + if( !HasWindow() ) + { + return; + } + auto window = (CcpWindow*)GetWindowID(); if( state.windowMode == Tr2WindowMode::WINDOWED ) { @@ -1172,113 +1194,113 @@ - (NSTouchBar *) makeTouchBar { window.level = NSMainMenuWindowLevel + 1; } - bool wasFullscreen = [window isFullscreen];//m_state.windowMode == Tr2WindowMode::FULL_SCREEN; - bool wantsFullscreen = state.windowMode == Tr2WindowMode::FULL_SCREEN; - if( wantsFullscreen != wasFullscreen ) - { - if( wantsFullscreen ) - { - auto screen = GetAdapterScreen( state.adapter ); - if( screen != [window screen] ) - { - [window setFrameOrigin:screen.visibleFrame.origin]; - } - [window setStyleMask:GetWindowStyleMask( state.windowMode )]; - [window setFrame:screen.visibleFrame display:YES]; - [window toggleFullScreen:nil]; - } - else - { - [window toggleFullScreen:nil]; - // We need to flush all events here because either the client or OS gets very confused - // when changing monitors - ProcessMessages(); - [window setStyleMask:GetWindowStyleMask( state.windowMode )]; - - // Move the window to the specified position first, then deal with size because - // here it may change the monitor and we need its backing scale - [window setFrameOrigin:NSMakePoint(state.left, state.top)]; - - auto factor = [window screen].backingScaleFactor; - [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; - auto size = [window contentView].frame.size; - state.width = uint32_t( size.width * factor ); - state.height = uint32_t( size.height * factor ); - - // Move the window again because its size may have changed - [window setFrameOrigin:NSMakePoint(state.left, state.top)]; - } - [window makeKeyWindow]; - [window makeFirstResponder:[window contentView]]; - } - else if( wantsFullscreen && state.adapter != m_state.adapter ) - { - [window toggleFullScreen:nil]; - while( [window isFullscreen]) - { - ProcessMessages(); - } - auto screen = GetAdapterScreen( state.adapter ); - [window setFrameOrigin:screen.visibleFrame.origin]; - [window setFrame:screen.visibleFrame display:YES]; - [window toggleFullScreen:nil]; - } - else if( !wantsFullscreen ) - { - auto newStyle = GetWindowStyleMask( state.windowMode ); - if( [window styleMask] != newStyle ) - { - [window setStyleMask:newStyle]; - } - [window setFrameOrigin:NSMakePoint(state.left, state.top)]; - auto factor = [window screen].backingScaleFactor; - [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; - [window setFrameOrigin:NSMakePoint(state.left, state.top)]; - } + bool wasFullscreen = [window isFullscreen]; //m_state.windowMode == Tr2WindowMode::FULL_SCREEN; + bool wantsFullscreen = state.windowMode == Tr2WindowMode::FULL_SCREEN; + if( wantsFullscreen != wasFullscreen ) + { + if( wantsFullscreen ) + { + auto screen = GetAdapterScreen( state.adapter ); + if( screen != [window screen] ) + { + [window setFrameOrigin:screen.visibleFrame.origin]; + } + [window setStyleMask:GetWindowStyleMask( state.windowMode )]; + [window setFrame:screen.visibleFrame display:YES]; + [window toggleFullScreen:nil]; + } + else + { + [window toggleFullScreen:nil]; + // We need to flush all events here because either the client or OS gets very confused + // when changing monitors + ProcessMessages(); + [window setStyleMask:GetWindowStyleMask( state.windowMode )]; + + // Move the window to the specified position first, then deal with size because + // here it may change the monitor and we need its backing scale + [window setFrameOrigin:NSMakePoint( state.left, state.top )]; + + auto factor = [window screen].backingScaleFactor; + [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; + auto size = [window contentView].frame.size; + state.width = uint32_t( size.width * factor ); + state.height = uint32_t( size.height * factor ); + + // Move the window again because its size may have changed + [window setFrameOrigin:NSMakePoint( state.left, state.top )]; + } + [window makeKeyWindow]; + [window makeFirstResponder:[window contentView]]; + } + else if( wantsFullscreen && state.adapter != m_state.adapter ) + { + [window toggleFullScreen:nil]; + while( [window isFullscreen] ) + { + ProcessMessages(); + } + auto screen = GetAdapterScreen( state.adapter ); + [window setFrameOrigin:screen.visibleFrame.origin]; + [window setFrame:screen.visibleFrame display:YES]; + [window toggleFullScreen:nil]; + } + else if( !wantsFullscreen ) + { + auto newStyle = GetWindowStyleMask( state.windowMode ); + if( [window styleMask] != newStyle ) + { + [window setStyleMask:newStyle]; + } + [window setFrameOrigin:NSMakePoint( state.left, state.top )]; + auto factor = [window screen].backingScaleFactor; + [window setContentSize:NSMakeSize( state.width / factor, state.height / factor )]; + [window setFrameOrigin:NSMakePoint( state.left, state.top )]; + } } Tr2MainWindow::Rect Tr2MainWindow::GetDesktopRect() const { - NSArray *screenArray = [NSScreen screens]; - uint32_t screenCount = uint32_t( [screenArray count] ); + NSArray* screenArray = [NSScreen screens]; + uint32_t screenCount = uint32_t( [screenArray count] ); - NSRect desktop = NSZeroRect; + NSRect desktop = NSZeroRect; - for( uint32_t index = 0; index < screenCount; index++ ) - { - NSScreen *screen = [screenArray objectAtIndex: index]; - NSRect screenRect = [screen visibleFrame]; - desktop = NSUnionRect(desktop, screenRect); - } + for( uint32_t index = 0; index < screenCount; index++ ) + { + NSScreen* screen = [screenArray objectAtIndex:index]; + NSRect screenRect = [screen visibleFrame]; + desktop = NSUnionRect( desktop, screenRect ); + } - return { - int32_t( desktop.origin.x ), - int32_t( desktop.origin.y ), - int32_t( desktop.origin.x + desktop.size.width ), - int32_t( desktop.origin.y + desktop.size.height ) - }; + return { int32_t( desktop.origin.x ), + int32_t( desktop.origin.y ), + int32_t( desktop.origin.x + desktop.size.width ), + int32_t( desktop.origin.y + desktop.size.height ) }; } Tr2MainWindow::Rect Tr2MainWindow::GetMonitorRect( uint32_t adapter ) const { - return { 0, 0, 100, 100 }; + return { 0, 0, 100, 100 }; } Tr2MainWindow::Size Tr2MainWindow::GetWindowSize( const Size& clientSize, Tr2WindowMode::Type mode ) const { - auto size = [NSWindow frameRectForContentRect:NSMakeRect(0, 0, clientSize.width, clientSize.height) styleMask:GetWindowStyleMask(mode)]; - return { uint32_t( size.size.width ), uint32_t( size.size.height ) }; + auto size = [NSWindow frameRectForContentRect:NSMakeRect( 0, 0, clientSize.width, clientSize.height ) + styleMask:GetWindowStyleMask( mode )]; + return { uint32_t( size.size.width ), uint32_t( size.size.height ) }; } Tr2MainWindow::Size Tr2MainWindow::GetClientSize( const Size& windowSize, Tr2WindowMode::Type mode ) const { - auto size = [NSWindow contentRectForFrameRect:NSMakeRect(0, 0, windowSize.width, windowSize.height) styleMask:GetWindowStyleMask(mode)]; - return { uint32_t( size.size.width ), uint32_t( size.size.height ) }; + auto size = [NSWindow contentRectForFrameRect:NSMakeRect( 0, 0, windowSize.width, windowSize.height ) + styleMask:GetWindowStyleMask( mode )]; + return { uint32_t( size.size.width ), uint32_t( size.size.height ) }; } bool Tr2MainWindow::SupportsFullscreen() const { - return true; + return true; } void Tr2MainWindow::ClipCursor( int32_t left, int32_t top, int32_t right, int32_t bottom ) @@ -1289,20 +1311,20 @@ - (NSTouchBar *) makeTouchBar { } id delegate = [NSApp delegate]; - if( ![delegate respondsToSelector:@selector(clipCursor:)] ) + if( ![delegate respondsToSelector:@selector( clipCursor: )] ) { return; } auto window = (NSWindow*)GetWindowID(); auto content = window.contentView.frame; - + auto l = CGFloat( left ) / m_state.width * content.size.width; auto t = content.size.height - CGFloat( top ) / m_state.height * content.size.height; auto r = CGFloat( right ) / m_state.width * content.size.width; auto b = content.size.height - CGFloat( bottom ) / m_state.height * content.size.height; - - auto rect = [window convertRectToScreen:NSMakeRect( l, b, r - l, t - b)]; + + auto rect = [window convertRectToScreen:NSMakeRect( l, b, r - l, t - b )]; [(CcpApplication*)delegate clipCursor:rect]; } @@ -1310,7 +1332,7 @@ - (NSTouchBar *) makeTouchBar { void Tr2MainWindow::UnclipCursor() { id delegate = [NSApp delegate]; - if( ![delegate respondsToSelector:@selector(unclipCursor)] ) + if( ![delegate respondsToSelector:@selector( unclipCursor )] ) { return; } @@ -1320,458 +1342,465 @@ - (NSTouchBar *) makeTouchBar { void Tr2MainWindow::SetCursorPos( int32_t x, int32_t y ) { - if( !HasWindow() ) - { - return; - } - auto window = (NSWindow*)GetWindowID(); - float sx = float( x ); - float sy = float( y ); - auto content = [[window contentView] frame]; - if( m_state.width ) - { - sx = sx / m_state.width * content.size.width; - } - if( m_state.height ) - { - sy = sy / m_state.height * content.size.height; - } - sy = content.size.height - sy; - NSPoint location = [window convertPointToScreen:NSMakePoint( sx, sy )]; - auto height = CGDisplayBounds(CGMainDisplayID()).size.height; - CGWarpMouseCursorPosition( CGPointMake( location.x, height - location.y ) ); + if( !HasWindow() ) + { + return; + } + auto window = (NSWindow*)GetWindowID(); + float sx = float( x ); + float sy = float( y ); + auto content = [[window contentView] frame]; + if( m_state.width ) + { + sx = sx / m_state.width * content.size.width; + } + if( m_state.height ) + { + sy = sy / m_state.height * content.size.height; + } + sy = content.size.height - sy; + NSPoint location = [window convertPointToScreen:NSMakePoint( sx, sy )]; + auto height = CGDisplayBounds( CGMainDisplayID() ).size.height; + CGWarpMouseCursorPosition( CGPointMake( location.x, height - location.y ) ); } std::pair Tr2MainWindow::GetCursorPos() const { - if( !HasWindow() ) - { - return { 0, 0 }; - } - auto window = (NSWindow*)GetWindowID(); - NSPoint mouseLoc = [NSEvent mouseLocation]; - mouseLoc = [window convertPointFromScreen:mouseLoc]; - auto x = mouseLoc.x; - auto y = mouseLoc.y; - auto content = [[window contentView] frame]; - x -= content.origin.x; - y -= content.origin.y; - y = content.size.height - y; + if( !HasWindow() ) + { + return { 0, 0 }; + } + auto window = (NSWindow*)GetWindowID(); + NSPoint mouseLoc = [NSEvent mouseLocation]; + mouseLoc = [window convertPointFromScreen:mouseLoc]; + auto x = mouseLoc.x; + auto y = mouseLoc.y; + auto content = [[window contentView] frame]; + x -= content.origin.x; + y -= content.origin.y; + y = content.size.height - y; - int32_t l = int32_t( x / content.size.width * m_state.width + 0.5 ); - int32_t t = int32_t( y / content.size.height * m_state.height + 0.5 ); + int32_t l = int32_t( x / content.size.width * m_state.width + 0.5 ); + int32_t t = int32_t( y / content.size.height * m_state.height + 0.5 ); - return { l, t }; + return { l, t }; } bool Tr2MainWindow::IsKeyToggled( uint32_t keyCode ) const { - if( keyCode != 0x14 ) - { - // we only report CapsLock - return false; - } - return ( [NSEvent modifierFlags] & NSEventModifierFlagCapsLock ) != 0; + if( keyCode != 0x14 ) + { + // we only report CapsLock + return false; + } + return ( [NSEvent modifierFlags] & NSEventModifierFlagCapsLock ) != 0; } bool Tr2MainWindow::IsKeyPressed( uint32_t keyCode ) const { - switch( keyCode ) - { - case VK_LBUTTON: - return ( [NSEvent pressedMouseButtons] & 1 ) != 0; - case VK_RBUTTON: - return ( [NSEvent pressedMouseButtons] & 2 ) != 0; - case VK_MBUTTON: - return ( [NSEvent pressedMouseButtons] & 4 ) != 0; - case VK_SHIFT: - return KeyboardHelpers::IsAppKeyPressed( VK_LSHIFT ) || KeyboardHelpers::IsAppKeyPressed( VK_RSHIFT ); - case VK_CONTROL: - return KeyboardHelpers::IsAppKeyPressed( VK_LCONTROL ) || KeyboardHelpers::IsAppKeyPressed( VK_RCONTROL ); - case VK_MENU: - return KeyboardHelpers::IsAppKeyPressed( VK_LMENU ) || KeyboardHelpers::IsAppKeyPressed( VK_RMENU ); + switch( keyCode ) + { + case VK_LBUTTON: + return ( [NSEvent pressedMouseButtons] & 1 ) != 0; + case VK_RBUTTON: + return ( [NSEvent pressedMouseButtons] & 2 ) != 0; + case VK_MBUTTON: + return ( [NSEvent pressedMouseButtons] & 4 ) != 0; + case VK_SHIFT: + return KeyboardHelpers::IsAppKeyPressed( VK_LSHIFT ) || KeyboardHelpers::IsAppKeyPressed( VK_RSHIFT ); + case VK_CONTROL: + return KeyboardHelpers::IsAppKeyPressed( VK_LCONTROL ) || KeyboardHelpers::IsAppKeyPressed( VK_RCONTROL ); + case VK_MENU: + return KeyboardHelpers::IsAppKeyPressed( VK_LMENU ) || KeyboardHelpers::IsAppKeyPressed( VK_RMENU ); case VK_LWIN: return KeyboardHelpers::IsAppKeyPressed( VK_LWIN ) || KeyboardHelpers::IsAppKeyPressed( VK_RWIN ); default: - return KeyboardHelpers::IsAppKeyPressed( keyCode ); - } + return KeyboardHelpers::IsAppKeyPressed( keyCode ); + } } std::string Tr2MainWindow::GetKeyName( uint32_t keyCode ) const { - return KeyboardHelpers::GetAppKeyName( keyCode ); + return KeyboardHelpers::GetAppKeyName( keyCode ); } bool Tr2MainWindow::ProcessMessages() { - @autoreleasepool - { - while( true ) - { - NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - if (event == nil) - { - break; - } - [NSApp sendEvent:event]; - } - } - return !s_quitRequested; + @autoreleasepool + { + while( true ) + { + NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if( event == nil ) + { + break; + } + [NSApp sendEvent:event]; + } + } + return !s_quitRequested; } bool Tr2MainWindow::OnClose_MacOS() { - bool canClose = true; - m_onClose.Call( canClose ); - return canClose; + bool canClose = true; + m_onClose.Call( canClose ); + return canClose; } void Tr2MainWindow::OnWindowStartedResizing_MacOS() { - m_isResizing = true; + m_isResizing = true; } void Tr2MainWindow::OnWindowFnishedResizing_MacOS() { - m_isResizing = false; - OnWindowResized_MacOS(); + m_isResizing = false; + OnWindowResized_MacOS(); } void Tr2MainWindow::OnWindowResized_MacOS() { - if( m_isResizing || m_inSetState || m_state.windowMode == Tr2WindowMode::FULL_SCREEN ) - { - return; - } - auto window = (NSWindow*)GetWindowID(); - auto size = [window contentView].frame.size; - - auto prevWidth = m_state.width; - auto prevHeight = m_state.height; - auto newMode = m_state; - auto factor = [window screen].backingScaleFactor; - newMode.width = uint32_t( size.width * factor ); - newMode.height = uint32_t( size.height * factor ); - - if( [window isZoomed] ) - { - newMode.showState = Tr2WindowShowState::MAXIMIZED; - } - else if( [window isMiniaturized] ) - { - newMode.showState = Tr2WindowShowState::MINIMIZED; - newMode.width = prevWidth; - newMode.height = prevHeight; - } - else - { - newMode.showState = Tr2WindowShowState::NORMAL; - } - SetState( false, newMode ); + if( m_isResizing || m_inSetState || m_state.windowMode == Tr2WindowMode::FULL_SCREEN ) + { + return; + } + auto window = (NSWindow*)GetWindowID(); + auto size = [window contentView].frame.size; + auto prevWidth = m_state.width; + auto prevHeight = m_state.height; + auto newMode = m_state; + auto factor = [window screen].backingScaleFactor; + newMode.width = uint32_t( size.width * factor ); + newMode.height = uint32_t( size.height * factor ); + + if( [window isZoomed] ) + { + newMode.showState = Tr2WindowShowState::MAXIMIZED; + } + else if( [window isMiniaturized] ) + { + newMode.showState = Tr2WindowShowState::MINIMIZED; + newMode.width = prevWidth; + newMode.height = prevHeight; + } + else + { + newMode.showState = Tr2WindowShowState::NORMAL; + } + SetState( false, newMode ); } void Tr2MainWindow::OnWinowMoved_MacOS() { - if( m_isResizing || m_inSetState ) - { - return; - } - if( m_state.windowMode == Tr2WindowMode::WINDOWED ) - { - auto window = (NSWindow*)GetWindowID(); + if( m_isResizing || m_inSetState ) + { + return; + } + if( m_state.windowMode == Tr2WindowMode::WINDOWED ) + { + auto window = (NSWindow*)GetWindowID(); - auto height = [[window screen] frame].size.height; - auto location = [window frame].origin; + auto height = [[window screen] frame].size.height; + auto location = [window frame].origin; - auto newState = m_state; - newState.left = int32_t( location.x ); - newState.top = int32_t( location.y ); - SetState( false, newState ); - } + auto newState = m_state; + newState.left = int32_t( location.x ); + newState.top = int32_t( location.y ); + SetState( false, newState ); + } } void Tr2MainWindow::OnWindowChangedKey_MacOS( bool isKey ) { auto window = (NSWindow*)GetWindowID(); - if( isKey ) - { + if( isKey ) + { if( m_state.windowMode != Tr2WindowMode::WINDOWED ) { window.level = NSMainMenuWindowLevel + 1; } - if( gTriDev ) - { - gTriDev->ApplicationActivated( TriDevice::APP_ACTIVATED ); + if( gTriDev ) + { + gTriDev->ApplicationActivated( TriDevice::APP_ACTIVATED ); gTriDev->SetThrottling( TriDevice::WINDOW_OUT_OF_FOCUS, false ); - } - g_activeFrametimeMean.SetSource( &g_ccpStatistics_frameTime ); - g_activeFrametimeStdDev.SetSource( &g_ccpStatistics_frameTime ); - } - else - { + } + g_activeFrametimeMean.SetSource( &g_ccpStatistics_frameTime ); + g_activeFrametimeStdDev.SetSource( &g_ccpStatistics_frameTime ); + } + else + { window.level = NSNormalWindowLevel; - if( gTriDev ) - { - gTriDev->ApplicationActivated( TriDevice::APP_DEACTIVATED ); + if( gTriDev ) + { + gTriDev->ApplicationActivated( TriDevice::APP_DEACTIVATED ); gTriDev->SetThrottling( TriDevice::WINDOW_OUT_OF_FOCUS, true ); - } - g_activeFrametimeMean.SetSource( nullptr ); - g_activeFrametimeStdDev.SetSource( nullptr ); - } - m_onFocusChange.CallVoid( isKey ); + } + g_activeFrametimeMean.SetSource( nullptr ); + g_activeFrametimeStdDev.SetSource( nullptr ); + } + m_onFocusChange.CallVoid( isKey ); } void Tr2MainWindow::OnMouseButton_MacOS( int32_t button, bool down, float left, float top ) { - auto size = [(NSWindow*)GetWindowID() contentView].frame.size; - int32_t l = int32_t( left / size.width * m_state.width + 0.5 ); - int32_t t = int32_t( top / size.height * m_state.height + 0.5 ); + auto size = [(NSWindow*)GetWindowID() contentView].frame.size; + int32_t l = int32_t( left / size.width * m_state.width + 0.5 ); + int32_t t = int32_t( top / size.height * m_state.height + 0.5 ); - if( down ) - { - m_onMouseDown.CallVoid( button, l, t ); - } - else - { - m_onMouseUp.CallVoid( button, l, t ); - } + if( down ) + { + m_onMouseDown.CallVoid( button, l, t ); + } + else + { + m_onMouseUp.CallVoid( button, l, t ); + } } void Tr2MainWindow::OnMouseMove_MacOS( float left, float top ) { - auto size = [(NSWindow*)GetWindowID() contentView].frame.size; - int32_t l = int32_t( left / size.width * m_state.width + 0.5 ); - int32_t t = int32_t( top / size.height * m_state.height + 0.5 ); + auto size = [(NSWindow*)GetWindowID() contentView].frame.size; + int32_t l = int32_t( left / size.width * m_state.width + 0.5 ); + int32_t t = int32_t( top / size.height * m_state.height + 0.5 ); - m_onMouseMove.CallVoid( l, t ); + m_onMouseMove.CallVoid( l, t ); } -void Tr2MainWindow::OnMouseWheel_MacOS(float delta) +void Tr2MainWindow::OnMouseWheel_MacOS( float delta ) { - auto intDelta = int32_t( delta ); - if( intDelta != 0 ) - { - m_onMouseWheel.CallVoid( intDelta ); - } + auto intDelta = int32_t( delta ); + if( intDelta != 0 ) + { + m_onMouseWheel.CallVoid( intDelta ); + } } void Tr2MainWindow::OnKey_MacOS( bool isDown, int32_t key, bool repeat ) { - auto k = KeyboardHelpers::PlatformKeyToAppKey( key ); - if (k == VK_LSHIFT || k == VK_RSHIFT) - { - k = VK_SHIFT; - } - else if (k == VK_LCONTROL || k == VK_RCONTROL) - { - k = VK_CONTROL; - } - else if (k == VK_LMENU || k == VK_RMENU) - { - k = VK_MENU; - } - if( isDown ) - { - m_onKeyDown.CallVoid( k, repeat ? 0x40000000u : 0u ); - } - else - { - m_onKeyUp.CallVoid( k, 0 ); - } + auto k = KeyboardHelpers::PlatformKeyToAppKey( key ); + if( k == VK_LSHIFT || k == VK_RSHIFT ) + { + k = VK_SHIFT; + } + else if( k == VK_LCONTROL || k == VK_RCONTROL ) + { + k = VK_CONTROL; + } + else if( k == VK_LMENU || k == VK_RMENU ) + { + k = VK_MENU; + } + if( isDown ) + { + m_onKeyDown.CallVoid( k, repeat ? 0x40000000u : 0u ); + } + else + { + m_onKeyUp.CallVoid( k, 0 ); + } } void Tr2MainWindow::OnChar_MacOS( wchar_t charCode ) { - m_onChar.CallVoid( int32_t( charCode ), 0, false ); + m_onChar.CallVoid( int32_t( charCode ), 0, false ); } void Tr2MainWindow::OnWindowDidChangeBackingProperties_MacOS() { - if( m_inSetState ) - { - return; - } - - auto window = (NSWindow*)GetWindowID(); - auto factor = [window screen].backingScaleFactor; - auto size = [window contentView].frame.size; - auto newMode = m_state; - newMode.width = uint32_t( size.width * factor ); - newMode.height = uint32_t( size.height * factor ); - [window setMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; - if( newMode.width < m_minimumSize.width || newMode.height < m_minimumSize.height ) - { - [window setContentSize:NSMakeSize( std::max( newMode.width, m_minimumSize.width ) * factor, std::max( newMode.height, m_minimumSize.height ) * factor )]; - } - else - { - SetState( false, newMode ); - } + if( m_inSetState ) + { + return; + } + + auto window = (NSWindow*)GetWindowID(); + auto factor = [window screen].backingScaleFactor; + auto size = [window contentView].frame.size; + auto newMode = m_state; + newMode.width = uint32_t( size.width * factor ); + newMode.height = uint32_t( size.height * factor ); + [window setMinSize:NSMakeSize( m_minimumSize.width / factor, m_minimumSize.height / factor )]; + if( newMode.width < m_minimumSize.width || newMode.height < m_minimumSize.height ) + { + [window setContentSize:NSMakeSize( std::max( newMode.width, m_minimumSize.width ) * factor, + std::max( newMode.height, m_minimumSize.height ) * factor )]; + } + else + { + SetState( false, newMode ); + } } void Tr2MainWindow::OnUpdateCursor_MacOS() { - if( m_cursor ) - { - m_cursor->Apply(); - } + if( m_cursor ) + { + m_cursor->Apply(); + } } void Tr2MainWindow::OnTick( Be::Time, Be::Time, void* ) { - if( !ProcessMessages() ) - { - BeOS->Terminate(); - } + if( !ProcessMessages() ) + { + BeOS->Terminate(); + } } void Tr2MainWindow::SanitizeWindowedResolution( Tr2MainWindowState::State& state ) const { - if( state.width == 0 && state.height == 0 ) - { - // use window size that spans default display, adjust for window frame - Tr2DisplayModeInfo mi; - Tr2VideoAdapterInfo::GetAdapterDisplayMode( state.adapter, mi ); + if( state.width == 0 && state.height == 0 ) + { + // use window size that spans default display, adjust for window frame + Tr2DisplayModeInfo mi; + Tr2VideoAdapterInfo::GetAdapterDisplayMode( state.adapter, mi ); - Size size = { mi.width, mi.height }; - size = GetClientSize( size, state.windowMode ); + Size size = { mi.width, mi.height }; + size = GetClientSize( size, state.windowMode ); - state.width = size.width; - state.height = size.height; - } - else - { - state.width = std::max( m_minimumSize.width, state.width ); - state.height = std::max( m_minimumSize.height, state.height ); - } + state.width = size.width; + state.height = size.height; + } + else + { + state.width = std::max( m_minimumSize.width, state.width ); + state.height = std::max( m_minimumSize.height, state.height ); + } } void Tr2MainWindow::SanitizeWindowPosition( Tr2MainWindowState::State& state ) const { - if( state.windowMode == Tr2WindowMode::FIXED_WINDOW ) - { - // fixed windows are always at the top left corner of the display - auto screen = GetAdapterScreen( state.adapter ); - auto frame = screen.frame; - CCP_LOG( "Tr2MainWindow::SanitizeWindowPosition: screen frame position is (%f, %f), size (%f, %f), backing scale factor %f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height, screen.backingScaleFactor ); - - state.left = int32_t( frame.origin.x ); - state.top = int32_t( frame.origin.y + frame.size.height - state.height / screen.backingScaleFactor ); - } - else - { - // window should intersect desktop with some margin - Size size = { state.width, state.height }; - size = GetWindowSize( size, state.windowMode ); + if( state.windowMode == Tr2WindowMode::FIXED_WINDOW ) + { + // fixed windows are always at the top left corner of the display + auto screen = GetAdapterScreen( state.adapter ); + auto frame = screen.frame; + CCP_LOG( + "Tr2MainWindow::SanitizeWindowPosition: screen frame position is (%f, %f), size (%f, %f), backing scale factor %f", + frame.origin.x, + frame.origin.y, + frame.size.width, + frame.size.height, + screen.backingScaleFactor ); + + state.left = int32_t( frame.origin.x ); + state.top = int32_t( frame.origin.y + frame.size.height - state.height / screen.backingScaleFactor ); + } + else + { + // window should intersect desktop with some margin + Size size = { state.width, state.height }; + size = GetWindowSize( size, state.windowMode ); - auto margin = int32_t( std::max( std::min( size.width / 2, size.height / 2 ), 50u ) ); + auto margin = int32_t( std::max( std::min( size.width / 2, size.height / 2 ), 50u ) ); - auto desktop = GetDesktopRect(); + auto desktop = GetDesktopRect(); - state.left = std::max( state.left, int32_t( desktop.left - size.width + margin ) ); - state.top = std::max( state.top, int32_t( desktop.top - size.height + margin ) ); - state.left = std::min( state.left, int32_t( desktop.right - margin ) ); - state.top = std::min( state.top, int32_t( desktop.bottom - margin ) ); - } + state.left = std::max( state.left, int32_t( desktop.left - size.width + margin ) ); + state.top = std::max( state.top, int32_t( desktop.top - size.height + margin ) ); + state.left = std::min( state.left, int32_t( desktop.right - margin ) ); + state.top = std::min( state.top, int32_t( desktop.bottom - margin ) ); + } } Tr2MainWindow::Size Tr2MainWindow::GetLargestWindowSize( uint32_t adapter, Tr2WindowMode::Type mode ) const { - if( [NSScreen screensHaveSeparateSpaces] ) - { - auto screen = GetAdapterScreen( adapter ); - switch( mode ) - { - case Tr2WindowMode::WINDOWED: - return { uint32_t( screen.visibleFrame.size.width * screen.backingScaleFactor ), uint32_t( screen.visibleFrame.size.height * screen.backingScaleFactor ) }; - case Tr2WindowMode::FULL_SCREEN: - { - auto screenFrame = screen.visibleFrame; - return { uint32_t( screenFrame.size.width * screen.backingScaleFactor ), uint32_t( screenFrame.size.height * screen.backingScaleFactor ) }; - } - default: - { - auto screenFrame = screen.frame; - return { uint32_t( screenFrame.size.width * screen.backingScaleFactor ), uint32_t( screenFrame.size.height * screen.backingScaleFactor ) }; - } - } - } - else - { - auto desktopRect = GetDesktopRect(); - return { uint32_t( desktopRect.right - desktopRect.left ), uint32_t( desktopRect.bottom - desktopRect.top ) }; - } + if( [NSScreen screensHaveSeparateSpaces] ) + { + auto screen = GetAdapterScreen( adapter ); + switch( mode ) + { + case Tr2WindowMode::WINDOWED: + return { uint32_t( screen.visibleFrame.size.width * screen.backingScaleFactor ), + uint32_t( screen.visibleFrame.size.height * screen.backingScaleFactor ) }; + case Tr2WindowMode::FULL_SCREEN: { + auto screenFrame = screen.visibleFrame; + return { uint32_t( screenFrame.size.width * screen.backingScaleFactor ), + uint32_t( screenFrame.size.height * screen.backingScaleFactor ) }; + } + default: { + auto screenFrame = screen.frame; + return { uint32_t( screenFrame.size.width * screen.backingScaleFactor ), + uint32_t( screenFrame.size.height * screen.backingScaleFactor ) }; + } + } + } + else + { + auto desktopRect = GetDesktopRect(); + return { uint32_t( desktopRect.right - desktopRect.left ), uint32_t( desktopRect.bottom - desktopRect.top ) }; + } } void Tr2MainWindow::OnWindowFullscreenChanged_MacOS( bool fullscreen ) { - bool isFullscreen = m_state.windowMode == Tr2WindowMode::FULL_SCREEN; - auto window = (NSWindow*)GetWindowID(); - if (fullscreen) - { - // We have to resize here again because now that the dock and menu bar is hidden - // we get the real "visible frame" - auto screen = [window screen]; - [window setFrame:screen.visibleFrame display:YES]; - } - if( isFullscreen != fullscreen ) - { - auto screen = [window screen]; - auto newState = m_state; - newState.windowMode = fullscreen ? Tr2WindowMode::FULL_SCREEN : Tr2WindowMode::WINDOWED; - newState.adapter = GetScreenAdapter( screen ); - if( fullscreen ) - { - const auto& stored = m_storedStates[Tr2WindowMode::FULL_SCREEN]; - if( stored.width > 0 && stored.adapter == newState.adapter ) - { - newState = stored; - } - else - { - newState.width = uint32_t( screen.frame.size.width * screen.backingScaleFactor ); - newState.height = uint32_t( screen.frame.size.height * screen.backingScaleFactor ); - newState.left = 0; - newState.top = 0; - } - } - else - { - const auto& stored = m_storedStates[Tr2WindowMode::WINDOWED]; - if( stored.width > 0 && stored.adapter == newState.adapter ) - { - newState = stored; - } - else - { - newState.width = uint32_t( [window contentView].frame.size.width * screen.backingScaleFactor ); - newState.height = uint32_t( [window contentView].frame.size.height * screen.backingScaleFactor ); - newState.left = int32_t( [window frame].origin.x ); - newState.top = int32_t( [window frame].origin.y ); - } - } + bool isFullscreen = m_state.windowMode == Tr2WindowMode::FULL_SCREEN; + auto window = (NSWindow*)GetWindowID(); + if( fullscreen ) + { + // We have to resize here again because now that the dock and menu bar is hidden + // we get the real "visible frame" + auto screen = [window screen]; + [window setFrame:screen.visibleFrame display:YES]; + } + if( isFullscreen != fullscreen ) + { + auto screen = [window screen]; + auto newState = m_state; + newState.windowMode = fullscreen ? Tr2WindowMode::FULL_SCREEN : Tr2WindowMode::WINDOWED; + newState.adapter = GetScreenAdapter( screen ); + if( fullscreen ) + { + const auto& stored = m_storedStates[Tr2WindowMode::FULL_SCREEN]; + if( stored.width > 0 && stored.adapter == newState.adapter ) + { + newState = stored; + } + else + { + newState.width = uint32_t( screen.frame.size.width * screen.backingScaleFactor ); + newState.height = uint32_t( screen.frame.size.height * screen.backingScaleFactor ); + newState.left = 0; + newState.top = 0; + } + } + else + { + const auto& stored = m_storedStates[Tr2WindowMode::WINDOWED]; + if( stored.width > 0 && stored.adapter == newState.adapter ) + { + newState = stored; + } + else + { + newState.width = uint32_t( [window contentView].frame.size.width * screen.backingScaleFactor ); + newState.height = uint32_t( [window contentView].frame.size.height * screen.backingScaleFactor ); + newState.left = int32_t( [window frame].origin.x ); + newState.top = int32_t( [window frame].origin.y ); + } + } auto newStyle = GetWindowStyleMask( newState.windowMode ); if( fullscreen ) { newStyle |= NSWindowStyleMaskFullScreen; } - if( window.styleMask != newStyle ) - { - [window setStyleMask:newStyle]; - } - SetState( false, newState ); - } - if( fullscreen ) - { - [window makeKeyWindow]; - [window makeFirstResponder:[window contentView]]; - } + if( window.styleMask != newStyle ) + { + [window setStyleMask:newStyle]; + } + SetState( false, newState ); + } + if( fullscreen ) + { + [window makeKeyWindow]; + [window makeFirstResponder:[window contentView]]; + } } void Tr2MainWindow::OnWindowOcclusionChanged_MacOS() @@ -1784,12 +1813,12 @@ - (NSTouchBar *) makeTouchBar { uintptr_t Tr2MainWindow::GetHwnd() const { - return uintptr_t( m_hwnd ); + return uintptr_t( m_hwnd ); } Tr2WindowHandle Tr2MainWindow::GetOutputWindow() const { - return [(NSWindow*)GetWindowID() contentView]; + return [(NSWindow*)GetWindowID() contentView]; } #endif diff --git a/trinity/UI/Tr2MainWindow_Windows.cpp b/trinity/UI/Tr2MainWindow_Windows.cpp index bd19ec28b..e4165cf1b 100644 --- a/trinity/UI/Tr2MainWindow_Windows.cpp +++ b/trinity/UI/Tr2MainWindow_Windows.cpp @@ -19,25 +19,25 @@ CCP_STATS_DECLARED_ELSEWHERE( frameTime ); namespace { - struct MonitorRects - { - std::vector rcMonitors; - RECT rcCombined; +struct MonitorRects +{ + std::vector rcMonitors; + RECT rcCombined; - static BOOL CALLBACK MonitorEnum( HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData ) - { - MonitorRects* pThis = reinterpret_cast( pData ); - pThis->rcMonitors.push_back( *lprcMonitor ); - UnionRect( &pThis->rcCombined, &pThis->rcCombined, lprcMonitor ); - return TRUE; - } + static BOOL CALLBACK MonitorEnum( HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData ) + { + MonitorRects* pThis = reinterpret_cast( pData ); + pThis->rcMonitors.push_back( *lprcMonitor ); + UnionRect( &pThis->rcCombined, &pThis->rcCombined, lprcMonitor ); + return TRUE; + } - MonitorRects() - { - SetRectEmpty( &rcCombined ); - EnumDisplayMonitors( 0, 0, MonitorEnum, (LPARAM)this ); - } - }; + MonitorRects() + { + SetRectEmpty( &rcCombined ); + EnumDisplayMonitors( 0, 0, MonitorEnum, (LPARAM)this ); + } +}; } @@ -100,8 +100,10 @@ void Tr2MainWindow::CreateOSWindow( Tr2MainWindowState::State& state ) (LPWSTR)wndClass, m_title.c_str(), style, - state.left, state.top, - ( rect.right - rect.left ), ( rect.bottom - rect.top ), + state.left, + state.top, + ( rect.right - rect.left ), + ( rect.bottom - rect.top ), 0L, NULL, wclass.hInstance, @@ -213,7 +215,7 @@ Tr2MainWindow::Size Tr2MainWindow::GetClientSize( const Size& windowSize, Tr2Win RECT rc; SetRectEmpty( &rc ); ::AdjustWindowRect( &rc, GetWindowStyle( mode ), FALSE ); - + Size size; size.width = int32_t( windowSize.width - rc.right + rc.left ); size.height = int32_t( windowSize.height - rc.bottom + rc.top ); @@ -235,7 +237,7 @@ void Tr2MainWindow::ClipCursor( int32_t left, int32_t top, int32_t right, int32_ RECT rect; ::GetClientRect( m_hwnd, &rect ); - RECT rc = { + RECT rc = { LONG( double( left ) / m_state.width * ( rect.right - rect.left ) + 0.5 ), LONG( double( top ) / m_state.height * ( rect.bottom - rect.top ) + 0.5 ), LONG( double( right ) / m_state.width * ( rect.right - rect.left ) + 0.5 ), @@ -266,10 +268,9 @@ void Tr2MainWindow::SetCursorPos( int32_t x, int32_t y ) POINT offs = { 0, 0 }; ClientToScreen( m_hwnd, &offs ); - ::SetCursorPos( + ::SetCursorPos( LONG( double( x ) / m_state.width * ( rect.right - rect.left ) + 0.5 ) + offs.x, - LONG( double( y ) / m_state.height * ( rect.bottom - rect.top ) + 0.5 ) + offs.y - ); + LONG( double( y ) / m_state.height * ( rect.bottom - rect.top ) + 0.5 ) + offs.y ); } std::pair Tr2MainWindow::GetCursorPos() const @@ -284,9 +285,10 @@ std::pair Tr2MainWindow::GetCursorPos() const RECT rect; ::GetClientRect( m_hwnd, &rect ); - return { - int32_t( double( pt.x ) / ( rect.right - rect.left ) * m_state.width + 0.5 ), - int32_t( double( pt.y ) / ( rect.bottom - rect.top ) * m_state.height + 0.5 ) }; + return { + int32_t( double( pt.x ) / ( rect.right - rect.left ) * m_state.width + 0.5 ), + int32_t( double( pt.y ) / ( rect.bottom - rect.top ) * m_state.height + 0.5 ) + }; } bool Tr2MainWindow::IsKeyToggled( uint32_t keyCode ) const @@ -317,8 +319,7 @@ std::string Tr2MainWindow::GetKeyName( uint32_t keyCode ) const case VK_INSERT: case VK_DELETE: case VK_DIVIDE: - case VK_NUMLOCK: - { + case VK_NUMLOCK: { scanCode |= ( 1 << 24 ); } } @@ -387,8 +388,7 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara int32_t mouseX, mouseY; - auto mouseCoords = [&]() - { + auto mouseCoords = [&]() { RECT rect; ::GetClientRect( m_hwnd, &rect ); mouseX = int32_t( double( int32_t( lParam & 0xffff ) ) / ( rect.right - rect.left ) * m_state.width + 0.5 ); @@ -476,8 +476,7 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara returnValue = std::make_pair( 0, m_onChar.IsValid() ); break; - case WM_GETMINMAXINFO: - { + case WM_GETMINMAXINFO: { auto size = GetWindowSize( m_minimumSize, m_state.windowMode ); ( (MINMAXINFO*)lParam )->ptMinTrackSize.x = size.width; ( (MINMAXINFO*)lParam )->ptMinTrackSize.y = size.height; @@ -533,7 +532,7 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara auto prevHeight = m_state.height; auto newMode = m_state; #if USE_BORDERLESS_WINDOW - if( newMode.windowMode != Tr2WindowMode::FULL_SCREEN) + if( newMode.windowMode != Tr2WindowMode::FULL_SCREEN ) #endif { newMode.width = uint32_t( rect.right - rect.left ); @@ -557,7 +556,7 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara gTriDev->SetThrottling( TriDevice::WINDOW_HIDDEN, false ); } - if ( !g_renderContextIsBeingDestroyed ) + if( !g_renderContextIsBeingDestroyed ) { SetState( false, newMode ); } @@ -567,8 +566,7 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return 1; } break; - case WM_SETCURSOR: - { + case WM_SETCURSOR: { bool useWindowsCursor = false; if( m_state.windowMode == Tr2WindowMode::WINDOWED ) { @@ -636,11 +634,10 @@ LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_SYSCOMMAND: if( wParam == SC_KEYMENU ) { - return 0; //catch all Alt-something combination messages. Specifically alt enter. + return 0; //catch all Alt-something combination messages. Specifically alt enter. } break; - case WM_CLOSE: - { + case WM_CLOSE: { bool canClose = true; m_onClose.Call( canClose ); returnValue = std::make_pair( canClose ? 0 : 1, m_onClose.IsValid() ); @@ -690,69 +687,68 @@ void Tr2MainWindow::SetWindowsMessageFilter( bool enabled, const std::vector& representations ) { @@ -55,15 +57,15 @@ bool Tr2MouseCursor::IsValid() const #ifdef _WIN32 return m_cursor != nullptr; #elif __APPLE__ - return m_cursor != 0; + return m_cursor != 0; #else - return false; + return false; #endif } // -------------------------------------------------------------------------------------- // Description: -// Helper function to convert color/alpha values in B5G6R5 + A8 format to B8G8R8A8 +// Helper function to convert color/alpha values in B5G6R5 + A8 format to B8G8R8A8 // format. // Arguments: // color - Color value in B5G6R5 format. @@ -71,11 +73,11 @@ bool Tr2MouseCursor::IsValid() const // Return Value: // Color/alpha value in B8G8R8A8 format // -------------------------------------------------------------------------------------- -inline unsigned ConvertBGR565A8ToBGRA8( unsigned color, unsigned alpha ) +inline unsigned ConvertBGR565A8ToBGRA8( unsigned color, unsigned alpha ) { - return unsigned( color & 0x1f ) * 255 / 31 | - ( unsigned( ( color >> 5 ) & 0x3f ) * 255 / 63 ) << 8 | - ( unsigned( ( color >> 11 ) & 0x1f ) * 255 / 31 ) << 16 | + return unsigned( color & 0x1f ) * 255 / 31 | + ( unsigned( ( color >> 5 ) & 0x3f ) * 255 / 63 ) << 8 | + ( unsigned( ( color >> 11 ) & 0x1f ) * 255 / 31 ) << 16 | ( alpha << 24 ); } @@ -83,7 +85,7 @@ inline unsigned ConvertBGR565A8ToBGRA8( unsigned color, unsigned alpha ) // Description: // Helper function to decompress BC1 format image into B8G8R8A8 format. Used by mouse // cursors, which are small and are cached, so the function doesn't have to be super- -// optimal. Also flips image vertically for DX11 and GL since DX and WINAPI use +// optimal. Also flips image vertically for DX11 and GL since DX and WINAPI use // different origin. // Arguments: // dest - Destination buffer @@ -120,10 +122,10 @@ static void DecompressBC1( char* dest, const char* source, unsigned width, unsig *destPixel = ConvertBGR565A8ToBGRA8( color1, 255 ); break; case 2: - *destPixel = ConvertBGR565A8ToBGRA8( (2*color0+color1)/3, 255 ); + *destPixel = ConvertBGR565A8ToBGRA8( ( 2 * color0 + color1 ) / 3, 255 ); break; case 3: - *destPixel = ConvertBGR565A8ToBGRA8( (color0+2*color1)/3, 255 ); + *destPixel = ConvertBGR565A8ToBGRA8( ( color0 + 2 * color1 ) / 3, 255 ); break; } } @@ -139,7 +141,7 @@ static void DecompressBC1( char* dest, const char* source, unsigned width, unsig destY = height - 1 - destY; uint32_t* destPixel = reinterpret_cast( dest + destY * pitch + ( x + i ) * sizeof( uint32_t ) ); - switch( ( bits >> 2*(4*y+x) ) & 3 ) + switch( ( bits >> 2 * ( 4 * y + x ) ) & 3 ) { case 0: *destPixel = ConvertBGR565A8ToBGRA8( color0, 255 ); @@ -148,10 +150,10 @@ static void DecompressBC1( char* dest, const char* source, unsigned width, unsig *destPixel = ConvertBGR565A8ToBGRA8( color1, 255 ); break; case 2: - *destPixel = ConvertBGR565A8ToBGRA8( (color0+color1)/2, 255 ); + *destPixel = ConvertBGR565A8ToBGRA8( ( color0 + color1 ) / 2, 255 ); break; case 3: - *destPixel = ConvertBGR565A8ToBGRA8( (color0+2*color1)/3, 0 ); + *destPixel = ConvertBGR565A8ToBGRA8( ( color0 + 2 * color1 ) / 3, 0 ); break; } } @@ -166,7 +168,7 @@ static void DecompressBC1( char* dest, const char* source, unsigned width, unsig // Description: // Helper function to decompress BC2 format image into B8G8R8A8 format. Used by mouse // cursors, which are small and are cached, so the function doesn't have to be super- -// optimal. Also flips image vertically for DX11 and GL since DX and WINAPI use +// optimal. Also flips image vertically for DX11 and GL since DX and WINAPI use // different origin. // Arguments: // dest - Destination buffer @@ -203,10 +205,10 @@ static void DecompressBC2( char* dest, const char* source, unsigned width, unsig *destPixel = ConvertBGR565A8ToBGRA8( color1, alphaValue ); break; case 2: - *destPixel = ConvertBGR565A8ToBGRA8( (2*color0+color1)/3, alphaValue ); + *destPixel = ConvertBGR565A8ToBGRA8( ( 2 * color0 + color1 ) / 3, alphaValue ); break; case 3: - *destPixel = ConvertBGR565A8ToBGRA8( (color0+2*color1)/3, alphaValue ); + *destPixel = ConvertBGR565A8ToBGRA8( ( color0 + 2 * color1 ) / 3, alphaValue ); break; } } @@ -234,16 +236,15 @@ std::unique_ptr GetUncompressedBitmap( const Tr2HostBitmap* bitmap ) break; case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_TYPELESS: case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM: - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: { + const char* row = bitmap->GetRawData(); + for( uint32_t j = 0; j < bitmap->GetHeight(); ++j ) { - const char* row = bitmap->GetRawData(); - for( uint32_t j = 0; j < bitmap->GetHeight(); ++j ) - { - memcpy( bits.get() + j * bitmap->GetWidth() * 4, row, bitmap->GetWidth() * 4 ); - row += bitmap->GetPitch(); - } + memcpy( bits.get() + j * bitmap->GetWidth() * 4, row, bitmap->GetWidth() * 4 ); + row += bitmap->GetPitch(); } - break; + } + break; default: return nullptr; } @@ -299,28 +300,28 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, return false; } -#if defined(_WIN32) - BITMAPV5HEADER bi; - ZeroMemory( &bi, sizeof( BITMAPV5HEADER ) ); - bi.bV5Size = sizeof( BITMAPV5HEADER ); +#if defined( _WIN32 ) + BITMAPV5HEADER bi; + ZeroMemory( &bi, sizeof( BITMAPV5HEADER ) ); + bi.bV5Size = sizeof( BITMAPV5HEADER ); bi.bV5Width = bitmap->GetWidth(); bi.bV5Height = bitmap->GetHeight(); - bi.bV5Planes = 1; - bi.bV5BitCount = 32; - bi.bV5Compression = BI_BITFIELDS; - bi.bV5RedMask = 0x00FF0000; - bi.bV5GreenMask = 0x0000FF00; - bi.bV5BlueMask = 0x000000FF; - bi.bV5AlphaMask = 0xFF000000; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; bi.bV5CSType = LCS_WINDOWS_COLOR_SPACE; - HDC hdc; - hdc = GetDC( nullptr ); + HDC hdc; + hdc = GetDC( nullptr ); - void *bits; - HBITMAP bmp = CreateDIBSection( hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &bits, NULL, 0 ); + void* bits; + HBITMAP bmp = CreateDIBSection( hdc, (BITMAPINFO*)&bi, DIB_RGB_COLORS, &bits, NULL, 0 ); - ReleaseDC( nullptr, hdc ); + ReleaseDC( nullptr, hdc ); if( bmp == nullptr ) { @@ -329,7 +330,7 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, } ON_BLOCK_EXIT( [&] { DeleteObject( bmp ); } ); - + switch( bitmap->GetFormat() ) { case Tr2RenderContextEnum::PIXEL_FORMAT_BC1_TYPELESS: @@ -345,16 +346,15 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, break; case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_TYPELESS: case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM: - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: { + const char* row = bitmap->GetRawData(); + for( unsigned j = 0; j < bitmap->GetHeight(); ++j ) { - const char* row = bitmap->GetRawData(); - for( unsigned j = 0; j < bitmap->GetHeight(); ++j ) - { - memcpy( reinterpret_cast( bits ) + ( bitmap->GetHeight() - 1 - j ) * bitmap->GetWidth(), row, bitmap->GetWidth() * 4 ); - row += bitmap->GetPitch(); - } + memcpy( reinterpret_cast( bits ) + ( bitmap->GetHeight() - 1 - j ) * bitmap->GetWidth(), row, bitmap->GetWidth() * 4 ); + row += bitmap->GetPitch(); } - break; + } + break; default: break; } @@ -384,8 +384,8 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, return m_cursor != nullptr; } - // Create an empty mask bitmap. - HBITMAP monoBitmap = CreateBitmap( bitmap->GetWidth(), bitmap->GetHeight(), 1, 1, nullptr ); + // Create an empty mask bitmap. + HBITMAP monoBitmap = CreateBitmap( bitmap->GetWidth(), bitmap->GetHeight(), 1, 1, nullptr ); if( monoBitmap == nullptr ) { CCP_LOGERR( "Tr2MouseCursor.Create: could not create alpha bitmap" ); @@ -393,26 +393,26 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, } ON_BLOCK_EXIT( [&] { DeleteObject( monoBitmap ); } ); - ICONINFO ii; - ii.fIcon = FALSE; - ii.xHotspot = hotspotX; - ii.yHotspot = hotspotY; - ii.hbmMask = monoBitmap; - ii.hbmColor = bmp; + ICONINFO ii; + ii.fIcon = FALSE; + ii.xHotspot = hotspotX; + ii.yHotspot = hotspotY; + ii.hbmMask = monoBitmap; + ii.hbmColor = bmp; - // Create the alpha cursor with the alpha DIB section. - m_cursor = (HCURSOR)CreateIconIndirect( &ii ); + // Create the alpha cursor with the alpha DIB section. + m_cursor = (HCURSOR)CreateIconIndirect( &ii ); return m_cursor != nullptr; #elif __APPLE__ std::vector reprData; - std::unique_ptr bits( GetUncompressedBitmap( bitmap ) ); + std::unique_ptr bits( GetUncompressedBitmap( bitmap ) ); if( !bits ) { return false; } reprData.emplace_back( Representation{ bitmap->GetWidth(), bitmap->GetHeight(), std::move( bits ) } ); - for (auto bmp : representations ) + for( auto bmp : representations ) { if( bmp ) { @@ -424,10 +424,10 @@ bool Tr2MouseCursor::Create( Tr2HostBitmap* bitmap, int hotspotX, int hotspotY, reprData.emplace_back( Representation{ bmp->GetWidth(), bmp->GetHeight(), std::move( reprBits ) } ); } } - - return Create_MacOS( reprData, bitmap->GetWidth(), bitmap->GetHeight(), hotspotX, hotspotY ); + + return Create_MacOS( reprData, bitmap->GetWidth(), bitmap->GetHeight(), hotspotX, hotspotY ); #else - return false; + return false; #endif } @@ -441,9 +441,9 @@ void Tr2MouseCursor::Apply() { return; } -#if defined(_WIN32) +#if defined( _WIN32 ) SetCursor( m_cursor ); #elif __APPLE__ - Apply_MacOS(); + Apply_MacOS(); #endif } diff --git a/trinity/UI/Tr2MouseCursor.h b/trinity/UI/Tr2MouseCursor.h index 95c62b1e8..9bde413ca 100644 --- a/trinity/UI/Tr2MouseCursor.h +++ b/trinity/UI/Tr2MouseCursor.h @@ -13,10 +13,10 @@ BLUE_DECLARE_VECTOR( Tr2MouseCursor ); // Tr2MouseCursor encapsulates mouse cursor image management. There is a considerable // difference in how mouse cursors are handled in DX9 and DX11/GL. // -------------------------------------------------------------------------------------- -class Tr2MouseCursor: public IRoot +class Tr2MouseCursor : public IRoot { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); Tr2MouseCursor( IRoot* lockobj = nullptr ); ~Tr2MouseCursor(); @@ -37,10 +37,10 @@ class Tr2MouseCursor: public IRoot std::unique_ptr pixelData; }; - bool Create_MacOS( const std::vector& representations, uint32_t width, uint32_t height, int hotspotX, int hotspotY ); - void Apply_MacOS(); - - id m_cursor; // NSCursor + bool Create_MacOS( const std::vector& representations, uint32_t width, uint32_t height, int hotspotX, int hotspotY ); + void Apply_MacOS(); + + id m_cursor; // NSCursor #endif }; diff --git a/trinity/UI/Tr2MouseCursor_Blue.cpp b/trinity/UI/Tr2MouseCursor_Blue.cpp index a8b3d59a3..bbd220592 100644 --- a/trinity/UI/Tr2MouseCursor_Blue.cpp +++ b/trinity/UI/Tr2MouseCursor_Blue.cpp @@ -13,38 +13,34 @@ const Be::ClassInfo* Tr2MouseCursor::ExposeToBlue() MAP_INTERFACE( Tr2MouseCursor ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "__init__", + "__init__", py__init__, 1, "Creates a cursor from bitmap\n" ":param bitmap: bitmap containing cursor image\n" ":param hotspotX: horizontal offset to cursor hotspot\n" ":param hotspotY: vertical offset to cursor hotspot\n" - ":param representations: optional list of alternative bitmaps for the cursor for different DPIs\n" - ) + ":param representations: optional list of alternative bitmaps for the cursor for different DPIs\n" ) MAP_METHOD_AND_WRAP_OPTIONAL_ARGS( - "Create", + "Create", Create, 1, - "Creates a new mouse cursor image\n" + "Creates a new mouse cursor image\n" ":param bitmap: bitmap containing cursor image\n" ":param hotspotX: horizontal offset to cursor hotspot\n" ":param hotspotY: vertical offset to cursor hotspot\n" - ":param representations: optional list of alternative bitmaps for the cursor for different DPIs\n" - ) + ":param representations: optional list of alternative bitmaps for the cursor for different DPIs\n" ) - MAP_METHOD_AND_WRAP( + MAP_METHOD_AND_WRAP( "IsValid", IsValid, - "Check if the cursor is valid (has image)" - ) + "Check if the cursor is valid (has image)" ) - MAP_PROPERTY_READONLY( + MAP_PROPERTY_READONLY( "isValid", IsValid, - "Is the cursor valid (has image)" - ) + "Is the cursor valid (has image)" ) EXPOSURE_END() } diff --git a/trinity/UI/Tr2MouseCursor_MacOS.mm b/trinity/UI/Tr2MouseCursor_MacOS.mm index adf8ddad2..5154dab54 100644 --- a/trinity/UI/Tr2MouseCursor_MacOS.mm +++ b/trinity/UI/Tr2MouseCursor_MacOS.mm @@ -7,36 +7,39 @@ #import -bool Tr2MouseCursor::Create_MacOS( const std::vector& representations, uint32_t width, uint32_t height, int hotspotX, int hotspotY ) +bool Tr2MouseCursor::Create_MacOS( const std::vector& representations, + uint32_t width, + uint32_t height, + int hotspotX, + int hotspotY ) { - auto image = [[NSImage alloc] initWithSize:NSMakeSize( width, height )]; - - for( const auto& repr : representations ) - { - auto bmp = [[NSBitmapImageRep alloc] - initWithBitmapDataPlanes:nil - pixelsWide:repr.width - pixelsHigh:repr.height - bitsPerSample:8 - samplesPerPixel:4 - hasAlpha:YES - isPlanar:NO - colorSpaceName:NSCalibratedRGBColorSpace - bitmapFormat:NSBitmapFormatAlphaNonpremultiplied - bytesPerRow:repr.width * 4 - bitsPerPixel:32]; - memcpy( [bmp bitmapData], repr.pixelData.get(), repr.width * repr.height * 4 ); - [image addRepresentation:bmp]; - } - - m_cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint( CGFloat( hotspotX ), CGFloat( hotspotY ) )]; - - return true; + auto image = [[NSImage alloc] initWithSize:NSMakeSize( width, height )]; + + for( const auto& repr : representations ) + { + auto bmp = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil + pixelsWide:repr.width + pixelsHigh:repr.height + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSCalibratedRGBColorSpace + bitmapFormat:NSBitmapFormatAlphaNonpremultiplied + bytesPerRow:repr.width * 4 + bitsPerPixel:32]; + memcpy( [bmp bitmapData], repr.pixelData.get(), repr.width * repr.height * 4 ); + [image addRepresentation:bmp]; + } + + m_cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint( CGFloat( hotspotX ), CGFloat( hotspotY ) )]; + + return true; } void Tr2MouseCursor::Apply_MacOS() { - [(NSCursor*)m_cursor set]; + [(NSCursor*)m_cursor set]; } #endif diff --git a/trinity/UI/Tr2PresentParameters.h b/trinity/UI/Tr2PresentParameters.h index daf7fe97f..b95d4b635 100644 --- a/trinity/UI/Tr2PresentParameters.h +++ b/trinity/UI/Tr2PresentParameters.h @@ -4,8 +4,8 @@ #ifndef Tr2PresentParameters_h #define Tr2PresentParameters_h -BLUE_CLASS( Tr2PresentParameters ) : - public IRoot, +BLUE_CLASS( Tr2PresentParameters ) : + public IRoot, public Tr2PresentParametersAL { public: diff --git a/trinity/UI/Tr2PresentParameters_Blue.cpp b/trinity/UI/Tr2PresentParameters_Blue.cpp index bdab7e82c..86c614bd6 100644 --- a/trinity/UI/Tr2PresentParameters_Blue.cpp +++ b/trinity/UI/Tr2PresentParameters_Blue.cpp @@ -9,34 +9,26 @@ BLUE_DEFINE( Tr2PresentParameters ); const Be::ClassInfo* Tr2PresentParameters::ExposeToBlue() { EXPOSURE_BEGIN( Tr2PresentParameters, "Structure used to pass values to functions creating the device" ) - MAP_ATTRIBUTE - ( + MAP_ATTRIBUTE( "backBufferWidth", mode.width, "", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "backBufferHeight", mode.height, "", - Be::READWRITE - ) - MAP_ATTRIBUTE - ( + Be::READWRITE ) + MAP_ATTRIBUTE( "windowed", windowed, "", - Be::READWRITE - ) - MAP_ATTRIBUTE_WITH_CHOOSER - ( + Be::READWRITE ) + MAP_ATTRIBUTE_WITH_CHOOSER( "software", software, "", Be::READWRITE | Be::ENUM, - TriDeviceTypeChooser - ) + TriDeviceTypeChooser ) EXPOSURE_END() } \ No newline at end of file diff --git a/trinity/UI/UIChoosers.cpp b/trinity/UI/UIChoosers.cpp index b7cca04b7..e9e44682a 100644 --- a/trinity/UI/UIChoosers.cpp +++ b/trinity/UI/UIChoosers.cpp @@ -6,10 +6,9 @@ #if BLUE_WITH_PYTHON -void AddUIChoosersToDict(PyObject* dict) +void AddUIChoosersToDict( PyObject* dict ) { - const Be::VarChooser* kvs [] = - { + const Be::VarChooser* kvs[] = { UIAlignChooser, UIAnchorChooser, UIIDChooser, @@ -23,15 +22,15 @@ void AddUIChoosersToDict(PyObject* dict) UIEventTypeChooser }; - for (int i = 0; i < sizeof kvs / sizeof kvs[0]; i++) + for( int i = 0; i < sizeof kvs / sizeof kvs[0]; i++ ) { const Be::VarChooser* kv = kvs[i]; - while (kv->mKey) + while( kv->mKey ) { - PyObject* value = ToPython(kv->mValue.mLong); - PyDict_SetItemString(dict, (char*)(kv->mKey ), value); - Py_DECREF(value); + PyObject* value = ToPython( kv->mValue.mLong ); + PyDict_SetItemString( dict, (char*)( kv->mKey ), value ); + Py_DECREF( value ); kv++; } } @@ -40,79 +39,77 @@ void AddUIChoosersToDict(PyObject* dict) -#define VAL(v) BeCast(v) +#define VAL( v ) BeCast( v ) -#define KV(_k, _d)\ - {#_k, VAL(_k), _d} +#define KV( _k, _d ) \ + { #_k, VAL( _k ), _d } //-------------------------------------------------------------------- // UIAlignChooser //-------------------------------------------------------------------- -const Be::VarChooser UIAlignChooser[] = -{ - KV(UI_ALNONE, "None"), - KV(UI_ALLEFT, "Left"), - KV(UI_ALRIGHT, "Right"), - KV(UI_ALTOP, "Top"), - KV(UI_ALBOTTOM, "Bottom"), - KV(UI_ALCLIENT, "Client"), - KV(UI_ALABSOLUTE, "Absolute"), - {0} +const Be::VarChooser UIAlignChooser[] = { + KV( UI_ALNONE, "None" ), + KV( UI_ALLEFT, "Left" ), + KV( UI_ALRIGHT, "Right" ), + KV( UI_ALTOP, "Top" ), + KV( UI_ALBOTTOM, "Bottom" ), + KV( UI_ALCLIENT, "Client" ), + KV( UI_ALABSOLUTE, "Absolute" ), + { 0 } }; //-------------------------------------------------------------------- // UIEventTypeChooser //-------------------------------------------------------------------- -const Be::VarChooser UIEventTypeChooser[] = -{ - KV(UI_CREATE,"OnCreate"), - KV(UI_UNHOOK,"OnUnHook"), - KV(UI_DESTROY,"OnDestroy"), - KV(UI_SETPARENT,"OnSetParent"), - KV(UI_CLOSE,"OnClose"), - KV(UI_RESIZE,"OnResize"), +const Be::VarChooser UIEventTypeChooser[] = { + KV( UI_CREATE, "OnCreate" ), + KV( UI_UNHOOK, "OnUnHook" ), + KV( UI_DESTROY, "OnDestroy" ), + KV( UI_SETPARENT, "OnSetParent" ), + KV( UI_CLOSE, "OnClose" ), + KV( UI_RESIZE, "OnResize" ), // Window state - KV(UI_ACTIVATE,"OnActivate"), - KV(UI_DEACTIVATE,"OnDeactivate"), - KV(UI_SETFOCUS,"OnSetFocus"), - KV(UI_KILLFOCUS,"OnKillFocus"), + KV( UI_ACTIVATE, "OnActivate" ), + KV( UI_DEACTIVATE, "OnDeactivate" ), + KV( UI_SETFOCUS, "OnSetFocus" ), + KV( UI_KILLFOCUS, "OnKillFocus" ), // Mouse events - KV(UI_MOUSEENTER,"OnMouseEnter"), - KV(UI_MOUSEEXIT,"OnMouseLeave"), - KV(UI_MOUSEHOVER,"OnMouseHover"), - KV(UI_MOUSEDOWN,"OnMouseDown"), - KV(UI_MOUSEUP,"OnMouseUp"), - KV(UI_MOUSEMOVE,"OnMouseMove"), - KV(UI_MOUSEWHEEL,"OnMouseWheel"), - KV(UI_CLICK,"OnClick"), - KV(UI_DBLCLICK,"OnDblClick"), - KV(UI_CONTEXTPOPUP,"OnContextPopup"), + KV( UI_MOUSEENTER, "OnMouseEnter" ), + KV( UI_MOUSEEXIT, "OnMouseLeave" ), + KV( UI_MOUSEHOVER, "OnMouseHover" ), + KV( UI_MOUSEDOWN, "OnMouseDown" ), + KV( UI_MOUSEUP, "OnMouseUp" ), + KV( UI_MOUSEMOVE, "OnMouseMove" ), + KV( UI_MOUSEWHEEL, "OnMouseWheel" ), + KV( UI_CLICK, "OnClick" ), + KV( UI_DBLCLICK, "OnDblClick" ), + KV( UI_CONTEXTPOPUP, "OnContextPopup" ), //{"OnHitTest", UI_HITTEST}, - + // Keyboard events - KV(UI_KEYDOWN,"OnKeyDown"), - KV(UI_KEYUP,"OnKeyUp"), - KV(UI_CHAR,"OnKeyPress"), + KV( UI_KEYDOWN, "OnKeyDown" ), + KV( UI_KEYUP, "OnKeyUp" ), + KV( UI_CHAR, "OnKeyPress" ), // Drag/drop - KV(UI_STARTDRAG,"OnStartDrag"), - KV(UI_DRAGOVER,"OnDragOver"), //(source, x, y, state[enter, leave, move]), return 1 to accept - KV(UI_DRAGDROP,"OnDragDrop"), //(source, x, y) - KV(UI_ENDDRAG,"OnEndDrag"), + KV( UI_STARTDRAG, "OnStartDrag" ), + KV( UI_DRAGOVER, "OnDragOver" ), //(source, x, y, state[enter, leave, move]), return 1 to accept + KV( UI_DRAGDROP, "OnDragDrop" ), //(source, x, y) + KV( UI_ENDDRAG, "OnEndDrag" ), // Other - KV(UI_SETTEXT,"OnSetText"), + KV( UI_SETTEXT, "OnSetText" ), - KV(UI_TRACKINGCHANGE, "OnTrackingChange"), - KV(UI_STATECHANGE, "OnStateChange"), + KV( UI_TRACKINGCHANGE, "OnTrackingChange" ), + KV( UI_STATECHANGE, "OnStateChange" ), - KV(UI_ACTIVE, "OnActive"), + KV( UI_ACTIVE, "OnActive" ), - {0} + { 0 } }; @@ -120,155 +117,142 @@ const Be::VarChooser UIEventTypeChooser[] = //-------------------------------------------------------------------- // UIAnchorChooser //-------------------------------------------------------------------- -const Be::VarChooser UIAnchorChooser[] = -{ - KV(UI_ANCHLEFT, - "The control\'s position is fixed with respect to the left edge of its parent."), - KV(UI_ANCHRIGHT, - "The control\'s position is fixed with respect to the right edge of its parent."), - KV(UI_ANCHTOP, - "The control\'s position is fixed with respect to the top edge of its parent."), - KV(UI_ANCHBOTTOM, - "The control\'s position is fixed with respect to the bottm edge of its parent."), - {0} +const Be::VarChooser UIAnchorChooser[] = { + KV( UI_ANCHLEFT, + "The control\'s position is fixed with respect to the left edge of its parent." ), + KV( UI_ANCHRIGHT, + "The control\'s position is fixed with respect to the right edge of its parent." ), + KV( UI_ANCHTOP, + "The control\'s position is fixed with respect to the top edge of its parent." ), + KV( UI_ANCHBOTTOM, + "The control\'s position is fixed with respect to the bottm edge of its parent." ), + { 0 } }; //-------------------------------------------------------------------- // UIIDChooser //-------------------------------------------------------------------- -const Be::VarChooser UIIDChooser[] = -{ - KV(ID_NONE, "None. The default value before the user exits."), - KV(ID_OK, "The user exited with OK button." ), - KV(ID_CANCEL, "The user exited with the CANCEL button." ), - KV(ID_YES, "The user exited with the YES button." ), - KV(ID_NO, "The user exited with the NO button." ), - KV(ID_CLOSE, "The user exited with the CLOSE button." ), - KV(ID_HELP, "The user exited with the HELP button." ), - {0} +const Be::VarChooser UIIDChooser[] = { + KV( ID_NONE, "None. The default value before the user exits." ), + KV( ID_OK, "The user exited with OK button." ), + KV( ID_CANCEL, "The user exited with the CANCEL button." ), + KV( ID_YES, "The user exited with the YES button." ), + KV( ID_NO, "The user exited with the NO button." ), + KV( ID_CLOSE, "The user exited with the CLOSE button." ), + KV( ID_HELP, "The user exited with the HELP button." ), + { 0 } }; //-------------------------------------------------------------------- // UIIDBoxChooser //-------------------------------------------------------------------- -const Be::VarChooser UIIDBoxChooser[] = -{ - KV(OK, "OK"), - KV(OKCANCEL, "OK, Cancel"), - KV(YESNOCANCEL, "Yes, No, Cancel"), - KV(YESNO, "Yes, No"), - - KV(INFO, "Yes, No"), - KV(WARNING, "Yes, No"), - KV(QUESTION, "Yes, No"), - KV(ERROR, "Yes, No"), - KV(FATAL, "Yes, No"), - {0} +const Be::VarChooser UIIDBoxChooser[] = { + KV( OK, "OK" ), + KV( OKCANCEL, "OK, Cancel" ), + KV( YESNOCANCEL, "Yes, No, Cancel" ), + KV( YESNO, "Yes, No" ), + + KV( INFO, "Yes, No" ), + KV( WARNING, "Yes, No" ), + KV( QUESTION, "Yes, No" ), + KV( ERROR, "Yes, No" ), + KV( FATAL, "Yes, No" ), + { 0 } }; //-------------------------------------------------------------------- // UIStateChooser //-------------------------------------------------------------------- -const Be::VarChooser UIStateChooser[] = -{ - KV(UI_NORMAL, "(Default)"), - KV(UI_DISABLED, "Disabled"), - KV(UI_HIDDEN, "Hidden"), - KV(UI_PICKCHILDREN, "PickChildren"), - {0} +const Be::VarChooser UIStateChooser[] = { + KV( UI_NORMAL, "(Default)" ), + KV( UI_DISABLED, "Disabled" ), + KV( UI_HIDDEN, "Hidden" ), + KV( UI_PICKCHILDREN, "PickChildren" ), + { 0 } }; //-------------------------------------------------------------------- // UIPosChooser //-------------------------------------------------------------------- -const Be::VarChooser UIPosChooser[] = -{ +const Be::VarChooser UIPosChooser[] = { KV( UI_POSDESIGNED, "The form appears positioned on the screen and with the same " - "height and width as it had at design time." - ), + "height and width as it had at design time." ), KV( - UI_POSDEFAULT, + UI_POSDEFAULT, "The form appears in a position on the screen and with a height " "and width determined by UILib. Each time you create the window, " "the form moves slightly down and to the right. The right side " "of the form is always near the far right side of the screen, and " "the bottom of the form is always near the bottom of the screen, " - "regardless of the screen's resolution." - ), + "regardless of the screen's resolution." ), KV( - UI_POSCENTER, + UI_POSCENTER, "The form remains the size you left it at design time, but is " - "positioned in the center of the screen." - ), + "positioned in the center of the screen." ), KV( - UI_POSCENTER2, - "Same as above, but moved just a tad upwards (ca. 15% of top margin)." - ), + UI_POSCENTER2, + "Same as above, but moved just a tad upwards (ca. 15% of top margin)." ), - {0} + { 0 } }; //-------------------------------------------------------------------- // UICtlTypeChooser //-------------------------------------------------------------------- -const Be::VarChooser UICtlTypeChooser[] = -{ - KV(UI_IMAGE, "No behaviour - act normal."), - KV(UI_PUSHBTN, "Behave as push button."), - KV(UI_RADIOBTN, "Behave as radio button."), - KV(UI_CHECKBTN, "Behave as check box."), - KV(UI_IMAGEBTN, "Does UV coord. adjustments."), - {0} +const Be::VarChooser UICtlTypeChooser[] = { + KV( UI_IMAGE, "No behaviour - act normal." ), + KV( UI_PUSHBTN, "Behave as push button." ), + KV( UI_RADIOBTN, "Behave as radio button." ), + KV( UI_CHECKBTN, "Behave as check box." ), + KV( UI_IMAGEBTN, "Does UV coord. adjustments." ), + { 0 } }; //-------------------------------------------------------------------- // UIFontSizeChooser //-------------------------------------------------------------------- -const Be::VarChooser UIFontSizeChooser[] = -{ - KV(UIFONT_6X10, "Font 6X10"), - KV(UIFONT_9X12, "Font 9X12"), - KV(UIFONT_9X17, "Font 9X17"), - {0} +const Be::VarChooser UIFontSizeChooser[] = { + KV( UIFONT_6X10, "Font 6X10" ), + KV( UIFONT_9X12, "Font 9X12" ), + KV( UIFONT_9X17, "Font 9X17" ), + { 0 } }; //-------------------------------------------------------------------- // UIFontStyleChooser //-------------------------------------------------------------------- -const Be::VarChooser UIFontStyleChooser[] = -{ - KV(UIFONT_NORMAL, "Normal"), - KV(UIFONT_DROPSHADOW, "Drop shadow"), - KV(UIFONT_HIGHLIGHTED, "Highlighted"), - {0} +const Be::VarChooser UIFontStyleChooser[] = { + KV( UIFONT_NORMAL, "Normal" ), + KV( UIFONT_DROPSHADOW, "Drop shadow" ), + KV( UIFONT_HIGHLIGHTED, "Highlighted" ), + { 0 } }; //-------------------------------------------------------------------- // UICursorChooser //-------------------------------------------------------------------- -const Be::VarChooser UICursorChooser[] = -{ - KV(UICURSOR_DEFAULT, "Default cursor"), - KV(UICURSOR_CROSS, "Crosshair"), - KV(UICURSOR_SELECT, "Selectable item"), - KV(UICURSOR_SELECTDOWN, "Selectable item with mouse button down"), - KV(UICURSOR_DRAGGABLE, "Draggable item"), - KV(UICURSOR_TARGET1, "Selectable target - blink state 1"), - KV(UICURSOR_TARGETDOWN, "Selectable target with mouse button down"), - KV(UICURSOR_TARGET2, "Selectable target - blink state 2"), - KV(UICURSOR_IBEAM, "I-beam"), - {0} +const Be::VarChooser UICursorChooser[] = { + KV( UICURSOR_DEFAULT, "Default cursor" ), + KV( UICURSOR_CROSS, "Crosshair" ), + KV( UICURSOR_SELECT, "Selectable item" ), + KV( UICURSOR_SELECTDOWN, "Selectable item with mouse button down" ), + KV( UICURSOR_DRAGGABLE, "Draggable item" ), + KV( UICURSOR_TARGET1, "Selectable target - blink state 1" ), + KV( UICURSOR_TARGETDOWN, "Selectable target with mouse button down" ), + KV( UICURSOR_TARGET2, "Selectable target - blink state 2" ), + KV( UICURSOR_IBEAM, "I-beam" ), + { 0 } }; diff --git a/trinity/UI/UIChoosers.h b/trinity/UI/UIChoosers.h index 29031206b..558889f6c 100644 --- a/trinity/UI/UIChoosers.h +++ b/trinity/UI/UIChoosers.h @@ -20,9 +20,8 @@ extern const Be::VarChooser UICursorChooser[]; #if BLUE_WITH_PYTHON -void AddUIChoosersToDict(PyObject* dict); +void AddUIChoosersToDict( PyObject* dict ); #endif #endif - diff --git a/trinity/UI/WindowIcon.cpp b/trinity/UI/WindowIcon.cpp index 13d13f6f1..9c182e350 100644 --- a/trinity/UI/WindowIcon.cpp +++ b/trinity/UI/WindowIcon.cpp @@ -9,8 +9,8 @@ HICON GetWindowIcon() { - HMODULE hModule = GetModuleHandle(0); - return (HICON)LoadImage(hModule, MAKEINTRESOURCE(101), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); + HMODULE hModule = GetModuleHandle( 0 ); + return (HICON)LoadImage( hModule, MAKEINTRESOURCE( 101 ), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED ); } #endif \ No newline at end of file diff --git a/trinity/Utilities/BoundingBox.cpp b/trinity/Utilities/BoundingBox.cpp index a587442f2..209ca0bd1 100644 --- a/trinity/Utilities/BoundingBox.cpp +++ b/trinity/Utilities/BoundingBox.cpp @@ -7,26 +7,28 @@ #include "TriViewport.h" -static const XMVECTOR g_UnitQuaternionEpsilon = -{ - 1.0e-4f, 1.0e-4f, 1.0e-4f, 1.0e-4f +static const XMVECTOR g_UnitQuaternionEpsilon = { + 1.0e-4f, + 1.0e-4f, + 1.0e-4f, + 1.0e-4f }; static inline bool XMVector3AnyTrue( FXMVECTOR V ) { - XMVECTOR C; + XMVECTOR C; - // Duplicate the fourth element from the first element. - C = XMVectorSwizzle( V, 0, 1, 2, 0 ); + // Duplicate the fourth element from the first element. + C = XMVectorSwizzle( V, 0, 1, 2, 0 ); - return XMComparisonAnyTrue( XMVector4EqualIntR( C, XMVectorTrueInt() ) ); + return XMComparisonAnyTrue( XMVector4EqualIntR( C, XMVectorTrueInt() ) ); } static inline bool XMQuaternionIsUnit( FXMVECTOR Q ) { - XMVECTOR Difference = XMVector4Length( Q ) - XMVectorSplatOne(); + XMVECTOR Difference = XMVector4Length( Q ) - XMVectorSplatOne(); - return XMVector4Less( XMVectorAbs( Difference ), g_UnitQuaternionEpsilon ) != 0; + return XMVector4Less( XMVectorAbs( Difference ), g_UnitQuaternionEpsilon ) != 0; } @@ -44,26 +46,26 @@ static inline bool XMQuaternionIsUnit( FXMVECTOR Q ) // false otherwise // -------------------------------------------------------------------------------------- #if BLUE_WITH_PYTHON -bool BlueExtractArgumentImpl( - PyObject* argument, - AxisAlignedBoundingBox& result, - unsigned int argID, +bool BlueExtractArgumentImpl( + PyObject* argument, + AxisAlignedBoundingBox& result, + unsigned int argID, std::false_type isBlueType ) { if( !PySequence_Check( argument ) ) { - PyErr_Format( PyExc_TypeError, - "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", - argID ); + PyErr_Format( PyExc_TypeError, + "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", + argID ); return false; } Py_ssize_t tupleCount = PySequence_Size( argument ); if( tupleCount != 2 ) { - PyErr_Format( PyExc_TypeError, - "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", - argID ); + PyErr_Format( PyExc_TypeError, + "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", + argID ); return false; } @@ -72,9 +74,9 @@ bool BlueExtractArgumentImpl( Py_DecRef( item ); if( !success ) { - PyErr_Format( PyExc_TypeError, - "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", - argID ); + PyErr_Format( PyExc_TypeError, + "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", + argID ); return false; } @@ -83,9 +85,9 @@ bool BlueExtractArgumentImpl( Py_DecRef( item ); if( !success ) { - PyErr_Format( PyExc_TypeError, - "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", - argID ); + PyErr_Format( PyExc_TypeError, + "Could not match argument %i to expected type: sequence of 2 3D vectors expected.", + argID ); return false; } return true; @@ -102,26 +104,26 @@ bool BlueExtractArgumentImpl( // -------------------------------------------------------------------------------------- BlueScriptValue BlueWrapReturnValueImpl( BlueScriptArguments args, const AxisAlignedBoundingBox& val ) { - return Py_BuildValue( - "(fff)(fff)", - val.m_min.x, - val.m_min.y, - val.m_min.z, - val.m_max.x, - val.m_max.y, + return Py_BuildValue( + "(fff)(fff)", + val.m_min.x, + val.m_min.y, + val.m_min.z, + val.m_max.x, + val.m_max.y, val.m_max.z ); } #endif void BoundingBoxInitialize( Vector3& min, Vector3& max ) { - min.x = FLT_MAX; - min.y = FLT_MAX; - min.z = FLT_MAX; + min.x = FLT_MAX; + min.y = FLT_MAX; + min.z = FLT_MAX; - max.x = -FLT_MAX; - max.y = -FLT_MAX; - max.z = -FLT_MAX; + max.x = -FLT_MAX; + max.y = -FLT_MAX; + max.z = -FLT_MAX; } void BoundingBoxInitialize( const Vector4& sphere, Vector3& min, Vector3& max ) @@ -149,15 +151,15 @@ bool BoundingBoxIsInside( const Vector3& min, const Vector3& max, const Vector3& bool BoundingBoxIsInside( const Vector3& min, const Vector3& max, const Vector3& pos, float epsilon ) { - if( ( min.x > pos.x+epsilon ) || ( max.x < pos.x-epsilon ) ) + if( ( min.x > pos.x + epsilon ) || ( max.x < pos.x - epsilon ) ) { return false; } - if( ( min.y > pos.y+epsilon ) || ( max.y < pos.y-epsilon ) ) + if( ( min.y > pos.y + epsilon ) || ( max.y < pos.y - epsilon ) ) { return false; } - if( ( min.z > pos.z+epsilon ) || ( max.z < pos.z-epsilon ) ) + if( ( min.z > pos.z + epsilon ) || ( max.z < pos.z - epsilon ) ) { return false; } @@ -166,38 +168,38 @@ bool BoundingBoxIsInside( const Vector3& min, const Vector3& max, const Vector3& void BoundingBoxUpdate( Vector3& min, Vector3& max, const Vector3& otherMin, const Vector3& otherMax ) { - BoundingBoxUpdate( min, max, otherMin ); - BoundingBoxUpdate( min, max, otherMax ); + BoundingBoxUpdate( min, max, otherMin ); + BoundingBoxUpdate( min, max, otherMax ); } void BoundingBoxUpdate( Vector3& min, Vector3& max, const Vector3& pos ) { - if( pos.x < min.x ) - { - min.x = pos.x; - } - if( pos.x > max.x ) - { - max.x = pos.x; - } - - if( pos.y < min.y ) - { - min.y = pos.y; - } - if( pos.y > max.y ) - { - max.y = pos.y; - } - - if( pos.z < min.z ) - { - min.z = pos.z; - } - if( pos.z > max.z ) - { - max.z = pos.z; - } + if( pos.x < min.x ) + { + min.x = pos.x; + } + if( pos.x > max.x ) + { + max.x = pos.x; + } + + if( pos.y < min.y ) + { + min.y = pos.y; + } + if( pos.y > max.y ) + { + max.y = pos.y; + } + + if( pos.z < min.z ) + { + min.z = pos.z; + } + if( pos.z > max.z ) + { + max.z = pos.z; + } } void BoundingBoxUpdate( Vector3& min, Vector3& max, const Vector4& sphere ) @@ -208,59 +210,59 @@ void BoundingBoxUpdate( Vector3& min, Vector3& max, const Vector4& sphere ) void BoundingBoxTransform( Vector3& min, Vector3& max, const Matrix& tf ) { - Vector3 corners[8]; - - corners[0] = min; - - corners[1].x = min.x; - corners[1].y = min.y; - corners[1].z = max.z; - - corners[2].x = max.x; - corners[2].y = min.y; - corners[2].z = min.z; - - corners[3].x = max.x; - corners[3].y = min.y; - corners[3].z = max.z; - - corners[4] = max; - - corners[5].x = max.x; - corners[5].y = max.y; - corners[5].z = min.z; - - corners[6].x = min.x; - corners[6].y = max.y; - corners[6].z = max.z; - - corners[7].x = min.x; - corners[7].y = max.y; - corners[7].z = min.z; - - TransformCoords( corners, tf ); - - min = corners[0]; - max = corners[0]; - float* pMin = (float*)&min; - float* pMax = (float*)&max; - - for( int i = 1; i < 8; ++i ) - { - float* pCorner = (float*)&corners[i]; - - for( int component = 0; component < 3; ++component ) - { - if( pCorner[component] < pMin[component] ) - { - pMin[component] = pCorner[component]; - } - if( pCorner[component] > pMax[component] ) - { - pMax[component] = pCorner[component]; - } - } - } + Vector3 corners[8]; + + corners[0] = min; + + corners[1].x = min.x; + corners[1].y = min.y; + corners[1].z = max.z; + + corners[2].x = max.x; + corners[2].y = min.y; + corners[2].z = min.z; + + corners[3].x = max.x; + corners[3].y = min.y; + corners[3].z = max.z; + + corners[4] = max; + + corners[5].x = max.x; + corners[5].y = max.y; + corners[5].z = min.z; + + corners[6].x = min.x; + corners[6].y = max.y; + corners[6].z = max.z; + + corners[7].x = min.x; + corners[7].y = max.y; + corners[7].z = min.z; + + TransformCoords( corners, tf ); + + min = corners[0]; + max = corners[0]; + float* pMin = (float*)&min; + float* pMax = (float*)&max; + + for( int i = 1; i < 8; ++i ) + { + float* pCorner = (float*)&corners[i]; + + for( int component = 0; component < 3; ++component ) + { + if( pCorner[component] < pMin[component] ) + { + pMin[component] = pCorner[component]; + } + if( pCorner[component] > pMax[component] ) + { + pMax[component] = pCorner[component]; + } + } + } } void BoundingBoxProject( Vector3& min, Vector3& max, const Matrix& view, const Matrix& proj, const TriViewport& vp ) @@ -329,20 +331,20 @@ bool IntersectAxisAlignedBoxAxisAlignedBox( const Vector3& minBoundsA, const Vec { XMVECTOR MinA = XMVectorSet( minBoundsA.x, minBoundsA.y, minBoundsA.z, 0.0f ); XMVECTOR MaxA = XMVectorSet( maxBoundsA.x, maxBoundsA.y, maxBoundsA.z, 0.0f ); - - XMVECTOR MinB = XMVectorSet( minBoundsB.x, minBoundsB.y, minBoundsB.z, 0.0f ); + + XMVECTOR MinB = XMVectorSet( minBoundsB.x, minBoundsB.y, minBoundsB.z, 0.0f ); XMVECTOR MaxB = XMVectorSet( maxBoundsB.x, maxBoundsB.y, maxBoundsB.z, 0.0f ); - // for each i in (x, y, z) if a_min(i) > b_max(i) or b_min(i) > a_max(i) then return FALSE - XMVECTOR Disjoint = XMVectorOrInt( XMVectorGreater( MinA, MaxB ), XMVectorGreater( MinB, MaxA ) ); + // for each i in (x, y, z) if a_min(i) > b_max(i) or b_min(i) > a_max(i) then return FALSE + XMVECTOR Disjoint = XMVectorOrInt( XMVectorGreater( MinA, MaxB ), XMVectorGreater( MinB, MaxA ) ); - return !XMVector3AnyTrue( Disjoint ); + return !XMVector3AnyTrue( Disjoint ); } // -------------------------------------------------------------------------------------- // Description: -// A ray AABB intersection check. +// A ray AABB intersection check. // Arguments: // minBounds, maxBounds - The min/max bounds of the AABB // rayOrigin, rayDir - The ray origin and direction (normalized) @@ -362,14 +364,14 @@ bool IntersectAxisAlignedBoxRay( const Vector3& minBounds, const Vector3& maxBou XMVECTOR minA = XMVectorSet( minBounds.x, minBounds.y, minBounds.z, 0.0f ); XMVECTOR maxA = XMVectorSet( maxBounds.x, maxBounds.y, maxBounds.z, 0.0f ); - + XMVECTOR invRayDir = XMVectorReciprocal( rayDir ); XMVECTOR t0 = ( minA - rayOrigin ) * invRayDir; XMVECTOR t1 = ( maxA - rayOrigin ) * invRayDir; XMVECTOR smallerIntersection = XMVectorMin( t0, t1 ); - XMVECTOR biggerIntersection = XMVectorMax( t0, t1); + XMVECTOR biggerIntersection = XMVectorMax( t0, t1 ); float minT = max( XMVectorGetX( smallerIntersection ), max( XMVectorGetY( smallerIntersection ), XMVectorGetZ( smallerIntersection ) ) ); float maxT = min( XMVectorGetX( biggerIntersection ), min( XMVectorGetY( biggerIntersection ), XMVectorGetZ( biggerIntersection ) ) ); @@ -378,18 +380,16 @@ bool IntersectAxisAlignedBoxRay( const Vector3& minBounds, const Vector3& maxBou return minT < maxT; } -bool IntersectOrientedBoxAxisAlignedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, - const Vector3& minBounds, const Vector3& maxBounds ) +bool IntersectOrientedBoxAxisAlignedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, const Vector3& minBounds, const Vector3& maxBounds ) { - Vector3 centerB = 0.5f * (maxBounds + minBounds); + Vector3 centerB = 0.5f * ( maxBounds + minBounds ); Vector3 extentsB = maxBounds - centerB; Quaternion orientationB( 0.0f, 0.0f, 0.0f, 1.0f ); return IntersectOrientedBoxOrientedBox( centerA, extentsA, orientationA, centerB, extentsB, orientationB ); } -bool IntersectOrientedBoxOrientedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, - const Vector3& centerB, const Vector3& extentsB, const Quaternion& orientationB ) +bool IntersectOrientedBoxOrientedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, const Vector3& centerB, const Vector3& extentsB, const Quaternion& orientationB ) { #define Permute0W1Z0Y0X XM_PERMUTE_0W, XM_PERMUTE_1Z, XM_PERMUTE_0Y, XM_PERMUTE_0X #define Permute0Z0W1X0Y XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_1X, XM_PERMUTE_0Y @@ -398,202 +398,202 @@ bool IntersectOrientedBoxOrientedBox( const Vector3& centerA, const Vector3& ext #define PermuteZWXY XM_PERMUTE_0Z, XM_PERMUTE_0W, XM_PERMUTE_0X, XM_PERMUTE_0Y #define PermuteYXWZ XM_PERMUTE_0Y, XM_PERMUTE_0X, XM_PERMUTE_0W, XM_PERMUTE_0Z - // Build the 3x3 rotation matrix that defines the orientation of B relative to A. + // Build the 3x3 rotation matrix that defines the orientation of B relative to A. XMVECTOR A_quat = XMVectorSet( orientationA.x, orientationA.y, orientationA.z, orientationA.w ); XMVECTOR B_quat = XMVectorSet( orientationB.x, orientationB.y, orientationB.z, orientationB.w ); - - assert( XMQuaternionIsUnit( A_quat ) ); - assert( XMQuaternionIsUnit( B_quat ) ); - XMVECTOR Q = XMQuaternionMultiply( A_quat, XMQuaternionConjugate( B_quat ) ); - XMMATRIX R = XMMatrixRotationQuaternion( Q ); + assert( XMQuaternionIsUnit( A_quat ) ); + assert( XMQuaternionIsUnit( B_quat ) ); + + XMVECTOR Q = XMQuaternionMultiply( A_quat, XMQuaternionConjugate( B_quat ) ); + XMMATRIX R = XMMatrixRotationQuaternion( Q ); - // Compute the translation of B relative to A. + // Compute the translation of B relative to A. XMVECTOR A_cent = XMVectorSet( centerA.x, centerA.y, centerA.z, 0.0f ); XMVECTOR B_cent = XMVectorSet( centerB.x, centerB.y, centerB.z, 0.0f ); - XMVECTOR t = XMVector3InverseRotate( B_cent - A_cent, A_quat ); - - // - // h(A) = extents of A. - // h(B) = extents of B. - // - // a(u) = axes of A = (1,0,0), (0,1,0), (0,0,1) - // b(u) = axes of B relative to A = (r00,r10,r20), (r01,r11,r21), (r02,r12,r22) - // - // For each possible separating axis l: - // d(A) = sum (for i = u,v,w) h(A)(i) * abs( a(i) dot l ) - // d(B) = sum (for i = u,v,w) h(B)(i) * abs( b(i) dot l ) - // if abs( t dot l ) > d(A) + d(B) then disjoint - // - - // Load extents of A and B. + XMVECTOR t = XMVector3InverseRotate( B_cent - A_cent, A_quat ); + + // + // h(A) = extents of A. + // h(B) = extents of B. + // + // a(u) = axes of A = (1,0,0), (0,1,0), (0,0,1) + // b(u) = axes of B relative to A = (r00,r10,r20), (r01,r11,r21), (r02,r12,r22) + // + // For each possible separating axis l: + // d(A) = sum (for i = u,v,w) h(A)(i) * abs( a(i) dot l ) + // d(B) = sum (for i = u,v,w) h(B)(i) * abs( b(i) dot l ) + // if abs( t dot l ) > d(A) + d(B) then disjoint + // + + // Load extents of A and B. XMVECTOR h_A = XMVectorSet( extentsA.x, extentsA.y, extentsA.z, 0.0f ); XMVECTOR h_B = XMVectorSet( extentsB.x, extentsB.y, extentsB.z, 0.0f ); - - // Rows. Note R[0,1,2]X.w = 0. - XMVECTOR R0X = R.r[0]; - XMVECTOR R1X = R.r[1]; - XMVECTOR R2X = R.r[2]; - - R = XMMatrixTranspose( R ); - - // Columns. Note RX[0,1,2].w = 0. - XMVECTOR RX0 = R.r[0]; - XMVECTOR RX1 = R.r[1]; - XMVECTOR RX2 = R.r[2]; - - // Absolute value of rows. - XMVECTOR AR0X = XMVectorAbs( R0X ); - XMVECTOR AR1X = XMVectorAbs( R1X ); - XMVECTOR AR2X = XMVectorAbs( R2X ); - - // Absolute value of columns. - XMVECTOR ARX0 = XMVectorAbs( RX0 ); - XMVECTOR ARX1 = XMVectorAbs( RX1 ); - XMVECTOR ARX2 = XMVectorAbs( RX2 ); - - // Test each of the 15 possible seperating axii. - XMVECTOR d, d_A, d_B; - - // l = a(u) = (1, 0, 0) - // t dot l = t.x - // d(A) = h(A).x - // d(B) = h(B) dot abs(r00, r01, r02) - d = XMVectorSplatX( t ); - d_A = XMVectorSplatX( h_A ); - d_B = XMVector3Dot( h_B, AR0X ); - XMVECTOR NoIntersection = XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ); - - // l = a(v) = (0, 1, 0) - // t dot l = t.y - // d(A) = h(A).y - // d(B) = h(B) dot abs(r10, r11, r12) - d = XMVectorSplatY( t ); - d_A = XMVectorSplatY( h_A ); - d_B = XMVector3Dot( h_B, AR1X ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(w) = (0, 0, 1) - // t dot l = t.z - // d(A) = h(A).z - // d(B) = h(B) dot abs(r20, r21, r22) - d = XMVectorSplatZ( t ); - d_A = XMVectorSplatZ( h_A ); - d_B = XMVector3Dot( h_B, AR2X ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = b(u) = (r00, r10, r20) - // d(A) = h(A) dot abs(r00, r10, r20) - // d(B) = h(B).x - d = XMVector3Dot( t, RX0 ); - d_A = XMVector3Dot( h_A, ARX0 ); - d_B = XMVectorSplatX( h_B ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = b(v) = (r01, r11, r21) - // d(A) = h(A) dot abs(r01, r11, r21) - // d(B) = h(B).y - d = XMVector3Dot( t, RX1 ); - d_A = XMVector3Dot( h_A, ARX1 ); - d_B = XMVectorSplatY( h_B ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = b(w) = (r02, r12, r22) - // d(A) = h(A) dot abs(r02, r12, r22) - // d(B) = h(B).z - d = XMVector3Dot( t, RX2 ); - d_A = XMVector3Dot( h_A, ARX2 ); - d_B = XMVectorSplatZ( h_B ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(u) x b(u) = (0, -r20, r10) - // d(A) = h(A) dot abs(0, r20, r10) - // d(B) = h(B) dot abs(0, r02, r01) - d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute0W1Z0Y0X ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteWZYX ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteWZYX ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(u) x b(v) = (0, -r21, r11) - // d(A) = h(A) dot abs(0, r21, r11) - // d(B) = h(B) dot abs(r02, 0, r00) - d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute0W1Z0Y0X ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteWZYX ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteZWXY ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(u) x b(w) = (0, -r22, r12) - // d(A) = h(A) dot abs(0, r22, r12) - // d(B) = h(B) dot abs(r01, r00, 0) - d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute0W1Z0Y0X ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteWZYX ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteYXWZ ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(v) x b(u) = (r20, 0, -r00) - // d(A) = h(A) dot abs(r20, 0, r00) - // d(B) = h(B) dot abs(0, r12, r11) - d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute0Z0W1X0Y ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteZWXY ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteWZYX ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(v) x b(v) = (r21, 0, -r01) - // d(A) = h(A) dot abs(r21, 0, r01) - // d(B) = h(B) dot abs(r12, 0, r10) - d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute0Z0W1X0Y ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteZWXY ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteZWXY ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(v) x b(w) = (r22, 0, -r02) - // d(A) = h(A) dot abs(r22, 0, r02) - // d(B) = h(B) dot abs(r11, r10, 0) - d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute0Z0W1X0Y ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteZWXY ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteYXWZ ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(w) x b(u) = (-r10, r00, 0) - // d(A) = h(A) dot abs(r10, r00, 0) - // d(B) = h(B) dot abs(0, r22, r21) - d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute1Y0X0W0Z ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteYXWZ ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteWZYX ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(w) x b(v) = (-r11, r01, 0) - // d(A) = h(A) dot abs(r11, r01, 0) - // d(B) = h(B) dot abs(r22, 0, r20) - d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute1Y0X0W0Z ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteYXWZ ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteZWXY ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // l = a(w) x b(w) = (-r12, r02, 0) - // d(A) = h(A) dot abs(r12, r02, 0) - // d(B) = h(B) dot abs(r21, r20, 0) - d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute1Y0X0W0Z ) ); - d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteYXWZ ) ); - d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteYXWZ ) ); - NoIntersection = XMVectorOrInt( NoIntersection, - XMVectorGreater( XMVectorAbs(d), XMVectorAdd( d_A, d_B ) ) ); - - // No seperating axis found, boxes must intersect. - return XMVector4NotEqualInt( NoIntersection, XMVectorTrueInt() ) != 0; + + // Rows. Note R[0,1,2]X.w = 0. + XMVECTOR R0X = R.r[0]; + XMVECTOR R1X = R.r[1]; + XMVECTOR R2X = R.r[2]; + + R = XMMatrixTranspose( R ); + + // Columns. Note RX[0,1,2].w = 0. + XMVECTOR RX0 = R.r[0]; + XMVECTOR RX1 = R.r[1]; + XMVECTOR RX2 = R.r[2]; + + // Absolute value of rows. + XMVECTOR AR0X = XMVectorAbs( R0X ); + XMVECTOR AR1X = XMVectorAbs( R1X ); + XMVECTOR AR2X = XMVectorAbs( R2X ); + + // Absolute value of columns. + XMVECTOR ARX0 = XMVectorAbs( RX0 ); + XMVECTOR ARX1 = XMVectorAbs( RX1 ); + XMVECTOR ARX2 = XMVectorAbs( RX2 ); + + // Test each of the 15 possible seperating axii. + XMVECTOR d, d_A, d_B; + + // l = a(u) = (1, 0, 0) + // t dot l = t.x + // d(A) = h(A).x + // d(B) = h(B) dot abs(r00, r01, r02) + d = XMVectorSplatX( t ); + d_A = XMVectorSplatX( h_A ); + d_B = XMVector3Dot( h_B, AR0X ); + XMVECTOR NoIntersection = XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ); + + // l = a(v) = (0, 1, 0) + // t dot l = t.y + // d(A) = h(A).y + // d(B) = h(B) dot abs(r10, r11, r12) + d = XMVectorSplatY( t ); + d_A = XMVectorSplatY( h_A ); + d_B = XMVector3Dot( h_B, AR1X ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(w) = (0, 0, 1) + // t dot l = t.z + // d(A) = h(A).z + // d(B) = h(B) dot abs(r20, r21, r22) + d = XMVectorSplatZ( t ); + d_A = XMVectorSplatZ( h_A ); + d_B = XMVector3Dot( h_B, AR2X ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = b(u) = (r00, r10, r20) + // d(A) = h(A) dot abs(r00, r10, r20) + // d(B) = h(B).x + d = XMVector3Dot( t, RX0 ); + d_A = XMVector3Dot( h_A, ARX0 ); + d_B = XMVectorSplatX( h_B ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = b(v) = (r01, r11, r21) + // d(A) = h(A) dot abs(r01, r11, r21) + // d(B) = h(B).y + d = XMVector3Dot( t, RX1 ); + d_A = XMVector3Dot( h_A, ARX1 ); + d_B = XMVectorSplatY( h_B ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = b(w) = (r02, r12, r22) + // d(A) = h(A) dot abs(r02, r12, r22) + // d(B) = h(B).z + d = XMVector3Dot( t, RX2 ); + d_A = XMVector3Dot( h_A, ARX2 ); + d_B = XMVectorSplatZ( h_B ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(u) x b(u) = (0, -r20, r10) + // d(A) = h(A) dot abs(0, r20, r10) + // d(B) = h(B) dot abs(0, r02, r01) + d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute0W1Z0Y0X ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteWZYX ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteWZYX ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(u) x b(v) = (0, -r21, r11) + // d(A) = h(A) dot abs(0, r21, r11) + // d(B) = h(B) dot abs(r02, 0, r00) + d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute0W1Z0Y0X ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteWZYX ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteZWXY ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(u) x b(w) = (0, -r22, r12) + // d(A) = h(A) dot abs(0, r22, r12) + // d(B) = h(B) dot abs(r01, r00, 0) + d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute0W1Z0Y0X ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteWZYX ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR0X, AR0X, PermuteYXWZ ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(v) x b(u) = (r20, 0, -r00) + // d(A) = h(A) dot abs(r20, 0, r00) + // d(B) = h(B) dot abs(0, r12, r11) + d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute0Z0W1X0Y ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteZWXY ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteWZYX ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(v) x b(v) = (r21, 0, -r01) + // d(A) = h(A) dot abs(r21, 0, r01) + // d(B) = h(B) dot abs(r12, 0, r10) + d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute0Z0W1X0Y ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteZWXY ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteZWXY ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(v) x b(w) = (r22, 0, -r02) + // d(A) = h(A) dot abs(r22, 0, r02) + // d(B) = h(B) dot abs(r11, r10, 0) + d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute0Z0W1X0Y ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteZWXY ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR1X, AR1X, PermuteYXWZ ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(w) x b(u) = (-r10, r00, 0) + // d(A) = h(A) dot abs(r10, r00, 0) + // d(B) = h(B) dot abs(0, r22, r21) + d = XMVector3Dot( t, XMVectorPermute( RX0, -RX0, Permute1Y0X0W0Z ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX0, ARX0, PermuteYXWZ ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteWZYX ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(w) x b(v) = (-r11, r01, 0) + // d(A) = h(A) dot abs(r11, r01, 0) + // d(B) = h(B) dot abs(r22, 0, r20) + d = XMVector3Dot( t, XMVectorPermute( RX1, -RX1, Permute1Y0X0W0Z ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX1, ARX1, PermuteYXWZ ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteZWXY ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // l = a(w) x b(w) = (-r12, r02, 0) + // d(A) = h(A) dot abs(r12, r02, 0) + // d(B) = h(B) dot abs(r21, r20, 0) + d = XMVector3Dot( t, XMVectorPermute( RX2, -RX2, Permute1Y0X0W0Z ) ); + d_A = XMVector3Dot( h_A, XMVectorPermute( ARX2, ARX2, PermuteYXWZ ) ); + d_B = XMVector3Dot( h_B, XMVectorPermute( AR2X, AR2X, PermuteYXWZ ) ); + NoIntersection = XMVectorOrInt( NoIntersection, + XMVectorGreater( XMVectorAbs( d ), XMVectorAdd( d_A, d_B ) ) ); + + // No seperating axis found, boxes must intersect. + return XMVector4NotEqualInt( NoIntersection, XMVectorTrueInt() ) != 0; } bool IntersectTriangleOrientedBox( const Vector3* triangleVertices, const Matrix& invOrientedBox ) @@ -604,15 +604,15 @@ bool IntersectTriangleOrientedBox( const Vector3* triangleVertices, const Matrix if( ( v[0].x < -1.f ) && ( v[1].x < -1.f ) && ( v[2].x < -1.f ) ) return false; - if( ( v[0].x > 1.f ) && ( v[1].x > 1.f ) && ( v[2].x > 1.f ) ) + if( ( v[0].x > 1.f ) && ( v[1].x > 1.f ) && ( v[2].x > 1.f ) ) return false; if( ( v[0].y < -1.f ) && ( v[1].y < -1.f ) && ( v[2].y < -1.f ) ) return false; - if( ( v[0].y > 1.f ) && ( v[1].y > 1.f ) && ( v[2].y > 1.f ) ) + if( ( v[0].y > 1.f ) && ( v[1].y > 1.f ) && ( v[2].y > 1.f ) ) return false; if( ( v[0].z < -1.f ) && ( v[1].z < -1.f ) && ( v[2].z < -1.f ) ) return false; - if( ( v[0].z > 1.f ) && ( v[1].z > 1.f ) && ( v[2].z > 1.f ) ) + if( ( v[0].z > 1.f ) && ( v[1].z > 1.f ) && ( v[2].z > 1.f ) ) return false; return true; @@ -620,7 +620,7 @@ bool IntersectTriangleOrientedBox( const Vector3* triangleVertices, const Matrix // -------------------------------------------------------------------------------------- // Description: -// A quick pre-test for triangle-AABB intersection. Can return false-positive answers. +// A quick pre-test for triangle-AABB intersection. Can return false-positive answers. // Arguments: // v0, v1, v2 - Triangle vertex positions // min, max - AABB @@ -628,10 +628,10 @@ bool IntersectTriangleOrientedBox( const Vector3* triangleVertices, const Matrix // false if triangle does not intersect AABB // true if triangle may intersect AABB // -------------------------------------------------------------------------------------- -bool IntersectTriangleAABB( const Vector3* v0, - const Vector3* v1, - const Vector3* v2, - const Vector3& min, +bool IntersectTriangleAABB( const Vector3* v0, + const Vector3* v1, + const Vector3* v2, + const Vector3& min, const Vector3& max ) { if( ( v0->x < min.x ) && ( v1->x < min.x ) && ( v2->x < min.x ) ) @@ -656,7 +656,7 @@ namespace // -------------------------------------------------------------------------------------- // Description: // A helper function to test separating plane at a cross product between triangle edge -// and one of sides of a unit AABB. +// and one of sides of a unit AABB. // Return Value: // false if separating plane was found // true otherwise @@ -677,7 +677,7 @@ inline bool AxisTest( float a, float b, float fa, float fb, const Vector3& v0, c // -------------------------------------------------------------------------------------- // Description: -// Checks if a triangle intersects an oriented bounding box. +// Checks if a triangle intersects an oriented bounding box. // Arguments: // v0, v1, v2 - Triangle vertex positions // invOrientedBox - Inverse transform of a box (-1, -1, -1) - (1, 1, 1) @@ -685,9 +685,9 @@ inline bool AxisTest( float a, float b, float fa, float fb, const Vector3& v0, c // false if triangle does not intersect the box // true if triangle intersects the box // -------------------------------------------------------------------------------------- -bool IntersectTriangleOrientedBox( const Vector3* v0, - const Vector3* v1, - const Vector3* v2, +bool IntersectTriangleOrientedBox( const Vector3* v0, + const Vector3* v1, + const Vector3* v2, const Matrix& invOrientedBox ) { // put triangle points in "inverse bounding box" space @@ -699,15 +699,15 @@ bool IntersectTriangleOrientedBox( const Vector3* v0, // checks box sides as separating plane if( ( v[0].x < -1.f ) && ( v[1].x < -1.f ) && ( v[2].x < -1.f ) ) return false; - if( ( v[0].x > 1.f ) && ( v[1].x > 1.f ) && ( v[2].x > 1.f ) ) + if( ( v[0].x > 1.f ) && ( v[1].x > 1.f ) && ( v[2].x > 1.f ) ) return false; if( ( v[0].y < -1.f ) && ( v[1].y < -1.f ) && ( v[2].y < -1.f ) ) return false; - if( ( v[0].y > 1.f ) && ( v[1].y > 1.f ) && ( v[2].y > 1.f ) ) + if( ( v[0].y > 1.f ) && ( v[1].y > 1.f ) && ( v[2].y > 1.f ) ) return false; if( ( v[0].z < -1.f ) && ( v[1].z < -1.f ) && ( v[2].z < -1.f ) ) return false; - if( ( v[0].z > 1.f ) && ( v[1].z > 1.f ) && ( v[2].z > 1.f ) ) + if( ( v[0].z > 1.f ) && ( v[1].z > 1.f ) && ( v[2].z > 1.f ) ) return false; Vector3 e0 = v[1] - v[0]; @@ -797,15 +797,15 @@ bool IntersectTriangleOrientedBox( const Vector3* v0, bool IsBoundingBoxEmpty( const Vector3& min, const Vector3& max ) { - for( int i = 0; i < 3; ++i ) - { - if( max[i] <= min[i] ) - { - return true; - } - } - - return false; + for( int i = 0; i < 3; ++i ) + { + if( max[i] <= min[i] ) + { + return true; + } + } + + return false; } Vector3 ClosestPointToBoundingBox( const Vector3& min, const Vector3& max, const Vector3& point ) { diff --git a/trinity/Utilities/BoundingBox.h b/trinity/Utilities/BoundingBox.h index b38823fea..6b057dd2b 100644 --- a/trinity/Utilities/BoundingBox.h +++ b/trinity/Utilities/BoundingBox.h @@ -32,26 +32,23 @@ void BoundingBoxTransform( Vector3& min, Vector3& max, const Matrix& tf ); // and projection matrices, along with a viewport. void BoundingBoxProject( Vector3& min, Vector3& max, const Matrix& proj, const Matrix& view, const TriViewport& vp ); -bool IntersectAxisAlignedBoxAxisAlignedBox( const Vector3& minBoundsA, const Vector3& maxBoundsA, - const Vector3& minBoundsB, const Vector3& maxBoundsB ); -bool IntersectOrientedBoxAxisAlignedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, - const Vector3& minBounds, const Vector3& maxBounds ); -bool IntersectOrientedBoxOrientedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, - const Vector3& centerB, const Vector3& extentsB, const Quaternion& orientationB ); +bool IntersectAxisAlignedBoxAxisAlignedBox( const Vector3& minBoundsA, const Vector3& maxBoundsA, const Vector3& minBoundsB, const Vector3& maxBoundsB ); +bool IntersectOrientedBoxAxisAlignedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, const Vector3& minBounds, const Vector3& maxBounds ); +bool IntersectOrientedBoxOrientedBox( const Vector3& centerA, const Vector3& extentsA, const Quaternion& orientationA, const Vector3& centerB, const Vector3& extentsB, const Quaternion& orientationB ); bool IntersectAxisAlignedBoxRay( const Vector3& minBounds, const Vector3& maxBounds, const Vector3& rayOrigin, const Vector3& rayDir, Vector3& intersection ); -bool IntersectTriangleOrientedBox(const Vector3* triangleVertices, const Matrix& invOrientedBox ); +bool IntersectTriangleOrientedBox( const Vector3* triangleVertices, const Matrix& invOrientedBox ); -bool IntersectTriangleOrientedBox( const Vector3* v0, - const Vector3* v1, - const Vector3* v2, +bool IntersectTriangleOrientedBox( const Vector3* v0, + const Vector3* v1, + const Vector3* v2, const Matrix& invOrientedBox ); -bool IntersectTriangleAABB( const Vector3* v0, - const Vector3* v1, - const Vector3* v2, - const Vector3& min, +bool IntersectTriangleAABB( const Vector3* v0, + const Vector3* v1, + const Vector3* v2, + const Vector3& min, const Vector3& max ); bool IsBoundingBoxEmpty( const Vector3& min, const Vector3& max ); diff --git a/trinity/Utilities/BoundingSphere.cpp b/trinity/Utilities/BoundingSphere.cpp index 76185e89f..deb7ac2dd 100644 --- a/trinity/Utilities/BoundingSphere.cpp +++ b/trinity/Utilities/BoundingSphere.cpp @@ -15,7 +15,7 @@ bool BoundingSphereIsInside( const Vector4& sphere, const Vector3& pos ) { const float radiusEpsilon = 1e-4f; - Vector3 delta = pos - ( const Vector3& )sphere; + Vector3 delta = pos - (const Vector3&)sphere; return ( LengthSq( delta ) <= sphere.w * sphere.w + radiusEpsilon ); } @@ -26,7 +26,7 @@ bool BoundingSphereIsSphereInside( const Vector4& parentSphere, const Vector4& t { return false; } - Vector3 delta = ( const Vector3& )testSphere - ( const Vector3& )parentSphere; + Vector3 delta = (const Vector3&)testSphere - (const Vector3&)parentSphere; return ( LengthSq( delta ) <= ( parentSphere.w - testSphere.w ) * ( parentSphere.w - testSphere.w ) ); } @@ -39,10 +39,10 @@ void BoundingSphereUpdate( const Vector3& pos, Vector4& sphere ) } // extend sphere - Vector3 delta = pos - ( Vector3& )sphere; + Vector3 delta = pos - (Vector3&)sphere; float deltaLen = Length( delta ); - ( Vector3& )sphere += 0.5f * ( 1.f - sphere.w / deltaLen ) * delta; + (Vector3&)sphere += 0.5f * ( 1.f - sphere.w / deltaLen ) * delta; sphere.w = 0.5f * ( sphere.w + deltaLen ); } @@ -60,10 +60,10 @@ void BoundingSphereUpdate( const Vector4& addSphere, Vector4& resultSphere ) } // extend sphere - Vector3 delta = ( Vector3& )addSphere - ( Vector3& )resultSphere; + Vector3 delta = (Vector3&)addSphere - (Vector3&)resultSphere; float deltaLen = Length( delta ); - ( Vector3& )resultSphere += 0.5f * ( 1.f + ( addSphere.w - resultSphere.w ) / deltaLen ) * delta; + (Vector3&)resultSphere += 0.5f * ( 1.f + ( addSphere.w - resultSphere.w ) / deltaLen ) * delta; resultSphere.w = 0.5f * ( resultSphere.w + addSphere.w + deltaLen ); } @@ -163,7 +163,7 @@ bool IntersectEllipsoidRayClosest( Vector3& out, const Vector3& ellipsoidCenter, pq = sqrt( pq ); float t1 = -pq - ( v_s / v_v ); float t2 = pq - ( v_s / v_v ); - + float minT = abs( t1 ) < abs( t2 ) ? t1 : t2; out = minT * rayDir + rayOrigin; return true; @@ -296,66 +296,59 @@ void BoundingSphereFromPoints( Vector4d& sphere, Vector3 const** points, size_t // init bounding sphere sphere = Vector4d( 0.0, 0.0, 0.0, 0.0 ); break; - case 1: - { - sphere = Vector4d( *points[0], (float)radiusEpsilon ); - } - break; - case 2: + case 1: { + sphere = Vector4d( *points[0], (float)radiusEpsilon ); + } + break; + case 2: { + // simple sphere srounf 2 points + Vector3d a = 0.5 * ( Vector3d( *points[1] ) - Vector3d( *points[0] ) ); + sphere = Vector4d( a + Vector3d( *points[0] ), Length( a ) + radiusEpsilon ); + } + break; + case 3: { + Vector3d a = Vector3d( *points[1] ) - Vector3d( *points[0] ); + Vector3d b = Vector3d( *points[2] ) - Vector3d( *points[0] ); + Vector3d axb, axbxa, bxaxb; + axb = Cross( a, b ); + axbxa = Cross( axb, a ); + bxaxb = Cross( b, axb ); + double denom = 2.0 * Dot( axb, axb ); + if( denom == 0.0 ) { - // simple sphere srounf 2 points - Vector3d a = 0.5 * ( Vector3d( *points[1] ) - Vector3d( *points[0] ) ); - sphere = Vector4d( a + Vector3d( *points[0] ), Length( a ) + radiusEpsilon ); + // fail, must try with two points + CCP_LOGWARN( "BoundingSphereFromPoints: failed because denominator is zero! Using fallback..." ); + return BoundingSphereFromPoints( sphere, points, 2 ); } - break; - case 3: + double a2 = Dot( a, a ); + double b2 = Dot( b, b ); + Vector3d o = ( b2 * axbxa + a2 * bxaxb ) / denom; + sphere = Vector4d( o + Vector3d( *points[0] ), Length( o ) + radiusEpsilon ); + } + break; + case 4: { + Vector3d a = Vector3d( *points[1] ) - Vector3d( *points[0] ); + Vector3d b = Vector3d( *points[2] ) - Vector3d( *points[0] ); + Vector3d c = Vector3d( *points[3] ) - Vector3d( *points[0] ); + double denom = 2.0 * ( a.x * ( b.y * c.z - c.y * b.z ) - b.x * ( a.y * c.z - c.y * a.z ) + c.x * ( a.y * b.z - b.y * a.z ) ); + if( denom == 0.0 ) { - Vector3d a = Vector3d( *points[1] ) - Vector3d( *points[0] ); - Vector3d b = Vector3d( *points[2] ) - Vector3d( *points[0] ); - Vector3d axb, axbxa, bxaxb; - axb = Cross( a, b ); - axbxa = Cross( axb, a ); - bxaxb = Cross( b, axb ); - double denom = 2.0 * Dot( axb, axb ); - if( denom == 0.0 ) - { - // fail, must try with two points - CCP_LOGWARN("BoundingSphereFromPoints: failed because denominator is zero! Using fallback..."); - return BoundingSphereFromPoints( sphere, points, 2 ); - } - double a2 = Dot( a, a ); - double b2 = Dot( b, b ); - Vector3d o = ( b2 * axbxa + a2 * bxaxb ) / denom; - sphere = Vector4d( o + Vector3d( *points[0] ), Length( o ) + radiusEpsilon ); + // fail, must try with three points + CCP_LOGWARN( "BoundingSphereFromPoints: failed because denominator is zero! Using fallback..." ); + return BoundingSphereFromPoints( sphere, points, 3 ); } - break; - case 4: - { - Vector3d a = Vector3d( *points[1] ) - Vector3d( *points[0] ); - Vector3d b = Vector3d( *points[2] ) - Vector3d( *points[0] ); - Vector3d c = Vector3d( *points[3] ) - Vector3d( *points[0] ); - double denom = 2.0 * ( a.x * (b.y * c.z - c.y * b.z) - b.x * (a.y * c.z - c.y * a.z) + c.x * (a.y * b.z - b.y * a.z) ); - if( denom == 0.0 ) - { - // fail, must try with three points - CCP_LOGWARN("BoundingSphereFromPoints: failed because denominator is zero! Using fallback..."); - return BoundingSphereFromPoints( sphere, points, 3 ); - } - double a2 = Dot( a, a ); - double b2 = Dot( b, b ); - double c2 = Dot( c, c ); - Vector3d axb = Cross( a, b ); - Vector3d cxa = Cross( c, a ); - Vector3d bxc = Cross( b, c ); - Vector3d o = ( c2 * axb + b2 * cxa + a2 * bxc ) / denom; - sphere = Vector4d( o + Vector3d( *points[0] ), Length( o ) + radiusEpsilon ); + double a2 = Dot( a, a ); + double b2 = Dot( b, b ); + double c2 = Dot( c, c ); + Vector3d axb = Cross( a, b ); + Vector3d cxa = Cross( c, a ); + Vector3d bxc = Cross( b, c ); + Vector3d o = ( c2 * axb + b2 * cxa + a2 * bxc ) / denom; + sphere = Vector4d( o + Vector3d( *points[0] ), Length( o ) + radiusEpsilon ); } - break; + break; default: sphere = recurBoundingSphereCreate( points, pointsCount, 0 ); break; } } - - - diff --git a/trinity/Utilities/BoundingSphere.h b/trinity/Utilities/BoundingSphere.h index a148e3023..0e36aa684 100644 --- a/trinity/Utilities/BoundingSphere.h +++ b/trinity/Utilities/BoundingSphere.h @@ -5,7 +5,10 @@ #define BoundingSphere_H // helper functions to deal with bounding spheres -inline const Vector3& BoundingSphereGetCenter( const Vector4& sphere ) { return ( const Vector3& )sphere; } +inline const Vector3& BoundingSphereGetCenter( const Vector4& sphere ) +{ + return (const Vector3&)sphere; +} void BoundingSphereInitialize( Vector4& sphere ); bool BoundingSphereIsInside( const Vector4& sphere, const Vector3& pos ); bool BoundingSphereIsSphereInside( const Vector4& parentSphere, const Vector4& testSphere ); diff --git a/trinity/Utilities/GeometryUtils.cpp b/trinity/Utilities/GeometryUtils.cpp index 924181346..a8c8101e1 100644 --- a/trinity/Utilities/GeometryUtils.cpp +++ b/trinity/Utilities/GeometryUtils.cpp @@ -8,23 +8,23 @@ #include #if WITH_GRANNY -void GetVertexPositionOffsetAndType(granny_mesh* grannyMesh, unsigned int &positionOffset, Tr2VertexDefinition::DataType &positionType ) +void GetVertexPositionOffsetAndType( granny_mesh* grannyMesh, unsigned int& positionOffset, Tr2VertexDefinition::DataType& positionType ) { positionOffset = 0; positionType = Tr2VertexDefinition::DT_UNKNOWN_TYPE; - if ( !grannyMesh ) - { + if( !grannyMesh ) + { return; } granny_data_type_definition* grannyVertexDecl = grannyMesh->PrimaryVertexData->VertexType; - if ( !grannyVertexDecl ) + if( !grannyVertexDecl ) { return; } - + while( grannyVertexDecl->Type != GrannyEndMember ) { if( !strcmp( grannyVertexDecl->Name, GrannyVertexPositionName ) ) @@ -41,19 +41,19 @@ void GetVertexPositionOffsetAndType(granny_mesh* grannyMesh, unsigned int &posit } #endif -void ConvertShort4ToVector3( const void *ptr, Vector3* dest ) +void ConvertShort4ToVector3( const void* ptr, Vector3* dest ) { - short *vdata = (short*)(ptr); + short* vdata = (short*)( ptr ); float rcp = 1.0f / (float)vdata[3]; dest->x = (float)vdata[0] * rcp; dest->y = (float)vdata[1] * rcp; dest->z = (float)vdata[2] * rcp; } -void ConvertUByte4ToVector3( const void *ptr, Vector3* dest ) +void ConvertUByte4ToVector3( const void* ptr, Vector3* dest ) { - unsigned char * vdata = (unsigned char *)(ptr); - + unsigned char* vdata = (unsigned char*)( ptr ); + dest->x = (float)vdata[2] / 255.0f * 2.0f - 1.0f; dest->y = (float)vdata[1] / 255.0f * 2.0f - 1.0f; dest->z = (float)vdata[0] / 255.0f * 2.0f - 1.0f; @@ -61,18 +61,14 @@ void ConvertUByte4ToVector3( const void *ptr, Vector3* dest ) #if WITH_GRANNY -void GetMeshVertexPosition( granny_mesh* grannyMesh, unsigned index, - Vector3 & position, - unsigned grannyBytesPerVertex, - unsigned positionOffset, - Tr2VertexDefinition::DataType positionType ) -{ +void GetMeshVertexPosition( granny_mesh* grannyMesh, unsigned index, Vector3& position, unsigned grannyBytesPerVertex, unsigned positionOffset, Tr2VertexDefinition::DataType positionType ) +{ if( !grannyBytesPerVertex ) { return; } - granny_uint8 *positionPtr = grannyMesh->PrimaryVertexData->Vertices + index * grannyBytesPerVertex + positionOffset; + granny_uint8* positionPtr = grannyMesh->PrimaryVertexData->Vertices + index * grannyBytesPerVertex + positionOffset; switch( positionType ) { @@ -86,18 +82,22 @@ void GetMeshVertexPosition( granny_mesh* grannyMesh, unsigned index, case Tr2VertexDefinition::SHORT_4: ConvertShort4ToVector3( positionPtr, &position ); - break; + break; default: CCP_ASSERT_M( false, "Unsupported position type in GetMeshVertexPosition" ); break; - } + } } #endif const char* VertexDeclTypeToString( Tr2VertexDefinition::DataType type ) { -#define VD_CASE(x) case Tr2VertexDefinition:: x : { static const char* text = #x ; return text; } +#define VD_CASE( x ) \ + case Tr2VertexDefinition::x: { \ + static const char* text = #x; \ + return text; \ + } switch( type ) { @@ -130,7 +130,7 @@ const char* VertexDeclTypeToString( Tr2VertexDefinition::DataType type ) VD_CASE( UINT32_2 ); VD_CASE( UINT32_3 ); VD_CASE( UINT32_4 ); - + VD_CASE( FLOAT16_1 ); VD_CASE( FLOAT16_2 ); VD_CASE( FLOAT16_3 ); @@ -140,7 +140,7 @@ const char* VertexDeclTypeToString( Tr2VertexDefinition::DataType type ) VD_CASE( UFLOAT16_2 ); VD_CASE( UFLOAT16_3 ); VD_CASE( UFLOAT16_4 ); - + VD_CASE( FLOAT32_1 ); VD_CASE( FLOAT32_2 ); VD_CASE( FLOAT32_3 ); @@ -157,11 +157,10 @@ const char* VertexDeclTypeToString( Tr2VertexDefinition::DataType type ) VD_CASE( SHORT_4_NORM ); VD_CASE( USHORT_4_NORM ); - default: - static const char* text = "Unknown"; - return text; + default: + static const char* text = "Unknown"; + return text; } - } const char* VertexDeclUsageToString( Tr2VertexDefinition::UsageCode usage ) @@ -177,7 +176,7 @@ const char* VertexDeclUsageToString( Tr2VertexDefinition::UsageCode usage ) "BLENDWEIGHTS" }; - return map[ usage ]; + return map[usage]; } void DescribeVertexDecl( unsigned int decl ) @@ -187,7 +186,7 @@ void DescribeVertexDecl( unsigned int decl ) if( !result ) { - CCP_LOG( "Invalid vertex declaration"); + CCP_LOG( "Invalid vertex declaration" ); return; } @@ -216,7 +215,7 @@ granny_file* ProtectedGrannyReadEntireFileFromMemory( const wchar_t* path, uint3 } #ifdef _MSC_VER __except( EXCEPTION_EXECUTE_HANDLER ) - { + { CCP_LOGERR( "Exception caught while reading Granny file %S", path ); CCP_LOGERR( "Files might be corrupt - try running the repair tool" ); } diff --git a/trinity/Utilities/GeometryUtils.h b/trinity/Utilities/GeometryUtils.h index cf335e049..934905f28 100644 --- a/trinity/Utilities/GeometryUtils.h +++ b/trinity/Utilities/GeometryUtils.h @@ -12,12 +12,12 @@ void DescribeVertexDecl( unsigned int decl ); void DescribeVertexDecl( const Tr2VertexDefinition& vd ); #if WITH_GRANNY -void GetVertexPositionOffsetAndType(granny_mesh* grannyMesh, unsigned int &positionOffset, Tr2VertexDefinition::DataType &positionType); -void GetMeshVertexPosition(granny_mesh* grannyMesh, unsigned int index, Vector3 &p, unsigned int bytesPerVertex, unsigned int positionOffset, Tr2VertexDefinition::DataType positionType); +void GetVertexPositionOffsetAndType( granny_mesh* grannyMesh, unsigned int& positionOffset, Tr2VertexDefinition::DataType& positionType ); +void GetMeshVertexPosition( granny_mesh* grannyMesh, unsigned int index, Vector3& p, unsigned int bytesPerVertex, unsigned int positionOffset, Tr2VertexDefinition::DataType positionType ); #endif -void ConvertShort4ToVector3( const void * src, Vector3* dest ); -void ConvertUByte4ToVector3( const void * src, Vector3* dest ); +void ConvertShort4ToVector3( const void* src, Vector3* dest ); +void ConvertUByte4ToVector3( const void* src, Vector3* dest ); #if WITH_GRANNY // Read a Granny file inside a structured exception handler. diff --git a/trinity/Utilities/GrannyCurveHelpers.h b/trinity/Utilities/GrannyCurveHelpers.h index 14a9c1f02..4411d12fa 100644 --- a/trinity/Utilities/GrannyCurveHelpers.h +++ b/trinity/Utilities/GrannyCurveHelpers.h @@ -7,18 +7,18 @@ #if WITH_GRANNY #include "granny.h" -template - void GetKeyFrameAtT( granny_curve2* curve, double time, T& value, double duration ) - { - granny_curve_data_da_keyframes32f* keyframedCurve = reinterpret_cast( curve->CurveData.Object ); +template +void GetKeyFrameAtT( granny_curve2* curve, double time, T& value, double duration ) +{ + granny_curve_data_da_keyframes32f* keyframedCurve = reinterpret_cast( curve->CurveData.Object ); - CCP_ASSERT( keyframedCurve->Dimension == sizeof( T ) / 4 ); + CCP_ASSERT( keyframedCurve->Dimension == sizeof( T ) / 4 ); - int numFrames = keyframedCurve->ControlCount / keyframedCurve->Dimension; - int frame = int(float(numFrames) * time / duration); - T* keys = reinterpret_cast( keyframedCurve->Controls ); - value = keys[frame]; - } + int numFrames = keyframedCurve->ControlCount / keyframedCurve->Dimension; + int frame = int( float( numFrames ) * time / duration ); + T* keys = reinterpret_cast( keyframedCurve->Controls ); + value = keys[frame]; +} #endif #endif \ No newline at end of file diff --git a/trinity/Utilities/MatrixUtils.cpp b/trinity/Utilities/MatrixUtils.cpp index ac89500c6..e15b29c2a 100644 --- a/trinity/Utilities/MatrixUtils.cpp +++ b/trinity/Utilities/MatrixUtils.cpp @@ -22,10 +22,7 @@ Float4x3::Float4x3( const Matrix& m ) Float4x3::operator Matrix() const { return Matrix( - elements[0], elements[4], elements[8], 0.0f, - elements[1], elements[5], elements[9], 0.0f, - elements[2], elements[6], elements[10], 0.0f, - elements[3], elements[7], elements[11], 1.0f ); + elements[0], elements[4], elements[8], 0.0f, elements[1], elements[5], elements[9], 0.0f, elements[2], elements[6], elements[10], 0.0f, elements[3], elements[7], elements[11], 1.0f ); } void DeconstructProjectionMatrix( const Matrix& proj, float& asp, float& fov, float& frontClip, float& backClip ) @@ -33,15 +30,15 @@ void DeconstructProjectionMatrix( const Matrix& proj, float& asp, float& fov, fl // Use the fact that: // aspect = m_22 / m_11; // m_33 = z_f/(z_f-z_n), m_43 = -z_n*z_f/(z_f-z_n) - // => front = z_n = -m_43/m_33 + // => front = z_n = -m_43/m_33 // => back = z_f = -m_43/(1+m_43/z_n) // m_22 = cotan(fov/2) = 1 / tan(fov/2) - // => fov = 2*tan(1/m_22) - asp = (proj._11 ? proj._22/proj._11 : 0.0f); - fov = (proj._22 ? 2.0f*atan(1.0f/proj._22) : 0.0f); + // => fov = 2*tan(1/m_22) + asp = ( proj._11 ? proj._22 / proj._11 : 0.0f ); + fov = ( proj._22 ? 2.0f * atan( 1.0f / proj._22 ) : 0.0f ); - frontClip = (proj._33 ? proj._43/proj._33 : 0.0f); - backClip = frontClip*proj._33/(proj._33+1); + frontClip = ( proj._33 ? proj._43 / proj._33 : 0.0f ); + backClip = frontClip * proj._33 / ( proj._33 + 1 ); } #if WITH_GRANNY diff --git a/trinity/Utilities/Obb.cpp b/trinity/Utilities/Obb.cpp index 09264f494..b5701d274 100644 --- a/trinity/Utilities/Obb.cpp +++ b/trinity/Utilities/Obb.cpp @@ -30,10 +30,10 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, center = Vector3( centerWorld.x, centerWorld.y, centerWorld.z ); - sizes = 0.5 * ( max - min ); - x = Vector3( localToWorld._11, localToWorld._12, localToWorld._13 ); - y = Vector3( localToWorld._21, localToWorld._22, localToWorld._23 ); - z = Vector3( localToWorld._31, localToWorld._32, localToWorld._33 ); + sizes = 0.5 * ( max - min ); + x = Vector3( localToWorld._11, localToWorld._12, localToWorld._13 ); + y = Vector3( localToWorld._21, localToWorld._22, localToWorld._23 ); + z = Vector3( localToWorld._31, localToWorld._32, localToWorld._33 ); if( !frustum ) { @@ -49,56 +49,74 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, // sequence: -X, +X, -Y, +Y, -Z, +Z for( unsigned side = 0; side != 6; ++side ) { - unsigned pt[4]; // bitmasks of points wanted, bits are 00000ZYX, not set = negative, set = positive side. - Vector3 rayDir; // direction of the ray to raycast with; ie the direction along which we try to move an OBB side + unsigned pt[4]; // bitmasks of points wanted, bits are 00000ZYX, not set = negative, set = positive side. + Vector3 rayDir; // direction of the ray to raycast with; ie the direction along which we try to move an OBB side switch( side ) { - // -X, so bit 0 zero - case 0: - pt[0] = 0; pt[1] = 2; pt[2] = 4; pt[3] = 6; - rayDir = x; - break; - - // +X, so bit 0 set - case 1: - pt[0] = 1; pt[1] = 3; pt[2] = 5; pt[3] = 7; - rayDir = -x; - break; - - // -Y, so bit 1 zero - case 2: - pt[0] = 0; pt[1] = 1; pt[2] = 4; pt[3] = 5; - rayDir = y; - break; - - // +Y, so bit 1 set - case 3: - pt[0] = 2; pt[1] = 3; pt[2] = 6; pt[3] = 7; - rayDir = -y; - break; - - // -Z, so bit 2 zero - case 4: - pt[0] = 0; pt[1] = 1; pt[2] = 3; pt[3] = 4; - rayDir = z; - break; - - // +Z, so bit 2 set - case 5: - pt[0] = 4; pt[1] = 5; pt[2] = 6; pt[3] = 7; - rayDir = -z; - break; + // -X, so bit 0 zero + case 0: + pt[0] = 0; + pt[1] = 2; + pt[2] = 4; + pt[3] = 6; + rayDir = x; + break; + + // +X, so bit 0 set + case 1: + pt[0] = 1; + pt[1] = 3; + pt[2] = 5; + pt[3] = 7; + rayDir = -x; + break; + + // -Y, so bit 1 zero + case 2: + pt[0] = 0; + pt[1] = 1; + pt[2] = 4; + pt[3] = 5; + rayDir = y; + break; + + // +Y, so bit 1 set + case 3: + pt[0] = 2; + pt[1] = 3; + pt[2] = 6; + pt[3] = 7; + rayDir = -y; + break; + + // -Z, so bit 2 zero + case 4: + pt[0] = 0; + pt[1] = 1; + pt[2] = 3; + pt[3] = 4; + rayDir = z; + break; + + // +Z, so bit 2 set + case 5: + pt[0] = 4; + pt[1] = 5; + pt[2] = 6; + pt[3] = 7; + rayDir = -z; + break; } float movement = largeF; - + for( unsigned frside = 0; frside != 6; ++frside ) { - const Plane& plane = frustum->m_planes[ frside ]; + const Plane& plane = frustum->m_planes[frside]; float planeMove = largeF; - bool pointInside = false; // leave OBB side alone if any of the 4 points is already inside the frustum. + bool pointInside = false; // leave OBB side alone if any of the 4 points is already inside the frustum. for( unsigned i = 0; i != 4 && !pointInside; ++i ) { Vector3 p; @@ -112,7 +130,7 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, // we can move them along rayDir without actually making them visible. // By then taking the minimum of this movement over all possible planes, we // move the points to the frustum without any visible clipping of the OBB. - + const float distance = DotCoord( plane, p ); if( distance >= 0 ) { @@ -122,12 +140,12 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, } const float vn = DotNormal( plane, rayDir ); - if( vn < 0.0001f ) // parallel, or negative (= OBB side points towards frustum plane's outside) + if( vn < 0.0001f ) // parallel, or negative (= OBB side points towards frustum plane's outside) { continue; } - float t = - distance / vn; + float t = -distance / vn; if( t <= 0 ) { continue; @@ -152,14 +170,20 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, switch( side ) { - case 0 : - case 1 : sizes.x -= movement; break; + case 0: + case 1: + sizes.x -= movement; + break; - case 2 : - case 3 : sizes.y -= movement; break; + case 2: + case 3: + sizes.y -= movement; + break; - case 4 : - case 5 : sizes.z -= movement; break; + case 4: + case 5: + sizes.z -= movement; + break; } } } @@ -174,9 +198,9 @@ void Obb::CreateClippedWorldBoundingObb( const Vector3& min, const Vector3& max, // ------------------------------------------------------------- Vector3 Obb::GetPoint( unsigned N ) const { - static const float X[8] = { 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f }; - static const float Y[8] = { 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f }; - static const float Z[8] = { 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f }; + static const float X[8] = { 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f }; + static const float Y[8] = { 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f }; + static const float Z[8] = { 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f }; CCP_ASSERT( N < 8 ); return center + X[N] * sizes[0] * x + Y[N] * sizes[1] * y + Z[N] * sizes[2] * z; diff --git a/trinity/Utilities/Obb.h b/trinity/Utilities/Obb.h index 9abf9f0b5..a68b1c3da 100644 --- a/trinity/Utilities/Obb.h +++ b/trinity/Utilities/Obb.h @@ -24,7 +24,7 @@ struct Obb Vector3 x; Vector3 y; Vector3 z; - + // center - the center, in world coordinates, of the OBB Vector3 center; diff --git a/trinity/Utilities/Range.cpp b/trinity/Utilities/Range.cpp index 77556c181..cf3af7a87 100644 --- a/trinity/Utilities/Range.cpp +++ b/trinity/Utilities/Range.cpp @@ -49,7 +49,7 @@ void Range::SetMaxRangePoint( const float var ) { m_maxRange = max( var, m_centerPoint ); - if ( m_isUniform ) + if( m_isUniform ) { m_minRange = m_centerPoint - ( m_maxRange - m_centerPoint ); } @@ -73,7 +73,7 @@ float Range::GetMaxRangePoint() const void Range::ToggleIsUniform() { m_isUniform = !m_isUniform; - if (m_isUniform) + if( m_isUniform ) { FixUniformity(); } @@ -82,7 +82,7 @@ void Range::ToggleIsUniform() void Range::SetIsUniform( const bool var ) { m_isUniform = var; - if (m_isUniform) + if( m_isUniform ) { FixUniformity(); } diff --git a/trinity/Utilities/Range.h b/trinity/Utilities/Range.h index f392c4591..de3c9e0ef 100644 --- a/trinity/Utilities/Range.h +++ b/trinity/Utilities/Range.h @@ -14,7 +14,7 @@ BLUE_CLASS( Range ) : void SetCenterPoint( const float var ); void SetMinRangePoint( float var ); - void Setup(float rangeCenterPoint, float rangeDeltaFromCenter, float sliderMin, float sliderMax); + void Setup( float rangeCenterPoint, float rangeDeltaFromCenter, float sliderMin, float sliderMax ); void SetMaxRangePoint( float var ); float GetCenterPoint() const; float GetMinRangePoint() const; @@ -40,4 +40,3 @@ BLUE_CLASS( Range ) : }; TYPEDEF_BLUECLASS( Range ); - \ No newline at end of file diff --git a/trinity/Utilities/Vector3d.h b/trinity/Utilities/Vector3d.h index 9592cd961..3afa13acb 100644 --- a/trinity/Utilities/Vector3d.h +++ b/trinity/Utilities/Vector3d.h @@ -8,7 +8,7 @@ // Description: // This structure represents a 3-vector of doubles. Unlike Vector3, it does not // inherit from a D3DXMath base class (because none of them use doubles). It provides -// the standard set of constructors, arithmetic, assignment, comparison, and +// the standard set of constructors, arithmetic, assignment, comparison, and // conversion operators. Vector3d is used in EVE in some situations which require // double precision. // See Also: @@ -21,7 +21,10 @@ struct Vector3d // Description // Default constructor, initializes to zero vector. // ---------------------------------------------------------------------------------- - Vector3d( void ) : x( 0.0 ), y( 0.0 ), z( 0.0 ) {} + Vector3d( void ) : + x( 0.0 ), y( 0.0 ), z( 0.0 ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -57,7 +60,10 @@ struct Vector3d // y - The y-component value to initialize // z - The z-component value to initialize // --------------------------------------------------------------------------------- - Vector3d( double _x, double _y, double _z ) : x( _x ), y( _y ), z( _z ) {} + Vector3d( double _x, double _y, double _z ) : + x( _x ), y( _y ), z( _z ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -65,7 +71,10 @@ struct Vector3d // Arguments: // other - The Vector3d to copy // ---------------------------------------------------------------------------------- - Vector3d( const Vector3d& other ) : x( other.x ), y( other.y ), z( other.z ) {} + Vector3d( const Vector3d& other ) : + x( other.x ), y( other.y ), z( other.z ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -73,7 +82,10 @@ struct Vector3d // Arguments: // other - The Vector3 to copy // ---------------------------------------------------------------------------------- - Vector3d( const Vector3& other ) : x( other.x ), y( other.y ), z( other.z ) {} + Vector3d( const Vector3& other ) : + x( other.x ), y( other.y ), z( other.z ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -106,8 +118,8 @@ struct Vector3d const Vector3 AsVector3( void ) const { return Vector3( static_cast( x ), - static_cast( y ), - static_cast( z ) ); + static_cast( y ), + static_cast( z ) ); } // ---------------------------------------------------------------------------------- @@ -379,7 +391,7 @@ struct Vector3d // ---------------------------------------------------------------------------------- double Length( void ) const { - return sqrt( x*x + y*y + z*z ); + return sqrt( x * x + y * y + z * z ); } // ---------------------------------------------------------------------------------- @@ -390,7 +402,7 @@ struct Vector3d // ---------------------------------------------------------------------------------- double LengthSq( void ) const { - return x*x + y*y + z*z; + return x * x + y * y + z * z; } // ---------------------------------------------------------------------------------- @@ -438,7 +450,7 @@ struct Vector3d double Dot( const Vector3d& other ) { - return x*other.x + y*other.y + z*other.z; + return x * other.x + y * other.y + z * other.z; }; // The x-component of the vector diff --git a/trinity/Utilities/Vector4d.h b/trinity/Utilities/Vector4d.h index 590d666f4..754edbc47 100644 --- a/trinity/Utilities/Vector4d.h +++ b/trinity/Utilities/Vector4d.h @@ -8,7 +8,7 @@ // Description: // This structure represents a 4-vector of doubles. Unlike Vector4, it does not // inherit from a D3DXMath base class (because none of them use doubles). It provides -// the standard set of constructors, arithmetic, assignment, comparison, and +// the standard set of constructors, arithmetic, assignment, comparison, and // conversion operators. Vector4d is used in EVE in some situations which require // double precision. // See Also: @@ -21,7 +21,10 @@ struct Vector4d // Description // Default constructor, initializes to zero vector. // ---------------------------------------------------------------------------------- - Vector4d( void ) : x( 0.0 ), y( 0.0 ), z( 0.0 ), w( 0.0 ) {} + Vector4d( void ) : + x( 0.0 ), y( 0.0 ), z( 0.0 ), w( 0.0 ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -60,7 +63,10 @@ struct Vector4d // z - The z-component value to initialize // w - The w-component value to initialize // --------------------------------------------------------------------------------- - Vector4d( double _x, double _y, double _z, double _w ) : x( _x ), y( _y ), z( _z ), w( _w ) {} + Vector4d( double _x, double _y, double _z, double _w ) : + x( _x ), y( _y ), z( _z ), w( _w ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -68,7 +74,10 @@ struct Vector4d // Arguments: // other - The Vector4d to copy // ---------------------------------------------------------------------------------- - Vector4d( const Vector4d& other ) : x( other.x ), y( other.y ), z( other.z ), w( other.w ) {} + Vector4d( const Vector4d& other ) : + x( other.x ), y( other.y ), z( other.z ), w( other.w ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -76,7 +85,10 @@ struct Vector4d // Arguments: // other - The Vector4 to copy // ---------------------------------------------------------------------------------- - Vector4d( const Vector4& other ) : x( other.x ), y( other.y ), z( other.z ), w( other.w ) {} + Vector4d( const Vector4& other ) : + x( other.x ), y( other.y ), z( other.z ), w( other.w ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -85,7 +97,10 @@ struct Vector4d // other - The Vector3d to copy // _w - The double w value // ---------------------------------------------------------------------------------- - Vector4d( const Vector3d& other, double _w ) : x( other.x ), y( other.y ), z( other.z ), w( _w ) {} + Vector4d( const Vector3d& other, double _w ) : + x( other.x ), y( other.y ), z( other.z ), w( _w ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -94,7 +109,10 @@ struct Vector4d // other - The Vector3 to copy // _w - The float w value // ---------------------------------------------------------------------------------- - Vector4d( const Vector3& other, float _w ) : x( other.x ), y( other.y ), z( other.z ), w( _w ) {} + Vector4d( const Vector3& other, float _w ) : + x( other.x ), y( other.y ), z( other.z ), w( _w ) + { + } // ---------------------------------------------------------------------------------- // Description @@ -127,9 +145,9 @@ struct Vector4d const Vector4 AsVector4( void ) const { return Vector4( static_cast( x ), - static_cast( y ), - static_cast( z ), - static_cast( w ) ); + static_cast( y ), + static_cast( z ), + static_cast( w ) ); } // ---------------------------------------------------------------------------------- diff --git a/trinity/Wod/WodBakingScene.cpp b/trinity/Wod/WodBakingScene.cpp index 7f9920baa..a1052a564 100644 --- a/trinity/Wod/WodBakingScene.cpp +++ b/trinity/Wod/WodBakingScene.cpp @@ -10,7 +10,7 @@ #include "Tr2Renderer.h" #include "TriRenderBatch.h" -static void PopulatePerFrameVSData( Tr2PerFrameVSData &data ) +static void PopulatePerFrameVSData( Tr2PerFrameVSData& data ) { // 0 memset( &data, 0, sizeof( Tr2PerFrameVSData ) ); @@ -18,25 +18,25 @@ static void PopulatePerFrameVSData( Tr2PerFrameVSData &data ) // column_major for shaders data.ViewMat = Transpose( Tr2Renderer::GetViewTransform() ); data.ProjectionMat = Transpose( Tr2Renderer::GetProjectionTransform() ); - + Matrix viewProjectionMat = Tr2Renderer::GetViewTransform() * Tr2Renderer::GetProjectionTransform(); data.ViewProjectionMat = Transpose( viewProjectionMat ); // attention: need the transposed, but shader also needs column_major, so it is transpose(transpose(m)) == m data.ViewInverseTransposeMat = Tr2Renderer::GetInverseViewTransform(); // sun - data.sunDirWorld.x = 0.0f; - data.sunDirWorld.y = 0.0f; + data.sunDirWorld.x = 0.0f; + data.sunDirWorld.y = 0.0f; data.sunDirWorld.z = 1.0f; } -static void PopulatePerFramePSData( Tr2PerFramePSData &data ) +static void PopulatePerFramePSData( Tr2PerFramePSData& data ) { // 0 memset( &data, 0, sizeof( Tr2PerFramePSData ) ); // column_major for shaders - Matrix viewProj = Tr2Renderer::GetViewTransform() * Tr2Renderer::GetProjectionTransform(); + Matrix viewProj = Tr2Renderer::GetViewTransform() * Tr2Renderer::GetProjectionTransform(); data.ViewProjectionMat = Transpose( viewProj ); // attention: need the transposed, but shader also needs column_major, so it is transpose(transpose(m)) == m data.ViewInverseTransposeMat = Tr2Renderer::GetInverseViewTransform(); @@ -46,28 +46,28 @@ static void PopulatePerFramePSData( Tr2PerFramePSData &data ) data.sunDiffuseColor.g = 0.0f; data.sunDiffuseColor.b = 0.0f; data.sunDiffuseColor.a = 1.0f; - + // Hard code specular data.sunSpecularColor.r = 0.8f; data.sunSpecularColor.g = 0.8f; data.sunSpecularColor.b = 0.8f; data.sunSpecularColor.a = 1.0f; - // Hard code ambient + // Hard code ambient data.sceneAmbientColor.r = 0.0f; data.sceneAmbientColor.g = 0.0f; data.sceneAmbientColor.b = 0.0f; data.sceneAmbientColor.a = 0.0f; - data.sunDirWorld.x = 0.0f; - data.sunDirWorld.y = 0.0f; + data.sunDirWorld.x = 0.0f; + data.sunDirWorld.y = 0.0f; data.sunDirWorld.z = 1.0f; data.cullDirection = 1.0f; data.shScale = 1.0f; } -WodBakingScene::WodBakingScene( IRoot* lockobj /*= NULL */ ): +WodBakingScene::WodBakingScene( IRoot* lockobj /*= NULL */ ) : m_visualizeMethod( VM_NONE ) { // Create render batch accumulators @@ -80,12 +80,12 @@ WodBakingScene::~WodBakingScene() CCP_DELETE( m_opaqueRenderBatches ); } -void WodBakingScene::Render( Tr2RenderContext& renderContext ) +void WodBakingScene::Render( Tr2RenderContext& renderContext ) { - D3DPERF_EVENT(L"WodBakingScene::Render"); + D3DPERF_EVENT( L"WodBakingScene::Render" ); // Nothing to render if we do not have a skinned object to bake out. - if ( !m_skinnedObject ) + if( !m_skinnedObject ) { return; } @@ -93,8 +93,8 @@ void WodBakingScene::Render( Tr2RenderContext& renderContext ) renderContext.AddGpuMarker( __FUNCTION__ ); Tr2PerObjectData* perObjectData = m_skinnedObject->GetPerObjectData( m_opaqueRenderBatches ); - m_skinnedObject->GetBatches( m_opaqueRenderBatches, TRIBATCHTYPE_OPAQUE, perObjectData ); - + m_skinnedObject->GetBatches( m_opaqueRenderBatches, TRIBATCHTYPE_OPAQUE, perObjectData ); + renderContext.m_esm.BeginManagedRendering(); renderContext.m_esm.SetInvertedCullMode( false ); using namespace Tr2RenderContextEnum; @@ -103,13 +103,13 @@ void WodBakingScene::Render( Tr2RenderContext& renderContext ) Tr2PerFrameVSData vsData; Tr2PerFramePSData psData; - // Set per-frame data + // Set per-frame data PopulatePerFramePSData( psData ); PopulatePerFrameVSData( vsData ); FillAndSetConstants( m_VSBuffer, vsData, VERTEX_SHADER, Tr2Renderer::GetPerFrameVSStartRegister(), renderContext ); - FillAndSetConstants( m_PSBuffer, psData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext ); - + FillAndSetConstants( m_PSBuffer, psData, PIXEL_SHADER, Tr2Renderer::GetPerFramePSStartRegister(), renderContext ); + m_opaqueRenderBatches->Finalize(); renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_OPAQUE ); @@ -118,11 +118,10 @@ void WodBakingScene::Render( Tr2RenderContext& renderContext ) // Clear the batches m_opaqueRenderBatches->Clear(); - + //m_transparentBatchStore->Clear(); renderContext.m_esm.EndManagedRendering(); - } void WodBakingScene::RenderDebugInfo( Tr2RenderContext& renderContext ) @@ -137,4 +136,3 @@ void WodBakingScene::Update( Be::Time realTime, Be::Time simTime ) m_skinnedObject->PostPhysicsUpdate( simTime, NULL ); } } - diff --git a/trinity/Wod/WodBakingScene.h b/trinity/Wod/WodBakingScene.h index fbacf0d6f..31ac75f98 100644 --- a/trinity/Wod/WodBakingScene.h +++ b/trinity/Wod/WodBakingScene.h @@ -10,8 +10,7 @@ BLUE_DECLARE( WodBakingScene ); BLUE_DECLARE( Tr2SkinnedObject ); -class WodBakingScene: - public ITr2Scene +class WodBakingScene : public ITr2Scene { public: WodBakingScene( IRoot* lockobj = NULL ); @@ -19,7 +18,7 @@ class WodBakingScene: EXPOSE_TO_BLUE(); - virtual void Render( Tr2RenderContext& renderContext ); + virtual void Render( Tr2RenderContext& renderContext ); virtual void RenderDebugInfo( Tr2RenderContext& renderContext ); virtual void Update( Be::Time realTime, Be::Time simTime ); @@ -31,7 +30,7 @@ class WodBakingScene: // Visualization VisualizeMethod m_visualizeMethod; - Tr2ConstantBufferAL m_VSBuffer, m_PSBuffer; + Tr2ConstantBufferAL m_VSBuffer, m_PSBuffer; }; TYPEDEF_BLUECLASS( WodBakingScene ); diff --git a/trinity/Wod/WodBakingScene_Blue.cpp b/trinity/Wod/WodBakingScene_Blue.cpp index d2a26641d..7d6d842b9 100644 --- a/trinity/Wod/WodBakingScene_Blue.cpp +++ b/trinity/Wod/WodBakingScene_Blue.cpp @@ -6,81 +6,52 @@ BLUE_DEFINE( WodBakingScene ); -static Be::VarChooser VisualizerChooser[] = -{ - { - "None", - BeCast( VM_NONE ), - "No visualizer - use normal rendering" - }, - { - "White", - BeCast( VM_WHITE ), - "Pixel shader returns white (useful to verify that something is output)" - }, +static Be::VarChooser VisualizerChooser[] = { + { "None", + BeCast( VM_NONE ), + "No visualizer - use normal rendering" }, + { "White", + BeCast( VM_WHITE ), + "Pixel shader returns white (useful to verify that something is output)" }, - { - "Object normal", - BeCast( VM_OBJECT_NORMAL ), - "Normal from vertices" - }, - { - "Tangent", - BeCast( VM_TANGENT ), - "Tangent from vertices" - }, - { - "Bitangent", - BeCast( VM_BITANGENT ), - "Bitangent from vertices" - }, + { "Object normal", + BeCast( VM_OBJECT_NORMAL ), + "Normal from vertices" }, + { "Tangent", + BeCast( VM_TANGENT ), + "Tangent from vertices" }, + { "Bitangent", + BeCast( VM_BITANGENT ), + "Bitangent from vertices" }, - { - "TexCoord0", - BeCast( VM_TEXCOORD0 ), - "Texture coordinate 0" - }, - { - "TexCoord1", - BeCast( VM_TEXCOORD1 ), - "Texture coordinate 0" - }, + { "TexCoord0", + BeCast( VM_TEXCOORD0 ), + "Texture coordinate 0" }, + { "TexCoord1", + BeCast( VM_TEXCOORD1 ), + "Texture coordinate 0" }, - { - "TexelDensity0", - BeCast( VM_TEXELDENSITY0 ), - "Density of texels mapped through texture coordinate 0" - }, - { - "Normal map", - BeCast( VM_NORMALMAP ), - "Tangent space normal from map" - }, - { - "Diffuse map", - BeCast( VM_DIFFUSEMAP ), - "Diffuse map" - }, - { - "Specular map", - BeCast( VM_SPECULARMAP ), - "Specular map" - }, - { - "Overdraw", - BeCast( VM_OVERDRAW ), - "See the overdraw of the scene" - }, - { - "Enlighten only", - BeCast( VM_EN_ONLY ), - "Enlighten only)" - }, - { - "Depth", - BeCast( VM_DEPTH ), - "See the depth buffer of the scene" - }, + { "TexelDensity0", + BeCast( VM_TEXELDENSITY0 ), + "Density of texels mapped through texture coordinate 0" }, + { "Normal map", + BeCast( VM_NORMALMAP ), + "Tangent space normal from map" }, + { "Diffuse map", + BeCast( VM_DIFFUSEMAP ), + "Diffuse map" }, + { "Specular map", + BeCast( VM_SPECULARMAP ), + "Specular map" }, + { "Overdraw", + BeCast( VM_OVERDRAW ), + "See the overdraw of the scene" }, + { "Enlighten only", + BeCast( VM_EN_ONLY ), + "Enlighten only)" }, + { "Depth", + BeCast( VM_DEPTH ), + "See the depth buffer of the scene" }, { 0 } }; @@ -93,11 +64,11 @@ const Be::ClassInfo* WodBakingScene::ExposeToBlue() MAP_ATTRIBUTE_WITH_CHOOSER( "visualizeMethod", m_visualizeMethod, "Legacy attribute, do not use. TODO: remove me", Be::READWRITE | Be::ENUM | Be::NOTIFY, VisualizerChooser ) - MAP_ATTRIBUTE( - "Avatar", - m_skinnedObject, - "The avatar to be baked in this scene", Be::READWRITE ) + MAP_ATTRIBUTE( + "Avatar", + m_skinnedObject, + "The avatar to be baked in this scene", + Be::READWRITE ) EXPOSURE_END() } - diff --git a/trinity/Wod/WodPlaceableRes.cpp b/trinity/Wod/WodPlaceableRes.cpp index beca54626..f9ffeebae 100644 --- a/trinity/Wod/WodPlaceableRes.cpp +++ b/trinity/Wod/WodPlaceableRes.cpp @@ -8,16 +8,15 @@ #include "Tr2MeshArea.h" #include "Utilities/BoundingBox.h" -WodPlaceableRes::WodPlaceableRes( IRoot* lockobj ) : - m_farFadeDistance( 100.0f*100.0f ), - m_nearFadeDistance( 50.0f*50.0f ), +WodPlaceableRes::WodPlaceableRes( IRoot* lockobj ) : + m_farFadeDistance( 100.0f * 100.0f ), + m_nearFadeDistance( 50.0f * 50.0f ), m_isShadowCaster( true ), - m_bIsReady(false), - PARENTLOCK( m_minBounds ), - PARENTLOCK( m_maxBounds ), + m_bIsReady( false ), + PARENTLOCK( m_minBounds ), + PARENTLOCK( m_maxBounds ), PARENTLOCK( m_curveSets ) { - } WodPlaceableRes::~WodPlaceableRes() @@ -26,50 +25,49 @@ WodPlaceableRes::~WodPlaceableRes() void WodPlaceableRes::GetBatches( ITriRenderBatchAccumulator* batches, TriBatchType batchType, - const Matrix& m , + const Matrix& m, const Tr2PerObjectData* data ) { - if( m_visualModel ) - { - m_visualModel->GetBatches( batches, batchType, m, data ); - } + if( m_visualModel ) + { + m_visualModel->GetBatches( batches, batchType, m, data ); + } } bool WodPlaceableRes::IsReady() { - if( m_bIsReady) - { - return true; - } - Vector3 myMin; - Vector3 myMax; + if( m_bIsReady ) + { + return true; + } + Vector3 myMin; + Vector3 myMax; - BoundingBoxInitialize( myMin, myMax ); - Vector3 meshMin; - Vector3 meshMax; + BoundingBoxInitialize( myMin, myMax ); + Vector3 meshMin; + Vector3 meshMax; - if( !m_visualModel->GetBoundingBox( meshMin, meshMax ) ) - { - return false; - } + if( !m_visualModel->GetBoundingBox( meshMin, meshMax ) ) + { + return false; + } - BoundingBoxUpdate( myMin, myMax, meshMin ); - BoundingBoxUpdate( myMin, myMax, meshMax ); + BoundingBoxUpdate( myMin, myMax, meshMin ); + BoundingBoxUpdate( myMin, myMax, meshMax ); - m_minBounds.SetVector( &myMin ); - m_maxBounds.SetVector( &myMax ); + m_minBounds.SetVector( &myMin ); + m_maxBounds.SetVector( &myMax ); - m_bIsReady = true; + m_bIsReady = true; return true; } bool WodPlaceableRes::HasTransparency() { - if( m_visualModel ) - { - return m_visualModel->HasTransparency(); - } - return false; + if( m_visualModel ) + { + return m_visualModel->HasTransparency(); + } + return false; } - diff --git a/trinity/Wod/WodPlaceableRes.h b/trinity/Wod/WodPlaceableRes.h index a466d1abf..8d3b67f55 100644 --- a/trinity/Wod/WodPlaceableRes.h +++ b/trinity/Wod/WodPlaceableRes.h @@ -12,47 +12,69 @@ BLUE_DECLARE( TriCurveSet ); BLUE_DECLARE_VECTOR( TriCurveSet ); // See http://core/wiki/WodPlaceableRes -// A WodPlaceableRes object holds the geometry for rendering a placeable, -// as well as data required for visibility determination. -BLUE_CLASS( WodPlaceableRes) : public IRoot +// A WodPlaceableRes object holds the geometry for rendering a placeable, +// as well as data required for visibility determination. +BLUE_CLASS( WodPlaceableRes ) : + public IRoot { public: - EXPOSE_TO_BLUE(); + EXPOSE_TO_BLUE(); - WodPlaceableRes( IRoot* lockobj = NULL ); - ~WodPlaceableRes(); + WodPlaceableRes( IRoot* lockobj = NULL ); + ~WodPlaceableRes(); - float GetNearFadeDistance() const { return m_nearFadeDistance; } - float GetFarFadeDistance() const { return m_farFadeDistance; } + float GetNearFadeDistance() const + { + return m_nearFadeDistance; + } + float GetFarFadeDistance() const + { + return m_farFadeDistance; + } - void GetBatches( ITriRenderBatchAccumulator* batches, + void GetBatches( ITriRenderBatchAccumulator * batches, TriBatchType batchType, - const Matrix& m, + const Matrix& m, const Tr2PerObjectData* data ); bool HasTransparency(); ////////////////////////////////////////////////////////////////////////////////////// // Bounding Volumes - void GetBoundingBox( Vector3& min, Vector3& max ) { IsReady(); min = m_minBounds; max = m_maxBounds; } + void GetBoundingBox( Vector3 & min, Vector3 & max ) + { + IsReady(); + min = m_minBounds; + max = m_maxBounds; + } + + bool IsReady(); + bool IsShadowCaster( void ) const + { + return m_isShadowCaster; + } + + Tr2ModelPtr GetVisualModel() + { + return m_visualModel; + } + + TriCurveSetVector* GetCurveSets() + { + return &m_curveSets; + } - bool IsReady(); - bool IsShadowCaster( void ) const { return m_isShadowCaster; } - - Tr2ModelPtr GetVisualModel() { return m_visualModel; } - - TriCurveSetVector* GetCurveSets() { return &m_curveSets; } private: - Tr2ModelPtr m_visualModel; - - float m_nearFadeDistance; - float m_farFadeDistance; + Tr2ModelPtr m_visualModel; + + float m_nearFadeDistance; + float m_farFadeDistance; bool m_isShadowCaster; - PTriVector m_minBounds; - PTriVector m_maxBounds; - bool m_bIsReady; + PTriVector m_minBounds; + PTriVector m_maxBounds; + bool m_bIsReady; PTriCurveSetVector m_curveSets; }; diff --git a/trinity/Wod/WodPlaceableRes_Blue.cpp b/trinity/Wod/WodPlaceableRes_Blue.cpp index b5ece4103..40da380da 100644 --- a/trinity/Wod/WodPlaceableRes_Blue.cpp +++ b/trinity/Wod/WodPlaceableRes_Blue.cpp @@ -8,21 +8,20 @@ BLUE_DEFINE( WodPlaceableRes ); const Be::ClassInfo* WodPlaceableRes::ExposeToBlue() { - EXPOSURE_BEGIN( WodPlaceableRes, "" ) - MAP_INTERFACE( WodPlaceableRes ) + EXPOSURE_BEGIN( WodPlaceableRes, "" ) + MAP_INTERFACE( WodPlaceableRes ) - MAP_ATTRIBUTE( "visualModel", m_visualModel, "", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "farFadeDistance", m_farFadeDistance,"", Be::READWRITE | Be::PERSIST ) - MAP_ATTRIBUTE( "nearFadeDistance", m_nearFadeDistance,"", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "visualModel", m_visualModel, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "farFadeDistance", m_farFadeDistance, "", Be::READWRITE | Be::PERSIST ) + MAP_ATTRIBUTE( "nearFadeDistance", m_nearFadeDistance, "", Be::READWRITE | Be::PERSIST ) MAP_ATTRIBUTE( "curveSets", m_curveSets, "Curve sets to animate light attributes", Be::READ | Be::PERSIST ) - MAP_ATTRIBUTE( - "isShadowCaster", - m_isShadowCaster, + MAP_ATTRIBUTE( + "isShadowCaster", + m_isShadowCaster, "Is this placeable res a shadow caster?", - Be::READWRITE | Be::PERSIST - ) + Be::READWRITE | Be::PERSIST ) - EXPOSURE_END() + EXPOSURE_END() } diff --git a/trinity/autoversion.h b/trinity/autoversion.h index 739e09cac..9cd13b660 100644 --- a/trinity/autoversion.h +++ b/trinity/autoversion.h @@ -1,8 +1,8 @@ // Copyright © 2023 CCP ehf. -#define EVEVER 9 -#define EVEDELIVERY 9 -#define EVEBUILD 9 +#define EVEVER 9 +#define EVEDELIVERY 9 +#define EVEBUILD 9 #define EVEPROJECTVER 9 #define EVEVERSIONSTRING "9.9.9.9\0" #define EVEBUILDDATE "Sometime, someday, somewhere\0" diff --git a/trinity/resource.h b/trinity/resource.h index 35d7860b4..28db2cfa7 100644 --- a/trinity/resource.h +++ b/trinity/resource.h @@ -6,13 +6,13 @@ // // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/trinity/trinity.cpp b/trinity/trinity.cpp index 0e10dfbb9..11142507b 100644 --- a/trinity/trinity.cpp +++ b/trinity/trinity.cpp @@ -47,17 +47,21 @@ const char* g_moduleName = "trinity"; #ifdef _WIN32 extern "C" { -__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; -__declspec(dllexport) uint32_t NvOptimusEnablement = 1; + __declspec( dllexport ) int AmdPowerXpressRequestHighPerformance = 1; + __declspec( dllexport ) uint32_t NvOptimusEnablement = 1; } #endif // reduce CRT link -extern "C" void _setargv(){} -extern "C" void _setenvp(){} +extern "C" void _setargv() +{ +} +extern "C" void _setenvp() +{ +} -#define BLUETHUNKREG(_Class) \ - PyOS->RegisterThunker(_Class::Defs(), _Class::IID() ); +#define BLUETHUNKREG( _Class ) \ + PyOS->RegisterThunker( _Class::Defs(), _Class::IID() ); #if WITH_GRANNY void* Tr2GrannyAllocate( const char* file, granny_int32x line, granny_uintaddrx alignment, granny_uintaddrx size, granny_int32x intent ) @@ -110,62 +114,57 @@ const char* InitializeForPython() #else PyObject* InitializeForPython() { - static PyMethodDef dummyMethods[] = {0}; + static PyMethodDef dummyMethods[] = { 0 }; // put myself into python as a module - static struct PyModuleDef trinityDef = { - PyModuleDef_HEAD_INIT, - CCP_STRINGIZE( CCP_CONCATENATE( TRINITYNAME, CCP_BUILD_FLAVOR ) ), - "", - -1, - dummyMethods - }; - PyObject* module = PyModule_Create(&trinityDef); - if ( module ) { - PyObject* dict = PyModule_GetDict(module); - - // constants - AddTriConstants(dict); - - // put UI into python as a separate module - static struct PyModuleDef triuiDef = { - PyModuleDef_HEAD_INIT, - "triui", - "", - -1, - dummyMethods - }; - PyObject* uiModule = PyModule_Create(&triuiDef); - PyObject* uiDict = PyModule_GetDict(uiModule); - - AddScancodesToDict(uiDict); - AddUIChoosersToDict(uiDict); - - PyObject* sys_modules = PyImport_GetModuleDict(); - if( PyDict_SetItemString( sys_modules, triuiDef.m_name, uiModule ) != 0 ) - { - return nullptr; - } - - BLUE_REGISTER_THUNKER(ITriScalarFunction_Thunk::Defs(), ITriScalarFunction_Thunk::IID()); - BLUE_REGISTER_THUNKER(ITriVectorFunction_Thunk::Defs(), ITriVectorFunction_Thunk::IID()); - BLUE_REGISTER_THUNKER(ITriQuaternionFunction_Thunk::Defs(), ITriQuaternionFunction_Thunk::IID()); - BLUE_REGISTER_THUNKER(ITriColorFunction_Thunk::Defs(), ITriColorFunction_Thunk::IID()); - - BlueRegisterToModule( module, BlueRegistration::GetClassRegs(), - BlueRegistration::GetFuncRegs(), - BlueRegistration::GetEnumRegs(), - BlueRegistration::GetTestRegs(), - BlueRegistration::GetThunkerRegs(), - BlueRegistration::GetFuncSignatures() ); - - BlueRegisterObjectsToModule( module, BlueRegistration::GetObjectRegs() ); - BlueRegisterExceptionsToModule( module, BlueRegistration::GetExceptionRegs() ); - - PyModule_AddObject( module, "settings", BlueWrapObjectForPython(&Tr2Renderer::GetSettings()) ); - PyModule_AddObject( module, "fontMan", BlueWrapObjectForPython( g_fontManager ) ); - - } + static struct PyModuleDef trinityDef = { + PyModuleDef_HEAD_INIT, + CCP_STRINGIZE( CCP_CONCATENATE( TRINITYNAME, CCP_BUILD_FLAVOR ) ), + "", + -1, + dummyMethods + }; + PyObject* module = PyModule_Create( &trinityDef ); + if( module ) + { + PyObject* dict = PyModule_GetDict( module ); + + // constants + AddTriConstants( dict ); + + // put UI into python as a separate module + static struct PyModuleDef triuiDef = { + PyModuleDef_HEAD_INIT, + "triui", + "", + -1, + dummyMethods + }; + PyObject* uiModule = PyModule_Create( &triuiDef ); + PyObject* uiDict = PyModule_GetDict( uiModule ); + + AddScancodesToDict( uiDict ); + AddUIChoosersToDict( uiDict ); + + PyObject* sys_modules = PyImport_GetModuleDict(); + if( PyDict_SetItemString( sys_modules, triuiDef.m_name, uiModule ) != 0 ) + { + return nullptr; + } + + BLUE_REGISTER_THUNKER( ITriScalarFunction_Thunk::Defs(), ITriScalarFunction_Thunk::IID() ); + BLUE_REGISTER_THUNKER( ITriVectorFunction_Thunk::Defs(), ITriVectorFunction_Thunk::IID() ); + BLUE_REGISTER_THUNKER( ITriQuaternionFunction_Thunk::Defs(), ITriQuaternionFunction_Thunk::IID() ); + BLUE_REGISTER_THUNKER( ITriColorFunction_Thunk::Defs(), ITriColorFunction_Thunk::IID() ); + + BlueRegisterToModule( module, BlueRegistration::GetClassRegs(), BlueRegistration::GetFuncRegs(), BlueRegistration::GetEnumRegs(), BlueRegistration::GetTestRegs(), BlueRegistration::GetThunkerRegs(), BlueRegistration::GetFuncSignatures() ); + + BlueRegisterObjectsToModule( module, BlueRegistration::GetObjectRegs() ); + BlueRegisterExceptionsToModule( module, BlueRegistration::GetExceptionRegs() ); + + PyModule_AddObject( module, "settings", BlueWrapObjectForPython( &Tr2Renderer::GetSettings() ) ); + PyModule_AddObject( module, "fontMan", BlueWrapObjectForPython( g_fontManager ) ); + } return module; } @@ -235,7 +234,7 @@ void InitializeTrinity() { g_upscalingDebug = upsclingDebugArg == L"1"; } - + auto debugArg = BeOS->GetStartupArgValue( L"deviceDebug" ); if( !debugArg.empty() ) { @@ -265,7 +264,7 @@ void InitializeTrinity() { g_gdrEnabled = gdpr != L"0"; } - + #if WITH_GRANNY GrannySetAllocator( Tr2GrannyAllocate, Tr2GrannyDeallocate ); #endif @@ -281,7 +280,7 @@ void InitializeTrinity() static void StartDLL() { CCP_LOG( "Trinity (%s) module starting", CCP_STRINGIZE( TRINITYNAME ) ); - BeClasses->RegisterClasses( BlueRegistration::GetClassRegs() ); + BeClasses->RegisterClasses( BlueRegistration::GetClassRegs() ); InitializeTrinity(); } @@ -298,15 +297,15 @@ extern "C" void #else __attribute__( ( visibility( "default" ) ) ) #endif - CCP_CONCATENATE( CCP_CONCATENATE( init, TRINITYNAME ), CCP_BUILD_FLAVOR )() + CCP_CONCATENATE( CCP_CONCATENATE( init, TRINITYNAME ), CCP_BUILD_FLAVOR )() { StartDLL(); InitializeForPython(); } -#else +#else PyMODINIT_FUNC -CCP_CONCATENATE( CCP_CONCATENATE( PyInit_, TRINITYNAME ), CCP_BUILD_FLAVOR )() + CCP_CONCATENATE( CCP_CONCATENATE( PyInit_, TRINITYNAME ), CCP_BUILD_FLAVOR )() { StartDLL(); return InitializeForPython(); @@ -316,7 +315,7 @@ CCP_CONCATENATE( CCP_CONCATENATE( PyInit_, TRINITYNAME ), CCP_BUILD_FLAVOR )() #ifndef _WIN32 -static void emptySignalHandler(int) +static void emptySignalHandler( int ) { } #endif @@ -342,7 +341,7 @@ static PyObject* PyBreakInDebugger( PyObject* module, PyObject* args ) { #ifdef _WIN32 - if( PyTuple_GET_SIZE(args) == 1 ) + if( PyTuple_GET_SIZE( args ) == 1 ) { PyObject* o = PyTuple_GetItem( args, 0 ); if( PyVerCompat::IsPyString( o ) ) @@ -352,22 +351,22 @@ static PyObject* PyBreakInDebugger( PyObject* module, PyObject* args ) OutputDebugString( context.c_str() ); OutputDebugString( "\n" ); } - } + } DoDebugBreak(); #else - struct sigaction action, oldAction; - memset( &action, 0, sizeof( action ) ); - action.sa_handler = &emptySignalHandler; - sigaction( SIGTRAP, &action, &oldAction ); - raise(SIGTRAP); - sigaction( SIGTRAP, &oldAction, &action ); + struct sigaction action, oldAction; + memset( &action, 0, sizeof( action ) ); + action.sa_handler = &emptySignalHandler; + sigaction( SIGTRAP, &action, &oldAction ); + raise( SIGTRAP ); + sigaction( SIGTRAP, &oldAction, &action ); #endif Py_RETURN_NONE; } -MAP_FUNCTION( - "BreakInDebugger", - PyBreakInDebugger, +MAP_FUNCTION( + "BreakInDebugger", + PyBreakInDebugger, "BreakInDebugger( [contextString] )\nBreaks in the debugger, if one is attached, allowing you to look at the program state at a point determined from Python.\n" ":param contextString: string that is dumped into the debugger output\n" ":type contextString: str\n" @@ -411,18 +410,17 @@ static BlueStdResult GetObjectWorldTransform( IRoot* object, Matrix& result ) spaceObject->GetLocalToWorldTransform( result ); return BlueStdResult( BLUE_STD_RESULT_OK ); } - + return BlueStdResult( BLUE_STD_RESULT_TYPE_ERROR ); } -MAP_FUNCTION_AND_WRAP( - "GetObjectWorldTransform", +MAP_FUNCTION_AND_WRAP( + "GetObjectWorldTransform", GetObjectWorldTransform, - "Returns world transform for some supported object interfaces. Currently only\n" + "Returns world transform for some supported object interfaces. Currently only\n" "IEveSpaceObject2 and IEveSpaceObjectChild interfaces are supported.\n" ":param obj: blue object to get world transform from\n" - ":raies TypeError: if the function does not support the object type" -); + ":raies TypeError: if the function does not support the object type" ); // Interface definitions BLUE_DEFINE_INTERFACE( IWorldPosition ); diff --git a/trinityal/ALLog.h b/trinityal/ALLog.h index 47531346c..4bec14e08 100644 --- a/trinityal/ALLog.h +++ b/trinityal/ALLog.h @@ -6,17 +6,17 @@ namespace CCP { - inline CcpLogChannel_t& GetTrinityALChannel() - { - static CcpLogChannel_t s_moduleChannel = CCP_LOG_DEFINE_CHANNEL( "TrinityAL" ); - return s_moduleChannel; - } +inline CcpLogChannel_t& GetTrinityALChannel() +{ + static CcpLogChannel_t s_moduleChannel = CCP_LOG_DEFINE_CHANNEL( "TrinityAL" ); + return s_moduleChannel; +} } -#define CCP_AL_LOG( ... ) CCP_LOG_CH ( CCP::GetTrinityALChannel(), __VA_ARGS__ ) -#define CCP_AL_LOGERR( ... ) CCP_LOGERR_CH ( CCP::GetTrinityALChannel(), __VA_ARGS__ ) -#define CCP_AL_LOGNOTICE( ... ) CCP_LOGNOTICE_CH ( CCP::GetTrinityALChannel(), __VA_ARGS__ ) -#define CCP_AL_LOGWARN( ... ) CCP_LOGWARN_CH ( CCP::GetTrinityALChannel(), __VA_ARGS__ ) +#define CCP_AL_LOG( ... ) CCP_LOG_CH( CCP::GetTrinityALChannel(), __VA_ARGS__ ) +#define CCP_AL_LOGERR( ... ) CCP_LOGERR_CH( CCP::GetTrinityALChannel(), __VA_ARGS__ ) +#define CCP_AL_LOGNOTICE( ... ) CCP_LOGNOTICE_CH( CCP::GetTrinityALChannel(), __VA_ARGS__ ) +#define CCP_AL_LOGWARN( ... ) CCP_LOGWARN_CH( CCP::GetTrinityALChannel(), __VA_ARGS__ ) #endif \ No newline at end of file diff --git a/trinityal/ALResult.cpp b/trinityal/ALResult.cpp index 13d3dbd09..948b186c0 100644 --- a/trinityal/ALResult.cpp +++ b/trinityal/ALResult.cpp @@ -4,7 +4,7 @@ #include "ALResult.h" #include "ALLog.h" -#if( TRINITYDEV == 1 ) +#if ( TRINITYDEV == 1 ) bool g_requestDeviceDebugLayer = true; #else bool g_requestDeviceDebugLayer = false; @@ -19,13 +19,13 @@ std::map s_errorMessages; } -#if defined(_DEBUG) || defined(TRINITYDEV) +#if defined( _DEBUG ) || defined( TRINITYDEV ) void ReportHresultError( const char* fileName, int lineNumber, const char* statement, HRESULT hr ) { const char* msgFormat = "%s(%d) : '%s' returned error 0x%X\n"; const int bufferSize = 1024; - char buffer[ bufferSize ] = ""; + char buffer[bufferSize] = ""; _snprintf_s( buffer, _TRUNCATE, msgFormat, fileName, lineNumber, statement, hr ); #ifdef _WIN32 OutputDebugString( buffer ); @@ -35,7 +35,7 @@ void ReportHresultError( const char* fileName, int lineNumber, const char* state } #if !defined( _WIN32 ) -static void emptySignalHandler(int) +static void emptySignalHandler( int ) { } #endif @@ -43,22 +43,22 @@ static void emptySignalHandler(int) void BreakInDebugger() { #ifdef _WIN32 - __try + __try { // This breakpoint exception is used by several D3D return value checking functions // If you get, here, go up the stack and see what D3D function failed DebugBreak(); } - __except(GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + __except( GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) { } #else - struct sigaction action, oldAction; - memset( &action, 0, sizeof( action ) ); - action.sa_handler = &emptySignalHandler; - sigaction( SIGTRAP, &action, &oldAction ); - raise(SIGTRAP); - sigaction( SIGTRAP, &oldAction, &action ); + struct sigaction action, oldAction; + memset( &action, 0, sizeof( action ) ); + action.sa_handler = &emptySignalHandler; + sigaction( SIGTRAP, &action, &oldAction ); + raise( SIGTRAP ); + sigaction( SIGTRAP, &oldAction, &action ); #endif } @@ -73,7 +73,8 @@ void BreakInDebugger() // Return value: // Static string with exception message // -------------------------------------------------------------------------------------- -template<> const char* BeGetErrorMessage( const Be::Result& result ) +template <> +const char* BeGetErrorMessage( const Be::Result& result ) { auto found = s_errorMessages.find( result ); if( found == s_errorMessages.end() ) diff --git a/trinityal/ALResult.h b/trinityal/ALResult.h index 1ce3419e2..0a938d346 100644 --- a/trinityal/ALResult.h +++ b/trinityal/ALResult.h @@ -14,86 +14,104 @@ #ifndef _WIN32 typedef int32_t HRESULT; -#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -#define FAILED(hr) (((HRESULT)(hr)) < 0) - -#define S_OK ((HRESULT)0L) -#define S_FALSE ((HRESULT)1L) -#define E_FAIL HRESULT(0x80004005L) -#define E_INVALIDARG HRESULT(0x80070057L) -#define E_INVALIDCALL HRESULT(0x8876086C) -#define E_OUTOFMEMORY HRESULT(0x8007000E) -#define E_DEVICELOST HRESULT(0x88760868) -#elif (TRINITYPLATFORM != TRINITYSTUB) +#define SUCCEEDED( hr ) ( ( (HRESULT)( hr ) ) >= 0 ) +#define FAILED( hr ) ( ( (HRESULT)( hr ) ) < 0 ) + +#define S_OK ( (HRESULT)0L ) +#define S_FALSE ( (HRESULT)1L ) +#define E_FAIL HRESULT( 0x80004005L ) +#define E_INVALIDARG HRESULT( 0x80070057L ) +#define E_INVALIDCALL HRESULT( 0x8876086C ) +#define E_OUTOFMEMORY HRESULT( 0x8007000E ) +#define E_DEVICELOST HRESULT( 0x88760868 ) +#elif ( TRINITYPLATFORM != TRINITYSTUB ) #define E_INVALIDCALL D3DERR_INVALIDCALL #define E_DEVICELOST D3DERR_DEVICELOST #else -#define E_INVALIDCALL HRESULT(0x8876086C) -#define E_DEVICELOST HRESULT(0x88760868) +#define E_INVALIDCALL HRESULT( 0x8876086C ) +#define E_DEVICELOST HRESULT( 0x88760868 ) #endif -#if defined(_DEBUG) || defined(TRINITYDEV) - void ReportHresultError( const char* fileName, int lineNumber, const char* statement, HRESULT hr ); - void BreakInDebugger(); +#if defined( _DEBUG ) || defined( TRINITYDEV ) +void ReportHresultError( const char* fileName, int lineNumber, const char* statement, HRESULT hr ); +void BreakInDebugger(); - #define CR( x ) \ - { \ - HRESULT _hr = x; \ - if( FAILED(_hr) ) \ - { \ +#define CR( x ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + { \ ReportHresultError( __FILE__, __LINE__, #x, _hr ); \ - BreakInDebugger(); \ - } \ + BreakInDebugger(); \ + } \ } - #define CR_RETURN( x ) \ - { \ - HRESULT _hr = x; \ - if( FAILED(_hr) ) \ - { \ +#define CR_RETURN( x ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + { \ ReportHresultError( __FILE__, __LINE__, #x, _hr ); \ - BreakInDebugger(); \ - return; \ - } \ + BreakInDebugger(); \ + return; \ + } \ } - #define CR_RETURN_HR( x ) \ - { \ - HRESULT _hr = x; \ - if( FAILED(_hr) ) \ - { \ +#define CR_RETURN_HR( x ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + { \ ReportHresultError( __FILE__, __LINE__, #x, _hr ); \ - BreakInDebugger(); \ - return _hr; \ - } \ + BreakInDebugger(); \ + return _hr; \ + } \ } - #define FORWARD_HR( x ) \ - { \ - HRESULT _hr = x; \ +#define FORWARD_HR( x ) \ + { \ + HRESULT _hr = x; \ if( FAILED( _hr ) ) \ - { \ - return _hr; \ - } \ + { \ + return _hr; \ + } \ } - #define CR_RETURN_VAL( x, failValue ) \ - { \ - HRESULT _hr = x; \ - if( FAILED(_hr) ) \ - { \ +#define CR_RETURN_VAL( x, failValue ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + { \ ReportHresultError( __FILE__, __LINE__, #x, _hr ); \ - BreakInDebugger(); \ - return failValue; \ - } \ + BreakInDebugger(); \ + return failValue; \ + } \ } #else - #define CR( x ) x - #define CR_RETURN( x ) { if( FAILED( x ) ) return; } - #define CR_RETURN_HR( x ) { HRESULT _hr = x; if( FAILED( _hr ) ) return _hr; } - #define CR_RETURN_VAL( x, failValue ) { if( FAILED( x ) ) return failValue; } - #define FORWARD_HR( x ) { HRESULT _hr = x; if( FAILED( _hr ) ) return _hr; } +#define CR( x ) x +#define CR_RETURN( x ) \ + { \ + if( FAILED( x ) ) \ + return; \ + } +#define CR_RETURN_HR( x ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + return _hr; \ + } +#define CR_RETURN_VAL( x, failValue ) \ + { \ + if( FAILED( x ) ) \ + return failValue; \ + } +#define FORWARD_HR( x ) \ + { \ + HRESULT _hr = x; \ + if( FAILED( _hr ) ) \ + return _hr; \ + } #endif @@ -106,12 +124,22 @@ namespace Be { template -struct Result {}; +struct Result +{ +}; } -template inline bool BeIsSuccess( const Be::Result& ) { return false; } -template const char* BeGetErrorMessage( const Be::Result& result ) { return ""; } +template +inline bool BeIsSuccess( const Be::Result& ) +{ + return false; +} +template +const char* BeGetErrorMessage( const Be::Result& result ) +{ + return ""; +} #endif @@ -120,7 +148,7 @@ template const char* BeGetErrorMessage( const Be::Result& result // A specialization of Be::Result for HRESULT type. Most AL operations return this // object as a method result. You can use usual macros (SUCCEEDED, FAIL, CR, etc.) with // this object. -// When TRACK_ALRESULT macro is defined to 1 this object also tracks if its result +// When TRACK_ALRESULT macro is defined to 1 this object also tracks if its result // was checked and if it wasn't, the object will check the result in its destructor // using CR macro. // -------------------------------------------------------------------------------------- @@ -146,36 +174,33 @@ struct Be::Result }; #if TRACK_ALRESULT == 0 - Result() - :m_result( S_OK ) + Result() : + m_result( S_OK ) { } - Result( HRESULT result ) - :m_result( result ) + Result( HRESULT result ) : + m_result( result ) { } - + HRESULT GetResult() const { return m_result; } #else - Result() - :m_result( S_OK ) - , m_isChecked( false ) + Result() : + m_result( S_OK ), m_isChecked( false ) { } - Result( HRESULT result ) - :m_result( result ) - , m_isChecked( false ) + Result( HRESULT result ) : + m_result( result ), m_isChecked( false ) { } - - Result( const Result& result ) - :m_result( result.m_result ) - , m_isChecked( false ) + + Result( const Result& result ) : + m_result( result.m_result ), m_isChecked( false ) { result.m_isChecked = true; } @@ -206,10 +231,10 @@ struct Be::Result return m_result; } #endif - - operator HRESULT() const - { - return GetResult(); + + operator HRESULT() const + { + return GetResult(); } Category GetCategory() const; @@ -218,6 +243,7 @@ struct Be::Result { return m_result == hr; } + private: Result( bool ); operator bool() const; @@ -228,12 +254,14 @@ struct Be::Result #endif }; -template<> inline bool BeIsSuccess( const Be::Result& result ) +template <> +inline bool BeIsSuccess( const Be::Result& result ) { return SUCCEEDED( result ); } -template<> const char* BeGetErrorMessage( const Be::Result& result ); +template <> +const char* BeGetErrorMessage( const Be::Result& result ); #if TRINITY_AL_WITH_BLUE_EXPOSURE && BLUE_WITH_PYTHON @@ -242,7 +270,8 @@ template<> const char* BeGetErrorMessage( const Be::Result& result ); // GetException function for ALResult. We declare it here so that it's picked up // by BlueExposure whenever ALResult is used. Its body needs to be defined outside // TrinityAL. -template<> PyObject* BeGetException( const Be::Result& result ); +template <> +PyObject* BeGetException( const Be::Result& result ); #endif diff --git a/trinityal/BcDecompress.cpp b/trinityal/BcDecompress.cpp index c16d812cf..ed7e71601 100644 --- a/trinityal/BcDecompress.cpp +++ b/trinityal/BcDecompress.cpp @@ -7,11 +7,11 @@ using namespace Tr2RenderContextEnum; namespace { -inline unsigned ConvertBGR565A8ToBGRA8( uint32_t color, uint32_t alpha ) +inline unsigned ConvertBGR565A8ToBGRA8( uint32_t color, uint32_t alpha ) { - return uint32_t( color & 0x1f ) * 255 / 31 | - ( uint32_t( ( color >> 5 ) & 0x3f ) * 255 / 63 ) << 8 | - ( uint32_t( ( color >> 11 ) & 0x1f ) * 255 / 31 ) << 16 | + return uint32_t( color & 0x1f ) * 255 / 31 | + ( uint32_t( ( color >> 5 ) & 0x3f ) * 255 / 63 ) << 8 | + ( uint32_t( ( color >> 11 ) & 0x1f ) * 255 / 31 ) << 16 | ( alpha << 24 ); } @@ -85,7 +85,7 @@ void DecompressBc1( uint32_t width, uint32_t height, uint32_t depth, const Tr2Su { uint32_t destY = j + y; uint32_t* destPixel = reinterpret_cast( decompressed + k * slice + destY * pitch + ( x + i ) * sizeof( uint32_t ) ); - switch( ( bits >> 2*(4*y+x) ) & 3 ) + switch( ( bits >> 2 * ( 4 * y + x ) ) & 3 ) { case 0: *destPixel = color0 | 0xff000000; @@ -172,24 +172,24 @@ void DecompressBc3( uint32_t width, uint32_t height, uint32_t depth, const Tr2Su alpha[0] = *reinterpret_cast( source ); alpha[1] = *reinterpret_cast( source + 1 ); auto alphaMask = source + 2; - uint32_t alphaMask0 = (alphaMask[0]) | (alphaMask[1] << 8) | (alphaMask[2] << 16); - uint32_t alphaMask1 = (alphaMask[3]) | (alphaMask[4] << 8) | (alphaMask[5] << 16); - if( alpha[0] > alpha[1] ) - { - alpha[2] = (6 * alpha[0] + 1 * alpha[1] + 3) / 7; - alpha[3] = (5 * alpha[0] + 2 * alpha[1] + 3) / 7; - alpha[4] = (4 * alpha[0] + 3 * alpha[1] + 3) / 7; - alpha[5] = (3 * alpha[0] + 4 * alpha[1] + 3) / 7; - alpha[6] = (2 * alpha[0] + 5 * alpha[1] + 3) / 7; - alpha[7] = (1 * alpha[0] + 6 * alpha[1] + 3) / 7; - } - else - { - alpha[2] = (4 * alpha[0] + 1 * alpha[1] + 2) / 5; - alpha[3] = (3 * alpha[0] + 2 * alpha[1] + 2) / 5; - alpha[4] = (2 * alpha[0] + 3 * alpha[1] + 2) / 5; - alpha[5] = (1 * alpha[0] + 4 * alpha[1] + 2) / 5; - alpha[6] = 0; + uint32_t alphaMask0 = ( alphaMask[0] ) | ( alphaMask[1] << 8 ) | ( alphaMask[2] << 16 ); + uint32_t alphaMask1 = ( alphaMask[3] ) | ( alphaMask[4] << 8 ) | ( alphaMask[5] << 16 ); + if( alpha[0] > alpha[1] ) + { + alpha[2] = ( 6 * alpha[0] + 1 * alpha[1] + 3 ) / 7; + alpha[3] = ( 5 * alpha[0] + 2 * alpha[1] + 3 ) / 7; + alpha[4] = ( 4 * alpha[0] + 3 * alpha[1] + 3 ) / 7; + alpha[5] = ( 3 * alpha[0] + 4 * alpha[1] + 3 ) / 7; + alpha[6] = ( 2 * alpha[0] + 5 * alpha[1] + 3 ) / 7; + alpha[7] = ( 1 * alpha[0] + 6 * alpha[1] + 3 ) / 7; + } + else + { + alpha[2] = ( 4 * alpha[0] + 1 * alpha[1] + 2 ) / 5; + alpha[3] = ( 3 * alpha[0] + 2 * alpha[1] + 2 ) / 5; + alpha[4] = ( 2 * alpha[0] + 3 * alpha[1] + 2 ) / 5; + alpha[5] = ( 1 * alpha[0] + 4 * alpha[1] + 2 ) / 5; + alpha[6] = 0; alpha[7] = 255; } @@ -251,13 +251,13 @@ bool BcDecompress( uint32_t width, uint32_t height, uint32_t depth, PixelFormat case PIXEL_FORMAT_BC1_UNORM_SRGB: DecompressBc1( width, height, depth, src, decompressed.get() ); return true; - + case PIXEL_FORMAT_BC2_TYPELESS: case PIXEL_FORMAT_BC2_UNORM: case PIXEL_FORMAT_BC2_UNORM_SRGB: DecompressBc2( width, height, depth, src, decompressed.get() ); return true; - + case PIXEL_FORMAT_BC3_TYPELESS: case PIXEL_FORMAT_BC3_UNORM: case PIXEL_FORMAT_BC3_UNORM_SRGB: diff --git a/trinityal/BcDecompress.h b/trinityal/BcDecompress.h index 796c36c0d..2dc022ddc 100644 --- a/trinityal/BcDecompress.h +++ b/trinityal/BcDecompress.h @@ -7,12 +7,12 @@ #include "Tr2RenderContextEnum.h" #include "Tr2HalHelperStructures.h" -bool BcDecompress( - uint32_t width, - uint32_t height, - uint32_t depth, - Tr2RenderContextEnum::PixelFormat format, - const Tr2SubresourceData& src, +bool BcDecompress( + uint32_t width, + uint32_t height, + uint32_t depth, + Tr2RenderContextEnum::PixelFormat format, + const Tr2SubresourceData& src, std::unique_ptr& decompressed ); #endif \ No newline at end of file diff --git a/trinityal/ITr2RenderContextEvents.h b/trinityal/ITr2RenderContextEvents.h index 9704cd908..626b2929d 100644 --- a/trinityal/ITr2RenderContextEvents.h +++ b/trinityal/ITr2RenderContextEvents.h @@ -9,7 +9,7 @@ class Tr2TextureAL; // -------------------------------------------------------------------------------------- // Description: -// A set of callbacks from Tr2RenderContextAL. +// A set of callbacks from Tr2RenderContextAL. // -------------------------------------------------------------------------------------- struct ITr2RenderContextEvents { diff --git a/trinityal/StdAfx.h b/trinityal/StdAfx.h index 6b91646a8..bd6d1199b 100644 --- a/trinityal/StdAfx.h +++ b/trinityal/StdAfx.h @@ -4,14 +4,14 @@ #define TrinityAL_StdAfx_H #ifdef _MSC_VER -#pragma warning(push, 3) +#pragma warning( push, 3 ) #endif #ifdef _WIN32 #ifndef NOMINMAX - #define NOMINMAX //don't want that evil microsoft macro +#define NOMINMAX //don't want that evil microsoft macro #endif -#include +#include #endif #include @@ -22,7 +22,7 @@ #ifdef _WIN32 typedef HWND Tr2WindowHandle; -#elif defined(__APPLE__) +#elif defined( __APPLE__ ) #include typedef id Tr2WindowHandle; #else @@ -30,12 +30,12 @@ typedef uintptr_t Tr2WindowHandle; #endif #ifdef _MSC_VER -#pragma warning(pop) +#pragma warning( pop ) #endif #include "include/TrinityALForward.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 || TRINITY_PLATFORM==TRINITY_DIRECTX12 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 || TRINITY_PLATFORM == TRINITY_DIRECTX12 ) #include #endif diff --git a/trinityal/Tr2AdapterStructures.h b/trinityal/Tr2AdapterStructures.h index 3ff258cef..e4f8cc592 100644 --- a/trinityal/Tr2AdapterStructures.h +++ b/trinityal/Tr2AdapterStructures.h @@ -8,10 +8,10 @@ struct AdapterGuid { - uint32_t data1; - uint16_t data2; - uint16_t data3; - uint8_t data4[8]; + uint32_t data1; + uint16_t data2; + uint16_t data3; + uint8_t data4[8]; }; struct Tr2DisplayModeInfo @@ -21,8 +21,8 @@ struct Tr2DisplayModeInfo uint32_t refreshRateNumerator; uint32_t refreshRateDenominator; Tr2RenderContextEnum::PixelFormat format; - Tr2RenderContextEnum::ScanlineOrdering scanlineOrdering; - Tr2RenderContextEnum::DisplayScaling scaling; + Tr2RenderContextEnum::ScanlineOrdering scanlineOrdering; + Tr2RenderContextEnum::DisplayScaling scaling; }; struct Tr2VideoDriverInfo diff --git a/trinityal/Tr2DeviceResourceAL.cpp b/trinityal/Tr2DeviceResourceAL.cpp index 4ceb154e8..2601b3535 100644 --- a/trinityal/Tr2DeviceResourceAL.cpp +++ b/trinityal/Tr2DeviceResourceAL.cpp @@ -6,50 +6,50 @@ namespace { - typedef std::set AllResourcesType; +typedef std::set AllResourcesType; - AllResourcesType& GetAllResources() - { - static AllResourcesType allResources; - return allResources; - } +AllResourcesType& GetAllResources() +{ + static AllResourcesType allResources; + return allResources; +} - CcpMutex& GetAllResourcesMutex() - { - static CcpMutex mutex( "GetAllResourcesMutex", "mutex" ); - return mutex; - } +CcpMutex& GetAllResourcesMutex() +{ + static CcpMutex mutex( "GetAllResourcesMutex", "mutex" ); + return mutex; +} - bool s_resourcesMutated = false; +bool s_resourcesMutated = false; } namespace TrinityALImpl { - Tr2BaseDeviceResourceAL::Tr2BaseDeviceResourceAL() - { - CcpAutoMutex lock( GetAllResourcesMutex() ); - GetAllResources().insert( this ); - s_resourcesMutated = true; - } +Tr2BaseDeviceResourceAL::Tr2BaseDeviceResourceAL() +{ + CcpAutoMutex lock( GetAllResourcesMutex() ); + GetAllResources().insert( this ); + s_resourcesMutated = true; +} - Tr2BaseDeviceResourceAL::~Tr2BaseDeviceResourceAL() - { - CcpAutoMutex lock( GetAllResourcesMutex() ); - GetAllResources().erase( this ); - s_resourcesMutated = true; - } +Tr2BaseDeviceResourceAL::~Tr2BaseDeviceResourceAL() +{ + CcpAutoMutex lock( GetAllResourcesMutex() ); + GetAllResources().erase( this ); + s_resourcesMutated = true; +} - void Tr2BaseDeviceResourceAL::EnumerateResources( ResourceOperation* operation ) - { - CcpAutoMutex lock( GetAllResourcesMutex() ); - auto& allResources = GetAllResources(); +void Tr2BaseDeviceResourceAL::EnumerateResources( ResourceOperation* operation ) +{ + CcpAutoMutex lock( GetAllResourcesMutex() ); + auto& allResources = GetAllResources(); - for( auto it = begin( allResources ); it != end( allResources ); ++it ) - { - ( *operation )( *it ); - } + for( auto it = begin( allResources ); it != end( allResources ); ++it ) + { + ( *operation )( *it ); } } +} void DescribeDeviceResources( Tr2DescribeDeviceResourceOperationAL operation ) { @@ -85,6 +85,5 @@ void DestroyDeviceResources( Tr2ALMemoryTypes memoryTypes ) break; } } - } - while( s_resourcesMutated ); + } while( s_resourcesMutated ); } diff --git a/trinityal/Tr2DeviceResourceAL.h b/trinityal/Tr2DeviceResourceAL.h index 2c44fba74..7ee94784d 100644 --- a/trinityal/Tr2DeviceResourceAL.h +++ b/trinityal/Tr2DeviceResourceAL.h @@ -4,7 +4,7 @@ enum Tr2ALMemoryType { - AL_MEMORY_VIDEO = 1 << 0, // resources created on video card memory + AL_MEMORY_VIDEO = 1 << 0, // resources created on video card memory AL_MEMORY_MANAGED = 1 << 1, // resources created in device memory }; @@ -16,37 +16,37 @@ typedef int Tr2ALMemoryTypes; namespace TrinityALImpl { - - class Tr2BaseDeviceResourceAL - { - public: - typedef void ( *ResourceOperation )( Tr2BaseDeviceResourceAL* ); - Tr2BaseDeviceResourceAL(); - virtual ~Tr2BaseDeviceResourceAL(); +class Tr2BaseDeviceResourceAL +{ +public: + typedef void ( *ResourceOperation )( Tr2BaseDeviceResourceAL* ); + + Tr2BaseDeviceResourceAL(); + virtual ~Tr2BaseDeviceResourceAL(); + + virtual bool IsResourceValid() const = 0; + virtual Tr2ALMemoryType GetResourceMemoryClass() const = 0; + virtual void Destroy() = 0; + virtual void Describe( Tr2DeviceResourceDescriptionAL& description ) const = 0; - virtual bool IsResourceValid() const = 0; - virtual Tr2ALMemoryType GetResourceMemoryClass() const = 0; - virtual void Destroy() = 0; - virtual void Describe( Tr2DeviceResourceDescriptionAL& description ) const = 0; + static void EnumerateResources( ResourceOperation* operation ); +}; - static void EnumerateResources( ResourceOperation* operation ); - }; +template +class Tr2DeviceResourceAL : public Tr2BaseDeviceResourceAL +{ +public: + bool IsResourceValid() const override + { + return static_cast( this )->IsValid(); + } - template - class Tr2DeviceResourceAL: public Tr2BaseDeviceResourceAL + Tr2ALMemoryType GetResourceMemoryClass() const override { - public: - bool IsResourceValid() const override - { - return static_cast( this )->IsValid(); - } - - Tr2ALMemoryType GetResourceMemoryClass() const override - { - return static_cast( this )->GetMemoryClass(); - } - }; + return static_cast( this )->GetMemoryClass(); + } +}; } diff --git a/trinityal/Tr2DrawUPHelper.cpp b/trinityal/Tr2DrawUPHelper.cpp index fc0ad1699..4b1ede1ec 100644 --- a/trinityal/Tr2DrawUPHelper.cpp +++ b/trinityal/Tr2DrawUPHelper.cpp @@ -9,267 +9,267 @@ using namespace Tr2RenderContextEnum; namespace { - uint32_t ComputeVertexCount( Topology topology, uint32_t primitiveCount ) +uint32_t ComputeVertexCount( Topology topology, uint32_t primitiveCount ) +{ + switch( topology ) { - switch( topology ) - { - case TOP_TRIANGLES: - return primitiveCount * 3; + case TOP_TRIANGLES: + return primitiveCount * 3; - case TOP_TRIANGLE_STRIP: - return primitiveCount + 2; + case TOP_TRIANGLE_STRIP: + return primitiveCount + 2; - case TOP_LINES: - return primitiveCount * 2; + case TOP_LINES: + return primitiveCount * 2; - case TOP_LINE_STRIP: - return primitiveCount + 1; + case TOP_LINE_STRIP: + return primitiveCount + 1; - case TOP_POINTS: - case TOP_TRIANGLE_FAN: - return primitiveCount; + case TOP_POINTS: + case TOP_TRIANGLE_FAN: + return primitiveCount; - default: - CCP_ASSERT_M( false, "Unsupported topology" ); - return 0; - } + default: + CCP_ASSERT_M( false, "Unsupported topology" ); + return 0; } +} } namespace TrinityALImpl { - Tr2DrawUPHelper::Tr2DrawUPHelper() - : m_nextRingVB( 0 ) - , m_nextRingIB16( 0 ) - , m_nextRingIB32( 0 ) - {} +Tr2DrawUPHelper::Tr2DrawUPHelper() : + m_nextRingVB( 0 ), m_nextRingIB16( 0 ), m_nextRingIB32( 0 ) +{ +} + +Tr2DrawUPHelper::~Tr2DrawUPHelper() +{ + Destroy(); +} - Tr2DrawUPHelper::~Tr2DrawUPHelper() +void Tr2DrawUPHelper::Destroy() +{ + for( unsigned i = 0; i != DRAW_UP_RING_SIZE; ++i ) { - Destroy(); + m_vertexUP[i] = ::Tr2BufferAL(); + m_indexUP16[i] = ::Tr2BufferAL(); + m_indexUP32[i] = ::Tr2BufferAL(); } - void Tr2DrawUPHelper::Destroy() + m_nextRingVB = m_nextRingIB16 = m_nextRingIB32 = 0; +} + +ALResult Tr2DrawUPHelper::FillUPVertexBuffer( + uint32_t vertexCount, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + const uint32_t totalSize = vertexCount * vertexStreamZeroStride; + + if( totalSize == 0 ) { - for( unsigned i = 0; i != DRAW_UP_RING_SIZE; ++i ) - { - m_vertexUP[i] = ::Tr2BufferAL(); - m_indexUP16[i] = ::Tr2BufferAL(); - m_indexUP32[i] = ::Tr2BufferAL(); - } - - m_nextRingVB = m_nextRingIB16 = m_nextRingIB32 = 0; + return S_OK; } - ALResult Tr2DrawUPHelper::FillUPVertexBuffer( - uint32_t vertexCount, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) + if( totalSize > buffer.GetDesc().count * buffer.GetDesc().stride ) { - const uint32_t totalSize = vertexCount * vertexStreamZeroStride; - - if( totalSize == 0 ) - { - return S_OK; - } - - if( totalSize > buffer.GetDesc().count * buffer.GetDesc().stride ) - { - CR_RETURN_HR( buffer.Create( 4, ( totalSize + 3 ) / 4, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, device ) ); - } - - void* mapped = nullptr; - CR_RETURN_HR( buffer.MapForWriting( mapped, renderContext ) ); - if( !mapped ) - { - buffer.UnmapForWriting( renderContext ); - return E_FAIL; - } - memcpy( mapped, vertexStreamZeroData, totalSize ); - buffer.UnmapForWriting( renderContext ); - - return S_OK; + CR_RETURN_HR( buffer.Create( 4, ( totalSize + 3 ) / 4, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, device ) ); } - ALResult Tr2DrawUPHelper::DrawPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t primitiveCount, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) + void* mapped = nullptr; + CR_RETURN_HR( buffer.MapForWriting( mapped, renderContext ) ); + if( !mapped ) { - if( primitiveCount == 0 ) - { - return S_OK; - } - - CR_RETURN_HR( FillUPVertexBuffer( ComputeVertexCount( topology, primitiveCount ), - vertexStreamZeroData, - vertexStreamZeroStride, - m_vertexUP[m_nextRingVB], - renderContext, - device ) ); - - CR_RETURN_HR( renderContext.SetStreamSource( - 0, - m_vertexUP[m_nextRingVB], - 0, - vertexStreamZeroStride ) ); - - m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; - - return renderContext.DrawPrimitive( 0, primitiveCount ); + buffer.UnmapForWriting( renderContext ); + return E_FAIL; } + memcpy( mapped, vertexStreamZeroData, totalSize ); + buffer.UnmapForWriting( renderContext ); - ALResult Tr2DrawUPHelper::FillUPIndexBuffer( - uint32_t indexCount, - const uint16_t* indices, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) + return S_OK; +} + +ALResult Tr2DrawUPHelper::DrawPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t primitiveCount, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + if( primitiveCount == 0 ) { - return FillUPIndexBuffer( indexCount, - (const void*)indices, - 2, - buffer, - renderContext, - device ); + return S_OK; } - ALResult Tr2DrawUPHelper::FillUPIndexBuffer( - uint32_t indexCount, - const uint32_t* indices, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) + CR_RETURN_HR( FillUPVertexBuffer( ComputeVertexCount( topology, primitiveCount ), + vertexStreamZeroData, + vertexStreamZeroStride, + m_vertexUP[m_nextRingVB], + renderContext, + device ) ); + + CR_RETURN_HR( renderContext.SetStreamSource( + 0, + m_vertexUP[m_nextRingVB], + 0, + vertexStreamZeroStride ) ); + + m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; + + return renderContext.DrawPrimitive( 0, primitiveCount ); +} + +ALResult Tr2DrawUPHelper::FillUPIndexBuffer( + uint32_t indexCount, + const uint16_t* indices, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + return FillUPIndexBuffer( indexCount, + (const void*)indices, + 2, + buffer, + renderContext, + device ); +} + +ALResult Tr2DrawUPHelper::FillUPIndexBuffer( + uint32_t indexCount, + const uint32_t* indices, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + return FillUPIndexBuffer( indexCount, + (const void*)indices, + 4, + buffer, + renderContext, + device ); +} + +ALResult Tr2DrawUPHelper::FillUPIndexBuffer( + uint32_t indexCount, + const void* indices, + uint32_t bytesPerIndex, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + const uint32_t totalSize = indexCount * bytesPerIndex; + + if( indexCount > buffer.GetDesc().count ) { - return FillUPIndexBuffer( indexCount, - (const void*)indices, - 4, - buffer, - renderContext, - device ); + CR_RETURN_HR( buffer.Create( bytesPerIndex, indexCount, Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, device ) ); } - ALResult Tr2DrawUPHelper::FillUPIndexBuffer( - uint32_t indexCount, - const void* indices, - uint32_t bytesPerIndex, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) + void* mapped = nullptr; + CR_RETURN_HR( buffer.MapForWriting( mapped, renderContext ) ); + if( !mapped ) { - const uint32_t totalSize = indexCount * bytesPerIndex; - - if( indexCount > buffer.GetDesc().count ) - { - CR_RETURN_HR( buffer.Create( bytesPerIndex, indexCount, Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::WRITE_OFTEN, nullptr, device ) ); - } - - void* mapped = nullptr; - CR_RETURN_HR( buffer.MapForWriting( mapped, renderContext ) ); - if( !mapped ) - { - buffer.UnmapForWriting( renderContext ); - return E_FAIL; - } - memcpy( mapped, indices, totalSize ); buffer.UnmapForWriting( renderContext ); - - return S_OK; + return E_FAIL; } + memcpy( mapped, indices, totalSize ); + buffer.UnmapForWriting( renderContext ); + + return S_OK; +} - ALResult Tr2DrawUPHelper::DrawIndexedPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) +ALResult Tr2DrawUPHelper::DrawIndexedPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + if( primitiveCount == 0 ) { - if( primitiveCount == 0 ) - { - return S_OK; - } - - CR_RETURN_HR( FillUPVertexBuffer( numVertices, - vertexStreamZeroData, - vertexStreamZeroStride, - m_vertexUP[m_nextRingVB], - renderContext, - device ) ); - - CR_RETURN_HR( renderContext.SetStreamSource( - 0, - m_vertexUP[m_nextRingVB], - 0, - vertexStreamZeroStride ) ); - - m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; - - CR_RETURN_HR( FillUPIndexBuffer( ComputeVertexCount( topology, primitiveCount ), - indexData, - 4, - m_indexUP32[m_nextRingIB32], - renderContext, - device ) ); - - CR_RETURN_HR( renderContext.SetIndices( m_indexUP32[m_nextRingIB32] ) ); - - m_nextRingIB32 = ( m_nextRingIB32 + 1 ) % DRAW_UP_RING_SIZE; - - return renderContext.DrawIndexedPrimitive( numVertices, 0, primitiveCount ); + return S_OK; } - ALResult Tr2DrawUPHelper::DrawIndexedPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ) - { - if( primitiveCount == 0 ) - { - return S_OK; - } + CR_RETURN_HR( FillUPVertexBuffer( numVertices, + vertexStreamZeroData, + vertexStreamZeroStride, + m_vertexUP[m_nextRingVB], + renderContext, + device ) ); - CR_RETURN_HR( FillUPVertexBuffer( numVertices, - vertexStreamZeroData, - vertexStreamZeroStride, - m_vertexUP[m_nextRingVB], - renderContext, - device ) ); + CR_RETURN_HR( renderContext.SetStreamSource( + 0, + m_vertexUP[m_nextRingVB], + 0, + vertexStreamZeroStride ) ); - CR_RETURN_HR( renderContext.SetStreamSource( - 0, - m_vertexUP[m_nextRingVB], - 0, - vertexStreamZeroStride ) ); + m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; - m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; + CR_RETURN_HR( FillUPIndexBuffer( ComputeVertexCount( topology, primitiveCount ), + indexData, + 4, + m_indexUP32[m_nextRingIB32], + renderContext, + device ) ); - CR_RETURN_HR( FillUPIndexBuffer( ComputeVertexCount( topology, primitiveCount ), - indexData, 2, - m_indexUP16[m_nextRingIB16], - renderContext, - device ) ); + CR_RETURN_HR( renderContext.SetIndices( m_indexUP32[m_nextRingIB32] ) ); - CR_RETURN_HR( renderContext.SetIndices( m_indexUP16[m_nextRingIB16] ) ); + m_nextRingIB32 = ( m_nextRingIB32 + 1 ) % DRAW_UP_RING_SIZE; - m_nextRingIB16 = ( m_nextRingIB16 + 1 ) % DRAW_UP_RING_SIZE; + return renderContext.DrawIndexedPrimitive( numVertices, 0, primitiveCount ); +} - return renderContext.DrawIndexedPrimitive( numVertices, 0, primitiveCount ); +ALResult Tr2DrawUPHelper::DrawIndexedPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ) +{ + if( primitiveCount == 0 ) + { + return S_OK; } + + CR_RETURN_HR( FillUPVertexBuffer( numVertices, + vertexStreamZeroData, + vertexStreamZeroStride, + m_vertexUP[m_nextRingVB], + renderContext, + device ) ); + + CR_RETURN_HR( renderContext.SetStreamSource( + 0, + m_vertexUP[m_nextRingVB], + 0, + vertexStreamZeroStride ) ); + + m_nextRingVB = ( m_nextRingVB + 1 ) % DRAW_UP_RING_SIZE; + + CR_RETURN_HR( FillUPIndexBuffer( ComputeVertexCount( topology, primitiveCount ), + indexData, + 2, + m_indexUP16[m_nextRingIB16], + renderContext, + device ) ); + + CR_RETURN_HR( renderContext.SetIndices( m_indexUP16[m_nextRingIB16] ) ); + + m_nextRingIB16 = ( m_nextRingIB16 + 1 ) % DRAW_UP_RING_SIZE; + + return renderContext.DrawIndexedPrimitive( numVertices, 0, primitiveCount ); +} } \ No newline at end of file diff --git a/trinityal/Tr2DrawUPHelper.h b/trinityal/Tr2DrawUPHelper.h index 7a91bffaa..d22678e53 100644 --- a/trinityal/Tr2DrawUPHelper.h +++ b/trinityal/Tr2DrawUPHelper.h @@ -12,85 +12,85 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2DrawUPHelper - { - public: - Tr2DrawUPHelper(); - ~Tr2DrawUPHelper(); - - ALResult DrawIndexedPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - ALResult DrawIndexedPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - ALResult DrawPrimitiveUP( - Tr2RenderContextEnum::Topology topology, - uint32_t primitiveCount, - const void* vertexStreamZeroData, - uint32_t VertexStreamZeroStride, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - void Destroy(); - - private: - // Vertex and index buffer to emulate the Draw...UP calls from DX9 - static const uint32_t DRAW_UP_RING_SIZE = 4; - - uint32_t m_nextRingVB, m_nextRingIB16, m_nextRingIB32; - ::Tr2BufferAL m_vertexUP[DRAW_UP_RING_SIZE]; - ::Tr2BufferAL m_indexUP16[DRAW_UP_RING_SIZE]; - ::Tr2BufferAL m_indexUP32[DRAW_UP_RING_SIZE]; - - ALResult FillUPVertexBuffer( - uint32_t vertexCount, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - ALResult FillUPIndexBuffer( - uint32_t indexCount, - const uint16_t* indices, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - ALResult FillUPIndexBuffer( - uint32_t indexCount, - const uint32_t* indices, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - ALResult FillUPIndexBuffer( - uint32_t indexCount, - const void* indices, - uint32_t bytesPerIndex, - ::Tr2BufferAL& buffer, - Tr2RenderContextAL& renderContext, - Tr2PrimaryRenderContextAL& device ); - - Tr2DrawUPHelper( const Tr2DrawUPHelper& ) /* = delete */; - Tr2DrawUPHelper& operator=( const Tr2DrawUPHelper& ) /* = delete */; - }; +class Tr2DrawUPHelper +{ +public: + Tr2DrawUPHelper(); + ~Tr2DrawUPHelper(); + + ALResult DrawIndexedPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + ALResult DrawIndexedPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + ALResult DrawPrimitiveUP( + Tr2RenderContextEnum::Topology topology, + uint32_t primitiveCount, + const void* vertexStreamZeroData, + uint32_t VertexStreamZeroStride, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + void Destroy(); + +private: + // Vertex and index buffer to emulate the Draw...UP calls from DX9 + static const uint32_t DRAW_UP_RING_SIZE = 4; + + uint32_t m_nextRingVB, m_nextRingIB16, m_nextRingIB32; + ::Tr2BufferAL m_vertexUP[DRAW_UP_RING_SIZE]; + ::Tr2BufferAL m_indexUP16[DRAW_UP_RING_SIZE]; + ::Tr2BufferAL m_indexUP32[DRAW_UP_RING_SIZE]; + + ALResult FillUPVertexBuffer( + uint32_t vertexCount, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + ALResult FillUPIndexBuffer( + uint32_t indexCount, + const uint16_t* indices, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + ALResult FillUPIndexBuffer( + uint32_t indexCount, + const uint32_t* indices, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + ALResult FillUPIndexBuffer( + uint32_t indexCount, + const void* indices, + uint32_t bytesPerIndex, + ::Tr2BufferAL& buffer, + Tr2RenderContextAL& renderContext, + Tr2PrimaryRenderContextAL& device ); + + Tr2DrawUPHelper( const Tr2DrawUPHelper& ) /* = delete */; + Tr2DrawUPHelper& operator=( const Tr2DrawUPHelper& ) /* = delete */; +}; } -#endif +#endif diff --git a/trinityal/Tr2DriverUtilities.cpp b/trinityal/Tr2DriverUtilities.cpp index 597e5fc5b..698f2574b 100644 --- a/trinityal/Tr2DriverUtilities.cpp +++ b/trinityal/Tr2DriverUtilities.cpp @@ -58,7 +58,7 @@ bool GetDeviceRegistryKey( uint32_t deviceId, std::string& keyPath ) DISPLAY_DEVICE dd; dd.cb = sizeof( DISPLAY_DEVICE ); - for( int i = 0; EnumDisplayDevices( nullptr, i, &dd, 0 ); ++i ) + for( int i = 0; EnumDisplayDevices( nullptr, i, &dd, 0 ); ++i ) { uint32_t device; if( GetHexIdFromDeviceId( dd.DeviceID, device ) && device == deviceId ) @@ -73,7 +73,7 @@ bool GetDeviceRegistryKey( uint32_t deviceId, std::string& keyPath ) bool GetRegistryValue( HKEY key, const char* name, std::string& value ) { char buffer[256]; - DWORD dwcb_data = sizeof( buffer ); + DWORD dwcb_data = sizeof( buffer ); LONG result = RegQueryValueEx( key, name, nullptr, nullptr, reinterpret_cast( buffer ), &dwcb_data ); if( result == ERROR_SUCCESS ) @@ -141,10 +141,10 @@ ALResult DoGetDriverVersion( uint32_t deviceId, Tr2VideoDriverInfo& info ) namespace Tr2DriverUtilities { -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) ALResult GetDriverVersion( uint32_t deviceId, Tr2VideoDriverInfo& info ) { - if ( deviceId == 0xffffffff ) + if( deviceId == 0xffffffff ) { return E_FAIL; } diff --git a/trinityal/Tr2HalHelperStructures.cpp b/trinityal/Tr2HalHelperStructures.cpp index a39f52a71..8ac5dac87 100644 --- a/trinityal/Tr2HalHelperStructures.cpp +++ b/trinityal/Tr2HalHelperStructures.cpp @@ -17,16 +17,16 @@ using namespace Tr2RenderContextEnum; // the entire resource. // -------------------------------------------------------------------------------------- Tr2TextureSubresource::Tr2TextureSubresource() : - m_startFace( 0 ), - m_endFace( std::numeric_limits::max() ), - m_startMipLevel( 0 ), - m_endMipLevel( 0xffffffff ), + m_startFace( 0 ), + m_endFace( std::numeric_limits::max() ), + m_startMipLevel( 0 ), + m_endMipLevel( 0xffffffff ), m_box{ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff } { } -Tr2TextureSubresource::Tr2TextureSubresource( uint32_t mipLevel ) - :m_startFace( 0 ), +Tr2TextureSubresource::Tr2TextureSubresource( uint32_t mipLevel ) : + m_startFace( 0 ), m_endFace( 1 ), m_startMipLevel( mipLevel ), m_endMipLevel( mipLevel + 1 ), @@ -39,8 +39,8 @@ Tr2TextureSubresource::Tr2TextureSubresource( uint32_t mipLevel ) // Tr2TextureSubresource default constructor: construct a subresource range containing // the a single mip level for a single cubemap face / array slice. // -------------------------------------------------------------------------------------- -Tr2TextureSubresource::Tr2TextureSubresource( uint32_t face, uint32_t mipLevel ) - :m_startFace( face ), +Tr2TextureSubresource::Tr2TextureSubresource( uint32_t face, uint32_t mipLevel ) : + m_startFace( face ), m_endFace( face + 1 ), m_startMipLevel( mipLevel ), m_endMipLevel( mipLevel + 1 ), @@ -50,7 +50,7 @@ Tr2TextureSubresource::Tr2TextureSubresource( uint32_t face, uint32_t mipLevel ) // -------------------------------------------------------------------------------------- // Description: -// Clamps subresource values to a specific texture dimensions. +// Clamps subresource values to a specific texture dimensions. // Arguments: // texture - Texture which dimensions are used to clamp subresource data // -------------------------------------------------------------------------------------- @@ -63,9 +63,9 @@ void Tr2TextureSubresource::ClampToTexture( const Tr2BitmapDimensions& texture ) m_startMipLevel = std::min( m_startMipLevel, texture.GetTrueMipCount() - 1 ); m_endMipLevel = std::min( m_endMipLevel, texture.GetTrueMipCount() ); - uint32_t mipWidth = texture.GetMipWidth( m_startMipLevel ); + uint32_t mipWidth = texture.GetMipWidth( m_startMipLevel ); uint32_t mipHeight = texture.GetMipHeight( m_startMipLevel ); - uint32_t mipDepth = std::max( texture.GetDepth() >> m_startMipLevel, 1u ); + uint32_t mipDepth = std::max( texture.GetDepth() >> m_startMipLevel, 1u ); if( HasBox() ) { @@ -92,7 +92,7 @@ void Tr2TextureSubresource::ClampToTexture( const Tr2BitmapDimensions& texture ) // -------------------------------------------------------------------------------------- // Description: -// Check if subresource covers the entire textures (all slices and all mip levels). +// Check if subresource covers the entire textures (all slices and all mip levels). // Arguments: // texture - Texture to check against // Return Value: @@ -201,11 +201,11 @@ Tr2TextureSubresource& Tr2TextureSubresource::SetRect( uint32_t left, uint32_t t bool Tr2TextureSubresource::operator==( const Tr2TextureSubresource& other ) const { - return m_startFace == other.m_startFace && - m_endFace == other.m_endFace && - m_startMipLevel == other.m_startMipLevel && - m_endMipLevel == other.m_endMipLevel && - m_box == other.m_box; + return m_startFace == other.m_startFace && + m_endFace == other.m_endFace && + m_startMipLevel == other.m_startMipLevel && + m_endMipLevel == other.m_endMipLevel && + m_box == other.m_box; } bool Tr2TextureSubresource::IsValid() const @@ -217,18 +217,18 @@ bool Tr2TextureSubresource::IsValid() const return false; } } - return m_startFace < m_endFace && m_startMipLevel < m_endMipLevel; + return m_startFace < m_endFace && m_startMipLevel < m_endMipLevel; } // Crop both subresources to the given bitmaps as well as each others dimensions; // and run some basic checks on them (IsValid, formats matching, ...). // Returns true if all that passed and a copy would make sense. -bool Crop( Tr2TextureSubresource& sourceSR, - const Tr2BitmapDimensions& sourceBD, - Tr2TextureSubresource& destSR, - const Tr2BitmapDimensions& destBD ) +bool Crop( Tr2TextureSubresource& sourceSR, + const Tr2BitmapDimensions& sourceBD, + Tr2TextureSubresource& destSR, + const Tr2BitmapDimensions& destBD ) { - if( destSR.GetFaceCount() != sourceSR.GetFaceCount() ) + if( destSR.GetFaceCount() != sourceSR.GetFaceCount() ) { return false; } @@ -239,7 +239,7 @@ bool Crop( Tr2TextureSubresource& sourceSR, } sourceSR.ClampToTexture( sourceBD ); - destSR .ClampToTexture( destBD ); + destSR.ClampToTexture( destBD ); if( sourceSR.GetWidth() < destSR.GetWidth() ) { @@ -260,7 +260,7 @@ bool Crop( Tr2TextureSubresource& sourceSR, } sourceSR.ClampToTexture( sourceBD ); - destSR .ClampToTexture( destBD ); + destSR.ClampToTexture( destBD ); if( !sourceSR.IsValid() || !destSR.IsValid() ) { diff --git a/trinityal/Tr2HalHelperStructures.h b/trinityal/Tr2HalHelperStructures.h index 2a09583c3..8858ec054 100644 --- a/trinityal/Tr2HalHelperStructures.h +++ b/trinityal/Tr2HalHelperStructures.h @@ -19,9 +19,9 @@ class Tr2ShaderProgramAL; // ------------------------------------------------------------- struct Tr2SubresourceData { - const void* m_sysMem; // pointer to pixels for this mip - uint32_t m_sysMemPitch; // size in bytes of one line of pixels - uint32_t m_sysMemSlicePitch; // size in bytes of entire mip level. cannot be zero! + const void* m_sysMem; // pointer to pixels for this mip + uint32_t m_sysMemPitch; // size in bytes of one line of pixels + uint32_t m_sysMemSlicePitch; // size in bytes of entire mip level. cannot be zero! }; // ------------------------------------------------------------- @@ -30,22 +30,20 @@ struct Tr2SubresourceData // ------------------------------------------------------------- struct Tr2Viewport { - Tr2Viewport() {} + Tr2Viewport() + { + } - Tr2Viewport( uint32_t width, uint32_t height ) - : m_x(0) - , m_y(0) - , m_width( (float)width ) - , m_height( (float)height ) - , m_minZ(0) - , m_maxZ(1.0f) - {} - float m_x; - float m_y; - float m_width; - float m_height; - float m_minZ; - float m_maxZ; + Tr2Viewport( uint32_t width, uint32_t height ) : + m_x( 0 ), m_y( 0 ), m_width( (float)width ), m_height( (float)height ), m_minZ( 0 ), m_maxZ( 1.0f ) + { + } + float m_x; + float m_y; + float m_width; + float m_height; + float m_minZ; + float m_maxZ; }; struct Tr2TextureCoordBox @@ -78,8 +76,8 @@ struct Tr2TextureCoordBox // -------------------------------------------------------------------------------------- // Description: -// Descibes region of texture (range of cubemap faces, mip levels, rectangle/box -// coordinates) for Tr2TextureAL::CopySubresourceRegion member function. +// Descibes region of texture (range of cubemap faces, mip levels, rectangle/box +// coordinates) for Tr2TextureAL::CopySubresourceRegion member function. // -------------------------------------------------------------------------------------- struct Tr2TextureSubresource { @@ -134,12 +132,12 @@ struct Tr2TextureSubresource // -------------------------------------------------------------------------------------- // Description: -// Descibes texture sampler. Used in creation of Tr2SamplerStateAL objects. +// Descibes texture sampler. Used in creation of Tr2SamplerStateAL objects. // -------------------------------------------------------------------------------------- struct Tr2SamplerDescription { - Tr2SamplerDescription() - : m_minFilter( Tr2RenderContextEnum::TF_POINT ), + Tr2SamplerDescription() : + m_minFilter( Tr2RenderContextEnum::TF_POINT ), m_magFilter( Tr2RenderContextEnum::TF_POINT ), m_mipFilter( Tr2RenderContextEnum::TF_POINT ), m_isComparisonFilter( false ), @@ -171,8 +169,8 @@ struct Tr2SamplerDescription Tr2RenderContextEnum::CompareFunc comparisonFunc, const float* borderColor, float minLOD, - float maxLOD ) - : m_minFilter( minFilter ), + float maxLOD ) : + m_minFilter( minFilter ), m_magFilter( magFilter ), m_mipFilter( mipFilter ), m_isComparisonFilter( isComparisonFilter ), @@ -181,7 +179,7 @@ struct Tr2SamplerDescription m_addressW( addressW ), m_mipLODBias( mipLODBias ), m_maxAnisotropy( maxAnisotropy ), - m_comparisonFunc( comparisonFunc ), + m_comparisonFunc( comparisonFunc ), m_minLOD( minLOD ), m_maxLOD( maxLOD ) { @@ -196,8 +194,8 @@ struct Tr2SamplerDescription Tr2RenderContextEnum::TextureAddressMode address, uint32_t maxAnisotropy = 1, float minLOD = 0.0f, - float maxLOD = std::numeric_limits::max() ) - : m_minFilter( filter ), + float maxLOD = std::numeric_limits::max() ) : + m_minFilter( filter ), m_magFilter( filter ), m_mipFilter( filter ), m_isComparisonFilter( false ), @@ -253,26 +251,26 @@ struct Tr2SamplerDescription namespace std { - template<> struct hash +template <> +struct hash +{ + std::size_t operator()( const Tr2SamplerDescription& desc ) const { - std::size_t operator()( const Tr2SamplerDescription& desc ) const - { - return - std::hash()( desc.m_minFilter ) ^ - ( std::hash()( desc.m_mipFilter ) << 1 ) ^ - ( std::hash()( desc.m_magFilter ) << 2 ) ^ - ( std::hash()( desc.m_addressU ) << 3 ) ^ - ( std::hash()( desc.m_addressV ) << 4 ) ^ - ( std::hash()( desc.m_addressW ) << 5 ); - } - }; + return std::hash()( desc.m_minFilter ) ^ + ( std::hash()( desc.m_mipFilter ) << 1 ) ^ + ( std::hash()( desc.m_magFilter ) << 2 ) ^ + ( std::hash()( desc.m_addressU ) << 3 ) ^ + ( std::hash()( desc.m_addressV ) << 4 ) ^ + ( std::hash()( desc.m_addressW ) << 5 ); + } +}; } -bool Crop( Tr2TextureSubresource& sourceSR, - const Tr2BitmapDimensions& sourceBD, - Tr2TextureSubresource& destSR, - const Tr2BitmapDimensions& destBD ); +bool Crop( Tr2TextureSubresource& sourceSR, + const Tr2BitmapDimensions& sourceBD, + Tr2TextureSubresource& destSR, + const Tr2BitmapDimensions& destBD ); void AdvanceMip( Tr2TextureSubresource& sub, const Tr2BitmapDimensions& bd, uint32_t mip ); @@ -282,18 +280,18 @@ struct Tr2MsaaDesc uint32_t samples; uint32_t quality; - Tr2MsaaDesc( uint32_t samples_ = 1, uint32_t quality_ = 0 ) - :samples( std::max( samples_, 1u ) ), + Tr2MsaaDesc( uint32_t samples_ = 1, uint32_t quality_ = 0 ) : + samples( std::max( samples_, 1u ) ), quality( quality_ ) { } - bool operator == ( const Tr2MsaaDesc& other ) const + bool operator==( const Tr2MsaaDesc& other ) const { return std::max( samples, 1u ) == std::max( other.samples, 1u ) && quality == other.quality; } - bool operator != ( const Tr2MsaaDesc& other ) const + bool operator!=( const Tr2MsaaDesc& other ) const { return std::max( samples, 1u ) != std::max( other.samples, 1u ) || quality != other.quality; } diff --git a/trinityal/Tr2LockGuard.cpp b/trinityal/Tr2LockGuard.cpp index 0333f1ea8..a49e62a0a 100644 --- a/trinityal/Tr2LockGuard.cpp +++ b/trinityal/Tr2LockGuard.cpp @@ -3,8 +3,8 @@ #include "StdAfx.h" #include "Tr2LockGuard.h" -Tr2LockGuard::Tr2LockGuard() - :m_memory( nullptr ), +Tr2LockGuard::Tr2LockGuard() : + m_memory( nullptr ), m_originalMemory( nullptr ), m_size( 0 ) { @@ -39,7 +39,7 @@ void Tr2LockGuard::Lock( size_t size, void* originalMemory ) m_memory = CCPMallocWithGuard( size ); if( !m_memory ) { - CCP_LOGERR(" TrinityAL: guarded lock out of memory (size: %zu)", size ); + CCP_LOGERR( " TrinityAL: guarded lock out of memory (size: %zu)", size ); } else { diff --git a/trinityal/Tr2LockGuard.h b/trinityal/Tr2LockGuard.h index d116a71d1..145cdb45f 100644 --- a/trinityal/Tr2LockGuard.h +++ b/trinityal/Tr2LockGuard.h @@ -13,6 +13,7 @@ class Tr2LockGuard void Lock( size_t size, void* originalMemory ); void Unlock(); void* GetMemory(); + private: void* m_originalMemory; void* m_memory; diff --git a/trinityal/Tr2MemoryCounterAL.cpp b/trinityal/Tr2MemoryCounterAL.cpp index 8a1667012..7bc090240 100644 --- a/trinityal/Tr2MemoryCounterAL.cpp +++ b/trinityal/Tr2MemoryCounterAL.cpp @@ -9,14 +9,14 @@ CCP_STATS_DECLARE( gpuMemoryTextureEst, "Trinity/AL/gpuMemoryEst/textures", fals CCP_STATS_DECLARE( gpuMemoryOtherEst, "Trinity/AL/gpuMemoryEst/other", false, CST_MEMORY, "Total estimated GPU memory (neither buffer nor textures)" ); -Tr2MemoryCounterAL::Tr2MemoryCounterAL() - :m_memoryType( SYSTEM_MEMORY ), +Tr2MemoryCounterAL::Tr2MemoryCounterAL() : + m_memoryType( SYSTEM_MEMORY ), m_size( 0 ) { } -Tr2MemoryCounterAL::Tr2MemoryCounterAL( Tr2MemoryCounterAL&& other ) - :m_memoryType( other.m_memoryType ), +Tr2MemoryCounterAL::Tr2MemoryCounterAL( Tr2MemoryCounterAL&& other ) : + m_memoryType( other.m_memoryType ), m_size( other.m_size ) { other.m_size = 0; @@ -56,16 +56,16 @@ void Tr2MemoryCounterAL::Set( MemoryType memoryType, size_t size ) void Tr2MemoryCounterAL::Grow( size_t size ) { - m_size += size; - UpdateCounters( int32_t( size ) ); + m_size += size; + UpdateCounters( int32_t( size ) ); } void Tr2MemoryCounterAL::Shrink( size_t size ) { - CCP_ASSERT( size <= m_size ); - - m_size -= size; - UpdateCounters( -int32_t( size ) ); + CCP_ASSERT( size <= m_size ); + + m_size -= size; + UpdateCounters( -int32_t( size ) ); } void Tr2MemoryCounterAL::Set( MemoryType memoryType, const Tr2BitmapDimensions& bitmap, const Tr2MsaaDesc& msaa ) diff --git a/trinityal/Tr2MemoryCounterAL.h b/trinityal/Tr2MemoryCounterAL.h index c186145d1..9e18f297a 100644 --- a/trinityal/Tr2MemoryCounterAL.h +++ b/trinityal/Tr2MemoryCounterAL.h @@ -24,9 +24,10 @@ class Tr2MemoryCounterAL void Set( MemoryType memoryType, size_t size ); void Set( MemoryType memoryType, const Tr2BitmapDimensions& bitmap, const Tr2MsaaDesc& msaa = Tr2MsaaDesc() ); - void Grow( size_t size ); - void Shrink( size_t size ); + void Grow( size_t size ); + void Shrink( size_t size ); void Reset(); + private: Tr2MemoryCounterAL( const Tr2MemoryCounterAL& ) /* = delete */; Tr2MemoryCounterAL& operator=( const Tr2MemoryCounterAL& ) /* = delete */; diff --git a/trinityal/Tr2ObjectFactory.h b/trinityal/Tr2ObjectFactory.h index 95ee20015..fae57fe1d 100644 --- a/trinityal/Tr2ObjectFactory.h +++ b/trinityal/Tr2ObjectFactory.h @@ -7,37 +7,38 @@ class Tr2PrimaryRenderContextAL; namespace TrinityALImpl { - template - class Tr2ObjectFactory +template +class Tr2ObjectFactory +{ +public: + ALResult Get( std::shared_ptr& object, const CreateArgument& argument, Tr2PrimaryRenderContextAL& renderContext ) { - public: - ALResult Get( std::shared_ptr& object, const CreateArgument& argument, Tr2PrimaryRenderContextAL &renderContext ) + auto found = m_objects.find( argument ); + if( found != m_objects.end() ) { - auto found = m_objects.find( argument ); - if( found != m_objects.end() ) + if( !found->second->IsValid() ) + { + m_objects.erase( found ); + } + else { - if( !found->second->IsValid() ) - { - m_objects.erase( found ); - } - else - { - object = found->second; - return S_OK; - } + object = found->second; + return S_OK; } - auto newObject = std::make_shared(); - CR_RETURN_HR( newObject->Create( argument, renderContext ) ); - m_objects[argument] = newObject; - object = newObject; - return S_OK; } + auto newObject = std::make_shared(); + CR_RETURN_HR( newObject->Create( argument, renderContext ) ); + m_objects[argument] = newObject; + object = newObject; + return S_OK; + } - void Clear() - { - m_objects.clear(); - } - private: - std::unordered_map> m_objects; - }; + void Clear() + { + m_objects.clear(); + } + +private: + std::unordered_map> m_objects; +}; } \ No newline at end of file diff --git a/trinityal/Tr2RenderContextEnum.cpp b/trinityal/Tr2RenderContextEnum.cpp index da0492ef6..8e756c70e 100644 --- a/trinityal/Tr2RenderContextEnum.cpp +++ b/trinityal/Tr2RenderContextEnum.cpp @@ -15,15 +15,24 @@ Tr2RenderContextEnum::PixelFormat Tr2RenderContextEnum::ConvertD3DBackBufferForm { switch( fmt ) { - case 116 /*D3DFMT_A32B32G32R32F*/: return PIXEL_FORMAT_R32G32B32A32_FLOAT; - case 113 /*D3DFMT_A16B16G16R16F*/: return PIXEL_FORMAT_R16G16B16A16_FLOAT; - case 36 /*D3DFMT_A16B16G16R16 */: return PIXEL_FORMAT_R16G16B16A16_UNORM; - case 35 /*D3DFMT_A2R10G10B10 */: return PIXEL_FORMAT_R10G10B10A2_UNORM; - case 32 /*D3DFMT_A8B8G8R8 */: return PIXEL_FORMAT_R8G8B8A8_UNORM; - case 23 /*D3DFMT_R5G6B5 */: return PIXEL_FORMAT_B5G6R5_UNORM; - case 25 /*D3DFMT_A1R5G5B5 */: return PIXEL_FORMAT_B5G5R5A1_UNORM; - case 21 /*D3DFMT_A8R8G8B8 */: return PIXEL_FORMAT_B8G8R8A8_UNORM; - case 22 /*D3DFMT_X8R8G8B8 */: return PIXEL_FORMAT_B8G8R8X8_UNORM; + case 116 /*D3DFMT_A32B32G32R32F*/: + return PIXEL_FORMAT_R32G32B32A32_FLOAT; + case 113 /*D3DFMT_A16B16G16R16F*/: + return PIXEL_FORMAT_R16G16B16A16_FLOAT; + case 36 /*D3DFMT_A16B16G16R16 */: + return PIXEL_FORMAT_R16G16B16A16_UNORM; + case 35 /*D3DFMT_A2R10G10B10 */: + return PIXEL_FORMAT_R10G10B10A2_UNORM; + case 32 /*D3DFMT_A8B8G8R8 */: + return PIXEL_FORMAT_R8G8B8A8_UNORM; + case 23 /*D3DFMT_R5G6B5 */: + return PIXEL_FORMAT_B5G6R5_UNORM; + case 25 /*D3DFMT_A1R5G5B5 */: + return PIXEL_FORMAT_B5G5R5A1_UNORM; + case 21 /*D3DFMT_A8R8G8B8 */: + return PIXEL_FORMAT_B8G8R8A8_UNORM; + case 22 /*D3DFMT_X8R8G8B8 */: + return PIXEL_FORMAT_B8G8R8X8_UNORM; } return PIXEL_FORMAT_UNKNOWN; } @@ -157,7 +166,6 @@ Tr2RenderContextEnum::PixelFormat Tr2RenderContextEnum::MakeSrgb( Tr2RenderConte default: return format; } - } Tr2RenderContextEnum::PixelFormat Tr2RenderContextEnum::ConvertDepthStencilFormat( DepthStencilFormat format ) diff --git a/trinityal/Tr2RenderContextEnum.h b/trinityal/Tr2RenderContextEnum.h index 9f713fbb0..d9591e457 100644 --- a/trinityal/Tr2RenderContextEnum.h +++ b/trinityal/Tr2RenderContextEnum.h @@ -6,429 +6,430 @@ namespace Tr2RenderContextEnum { - using namespace ImageIO; - - enum ObjectType - { - OT_CONSTANT_BUFFER, - OT_RENDER_CONTEXT, - OT_SHADER, - OT_SAMPLER_STATE, - OT_TEXTURE, - OT_VERTEX_LAYOUT, - OT_OCCLUSION_QUERY, - OT_SWAP_CHAIN, - OT_FENCE, - OT_TIMER, - - OT_SHADER_PROGRAM, - OT_RESOURCE_SET, - OT_BUFFER, - - OBJECT_TYPE_COUNT - }; - - enum ShaderType - { - VERTEX_SHADER, - PIXEL_SHADER, - COMPUTE_SHADER, - GEOMETRY_SHADER, - HULL_SHADER, - DOMAIN_SHADER, - - INVALID_SHADER, - SHADER_TYPE_FIRST = VERTEX_SHADER, - SHADER_TYPE_COUNT = INVALID_SHADER, - }; - - // Special case constant buffers added to handle trinity - enum - { - CBUFFER_GUI = SHADER_TYPE_COUNT, - CBUFFER_COUNT // total number of cbuffers passed to SetPerObjectToDevice - }; - - // Clearing bound renderTarget and/or depth stencil - enum ClearFlags - { - CLEARFLAGS_TARGET = 1, - CLEARFLAGS_ZBUFFER = 2, - CLEARFLAGS_STENCIL = 4, - }; - - enum CullMode - { - CULLMODE_NONE = 1, - CULLMODE_CW = 2, - CULLMODE_CCW = 3, - }; - - enum ColorWriteEnable - { - COLORWRITEENABLE_RED = 1 << 0, - COLORWRITEENABLE_GREEN = 1 << 1, - COLORWRITEENABLE_BLUE = 1 << 2, - COLORWRITEENABLE_ALPHA = 1 << 3, - }; - - - // Formats for depth/stencil bufers - enum DepthStencilFormat - { - DSFMT_UNKNOWN, // invalid, zero, make sure any valid enum is > 0 - - DSFMT_D24S8, - DSFMT_D24X8, - DSFMT_D24FS8, - DSFMT_D32F, - DSFMT_D32, - DSFMT_READABLE, - - DSFMT_AUTO, // "don't care, use what's most likely to work" - - // These are just here for completeness, probably not a great idea to try and use them. - DSFMT_D16_LOCKABLE, - DSFMT_D15S1, - DSFMT_D24X4S4, - DSFMT_D16, - DSFMT_D32F_LOCKABLE - }; - - // Locking buffers - enum LockType - { - LOCK_READONLY, - LOCK_WRITEONLY, - LOCK_NO_OVERWRITE, - LOCK_INVALID - }; - - // Vertex/index buffer usage flags - enum BufferUsageFlags - { - // Resource is inteded to be locked for reading - USAGE_CPU_READ = 1 << 0, - // Resource is inteded to be locked for writing - USAGE_CPU_WRITE = 1 << 1, - // Resource is inteded to be locked more than once per frame - USAGE_LOCK_FREQUENTLY = 1 << 2, - // Resource is immutable (no CPU or GPU modifications) - USAGE_IMMUTABLE = 1 << 3, - // DX9-specific: put resource into managed pool - USAGE_HINT_MANAGED = 1 << 4, - // Access resource as a unordered access view in shaders - USAGE_UNORDERED_ACCESS = 1 << 5, - // Access resource to be accessed shaders (as shader resources); applies to buffers - USAGE_SHADER_RESOURCE = 1 << 6, - }; - - // Combination of BufferUsageFlags - typedef int BufferUsage; - - bool ValidateUsage( BufferUsage ); - - // Topology - enum Topology - { - TOP_INVALID, - - TOP_TRIANGLES, - TOP_TRIANGLE_STRIP, - TOP_TRIANGLE_FAN, // invalid on DX11! - TOP_LINES, - TOP_LINE_STRIP, - TOP_POINTS, - - TOP_MAX_TOPOLOGY - }; - - // Comparison functions - enum CompareFunc - { - CMP_NEVER = 1, - CMP_LESS = 2, - CMP_EQUAL = 3, - CMP_LESSEQUAL = 4, - CMP_GREATER = 5, - CMP_NOTEQUAL = 6, - CMP_GREATEREQUAL = 7, - CMP_ALWAYS = 8, - - CMP_FORCE_DWORD = 0xffffffff - }; - - enum FillMode - { - FM_POINT = 1, - FM_WIREFRAME = 2, - FM_SOLID = 3, - FM_FORCE_DWORD = 0xffffffff - }; - - enum BlendMode - { - BM_ZERO = 1, - BM_ONE = 2, - BM_SRCCOLOR = 3, - BM_INVSRCCOLOR = 4, - BM_SRCALPHA = 5, - BM_INVSRCALPHA = 6, - BM_DESTALPHA = 7, - BM_INVDESTALPHA = 8, - BM_DESTCOLOR = 9, - BM_INVDESTCOLOR = 10, - BM_SRCALPHASAT = 11, - BM_BOTHSRCALPHA = 12, - BM_BOTHINVSRCALPHA = 13, - BM_BLENDFACTOR = 14, - BM_INVBLENDFACTOR = 15, - BM_FORCE_DWORD = 0xffffffff - }; - - enum BlendOperation - { - BO_DISABLE = 0, - BO_ADD = 1, - BO_SUBTRACT = 2, - BO_REVSUBTRACT = 3, - BO_MIN = 4, - BO_MAX = 5, - BO_FORCE_DWORD = 0xffffffff - }; - - // Magical flags for CreateEx and friends - enum ExFlag - { - EX_NONE = 0, - EX_CREATE_SHARED = 1 << 0, - EX_BIND_UNORDERED_ACCESS = 1 << 1, - EX_DRAW_INDIRECT = 1 << 3, - }; - - inline ExFlag operator|( ExFlag a, ExFlag b ) - { - return ExFlag( int( a ) | int( b ) ); - } - - - // Texture color space - enum ColorSpace - { - COLOR_SPACE_LINEAR, - COLOR_SPACE_SRGB, - _COLOR_SPACE_COUNT, - }; - - enum StencilOperation { - STENCILOP_KEEP = 1, - STENCILOP_ZERO = 2, - STENCILOP_REPLACE = 3, - STENCILOP_INCRSAT = 4, - STENCILOP_DECRSAT = 5, - STENCILOP_INVERT = 6, - STENCILOP_INCR = 7, - STENCILOP_DECR = 8, - }; - - // Rasterization states for backward compatibility - enum RenderState - { - RS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ - RS_FILLMODE = 8, /* D3DFILLMODE */ - RS_SHADEMODE = 9, /* D3DSHADEMODE */ - RS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ - RS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ - RS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ - RS_SRCBLEND = 19, /* D3DBLEND */ - RS_DESTBLEND = 20, /* D3DBLEND */ - RS_CULLMODE = 22, /* D3DCULL */ - RS_ZFUNC = 23, /* D3DCMPFUNC */ - RS_ALPHAREF = 24, /* D3DFIXED */ - RS_ALPHAFUNC = 25, /* D3DCMPFUNC */ - RS_DITHERENABLE = 26, /* TRUE to enable dithering */ - RS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ - RS_FOGENABLE = 28, /* TRUE to enable fog blending */ - RS_SPECULARENABLE = 29, /* TRUE to enable specular */ - RS_FOGCOLOR = 34, /* D3DCOLOR */ - RS_FOGTABLEMODE = 35, /* D3DFOGMODE */ - RS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ - RS_FOGEND = 37, /* Fog end */ - RS_FOGDENSITY = 38, /* Fog density */ - RS_RANGEFOGENABLE = 48, /* Enables range-based fog */ - RS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ - RS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ - RS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ - RS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ - RS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - RS_STENCILREF = 57, /* Reference value used in stencil test */ - RS_STENCILMASK = 58, /* Mask value used in stencil test */ - RS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ - RS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ - RS_DEPTH_CLIP_ENABLE = 61, /* Corresponds to D3D12_RASTERIZER_DESC.DepthClipEnable */ - RS_WRAP0 = 128, /* wrap for 1st texture coord. set */ - RS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ - RS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ - RS_WRAP3 = 131, /* wrap for 4th texture coord. set */ - RS_WRAP4 = 132, /* wrap for 5th texture coord. set */ - RS_WRAP5 = 133, /* wrap for 6th texture coord. set */ - RS_WRAP6 = 134, /* wrap for 7th texture coord. set */ - RS_WRAP7 = 135, /* wrap for 8th texture coord. set */ - RS_CLIPPING = 136, - RS_LIGHTING = 137, - RS_AMBIENT = 139, - RS_FOGVERTEXMODE = 140, - RS_COLORVERTEX = 141, - RS_LOCALVIEWER = 142, - RS_NORMALIZENORMALS = 143, - RS_DIFFUSEMATERIALSOURCE = 145, - RS_SPECULARMATERIALSOURCE = 146, - RS_AMBIENTMATERIALSOURCE = 147, - RS_EMISSIVEMATERIALSOURCE = 148, - RS_VERTEXBLEND = 151, - RS_CLIPPLANEENABLE = 152, - RS_POINTSIZE = 154, /* float point size */ - RS_POINTSIZE_MIN = 155, /* float point size min threshold */ - RS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ - RS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ - RS_POINTSCALE_A = 158, /* float point attenuation A value */ - RS_POINTSCALE_B = 159, /* float point attenuation B value */ - RS_POINTSCALE_C = 160, /* float point attenuation C value */ - RS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer - RS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable - RS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation - RS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor - RS_POINTSIZE_MAX = 166, /* float point size max threshold */ - RS_INDEXEDVERTEXBLENDENABLE = 167, - RS_COLORWRITEENABLE = 168, // per-channel write enable - RS_TWEENFACTOR = 170, // float tween factor - RS_BLENDOP = 171, // D3DBLENDOP setting - RS_POSITIONDEGREE = 172, // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) - RS_NORMALDEGREE = 173, // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC - RS_SLOPESCALEDEPTHBIAS = 175, - RS_ANTIALIASEDLINEENABLE = 176, - RS_MINTESSELLATIONLEVEL = 178, - RS_MAXTESSELLATIONLEVEL = 179, - RS_ADAPTIVETESS_X = 180, - RS_ADAPTIVETESS_Y = 181, - RS_ADAPTIVETESS_Z = 182, - RS_ADAPTIVETESS_W = 183, - RS_ENABLEADAPTIVETESSELLATION = 184, - RS_TWOSIDEDSTENCILMODE = 185, /* BOOL enable/disable 2 sided stenciling */ - RS_CCW_STENCILFAIL = 186, /* D3DSTENCILOP to do if ccw stencil test fails */ - RS_CCW_STENCILZFAIL = 187, /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */ - RS_CCW_STENCILPASS = 188, /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */ - RS_CCW_STENCILFUNC = 189, /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ - RS_COLORWRITEENABLE1 = 190, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - RS_COLORWRITEENABLE2 = 191, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - RS_COLORWRITEENABLE3 = 192, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ - RS_BLENDFACTOR = 193, /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */ - RS_SRGBWRITEENABLE = 194, /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */ - RS_DEPTHBIAS = 195, - RS_WRAP8 = 198, /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */ - RS_WRAP9 = 199, - RS_WRAP10 = 200, - RS_WRAP11 = 201, - RS_WRAP12 = 202, - RS_WRAP13 = 203, - RS_WRAP14 = 204, - RS_WRAP15 = 205, - RS_SEPARATEALPHABLENDENABLE = 206, /* TRUE to enable a separate blending function for the alpha channel */ - RS_SRCBLENDALPHA = 207, /* SRC blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ - RS_DESTBLENDALPHA = 208, /* DST blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ - RS_BLENDOPALPHA = 209, /* Blending operation for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ - - // from DX8? - RS_ZBIAS = 47, - - - RS_MAX_STATE = 210, - - RS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ - }; - - enum TextureFilter - { - TF_NONE = 0, - TF_POINT = 1, - TF_LINEAR = 2, - TF_ANISOTROPIC = 3, - TF_COMPARISON = 0x80, - }; - - enum TextureAddressMode - { - TA_WRAP = 1, - TA_MIRROR = 2, - TA_CLAMP = 3, - TA_BORDER = 4, - TA_MIRROR_ONCE = 5, - }; - - - enum ScanlineOrdering - { - SCANLINE_ORDER_UNSPECIFIED = 0, - SCANLINE_ORDER_PROGRESSIVE = 1, - SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, - SCANLINE_ORDER_LOWER_FIELD_FIRST = 3 - }; - - enum DisplayScaling - { - DISPLAY_SCALING_UNSPECIFIED = 0, - DISPLAY_SCALING_CENTERED = 1, - DISPLAY_SCALING_STRETCHED = 2 - }; - - enum SwapEffect - { - SWAP_EFFECT_DISCARD = 0, - SWAP_EFFECT_SEQUENTIAL = 1, - }; - - enum PresentInterval - { - PRESENT_INTERVAL_IMMEDIATE = 0, - PRESENT_INTERVAL_ONE = 1, - }; - - - PixelFormat ConvertD3DBackBufferFormat( /*D3DFORMAT*/ unsigned fmt ); - - PixelFormat MakeTypeless( PixelFormat fmt ); - PixelFormat MakeSrgb( PixelFormat format ); - - PixelFormat ConvertDepthStencilFormat( DepthStencilFormat format ); - - - static const int CONSTANT_BUFFER_FOR_EFFECT_PARAMETERS = 0; - static const int CONSTANT_BUFFER_FOR_FRAGMENT_PARAMETERS = 7; - static const int CONSTANT_BUFFER_FOR_FRAGMENT_OP_EMULATION = 10; - - static const int VERTEX_BUFFER_ZERO_STREAM_RESERVED = 4; +using namespace ImageIO; + +enum ObjectType +{ + OT_CONSTANT_BUFFER, + OT_RENDER_CONTEXT, + OT_SHADER, + OT_SAMPLER_STATE, + OT_TEXTURE, + OT_VERTEX_LAYOUT, + OT_OCCLUSION_QUERY, + OT_SWAP_CHAIN, + OT_FENCE, + OT_TIMER, + + OT_SHADER_PROGRAM, + OT_RESOURCE_SET, + OT_BUFFER, + + OBJECT_TYPE_COUNT +}; + +enum ShaderType +{ + VERTEX_SHADER, + PIXEL_SHADER, + COMPUTE_SHADER, + GEOMETRY_SHADER, + HULL_SHADER, + DOMAIN_SHADER, + + INVALID_SHADER, + SHADER_TYPE_FIRST = VERTEX_SHADER, + SHADER_TYPE_COUNT = INVALID_SHADER, +}; + +// Special case constant buffers added to handle trinity +enum +{ + CBUFFER_GUI = SHADER_TYPE_COUNT, + CBUFFER_COUNT // total number of cbuffers passed to SetPerObjectToDevice +}; + +// Clearing bound renderTarget and/or depth stencil +enum ClearFlags +{ + CLEARFLAGS_TARGET = 1, + CLEARFLAGS_ZBUFFER = 2, + CLEARFLAGS_STENCIL = 4, +}; + +enum CullMode +{ + CULLMODE_NONE = 1, + CULLMODE_CW = 2, + CULLMODE_CCW = 3, +}; + +enum ColorWriteEnable +{ + COLORWRITEENABLE_RED = 1 << 0, + COLORWRITEENABLE_GREEN = 1 << 1, + COLORWRITEENABLE_BLUE = 1 << 2, + COLORWRITEENABLE_ALPHA = 1 << 3, +}; + + +// Formats for depth/stencil bufers +enum DepthStencilFormat +{ + DSFMT_UNKNOWN, // invalid, zero, make sure any valid enum is > 0 + + DSFMT_D24S8, + DSFMT_D24X8, + DSFMT_D24FS8, + DSFMT_D32F, + DSFMT_D32, + DSFMT_READABLE, + + DSFMT_AUTO, // "don't care, use what's most likely to work" + + // These are just here for completeness, probably not a great idea to try and use them. + DSFMT_D16_LOCKABLE, + DSFMT_D15S1, + DSFMT_D24X4S4, + DSFMT_D16, + DSFMT_D32F_LOCKABLE +}; + +// Locking buffers +enum LockType +{ + LOCK_READONLY, + LOCK_WRITEONLY, + LOCK_NO_OVERWRITE, + LOCK_INVALID +}; + +// Vertex/index buffer usage flags +enum BufferUsageFlags +{ + // Resource is inteded to be locked for reading + USAGE_CPU_READ = 1 << 0, + // Resource is inteded to be locked for writing + USAGE_CPU_WRITE = 1 << 1, + // Resource is inteded to be locked more than once per frame + USAGE_LOCK_FREQUENTLY = 1 << 2, + // Resource is immutable (no CPU or GPU modifications) + USAGE_IMMUTABLE = 1 << 3, + // DX9-specific: put resource into managed pool + USAGE_HINT_MANAGED = 1 << 4, + // Access resource as a unordered access view in shaders + USAGE_UNORDERED_ACCESS = 1 << 5, + // Access resource to be accessed shaders (as shader resources); applies to buffers + USAGE_SHADER_RESOURCE = 1 << 6, +}; + +// Combination of BufferUsageFlags +typedef int BufferUsage; + +bool ValidateUsage( BufferUsage ); + +// Topology +enum Topology +{ + TOP_INVALID, + + TOP_TRIANGLES, + TOP_TRIANGLE_STRIP, + TOP_TRIANGLE_FAN, // invalid on DX11! + TOP_LINES, + TOP_LINE_STRIP, + TOP_POINTS, + + TOP_MAX_TOPOLOGY +}; + +// Comparison functions +enum CompareFunc +{ + CMP_NEVER = 1, + CMP_LESS = 2, + CMP_EQUAL = 3, + CMP_LESSEQUAL = 4, + CMP_GREATER = 5, + CMP_NOTEQUAL = 6, + CMP_GREATEREQUAL = 7, + CMP_ALWAYS = 8, + + CMP_FORCE_DWORD = 0xffffffff +}; + +enum FillMode +{ + FM_POINT = 1, + FM_WIREFRAME = 2, + FM_SOLID = 3, + FM_FORCE_DWORD = 0xffffffff +}; + +enum BlendMode +{ + BM_ZERO = 1, + BM_ONE = 2, + BM_SRCCOLOR = 3, + BM_INVSRCCOLOR = 4, + BM_SRCALPHA = 5, + BM_INVSRCALPHA = 6, + BM_DESTALPHA = 7, + BM_INVDESTALPHA = 8, + BM_DESTCOLOR = 9, + BM_INVDESTCOLOR = 10, + BM_SRCALPHASAT = 11, + BM_BOTHSRCALPHA = 12, + BM_BOTHINVSRCALPHA = 13, + BM_BLENDFACTOR = 14, + BM_INVBLENDFACTOR = 15, + BM_FORCE_DWORD = 0xffffffff +}; + +enum BlendOperation +{ + BO_DISABLE = 0, + BO_ADD = 1, + BO_SUBTRACT = 2, + BO_REVSUBTRACT = 3, + BO_MIN = 4, + BO_MAX = 5, + BO_FORCE_DWORD = 0xffffffff +}; + +// Magical flags for CreateEx and friends +enum ExFlag +{ + EX_NONE = 0, + EX_CREATE_SHARED = 1 << 0, + EX_BIND_UNORDERED_ACCESS = 1 << 1, + EX_DRAW_INDIRECT = 1 << 3, +}; + +inline ExFlag operator|( ExFlag a, ExFlag b ) +{ + return ExFlag( int( a ) | int( b ) ); +} + + +// Texture color space +enum ColorSpace +{ + COLOR_SPACE_LINEAR, + COLOR_SPACE_SRGB, + _COLOR_SPACE_COUNT, +}; + +enum StencilOperation +{ + STENCILOP_KEEP = 1, + STENCILOP_ZERO = 2, + STENCILOP_REPLACE = 3, + STENCILOP_INCRSAT = 4, + STENCILOP_DECRSAT = 5, + STENCILOP_INVERT = 6, + STENCILOP_INCR = 7, + STENCILOP_DECR = 8, +}; + +// Rasterization states for backward compatibility +enum RenderState +{ + RS_ZENABLE = 7, /* D3DZBUFFERTYPE (or TRUE/FALSE for legacy) */ + RS_FILLMODE = 8, /* D3DFILLMODE */ + RS_SHADEMODE = 9, /* D3DSHADEMODE */ + RS_ZWRITEENABLE = 14, /* TRUE to enable z writes */ + RS_ALPHATESTENABLE = 15, /* TRUE to enable alpha tests */ + RS_LASTPIXEL = 16, /* TRUE for last-pixel on lines */ + RS_SRCBLEND = 19, /* D3DBLEND */ + RS_DESTBLEND = 20, /* D3DBLEND */ + RS_CULLMODE = 22, /* D3DCULL */ + RS_ZFUNC = 23, /* D3DCMPFUNC */ + RS_ALPHAREF = 24, /* D3DFIXED */ + RS_ALPHAFUNC = 25, /* D3DCMPFUNC */ + RS_DITHERENABLE = 26, /* TRUE to enable dithering */ + RS_ALPHABLENDENABLE = 27, /* TRUE to enable alpha blending */ + RS_FOGENABLE = 28, /* TRUE to enable fog blending */ + RS_SPECULARENABLE = 29, /* TRUE to enable specular */ + RS_FOGCOLOR = 34, /* D3DCOLOR */ + RS_FOGTABLEMODE = 35, /* D3DFOGMODE */ + RS_FOGSTART = 36, /* Fog start (for both vertex and pixel fog) */ + RS_FOGEND = 37, /* Fog end */ + RS_FOGDENSITY = 38, /* Fog density */ + RS_RANGEFOGENABLE = 48, /* Enables range-based fog */ + RS_STENCILENABLE = 52, /* BOOL enable/disable stenciling */ + RS_STENCILFAIL = 53, /* D3DSTENCILOP to do if stencil test fails */ + RS_STENCILZFAIL = 54, /* D3DSTENCILOP to do if stencil test passes and Z test fails */ + RS_STENCILPASS = 55, /* D3DSTENCILOP to do if both stencil and Z tests pass */ + RS_STENCILFUNC = 56, /* D3DCMPFUNC fn. Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + RS_STENCILREF = 57, /* Reference value used in stencil test */ + RS_STENCILMASK = 58, /* Mask value used in stencil test */ + RS_STENCILWRITEMASK = 59, /* Write mask applied to values written to stencil buffer */ + RS_TEXTUREFACTOR = 60, /* D3DCOLOR used for multi-texture blend */ + RS_DEPTH_CLIP_ENABLE = 61, /* Corresponds to D3D12_RASTERIZER_DESC.DepthClipEnable */ + RS_WRAP0 = 128, /* wrap for 1st texture coord. set */ + RS_WRAP1 = 129, /* wrap for 2nd texture coord. set */ + RS_WRAP2 = 130, /* wrap for 3rd texture coord. set */ + RS_WRAP3 = 131, /* wrap for 4th texture coord. set */ + RS_WRAP4 = 132, /* wrap for 5th texture coord. set */ + RS_WRAP5 = 133, /* wrap for 6th texture coord. set */ + RS_WRAP6 = 134, /* wrap for 7th texture coord. set */ + RS_WRAP7 = 135, /* wrap for 8th texture coord. set */ + RS_CLIPPING = 136, + RS_LIGHTING = 137, + RS_AMBIENT = 139, + RS_FOGVERTEXMODE = 140, + RS_COLORVERTEX = 141, + RS_LOCALVIEWER = 142, + RS_NORMALIZENORMALS = 143, + RS_DIFFUSEMATERIALSOURCE = 145, + RS_SPECULARMATERIALSOURCE = 146, + RS_AMBIENTMATERIALSOURCE = 147, + RS_EMISSIVEMATERIALSOURCE = 148, + RS_VERTEXBLEND = 151, + RS_CLIPPLANEENABLE = 152, + RS_POINTSIZE = 154, /* float point size */ + RS_POINTSIZE_MIN = 155, /* float point size min threshold */ + RS_POINTSPRITEENABLE = 156, /* BOOL point texture coord control */ + RS_POINTSCALEENABLE = 157, /* BOOL point size scale enable */ + RS_POINTSCALE_A = 158, /* float point attenuation A value */ + RS_POINTSCALE_B = 159, /* float point attenuation B value */ + RS_POINTSCALE_C = 160, /* float point attenuation C value */ + RS_MULTISAMPLEANTIALIAS = 161, // BOOL - set to do FSAA with multisample buffer + RS_MULTISAMPLEMASK = 162, // DWORD - per-sample enable/disable + RS_PATCHEDGESTYLE = 163, // Sets whether patch edges will use float style tessellation + RS_DEBUGMONITORTOKEN = 165, // DEBUG ONLY - token to debug monitor + RS_POINTSIZE_MAX = 166, /* float point size max threshold */ + RS_INDEXEDVERTEXBLENDENABLE = 167, + RS_COLORWRITEENABLE = 168, // per-channel write enable + RS_TWEENFACTOR = 170, // float tween factor + RS_BLENDOP = 171, // D3DBLENDOP setting + RS_POSITIONDEGREE = 172, // NPatch position interpolation degree. D3DDEGREE_LINEAR or D3DDEGREE_CUBIC (default) + RS_NORMALDEGREE = 173, // NPatch normal interpolation degree. D3DDEGREE_LINEAR (default) or D3DDEGREE_QUADRATIC + RS_SLOPESCALEDEPTHBIAS = 175, + RS_ANTIALIASEDLINEENABLE = 176, + RS_MINTESSELLATIONLEVEL = 178, + RS_MAXTESSELLATIONLEVEL = 179, + RS_ADAPTIVETESS_X = 180, + RS_ADAPTIVETESS_Y = 181, + RS_ADAPTIVETESS_Z = 182, + RS_ADAPTIVETESS_W = 183, + RS_ENABLEADAPTIVETESSELLATION = 184, + RS_TWOSIDEDSTENCILMODE = 185, /* BOOL enable/disable 2 sided stenciling */ + RS_CCW_STENCILFAIL = 186, /* D3DSTENCILOP to do if ccw stencil test fails */ + RS_CCW_STENCILZFAIL = 187, /* D3DSTENCILOP to do if ccw stencil test passes and Z test fails */ + RS_CCW_STENCILPASS = 188, /* D3DSTENCILOP to do if both ccw stencil and Z tests pass */ + RS_CCW_STENCILFUNC = 189, /* D3DCMPFUNC fn. ccw Stencil Test passes if ((ref & mask) stencilfn (stencil & mask)) is true */ + RS_COLORWRITEENABLE1 = 190, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + RS_COLORWRITEENABLE2 = 191, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + RS_COLORWRITEENABLE3 = 192, /* Additional ColorWriteEnables for the devices that support D3DPMISCCAPS_INDEPENDENTWRITEMASKS */ + RS_BLENDFACTOR = 193, /* D3DCOLOR used for a constant blend factor during alpha blending for devices that support D3DPBLENDCAPS_BLENDFACTOR */ + RS_SRGBWRITEENABLE = 194, /* Enable rendertarget writes to be DE-linearized to SRGB (for formats that expose D3DUSAGE_QUERY_SRGBWRITE) */ + RS_DEPTHBIAS = 195, + RS_WRAP8 = 198, /* Additional wrap states for vs_3_0+ attributes with D3DDECLUSAGE_TEXCOORD */ + RS_WRAP9 = 199, + RS_WRAP10 = 200, + RS_WRAP11 = 201, + RS_WRAP12 = 202, + RS_WRAP13 = 203, + RS_WRAP14 = 204, + RS_WRAP15 = 205, + RS_SEPARATEALPHABLENDENABLE = 206, /* TRUE to enable a separate blending function for the alpha channel */ + RS_SRCBLENDALPHA = 207, /* SRC blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ + RS_DESTBLENDALPHA = 208, /* DST blend factor for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ + RS_BLENDOPALPHA = 209, /* Blending operation for the alpha channel when RS_SEPARATEDESTALPHAENABLE is TRUE */ + + // from DX8? + RS_ZBIAS = 47, + + + RS_MAX_STATE = 210, + + RS_FORCE_DWORD = 0x7fffffff, /* force 32-bit size enum */ +}; + +enum TextureFilter +{ + TF_NONE = 0, + TF_POINT = 1, + TF_LINEAR = 2, + TF_ANISOTROPIC = 3, + TF_COMPARISON = 0x80, +}; + +enum TextureAddressMode +{ + TA_WRAP = 1, + TA_MIRROR = 2, + TA_CLAMP = 3, + TA_BORDER = 4, + TA_MIRROR_ONCE = 5, +}; + + +enum ScanlineOrdering +{ + SCANLINE_ORDER_UNSPECIFIED = 0, + SCANLINE_ORDER_PROGRESSIVE = 1, + SCANLINE_ORDER_UPPER_FIELD_FIRST = 2, + SCANLINE_ORDER_LOWER_FIELD_FIRST = 3 +}; + +enum DisplayScaling +{ + DISPLAY_SCALING_UNSPECIFIED = 0, + DISPLAY_SCALING_CENTERED = 1, + DISPLAY_SCALING_STRETCHED = 2 +}; + +enum SwapEffect +{ + SWAP_EFFECT_DISCARD = 0, + SWAP_EFFECT_SEQUENTIAL = 1, +}; + +enum PresentInterval +{ + PRESENT_INTERVAL_IMMEDIATE = 0, + PRESENT_INTERVAL_ONE = 1, +}; + + +PixelFormat ConvertD3DBackBufferFormat( /*D3DFORMAT*/ unsigned fmt ); + +PixelFormat MakeTypeless( PixelFormat fmt ); +PixelFormat MakeSrgb( PixelFormat format ); + +PixelFormat ConvertDepthStencilFormat( DepthStencilFormat format ); + + +static const int CONSTANT_BUFFER_FOR_EFFECT_PARAMETERS = 0; +static const int CONSTANT_BUFFER_FOR_FRAGMENT_PARAMETERS = 7; +static const int CONSTANT_BUFFER_FOR_FRAGMENT_OP_EMULATION = 10; + +static const int VERTEX_BUFFER_ZERO_STREAM_RESERVED = 4; // Check if shader type (Tr2RenderContextEnum::ShaderType) exists on the current platform #define SHADER_TYPE_EXISTS( shaderType ) ( Tr2RenderContextAL::SHADER_TYPE_MASK & ( 1 << ( shaderType ) ) ) - enum RenderContextStatus - { - CONTEXT_STATUS_NOT_STARTED = 0, - CONTEXT_STATUS_EXECUTING, - CONTEXT_STATUS_FINISHED, - - CONTEXT_STATUS_INVALID, - }; - - enum FrameEvent - { - FRAME_EVENT_UPDATE_STARTED, - FRAME_EVENT_UPDATE_FINISHED, - FRAME_EVENT_PRESENT_STARTED, - FRAME_EVENT_PRESENT_FINISHED, - FRAME_EVENT_RENDERING_STARTED, - FRAME_EVENT_RENDERING_FINISHED - }; +enum RenderContextStatus +{ + CONTEXT_STATUS_NOT_STARTED = 0, + CONTEXT_STATUS_EXECUTING, + CONTEXT_STATUS_FINISHED, + + CONTEXT_STATUS_INVALID, +}; + +enum FrameEvent +{ + FRAME_EVENT_UPDATE_STARTED, + FRAME_EVENT_UPDATE_FINISHED, + FRAME_EVENT_PRESENT_STARTED, + FRAME_EVENT_PRESENT_FINISHED, + FRAME_EVENT_RENDERING_STARTED, + FRAME_EVENT_RENDERING_FINISHED +}; } using Tr2BitmapDimensions = ImageIO::BitmapDimensions; @@ -436,95 +437,95 @@ using Tr2BitmapDimensions = ImageIO::BitmapDimensions; namespace Tr2CpuUsage { - enum Type - { - NONE = 0, - READ = 1 << 0, - WRITE = 1 << 1, - READ_OFTEN = READ | ( 1 << 2 ), - WRITE_OFTEN = WRITE | ( 1 << 3 ), - NON_SYNCRONIZED_WRITE = 1 << 4, - }; - - inline Type operator|( Type a, Type b ) - { - return Type( int( a ) | int( b ) ); - } - - inline bool HasFlag( Type value, Type flag ) - { - return ( value & flag ) == flag; - } +enum Type +{ + NONE = 0, + READ = 1 << 0, + WRITE = 1 << 1, + READ_OFTEN = READ | ( 1 << 2 ), + WRITE_OFTEN = WRITE | ( 1 << 3 ), + NON_SYNCRONIZED_WRITE = 1 << 4, +}; + +inline Type operator|( Type a, Type b ) +{ + return Type( int( a ) | int( b ) ); +} + +inline bool HasFlag( Type value, Type flag ) +{ + return ( value & flag ) == flag; +} } namespace Tr2GpuUsage { - enum Type - { - NONE = 0, - VERTEX_BUFFER = 1 << 0, - INDEX_BUFFER = 1 << 1, +enum Type +{ + NONE = 0, + VERTEX_BUFFER = 1 << 0, + INDEX_BUFFER = 1 << 1, - RENDER_TARGET = 1 << 2, - DEPTH_STENCIL = 1 << 3, + RENDER_TARGET = 1 << 2, + DEPTH_STENCIL = 1 << 3, - SHADER_RESOURCE = 1 << 4, - UNORDERED_ACCESS = 1 << 5, - COPY_DESTINATION = 1 << 6, + SHADER_RESOURCE = 1 << 4, + UNORDERED_ACCESS = 1 << 5, + COPY_DESTINATION = 1 << 6, - DRAW_INDIRECT_ARGS = 1 << 7, + DRAW_INDIRECT_ARGS = 1 << 7, - ACCELERATION_STRUCTURE = 1 << 8, + ACCELERATION_STRUCTURE = 1 << 8, - SHARED = 1 << 9, - }; + SHARED = 1 << 9, +}; - inline Type operator|( Type a, Type b ) - { - return Type( int( a ) | int( b ) ); - } +inline Type operator|( Type a, Type b ) +{ + return Type( int( a ) | int( b ) ); +} - inline Type& operator|=( Type& a, Type b ) - { - a = Type( a | b ); - return a; - } +inline Type& operator|=( Type& a, Type b ) +{ + a = Type( a | b ); + return a; +} - inline bool HasFlag( Type value, Type flag ) - { - return ( value & flag ) == flag; - } +inline bool HasFlag( Type value, Type flag ) +{ + return ( value & flag ) == flag; +} - inline bool IsWritable( Type value ) - { - return ( value & ( RENDER_TARGET | DEPTH_STENCIL | UNORDERED_ACCESS | COPY_DESTINATION ) ) != 0; - } +inline bool IsWritable( Type value ) +{ + return ( value & ( RENDER_TARGET | DEPTH_STENCIL | UNORDERED_ACCESS | COPY_DESTINATION ) ) != 0; +} - inline bool HasBufferFlags( Type value ) - { - return ( value & ( VERTEX_BUFFER | INDEX_BUFFER | DRAW_INDIRECT_ARGS ) ) != 0; - } +inline bool HasBufferFlags( Type value ) +{ + return ( value & ( VERTEX_BUFFER | INDEX_BUFFER | DRAW_INDIRECT_ARGS ) ) != 0; +} - inline bool HasTextureFlags( Type value ) - { - return ( value & ( RENDER_TARGET | DEPTH_STENCIL ) ) != 0; - } +inline bool HasTextureFlags( Type value ) +{ + return ( value & ( RENDER_TARGET | DEPTH_STENCIL ) ) != 0; +} } namespace Tr2LockType { - enum Type - { - SYNCHRONIZED, - NON_SYNCHRONIZED, - }; +enum Type +{ + SYNCHRONIZED, + NON_SYNCHRONIZED, +}; } enum class Tr2UseResourceDestination { - RENDER, - COMPUTE, + RENDER, + COMPUTE, }; #endif // Tr2RenderContextEnum_h diff --git a/trinityal/Tr2VertexDefinition.cpp b/trinityal/Tr2VertexDefinition.cpp index 804f40040..47ce36e85 100644 --- a/trinityal/Tr2VertexDefinition.cpp +++ b/trinityal/Tr2VertexDefinition.cpp @@ -17,33 +17,28 @@ Tr2VertexDefinition::Tr2VertexDefinition( const Tr2VertexDefinition& other ) *this = other; } -Tr2VertexDefinition::Item::Item() - : m_usage( Tr2VertexDefinition::POSITION ) - , m_usageIndex( 0 ) - , m_dataType( FLOAT32_1 ) - , m_offset( 0 ) - , m_stream( 0 ) - , m_instanceStepRate( 0 ) -{} +Tr2VertexDefinition::Item::Item() : + m_usage( Tr2VertexDefinition::POSITION ), m_usageIndex( 0 ), m_dataType( FLOAT32_1 ), m_offset( 0 ), m_stream( 0 ), m_instanceStepRate( 0 ) +{ +} bool Tr2VertexDefinition::Item::operator==( const Tr2VertexDefinition::Item& other ) const { - return m_usage == other.m_usage && - m_usageIndex == other.m_usageIndex && - m_dataType == other.m_dataType && - m_offset == other.m_offset && - m_stream == other.m_stream && - m_instanceStepRate == other.m_instanceStepRate - ; + return m_usage == other.m_usage && + m_usageIndex == other.m_usageIndex && + m_dataType == other.m_dataType && + m_offset == other.m_offset && + m_stream == other.m_stream && + m_instanceStepRate == other.m_instanceStepRate; } bool Tr2VertexDefinition::operator==( const Tr2VertexDefinition& other ) const { - return m_nextOffset[0] == other.m_nextOffset[0] && - m_nextOffset[1] == other.m_nextOffset[1] && - m_nextOffset[2] == other.m_nextOffset[2] && - m_nextOffset[3] == other.m_nextOffset[3] && - m_items == other.m_items; + return m_nextOffset[0] == other.m_nextOffset[0] && + m_nextOffset[1] == other.m_nextOffset[1] && + m_nextOffset[2] == other.m_nextOffset[2] && + m_nextOffset[3] == other.m_nextOffset[3] && + m_items == other.m_items; } Tr2VertexDefinition& Tr2VertexDefinition::operator=( const Tr2VertexDefinition& other ) @@ -69,12 +64,12 @@ Tr2VertexDefinition& Tr2VertexDefinition::operator=( Tr2VertexDefinition&& other Tr2VertexDefinition::Item& Tr2VertexDefinition::Add( Tr2VertexDefinition::DataType type, Tr2VertexDefinition::UsageCode usage, unsigned usageIndex, unsigned stream, unsigned stepRate ) { Item item; - item.m_dataType = type; - item.m_offset = stream < OFFSET_COUNT ? m_nextOffset[stream] : 0; - item.m_stream = stream; - item.m_usage = usage; - item.m_usageIndex = usageIndex; - item.m_instanceStepRate = stepRate; + item.m_dataType = type; + item.m_offset = stream < OFFSET_COUNT ? m_nextOffset[stream] : 0; + item.m_stream = stream; + item.m_usage = usage; + item.m_usageIndex = usageIndex; + item.m_instanceStepRate = stepRate; m_items.push_back( item ); if( stream < OFFSET_COUNT ) { @@ -85,16 +80,14 @@ Tr2VertexDefinition::Item& Tr2VertexDefinition::Add( Tr2VertexDefinition::DataTy Tr2VertexDefinition::Item* Tr2VertexDefinition::Find( UsageCode usage ) { - auto it = std::find_if( begin( m_items ), end( m_items ), [=]( const Item& v ) - { return v.m_usage == usage; } ); + auto it = std::find_if( begin( m_items ), end( m_items ), [=]( const Item& v ) { return v.m_usage == usage; } ); return it == m_items.end() ? nullptr : &*it; } Tr2VertexDefinition::Item* Tr2VertexDefinition::Find( UsageCode usage, unsigned usageIndex ) { - auto it = std::find_if( begin( m_items ), end( m_items ), [=]( const Item& v ) - { return v.m_usage == usage && v.m_usageIndex == usageIndex; } ); + auto it = std::find_if( begin( m_items ), end( m_items ), [=]( const Item& v ) { return v.m_usage == usage && v.m_usageIndex == usageIndex; } ); return it == m_items.end() ? nullptr : &*it; } diff --git a/trinityal/Tr2VertexDefinition.h b/trinityal/Tr2VertexDefinition.h index 4af2774c1..6f40d04f7 100644 --- a/trinityal/Tr2VertexDefinition.h +++ b/trinityal/Tr2VertexDefinition.h @@ -8,7 +8,7 @@ // Description: // Simple array to store a vertex declaration -- type codes, offsets, // sizes and usage index. This replaces granny_data_type_definition, -// which requires string comparisons and offset recomputations, and +// which requires string comparisons and offset recomputations, and // D3DVERTEXELEMENT9[] which is DX9 specific. // ------------------------------------------------------------- class Tr2VertexDefinition @@ -30,125 +30,134 @@ class Tr2VertexDefinition enum DataType { - DT_INT8 = 0, - DT_INT16 = 1, - DT_INT32 = 2, - DT_FLOAT16 = 3, - DT_FLOAT32 = 4, - - DT_TYPE_MASK = 7, - - DT_UNSIGNED_BIT = 1 << 3, - DT_NORMALIZED_BIT = 1 << 4, - - DT_SIZE_OFFSET = 5, - DT_SIZE_MASK = 3 << DT_SIZE_OFFSET, - DT_SIZE_1 = 0 << DT_SIZE_OFFSET, - DT_SIZE_2 = 1 << DT_SIZE_OFFSET, - DT_SIZE_3 = 2 << DT_SIZE_OFFSET, - DT_SIZE_4 = 3 << DT_SIZE_OFFSET, - - BYTE_1 = DT_INT8 | DT_SIZE_1, - BYTE_2 = DT_INT8 | DT_SIZE_2, - BYTE_3 = DT_INT8 | DT_SIZE_3, - BYTE_4 = DT_INT8 | DT_SIZE_4, - - UBYTE_1 = DT_INT8 | DT_SIZE_1 | DT_UNSIGNED_BIT, - UBYTE_2 = DT_INT8 | DT_SIZE_2 | DT_UNSIGNED_BIT, - UBYTE_3 = DT_INT8 | DT_SIZE_3 | DT_UNSIGNED_BIT, - UBYTE_4 = DT_INT8 | DT_SIZE_4 | DT_UNSIGNED_BIT, - - SHORT_1 = DT_INT16 | DT_SIZE_1, - SHORT_2 = DT_INT16 | DT_SIZE_2, - SHORT_3 = DT_INT16 | DT_SIZE_3, - SHORT_4 = DT_INT16 | DT_SIZE_4, - - USHORT_1 = DT_INT16 | DT_SIZE_1 | DT_UNSIGNED_BIT, - USHORT_2 = DT_INT16 | DT_SIZE_2 | DT_UNSIGNED_BIT, - USHORT_3 = DT_INT16 | DT_SIZE_3 | DT_UNSIGNED_BIT, - USHORT_4 = DT_INT16 | DT_SIZE_4 | DT_UNSIGNED_BIT, - - INT32_1 = DT_INT32 | DT_SIZE_1, - INT32_2 = DT_INT32 | DT_SIZE_2, - INT32_3 = DT_INT32 | DT_SIZE_3, - INT32_4 = DT_INT32 | DT_SIZE_4, - - UINT32_1 = DT_INT32 | DT_SIZE_1 | DT_UNSIGNED_BIT, - UINT32_2 = DT_INT32 | DT_SIZE_2 | DT_UNSIGNED_BIT, - UINT32_3 = DT_INT32 | DT_SIZE_3 | DT_UNSIGNED_BIT, - UINT32_4 = DT_INT32 | DT_SIZE_4 | DT_UNSIGNED_BIT, - - FLOAT16_1 = DT_FLOAT16 | DT_SIZE_1, - FLOAT16_2 = DT_FLOAT16 | DT_SIZE_2, - FLOAT16_3 = DT_FLOAT16 | DT_SIZE_3, - FLOAT16_4 = DT_FLOAT16 | DT_SIZE_4, - - UFLOAT16_1 = DT_FLOAT16 | DT_SIZE_1 | DT_UNSIGNED_BIT, - UFLOAT16_2 = DT_FLOAT16 | DT_SIZE_2 | DT_UNSIGNED_BIT, - UFLOAT16_3 = DT_FLOAT16 | DT_SIZE_3 | DT_UNSIGNED_BIT, - UFLOAT16_4 = DT_FLOAT16 | DT_SIZE_4 | DT_UNSIGNED_BIT, - - FLOAT32_1 = DT_FLOAT32 | DT_SIZE_1, - FLOAT32_2 = DT_FLOAT32 | DT_SIZE_2, - FLOAT32_3 = DT_FLOAT32 | DT_SIZE_3, - FLOAT32_4 = DT_FLOAT32 | DT_SIZE_4, - - UFLOAT32_1 = DT_FLOAT32 | DT_SIZE_1 | DT_UNSIGNED_BIT, - UFLOAT32_2 = DT_FLOAT32 | DT_SIZE_2 | DT_UNSIGNED_BIT, - UFLOAT32_3 = DT_FLOAT32 | DT_SIZE_3 | DT_UNSIGNED_BIT, - UFLOAT32_4 = DT_FLOAT32 | DT_SIZE_4 | DT_UNSIGNED_BIT, - - BYTE_1_NORM = BYTE_1 | DT_NORMALIZED_BIT, - BYTE_2_NORM = BYTE_2 | DT_NORMALIZED_BIT, - BYTE_3_NORM = BYTE_3 | DT_NORMALIZED_BIT, - BYTE_4_NORM = BYTE_4 | DT_NORMALIZED_BIT, - - UBYTE_1_NORM = UBYTE_1 | DT_NORMALIZED_BIT, - UBYTE_2_NORM = UBYTE_2 | DT_NORMALIZED_BIT, - UBYTE_3_NORM = UBYTE_3 | DT_NORMALIZED_BIT, - UBYTE_4_NORM = UBYTE_4 | DT_NORMALIZED_BIT, - - SHORT_1_NORM = SHORT_1 | DT_NORMALIZED_BIT, - SHORT_2_NORM = SHORT_2 | DT_NORMALIZED_BIT, - SHORT_3_NORM = SHORT_3 | DT_NORMALIZED_BIT, - SHORT_4_NORM = SHORT_4 | DT_NORMALIZED_BIT, - - USHORT_1_NORM = USHORT_1 | DT_NORMALIZED_BIT, - USHORT_2_NORM = USHORT_2 | DT_NORMALIZED_BIT, - USHORT_3_NORM = USHORT_3 | DT_NORMALIZED_BIT, - USHORT_4_NORM = USHORT_4 | DT_NORMALIZED_BIT, - - DT_UNKNOWN_TYPE = 0xffFFffFFu + DT_INT8 = 0, + DT_INT16 = 1, + DT_INT32 = 2, + DT_FLOAT16 = 3, + DT_FLOAT32 = 4, + + DT_TYPE_MASK = 7, + + DT_UNSIGNED_BIT = 1 << 3, + DT_NORMALIZED_BIT = 1 << 4, + + DT_SIZE_OFFSET = 5, + DT_SIZE_MASK = 3 << DT_SIZE_OFFSET, + DT_SIZE_1 = 0 << DT_SIZE_OFFSET, + DT_SIZE_2 = 1 << DT_SIZE_OFFSET, + DT_SIZE_3 = 2 << DT_SIZE_OFFSET, + DT_SIZE_4 = 3 << DT_SIZE_OFFSET, + + BYTE_1 = DT_INT8 | DT_SIZE_1, + BYTE_2 = DT_INT8 | DT_SIZE_2, + BYTE_3 = DT_INT8 | DT_SIZE_3, + BYTE_4 = DT_INT8 | DT_SIZE_4, + + UBYTE_1 = DT_INT8 | DT_SIZE_1 | DT_UNSIGNED_BIT, + UBYTE_2 = DT_INT8 | DT_SIZE_2 | DT_UNSIGNED_BIT, + UBYTE_3 = DT_INT8 | DT_SIZE_3 | DT_UNSIGNED_BIT, + UBYTE_4 = DT_INT8 | DT_SIZE_4 | DT_UNSIGNED_BIT, + + SHORT_1 = DT_INT16 | DT_SIZE_1, + SHORT_2 = DT_INT16 | DT_SIZE_2, + SHORT_3 = DT_INT16 | DT_SIZE_3, + SHORT_4 = DT_INT16 | DT_SIZE_4, + + USHORT_1 = DT_INT16 | DT_SIZE_1 | DT_UNSIGNED_BIT, + USHORT_2 = DT_INT16 | DT_SIZE_2 | DT_UNSIGNED_BIT, + USHORT_3 = DT_INT16 | DT_SIZE_3 | DT_UNSIGNED_BIT, + USHORT_4 = DT_INT16 | DT_SIZE_4 | DT_UNSIGNED_BIT, + + INT32_1 = DT_INT32 | DT_SIZE_1, + INT32_2 = DT_INT32 | DT_SIZE_2, + INT32_3 = DT_INT32 | DT_SIZE_3, + INT32_4 = DT_INT32 | DT_SIZE_4, + + UINT32_1 = DT_INT32 | DT_SIZE_1 | DT_UNSIGNED_BIT, + UINT32_2 = DT_INT32 | DT_SIZE_2 | DT_UNSIGNED_BIT, + UINT32_3 = DT_INT32 | DT_SIZE_3 | DT_UNSIGNED_BIT, + UINT32_4 = DT_INT32 | DT_SIZE_4 | DT_UNSIGNED_BIT, + + FLOAT16_1 = DT_FLOAT16 | DT_SIZE_1, + FLOAT16_2 = DT_FLOAT16 | DT_SIZE_2, + FLOAT16_3 = DT_FLOAT16 | DT_SIZE_3, + FLOAT16_4 = DT_FLOAT16 | DT_SIZE_4, + + UFLOAT16_1 = DT_FLOAT16 | DT_SIZE_1 | DT_UNSIGNED_BIT, + UFLOAT16_2 = DT_FLOAT16 | DT_SIZE_2 | DT_UNSIGNED_BIT, + UFLOAT16_3 = DT_FLOAT16 | DT_SIZE_3 | DT_UNSIGNED_BIT, + UFLOAT16_4 = DT_FLOAT16 | DT_SIZE_4 | DT_UNSIGNED_BIT, + + FLOAT32_1 = DT_FLOAT32 | DT_SIZE_1, + FLOAT32_2 = DT_FLOAT32 | DT_SIZE_2, + FLOAT32_3 = DT_FLOAT32 | DT_SIZE_3, + FLOAT32_4 = DT_FLOAT32 | DT_SIZE_4, + + UFLOAT32_1 = DT_FLOAT32 | DT_SIZE_1 | DT_UNSIGNED_BIT, + UFLOAT32_2 = DT_FLOAT32 | DT_SIZE_2 | DT_UNSIGNED_BIT, + UFLOAT32_3 = DT_FLOAT32 | DT_SIZE_3 | DT_UNSIGNED_BIT, + UFLOAT32_4 = DT_FLOAT32 | DT_SIZE_4 | DT_UNSIGNED_BIT, + + BYTE_1_NORM = BYTE_1 | DT_NORMALIZED_BIT, + BYTE_2_NORM = BYTE_2 | DT_NORMALIZED_BIT, + BYTE_3_NORM = BYTE_3 | DT_NORMALIZED_BIT, + BYTE_4_NORM = BYTE_4 | DT_NORMALIZED_BIT, + + UBYTE_1_NORM = UBYTE_1 | DT_NORMALIZED_BIT, + UBYTE_2_NORM = UBYTE_2 | DT_NORMALIZED_BIT, + UBYTE_3_NORM = UBYTE_3 | DT_NORMALIZED_BIT, + UBYTE_4_NORM = UBYTE_4 | DT_NORMALIZED_BIT, + + SHORT_1_NORM = SHORT_1 | DT_NORMALIZED_BIT, + SHORT_2_NORM = SHORT_2 | DT_NORMALIZED_BIT, + SHORT_3_NORM = SHORT_3 | DT_NORMALIZED_BIT, + SHORT_4_NORM = SHORT_4 | DT_NORMALIZED_BIT, + + USHORT_1_NORM = USHORT_1 | DT_NORMALIZED_BIT, + USHORT_2_NORM = USHORT_2 | DT_NORMALIZED_BIT, + USHORT_3_NORM = USHORT_3 | DT_NORMALIZED_BIT, + USHORT_4_NORM = USHORT_4 | DT_NORMALIZED_BIT, + + DT_UNKNOWN_TYPE = 0xffFFffFFu }; struct Item { Item(); - UsageCode m_usage; - unsigned m_usageIndex; - DataType m_dataType; - unsigned m_offset; - unsigned m_stream; - unsigned m_instanceStepRate; + UsageCode m_usage; + unsigned m_usageIndex; + DataType m_dataType; + unsigned m_offset; + unsigned m_stream; + unsigned m_instanceStepRate; bool operator==( const Item& other ) const; // most common way to sort these is by offset - bool operator<( const Item& other ) const { return m_offset < other.m_offset; } + bool operator<( const Item& other ) const + { + return m_offset < other.m_offset; + } }; - std::vector m_items; + std::vector m_items; // Return true if there are no items at all in m_items. - bool empty() const { return m_items.empty(); } + bool empty() const + { + return m_items.empty(); + } // Stores the next offset for an item that will be added with Add(). Otherwise unused, // the vertex definition and layout don't care about this value. // We support up to OFFSET_COUNT streams, if you have more than that then you will need // to track the offsets manually. - enum { OFFSET_COUNT = 4 }; - unsigned m_nextOffset[OFFSET_COUNT]; + enum + { + OFFSET_COUNT = 4 + }; + unsigned m_nextOffset[OFFSET_COUNT]; Tr2VertexDefinition(); bool operator==( const Tr2VertexDefinition& other ) const; @@ -172,21 +181,26 @@ class Tr2VertexDefinition // Returns the item just added. Item& Add( DataType type, UsageCode usage, unsigned usageIndex = 0, unsigned stream = 0, unsigned stepRate = 0 ); - static inline unsigned GetDataTypeSizeInMembers( DataType dataType ) + static inline unsigned GetDataTypeSizeInMembers( DataType dataType ) { return ( ( dataType & DT_SIZE_MASK ) >> DT_SIZE_OFFSET ) + 1; } - // Static helper array that tells you how many bytes a given data type takes. - static inline unsigned GetDataTypeSizeInBytes( DataType dataType ) - { + // Static helper array that tells you how many bytes a given data type takes. + static inline unsigned GetDataTypeSizeInBytes( DataType dataType ) + { const unsigned size = GetDataTypeSizeInMembers( dataType ); switch( dataType & DT_TYPE_MASK ) { - case DT_INT8 : return size; - case DT_INT16 : return size * 2; - case DT_INT32 : return size * 4; - case DT_FLOAT16 : return size * 2; - case DT_FLOAT32 : return size * 4; + case DT_INT8: + return size; + case DT_INT16: + return size * 2; + case DT_INT32: + return size * 4; + case DT_FLOAT16: + return size * 2; + case DT_FLOAT32: + return size * 4; } return 0; } diff --git a/trinityal/dx11/Tr2BufferALDx11.cpp b/trinityal/dx11/Tr2BufferALDx11.cpp index 5684095cd..2827cfe72 100644 --- a/trinityal/dx11/Tr2BufferALDx11.cpp +++ b/trinityal/dx11/Tr2BufferALDx11.cpp @@ -12,470 +12,470 @@ using namespace Tr2RenderContextEnum; namespace { - template - bool HasFlag( T value, T flag ) - { - return ( value & flag ) == flag; - } +template +bool HasFlag( T value, T flag ) +{ + return ( value & flag ) == flag; +} } namespace TrinityALImpl { - ALResult Tr2BufferAL::Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); +ALResult Tr2BufferAL::Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - auto stride = desc.stride; - if( desc.format != PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( desc.format ); - } + auto stride = desc.stride; + if( desc.format != PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( desc.format ); + } - if( desc.count == 0 ) - { - return E_INVALIDARG; - } + if( desc.count == 0 ) + { + return E_INVALIDARG; + } - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + if( !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } - bool isImmutable = !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); - if( isImmutable && !initialData ) - { - return E_INVALIDARG; - } + bool isImmutable = !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); + if( isImmutable && !initialData ) + { + return E_INVALIDARG; + } - D3D11_BUFFER_DESC bd; - memset( &bd, 0, sizeof( bd ) ); + D3D11_BUFFER_DESC bd; + memset( &bd, 0, sizeof( bd ) ); - if( isImmutable ) - { - bd.Usage = D3D11_USAGE_IMMUTABLE; - } - else if( HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - bd.Usage = D3D11_USAGE_DYNAMIC; - bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - } - else - { - bd.Usage = D3D11_USAGE_DEFAULT; - } + if( isImmutable ) + { + bd.Usage = D3D11_USAGE_IMMUTABLE; + } + else if( HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + bd.Usage = D3D11_USAGE_DYNAMIC; + bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } + else + { + bd.Usage = D3D11_USAGE_DEFAULT; + } - bd.ByteWidth = stride * desc.count; - bd.StructureByteStride = stride; + bd.ByteWidth = stride * desc.count; + bd.StructureByteStride = stride; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) - { - bd.BindFlags |= D3D11_BIND_VERTEX_BUFFER; - } + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) + { + bd.BindFlags |= D3D11_BIND_VERTEX_BUFFER; + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) - { - bd.BindFlags |= D3D11_BIND_INDEX_BUFFER; - } + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) + { + bd.BindFlags |= D3D11_BIND_INDEX_BUFFER; + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + bd.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + if( desc.format == PIXEL_FORMAT_UNKNOWN ) { - bd.BindFlags |= D3D11_BIND_SHADER_RESOURCE; - if( desc.format == PIXEL_FORMAT_UNKNOWN ) + if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) { - if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) - { - bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; - } + bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; } } + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + bd.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; + if( desc.format == PIXEL_FORMAT_UNKNOWN ) { - bd.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; - if( desc.format == PIXEL_FORMAT_UNKNOWN ) + if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) { - if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) - { - bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; - } + bd.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; } } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::DRAW_INDIRECT_ARGS ) ) + } + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::DRAW_INDIRECT_ARGS ) ) + { + bd.MiscFlags |= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS; + } + + D3D11_SUBRESOURCE_DATA initialData11; + if( initialData ) + { + initialData11.pSysMem = initialData; + initialData11.SysMemPitch = 0; + initialData11.SysMemSlicePitch = 0; + } + + auto hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &initialData11 : nullptr, &m_buffer ); + if( hr == E_OUTOFMEMORY ) + { + int retries = 10; + while( hr == E_OUTOFMEMORY && retries ) { - bd.MiscFlags |= D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS; + CCP_AL_LOGWARN( "CreateBuffer failed with E_OUTOFMEMORY - retrying after Flush" ); + renderContext.m_context->Flush(); + hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &initialData11 : nullptr, &m_buffer ); + --retries; } + } + if( FAILED( hr ) ) + { + Destroy(); + return hr; + } - D3D11_SUBRESOURCE_DATA initialData11; - if( initialData ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + D3D11_SHADER_RESOURCE_VIEW_DESC descSRV; + memset( &descSRV, 0, sizeof( descSRV ) ); + if( desc.format == PIXEL_FORMAT_UNKNOWN && ( bd.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED ) == 0 ) { - initialData11.pSysMem = initialData; - initialData11.SysMemPitch = 0; - initialData11.SysMemSlicePitch = 0; + descSRV.Format = DXGI_FORMAT_R32_UINT; } - - auto hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &initialData11 : nullptr, &m_buffer ); - if( hr == E_OUTOFMEMORY ) + else { - int retries = 10; - while( hr == E_OUTOFMEMORY && retries ) - { - CCP_AL_LOGWARN( "CreateBuffer failed with E_OUTOFMEMORY - retrying after Flush" ); - renderContext.m_context->Flush(); - hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &initialData11 : nullptr, &m_buffer ); - --retries; - } + descSRV.Format = static_cast( desc.format ); } - if( FAILED( hr ) ) + descSRV.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + descSRV.Buffer.ElementWidth = stride; + descSRV.Buffer.NumElements = desc.count; + if( FAILED( hr = renderContext.m_d3dDevice11->CreateShaderResourceView( m_buffer, &descSRV, &m_srv ) ) ) { Destroy(); return hr; } + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + D3D11_UNORDERED_ACCESS_VIEW_DESC descUAV; + descUAV.Format = static_cast( desc.format ); + descUAV.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; + descUAV.Buffer.FirstElement = 0; + descUAV.Buffer.NumElements = desc.count; + descUAV.Buffer.Flags = 0; + if( FAILED( hr = renderContext.m_d3dDevice11->CreateUnorderedAccessView( m_buffer, &descUAV, &m_uav ) ) ) { - D3D11_SHADER_RESOURCE_VIEW_DESC descSRV; - memset( &descSRV, 0, sizeof( descSRV ) ); - if( desc.format == PIXEL_FORMAT_UNKNOWN && ( bd.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED ) == 0 ) - { - descSRV.Format = DXGI_FORMAT_R32_UINT; - } - else - { - descSRV.Format = static_cast( desc.format ); - } - descSRV.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; - descSRV.Buffer.ElementWidth = stride; - descSRV.Buffer.NumElements = desc.count; - if( FAILED( hr = renderContext.m_d3dDevice11->CreateShaderResourceView( m_buffer, &descSRV, &m_srv ) ) ) - { - Destroy(); - return hr; - } + Destroy(); + return hr; } + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - D3D11_UNORDERED_ACCESS_VIEW_DESC descUAV; - descUAV.Format = static_cast( desc.format ); - descUAV.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; - descUAV.Buffer.FirstElement = 0; - descUAV.Buffer.NumElements = desc.count; - descUAV.Buffer.Flags = 0; - if( FAILED( hr = renderContext.m_d3dDevice11->CreateUnorderedAccessView( m_buffer, &descUAV, &m_uav ) ) ) - { - Destroy(); - return hr; - } - } + m_memory.Set( Tr2MemoryCounterAL::BUFFER, stride * desc.count ); + m_desc = desc; + m_desc.stride = stride; - m_memory.Set( Tr2MemoryCounterAL::BUFFER, stride * desc.count ); - m_desc = desc; - m_desc.stride = stride; + return hr; +} - return hr; - } +void Tr2BufferAL::Destroy() +{ + m_memory.Reset(); + m_buffer = nullptr; + m_staging = nullptr; + m_srv = nullptr; + m_uav = nullptr; + m_desc.count = 0; + m_writeLockMemory.clear(); +} + +bool Tr2BufferAL::IsValid() const +{ + return m_buffer != nullptr; +} - void Tr2BufferAL::Destroy() +Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const +{ + return m_desc; +} + +ALResult Tr2BufferAL::CreateStagingBuffer( uint32_t size, Tr2RenderContextAL& renderContext ) +{ + if( m_staging ) { - m_memory.Reset(); - m_buffer = nullptr; + D3D11_BUFFER_DESC desc; + m_staging->GetDesc( &desc ); + if( desc.ByteWidth >= size ) + { + return S_OK; + } m_staging = nullptr; - m_srv = nullptr; - m_uav = nullptr; - m_desc.count = 0; - m_writeLockMemory.clear(); } + D3D11_BUFFER_DESC bd; + memset( &bd, 0, sizeof( bd ) ); + + bd.Usage = D3D11_USAGE_STAGING; + bd.ByteWidth = m_desc.stride * m_desc.count; + bd.BindFlags = 0; + bd.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; + + CR_RETURN_HR( + renderContext.m_secondaryDevice11->CreateBuffer( + &bd, + nullptr, + &m_staging ) ); + if( !m_staging ) + { + return E_FAIL; + } + return S_OK; +} - bool Tr2BufferAL::IsValid() const +ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) + { + data = nullptr; + return E_INVALIDCALL; + } + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) { - return m_buffer != nullptr; + return E_INVALIDCALL; } + CR_RETURN_HR( CreateStagingBuffer( m_desc.stride * m_desc.count, renderContext ) ); - Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const + renderContext.m_context->CopyResource( m_staging, m_buffer ); + + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + auto hr = renderContext.m_context->Map( m_staging, 0, D3D11_MAP_READ, 0, &ms ); + if( !ms.pData ) { - return AL_MEMORY_MANAGED; + return E_FAIL; } + data = ms.pData; + return hr; +} - const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const +ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - return m_desc; + data = nullptr; + return E_INVALIDCALL; } + if( size == 0 || offset + size > m_desc.stride * m_desc.count ) + { + data = nullptr; + return E_INVALIDARG; + } + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) + { + return E_INVALIDCALL; + } + CR_RETURN_HR( CreateStagingBuffer( size, renderContext ) ); - ALResult Tr2BufferAL::CreateStagingBuffer( uint32_t size, Tr2RenderContextAL& renderContext ) + if( size == m_desc.stride * m_desc.count ) { - if( m_staging ) - { - D3D11_BUFFER_DESC desc; - m_staging->GetDesc( &desc ); - if( desc.ByteWidth >= size ) - { - return S_OK; - } - m_staging = nullptr; - } - D3D11_BUFFER_DESC bd; - memset( &bd, 0, sizeof( bd ) ); - - bd.Usage = D3D11_USAGE_STAGING; - bd.ByteWidth = m_desc.stride * m_desc.count; - bd.BindFlags = 0; - bd.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - - CR_RETURN_HR( - renderContext.m_secondaryDevice11->CreateBuffer( - &bd, - nullptr, - &m_staging ) ); - if( !m_staging ) - { - return E_FAIL; - } - return S_OK; + renderContext.m_context->CopyResource( m_staging, m_buffer ); + } + else + { + D3D11_BOX box = { offset, 0, 0, offset + size, 1, 1 }; + renderContext.m_context->CopySubresourceRegion( m_staging, 0, 0, 0, 0, m_buffer, 0, &box ); } - ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + auto hr = renderContext.m_context->Map( m_staging, 0, D3D11_MAP_READ, 0, &ms ); + if( !ms.pData ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } - CR_RETURN_HR( CreateStagingBuffer( m_desc.stride * m_desc.count, renderContext ) ); + return E_FAIL; + } + data = ms.pData; + return hr; +} - renderContext.m_context->CopyResource( m_staging, m_buffer ); +void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) + { + return; + } + if( !m_staging ) + { + return; + } + renderContext.m_context->Unmap( m_staging, 0 ); + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) + { + m_staging = nullptr; + } +} - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - auto hr = renderContext.m_context->Map( m_staging, 0, D3D11_MAP_READ, 0, &ms ); - if( !ms.pData ) - { - return E_FAIL; - } - data = ms.pData; - return hr; +ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) +{ + data = nullptr; + if( !renderContext.IsValid() || !IsValid() ) + { + return E_INVALIDCALL; } - ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( size == 0 || offset + size > m_desc.stride * m_desc.count ) + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + auto mapType = HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? D3D11_MAP_WRITE_NO_OVERWRITE : D3D11_MAP_WRITE_DISCARD; + auto hr = renderContext.m_context->Map( m_buffer, 0, mapType, 0, &ms ); + if( FAILED( hr ) ) { - data = nullptr; - return E_INVALIDARG; + return hr; } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) + if( !ms.pData ) { - return E_INVALIDCALL; + return E_FAIL; } - CR_RETURN_HR( CreateStagingBuffer( size, renderContext ) ); - - if( size == m_desc.stride * m_desc.count ) +#if TRINITY_AL_GUARD_LOCKS + if( noSyncronization ) { - renderContext.m_context->CopyResource( m_staging, m_buffer ); + data = ms.pData; } else { - D3D11_BOX box = { offset, 0, 0, offset + size, 1, 1 }; - renderContext.m_context->CopySubresourceRegion( m_staging, 0, 0, 0, 0, m_buffer, 0, &box ); - } - - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - auto hr = renderContext.m_context->Map( m_staging, 0, D3D11_MAP_READ, 0, &ms ); - if( !ms.pData ) - { - return E_FAIL; + m_lockGuard.Lock( m_desc.count * m_desc.stride, ms.pData ); + data = m_lockGuard.GetMemory(); } +#else data = ms.pData; +#endif return hr; } - - void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& renderContext ) + else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - if( !renderContext.IsValid() || !IsValid() ) + if( m_writeLockMemory.empty() ) { - return; + CcpAlignedMallocBuffer buffer( "Tr2BufferAL::m_writeLockMemory", m_desc.stride * m_desc.count, 16 ); + m_writeLockMemory.swap( buffer ); } - if( !m_staging ) + if( m_writeLockMemory.empty() ) { - return; + return E_OUTOFMEMORY; } - renderContext.m_context->Unmap( m_staging, 0 ); - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) - { - m_staging = nullptr; - } - } - ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) + data = m_writeLockMemory.get(); + return S_OK; + } + else { - data = nullptr; - if( !renderContext.IsValid() || !IsValid() ) - { - return E_INVALIDCALL; - } + return E_INVALIDCALL; + } +} - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - auto mapType = HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? D3D11_MAP_WRITE_NO_OVERWRITE : D3D11_MAP_WRITE_DISCARD; - auto hr = renderContext.m_context->Map( m_buffer, 0, mapType, 0, &ms ); - if( FAILED( hr ) ) - { - return hr; - } - if( !ms.pData ) - { - return E_FAIL; - } +void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) + { + return; + } + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { #if TRINITY_AL_GUARD_LOCKS - if( noSyncronization ) - { - data = ms.pData; - } - else - { - m_lockGuard.Lock( m_desc.count * m_desc.stride, ms.pData ); - data = m_lockGuard.GetMemory(); - } -#else - data = ms.pData; -#endif - return hr; - } - else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) - { - if( m_writeLockMemory.empty() ) - { - CcpAlignedMallocBuffer buffer( "Tr2BufferAL::m_writeLockMemory", m_desc.stride * m_desc.count, 16 ); - m_writeLockMemory.swap( buffer ); - } - if( m_writeLockMemory.empty() ) - { - return E_OUTOFMEMORY; - } - - data = m_writeLockMemory.get(); - return S_OK; - } - else + if( m_lockGuard.GetMemory() ) { - return E_INVALIDCALL; + m_lockGuard.Unlock(); } +#endif + renderContext.m_context->Unmap( m_buffer, 0 ); } - - void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) + else { - if( !renderContext.IsValid() || !IsValid() ) + if( m_writeLockMemory.empty() ) { return; } - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { -#if TRINITY_AL_GUARD_LOCKS - if( m_lockGuard.GetMemory() ) - { - m_lockGuard.Unlock(); - } -#endif - renderContext.m_context->Unmap( m_buffer, 0 ); - } - else - { - if( m_writeLockMemory.empty() ) - { - return; - } - renderContext.m_context->UpdateSubresource( m_buffer, 0, nullptr, m_writeLockMemory.get(), 0, 0 ); - } + renderContext.m_context->UpdateSubresource( m_buffer, 0, nullptr, m_writeLockMemory.get(), 0, 0 ); } +} - ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ) +ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - if( !renderContext.IsValid() || !IsValid() ) - { - return E_INVALIDCALL; - } - if( offset + size > m_desc.stride * m_desc.count ) - { - return E_INVALIDARG; - } - if( size == 0 ) - { - return S_OK; - } - - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - void* ptr; - CR_RETURN_HR( MapForWriting( ptr, renderContext ) ); - - uint8_t* dst = static_cast( ptr ) + offset; - const uint8_t* src = static_cast( data ); - - memcpy( dst, src, size ); - UnmapForWriting( renderContext ); - } - else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) - { - D3D11_BOX box = { offset, 0, 0, offset + size, 1, 1 }; - renderContext.m_context->UpdateSubresource( m_buffer, 0, &box, data, 0, 0 ); - } - else - { - return E_INVALIDCALL; - } - - return S_OK; + return E_INVALIDCALL; } - - uint32_t Tr2BufferAL::GetSrvIndexInHeap() const + if( offset + size > m_desc.stride * m_desc.count ) { - return 0xffffffff; + return E_INVALIDARG; } - - uint32_t Tr2BufferAL::GetUavIndexInHeap() const + if( size == 0 ) { - return 0xffffffff; + return S_OK; } - void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - description["type"] = "Tr2BufferAL"; - description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); - description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); - description["format"] = std::to_string( int( GetDesc().format ) ); - description["stride"] = std::to_string( GetDesc().stride ); - description["count"] = std::to_string( GetDesc().count ); - description["name"] = m_name; + void* ptr; + CR_RETURN_HR( MapForWriting( ptr, renderContext ) ); + + uint8_t* dst = static_cast( ptr ) + offset; + const uint8_t* src = static_cast( data ); + + memcpy( dst, src, size ); + UnmapForWriting( renderContext ); } - - ALResult Tr2BufferAL::SetName( const char* name ) + else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - m_name = name; - SetDebugName( m_buffer, name ); - SetDebugName( m_staging, name ); - SetDebugName( m_srv, name ); - SetDebugName( m_uav, name ); - return S_OK; + D3D11_BOX box = { offset, 0, 0, offset + size, 1, 1 }; + renderContext.m_context->UpdateSubresource( m_buffer, 0, &box, data, 0, 0 ); } - - - ID3D11Buffer* Tr2BufferAL::GetGpuResource() const + else { - return m_buffer; + return E_INVALIDCALL; } + + return S_OK; +} + +uint32_t Tr2BufferAL::GetSrvIndexInHeap() const +{ + return 0xffffffff; +} + +uint32_t Tr2BufferAL::GetUavIndexInHeap() const +{ + return 0xffffffff; +} + +void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2BufferAL"; + description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); + description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); + description["format"] = std::to_string( int( GetDesc().format ) ); + description["stride"] = std::to_string( GetDesc().stride ); + description["count"] = std::to_string( GetDesc().count ); + description["name"] = m_name; +} + +ALResult Tr2BufferAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_buffer, name ); + SetDebugName( m_staging, name ); + SetDebugName( m_srv, name ); + SetDebugName( m_uav, name ); + return S_OK; +} + + +ID3D11Buffer* Tr2BufferAL::GetGpuResource() const +{ + return m_buffer; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2BufferALDx11.h b/trinityal/dx11/Tr2BufferALDx11.h index 72d232530..0724f8e33 100644 --- a/trinityal/dx11/Tr2BufferALDx11.h +++ b/trinityal/dx11/Tr2BufferALDx11.h @@ -11,54 +11,54 @@ namespace TrinityALImpl { - class Tr2BufferAL : public Tr2DeviceResourceAL - { - public: - ALResult Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); +class Tr2BufferAL : public Tr2DeviceResourceAL +{ +public: + ALResult Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BufferDescriptionAL& GetDesc() const; + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BufferDescriptionAL& GetDesc() const; - ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); - ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); - ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ); + ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - ID3D11Buffer* GetGpuResource() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + ID3D11Buffer* GetGpuResource() const; - uint32_t GetSrvIndexInHeap() const; - uint32_t GetUavIndexInHeap() const; + uint32_t GetSrvIndexInHeap() const; + uint32_t GetUavIndexInHeap() const; - private: - ALResult CreateStagingBuffer( uint32_t size, Tr2RenderContextAL& renderContext ); +private: + ALResult CreateStagingBuffer( uint32_t size, Tr2RenderContextAL& renderContext ); - CComPtr m_buffer; - CComPtr m_staging; - CComPtr m_srv; - CComPtr m_uav; - Tr2MemoryCounterAL m_memory; - Tr2BufferDescriptionAL m_desc; - CcpAlignedMallocBuffer m_writeLockMemory; + CComPtr m_buffer; + CComPtr m_staging; + CComPtr m_srv; + CComPtr m_uav; + Tr2MemoryCounterAL m_memory; + Tr2BufferDescriptionAL m_desc; + CcpAlignedMallocBuffer m_writeLockMemory; #if TRINITY_AL_GUARD_LOCKS - Tr2LockGuard m_lockGuard; + Tr2LockGuard m_lockGuard; #endif - std::string m_name; + std::string m_name; - friend class Tr2RenderContextAL; - friend class Tr2PrimaryRenderContextAL; - friend class Tr2ResourceSetAL; - }; + friend class Tr2RenderContextAL; + friend class Tr2PrimaryRenderContextAL; + friend class Tr2ResourceSetAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2CapsALDx11.cpp b/trinityal/dx11/Tr2CapsALDx11.cpp index d6846929f..1491579b2 100644 --- a/trinityal/dx11/Tr2CapsALDx11.cpp +++ b/trinityal/dx11/Tr2CapsALDx11.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2CapsALDx11.h" Tr2CapsAL::Tr2CapsAL() diff --git a/trinityal/dx11/Tr2CapsALDx11.h b/trinityal/dx11/Tr2CapsALDx11.h index 829f28fd7..5ccc090b2 100644 --- a/trinityal/dx11/Tr2CapsALDx11.h +++ b/trinityal/dx11/Tr2CapsALDx11.h @@ -4,7 +4,7 @@ #ifndef Tr2CapsALDx11_H #define Tr2CapsALDx11_H -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #define TRINITY_PLATFORM_SUPPORTS_BUFFER_SHADER_RESOURCES 1 #define TRINITY_PLATFORM_SUPPORTS_BUFFER_COUNTERS 1 diff --git a/trinityal/dx11/Tr2ConstantBufferALDx11.cpp b/trinityal/dx11/Tr2ConstantBufferALDx11.cpp index f910cefce..401afb3f1 100644 --- a/trinityal/dx11/Tr2ConstantBufferALDx11.cpp +++ b/trinityal/dx11/Tr2ConstantBufferALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2ConstantBufferALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" @@ -11,178 +11,178 @@ namespace TrinityALImpl { - Tr2ConstantBufferAL::Tr2ConstantBufferAL() - : m_size( 0 ), - m_usage( Tr2ConstantUsageAL::REUSABLE ) +Tr2ConstantBufferAL::Tr2ConstantBufferAL() : + m_size( 0 ), + m_usage( Tr2ConstantUsageAL::REUSABLE ) +{ +} + +ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.m_d3dDevice11 ) { + return E_FAIL; } - ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL & renderContext ) + if( usage == Tr2ConstantUsageAL::IMMUTABLE && !initialData ) { - Destroy(); - - if( !renderContext.m_d3dDevice11 ) - { - return E_FAIL; - } + CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); + return E_INVALIDARG; + } - if( usage == Tr2ConstantUsageAL::IMMUTABLE && !initialData ) + if( usage == Tr2ConstantUsageAL::ONE_SHOT ) + { + m_bufferMirror.resize( "Tr2ConstantBufferAL.m_bufferMirror", size ); + if( initialData ) { - CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); - return E_INVALIDARG; + memcpy( m_bufferMirror.get(), initialData, size ); } - if( usage == Tr2ConstantUsageAL::ONE_SHOT ) - { - m_bufferMirror.resize( "Tr2ConstantBufferAL.m_bufferMirror", size ); - if( initialData ) - { - memcpy( m_bufferMirror.get(), initialData, size ); - } - - m_size = size; - m_usage = usage; + m_size = size; + m_usage = usage; - return S_OK; - } - else - { - D3D11_BUFFER_DESC bd; - ZeroMemory( &bd, sizeof( bd ) ); - - bd.ByteWidth = size; - bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bd.Usage = D3D11_USAGE_DYNAMIC; - bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - - D3D11_SUBRESOURCE_DATA data; - if( initialData ) - { - data.pSysMem = initialData; - data.SysMemPitch = 0; - data.SysMemSlicePitch = 0; - } - auto hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &data : nullptr, &m_buffer ); - if( FAILED( hr ) ) - { - return hr; - } - - m_size = size; - m_usage = usage; - - return S_OK; - } + return S_OK; } - - ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL & renderContext ) + else { - if( m_usage == Tr2ConstantUsageAL::ONE_SHOT ) - { - if( !m_bufferMirror ) - { - *data = 0; - return E_FAIL; - } - *data = m_bufferMirror.get(); - return S_OK; - } + D3D11_BUFFER_DESC bd; + ZeroMemory( &bd, sizeof( bd ) ); - if( !m_buffer ) + bd.ByteWidth = size; + bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + bd.Usage = D3D11_USAGE_DYNAMIC; + bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + D3D11_SUBRESOURCE_DATA data; + if( initialData ) { - *data = 0; - return E_FAIL; + data.pSysMem = initialData; + data.SysMemPitch = 0; + data.SysMemSlicePitch = 0; } - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - HRESULT hr = renderContext.m_context->Map( m_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ms ); + auto hr = renderContext.m_d3dDevice11->CreateBuffer( &bd, initialData ? &data : nullptr, &m_buffer ); if( FAILED( hr ) ) { - *data = nullptr; return hr; } - if( !ms.pData ) + + m_size = size; + m_usage = usage; + + return S_OK; + } +} + +ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& renderContext ) +{ + if( m_usage == Tr2ConstantUsageAL::ONE_SHOT ) + { + if( !m_bufferMirror ) { - *data = nullptr; + *data = 0; return E_FAIL; } + *data = m_bufferMirror.get(); + return S_OK; + } + + if( !m_buffer ) + { + *data = 0; + return E_FAIL; + } + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + HRESULT hr = renderContext.m_context->Map( m_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ms ); + if( FAILED( hr ) ) + { + *data = nullptr; + return hr; + } + if( !ms.pData ) + { + *data = nullptr; + return E_FAIL; + } #ifdef TRINITY_AL_GUARD_LOCKS - m_lockGuard.Lock( m_size, ms.pData ); - *data = m_lockGuard.GetMemory(); + m_lockGuard.Lock( m_size, ms.pData ); + *data = m_lockGuard.GetMemory(); #else - *data = ms.pData; + *data = ms.pData; #endif - return hr; - } + return hr; +} - ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL & renderContext ) +ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& renderContext ) +{ + if( m_usage == Tr2ConstantUsageAL::ONE_SHOT ) { - if( m_usage == Tr2ConstantUsageAL::ONE_SHOT ) + if( !m_bufferMirror ) { - if( !m_bufferMirror ) - { - CCP_ASSERT_M( false, "Unlocking a null buffer" ); - return E_FAIL; - } - - return S_OK; + CCP_ASSERT_M( false, "Unlocking a null buffer" ); + return E_FAIL; } - else + + return S_OK; + } + else + { + if( !m_buffer ) { - if( !m_buffer ) - { - CCP_ASSERT_M( false, "Unlocking a null buffer" ); - return E_FAIL; - } + CCP_ASSERT_M( false, "Unlocking a null buffer" ); + return E_FAIL; + } #ifdef TRINITY_AL_GUARD_LOCKS - m_lockGuard.Unlock(); + m_lockGuard.Unlock(); #endif - renderContext.m_context->Unmap( m_buffer, 0 ); - } - return S_OK; + renderContext.m_context->Unmap( m_buffer, 0 ); } + return S_OK; +} - void Tr2ConstantBufferAL::Destroy() - { - m_buffer = nullptr; - m_bufferMirror.clear(); - m_usage = Tr2ConstantUsageAL::REUSABLE; - m_size = 0; - } +void Tr2ConstantBufferAL::Destroy() +{ + m_buffer = nullptr; + m_bufferMirror.clear(); + m_usage = Tr2ConstantUsageAL::REUSABLE; + m_size = 0; +} - bool Tr2ConstantBufferAL::IsValid() const - { - return m_size > 0 && ( m_usage == Tr2ConstantUsageAL::ONE_SHOT || m_buffer != nullptr ); - } +bool Tr2ConstantBufferAL::IsValid() const +{ + return m_size > 0 && ( m_usage == Tr2ConstantUsageAL::ONE_SHOT || m_buffer != nullptr ); +} - Tr2ConstantUsageAL::Type Tr2ConstantBufferAL::GetUsage() const - { - return m_usage; - } +Tr2ConstantUsageAL::Type Tr2ConstantBufferAL::GetUsage() const +{ + return m_usage; +} - uint32_t Tr2ConstantBufferAL::GetSize() const - { - return m_size; - } +uint32_t Tr2ConstantBufferAL::GetSize() const +{ + return m_size; +} - Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ConstantBufferAL"; - description["usage"] = std::to_string( int( m_usage ) ); - description["size"] = std::to_string( m_size ); - description["name"] = m_name; - } +void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ConstantBufferAL"; + description["usage"] = std::to_string( int( m_usage ) ); + description["size"] = std::to_string( m_size ); + description["name"] = m_name; +} - ALResult Tr2ConstantBufferAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_buffer, name ); - return S_OK; - } +ALResult Tr2ConstantBufferAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_buffer, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2ConstantBufferALDx11.h b/trinityal/dx11/Tr2ConstantBufferALDx11.h index fed09f7bb..46d7e0fb0 100644 --- a/trinityal/dx11/Tr2ConstantBufferALDx11.h +++ b/trinityal/dx11/Tr2ConstantBufferALDx11.h @@ -3,7 +3,7 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2ConstantBufferAL.h" @@ -13,41 +13,41 @@ namespace TrinityALImpl { - class Tr2ConstantBufferAL : public Tr2DeviceResourceAL - { - public: - Tr2ConstantBufferAL(); +class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +{ +public: + Tr2ConstantBufferAL(); - ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL & renderContext ); - void Destroy(); + ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - ALResult Lock( void** data, Tr2RenderContextAL & renderContext ); - ALResult Unlock( Tr2RenderContextAL & renderContext ); + ALResult Lock( void** data, Tr2RenderContextAL& renderContext ); + ALResult Unlock( Tr2RenderContextAL& renderContext ); - bool IsValid() const; - Tr2ConstantUsageAL::Type GetUsage() const; - uint32_t GetSize() const; - Tr2ALMemoryType GetMemoryClass() const; + bool IsValid() const; + Tr2ConstantUsageAL::Type GetUsage() const; + uint32_t GetSize() const; + Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; - Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; +private: + Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; + Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; - CComPtr m_buffer; - CcpMallocBuffer m_bufferMirror; - Tr2ConstantUsageAL::Type m_usage; - uint32_t m_size; + CComPtr m_buffer; + CcpMallocBuffer m_bufferMirror; + Tr2ConstantUsageAL::Type m_usage; + uint32_t m_size; #ifdef TRINITY_AL_GUARD_LOCKS - Tr2LockGuard m_lockGuard; + Tr2LockGuard m_lockGuard; #endif - std::string m_name; + std::string m_name; - friend class Tr2RenderContextAL; - }; + friend class Tr2RenderContextAL; +}; } -#endif +#endif diff --git a/trinityal/dx11/Tr2FenceALDx11.cpp b/trinityal/dx11/Tr2FenceALDx11.cpp index 3034f79f1..613745070 100644 --- a/trinityal/dx11/Tr2FenceALDx11.cpp +++ b/trinityal/dx11/Tr2FenceALDx11.cpp @@ -1,107 +1,107 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2FenceALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" namespace TrinityALImpl { - Tr2FenceAL::Tr2FenceAL() +Tr2FenceAL::Tr2FenceAL() +{ +} + +Tr2FenceAL::~Tr2FenceAL() +{ +} + +ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { + return E_FAIL; } + D3D11_QUERY_DESC desc; + desc.Query = D3D11_QUERY_EVENT; + desc.MiscFlags = 0; + return renderContext.m_d3dDevice11->CreateQuery( &desc, &m_query ); +} + +void Tr2FenceAL::Destroy() +{ + m_query = nullptr; +} + +bool Tr2FenceAL::IsValid() const +{ + return m_query != nullptr; +} - Tr2FenceAL::~Tr2FenceAL() +ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { + return E_INVALIDCALL; } - - ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - D3D11_QUERY_DESC desc; - desc.Query = D3D11_QUERY_EVENT; - desc.MiscFlags = 0; - return renderContext.m_d3dDevice11->CreateQuery( &desc, &m_query ); + return E_FAIL; } + renderContext.m_context->End( m_query ); + return S_OK; +} - void Tr2FenceAL::Destroy() +ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { - m_query = nullptr; + return E_INVALIDCALL; } - - bool Tr2FenceAL::IsValid() const + if( !renderContext.IsValid() ) { - return m_query != nullptr; + return E_FAIL; } + HRESULT hr = renderContext.m_context->GetData( m_query, nullptr, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH ); + CR_RETURN_HR( hr ); + isReached = hr == S_OK; + return S_OK; +} - ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& renderContext ) +ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - renderContext.m_context->End( m_query ); - return S_OK; + return E_INVALIDCALL; } - - ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - HRESULT hr = renderContext.m_context->GetData( m_query, nullptr, 0, D3D11_ASYNC_GETDATA_DONOTFLUSH ); - CR_RETURN_HR( hr ); - isReached = hr == S_OK; - return S_OK; + return E_FAIL; } - - ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& renderContext ) + while( true ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - while( true ) + HRESULT hr = renderContext.m_context->GetData( m_query, nullptr, 0, 0 ); + CR_RETURN_HR( hr ); + if( hr == S_OK ) { - HRESULT hr = renderContext.m_context->GetData( m_query, nullptr, 0, 0 ); - CR_RETURN_HR( hr ); - if( hr == S_OK ) - { - break; - } + break; } - return S_OK; } + return S_OK; +} - void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2FenceAL"; - description["name"] = m_name; - } +void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2FenceAL"; + description["name"] = m_name; +} - ALResult Tr2FenceAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_query, name ); - return S_OK; - } +ALResult Tr2FenceAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_query, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2FenceALDx11.h b/trinityal/dx11/Tr2FenceALDx11.h index b5b62c34a..a18f732b1 100644 --- a/trinityal/dx11/Tr2FenceALDx11.h +++ b/trinityal/dx11/Tr2FenceALDx11.h @@ -2,39 +2,41 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2FenceAL.h" namespace TrinityALImpl { - class Tr2FenceAL : - public Tr2DeviceResourceAL - { - public: - Tr2FenceAL(); - ~Tr2FenceAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; +class Tr2FenceAL : public Tr2DeviceResourceAL +{ +public: + Tr2FenceAL(); + ~Tr2FenceAL(); - ALResult PutFence( Tr2RenderContextAL& renderContext ); - ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); - ALResult Wait( Tr2RenderContextAL& renderContext ); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + bool IsValid() const; - private: - Tr2FenceAL( const Tr2FenceAL& ) /* = delete */; - Tr2FenceAL& operator=( const Tr2FenceAL& ) /* = delete */; + ALResult PutFence( Tr2RenderContextAL& renderContext ); + ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); + ALResult Wait( Tr2RenderContextAL& renderContext ); - CComPtr m_query; - std::string m_name; - }; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2FenceAL( const Tr2FenceAL& ) /* = delete */; + Tr2FenceAL& operator=( const Tr2FenceAL& ) /* = delete */; + + CComPtr m_query; + std::string m_name; +}; } diff --git a/trinityal/dx11/Tr2GpuTimerALDx11.cpp b/trinityal/dx11/Tr2GpuTimerALDx11.cpp index 83678a225..18099980e 100644 --- a/trinityal/dx11/Tr2GpuTimerALDx11.cpp +++ b/trinityal/dx11/Tr2GpuTimerALDx11.cpp @@ -1,154 +1,153 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2GpuTimerALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" namespace TrinityALImpl { - Tr2GpuTimerAL::Tr2GpuTimerAL() - :m_begin(0xffffffffffffffff), - m_end(0xffffffffffffffff), - m_lastTime(-1.f), - m_state(UNINITIALIZED) +Tr2GpuTimerAL::Tr2GpuTimerAL() : + m_begin( 0xffffffffffffffff ), + m_end( 0xffffffffffffffff ), + m_lastTime( -1.f ), + m_state( UNINITIALIZED ) +{ +} + +ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { + return E_INVALIDCALL; } - ALResult Tr2GpuTimerAL::Create(Tr2PrimaryRenderContextAL& renderContext) - { - Destroy(); - if (!renderContext.IsValid()) - { - return E_INVALIDCALL; - } + CComPtr beginQuery; + CComPtr endQuery; + CComPtr disjointQuery; - CComPtr beginQuery; - CComPtr endQuery; - CComPtr disjointQuery; + D3D11_QUERY_DESC desc; + desc.Query = D3D11_QUERY_TIMESTAMP; + desc.MiscFlags = 0; - D3D11_QUERY_DESC desc; - desc.Query = D3D11_QUERY_TIMESTAMP; - desc.MiscFlags = 0; + CR_RETURN_HR( renderContext.m_d3dDevice11->CreateQuery( &desc, &beginQuery.p ) ); + CR_RETURN_HR( renderContext.m_d3dDevice11->CreateQuery( &desc, &endQuery.p ) ); - CR_RETURN_HR(renderContext.m_d3dDevice11->CreateQuery(&desc, &beginQuery.p)); - CR_RETURN_HR(renderContext.m_d3dDevice11->CreateQuery(&desc, &endQuery.p)); + desc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; + desc.MiscFlags = 0; + CR_RETURN_HR( renderContext.m_d3dDevice11->CreateQuery( &desc, &disjointQuery.p ) ); - desc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT; - desc.MiscFlags = 0; - CR_RETURN_HR(renderContext.m_d3dDevice11->CreateQuery(&desc, &disjointQuery.p)); + m_beginQuery = beginQuery; + m_endQuery = endQuery; + m_disjointQuery = disjointQuery; + m_state = READY; + return S_OK; +} - m_beginQuery = beginQuery; - m_endQuery = endQuery; - m_disjointQuery = disjointQuery; - m_state = READY; - return S_OK; - } +void Tr2GpuTimerAL::Destroy() +{ + m_beginQuery = nullptr; + m_endQuery = nullptr; + m_disjointQuery = nullptr; + m_state = UNINITIALIZED; + m_lastTime = -1.f; +} + +bool Tr2GpuTimerAL::IsValid() const +{ + return m_state != UNINITIALIZED; +} - void Tr2GpuTimerAL::Destroy() +bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( !m_beginQuery || !m_endQuery || m_state != READY ) { - m_beginQuery = nullptr; - m_endQuery = nullptr; - m_disjointQuery = nullptr; - m_state = UNINITIALIZED; - m_lastTime = -1.f; + return false; } + renderContext.m_context->Begin( m_disjointQuery ); + renderContext.m_context->End( m_beginQuery ); + m_state = BEGIN_ISSUED; + return true; +} - bool Tr2GpuTimerAL::IsValid() const +void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) +{ + if( !m_beginQuery || !m_endQuery || m_state != BEGIN_ISSUED ) { - return m_state != UNINITIALIZED; + return; } + renderContext.m_context->End( m_endQuery ); + renderContext.m_context->End( m_disjointQuery ); + m_state = END_ISSUED; +} - bool Tr2GpuTimerAL::Begin(Tr2RenderContextAL& renderContext) +float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& renderContext ) +{ + if( !m_beginQuery || !m_endQuery ) { - if (!m_beginQuery || !m_endQuery || m_state != READY) - { - return false; - } - renderContext.m_context->Begin(m_disjointQuery); - renderContext.m_context->End(m_beginQuery); - m_state = BEGIN_ISSUED; - return true; + return m_lastTime; } - - void Tr2GpuTimerAL::End(Tr2RenderContextAL& renderContext) + if( m_state == END_ISSUED ) { - if (!m_beginQuery || !m_endQuery || m_state != BEGIN_ISSUED) + switch( renderContext.m_context->GetData( m_beginQuery, &m_begin, sizeof( m_begin ), D3D11_ASYNC_GETDATA_DONOTFLUSH ) ) { - return; + case S_OK: + m_state = BEGIN_RECEIVED; + break; + case S_FALSE: + break; + default: + m_state = READY; + m_lastTime = -1.f; } - renderContext.m_context->End(m_endQuery); - renderContext.m_context->End(m_disjointQuery); - m_state = END_ISSUED; } - - float Tr2GpuTimerAL::GetTime(Tr2RenderContextAL& renderContext) + if( m_state == BEGIN_RECEIVED ) { - if (!m_beginQuery || !m_endQuery) - { - return m_lastTime; - } - if (m_state == END_ISSUED) + switch( renderContext.m_context->GetData( m_endQuery, &m_end, sizeof( m_end ), D3D11_ASYNC_GETDATA_DONOTFLUSH ) ) { - switch (renderContext.m_context->GetData(m_beginQuery, &m_begin, sizeof(m_begin), D3D11_ASYNC_GETDATA_DONOTFLUSH)) + case S_OK: { + D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint; + if( FAILED( renderContext.m_context->GetData( m_disjointQuery, &disjoint, sizeof( disjoint ), 0 ) ) ) { - case S_OK: - m_state = BEGIN_RECEIVED; - break; - case S_FALSE: - break; - default: m_state = READY; m_lastTime = -1.f; } - } - if (m_state == BEGIN_RECEIVED) - { - switch (renderContext.m_context->GetData(m_endQuery, &m_end, sizeof(m_end), D3D11_ASYNC_GETDATA_DONOTFLUSH)) + else { - case S_OK: - { - D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint; - if (FAILED(renderContext.m_context->GetData(m_disjointQuery, &disjoint, sizeof(disjoint), 0))) - { - m_state = READY; - m_lastTime = -1.f; - } - else + if( !disjoint.Disjoint ) { - if (!disjoint.Disjoint) - { - m_lastTime = float(double(m_end - m_begin) / double(disjoint.Frequency)); - } - m_state = READY; + m_lastTime = float( double( m_end - m_begin ) / double( disjoint.Frequency ) ); } - } - break; - case S_FALSE: - break; - default: m_state = READY; - m_lastTime = -1.f; } } - return m_lastTime; + break; + case S_FALSE: + break; + default: + m_state = READY; + m_lastTime = -1.f; + } } + return m_lastTime; +} - void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2GpuTimerAL"; - description["name"] = m_name; - } +void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2GpuTimerAL"; + description["name"] = m_name; +} - ALResult Tr2GpuTimerAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_beginQuery, name ); - SetDebugName( m_endQuery, name ); - SetDebugName( m_disjointQuery, name ); - return S_OK; - } +ALResult Tr2GpuTimerAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_beginQuery, name ); + SetDebugName( m_endQuery, name ); + SetDebugName( m_disjointQuery, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2GpuTimerALDx11.h b/trinityal/dx11/Tr2GpuTimerALDx11.h index 4b09ada39..cf6c3af4a 100644 --- a/trinityal/dx11/Tr2GpuTimerALDx11.h +++ b/trinityal/dx11/Tr2GpuTimerALDx11.h @@ -4,59 +4,59 @@ #ifndef Tr2GpuTimerALDx11_H #define Tr2GpuTimerALDx11_H -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2GpuTimerAL.h" namespace TrinityALImpl { - class Tr2GpuTimerAL : - public Tr2DeviceResourceAL - { - public: - Tr2GpuTimerAL(); - - ALResult Create(Tr2PrimaryRenderContextAL& renderContext); - - void Destroy(); - - bool Begin(Tr2RenderContextAL& renderContext); +class Tr2GpuTimerAL : public Tr2DeviceResourceAL +{ +public: + Tr2GpuTimerAL(); - void End(Tr2RenderContextAL& renderContext); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - float GetTime(Tr2RenderContextAL& renderContext); + void Destroy(); - bool IsValid() const; + bool Begin( Tr2RenderContextAL& renderContext ); - bool operator==(const Tr2GpuTimerAL& other) const - { - return this == &other; - } + void End( Tr2RenderContextAL& renderContext ); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + float GetTime( Tr2RenderContextAL& renderContext ); - private: - CComPtr m_beginQuery; - CComPtr m_endQuery; - CComPtr m_disjointQuery; - uint64_t m_begin; - uint64_t m_end; - float m_lastTime; - enum - { - UNINITIALIZED, - READY, - BEGIN_ISSUED, - END_ISSUED, - BEGIN_RECEIVED, - } m_state; - std::string m_name; + bool IsValid() const; + bool operator==( const Tr2GpuTimerAL& other ) const + { + return this == &other; + } - }; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + CComPtr m_beginQuery; + CComPtr m_endQuery; + CComPtr m_disjointQuery; + uint64_t m_begin; + uint64_t m_end; + float m_lastTime; + enum + { + UNINITIALIZED, + READY, + BEGIN_ISSUED, + END_ISSUED, + BEGIN_RECEIVED, + } m_state; + std::string m_name; +}; } diff --git a/trinityal/dx11/Tr2OcclusionQueryALDx11.cpp b/trinityal/dx11/Tr2OcclusionQueryALDx11.cpp index a9ba9f643..50134a70a 100644 --- a/trinityal/dx11/Tr2OcclusionQueryALDx11.cpp +++ b/trinityal/dx11/Tr2OcclusionQueryALDx11.cpp @@ -2,118 +2,118 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2OcclusionQueryALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" namespace TrinityALImpl { - Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() +Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() +{ +} + +ALResult Tr2OcclusionQueryAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.m_d3dDevice11 ) { + return E_FAIL; } - ALResult Tr2OcclusionQueryAL::Create( Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); + D3D11_QUERY_DESC desc; + desc.Query = D3D11_QUERY_OCCLUSION; + desc.MiscFlags = 0; + return renderContext.m_d3dDevice11->CreateQuery( &desc, &m_query ); +} - if( !renderContext.m_d3dDevice11 ) - { - return E_FAIL; - } +// ------------------------------------------------------------- +// Description: +// Returns true if the query was successfully created. +// ------------------------------------------------------------- +bool Tr2OcclusionQueryAL::IsValid() const +{ + return m_query != nullptr; +} - D3D11_QUERY_DESC desc; - desc.Query = D3D11_QUERY_OCCLUSION; - desc.MiscFlags = 0; - return renderContext.m_d3dDevice11->CreateQuery( &desc, &m_query ); - } +void Tr2OcclusionQueryAL::Destroy() +{ + m_query = nullptr; +} - // ------------------------------------------------------------- - // Description: - // Returns true if the query was successfully created. - // ------------------------------------------------------------- - bool Tr2OcclusionQueryAL::IsValid() const +// ------------------------------------------------------------- +// Description: +// Begin a rendering query. +// ------------------------------------------------------------- +ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( m_query == nullptr ) { - return m_query != nullptr; + return E_INVALIDARG; } - - void Tr2OcclusionQueryAL::Destroy() + if( !renderContext.m_context ) { - m_query = nullptr; + return E_FAIL; } + renderContext.m_context->Begin( m_query ); + return S_OK; +} - // ------------------------------------------------------------- - // Description: - // Begin a rendering query. - // ------------------------------------------------------------- - ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) +// ------------------------------------------------------------- +// Description: +// End a rendering query. +// ------------------------------------------------------------- +ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) +{ + if( m_query == nullptr ) { - if( m_query == nullptr ) - { - return E_INVALIDARG; - } - if( !renderContext.m_context ) - { - return E_FAIL; - } - renderContext.m_context->Begin( m_query ); - return S_OK; + return E_INVALIDARG; } - - // ------------------------------------------------------------- - // Description: - // End a rendering query. - // ------------------------------------------------------------- - ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) + if( !renderContext.m_context ) { - if( m_query == nullptr ) - { - return E_INVALIDARG; - } - if( !renderContext.m_context ) - { - return E_FAIL; - } - renderContext.m_context->End( m_query ); - return S_OK; + return E_FAIL; } + renderContext.m_context->End( m_query ); + return S_OK; +} - // ------------------------------------------------------------- - // Description: - // Get the number of pixels rendering between Begin and End. - // If WaitMode is DO_NOT_WAIT this checks if the data is available and if not, returns zero. - // ------------------------------------------------------------- - ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ) +// ------------------------------------------------------------- +// Description: +// Get the number of pixels rendering between Begin and End. +// If WaitMode is DO_NOT_WAIT this checks if the data is available and if not, returns zero. +// ------------------------------------------------------------- +ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ) +{ + if( m_query == nullptr ) { - if( m_query == nullptr ) - { - return E_INVALIDARG; - } - if( !renderContext.m_context ) - { - return E_FAIL; - } - UINT64 data = 0; - HRESULT hr = renderContext.m_context->GetData( m_query, (void*)&data, sizeof( UINT64 ), waitMode == ::Tr2OcclusionQueryAL::DO_NOT_WAIT ? D3D11_ASYNC_GETDATA_DONOTFLUSH : 0 ); - if( hr == S_OK ) - { - count = static_cast( data ); - } - return hr; + return E_INVALIDARG; } - - void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + if( !renderContext.m_context ) { - description["type"] = "Tr2OcclusionQueryAL"; - description["name"] = m_name; + return E_FAIL; } - - ALResult Tr2OcclusionQueryAL::SetName( const char* name ) + UINT64 data = 0; + HRESULT hr = renderContext.m_context->GetData( m_query, (void*)&data, sizeof( UINT64 ), waitMode == ::Tr2OcclusionQueryAL::DO_NOT_WAIT ? D3D11_ASYNC_GETDATA_DONOTFLUSH : 0 ); + if( hr == S_OK ) { - m_name = name; - SetDebugName( m_query, name ); - return S_OK; + count = static_cast( data ); } + return hr; +} + +void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2OcclusionQueryAL"; + description["name"] = m_name; +} + +ALResult Tr2OcclusionQueryAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_query, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2OcclusionQueryALDx11.h b/trinityal/dx11/Tr2OcclusionQueryALDx11.h index 60839a5db..58beb8f3f 100644 --- a/trinityal/dx11/Tr2OcclusionQueryALDx11.h +++ b/trinityal/dx11/Tr2OcclusionQueryALDx11.h @@ -2,41 +2,44 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2OcclusionQueryAL.h" namespace TrinityALImpl { - // ------------------------------------------------------------- - // Description: - // Wraps the hardware specifics of running an occlusion query. - // 32bit - we do not support returning a query of > 4 gig pixels - // ------------------------------------------------------------- - class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL - { - public: - Tr2OcclusionQueryAL(); +// ------------------------------------------------------------- +// Description: +// Wraps the hardware specifics of running an occlusion query. +// 32bit - we do not support returning a query of > 4 gig pixels +// ------------------------------------------------------------- +class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL +{ +public: + Tr2OcclusionQueryAL(); - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - void Destroy(); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + void Destroy(); - ALResult Begin( Tr2RenderContextAL& renderContext ); - ALResult End( Tr2RenderContextAL& renderContext ); - ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); + ALResult Begin( Tr2RenderContextAL& renderContext ); + ALResult End( Tr2RenderContextAL& renderContext ); + ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; - Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; +private: + Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; + Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; - CComPtr m_query; - std::string m_name; - }; - } + CComPtr m_query; + std::string m_name; +}; +} #endif diff --git a/trinityal/dx11/Tr2PipelineStatsQueryALDx11.cpp b/trinityal/dx11/Tr2PipelineStatsQueryALDx11.cpp index c0407013c..580b37735 100644 --- a/trinityal/dx11/Tr2PipelineStatsQueryALDx11.cpp +++ b/trinityal/dx11/Tr2PipelineStatsQueryALDx11.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if TRINITY_PLATFORM==TRINITY_DIRECTX11 +#if TRINITY_PLATFORM == TRINITY_DIRECTX11 #include "Tr2PipelineStatsQueryALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" @@ -38,7 +38,6 @@ namespace TrinityALImpl Tr2PipelineStatsQueryAL::Tr2PipelineStatsQueryAL() { - } ALResult Tr2PipelineStatsQueryAL::Create( Tr2PrimaryRenderContextAL& renderContext ) diff --git a/trinityal/dx11/Tr2PrimaryRenderContextDx11.cpp b/trinityal/dx11/Tr2PrimaryRenderContextDx11.cpp index 4ce498ce8..123c291b2 100644 --- a/trinityal/dx11/Tr2PrimaryRenderContextDx11.cpp +++ b/trinityal/dx11/Tr2PrimaryRenderContextDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2PrimaryRenderContextDx11.h" #include "ITr2RenderContextEvents.h" @@ -31,17 +31,18 @@ CCP_STATS_DECLARE( dx11HSInvocations, "Trinity/AL/Pipeline/HSInvocations", false CCP_STATS_DECLARE( dx11DSInvocations, "Trinity/AL/Pipeline/DSInvocations", false, CST_COUNTER_HIGH, "Number of times a domain shader was invoked" ); CCP_STATS_DECLARE( gpuFrameTime, "Trinity/AL/GpuFrameTime", false, CST_TIME, "Time spent on GPU processing a frame" ); -namespace Tr2RenderContextImpl { - struct NullContext; - extern NullContext s_nullContext; +namespace Tr2RenderContextImpl +{ +struct NullContext; +extern NullContext s_nullContext; } -Tr2PrimaryRenderContextAL::Tr2PrimaryRenderContextAL() - : m_usingEXDevice( false ), +Tr2PrimaryRenderContextAL::Tr2PrimaryRenderContextAL() : + m_usingEXDevice( false ), m_recodingFrame( 1 ), m_renderedFrame( 0 ), - m_vsyncInterval( 0 ), - m_adapterVendorId( 0 ), + m_vsyncInterval( 0 ), + m_adapterVendorId( 0 ), m_deviceStatisticsQueryEmpty( false ), m_upscalingTechnique( nullptr ) { @@ -80,13 +81,13 @@ void Tr2PrimaryRenderContextAL::Destroy() m_defaultBackBuffer.m_texture->Destroy(); - m_usingEXDevice = false; - m_deviceStatistics = nullptr; + m_usingEXDevice = false; + m_deviceStatistics = nullptr; - m_d3dDevice11 = nullptr; - m_swapChain = nullptr; - m_dxgiFactory = nullptr; - m_dxgiOutput = nullptr; + m_d3dDevice11 = nullptr; + m_swapChain = nullptr; + m_dxgiFactory = nullptr; + m_dxgiOutput = nullptr; //m_context = nullptr; if( m_aftermathContext ) { @@ -94,7 +95,7 @@ void Tr2PrimaryRenderContextAL::Destroy() m_aftermathContext = nullptr; } m_context.Attach( (ID3D11DeviceContext*)&Tr2RenderContextImpl::s_nullContext ); - + m_zeroVertexBuffer = Tr2BufferAL(); m_adapterVendorId = 0; @@ -103,54 +104,55 @@ void Tr2PrimaryRenderContextAL::Destroy() m_renderedFrame = 0; } -namespace { - DXGI_FORMAT SafeConvertD3DBackBufferFormat( PixelFormat bbFormat ) +namespace +{ +DXGI_FORMAT SafeConvertD3DBackBufferFormat( PixelFormat bbFormat ) +{ + DXGI_FORMAT out = static_cast( bbFormat ); + if( out == DXGI_FORMAT_B8G8R8X8_UNORM ) { - DXGI_FORMAT out = static_cast( bbFormat ); - if( out == DXGI_FORMAT_B8G8R8X8_UNORM ) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - if( out == PIXEL_FORMAT_UNKNOWN ) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - return out; + return DXGI_FORMAT_B8G8R8A8_UNORM; } + if( out == PIXEL_FORMAT_UNKNOWN ) + { + return DXGI_FORMAT_B8G8R8A8_UNORM; + } + return out; +} } -ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, - Tr2WindowHandle hFocusWindow, - const Tr2PresentParametersAL& pp ) +ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, + Tr2WindowHandle hFocusWindow, + const Tr2PresentParametersAL& pp ) { - const bool isWindowless = (hFocusWindow == 0) && pp.software; + const bool isWindowless = ( hFocusWindow == 0 ) && pp.software; DXGI_SWAP_CHAIN_DESC sd; memset( &sd, 0, sizeof( sd ) ); - sd.BufferCount = 1; + sd.BufferCount = 1; sd.OutputWindow = Tr2WindowHandle( pp.outputWindow ); if( !sd.OutputWindow ) { sd.OutputWindow = hFocusWindow; } - sd.Windowed = true; - sd.SwapEffect = DXGI_SWAP_EFFECT( pp.swapEffect ); - sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - + sd.Windowed = true; + sd.SwapEffect = DXGI_SWAP_EFFECT( pp.swapEffect ); + sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + sd.SampleDesc.Count = std::max( pp.msaaType, 1u ); sd.SampleDesc.Quality = pp.msaaQuality; - - sd.BufferDesc.Width = pp.mode.width; + + sd.BufferDesc.Width = pp.mode.width; sd.BufferDesc.Height = pp.mode.height; sd.BufferDesc.Format = SafeConvertD3DBackBufferFormat( pp.mode.format ); sd.BufferDesc.RefreshRate.Numerator = sd.BufferDesc.RefreshRate.Denominator = 0; sd.BufferDesc.Scaling = DXGI_MODE_SCALING( pp.mode.scaling ); sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER( pp.mode.scanlineOrdering ); - - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - + + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + uint32_t dwFlags = 0; if( g_requestDeviceDebugLayer ) @@ -162,9 +164,9 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, D3D_FEATURE_LEVEL levelSupported; CComPtr adapterPtr; - if( !isWindowless ) + if( !isWindowless ) { - + if( FAILED( Tr2VideoAdapterInfo::GetVideoAdapterDX11( adapter, &adapterPtr, &m_dxgiOutput ) ) ) { return E_FAIL; @@ -184,9 +186,9 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, GFSDK_Aftermath_ReleaseContextHandle( reinterpret_cast( m_aftermathContext ) ); m_aftermathContext = nullptr; } - + m_context.Release(); - + D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_UNKNOWN; if( pp.software ) { @@ -198,8 +200,8 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, CCP_AL_LOG( "DX11: driverType: %i", driverType ); HRESULT HR = 0; - - if( isWindowless ) + + if( isWindowless ) { CCP_AL_LOG( "DX11: Creating device without a swap chain" ); @@ -214,24 +216,26 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, &m_d3dDevice11, &levelSupported, &m_context ); - } else { + } + else + { HR = D3D11CreateDeviceAndSwapChain( - pp.software ? NULL : adapterPtr, - driverType, - 0, - dwFlags, - &levelWanted, - 1, - D3D11_SDK_VERSION, - &sd, - &m_swapChain, - &m_d3dDevice11, - &levelSupported, - &m_context ); - } - - - if( SUCCEEDED( HR ) ) + pp.software ? NULL : adapterPtr, + driverType, + 0, + dwFlags, + &levelWanted, + 1, + D3D11_SDK_VERSION, + &sd, + &m_swapChain, + &m_d3dDevice11, + &levelSupported, + &m_context ); + } + + + if( SUCCEEDED( HR ) ) { if( m_upscalingTechnique ) { @@ -239,10 +243,10 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, } CCP_AL_LOG( "DX11: device created succesfully" ); } - else - { - m_swapChain = nullptr; - m_d3dDevice11 = nullptr; + else + { + m_swapChain = nullptr; + m_d3dDevice11 = nullptr; m_context.Attach( (ID3D11DeviceContext*)&Tr2RenderContextImpl::s_nullContext ); if( g_requestDeviceDebugLayer ) @@ -250,7 +254,7 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, // Try once again without DEVICE_DEBUG flag for people without DirectX SDK dwFlags &= ~D3D11_CREATE_DEVICE_DEBUG; - if( isWindowless ) + if( isWindowless ) { HR = D3D11CreateDevice( NULL, @@ -263,20 +267,22 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, &m_d3dDevice11, &levelSupported, &m_context ); - } else { + } + else + { HR = D3D11CreateDeviceAndSwapChain( - pp.software ? NULL : adapterPtr, - driverType, - 0, - dwFlags, - &levelWanted, - 1, - D3D11_SDK_VERSION, - &sd, - &m_swapChain, - &m_d3dDevice11, - &levelSupported, - &m_context ); + pp.software ? NULL : adapterPtr, + driverType, + 0, + dwFlags, + &levelWanted, + 1, + D3D11_SDK_VERSION, + &sd, + &m_swapChain, + &m_d3dDevice11, + &levelSupported, + &m_context ); } if( SUCCEEDED( HR ) ) @@ -298,12 +304,12 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, } } - if( !m_d3dDevice11 || !m_context || (!isWindowless && !m_swapChain) ) + if( !m_d3dDevice11 || !m_context || ( !isWindowless && !m_swapChain ) ) { CCP_AL_LOGERR( "Failed to D3D11CreateDeviceAndSwapChain" ); - m_swapChain = nullptr; - m_d3dDevice11 = nullptr; - m_dxgiOutput = nullptr; + m_swapChain = nullptr; + m_d3dDevice11 = nullptr; + m_dxgiOutput = nullptr; m_context.Attach( (ID3D11DeviceContext*)&Tr2RenderContextImpl::s_nullContext ); return E_FAIL; } @@ -354,21 +360,21 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, } // Disable Windows support for alt-enter fullscreen - if( adapterPtr ) + if( adapterPtr ) { - adapterPtr->GetParent(__uuidof(IDXGIFactory), (void **)&m_dxgiFactory); + adapterPtr->GetParent( __uuidof( IDXGIFactory ), (void**)&m_dxgiFactory ); if( m_dxgiFactory ) { m_dxgiFactory->MakeWindowAssociation( Tr2WindowHandle( pp.outputWindow ), DXGI_MWA_NO_WINDOW_CHANGES ); } } - + if( !isWindowless && !pp.windowed ) { CR( m_swapChain->ResizeTarget( &sd.BufferDesc ) ); - CR( m_swapChain->ResizeBuffers( sd.BufferCount, + CR( m_swapChain->ResizeBuffers( sd.BufferCount, sd.BufferDesc.Width, sd.BufferDesc.Height, sd.BufferDesc.Format, @@ -386,11 +392,13 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, } uint32_t zero = 0; - m_context->IASetVertexBuffers( VERTEX_BUFFER_ZERO_STREAM_RESERVED, - 1, &m_zeroVertexBuffer.m_buffer->m_buffer, - &zero, &zero ); + m_context->IASetVertexBuffers( VERTEX_BUFFER_ZERO_STREAM_RESERVED, + 1, + &m_zeroVertexBuffer.m_buffer->m_buffer, + &zero, + &zero ); - if( !isWindowless ) + if( !isWindowless ) { CR_RETURN_HR( CreateBackBuffers( pp ) ); } @@ -401,12 +409,11 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, CComQIPtr queue( m_d3dDevice11 ); if( queue ) { - D3D11_MESSAGE_SEVERITY severity[] = - { + D3D11_MESSAGE_SEVERITY severity[] = { D3D11_MESSAGE_SEVERITY_CORRUPTION, D3D11_MESSAGE_SEVERITY_ERROR, }; - + D3D11_INFO_QUEUE_FILTER filter; memset( &filter, 0, sizeof( filter ) ); filter.AllowList.NumSeverities = 2; @@ -429,7 +436,7 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, { m_events->OnContextCreated( *this ); } - + return S_OK; } @@ -472,11 +479,11 @@ ALResult Tr2PrimaryRenderContextAL::SetPresentParameters( unsigned adapter, cons m_defaultBackBuffer.m_texture->Destroy(); - CR( m_swapChain->ResizeBuffers( presentationParameters.backBufferCount, - presentationParameters.mode.width, - presentationParameters.mode.height, - fmt, - DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ) ); + CR( m_swapChain->ResizeBuffers( presentationParameters.backBufferCount, + presentationParameters.mode.width, + presentationParameters.mode.height, + fmt, + DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ) ); if( !presentationParameters.windowed ) { @@ -505,9 +512,8 @@ ALResult Tr2PrimaryRenderContextAL::CreateBackBuffers( const Tr2PresentParameter m_defaultBackBuffer.m_texture->Destroy(); CComPtr pBackBuffer; - HRESULT HR = m_swapChain ? m_swapChain->GetBuffer( 0, __uuidof (ID3D11Texture2D), (LPVOID*)&pBackBuffer ) - : E_FAIL; - if( FAILED(HR) ) + HRESULT HR = m_swapChain ? m_swapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&pBackBuffer ) : E_FAIL; + if( FAILED( HR ) ) { CCP_AL_LOGERR( "Failed to GetBuffer, %d", HR ); return HR; @@ -523,16 +529,16 @@ ALResult Tr2PrimaryRenderContextAL::CreateBackBuffers( const Tr2PresentParameter { m_memory.Set( Tr2MemoryCounterAL::TEXTURE, m_defaultBackBuffer.GetDesc(), m_defaultBackBuffer.GetMsaaDesc() ); } - + D3D11_VIEWPORT viewport; - ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT)); + ZeroMemory( &viewport, sizeof( D3D11_VIEWPORT ) ); - viewport.TopLeftX = 0; - viewport.TopLeftY = 0; - viewport.Width = (float)presentationParameters.mode.width; - viewport.Height = (float)presentationParameters.mode.height; - viewport.MinDepth = 0; - viewport.MaxDepth = 1.0f; + viewport.TopLeftX = 0; + viewport.TopLeftY = 0; + viewport.Width = (float)presentationParameters.mode.width; + viewport.Height = (float)presentationParameters.mode.height; + viewport.MinDepth = 0; + viewport.MaxDepth = 1.0f; m_context->RSSetViewports( 1, &viewport ); @@ -576,7 +582,7 @@ ALResult Tr2PrimaryRenderContextAL::Present() } D3D11_QUERY_DATA_PIPELINE_STATISTICS GPUProbeStats; - if( m_deviceStatisticsQueryEmpty && + if( m_deviceStatisticsQueryEmpty && m_context->GetData( m_deviceStatistics, &GPUProbeStats, sizeof( GPUProbeStats ), 0 ) == S_OK ) { CCP_STATS_SET( dx11IAVertices, GPUProbeStats.IAVertices ); @@ -626,7 +632,9 @@ ALResult Tr2PrimaryRenderContextAL::Present() if( m_swapChain ) { m_swapChain->Present( m_vsyncInterval, 0 ); - } else { + } + else + { m_context->Flush(); } @@ -840,7 +848,7 @@ std::vector> Tr2PrimaryRen supportedTechniques.push_back( { technique, allSettings, tech->SupportsFrameGeneration() } ); } if( tech ) - { + { delete tech; tech = nullptr; } @@ -864,4 +872,4 @@ uint64_t Tr2PrimaryRenderContextAL::GetRenderedFrameNumber() const } -#endif //DX11? +#endif //DX11? diff --git a/trinityal/dx11/Tr2PrimaryRenderContextDx11.h b/trinityal/dx11/Tr2PrimaryRenderContextDx11.h index 7385dd6fe..6f0a5ba0a 100644 --- a/trinityal/dx11/Tr2PrimaryRenderContextDx11.h +++ b/trinityal/dx11/Tr2PrimaryRenderContextDx11.h @@ -17,24 +17,24 @@ struct Tr2PresentParametersAL; -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) class Tr2PrimaryRenderContextAL : public Tr2RenderContextAL { public: Tr2PrimaryRenderContextAL(); ~Tr2PrimaryRenderContextAL(); - void Destroy(); + void Destroy(); - ALResult CreateDevice( - uint32_t Adapter, - Tr2WindowHandle hFocusWindow, + ALResult CreateDevice( + uint32_t Adapter, + Tr2WindowHandle hFocusWindow, const Tr2PresentParametersAL& pPresentationParameters ); ALResult SetPresentParameters( unsigned adapter, const Tr2PresentParametersAL& pPresentationParameters ); const Tr2CapsAL& GetCaps() const; - + ALResult Present(); bool IsValid(); @@ -48,7 +48,7 @@ class Tr2PrimaryRenderContextAL : public Tr2RenderContextAL Tr2UpscalingAL::Result EnableUpscaling( Tr2UpscalingAL::Technique tech, Tr2UpscalingAL::Setting setting, bool framegeneration, uint32_t adapter ); Tr2UpscalingContextAL* GetUpscalingContext( uint32_t upscalingContextID ) const; - Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params , uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID); + Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID ); void DeleteUpscalingContext( uint32_t contextID ); std::vector> GetSupportedUpscalingTechniques( uint32_t adapter ); void GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, Tr2UpscalingAL::Setting& setting, bool& framegeneration, bool& temporal ) const; @@ -59,21 +59,21 @@ class Tr2PrimaryRenderContextAL : public Tr2RenderContextAL public: bool m_usingEXDevice; - CComPtr m_d3dDevice11; + CComPtr m_d3dDevice11; + + CComPtr m_swapChain; + CComPtr m_dxgiFactory; + CComPtr m_dxgiOutput; - CComPtr m_swapChain; - CComPtr m_dxgiFactory; - CComPtr m_dxgiOutput; - Tr2TextureAL m_defaultBackBuffer; - + private: ALResult CreateBackBuffers( const Tr2PresentParametersAL& presentationParameters ); uint64_t m_recodingFrame; uint64_t m_renderedFrame; - uint32_t m_vsyncInterval; + uint32_t m_vsyncInterval; // Device statistics //CComPtr m_deviceStatistics; diff --git a/trinityal/dx11/Tr2RenderContextDx11.cpp b/trinityal/dx11/Tr2RenderContextDx11.cpp index 7db4fb675..09fa4ea73 100644 --- a/trinityal/dx11/Tr2RenderContextDx11.cpp +++ b/trinityal/dx11/Tr2RenderContextDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2RenderContextDx11.h" #include "ITr2RenderContextEvents.h" @@ -20,17 +20,18 @@ #include "Tr2ConstantBufferALDx11.h" -CCP_STATS_DECLARE( primitiveCount , "Trinity/AL/primitiveCount" , true, CST_COUNTER_HIGH, "Primitive count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( vertexCount , "Trinity/AL/vertexCount" , true, CST_COUNTER_HIGH, "Vertex count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( sceneDrawcallCount , "Trinity/AL/sceneDrawcallCount" , true, CST_COUNTER_LOW, "Number of DrawPrimitive calls." ); +CCP_STATS_DECLARE( primitiveCount, "Trinity/AL/primitiveCount", true, CST_COUNTER_HIGH, "Primitive count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( vertexCount, "Trinity/AL/vertexCount", true, CST_COUNTER_HIGH, "Vertex count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( sceneDrawcallCount, "Trinity/AL/sceneDrawcallCount", true, CST_COUNTER_LOW, "Number of DrawPrimitive calls." ); -CCP_STATS_DECLARE( cbCacheHit , "Trinity/AL/cbCacheHit" , true, CST_COUNTER_HIGH, "Number of cache hits for dynamic constant buffers." ); -CCP_STATS_DECLARE( cbCacheMiss , "Trinity/AL/cbCacheMiss" , true, CST_COUNTER_HIGH, "Number of cache misses for dynamic constant buffers." ); +CCP_STATS_DECLARE( cbCacheHit, "Trinity/AL/cbCacheHit", true, CST_COUNTER_HIGH, "Number of cache hits for dynamic constant buffers." ); +CCP_STATS_DECLARE( cbCacheMiss, "Trinity/AL/cbCacheMiss", true, CST_COUNTER_HIGH, "Number of cache misses for dynamic constant buffers." ); using namespace Tr2RenderContextEnum; -namespace { +namespace +{ Tr2PrimaryRenderContextAL*& GetPrimaryRenderContextPointer() { @@ -38,513 +39,737 @@ Tr2PrimaryRenderContextAL*& GetPrimaryRenderContextPointer() return primaryRenderContext; } - const D3D11_RENDER_TARGET_BLEND_DESC defaultBlend = - { - FALSE, - D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, - D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, - D3D11_COLOR_WRITE_ENABLE_ALL - }; +const D3D11_RENDER_TARGET_BLEND_DESC defaultBlend = { + FALSE, + D3D11_BLEND_ONE, + D3D11_BLEND_ZERO, + D3D11_BLEND_OP_ADD, + D3D11_BLEND_ONE, + D3D11_BLEND_ZERO, + D3D11_BLEND_OP_ADD, + D3D11_COLOR_WRITE_ENABLE_ALL +}; + +const D3D11_DEPTH_STENCILOP_DESC defaultStencilOp = { + D3D11_STENCIL_OP_KEEP, + D3D11_STENCIL_OP_KEEP, + D3D11_STENCIL_OP_KEEP, + D3D11_COMPARISON_ALWAYS +}; + +const D3D11_DEPTH_STENCIL_DESC defaultDepthStencil = { + true, + D3D11_DEPTH_WRITE_MASK_ALL, + D3D11_COMPARISON_LESS, + false, + D3D11_DEFAULT_STENCIL_READ_MASK, + D3D11_DEFAULT_STENCIL_WRITE_MASK, + defaultStencilOp, + defaultStencilOp +}; + +const D3D11_RASTERIZER_DESC defaultRasterizer = { + D3D11_FILL_SOLID, + D3D11_CULL_BACK, + false, + 0, + 0, + 0, + true, + false, + false, + false +}; +} - const D3D11_DEPTH_STENCILOP_DESC defaultStencilOp = +namespace Tr2RenderContextImpl +{ + +#pragma warning( disable : 4100 ) +struct NullContext : ID3D11DeviceContext +{ + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + __RPC__deref_out void __RPC_FAR* __RPC_FAR* ppvObject ) { - D3D11_STENCIL_OP_KEEP, - D3D11_STENCIL_OP_KEEP, - D3D11_STENCIL_OP_KEEP, - D3D11_COMPARISON_ALWAYS - }; + return E_FAIL; + } + virtual ULONG STDMETHODCALLTYPE AddRef( void ) + { + return S_OK; + } + virtual ULONG STDMETHODCALLTYPE Release( void ) + { + return S_OK; + } + virtual void STDMETHODCALLTYPE GetDevice( ID3D11Device** ppDevice ) + { + } - const D3D11_DEPTH_STENCIL_DESC defaultDepthStencil = + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + REFGUID guid, + uint32_t* pDataSize, + __out_bcount_opt( *pDataSize ) void* pData ) { - true, - D3D11_DEPTH_WRITE_MASK_ALL, - D3D11_COMPARISON_LESS, - false, - D3D11_DEFAULT_STENCIL_READ_MASK, - D3D11_DEFAULT_STENCIL_WRITE_MASK, - defaultStencilOp, - defaultStencilOp - }; + return S_OK; + } - const D3D11_RASTERIZER_DESC defaultRasterizer = + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + REFGUID guid, + uint32_t DataSize, + const void* pData ) { - D3D11_FILL_SOLID, - D3D11_CULL_BACK, - false, - 0, - 0, - 0, - true, - false, - false, - false - }; + return S_OK; + } + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + /* [annotation] */ + REFGUID guid, + /* [annotation] */ + __in_opt const IUnknown* pData ) + { + return S_OK; + } + virtual void STDMETHODCALLTYPE VSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE PSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE PSSetShader( + __in_opt ID3D11PixelShader* pPixelShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE PSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE VSSetShader( + __in_opt ID3D11VertexShader* pVertexShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE DrawIndexed( + uint32_t IndexCount, + uint32_t StartIndexLocation, + INT BaseVertexLocation ) + { + } + virtual void STDMETHODCALLTYPE Draw( + uint32_t VertexCount, + uint32_t StartVertexLocation ) + { + } + virtual HRESULT STDMETHODCALLTYPE Map( + ID3D11Resource* pResource, + uint32_t Subresource, + D3D11_MAP MapType, + uint32_t MapFlags, + D3D11_MAPPED_SUBRESOURCE* pMappedResource ) + { + return E_FAIL; + } + virtual void STDMETHODCALLTYPE Unmap( + ID3D11Resource* pResource, + uint32_t Subresource ) + { + } + virtual void STDMETHODCALLTYPE PSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE IASetInputLayout( + __in_opt ID3D11InputLayout* pInputLayout ) + { + } + virtual void STDMETHODCALLTYPE IASetVertexBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppVertexBuffers, + const uint32_t* pStrides, + const uint32_t* pOffsets ) + { + } + virtual void STDMETHODCALLTYPE IASetIndexBuffer( + __in_opt ID3D11Buffer* pIndexBuffer, + DXGI_FORMAT Format, + uint32_t Offset ) + { + } + virtual void STDMETHODCALLTYPE DrawIndexedInstanced( + uint32_t IndexCountPerInstance, + uint32_t InstanceCount, + uint32_t StartIndexLocation, + INT BaseVertexLocation, + uint32_t StartInstanceLocation ) + { + } + virtual void STDMETHODCALLTYPE DrawInstanced( + uint32_t VertexCountPerInstance, + uint32_t InstanceCount, + uint32_t StartVertexLocation, + uint32_t StartInstanceLocation ) + { + } + virtual void STDMETHODCALLTYPE GSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE GSSetShader( + __in_opt ID3D11GeometryShader* pShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( + D3D11_PRIMITIVE_TOPOLOGY Topology ) + { + } + virtual void STDMETHODCALLTYPE VSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE VSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE Begin( + ID3D11Asynchronous* pAsync ) + { + } + virtual void STDMETHODCALLTYPE End( + ID3D11Asynchronous* pAsync ) + { + } + virtual HRESULT STDMETHODCALLTYPE GetData( + ID3D11Asynchronous* pAsync, + __out_bcount_opt( DataSize ) void* pData, + uint32_t DataSize, + uint32_t GetDataFlags ) + { + return E_FAIL; + } + virtual void STDMETHODCALLTYPE SetPredication( + __in_opt ID3D11Predicate* pPredicate, + BOOL PredicateValue ) + { + } + virtual void STDMETHODCALLTYPE GSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE GSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE OMSetRenderTargets( + uint32_t NumViews, + ID3D11RenderTargetView* const* ppRenderTargetViews, + __in_opt ID3D11DepthStencilView* pDepthStencilView ) + { + } + virtual void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews( + uint32_t NumRTVs, + ID3D11RenderTargetView* const* ppRenderTargetViews, + __in_opt ID3D11DepthStencilView* pDepthStencilView, + uint32_t UAVStartSlot, + uint32_t NumUAVs, + ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, + const uint32_t* pUAVInitialCounts ) + { + } + virtual void STDMETHODCALLTYPE OMSetBlendState( + __in_opt ID3D11BlendState* pBlendState, + __in_opt const FLOAT BlendFactor[4], + uint32_t SampleMask ) + { + } + virtual void STDMETHODCALLTYPE OMSetDepthStencilState( + __in_opt ID3D11DepthStencilState* pDepthStencilState, + uint32_t StencilRef ) + { + } + virtual void STDMETHODCALLTYPE SOSetTargets( + uint32_t NumBuffers, + ID3D11Buffer* const* ppSOTargets, + const uint32_t* pOffsets ) + { + } + virtual void STDMETHODCALLTYPE DrawAuto( void ) + { + } + virtual void STDMETHODCALLTYPE DrawIndexedInstancedIndirect( + ID3D11Buffer* pBufferForArgs, + uint32_t AlignedByteOffsetForArgs ) + { + } + virtual void STDMETHODCALLTYPE DrawInstancedIndirect( + ID3D11Buffer* pBufferForArgs, + uint32_t AlignedByteOffsetForArgs ) + { + } + virtual void STDMETHODCALLTYPE Dispatch( + uint32_t ThreadGroupCountX, + uint32_t ThreadGroupCountY, + uint32_t ThreadGroupCountZ ) + { + } + virtual void STDMETHODCALLTYPE DispatchIndirect( + ID3D11Buffer* pBufferForArgs, + uint32_t AlignedByteOffsetForArgs ) + { + } + virtual void STDMETHODCALLTYPE RSSetState( + __in_opt ID3D11RasterizerState* pRasterizerState ) + { + } + virtual void STDMETHODCALLTYPE RSSetViewports( + uint32_t NumViewports, + const D3D11_VIEWPORT* pViewports ) + { + } + virtual void STDMETHODCALLTYPE RSSetScissorRects( + uint32_t NumRects, + const D3D11_RECT* pRects ) + { + } + virtual void STDMETHODCALLTYPE CopySubresourceRegion( + ID3D11Resource* pDstResource, + uint32_t DstSubresource, + uint32_t DstX, + uint32_t DstY, + uint32_t DstZ, + ID3D11Resource* pSrcResource, + uint32_t SrcSubresource, + __in_opt const D3D11_BOX* pSrcBox ) + { + } + virtual void STDMETHODCALLTYPE CopyResource( + ID3D11Resource* pDstResource, + ID3D11Resource* pSrcResource ) + { + } + virtual void STDMETHODCALLTYPE UpdateSubresource( + ID3D11Resource* pDstResource, + uint32_t DstSubresource, + __in_opt const D3D11_BOX* pDstBox, + const void* pSrcData, + uint32_t SrcRowPitch, + uint32_t SrcDepthPitch ) + { + } + virtual void STDMETHODCALLTYPE CopyStructureCount( + ID3D11Buffer* pDstBuffer, + uint32_t DstAlignedByteOffset, + ID3D11UnorderedAccessView* pSrcView ) + { + } + virtual void STDMETHODCALLTYPE ClearRenderTargetView( + ID3D11RenderTargetView* pRenderTargetView, + const FLOAT ColorRGBA[4] ) + { + } + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( + ID3D11UnorderedAccessView* pUnorderedAccessView, + const uint32_t Values[4] ) + { + } + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( + ID3D11UnorderedAccessView* pUnorderedAccessView, + const FLOAT Values[4] ) + { + } + virtual void STDMETHODCALLTYPE ClearDepthStencilView( + ID3D11DepthStencilView* pDepthStencilView, + uint32_t ClearFlags, + FLOAT Depth, + UINT8 Stencil ) + { + } + virtual void STDMETHODCALLTYPE GenerateMips( + ID3D11ShaderResourceView* pShaderResourceView ) + { + } + virtual void STDMETHODCALLTYPE SetResourceMinLOD( + ID3D11Resource* pResource, + FLOAT MinLOD ) + { + } + virtual FLOAT STDMETHODCALLTYPE GetResourceMinLOD( + ID3D11Resource* pResource ) + { + return 0; + } + virtual void STDMETHODCALLTYPE ResolveSubresource( + ID3D11Resource* pDstResource, + uint32_t DstSubresource, + ID3D11Resource* pSrcResource, + uint32_t SrcSubresource, + DXGI_FORMAT Format ) + { + } + virtual void STDMETHODCALLTYPE ExecuteCommandList( + ID3D11CommandList* pCommandList, + BOOL RestoreContextState ) + { + } + virtual void STDMETHODCALLTYPE HSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE HSSetShader( + __in_opt ID3D11HullShader* pHullShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE HSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE HSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE DSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE DSSetShader( + __in_opt ID3D11DomainShader* pDomainShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE DSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE DSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE CSSetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView* const* ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE CSSetUnorderedAccessViews( + uint32_t StartSlot, + uint32_t NumUAVs, + ID3D11UnorderedAccessView* const* ppUnorderedAccessViews, + const uint32_t* pUAVInitialCounts ) + { + } + virtual void STDMETHODCALLTYPE CSSetShader( + __in_opt ID3D11ComputeShader* pComputeShader, + ID3D11ClassInstance* const* ppClassInstances, + uint32_t NumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE CSSetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState* const* ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE CSSetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer* const* ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE VSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE PSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE PSGetShader( + ID3D11PixelShader** ppPixelShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE PSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE VSGetShader( + ID3D11VertexShader** ppVertexShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE PSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE IAGetInputLayout( + ID3D11InputLayout** ppInputLayout ) + { + } + virtual void STDMETHODCALLTYPE IAGetVertexBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppVertexBuffers, + uint32_t* pStrides, + uint32_t* pOffsets ) + { + } + virtual void STDMETHODCALLTYPE IAGetIndexBuffer( + ID3D11Buffer** pIndexBuffer, + DXGI_FORMAT* Format, + uint32_t* Offset ) + { + } + virtual void STDMETHODCALLTYPE GSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE GSGetShader( + ID3D11GeometryShader** ppGeometryShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( + D3D11_PRIMITIVE_TOPOLOGY* pTopology ) + { + } + virtual void STDMETHODCALLTYPE VSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE VSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE GetPredication( + ID3D11Predicate** ppPredicate, + BOOL* pPredicateValue ) + { + } + virtual void STDMETHODCALLTYPE GSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE GSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE OMGetRenderTargets( + uint32_t NumViews, + ID3D11RenderTargetView** ppRenderTargetViews, + ID3D11DepthStencilView** ppDepthStencilView ) + { + } + virtual void STDMETHODCALLTYPE OMGetRenderTargetsAndUnorderedAccessViews( + uint32_t NumRTVs, + ID3D11RenderTargetView** ppRenderTargetViews, + ID3D11DepthStencilView** ppDepthStencilView, + uint32_t UAVStartSlot, + uint32_t NumUAVs, + ID3D11UnorderedAccessView** ppUnorderedAccessViews ) + { + } + virtual void STDMETHODCALLTYPE OMGetBlendState( + ID3D11BlendState** ppBlendState, + FLOAT BlendFactor[4], + uint32_t* pSampleMask ) + { + } + virtual void STDMETHODCALLTYPE OMGetDepthStencilState( + ID3D11DepthStencilState** ppDepthStencilState, + uint32_t* pStencilRef ) + { + } + virtual void STDMETHODCALLTYPE SOGetTargets( + uint32_t NumBuffers, + ID3D11Buffer** ppSOTargets ) + { + } + virtual void STDMETHODCALLTYPE RSGetState( + ID3D11RasterizerState** ppRasterizerState ) + { + } + virtual void STDMETHODCALLTYPE RSGetViewports( + uint32_t* pNumViewports, + D3D11_VIEWPORT* pViewports ) + { + } + virtual void STDMETHODCALLTYPE RSGetScissorRects( + uint32_t* pNumRects, + D3D11_RECT* pRects ) + { + } + virtual void STDMETHODCALLTYPE HSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE HSGetShader( + ID3D11HullShader** ppHullShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE HSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE HSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE DSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE DSGetShader( + ID3D11DomainShader** ppDomainShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE DSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE DSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE CSGetShaderResources( + uint32_t StartSlot, + uint32_t NumViews, + ID3D11ShaderResourceView** ppShaderResourceViews ) + { + } + virtual void STDMETHODCALLTYPE CSGetUnorderedAccessViews( + uint32_t StartSlot, + uint32_t NumUAVs, + ID3D11UnorderedAccessView** ppUnorderedAccessViews ) + { + } + virtual void STDMETHODCALLTYPE CSGetShader( + ID3D11ComputeShader** ppComputeShader, + ID3D11ClassInstance** ppClassInstances, + uint32_t* pNumClassInstances ) + { + } + virtual void STDMETHODCALLTYPE CSGetSamplers( + uint32_t StartSlot, + uint32_t NumSamplers, + ID3D11SamplerState** ppSamplers ) + { + } + virtual void STDMETHODCALLTYPE CSGetConstantBuffers( + uint32_t StartSlot, + uint32_t NumBuffers, + ID3D11Buffer** ppConstantBuffers ) + { + } + virtual void STDMETHODCALLTYPE ClearState( void ) + { + } + virtual void STDMETHODCALLTYPE Flush( void ) + { + } + virtual D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType( void ) + { + return D3D11_DEVICE_CONTEXT_IMMEDIATE; + } + virtual uint32_t STDMETHODCALLTYPE GetContextFlags( void ) + { + return 0; + } + virtual HRESULT STDMETHODCALLTYPE FinishCommandList( + BOOL RestoreDeferredContextState, + ID3D11CommandList** ppCommandList ) + { + return E_FAIL; + } +} s_nullContext; + } +#pragma warning( default : 4100 ) -namespace Tr2RenderContextImpl { - -#pragma warning( disable: 4100 ) - struct NullContext : ID3D11DeviceContext - { - virtual HRESULT STDMETHODCALLTYPE QueryInterface( - REFIID riid, - __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject) { return E_FAIL; } - virtual ULONG STDMETHODCALLTYPE AddRef( void) { return S_OK; } - virtual ULONG STDMETHODCALLTYPE Release( void) { return S_OK; } - virtual void STDMETHODCALLTYPE GetDevice( ID3D11Device **ppDevice) {} - - virtual HRESULT STDMETHODCALLTYPE GetPrivateData( - REFGUID guid, - uint32_t *pDataSize, - __out_bcount_opt( *pDataSize ) void *pData) - { return S_OK; } - - virtual HRESULT STDMETHODCALLTYPE SetPrivateData( - REFGUID guid, - uint32_t DataSize, - const void *pData) - { return S_OK; } - - virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( - /* [annotation] */ - REFGUID guid, - /* [annotation] */ - __in_opt const IUnknown *pData) - { return S_OK; } - virtual void STDMETHODCALLTYPE VSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE PSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE PSSetShader( - __in_opt ID3D11PixelShader *pPixelShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE PSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE VSSetShader( - __in_opt ID3D11VertexShader *pVertexShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE DrawIndexed( - uint32_t IndexCount, - uint32_t StartIndexLocation, - INT BaseVertexLocation) {} - virtual void STDMETHODCALLTYPE Draw( - uint32_t VertexCount, - uint32_t StartVertexLocation) {} - virtual HRESULT STDMETHODCALLTYPE Map( - ID3D11Resource *pResource, - uint32_t Subresource, - D3D11_MAP MapType, - uint32_t MapFlags, - D3D11_MAPPED_SUBRESOURCE *pMappedResource){ return E_FAIL; } - virtual void STDMETHODCALLTYPE Unmap( - ID3D11Resource *pResource, - uint32_t Subresource) {} - virtual void STDMETHODCALLTYPE PSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE IASetInputLayout( - __in_opt ID3D11InputLayout *pInputLayout) {} - virtual void STDMETHODCALLTYPE IASetVertexBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppVertexBuffers, - const uint32_t *pStrides, - const uint32_t *pOffsets) {} - virtual void STDMETHODCALLTYPE IASetIndexBuffer( - __in_opt ID3D11Buffer *pIndexBuffer, - DXGI_FORMAT Format, - uint32_t Offset) {} - virtual void STDMETHODCALLTYPE DrawIndexedInstanced( - uint32_t IndexCountPerInstance, - uint32_t InstanceCount, - uint32_t StartIndexLocation, - INT BaseVertexLocation, - uint32_t StartInstanceLocation) {} - virtual void STDMETHODCALLTYPE DrawInstanced( - uint32_t VertexCountPerInstance, - uint32_t InstanceCount, - uint32_t StartVertexLocation, - uint32_t StartInstanceLocation) {} - virtual void STDMETHODCALLTYPE GSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE GSSetShader( - __in_opt ID3D11GeometryShader *pShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( - D3D11_PRIMITIVE_TOPOLOGY Topology) {} - virtual void STDMETHODCALLTYPE VSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE VSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE Begin( - ID3D11Asynchronous *pAsync) {} - virtual void STDMETHODCALLTYPE End( - ID3D11Asynchronous *pAsync) {} - virtual HRESULT STDMETHODCALLTYPE GetData( - ID3D11Asynchronous *pAsync, - __out_bcount_opt( DataSize ) void *pData, - uint32_t DataSize, - uint32_t GetDataFlags){return E_FAIL; } - virtual void STDMETHODCALLTYPE SetPredication( - __in_opt ID3D11Predicate *pPredicate, - BOOL PredicateValue) {} - virtual void STDMETHODCALLTYPE GSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE GSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE OMSetRenderTargets( - uint32_t NumViews, - ID3D11RenderTargetView *const *ppRenderTargetViews, - __in_opt ID3D11DepthStencilView *pDepthStencilView) {} - virtual void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews( - uint32_t NumRTVs, - ID3D11RenderTargetView *const *ppRenderTargetViews, - __in_opt ID3D11DepthStencilView *pDepthStencilView, - uint32_t UAVStartSlot, - uint32_t NumUAVs, - ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, - const uint32_t *pUAVInitialCounts) {} - virtual void STDMETHODCALLTYPE OMSetBlendState( - __in_opt ID3D11BlendState *pBlendState, - __in_opt const FLOAT BlendFactor[ 4 ], - uint32_t SampleMask) {} - virtual void STDMETHODCALLTYPE OMSetDepthStencilState( - __in_opt ID3D11DepthStencilState *pDepthStencilState, - uint32_t StencilRef) {} - virtual void STDMETHODCALLTYPE SOSetTargets( - uint32_t NumBuffers, - ID3D11Buffer *const *ppSOTargets, - const uint32_t *pOffsets) {} - virtual void STDMETHODCALLTYPE DrawAuto( void) {} - virtual void STDMETHODCALLTYPE DrawIndexedInstancedIndirect( - ID3D11Buffer *pBufferForArgs, - uint32_t AlignedByteOffsetForArgs) {} - virtual void STDMETHODCALLTYPE DrawInstancedIndirect( - ID3D11Buffer *pBufferForArgs, - uint32_t AlignedByteOffsetForArgs) {} - virtual void STDMETHODCALLTYPE Dispatch( - uint32_t ThreadGroupCountX, - uint32_t ThreadGroupCountY, - uint32_t ThreadGroupCountZ) {} - virtual void STDMETHODCALLTYPE DispatchIndirect( - ID3D11Buffer *pBufferForArgs, - uint32_t AlignedByteOffsetForArgs) {} - virtual void STDMETHODCALLTYPE RSSetState( - __in_opt ID3D11RasterizerState *pRasterizerState) {} - virtual void STDMETHODCALLTYPE RSSetViewports( - uint32_t NumViewports, - const D3D11_VIEWPORT *pViewports) {} - virtual void STDMETHODCALLTYPE RSSetScissorRects( - uint32_t NumRects, - const D3D11_RECT *pRects) {} - virtual void STDMETHODCALLTYPE CopySubresourceRegion( - ID3D11Resource *pDstResource, - uint32_t DstSubresource, - uint32_t DstX, - uint32_t DstY, - uint32_t DstZ, - ID3D11Resource *pSrcResource, - uint32_t SrcSubresource, - __in_opt const D3D11_BOX *pSrcBox) {} - virtual void STDMETHODCALLTYPE CopyResource( - ID3D11Resource *pDstResource, - ID3D11Resource *pSrcResource) {} - virtual void STDMETHODCALLTYPE UpdateSubresource( - ID3D11Resource *pDstResource, - uint32_t DstSubresource, - __in_opt const D3D11_BOX *pDstBox, - const void *pSrcData, - uint32_t SrcRowPitch, - uint32_t SrcDepthPitch) {} - virtual void STDMETHODCALLTYPE CopyStructureCount( - ID3D11Buffer *pDstBuffer, - uint32_t DstAlignedByteOffset, - ID3D11UnorderedAccessView *pSrcView) {} - virtual void STDMETHODCALLTYPE ClearRenderTargetView( - ID3D11RenderTargetView *pRenderTargetView, - const FLOAT ColorRGBA[ 4 ]) {} - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( - ID3D11UnorderedAccessView *pUnorderedAccessView, - const uint32_t Values[ 4 ]) {} - virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( - ID3D11UnorderedAccessView *pUnorderedAccessView, - const FLOAT Values[ 4 ]) {} - virtual void STDMETHODCALLTYPE ClearDepthStencilView( - ID3D11DepthStencilView *pDepthStencilView, - uint32_t ClearFlags, - FLOAT Depth, - UINT8 Stencil) {} - virtual void STDMETHODCALLTYPE GenerateMips( - ID3D11ShaderResourceView *pShaderResourceView) {} - virtual void STDMETHODCALLTYPE SetResourceMinLOD( - ID3D11Resource *pResource, - FLOAT MinLOD) {} - virtual FLOAT STDMETHODCALLTYPE GetResourceMinLOD( - ID3D11Resource *pResource){return 0; } - virtual void STDMETHODCALLTYPE ResolveSubresource( - ID3D11Resource *pDstResource, - uint32_t DstSubresource, - ID3D11Resource *pSrcResource, - uint32_t SrcSubresource, - DXGI_FORMAT Format) {} - virtual void STDMETHODCALLTYPE ExecuteCommandList( - ID3D11CommandList *pCommandList, - BOOL RestoreContextState) {} - virtual void STDMETHODCALLTYPE HSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE HSSetShader( - __in_opt ID3D11HullShader *pHullShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE HSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE HSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE DSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE DSSetShader( - __in_opt ID3D11DomainShader *pDomainShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE DSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE DSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE CSSetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView *const *ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE CSSetUnorderedAccessViews( - uint32_t StartSlot, - uint32_t NumUAVs, - ID3D11UnorderedAccessView *const *ppUnorderedAccessViews, - const uint32_t *pUAVInitialCounts) {} - virtual void STDMETHODCALLTYPE CSSetShader( - __in_opt ID3D11ComputeShader *pComputeShader, - ID3D11ClassInstance *const *ppClassInstances, - uint32_t NumClassInstances) {} - virtual void STDMETHODCALLTYPE CSSetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState *const *ppSamplers) {} - virtual void STDMETHODCALLTYPE CSSetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer *const *ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE VSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE PSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE PSGetShader( - ID3D11PixelShader **ppPixelShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE PSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE VSGetShader( - ID3D11VertexShader **ppVertexShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE PSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE IAGetInputLayout( - ID3D11InputLayout **ppInputLayout) {} - virtual void STDMETHODCALLTYPE IAGetVertexBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppVertexBuffers, - uint32_t *pStrides, - uint32_t *pOffsets) {} - virtual void STDMETHODCALLTYPE IAGetIndexBuffer( - ID3D11Buffer **pIndexBuffer, - DXGI_FORMAT *Format, - uint32_t *Offset) {} - virtual void STDMETHODCALLTYPE GSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE GSGetShader( - ID3D11GeometryShader **ppGeometryShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE IAGetPrimitiveTopology( - D3D11_PRIMITIVE_TOPOLOGY *pTopology) {} - virtual void STDMETHODCALLTYPE VSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE VSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE GetPredication( - ID3D11Predicate **ppPredicate, - BOOL *pPredicateValue) {} - virtual void STDMETHODCALLTYPE GSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE GSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE OMGetRenderTargets( - uint32_t NumViews, - ID3D11RenderTargetView **ppRenderTargetViews, - ID3D11DepthStencilView **ppDepthStencilView) {} - virtual void STDMETHODCALLTYPE OMGetRenderTargetsAndUnorderedAccessViews( - uint32_t NumRTVs, - ID3D11RenderTargetView **ppRenderTargetViews, - ID3D11DepthStencilView **ppDepthStencilView, - uint32_t UAVStartSlot, - uint32_t NumUAVs, - ID3D11UnorderedAccessView **ppUnorderedAccessViews) {} - virtual void STDMETHODCALLTYPE OMGetBlendState( - ID3D11BlendState **ppBlendState, - FLOAT BlendFactor[ 4 ], - uint32_t *pSampleMask) {} - virtual void STDMETHODCALLTYPE OMGetDepthStencilState( - ID3D11DepthStencilState **ppDepthStencilState, - uint32_t *pStencilRef) {} - virtual void STDMETHODCALLTYPE SOGetTargets( - uint32_t NumBuffers, - ID3D11Buffer **ppSOTargets) {} - virtual void STDMETHODCALLTYPE RSGetState( - ID3D11RasterizerState **ppRasterizerState) {} - virtual void STDMETHODCALLTYPE RSGetViewports( - uint32_t *pNumViewports, - D3D11_VIEWPORT *pViewports) {} - virtual void STDMETHODCALLTYPE RSGetScissorRects( - uint32_t *pNumRects, - D3D11_RECT *pRects) {} - virtual void STDMETHODCALLTYPE HSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE HSGetShader( - ID3D11HullShader **ppHullShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE HSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE HSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE DSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE DSGetShader( - ID3D11DomainShader **ppDomainShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE DSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE DSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE CSGetShaderResources( - uint32_t StartSlot, - uint32_t NumViews, - ID3D11ShaderResourceView **ppShaderResourceViews) {} - virtual void STDMETHODCALLTYPE CSGetUnorderedAccessViews( - uint32_t StartSlot, - uint32_t NumUAVs, - ID3D11UnorderedAccessView **ppUnorderedAccessViews) {} - virtual void STDMETHODCALLTYPE CSGetShader( - ID3D11ComputeShader **ppComputeShader, - ID3D11ClassInstance **ppClassInstances, - uint32_t *pNumClassInstances) {} - virtual void STDMETHODCALLTYPE CSGetSamplers( - uint32_t StartSlot, - uint32_t NumSamplers, - ID3D11SamplerState **ppSamplers) {} - virtual void STDMETHODCALLTYPE CSGetConstantBuffers( - uint32_t StartSlot, - uint32_t NumBuffers, - ID3D11Buffer **ppConstantBuffers) {} - virtual void STDMETHODCALLTYPE ClearState( void) {} - virtual void STDMETHODCALLTYPE Flush( void) {} - virtual D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType( void) - {return D3D11_DEVICE_CONTEXT_IMMEDIATE; } - virtual uint32_t STDMETHODCALLTYPE GetContextFlags( void) - { return 0; } - virtual HRESULT STDMETHODCALLTYPE FinishCommandList( - BOOL RestoreDeferredContextState, - ID3D11CommandList **ppCommandList) - { return E_FAIL; } - } s_nullContext; - -} -#pragma warning( default: 4100 ) - -Tr2RenderContextAL::Tr2RenderContextAL() throw() - : m_topology( TOP_INVALID ) - , m_lastSetTopology( TOP_INVALID ) - , m_renderTargetHighWaterMark( 1 ) - , m_lastSetVertexLayoutVSHash( 0 ) - , m_stackDS( "Tr2RenderContextAL::m_stackDS" ) - , m_useReadOnlyDepthView( false ) - , m_isDepthReadOnly( false ) - , m_isSrgbRenderTarget( false ) - , m_previouslyHadHullShader( false ) - , m_events( nullptr ) - , m_aftermathContext( nullptr ), - m_assignedUavCount( 0 ), - m_assignedUavOffset( 0 ), - m_assignedPsUavs( false ) -{ +Tr2RenderContextAL::Tr2RenderContextAL() throw() : + m_topology( TOP_INVALID ), m_lastSetTopology( TOP_INVALID ), m_renderTargetHighWaterMark( 1 ), m_lastSetVertexLayoutVSHash( 0 ), m_stackDS( "Tr2RenderContextAL::m_stackDS" ), m_useReadOnlyDepthView( false ), m_isDepthReadOnly( false ), m_isSrgbRenderTarget( false ), m_previouslyHadHullShader( false ), m_events( nullptr ), m_aftermathContext( nullptr ), m_assignedUavCount( 0 ), m_assignedUavOffset( 0 ), m_assignedPsUavs( false ) +{ m_dirtyFlag.mask = 0; m_context.Attach( &Tr2RenderContextImpl::s_nullContext ); - static_assert( D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT >= MAX_RENDER_TARGET, - "Bad define" ); + static_assert( D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT >= MAX_RENDER_TARGET, + "Bad define" ); for( unsigned i = 0; i != MAX_RENDER_TARGET; ++i ) { @@ -556,8 +781,7 @@ Tr2RenderContextAL::Tr2RenderContextAL() throw() m_sharedConstantBuffers[i].size = 0; } - memset( &m_renderStateEmulation.m_currentBlend, 0, - sizeof( m_renderStateEmulation.m_currentBlend ) ); + memset( &m_renderStateEmulation.m_currentBlend, 0, sizeof( m_renderStateEmulation.m_currentBlend ) ); m_renderStateEmulation.m_currentBlend.RenderTarget[0] = defaultBlend; m_renderStateEmulation.m_currentDepthStencil = defaultDepthStencil; @@ -605,23 +829,22 @@ void Tr2RenderContextAL::Destroy() throw() m_assignedUavOffset = 0; m_assignedPsUavs = false; - m_secondaryDefaultBackBuffer = Tr2TextureAL(); + m_secondaryDefaultBackBuffer = Tr2TextureAL(); if( m_aftermathContext ) { GFSDK_Aftermath_ReleaseContextHandle( reinterpret_cast( m_aftermathContext ) ); m_aftermathContext = nullptr; } m_context.Attach( &Tr2RenderContextImpl::s_nullContext ); - - m_boundDepthStencil = Tr2TextureAL(); + + m_boundDepthStencil = Tr2TextureAL(); m_topology = TOP_INVALID; m_lastSetTopology = TOP_INVALID; std::fill_n( m_boundRenderTarget, MAX_RENDER_TARGET, BoundRT{} ); - memset( &m_renderStateEmulation.m_currentBlend, 0, - sizeof( m_renderStateEmulation.m_currentBlend ) ); + memset( &m_renderStateEmulation.m_currentBlend, 0, sizeof( m_renderStateEmulation.m_currentBlend ) ); m_renderStateEmulation.m_currentBlend.RenderTarget[0] = defaultBlend; m_renderStateEmulation.m_currentDepthStencil = defaultDepthStencil; @@ -635,7 +858,7 @@ void Tr2RenderContextAL::Destroy() throw() m_renderStateEmulation.s_rasterizerCache.clear(); m_dirtyFlag.mask = 0; - + m_fragmentOpBuffer = Tr2ConstantBufferAL(); //raw pointers only//m_vertexShader.Destroy(); @@ -644,7 +867,7 @@ void Tr2RenderContextAL::Destroy() throw() m_lastSetVertexLayoutVSHash = 0; m_drawUP.Destroy(); - + for( unsigned i = 0; i != MAX_RENDER_TARGET; ++i ) { TrackableStdStack stack; @@ -668,11 +891,11 @@ void Tr2RenderContextAL::Destroy() throw() PixelFormat Tr2RenderContextAL::GetBackBufferFormat() const throw() { auto& renderContext = Tr2RenderContextAL::GetPrimaryRenderContext(); - return renderContext.GetBackBufferFormat(); + return renderContext.GetBackBufferFormat(); } ALResult Tr2RenderContextAL::BeginScene() throw() -{ +{ m_shaderProgram = Tr2ShaderProgramAL(); std::fill( std::begin( m_samplerHashes ), std::end( m_samplerHashes ), 0 ); @@ -694,13 +917,12 @@ ALResult Tr2RenderContextAL::BeginScene() throw() 0, TrinityALImpl::Tr2ResourceSetAL::MAX_RESOURCES, nullSrv ); - } } m_currentResourceSet = Tr2ResourceSetAL(); - return S_OK; + return S_OK; } bool Tr2RenderContextAL::IsValid() const throw() @@ -727,8 +949,8 @@ __forceinline uint32_t Tr2RenderContextAL::ComputeVertexCount( uint32_t primitiv case TOP_POINTS: case TOP_TRIANGLE_FAN: return primitiveCount; - - + + default: CCP_ASSERT_M( false, "Unsupported topology" ); return 0; @@ -746,14 +968,14 @@ void Tr2RenderContextAL::ApplyReadOnlyDepth() throw() } }; -ALResult Tr2RenderContextAL::DrawIndexedPrimitive( +ALResult Tr2RenderContextAL::DrawIndexedPrimitive( uint32_t, - uint32_t startIndex, - uint32_t primitiveCount, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t baseVertexLocation ) throw() { auto vc = ComputeVertexCount( primitiveCount ); - + CCP_STATS_ADD( primitiveCount, primitiveCount ); CCP_STATS_ADD( vertexCount, vc ); CCP_STATS_INC( sceneDrawcallCount ); @@ -765,14 +987,14 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitive( ApplyReadOnlyDepth(); m_context->DrawIndexed( vc, startIndex, baseVertexLocation ); - + return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedInstanced( - uint32_t, - uint32_t startIndex, - uint32_t primitiveCount, +ALResult Tr2RenderContextAL::DrawIndexedInstanced( + uint32_t, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t numInstances ) throw() { auto vc = ComputeVertexCount( primitiveCount ); @@ -788,7 +1010,7 @@ ALResult Tr2RenderContextAL::DrawIndexedInstanced( ApplyReadOnlyDepth(); m_context->DrawIndexedInstanced( vc, numInstances, startIndex, 0, 0 ); - + return S_OK; } @@ -818,7 +1040,7 @@ ALResult Tr2RenderContextAL::DrawInstanced( uint32_t vertexCountPerInstance, uint32_t instanceCount, uint32_t startVertexLocation, - uint32_t startInstanceLocation ) throw( ) + uint32_t startInstanceLocation ) throw() { CCP_STATS_ADD( primitiveCount, vertexCountPerInstance * instanceCount / 3 ); CCP_STATS_ADD( vertexCount, vertexCountPerInstance * instanceCount ); @@ -885,34 +1107,34 @@ ALResult Tr2RenderContextAL::DrawPrimitive( uint32_t startVertex, uint32_t primi ApplyReadOnlyDepth(); m_context->Draw( vc, startVertex ); - + return S_OK; } -ALResult Tr2RenderContextAL::DrawPrimitiveUP( - uint32_t primitiveCount, - const void* vertexStreamZeroData, +ALResult Tr2RenderContextAL::DrawPrimitiveUP( + uint32_t primitiveCount, + const void* vertexStreamZeroData, uint32_t vertexStreamZeroStride ) throw() { return m_drawUP.DrawPrimitiveUP( m_topology, primitiveCount, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( + uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride) throw() + uint32_t vertexStreamZeroStride ) throw() { return m_drawUP.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( + uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride) throw() + uint32_t vertexStreamZeroStride ) throw() { return m_drawUP.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); } @@ -935,7 +1157,7 @@ ALResult Tr2RenderContextAL::RunComputeShader( unsigned groupDimX, unsigned grou return S_OK; } -ALResult Tr2RenderContextAL::RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw( ) +ALResult Tr2RenderContextAL::RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw() { if( !indirectParams.IsValid() ) { @@ -947,10 +1169,10 @@ ALResult Tr2RenderContextAL::RunComputeShaderIndirect( Tr2BufferAL& indirectPara } ALResult Tr2RenderContextAL::SetConstants( - const Tr2ConstantBufferAL& buffer, - Tr2RenderContextEnum::ShaderType constantType, - uint32_t registerIndex, - uint32_t ) throw() + const Tr2ConstantBufferAL& buffer, + Tr2RenderContextEnum::ShaderType constantType, + uint32_t registerIndex, + uint32_t ) throw() { using namespace Tr2RenderContextEnum; @@ -1014,12 +1236,12 @@ ALResult Tr2RenderContextAL::SetConstants( cb.size = 0; } } - + switch( constantType ) { case VERTEX_SHADER: m_context->VSSetConstantBuffers( registerIndex, 1, bufArray ); - break; + break; case PIXEL_SHADER: m_context->PSSetConstantBuffers( registerIndex, 1, bufArray ); @@ -1048,19 +1270,18 @@ ALResult Tr2RenderContextAL::SetConstants( return S_OK; } -ALResult Tr2RenderContextAL::Clear( +ALResult Tr2RenderContextAL::Clear( uint32_t clearFlags, - uint32_t color, - float depth, + uint32_t color, + float depth, uint32_t stencil, uint32_t slot ) throw() { if( clearFlags & CLEARFLAGS_TARGET ) { - ID3D11RenderTargetView* rtView = - m_boundRenderTarget[slot].texture.IsValid() ? m_boundRenderTarget[slot].texture.m_texture->m_renderTarget[COLOR_SPACE_LINEAR + m_boundRenderTarget[slot].slice * 2] - : slot == 0 ? ( m_secondaryDefaultBackBuffer.m_texture->m_renderTarget.empty() ? nullptr : m_secondaryDefaultBackBuffer.m_texture->m_renderTarget[COLOR_SPACE_LINEAR] ) - : nullptr; + ID3D11RenderTargetView* rtView = + m_boundRenderTarget[slot].texture.IsValid() ? m_boundRenderTarget[slot].texture.m_texture->m_renderTarget[COLOR_SPACE_LINEAR + m_boundRenderTarget[slot].slice * 2] : slot == 0 ? ( m_secondaryDefaultBackBuffer.m_texture->m_renderTarget.empty() ? nullptr : m_secondaryDefaultBackBuffer.m_texture->m_renderTarget[COLOR_SPACE_LINEAR] ) : + nullptr; if( rtView ) { @@ -1090,8 +1311,9 @@ ALResult Tr2RenderContextAL::Clear( if( d3dFlags && m_boundDepthStencil.IsValid() ) { m_context->ClearDepthStencilView( m_boundDepthStencil.m_texture->m_depthStencil[TrinityALImpl::Tr2TextureAL::DepthOption::READ_WRITE], - d3dFlags, depth, - static_cast(stencil) ); + d3dFlags, + depth, + static_cast( stencil ) ); } return S_OK; @@ -1118,7 +1340,7 @@ ALResult Tr2RenderContextAL::SetRtDsToDevice( uint32_t changedSlot ) throw() ( m_context->*( setResources[i] ) )( 0, 16, nullViews ); } - ID3D11RenderTargetView* rtViews[MAX_RENDER_TARGET]; + ID3D11RenderTargetView* rtViews[MAX_RENDER_TARGET]; // Follow the DX9 behavior: null means 'default backbuffer' for slot 0, and 'nothing' for everything else. for( uint32_t i = 0; i != m_renderTargetHighWaterMark; ++i ) { @@ -1142,13 +1364,13 @@ ALResult Tr2RenderContextAL::SetRtDsToDevice( uint32_t changedSlot ) throw() // dont't even bother setting it when the dimensions don't match, it's not gonna work. // This happens when we set/push/pop an RT and DS in two separate calls -- there's a point between // those two where it's in a bad state. Silently "works" in DX9, complains in DX11. Fix the spam: - if( !m_boundDepthStencil.IsValid() || - !m_boundRenderTarget[0].texture.IsValid() || - ( m_boundDepthStencil.GetDesc().GetWidth() == bb.GetDesc().GetWidth() && - m_boundDepthStencil.GetDesc().GetHeight() == bb.GetDesc().GetHeight() && - m_boundDepthStencil.GetMsaaDesc().quality == bb.GetMsaaDesc().quality && - dsMsaaType == bbMsaaType ) ) - { + if( !m_boundDepthStencil.IsValid() || + !m_boundRenderTarget[0].texture.IsValid() || + ( m_boundDepthStencil.GetDesc().GetWidth() == bb.GetDesc().GetWidth() && + m_boundDepthStencil.GetDesc().GetHeight() == bb.GetDesc().GetHeight() && + m_boundDepthStencil.GetMsaaDesc().quality == bb.GetMsaaDesc().quality && + dsMsaaType == bbMsaaType ) ) + { ID3D11DepthStencilView* dsView = nullptr; if( m_boundDepthStencil.IsValid() ) { @@ -1161,13 +1383,13 @@ ALResult Tr2RenderContextAL::SetRtDsToDevice( uint32_t changedSlot ) throw() dsView = m_boundDepthStencil.m_texture->m_depthStencil[TrinityALImpl::Tr2TextureAL::DepthOption::READ_WRITE]; } } - m_context->OMSetRenderTargetsAndUnorderedAccessViews( - m_renderTargetHighWaterMark, + m_context->OMSetRenderTargetsAndUnorderedAccessViews( + m_renderTargetHighWaterMark, rtViews, dsView, - 0, - D3D11_KEEP_UNORDERED_ACCESS_VIEWS, - nullptr, + 0, + D3D11_KEEP_UNORDERED_ACCESS_VIEWS, + nullptr, nullptr ); } @@ -1186,9 +1408,9 @@ ALResult Tr2RenderContextAL::SetRtDsToDevice( uint32_t changedSlot ) throw() if( m_boundRenderTarget[0].texture.IsValid() ) { SetViewport( Tr2Viewport( bb.GetDesc().GetWidth(), bb.GetDesc().GetHeight() ) ); - D3D11_RECT rect = { 0, 0, LONG( bb.GetDesc().GetWidth() ), LONG( bb.GetDesc().GetHeight() ) }; - m_context->RSSetScissorRects( 1, &rect ); - } + D3D11_RECT rect = { 0, 0, LONG( bb.GetDesc().GetWidth() ), LONG( bb.GetDesc().GetHeight() ) }; + m_context->RSSetScissorRects( 1, &rect ); + } else if( m_boundDepthStencil.IsValid() ) { SetViewport( Tr2Viewport( m_boundDepthStencil.GetDesc().GetWidth(), m_boundDepthStencil.GetDesc().GetHeight() ) ); @@ -1234,7 +1456,7 @@ ALResult Tr2RenderContextAL::SetDepthStencil( const Tr2TextureAL& depthStencil ) { m_boundDepthStencil = Tr2TextureAL(); } - + SetRtDsToDevice( MAX_RENDER_TARGET ); return S_OK; } @@ -1270,7 +1492,7 @@ ALResult Tr2RenderContextAL::SetRenderTarget( const Tr2TextureAL& renderTarget, ALResult Tr2RenderContextAL::SetStreamSource( uint32_t stream, - const Tr2BufferAL & buffer, + const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ) throw() { @@ -1283,13 +1505,13 @@ ALResult Tr2RenderContextAL::SetStreamSource( return S_OK; } -ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL & buffer ) throw() +ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer ) throw() { return SetIndices( buffer, buffer.GetDesc().stride ); } -ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, uint32_t stride) throw() +ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, uint32_t stride ) throw() { m_context->IASetIndexBuffer( buffer.m_buffer->m_buffer, stride == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0 ); return S_OK; @@ -1318,15 +1540,22 @@ ALResult Tr2RenderContextAL::CopySubBuffer( { return E_FAIL; } - D3D11_BOX srcBox = { offset, 0, 0, offset + length, 1, 1, }; - m_context->CopySubresourceRegion( dest.m_buffer->m_buffer, - 0, - destOffset, + D3D11_BOX srcBox = { + offset, 0, 0, - src.m_buffer->m_buffer, - 0, - &srcBox ); + offset + length, + 1, + 1, + }; + m_context->CopySubresourceRegion( dest.m_buffer->m_buffer, + 0, + destOffset, + 0, + 0, + src.m_buffer->m_buffer, + 0, + &srcBox ); return S_OK; } @@ -1382,7 +1611,7 @@ ALResult Tr2RenderContextAL::SetRenderState( RenderState state, uint32_t value ) return SetRenderStatesImpl( sv, 1 ); } -ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t *stateValuePairs, uint32_t count ) throw() +ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw() { if( !stateValuePairs ) { @@ -1392,40 +1621,40 @@ ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t *stateValuePairs, u return SetRenderStatesImpl( stateValuePairs, count ); } -ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePairs, uint32_t count ) throw() +ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t* stateValuePairs, uint32_t count ) throw() { auto& rt0 = m_renderStateEmulation.m_currentBlend.RenderTarget[0]; - auto& ds = m_renderStateEmulation.m_currentDepthStencil; - auto& rs = m_renderStateEmulation.m_currentRasterizer; + auto& ds = m_renderStateEmulation.m_currentDepthStencil; + auto& rs = m_renderStateEmulation.m_currentRasterizer; -#define checkBlend(blends,value) \ - { \ - if( blends != static_cast( value ) ) \ - { \ - blends = static_cast( value ); \ - m_dirtyFlag.flags.blend = true; \ - } \ +#define checkBlend( blends, value ) \ + { \ + if( blends != static_cast( value ) ) \ + { \ + blends = static_cast( value ); \ + m_dirtyFlag.flags.blend = true; \ + } \ } -#define checkBlendOp(op, value ) \ - { \ - if( op != static_cast( value ) ) \ - { \ - op = static_cast( value ); \ - m_dirtyFlag.flags.blend = true; \ - } \ +#define checkBlendOp( op, value ) \ + { \ + if( op != static_cast( value ) ) \ + { \ + op = static_cast( value ); \ + m_dirtyFlag.flags.blend = true; \ + } \ } - for( uint32_t i = 0; - ( count == 0 && *stateValuePairs ) || ( count != 0 && i != count ); - ++i ) + for( uint32_t i = 0; + ( count == 0 && *stateValuePairs ) || ( count != 0 && i != count ); + ++i ) { - static_assert( sizeof( RenderState ) == sizeof( uint32_t ), - "RenderState and value differ in size" ); + static_assert( sizeof( RenderState ) == sizeof( uint32_t ), + "RenderState and value differ in size" ); const RenderState state = static_cast( *stateValuePairs++ ); - const uint32_t value = *stateValuePairs++; + const uint32_t value = *stateValuePairs++; - if( (uint32_t)state >= RS_MAX_STATE || m_allRenderStates[ state ] == value ) + if( (uint32_t)state >= RS_MAX_STATE || m_allRenderStates[state] == value ) { continue; } @@ -1433,7 +1662,7 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair #if 1 if( state < RS_MAX_STATE ) { - m_allRenderStates[ state ] = value; + m_allRenderStates[state] = value; } #endif @@ -1446,24 +1675,36 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair rt0.BlendEnable = value ? 1 : 0; m_dirtyFlag.flags.blend = true; } - continue; //return S_OK; + continue; //return S_OK; + + case RS_SRCBLEND: /*return*/ + checkBlend( rt0.SrcBlend, value ); + continue; + case RS_DESTBLEND: /*return*/ + checkBlend( rt0.DestBlend, value ); + continue; + case RS_SRCBLENDALPHA: /*return*/ + checkBlend( rt0.SrcBlendAlpha, value ); + continue; + case RS_DESTBLENDALPHA: /*return*/ + checkBlend( rt0.DestBlendAlpha, value ); + continue; - case RS_SRCBLEND: /*return*/ checkBlend( rt0.SrcBlend, value ); continue; - case RS_DESTBLEND: /*return*/ checkBlend( rt0.DestBlend, value ); continue; - case RS_SRCBLENDALPHA: /*return*/ checkBlend( rt0.SrcBlendAlpha, value ); continue; - case RS_DESTBLENDALPHA: /*return*/ checkBlend( rt0.DestBlendAlpha, value ); continue; + case RS_BLENDOP: /*return*/ + checkBlendOp( rt0.BlendOp, value ); + continue; + case RS_BLENDOPALPHA: /*return*/ + checkBlendOp( rt0.BlendOpAlpha, value ); + continue; - case RS_BLENDOP: /*return*/ checkBlendOp( rt0.BlendOp, value ); continue; - case RS_BLENDOPALPHA: /*return*/ checkBlendOp( rt0.BlendOpAlpha, value ); continue; - case RS_COLORWRITEENABLE: if( rt0.RenderTargetWriteMask != value ) { rt0.RenderTargetWriteMask = static_cast( value ) & 0xf; - m_dirtyFlag.flags.blend = true; + m_dirtyFlag.flags.blend = true; } //m_queryableRenderState.m_colorWriteEnable = value; - continue; //return S_OK; + continue; //return S_OK; case RS_SEPARATEALPHABLENDENABLE: if( m_renderStateEmulation.m_separateAlphaBlendEnabled != ( value != 0 ) ) @@ -1471,7 +1712,7 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair m_renderStateEmulation.m_separateAlphaBlendEnabled = value != 0; m_dirtyFlag.flags.blend = true; } - continue; //return S_OK; + continue; //return S_OK; // ------------------------------ Depth Stencil state case RS_ZENABLE: @@ -1481,26 +1722,24 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair m_dirtyFlag.flags.depthStencil = true; } //m_queryableRenderState.m_zEnable = value; - continue; //return S_OK; + continue; //return S_OK; case RS_ZWRITEENABLE: - if( ds.DepthWriteMask != ( value ? D3D11_DEPTH_WRITE_MASK_ALL - : D3D11_DEPTH_WRITE_MASK_ZERO ) ) + if( ds.DepthWriteMask != ( value ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO ) ) { - ds.DepthWriteMask = value ? D3D11_DEPTH_WRITE_MASK_ALL - : D3D11_DEPTH_WRITE_MASK_ZERO; + ds.DepthWriteMask = value ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; m_dirtyFlag.flags.depthStencil = true; } //m_queryableRenderState.m_zWriteEnable = value; - continue; //return S_OK; + continue; //return S_OK; case RS_ZFUNC: if( ds.DepthFunc != static_cast( value ) ) { - ds.DepthFunc = static_cast( value ); // same -- TODO Halify the enum values + ds.DepthFunc = static_cast( value ); // same -- TODO Halify the enum values m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILENABLE: if( ( ds.StencilEnable == 0 ) != ( value == 0 ) ) @@ -1508,7 +1747,7 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair ds.StencilEnable = value ? 1 : 0; m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILMASK: if( ds.StencilReadMask != value || ds.StencilWriteMask != value ) @@ -1516,7 +1755,7 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair ds.StencilReadMask = ds.StencilWriteMask = static_cast( value ); m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILREF: if( m_renderStateEmulation.m_currentStencilRef != value ) @@ -1524,83 +1763,80 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair m_renderStateEmulation.m_currentStencilRef = value; m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILFAIL: if( ds.FrontFace.StencilFailOp != static_cast( value ) || - ds.BackFace .StencilFailOp != static_cast( value ) ) + ds.BackFace.StencilFailOp != static_cast( value ) ) { - ds.FrontFace.StencilFailOp = - ds.BackFace.StencilFailOp = static_cast( value ); // same -- TODO halify + ds.FrontFace.StencilFailOp = + ds.BackFace.StencilFailOp = static_cast( value ); // same -- TODO halify m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILZFAIL: if( ds.FrontFace.StencilDepthFailOp != static_cast( value ) || - ds.BackFace .StencilDepthFailOp != static_cast( value ) ) + ds.BackFace.StencilDepthFailOp != static_cast( value ) ) { - ds.FrontFace.StencilDepthFailOp = - ds.BackFace.StencilDepthFailOp = static_cast( value ); // same -- TODO halify + ds.FrontFace.StencilDepthFailOp = + ds.BackFace.StencilDepthFailOp = static_cast( value ); // same -- TODO halify m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_STENCILPASS: if( ds.FrontFace.StencilPassOp != static_cast( value ) || - ds.BackFace .StencilPassOp != static_cast( value ) ) + ds.BackFace.StencilPassOp != static_cast( value ) ) { - ds.FrontFace.StencilPassOp = - ds.BackFace.StencilPassOp = static_cast( value ); // same -- TODO halify + ds.FrontFace.StencilPassOp = + ds.BackFace.StencilPassOp = static_cast( value ); // same -- TODO halify m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; - + continue; //return S_OK; + case RS_STENCILFUNC: if( ds.FrontFace.StencilFunc != static_cast( value ) || - ds.BackFace .StencilFunc != static_cast( value ) ) + ds.BackFace.StencilFunc != static_cast( value ) ) { - ds.FrontFace.StencilFunc = - ds.BackFace.StencilFunc = static_cast( value ); // same -- TODO halify + ds.FrontFace.StencilFunc = + ds.BackFace.StencilFunc = static_cast( value ); // same -- TODO halify m_dirtyFlag.flags.depthStencil = true; } - continue; //return S_OK; + continue; //return S_OK; // ------------------------------ Rasterizer state case RS_FILLMODE: if( rs.FillMode != static_cast( value ) ) { - rs.FillMode = static_cast( value ); // same -- Halify + rs.FillMode = static_cast( value ); // same -- Halify m_dirtyFlag.flags.rasterizer = true; } - continue; //return S_OK; + continue; //return S_OK; - case RS_CULLMODE: + case RS_CULLMODE: { + auto newValue = value == 1 /* D3DCULL_NONE */ ? D3D11_CULL_NONE : ( value == 3 /* D3DCULL_CCW */ ? D3D11_CULL_BACK : D3D11_CULL_FRONT ); + if( rs.CullMode != newValue ) { - auto newValue = value == 1 /* D3DCULL_NONE */ ? D3D11_CULL_NONE - : ( value == 3 /* D3DCULL_CCW */ ? D3D11_CULL_BACK - : D3D11_CULL_FRONT ); - if( rs.CullMode != newValue ) - { - rs.CullMode = newValue; - rs.FrontCounterClockwise = FALSE; - m_dirtyFlag.flags.rasterizer = true; - } - //m_queryableRenderState.m_cullMode = value; + rs.CullMode = newValue; + rs.FrontCounterClockwise = FALSE; + m_dirtyFlag.flags.rasterizer = true; } - continue; //return S_OK; + //m_queryableRenderState.m_cullMode = value; + } + continue; //return S_OK; + - case RS_DEPTHBIAS: - case RS_ZBIAS: // same thing from Dx8? - if( rs.DepthBias != static_cast(value) ) + case RS_ZBIAS: // same thing from Dx8? + if( rs.DepthBias != static_cast( value ) ) { //rs.DepthBias = static_cast(value); rs.DepthBias = static_cast( *(float*)&value ); // cppcheck-suppress invalidPointerCast m_dirtyFlag.flags.rasterizer = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_SLOPESCALEDEPTHBIAS: if( rs.SlopeScaledDepthBias != *( (float*)&value ) ) // cppcheck-suppress invalidPointerCast @@ -1608,7 +1844,7 @@ ALResult Tr2RenderContextAL::SetRenderStatesImpl( const uint32_t *stateValuePair rs.SlopeScaledDepthBias = *( (float*)&value ); // cppcheck-suppress invalidPointerCast m_dirtyFlag.flags.rasterizer = true; } - continue; //return S_OK; + continue; //return S_OK; case RS_SRGBWRITEENABLE: if( ( value != 0 ) != m_isSrgbRenderTarget ) { @@ -1645,11 +1881,10 @@ bool Tr2RenderContextAL::ApplyShadowRenderStates() throw() { return false; } - if( !( m_vertexLayout == m_lastSetVertexLayout ) || + if( !( m_vertexLayout == m_lastSetVertexLayout ) || m_shaderProgram.m_program->m_vertexShader.m_shader->m_pipelineInputHash != m_lastSetVertexLayoutVSHash ) { - CR_RETURN_VAL( m_vertexLayout.m_layout->SetLayout( m_shaderProgram.m_program->m_vertexShader.m_shader.get(), *this ) - , false ); + CR_RETURN_VAL( m_vertexLayout.m_layout->SetLayout( m_shaderProgram.m_program->m_vertexShader.m_shader.get(), *this ), false ); m_lastSetVertexLayout = m_vertexLayout; m_lastSetVertexLayoutVSHash = m_shaderProgram.m_program->m_vertexShader.m_shader->m_pipelineInputHash; @@ -1668,7 +1903,7 @@ bool Tr2RenderContextAL::ApplyShadowRenderStates() throw() m_dirtyFlag.mask = 0; } - auto hasHullShader =m_shaderProgram.m_program->m_shaders.hullShader != nullptr; + auto hasHullShader = m_shaderProgram.m_program->m_shaders.hullShader != nullptr; if( m_topology == TOP_TRIANGLES && ( m_topology != m_lastSetTopology || m_previouslyHadHullShader != hasHullShader ) ) { @@ -1683,20 +1918,19 @@ bool Tr2RenderContextAL::ApplyShadowRenderStates() throw() m_previouslyHadHullShader = hasHullShader; m_lastSetTopology = m_topology; } - + return OK; } bool Tr2RenderContextAL::ApplyBlendState() throw() -{ +{ if( !m_dirtyFlag.flags.blend ) { return true; } CComPtr blendState; - CR_RETURN_VAL( m_renderStateEmulation.GetBlendState( blendState, m_secondaryDevice11 ) - , false ); + CR_RETURN_VAL( m_renderStateEmulation.GetBlendState( blendState, m_secondaryDevice11 ), false ); static const float blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; m_context->OMSetBlendState( blendState, blendFactor, 0xFFffFFff ); @@ -1704,37 +1938,37 @@ bool Tr2RenderContextAL::ApplyBlendState() throw() } bool Tr2RenderContextAL::ApplyDepthStencilState() throw() -{ +{ if( !m_dirtyFlag.flags.depthStencil ) { return true; } - + CComPtr depthStencilState; - CR_RETURN_VAL( + CR_RETURN_VAL( m_renderStateEmulation.GetDepthStencilState( depthStencilState, - m_secondaryDevice11 ) - , false ); + m_secondaryDevice11 ), + false ); m_context->OMSetDepthStencilState( depthStencilState, m_renderStateEmulation.m_currentStencilRef ); return true; } bool Tr2RenderContextAL::ApplyRasterizerState() throw() -{ +{ if( !m_dirtyFlag.flags.rasterizer ) { return true; } - m_renderStateEmulation.m_currentRasterizer.MultisampleEnable = true; // has nothing to do with MSAAness of current RT, but has something to do with lines. - // "Recommended to always True" -- http://msdn.microsoft.com/en-us/library/windows/desktop/ff476198%28v=vs.85%29.aspx + m_renderStateEmulation.m_currentRasterizer.MultisampleEnable = true; // has nothing to do with MSAAness of current RT, but has something to do with lines. + // "Recommended to always True" -- http://msdn.microsoft.com/en-us/library/windows/desktop/ff476198%28v=vs.85%29.aspx CComPtr rasterizerState; CR_RETURN_VAL( - m_renderStateEmulation.GetRasterizerState( rasterizerState, - m_secondaryDevice11 ) - , false ); + m_renderStateEmulation.GetRasterizerState( rasterizerState, + m_secondaryDevice11 ), + false ); m_context->RSSetState( rasterizerState ); return true; @@ -1744,7 +1978,7 @@ ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet { if( m_currentResourceSet.m_resourceSet == resourceSet.m_resourceSet ) { - return S_OK; + return S_OK; } m_currentResourceSet = resourceSet; @@ -1807,7 +2041,6 @@ ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet 0, TrinityALImpl::Tr2ResourceSetAL::MAX_RESOURCES, nullSrv ); - } } @@ -1837,10 +2070,10 @@ ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet begin = rs.m_uavOffset; end = rs.m_uavOffset + rs.m_uavCount; } - m_context->CSSetUnorderedAccessViews( + m_context->CSSetUnorderedAccessViews( begin, - end - begin, - reinterpret_cast( rs.m_uavs + begin ), + end - begin, + reinterpret_cast( rs.m_uavs + begin ), nullptr ); m_assignedUavCount = rs.m_uavCount; m_assignedUavOffset = rs.m_uavOffset; @@ -1931,14 +2164,14 @@ ALResult Tr2RenderContextAL::ClearUav( const Tr2TextureAL& rt, uint32_t mipLevel ALResult Tr2RenderContextAL::SetViewport( const Tr2Viewport& viewport ) throw() { static_assert( sizeof( viewport ) == sizeof( D3D11_VIEWPORT ), "viewport size mismatch" ); - m_context->RSSetViewports( 1, reinterpret_cast(&viewport) ); + m_context->RSSetViewports( 1, reinterpret_cast( &viewport ) ); return S_OK; } ALResult Tr2RenderContextAL::GetViewport( Tr2Viewport& viewport ) throw() { uint32_t count = 1; - m_context->RSGetViewports( &count, reinterpret_cast(&viewport) ); + m_context->RSGetViewports( &count, reinterpret_cast( &viewport ) ); return S_OK; } @@ -2005,9 +2238,9 @@ ALResult Tr2RenderContextAL::GetRenderTargetSize( uint32_t& width, uint32_t& hei height = m_boundRenderTarget[slot].texture.GetDesc().GetHeight(); return S_OK; } - + if( slot == 0 && m_secondarySwapChain ) - { + { DXGI_SWAP_CHAIN_DESC desc; m_secondarySwapChain->GetDesc( &desc ); width = desc.BufferDesc.Width; @@ -2020,7 +2253,7 @@ ALResult Tr2RenderContextAL::GetRenderTargetSize( uint32_t& width, uint32_t& hei bool Tr2RenderContextAL::IsBackBuffer( const Tr2TextureAL& rt ) const throw() { - return m_secondaryDefaultBackBuffer == rt; + return m_secondaryDefaultBackBuffer == rt; } Tr2TextureAL& Tr2RenderContextAL::GetDefaultBackBuffer() @@ -2040,8 +2273,7 @@ void Tr2RenderContextAL::ResetCapturePlayback() memset( m_allRenderStates, 0xff, sizeof( m_allRenderStates ) ); - memset( &m_renderStateEmulation.m_currentBlend, 0, - sizeof( m_renderStateEmulation.m_currentBlend ) ); + memset( &m_renderStateEmulation.m_currentBlend, 0, sizeof( m_renderStateEmulation.m_currentBlend ) ); m_renderStateEmulation.m_currentBlend.RenderTarget[0] = defaultBlend; m_renderStateEmulation.m_currentDepthStencil = defaultDepthStencil; @@ -2054,9 +2286,8 @@ void Tr2RenderContextAL::ResetCapturePlayback() ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topology ) throw() { using namespace Tr2RenderContextEnum; - static D3D11_PRIMITIVE_TOPOLOGY lookup[TOP_MAX_TOPOLOGY] = - { - D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, // invalid + static D3D11_PRIMITIVE_TOPOLOGY lookup[TOP_MAX_TOPOLOGY] = { + D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, // invalid D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, @@ -2065,7 +2296,7 @@ ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topolog D3D11_PRIMITIVE_TOPOLOGY_LINELIST, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, - D3D11_PRIMITIVE_TOPOLOGY_POINTLIST + D3D11_PRIMITIVE_TOPOLOGY_POINTLIST }; if( topology == TOP_TRIANGLE_FAN ) @@ -2084,7 +2315,7 @@ ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topolog { if( m_topology != TOP_TRIANGLES && m_topology != m_lastSetTopology ) { - m_context->IASetPrimitiveTopology( lookup[ topology ] ); + m_context->IASetPrimitiveTopology( lookup[topology] ); m_lastSetTopology = m_topology; } return S_OK; @@ -2101,7 +2332,7 @@ void Tr2RenderContextAL::AddGpuMarker( const char* marker ) } size_t length = strlen( marker ) + 1; - if( length % 4 == 0) + if( length % 4 == 0 ) { GFSDK_Aftermath_SetEventMarker( reinterpret_cast( m_aftermathContext ), marker, unsigned( length ) ); return; @@ -2195,7 +2426,7 @@ ALResult Tr2RenderContextAL::UseResources( Tr2UseResourceDestination, Tr2GpuUsag ALResult Tr2RenderContextAL::UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ) { - return S_OK; + return S_OK; } void TrinityALImpl::SetDebugName( ID3D11DeviceChild* resource, const char* name ) @@ -2211,4 +2442,4 @@ ALResult Tr2RenderContextAL::DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2Rt return E_FAIL; } -#endif //DX11? +#endif //DX11? diff --git a/trinityal/dx11/Tr2RenderContextDx11.h b/trinityal/dx11/Tr2RenderContextDx11.h index f19d1c78a..b794d9e65 100644 --- a/trinityal/dx11/Tr2RenderContextDx11.h +++ b/trinityal/dx11/Tr2RenderContextDx11.h @@ -26,7 +26,7 @@ class Tr2RtShaderTableAL; struct Tr2Viewport; -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2RenderStateEmulationDx11.h" #include "Tr2ShaderProgramALDx11.h" @@ -65,8 +65,11 @@ class Tr2RenderContextAL static Tr2PrimaryRenderContextAL* GetPrimaryRenderContextPointer(); ALResult BeginScene() throw(); - ALResult EndScene() { return S_OK; } - + ALResult EndScene() + { + return S_OK; + } + bool IsValid() const throw(); void ReleaseDeviceResources() throw(); @@ -74,10 +77,10 @@ class Tr2RenderContextAL ALResult SetStreamSource( uint32_t stream, - const Tr2BufferAL & buffer, + const Tr2BufferAL& buffer, uint32_t offset, - uint32_t stride ) throw( ); - ALResult SetIndices( const Tr2BufferAL& buffer ) throw( ); + uint32_t stride ) throw(); + ALResult SetIndices( const Tr2BufferAL& buffer ) throw(); ALResult SetIndices( const Tr2BufferAL& buffer, uint32_t stride ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const uint32_t values[4] ) throw(); @@ -91,25 +94,25 @@ class Tr2RenderContextAL ALResult SetTopology( Tr2RenderContextEnum::Topology topology ) throw(); ALResult SetVertexLayout( const Tr2VertexLayoutAL& layout ) throw(); - ALResult SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw( ); + ALResult SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw(); - ALResult ClearUav( const Tr2TextureAL& rt, uint32_t mipLevel, const float values[4] ) throw( ); + ALResult ClearUav( const Tr2TextureAL& rt, uint32_t mipLevel, const float values[4] ) throw(); ALResult ClearUav( const Tr2TextureAL& rt, uint32_t mipLevel, const uint32_t values[4] ) throw(); - ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw( ); - - ALResult DrawIndexedPrimitive( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, + ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw(); + + ALResult DrawIndexedPrimitive( + uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t minimumIndex = 0 ) throw(); - ALResult DrawPrimitive(uint32_t startVertex, uint32_t primitiveCount ) throw(); + ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ) throw(); - ALResult DrawIndexedInstanced( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, + ALResult DrawIndexedInstanced( + uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t numInstances ) throw(); ALResult DrawIndexedInstanced( uint32_t indexCountPerInstance, @@ -122,31 +125,31 @@ class Tr2RenderContextAL uint32_t instanceCount, uint32_t startVertexLocation, uint32_t startInstanceLocation ) throw(); - - ALResult DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ); - ALResult DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ); + + ALResult DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw(); + ALResult DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw(); ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, + uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, uint32_t vertexStreamZeroStride ) throw(); - ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride) throw(); + ALResult DrawIndexedPrimitiveUP( + uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ) throw(); - ALResult DrawPrimitiveUP( - uint32_t primitiveCount, - const void* vertexStreamZeroData, + ALResult DrawPrimitiveUP( + uint32_t primitiveCount, + const void* vertexStreamZeroData, uint32_t VertexStreamZeroStride ) throw(); ALResult RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) throw(); - ALResult RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw( ); + ALResult RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw(); ALResult DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2RtShaderTableAL& shaderTable, const wchar_t* rayGenShader, uint32_t width, uint32_t height, uint32_t depth ); @@ -154,10 +157,10 @@ class Tr2RenderContextAL ALResult SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw(); - ALResult SetConstants( - const Tr2ConstantBufferAL& buffer, - Tr2RenderContextEnum::ShaderType constantType, - uint32_t registerIndex, + ALResult SetConstants( + const Tr2ConstantBufferAL& buffer, + Tr2RenderContextEnum::ShaderType constantType, + uint32_t registerIndex, uint32_t unusedArgument = 0 ) throw(); // Set a depth stencil. Ideally you'd set renderTarget and depthStencil at the same time. @@ -172,10 +175,10 @@ class Tr2RenderContextAL static void DestroyMainThreadRenderContext(); // Helper function to clear the current primary backbuffer, depth and/or stencil. - ALResult Clear( - uint32_t clearFlags, - uint32_t color, - float depth, + ALResult Clear( + uint32_t clearFlags, + uint32_t color, + float depth, uint32_t stencil = 0, uint32_t slot = 0 ) throw(); @@ -189,8 +192,8 @@ class Tr2RenderContextAL ALResult GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot = 0 ) throw(); Tr2RenderContextEnum::PixelFormat GetBackBufferFormat() const throw(); - - static const uint32_t SHADER_TYPE_MASK = + + static const uint32_t SHADER_TYPE_MASK = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ) | ( 1 << Tr2RenderContextEnum::PIXEL_SHADER ) | ( 1 << Tr2RenderContextEnum::COMPUTE_SHADER ) | @@ -199,10 +202,16 @@ class Tr2RenderContextAL ( 1 << Tr2RenderContextEnum::DOMAIN_SHADER ); // Debug helpers - size_t GetStackSizeRT( uint32_t RT = 0 ) const { return m_stackRT[RT].size(); } - size_t GetStackSizeDS() const { return m_stackDS .size(); } + size_t GetStackSizeRT( uint32_t RT = 0 ) const + { + return m_stackRT[RT].size(); + } + size_t GetStackSizeDS() const + { + return m_stackDS.size(); + } - void ResetCapturePlayback(); + void ResetCapturePlayback(); // Set of variables that are the first thing we need in ApplyShadowState, keep them // close for the cache -- don't put renderstates, renderStateEmulation or m_esm @@ -212,16 +221,16 @@ class Tr2RenderContextAL void PushGpuMarker( const char* marker ); void PopGpuMarker(); ALResult GetGpuStateMarker( Tr2RenderContextEnum::RenderContextStatus& status, std::string& marker ) const; - ALResult GetGpuPageFaultResource( - Tr2RenderContextEnum::PixelFormat& format, - uint64_t& size, - uint32_t& width, - uint32_t& height, - uint32_t& depth, + ALResult GetGpuPageFaultResource( + Tr2RenderContextEnum::PixelFormat& format, + uint64_t& size, + uint32_t& width, + uint32_t& height, + uint32_t& depth, uint32_t& mips ) const; ALResult UseResources( Tr2UseResourceDestination dest, Tr2GpuUsage::Type usage, const Tr2BindlessResourcesAL& resources ); - ALResult UseAccelerationStructure(Tr2RtTopLevelAccelerationStructureAL tlas ); + ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); private: union @@ -234,8 +243,10 @@ class Tr2RenderContextAL } flags; uint32_t mask; } m_dirtyFlag; + public: - CComPtr m_context; + CComPtr m_context; + private: // Current vertex layout (for creating vertex layout) Tr2VertexLayoutAL m_vertexLayout; @@ -245,8 +256,8 @@ class Tr2RenderContextAL // Current shaders Tr2ShaderProgramAL m_shaderProgram; - Tr2RenderContextEnum::Topology m_topology; - Tr2RenderContextEnum::Topology m_lastSetTopology; + Tr2RenderContextEnum::Topology m_topology; + Tr2RenderContextEnum::Topology m_lastSetTopology; // If readonly depth buffer was requested bool m_useReadOnlyDepthView; // If readonly depth buffer needs to be set (i.e. if m_useReadOnlyDepthView and we are not writing to depth) @@ -268,44 +279,47 @@ class Tr2RenderContextAL public: uint32_t ComputeVertexCount( uint32_t primitiveCount ) const throw(); - CComPtr m_secondaryDevice11; - CComPtr m_secondarySwapChain; - - Tr2TextureAL m_secondaryDefaultBackBuffer; + CComPtr m_secondaryDevice11; + CComPtr m_secondarySwapChain; + + Tr2TextureAL m_secondaryDefaultBackBuffer; - bool IsBackBuffer( const Tr2TextureAL& rt ) const throw(); + bool IsBackBuffer( const Tr2TextureAL& rt ) const throw(); // If you need this, you're probably doing something wrong :P - Tr2TextureAL& GetDefaultBackBuffer(); + Tr2TextureAL& GetDefaultBackBuffer(); -private: +private: // We can only set renderTarget and depthStencil together, so remember what's set in case code asks // to update only one. - enum { MAX_RENDER_TARGET = 8 }; + enum + { + MAX_RENDER_TARGET = 8 + }; struct BoundRT { Tr2TextureAL texture; uint32_t slice; }; BoundRT m_boundRenderTarget[MAX_RENDER_TARGET]; - uint32_t m_renderTargetHighWaterMark; + uint32_t m_renderTargetHighWaterMark; Tr2TextureAL m_boundDepthStencil; - Tr2RenderStateEmulation m_renderStateEmulation; - - bool ApplyShadowRenderStates() throw(); - bool ApplyBlendState() throw(); - bool ApplyDepthStencilState() throw(); - bool ApplyRasterizerState() throw(); + Tr2RenderStateEmulation m_renderStateEmulation; + + bool ApplyShadowRenderStates() throw(); + bool ApplyBlendState() throw(); + bool ApplyDepthStencilState() throw(); + bool ApplyRasterizerState() throw(); void ApplyReadOnlyDepth() throw(); - Tr2ConstantBufferAL m_fragmentOpBuffer; + Tr2ConstantBufferAL m_fragmentOpBuffer; + + uint32_t m_allRenderStates[Tr2RenderContextEnum::RS_MAX_STATE]; - uint32_t m_allRenderStates[ Tr2RenderContextEnum::RS_MAX_STATE ]; - // Has active hull shader (requires changing topology) - bool m_previouslyHadHullShader; + bool m_previouslyHadHullShader; TrinityALImpl::Tr2DrawUPHelper m_drawUP; @@ -319,7 +333,7 @@ class Tr2RenderContextAL Tr2ResourceSetAL m_currentResourceSet; friend class Tr2PrimaryRenderContextAL; - typedef TrackableStdStack TextureStack; + typedef TrackableStdStack TextureStack; TrackableStdStack m_stackRT[MAX_RENDER_TARGET]; TextureStack m_stackDS; diff --git a/trinityal/dx11/Tr2RenderStateEmulationDx11.cpp b/trinityal/dx11/Tr2RenderStateEmulationDx11.cpp index ac4d79421..129148f7c 100644 --- a/trinityal/dx11/Tr2RenderStateEmulationDx11.cpp +++ b/trinityal/dx11/Tr2RenderStateEmulationDx11.cpp @@ -2,34 +2,34 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2RenderStateEmulationDx11.h" -TrackableStdUnorderedMap< D3D11_BLEND_DESC, - CComPtr, - Tr2RenderStateEmulation::TBlendHash, - Tr2RenderStateEmulation::TBlendEq> - Tr2RenderStateEmulation::s_blendStateCache( "Tr2RenderStateEmulation::s_blendStateCache" ); +TrackableStdUnorderedMap, + Tr2RenderStateEmulation::TBlendHash, + Tr2RenderStateEmulation::TBlendEq> + Tr2RenderStateEmulation::s_blendStateCache( "Tr2RenderStateEmulation::s_blendStateCache" ); -TrackableStdUnorderedMap< D3D11_DEPTH_STENCIL_DESC, - CComPtr, - Tr2RenderStateEmulation::TDepthStencilHash, - Tr2RenderStateEmulation::TDepthStencilEq> - Tr2RenderStateEmulation::s_depthStencilStateCache( "Tr2RenderStateEmulation::s_depthStencilStateCache" ); +TrackableStdUnorderedMap, + Tr2RenderStateEmulation::TDepthStencilHash, + Tr2RenderStateEmulation::TDepthStencilEq> + Tr2RenderStateEmulation::s_depthStencilStateCache( "Tr2RenderStateEmulation::s_depthStencilStateCache" ); -TrackableStdUnorderedMap< D3D11_RASTERIZER_DESC, - CComPtr, - Tr2RenderStateEmulation::TRasterizerHash, - Tr2RenderStateEmulation::TRasterizerEq> - Tr2RenderStateEmulation::s_rasterizerCache( "Tr2RenderStateEmulation::s_rasterizerCache" ); +TrackableStdUnorderedMap, + Tr2RenderStateEmulation::TRasterizerHash, + Tr2RenderStateEmulation::TRasterizerEq> + Tr2RenderStateEmulation::s_rasterizerCache( "Tr2RenderStateEmulation::s_rasterizerCache" ); long Tr2RenderStateEmulation::TBlendHash::operator()( const D3D11_BLEND_DESC& bd ) const { return CcpHashFNV1( &bd, sizeof( bd ) ); } - + bool Tr2RenderStateEmulation::TBlendEq::operator()( const D3D11_BLEND_DESC& bd1, const D3D11_BLEND_DESC& bd2 ) const { return memcmp( &bd1, &bd2, sizeof( bd1 ) ) == 0; @@ -39,9 +39,9 @@ long Tr2RenderStateEmulation::TDepthStencilHash::operator()( const D3D11_DEPTH_S { return CcpHashFNV1( &dsd, sizeof( dsd ) ); } - -bool Tr2RenderStateEmulation::TDepthStencilEq::operator()( const D3D11_DEPTH_STENCIL_DESC& dsd1, - const D3D11_DEPTH_STENCIL_DESC& dsd2 ) const + +bool Tr2RenderStateEmulation::TDepthStencilEq::operator()( const D3D11_DEPTH_STENCIL_DESC& dsd1, + const D3D11_DEPTH_STENCIL_DESC& dsd2 ) const { return memcmp( &dsd1, &dsd2, sizeof( dsd1 ) ) == 0; } @@ -50,18 +50,18 @@ long Tr2RenderStateEmulation::TRasterizerHash::operator()( const D3D11_RASTERIZE { return CcpHashFNV1( &rd, sizeof( rd ) ); } - -bool Tr2RenderStateEmulation::TRasterizerEq::operator()( const D3D11_RASTERIZER_DESC& rd1, - const D3D11_RASTERIZER_DESC& rd2 ) const + +bool Tr2RenderStateEmulation::TRasterizerEq::operator()( const D3D11_RASTERIZER_DESC& rd1, + const D3D11_RASTERIZER_DESC& rd2 ) const { return memcmp( &rd1, &rd2, sizeof( rd1 ) ) == 0; } ALResult Tr2RenderStateEmulation::GetBlendState( CComPtr& blendState, const CComPtr& device11 ) const -{ +{ auto blendCopy = m_currentBlend; - if( !m_separateAlphaBlendEnabled ) + if( !m_separateAlphaBlendEnabled ) { auto& desc = blendCopy.RenderTarget[0]; static D3D11_BLEND alphaBlendRemap[] = { @@ -97,7 +97,7 @@ ALResult Tr2RenderStateEmulation::GetBlendState( CComPtr& blen blendState = cached->second; return S_OK; } - + const HRESULT hr = device11->CreateBlendState( &blendCopy, &blendState ); if( hr == D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS ) { @@ -107,18 +107,17 @@ ALResult Tr2RenderStateEmulation::GetBlendState( CComPtr& blen CR_RETURN_HR( device11->CreateBlendState( &blendCopy, &blendState ) ); } - else - if( FAILED( hr ) ) + else if( FAILED( hr ) ) { return hr; } - - s_blendStateCache[ blendCopy ] = blendState; + + s_blendStateCache[blendCopy] = blendState; return S_OK; } ALResult Tr2RenderStateEmulation::GetDepthStencilState( CComPtr& depthStencilState, const CComPtr& device11 ) const -{ +{ auto cached = s_depthStencilStateCache.find( m_currentDepthStencil ); if( cached != s_depthStencilStateCache.end() ) @@ -126,27 +125,26 @@ ALResult Tr2RenderStateEmulation::GetDepthStencilState( CComPtrsecond; return S_OK; } - - const HRESULT hr = device11->CreateDepthStencilState( &m_currentDepthStencil, &depthStencilState ); + + const HRESULT hr = device11->CreateDepthStencilState( &m_currentDepthStencil, &depthStencilState ); if( hr == D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS ) { s_depthStencilStateCache.clear(); - CR_RETURN_HR( - device11->CreateDepthStencilState( &m_currentDepthStencil, - &depthStencilState ) ); + CR_RETURN_HR( + device11->CreateDepthStencilState( &m_currentDepthStencil, + &depthStencilState ) ); } - else - if( FAILED( hr ) ) + else if( FAILED( hr ) ) { return hr; } - - s_depthStencilStateCache[ m_currentDepthStencil ] = depthStencilState; + + s_depthStencilStateCache[m_currentDepthStencil] = depthStencilState; return S_OK; } ALResult Tr2RenderStateEmulation::GetRasterizerState( CComPtr& rasterizerState, const CComPtr& device11 ) const -{ +{ auto cached = s_rasterizerCache.find( m_currentRasterizer ); if( cached != s_rasterizerCache.end() ) @@ -154,24 +152,23 @@ ALResult Tr2RenderStateEmulation::GetRasterizerState( CComPtrsecond; return S_OK; } - - const HRESULT hr = device11->CreateRasterizerState( &m_currentRasterizer, + + const HRESULT hr = device11->CreateRasterizerState( &m_currentRasterizer, &rasterizerState ); if( hr == D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS ) { s_rasterizerCache.clear(); - CR_RETURN_HR( device11->CreateRasterizerState( &m_currentRasterizer, - &rasterizerState ) ); + CR_RETURN_HR( device11->CreateRasterizerState( &m_currentRasterizer, + &rasterizerState ) ); } - else - if( FAILED( hr ) ) + else if( FAILED( hr ) ) { return hr; } - - s_rasterizerCache[ m_currentRasterizer ] = rasterizerState; + + s_rasterizerCache[m_currentRasterizer] = rasterizerState; return S_OK; } -#endif //DX11? +#endif //DX11? diff --git a/trinityal/dx11/Tr2RenderStateEmulationDx11.h b/trinityal/dx11/Tr2RenderStateEmulationDx11.h index 74e3e3af9..ba257737a 100644 --- a/trinityal/dx11/Tr2RenderStateEmulationDx11.h +++ b/trinityal/dx11/Tr2RenderStateEmulationDx11.h @@ -4,7 +4,7 @@ #ifndef Tr2RenderStateEmulationDx11_h_ #define Tr2RenderStateEmulationDx11_h_ -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../ALResult.h" @@ -18,15 +18,15 @@ // objects. // ------------------------------------------------------------- struct Tr2RenderStateEmulation -{ +{ // sum of current SetRenderState calls for blending, may or may not be what's on the device. We only // track one render target blend because DX9 can't do independent blending, so we don't need to support it. In the // future we want client code to directly build and set their own blend state blocks anyway. - D3D11_BLEND_DESC m_currentBlend; - D3D11_DEPTH_STENCIL_DESC m_currentDepthStencil; - D3D11_RASTERIZER_DESC m_currentRasterizer; - uint32_t m_currentStencilRef; - bool m_separateAlphaBlendEnabled; + D3D11_BLEND_DESC m_currentBlend; + D3D11_DEPTH_STENCIL_DESC m_currentDepthStencil; + D3D11_RASTERIZER_DESC m_currentRasterizer; + uint32_t m_currentStencilRef; + bool m_separateAlphaBlendEnabled; ALResult GetBlendState( CComPtr& blendState, const CComPtr& device11 ) const; @@ -43,7 +43,7 @@ struct Tr2RenderStateEmulation { bool operator()( const D3D11_BLEND_DESC& bd1, const D3D11_BLEND_DESC& bd2 ) const; }; - static TrackableStdUnorderedMap, TBlendHash, TBlendEq> s_blendStateCache; + static TrackableStdUnorderedMap, TBlendHash, TBlendEq> s_blendStateCache; struct TDepthStencilHash { @@ -53,7 +53,7 @@ struct Tr2RenderStateEmulation { bool operator()( const D3D11_DEPTH_STENCIL_DESC& dsd1, const D3D11_DEPTH_STENCIL_DESC& dsd2 ) const; }; - static TrackableStdUnorderedMap, TDepthStencilHash, TDepthStencilEq> s_depthStencilStateCache; + static TrackableStdUnorderedMap, TDepthStencilHash, TDepthStencilEq> s_depthStencilStateCache; struct TRasterizerHash { @@ -63,7 +63,7 @@ struct Tr2RenderStateEmulation { bool operator()( const D3D11_RASTERIZER_DESC& rd1, const D3D11_RASTERIZER_DESC& rd2 ) const; }; - static TrackableStdUnorderedMap, TRasterizerHash, TRasterizerEq> s_rasterizerCache; + static TrackableStdUnorderedMap, TRasterizerHash, TRasterizerEq> s_rasterizerCache; }; #endif // ( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) diff --git a/trinityal/dx11/Tr2ResourceSetALDx11.cpp b/trinityal/dx11/Tr2ResourceSetALDx11.cpp index 6120076ab..d335a3584 100644 --- a/trinityal/dx11/Tr2ResourceSetALDx11.cpp +++ b/trinityal/dx11/Tr2ResourceSetALDx11.cpp @@ -14,225 +14,225 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - Tr2ResourceSetAL::Tr2ResourceSetAL() - :m_isValid( false ), - m_empty( true ), - m_uavCount( 0 ), - m_csUavs( false ) +Tr2ResourceSetAL::Tr2ResourceSetAL() : + m_isValid( false ), + m_empty( true ), + m_uavCount( 0 ), + m_csUavs( false ) +{ +} + +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& /*renderContext*/ ) +{ + Destroy(); + + if( program.GetRegisterMap() != description.m_registerMap ) { + return E_INVALIDARG; } - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& /*renderContext*/ ) - { - Destroy(); + ON_BLOCK_EXIT_WITH_UNUSED( [&] { if( !IsValid() ) Destroy(); } ); - if( program.GetRegisterMap() != description.m_registerMap ) + for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) + { + it->resourceOffset = MAX_RESOURCES; + it->samplerOffset = MAX_RESOURCES; + } + bool hasPsUavs = false; + m_uavOffset = MAX_RESOURCES; + for( uint32_t stageIndex = 0; stageIndex < SHADER_TYPE_COUNT; ++stageIndex ) + { + auto& stage = m_stages[stageIndex]; + for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) { - return E_INVALIDARG; + if( description.m_registerMap.srvs[stageIndex][registerIndex] >= description.m_registerMap.srvCount ) + { + continue; + } + auto& desc = description.m_srv[description.m_registerMap.srvs[stageIndex][registerIndex]]; + switch( desc.type ) + { + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + stage.resources[registerIndex] = desc.buffer.m_buffer->m_srv; + break; + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + stage.resources[registerIndex] = desc.texture.m_texture->m_view[desc.colorSpace]; + break; + case Tr2ResourceSetDescriptionAL::Resource::NONE: + continue; + default: + return E_INVALIDARG; + } + stage.resourceOffset = std::min( stage.resourceOffset, registerIndex ); + stage.resourceCount = std::max( stage.resourceCount, registerIndex + 1 ); } - - ON_BLOCK_EXIT_WITH_UNUSED( [&] { if( !IsValid() ) Destroy(); } ); - - for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) + for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) { - it->resourceOffset = MAX_RESOURCES; - it->samplerOffset = MAX_RESOURCES; + if( description.m_registerMap.samplers[stageIndex][registerIndex] >= description.m_registerMap.samplerCount ) + { + continue; + } + auto& desc = description.m_samplers[description.m_registerMap.samplers[stageIndex][registerIndex]]; + if( desc.type == Tr2ResourceSetDescriptionAL::Sampler::SAMPLER ) + { + stage.samplers[registerIndex] = desc.sampler.m_sampler->m_samplerState; + stage.samplerOffset = std::min( stage.samplerOffset, registerIndex ); + stage.samplerCount = std::max( stage.samplerCount, registerIndex + 1 ); + } } - bool hasPsUavs = false; - m_uavOffset = MAX_RESOURCES; - for( uint32_t stageIndex = 0; stageIndex < SHADER_TYPE_COUNT; ++stageIndex ) + for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) { - auto& stage = m_stages[stageIndex]; - for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) + if( description.m_registerMap.uavs[stageIndex][registerIndex] >= description.m_registerMap.uavCount ) { - if( description.m_registerMap.srvs[stageIndex][registerIndex] >= description.m_registerMap.srvCount ) - { - continue; - } - auto& desc = description.m_srv[description.m_registerMap.srvs[stageIndex][registerIndex]]; - switch( desc.type ) - { - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - stage.resources[registerIndex] = desc.buffer.m_buffer->m_srv; - break; - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - stage.resources[registerIndex] = desc.texture.m_texture->m_view[desc.colorSpace]; - break; - case Tr2ResourceSetDescriptionAL::Resource::NONE: - continue; - default: - return E_INVALIDARG; - } - stage.resourceOffset = std::min( stage.resourceOffset, registerIndex ); - stage.resourceCount = std::max( stage.resourceCount, registerIndex + 1 ); + continue; } - for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) + auto& desc = description.m_uav[description.m_registerMap.uavs[stageIndex][registerIndex]]; + if( desc.type == Tr2ResourceSetDescriptionAL::Resource::NONE ) { - if( description.m_registerMap.samplers[stageIndex][registerIndex] >= description.m_registerMap.samplerCount ) - { - continue; - } - auto& desc = description.m_samplers[description.m_registerMap.samplers[stageIndex][registerIndex]]; - if( desc.type == Tr2ResourceSetDescriptionAL::Sampler::SAMPLER ) - { - stage.samplers[registerIndex] = desc.sampler.m_sampler->m_samplerState; - stage.samplerOffset = std::min( stage.samplerOffset, registerIndex ); - stage.samplerCount = std::max( stage.samplerCount, registerIndex + 1 ); - } + continue; } - for( uint32_t registerIndex = 0; registerIndex < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++registerIndex ) + if( stageIndex != PIXEL_SHADER && stageIndex != COMPUTE_SHADER ) { - if( description.m_registerMap.uavs[stageIndex][registerIndex] >= description.m_registerMap.uavCount ) - { - continue; - } - auto& desc = description.m_uav[description.m_registerMap.uavs[stageIndex][registerIndex]]; - if( desc.type == Tr2ResourceSetDescriptionAL::Resource::NONE ) - { - continue; - } - if( stageIndex != PIXEL_SHADER && stageIndex != COMPUTE_SHADER ) - { - return E_INVALIDARG; - } - if( stageIndex == PIXEL_SHADER ) - { - hasPsUavs = true; - } - else if( hasPsUavs ) + return E_INVALIDARG; + } + if( stageIndex == PIXEL_SHADER ) + { + hasPsUavs = true; + } + else if( hasPsUavs ) + { + return E_INVALIDARG; + } + switch( desc.type ) + { + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + m_uavs[registerIndex] = desc.buffer.m_buffer->m_uav; + m_uavCount = registerIndex + 1; + m_uavOffset = std::min( m_uavOffset, registerIndex ); + break; + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + if( desc.mip < desc.texture.m_texture->m_uav.size() ) { - return E_INVALIDARG; + m_uavs[registerIndex] = desc.texture.m_texture->m_uav[desc.mip]; } - switch( desc.type ) + else { - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - m_uavs[registerIndex] = desc.buffer.m_buffer->m_uav; - m_uavCount = registerIndex + 1; - m_uavOffset = std::min( m_uavOffset, registerIndex ); - break; - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - if( desc.mip < desc.texture.m_texture->m_uav.size() ) - { - m_uavs[registerIndex] = desc.texture.m_texture->m_uav[desc.mip]; - } - else - { - m_uavs[registerIndex] = nullptr; - } - m_uavCount = registerIndex + 1; - m_uavOffset = std::min( m_uavOffset, registerIndex ); - break; - default: - return E_INVALIDARG; + m_uavs[registerIndex] = nullptr; } - m_csUavs = stageIndex == COMPUTE_SHADER; + m_uavCount = registerIndex + 1; + m_uavOffset = std::min( m_uavOffset, registerIndex ); + break; + default: + return E_INVALIDARG; } + m_csUavs = stageIndex == COMPUTE_SHADER; } + } + + if( m_uavCount ) + { + m_empty = false; + m_uavCount -= m_uavOffset; + } + else + { + m_empty = true; + m_uavOffset = 0; + } - if( m_uavCount ) + for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) + { + if( it->resourceCount > it->resourceOffset ) { + it->resourceHash = 0; + for( uint32_t i = it->resourceOffset; i != it->resourceCount; ++i ) + { + it->resourceHash ^= uint32_t( reinterpret_cast( it->resources[i].p ) & 0xffffffff ) << i; + } + it->resourceCount -= it->resourceOffset; m_empty = false; - m_uavCount -= m_uavOffset; } else { - m_empty = true; - m_uavOffset = 0; + it->resourceCount = 0; + it->resourceHash = 0; } - - for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) + if( it->samplerCount > it->samplerOffset ) { - if( it->resourceCount > it->resourceOffset ) - { - it->resourceHash = 0; - for( uint32_t i = it->resourceOffset; i != it->resourceCount; ++i ) - { - it->resourceHash ^= uint32_t( reinterpret_cast( it->resources[i].p ) & 0xffffffff ) << i; - } - it->resourceCount -= it->resourceOffset; - m_empty = false; - } - else - { - it->resourceCount = 0; - it->resourceHash = 0; - } - if( it->samplerCount > it->samplerOffset ) - { - it->samplerHash = 0; - for( uint32_t i = it->samplerOffset; i != it->samplerCount; ++i ) - { - it->samplerHash ^= uint32_t( reinterpret_cast( it->samplers[i].p ) & 0xffffffff ) << i; - } - it->samplerCount -= it->samplerOffset; - m_empty = false; - } - else + it->samplerHash = 0; + for( uint32_t i = it->samplerOffset; i != it->samplerCount; ++i ) { - it->samplerCount = 0; - it->samplerHash = 0; + it->samplerHash ^= uint32_t( reinterpret_cast( it->samplers[i].p ) & 0xffffffff ) << i; } + it->samplerCount -= it->samplerOffset; + m_empty = false; } - m_isValid = true; - return S_OK; - }; - - bool Tr2ResourceSetAL::IsValid() const - { - return m_isValid; - } - - void Tr2ResourceSetAL::Destroy() - { - for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) + else { - it->Destroy(); + it->samplerCount = 0; + it->samplerHash = 0; } - std::fill_n( m_uavs, MAX_RESOURCES, nullptr ); - m_uavCount = 0; - m_uavOffset = 0; - m_isValid = false; - m_empty = true; - m_csUavs = false; } + m_isValid = true; + return S_OK; +}; - Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const +bool Tr2ResourceSetAL::IsValid() const +{ + return m_isValid; +} + +void Tr2ResourceSetAL::Destroy() +{ + for( auto it = std::begin( m_stages ); it != std::end( m_stages ); ++it ) { - return AL_MEMORY_MANAGED; + it->Destroy(); } + std::fill_n( m_uavs, MAX_RESOURCES, nullptr ); + m_uavCount = 0; + m_uavOffset = 0; + m_isValid = false; + m_empty = true; + m_csUavs = false; +} +Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - Tr2ResourceSetAL::StageInput::StageInput() - :resourceCount( 0 ), - resourceOffset( 0 ), - samplerCount( 0 ), - samplerOffset( 0 ), - resourceHash( 0 ), - samplerHash( 0 ) - { - } - void Tr2ResourceSetAL::StageInput::Destroy() - { - std::fill_n( resources, MAX_RESOURCES, nullptr ); - std::fill_n( samplers, MAX_RESOURCES, nullptr ); - resourceCount = 0; - samplerCount = 0; - resourceHash = 0; - samplerHash = 0; - } +Tr2ResourceSetAL::StageInput::StageInput() : + resourceCount( 0 ), + resourceOffset( 0 ), + samplerCount( 0 ), + samplerOffset( 0 ), + resourceHash( 0 ), + samplerHash( 0 ) +{ +} - void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ResourceSetAL"; - description["name"] = m_name; - } +void Tr2ResourceSetAL::StageInput::Destroy() +{ + std::fill_n( resources, MAX_RESOURCES, nullptr ); + std::fill_n( samplers, MAX_RESOURCES, nullptr ); + resourceCount = 0; + samplerCount = 0; + resourceHash = 0; + samplerHash = 0; +} - ALResult Tr2ResourceSetAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ResourceSetAL"; + description["name"] = m_name; +} + +ALResult Tr2ResourceSetAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2ResourceSetALDx11.h b/trinityal/dx11/Tr2ResourceSetALDx11.h index cb27f4ad7..d6aa4b9e7 100644 --- a/trinityal/dx11/Tr2ResourceSetALDx11.h +++ b/trinityal/dx11/Tr2ResourceSetALDx11.h @@ -8,51 +8,51 @@ namespace TrinityALImpl { - class Tr2ResourceSetAL: public Tr2DeviceResourceAL - { - public: - Tr2ResourceSetAL(); +class Tr2ResourceSetAL : public Tr2DeviceResourceAL +{ +public: + Tr2ResourceSetAL(); - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; + ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - static const uint32_t MAX_RESOURCES = 32; +private: + static const uint32_t MAX_RESOURCES = 32; - struct StageInput - { - StageInput(); - void Destroy(); + struct StageInput + { + StageInput(); + void Destroy(); - CComPtr resources[MAX_RESOURCES]; - CComPtr samplers[MAX_RESOURCES]; + CComPtr resources[MAX_RESOURCES]; + CComPtr samplers[MAX_RESOURCES]; - uint32_t resourceCount; - uint32_t resourceOffset; - uint32_t samplerCount; - uint32_t samplerOffset; - uint32_t resourceHash; - uint32_t samplerHash; - }; + uint32_t resourceCount; + uint32_t resourceOffset; + uint32_t samplerCount; + uint32_t samplerOffset; + uint32_t resourceHash; + uint32_t samplerHash; + }; - StageInput m_stages[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + StageInput m_stages[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - CComPtr m_uavs[MAX_RESOURCES]; - uint32_t m_uavOffset; - uint32_t m_uavCount; - std::string m_name; - bool m_csUavs; + CComPtr m_uavs[MAX_RESOURCES]; + uint32_t m_uavOffset; + uint32_t m_uavCount; + std::string m_name; + bool m_csUavs; - bool m_empty; - bool m_isValid; + bool m_empty; + bool m_isValid; - friend class Tr2RenderContextAL; - }; + friend class Tr2RenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2SamplerStateALDx11.cpp b/trinityal/dx11/Tr2SamplerStateALDx11.cpp index 9da1fdda3..f3228a043 100644 --- a/trinityal/dx11/Tr2SamplerStateALDx11.cpp +++ b/trinityal/dx11/Tr2SamplerStateALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2SamplerStateALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" @@ -14,79 +14,79 @@ extern uint32_t g_forceAnisotropy; namespace TrinityALImpl { - Tr2SamplerStateAL::Tr2SamplerStateAL() - { - } +Tr2SamplerStateAL::Tr2SamplerStateAL() +{ +} - ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ) +ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.m_d3dDevice11 ) { - if( !renderContext.m_d3dDevice11 ) - { - return E_FAIL; - } - - D3D11_SAMPLER_DESC samplerDesc; - if( g_forceAnisotropy != 1 && ( description.m_minFilter == TF_ANISOTROPIC || description.m_magFilter == TF_ANISOTROPIC || description.m_mipFilter == TF_ANISOTROPIC ) ) - { - samplerDesc.Filter = D3D11_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); - } - else - { - samplerDesc.Filter = D3D11_ENCODE_BASIC_FILTER( - description.m_minFilter == TF_POINT ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, - description.m_magFilter == TF_POINT ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, - description.m_mipFilter == TF_POINT || description.m_mipFilter == TF_NONE ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, - description.m_isComparisonFilter ? 1 : 0 ); - } - samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressU ); - samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressV ); - samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressW ); - samplerDesc.MipLODBias = description.m_mipLODBias; - samplerDesc.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; - samplerDesc.ComparisonFunc = D3D11_COMPARISON_FUNC( description.m_comparisonFunc ); - samplerDesc.BorderColor[0] = description.m_borderColor[0]; - samplerDesc.BorderColor[1] = description.m_borderColor[1]; - samplerDesc.BorderColor[2] = description.m_borderColor[2]; - samplerDesc.BorderColor[3] = description.m_borderColor[3]; - samplerDesc.MinLOD = description.m_minLOD; - samplerDesc.MaxLOD = description.m_mipFilter == TF_NONE ? description.m_minLOD : description.m_maxLOD; - - m_samplerState = nullptr; - return renderContext.m_d3dDevice11->CreateSamplerState( &samplerDesc, &m_samplerState ); + return E_FAIL; } - void Tr2SamplerStateAL::Destroy() + D3D11_SAMPLER_DESC samplerDesc; + if( g_forceAnisotropy != 1 && ( description.m_minFilter == TF_ANISOTROPIC || description.m_magFilter == TF_ANISOTROPIC || description.m_mipFilter == TF_ANISOTROPIC ) ) { - m_samplerState = nullptr; + samplerDesc.Filter = D3D11_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); } - - uint32_t Tr2SamplerStateAL::GetIndexInHeap() const + else { - return 0xffffffff; + samplerDesc.Filter = D3D11_ENCODE_BASIC_FILTER( + description.m_minFilter == TF_POINT ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, + description.m_magFilter == TF_POINT ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, + description.m_mipFilter == TF_POINT || description.m_mipFilter == TF_NONE ? D3D11_FILTER_TYPE_POINT : D3D11_FILTER_TYPE_LINEAR, + description.m_isComparisonFilter ? 1 : 0 ); } + samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressU ); + samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressV ); + samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MODE( description.m_addressW ); + samplerDesc.MipLODBias = description.m_mipLODBias; + samplerDesc.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; + samplerDesc.ComparisonFunc = D3D11_COMPARISON_FUNC( description.m_comparisonFunc ); + samplerDesc.BorderColor[0] = description.m_borderColor[0]; + samplerDesc.BorderColor[1] = description.m_borderColor[1]; + samplerDesc.BorderColor[2] = description.m_borderColor[2]; + samplerDesc.BorderColor[3] = description.m_borderColor[3]; + samplerDesc.MinLOD = description.m_minLOD; + samplerDesc.MaxLOD = description.m_mipFilter == TF_NONE ? description.m_minLOD : description.m_maxLOD; + + m_samplerState = nullptr; + return renderContext.m_d3dDevice11->CreateSamplerState( &samplerDesc, &m_samplerState ); +} - bool Tr2SamplerStateAL::IsValid() const - { - return m_samplerState != nullptr; - } +void Tr2SamplerStateAL::Destroy() +{ + m_samplerState = nullptr; +} - Tr2ALMemoryType Tr2SamplerStateAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +uint32_t Tr2SamplerStateAL::GetIndexInHeap() const +{ + return 0xffffffff; +} - void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2SamplerStateAL"; - description["name"] = m_name; - } +bool Tr2SamplerStateAL::IsValid() const +{ + return m_samplerState != nullptr; +} - ALResult Tr2SamplerStateAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_samplerState, name ); - return S_OK; - } +Tr2ALMemoryType Tr2SamplerStateAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SamplerStateAL"; + description["name"] = m_name; +} + +ALResult Tr2SamplerStateAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_samplerState, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2SamplerStateALDx11.h b/trinityal/dx11/Tr2SamplerStateALDx11.h index 60794979c..1c7ba9257 100644 --- a/trinityal/dx11/Tr2SamplerStateALDx11.h +++ b/trinityal/dx11/Tr2SamplerStateALDx11.h @@ -2,35 +2,35 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2SamplerStateAL.h" namespace TrinityALImpl { - class Tr2SamplerStateAL : public Tr2DeviceResourceAL - { - public: - Tr2SamplerStateAL(); +class Tr2SamplerStateAL : public Tr2DeviceResourceAL +{ +public: + Tr2SamplerStateAL(); - ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ); - void Destroy(); + ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - uint32_t GetIndexInHeap() const; + uint32_t GetIndexInHeap() const; - bool IsValid() const; + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - CComPtr m_samplerState; - std::string m_name; - friend class Tr2RenderContextAL; - friend class Tr2ResourceSetAL; - }; +private: + CComPtr m_samplerState; + std::string m_name; + friend class Tr2RenderContextAL; + friend class Tr2ResourceSetAL; +}; } diff --git a/trinityal/dx11/Tr2ShaderALDx11.cpp b/trinityal/dx11/Tr2ShaderALDx11.cpp index ad553c03f..b972097ca 100644 --- a/trinityal/dx11/Tr2ShaderALDx11.cpp +++ b/trinityal/dx11/Tr2ShaderALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2ShaderALDx11.h" #include "ALLog.h" @@ -12,190 +12,190 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - Tr2ShaderAL::Tr2ShaderAL() - : m_type( INVALID_SHADER ), - m_pipelineInputHash( 0 ) +Tr2ShaderAL::Tr2ShaderAL() : + m_type( INVALID_SHADER ), + m_pipelineInputHash( 0 ) +{ + m_shader.vertexShader = nullptr; +} + +ALResult Tr2ShaderAL::Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char*, + Tr2PrimaryRenderContextAL& renderContext ) +{ + ReleaseShader(); + + if( renderContext.m_d3dDevice11 == nullptr ) { - m_shader.vertexShader = nullptr; + return E_FAIL; } + if( !signature.samplers.empty() ) + { + return E_INVALIDARG; + } + + m_type = type; - ALResult Tr2ShaderAL::Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char*, - Tr2PrimaryRenderContextAL &renderContext ) + m_bytecode.resize( "Tr2ShaderAL::m_byteCode", bytecode.size ); + if( !m_bytecode.empty() ) { - ReleaseShader(); + memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); + } + + m_signature = signature; - if( renderContext.m_d3dDevice11 == nullptr ) + m_shader.vertexShader = nullptr; + + switch( type ) + { + case VERTEX_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreateVertexShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.vertexShader ) ) ) { + CCP_AL_LOGERR( "Tr2ShaderAL: vertex shader creation failed" ); + m_type = INVALID_SHADER; return E_FAIL; } - if( !signature.samplers.empty() ) + break; + case PIXEL_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreatePixelShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.pixelShader ) ) ) { - return E_INVALIDARG; + CCP_AL_LOGERR( "Tr2ShaderAL: pixel shader creation failed" ); + m_type = INVALID_SHADER; + return E_FAIL; } - - m_type = type; - - m_bytecode.resize( "Tr2ShaderAL::m_byteCode", bytecode.size ); - if( !m_bytecode.empty() ) + break; + case COMPUTE_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreateComputeShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.computeShader ) ) ) { - memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); + CCP_AL_LOGERR( "Tr2ShaderAL: compute shader creation failed" ); + m_type = INVALID_SHADER; + return E_FAIL; } - - m_signature = signature; - - m_shader.vertexShader = nullptr; - - switch( type ) + break; + case GEOMETRY_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreateGeometryShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.geometryShader ) ) ) { - case VERTEX_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreateVertexShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.vertexShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: vertex shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - case PIXEL_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreatePixelShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.pixelShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: pixel shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - case COMPUTE_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreateComputeShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.computeShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: compute shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - case GEOMETRY_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreateGeometryShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.geometryShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: geometry shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - case HULL_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreateHullShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.hullShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: hull shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - case DOMAIN_SHADER: - if( FAILED( renderContext.m_d3dDevice11->CreateDomainShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.domainShader ) ) ) - { - CCP_AL_LOGERR( "Tr2ShaderAL: domain shader creation failed" ); - m_type = INVALID_SHADER; - return E_FAIL; - } - break; - default: - CCP_AL_LOGERR( "Tr2ShaderAL: invalid shader type" ); + CCP_AL_LOGERR( "Tr2ShaderAL: geometry shader creation failed" ); m_type = INVALID_SHADER; - return E_INVALIDARG; + return E_FAIL; } - - if( signature.pipelineInputs.empty() ) + break; + case HULL_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreateHullShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.hullShader ) ) ) { - m_pipelineInputHash = 0; + CCP_AL_LOGERR( "Tr2ShaderAL: hull shader creation failed" ); + m_type = INVALID_SHADER; + return E_FAIL; } - else + break; + case DOMAIN_SHADER: + if( FAILED( renderContext.m_d3dDevice11->CreateDomainShader( bytecode.bytecode, bytecode.size, nullptr, &m_shader.domainShader ) ) ) { - m_pipelineInputHash = uint32_t( CcpHashFNV1( &signature.pipelineInputs[0], sizeof( Tr2ShaderPipelineInputAL ) * signature.pipelineInputs.size() ) ); + CCP_AL_LOGERR( "Tr2ShaderAL: domain shader creation failed" ); + m_type = INVALID_SHADER; + return E_FAIL; } - - return S_OK; + break; + default: + CCP_AL_LOGERR( "Tr2ShaderAL: invalid shader type" ); + m_type = INVALID_SHADER; + return E_INVALIDARG; } - Tr2ShaderAL::~Tr2ShaderAL() + if( signature.pipelineInputs.empty() ) { - ReleaseShader(); + m_pipelineInputHash = 0; } - - void Tr2ShaderAL::Destroy() + else { - if( IsValid() ) - { - ReleaseShader(); - } + m_pipelineInputHash = uint32_t( CcpHashFNV1( &signature.pipelineInputs[0], sizeof( Tr2ShaderPipelineInputAL ) * signature.pipelineInputs.size() ) ); } - bool Tr2ShaderAL::IsValid() const - { - return m_type != INVALID_SHADER && m_shader.vertexShader != nullptr; - } + return S_OK; +} - ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const - { - if( m_type == INVALID_SHADER ) - { - bytecode = Tr2ShaderBytecodeAL(); - return E_FAIL; - } +Tr2ShaderAL::~Tr2ShaderAL() +{ + ReleaseShader(); +} - bytecode.bytecode = m_bytecode.empty() ? nullptr : m_bytecode.get(); - bytecode.size = m_bytecode.size(); - return S_OK; +void Tr2ShaderAL::Destroy() +{ + if( IsValid() ) + { + ReleaseShader(); } +} + +bool Tr2ShaderAL::IsValid() const +{ + return m_type != INVALID_SHADER && m_shader.vertexShader != nullptr; +} - const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const +{ + if( m_type == INVALID_SHADER ) { - return m_signature; + bytecode = Tr2ShaderBytecodeAL(); + return E_FAIL; } - void Tr2ShaderAL::ReleaseShader() + bytecode.bytecode = m_bytecode.empty() ? nullptr : m_bytecode.get(); + bytecode.size = m_bytecode.size(); + return S_OK; +} + +const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +{ + return m_signature; +} + +void Tr2ShaderAL::ReleaseShader() +{ + if( m_shader.vertexShader ) { - if( m_shader.vertexShader ) + switch( m_type ) { - switch( m_type ) - { - case VERTEX_SHADER: - m_shader.vertexShader->Release(); - break; - case PIXEL_SHADER: - m_shader.pixelShader->Release(); - break; - case COMPUTE_SHADER: - m_shader.computeShader->Release(); - break; - case GEOMETRY_SHADER: - m_shader.geometryShader->Release(); - break; - case HULL_SHADER: - m_shader.hullShader->Release(); - break; - case DOMAIN_SHADER: - m_shader.domainShader->Release(); - break; - } - m_shader.vertexShader = nullptr; + case VERTEX_SHADER: + m_shader.vertexShader->Release(); + break; + case PIXEL_SHADER: + m_shader.pixelShader->Release(); + break; + case COMPUTE_SHADER: + m_shader.computeShader->Release(); + break; + case GEOMETRY_SHADER: + m_shader.geometryShader->Release(); + break; + case HULL_SHADER: + m_shader.hullShader->Release(); + break; + case DOMAIN_SHADER: + m_shader.domainShader->Release(); + break; } - m_type = INVALID_SHADER; + m_shader.vertexShader = nullptr; } + m_type = INVALID_SHADER; +} - void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ShaderAL"; - description["shader"] = std::to_string( int( GetType() ) ); - description["size"] = std::to_string( m_bytecode.size() ); - description["name"] = m_name; - } +void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderAL"; + description["shader"] = std::to_string( int( GetType() ) ); + description["size"] = std::to_string( m_bytecode.size() ); + description["name"] = m_name; +} - ALResult Tr2ShaderAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_shader.vertexShader, name ); - return S_OK; - } +ALResult Tr2ShaderAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_shader.vertexShader, name ); + return S_OK; +} } #endif diff --git a/trinityal/dx11/Tr2ShaderALDx11.h b/trinityal/dx11/Tr2ShaderALDx11.h index 9f4a31098..edc50baac 100644 --- a/trinityal/dx11/Tr2ShaderALDx11.h +++ b/trinityal/dx11/Tr2ShaderALDx11.h @@ -10,66 +10,71 @@ namespace TrinityALImpl { - // ------------------------------------------------------------- - // Description: - // A low level wrapper around shaders / shader programs. DX11 - // specific version will also hold on to byte code for the - // shader as this is needed for construction of input layouts. - // Avoid using this class directly; instead use effects and Tr2Effect. - // 32bit - no support for shader blobs > 4 gig - // ------------------------------------------------------------- - class Tr2ShaderAL : - public Tr2DeviceResourceAL +// ------------------------------------------------------------- +// Description: +// A low level wrapper around shaders / shader programs. DX11 +// specific version will also hold on to byte code for the +// shader as this is needed for construction of input layouts. +// Avoid using this class directly; instead use effects and Tr2Effect. +// 32bit - no support for shader blobs > 4 gig +// ------------------------------------------------------------- +class Tr2ShaderAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderAL(); + ~Tr2ShaderAL(); + + ALResult Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ); + + void Destroy(); + + bool IsValid() const; + Tr2RenderContextEnum::ShaderType GetType() const + { + return m_type; + } + ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; + const Tr2ShaderSignatureAL& GetSignature() const; + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2ShaderAL(); - ~Tr2ShaderAL(); - - ALResult Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ); - - void Destroy(); - - bool IsValid() const; - Tr2RenderContextEnum::ShaderType GetType() const { return m_type; } - ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; - const Tr2ShaderSignatureAL& GetSignature() const; - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2ShaderAL( const Tr2ShaderAL& shader ); - Tr2ShaderAL& operator=( const Tr2ShaderAL& shader ); - - void ReleaseShader(); - - Tr2RenderContextEnum::ShaderType m_type; - CcpMallocBuffer m_bytecode; - Tr2ShaderSignatureAL m_signature; - uint32_t m_pipelineInputHash; - union Shader - { - ID3D11VertexShader* vertexShader; - ID3D11PixelShader* pixelShader; - ID3D11ComputeShader* computeShader; - ID3D11GeometryShader* geometryShader; - ID3D11HullShader* hullShader; - ID3D11DomainShader* domainShader; - }; - Shader m_shader; - std::string m_name; - - friend class Tr2RenderContextAL; - friend class Tr2ShaderProgramAL; - friend class Tr2VertexLayoutAL; + return AL_MEMORY_MANAGED; + } + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2ShaderAL( const Tr2ShaderAL& shader ); + Tr2ShaderAL& operator=( const Tr2ShaderAL& shader ); + + void ReleaseShader(); + + Tr2RenderContextEnum::ShaderType m_type; + CcpMallocBuffer m_bytecode; + Tr2ShaderSignatureAL m_signature; + uint32_t m_pipelineInputHash; + union Shader + { + ID3D11VertexShader* vertexShader; + ID3D11PixelShader* pixelShader; + ID3D11ComputeShader* computeShader; + ID3D11GeometryShader* geometryShader; + ID3D11HullShader* hullShader; + ID3D11DomainShader* domainShader; }; + Shader m_shader; + std::string m_name; + + friend class Tr2RenderContextAL; + friend class Tr2ShaderProgramAL; + friend class Tr2VertexLayoutAL; +}; } #endif diff --git a/trinityal/dx11/Tr2ShaderProgramALDx11.cpp b/trinityal/dx11/Tr2ShaderProgramALDx11.cpp index ff2a65a02..c8f293647 100644 --- a/trinityal/dx11/Tr2ShaderProgramALDx11.cpp +++ b/trinityal/dx11/Tr2ShaderProgramALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2ShaderProgramALDx11.h" #include "Tr2ShaderALDx11.h" @@ -13,124 +13,124 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - Tr2ShaderProgramAL::Tr2ShaderProgramAL() - :m_isValid( false ) +Tr2ShaderProgramAL::Tr2ShaderProgramAL() : + m_isValid( false ) +{ +} + +ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { + return E_INVALIDCALL; } - ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) + if( count == 0 ) { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + return E_INVALIDARG; + } - if( count == 0 ) + for( size_t i = 0; i < count; ++i ) + { + if( !shaders[i].IsValid() ) { return E_INVALIDARG; } - - for( size_t i = 0; i < count; ++i ) + switch( shaders[i].GetType() ) { - if( !shaders[i].IsValid() ) + case VERTEX_SHADER: + if( m_shaders.vertexShader ) + { + return E_INVALIDARG; + } + m_shaders.vertexShader = shaders[i].m_shader->m_shader.vertexShader; + m_vertexShader = shaders[i]; + break; + case PIXEL_SHADER: + if( m_shaders.pixelShader ) + { + return E_INVALIDARG; + } + m_shaders.pixelShader = shaders[i].m_shader->m_shader.pixelShader; + break; + case COMPUTE_SHADER: + if( m_shaders.computeShader ) + { + return E_INVALIDARG; + } + m_shaders.computeShader = shaders[i].m_shader->m_shader.computeShader; + break; + case GEOMETRY_SHADER: + if( m_shaders.geometryShader ) { return E_INVALIDARG; } - switch( shaders[i].GetType() ) + m_shaders.geometryShader = shaders[i].m_shader->m_shader.geometryShader; + break; + case HULL_SHADER: + if( m_shaders.hullShader ) { - case VERTEX_SHADER: - if( m_shaders.vertexShader ) - { - return E_INVALIDARG; - } - m_shaders.vertexShader = shaders[i].m_shader->m_shader.vertexShader; - m_vertexShader = shaders[i]; - break; - case PIXEL_SHADER: - if( m_shaders.pixelShader ) - { - return E_INVALIDARG; - } - m_shaders.pixelShader = shaders[i].m_shader->m_shader.pixelShader; - break; - case COMPUTE_SHADER: - if( m_shaders.computeShader ) - { - return E_INVALIDARG; - } - m_shaders.computeShader = shaders[i].m_shader->m_shader.computeShader; - break; - case GEOMETRY_SHADER: - if( m_shaders.geometryShader ) - { - return E_INVALIDARG; - } - m_shaders.geometryShader = shaders[i].m_shader->m_shader.geometryShader; - break; - case HULL_SHADER: - if( m_shaders.hullShader ) - { - return E_INVALIDARG; - } - m_shaders.hullShader = shaders[i].m_shader->m_shader.hullShader; - break; - case DOMAIN_SHADER: - if( m_shaders.domainShader ) - { - return E_INVALIDARG; - } - m_shaders.domainShader = shaders[i].m_shader->m_shader.domainShader; - break; - default: return E_INVALIDARG; } + m_shaders.hullShader = shaders[i].m_shader->m_shader.hullShader; + break; + case DOMAIN_SHADER: + if( m_shaders.domainShader ) + { + return E_INVALIDARG; + } + m_shaders.domainShader = shaders[i].m_shader->m_shader.domainShader; + break; + default: + return E_INVALIDARG; } - m_registerMap = Tr2RegisterMapAL( shaders, count ); - - m_isValid = true; - return S_OK; } + m_registerMap = Tr2RegisterMapAL( shaders, count ); - void Tr2ShaderProgramAL::Destroy() - { - m_shaders.vertexShader = nullptr; - m_shaders.pixelShader = nullptr; - m_shaders.computeShader = nullptr; - m_shaders.geometryShader = nullptr; - m_shaders.hullShader = nullptr; - m_shaders.domainShader = nullptr; - m_isValid = false; - m_vertexShader = ::Tr2ShaderAL(); - m_registerMap = Tr2RegisterMapAL(); - } + m_isValid = true; + return S_OK; +} - bool Tr2ShaderProgramAL::IsValid() const - { - return m_isValid; - } +void Tr2ShaderProgramAL::Destroy() +{ + m_shaders.vertexShader = nullptr; + m_shaders.pixelShader = nullptr; + m_shaders.computeShader = nullptr; + m_shaders.geometryShader = nullptr; + m_shaders.hullShader = nullptr; + m_shaders.domainShader = nullptr; + m_isValid = false; + m_vertexShader = ::Tr2ShaderAL(); + m_registerMap = Tr2RegisterMapAL(); +} - Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +bool Tr2ShaderProgramAL::IsValid() const +{ + return m_isValid; +} - void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ShaderProgramAL"; - description["name"] = m_name; - } +Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const - { - return m_registerMap; - } +void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderProgramAL"; + description["name"] = m_name; +} - ALResult Tr2ShaderProgramAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const +{ + return m_registerMap; +} + +ALResult Tr2ShaderProgramAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2ShaderProgramALDx11.h b/trinityal/dx11/Tr2ShaderProgramALDx11.h index 481a87331..399fbfb8d 100644 --- a/trinityal/dx11/Tr2ShaderProgramALDx11.h +++ b/trinityal/dx11/Tr2ShaderProgramALDx11.h @@ -6,47 +6,47 @@ #include "../include/Tr2ShaderAL.h" #include "../include/Tr2ResourceSetAL.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) namespace TrinityALImpl { - class Tr2ShaderProgramAL : public Tr2DeviceResourceAL - { - public: - Tr2ShaderProgramAL(); +class Tr2ShaderProgramAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderProgramAL(); - ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; + Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - const Tr2RegisterMapAL& GetRegisterMap() const; - ALResult SetName( const char* name ); + const Tr2RegisterMapAL& GetRegisterMap() const; + ALResult SetName( const char* name ); - private: - struct Shaders - { - CComPtr vertexShader; - CComPtr pixelShader; - CComPtr computeShader; - CComPtr geometryShader; - CComPtr hullShader; - CComPtr domainShader; - }; +private: + struct Shaders + { + CComPtr vertexShader; + CComPtr pixelShader; + CComPtr computeShader; + CComPtr geometryShader; + CComPtr hullShader; + CComPtr domainShader; + }; - ::Tr2ShaderAL m_vertexShader; - Shaders m_shaders; - Tr2RegisterMapAL m_registerMap; - std::string m_name; + ::Tr2ShaderAL m_vertexShader; + Shaders m_shaders; + Tr2RegisterMapAL m_registerMap; + std::string m_name; - bool m_isValid; + bool m_isValid; - friend class ::Tr2RenderContextAL; - }; + friend class ::Tr2RenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx11/Tr2StreamlineALDx11.cpp b/trinityal/dx11/Tr2StreamlineALDx11.cpp index f66a63165..10fa1cc12 100644 --- a/trinityal/dx11/Tr2StreamlineALDx11.cpp +++ b/trinityal/dx11/Tr2StreamlineALDx11.cpp @@ -17,583 +17,583 @@ extern bool g_skipNvidiaStreamline; namespace StreamlineUtils { - void Log( sl::LogType type, const char* msg ) +void Log( sl::LogType type, const char* msg ) +{ + switch( type ) { - switch( type ) - { - case sl::LogType::eInfo: - CCP_LOGNOTICE( msg ); - break; + case sl::LogType::eInfo: + CCP_LOGNOTICE( msg ); + break; - case sl::LogType::eWarn: - CCP_LOGWARN( msg ); - break; + case sl::LogType::eWarn: + CCP_LOGWARN( msg ); + break; - case sl::LogType::eError: - CCP_LOGERR( msg ); - break; - default: - break; - } + case sl::LogType::eError: + CCP_LOGERR( msg ); + break; + default: + break; } +} - sl::Resource GenerateTextureResource( Tr2TextureAL* texture ) +sl::Resource GenerateTextureResource( Tr2TextureAL* texture ) +{ + if( texture && texture->IsValid() ) { - if( texture && texture->IsValid() ) - { - return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx11(), nullptr, nullptr, 0 }; - } - else - { - return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; - } + return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx11(), nullptr, nullptr, 0 }; } - - sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) + else { - return renderContext.m_context; + return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; } } -namespace Tr2Streamline +sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) { - // Static Streamline interface - // Responsible for checking if it is available, initializing the Streamline framework and keeping tabs on plugin availability - Status s_status = Status::UNCHECKED; - bool s_reset = false; - bool s_reflexEnabled = false; - bool s_framegenEnabled = false; - Tr2DlssPlugin* s_dlssPlugin = nullptr; - Tr2NisPlugin* s_nisPlugin = nullptr; - HMODULE s_streamlineModule; + return renderContext.m_context; +} +} +namespace Tr2Streamline +{ +// Static Streamline interface +// Responsible for checking if it is available, initializing the Streamline framework and keeping tabs on plugin availability +Status s_status = Status::UNCHECKED; +bool s_reset = false; +bool s_reflexEnabled = false; +bool s_framegenEnabled = false; +Tr2DlssPlugin* s_dlssPlugin = nullptr; +Tr2NisPlugin* s_nisPlugin = nullptr; +HMODULE s_streamlineModule; - sl::FrameToken* s_frameToken = 0; - sl::Constants s_commonConstants = {}; - std::map s_pluginInfo = { - { - StreamlineUtils::SP_DLSS, - { "dlss", sl::kFeatureDLSS, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_DLSSG, - { "dlss_g", sl::kFeatureDLSS_G, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_REFLEX, - { "reflex", sl::kFeatureReflex, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_NIS, - { "nis", sl::kFeatureNIS, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_DEBUG, - { "imgui", sl::kFeatureImGUI, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - }; +sl::FrameToken* s_frameToken = 0; +sl::Constants s_commonConstants = {}; - sl::float2 AsFloat2( float f[2] ) +std::map s_pluginInfo = { { - return sl::float2( f[0], f[1] ); - } - - sl::float3 AsFloat3( float f[3] ) + StreamlineUtils::SP_DLSS, + { "dlss", sl::kFeatureDLSS, StreamlineUtils::SLPA_UNKNOWN, false }, + }, { - return sl::float3( f[0], f[1], f[2] ); - } - - sl::float4 AsFloat4( float f[4] ) + StreamlineUtils::SP_DLSSG, + { "dlss_g", sl::kFeatureDLSS_G, StreamlineUtils::SLPA_UNKNOWN, false }, + }, { - return sl::float4( f[0], f[1], f[2], f[3] ); - } - - sl::float4x4 AsFloat4x4( float f[16] ) + StreamlineUtils::SP_REFLEX, + { "reflex", sl::kFeatureReflex, StreamlineUtils::SLPA_UNKNOWN, false }, + }, { - sl::float4x4 m; - m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); - m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); - m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); - m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); - return m; - } + StreamlineUtils::SP_NIS, + { "nis", sl::kFeatureNIS, StreamlineUtils::SLPA_UNKNOWN, false }, + }, + { + StreamlineUtils::SP_DEBUG, + { "imgui", sl::kFeatureImGUI, StreamlineUtils::SLPA_UNKNOWN, false }, + }, +}; + +sl::float2 AsFloat2( float f[2] ) +{ + return sl::float2( f[0], f[1] ); +} + +sl::float3 AsFloat3( float f[3] ) +{ + return sl::float3( f[0], f[1], f[2] ); +} + +sl::float4 AsFloat4( float f[4] ) +{ + return sl::float4( f[0], f[1], f[2], f[3] ); +} + +sl::float4x4 AsFloat4x4( float f[16] ) +{ + sl::float4x4 m; + m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); + m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); + m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); + m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); + return m; +} - bool IsAvailable() +bool IsAvailable() +{ + if( s_status == UNCHECKED ) { - if( s_status == UNCHECKED ) - { - s_status = UNAVAILABLE; + s_status = UNAVAILABLE; - if( !g_skipNvidiaStreamline ) + if( !g_skipNvidiaStreamline ) + { + wchar_t abs_path[2048]; + auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 2048, abs_path, nullptr ); + bool available = false; + if( size == 0 ) + { + CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); + } + else { - wchar_t abs_path[2048]; - auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 2048, abs_path, nullptr ); - bool available = false; - if( size == 0 ) - { - CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); - } - else - { - available = sl::security::verifyEmbeddedSignature( abs_path ); - s_streamlineModule = LoadLibraryW( abs_path ); - available = !!s_streamlineModule; - } - CCP_LOGNOTICE( "Nvidia Streamline is %s", available ? "enabled" : "disabled" ); - s_status = available ? AVAILABLE : UNAVAILABLE; + available = sl::security::verifyEmbeddedSignature( abs_path ); + s_streamlineModule = LoadLibraryW( abs_path ); + available = !!s_streamlineModule; } + CCP_LOGNOTICE( "Nvidia Streamline is %s", available ? "enabled" : "disabled" ); + s_status = available ? AVAILABLE : UNAVAILABLE; } - return s_status != UNAVAILABLE; } + return s_status != UNAVAILABLE; +} - bool Initialize() +bool Initialize() +{ + if( !IsAvailable() ) { - if( !IsAvailable() ) - { - return false; - } + return false; + } - if( s_status != AVAILABLE ) - { - return s_status == INITIALIZED; - } + if( s_status != AVAILABLE ) + { + return s_status == INITIALIZED; + } - sl::Preferences pref{}; + sl::Preferences pref{}; - #ifndef NDEBUG - pref.showConsole = true; // for debugging, set to false in production - #else - pref.showConsole = false; - #endif - auto features = std::vector(); +#ifndef NDEBUG + pref.showConsole = true; // for debugging, set to false in production +#else + pref.showConsole = false; +#endif + auto features = std::vector(); - for( auto& pluginInfo : s_pluginInfo ) - { - features.push_back( pluginInfo.second.streamlineID ); - } - #ifndef NDEBUG - features.push_back( sl::kFeatureImGUI ); - #endif + for( auto& pluginInfo : s_pluginInfo ) + { + features.push_back( pluginInfo.second.streamlineID ); + } +#ifndef NDEBUG + features.push_back( sl::kFeatureImGUI ); +#endif - sl::Feature* featuresToEnable = features.data(); - pref.numFeaturesToLoad = (uint32_t)features.size(); + sl::Feature* featuresToEnable = features.data(); + pref.numFeaturesToLoad = (uint32_t)features.size(); - pref.logLevel = sl::LogLevel::eDefault; + pref.logLevel = sl::LogLevel::eDefault; - pref.featuresToLoad = featuresToEnable; - pref.logMessageCallback = StreamlineUtils::Log; - pref.applicationId = EVE_ONLINE_APP_ID; - pref.engine = sl::EngineType::eCustom; - pref.flags |= sl::PreferenceFlags::eAllowOTA; - pref.flags |= sl::PreferenceFlags::eUseManualHooking; + pref.featuresToLoad = featuresToEnable; + pref.logMessageCallback = StreamlineUtils::Log; + pref.applicationId = EVE_ONLINE_APP_ID; + pref.engine = sl::EngineType::eCustom; + pref.flags |= sl::PreferenceFlags::eAllowOTA; + pref.flags |= sl::PreferenceFlags::eUseManualHooking; - DECLARE_STATIC_SL_FUNC( slInit ); - if( SL_FAILED( res, s_slInit( pref, sl::kSDKVersion ) ) ) + DECLARE_STATIC_SL_FUNC( slInit ); + if( SL_FAILED( res, s_slInit( pref, sl::kSDKVersion ) ) ) + { + s_status = UNINITIALIZED; + + if( res == sl::Result::eErrorDriverOutOfDate ) { - s_status = UNINITIALIZED; + CCP_LOGWARN( "Could not initialize NVidia Streamline due to drivers being out of date" ); + } - if( res == sl::Result::eErrorDriverOutOfDate ) - { - CCP_LOGWARN( "Could not initialize NVidia Streamline due to drivers being out of date" ); - } + return false; + } - return false; - } + CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); + s_status = INITIALIZED; + return true; +} - CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); - s_status = INITIALIZED; - return true; +void CreateProxy( void* native, void** proxy ) +{ + proxy = &native; + + if( s_status == UNAVAILABLE ) + { + return; } + DECLARE_STATIC_SL_FUNC( slUpgradeInterface ); - void CreateProxy( void* native, void** proxy ) + if( SL_FAILED( res, s_slUpgradeInterface( proxy ) ) ) { - proxy = &native; + CCP_LOGWARN( "Could not upgrade interface to proxy device (%d)", res ); + } + CCP_ASSERT( proxy != nullptr ); +} - if( s_status == UNAVAILABLE ) - { - return; - } - DECLARE_STATIC_SL_FUNC( slUpgradeInterface ); +void CreateNative( void* proxy, void** native ) +{ + if( s_status == UNAVAILABLE ) + { + return; + } + DECLARE_STATIC_SL_FUNC( slGetNativeInterface ); - if( SL_FAILED( res, s_slUpgradeInterface( proxy ) ) ) - { - CCP_LOGWARN( "Could not upgrade interface to proxy device (%d)", res ); - } - CCP_ASSERT( proxy != nullptr ); + if( SL_FAILED( res, s_slGetNativeInterface( proxy, native ) ) ) + { + CCP_LOGWARN( "Could not get native interface from proxy device (%d)", res ); } + CCP_ASSERT( native != nullptr ); +} - void CreateNative( void* proxy, void** native ) +void Attach( void* device ) +{ + if( s_status == UNAVAILABLE ) { - if( s_status == UNAVAILABLE ) - { - return; - } - DECLARE_STATIC_SL_FUNC( slGetNativeInterface ); + return; + } + DECLARE_STATIC_SL_FUNC( slSetD3DDevice ); - if( SL_FAILED( res, s_slGetNativeInterface( proxy, native ) ) ) - { - CCP_LOGWARN( "Could not get native interface from proxy device (%d)", res ); - } - CCP_ASSERT( native != nullptr ); + if( SL_FAILED( res, s_slSetD3DDevice( device ) ) ) + { + CCP_LOGWARN( "Could not attach NVidia Streamline to device (%d)", res ); + return; } - void Attach( void* device ) + s_status = ATTACHED; + CCP_LOGNOTICE( "NVidia Streamline successfully attached to device and adapter" ); +} + +void Shutdown() +{ + if( s_status == ATTACHED || s_status == INITIALIZED ) + { + // Un-set all tags + sl::ResourceTag inputs[] = { + sl::ResourceTag{ nullptr, sl::kBufferTypeDepth, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeMotionVectors, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeScalingInputColor, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeScalingOutputColor, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeHUDLessColor, sl::ResourceLifecycle::eValidUntilPresent } + }; + DECLARE_STATIC_SL_FUNC( slSetTag ); + s_slSetTag( 0, inputs, _countof( inputs ), nullptr ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DEBUG, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_NIS, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSSG, false ); + + DECLARE_STATIC_SL_FUNC( slShutdown ); + + if( SL_FAILED( result, s_slShutdown() ) ) + { + CCP_LOGWARN( "Could not shutdown NVidia Streamline (%d)", result ); + } + } + s_status = UNCHECKED; + // unload the streamline module + s_streamlineModule = nullptr; +} + +void UpdateFrameToken() +{ + if( s_status == ATTACHED ) { - if( s_status == UNAVAILABLE ) - { - return; - } - DECLARE_STATIC_SL_FUNC( slSetD3DDevice ); + DECLARE_STATIC_SL_FUNC( slGetNewFrameToken ); - if( SL_FAILED( res, s_slSetD3DDevice( device ) ) ) + if( SL_FAILED( res, s_slGetNewFrameToken( s_frameToken, nullptr ) ) ) { - CCP_LOGWARN( "Could not attach NVidia Streamline to device (%d)", res ); + CCP_LOGERR( "Could not get new frame token for Nvidia Streamline (%d)", res ); return; } - - s_status = ATTACHED; - CCP_LOGNOTICE( "NVidia Streamline successfully attached to device and adapter" ); + s_reset = false; } +} - void Shutdown() +// functions to create dx stuff from streamline or not +HRESULT SlCreateDXGIFactory( REFIID id, void** factory ) +{ + if( !g_skipNvidiaStreamline ) { - if( s_status == ATTACHED || s_status == INITIALIZED ) - { - // Un-set all tags - sl::ResourceTag inputs[] = { - sl::ResourceTag{ nullptr, sl::kBufferTypeDepth, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeMotionVectors, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeScalingInputColor, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeScalingOutputColor, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeHUDLessColor, sl::ResourceLifecycle::eValidUntilPresent } - }; - DECLARE_STATIC_SL_FUNC( slSetTag ); - s_slSetTag( 0, inputs, _countof( inputs ), nullptr ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DEBUG, false ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_NIS, false ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, false ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSSG, false ); - - DECLARE_STATIC_SL_FUNC( slShutdown ); - - if( SL_FAILED( result, s_slShutdown() ) ) - { - CCP_LOGWARN( "Could not shutdown NVidia Streamline (%d)", result ); - } - } - s_status = UNCHECKED; - // unload the streamline module - s_streamlineModule = nullptr; + typedef HRESULT( WINAPI * PFunCreateDXGIFactory )( REFIID, void** ); + static auto slCreateDXGIFactory = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory" ) ); + return slCreateDXGIFactory( id, factory ); } + return CreateDXGIFactory( id, factory ); +} - void UpdateFrameToken() +HRESULT SlCreateDXGIFactory1( REFIID id, void** factory1 ) +{ + if( !g_skipNvidiaStreamline ) { - if( s_status == ATTACHED ) - { - DECLARE_STATIC_SL_FUNC( slGetNewFrameToken ); - - if( SL_FAILED( res, s_slGetNewFrameToken( s_frameToken, nullptr ) ) ) - { - CCP_LOGERR( "Could not get new frame token for Nvidia Streamline (%d)", res ); - return; - } - s_reset = false; - } + typedef HRESULT( WINAPI * PFunCreateDXGIFactory1 )( REFIID, void** ); + static auto slCreateDXGIFactory1 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory1" ) ); + return slCreateDXGIFactory1( id, factory1 ); } + return CreateDXGIFactory1( id, factory1 ); +} - // functions to create dx stuff from streamline or not - HRESULT SlCreateDXGIFactory( REFIID id, void** factory ) +bool IsValid( StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info ) +{ + auto foundThing = s_pluginInfo.find( plugin ); + if( foundThing == s_pluginInfo.end() ) { - if( !g_skipNvidiaStreamline ) - { - typedef HRESULT( WINAPI * PFunCreateDXGIFactory )( REFIID, void** ); - static auto slCreateDXGIFactory = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory" ) ); - return slCreateDXGIFactory( id, factory ); - } - return CreateDXGIFactory( id, factory ); + return false; } + info = foundThing->second; + return info.available != StreamlineUtils::SLPA_NO; +} - HRESULT SlCreateDXGIFactory1( REFIID id, void** factory1 ) +bool IsAvailable( StreamlineUtils::StreamlinePlugin plugin ) +{ + if( s_status != ATTACHED ) { - if( !g_skipNvidiaStreamline ) - { - typedef HRESULT( WINAPI * PFunCreateDXGIFactory1 )( REFIID, void** ); - static auto slCreateDXGIFactory1 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory1" ) ); - return slCreateDXGIFactory1( id, factory1 ); - } - return CreateDXGIFactory1( id, factory1 ); + return false; } + // We are using NULL adapter on purpose + sl::AdapterInfo adapterInfo{}; - bool IsValid( StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info ) + StreamlineUtils::PluginInfo info; + if( !IsValid( plugin, info ) ) { - auto foundThing = s_pluginInfo.find( plugin ); - if( foundThing == s_pluginInfo.end() ) - { - return false; - } - info = foundThing->second; - return info.available != StreamlineUtils::SLPA_NO; + return false; } - - bool IsAvailable( StreamlineUtils::StreamlinePlugin plugin ) + if( info.available == StreamlineUtils::SLPA_YES ) { - if( s_status != ATTACHED ) - { - return false; - } - // We are using NULL adapter on purpose - sl::AdapterInfo adapterInfo{}; - - StreamlineUtils::PluginInfo info; - if( !IsValid( plugin, info ) ) - { - return false; - } - if( info.available == StreamlineUtils::SLPA_YES ) - { - return true; - } + return true; + } - uint32_t pluginId = info.streamlineID; + uint32_t pluginId = info.streamlineID; - DECLARE_STATIC_SL_FUNC( slIsFeatureSupported ); - auto result = s_slIsFeatureSupported( pluginId, adapterInfo ); - if( result != sl::Result::eOk ) + DECLARE_STATIC_SL_FUNC( slIsFeatureSupported ); + auto result = s_slIsFeatureSupported( pluginId, adapterInfo ); + if( result != sl::Result::eOk ) + { + CCP_LOGWARN( "NVidia Streamline plugin '%s' is not supported", info.pluginName ); + switch( result ) { - CCP_LOGWARN( "NVidia Streamline plugin '%s' is not supported", info.pluginName ); - switch( result ) - { - case sl::Result::eErrorOSOutOfDate: // inform user to update OS - CCP_LOGWARN( "OS is out of date, please update OS to use %s", info.pluginName ); - break; - case sl::Result::eErrorDriverOutOfDate: // inform user to update driver - CCP_LOGWARN( "Driver is out of date, please update driver to use %s", info.pluginName ); - break; - case sl::Result::eErrorAdapterNotSupported: - CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); - default: - CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); - }; - info.available = StreamlineUtils::SLPA_NO; - s_pluginInfo[plugin] = info; - return false; - } - - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", info.pluginName ); - info.available = StreamlineUtils::SLPA_YES; + case sl::Result::eErrorOSOutOfDate: // inform user to update OS + CCP_LOGWARN( "OS is out of date, please update OS to use %s", info.pluginName ); + break; + case sl::Result::eErrorDriverOutOfDate: // inform user to update driver + CCP_LOGWARN( "Driver is out of date, please update driver to use %s", info.pluginName ); + break; + case sl::Result::eErrorAdapterNotSupported: + CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); + default: + CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); + }; + info.available = StreamlineUtils::SLPA_NO; s_pluginInfo[plugin] = info; - return true; + return false; } + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", info.pluginName ); + info.available = StreamlineUtils::SLPA_YES; + s_pluginInfo[plugin] = info; + return true; +} + - void MarkFrameStart() +void MarkFrameStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker eRenderSubmitStart(%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker eRenderSubmitStart(%d)", result ); } } +} - void MarkFrameEnd() +void MarkFrameEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker eRenderSubmitEnd(%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker eRenderSubmitEnd(%d)", result ); } } +} - void MarkPresentStart() +void MarkPresentStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentStart (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentStart (%d)", result ); } } +} - void MarkPresentEnd() +void MarkPresentEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } - void MarkUpdateStart() +} +void MarkUpdateStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } - void MarkUpdateEnd() +} +void MarkUpdateEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } +} + +bool IsRunning() +{ + return s_dlssPlugin != nullptr; +} + +bool GetDlssPlugin( Tr2DlssPlugin& plugin ) +{ + if( s_dlssPlugin == nullptr ) + { + return false; + } + plugin = *s_dlssPlugin; + return true; +} - bool IsRunning() +bool GetNisPlugin( Tr2NisPlugin& plugin ) +{ + if( s_nisPlugin == nullptr ) { - return s_dlssPlugin != nullptr; + return false; } + plugin = *s_nisPlugin; + return true; +} - bool GetDlssPlugin( Tr2DlssPlugin& plugin ) +void Toggle( StreamlineUtils::StreamlinePlugin plugin, bool enable ) +{ + StreamlineUtils::PluginInfo info; + if( !IsAvailable( plugin ) || !IsValid( plugin, info ) ) { - if( s_dlssPlugin == nullptr ) - { - return false; - } - plugin = *s_dlssPlugin; - return true; + return; } - bool GetNisPlugin( Tr2NisPlugin& plugin ) + // check if the plugin is availabe + if( s_pluginInfo[plugin].created == enable ) { - if( s_nisPlugin == nullptr ) - { - return false; - } - plugin = *s_nisPlugin; - return true; + // don't need to do anything + CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it is already %s", enable ? "enable" : "disable", info.pluginName, enable ? "enabled" : "disabled" ); + return; } - void Toggle( StreamlineUtils::StreamlinePlugin plugin, bool enable ) + uint32_t pluginId = info.streamlineID; + + DECLARE_STATIC_SL_FUNC( slSetFeatureLoaded ); + if( SL_FAILED( res, s_slSetFeatureLoaded( pluginId, enable ) ) ) { - StreamlineUtils::PluginInfo info; - if( !IsAvailable( plugin ) || !IsValid( plugin, info ) ) - { - return; - } + CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it failed (%d)", enable ? "enable" : "disable", info.pluginName, res ); + return; + } - // check if the plugin is availabe - if( s_pluginInfo[plugin].created == enable ) - { - // don't need to do anything - CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it is already %s", enable ? "enable" : "disable", info.pluginName, enable ? "enabled" : "disabled" ); - return; - } + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is now %s", info.pluginName, enable ? "enabled" : "disabled" ); - uint32_t pluginId = info.streamlineID; + s_pluginInfo[plugin].created = enable; - DECLARE_STATIC_SL_FUNC( slSetFeatureLoaded ); - if( SL_FAILED( res, s_slSetFeatureLoaded( pluginId, enable ) ) ) + // Setup/delete the plugin + switch( plugin ) + { + case StreamlineUtils::SP_DLSS: + s_dlssPlugin = enable ? new Tr2DlssPlugin( 0, false ) : nullptr; + break; + case StreamlineUtils::SP_DLSSG: + if( !s_dlssPlugin ) { - CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it failed (%d)", enable ? "enable" : "disable", info.pluginName, res ); - return; + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, true ); } - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is now %s", info.pluginName, enable ? "enabled" : "disabled" ); + s_dlssPlugin->EnableFrameGeneration( enable ); + PrepareReflex( enable ); - s_pluginInfo[plugin].created = enable; - - // Setup/delete the plugin - switch( plugin ) - { - case StreamlineUtils::SP_DLSS: - s_dlssPlugin = enable ? new Tr2DlssPlugin( 0, false ) : nullptr; - break; - case StreamlineUtils::SP_DLSSG: - if( !s_dlssPlugin ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, true ); - } - - s_dlssPlugin->EnableFrameGeneration( enable ); - PrepareReflex( enable ); + break; + case StreamlineUtils::SP_NIS: + s_nisPlugin = enable ? new Tr2NisPlugin( 0 ) : nullptr; + break; + default: + break; + } +} - break; - case StreamlineUtils::SP_NIS: - s_nisPlugin = enable ? new Tr2NisPlugin( 0 ) : nullptr; - break; - default: - break; - } +void PrepareReflex( bool enable ) +{ + if( enable ) + { + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, true ); } - void PrepareReflex( bool enable ) + auto reflexConst = sl::ReflexOptions{}; + reflexConst.mode = enable ? sl::ReflexMode::eLowLatency : sl::ReflexMode::eOff; + reflexConst.useMarkersToOptimize = true; + reflexConst.virtualKey = VK_F13; + reflexConst.frameLimitUs = 0; + DECLARE_STATIC_FEATURE_FUNC( slReflexSetOptions, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetOptions( reflexConst ) ) ) { - if( enable ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, true ); - } + CCP_LOGERR( "Reflex failed to set options (%d)", result ); + } - auto reflexConst = sl::ReflexOptions{}; - reflexConst.mode = enable ? sl::ReflexMode::eLowLatency : sl::ReflexMode::eOff; - reflexConst.useMarkersToOptimize = true; - reflexConst.virtualKey = VK_F13; - reflexConst.frameLimitUs = 0; - DECLARE_STATIC_FEATURE_FUNC( slReflexSetOptions, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetOptions( reflexConst ) ) ) - { - CCP_LOGERR( "Reflex failed to set options (%d)", result ); - } + if( !enable ) + { + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); + } + s_reflexEnabled = enable; +} - if( !enable ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); - } - s_reflexEnabled = enable; - } - - void SetCommonConstants( StreamlineUtils::CommonConstants constants ) - { - s_commonConstants.cameraAspectRatio = constants.cameraAspectRatio; - s_commonConstants.cameraFar = constants.cameraFar; - s_commonConstants.cameraFOV = constants.cameraFOV; - s_commonConstants.cameraFwd = AsFloat3( constants.cameraForward ); - s_commonConstants.cameraMotionIncluded = sl::eTrue; - s_commonConstants.cameraNear = constants.cameraNear; - s_commonConstants.cameraPos = AsFloat3( constants.cameraPos ); - s_commonConstants.cameraRight = AsFloat3( constants.cameraRight ); - s_commonConstants.cameraUp = AsFloat3( constants.cameraUp ); - s_commonConstants.cameraViewToClip = AsFloat4x4( constants.projection ); - s_commonConstants.clipToCameraView = AsFloat4x4( constants.invprojection ); - s_commonConstants.clipToPrevClip = AsFloat4x4( constants.clipToPrevClip ); - s_commonConstants.depthInverted = sl::eTrue; - s_commonConstants.jitterOffset = AsFloat2( constants.jitterOffset ); - s_commonConstants.motionVectors3D = sl::eFalse; - s_commonConstants.motionVectorsDilated = sl::eFalse; - s_commonConstants.motionVectorsJittered = sl::eFalse; - s_commonConstants.mvecScale = AsFloat2( constants.motionScale ); - s_commonConstants.orthographicProjection = sl::eFalse; - s_commonConstants.prevClipToClip = AsFloat4x4( constants.prevClipToClip ); - // unused things - s_commonConstants.cameraPinholeOffset = sl::float2( 0, 0 ); - s_commonConstants.reset = s_reset ? sl::eTrue : sl::eFalse; - - DECLARE_STATIC_SL_FUNC( slSetConstants ); - if( SL_FAILED( result, s_slSetConstants( s_commonConstants, *s_frameToken, 0 ) ) ) - { - CCP_LOGERR( "Setting Nvidia Streamline common constants failed (%d)", result ); - } +void SetCommonConstants( StreamlineUtils::CommonConstants constants ) +{ + s_commonConstants.cameraAspectRatio = constants.cameraAspectRatio; + s_commonConstants.cameraFar = constants.cameraFar; + s_commonConstants.cameraFOV = constants.cameraFOV; + s_commonConstants.cameraFwd = AsFloat3( constants.cameraForward ); + s_commonConstants.cameraMotionIncluded = sl::eTrue; + s_commonConstants.cameraNear = constants.cameraNear; + s_commonConstants.cameraPos = AsFloat3( constants.cameraPos ); + s_commonConstants.cameraRight = AsFloat3( constants.cameraRight ); + s_commonConstants.cameraUp = AsFloat3( constants.cameraUp ); + s_commonConstants.cameraViewToClip = AsFloat4x4( constants.projection ); + s_commonConstants.clipToCameraView = AsFloat4x4( constants.invprojection ); + s_commonConstants.clipToPrevClip = AsFloat4x4( constants.clipToPrevClip ); + s_commonConstants.depthInverted = sl::eTrue; + s_commonConstants.jitterOffset = AsFloat2( constants.jitterOffset ); + s_commonConstants.motionVectors3D = sl::eFalse; + s_commonConstants.motionVectorsDilated = sl::eFalse; + s_commonConstants.motionVectorsJittered = sl::eFalse; + s_commonConstants.mvecScale = AsFloat2( constants.motionScale ); + s_commonConstants.orthographicProjection = sl::eFalse; + s_commonConstants.prevClipToClip = AsFloat4x4( constants.prevClipToClip ); + // unused things + s_commonConstants.cameraPinholeOffset = sl::float2( 0, 0 ); + s_commonConstants.reset = s_reset ? sl::eTrue : sl::eFalse; + + DECLARE_STATIC_SL_FUNC( slSetConstants ); + if( SL_FAILED( result, s_slSetConstants( s_commonConstants, *s_frameToken, 0 ) ) ) + { + CCP_LOGERR( "Setting Nvidia Streamline common constants failed (%d)", result ); } } +} Tr2DlssPlugin::Tr2DlssPlugin() { } diff --git a/trinityal/dx11/Tr2StreamlineALDx11.h b/trinityal/dx11/Tr2StreamlineALDx11.h index acdebb421..c073e065c 100644 --- a/trinityal/dx11/Tr2StreamlineALDx11.h +++ b/trinityal/dx11/Tr2StreamlineALDx11.h @@ -30,112 +30,112 @@ namespace StreamlineUtils { - void Log( sl::LogType type, const char* msg ); - sl::Resource GenerateTextureResource( Tr2TextureAL* texture ); - sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ); +void Log( sl::LogType type, const char* msg ); +sl::Resource GenerateTextureResource( Tr2TextureAL* texture ); +sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ); - enum PluginAvailability - { - SLPA_YES, - SLPA_NO, - SLPA_UNKNOWN - }; +enum PluginAvailability +{ + SLPA_YES, + SLPA_NO, + SLPA_UNKNOWN +}; - struct PluginInfo - { - std::string pluginName; - uint32_t streamlineID; - PluginAvailability available; - bool created; - }; +struct PluginInfo +{ + std::string pluginName; + uint32_t streamlineID; + PluginAvailability available; + bool created; +}; - enum StreamlinePlugin - { - SP_DLSS, - SP_DLSSG, - SP_REFLEX, - SP_NIS, - SP_DEBUG, - SP_COUNT - }; - - struct CommonConstants - { - float projection[16]; - float invprojection[16]; - float clipToPrevClip[16]; - float prevClipToClip[16]; - float jitterOffset[2]; - float motionScale[2]; - float cameraPos[3]; - float cameraUp[3]; - float cameraRight[3]; - float cameraForward[3]; - float cameraNear; - float cameraFar; - float cameraFOV; - float cameraAspectRatio; - bool reset; - }; +enum StreamlinePlugin +{ + SP_DLSS, + SP_DLSSG, + SP_REFLEX, + SP_NIS, + SP_DEBUG, + SP_COUNT +}; + +struct CommonConstants +{ + float projection[16]; + float invprojection[16]; + float clipToPrevClip[16]; + float prevClipToClip[16]; + float jitterOffset[2]; + float motionScale[2]; + float cameraPos[3]; + float cameraUp[3]; + float cameraRight[3]; + float cameraForward[3]; + float cameraNear; + float cameraFar; + float cameraFOV; + float cameraAspectRatio; + bool reset; +}; } namespace DlssUtils { - enum DlssMode - { - dmUltraPerformance, - dmPerformance, - dmBalanced, - dmQuality, - dmUltraQuality, - }; - - struct DlssOptions - { - DlssMode mode; - uint32_t outputWidth; - uint32_t outputHeight; - uint32_t renderWidth; - uint32_t renderHeight; - Tr2RenderContextEnum::PixelFormat renderPixelFormat; - Tr2RenderContextEnum::PixelFormat outputPixelFormat; - Tr2RenderContextEnum::PixelFormat motionVectorPixelFormat; - Tr2RenderContextEnum::PixelFormat depthPixelFormat; - bool hdr; - }; - - struct DlssOptimalSetting - { - float sharpness; - uint32_t renderWidth; - uint32_t renderHeight; - }; +enum DlssMode +{ + dmUltraPerformance, + dmPerformance, + dmBalanced, + dmQuality, + dmUltraQuality, +}; - struct DlssResources - { - Tr2TextureAL* input; - Tr2TextureAL* depth; - Tr2TextureAL* velocity; - Tr2TextureAL* output; - Tr2TextureAL* opaqueOnly; - Tr2TextureAL* exposure; - Tr2TextureAL* reactive; - }; +struct DlssOptions +{ + DlssMode mode; + uint32_t outputWidth; + uint32_t outputHeight; + uint32_t renderWidth; + uint32_t renderHeight; + Tr2RenderContextEnum::PixelFormat renderPixelFormat; + Tr2RenderContextEnum::PixelFormat outputPixelFormat; + Tr2RenderContextEnum::PixelFormat motionVectorPixelFormat; + Tr2RenderContextEnum::PixelFormat depthPixelFormat; + bool hdr; +}; + +struct DlssOptimalSetting +{ + float sharpness; + uint32_t renderWidth; + uint32_t renderHeight; +}; + +struct DlssResources +{ + Tr2TextureAL* input; + Tr2TextureAL* depth; + Tr2TextureAL* velocity; + Tr2TextureAL* output; + Tr2TextureAL* opaqueOnly; + Tr2TextureAL* exposure; + Tr2TextureAL* reactive; +}; } namespace NisUtils { - struct NisResources - { - Tr2TextureAL* input; - Tr2TextureAL* output; - }; +struct NisResources +{ + Tr2TextureAL* input; + Tr2TextureAL* output; +}; - struct NisOptions - { - float sharpness; - bool hdr; - }; +struct NisOptions +{ + float sharpness; + bool hdr; +}; } class Tr2DlssPlugin diff --git a/trinityal/dx11/Tr2SwapChainALDx11.cpp b/trinityal/dx11/Tr2SwapChainALDx11.cpp index 698114e87..ed2e0415a 100644 --- a/trinityal/dx11/Tr2SwapChainALDx11.cpp +++ b/trinityal/dx11/Tr2SwapChainALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if TRINITY_PLATFORM==TRINITY_DIRECTX11 +#if TRINITY_PLATFORM == TRINITY_DIRECTX11 #include "Tr2SwapChainALDx11.h" #include "Tr2TextureALDx11.h" @@ -12,166 +12,166 @@ namespace TrinityALImpl { - // -------------------------------------------------------------------------------------- - // Description: - // Tr2SwapChainAL default constructor - // -------------------------------------------------------------------------------------- - Tr2SwapChainAL::Tr2SwapChainAL() - :m_width( 0 ), - m_height( 0 ) +// -------------------------------------------------------------------------------------- +// Description: +// Tr2SwapChainAL default constructor +// -------------------------------------------------------------------------------------- +Tr2SwapChainAL::Tr2SwapChainAL() : + m_width( 0 ), + m_height( 0 ) +{ + memset( &m_description, 0, sizeof( m_description ) ); + m_backBuffer.m_texture = std::make_shared(); +} + +// -------------------------------------------------------------------------------------- +// Description: +// Creates swap chain and associated buffers. +// Arguments: +// windowHandle - Handle to window object (Tr2WindowHandle) for which the swap chain is created +// renderContext - Current render context +// Return value: +// HRESULT value +// -------------------------------------------------------------------------------------- +ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + m_description.OutputWindow = windowHandle; + + if( !renderContext.m_d3dDevice11 ) { - memset( &m_description, 0, sizeof( m_description ) ); - m_backBuffer.m_texture = std::make_shared(); + return E_FAIL; } - // -------------------------------------------------------------------------------------- - // Description: - // Creates swap chain and associated buffers. - // Arguments: - // windowHandle - Handle to window object (Tr2WindowHandle) for which the swap chain is created - // renderContext - Current render context - // Return value: - // HRESULT value - // -------------------------------------------------------------------------------------- - ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ) + if( windowHandle ) { - Destroy(); - - m_description.OutputWindow = windowHandle; - - if( !renderContext.m_d3dDevice11 ) - { - return E_FAIL; - } + m_width = 0; + m_height = 0; - if( windowHandle ) - { - m_width = 0; - m_height = 0; + m_description.BufferCount = 1; + m_description.Windowed = true; + m_description.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - m_description.BufferCount = 1; - m_description.Windowed = true; - m_description.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + m_description.SampleDesc.Count = /*msaa*/ 1; + m_description.SampleDesc.Quality = 0; - m_description.SampleDesc.Count = /*msaa*/ 1; - m_description.SampleDesc.Quality = 0; + m_description.BufferDesc.Width = 0; + m_description.BufferDesc.Height = 0; + m_description.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + m_description.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - m_description.BufferDesc.Width = 0; - m_description.BufferDesc.Height = 0; - m_description.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; - m_description.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + CComPtr pDXGIDevice; + renderContext.m_d3dDevice11->QueryInterface( __uuidof( IDXGIDevice ), (void**)&pDXGIDevice ); - CComPtr pDXGIDevice; - renderContext.m_d3dDevice11->QueryInterface( __uuidof( IDXGIDevice ), (void **)&pDXGIDevice ); + CComPtr pDXGIAdapter; + pDXGIDevice->GetParent( __uuidof( IDXGIAdapter ), (void**)&pDXGIAdapter ); - CComPtr pDXGIAdapter; - pDXGIDevice->GetParent( __uuidof( IDXGIAdapter ), (void **)&pDXGIAdapter ); + CComPtr pIDXGIFactory; + pDXGIAdapter->GetParent( __uuidof( IDXGIFactory ), (void**)&pIDXGIFactory ); - CComPtr pIDXGIFactory; - pDXGIAdapter->GetParent( __uuidof( IDXGIFactory ), (void **)&pIDXGIFactory ); + CR_RETURN_HR( pIDXGIFactory->CreateSwapChain( renderContext.m_d3dDevice11, &m_description, &m_swapChain ) ); - CR_RETURN_HR( pIDXGIFactory->CreateSwapChain( renderContext.m_d3dDevice11, &m_description, &m_swapChain ) ); + CComPtr pBackBuffer; + CR_RETURN_HR( m_swapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (LPVOID*)&pBackBuffer ) ); - CComPtr pBackBuffer; - CR_RETURN_HR( m_swapChain->GetBuffer( 0, __uuidof ( ID3D11Texture2D ), (LPVOID*)&pBackBuffer ) ); + CR_RETURN_HR( m_backBuffer.m_texture->Attach( pBackBuffer, renderContext ) ); + m_width = m_backBuffer.GetWidth(); + m_height = m_backBuffer.GetHeight(); - CR_RETURN_HR( m_backBuffer.m_texture->Attach( pBackBuffer, renderContext ) ); - m_width = m_backBuffer.GetWidth(); - m_height = m_backBuffer.GetHeight(); - - return S_OK; - } - else - { - return E_FAIL; - } - } - - // -------------------------------------------------------------------------------------- - // Description: - // Destroys device resources (swap chain, buffers). - // -------------------------------------------------------------------------------------- - void Tr2SwapChainAL::Destroy() - { - m_swapChain = nullptr; - m_backBuffer.m_texture->Destroy(); + return S_OK; } - - // -------------------------------------------------------------------------------------- - // Description: - // Checks if the swap chain was successfully created. - // Return value: - // true If the swap chain is valid and can be used - // false Otherwise - // -------------------------------------------------------------------------------------- - bool Tr2SwapChainAL::IsValid() const + else { - return m_swapChain != nullptr; + return E_FAIL; } +} - // -------------------------------------------------------------------------------------- - // Description: - // Presents the swap chain back buffer to the window. - // Return value: - // HRESULT value - // -------------------------------------------------------------------------------------- - ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& /* renderContext */ ) +// -------------------------------------------------------------------------------------- +// Description: +// Destroys device resources (swap chain, buffers). +// -------------------------------------------------------------------------------------- +void Tr2SwapChainAL::Destroy() +{ + m_swapChain = nullptr; + m_backBuffer.m_texture->Destroy(); +} + +// -------------------------------------------------------------------------------------- +// Description: +// Checks if the swap chain was successfully created. +// Return value: +// true If the swap chain is valid and can be used +// false Otherwise +// -------------------------------------------------------------------------------------- +bool Tr2SwapChainAL::IsValid() const +{ + return m_swapChain != nullptr; +} + +// -------------------------------------------------------------------------------------- +// Description: +// Presents the swap chain back buffer to the window. +// Return value: +// HRESULT value +// -------------------------------------------------------------------------------------- +ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& /* renderContext */ ) +{ + if( !m_swapChain ) { - if( !m_swapChain ) - { - return E_FAIL; - } - - HRESULT hr = m_swapChain->Present( 0, 0 ); - if( !SUCCEEDED( hr ) ) - { - CCP_AL_LOGERR( "Tr2SwapChainAL::Present failed" ); - } - - return hr; + return E_FAIL; } - // -------------------------------------------------------------------------------------- - // Description: - // Returns width of the swap chain back buffer (if swap chain is not valid the result - // is undefined). - // Return value: - // Width of the back buffer - // -------------------------------------------------------------------------------------- - uint32_t Tr2SwapChainAL::GetWidth() const + HRESULT hr = m_swapChain->Present( 0, 0 ); + if( !SUCCEEDED( hr ) ) { - return m_width; + CCP_AL_LOGERR( "Tr2SwapChainAL::Present failed" ); } - // -------------------------------------------------------------------------------------- - // Description: - // Returns height of the swap chain back buffer (if swap chain is not valid the result - // is undefined). - // Return value: - // Height of the back buffer - // -------------------------------------------------------------------------------------- - uint32_t Tr2SwapChainAL::GetHeight() const - { - return m_height; - } + return hr; +} + +// -------------------------------------------------------------------------------------- +// Description: +// Returns width of the swap chain back buffer (if swap chain is not valid the result +// is undefined). +// Return value: +// Width of the back buffer +// -------------------------------------------------------------------------------------- +uint32_t Tr2SwapChainAL::GetWidth() const +{ + return m_width; +} + +// -------------------------------------------------------------------------------------- +// Description: +// Returns height of the swap chain back buffer (if swap chain is not valid the result +// is undefined). +// Return value: +// Height of the back buffer +// -------------------------------------------------------------------------------------- +uint32_t Tr2SwapChainAL::GetHeight() const +{ + return m_height; +} - void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2SwapChainAL"; - description["width"] = std::to_string( m_width ); - description["height"] = std::to_string( m_height ); - description["name"] = m_name; - } +void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SwapChainAL"; + description["width"] = std::to_string( m_width ); + description["height"] = std::to_string( m_height ); + description["name"] = m_name; +} - ALResult Tr2SwapChainAL::SetName( const char* name ) +ALResult Tr2SwapChainAL::SetName( const char* name ) +{ + if( !m_swapChain ) { - if( !m_swapChain ) - { - return E_INVALIDCALL; - } - m_name = name; - return m_swapChain->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); + return E_INVALIDCALL; } + m_name = name; + return m_swapChain->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); +} - } +} #endif diff --git a/trinityal/dx11/Tr2SwapChainALDx11.h b/trinityal/dx11/Tr2SwapChainALDx11.h index 5b1bd5a3b..fb930d483 100644 --- a/trinityal/dx11/Tr2SwapChainALDx11.h +++ b/trinityal/dx11/Tr2SwapChainALDx11.h @@ -2,7 +2,7 @@ #pragma once -#if TRINITY_PLATFORM==TRINITY_DIRECTX11 +#if TRINITY_PLATFORM == TRINITY_DIRECTX11 #include "../include/Tr2SwapChainAL.h" #include "../include/Tr2TextureAL.h" @@ -11,37 +11,40 @@ namespace TrinityALImpl { - class Tr2SwapChainAL : public Tr2DeviceResourceAL - { - public: - Tr2SwapChainAL(); - - ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ); - void Destroy(); - - bool IsValid() const; +class Tr2SwapChainAL : public Tr2DeviceResourceAL +{ +public: + Tr2SwapChainAL(); - ALResult Present( Tr2RenderContextAL& renderContext ); + ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - uint32_t GetWidth() const; - uint32_t GetHeight() const; + bool IsValid() const; - ::Tr2TextureAL m_backBuffer; + ALResult Present( Tr2RenderContextAL& renderContext ); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + uint32_t GetWidth() const; + uint32_t GetHeight() const; - private: - Tr2SwapChainAL( const Tr2SwapChainAL& ) /* = delete */; - Tr2SwapChainAL& operator=( const Tr2SwapChainAL& ) /* = delete */; + ::Tr2TextureAL m_backBuffer; - DXGI_SWAP_CHAIN_DESC m_description; - CComPtr m_swapChain; - uint32_t m_width; - uint32_t m_height; - std::string m_name; - }; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2SwapChainAL( const Tr2SwapChainAL& ) /* = delete */; + Tr2SwapChainAL& operator=( const Tr2SwapChainAL& ) /* = delete */; + + DXGI_SWAP_CHAIN_DESC m_description; + CComPtr m_swapChain; + uint32_t m_width; + uint32_t m_height; + std::string m_name; +}; } diff --git a/trinityal/dx11/Tr2TextureALDx11.cpp b/trinityal/dx11/Tr2TextureALDx11.cpp index d57d1e3e5..4c0cea87c 100644 --- a/trinityal/dx11/Tr2TextureALDx11.cpp +++ b/trinityal/dx11/Tr2TextureALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2TextureALDx11.h" #include "Tr2PrimaryRenderContextDx11.h" @@ -10,552 +10,427 @@ namespace { - std::vector ConvertInitialData( uint32_t numInit, Tr2SubresourceData* initialData ) +std::vector ConvertInitialData( uint32_t numInit, Tr2SubresourceData* initialData ) +{ + std::vector init( numInit ); + if( initialData ) { - std::vector init( numInit ); - if( initialData ) + for( size_t i = 0; i != init.size(); ++i ) { - for( size_t i = 0; i != init.size(); ++i ) - { - init[i].pSysMem = initialData[i].m_sysMem; - init[i].SysMemPitch = initialData[i].m_sysMemPitch; - init[i].SysMemSlicePitch = initialData[i].m_sysMemSlicePitch; - } + init[i].pSysMem = initialData[i].m_sysMem; + init[i].SysMemPitch = initialData[i].m_sysMemPitch; + init[i].SysMemSlicePitch = initialData[i].m_sysMemSlicePitch; } - - return init; } - DXGI_FORMAT GetSrvFormat( Tr2RenderContextEnum::PixelFormat format ) + return init; +} + +DXGI_FORMAT GetSrvFormat( Tr2RenderContextEnum::PixelFormat format ) +{ + switch( format ) { - switch( format ) - { - case Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT: - return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; - case Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT: - return DXGI_FORMAT_R32_FLOAT; - default: - return DXGI_FORMAT( format ); - } + case Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT: + return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + case Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT: + return DXGI_FORMAT_R32_FLOAT; + default: + return DXGI_FORMAT( format ); } +} - ALResult Create1D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc&, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +ALResult Create1D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc&, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + D3D11_TEXTURE1D_DESC desc1D; + memset( &desc1D, 0, sizeof( desc1D ) ); + desc1D.Width = desc.GetWidth(); + desc1D.MipLevels = desc.GetTrueMipCount(); // see below, no auto-gen yet + desc1D.ArraySize = desc.GetArraySize(); + desc1D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + + if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + desc1D.Usage = D3D11_USAGE_DYNAMIC; + desc1D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } + else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + desc1D.Usage = D3D11_USAGE_DEFAULT; + desc1D.CPUAccessFlags = 0; + } + else if( IsWritable( gpuUsage ) ) + { + desc1D.Usage = D3D11_USAGE_DEFAULT; + } + else { - D3D11_TEXTURE1D_DESC desc1D; - memset( &desc1D, 0, sizeof( desc1D ) ); - desc1D.Width = desc.GetWidth(); - desc1D.MipLevels = desc.GetTrueMipCount(); // see below, no auto-gen yet - desc1D.ArraySize = desc.GetArraySize(); - desc1D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + desc1D.Usage = D3D11_USAGE_IMMUTABLE; + } - if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - desc1D.Usage = D3D11_USAGE_DYNAMIC; - desc1D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - } - else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) - { - desc1D.Usage = D3D11_USAGE_DEFAULT; - desc1D.CPUAccessFlags = 0; - } - else if( IsWritable( gpuUsage ) ) - { - desc1D.Usage = D3D11_USAGE_DEFAULT; - } - else + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + desc1D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + desc1D.BindFlags |= D3D11_BIND_RENDER_TARGET; + if( desc.GetTrueMipCount() > 1 && HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - desc1D.Usage = D3D11_USAGE_IMMUTABLE; + desc1D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; } + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + desc1D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + desc1D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) + { + desc1D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; + } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - desc1D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - desc1D.BindFlags |= D3D11_BIND_RENDER_TARGET; - if( desc.GetTrueMipCount() > 1 && HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - desc1D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; - } - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - desc1D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - desc1D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) - { - desc1D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; - } + auto init = ConvertInitialData( desc1D.MipLevels * desc1D.ArraySize, initialData ); - auto init = ConvertInitialData( desc1D.MipLevels * desc1D.ArraySize, initialData ); + CComPtr texture1D; - CComPtr texture1D; + FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture1D( &desc1D, initialData ? &init[0] : nullptr, &texture1D ) ); + texture = texture1D; + return S_OK; +} - FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture1D( &desc1D, initialData ? &init[0] : nullptr, &texture1D ) ); - texture = texture1D; - return S_OK; +ALResult Create2D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + D3D11_TEXTURE2D_DESC desc2D; + memset( &desc2D, 0, sizeof( desc2D ) ); + desc2D.Width = desc.GetWidth(); + desc2D.Height = desc.GetHeight(); + desc2D.MipLevels = desc.GetTrueMipCount(); // see below, no auto-gen yet + desc2D.ArraySize = desc.GetArraySize(); + desc2D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + + if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + desc2D.Usage = D3D11_USAGE_DYNAMIC; + desc2D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; } - - ALResult Create2D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) + else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + desc2D.Usage = D3D11_USAGE_DEFAULT; + desc2D.CPUAccessFlags = 0; + } + else if( IsWritable( gpuUsage ) ) + { + desc2D.Usage = D3D11_USAGE_DEFAULT; + } + else { - D3D11_TEXTURE2D_DESC desc2D; - memset( &desc2D, 0, sizeof( desc2D ) ); - desc2D.Width = desc.GetWidth(); - desc2D.Height = desc.GetHeight(); - desc2D.MipLevels = desc.GetTrueMipCount(); // see below, no auto-gen yet - desc2D.ArraySize = desc.GetArraySize(); - desc2D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + desc2D.Usage = D3D11_USAGE_IMMUTABLE; + } - if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - desc2D.Usage = D3D11_USAGE_DYNAMIC; - desc2D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - } - else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) - { - desc2D.Usage = D3D11_USAGE_DEFAULT; - desc2D.CPUAccessFlags = 0; - } - else if( IsWritable( gpuUsage ) ) - { - desc2D.Usage = D3D11_USAGE_DEFAULT; - } - else + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + desc2D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + desc2D.BindFlags |= D3D11_BIND_RENDER_TARGET; + if( desc.GetTrueMipCount() > 1 && HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - desc2D.Usage = D3D11_USAGE_IMMUTABLE; + desc2D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; } + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + desc2D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + desc2D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) + { + desc2D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; + } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - desc2D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - desc2D.BindFlags |= D3D11_BIND_RENDER_TARGET; - if( desc.GetTrueMipCount() > 1 && HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - desc2D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; - } - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - desc2D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - desc2D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) - { - desc2D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; - } + desc2D.SampleDesc.Count = msaa.samples; + desc2D.SampleDesc.Quality = msaa.quality; + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) + { + desc2D.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE; + } - desc2D.SampleDesc.Count = msaa.samples; - desc2D.SampleDesc.Quality = msaa.quality; - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - desc2D.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE; - } + auto init = ConvertInitialData( desc2D.MipLevels * desc2D.ArraySize, initialData ); - auto init = ConvertInitialData( desc2D.MipLevels * desc2D.ArraySize, initialData ); + CComPtr texture2D; - CComPtr texture2D; + FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture2D( &desc2D, initialData ? &init[0] : nullptr, &texture2D ) ); + texture = texture2D; + return S_OK; +} - FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture2D( &desc2D, initialData ? &init[0] : nullptr, &texture2D ) ); - texture = texture2D; - return S_OK; - } +ALResult Create3D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + CCP_UNUSED( msaa ); - ALResult Create3D( CComPtr& texture, const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) - { - CCP_UNUSED( msaa ); + D3D11_TEXTURE3D_DESC desc3D; + memset( &desc3D, 0, sizeof( desc3D ) ); + desc3D.Width = desc.GetWidth(); + desc3D.Height = desc.GetHeight(); + desc3D.Depth = desc.GetDepth(); + desc3D.MipLevels = desc.GetTrueMipCount(); + desc3D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); - D3D11_TEXTURE3D_DESC desc3D; - memset( &desc3D, 0, sizeof( desc3D ) ); - desc3D.Width = desc.GetWidth(); - desc3D.Height = desc.GetHeight(); - desc3D.Depth = desc.GetDepth(); - desc3D.MipLevels = desc.GetTrueMipCount(); - desc3D.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + desc3D.Usage = D3D11_USAGE_DYNAMIC; + desc3D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } + else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + desc3D.Usage = D3D11_USAGE_DEFAULT; // or D3D11_USAGE_DYNAMIC? + desc3D.CPUAccessFlags = 0; + } + else if( IsWritable( gpuUsage ) ) + { + desc3D.Usage = D3D11_USAGE_DEFAULT; + } + else + { + desc3D.Usage = D3D11_USAGE_IMMUTABLE; + } - if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - desc3D.Usage = D3D11_USAGE_DYNAMIC; - desc3D.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - } - else if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) - { - desc3D.Usage = D3D11_USAGE_DEFAULT; // or D3D11_USAGE_DYNAMIC? - desc3D.CPUAccessFlags = 0; - } - else if( IsWritable( gpuUsage ) ) - { - desc3D.Usage = D3D11_USAGE_DEFAULT; - } - else - { - desc3D.Usage = D3D11_USAGE_IMMUTABLE; - } + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + desc3D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + desc3D.BindFlags |= D3D11_BIND_RENDER_TARGET; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + desc3D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + desc3D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) + { + desc3D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; + } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - desc3D.BindFlags |= D3D11_BIND_SHADER_RESOURCE; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - desc3D.BindFlags |= D3D11_BIND_RENDER_TARGET; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - desc3D.BindFlags |= D3D11_BIND_DEPTH_STENCIL; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - desc3D.BindFlags |= D3D11_BIND_UNORDERED_ACCESS; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHARED ) ) - { - desc3D.MiscFlags |= D3D11_RESOURCE_MISC_SHARED; - } + if( !desc.GetMipCount() ) + { + desc3D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; + } - if( !desc.GetMipCount() ) - { - desc3D.MiscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; - } + auto init = ConvertInitialData( desc3D.MipLevels, initialData ); - auto init = ConvertInitialData( desc3D.MipLevels, initialData ); + CComPtr texture3D; - CComPtr texture3D; + FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture3D( &desc3D, initialData ? &init[0] : nullptr, &texture3D ) ); + texture = texture3D; + return S_OK; +} - FORWARD_HR( renderContext.m_d3dDevice11->CreateTexture3D( &desc3D, initialData ? &init[0] : nullptr, &texture3D ) ); - texture = texture3D; - return S_OK; - } +bool IsTypeless( Tr2RenderContextEnum::PixelFormat format ) +{ + using namespace Tr2RenderContextEnum; + return format == PIXEL_FORMAT_R32G32B32A32_TYPELESS || + format == PIXEL_FORMAT_R32G32B32_TYPELESS || + format == PIXEL_FORMAT_R16G16B16A16_TYPELESS || + format == PIXEL_FORMAT_R32G32_TYPELESS || + format == PIXEL_FORMAT_R10G10B10A2_TYPELESS || + format == PIXEL_FORMAT_R8G8B8A8_TYPELESS || + format == PIXEL_FORMAT_R16G16_TYPELESS || + format == PIXEL_FORMAT_R32_TYPELESS || + format == PIXEL_FORMAT_R8G8_TYPELESS || + format == PIXEL_FORMAT_R16_TYPELESS || + format == PIXEL_FORMAT_R8_TYPELESS || + format == PIXEL_FORMAT_BC1_TYPELESS || + format == PIXEL_FORMAT_BC2_TYPELESS || + format == PIXEL_FORMAT_BC3_TYPELESS || + format == PIXEL_FORMAT_BC4_TYPELESS || + format == PIXEL_FORMAT_BC5_TYPELESS || + format == PIXEL_FORMAT_BC6H_TYPELESS || + format == PIXEL_FORMAT_BC7_TYPELESS || + format == PIXEL_FORMAT_B8G8R8A8_TYPELESS || + format == PIXEL_FORMAT_B8G8R8X8_TYPELESS; +} - bool IsTypeless( Tr2RenderContextEnum::PixelFormat format ) - { - using namespace Tr2RenderContextEnum; - return format == PIXEL_FORMAT_R32G32B32A32_TYPELESS || - format == PIXEL_FORMAT_R32G32B32_TYPELESS || - format == PIXEL_FORMAT_R16G16B16A16_TYPELESS || - format == PIXEL_FORMAT_R32G32_TYPELESS || - format == PIXEL_FORMAT_R10G10B10A2_TYPELESS || - format == PIXEL_FORMAT_R8G8B8A8_TYPELESS || - format == PIXEL_FORMAT_R16G16_TYPELESS || - format == PIXEL_FORMAT_R32_TYPELESS || - format == PIXEL_FORMAT_R8G8_TYPELESS || - format == PIXEL_FORMAT_R16_TYPELESS || - format == PIXEL_FORMAT_R8_TYPELESS || - format == PIXEL_FORMAT_BC1_TYPELESS || - format == PIXEL_FORMAT_BC2_TYPELESS || - format == PIXEL_FORMAT_BC3_TYPELESS || - format == PIXEL_FORMAT_BC4_TYPELESS || - format == PIXEL_FORMAT_BC5_TYPELESS || - format == PIXEL_FORMAT_BC6H_TYPELESS || - format == PIXEL_FORMAT_BC7_TYPELESS || - format == PIXEL_FORMAT_B8G8R8A8_TYPELESS || - format == PIXEL_FORMAT_B8G8R8X8_TYPELESS; - } - - Tr2RenderContextEnum::PixelFormat FromTypeless( Tr2RenderContextEnum::PixelFormat format ) - { - using namespace Tr2RenderContextEnum; - switch( format ) - { - case PIXEL_FORMAT_R32G32B32A32_TYPELESS: - return PIXEL_FORMAT_R32G32B32A32_FLOAT; - case PIXEL_FORMAT_R32G32B32_TYPELESS: - return PIXEL_FORMAT_R32G32B32_FLOAT; - - case PIXEL_FORMAT_R16G16B16A16_TYPELESS: - return PIXEL_FORMAT_R16G16B16A16_FLOAT; - - case PIXEL_FORMAT_R32G32_TYPELESS: - return PIXEL_FORMAT_R32G32_FLOAT; - - case PIXEL_FORMAT_R10G10B10A2_TYPELESS: - return PIXEL_FORMAT_R10G10B10A2_UNORM; - - case PIXEL_FORMAT_R8G8B8A8_TYPELESS: - return PIXEL_FORMAT_R8G8B8A8_UNORM; - - case PIXEL_FORMAT_R16G16_TYPELESS: - return PIXEL_FORMAT_R16G16_FLOAT; - - case PIXEL_FORMAT_R32_TYPELESS: - return PIXEL_FORMAT_R32_FLOAT; - - case PIXEL_FORMAT_R8G8_TYPELESS: - return PIXEL_FORMAT_R8G8_UNORM; - - case PIXEL_FORMAT_R16_TYPELESS: - return PIXEL_FORMAT_R16_FLOAT; - - case PIXEL_FORMAT_R8_TYPELESS: - return PIXEL_FORMAT_R8_UNORM; - - case PIXEL_FORMAT_BC1_TYPELESS: - return PIXEL_FORMAT_BC1_UNORM; - case PIXEL_FORMAT_BC2_TYPELESS: - return PIXEL_FORMAT_BC2_UNORM; - case PIXEL_FORMAT_BC3_TYPELESS: - return PIXEL_FORMAT_BC3_UNORM; - case PIXEL_FORMAT_BC4_TYPELESS: - return PIXEL_FORMAT_BC4_UNORM; - case PIXEL_FORMAT_BC5_TYPELESS: - return PIXEL_FORMAT_BC5_UNORM; - case PIXEL_FORMAT_BC6H_TYPELESS: - return PIXEL_FORMAT_BC6H_SF16; - case PIXEL_FORMAT_BC7_TYPELESS: - return PIXEL_FORMAT_BC7_UNORM; - - case PIXEL_FORMAT_B8G8R8A8_TYPELESS: - return PIXEL_FORMAT_B8G8R8A8_UNORM; - case PIXEL_FORMAT_B8G8R8X8_TYPELESS: - return PIXEL_FORMAT_B8G8R8X8_UNORM; - - default: - return format; - } +Tr2RenderContextEnum::PixelFormat FromTypeless( Tr2RenderContextEnum::PixelFormat format ) +{ + using namespace Tr2RenderContextEnum; + switch( format ) + { + case PIXEL_FORMAT_R32G32B32A32_TYPELESS: + return PIXEL_FORMAT_R32G32B32A32_FLOAT; + case PIXEL_FORMAT_R32G32B32_TYPELESS: + return PIXEL_FORMAT_R32G32B32_FLOAT; + + case PIXEL_FORMAT_R16G16B16A16_TYPELESS: + return PIXEL_FORMAT_R16G16B16A16_FLOAT; + + case PIXEL_FORMAT_R32G32_TYPELESS: + return PIXEL_FORMAT_R32G32_FLOAT; + + case PIXEL_FORMAT_R10G10B10A2_TYPELESS: + return PIXEL_FORMAT_R10G10B10A2_UNORM; + + case PIXEL_FORMAT_R8G8B8A8_TYPELESS: + return PIXEL_FORMAT_R8G8B8A8_UNORM; + + case PIXEL_FORMAT_R16G16_TYPELESS: + return PIXEL_FORMAT_R16G16_FLOAT; + + case PIXEL_FORMAT_R32_TYPELESS: + return PIXEL_FORMAT_R32_FLOAT; + + case PIXEL_FORMAT_R8G8_TYPELESS: + return PIXEL_FORMAT_R8G8_UNORM; + + case PIXEL_FORMAT_R16_TYPELESS: + return PIXEL_FORMAT_R16_FLOAT; + + case PIXEL_FORMAT_R8_TYPELESS: + return PIXEL_FORMAT_R8_UNORM; + + case PIXEL_FORMAT_BC1_TYPELESS: + return PIXEL_FORMAT_BC1_UNORM; + case PIXEL_FORMAT_BC2_TYPELESS: + return PIXEL_FORMAT_BC2_UNORM; + case PIXEL_FORMAT_BC3_TYPELESS: + return PIXEL_FORMAT_BC3_UNORM; + case PIXEL_FORMAT_BC4_TYPELESS: + return PIXEL_FORMAT_BC4_UNORM; + case PIXEL_FORMAT_BC5_TYPELESS: + return PIXEL_FORMAT_BC5_UNORM; + case PIXEL_FORMAT_BC6H_TYPELESS: + return PIXEL_FORMAT_BC6H_SF16; + case PIXEL_FORMAT_BC7_TYPELESS: + return PIXEL_FORMAT_BC7_UNORM; + + case PIXEL_FORMAT_B8G8R8A8_TYPELESS: + return PIXEL_FORMAT_B8G8R8A8_UNORM; + case PIXEL_FORMAT_B8G8R8X8_TYPELESS: + return PIXEL_FORMAT_B8G8R8X8_UNORM; + + default: + return format; } } +} namespace TrinityALImpl { - Tr2TextureAL::Tr2TextureAL() - :m_gpuUsage( Tr2GpuUsage::NONE ), - m_cpuUsage( Tr2CpuUsage::NONE ), - m_lockedSubresource( 0 ), - m_writeBox{ 0, 0, 0, 0, 0, 0 } +Tr2TextureAL::Tr2TextureAL() : + m_gpuUsage( Tr2GpuUsage::NONE ), + m_cpuUsage( Tr2CpuUsage::NONE ), + m_lockedSubresource( 0 ), + m_writeBox{ 0, 0, 0, 0, 0, 0 } +{ +} + +ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( HasBufferFlags( gpuUsage ) ) { + return E_INVALIDARG; } - ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - Destroy(); - - if( HasBufferFlags( gpuUsage ) ) - { - return E_INVALIDARG; - } - - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - if( msaa.samples > 1 ) - { - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - return E_INVALIDARG; - } - if( cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - return E_INVALIDARG; - } - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - if( desc.GetArraySize() != 6 ) - { - return E_INVALIDARG; - } - } - else if( desc.GetArraySize() > 1 ) - { - return E_INVALIDARG; - } - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - return E_INVALIDARG; - } - if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + return E_FAIL; + } + if( msaa.samples > 1 ) + { + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { return E_INVALIDARG; } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) + if( cpuUsage != Tr2CpuUsage::NONE ) { return E_INVALIDARG; } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) { return E_INVALIDARG; } - - CComPtr texture; - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) - { - FORWARD_HR( Create1D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) - { - FORWARD_HR( Create3D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); - } - else - { - FORWARD_HR( Create2D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); - } - - // Behold! A workaround for WARP device crash when creating multiple SRVs into a BC7 texture! - if( !renderContext.m_dxgiOutput && desc.GetFormat() == Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM ) - { - // Create a single linear view into the texture - FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, false, renderContext ) ); - - // For sRGB view we create a copy of BC7 texture with an sRGB view into it - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - CComPtr srgbTexture; - FORWARD_HR( Create2D( srgbTexture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); - - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - memset( &srvDesc, 0, sizeof( srvDesc ) ); - - srvDesc.Format = GetSrvFormat( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) - { - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; - srvDesc.Texture3D.MipLevels = desc.GetTrueMipCount(); - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; - srvDesc.TextureCube.MipLevels = desc.GetTrueMipCount(); - } - else if( msaa.samples > 1 ) - { - srvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY : D3D11_SRV_DIMENSION_TEXTURE2DMS; - srvDesc.Texture2DMSArray.ArraySize = desc.GetArraySize(); - } - else - { - srvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DARRAY : D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.GetTrueMipCount(); - srvDesc.Texture2DArray.ArraySize = desc.GetArraySize(); - } - m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; - FORWARD_HR( renderContext.m_d3dDevice11->CreateShaderResourceView( srgbTexture, &srvDesc, &m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ); - } - } - else - { - FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, true, renderContext ) ); - } - - m_desc = desc; - m_gpuUsage = gpuUsage; - m_cpuUsage = cpuUsage; - m_msaa = msaa; - - m_memory.Set( Tr2MemoryCounterAL::TEXTURE, m_desc, msaa ); - - return S_OK; } - - ALResult Tr2TextureAL::OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - - CCP_AL_LOG( "Opening shared texture %lld", uint64_t( handle ) ); - - CComPtr resource; - auto hr = renderContext.m_d3dDevice11->OpenSharedResource( reinterpret_cast( handle ), __uuidof( ID3D11Texture2D ), reinterpret_cast( &resource.p ) ); - if( FAILED( hr ) ) - { - CCP_AL_LOG( "Failed to open shared texture %lld", uint64_t( handle ) ); - } - - FORWARD_HR( hr ); - - if( !resource ) - { - return E_FAIL; - } - - D3D11_TEXTURE2D_DESC dxDesc; - resource->GetDesc( &dxDesc ); - Tr2RenderContextEnum::PixelFormat fmt; - bool createSrgb = true; - if( IsTypeless( Tr2RenderContextEnum::PixelFormat( dxDesc.Format ) ) ) - { - fmt = FromTypeless( Tr2RenderContextEnum::PixelFormat( dxDesc.Format ) ); - } - else + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - fmt = Tr2RenderContextEnum::PixelFormat( dxDesc.Format ); - createSrgb = false; + if( desc.GetArraySize() != 6 ) + { + return E_INVALIDARG; + } } - Tr2BitmapDimensions desc( Tr2RenderContextEnum::TEX_TYPE_2D, fmt, dxDesc.Width, dxDesc.Height, 1, dxDesc.MipLevels ); - - CCP_AL_LOG( "Creating views for the shared texture %lld, GPU usage is %d", uint64_t( handle ), int( gpuUsage ) ); - - hr = CreateViews( resource, desc, Tr2MsaaDesc(), gpuUsage, Tr2CpuUsage::NONE, createSrgb, renderContext ); - if( FAILED( hr ) ) + else if( desc.GetArraySize() > 1 ) { - CCP_AL_LOG( "Failed to create views for the shared texture %lld, GPU usage is %d", uint64_t( handle ), int( gpuUsage ) ); - } - FORWARD_HR( hr ); - - m_desc = desc; - m_msaa = Tr2MsaaDesc(); - m_gpuUsage = gpuUsage; - m_cpuUsage = Tr2CpuUsage::NONE; - m_texture = resource; - return S_OK; + return E_INVALIDARG; + } + } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + return E_INVALIDARG; + } + if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; } - ALResult Tr2TextureAL::CreateViews( - ID3D11Resource* texture, - const Tr2BitmapDimensions& desc, - const Tr2MsaaDesc& msaa, - Tr2GpuUsage::Type gpuUsage, - Tr2CpuUsage::Type cpuUsage, - bool createSrgb, - Tr2PrimaryRenderContextAL& renderContext ) + CComPtr texture; + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) + { + FORWARD_HR( Create1D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); + } + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) + { + FORWARD_HR( Create3D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); + } + else { - CCP_UNUSED( cpuUsage ); + FORWARD_HR( Create2D( texture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); + } - CComPtr view[Tr2RenderContextEnum::_COLOR_SPACE_COUNT]; - std::vector> renderTargets; - CComPtr depthStencil[DepthOption::COUNT]; - std::vector> uav; + // Behold! A workaround for WARP device crash when creating multiple SRVs into a BC7 texture! + if( !renderContext.m_dxgiOutput && desc.GetFormat() == Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM ) + { + // Create a single linear view into the texture + FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, false, renderContext ) ); + // For sRGB view we create a copy of BC7 texture with an sRGB view into it if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { + CComPtr srgbTexture; + FORWARD_HR( Create2D( srgbTexture, desc, msaa, gpuUsage, cpuUsage, initialData, renderContext ) ); + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; memset( &srvDesc, 0, sizeof( srvDesc ) ); - srvDesc.Format = GetSrvFormat( desc.GetFormat() ); + srvDesc.Format = GetSrvFormat( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) - { - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; - srvDesc.Texture1D.MipLevels = desc.GetTrueMipCount(); - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) { srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; srvDesc.Texture3D.MipLevels = desc.GetTrueMipCount(); @@ -576,805 +451,929 @@ namespace TrinityALImpl srvDesc.Texture2D.MipLevels = desc.GetTrueMipCount(); srvDesc.Texture2DArray.ArraySize = desc.GetArraySize(); } - FORWARD_HR( renderContext.m_d3dDevice11->CreateShaderResourceView( texture, &srvDesc, &view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ) ); - if( createSrgb ) - { - srvDesc.Format = GetSrvFormat( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - if( FAILED( renderContext.m_d3dDevice11->CreateShaderResourceView( texture, &srvDesc, &view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ) ) - { - CCP_AL_LOGWARN( "Failed to create an sRGB view for the texture of format %i - will use the linear view instead", int( srvDesc.Format ) ); - view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; - } - } - else - { - view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; - } - } - - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; - memset( &rtvDesc, 0, sizeof( rtvDesc ) ); - - rtvDesc.Format = static_cast( desc.GetFormat() ); - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) - { - rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D; - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) - { - rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; - rtvDesc.Texture3D.WSize = 1; - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; - rtvDesc.Texture2DArray.ArraySize = 1; - } - else if( msaa.samples > 1 ) - { - rtvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY : D3D11_RTV_DIMENSION_TEXTURE2DMS; - rtvDesc.Texture2DMSArray.ArraySize = 1; - } - else - { - rtvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DARRAY : D3D11_RTV_DIMENSION_TEXTURE2D; - rtvDesc.Texture2DArray.ArraySize = 1; - } - - renderTargets.resize( 2 ); - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ) ); - if( createSrgb ) - { - rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ); - } - else - { - renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; - } - - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) - { - renderTargets.resize( desc.GetDepth() * 2 ); - for( uint32_t i = 1; i < desc.GetDepth(); ++i ) - { - rtvDesc.Texture3D.FirstWSlice = i; - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2] ) ); - if( createSrgb ) - { - rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] ) ); - } - else - { - renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2]; - } - } - } - else if( desc.GetArraySize() > 1 ) - { - renderTargets.resize( desc.GetArraySize() * 2 ); - for( uint32_t i = 1; i < desc.GetArraySize(); ++i ) - { - rtvDesc.Texture2DArray.FirstArraySlice = i; - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2] ) ); - if( createSrgb ) - { - rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] ) ); - } - else - { - renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2]; - } - } - } - + m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; + FORWARD_HR( renderContext.m_d3dDevice11->CreateShaderResourceView( srgbTexture, &srvDesc, &m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ); } + } + else + { + FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, true, renderContext ) ); + } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; - memset( &descDSV, 0, sizeof( descDSV ) ); - descDSV.Format = static_cast( desc.GetFormat() ); - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; - descDSV.Texture2DArray.ArraySize = 6; - } - else if( msaa.samples > 1 ) - { - descDSV.ViewDimension = desc.GetArraySize() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY : D3D11_DSV_DIMENSION_TEXTURE2DMS; - descDSV.Texture2DMSArray.ArraySize = desc.GetArraySize(); - } - else - { - descDSV.ViewDimension = desc.GetArraySize() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DARRAY : D3D11_DSV_DIMENSION_TEXTURE2D; - descDSV.Texture2DArray.ArraySize = desc.GetArraySize(); - } + m_desc = desc; + m_gpuUsage = gpuUsage; + m_cpuUsage = cpuUsage; + m_msaa = msaa; - FORWARD_HR( renderContext.m_d3dDevice11->CreateDepthStencilView( texture, &descDSV, &depthStencil[DepthOption::READ_WRITE] ) ); - descDSV.Flags |= D3D11_DSV_READ_ONLY_DEPTH; - FORWARD_HR( renderContext.m_d3dDevice11->CreateDepthStencilView( texture, &descDSV, &depthStencil[DepthOption::READ_ONLY] ) ); - } + m_memory.Set( Tr2MemoryCounterAL::TEXTURE, m_desc, msaa ); - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - D3D11_UNORDERED_ACCESS_VIEW_DESC descUAV; - memset( &descUAV, 0, sizeof( descUAV ) ); - descUAV.Format = static_cast( desc.GetFormat() ); - uav.resize( desc.GetTrueMipCount() ); - for( uint32_t mip = 0; mip < desc.GetTrueMipCount(); ++mip ) - { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) - { - descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE1D; - descUAV.Texture1D.MipSlice = mip; - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) - { - descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE3D; - descUAV.Texture3D.WSize = (UINT)-1; - descUAV.Texture3D.MipSlice = mip; - } - else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; - descUAV.Texture2DArray.ArraySize = 6; - descUAV.Texture2DArray.MipSlice = mip; - } - else if( desc.GetArraySize() > 1 ) - { - descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; - descUAV.Texture2DArray.ArraySize = desc.GetArraySize(); - descUAV.Texture2DArray.MipSlice = mip; - } - else - { - descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D; - descUAV.Texture2D.MipSlice = mip; - } - FORWARD_HR( renderContext.m_d3dDevice11->CreateUnorderedAccessView( texture, &descUAV, &uav[mip] ) ); - } - } + return S_OK; +} - m_texture = texture; - m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; - m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_SRGB]; - m_renderTarget = renderTargets; - m_depthStencil[DepthOption::READ_WRITE] = depthStencil[DepthOption::READ_WRITE]; - m_depthStencil[DepthOption::READ_ONLY] = depthStencil[DepthOption::READ_ONLY]; - m_uav = uav; - return S_OK; - } +ALResult Tr2TextureAL::OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - void Tr2TextureAL::Destroy() + if( !renderContext.IsValid() ) { - m_texture = nullptr; - m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = nullptr; - m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; - m_renderTarget.clear(); - m_depthStencil[DepthOption::READ_WRITE] = nullptr; - m_depthStencil[DepthOption::READ_ONLY] = nullptr; - m_uav.clear(); - m_stagingTexture = nullptr; - m_memory.Reset(); - memset( &m_desc, 0, sizeof( m_desc ) ); - m_msaa = Tr2MsaaDesc(); - m_gpuUsage = Tr2GpuUsage::NONE; - m_cpuUsage = Tr2CpuUsage::NONE; - m_writeStaging.clear(); - m_lockedSubresource = 0; - m_writeBox = { 0, 0, 0, 0, 0, 0 }; + return E_FAIL; } - bool Tr2TextureAL::IsValid() const - { - return m_texture != nullptr; - } + CCP_AL_LOG( "Opening shared texture %lld", uint64_t( handle ) ); - Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const + CComPtr resource; + auto hr = renderContext.m_d3dDevice11->OpenSharedResource( reinterpret_cast( handle ), __uuidof( ID3D11Texture2D ), reinterpret_cast( &resource.p ) ); + if( FAILED( hr ) ) { - return AL_MEMORY_MANAGED; + CCP_AL_LOG( "Failed to open shared texture %lld", uint64_t( handle ) ); } - const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const + FORWARD_HR( hr ); + + if( !resource ) { - return m_desc; + return E_FAIL; } - const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const + D3D11_TEXTURE2D_DESC dxDesc; + resource->GetDesc( &dxDesc ); + Tr2RenderContextEnum::PixelFormat fmt; + bool createSrgb = true; + if( IsTypeless( Tr2RenderContextEnum::PixelFormat( dxDesc.Format ) ) ) { - return m_msaa; + fmt = FromTypeless( Tr2RenderContextEnum::PixelFormat( dxDesc.Format ) ); } - - Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const + else { - return m_gpuUsage; + fmt = Tr2RenderContextEnum::PixelFormat( dxDesc.Format ); + createSrgb = false; } + Tr2BitmapDimensions desc( Tr2RenderContextEnum::TEX_TYPE_2D, fmt, dxDesc.Width, dxDesc.Height, 1, dxDesc.MipLevels ); - Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const + CCP_AL_LOG( "Creating views for the shared texture %lld, GPU usage is %d", uint64_t( handle ), int( gpuUsage ) ); + + hr = CreateViews( resource, desc, Tr2MsaaDesc(), gpuUsage, Tr2CpuUsage::NONE, createSrgb, renderContext ); + if( FAILED( hr ) ) { - return m_cpuUsage; + CCP_AL_LOG( "Failed to create views for the shared texture %lld, GPU usage is %d", uint64_t( handle ), int( gpuUsage ) ); } + FORWARD_HR( hr ); + + m_desc = desc; + m_msaa = Tr2MsaaDesc(); + m_gpuUsage = gpuUsage; + m_cpuUsage = Tr2CpuUsage::NONE; + m_texture = resource; + return S_OK; +} + +ALResult Tr2TextureAL::CreateViews( + ID3D11Resource* texture, + const Tr2BitmapDimensions& desc, + const Tr2MsaaDesc& msaa, + Tr2GpuUsage::Type gpuUsage, + Tr2CpuUsage::Type cpuUsage, + bool createSrgb, + Tr2PrimaryRenderContextAL& renderContext ) +{ + CCP_UNUSED( cpuUsage ); - ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + CComPtr view[Tr2RenderContextEnum::_COLOR_SPACE_COUNT]; + std::vector> renderTargets; + CComPtr depthStencil[DepthOption::COUNT]; + std::vector> uav; + + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + memset( &srvDesc, 0, sizeof( srvDesc ) ); - //Note: synchronize is ignored on DX11, as the current code needs significant refactoring to support asynchronous mapping. + srvDesc.Format = GetSrvFormat( desc.GetFormat() ); - data = nullptr; - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) { - return E_INVALIDCALL; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; + srvDesc.Texture1D.MipLevels = desc.GetTrueMipCount(); } - - if( !IsValid() || !renderContext.IsValid() ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) { - return E_FAIL; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + srvDesc.Texture3D.MipLevels = desc.GetTrueMipCount(); } - if( m_desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - return E_FAIL; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; + srvDesc.TextureCube.MipLevels = desc.GetTrueMipCount(); } - - if( !region.IsValidForBitmap( m_desc ) ) + else if( msaa.samples > 1 ) { - return E_INVALIDARG; + srvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY : D3D11_SRV_DIMENSION_TEXTURE2DMS; + srvDesc.Texture2DMSArray.ArraySize = desc.GetArraySize(); } - if( !region.IsSingleSubresource() ) + else { - return E_INVALIDARG; + srvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DARRAY : D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.GetTrueMipCount(); + srvDesc.Texture2DArray.ArraySize = desc.GetArraySize(); } - - if( !m_stagingTexture ) + FORWARD_HR( renderContext.m_d3dDevice11->CreateShaderResourceView( texture, &srvDesc, &view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ) ); + if( createSrgb ) { - D3D11_TEXTURE2D_DESC desc; - memset( &desc, 0, sizeof( desc ) ); - desc.Width = m_desc.GetWidth(); - desc.Height = m_desc.GetHeight(); - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( m_desc.GetFormat() ) ); - - desc.Usage = D3D11_USAGE_STAGING; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - - desc.SampleDesc.Count = 1; - - if( !renderContext.m_secondaryDevice11 ) - { - return E_FAIL; - } - FORWARD_HR( renderContext.m_secondaryDevice11->CreateTexture2D( &desc, nullptr, &m_stagingTexture ) ); - if( !m_stagingTexture ) + srvDesc.Format = GetSrvFormat( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + if( FAILED( renderContext.m_d3dDevice11->CreateShaderResourceView( texture, &srvDesc, &view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ) ) { - return E_FAIL; + CCP_AL_LOGWARN( "Failed to create an sRGB view for the texture of format %i - will use the linear view instead", int( srvDesc.Format ) ); + view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; } } - - if( region.HasBox() ) - { - D3D11_BOX box = { region.m_box.left, region.m_box.top, region.m_box.front, region.m_box.right, region.m_box.bottom, region.m_box.back }; - renderContext.m_context->CopySubresourceRegion( m_stagingTexture, 0, 0, 0, 0, m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), &box ); - } else { - renderContext.m_context->CopySubresourceRegion( m_stagingTexture, 0, 0, 0, 0, m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), nullptr ); - } - - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - HRESULT hr = renderContext.m_context->Map( m_stagingTexture, 0, D3D11_MAP_READ, 0, &ms ); - data = ms.pData; - pitch = ms.RowPitch; - if( !ms.pData ) - { - return E_FAIL; + view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; } - return hr; } - void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& renderContext ) + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) { - if( !m_stagingTexture || !renderContext.IsValid() ) + D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; + memset( &rtvDesc, 0, sizeof( rtvDesc ) ); + + rtvDesc.Format = static_cast( desc.GetFormat() ); + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) { - return; + rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D; } - renderContext.m_context->Unmap( m_stagingTexture, 0 ); - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) { - m_stagingTexture = nullptr; + rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D; + rtvDesc.Texture3D.WSize = 1; } - } - - ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - data = nullptr; - - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - return E_INVALIDCALL; + rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY; + rtvDesc.Texture2DArray.ArraySize = 1; } - if( !IsValid() || !renderContext.IsValid() ) + else if( msaa.samples > 1 ) { - return E_FAIL; + rtvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY : D3D11_RTV_DIMENSION_TEXTURE2DMS; + rtvDesc.Texture2DMSArray.ArraySize = 1; } - if( !region.IsValidForBitmap( m_desc ) ) + else { - return E_INVALIDARG; + rtvDesc.ViewDimension = desc.GetArraySize() > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DARRAY : D3D11_RTV_DIMENSION_TEXTURE2D; + rtvDesc.Texture2DArray.ArraySize = 1; } - if( !region.IsSingleSubresource() ) + + renderTargets.resize( 2 ); + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ) ); + if( createSrgb ) { - return E_INVALIDARG; + rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB] ) ); } - if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) + else { - return E_INVALIDARG; + renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; } - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) { - D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; - HRESULT hr = renderContext.m_context->Map( m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), D3D11_MAP_WRITE_DISCARD, 0, &ms ); - if( FAILED( hr ) ) - { - pitch = 0; - return hr; - } - if( !ms.pData ) - { - pitch = 0; - return E_FAIL; - } - if( region.HasBox() ) - { - ms.pData = static_cast( ms.pData ) + region.m_box.left * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ) + region.m_box.top * ms.RowPitch + region.m_box.front * ms.DepthPitch; - } -#if TRINITY_AL_GUARD_LOCKS - size_t size; - if( region.HasBox() ) + renderTargets.resize( desc.GetDepth() * 2 ); + for( uint32_t i = 1; i < desc.GetDepth(); ++i ) { - size = ms.RowPitch * ( region.m_box.bottom - region.m_box.top ); + rtvDesc.Texture3D.FirstWSlice = i; + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2] ) ); + if( createSrgb ) + { + rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] ) ); + } + else + { + renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2]; + } } - else + } + else if( desc.GetArraySize() > 1 ) + { + renderTargets.resize( desc.GetArraySize() * 2 ); + for( uint32_t i = 1; i < desc.GetArraySize(); ++i ) { - size = ms.RowPitch * m_desc.GetMipHeight( region.m_startMipLevel ); + rtvDesc.Texture2DArray.FirstArraySlice = i; + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2] ) ); + if( createSrgb ) + { + rtvDesc.Format = static_cast( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + FORWARD_HR( renderContext.m_d3dDevice11->CreateRenderTargetView( texture, &rtvDesc, &renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] ) ); + } + else + { + renderTargets[Tr2RenderContextEnum::COLOR_SPACE_SRGB + i * 2] = renderTargets[Tr2RenderContextEnum::COLOR_SPACE_LINEAR + i * 2]; + } } + } + } - m_lockGuard.Lock( size, ms.pData ); - data = m_lockGuard.GetMemory(); - pitch = ms.RowPitch; -#else - data = ms.pData; - pitch = ms.RowPitch; -#endif - m_lockedSubresource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); - return hr; + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + D3D11_DEPTH_STENCIL_VIEW_DESC descDSV; + memset( &descDSV, 0, sizeof( descDSV ) ); + descDSV.Format = static_cast( desc.GetFormat() ); + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) + { + descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY; + descDSV.Texture2DArray.ArraySize = 6; + } + else if( msaa.samples > 1 ) + { + descDSV.ViewDimension = desc.GetArraySize() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY : D3D11_DSV_DIMENSION_TEXTURE2DMS; + descDSV.Texture2DMSArray.ArraySize = desc.GetArraySize(); } else { - const uint32_t w = region.HasBox() ? region.GetWidth() : m_desc.GetMipWidth( region.m_startMipLevel ); - const uint32_t h = region.HasBox() ? region.GetHeight() : m_desc.GetMipHeight( region.m_startMipLevel ); - const uint32_t d = std::max( 1u, region.HasBox() ? region.GetDepth() : m_desc.GetMipDepth( region.m_startMipLevel ) ); - pitch = w * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + descDSV.ViewDimension = desc.GetArraySize() > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DARRAY : D3D11_DSV_DIMENSION_TEXTURE2D; + descDSV.Texture2DArray.ArraySize = desc.GetArraySize(); + } - CcpAlignedMallocBuffer buf( "Tr2TextureAL::MapForWriting", pitch * h * d, 32 ); - m_writeStaging.swap( buf ); + FORWARD_HR( renderContext.m_d3dDevice11->CreateDepthStencilView( texture, &descDSV, &depthStencil[DepthOption::READ_WRITE] ) ); + descDSV.Flags |= D3D11_DSV_READ_ONLY_DEPTH; + FORWARD_HR( renderContext.m_d3dDevice11->CreateDepthStencilView( texture, &descDSV, &depthStencil[DepthOption::READ_ONLY] ) ); + } - if( region.HasBox() ) - { - m_writeBox = region.m_box; - } - else + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + D3D11_UNORDERED_ACCESS_VIEW_DESC descUAV; + memset( &descUAV, 0, sizeof( descUAV ) ); + descUAV.Format = static_cast( desc.GetFormat() ); + uav.resize( desc.GetTrueMipCount() ); + for( uint32_t mip = 0; mip < desc.GetTrueMipCount(); ++mip ) + { + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_1D ) { - m_writeBox = { 0, 0, 0, w, h, d }; + descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE1D; + descUAV.Texture1D.MipSlice = mip; } - - if( m_writeBox.right > m_desc.GetMipWidth( region.m_startMipLevel ) || m_writeBox.bottom > m_desc.GetMipHeight( region.m_startMipLevel ) || m_writeBox.back > m_desc.GetMipDepth( region.m_startMipLevel ) ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) { - CCP_LOGERR( "TrinityAL: invalid rectangle in Tr2TextureAL::LockWriting" ); - m_writeStaging.clear(); - CCP_ASSERT( false ); - return E_FAIL; + descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE3D; + descUAV.Texture3D.WSize = (UINT)-1; + descUAV.Texture3D.MipSlice = mip; } - - if( m_writeStaging.empty() ) + else if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - return E_OUTOFMEMORY; + descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; + descUAV.Texture2DArray.ArraySize = 6; + descUAV.Texture2DArray.MipSlice = mip; } -#if TRINITY_AL_GUARD_LOCKS - size_t size; - if( region.HasBox() ) + else if( desc.GetArraySize() > 1 ) { - size = pitch * region.GetHeight() * region.GetDepth(); + descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY; + descUAV.Texture2DArray.ArraySize = desc.GetArraySize(); + descUAV.Texture2DArray.MipSlice = mip; } else { - size = pitch * m_desc.GetMipHeight( region.m_startMipLevel ) * m_desc.GetMipDepth( region.m_startMipLevel ); + descUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D; + descUAV.Texture2D.MipSlice = mip; } + FORWARD_HR( renderContext.m_d3dDevice11->CreateUnorderedAccessView( texture, &descUAV, &uav[mip] ) ); + } + } - m_lockGuard.Lock( size, m_writeStaging.get() ); - data = m_lockGuard.GetMemory(); -#else - data = m_writeStaging.get(); -#endif + m_texture = texture; + m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR]; + m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = view[Tr2RenderContextEnum::COLOR_SPACE_SRGB]; + m_renderTarget = renderTargets; + m_depthStencil[DepthOption::READ_WRITE] = depthStencil[DepthOption::READ_WRITE]; + m_depthStencil[DepthOption::READ_ONLY] = depthStencil[DepthOption::READ_ONLY]; + m_uav = uav; + return S_OK; +} - m_lockedSubresource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); - return S_OK; - } +void Tr2TextureAL::Destroy() +{ + m_texture = nullptr; + m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = nullptr; + m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; + m_renderTarget.clear(); + m_depthStencil[DepthOption::READ_WRITE] = nullptr; + m_depthStencil[DepthOption::READ_ONLY] = nullptr; + m_uav.clear(); + m_stagingTexture = nullptr; + m_memory.Reset(); + memset( &m_desc, 0, sizeof( m_desc ) ); + m_msaa = Tr2MsaaDesc(); + m_gpuUsage = Tr2GpuUsage::NONE; + m_cpuUsage = Tr2CpuUsage::NONE; + m_writeStaging.clear(); + m_lockedSubresource = 0; + m_writeBox = { 0, 0, 0, 0, 0, 0 }; +} + +bool Tr2TextureAL::IsValid() const +{ + return m_texture != nullptr; +} + +Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const +{ + return m_desc; +} + +const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const +{ + return m_msaa; +} + +Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const +{ + return m_gpuUsage; +} + +Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const +{ + return m_cpuUsage; +} + +ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + + //Note: synchronize is ignored on DX11, as the current code needs significant refactoring to support asynchronous mapping. + + data = nullptr; + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) + { + return E_INVALIDCALL; + } + + if( !IsValid() || !renderContext.IsValid() ) + { + return E_FAIL; + } + if( m_desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D ) + { + return E_FAIL; + } + + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; } - void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) + if( !m_stagingTexture ) { - if( !renderContext.IsValid() ) + D3D11_TEXTURE2D_DESC desc; + memset( &desc, 0, sizeof( desc ) ); + desc.Width = m_desc.GetWidth(); + desc.Height = m_desc.GetHeight(); + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = static_cast( Tr2RenderContextEnum::MakeTypeless( m_desc.GetFormat() ) ); + + desc.Usage = D3D11_USAGE_STAGING; + desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; + + desc.SampleDesc.Count = 1; + + if( !renderContext.m_secondaryDevice11 ) { - return; + return E_FAIL; } -#if TRINITY_AL_GUARD_LOCKS - m_lockGuard.Unlock(); -#endif - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + FORWARD_HR( renderContext.m_secondaryDevice11->CreateTexture2D( &desc, nullptr, &m_stagingTexture ) ); + if( !m_stagingTexture ) { - renderContext.m_context->Unmap( m_texture, m_lockedSubresource ); + return E_FAIL; } - else - { - const uint32_t w = m_writeBox.GetWidth(); - const uint32_t pitch = w * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + } - if( renderContext.m_context ) - { - D3D11_BOX box; - box.left = m_writeBox.left; - box.top = m_writeBox.top; - box.right = m_writeBox.right; - box.bottom = m_writeBox.bottom; - box.front = m_writeBox.front; - box.back = m_writeBox.back; + if( region.HasBox() ) + { + D3D11_BOX box = { region.m_box.left, region.m_box.top, region.m_box.front, region.m_box.right, region.m_box.bottom, region.m_box.back }; + renderContext.m_context->CopySubresourceRegion( m_stagingTexture, 0, 0, 0, 0, m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), &box ); + } + else + { + renderContext.m_context->CopySubresourceRegion( m_stagingTexture, 0, 0, 0, 0, m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), nullptr ); + } - auto mip = m_lockedSubresource % m_desc.GetTrueMipCount(); + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + HRESULT hr = renderContext.m_context->Map( m_stagingTexture, 0, D3D11_MAP_READ, 0, &ms ); + data = ms.pData; + pitch = ms.RowPitch; + if( !ms.pData ) + { + return E_FAIL; + } + return hr; +} - if( m_writeBox.right > m_desc.GetMipWidth( mip ) || m_writeBox.bottom > m_desc.GetMipHeight( mip ) || m_writeBox.back > m_desc.GetMipDepth( mip ) ) - { - CCP_LOGERR( "TrinityAL: invalid rectangle in Tr2TextureAL::UnlockWriting" ); - return; - } +void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& renderContext ) +{ + if( !m_stagingTexture || !renderContext.IsValid() ) + { + return; + } + renderContext.m_context->Unmap( m_stagingTexture, 0 ); + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) + { + m_stagingTexture = nullptr; + } +} - renderContext.m_context->UpdateSubresource( m_texture, m_lockedSubresource, &box, m_writeStaging.get(), pitch, pitch * m_writeBox.GetHeight() ); - } +ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + data = nullptr; - m_writeStaging.clear(); - m_writeBox = { 0, 0, 0, 0, 0, 0 }; - } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDCALL; + } + if( !IsValid() || !renderContext.IsValid() ) + { + return E_FAIL; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) + { + return E_INVALIDARG; } - ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ) + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; + HRESULT hr = renderContext.m_context->Map( m_texture, D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ), D3D11_MAP_WRITE_DISCARD, 0, &ms ); + if( FAILED( hr ) ) { - return E_INVALIDCALL; + pitch = 0; + return hr; } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + if( !ms.pData ) { - return E_INVALIDCALL; + pitch = 0; + return E_FAIL; } - - if( !IsValid() || !renderContext.IsValid() ) + if( region.HasBox() ) { - return E_INVALIDCALL; + ms.pData = static_cast( ms.pData ) + region.m_box.left * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ) + region.m_box.top * ms.RowPitch + region.m_box.front * ms.DepthPitch; } - - if( !region.IsValidForBitmap( m_desc ) ) +#if TRINITY_AL_GUARD_LOCKS + size_t size; + if( region.HasBox() ) { - return E_INVALIDARG; + size = ms.RowPitch * ( region.m_box.bottom - region.m_box.top ); } - if( !region.IsSingleSubresource() ) + else { - return E_INVALIDARG; + size = ms.RowPitch * m_desc.GetMipHeight( region.m_startMipLevel ); } - auto subResource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); + m_lockGuard.Lock( size, ms.pData ); + data = m_lockGuard.GetMemory(); + pitch = ms.RowPitch; +#else + data = ms.pData; + pitch = ms.RowPitch; +#endif + m_lockedSubresource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); + return hr; + } + else + { + const uint32_t w = region.HasBox() ? region.GetWidth() : m_desc.GetMipWidth( region.m_startMipLevel ); + const uint32_t h = region.HasBox() ? region.GetHeight() : m_desc.GetMipHeight( region.m_startMipLevel ); + const uint32_t d = std::max( 1u, region.HasBox() ? region.GetDepth() : m_desc.GetMipDepth( region.m_startMipLevel ) ); + pitch = w * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + + CcpAlignedMallocBuffer buf( "Tr2TextureAL::MapForWriting", pitch * h * d, 32 ); + m_writeStaging.swap( buf ); if( region.HasBox() ) { - D3D11_BOX box; - box.left = region.m_box.left; - box.top = region.m_box.top; - box.front = region.m_box.front; - box.right = region.m_box.right; - box.bottom = region.m_box.bottom; - box.back = region.m_box.back; - - renderContext.m_context->UpdateSubresource( m_texture, subResource, &box, source, pitch, slicePitch ); + m_writeBox = region.m_box; } else { - renderContext.m_context->UpdateSubresource( m_texture, subResource, nullptr, source, pitch, slicePitch ); + m_writeBox = { 0, 0, 0, w, h, d }; } - return S_OK; - } - - ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) - { - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !source.IsValid() ) + if( m_writeBox.right > m_desc.GetMipWidth( region.m_startMipLevel ) || m_writeBox.bottom > m_desc.GetMipHeight( region.m_startMipLevel ) || m_writeBox.back > m_desc.GetMipDepth( region.m_startMipLevel ) ) { - return E_INVALIDARG; + CCP_LOGERR( "TrinityAL: invalid rectangle in Tr2TextureAL::LockWriting" ); + m_writeStaging.clear(); + CCP_ASSERT( false ); + return E_FAIL; } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + + if( m_writeStaging.empty() ) { - return E_INVALIDCALL; + return E_OUTOFMEMORY; } - - if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) +#if TRINITY_AL_GUARD_LOCKS + size_t size; + if( region.HasBox() ) { - renderContext.m_context->CopyResource( m_texture, source.m_texture ); - return S_OK; + size = pitch * region.GetHeight() * region.GetDepth(); } - - Tr2TextureSubresource src = sourceSubresource; - Tr2TextureSubresource dst = destSubresource; - - if( !Crop( src, source.m_desc, dst, m_desc ) ) + else { - return E_FAIL; + size = pitch * m_desc.GetMipHeight( region.m_startMipLevel ) * m_desc.GetMipDepth( region.m_startMipLevel ); } - D3D11_BOX box = { src.m_box.left, src.m_box.top, src.m_box.front, src.m_box.right, src.m_box.bottom, src.m_box.back }; + m_lockGuard.Lock( size, m_writeStaging.get() ); + data = m_lockGuard.GetMemory(); +#else + data = m_writeStaging.get(); +#endif - const uint32_t srcMipCount = source.m_desc.GetTrueMipCount(); - const uint32_t dstMipCount = m_desc.GetTrueMipCount(); + m_lockedSubresource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); + return S_OK; + } +} - const uint32_t mipCount = std::min( src.GetMipCount(), dst.GetMipCount() ); +void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) + { + return; + } +#if TRINITY_AL_GUARD_LOCKS + m_lockGuard.Unlock(); +#endif + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + renderContext.m_context->Unmap( m_texture, m_lockedSubresource ); + } + else + { + const uint32_t w = m_writeBox.GetWidth(); + const uint32_t pitch = w * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); - for( uint32_t mip = 0; mip != mipCount; ++mip ) + if( renderContext.m_context ) { - for( uint32_t face = 0; face != src.GetFaceCount(); ++face ) - { - renderContext.m_context->CopySubresourceRegion( - m_texture, - D3D10CalcSubresource( dst.m_startMipLevel + mip, dst.m_startFace + face, dstMipCount ), - dst.m_box.left, - dst.m_box.top, - dst.m_box.front, - source.m_texture, - D3D10CalcSubresource( src.m_startMipLevel + mip, src.m_startFace + face, srcMipCount ), - &box ); - } + D3D11_BOX box; + box.left = m_writeBox.left; + box.top = m_writeBox.top; + box.right = m_writeBox.right; + box.bottom = m_writeBox.bottom; + box.front = m_writeBox.front; + box.back = m_writeBox.back; + + auto mip = m_lockedSubresource % m_desc.GetTrueMipCount(); - if( mip + 1 != src.GetMipCount() ) + if( m_writeBox.right > m_desc.GetMipWidth( mip ) || m_writeBox.bottom > m_desc.GetMipHeight( mip ) || m_writeBox.back > m_desc.GetMipDepth( mip ) ) { - AdvanceMip( src, source.m_desc, mip ); - AdvanceMip( dst, m_desc, mip ); + CCP_LOGERR( "TrinityAL: invalid rectangle in Tr2TextureAL::UnlockWriting" ); + return; } - box.left = box.left >> 1; - box.right = std::max( box.right >> 1, box.left + 1 ); - box.top = box.top >> 1; - box.bottom = std::max( box.bottom >> 1, box.top + 1 ); - box.front = box.front >> 1; - box.back = std::max( box.back >> 1, box.front + 1 ); + renderContext.m_context->UpdateSubresource( m_texture, m_lockedSubresource, &box, m_writeStaging.get(), pitch, pitch * m_writeBox.GetHeight() ); } - return S_OK; + m_writeStaging.clear(); + m_writeBox = { 0, 0, 0, 0, 0, 0 }; } +} - ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) +ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ) +{ + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDCALL; - } - if( m_desc.GetTrueMipCount() <= 1 ) - { - return S_OK; - } - renderContext.m_context->GenerateMips( m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ); - return S_OK; + return E_INVALIDCALL; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; } - ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) + if( !IsValid() || !renderContext.IsValid() ) { - if( m_msaa.samples <= 1 ) - { - return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); - } + return E_INVALIDCALL; + } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !destination.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) - { - return E_INVALIDARG; - } - if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) - { - return E_INVALIDARG; - } - if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) - { - return E_INVALIDARG; - } - if( destination.m_msaa.samples > 1 ) - { - return E_INVALIDARG; - } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } - renderContext.m_context->ResolveSubresource( destination.m_texture, 0, m_texture, 0, static_cast( m_desc.GetFormat() ) ); + auto subResource = D3D10CalcSubresource( region.m_startMipLevel, region.m_startFace, m_desc.GetTrueMipCount() ); - return S_OK; + if( region.HasBox() ) + { + D3D11_BOX box; + box.left = region.m_box.left; + box.top = region.m_box.top; + box.front = region.m_box.front; + box.right = region.m_box.right; + box.bottom = region.m_box.bottom; + box.back = region.m_box.back; + + renderContext.m_context->UpdateSubresource( m_texture, subResource, &box, source, pitch, slicePitch ); + } + else + { + renderContext.m_context->UpdateSubresource( m_texture, subResource, nullptr, source, pitch, slicePitch ); } - uintptr_t Tr2TextureAL::GetSharedHandle() const + return S_OK; +} + +ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() || !renderContext.IsValid() ) { - IDXGIResource* pOtherResource( NULL ); - if( m_texture == NULL ) - { - CCP_AL_LOGERR( "GetSharedHandle: texture is NULL" ); - return 0; - } - HRESULT HR = m_texture->QueryInterface( __uuidof( IDXGIResource ), (void**)&pOtherResource ); - if( FAILED( HR ) ) - { - CCP_AL_LOGERR( "GetSharedHandle: QueryInterface failed: 0x%x", HR ); - return 0; - } - else - { - HANDLE sharedHandle; - HR = pOtherResource->GetSharedHandle( &sharedHandle ); - if( FAILED( HR ) ) - { - CCP_AL_LOGERR( "GetSharedHandle: GetSharedHandle failed: 0x%x", HR ); - pOtherResource->Release(); - return 0; - } - pOtherResource->Release(); - return reinterpret_cast( sharedHandle ); - } + return E_INVALIDCALL; + } + if( !source.IsValid() ) + { + return E_INVALIDARG; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; } - ALResult Tr2TextureAL::Attach( ID3D11Texture2D* texture, Tr2PrimaryRenderContextAL& renderContext ) + if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) { - Destroy(); + renderContext.m_context->CopyResource( m_texture, source.m_texture ); + return S_OK; + } - if( texture == nullptr || !renderContext.IsValid() ) - { - return E_INVALIDARG; - } + Tr2TextureSubresource src = sourceSubresource; + Tr2TextureSubresource dst = destSubresource; - D3D11_TEXTURE2D_DESC dx11Desc; - texture->GetDesc( &dx11Desc ); + if( !Crop( src, source.m_desc, dst, m_desc ) ) + { + return E_FAIL; + } - Tr2BitmapDimensions desc( dx11Desc.Width, dx11Desc.Height, dx11Desc.MipLevels, static_cast( dx11Desc.Format ) ); - Tr2MsaaDesc msaa( dx11Desc.SampleDesc.Count, dx11Desc.SampleDesc.Quality ); - Tr2GpuUsage::Type gpuUsage = Tr2GpuUsage::NONE; - Tr2CpuUsage::Type cpuUsage = Tr2CpuUsage::NONE; + D3D11_BOX box = { src.m_box.left, src.m_box.top, src.m_box.front, src.m_box.right, src.m_box.bottom, src.m_box.back }; - cpuUsage = dx11Desc.SampleDesc.Count > 1 ? Tr2CpuUsage::NONE : Tr2CpuUsage::READ; - if( dx11Desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ ) - { - cpuUsage = cpuUsage | Tr2CpuUsage::READ; - } - if( dx11Desc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE ) - { - if( dx11Desc.Usage == D3D11_USAGE_DYNAMIC ) - { - cpuUsage = cpuUsage | Tr2CpuUsage::WRITE_OFTEN; - } - else - { - cpuUsage = cpuUsage | Tr2CpuUsage::WRITE; - } - } - gpuUsage = Tr2GpuUsage::NONE; - if( dx11Desc.BindFlags & D3D11_BIND_SHADER_RESOURCE ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::SHADER_RESOURCE; - } - if( dx11Desc.BindFlags & D3D11_BIND_RENDER_TARGET ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::RENDER_TARGET; - } - if( dx11Desc.BindFlags & D3D11_BIND_DEPTH_STENCIL ) + const uint32_t srcMipCount = source.m_desc.GetTrueMipCount(); + const uint32_t dstMipCount = m_desc.GetTrueMipCount(); + + const uint32_t mipCount = std::min( src.GetMipCount(), dst.GetMipCount() ); + + for( uint32_t mip = 0; mip != mipCount; ++mip ) + { + for( uint32_t face = 0; face != src.GetFaceCount(); ++face ) { - gpuUsage = gpuUsage | Tr2GpuUsage::DEPTH_STENCIL; + renderContext.m_context->CopySubresourceRegion( + m_texture, + D3D10CalcSubresource( dst.m_startMipLevel + mip, dst.m_startFace + face, dstMipCount ), + dst.m_box.left, + dst.m_box.top, + dst.m_box.front, + source.m_texture, + D3D10CalcSubresource( src.m_startMipLevel + mip, src.m_startFace + face, srcMipCount ), + &box ); } - if( dx11Desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS ) + + if( mip + 1 != src.GetMipCount() ) { - gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; + AdvanceMip( src, source.m_desc, mip ); + AdvanceMip( dst, m_desc, mip ); } - FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, true, renderContext ) ); - - m_texture = texture; - m_desc = desc; - m_msaa = msaa; - m_gpuUsage = gpuUsage; - m_cpuUsage = cpuUsage; + box.left = box.left >> 1; + box.right = std::max( box.right >> 1, box.left + 1 ); + box.top = box.top >> 1; + box.bottom = std::max( box.bottom >> 1, box.top + 1 ); + box.front = box.front >> 1; + box.back = std::max( box.back >> 1, box.front + 1 ); + } - m_memory.Set( Tr2MemoryCounterAL::TEXTURE, m_desc, m_msaa ); + return S_OK; +} +ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) +{ + if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + return E_INVALIDCALL; + } + if( m_desc.GetTrueMipCount() <= 1 ) + { return S_OK; } + renderContext.m_context->GenerateMips( m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] ); + return S_OK; +} - uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace ) const +ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) +{ + if( m_msaa.samples <= 1 ) { - return 0xffffffff; + return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); } - - uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t ) const + + if( !IsValid() || !renderContext.IsValid() ) { - return 0xffffffff; + return E_INVALIDCALL; } - - void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + if( !destination.IsValid() ) + { + return E_INVALIDARG; + } + if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) + { + return E_INVALIDARG; + } + if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) { - description["type"] = "Tr2TextureAL"; + return E_INVALIDARG; + } + if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) + { + return E_INVALIDARG; + } + if( destination.m_msaa.samples > 1 ) + { + return E_INVALIDARG; + } - unsigned size = 0; - for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) - { - size += m_desc.GetMipSize( i ); - } + renderContext.m_context->ResolveSubresource( destination.m_texture, 0, m_texture, 0, static_cast( m_desc.GetFormat() ) ); - description["size"] = std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); - description["width"] = std::to_string( m_desc.GetWidth() ); - description["height"] = std::to_string( m_desc.GetHeight() ); - description["depth"] = std::to_string( m_desc.GetDepth() ); - description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); - description["format"] = std::to_string( int( m_desc.GetFormat() ) ); - description["texType"] = std::to_string( int( m_desc.GetType() ) ); - description["array"] = std::to_string( m_desc.GetArraySize() ); - description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); - description["msaa"] = std::to_string( m_msaa.samples ); - description["name"] = m_name; - } - - ALResult Tr2TextureAL::SetName( const char* name ) - { - m_name = name; - SetDebugName( m_texture, name ); - for( auto& view : m_view ) - { - SetDebugName( view, name ); - } - for( auto& view : m_renderTarget ) + return S_OK; +} + +uintptr_t Tr2TextureAL::GetSharedHandle() const +{ + IDXGIResource* pOtherResource( NULL ); + if( m_texture == NULL ) + { + CCP_AL_LOGERR( "GetSharedHandle: texture is NULL" ); + return 0; + } + HRESULT HR = m_texture->QueryInterface( __uuidof( IDXGIResource ), (void**)&pOtherResource ); + if( FAILED( HR ) ) + { + CCP_AL_LOGERR( "GetSharedHandle: QueryInterface failed: 0x%x", HR ); + return 0; + } + else + { + HANDLE sharedHandle; + HR = pOtherResource->GetSharedHandle( &sharedHandle ); + if( FAILED( HR ) ) { - SetDebugName( view, name ); + CCP_AL_LOGERR( "GetSharedHandle: GetSharedHandle failed: 0x%x", HR ); + pOtherResource->Release(); + return 0; } - for( auto& view : m_depthStencil ) + pOtherResource->Release(); + return reinterpret_cast( sharedHandle ); + } +} + +ALResult Tr2TextureAL::Attach( ID3D11Texture2D* texture, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( texture == nullptr || !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + + D3D11_TEXTURE2D_DESC dx11Desc; + texture->GetDesc( &dx11Desc ); + + Tr2BitmapDimensions desc( dx11Desc.Width, dx11Desc.Height, dx11Desc.MipLevels, static_cast( dx11Desc.Format ) ); + Tr2MsaaDesc msaa( dx11Desc.SampleDesc.Count, dx11Desc.SampleDesc.Quality ); + Tr2GpuUsage::Type gpuUsage = Tr2GpuUsage::NONE; + Tr2CpuUsage::Type cpuUsage = Tr2CpuUsage::NONE; + + cpuUsage = dx11Desc.SampleDesc.Count > 1 ? Tr2CpuUsage::NONE : Tr2CpuUsage::READ; + if( dx11Desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ ) + { + cpuUsage = cpuUsage | Tr2CpuUsage::READ; + } + if( dx11Desc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE ) + { + if( dx11Desc.Usage == D3D11_USAGE_DYNAMIC ) { - SetDebugName( view, name ); + cpuUsage = cpuUsage | Tr2CpuUsage::WRITE_OFTEN; } - for( auto& view : m_uav ) + else { - SetDebugName( view, name ); + cpuUsage = cpuUsage | Tr2CpuUsage::WRITE; } - return S_OK; } + gpuUsage = Tr2GpuUsage::NONE; + if( dx11Desc.BindFlags & D3D11_BIND_SHADER_RESOURCE ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::SHADER_RESOURCE; + } + if( dx11Desc.BindFlags & D3D11_BIND_RENDER_TARGET ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::RENDER_TARGET; + } + if( dx11Desc.BindFlags & D3D11_BIND_DEPTH_STENCIL ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::DEPTH_STENCIL; + } + if( dx11Desc.BindFlags & D3D11_BIND_UNORDERED_ACCESS ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; + } + + FORWARD_HR( CreateViews( texture, desc, msaa, gpuUsage, cpuUsage, true, renderContext ) ); + + m_texture = texture; + m_desc = desc; + m_msaa = msaa; + m_gpuUsage = gpuUsage; + m_cpuUsage = cpuUsage; + + m_memory.Set( Tr2MemoryCounterAL::TEXTURE, m_desc, m_msaa ); + + return S_OK; +} + +uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace ) const +{ + return 0xffffffff; +} + +uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t ) const +{ + return 0xffffffff; +} + +void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2TextureAL"; - const char* Tr2TextureAL::GetName() const + unsigned size = 0; + for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) { - return m_name.c_str(); + size += m_desc.GetMipSize( i ); } - ID3D11Resource* Tr2TextureAL::GetResourceDx11() const + description["size"] = std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); + description["width"] = std::to_string( m_desc.GetWidth() ); + description["height"] = std::to_string( m_desc.GetHeight() ); + description["depth"] = std::to_string( m_desc.GetDepth() ); + description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); + description["format"] = std::to_string( int( m_desc.GetFormat() ) ); + description["texType"] = std::to_string( int( m_desc.GetType() ) ); + description["array"] = std::to_string( m_desc.GetArraySize() ); + description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); + description["msaa"] = std::to_string( m_msaa.samples ); + description["name"] = m_name; +} + +ALResult Tr2TextureAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_texture, name ); + for( auto& view : m_view ) + { + SetDebugName( view, name ); + } + for( auto& view : m_renderTarget ) + { + SetDebugName( view, name ); + } + for( auto& view : m_depthStencil ) + { + SetDebugName( view, name ); + } + for( auto& view : m_uav ) { - return m_texture; + SetDebugName( view, name ); } + return S_OK; +} + +const char* Tr2TextureAL::GetName() const +{ + return m_name.c_str(); +} + +ID3D11Resource* Tr2TextureAL::GetResourceDx11() const +{ + return m_texture; +} } diff --git a/trinityal/dx11/Tr2TextureALDx11.h b/trinityal/dx11/Tr2TextureALDx11.h index 7ceccafbf..b655adfcc 100644 --- a/trinityal/dx11/Tr2TextureALDx11.h +++ b/trinityal/dx11/Tr2TextureALDx11.h @@ -4,7 +4,7 @@ #ifndef Tr2TextureALDx11_h_ #define Tr2TextureALDx11_h_ -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2TextureAL.h" @@ -16,100 +16,100 @@ namespace TrinityALImpl { - class Tr2ResourceSetAL; +class Tr2ResourceSetAL; } namespace TrinityALImpl { - class Tr2TextureAL : public Tr2DeviceResourceAL - { - public: - Tr2TextureAL(); +class Tr2TextureAL : public Tr2DeviceResourceAL +{ +public: + Tr2TextureAL(); - ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); - ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); + ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BitmapDimensions& GetDesc() const; - const Tr2MsaaDesc& GetMsaaDesc() const; - Tr2GpuUsage::Type GetGpuUsage() const; - Tr2CpuUsage::Type GetCpuUsage() const; + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BitmapDimensions& GetDesc() const; + const Tr2MsaaDesc& GetMsaaDesc() const; + Tr2GpuUsage::Type GetGpuUsage() const; + Tr2CpuUsage::Type GetCpuUsage() const; - ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - return MapForReading( region, true, data, pitch, renderContext ); - } - ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + { + return MapForReading( region, true, data, pitch, renderContext ); + } + ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); - ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); - ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); - ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); - ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); - uintptr_t GetSharedHandle() const; + ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); + ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); + ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); + ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); + uintptr_t GetSharedHandle() const; - ALResult Attach( ID3D11Texture2D* texture, Tr2PrimaryRenderContextAL& renderContext ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - const char* GetName() const; + ALResult Attach( ID3D11Texture2D* texture, Tr2PrimaryRenderContextAL& renderContext ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + const char* GetName() const; - uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; - uint32_t GetUavIndexInHeap( uint32_t mip ) const; + uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; + uint32_t GetUavIndexInHeap( uint32_t mip ) const; - ID3D11Resource* GetResourceDx11() const; + ID3D11Resource* GetResourceDx11() const; - private: - struct DepthOption +private: + struct DepthOption + { + enum Type { - enum Type - { - READ_WRITE = 0, - READ_ONLY = 1, + READ_WRITE = 0, + READ_ONLY = 1, - COUNT = 2, - }; + COUNT = 2, }; + }; - ALResult CreateViews( - ID3D11Resource* texture, - const Tr2BitmapDimensions& desc, - const Tr2MsaaDesc& msaa, - Tr2GpuUsage::Type gpuUsage, - Tr2CpuUsage::Type cpuUsage, - bool createSrgb, - Tr2PrimaryRenderContextAL& renderContext ); - - CComPtr m_texture; - CComPtr m_view[Tr2RenderContextEnum::_COLOR_SPACE_COUNT]; - std::vector> m_renderTarget; - CComPtr m_depthStencil[DepthOption::COUNT]; - std::vector> m_uav; - CComPtr m_stagingTexture; - CcpAlignedMallocBuffer m_writeStaging; - Tr2TextureCoordBox m_writeBox; - - Tr2BitmapDimensions m_desc; - Tr2MsaaDesc m_msaa; - Tr2GpuUsage::Type m_gpuUsage; - Tr2CpuUsage::Type m_cpuUsage; - Tr2MemoryCounterAL m_memory; + ALResult CreateViews( + ID3D11Resource* texture, + const Tr2BitmapDimensions& desc, + const Tr2MsaaDesc& msaa, + Tr2GpuUsage::Type gpuUsage, + Tr2CpuUsage::Type cpuUsage, + bool createSrgb, + Tr2PrimaryRenderContextAL& renderContext ); + + CComPtr m_texture; + CComPtr m_view[Tr2RenderContextEnum::_COLOR_SPACE_COUNT]; + std::vector> m_renderTarget; + CComPtr m_depthStencil[DepthOption::COUNT]; + std::vector> m_uav; + CComPtr m_stagingTexture; + CcpAlignedMallocBuffer m_writeStaging; + Tr2TextureCoordBox m_writeBox; + + Tr2BitmapDimensions m_desc; + Tr2MsaaDesc m_msaa; + Tr2GpuUsage::Type m_gpuUsage; + Tr2CpuUsage::Type m_cpuUsage; + Tr2MemoryCounterAL m_memory; #if TRINITY_AL_GUARD_LOCKS - Tr2LockGuard m_lockGuard; + Tr2LockGuard m_lockGuard; #endif - uint32_t m_lockedSubresource; - std::string m_name; + uint32_t m_lockedSubresource; + std::string m_name; - friend class Tr2PrimaryRenderContextAL; - friend class Tr2RenderContextAL; - friend class Tr2ResourceSetAL; - }; + friend class Tr2PrimaryRenderContextAL; + friend class Tr2RenderContextAL; + friend class Tr2ResourceSetAL; +}; } #endif diff --git a/trinityal/dx11/Tr2VertexLayoutALDx11.cpp b/trinityal/dx11/Tr2VertexLayoutALDx11.cpp index 4feb06b38..9b9bcd7e1 100644 --- a/trinityal/dx11/Tr2VertexLayoutALDx11.cpp +++ b/trinityal/dx11/Tr2VertexLayoutALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2VertexLayoutALDx11.h" #include "Tr2VertexDefinition.h" @@ -13,230 +13,232 @@ using namespace Tr2RenderContextEnum; -namespace { +namespace +{ - const char* semanticNames[ Tr2VertexDefinition::NUM_USAGE_CODE ] = - { - "POSITION", - "COLOR", - "NORMAL", - "TANGENT", - "BINORMAL", - "TEXCOORD", - "BLENDINDICES", - "BLENDWEIGHT" - }; +const char* semanticNames[Tr2VertexDefinition::NUM_USAGE_CODE] = { + "POSITION", + "COLOR", + "NORMAL", + "TANGENT", + "BINORMAL", + "TEXCOORD", + "BLENDINDICES", + "BLENDWEIGHT" +}; + +DXGI_FORMAT GetDxgiDataType( Tr2VertexDefinition::DataType dataType ) +{ - DXGI_FORMAT GetDxgiDataType( Tr2VertexDefinition::DataType dataType ) +#define VD_CASE( x, y ) \ + case Tr2VertexDefinition::x: \ + return y; + switch( dataType ) { + VD_CASE( BYTE_1, DXGI_FORMAT_R8_SINT ); + VD_CASE( BYTE_2, DXGI_FORMAT_R8G8_SINT ); + VD_CASE( BYTE_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( BYTE_4, DXGI_FORMAT_R8G8B8A8_SINT ); + + VD_CASE( UBYTE_1, DXGI_FORMAT_R8_UINT ); + VD_CASE( UBYTE_2, DXGI_FORMAT_R8G8_UINT ); + VD_CASE( UBYTE_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( UBYTE_4, DXGI_FORMAT_R8G8B8A8_UINT ); + + VD_CASE( BYTE_1_NORM, DXGI_FORMAT_R8_SNORM ); + VD_CASE( BYTE_2_NORM, DXGI_FORMAT_R8G8_SNORM ); + VD_CASE( BYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( BYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_SNORM ); + + VD_CASE( UBYTE_1_NORM, DXGI_FORMAT_R8_UNORM ); + VD_CASE( UBYTE_2_NORM, DXGI_FORMAT_R8G8_UNORM ); + VD_CASE( UBYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( UBYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_UNORM ); + + + VD_CASE( SHORT_1, DXGI_FORMAT_R16_SINT ); + VD_CASE( SHORT_2, DXGI_FORMAT_R16G16_SINT ); + VD_CASE( SHORT_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( SHORT_4, DXGI_FORMAT_R16G16B16A16_SINT ); + + VD_CASE( USHORT_1, DXGI_FORMAT_R16_UINT ); + VD_CASE( USHORT_2, DXGI_FORMAT_R16G16_UINT ); + VD_CASE( USHORT_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( USHORT_4, DXGI_FORMAT_R16G16B16A16_UINT ); + + VD_CASE( SHORT_1_NORM, DXGI_FORMAT_R16_SNORM ); + VD_CASE( SHORT_2_NORM, DXGI_FORMAT_R16G16_SNORM ); + VD_CASE( SHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( SHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_SNORM ); + + VD_CASE( USHORT_1_NORM, DXGI_FORMAT_R16_UNORM ); + VD_CASE( USHORT_2_NORM, DXGI_FORMAT_R16G16_UNORM ); + VD_CASE( USHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( USHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_UNORM ); + + + VD_CASE( INT32_1, DXGI_FORMAT_R32_SINT ); + VD_CASE( INT32_2, DXGI_FORMAT_R32G32_SINT ); + VD_CASE( INT32_3, DXGI_FORMAT_R32G32B32_SINT ); + VD_CASE( INT32_4, DXGI_FORMAT_R32G32B32A32_SINT ); + + VD_CASE( UINT32_1, DXGI_FORMAT_R32_UINT ); + VD_CASE( UINT32_2, DXGI_FORMAT_R32G32_UINT ); + VD_CASE( UINT32_3, DXGI_FORMAT_R32G32B32_UINT ); + VD_CASE( UINT32_4, DXGI_FORMAT_R32G32B32A32_UINT ); + + + VD_CASE( FLOAT16_1, DXGI_FORMAT_R16_FLOAT ); + VD_CASE( FLOAT16_2, DXGI_FORMAT_R16G16_FLOAT ); + VD_CASE( FLOAT16_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( FLOAT16_4, DXGI_FORMAT_R16G16B16A16_FLOAT ); + + VD_CASE( FLOAT32_1, DXGI_FORMAT_R32_FLOAT ); + VD_CASE( FLOAT32_2, DXGI_FORMAT_R32G32_FLOAT ); + VD_CASE( FLOAT32_3, DXGI_FORMAT_R32G32B32_FLOAT ); + VD_CASE( FLOAT32_4, DXGI_FORMAT_R32G32B32A32_FLOAT ); + } -#define VD_CASE(x,y) case Tr2VertexDefinition::x : return y; - switch( dataType ) - { - VD_CASE( BYTE_1 , DXGI_FORMAT_R8_SINT ); - VD_CASE( BYTE_2 , DXGI_FORMAT_R8G8_SINT ); - VD_CASE( BYTE_3 , DXGI_FORMAT_UNKNOWN ); - VD_CASE( BYTE_4 , DXGI_FORMAT_R8G8B8A8_SINT ); - - VD_CASE( UBYTE_1 , DXGI_FORMAT_R8_UINT ); - VD_CASE( UBYTE_2 , DXGI_FORMAT_R8G8_UINT ); - VD_CASE( UBYTE_3 , DXGI_FORMAT_UNKNOWN ); - VD_CASE( UBYTE_4 , DXGI_FORMAT_R8G8B8A8_UINT ); - - VD_CASE( BYTE_1_NORM , DXGI_FORMAT_R8_SNORM ); - VD_CASE( BYTE_2_NORM , DXGI_FORMAT_R8G8_SNORM ); - VD_CASE( BYTE_3_NORM , DXGI_FORMAT_UNKNOWN ); - VD_CASE( BYTE_4_NORM , DXGI_FORMAT_R8G8B8A8_SNORM ); - - VD_CASE( UBYTE_1_NORM , DXGI_FORMAT_R8_UNORM ); - VD_CASE( UBYTE_2_NORM , DXGI_FORMAT_R8G8_UNORM ); - VD_CASE( UBYTE_3_NORM , DXGI_FORMAT_UNKNOWN ); - VD_CASE( UBYTE_4_NORM , DXGI_FORMAT_R8G8B8A8_UNORM ); - - - VD_CASE( SHORT_1 , DXGI_FORMAT_R16_SINT ); - VD_CASE( SHORT_2 , DXGI_FORMAT_R16G16_SINT ); - VD_CASE( SHORT_3 , DXGI_FORMAT_UNKNOWN ); - VD_CASE( SHORT_4 , DXGI_FORMAT_R16G16B16A16_SINT ); - - VD_CASE( USHORT_1 , DXGI_FORMAT_R16_UINT ); - VD_CASE( USHORT_2 , DXGI_FORMAT_R16G16_UINT ); - VD_CASE( USHORT_3 , DXGI_FORMAT_UNKNOWN ); - VD_CASE( USHORT_4 , DXGI_FORMAT_R16G16B16A16_UINT ); - - VD_CASE( SHORT_1_NORM , DXGI_FORMAT_R16_SNORM ); - VD_CASE( SHORT_2_NORM , DXGI_FORMAT_R16G16_SNORM ); - VD_CASE( SHORT_3_NORM , DXGI_FORMAT_UNKNOWN ); - VD_CASE( SHORT_4_NORM , DXGI_FORMAT_R16G16B16A16_SNORM ); - - VD_CASE( USHORT_1_NORM , DXGI_FORMAT_R16_UNORM ); - VD_CASE( USHORT_2_NORM , DXGI_FORMAT_R16G16_UNORM ); - VD_CASE( USHORT_3_NORM , DXGI_FORMAT_UNKNOWN ); - VD_CASE( USHORT_4_NORM , DXGI_FORMAT_R16G16B16A16_UNORM ); - - - VD_CASE( INT32_1 , DXGI_FORMAT_R32_SINT ); - VD_CASE( INT32_2 , DXGI_FORMAT_R32G32_SINT ); - VD_CASE( INT32_3 , DXGI_FORMAT_R32G32B32_SINT ); - VD_CASE( INT32_4 , DXGI_FORMAT_R32G32B32A32_SINT ); - - VD_CASE( UINT32_1 , DXGI_FORMAT_R32_UINT ); - VD_CASE( UINT32_2 , DXGI_FORMAT_R32G32_UINT ); - VD_CASE( UINT32_3 , DXGI_FORMAT_R32G32B32_UINT ); - VD_CASE( UINT32_4 , DXGI_FORMAT_R32G32B32A32_UINT ); - - - VD_CASE( FLOAT16_1 , DXGI_FORMAT_R16_FLOAT ); - VD_CASE( FLOAT16_2 , DXGI_FORMAT_R16G16_FLOAT ); - VD_CASE( FLOAT16_3 , DXGI_FORMAT_UNKNOWN ); - VD_CASE( FLOAT16_4 , DXGI_FORMAT_R16G16B16A16_FLOAT ); - - VD_CASE( FLOAT32_1 , DXGI_FORMAT_R32_FLOAT ); - VD_CASE( FLOAT32_2 , DXGI_FORMAT_R32G32_FLOAT ); - VD_CASE( FLOAT32_3 , DXGI_FORMAT_R32G32B32_FLOAT ); - VD_CASE( FLOAT32_4 , DXGI_FORMAT_R32G32B32A32_FLOAT ); - } - - return DXGI_FORMAT_UNKNOWN; - }; + return DXGI_FORMAT_UNKNOWN; +}; } namespace TrinityALImpl { - ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_FAIL; - } + return E_FAIL; + } - m_definition.resize( definition.m_items.size() ); + m_definition.resize( definition.m_items.size() ); - for( size_t i = 0; i != definition.m_items.size(); ++i ) - { - const Tr2VertexDefinition::Item& src = definition.m_items[i]; - D3D11_INPUT_ELEMENT_DESC& dst = m_definition[i]; + for( size_t i = 0; i != definition.m_items.size(); ++i ) + { + const Tr2VertexDefinition::Item& src = definition.m_items[i]; + D3D11_INPUT_ELEMENT_DESC& dst = m_definition[i]; - dst.SemanticName = semanticNames[src.m_usage]; - dst.SemanticIndex = src.m_usageIndex; + dst.SemanticName = semanticNames[src.m_usage]; + dst.SemanticIndex = src.m_usageIndex; - dst.Format = GetDxgiDataType( src.m_dataType ); - CCP_ASSERT( dst.Format != DXGI_FORMAT_UNKNOWN ); + dst.Format = GetDxgiDataType( src.m_dataType ); + CCP_ASSERT( dst.Format != DXGI_FORMAT_UNKNOWN ); - dst.InputSlot = src.m_stream; - dst.AlignedByteOffset = src.m_offset; - dst.InputSlotClass = src.m_instanceStepRate ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA; - dst.InstanceDataStepRate = src.m_instanceStepRate; - }; + dst.InputSlot = src.m_stream; + dst.AlignedByteOffset = src.m_offset; + dst.InputSlotClass = src.m_instanceStepRate ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA; + dst.InstanceDataStepRate = src.m_instanceStepRate; + }; - return S_OK; - } + return S_OK; +} - void Tr2VertexLayoutAL::Destroy() - { - m_layout.clear(); - m_definition.clear(); - } +void Tr2VertexLayoutAL::Destroy() +{ + m_layout.clear(); + m_definition.clear(); +} - static bool FindInputElement( const TrackableStdVector& elements, - const Tr2ShaderPipelineInputAL& element ) +static bool FindInputElement( const TrackableStdVector& elements, + const Tr2ShaderPipelineInputAL& element ) +{ + for( auto it = elements.begin(); it != elements.end(); ++it ) { - for( auto it = elements.begin(); it != elements.end(); ++it ) + if( element.usageIndex == it->SemanticIndex && strcmp( semanticNames[element.usage], it->SemanticName ) == 0 ) { - if( element.usageIndex == it->SemanticIndex && strcmp( semanticNames[element.usage], it->SemanticName ) == 0 ) - { - return true; - } + return true; } - return false; } + return false; +} - ALResult Tr2VertexLayoutAL::SetLayout( const TrinityALImpl::Tr2ShaderAL* vertexShader, Tr2RenderContextAL& renderContext ) const +ALResult Tr2VertexLayoutAL::SetLayout( const TrinityALImpl::Tr2ShaderAL* vertexShader, Tr2RenderContextAL& renderContext ) const +{ + if( !renderContext.m_secondaryDevice11 || !vertexShader || m_definition.empty() ) { - if( !renderContext.m_secondaryDevice11 || !vertexShader || m_definition.empty() ) - { - return E_FAIL; - } - auto found = m_layout.find( vertexShader->m_pipelineInputHash ); - if( found != m_layout.end() ) - { - renderContext.m_context->IASetInputLayout( found->second ); - return S_OK; - } + return E_FAIL; + } + auto found = m_layout.find( vertexShader->m_pipelineInputHash ); + if( found != m_layout.end() ) + { + renderContext.m_context->IASetInputLayout( found->second ); + return S_OK; + } - Tr2ShaderBytecodeAL bytecode; - CR_RETURN_HR( vertexShader->GetBytecode( bytecode ) ); + Tr2ShaderBytecodeAL bytecode; + CR_RETURN_HR( vertexShader->GetBytecode( bytecode ) ); - const auto& definition = vertexShader->m_signature; - auto patchedDefinition = m_definition; - for( auto it = definition.pipelineInputs.begin(); it != definition.pipelineInputs.end(); ++it ) + const auto& definition = vertexShader->m_signature; + auto patchedDefinition = m_definition; + for( auto it = definition.pipelineInputs.begin(); it != definition.pipelineInputs.end(); ++it ) + { + if( !FindInputElement( m_definition, *it ) ) { - if( !FindInputElement( m_definition, *it ) ) + D3D11_INPUT_ELEMENT_DESC fakeElement; + fakeElement.AlignedByteOffset = 0; + switch( it->type ) { - D3D11_INPUT_ELEMENT_DESC fakeElement; - fakeElement.AlignedByteOffset = 0; - switch( it->type ) - { - case Tr2ShaderPipelineInputAL::INT: - fakeElement.Format = DXGI_FORMAT_R8G8B8A8_SINT; - break; - case Tr2ShaderPipelineInputAL::UINT: - fakeElement.Format = DXGI_FORMAT_R8G8B8A8_UINT; - break; - default: - fakeElement.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; - } - fakeElement.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; - fakeElement.InstanceDataStepRate = 0; - fakeElement.SemanticIndex = it->usageIndex; - fakeElement.SemanticName = semanticNames[it->usage]; - if( it->usedMask == 0 ) - { - fakeElement.InputSlot = 4; - } - else - { - fakeElement.InputSlot = 4; - } - patchedDefinition.push_back( fakeElement ); + case Tr2ShaderPipelineInputAL::INT: + fakeElement.Format = DXGI_FORMAT_R8G8B8A8_SINT; + break; + case Tr2ShaderPipelineInputAL::UINT: + fakeElement.Format = DXGI_FORMAT_R8G8B8A8_UINT; + break; + default: + fakeElement.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; } - } - - CComPtr layout; - long result = renderContext.m_secondaryDevice11->CreateInputLayout( - patchedDefinition.data(), - (uint32_t)patchedDefinition.size(), - bytecode.bytecode, - bytecode.size, - &layout ); - - if( result == S_OK ) - { - if( !m_name.empty() ) + fakeElement.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; + fakeElement.InstanceDataStepRate = 0; + fakeElement.SemanticIndex = it->usageIndex; + fakeElement.SemanticName = semanticNames[it->usage]; + if( it->usedMask == 0 ) { - layout->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( m_name.size() ), m_name.c_str() ); + fakeElement.InputSlot = 4; } - m_layout[vertexShader->m_pipelineInputHash] = layout; - renderContext.m_context->IASetInputLayout( layout ); + else + { + fakeElement.InputSlot = 4; + } + patchedDefinition.push_back( fakeElement ); } - return result; } - void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2VertexLayoutAL"; - } + CComPtr layout; + long result = renderContext.m_secondaryDevice11->CreateInputLayout( + patchedDefinition.data(), + (uint32_t)patchedDefinition.size(), + bytecode.bytecode, + bytecode.size, + &layout ); - ALResult Tr2VertexLayoutAL::SetName( const char* name ) + if( result == S_OK ) { - m_name = name; - for( auto& vl : m_layout ) + if( !m_name.empty() ) { - SetDebugName( vl.second, name ); + layout->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( m_name.size() ), m_name.c_str() ); } - return S_OK; + m_layout[vertexShader->m_pipelineInputHash] = layout; + renderContext.m_context->IASetInputLayout( layout ); } + return result; +} + +void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2VertexLayoutAL"; +} + +ALResult Tr2VertexLayoutAL::SetName( const char* name ) +{ + m_name = name; + for( auto& vl : m_layout ) + { + SetDebugName( vl.second, name ); + } + return S_OK; +} } #endif // DX11? diff --git a/trinityal/dx11/Tr2VertexLayoutALDx11.h b/trinityal/dx11/Tr2VertexLayoutALDx11.h index b917f61e0..b9ac7350c 100644 --- a/trinityal/dx11/Tr2VertexLayoutALDx11.h +++ b/trinityal/dx11/Tr2VertexLayoutALDx11.h @@ -3,7 +3,7 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "../include/Tr2VertexLayoutAL.h" @@ -19,41 +19,41 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2ShaderAL; +class Tr2ShaderAL; - class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +{ +public: + Tr2VertexLayoutAL() : + m_definition( "Tr2VertexLayoutAL::m_definition" ) + { + } + + ALResult Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const { - public: - Tr2VertexLayoutAL() - : m_definition( "Tr2VertexLayoutAL::m_definition" ) - { - } - - ALResult Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const - { - return !m_definition.empty(); - } - void Destroy(); - - ALResult SetLayout( const TrinityALImpl::Tr2ShaderAL* vertexShader, Tr2RenderContextAL& renderContext ) const; - - Tr2ALMemoryType GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2VertexLayoutAL( const Tr2VertexLayoutAL& )/* = delete */; - Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& )/* = delete */; - - TrackableStdVector m_definition; - mutable std::map> m_layout; - std::string m_name; - }; + return !m_definition.empty(); } + void Destroy(); + + ALResult SetLayout( const TrinityALImpl::Tr2ShaderAL* vertexShader, Tr2RenderContextAL& renderContext ) const; + + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2VertexLayoutAL( const Tr2VertexLayoutAL& ) /* = delete */; + Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& ) /* = delete */; + + TrackableStdVector m_definition; + mutable std::map> m_layout; + std::string m_name; +}; +} #endif // DX11? diff --git a/trinityal/dx11/Tr2VideoAdapterInfoALDx11.cpp b/trinityal/dx11/Tr2VideoAdapterInfoALDx11.cpp index 0845e0400..f811d6475 100644 --- a/trinityal/dx11/Tr2VideoAdapterInfoALDx11.cpp +++ b/trinityal/dx11/Tr2VideoAdapterInfoALDx11.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #include "Tr2VideoAdapterInfoALDx11.h" #include "Tr2AdapterStructures.h" @@ -40,12 +40,12 @@ struct DeviceInfo std::vector s_adapters; std::vector s_deviceInfo; -HRESULT GetFallbackMode( DXGI_MODE_DESC &desc ) +HRESULT GetFallbackMode( DXGI_MODE_DESC& desc ) { DEVMODE devMode; - memset(&devMode, 0, sizeof(devMode)); - devMode.dmSize = sizeof(devMode); - if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &devMode)) + memset( &devMode, 0, sizeof( devMode ) ); + devMode.dmSize = sizeof( devMode ); + if( !EnumDisplaySettings( 0, ENUM_CURRENT_SETTINGS, &devMode ) ) { return E_FAIL; } @@ -70,7 +70,7 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat } uint32_t count = 0; - HRESULT hr = output.m_output->GetDisplayModeList( + HRESULT hr = output.m_output->GetDisplayModeList( backBufferFormat, 0, &count, @@ -81,12 +81,12 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat displayModes.resize( 1 ); return GetFallbackMode( displayModes[0] ); } - if ( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM ) + if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM ) { CCP_LOGWARN( "Tr2VideoAdapterInfo: failed to enumerate display modes (running in remote desktop?)" ); count = 1; } - else if ( FAILED( hr ) || (count == 0) ) + else if( FAILED( hr ) || ( count == 0 ) ) { return hr; } @@ -95,14 +95,14 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat displayModes.resize( count ); hr = output.m_output->GetDisplayModeList( static_cast( backBufferFormat ), - 0, - &count, - &displayModes[0] ); - if ( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && !displayModes.empty() ) + 0, + &count, + &displayModes[0] ); + if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && !displayModes.empty() ) { return GetFallbackMode( displayModes[0] ); } - else if ( FAILED( hr ) ) + else if( FAILED( hr ) ) { return hr; } @@ -117,14 +117,14 @@ ALResult InitializeDirect3D() s_factory = nullptr; CR_RETURN_HR( CreateDXGIFactory1( - __uuidof( IDXGIFactory1 ), - (void**)( &s_factory ) ) ); + __uuidof( IDXGIFactory1 ), + (void**)( &s_factory ) ) ); const D3D_FEATURE_LEVEL levelWanted = D3D_FEATURE_LEVEL_11_0; D3D_FEATURE_LEVEL levelSupported; uint32_t dwFlags = 0; - if ( !s_factory ) + if( !s_factory ) { return E_FAIL; } @@ -132,19 +132,21 @@ ALResult InitializeDirect3D() CComPtr adapterPtr; uint32_t adapterIndex = 0; - while ( SUCCEEDED( s_factory->EnumAdapters1( adapterIndex++, &adapterPtr ) ) ) + while( SUCCEEDED( s_factory->EnumAdapters1( adapterIndex++, &adapterPtr ) ) ) { CComPtr device; CComPtr context; - if ( FAILED( D3D11CreateDevice( adapterPtr, - D3D_DRIVER_TYPE_UNKNOWN, - 0, dwFlags, - &levelWanted, 1, - D3D11_SDK_VERSION, - &device, - &levelSupported, - &context ) ) ) + if( FAILED( D3D11CreateDevice( adapterPtr, + D3D_DRIVER_TYPE_UNKNOWN, + 0, + dwFlags, + &levelWanted, + 1, + D3D11_SDK_VERSION, + &device, + &levelSupported, + &context ) ) ) { continue; } @@ -156,7 +158,7 @@ ALResult InitializeDirect3D() DeviceInfo deviceInfo; memset( deviceInfo.m_formatSupport, 0, sizeof( deviceInfo.m_formatSupport ) ); - for ( unsigned i = 0; i < DeviceInfo::FORMAT_COUNT; ++i ) + for( unsigned i = 0; i < DeviceInfo::FORMAT_COUNT; ++i ) { device->CheckFormatSupport( static_cast( i ), deviceInfo.m_formatSupport + i ); } @@ -164,7 +166,7 @@ ALResult InitializeDirect3D() CComPtr outputPtr; uint32_t outputIndex = 0; bool hasValidOutputs = false; - while ( SUCCEEDED( adapterPtr->EnumOutputs( outputIndex++, &outputPtr ) ) ) + while( SUCCEEDED( adapterPtr->EnumOutputs( outputIndex++, &outputPtr ) ) ) { AdapterInfo adapter; adapter.m_adapter = adapterPtr; @@ -184,7 +186,7 @@ ALResult InitializeDirect3D() } outputPtr.Release(); } - if ( hasValidOutputs ) + if( hasValidOutputs ) { s_deviceInfo.push_back( deviceInfo ); } @@ -197,28 +199,28 @@ ALResult InitializeDirect3D() } -#define CHECK_INIT \ - if( !s_factory ) \ - { \ - CR_RETURN_HR( InitializeDirect3D() ); \ +#define CHECK_INIT \ + if( !s_factory ) \ + { \ + CR_RETURN_HR( InitializeDirect3D() ); \ } -#define CHECK_VALID_ADAPTER \ - if( adapterIndex >= s_adapters.size() ) \ - { \ - return E_INVALIDARG; \ +#define CHECK_VALID_ADAPTER \ + if( adapterIndex >= s_adapters.size() ) \ + { \ + return E_INVALIDARG; \ } -#define CHECK_INIT_BOOL \ - if( !s_factory && !SUCCEEDED( InitializeDirect3D() ) ) \ - { \ - return false; \ +#define CHECK_INIT_BOOL \ + if( !s_factory && !SUCCEEDED( InitializeDirect3D() ) ) \ + { \ + return false; \ } -#define CHECK_VALID_ADAPTER_BOOL \ - if( adapterIndex >= s_adapters.size() ) \ - { \ - return false; \ +#define CHECK_VALID_ADAPTER_BOOL \ + if( adapterIndex >= s_adapters.size() ) \ + { \ + return false; \ } ALResult Tr2VideoAdapterInfo::GetAdapterCount( uint32_t& count ) @@ -246,7 +248,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterInfo( unsigned adapterIndex, info.deviceID = desc.DeviceId; info.subSystemID = desc.SubSysId; info.revision = desc.Revision; - memcpy(info.luid, &desc.AdapterLuid, sizeof(LUID)); + memcpy( info.luid, &desc.AdapterLuid, sizeof( LUID ) ); memset( &info.deviceIdentifier, 0, sizeof( info.deviceIdentifier ) ); return S_OK; @@ -275,7 +277,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, return E_FAIL; } - const auto & mm = s_adapters[adapterIndex].m_displayModes[DXGI_FORMAT_B8G8R8A8_UNORM][0]; + const auto& mm = s_adapters[adapterIndex].m_displayModes[DXGI_FORMAT_B8G8R8A8_UNORM][0]; mode.format = static_cast( mm.Format ); mode.refreshRateDenominator = mm.RefreshRate.Denominator; mode.refreshRateNumerator = mm.RefreshRate.Numerator; @@ -285,7 +287,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, DEVMODE devMode; memset( &devMode, 0, sizeof( devMode ) ); devMode.dmSize = sizeof( devMode ); - if ( !EnumDisplaySettings( monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode ) ) + if( !EnumDisplaySettings( monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode ) ) { return E_FAIL; } @@ -304,7 +306,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterModeCount( unsigned adapterIndex, count = 0; - auto & output = s_adapters[adapterIndex]; + auto& output = s_adapters[adapterIndex]; CR_RETURN_HR( PopulateDisplayModes( output, static_cast( backBufferFormat ) ) ); count = unsigned( output.m_displayModes[static_cast( backBufferFormat )].size() ); @@ -319,16 +321,16 @@ ALResult Tr2VideoAdapterInfo::GetAdapterMode( unsigned adapterIndex, CHECK_INIT; CHECK_VALID_ADAPTER; - auto & output = s_adapters[adapterIndex]; + auto& output = s_adapters[adapterIndex]; CR_RETURN_HR( PopulateDisplayModes( output, static_cast( backBufferFormat ) ) ); auto& displayModes = output.m_displayModes[static_cast( backBufferFormat )]; - if ( modeIndex >= displayModes.size() ) + if( modeIndex >= displayModes.size() ) { return E_INVALIDARG; } - auto & mm = displayModes[modeIndex]; + auto& mm = displayModes[modeIndex]; mode.format = static_cast( mm.Format ); mode.height = mm.Height; @@ -340,7 +342,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterMode( unsigned adapterIndex, return S_OK; } -ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned/*adapterIndex*/, +ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned /*adapterIndex*/, unsigned& maxWidth ) { maxWidth = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; @@ -353,7 +355,7 @@ bool Tr2VideoAdapterInfo::SupportsBackBufferFormat( unsigned adapterIndex, CHECK_INIT_BOOL; CHECK_VALID_ADAPTER_BOOL; - if ( backBufferFormat >= (unsigned)DeviceInfo::FORMAT_COUNT ) + if( backBufferFormat >= (unsigned)DeviceInfo::FORMAT_COUNT ) { return false; } @@ -361,7 +363,7 @@ bool Tr2VideoAdapterInfo::SupportsBackBufferFormat( unsigned adapterIndex, uint32_t flags = s_deviceInfo[s_adapters[adapterIndex].m_deviceInfoIndex].m_formatSupport[backBufferFormat]; // or should it be D3D11_FORMAT_SUPPORT_DISPLAY? - if ( ( flags & D3D11_FORMAT_SUPPORT_RENDER_TARGET ) == 0 ) + if( ( flags & D3D11_FORMAT_SUPPORT_RENDER_TARGET ) == 0 ) { return false; } @@ -374,14 +376,14 @@ bool Tr2VideoAdapterInfo::SupportsRenderTargetFormat( unsigned adapterIndex, Tr2 CHECK_INIT_BOOL; CHECK_VALID_ADAPTER_BOOL; - if ( format >= (unsigned)DeviceInfo::FORMAT_COUNT ) + if( format >= (unsigned)DeviceInfo::FORMAT_COUNT ) { return false; } uint32_t flags = s_deviceInfo[s_adapters[adapterIndex].m_deviceInfoIndex].m_formatSupport[format]; - if ( ( flags & D3D11_FORMAT_SUPPORT_RENDER_TARGET ) == 0 ) + if( ( flags & D3D11_FORMAT_SUPPORT_RENDER_TARGET ) == 0 ) { return false; } @@ -392,7 +394,7 @@ bool Tr2VideoAdapterInfo::SupportsRenderTargetFormat( unsigned adapterIndex, Tr2 unsigned log2( unsigned int x ) { unsigned ans = 0; - while ( x >>= 1 ) + while( x >>= 1 ) { ans++; } @@ -407,11 +409,11 @@ ALResult Tr2VideoAdapterInfo::RefreshData() bool Tr2VideoAdapterInfo::AreAdaptersDifferent( unsigned adapter1, unsigned adapter2 ) { - if ( adapter1 == adapter2 ) + if( adapter1 == adapter2 ) { return false; } - if ( adapter1 >= s_adapters.size() || adapter2 >= s_adapters.size() ) + if( adapter1 >= s_adapters.size() || adapter2 >= s_adapters.size() ) { return true; } @@ -434,11 +436,11 @@ ALResult Tr2VideoAdapterInfo::GetVideoAdapterDX11( unsigned adapterIndex, IDXGIAdapter1** adapter, IDXGIOutput** output ) { - if ( !s_factory ) + if( !s_factory ) { CR_RETURN_HR( InitializeDirect3D() ); } - if ( adapterIndex >= s_adapters.size() ) + if( adapterIndex >= s_adapters.size() ) { return E_INVALIDARG; } diff --git a/trinityal/dx11/Tr2VideoAdapterInfoALDx11.h b/trinityal/dx11/Tr2VideoAdapterInfoALDx11.h index 853557191..629c648d2 100644 --- a/trinityal/dx11/Tr2VideoAdapterInfoALDx11.h +++ b/trinityal/dx11/Tr2VideoAdapterInfoALDx11.h @@ -10,7 +10,7 @@ struct Tr2AdapterInfo; struct Tr2DisplayModeInfo; -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) class Tr2VideoAdapterInfo { diff --git a/trinityal/dx11/upscaling/Tr2DlssUpscaling.cpp b/trinityal/dx11/upscaling/Tr2DlssUpscaling.cpp index a64d95e91..390bc4310 100644 --- a/trinityal/dx11/upscaling/Tr2DlssUpscaling.cpp +++ b/trinityal/dx11/upscaling/Tr2DlssUpscaling.cpp @@ -8,7 +8,7 @@ #include "include/Tr2StreamlineAL.h" #include "../Tr2AdapterStructures.h" -#include "../Tr2VideoAdapterInfoALDx11.h" +#include "../Tr2VideoAdapterInfoALDx11.h" #include "../Tr2RenderContextDx11.h" #include "../Tr2TextureALDx11.h" @@ -17,15 +17,15 @@ extern uint32_t g_streamlineAppID; namespace DlssUtils { - sl::Resource GenerateTextureResource( const Tr2TextureAL* texture ) +sl::Resource GenerateTextureResource( const Tr2TextureAL* texture ) +{ + if( texture && texture->IsValid() ) { - if( texture && texture->IsValid() ) - { - return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx11(), nullptr, nullptr, 0 }; - } - - return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; + return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx11(), nullptr, nullptr, 0 }; } + + return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; +} } Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : @@ -39,7 +39,7 @@ Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& render m_streamlineSetup = false; - + //We need to create a dummy device to figure out if DLSS and frame generation actually is supported. { @@ -49,21 +49,21 @@ Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& render return; } - + CComPtr dxgiAdapter; CComPtr output; Tr2VideoAdapterInfo::GetVideoAdapterDX11( adapter, &dxgiAdapter, &output ); const D3D_FEATURE_LEVEL levelWanted = D3D_FEATURE_LEVEL_11_0; - + D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_UNKNOWN; CComPtr device; D3D_FEATURE_LEVEL levelSupported; CComPtr m_context; - - + + if( SUCCEEDED( D3D11CreateDevice( dxgiAdapter, driverType, 0, 0, &levelWanted, 1, D3D11_SDK_VERSION, &device, &levelSupported, &m_context ) ) ) { if( Tr2StreamlineAL::SetDevice( device, adapter ) == sl::Result::eOk ) @@ -74,7 +74,7 @@ Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& render Tr2StreamlineAL::ReleaseStreamline(); } - + //We're done gathering info, initialize Streamline again and await the actual device! if( SL_FAILED( res, Tr2StreamlineAL::InitializeStreamline( g_streamlineAppID ) ) ) { @@ -90,10 +90,10 @@ Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& render Tr2DlssUpscalingTechnique::~Tr2DlssUpscalingTechnique() { - Tr2StreamlineAL::ReleaseStreamline( ); + Tr2StreamlineAL::ReleaseStreamline(); } -bool Tr2DlssUpscalingTechnique::IsAvailable( ) const +bool Tr2DlssUpscalingTechnique::IsAvailable() const { return m_isAvailable; } @@ -101,14 +101,14 @@ bool Tr2DlssUpscalingTechnique::IsAvailable( ) const std::vector Tr2DlssUpscalingTechnique::GetAvailableSettings() const { return { - Tr2UpscalingAL::QUALITY, - Tr2UpscalingAL::BALANCED, + Tr2UpscalingAL::QUALITY, + Tr2UpscalingAL::BALANCED, Tr2UpscalingAL::PERFORMANCE, Tr2UpscalingAL::ULTRA_PERFORMANCE }; } -bool Tr2DlssUpscalingTechnique::IsTemporal() const +bool Tr2DlssUpscalingTechnique::IsTemporal() const { return true; } @@ -130,7 +130,7 @@ void Tr2DlssUpscalingTechnique::MarkFrameEvent( Tr2RenderContextEnum::FrameEvent } } -void Tr2DlssUpscalingTechnique::AttachToDevice(CComPtr& device) +void Tr2DlssUpscalingTechnique::AttachToDevice( CComPtr& device ) { if( SL_FAILED( res, Tr2StreamlineAL::SetDevice( device, m_adapter ) ) ) @@ -146,11 +146,11 @@ Tr2UpscalingContextAL* Tr2DlssUpscalingTechnique::CreateContextInstance( Tr2Upsc return new Tr2DlssUpscalingContext( m_setting, false, params, m_contextIndex++, m_frameToken ); } -Tr2DlssUpscalingContext::Tr2DlssUpscalingContext( - Tr2UpscalingAL::Setting setting, - bool frameGeneration, +Tr2DlssUpscalingContext::Tr2DlssUpscalingContext( + Tr2UpscalingAL::Setting setting, + bool frameGeneration, Tr2UpscalingAL::UpscalingContextParams params, - uint32_t contextNumber, + uint32_t contextNumber, sl::FrameToken* frameToken ) : Tr2UpscalingContextAL( setting, frameGeneration, params ), m_viewHandle( sl::ViewportHandle( contextNumber ) ), @@ -283,7 +283,7 @@ sl::Result Tr2DlssUpscalingContext::ReadyDLSSResources( Tr2UpscalingAL::Dispatch sl::ResourceTag exposureTag = sl::ResourceTag{ &exposureResource, sl::kBufferTypeExposure, sl::ResourceLifecycle::eValidUntilPresent, &exposureExtent }; sl::ResourceTag resources[] = { colorInTag, opaqueColorInTag, colorOutTag, depthTag, mvecTag, exposureTag }; - + if( SL_FAILED( res, Tr2StreamlineAL::SetTagsForFrame( m_params.renderContext, *m_frameToken, m_viewHandle, resources, 6 ) ) ) { CCP_LOGERR( "DLSS Failed to tag resources (%d)", res ); diff --git a/trinityal/dx11/upscaling/Tr2DlssUpscaling.h b/trinityal/dx11/upscaling/Tr2DlssUpscaling.h index 19380588f..4bc042916 100644 --- a/trinityal/dx11/upscaling/Tr2DlssUpscaling.h +++ b/trinityal/dx11/upscaling/Tr2DlssUpscaling.h @@ -13,9 +13,9 @@ namespace DlssUtils { - sl::Resource GenerateTextureResource( const Tr2TextureAL* texture ); - const char* GetPluginName( sl::Feature feature ); - sl::float4x4 AsFloat4x4( float f[16] ); +sl::Resource GenerateTextureResource( const Tr2TextureAL* texture ); +const char* GetPluginName( sl::Feature feature ); +sl::float4x4 AsFloat4x4( float f[16] ); } class Tr2DlssUpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx11 @@ -25,7 +25,7 @@ class Tr2DlssUpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx1 ~Tr2DlssUpscalingTechnique(); // Tr2UpscalingTechniqueAL overrides - virtual bool IsAvailable( ) const override; + virtual bool IsAvailable() const override; virtual std::vector GetAvailableSettings() const override; virtual bool IsTemporal() const override; @@ -49,11 +49,11 @@ class Tr2DlssUpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx1 class Tr2DlssUpscalingContext : public Tr2UpscalingContextAL { public: - Tr2DlssUpscalingContext( - Tr2UpscalingAL::Setting setting, - bool frameGeneration, + Tr2DlssUpscalingContext( + Tr2UpscalingAL::Setting setting, + bool frameGeneration, Tr2UpscalingAL::UpscalingContextParams params, - uint32_t contextNumber, + uint32_t contextNumber, sl::FrameToken* frameToken ); ~Tr2DlssUpscalingContext(); diff --git a/trinityal/dx11/upscaling/Tr2UpscalingALDx11.cpp b/trinityal/dx11/upscaling/Tr2UpscalingALDx11.cpp index af4ce36ae..0d86c0c63 100644 --- a/trinityal/dx11/upscaling/Tr2UpscalingALDx11.cpp +++ b/trinityal/dx11/upscaling/Tr2UpscalingALDx11.cpp @@ -10,37 +10,37 @@ namespace TrinityALImpl { - Tr2UpscalingTechniqueDx11::Tr2UpscalingTechniqueDx11( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : +Tr2UpscalingTechniqueDx11::Tr2UpscalingTechniqueDx11( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : Tr2UpscalingTechniqueAL( renderContext, technique, setting, frameGeneration, adapter ) - { - } +{ +} - Tr2UpscalingTechniqueDx11::~Tr2UpscalingTechniqueDx11() - { - } - - void Tr2UpscalingTechniqueDx11::AttachToDevice( CComPtr& device ) +Tr2UpscalingTechniqueDx11::~Tr2UpscalingTechniqueDx11() +{ +} + +void Tr2UpscalingTechniqueDx11::AttachToDevice( CComPtr& device ) +{ +} + +Tr2UpscalingTechniqueDx11* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) +{ + TrinityALImpl::Tr2UpscalingTechniqueDx11* techniqueImpl = nullptr; + switch( technique ) { + case Tr2UpscalingAL::Technique::FSR1: + techniqueImpl = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + default: + break; } - - Tr2UpscalingTechniqueDx11* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) + if( techniqueImpl && techniqueImpl->IsAvailable() ) { - TrinityALImpl::Tr2UpscalingTechniqueDx11* techniqueImpl = nullptr; - switch( technique ) - { - case Tr2UpscalingAL::Technique::FSR1: - techniqueImpl = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - default: - break; - } - if( techniqueImpl && techniqueImpl->IsAvailable( ) ) - { - return techniqueImpl; - } - delete techniqueImpl; - techniqueImpl = nullptr; - return nullptr; + return techniqueImpl; } + delete techniqueImpl; + techniqueImpl = nullptr; + return nullptr; +} } #endif diff --git a/trinityal/dx11/upscaling/Tr2UpscalingALDx11.h b/trinityal/dx11/upscaling/Tr2UpscalingALDx11.h index 48e01ad3c..ee4335666 100644 --- a/trinityal/dx11/upscaling/Tr2UpscalingALDx11.h +++ b/trinityal/dx11/upscaling/Tr2UpscalingALDx11.h @@ -7,20 +7,20 @@ namespace TrinityALImpl { - constexpr Tr2UpscalingAL::Technique AVAILABLE_UPSCALING_TECHNIQUES[] = { - Tr2UpscalingAL::FSR1 - }; +constexpr Tr2UpscalingAL::Technique AVAILABLE_UPSCALING_TECHNIQUES[] = { + Tr2UpscalingAL::FSR1 +}; - class Tr2UpscalingTechniqueDx11 : public Tr2UpscalingTechniqueAL - { - public: - Tr2UpscalingTechniqueDx11( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); - virtual ~Tr2UpscalingTechniqueDx11(); +class Tr2UpscalingTechniqueDx11 : public Tr2UpscalingTechniqueAL +{ +public: + Tr2UpscalingTechniqueDx11( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); + virtual ~Tr2UpscalingTechniqueDx11(); - virtual void AttachToDevice( CComPtr& device ); - }; + virtual void AttachToDevice( CComPtr& device ); +}; - Tr2UpscalingTechniqueDx11* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); +Tr2UpscalingTechniqueDx11* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2BufferALDx12.cpp b/trinityal/dx12/Tr2BufferALDx12.cpp index 140b433f7..5860a5e20 100644 --- a/trinityal/dx12/Tr2BufferALDx12.cpp +++ b/trinityal/dx12/Tr2BufferALDx12.cpp @@ -11,454 +11,453 @@ namespace TrinityALImpl { - Tr2BufferAL::Tr2BufferAL() - :m_owner( nullptr ), - m_defaultState( D3D12_RESOURCE_STATE_COMMON ) +Tr2BufferAL::Tr2BufferAL() : + m_owner( nullptr ), + m_defaultState( D3D12_RESOURCE_STATE_COMMON ) +{ + memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); + memset( &m_uavDesc, 0, sizeof( m_uavDesc ) ); + m_desc.count = 0; +} + +Tr2BufferAL::~Tr2BufferAL() +{ + Destroy(); +} + +ALResult Tr2BufferAL::Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( desc.count == 0 ) { - memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); - memset( &m_uavDesc, 0, sizeof( m_uavDesc ) ); - m_desc.count = 0; + return E_INVALIDARG; } - Tr2BufferAL::~Tr2BufferAL() + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDCALL; } - ALResult Tr2BufferAL::Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ) + bool isImmutable = !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); + if( isImmutable && !initialData ) { - Destroy(); - - if( desc.count == 0 ) - { - return E_INVALIDARG; - } + return E_INVALIDARG; + } - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + if( HasFlag( desc.cpuUsage, Tr2CpuUsage::READ ) && HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + return E_INVALIDARG; + } - bool isImmutable = !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); - if( isImmutable && !initialData ) - { - return E_INVALIDARG; - } + auto stride = desc.stride; + if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( desc.format ); + } - if( HasFlag( desc.cpuUsage, Tr2CpuUsage::READ ) && HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - return E_INVALIDARG; - } + auto size = desc.count * stride; - auto stride = desc.stride; - if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( desc.format ); - } + D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + } + if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + resourceFlags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; + } - auto size = desc.count * stride; + D3D12_RESOURCE_STATES defaultState; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) + { + defaultState = D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE; + } + else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) || + HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) || + HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + defaultState = D3D12_RESOURCE_STATE_COMMON; - D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) { - resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + defaultState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; } - if( !HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) { - resourceFlags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; + defaultState |= D3D12_RESOURCE_STATE_INDEX_BUFFER; } - - D3D12_RESOURCE_STATES defaultState; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - defaultState = D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE; + defaultState |= D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; } - else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) || - HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) || - HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) - ) - { - defaultState = D3D12_RESOURCE_STATE_COMMON; + } + else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::DRAW_INDIRECT_ARGS ) ) + { + defaultState = D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT; + } + else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + defaultState = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + } + else + { + defaultState = D3D12_RESOURCE_STATE_COPY_DEST; + } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) - { - defaultState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; - } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::INDEX_BUFFER ) ) - { - defaultState |= D3D12_RESOURCE_STATE_INDEX_BUFFER; - } - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - defaultState |= D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - } - } - else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::DRAW_INDIRECT_ARGS ) ) + D3D12_SUBRESOURCE_DATA subresourceData = { initialData, size, size }; + + Tr2ResourceHelper::Strategy strategy; + if( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + strategy = Tr2ResourceHelper::STATIC; + } + else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + strategy = Tr2ResourceHelper::SEMI_DYNAMIC; + } + else + { + strategy = Tr2ResourceHelper::DYNAMIC; + defaultState = D3D12_RESOURCE_STATE_GENERIC_READ; + } + FORWARD_HR( m_buffer.Create( strategy, size, resourceFlags, defaultState, RequiresImmediateBarriers( desc.gpuUsage ), initialData ? 1 : 0, initialData ? &subresourceData : nullptr, renderContext ) ); + + if( renderContext.m_device1 ) + { + ID3D12Pageable* resource = m_buffer.GetResource(); + D3D12_RESIDENCY_PRIORITY priority; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) { - defaultState = D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT; + //Acceleration structures are very important to keep in VRAM. + priority = D3D12_RESIDENCY_PRIORITY_MAXIMUM; } else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { - defaultState = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + //Unordered access views are written and read by the GPU, so keep them in VRAM if possible. + priority = D3D12_RESIDENCY_PRIORITY_NORMAL; } else { - defaultState = D3D12_RESOURCE_STATE_COPY_DEST; + //Read-only buffers are generally not as critical as other things. + priority = D3D12_RESIDENCY_PRIORITY_MINIMUM; } - D3D12_SUBRESOURCE_DATA subresourceData = { initialData, size, size }; + renderContext.m_device1->SetResidencyPriority( 1, &resource, &priority ); + } - Tr2ResourceHelper::Strategy strategy; - if( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - strategy = Tr2ResourceHelper::STATIC; - } - else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + m_desc = desc; + m_owner = &renderContext; + m_defaultState = defaultState; + + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + m_srvDesc.Format = DXGI_FORMAT( desc.format ); + m_srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) { - strategy = Tr2ResourceHelper::SEMI_DYNAMIC; + m_srvDesc.ViewDimension = D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE; + m_srvDesc.RaytracingAccelerationStructure.Location = m_buffer.GetGpuView(); } else { - strategy = Tr2ResourceHelper::DYNAMIC; - defaultState = D3D12_RESOURCE_STATE_GENERIC_READ; - } - FORWARD_HR( m_buffer.Create( strategy, size, resourceFlags, defaultState, RequiresImmediateBarriers( desc.gpuUsage ), initialData ? 1 : 0, initialData ? &subresourceData : nullptr, renderContext ) ); - - if (renderContext.m_device1) - { - ID3D12Pageable* resource = m_buffer.GetResource(); - D3D12_RESIDENCY_PRIORITY priority; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) - { - //Acceleration structures are very important to keep in VRAM. - priority = D3D12_RESIDENCY_PRIORITY_MAXIMUM; - } - else if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - //Unordered access views are written and read by the GPU, so keep them in VRAM if possible. - priority = D3D12_RESIDENCY_PRIORITY_NORMAL; - } - else + m_srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + m_srvDesc.Buffer.FirstElement = 0; + m_srvDesc.Buffer.NumElements = desc.count; + m_srvDesc.Buffer.StructureByteStride = m_srvDesc.Format == DXGI_FORMAT_UNKNOWN ? stride : 0; + m_srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) { - //Read-only buffers are generally not as critical as other things. - priority = D3D12_RESIDENCY_PRIORITY_MINIMUM; + m_srvDesc.Buffer.StructureByteStride = 4; + m_srvDesc.Buffer.NumElements = size / 4; } - - renderContext.m_device1->SetResidencyPriority( 1, &resource, &priority ); } - m_desc = desc; - m_owner = &renderContext; - m_defaultState = defaultState; - - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + HRESULT hr; + if( FAILED( hr = renderContext.CreateShaderResourceView( m_buffer.GetResource(), m_srvDesc, m_srv ) ) ) { - m_srvDesc.Format = DXGI_FORMAT( desc.format ); - m_srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::ACCELERATION_STRUCTURE ) ) - { - m_srvDesc.ViewDimension = D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE; - m_srvDesc.RaytracingAccelerationStructure.Location = m_buffer.GetGpuView(); - } - else - { - m_srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - m_srvDesc.Buffer.FirstElement = 0; - m_srvDesc.Buffer.NumElements = desc.count; - m_srvDesc.Buffer.StructureByteStride = m_srvDesc.Format == DXGI_FORMAT_UNKNOWN ? stride : 0; - m_srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::VERTEX_BUFFER ) ) - { - m_srvDesc.Buffer.StructureByteStride = 4; - m_srvDesc.Buffer.NumElements = size / 4; - } - } + Destroy(); + return hr; + } + } + else + { + memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); + } - HRESULT hr; - if (FAILED(hr = renderContext.CreateShaderResourceView(m_buffer.GetResource(), m_srvDesc, m_srv))) - { - Destroy(); - return hr; - } + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + D3D12_UNORDERED_ACCESS_VIEW_DESC clearUav; + if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + clearUav.Format = DXGI_FORMAT( desc.format ); + clearUav.Buffer.NumElements = desc.count; } else { - memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); + clearUav.Format = DXGI_FORMAT_R32_UINT; + clearUav.Buffer.NumElements = ( desc.count * desc.stride ) / 4; } + clearUav.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + clearUav.Buffer.FirstElement = 0; + clearUav.Buffer.StructureByteStride = 0; + clearUav.Buffer.CounterOffsetInBytes = 0; + clearUav.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + HRESULT hr; + if( FAILED( hr = renderContext.CreateUnorderedAccessView( m_buffer.GetResource(), nullptr, clearUav, m_clearUav ) ) ) { - D3D12_UNORDERED_ACCESS_VIEW_DESC clearUav; - if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - clearUav.Format = DXGI_FORMAT( desc.format ); - clearUav.Buffer.NumElements = desc.count; - } - else - { - clearUav.Format = DXGI_FORMAT_R32_UINT; - clearUav.Buffer.NumElements = ( desc.count * desc.stride ) / 4; - } - clearUav.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - clearUav.Buffer.FirstElement = 0; - clearUav.Buffer.StructureByteStride = 0; - clearUav.Buffer.CounterOffsetInBytes = 0; - clearUav.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; - - HRESULT hr; - if (FAILED(hr = renderContext.CreateUnorderedAccessView(m_buffer.GetResource(), nullptr, clearUav, m_clearUav))) - { - Destroy(); - return hr; - } + Destroy(); + return hr; + } - m_uavDesc.Format = DXGI_FORMAT( desc.format ); - m_uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - m_uavDesc.Buffer.FirstElement = 0; - m_uavDesc.Buffer.NumElements = desc.count; - m_uavDesc.Buffer.StructureByteStride = m_uavDesc.Format == DXGI_FORMAT_UNKNOWN ? stride : 0; - m_uavDesc.Buffer.CounterOffsetInBytes = 0; - m_uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; + m_uavDesc.Format = DXGI_FORMAT( desc.format ); + m_uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + m_uavDesc.Buffer.FirstElement = 0; + m_uavDesc.Buffer.NumElements = desc.count; + m_uavDesc.Buffer.StructureByteStride = m_uavDesc.Format == DXGI_FORMAT_UNKNOWN ? stride : 0; + m_uavDesc.Buffer.CounterOffsetInBytes = 0; + m_uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; - if (FAILED(hr = renderContext.CreateUnorderedAccessView(m_buffer.GetResource(), nullptr, m_uavDesc, m_uav))) - { - Destroy(); - return hr; - } - } - else + if( FAILED( hr = renderContext.CreateUnorderedAccessView( m_buffer.GetResource(), nullptr, m_uavDesc, m_uav ) ) ) { - memset( &m_uavDesc, 0, sizeof( m_uavDesc ) ); + Destroy(); + return hr; } - - return S_OK; } - - void Tr2BufferAL::Destroy() + else { - if( m_owner ) - { - m_buffer.Destroy( *m_owner ); - } - if( m_lockedScratch ) - { - RELEASE_LATER( m_owner, m_lockedScratch ); - m_lockedScratch = nullptr; - } - - memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); memset( &m_uavDesc, 0, sizeof( m_uavDesc ) ); - m_srv = nullptr; - m_uav = nullptr; - m_clearUav = nullptr; - m_desc.count = 0; - m_owner = nullptr; - m_defaultState = D3D12_RESOURCE_STATE_COMMON; } - bool Tr2BufferAL::IsValid() const - { - return m_owner != nullptr; - } + return S_OK; +} - Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const +void Tr2BufferAL::Destroy() +{ + if( m_owner ) { - return AL_MEMORY_MANAGED; + m_buffer.Destroy( *m_owner ); } - - const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const + if( m_lockedScratch ) { - return m_desc; + RELEASE_LATER( m_owner, m_lockedScratch ); + m_lockedScratch = nullptr; } - ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) + memset( &m_srvDesc, 0, sizeof( m_srvDesc ) ); + memset( &m_uavDesc, 0, sizeof( m_uavDesc ) ); + m_srv = nullptr; + m_uav = nullptr; + m_clearUav = nullptr; + m_desc.count = 0; + m_owner = nullptr; + m_defaultState = D3D12_RESOURCE_STATE_COMMON; +} + +bool Tr2BufferAL::IsValid() const +{ + return m_owner != nullptr; +} + +Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const +{ + return m_desc; +} + +ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - return m_buffer.MapForWriting( data, HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? Tr2LockType::NON_SYNCHRONIZED : Tr2LockType::SYNCHRONIZED, *m_owner ); + return E_INVALIDCALL; } - - void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& ) + if( !renderContext.IsValid() ) { - m_buffer.UnmapForWriting( *m_owner ); + return E_INVALIDARG; } - - ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - auto stride = m_desc.stride; - if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( m_desc.format ); - } - if( m_desc.count * stride < size ) - { - return E_INVALIDARG; - } + return E_INVALIDCALL; + } + return m_buffer.MapForWriting( data, HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? Tr2LockType::NON_SYNCHRONIZED : Tr2LockType::SYNCHRONIZED, *m_owner ); +} - if( !size ) - { - size = m_desc.count * stride; - } +void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& ) +{ + m_buffer.UnmapForWriting( *m_owner ); +} - return m_buffer.UpdateBuffer( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? Tr2LockType::NON_SYNCHRONIZED : Tr2LockType::SYNCHRONIZED, offset, size, data, renderContext ); +ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ) +{ + auto stride = m_desc.stride; + if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( m_desc.format ); } - - ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) + if( m_desc.count * stride < size ) { - auto stride = m_desc.stride; - if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( m_desc.format ); - } - auto size = m_desc.count * stride; - return MapForReading( data, 0, size, renderContext ); + return E_INVALIDARG; } - ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) + if( !size ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } - if( m_lockedScratch ) - { - return E_INVALIDCALL; - } - - auto stride = m_desc.stride; - if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( m_desc.format ); - } - if( size == 0 || offset + size > m_desc.count * stride ) - { - return E_INVALIDARG; - } - - CComPtr scratch; - auto scratchDesc = BufferDesc( size ); - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_READBACK ); - CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); - - renderContext.ResourceBarrierDx12( Transition( m_buffer.GetResource(), m_defaultState, D3D12_RESOURCE_STATE_COPY_SOURCE ) ); - renderContext.FlushBarriersDx12( m_buffer.GetResource() ); - renderContext.m_commandList->CopyBufferRegion( scratch, 0, m_buffer.GetResource(), offset, size ); - renderContext.ResourceBarrierDx12( Transition( m_buffer.GetResource(), D3D12_RESOURCE_STATE_COPY_SOURCE, m_defaultState ) ); - if( RequiresImmediateBarriers( m_desc.gpuUsage ) ) - { - renderContext.FlushBarriersDx12( m_buffer.GetResource() ); - } - - auto hr = renderContext.FlushAndSyncDx12(); - if( FAILED( hr ) ) - { - RELEASE_LATER( m_owner, scratch ); - scratch = nullptr; - return hr; - } + size = m_desc.count * stride; + } - CR_RETURN_HR( scratch->Map( 0, nullptr, (void**)&data ) ); - m_lockedScratch = scratch; + return m_buffer.UpdateBuffer( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ? Tr2LockType::NON_SYNCHRONIZED : Tr2LockType::SYNCHRONIZED, offset, size, data, renderContext ); +} - return S_OK; +ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) +{ + auto stride = m_desc.stride; + if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( m_desc.format ); } + auto size = m_desc.count * stride; + return MapForReading( data, 0, size, renderContext ); +} - void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& ) +ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { - if( !m_lockedScratch ) - { - return; - } - D3D12_RANGE range = { 0, 0 }; - m_lockedScratch->Unmap( 0, &range ); - RELEASE_LATER( m_owner, m_lockedScratch ); - m_lockedScratch = nullptr; + return E_INVALIDCALL; } - - ID3D12Resource* Tr2BufferAL::GetGpuResource() + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) { - return m_buffer.GetResource(); + return E_INVALIDCALL; + } + if( m_lockedScratch ) + { + return E_INVALIDCALL; } - D3D12_GPU_VIRTUAL_ADDRESS Tr2BufferAL::GetGpuView() + auto stride = m_desc.stride; + if( m_desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( m_desc.format ); + } + if( size == 0 || offset + size > m_desc.count * stride ) { - return m_buffer.GetGpuView(); + return E_INVALIDARG; } - uint32_t Tr2BufferAL::GetSrvIndexInHeap() const + CComPtr scratch; + auto scratchDesc = BufferDesc( size ); + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_READBACK ); + CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &scratch ) ) ); + + renderContext.ResourceBarrierDx12( Transition( m_buffer.GetResource(), m_defaultState, D3D12_RESOURCE_STATE_COPY_SOURCE ) ); + renderContext.FlushBarriersDx12( m_buffer.GetResource() ); + renderContext.m_commandList->CopyBufferRegion( scratch, 0, m_buffer.GetResource(), offset, size ); + renderContext.ResourceBarrierDx12( Transition( m_buffer.GetResource(), D3D12_RESOURCE_STATE_COPY_SOURCE, m_defaultState ) ); + if( RequiresImmediateBarriers( m_desc.gpuUsage ) ) { - if( m_srv ) - { - return m_srv->GetIndexInHeap(); - } - else - { - return 0xffffffff; - } + renderContext.FlushBarriersDx12( m_buffer.GetResource() ); } - - uint32_t Tr2BufferAL::GetUavIndexInHeap() const + + auto hr = renderContext.FlushAndSyncDx12(); + if( FAILED( hr ) ) { - if( m_uav ) - { - return m_uav->GetIndexInHeap(); - } - else - { - return 0xffffffff; - } + RELEASE_LATER( m_owner, scratch ); + scratch = nullptr; + return hr; } - void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + CR_RETURN_HR( scratch->Map( 0, nullptr, (void**)&data ) ); + m_lockedScratch = scratch; + + return S_OK; +} + +void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& ) +{ + if( !m_lockedScratch ) { - description["type"] = "Tr2BufferAL"; - description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); - description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); - description["format"] = std::to_string( int( GetDesc().format ) ); - description["stride"] = std::to_string( GetDesc().stride ); - description["count"] = std::to_string( GetDesc().count ); - description["name"] = m_buffer.GetName(); + return; } + D3D12_RANGE range = { 0, 0 }; + m_lockedScratch->Unmap( 0, &range ); + RELEASE_LATER( m_owner, m_lockedScratch ); + m_lockedScratch = nullptr; +} - ALResult Tr2BufferAL::SetName( const char* name ) +ID3D12Resource* Tr2BufferAL::GetGpuResource() +{ + return m_buffer.GetResource(); +} + +D3D12_GPU_VIRTUAL_ADDRESS Tr2BufferAL::GetGpuView() +{ + return m_buffer.GetGpuView(); +} + +uint32_t Tr2BufferAL::GetSrvIndexInHeap() const +{ + if( m_srv ) + { + return m_srv->GetIndexInHeap(); + } + else { - m_buffer.SetName( name ); - return S_OK; + return 0xffffffff; } +} - D3D12_RESOURCE_STATES Tr2BufferAL::GetDefaultState() const +uint32_t Tr2BufferAL::GetUavIndexInHeap() const +{ + if( m_uav ) + { + return m_uav->GetIndexInHeap(); + } + else { - return m_defaultState; + return 0xffffffff; } } +void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2BufferAL"; + description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); + description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); + description["format"] = std::to_string( int( GetDesc().format ) ); + description["stride"] = std::to_string( GetDesc().stride ); + description["count"] = std::to_string( GetDesc().count ); + description["name"] = m_buffer.GetName(); +} + +ALResult Tr2BufferAL::SetName( const char* name ) +{ + m_buffer.SetName( name ); + return S_OK; +} + +D3D12_RESOURCE_STATES Tr2BufferAL::GetDefaultState() const +{ + return m_defaultState; +} +} + #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2BufferALDx12.h b/trinityal/dx12/Tr2BufferALDx12.h index 8beece182..2e2e5bd51 100644 --- a/trinityal/dx12/Tr2BufferALDx12.h +++ b/trinityal/dx12/Tr2BufferALDx12.h @@ -12,62 +12,62 @@ namespace TrinityALImpl { - class Tr2RtShaderTableAL; +class Tr2RtShaderTableAL; - class Tr2BufferAL : public Tr2DeviceResourceAL - { - public: - Tr2BufferAL(); - ~Tr2BufferAL(); +class Tr2BufferAL : public Tr2DeviceResourceAL +{ +public: + Tr2BufferAL(); + ~Tr2BufferAL(); - ALResult Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ); + ALResult Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; + void Destroy(); + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BufferDescriptionAL& GetDesc() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BufferDescriptionAL& GetDesc() const; - ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); - ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); - ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ); + ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); - ID3D12Resource* GetGpuResource(); - D3D12_GPU_VIRTUAL_ADDRESS GetGpuView(); + ID3D12Resource* GetGpuResource(); + D3D12_GPU_VIRTUAL_ADDRESS GetGpuView(); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - D3D12_RESOURCE_STATES GetDefaultState() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + D3D12_RESOURCE_STATES GetDefaultState() const; - uint32_t GetSrvIndexInHeap() const; - uint32_t GetUavIndexInHeap() const; + uint32_t GetSrvIndexInHeap() const; + uint32_t GetUavIndexInHeap() const; - private: - Tr2BufferDescriptionAL m_desc; - Tr2ResourceHelper m_buffer; +private: + Tr2BufferDescriptionAL m_desc; + Tr2ResourceHelper m_buffer; - Tr2PrimaryRenderContextAL* m_owner; - D3D12_RESOURCE_STATES m_defaultState; - CComPtr m_lockedScratch; + Tr2PrimaryRenderContextAL* m_owner; + D3D12_RESOURCE_STATES m_defaultState; + CComPtr m_lockedScratch; - D3D12_SHADER_RESOURCE_VIEW_DESC m_srvDesc; - D3D12_UNORDERED_ACCESS_VIEW_DESC m_uavDesc; - std::shared_ptr m_srv; - std::shared_ptr m_uav; - std::shared_ptr m_clearUav; + D3D12_SHADER_RESOURCE_VIEW_DESC m_srvDesc; + D3D12_UNORDERED_ACCESS_VIEW_DESC m_uavDesc; + std::shared_ptr m_srv; + std::shared_ptr m_uav; + std::shared_ptr m_clearUav; - friend class Tr2RenderContextAL; - friend class TrinityALImpl::Tr2ResourceSetAL; - friend class TrinityALImpl::Tr2RtShaderTableAL; - }; + friend class Tr2RenderContextAL; + friend class TrinityALImpl::Tr2ResourceSetAL; + friend class TrinityALImpl::Tr2RtShaderTableAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2CapsALDx12.h b/trinityal/dx12/Tr2CapsALDx12.h index 10caf2757..9a22b9bd2 100644 --- a/trinityal/dx12/Tr2CapsALDx12.h +++ b/trinityal/dx12/Tr2CapsALDx12.h @@ -45,7 +45,7 @@ class Tr2CapsAL CComPtr factory4; UINT createFactoryFlags = 0; -#if( TRINITYDEV == 1 ) +#if ( TRINITYDEV == 1 ) createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG; #endif @@ -71,16 +71,17 @@ class Tr2CapsAL } private: - Tr2CapsAL( ) : m_supportsDxr(false) + Tr2CapsAL() : + m_supportsDxr( false ) { } - Tr2CapsAL(const Tr2CapsAL& other) - :m_supportsDxr(other.m_supportsDxr) + Tr2CapsAL( const Tr2CapsAL& other ) : + m_supportsDxr( other.m_supportsDxr ) { } - Tr2CapsAL& operator=(const Tr2CapsAL& other) + Tr2CapsAL& operator=( const Tr2CapsAL& other ) { m_supportsDxr = other.m_supportsDxr; return *this; diff --git a/trinityal/dx12/Tr2ConstantBufferALDx12.cpp b/trinityal/dx12/Tr2ConstantBufferALDx12.cpp index eb2c40b3d..1ac317515 100644 --- a/trinityal/dx12/Tr2ConstantBufferALDx12.cpp +++ b/trinityal/dx12/Tr2ConstantBufferALDx12.cpp @@ -11,104 +11,104 @@ namespace { - const uint32_t MAX_CB_SIZE = 64 * 1024; +const uint32_t MAX_CB_SIZE = 64 * 1024; } namespace TrinityALImpl { - Tr2ConstantBufferAL::Tr2ConstantBufferAL() - :m_size( 0 ), - m_owner( nullptr ) - { - } +Tr2ConstantBufferAL::Tr2ConstantBufferAL() : + m_size( 0 ), + m_owner( nullptr ) +{ +} - Tr2ConstantBufferAL::~Tr2ConstantBufferAL() - { - Destroy(); - } +Tr2ConstantBufferAL::~Tr2ConstantBufferAL() +{ + Destroy(); +} - ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - if( !size || size > MAX_CB_SIZE ) - { - return E_INVALIDARG; - } - if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) != 0 && !initialData ) - { - return E_INVALIDARG; - } - - m_size = size; - m_data.resize( "Tr2ConstantBufferAL::m_data", m_size ); - m_owner = &renderContext; - - if( initialData ) - { - memcpy( m_data.get(), initialData, m_size ); - } - - return S_OK; - } +ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - void Tr2ConstantBufferAL::Destroy() + if( !renderContext.IsValid() ) { - m_size = 0; - m_data.clear(); - m_owner = nullptr; + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& ) + if( !size || size > MAX_CB_SIZE ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - // JB: Lock now just returns a handle to m_data - *data = (void*)m_data.get(); - return S_OK; + return E_INVALIDARG; } - - ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& ) + if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) != 0 && !initialData ) { - // JB: Forcibly dirty the render token causing a re-upload - m_token.m_frameNumber--; - return S_OK; + return E_INVALIDARG; } - bool Tr2ConstantBufferAL::IsValid() const - { - return !m_data.empty(); - } + m_size = size; + m_data.resize( "Tr2ConstantBufferAL::m_data", m_size ); + m_owner = &renderContext; - uint32_t Tr2ConstantBufferAL::GetSize() const + if( initialData ) { - return m_size; + memcpy( m_data.get(), initialData, m_size ); } - Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } + return S_OK; +} - void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ConstantBufferAL"; - description["size"] = std::to_string( m_size ); - description["name"] = m_name; - } +void Tr2ConstantBufferAL::Destroy() +{ + m_size = 0; + m_data.clear(); + m_owner = nullptr; +} - ALResult Tr2ConstantBufferAL::SetName( const char* name ) +ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& ) +{ + if( !IsValid() ) { - m_name = name; - return S_OK; + return E_INVALIDCALL; } + // JB: Lock now just returns a handle to m_data + *data = (void*)m_data.get(); + return S_OK; +} + +ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& ) +{ + // JB: Forcibly dirty the render token causing a re-upload + m_token.m_frameNumber--; + return S_OK; +} + +bool Tr2ConstantBufferAL::IsValid() const +{ + return !m_data.empty(); +} + +uint32_t Tr2ConstantBufferAL::GetSize() const +{ + return m_size; +} + +Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ConstantBufferAL"; + description["size"] = std::to_string( m_size ); + description["name"] = m_name; +} + +ALResult Tr2ConstantBufferAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ConstantBufferALDx12.h b/trinityal/dx12/Tr2ConstantBufferALDx12.h index b34602c9f..1502716ef 100644 --- a/trinityal/dx12/Tr2ConstantBufferALDx12.h +++ b/trinityal/dx12/Tr2ConstantBufferALDx12.h @@ -12,52 +12,57 @@ class DescriptorStateCache; namespace TrinityALImpl { - class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +{ +public: + /** JB: A token which stored a previously allocated frame-local instance of this buffer */ + struct GPUViewToken { - public: - - /** JB: A token which stored a previously allocated frame-local instance of this buffer */ - struct GPUViewToken + GPUViewToken() : + m_address( 0 ), m_frameNumber( UINT64_MAX ) { - GPUViewToken() : m_address( 0 ), m_frameNumber( UINT64_MAX ) { } + } - std::atomic m_address; - std::atomic m_frameNumber; - }; + std::atomic m_address; + std::atomic m_frameNumber; + }; - Tr2ConstantBufferAL(); - ~Tr2ConstantBufferAL(); + Tr2ConstantBufferAL(); + ~Tr2ConstantBufferAL(); - ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL & renderContext ); - void Destroy(); + ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - ALResult Lock( void** data, Tr2RenderContextAL & renderContext ); - ALResult Unlock( Tr2RenderContextAL & renderContext ); + ALResult Lock( void** data, Tr2RenderContextAL& renderContext ); + ALResult Unlock( Tr2RenderContextAL& renderContext ); - bool IsValid() const; + bool IsValid() const; - uint32_t GetSize() const; - Tr2ALMemoryType GetMemoryClass() const; + uint32_t GetSize() const; + Tr2ALMemoryType GetMemoryClass() const; - void* GetDataPtr() const { return (void*)m_data.get(); } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void* GetDataPtr() const + { + return (void*)m_data.get(); + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; - Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; +private: + Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; + Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; - Tr2PrimaryRenderContextAL* m_owner; - mutable GPUViewToken m_token; + Tr2PrimaryRenderContextAL* m_owner; + mutable GPUViewToken m_token; - CcpMallocBuffer m_data; - uint32_t m_size; + CcpMallocBuffer m_data; + uint32_t m_size; - std::string m_name; + std::string m_name; - friend class Tr2RenderContextAL; - friend class ::DescriptorStateCache; - }; + friend class Tr2RenderContextAL; + friend class ::DescriptorStateCache; +}; } #endif diff --git a/trinityal/dx12/Tr2FenceALDx12.cpp b/trinityal/dx12/Tr2FenceALDx12.cpp index a23389bfc..96fc04765 100644 --- a/trinityal/dx12/Tr2FenceALDx12.cpp +++ b/trinityal/dx12/Tr2FenceALDx12.cpp @@ -10,80 +10,80 @@ namespace TrinityALImpl { - Tr2FenceAL::Tr2FenceAL() - :m_frameIndex( 0xffffffffffffffff ), - m_owner( nullptr ) - { - } +Tr2FenceAL::Tr2FenceAL() : + m_frameIndex( 0xffffffffffffffff ), + m_owner( nullptr ) +{ +} - ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - m_owner = &renderContext; - return S_OK; + return E_INVALIDARG; } + m_owner = &renderContext; + return S_OK; +} - void Tr2FenceAL::Destroy() - { - m_frameIndex = 0xffffffffffffffff; - m_owner = nullptr; - } +void Tr2FenceAL::Destroy() +{ + m_frameIndex = 0xffffffffffffffff; + m_owner = nullptr; +} - bool Tr2FenceAL::IsValid() const - { - return m_owner != nullptr; - } +bool Tr2FenceAL::IsValid() const +{ + return m_owner != nullptr; +} - ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& ) +ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& ) +{ + if( !m_owner ) { - if( !m_owner ) - { - return E_INVALIDCALL; - } - m_frameIndex = m_owner->GetRecordingFrameNumber(); - return S_OK; + return E_INVALIDCALL; } + m_frameIndex = m_owner->GetRecordingFrameNumber(); + return S_OK; +} - ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& ) +ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& ) +{ + if( m_frameIndex == 0xffffffffffffffff ) { - if( m_frameIndex == 0xffffffffffffffff ) - { - return E_INVALIDCALL; - } - isReached = m_owner->GetRenderedFrameNumber() >= m_frameIndex; - return S_OK; + return E_INVALIDCALL; } + isReached = m_owner->GetRenderedFrameNumber() >= m_frameIndex; + return S_OK; +} - ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& renderContext ) +ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& renderContext ) +{ + if( !m_owner ) { - if( !m_owner ) - { - return E_INVALIDCALL; - } - CR_RETURN_HR( renderContext.FlushAndSyncDx12() ); - return S_OK; + return E_INVALIDCALL; } + CR_RETURN_HR( renderContext.FlushAndSyncDx12() ); + return S_OK; +} - Tr2ALMemoryType Tr2FenceAL::GetMemoryClass() const - { - return AL_MEMORY_VIDEO; - } +Tr2ALMemoryType Tr2FenceAL::GetMemoryClass() const +{ + return AL_MEMORY_VIDEO; +} - void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2FenceAL"; - description["name"] = m_name; - } +void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2FenceAL"; + description["name"] = m_name; +} - ALResult Tr2FenceAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +ALResult Tr2FenceAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2FenceALDx12.h b/trinityal/dx12/Tr2FenceALDx12.h index 69338b25e..aeba7c939 100644 --- a/trinityal/dx12/Tr2FenceALDx12.h +++ b/trinityal/dx12/Tr2FenceALDx12.h @@ -8,32 +8,31 @@ namespace TrinityALImpl { - class Tr2FenceAL : - public Tr2DeviceResourceAL - { - public: - Tr2FenceAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - ALResult PutFence( Tr2RenderContextAL& renderContext ); - ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); - ALResult Wait( Tr2RenderContextAL& renderContext ); - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2FenceAL( const Tr2FenceAL& ) /* = delete */; - Tr2FenceAL& operator=( const Tr2FenceAL& ) /* = delete */; - - uint64_t m_frameIndex; - Tr2PrimaryRenderContextAL* m_owner; - std::string m_name; - }; - } +class Tr2FenceAL : public Tr2DeviceResourceAL +{ +public: + Tr2FenceAL(); + + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + ALResult PutFence( Tr2RenderContextAL& renderContext ); + ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); + ALResult Wait( Tr2RenderContextAL& renderContext ); + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2FenceAL( const Tr2FenceAL& ) /* = delete */; + Tr2FenceAL& operator=( const Tr2FenceAL& ) /* = delete */; + + uint64_t m_frameIndex; + Tr2PrimaryRenderContextAL* m_owner; + std::string m_name; +}; +} #endif diff --git a/trinityal/dx12/Tr2GpuTimerALDx12.cpp b/trinityal/dx12/Tr2GpuTimerALDx12.cpp index bcfe4c26d..0df8ac4b4 100644 --- a/trinityal/dx12/Tr2GpuTimerALDx12.cpp +++ b/trinityal/dx12/Tr2GpuTimerALDx12.cpp @@ -11,167 +11,166 @@ namespace TrinityALImpl { - Tr2GpuTimerAL::Tr2GpuTimerAL() - :m_frameIndex( 0 ), - m_owner( nullptr ), - m_lastTime( -1 ), - m_state( UNINITIALIZED ) +Tr2GpuTimerAL::Tr2GpuTimerAL() : + m_frameIndex( 0 ), + m_owner( nullptr ), + m_lastTime( -1 ), + m_state( UNINITIALIZED ) +{ +} + +Tr2GpuTimerAL::~Tr2GpuTimerAL() +{ + Destroy(); +} + +ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { + return E_INVALIDARG; } - Tr2GpuTimerAL::~Tr2GpuTimerAL() + CComPtr query; + CComPtr result; + CComPtr fence; + + D3D12_QUERY_HEAP_DESC queryHeapDesc = {}; + queryHeapDesc.Count = 2; + queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP; + CR_RETURN_HR( renderContext.m_device->CreateQueryHeap( &queryHeapDesc, IID_PPV_ARGS( &query ) ) ); + + auto scratchHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_READBACK ); + auto bufferDesc = TrinityALImpl::BufferDesc( 8 * 2 ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &bufferDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &result ) ) ); + + m_query = query; + m_result = result; + m_owner = &renderContext; + m_state = READY; + + return S_OK; +} + +void Tr2GpuTimerAL::Destroy() +{ + if( m_query ) { - Destroy(); + RELEASE_LATER( m_owner, m_query ); + m_query = nullptr; } - - ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) + if( m_result ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - CComPtr query; - CComPtr result; - CComPtr fence; - - D3D12_QUERY_HEAP_DESC queryHeapDesc = {}; - queryHeapDesc.Count = 2; - queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP; - CR_RETURN_HR( renderContext.m_device->CreateQueryHeap( &queryHeapDesc, IID_PPV_ARGS( &query ) ) ); - - auto scratchHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_READBACK ); - auto bufferDesc = TrinityALImpl::BufferDesc( 8 * 2 ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &bufferDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &result ) - ) ); - - m_query = query; - m_result = result; - m_owner = &renderContext; - m_state = READY; - - return S_OK; + RELEASE_LATER( m_owner, m_result ); + m_result = nullptr; } + m_owner = nullptr; + m_lastTime = -1; + m_state = UNINITIALIZED; +} - void Tr2GpuTimerAL::Destroy() +bool Tr2GpuTimerAL::IsValid() const +{ + return m_query != nullptr; +} + +bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( !m_query || m_state != READY ) { - if( m_query ) - { - RELEASE_LATER(m_owner, m_query ); - m_query = nullptr; - } - if( m_result ) - { - RELEASE_LATER( m_owner, m_result ); - m_result = nullptr; - } - m_owner = nullptr; - m_lastTime = -1; - m_state = UNINITIALIZED; + return false; } - - bool Tr2GpuTimerAL::IsValid() const + if( !renderContext.m_commandList ) { - return m_query != nullptr; + return false; } + renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 0 ); + m_state = BEGIN_ISSUED; + return true; +} - bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) +void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) +{ + if( !m_query || m_state != BEGIN_ISSUED ) { - if( !m_query || m_state != READY ) - { - return false; - } - if( !renderContext.m_commandList ) - { - return false; - } - renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 0 ); - m_state = BEGIN_ISSUED; - return true; + return; } - - void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) + if( !renderContext.m_commandList ) { - if( !m_query || m_state != BEGIN_ISSUED ) - { - return; - } - if( !renderContext.m_commandList ) - { - return; - } - renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 1 ); - renderContext.m_commandList->ResolveQueryData( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, m_result, 0 ); - m_frameIndex = m_owner->GetRecordingFrameNumber(); - m_state = END_ISSUED; + return; } + renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 1 ); + renderContext.m_commandList->ResolveQueryData( m_query, D3D12_QUERY_TYPE_TIMESTAMP, 0, 2, m_result, 0 ); + m_frameIndex = m_owner->GetRecordingFrameNumber(); + m_state = END_ISSUED; +} - float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& ) +float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& ) +{ + if( !m_result ) { - if( !m_result ) - { - return m_lastTime; - } - if( m_state != END_ISSUED ) - { - return m_lastTime; - } - if( m_owner->GetRenderedFrameNumber() < m_frameIndex ) - { - return m_lastTime; - } - D3D12_RANGE readRange = { 0, 8 }; - void* data; - if( FAILED( m_result->Map( 0, &readRange, &data ) ) ) - { - return m_lastTime; - } - auto t0 = static_cast( data )[0]; - auto t1 = static_cast( data )[1]; - D3D12_RANGE writeRange = { 0, 0 }; - m_result->Unmap( 0, &writeRange ); - - UINT64 freq; - if( FAILED( m_owner->m_commandQueue->GetTimestampFrequency( &freq ) ) ) - { - return m_lastTime; - } - m_lastTime = float( double( t1 - t0 ) / double( freq ) ); - m_state = READY; - return m_lastTime; } - - bool Tr2GpuTimerAL::operator==( const Tr2GpuTimerAL& other ) const + if( m_state != END_ISSUED ) { - return this == &other; + return m_lastTime; } - - Tr2ALMemoryType Tr2GpuTimerAL::GetMemoryClass() const - { - return AL_MEMORY_VIDEO; + if( m_owner->GetRenderedFrameNumber() < m_frameIndex ) + { + return m_lastTime; } - - void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + D3D12_RANGE readRange = { 0, 8 }; + void* data; + if( FAILED( m_result->Map( 0, &readRange, &data ) ) ) { - description["type"] = "Tr2GpuTimerAL"; - description["name"] = m_name; + return m_lastTime; } + auto t0 = static_cast( data )[0]; + auto t1 = static_cast( data )[1]; + D3D12_RANGE writeRange = { 0, 0 }; + m_result->Unmap( 0, &writeRange ); - ALResult Tr2GpuTimerAL::SetName( const char* name ) + UINT64 freq; + if( FAILED( m_owner->m_commandQueue->GetTimestampFrequency( &freq ) ) ) { - m_name = name; - SetDebugName( m_query, name ); - SetDebugName( m_result, name ); - return S_OK; + return m_lastTime; } + m_lastTime = float( double( t1 - t0 ) / double( freq ) ); + m_state = READY; + + return m_lastTime; +} + +bool Tr2GpuTimerAL::operator==( const Tr2GpuTimerAL& other ) const +{ + return this == &other; +} + +Tr2ALMemoryType Tr2GpuTimerAL::GetMemoryClass() const +{ + return AL_MEMORY_VIDEO; +} + +void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2GpuTimerAL"; + description["name"] = m_name; +} + +ALResult Tr2GpuTimerAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_query, name ); + SetDebugName( m_result, name ); + return S_OK; +} } diff --git a/trinityal/dx12/Tr2GpuTimerALDx12.h b/trinityal/dx12/Tr2GpuTimerALDx12.h index a495c4b1a..7d2a2a840 100644 --- a/trinityal/dx12/Tr2GpuTimerALDx12.h +++ b/trinityal/dx12/Tr2GpuTimerALDx12.h @@ -14,42 +14,41 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2GpuTimerAL : - public Tr2DeviceResourceAL +class Tr2GpuTimerAL : public Tr2DeviceResourceAL +{ +public: + Tr2GpuTimerAL(); + ~Tr2GpuTimerAL(); + + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + bool Begin( Tr2RenderContextAL& renderContext ); + void End( Tr2RenderContextAL& renderContext ); + + float GetTime( Tr2RenderContextAL& renderContext ); + + bool operator==( const Tr2GpuTimerAL& other ) const; + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + CComPtr m_query; + CComPtr m_result; + uint64_t m_frameIndex; + Tr2PrimaryRenderContextAL* m_owner; + float m_lastTime; + enum { - public: - Tr2GpuTimerAL(); - ~Tr2GpuTimerAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - bool Begin( Tr2RenderContextAL& renderContext ); - void End( Tr2RenderContextAL& renderContext ); - - float GetTime( Tr2RenderContextAL& renderContext ); - - bool operator==( const Tr2GpuTimerAL& other ) const; - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - CComPtr m_query; - CComPtr m_result; - uint64_t m_frameIndex; - Tr2PrimaryRenderContextAL* m_owner; - float m_lastTime; - enum - { - UNINITIALIZED, - READY, - BEGIN_ISSUED, - END_ISSUED, - } m_state; - std::string m_name; - }; + UNINITIALIZED, + READY, + BEGIN_ISSUED, + END_ISSUED, + } m_state; + std::string m_name; +}; } diff --git a/trinityal/dx12/Tr2OcclusionQueryALDx12.cpp b/trinityal/dx12/Tr2OcclusionQueryALDx12.cpp index 65390e1e9..323add01a 100644 --- a/trinityal/dx12/Tr2OcclusionQueryALDx12.cpp +++ b/trinityal/dx12/Tr2OcclusionQueryALDx12.cpp @@ -11,143 +11,142 @@ namespace TrinityALImpl { - Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() - :m_owner( nullptr ), - m_frameIndex( 0 ) - { - } +Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() : + m_owner( nullptr ), + m_frameIndex( 0 ) +{ +} - Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() +Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() +{ + Destroy(); +} + +ALResult Tr2OcclusionQueryAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - ALResult Tr2OcclusionQueryAL::Create( Tr2PrimaryRenderContextAL& renderContext ) + CComPtr query; + CComPtr result; + CComPtr fence; + + D3D12_QUERY_HEAP_DESC queryHeapDesc = {}; + queryHeapDesc.Count = 1; + queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION; + CR_RETURN_HR( renderContext.m_device->CreateQueryHeap( &queryHeapDesc, IID_PPV_ARGS( &query ) ) ); + + auto scratchHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_READBACK ); + auto bufferDesc = TrinityALImpl::BufferDesc( 8 ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &bufferDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &result ) ) ); + + m_query = query; + m_result = result; + m_owner = &renderContext; + + return S_OK; +} + +bool Tr2OcclusionQueryAL::IsValid() const +{ + return m_query != nullptr; +} + +void Tr2OcclusionQueryAL::Destroy() +{ + if( m_query ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - CComPtr query; - CComPtr result; - CComPtr fence; - - D3D12_QUERY_HEAP_DESC queryHeapDesc = {}; - queryHeapDesc.Count = 1; - queryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_OCCLUSION; - CR_RETURN_HR( renderContext.m_device->CreateQueryHeap( &queryHeapDesc, IID_PPV_ARGS( &query ) ) ); - - auto scratchHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_READBACK ); - auto bufferDesc = TrinityALImpl::BufferDesc( 8 ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &bufferDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &result ) - ) ); - - m_query = query; - m_result = result; - m_owner = &renderContext; - - return S_OK; + RELEASE_LATER( m_owner, m_query ); + m_query = nullptr; } - - bool Tr2OcclusionQueryAL::IsValid() const + if( m_result ) { - return m_query != nullptr; + RELEASE_LATER( m_owner, m_result ); + m_result = nullptr; } + m_owner = nullptr; +} - void Tr2OcclusionQueryAL::Destroy() +ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( !m_query ) { - if( m_query ) - { - RELEASE_LATER( m_owner, m_query ); - m_query = nullptr; - } - if( m_result ) - { - RELEASE_LATER( m_owner, m_result ); - m_result = nullptr; - } - m_owner = nullptr; + return E_INVALIDCALL; } - - ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) + if( !renderContext.m_commandList ) { - if( !m_query ) - { - return E_INVALIDCALL; - } - if( !renderContext.m_commandList ) - { - return E_INVALIDARG; - } - renderContext.m_commandList->BeginQuery( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0 ); - return S_OK; + return E_INVALIDARG; } + renderContext.m_commandList->BeginQuery( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0 ); + return S_OK; +} - ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) +ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) +{ + if( !m_query ) { - if( !m_query ) - { - return E_INVALIDCALL; - } - if( !renderContext.m_commandList ) - { - return E_INVALIDARG; - } - renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0 ); - renderContext.m_commandList->ResolveQueryData( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0, 1, m_result, 0 ); - m_frameIndex = m_owner->GetRecordingFrameNumber(); - return S_OK; + return E_INVALIDCALL; } - - ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ) + if( !renderContext.m_commandList ) { - if( !m_result ) - { - return E_INVALIDCALL; - } - if( waitMode == ::Tr2OcclusionQueryAL::WAIT ) - { - renderContext.FlushAndSyncDx12(); - } - if( m_owner->GetRenderedFrameNumber() < m_frameIndex ) - { - return S_FALSE; - } - D3D12_RANGE readRange = { 0, 8 }; - void* data; - CR_RETURN_HR( m_result->Map( 0, &readRange, &data ) ); - count = uint32_t( *static_cast( data ) ); - D3D12_RANGE writeRange = { 0, 0 }; - m_result->Unmap( 0, &writeRange ); - return S_OK; + return E_INVALIDARG; } + renderContext.m_commandList->EndQuery( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0 ); + renderContext.m_commandList->ResolveQueryData( m_query, D3D12_QUERY_TYPE_OCCLUSION, 0, 1, m_result, 0 ); + m_frameIndex = m_owner->GetRecordingFrameNumber(); + return S_OK; +} - Tr2ALMemoryType Tr2OcclusionQueryAL::GetMemoryClass() const +ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ) +{ + if( !m_result ) { - return AL_MEMORY_MANAGED; + return E_INVALIDCALL; } - - void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + if( waitMode == ::Tr2OcclusionQueryAL::WAIT ) { - description["type"] = "Tr2OcclusionQueryAL"; - description["name"] = m_name; + renderContext.FlushAndSyncDx12(); } - - ALResult Tr2OcclusionQueryAL::SetName( const char* name ) + if( m_owner->GetRenderedFrameNumber() < m_frameIndex ) { - m_name = name; - SetDebugName( m_query, name ); - SetDebugName( m_result, name ); - return S_OK; + return S_FALSE; } + D3D12_RANGE readRange = { 0, 8 }; + void* data; + CR_RETURN_HR( m_result->Map( 0, &readRange, &data ) ); + count = uint32_t( *static_cast( data ) ); + D3D12_RANGE writeRange = { 0, 0 }; + m_result->Unmap( 0, &writeRange ); + return S_OK; +} + +Tr2ALMemoryType Tr2OcclusionQueryAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2OcclusionQueryAL"; + description["name"] = m_name; +} + +ALResult Tr2OcclusionQueryAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_query, name ); + SetDebugName( m_result, name ); + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2OcclusionQueryALDx12.h b/trinityal/dx12/Tr2OcclusionQueryALDx12.h index 97ab8e125..e5fb37c2f 100644 --- a/trinityal/dx12/Tr2OcclusionQueryALDx12.h +++ b/trinityal/dx12/Tr2OcclusionQueryALDx12.h @@ -8,35 +8,35 @@ namespace TrinityALImpl { - class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL - { - public: - Tr2OcclusionQueryAL(); - ~Tr2OcclusionQueryAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; - - ALResult Begin( Tr2RenderContextAL& renderContext ); - ALResult End( Tr2RenderContextAL& renderContext ); - ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; - Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; - - CComPtr m_query; - CComPtr m_result; - uint64_t m_frameIndex; - Tr2PrimaryRenderContextAL* m_owner; - std::string m_name; - }; - } +class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL +{ +public: + Tr2OcclusionQueryAL(); + ~Tr2OcclusionQueryAL(); + + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + + ALResult Begin( Tr2RenderContextAL& renderContext ); + ALResult End( Tr2RenderContextAL& renderContext ); + ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; + Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; + + CComPtr m_query; + CComPtr m_result; + uint64_t m_frameIndex; + Tr2PrimaryRenderContextAL* m_owner; + std::string m_name; +}; +} #endif diff --git a/trinityal/dx12/Tr2PipelineStatsQueryALDx12.cpp b/trinityal/dx12/Tr2PipelineStatsQueryALDx12.cpp index 61c93d82f..8fcb636dd 100644 --- a/trinityal/dx12/Tr2PipelineStatsQueryALDx12.cpp +++ b/trinityal/dx12/Tr2PipelineStatsQueryALDx12.cpp @@ -65,7 +65,7 @@ ALResult Tr2PipelineStatsQueryAL::Create( Tr2PrimaryRenderContextAL& renderConte CR_RETURN_HR( renderContext.m_device->CreateQueryHeap( &queryHeapDesc, IID_PPV_ARGS( &query ) ) ); auto scratchHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_READBACK ); - auto bufferDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_QUERY_DATA_PIPELINE_STATISTICS ) ); + auto bufferDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_QUERY_DATA_PIPELINE_STATISTICS ) ); CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( &scratchHeap, D3D12_HEAP_FLAG_NONE, diff --git a/trinityal/dx12/Tr2PrimaryRenderContextDx12.cpp b/trinityal/dx12/Tr2PrimaryRenderContextDx12.cpp index b798f6b40..68c3e5ac3 100644 --- a/trinityal/dx12/Tr2PrimaryRenderContextDx12.cpp +++ b/trinityal/dx12/Tr2PrimaryRenderContextDx12.cpp @@ -36,75 +36,73 @@ CCP_STATS_DECLARE( dx12GpuMemoryBudgetLocal, "Trinity/AL/gpuMemory/budgetLocal", namespace { - bool EnableDebugLayer() +bool EnableDebugLayer() +{ + CComPtr pDredSettings; + if( SUCCEEDED( D3D12GetDebugInterface( IID_PPV_ARGS( &pDredSettings ) ) ) ) { - CComPtr pDredSettings; - if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pDredSettings)))) - { - // Turn on auto-breadcrumbs and page fault reporting. - pDredSettings->SetAutoBreadcrumbsEnablement( D3D12_DRED_ENABLEMENT_FORCED_ON ); - pDredSettings->SetPageFaultEnablement( D3D12_DRED_ENABLEMENT_FORCED_ON ); - } + // Turn on auto-breadcrumbs and page fault reporting. + pDredSettings->SetAutoBreadcrumbsEnablement( D3D12_DRED_ENABLEMENT_FORCED_ON ); + pDredSettings->SetPageFaultEnablement( D3D12_DRED_ENABLEMENT_FORCED_ON ); + } - CComPtr debugInterface; - CComPtr debugInterface1; - if( SUCCEEDED( D3D12GetDebugInterface( IID_PPV_ARGS( &debugInterface ) ) ) ) - { - debugInterface->EnableDebugLayer(); - if( SUCCEEDED( debugInterface->QueryInterface( IID_PPV_ARGS( &debugInterface1 ) ) ) ) - { - debugInterface1->SetEnableGPUBasedValidation( true ); - } - return true; - } - else + CComPtr debugInterface; + CComPtr debugInterface1; + if( SUCCEEDED( D3D12GetDebugInterface( IID_PPV_ARGS( &debugInterface ) ) ) ) + { + debugInterface->EnableDebugLayer(); + if( SUCCEEDED( debugInterface->QueryInterface( IID_PPV_ARGS( &debugInterface1 ) ) ) ) { - CCP_AL_LOGWARN( "DX12: No debug interface available, no error logging will be available" ); - return false; + debugInterface1->SetEnableGPUBasedValidation( true ); } + return true; } - - void SetupInfoQueue( ID3D12Device* device ) + else { - CComQIPtr queue( device ); - if( queue ) - { - D3D12_MESSAGE_SEVERITY severity[] = - { - D3D12_MESSAGE_SEVERITY_CORRUPTION, - D3D12_MESSAGE_SEVERITY_ERROR, - }; - - // JB: Added some message filters - D3D12_MESSAGE_ID blocked[] = - { - // JB: Removed this because it pops up due to a bug - D3D12_MESSAGE_ID_COPY_DESCRIPTORS_INVALID_RANGES, - - // JB: This spam a lot and should be suppressed. - // *HOWEVER* it would be a good idea to uncomment them and try to use the feature! - D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE, - D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE - }; - - D3D12_INFO_QUEUE_FILTER filter; - memset( &filter, 0, sizeof( filter ) ); - filter.AllowList.NumSeverities = 2; - filter.AllowList.pSeverityList = severity; - filter.DenyList.pIDList = blocked; - filter.DenyList.NumIDs = sizeof(blocked) / sizeof(blocked[0]); - CR( queue->PushRetrievalFilter( &filter ) ); - CR( queue->PushStorageFilter(&filter) ); - } + CCP_AL_LOGWARN( "DX12: No debug interface available, no error logging will be available" ); + return false; } +} - size_t RegisterTypeIndex( Tr2ShaderRegisterAL::RegisterType type ) - { - return size_t( type ) & 31; +void SetupInfoQueue( ID3D12Device* device ) +{ + CComQIPtr queue( device ); + if( queue ) + { + D3D12_MESSAGE_SEVERITY severity[] = { + D3D12_MESSAGE_SEVERITY_CORRUPTION, + D3D12_MESSAGE_SEVERITY_ERROR, + }; + + // JB: Added some message filters + D3D12_MESSAGE_ID blocked[] = { + // JB: Removed this because it pops up due to a bug + D3D12_MESSAGE_ID_COPY_DESCRIPTORS_INVALID_RANGES, + + // JB: This spam a lot and should be suppressed. + // *HOWEVER* it would be a good idea to uncomment them and try to use the feature! + D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE + }; + + D3D12_INFO_QUEUE_FILTER filter; + memset( &filter, 0, sizeof( filter ) ); + filter.AllowList.NumSeverities = 2; + filter.AllowList.pSeverityList = severity; + filter.DenyList.pIDList = blocked; + filter.DenyList.NumIDs = sizeof( blocked ) / sizeof( blocked[0] ); + CR( queue->PushRetrievalFilter( &filter ) ); + CR( queue->PushStorageFilter( &filter ) ); } - - size_t s_perFrameMinReleaseCount = 100; +} + +size_t RegisterTypeIndex( Tr2ShaderRegisterAL::RegisterType type ) +{ + return size_t( type ) & 31; +} + +size_t s_perFrameMinReleaseCount = 100; } @@ -163,7 +161,7 @@ class Tr2PrimaryRenderContextAL::MemoryWatchdog ~MemoryWatchdog() { - if ( m_watchdogThread.joinable() ) + if( m_watchdogThread.joinable() ) { SetEvent( m_stopEvent ); m_watchdogThread.join(); @@ -176,14 +174,13 @@ class Tr2PrimaryRenderContextAL::MemoryWatchdog { CloseHandle( m_stopEvent ); } - if ( m_bugdetChangeEvent ) + if( m_bugdetChangeEvent ) { CloseHandle( m_bugdetChangeEvent ); } } private: - void Watcher() { while( true ) @@ -290,7 +287,7 @@ Tr2PrimaryRenderContextAL::~Tr2PrimaryRenderContextAL() ALResult Tr2PrimaryRenderContextAL::CreateDevice( uint32_t adapter, - Tr2WindowHandle focusWindow, + Tr2WindowHandle focusWindow, const Tr2PresentParametersAL& pp ) { Destroy(); @@ -315,13 +312,13 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( m_gpuCrashTracker = new TrinityALImpl::GpuCrashTracker(); } CR_RETURN_HR( TrinityALImpl::GetVideoAdapter( adapter, &dxgiAdapter, &output ) ); - + bool dxrAvailable = false; // Create directX 12.1 device for raytracing, if it fails fall back to 12.0 if( SUCCEEDED( CreateDevice( dxgiAdapter, D3D_FEATURE_LEVEL_12_1, device ) ) ) - { + { D3D12_FEATURE_DATA_D3D12_OPTIONS5 caps = {}; - if( FAILED( device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &caps, sizeof( caps ) ) ) || caps.RaytracingTier < D3D12_RAYTRACING_TIER_1_1 ) + if( FAILED( device->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS5, &caps, sizeof( caps ) ) ) || caps.RaytracingTier < D3D12_RAYTRACING_TIER_1_1 ) { CCP_LOGNOTICE( "DirectX device or driver does not support raytracing" ); } @@ -334,7 +331,7 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( else { CCP_LOGNOTICE( "Failed to create DirectX 12.1 device, now creating DirectX 12.0 device instead" ); - CR_RETURN_HR(CreateDevice( dxgiAdapter, D3D_FEATURE_LEVEL_12_0, device ) ); + CR_RETURN_HR( CreateDevice( dxgiAdapter, D3D_FEATURE_LEVEL_12_0, device ) ); } if( !m_gpuCrashTracker->IsValid() ) @@ -357,20 +354,19 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( D3D12_DESCRIPTOR_HEAP_TYPE m_type; uint32_t m_pageSize; uint32_t m_numPages; - } heapLayout[] = - { + } heapLayout[] = { { D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, CRVSRVUAV_PAGE_SIZE, CRVSRVUAV_NUM_PAGES }, { D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, SAMPLER_PAGE_SIZE, SAMPLER_NUM_PAGES }, { D3D12_DESCRIPTOR_HEAP_TYPE_RTV, RTV_PAGE_SIZE, RTV_NUM_PAGES }, { D3D12_DESCRIPTOR_HEAP_TYPE_DSV, DSV_PAGE_SIZE, DSV_NUM_PAGES } }; - for (int32_t idx = 0; idx < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++idx) + for( int32_t idx = 0; idx < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++idx ) { - CCP_ASSERT(heapLayout[idx].m_type == D3D12_DESCRIPTOR_HEAP_TYPE(idx)); + CCP_ASSERT( heapLayout[idx].m_type == D3D12_DESCRIPTOR_HEAP_TYPE( idx ) ); m_allocators[idx] = std::make_shared( device, heapLayout[idx].m_numPages, heapLayout[idx].m_pageSize, heapLayout[idx].m_type ); - CCP_ASSERT(m_allocators[idx].get() != nullptr); + CCP_ASSERT( m_allocators[idx].get() != nullptr ); } m_srvUavAllocator = std::make_shared( device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 16 * 1024 ); @@ -405,10 +401,10 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( if( !isWindowless ) { backBufferCount = Tr2SwapChainUtils::BACK_BUFFER_COUNT; - FORWARD_HR( Tr2SwapChainUtils::CreateSwapChain( swapchain, focusWindow, presentationParameters, commandQueue, output, *this) ); + FORWARD_HR( Tr2SwapChainUtils::CreateSwapChain( swapchain, focusWindow, presentationParameters, commandQueue, output, *this ) ); } - + std::vector> rtvs; std::vector> backBuffers; @@ -418,10 +414,10 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( HRESULT hr = TrinityALImpl::Tr2SwapChainAL::GetBackBuffers( this, backBuffers, rtvs, swapchain ); m_device = nullptr; - FORWARD_HR(hr); + FORWARD_HR( hr ); } - std::vector < CComPtr> commandAllocators; + std::vector> commandAllocators; for( uint32_t i = 0; i < backBufferCount; ++i ) { CComPtr commandAllocator; @@ -576,7 +572,7 @@ ALResult Tr2PrimaryRenderContextAL::CreateDevice( CCP_AL_LOGNOTICE( "Created dx12 device for adapter %S", info.description.c_str() ); } - m_options = {}; + m_options = {}; m_device->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS, &m_options, sizeof( m_options ) ); @@ -717,7 +713,7 @@ void Tr2PrimaryRenderContextAL::Destroy() m_srvUavAllocator = nullptr; m_samplerHeapStart = nullptr; m_samplerAllocator = nullptr; - for (int32_t idx = 0; idx < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++idx) + for( int32_t idx = 0; idx < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++idx ) { m_allocators[idx] = nullptr; } @@ -816,7 +812,7 @@ ALResult Tr2PrimaryRenderContextAL::SetPresentParameters( uint32_t adapter, cons m_frameFenceValues.resize( Tr2SwapChainUtils::BACK_BUFFER_COUNT, value + 1 ); UINT resizeFlags = 0; - + if( m_supportsVariableRefreshRate ) { resizeFlags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; @@ -824,10 +820,10 @@ ALResult Tr2PrimaryRenderContextAL::SetPresentParameters( uint32_t adapter, cons // Dx12 is never in proper fullscreen CR( m_swapchain->ResizeBuffers( Tr2SwapChainUtils::BACK_BUFFER_COUNT, - presentationParameters.mode.width, - presentationParameters.mode.height, - fmt, - resizeFlags ) ); + presentationParameters.mode.width, + presentationParameters.mode.height, + fmt, + resizeFlags ) ); m_syncInterval = presentationParameters.presentInterval; @@ -868,7 +864,7 @@ ALResult Tr2PrimaryRenderContextAL::Present() { // some swap chains scheduled for presenting might have already been destroyed m_pendingPresents.erase( - std::remove_if( begin( m_pendingPresents ), end( m_pendingPresents ), []( const PendingPresent& p )->bool { return !p.backBuffer.IsValid(); } ), + std::remove_if( begin( m_pendingPresents ), end( m_pendingPresents ), []( const PendingPresent& p ) -> bool { return !p.backBuffer.IsValid(); } ), end( m_pendingPresents ) ); SetResourceSet( Tr2ResourceSetAL() ); @@ -940,7 +936,7 @@ ALResult Tr2PrimaryRenderContextAL::Present() m_commandQueue->ExecuteCommandLists( _countof( commandLists ), commandLists ); m_frameFenceValues[m_currentBackBufferIndex] = SignalDx12(); - auto presentFlag = (m_syncInterval == Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE && m_supportsVariableRefreshRate) ? DXGI_PRESENT_ALLOW_TEARING : 0; + auto presentFlag = ( m_syncInterval == Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE && m_supportsVariableRefreshRate ) ? DXGI_PRESENT_ALLOW_TEARING : 0; CR( m_swapchain->Present( m_syncInterval, presentFlag ) ); FORWARD_HR( m_device->GetDeviceRemovedReason(); ) @@ -1006,8 +1002,7 @@ ALResult Tr2PrimaryRenderContextAL::Present() &bufferDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, - IID_PPV_ARGS( &m_statsResult ) - ) ); + IID_PPV_ARGS( &m_statsResult ) ) ); if( m_statsResult ) { m_statsStatus = STAT_READY; @@ -1080,7 +1075,7 @@ uint64_t Tr2PrimaryRenderContextAL::SignalDx12() ALResult Tr2PrimaryRenderContextAL::WaitForFenceDx12( uint64_t value ) { CR_RETURN_HR( m_presentFence->SetEventOnCompletion( value, m_presentFenceEvent ) ); - for( uint32_t count = 0; ; ++count ) + for( uint32_t count = 0;; ++count ) { if( WaitForSingleObject( m_presentFenceEvent, 1000 ) == WAIT_OBJECT_0 ) { @@ -1101,15 +1096,15 @@ ALResult Tr2PrimaryRenderContextAL::WaitForFenceDx12( uint64_t value ) } #if ENABLE_RELEASE_LATER_TAG -void Tr2PrimaryRenderContextAL::ReleaseLater( IUnknown* resource, const std::string& name) +void Tr2PrimaryRenderContextAL::ReleaseLater( IUnknown* resource, const std::string& name ) { ReleasePair pair = { resource, name }; - m_pendingRelease[m_currentBackBufferIndex].push_back(pair); + m_pendingRelease[m_currentBackBufferIndex].push_back( pair ); } #else -void Tr2PrimaryRenderContextAL::ReleaseLater(IUnknown* resource) +void Tr2PrimaryRenderContextAL::ReleaseLater( IUnknown* resource ) { - m_pendingRelease[m_currentBackBufferIndex].push_back(resource); + m_pendingRelease[m_currentBackBufferIndex].push_back( resource ); } #endif @@ -1183,14 +1178,14 @@ ALResult Tr2PrimaryRenderContextAL::FlushAndSyncDx12( Tr2RenderContextAL& render FORWARD_HR( WaitForFenceDx12( SignalDx12() ) ); m_pendingPresents.erase( - std::remove_if( begin( m_pendingPresents ), end( m_pendingPresents ), []( const PendingPresent& p )->bool { return !p.backBuffer.IsValid(); } ), + std::remove_if( begin( m_pendingPresents ), end( m_pendingPresents ), []( const PendingPresent& p ) -> bool { return !p.backBuffer.IsValid(); } ), end( m_pendingPresents ) ); m_srvUavAllocator->SetFrameIndices( GetRecordingFrameNumber(), GetRenderedFrameNumber() ); - // Reduce the pending releases + // Reduce the pending releases for( auto index = 0; index < m_pendingRelease.size(); ++index ) { - PopPendingRelease(index); + PopPendingRelease( index ); } auto commandAllocator = m_commandAllocators[m_commandAllocatorIndex++ % m_commandAllocators.size()]; @@ -1242,19 +1237,19 @@ TrinityALImpl::GpuCrashTracker* Tr2PrimaryRenderContextAL::GetGpuCrashTracker() return m_gpuCrashTracker; } -void Tr2PrimaryRenderContextAL::UnRegisterFromCrashTracker(ID3D12GraphicsCommandList2* commandList) +void Tr2PrimaryRenderContextAL::UnRegisterFromCrashTracker( ID3D12GraphicsCommandList2* commandList ) { - if(m_gpuCrashTracker) + if( m_gpuCrashTracker ) { - m_gpuCrashTracker->UnRegisterCommandList(commandList); + m_gpuCrashTracker->UnRegisterCommandList( commandList ); } } -void Tr2PrimaryRenderContextAL::AddShaderBinaryToCrashTracker(const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath) +void Tr2PrimaryRenderContextAL::AddShaderBinaryToCrashTracker( const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath ) { - if(m_gpuCrashTracker) + if( m_gpuCrashTracker ) { - m_gpuCrashTracker->RegisterShaderBinary(bytecode, shaderPath); + m_gpuCrashTracker->RegisterShaderBinary( bytecode, shaderPath ); } } @@ -1327,7 +1322,7 @@ std::shared_ptr Tr2PrimaryRenderContextAL::GetSamplerHeapView( } /** Create a ShaderResourceView */ -HRESULT Tr2PrimaryRenderContextAL::CreateShaderResourceView(ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC& desc, std::shared_ptr& srvView) +HRESULT Tr2PrimaryRenderContextAL::CreateShaderResourceView( ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC& desc, std::shared_ptr& srvView ) { auto entry = m_srvUavAllocator->Allocate(); if( entry == nullptr ) @@ -1335,14 +1330,14 @@ HRESULT Tr2PrimaryRenderContextAL::CreateShaderResourceView(ID3D12Resource* reso return E_OUTOFMEMORY; } // CHECK - m_device->CreateShaderResourceView( desc.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE ? nullptr : resource , &desc, entry->m_offsetCPU ); + m_device->CreateShaderResourceView( desc.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE ? nullptr : resource, &desc, entry->m_offsetCPU ); m_device->CreateShaderResourceView( desc.ViewDimension == D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE ? nullptr : resource, &desc, m_srvUavAllocator->GetDescriptorInCpuHeap( entry ) ); srvView = std::make_shared( m_srvUavAllocator.get(), entry ); return S_OK; } /** Create an UnorderedAccessView */ -HRESULT Tr2PrimaryRenderContextAL::CreateUnorderedAccessView(ID3D12Resource* resource, ID3D12Resource* counterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC& desc, std::shared_ptr& uavView) +HRESULT Tr2PrimaryRenderContextAL::CreateUnorderedAccessView( ID3D12Resource* resource, ID3D12Resource* counterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC& desc, std::shared_ptr& uavView ) { auto entry = m_srvUavAllocator->Allocate(); if( entry == nullptr ) @@ -1356,43 +1351,43 @@ HRESULT Tr2PrimaryRenderContextAL::CreateUnorderedAccessView(ID3D12Resource* res } /** Create a SamplerState */ -HRESULT Tr2PrimaryRenderContextAL::CreateSamplerState(const D3D12_SAMPLER_DESC& desc, std::shared_ptr& samplerState) +HRESULT Tr2PrimaryRenderContextAL::CreateSamplerState( const D3D12_SAMPLER_DESC& desc, std::shared_ptr& samplerState ) { GlobalDescriptorHeapPage::DescriptorEntry* entry = m_samplerAllocator->Allocate(); if( entry == nullptr ) { return E_OUTOFMEMORY; } - m_device->CreateSampler(&desc, entry->m_offsetCPU); + m_device->CreateSampler( &desc, entry->m_offsetCPU ); samplerState = std::make_shared( m_samplerAllocator.get(), entry ); return S_OK; } /** Create a RenderTargetView */ -HRESULT Tr2PrimaryRenderContextAL::CreateRenderTargetView(ID3D12Resource* resource, const D3D12_RENDER_TARGET_VIEW_DESC* desc, std::shared_ptr& rtvView) +HRESULT Tr2PrimaryRenderContextAL::CreateRenderTargetView( ID3D12Resource* resource, const D3D12_RENDER_TARGET_VIEW_DESC* desc, std::shared_ptr& rtvView ) { const std::shared_ptr& allocator = m_allocators[D3D12_DESCRIPTOR_HEAP_TYPE_RTV]; GlobalDescriptorHeapPage::DescriptorEntry* entry = allocator->Allocate(); - if (entry == nullptr) + if( entry == nullptr ) return E_OUTOFMEMORY; - m_device->CreateRenderTargetView(resource, desc, entry->m_offsetCPU); + m_device->CreateRenderTargetView( resource, desc, entry->m_offsetCPU ); - rtvView = std::make_shared(allocator.get(), entry); + rtvView = std::make_shared( allocator.get(), entry ); return S_OK; } /** Create a DepthStencilView */ -HRESULT Tr2PrimaryRenderContextAL::CreateDepthStencilView(ID3D12Resource* resource, const D3D12_DEPTH_STENCIL_VIEW_DESC& desc, std::shared_ptr& dsvView) +HRESULT Tr2PrimaryRenderContextAL::CreateDepthStencilView( ID3D12Resource* resource, const D3D12_DEPTH_STENCIL_VIEW_DESC& desc, std::shared_ptr& dsvView ) { const std::shared_ptr& allocator = m_allocators[D3D12_DESCRIPTOR_HEAP_TYPE_DSV]; GlobalDescriptorHeapPage::DescriptorEntry* entry = allocator->Allocate(); - if (entry == nullptr) + if( entry == nullptr ) return E_OUTOFMEMORY; - m_device->CreateDepthStencilView(resource, &desc, entry->m_offsetCPU); + m_device->CreateDepthStencilView( resource, &desc, entry->m_offsetCPU ); - dsvView = std::make_shared(allocator.get(), entry); + dsvView = std::make_shared( allocator.get(), entry ); return S_OK; } @@ -1432,7 +1427,7 @@ bool Tr2PrimaryRenderContextAL::FormatIsUAVCompatibleDx12( DXGI_FORMAT format ) case DXGI_FORMAT_R8_UINT: case DXGI_FORMAT_R8_SINT: return m_options.TypedUAVLoadAdditionalFormats != 0; - case DXGI_FORMAT_R11G11B10_FLOAT: + case DXGI_FORMAT_R11G11B10_FLOAT: if( m_device && m_options.TypedUAVLoadAdditionalFormats != 0 ) { D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupport = { format, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE }; @@ -1477,7 +1472,7 @@ Tr2UpscalingAL::Result Tr2PrimaryRenderContextAL::EnableUpscaling( Tr2UpscalingA } // find the technique - auto supportedTechnique = std::find( std::begin( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES), std::end(TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES), tech ); + auto supportedTechnique = std::find( std::begin( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ), std::end( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ), tech ); if( supportedTechnique == std::end( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ) ) { return Tr2UpscalingAL::Result::TECHNIQUE_NOT_SUPPORTED; @@ -1555,8 +1550,8 @@ std::vector> Tr2PrimaryRen std::vector> supportedTechniques; for( auto& technique : TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ) { - if( technique == activeTechnique && m_upscalingTechnique) - { + if( technique == activeTechnique && m_upscalingTechnique ) + { uint32_t allSettings = 0; for( auto& setting : m_upscalingTechnique->GetAvailableSettings() ) @@ -1638,7 +1633,7 @@ HRESULT Tr2PrimaryRenderContextAL::CreateSwapChainForHwnd( return S_OK; } -HRESULT Tr2PrimaryRenderContextAL::CreateDevice(IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, CComPtr& device) const +HRESULT Tr2PrimaryRenderContextAL::CreateDevice( IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, CComPtr& device ) const { CR_RETURN_HR( D3D12CreateDevice( adapter, featureLevel, IID_PPV_ARGS( &device ) ) ); diff --git a/trinityal/dx12/Tr2PrimaryRenderContextDx12.h b/trinityal/dx12/Tr2PrimaryRenderContextDx12.h index cd0e9c366..5051b3d7b 100644 --- a/trinityal/dx12/Tr2PrimaryRenderContextDx12.h +++ b/trinityal/dx12/Tr2PrimaryRenderContextDx12.h @@ -25,34 +25,34 @@ #define ENABLE_RELEASE_LATER_TAG 0 #define DUMP_RELEASE_LATER_TAGS 1 #if ENABLE_RELEASE_LATER_TAG - #define _RT_STRINGIFY__(s) #s - #define RT_STRINGIFY(s) _RT_STRINGIFY__(s) +#define _RT_STRINGIFY__( s ) #s +#define RT_STRINGIFY( s ) _RT_STRINGIFY__( s ) // #define RELEASE_LATER(ownerDevice, comObject) (ownerDevice)->ReleaseLater(comObject, __FILE__ ":" RT_STRINGIFY(__LINE__) " " #comObject); - #define RELEASE_LATER(ownerDevice, comObject) \ - { \ - char __dbo[256]; \ - sprintf_s(__dbo, __FILE__ ":" RT_STRINGIFY(__LINE__) " " #comObject " Frame(%i)", (ownerDevice)->GetCurrentBackBufferIndex()); \ - (ownerDevice)->ReleaseLater(comObject, __dbo); \ - } +#define RELEASE_LATER( ownerDevice, comObject ) \ + { \ + char __dbo[256]; \ + sprintf_s( __dbo, __FILE__ ":" RT_STRINGIFY( __LINE__ ) " " #comObject " Frame(%i)", ( ownerDevice )->GetCurrentBackBufferIndex() ); \ + ( ownerDevice )->ReleaseLater( comObject, __dbo ); \ + } #else - #define RELEASE_LATER(ownerDevice, comObject) (ownerDevice)->ReleaseLater(comObject); +#define RELEASE_LATER( ownerDevice, comObject ) ( ownerDevice )->ReleaseLater( comObject ); #endif struct Tr2PresentParametersAL; namespace TrinityALImpl { - class GenerateMipsResources; +class GenerateMipsResources; } -class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL +class Tr2PrimaryRenderContextAL : public Tr2RenderContextAL { public: Tr2PrimaryRenderContextAL(); ~Tr2PrimaryRenderContextAL(); - ALResult CreateDevice( uint32_t adapter, Tr2WindowHandle focusWindow, const Tr2PresentParametersAL& presentationParameters ); + ALResult CreateDevice( uint32_t adapter, Tr2WindowHandle focusWindow, const Tr2PresentParametersAL& presentationParameters ); void Destroy(); bool IsValid() const; @@ -60,13 +60,13 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL ALResult SetPresentParameters( uint32_t adapter, const Tr2PresentParametersAL& presentationParameters ); const Tr2CapsAL& GetCaps() const; - + ALResult Present(); Tr2RenderContextEnum::PixelFormat GetBackBufferFormat() const; - void AddShaderBinaryToCrashTracker(const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath); - void UnRegisterFromCrashTracker(ID3D12GraphicsCommandList2* commandList); + void AddShaderBinaryToCrashTracker( const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath ); + void UnRegisterFromCrashTracker( ID3D12GraphicsCommandList2* commandList ); bool SupportsBindlessTextures() const; @@ -79,10 +79,11 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL ITr2RenderContextEvents* m_events; TrinityALImpl::GenerateMipsResources* m_genMipsResources; + public: TrinityALImpl::Tr2SamplerStateALFactory m_samplerStateFactory; - Tr2TextureAL& GetDefaultBackBuffer() + Tr2TextureAL& GetDefaultBackBuffer() { return m_defaultBackBuffer; } @@ -97,9 +98,9 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL uint32_t& mips ) const; #if ENABLE_RELEASE_LATER_TAG - void ReleaseLater(IUnknown* resource, const std::string& name); + void ReleaseLater( IUnknown* resource, const std::string& name ); #else - void ReleaseLater(IUnknown* resource); + void ReleaseLater( IUnknown* resource ); #endif void FlushPendingRelease(); @@ -110,7 +111,7 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL ALResult SignalDx12( uint64_t& fenceValue ); uint64_t SignalDx12(); ALResult WaitForFenceDx12( uint64_t value ); - const TrinityALImpl::GpuMarkerBuffer &GetMarkerBuffer() const; + const TrinityALImpl::GpuMarkerBuffer& GetMarkerBuffer() const; TrinityALImpl::GpuCrashTracker* GetGpuCrashTracker() const; void ScheduleSwapchainPresentDx12( IDXGISwapChain3* swapChain, const Tr2TextureAL& backbuffer, uint32_t presentInterval ); @@ -123,22 +124,25 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL std::shared_ptr GetSamplerHeapView() const; /** Create a ShaderResourceView */ - HRESULT CreateShaderResourceView(ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC& desc, std::shared_ptr& srvView); + HRESULT CreateShaderResourceView( ID3D12Resource* resource, const D3D12_SHADER_RESOURCE_VIEW_DESC& desc, std::shared_ptr& srvView ); /** Create an UnorderedAccessView */ - HRESULT CreateUnorderedAccessView(ID3D12Resource* resource, ID3D12Resource* counterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC& desc, std::shared_ptr& uavView); + HRESULT CreateUnorderedAccessView( ID3D12Resource* resource, ID3D12Resource* counterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC& desc, std::shared_ptr& uavView ); /** Create a SamplerState */ - HRESULT CreateSamplerState(const D3D12_SAMPLER_DESC& desc, std::shared_ptr& samplerState); + HRESULT CreateSamplerState( const D3D12_SAMPLER_DESC& desc, std::shared_ptr& samplerState ); /** Create a RenderTargetView */ - HRESULT CreateRenderTargetView(ID3D12Resource* resource, const D3D12_RENDER_TARGET_VIEW_DESC* desc, std::shared_ptr& rtvView); + HRESULT CreateRenderTargetView( ID3D12Resource* resource, const D3D12_RENDER_TARGET_VIEW_DESC* desc, std::shared_ptr& rtvView ); /** Create a DepthStencilView */ - HRESULT CreateDepthStencilView(ID3D12Resource* resource, const D3D12_DEPTH_STENCIL_VIEW_DESC& desc, std::shared_ptr& dsvView); + HRESULT CreateDepthStencilView( ID3D12Resource* resource, const D3D12_DEPTH_STENCIL_VIEW_DESC& desc, std::shared_ptr& dsvView ); /** Get the current buffer index */ - uint32_t GetCurrentBackBufferIndex() const { return m_currentBackBufferIndex; } + uint32_t GetCurrentBackBufferIndex() const + { + return m_currentBackBufferIndex; + } uint32_t GetBackBufferCount() const { return uint32_t( m_frameFenceValues.size() ); @@ -148,17 +152,17 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL std::shared_ptr GetNullSrvDx12( Tr2ShaderRegisterAL::RegisterType type ) const; std::shared_ptr GetNullUavDx12( Tr2ShaderRegisterAL::RegisterType type ) const; std::shared_ptr GetNullSamplerDx12() const; - + Tr2UpscalingAL::Result EnableUpscaling( Tr2UpscalingAL::Technique tech, Tr2UpscalingAL::Setting setting, bool framegeneration, uint32_t adapter ); Tr2UpscalingContextAL* GetUpscalingContext( uint32_t upscalingContextID ) const; - Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params , uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID ); + Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID ); void DeleteUpscalingContext( uint32_t contextID ); Tr2UpscalingAL::UpscalingInfo GetUpscalingInfo( uint32_t upscalingContextID ) const; std::vector> GetSupportedUpscalingTechniques( uint32_t adapter ); void GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, Tr2UpscalingAL::Setting& setting, bool& framegeneration, bool& temporal ) const; void MarkFrameEvent( Tr2RenderContextEnum::FrameEvent frameEvent ); - + HRESULT CreateSwapChainForHwnd( CComPtr& factory4, ID3D12CommandQueue* commandQueue, @@ -172,7 +176,6 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL HRESULT CreateFactory2( UINT flags, CComPtr& factory ) const; private: - void ResetRenderTargets(); Tr2PrimaryRenderContextAL( const Tr2PrimaryRenderContextAL& ) /* = delete */; @@ -180,7 +183,7 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL void PopPendingRelease( size_t backBufferIndex ); - std::vector < CComPtr> m_commandAllocators; + std::vector> m_commandAllocators; uint32_t m_commandAllocatorIndex; @@ -207,7 +210,7 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL uint64_t m_fenceValue; uint64_t m_completedFrameIndex; std::vector m_frameFenceValues; - + uint32_t m_syncInterval; @@ -226,8 +229,7 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL operator size_t() const { - return - std::hash()( uint32_t( format ) ) ^ + return std::hash()( uint32_t( format ) ) ^ ( std::hash()( width ) << 1 ) ^ ( std::hash()( height ) << 2 ) ^ ( std::hash()( msaa.samples ) << 3 ); @@ -267,7 +269,7 @@ class Tr2PrimaryRenderContextAL: public Tr2RenderContextAL }; std::vector m_pendingPresents; - + /** Descriptor heap specific content */ enum { diff --git a/trinityal/dx12/Tr2RenderContextDx12.cpp b/trinityal/dx12/Tr2RenderContextDx12.cpp index 7607d2425..e13747566 100644 --- a/trinityal/dx12/Tr2RenderContextDx12.cpp +++ b/trinityal/dx12/Tr2RenderContextDx12.cpp @@ -18,74 +18,74 @@ extern bool g_requestDebugMarkers; -CCP_STATS_DECLARE( primitiveCount , "Trinity/AL/primitiveCount" , true, CST_COUNTER_HIGH, "Primitive count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( vertexCount , "Trinity/AL/vertexCount" , true, CST_COUNTER_HIGH, "Vertex count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( sceneDrawcallCount , "Trinity/AL/sceneDrawcallCount" , true, CST_COUNTER_LOW, "Number of DrawPrimitive calls." ); +CCP_STATS_DECLARE( primitiveCount, "Trinity/AL/primitiveCount", true, CST_COUNTER_HIGH, "Primitive count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( vertexCount, "Trinity/AL/vertexCount", true, CST_COUNTER_HIGH, "Vertex count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( sceneDrawcallCount, "Trinity/AL/sceneDrawcallCount", true, CST_COUNTER_LOW, "Number of DrawPrimitive calls." ); namespace { - enum - { - /* +enum +{ + /* * NOTE: Cache heaps store descriptors for batches in flight, so they typically consume less total memory * but can benefit from having a larger page size to reduce the chance of having to hit the allocator * mid frame */ - DESCRIPTOR_CACHE_SAMPLER_PAGE_SIZE = 1024, - - }; - - - D3D12_PRIMITIVE_TOPOLOGY s_topologies[] = { - D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, - D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, - D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, - D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, - D3D_PRIMITIVE_TOPOLOGY_LINELIST, - D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, - D3D_PRIMITIVE_TOPOLOGY_POINTLIST, - }; - - D3D12_PRIMITIVE_TOPOLOGY_TYPE s_topologyTypes[] = { - D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, - D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT - }; - - std::pair s_primitiveToVertexCount[] = { - std::make_pair( 0, 0 ), - std::make_pair( 3, 0 ), - std::make_pair( 1, 2 ), - std::make_pair( 0, 0 ), - std::make_pair( 2, 0 ), - std::make_pair( 1, 1 ), - std::make_pair( 1, 0 ), - }; - - D3D12_RESOURCE_STATES GetDepthBufferState( const Tr2TextureAL& depthBuffer, bool readOnly ) - { - if( readOnly ) + DESCRIPTOR_CACHE_SAMPLER_PAGE_SIZE = 1024, + +}; + + +D3D12_PRIMITIVE_TOPOLOGY s_topologies[] = { + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, + D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, + D3D_PRIMITIVE_TOPOLOGY_LINELIST, + D3D_PRIMITIVE_TOPOLOGY_LINESTRIP, + D3D_PRIMITIVE_TOPOLOGY_POINTLIST, +}; + +D3D12_PRIMITIVE_TOPOLOGY_TYPE s_topologyTypes[] = { + D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT +}; + +std::pair s_primitiveToVertexCount[] = { + std::make_pair( 0, 0 ), + std::make_pair( 3, 0 ), + std::make_pair( 1, 2 ), + std::make_pair( 0, 0 ), + std::make_pair( 2, 0 ), + std::make_pair( 1, 1 ), + std::make_pair( 1, 0 ), +}; + +D3D12_RESOURCE_STATES GetDepthBufferState( const Tr2TextureAL& depthBuffer, bool readOnly ) +{ + if( readOnly ) + { + auto readState = D3D12_RESOURCE_STATE_DEPTH_READ; + if( HasFlag( depthBuffer.GetGpuUsage(), Tr2GpuUsage::SHADER_RESOURCE ) ) { - auto readState = D3D12_RESOURCE_STATE_DEPTH_READ; - if( HasFlag( depthBuffer.GetGpuUsage(), Tr2GpuUsage::SHADER_RESOURCE ) ) - { - readState |= D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; - } - return readState; + readState |= D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; } - return D3D12_RESOURCE_STATE_DEPTH_WRITE; + return readState; } + return D3D12_RESOURCE_STATE_DEPTH_WRITE; +} } -Tr2RenderContextAL::Tr2RenderContextAL() throw( ) - :m_primitiveToVertexCount( 0, 0 ), +Tr2RenderContextAL::Tr2RenderContextAL() throw() : + m_primitiveToVertexCount( 0, 0 ), m_ownerDevice( nullptr ), m_dirtyPso( true ), m_readOnlyDepth( false ), @@ -95,17 +95,17 @@ Tr2RenderContextAL::Tr2RenderContextAL() throw( ) m_separateAlphaBlendEnabled( false ), m_srgbWriteEnable( false ), m_topology( Tr2RenderContextEnum::TOP_TRIANGLES ), - m_uavBarriersDisabledCounter(0) + m_uavBarriersDisabledCounter( 0 ) { std::fill( std::begin( m_vertexBuffers ), std::end( m_vertexBuffers ), VB() ); } -Tr2RenderContextAL::~Tr2RenderContextAL() throw( ) +Tr2RenderContextAL::~Tr2RenderContextAL() throw() { Destroy(); } -void Tr2RenderContextAL::Destroy() throw( ) +void Tr2RenderContextAL::Destroy() throw() { if( m_ownerDevice ) { @@ -126,18 +126,18 @@ void Tr2RenderContextAL::Destroy() throw( ) m_commandList4 = nullptr; } -bool Tr2RenderContextAL::IsValid() const throw( ) +bool Tr2RenderContextAL::IsValid() const throw() { return m_commandList != nullptr; } ALResult Tr2RenderContextAL::CreateDx12( ID3D12CommandAllocator* commandAllocator, Tr2PrimaryRenderContextAL& renderContext ) { - CR_RETURN_HR( renderContext.m_device->CreateCommandList( - 0, - D3D12_COMMAND_LIST_TYPE_DIRECT, + CR_RETURN_HR( renderContext.m_device->CreateCommandList( + 0, + D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator, - nullptr, + nullptr, IID_PPV_ARGS( &m_commandList ) ) ); CR_RETURN_HR( m_commandList->Close() ); m_commandList.QueryInterface( &m_commandList2 ); @@ -149,8 +149,8 @@ ALResult Tr2RenderContextAL::CreateDx12( ID3D12CommandAllocator* commandAllocato for( uint32_t bufferIdx = 0; bufferIdx < renderContext.GetBackBufferCount(); ++bufferIdx ) { - m_descriptorCache.push_back( std::make_shared( - renderContext.m_device, + m_descriptorCache.push_back( std::make_shared( + renderContext.m_device, &renderContext ) ); } m_ownerDevice = &renderContext; @@ -167,7 +167,7 @@ Tr2PrimaryRenderContextAL* Tr2RenderContextAL::GetPrimaryRenderContextPointer() return m_ownerDevice; } -ALResult Tr2RenderContextAL::BeginScene() throw( ) +ALResult Tr2RenderContextAL::BeginScene() throw() { return S_OK; } @@ -178,7 +178,7 @@ ALResult Tr2RenderContextAL::EndScene() } -ALResult Tr2RenderContextAL::Clear( uint32_t clearFlags, uint32_t color, float depth, uint32_t stencil, uint32_t slot ) throw( ) +ALResult Tr2RenderContextAL::Clear( uint32_t clearFlags, uint32_t color, float depth, uint32_t stencil, uint32_t slot ) throw() { bool rtClear = false; bool dsClear = false; @@ -249,9 +249,9 @@ ALResult Tr2RenderContextAL::Clear( uint32_t clearFlags, uint32_t color, float d ALResult Tr2RenderContextAL::SetStreamSource( uint32_t index, - const Tr2BufferAL & buffer, + const Tr2BufferAL& buffer, uint32_t offset, - uint32_t stride ) throw( ) + uint32_t stride ) throw() { if( index > 3 ) { @@ -293,7 +293,7 @@ ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer ) throw() return SetIndices( buffer, buffer.GetDesc().stride ); } -ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, int stride ) throw( ) +ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, int stride ) throw() { m_indexBuffer = buffer; @@ -310,7 +310,7 @@ ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, int stride ) return S_OK; } -ALResult Tr2RenderContextAL::SetVertexLayout( const Tr2VertexLayoutAL& layout ) throw( ) +ALResult Tr2RenderContextAL::SetVertexLayout( const Tr2VertexLayoutAL& layout ) throw() { if( !( m_psoDescription.m_vertexLayout == layout ) ) { @@ -321,7 +321,7 @@ ALResult Tr2RenderContextAL::SetVertexLayout( const Tr2VertexLayoutAL& layout ) return S_OK; } -ALResult Tr2RenderContextAL::SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw( ) +ALResult Tr2RenderContextAL::SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw() { if( !( m_psoDescription.m_shaderProgram == shader ) ) { @@ -331,7 +331,7 @@ ALResult Tr2RenderContextAL::SetShaderProgram( const Tr2ShaderProgramAL& shader return S_OK; } -ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topology ) throw( ) +ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topology ) throw() { auto dxTopology = s_topologies[topology]; m_commandList->IASetPrimitiveTopology( dxTopology ); @@ -346,46 +346,46 @@ ALResult Tr2RenderContextAL::SetTopology( Tr2RenderContextEnum::Topology topolog return S_OK; } -ALResult Tr2RenderContextAL::SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ) throw( ) +ALResult Tr2RenderContextAL::SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ) throw() { -#define HANDLE_STATE( rs, dest ) \ - case rs: \ - if( dest != static_cast( value ) ) \ - { \ - dest = static_cast( value ); \ - m_dirtyPso = true; \ - } \ +#define HANDLE_STATE( rs, dest ) \ + case rs: \ + if( dest != static_cast( value ) ) \ + { \ + dest = static_cast( value ); \ + m_dirtyPso = true; \ + } \ break; -#define HANDLE_STATE_FLT( rs, dest ) \ - case rs: \ - if( dest != static_cast( *reinterpret_cast( &value ) ) ) \ - { \ - dest = static_cast( *reinterpret_cast( &value ) ); \ - m_dirtyPso = true; \ - } \ +#define HANDLE_STATE_FLT( rs, dest ) \ + case rs: \ + if( dest != static_cast( *reinterpret_cast( &value ) ) ) \ + { \ + dest = static_cast( *reinterpret_cast( &value ) ); \ + m_dirtyPso = true; \ + } \ break; -#define HANDLE_STATE_DBL( rs, dest1, dest2 ) \ - case rs: \ +#define HANDLE_STATE_DBL( rs, dest1, dest2 ) \ + case rs: \ if( dest1 != static_cast( value ) || \ - dest2 != static_cast( value ) ) \ - { \ - dest1 = static_cast( value ); \ - dest2 = static_cast( value ); \ - m_dirtyPso = true; \ - } \ + dest2 != static_cast( value ) ) \ + { \ + dest1 = static_cast( value ); \ + dest2 = static_cast( value ); \ + m_dirtyPso = true; \ + } \ break; switch( state ) { - HANDLE_STATE( Tr2RenderContextEnum::RS_ALPHABLENDENABLE, m_psoDescription.m_blendDesc.RenderTarget[0].BlendEnable ); - HANDLE_STATE( Tr2RenderContextEnum::RS_SRCBLEND, m_psoDescription.m_blendDesc.RenderTarget[0].SrcBlend ); - HANDLE_STATE( Tr2RenderContextEnum::RS_DESTBLEND, m_psoDescription.m_blendDesc.RenderTarget[0].DestBlend ); - HANDLE_STATE( Tr2RenderContextEnum::RS_BLENDOP, m_psoDescription.m_blendDesc.RenderTarget[0].BlendOp ); - HANDLE_STATE( Tr2RenderContextEnum::RS_SRCBLENDALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].SrcBlendAlpha ); - HANDLE_STATE( Tr2RenderContextEnum::RS_DESTBLENDALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].DestBlendAlpha ); - HANDLE_STATE( Tr2RenderContextEnum::RS_BLENDOPALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].BlendOpAlpha ); + HANDLE_STATE( Tr2RenderContextEnum::RS_ALPHABLENDENABLE, m_psoDescription.m_blendDesc.RenderTarget[0].BlendEnable ); + HANDLE_STATE( Tr2RenderContextEnum::RS_SRCBLEND, m_psoDescription.m_blendDesc.RenderTarget[0].SrcBlend ); + HANDLE_STATE( Tr2RenderContextEnum::RS_DESTBLEND, m_psoDescription.m_blendDesc.RenderTarget[0].DestBlend ); + HANDLE_STATE( Tr2RenderContextEnum::RS_BLENDOP, m_psoDescription.m_blendDesc.RenderTarget[0].BlendOp ); + HANDLE_STATE( Tr2RenderContextEnum::RS_SRCBLENDALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].SrcBlendAlpha ); + HANDLE_STATE( Tr2RenderContextEnum::RS_DESTBLENDALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].DestBlendAlpha ); + HANDLE_STATE( Tr2RenderContextEnum::RS_BLENDOPALPHA, m_psoDescription.m_blendDesc.RenderTarget[0].BlendOpAlpha ); case Tr2RenderContextEnum::RS_COLORWRITEENABLE: if( m_psoDescription.m_blendDesc.RenderTarget[0].RenderTargetWriteMask != ( value & 0xf ) ) { @@ -394,23 +394,22 @@ ALResult Tr2RenderContextAL::SetRenderState( Tr2RenderContextEnum::RenderState s } break; - HANDLE_STATE( Tr2RenderContextEnum::RS_CULLMODE, m_psoDescription.m_rasterizerDesc.CullMode ); - HANDLE_STATE( Tr2RenderContextEnum::RS_FILLMODE, m_psoDescription.m_rasterizerDesc.FillMode ); - HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_DEPTHBIAS, m_psoDescription.m_rasterizerDesc.DepthBias ); // cppcheck-suppress invalidPointerCast - HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_ZBIAS, m_psoDescription.m_rasterizerDesc.DepthBias ); // cppcheck-suppress invalidPointerCast - HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_SLOPESCALEDEPTHBIAS, m_psoDescription.m_rasterizerDesc.SlopeScaledDepthBias ); // cppcheck-suppress invalidPointerCast - - HANDLE_STATE( Tr2RenderContextEnum::RS_ZENABLE, m_psoDescription.m_depthStencilDesc.DepthEnable ); - HANDLE_STATE( Tr2RenderContextEnum::RS_ZFUNC, m_psoDescription.m_depthStencilDesc.DepthFunc ); - HANDLE_STATE( Tr2RenderContextEnum::RS_STENCILENABLE, m_psoDescription.m_depthStencilDesc.StencilEnable ); - HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILMASK, m_psoDescription.m_depthStencilDesc.StencilReadMask, m_psoDescription.m_depthStencilDesc.StencilWriteMask ); - HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILFAIL, m_psoDescription.m_depthStencilDesc.FrontFace.StencilFailOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilFailOp ); - HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILZFAIL, m_psoDescription.m_depthStencilDesc.FrontFace.StencilDepthFailOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilDepthFailOp ); - HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILPASS, m_psoDescription.m_depthStencilDesc.FrontFace.StencilPassOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilPassOp ); - HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILFUNC, m_psoDescription.m_depthStencilDesc.FrontFace.StencilFunc, m_psoDescription.m_depthStencilDesc.BackFace.StencilFunc ); - - case Tr2RenderContextEnum::RS_ZWRITEENABLE: - { + HANDLE_STATE( Tr2RenderContextEnum::RS_CULLMODE, m_psoDescription.m_rasterizerDesc.CullMode ); + HANDLE_STATE( Tr2RenderContextEnum::RS_FILLMODE, m_psoDescription.m_rasterizerDesc.FillMode ); + HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_DEPTHBIAS, m_psoDescription.m_rasterizerDesc.DepthBias ); // cppcheck-suppress invalidPointerCast + HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_ZBIAS, m_psoDescription.m_rasterizerDesc.DepthBias ); // cppcheck-suppress invalidPointerCast + HANDLE_STATE_FLT( Tr2RenderContextEnum::RS_SLOPESCALEDEPTHBIAS, m_psoDescription.m_rasterizerDesc.SlopeScaledDepthBias ); // cppcheck-suppress invalidPointerCast + + HANDLE_STATE( Tr2RenderContextEnum::RS_ZENABLE, m_psoDescription.m_depthStencilDesc.DepthEnable ); + HANDLE_STATE( Tr2RenderContextEnum::RS_ZFUNC, m_psoDescription.m_depthStencilDesc.DepthFunc ); + HANDLE_STATE( Tr2RenderContextEnum::RS_STENCILENABLE, m_psoDescription.m_depthStencilDesc.StencilEnable ); + HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILMASK, m_psoDescription.m_depthStencilDesc.StencilReadMask, m_psoDescription.m_depthStencilDesc.StencilWriteMask ); + HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILFAIL, m_psoDescription.m_depthStencilDesc.FrontFace.StencilFailOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilFailOp ); + HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILZFAIL, m_psoDescription.m_depthStencilDesc.FrontFace.StencilDepthFailOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilDepthFailOp ); + HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILPASS, m_psoDescription.m_depthStencilDesc.FrontFace.StencilPassOp, m_psoDescription.m_depthStencilDesc.BackFace.StencilPassOp ); + HANDLE_STATE_DBL( Tr2RenderContextEnum::RS_STENCILFUNC, m_psoDescription.m_depthStencilDesc.FrontFace.StencilFunc, m_psoDescription.m_depthStencilDesc.BackFace.StencilFunc ); + + case Tr2RenderContextEnum::RS_ZWRITEENABLE: { auto mask = ( value != 0 && !m_readOnlyDepth ) ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; if( m_psoDescription.m_depthStencilDesc.DepthWriteMask != mask ) { @@ -434,7 +433,7 @@ ALResult Tr2RenderContextAL::SetRenderState( Tr2RenderContextEnum::RenderState s if( m_srgbWriteEnable != ( value != 0 ) ) { m_srgbWriteEnable = value != 0; - + D3D12_CPU_DESCRIPTOR_HANDLE handles[RENDER_TARGET_COUNT]; uint32_t count = 0; if( GetRenderTargetHandles( handles, count ) ) @@ -479,7 +478,7 @@ ALResult Tr2RenderContextAL::SetRenderState( Tr2RenderContextEnum::RenderState s #undef SET_STATE } -ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw( ) +ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw() { while( count-- ) { @@ -490,7 +489,7 @@ ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t* stateValuePairs, u return S_OK; } -ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw( ) +ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw() { if( m_resourceSet.IsValid() && !m_resourceSet.m_resourceSet->m_outTransitions.empty() ) { @@ -527,10 +526,10 @@ ALResult Tr2RenderContextAL::SetResourceSet( const Tr2ResourceSetAL& resourceSet return S_OK; } -ALResult Tr2RenderContextAL::SetConstants( const Tr2ConstantBufferAL& buffer, Tr2RenderContextEnum::ShaderType constantType, uint32_t registerIndex, uint32_t ) throw( ) +ALResult Tr2RenderContextAL::SetConstants( const Tr2ConstantBufferAL& buffer, Tr2RenderContextEnum::ShaderType constantType, uint32_t registerIndex, uint32_t ) throw() { uint32_t bufferIndex = GetPrimaryRenderContextPointer()->GetCurrentBackBufferIndex(); - m_descriptorCache[bufferIndex]->SetConstantBuffers(constantType, registerIndex, *buffer.m_buffer); + m_descriptorCache[bufferIndex]->SetConstantBuffers( constantType, registerIndex, *buffer.m_buffer ); return S_OK; } @@ -548,7 +547,7 @@ uint64_t Tr2RenderContextAL::UploadConstants( const Tr2ConstantBufferAL& buffer -ALResult Tr2RenderContextAL::DrawIndexedPrimitive( uint32_t, uint32_t startIndex, uint32_t primitiveCount, uint32_t minimumIndex ) throw( ) +ALResult Tr2RenderContextAL::DrawIndexedPrimitive( uint32_t, uint32_t startIndex, uint32_t primitiveCount, uint32_t minimumIndex ) throw() { CR_RETURN_HR( SetAllState() ); FlushGraphicsBarriersDx12(); @@ -563,7 +562,7 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitive( uint32_t, uint32_t startIndex return S_OK; } -ALResult Tr2RenderContextAL::DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ) throw( ) +ALResult Tr2RenderContextAL::DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ) throw() { CR_RETURN_HR( SetAllState() ); FlushGraphicsBarriersDx12(); @@ -583,7 +582,7 @@ ALResult Tr2RenderContextAL::DrawIndexedInstanced( uint32_t, uint32_t startIndex, uint32_t primitiveCount, - uint32_t numInstances ) throw( ) + uint32_t numInstances ) throw() { CR_RETURN_HR( SetAllState() ); FlushGraphicsBarriersDx12(); @@ -622,7 +621,7 @@ ALResult Tr2RenderContextAL::DrawInstanced( uint32_t vertexCountPerInstance, uint32_t instanceCount, uint32_t startVertexLocation, - uint32_t startInstanceLocation ) throw( ) + uint32_t startInstanceLocation ) throw() { CR_RETURN_HR( SetAllState() ); FlushGraphicsBarriersDx12(); @@ -637,14 +636,14 @@ ALResult Tr2RenderContextAL::DrawInstanced( } -ALResult Tr2RenderContextAL::DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ) +ALResult Tr2RenderContextAL::DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw() { auto buffer = params.m_buffer->GetGpuResource(); if( ( params.m_buffer->m_defaultState & D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) != D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) { ResourceBarrierDx12( TrinityALImpl::Transition( buffer, params.m_buffer->m_defaultState, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) ); } - + CR_RETURN_HR( SetAllState() ); FlushGraphicsBarriersDx12( buffer ); @@ -663,7 +662,7 @@ ALResult Tr2RenderContextAL::DrawIndexedInstancedIndirect( Tr2BufferAL& params, return S_OK; } -ALResult Tr2RenderContextAL::DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ) +ALResult Tr2RenderContextAL::DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw() { auto buffer = params.m_buffer->GetGpuResource(); if( ( params.m_buffer->m_defaultState & D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) != D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) @@ -686,7 +685,7 @@ ALResult Tr2RenderContextAL::DrawInstancedIndirect( Tr2BufferAL& params, uint32_ return S_OK; } -ALResult Tr2RenderContextAL::RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) throw( ) +ALResult Tr2RenderContextAL::RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) throw() { CR_RETURN_HR( SetAllState() ); FlushComputeBarriersDx12(); @@ -695,7 +694,7 @@ ALResult Tr2RenderContextAL::RunComputeShader( unsigned groupDimX, unsigned grou return S_OK; } -ALResult Tr2RenderContextAL::RunComputeShaderIndirect( Tr2BufferAL& params, unsigned offset ) throw( ) +ALResult Tr2RenderContextAL::RunComputeShaderIndirect( Tr2BufferAL& params, unsigned offset ) throw() { auto buffer = params.m_buffer->GetGpuResource(); if( ( params.m_buffer->m_defaultState & D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) != D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT ) @@ -828,7 +827,7 @@ ALResult Tr2RenderContextAL::SetAllState() } m_commandList->IASetVertexBuffers( 0, 4, vb ); } - + if( m_dynamicIB ) { D3D12_INDEX_BUFFER_VIEW ib = { 0, 0, DXGI_FORMAT_UNKNOWN }; @@ -886,8 +885,8 @@ void Tr2RenderContextAL::FlushGraphicsBarriersDx12( ID3D12Resource* resource ) } size_t count = 0; // resource + m_boundRenderTargets + m_boundDepthStencil + m_vertexBuffers + m_indexBuffer + m_resourceSet - ID3D12Resource* resources[1 + RENDER_TARGET_COUNT + 1 + 4 + 1 + Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - + ID3D12Resource* resources[1 + RENDER_TARGET_COUNT + 1 + 4 + 1 + Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + if( resource ) { resources[count++] = resource; @@ -977,7 +976,7 @@ ALResult Tr2RenderContextAL::SetRenderTarget( const Tr2TextureAL& renderTarget, { return S_OK; } - if( renderTarget.IsValid() && renderTarget.m_texture->GetRtvDescriptorHandleDx12(m_srgbWriteEnable ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR) == nullptr ) + if( renderTarget.IsValid() && renderTarget.m_texture->GetRtvDescriptorHandleDx12( m_srgbWriteEnable ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) == nullptr ) { return E_INVALIDARG; } @@ -1070,12 +1069,12 @@ ALResult Tr2RenderContextAL::SetRenderTarget( const Tr2TextureAL& renderTarget, } -ALResult Tr2RenderContextAL::PushDepthStencil() throw( ) +ALResult Tr2RenderContextAL::PushDepthStencil() throw() { m_dsStack.push_back( m_boundDepthStencil ); return S_OK; } -ALResult Tr2RenderContextAL::PopDepthStencil() throw( ) +ALResult Tr2RenderContextAL::PopDepthStencil() throw() { if( m_dsStack.empty() ) { @@ -1086,7 +1085,7 @@ ALResult Tr2RenderContextAL::PopDepthStencil() throw( ) return SetDepthStencil( ds ); } -ALResult Tr2RenderContextAL::SetDepthStencil( const Tr2TextureAL& depthStencil ) throw( ) +ALResult Tr2RenderContextAL::SetDepthStencil( const Tr2TextureAL& depthStencil ) throw() { if( depthStencil == m_boundDepthStencil ) { @@ -1156,7 +1155,7 @@ ALResult Tr2RenderContextAL::SetDepthStencil( const Tr2TextureAL& depthStencil ) return S_OK; } -void Tr2RenderContextAL::SetReadOnlyDepth( bool enable ) throw( ) +void Tr2RenderContextAL::SetReadOnlyDepth( bool enable ) throw() { if( m_readOnlyDepth == enable ) { @@ -1182,7 +1181,7 @@ bool Tr2RenderContextAL::GetReadOnlyDepth() const return m_readOnlyDepth; } -ALResult Tr2RenderContextAL::GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot ) throw( ) +ALResult Tr2RenderContextAL::GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot ) throw() { if( m_boundRenderTargets[slot].texture.IsValid() ) { @@ -1200,7 +1199,7 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( uint32_t primitiveCount, const uint32_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) throw( ) + uint32_t vertexStreamZeroStride ) throw() { return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, *m_ownerDevice ); } @@ -1210,7 +1209,7 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( uint32_t primitiveCount, const uint16_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) throw( ) + uint32_t vertexStreamZeroStride ) throw() { return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, *m_ownerDevice ); } @@ -1218,12 +1217,12 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( ALResult Tr2RenderContextAL::DrawPrimitiveUP( uint32_t primitiveCount, const void* vertexStreamZeroData, - uint32_t VertexStreamZeroStride ) throw( ) + uint32_t VertexStreamZeroStride ) throw() { return m_drawUPHelper.DrawPrimitiveUP( m_topology, primitiveCount, vertexStreamZeroData, VertexStreamZeroStride, *this, *m_ownerDevice ); } -ALResult Tr2RenderContextAL::SetViewport( const Tr2Viewport& viewport ) throw( ) +ALResult Tr2RenderContextAL::SetViewport( const Tr2Viewport& viewport ) throw() { m_viewport = viewport; D3D12_VIEWPORT vp = { viewport.m_x, viewport.m_y, viewport.m_width, viewport.m_height, viewport.m_minZ, viewport.m_maxZ }; @@ -1231,7 +1230,7 @@ ALResult Tr2RenderContextAL::SetViewport( const Tr2Viewport& viewport ) throw( ) return S_OK; } -ALResult Tr2RenderContextAL::GetViewport( Tr2Viewport& viewport ) throw( ) +ALResult Tr2RenderContextAL::GetViewport( Tr2Viewport& viewport ) throw() { viewport = m_viewport; return S_OK; @@ -1487,10 +1486,10 @@ bool Tr2RenderContextAL::GetRenderTargetHandles( D3D12_CPU_DESCRIPTOR_HANDLE* ha { if( m_boundRenderTargets[i].texture.IsValid() ) { - const std::shared_ptr& rtv = m_boundRenderTargets[i].texture.m_texture->GetRtvDescriptorHandleDx12( - m_srgbWriteEnable ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR, + const std::shared_ptr& rtv = m_boundRenderTargets[i].texture.m_texture->GetRtvDescriptorHandleDx12( + m_srgbWriteEnable ? Tr2RenderContextEnum::COLOR_SPACE_SRGB : Tr2RenderContextEnum::COLOR_SPACE_LINEAR, m_boundRenderTargets[i].slice ); - CCP_ASSERT(rtv != nullptr); + CCP_ASSERT( rtv != nullptr ); handles[i] = rtv->GetHandleCPU(); count = i + 1; hasNullRtsInside = hasNullRts; @@ -1602,13 +1601,12 @@ void Tr2RenderContextAL::PopGpuMarker() { m_commandList->EndEvent(); } - } /** Forcibly reset and dirty all descriptor caches (used for explicit synchronization) */ void Tr2RenderContextAL::ResetDescriptorCaches() { - for (size_t idx = 0; idx < m_descriptorCache.size(); ++idx) + for( size_t idx = 0; idx < m_descriptorCache.size(); ++idx ) { m_descriptorCache[idx]->Reset(); } @@ -1864,7 +1862,7 @@ ALResult Tr2RenderContextAL::UseResources( Tr2UseResourceDestination, Tr2GpuUsag ALResult Tr2RenderContextAL::UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ) { - return S_OK; + return S_OK; } void Tr2BindlessResourcesAL::Add( const Tr2TextureAL& texture ) diff --git a/trinityal/dx12/Tr2RenderContextDx12.h b/trinityal/dx12/Tr2RenderContextDx12.h index 893cff86b..00e910a48 100644 --- a/trinityal/dx12/Tr2RenderContextDx12.h +++ b/trinityal/dx12/Tr2RenderContextDx12.h @@ -47,35 +47,33 @@ class Tr2BindlessResourcesAL class Tr2RenderContextAL { public: - Tr2RenderContextAL() throw( ); - ~Tr2RenderContextAL() throw( ); + Tr2RenderContextAL() throw(); + ~Tr2RenderContextAL() throw(); - void Destroy() throw( ); + void Destroy() throw(); - bool IsValid() const throw( ); + bool IsValid() const throw(); ALResult CreateDx12( ID3D12CommandAllocator* commandAllocator, Tr2PrimaryRenderContextAL& renderContext ); static void SetPrimaryRenderContext( Tr2PrimaryRenderContextAL* ) { - } Tr2PrimaryRenderContextAL& GetPrimaryRenderContext(); Tr2PrimaryRenderContextAL* GetPrimaryRenderContextPointer(); - ALResult BeginScene() throw( ); + ALResult BeginScene() throw(); ALResult EndScene(); - void ReleaseDeviceResources() throw( ) + void ReleaseDeviceResources() throw() { - } - ALResult SetStreamSource( uint32_t stream, const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ) throw( ); - - ALResult SetIndices( const Tr2BufferAL & buffer ) throw( ); - ALResult SetIndices( const Tr2BufferAL & buffer, int stride ) throw(); + ALResult SetStreamSource( uint32_t stream, const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ) throw(); + + ALResult SetIndices( const Tr2BufferAL& buffer ) throw(); + ALResult SetIndices( const Tr2BufferAL& buffer, int stride ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const uint32_t values[4] ) throw(); @@ -89,25 +87,25 @@ class Tr2RenderContextAL uint32_t offset, uint32_t length ); - ALResult SetTopology( Tr2RenderContextEnum::Topology topology ) throw( ); - ALResult SetVertexLayout( const Tr2VertexLayoutAL& layout ) throw( ); - ALResult SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw( ); + ALResult SetTopology( Tr2RenderContextEnum::Topology topology ) throw(); + ALResult SetVertexLayout( const Tr2VertexLayoutAL& layout ) throw(); + ALResult SetShaderProgram( const Tr2ShaderProgramAL& shader ) throw(); + + ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw(); - ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ) throw( ); - ALResult DrawIndexedPrimitive( uint32_t numVertices, uint32_t startIndex, uint32_t primitiveCount, - uint32_t minimumIndex = 0 ) throw( ); + uint32_t minimumIndex = 0 ) throw(); - ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ) throw( ); + ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ) throw(); ALResult DrawIndexedInstanced( uint32_t numVertices, uint32_t startIndex, uint32_t primitiveCount, - uint32_t numInstances ) throw( ); + uint32_t numInstances ) throw(); ALResult DrawIndexedInstanced( uint32_t indexCountPerInstance, uint32_t instanceCount, @@ -119,40 +117,40 @@ class Tr2RenderContextAL uint32_t instanceCount, uint32_t startVertexLocation, uint32_t startInstanceLocation ) throw(); - - ALResult DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ); - ALResult DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw( ); + + ALResult DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw(); + ALResult DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ) throw(); ALResult DrawIndexedPrimitiveUP( uint32_t numVertices, uint32_t primitiveCount, const uint32_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) throw( ); + uint32_t vertexStreamZeroStride ) throw(); ALResult DrawIndexedPrimitiveUP( uint32_t numVertices, uint32_t primitiveCount, const uint16_t* indexData, const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) throw( ); + uint32_t vertexStreamZeroStride ) throw(); ALResult DrawPrimitiveUP( uint32_t primitiveCount, const void* vertexStreamZeroData, - uint32_t VertexStreamZeroStride ) throw( ); + uint32_t VertexStreamZeroStride ) throw(); - ALResult RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) throw( ); - ALResult RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw( ); + ALResult RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) throw(); + ALResult RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ) throw(); ALResult DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2RtShaderTableAL& shaderTable, const wchar_t* rayGenShader, uint32_t width, uint32_t height, uint32_t depth ); - ALResult SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ) throw( ); - ALResult SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw( ); + ALResult SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ) throw(); + ALResult SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) throw(); ALResult SetConstants( const Tr2ConstantBufferAL& buffer, Tr2RenderContextEnum::ShaderType constantType, uint32_t registerIndex, - uint32_t unusedArgument = 0 ) throw( ); + uint32_t unusedArgument = 0 ) throw(); uint64_t UploadConstants( const void* data, size_t size ); uint64_t UploadConstants( const Tr2ConstantBufferAL& buffer ); @@ -160,7 +158,6 @@ class Tr2RenderContextAL static void DestroyMainThreadRenderContext() { - } ALResult Clear( @@ -168,27 +165,27 @@ class Tr2RenderContextAL uint32_t color, float depth, uint32_t stencil = 0, - uint32_t slot = 0 ) throw( ); + uint32_t slot = 0 ) throw(); - ALResult SetViewport( const Tr2Viewport& viewport ) throw( ); - ALResult GetViewport( Tr2Viewport& viewport ) throw( ); + ALResult SetViewport( const Tr2Viewport& viewport ) throw(); + ALResult GetViewport( Tr2Viewport& viewport ) throw(); - ALResult SetRenderTarget( const Tr2TextureAL& renderTarget, uint32_t slot = 0, uint32_t slice = 0 ) throw( ); - ALResult PushRenderTarget( uint32_t slot = 0 ) throw( ); - ALResult PopRenderTarget( uint32_t slot = 0 ) throw( ); + ALResult SetRenderTarget( const Tr2TextureAL& renderTarget, uint32_t slot = 0, uint32_t slice = 0 ) throw(); + ALResult PushRenderTarget( uint32_t slot = 0 ) throw(); + ALResult PopRenderTarget( uint32_t slot = 0 ) throw(); - ALResult SetDepthStencil( const Tr2TextureAL& depthStencil ) throw( ); - ALResult PushDepthStencil() throw( ); - ALResult PopDepthStencil() throw( ); - void SetReadOnlyDepth( bool enable ) throw( ); + ALResult SetDepthStencil( const Tr2TextureAL& depthStencil ) throw(); + ALResult PushDepthStencil() throw(); + ALResult PopDepthStencil() throw(); + void SetReadOnlyDepth( bool enable ) throw(); bool GetReadOnlyDepth() const; void RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2DepthAttachment& depth ); void RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2ColorAttachment& rt1, const Tr2DepthAttachment& depth ); - ALResult GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot = 0 ) throw( ); - - static const uint32_t SHADER_TYPE_MASK = + ALResult GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot = 0 ) throw(); + + static const uint32_t SHADER_TYPE_MASK = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ) | ( 1 << Tr2RenderContextEnum::PIXEL_SHADER ) | ( 1 << Tr2RenderContextEnum::COMPUTE_SHADER ) | @@ -197,8 +194,14 @@ class Tr2RenderContextAL ( 1 << Tr2RenderContextEnum::DOMAIN_SHADER ); // Debug helpers - size_t GetStackSizeRT( uint32_t = 0 ) const { return 0; } - size_t GetStackSizeDS() const { return 0; } + size_t GetStackSizeRT( uint32_t = 0 ) const + { + return 0; + } + size_t GetStackSizeDS() const + { + return 0; + } void AddGpuMarker( const char* marker ); void PushGpuMarker( const char* marker ); @@ -227,9 +230,10 @@ class Tr2RenderContextAL void FlushComputeBarriersDx12( ID3D12Resource* resource = nullptr ); ALResult UseResources( Tr2UseResourceDestination dest, Tr2GpuUsage::Type usage, const Tr2BindlessResourcesAL& resources ); - ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); - + ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); + ALResult SetAllState(); + protected: ID3D12PipelineState* GetPipelineState(); @@ -260,6 +264,7 @@ class Tr2RenderContextAL Tr2ResourceSetAL m_resourceSet; bool GetRenderTargetHandles( D3D12_CPU_DESCRIPTOR_HANDLE* handles, uint32_t& count ); + public: std::vector> m_descriptorCache; @@ -272,9 +277,8 @@ class Tr2RenderContextAL Tr2PrimaryRenderContextAL* m_ownerDevice; bool m_dirtyPso; -protected: - +protected: static const uint32_t RENDER_TARGET_COUNT = 4; struct BoundRT @@ -293,14 +297,13 @@ class Tr2RenderContextAL Tr2RenderContextEnum::Topology m_topology; TrinityALImpl::Tr2DrawUPHelper m_drawUPHelper; -private: +private: int32_t m_uavBarriersDisabledCounter; std::vector m_barriers; Tr2RenderContextAL( const Tr2RenderContextAL& ) /* = delete */; Tr2RenderContextAL& operator=( const Tr2RenderContextAL& ) /* = delete */; - }; #endif diff --git a/trinityal/dx12/Tr2ResourceHelper.cpp b/trinityal/dx12/Tr2ResourceHelper.cpp index 070d64de9..f4dc21694 100644 --- a/trinityal/dx12/Tr2ResourceHelper.cpp +++ b/trinityal/dx12/Tr2ResourceHelper.cpp @@ -11,43 +11,43 @@ namespace TrinityALImpl { - Tr2ResourceHelper::Tr2ResourceHelper() : - m_size( 0 ), - m_defaultState( D3D12_RESOURCE_STATE_COMMON ), - m_strategy( STATIC ), - m_gpuResource(), - m_mapped(), - m_requiresImmediateBarriers( false ) - { - } +Tr2ResourceHelper::Tr2ResourceHelper() : + m_size( 0 ), + m_defaultState( D3D12_RESOURCE_STATE_COMMON ), + m_strategy( STATIC ), + m_gpuResource(), + m_mapped(), + m_requiresImmediateBarriers( false ) +{ +} - ALResult Tr2ResourceHelper::Create( Strategy strategy, size_t size, D3D12_RESOURCE_FLAGS resourceFlags, D3D12_RESOURCE_STATES state, bool requiresImmediateBarriers, uint32_t initialDataCount, const D3D12_SUBRESOURCE_DATA* initialData, Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2ResourceHelper::Create( Strategy strategy, size_t size, D3D12_RESOURCE_FLAGS resourceFlags, D3D12_RESOURCE_STATES state, bool requiresImmediateBarriers, uint32_t initialDataCount, const D3D12_SUBRESOURCE_DATA* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( strategy != DYNAMIC ) { - if( strategy != DYNAMIC ) + CComPtr buffer, scratch; + auto heap = HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + auto resourceDesc = BufferDesc( size, resourceFlags ); + auto initialState = initialDataCount ? D3D12_RESOURCE_STATE_COPY_DEST : state; + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &resourceDesc, + initialState, + nullptr, + IID_PPV_ARGS( &buffer ) ) ); + if( initialDataCount ) { - CComPtr buffer, scratch; - auto heap = HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); - auto resourceDesc = BufferDesc( size, resourceFlags ); - auto initialState = initialDataCount ? D3D12_RESOURCE_STATE_COPY_DEST : state; + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto scratchDesc = BufferDesc( size ); CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, + &scratchHeap, D3D12_HEAP_FLAG_NONE, - &resourceDesc, - initialState, + &scratchDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, - IID_PPV_ARGS( &buffer ) ) ); - if( initialDataCount ) - { - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto scratchDesc = BufferDesc( size ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); - if( !UpdateSubresources( + IID_PPV_ARGS( &scratch ) ) ); + if( !UpdateSubresources( renderContext.m_commandList, buffer, scratch, @@ -55,235 +55,213 @@ namespace TrinityALImpl 0, initialDataCount, initialData ) ) + { + return E_FAIL; + } + if( state != initialState ) + { + renderContext.ResourceBarrierDx12( Transition( buffer, initialState, state ) ); + if( requiresImmediateBarriers ) { - return E_FAIL; - } - if( state != initialState ) - { - renderContext.ResourceBarrierDx12( Transition( buffer, initialState, state ) ); - if( requiresImmediateBarriers ) - { - renderContext.FlushBarriersDx12( buffer ); - } - } - if( strategy == STATIC ) - { - RELEASE_LATER( &renderContext, scratch ); - } - else - { - Resource r = { scratch, renderContext.GetRecordingFrameNumber(), nullptr, 0 }; - D3D12_RANGE readRange = { 0, 0 }; - CR_RETURN_HR( scratch->Map( 0, &readRange, &r.cpuAddress ) ); - - m_resources.push_back( r ); + renderContext.FlushBarriersDx12( buffer ); } } - m_gpuResource.resource = buffer; - m_gpuResource.frameIndex = renderContext.GetRecordingFrameNumber(); - m_gpuResource.cpuAddress = nullptr; - m_gpuResource.gpuAddress = buffer->GetGPUVirtualAddress(); - } - else - { - CComPtr buffer; - auto heap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto resourceDesc = BufferDesc( size, resourceFlags ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, - D3D12_HEAP_FLAG_NONE, - &resourceDesc, - state, - nullptr, - IID_PPV_ARGS( &buffer ) ) ); - Resource r = { buffer, renderContext.GetRecordingFrameNumber(), nullptr, buffer->GetGPUVirtualAddress() }; - D3D12_RANGE readRange = { 0, 0 }; - CR_RETURN_HR( buffer->Map( 0, &readRange, &r.cpuAddress ) ); - if( initialDataCount ) + if( strategy == STATIC ) { - memcpy( r.cpuAddress, initialData[0].pData, size ); + RELEASE_LATER( &renderContext, scratch ); } - m_resources.push_back( r ); - m_gpuResource = r; - } - m_size = size; - m_defaultState = state; - m_strategy = strategy; - m_requiresImmediateBarriers = requiresImmediateBarriers; - return S_OK; - } + else + { + Resource r = { scratch, renderContext.GetRecordingFrameNumber(), nullptr, 0 }; + D3D12_RANGE readRange = { 0, 0 }; + CR_RETURN_HR( scratch->Map( 0, &readRange, &r.cpuAddress ) ); - void Tr2ResourceHelper::Destroy( Tr2PrimaryRenderContextAL& renderContext ) - { - if( m_gpuResource.resource ) - { - RELEASE_LATER( &renderContext, m_gpuResource.resource ); - m_gpuResource = Resource(); - } - for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) - { - RELEASE_LATER( &renderContext, it->resource ); + m_resources.push_back( r ); + } } - m_resources.clear(); + m_gpuResource.resource = buffer; + m_gpuResource.frameIndex = renderContext.GetRecordingFrameNumber(); + m_gpuResource.cpuAddress = nullptr; + m_gpuResource.gpuAddress = buffer->GetGPUVirtualAddress(); } - - ALResult Tr2ResourceHelper::CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext, size_t size) + else { CComPtr buffer; - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto scratchDesc = BufferDesc( size ); + auto heap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto resourceDesc = BufferDesc( size, resourceFlags ); CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &scratchHeap, + &heap, D3D12_HEAP_FLAG_NONE, - &scratchDesc, - m_strategy == DYNAMIC ? m_defaultState : D3D12_RESOURCE_STATE_GENERIC_READ, + &resourceDesc, + state, nullptr, IID_PPV_ARGS( &buffer ) ) ); - + Resource r = { buffer, renderContext.GetRecordingFrameNumber(), nullptr, buffer->GetGPUVirtualAddress() }; D3D12_RANGE readRange = { 0, 0 }; - CR_RETURN_HR( buffer->Map( 0, &readRange, &resource.cpuAddress ) ); - resource.resource = buffer; - resource.frameIndex = renderContext.GetRecordingFrameNumber(); - resource.gpuAddress = buffer->GetGPUVirtualAddress(); - if( !m_name.empty() ) + CR_RETURN_HR( buffer->Map( 0, &readRange, &r.cpuAddress ) ); + if( initialDataCount ) { - SetDebugName( buffer, m_name.c_str() ); + memcpy( r.cpuAddress, initialData[0].pData, size ); } - return S_OK; + m_resources.push_back( r ); + m_gpuResource = r; + } + m_size = size; + m_defaultState = state; + m_strategy = strategy; + m_requiresImmediateBarriers = requiresImmediateBarriers; + return S_OK; +} + +void Tr2ResourceHelper::Destroy( Tr2PrimaryRenderContextAL& renderContext ) +{ + if( m_gpuResource.resource ) + { + RELEASE_LATER( &renderContext, m_gpuResource.resource ); + m_gpuResource = Resource(); + } + for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) + { + RELEASE_LATER( &renderContext, it->resource ); + } + m_resources.clear(); +} + +ALResult Tr2ResourceHelper::CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext, size_t size ) +{ + CComPtr buffer; + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto scratchDesc = BufferDesc( size ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + m_strategy == DYNAMIC ? m_defaultState : D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS( &buffer ) ) ); + + D3D12_RANGE readRange = { 0, 0 }; + CR_RETURN_HR( buffer->Map( 0, &readRange, &resource.cpuAddress ) ); + resource.resource = buffer; + resource.frameIndex = renderContext.GetRecordingFrameNumber(); + resource.gpuAddress = buffer->GetGPUVirtualAddress(); + if( !m_name.empty() ) + { + SetDebugName( buffer, m_name.c_str() ); } + return S_OK; +} - ALResult Tr2ResourceHelper::MapForWriting( void*& data, Tr2LockType::Type lockType, Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2ResourceHelper::MapForWriting( void*& data, Tr2LockType::Type lockType, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( lockType == Tr2LockType::NON_SYNCHRONIZED ) { - if( lockType == Tr2LockType::NON_SYNCHRONIZED ) + if( m_strategy == DYNAMIC ) { - if( m_strategy == DYNAMIC ) - { - for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) - { - if( it->resource == m_gpuResource.resource ) - { - it->frameIndex = renderContext.GetRecordingFrameNumber(); - break; - } - } - m_mapped = m_gpuResource; - data = m_mapped.cpuAddress; - return S_OK; - } - else + for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) { - if( m_resources.empty() ) + if( it->resource == m_gpuResource.resource ) { - FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); - m_resources.push_back( m_mapped ); + it->frameIndex = renderContext.GetRecordingFrameNumber(); + break; } - m_mapped = m_resources.front(); - data = m_mapped.cpuAddress; - return S_OK; } - } - if( m_strategy == STATIC ) - { - FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); + m_mapped = m_gpuResource; data = m_mapped.cpuAddress; return S_OK; } else { - auto completed = renderContext.GetRenderedFrameNumber(); - - for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) + if( m_resources.empty() ) { - if( completed >= it->frameIndex ) - { - it->frameIndex = renderContext.GetRecordingFrameNumber(); - m_mapped = *it; - data = m_mapped.cpuAddress; - return S_OK; - } + FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); + m_resources.push_back( m_mapped ); } - - FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); - m_resources.push_back( m_mapped ); + m_mapped = m_resources.front(); data = m_mapped.cpuAddress; return S_OK; } } - - void Tr2ResourceHelper::UnmapForWriting( Tr2PrimaryRenderContextAL& renderContext ) + if( m_strategy == STATIC ) { - if( !m_mapped.resource ) - { - return; - } - if( m_strategy == DYNAMIC ) - { - m_gpuResource = m_mapped; - } - else - { - auto barrier = Transition( m_gpuResource.resource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ); - renderContext.ResourceBarrierDx12( barrier ); - renderContext.FlushBarriersDx12( m_gpuResource.resource ); - - renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, 0, m_mapped.resource, 0, m_size ); - - std::swap( barrier.Transition.StateAfter, barrier.Transition.StateBefore ); - renderContext.ResourceBarrierDx12( barrier ); - if( m_requiresImmediateBarriers ) - { - renderContext.FlushBarriersDx12( m_gpuResource.resource ); - } + FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); + data = m_mapped.cpuAddress; + return S_OK; + } + else + { + auto completed = renderContext.GetRenderedFrameNumber(); - if( m_strategy == STATIC ) + for( auto it = begin( m_resources ); it != end( m_resources ); ++it ) + { + if( completed >= it->frameIndex ) { - RELEASE_LATER( renderContext.m_ownerDevice, m_mapped.resource ); + it->frameIndex = renderContext.GetRecordingFrameNumber(); + m_mapped = *it; + data = m_mapped.cpuAddress; + return S_OK; } } - m_mapped = Resource(); + + FORWARD_HR( CreateScratch( m_mapped, renderContext ) ); + m_resources.push_back( m_mapped ); + data = m_mapped.cpuAddress; + return S_OK; } +} - ALResult Tr2ResourceHelper::UpdateBuffer( Tr2LockType::Type lockType, uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ) +void Tr2ResourceHelper::UnmapForWriting( Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !m_mapped.resource ) { - if( m_strategy == DYNAMIC ) - { - return E_FAIL; - } - - if( lockType == Tr2LockType::SYNCHRONIZED && m_strategy == STATIC ) - { + return; + } + if( m_strategy == DYNAMIC ) + { + m_gpuResource = m_mapped; + } + else + { + auto barrier = Transition( m_gpuResource.resource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ); + renderContext.ResourceBarrierDx12( barrier ); + renderContext.FlushBarriersDx12( m_gpuResource.resource ); - FORWARD_HR( CreateScratch( m_mapped, *renderContext.m_ownerDevice, size ) ); - memcpy( m_mapped.cpuAddress, data, size ); + renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, 0, m_mapped.resource, 0, m_size ); - - auto barrier = Transition( m_gpuResource.resource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ); - renderContext.ResourceBarrierDx12( barrier ); + std::swap( barrier.Transition.StateAfter, barrier.Transition.StateBefore ); + renderContext.ResourceBarrierDx12( barrier ); + if( m_requiresImmediateBarriers ) + { renderContext.FlushBarriersDx12( m_gpuResource.resource ); + } - renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, offset, m_mapped.resource, 0, size ); + if( m_strategy == STATIC ) + { + RELEASE_LATER( renderContext.m_ownerDevice, m_mapped.resource ); + } + } + m_mapped = Resource(); +} - std::swap( barrier.Transition.StateAfter, barrier.Transition.StateBefore ); - renderContext.ResourceBarrierDx12( barrier ); - if( m_requiresImmediateBarriers ) - { - renderContext.FlushBarriersDx12( m_gpuResource.resource ); - } +ALResult Tr2ResourceHelper::UpdateBuffer( Tr2LockType::Type lockType, uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ) +{ + if( m_strategy == DYNAMIC ) + { + return E_FAIL; + } - RELEASE_LATER( renderContext.m_ownerDevice, m_mapped.resource ); + if( lockType == Tr2LockType::SYNCHRONIZED && m_strategy == STATIC ) + { - return S_OK; - } + FORWARD_HR( CreateScratch( m_mapped, *renderContext.m_ownerDevice, size ) ); + memcpy( m_mapped.cpuAddress, data, size ); - void* dst = nullptr; - FORWARD_HR( MapForWriting( dst, lockType, *renderContext.m_ownerDevice ) ); - memcpy( static_cast( dst ) + offset, data, size ); auto barrier = Transition( m_gpuResource.resource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ); renderContext.ResourceBarrierDx12( barrier ); renderContext.FlushBarriersDx12( m_gpuResource.resource ); - renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, offset, m_mapped.resource, offset, size ); + renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, offset, m_mapped.resource, 0, size ); std::swap( barrier.Transition.StateAfter, barrier.Transition.StateBefore ); renderContext.ResourceBarrierDx12( barrier ); @@ -291,37 +269,59 @@ namespace TrinityALImpl { renderContext.FlushBarriersDx12( m_gpuResource.resource ); } - m_mapped = Resource(); + + RELEASE_LATER( renderContext.m_ownerDevice, m_mapped.resource ); + return S_OK; } - ID3D12Resource* Tr2ResourceHelper::GetResource() const - { - return m_gpuResource.resource; - } + void* dst = nullptr; + FORWARD_HR( MapForWriting( dst, lockType, *renderContext.m_ownerDevice ) ); + memcpy( static_cast( dst ) + offset, data, size ); + + auto barrier = Transition( m_gpuResource.resource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ); + renderContext.ResourceBarrierDx12( barrier ); + renderContext.FlushBarriersDx12( m_gpuResource.resource ); - D3D12_GPU_VIRTUAL_ADDRESS Tr2ResourceHelper::GetGpuView() const + renderContext.m_commandList->CopyBufferRegion( m_gpuResource.resource, offset, m_mapped.resource, offset, size ); + + std::swap( barrier.Transition.StateAfter, barrier.Transition.StateBefore ); + renderContext.ResourceBarrierDx12( barrier ); + if( m_requiresImmediateBarriers ) { - return m_gpuResource.gpuAddress; + renderContext.FlushBarriersDx12( m_gpuResource.resource ); } + m_mapped = Resource(); + return S_OK; +} + +ID3D12Resource* Tr2ResourceHelper::GetResource() const +{ + return m_gpuResource.resource; +} - void Tr2ResourceHelper::SetName( const char* name ) +D3D12_GPU_VIRTUAL_ADDRESS Tr2ResourceHelper::GetGpuView() const +{ + return m_gpuResource.gpuAddress; +} + +void Tr2ResourceHelper::SetName( const char* name ) +{ + m_name = name; + for( auto& r : m_resources ) { - m_name = name; - for( auto& r : m_resources ) - { - SetDebugName( r.resource, name ); - } - if( m_gpuResource.resource ) - { - SetDebugName( m_gpuResource.resource, name ); - } + SetDebugName( r.resource, name ); } - - const std::string& Tr2ResourceHelper::GetName() const + if( m_gpuResource.resource ) { - return m_name; + SetDebugName( m_gpuResource.resource, name ); } } +const std::string& Tr2ResourceHelper::GetName() const +{ + return m_name; +} +} + #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ResourceHelper.h b/trinityal/dx12/Tr2ResourceHelper.h index 0f2cdccf6..d7cbc7cf1 100644 --- a/trinityal/dx12/Tr2ResourceHelper.h +++ b/trinityal/dx12/Tr2ResourceHelper.h @@ -12,55 +12,56 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2ResourceHelper +class Tr2ResourceHelper +{ +public: + enum Strategy { - public: - enum Strategy - { - STATIC, - SEMI_DYNAMIC, - DYNAMIC, - }; - - Tr2ResourceHelper(); + STATIC, + SEMI_DYNAMIC, + DYNAMIC, + }; - ALResult Create( Strategy strategy, size_t size, D3D12_RESOURCE_FLAGS resourceFlags, D3D12_RESOURCE_STATES state, bool requiresImmediateBarriers, uint32_t initialDataCount, const D3D12_SUBRESOURCE_DATA* initialData, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy( Tr2PrimaryRenderContextAL& renderContext ); + Tr2ResourceHelper(); - ALResult MapForWriting( void*& data, Tr2LockType::Type lockType, Tr2PrimaryRenderContextAL& renderContext ); - void UnmapForWriting( Tr2PrimaryRenderContextAL& renderContext ); + ALResult Create( Strategy strategy, size_t size, D3D12_RESOURCE_FLAGS resourceFlags, D3D12_RESOURCE_STATES state, bool requiresImmediateBarriers, uint32_t initialDataCount, const D3D12_SUBRESOURCE_DATA* initialData, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy( Tr2PrimaryRenderContextAL& renderContext ); - ALResult UpdateBuffer( Tr2LockType::Type lockType, uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( void*& data, Tr2LockType::Type lockType, Tr2PrimaryRenderContextAL& renderContext ); + void UnmapForWriting( Tr2PrimaryRenderContextAL& renderContext ); - ID3D12Resource* GetResource() const; - D3D12_GPU_VIRTUAL_ADDRESS GetGpuView() const; + ALResult UpdateBuffer( Tr2LockType::Type lockType, uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); - void SetName( const char* name ); - const std::string& GetName() const; - private: - struct Resource - { - CComPtr resource; - uint64_t frameIndex; - void* cpuAddress; - D3D12_GPU_VIRTUAL_ADDRESS gpuAddress; - }; + ID3D12Resource* GetResource() const; + D3D12_GPU_VIRTUAL_ADDRESS GetGpuView() const; - ALResult CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext ) - { - return CreateScratch( resource, renderContext, m_size ); - } - ALResult CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext, size_t size ); + void SetName( const char* name ); + const std::string& GetName() const; - std::vector m_resources; - Resource m_gpuResource; - Resource m_mapped; - size_t m_size; - D3D12_RESOURCE_STATES m_defaultState; - Strategy m_strategy; - std::string m_name; - bool m_requiresImmediateBarriers; +private: + struct Resource + { + CComPtr resource; + uint64_t frameIndex; + void* cpuAddress; + D3D12_GPU_VIRTUAL_ADDRESS gpuAddress; }; + + ALResult CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext ) + { + return CreateScratch( resource, renderContext, m_size ); } + ALResult CreateScratch( Resource& resource, Tr2PrimaryRenderContextAL& renderContext, size_t size ); + + std::vector m_resources; + Resource m_gpuResource; + Resource m_mapped; + size_t m_size; + D3D12_RESOURCE_STATES m_defaultState; + Strategy m_strategy; + std::string m_name; + bool m_requiresImmediateBarriers; +}; +} #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ResourceSetALDx12.cpp b/trinityal/dx12/Tr2ResourceSetALDx12.cpp index 7e92c7479..08fc52f84 100644 --- a/trinityal/dx12/Tr2ResourceSetALDx12.cpp +++ b/trinityal/dx12/Tr2ResourceSetALDx12.cpp @@ -18,267 +18,266 @@ using namespace Tr2RenderContextEnum; namespace { - D3D12_CPU_DESCRIPTOR_HANDLE operator+( const D3D12_CPU_DESCRIPTOR_HANDLE& handle, uint32_t offset ) - { - D3D12_CPU_DESCRIPTOR_HANDLE result = { handle.ptr + offset }; - return result; - } +D3D12_CPU_DESCRIPTOR_HANDLE operator+( const D3D12_CPU_DESCRIPTOR_HANDLE& handle, uint32_t offset ) +{ + D3D12_CPU_DESCRIPTOR_HANDLE result = { handle.ptr + offset }; + return result; +} } namespace TrinityALImpl { - Tr2ResourceSetAL::Tr2ResourceSetAL() - :m_owner( nullptr ), - m_samplerCount( 0 ), - m_resourceCount( 0 ), - m_srvMask( 0 ), - m_uavMask( 0 ) +Tr2ResourceSetAL::Tr2ResourceSetAL() : + m_owner( nullptr ), + m_samplerCount( 0 ), + m_resourceCount( 0 ), + m_srvMask( 0 ), + m_uavMask( 0 ) +{ +} + +Tr2ResourceSetAL::~Tr2ResourceSetAL() +{ + Destroy(); +} + +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { + return E_INVALIDARG; } - - Tr2ResourceSetAL::~Tr2ResourceSetAL() + if( !program.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); + return Create( description, program.m_program->m_rootSignature, renderContext, program.m_program->m_name.c_str() ); +} - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !program.IsValid() ) - { - return E_INVALIDARG; - } +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - return Create( description, program.m_program->m_rootSignature, renderContext, program.m_program->m_name.c_str() ); + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; } - - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ) + if( !pipeline.IsValid() ) { - Destroy(); + return E_INVALIDARG; + } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !pipeline.IsValid() ) - { - return E_INVALIDARG; - } + return Create( description, pipeline.TrinityALImpl_GetObject()->GetGlobalRootSignature(), renderContext, "RtPipeline" ); +} - return Create( description, pipeline.TrinityALImpl_GetObject()->GetGlobalRootSignature(), renderContext, "RtPipeline" ); +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const Tr2RootSignatureAL& rootSignature, Tr2PrimaryRenderContextAL& renderContext, const char* shaderName ) +{ + if( rootSignature.m_registerMap != description.m_registerMap ) + { + return E_INVALIDARG; } - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const Tr2RootSignatureAL& rootSignature, Tr2PrimaryRenderContextAL& renderContext, const char* shaderName ) - { - if( rootSignature.m_registerMap != description.m_registerMap ) + std::vector transitioned; + + auto AddTransition = [&]( ID3D12Resource* res, D3D12_RESOURCE_STATES defaultState, D3D12_RESOURCE_STATES expectedState ) { + // TODO: verify state + if( ( defaultState & expectedState ) == 0 && defaultState != D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE ) { - return E_INVALIDARG; + auto found = std::find( begin( transitioned ), end( transitioned ), res ); + if( found == transitioned.end() ) + { + m_inTransitions.push_back( Transition( res, defaultState, expectedState ) ); + m_outTransitions.push_back( Transition( res, expectedState, defaultState ) ); + transitioned.push_back( res ); + } } + m_usedResources.push_back( res ); + }; - std::vector transitioned; - - auto AddTransition = [&]( ID3D12Resource* res, D3D12_RESOURCE_STATES defaultState, D3D12_RESOURCE_STATES expectedState ) { - // TODO: verify state - if( ( defaultState & expectedState ) == 0 && defaultState != D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE ) + for( auto it = begin( rootSignature.m_srvRegisters ); it != end( rootSignature.m_srvRegisters ); ++it ) + { + auto& reg = *it; + auto& resource = description.m_srv[description.m_registerMap.srvs[reg.stage][reg.index]]; + auto stateFlag = reg.stage == PIXEL_SHADER ? D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE : D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + m_resourceCount = std::max( reg.parameter + 1, m_resourceCount ); + m_srvMask |= 1 << reg.parameter; + switch( resource.type ) + { + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + if( resource.texture.IsValid() && it->registerType >= Tr2ShaderRegisterAL::SRV_TEXTURE1D ) { - auto found = std::find( begin( transitioned ), end( transitioned ), res ); - if( found == transitioned.end() ) - { - m_inTransitions.push_back( Transition( res, defaultState, expectedState ) ); - m_outTransitions.push_back( Transition( res, expectedState, defaultState ) ); - transitioned.push_back( res ); - } + m_srv[reg.parameter] = resource.texture.m_texture->m_view[resource.colorSpace]; + } + else + { + m_srv[reg.parameter] = nullptr; + } + if( !m_srv[reg.parameter] ) + { + m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); + } + else + { + AddTransition( resource.texture.m_texture->GetResourceDx12(), resource.texture.m_texture->m_defaultState, stateFlag ); + } + break; + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + if( resource.buffer.IsValid() && it->registerType <= Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER ) + { + m_srv[reg.parameter] = resource.buffer.m_buffer->m_srv; + } + else + { + m_srv[reg.parameter] = nullptr; + } + if( !m_srv[reg.parameter] ) + { + m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); + } + else + { + AddTransition( resource.buffer.m_buffer->GetGpuResource(), resource.buffer.m_buffer->m_defaultState, stateFlag ); } - m_usedResources.push_back( res ); - }; + break; + case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: + m_srv[reg.parameter] = renderContext.GetSrvHeapView(); + break; + default: + m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); + break; + } + } - for( auto it = begin( rootSignature.m_srvRegisters ); it != end( rootSignature.m_srvRegisters ); ++it ) + for( auto it = begin( rootSignature.m_uavRegisters ); it != end( rootSignature.m_uavRegisters ); ++it ) + { + auto& reg = *it; + auto& resource = description.m_uav[description.m_registerMap.uavs[reg.stage][reg.index]]; + m_resourceCount = std::max( reg.parameter + 1, m_resourceCount ); + m_uavMask |= 1 << reg.parameter; + switch( resource.type ) { - auto& reg = *it; - auto& resource = description.m_srv[description.m_registerMap.srvs[reg.stage][reg.index]]; - auto stateFlag = reg.stage == PIXEL_SHADER ? D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE : D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; - m_resourceCount = std::max( reg.parameter + 1, m_resourceCount ); - m_srvMask |= 1 << reg.parameter; - switch (resource.type) + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + if( resource.texture.IsValid() ) { - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - if( resource.texture.IsValid() && it->registerType >= Tr2ShaderRegisterAL::SRV_TEXTURE1D ) + if( resource.texture.IsValid() && it->registerType >= Tr2ShaderRegisterAL::UAV_TEXTURE1D ) { - m_srv[reg.parameter] = resource.texture.m_texture->m_view[resource.colorSpace]; + m_uav[reg.parameter] = resource.texture.m_texture->m_uav[resource.mip]; } else { - m_srv[reg.parameter] = nullptr; + m_uav[reg.parameter] = nullptr; } - if( !m_srv[reg.parameter] ) + if( !m_uav[reg.parameter] ) { - m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); + m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); } else { - AddTransition( resource.texture.m_texture->GetResourceDx12(), resource.texture.m_texture->m_defaultState, stateFlag ); + AddTransition( resource.texture.m_texture->GetResourceDx12(), resource.texture.m_texture->m_defaultState, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); } - break; - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - if( resource.buffer.IsValid() && it->registerType <= Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER ) + } + break; + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + if( resource.buffer.IsValid() ) + { + if( resource.buffer.IsValid() && it->registerType <= Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER ) { - m_srv[reg.parameter] = resource.buffer.m_buffer->m_srv; + m_uav[reg.parameter] = resource.buffer.m_buffer->m_uav; } else { - m_srv[reg.parameter] = nullptr; + m_uav[reg.parameter] = nullptr; } - if( !m_srv[reg.parameter] ) + if( !m_uav[reg.parameter] ) { - m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); + m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); } else { - AddTransition( resource.buffer.m_buffer->GetGpuResource(), resource.buffer.m_buffer->m_defaultState, stateFlag ); - } - break; - case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: - m_srv[reg.parameter] = renderContext.GetSrvHeapView(); - break; - default: - m_srv[reg.parameter] = renderContext.GetNullSrvDx12( it->registerType ); - break; - } - } - - for (auto it = begin(rootSignature.m_uavRegisters); it != end( rootSignature.m_uavRegisters); ++it) - { - auto& reg = *it; - auto& resource = description.m_uav[description.m_registerMap.uavs[reg.stage][reg.index]]; - m_resourceCount = std::max( reg.parameter + 1, m_resourceCount ); - m_uavMask |= 1 << reg.parameter; - switch( resource.type ) - { - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - if (resource.texture.IsValid()) - { - if( resource.texture.IsValid() && it->registerType >= Tr2ShaderRegisterAL::UAV_TEXTURE1D ) - { - m_uav[reg.parameter] = resource.texture.m_texture->m_uav[resource.mip]; - } - else - { - m_uav[reg.parameter] = nullptr; - } - if( !m_uav[reg.parameter] ) - { - m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); - } - else - { - AddTransition( resource.texture.m_texture->GetResourceDx12(), resource.texture.m_texture->m_defaultState, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); - } + AddTransition( resource.buffer.m_buffer->GetGpuResource(), resource.buffer.m_buffer->m_defaultState, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); } - break; - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - if (resource.buffer.IsValid()) - { - if( resource.buffer.IsValid() && it->registerType <= Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER ) - { - m_uav[reg.parameter] = resource.buffer.m_buffer->m_uav; - } - else - { - m_uav[reg.parameter] = nullptr; - } - if( !m_uav[reg.parameter] ) - { - m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); - } - else - { - AddTransition( resource.buffer.m_buffer->GetGpuResource(), resource.buffer.m_buffer->m_defaultState, D3D12_RESOURCE_STATE_UNORDERED_ACCESS ); - } - } - break; - case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: - m_uav[reg.parameter] = renderContext.GetUavHeapView(); - break; - default: - CCP_AL_LOGWARN("Missing UAV resource in resource set for register %u, stage %u, shader '%s'", reg.index, reg.stage, shaderName); - m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); - break; } - + break; + case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: + m_uav[reg.parameter] = renderContext.GetUavHeapView(); + break; + default: + CCP_AL_LOGWARN( "Missing UAV resource in resource set for register %u, stage %u, shader '%s'", reg.index, reg.stage, shaderName ); + m_uav[reg.parameter] = renderContext.GetNullUavDx12( it->registerType ); + break; } - - for (auto it = begin(rootSignature.m_samplerRegisters); it != end( rootSignature.m_samplerRegisters); ++it) - { - auto& reg = *it; - auto& sampler = description.m_samplers[description.m_registerMap.samplers[reg.stage][reg.index]]; - switch( sampler.type ) - { - case Tr2ResourceSetDescriptionAL::Sampler::SAMPLER: - m_sampler[reg.parameter] = sampler.sampler.m_sampler->m_samplerState; - break; - case Tr2ResourceSetDescriptionAL::Sampler::HEAP_VIEW: - m_sampler[reg.parameter] = renderContext.GetSamplerHeapView(); - break; - default: - m_sampler[reg.parameter] = renderContext.GetNullSamplerDx12(); - break; - } - m_samplerCount = std::max( reg.parameter + 1, m_samplerCount ); - } - - m_owner = &renderContext; - - return S_OK; } - void Tr2ResourceSetAL::Destroy() + for( auto it = begin( rootSignature.m_samplerRegisters ); it != end( rootSignature.m_samplerRegisters ); ++it ) { - for( uint32_t idx = 0; idx < m_resourceCount; ++idx ) - { - m_srv[idx] = nullptr; - m_uav[idx] = nullptr; - } - m_resourceCount = 0; - m_srvMask = 0; - m_uavMask = 0; - for( uint32_t idx = 0; idx < m_samplerCount; ++idx ) + auto& reg = *it; + auto& sampler = description.m_samplers[description.m_registerMap.samplers[reg.stage][reg.index]]; + switch( sampler.type ) { - m_sampler[idx] = nullptr; + case Tr2ResourceSetDescriptionAL::Sampler::SAMPLER: + m_sampler[reg.parameter] = sampler.sampler.m_sampler->m_samplerState; + break; + case Tr2ResourceSetDescriptionAL::Sampler::HEAP_VIEW: + m_sampler[reg.parameter] = renderContext.GetSamplerHeapView(); + break; + default: + m_sampler[reg.parameter] = renderContext.GetNullSamplerDx12(); + break; } - m_samplerCount = 0; - - m_owner = nullptr; - m_inTransitions.clear(); - m_outTransitions.clear(); - m_usedResources.clear(); + m_samplerCount = std::max( reg.parameter + 1, m_samplerCount ); } - bool Tr2ResourceSetAL::IsValid() const - { - return m_owner != nullptr; - } + m_owner = &renderContext; - Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } + return S_OK; +} - void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +void Tr2ResourceSetAL::Destroy() +{ + for( uint32_t idx = 0; idx < m_resourceCount; ++idx ) { - description["type"] = "Tr2ResourceSetAL"; - description["name"] = m_name; + m_srv[idx] = nullptr; + m_uav[idx] = nullptr; } - - ALResult Tr2ResourceSetAL::SetName( const char* name ) + m_resourceCount = 0; + m_srvMask = 0; + m_uavMask = 0; + for( uint32_t idx = 0; idx < m_samplerCount; ++idx ) { - m_name = name; - return S_OK; + m_sampler[idx] = nullptr; } + m_samplerCount = 0; + + m_owner = nullptr; + m_inTransitions.clear(); + m_outTransitions.clear(); + m_usedResources.clear(); +} + +bool Tr2ResourceSetAL::IsValid() const +{ + return m_owner != nullptr; +} + +Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ResourceSetAL"; + description["name"] = m_name; +} + +ALResult Tr2ResourceSetAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ResourceSetALDx12.h b/trinityal/dx12/Tr2ResourceSetALDx12.h index 811a81a10..f20d5d227 100644 --- a/trinityal/dx12/Tr2ResourceSetALDx12.h +++ b/trinityal/dx12/Tr2ResourceSetALDx12.h @@ -9,41 +9,41 @@ namespace TrinityALImpl { - struct Tr2RootSignatureAL; - class Tr2ResourceSetAL: public Tr2DeviceResourceAL - { - public: - Tr2ResourceSetAL(); - ~Tr2ResourceSetAL(); - - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const Tr2RootSignatureAL& signature, Tr2PrimaryRenderContextAL& renderContext, const char* shaderName ); - std::shared_ptr m_srv[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - std::shared_ptr m_uav[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - std::shared_ptr m_sampler[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - uint32_t m_samplerCount; - uint32_t m_resourceCount; - uint32_t m_srvMask; - uint32_t m_uavMask; - Tr2PrimaryRenderContextAL* m_owner; - - std::vector m_inTransitions; - std::vector m_outTransitions; - std::vector m_usedResources; - std::string m_name; - - friend class ::Tr2RenderContextAL; - }; +struct Tr2RootSignatureAL; +class Tr2ResourceSetAL : public Tr2DeviceResourceAL +{ +public: + Tr2ResourceSetAL(); + ~Tr2ResourceSetAL(); + + ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); + ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + ALResult Create( const Tr2ResourceSetDescriptionAL& description, const Tr2RootSignatureAL& signature, Tr2PrimaryRenderContextAL& renderContext, const char* shaderName ); + std::shared_ptr m_srv[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + std::shared_ptr m_uav[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + std::shared_ptr m_sampler[Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + uint32_t m_samplerCount; + uint32_t m_resourceCount; + uint32_t m_srvMask; + uint32_t m_uavMask; + Tr2PrimaryRenderContextAL* m_owner; + + std::vector m_inTransitions; + std::vector m_outTransitions; + std::vector m_usedResources; + std::string m_name; + + friend class ::Tr2RenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.cpp b/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.cpp index 7cb5ff93e..1f50dd409 100644 --- a/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.cpp +++ b/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.cpp @@ -76,180 +76,180 @@ void BuildRaytracingAccelerationStructure( const D3D12_BUILD_RAYTRACING_ACCELERA namespace TrinityALImpl { - Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() - :m_bufferAddress{}, - m_geometryDesc{}, - m_geometryFlags{}, - m_buildFlags{}, - m_owner( nullptr ) +Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() : + m_bufferAddress{}, + m_geometryDesc{}, + m_geometryFlags{}, + m_buildFlags{}, + m_owner( nullptr ) +{ +} + +Tr2RtBottomLevelAccelerationStructureAL::~Tr2RtBottomLevelAccelerationStructureAL() +{ + Destroy(); +} + +ALResult Tr2RtBottomLevelAccelerationStructureAL::Create( const Tr2RtGeometryAL& geometry, const Tr2RtGeometryAL& capacity, Tr2RtBlasGeometryFlags::Type geometryFlags, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) { + return E_INVALIDCALL; } - - Tr2RtBottomLevelAccelerationStructureAL::~Tr2RtBottomLevelAccelerationStructureAL() + if( !geometry.positions.IsValid() || !HasFlag( geometry.positions.m_vertexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - Destroy(); + return E_INVALIDARG; } - - ALResult Tr2RtBottomLevelAccelerationStructureAL::Create( const Tr2RtGeometryAL& geometry, const Tr2RtGeometryAL& capacity, Tr2RtBlasGeometryFlags::Type geometryFlags, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) + if( !geometry.indices.IsValid() || !HasFlag( geometry.indices.m_indexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) - { - return E_INVALIDCALL; - } - if( !geometry.positions.IsValid() || !HasFlag( geometry.positions.m_vertexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDARG; - } - if( !geometry.indices.IsValid() || !HasFlag( geometry.indices.m_indexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDARG; - } - if( !renderContext.m_commandList4 ) - { - return E_INVALIDCALL; - } - - // gather geometry info for buffer - D3D12_RAYTRACING_GEOMETRY_DESC geometryDesc = CreateGeometryDesc( capacity, geometryFlags ); - - // size requirements for scratch and acceleration structure buffers - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS prebuildDesc = CreateInputsDesc( &geometryDesc, buildFlags ); - - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO preBuildInfo = {}; - // do some bvh optimization and return an estimate on how big the structure will be - runs on cpu - renderContext.m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &prebuildDesc, &preBuildInfo ); - - if( preBuildInfo.ResultDataMaxSizeInBytes <= 0 ) - { - return E_INVALIDCALL; - } - - // Create two buffers - // 1. Scratch buffer which is required for intermediate computation. - // 2. The result buffer which will hold the acceleration data. - CComPtr scratch; - CComPtr buffer; - - auto heap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + return E_INVALIDARG; + } + if( !renderContext.m_commandList4 ) + { + return E_INVALIDCALL; + } - // Buffer sizes need to be 256-byte-aligned - auto scratchDesc = TrinityALImpl::BufferDesc( Align( preBuildInfo.ScratchDataSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_UNORDERED_ACCESS, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); + // gather geometry info for buffer + D3D12_RAYTRACING_GEOMETRY_DESC geometryDesc = CreateGeometryDesc( capacity, geometryFlags ); - // for no compaction we use ResultDataMaxSizeInBytes - auto bufferDesc = TrinityALImpl::BufferDesc( Align( preBuildInfo.ResultDataMaxSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, - D3D12_HEAP_FLAG_NONE, - &bufferDesc, - D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, - nullptr, - IID_PPV_ARGS( &buffer ) ) ); + // size requirements for scratch and acceleration structure buffers + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS prebuildDesc = CreateInputsDesc( &geometryDesc, buildFlags ); - geometryDesc = CreateGeometryDesc( geometry, geometryFlags ); + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO preBuildInfo = {}; + // do some bvh optimization and return an estimate on how big the structure will be - runs on cpu + renderContext.m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &prebuildDesc, &preBuildInfo ); - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; - desc.Inputs = prebuildDesc; - desc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); - desc.DestAccelerationStructureData = buffer->GetGPUVirtualAddress(); + if( preBuildInfo.ResultDataMaxSizeInBytes <= 0 ) + { + return E_INVALIDCALL; + } - BuildRaytracingAccelerationStructure( desc, geometry, renderContext ); + // Create two buffers + // 1. Scratch buffer which is required for intermediate computation. + // 2. The result buffer which will hold the acceleration data. + CComPtr scratch; + CComPtr buffer; + + auto heap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + + // Buffer sizes need to be 256-byte-aligned + auto scratchDesc = TrinityALImpl::BufferDesc( Align( preBuildInfo.ScratchDataSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, + nullptr, + IID_PPV_ARGS( &scratch ) ) ); + + // for no compaction we use ResultDataMaxSizeInBytes + auto bufferDesc = TrinityALImpl::BufferDesc( Align( preBuildInfo.ResultDataMaxSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &bufferDesc, + D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE, + nullptr, + IID_PPV_ARGS( &buffer ) ) ); + + geometryDesc = CreateGeometryDesc( geometry, geometryFlags ); + + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; + desc.Inputs = prebuildDesc; + desc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + desc.DestAccelerationStructureData = buffer->GetGPUVirtualAddress(); + + BuildRaytracingAccelerationStructure( desc, geometry, renderContext ); + + m_buffer = buffer; + m_owner = &renderContext; + m_geometryDesc = geometryDesc; + m_geometryFlags = geometryFlags; + m_buildFlags = buildFlags; + if( ( buildFlags & Tr2RtBuildFlags::ALLOW_UPDATE ) != 0 ) + { + m_scratch = scratch; + } + else + { + renderContext.ReleaseLater( scratch ); + } + m_bufferAddress = m_buffer->GetGPUVirtualAddress(); - m_buffer = buffer; - m_owner = &renderContext; - m_geometryDesc = geometryDesc; - m_geometryFlags = geometryFlags; - m_buildFlags = buildFlags; - if( (buildFlags & Tr2RtBuildFlags::ALLOW_UPDATE) != 0 ) - { - m_scratch = scratch; - } - else - { - renderContext.ReleaseLater( scratch ); - } - m_bufferAddress = m_buffer->GetGPUVirtualAddress(); + return S_OK; +} - return S_OK; +ALResult Tr2RtBottomLevelAccelerationStructureAL::Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ) +{ + if( !m_scratch || !m_buffer ) + { + return E_INVALIDCALL; } - - ALResult Tr2RtBottomLevelAccelerationStructureAL::Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - if( !m_scratch || !m_buffer ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !renderContext.m_commandList4 ) - { - return E_INVALIDCALL; - } + return E_INVALIDARG; + } + if( !renderContext.m_commandList4 ) + { + return E_INVALIDCALL; + } - bool rebuild = false; + bool rebuild = false; - D3D12_RAYTRACING_GEOMETRY_DESC geometryDesc = CreateGeometryDesc( geometry, m_geometryFlags ); - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS inputs = CreateInputsDesc( &geometryDesc, m_buildFlags ); + D3D12_RAYTRACING_GEOMETRY_DESC geometryDesc = CreateGeometryDesc( geometry, m_geometryFlags ); + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS inputs = CreateInputsDesc( &geometryDesc, m_buildFlags ); - if( m_geometryDesc.Triangles.VertexBuffer.StrideInBytes != geometryDesc.Triangles.VertexBuffer.StrideInBytes || - m_geometryDesc.Triangles.VertexCount != geometryDesc.Triangles.VertexCount || - m_geometryDesc.Triangles.VertexFormat != geometryDesc.Triangles.VertexFormat || - m_geometryDesc.Triangles.IndexFormat != geometryDesc.Triangles.IndexFormat || - m_geometryDesc.Triangles.IndexCount != geometryDesc.Triangles.IndexCount ) - { + if( m_geometryDesc.Triangles.VertexBuffer.StrideInBytes != geometryDesc.Triangles.VertexBuffer.StrideInBytes || + m_geometryDesc.Triangles.VertexCount != geometryDesc.Triangles.VertexCount || + m_geometryDesc.Triangles.VertexFormat != geometryDesc.Triangles.VertexFormat || + m_geometryDesc.Triangles.IndexFormat != geometryDesc.Triangles.IndexFormat || + m_geometryDesc.Triangles.IndexCount != geometryDesc.Triangles.IndexCount ) + { - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO preBuildInfo = {}; - renderContext.GetPrimaryRenderContext().m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &inputs, &preBuildInfo ); - - if( preBuildInfo.ResultDataMaxSizeInBytes <= 0 || preBuildInfo.ScratchDataSizeInBytes > m_scratch->GetDesc().Width || preBuildInfo.ResultDataMaxSizeInBytes > m_buffer->GetDesc().Width ) - { - return E_INVALIDARG; - } - rebuild = true; - } - m_geometryDesc = geometryDesc; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO preBuildInfo = {}; + renderContext.GetPrimaryRenderContext().m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &inputs, &preBuildInfo ); - if( !rebuild ) + if( preBuildInfo.ResultDataMaxSizeInBytes <= 0 || preBuildInfo.ScratchDataSizeInBytes > m_scratch->GetDesc().Width || preBuildInfo.ResultDataMaxSizeInBytes > m_buffer->GetDesc().Width ) { - inputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE; + return E_INVALIDARG; } + rebuild = true; + } + m_geometryDesc = geometryDesc; + + if( !rebuild ) + { + inputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE; + } - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; - desc.Inputs = inputs; - desc.SourceAccelerationStructureData = rebuild ? 0 : m_buffer->GetGPUVirtualAddress(); // If this address is the same as DestAccelerationStructureData, the update is to be performed in-place. - desc.ScratchAccelerationStructureData = m_scratch->GetGPUVirtualAddress(); - desc.DestAccelerationStructureData = m_buffer->GetGPUVirtualAddress(); + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; + desc.Inputs = inputs; + desc.SourceAccelerationStructureData = rebuild ? 0 : m_buffer->GetGPUVirtualAddress(); // If this address is the same as DestAccelerationStructureData, the update is to be performed in-place. + desc.ScratchAccelerationStructureData = m_scratch->GetGPUVirtualAddress(); + desc.DestAccelerationStructureData = m_buffer->GetGPUVirtualAddress(); - BuildRaytracingAccelerationStructure( desc, geometry, renderContext ); + BuildRaytracingAccelerationStructure( desc, geometry, renderContext ); - return S_OK; - } + return S_OK; +} - ALResult Tr2RtBottomLevelAccelerationStructureAL::CompactBlas( Tr2PrimaryRenderContextAL& renderContext ) - { - /**************** COMPACTION ****************/ - - // full compaction: - // for each acceleration structure - // - // BuildRaytracingAccelerationStructure to (tempBuffer + tempOffset ) - // tempOffset += _PREBUILD_INFO.ResultDataMaxSizeInBytes - // wait for builds to finish executing - // maybe even do some rendering - // - // For each acceleration structure - // CopyRayTracingAccelerationStructure(buffer + bufferOffset, - // tempBufferLocation, _ACCELERATION_STRUCTURE_COPY_MODE_COMPACT); - // bufferOffset += _POSTBUILD_INFO_COMPACTED_SIZE - /* +ALResult Tr2RtBottomLevelAccelerationStructureAL::CompactBlas( Tr2PrimaryRenderContextAL& renderContext ) +{ + /**************** COMPACTION ****************/ + + // full compaction: + // for each acceleration structure + // + // BuildRaytracingAccelerationStructure to (tempBuffer + tempOffset ) + // tempOffset += _PREBUILD_INFO.ResultDataMaxSizeInBytes + // wait for builds to finish executing + // maybe even do some rendering + // + // For each acceleration structure + // CopyRayTracingAccelerationStructure(buffer + bufferOffset, + // tempBufferLocation, _ACCELERATION_STRUCTURE_COPY_MODE_COMPACT); + // bufferOffset += _POSTBUILD_INFO_COMPACTED_SIZE + /* D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC postBuildDesc = {}; postBuildDesc.InfoType = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE; @@ -278,50 +278,49 @@ namespace TrinityALImpl m_buffer = finalBuffer;*/ - return S_OK; - - } + return S_OK; +} - void Tr2RtBottomLevelAccelerationStructureAL::Destroy() +void Tr2RtBottomLevelAccelerationStructureAL::Destroy() +{ + if( m_owner ) { - if( m_owner ) + RELEASE_LATER( m_owner, m_buffer ); + if( m_scratch ) { - RELEASE_LATER( m_owner, m_buffer ); - if( m_scratch ) - { - RELEASE_LATER( m_owner, m_scratch ); - } - m_scratch = nullptr; - m_buffer = nullptr; - m_bufferAddress = {}; - m_geometryDesc = {}; - m_owner = nullptr; + RELEASE_LATER( m_owner, m_scratch ); } + m_scratch = nullptr; + m_buffer = nullptr; + m_bufferAddress = {}; + m_geometryDesc = {}; + m_owner = nullptr; } +} - bool Tr2RtBottomLevelAccelerationStructureAL::IsValid() const - { - return m_buffer != nullptr; - } +bool Tr2RtBottomLevelAccelerationStructureAL::IsValid() const +{ + return m_buffer != nullptr; +} - ID3D12Resource* Tr2RtBottomLevelAccelerationStructureAL::GetBuffer() const - { - return m_buffer; - } +ID3D12Resource* Tr2RtBottomLevelAccelerationStructureAL::GetBuffer() const +{ + return m_buffer; +} - D3D12_GPU_VIRTUAL_ADDRESS Tr2RtBottomLevelAccelerationStructureAL::GetGPUVirtualAddress() const - { - return m_bufferAddress; - } +D3D12_GPU_VIRTUAL_ADDRESS Tr2RtBottomLevelAccelerationStructureAL::GetGPUVirtualAddress() const +{ + return m_bufferAddress; +} - Tr2ALMemoryType Tr2RtBottomLevelAccelerationStructureAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +Tr2ALMemoryType Tr2RtBottomLevelAccelerationStructureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2RtBottomLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtBottomLevelAccelerationStructureAL"; - } +void Tr2RtBottomLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtBottomLevelAccelerationStructureAL"; +} } #endif diff --git a/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.h b/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.h index 22821241b..ee3a96355 100644 --- a/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.h +++ b/trinityal/dx12/Tr2RtBottomLevelAccelerationStructureALDx12.h @@ -8,33 +8,33 @@ namespace TrinityALImpl { - class Tr2RtBottomLevelAccelerationStructureAL : public Tr2DeviceResourceAL - { - public: - Tr2RtBottomLevelAccelerationStructureAL(); - ~Tr2RtBottomLevelAccelerationStructureAL(); - - ALResult Create( const Tr2RtGeometryAL& geometry, const Tr2RtGeometryAL& capacity, Tr2RtBlasGeometryFlags::Type geometryFlags, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ); - ALResult CompactBlas( Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - ID3D12Resource* GetBuffer() const; - D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const; - - private: - CComPtr m_buffer; - CComPtr m_scratch; - D3D12_GPU_VIRTUAL_ADDRESS m_bufferAddress; - D3D12_RAYTRACING_GEOMETRY_DESC m_geometryDesc; - Tr2RtBlasGeometryFlags::Type m_geometryFlags; - Tr2RtBuildFlags::Type m_buildFlags; - Tr2PrimaryRenderContextAL* m_owner; - }; +class Tr2RtBottomLevelAccelerationStructureAL : public Tr2DeviceResourceAL +{ +public: + Tr2RtBottomLevelAccelerationStructureAL(); + ~Tr2RtBottomLevelAccelerationStructureAL(); + + ALResult Create( const Tr2RtGeometryAL& geometry, const Tr2RtGeometryAL& capacity, Tr2RtBlasGeometryFlags::Type geometryFlags, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ); + ALResult Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ); + ALResult CompactBlas( Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + ID3D12Resource* GetBuffer() const; + D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const; + +private: + CComPtr m_buffer; + CComPtr m_scratch; + D3D12_GPU_VIRTUAL_ADDRESS m_bufferAddress; + D3D12_RAYTRACING_GEOMETRY_DESC m_geometryDesc; + Tr2RtBlasGeometryFlags::Type m_geometryFlags; + Tr2RtBuildFlags::Type m_buildFlags; + Tr2PrimaryRenderContextAL* m_owner; +}; } #endif diff --git a/trinityal/dx12/Tr2RtPipelineStateALDx12.cpp b/trinityal/dx12/Tr2RtPipelineStateALDx12.cpp index c7c85ef78..283bc90b4 100644 --- a/trinityal/dx12/Tr2RtPipelineStateALDx12.cpp +++ b/trinityal/dx12/Tr2RtPipelineStateALDx12.cpp @@ -12,132 +12,152 @@ extern uint32_t g_forceAnisotropy; namespace { - class DataStoreCache +class DataStoreCache +{ +public: + DataStoreCache() : + m_dataOffset( PAGE_SIZE ) + { + } + void* AddData( size_t size ) { - public: - DataStoreCache() - :m_dataOffset( PAGE_SIZE ) + if( m_dataOffset + size > PAGE_SIZE ) { + std::unique_ptr page( new uint8_t[std::max( size, PAGE_SIZE )] ); + m_dataPages.emplace_back( std::move( page ) ); + m_dataOffset = size; + return m_dataPages.back().get(); } - void* AddData( size_t size ) - { - if( m_dataOffset + size > PAGE_SIZE ) - { - std::unique_ptr page( new uint8_t[std::max( size, PAGE_SIZE )] ); - m_dataPages.emplace_back( std::move( page ) ); - m_dataOffset = size; - return m_dataPages.back().get(); - } - auto result = m_dataPages.back().get() + m_dataOffset; - m_dataOffset += size; - return result; - } + auto result = m_dataPages.back().get() + m_dataOffset; + m_dataOffset += size; + return result; + } - template - T* AddData( size_t count = 1) - { - return static_cast(AddData( sizeof( T ) * count )); - } - private: - std::vector> m_dataPages; - static const size_t PAGE_SIZE = 1024; - size_t m_dataOffset; - }; + template + T* AddData( size_t count = 1 ) + { + return static_cast( AddData( sizeof( T ) * count ) ); + } + +private: + std::vector> m_dataPages; + static const size_t PAGE_SIZE = 1024; + size_t m_dataOffset; +}; } namespace TrinityALImpl { - Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() - :m_owner( nullptr ) - { - } +Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() : + m_owner( nullptr ) +{ +} - Tr2RtPipelineStateAL::~Tr2RtPipelineStateAL() +Tr2RtPipelineStateAL::~Tr2RtPipelineStateAL() +{ + Destroy(); +} + +ALResult Tr2RtPipelineStateAL::CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDCALL; } - ALResult Tr2RtPipelineStateAL::CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ) - { - if( !renderContext.IsValid() ) + // pipeline state obj is just an array of subobjects, + // where each subobject describes a single element of the state + DataStoreCache dataStore; + std::vector subObjects; + subObjects.reserve( desc.m_shaders.size() * 4 + desc.m_hitGroups.size() * 2 + desc.m_localSignatures.size() + 2 ); + + std::vector localSignatures; + ON_BLOCK_EXIT( [&localSignatures] { + for( auto it = begin( localSignatures ); it != end( localSignatures ); ++it ) { - return E_INVALIDCALL; + delete *it; } + } ); - // pipeline state obj is just an array of subobjects, - // where each subobject describes a single element of the state - DataStoreCache dataStore; - std::vector subObjects; - subObjects.reserve( desc.m_shaders.size() * 4 + desc.m_hitGroups.size() * 2 + desc.m_localSignatures.size() + 2 ); + for( auto it = begin( desc.m_localSignatures ); it != end( desc.m_localSignatures ); ++it ) + { + TrinityALImpl::Tr2RootSignatureAL* localSignature = new TrinityALImpl::Tr2RootSignatureAL(); + localSignatures.push_back( localSignature ); - std::vector localSignatures; - ON_BLOCK_EXIT( [&localSignatures] { - for( auto it = begin( localSignatures ); it != end( localSignatures ); ++it ) - { - delete* it; - } - } ); + CR_RETURN_HR( CreateRootSignature( *localSignature, *it, D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE, renderContext ) ); - for( auto it = begin( desc.m_localSignatures ); it != end( desc.m_localSignatures ); ++it ) - { - TrinityALImpl::Tr2RootSignatureAL* localSignature = new TrinityALImpl::Tr2RootSignatureAL(); - localSignatures.push_back( localSignature ); + auto signatureDesc = dataStore.AddData(); + signatureDesc->pLocalRootSignature = localSignature->m_rootSignature.p; - CR_RETURN_HR( CreateRootSignature( *localSignature, *it, D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE, renderContext ) ); + D3D12_STATE_SUBOBJECT subobject = {}; + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; + subobject.pDesc = signatureDesc; - auto signatureDesc = dataStore.AddData(); - signatureDesc->pLocalRootSignature = localSignature->m_rootSignature.p; + subObjects.push_back( subobject ); + } - D3D12_STATE_SUBOBJECT subobject = {}; - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; - subobject.pDesc = signatureDesc; + for( auto it = begin( desc.m_shaders ); it != end( desc.m_shaders ); ++it ) + { + auto& shader = *it; - subObjects.push_back( subobject ); - } + // CREATE DXIL LIBRARY + // 1. subobject = dxil library - for( auto it = begin( desc.m_shaders ); it != end( desc.m_shaders ); ++it ) + // dxil export + auto rgsExportDesc = dataStore.AddData( shader.names.size() ); + for( size_t i = 0; i < shader.names.size(); ++i ) { - auto& shader = *it; + rgsExportDesc[i].Name = shader.names[i].exportName.c_str(); + rgsExportDesc[i].ExportToRename = shader.names[i].name.c_str(); + rgsExportDesc[i].Flags = D3D12_EXPORT_FLAG_NONE; + } - // CREATE DXIL LIBRARY - // 1. subobject = dxil library + // dxil library + auto rgsLibDesc = dataStore.AddData(); + rgsLibDesc->DXILLibrary.BytecodeLength = shader.bytecode.size; + rgsLibDesc->DXILLibrary.pShaderBytecode = shader.bytecode.bytecode; + rgsLibDesc->NumExports = UINT( shader.names.size() ); + rgsLibDesc->pExports = rgsExportDesc; - // dxil export - auto rgsExportDesc = dataStore.AddData( shader.names.size() ); - for( size_t i = 0; i < shader.names.size(); ++i ) - { - rgsExportDesc[i].Name = shader.names[i].exportName.c_str(); - rgsExportDesc[i].ExportToRename = shader.names[i].name.c_str(); - rgsExportDesc[i].Flags = D3D12_EXPORT_FLAG_NONE; - } + D3D12_STATE_SUBOBJECT subobject = {}; + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; + subobject.pDesc = rgsLibDesc; - // dxil library - auto rgsLibDesc = dataStore.AddData(); - rgsLibDesc->DXILLibrary.BytecodeLength = shader.bytecode.size; - rgsLibDesc->DXILLibrary.pShaderBytecode = shader.bytecode.bytecode; - rgsLibDesc->NumExports = UINT( shader.names.size() ); - rgsLibDesc->pExports = rgsExportDesc; + subObjects.push_back( subobject ); - D3D12_STATE_SUBOBJECT subobject = {}; - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; - subobject.pDesc = rgsLibDesc; + // ************** + // 2. SHADER CONFIG + auto shaderDesc = dataStore.AddData(); + shaderDesc->MaxPayloadSizeInBytes = shader.payloadSize; + shaderDesc->MaxAttributeSizeInBytes = D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES; - subObjects.push_back( subobject ); + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; + subobject.pDesc = shaderDesc; - // ************** - // 2. SHADER CONFIG - auto shaderDesc = dataStore.AddData(); - shaderDesc->MaxPayloadSizeInBytes = shader.payloadSize; - shaderDesc->MaxAttributeSizeInBytes = D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES; + subObjects.push_back( subobject ); - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; - subobject.pDesc = shaderDesc; + // ************** + // 3. ASSOCIATE ROOT SIG TO RGS + auto shaderPayloadAssociation = dataStore.AddData(); + shaderPayloadAssociation->NumExports = UINT( shader.names.size() ); + auto names = dataStore.AddData( shader.names.size() ); + for( size_t i = 0; i < shader.names.size(); ++i ) + { + names[i] = shader.names[i].exportName.c_str(); + } + shaderPayloadAssociation->pExports = names; + shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[subObjects.size() - 1]; - subObjects.push_back( subobject ); + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + subobject.pDesc = shaderPayloadAssociation; - // ************** - // 3. ASSOCIATE ROOT SIG TO RGS + subObjects.push_back( subobject ); + + // ************** + // LOCAL ROOT SIGNATURES + if( shader.localSignature != Tr2RtPipelineStateDescriptionAL::NO_SIGNATURE ) + { auto shaderPayloadAssociation = dataStore.AddData(); shaderPayloadAssociation->NumExports = UINT( shader.names.size() ); auto names = dataStore.AddData( shader.names.size() ); @@ -146,364 +166,343 @@ namespace TrinityALImpl names[i] = shader.names[i].exportName.c_str(); } shaderPayloadAssociation->pExports = names; - shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[subObjects.size() - 1]; + shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[shader.localSignature]; subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; subobject.pDesc = shaderPayloadAssociation; subObjects.push_back( subobject ); - // ************** - // LOCAL ROOT SIGNATURES - if( shader.localSignature != Tr2RtPipelineStateDescriptionAL::NO_SIGNATURE ) + for( size_t i = 0; i < shader.names.size(); ++i ) { - auto shaderPayloadAssociation = dataStore.AddData(); - shaderPayloadAssociation->NumExports = UINT( shader.names.size() ); - auto names = dataStore.AddData( shader.names.size() ); - for( size_t i = 0; i < shader.names.size(); ++i ) - { - names[i] = shader.names[i].exportName.c_str(); - } - shaderPayloadAssociation->pExports = names; - shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[shader.localSignature]; - - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - subobject.pDesc = shaderPayloadAssociation; - - subObjects.push_back( subobject ); - - for( size_t i = 0; i < shader.names.size(); ++i ) - { - m_shaderInfoForName[shader.names[i].exportName] = { localSignatures[shader.localSignature] }; - } + m_shaderInfoForName[shader.names[i].exportName] = { localSignatures[shader.localSignature] }; } - else + } + else + { + for( size_t i = 0; i < shader.names.size(); ++i ) { - for( size_t i = 0; i < shader.names.size(); ++i ) - { - m_shaderInfoForName[shader.names[i].exportName] = { nullptr }; - } + m_shaderInfoForName[shader.names[i].exportName] = { nullptr }; } } + } - for( auto it = begin( desc.m_hitGroups ); it != end( desc.m_hitGroups ); ++it ) - { - // ************** - // 4. HIT GROUP - auto& hitGroup = *it; + for( auto it = begin( desc.m_hitGroups ); it != end( desc.m_hitGroups ); ++it ) + { + // ************** + // 4. HIT GROUP + auto& hitGroup = *it; - auto hitGroupDesc = dataStore.AddData(); - hitGroupDesc->HitGroupExport = hitGroup.exportName.c_str(); - hitGroupDesc->Type = D3D12_HIT_GROUP_TYPE_TRIANGLES; - hitGroupDesc->AnyHitShaderImport = hitGroup.anyHit.empty() ? nullptr : hitGroup.anyHit.c_str(); - hitGroupDesc->ClosestHitShaderImport = hitGroup.closestHit.empty() ? nullptr : hitGroup.closestHit.c_str(); - hitGroupDesc->IntersectionShaderImport = hitGroup.intersection.empty() ? nullptr : hitGroup.intersection.c_str(); + auto hitGroupDesc = dataStore.AddData(); + hitGroupDesc->HitGroupExport = hitGroup.exportName.c_str(); + hitGroupDesc->Type = D3D12_HIT_GROUP_TYPE_TRIANGLES; + hitGroupDesc->AnyHitShaderImport = hitGroup.anyHit.empty() ? nullptr : hitGroup.anyHit.c_str(); + hitGroupDesc->ClosestHitShaderImport = hitGroup.closestHit.empty() ? nullptr : hitGroup.closestHit.c_str(); + hitGroupDesc->IntersectionShaderImport = hitGroup.intersection.empty() ? nullptr : hitGroup.intersection.c_str(); - D3D12_STATE_SUBOBJECT subobject = {}; - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; - subobject.pDesc = hitGroupDesc; + D3D12_STATE_SUBOBJECT subobject = {}; + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; + subobject.pDesc = hitGroupDesc; - subObjects.push_back( subobject ); + subObjects.push_back( subobject ); - // LOCAL SIGNATURE - if( hitGroup.localSignature != Tr2RtPipelineStateDescriptionAL::NO_SIGNATURE ) - { - auto shaderPayloadAssociation = dataStore.AddData(); - shaderPayloadAssociation->NumExports = 1; - auto names = dataStore.AddData(); - names[0] = hitGroup.exportName.c_str(); - shaderPayloadAssociation->pExports = names; - shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[hitGroup.localSignature]; + // LOCAL SIGNATURE + if( hitGroup.localSignature != Tr2RtPipelineStateDescriptionAL::NO_SIGNATURE ) + { + auto shaderPayloadAssociation = dataStore.AddData(); + shaderPayloadAssociation->NumExports = 1; + auto names = dataStore.AddData(); + names[0] = hitGroup.exportName.c_str(); + shaderPayloadAssociation->pExports = names; + shaderPayloadAssociation->pSubobjectToAssociate = &subObjects[hitGroup.localSignature]; - subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - subobject.pDesc = shaderPayloadAssociation; + subobject.Type = D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + subobject.pDesc = shaderPayloadAssociation; - subObjects.push_back( subobject ); + subObjects.push_back( subobject ); - m_shaderInfoForName[hitGroup.exportName] = { localSignatures[hitGroup.localSignature] }; - } - else - { - m_shaderInfoForName[hitGroup.exportName] = { nullptr }; - } + m_shaderInfoForName[hitGroup.exportName] = { localSignatures[hitGroup.localSignature] }; } - // ************** - // SHADERPROGRAM - // Create the global root signature and store the empty signature - TrinityALImpl::Tr2RootSignatureAL rootSignature; - CR_RETURN_HR( CreateRootSignature( rootSignature, desc.m_globalSignature, D3D12_ROOT_SIGNATURE_FLAG_NONE, renderContext ) ); + else + { + m_shaderInfoForName[hitGroup.exportName] = { nullptr }; + } + } + // ************** + // SHADERPROGRAM + // Create the global root signature and store the empty signature + TrinityALImpl::Tr2RootSignatureAL rootSignature; + CR_RETURN_HR( CreateRootSignature( rootSignature, desc.m_globalSignature, D3D12_ROOT_SIGNATURE_FLAG_NONE, renderContext ) ); + + D3D12_STATE_SUBOBJECT globalRootSig; + globalRootSig.Type = D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; + globalRootSig.pDesc = &rootSignature.m_rootSignature.p; + subObjects.push_back( globalRootSig ); + + // pipeline config + D3D12_RAYTRACING_PIPELINE_CONFIG pipelineConfig = {}; + pipelineConfig.MaxTraceRecursionDepth = 1; + + D3D12_STATE_SUBOBJECT pipelineConfigObject = {}; + pipelineConfigObject.Type = D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; + pipelineConfigObject.pDesc = &pipelineConfig; + + subObjects.push_back( pipelineConfigObject ); + + // ************** + // Create the state + D3D12_STATE_OBJECT_DESC pipelineDesc = { D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE }; + //pipelineDesc.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE; + pipelineDesc.NumSubobjects = static_cast( subObjects.size() ); + pipelineDesc.pSubobjects = subObjects.data(); + + // device5 = dxrDevice + CR_RETURN_HR( renderContext.m_device5->CreateStateObject( &pipelineDesc, IID_PPV_ARGS( &m_state ) ) ); + m_state.QueryInterface( &m_stateInfo ); + + for( auto& data : m_shaderInfoForName ) + { + data.second.shaderIdentifier = m_stateInfo->GetShaderIdentifier( data.first.c_str() ); + } - D3D12_STATE_SUBOBJECT globalRootSig; - globalRootSig.Type = D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; - globalRootSig.pDesc = &rootSignature.m_rootSignature.p; - subObjects.push_back( globalRootSig ); + m_globalSignature = rootSignature; + m_localSignatures = localSignatures; + localSignatures.clear(); + m_owner = &renderContext; + return S_OK; +} - // pipeline config - D3D12_RAYTRACING_PIPELINE_CONFIG pipelineConfig = {}; - pipelineConfig.MaxTraceRecursionDepth = 1; +void Tr2RtPipelineStateAL::Destroy() +{ + if( m_owner ) + { + for( auto it = begin( m_localSignatures ); it != end( m_localSignatures ); ++it ) + { + ( *it )->Destroy( *m_owner ); + delete *it; + } + m_localSignatures.clear(); + + RELEASE_LATER( m_owner, m_state ); + RELEASE_LATER( m_owner, m_stateInfo ); + m_globalSignature.Destroy( *m_owner ); + m_state = nullptr; + m_stateInfo = nullptr; + m_owner = nullptr; + m_shaderInfoForName.clear(); + } +} - D3D12_STATE_SUBOBJECT pipelineConfigObject = {}; - pipelineConfigObject.Type = D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; - pipelineConfigObject.pDesc = &pipelineConfig; +bool Tr2RtPipelineStateAL::IsValid() const +{ + return m_owner != nullptr; +} - subObjects.push_back( pipelineConfigObject ); +Tr2ALMemoryType Tr2RtPipelineStateAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - // ************** - // Create the state - D3D12_STATE_OBJECT_DESC pipelineDesc = { D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE }; - //pipelineDesc.Type = D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE; - pipelineDesc.NumSubobjects = static_cast(subObjects.size()); - pipelineDesc.pSubobjects = subObjects.data(); - // device5 = dxrDevice - CR_RETURN_HR( renderContext.m_device5->CreateStateObject( &pipelineDesc, IID_PPV_ARGS( &m_state ) ) ); - m_state.QueryInterface( &m_stateInfo ); +void Tr2RtPipelineStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtPipelineStateAL"; +} - for( auto& data : m_shaderInfoForName ) - { - data.second.shaderIdentifier = m_stateInfo->GetShaderIdentifier( data.first.c_str() ); - } +const TrinityALImpl::Tr2RootSignatureAL& Tr2RtPipelineStateAL::GetGlobalRootSignature() const +{ + return m_globalSignature; +} - m_globalSignature = rootSignature; - m_localSignatures = localSignatures; - localSignatures.clear(); - m_owner = &renderContext; - return S_OK; - - } +ID3D12StateObjectProperties* Tr2RtPipelineStateAL::GetStateInfo() const +{ + return m_stateInfo; +} + +ID3D12StateObject* Tr2RtPipelineStateAL::GetStateObject() const +{ + return m_state; +} - void Tr2RtPipelineStateAL::Destroy() +ALResult Tr2RtPipelineStateAL::CreateRootSignature( TrinityALImpl::Tr2RootSignatureAL& rootSignature, const Tr2ShaderSignatureAL& signature, D3D12_ROOT_SIGNATURE_FLAGS flags, Tr2PrimaryRenderContextAL& renderContext ) +{ + D3D12_ROOT_SIGNATURE_DESC signatureDesc; + memset( &signatureDesc, 0, sizeof( signatureDesc ) ); + signatureDesc.Flags = flags; + + std::vector parameters; + std::vector> ranges; + + const auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; + + auto CreateRange = []( D3D12_DESCRIPTOR_RANGE_TYPE rangeType, uint32_t registerIndex, uint32_t registerSpace, uint32_t arrayCount, uint32_t offset = 0 ) { + D3D12_DESCRIPTOR_RANGE range; + range.RangeType = rangeType; + range.NumDescriptors = arrayCount ? arrayCount : UINT_MAX; + range.BaseShaderRegister = registerIndex; + range.RegisterSpace = registerSpace; + range.OffsetInDescriptorsFromTableStart = offset; + return range; + }; + + for( auto& reg : signature.registers ) { - if( m_owner ) + auto isSrv = reg.IsSrv(); + if( isSrv || reg.IsUav() ) { - for( auto it = begin( m_localSignatures ); it != end( m_localSignatures ); ++it ) + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; + D3D12_DESCRIPTOR_RANGE_TYPE rangeType; + if( isSrv ) + { + rootSignature.m_srvRegisters.push_back( cbr ); + rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; + } + else { - (*it)->Destroy( *m_owner ); - delete* it; + rootSignature.m_uavRegisters.push_back( cbr ); + rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; } - m_localSignatures.clear(); - - RELEASE_LATER( m_owner, m_state ); - RELEASE_LATER( m_owner, m_stateInfo ); - m_globalSignature.Destroy( *m_owner ); - m_state = nullptr; - m_stateInfo = nullptr; - m_owner = nullptr; - m_shaderInfoForName.clear(); + ranges.push_back( std::make_unique( CreateRange( rangeType, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); + + D3D12_ROOT_PARAMETER parameter; + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + parameter.DescriptorTable.NumDescriptorRanges = 1; + parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); + parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + parameters.push_back( parameter ); + rootSignature.m_srvUavParameterCount++; } } - - bool Tr2RtPipelineStateAL::IsValid() const + for( auto& reg : signature.registers ) { - return m_owner != nullptr; - } - - Tr2ALMemoryType Tr2RtPipelineStateAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } + D3D12_ROOT_PARAMETER parameter; + if( reg.registerType == Tr2ShaderRegisterAL::CONSTANT_BUFFER ) + { + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + parameter.Descriptor.RegisterSpace = reg.registerSpace; + parameter.Descriptor.ShaderRegister = reg.registerIndex; + parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; + rootSignature.m_cbRegisters.push_back( cbr ); - void Tr2RtPipelineStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtPipelineStateAL"; + parameters.push_back( parameter ); + } } - - const TrinityALImpl::Tr2RootSignatureAL& Tr2RtPipelineStateAL::GetGlobalRootSignature() const + for( auto& reg : signature.registers ) { - return m_globalSignature; - } + if( reg.registerType == Tr2ShaderRegisterAL::SAMPLER ) + { + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; + rootSignature.m_samplerRegisters.push_back( cbr ); - ID3D12StateObjectProperties* Tr2RtPipelineStateAL::GetStateInfo() const - { - return m_stateInfo; - } + ranges.push_back( std::make_unique( CreateRange( D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); - ID3D12StateObject* Tr2RtPipelineStateAL::GetStateObject() const - { - return m_state; + D3D12_ROOT_PARAMETER parameter; + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + parameter.DescriptorTable.NumDescriptorRanges = 1; + parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); + parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + parameters.push_back( parameter ); + rootSignature.m_samplerParameterCount++; + } } - ALResult Tr2RtPipelineStateAL::CreateRootSignature( TrinityALImpl::Tr2RootSignatureAL& rootSignature, const Tr2ShaderSignatureAL& signature, D3D12_ROOT_SIGNATURE_FLAGS flags, Tr2PrimaryRenderContextAL& renderContext ) + std::vector samplers; + for( auto& sampl : signature.samplers ) { - D3D12_ROOT_SIGNATURE_DESC signatureDesc; - memset( &signatureDesc, 0, sizeof( signatureDesc ) ); - signatureDesc.Flags = flags; - - std::vector parameters; - std::vector> ranges; - - const auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; - - auto CreateRange = []( D3D12_DESCRIPTOR_RANGE_TYPE rangeType, uint32_t registerIndex, uint32_t registerSpace, uint32_t arrayCount, uint32_t offset = 0 ) + auto& description = sampl.sampler; + D3D12_STATIC_SAMPLER_DESC sampler; + if( g_forceAnisotropy != 1 && ( description.m_minFilter == Tr2RenderContextEnum::TF_ANISOTROPIC || description.m_magFilter == Tr2RenderContextEnum::TF_ANISOTROPIC || description.m_mipFilter == Tr2RenderContextEnum::TF_ANISOTROPIC ) ) { - D3D12_DESCRIPTOR_RANGE range; - range.RangeType = rangeType; - range.NumDescriptors = arrayCount ? arrayCount : UINT_MAX; - range.BaseShaderRegister = registerIndex; - range.RegisterSpace = registerSpace; - range.OffsetInDescriptorsFromTableStart = offset; - return range; - }; - - for( auto& reg : signature.registers ) - { - auto isSrv = reg.IsSrv(); - if( isSrv || reg.IsUav() ) - { - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; - D3D12_DESCRIPTOR_RANGE_TYPE rangeType; - if( isSrv ) - { - rootSignature.m_srvRegisters.push_back( cbr ); - rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - } - else - { - rootSignature.m_uavRegisters.push_back( cbr ); - rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - } - ranges.push_back( std::make_unique( CreateRange( rangeType, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); - - D3D12_ROOT_PARAMETER parameter; - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - parameter.DescriptorTable.NumDescriptorRanges = 1; - parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); - parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; - parameters.push_back( parameter ); - rootSignature.m_srvUavParameterCount++; - } + sampler.Filter = D3D12_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); } - for( auto& reg : signature.registers ) + else { - D3D12_ROOT_PARAMETER parameter; - if( reg.registerType == Tr2ShaderRegisterAL::CONSTANT_BUFFER ) - { - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - parameter.Descriptor.RegisterSpace = reg.registerSpace; - parameter.Descriptor.ShaderRegister = reg.registerIndex; - parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; - - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; - rootSignature.m_cbRegisters.push_back( cbr ); - - parameters.push_back( parameter ); - } + sampler.Filter = D3D12_ENCODE_BASIC_FILTER( + description.m_minFilter == Tr2RenderContextEnum::TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_magFilter == Tr2RenderContextEnum::TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_mipFilter == Tr2RenderContextEnum::TF_POINT || description.m_mipFilter == Tr2RenderContextEnum::TF_NONE ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_isComparisonFilter ? 1 : 0 ); } - for( auto& reg : signature.registers ) + sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressU ); + sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressV ); + sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressW ); + sampler.MipLODBias = description.m_mipLODBias; + sampler.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; + sampler.ComparisonFunc = D3D12_COMPARISON_FUNC( description.m_comparisonFunc ); + if( description.m_borderColor[0] > 0 ) { - if( reg.registerType == Tr2ShaderRegisterAL::SAMPLER ) - { - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; - rootSignature.m_samplerRegisters.push_back( cbr ); - - ranges.push_back( std::make_unique( CreateRange( D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); - - D3D12_ROOT_PARAMETER parameter; - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - parameter.DescriptorTable.NumDescriptorRanges = 1; - parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); - parameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; - parameters.push_back( parameter ); - rootSignature.m_samplerParameterCount++; - } + sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE; } - - std::vector samplers; - for( auto& sampl : signature.samplers ) + else if( description.m_borderColor[3] > 0 ) { - auto& description = sampl.sampler; - D3D12_STATIC_SAMPLER_DESC sampler; - if( g_forceAnisotropy != 1 && ( description.m_minFilter == Tr2RenderContextEnum::TF_ANISOTROPIC || description.m_magFilter == Tr2RenderContextEnum::TF_ANISOTROPIC || description.m_mipFilter == Tr2RenderContextEnum::TF_ANISOTROPIC ) ) - { - sampler.Filter = D3D12_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); - } - else - { - sampler.Filter = D3D12_ENCODE_BASIC_FILTER( - description.m_minFilter == Tr2RenderContextEnum::TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_magFilter == Tr2RenderContextEnum::TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_mipFilter == Tr2RenderContextEnum::TF_POINT || description.m_mipFilter == Tr2RenderContextEnum::TF_NONE ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_isComparisonFilter ? 1 : 0 ); - } - sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressU ); - sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressV ); - sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressW ); - sampler.MipLODBias = description.m_mipLODBias; - sampler.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; - sampler.ComparisonFunc = D3D12_COMPARISON_FUNC( description.m_comparisonFunc ); - if( description.m_borderColor[0] > 0 ) - { - sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE; - } - else if( description.m_borderColor[3] > 0 ) - { - sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK; - } - else - { - sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; - } - sampler.MinLOD = description.m_minLOD; - sampler.MaxLOD = description.m_mipFilter == Tr2RenderContextEnum::TF_NONE ? description.m_minLOD : description.m_maxLOD; - - sampler.ShaderRegister = sampl.registerIndex; - sampler.RegisterSpace = sampl.registerSpace; - sampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; - - samplers.push_back( sampler ); + sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK; } - - signatureDesc.NumParameters = UINT( parameters.size() ); - if( signatureDesc.NumParameters ) + else { - signatureDesc.pParameters = parameters.data(); + sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; } + sampler.MinLOD = description.m_minLOD; + sampler.MaxLOD = description.m_mipFilter == Tr2RenderContextEnum::TF_NONE ? description.m_minLOD : description.m_maxLOD; - signatureDesc.NumStaticSamplers = UINT( samplers.size() ); - signatureDesc.pStaticSamplers = samplers.data(); + sampler.ShaderRegister = sampl.registerIndex; + sampler.RegisterSpace = sampl.registerSpace; + sampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; - CComPtr rootSignatureBlob; - CComPtr errorBlob; - auto hr = D3D12SerializeRootSignature( &signatureDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ); - if( FAILED( hr ) ) - { - if( errorBlob ) - { - auto errorMsg = static_cast( errorBlob->GetBufferPointer() ); - CCP_AL_LOGERR( "Failed to serialize a root signature: %s", errorMsg ); - } - else - { - CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); - } - Destroy(); - return hr; - } - rootSignature.m_isCompute = true; - rootSignature.m_registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); - - return renderContext.m_device->CreateRootSignature( - 0, - rootSignatureBlob->GetBufferPointer(), - rootSignatureBlob->GetBufferSize(), - IID_PPV_ARGS( &rootSignature.m_rootSignature ) ); + samplers.push_back( sampler ); } - - const std::vector& Tr2RtPipelineStateAL::GetLocalSignatures() const + + signatureDesc.NumParameters = UINT( parameters.size() ); + if( signatureDesc.NumParameters ) { - return m_localSignatures; + signatureDesc.pParameters = parameters.data(); } - const Tr2RtPipelineStateAL::ShaderInfo* Tr2RtPipelineStateAL::GetShaderInfo( const wchar_t* name ) const + signatureDesc.NumStaticSamplers = UINT( samplers.size() ); + signatureDesc.pStaticSamplers = samplers.data(); + + CComPtr rootSignatureBlob; + CComPtr errorBlob; + auto hr = D3D12SerializeRootSignature( &signatureDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ); + if( FAILED( hr ) ) { - auto found = m_shaderInfoForName.find( name ); - if( found == m_shaderInfoForName.end() ) + if( errorBlob ) + { + auto errorMsg = static_cast( errorBlob->GetBufferPointer() ); + CCP_AL_LOGERR( "Failed to serialize a root signature: %s", errorMsg ); + } + else { - return nullptr; + CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); } - return &found->second; + Destroy(); + return hr; + } + rootSignature.m_isCompute = true; + rootSignature.m_registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); + + return renderContext.m_device->CreateRootSignature( + 0, + rootSignatureBlob->GetBufferPointer(), + rootSignatureBlob->GetBufferSize(), + IID_PPV_ARGS( &rootSignature.m_rootSignature ) ); +} + +const std::vector& Tr2RtPipelineStateAL::GetLocalSignatures() const +{ + return m_localSignatures; +} + +const Tr2RtPipelineStateAL::ShaderInfo* Tr2RtPipelineStateAL::GetShaderInfo( const wchar_t* name ) const +{ + auto found = m_shaderInfoForName.find( name ); + if( found == m_shaderInfoForName.end() ) + { + return nullptr; } + return &found->second; +} } #endif diff --git a/trinityal/dx12/Tr2RtPipelineStateALDx12.h b/trinityal/dx12/Tr2RtPipelineStateALDx12.h index 981b2bcde..048b10c92 100644 --- a/trinityal/dx12/Tr2RtPipelineStateALDx12.h +++ b/trinityal/dx12/Tr2RtPipelineStateALDx12.h @@ -11,42 +11,41 @@ namespace TrinityALImpl { - class Tr2RtPipelineStateAL : public Tr2DeviceResourceAL +class Tr2RtPipelineStateAL : public Tr2DeviceResourceAL +{ +public: + struct ShaderInfo { - public: - - struct ShaderInfo - { - const TrinityALImpl::Tr2RootSignatureAL* localSignature; - const void* shaderIdentifier; - }; - - Tr2RtPipelineStateAL(); - ~Tr2RtPipelineStateAL(); - - ALResult CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - ID3D12StateObjectProperties* GetStateInfo() const; - ID3D12StateObject* GetStateObject() const; - const Tr2RootSignatureAL& GetGlobalRootSignature() const; - const std::vector& GetLocalSignatures() const; - const ShaderInfo* GetShaderInfo( const wchar_t* name ) const; - private: - ALResult CreateRootSignature( TrinityALImpl::Tr2RootSignatureAL& rootSignature, const Tr2ShaderSignatureAL& signature, D3D12_ROOT_SIGNATURE_FLAGS flags, Tr2PrimaryRenderContextAL& renderContext ); - - CComPtr m_state; - CComPtr m_stateInfo; - TrinityALImpl::Tr2RootSignatureAL m_globalSignature; - std::vector m_localSignatures; - std::map> m_shaderInfoForName; - Tr2PrimaryRenderContextAL* m_owner; - + const TrinityALImpl::Tr2RootSignatureAL* localSignature; + const void* shaderIdentifier; }; + + Tr2RtPipelineStateAL(); + ~Tr2RtPipelineStateAL(); + + ALResult CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + ID3D12StateObjectProperties* GetStateInfo() const; + ID3D12StateObject* GetStateObject() const; + const Tr2RootSignatureAL& GetGlobalRootSignature() const; + const std::vector& GetLocalSignatures() const; + const ShaderInfo* GetShaderInfo( const wchar_t* name ) const; + +private: + ALResult CreateRootSignature( TrinityALImpl::Tr2RootSignatureAL& rootSignature, const Tr2ShaderSignatureAL& signature, D3D12_ROOT_SIGNATURE_FLAGS flags, Tr2PrimaryRenderContextAL& renderContext ); + + CComPtr m_state; + CComPtr m_stateInfo; + TrinityALImpl::Tr2RootSignatureAL m_globalSignature; + std::vector m_localSignatures; + std::map> m_shaderInfoForName; + Tr2PrimaryRenderContextAL* m_owner; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2RtShaderTableALDx12.cpp b/trinityal/dx12/Tr2RtShaderTableALDx12.cpp index a5c287e8d..724636e7a 100644 --- a/trinityal/dx12/Tr2RtShaderTableALDx12.cpp +++ b/trinityal/dx12/Tr2RtShaderTableALDx12.cpp @@ -14,220 +14,219 @@ namespace { - uintptr_t Align( uintptr_t offset, size_t alignment ) - { - return (offset + (alignment - 1)) & ~(alignment - 1); - } +uintptr_t Align( uintptr_t offset, size_t alignment ) +{ + return ( offset + ( alignment - 1 ) ) & ~( alignment - 1 ); +} - size_t GetSignatureSize( const TrinityALImpl::Tr2RootSignatureAL* signature ) +size_t GetSignatureSize( const TrinityALImpl::Tr2RootSignatureAL* signature ) +{ + if( !signature ) { - if( !signature ) - { - return 0; - } - size_t size = signature->m_cbRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); - size += signature->m_srvRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); - size += signature->m_uavRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); - size += signature->m_samplerRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); - return size; + return 0; } + size_t size = signature->m_cbRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); + size += signature->m_srvRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); + size += signature->m_uavRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); + size += signature->m_samplerRegisters.size() * sizeof( D3D12_GPU_DESCRIPTOR_HANDLE ); + return size; +} - size_t GetMaxElementSize( const ::Tr2RtPipelineStateAL& pipeline ) +size_t GetMaxElementSize( const ::Tr2RtPipelineStateAL& pipeline ) +{ + size_t signatureSize = 0; + auto& localSignatures = pipeline.TrinityALImpl_GetObject()->GetLocalSignatures(); + for( auto it = begin( localSignatures ); it != end( localSignatures ); ++it ) { - size_t signatureSize = 0; - auto& localSignatures = pipeline.TrinityALImpl_GetObject()->GetLocalSignatures(); - for( auto it = begin( localSignatures ); it != end( localSignatures ); ++it ) - { - signatureSize = std::max( signatureSize, GetSignatureSize( *it ) ); - } - return signatureSize; + signatureSize = std::max( signatureSize, GetSignatureSize( *it ) ); } + return signatureSize; +} } namespace TrinityALImpl { - Tr2RtShaderTableAL::Tr2RtShaderTableAL() - :m_owner( nullptr ), - m_entrySize( 0 ) +Tr2RtShaderTableAL::Tr2RtShaderTableAL() : + m_owner( nullptr ), + m_entrySize( 0 ) +{ +} + +Tr2RtShaderTableAL::~Tr2RtShaderTableAL() +{ + Destroy(); +} + +// Shader tables contain shader records. Shader records contain a shader identifier and root arguments used to look up resources +ALResult Tr2RtShaderTableAL::Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { + return E_INVALIDCALL; } - - Tr2RtShaderTableAL::~Tr2RtShaderTableAL() + if( !pipeline.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - // Shader tables contain shader records. Shader records contain a shader identifier and root arguments used to look up resources - ALResult Tr2RtShaderTableAL::Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ) + // Gather info for local signature + // local signature contains material(s) and sampler(s) + size_t signatureSize = 0; + uint32_t srvDescriptorCount = 0; + uint32_t samplerDescriptorCount = 0; + for( auto& signature : pipeline.TrinityALImpl_GetObject()->GetLocalSignatures() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !pipeline.IsValid() ) - { - return E_INVALIDARG; - } - - // Gather info for local signature - // local signature contains material(s) and sampler(s) - size_t signatureSize = 0; - uint32_t srvDescriptorCount = 0; - uint32_t samplerDescriptorCount = 0; - for( auto& signature : pipeline.TrinityALImpl_GetObject()->GetLocalSignatures() ) - { - signatureSize = std::max( signatureSize, GetSignatureSize( signature ) ); - srvDescriptorCount = std::max( srvDescriptorCount, signature->m_srvUavParameterCount ); - samplerDescriptorCount = std::max( samplerDescriptorCount, signature->m_samplerParameterCount ); - } + signatureSize = std::max( signatureSize, GetSignatureSize( signature ) ); + srvDescriptorCount = std::max( srvDescriptorCount, signature->m_srvUavParameterCount ); + samplerDescriptorCount = std::max( samplerDescriptorCount, signature->m_samplerParameterCount ); + } - auto& descriptorCache = *renderContext.m_descriptorCache[renderContext.GetCurrentBackBufferIndex()]; + auto& descriptorCache = *renderContext.m_descriptorCache[renderContext.GetCurrentBackBufferIndex()]; - size_t entrySize = Align( D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES + signatureSize, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT ); - auto size = (desc.m_rayGenNames.size() + desc.m_missNames.size() + desc.m_hitGroupNames.size()) * entrySize; + size_t entrySize = Align( D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES + signatureSize, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT ); + auto size = ( desc.m_rayGenNames.size() + desc.m_missNames.size() + desc.m_hitGroupNames.size() ) * entrySize; - CComPtr table; - auto heap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto scratchDesc = BufferDesc( Align( size, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_NONE ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &table ) ) ); + CComPtr table; + auto heap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto scratchDesc = BufferDesc( Align( size, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT ), D3D12_RESOURCE_FLAG_NONE ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS( &table ) ) ); - uint8_t* tableData; - CR_RETURN_HR( table->Map( 0, nullptr, (void**)&tableData ) ); - ON_BLOCK_EXIT( [&] {table->Unmap( 0, nullptr ); } ); + uint8_t* tableData; + CR_RETURN_HR( table->Map( 0, nullptr, (void**)&tableData ) ); + ON_BLOCK_EXIT( [&] { table->Unmap( 0, nullptr ); } ); - uint32_t samplerHeapIncrement = renderContext.m_device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER ); + uint32_t samplerHeapIncrement = renderContext.m_device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER ); - auto FillRecord = [&]( uint8_t* tableData, const wchar_t* name, const Tr2RtLocalMaterialDescriptionAL& material )->ALResult + auto FillRecord = [&]( uint8_t* tableData, const wchar_t* name, const Tr2RtLocalMaterialDescriptionAL& material ) -> ALResult { + auto shaderInfo = pipeline.TrinityALImpl_GetObject()->GetShaderInfo( name ); + if( !shaderInfo || !shaderInfo->shaderIdentifier ) { - auto shaderInfo = pipeline.TrinityALImpl_GetObject()->GetShaderInfo( name ); - if( !shaderInfo || !shaderInfo->shaderIdentifier ) - { - return E_INVALIDARG; - } - memcpy( tableData, shaderInfo->shaderIdentifier, D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ); - if( auto signature = shaderInfo->localSignature ) + return E_INVALIDARG; + } + memcpy( tableData, shaderInfo->shaderIdentifier, D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ); + if( auto signature = shaderInfo->localSignature ) + { + for( auto jt = begin( signature->m_cbRegisters ); jt != end( signature->m_cbRegisters ); ++jt ) { - for( auto jt = begin( signature->m_cbRegisters ); jt != end( signature->m_cbRegisters ); ++jt ) + auto& cb = material.m_constants[jt->index]; + D3D12_GPU_VIRTUAL_ADDRESS addr; + if( cb && cb->IsValid() ) { - auto& cb = material.m_constants[jt->index]; - D3D12_GPU_VIRTUAL_ADDRESS addr; - if( cb && cb->IsValid() ) - { - addr = descriptorCache.UploadConstants( *cb->TrinityALImpl_GetObject() ); - } - else - { - addr = renderContext.m_nullCB.GetGpuView(); - } - memcpy( tableData + D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES + jt->parameter * sizeof( D3D12_GPU_VIRTUAL_ADDRESS ), &addr, sizeof( D3D12_GPU_VIRTUAL_ADDRESS ) ); + addr = descriptorCache.UploadConstants( *cb->TrinityALImpl_GetObject() ); } - if( signature->m_srvUavParameterCount ) + else { - return E_FAIL; - } - if( signature->m_samplerParameterCount ) - { - return E_FAIL; + addr = renderContext.m_nullCB.GetGpuView(); } + memcpy( tableData + D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES + jt->parameter * sizeof( D3D12_GPU_VIRTUAL_ADDRESS ), &addr, sizeof( D3D12_GPU_VIRTUAL_ADDRESS ) ); + } + if( signature->m_srvUavParameterCount ) + { + return E_FAIL; + } + if( signature->m_samplerParameterCount ) + { + return E_FAIL; } - return S_OK; - }; - - for( auto it = begin( desc.m_rayGenNames ); it != end( desc.m_rayGenNames ); ++it ) - { - CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); - tableData += entrySize; - } - - for( auto it = begin( desc.m_missNames ); it != end( desc.m_missNames ); ++it ) - { - CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); - tableData += entrySize; - } - - for( auto it = begin( desc.m_hitGroupNames ); it != end( desc.m_hitGroupNames ); ++it ) - { - CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); - tableData += entrySize; } - - m_table = table; - m_desc = desc; - m_entrySize = entrySize; - m_owner = &renderContext; return S_OK; - } + }; - void Tr2RtShaderTableAL::Destroy() + for( auto it = begin( desc.m_rayGenNames ); it != end( desc.m_rayGenNames ); ++it ) { - if( m_owner ) - { - RELEASE_LATER( m_owner, m_table ); - m_owner = nullptr; - m_table = nullptr; - m_desc = Tr2RtShaderTableDescriptionAL(); - m_entrySize = 0; - } + CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); + tableData += entrySize; } - bool Tr2RtShaderTableAL::IsValid() const + for( auto it = begin( desc.m_missNames ); it != end( desc.m_missNames ); ++it ) { - return m_table != nullptr; + CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); + tableData += entrySize; } - Tr2ALMemoryType Tr2RtShaderTableAL::GetMemoryClass() const + for( auto it = begin( desc.m_hitGroupNames ); it != end( desc.m_hitGroupNames ); ++it ) { - return AL_MEMORY_MANAGED; + CR_RETURN_HR( FillRecord( tableData, it->name, it->material ) ); + tableData += entrySize; } - void Tr2RtShaderTableAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + m_table = table; + m_desc = desc; + m_entrySize = entrySize; + m_owner = &renderContext; + return S_OK; +} + +void Tr2RtShaderTableAL::Destroy() +{ + if( m_owner ) { - description["type"] = "Tr2RtShaderTableAL"; + RELEASE_LATER( m_owner, m_table ); + m_owner = nullptr; + m_table = nullptr; + m_desc = Tr2RtShaderTableDescriptionAL(); + m_entrySize = 0; } +} - D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetRayGenShader( const wchar_t* name ) const +bool Tr2RtShaderTableAL::IsValid() const +{ + return m_table != nullptr; +} + +Tr2ALMemoryType Tr2RtShaderTableAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2RtShaderTableAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtShaderTableAL"; +} + +D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetRayGenShader( const wchar_t* name ) const +{ + for( size_t i = 0; i < m_desc.m_rayGenNames.size(); ++i ) { - for( size_t i = 0; i < m_desc.m_rayGenNames.size(); ++i ) + if( m_desc.m_rayGenNames[i].name == name ) { - if( m_desc.m_rayGenNames[i].name == name ) - { - return m_table->GetGPUVirtualAddress() + i * GetEntrySize(); - } + return m_table->GetGPUVirtualAddress() + i * GetEntrySize(); } - return 0; } + return 0; +} - D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetMissShaders() const - { - return m_table->GetGPUVirtualAddress() + m_desc.m_rayGenNames.size() * GetEntrySize(); - } +D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetMissShaders() const +{ + return m_table->GetGPUVirtualAddress() + m_desc.m_rayGenNames.size() * GetEntrySize(); +} - D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetHitGroupShaders() const - { - return m_table->GetGPUVirtualAddress() + (m_desc.m_rayGenNames.size() + m_desc.m_missNames.size()) * GetEntrySize(); - } +D3D12_GPU_VIRTUAL_ADDRESS Tr2RtShaderTableAL::GetHitGroupShaders() const +{ + return m_table->GetGPUVirtualAddress() + ( m_desc.m_rayGenNames.size() + m_desc.m_missNames.size() ) * GetEntrySize(); +} - uint64_t Tr2RtShaderTableAL::GetEntrySize() const - { - return m_entrySize; - } +uint64_t Tr2RtShaderTableAL::GetEntrySize() const +{ + return m_entrySize; +} - uint64_t Tr2RtShaderTableAL::GetMissShaderTableSize() const - { - return GetEntrySize() * m_desc.m_missNames.size(); - } +uint64_t Tr2RtShaderTableAL::GetMissShaderTableSize() const +{ + return GetEntrySize() * m_desc.m_missNames.size(); +} - uint64_t Tr2RtShaderTableAL::GetHitGroupTableSize() const - { - return GetEntrySize() * m_desc.m_hitGroupNames.size(); - } +uint64_t Tr2RtShaderTableAL::GetHitGroupTableSize() const +{ + return GetEntrySize() * m_desc.m_hitGroupNames.size(); +} } diff --git a/trinityal/dx12/Tr2RtShaderTableALDx12.h b/trinityal/dx12/Tr2RtShaderTableALDx12.h index 9fd84986c..c70a965c6 100644 --- a/trinityal/dx12/Tr2RtShaderTableALDx12.h +++ b/trinityal/dx12/Tr2RtShaderTableALDx12.h @@ -10,32 +10,32 @@ namespace TrinityALImpl { - class Tr2RtShaderTableAL : public Tr2DeviceResourceAL - { - public: - Tr2RtShaderTableAL(); - ~Tr2RtShaderTableAL(); - - ALResult Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - D3D12_GPU_VIRTUAL_ADDRESS GetRayGenShader( const wchar_t* name ) const; - D3D12_GPU_VIRTUAL_ADDRESS GetMissShaders() const; - D3D12_GPU_VIRTUAL_ADDRESS GetHitGroupShaders() const; - uint64_t GetEntrySize() const; - uint64_t GetMissShaderTableSize() const; - uint64_t GetHitGroupTableSize() const; - - private: - Tr2RtShaderTableDescriptionAL m_desc; - CComPtr m_table; - Tr2PrimaryRenderContextAL* m_owner; - uint64_t m_entrySize; - }; +class Tr2RtShaderTableAL : public Tr2DeviceResourceAL +{ +public: + Tr2RtShaderTableAL(); + ~Tr2RtShaderTableAL(); + + ALResult Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + D3D12_GPU_VIRTUAL_ADDRESS GetRayGenShader( const wchar_t* name ) const; + D3D12_GPU_VIRTUAL_ADDRESS GetMissShaders() const; + D3D12_GPU_VIRTUAL_ADDRESS GetHitGroupShaders() const; + uint64_t GetEntrySize() const; + uint64_t GetMissShaderTableSize() const; + uint64_t GetHitGroupTableSize() const; + +private: + Tr2RtShaderTableDescriptionAL m_desc; + CComPtr m_table; + Tr2PrimaryRenderContextAL* m_owner; + uint64_t m_entrySize; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.cpp b/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.cpp index 67e6698c5..459186ef1 100644 --- a/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.cpp +++ b/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.cpp @@ -13,299 +13,299 @@ namespace { - uintptr_t Align( uintptr_t offset, size_t alignment ) - { - return (offset + (alignment - 1)) & ~(alignment - 1); - } +uintptr_t Align( uintptr_t offset, size_t alignment ) +{ + return ( offset + ( alignment - 1 ) ) & ~( alignment - 1 ); +} - ALResult UploadInstanceData( ID3D12Resource* uploadBuffer, const size_t count, const Tr2RtInstanceAL* instances ) +ALResult UploadInstanceData( ID3D12Resource* uploadBuffer, const size_t count, const Tr2RtInstanceAL* instances ) +{ + D3D12_RAYTRACING_INSTANCE_DESC* data; + CR_RETURN_HR( uploadBuffer->Map( 0, nullptr, reinterpret_cast( &data ) ) ); + for( size_t i = 0; i < count; ++i ) { - D3D12_RAYTRACING_INSTANCE_DESC* data; - CR_RETURN_HR( uploadBuffer->Map( 0, nullptr, reinterpret_cast( &data ) ) ); - for( size_t i = 0; i < count; ++i ) + if( !instances[i].blas->IsValid() ) { - if( !instances[i].blas->IsValid() ) - { - uploadBuffer->Unmap( 0, nullptr ); - return E_INVALIDARG; - } - D3D12_RAYTRACING_INSTANCE_DESC d; - d.InstanceID = i; - d.InstanceContributionToHitGroupIndex = instances[i].materialIndex; - d.InstanceMask = 0xff; - memcpy( d.Transform, instances[i].transform, 12 * sizeof( float ) ); - d.AccelerationStructure = instances[i].blas->GetGPUVirtualAddress(); - d.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE | instances[i].flags; - memcpy( data + i, &d, sizeof( d ) ); + uploadBuffer->Unmap( 0, nullptr ); + return E_INVALIDARG; } - uploadBuffer->Unmap( 0, nullptr ); - return S_OK; + D3D12_RAYTRACING_INSTANCE_DESC d; + d.InstanceID = i; + d.InstanceContributionToHitGroupIndex = instances[i].materialIndex; + d.InstanceMask = 0xff; + memcpy( d.Transform, instances[i].transform, 12 * sizeof( float ) ); + d.AccelerationStructure = instances[i].blas->GetGPUVirtualAddress(); + d.Flags = D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE | instances[i].flags; + memcpy( data + i, &d, sizeof( d ) ); } + uploadBuffer->Unmap( 0, nullptr ); + return S_OK; +} } namespace TrinityALImpl { - Tr2RtTopLevelAccelerationStructureAL::Tr2RtTopLevelAccelerationStructureAL() - :m_capacity( 0 ), - m_buildFlags( Tr2RtBuildFlags::NONE ), - m_owner( nullptr ) +Tr2RtTopLevelAccelerationStructureAL::Tr2RtTopLevelAccelerationStructureAL() : + m_capacity( 0 ), + m_buildFlags( Tr2RtBuildFlags::NONE ), + m_owner( nullptr ) +{ +} + +Tr2RtTopLevelAccelerationStructureAL::~Tr2RtTopLevelAccelerationStructureAL() +{ + Destroy(); +} + +ALResult Tr2RtTopLevelAccelerationStructureAL::Create( const size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) + { + return E_INVALIDCALL; + } + if( count == 0 ) + { + return E_INVALIDARG; + } + if( !renderContext.m_commandList4 ) { + return E_INVALIDCALL; } - Tr2RtTopLevelAccelerationStructureAL::~Tr2RtTopLevelAccelerationStructureAL() + //if this causes problems then create an array of all the instances.blas buffers fill the uav barrier with that + D3D12_RESOURCE_BARRIER uavBarrier; + uavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + uavBarrier.UAV.pResource = nullptr; + uavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + renderContext.m_commandList->ResourceBarrier( 1, &uavBarrier ); + + size_t capacity = Align( count, 128 ); + + auto uploadHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto uploadDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_RAYTRACING_INSTANCE_DESC ) * capacity, D3D12_RESOURCE_FLAG_NONE ); + CComPtr uploadBuffer; + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &uploadHeap, + D3D12_HEAP_FLAG_NONE, + &uploadDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS( &uploadBuffer ) ) ); + + CR_RETURN_HR( UploadInstanceData( uploadBuffer, count, instances ) ); + + // Describe the work being requested + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS ASInputs = {}; + ASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL; + ASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; + ASInputs.InstanceDescs = uploadBuffer->GetGPUVirtualAddress(); + ASInputs.NumDescs = UINT( capacity ); + ASInputs.Flags = (D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS)buildFlags; + + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO ASBuildInfo = {}; + renderContext.m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &ASInputs, &ASBuildInfo ); + + if( ASBuildInfo.ResultDataMaxSizeInBytes <= 0 ) + { + return E_INVALIDCALL; + } + ASInputs.NumDescs = UINT( count ); + + CComPtr scratch; + auto heap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + auto scratchDesc = TrinityALImpl::BufferDesc( + Align( ASBuildInfo.ScratchDataSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS, + nullptr, + IID_PPV_ARGS( &scratch ) ) ); + + ::Tr2BufferAL buffer; + CR_RETURN_HR( buffer.Create( + Tr2BufferDescriptionAL( 1, + uint32_t( Align( ASBuildInfo.ResultDataMaxSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ) ), + Tr2GpuUsage::ACCELERATION_STRUCTURE | Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::UNORDERED_ACCESS, + Tr2CpuUsage::NONE ), + nullptr, + renderContext ) ); + + if( !buffer.IsValid() ) { - Destroy(); + return E_INVALIDCALL; } - ALResult Tr2RtTopLevelAccelerationStructureAL::Create( const size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; + desc.Inputs = ASInputs; + + desc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); + desc.DestAccelerationStructureData = buffer.TrinityALImpl_GetObject()->GetGpuView(); + + if( renderContext.m_commandList4 ) { - if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) - { - return E_INVALIDCALL; - } - if( count == 0 ) - { - return E_INVALIDARG; - } - if( !renderContext.m_commandList4 ) - { - return E_INVALIDCALL; - } + renderContext.m_commandList4->BuildRaytracingAccelerationStructure( &desc, 0, nullptr ); + } - //if this causes problems then create an array of all the instances.blas buffers fill the uav barrier with that - D3D12_RESOURCE_BARRIER uavBarrier; - uavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - uavBarrier.UAV.pResource = nullptr; - uavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - renderContext.m_commandList->ResourceBarrier( 1, &uavBarrier ); + // don't compact things if they animate + // but here we would maybe compact - size_t capacity = Align( count, 128 ); + m_buffer = buffer; + m_scratch = scratch; + UploadBuffer ub = { uploadBuffer, renderContext.GetRecordingFrameNumber() }; + m_capacity = capacity; + m_buildFlags = buildFlags; + m_owner = &renderContext; + m_uploadBuffers.push_back( ub ); - auto uploadHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto uploadDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_RAYTRACING_INSTANCE_DESC ) * capacity, D3D12_RESOURCE_FLAG_NONE ); - CComPtr uploadBuffer; - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &uploadHeap, - D3D12_HEAP_FLAG_NONE, - &uploadDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &uploadBuffer ) ) ); + D3D12_RESOURCE_BARRIER topLevelUavBarrier; + topLevelUavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + topLevelUavBarrier.UAV.pResource = buffer.TrinityALImpl_GetObject()->GetGpuResource(); + topLevelUavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + renderContext.m_commandList->ResourceBarrier( 1, &topLevelUavBarrier ); - CR_RETURN_HR( UploadInstanceData( uploadBuffer, count, instances ) ); + return S_OK; +} - // Describe the work being requested - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS ASInputs = {}; - ASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL; - ASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; - ASInputs.InstanceDescs = uploadBuffer->GetGPUVirtualAddress(); - ASInputs.NumDescs = UINT( capacity ); - ASInputs.Flags = (D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS)buildFlags; +// DXR suggests to rebuild the TLAS every frame instead of updating it +ALResult Tr2RtTopLevelAccelerationStructureAL::Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) + { + return E_INVALIDCALL; + } + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + if( m_capacity < count ) + { + return E_INVALIDARG; + } + if( !renderContext.m_commandList4 ) + { + return E_INVALIDCALL; + } - D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO ASBuildInfo = {}; - renderContext.m_device5->GetRaytracingAccelerationStructurePrebuildInfo( &ASInputs, &ASBuildInfo ); + //if this causes problems then create an array of all the instances.blas buffers fill the uav barrier with that + D3D12_RESOURCE_BARRIER uavBarrier; + uavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + uavBarrier.UAV.pResource = nullptr; + uavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + renderContext.m_commandList->ResourceBarrier( 1, &uavBarrier ); - if( ASBuildInfo.ResultDataMaxSizeInBytes <= 0 ) + CComPtr uploadBuffer; + auto completed = m_owner->GetRenderedFrameNumber(); + for( auto it = begin( m_uploadBuffers ); it != end( m_uploadBuffers ); ++it ) + { + if( completed >= it->frameIndex ) { - return E_INVALIDCALL; + uploadBuffer = it->uploadBuffer; + it->frameIndex = m_owner->GetRecordingFrameNumber(); + break; } - ASInputs.NumDescs = UINT( count ); - - CComPtr scratch; - auto heap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); - auto scratchDesc = TrinityALImpl::BufferDesc( - Align( ASBuildInfo.ScratchDataSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ), - D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, + } + if( !uploadBuffer ) + { + auto uploadHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto uploadDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_RAYTRACING_INSTANCE_DESC ) * m_capacity, D3D12_RESOURCE_FLAG_NONE ); + CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( + &uploadHeap, D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_UNORDERED_ACCESS, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); - - ::Tr2BufferAL buffer; - CR_RETURN_HR( buffer.Create( - Tr2BufferDescriptionAL( 1, - uint32_t( Align( ASBuildInfo.ResultDataMaxSizeInBytes, D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ) ), - Tr2GpuUsage::ACCELERATION_STRUCTURE | Tr2GpuUsage::SHADER_RESOURCE | Tr2GpuUsage::UNORDERED_ACCESS, - Tr2CpuUsage::NONE ), + &uploadDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, - renderContext )); - - if( !buffer.IsValid() ) - { - return E_INVALIDCALL; - } - - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; - desc.Inputs = ASInputs; - - desc.ScratchAccelerationStructureData = scratch->GetGPUVirtualAddress(); - desc.DestAccelerationStructureData = buffer.TrinityALImpl_GetObject()->GetGpuView(); + IID_PPV_ARGS( &uploadBuffer ) ) ); - if( renderContext.m_commandList4 ) - { - renderContext.m_commandList4->BuildRaytracingAccelerationStructure( &desc, 0, nullptr ); - } - - // don't compact things if they animate - // but here we would maybe compact - - m_buffer = buffer; - m_scratch = scratch; - UploadBuffer ub = { uploadBuffer, renderContext.GetRecordingFrameNumber() }; - m_capacity = capacity; - m_buildFlags = buildFlags; - m_owner = &renderContext; + UploadBuffer ub = { uploadBuffer, m_owner->GetRecordingFrameNumber() }; m_uploadBuffers.push_back( ub ); - - D3D12_RESOURCE_BARRIER topLevelUavBarrier; - topLevelUavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - topLevelUavBarrier.UAV.pResource = buffer.TrinityALImpl_GetObject()->GetGpuResource(); - topLevelUavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - renderContext.m_commandList->ResourceBarrier( 1, &topLevelUavBarrier ); - - return S_OK; } - // DXR suggests to rebuild the TLAS every frame instead of updating it - ALResult Tr2RtTopLevelAccelerationStructureAL::Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ) + CR_RETURN_HR( UploadInstanceData( uploadBuffer, count, instances ) ); + + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS ASInputs = {}; + ASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL; + ASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; + ASInputs.InstanceDescs = uploadBuffer->GetGPUVirtualAddress(); + ASInputs.NumDescs = UINT( count ); + ASInputs.Flags = (D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS)m_buildFlags; + if( HasFlag( m_buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( m_capacity < count ) - { - return E_INVALIDARG; - } - if( !renderContext.m_commandList4 ) - { - return E_INVALIDCALL; - } + ASInputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE; + } - //if this causes problems then create an array of all the instances.blas buffers fill the uav barrier with that - D3D12_RESOURCE_BARRIER uavBarrier; - uavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - uavBarrier.UAV.pResource = nullptr; - uavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - renderContext.m_commandList->ResourceBarrier( 1, &uavBarrier ); + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; + desc.Inputs = ASInputs; - CComPtr uploadBuffer; - auto completed = m_owner->GetRenderedFrameNumber(); - for( auto it = begin( m_uploadBuffers ); it != end( m_uploadBuffers ); ++it ) - { - if( completed >= it->frameIndex ) - { - uploadBuffer = it->uploadBuffer; - it->frameIndex = m_owner->GetRecordingFrameNumber(); - break; - } - } - if( !uploadBuffer ) - { - auto uploadHeap = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto uploadDesc = TrinityALImpl::BufferDesc( sizeof( D3D12_RAYTRACING_INSTANCE_DESC ) * m_capacity, D3D12_RESOURCE_FLAG_NONE ); - CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( - &uploadHeap, - D3D12_HEAP_FLAG_NONE, - &uploadDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &uploadBuffer ) ) ); - - UploadBuffer ub = { uploadBuffer, m_owner->GetRecordingFrameNumber() }; - m_uploadBuffers.push_back( ub ); - } + if( HasFlag( m_buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) + { + desc.SourceAccelerationStructureData = m_buffer.TrinityALImpl_GetObject()->GetGpuView(); + } + desc.ScratchAccelerationStructureData = m_scratch->GetGPUVirtualAddress(); + desc.DestAccelerationStructureData = m_buffer.TrinityALImpl_GetObject()->GetGpuView(); - CR_RETURN_HR( UploadInstanceData( uploadBuffer, count, instances ) ); + if( renderContext.m_commandList4 ) + { + renderContext.m_commandList4->BuildRaytracingAccelerationStructure( &desc, 0, nullptr ); + } - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS ASInputs = {}; - ASInputs.Type = D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL; - ASInputs.DescsLayout = D3D12_ELEMENTS_LAYOUT_ARRAY; - ASInputs.InstanceDescs = uploadBuffer->GetGPUVirtualAddress(); - ASInputs.NumDescs = UINT( count ); - ASInputs.Flags = (D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS)m_buildFlags; - if( HasFlag( m_buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) - { - ASInputs.Flags |= D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE; - } + D3D12_RESOURCE_BARRIER topLevelUavBarrier; + topLevelUavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + topLevelUavBarrier.UAV.pResource = m_buffer.TrinityALImpl_GetObject()->GetGpuResource(); + topLevelUavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + renderContext.m_commandList->ResourceBarrier( 1, &topLevelUavBarrier ); - D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC desc = {}; - desc.Inputs = ASInputs; + return S_OK; +} - if( HasFlag( m_buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) - { - desc.SourceAccelerationStructureData = m_buffer.TrinityALImpl_GetObject()->GetGpuView(); - } - desc.ScratchAccelerationStructureData = m_scratch->GetGPUVirtualAddress(); - desc.DestAccelerationStructureData = m_buffer.TrinityALImpl_GetObject()->GetGpuView(); +bool Tr2RtTopLevelAccelerationStructureAL::IsValid() const +{ + return m_owner != nullptr; +} - if( renderContext.m_commandList4 ) +void Tr2RtTopLevelAccelerationStructureAL::Destroy() +{ + if( m_owner ) + { + for( auto it = begin( m_uploadBuffers ); it != end( m_uploadBuffers ); ++it ) { - renderContext.m_commandList4->BuildRaytracingAccelerationStructure( &desc, 0, nullptr ); + RELEASE_LATER( m_owner, it->uploadBuffer ); } - - D3D12_RESOURCE_BARRIER topLevelUavBarrier; - topLevelUavBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - topLevelUavBarrier.UAV.pResource = m_buffer.TrinityALImpl_GetObject()->GetGpuResource(); - topLevelUavBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - renderContext.m_commandList->ResourceBarrier( 1, &topLevelUavBarrier ); - - return S_OK; - } - - bool Tr2RtTopLevelAccelerationStructureAL::IsValid() const - { - return m_owner != nullptr; - } - - void Tr2RtTopLevelAccelerationStructureAL::Destroy() - { - if( m_owner ) + m_uploadBuffers.clear(); + if( m_scratch ) { - for( auto it = begin( m_uploadBuffers ); it != end( m_uploadBuffers ); ++it ) - { - RELEASE_LATER( m_owner, it->uploadBuffer ); - } - m_uploadBuffers.clear(); - if( m_scratch ) - { - RELEASE_LATER( m_owner, m_scratch ); - } - m_scratch = nullptr; - m_capacity = 0; - m_buildFlags = Tr2RtBuildFlags::NONE; - m_owner = nullptr; + RELEASE_LATER( m_owner, m_scratch ); } + m_scratch = nullptr; + m_capacity = 0; + m_buildFlags = Tr2RtBuildFlags::NONE; + m_owner = nullptr; } +} - Tr2ALMemoryType Tr2RtTopLevelAccelerationStructureAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +Tr2ALMemoryType Tr2RtTopLevelAccelerationStructureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2RtTopLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtTopLevelAccelerationStructureAL"; - } +void Tr2RtTopLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtTopLevelAccelerationStructureAL"; +} - const ::Tr2BufferAL& Tr2RtTopLevelAccelerationStructureAL::GetBuffer() const - { - return m_buffer; - } +const ::Tr2BufferAL& Tr2RtTopLevelAccelerationStructureAL::GetBuffer() const +{ + return m_buffer; +} - size_t Tr2RtTopLevelAccelerationStructureAL::GetCapacity() const - { - return m_capacity; - } +size_t Tr2RtTopLevelAccelerationStructureAL::GetCapacity() const +{ + return m_capacity; +} } #endif diff --git a/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.h b/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.h index e4f5100e1..bfd6a07aa 100644 --- a/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.h +++ b/trinityal/dx12/Tr2RtTopLevelAccelerationStructureALDx12.h @@ -8,37 +8,38 @@ namespace TrinityALImpl { - class Tr2RtTopLevelAccelerationStructureAL : public Tr2DeviceResourceAL +class Tr2RtTopLevelAccelerationStructureAL : public Tr2DeviceResourceAL +{ +public: + Tr2RtTopLevelAccelerationStructureAL(); + ~Tr2RtTopLevelAccelerationStructureAL(); + + ALResult Create( const size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ); + ALResult Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ); + + bool IsValid() const; + + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + const ::Tr2BufferAL& GetBuffer() const; + size_t GetCapacity() const; + +private: + struct UploadBuffer { - public: - Tr2RtTopLevelAccelerationStructureAL(); - ~Tr2RtTopLevelAccelerationStructureAL(); - - ALResult Create( const size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ); - - bool IsValid() const; - - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - const ::Tr2BufferAL& GetBuffer() const; - size_t GetCapacity() const; - private: - struct UploadBuffer - { - CComPtr uploadBuffer; - uint64_t frameIndex; - }; - - ::Tr2BufferAL m_buffer; - std::vector m_uploadBuffers; - CComPtr m_scratch; - size_t m_capacity; - Tr2RtBuildFlags::Type m_buildFlags; - Tr2PrimaryRenderContextAL* m_owner; + CComPtr uploadBuffer; + uint64_t frameIndex; }; + + ::Tr2BufferAL m_buffer; + std::vector m_uploadBuffers; + CComPtr m_scratch; + size_t m_capacity; + Tr2RtBuildFlags::Type m_buildFlags; + Tr2PrimaryRenderContextAL* m_owner; +}; } #endif diff --git a/trinityal/dx12/Tr2SamplerStateALDx12.cpp b/trinityal/dx12/Tr2SamplerStateALDx12.cpp index b6f642569..8c291fd62 100644 --- a/trinityal/dx12/Tr2SamplerStateALDx12.cpp +++ b/trinityal/dx12/Tr2SamplerStateALDx12.cpp @@ -13,86 +13,86 @@ extern uint32_t g_forceAnisotropy; namespace TrinityALImpl { - Tr2SamplerStateAL::Tr2SamplerStateAL() : - m_indexInHeap( 0xffffffff ), - m_isValid( false ) - { - } +Tr2SamplerStateAL::Tr2SamplerStateAL() : + m_indexInHeap( 0xffffffff ), + m_isValid( false ) +{ +} - ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ) +ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - if( g_forceAnisotropy != 1 && ( description.m_minFilter == TF_ANISOTROPIC || description.m_magFilter == TF_ANISOTROPIC || description.m_mipFilter == TF_ANISOTROPIC ) ) - { - m_sampler.Filter = D3D12_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); - } - else - { - m_sampler.Filter = D3D12_ENCODE_BASIC_FILTER( - description.m_minFilter == TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_magFilter == TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_mipFilter == TF_POINT || description.m_mipFilter == TF_NONE ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, - description.m_isComparisonFilter ? 1 : 0 ); - } - m_sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressU ); - m_sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressV ); - m_sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressW ); - m_sampler.MipLODBias = description.m_mipLODBias; - m_sampler.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; - m_sampler.ComparisonFunc = D3D12_COMPARISON_FUNC( description.m_comparisonFunc ); - m_sampler.BorderColor[0] = description.m_borderColor[0]; - m_sampler.BorderColor[1] = description.m_borderColor[1]; - m_sampler.BorderColor[2] = description.m_borderColor[2]; - m_sampler.BorderColor[3] = description.m_borderColor[3]; - m_sampler.MinLOD = description.m_minLOD; - m_sampler.MaxLOD = description.m_mipFilter == TF_NONE ? description.m_minLOD : description.m_maxLOD; - - m_isValid = true; - - m_samplerState = nullptr; - FORWARD_HR( renderContext.CreateSamplerState( m_sampler, m_samplerState ) ); - m_indexInHeap = m_samplerState->GetIndexInHeap(); - return S_OK; + return E_INVALIDARG; } - void Tr2SamplerStateAL::Destroy() + if( g_forceAnisotropy != 1 && ( description.m_minFilter == TF_ANISOTROPIC || description.m_magFilter == TF_ANISOTROPIC || description.m_mipFilter == TF_ANISOTROPIC ) ) { - m_samplerState = nullptr; - m_isValid = false; - m_indexInHeap = 0xffffffff; + m_sampler.Filter = D3D12_ENCODE_ANISOTROPIC_FILTER( description.m_isComparisonFilter ? 1 : 0 ); } - - uint32_t Tr2SamplerStateAL::GetIndexInHeap() const + else { - return m_indexInHeap; + m_sampler.Filter = D3D12_ENCODE_BASIC_FILTER( + description.m_minFilter == TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_magFilter == TF_POINT ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_mipFilter == TF_POINT || description.m_mipFilter == TF_NONE ? D3D12_FILTER_TYPE_POINT : D3D12_FILTER_TYPE_LINEAR, + description.m_isComparisonFilter ? 1 : 0 ); } + m_sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressU ); + m_sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressV ); + m_sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE( description.m_addressW ); + m_sampler.MipLODBias = description.m_mipLODBias; + m_sampler.MaxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : description.m_maxAnisotropy; + m_sampler.ComparisonFunc = D3D12_COMPARISON_FUNC( description.m_comparisonFunc ); + m_sampler.BorderColor[0] = description.m_borderColor[0]; + m_sampler.BorderColor[1] = description.m_borderColor[1]; + m_sampler.BorderColor[2] = description.m_borderColor[2]; + m_sampler.BorderColor[3] = description.m_borderColor[3]; + m_sampler.MinLOD = description.m_minLOD; + m_sampler.MaxLOD = description.m_mipFilter == TF_NONE ? description.m_minLOD : description.m_maxLOD; + + m_isValid = true; + + m_samplerState = nullptr; + FORWARD_HR( renderContext.CreateSamplerState( m_sampler, m_samplerState ) ); + m_indexInHeap = m_samplerState->GetIndexInHeap(); + return S_OK; +} - bool Tr2SamplerStateAL::IsValid() const - { - return m_isValid; - } +void Tr2SamplerStateAL::Destroy() +{ + m_samplerState = nullptr; + m_isValid = false; + m_indexInHeap = 0xffffffff; +} - Tr2ALMemoryType Tr2SamplerStateAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +uint32_t Tr2SamplerStateAL::GetIndexInHeap() const +{ + return m_indexInHeap; +} - void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2SamplerStateAL"; - description["name"] = m_name; - } +bool Tr2SamplerStateAL::IsValid() const +{ + return m_isValid; +} - ALResult Tr2SamplerStateAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +Tr2ALMemoryType Tr2SamplerStateAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SamplerStateAL"; + description["name"] = m_name; +} + +ALResult Tr2SamplerStateAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } diff --git a/trinityal/dx12/Tr2SamplerStateALDx12.h b/trinityal/dx12/Tr2SamplerStateALDx12.h index 4b76ea672..a66407662 100644 --- a/trinityal/dx12/Tr2SamplerStateALDx12.h +++ b/trinityal/dx12/Tr2SamplerStateALDx12.h @@ -10,35 +10,35 @@ namespace TrinityALImpl { - class Tr2RtShaderTableAL; +class Tr2RtShaderTableAL; - class Tr2SamplerStateAL : public Tr2DeviceResourceAL - { - public: - Tr2SamplerStateAL(); +class Tr2SamplerStateAL : public Tr2DeviceResourceAL +{ +public: + Tr2SamplerStateAL(); - ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ); + ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ); - uint32_t GetIndexInHeap() const; + uint32_t GetIndexInHeap() const; - void Destroy(); + void Destroy(); - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - std::shared_ptr m_samplerState; - uint32_t m_indexInHeap; - D3D12_SAMPLER_DESC m_sampler; - std::string m_name; - bool m_isValid; +private: + std::shared_ptr m_samplerState; + uint32_t m_indexInHeap; + D3D12_SAMPLER_DESC m_sampler; + std::string m_name; + bool m_isValid; - friend class Tr2RenderContextAL; - friend class Tr2ResourceSetAL; - friend class TrinityALImpl::Tr2RtShaderTableAL; - }; + friend class Tr2RenderContextAL; + friend class Tr2ResourceSetAL; + friend class TrinityALImpl::Tr2RtShaderTableAL; +}; } diff --git a/trinityal/dx12/Tr2ShaderALDx12.cpp b/trinityal/dx12/Tr2ShaderALDx12.cpp index 2d95bd246..379424fa6 100644 --- a/trinityal/dx12/Tr2ShaderALDx12.cpp +++ b/trinityal/dx12/Tr2ShaderALDx12.cpp @@ -10,86 +10,85 @@ namespace TrinityALImpl { - Tr2ShaderAL::Tr2ShaderAL() - :m_type( Tr2RenderContextEnum::INVALID_SHADER ) - { - - } +Tr2ShaderAL::Tr2ShaderAL() : + m_type( Tr2RenderContextEnum::INVALID_SHADER ) +{ +} - ALResult Tr2ShaderAL::Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL& renderContext) +ALResult Tr2ShaderAL::Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ) +{ + m_bytecode.resize( "Tr2ShaderAL::m_bytecode", bytecode.size ); + if( m_bytecode.empty() ) { - m_bytecode.resize( "Tr2ShaderAL::m_bytecode", bytecode.size ); - if( m_bytecode.empty() ) - { - return E_OUTOFMEMORY; - } - memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); - m_signature = signature; - m_type = type; - m_name = shaderPath ? shaderPath : ""; - - renderContext.AddShaderBinaryToCrashTracker(bytecode, shaderPath); - - return S_OK; + return E_OUTOFMEMORY; } + memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); + m_signature = signature; + m_type = type; + m_name = shaderPath ? shaderPath : ""; - void Tr2ShaderAL::Destroy() - { - m_bytecode.clear(); - m_signature = Tr2ShaderSignatureAL(); - m_type = Tr2RenderContextEnum::INVALID_SHADER; - } + renderContext.AddShaderBinaryToCrashTracker( bytecode, shaderPath ); - bool Tr2ShaderAL::IsValid() const - { - return m_type != Tr2RenderContextEnum::INVALID_SHADER; - } + return S_OK; +} - Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const - { - return m_type; - } +void Tr2ShaderAL::Destroy() +{ + m_bytecode.clear(); + m_signature = Tr2ShaderSignatureAL(); + m_type = Tr2RenderContextEnum::INVALID_SHADER; +} - Tr2ALMemoryType Tr2ShaderAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +bool Tr2ShaderAL::IsValid() const +{ + return m_type != Tr2RenderContextEnum::INVALID_SHADER; +} - ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const - { - if( !IsValid() ) - { - bytecode = Tr2ShaderBytecodeAL(); - return E_INVALIDCALL; - } - bytecode.bytecode = m_bytecode.get(); - bytecode.size = m_bytecode.size(); - return S_OK; - } +Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const +{ + return m_type; +} - const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const - { - return m_signature; - } +Tr2ALMemoryType Tr2ShaderAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const +{ + if( !IsValid() ) { - description["type"] = "Tr2ShaderAL"; - description["shader"] = std::to_string( int( GetType() ) ); - description["size"] = std::to_string( m_bytecode.size() ); - description["name"] = m_name; + bytecode = Tr2ShaderBytecodeAL(); + return E_INVALIDCALL; } + bytecode.bytecode = m_bytecode.get(); + bytecode.size = m_bytecode.size(); + return S_OK; +} - ALResult Tr2ShaderAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +{ + return m_signature; +} + +void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderAL"; + description["shader"] = std::to_string( int( GetType() ) ); + description["size"] = std::to_string( m_bytecode.size() ); + description["name"] = m_name; +} + +ALResult Tr2ShaderAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ShaderALDx12.h b/trinityal/dx12/Tr2ShaderALDx12.h index 79993689d..72c361104 100644 --- a/trinityal/dx12/Tr2ShaderALDx12.h +++ b/trinityal/dx12/Tr2ShaderALDx12.h @@ -9,48 +9,47 @@ namespace TrinityALImpl { - // ------------------------------------------------------------- - // Description: - // A low level wrapper around shaders / shader programs. DX11 - // specific version will also hold on to byte code for the - // shader as this is needed for construction of input layouts. - // Avoid using this class directly; instead use effects and Tr2Effect. - // 32bit - no support for shader blobs > 4 gig - // ------------------------------------------------------------- - class Tr2ShaderAL : - public Tr2DeviceResourceAL - { - public: - Tr2ShaderAL(); - - ALResult Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ); - void Destroy(); - bool IsValid() const; - - Tr2RenderContextEnum::ShaderType GetType() const; - ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; - const Tr2ShaderSignatureAL& GetSignature() const; - Tr2ALMemoryType GetMemoryClass() const; - - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2ShaderAL( const Tr2ShaderAL& shader ); - Tr2ShaderAL& operator=( const Tr2ShaderAL& shader ); - - Tr2ShaderSignatureAL m_signature; - CcpMallocBuffer m_bytecode; - Tr2RenderContextEnum::ShaderType m_type; - std::string m_name; - - friend class Tr2ShaderProgramAL; - }; +// ------------------------------------------------------------- +// Description: +// A low level wrapper around shaders / shader programs. DX11 +// specific version will also hold on to byte code for the +// shader as this is needed for construction of input layouts. +// Avoid using this class directly; instead use effects and Tr2Effect. +// 32bit - no support for shader blobs > 4 gig +// ------------------------------------------------------------- +class Tr2ShaderAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderAL(); + + ALResult Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + Tr2RenderContextEnum::ShaderType GetType() const; + ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; + const Tr2ShaderSignatureAL& GetSignature() const; + Tr2ALMemoryType GetMemoryClass() const; + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2ShaderAL( const Tr2ShaderAL& shader ); + Tr2ShaderAL& operator=( const Tr2ShaderAL& shader ); + + Tr2ShaderSignatureAL m_signature; + CcpMallocBuffer m_bytecode; + Tr2RenderContextEnum::ShaderType m_type; + std::string m_name; + + friend class Tr2ShaderProgramAL; +}; } -#endif +#endif diff --git a/trinityal/dx12/Tr2ShaderProgramALDx12.cpp b/trinityal/dx12/Tr2ShaderProgramALDx12.cpp index 82be057e5..187efda87 100644 --- a/trinityal/dx12/Tr2ShaderProgramALDx12.cpp +++ b/trinityal/dx12/Tr2ShaderProgramALDx12.cpp @@ -124,426 +124,426 @@ ALResult ValidateShaders( Tr2ShaderAL* shaders, size_t count ) namespace TrinityALImpl { - Tr2RootSignatureAL::Tr2RootSignatureAL() : - m_srvUavParameterCount( 0 ), - m_srvUavParameterOffset( 0 ), - m_samplerParameterCount( 0 ), - m_samplerParameterOffset( 0 ), - m_isCompute( false ) +Tr2RootSignatureAL::Tr2RootSignatureAL() : + m_srvUavParameterCount( 0 ), + m_srvUavParameterOffset( 0 ), + m_samplerParameterCount( 0 ), + m_samplerParameterOffset( 0 ), + m_isCompute( false ) +{ +} + +void Tr2RootSignatureAL::Destroy( Tr2PrimaryRenderContextAL& owner ) +{ + if( m_rootSignature ) { + RELEASE_LATER( &owner, m_rootSignature ); + m_rootSignature = nullptr; } - void Tr2RootSignatureAL::Destroy( Tr2PrimaryRenderContextAL& owner ) - { - if( m_rootSignature ) - { - RELEASE_LATER( &owner, m_rootSignature ); - m_rootSignature = nullptr; - } + m_cbRegisters.clear(); + m_srvRegisters.clear(); + m_uavRegisters.clear(); + m_samplerRegisters.clear(); - m_cbRegisters.clear(); - m_srvRegisters.clear(); - m_uavRegisters.clear(); - m_samplerRegisters.clear(); + m_registerMap = Tr2RegisterMapAL(); - m_registerMap = Tr2RegisterMapAL(); + m_srvUavParameterCount = 0; + m_srvUavParameterOffset = 0; + m_samplerParameterCount = 0; + m_samplerParameterOffset = 0; +} - m_srvUavParameterCount = 0; - m_srvUavParameterOffset = 0; - m_samplerParameterCount = 0; - m_samplerParameterOffset = 0; - } +Tr2ShaderProgramAL::Tr2ShaderProgramAL() : + m_CS( { nullptr, 0 } ), + m_VS( { nullptr, 0 } ), + m_PS( { nullptr, 0 } ), + m_DS( { nullptr, 0 } ), + m_HS( { nullptr, 0 } ), + m_GS( { nullptr, 0 } ), + m_owner( nullptr ) +{ +} - Tr2ShaderProgramAL::Tr2ShaderProgramAL() : - m_CS( { nullptr, 0 } ), - m_VS( { nullptr, 0 } ), - m_PS( { nullptr, 0 } ), - m_DS( { nullptr, 0 } ), - m_HS( { nullptr, 0 } ), - m_GS( { nullptr, 0 } ), - m_owner( nullptr ) - { - } +Tr2ShaderProgramAL::~Tr2ShaderProgramAL() +{ + Destroy(); +} - Tr2ShaderProgramAL::~Tr2ShaderProgramAL() - { - Destroy(); - } +ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + return E_INVALIDCALL; + } - FORWARD_HR( ValidateShaders( shaders, count ) ); + FORWARD_HR( ValidateShaders( shaders, count ) ); - m_shaders.reserve( count ); + m_shaders.reserve( count ); - D3D12_ROOT_SIGNATURE_DESC signatureDesc; - memset( &signatureDesc, 0, sizeof( signatureDesc ) ); + D3D12_ROOT_SIGNATURE_DESC signatureDesc; + memset( &signatureDesc, 0, sizeof( signatureDesc ) ); - for( size_t i = 0; i < count; ++i ) + for( size_t i = 0; i < count; ++i ) + { + switch( shaders[i].GetType() ) { - switch( shaders[i].GetType() ) + case VERTEX_SHADER: + m_VS = MakeShaderBytecode( shaders[i] ); + if( !shaders[i].m_shader->m_signature.pipelineInputs.empty() ) { - case VERTEX_SHADER: - m_VS = MakeShaderBytecode( shaders[i] ); - if( !shaders[i].m_shader->m_signature.pipelineInputs.empty() ) - { - signatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; - } - m_iaInputs = shaders[i].m_shader->m_signature.pipelineInputs; - break; - case PIXEL_SHADER: - m_PS = MakeShaderBytecode( shaders[i] ); - break; - case DOMAIN_SHADER: - m_DS = MakeShaderBytecode( shaders[i] ); - break; - case HULL_SHADER: - m_HS = MakeShaderBytecode( shaders[i] ); - break; - case GEOMETRY_SHADER: - m_GS = MakeShaderBytecode( shaders[i] ); - break; - case COMPUTE_SHADER: - m_CS = MakeShaderBytecode( shaders[i] ); - break; - default: - return E_INVALIDARG; + signatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; } - m_shaders.push_back( shaders[i] ); + m_iaInputs = shaders[i].m_shader->m_signature.pipelineInputs; + break; + case PIXEL_SHADER: + m_PS = MakeShaderBytecode( shaders[i] ); + break; + case DOMAIN_SHADER: + m_DS = MakeShaderBytecode( shaders[i] ); + break; + case HULL_SHADER: + m_HS = MakeShaderBytecode( shaders[i] ); + break; + case GEOMETRY_SHADER: + m_GS = MakeShaderBytecode( shaders[i] ); + break; + case COMPUTE_SHADER: + m_CS = MakeShaderBytecode( shaders[i] ); + break; + default: + return E_INVALIDARG; } + m_shaders.push_back( shaders[i] ); + } - std::vector parameters; - std::vector> ranges; + std::vector parameters; + std::vector> ranges; - for( size_t i = 0; i < count; ++i ) - { - AddCbvParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, true ); - } + for( size_t i = 0; i < count; ++i ) + { + AddCbvParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, true ); + } - for( size_t i = 0; i < count; ++i ) - { - AddCbvParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, false ); - } + for( size_t i = 0; i < count; ++i ) + { + AddCbvParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, false ); + } - m_rootSignature.m_srvUavParameterOffset = uint32_t( parameters.size() ); - for( size_t i = 0; i < count; ++i ) - { - AddSrvUavParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, ranges ); - } + m_rootSignature.m_srvUavParameterOffset = uint32_t( parameters.size() ); + for( size_t i = 0; i < count; ++i ) + { + AddSrvUavParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, ranges ); + } - m_rootSignature.m_samplerParameterOffset = uint32_t( parameters.size() ); - for( size_t i = 0; i < count; ++i ) - { - AddSamplerParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, ranges ); - } + m_rootSignature.m_samplerParameterOffset = uint32_t( parameters.size() ); + for( size_t i = 0; i < count; ++i ) + { + AddSamplerParameters( shaders[i].GetType(), shaders[i].m_shader->m_signature, parameters, ranges ); + } - std::vector samplers; - for( size_t i = 0; i < count; ++i ) + std::vector samplers; + for( size_t i = 0; i < count; ++i ) + { + for( auto& sampl : shaders[i].m_shader->m_signature.samplers ) { - for( auto& sampl : shaders[i].m_shader->m_signature.samplers ) - { - samplers.push_back( CreateStaticSampler( sampl, shaders[i].GetType() ) ); - } + samplers.push_back( CreateStaticSampler( sampl, shaders[i].GetType() ) ); } + } - signatureDesc.NumParameters = UINT( parameters.size() ); - if( signatureDesc.NumParameters ) - { - signatureDesc.pParameters = parameters.data(); - } + signatureDesc.NumParameters = UINT( parameters.size() ); + if( signatureDesc.NumParameters ) + { + signatureDesc.pParameters = parameters.data(); + } - signatureDesc.NumStaticSamplers = UINT( samplers.size() ); - signatureDesc.pStaticSamplers = samplers.data(); + signatureDesc.NumStaticSamplers = UINT( samplers.size() ); + signatureDesc.pStaticSamplers = samplers.data(); - CComPtr rootSignatureBlob; - CComPtr errorBlob; - auto hr = D3D12SerializeRootSignature( &signatureDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ); - if( FAILED( hr ) ) + CComPtr rootSignatureBlob; + CComPtr errorBlob; + auto hr = D3D12SerializeRootSignature( &signatureDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ); + if( FAILED( hr ) ) + { + if( errorBlob ) { - if( errorBlob ) - { - CCP_AL_LOGERR( "Failed to serialize a root signature: %s", static_cast( errorBlob->GetBufferPointer() ) ); - } - else - { - CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); - } - Destroy(); - return hr; + CCP_AL_LOGERR( "Failed to serialize a root signature: %s", static_cast( errorBlob->GetBufferPointer() ) ); } - - hr = renderContext.m_device->CreateRootSignature( - 0, - rootSignatureBlob->GetBufferPointer(), - rootSignatureBlob->GetBufferSize(), - IID_PPV_ARGS( &m_rootSignature.m_rootSignature ) ); - if( FAILED( hr ) ) + else { - Destroy(); - return hr; + CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); } + Destroy(); + return hr; + } - m_rootSignature.m_isCompute = IsComputeProgramDx12(); + hr = renderContext.m_device->CreateRootSignature( + 0, + rootSignatureBlob->GetBufferPointer(), + rootSignatureBlob->GetBufferSize(), + IID_PPV_ARGS( &m_rootSignature.m_rootSignature ) ); + if( FAILED( hr ) ) + { + Destroy(); + return hr; + } + + m_rootSignature.m_isCompute = IsComputeProgramDx12(); - m_rootSignature.m_registerMap = Tr2RegisterMapAL( shaders, count ); + m_rootSignature.m_registerMap = Tr2RegisterMapAL( shaders, count ); - m_owner = &renderContext; + m_owner = &renderContext; - if( m_name.empty() ) + if( m_name.empty() ) + { + for( size_t i = 0; i < count; ++i ) { - for( size_t i = 0; i < count; ++i ) + auto& shaderName = shaders[i].m_shader->m_name; + if( !shaderName.empty() ) { - auto& shaderName = shaders[i].m_shader->m_name; - if( !shaderName.empty() ) - { - if( !m_name.empty() ) - m_name += " + "; - m_name += shaderName; - } + if( !m_name.empty() ) + m_name += " + "; + m_name += shaderName; } } - - return S_OK; } - void Tr2ShaderProgramAL::Destroy() + return S_OK; +} + +void Tr2ShaderProgramAL::Destroy() +{ + if( m_drawInstanced ) { - if( m_drawInstanced ) - { - RELEASE_LATER( m_owner, m_drawInstanced ); - m_drawInstanced = nullptr; - } - if( m_drawIndexedInstanced ) - { - RELEASE_LATER( m_owner, m_drawIndexedInstanced ); - m_drawIndexedInstanced = nullptr; - } - auto owner = m_owner; - if( m_owner ) - { - m_rootSignature.Destroy( *m_owner ); - } + RELEASE_LATER( m_owner, m_drawInstanced ); + m_drawInstanced = nullptr; + } + if( m_drawIndexedInstanced ) + { + RELEASE_LATER( m_owner, m_drawIndexedInstanced ); + m_drawIndexedInstanced = nullptr; + } + auto owner = m_owner; + if( m_owner ) + { + m_rootSignature.Destroy( *m_owner ); + } - m_shaders.clear(); - D3D12_SHADER_BYTECODE none = { nullptr, 0 }; - m_VS = none; - m_PS = none; - m_DS = none; - m_HS = none; - m_GS = none; - m_CS = none; + m_shaders.clear(); + D3D12_SHADER_BYTECODE none = { nullptr, 0 }; + m_VS = none; + m_PS = none; + m_DS = none; + m_HS = none; + m_GS = none; + m_CS = none; - m_iaInputs.clear(); + m_iaInputs.clear(); - m_indirectBufferLayout.constantBufferCount = {}; + m_indirectBufferLayout.constantBufferCount = {}; - m_owner = nullptr; + m_owner = nullptr; - // We want to notify the owner last as it may trigger destruction of this program - if( owner ) - { - owner->OnShaderProgramDestroyedDx12( this ); - } + // We want to notify the owner last as it may trigger destruction of this program + if( owner ) + { + owner->OnShaderProgramDestroyedDx12( this ); } +} - ALResult Tr2ShaderProgramAL::CreateCommandSignatures( Tr2IndirectBufferLayoutAL& bufferLayout, Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2ShaderProgramAL::CreateCommandSignatures( Tr2IndirectBufferLayoutAL& bufferLayout, Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( m_drawInstanced ) - { - bufferLayout = m_indirectBufferLayout; - return S_OK; - } + return E_INVALIDCALL; + } + if( m_drawInstanced ) + { + bufferLayout = m_indirectBufferLayout; + return S_OK; + } - m_indirectBufferLayout = {}; + m_indirectBufferLayout = {}; - std::vector indirectArgs; + std::vector indirectArgs; - for( auto& reg : m_rootSignature.m_cbRegisters ) + for( auto& reg : m_rootSignature.m_cbRegisters ) + { + if( reg.dynamic ) { - if( reg.dynamic ) - { - D3D12_INDIRECT_ARGUMENT_DESC arg; - arg.Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW; - arg.ConstantBufferView.RootParameterIndex = reg.parameter; - indirectArgs.push_back( arg ); + D3D12_INDIRECT_ARGUMENT_DESC arg; + arg.Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW; + arg.ConstantBufferView.RootParameterIndex = reg.parameter; + indirectArgs.push_back( arg ); - m_indirectBufferLayout.constantBuffers[m_indirectBufferLayout.constantBufferCount++] = { Tr2RenderContextEnum::ShaderType( reg.stage ), reg.index }; - } + m_indirectBufferLayout.constantBuffers[m_indirectBufferLayout.constantBufferCount++] = { Tr2RenderContextEnum::ShaderType( reg.stage ), reg.index }; } + } - if( indirectArgs.empty() ) - { - m_drawInstanced = renderContext.m_drawInstancedIndirect; - m_indirectBufferLayout.drawStride = sizeof( D3D12_DRAW_ARGUMENTS ); - - m_drawIndexedInstanced = renderContext.m_drawIndexedInstancedIndirect; - m_indirectBufferLayout.drawIndexedStride = sizeof( D3D12_DRAW_INDEXED_ARGUMENTS ); - - m_indirectBufferLayout.drawArgOffset = 0; - } - else - { - indirectArgs.push_back( {} ); - indirectArgs.back().Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; - - D3D12_COMMAND_SIGNATURE_DESC signature; - signature.ByteStride = UINT( sizeof( D3D12_DRAW_ARGUMENTS ) + 8 * ( indirectArgs.size() - 1 ) ); - signature.NodeMask = 0; - signature.NumArgumentDescs = UINT( indirectArgs.size() ); - signature.pArgumentDescs = indirectArgs.data(); - - FORWARD_HR( renderContext.m_device->CreateCommandSignature( &signature, indirectArgs.size() > 1 ? m_rootSignature.m_rootSignature : nullptr, IID_PPV_ARGS( &m_drawInstanced ) ) ); - m_indirectBufferLayout.drawStride = signature.ByteStride; - signature.ByteStride = UINT( sizeof( D3D12_DRAW_INDEXED_ARGUMENTS ) + 8 * ( indirectArgs.size() - 1 ) ); - indirectArgs.back().Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED; - FORWARD_HR( renderContext.m_device->CreateCommandSignature( &signature, indirectArgs.size() > 1 ? m_rootSignature.m_rootSignature : nullptr, IID_PPV_ARGS( &m_drawIndexedInstanced ) ) ); - m_indirectBufferLayout.drawIndexedStride = signature.ByteStride; - m_indirectBufferLayout.drawArgOffset = uint32_t( 8 * ( indirectArgs.size() - 1 ) ); - } + if( indirectArgs.empty() ) + { + m_drawInstanced = renderContext.m_drawInstancedIndirect; + m_indirectBufferLayout.drawStride = sizeof( D3D12_DRAW_ARGUMENTS ); + m_drawIndexedInstanced = renderContext.m_drawIndexedInstancedIndirect; + m_indirectBufferLayout.drawIndexedStride = sizeof( D3D12_DRAW_INDEXED_ARGUMENTS ); - bufferLayout = m_indirectBufferLayout; - return S_OK; + m_indirectBufferLayout.drawArgOffset = 0; } - - bool Tr2ShaderProgramAL::IsValid() const + else { - return m_rootSignature.m_rootSignature != nullptr; + indirectArgs.push_back( {} ); + indirectArgs.back().Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; + + D3D12_COMMAND_SIGNATURE_DESC signature; + signature.ByteStride = UINT( sizeof( D3D12_DRAW_ARGUMENTS ) + 8 * ( indirectArgs.size() - 1 ) ); + signature.NodeMask = 0; + signature.NumArgumentDescs = UINT( indirectArgs.size() ); + signature.pArgumentDescs = indirectArgs.data(); + + FORWARD_HR( renderContext.m_device->CreateCommandSignature( &signature, indirectArgs.size() > 1 ? m_rootSignature.m_rootSignature : nullptr, IID_PPV_ARGS( &m_drawInstanced ) ) ); + m_indirectBufferLayout.drawStride = signature.ByteStride; + signature.ByteStride = UINT( sizeof( D3D12_DRAW_INDEXED_ARGUMENTS ) + 8 * ( indirectArgs.size() - 1 ) ); + indirectArgs.back().Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED; + FORWARD_HR( renderContext.m_device->CreateCommandSignature( &signature, indirectArgs.size() > 1 ? m_rootSignature.m_rootSignature : nullptr, IID_PPV_ARGS( &m_drawIndexedInstanced ) ) ); + m_indirectBufferLayout.drawIndexedStride = signature.ByteStride; + m_indirectBufferLayout.drawArgOffset = uint32_t( 8 * ( indirectArgs.size() - 1 ) ); } - Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - D3D12_SHADER_BYTECODE Tr2ShaderProgramAL::MakeShaderBytecode( const ::Tr2ShaderAL& shader ) - { - D3D12_SHADER_BYTECODE result; - result.BytecodeLength = shader.m_shader->m_bytecode.size(); - result.pShaderBytecode = shader.m_shader->m_bytecode.get(); - return result; - } + bufferLayout = m_indirectBufferLayout; + return S_OK; +} - void Tr2ShaderProgramAL::AddSrvUavParameters( - ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - std::vector>& ranges ) +bool Tr2ShaderProgramAL::IsValid() const +{ + return m_rootSignature.m_rootSignature != nullptr; +} + +Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +D3D12_SHADER_BYTECODE Tr2ShaderProgramAL::MakeShaderBytecode( const ::Tr2ShaderAL& shader ) +{ + D3D12_SHADER_BYTECODE result; + result.BytecodeLength = shader.m_shader->m_bytecode.size(); + result.pShaderBytecode = shader.m_shader->m_bytecode.get(); + return result; +} + +void Tr2ShaderProgramAL::AddSrvUavParameters( + ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + std::vector>& ranges ) +{ + for( auto& reg : signature.registers ) { - for( auto& reg : signature.registers ) + auto isSrv = reg.IsSrv(); + if( isSrv || reg.IsUav() ) { - auto isSrv = reg.IsSrv(); - if( isSrv || reg.IsUav() ) + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; + D3D12_DESCRIPTOR_RANGE_TYPE rangeType; + if( isSrv ) { - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; - D3D12_DESCRIPTOR_RANGE_TYPE rangeType; - if( isSrv ) - { - m_rootSignature.m_srvRegisters.push_back( cbr ); - rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - } - else - { - m_rootSignature.m_uavRegisters.push_back( cbr ); - rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; - } - ranges.push_back( std::make_unique( CreateRange( rangeType, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); - - D3D12_ROOT_PARAMETER parameter; - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - parameter.DescriptorTable.NumDescriptorRanges = 1; - parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); - parameter.ShaderVisibility = ShaderVisibility( shaderType ); - parameters.push_back( parameter ); - m_rootSignature.m_srvUavParameterCount++; + m_rootSignature.m_srvRegisters.push_back( cbr ); + rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; } - } - } - - void Tr2ShaderProgramAL::AddCbvParameters( - ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - bool dynamicBuffers ) - { - for( auto& reg : signature.registers ) - { - if( reg.registerType != Tr2ShaderRegisterAL::CONSTANT_BUFFER || reg.dynamic != dynamicBuffers ) + else { - continue; + m_rootSignature.m_uavRegisters.push_back( cbr ); + rangeType = D3D12_DESCRIPTOR_RANGE_TYPE_UAV; } + ranges.push_back( std::make_unique( CreateRange( rangeType, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); D3D12_ROOT_PARAMETER parameter; - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - parameter.Descriptor.RegisterSpace = reg.registerSpace; - parameter.Descriptor.ShaderRegister = reg.registerIndex; + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + parameter.DescriptorTable.NumDescriptorRanges = 1; + parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); parameter.ShaderVisibility = ShaderVisibility( shaderType ); - - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType, reg.dynamic }; - m_rootSignature.m_cbRegisters.push_back( cbr ); - parameters.push_back( parameter ); + m_rootSignature.m_srvUavParameterCount++; } } +} - void Tr2ShaderProgramAL::AddSamplerParameters( - ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - std::vector>& ranges ) +void Tr2ShaderProgramAL::AddCbvParameters( + ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + bool dynamicBuffers ) +{ + for( auto& reg : signature.registers ) { - for( auto& reg : signature.registers ) + if( reg.registerType != Tr2ShaderRegisterAL::CONSTANT_BUFFER || reg.dynamic != dynamicBuffers ) { - if( reg.registerType == Tr2ShaderRegisterAL::SAMPLER ) - { - Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; - m_rootSignature.m_samplerRegisters.push_back( cbr ); - ranges.push_back( std::make_unique( CreateRange( D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); - - D3D12_ROOT_PARAMETER parameter; - parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - parameter.DescriptorTable.NumDescriptorRanges = 1; - parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); - parameter.ShaderVisibility = ShaderVisibility( shaderType ); - parameters.push_back( parameter ); - m_rootSignature.m_samplerParameterCount++; - } + continue; } - } - const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const - { - return m_rootSignature.m_registerMap; - } + D3D12_ROOT_PARAMETER parameter; + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + parameter.Descriptor.RegisterSpace = reg.registerSpace; + parameter.Descriptor.ShaderRegister = reg.registerIndex; + parameter.ShaderVisibility = ShaderVisibility( shaderType ); - bool Tr2ShaderProgramAL::IsComputeProgramDx12() const - { - return m_CS.pShaderBytecode != nullptr; - } + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType, reg.dynamic }; + m_rootSignature.m_cbRegisters.push_back( cbr ); - void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ShaderProgramAL"; - description["name"] = m_name; + parameters.push_back( parameter ); } +} - ALResult Tr2ShaderProgramAL::SetName( const char* name ) +void Tr2ShaderProgramAL::AddSamplerParameters( + ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + std::vector>& ranges ) +{ + for( auto& reg : signature.registers ) { - m_name = name; - SetDebugName( m_rootSignature.m_rootSignature, name ); - return S_OK; + if( reg.registerType == Tr2ShaderRegisterAL::SAMPLER ) + { + Tr2RootSignatureAL::CbRegister cbr = { uint32_t( shaderType ), reg.registerIndex, uint32_t( parameters.size() ), reg.registerType }; + m_rootSignature.m_samplerRegisters.push_back( cbr ); + ranges.push_back( std::make_unique( CreateRange( D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, reg.registerIndex, reg.registerSpace, reg.arrayCount ) ) ); + + D3D12_ROOT_PARAMETER parameter; + parameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + parameter.DescriptorTable.NumDescriptorRanges = 1; + parameter.DescriptorTable.pDescriptorRanges = ranges.back().get(); + parameter.ShaderVisibility = ShaderVisibility( shaderType ); + parameters.push_back( parameter ); + m_rootSignature.m_samplerParameterCount++; + } } } + +const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const +{ + return m_rootSignature.m_registerMap; +} + +bool Tr2ShaderProgramAL::IsComputeProgramDx12() const +{ + return m_CS.pShaderBytecode != nullptr; +} + +void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderProgramAL"; + description["name"] = m_name; +} + +ALResult Tr2ShaderProgramAL::SetName( const char* name ) +{ + m_name = name; + SetDebugName( m_rootSignature.m_rootSignature, name ); + return S_OK; +} +} #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2ShaderProgramALDx12.h b/trinityal/dx12/Tr2ShaderProgramALDx12.h index efc21256d..ec664b71c 100644 --- a/trinityal/dx12/Tr2ShaderProgramALDx12.h +++ b/trinityal/dx12/Tr2ShaderProgramALDx12.h @@ -14,108 +14,107 @@ struct Tr2ShaderPipelineInputAL; namespace TrinityALImpl { - struct Tr2RootSignatureAL +struct Tr2RootSignatureAL +{ + Tr2RootSignatureAL(); + void Destroy( Tr2PrimaryRenderContextAL& owner ); + + CComPtr m_rootSignature; + + struct CbRegister { - Tr2RootSignatureAL(); - void Destroy( Tr2PrimaryRenderContextAL& owner ); - - CComPtr m_rootSignature; - - struct CbRegister - { - uint32_t stage; - uint32_t index; - uint32_t parameter; - Tr2ShaderRegisterAL::RegisterType registerType; - bool dynamic; - }; - std::vector m_cbRegisters; - std::vector m_srvRegisters; - std::vector m_uavRegisters; - std::vector m_samplerRegisters; - - Tr2RegisterMapAL m_registerMap; - - uint32_t m_srvUavParameterCount; - uint32_t m_srvUavParameterOffset; - uint32_t m_samplerParameterCount; - uint32_t m_samplerParameterOffset; - - bool m_isCompute; + uint32_t stage; + uint32_t index; + uint32_t parameter; + Tr2ShaderRegisterAL::RegisterType registerType; + bool dynamic; }; + std::vector m_cbRegisters; + std::vector m_srvRegisters; + std::vector m_uavRegisters; + std::vector m_samplerRegisters; + Tr2RegisterMapAL m_registerMap; - class Tr2ShaderProgramAL : public Tr2DeviceResourceAL - { - public: - Tr2ShaderProgramAL(); - ~Tr2ShaderProgramAL(); + uint32_t m_srvUavParameterCount; + uint32_t m_srvUavParameterOffset; + uint32_t m_samplerParameterCount; + uint32_t m_samplerParameterOffset; - ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + bool m_isCompute; +}; - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; +class Tr2ShaderProgramAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderProgramAL(); + ~Tr2ShaderProgramAL(); - bool IsComputeProgramDx12() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - const Tr2RegisterMapAL& GetRegisterMap() const; - ALResult SetName( const char* name ); + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; - ALResult CreateCommandSignatures( Tr2IndirectBufferLayoutAL& bufferLayout, Tr2PrimaryRenderContextAL& renderContext ); + bool IsComputeProgramDx12() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - CComPtr m_drawIndexedInstanced; + const Tr2RegisterMapAL& GetRegisterMap() const; + ALResult SetName( const char* name ); - private: - void AddSrvUavParameters( - Tr2RenderContextEnum::ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - std::vector>& ranges ); - void AddCbvParameters( - Tr2RenderContextEnum::ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - bool dynamicBuffers - ); - void AddSamplerParameters( - Tr2RenderContextEnum::ShaderType shaderType, - const Tr2ShaderSignatureAL& signature, - std::vector& parameters, - std::vector>& ranges ); - static D3D12_SHADER_BYTECODE MakeShaderBytecode( const ::Tr2ShaderAL& shader ); + ALResult CreateCommandSignatures( Tr2IndirectBufferLayoutAL& bufferLayout, Tr2PrimaryRenderContextAL& renderContext ); - Tr2RootSignatureAL m_rootSignature; + CComPtr m_drawIndexedInstanced; - CComPtr m_drawInstanced; +private: + void AddSrvUavParameters( + Tr2RenderContextEnum::ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + std::vector>& ranges ); + void AddCbvParameters( + Tr2RenderContextEnum::ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + bool dynamicBuffers ); + void AddSamplerParameters( + Tr2RenderContextEnum::ShaderType shaderType, + const Tr2ShaderSignatureAL& signature, + std::vector& parameters, + std::vector>& ranges ); + static D3D12_SHADER_BYTECODE MakeShaderBytecode( const ::Tr2ShaderAL& shader ); - D3D12_SHADER_BYTECODE m_CS; - D3D12_SHADER_BYTECODE m_VS; - D3D12_SHADER_BYTECODE m_PS; - D3D12_SHADER_BYTECODE m_DS; - D3D12_SHADER_BYTECODE m_HS; - D3D12_SHADER_BYTECODE m_GS; - std::vector<::Tr2ShaderAL> m_shaders; - std::vector m_iaInputs; + Tr2RootSignatureAL m_rootSignature; - Tr2PrimaryRenderContextAL* m_owner; + CComPtr m_drawInstanced; - Tr2RegisterMapAL m_registerMap; + D3D12_SHADER_BYTECODE m_CS; + D3D12_SHADER_BYTECODE m_VS; + D3D12_SHADER_BYTECODE m_PS; + D3D12_SHADER_BYTECODE m_DS; + D3D12_SHADER_BYTECODE m_HS; + D3D12_SHADER_BYTECODE m_GS; - Tr2IndirectBufferLayoutAL m_indirectBufferLayout; + std::vector<::Tr2ShaderAL> m_shaders; + std::vector m_iaInputs; - std::string m_name; + Tr2PrimaryRenderContextAL* m_owner; - friend class ::Tr2RenderContextAL; - friend class Tr2ResourceSetAL; - friend class ::DescriptorStateCache; - friend class PSODescription; - }; + Tr2RegisterMapAL m_registerMap; + + Tr2IndirectBufferLayoutAL m_indirectBufferLayout; + + std::string m_name; + + friend class ::Tr2RenderContextAL; + friend class Tr2ResourceSetAL; + friend class ::DescriptorStateCache; + friend class PSODescription; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2StreamlineALDx12.cpp b/trinityal/dx12/Tr2StreamlineALDx12.cpp index a64c9d345..07e61da31 100644 --- a/trinityal/dx12/Tr2StreamlineALDx12.cpp +++ b/trinityal/dx12/Tr2StreamlineALDx12.cpp @@ -17,613 +17,613 @@ extern bool g_skipNvidiaStreamline; namespace StreamlineUtils { - void Log( sl::LogType type, const char* msg ) +void Log( sl::LogType type, const char* msg ) +{ + switch( type ) { - switch( type ) - { - case sl::LogType::eInfo: - CCP_LOGNOTICE( msg ); - break; + case sl::LogType::eInfo: + CCP_LOGNOTICE( msg ); + break; - case sl::LogType::eWarn: - CCP_LOGWARN( msg ); - break; + case sl::LogType::eWarn: + CCP_LOGWARN( msg ); + break; - case sl::LogType::eError: - CCP_LOGERR( msg ); - break; - default: - break; - } + case sl::LogType::eError: + CCP_LOGERR( msg ); + break; + default: + break; } +} - sl::Resource GenerateTextureResource( Tr2TextureAL* texture ) +sl::Resource GenerateTextureResource( Tr2TextureAL* texture ) +{ + if( texture && texture->IsValid() ) { - if( texture && texture->IsValid() ) - { - return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx12(), nullptr, nullptr, (uint32_t)texture->TrinityALImpl_GetObject()->GetResourceState() }; - } - else - { - return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; - } + return { sl::ResourceType::eTex2d, texture->TrinityALImpl_GetObject()->GetResourceDx12(), nullptr, nullptr, (uint32_t)texture->TrinityALImpl_GetObject()->GetResourceState() }; } - - sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) + else { - return renderContext.m_commandList; + return { sl::ResourceType::eTex2d, nullptr, nullptr, nullptr, 0 }; } } +sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) +{ + return renderContext.m_commandList; +} +} + namespace Tr2Streamline { - // Static Streamline interface - // Responsible for checking if it is available, initializing the Streamline framework and keeping tabs on plugin availability - Status s_status = Status::UNCHECKED; - bool s_reflexEnabled = false; - bool s_framegenEnabled = false; - Tr2DlssPlugin* s_dlssPlugin = nullptr; - Tr2NisPlugin* s_nisPlugin = nullptr; - std::function s_swapchainCreator = []() {}; - std::function s_swapchainDestroyer = []() {}; - HMODULE s_streamlineModule; - - sl::FrameToken* s_frameToken = 0; - sl::Constants s_commonConstants = {}; - - std::map s_pluginInfo = { - { - StreamlineUtils::SP_DLSS, - { "dlss", sl::kFeatureDLSS, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_DLSSG, - { "dlss_g", sl::kFeatureDLSS_G, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_REFLEX, - { "reflex", sl::kFeatureReflex, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_NIS, - { "nis", sl::kFeatureNIS, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - { - StreamlineUtils::SP_DEBUG, - { "imgui", sl::kFeatureImGUI, StreamlineUtils::SLPA_UNKNOWN, false }, - }, - }; +// Static Streamline interface +// Responsible for checking if it is available, initializing the Streamline framework and keeping tabs on plugin availability +Status s_status = Status::UNCHECKED; +bool s_reflexEnabled = false; +bool s_framegenEnabled = false; +Tr2DlssPlugin* s_dlssPlugin = nullptr; +Tr2NisPlugin* s_nisPlugin = nullptr; +std::function s_swapchainCreator = []() {}; +std::function s_swapchainDestroyer = []() {}; +HMODULE s_streamlineModule; + +sl::FrameToken* s_frameToken = 0; +sl::Constants s_commonConstants = {}; + +std::map s_pluginInfo = { + { + StreamlineUtils::SP_DLSS, + { "dlss", sl::kFeatureDLSS, StreamlineUtils::SLPA_UNKNOWN, false }, + }, + { + StreamlineUtils::SP_DLSSG, + { "dlss_g", sl::kFeatureDLSS_G, StreamlineUtils::SLPA_UNKNOWN, false }, + }, + { + StreamlineUtils::SP_REFLEX, + { "reflex", sl::kFeatureReflex, StreamlineUtils::SLPA_UNKNOWN, false }, + }, + { + StreamlineUtils::SP_NIS, + { "nis", sl::kFeatureNIS, StreamlineUtils::SLPA_UNKNOWN, false }, + }, + { + StreamlineUtils::SP_DEBUG, + { "imgui", sl::kFeatureImGUI, StreamlineUtils::SLPA_UNKNOWN, false }, + }, +}; + +sl::float2 AsFloat2( float f[2] ) +{ + return sl::float2( f[0], f[1] ); +} - sl::float2 AsFloat2( float f[2] ) - { - return sl::float2( f[0], f[1] ); - } +sl::float3 AsFloat3( float f[3] ) +{ + return sl::float3( f[0], f[1], f[2] ); +} - sl::float3 AsFloat3( float f[3] ) - { - return sl::float3( f[0], f[1], f[2] ); - } +sl::float4 AsFloat4( float f[4] ) +{ + return sl::float4( f[0], f[1], f[2], f[3] ); +} - sl::float4 AsFloat4( float f[4] ) - { - return sl::float4( f[0], f[1], f[2], f[3] ); - } +sl::float4x4 AsFloat4x4( float f[16] ) +{ + sl::float4x4 m; + m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); + m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); + m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); + m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); + return m; +} - sl::float4x4 AsFloat4x4( float f[16] ) +bool IsAvailable() +{ + if( s_status == UNCHECKED ) { - sl::float4x4 m; - m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); - m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); - m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); - m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); - return m; - } + s_status = UNAVAILABLE; - bool IsAvailable() - { - if( s_status == UNCHECKED ) + if( !g_skipNvidiaStreamline ) { - s_status = UNAVAILABLE; - - if( !g_skipNvidiaStreamline ) + wchar_t abs_path[2048]; + auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 2048, abs_path, nullptr ); + bool available = false; + if( size == 0 ) + { + CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); + } + else { - wchar_t abs_path[2048]; - auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 2048, abs_path, nullptr ); - bool available = false; - if( size == 0 ) - { - CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); - } - else - { - available = sl::security::verifyEmbeddedSignature( abs_path ); - s_streamlineModule = LoadLibraryW( abs_path ); - available = !!s_streamlineModule; - } - CCP_LOGNOTICE( "Nvidia Streamline is %s", available ? "enabled" : "disabled" ); - s_status = available ? AVAILABLE : UNAVAILABLE; + available = sl::security::verifyEmbeddedSignature( abs_path ); + s_streamlineModule = LoadLibraryW( abs_path ); + available = !!s_streamlineModule; } + CCP_LOGNOTICE( "Nvidia Streamline is %s", available ? "enabled" : "disabled" ); + s_status = available ? AVAILABLE : UNAVAILABLE; } - return s_status != UNAVAILABLE; } + return s_status != UNAVAILABLE; +} - HMODULE GetStreamlineModule() +HMODULE GetStreamlineModule() +{ + return s_streamlineModule; +} + +bool Initialize() +{ + if( !IsAvailable() ) { - return s_streamlineModule; + return false; } - bool Initialize() + if( s_status != AVAILABLE ) { - if( !IsAvailable() ) - { - return false; - } + return s_status == INITIALIZED; + } - if( s_status != AVAILABLE ) - { - return s_status == INITIALIZED; - } + sl::Preferences pref{}; - sl::Preferences pref{}; +#ifndef NDEBUG + pref.showConsole = true; // for debugging, set to false in production + pref.logLevel = sl::LogLevel::eVerbose; +#else + pref.showConsole = false; + pref.logLevel = sl::LogLevel::eDefault; +#endif + auto features = std::vector(); - #ifndef NDEBUG - pref.showConsole = true; // for debugging, set to false in production - pref.logLevel = sl::LogLevel::eVerbose; - #else - pref.showConsole = false; - pref.logLevel = sl::LogLevel::eDefault; - #endif - auto features = std::vector(); + for( auto& pluginInfo : s_pluginInfo ) + { + features.push_back( pluginInfo.second.streamlineID ); + } +#ifndef NDEBUG + features.push_back( sl::kFeatureImGUI ); +#endif - for( auto& pluginInfo : s_pluginInfo ) - { - features.push_back( pluginInfo.second.streamlineID ); - } - #ifndef NDEBUG - features.push_back( sl::kFeatureImGUI ); - #endif - - sl::Feature* featuresToEnable = features.data(); - pref.numFeaturesToLoad = (uint32_t)features.size(); - - pref.featuresToLoad = featuresToEnable; - pref.logMessageCallback = StreamlineUtils::Log; - pref.applicationId = EVE_ONLINE_APP_ID; - pref.engine = sl::EngineType::eCustom; - pref.flags |= sl::PreferenceFlags::eAllowOTA; - pref.flags |= sl::PreferenceFlags::eUseManualHooking; - - DECLARE_STATIC_SL_FUNC( slInit ); - if( SL_FAILED( res, s_slInit( pref, sl::kSDKVersion ) ) ) - { - s_status = UNINITIALIZED; + sl::Feature* featuresToEnable = features.data(); + pref.numFeaturesToLoad = (uint32_t)features.size(); - if( res == sl::Result::eErrorDriverOutOfDate ) - { - CCP_LOGWARN( "Could not initialize NVidia Streamline due to drivers being out of date" ); - } + pref.featuresToLoad = featuresToEnable; + pref.logMessageCallback = StreamlineUtils::Log; + pref.applicationId = EVE_ONLINE_APP_ID; + pref.engine = sl::EngineType::eCustom; + pref.flags |= sl::PreferenceFlags::eAllowOTA; + pref.flags |= sl::PreferenceFlags::eUseManualHooking; - return false; + DECLARE_STATIC_SL_FUNC( slInit ); + if( SL_FAILED( res, s_slInit( pref, sl::kSDKVersion ) ) ) + { + s_status = UNINITIALIZED; + + if( res == sl::Result::eErrorDriverOutOfDate ) + { + CCP_LOGWARN( "Could not initialize NVidia Streamline due to drivers being out of date" ); } - CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); - s_status = INITIALIZED; - return true; + return false; } - void SetSwapchainCreator( std::function creator ) + CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); + s_status = INITIALIZED; + return true; +} + +void SetSwapchainCreator( std::function creator ) +{ + s_swapchainCreator = creator; +} + +void SetSwapchainDestroyer( std::function destroyer ) +{ + s_swapchainDestroyer = destroyer; +} + +void Attach( void* device ) +{ + if( !IsAvailable() ) { - s_swapchainCreator = creator; + return; } + DECLARE_STATIC_SL_FUNC( slSetD3DDevice ); - void SetSwapchainDestroyer( std::function destroyer ) + if( SL_FAILED( res, s_slSetD3DDevice( device ) ) ) { - s_swapchainDestroyer = destroyer; + CCP_LOGWARN( "Could not attach NVidia Streamline to device (%d)", res ); + return; } - void Attach( void* device ) + s_status = ATTACHED; + CCP_LOGNOTICE( "NVidia Streamline successfully attached to device and adapter" ); +} + +void Shutdown() +{ + if( s_status == ATTACHED || s_status == INITIALIZED ) { - if( !IsAvailable() ) - { - return; - } - DECLARE_STATIC_SL_FUNC( slSetD3DDevice ); + // Un-set all tags + sl::ResourceTag inputs[] = { + sl::ResourceTag{ nullptr, sl::kBufferTypeDepth, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeMotionVectors, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeScalingInputColor, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeScalingOutputColor, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeHUDLessColor, sl::ResourceLifecycle::eValidUntilPresent }, + sl::ResourceTag{ nullptr, sl::kBufferTypeExposure, sl::ResourceLifecycle::eValidUntilPresent }, + }; - if( SL_FAILED( res, s_slSetD3DDevice( device ) ) ) - { - CCP_LOGWARN( "Could not attach NVidia Streamline to device (%d)", res ); - return; - } + DECLARE_STATIC_SL_FUNC( slSetTag ); + s_slSetTag( 0, inputs, _countof( inputs ), nullptr ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DEBUG, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_NIS, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, false ); + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSSG, false ); - s_status = ATTACHED; - CCP_LOGNOTICE( "NVidia Streamline successfully attached to device and adapter" ); - } + DECLARE_STATIC_SL_FUNC( slShutdown ); - void Shutdown() - { - if( s_status == ATTACHED || s_status == INITIALIZED ) + if( SL_FAILED( result, s_slShutdown() ) ) { - // Un-set all tags - sl::ResourceTag inputs[] = { - sl::ResourceTag{ nullptr, sl::kBufferTypeDepth, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeMotionVectors, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeScalingInputColor, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeScalingOutputColor, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeHUDLessColor, sl::ResourceLifecycle::eValidUntilPresent }, - sl::ResourceTag{ nullptr, sl::kBufferTypeExposure, sl::ResourceLifecycle::eValidUntilPresent }, - }; - - DECLARE_STATIC_SL_FUNC( slSetTag ); - s_slSetTag( 0, inputs, _countof( inputs ), nullptr ); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DEBUG, false); - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false); - Toggle( StreamlineUtils::StreamlinePlugin::SP_NIS, false); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, false); - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSSG, false ); - - DECLARE_STATIC_SL_FUNC( slShutdown ); - - if( SL_FAILED( result, s_slShutdown() ) ) - { - CCP_LOGWARN( "Could not shutdown NVidia Streamline (%d)", result ); - } + CCP_LOGWARN( "Could not shutdown NVidia Streamline (%d)", result ); } - s_status = UNCHECKED; - // unload the streamline module - s_streamlineModule = nullptr; } + s_status = UNCHECKED; + // unload the streamline module + s_streamlineModule = nullptr; +} - void UpdateFrameToken() +void UpdateFrameToken() +{ + if( IsAvailable() ) { - if( IsAvailable() ) + DECLARE_STATIC_SL_FUNC( slGetNewFrameToken ); + if( SL_FAILED( res, s_slGetNewFrameToken( s_frameToken, nullptr ) ) ) { - DECLARE_STATIC_SL_FUNC( slGetNewFrameToken ); - if( SL_FAILED( res, s_slGetNewFrameToken( s_frameToken, nullptr ) ) ) - { - CCP_LOGERR( "Could not get new frame token for Nvidia Streamline (%d)", res ); - return; - } + CCP_LOGERR( "Could not get new frame token for Nvidia Streamline (%d)", res ); + return; } } +} - // functions to create dx stuff from streamline or not - HRESULT SlCreateDXGIFactory( REFIID id, void** factory ) +// functions to create dx stuff from streamline or not +HRESULT SlCreateDXGIFactory( REFIID id, void** factory ) +{ + if( IsAvailable() ) { - if( IsAvailable() ) - { - typedef HRESULT( WINAPI * PFunCreateDXGIFactory )( REFIID, void** ); - static auto slCreateDXGIFactory = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory" ) ); - return slCreateDXGIFactory( id, factory ); - } - return CreateDXGIFactory( id, factory ); + typedef HRESULT( WINAPI * PFunCreateDXGIFactory )( REFIID, void** ); + static auto slCreateDXGIFactory = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory" ) ); + return slCreateDXGIFactory( id, factory ); } + return CreateDXGIFactory( id, factory ); +} - HRESULT SlCreateDXGIFactory1( REFIID id, void** factory1 ) +HRESULT SlCreateDXGIFactory1( REFIID id, void** factory1 ) +{ + if( IsAvailable() ) { - if( IsAvailable() ) - { - typedef HRESULT( WINAPI * PFunCreateDXGIFactory1 )( REFIID, void** ); - static auto slCreateDXGIFactory1 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory1" ) ); - return slCreateDXGIFactory1( id, factory1 ); - } - return CreateDXGIFactory1( id, factory1 ); + typedef HRESULT( WINAPI * PFunCreateDXGIFactory1 )( REFIID, void** ); + static auto slCreateDXGIFactory1 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory1" ) ); + return slCreateDXGIFactory1( id, factory1 ); } + return CreateDXGIFactory1( id, factory1 ); +} - HRESULT SlCreateDXGIFactory2( UINT flags, REFIID id, void** factory2 ) +HRESULT SlCreateDXGIFactory2( UINT flags, REFIID id, void** factory2 ) +{ + if( IsAvailable() ) { - if( IsAvailable() ) - { - typedef HRESULT( WINAPI * PFunCreateDXGIFactory2 )( UINT, REFIID, void** ); - static auto slCreateDXGIFactory2 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory2" ) ); - return slCreateDXGIFactory2( flags, id, factory2 ); - } - return CreateDXGIFactory2( flags, id, factory2 ); + typedef HRESULT( WINAPI * PFunCreateDXGIFactory2 )( UINT, REFIID, void** ); + static auto slCreateDXGIFactory2 = reinterpret_cast( GetProcAddress( s_streamlineModule, "CreateDXGIFactory2" ) ); + return slCreateDXGIFactory2( flags, id, factory2 ); } + return CreateDXGIFactory2( flags, id, factory2 ); +} - HRESULT SlD3D12CreateDevice( IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, REFIID id, void** device ) +HRESULT SlD3D12CreateDevice( IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, REFIID id, void** device ) +{ + if( IsAvailable() ) { - if( IsAvailable() ) - { - typedef HRESULT( WINAPI * PFunD3D12CreateDevice )( IUnknown*, D3D_FEATURE_LEVEL, REFIID, void** ); - static auto slD3D12CreateDevice = reinterpret_cast( GetProcAddress( s_streamlineModule, "D3D12CreateDevice" ) ); - return slD3D12CreateDevice( adapter, featureLevel, id, device ); - } - return D3D12CreateDevice( adapter, featureLevel, id, device ); + typedef HRESULT( WINAPI * PFunD3D12CreateDevice )( IUnknown*, D3D_FEATURE_LEVEL, REFIID, void** ); + static auto slD3D12CreateDevice = reinterpret_cast( GetProcAddress( s_streamlineModule, "D3D12CreateDevice" ) ); + return slD3D12CreateDevice( adapter, featureLevel, id, device ); } + return D3D12CreateDevice( adapter, featureLevel, id, device ); +} - bool IsValid( StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info ) +bool IsValid( StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info ) +{ + auto foundThing = s_pluginInfo.find( plugin ); + if( foundThing == s_pluginInfo.end() ) { - auto foundThing = s_pluginInfo.find( plugin ); - if( foundThing == s_pluginInfo.end() ) - { - return false; - } - info = foundThing->second; - return info.available != StreamlineUtils::SLPA_NO; + return false; } + info = foundThing->second; + return info.available != StreamlineUtils::SLPA_NO; +} - bool IsAvailable( StreamlineUtils::StreamlinePlugin plugin ) +bool IsAvailable( StreamlineUtils::StreamlinePlugin plugin ) +{ + if( !IsAvailable() ) { - if( !IsAvailable() ) - { - return false; - } - // We are using NULL adapter on purpose - sl::AdapterInfo adapterInfo{}; + return false; + } + // We are using NULL adapter on purpose + sl::AdapterInfo adapterInfo{}; - StreamlineUtils::PluginInfo info; - if( !IsValid( plugin, info ) ) - { - return false; - } - if( info.available == StreamlineUtils::SLPA_YES ) - { - return true; - } + StreamlineUtils::PluginInfo info; + if( !IsValid( plugin, info ) ) + { + return false; + } + if( info.available == StreamlineUtils::SLPA_YES ) + { + return true; + } - uint32_t pluginId = info.streamlineID; + uint32_t pluginId = info.streamlineID; - DECLARE_STATIC_SL_FUNC( slIsFeatureSupported ); - auto result = s_slIsFeatureSupported( pluginId, adapterInfo ); - if( result != sl::Result::eOk ) + DECLARE_STATIC_SL_FUNC( slIsFeatureSupported ); + auto result = s_slIsFeatureSupported( pluginId, adapterInfo ); + if( result != sl::Result::eOk ) + { + CCP_LOGWARN( "NVidia Streamline plugin '%s' is not supported", info.pluginName ); + switch( result ) { - CCP_LOGWARN( "NVidia Streamline plugin '%s' is not supported", info.pluginName ); - switch( result ) - { - case sl::Result::eErrorOSOutOfDate: // inform user to update OS - CCP_LOGWARN( "OS is out of date, please update OS to use %s", info.pluginName ); - break; - case sl::Result::eErrorDriverOutOfDate: // inform user to update driver - CCP_LOGWARN( "Driver is out of date, please update driver to use %s", info.pluginName ); - break; - case sl::Result::eErrorAdapterNotSupported: - CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); - default: - CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); - }; - info.available = StreamlineUtils::SLPA_NO; - s_pluginInfo[plugin] = info; - return false; - } - - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", info.pluginName ); - info.available = StreamlineUtils::SLPA_YES; + case sl::Result::eErrorOSOutOfDate: // inform user to update OS + CCP_LOGWARN( "OS is out of date, please update OS to use %s", info.pluginName ); + break; + case sl::Result::eErrorDriverOutOfDate: // inform user to update driver + CCP_LOGWARN( "Driver is out of date, please update driver to use %s", info.pluginName ); + break; + case sl::Result::eErrorAdapterNotSupported: + CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); + default: + CCP_LOGWARN( "No adapter found that supports %s", info.pluginName ); + }; + info.available = StreamlineUtils::SLPA_NO; s_pluginInfo[plugin] = info; - return true; + return false; } + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", info.pluginName ); + info.available = StreamlineUtils::SLPA_YES; + s_pluginInfo[plugin] = info; + return true; +} + - void MarkFrameStart() +void MarkFrameStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker eRenderSubmitStart(%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker eRenderSubmitStart(%d)", result ); } } +} - void MarkFrameEnd() +void MarkFrameEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eRenderSubmitEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker eRenderSubmitEnd(%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker eRenderSubmitEnd(%d)", result ); } } +} - void MarkPresentStart() +void MarkPresentStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentStart (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentStart (%d)", result ); } } +} - void MarkPresentEnd() +void MarkPresentEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::ePresentEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } - void MarkUpdateStart() +} +void MarkUpdateStart() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationStart, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationStart, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } - void MarkUpdateEnd() +} +void MarkUpdateEnd() +{ + if( s_reflexEnabled && s_frameToken ) { - if( s_reflexEnabled && s_frameToken ) + DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationEnd, *s_frameToken ) ) ) { - DECLARE_STATIC_FEATURE_FUNC( slReflexSetMarker, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetMarker( sl::ReflexMarker::eSimulationEnd, *s_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); - } + CCP_LOGERR( "Reflex failed to set marker ePresentEnd (%d)", result ); } } +} + +bool IsRunning() +{ + return s_dlssPlugin != nullptr; +} - bool IsRunning() +bool GetDlssPlugin( Tr2DlssPlugin& plugin ) +{ + if( s_dlssPlugin == nullptr ) { - return s_dlssPlugin != nullptr; + return false; } + plugin = *s_dlssPlugin; + return true; +} - bool GetDlssPlugin( Tr2DlssPlugin& plugin ) +bool GetNisPlugin( Tr2NisPlugin& plugin ) +{ + if( s_nisPlugin == nullptr ) { - if( s_dlssPlugin == nullptr ) - { - return false; - } - plugin = *s_dlssPlugin; - return true; + return false; } + plugin = *s_nisPlugin; + return true; +} - bool GetNisPlugin( Tr2NisPlugin& plugin ) +void Toggle( StreamlineUtils::StreamlinePlugin plugin, bool enable ) +{ + StreamlineUtils::PluginInfo info; + // check if the plugin is available + if( !IsAvailable( plugin ) || !IsValid( plugin, info ) ) { - if( s_nisPlugin == nullptr ) - { - return false; - } - plugin = *s_nisPlugin; - return true; + return; } - void Toggle( StreamlineUtils::StreamlinePlugin plugin, bool enable ) + // check if the plugin is already enabled + if( s_pluginInfo[plugin].created == enable ) { - StreamlineUtils::PluginInfo info; - // check if the plugin is available - if( !IsAvailable( plugin ) || !IsValid( plugin, info ) ) - { - return; - } - - // check if the plugin is already enabled - if( s_pluginInfo[plugin].created == enable ) - { - // don't need to do anything - CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it is already %s", enable ? "enable" : "disable", info.pluginName, enable ? "enabled" : "disabled" ); - return; - } + // don't need to do anything + CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it is already %s", enable ? "enable" : "disable", info.pluginName, enable ? "enabled" : "disabled" ); + return; + } - if( plugin == StreamlineUtils::SP_DLSSG ) - { - // special consideration is needed for dlssg which needs to destroy the swapchain, toggle and recreate the swapchain - s_swapchainDestroyer(); - PrepareReflex( enable ); - } + if( plugin == StreamlineUtils::SP_DLSSG ) + { + // special consideration is needed for dlssg which needs to destroy the swapchain, toggle and recreate the swapchain + s_swapchainDestroyer(); + PrepareReflex( enable ); + } - uint32_t pluginId = info.streamlineID; + uint32_t pluginId = info.streamlineID; - DECLARE_STATIC_SL_FUNC( slSetFeatureLoaded ); - if( SL_FAILED( res, s_slSetFeatureLoaded( pluginId, enable ) ) ) - { - CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it failed (%d)", enable ? "enable" : "disable", info.pluginName, res ); - return; - } + DECLARE_STATIC_SL_FUNC( slSetFeatureLoaded ); + if( SL_FAILED( res, s_slSetFeatureLoaded( pluginId, enable ) ) ) + { + CCP_LOGERR( "Trying to %s Nvidia Streamline plugin '%s' but it failed (%d)", enable ? "enable" : "disable", info.pluginName, res ); + return; + } - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is now %s", info.pluginName, enable ? "enabled" : "disabled" ); + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is now %s", info.pluginName, enable ? "enabled" : "disabled" ); - s_pluginInfo[plugin].created = enable; + s_pluginInfo[plugin].created = enable; - // Setup/delete the plugin - switch( plugin ) + // Setup/delete the plugin + switch( plugin ) + { + case StreamlineUtils::SP_DLSS: + s_dlssPlugin = enable ? new Tr2DlssPlugin( 0, false ) : nullptr; + break; + case StreamlineUtils::SP_DLSSG: + if( !s_dlssPlugin ) { - case StreamlineUtils::SP_DLSS: - s_dlssPlugin = enable ? new Tr2DlssPlugin( 0, false ) : nullptr; - break; - case StreamlineUtils::SP_DLSSG: - if( !s_dlssPlugin ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, true ); - } + Toggle( StreamlineUtils::StreamlinePlugin::SP_DLSS, true ); + } - s_dlssPlugin->EnableFrameGeneration( enable ); + s_dlssPlugin->EnableFrameGeneration( enable ); - // recreate the swapchain! - s_swapchainCreator(); - break; - case StreamlineUtils::SP_NIS: - s_nisPlugin = enable ? new Tr2NisPlugin( 0 ) : nullptr; - break; - default: - break; - } + // recreate the swapchain! + s_swapchainCreator(); + break; + case StreamlineUtils::SP_NIS: + s_nisPlugin = enable ? new Tr2NisPlugin( 0 ) : nullptr; + break; + default: + break; } +} - void PrepareReflex( bool enable ) +void PrepareReflex( bool enable ) +{ + if( enable ) { - if( enable ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, true ); - } + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, true ); + } - auto reflexConst = sl::ReflexOptions{}; - reflexConst.mode = enable ? sl::ReflexMode::eLowLatency : sl::ReflexMode::eOff; - reflexConst.useMarkersToOptimize = true; - reflexConst.virtualKey = VK_F13; - reflexConst.frameLimitUs = 0; - DECLARE_STATIC_FEATURE_FUNC( slReflexSetOptions, sl::kFeatureReflex ); - if( SL_FAILED( result, s_slReflexSetOptions( reflexConst ) ) ) - { - CCP_LOGERR( "Reflex failed to set options (%d)", result ); - } + auto reflexConst = sl::ReflexOptions{}; + reflexConst.mode = enable ? sl::ReflexMode::eLowLatency : sl::ReflexMode::eOff; + reflexConst.useMarkersToOptimize = true; + reflexConst.virtualKey = VK_F13; + reflexConst.frameLimitUs = 0; + DECLARE_STATIC_FEATURE_FUNC( slReflexSetOptions, sl::kFeatureReflex ); + if( SL_FAILED( result, s_slReflexSetOptions( reflexConst ) ) ) + { + CCP_LOGERR( "Reflex failed to set options (%d)", result ); + } - if( !enable ) - { - Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); - } - s_reflexEnabled = enable; - } - - void SetCommonConstants( StreamlineUtils::CommonConstants constants ) - { - s_commonConstants.cameraAspectRatio = constants.cameraAspectRatio; - s_commonConstants.cameraFar = constants.cameraFar; - s_commonConstants.cameraFOV = constants.cameraFOV; - s_commonConstants.cameraFwd = AsFloat3( constants.cameraForward ); - s_commonConstants.cameraMotionIncluded = sl::eTrue; - s_commonConstants.cameraNear = constants.cameraNear; - s_commonConstants.cameraPos = AsFloat3( constants.cameraPos ); - s_commonConstants.cameraRight = AsFloat3( constants.cameraRight ); - s_commonConstants.cameraUp = AsFloat3( constants.cameraUp ); - s_commonConstants.cameraViewToClip = AsFloat4x4( constants.projection ); - s_commonConstants.clipToCameraView = AsFloat4x4( constants.invprojection ); - s_commonConstants.clipToPrevClip = AsFloat4x4( constants.clipToPrevClip ); - s_commonConstants.depthInverted = sl::eTrue; - s_commonConstants.jitterOffset = AsFloat2( constants.jitterOffset ); - s_commonConstants.motionVectors3D = sl::eFalse; - s_commonConstants.motionVectorsDilated = sl::eFalse; - s_commonConstants.motionVectorsJittered = sl::eFalse; - s_commonConstants.mvecScale = AsFloat2( constants.motionScale ); - s_commonConstants.orthographicProjection = sl::eFalse; - s_commonConstants.prevClipToClip = AsFloat4x4( constants.prevClipToClip ); - // unused things - s_commonConstants.cameraPinholeOffset = sl::float2( 0, 0 ); - s_commonConstants.reset = constants.reset ? sl::eTrue : sl::eFalse; - - DECLARE_STATIC_SL_FUNC( slSetConstants ); - if( SL_FAILED( result, s_slSetConstants( s_commonConstants, *s_frameToken, 0 ) ) ) - { - CCP_LOGERR( "Setting Nvidia Streamline common constants failed (%d)", result ); - } + if( !enable ) + { + Toggle( StreamlineUtils::StreamlinePlugin::SP_REFLEX, false ); } + s_reflexEnabled = enable; +} - void FreeResources() +void SetCommonConstants( StreamlineUtils::CommonConstants constants ) +{ + s_commonConstants.cameraAspectRatio = constants.cameraAspectRatio; + s_commonConstants.cameraFar = constants.cameraFar; + s_commonConstants.cameraFOV = constants.cameraFOV; + s_commonConstants.cameraFwd = AsFloat3( constants.cameraForward ); + s_commonConstants.cameraMotionIncluded = sl::eTrue; + s_commonConstants.cameraNear = constants.cameraNear; + s_commonConstants.cameraPos = AsFloat3( constants.cameraPos ); + s_commonConstants.cameraRight = AsFloat3( constants.cameraRight ); + s_commonConstants.cameraUp = AsFloat3( constants.cameraUp ); + s_commonConstants.cameraViewToClip = AsFloat4x4( constants.projection ); + s_commonConstants.clipToCameraView = AsFloat4x4( constants.invprojection ); + s_commonConstants.clipToPrevClip = AsFloat4x4( constants.clipToPrevClip ); + s_commonConstants.depthInverted = sl::eTrue; + s_commonConstants.jitterOffset = AsFloat2( constants.jitterOffset ); + s_commonConstants.motionVectors3D = sl::eFalse; + s_commonConstants.motionVectorsDilated = sl::eFalse; + s_commonConstants.motionVectorsJittered = sl::eFalse; + s_commonConstants.mvecScale = AsFloat2( constants.motionScale ); + s_commonConstants.orthographicProjection = sl::eFalse; + s_commonConstants.prevClipToClip = AsFloat4x4( constants.prevClipToClip ); + // unused things + s_commonConstants.cameraPinholeOffset = sl::float2( 0, 0 ); + s_commonConstants.reset = constants.reset ? sl::eTrue : sl::eFalse; + + DECLARE_STATIC_SL_FUNC( slSetConstants ); + if( SL_FAILED( result, s_slSetConstants( s_commonConstants, *s_frameToken, 0 ) ) ) + { + CCP_LOGERR( "Setting Nvidia Streamline common constants failed (%d)", result ); + } +} + +void FreeResources() +{ + if( IsAvailable() ) { - if( IsAvailable() ) - { - DECLARE_STATIC_SL_FUNC( slFreeResources ); + DECLARE_STATIC_SL_FUNC( slFreeResources ); - for( auto& pluginInfo : s_pluginInfo ) + for( auto& pluginInfo : s_pluginInfo ) + { + if( pluginInfo.second.created ) { - if( pluginInfo.second.created ) - { - s_slFreeResources( pluginInfo.second.streamlineID, 0 ); - } + s_slFreeResources( pluginInfo.second.streamlineID, 0 ); } } } } +} Tr2DlssPlugin::Tr2DlssPlugin() { diff --git a/trinityal/dx12/Tr2StreamlineALDx12.h b/trinityal/dx12/Tr2StreamlineALDx12.h index 180cdb480..84db96dc9 100644 --- a/trinityal/dx12/Tr2StreamlineALDx12.h +++ b/trinityal/dx12/Tr2StreamlineALDx12.h @@ -34,133 +34,133 @@ namespace StreamlineUtils { - void Log(sl::LogType type, const char* msg); - sl::Resource GenerateTextureResource(Tr2TextureAL* texture); - sl::CommandBuffer* GetCommandBuffer(Tr2RenderContextAL& renderContext); +void Log( sl::LogType type, const char* msg ); +sl::Resource GenerateTextureResource( Tr2TextureAL* texture ); +sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ); - enum PluginAvailability - { - SLPA_YES, - SLPA_NO, - SLPA_UNKNOWN - }; +enum PluginAvailability +{ + SLPA_YES, + SLPA_NO, + SLPA_UNKNOWN +}; - struct PluginInfo - { - std::string pluginName; - uint32_t streamlineID; - PluginAvailability available; - bool created; - }; +struct PluginInfo +{ + std::string pluginName; + uint32_t streamlineID; + PluginAvailability available; + bool created; +}; - enum StreamlinePlugin - { - SP_DLSS, - SP_DLSSG, - SP_REFLEX, - SP_NIS, - SP_DEBUG, - SP_COUNT - }; - - struct CommonConstants - { - float projection[16]; - float invprojection[16]; - float clipToPrevClip[16]; - float prevClipToClip[16]; - float jitterOffset[2]; - float motionScale[2]; - float cameraPos[3]; - float cameraUp[3]; - float cameraRight[3]; - float cameraForward[3]; - float cameraNear; - float cameraFar; - float cameraFOV; - float cameraAspectRatio; - bool reset; - }; +enum StreamlinePlugin +{ + SP_DLSS, + SP_DLSSG, + SP_REFLEX, + SP_NIS, + SP_DEBUG, + SP_COUNT +}; + +struct CommonConstants +{ + float projection[16]; + float invprojection[16]; + float clipToPrevClip[16]; + float prevClipToClip[16]; + float jitterOffset[2]; + float motionScale[2]; + float cameraPos[3]; + float cameraUp[3]; + float cameraRight[3]; + float cameraForward[3]; + float cameraNear; + float cameraFar; + float cameraFOV; + float cameraAspectRatio; + bool reset; +}; } namespace DlssUtils { - enum DlssMode - { - dmUltraPerformance, - dmPerformance, - dmBalanced, - dmQuality, - dmUltraQuality, - }; - - struct DlssOptions - { - DlssMode mode; - uint32_t outputWidth; - uint32_t outputHeight; - uint32_t renderWidth; - uint32_t renderHeight; - Tr2RenderContextEnum::PixelFormat renderPixelFormat; - Tr2RenderContextEnum::PixelFormat outputPixelFormat; - Tr2RenderContextEnum::PixelFormat motionVectorPixelFormat; - Tr2RenderContextEnum::PixelFormat depthPixelFormat; - bool hdr; - }; - - struct DlssOptimalSetting - { - float sharpness; - uint32_t renderWidth; - uint32_t renderHeight; - }; +enum DlssMode +{ + dmUltraPerformance, + dmPerformance, + dmBalanced, + dmQuality, + dmUltraQuality, +}; - struct DlssResources - { - Tr2TextureAL* input; - Tr2TextureAL* depth; - Tr2TextureAL* velocity; - Tr2TextureAL* output; - Tr2TextureAL* opaqueOnly; - Tr2TextureAL* exposure; - Tr2TextureAL* reactive; - }; +struct DlssOptions +{ + DlssMode mode; + uint32_t outputWidth; + uint32_t outputHeight; + uint32_t renderWidth; + uint32_t renderHeight; + Tr2RenderContextEnum::PixelFormat renderPixelFormat; + Tr2RenderContextEnum::PixelFormat outputPixelFormat; + Tr2RenderContextEnum::PixelFormat motionVectorPixelFormat; + Tr2RenderContextEnum::PixelFormat depthPixelFormat; + bool hdr; +}; + +struct DlssOptimalSetting +{ + float sharpness; + uint32_t renderWidth; + uint32_t renderHeight; +}; + +struct DlssResources +{ + Tr2TextureAL* input; + Tr2TextureAL* depth; + Tr2TextureAL* velocity; + Tr2TextureAL* output; + Tr2TextureAL* opaqueOnly; + Tr2TextureAL* exposure; + Tr2TextureAL* reactive; +}; } namespace NisUtils { - struct NisResources - { - Tr2TextureAL* input; - Tr2TextureAL* output; - }; +struct NisResources +{ + Tr2TextureAL* input; + Tr2TextureAL* output; +}; - struct NisOptions - { - float sharpness; - bool hdr; - }; +struct NisOptions +{ + float sharpness; + bool hdr; +}; } class Tr2DlssPlugin { public: Tr2DlssPlugin(); - Tr2DlssPlugin(uint32_t id, bool framegeneration); + Tr2DlssPlugin( uint32_t id, bool framegeneration ); ~Tr2DlssPlugin(); - DlssUtils::DlssOptimalSetting GetOptimalSettings(DlssUtils::DlssMode mode, uint32_t outputWidth, uint32_t outputHeight); - void SetSettings(DlssUtils::DlssOptions options); - void SetResources(DlssUtils::DlssOptions options, DlssUtils::DlssResources resources, Tr2RenderContextAL& renderContext); - void SetHudLessResource(Tr2TextureAL* hudless, Tr2RenderContextAL& renderContext); - void SetUiAndAlphaResource(Tr2TextureAL* uiAlpha, Tr2RenderContextAL& renderContext); - void Dispatch(Tr2RenderContextAL& renderContext); + DlssUtils::DlssOptimalSetting GetOptimalSettings( DlssUtils::DlssMode mode, uint32_t outputWidth, uint32_t outputHeight ); + void SetSettings( DlssUtils::DlssOptions options ); + void SetResources( DlssUtils::DlssOptions options, DlssUtils::DlssResources resources, Tr2RenderContextAL& renderContext ); + void SetHudLessResource( Tr2TextureAL* hudless, Tr2RenderContextAL& renderContext ); + void SetUiAndAlphaResource( Tr2TextureAL* uiAlpha, Tr2RenderContextAL& renderContext ); + void Dispatch( Tr2RenderContextAL& renderContext ); uint64_t GetEstimatedVRAMUsageInBytes(); uint32_t GetMinWidthOrHeight(); uint32_t GetNumFramesActuallyPresented(); - void EnableFrameGeneration(bool enable); + void EnableFrameGeneration( bool enable ); protected: uint32_t m_id; @@ -178,12 +178,12 @@ class Tr2NisPlugin { public: Tr2NisPlugin(); - Tr2NisPlugin(uint32_t id); + Tr2NisPlugin( uint32_t id ); ~Tr2NisPlugin(); - void SetSettings(NisUtils::NisOptions options); - void SetResources(NisUtils::NisResources resources, Tr2RenderContextAL& renderContext); - void Dispatch(Tr2RenderContextAL& renderContext); + void SetSettings( NisUtils::NisOptions options ); + void SetResources( NisUtils::NisResources resources, Tr2RenderContextAL& renderContext ); + void Dispatch( Tr2RenderContextAL& renderContext ); private: uint32_t m_id; @@ -192,112 +192,112 @@ class Tr2NisPlugin namespace Tr2Streamline { - enum Status - { - UNCHECKED, - AVAILABLE, - UNAVAILABLE, - INITIALIZED, - UNINITIALIZED, - ATTACHED - }; - - // static things - bool IsAvailable(); - bool IsAvailable(StreamlineUtils::StreamlinePlugin plugin); - bool IsInitialized(); - - void MarkFrameStart(); - void MarkFrameEnd(); - void MarkPresentStart(); - void MarkPresentEnd(); - void MarkUpdateStart(); - void MarkUpdateEnd(); - void SetSwapchainCreator(std::function creator); - void SetSwapchainDestroyer(std::function destroyer); - - void UpdateFrameToken(); - - HMODULE GetStreamlineModule(); - - template - void CheckForProxy(T thing, const std::string& message) +enum Status +{ + UNCHECKED, + AVAILABLE, + UNAVAILABLE, + INITIALIZED, + UNINITIALIZED, + ATTACHED +}; + +// static things +bool IsAvailable(); +bool IsAvailable( StreamlineUtils::StreamlinePlugin plugin ); +bool IsInitialized(); + +void MarkFrameStart(); +void MarkFrameEnd(); +void MarkPresentStart(); +void MarkPresentEnd(); +void MarkUpdateStart(); +void MarkUpdateEnd(); +void SetSwapchainCreator( std::function creator ); +void SetSwapchainDestroyer( std::function destroyer ); + +void UpdateFrameToken(); + +HMODULE GetStreamlineModule(); + +template +void CheckForProxy( T thing, const std::string& message ) +{ + // Use special GUID to to obtain the underlying native interface if SL proxy is used, returns null otherwise + IID riid; + IIDFromString( L"{ADEC44E2-61F0-45C3-AD9F-1B37379284FF}", &riid ); + // This can be ID3D12Device, IDXGIFactory, ID3D12GraphicsCommandList or any other interface which has SL proxy + ATL::CComPtr native = nullptr; + thing->QueryInterface( riid, reinterpret_cast( &native.p ) ); + + if( native ) { - // Use special GUID to to obtain the underlying native interface if SL proxy is used, returns null otherwise - IID riid; - IIDFromString(L"{ADEC44E2-61F0-45C3-AD9F-1B37379284FF}", &riid); - // This can be ID3D12Device, IDXGIFactory, ID3D12GraphicsCommandList or any other interface which has SL proxy - ATL::CComPtr native = nullptr; - thing->QueryInterface(riid, reinterpret_cast(&native.p)); - - if (native) - { - CCP_LOG("%s - is proxy!", message); - native.Release(); - } - else - { - - CCP_LOG("%s - is not a proxy!", message); - } - }; - - - bool Initialize(); - void Shutdown(); - - template - ATL::CComPtr CreateProxy( ATL::CComPtr native ) + CCP_LOG( "%s - is proxy!", message ); + native.Release(); + } + else { - if( !IsAvailable() ) - { - return native; - } - DECLARE_STATIC_SL_FUNC( slUpgradeInterface ); - ATL::CComPtr proxy; - if( SL_FAILED( res, s_slUpgradeInterface( (void**)&proxy.p ) ) ) - { - CCP_LOGWARN( "Could not upgrade interface to proxy device (%d)", res ); - } - CCP_ASSERT( proxy != nullptr ); - return proxy; - }; - template - ATL::CComPtr CreateNative( ATL::CComPtr proxy ) + CCP_LOG( "%s - is not a proxy!", message ); + } +}; + + +bool Initialize(); +void Shutdown(); + +template +ATL::CComPtr CreateProxy( ATL::CComPtr native ) +{ + if( !IsAvailable() ) { - if( !IsAvailable() ) - { - return proxy; - } - DECLARE_STATIC_SL_FUNC( slGetNativeInterface ); - ATL::CComPtr native; - if( SL_FAILED( res, s_slGetNativeInterface( proxy.p, (void**)&native.p ) ) ) - { - CCP_LOGWARN( "Could not get native interface from proxy device (%d)", res ); - } - CCP_ASSERT( native != nullptr ); return native; - }; + } + DECLARE_STATIC_SL_FUNC( slUpgradeInterface ); + ATL::CComPtr proxy; + if( SL_FAILED( res, s_slUpgradeInterface( (void**)&proxy.p ) ) ) + { + CCP_LOGWARN( "Could not upgrade interface to proxy device (%d)", res ); + } + CCP_ASSERT( proxy != nullptr ); + return proxy; +}; + +template +ATL::CComPtr CreateNative( ATL::CComPtr proxy ) +{ + if( !IsAvailable() ) + { + return proxy; + } + DECLARE_STATIC_SL_FUNC( slGetNativeInterface ); + ATL::CComPtr native; + if( SL_FAILED( res, s_slGetNativeInterface( proxy.p, (void**)&native.p ) ) ) + { + CCP_LOGWARN( "Could not get native interface from proxy device (%d)", res ); + } + CCP_ASSERT( native != nullptr ); + return native; +}; - void Attach(void* d3dDevice); +void Attach( void* d3dDevice ); - HRESULT SlCreateDXGIFactory(REFIID id, void** factory); - HRESULT SlCreateDXGIFactory1(REFIID id, void** factory1); - HRESULT SlCreateDXGIFactory2(UINT flags, REFIID id, void** factory2); - HRESULT SlD3D12CreateDevice(IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, REFIID id, void** device); +HRESULT SlCreateDXGIFactory( REFIID id, void** factory ); +HRESULT SlCreateDXGIFactory1( REFIID id, void** factory1 ); +HRESULT SlCreateDXGIFactory2( UINT flags, REFIID id, void** factory2 ); +HRESULT SlD3D12CreateDevice( IUnknown* adapter, D3D_FEATURE_LEVEL featureLevel, REFIID id, void** device ); - bool IsRunning(); - bool GetDlssPlugin(Tr2DlssPlugin& plugin); - bool GetNisPlugin(Tr2NisPlugin& plugin); - void Toggle(StreamlineUtils::StreamlinePlugin plugin, bool enable); - void SetCommonConstants(StreamlineUtils::CommonConstants constants); +bool IsRunning(); +bool GetDlssPlugin( Tr2DlssPlugin& plugin ); +bool GetNisPlugin( Tr2NisPlugin& plugin ); +void Toggle( StreamlineUtils::StreamlinePlugin plugin, bool enable ); +void SetCommonConstants( StreamlineUtils::CommonConstants constants ); - void FreeResources(); +void FreeResources(); - void PrepareReflex(bool enable); - bool IsValid(StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info); +void PrepareReflex( bool enable ); +bool IsValid( StreamlineUtils::StreamlinePlugin plugin, StreamlineUtils::PluginInfo& info ); }; #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2SwapChainALDx12.cpp b/trinityal/dx12/Tr2SwapChainALDx12.cpp index 104c9ef54..d87dde80a 100644 --- a/trinityal/dx12/Tr2SwapChainALDx12.cpp +++ b/trinityal/dx12/Tr2SwapChainALDx12.cpp @@ -17,245 +17,245 @@ using namespace Tr2RenderContextEnum; namespace Tr2SwapChainUtils { - DXGI_FORMAT SafeConvertD3DBackBufferFormat( Tr2RenderContextEnum::PixelFormat bbFormat ) - { - DXGI_FORMAT out = static_cast( bbFormat ); - if( out == DXGI_FORMAT_B8G8R8X8_UNORM ) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - if( out == Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - return out; - } - - ALResult CreateSwapChain( - CComPtr& swapChain, - Tr2WindowHandle focusWindow, - const Tr2PresentParametersAL& presentationParameters, - ID3D12CommandQueue* commandQueue, - IDXGIOutput* output, - Tr2PrimaryRenderContextAL& renderContext ) +DXGI_FORMAT SafeConvertD3DBackBufferFormat( Tr2RenderContextEnum::PixelFormat bbFormat ) +{ + DXGI_FORMAT out = static_cast( bbFormat ); + if( out == DXGI_FORMAT_B8G8R8X8_UNORM ) { - CComPtr factory; - - UINT createFactoryFlags = 0; - if( g_requestDeviceDebugLayer ) - { - createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG; - } - - CR_RETURN_HR( renderContext.CreateFactory2( createFactoryFlags, factory ) ); - - DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; - swapChainDesc.Width = presentationParameters.mode.width; - swapChainDesc.Height = presentationParameters.mode.height; - swapChainDesc.Format = SafeConvertD3DBackBufferFormat( presentationParameters.mode.format ); - swapChainDesc.Stereo = FALSE; - swapChainDesc.SampleDesc.Count = std::max( presentationParameters.msaaType, 1u ); - swapChainDesc.SampleDesc.Quality = presentationParameters.msaaQuality; - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferCount = Tr2SwapChainUtils::BACK_BUFFER_COUNT; - swapChainDesc.Scaling = DXGI_SCALING_STRETCH;// DXGI_MODE_SCALING( presentationParameters.mode.scaling ); - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; - swapChainDesc.Flags = 0; - - if( presentationParameters.variableRefreshRateSupported ) - { - swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; - } - - auto wnd = Tr2WindowHandle( presentationParameters.outputWindow ); - if( !presentationParameters.outputWindow ) - { - wnd = focusWindow; - } - - CR_RETURN_HR( renderContext.CreateSwapChainForHwnd( factory, commandQueue, wnd, &swapChainDesc, nullptr, output, swapChain ) ); - - CR_RETURN_HR( factory->MakeWindowAssociation( wnd, DXGI_MWA_NO_ALT_ENTER ) ); - return S_OK; + return DXGI_FORMAT_B8G8R8A8_UNORM; } - - ALResult FillPresentationParameters( Tr2PresentParametersAL& presentationParameters, Tr2WindowHandle windowHandle ) + if( out == Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) { - RECT rect; - if( !GetClientRect( reinterpret_cast( windowHandle ), &rect ) ) - { - return E_INVALIDARG; - } - if( rect.left >= rect.right || rect.top >= rect.bottom ) - { - return E_INVALIDCALL; - } - Tr2PresentParametersAL pp = { - { uint32_t( rect.right - rect.left ), uint32_t( rect.bottom - rect.top ), 0, 0, PIXEL_FORMAT_B8G8R8X8_UNORM, SCANLINE_ORDER_UNSPECIFIED, DISPLAY_SCALING_UNSPECIFIED }, - Tr2SwapChainUtils::BACK_BUFFER_COUNT, - 1, - 0, - SWAP_EFFECT_DISCARD, - windowHandle, - true, - false, - PRESENT_INTERVAL_IMMEDIATE, - false - }; - presentationParameters = pp; - return S_OK; + return DXGI_FORMAT_B8G8R8A8_UNORM; } + return out; } -namespace TrinityALImpl +ALResult CreateSwapChain( + CComPtr& swapChain, + Tr2WindowHandle focusWindow, + const Tr2PresentParametersAL& presentationParameters, + ID3D12CommandQueue* commandQueue, + IDXGIOutput* output, + Tr2PrimaryRenderContextAL& renderContext ) { + CComPtr factory; - Tr2SwapChainAL::Tr2SwapChainAL() - :m_owner( nullptr ) + UINT createFactoryFlags = 0; + if( g_requestDeviceDebugLayer ) { - m_backBuffer.m_texture = std::make_shared(); - memset( &m_presentParameters, 0, sizeof( m_presentParameters ) ); + createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG; } - Tr2SwapChainAL::~Tr2SwapChainAL() + CR_RETURN_HR( renderContext.CreateFactory2( createFactoryFlags, factory ) ); + + DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; + swapChainDesc.Width = presentationParameters.mode.width; + swapChainDesc.Height = presentationParameters.mode.height; + swapChainDesc.Format = SafeConvertD3DBackBufferFormat( presentationParameters.mode.format ); + swapChainDesc.Stereo = FALSE; + swapChainDesc.SampleDesc.Count = std::max( presentationParameters.msaaType, 1u ); + swapChainDesc.SampleDesc.Quality = presentationParameters.msaaQuality; + swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapChainDesc.BufferCount = Tr2SwapChainUtils::BACK_BUFFER_COUNT; + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; // DXGI_MODE_SCALING( presentationParameters.mode.scaling ); + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; + swapChainDesc.Flags = 0; + + if( presentationParameters.variableRefreshRateSupported ) { - Destroy(); + swapChainDesc.Flags |= DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; } - ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ) + auto wnd = Tr2WindowHandle( presentationParameters.outputWindow ); + if( !presentationParameters.outputWindow ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + wnd = focusWindow; + } - FORWARD_HR( renderContext.FlushAndSyncDx12( renderContext ) ); - renderContext.FlushPendingRelease(); // Make sure we have no references to the old swap chain lingering around + CR_RETURN_HR( renderContext.CreateSwapChainForHwnd( factory, commandQueue, wnd, &swapChainDesc, nullptr, output, swapChain ) ); - Tr2PresentParametersAL presentationParameters; - CR_RETURN_HR( Tr2SwapChainUtils::FillPresentationParameters( presentationParameters, windowHandle ) ); + CR_RETURN_HR( factory->MakeWindowAssociation( wnd, DXGI_MWA_NO_ALT_ENTER ) ); + return S_OK; +} - return CreateDx12( presentationParameters, nullptr, renderContext.m_commandQueue, renderContext ); +ALResult FillPresentationParameters( Tr2PresentParametersAL& presentationParameters, Tr2WindowHandle windowHandle ) +{ + RECT rect; + if( !GetClientRect( reinterpret_cast( windowHandle ), &rect ) ) + { + return E_INVALIDARG; + } + if( rect.left >= rect.right || rect.top >= rect.bottom ) + { + return E_INVALIDCALL; } + Tr2PresentParametersAL pp = { + { uint32_t( rect.right - rect.left ), uint32_t( rect.bottom - rect.top ), 0, 0, PIXEL_FORMAT_B8G8R8X8_UNORM, SCANLINE_ORDER_UNSPECIFIED, DISPLAY_SCALING_UNSPECIFIED }, + Tr2SwapChainUtils::BACK_BUFFER_COUNT, + 1, + 0, + SWAP_EFFECT_DISCARD, + windowHandle, + true, + false, + PRESENT_INTERVAL_IMMEDIATE, + false + }; + presentationParameters = pp; + return S_OK; +} +} + +namespace TrinityALImpl +{ - ALResult Tr2SwapChainAL::CreateDx12( const Tr2PresentParametersAL& presentationParameters, IDXGIOutput* output, ID3D12CommandQueue* commandQueue, Tr2PrimaryRenderContextAL &renderContext ) +Tr2SwapChainAL::Tr2SwapChainAL() : + m_owner( nullptr ) +{ + m_backBuffer.m_texture = std::make_shared(); + memset( &m_presentParameters, 0, sizeof( m_presentParameters ) ); +} + +Tr2SwapChainAL::~Tr2SwapChainAL() +{ + Destroy(); +} + +ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { - CComPtr swapChain; - FORWARD_HR( Tr2SwapChainUtils::CreateSwapChain( swapChain, presentationParameters.outputWindow, presentationParameters, commandQueue, output, renderContext ) ); + return E_INVALIDCALL; + } - std::vector> rtvs; - std::vector> backBuffers; - FORWARD_HR( GetBackBuffers( &renderContext, backBuffers, rtvs, swapChain ) ); + FORWARD_HR( renderContext.FlushAndSyncDx12( renderContext ) ); + renderContext.FlushPendingRelease(); // Make sure we have no references to the old swap chain lingering around - m_swapChain = swapChain; - m_presentParameters = presentationParameters; - m_owner = &renderContext; + Tr2PresentParametersAL presentationParameters; + CR_RETURN_HR( Tr2SwapChainUtils::FillPresentationParameters( presentationParameters, windowHandle ) ); - m_backBuffer.m_texture->AssignFromSwapChainDx12( backBuffers, rtvs, renderContext ); - m_backBuffer.m_texture->SetSwapChainBufferIndexDx12( swapChain->GetCurrentBackBufferIndex() ); + return CreateDx12( presentationParameters, nullptr, renderContext.m_commandQueue, renderContext ); +} - renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( m_backBuffer.m_texture->GetResourceDx12(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET ) ); +ALResult Tr2SwapChainAL::CreateDx12( const Tr2PresentParametersAL& presentationParameters, IDXGIOutput* output, ID3D12CommandQueue* commandQueue, Tr2PrimaryRenderContextAL& renderContext ) +{ + CComPtr swapChain; + FORWARD_HR( Tr2SwapChainUtils::CreateSwapChain( swapChain, presentationParameters.outputWindow, presentationParameters, commandQueue, output, renderContext ) ); - return S_OK; - } + std::vector> rtvs; + std::vector> backBuffers; + FORWARD_HR( GetBackBuffers( &renderContext, backBuffers, rtvs, swapChain ) ); - void Tr2SwapChainAL::Destroy() - { - if( m_owner ) - { - m_backBuffer.m_texture->Destroy(); + m_swapChain = swapChain; + m_presentParameters = presentationParameters; + m_owner = &renderContext; - m_owner = nullptr; - m_swapChain = nullptr; + m_backBuffer.m_texture->AssignFromSwapChainDx12( backBuffers, rtvs, renderContext ); + m_backBuffer.m_texture->SetSwapChainBufferIndexDx12( swapChain->GetCurrentBackBufferIndex() ); - m_presentParameters = Tr2PresentParametersAL(); - } - } + renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( m_backBuffer.m_texture->GetResourceDx12(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET ) ); - bool Tr2SwapChainAL::IsValid() const - { - return m_swapChain != nullptr; - } + return S_OK; +} - ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& renderContext ) +void Tr2SwapChainAL::Destroy() +{ + if( m_owner ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - m_owner->ScheduleSwapchainPresentDx12( m_swapChain, m_backBuffer, m_presentParameters.presentInterval & 0xf ); - return S_OK; - } + m_backBuffer.m_texture->Destroy(); - uint32_t Tr2SwapChainAL::GetWidth() const - { - return m_presentParameters.mode.width; - } + m_owner = nullptr; + m_swapChain = nullptr; - uint32_t Tr2SwapChainAL::GetHeight() const - { - return m_presentParameters.mode.height; + m_presentParameters = Tr2PresentParametersAL(); } +} + +bool Tr2SwapChainAL::IsValid() const +{ + return m_swapChain != nullptr; +} - Tr2ALMemoryType Tr2SwapChainAL::GetMemoryClass() const +ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) { - return AL_MEMORY_MANAGED; + return E_INVALIDCALL; } - - /** Gather backbuffer textures and RTVs (JB: Make this public-static since it was duplicated) */ - ALResult Tr2SwapChainAL::GetBackBuffers( - Tr2PrimaryRenderContextAL* primaryContext, - std::vector>& backBuffers, - std::vector>& rtvs, - IDXGISwapChain1* swapChain ) + if( !renderContext.IsValid() ) { - DXGI_SWAP_CHAIN_DESC scDesc; - swapChain->GetDesc( &scDesc ); + return E_INVALIDARG; + } - for( uint32_t i = 0; i < Tr2SwapChainUtils::BACK_BUFFER_COUNT; ++i ) - { - CComPtr backBuffer; - CR_RETURN_HR( swapChain->GetBuffer( i, IID_PPV_ARGS( &backBuffer ) ) ); - backBuffers.push_back( backBuffer ); + m_owner->ScheduleSwapchainPresentDx12( m_swapChain, m_backBuffer, m_presentParameters.presentInterval & 0xf ); + return S_OK; +} - std::shared_ptr view; - primaryContext->CreateRenderTargetView( backBuffer, nullptr, view ); - rtvs.push_back( view ); +uint32_t Tr2SwapChainAL::GetWidth() const +{ + return m_presentParameters.mode.width; +} +uint32_t Tr2SwapChainAL::GetHeight() const +{ + return m_presentParameters.mode.height; +} - D3D12_RENDER_TARGET_VIEW_DESC rtv = { DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( Tr2RenderContextEnum::PixelFormat( scDesc.BufferDesc.Format ) ) ), D3D12_RTV_DIMENSION_TEXTURE2D }; - rtv.Texture2D.MipSlice = rtv.Texture2D.PlaneSlice = 0; +Tr2ALMemoryType Tr2SwapChainAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - primaryContext->CreateRenderTargetView( backBuffer, &rtv, view ); - rtvs.push_back( view ); - } - return S_OK; - } +/** Gather backbuffer textures and RTVs (JB: Make this public-static since it was duplicated) */ +ALResult Tr2SwapChainAL::GetBackBuffers( + Tr2PrimaryRenderContextAL* primaryContext, + std::vector>& backBuffers, + std::vector>& rtvs, + IDXGISwapChain1* swapChain ) +{ + DXGI_SWAP_CHAIN_DESC scDesc; + swapChain->GetDesc( &scDesc ); - void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + for( uint32_t i = 0; i < Tr2SwapChainUtils::BACK_BUFFER_COUNT; ++i ) { - description["type"] = "Tr2SwapChainAL"; - description["width"] = std::to_string( m_presentParameters.mode.width ); - description["height"] = std::to_string( m_presentParameters.mode.height ); - description["name"] = m_name; + CComPtr backBuffer; + CR_RETURN_HR( swapChain->GetBuffer( i, IID_PPV_ARGS( &backBuffer ) ) ); + backBuffers.push_back( backBuffer ); + + std::shared_ptr view; + primaryContext->CreateRenderTargetView( backBuffer, nullptr, view ); + rtvs.push_back( view ); + + + D3D12_RENDER_TARGET_VIEW_DESC rtv = { DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( Tr2RenderContextEnum::PixelFormat( scDesc.BufferDesc.Format ) ) ), D3D12_RTV_DIMENSION_TEXTURE2D }; + rtv.Texture2D.MipSlice = rtv.Texture2D.PlaneSlice = 0; + + primaryContext->CreateRenderTargetView( backBuffer, &rtv, view ); + rtvs.push_back( view ); } + return S_OK; +} + +void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SwapChainAL"; + description["width"] = std::to_string( m_presentParameters.mode.width ); + description["height"] = std::to_string( m_presentParameters.mode.height ); + description["name"] = m_name; +} - ALResult Tr2SwapChainAL::SetName( const char* name ) +ALResult Tr2SwapChainAL::SetName( const char* name ) +{ + m_name = name; + if( m_swapChain ) { - m_name = name; - if( m_swapChain ) - { - m_swapChain->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); - } - return m_backBuffer.SetName( name ); + m_swapChain->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); } + return m_backBuffer.SetName( name ); +} - } +} #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2SwapChainALDx12.h b/trinityal/dx12/Tr2SwapChainALDx12.h index 383ef14b8..59489ebad 100644 --- a/trinityal/dx12/Tr2SwapChainALDx12.h +++ b/trinityal/dx12/Tr2SwapChainALDx12.h @@ -12,64 +12,64 @@ namespace Tr2SwapChainUtils { - const uint32_t BACK_BUFFER_COUNT = 3; - - DXGI_FORMAT SafeConvertD3DBackBufferFormat( Tr2RenderContextEnum::PixelFormat bbFormat ); - - ALResult CreateSwapChain( - CComPtr& swapChain, - Tr2WindowHandle focusWindow, - const Tr2PresentParametersAL& presentationParameters, - ID3D12CommandQueue* commandQueue, - IDXGIOutput* output, - Tr2PrimaryRenderContextAL& renderContext ); - - ALResult FillPresentationParameters( Tr2PresentParametersAL& presentationParameters, Tr2WindowHandle windowHandle ); +const uint32_t BACK_BUFFER_COUNT = 3; + +DXGI_FORMAT SafeConvertD3DBackBufferFormat( Tr2RenderContextEnum::PixelFormat bbFormat ); + +ALResult CreateSwapChain( + CComPtr& swapChain, + Tr2WindowHandle focusWindow, + const Tr2PresentParametersAL& presentationParameters, + ID3D12CommandQueue* commandQueue, + IDXGIOutput* output, + Tr2PrimaryRenderContextAL& renderContext ); + +ALResult FillPresentationParameters( Tr2PresentParametersAL& presentationParameters, Tr2WindowHandle windowHandle ); } namespace TrinityALImpl { - class Tr2SwapChainAL : public Tr2DeviceResourceAL - { - public: - Tr2SwapChainAL(); - ~Tr2SwapChainAL(); +class Tr2SwapChainAL : public Tr2DeviceResourceAL +{ +public: + Tr2SwapChainAL(); + ~Tr2SwapChainAL(); - ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ); - void Destroy(); + ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - ALResult Present( Tr2RenderContextAL& renderContext ); + ALResult Present( Tr2RenderContextAL& renderContext ); - uint32_t GetWidth() const; - uint32_t GetHeight() const; + uint32_t GetWidth() const; + uint32_t GetHeight() const; - ::Tr2TextureAL m_backBuffer; + ::Tr2TextureAL m_backBuffer; - Tr2ALMemoryType GetMemoryClass() const; + Tr2ALMemoryType GetMemoryClass() const; - ALResult CreateDx12( const Tr2PresentParametersAL& presentationParameters, IDXGIOutput* output, ID3D12CommandQueue* commandQueue, Tr2PrimaryRenderContextAL &renderContext ); + ALResult CreateDx12( const Tr2PresentParametersAL& presentationParameters, IDXGIOutput* output, ID3D12CommandQueue* commandQueue, Tr2PrimaryRenderContextAL& renderContext ); - static ALResult GetBackBuffers( - Tr2PrimaryRenderContextAL* primaryContext, - std::vector>& backBuffers, - std::vector>& rtvs, - IDXGISwapChain1* swapChain ); + static ALResult GetBackBuffers( + Tr2PrimaryRenderContextAL* primaryContext, + std::vector>& backBuffers, + std::vector>& rtvs, + IDXGISwapChain1* swapChain ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2SwapChainAL( const Tr2SwapChainAL& ) /* = delete */; - Tr2SwapChainAL& operator=( const Tr2SwapChainAL& ) /* = delete */; +private: + Tr2SwapChainAL( const Tr2SwapChainAL& ) /* = delete */; + Tr2SwapChainAL& operator=( const Tr2SwapChainAL& ) /* = delete */; - CComPtr m_swapChain; - Tr2PrimaryRenderContextAL* m_owner; - Tr2PresentParametersAL m_presentParameters; - std::string m_name; + CComPtr m_swapChain; + Tr2PrimaryRenderContextAL* m_owner; + Tr2PresentParametersAL m_presentParameters; + std::string m_name; - friend class Tr2PrimaryRenderContextAL; - }; + friend class Tr2PrimaryRenderContextAL; +}; } #endif diff --git a/trinityal/dx12/Tr2TextureALDx12.cpp b/trinityal/dx12/Tr2TextureALDx12.cpp index f3cf04bc2..c51a92174 100644 --- a/trinityal/dx12/Tr2TextureALDx12.cpp +++ b/trinityal/dx12/Tr2TextureALDx12.cpp @@ -16,175 +16,175 @@ using namespace Tr2RenderContextEnum; namespace { - ALResult CheckCreationFlags( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage ) +ALResult CheckCreationFlags( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage ) +{ + if( HasBufferFlags( gpuUsage ) ) { - if( HasBufferFlags( gpuUsage ) ) - { - return E_INVALIDARG; - } + return E_INVALIDARG; + } - if( msaa.samples > 1 ) - { - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - return E_INVALIDARG; - } - if( cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - return E_INVALIDARG; - } - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - if( desc.GetArraySize() != 6 ) - { - return E_INVALIDARG; - } - } - else if( desc.GetArraySize() > 1 ) - { - return E_INVALIDARG; - } - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - return E_INVALIDARG; - } - if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) + if( msaa.samples > 1 ) + { + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { return E_INVALIDARG; } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + if( cpuUsage != Tr2CpuUsage::NONE ) { return E_INVALIDARG; } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) { return E_INVALIDARG; } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) + } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) + { + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - return E_INVALIDARG; + if( desc.GetArraySize() != 6 ) + { + return E_INVALIDARG; + } } - if( HasFlag( cpuUsage, Tr2CpuUsage::READ ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + else if( desc.GetArraySize() > 1 ) { return E_INVALIDARG; } - return S_OK; } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + return E_INVALIDARG; + } + if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; + } + if( HasFlag( cpuUsage, Tr2CpuUsage::READ ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + return E_INVALIDARG; + } + return S_OK; +} - D3D12_RESOURCE_DESC TextureDesc( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) +D3D12_RESOURCE_DESC TextureDesc( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) +{ + D3D12_RESOURCE_DESC resourceDesc = {}; + resourceDesc.Width = desc.GetWidth(); + resourceDesc.Height = desc.GetHeight(); + switch( desc.GetType() ) { - D3D12_RESOURCE_DESC resourceDesc = {}; - resourceDesc.Width = desc.GetWidth(); - resourceDesc.Height = desc.GetHeight(); - switch( desc.GetType() ) - { - case TEX_TYPE_1D: - resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE1D; - resourceDesc.DepthOrArraySize = UINT16( desc.GetArraySize() ); - break; - case TEX_TYPE_3D: - resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D; - resourceDesc.DepthOrArraySize = UINT16( desc.GetDepth() ); - break; - default: - resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - resourceDesc.DepthOrArraySize = UINT16( desc.GetArraySize() ); - break; - } - resourceDesc.MipLevels = UINT16( desc.GetTrueMipCount() ); - resourceDesc.Format = DXGI_FORMAT( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); - resourceDesc.SampleDesc.Count = msaa.samples; - resourceDesc.SampleDesc.Quality = msaa.quality; - resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - resourceDesc.Flags = flags; - return resourceDesc; + case TEX_TYPE_1D: + resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE1D; + resourceDesc.DepthOrArraySize = UINT16( desc.GetArraySize() ); + break; + case TEX_TYPE_3D: + resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D; + resourceDesc.DepthOrArraySize = UINT16( desc.GetDepth() ); + break; + default: + resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + resourceDesc.DepthOrArraySize = UINT16( desc.GetArraySize() ); + break; } + resourceDesc.MipLevels = UINT16( desc.GetTrueMipCount() ); + resourceDesc.Format = DXGI_FORMAT( Tr2RenderContextEnum::MakeTypeless( desc.GetFormat() ) ); + resourceDesc.SampleDesc.Count = msaa.samples; + resourceDesc.SampleDesc.Quality = msaa.quality; + resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; + resourceDesc.Flags = flags; + return resourceDesc; +} - DXGI_FORMAT GetSrvFormat( Tr2RenderContextEnum::PixelFormat format ) +DXGI_FORMAT GetSrvFormat( Tr2RenderContextEnum::PixelFormat format ) +{ + switch( format ) { - switch( format ) - { - case Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT: - return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; - case Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT: - return DXGI_FORMAT_R32_FLOAT; - default: - return DXGI_FORMAT( format ); - } + case Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT: + return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; + case Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT: + return DXGI_FORMAT_R32_FLOAT; + default: + return DXGI_FORMAT( format ); } } +} namespace { - bool FormatIsBGR( DXGI_FORMAT format ) +bool FormatIsBGR( DXGI_FORMAT format ) +{ + switch( format ) { - switch( format ) - { - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return true; - default: - return false; - } + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + return true; + default: + return false; } +} - bool FormatIsSRGB( DXGI_FORMAT format ) +bool FormatIsSRGB( DXGI_FORMAT format ) +{ + switch( format ) { - switch( format ) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return true; - default: - return false; - } + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + return true; + default: + return false; } +} - DXGI_FORMAT ConvertSRVtoResourceFormat( DXGI_FORMAT format ) +DXGI_FORMAT ConvertSRVtoResourceFormat( DXGI_FORMAT format ) +{ + switch( format ) { - switch( format ) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return DXGI_FORMAT_R32G32B32A32_TYPELESS; - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SINT: - return DXGI_FORMAT_R16G16B16A16_TYPELESS; - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SINT: - return DXGI_FORMAT_R8G8B8A8_TYPELESS; - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - return DXGI_FORMAT_R32_TYPELESS; - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SINT: - return DXGI_FORMAT_R16_TYPELESS; - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SINT: - return DXGI_FORMAT_R8_TYPELESS; - default: - return format; - } + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + return DXGI_FORMAT_R32G32B32A32_TYPELESS; + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SINT: + return DXGI_FORMAT_R16G16B16A16_TYPELESS; + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SINT: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case DXGI_FORMAT_R32_FLOAT: + case DXGI_FORMAT_R32_UINT: + case DXGI_FORMAT_R32_SINT: + return DXGI_FORMAT_R32_TYPELESS; + case DXGI_FORMAT_R16_FLOAT: + case DXGI_FORMAT_R16_UINT: + case DXGI_FORMAT_R16_SINT: + return DXGI_FORMAT_R16_TYPELESS; + case DXGI_FORMAT_R8_UNORM: + case DXGI_FORMAT_R8_UINT: + case DXGI_FORMAT_R8_SINT: + return DXGI_FORMAT_R8_TYPELESS; + default: + return format; } +} @@ -193,580 +193,580 @@ namespace namespace TrinityALImpl { - struct Tr2TextureAL::MipMapGenerator +struct Tr2TextureAL::MipMapGenerator +{ + MipMapGenerator( Tr2PrimaryRenderContextAL& device ) : + m_device( device ) + { + } + + ~MipMapGenerator() + { + if( m_staging ) + { + RELEASE_LATER( &m_device, m_staging ); + } + if( m_descriptorHeap ) + { + RELEASE_LATER( &m_device, m_descriptorHeap ); + } + if( m_resourceCopy ) + { + RELEASE_LATER( &m_device, m_resourceCopy ); + } + if( m_bgrHeap ) + { + RELEASE_LATER( &m_device, m_bgrHeap ); + } + if( m_bgrResourceCopy ) + { + RELEASE_LATER( &m_device, m_bgrResourceCopy ); + } + if( m_bgrAliasCopy ) + { + RELEASE_LATER( &m_device, m_bgrAliasCopy ); + } + } + + ALResult GenerateMips_UnorderedAccessPath( _In_ ID3D12Resource* resource, DXGI_FORMAT format, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) { - MipMapGenerator( Tr2PrimaryRenderContextAL& device ) : - m_device( device ) + const auto desc = resource->GetDesc(); + if( FormatIsBGR( format ) || FormatIsSRGB( format ) ) { + return E_INVALIDARG; } - ~MipMapGenerator() + D3D12_RESOURCE_STATES readState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; + CComPtr staging; + // Create a staging resource if we have to + if( ( desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ) == 0 ) { - if( m_staging ) + if( !m_staging ) { - RELEASE_LATER( &m_device, m_staging ); - } - if( m_descriptorHeap ) - { - RELEASE_LATER( &m_device, m_descriptorHeap ); - } - if( m_resourceCopy ) - { - RELEASE_LATER( &m_device, m_resourceCopy ); + D3D12_HEAP_PROPERTIES defaultHeapProperties = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + + D3D12_RESOURCE_DESC stagingDesc = desc; + stagingDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + + CR_RETURN_HR( m_device.m_device->CreateCommittedResource( + &defaultHeapProperties, + D3D12_HEAP_FLAG_NONE, + &stagingDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &m_staging ) ) ); + SetDebugName( m_staging, "GenerateMips UAVCopy" ); } - if( m_bgrHeap ) + else { - RELEASE_LATER( &m_device, m_bgrHeap ); + auto restore = TrinityALImpl::Transition( m_staging, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + commandList->ResourceBarrier( 1, &restore ); } - if( m_bgrResourceCopy ) + + staging = m_staging; + + // Copy the resource to staging + auto from = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); + commandList->ResourceBarrier( 1, &from ); + commandList->CopyResource( staging, resource ); + auto to = TrinityALImpl::Transition( staging, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + commandList->ResourceBarrier( 1, &to ); + } + else + { + // Resource is already a UAV so we can do this in-place + staging = resource; + if( ( resourceState & D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) == 0 ) { - RELEASE_LATER( &m_device, m_bgrResourceCopy ); + auto barrier = TrinityALImpl::Transition( staging, resourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + commandList->ResourceBarrier( 1, &barrier ); } - if( m_bgrAliasCopy ) + else { - RELEASE_LATER( &m_device, m_bgrAliasCopy ); + readState = resourceState; } } - ALResult GenerateMips_UnorderedAccessPath( _In_ ID3D12Resource* resource, DXGI_FORMAT format, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) + uint32_t descriptorSize = m_device.m_device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ); + // Create a descriptor heap that holds our resource descriptors + if( !m_descriptorHeap ) { - const auto desc = resource->GetDesc(); - if( FormatIsBGR( format ) || FormatIsSRGB( format ) ) - { - return E_INVALIDARG; - } + D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {}; + descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + descriptorHeapDesc.NumDescriptors = desc.MipLevels; + CR_RETURN_HR( m_device.m_device->CreateDescriptorHeap( &descriptorHeapDesc, IID_PPV_ARGS( &m_descriptorHeap ) ) ); + SetDebugName( m_descriptorHeap, "GenerateMips DescriptorHeap" ); - D3D12_RESOURCE_STATES readState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - CComPtr staging; - // Create a staging resource if we have to - if( ( desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ) == 0 ) + + // Create the top-level SRV + D3D12_CPU_DESCRIPTOR_HANDLE handleIt( m_descriptorHeap->GetCPUDescriptorHandleForHeapStart() ); + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.Format = format; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + if( desc.DepthOrArraySize > 1 ) { - if( !m_staging ) - { - D3D12_HEAP_PROPERTIES defaultHeapProperties = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); - - D3D12_RESOURCE_DESC stagingDesc = desc; - stagingDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - - CR_RETURN_HR( m_device.m_device->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &stagingDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &m_staging ) ) ); - SetDebugName( m_staging, "GenerateMips UAVCopy" ); - } - else - { - auto restore = TrinityALImpl::Transition( m_staging, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); - commandList->ResourceBarrier( 1, &restore ); - } - - staging = m_staging; - - // Copy the resource to staging - auto from = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); - commandList->ResourceBarrier( 1, &from ); - commandList->CopyResource( staging, resource ); - auto to = TrinityALImpl::Transition( staging, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); - commandList->ResourceBarrier( 1, &to ); + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; + srvDesc.Texture2DArray.MipLevels = desc.MipLevels; + srvDesc.Texture2DArray.ArraySize = desc.DepthOrArraySize; } else { - // Resource is already a UAV so we can do this in-place - staging = resource; - if( ( resourceState & D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) == 0 ) - { - auto barrier = TrinityALImpl::Transition( staging, resourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - } - else - { - readState = resourceState; - } + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srvDesc.Texture2D.MostDetailedMip = 0; + srvDesc.Texture2D.MipLevels = desc.MipLevels; } - uint32_t descriptorSize = m_device.m_device->GetDescriptorHandleIncrementSize( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ); - // Create a descriptor heap that holds our resource descriptors - if( !m_descriptorHeap ) + m_device.m_device->CreateShaderResourceView( staging, &srvDesc, handleIt ); + + // Create the UAVs for the tail + for( uint16_t mip = 1; mip < desc.MipLevels; ++mip ) { - D3D12_DESCRIPTOR_HEAP_DESC descriptorHeapDesc = {}; - descriptorHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; - descriptorHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - descriptorHeapDesc.NumDescriptors = desc.MipLevels; - CR_RETURN_HR( m_device.m_device->CreateDescriptorHeap( &descriptorHeapDesc, IID_PPV_ARGS( &m_descriptorHeap ) ) ); - SetDebugName( m_descriptorHeap, "GenerateMips DescriptorHeap" ); - - - // Create the top-level SRV - D3D12_CPU_DESCRIPTOR_HANDLE handleIt( m_descriptorHeap->GetCPUDescriptorHandleForHeapStart() ); - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.Format = format; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {}; + uavDesc.Format = format; if( desc.DepthOrArraySize > 1 ) { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - srvDesc.Texture2DArray.MipLevels = desc.MipLevels; - srvDesc.Texture2DArray.ArraySize = desc.DepthOrArraySize; + uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; + uavDesc.Texture2DArray.MipSlice = mip; + uavDesc.Texture2DArray.ArraySize = desc.DepthOrArraySize; } else { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - srvDesc.Texture2D.MostDetailedMip = 0; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - } - - m_device.m_device->CreateShaderResourceView( staging, &srvDesc, handleIt ); - - // Create the UAVs for the tail - for( uint16_t mip = 1; mip < desc.MipLevels; ++mip ) - { - D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {}; - uavDesc.Format = format; - if( desc.DepthOrArraySize > 1 ) - { - uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; - uavDesc.Texture2DArray.MipSlice = mip; - uavDesc.Texture2DArray.ArraySize = desc.DepthOrArraySize; - } - else - { - uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; - uavDesc.Texture2D.MipSlice = mip; - } - - handleIt.ptr += descriptorSize; - m_device.m_device->CreateUnorderedAccessView( staging, nullptr, &uavDesc, handleIt ); + uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; + uavDesc.Texture2D.MipSlice = mip; } - } - - // Set up UAV barrier (used in loop) - D3D12_RESOURCE_BARRIER barrierUAV = {}; - barrierUAV.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - barrierUAV.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrierUAV.UAV.pResource = staging; - // Barrier for transitioning the subresources to UAVs - std::vector srv2uavDescs( desc.DepthOrArraySize ); - std::vector uav2srvDescs( desc.DepthOrArraySize ); - for(int i = 0 ; i < desc.DepthOrArraySize; ++i ) - { - srv2uavDescs[i].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - srv2uavDescs[i].Transition.pResource = staging; - srv2uavDescs[i].Transition.Subresource = i; - srv2uavDescs[i].Transition.StateBefore = readState; - srv2uavDescs[i].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - - - uav2srvDescs[i].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - uav2srvDescs[i].Transition.pResource = staging; - uav2srvDescs[i].Transition.Subresource = i; - uav2srvDescs[i].Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - uav2srvDescs[i].Transition.StateAfter = readState; + handleIt.ptr += descriptorSize; + m_device.m_device->CreateUnorderedAccessView( staging, nullptr, &uavDesc, handleIt ); } + } - // Set up state - commandList->SetComputeRootSignature( m_device.m_genMipsResources->rootSignature ); - commandList->SetPipelineState( desc.DepthOrArraySize > 1 ? m_device.m_genMipsResources->generateMipsArrayPSO : m_device.m_genMipsResources->generateMipsPSO ); - commandList->SetDescriptorHeaps( 1, &m_descriptorHeap ); - commandList->SetComputeRootDescriptorTable( TrinityALImpl::GenerateMipsResources::SourceTexture, m_descriptorHeap->GetGPUDescriptorHandleForHeapStart() ); - - // Get the descriptor handle -- uavH will increment over each loop - D3D12_GPU_DESCRIPTOR_HANDLE uavH = { m_descriptorHeap->GetGPUDescriptorHandleForHeapStart().ptr + descriptorSize }; // offset by 1 descriptor + // Set up UAV barrier (used in loop) + D3D12_RESOURCE_BARRIER barrierUAV = {}; + barrierUAV.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; + barrierUAV.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; + barrierUAV.UAV.pResource = staging; - // Process each mip - auto mipWidth = static_cast( desc.Width ); - uint32_t mipHeight = desc.Height; - for( uint32_t mip = 1; mip < desc.MipLevels; ++mip ) - { - mipWidth = std::max( 1, mipWidth >> 1 ); - mipHeight = std::max( 1, mipHeight >> 1 ); + // Barrier for transitioning the subresources to UAVs + std::vector srv2uavDescs( desc.DepthOrArraySize ); + std::vector uav2srvDescs( desc.DepthOrArraySize ); + for( int i = 0; i < desc.DepthOrArraySize; ++i ) + { + srv2uavDescs[i].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + srv2uavDescs[i].Transition.pResource = staging; + srv2uavDescs[i].Transition.Subresource = i; + srv2uavDescs[i].Transition.StateBefore = readState; + srv2uavDescs[i].Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - // Transition the mip to a UAV - for ( int i = 0; i < desc.DepthOrArraySize; ++i ) - { - srv2uavDescs[i].Transition.Subresource = mip + ( i * desc.MipLevels ); - uav2srvDescs[i].Transition.Subresource = mip + ( i * desc.MipLevels ); - } - commandList->ResourceBarrier( desc.DepthOrArraySize, srv2uavDescs.data() ); - - // Bind the mip subresources - commandList->SetComputeRootDescriptorTable( TrinityALImpl::GenerateMipsResources::TargetTexture, uavH ); - - // Set constants - TrinityALImpl::GenerateMipsResources::ConstantData constants; - constants.SrcMipIndex = mip - 1; - constants.InvOutTexelSizeX = 1 / float( mipWidth ); - constants.InvOutTexelSizeY = 1 / float( mipHeight ); - commandList->SetComputeRoot32BitConstants( - TrinityALImpl::GenerateMipsResources::Constants, - TrinityALImpl::GenerateMipsResources::Num32BitConstants, - &constants, - 0 ); - - // Process this mip - commandList->Dispatch( - ( mipWidth + TrinityALImpl::GenerateMipsResources::ThreadGroupSize - 1 ) / TrinityALImpl::GenerateMipsResources::ThreadGroupSize, - ( mipHeight + TrinityALImpl::GenerateMipsResources::ThreadGroupSize - 1 ) / TrinityALImpl::GenerateMipsResources::ThreadGroupSize, - desc.DepthOrArraySize ); - - commandList->ResourceBarrier( 1, &barrierUAV ); - - // Transition the mip to an SRV - commandList->ResourceBarrier( desc.DepthOrArraySize, uav2srvDescs.data() ); - - // Offset the descriptor heap handles - uavH.ptr += descriptorSize; - } - // If the staging resource is NOT the same as the resource, we need to copy everything back - if( staging != resource ) - { - // Transition the resources ready for copy - D3D12_RESOURCE_BARRIER barriers[2] = { - TrinityALImpl::Transition( staging, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_SOURCE ), - TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ) - }; - - commandList->ResourceBarrier( 2, barriers ); - // Copy the entire resource back - commandList->CopyResource( resource, staging ); - - // Transition the target resource back to pixel shader resource - auto barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); - commandList->ResourceBarrier( 1, &barrier ); - } - else if( ( resourceState & D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) == 0 ) - { - auto barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, resourceState ); - commandList->ResourceBarrier( 1, &barrier ); - } + uav2srvDescs[i].Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + uav2srvDescs[i].Transition.pResource = staging; + uav2srvDescs[i].Transition.Subresource = i; + uav2srvDescs[i].Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + uav2srvDescs[i].Transition.StateAfter = readState; + } - m_device.DirtyDescriptorCache(); + // Set up state + commandList->SetComputeRootSignature( m_device.m_genMipsResources->rootSignature ); + commandList->SetPipelineState( desc.DepthOrArraySize > 1 ? m_device.m_genMipsResources->generateMipsArrayPSO : m_device.m_genMipsResources->generateMipsPSO ); + commandList->SetDescriptorHeaps( 1, &m_descriptorHeap ); + commandList->SetComputeRootDescriptorTable( TrinityALImpl::GenerateMipsResources::SourceTexture, m_descriptorHeap->GetGPUDescriptorHandleForHeapStart() ); - return S_OK; - } + // Get the descriptor handle -- uavH will increment over each loop + D3D12_GPU_DESCRIPTOR_HANDLE uavH = { m_descriptorHeap->GetGPUDescriptorHandleForHeapStart().ptr + descriptorSize }; // offset by 1 descriptor - ALResult GenerateMips_TexturePath( _In_ ID3D12Resource* resource, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) + // Process each mip + auto mipWidth = static_cast( desc.Width ); + uint32_t mipHeight = desc.Height; + for( uint32_t mip = 1; mip < desc.MipLevels; ++mip ) { - const auto resourceDesc = resource->GetDesc(); - if( FormatIsBGR( resourceDesc.Format ) && !FormatIsSRGB( resourceDesc.Format ) ) + mipWidth = std::max( 1, mipWidth >> 1 ); + mipHeight = std::max( 1, mipHeight >> 1 ); + + // Transition the mip to a UAV + for( int i = 0; i < desc.DepthOrArraySize; ++i ) { - return E_FAIL; + srv2uavDescs[i].Transition.Subresource = mip + ( i * desc.MipLevels ); + uav2srvDescs[i].Transition.Subresource = mip + ( i * desc.MipLevels ); } + commandList->ResourceBarrier( desc.DepthOrArraySize, srv2uavDescs.data() ); - if( !m_resourceCopy ) - { - auto copyDesc = resourceDesc; - copyDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; - copyDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + // Bind the mip subresources + commandList->SetComputeRootDescriptorTable( TrinityALImpl::GenerateMipsResources::TargetTexture, uavH ); - auto heapProperties = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + // Set constants + TrinityALImpl::GenerateMipsResources::ConstantData constants; + constants.SrcMipIndex = mip - 1; + constants.InvOutTexelSizeX = 1 / float( mipWidth ); + constants.InvOutTexelSizeY = 1 / float( mipHeight ); + commandList->SetComputeRoot32BitConstants( + TrinityALImpl::GenerateMipsResources::Constants, + TrinityALImpl::GenerateMipsResources::Num32BitConstants, + &constants, + 0 ); - // Create a resource with the same description, but without SRGB, and with UAV flags - CR_RETURN_HR( m_device.m_device->CreateCommittedResource( - &heapProperties, - D3D12_HEAP_FLAG_NONE, - ©Desc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &m_resourceCopy ) ) ); - } - else - { - auto restore = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); - commandList->ResourceBarrier( 1, &restore ); - } + // Process this mip + commandList->Dispatch( + ( mipWidth + TrinityALImpl::GenerateMipsResources::ThreadGroupSize - 1 ) / TrinityALImpl::GenerateMipsResources::ThreadGroupSize, + ( mipHeight + TrinityALImpl::GenerateMipsResources::ThreadGroupSize - 1 ) / TrinityALImpl::GenerateMipsResources::ThreadGroupSize, + desc.DepthOrArraySize ); - // Copy the resource data - auto barrier = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - commandList->CopyResource( m_resourceCopy, resource ); - barrier = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); - commandList->ResourceBarrier( 1, &barrier ); + commandList->ResourceBarrier( 1, &barrierUAV ); - // Generate the mips - GenerateMips_UnorderedAccessPath( m_resourceCopy, DXGI_FORMAT_R8G8B8A8_UNORM, commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + // Transition the mip to an SRV + commandList->ResourceBarrier( desc.DepthOrArraySize, uav2srvDescs.data() ); - // Direct copy back - barrier = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_SOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); - commandList->ResourceBarrier( 1, &barrier ); - commandList->CopyResource( resource, m_resourceCopy ); - barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); - commandList->ResourceBarrier( 1, &barrier ); - return S_OK; + // Offset the descriptor heap handles + uavH.ptr += descriptorSize; } - ALResult GenerateMips_TexturePathBGR( _In_ ID3D12Resource* resource, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) + // If the staging resource is NOT the same as the resource, we need to copy everything back + if( staging != resource ) { - const auto resourceDesc = resource->GetDesc(); - if( !FormatIsBGR( resourceDesc.Format ) ) - { - return E_FAIL; - } - - if( !m_bgrHeap ) - { - // Create a resource with the same description, but without SRGB, and with UAV flags - auto copyDesc = resourceDesc; - copyDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; - copyDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - - D3D12_HEAP_DESC heapDesc = {}; - auto allocInfo = m_device.m_device->GetResourceAllocationInfo( 0, 1, &resourceDesc ); - heapDesc.SizeInBytes = allocInfo.SizeInBytes; - heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; - heapDesc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - heapDesc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - heapDesc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT; - - CR_RETURN_HR( m_device.m_device->CreateHeap( &heapDesc, IID_PPV_ARGS( &m_bgrHeap ) ) ); - - CR_RETURN_HR( m_device.m_device->CreatePlacedResource( - m_bgrHeap, - 0, - ©Desc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &m_bgrResourceCopy ) ) ); - - // Create a BGRA alias - auto aliasDesc = resourceDesc; - aliasDesc.Format = ( resourceDesc.Format == DXGI_FORMAT_B8G8R8X8_TYPELESS ) ? DXGI_FORMAT_B8G8R8X8_TYPELESS : DXGI_FORMAT_B8G8R8A8_TYPELESS; - aliasDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - CR_RETURN_HR( m_device.m_device->CreatePlacedResource( - m_bgrHeap, - 0, - &aliasDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &m_bgrAliasCopy ) ) ); - } - else - { - auto restore = TrinityALImpl::Transition( m_bgrAliasCopy, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); - commandList->ResourceBarrier( 1, &restore ); - } - - // Copy the resource data - auto barrier = TrinityALImpl::AliasBarrier( nullptr, m_bgrAliasCopy ); - commandList->ResourceBarrier( 1, &barrier ); - barrier = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - commandList->CopyResource( m_bgrAliasCopy, resource ); + // Transition the resources ready for copy + D3D12_RESOURCE_BARRIER barriers[2] = { + TrinityALImpl::Transition( staging, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_SOURCE ), + TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ) + }; - // Generate the mips - barrier = TrinityALImpl::AliasBarrier( m_bgrAliasCopy, m_bgrResourceCopy ); - commandList->ResourceBarrier( 1, &barrier ); - barrier = TrinityALImpl::Transition( m_bgrResourceCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - FORWARD_HR( GenerateMips_UnorderedAccessPath( m_bgrResourceCopy, DXGI_FORMAT_R8G8B8A8_UNORM, commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) ); + commandList->ResourceBarrier( 2, barriers ); + // Copy the entire resource back + commandList->CopyResource( resource, staging ); - // Direct copy back - barrier = TrinityALImpl::AliasBarrier( m_bgrResourceCopy, m_bgrAliasCopy ); - commandList->ResourceBarrier( 1, &barrier ); - barrier = TrinityALImpl::Transition( m_bgrAliasCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE ); - commandList->ResourceBarrier( 1, &barrier ); - barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + // Transition the target resource back to pixel shader resource + auto barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); commandList->ResourceBarrier( 1, &barrier ); - commandList->CopyResource( resource, m_bgrAliasCopy ); - barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); + } + else if( ( resourceState & D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) == 0 ) + { + auto barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, resourceState ); commandList->ResourceBarrier( 1, &barrier ); - return S_OK; } - - CComPtr m_staging; - CComPtr m_descriptorHeap; - CComPtr m_resourceCopy; - CComPtr m_bgrHeap; - CComPtr m_bgrResourceCopy; - CComPtr m_bgrAliasCopy; - Tr2PrimaryRenderContextAL& m_device; - }; + m_device.DirtyDescriptorCache(); + + return S_OK; + } - void FlushBarriersMaybe( const Tr2TextureAL& tex1, const Tr2TextureAL& tex2, Tr2RenderContextAL& renderContext ) + ALResult GenerateMips_TexturePath( _In_ ID3D12Resource* resource, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) { - if( RequiresImmediateBarriers( tex1.GetGpuUsage() ) && RequiresImmediateBarriers( tex2.GetGpuUsage() ) ) + const auto resourceDesc = resource->GetDesc(); + if( FormatIsBGR( resourceDesc.Format ) && !FormatIsSRGB( resourceDesc.Format ) ) { - renderContext.FlushBarriersDx12( tex1.GetResourceDx12(), tex2.GetResourceDx12() ); + return E_FAIL; } - else if( RequiresImmediateBarriers( tex1.GetGpuUsage() ) ) + + if( !m_resourceCopy ) { - renderContext.FlushBarriersDx12( tex1.GetResourceDx12() ); + auto copyDesc = resourceDesc; + copyDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; + copyDesc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + + auto heapProperties = TrinityALImpl::HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + + // Create a resource with the same description, but without SRGB, and with UAV flags + CR_RETURN_HR( m_device.m_device->CreateCommittedResource( + &heapProperties, + D3D12_HEAP_FLAG_NONE, + ©Desc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &m_resourceCopy ) ) ); } - else if( RequiresImmediateBarriers( tex2.GetGpuUsage() ) ) + else { - renderContext.FlushBarriersDx12( tex2.GetResourceDx12() ); + auto restore = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + commandList->ResourceBarrier( 1, &restore ); } + + // Copy the resource data + auto barrier = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + commandList->CopyResource( m_resourceCopy, resource ); + barrier = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + + // Generate the mips + GenerateMips_UnorderedAccessPath( m_resourceCopy, DXGI_FORMAT_R8G8B8A8_UNORM, commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + + // Direct copy back + barrier = TrinityALImpl::Transition( m_resourceCopy, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_COPY_SOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + commandList->ResourceBarrier( 1, &barrier ); + commandList->CopyResource( resource, m_resourceCopy ); + barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); + commandList->ResourceBarrier( 1, &barrier ); + return S_OK; } - void FlushBarriersMaybe( const Tr2TextureAL& tex, Tr2RenderContextAL& renderContext ) + ALResult GenerateMips_TexturePathBGR( _In_ ID3D12Resource* resource, ID3D12GraphicsCommandList* commandList, D3D12_RESOURCE_STATES resourceState ) { - if( RequiresImmediateBarriers( tex.GetGpuUsage() ) ) + const auto resourceDesc = resource->GetDesc(); + if( !FormatIsBGR( resourceDesc.Format ) ) { - renderContext.FlushBarriersDx12( tex.GetResourceDx12() ); + return E_FAIL; } - } + if( !m_bgrHeap ) + { + // Create a resource with the same description, but without SRGB, and with UAV flags + auto copyDesc = resourceDesc; + copyDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; + copyDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - Tr2TextureAL::Tr2TextureAL() - :m_owner( nullptr ), - m_currentTextureIndex( 0 ), - m_defaultState( D3D12_RESOURCE_STATE_COMMON ), - m_gpuUsage( Tr2GpuUsage::NONE ), - m_cpuUsage( Tr2CpuUsage::NONE ), - m_mipMapGenerator( nullptr ) - { - m_srvIndicesInHeap[0] = m_srvIndicesInHeap[1] = 0xffffffff; - m_mappedScratch = m_writeScratches.end(); - } + D3D12_HEAP_DESC heapDesc = {}; + auto allocInfo = m_device.m_device->GetResourceAllocationInfo( 0, 1, &resourceDesc ); + heapDesc.SizeInBytes = allocInfo.SizeInBytes; + heapDesc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES; + heapDesc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapDesc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapDesc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT; - Tr2TextureAL::~Tr2TextureAL() - { - Destroy(); + CR_RETURN_HR( m_device.m_device->CreateHeap( &heapDesc, IID_PPV_ARGS( &m_bgrHeap ) ) ); - m_mipMapGenerator = nullptr; - } + CR_RETURN_HR( m_device.m_device->CreatePlacedResource( + m_bgrHeap, + 0, + ©Desc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &m_bgrResourceCopy ) ) ); - ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); + // Create a BGRA alias + auto aliasDesc = resourceDesc; + aliasDesc.Format = ( resourceDesc.Format == DXGI_FORMAT_B8G8R8X8_TYPELESS ) ? DXGI_FORMAT_B8G8R8X8_TYPELESS : DXGI_FORMAT_B8G8R8A8_TYPELESS; + aliasDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; + CR_RETURN_HR( m_device.m_device->CreatePlacedResource( + m_bgrHeap, + 0, + &aliasDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &m_bgrAliasCopy ) ) ); } - - FORWARD_HR( CheckCreationFlags( desc, msaa, gpuUsage, cpuUsage ) ); - - if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) + else { - return E_INVALIDARG; - } + auto restore = TrinityALImpl::Transition( m_bgrAliasCopy, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + commandList->ResourceBarrier( 1, &restore ); + } + + // Copy the resource data + auto barrier = TrinityALImpl::AliasBarrier( nullptr, m_bgrAliasCopy ); + commandList->ResourceBarrier( 1, &barrier ); + barrier = TrinityALImpl::Transition( resource, resourceState, D3D12_RESOURCE_STATE_COPY_SOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + commandList->CopyResource( m_bgrAliasCopy, resource ); + + // Generate the mips + barrier = TrinityALImpl::AliasBarrier( m_bgrAliasCopy, m_bgrResourceCopy ); + commandList->ResourceBarrier( 1, &barrier ); + barrier = TrinityALImpl::Transition( m_bgrResourceCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + FORWARD_HR( GenerateMips_UnorderedAccessPath( m_bgrResourceCopy, DXGI_FORMAT_R8G8B8A8_UNORM, commandList, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE ) ); + + // Direct copy back + barrier = TrinityALImpl::AliasBarrier( m_bgrResourceCopy, m_bgrAliasCopy ); + commandList->ResourceBarrier( 1, &barrier ); + barrier = TrinityALImpl::Transition( m_bgrAliasCopy, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE ); + commandList->ResourceBarrier( 1, &barrier ); + barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COPY_DEST ); + commandList->ResourceBarrier( 1, &barrier ); + commandList->CopyResource( resource, m_bgrAliasCopy ); + barrier = TrinityALImpl::Transition( resource, D3D12_RESOURCE_STATE_COPY_DEST, resourceState ); + commandList->ResourceBarrier( 1, &barrier ); + return S_OK; + } - if( desc.GetType() == TEX_TYPE_INVALID ) - { - return E_INVALIDARG; - } - if( desc.GetFormat() == Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - return E_INVALIDARG; - } + CComPtr m_staging; + CComPtr m_descriptorHeap; + CComPtr m_resourceCopy; + CComPtr m_bgrHeap; + CComPtr m_bgrResourceCopy; + CComPtr m_bgrAliasCopy; + Tr2PrimaryRenderContextAL& m_device; +}; - if( desc.GetWidth() == 0 || desc.GetHeight() == 0 || ( desc.GetType() == TEX_TYPE_3D && desc.GetDepth() == 0 ) || ( desc.GetType() != TEX_TYPE_3D && desc.GetArraySize() == 0 ) ) - { - return E_INVALIDARG; - } +void FlushBarriersMaybe( const Tr2TextureAL& tex1, const Tr2TextureAL& tex2, Tr2RenderContextAL& renderContext ) +{ + if( RequiresImmediateBarriers( tex1.GetGpuUsage() ) && RequiresImmediateBarriers( tex2.GetGpuUsage() ) ) + { + renderContext.FlushBarriersDx12( tex1.GetResourceDx12(), tex2.GetResourceDx12() ); + } + else if( RequiresImmediateBarriers( tex1.GetGpuUsage() ) ) + { + renderContext.FlushBarriersDx12( tex1.GetResourceDx12() ); + } + else if( RequiresImmediateBarriers( tex2.GetGpuUsage() ) ) + { + renderContext.FlushBarriersDx12( tex2.GetResourceDx12() ); + } +} - D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE; - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; - if( !HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - resourceFlags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; - } - } +void FlushBarriersMaybe( const Tr2TextureAL& tex, Tr2RenderContextAL& renderContext ) +{ + if( RequiresImmediateBarriers( tex.GetGpuUsage() ) ) + { + renderContext.FlushBarriersDx12( tex.GetResourceDx12() ); + } +} - D3D12_RESOURCE_STATES defaultState; - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - defaultState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; - } - else if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) - { - defaultState = D3D12_RESOURCE_STATE_RENDER_TARGET; - } - else if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + +Tr2TextureAL::Tr2TextureAL() : + m_owner( nullptr ), + m_currentTextureIndex( 0 ), + m_defaultState( D3D12_RESOURCE_STATE_COMMON ), + m_gpuUsage( Tr2GpuUsage::NONE ), + m_cpuUsage( Tr2CpuUsage::NONE ), + m_mipMapGenerator( nullptr ) +{ + m_srvIndicesInHeap[0] = m_srvIndicesInHeap[1] = 0xffffffff; + m_mappedScratch = m_writeScratches.end(); +} + +Tr2TextureAL::~Tr2TextureAL() +{ + Destroy(); + + m_mipMapGenerator = nullptr; +} + +ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + + FORWARD_HR( CheckCreationFlags( desc, msaa, gpuUsage, cpuUsage ) ); + + if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) + { + return E_INVALIDARG; + } + + if( desc.GetType() == TEX_TYPE_INVALID ) + { + return E_INVALIDARG; + } + + if( desc.GetFormat() == Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + return E_INVALIDARG; + } + + if( desc.GetWidth() == 0 || desc.GetHeight() == 0 || ( desc.GetType() == TEX_TYPE_3D && desc.GetDepth() == 0 ) || ( desc.GetType() != TEX_TYPE_3D && desc.GetArraySize() == 0 ) ) + { + return E_INVALIDARG; + } + + D3D12_RESOURCE_FLAGS resourceFlags = D3D12_RESOURCE_FLAG_NONE; + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + resourceFlags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; + if( !HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - defaultState = D3D12_RESOURCE_STATE_DEPTH_WRITE; + resourceFlags |= D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; } - else if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + } + + D3D12_RESOURCE_STATES defaultState; + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + defaultState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE; + } + else if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + defaultState = D3D12_RESOURCE_STATE_RENDER_TARGET; + } + else if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + defaultState = D3D12_RESOURCE_STATE_DEPTH_WRITE; + } + else if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + defaultState = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + } + else + { + defaultState = D3D12_RESOURCE_STATE_COPY_DEST; + } + + D3D12_RESOURCE_STATES creationState = defaultState; + if( initialData ) + { + creationState = D3D12_RESOURCE_STATE_COPY_DEST; + } + + CComPtr texture; + auto heap = HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); + auto resourceDesc = TextureDesc( desc, msaa, resourceFlags ); + CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( + &heap, + D3D12_HEAP_FLAG_NONE, + &resourceDesc, + creationState, + nullptr, + IID_PPV_ARGS( &texture ) ) ); + + if( renderContext.m_device1 ) + { + ID3D12Pageable* resource = texture; + D3D12_RESIDENCY_PRIORITY priority; + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) || HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { - defaultState = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; + //Writable textures are generally very important to keep in VRAM. + priority = D3D12_RESIDENCY_PRIORITY_HIGH; } else { - defaultState = D3D12_RESOURCE_STATE_COPY_DEST; + //Read-only textures are generally not as critical. + priority = D3D12_RESIDENCY_PRIORITY_LOW; } - D3D12_RESOURCE_STATES creationState = defaultState; - if( initialData ) - { - creationState = D3D12_RESOURCE_STATE_COPY_DEST; - } + renderContext.m_device1->SetResidencyPriority( 1, &resource, &priority ); + } + + CComPtr scratch; + uint64_t writeScratchSize = 0; + if( initialData ) + { + auto subresources = std::max( 1u, desc.GetArraySize() ) * resourceDesc.MipLevels; + writeScratchSize = GetRequiredIntermediateSize( texture, 0, subresources ); - CComPtr texture; - auto heap = HeapDesc( D3D12_HEAP_TYPE_DEFAULT ); - auto resourceDesc = TextureDesc( desc, msaa, resourceFlags ); + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto scratchDesc = BufferDesc( writeScratchSize ); CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &heap, + &scratchHeap, D3D12_HEAP_FLAG_NONE, - &resourceDesc, - creationState, + &scratchDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, - IID_PPV_ARGS( &texture ) ) ); - - if( renderContext.m_device1 ) - { - ID3D12Pageable* resource = texture; - D3D12_RESIDENCY_PRIORITY priority; - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) || HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - //Writable textures are generally very important to keep in VRAM. - priority = D3D12_RESIDENCY_PRIORITY_HIGH; - } - else - { - //Read-only textures are generally not as critical. - priority = D3D12_RESIDENCY_PRIORITY_LOW; - } - - renderContext.m_device1->SetResidencyPriority( 1, &resource, &priority ); - } + IID_PPV_ARGS( &scratch ) ) ); - CComPtr scratch; - uint64_t writeScratchSize = 0; - if( initialData ) + std::vector dx12InitialData( desc.GetArraySize() * resourceDesc.MipLevels ); + for( size_t i = 0; i < dx12InitialData.size(); ++i ) { - auto subresources = std::max( 1u, desc.GetArraySize() ) * resourceDesc.MipLevels; - writeScratchSize = GetRequiredIntermediateSize( texture, 0, subresources ); - - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto scratchDesc = BufferDesc( writeScratchSize ); - CR_RETURN_HR( renderContext.m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); - - std::vector dx12InitialData( desc.GetArraySize() * resourceDesc.MipLevels ); - for( size_t i = 0; i < dx12InitialData.size(); ++i ) - { - dx12InitialData[i].pData = initialData[i].m_sysMem; - dx12InitialData[i].RowPitch = initialData[i].m_sysMemPitch; - dx12InitialData[i].SlicePitch = initialData[i].m_sysMemSlicePitch; - } + dx12InitialData[i].pData = initialData[i].m_sysMem; + dx12InitialData[i].RowPitch = initialData[i].m_sysMemPitch; + dx12InitialData[i].SlicePitch = initialData[i].m_sysMemSlicePitch; + } - if( !UpdateSubresources( + if( !UpdateSubresources( renderContext.m_commandList, texture, scratch, @@ -774,165 +774,191 @@ namespace TrinityALImpl 0, subresources, &dx12InitialData[0] ) ) + { + return E_FAIL; + } + if( defaultState != creationState ) + { + renderContext.ResourceBarrierDx12( Transition( texture, creationState, defaultState ) ); + if( RequiresImmediateBarriers( gpuUsage ) ) + { + renderContext.FlushBarriersDx12( texture ); + } + } + RELEASE_LATER( &renderContext, scratch ); + } + + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + + D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.Format = GetSrvFormat( desc.GetFormat() ); + srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + switch( desc.GetType() ) + { + case TEX_TYPE_1D: + if( resourceDesc.DepthOrArraySize > 1 ) { - return E_FAIL; + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY; + srvDesc.Texture1DArray.MipLevels = resourceDesc.MipLevels; + srvDesc.Texture1DArray.ArraySize = resourceDesc.DepthOrArraySize; } - if( defaultState != creationState ) + else { - renderContext.ResourceBarrierDx12( Transition( texture, creationState, defaultState ) ); - if( RequiresImmediateBarriers( gpuUsage ) ) + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D; + srvDesc.Texture1D.MipLevels = resourceDesc.MipLevels; + } + break; + case TEX_TYPE_3D: + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; + srvDesc.Texture3D.MipLevels = resourceDesc.MipLevels; + break; + case TEX_TYPE_CUBE: + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; + srvDesc.TextureCube.MipLevels = resourceDesc.MipLevels; + break; + default: + if( msaa.samples > 1 ) + { + if( resourceDesc.DepthOrArraySize > 1 ) + { + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY; + srvDesc.Texture2DMSArray.FirstArraySlice = 0; + srvDesc.Texture2DMSArray.ArraySize = resourceDesc.DepthOrArraySize; + } + else + { + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; + } + } + else + { + if( resourceDesc.DepthOrArraySize > 1 ) + { + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; + srvDesc.Texture2DArray.MipLevels = resourceDesc.MipLevels; + srvDesc.Texture2DArray.ArraySize = resourceDesc.DepthOrArraySize; + } + else { - renderContext.FlushBarriersDx12( texture ); + srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = resourceDesc.MipLevels; } } - RELEASE_LATER( &renderContext, scratch ); } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { + m_srvDesc[0] = srvDesc; + m_srvDesc[1] = srvDesc; + m_srvDesc[1].Format = GetSrvFormat( MakeSrgb( desc.GetFormat() ) ); - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.Format = GetSrvFormat( desc.GetFormat() ); - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + renderContext.CreateShaderResourceView( texture, m_srvDesc[0], m_view[0] ); + renderContext.CreateShaderResourceView( texture, m_srvDesc[1], m_view[1] ); + m_srvIndicesInHeap[0] = m_view[0]->GetIndexInHeap(); + m_srvIndicesInHeap[1] = m_view[1]->GetIndexInHeap(); + } + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + heapDesc.NumDescriptors = resourceDesc.MipLevels; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + + D3D12_UNORDERED_ACCESS_VIEW_DESC uav; + uav.Format = GetSrvFormat( desc.GetFormat() ); + for( uint32_t i = 0; i < resourceDesc.MipLevels; ++i ) + { switch( desc.GetType() ) { case TEX_TYPE_1D: if( resourceDesc.DepthOrArraySize > 1 ) { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY; - srvDesc.Texture1DArray.MipLevels = resourceDesc.MipLevels; - srvDesc.Texture1DArray.ArraySize = resourceDesc.DepthOrArraySize; + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1DARRAY; + uav.Texture1DArray.MipSlice = i; + uav.Texture1DArray.FirstArraySlice = 0; + uav.Texture1DArray.ArraySize = resourceDesc.DepthOrArraySize; } else { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D; - srvDesc.Texture1D.MipLevels = resourceDesc.MipLevels; + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D; + uav.Texture1D.MipSlice = i; } break; case TEX_TYPE_3D: - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; - srvDesc.Texture3D.MipLevels = resourceDesc.MipLevels; + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; + uav.Texture3D.MipSlice = i; + uav.Texture3D.FirstWSlice = 0; + uav.Texture3D.WSize = UINT( std::max( 1, resourceDesc.DepthOrArraySize >> i ) ); break; case TEX_TYPE_CUBE: - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; - srvDesc.TextureCube.MipLevels = resourceDesc.MipLevels; + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; + uav.Texture2DArray.ArraySize = 6; + uav.Texture2DArray.FirstArraySlice = 0; + uav.Texture2DArray.PlaneSlice = 0; + uav.Texture2DArray.MipSlice = i; break; default: - if( msaa.samples > 1 ) + if( resourceDesc.DepthOrArraySize > 1 ) { - if( resourceDesc.DepthOrArraySize > 1 ) - { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY; - srvDesc.Texture2DMSArray.FirstArraySlice = 0; - srvDesc.Texture2DMSArray.ArraySize = resourceDesc.DepthOrArraySize; - } - else - { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; - } + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; + uav.Texture2DArray.ArraySize = resourceDesc.DepthOrArraySize; + uav.Texture2DArray.FirstArraySlice = 0; + uav.Texture2DArray.PlaneSlice = 0; + uav.Texture2DArray.MipSlice = i; } else { - if( resourceDesc.DepthOrArraySize > 1 ) - { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - srvDesc.Texture2DArray.MipLevels = resourceDesc.MipLevels; - srvDesc.Texture2DArray.ArraySize = resourceDesc.DepthOrArraySize; - } - else - { - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = resourceDesc.MipLevels; - } + uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; + uav.Texture2D.PlaneSlice = 0; + uav.Texture2D.MipSlice = i; } } - m_srvDesc[0] = srvDesc; - m_srvDesc[1] = srvDesc; - m_srvDesc[1].Format = GetSrvFormat( MakeSrgb( desc.GetFormat() ) ); - - renderContext.CreateShaderResourceView(texture, m_srvDesc[0], m_view[0]); - renderContext.CreateShaderResourceView(texture, m_srvDesc[1], m_view[1]); - m_srvIndicesInHeap[0] = m_view[0]->GetIndexInHeap(); - m_srvIndicesInHeap[1] = m_view[1]->GetIndexInHeap(); + std::shared_ptr uavView; + renderContext.CreateUnorderedAccessView( texture, nullptr, uav, uavView ); + m_uav.push_back( uavView ); } - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + { + D3D12_RENDER_TARGET_VIEW_DESC rtv; + rtv.Format = DXGI_FORMAT( desc.GetFormat() ); + if( desc.GetType() == TEX_TYPE_3D ) { - D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; - heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - heapDesc.NumDescriptors = resourceDesc.MipLevels; - heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; - - D3D12_UNORDERED_ACCESS_VIEW_DESC uav; - uav.Format = GetSrvFormat( desc.GetFormat() ); - for( uint32_t i = 0; i < resourceDesc.MipLevels; ++i ) + rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D; + rtv.Texture3D.MipSlice = 0; + rtv.Texture3D.WSize = 1; + m_rtv.resize( 2 * desc.GetDepth() ); + auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + + for( uint32_t i = 0; i < desc.GetDepth(); ++i ) { - switch( desc.GetType() ) + rtv.Texture3D.FirstWSlice = i; + rtv.Format = DXGI_FORMAT( desc.GetFormat() ); + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2] ); + if( srgb != rtv.Format ) { - case TEX_TYPE_1D: - if( resourceDesc.DepthOrArraySize > 1 ) - { - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1DARRAY; - uav.Texture1DArray.MipSlice = i; - uav.Texture1DArray.FirstArraySlice = 0; - uav.Texture1DArray.ArraySize = resourceDesc.DepthOrArraySize; - } - else - { - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D; - uav.Texture1D.MipSlice = i; - } - break; - case TEX_TYPE_3D: - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; - uav.Texture3D.MipSlice = i; - uav.Texture3D.FirstWSlice = 0; - uav.Texture3D.WSize = UINT( std::max( 1, resourceDesc.DepthOrArraySize >> i ) ); - break; - case TEX_TYPE_CUBE: - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; - uav.Texture2DArray.ArraySize = 6; - uav.Texture2DArray.FirstArraySlice = 0; - uav.Texture2DArray.PlaneSlice = 0; - uav.Texture2DArray.MipSlice = i; - break; - default: - if( resourceDesc.DepthOrArraySize > 1 ) - { - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; - uav.Texture2DArray.ArraySize = resourceDesc.DepthOrArraySize; - uav.Texture2DArray.FirstArraySlice = 0; - uav.Texture2DArray.PlaneSlice = 0; - uav.Texture2DArray.MipSlice = i; - } - else - { - uav.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; - uav.Texture2D.PlaneSlice = 0; - uav.Texture2D.MipSlice = i; - } + rtv.Format = srgb; + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2 + 1] ); + } + else + { + m_rtv[i * 2 + 1] = m_rtv[i * 2]; } - - std::shared_ptr uavView; - renderContext.CreateUnorderedAccessView(texture, nullptr, uav, uavView); - m_uav.push_back(uavView); } } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) ) + else if( desc.GetArraySize() > 1 ) { - D3D12_RENDER_TARGET_VIEW_DESC rtv; - rtv.Format = DXGI_FORMAT( desc.GetFormat() ); - if( desc.GetType() == TEX_TYPE_3D ) + if( msaa.samples > 1 ) { - rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D; - rtv.Texture3D.MipSlice = 0; - rtv.Texture3D.WSize = 1; - m_rtv.resize( 2 * desc.GetDepth() ); + rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY; + rtv.Texture2DMSArray.ArraySize = 1; + + m_rtv.resize( 2 * desc.GetArraySize() ); auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - for( uint32_t i = 0; i < desc.GetDepth(); ++i ) + for( uint32_t i = 0; i < desc.GetArraySize(); ++i ) { - rtv.Texture3D.FirstWSlice = i; + rtv.Texture2DMSArray.FirstArraySlice = i; rtv.Format = DXGI_FORMAT( desc.GetFormat() ); renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2] ); if( srgb != rtv.Format ) @@ -946,333 +972,271 @@ namespace TrinityALImpl } } } - else if( desc.GetArraySize() > 1 ) + else { - if( msaa.samples > 1 ) - { - rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY; - rtv.Texture2DMSArray.ArraySize = 1; + rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; + rtv.Texture2DArray.ArraySize = 1; + rtv.Texture2DArray.MipSlice = 0; + rtv.Texture2DArray.PlaneSlice = 0; - m_rtv.resize( 2 * desc.GetArraySize() ); - auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + m_rtv.resize( 2 * desc.GetArraySize() ); + auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - for( uint32_t i = 0; i < desc.GetArraySize(); ++i ) + for( uint32_t i = 0; i < desc.GetArraySize(); ++i ) + { + rtv.Texture2DArray.FirstArraySlice = i; + rtv.Format = DXGI_FORMAT( desc.GetFormat() ); + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2] ); + if( srgb != rtv.Format ) { - rtv.Texture2DMSArray.FirstArraySlice = i; - rtv.Format = DXGI_FORMAT( desc.GetFormat() ); - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2] ); - if( srgb != rtv.Format ) - { - rtv.Format = srgb; - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2 + 1] ); - } - else - { - m_rtv[i * 2 + 1] = m_rtv[i * 2]; - } + rtv.Format = srgb; + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2 + 1] ); } - } - else - { - rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; - rtv.Texture2DArray.ArraySize = 1; - rtv.Texture2DArray.MipSlice = 0; - rtv.Texture2DArray.PlaneSlice = 0; - - m_rtv.resize( 2 * desc.GetArraySize() ); - auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - - for( uint32_t i = 0; i < desc.GetArraySize(); ++i ) + else { - rtv.Texture2DArray.FirstArraySlice = i; - rtv.Format = DXGI_FORMAT( desc.GetFormat() ); - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2] ); - if( srgb != rtv.Format ) - { - rtv.Format = srgb; - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[i * 2 + 1] ); - } - else - { - m_rtv[i * 2 + 1] = m_rtv[i * 2]; - } + m_rtv[i * 2 + 1] = m_rtv[i * 2]; } } } - else - { - if( msaa.samples > 1 ) - { - rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS; - } - else - { - rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; - rtv.Texture2D.MipSlice = 0; - rtv.Texture2D.PlaneSlice = 0; - } - m_rtv.resize( 2 ); - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[0] ); - - auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); - if( srgb != rtv.Format ) - { - rtv.Format = srgb; - renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[1] ); - } - else - { - m_rtv[1] = m_rtv[0]; - } - } } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + else { - D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; - heapDesc.NumDescriptors = 1; - heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; - - D3D12_DEPTH_STENCIL_VIEW_DESC dsv; - dsv.Format = DXGI_FORMAT( desc.GetFormat() ); - dsv.Flags = D3D12_DSV_FLAG_NONE; if( msaa.samples > 1 ) { - dsv.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMS; + rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS; } else { - dsv.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; - dsv.Texture2D.MipSlice = 0; + rtv.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; + rtv.Texture2D.MipSlice = 0; + rtv.Texture2D.PlaneSlice = 0; } + m_rtv.resize( 2 ); + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[0] ); - renderContext.CreateDepthStencilView(texture, dsv, m_dsv); - } - - m_textures.push_back( texture ); - m_desc = desc; - m_msaa = msaa; - m_owner = &renderContext; - m_defaultState = defaultState; - m_gpuUsage = gpuUsage; - m_cpuUsage = cpuUsage; - if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && scratch ) - { - WriteScratch s = { scratch, writeScratchSize, renderContext.GetRecordingFrameNumber() }; - m_writeScratches.push_back( s ); + auto srgb = DXGI_FORMAT( Tr2RenderContextEnum::MakeSrgb( desc.GetFormat() ) ); + if( srgb != rtv.Format ) + { + rtv.Format = srgb; + renderContext.CreateRenderTargetView( texture, &rtv, m_rtv[1] ); + } + else + { + m_rtv[1] = m_rtv[0]; + } } - - return S_OK; } - - void Tr2TextureAL::Destroy() + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) { - m_mipMapGenerator.reset(); - - for( auto it = begin( m_textures ); it != end( m_textures ); ++it ) + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.NumDescriptors = 1; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + + D3D12_DEPTH_STENCIL_VIEW_DESC dsv; + dsv.Format = DXGI_FORMAT( desc.GetFormat() ); + dsv.Flags = D3D12_DSV_FLAG_NONE; + if( msaa.samples > 1 ) { - RELEASE_LATER( m_owner, *it ); + dsv.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMS; } - m_textures.clear(); - for( auto it = begin( m_writeScratches ); it != end( m_writeScratches ); ++it ) + else { - RELEASE_LATER( m_owner, it->scratch ); + dsv.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; + dsv.Texture2D.MipSlice = 0; } - m_writeScratches.clear(); - m_mappedScratch = m_writeScratches.end(); - m_readScratch = nullptr; - m_currentTextureIndex = 0; - memset( &m_desc, 0, sizeof( m_desc ) ); - m_msaa = Tr2MsaaDesc(); - m_owner = nullptr; - m_defaultState = D3D12_RESOURCE_STATE_COMMON; - m_gpuUsage = Tr2GpuUsage::NONE; - m_cpuUsage = Tr2CpuUsage::NONE; - // JB: Don't need to ReleaseLater() because views aren't actually GPU visible - m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = nullptr; - m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; - m_srvIndicesInHeap[0] = 0xffffffff; - m_srvIndicesInHeap[1] = 0xffffffff; - m_rtv.clear(); - m_dsv = nullptr; - m_uav.clear(); + renderContext.CreateDepthStencilView( texture, dsv, m_dsv ); } - bool Tr2TextureAL::IsValid() const + m_textures.push_back( texture ); + m_desc = desc; + m_msaa = msaa; + m_owner = &renderContext; + m_defaultState = defaultState; + m_gpuUsage = gpuUsage; + m_cpuUsage = cpuUsage; + if( HasFlag( cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && scratch ) { - return !m_textures.empty(); + WriteScratch s = { scratch, writeScratchSize, renderContext.GetRecordingFrameNumber() }; + m_writeScratches.push_back( s ); } - ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) - { - if( m_msaa.samples <= 1 ) - { - return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); - } - - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !destination.IsValid() ) - { - return E_INVALIDARG; - } - if( !IsWritable( destination.m_gpuUsage ) ) - { - return E_INVALIDARG; - } - if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) - { - return E_INVALIDARG; - } - if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) - { - return E_INVALIDARG; - } - if( destination.m_msaa.samples > 1 ) - { - return E_INVALIDARG; - } + return S_OK; +} - auto srcState = m_defaultState; - renderContext.IsBoundDx12( *this, srcState ); +void Tr2TextureAL::Destroy() +{ + m_mipMapGenerator.reset(); - D3D12_RESOURCE_BARRIER barriers[2]; - ID3D12Resource* resources[2]; - uint32_t barrierCount = 0; - if( srcState != D3D12_RESOURCE_STATE_RESOLVE_SOURCE ) - { - resources[barrierCount] = GetResourceDx12(); - barriers[barrierCount++] = Transition( GetResourceDx12(), srcState, D3D12_RESOURCE_STATE_RESOLVE_SOURCE, 0 ); - } - if( destination.m_defaultState != D3D12_RESOURCE_STATE_RESOLVE_DEST ) - { - resources[barrierCount] = destination.GetResourceDx12(); - barriers[barrierCount++] = Transition( destination.GetResourceDx12(), destination.m_defaultState, D3D12_RESOURCE_STATE_RESOLVE_DEST, 0 ); - } - if( barrierCount ) - { - renderContext.ResourceBarrierDx12( barrierCount, barriers ); - renderContext.FlushBarriersDx12( barrierCount, resources ); - } + for( auto it = begin( m_textures ); it != end( m_textures ); ++it ) + { + RELEASE_LATER( m_owner, *it ); + } + m_textures.clear(); + for( auto it = begin( m_writeScratches ); it != end( m_writeScratches ); ++it ) + { + RELEASE_LATER( m_owner, it->scratch ); + } + m_writeScratches.clear(); + m_mappedScratch = m_writeScratches.end(); + m_readScratch = nullptr; + m_currentTextureIndex = 0; + memset( &m_desc, 0, sizeof( m_desc ) ); + m_msaa = Tr2MsaaDesc(); + m_owner = nullptr; + m_defaultState = D3D12_RESOURCE_STATE_COMMON; + m_gpuUsage = Tr2GpuUsage::NONE; + m_cpuUsage = Tr2CpuUsage::NONE; + + // JB: Don't need to ReleaseLater() because views aren't actually GPU visible + m_view[Tr2RenderContextEnum::COLOR_SPACE_LINEAR] = nullptr; + m_view[Tr2RenderContextEnum::COLOR_SPACE_SRGB] = nullptr; + m_srvIndicesInHeap[0] = 0xffffffff; + m_srvIndicesInHeap[1] = 0xffffffff; + m_rtv.clear(); + m_dsv = nullptr; + m_uav.clear(); +} - renderContext.m_commandList->ResolveSubresource( destination.GetResourceDx12(), 0, GetResourceDx12(), 0, DXGI_FORMAT( m_desc.GetFormat() ) ); +bool Tr2TextureAL::IsValid() const +{ + return !m_textures.empty(); +} - if( barrierCount ) - { - for( uint32_t i = 0; i < barrierCount; ++i ) - { - std::swap( barriers[i].Transition.StateAfter, barriers[i].Transition.StateBefore ); - } - renderContext.ResourceBarrierDx12( barrierCount, barriers ); - FlushBarriersMaybe( *this, destination, renderContext ); - } - return S_OK; +ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) +{ + if( m_msaa.samples <= 1 ) + { + return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); } - ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) + if( !IsValid() || !renderContext.IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( m_desc.GetTrueMipCount() == 1 ) - { - return S_OK; - } + return E_INVALIDCALL; + } + if( !destination.IsValid() ) + { + return E_INVALIDARG; + } + if( !IsWritable( destination.m_gpuUsage ) ) + { + return E_INVALIDARG; + } + if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) + { + return E_INVALIDARG; + } + if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) + { + return E_INVALIDARG; + } + if( destination.m_msaa.samples > 1 ) + { + return E_INVALIDARG; + } - const auto desc = m_textures[0]->GetDesc(); - if( m_desc.GetType() != TEX_TYPE_2D && m_desc.GetType() != TEX_TYPE_CUBE ) - { - return E_INVALIDCALL; - } + auto srcState = m_defaultState; + renderContext.IsBoundDx12( *this, srcState ); - renderContext.SetResourceSet( ::Tr2ResourceSetAL() ); - renderContext.FlushBarriersDx12( m_textures[0] ); + D3D12_RESOURCE_BARRIER barriers[2]; + ID3D12Resource* resources[2]; + uint32_t barrierCount = 0; + if( srcState != D3D12_RESOURCE_STATE_RESOLVE_SOURCE ) + { + resources[barrierCount] = GetResourceDx12(); + barriers[barrierCount++] = Transition( GetResourceDx12(), srcState, D3D12_RESOURCE_STATE_RESOLVE_SOURCE, 0 ); + } + if( destination.m_defaultState != D3D12_RESOURCE_STATE_RESOLVE_DEST ) + { + resources[barrierCount] = destination.GetResourceDx12(); + barriers[barrierCount++] = Transition( destination.GetResourceDx12(), destination.m_defaultState, D3D12_RESOURCE_STATE_RESOLVE_DEST, 0 ); + } + if( barrierCount ) + { + renderContext.ResourceBarrierDx12( barrierCount, barriers ); + renderContext.FlushBarriersDx12( barrierCount, resources ); + } - renderContext.m_dirtyPso = true; + renderContext.m_commandList->ResolveSubresource( destination.GetResourceDx12(), 0, GetResourceDx12(), 0, DXGI_FORMAT( m_desc.GetFormat() ) ); - if( !m_mipMapGenerator ) - { - m_mipMapGenerator.reset( new MipMapGenerator( *m_owner ) ); - } - if( m_owner->FormatIsUAVCompatibleDx12( DXGI_FORMAT( m_desc.GetFormat() ) ) ) - { - FORWARD_HR( m_mipMapGenerator->GenerateMips_UnorderedAccessPath( m_textures[0], DXGI_FORMAT( m_desc.GetFormat() ), renderContext.m_commandList, m_defaultState ) ); - } - else if( FormatIsBGR( desc.Format ) ) - { - FORWARD_HR( m_mipMapGenerator->GenerateMips_TexturePathBGR( m_textures[0], renderContext.m_commandList, m_defaultState ) ); - } - else + if( barrierCount ) + { + for( uint32_t i = 0; i < barrierCount; ++i ) { - FORWARD_HR( m_mipMapGenerator->GenerateMips_TexturePath( m_textures[0], renderContext.m_commandList, m_defaultState ) ); + std::swap( barriers[i].Transition.StateAfter, barriers[i].Transition.StateBefore ); } + renderContext.ResourceBarrierDx12( barrierCount, barriers ); + FlushBarriersMaybe( *this, destination, renderContext ); + } + return S_OK; +} +ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) + { + return E_INVALIDCALL; + } + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + if( m_desc.GetTrueMipCount() == 1 ) + { return S_OK; } - ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) + const auto desc = m_textures[0]->GetDesc(); + if( m_desc.GetType() != TEX_TYPE_2D && m_desc.GetType() != TEX_TYPE_CUBE ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !source.IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - auto dstResource = GetResourceDx12(); - auto srcResource = source.GetResourceDx12(); - - auto srcState = source.m_defaultState; - renderContext.IsBoundDx12( source, srcState ); + return E_INVALIDCALL; + } - if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) - { - { - D3D12_RESOURCE_BARRIER barriers[2] = { - TrinityALImpl::Transition( srcResource, srcState, D3D12_RESOURCE_STATE_COPY_SOURCE ), - TrinityALImpl::Transition( dstResource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ), - }; - renderContext.ResourceBarrierDx12( 2, barriers ); - renderContext.FlushBarriersDx12( srcResource, dstResource ); - } - renderContext.m_commandList->CopyResource( dstResource, srcResource ); - { - D3D12_RESOURCE_BARRIER barriers[2] = { - TrinityALImpl::Transition( srcResource, D3D12_RESOURCE_STATE_COPY_SOURCE, srcState ), - TrinityALImpl::Transition( dstResource, D3D12_RESOURCE_STATE_COPY_DEST, m_defaultState ), - }; - renderContext.ResourceBarrierDx12( 2, barriers ); - FlushBarriersMaybe( *this, source, renderContext ); - } - return S_OK; - } + renderContext.SetResourceSet( ::Tr2ResourceSetAL() ); + renderContext.FlushBarriersDx12( m_textures[0] ); + renderContext.m_dirtyPso = true; - Tr2TextureSubresource src = sourceSubresource; - Tr2TextureSubresource dst = destSubresource; + if( !m_mipMapGenerator ) + { + m_mipMapGenerator.reset( new MipMapGenerator( *m_owner ) ); + } + if( m_owner->FormatIsUAVCompatibleDx12( DXGI_FORMAT( m_desc.GetFormat() ) ) ) + { + FORWARD_HR( m_mipMapGenerator->GenerateMips_UnorderedAccessPath( m_textures[0], DXGI_FORMAT( m_desc.GetFormat() ), renderContext.m_commandList, m_defaultState ) ); + } + else if( FormatIsBGR( desc.Format ) ) + { + FORWARD_HR( m_mipMapGenerator->GenerateMips_TexturePathBGR( m_textures[0], renderContext.m_commandList, m_defaultState ) ); + } + else + { + FORWARD_HR( m_mipMapGenerator->GenerateMips_TexturePath( m_textures[0], renderContext.m_commandList, m_defaultState ) ); + } - if( !Crop( src, source.m_desc, dst, m_desc ) ) - { - return E_FAIL; - } + return S_OK; +} - D3D12_BOX box = { src.m_box.left, src.m_box.top, src.m_box.front, src.m_box.right, src.m_box.bottom, src.m_box.back }; +ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) + { + return E_INVALIDCALL; + } + if( !source.IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDARG; + } - const uint32_t srcMipCount = source.m_desc.GetTrueMipCount(); - const uint32_t dstMipCount = m_desc.GetTrueMipCount(); + auto dstResource = GetResourceDx12(); + auto srcResource = source.GetResourceDx12(); - const uint32_t mipCount = std::min( src.GetMipCount(), dst.GetMipCount() ); + auto srcState = source.m_defaultState; + renderContext.IsBoundDx12( source, srcState ); + if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) + { { D3D12_RESOURCE_BARRIER barriers[2] = { TrinityALImpl::Transition( srcResource, srcState, D3D12_RESOURCE_STATE_COPY_SOURCE ), @@ -1281,30 +1245,7 @@ namespace TrinityALImpl renderContext.ResourceBarrierDx12( 2, barriers ); renderContext.FlushBarriersDx12( srcResource, dstResource ); } - - for( uint32_t mip = 0; mip != mipCount; ++mip ) - { - for( uint32_t face = 0; face != src.GetFaceCount(); ++face ) - { - D3D12_TEXTURE_COPY_LOCATION dstLoc = { dstResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, dst.m_startMipLevel + mip + ( dst.m_startFace + face ) * dstMipCount }; - D3D12_TEXTURE_COPY_LOCATION srcLoc = { srcResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, src.m_startMipLevel + mip + ( src.m_startFace + face ) * srcMipCount }; - renderContext.m_commandList->CopyTextureRegion( &dstLoc, dst.m_box.left, dst.m_box.top, dst.m_box.front, &srcLoc, &box ); - } - - if( mip + 1 != src.GetMipCount() ) - { - AdvanceMip( src, source.m_desc, mip ); - AdvanceMip( dst, m_desc, mip ); - } - - box.left = box.left >> 1; - box.right = std::max( box.right >> 1, box.left + 1 ); - box.top = box.top >> 1; - box.bottom = std::max( box.bottom >> 1, box.top + 1 ); - box.front = box.front >> 1; - box.back = std::max( box.back >> 1, box.front + 1 ); - } - + renderContext.m_commandList->CopyResource( dstResource, srcResource ); { D3D12_RESOURCE_BARRIER barriers[2] = { TrinityALImpl::Transition( srcResource, D3D12_RESOURCE_STATE_COPY_SOURCE, srcState ), @@ -1313,424 +1254,482 @@ namespace TrinityALImpl renderContext.ResourceBarrierDx12( 2, barriers ); FlushBarriersMaybe( *this, source, renderContext ); } - return S_OK; } - Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const - { - return m_desc; - } + Tr2TextureSubresource src = sourceSubresource; + Tr2TextureSubresource dst = destSubresource; - const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const + if( !Crop( src, source.m_desc, dst, m_desc ) ) { - return m_msaa; + return E_FAIL; } - Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const - { - return m_gpuUsage; - } + D3D12_BOX box = { src.m_box.left, src.m_box.top, src.m_box.front, src.m_box.right, src.m_box.bottom, src.m_box.back }; + + const uint32_t srcMipCount = source.m_desc.GetTrueMipCount(); + const uint32_t dstMipCount = m_desc.GetTrueMipCount(); + + const uint32_t mipCount = std::min( src.GetMipCount(), dst.GetMipCount() ); - Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const { - return m_cpuUsage; + D3D12_RESOURCE_BARRIER barriers[2] = { + TrinityALImpl::Transition( srcResource, srcState, D3D12_RESOURCE_STATE_COPY_SOURCE ), + TrinityALImpl::Transition( dstResource, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ), + }; + renderContext.ResourceBarrierDx12( 2, barriers ); + renderContext.FlushBarriersDx12( srcResource, dstResource ); } - void Tr2TextureAL::GetRegionSize( const Tr2TextureSubresource& region, uint32_t& pitch, uint64_t& size ) + for( uint32_t mip = 0; mip != mipCount; ++mip ) { - if( region.HasBox() ) + for( uint32_t face = 0; face != src.GetFaceCount(); ++face ) { - pitch = region.GetWidth() * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); - pitch = ( ( pitch + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1 ) / D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; - size = region.GetHeight() * region.GetDepth() * pitch; + D3D12_TEXTURE_COPY_LOCATION dstLoc = { dstResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, dst.m_startMipLevel + mip + ( dst.m_startFace + face ) * dstMipCount }; + D3D12_TEXTURE_COPY_LOCATION srcLoc = { srcResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, src.m_startMipLevel + mip + ( src.m_startFace + face ) * srcMipCount }; + renderContext.m_commandList->CopyTextureRegion( &dstLoc, dst.m_box.left, dst.m_box.top, dst.m_box.front, &srcLoc, &box ); } - else + + if( mip + 1 != src.GetMipCount() ) { - pitch = m_desc.GetMipPitch( region.m_startMipLevel ); - pitch = ( ( pitch + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1 ) / D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; - size = m_desc.GetMipHeight( region.m_startMipLevel ) * m_desc.GetMipDepth( region.m_startMipLevel ) * pitch; + AdvanceMip( src, source.m_desc, mip ); + AdvanceMip( dst, m_desc, mip ); } + + box.left = box.left >> 1; + box.right = std::max( box.right >> 1, box.left + 1 ); + box.top = box.top >> 1; + box.bottom = std::max( box.bottom >> 1, box.top + 1 ); + box.front = box.front >> 1; + box.back = std::max( box.back >> 1, box.front + 1 ); } - ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) { - if( !IsValid() || !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } - if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) - { - return E_INVALIDARG; - } - - uint64_t requiredSize = 0; - uint32_t myPitch = 0; - GetRegionSize( region, myPitch, requiredSize ); + D3D12_RESOURCE_BARRIER barriers[2] = { + TrinityALImpl::Transition( srcResource, D3D12_RESOURCE_STATE_COPY_SOURCE, srcState ), + TrinityALImpl::Transition( dstResource, D3D12_RESOURCE_STATE_COPY_DEST, m_defaultState ), + }; + renderContext.ResourceBarrierDx12( 2, barriers ); + FlushBarriersMaybe( *this, source, renderContext ); + } - auto completed = m_owner->GetRenderedFrameNumber(); - m_mappedScratch = m_writeScratches.end(); - for( auto it = begin( m_writeScratches ); it != end( m_writeScratches ); ++it ) - { - if( completed >= it->frameIndex && requiredSize <= it->size ) - { - m_mappedScratch = it; - break; - } - } + return S_OK; +} - if( m_mappedScratch == m_writeScratches.end() ) - { - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); - auto scratchDesc = BufferDesc( requiredSize ); - WriteScratch scratch; - CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, - nullptr, - IID_PPV_ARGS( &scratch.scratch ) ) ); - scratch.size = requiredSize; - scratch.frameIndex = m_owner->GetRecordingFrameNumber(); - m_writeScratches.push_back( scratch ); - m_mappedScratch = m_writeScratches.begin() + ( m_writeScratches.size() - 1 ); - } +Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - D3D12_RANGE range = { 0, 0 }; - CR_RETURN_HR( m_mappedScratch->scratch->Map( 0, &range, &data ) ); - pitch = myPitch; - m_mappedRegion = region; +const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const +{ + return m_desc; +} - return S_OK; - } +const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const +{ + return m_msaa; +} - void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) - { - if( m_mappedScratch == m_writeScratches.end() || !renderContext.IsValid() || !m_mappedRegion.IsValid() ) - { - return; - } +Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const +{ + return m_gpuUsage; +} - uint64_t requiredSize = 0; - uint32_t pitch = 0; - GetRegionSize( m_mappedRegion, pitch, requiredSize ); +Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const +{ + return m_cpuUsage; +} - m_mappedScratch->scratch->Unmap( 0, nullptr ); +void Tr2TextureAL::GetRegionSize( const Tr2TextureSubresource& region, uint32_t& pitch, uint64_t& size ) +{ + if( region.HasBox() ) + { + pitch = region.GetWidth() * Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + pitch = ( ( pitch + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1 ) / D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; + size = region.GetHeight() * region.GetDepth() * pitch; + } + else + { + pitch = m_desc.GetMipPitch( region.m_startMipLevel ); + pitch = ( ( pitch + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1 ) / D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ) * D3D12_TEXTURE_DATA_PITCH_ALIGNMENT; + size = m_desc.GetMipHeight( region.m_startMipLevel ) * m_desc.GetMipDepth( region.m_startMipLevel ) * pitch; + } +} - auto texture = GetResourceDx12(); - auto subresource = m_mappedRegion.m_startFace * m_desc.GetTrueMipCount() + m_mappedRegion.m_startMipLevel; - D3D12_RESOURCE_DESC desc = texture->GetDesc(); - D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; - layout.Offset = 0; - if( m_mappedRegion.HasBox() ) - { - D3D12_SUBRESOURCE_FOOTPRINT f = { desc.Format, m_mappedRegion.GetWidth(), m_mappedRegion.GetHeight(), m_mappedRegion.GetDepth(), pitch }; - layout.Footprint = f; - } - else - { - auto mip = m_mappedRegion.m_startMipLevel; - D3D12_SUBRESOURCE_FOOTPRINT f = { desc.Format, m_desc.GetMipWidth( mip ), m_desc.GetMipHeight( mip ), m_desc.GetMipDepth( mip ), pitch }; - layout.Footprint = f; - } - D3D12_TEXTURE_COPY_LOCATION Dst = { texture, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, subresource }; - D3D12_TEXTURE_COPY_LOCATION Src = { m_mappedScratch->scratch, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; +ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() || !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDCALL; + } + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) + { + return E_INVALIDARG; + } - renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( texture, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ) ); - renderContext.FlushBarriersDx12( texture ); + uint64_t requiredSize = 0; + uint32_t myPitch = 0; + GetRegionSize( region, myPitch, requiredSize ); - if( m_mappedRegion.HasBox() ) - { - D3D12_BOX box = { 0, 0, 0, m_mappedRegion.m_box.GetWidth(), m_mappedRegion.m_box.GetHeight(), m_mappedRegion.m_box.GetDepth() }; - renderContext.m_commandList->CopyTextureRegion( - &Dst, - m_mappedRegion.m_box.left, - m_mappedRegion.m_box.top, - m_mappedRegion.m_box.front, - &Src, - &box ); - } - else + auto completed = m_owner->GetRenderedFrameNumber(); + m_mappedScratch = m_writeScratches.end(); + for( auto it = begin( m_writeScratches ); it != end( m_writeScratches ); ++it ) + { + if( completed >= it->frameIndex && requiredSize <= it->size ) { - renderContext.m_commandList->CopyTextureRegion( &Dst, 0, 0, 0, &Src, nullptr ); + m_mappedScratch = it; + break; } + } - renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( texture, D3D12_RESOURCE_STATE_COPY_DEST, m_defaultState ) ); - FlushBarriersMaybe( *this, renderContext ); + if( m_mappedScratch == m_writeScratches.end() ) + { + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_UPLOAD ); + auto scratchDesc = BufferDesc( requiredSize ); + WriteScratch scratch; + CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_GENERIC_READ, + nullptr, + IID_PPV_ARGS( &scratch.scratch ) ) ); + scratch.size = requiredSize; + scratch.frameIndex = m_owner->GetRecordingFrameNumber(); + m_writeScratches.push_back( scratch ); + m_mappedScratch = m_writeScratches.begin() + ( m_writeScratches.size() - 1 ); + } - m_mappedScratch->frameIndex = m_owner->GetRecordingFrameNumber(); + D3D12_RANGE range = { 0, 0 }; + CR_RETURN_HR( m_mappedScratch->scratch->Map( 0, &range, &data ) ); + pitch = myPitch; + m_mappedRegion = region; - m_mappedRegion = Tr2TextureSubresource(); - m_mappedScratch = m_writeScratches.end(); - } + return S_OK; +} - ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) +{ + if( m_mappedScratch == m_writeScratches.end() || !renderContext.IsValid() || !m_mappedRegion.IsValid() ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } + return; + } - auto texture = GetResourceDx12(); + uint64_t requiredSize = 0; + uint32_t pitch = 0; + GetRegionSize( m_mappedRegion, pitch, requiredSize ); - CComPtr scratch = m_readScratch; - if( !scratch ) - { - auto totalSize = GetRequiredIntermediateSize( texture, 0, 1 ); - auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_READBACK ); - auto scratchDesc = BufferDesc( totalSize ); - CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( - &scratchHeap, - D3D12_HEAP_FLAG_NONE, - &scratchDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &scratch ) ) ); - } + m_mappedScratch->scratch->Unmap( 0, nullptr ); - renderContext.ResourceBarrierDx12( Transition( texture, m_defaultState, D3D12_RESOURCE_STATE_COPY_SOURCE ) ); - renderContext.FlushBarriersDx12( texture ); + auto texture = GetResourceDx12(); + auto subresource = m_mappedRegion.m_startFace * m_desc.GetTrueMipCount() + m_mappedRegion.m_startMipLevel; + D3D12_RESOURCE_DESC desc = texture->GetDesc(); + D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; + layout.Offset = 0; + if( m_mappedRegion.HasBox() ) + { + D3D12_SUBRESOURCE_FOOTPRINT f = { desc.Format, m_mappedRegion.GetWidth(), m_mappedRegion.GetHeight(), m_mappedRegion.GetDepth(), pitch }; + layout.Footprint = f; + } + else + { + auto mip = m_mappedRegion.m_startMipLevel; + D3D12_SUBRESOURCE_FOOTPRINT f = { desc.Format, m_desc.GetMipWidth( mip ), m_desc.GetMipHeight( mip ), m_desc.GetMipDepth( mip ), pitch }; + layout.Footprint = f; + } + D3D12_TEXTURE_COPY_LOCATION Dst = { texture, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, subresource }; + D3D12_TEXTURE_COPY_LOCATION Src = { m_mappedScratch->scratch, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; - auto subresource = region.m_startFace * m_desc.GetTrueMipCount() + region.m_startMipLevel; - D3D12_RESOURCE_DESC desc = texture->GetDesc(); - D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; - m_owner->m_device->GetCopyableFootprints( &desc, subresource, 1, 0, &layout, nullptr, nullptr, nullptr ); - layout.Offset = 0; - D3D12_TEXTURE_COPY_LOCATION Src = { texture, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, subresource }; - D3D12_TEXTURE_COPY_LOCATION Dst = { scratch, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; + renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( texture, m_defaultState, D3D12_RESOURCE_STATE_COPY_DEST ) ); + renderContext.FlushBarriersDx12( texture ); + if( m_mappedRegion.HasBox() ) + { + D3D12_BOX box = { 0, 0, 0, m_mappedRegion.m_box.GetWidth(), m_mappedRegion.m_box.GetHeight(), m_mappedRegion.m_box.GetDepth() }; + renderContext.m_commandList->CopyTextureRegion( + &Dst, + m_mappedRegion.m_box.left, + m_mappedRegion.m_box.top, + m_mappedRegion.m_box.front, + &Src, + &box ); + } + else + { renderContext.m_commandList->CopyTextureRegion( &Dst, 0, 0, 0, &Src, nullptr ); + } - renderContext.ResourceBarrierDx12( Transition( texture, D3D12_RESOURCE_STATE_COPY_SOURCE, m_defaultState ) ); - FlushBarriersMaybe( *this, renderContext ); - - if( synchronize ) - { - auto hr = renderContext.FlushAndSyncDx12(); - if( FAILED( hr ) ) - { - RELEASE_LATER( m_owner, scratch ); - scratch = nullptr; - return hr; - } - } + renderContext.ResourceBarrierDx12( TrinityALImpl::Transition( texture, D3D12_RESOURCE_STATE_COPY_DEST, m_defaultState ) ); + FlushBarriersMaybe( *this, renderContext ); - CR_RETURN_HR( scratch->Map( 0, nullptr, (void**)&data ) ); - m_readScratch = scratch; + m_mappedScratch->frameIndex = m_owner->GetRecordingFrameNumber(); - pitch = layout.Footprint.RowPitch; + m_mappedRegion = Tr2TextureSubresource(); + m_mappedScratch = m_writeScratches.end(); +} - return S_OK; +ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) + { + return E_INVALIDCALL; } - - void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& ) + if( !renderContext.IsValid() ) { - if( !m_readScratch ) - { - return; - } - D3D12_RANGE writtenRange = { 0, 0 }; - m_readScratch->Unmap( 0, &writtenRange ); - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) - { - m_readScratch = nullptr; - } + return E_INVALIDARG; } - - ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t depthPitch, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } + return E_INVALIDCALL; + } - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - return E_INVALIDCALL; - } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) - { - return E_INVALIDCALL; - } + auto texture = GetResourceDx12(); - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } + CComPtr scratch = m_readScratch; + if( !scratch ) + { + auto totalSize = GetRequiredIntermediateSize( texture, 0, 1 ); + auto scratchHeap = HeapDesc( D3D12_HEAP_TYPE_READBACK ); + auto scratchDesc = BufferDesc( totalSize ); + CR_RETURN_HR( m_owner->m_device->CreateCommittedResource( + &scratchHeap, + D3D12_HEAP_FLAG_NONE, + &scratchDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &scratch ) ) ); + } - void* dest; - uint32_t destPitch; - FORWARD_HR( MapForWriting( region, dest, destPitch, renderContext ) ); + renderContext.ResourceBarrierDx12( Transition( texture, m_defaultState, D3D12_RESOURCE_STATE_COPY_SOURCE ) ); + renderContext.FlushBarriersDx12( texture ); - auto clamped = region; - clamped.ClampToTexture( m_desc ); + auto subresource = region.m_startFace * m_desc.GetTrueMipCount() + region.m_startMipLevel; + D3D12_RESOURCE_DESC desc = texture->GetDesc(); + D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; + m_owner->m_device->GetCopyableFootprints( &desc, subresource, 1, 0, &layout, nullptr, nullptr, nullptr ); + layout.Offset = 0; + D3D12_TEXTURE_COPY_LOCATION Src = { texture, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, subresource }; + D3D12_TEXTURE_COPY_LOCATION Dst = { scratch, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, layout }; - auto bpp = Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); - auto width = clamped.m_box.GetWidth(); - width *= bpp; - auto depthSlice = static_cast( source ); + renderContext.m_commandList->CopyTextureRegion( &Dst, 0, 0, 0, &Src, nullptr ); - for( uint32_t j = clamped.m_box.front; j != clamped.m_box.back; ++j ) + renderContext.ResourceBarrierDx12( Transition( texture, D3D12_RESOURCE_STATE_COPY_SOURCE, m_defaultState ) ); + FlushBarriersMaybe( *this, renderContext ); + + if( synchronize ) + { + auto hr = renderContext.FlushAndSyncDx12(); + if( FAILED( hr ) ) { - auto src = depthSlice; - for( uint32_t i = clamped.m_box.top; i != clamped.m_box.bottom; ++i ) - { - memcpy( dest, src, width ); - dest = static_cast( dest ) + destPitch; - src += pitch; - } - depthSlice += depthPitch; + RELEASE_LATER( m_owner, scratch ); + scratch = nullptr; + return hr; } - UnmapForWriting( renderContext ); - - return S_OK; } + CR_RETURN_HR( scratch->Map( 0, nullptr, (void**)&data ) ); + m_readScratch = scratch; + pitch = layout.Footprint.RowPitch; + + return S_OK; +} - ID3D12Resource* Tr2TextureAL::GetResourceDx12() const +void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& ) +{ + if( !m_readScratch ) { - if( m_currentTextureIndex < m_textures.size() ) - { - return m_textures[m_currentTextureIndex]; - } - return nullptr; + return; } - - D3D12_RESOURCE_STATES Tr2TextureAL::GetResourceState() const + D3D12_RANGE writtenRange = { 0, 0 }; + m_readScratch->Unmap( 0, &writtenRange ); + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) ) { - return m_defaultState; + m_readScratch = nullptr; } +} - const std::shared_ptr& Tr2TextureAL::GetRtvDescriptorHandleDx12( Tr2RenderContextEnum::ColorSpace colorSpace, uint32_t slice ) const +ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t depthPitch, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() ) + { + return E_INVALIDCALL; + } + if( !renderContext.IsValid() ) { - auto slices = std::max( 1u, m_desc.GetDepth() ); - auto index = m_currentTextureIndex * slices * 2 + 2 * slice + colorSpace; - return m_rtv[index]; + return E_INVALIDARG; } - void Tr2TextureAL::AssignFromSwapChainDx12( const std::vector>& backBuffers, const std::vector>& rtvs, Tr2PrimaryRenderContextAL& renderContext ) + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - Destroy(); - if( !backBuffers.empty() ) - { - auto desc = backBuffers[0]->GetDesc(); - m_msaa.samples = desc.SampleDesc.Count; - m_msaa.quality = desc.SampleDesc.Quality; - m_desc = Tr2BitmapDimensions( - Tr2RenderContextEnum::TEX_TYPE_2D, - Tr2RenderContextEnum::PixelFormat( desc.Format ), - uint32_t( desc.Width ), - uint32_t( desc.Height ), - 1, - 1 - ); - m_textures = backBuffers; - m_rtv = rtvs; - m_owner = &renderContext; - m_cpuUsage = Tr2CpuUsage::READ; - m_gpuUsage = Tr2GpuUsage::RENDER_TARGET; - m_defaultState = D3D12_RESOURCE_STATE_RENDER_TARGET; - } + return E_INVALIDCALL; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; } - uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace ) const + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) { - return m_srvIndicesInHeap[colorSpace]; + return E_INVALIDARG; } - - uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t mip ) const + + void* dest; + uint32_t destPitch; + FORWARD_HR( MapForWriting( region, dest, destPitch, renderContext ) ); + + auto clamped = region; + clamped.ClampToTexture( m_desc ); + + auto bpp = Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + auto width = clamped.m_box.GetWidth(); + width *= bpp; + auto depthSlice = static_cast( source ); + + for( uint32_t j = clamped.m_box.front; j != clamped.m_box.back; ++j ) { - if( mip < m_uav.size() && m_uav[mip] ) + auto src = depthSlice; + for( uint32_t i = clamped.m_box.top; i != clamped.m_box.bottom; ++i ) { - return m_uav[mip]->GetIndexInHeap(); + memcpy( dest, src, width ); + dest = static_cast( dest ) + destPitch; + src += pitch; } - return 0xffffffff; + depthSlice += depthPitch; } + UnmapForWriting( renderContext ); + + return S_OK; +} + - void Tr2TextureAL::SetSwapChainBufferIndexDx12( uint32_t index ) + +ID3D12Resource* Tr2TextureAL::GetResourceDx12() const +{ + if( m_currentTextureIndex < m_textures.size() ) { - m_currentTextureIndex = index; + return m_textures[m_currentTextureIndex]; } + return nullptr; +} + +D3D12_RESOURCE_STATES Tr2TextureAL::GetResourceState() const +{ + return m_defaultState; +} - void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +const std::shared_ptr& Tr2TextureAL::GetRtvDescriptorHandleDx12( Tr2RenderContextEnum::ColorSpace colorSpace, uint32_t slice ) const +{ + auto slices = std::max( 1u, m_desc.GetDepth() ); + auto index = m_currentTextureIndex * slices * 2 + 2 * slice + colorSpace; + return m_rtv[index]; +} + +void Tr2TextureAL::AssignFromSwapChainDx12( const std::vector>& backBuffers, const std::vector>& rtvs, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !backBuffers.empty() ) { - description["type"] = "Tr2TextureAL"; + auto desc = backBuffers[0]->GetDesc(); + m_msaa.samples = desc.SampleDesc.Count; + m_msaa.quality = desc.SampleDesc.Quality; + m_desc = Tr2BitmapDimensions( + Tr2RenderContextEnum::TEX_TYPE_2D, + Tr2RenderContextEnum::PixelFormat( desc.Format ), + uint32_t( desc.Width ), + uint32_t( desc.Height ), + 1, + 1 ); + m_textures = backBuffers; + m_rtv = rtvs; + m_owner = &renderContext; + m_cpuUsage = Tr2CpuUsage::READ; + m_gpuUsage = Tr2GpuUsage::RENDER_TARGET; + m_defaultState = D3D12_RESOURCE_STATE_RENDER_TARGET; + } +} - unsigned size = 0; - for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) - { - size += m_desc.GetMipSize( i ); - } +uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace ) const +{ + return m_srvIndicesInHeap[colorSpace]; +} - description["size"] = std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); - description["width"] = std::to_string( m_desc.GetWidth() ); - description["height"] = std::to_string( m_desc.GetHeight() ); - description["depth"] = std::to_string( m_desc.GetDepth() ); - description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); - description["format"] = std::to_string( int( m_desc.GetFormat() ) ); - description["texType"] = std::to_string( int( m_desc.GetType() ) ); - description["array"] = std::to_string( m_desc.GetArraySize() ); - description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); - description["msaa"] = std::to_string( m_msaa.samples ); - description["name"] = m_name; - } - - ALResult Tr2TextureAL::SetName( const char* name ) - { - m_name = name; - auto length = strlen( name ); - for( auto& t : m_textures ) - { - SetDebugName( t, name ); - } - return S_OK; +uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t mip ) const +{ + if( mip < m_uav.size() && m_uav[mip] ) + { + return m_uav[mip]->GetIndexInHeap(); } + return 0xffffffff; +} + +void Tr2TextureAL::SetSwapChainBufferIndexDx12( uint32_t index ) +{ + m_currentTextureIndex = index; +} - const char* Tr2TextureAL::GetName() const +void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2TextureAL"; + + unsigned size = 0; + for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) { - return m_name.c_str(); + size += m_desc.GetMipSize( i ); } - bool Tr2TextureAL::operator==( const Tr2TextureAL& other ) const + description["size"] = std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); + description["width"] = std::to_string( m_desc.GetWidth() ); + description["height"] = std::to_string( m_desc.GetHeight() ); + description["depth"] = std::to_string( m_desc.GetDepth() ); + description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); + description["format"] = std::to_string( int( m_desc.GetFormat() ) ); + description["texType"] = std::to_string( int( m_desc.GetType() ) ); + description["array"] = std::to_string( m_desc.GetArraySize() ); + description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); + description["msaa"] = std::to_string( m_msaa.samples ); + description["name"] = m_name; +} + +ALResult Tr2TextureAL::SetName( const char* name ) +{ + m_name = name; + auto length = strlen( name ); + for( auto& t : m_textures ) { - return GetResourceDx12() == other.GetResourceDx12(); + SetDebugName( t, name ); } + return S_OK; +} + +const char* Tr2TextureAL::GetName() const +{ + return m_name.c_str(); +} + +bool Tr2TextureAL::operator==( const Tr2TextureAL& other ) const +{ + return GetResourceDx12() == other.GetResourceDx12(); +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2TextureALDx12.h b/trinityal/dx12/Tr2TextureALDx12.h index f1e915515..18fcb21bc 100644 --- a/trinityal/dx12/Tr2TextureALDx12.h +++ b/trinityal/dx12/Tr2TextureALDx12.h @@ -17,112 +17,112 @@ namespace TrinityALImpl { - class Tr2ResourceSetAL; - class Tr2RtShaderTableAL; +class Tr2ResourceSetAL; +class Tr2RtShaderTableAL; } namespace TrinityALImpl { - class Tr2TextureAL : public Tr2DeviceResourceAL +class Tr2TextureAL : public Tr2DeviceResourceAL +{ +public: + Tr2TextureAL(); + ~Tr2TextureAL(); + + ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); + ALResult OpenShared( uintptr_t, Tr2GpuUsage::Type, Tr2PrimaryRenderContextAL& ) + { + return E_NOTIMPL; + } + void Destroy(); + + bool IsValid() const; + + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BitmapDimensions& GetDesc() const; + const Tr2MsaaDesc& GetMsaaDesc() const; + Tr2GpuUsage::Type GetGpuUsage() const; + Tr2CpuUsage::Type GetCpuUsage() const; + + ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + { + return MapForReading( region, true, data, pitch, renderContext ); + } + ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); + + ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); + ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); + ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); + ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); + + uintptr_t GetSharedHandle() const + { + return 0; + } + + ID3D12Resource* GetResourceDx12() const; + D3D12_RESOURCE_STATES GetResourceState() const; + const std::shared_ptr& GetRtvDescriptorHandleDx12( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR, uint32_t slice = 0 ) const; + void AssignFromSwapChainDx12( const std::vector>& backBuffers, const std::vector>& rtvs, Tr2PrimaryRenderContextAL& renderContext ); + void SetSwapChainBufferIndexDx12( uint32_t index ); + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + const char* GetName() const; + + bool operator==( const Tr2TextureAL& other ) const; + + uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; + uint32_t GetUavIndexInHeap( uint32_t mip ) const; + +private: + void GetRegionSize( const Tr2TextureSubresource& region, uint32_t& pitch, uint64_t& size ); + + Tr2BitmapDimensions m_desc; + Tr2MsaaDesc m_msaa; + Tr2CpuUsage::Type m_cpuUsage; + Tr2GpuUsage::Type m_gpuUsage; + + std::vector> m_textures; + + struct WriteScratch { - public: - Tr2TextureAL(); - ~Tr2TextureAL(); - - ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); - ALResult OpenShared( uintptr_t, Tr2GpuUsage::Type, Tr2PrimaryRenderContextAL& ) - { - return E_NOTIMPL; - } - void Destroy(); - - bool IsValid() const; - - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BitmapDimensions& GetDesc() const; - const Tr2MsaaDesc& GetMsaaDesc() const; - Tr2GpuUsage::Type GetGpuUsage() const; - Tr2CpuUsage::Type GetCpuUsage() const; - - ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - return MapForReading( region, true, data, pitch, renderContext ); - } - ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); - - ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); - ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); - ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); - ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); - - uintptr_t GetSharedHandle() const - { - return 0; - } - - ID3D12Resource* GetResourceDx12() const; - D3D12_RESOURCE_STATES GetResourceState() const; - const std::shared_ptr& GetRtvDescriptorHandleDx12( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR, uint32_t slice = 0 ) const; - void AssignFromSwapChainDx12( const std::vector>& backBuffers, const std::vector>& rtvs, Tr2PrimaryRenderContextAL& renderContext ); - void SetSwapChainBufferIndexDx12( uint32_t index ); - - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - const char* GetName() const; - - bool operator==( const Tr2TextureAL& other ) const; - - uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; - uint32_t GetUavIndexInHeap( uint32_t mip ) const; - - private: - void GetRegionSize( const Tr2TextureSubresource& region, uint32_t& pitch, uint64_t& size ); - - Tr2BitmapDimensions m_desc; - Tr2MsaaDesc m_msaa; - Tr2CpuUsage::Type m_cpuUsage; - Tr2GpuUsage::Type m_gpuUsage; - - std::vector> m_textures; - - struct WriteScratch - { - CComPtr scratch; - uint64_t size; - uint64_t frameIndex; - }; - typedef std::vector WriteScratches; - - WriteScratches m_writeScratches; - WriteScratches::iterator m_mappedScratch; - - CComPtr m_readScratch; - Tr2TextureSubresource m_mappedRegion; - - Tr2PrimaryRenderContextAL* m_owner; - uint32_t m_currentTextureIndex; - D3D12_RESOURCE_STATES m_defaultState; - - D3D12_SHADER_RESOURCE_VIEW_DESC m_srvDesc[2]; - std::vector> m_uav; - std::shared_ptr m_view[2]; - std::vector> m_rtv; - std::shared_ptr m_dsv; - uint32_t m_srvIndicesInHeap[2]; - std::string m_name; - - struct MipMapGenerator; - std::unique_ptr m_mipMapGenerator; - - friend class Tr2ResourceSetAL; - friend class Tr2RenderContextAL; - friend class Tr2RtShaderTableAL; + CComPtr scratch; + uint64_t size; + uint64_t frameIndex; }; + typedef std::vector WriteScratches; + + WriteScratches m_writeScratches; + WriteScratches::iterator m_mappedScratch; + + CComPtr m_readScratch; + Tr2TextureSubresource m_mappedRegion; + + Tr2PrimaryRenderContextAL* m_owner; + uint32_t m_currentTextureIndex; + D3D12_RESOURCE_STATES m_defaultState; + + D3D12_SHADER_RESOURCE_VIEW_DESC m_srvDesc[2]; + std::vector> m_uav; + std::shared_ptr m_view[2]; + std::vector> m_rtv; + std::shared_ptr m_dsv; + uint32_t m_srvIndicesInHeap[2]; + std::string m_name; + + struct MipMapGenerator; + std::unique_ptr m_mipMapGenerator; + + friend class Tr2ResourceSetAL; + friend class Tr2RenderContextAL; + friend class Tr2RtShaderTableAL; +}; } #endif diff --git a/trinityal/dx12/Tr2VertexLayoutALDx12.cpp b/trinityal/dx12/Tr2VertexLayoutALDx12.cpp index 74dca23fb..09e671456 100644 --- a/trinityal/dx12/Tr2VertexLayoutALDx12.cpp +++ b/trinityal/dx12/Tr2VertexLayoutALDx12.cpp @@ -11,191 +11,193 @@ namespace { - const char* s_usageNames[] = { - "POSITION", - "COLOR", - "NORMAL", - "TANGENT", - "BINORMAL", - "TEXCOORD", - "BLENDINDICES", - "BLENDWEIGHT", - }; - static_assert( sizeof( s_usageNames ) / sizeof( s_usageNames[0] ) == Tr2VertexDefinition::NUM_USAGE_CODE, "Usage name count mismatch" ); - - DXGI_FORMAT GetDxgiDataType( Tr2VertexDefinition::DataType dataType ) - { +const char* s_usageNames[] = { + "POSITION", + "COLOR", + "NORMAL", + "TANGENT", + "BINORMAL", + "TEXCOORD", + "BLENDINDICES", + "BLENDWEIGHT", +}; +static_assert( sizeof( s_usageNames ) / sizeof( s_usageNames[0] ) == Tr2VertexDefinition::NUM_USAGE_CODE, "Usage name count mismatch" ); + +DXGI_FORMAT GetDxgiDataType( Tr2VertexDefinition::DataType dataType ) +{ -#define VD_CASE(x,y) case Tr2VertexDefinition::x : return y; - switch( dataType ) - { - VD_CASE( BYTE_1, DXGI_FORMAT_R8_SINT ); - VD_CASE( BYTE_2, DXGI_FORMAT_R8G8_SINT ); - VD_CASE( BYTE_3, DXGI_FORMAT_UNKNOWN ); - VD_CASE( BYTE_4, DXGI_FORMAT_R8G8B8A8_SINT ); - - VD_CASE( UBYTE_1, DXGI_FORMAT_R8_UINT ); - VD_CASE( UBYTE_2, DXGI_FORMAT_R8G8_UINT ); - VD_CASE( UBYTE_3, DXGI_FORMAT_UNKNOWN ); - VD_CASE( UBYTE_4, DXGI_FORMAT_R8G8B8A8_UINT ); - - VD_CASE( BYTE_1_NORM, DXGI_FORMAT_R8_SNORM ); - VD_CASE( BYTE_2_NORM, DXGI_FORMAT_R8G8_SNORM ); - VD_CASE( BYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); - VD_CASE( BYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_SNORM ); - - VD_CASE( UBYTE_1_NORM, DXGI_FORMAT_R8_UNORM ); - VD_CASE( UBYTE_2_NORM, DXGI_FORMAT_R8G8_UNORM ); - VD_CASE( UBYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); - VD_CASE( UBYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_UNORM ); - - - VD_CASE( SHORT_1, DXGI_FORMAT_R16_SINT ); - VD_CASE( SHORT_2, DXGI_FORMAT_R16G16_SINT ); - VD_CASE( SHORT_3, DXGI_FORMAT_UNKNOWN ); - VD_CASE( SHORT_4, DXGI_FORMAT_R16G16B16A16_SINT ); - - VD_CASE( USHORT_1, DXGI_FORMAT_R16_UINT ); - VD_CASE( USHORT_2, DXGI_FORMAT_R16G16_UINT ); - VD_CASE( USHORT_3, DXGI_FORMAT_UNKNOWN ); - VD_CASE( USHORT_4, DXGI_FORMAT_R16G16B16A16_UINT ); - - VD_CASE( SHORT_1_NORM, DXGI_FORMAT_R16_SNORM ); - VD_CASE( SHORT_2_NORM, DXGI_FORMAT_R16G16_SNORM ); - VD_CASE( SHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); - VD_CASE( SHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_SNORM ); - - VD_CASE( USHORT_1_NORM, DXGI_FORMAT_R16_UNORM ); - VD_CASE( USHORT_2_NORM, DXGI_FORMAT_R16G16_UNORM ); - VD_CASE( USHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); - VD_CASE( USHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_UNORM ); - - - VD_CASE( INT32_1, DXGI_FORMAT_R32_SINT ); - VD_CASE( INT32_2, DXGI_FORMAT_R32G32_SINT ); - VD_CASE( INT32_3, DXGI_FORMAT_R32G32B32_SINT ); - VD_CASE( INT32_4, DXGI_FORMAT_R32G32B32A32_SINT ); - - VD_CASE( UINT32_1, DXGI_FORMAT_R32_UINT ); - VD_CASE( UINT32_2, DXGI_FORMAT_R32G32_UINT ); - VD_CASE( UINT32_3, DXGI_FORMAT_R32G32B32_UINT ); - VD_CASE( UINT32_4, DXGI_FORMAT_R32G32B32A32_UINT ); - - - VD_CASE( FLOAT16_1, DXGI_FORMAT_R16_FLOAT ); - VD_CASE( FLOAT16_2, DXGI_FORMAT_R16G16_FLOAT ); - VD_CASE( FLOAT16_3, DXGI_FORMAT_UNKNOWN ); - VD_CASE( FLOAT16_4, DXGI_FORMAT_R16G16B16A16_FLOAT ); - - VD_CASE( FLOAT32_1, DXGI_FORMAT_R32_FLOAT ); - VD_CASE( FLOAT32_2, DXGI_FORMAT_R32G32_FLOAT ); - VD_CASE( FLOAT32_3, DXGI_FORMAT_R32G32B32_FLOAT ); - VD_CASE( FLOAT32_4, DXGI_FORMAT_R32G32B32A32_FLOAT ); - } +#define VD_CASE( x, y ) \ + case Tr2VertexDefinition::x: \ + return y; + switch( dataType ) + { + VD_CASE( BYTE_1, DXGI_FORMAT_R8_SINT ); + VD_CASE( BYTE_2, DXGI_FORMAT_R8G8_SINT ); + VD_CASE( BYTE_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( BYTE_4, DXGI_FORMAT_R8G8B8A8_SINT ); + + VD_CASE( UBYTE_1, DXGI_FORMAT_R8_UINT ); + VD_CASE( UBYTE_2, DXGI_FORMAT_R8G8_UINT ); + VD_CASE( UBYTE_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( UBYTE_4, DXGI_FORMAT_R8G8B8A8_UINT ); + + VD_CASE( BYTE_1_NORM, DXGI_FORMAT_R8_SNORM ); + VD_CASE( BYTE_2_NORM, DXGI_FORMAT_R8G8_SNORM ); + VD_CASE( BYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( BYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_SNORM ); + + VD_CASE( UBYTE_1_NORM, DXGI_FORMAT_R8_UNORM ); + VD_CASE( UBYTE_2_NORM, DXGI_FORMAT_R8G8_UNORM ); + VD_CASE( UBYTE_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( UBYTE_4_NORM, DXGI_FORMAT_R8G8B8A8_UNORM ); + + + VD_CASE( SHORT_1, DXGI_FORMAT_R16_SINT ); + VD_CASE( SHORT_2, DXGI_FORMAT_R16G16_SINT ); + VD_CASE( SHORT_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( SHORT_4, DXGI_FORMAT_R16G16B16A16_SINT ); + + VD_CASE( USHORT_1, DXGI_FORMAT_R16_UINT ); + VD_CASE( USHORT_2, DXGI_FORMAT_R16G16_UINT ); + VD_CASE( USHORT_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( USHORT_4, DXGI_FORMAT_R16G16B16A16_UINT ); + + VD_CASE( SHORT_1_NORM, DXGI_FORMAT_R16_SNORM ); + VD_CASE( SHORT_2_NORM, DXGI_FORMAT_R16G16_SNORM ); + VD_CASE( SHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( SHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_SNORM ); + + VD_CASE( USHORT_1_NORM, DXGI_FORMAT_R16_UNORM ); + VD_CASE( USHORT_2_NORM, DXGI_FORMAT_R16G16_UNORM ); + VD_CASE( USHORT_3_NORM, DXGI_FORMAT_UNKNOWN ); + VD_CASE( USHORT_4_NORM, DXGI_FORMAT_R16G16B16A16_UNORM ); + + + VD_CASE( INT32_1, DXGI_FORMAT_R32_SINT ); + VD_CASE( INT32_2, DXGI_FORMAT_R32G32_SINT ); + VD_CASE( INT32_3, DXGI_FORMAT_R32G32B32_SINT ); + VD_CASE( INT32_4, DXGI_FORMAT_R32G32B32A32_SINT ); + + VD_CASE( UINT32_1, DXGI_FORMAT_R32_UINT ); + VD_CASE( UINT32_2, DXGI_FORMAT_R32G32_UINT ); + VD_CASE( UINT32_3, DXGI_FORMAT_R32G32B32_UINT ); + VD_CASE( UINT32_4, DXGI_FORMAT_R32G32B32A32_UINT ); + + + VD_CASE( FLOAT16_1, DXGI_FORMAT_R16_FLOAT ); + VD_CASE( FLOAT16_2, DXGI_FORMAT_R16G16_FLOAT ); + VD_CASE( FLOAT16_3, DXGI_FORMAT_UNKNOWN ); + VD_CASE( FLOAT16_4, DXGI_FORMAT_R16G16B16A16_FLOAT ); + + VD_CASE( FLOAT32_1, DXGI_FORMAT_R32_FLOAT ); + VD_CASE( FLOAT32_2, DXGI_FORMAT_R32G32_FLOAT ); + VD_CASE( FLOAT32_3, DXGI_FORMAT_R32G32B32_FLOAT ); + VD_CASE( FLOAT32_4, DXGI_FORMAT_R32G32B32A32_FLOAT ); + } - return DXGI_FORMAT_UNKNOWN; - }; + return DXGI_FORMAT_UNKNOWN; +}; } namespace TrinityALImpl { - Tr2VertexLayoutAL::Tr2VertexLayoutAL() : - m_vertexStreamMask( 0 ), - m_owner( nullptr ) - { - } +Tr2VertexLayoutAL::Tr2VertexLayoutAL() : + m_vertexStreamMask( 0 ), + m_owner( nullptr ) +{ +} + +Tr2VertexLayoutAL::~Tr2VertexLayoutAL() +{ + Destroy(); +} - Tr2VertexLayoutAL::~Tr2VertexLayoutAL() +ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDCALL; } - ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ) + for( auto it = begin( definition.m_items ); it != end( definition.m_items ); ++it ) { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - - for( auto it = begin( definition.m_items ); it != end( definition.m_items ); ++it ) - { - D3D12_INPUT_ELEMENT_DESC element; - element.SemanticName = s_usageNames[it->m_usage]; - element.SemanticIndex = it->m_usageIndex; - element.Format = GetDxgiDataType( it->m_dataType ); - element.InputSlot = it->m_stream; - element.AlignedByteOffset = it->m_offset; - element.InputSlotClass = it->m_instanceStepRate ? D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA : D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; - element.InstanceDataStepRate = it->m_instanceStepRate; - m_elements.push_back( element ); - - m_vertexStreamMask |= 1 << it->m_stream; - } + D3D12_INPUT_ELEMENT_DESC element; + element.SemanticName = s_usageNames[it->m_usage]; + element.SemanticIndex = it->m_usageIndex; + element.Format = GetDxgiDataType( it->m_dataType ); + element.InputSlot = it->m_stream; + element.AlignedByteOffset = it->m_offset; + element.InputSlotClass = it->m_instanceStepRate ? D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA : D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; + element.InstanceDataStepRate = it->m_instanceStepRate; + m_elements.push_back( element ); + + m_vertexStreamMask |= 1 << it->m_stream; + } - m_owner = &renderContext; + m_owner = &renderContext; - return S_OK; - } + return S_OK; +} - bool Tr2VertexLayoutAL::IsValid() const - { - return m_owner != nullptr; - } +bool Tr2VertexLayoutAL::IsValid() const +{ + return m_owner != nullptr; +} - void Tr2VertexLayoutAL::Destroy() +void Tr2VertexLayoutAL::Destroy() +{ + if( m_owner ) { - if( m_owner ) - { - m_owner->OnVertexLayoutDestroyedDx12( this ); - } - m_elements.clear(); - m_owner = nullptr; - m_vertexStreamMask = 0; + m_owner->OnVertexLayoutDestroyedDx12( this ); } + m_elements.clear(); + m_owner = nullptr; + m_vertexStreamMask = 0; +} - Tr2ALMemoryType Tr2VertexLayoutAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +Tr2ALMemoryType Tr2VertexLayoutAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2VertexLayoutAL::PopulateInputLayout( std::vector& layout, const std::vector& shaderInputs ) const +void Tr2VertexLayoutAL::PopulateInputLayout( std::vector& layout, const std::vector& shaderInputs ) const +{ + layout.reserve( shaderInputs.size() ); + for( auto it = begin( shaderInputs ); it != end( shaderInputs ); ++it ) { - layout.reserve( shaderInputs.size() ); - for( auto it = begin( shaderInputs ); it != end( shaderInputs ); ++it ) + auto& in = *it; + bool found = false; + for( auto jt = begin( m_elements ); jt != end( m_elements ); ++jt ) { - auto& in = *it; - bool found = false; - for( auto jt = begin( m_elements ); jt != end( m_elements ); ++jt ) + auto out = *jt; + if( in.usageIndex == out.SemanticIndex && s_usageNames[in.usage] == out.SemanticName ) { - auto out = *jt; - if( in.usageIndex == out.SemanticIndex && s_usageNames[in.usage] == out.SemanticName ) - { - layout.push_back( *jt ); - found = true; - break; - } - } - if( !found ) - { - D3D12_INPUT_ELEMENT_DESC desc = { s_usageNames[in.usage], in.usageIndex, it->usage == Tr2VertexDefinition::BLENDINDICES ? DXGI_FORMAT_R8G8B8A8_UINT : DXGI_FORMAT_R32G32B32A32_FLOAT, 4, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }; - layout.push_back( desc ); + layout.push_back( *jt ); + found = true; + break; } } + if( !found ) + { + D3D12_INPUT_ELEMENT_DESC desc = { s_usageNames[in.usage], in.usageIndex, it->usage == Tr2VertexDefinition::BLENDINDICES ? DXGI_FORMAT_R8G8B8A8_UINT : DXGI_FORMAT_R32G32B32A32_FLOAT, 4, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }; + layout.push_back( desc ); + } } +} - void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2VertexLayoutAL"; - description["name"] = m_name; - } +void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2VertexLayoutAL"; + description["name"] = m_name; +} - ALResult Tr2VertexLayoutAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +ALResult Tr2VertexLayoutAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2VertexLayoutALDx12.h b/trinityal/dx12/Tr2VertexLayoutALDx12.h index 3e734be6d..9d735399a 100644 --- a/trinityal/dx12/Tr2VertexLayoutALDx12.h +++ b/trinityal/dx12/Tr2VertexLayoutALDx12.h @@ -10,34 +10,34 @@ struct Tr2ShaderPipelineInputAL; namespace TrinityALImpl { - class Tr2VertexLayoutAL : public Tr2DeviceResourceAL - { - public: - Tr2VertexLayoutAL(); - ~Tr2VertexLayoutAL(); - - ALResult Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - void Destroy(); - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2VertexLayoutAL( const Tr2VertexLayoutAL& )/* = delete */; - Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& )/* = delete */; - - void PopulateInputLayout( std::vector& layout, const std::vector& shaderInputs ) const; - - uint32_t m_vertexStreamMask; - std::vector m_elements; - Tr2PrimaryRenderContextAL* m_owner; - std::string m_name; - - friend class Tr2RenderContextAL; - friend class PSODescription; - }; +class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +{ +public: + Tr2VertexLayoutAL(); + ~Tr2VertexLayoutAL(); + + ALResult Create( const Tr2VertexDefinition& definition, Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + void Destroy(); + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2VertexLayoutAL( const Tr2VertexLayoutAL& ) /* = delete */; + Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& ) /* = delete */; + + void PopulateInputLayout( std::vector& layout, const std::vector& shaderInputs ) const; + + uint32_t m_vertexStreamMask; + std::vector m_elements; + Tr2PrimaryRenderContextAL* m_owner; + std::string m_name; + + friend class Tr2RenderContextAL; + friend class PSODescription; +}; } #endif diff --git a/trinityal/dx12/Tr2VideoAdapterInfoALDx12.cpp b/trinityal/dx12/Tr2VideoAdapterInfoALDx12.cpp index 11a351baa..ec24bed6a 100644 --- a/trinityal/dx12/Tr2VideoAdapterInfoALDx12.cpp +++ b/trinityal/dx12/Tr2VideoAdapterInfoALDx12.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if TRINITY_PLATFORM==TRINITY_DIRECTX12 +#if TRINITY_PLATFORM == TRINITY_DIRECTX12 #include "Tr2VideoAdapterInfoALDx12.h" #include "Tr2AdapterStructures.h" @@ -40,12 +40,12 @@ struct DeviceInfo std::vector s_adapters; std::vector s_deviceInfo; -HRESULT GetFallbackMode( DXGI_MODE_DESC &desc ) +HRESULT GetFallbackMode( DXGI_MODE_DESC& desc ) { DEVMODE devMode; - memset(&devMode, 0, sizeof(devMode)); - devMode.dmSize = sizeof(devMode); - if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &devMode)) + memset( &devMode, 0, sizeof( devMode ) ); + devMode.dmSize = sizeof( devMode ); + if( !EnumDisplaySettings( 0, ENUM_CURRENT_SETTINGS, &devMode ) ) { return E_FAIL; } @@ -70,7 +70,7 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat } uint32_t count = 0; - HRESULT hr = output.m_output->GetDisplayModeList( + HRESULT hr = output.m_output->GetDisplayModeList( backBufferFormat, 0, &count, @@ -81,12 +81,12 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat displayModes.resize( 1 ); return GetFallbackMode( displayModes[0] ); } - if ( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM ) + if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM ) { CCP_LOGWARN( "Tr2VideoAdapterInfo: failed to enumerate display modes (running in remote desktop?)" ); count = 1; } - else if ( FAILED( hr ) || (count == 0) ) + else if( FAILED( hr ) || ( count == 0 ) ) { return hr; } @@ -95,14 +95,14 @@ ALResult PopulateDisplayModes( AdapterInfo& output, DXGI_FORMAT backBufferFormat displayModes.resize( count ); hr = output.m_output->GetDisplayModeList( static_cast( backBufferFormat ), - 0, - &count, - &displayModes[0] ); - if ( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && !displayModes.empty() ) + 0, + &count, + &displayModes[0] ); + if( hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE && backBufferFormat == DXGI_FORMAT_B8G8R8A8_UNORM && !displayModes.empty() ) { return GetFallbackMode( displayModes[0] ); } - else if ( FAILED( hr ) ) + else if( FAILED( hr ) ) { return hr; } @@ -117,10 +117,10 @@ ALResult InitializeDirect3D() s_factory = nullptr; CR_RETURN_HR( CreateDXGIFactory1( - __uuidof( IDXGIFactory1 ), - (void**)( &s_factory ) ) ); + __uuidof( IDXGIFactory1 ), + (void**)( &s_factory ) ) ); - if ( !s_factory ) + if( !s_factory ) { return E_FAIL; } @@ -128,7 +128,7 @@ ALResult InitializeDirect3D() CComPtr adapterPtr; uint32_t adapterIndex = 0; - while ( SUCCEEDED( s_factory->EnumAdapters1( adapterIndex++, &adapterPtr ) ) ) + while( SUCCEEDED( s_factory->EnumAdapters1( adapterIndex++, &adapterPtr ) ) ) { CComPtr device; if( FAILED( D3D12CreateDevice( adapterPtr, D3D_FEATURE_LEVEL_12_0, IID_PPV_ARGS( &device ) ) ) ) @@ -143,7 +143,7 @@ ALResult InitializeDirect3D() DeviceInfo deviceInfo; memset( deviceInfo.m_formatSupport, 0, sizeof( deviceInfo.m_formatSupport ) ); - for ( unsigned i = 0; i < DeviceInfo::FORMAT_COUNT; ++i ) + for( unsigned i = 0; i < DeviceInfo::FORMAT_COUNT; ++i ) { D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupport = { static_cast( i ), D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE }; device->CheckFeatureSupport( D3D12_FEATURE_FORMAT_SUPPORT, &formatSupport, sizeof( formatSupport ) ); @@ -153,7 +153,7 @@ ALResult InitializeDirect3D() CComPtr outputPtr; uint32_t outputIndex = 0; bool hasValidOutputs = false; - while ( SUCCEEDED( adapterPtr->EnumOutputs( outputIndex++, &outputPtr ) ) ) + while( SUCCEEDED( adapterPtr->EnumOutputs( outputIndex++, &outputPtr ) ) ) { AdapterInfo adapter; adapter.m_adapter = adapterPtr; @@ -173,7 +173,7 @@ ALResult InitializeDirect3D() } outputPtr.Release(); } - if ( hasValidOutputs ) + if( hasValidOutputs ) { s_deviceInfo.push_back( deviceInfo ); } @@ -186,28 +186,28 @@ ALResult InitializeDirect3D() } -#define CHECK_INIT \ - if( !s_factory ) \ - { \ - CR_RETURN_HR( InitializeDirect3D() ); \ +#define CHECK_INIT \ + if( !s_factory ) \ + { \ + CR_RETURN_HR( InitializeDirect3D() ); \ } -#define CHECK_VALID_ADAPTER \ - if( adapterIndex >= s_adapters.size() ) \ - { \ - return E_INVALIDARG; \ +#define CHECK_VALID_ADAPTER \ + if( adapterIndex >= s_adapters.size() ) \ + { \ + return E_INVALIDARG; \ } -#define CHECK_INIT_BOOL \ - if( !s_factory && !SUCCEEDED( InitializeDirect3D() ) ) \ - { \ - return false; \ +#define CHECK_INIT_BOOL \ + if( !s_factory && !SUCCEEDED( InitializeDirect3D() ) ) \ + { \ + return false; \ } -#define CHECK_VALID_ADAPTER_BOOL \ - if( adapterIndex >= s_adapters.size() ) \ - { \ - return false; \ +#define CHECK_VALID_ADAPTER_BOOL \ + if( adapterIndex >= s_adapters.size() ) \ + { \ + return false; \ } ALResult Tr2VideoAdapterInfo::GetAdapterCount( uint32_t& count ) @@ -235,7 +235,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterInfo( unsigned adapterIndex, info.deviceID = desc.DeviceId; info.subSystemID = desc.SubSysId; info.revision = desc.Revision; - memcpy( info.luid, &desc.AdapterLuid, sizeof(LUID) ); + memcpy( info.luid, &desc.AdapterLuid, sizeof( LUID ) ); memset( &info.deviceIdentifier, 0, sizeof( info.deviceIdentifier ) ); return S_OK; @@ -264,7 +264,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, return E_FAIL; } - const auto & mm = s_adapters[adapterIndex].m_displayModes[DXGI_FORMAT_B8G8R8A8_UNORM][0]; + const auto& mm = s_adapters[adapterIndex].m_displayModes[DXGI_FORMAT_B8G8R8A8_UNORM][0]; mode.format = static_cast( mm.Format ); mode.refreshRateDenominator = mm.RefreshRate.Denominator; mode.refreshRateNumerator = mm.RefreshRate.Numerator; @@ -274,7 +274,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, DEVMODE devMode; memset( &devMode, 0, sizeof( devMode ) ); devMode.dmSize = sizeof( devMode ); - if ( !EnumDisplaySettings( monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode ) ) + if( !EnumDisplaySettings( monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &devMode ) ) { return E_FAIL; } @@ -293,7 +293,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterModeCount( unsigned adapterIndex, count = 0; - auto & output = s_adapters[adapterIndex]; + auto& output = s_adapters[adapterIndex]; CR_RETURN_HR( PopulateDisplayModes( output, static_cast( backBufferFormat ) ) ); count = unsigned( output.m_displayModes[static_cast( backBufferFormat )].size() ); @@ -308,16 +308,16 @@ ALResult Tr2VideoAdapterInfo::GetAdapterMode( unsigned adapterIndex, CHECK_INIT; CHECK_VALID_ADAPTER; - auto & output = s_adapters[adapterIndex]; + auto& output = s_adapters[adapterIndex]; CR_RETURN_HR( PopulateDisplayModes( output, static_cast( backBufferFormat ) ) ); auto& displayModes = output.m_displayModes[static_cast( backBufferFormat )]; - if ( modeIndex >= displayModes.size() ) + if( modeIndex >= displayModes.size() ) { return E_INVALIDARG; } - auto & mm = displayModes[modeIndex]; + auto& mm = displayModes[modeIndex]; mode.format = static_cast( mm.Format ); mode.height = mm.Height; @@ -329,7 +329,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterMode( unsigned adapterIndex, return S_OK; } -ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned/*adapterIndex*/, +ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned /*adapterIndex*/, unsigned& maxWidth ) { maxWidth = D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION; @@ -342,14 +342,14 @@ bool Tr2VideoAdapterInfo::SupportsBackBufferFormat( unsigned adapterIndex, CHECK_INIT_BOOL; CHECK_VALID_ADAPTER_BOOL; - if ( backBufferFormat >= (unsigned)DeviceInfo::FORMAT_COUNT ) + if( backBufferFormat >= (unsigned)DeviceInfo::FORMAT_COUNT ) { return false; } uint32_t flags = s_deviceInfo[s_adapters[adapterIndex].m_deviceInfoIndex].m_formatSupport[backBufferFormat]; - if ( ( flags & D3D12_FORMAT_SUPPORT1_RENDER_TARGET ) == 0 ) + if( ( flags & D3D12_FORMAT_SUPPORT1_RENDER_TARGET ) == 0 ) { return false; } @@ -362,14 +362,14 @@ bool Tr2VideoAdapterInfo::SupportsRenderTargetFormat( unsigned adapterIndex, Tr2 CHECK_INIT_BOOL; CHECK_VALID_ADAPTER_BOOL; - if ( format >= (unsigned)DeviceInfo::FORMAT_COUNT ) + if( format >= (unsigned)DeviceInfo::FORMAT_COUNT ) { return false; } uint32_t flags = s_deviceInfo[s_adapters[adapterIndex].m_deviceInfoIndex].m_formatSupport[format]; - if ( ( flags & D3D12_FORMAT_SUPPORT1_RENDER_TARGET ) == 0 ) + if( ( flags & D3D12_FORMAT_SUPPORT1_RENDER_TARGET ) == 0 ) { return false; } @@ -380,7 +380,7 @@ bool Tr2VideoAdapterInfo::SupportsRenderTargetFormat( unsigned adapterIndex, Tr2 unsigned log2( unsigned int x ) { unsigned ans = 0; - while ( x >>= 1 ) + while( x >>= 1 ) { ans++; } @@ -396,11 +396,11 @@ ALResult Tr2VideoAdapterInfo::RefreshData() bool Tr2VideoAdapterInfo::AreAdaptersDifferent( unsigned adapter1, unsigned adapter2 ) { - if ( adapter1 == adapter2 ) + if( adapter1 == adapter2 ) { return false; } - if ( adapter1 >= s_adapters.size() || adapter2 >= s_adapters.size() ) + if( adapter1 >= s_adapters.size() || adapter2 >= s_adapters.size() ) { return true; } @@ -410,30 +410,30 @@ bool Tr2VideoAdapterInfo::AreAdaptersDifferent( unsigned adapter1, namespace TrinityALImpl { - ALResult GetVideoAdapter( unsigned adapterIndex, IDXGIAdapter1** adapter, IDXGIOutput** output ) +ALResult GetVideoAdapter( unsigned adapterIndex, IDXGIAdapter1** adapter, IDXGIOutput** output ) +{ + if( !s_factory ) { - if( !s_factory ) - { - CR_RETURN_HR( InitializeDirect3D() ); - } - if( adapterIndex >= s_adapters.size() ) - { - return E_INVALIDARG; - } - *adapter = s_adapters[adapterIndex].m_adapter; - ( *adapter )->AddRef(); - *output = s_adapters[adapterIndex].m_output; - ( *output )->AddRef(); - return S_OK; + CR_RETURN_HR( InitializeDirect3D() ); } - - ALResult Destroy() + if( adapterIndex >= s_adapters.size() ) { - s_adapters.resize( 0 ); - s_deviceInfo.resize( 0 ); - s_factory = nullptr; - return S_OK; + return E_INVALIDARG; } + *adapter = s_adapters[adapterIndex].m_adapter; + ( *adapter )->AddRef(); + *output = s_adapters[adapterIndex].m_output; + ( *output )->AddRef(); + return S_OK; +} + +ALResult Destroy() +{ + s_adapters.resize( 0 ); + s_deviceInfo.resize( 0 ); + s_factory = nullptr; + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/Tr2VideoAdapterInfoALDx12.h b/trinityal/dx12/Tr2VideoAdapterInfoALDx12.h index ef85123dd..ad86afc7e 100644 --- a/trinityal/dx12/Tr2VideoAdapterInfoALDx12.h +++ b/trinityal/dx12/Tr2VideoAdapterInfoALDx12.h @@ -32,8 +32,8 @@ class Tr2VideoAdapterInfo namespace TrinityALImpl { - ALResult GetVideoAdapter( unsigned adapterIndex, IDXGIAdapter1** adapter, IDXGIOutput** output ); - ALResult Destroy(); +ALResult GetVideoAdapter( unsigned adapterIndex, IDXGIAdapter1** adapter, IDXGIOutput** output ); +ALResult Destroy(); } #endif diff --git a/trinityal/dx12/Utilities.cpp b/trinityal/dx12/Utilities.cpp index 5640cf36a..479be6763 100644 --- a/trinityal/dx12/Utilities.cpp +++ b/trinityal/dx12/Utilities.cpp @@ -49,115 +49,640 @@ namespace // Approximately 0 instruction slots used #endif - const BYTE GenerateMipsArray_main[] = - { - 68, 88, 66, 67, 241, 67, - 172, 232, 125, 43, 186, 29, - 188, 227, 51, 90, 246, 4, - 196, 156, 1, 0, 0, 0, - 120, 2, 0, 0, 4, 0, - 0, 0, 48, 0, 0, 0, - 64, 0, 0, 0, 80, 0, - 0, 0, 188, 1, 0, 0, - 73, 83, 71, 78, 8, 0, - 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 79, 83, - 71, 78, 8, 0, 0, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 83, 72, 69, 88, - 100, 1, 0, 0, 81, 0, - 5, 0, 89, 0, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 7, 70, 142, 48, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 90, 0, 0, 6, - 70, 110, 48, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 88, 64, 0, 7, - 70, 126, 48, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 85, 85, - 0, 0, 0, 0, 0, 0, - 156, 64, 0, 7, 70, 238, - 49, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 0, 0, 0, 0, 95, 0, - 0, 2, 114, 0, 2, 0, - 104, 0, 0, 2, 2, 0, - 0, 0, 155, 0, 0, 4, - 8, 0, 0, 0, 8, 0, - 0, 0, 1, 0, 0, 0, - 86, 0, 0, 4, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 2, 0, 0, 0, - 0, 10, 50, 0, 16, 0, - 1, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 9, - 50, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 1, 0, 0, 0, 70, 128, - 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 86, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 42, 128, 48, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 72, 0, 0, 13, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 0, 0, - 0, 0, 70, 126, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 96, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 164, 0, - 0, 7, 242, 224, 33, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 70, 10, 2, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 82, 84, 83, 48, 180, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 24, 0, - 0, 0, 1, 0, 0, 0, - 128, 0, 0, 0, 62, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 60, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 72, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 1, 0, 0, 0, 108, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 20, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 16, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 127, 127, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 - }; +const BYTE GenerateMipsArray_main[] = { + 68, + 88, + 66, + 67, + 241, + 67, + 172, + 232, + 125, + 43, + 186, + 29, + 188, + 227, + 51, + 90, + 246, + 4, + 196, + 156, + 1, + 0, + 0, + 0, + 120, + 2, + 0, + 0, + 4, + 0, + 0, + 0, + 48, + 0, + 0, + 0, + 64, + 0, + 0, + 0, + 80, + 0, + 0, + 0, + 188, + 1, + 0, + 0, + 73, + 83, + 71, + 78, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 79, + 83, + 71, + 78, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 83, + 72, + 69, + 88, + 100, + 1, + 0, + 0, + 81, + 0, + 5, + 0, + 89, + 0, + 0, + 0, + 106, + 8, + 0, + 1, + 89, + 0, + 0, + 7, + 70, + 142, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 90, + 0, + 0, + 6, + 70, + 110, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 88, + 64, + 0, + 7, + 70, + 126, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 85, + 85, + 0, + 0, + 0, + 0, + 0, + 0, + 156, + 64, + 0, + 7, + 70, + 238, + 49, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 85, + 85, + 0, + 0, + 0, + 0, + 0, + 0, + 95, + 0, + 0, + 2, + 114, + 0, + 2, + 0, + 104, + 0, + 0, + 2, + 2, + 0, + 0, + 0, + 155, + 0, + 0, + 4, + 8, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 86, + 0, + 0, + 4, + 114, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 2, + 2, + 0, + 0, + 0, + 0, + 10, + 50, + 0, + 16, + 0, + 1, + 0, + 0, + 0, + 70, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 2, + 64, + 0, + 0, + 0, + 0, + 0, + 63, + 0, + 0, + 0, + 63, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 56, + 0, + 0, + 9, + 50, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 0, + 16, + 0, + 1, + 0, + 0, + 0, + 70, + 128, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 86, + 0, + 0, + 7, + 130, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 42, + 128, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 72, + 0, + 0, + 13, + 242, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 2, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 126, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 96, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 58, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 164, + 0, + 0, + 7, + 242, + 224, + 33, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 70, + 10, + 2, + 0, + 70, + 14, + 16, + 0, + 0, + 0, + 0, + 0, + 62, + 0, + 0, + 1, + 82, + 84, + 83, + 48, + 180, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 24, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 128, + 0, + 0, + 0, + 62, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 60, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 72, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 80, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 255, + 255, + 1, + 0, + 0, + 0, + 108, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 255, + 255, + 20, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 16, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 127, + 127, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +}; #if 0 // // Generated by Microsoft (R) D3D Shader Disassembler @@ -193,401 +718,927 @@ namespace // Approximately 0 instruction slots used #endif - const BYTE GenerateMips_main[] = - { - 68, 88, 66, 67, 189, 63, - 191, 181, 181, 45, 113, 6, - 56, 182, 109, 157, 174, 172, - 122, 11, 1, 0, 0, 0, - 120, 2, 0, 0, 4, 0, - 0, 0, 48, 0, 0, 0, - 64, 0, 0, 0, 80, 0, - 0, 0, 188, 1, 0, 0, - 73, 83, 71, 78, 8, 0, - 0, 0, 0, 0, 0, 0, - 8, 0, 0, 0, 79, 83, - 71, 78, 8, 0, 0, 0, - 0, 0, 0, 0, 8, 0, - 0, 0, 83, 72, 69, 88, - 100, 1, 0, 0, 81, 0, - 5, 0, 89, 0, 0, 0, - 106, 8, 0, 1, 89, 0, - 0, 7, 70, 142, 48, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 90, 0, 0, 6, - 70, 110, 48, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 88, 24, 0, 7, - 70, 126, 48, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 85, 85, - 0, 0, 0, 0, 0, 0, - 156, 24, 0, 7, 70, 238, - 49, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 0, 0, 0, 0, 95, 0, - 0, 2, 50, 0, 2, 0, - 104, 0, 0, 2, 1, 0, - 0, 0, 155, 0, 0, 4, - 8, 0, 0, 0, 8, 0, - 0, 0, 1, 0, 0, 0, - 86, 0, 0, 4, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 2, 0, 0, 0, - 0, 10, 50, 0, 16, 0, - 0, 0, 0, 0, 70, 0, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 63, 0, 0, 0, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 0, 9, - 50, 0, 16, 0, 0, 0, - 0, 0, 70, 0, 16, 0, - 0, 0, 0, 0, 70, 128, - 48, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 86, 0, 0, 7, - 66, 0, 16, 0, 0, 0, - 0, 0, 42, 128, 48, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 72, 0, 0, 13, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 70, 126, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 96, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 42, 0, 16, 0, - 0, 0, 0, 0, 164, 0, - 0, 7, 242, 224, 33, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 70, 5, 2, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 62, 0, 0, 1, - 82, 84, 83, 48, 180, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 24, 0, - 0, 0, 1, 0, 0, 0, - 128, 0, 0, 0, 62, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 60, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 72, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 100, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 80, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 255, 255, 255, 255, - 1, 0, 0, 0, 108, 0, - 0, 0, 1, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 255, 255, 255, 255, 20, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 16, 0, 0, 0, 4, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 255, 255, - 127, 127, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0 - }; +const BYTE GenerateMips_main[] = { + 68, + 88, + 66, + 67, + 189, + 63, + 191, + 181, + 181, + 45, + 113, + 6, + 56, + 182, + 109, + 157, + 174, + 172, + 122, + 11, + 1, + 0, + 0, + 0, + 120, + 2, + 0, + 0, + 4, + 0, + 0, + 0, + 48, + 0, + 0, + 0, + 64, + 0, + 0, + 0, + 80, + 0, + 0, + 0, + 188, + 1, + 0, + 0, + 73, + 83, + 71, + 78, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 79, + 83, + 71, + 78, + 8, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 83, + 72, + 69, + 88, + 100, + 1, + 0, + 0, + 81, + 0, + 5, + 0, + 89, + 0, + 0, + 0, + 106, + 8, + 0, + 1, + 89, + 0, + 0, + 7, + 70, + 142, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 90, + 0, + 0, + 6, + 70, + 110, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 88, + 24, + 0, + 7, + 70, + 126, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 85, + 85, + 0, + 0, + 0, + 0, + 0, + 0, + 156, + 24, + 0, + 7, + 70, + 238, + 49, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 85, + 85, + 0, + 0, + 0, + 0, + 0, + 0, + 95, + 0, + 0, + 2, + 50, + 0, + 2, + 0, + 104, + 0, + 0, + 2, + 1, + 0, + 0, + 0, + 155, + 0, + 0, + 4, + 8, + 0, + 0, + 0, + 8, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 86, + 0, + 0, + 4, + 50, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 0, + 2, + 0, + 0, + 0, + 0, + 10, + 50, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 2, + 64, + 0, + 0, + 0, + 0, + 0, + 63, + 0, + 0, + 0, + 63, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 56, + 0, + 0, + 9, + 50, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 128, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 86, + 0, + 0, + 7, + 66, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 42, + 128, + 48, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 72, + 0, + 0, + 13, + 242, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 70, + 126, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 96, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 42, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 164, + 0, + 0, + 7, + 242, + 224, + 33, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 70, + 5, + 2, + 0, + 70, + 14, + 16, + 0, + 0, + 0, + 0, + 0, + 62, + 0, + 0, + 1, + 82, + 84, + 83, + 48, + 180, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 24, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 128, + 0, + 0, + 0, + 62, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 60, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 72, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 100, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 80, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 255, + 255, + 1, + 0, + 0, + 0, + 108, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 255, + 255, + 20, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 16, + 0, + 0, + 0, + 4, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 255, + 255, + 127, + 127, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +}; } namespace TrinityALImpl { - D3D12_RESOURCE_BARRIER Transition( - ID3D12Resource* pResource, - D3D12_RESOURCE_STATES stateBefore, - D3D12_RESOURCE_STATES stateAfter, - UINT subresource, - D3D12_RESOURCE_BARRIER_FLAGS flags ) - { - D3D12_RESOURCE_BARRIER barrier; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Flags = flags; - barrier.Transition.pResource = pResource; - barrier.Transition.StateBefore = stateBefore; - barrier.Transition.StateAfter = stateAfter; - barrier.Transition.Subresource = subresource; - return barrier; - } +D3D12_RESOURCE_BARRIER Transition( + ID3D12Resource* pResource, + D3D12_RESOURCE_STATES stateBefore, + D3D12_RESOURCE_STATES stateAfter, + UINT subresource, + D3D12_RESOURCE_BARRIER_FLAGS flags ) +{ + D3D12_RESOURCE_BARRIER barrier; + barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; + barrier.Flags = flags; + barrier.Transition.pResource = pResource; + barrier.Transition.StateBefore = stateBefore; + barrier.Transition.StateAfter = stateAfter; + barrier.Transition.Subresource = subresource; + return barrier; +} - D3D12_RESOURCE_BARRIER AliasBarrier( - ID3D12Resource* before, - ID3D12Resource* after ) - { - D3D12_RESOURCE_BARRIER desc = {}; - desc.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; - desc.Aliasing.pResourceBefore = before; - desc.Aliasing.pResourceAfter = after; - return desc; - } +D3D12_RESOURCE_BARRIER AliasBarrier( + ID3D12Resource* before, + ID3D12Resource* after ) +{ + D3D12_RESOURCE_BARRIER desc = {}; + desc.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; + desc.Aliasing.pResourceBefore = before; + desc.Aliasing.pResourceAfter = after; + return desc; +} - D3D12_HEAP_PROPERTIES HeapDesc( D3D12_HEAP_TYPE type ) - { - D3D12_HEAP_PROPERTIES heap = { type, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0, 0 }; - return heap; - } +D3D12_HEAP_PROPERTIES HeapDesc( D3D12_HEAP_TYPE type ) +{ + D3D12_HEAP_PROPERTIES heap = { type, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0, 0 }; + return heap; +} - //------------------------------------------------------------------------------------------------ - // Row-by-row memcpy - void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const D3D12_SUBRESOURCE_DATA* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices ) +//------------------------------------------------------------------------------------------------ +// Row-by-row memcpy +void MemcpySubresource( + _In_ const D3D12_MEMCPY_DEST* pDest, + _In_ const D3D12_SUBRESOURCE_DATA* pSrc, + SIZE_T RowSizeInBytes, + UINT NumRows, + UINT NumSlices ) +{ + for( UINT z = 0; z < NumSlices; ++z ) { - for( UINT z = 0; z < NumSlices; ++z ) + BYTE* pDestSlice = reinterpret_cast( pDest->pData ) + pDest->SlicePitch * z; + const BYTE* pSrcSlice = reinterpret_cast( pSrc->pData ) + pSrc->SlicePitch * z; + for( UINT y = 0; y < NumRows; ++y ) { - BYTE* pDestSlice = reinterpret_cast( pDest->pData ) + pDest->SlicePitch * z; - const BYTE* pSrcSlice = reinterpret_cast( pSrc->pData ) + pSrc->SlicePitch * z; - for( UINT y = 0; y < NumRows; ++y ) - { - memcpy( pDestSlice + pDest->RowPitch * y, + memcpy( pDestSlice + pDest->RowPitch * y, pSrcSlice + pSrc->RowPitch * y, RowSizeInBytes ); - } } } +} - //------------------------------------------------------------------------------------------------ - // All arrays must be populated (e.g. by calling GetCopyableFootprints) - UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_( NumSubresources ) const UINT* pNumRows, - _In_reads_( NumSubresources ) const UINT64* pRowSizesInBytes, - _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) +//------------------------------------------------------------------------------------------------ +// All arrays must be populated (e.g. by calling GetCopyableFootprints) +UINT64 UpdateSubresources( + _In_ ID3D12GraphicsCommandList* pCmdList, + _In_ ID3D12Resource* pDestinationResource, + _In_ ID3D12Resource* pIntermediate, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, + UINT64 RequiredSize, + _In_reads_( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, + _In_reads_( NumSubresources ) const UINT* pNumRows, + _In_reads_( NumSubresources ) const UINT64* pRowSizesInBytes, + _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) +{ + // Minor validation + D3D12_RESOURCE_DESC IntermediateDesc = pIntermediate->GetDesc(); + D3D12_RESOURCE_DESC DestinationDesc = pDestinationResource->GetDesc(); + if( IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || + IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || + RequiredSize > (SIZE_T)-1 || + ( DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && + ( FirstSubresource != 0 || NumSubresources != 1 ) ) ) { - // Minor validation - D3D12_RESOURCE_DESC IntermediateDesc = pIntermediate->GetDesc(); - D3D12_RESOURCE_DESC DestinationDesc = pDestinationResource->GetDesc(); - if( IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize >( SIZE_T ) - 1 || - ( DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - ( FirstSubresource != 0 || NumSubresources != 1 ) ) ) - { - return 0; - } + return 0; + } - BYTE* pData; - HRESULT hr = pIntermediate->Map( 0, NULL, reinterpret_cast( &pData ) ); - if( FAILED( hr ) ) - { + BYTE* pData; + HRESULT hr = pIntermediate->Map( 0, NULL, reinterpret_cast( &pData ) ); + if( FAILED( hr ) ) + { + return 0; + } + + for( UINT i = 0; i < NumSubresources; ++i ) + { + if( pRowSizesInBytes[i] > (SIZE_T)-1 ) return 0; - } + D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, pLayouts[i].Footprint.RowPitch * pNumRows[i] }; + MemcpySubresource( &DestData, &pSrcData[i], (SIZE_T)pRowSizesInBytes[i], pNumRows[i], pLayouts[i].Footprint.Depth ); + } + pIntermediate->Unmap( 0, NULL ); + if( DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER ) + { + pCmdList->CopyBufferRegion( + pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width ); + } + else + { for( UINT i = 0; i < NumSubresources; ++i ) { - if( pRowSizesInBytes[i] > ( SIZE_T )-1 ) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, pLayouts[i].Footprint.RowPitch * pNumRows[i] }; - MemcpySubresource( &DestData, &pSrcData[i], (SIZE_T)pRowSizesInBytes[i], pNumRows[i], pLayouts[i].Footprint.Depth ); + D3D12_TEXTURE_COPY_LOCATION Dst = { pDestinationResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, i + FirstSubresource }; + D3D12_TEXTURE_COPY_LOCATION Src = { pIntermediate, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, pLayouts[i] }; + pCmdList->CopyTextureRegion( &Dst, 0, 0, 0, &Src, nullptr ); } - pIntermediate->Unmap( 0, NULL ); - - if( DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER ) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width ); - } - else - { - for( UINT i = 0; i < NumSubresources; ++i ) - { - D3D12_TEXTURE_COPY_LOCATION Dst = { pDestinationResource, D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, i + FirstSubresource }; - D3D12_TEXTURE_COPY_LOCATION Src = { pIntermediate, D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, pLayouts[i] }; - pCmdList->CopyTextureRegion( &Dst, 0, 0, 0, &Src, nullptr ); - } - } - return RequiredSize; } + return RequiredSize; +} - //------------------------------------------------------------------------------------------------ - // Heap-allocating UpdateSubresources implementation - UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, - _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) +//------------------------------------------------------------------------------------------------ +// Heap-allocating UpdateSubresources implementation +UINT64 UpdateSubresources( + _In_ ID3D12GraphicsCommandList* pCmdList, + _In_ ID3D12Resource* pDestinationResource, + _In_ ID3D12Resource* pIntermediate, + UINT64 IntermediateOffset, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, + _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) +{ + UINT64 RequiredSize = 0; + UINT64 MemToAlloc = static_cast( sizeof( D3D12_PLACED_SUBRESOURCE_FOOTPRINT ) + sizeof( UINT ) + sizeof( UINT64 ) ) * NumSubresources; + if( MemToAlloc > SIZE_MAX ) { - UINT64 RequiredSize = 0; - UINT64 MemToAlloc = static_cast( sizeof( D3D12_PLACED_SUBRESOURCE_FOOTPRINT ) + sizeof( UINT ) + sizeof( UINT64 ) ) * NumSubresources; - if( MemToAlloc > SIZE_MAX ) - { - return 0; - } - void* pMem = HeapAlloc( GetProcessHeap(), 0, static_cast( MemToAlloc ) ); - if( pMem == NULL ) - { - return 0; - } - D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts = reinterpret_cast( pMem ); - UINT64* pRowSizesInBytes = reinterpret_cast( pLayouts + NumSubresources ); - UINT* pNumRows = reinterpret_cast( pRowSizesInBytes + NumSubresources ); - - D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice; - pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); - pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize ); - pDevice->Release(); - - UINT64 Result = UpdateSubresources( pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData ); - HeapFree( GetProcessHeap(), 0, pMem ); - return Result; + return 0; } - - UINT64 GetRequiredIntermediateSize( - _In_ ID3D12Resource* pDestinationResource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ) + void* pMem = HeapAlloc( GetProcessHeap(), 0, static_cast( MemToAlloc ) ); + if( pMem == NULL ) { - auto Desc = pDestinationResource->GetDesc(); - UINT64 RequiredSize = 0; + return 0; + } + D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts = reinterpret_cast( pMem ); + UINT64* pRowSizesInBytes = reinterpret_cast( pLayouts + NumSubresources ); + UINT* pNumRows = reinterpret_cast( pRowSizesInBytes + NumSubresources ); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); - pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize ); - pDevice->Release(); + D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc(); + ID3D12Device* pDevice; + pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); + pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize ); + pDevice->Release(); - return RequiredSize; - } + UINT64 Result = UpdateSubresources( pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData ); + HeapFree( GetProcessHeap(), 0, pMem ); + return Result; +} - D3D12_RESOURCE_DESC BufferDesc( uint64_t size, D3D12_RESOURCE_FLAGS flags ) - { - D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER, 0, size, 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags }; - return resourceDesc; - } +UINT64 GetRequiredIntermediateSize( + _In_ ID3D12Resource* pDestinationResource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ) +{ + auto Desc = pDestinationResource->GetDesc(); + UINT64 RequiredSize = 0; + ID3D12Device* pDevice = nullptr; + pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); + pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize ); + pDevice->Release(); - GenerateMipsResources::GenerateMipsResources( _In_ ID3D12Device* device ) : - rootSignature( CreateGenMipsRootSignature( device ) ) - { - generateMipsPSO = CreateGenMipsPipelineState( device, rootSignature, GenerateMips_main, sizeof( GenerateMips_main ) ); - generateMipsArrayPSO = CreateGenMipsPipelineState( device, rootSignature, GenerateMipsArray_main, sizeof( GenerateMipsArray_main ) ); - } + return RequiredSize; +} - CComPtr GenerateMipsResources::CreateGenMipsRootSignature( _In_ ID3D12Device* device ) - { - D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags = - D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS; - - D3D12_STATIC_SAMPLER_DESC sampler = { - D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, - D3D12_TEXTURE_ADDRESS_MODE_CLAMP, - D3D12_TEXTURE_ADDRESS_MODE_CLAMP, - D3D12_TEXTURE_ADDRESS_MODE_CLAMP, - 0, - 0, - D3D12_COMPARISON_FUNC_ALWAYS, - D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, - 0, - FLT_MAX, - 0, // register - 0, - D3D12_SHADER_VISIBILITY_ALL - }; +D3D12_RESOURCE_DESC BufferDesc( uint64_t size, D3D12_RESOURCE_FLAGS flags ) +{ + D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER, 0, size, 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags }; + return resourceDesc; +} + + +GenerateMipsResources::GenerateMipsResources( _In_ ID3D12Device* device ) : + rootSignature( CreateGenMipsRootSignature( device ) ) +{ + generateMipsPSO = CreateGenMipsPipelineState( device, rootSignature, GenerateMips_main, sizeof( GenerateMips_main ) ); + generateMipsArrayPSO = CreateGenMipsPipelineState( device, rootSignature, GenerateMipsArray_main, sizeof( GenerateMipsArray_main ) ); +} - D3D12_DESCRIPTOR_RANGE sourceDescriptorRange = { D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0, 0 }; - D3D12_DESCRIPTOR_RANGE targetDescriptorRange = { D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0 }; +CComPtr GenerateMipsResources::CreateGenMipsRootSignature( _In_ ID3D12Device* device ) +{ + D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags = + D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS | + D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS | + D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS | + D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS | + D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS; + + D3D12_STATIC_SAMPLER_DESC sampler = { + D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP, + 0, + 0, + D3D12_COMPARISON_FUNC_ALWAYS, + D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK, + 0, + FLT_MAX, + 0, // register + 0, + D3D12_SHADER_VISIBILITY_ALL + }; - D3D12_ROOT_PARAMETER rootParameters[RootParameterCount] = {}; - rootParameters[Constants].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParameters[Constants].Constants.Num32BitValues = Num32BitConstants; + D3D12_DESCRIPTOR_RANGE sourceDescriptorRange = { D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0, 0 }; + D3D12_DESCRIPTOR_RANGE targetDescriptorRange = { D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 1, 0, 0 }; - rootParameters[SourceTexture].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParameters[SourceTexture].DescriptorTable.NumDescriptorRanges = 1; - rootParameters[SourceTexture].DescriptorTable.pDescriptorRanges = &sourceDescriptorRange; + D3D12_ROOT_PARAMETER rootParameters[RootParameterCount] = {}; + rootParameters[Constants].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; + rootParameters[Constants].Constants.Num32BitValues = Num32BitConstants; - rootParameters[TargetTexture].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParameters[TargetTexture].DescriptorTable.NumDescriptorRanges = 1; - rootParameters[TargetTexture].DescriptorTable.pDescriptorRanges = &targetDescriptorRange; + rootParameters[SourceTexture].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + rootParameters[SourceTexture].DescriptorTable.NumDescriptorRanges = 1; + rootParameters[SourceTexture].DescriptorTable.pDescriptorRanges = &sourceDescriptorRange; + rootParameters[TargetTexture].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + rootParameters[TargetTexture].DescriptorTable.NumDescriptorRanges = 1; + rootParameters[TargetTexture].DescriptorTable.pDescriptorRanges = &targetDescriptorRange; - D3D12_ROOT_SIGNATURE_DESC rsigDesc = { _countof( rootParameters ), rootParameters, 1, &sampler, rootSignatureFlags }; - CComPtr rootSignature; + D3D12_ROOT_SIGNATURE_DESC rsigDesc = { _countof( rootParameters ), rootParameters, 1, &sampler, rootSignatureFlags }; + + CComPtr rootSignature; + { + CComPtr rootSignatureBlob; + CComPtr errorBlob; + HRESULT hr; + CR( hr = D3D12SerializeRootSignature( &rsigDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ) ); + if( FAILED( hr ) ) { - CComPtr rootSignatureBlob; - CComPtr errorBlob; - HRESULT hr; - CR( hr = D3D12SerializeRootSignature( &rsigDesc, D3D_ROOT_SIGNATURE_VERSION_1_0, &rootSignatureBlob, &errorBlob ) ); - if( FAILED( hr ) ) + if( errorBlob ) { - if( errorBlob ) - { - CCP_AL_LOGERR( "Failed to serialize a root signature: %s", static_cast( errorBlob->GetBufferPointer() ) ); - } - else - { - CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); - } + CCP_AL_LOGERR( "Failed to serialize a root signature: %s", static_cast( errorBlob->GetBufferPointer() ) ); + } + else + { + CCP_AL_LOGERR( "Failed to serialize a root signature - unknown error" ); } - - CR( device->CreateRootSignature( - 0, - rootSignatureBlob->GetBufferPointer(), - rootSignatureBlob->GetBufferSize(), - IID_PPV_ARGS( &rootSignature ) ) ); } - return rootSignature; + CR( device->CreateRootSignature( + 0, + rootSignatureBlob->GetBufferPointer(), + rootSignatureBlob->GetBufferSize(), + IID_PPV_ARGS( &rootSignature ) ) ); } - CComPtr GenerateMipsResources::CreateGenMipsPipelineState( - _In_ ID3D12Device* device, - _In_ ID3D12RootSignature* rootSignature, - _In_reads_( bytecodeSize ) const uint8_t* bytecode, - _In_ size_t bytecodeSize ) - { - D3D12_COMPUTE_PIPELINE_STATE_DESC desc = {}; - desc.CS.BytecodeLength = bytecodeSize; - desc.CS.pShaderBytecode = bytecode; - desc.pRootSignature = rootSignature; + return rootSignature; +} - CComPtr pso; - CR( device->CreateComputePipelineState( &desc, IID_PPV_ARGS( &pso ) ) ); +CComPtr GenerateMipsResources::CreateGenMipsPipelineState( + _In_ ID3D12Device* device, + _In_ ID3D12RootSignature* rootSignature, + _In_reads_( bytecodeSize ) const uint8_t* bytecode, + _In_ size_t bytecodeSize ) +{ + D3D12_COMPUTE_PIPELINE_STATE_DESC desc = {}; + desc.CS.BytecodeLength = bytecodeSize; + desc.CS.pShaderBytecode = bytecode; + desc.pRootSignature = rootSignature; - return pso; - } + CComPtr pso; + CR( device->CreateComputePipelineState( &desc, IID_PPV_ARGS( &pso ) ) ); - void SetDebugName( ID3D12DeviceChild* resource, const char* name ) - { - if( resource ) - { - resource->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); - } - } + return pso; +} - bool RequiresImmediateBarriers( Tr2GpuUsage::Type gpuUsage ) +void SetDebugName( ID3D12DeviceChild* resource, const char* name ) +{ + if( resource ) { - return ( gpuUsage & ( Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::DEPTH_STENCIL | Tr2GpuUsage::UNORDERED_ACCESS ) ) == 0; + resource->SetPrivateData( WKPDID_D3DDebugObjectName, UINT( strlen( name ) ), name ); } } +bool RequiresImmediateBarriers( Tr2GpuUsage::Type gpuUsage ) +{ + return ( gpuUsage & ( Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::DEPTH_STENCIL | Tr2GpuUsage::UNORDERED_ACCESS ) ) == 0; +} +} + #endif \ No newline at end of file diff --git a/trinityal/dx12/Utilities.h b/trinityal/dx12/Utilities.h index 63d76de04..efa37b3c5 100644 --- a/trinityal/dx12/Utilities.h +++ b/trinityal/dx12/Utilities.h @@ -9,124 +9,124 @@ namespace TrinityALImpl { - D3D12_RESOURCE_BARRIER Transition( - ID3D12Resource* pResource, - D3D12_RESOURCE_STATES stateBefore, - D3D12_RESOURCE_STATES stateAfter, - UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE ); - - D3D12_RESOURCE_BARRIER AliasBarrier( - ID3D12Resource* before, - ID3D12Resource* after ); - - D3D12_HEAP_PROPERTIES HeapDesc( D3D12_HEAP_TYPE type ); - - void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const D3D12_SUBRESOURCE_DATA* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices ); - - UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_( NumSubresources ) const UINT* pNumRows, - _In_reads_( NumSubresources ) const UINT64* pRowSizesInBytes, - _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ); - - UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, - _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ); - - //------------------------------------------------------------------------------------------------ - // Stack-allocating UpdateSubresources implementation - template - inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_( 0, MaxSubresources ) UINT FirstSubresource, - _In_range_( 1, MaxSubresources - FirstSubresource ) UINT NumSubresources, - _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) - { - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; +D3D12_RESOURCE_BARRIER Transition( + ID3D12Resource* pResource, + D3D12_RESOURCE_STATES stateBefore, + D3D12_RESOURCE_STATES stateAfter, + UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE ); + +D3D12_RESOURCE_BARRIER AliasBarrier( + ID3D12Resource* before, + ID3D12Resource* after ); + +D3D12_HEAP_PROPERTIES HeapDesc( D3D12_HEAP_TYPE type ); + +void MemcpySubresource( + _In_ const D3D12_MEMCPY_DEST* pDest, + _In_ const D3D12_SUBRESOURCE_DATA* pSrc, + SIZE_T RowSizeInBytes, + UINT NumRows, + UINT NumSlices ); + +UINT64 UpdateSubresources( + _In_ ID3D12GraphicsCommandList* pCmdList, + _In_ ID3D12Resource* pDestinationResource, + _In_ ID3D12Resource* pIntermediate, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, + UINT64 RequiredSize, + _In_reads_( NumSubresources ) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, + _In_reads_( NumSubresources ) const UINT* pNumRows, + _In_reads_( NumSubresources ) const UINT64* pRowSizesInBytes, + _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ); + +UINT64 UpdateSubresources( + _In_ ID3D12GraphicsCommandList* pCmdList, + _In_ ID3D12Resource* pDestinationResource, + _In_ ID3D12Resource* pIntermediate, + UINT64 IntermediateOffset, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources, + _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ); + +//------------------------------------------------------------------------------------------------ +// Stack-allocating UpdateSubresources implementation +template +inline UINT64 UpdateSubresources( + _In_ ID3D12GraphicsCommandList* pCmdList, + _In_ ID3D12Resource* pDestinationResource, + _In_ ID3D12Resource* pIntermediate, + UINT64 IntermediateOffset, + _In_range_( 0, MaxSubresources ) UINT FirstSubresource, + _In_range_( 1, MaxSubresources - FirstSubresource ) UINT NumSubresources, + _In_reads_( NumSubresources ) const D3D12_SUBRESOURCE_DATA* pSrcData ) +{ + UINT64 RequiredSize = 0; + D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; + UINT NumRows[MaxSubresources]; + UINT64 RowSizesInBytes[MaxSubresources]; + + D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc(); + ID3D12Device* pDevice; + pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); + pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize ); + pDevice->Release(); + + return UpdateSubresources( pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData ); +} - D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice; - pDestinationResource->GetDevice( __uuidof( ID3D12Device ), reinterpret_cast( &pDevice ) ); - pDevice->GetCopyableFootprints( &Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize ); - pDevice->Release(); +UINT64 GetRequiredIntermediateSize( + _In_ ID3D12Resource* pDestinationResource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, + _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ); - return UpdateSubresources( pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData ); - } +D3D12_RESOURCE_DESC BufferDesc( uint64_t size, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ); - UINT64 GetRequiredIntermediateSize( - _In_ ID3D12Resource* pDestinationResource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES ) UINT FirstSubresource, - _In_range_( 0, D3D12_REQ_SUBRESOURCES - FirstSubresource ) UINT NumSubresources ); - D3D12_RESOURCE_DESC BufferDesc( uint64_t size, D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ); +class GenerateMipsResources +{ +public: + GenerateMipsResources( _In_ ID3D12Device* device ); + + CComPtr rootSignature; + CComPtr generateMipsPSO; + CComPtr generateMipsArrayPSO; + enum RootParameterIndex + { + Constants, + SourceTexture, + TargetTexture, + RootParameterCount + }; - class GenerateMipsResources +#pragma pack( push, 4 ) + struct ConstantData { - public: - GenerateMipsResources( _In_ ID3D12Device* device ); - - CComPtr rootSignature; - CComPtr generateMipsPSO; - CComPtr generateMipsArrayPSO; - - enum RootParameterIndex - { - Constants, - SourceTexture, - TargetTexture, - RootParameterCount - }; - -#pragma pack(push, 4) - struct ConstantData - { - float InvOutTexelSizeX; - float InvOutTexelSizeY; - uint32_t SrcMipIndex; - }; -#pragma pack(pop) - - static const uint32_t Num32BitConstants = static_cast( sizeof( ConstantData ) / sizeof( uint32_t ) ); - static const uint32_t ThreadGroupSize = 8; - - private: - static CComPtr CreateGenMipsRootSignature( - _In_ ID3D12Device* device ); - - static CComPtr CreateGenMipsPipelineState( - _In_ ID3D12Device* device, - _In_ ID3D12RootSignature* rootSignature, - _In_reads_( bytecodeSize ) const uint8_t* bytecode, - _In_ size_t bytecodeSize ); + float InvOutTexelSizeX; + float InvOutTexelSizeY; + uint32_t SrcMipIndex; }; +#pragma pack( pop ) + + static const uint32_t Num32BitConstants = static_cast( sizeof( ConstantData ) / sizeof( uint32_t ) ); + static const uint32_t ThreadGroupSize = 8; + +private: + static CComPtr CreateGenMipsRootSignature( + _In_ ID3D12Device* device ); + + static CComPtr CreateGenMipsPipelineState( + _In_ ID3D12Device* device, + _In_ ID3D12RootSignature* rootSignature, + _In_reads_( bytecodeSize ) const uint8_t* bytecode, + _In_ size_t bytecodeSize ); +}; - void SetDebugName( ID3D12DeviceChild* resource, const char* name ); +void SetDebugName( ID3D12DeviceChild* resource, const char* name ); - bool RequiresImmediateBarriers( Tr2GpuUsage::Type gpuUsage ); +bool RequiresImmediateBarriers( Tr2GpuUsage::Type gpuUsage ); } #endif \ No newline at end of file diff --git a/trinityal/dx12/upscaling/Tr2DlssUpscaling.cpp b/trinityal/dx12/upscaling/Tr2DlssUpscaling.cpp index ff4ffd14c..f5fdee8b0 100644 --- a/trinityal/dx12/upscaling/Tr2DlssUpscaling.cpp +++ b/trinityal/dx12/upscaling/Tr2DlssUpscaling.cpp @@ -36,14 +36,14 @@ sl::Resource GenerateTextureResource( const Tr2TextureAL* texture ) Tr2DlssUpscalingTechnique::Tr2DlssUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : TrinityALImpl::Tr2UpscalingTechniqueDx12( renderContext, technique, setting, frameGeneration, adapter ), m_adapter( adapter ), - m_frameToken( 0 ), + m_frameToken( 0 ), m_supportsFrameGeneration( false ), m_contextIndex( 0 ) { m_isAvailable = false; m_streamlineSetup = false; - + //We need to create a dummy device to figure out if DLSS and frame generation actually is supported. { if( SL_FAILED( res, Tr2StreamlineAL::InitializeStreamline( g_streamlineAppID ) ) ) @@ -90,7 +90,7 @@ Tr2DlssUpscalingTechnique::~Tr2DlssUpscalingTechnique() Tr2StreamlineAL::ReleaseStreamline(); //this should be enough, no need to shut down plugins manually. } -bool Tr2DlssUpscalingTechnique::IsAvailable( ) const +bool Tr2DlssUpscalingTechnique::IsAvailable() const { return m_streamlineSetup && m_isAvailable; } @@ -110,7 +110,7 @@ bool Tr2DlssUpscalingTechnique::IsTemporal() const return true; } -bool Tr2DlssUpscalingTechnique::SupportsFrameGeneration( ) const +bool Tr2DlssUpscalingTechnique::SupportsFrameGeneration() const { return m_supportsFrameGeneration; } @@ -157,7 +157,7 @@ CComPtr Tr2DlssUpscalingTechnique::ReplaceDevice( CComPtr GetAvailableSettings() const override; - virtual bool SupportsFrameGeneration( ) const override; + virtual bool SupportsFrameGeneration() const override; virtual bool IsTemporal() const override; virtual void MarkFrameEvent( Tr2RenderContextEnum::FrameEvent& frameEvent ) override; @@ -46,7 +46,7 @@ class Tr2DlssUpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx1 virtual Tr2UpscalingContextAL* CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) override; uint32_t m_adapter; - + bool m_isAvailable; bool m_supportsFrameGeneration; @@ -54,17 +54,16 @@ class Tr2DlssUpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx1 uint32_t m_contextIndex; sl::FrameToken* m_frameToken; - }; class Tr2DlssUpscalingContext : public Tr2UpscalingContextAL { public: - Tr2DlssUpscalingContext( - Tr2UpscalingAL::Setting setting, - bool frameGeneration, + Tr2DlssUpscalingContext( + Tr2UpscalingAL::Setting setting, + bool frameGeneration, Tr2UpscalingAL::UpscalingContextParams params, - uint32_t contextNumber, + uint32_t contextNumber, sl::FrameToken* frameToken ); ~Tr2DlssUpscalingContext(); diff --git a/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.cpp b/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.cpp index 5855bf664..aa6f2b7bd 100644 --- a/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.cpp +++ b/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.cpp @@ -12,100 +12,100 @@ CCP_STATS_DECLARED_ELSEWHERE( generatedFrames ); namespace Fsr3Utils { - void LogFsr3Message( uint32_t type, const wchar_t* message ) - { - std::string m = std::string( "FSR3 Upscaling: " + std::string( CW2A( message ) ) ); - - switch( type ) - { - case FFX_API_MESSAGE_TYPE_ERROR: - CCP_LOGERR( m.c_str() ); - break; - case FFX_API_MESSAGE_TYPE_WARNING: - CCP_LOGWARN( m.c_str() ); - break; - default: - CCP_LOG( m.c_str() ); - } - } +void LogFsr3Message( uint32_t type, const wchar_t* message ) +{ + std::string m = std::string( "FSR3 Upscaling: " + std::string( CW2A( message ) ) ); - FfxApiResource ConvertTextureToFfxResource( const Tr2TextureAL* texture, const wchar_t* textureName ) + switch( type ) { - ID3D12Resource* res = nullptr; - FfxApiResource ffxRes; + case FFX_API_MESSAGE_TYPE_ERROR: + CCP_LOGERR( m.c_str() ); + break; + case FFX_API_MESSAGE_TYPE_WARNING: + CCP_LOGWARN( m.c_str() ); + break; + default: + CCP_LOG( m.c_str() ); + } +} - if( texture && texture->IsValid() ) - { - auto texObj = texture->TrinityALImpl_GetObject(); - res = texObj->GetResourceDx12(); - res->SetName( textureName ); - ffxRes = ffxApiGetResourceDX12( res ); - // Since we set the dx12 resource format as typeless and then we create views into that resource - // so we need to get the actual format here... - ffxRes.description.format = GetFfxSurfaceFormat( texture->GetFormat() ); - } - else - { - ffxRes = ffxApiGetResourceDX12(nullptr); - } +FfxApiResource ConvertTextureToFfxResource( const Tr2TextureAL* texture, const wchar_t* textureName ) +{ + ID3D12Resource* res = nullptr; + FfxApiResource ffxRes; - return ffxRes; + if( texture && texture->IsValid() ) + { + auto texObj = texture->TrinityALImpl_GetObject(); + res = texObj->GetResourceDx12(); + res->SetName( textureName ); + ffxRes = ffxApiGetResourceDX12( res ); + // Since we set the dx12 resource format as typeless and then we create views into that resource + // so we need to get the actual format here... + ffxRes.description.format = GetFfxSurfaceFormat( texture->GetFormat() ); } + else + { + ffxRes = ffxApiGetResourceDX12( nullptr ); + } + + return ffxRes; +} - FfxApiSurfaceFormat GetFfxSurfaceFormat( Tr2RenderContextEnum::PixelFormat format ) +FfxApiSurfaceFormat GetFfxSurfaceFormat( Tr2RenderContextEnum::PixelFormat format ) +{ + switch( format ) { - switch( format ) - { - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_TYPELESS ): - return FFX_API_SURFACE_FORMAT_R32G32B32A32_TYPELESS; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_FLOAT ): - return FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16B16A16_FLOAT ): - return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32_FLOAT ): - return FFX_API_SURFACE_FORMAT_R32G32_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8_UINT ): - return FFX_API_SURFACE_FORMAT_R8_UINT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32_UINT ): - return FFX_API_SURFACE_FORMAT_R32_UINT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_TYPELESS ): - return FFX_API_SURFACE_FORMAT_R8G8B8A8_TYPELESS; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_UNORM ): - return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB ): - return FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R11G11B10_FLOAT ): - return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16_FLOAT ): - return FFX_API_SURFACE_FORMAT_R16G16_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16_UINT ): - return FFX_API_SURFACE_FORMAT_R16G16_UINT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_FLOAT ): - return FFX_API_SURFACE_FORMAT_R16_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_UINT ): - return FFX_API_SURFACE_FORMAT_R16_UINT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_UNORM ): - return FFX_API_SURFACE_FORMAT_R16_UNORM; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_SNORM ): - return FFX_API_SURFACE_FORMAT_R16_SNORM; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8_UNORM ): - return FFX_API_SURFACE_FORMAT_R8_UNORM; - case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8_UNORM: - return FFX_API_SURFACE_FORMAT_R8G8_UNORM; - case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32_FLOAT: - case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_D32_FLOAT: - return FFX_API_SURFACE_FORMAT_R32_FLOAT; - case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_UNKNOWN ): - return FFX_API_SURFACE_FORMAT_UNKNOWN; - case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_UINT: - return FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT; - case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_B8G8R8A8_UNORM: - return FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM; - default: - CCP_LOGERR( "FSR3: GetFfxSurfaceFormat: Unsupported format requested. Please implement." ); - return FFX_API_SURFACE_FORMAT_UNKNOWN; - } + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_TYPELESS ): + return FFX_API_SURFACE_FORMAT_R32G32B32A32_TYPELESS; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_FLOAT ): + return FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16B16A16_FLOAT ): + return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32_FLOAT ): + return FFX_API_SURFACE_FORMAT_R32G32_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8_UINT ): + return FFX_API_SURFACE_FORMAT_R8_UINT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32_UINT ): + return FFX_API_SURFACE_FORMAT_R32_UINT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_TYPELESS ): + return FFX_API_SURFACE_FORMAT_R8G8B8A8_TYPELESS; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_UNORM ): + return FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB ): + return FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R11G11B10_FLOAT ): + return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16_FLOAT ): + return FFX_API_SURFACE_FORMAT_R16G16_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16G16_UINT ): + return FFX_API_SURFACE_FORMAT_R16G16_UINT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_FLOAT ): + return FFX_API_SURFACE_FORMAT_R16_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_UINT ): + return FFX_API_SURFACE_FORMAT_R16_UINT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_UNORM ): + return FFX_API_SURFACE_FORMAT_R16_UNORM; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R16_SNORM ): + return FFX_API_SURFACE_FORMAT_R16_SNORM; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8_UNORM ): + return FFX_API_SURFACE_FORMAT_R8_UNORM; + case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R8G8_UNORM: + return FFX_API_SURFACE_FORMAT_R8G8_UNORM; + case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32_FLOAT: + case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_D32_FLOAT: + return FFX_API_SURFACE_FORMAT_R32_FLOAT; + case( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_UNKNOWN ): + return FFX_API_SURFACE_FORMAT_UNKNOWN; + case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_R32G32B32A32_UINT: + return FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT; + case Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_B8G8R8A8_UNORM: + return FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM; + default: + CCP_LOGERR( "FSR3: GetFfxSurfaceFormat: Unsupported format requested. Please implement." ); + return FFX_API_SURFACE_FORMAT_UNKNOWN; } +} } @@ -205,7 +205,7 @@ void Tr2Fsr3UpscalingTechnique::MarkFrameEvent( Tr2RenderContextEnum::FrameEvent Tr2UpscalingContextAL* Tr2Fsr3UpscalingTechnique::CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) { return new Tr2Fsr3UpscalingContext( m_setting, m_frameGeneration, m_swapChainContext, params ); -} +} Tr2Fsr3UpscalingContext::Tr2Fsr3UpscalingContext( Tr2UpscalingAL::Setting setting, bool frameGeneration, ffx::Context swapchainContext, Tr2UpscalingAL::UpscalingContextParams params ) : Tr2UpscalingContextAL( setting, frameGeneration, params ), @@ -294,7 +294,7 @@ void Tr2Fsr3UpscalingContext::SetupForReuse() { if( m_frameGeneration ) { - // disable frame generation just for a moment (reenabled in dispatch) + // disable frame generation just for a moment (reenabled in dispatch) m_frameGenerationConfig.frameGenerationEnabled = false; m_frameGenerationConfig.swapChain = m_params.renderContext.GetPrimaryRenderContext().m_swapchain; m_frameGenerationConfig.frameGenerationCallback = nullptr; @@ -368,16 +368,16 @@ Tr2UpscalingAL::Result Tr2Fsr3UpscalingContext::SetupFrameGen() m_frameGenerationConfig.frameGenerationEnabled = true; m_frameGenerationConfig.frameGenerationCallback = m_frameGenerationCallback; m_frameGenerationConfig.frameGenerationCallbackUserContext = &m_framegenerationFfxContext; - + m_frameGenerationConfig.presentCallback = nullptr; m_frameGenerationConfig.presentCallbackUserContext = nullptr; - + m_frameGenerationConfig.swapChain = m_params.renderContext.GetPrimaryRenderContext().m_swapchain; m_frameGenerationConfig.HUDLessColor = FfxApiResource( {} ); // we don't have a HUDless texture yet m_frameGenerationConfig.frameID = 0; m_frameGenerationConfig.allowAsyncWorkloads = false; - + retCode = ffx::Configure( m_framegenerationFfxContext, m_frameGenerationConfig ); if( retCode != ffx::ReturnCode::Ok ) { @@ -421,7 +421,7 @@ void Tr2Fsr3UpscalingContext::Tr2Fsr3UpscalingContext::UpdateJitter() m_jitterX = 0.0f; m_jitterY = 0.0f; - // Increment jitter index for frame + // Increment jitter index for frame ++m_jitterIndex; ffx::ReturnCode retCode; @@ -456,8 +456,8 @@ void Tr2Fsr3UpscalingContext::Tr2Fsr3UpscalingContext::UpdateJitter() uint32_t Tr2Fsr3UpscalingContext::GetDispatchRequirements() const { - return Tr2UpscalingAL::DispatchRequirements::DEPTH | Tr2UpscalingAL::DispatchRequirements::OPAQUE_ONLY | Tr2UpscalingAL::DispatchRequirements::OPTIONAL_EXPOSURE | - Tr2UpscalingAL::DispatchRequirements::VELOCITY | Tr2UpscalingAL::DispatchRequirements::TRANSPARENCY | Tr2UpscalingAL::DispatchRequirements::REACTIVE; + return Tr2UpscalingAL::DispatchRequirements::DEPTH | Tr2UpscalingAL::DispatchRequirements::OPAQUE_ONLY | Tr2UpscalingAL::DispatchRequirements::OPTIONAL_EXPOSURE | + Tr2UpscalingAL::DispatchRequirements::VELOCITY | Tr2UpscalingAL::DispatchRequirements::TRANSPARENCY | Tr2UpscalingAL::DispatchRequirements::REACTIVE; } @@ -546,7 +546,7 @@ Tr2UpscalingAL::Result Tr2Fsr3UpscalingContext::DispatchFrameGen( Tr2UpscalingAL dispatchFgPrep.depth = Fsr3Utils::ConvertTextureToFfxResource( dispatchParameters.depth, L"FSR3_InputDepth" ); dispatchFgPrep.motionVectors = Fsr3Utils::ConvertTextureToFfxResource( dispatchParameters.velocity, L"FSR3_InputMotionVectors" ); dispatchFgPrep.flags = dispatchParameters.frameGenDebugView ? FFX_FRAMEGENERATION_FLAG_DRAW_DEBUG_VIEW : 0; - + dispatchFgPrep.jitterOffset.x = m_jitterX; dispatchFgPrep.jitterOffset.y = m_jitterY; dispatchFgPrep.motionVectorScale.x = (float)m_renderWidth; @@ -562,14 +562,14 @@ Tr2UpscalingAL::Result Tr2Fsr3UpscalingContext::DispatchFrameGen( Tr2UpscalingAL dispatchFgPrep.viewSpaceToMetersFactor = 1.f; dispatchFgPrep.frameID = dispatchParameters.currentFrameIndex; - ffxDispatchDescFrameGenerationPrepareCameraInfo cameraInfo {}; + ffxDispatchDescFrameGenerationPrepareCameraInfo cameraInfo{}; std::copy( std::begin( dispatchParameters.cameraForward ), std::end( dispatchParameters.cameraForward ), cameraInfo.cameraForward ); std::copy( std::begin( dispatchParameters.cameraRight ), std::end( dispatchParameters.cameraRight ), cameraInfo.cameraRight ); std::copy( std::begin( dispatchParameters.cameraUp ), std::end( dispatchParameters.cameraUp ), cameraInfo.cameraUp ); std::copy( std::begin( dispatchParameters.cameraPos ), std::end( dispatchParameters.cameraPos ), cameraInfo.cameraPosition ); dispatchFgPrep.header.pNext = &cameraInfo.header; - + m_frameGenerationConfig.frameID = dispatchParameters.currentFrameIndex; m_frameGenerationConfig.frameGenerationEnabled = true; m_frameGenerationConfig.frameGenerationCallback = m_frameGenerationCallback; @@ -589,7 +589,7 @@ Tr2UpscalingAL::Result Tr2Fsr3UpscalingContext::DispatchFrameGen( Tr2UpscalingAL CCP_LOGERR( "FSR3 error while dispatching frame generation preparation during dispatch %d", retCode ); } } - + return Tr2UpscalingAL::Result::OK; } #endif \ No newline at end of file diff --git a/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.h b/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.h index a16ab215f..12c3f00ec 100644 --- a/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.h +++ b/trinityal/dx12/upscaling/Tr2Fsr3Upscaling.h @@ -13,9 +13,9 @@ namespace Fsr3Utils { - void LogFsr3Message( uint32_t type, const wchar_t* message ); - FfxApiResource ConvertTextureToFfxResource( const Tr2TextureAL* texture, const wchar_t* textureName ); - FfxApiSurfaceFormat GetFfxSurfaceFormat( Tr2RenderContextEnum::PixelFormat format ); +void LogFsr3Message( uint32_t type, const wchar_t* message ); +FfxApiResource ConvertTextureToFfxResource( const Tr2TextureAL* texture, const wchar_t* textureName ); +FfxApiSurfaceFormat GetFfxSurfaceFormat( Tr2RenderContextEnum::PixelFormat format ); } class Tr2Fsr3UpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx12 @@ -36,7 +36,6 @@ class Tr2Fsr3UpscalingTechnique : public TrinityALImpl::Tr2UpscalingTechniqueDx1 virtual void ReplaceSwapchain( CComPtr& swapchain, Tr2WindowHandle hwnd, ID3D12CommandQueue* commandQueue ) override; private: - virtual Tr2UpscalingContextAL* CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) override; bool m_supportsFrameGeneration; @@ -59,7 +58,6 @@ class Tr2Fsr3UpscalingContext : public Tr2UpscalingContextAL virtual Tr2UpscalingAL::Result Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) override; private: - Tr2UpscalingAL::Result SetupFrameGen(); void TearDownFrameGen(); Tr2UpscalingAL::Result SetupUpscaling(); diff --git a/trinityal/dx12/upscaling/Tr2UpscalingALDx12.cpp b/trinityal/dx12/upscaling/Tr2UpscalingALDx12.cpp index 8a64246da..ee0896fa9 100644 --- a/trinityal/dx12/upscaling/Tr2UpscalingALDx12.cpp +++ b/trinityal/dx12/upscaling/Tr2UpscalingALDx12.cpp @@ -12,83 +12,83 @@ namespace TrinityALImpl { - TrinityALImpl::Tr2UpscalingTechniqueDx12* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) +TrinityALImpl::Tr2UpscalingTechniqueDx12* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) +{ + TrinityALImpl::Tr2UpscalingTechniqueDx12* techniqueImpl = nullptr; + switch( technique ) { - TrinityALImpl::Tr2UpscalingTechniqueDx12* techniqueImpl = nullptr; - switch( technique ) - { - case Tr2UpscalingAL::Technique::FSR1: - techniqueImpl = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - case Tr2UpscalingAL::Technique::FSR3: - techniqueImpl = new Tr2Fsr3UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - case Tr2UpscalingAL::Technique::DLSS: - techniqueImpl = new Tr2DlssUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - case Tr2UpscalingAL::Technique::XESS: - techniqueImpl = new Tr2XessUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - default: - break; - } - - if( techniqueImpl && techniqueImpl->IsAvailable( ) ) - { - return techniqueImpl; - } - delete techniqueImpl; - techniqueImpl = nullptr; - return nullptr; + case Tr2UpscalingAL::Technique::FSR1: + techniqueImpl = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + case Tr2UpscalingAL::Technique::FSR3: + techniqueImpl = new Tr2Fsr3UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + case Tr2UpscalingAL::Technique::DLSS: + techniqueImpl = new Tr2DlssUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + case Tr2UpscalingAL::Technique::XESS: + techniqueImpl = new Tr2XessUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + default: + break; } - Tr2UpscalingTechniqueDx12::Tr2UpscalingTechniqueDx12( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : - Tr2UpscalingTechniqueAL( renderContext, technique, setting, frameGeneration, adapter ) + if( techniqueImpl && techniqueImpl->IsAvailable() ) { + return techniqueImpl; } + delete techniqueImpl; + techniqueImpl = nullptr; + return nullptr; +} - Tr2UpscalingTechniqueDx12::~Tr2UpscalingTechniqueDx12() - { - } +Tr2UpscalingTechniqueDx12::Tr2UpscalingTechniqueDx12( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : + Tr2UpscalingTechniqueAL( renderContext, technique, setting, frameGeneration, adapter ) +{ +} - bool Tr2UpscalingTechniqueDx12::ReplacesSwapchain() const - { - return false; - } +Tr2UpscalingTechniqueDx12::~Tr2UpscalingTechniqueDx12() +{ +} - bool Tr2UpscalingTechniqueDx12::ReplacesDevice() const - { - return false; - } - - bool Tr2UpscalingTechniqueDx12::ReplacesCommandQueue() const - { - return false; - } - - bool Tr2UpscalingTechniqueDx12::ReplacesFactory() const - { - return false; - } +bool Tr2UpscalingTechniqueDx12::ReplacesSwapchain() const +{ + return false; +} - void Tr2UpscalingTechniqueDx12::ReplaceSwapchain( CComPtr& swapchain, Tr2WindowHandle hwnd, ID3D12CommandQueue* commandQueue ) - { - } +bool Tr2UpscalingTechniqueDx12::ReplacesDevice() const +{ + return false; +} - CComPtr Tr2UpscalingTechniqueDx12::ReplaceDevice( CComPtr& device ) - { - return device; - } +bool Tr2UpscalingTechniqueDx12::ReplacesCommandQueue() const +{ + return false; +} - CComPtr Tr2UpscalingTechniqueDx12::ReplaceCommandQueue( CComPtr& commandQueue ) - { - return commandQueue; - } - - CComPtr Tr2UpscalingTechniqueDx12::ReplaceFactory( CComPtr& factory ) - { - return factory; - } +bool Tr2UpscalingTechniqueDx12::ReplacesFactory() const +{ + return false; +} + +void Tr2UpscalingTechniqueDx12::ReplaceSwapchain( CComPtr& swapchain, Tr2WindowHandle hwnd, ID3D12CommandQueue* commandQueue ) +{ +} + +CComPtr Tr2UpscalingTechniqueDx12::ReplaceDevice( CComPtr& device ) +{ + return device; +} + +CComPtr Tr2UpscalingTechniqueDx12::ReplaceCommandQueue( CComPtr& commandQueue ) +{ + return commandQueue; +} + +CComPtr Tr2UpscalingTechniqueDx12::ReplaceFactory( CComPtr& factory ) +{ + return factory; +} } #endif diff --git a/trinityal/dx12/upscaling/Tr2UpscalingALDx12.h b/trinityal/dx12/upscaling/Tr2UpscalingALDx12.h index 41553578e..608bf0406 100644 --- a/trinityal/dx12/upscaling/Tr2UpscalingALDx12.h +++ b/trinityal/dx12/upscaling/Tr2UpscalingALDx12.h @@ -7,30 +7,30 @@ namespace TrinityALImpl { - constexpr Tr2UpscalingAL::Technique AVAILABLE_UPSCALING_TECHNIQUES[] = { - Tr2UpscalingAL::Technique::FSR1, - Tr2UpscalingAL::Technique::FSR3, - Tr2UpscalingAL::Technique::XESS, - Tr2UpscalingAL::Technique::DLSS, - }; - - class Tr2UpscalingTechniqueDx12 : public Tr2UpscalingTechniqueAL - { - public: - Tr2UpscalingTechniqueDx12( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); - virtual ~Tr2UpscalingTechniqueDx12(); - virtual bool ReplacesSwapchain() const; - virtual bool ReplacesDevice() const; - virtual bool ReplacesCommandQueue() const; - virtual bool ReplacesFactory() const; - - virtual void ReplaceSwapchain( CComPtr& swapchain, Tr2WindowHandle hwnd, ID3D12CommandQueue* commandQueue ); - virtual CComPtr ReplaceDevice( CComPtr& device ); - virtual CComPtr ReplaceCommandQueue( CComPtr& commandQueue ); - virtual CComPtr ReplaceFactory( CComPtr& factory ); - }; - - TrinityALImpl::Tr2UpscalingTechniqueDx12* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); +constexpr Tr2UpscalingAL::Technique AVAILABLE_UPSCALING_TECHNIQUES[] = { + Tr2UpscalingAL::Technique::FSR1, + Tr2UpscalingAL::Technique::FSR3, + Tr2UpscalingAL::Technique::XESS, + Tr2UpscalingAL::Technique::DLSS, +}; + +class Tr2UpscalingTechniqueDx12 : public Tr2UpscalingTechniqueAL +{ +public: + Tr2UpscalingTechniqueDx12( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); + virtual ~Tr2UpscalingTechniqueDx12(); + virtual bool ReplacesSwapchain() const; + virtual bool ReplacesDevice() const; + virtual bool ReplacesCommandQueue() const; + virtual bool ReplacesFactory() const; + + virtual void ReplaceSwapchain( CComPtr& swapchain, Tr2WindowHandle hwnd, ID3D12CommandQueue* commandQueue ); + virtual CComPtr ReplaceDevice( CComPtr& device ); + virtual CComPtr ReplaceCommandQueue( CComPtr& commandQueue ); + virtual CComPtr ReplaceFactory( CComPtr& factory ); +}; + +TrinityALImpl::Tr2UpscalingTechniqueDx12* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); } diff --git a/trinityal/dx12/upscaling/Tr2XessUpscaling.cpp b/trinityal/dx12/upscaling/Tr2XessUpscaling.cpp index 5cb048bd6..2a00d6428 100644 --- a/trinityal/dx12/upscaling/Tr2XessUpscaling.cpp +++ b/trinityal/dx12/upscaling/Tr2XessUpscaling.cpp @@ -102,7 +102,7 @@ bool Tr2XessUpscalingTechnique::IsTemporal() const return true; } -bool Tr2XessUpscalingTechnique::IsAvailable( ) const +bool Tr2XessUpscalingTechnique::IsAvailable() const { return true; } @@ -170,17 +170,17 @@ void Tr2XessUpscalingContext::UpdateJitter() } } -void Tr2XessUpscalingContext::Destroy( ) +void Tr2XessUpscalingContext::Destroy() { if( m_context ) { - m_params.renderContext.FlushAndSyncDx12( ); + m_params.renderContext.FlushAndSyncDx12(); xessDestroyContext( m_context ); m_context = nullptr; } } -void Tr2XessUpscalingContext::Setup( ) +void Tr2XessUpscalingContext::Setup() { m_setup = false; @@ -194,7 +194,7 @@ void Tr2XessUpscalingContext::Setup( ) params.initFlags |= XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE; } - auto& renderContext = m_params.renderContext; + auto& renderContext = m_params.renderContext; renderContext.FlushAndSyncDx12(); renderContext.DirtyDescriptorCache(); @@ -205,7 +205,7 @@ void Tr2XessUpscalingContext::Setup( ) CCP_LOGNOTICE( "XeSS: XeSS is not supported on this device. Result - %s.", Tr2XessUpscalingUtils::ResultToString( status ) ); return; } - + if( XESS_RESULT_WARNING_OLD_DRIVER == xessIsOptimalDriver( m_context ) ) { CCP_LOGNOTICE( "XeSS: Please install the latest graphics driver from your vendor for optimal Intel(R) XeSS performance and visual quality" ); diff --git a/trinityal/dx12/upscaling/Tr2XessUpscaling.h b/trinityal/dx12/upscaling/Tr2XessUpscaling.h index c72a00351..1096d3344 100644 --- a/trinityal/dx12/upscaling/Tr2XessUpscaling.h +++ b/trinityal/dx12/upscaling/Tr2XessUpscaling.h @@ -38,7 +38,6 @@ class Tr2XessUpscalingContext : public Tr2UpscalingContextAL virtual Tr2UpscalingAL::Result Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) override; private: - xess_context_handle_t m_context; _xess_quality_settings_t m_xessSetting; Tr2UpscalingAL::JitterSequence m_jitterSequence; diff --git a/trinityal/dx12/util/AmdExtDevice.h b/trinityal/dx12/util/AmdExtDevice.h index d95b6c645..b0683975c 100644 --- a/trinityal/dx12/util/AmdExtDevice.h +++ b/trinityal/dx12/util/AmdExtDevice.h @@ -8,10 +8,10 @@ * @brief AMD extension structure enumeration supported by the driver *********************************************************************************************************************** */ -enum AmdExtD3DStructType: UINT +enum AmdExtD3DStructType : UINT { - AmdExtD3DStructUnknown, ///< Unsupported - AmdExtD3DStructPipelineState, ///< Pipeline state extension structure (AmdExtD3DPipelineCreateInfo) + AmdExtD3DStructUnknown, ///< Unsupported + AmdExtD3DStructPipelineState, ///< Pipeline state extension structure (AmdExtD3DPipelineCreateInfo) }; /** @@ -21,11 +21,11 @@ enum AmdExtD3DStructType: UINT */ struct AmdExtD3DCreateInfo { - UINT type; ///< AMD create info structure. Must be one of the supported types. - void* pNext; ///< Pointer to a valid AMD structure. Must be nullptr if using base version. - /// Structures defined by multiple extensions (or versions) may be chained - /// together using this field. When chaining, the driver will process the chain - /// starting from the base parameter onwards. + UINT type; ///< AMD create info structure. Must be one of the supported types. + void* pNext; ///< Pointer to a valid AMD structure. Must be nullptr if using base version. + /// Structures defined by multiple extensions (or versions) may be chained + /// together using this field. When chaining, the driver will process the chain + /// starting from the base parameter onwards. }; /** @@ -35,8 +35,8 @@ struct AmdExtD3DCreateInfo */ struct AmdExtD3DPipelineFlags { - unsigned int depthBoundsTestEnable : 1; ///< Enable depth bounds testing - unsigned int reserved : 31; ///< Reserved bits (must be 0) + unsigned int depthBoundsTestEnable : 1; ///< Enable depth bounds testing + unsigned int reserved : 31; ///< Reserved bits (must be 0) }; /** @@ -44,9 +44,9 @@ struct AmdExtD3DPipelineFlags * @brief Extended pipeline state create info structure *********************************************************************************************************************** */ -struct AmdExtD3DPipelineCreateInfo: AmdExtD3DCreateInfo +struct AmdExtD3DPipelineCreateInfo : AmdExtD3DCreateInfo { - AmdExtD3DPipelineFlags flags; ///< Pipeline flags + AmdExtD3DPipelineFlags flags; ///< Pipeline flags }; /** @@ -55,13 +55,13 @@ struct AmdExtD3DPipelineCreateInfo: AmdExtD3DCreateInfo *********************************************************************************************************************** */ interface __declspec( uuid( "8104C0FC-7413-410F-8E83-AA617E908648" ) ) - IAmdExtD3DDevice: public IUnknown +IAmdExtD3DDevice : public IUnknown { public: virtual HRESULT CreateGraphicsPipelineState( const AmdExtD3DCreateInfo* pAmdExtCreateInfo, const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc, - REFIID riid, + REFIID riid, void** ppPipelineState ) = 0; }; @@ -71,20 +71,20 @@ interface __declspec( uuid( "8104C0FC-7413-410F-8E83-AA617E908648" ) ) *********************************************************************************************************************** */ interface __declspec( uuid( "4BBCAF68-EAF7-4FA4-B653-CB458C334A4E" ) ) - IAmdExtD3DDevice1: public IAmdExtD3DDevice +IAmdExtD3DDevice1 : public IAmdExtD3DDevice { public: - virtual VOID PushMarker( ID3D12GraphicsCommandList* pGfxCmdList, const char* pMarker ) = 0; - virtual VOID PopMarker( ID3D12GraphicsCommandList* pGfxCmdList ) = 0; - virtual VOID SetMarker( ID3D12GraphicsCommandList* pGfxCmdList, const char* pMarker ) = 0; + virtual VOID PushMarker( ID3D12GraphicsCommandList * pGfxCmdList, const char* pMarker ) = 0; + virtual VOID PopMarker( ID3D12GraphicsCommandList * pGfxCmdList ) = 0; + virtual VOID SetMarker( ID3D12GraphicsCommandList * pGfxCmdList, const char* pMarker ) = 0; }; // The app must use GetProcAddress, etc. to retrive this exported function // The associated typedef provides a convenient way to define the function pointer HRESULT __cdecl AmdExtD3DCreateInterface( - IUnknown* pOuter, ///< [in] object on which to base this new interface; usually a D3D device - REFIID riid, ///< ID of the requested interface + IUnknown* pOuter, ///< [in] object on which to base this new interface; usually a D3D device + REFIID riid, ///< ID of the requested interface void** ppvObject ); ///< [out] The result interface object typedef HRESULT( __cdecl* PFNAmdExtD3DCreateInterface )( IUnknown* pOuter, REFIID riid, void** ppvObject ); @@ -95,13 +95,13 @@ typedef HRESULT( __cdecl* PFNAmdExtD3DCreateInterface )( IUnknown* pOuter, REFII * Each extension interface (e.g. tessellation) will derive from this class *********************************************************************************************************************** */ -interface __declspec ( uuid( "014937EC-9288-446F-A9AC-D75A8E3A984F" ) ) - IAmdExtD3DFactory: public IUnknown +interface __declspec( uuid( "014937EC-9288-446F-A9AC-D75A8E3A984F" ) ) +IAmdExtD3DFactory : public IUnknown { public: virtual HRESULT CreateInterface( - IUnknown* pOuter, ///< [in] An object on which to base this new interface; the required object type - ///< is usually a device object but not always - REFIID riid, ///< The ID of the requested interface - void** ppvObject ) = 0; ///< [out] The result interface object + IUnknown * pOuter, ///< [in] An object on which to base this new interface; the required object type + ///< is usually a device object but not always + REFIID riid, ///< The ID of the requested interface + void** ppvObject ) = 0; ///< [out] The result interface object }; diff --git a/trinityal/dx12/util/DescriptorHeapViewDx12.cpp b/trinityal/dx12/util/DescriptorHeapViewDx12.cpp index 3db8408b6..4b8c0ed83 100644 --- a/trinityal/dx12/util/DescriptorHeapViewDx12.cpp +++ b/trinityal/dx12/util/DescriptorHeapViewDx12.cpp @@ -8,18 +8,18 @@ #include "../Tr2PrimaryRenderContextDx12.h" /** */ -DescriptorHeapViewDx12::DescriptorHeapViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry) : - m_entry(heapEntry), - m_allocator(allocator) +DescriptorHeapViewDx12::DescriptorHeapViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ) : + m_entry( heapEntry ), + m_allocator( allocator ) { } /** */ DescriptorHeapViewDx12::~DescriptorHeapViewDx12() { - if (m_allocator != nullptr) + if( m_allocator != nullptr ) { - m_allocator->Free(m_entry); + m_allocator->Free( m_entry ); } } @@ -49,31 +49,28 @@ SamplerStateDx12::SamplerStateDx12( GpuVisibleDescriptorAllocator* allocator, Gl /** */ SamplerStateDx12::~SamplerStateDx12() { - } /** */ -RenderTargetViewDx12::RenderTargetViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry) : - DescriptorHeapViewDx12(allocator, heapEntry) +RenderTargetViewDx12::RenderTargetViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ) : + DescriptorHeapViewDx12( allocator, heapEntry ) { } /** */ RenderTargetViewDx12::~RenderTargetViewDx12() { - } /** */ -DepthStencilViewDx12::DepthStencilViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry) : - DescriptorHeapViewDx12(allocator, heapEntry) +DepthStencilViewDx12::DepthStencilViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ) : + DescriptorHeapViewDx12( allocator, heapEntry ) { } /** */ DepthStencilViewDx12::~DepthStencilViewDx12() { - } #endif diff --git a/trinityal/dx12/util/DescriptorHeapViewDx12.h b/trinityal/dx12/util/DescriptorHeapViewDx12.h index 545f5fda7..95fc76593 100644 --- a/trinityal/dx12/util/DescriptorHeapViewDx12.h +++ b/trinityal/dx12/util/DescriptorHeapViewDx12.h @@ -10,21 +10,27 @@ class DescriptorHeapViewDx12 { public: - /** */ - DescriptorHeapViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry); + DescriptorHeapViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ); /** */ virtual ~DescriptorHeapViewDx12(); /** Get the underlying CPU descriptor handle */ - D3D12_CPU_DESCRIPTOR_HANDLE GetHandleCPU() const { CCP_ASSERT(m_entry != nullptr); return m_entry->m_offsetCPU; }; + D3D12_CPU_DESCRIPTOR_HANDLE GetHandleCPU() const + { + CCP_ASSERT( m_entry != nullptr ); + return m_entry->m_offsetCPU; + }; /** Get the underlying GPU descriptor handle */ - D3D12_GPU_DESCRIPTOR_HANDLE GetHandleGPU() const { CCP_ASSERT(m_entry != nullptr); return m_entry->m_offsetGPU; }; + D3D12_GPU_DESCRIPTOR_HANDLE GetHandleGPU() const + { + CCP_ASSERT( m_entry != nullptr ); + return m_entry->m_offsetGPU; + }; protected: - GlobalDescriptorHeapPage::DescriptorEntry* m_entry; GlobalDescriptorHeapAllocator* m_allocator; }; @@ -33,7 +39,6 @@ class DescriptorHeapViewDx12 class ShaderResourceViewDx12 { public: - ShaderResourceViewDx12( GpuVisibleDescriptorAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ); virtual ~ShaderResourceViewDx12(); @@ -81,7 +86,6 @@ class UnorderedAccessViewDx12 : public ShaderResourceViewDx12 class SamplerStateDx12 : public ShaderResourceViewDx12 { public: - SamplerStateDx12( GpuVisibleDescriptorAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ); virtual ~SamplerStateDx12(); }; @@ -90,8 +94,7 @@ class SamplerStateDx12 : public ShaderResourceViewDx12 class RenderTargetViewDx12 : public DescriptorHeapViewDx12 { public: - - RenderTargetViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry); + RenderTargetViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ); virtual ~RenderTargetViewDx12(); }; @@ -99,8 +102,7 @@ class RenderTargetViewDx12 : public DescriptorHeapViewDx12 class DepthStencilViewDx12 : public DescriptorHeapViewDx12 { public: - - DepthStencilViewDx12(GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry); + DepthStencilViewDx12( GlobalDescriptorHeapAllocator* allocator, GlobalDescriptorHeapPage::DescriptorEntry* heapEntry ); virtual ~DepthStencilViewDx12(); }; diff --git a/trinityal/dx12/util/DescriptorStateCacheDx12.cpp b/trinityal/dx12/util/DescriptorStateCacheDx12.cpp index 216243e57..4b9de3f0b 100644 --- a/trinityal/dx12/util/DescriptorStateCacheDx12.cpp +++ b/trinityal/dx12/util/DescriptorStateCacheDx12.cpp @@ -10,8 +10,8 @@ /** */ DescriptorStateCache::DescriptorStateCache( CComPtr device, Tr2PrimaryRenderContextAL* context ) : - m_primaryContext(context), - m_device(device) + m_primaryContext( context ), + m_device( device ) { m_allocatorUpload.Initialize( device ); @@ -20,12 +20,12 @@ DescriptorStateCache::DescriptorStateCache( CComPtr device, Tr2Pri nullSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; nullSrvDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; nullSrvDesc.Texture2D.MipLevels = 1; - context->CreateShaderResourceView(nullptr, nullSrvDesc, m_nullSrv); + context->CreateShaderResourceView( nullptr, nullSrvDesc, m_nullSrv ); D3D12_UNORDERED_ACCESS_VIEW_DESC nullUavDesc = {}; nullUavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; nullUavDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - context->CreateUnorderedAccessView(nullptr, nullptr, nullUavDesc, m_nullUav); + context->CreateUnorderedAccessView( nullptr, nullptr, nullUavDesc, m_nullUav ); D3D12_SAMPLER_DESC nullSamplerDesc = { D3D12_FILTER_MIN_MAG_MIP_POINT, D3D12_TEXTURE_ADDRESS_MODE_WRAP, D3D12_TEXTURE_ADDRESS_MODE_WRAP, D3D12_TEXTURE_ADDRESS_MODE_WRAP, 0, 0, D3D12_COMPARISON_FUNC_ALWAYS }; nullSamplerDesc.Filter = D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT; @@ -33,7 +33,7 @@ DescriptorStateCache::DescriptorStateCache( CComPtr device, Tr2Pri nullSamplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; nullSamplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; nullSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; - context->CreateSamplerState(nullSamplerDesc, m_nullSampler); + context->CreateSamplerState( nullSamplerDesc, m_nullSampler ); Reset(); } @@ -41,14 +41,14 @@ DescriptorStateCache::DescriptorStateCache( CComPtr device, Tr2Pri /** Dirty all states and reset internal allocators */ void DescriptorStateCache::Reset() { - for (uint32_t slot = 0; slot < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++slot) + for( uint32_t slot = 0; slot < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++slot ) { m_srvUav[slot] = m_nullSrv; m_sampler[slot] = m_nullSampler; m_parameterSlots[slot].SetNone(); } - memset(m_cbv, 0, sizeof(m_cbv)); + memset( m_cbv, 0, sizeof( m_cbv ) ); m_heapsDirty = true; m_srvUavDirty = true; @@ -72,7 +72,7 @@ void DescriptorStateCache::Dirty() m_samplerDirty = true; // Pretend that nothing is currently bound forcing the next Commit() to re-assign every parameter - for (uint32_t slot = 0; slot < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++slot) + for( uint32_t slot = 0; slot < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++slot ) { m_parameterSlots[slot].SetNone(); m_parameterSlots[slot].SetNone(); @@ -80,9 +80,9 @@ void DescriptorStateCache::Dirty() } /** Set an array of ShaderResourceViews */ -void DescriptorStateCache::SetShaderResources(uint32_t startSlot, uint32_t numViews, std::shared_ptr* shaderResourceViews) +void DescriptorStateCache::SetShaderResources( uint32_t startSlot, uint32_t numViews, std::shared_ptr* shaderResourceViews ) { - for (uint32_t slot = 0; slot < numViews; ++slot) + for( uint32_t slot = 0; slot < numViews; ++slot ) { uint32_t writeSlot = startSlot + slot; auto& srv = shaderResourceViews[slot] != nullptr ? shaderResourceViews[slot] : m_nullSrv; @@ -95,9 +95,9 @@ void DescriptorStateCache::SetShaderResources(uint32_t startSlot, uint32_t numVi } /** Set an array or UnorderedAccessViews */ -void DescriptorStateCache::SetUnorderedAccessViews(uint32_t startSlot, uint32_t numViews, std::shared_ptr* unorderedAccessViews) +void DescriptorStateCache::SetUnorderedAccessViews( uint32_t startSlot, uint32_t numViews, std::shared_ptr* unorderedAccessViews ) { - for (uint32_t slot = 0; slot < numViews; ++slot) + for( uint32_t slot = 0; slot < numViews; ++slot ) { uint32_t writeSlot = startSlot + slot; @@ -111,9 +111,9 @@ void DescriptorStateCache::SetUnorderedAccessViews(uint32_t startSlot, uint32_t } /** Set an array of SamplerStates */ -void DescriptorStateCache::SetSamplers(uint32_t startSlot, uint32_t numViews, std::shared_ptr* samplers) +void DescriptorStateCache::SetSamplers( uint32_t startSlot, uint32_t numViews, std::shared_ptr* samplers ) { - for (uint32_t slot = 0; slot < numViews; ++slot) + for( uint32_t slot = 0; slot < numViews; ++slot ) { uint32_t writeSlot = startSlot + slot; auto& sampler = samplers[slot] != nullptr ? samplers[slot] : m_nullSampler; diff --git a/trinityal/dx12/util/DescriptorStateCacheDx12.h b/trinityal/dx12/util/DescriptorStateCacheDx12.h index 74cb1e3ec..238cdbc65 100644 --- a/trinityal/dx12/util/DescriptorStateCacheDx12.h +++ b/trinityal/dx12/util/DescriptorStateCacheDx12.h @@ -19,7 +19,6 @@ class DescriptorStateCache { public: - /** */ DescriptorStateCache( CComPtr device, class Tr2PrimaryRenderContextAL* context ); @@ -33,25 +32,24 @@ class DescriptorStateCache void Commit( ID3D12GraphicsCommandList* commandList, ID3D12DescriptorHeap* globalSrvUavHeap, ID3D12DescriptorHeap* globalSamplerHeap, const TrinityALImpl::Tr2RootSignatureAL* rootSignature ); /** Set an array of ShaderResourceViews */ - void SetShaderResources(uint32_t startSlot, uint32_t numViews, std::shared_ptr* shaderResourceViews); + void SetShaderResources( uint32_t startSlot, uint32_t numViews, std::shared_ptr* shaderResourceViews ); /** Set an array of SamplerStates */ - void SetSamplers(uint32_t startSlot, uint32_t numViews, std::shared_ptr* samplers); + void SetSamplers( uint32_t startSlot, uint32_t numViews, std::shared_ptr* samplers ); /** Set a constantbuffer */ - void SetConstantBuffers(Tr2RenderContextEnum::ShaderType shaderStage, uint32_t slot, const TrinityALImpl::Tr2ConstantBufferAL& constantBuffer); + void SetConstantBuffers( Tr2RenderContextEnum::ShaderType shaderStage, uint32_t slot, const TrinityALImpl::Tr2ConstantBufferAL& constantBuffer ); D3D12_GPU_VIRTUAL_ADDRESS UploadConstants( const TrinityALImpl::Tr2ConstantBufferAL& constantBuffer ); D3D12_GPU_VIRTUAL_ADDRESS UploadConstants( const void* data, uint32_t size ); /** Set an array or UnorderedAccessViews */ - void SetUnorderedAccessViews(uint32_t startSlot, uint32_t numViews, std::shared_ptr* unorderedAccessViews); + void SetUnorderedAccessViews( uint32_t startSlot, uint32_t numViews, std::shared_ptr* unorderedAccessViews ); void SetHeaps( ID3D12GraphicsCommandList* commandList, ID3D12DescriptorHeap* globalSrvUavHeap, ID3D12DescriptorHeap* globalSamplerHeap ); private: - /** Instance of a root parameter set slot */ - struct RootParameterSlot + struct RootParameterSlot { enum ERootParameterType { @@ -61,7 +59,10 @@ class DescriptorStateCache RPT_Sampler = 3 }; - RootParameterSlot() { SetNone(); } + RootParameterSlot() + { + SetNone(); + } /** Empty slot */ void SetNone() @@ -71,50 +72,50 @@ class DescriptorStateCache } /** Mark as SRV */ - void SetSRV(D3D12_GPU_DESCRIPTOR_HANDLE address) + void SetSRV( D3D12_GPU_DESCRIPTOR_HANDLE address ) { m_addressDescriptor = address; m_type = RPT_SRV; } /** Mark as Sampler */ - void SetSampler(D3D12_GPU_DESCRIPTOR_HANDLE address) + void SetSampler( D3D12_GPU_DESCRIPTOR_HANDLE address ) { m_addressDescriptor = address; m_type = RPT_Sampler; } /** Mark as CBV */ - void SetCBV(D3D12_GPU_VIRTUAL_ADDRESS address) + void SetCBV( D3D12_GPU_VIRTUAL_ADDRESS address ) { m_addressVirtual = address; m_type = RPT_CBV; } /** Does the slot contain an SRV at the given address? */ - bool IsValidSRV(D3D12_GPU_DESCRIPTOR_HANDLE address) + bool IsValidSRV( D3D12_GPU_DESCRIPTOR_HANDLE address ) { return m_type == RPT_SRV && m_addressDescriptor.ptr == address.ptr; } /** Does the slot contain sampler at the given address? */ - bool IsValidSampler(D3D12_GPU_DESCRIPTOR_HANDLE address) + bool IsValidSampler( D3D12_GPU_DESCRIPTOR_HANDLE address ) { return m_type == RPT_Sampler && m_addressDescriptor.ptr == address.ptr; } /** Does the slot contain a CBVat the given address/stage/index */ - bool IsValidCBV(D3D12_GPU_VIRTUAL_ADDRESS address) + bool IsValidCBV( D3D12_GPU_VIRTUAL_ADDRESS address ) { return m_type == RPT_CBV && m_addressVirtual == address; } - - union + + union { D3D12_GPU_DESCRIPTOR_HANDLE m_addressDescriptor; D3D12_GPU_VIRTUAL_ADDRESS m_addressVirtual; }; - + ERootParameterType m_type; }; diff --git a/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.cpp b/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.cpp index 58443555b..7041d50ba 100644 --- a/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.cpp +++ b/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.cpp @@ -11,11 +11,11 @@ ////////////////////////////////////////////////////////////////////////// /** */ -FrameLocalDescriptorHeapPage::FrameLocalDescriptorHeapPage(CComPtr descriptorHeap, uint32_t entryCount, uint32_t entrySize) : - m_entryCount(entryCount), - m_entrySize(entrySize), - m_currentEntry(0), - m_descriptorHeap(descriptorHeap) +FrameLocalDescriptorHeapPage::FrameLocalDescriptorHeapPage( CComPtr descriptorHeap, uint32_t entryCount, uint32_t entrySize ) : + m_entryCount( entryCount ), + m_entrySize( entrySize ), + m_currentEntry( 0 ), + m_descriptorHeap( descriptorHeap ) { m_baseOffsetCpu = m_descriptorHeap->GetCPUDescriptorHandleForHeapStart(); m_baseOffsetGpu = m_descriptorHeap->GetGPUDescriptorHandleForHeapStart(); @@ -28,15 +28,15 @@ void FrameLocalDescriptorHeapPage::Reset() } /** Gets whether the page can accomodate the request entry count */ -bool FrameLocalDescriptorHeapPage::HasSpace(uint32_t requiredEntries) const +bool FrameLocalDescriptorHeapPage::HasSpace( uint32_t requiredEntries ) const { return m_entryCount - m_currentEntry >= requiredEntries; } /** Allocates space within the page */ -DescriptorHeapEntry FrameLocalDescriptorHeapPage::Allocate(uint32_t requiredEntries) +DescriptorHeapEntry FrameLocalDescriptorHeapPage::Allocate( uint32_t requiredEntries ) { - CCP_ASSERT(HasSpace(requiredEntries)); + CCP_ASSERT( HasSpace( requiredEntries ) ); DescriptorHeapEntry result; result.m_cpuHandle.ptr = m_baseOffsetCpu.ptr + m_currentEntry * m_entrySize; @@ -54,13 +54,13 @@ DescriptorHeapEntry FrameLocalDescriptorHeapPage::Allocate(uint32_t requiredEntr ////////////////////////////////////////////////////////////////////////// /** */ -FrameLocalDescriptorHeapAllocator::FrameLocalDescriptorHeapAllocator(CComPtr device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, uint32_t pageEntryCount) : - m_device(device), - m_heapType(heapType), - m_pageEntryCount(pageEntryCount), - m_currentPage(0) +FrameLocalDescriptorHeapAllocator::FrameLocalDescriptorHeapAllocator( CComPtr device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, uint32_t pageEntryCount ) : + m_device( device ), + m_heapType( heapType ), + m_pageEntryCount( pageEntryCount ), + m_currentPage( 0 ) { - m_pageEntrySize = m_device->GetDescriptorHandleIncrementSize(m_heapType); + m_pageEntrySize = m_device->GetDescriptorHandleIncrementSize( m_heapType ); // Add default page AddPage(); @@ -74,20 +74,20 @@ void FrameLocalDescriptorHeapAllocator::Reset() } /** Allocates space within the heap and grows if necessary */ -DescriptorHeapEntry FrameLocalDescriptorHeapAllocator::Allocate(uint32_t requiredEntries) +DescriptorHeapEntry FrameLocalDescriptorHeapAllocator::Allocate( uint32_t requiredEntries ) { // What if a page size is too small to fit all the possible resource in? - CCP_ASSERT(requiredEntries <= m_pageEntryCount); + CCP_ASSERT( requiredEntries <= m_pageEntryCount ); // Page is almost full, move to the next one bool isDirty = false; - if (!m_pages[m_currentPage].HasSpace(requiredEntries)) + if( !m_pages[m_currentPage].HasSpace( requiredEntries ) ) { m_currentPage++; isDirty = true; // Grow allocator if necessary - if (m_currentPage >= m_pages.size()) + if( m_currentPage >= m_pages.size() ) { AddPage(); } @@ -96,9 +96,9 @@ DescriptorHeapEntry FrameLocalDescriptorHeapAllocator::Allocate(uint32_t require m_pages[m_currentPage].Reset(); } } - CCP_ASSERT(m_pages[m_currentPage].HasSpace(requiredEntries)); + CCP_ASSERT( m_pages[m_currentPage].HasSpace( requiredEntries ) ); - DescriptorHeapEntry result = m_pages[m_currentPage].Allocate(requiredEntries); + DescriptorHeapEntry result = m_pages[m_currentPage].Allocate( requiredEntries ); result.m_isDirty = isDirty; return result; } @@ -113,14 +113,14 @@ void FrameLocalDescriptorHeapAllocator::AddPage() heapDesc.Type = m_heapType; heapDesc.NumDescriptors = m_pageEntryCount; - HRESULT hr = m_device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); - CCP_ASSERT(hr == S_OK); - if (hr != S_OK) + HRESULT hr = m_device->CreateDescriptorHeap( &heapDesc, IID_PPV_ARGS( &descriptorHeap ) ); + CCP_ASSERT( hr == S_OK ); + if( hr != S_OK ) { return; } - m_pages.push_back(FrameLocalDescriptorHeapPage(descriptorHeap, m_pageEntryCount, m_pageEntrySize)); + m_pages.push_back( FrameLocalDescriptorHeapPage( descriptorHeap, m_pageEntryCount, m_pageEntrySize ) ); } /** Gets the handle of the currently active page */ diff --git a/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.h b/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.h index 14b9e71e1..a0973adc0 100644 --- a/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.h +++ b/trinityal/dx12/util/FrameLocalDescriptorHeapAllocatorDx12.h @@ -21,24 +21,25 @@ struct DescriptorHeapEntry class FrameLocalDescriptorHeapPage { public: - /** */ - FrameLocalDescriptorHeapPage(CComPtr descriptorHeap, uint32_t entryCount, uint32_t entrySize); + FrameLocalDescriptorHeapPage( CComPtr descriptorHeap, uint32_t entryCount, uint32_t entrySize ); /** Reset the page write pointer */ void Reset(); /** Gets whether the page can accomodate the request entry count */ - bool HasSpace(uint32_t requiredEntries) const; + bool HasSpace( uint32_t requiredEntries ) const; /** Allocates space within the page */ - DescriptorHeapEntry Allocate(uint32_t requiredEntries); + DescriptorHeapEntry Allocate( uint32_t requiredEntries ); /** Gets the handle of this heap */ - ID3D12DescriptorHeap* GetHeap() const { return m_descriptorHeap; } + ID3D12DescriptorHeap* GetHeap() const + { + return m_descriptorHeap; + } private: - uint32_t m_entryCount; uint32_t m_entrySize; uint32_t m_currentEntry; @@ -51,21 +52,19 @@ class FrameLocalDescriptorHeapPage class FrameLocalDescriptorHeapAllocator { public: - /** */ - FrameLocalDescriptorHeapAllocator(CComPtr device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, uint32_t pageEntryCount); + FrameLocalDescriptorHeapAllocator( CComPtr device, D3D12_DESCRIPTOR_HEAP_TYPE heapType, uint32_t pageEntryCount ); /** Resets the current page pointer as well as the page */ void Reset(); /** Allocates space within the heap and grows if necessary */ - DescriptorHeapEntry Allocate(uint32_t requiredEntries); + DescriptorHeapEntry Allocate( uint32_t requiredEntries ); /** Gets the handle of the currently active page */ ID3D12DescriptorHeap* GetCurrentHeap() const; private: - /** Add a new page */ void AddPage(); diff --git a/trinityal/dx12/util/FrameLocalUploadBufferAllocatorDx12.cpp b/trinityal/dx12/util/FrameLocalUploadBufferAllocatorDx12.cpp index f182157d1..198543581 100644 --- a/trinityal/dx12/util/FrameLocalUploadBufferAllocatorDx12.cpp +++ b/trinityal/dx12/util/FrameLocalUploadBufferAllocatorDx12.cpp @@ -62,7 +62,7 @@ ConstantBufferAllocator::Entry ConstantBufferAllocator::Allocate( const void* da std::lock_guard lock( m_spillMutex ); if( !m_spillPage.buffer || m_spillOffset + size > m_spillPage.size ) - { + { m_spillPage.size *= 2; CreatePage( m_spillPage ); } @@ -71,9 +71,9 @@ ConstantBufferAllocator::Entry ConstantBufferAllocator::Allocate( const void* da m_spillOffset += size; } if( data ) - { + { memcpy( entry.m_cpuAddr, data, dataSize ); - } + } return entry; } diff --git a/trinityal/dx12/util/FreeList.h b/trinityal/dx12/util/FreeList.h index d342c4caf..103a772f1 100644 --- a/trinityal/dx12/util/FreeList.h +++ b/trinityal/dx12/util/FreeList.h @@ -8,10 +8,10 @@ #include /** FreeList class, used by D3D12 Allocators */ -template class FreeList +template +class FreeList { public: - /** List Entry State */ enum EMode { @@ -25,11 +25,11 @@ template class FreeList /** Single list entry */ struct Entry : T { - Entry(uint32_t entryIndex, const tInitArgs& initArgs) : - T(entryIndex, initArgs), - m_mode(EM_Free), - m_prev(nullptr), - m_next(nullptr) + Entry( uint32_t entryIndex, const tInitArgs& initArgs ) : + T( entryIndex, initArgs ), + m_mode( EM_Free ), + m_prev( nullptr ), + m_next( nullptr ) { } @@ -39,11 +39,11 @@ template class FreeList }; /** */ - FreeList(uint32_t entryCount, const tInitArgs& initArgs) : - m_entryCount(0), - m_freeCount(0), - m_freeHead(nullptr), - m_inUseHead(nullptr) + FreeList( uint32_t entryCount, const tInitArgs& initArgs ) : + m_entryCount( 0 ), + m_freeCount( 0 ), + m_freeHead( nullptr ), + m_inUseHead( nullptr ) { AddPage( entryCount, initArgs ); @@ -75,7 +75,7 @@ template class FreeList { m_allEntries.emplace_back( std::make_unique>() ); // Create free list - auto& page = *m_allEntries.back(); + auto& page = *m_allEntries.back(); page.reserve( pageSize ); for( uint32_t entryIdx = 0; entryIdx < pageSize; ++entryIdx ) { @@ -136,21 +136,21 @@ template class FreeList T* Allocate() { // List is full - if (m_freeHead == nullptr) + if( m_freeHead == nullptr ) return nullptr; Entry* entry = m_freeHead; // Move to the next free element, then unlink this entry m_freeHead = entry->m_next; - if (m_freeHead != nullptr) + if( m_freeHead != nullptr ) { m_freeHead->m_prev = nullptr; entry->m_next = nullptr; } // Push into the allocated list - if (m_inUseHead != nullptr) + if( m_inUseHead != nullptr ) { m_inUseHead->m_prev = entry; } @@ -159,41 +159,41 @@ template class FreeList entry->m_mode = EM_InUse; m_inUseHead = entry; - CCP_ASSERT(m_freeCount > 0); + CCP_ASSERT( m_freeCount > 0 ); --m_freeCount; return entry; } /** Free an entry */ - void Free(T* entryAsT) + void Free( T* entryAsT ) { - Entry* entry = reinterpret_cast(entryAsT); - ValidateEntry(entry); + Entry* entry = reinterpret_cast( entryAsT ); + ValidateEntry( entry ); - if (entry == nullptr || entry->m_mode == EM_Free) + if( entry == nullptr || entry->m_mode == EM_Free ) return; // Unlink from in-use neighbors - if (entry->m_prev != nullptr) + if( entry->m_prev != nullptr ) { entry->m_prev->m_next = entry->m_next; } - if (entry->m_next != nullptr) + if( entry->m_next != nullptr ) { entry->m_next->m_prev = entry->m_prev; } // Also, ensure head reference is updated - if (m_inUseHead == entry) + if( m_inUseHead == entry ) { m_inUseHead = entry->m_next; } // Insert into free section - if (m_freeHead != nullptr) + if( m_freeHead != nullptr ) { m_freeHead->m_prev = entry; } @@ -204,11 +204,11 @@ template class FreeList m_freeHead = entry; m_freeCount++; - CCP_ASSERT(m_freeCount <= m_entryCount); + CCP_ASSERT( m_freeCount <= m_entryCount ); } /** Validate that an entry exists within this lists scope */ - void ValidateEntry(T* entry) + void ValidateEntry( T* entry ) { // The pointer should lie within our pre-allocated list uintptr_t entryPtr = reinterpret_cast( entry ); @@ -226,7 +226,6 @@ template class FreeList } private: - uint32_t m_entryCount; uint32_t m_freeCount; std::vector>> m_allEntries; diff --git a/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.cpp b/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.cpp index f12b722db..a8340f96a 100644 --- a/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.cpp +++ b/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.cpp @@ -13,15 +13,15 @@ ////////////////////////////////////////////////////////////////////////// /** */ -GlobalDescriptorHeapAllocator::GlobalDescriptorHeapAllocator(CComPtr device, uint32_t maxPages, uint32_t pageEntryCount, D3D12_DESCRIPTOR_HEAP_TYPE heapType) : - m_mutex("GlobalDescriptorHeapAllocator", "m_mutex"), - m_device(device), - m_heapType(heapType), - m_pageEntryCount(pageEntryCount), - m_descriptorsInUse(0), +GlobalDescriptorHeapAllocator::GlobalDescriptorHeapAllocator( CComPtr device, uint32_t maxPages, uint32_t pageEntryCount, D3D12_DESCRIPTOR_HEAP_TYPE heapType ) : + m_mutex( "GlobalDescriptorHeapAllocator", "m_mutex" ), + m_device( device ), + m_heapType( heapType ), + m_pageEntryCount( pageEntryCount ), + m_descriptorsInUse( 0 ), m_pages( maxPages, maxPages ) { - m_heapIncrement = m_device->GetDescriptorHandleIncrementSize(m_heapType); + m_heapIncrement = m_device->GetDescriptorHandleIncrementSize( m_heapType ); } /** */ @@ -30,24 +30,24 @@ GlobalDescriptorHeapAllocator::~GlobalDescriptorHeapAllocator() // If this isn't 0, then some views haven't been freed yet // If necessary, we could add a debug string to DescriptorEntry and dump those // if we want better object tracking - CCP_ASSERT(m_descriptorsInUse == 0); + CCP_ASSERT( m_descriptorsInUse == 0 ); } /** Allocate an entry */ GlobalDescriptorHeapPage::DescriptorEntry* GlobalDescriptorHeapAllocator::Allocate() { - CcpAutoMutex lock(m_mutex); + CcpAutoMutex lock( m_mutex ); HeapPageEntry* page = m_pages.GetFirstFree(); - if (page == nullptr) + if( page == nullptr ) { // FATAL: Totally out of memory,, is there a better way of handling this? - CCP_ASSERT(page != nullptr); + CCP_ASSERT( page != nullptr ); return nullptr; } // Pages start off uninitialized... we might want to change this behavior in the future - if (page->m_page == nullptr) + if( page->m_page == nullptr ) { CComPtr descriptorHeap = nullptr; @@ -56,29 +56,29 @@ GlobalDescriptorHeapPage::DescriptorEntry* GlobalDescriptorHeapAllocator::Alloca heapDesc.NumDescriptors = m_pageEntryCount; heapDesc.Type = m_heapType; - HRESULT hr = m_device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); - if (hr != S_OK) + HRESULT hr = m_device->CreateDescriptorHeap( &heapDesc, IID_PPV_ARGS( &descriptorHeap ) ); + if( hr != S_OK ) { // FATAL: Can't back an allocation with a heap - CCP_ASSERT(hr == S_OK); + CCP_ASSERT( hr == S_OK ); return nullptr; } - page->m_page = std::make_unique(descriptorHeap, m_pageEntryCount, m_heapIncrement); + page->m_page = std::make_unique( descriptorHeap, m_pageEntryCount, m_heapIncrement ); } // m_page->getFirstFree() should never return a full page! - CCP_ASSERT(!page->m_page->IsFull()); + CCP_ASSERT( !page->m_page->IsFull() ); // Allocate entry GlobalDescriptorHeapPage::DescriptorEntry* entry = page->m_page->Allocate(); - CCP_ASSERT(entry != nullptr); + CCP_ASSERT( entry != nullptr ); // Assign a tag, so we can quickly free this entry later entry->m_pageTag = page; // If the page is now full, mark it as such - if (page->m_page->IsFull()) + if( page->m_page->IsFull() ) { // Note: Nothing is allocated, the free list will just move the first entry // over into the 'in use' list @@ -91,32 +91,32 @@ GlobalDescriptorHeapPage::DescriptorEntry* GlobalDescriptorHeapAllocator::Alloca } /** Free an entry */ -void GlobalDescriptorHeapAllocator::Free(GlobalDescriptorHeapPage::DescriptorEntry* entry) +void GlobalDescriptorHeapAllocator::Free( GlobalDescriptorHeapPage::DescriptorEntry* entry ) { - CcpAutoMutex lock(m_mutex); + CcpAutoMutex lock( m_mutex ); - CCP_ASSERT(entry->m_pageTag != nullptr); - CCP_ASSERT(entry->m_owner != nullptr); + CCP_ASSERT( entry->m_pageTag != nullptr ); + CCP_ASSERT( entry->m_owner != nullptr ); // Recover page handle - HeapPageEntry* page = reinterpret_cast(entry->m_pageTag); - CCP_ASSERT(page->m_page != nullptr); - m_pages.ValidateEntry(page); + HeapPageEntry* page = reinterpret_cast( entry->m_pageTag ); + CCP_ASSERT( page->m_page != nullptr ); + m_pages.ValidateEntry( page ); // If the page is currently full, then it'll be marked as InUse // it'll definitely not be full after this operation, so we can move it over - if (page->m_page->IsFull()) + if( page->m_page->IsFull() ) { - m_pages.Free(page); + m_pages.Free( page ); } // Free entry - page->m_page->Free(entry); + page->m_page->Free( entry ); - CCP_ASSERT(m_descriptorsInUse > 0); + CCP_ASSERT( m_descriptorsInUse > 0 ); m_descriptorsInUse--; - CCP_ASSERT(!page->m_page->IsFull()); + CCP_ASSERT( !page->m_page->IsFull() ); } ////////////////////////////////////////////////////////////////////////// @@ -124,23 +124,23 @@ void GlobalDescriptorHeapAllocator::Free(GlobalDescriptorHeapPage::DescriptorEnt ////////////////////////////////////////////////////////////////////////// /** */ -GlobalDescriptorHeapPage::DescriptorEntry::DescriptorEntry(uint32_t entryIdx, const GlobalDescriptorHeapPage::DescriptorInitArgs& initArgs) : - m_owner(nullptr), - m_pageTag(nullptr) +GlobalDescriptorHeapPage::DescriptorEntry::DescriptorEntry( uint32_t entryIdx, const GlobalDescriptorHeapPage::DescriptorInitArgs& initArgs ) : + m_owner( nullptr ), + m_pageTag( nullptr ) { m_offsetCPU.ptr = initArgs.m_baseOffsetCPU.ptr + entryIdx * initArgs.m_entrySize; m_offsetGPU.ptr = initArgs.m_baseOffsetGPU.ptr + entryIdx * initArgs.m_entrySize; } /** */ -GlobalDescriptorHeapPage::GlobalDescriptorHeapPage(CComPtr descriptorHeap, UINT entryCount, UINT entrySize) : - m_descriptorHeap(descriptorHeap) +GlobalDescriptorHeapPage::GlobalDescriptorHeapPage( CComPtr descriptorHeap, UINT entryCount, UINT entrySize ) : + m_descriptorHeap( descriptorHeap ) { D3D12_CPU_DESCRIPTOR_HANDLE baseOffsetCPU = m_descriptorHeap->GetCPUDescriptorHandleForHeapStart(); D3D12_GPU_DESCRIPTOR_HANDLE baseOffsetGPU = { 0 }; - DescriptorInitArgs init(baseOffsetCPU, baseOffsetGPU, entrySize); - m_freeList = std::make_shared(entryCount, init); + DescriptorInitArgs init( baseOffsetCPU, baseOffsetGPU, entrySize ); + m_freeList = std::make_shared( entryCount, init ); } /** Allocate an entry */ @@ -153,11 +153,11 @@ GlobalDescriptorHeapPage::DescriptorEntry* GlobalDescriptorHeapPage::Allocate() } /** Free an entry */ -void GlobalDescriptorHeapPage::Free(GlobalDescriptorHeapPage::DescriptorEntry* entry) +void GlobalDescriptorHeapPage::Free( GlobalDescriptorHeapPage::DescriptorEntry* entry ) { - CCP_ASSERT(entry->m_owner == this); + CCP_ASSERT( entry->m_owner == this ); - m_freeList->Free(entry); + m_freeList->Free( entry ); } diff --git a/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.h b/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.h index dfe8422b6..19aa1175c 100644 --- a/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.h +++ b/trinityal/dx12/util/GlobalDescriptorHeapAllocatorDx12.h @@ -13,7 +13,6 @@ class GlobalDescriptorHeapPage { public: - /** Init args for DescriptorEntry */ struct DescriptorInitArgs { @@ -21,10 +20,10 @@ class GlobalDescriptorHeapPage D3D12_GPU_DESCRIPTOR_HANDLE m_baseOffsetGPU; UINT m_entrySize; - DescriptorInitArgs(D3D12_CPU_DESCRIPTOR_HANDLE baseOffsetCPU, D3D12_GPU_DESCRIPTOR_HANDLE baseOffsetGPU, UINT entrySize) : - m_baseOffsetCPU(baseOffsetCPU), - m_baseOffsetGPU(baseOffsetGPU), - m_entrySize(entrySize) + DescriptorInitArgs( D3D12_CPU_DESCRIPTOR_HANDLE baseOffsetCPU, D3D12_GPU_DESCRIPTOR_HANDLE baseOffsetGPU, UINT entrySize ) : + m_baseOffsetCPU( baseOffsetCPU ), + m_baseOffsetGPU( baseOffsetGPU ), + m_entrySize( entrySize ) { } }; @@ -43,23 +42,25 @@ class GlobalDescriptorHeapPage D3D12_GPU_DESCRIPTOR_HANDLE m_offsetGPU; /** */ - DescriptorEntry(uint32_t entryIdx, const struct DescriptorInitArgs& initArgs); + DescriptorEntry( uint32_t entryIdx, const struct DescriptorInitArgs& initArgs ); }; /** */ - GlobalDescriptorHeapPage(CComPtr descriptorHeap, UINT entryCount, UINT entrySize); + GlobalDescriptorHeapPage( CComPtr descriptorHeap, UINT entryCount, UINT entrySize ); /** Allocate an entry */ DescriptorEntry* Allocate(); /** Free an entry */ - void Free(DescriptorEntry* entry); + void Free( DescriptorEntry* entry ); /** Get whether this page is full */ - bool IsFull() const { return m_freeList->IsFull(); } + bool IsFull() const + { + return m_freeList->IsFull(); + } private: - typedef FreeList DescriptorList; std::shared_ptr m_freeList; @@ -70,7 +71,6 @@ class GlobalDescriptorHeapPage class GlobalDescriptorHeapAllocator { public: - /** Heap stats container */ struct HeapStats { @@ -91,7 +91,7 @@ class GlobalDescriptorHeapAllocator }; /** */ - GlobalDescriptorHeapAllocator(CComPtr device, uint32_t maxPages, uint32_t pageEntryCount, D3D12_DESCRIPTOR_HEAP_TYPE heapType); + GlobalDescriptorHeapAllocator( CComPtr device, uint32_t maxPages, uint32_t pageEntryCount, D3D12_DESCRIPTOR_HEAP_TYPE heapType ); /** */ ~GlobalDescriptorHeapAllocator(); @@ -100,17 +100,16 @@ class GlobalDescriptorHeapAllocator GlobalDescriptorHeapPage::DescriptorEntry* Allocate(); /** Free an entry */ - void Free(GlobalDescriptorHeapPage::DescriptorEntry* entry); + void Free( GlobalDescriptorHeapPage::DescriptorEntry* entry ); private: - /** A freelist page entry */ struct HeapPageEntry { std::unique_ptr m_page; - HeapPageEntry(uint32_t, const uint32_t&) - : m_page(nullptr) + HeapPageEntry( uint32_t, const uint32_t& ) : + m_page( nullptr ) { } }; @@ -132,7 +131,6 @@ class GlobalDescriptorHeapAllocator class GpuVisibleDescriptorAllocator { public: - GpuVisibleDescriptorAllocator( ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t initialSize ); ~GpuVisibleDescriptorAllocator(); diff --git a/trinityal/dx12/util/GpuCrashTracker.cpp b/trinityal/dx12/util/GpuCrashTracker.cpp index 70d5caec9..8bbea2263 100644 --- a/trinityal/dx12/util/GpuCrashTracker.cpp +++ b/trinityal/dx12/util/GpuCrashTracker.cpp @@ -10,286 +10,286 @@ #include #include -#define AFTERMATH_CHECK_ERROR( FC ) \ - [&]() { \ - GFSDK_Aftermath_Result _result = FC; \ - if( !GFSDK_Aftermath_SUCCEED( _result ) ) \ - { \ - return false; \ - } \ - return true; \ +#define AFTERMATH_CHECK_ERROR( FC ) \ + [&]() { \ + GFSDK_Aftermath_Result _result = FC; \ + if( !GFSDK_Aftermath_SUCCEED( _result ) ) \ + { \ + return false; \ + } \ + return true; \ }() -#define AFTERMATH_CHECK_AND_LOG_ERROR( FC ) \ - [&]() { \ - GFSDK_Aftermath_Result _result = FC; \ - if( !GFSDK_Aftermath_SUCCEED( _result ) ) \ - { \ - CCP_LOGERR( Aftermath::GetErrorMessage( _result ).c_str() ); \ - return false; \ - } \ - return true; \ +#define AFTERMATH_CHECK_AND_LOG_ERROR( FC ) \ + [&]() { \ + GFSDK_Aftermath_Result _result = FC; \ + if( !GFSDK_Aftermath_SUCCEED( _result ) ) \ + { \ + CCP_LOGERR( Aftermath::GetErrorMessage( _result ).c_str() ); \ + return false; \ + } \ + return true; \ }() namespace Aftermath { - template - inline std::string to_hex_string(T n) - { - std::stringstream stream; - stream << std::setfill('0') << std::setw(2 * sizeof(T)) << std::hex << n; - return stream.str(); - } +template +inline std::string to_hex_string( T n ) +{ + std::stringstream stream; + stream << std::setfill( '0' ) << std::setw( 2 * sizeof( T ) ) << std::hex << n; + return stream.str(); +} - inline std::string to_string(GFSDK_Aftermath_Result result) - { - return std::string("0x") + to_hex_string(static_cast(result)); - } +inline std::string to_string( GFSDK_Aftermath_Result result ) +{ + return std::string( "0x" ) + to_hex_string( static_cast( result ) ); +} - inline std::string to_string(const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier) - { - return to_hex_string(identifier.id[0]) + "-" + to_hex_string(identifier.id[1]); - } +inline std::string to_string( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier ) +{ + return to_hex_string( identifier.id[0] ) + "-" + to_hex_string( identifier.id[1] ); +} - inline std::string to_string(const GFSDK_Aftermath_ShaderHash& hash) - { - return to_hex_string(hash.hash); - } +inline std::string to_string( const GFSDK_Aftermath_ShaderHash& hash ) +{ + return to_hex_string( hash.hash ); +} - inline std::string to_string(const GFSDK_Aftermath_ShaderInstructionsHash& hash) - { - return to_hex_string(hash.hash) + "-" + to_hex_string(hash.hash); - } +inline std::string to_string( const GFSDK_Aftermath_ShaderInstructionsHash& hash ) +{ + return to_hex_string( hash.hash ) + "-" + to_hex_string( hash.hash ); +} - std::string GetErrorMessage( GFSDK_Aftermath_Result result ) +std::string GetErrorMessage( GFSDK_Aftermath_Result result ) +{ + switch( result ) { - switch( result ) - { - case GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported: - return "Unsupported driver version - requires at least an NVIDIA R435 display driver."; - case GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported: - return "Aftermath is incompatible with D3D API interception, such as PIX or Nsight Graphics."; - default: - return "Aftermath Error 0x" + to_hex_string(result); - } + case GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported: + return "Unsupported driver version - requires at least an NVIDIA R435 display driver."; + case GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported: + return "Aftermath is incompatible with D3D API interception, such as PIX or Nsight Graphics."; + default: + return "Aftermath Error 0x" + to_hex_string( result ); } } +} -namespace TrinityALImpl +namespace TrinityALImpl { - GpuCrashTracker::GpuCrashTracker(): - m_offendingShader(""), - m_initializedForDevice( false ) - { - m_initialized = AFTERMATH_CHECK_ERROR( GFSDK_Aftermath_EnableGpuCrashDumps( - GFSDK_Aftermath_Version_API, - GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_DX, - GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks, // Let the Nsight Aftermath library cache shader debug information. - GpuCrashDumpCallback, // Register callback for GPU crash dumps. - ShaderDebugInfoCallback, // Register callback for shader debug information. - nullptr, // callback for GPU crash dump description. - this ) ); // Set the GpuCrashTracker object as user data for the above callbacks. - } +GpuCrashTracker::GpuCrashTracker() : + m_offendingShader( "" ), + m_initializedForDevice( false ) +{ + m_initialized = AFTERMATH_CHECK_ERROR( GFSDK_Aftermath_EnableGpuCrashDumps( + GFSDK_Aftermath_Version_API, + GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_DX, + GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks, // Let the Nsight Aftermath library cache shader debug information. + GpuCrashDumpCallback, // Register callback for GPU crash dumps. + ShaderDebugInfoCallback, // Register callback for shader debug information. + nullptr, // callback for GPU crash dump description. + this ) ); // Set the GpuCrashTracker object as user data for the above callbacks. +} - GpuCrashTracker::~GpuCrashTracker() +GpuCrashTracker::~GpuCrashTracker() +{ + if( m_initialized ) { - if (m_initialized) - { - GFSDK_Aftermath_DisableGpuCrashDumps(); - } + GFSDK_Aftermath_DisableGpuCrashDumps(); } +} - void GpuCrashTracker::GetOffendingShader(std::string& shaderString) const - { - shaderString = m_offendingShader; - } +void GpuCrashTracker::GetOffendingShader( std::string& shaderString ) const +{ + shaderString = m_offendingShader; +} - bool GpuCrashTracker::IsValid() const - { - return m_initialized; - } +bool GpuCrashTracker::IsValid() const +{ + return m_initialized; +} - void GpuCrashTracker::Initialize( ID3D12Device* device ) +void GpuCrashTracker::Initialize( ID3D12Device* device ) +{ + const uint32_t aftermathFlags = + GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking. + GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of resources. + GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo; // Generate debug information for shaders. + // There are additional flag to set, but we don't because it will affect performance + + m_initializedForDevice = AFTERMATH_CHECK_ERROR( GFSDK_Aftermath_DX12_Initialize( + GFSDK_Aftermath_Version_API, + aftermathFlags, + device ) ); + + if( m_initializedForDevice ) { - const uint32_t aftermathFlags = - GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking. - GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of resources. - GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo; // Generate debug information for shaders. - // There are additional flag to set, but we don't because it will affect performance - - m_initializedForDevice = AFTERMATH_CHECK_ERROR( GFSDK_Aftermath_DX12_Initialize( - GFSDK_Aftermath_Version_API, - aftermathFlags, - device ) ); - - if(m_initializedForDevice) - { - CCP_LOGNOTICE( "Aftermath enabled for device" ); - } + CCP_LOGNOTICE( "Aftermath enabled for device" ); } +} - void GpuCrashTracker::RegisterShaderBinary(const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath) +void GpuCrashTracker::RegisterShaderBinary( const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath ) +{ + if( !m_initializedForDevice ) { - if( !m_initializedForDevice ) - { - return; - } - // Create shader hashes for the shader bytecode - const D3D12_SHADER_BYTECODE shader{ bytecode.bytecode, bytecode.size }; - GFSDK_Aftermath_ShaderHash shaderHash; - GFSDK_Aftermath_ShaderInstructionsHash shaderInstructionsHash; - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GetShaderHash( - GFSDK_Aftermath_Version_API, - &shader, - &shaderHash, - &shaderInstructionsHash)); - - // Store the data for shader instruction address mapping when decoding GPU crash dumps. - m_shaderHashToBytecode[shaderHash] = std::pair(bytecode.bytecode, bytecode.size); - m_shaderHashToPath[shaderHash] = shaderPath; - m_shaderInstructionsToShaderHash[shaderInstructionsHash] = shaderHash; + return; } + // Create shader hashes for the shader bytecode + const D3D12_SHADER_BYTECODE shader{ bytecode.bytecode, bytecode.size }; + GFSDK_Aftermath_ShaderHash shaderHash; + GFSDK_Aftermath_ShaderInstructionsHash shaderInstructionsHash; + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GetShaderHash( + GFSDK_Aftermath_Version_API, + &shader, + &shaderHash, + &shaderInstructionsHash ) ); + + // Store the data for shader instruction address mapping when decoding GPU crash dumps. + m_shaderHashToBytecode[shaderHash] = std::pair( bytecode.bytecode, bytecode.size ); + m_shaderHashToPath[shaderHash] = shaderPath; + m_shaderInstructionsToShaderHash[shaderInstructionsHash] = shaderHash; +} - // This function should be used to dump the shader debug information to a file - // The code commented out here below is how it should work, if we have dxil shaders at some point - // Handler for shader debug information callbacks (called by ShaderDebugInfoCallback) - void GpuCrashTracker::OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize) - { - // Get shader debug information identifier. - GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {}; - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GetShaderDebugInfoIdentifier( GFSDK_Aftermath_Version_API, pShaderDebugInfo, shaderDebugInfoSize, &identifier ) ); +// This function should be used to dump the shader debug information to a file +// The code commented out here below is how it should work, if we have dxil shaders at some point +// Handler for shader debug information callbacks (called by ShaderDebugInfoCallback) +void GpuCrashTracker::OnShaderDebugInfo( const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize ) +{ + // Get shader debug information identifier. + GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {}; + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GetShaderDebugInfoIdentifier( GFSDK_Aftermath_Version_API, pShaderDebugInfo, shaderDebugInfoSize, &identifier ) ); - // store the debug info for retrieval in the json file - std::vector data((uint8_t*)pShaderDebugInfo, (uint8_t*)pShaderDebugInfo + shaderDebugInfoSize); - m_shaderDebugInfo[identifier].swap(data); - } + // store the debug info for retrieval in the json file + std::vector data( (uint8_t*)pShaderDebugInfo, (uint8_t*)pShaderDebugInfo + shaderDebugInfoSize ); + m_shaderDebugInfo[identifier].swap( data ); +} - // Handler for shader debug information lookup callbacks. - // This is used by the JSON decoder for mapping shader instruction - // addresses to DXIL lines or HLSl source lines.ho - void GpuCrashTracker::OnShaderDebugInfoLookup( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const +// Handler for shader debug information lookup callbacks. +// This is used by the JSON decoder for mapping shader instruction +// addresses to DXIL lines or HLSl source lines.ho +void GpuCrashTracker::OnShaderDebugInfoLookup( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo ) const +{ + // Search the list of shader debug information blobs received earlier. + auto i_debugInfo = m_shaderDebugInfo.find( identifier ); + if( i_debugInfo == m_shaderDebugInfo.end() ) { - // Search the list of shader debug information blobs received earlier. - auto i_debugInfo = m_shaderDebugInfo.find(identifier); - if (i_debugInfo == m_shaderDebugInfo.end()) - { - // Early exit, nothing found. No need to call setShaderDebugInfo. - return; - } - // Let the GPU crash dump decoder know about the shader debug information - // that was found. - // This is very important so we get a call to OnShaderLookup - setShaderDebugInfo(i_debugInfo->second.data(), uint32_t(i_debugInfo->second.size())); + // Early exit, nothing found. No need to call setShaderDebugInfo. + return; } + // Let the GPU crash dump decoder know about the shader debug information + // that was found. + // This is very important so we get a call to OnShaderLookup + setShaderDebugInfo( i_debugInfo->second.data(), uint32_t( i_debugInfo->second.size() ) ); +} - void GpuCrashTracker::OnShaderLookup( const GFSDK_Aftermath_ShaderHash& shaderHash, PFN_GFSDK_Aftermath_SetData ) +void GpuCrashTracker::OnShaderLookup( const GFSDK_Aftermath_ShaderHash& shaderHash, PFN_GFSDK_Aftermath_SetData ) +{ + // store the crashed shader so we can report it! + auto shaderPath = m_shaderHashToPath.find( shaderHash ); + if( shaderPath != m_shaderHashToPath.end() ) { - // store the crashed shader so we can report it! - auto shaderPath = m_shaderHashToPath.find(shaderHash); - if( shaderPath != m_shaderHashToPath.end()) - { - m_offendingShader = shaderPath->second; - } + m_offendingShader = shaderPath->second; } +} - GFSDK_Aftermath_ContextHandle GpuCrashTracker::GetCommandListContextHandle(ID3D12GraphicsCommandList2* commandList) +GFSDK_Aftermath_ContextHandle GpuCrashTracker::GetCommandListContextHandle( ID3D12GraphicsCommandList2* commandList ) +{ + auto results = m_commandListContextMap.find( commandList ); + if( results != m_commandListContextMap.end() ) { - auto results = m_commandListContextMap.find(commandList); - if(results != m_commandListContextMap.end()) - { - return results->second; - } - GFSDK_Aftermath_ContextHandle context = nullptr; - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_DX12_CreateContextHandle( commandList, &context ) ); - - m_commandListContextMap[commandList] = context; - return context; + return results->second; } + GFSDK_Aftermath_ContextHandle context = nullptr; + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_DX12_CreateContextHandle( commandList, &context ) ); - void GpuCrashTracker::UnRegisterCommandList(ID3D12GraphicsCommandList2* commandList) - { - auto results = m_commandListContextMap.find(commandList); - if(results == m_commandListContextMap.end()) - { - return; - } - - m_commandListContextMap.erase(results); - } + m_commandListContextMap[commandList] = context; + return context; +} - void GpuCrashTracker::PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) +void GpuCrashTracker::UnRegisterCommandList( ID3D12GraphicsCommandList2* commandList ) +{ + auto results = m_commandListContextMap.find( commandList ); + if( results == m_commandListContextMap.end() ) { - if( !m_initializedForDevice ) - { - return; - } - auto context = GetCommandListContextHandle(commandList); - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_SetEventMarker( context, (void*)marker, (unsigned int)strlen( marker ) + 1 ) ); + return; } - // Helper for writing a GPU crash dump to a file - void GpuCrashTracker::ResolveCrash( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize ) - { - // Create a GPU crash dump decoder object for the GPU crash dump. - GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {}; - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_CreateDecoder( - GFSDK_Aftermath_Version_API, - pGpuCrashDump, - gpuCrashDumpSize, - &decoder ) ); - - // Decode the crash dump to a JSON string. - // Fake most of this since we don't care about anything except the shader that failed - uint32_t jsonSize = 0; - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_GenerateJSON( - decoder, - GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO, - GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE, - ShaderDebugInfoLookupCallback, // need this so we can actually look up what shader crashed - ShaderLookupCallback, // need this so we can actually look up what shader crashed - nullptr, - nullptr, - this, - &jsonSize ) ); - - // Destroy the GPU crash dump decoder object. - AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_DestroyDecoder( decoder ) ); - } + m_commandListContextMap.erase( results ); +} - // Static callback wrapper for OnCrashDump - void GpuCrashTracker::GpuCrashDumpCallback( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData ) +void GpuCrashTracker::PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) +{ + if( !m_initializedForDevice ) { - auto tracker = reinterpret_cast( pUserData ); - tracker->ResolveCrash( pGpuCrashDump, gpuCrashDumpSize ); + return; } + auto context = GetCommandListContextHandle( commandList ); + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_SetEventMarker( context, (void*)marker, (unsigned int)strlen( marker ) + 1 ) ); +} - void GpuCrashTracker::ShaderDebugInfoCallback( - const void* pShaderDebugInfo, - const uint32_t shaderDebugInfoSize, - void* pUserData) - { - auto pGpuCrashTracker = reinterpret_cast(pUserData); - pGpuCrashTracker->OnShaderDebugInfo(pShaderDebugInfo, shaderDebugInfoSize); - } +// Helper for writing a GPU crash dump to a file +void GpuCrashTracker::ResolveCrash( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize ) +{ + // Create a GPU crash dump decoder object for the GPU crash dump. + GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {}; + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_CreateDecoder( + GFSDK_Aftermath_Version_API, + pGpuCrashDump, + gpuCrashDumpSize, + &decoder ) ); + + // Decode the crash dump to a JSON string. + // Fake most of this since we don't care about anything except the shader that failed + uint32_t jsonSize = 0; + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_GenerateJSON( + decoder, + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO, + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE, + ShaderDebugInfoLookupCallback, // need this so we can actually look up what shader crashed + ShaderLookupCallback, // need this so we can actually look up what shader crashed + nullptr, + nullptr, + this, + &jsonSize ) ); + + // Destroy the GPU crash dump decoder object. + AFTERMATH_CHECK_AND_LOG_ERROR( GFSDK_Aftermath_GpuCrashDump_DestroyDecoder( decoder ) ); +} - void GpuCrashTracker::ShaderDebugInfoLookupCallback( - const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, - PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, - void* pUserData) - { - auto pGpuCrashTracker = reinterpret_cast(pUserData); - pGpuCrashTracker->OnShaderDebugInfoLookup(*pIdentifier, setShaderDebugInfo); - } +// Static callback wrapper for OnCrashDump +void GpuCrashTracker::GpuCrashDumpCallback( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData ) +{ + auto tracker = reinterpret_cast( pUserData ); + tracker->ResolveCrash( pGpuCrashDump, gpuCrashDumpSize ); +} - void GpuCrashTracker::ShaderLookupCallback( - const GFSDK_Aftermath_ShaderHash* pShaderHash, - PFN_GFSDK_Aftermath_SetData setShaderBinary, - void* pUserData) - { - auto pGpuCrashTracker = reinterpret_cast(pUserData); - pGpuCrashTracker->OnShaderLookup(*pShaderHash, setShaderBinary); - } +void GpuCrashTracker::ShaderDebugInfoCallback( + const void* pShaderDebugInfo, + const uint32_t shaderDebugInfoSize, + void* pUserData ) +{ + auto pGpuCrashTracker = reinterpret_cast( pUserData ); + pGpuCrashTracker->OnShaderDebugInfo( pShaderDebugInfo, shaderDebugInfoSize ); +} + +void GpuCrashTracker::ShaderDebugInfoLookupCallback( + const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, + PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, + void* pUserData ) +{ + auto pGpuCrashTracker = reinterpret_cast( pUserData ); + pGpuCrashTracker->OnShaderDebugInfoLookup( *pIdentifier, setShaderDebugInfo ); +} + +void GpuCrashTracker::ShaderLookupCallback( + const GFSDK_Aftermath_ShaderHash* pShaderHash, + PFN_GFSDK_Aftermath_SetData setShaderBinary, + void* pUserData ) +{ + auto pGpuCrashTracker = reinterpret_cast( pUserData ); + pGpuCrashTracker->OnShaderLookup( *pShaderHash, setShaderBinary ); +} } diff --git a/trinityal/dx12/util/GpuCrashTracker.h b/trinityal/dx12/util/GpuCrashTracker.h index e728241e3..bec849023 100644 --- a/trinityal/dx12/util/GpuCrashTracker.h +++ b/trinityal/dx12/util/GpuCrashTracker.h @@ -9,21 +9,21 @@ #include "../../include/Tr2ShaderAL.h" // Helper for comparing GFSDK_Aftermath_ShaderHash. -inline bool operator<(const GFSDK_Aftermath_ShaderHash& lhs, const GFSDK_Aftermath_ShaderHash& rhs) +inline bool operator<( const GFSDK_Aftermath_ShaderHash& lhs, const GFSDK_Aftermath_ShaderHash& rhs ) { return lhs.hash < rhs.hash; } // Helper for comparing GFSDK_Aftermath_ShaderInstructionsHash. -inline bool operator<(const GFSDK_Aftermath_ShaderInstructionsHash& lhs, const GFSDK_Aftermath_ShaderInstructionsHash& rhs) +inline bool operator<( const GFSDK_Aftermath_ShaderInstructionsHash& lhs, const GFSDK_Aftermath_ShaderInstructionsHash& rhs ) { return lhs.hash < rhs.hash; } // Helper for comparing GFSDK_Aftermath_ShaderInstructionsHash. -inline bool operator<(const GFSDK_Aftermath_ShaderDebugInfoIdentifier& lhs, const GFSDK_Aftermath_ShaderDebugInfoIdentifier& rhs) +inline bool operator<( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& lhs, const GFSDK_Aftermath_ShaderDebugInfoIdentifier& rhs ) { - if (lhs.id[0] == rhs.id[0]) + if( lhs.id[0] == rhs.id[0] ) { return lhs.id[1] < rhs.id[1]; } @@ -32,51 +32,50 @@ inline bool operator<(const GFSDK_Aftermath_ShaderDebugInfoIdentifier& lhs, cons namespace TrinityALImpl { - class GpuCrashTracker - { - public: - GpuCrashTracker(); - ~GpuCrashTracker(); - - void Initialize( ID3D12Device* device ); - void SetCrashDumpFolder( std::wstring folder); - bool IsValid() const; +class GpuCrashTracker +{ +public: + GpuCrashTracker(); + ~GpuCrashTracker(); - void PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ); + void Initialize( ID3D12Device* device ); + void SetCrashDumpFolder( std::wstring folder ); + bool IsValid() const; - void UnRegisterCommandList(ID3D12GraphicsCommandList2* commandList); - void RegisterShaderBinary(const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath); + void PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ); - void GetOffendingShader(std::string& shaderString) const; - private: + void UnRegisterCommandList( ID3D12GraphicsCommandList2* commandList ); + void RegisterShaderBinary( const Tr2ShaderBytecodeAL& bytecode, const char* shaderPath ); - GFSDK_Aftermath_ContextHandle GetCommandListContextHandle(ID3D12GraphicsCommandList2* commandList); + void GetOffendingShader( std::string& shaderString ) const; - // Callback handlers for GPU crash dumps and related data. - void OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize); - void OnDescription( PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription ); - void OnShaderLookup( const GFSDK_Aftermath_ShaderHash& shaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary); - void OnShaderDebugInfoLookup( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const; +private: + GFSDK_Aftermath_ContextHandle GetCommandListContextHandle( ID3D12GraphicsCommandList2* commandList ); - void ResolveCrash( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize ); + // Callback handlers for GPU crash dumps and related data. + void OnShaderDebugInfo( const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize ); + void OnDescription( PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription ); + void OnShaderLookup( const GFSDK_Aftermath_ShaderHash& shaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary ); + void OnShaderDebugInfoLookup( const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo ) const; - bool m_initialized; - bool m_initializedForDevice; - std::string m_offendingShader; + void ResolveCrash( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize ); - std::map> m_shaderHashToBytecode; - std::map m_shaderInstructionsToShaderHash; - std::map> m_shaderDebugInfo; - std::map m_commandListContextMap; + bool m_initialized; + bool m_initializedForDevice; + std::string m_offendingShader; - std::map m_shaderHashToPath; + std::map> m_shaderHashToBytecode; + std::map m_shaderInstructionsToShaderHash; + std::map> m_shaderDebugInfo; + std::map m_commandListContextMap; - // Static callback wrappers. - static void GpuCrashDumpCallback( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData ); - static void ShaderDebugInfoCallback( const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void* pUserData); - static void ShaderLookupCallback( const GFSDK_Aftermath_ShaderHash* pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData); - static void ShaderDebugInfoLookupCallback( const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void* pUserData); + std::map m_shaderHashToPath; - }; + // Static callback wrappers. + static void GpuCrashDumpCallback( const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData ); + static void ShaderDebugInfoCallback( const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void* pUserData ); + static void ShaderLookupCallback( const GFSDK_Aftermath_ShaderHash* pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData ); + static void ShaderDebugInfoLookupCallback( const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void* pUserData ); +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/util/GpuMarkerBuffer.cpp b/trinityal/dx12/util/GpuMarkerBuffer.cpp index b7f4b318d..c316ebc01 100644 --- a/trinityal/dx12/util/GpuMarkerBuffer.cpp +++ b/trinityal/dx12/util/GpuMarkerBuffer.cpp @@ -8,101 +8,101 @@ namespace TrinityALImpl { - GpuMarkerBuffer::GpuMarkerBuffer() - :m_gpuAddress( 0 ), - m_cpuAddress( nullptr ) - { - } +GpuMarkerBuffer::GpuMarkerBuffer() : + m_gpuAddress( 0 ), + m_cpuAddress( nullptr ) +{ +} - GpuMarkerBuffer::~GpuMarkerBuffer() - { - Destroy(); - } +GpuMarkerBuffer::~GpuMarkerBuffer() +{ + Destroy(); +} - ALResult GpuMarkerBuffer::Create( ID3D12Device* device ) - { - Destroy(); +ALResult GpuMarkerBuffer::Create( ID3D12Device* device ) +{ + Destroy(); - D3D12_FEATURE_DATA_D3D12_OPTIONS3 options; - CR_RETURN_HR( device->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS3, &options, sizeof( options ) ) ); - if( ( options.WriteBufferImmediateSupportFlags & D3D12_COMMAND_LIST_SUPPORT_FLAG_DIRECT ) == 0 ) - { - return E_FAIL; - } + D3D12_FEATURE_DATA_D3D12_OPTIONS3 options; + CR_RETURN_HR( device->CheckFeatureSupport( D3D12_FEATURE_D3D12_OPTIONS3, &options, sizeof( options ) ) ); + if( ( options.WriteBufferImmediateSupportFlags & D3D12_COMMAND_LIST_SUPPORT_FLAG_DIRECT ) == 0 ) + { + return E_FAIL; + } - D3D12_HEAP_PROPERTIES heapProperties = { D3D12_HEAP_TYPE_READBACK }; + D3D12_HEAP_PROPERTIES heapProperties = { D3D12_HEAP_TYPE_READBACK }; - D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER }; - resourceDesc.Width = 256; - resourceDesc.Height = resourceDesc.DepthOrArraySize = resourceDesc.MipLevels = 1; - resourceDesc.SampleDesc.Count = 1; - resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - resourceDesc.Flags = D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; + D3D12_RESOURCE_DESC resourceDesc = { D3D12_RESOURCE_DIMENSION_BUFFER }; + resourceDesc.Width = 256; + resourceDesc.Height = resourceDesc.DepthOrArraySize = resourceDesc.MipLevels = 1; + resourceDesc.SampleDesc.Count = 1; + resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; + resourceDesc.Flags = D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE; - CR_RETURN_HR( device->CreateCommittedResource( - &heapProperties, - D3D12_HEAP_FLAG_NONE, - &resourceDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_PPV_ARGS( &m_buffer ) ) ); - m_buffer->SetName( L"WriteImmedateBuffer" ); - if( FAILED( m_buffer->Map( 0, nullptr, (void**)&m_cpuAddress ) ) ) - { - m_buffer = nullptr; - m_cpuAddress = nullptr; - return E_FAIL; - } - m_gpuAddress = m_buffer->GetGPUVirtualAddress(); - return S_OK; + CR_RETURN_HR( device->CreateCommittedResource( + &heapProperties, + D3D12_HEAP_FLAG_NONE, + &resourceDesc, + D3D12_RESOURCE_STATE_COPY_DEST, + nullptr, + IID_PPV_ARGS( &m_buffer ) ) ); + m_buffer->SetName( L"WriteImmedateBuffer" ); + if( FAILED( m_buffer->Map( 0, nullptr, (void**)&m_cpuAddress ) ) ) + { + m_buffer = nullptr; + m_cpuAddress = nullptr; + return E_FAIL; } + m_gpuAddress = m_buffer->GetGPUVirtualAddress(); + return S_OK; +} - void GpuMarkerBuffer::Destroy() +void GpuMarkerBuffer::Destroy() +{ + if( m_buffer ) { - if( m_buffer ) - { - D3D12_RANGE emptyRange = { 0, 0 }; - m_buffer->Unmap( 0, &emptyRange ); - m_buffer = nullptr; - } - m_gpuAddress = 0; - m_cpuAddress = nullptr; + D3D12_RANGE emptyRange = { 0, 0 }; + m_buffer->Unmap( 0, &emptyRange ); + m_buffer = nullptr; } + m_gpuAddress = 0; + m_cpuAddress = nullptr; +} - void GpuMarkerBuffer::PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) const +void GpuMarkerBuffer::PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) const +{ + if( commandList && m_buffer ) { - if( commandList && m_buffer ) + auto length = std::min( strlen( marker ) + 1, size_t( 256 ) ); + D3D12_WRITEBUFFERIMMEDIATE_PARAMETER params[256 / 4]; + D3D12_WRITEBUFFERIMMEDIATE_MODE modes[256 / 4]; + auto addr = m_gpuAddress; + uint32_t count = 0; + for( size_t i = 0; i < 256 / 4 && length > 0; ++i ) { - auto length = std::min( strlen( marker ) + 1, size_t( 256 ) ); - D3D12_WRITEBUFFERIMMEDIATE_PARAMETER params[256 / 4]; - D3D12_WRITEBUFFERIMMEDIATE_MODE modes[256 / 4]; - auto addr = m_gpuAddress; - uint32_t count = 0; - for( size_t i = 0; i < 256 / 4 && length > 0; ++i ) - { - params[i].Value = 0; - params[i].Dest = addr; - addr += 4; - auto l = std::min( length, sizeof( params[i].Value ) ); - memcpy( ¶ms[i].Value, marker, l ); - marker += l; - length -= l; - modes[i] = D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT; - ++count; - } - commandList->WriteBufferImmediate( count, params, modes ); + params[i].Value = 0; + params[i].Dest = addr; + addr += 4; + auto l = std::min( length, sizeof( params[i].Value ) ); + memcpy( ¶ms[i].Value, marker, l ); + marker += l; + length -= l; + modes[i] = D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT; + ++count; } + commandList->WriteBufferImmediate( count, params, modes ); } - ALResult GpuMarkerBuffer::GetMarker( std::string& marker ) const +} +ALResult GpuMarkerBuffer::GetMarker( std::string& marker ) const +{ + if( m_buffer ) { - if( m_buffer ) - { - marker = std::string( static_cast( m_cpuAddress )); - return S_OK; - } - - return E_FAIL; + marker = std::string( static_cast( m_cpuAddress ) ); + return S_OK; } + + return E_FAIL; +} } #endif \ No newline at end of file diff --git a/trinityal/dx12/util/GpuMarkerBuffer.h b/trinityal/dx12/util/GpuMarkerBuffer.h index 7b3f5676c..dc915df80 100644 --- a/trinityal/dx12/util/GpuMarkerBuffer.h +++ b/trinityal/dx12/util/GpuMarkerBuffer.h @@ -9,22 +9,23 @@ namespace TrinityALImpl { - class GpuMarkerBuffer - { - public: - GpuMarkerBuffer(); - ~GpuMarkerBuffer(); - - ALResult Create( ID3D12Device* device ); - void Destroy(); - - void PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) const; - ALResult GetMarker( std::string& marker ) const; - private: - CComPtr m_buffer; - D3D12_GPU_VIRTUAL_ADDRESS m_gpuAddress; - const void* m_cpuAddress; - }; +class GpuMarkerBuffer +{ +public: + GpuMarkerBuffer(); + ~GpuMarkerBuffer(); + + ALResult Create( ID3D12Device* device ); + void Destroy(); + + void PutMarker( ID3D12GraphicsCommandList2* commandList, const char* marker ) const; + ALResult GetMarker( std::string& marker ) const; + +private: + CComPtr m_buffer; + D3D12_GPU_VIRTUAL_ADDRESS m_gpuAddress; + const void* m_cpuAddress; +}; } #endif \ No newline at end of file diff --git a/trinityal/dx12/util/PsoDescription.cpp b/trinityal/dx12/util/PsoDescription.cpp index ae551b17a..8d6306e80 100644 --- a/trinityal/dx12/util/PsoDescription.cpp +++ b/trinityal/dx12/util/PsoDescription.cpp @@ -10,148 +10,145 @@ namespace { - const D3D12_RASTERIZER_DESC s_defaultRasterizer = - { - D3D12_FILL_MODE_SOLID, - D3D12_CULL_MODE_BACK, - false, - 0, - 0, - 0, - true, - false, - false, - 0, - D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF - }; - - const D3D12_DEPTH_STENCILOP_DESC s_defaultStencilOp = - { - D3D12_STENCIL_OP_KEEP, - D3D12_STENCIL_OP_KEEP, - D3D12_STENCIL_OP_KEEP, - D3D12_COMPARISON_FUNC_ALWAYS - }; - - const D3D12_DEPTH_STENCIL_DESC s_defaultDepthStencil = - { - true, - D3D12_DEPTH_WRITE_MASK_ALL, - D3D12_COMPARISON_FUNC_LESS, - false, - D3D12_DEFAULT_STENCIL_READ_MASK, - D3D12_DEFAULT_STENCIL_WRITE_MASK, - s_defaultStencilOp, - s_defaultStencilOp - }; - - D3D12_BLEND_DESC s_defaultBlend = { - false, - false, - { false, false, D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, D3D12_LOGIC_OP_NOOP, D3D12_COLOR_WRITE_ENABLE_ALL } - }; +const D3D12_RASTERIZER_DESC s_defaultRasterizer = { + D3D12_FILL_MODE_SOLID, + D3D12_CULL_MODE_BACK, + false, + 0, + 0, + 0, + true, + false, + false, + 0, + D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF +}; + +const D3D12_DEPTH_STENCILOP_DESC s_defaultStencilOp = { + D3D12_STENCIL_OP_KEEP, + D3D12_STENCIL_OP_KEEP, + D3D12_STENCIL_OP_KEEP, + D3D12_COMPARISON_FUNC_ALWAYS +}; + +const D3D12_DEPTH_STENCIL_DESC s_defaultDepthStencil = { + true, + D3D12_DEPTH_WRITE_MASK_ALL, + D3D12_COMPARISON_FUNC_LESS, + false, + D3D12_DEFAULT_STENCIL_READ_MASK, + D3D12_DEFAULT_STENCIL_WRITE_MASK, + s_defaultStencilOp, + s_defaultStencilOp +}; + +D3D12_BLEND_DESC s_defaultBlend = { + false, + false, + { false, false, D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, D3D12_LOGIC_OP_NOOP, D3D12_COLOR_WRITE_ENABLE_ALL } +}; } namespace TrinityALImpl { - PSODescription::PSODescription() - :m_topologyType( D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED ), - m_blendDesc( s_defaultBlend ), - m_rasterizerDesc( s_defaultRasterizer ), - m_depthStencilDesc( s_defaultDepthStencil ), - m_renderTargetCount( 0 ), - m_depthStencilFormat( Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ), - m_vertexStreamMask( 0 ) - { - std::fill( std::begin( m_renderTargetFormats ), std::end( m_renderTargetFormats ), Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ); - UpdateHash(); - } +PSODescription::PSODescription() : + m_topologyType( D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED ), + m_blendDesc( s_defaultBlend ), + m_rasterizerDesc( s_defaultRasterizer ), + m_depthStencilDesc( s_defaultDepthStencil ), + m_renderTargetCount( 0 ), + m_depthStencilFormat( Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ), + m_vertexStreamMask( 0 ) +{ + std::fill( std::begin( m_renderTargetFormats ), std::end( m_renderTargetFormats ), Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ); + UpdateHash(); +} - bool PSODescription::operator==( const PSODescription& other ) const - { - return m_vertexLayout == other.m_vertexLayout && m_shaderProgram == other.m_shaderProgram && memcmp( GetHashableBlock(), other.GetHashableBlock(), GetHashableBlockSize() ) == 0; - } +bool PSODescription::operator==( const PSODescription& other ) const +{ + return m_vertexLayout == other.m_vertexLayout && m_shaderProgram == other.m_shaderProgram && memcmp( GetHashableBlock(), other.GetHashableBlock(), GetHashableBlockSize() ) == 0; +} + +PSODescription::operator size_t() const +{ + return m_hash; +} - PSODescription::operator size_t() const +ALResult PSODescription::CreatePipelineState( ID3D12Device* device, CComPtr& pipelineState ) const +{ + if( m_shaderProgram.m_program->IsComputeProgramDx12() ) { - return m_hash; - } + D3D12_COMPUTE_PIPELINE_STATE_DESC desc; + memset( &desc, 0, sizeof( desc ) ); + desc.pRootSignature = m_shaderProgram.m_program->m_rootSignature.m_rootSignature; + desc.CS = m_shaderProgram.m_program->m_CS; - ALResult PSODescription::CreatePipelineState( ID3D12Device* device, CComPtr& pipelineState ) const + return device->CreateComputePipelineState( &desc, IID_PPV_ARGS( &pipelineState ) ); + } + else { - if( m_shaderProgram.m_program->IsComputeProgramDx12() ) + D3D12_GRAPHICS_PIPELINE_STATE_DESC desc; + memset( &desc, 0, sizeof( desc ) ); + + if( m_shaderProgram.IsValid() ) { - D3D12_COMPUTE_PIPELINE_STATE_DESC desc; - memset( &desc, 0, sizeof( desc ) ); desc.pRootSignature = m_shaderProgram.m_program->m_rootSignature.m_rootSignature; - desc.CS = m_shaderProgram.m_program->m_CS; - - return device->CreateComputePipelineState( &desc, IID_PPV_ARGS( &pipelineState ) ); + desc.VS = m_shaderProgram.m_program->m_VS; + desc.PS = m_shaderProgram.m_program->m_PS; + desc.DS = m_shaderProgram.m_program->m_DS; + desc.HS = m_shaderProgram.m_program->m_HS; + desc.GS = m_shaderProgram.m_program->m_GS; } - else + desc.RasterizerState = m_rasterizerDesc; + desc.DepthStencilState = m_depthStencilDesc; + desc.BlendState = m_blendDesc; + desc.SampleMask = 0xff; + desc.SampleDesc.Count = 1; + + std::vector layout; + if( !m_vertexLayout.m_layout->m_elements.empty() ) { - D3D12_GRAPHICS_PIPELINE_STATE_DESC desc; - memset( &desc, 0, sizeof( desc ) ); - - if( m_shaderProgram.IsValid() ) + m_vertexLayout.m_layout->PopulateInputLayout( layout, m_shaderProgram.m_program->m_iaInputs ); + if( !layout.empty() ) { - desc.pRootSignature = m_shaderProgram.m_program->m_rootSignature.m_rootSignature; - desc.VS = m_shaderProgram.m_program->m_VS; - desc.PS = m_shaderProgram.m_program->m_PS; - desc.DS = m_shaderProgram.m_program->m_DS; - desc.HS = m_shaderProgram.m_program->m_HS; - desc.GS = m_shaderProgram.m_program->m_GS; + desc.InputLayout.NumElements = UINT( layout.size() ); + desc.InputLayout.pInputElementDescs = &layout[0]; } - desc.RasterizerState = m_rasterizerDesc; - desc.DepthStencilState = m_depthStencilDesc; - desc.BlendState = m_blendDesc; - desc.SampleMask = 0xff; - desc.SampleDesc.Count = 1; - - std::vector layout; - if( !m_vertexLayout.m_layout->m_elements.empty() ) - { - m_vertexLayout.m_layout->PopulateInputLayout( layout, m_shaderProgram.m_program->m_iaInputs ); - if( !layout.empty() ) - { - desc.InputLayout.NumElements = UINT( layout.size() ); - desc.InputLayout.pInputElementDescs = &layout[0]; - } - } - desc.PrimitiveTopologyType = m_topologyType; + } + desc.PrimitiveTopologyType = m_topologyType; - desc.NumRenderTargets = m_renderTargetCount; - memcpy( desc.RTVFormats, m_renderTargetFormats, sizeof( desc.RTVFormats ) ); + desc.NumRenderTargets = m_renderTargetCount; + memcpy( desc.RTVFormats, m_renderTargetFormats, sizeof( desc.RTVFormats ) ); - // fill the rest with unknowns - std::fill( std::begin(desc.RTVFormats) + m_renderTargetCount, std::end(desc.RTVFormats), (DXGI_FORMAT)Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ); + // fill the rest with unknowns + std::fill( std::begin( desc.RTVFormats ) + m_renderTargetCount, std::end( desc.RTVFormats ), (DXGI_FORMAT)Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ); - desc.DSVFormat = DXGI_FORMAT( m_depthStencilFormat ); - desc.SampleDesc.Count = m_sampleDesc.samples; - desc.SampleDesc.Quality = m_sampleDesc.quality; + desc.DSVFormat = DXGI_FORMAT( m_depthStencilFormat ); + desc.SampleDesc.Count = m_sampleDesc.samples; + desc.SampleDesc.Quality = m_sampleDesc.quality; - return device->CreateGraphicsPipelineState( &desc, IID_PPV_ARGS( &pipelineState ) ); - } + return device->CreateGraphicsPipelineState( &desc, IID_PPV_ARGS( &pipelineState ) ); } +} - void PSODescription::UpdateHash() - { - m_hash = CcpHashFNV1( GetHashableBlock(), GetHashableBlockSize() ); - const void* ptrs[2] = { m_shaderProgram.m_program.get(), m_vertexLayout.m_layout.get() }; - m_hash = CcpHashFNV1( ptrs, sizeof( ptrs ), unsigned( m_hash ) ); - } +void PSODescription::UpdateHash() +{ + m_hash = CcpHashFNV1( GetHashableBlock(), GetHashableBlockSize() ); + const void* ptrs[2] = { m_shaderProgram.m_program.get(), m_vertexLayout.m_layout.get() }; + m_hash = CcpHashFNV1( ptrs, sizeof( ptrs ), unsigned( m_hash ) ); +} - size_t PSODescription::GetHashableBlockSize() const - { - return reinterpret_cast( &m_sampleDesc ) - reinterpret_cast( &m_topologyType ) + sizeof( m_sampleDesc ); - } +size_t PSODescription::GetHashableBlockSize() const +{ + return reinterpret_cast( &m_sampleDesc ) - reinterpret_cast( &m_topologyType ) + sizeof( m_sampleDesc ); +} - const void* PSODescription::GetHashableBlock() const - { - return &m_topologyType; - } +const void* PSODescription::GetHashableBlock() const +{ + return &m_topologyType; +} } diff --git a/trinityal/dx12/util/PsoDescription.h b/trinityal/dx12/util/PsoDescription.h index 9a41d8336..1bf366585 100644 --- a/trinityal/dx12/util/PsoDescription.h +++ b/trinityal/dx12/util/PsoDescription.h @@ -11,48 +11,51 @@ namespace TrinityALImpl { - class PSODescription - { - public: - PSODescription(); +class PSODescription +{ +public: + PSODescription(); + + bool operator==( const PSODescription& other ) const; + operator size_t() const; - bool operator==( const PSODescription& other ) const; - operator size_t() const; + ALResult CreatePipelineState( ID3D12Device* device, CComPtr& pipelineState ) const; + void UpdateHash(); - ALResult CreatePipelineState( ID3D12Device* device, CComPtr& pipelineState ) const; - void UpdateHash(); + ::Tr2VertexLayoutAL m_vertexLayout; + ::Tr2ShaderProgramAL m_shaderProgram; - ::Tr2VertexLayoutAL m_vertexLayout; - ::Tr2ShaderProgramAL m_shaderProgram; + D3D12_PRIMITIVE_TOPOLOGY_TYPE m_topologyType; + D3D12_BLEND_DESC m_blendDesc; + D3D12_RASTERIZER_DESC m_rasterizerDesc; + D3D12_DEPTH_STENCIL_DESC m_depthStencilDesc; + uint32_t m_renderTargetCount; + Tr2RenderContextEnum::PixelFormat m_renderTargetFormats[8]; + Tr2RenderContextEnum::PixelFormat m_depthStencilFormat; + Tr2MsaaDesc m_sampleDesc; - D3D12_PRIMITIVE_TOPOLOGY_TYPE m_topologyType; - D3D12_BLEND_DESC m_blendDesc; - D3D12_RASTERIZER_DESC m_rasterizerDesc; - D3D12_DEPTH_STENCIL_DESC m_depthStencilDesc; - uint32_t m_renderTargetCount; - Tr2RenderContextEnum::PixelFormat m_renderTargetFormats[8]; - Tr2RenderContextEnum::PixelFormat m_depthStencilFormat; - Tr2MsaaDesc m_sampleDesc; + uint32_t m_vertexStreamMask; - uint32_t m_vertexStreamMask; +private: + size_t m_hash; - private: - size_t m_hash; - private: - size_t GetHashableBlockSize() const; - const void* GetHashableBlock() const; - }; +private: + size_t GetHashableBlockSize() const; + const void* GetHashableBlock() const; +}; } -namespace std { - template<> struct hash +namespace std +{ +template <> +struct hash +{ + size_t operator()( const TrinityALImpl::PSODescription& p ) const { - size_t operator()( const TrinityALImpl::PSODescription& p ) const - { - return p; - } - }; + return p; + } +}; } diff --git a/trinityal/include/Tr2BufferAL.h b/trinityal/include/Tr2BufferAL.h index adf268591..588251b81 100644 --- a/trinityal/include/Tr2BufferAL.h +++ b/trinityal/include/Tr2BufferAL.h @@ -11,8 +11,8 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2BufferAL; - class Tr2ResourceSetAL; +class Tr2BufferAL; +class Tr2ResourceSetAL; } @@ -73,12 +73,14 @@ class Tr2BufferAL bool operator==( const Tr2BufferAL& other ) const; - template ALResult MapForReading( const T*& data, Tr2RenderContextAL& renderContext ) const; + template + ALResult MapForReading( const T*& data, Tr2RenderContextAL& renderContext ) const; ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) const; ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) const; void UnmapForReading( Tr2RenderContextAL& renderContext ) const; - template ALResult MapForWriting( T*& data, Tr2RenderContextAL& renderContext ); + template + ALResult MapForWriting( T*& data, Tr2RenderContextAL& renderContext ); ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); void UnmapForWriting( Tr2RenderContextAL& renderContext ); diff --git a/trinityal/include/Tr2ConstantBufferAL.h b/trinityal/include/Tr2ConstantBufferAL.h index a241e2717..5d9537bb0 100644 --- a/trinityal/include/Tr2ConstantBufferAL.h +++ b/trinityal/include/Tr2ConstantBufferAL.h @@ -10,17 +10,17 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2ConstantBufferAL; +class Tr2ConstantBufferAL; } namespace Tr2ConstantUsageAL { - enum Type - { - IMMUTABLE, - ONE_SHOT, - REUSABLE, - }; +enum Type +{ + IMMUTABLE, + ONE_SHOT, + REUSABLE, +}; } class Tr2ConstantBufferAL @@ -29,11 +29,11 @@ class Tr2ConstantBufferAL Tr2ConstantBufferAL(); - ALResult Create( uint32_t size, Tr2PrimaryRenderContextAL & renderContext ); - ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL & renderContext ); + ALResult Create( uint32_t size, Tr2PrimaryRenderContextAL& renderContext ); + ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Lock( void** data, Tr2RenderContextAL & renderContext ); - ALResult Unlock( Tr2RenderContextAL & renderContext ); + ALResult Lock( void** data, Tr2RenderContextAL& renderContext ); + ALResult Unlock( Tr2RenderContextAL& renderContext ); bool IsValid() const; uint32_t GetSize() const; diff --git a/trinityal/include/Tr2FenceAL.h b/trinityal/include/Tr2FenceAL.h index 4f104e93d..e2995a5df 100644 --- a/trinityal/include/Tr2FenceAL.h +++ b/trinityal/include/Tr2FenceAL.h @@ -10,7 +10,7 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2FenceAL; +class Tr2FenceAL; } class Tr2FenceAL diff --git a/trinityal/include/Tr2GpuTimerAL.h b/trinityal/include/Tr2GpuTimerAL.h index 85f124339..ba27138f6 100644 --- a/trinityal/include/Tr2GpuTimerAL.h +++ b/trinityal/include/Tr2GpuTimerAL.h @@ -7,7 +7,7 @@ namespace TrinityALImpl { - class Tr2GpuTimerAL; +class Tr2GpuTimerAL; } class Tr2PrimaryRenderContextAL; diff --git a/trinityal/include/Tr2OcclusionQueryAL.h b/trinityal/include/Tr2OcclusionQueryAL.h index 512072647..5915457ae 100644 --- a/trinityal/include/Tr2OcclusionQueryAL.h +++ b/trinityal/include/Tr2OcclusionQueryAL.h @@ -10,7 +10,7 @@ class Tr2RenderContextAL; namespace TrinityALImpl { - class Tr2OcclusionQueryAL; +class Tr2OcclusionQueryAL; } diff --git a/trinityal/include/Tr2RenderContextAL.h b/trinityal/include/Tr2RenderContextAL.h index 051c24f36..db6fdbfa3 100644 --- a/trinityal/include/Tr2RenderContextAL.h +++ b/trinityal/include/Tr2RenderContextAL.h @@ -7,8 +7,8 @@ class Tr2GpuRegion { public: - Tr2GpuRegion( Tr2RenderContextAL& renderContext, const char* name ) - :m_renderContext( renderContext ) + Tr2GpuRegion( Tr2RenderContextAL& renderContext, const char* name ) : + m_renderContext( renderContext ) { m_renderContext.PushGpuMarker( name ); } @@ -16,6 +16,7 @@ class Tr2GpuRegion { m_renderContext.PopGpuMarker(); } + private: Tr2RenderContextAL& m_renderContext; }; diff --git a/trinityal/include/Tr2ResourceSetAL.h b/trinityal/include/Tr2ResourceSetAL.h index 5cb545123..261f9c02c 100644 --- a/trinityal/include/Tr2ResourceSetAL.h +++ b/trinityal/include/Tr2ResourceSetAL.h @@ -16,8 +16,8 @@ struct Tr2ShaderSignatureAL; namespace TrinityALImpl { - class Tr2ResourceSetAL; - class Tr2RtShaderTableAL; +class Tr2ResourceSetAL; +class Tr2RtShaderTableAL; } struct Tr2RegisterMapAL @@ -63,10 +63,11 @@ class Tr2ResourceSetDescriptionAL bool SetSamplerHeapView( Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex ); bool SetSampler( Tr2RenderContextEnum::ShaderType stage, uint32_t registerIndex, const Tr2SamplerStateAL& sampler ); void ClearResources(); - + uint32_t ComputeHash() const; bool operator==( const Tr2ResourceSetDescriptionAL& other ) const; + private: struct Resource { diff --git a/trinityal/include/Tr2RtBottomLevelAccelerationStructureAL.h b/trinityal/include/Tr2RtBottomLevelAccelerationStructureAL.h index ff3b104ac..cfc750c69 100644 --- a/trinityal/include/Tr2RtBottomLevelAccelerationStructureAL.h +++ b/trinityal/include/Tr2RtBottomLevelAccelerationStructureAL.h @@ -10,62 +10,62 @@ class Tr2PrimaryRenderContextAL; namespace TrinityALImpl { - class Tr2RtBottomLevelAccelerationStructureAL; +class Tr2RtBottomLevelAccelerationStructureAL; } namespace Tr2RtBlasGeometryFlags { - enum Type - { - NONE, - OPAQUE_GEOMETRY, - }; - - inline Type operator|( Type a, Type b ) - { - return Type( int( a ) | int( b ) ); - } - - inline Type& operator|=( Type& a, Type b ) - { - a = Type( a | b ); - return a; - } - - inline bool HasFlag( Type value, Type flag ) - { - return (value & flag) == flag; - } +enum Type +{ + NONE, + OPAQUE_GEOMETRY, +}; + +inline Type operator|( Type a, Type b ) +{ + return Type( int( a ) | int( b ) ); +} + +inline Type& operator|=( Type& a, Type b ) +{ + a = Type( a | b ); + return a; +} + +inline bool HasFlag( Type value, Type flag ) +{ + return ( value & flag ) == flag; +} } namespace Tr2RtBuildFlags { - enum Type - { - NONE = 0, - ALLOW_UPDATE = 0x1, - ALLOW_COMPACTION = 0x2, - PREFER_FAST_TRACE = 0x4, - PREFER_FAST_BUILD = 0x8, - MINIMIZE_MEMORY = 0x10, - PERFORM_UPDATE = 0x20 - }; - - inline Type operator|( Type a, Type b ) - { - return Type( int( a ) | int( b ) ); - } - - inline Type& operator|=( Type& a, Type b ) - { - a = Type( a | b ); - return a; - } - - inline bool HasFlag( Type value, Type flag ) - { - return (value & flag) == flag; - } +enum Type +{ + NONE = 0, + ALLOW_UPDATE = 0x1, + ALLOW_COMPACTION = 0x2, + PREFER_FAST_TRACE = 0x4, + PREFER_FAST_BUILD = 0x8, + MINIMIZE_MEMORY = 0x10, + PERFORM_UPDATE = 0x20 +}; + +inline Type operator|( Type a, Type b ) +{ + return Type( int( a ) | int( b ) ); +} + +inline Type& operator|=( Type& a, Type b ) +{ + a = Type( a | b ); + return a; +} + +inline bool HasFlag( Type value, Type flag ) +{ + return ( value & flag ) == flag; +} } struct Tr2RtPositionStreamAL @@ -119,6 +119,7 @@ class Tr2RtBottomLevelAccelerationStructureAL ALResult CompactBlas( Tr2PrimaryRenderContextAL& renderContext ); TrinityALImpl::Tr2RtBottomLevelAccelerationStructureAL* TrinityALImpl_GetObject() const; + private: std::shared_ptr m_blas; }; \ No newline at end of file diff --git a/trinityal/include/Tr2RtPipelineStateAL.h b/trinityal/include/Tr2RtPipelineStateAL.h index d00c6db44..8e2433b76 100644 --- a/trinityal/include/Tr2RtPipelineStateAL.h +++ b/trinityal/include/Tr2RtPipelineStateAL.h @@ -9,15 +9,15 @@ namespace TrinityALImpl { - class Tr2RtPipelineStateAL; +class Tr2RtPipelineStateAL; } class Tr2RtPipelineStateDescriptionAL { public: ~Tr2RtPipelineStateDescriptionAL(); - - void AddShader( Tr2ShaderAL& shader, const wchar_t* exportName, const wchar_t* name, Tr2ShaderProgramAL shaderProgram ); + + void AddShader( Tr2ShaderAL& shader, const wchar_t* exportName, const wchar_t* name, Tr2ShaderProgramAL shaderProgram ); void AddShader( const wchar_t* exportName, const Tr2ShaderBytecodeAL& bytecode, const wchar_t* name, uint32_t payloadSize ); void AddShaders( size_t count, const wchar_t** exportNames, const Tr2ShaderBytecodeAL& bytecode, const wchar_t** names, uint32_t payloadSize ); void AddShaders( size_t count, const wchar_t** exportNames, const Tr2ShaderBytecodeAL& bytecode, const wchar_t** names, uint32_t payloadSize, const Tr2ShaderSignatureAL& signature ); @@ -25,7 +25,7 @@ class Tr2RtPipelineStateDescriptionAL void AddHitGroup( const wchar_t* exportName, const wchar_t* anyHit, const wchar_t* closestHit, const wchar_t* intersection, const Tr2ShaderSignatureAL& signature ); void AddGlobalSignature( const Tr2ShaderSignatureAL& signature ); uint32_t AddLocalSignature( const Tr2ShaderSignatureAL& signature ); - + private: static const uint32_t NO_SIGNATURE = 0xffffffff; @@ -36,7 +36,7 @@ class Tr2RtPipelineStateDescriptionAL }; struct Shader { - ~Shader(); + ~Shader(); std::vector names; Tr2ShaderBytecodeAL bytecode; uint32_t payloadSize; @@ -68,9 +68,9 @@ class Tr2RtPipelineStateAL bool IsValid() const; TrinityALImpl::Tr2RtPipelineStateAL* TrinityALImpl_GetObject() const; - + private: - std::shared_ptr m_pipeline; - - friend class TrinityALImpl::Tr2ResourceSetAL; + std::shared_ptr m_pipeline; + + friend class TrinityALImpl::Tr2ResourceSetAL; }; diff --git a/trinityal/include/Tr2RtShaderTableAL.h b/trinityal/include/Tr2RtShaderTableAL.h index 2558770ab..ba91f784b 100644 --- a/trinityal/include/Tr2RtShaderTableAL.h +++ b/trinityal/include/Tr2RtShaderTableAL.h @@ -10,7 +10,7 @@ namespace TrinityALImpl { - class Tr2RtShaderTableAL; +class Tr2RtShaderTableAL; } class Tr2PrimaryRenderContextAL; @@ -22,6 +22,7 @@ class Tr2RtLocalMaterialDescriptionAL public: // Stores a raw pointer to the constant buffer, make sure that it lives as long as the shader table Tr2RtLocalMaterialDescriptionAL& SetConstants( uint32_t registerIndex, const Tr2ConstantBufferAL& buffer ); + private: const Tr2ConstantBufferAL* m_constants[8] = {}; @@ -40,6 +41,7 @@ class Tr2RtShaderTableDescriptionAL void AddHitGroup( const wchar_t* name, const Tr2RtLocalMaterialDescriptionAL& material ); void Reserve( size_t hitGroupCount ); + private: struct ShaderRecord { @@ -63,6 +65,7 @@ class Tr2RtShaderTableAL bool IsValid() const; TrinityALImpl::Tr2RtShaderTableAL* TrinityALImpl_GetObject() const; + private: std::shared_ptr m_shaderTable; }; diff --git a/trinityal/include/Tr2RtTopLevelAccelerationStructureAL.h b/trinityal/include/Tr2RtTopLevelAccelerationStructureAL.h index 38d74e721..879318162 100644 --- a/trinityal/include/Tr2RtTopLevelAccelerationStructureAL.h +++ b/trinityal/include/Tr2RtTopLevelAccelerationStructureAL.h @@ -6,7 +6,7 @@ namespace TrinityALImpl { - class Tr2RtTopLevelAccelerationStructureAL; +class Tr2RtTopLevelAccelerationStructureAL; } // The TLAS references the bottom level structures, with each reference containing local-to-world transformation matrix @@ -37,6 +37,7 @@ class Tr2RtTopLevelAccelerationStructureAL const Tr2BufferAL& GetBuffer() const; size_t GetCapacity() const; TrinityALImpl::Tr2RtTopLevelAccelerationStructureAL* TrinityALImpl_GetObject() const; + private: std::shared_ptr m_tlas; }; diff --git a/trinityal/include/Tr2SamplerStateAL.h b/trinityal/include/Tr2SamplerStateAL.h index 7c469a829..583ee5506 100644 --- a/trinityal/include/Tr2SamplerStateAL.h +++ b/trinityal/include/Tr2SamplerStateAL.h @@ -10,15 +10,15 @@ class Tr2PrimaryRenderContextAL; struct Tr2SamplerDescription; namespace TrinityALImpl { - class Tr2SamplerStateAL; - class Tr2ResourceSetAL; +class Tr2SamplerStateAL; +class Tr2ResourceSetAL; } class Tr2SamplerStateAL { public: Tr2SamplerStateAL(); - ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ); + ALResult Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ); uint32_t GetIndexInHeap() const; @@ -40,5 +40,5 @@ class Tr2SamplerStateAL namespace TrinityALImpl { - typedef Tr2ObjectFactory Tr2SamplerStateALFactory; +typedef Tr2ObjectFactory Tr2SamplerStateALFactory; } diff --git a/trinityal/include/Tr2ShaderAL.h b/trinityal/include/Tr2ShaderAL.h index cccabfb8a..95f1d44b2 100644 --- a/trinityal/include/Tr2ShaderAL.h +++ b/trinityal/include/Tr2ShaderAL.h @@ -13,15 +13,15 @@ struct Tr2ShaderBytecodeAL { Tr2ShaderBytecodeAL(); Tr2ShaderBytecodeAL( const void* bytecode, size_t size ); - + template - Tr2ShaderBytecodeAL( const T( &bytecode_ )[Size] ) - :bytecode( bytecode_ ), + Tr2ShaderBytecodeAL( const T ( &bytecode_ )[Size] ) : + bytecode( bytecode_ ), size( Size * sizeof( T ) ) { } - - ~Tr2ShaderBytecodeAL(); + + ~Tr2ShaderBytecodeAL(); const void* bytecode; size_t size; @@ -116,8 +116,14 @@ struct Tr2StaticSamplerAL struct Tr2ShaderThreadGroupSizeAL { - Tr2ShaderThreadGroupSizeAL() : x( 1 ), y( 1 ), z( 1 ) {} - Tr2ShaderThreadGroupSizeAL( uint32_t x, uint32_t y, uint32_t z ) : x( x ), y( y ), z( z ) {} + Tr2ShaderThreadGroupSizeAL() : + x( 1 ), y( 1 ), z( 1 ) + { + } + Tr2ShaderThreadGroupSizeAL( uint32_t x, uint32_t y, uint32_t z ) : + x( x ), y( y ), z( z ) + { + } uint32_t x; uint32_t y; @@ -148,8 +154,8 @@ class Tr2ShaderAL; namespace TrinityALImpl { - class Tr2ShaderAL; - class Tr2ShaderProgramAL; +class Tr2ShaderAL; +class Tr2ShaderProgramAL; } class Tr2PrimaryRenderContextAL; @@ -164,8 +170,7 @@ class Tr2ShaderAL const Tr2ShaderBytecodeAL& bytecode, const Tr2ShaderSignatureAL& signature, const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext - ); + Tr2PrimaryRenderContextAL& renderContext ); bool IsValid() const; @@ -178,7 +183,7 @@ class Tr2ShaderAL ALResult SetName( const char* name ); - TrinityALImpl::Tr2ShaderAL* TrinityALImpl_GetObject() const; + TrinityALImpl::Tr2ShaderAL* TrinityALImpl_GetObject() const; private: Tr2ShaderAL( std::shared_ptr shader ); diff --git a/trinityal/include/Tr2ShaderProgramAL.h b/trinityal/include/Tr2ShaderProgramAL.h index f6dddf61e..a65fd9410 100644 --- a/trinityal/include/Tr2ShaderProgramAL.h +++ b/trinityal/include/Tr2ShaderProgramAL.h @@ -11,9 +11,9 @@ class Tr2PrimaryRenderContextAL; struct Tr2RegisterMapAL; namespace TrinityALImpl { - class Tr2ShaderProgramAL; - class Tr2ResourceSetAL; - class PSODescription; +class Tr2ShaderProgramAL; +class Tr2ResourceSetAL; +class PSODescription; } struct Tr2ConstantBufferRegisterAL diff --git a/trinityal/include/Tr2StreamlineAL.h b/trinityal/include/Tr2StreamlineAL.h index 8d95463f9..aa1779b27 100644 --- a/trinityal/include/Tr2StreamlineAL.h +++ b/trinityal/include/Tr2StreamlineAL.h @@ -10,72 +10,72 @@ #include #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - #include - #include - #include +#include +#include +#include #endif #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - #include - #include "dx12/Tr2VideoAdapterInfoALDx12.h" +#include +#include "dx12/Tr2VideoAdapterInfoALDx12.h" #elif TRINITY_PLATFORM == TRINITY_DIRECTX11 - #include - #include "dx11/Tr2VideoAdapterInfoALDx11.h" +#include +#include "dx11/Tr2VideoAdapterInfoALDx11.h" #endif namespace Tr2StreamlineAL -{ - const char* GetPluginName( sl::Feature feature ); - sl::float4x4 F16AsFloat4x4( const float f[16] ); +{ +const char* GetPluginName( sl::Feature feature ); +sl::float4x4 F16AsFloat4x4( const float f[16] ); - void Tr2StreamlineLog( sl::LogType type, const char* msg ); +void Tr2StreamlineLog( sl::LogType type, const char* msg ); - sl::Result InitializeStreamline( uint32_t appID ); - void ReleaseStreamline( ); +sl::Result InitializeStreamline( uint32_t appID ); +void ReleaseStreamline(); - const char* GetSlResultMessage( sl::Result result ); - +const char* GetSlResultMessage( sl::Result result ); - //Streamline functions - sl::Result SetDevice( void* d3dDevice, uint32_t adapter ); - sl::Result UpgradeInterface( void** nativeInterface ); +//Streamline functions - sl::Result SetFeatureLoaded( sl::Feature feature, bool enable ); +sl::Result SetDevice( void* d3dDevice, uint32_t adapter ); +sl::Result UpgradeInterface( void** nativeInterface ); - sl::Result GetNewFrameToken( sl::FrameToken*& m_frameToken ); +sl::Result SetFeatureLoaded( sl::Feature feature, bool enable ); - sl::Result SetTagsForFrame( Tr2RenderContextAL& renderContext, const sl::FrameToken& frame, const sl::ViewportHandle& viewport, const sl::ResourceTag* tags, uint32_t numTags ); - sl::Result SetConstants( const sl::Constants& values, const sl::FrameToken& frame, const sl::ViewportHandle& viewport ); - sl::Result EvaluateFeature( Tr2RenderContextAL& renderContext, sl::Feature feature, const sl::FrameToken& frame, const sl::BaseStructure** inputs, uint32_t numInputs ); +sl::Result GetNewFrameToken( sl::FrameToken*& m_frameToken ); +sl::Result SetTagsForFrame( Tr2RenderContextAL& renderContext, const sl::FrameToken& frame, const sl::ViewportHandle& viewport, const sl::ResourceTag* tags, uint32_t numTags ); +sl::Result SetConstants( const sl::Constants& values, const sl::FrameToken& frame, const sl::ViewportHandle& viewport ); +sl::Result EvaluateFeature( Tr2RenderContextAL& renderContext, sl::Feature feature, const sl::FrameToken& frame, const sl::BaseStructure** inputs, uint32_t numInputs ); - //Feature functions - sl::Result GetDLSSOptimalSettings( const sl::DLSSOptions& options, sl::DLSSOptimalSettings& settings ); - sl::Result SetDLSSOptions( const sl::ViewportHandle& viewport, const sl::DLSSOptions& options ); +//Feature functions + +sl::Result GetDLSSOptimalSettings( const sl::DLSSOptions& options, sl::DLSSOptimalSettings& settings ); +sl::Result SetDLSSOptions( const sl::ViewportHandle& viewport, const sl::DLSSOptions& options ); + +sl::Result SetNISOptions( const sl::ViewportHandle& viewport, const sl::NISOptions& options ); - sl::Result SetNISOptions( const sl::ViewportHandle& viewport, const sl::NISOptions& options ); - #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - sl::Result SetDLSSGOptions( const sl::ViewportHandle& viewport, const sl::DLSSGOptions& options ); - sl::Result GetDLSSGState( const sl::ViewportHandle& viewport, sl::DLSSGState& state, const sl::DLSSGOptions* options ); +sl::Result SetDLSSGOptions( const sl::ViewportHandle& viewport, const sl::DLSSGOptions& options ); +sl::Result GetDLSSGState( const sl::ViewportHandle& viewport, sl::DLSSGState& state, const sl::DLSSGOptions* options ); - sl::Result SetReflexOptions( const sl::ReflexOptions& options ); +sl::Result SetReflexOptions( const sl::ReflexOptions& options ); - void SetPCLMarker( Tr2RenderContextEnum::FrameEvent& frameEvent, sl::FrameToken* m_frameToken ); +void SetPCLMarker( Tr2RenderContextEnum::FrameEvent& frameEvent, sl::FrameToken* m_frameToken ); #endif - - void FreeResources( sl::Feature feature, const sl::ViewportHandle& viewport ); - bool IsDLSSAvailable(); +void FreeResources( sl::Feature feature, const sl::ViewportHandle& viewport ); + +bool IsDLSSAvailable(); #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - bool IsFrameGenerationAvailable(); +bool IsFrameGenerationAvailable(); #endif diff --git a/trinityal/include/Tr2SwapChainAL.h b/trinityal/include/Tr2SwapChainAL.h index 50b26b7fa..2f6fa5053 100644 --- a/trinityal/include/Tr2SwapChainAL.h +++ b/trinityal/include/Tr2SwapChainAL.h @@ -11,7 +11,7 @@ class Tr2RenderContextAL; class Tr2TextureAL; namespace TrinityALImpl { - class Tr2SwapChainAL; +class Tr2SwapChainAL; } @@ -20,7 +20,7 @@ class Tr2SwapChainAL public: Tr2SwapChainAL(); - ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ); + ALResult Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ); ALResult Present( Tr2RenderContextAL& renderContext ); diff --git a/trinityal/include/Tr2TextureAL.h b/trinityal/include/Tr2TextureAL.h index 91b19db99..67071be97 100644 --- a/trinityal/include/Tr2TextureAL.h +++ b/trinityal/include/Tr2TextureAL.h @@ -8,9 +8,9 @@ namespace TrinityALImpl { - class Tr2TextureAL; - class Tr2ResourceSetAL; - class Tr2SwapChainAL; +class Tr2TextureAL; +class Tr2ResourceSetAL; +class Tr2SwapChainAL; } diff --git a/trinityal/include/Tr2VertexLayoutAL.h b/trinityal/include/Tr2VertexLayoutAL.h index 5c5b56ccf..f1832493a 100644 --- a/trinityal/include/Tr2VertexLayoutAL.h +++ b/trinityal/include/Tr2VertexLayoutAL.h @@ -12,8 +12,8 @@ class Tr2VertexDefinition; namespace TrinityALImpl { - class Tr2VertexLayoutAL; - class PSODescription; +class Tr2VertexLayoutAL; +class PSODescription; } class Tr2VertexLayoutAL diff --git a/trinityal/include/TrinityALForward.h b/trinityal/include/TrinityALForward.h index 6a3e09e14..1fa5dcaec 100644 --- a/trinityal/include/TrinityALForward.h +++ b/trinityal/include/TrinityALForward.h @@ -6,18 +6,18 @@ #define TRINITY_AL_WITH_BLUE_EXPOSURE 1 #endif -#define TRINITY_DIRECTX11 2 -#define TRINITY_STUB 5 -#define TRINITY_DIRECTX12 6 -#define TRINITY_METAL 10 +#define TRINITY_DIRECTX11 2 +#define TRINITY_STUB 5 +#define TRINITY_DIRECTX12 6 +#define TRINITY_METAL 10 #ifndef TRINITY_PLATFORM -# error TRINITY_PLATFORM must be set +#error TRINITY_PLATFORM must be set #endif #ifdef _MSC_VER -#pragma warning(push, 3) +#pragma warning( push, 3 ) #endif #ifdef _WIN32 @@ -42,17 +42,17 @@ #include #ifdef _MSC_VER -#pragma warning(pop) +#pragma warning( pop ) #endif #if TRINITY_PLATFORM != TRINITY_DIRECTX11 && TRINITY_PLATFORM != TRINITY_DIRECTX12 #define TRINITY_PLATFORM_HAS_PRIMARY_CONTEXT 0 -#define Tr2PrimaryRenderContextAL Tr2RenderContextAL +#define Tr2PrimaryRenderContextAL Tr2RenderContextAL #else #define TRINITY_PLATFORM_HAS_PRIMARY_CONTEXT 1 #endif -#if TRINITY_PLATFORM==TRINITY_DIRECTX11 +#if TRINITY_PLATFORM == TRINITY_DIRECTX11 #define TRINITY_PLATFORM_SYMBOL dx11 #define TRINITY_PLATFORM_SYMBOL_SUFFIX Dx11 @@ -61,7 +61,7 @@ #include #include -#elif( TRINITY_PLATFORM==TRINITY_STUB ) +#elif ( TRINITY_PLATFORM == TRINITY_STUB ) #define TRINITY_PLATFORM_SYMBOL stub #define TRINITY_PLATFORM_SYMBOL_SUFFIX Stub @@ -88,5 +88,6 @@ #endif - -#define TRINITY_AL_PLATFORM_INCLUDE( className ) CCP_STRINGIZE(../TRINITY_PLATFORM_SYMBOL/CCP_CONCATENATE(className, TRINITY_PLATFORM_SYMBOL_SUFFIX).h) +// clang-format off +#define TRINITY_AL_PLATFORM_INCLUDE( className ) CCP_STRINGIZE(../TRINITY_PLATFORM_SYMBOL/CCP_CONCATENATE( className, TRINITY_PLATFORM_SYMBOL_SUFFIX ).h ) +// clang-format on \ No newline at end of file diff --git a/trinityal/include/upscaling/Fsr1DX.h b/trinityal/include/upscaling/Fsr1DX.h index 8b719c429..d30b1c26f 100644 --- a/trinityal/include/upscaling/Fsr1DX.h +++ b/trinityal/include/upscaling/Fsr1DX.h @@ -1,1762 +1,1762 @@ // Copyright © 2024 CCP ehf. -0x44, 0x58, 0x42, 0x43, 0x1d, 0xac, 0xc6, 0x0f, 0xe2, 0xa6, 0x66, 0x5e, 0x3d, 0x4f, 0xa5, 0x7b, -0xc6, 0x26, 0x88, 0xaa, 0x01, 0x00, 0x00, 0x00, 0xf4, 0x6d, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x68, 0x02, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, -0x58, 0x6d, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x1c, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0xf0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0x53, 0x43, -0x00, 0x81, 0x00, 0x00, 0xf1, 0x01, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, -0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, -0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, -0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, -0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x49, 0x6e, 0x70, 0x75, -0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, -0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x63, 0x62, 0x00, 0xab, 0xab, 0xeb, 0x00, 0x00, 0x00, -0x04, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x01, 0x00, 0x00, -0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xea, 0x01, 0x00, 0x00, -0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, -0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x30, 0x00, 0x75, 0x69, 0x6e, 0x74, 0x34, -0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x13, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xaf, 0x01, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x31, 0x00, 0x43, -0x6f, 0x6e, 0x73, 0x74, 0x32, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x33, 0x00, 0x4d, 0x69, 0x63, -0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, -0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, -0x31, 0x30, 0x2e, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x53, 0x48, 0x45, 0x58, 0xd8, 0x6a, 0x00, 0x00, -0x50, 0x00, 0x05, 0x00, 0xb6, 0x1a, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, -0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, -0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x9c, 0x18, 0x00, 0x04, 0x00, 0xe0, 0x11, 0x00, -0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x02, 0x32, 0x10, 0x02, 0x00, -0x5f, 0x00, 0x00, 0x02, 0x12, 0x20, 0x02, 0x00, 0x68, 0x00, 0x00, 0x02, 0x16, 0x00, 0x00, 0x00, -0x9b, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x55, 0x00, 0x00, 0x06, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, -0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x0a, 0x82, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x8a, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, -0x23, 0x00, 0x00, 0x0b, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x14, 0x02, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x10, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, -0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0b, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x05, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0b, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x06, 0x04, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, -0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x02, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, -0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x10, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x22, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x56, 0x09, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, -0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, -0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, -0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x96, 0x0f, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x96, 0x05, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x66, 0x0a, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x66, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x12, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0x42, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x66, 0x0b, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, -0xf2, 0xe0, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x56, 0x00, 0x00, 0x05, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x04, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xe6, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x41, 0x00, 0x00, 0x05, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0xe6, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x46, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0xd2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, -0x76, 0x0f, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x26, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x12, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, -0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x16, 0x05, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xc2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x09, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x82, 0x00, 0x00, 0x05, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, -0x55, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, -0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, -0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x0a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x26, 0x0a, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, -0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, -0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x0f, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x96, 0x0f, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, -0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, -0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, -0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, -0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x12, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xa6, 0x06, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x66, 0x0a, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, -0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x14, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x05, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, -0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x0f, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, -0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0xe6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0xd2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x09, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x22, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0xf6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, -0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x56, 0x01, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, -0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, -0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, -0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, -0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x96, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x56, 0x09, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x06, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x09, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x22, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x02, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, -0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0xf8, 0xff, 0xff, 0xff, 0x36, 0x00, 0x00, 0x05, 0xe2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0x12, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, -0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, -0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, -0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, -0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, -0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, -0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, -0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, -0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x16, 0x05, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x16, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, -0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x07, -0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, 0x42, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, -0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, -0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x0a, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0f, -0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x0f, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, -0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, -0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, -0x00, 0x00, 0x80, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x11, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, -0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, -0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, -0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, -0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x06, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x09, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, -0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, -0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, -0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0xa6, 0x05, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, -0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, -0xf6, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, -0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, -0x08, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, -0x06, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, -0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, -0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, -0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, -0x22, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0xa6, 0x0b, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x06, 0x01, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, -0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, -0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, -0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, -0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, -0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, -0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, -0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, -0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, -0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, -0x46, 0x02, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, -0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, -0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, -0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, -0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, -0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, -0x1a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, -0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, -0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, -0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, -0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, -0x29, 0x03, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, -0x81, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x04, 0x00, 0x00, 0x00 \ No newline at end of file +0x44, 0x58, 0x42, 0x43, 0x1d, 0xac, 0xc6, 0x0f, 0xe2, 0xa6, 0x66, 0x5e, 0x3d, 0x4f, 0xa5, 0x7b, + 0xc6, 0x26, 0x88, 0xaa, 0x01, 0x00, 0x00, 0x00, 0xf4, 0x6d, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x68, 0x02, 0x00, 0x00, 0x78, 0x02, 0x00, 0x00, + 0x58, 0x6d, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x1c, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xf0, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x05, 0x53, 0x43, + 0x00, 0x81, 0x00, 0x00, 0xf1, 0x01, 0x00, 0x00, 0x52, 0x44, 0x31, 0x31, 0x3c, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, + 0x74, 0x75, 0x72, 0x65, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x00, 0x49, 0x6e, 0x70, 0x75, + 0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, + 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x63, 0x62, 0x00, 0xab, 0xab, 0xeb, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x01, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xea, 0x01, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x30, 0x00, 0x75, 0x69, 0x6e, 0x74, 0x34, + 0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x13, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xaf, 0x01, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x31, 0x00, 0x43, + 0x6f, 0x6e, 0x73, 0x74, 0x32, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x33, 0x00, 0x4d, 0x69, 0x63, + 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, + 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, + 0x31, 0x30, 0x2e, 0x31, 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x53, 0x48, 0x45, 0x58, 0xd8, 0x6a, 0x00, 0x00, + 0x50, 0x00, 0x05, 0x00, 0xb6, 0x1a, 0x00, 0x00, 0x6a, 0x08, 0x00, 0x01, 0x59, 0x00, 0x00, 0x04, + 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, + 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x9c, 0x18, 0x00, 0x04, 0x00, 0xe0, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x02, 0x32, 0x10, 0x02, 0x00, + 0x5f, 0x00, 0x00, 0x02, 0x12, 0x20, 0x02, 0x00, 0x68, 0x00, 0x00, 0x02, 0x16, 0x00, 0x00, 0x00, + 0x9b, 0x00, 0x00, 0x04, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x06, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x0a, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x20, 0x02, 0x00, + 0x23, 0x00, 0x00, 0x0b, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x14, 0x02, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, + 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0b, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x05, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0b, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x06, 0x04, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, + 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x02, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, + 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x22, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x56, 0x09, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, + 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, + 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, + 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x96, 0x0f, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x96, 0x05, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x66, 0x0a, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x66, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x12, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x42, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x66, 0x0b, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, + 0xf2, 0xe0, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x05, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x04, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x00, 0x05, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xe6, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0xd2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x76, 0x0f, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x26, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x16, 0x05, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xc2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x82, 0x00, 0x00, 0x05, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, + 0x55, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, + 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, + 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x0a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x26, 0x0a, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, + 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, + 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x96, 0x0f, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, + 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, + 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, + 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, + 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x12, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xa6, 0x06, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x66, 0x0a, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, + 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x14, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x05, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, + 0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0x0f, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, + 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x06, 0x04, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xe6, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x46, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0xd2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xf2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x22, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0xf6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, + 0xc2, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x56, 0x01, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0xa6, 0x0e, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, + 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, + 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, + 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x96, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x56, 0x09, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x06, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x09, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x22, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0xf8, 0xff, 0xff, 0xff, 0x36, 0x00, 0x00, 0x05, 0xe2, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x05, 0x12, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, + 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, + 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x16, 0x04, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xc2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xc2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x04, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x56, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, + 0x43, 0x55, 0x15, 0x00, 0xf2, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x22, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x76, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xb6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xf6, 0x07, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x07, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x20, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x80, + 0x81, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, + 0xc2, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x8b, 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x8b, + 0xc2, 0x00, 0x00, 0x80, 0x43, 0x55, 0x15, 0x00, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x74, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xb6, 0x0f, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x16, 0x05, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x16, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x38, 0x20, 0x00, 0x08, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x07, + 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x55, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0xa3, 0x59, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, 0x42, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x09, + 0x12, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x1a, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x02, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x09, + 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80, 0x81, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x82, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0f, + 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0xe1, 0x7a, 0x94, 0xbe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x0f, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0a, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x09, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x82, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x08, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, + 0x84, 0x77, 0x00, 0x00, 0x83, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, + 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x80, 0x3f, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x0b, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x16, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, + 0xc2, 0x00, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x56, 0x05, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x38, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x06, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x09, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x92, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xf6, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0c, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xcd, 0xcc, 0xcc, 0x3e, 0xcd, 0xcc, 0xcc, 0x3e, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x38, 0x00, 0x00, 0x07, + 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0xc2, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x3f, 0x00, 0x00, 0xc8, 0x3f, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xbf, + 0x00, 0x00, 0x10, 0xbf, 0x38, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xc2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xa6, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x05, + 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa6, 0x05, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, + 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, + 0xf6, 0x00, 0x10, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, + 0xf2, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x09, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, + 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x07, + 0x32, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x22, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa6, 0x0b, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x01, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xa6, 0x05, 0x10, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x01, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, 0x62, 0x00, 0x10, 0x00, + 0x01, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xa6, 0x0b, 0x10, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x56, 0x06, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x0a, + 0xf2, 0x00, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, 0xf6, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, + 0x00, 0x00, 0x80, 0x3f, 0x34, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x46, 0x0e, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0xe6, 0x0a, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09, + 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe6, 0x0a, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x05, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, + 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, + 0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x03, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x0b, 0x10, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0xa4, 0x00, 0x00, 0x07, 0xf2, 0xe0, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x94, 0x00, 0x00, 0x00, + 0x29, 0x03, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x81, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00 \ No newline at end of file diff --git a/trinityal/include/upscaling/Fsr1Metal.h b/trinityal/include/upscaling/Fsr1Metal.h index 1e31f34a6..8b20dab37 100644 --- a/trinityal/include/upscaling/Fsr1Metal.h +++ b/trinityal/include/upscaling/Fsr1Metal.h @@ -1,1022 +1,1022 @@ // Copyright © 2024 CCP ehf. -0x4d, 0x54, 0x4c, 0x42, 0x01, 0x80, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xb2, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xb0, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, -0x4e, 0x41, 0x4d, 0x45, 0x07, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x53, 0x00, 0x54, 0x59, 0x50, -0x45, 0x01, 0x00, 0x02, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, 0xff, 0xc3, 0x7b, 0x71, 0xa3, 0xa3, -0x10, 0xa1, 0x68, 0xe1, 0xe0, 0x76, 0x91, 0xea, 0x2b, 0x86, 0xc6, 0x34, 0x64, 0x13, 0x78, 0x04, -0x8a, 0x06, 0xf6, 0xa9, 0x7b, 0x80, 0xec, 0x0e, 0x4e, 0x3f, 0x4f, 0x46, 0x46, 0x54, 0x18, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x02, 0x00, -0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x4d, 0x44, 0x53, 0x5a, 0x08, 0x00, 0xb0, 0x3e, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x55, 0x55, 0x49, 0x44, 0x10, 0x00, 0xa8, 0xbb, -0x4f, 0x33, 0x18, 0xd7, 0x30, 0xac, 0x94, 0x77, 0xc2, 0x6b, 0x4f, 0xaa, 0xac, 0xc3, 0x45, 0x4e, -0x44, 0x54, 0x08, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x08, 0x00, 0x00, 0x00, 0x45, 0x4e, -0x44, 0x54, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x94, 0x3e, -0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, 0x35, 0x14, 0x00, 0x00, 0x03, 0x00, -0x00, 0x00, 0x62, 0x0c, 0x30, 0x24, 0x80, 0x10, 0x05, 0xc8, 0x14, 0x00, 0x00, 0x00, 0x21, 0x0c, -0x00, 0x00, 0xbe, 0x0e, 0x00, 0x00, 0x0b, 0x02, 0x21, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, -0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, -0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x18, 0x45, 0x02, 0x42, 0x92, -0x0b, 0x42, 0xc4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x62, 0x88, 0x48, 0x90, -0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0x04, 0x49, 0x0e, 0x90, 0x11, 0x23, -0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x31, 0x46, 0x06, 0x51, 0x18, -0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x1b, 0xc8, 0x25, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x01, 0x58, -0x03, 0x40, 0x22, 0xc6, 0xe1, 0x1d, 0xe4, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xe8, 0x81, 0x1d, 0xf2, -0xa1, 0x0d, 0xe4, 0xe1, 0x1d, 0xea, 0xc1, 0x1d, 0xc8, 0xa1, 0x1c, 0xc8, 0xa1, 0x0d, 0xc8, 0x21, -0x1d, 0xec, 0x21, 0x1d, 0xc8, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xe2, 0x41, 0x1e, 0xe8, 0xa1, 0x0d, -0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, -0x79, 0x28, 0x07, 0x80, 0x20, 0x87, 0x74, 0x98, 0x87, 0x70, 0x10, 0x07, 0x76, 0x28, 0x87, 0x36, -0xa0, 0x87, 0x70, 0x48, 0x07, 0x76, 0x68, 0x83, 0x71, 0x08, 0x07, 0x76, 0x60, 0x87, 0x79, 0x00, -0xcc, 0x21, 0x1c, 0xd8, 0x61, 0x1e, 0xca, 0x01, 0x20, 0xd8, 0xa1, 0x1c, 0xe6, 0x61, 0x1e, 0xda, -0x00, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x21, 0x1d, 0xe6, 0xa1, 0x1c, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, -0x1d, 0xc2, 0x81, 0x1c, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, -0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, -0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, -0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, -0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, -0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, -0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, -0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, -0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x50, 0x87, 0x7a, 0x68, 0x07, 0x78, 0x68, 0x03, 0x7a, -0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x98, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, -0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xdc, 0x21, 0x1c, 0xdc, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, -0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, -0x70, 0x87, 0x77, 0x68, 0x83, 0x79, 0x48, 0x87, 0x73, 0x70, 0x87, 0x72, 0x20, 0x87, 0x36, 0xd0, -0x87, 0x72, 0x90, 0x87, 0x77, 0x98, 0x87, 0x36, 0x30, 0x07, 0x78, 0x68, 0x83, 0x76, 0x08, 0x07, -0x7a, 0x40, 0x07, 0x80, 0x1e, 0xe4, 0xa1, 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x80, -0x1e, 0xe4, 0x21, 0x1c, 0xe0, 0x01, 0x1e, 0xd2, 0xc1, 0x1d, 0xce, 0xa1, 0x0d, 0xda, 0x21, 0x1c, -0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, 0x98, 0x07, 0x7a, 0x08, 0x87, -0x71, 0x58, 0x87, 0x36, 0x80, 0x07, 0x79, 0x78, 0x07, 0x7a, 0x28, 0x87, 0x71, 0xa0, 0x87, 0x77, -0x90, 0x87, 0x36, 0x10, 0x87, 0x7a, 0x30, 0x07, 0x73, 0x28, 0x07, 0x79, 0x68, 0x83, 0x79, 0x48, -0x07, 0x7d, 0x28, 0x07, 0x00, 0x0f, 0x00, 0xa2, 0x1e, 0xdc, 0x61, 0x1e, 0xc2, 0xc1, 0x1c, 0xca, -0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, -0xa8, 0x87, 0x72, 0x00, 0x88, 0x7a, 0x98, 0x87, 0x72, 0x68, 0x83, 0x79, 0x78, 0x07, 0x73, 0xa0, -0x87, 0x36, 0x30, 0x07, 0x76, 0x78, 0x87, 0x70, 0xa0, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, -0xa1, 0x1c, 0x80, 0x0d, 0x84, 0x20, 0x00, 0xd5, 0x86, 0x65, 0x18, 0x80, 0x04, 0x58, 0x80, 0x2a, -0x48, 0x03, 0x50, 0xd8, 0x20, 0x2e, 0xc4, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x80, 0x44, 0x8c, 0xc3, -0x3b, 0xc8, 0x83, 0x3c, 0x94, 0xc3, 0x38, 0xd0, 0x03, 0x3b, 0xe4, 0x43, 0x1b, 0xc8, 0xc3, 0x3b, -0xd4, 0x83, 0x3b, 0x90, 0x43, 0x39, 0x90, 0x43, 0x1b, 0x90, 0x43, 0x3a, 0xd8, 0x43, 0x3a, 0x90, -0x43, 0x39, 0xb4, 0xc1, 0x3c, 0xc4, 0x83, 0x3c, 0xd0, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, -0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0x41, -0x0e, 0xe9, 0x30, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x6d, 0x40, 0x0f, 0xe1, 0x90, 0x0e, -0xec, 0xd0, 0x06, 0xe3, 0x10, 0x0e, 0xec, 0xc0, 0x0e, 0xf3, 0x00, 0x98, 0x43, 0x38, 0xb0, 0xc3, -0x3c, 0x94, 0x03, 0x40, 0xb0, 0x43, 0x39, 0xcc, 0xc3, 0x3c, 0xb4, 0x01, 0x3c, 0xc8, 0x43, 0x39, -0x8c, 0x43, 0x3a, 0xcc, 0x43, 0x39, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x3b, 0x84, 0x03, 0x39, 0x00, -0xe6, 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x60, 0x0e, 0xf2, -0x10, 0x0e, 0xed, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0xef, 0x90, 0x0e, 0xee, 0x40, 0x0f, 0xe5, 0x20, -0x0f, 0x6d, 0x50, 0x0e, 0xec, 0x90, 0x0e, 0xed, 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, -0x83, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, -0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, -0xb4, 0x81, 0x3b, 0xbc, 0x83, 0x3b, 0xb4, 0x01, 0x3b, 0x94, 0x43, 0x38, 0x98, 0x03, 0x40, 0xb8, -0xc3, 0x3b, 0xb4, 0x41, 0x3a, 0xb8, 0x83, 0x39, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, -0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, -0x0e, 0x6d, 0xa0, 0x0e, 0xf5, 0xd0, 0x0e, 0xf0, 0xd0, 0x06, 0xf4, 0x10, 0x0e, 0xe2, 0xc0, 0x0e, -0xe5, 0x30, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, -0x1b, 0xb8, 0x43, 0x38, 0xb8, 0xc3, 0x3c, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, 0xb4, 0x43, 0x38, -0xd0, 0x03, 0x3a, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, 0x06, -0xf3, 0x90, 0x0e, 0xe7, 0xe0, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0xa0, 0x0f, 0xe5, 0x20, 0x0f, 0xef, -0x30, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, -0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0x01, 0x3d, 0xc8, 0x43, 0x38, 0xc0, -0x03, 0x3c, 0xa4, 0x83, 0x3b, 0x9c, 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, 0x00, 0xf4, -0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, 0x00, -0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, 0x20, 0x0f, 0x6d, 0x20, 0x0e, -0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, -0x1e, 0x00, 0x44, 0x3d, 0xb8, 0xc3, 0x3c, 0x84, 0x83, 0x39, 0x94, 0x43, 0x1b, 0x98, 0x03, 0x3c, -0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, -0xf5, 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xf3, 0xf0, 0x0e, 0xe6, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xec, -0xf0, 0x0e, 0xe1, 0x40, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x1b, 0x92, -0x62, 0x00, 0x16, 0xa0, 0x0a, 0xd2, 0x00, 0x14, 0x36, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0x0f, -0x40, 0x1b, 0x00, 0xd2, 0x06, 0xe2, 0x08, 0x80, 0x65, 0x83, 0x81, 0xfc, 0xff, 0xff, 0xff, 0xff, -0x00, 0x48, 0x00, 0xb5, 0x01, 0x49, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xda, 0x00, 0x90, 0x80, -0x6a, 0x83, 0xa1, 0x04, 0xc0, 0x02, 0x54, 0x1b, 0x8c, 0x45, 0x00, 0x16, 0xa0, 0xda, 0x50, 0x30, -0x43, 0x90, 0x06, 0xa0, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x86, -0x40, 0x18, 0x26, 0x0c, 0x84, 0x50, 0x4c, 0x10, 0x8c, 0x63, 0x42, 0x80, 0x4c, 0x18, 0x12, 0x65, -0x99, 0x10, 0x30, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x22, -0x88, 0x09, 0x20, 0x64, 0x85, 0x04, 0x13, 0x23, 0xa4, 0x84, 0x04, 0x13, 0x23, 0xe3, 0x84, 0xa1, -0x90, 0x14, 0x12, 0x4c, 0x8c, 0x8c, 0x0b, 0x84, 0xc4, 0x4c, 0x10, 0xa0, 0xc1, 0x1c, 0x01, 0x28, -0x0c, 0x22, 0x00, 0xc2, 0x08, 0xc0, 0x51, 0xd2, 0x14, 0x51, 0xc2, 0xe4, 0xff, 0x13, 0x71, 0x4d, -0x54, 0x44, 0xfc, 0xf6, 0xf0, 0x4f, 0x63, 0x04, 0xc0, 0x20, 0xc2, 0x10, 0xcc, 0x11, 0x80, 0xc1, -0x30, 0x02, 0x51, 0x9c, 0x24, 0x4d, 0x11, 0x25, 0x4c, 0x3e, 0xb8, 0x38, 0x01, 0xb0, 0x48, 0x1d, -0x30, 0x01, 0x88, 0x30, 0x0c, 0xc3, 0x18, 0x44, 0x38, 0x84, 0x61, 0x84, 0xa1, 0x28, 0x87, 0x40, -0x10, 0x48, 0x92, 0x24, 0xa4, 0x0c, 0x23, 0x08, 0xc5, 0x0c, 0xc0, 0x30, 0x02, 0xd1, 0x14, 0x43, -0x20, 0x18, 0xa7, 0x28, 0xe8, 0x19, 0x46, 0x18, 0x9a, 0x32, 0x44, 0x51, 0x44, 0xd2, 0x30, 0x82, -0xd0, 0x94, 0x81, 0xa2, 0x28, 0xaa, 0xca, 0xd0, 0x34, 0x0d, 0x5d, 0x45, 0x68, 0x1a, 0xca, 0x8a, -0x40, 0x51, 0xb4, 0x5d, 0x24, 0x4d, 0x11, 0x25, 0x4c, 0xfe, 0x2f, 0x01, 0xcc, 0xb3, 0x10, 0xd1, -0x3f, 0x8d, 0x11, 0x00, 0x83, 0x08, 0x9d, 0x30, 0x47, 0x10, 0x14, 0xc4, 0x21, 0x3c, 0xea, 0x63, -0x8a, 0x82, 0xc0, 0x22, 0x50, 0x0c, 0x89, 0x03, 0x01, 0x83, 0x08, 0x86, 0x30, 0x0a, 0x30, 0x47, -0x00, 0x01, 0x13, 0xb2, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, -0x78, 0x60, 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, 0x87, 0x38, -0x80, 0x03, 0x37, 0x88, 0x03, 0x3a, 0x70, 0x03, 0x38, 0xd8, 0x70, 0x1b, 0xe5, 0xd0, 0x06, 0xf0, -0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, -0x0e, 0x71, 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, 0x80, 0x07, -0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, -0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, -0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, -0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, -0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, -0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, -0x72, 0x40, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, -0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x74, 0x80, -0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, -0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, -0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x20, -0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, -0xf6, 0x10, 0x07, 0x79, 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, -0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, -0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, -0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, -0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, -0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0xf4, -0x80, 0x10, 0x21, 0x01, 0x64, 0xc8, 0x48, 0x91, 0x11, 0x40, 0x23, 0x84, 0x61, 0x0d, 0x06, 0x40, -0x1a, 0x8e, 0x25, 0xc0, 0xc4, 0x02, 0x0d, 0x0e, 0x89, 0x26, 0x43, 0x01, 0x00, 0x20, 0x00, 0x00, -0x00, 0x10, 0x00, 0x00, 0x00, 0x80, 0x21, 0x51, 0x26, 0x0e, 0x0a, 0x02, 0x0c, 0x02, 0x00, 0x00, -0x40, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x89, 0xf6, 0x41, 0x7b, 0x80, 0x00, 0x18, 0x00, 0x00, 0x00, -0x04, 0x00, 0x00, 0x00, 0x60, 0x48, 0x54, 0x13, 0x93, 0x04, 0x04, 0x00, 0x01, 0x00, 0x00, 0x20, -0x00, 0x00, 0x00, 0x00, 0x43, 0x22, 0xb4, 0x98, 0x24, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, -0x00, 0x00, 0x00, 0x18, 0x12, 0xed, 0xc5, 0x54, 0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, -0x00, 0x00, 0xc0, 0x90, 0xc8, 0x35, 0xa6, 0x0a, 0x08, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, -0x00, 0x00, 0x86, 0x44, 0xe1, 0x11, 0x5d, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, -0x00, 0x30, 0x24, 0x92, 0x8f, 0x28, 0x03, 0x02, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, -0x80, 0x21, 0xd1, 0x88, 0x5c, 0x1b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, -0x0c, 0x89, 0x74, 0x64, 0xda, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, -0x48, 0xd4, 0x26, 0x1b, 0x18, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xc0, -0x90, 0x08, 0x55, 0xa8, 0x0d, 0x08, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x86, -0x44, 0xbc, 0xb2, 0x89, 0x01, 0x10, 0x00, 0x04, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x48, -0x6c, 0x10, 0x28, 0x0c, 0xec, 0x00, 0x00, 0x90, 0x05, 0x02, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x1e, -0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x02, 0xea, 0xdd, -0xda, 0xf7, 0xff, 0xff, 0x17, 0x90, 0xf0, 0x3f, 0x60, 0x04, 0x80, 0x8a, 0x12, 0x28, 0x84, 0x22, -0x18, 0x01, 0x28, 0x98, 0x02, 0x0c, 0x28, 0x90, 0x02, 0x2a, 0xb0, 0x32, 0x28, 0x05, 0x00, 0x00, -0x00, 0x00, 0xb1, 0x18, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, -0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, -0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, -0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, -0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, -0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, -0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, -0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, -0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, -0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, -0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, -0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, -0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, -0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, -0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, -0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, -0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, -0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, -0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, -0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, -0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, -0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, -0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, -0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x33, 0x1e, 0x6a, 0x1e, 0xca, 0x61, 0x1c, 0xe8, -0x21, 0x1d, 0xde, 0xc1, 0x1d, 0x7e, 0x01, 0x1e, 0xe4, 0xa1, 0x1c, 0xcc, 0x21, 0x1d, 0xf0, 0x61, -0x06, 0x54, 0x85, 0x83, 0x38, 0xcc, 0xc3, 0x3b, 0xb0, 0x43, 0x3d, 0xd0, 0x43, 0x39, 0xfc, 0xc2, -0x3c, 0xe4, 0x43, 0x3b, 0x88, 0xc3, 0x3b, 0xb0, 0xc3, 0x8c, 0xc5, 0x0a, 0x87, 0x79, 0x98, 0x87, -0x77, 0x18, 0x87, 0x74, 0x08, 0x07, 0x7a, 0x28, 0x07, 0x72, 0x98, 0x81, 0x5c, 0xe3, 0x10, 0x0e, -0xec, 0xc0, 0x0e, 0xe5, 0x50, 0x0e, 0xf3, 0x30, 0x23, 0xc1, 0xd2, 0x41, 0x1e, 0xe4, 0xe1, 0x17, -0xd8, 0xe1, 0x1d, 0xde, 0x01, 0x1e, 0x66, 0x50, 0x59, 0x38, 0xa4, 0x83, 0x3c, 0xb8, 0x81, 0x39, -0xd4, 0x83, 0x3b, 0x8c, 0x03, 0x3d, 0xa4, 0xc3, 0x3b, 0xb8, 0xc3, 0x2f, 0x9c, 0x83, 0x3c, 0xbc, -0x43, 0x3d, 0xc0, 0xc3, 0x3c, 0x00, 0x79, 0x20, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x32, 0x9a, -0x08, 0x14, 0x02, 0x85, 0x8c, 0x27, 0x46, 0x46, 0xc8, 0x11, 0x32, 0x64, 0xd4, 0xca, 0x00, 0x0c, -0xe8, 0x09, 0x4a, 0x1e, 0x14, 0x1b, 0x57, 0x06, 0x8b, 0x94, 0x44, 0x17, 0xd3, 0x28, 0x18, 0xa3, -0x3c, 0x08, 0x55, 0x18, 0x86, 0x61, 0x44, 0xd7, 0x72, 0x88, 0x41, 0xd1, 0x80, 0xc1, 0xb2, 0x11, -0x11, 0x00, 0x77, 0x63, 0x68, 0x61, 0x72, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x41, 0x70, 0x70, 0x6c, -0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, -0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x20, 0x28, 0x6d, 0x65, 0x74, 0x61, 0x6c, -0x66, 0x65, 0x2d, 0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x2d, 0x77, 0x69, 0x6e, -0x64, 0x6f, 0x77, 0x73, 0x29, 0x4d, 0x65, 0x74, 0x61, 0x6c, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, -0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x6e, 0x6f, 0x72, 0x6d, 0x73, 0x5f, 0x64, 0x69, -0x73, 0x61, 0x62, 0x6c, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, -0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, -0x65, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x72, 0x61, -0x6d, 0x65, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x5f, 0x66, 0x65, 0x74, 0x63, 0x68, 0x5f, 0x64, -0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, -0x65, 0x61, 0x69, 0x72, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, -0x64, 0x65, 0x78, 0x61, 0x69, 0x72, 0x2e, 0x77, 0x72, 0x69, 0x74, 0x65, 0x61, 0x69, 0x72, 0x2e, -0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x78, -0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x77, 0x72, -0x69, 0x74, 0x65, 0x3e, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, -0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x61, 0x69, 0x72, -0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, -0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x3e, 0x49, -0x6e, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x62, -0x75, 0x66, 0x66, 0x65, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x5f, -0x73, 0x69, 0x7a, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x61, 0x69, 0x72, 0x2e, -0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, -0x75, 0x69, 0x6e, 0x74, 0x34, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x30, 0x43, 0x6f, 0x6e, 0x73, 0x74, -0x31, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x32, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x33, 0x61, 0x69, 0x72, -0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x61, 0x69, -0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x67, 0x6e, -0x5f, 0x73, 0x69, 0x7a, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x44, 0x61, 0x74, 0x61, -0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x61, -0x64, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x74, 0x68, -0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x4c, 0x6f, -0x63, 0x61, 0x6c, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x49, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x74, -0x68, 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, -0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x67, 0x72, 0x69, 0x64, 0x57, 0x6f, 0x72, 0x6b, 0x47, -0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, -0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x67, 0x72, 0x69, -0x64, 0x44, 0x74, 0x69, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, -0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x24, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x82, -0x50, 0x44, 0x23, 0x08, 0x85, 0x34, 0x82, 0x50, 0x4c, 0x23, 0x08, 0x05, 0x35, 0x82, 0xb0, 0x04, -0x23, 0x08, 0x45, 0x35, 0x82, 0x50, 0x58, 0x23, 0x08, 0xc5, 0x35, 0x82, 0x50, 0x60, 0x23, 0x08, -0x45, 0x36, 0x82, 0x50, 0x68, 0x23, 0x08, 0xc5, 0x36, 0x82, 0x10, 0x00, 0x33, 0x0c, 0x66, 0x10, -0x9c, 0xc1, 0x0c, 0x81, 0x30, 0xc3, 0x80, 0x06, 0x66, 0x90, 0x06, 0x33, 0x10, 0x03, 0x1a, 0x98, -0x41, 0x1a, 0xcc, 0x10, 0x10, 0x33, 0x04, 0xc5, 0x0c, 0x81, 0x31, 0x03, 0x30, 0x83, 0x92, 0x06, -0x07, 0xb2, 0x06, 0x66, 0x90, 0x28, 0x0b, 0xd3, 0xcc, 0xa0, 0x98, 0xc1, 0x81, 0x98, 0x81, 0x19, -0x38, 0xca, 0xc3, 0x40, 0x33, 0x50, 0x69, 0xd0, 0x06, 0x69, 0x50, 0x59, 0x6d, 0xd0, 0x06, 0x69, -0x50, 0x5d, 0x6e, 0xd0, 0x06, 0x69, 0x50, 0x61, 0x6f, 0xd0, 0x06, 0x69, 0x50, 0x65, 0x33, 0x48, -0x68, 0x10, 0x49, 0x6c, 0x80, 0x9c, 0x81, 0x19, 0x4c, 0x54, 0x1f, 0x68, 0x6c, 0xb0, 0xb5, 0x81, -0xc2, 0x31, 0xdd, 0x0c, 0x06, 0x1c, 0x78, 0xca, 0xc7, 0x80, 0xc1, 0x0c, 0xc6, 0x19, 0x84, 0x81, -0xf2, 0x31, 0x62, 0x30, 0x83, 0x11, 0x07, 0x63, 0xa0, 0x7c, 0x0c, 0x19, 0xcc, 0x60, 0xec, 0x01, -0x1f, 0xf8, 0xc1, 0x1f, 0x80, 0x42, 0x28, 0xcc, 0x30, 0xa8, 0x81, 0x1e, 0x88, 0xc2, 0x0c, 0x42, -0x19, 0xc8, 0x41, 0x7d, 0x00, 0xc7, 0x71, 0x1c, 0xc7, 0x71, 0x1c, 0xc7, 0x71, 0x1c, 0xe7, 0x06, -0x16, 0x1d, 0xe8, 0x81, 0x65, 0x59, 0x90, 0x2f, 0xf8, 0x02, 0x6c, 0x98, 0x05, 0x28, 0x98, 0x82, -0x29, 0xe0, 0x02, 0x1d, 0xc8, 0x48, 0x60, 0x82, 0x2e, 0x62, 0x63, 0xb3, 0x6b, 0x73, 0x69, 0x7b, -0x23, 0xab, 0x63, 0x2b, 0x73, 0x31, 0x63, 0x0b, 0x3b, 0x9b, 0x1b, 0x25, 0x90, 0x83, 0x53, 0xd8, -0xd8, 0xec, 0xda, 0x5c, 0xd2, 0xc8, 0xca, 0xdc, 0xe8, 0x46, 0x09, 0xe6, 0xe0, 0x96, 0xb0, 0x34, -0x39, 0x17, 0xbb, 0x32, 0xb9, 0xb9, 0xb4, 0x37, 0xb7, 0x51, 0x02, 0x3a, 0x38, 0x2a, 0x2c, 0x4d, -0xce, 0x85, 0x2d, 0xcc, 0xed, 0xac, 0x2e, 0xec, 0xac, 0xec, 0xcb, 0xae, 0x4c, 0x6e, 0x2e, 0xed, -0xcd, 0x6d, 0x94, 0xa0, 0x0e, 0x6e, 0x0a, 0x4b, 0x93, 0x73, 0x19, 0x7b, 0x6b, 0x83, 0x4b, 0x63, -0x2b, 0xfb, 0x7a, 0x83, 0xa3, 0x4b, 0x7b, 0x73, 0x9b, 0x1b, 0x65, 0xb0, 0x83, 0x3b, 0xc0, 0x83, -0x53, 0xc2, 0xd2, 0xe4, 0x5c, 0xd6, 0xca, 0xe4, 0xdc, 0xca, 0xd8, 0x46, 0x09, 0x44, 0xe1, 0xa4, -0xb0, 0x34, 0x39, 0x97, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, 0xb9, 0xaf, 0x39, 0xba, 0x30, 0xba, -0xb2, 0xb9, 0x51, 0x82, 0x51, 0x00, 0xa9, 0x18, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x0a, -0x72, 0x28, 0x87, 0x77, 0x80, 0x07, 0x7a, 0x58, 0x70, 0x98, 0x43, 0x3d, 0xb8, 0xc3, 0x38, 0xb0, -0x43, 0x39, 0xd0, 0xc3, 0x82, 0xe6, 0x1c, 0xc6, 0xa1, 0x0d, 0xe8, 0x41, 0x1e, 0xc2, 0xc1, 0x1d, -0xe6, 0x21, 0x1d, 0xe8, 0x21, 0x1d, 0xde, 0xc1, 0x1d, 0x00, 0xd1, 0x10, 0x00, 0x00, 0x06, 0x00, -0x00, 0x00, 0x07, 0xcc, 0x3c, 0xa4, 0x83, 0x3b, 0x9c, 0x03, 0x3b, 0x94, 0x03, 0x3d, 0xa0, 0x83, -0x3c, 0x94, 0x43, 0x38, 0x90, 0xc3, 0x01, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x08, 0x00, -0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x94, 0xcc, -0x00, 0x00, 0x23, 0x06, 0x8a, 0x11, 0x83, 0x60, 0xa0, 0x84, 0xc1, 0x61, 0x14, 0xc4, 0x10, 0x20, -0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x07, 0x0b, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, -0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x04, 0x94, 0x40, 0x11, 0x94, 0x01, 0x15, 0x33, 0x00, 0x05, -0x51, 0x0e, 0xc5, 0x40, 0xc6, 0x0c, 0xc0, 0x1c, 0x04, 0x15, 0x4d, 0x65, 0x40, 0xc9, 0x1c, 0x03, -0x15, 0x95, 0xc1, 0x1c, 0x43, 0xa4, 0x95, 0xc1, 0x58, 0x03, 0x10, 0x10, 0x73, 0x0c, 0xd4, 0x54, -0x06, 0x63, 0x0d, 0x40, 0x30, 0x8c, 0x00, 0x10, 0x33, 0x02, 0x30, 0x96, 0x00, 0x04, 0x63, 0x09, -0xc2, 0x30, 0x96, 0x30, 0x08, 0x63, 0x09, 0x41, 0x30, 0x96, 0x20, 0x1c, 0x63, 0x09, 0x01, 0x31, -0x96, 0x00, 0x08, 0x33, 0x00, 0x63, 0x09, 0x42, 0x40, 0x5f, 0x0d, 0xd0, 0x59, 0x88, 0xde, 0x03, -0x25, 0x50, 0xc6, 0xe6, 0x02, 0xd4, 0x8c, 0x11, 0x80, 0x20, 0x08, 0x82, 0xa0, 0x30, 0x46, 0x00, -0x82, 0x20, 0x88, 0x7f, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf0, 0x37, 0x46, 0x00, 0x82, 0x20, 0x08, -0x72, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf8, 0x2f, 0x8c, 0x11, 0x84, 0xb7, 0x8f, 0xa6, 0x1f, 0x39, -0x33, 0x00, 0x63, 0x11, 0x20, 0x08, 0x82, 0xf0, 0x07, 0x82, 0x20, 0x08, 0x7f, 0x20, 0x08, 0x82, -0xf0, 0x07, 0x82, 0x20, 0x08, 0x7f, 0x14, 0xcd, 0x00, 0x8c, 0x35, 0x80, 0x20, 0x08, 0x82, 0xa0, -0x00, 0x82, 0x20, 0x08, 0x82, 0x02, 0x08, 0x82, 0x20, 0x08, 0x0a, 0x44, 0xcd, 0x00, 0x8c, 0x25, -0x80, 0x20, 0x08, 0xe2, 0xbf, 0x00, 0x82, 0x20, 0x88, 0xff, 0xc2, 0x58, 0x42, 0x6b, 0xce, 0x39, -0xfb, 0xb5, 0xe6, 0x9c, 0xb3, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x30, 0xff, 0x81, 0x20, 0x08, 0xf3, -0xdf, 0x58, 0x02, 0x08, 0x82, 0x60, 0xfc, 0x0b, 0x20, 0x08, 0x82, 0xf1, 0x2f, 0x8c, 0x25, 0x80, -0x20, 0x08, 0xe2, 0x1f, 0x08, 0x82, 0x20, 0xfe, 0x8d, 0x25, 0x80, 0x20, 0x08, 0xe2, 0x1f, 0x30, -0x96, 0x00, 0x80, 0x20, 0x08, 0xe2, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x20, 0xfe, 0x0b, 0xc0, 0x58, -0x02, 0x00, 0x82, 0x20, 0x88, 0xff, 0xc2, 0x58, 0x02, 0x08, 0x82, 0x20, 0x08, 0x0a, 0x20, 0x08, -0x82, 0x20, 0x28, 0x8c, 0x25, 0x80, 0x20, 0x08, 0xe2, 0x1f, 0x08, 0x82, 0x20, 0x08, 0x06, 0x63, -0x09, 0x20, 0x08, 0x82, 0x20, 0x18, 0x80, 0x20, 0x08, 0xe2, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x20, -0x08, 0x06, 0x20, 0x08, 0x82, 0x20, 0x18, 0x90, 0x67, 0x1b, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x30, -0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x22, 0x47, 0xc8, 0x90, 0x51, 0x0a, 0x84, 0x18, 0x00, 0x00, -0x00, 0x00, 0xcf, 0x03, 0x00, 0x00, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, -0x20, 0x63, 0x68, 0x61, 0x72, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x2b, 0x2b, 0x20, -0x54, 0x42, 0x41, 0x41, 0x00, 0x00, 0x13, 0x04, 0x00, 0xda, 0x10, 0x98, 0xc2, 0x86, 0xa1, 0x14, -0x50, 0xe1, 0x14, 0x36, 0x0c, 0xa9, 0x90, 0x0a, 0xa7, 0x00, 0x63, 0x08, 0x79, 0x80, 0x0a, 0x15, -0xa0, 0x02, 0x56, 0x30, 0x07, 0x3a, 0xc7, 0x20, 0x06, 0xc1, 0x29, 0x14, 0x21, 0x0a, 0x58, 0x05, -0x2b, 0x68, 0x09, 0x76, 0xa0, 0x15, 0x08, 0x3b, 0xc7, 0x50, 0x04, 0xaf, 0x30, 0x86, 0x10, 0x0a, -0xb1, 0x50, 0x01, 0x2c, 0xdc, 0x1c, 0x83, 0x1a, 0x04, 0xaf, 0x30, 0x86, 0x40, 0x0a, 0xa2, 0x50, -0xc1, 0x2c, 0xdc, 0x1c, 0xc3, 0x10, 0xd4, 0x42, 0x1d, 0x01, 0xec, 0x63, 0x50, 0x05, 0x5c, 0xa0, -0x05, 0x0a, 0x8c, 0xb2, 0x8f, 0x81, 0x15, 0x74, 0x21, 0x17, 0x28, 0x30, 0xca, 0x3e, 0x06, 0x57, -0xe0, 0x85, 0x5c, 0xa0, 0xc0, 0x28, 0xfb, 0x18, 0x60, 0xc1, 0x17, 0x68, 0x81, 0x02, 0xa3, 0x8c, -0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x88, 0x81, 0x38, 0x24, 0x83, 0x0c, 0x08, 0x2a, 0xfc, -0xc1, 0x05, 0xd4, 0xda, 0x10, 0x88, 0xff, 0x20, 0xc3, 0xb2, 0x0a, 0xa1, 0x70, 0x01, 0xb5, 0x36, -0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xa9, 0x43, 0x60, 0x42, 0x10, -0xfe, 0x83, 0x0c, 0x0e, 0x2c, 0x9c, 0xc2, 0x05, 0xd4, 0x1a, 0x11, 0x88, 0xff, 0x20, 0x43, 0x34, -0x0b, 0xa9, 0x70, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x20, 0xd9, 0x42, 0x2b, 0x5c, 0x40, -0xad, 0x0d, 0x01, 0xf8, 0x0f, 0x32, 0x54, 0xb9, 0xf0, 0x0a, 0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, -0x83, 0x0c, 0x16, 0x2f, 0xcc, 0xc2, 0x05, 0xd4, 0x5a, 0x12, 0x80, 0xff, 0x88, 0x01, 0x53, 0x84, -0x20, 0x58, 0xf8, 0x07, 0x18, 0xf0, 0xc3, 0x3a, 0xc4, 0x81, 0xd2, 0x0a, 0xb7, 0x40, 0x0f, 0xf4, -0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0xfd, 0xc0, 0x0e, 0x72, 0xb0, 0xb8, -0x02, 0x2e, 0xe0, 0x43, 0x3d, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0x3f, -0xb4, 0xc3, 0x1c, 0x30, 0xaf, 0x90, 0x0b, 0xf7, 0x60, 0x0f, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, -0xe1, 0x1f, 0x60, 0xf0, 0x0f, 0xee, 0x40, 0x07, 0x0a, 0x2c, 0xe8, 0xc2, 0x3d, 0xdc, 0xc3, 0x88, -0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0x80, 0xc4, 0x3b, 0xd4, 0xc1, 0x12, 0x0b, 0xbb, -0xb0, 0x0f, 0xf8, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x21, 0x01, 0x0f, -0x76, 0xc0, 0xc8, 0x02, 0x2f, 0xe8, 0x43, 0x3e, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, -0x80, 0x81, 0x48, 0xc4, 0xc3, 0x1d, 0x28, 0xb3, 0xd0, 0x0b, 0xfa, 0xa0, 0x0f, 0x23, 0x06, 0x4c, -0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x30, 0x12, 0xf2, 0x80, 0x07, 0x0b, 0x2d, 0xf8, 0x82, 0x3f, -0xec, 0xc3, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0x90, 0xc4, 0x3c, 0xe4, 0x01, -0x53, 0x0b, 0xbf, 0xd0, 0x0f, 0xfc, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, -0x25, 0x41, 0x0f, 0x7a, 0xa0, 0xd8, 0x02, 0x38, 0xf4, 0x43, 0x3f, 0x8c, 0x18, 0x30, 0x45, 0x08, -0x82, 0x85, 0x7f, 0x80, 0x81, 0x49, 0xd4, 0xc3, 0x1e, 0x2c, 0xb7, 0x10, 0x0e, 0x21, 0xe1, 0x0f, -0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x70, 0x12, 0xf6, 0xc0, 0x07, 0x0c, 0x2e, -0x88, 0x03, 0x48, 0xfc, 0x83, 0x29, 0x0c, 0xf8, 0x5b, 0xf0, 0x0a, 0xe2, 0x6f, 0x41, 0x03, 0xfe, -0xa6, 0x30, 0xe0, 0x6f, 0x81, 0x2c, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, -0xb5, 0x20, 0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0xe0, 0x82, 0xf8, 0x5b, 0xd0, -0x80, 0xff, 0x20, 0x83, 0xb2, 0x0b, 0xee, 0x30, 0xc8, 0x80, 0xf0, 0x42, 0x3b, 0x0c, 0x32, 0x24, -0x06, 0x3b, 0x0c, 0x32, 0x1c, 0xbe, 0xf0, 0x0e, 0x83, 0x0c, 0x0b, 0xd2, 0x0e, 0x63, 0x08, 0x6d, -0x50, 0x13, 0x76, 0x0e, 0x41, 0xf8, 0xcf, 0x31, 0xf8, 0x42, 0x30, 0x13, 0x83, 0x0c, 0x01, 0x1c, -0xc0, 0x83, 0x05, 0xba, 0x00, 0xfe, 0x63, 0x08, 0x72, 0x80, 0x12, 0xb6, 0x0e, 0x41, 0xf8, 0xcf, -0x31, 0x8c, 0x43, 0x80, 0x13, 0x83, 0x0c, 0x01, 0x39, 0xf0, 0x83, 0x15, 0x81, 0xf8, 0x1b, 0xd3, -0x84, 0xbf, 0x39, 0x4f, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x66, 0x21, -0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x67, 0x21, 0x8c, 0x18, 0x1c, 0x44, 0x08, -0x82, 0x85, 0x7f, 0x54, 0x6c, 0x21, 0x04, 0x66, 0x0e, 0x01, 0xf9, 0x9b, 0x44, 0x85, 0xbf, 0x05, -0x88, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6c, 0x21, 0x58, 0x40, 0x88, -0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xf6, 0x16, 0x81, 0x05, 0x81, 0xf8, 0xdb, -0x95, 0x85, 0xbf, 0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x72, -0x21, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x73, 0x21, 0x8c, 0x18, 0x1c, 0x44, -0x08, 0x82, 0x85, 0x7f, 0x54, 0x78, 0x21, 0x04, 0x26, 0x0f, 0x01, 0xf9, 0x5b, 0x17, 0x06, 0xe1, -0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x5e, 0x08, 0x16, -0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xed, 0x45, 0x60, 0x41, 0x20, -0xfe, 0x83, 0x0c, 0x6e, 0x20, 0x12, 0x35, 0x31, 0xc8, 0xc0, 0x06, 0x23, 0x61, 0x13, 0x83, 0x0c, -0x6a, 0x40, 0x12, 0x35, 0x31, 0xc8, 0x20, 0x0b, 0x21, 0x51, 0x13, 0x26, 0x06, 0x81, 0xf8, 0x1b, -0x81, 0x06, 0xe1, 0x6f, 0x69, 0x60, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, -0x36, 0x1a, 0xc2, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x46, 0x1a, 0xc2, 0x88, 0xc1, -0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x95, 0x1a, 0x42, 0x60, 0x23, 0x11, 0x90, 0xbf, 0x29, 0x4b, -0xf8, 0x5b, 0x80, 0x88, 0xbf, 0x79, 0x01, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, -0x6c, 0xaa, 0x31, 0x58, 0x50, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xd6, -0x1a, 0x81, 0x05, 0x81, 0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, -0xfe, 0xb1, 0xbd, 0x46, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xd1, 0x46, 0xe0, -0x99, 0x4b, 0x04, 0xe4, 0x6f, 0xd4, 0x1e, 0x84, 0xbf, 0x05, 0x93, 0xf8, 0x5b, 0xd0, 0x81, 0xff, -0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x56, 0x1b, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, -0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb8, 0x11, 0x58, 0x10, 0x88, 0xbf, 0x05, 0x0c, 0xf8, -0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, 0x20, 0xfe, 0x36, 0x04, 0xe0, -0x3f, 0x86, 0x50, 0xe5, 0xc6, 0x18, 0x82, 0x85, 0x1a, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x30, 0x16, -0x01, 0x6e, 0x8c, 0x21, 0x38, 0xbd, 0x31, 0x86, 0xf0, 0xb0, 0x86, 0x09, 0x01, 0xf8, 0xcf, 0x31, -0x10, 0xc1, 0x6f, 0x8c, 0x21, 0x24, 0xe1, 0x31, 0x86, 0xa0, 0xc0, 0x86, 0x09, 0x01, 0xf8, 0x1b, -0x41, 0x88, 0xff, 0x18, 0x42, 0x50, 0x1e, 0x63, 0x08, 0x02, 0x6d, 0x98, 0x10, 0x80, 0xff, 0x70, -0x44, 0x60, 0x17, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0xe0, 0x17, 0x68, 0x7e, 0x11, -0x84, 0xc0, 0x05, 0xe6, 0x5e, 0xd0, 0xe0, 0x74, 0xc3, 0x5f, 0x04, 0xc7, 0x74, 0x03, 0x68, 0x54, -0xc8, 0x1c, 0x43, 0x14, 0xc4, 0xc7, 0x1c, 0x43, 0x5e, 0x0c, 0xee, 0x31, 0xc8, 0x10, 0xe8, 0x85, -0x6c, 0x58, 0x30, 0x88, 0xbf, 0x49, 0xa4, 0x21, 0xfe, 0x16, 0x04, 0xe2, 0x3f, 0x86, 0x30, 0xdc, -0x87, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0xe7, 0x61, 0x41, 0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, -0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0x8d, 0x48, 0x31, 0x62, 0x60, 0x10, 0x21, 0x08, -0x16, 0xfe, 0x91, 0x91, 0x08, 0x31, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x71, 0x99, 0x88, -0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x6d, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x68, 0x49, -0x20, 0xfe, 0x16, 0xc8, 0x06, 0xf8, 0x5b, 0x00, 0x89, 0xbf, 0x05, 0xb7, 0x01, 0xfe, 0x26, 0xdd, -0x86, 0xf8, 0x5b, 0x6e, 0x04, 0xe1, 0x6f, 0x94, 0x6d, 0x88, 0xbf, 0xe9, 0x46, 0x10, 0xfe, 0x17, -0x98, 0x77, 0xc1, 0xb9, 0x25, 0x1e, 0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x8e, 0x21, 0xd8, 0x84, -0x7f, 0xd8, 0x78, 0x04, 0xe1, 0x3f, 0xc7, 0xa0, 0x1b, 0xc1, 0x8b, 0xcc, 0x31, 0x04, 0xc3, 0x8c, -0x8c, 0x21, 0xdc, 0x44, 0x88, 0xd8, 0x79, 0x04, 0xe1, 0x3f, 0xc7, 0xe0, 0x1b, 0xc1, 0x8c, 0xcc, -0x31, 0x04, 0xc3, 0x8d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x62, 0x52, 0x04, -0x63, 0x08, 0x3f, 0x81, 0x22, 0xc6, 0x1e, 0x41, 0xf8, 0xcf, 0x31, 0x8c, 0x47, 0x80, 0x23, 0x73, -0x0c, 0xc1, 0xc0, 0x23, 0x63, 0x08, 0x60, 0xe1, 0x23, 0x06, 0x1f, 0x41, 0xf8, 0xcf, 0x31, 0x9c, -0x47, 0xc0, 0x23, 0x73, 0x0c, 0xc1, 0x00, 0x26, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0xd5, 0x9a, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xc5, 0x26, 0x4a, 0x30, -0x86, 0x80, 0x16, 0x31, 0x62, 0xf6, 0x11, 0x84, 0xff, 0x1c, 0x43, 0x7b, 0x04, 0x62, 0x32, 0xc7, -0x10, 0x0c, 0x66, 0x32, 0x86, 0x90, 0x16, 0x34, 0x62, 0xfa, 0x11, 0x84, 0xff, 0x1c, 0x43, 0x7c, -0x04, 0x66, 0x32, 0xc7, 0x10, 0x0c, 0x6a, 0x32, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, -0xd5, 0x49, 0x11, 0x8c, 0x21, 0xc4, 0xc5, 0x8e, 0xd8, 0x7f, 0x04, 0xe1, 0x3f, 0xc7, 0x60, 0x1f, -0xc1, 0x9a, 0xcc, 0x31, 0x04, 0xc3, 0x9b, 0x8c, 0x21, 0xc8, 0x45, 0x9c, 0xd8, 0x88, 0x04, 0xe1, -0x3f, 0xc7, 0xa0, 0x1f, 0xc1, 0x9b, 0xcc, 0x31, 0x04, 0xc3, 0x9c, 0x8c, 0x18, 0x1c, 0x44, 0x08, -0x82, 0x85, 0x7f, 0x54, 0x7e, 0x52, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, -0x9f, 0x28, 0xc1, 0x18, 0x82, 0x5e, 0x90, 0x89, 0xa5, 0x48, 0x10, 0xfe, 0x73, 0x0c, 0x20, 0x12, -0xd4, 0xc9, 0x1c, 0x43, 0x30, 0xe4, 0xc9, 0x18, 0xc2, 0x5e, 0x9c, 0x89, 0xb5, 0x48, 0x10, 0xfe, -0x73, 0x0c, 0x24, 0x12, 0xe4, 0xc9, 0x1c, 0x43, 0x30, 0xf4, 0xc9, 0x88, 0xc1, 0x41, 0x84, 0x20, -0x58, 0xf8, 0x47, 0x85, 0x2a, 0x45, 0x30, 0x86, 0x30, 0x1a, 0x6e, 0x62, 0x32, 0x12, 0x84, 0xff, -0x1c, 0x43, 0x8a, 0x04, 0x7e, 0x32, 0xc7, 0x10, 0x0c, 0xa2, 0x32, 0x86, 0x40, 0x1a, 0xa4, 0x62, -0x36, 0x12, 0x84, 0xff, 0x1c, 0x43, 0x8b, 0x04, 0xa2, 0x32, 0xc7, 0x10, 0x0c, 0xa6, 0x32, 0x62, -0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xc5, 0x4a, 0x11, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, -0x85, 0x7f, 0x54, 0xb2, 0xa2, 0x04, 0x83, 0x0c, 0x41, 0x8c, 0xbc, 0xc9, 0x20, 0xc3, 0x78, 0xc8, -0x88, 0x9a, 0x18, 0x8b, 0x04, 0xe1, 0x6f, 0x33, 0x32, 0x13, 0xe1, 0x3f, 0xc8, 0x60, 0x1b, 0x39, -0xc2, 0x26, 0x83, 0x0c, 0xb6, 0xa1, 0x23, 0x6d, 0x32, 0xc8, 0x60, 0x1b, 0x3b, 0xe2, 0x26, 0x83, -0x0c, 0xbd, 0x80, 0x23, 0x70, 0x62, 0x81, 0x21, 0xfe, 0x83, 0x0c, 0xbf, 0xa0, 0x23, 0x6e, 0x62, -0xc1, 0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, 0xe2, 0x6f, 0x81, 0x10, -0xfe, 0x73, 0x0c, 0x60, 0x22, 0x0b, 0xb5, 0x32, 0xc8, 0x10, 0x84, 0x49, 0x9e, 0x58, 0x60, 0x88, -0xff, 0x1c, 0xc3, 0x98, 0xcc, 0x02, 0xae, 0x0c, 0x32, 0x04, 0x64, 0xc2, 0x27, 0x16, 0x18, 0xe2, -0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x73, 0x0c, 0x69, 0x22, 0x0b, -0xbe, 0x32, 0xc8, 0x10, 0xa8, 0x89, 0xa8, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, -0xee, 0x32, 0x04, 0x16, 0xa8, 0x89, 0xf8, 0x5b, 0xc0, 0x26, 0xe0, 0x3f, 0xc7, 0xe0, 0x26, 0xbc, -0x30, 0x2e, 0x83, 0x0c, 0xc1, 0x9b, 0x9c, 0x8a, 0x05, 0x85, 0xf8, 0x5b, 0x00, 0x27, 0xe0, 0x6f, -0x41, 0x20, 0xfe, 0x66, 0x18, 0xe2, 0x6f, 0x41, 0x9c, 0x88, 0xbf, 0x05, 0x71, 0x02, 0xfe, 0x46, -0x04, 0xe2, 0x6f, 0x81, 0x18, 0x88, 0xbf, 0x09, 0x62, 0x20, 0xfe, 0x36, 0x88, 0x81, 0xf8, 0x9b, -0x9c, 0xa0, 0x41, 0xf8, 0x9b, 0x9d, 0xe8, 0x45, 0xf8, 0x0f, 0x32, 0xe8, 0x07, 0xa8, 0xcc, 0xca, -0x20, 0x83, 0x7e, 0x84, 0x0a, 0xad, 0x0c, 0x32, 0xe8, 0x87, 0xa8, 0xd4, 0x8a, 0x9d, 0x41, 0x21, -0xfe, 0x66, 0x06, 0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa1, 0x01, 0x22, 0xfe, 0xb6, 0x06, 0x88, -0xf8, 0x5b, 0x20, 0x84, 0xbf, 0x91, 0x01, 0x21, 0xfe, 0x26, 0x06, 0x82, 0xf8, 0x9b, 0x20, 0x88, -0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, -0xd5, 0x32, 0x01, 0x18, 0x58, 0x90, 0x2a, 0xe2, 0x6f, 0xc1, 0xaa, 0x80, 0xbf, 0x0d, 0x9e, 0xf8, -0x5b, 0xd0, 0x2a, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0x81, 0xab, 0x88, 0xbf, -0x05, 0xae, 0x02, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x78, 0xe0, 0x6f, 0x43, -0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, 0xf8, 0xdb, 0x41, 0x06, -0xe0, 0x6f, 0xb2, 0x92, 0x0a, 0xe1, 0x6f, 0xb2, 0xb2, 0x1b, 0xe1, 0x3f, 0xc8, 0xb0, 0x23, 0xe1, -0x32, 0x2f, 0x83, 0x0c, 0x3b, 0x22, 0x2e, 0xf4, 0x32, 0xc8, 0xb0, 0x23, 0xe3, 0x52, 0x2f, 0x86, -0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, 0x0a, 0x88, 0xf8, 0x1b, -0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, 0x28, 0x08, 0xe2, 0x6f, -0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, -0xe1, 0x1f, 0x95, 0xdb, 0x04, 0xa1, 0x60, 0x81, 0xba, 0x88, 0xbf, 0x05, 0xec, 0x02, 0xfe, 0x36, -0xfc, 0x81, 0xf8, 0x5b, 0xe0, 0x2e, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0xc1, -0xbb, 0x88, 0xbf, 0x05, 0xef, 0x02, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x06, -0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, 0xe2, 0x6f, 0x61, 0x10, -0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x16, 0x2f, 0xea, 0x10, 0xfe, 0x83, 0x0c, 0x78, 0x12, 0x32, -0x34, 0x33, 0xc8, 0x80, 0x27, 0x22, 0x53, 0x33, 0x83, 0x0c, 0x78, 0x32, 0x32, 0x36, 0x63, 0xe8, -0x40, 0x88, 0xbf, 0x05, 0xa1, 0x00, 0xfe, 0x86, 0x0e, 0x86, 0xf8, 0x1b, 0x28, 0x04, 0xe1, 0x6f, -0xe3, 0x30, 0x88, 0xbf, 0x85, 0x83, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, -0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xb1, 0x4e, 0xf0, 0x0b, 0x16, -0xa0, 0x8c, 0xf8, 0x5b, 0xa0, 0x32, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, 0x05, 0x2c, 0x03, 0xfe, -0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0xb4, 0x8c, 0xf8, 0x5b, 0xd0, 0x32, 0xe0, 0x6f, -0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x36, 0x5c, 0xe2, 0x6f, 0x5e, 0x00, -0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0xe6, 0x1d, 0xe0, 0x6f, 0x2e, 0x83, 0x12, 0xe1, -0x3f, 0xc8, 0x60, 0x2b, 0x3f, 0x13, 0x37, 0x83, 0x0c, 0xb6, 0x02, 0x36, 0x72, 0x33, 0xc8, 0x60, -0x2b, 0x61, 0x33, 0x37, 0x66, 0x12, 0x84, 0xf8, 0x5b, 0xe0, 0x07, 0xe0, 0x6f, 0x26, 0x61, 0x88, -0xbf, 0xf5, 0x41, 0x10, 0xfe, 0x16, 0x12, 0x83, 0xf8, 0xdb, 0x3f, 0x08, 0xe2, 0x6f, 0x82, 0x20, -0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0x95, 0xfa, 0x04, 0xfd, 0x60, 0x81, 0xd9, 0x88, 0xbf, 0x05, 0x68, 0x03, 0xfe, 0x36, 0xec, 0x83, -0xf8, 0x5b, 0xa0, 0x36, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0xc1, 0xda, 0x88, -0xbf, 0x05, 0x6b, 0x03, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, -0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, 0x26, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xde, 0x01, -0xfe, 0x26, 0x37, 0x66, 0x11, 0xfe, 0xc6, 0x36, 0x78, 0x12, 0xfe, 0x83, 0x0c, 0xf2, 0xe2, 0x37, -0xb0, 0x33, 0xc8, 0x20, 0x2f, 0x7f, 0x13, 0x3b, 0x83, 0x0c, 0xf2, 0x02, 0x3a, 0xb2, 0x63, 0x65, -0x51, 0x88, 0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, 0x81, 0x88, 0xbf, 0xa5, -0x05, 0x22, 0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, 0x85, 0x20, 0xfe, 0x26, -0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, -0xfe, 0x51, 0xad, 0x50, 0xe0, 0x13, 0x16, 0x9c, 0x8e, 0xf8, 0x5b, 0x90, 0x3a, 0xe0, 0x6f, 0x03, -0x4f, 0x88, 0xbf, 0x05, 0xab, 0x03, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0xb0, -0x8e, 0xf8, 0x5b, 0xc0, 0x3a, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x60, 0xe2, 0x6f, 0x61, 0x10, -0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x06, 0x01, -0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x3f, 0x86, 0x60, 0xc8, 0xd0, 0x18, 0xc2, 0x11, 0x42, 0x26, 0x04, -0xe0, 0x3f, 0xc7, 0xe0, 0x3b, 0x41, 0x0c, 0x8d, 0x21, 0x20, 0x36, 0x34, 0x86, 0x90, 0x94, 0x90, -0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x01, 0x0e, 0x8d, 0x21, 0x28, 0x3a, 0x34, 0x86, 0xb0, 0xa4, -0x90, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x81, 0x0e, 0x8d, 0x21, 0x34, 0x3e, 0x34, 0x86, 0xe0, -0xb4, 0x90, 0x09, 0x01, 0xf8, 0x0f, 0x32, 0xf8, 0xc7, 0x7a, 0x94, 0xd0, 0x20, 0x43, 0x80, 0x1b, -0x25, 0x34, 0xc8, 0x00, 0x22, 0xed, 0x51, 0x42, 0x83, 0x0c, 0x81, 0x6e, 0x94, 0x90, 0xb5, 0x4f, -0x10, 0xfe, 0x66, 0x3f, 0x06, 0xf9, 0xcf, 0x31, 0xc0, 0x4f, 0x30, 0x46, 0x83, 0x0c, 0x41, 0xfc, -0xa0, 0x90, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x48, 0x75, 0x54, -0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd2, 0x1d, 0x25, 0xc1, 0x20, 0x43, 0x50, -0x3f, 0x32, 0x34, 0xc7, 0x10, 0xf4, 0xcf, 0x18, 0x8d, 0x18, 0x24, 0x43, 0x08, 0x82, 0xc1, 0xb3, -0x47, 0x62, 0x74, 0x3b, 0x81, 0x1a, 0xad, 0xd1, 0x18, 0xc2, 0xed, 0xb8, 0x51, 0x05, 0x39, 0x04, -0x73, 0x0c, 0xb9, 0x13, 0xc0, 0x11, 0xe5, 0x8e, 0x51, 0x08, 0x77, 0x8c, 0x42, 0xb7, 0x63, 0x14, -0xb2, 0x1d, 0xa3, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x88, 0xc1, 0x1d, 0x15, 0x83, -0x0c, 0x45, 0x0f, 0xd1, 0xd0, 0x05, 0xd4, 0xda, 0x10, 0x88, 0xff, 0x20, 0x03, 0x02, 0x46, 0x36, -0x74, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xfd, -0x51, 0x60, 0x42, 0x10, 0xfe, 0x83, 0x0c, 0x4c, 0x19, 0xf1, 0xd0, 0x05, 0xd4, 0x1a, 0x11, 0x88, -0xff, 0x20, 0xc3, 0x83, 0x46, 0x3e, 0x74, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x10, 0xad, -0x91, 0x18, 0x5d, 0x40, 0xad, 0x0d, 0x01, 0xf8, 0x0f, 0x32, 0x50, 0x6e, 0x44, 0x46, 0x17, 0x50, -0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, 0x56, 0x1c, 0xa1, 0xd1, 0x05, 0xd4, 0x5a, 0x12, 0x80, 0xff, -0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xc4, 0x12, 0x28, 0x99, 0x90, 0x22, 0x46, -0x6c, 0x94, 0x4a, 0xa9, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0xb2, 0x14, -0x4a, 0x27, 0xb4, 0x8c, 0x51, 0x1b, 0xb5, 0x92, 0x2a, 0x8d, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, -0x7f, 0x80, 0xc1, 0x2c, 0x89, 0x12, 0x0a, 0x31, 0x64, 0xe4, 0x46, 0xac, 0xb4, 0x4a, 0x23, 0x06, -0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x40, 0x4b, 0xa3, 0x94, 0x42, 0x4a, 0x19, 0xbd, 0x11, -0x2b, 0xb1, 0xd2, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xd4, 0x12, 0x29, 0xa9, -0xd0, 0x62, 0x46, 0x70, 0x04, 0x4b, 0xad, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, -0x06, 0xb6, 0x54, 0x4a, 0x2b, 0xc4, 0x9c, 0x51, 0x1c, 0xbd, 0x92, 0x2b, 0x8d, 0x18, 0x30, 0x45, -0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0x2d, 0x99, 0x12, 0x0b, 0x29, 0x68, 0x24, 0x47, 0xaf, 0xf4, -0x4a, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x80, 0x4b, 0xa7, 0xd4, 0x42, 0x4b, -0x1a, 0xcd, 0xd1, 0x2c, 0xc1, 0xd2, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xe4, -0x12, 0x2a, 0xb9, 0x10, 0xa3, 0x46, 0x74, 0x24, 0x4b, 0xb1, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, -0x16, 0xfe, 0x01, 0x06, 0xba, 0x94, 0x4a, 0x2f, 0xa4, 0xac, 0x51, 0x1d, 0xc9, 0x92, 0x2c, 0x8d, -0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0x2e, 0xa9, 0x12, 0x0c, 0x2d, 0x6c, 0x64, -0x47, 0xb6, 0x34, 0x4b, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xc0, 0x4b, 0xab, -0x14, 0x43, 0x4c, 0x1b, 0xdd, 0x51, 0x2d, 0xd1, 0x92, 0x29, 0x0c, 0xf8, 0x5b, 0x40, 0x46, 0xe2, -0x6f, 0x41, 0x03, 0xfe, 0xa6, 0x30, 0xe0, 0x6f, 0xc1, 0x19, 0x89, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, -0xc2, 0x80, 0xbf, 0x05, 0x6a, 0x24, 0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0xb4, -0x91, 0xf8, 0x5b, 0xd0, 0x80, 0xff, 0x20, 0x83, 0x02, 0x47, 0xa3, 0x34, 0xc8, 0x80, 0xc4, 0x91, -0x28, 0x0d, 0x32, 0x24, 0x46, 0x28, 0x0d, 0x32, 0x1c, 0x73, 0x44, 0x4a, 0x83, 0x0c, 0x0b, 0x22, -0x4a, 0x63, 0x08, 0x6d, 0xa0, 0x4e, 0xc6, 0x47, 0x41, 0xf8, 0xcf, 0x31, 0xcc, 0x51, 0x80, 0x4e, -0x83, 0x0c, 0x01, 0x1c, 0x94, 0x92, 0x05, 0x6f, 0x04, 0xfe, 0x63, 0x08, 0x72, 0xd0, 0x4b, 0x06, -0x4a, 0x41, 0xf8, 0xcf, 0x31, 0xe0, 0x51, 0xd0, 0x4e, 0x83, 0x0c, 0x41, 0x1e, 0xc5, 0x92, 0x15, -0x81, 0xf8, 0x1b, 0xd3, 0x84, 0xbf, 0x39, 0x4f, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, -0x7f, 0x6c, 0xfb, 0x24, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xfc, 0x24, 0x8c, -0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x21, 0x25, 0x04, 0xb6, 0x47, 0x01, 0xf9, 0x9b, -0x44, 0x85, 0xbf, 0x05, 0x88, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x21, -0x25, 0x58, 0x40, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x46, 0x52, 0x81, -0x05, 0x81, 0xf8, 0xdb, 0x95, 0x85, 0xbf, 0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, -0x85, 0x7f, 0x6c, 0x27, 0x25, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x28, 0x25, -0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x2d, 0x25, 0x04, 0x76, 0x4a, 0x01, 0xf9, -0x5b, 0x17, 0x06, 0xe1, 0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0x5b, 0x4b, 0x09, 0x16, 0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xc1, -0x54, 0x60, 0x41, 0x20, 0xfe, 0x83, 0x0c, 0x6e, 0x70, 0x4b, 0xea, 0x34, 0xc8, 0xc0, 0x06, 0xb8, -0xb4, 0x4e, 0x83, 0x0c, 0x6a, 0x90, 0x4b, 0xea, 0x34, 0xc8, 0x20, 0x0b, 0xb6, 0xa4, 0x4e, 0x26, -0x06, 0x81, 0xf8, 0x1b, 0x81, 0x06, 0xe1, 0x6f, 0x69, 0x60, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, -0x20, 0x58, 0xf8, 0xc7, 0x86, 0x53, 0xc2, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x96, -0x53, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xe5, 0x53, 0x42, 0x60, 0xb8, 0x14, -0x90, 0xbf, 0x29, 0x4b, 0xf8, 0x5b, 0x80, 0x88, 0xbf, 0x79, 0x01, 0xf8, 0x8f, 0x18, 0x18, 0x44, -0x08, 0x82, 0x85, 0x7f, 0x6c, 0x3f, 0x35, 0x58, 0x50, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, -0x58, 0xf8, 0xc7, 0x26, 0x56, 0x81, 0x05, 0x81, 0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, -0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0x91, 0x55, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, -0x51, 0xa5, 0x55, 0xe0, 0xd9, 0x38, 0x05, 0xe4, 0x6f, 0xd4, 0x1e, 0x84, 0xbf, 0x05, 0x93, 0xf8, -0x5b, 0xd0, 0x81, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xa6, 0x56, 0x83, 0x05, -0x85, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6d, 0x15, 0x58, 0x10, 0x88, -0xbf, 0x05, 0x0c, 0xf8, 0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, 0x20, -0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x86, 0x50, 0xb9, 0xd5, 0x18, 0x82, 0xd5, 0x53, 0x26, 0x04, 0xe0, -0x3f, 0xc7, 0x80, 0x4f, 0x41, 0x5b, 0x8d, 0x21, 0x38, 0x72, 0x35, 0x86, 0xf0, 0x84, 0x95, 0x09, -0x01, 0xf8, 0xcf, 0x31, 0x10, 0x01, 0x5d, 0x8d, 0x21, 0x24, 0x76, 0x35, 0x86, 0xa0, 0x94, 0x95, -0x09, 0x01, 0xf8, 0x1b, 0x41, 0x88, 0xff, 0x18, 0x42, 0xa0, 0x57, 0x63, 0x08, 0x42, 0x5a, 0x99, -0x10, 0x80, 0xff, 0x70, 0x44, 0xb0, 0x52, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x30, -0x53, 0x68, 0x33, 0x15, 0x84, 0xc0, 0x05, 0xe6, 0x5e, 0xd0, 0xe0, 0x74, 0x03, 0x4d, 0x05, 0xc7, -0x74, 0x43, 0x4d, 0x55, 0xc8, 0x1c, 0x43, 0x14, 0x98, 0xd6, 0x1c, 0x83, 0x4b, 0x0d, 0xa3, 0x35, -0xc8, 0x10, 0xbc, 0xd4, 0x59, 0x59, 0x30, 0x88, 0xbf, 0x49, 0x39, 0x25, 0xfe, 0x16, 0x04, 0xe2, -0x3f, 0x86, 0x30, 0xb0, 0x96, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0x7c, 0x65, 0x41, 0x20, 0xfe, -0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xe1, 0x56, 0x31, 0x62, -0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xe5, 0x16, 0x31, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, -0xfe, 0x71, 0xed, 0x96, 0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x96, 0x5a, 0x05, 0x71, 0x81, 0xb9, -0x17, 0x34, 0x68, 0x49, 0x20, 0xfe, 0x16, 0x9c, 0x15, 0xf8, 0x5b, 0x00, 0x89, 0xbf, 0x05, 0x6c, -0x05, 0xfe, 0x26, 0xb1, 0x95, 0xf8, 0x9b, 0x5b, 0x05, 0xe1, 0x6f, 0xd4, 0x5a, 0x89, 0xbf, 0xbd, -0x55, 0x10, 0xfe, 0x17, 0x98, 0x77, 0xc1, 0xb9, 0x75, 0x57, 0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, -0x8e, 0x21, 0xd8, 0xc4, 0x6c, 0x19, 0x5e, 0x05, 0xe1, 0x3f, 0xc7, 0xf0, 0x56, 0x01, 0x79, 0xcd, -0x31, 0x04, 0x03, 0x7a, 0x8d, 0x21, 0xdc, 0x84, 0x6d, 0x19, 0x5f, 0x05, 0xe1, 0x3f, 0xc7, 0x30, -0x57, 0x01, 0x7a, 0xcd, 0x31, 0x04, 0x03, 0x7b, 0x8d, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, -0x54, 0xf7, 0x55, 0x04, 0x63, 0x08, 0x3f, 0xd1, 0x5b, 0x16, 0x5a, 0x41, 0xf8, 0xcf, 0x31, 0xe0, -0x55, 0xd0, 0x5e, 0x73, 0x0c, 0xc1, 0x10, 0x5f, 0x63, 0x08, 0x60, 0x31, 0x5f, 0x56, 0x5a, 0x41, -0xf8, 0xcf, 0x31, 0xf0, 0x55, 0x10, 0x5f, 0x73, 0x0c, 0xc1, 0x50, 0x5f, 0x23, 0x06, 0x07, 0x11, -0x82, 0x60, 0xe1, 0x1f, 0x15, 0x88, 0x15, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, -0x15, 0x62, 0x4a, 0x30, 0x86, 0x80, 0x16, 0xe6, 0x65, 0xab, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x68, -0x05, 0xf7, 0x35, 0xc7, 0x10, 0x0c, 0xfb, 0x35, 0x86, 0x90, 0x16, 0xe9, 0x65, 0xaf, 0x15, 0x84, -0xff, 0x1c, 0x83, 0x69, 0x05, 0xfb, 0x35, 0xc7, 0x10, 0x0c, 0xff, 0x35, 0x62, 0x70, 0x10, 0x21, -0x08, 0x16, 0xfe, 0x51, 0xa9, 0x58, 0x11, 0x8c, 0x21, 0xc4, 0x05, 0x7c, 0x19, 0x6d, 0x05, 0xe1, -0x3f, 0xc7, 0xb0, 0x5a, 0x01, 0x88, 0xcd, 0x31, 0x04, 0x03, 0x89, 0x8d, 0x21, 0xc8, 0x85, 0x89, -0x19, 0x6e, 0x05, 0xe1, 0x3f, 0xc7, 0xf0, 0x5a, 0x01, 0x89, 0xcd, 0x31, 0x04, 0x03, 0x8a, 0x8d, -0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x33, 0x56, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, -0x60, 0xe1, 0x1f, 0x15, 0x8d, 0x29, 0xc1, 0x18, 0x82, 0x5e, 0xe4, 0x97, 0xf9, 0x56, 0x10, 0xfe, -0x73, 0x0c, 0xb5, 0x15, 0xa8, 0xd8, 0x1c, 0x43, 0x30, 0xb8, 0xd8, 0x18, 0xc2, 0x5e, 0xf0, 0x97, -0x89, 0x57, 0x10, 0xfe, 0x73, 0x0c, 0xb9, 0x15, 0xb8, 0xd8, 0x1c, 0x43, 0x30, 0xc8, 0xd8, 0x88, -0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xd5, 0x63, 0x45, 0x30, 0x86, 0x30, 0x1a, 0x23, 0x66, -0xe7, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x6f, 0x05, 0x33, 0x36, 0xc7, 0x10, 0x0c, 0x37, 0x36, 0x86, -0x40, 0x1a, 0x39, 0x66, 0xeb, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x78, 0x05, 0x37, 0x36, 0xc7, 0x10, -0x0c, 0x3b, 0x36, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x99, 0x59, 0x11, 0x8c, 0x18, -0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x67, 0xa6, 0x04, 0x83, 0x0c, 0x81, 0x79, 0x91, 0xd8, -0x20, 0xc3, 0x78, 0x9c, 0xd7, 0x7f, 0x59, 0x78, 0x05, 0xe1, 0x6f, 0xe8, 0x35, 0x13, 0xe1, 0x3f, -0xc8, 0x60, 0x1b, 0xee, 0x15, 0x62, 0x83, 0x0c, 0xb6, 0xf1, 0x5e, 0x22, 0x36, 0xc8, 0x60, 0x1b, -0xf0, 0x35, 0x62, 0x83, 0x0c, 0xbd, 0xd0, 0x5e, 0x25, 0x66, 0x81, 0x21, 0xfe, 0x83, 0x0c, 0xbf, -0xf0, 0x5e, 0x23, 0x66, 0xc1, 0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, -0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x73, 0x0c, 0xf5, 0x25, 0x0b, 0x6a, 0x36, 0xc8, 0x10, 0xd8, 0x97, -0x8b, 0x59, 0x60, 0x88, 0xff, 0x1c, 0x03, 0x7e, 0xcd, 0x42, 0x9b, 0x0d, 0x32, 0x04, 0xf9, 0x15, -0x63, 0x16, 0x18, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x73, -0x0c, 0xfe, 0x25, 0x0b, 0x73, 0x36, 0xc8, 0x10, 0xfc, 0xd7, 0x8d, 0x8d, 0x18, 0x1c, 0x44, 0x08, -0x82, 0x85, 0x7f, 0x54, 0xa3, 0x36, 0x04, 0x16, 0xfc, 0x97, 0xf8, 0x5b, 0x10, 0x62, 0xe0, 0x3f, -0xc7, 0x30, 0x62, 0xbc, 0x80, 0x67, 0x83, 0x0c, 0x01, 0x89, 0xf1, 0x98, 0x05, 0x85, 0xf8, 0x5b, -0x50, 0x62, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x66, 0x18, 0xe2, 0x6f, 0x81, 0x89, 0x89, 0xbf, 0x05, -0x26, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x18, 0x88, 0xbf, 0x09, 0x62, 0x20, 0xfe, 0x36, -0x88, 0x81, 0xf8, 0xdb, 0x89, 0xa1, 0x41, 0xf8, 0xdb, 0x8a, 0xe9, 0x45, 0xf8, 0x0f, 0x32, 0xe8, -0x47, 0x8d, 0xa1, 0xd9, 0x20, 0x83, 0x7e, 0xd8, 0x58, 0x9a, 0x0d, 0x32, 0xe8, 0xc7, 0x8d, 0xa9, -0x99, 0x9d, 0x41, 0x21, 0xfe, 0x66, 0x06, 0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa1, 0x01, 0x22, -0xfe, 0xb6, 0x06, 0x88, 0xf8, 0x5b, 0x20, 0x84, 0xbf, 0x91, 0x01, 0x21, 0xfe, 0x26, 0x06, 0x82, -0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, -0x20, 0x58, 0xf8, 0x47, 0x25, 0x6e, 0x01, 0x18, 0x58, 0xe0, 0x63, 0xe2, 0x6f, 0x01, 0x98, 0x81, -0xbf, 0x0d, 0x9e, 0xf8, 0x5b, 0x20, 0x66, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, -0xc1, 0x98, 0x89, 0xbf, 0x05, 0x63, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, -0x78, 0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, -0xf8, 0xdb, 0x41, 0x06, 0xe0, 0x6f, 0x67, 0x96, 0x0a, 0xe1, 0x6f, 0x67, 0xb6, 0x1b, 0xe1, 0x3f, -0xc8, 0xb0, 0x23, 0x76, 0x86, 0x6a, 0x83, 0x0c, 0x3b, 0x72, 0x67, 0xa9, 0x36, 0xc8, 0xb0, 0x23, -0x78, 0xa6, 0x6a, 0x86, 0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, -0x0a, 0x88, 0xf8, 0x1b, 0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, -0x28, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, -0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0xc8, 0x05, 0xa1, 0x60, 0xc1, 0x9f, 0x89, 0xbf, 0x05, -0xa1, 0x06, 0xfe, 0x36, 0xfc, 0x81, 0xf8, 0x5b, 0x30, 0x6a, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, -0x10, 0xe2, 0x6f, 0x01, 0xa9, 0x89, 0xbf, 0x05, 0xa4, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, -0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, -0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x66, 0x6a, 0xea, 0x10, 0xfe, 0x83, -0x0c, 0x78, 0x62, 0x6b, 0xe9, 0x36, 0xc8, 0x80, 0x27, 0xb7, 0xa6, 0x6e, 0x83, 0x0c, 0x78, 0x82, -0x6b, 0xeb, 0x66, 0xe8, 0x40, 0x88, 0xbf, 0x05, 0xa1, 0x00, 0xfe, 0x86, 0x0e, 0x86, 0xf8, 0x1b, -0x28, 0x04, 0xe1, 0x6f, 0xe3, 0x30, 0x88, 0xbf, 0x85, 0x83, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, -0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x85, -0x5d, 0xf0, 0x0b, 0x16, 0xf4, 0x9a, 0xf8, 0x5b, 0xf0, 0x6b, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, -0x05, 0xe1, 0x06, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0x88, 0x9b, 0xf8, 0x5b, -0x20, 0x6e, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x36, 0x5c, -0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0xe6, 0x1d, 0xe0, 0x6f, -0xe3, 0x86, 0x12, 0xe1, 0x3f, 0xc8, 0x60, 0x2b, 0xf4, 0x66, 0x72, 0x83, 0x0c, 0xb6, 0x52, 0x6f, -0x27, 0x37, 0xc8, 0x60, 0x2b, 0xf6, 0x86, 0x72, 0x66, 0x12, 0x84, 0xf8, 0x5b, 0xe0, 0x07, 0xe0, -0x6f, 0x26, 0x61, 0x88, 0xbf, 0xf5, 0x41, 0x10, 0xfe, 0x16, 0x12, 0x83, 0xf8, 0xdb, 0x3f, 0x08, -0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, -0x82, 0x60, 0xe1, 0x1f, 0xd5, 0xdf, 0x05, 0xfd, 0x60, 0xc1, 0xbe, 0x89, 0xbf, 0x05, 0xfd, 0x06, -0xfe, 0x36, 0xec, 0x83, 0xf8, 0x5b, 0xf0, 0x6f, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, -0x6f, 0x01, 0xc8, 0x89, 0xbf, 0x05, 0x20, 0x07, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x25, 0xfe, -0xe6, 0x05, 0xe0, 0x6f, 0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, 0x26, 0xfe, 0xe6, 0x05, -0xe0, 0x6f, 0xde, 0x01, 0xfe, 0x76, 0x72, 0x66, 0x11, 0xfe, 0x16, 0x72, 0x78, 0x12, 0xfe, 0x83, -0x0c, 0xf2, 0x32, 0x73, 0x65, 0x37, 0xc8, 0x20, 0x2f, 0x34, 0x67, 0x76, 0x83, 0x0c, 0xf2, 0x52, -0x73, 0x67, 0x67, 0x65, 0x51, 0x88, 0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, -0x81, 0x88, 0xbf, 0xa5, 0x05, 0x22, 0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, -0x85, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, -0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x81, 0x5f, 0xe0, 0x13, 0x16, 0xf0, 0x9c, 0xf8, 0x5b, 0xe0, -0x73, 0xe0, 0x6f, 0x03, 0x4f, 0x88, 0xbf, 0x05, 0x60, 0x07, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, -0x21, 0xfe, 0x16, 0x84, 0x9d, 0xf8, 0x5b, 0x10, 0x76, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x60, -0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, 0x26, -0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x3f, 0x86, 0x60, 0x9c, 0xdf, 0x18, 0xc2, -0x61, 0x7b, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x30, 0x77, 0x81, 0xf9, 0x8d, 0x21, 0x20, 0xeb, 0x37, -0x86, 0x90, 0xe8, 0x9e, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x41, 0xfb, 0x8d, 0x21, 0x28, 0xef, -0x37, 0x86, 0xb0, 0xf8, 0x9e, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0xc1, 0xfb, 0x8d, 0x21, 0x34, -0xf3, 0x37, 0x86, 0xe0, 0x88, 0x9f, 0x09, 0x01, 0xf8, 0x0f, 0x32, 0xf8, 0xc7, 0x7a, 0xe8, 0xde, -0x20, 0x43, 0x80, 0x1b, 0xba, 0x37, 0xc8, 0x00, 0x22, 0xed, 0xa1, 0x7b, 0x83, 0x0c, 0x81, 0x6e, -0xe8, 0x9e, 0x89, 0x5e, 0x10, 0xfe, 0xb6, 0x7a, 0x06, 0xf9, 0xcf, 0x31, 0x94, 0x5e, 0x80, 0x7f, -0x83, 0x0c, 0x81, 0xe9, 0xf5, 0x9e, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, -0x7f, 0x48, 0x2a, 0x18, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x87, 0xc4, 0x82, -0x41, 0x12, 0x0c, 0x32, 0x04, 0xaa, 0x77, 0x7e, 0x73, 0x0c, 0x81, 0xec, 0xe1, 0xdf, 0x88, 0x41, -0x32, 0x84, 0x20, 0x18, 0x3c, 0x30, 0x18, 0xdc, 0xdf, 0xec, 0x04, 0xff, 0x07, 0x82, 0xc1, 0x18, -0x02, 0xdb, 0xc5, 0x5f, 0x05, 0xee, 0x07, 0x73, 0x0c, 0xb5, 0x13, 0xcc, 0x1f, 0xb9, 0x9d, 0x51, -0xa8, 0xed, 0x8c, 0x42, 0x6c, 0x67, 0x14, 0x5a, 0x3b, 0xa3, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, -0x85, 0x7f, 0x88, 0x01, 0x0b, 0x06, 0xc5, 0x20, 0x43, 0x21, 0x7f, 0xe9, 0x77, 0x01, 0xb5, 0x36, -0x04, 0xe2, 0x3f, 0xc8, 0x80, 0xd4, 0xdf, 0xfa, 0x5d, 0x40, 0xad, 0x0d, 0x01, 0xf8, 0x8f, 0x18, -0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x34, 0x18, 0x04, 0x26, 0x04, 0xe1, 0x3f, 0xc8, 0xc0, -0xe8, 0x5f, 0xfc, 0x5d, 0x40, 0xad, 0x11, 0x81, 0xf8, 0x0f, 0x32, 0x3c, 0xfd, 0x37, 0x7f, 0x17, -0x50, 0x6b, 0x43, 0x00, 0xfe, 0x83, 0x0c, 0x11, 0x08, 0x06, 0xf7, 0x77, 0x01, 0xb5, 0x36, 0x04, -0xe0, 0x3f, 0xc8, 0x40, 0x8d, 0x60, 0x90, 0x7f, 0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, -0x96, 0x09, 0x06, 0xfd, 0x77, 0x01, 0xb5, 0x96, 0x04, 0xe0, 0x3f, 0x62, 0xc0, 0x14, 0x21, 0x08, -0x16, 0xfe, 0x01, 0x06, 0x66, 0x18, 0xd4, 0x60, 0xb0, 0x7b, 0xca, 0xfd, 0x85, 0x60, 0xe0, 0x83, -0x81, 0x0f, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x70, 0x86, 0x81, 0x0d, -0x06, 0xbc, 0xb7, 0xe0, 0x9f, 0x08, 0x06, 0x62, 0x18, 0xfc, 0x60, 0x30, 0x62, 0xc0, 0x14, 0x21, -0x08, 0x16, 0xfe, 0x01, 0x06, 0x68, 0x18, 0xdc, 0x60, 0xd0, 0x7b, 0x4c, 0xfe, 0x8d, 0x60, 0x10, -0x86, 0x01, 0x18, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x90, 0x86, 0x01, -0x0e, 0x06, 0xbe, 0xa7, 0xe8, 0x1f, 0x09, 0x06, 0x61, 0x18, 0x84, 0x61, 0x30, 0x62, 0xc0, 0x14, -0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6a, 0x18, 0xe4, 0x60, 0xf0, 0x7b, 0xcb, 0xfe, 0x95, 0x60, -0x50, 0x86, 0x81, 0x18, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xb0, 0x86, -0x81, 0x0e, 0x06, 0xe0, 0xc7, 0xf0, 0x9f, 0x09, 0x06, 0x64, 0x18, 0x8c, 0x61, 0x30, 0x62, 0xc0, -0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6c, 0x18, 0xec, 0x60, 0x10, 0x7e, 0x4a, 0xff, 0x9d, -0x60, 0x40, 0x86, 0x01, 0x19, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xd0, -0x86, 0x01, 0x0f, 0x06, 0xe2, 0xb7, 0xf8, 0x1f, 0x0a, 0x06, 0x68, 0x18, 0x94, 0x61, 0x30, 0x62, -0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6e, 0x18, 0xf4, 0x60, 0x30, 0x7e, 0xcc, 0xff, -0xa5, 0x60, 0x70, 0x86, 0x81, 0x19, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, -0xf0, 0x86, 0x81, 0x0f, 0x06, 0xe4, 0xa7, 0x80, 0x60, 0xa0, 0x82, 0xc1, 0x19, 0x06, 0x67, 0x18, -0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0x1c, 0x06, 0x3f, 0x18, 0x94, 0xdf, -0x12, 0x82, 0xc1, 0x0a, 0x06, 0x6b, 0x18, 0xa0, 0x61, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, -0xfe, 0x01, 0x06, 0x71, 0x18, 0x80, 0x61, 0x60, 0x7e, 0x8c, 0x08, 0x06, 0x2c, 0x18, 0xa8, 0x61, -0x90, 0x86, 0x81, 0x29, 0x0c, 0xf8, 0x5b, 0x90, 0x7f, 0xe2, 0x6f, 0x41, 0x03, 0xfe, 0xa6, 0x30, -0xe0, 0x6f, 0x01, 0xff, 0x89, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xff, 0x27, -0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0x88, 0x60, 0x20, 0xfe, 0x16, 0x34, 0xe0, -0x3f, 0xc8, 0xa0, 0x94, 0x60, 0x80, 0x83, 0xc1, 0x20, 0x03, 0x62, 0x82, 0xc1, 0x0d, 0x06, 0x83, -0x0c, 0x89, 0x61, 0x83, 0xc1, 0x20, 0xc3, 0x81, 0x82, 0x41, 0x0e, 0x06, 0x83, 0x0c, 0x0b, 0x72, -0x83, 0xc1, 0x18, 0x42, 0x1b, 0xfc, 0x61, 0x60, 0x31, 0x18, 0x04, 0xe1, 0x3f, 0xc7, 0x80, 0x82, -0x41, 0xd0, 0x87, 0xc1, 0x20, 0x43, 0x00, 0x07, 0x3a, 0x18, 0x58, 0x40, 0x82, 0x01, 0xf8, 0x8f, -0x21, 0xc8, 0x81, 0x1c, 0x06, 0x56, 0x83, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x2d, 0x18, 0x04, 0xa2, -0x18, 0x0c, 0x32, 0x04, 0x2e, 0x18, 0x98, 0x61, 0x60, 0x45, 0x20, 0xfe, 0xc6, 0x34, 0xe1, 0x6f, -0xce, 0x13, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x2c, 0x06, 0xc2, 0x88, -0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x16, 0x8b, 0x81, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, -0x16, 0xfe, 0x51, 0xd9, 0x62, 0x20, 0x04, 0x06, 0x83, 0x41, 0x40, 0xfe, 0x26, 0x51, 0xe1, 0x6f, -0x01, 0x22, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2d, 0x06, 0x82, 0x05, -0x84, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb9, 0x18, 0x04, 0x16, 0x04, -0xe2, 0x6f, 0x57, 0x16, 0xfe, 0xa6, 0x71, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, -0xb1, 0xf1, 0x62, 0x20, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xbd, 0x18, 0x08, -0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x95, 0x38, 0x06, 0x42, 0x60, 0x3c, 0x18, 0x04, -0xe4, 0x6f, 0x5d, 0x18, 0x84, 0xbf, 0x05, 0x94, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, -0x7f, 0x6c, 0xe2, 0x18, 0x08, 0x16, 0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, -0xb1, 0x95, 0x63, 0x10, 0x58, 0x10, 0x88, 0xff, 0x20, 0x83, 0x1b, 0xb0, 0x61, 0xf0, 0x87, 0xc1, -0x20, 0x03, 0x1b, 0xb4, 0x61, 0x00, 0x8a, 0xc1, 0x20, 0x83, 0x1a, 0xb8, 0x61, 0xf0, 0x87, 0xc1, -0x20, 0x83, 0x2c, 0xac, 0x61, 0xf0, 0x87, 0x81, 0x89, 0x41, 0x20, 0xfe, 0x46, 0xa0, 0x41, 0xf8, -0x5b, 0x1a, 0x18, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xb5, 0x63, 0x20, -0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xee, 0x18, 0x08, 0x23, 0x06, 0x07, 0x11, -0x82, 0x60, 0xe1, 0x1f, 0xd5, 0x3c, 0x06, 0x42, 0x60, 0x6d, 0x18, 0x04, 0xe4, 0x6f, 0xca, 0x12, -0xfe, 0x16, 0x20, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0x1b, 0x3d, 0x06, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, -0xf7, 0x18, 0x04, 0x16, 0x04, 0xe2, 0x6f, 0x50, 0x1d, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, -0x58, 0xf8, 0xc7, 0x96, 0x8f, 0x41, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xf9, -0x63, 0x10, 0x78, 0x86, 0x87, 0x41, 0x40, 0xfe, 0x46, 0xed, 0x41, 0xf8, 0x5b, 0x30, 0x89, 0xbf, -0x05, 0x1d, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xff, 0x18, 0x0c, 0x16, -0x14, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0x89, 0x64, 0x10, 0x58, 0x10, -0x88, 0xbf, 0x05, 0x0c, 0xf8, 0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, -0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x86, 0x50, 0x8d, 0x64, 0x30, 0x86, 0x60, 0xc9, 0x63, 0x60, -0x42, 0x00, 0xfe, 0x73, 0x0c, 0xad, 0x18, 0x04, 0x22, 0x19, 0x8c, 0x21, 0x38, 0x27, 0x19, 0x8c, -0x21, 0x3c, 0xf6, 0x18, 0x98, 0x10, 0x80, 0xff, 0x1c, 0x03, 0x11, 0xa4, 0x64, 0x30, 0x86, 0x90, -0xac, 0x64, 0x30, 0x86, 0xa0, 0xe8, 0x63, 0x60, 0x42, 0x00, 0xfe, 0x46, 0x10, 0xe2, 0x3f, 0x86, -0x10, 0xbc, 0x64, 0x30, 0x86, 0x20, 0xf8, 0x63, 0x60, 0x42, 0x00, 0xfe, 0xc3, 0x11, 0x01, 0x38, -0x06, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x80, 0x8e, 0x01, 0x1a, 0x3a, 0x06, 0x41, -0x08, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x4e, 0x37, 0xa4, 0x63, 0x10, 0x1c, 0xd3, 0x0d, 0xea, 0x18, -0x54, 0xc8, 0x1c, 0x43, 0x14, 0xec, 0x64, 0x30, 0xc7, 0x30, 0x8e, 0xc1, 0x80, 0x93, 0xc1, 0x20, -0x43, 0x40, 0x8e, 0x01, 0x3f, 0x06, 0x16, 0x0c, 0xe2, 0x6f, 0x92, 0x3b, 0x06, 0xe2, 0x6f, 0x41, -0x20, 0xfe, 0x63, 0x08, 0x43, 0x58, 0x06, 0x16, 0x04, 0xe2, 0x3f, 0x86, 0x50, 0xc4, 0x64, 0x60, -0x41, 0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xb5, -0x65, 0x50, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x64, 0x6e, 0x19, 0x10, 0x23, 0x06, -0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x17, 0x5c, 0x06, 0x42, 0x70, 0x81, 0x79, 0x17, 0x9c, 0x5b, -0xff, 0x18, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x68, 0x49, 0x20, 0xfe, 0x16, 0xf0, 0x63, 0x00, -0xfe, 0x16, 0x40, 0xe2, 0x6f, 0x41, 0x48, 0x06, 0xe0, 0x6f, 0x52, 0x48, 0x06, 0xe2, 0x6f, 0x23, -0x19, 0x04, 0xe1, 0x6f, 0x14, 0x48, 0x06, 0xe2, 0x6f, 0x24, 0x19, 0x04, 0xe1, 0x7f, 0x81, 0x79, -0x17, 0x9c, 0x5b, 0x2c, 0x19, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x38, 0x86, 0x60, 0x13, 0x68, -0x19, 0x58, 0x4b, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0x90, 0x64, 0x10, 0xe4, 0x65, 0x30, 0xc7, 0x10, -0x0c, 0x7d, 0x19, 0x8c, 0x21, 0xdc, 0xc4, 0x5a, 0x06, 0x16, 0x93, 0x41, 0x10, 0xfe, 0x73, 0x0c, -0x28, 0x19, 0x04, 0x7d, 0x19, 0xcc, 0x31, 0x04, 0x43, 0x68, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, -0x60, 0xe1, 0x1f, 0x15, 0x6b, 0x06, 0x45, 0x30, 0x86, 0xf0, 0x13, 0x72, 0x19, 0x98, 0x4d, 0x06, -0x41, 0xf8, 0xcf, 0x31, 0xb4, 0x64, 0x10, 0x88, 0x66, 0x30, 0xc7, 0x10, 0x0c, 0xa6, 0x19, 0x8c, -0x21, 0x80, 0x05, 0x6a, 0x06, 0xa6, 0x93, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x31, 0x19, 0x04, 0xa6, -0x19, 0xcc, 0x31, 0x04, 0x83, 0x6a, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x55, -0x6d, 0x06, 0x45, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xd9, 0x66, 0xa0, 0x04, -0x63, 0x08, 0x68, 0xb1, 0x97, 0x81, 0x81, 0x65, 0x10, 0x84, 0xff, 0x1c, 0xc3, 0x4d, 0x06, 0x01, -0x6b, 0x06, 0x73, 0x0c, 0xc1, 0x00, 0x9b, 0xc1, 0x18, 0x42, 0x5a, 0xf8, 0x65, 0x60, 0x64, 0x19, -0x04, 0xe1, 0x3f, 0xc7, 0xb0, 0x93, 0x41, 0x00, 0x9b, 0xc1, 0x1c, 0x43, 0x30, 0xd0, 0x66, 0x30, -0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xfd, 0x66, 0x50, 0x04, 0x63, 0x08, 0x71, 0x51, -0x9a, 0x81, 0xa5, 0x65, 0x10, 0x84, 0xff, 0x1c, 0x03, 0x58, 0x06, 0x41, 0x6d, 0x06, 0x73, 0x0c, -0xc1, 0x90, 0x9b, 0xc1, 0x18, 0x82, 0x5c, 0xec, 0x66, 0x60, 0x6d, 0x19, 0x04, 0xe1, 0x3f, 0xc7, -0x40, 0x96, 0x41, 0x90, 0x9b, 0xc1, 0x1c, 0x43, 0x30, 0xf4, 0x66, 0x30, 0x62, 0x70, 0x10, 0x21, -0x08, 0x16, 0xfe, 0x51, 0xa1, 0x67, 0x50, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0x55, 0x7a, 0x06, 0x4a, 0x30, 0x86, 0xa0, 0x17, 0xae, 0x19, 0xd8, 0x5c, 0x06, 0x41, 0xf8, 0xcf, -0x31, 0xa8, 0x65, 0x10, 0xfc, 0x66, 0x30, 0xc7, 0x10, 0x0c, 0xe3, 0x19, 0x8c, 0x21, 0xec, 0x45, -0x6c, 0x06, 0x76, 0x97, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x6e, 0x19, 0x04, 0xe3, 0x19, 0xcc, 0x31, -0x04, 0xc3, 0x79, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x95, 0x7c, 0x06, 0x45, -0x30, 0x86, 0x30, 0x1a, 0xb8, 0x19, 0x18, 0x5f, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0xcc, 0x65, 0x10, -0xa0, 0x67, 0x30, 0xc7, 0x10, 0x0c, 0xec, 0x19, 0x8c, 0x21, 0x90, 0x86, 0x7b, 0x06, 0x06, 0x9a, -0x41, 0x10, 0xfe, 0x73, 0x0c, 0x77, 0x19, 0x04, 0xec, 0x19, 0xcc, 0x31, 0x04, 0x03, 0x7c, 0x06, -0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0x7e, 0x06, 0x45, 0x30, 0x62, 0x70, 0x10, -0x21, 0x08, 0x16, 0xfe, 0x51, 0xf1, 0x67, 0xa0, 0x04, 0x83, 0x0c, 0xc1, 0x5e, 0x06, 0xb9, 0x19, -0x0c, 0x32, 0x8c, 0x07, 0x5f, 0x06, 0xb4, 0x19, 0x98, 0x5d, 0x06, 0x41, 0xf8, 0x5b, 0x5f, 0x06, -0x33, 0x11, 0xfe, 0x83, 0x0c, 0xb6, 0x31, 0x9a, 0x81, 0x6d, 0x06, 0x83, 0x0c, 0xb6, 0x41, 0x9a, -0xc1, 0x6d, 0x06, 0x83, 0x0c, 0xb6, 0x51, 0x9a, 0x01, 0x6e, 0x06, 0x83, 0x0c, 0xbd, 0x20, 0x9a, -0x81, 0x6e, 0x06, 0x16, 0x18, 0xe2, 0x3f, 0xc8, 0xf0, 0x0b, 0xa4, 0x19, 0xe0, 0x66, 0x60, 0xc1, -0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, 0xe2, 0x6f, 0x81, 0x10, 0xfe, -0x73, 0x0c, 0xaa, 0x19, 0xc8, 0xc2, 0x7f, 0x06, 0x83, 0x0c, 0xc1, 0x6a, 0x06, 0xe3, 0x19, 0x58, -0x60, 0x88, 0xff, 0x1c, 0x43, 0x6b, 0x06, 0xb3, 0x20, 0xa2, 0xc1, 0x20, 0x43, 0xe0, 0x9a, 0x81, -0x79, 0x06, 0x16, 0x18, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, -0x73, 0x0c, 0xb3, 0x19, 0xc8, 0x02, 0x8a, 0x06, 0x83, 0x0c, 0x01, 0x6d, 0x06, 0xec, 0x19, 0x8c, -0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x38, 0x1a, 0x0c, 0x81, 0x05, 0xb4, 0x19, 0x88, -0xbf, 0x05, 0xb6, 0x19, 0x80, 0xff, 0x1c, 0x03, 0x6e, 0x06, 0xbc, 0xd0, 0xa2, 0xc1, 0x20, 0x43, -0x90, 0x9b, 0x41, 0x7c, 0x06, 0x16, 0x14, 0xe2, 0x6f, 0x81, 0x6e, 0x06, 0xe0, 0x6f, 0x41, 0x20, -0xfe, 0x66, 0x18, 0xe2, 0x6f, 0xc1, 0x6e, 0x06, 0xe2, 0x6f, 0xc1, 0x6e, 0x06, 0xe0, 0x6f, 0x44, -0x20, 0xfe, 0x16, 0x88, 0x81, 0xf8, 0x9b, 0x20, 0x06, 0xe2, 0x6f, 0x83, 0x18, 0x88, 0xbf, 0xf1, -0x66, 0x80, 0x06, 0xe1, 0x6f, 0xe0, 0x19, 0xe8, 0x45, 0xf8, 0x0f, 0x32, 0xe8, 0x87, 0x7a, 0x06, -0xfd, 0x19, 0x0c, 0x32, 0xe8, 0xc7, 0x7a, 0x06, 0xfe, 0x19, 0x0c, 0x32, 0xe8, 0x07, 0x7b, 0x06, -0xff, 0x19, 0xd8, 0x19, 0x14, 0xe2, 0x6f, 0x66, 0x50, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x1b, 0x1a, -0x20, 0xe2, 0x6f, 0x6b, 0x80, 0x88, 0xbf, 0x05, 0x42, 0xf8, 0x1b, 0x19, 0x10, 0xe2, 0x6f, 0x62, -0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, -0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x77, 0x1a, 0x04, 0x60, 0x60, 0xc1, 0x7c, 0x06, 0xe2, 0x6f, -0x41, 0x7d, 0x06, 0xe0, 0x6f, 0x83, 0x27, 0xfe, 0x16, 0xdc, 0x67, 0x00, 0xfe, 0x16, 0x04, 0xe2, -0x6f, 0x04, 0x21, 0xfe, 0x16, 0xe0, 0x67, 0x20, 0xfe, 0x16, 0xe0, 0x67, 0x00, 0xfe, 0x46, 0x04, -0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x78, 0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, -0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, 0xf8, 0xdb, 0x41, 0x06, 0xe0, 0x6f, 0xfc, 0x19, 0xa4, 0x42, -0xf8, 0x1b, 0x7f, 0x06, 0xbb, 0x11, 0xfe, 0x83, 0x0c, 0x3b, 0xb2, 0xa2, 0x41, 0x8f, 0x06, 0x83, -0x0c, 0x3b, 0xc2, 0xa2, 0x81, 0x8f, 0x06, 0x83, 0x0c, 0x3b, 0xd2, 0xa2, 0xc1, 0x8f, 0x06, 0x86, -0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, 0x0a, 0x88, 0xf8, 0x1b, -0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, 0x28, 0x08, 0xe2, 0x6f, -0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, -0xe1, 0x1f, 0x15, 0xae, 0x06, 0x41, 0x28, 0x58, 0x40, 0xa3, 0x81, 0xf8, 0x5b, 0x60, 0xa3, 0x01, -0xf8, 0xdb, 0xf0, 0x07, 0xe2, 0x6f, 0x01, 0x8e, 0x06, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, -0xe2, 0x6f, 0x41, 0x8e, 0x06, 0xe2, 0x6f, 0x41, 0x8e, 0x06, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, -0x60, 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, -0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x6f, 0x3b, 0x1a, 0xa8, 0x43, 0xf8, -0x0f, 0x32, 0xe0, 0xc9, 0x9a, 0x06, 0x7e, 0x1a, 0x0c, 0x32, 0xe0, 0x09, 0x9b, 0x06, 0x7f, 0x1a, -0x0c, 0x32, 0xe0, 0x49, 0x9b, 0x06, 0xa0, 0x1a, 0x18, 0x3a, 0x10, 0xe2, 0x6f, 0x41, 0x28, 0x80, -0xbf, 0xa1, 0x83, 0x21, 0xfe, 0x06, 0x0a, 0x41, 0xf8, 0xdb, 0x38, 0x0c, 0xe2, 0x6f, 0xe1, 0x20, -0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, -0x08, 0x82, 0x85, 0x7f, 0x54, 0xf6, 0x1a, 0x04, 0xbf, 0x60, 0x81, 0x9c, 0x06, 0xe2, 0x6f, 0x01, -0x9d, 0x06, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, 0x05, 0x76, 0x1a, 0x80, 0xbf, 0x05, 0x81, 0xf8, -0x1b, 0x41, 0x88, 0xbf, 0x05, 0x77, 0x1a, 0x88, 0xbf, 0x05, 0x77, 0x1a, 0x80, 0xbf, 0x11, 0x81, -0xf8, 0x5b, 0x60, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0xdb, 0x70, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x5b, -0x81, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x9b, 0x77, 0x80, 0xbf, 0xe1, 0x69, 0x80, 0x12, 0xe1, 0x3f, -0xc8, 0x60, 0x2b, 0xa9, 0x1a, 0xec, 0x6a, 0x30, 0xc8, 0x60, 0x2b, 0xaa, 0x1a, 0xf0, 0x6a, 0x30, -0xc8, 0x60, 0x2b, 0xab, 0x1a, 0xf4, 0x6a, 0x60, 0x26, 0x41, 0x88, 0xbf, 0x05, 0x7e, 0x00, 0xfe, -0x66, 0x12, 0x86, 0xf8, 0x5b, 0x1f, 0x04, 0xe1, 0x6f, 0x21, 0x31, 0x88, 0xbf, 0xfd, 0x83, 0x20, -0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, -0x08, 0x16, 0xfe, 0x51, 0xd1, 0x6c, 0x10, 0xf4, 0x83, 0x05, 0xb0, 0x1a, 0x88, 0xbf, 0x05, 0xb2, -0x1a, 0x80, 0xbf, 0x0d, 0xfb, 0x20, 0xfe, 0x16, 0xd0, 0x6a, 0x00, 0xfe, 0x16, 0x04, 0xe2, 0x6f, -0x04, 0x21, 0xfe, 0x16, 0xd4, 0x6a, 0x20, 0xfe, 0x16, 0xd4, 0x6a, 0x00, 0xfe, 0x46, 0x04, 0xe2, -0x6f, 0x81, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, -0x26, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xde, 0x01, 0xfe, 0xc6, 0xab, 0x81, 0x59, 0x84, 0xbf, 0xd9, -0x6a, 0x80, 0x27, 0xe1, 0x3f, 0xc8, 0x20, 0x2f, 0xe8, 0x1a, 0xe8, 0x6b, 0x30, 0xc8, 0x20, 0x2f, -0xe9, 0x1a, 0xec, 0x6b, 0x30, 0xc8, 0x20, 0x2f, 0xea, 0x1a, 0xf0, 0x6b, 0x60, 0x65, 0x51, 0x88, -0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, 0x81, 0x88, 0xbf, 0xa5, 0x05, 0x22, -0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, 0x85, 0x20, 0xfe, 0x26, 0x08, 0xe2, -0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, -0xd5, 0x6d, 0x10, 0xf8, 0x84, 0x05, 0xf1, 0x1a, 0x88, 0xbf, 0x05, 0xf3, 0x1a, 0x80, 0xbf, 0x0d, -0x3c, 0x21, 0xfe, 0x16, 0xd4, 0x6b, 0x00, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, -0xd8, 0x6b, 0x20, 0xfe, 0x16, 0xd8, 0x6b, 0x00, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, -0x16, 0x06, 0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, 0xe2, 0x6f, -0x61, 0x10, 0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x63, 0x08, 0x06, 0xdf, 0x06, 0x63, 0x08, 0xc7, -0xda, 0x06, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x80, 0xb2, 0x41, 0xb0, 0xb7, 0xc1, 0x18, 0x02, 0x02, -0xba, 0xc1, 0x18, 0x42, 0xf2, 0xb6, 0x81, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x81, 0xe8, 0x06, -0x63, 0x08, 0x0a, 0xe9, 0x06, 0x63, 0x08, 0xcb, 0xdc, 0x06, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x40, -0x04, 0xa4, 0x1b, 0x8c, 0x21, 0x34, 0xa8, 0x1b, 0x8c, 0x21, 0x38, 0x77, 0x1b, 0x98, 0x10, 0x80, -0xff, 0x20, 0x83, 0x7f, 0xac, 0xc7, 0xdb, 0x06, 0x83, 0x0c, 0x01, 0x6e, 0xbc, 0x6d, 0x30, 0xc8, -0x00, 0x22, 0xed, 0xf1, 0xb6, 0xc1, 0x20, 0x43, 0xa0, 0x1b, 0x6f, 0x1b, 0xd8, 0xcd, 0x06, 0x41, -0xf8, 0x1b, 0xd8, 0x06, 0x06, 0xf9, 0xcf, 0x31, 0xe8, 0x6c, 0x10, 0xb4, 0x6e, 0x30, 0xc8, 0x10, -0xec, 0x6c, 0x20, 0xb7, 0x81, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, -0x48, 0xbf, 0x1b, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x87, 0x14, 0xbe, 0x41, -0x12, 0x0c, 0x32, 0x04, 0x3f, 0x1b, 0xf0, 0x6d, 0x30, 0xc7, 0x10, 0x9c, 0x6d, 0xd0, 0xba, 0xc1, -0x88, 0x41, 0x32, 0x84, 0x20, 0x18, 0x3c, 0xe5, 0x1b, 0xb0, 0x6e, 0x30, 0x3b, 0x01, 0xed, 0x06, -0xb5, 0x1b, 0x0c, 0x32, 0xcc, 0x4e, 0xc8, 0x06, 0x6e, 0x1b, 0x50, 0xc8, 0x06, 0x46, 0x21, 0x90, -0x0d, 0x8c, 0x42, 0xff, 0x1a, 0x18, 0x85, 0xfc, 0x35, 0x30, 0xca, 0x88, 0x81, 0x41, 0x84, 0x20, -0x58, 0xf8, 0x87, 0x18, 0xfc, 0x6e, 0x50, 0x0c, 0x32, 0x14, 0xa5, 0x1b, 0xf0, 0x6d, 0x70, 0x01, -0xb5, 0x36, 0x04, 0xe2, 0x3f, 0xc8, 0x80, 0xa0, 0x6e, 0xe0, 0xb7, 0xc1, 0x05, 0xd4, 0xda, 0x10, -0x80, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x76, 0xbe, 0x41, 0x60, 0x42, 0x10, -0xfe, 0x83, 0x0c, 0x4c, 0xeb, 0x06, 0xa4, 0x1b, 0x5c, 0x40, 0xad, 0x11, 0x81, 0xf8, 0x0f, 0x32, -0x3c, 0xb0, 0x1b, 0x98, 0x6e, 0x70, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x10, 0xcd, 0x6e, -0xa0, 0xba, 0xc1, 0x05, 0xd4, 0xda, 0x10, 0x80, 0xff, 0x20, 0x03, 0x65, 0xbb, 0x01, 0xeb, 0x06, -0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, 0x56, 0xee, 0x06, 0xb0, 0x1b, 0x5c, 0x40, 0xad, -0x25, 0x01, 0xf8, 0x8f, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x41, 0xfe, 0x06, 0xe8, -0x1b, 0xb8, 0x6d, 0xa0, 0xa8, 0x6e, 0x40, 0xbb, 0x41, 0xfc, 0x06, 0xf1, 0x1b, 0x8c, 0x18, 0x30, -0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0xfe, 0x06, 0xe9, 0x1b, 0xbc, 0x6d, 0xb0, 0xac, 0x6e, -0x50, 0xbb, 0x41, 0xfd, 0x06, 0xf2, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, -0xc1, 0xfe, 0x06, 0xea, 0x1b, 0xc0, 0x6d, 0xc0, 0xb0, 0x6e, 0x60, 0xbb, 0x01, 0xfd, 0x06, 0xf3, -0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0xff, 0x06, 0xeb, 0x1b, 0xc4, -0x6d, 0xa0, 0xb4, 0x6e, 0x70, 0xbb, 0x01, 0xfd, 0x06, 0xf4, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, -0x82, 0x85, 0x7f, 0x80, 0x41, 0xff, 0x06, 0xec, 0x1b, 0xc8, 0x6d, 0xb0, 0xb8, 0x6e, 0x80, 0xbb, -0x01, 0xfe, 0x06, 0xf5, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0xff, -0x06, 0xed, 0x1b, 0xcc, 0x6d, 0xc0, 0xbc, 0x6e, 0x90, 0xbb, 0xc1, 0xfd, 0x06, 0xf6, 0x1b, 0x8c, -0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0xff, 0x06, 0xee, 0x1b, 0xd0, 0x6d, 0xa0, -0xc0, 0x6e, 0xa0, 0xbb, 0xc1, 0xfd, 0x06, 0xf7, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, -0x7f, 0x80, 0x01, 0x08, 0x07, 0xef, 0x1b, 0xd4, 0x6d, 0xb0, 0xc4, 0x6e, 0xb0, 0xbb, 0xc1, 0xfe, -0x06, 0xf8, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x41, 0x08, 0x07, 0xf0, -0x1b, 0xd8, 0x6d, 0xc0, 0xc8, 0x6e, 0xc0, 0xbb, 0x81, 0xfe, 0x06, 0xf9, 0x1b, 0x8c, 0x18, 0x30, -0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0x08, 0x07, 0xf1, 0x1b, 0xdc, 0x6d, 0xa0, 0xcc, 0x6e, -0xd0, 0xbb, 0x81, 0xfe, 0x06, 0xfa, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, -0xc1, 0x08, 0x07, 0xf2, 0x1b, 0xe0, 0x6d, 0xb0, 0xd0, 0x6e, 0xe0, 0xbb, 0x81, 0xff, 0x06, 0xfb, -0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0x09, 0x07, 0xf3, 0x1b, 0xe4, -0x6d, 0xc0, 0xd4, 0x6e, 0xf0, 0xbb, 0x41, 0xff, 0x06, 0xfc, 0x1b, 0x98, 0xc2, 0x80, 0xbf, 0x05, -0xac, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xaf, 0x1b, 0x88, 0xbf, -0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xb2, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, -0xc2, 0x80, 0xbf, 0x05, 0xb5, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x0f, 0x32, 0x28, 0xb8, 0x1b, -0xac, 0x6f, 0x30, 0xc8, 0x80, 0xe4, 0x6e, 0xa0, 0xbe, 0xc1, 0x20, 0x43, 0x62, 0xa4, 0x6f, 0x30, -0xc8, 0x70, 0xec, 0x6e, 0xc0, 0xbe, 0xc1, 0x20, 0xc3, 0x82, 0xa8, 0x6f, 0x30, 0x86, 0xd0, 0x06, -0x32, 0x1c, 0x18, 0xf9, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0xec, 0x6e, 0x10, 0xc0, 0x70, 0x30, 0xc8, -0x10, 0xc0, 0x41, 0xfb, 0x06, 0x16, 0xdc, 0x6e, 0x00, 0xfe, 0x63, 0x08, 0x72, 0x50, 0xc2, 0x81, -0xa1, 0x6f, 0x10, 0x84, 0xff, 0x1c, 0x03, 0xf8, 0x06, 0x41, 0x0d, 0x07, 0x83, 0x0c, 0x41, 0xf8, -0x06, 0xf9, 0x1b, 0x58, 0x11, 0x88, 0xbf, 0x31, 0x4d, 0xf8, 0x9b, 0xf3, 0x84, 0xff, 0x88, 0x81, -0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x36, 0xc6, 0x81, 0x30, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, -0xfe, 0xb1, 0x91, 0x71, 0x20, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x69, 0x1c, -0x08, 0x81, 0x8d, 0x6f, 0x10, 0x90, 0xbf, 0x49, 0x54, 0xf8, 0x5b, 0x80, 0x88, 0xff, 0x88, 0x81, -0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x96, 0xc6, 0x81, 0x60, 0x01, 0x21, 0xfe, 0x23, 0x06, 0x06, -0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x1b, 0x07, 0x81, 0x05, 0x81, 0xf8, 0xdb, 0x95, 0x85, 0xbf, -0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6f, 0x1c, 0x08, 0x23, -0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x1c, 0x07, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, -0x58, 0xf8, 0x47, 0x55, 0xc7, 0x81, 0x10, 0xd8, 0xfb, 0x06, 0x01, 0xf9, 0x5b, 0x17, 0x06, 0xe1, -0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x5b, 0x1d, 0x07, 0x82, -0x05, 0x84, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x78, 0x1c, 0x04, 0x16, -0x04, 0xe2, 0x3f, 0xc8, 0xe0, 0x06, 0xff, 0x1b, 0xc8, 0x70, 0x30, 0xc8, 0xc0, 0x06, 0x20, 0x1c, -0xcc, 0x70, 0x30, 0xc8, 0xa0, 0x06, 0x21, 0x1c, 0xc8, 0x70, 0x30, 0xc8, 0x20, 0x0b, 0xfe, 0x1b, -0xc8, 0x70, 0x60, 0x62, 0x10, 0x88, 0xbf, 0x11, 0x68, 0x10, 0xfe, 0x96, 0x06, 0x46, 0xf8, 0x8f, -0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xa0, 0x1c, 0x08, 0x23, 0x06, 0x06, 0x11, 0x82, -0x60, 0xe1, 0x1f, 0x5b, 0x28, 0x07, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x65, -0xca, 0x81, 0x10, 0x18, 0x08, 0x07, 0x01, 0xf9, 0x9b, 0xb2, 0x84, 0xbf, 0x05, 0x88, 0xf8, 0x9b, -0x17, 0x80, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x76, 0xca, 0xc1, 0x60, 0x41, -0x21, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2a, 0x07, 0x81, 0x05, 0x81, -0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xb1, 0x72, -0x10, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0xb1, 0x1c, 0x04, 0x9e, 0xad, 0x70, -0x10, 0x90, 0xbf, 0x51, 0x7b, 0x10, 0xfe, 0x16, 0x4c, 0xe2, 0x6f, 0x41, 0x07, 0xfe, 0x23, 0x06, -0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2c, 0x07, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, 0x18, -0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb5, 0x1c, 0x04, 0x16, 0x04, 0xe2, 0x6f, 0x01, 0x03, 0xfe, -0x16, 0x68, 0xe2, 0x6f, 0x60, 0xc0, 0x06, 0xe0, 0x6f, 0x41, 0x1e, 0x88, 0xbf, 0x0d, 0x01, 0xf8, -0x8f, 0x21, 0x54, 0xb6, 0x1c, 0x8c, 0x21, 0x58, 0xa5, 0x1c, 0x98, 0x10, 0x80, 0xff, 0x1c, 0x03, -0x18, 0x07, 0x41, 0x2d, 0x07, 0x63, 0x08, 0x8e, 0x2e, 0x07, 0x63, 0x08, 0x4f, 0x2a, 0x07, 0x26, -0x04, 0xe0, 0x3f, 0xc7, 0x40, 0x04, 0xbc, 0x1c, 0x8c, 0x21, 0x24, 0xbe, 0x1c, 0x8c, 0x21, 0x28, -0xad, 0x1c, 0x98, 0x10, 0x80, 0xbf, 0x11, 0x84, 0xf8, 0x8f, 0x21, 0x04, 0xe2, 0x1c, 0x8c, 0x21, -0x08, 0xb1, 0x1c, 0x98, 0x10, 0x80, 0xff, 0x70, 0x44, 0x30, 0xc7, 0x01, 0xe1, 0x1f, 0x27, 0x98, -0x77, 0xc1, 0xb9, 0x15, 0xec, 0x71, 0x80, 0xb6, 0xc7, 0x41, 0x10, 0x02, 0x17, 0x98, 0x7b, 0x41, -0x83, 0xd3, 0x0d, 0x7c, 0x1c, 0x04, 0xc7, 0x74, 0x43, 0x1f, 0x07, 0x15, 0x32, 0xc7, 0x10, 0x05, -0xee, 0x1c, 0xcc, 0x31, 0xd8, 0x71, 0x30, 0xac, 0x73, 0x30, 0xc8, 0x10, 0xdc, 0x71, 0xf0, 0xca, -0x81, 0x05, 0x83, 0xf8, 0x9b, 0x14, 0xca, 0x81, 0xf8, 0x5b, 0x10, 0x88, 0xff, 0x18, 0xc2, 0x40, -0xcf, 0x81, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0xe4, 0x1c, 0x58, 0x10, 0x88, 0xbf, 0x0d, 0x01, -0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x64, 0x20, 0x1d, 0x14, 0x23, 0x06, 0x06, -0x11, 0x82, 0x60, 0xe1, 0x1f, 0x59, 0x48, 0x07, 0xc4, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, -0xc7, 0x35, 0xd2, 0x81, 0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x96, 0x2c, 0x07, 0x41, 0x5c, 0x60, -0xee, 0x05, 0x0d, 0x5a, 0x12, 0x88, 0xbf, 0x05, 0xaf, 0x1c, 0x80, 0xbf, 0x05, 0x90, 0xf8, 0x5b, -0x40, 0xcb, 0x01, 0xf8, 0x9b, 0x44, 0xcb, 0x81, 0xf8, 0x9b, 0x2d, 0x07, 0x41, 0xf8, 0x1b, 0x35, -0xcb, 0x81, 0xf8, 0xdb, 0x2d, 0x07, 0x41, 0xf8, 0x5f, 0x60, 0xde, 0x05, 0xe7, 0xd6, 0x2f, 0x07, -0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x8e, 0x21, 0xd8, 0xc4, 0x3e, 0x07, 0x06, 0xce, 0x41, 0x10, -0xfe, 0x73, 0x0c, 0xb7, 0x1c, 0x04, 0x2c, 0x1d, 0xcc, 0x31, 0x04, 0x03, 0x4c, 0x07, 0x63, 0x08, -0x37, 0xe1, 0xcf, 0x81, 0x91, 0x73, 0x10, 0x84, 0xff, 0x1c, 0xc3, 0x2e, 0x07, 0x01, 0x4c, 0x07, -0x73, 0x0c, 0xc1, 0x40, 0xd3, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xf5, 0xd3, -0x41, 0x11, 0x8c, 0x21, 0xfc, 0x44, 0x49, 0x07, 0x96, 0xce, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0xe0, -0x1c, 0x04, 0x35, 0x1d, 0xcc, 0x31, 0x04, 0x43, 0x4e, 0x07, 0x63, 0x08, 0x60, 0xb1, 0xd3, 0x81, -0xb5, 0x73, 0x10, 0x84, 0xff, 0x1c, 0x03, 0x39, 0x07, 0x41, 0x4e, 0x07, 0x73, 0x0c, 0xc1, 0xd0, -0xd3, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x85, 0xd6, 0x41, 0x11, 0x8c, 0x18, -0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x69, 0x1d, 0x28, 0xc1, 0x18, 0x02, 0x5a, 0xb8, 0x74, -0x60, 0xf3, 0x1c, 0x04, 0xe1, 0x3f, 0xc7, 0xa0, 0xce, 0x41, 0xf0, 0xd3, 0xc1, 0x1c, 0x43, 0x30, -0x8c, 0x75, 0x30, 0x86, 0x90, 0x16, 0x31, 0x1d, 0xd8, 0x3d, 0x07, 0x41, 0xf8, 0xcf, 0x31, 0xb8, -0x73, 0x10, 0x8c, 0x75, 0x30, 0xc7, 0x10, 0x0c, 0x67, 0x1d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, -0x85, 0x7f, 0x54, 0x72, 0x1d, 0x14, 0xc1, 0x18, 0x42, 0x5c, 0xe0, 0x74, 0x60, 0xfc, 0x1c, 0x04, -0xe1, 0x3f, 0xc7, 0x30, 0xcf, 0x41, 0x80, 0xd6, 0xc1, 0x1c, 0x43, 0x30, 0xb0, 0x75, 0x30, 0x86, -0x20, 0x17, 0x6e, 0x1d, 0x18, 0x48, 0x07, 0x41, 0xf8, 0xcf, 0x31, 0xdc, 0x73, 0x10, 0xb0, 0x75, -0x30, 0xc7, 0x10, 0x0c, 0x70, 0x1d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x7b, -0x1d, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xc5, 0xd7, 0x81, 0x12, 0x8c, -0x21, 0xe8, 0x45, 0x58, 0x07, 0x66, 0xd2, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0xfd, 0x1c, 0x04, 0x72, -0x1d, 0xcc, 0x31, 0x04, 0x83, 0x5d, 0x07, 0x63, 0x08, 0x7b, 0x41, 0xd6, 0x81, 0xa9, 0x74, 0x10, -0x84, 0xff, 0x1c, 0x43, 0x48, 0x07, 0x81, 0x5d, 0x07, 0x73, 0x0c, 0xc1, 0xa0, 0xd7, 0xc1, 0x88, -0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x55, 0xda, 0x41, 0x11, 0x8c, 0x21, 0x8c, 0xc6, 0x5a, -0x07, 0xf6, 0xd2, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x26, 0x1d, 0x04, 0x7b, 0x1d, 0xcc, 0x31, 0x04, -0xc3, 0x5f, 0x07, 0x63, 0x08, 0xa4, 0x11, 0xda, 0x81, 0xcd, 0x74, 0x10, 0x84, 0xff, 0x1c, 0x83, -0x4a, 0x07, 0xc1, 0x5f, 0x07, 0x73, 0x0c, 0xc1, 0x30, 0xda, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, -0x58, 0xf8, 0x47, 0xe5, 0xda, 0x41, 0x11, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, -0xaf, 0x1d, 0x28, 0xc1, 0x20, 0x43, 0xe0, 0xd2, 0x01, 0x5b, 0x07, 0x83, 0x0c, 0xe3, 0xf1, 0xd2, -0xc1, 0x59, 0x07, 0x96, 0xd2, 0x41, 0x10, 0xfe, 0x06, 0xd3, 0xc1, 0x4c, 0x84, 0xff, 0x20, 0x83, -0x6d, 0xd8, 0x74, 0x90, 0xd6, 0xc1, 0x20, 0x83, 0x6d, 0xdc, 0x74, 0xa0, 0xd6, 0xc1, 0x20, 0x83, -0x6d, 0xe0, 0x74, 0xb0, 0xd6, 0xc1, 0x20, 0x43, 0x2f, 0xd4, 0x74, 0xd0, 0xd6, 0x81, 0x05, 0x86, -0xf8, 0x0f, 0x32, 0xfc, 0xc2, 0x4d, 0x07, 0x6b, 0x1d, 0x58, 0x70, 0x88, 0xbf, 0x0d, 0x01, 0xf8, -0xdb, 0xa0, 0x88, 0xbf, 0x19, 0x8a, 0xf8, 0x5b, 0x20, 0x84, 0xff, 0x1c, 0x43, 0x4f, 0x07, 0xb2, -0x20, 0xdb, 0xc1, 0x20, 0x43, 0xe0, 0xd3, 0x81, 0x5d, 0x07, 0x16, 0x18, 0xe2, 0x3f, 0xc7, 0x00, -0xd6, 0xc1, 0x2c, 0xd4, 0x76, 0x30, 0xc8, 0x10, 0x84, 0x75, 0x90, 0xd7, 0x81, 0x05, 0x86, 0xf8, -0x1b, 0x41, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x1c, 0x83, 0x59, 0x07, 0xb2, -0xb0, 0xdb, 0xc1, 0x20, 0x43, 0x70, 0xd6, 0xc1, 0x5f, 0x07, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, -0xe1, 0x1f, 0xd5, 0x7a, 0x07, 0x43, 0x60, 0xc1, 0x59, 0x07, 0xe2, 0x6f, 0x41, 0x5a, 0x07, 0xe0, -0x3f, 0xc7, 0xb0, 0xd6, 0x01, 0x2f, 0x80, 0x77, 0x30, 0xc8, 0x10, 0xb0, 0x75, 0x40, 0xda, 0x81, -0x05, 0x85, 0xf8, 0x5b, 0xd0, 0xd6, 0x01, 0xf8, 0x5b, 0x10, 0x88, 0xbf, 0x19, 0x86, 0xf8, 0x5b, -0xe0, 0xd6, 0x81, 0xf8, 0x5b, 0xe0, 0xd6, 0x01, 0xf8, 0x1b, 0x11, 0x88, 0xbf, 0x05, 0x62, 0x20, -0xfe, 0x26, 0x88, 0x81, 0xf8, 0xdb, 0x20, 0x06, 0xe2, 0x6f, 0x6f, 0x1d, 0xa0, 0x41, 0xf8, 0xdb, -0x5c, 0x07, 0x7a, 0x11, 0xfe, 0x83, 0x0c, 0xfa, 0xd1, 0xd7, 0x01, 0x6c, 0x07, 0x83, 0x0c, 0xfa, -0xe1, 0xd7, 0x41, 0x6c, 0x07, 0x83, 0x0c, 0xfa, 0xf1, 0xd7, 0x81, 0x6c, 0x07, 0x76, 0x06, 0x85, -0xf8, 0x9b, 0x19, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x86, 0x06, 0x88, 0xf8, 0xdb, 0x1a, 0x20, -0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x46, 0x06, 0x84, 0xf8, 0x9b, 0x18, 0x08, 0xe2, 0x6f, 0x82, 0x20, -0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, -0x95, 0x8a, 0x07, 0x01, 0x18, 0x58, 0x60, 0xda, 0x81, 0xf8, 0x5b, 0x80, 0xda, 0x01, 0xf8, 0xdb, -0xe0, 0x89, 0xbf, 0x05, 0xaa, 0x1d, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, -0xab, 0x1d, 0x88, 0xbf, 0x05, 0xab, 0x1d, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x80, 0x89, 0xbf, -0x05, 0x1e, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x05, 0x1f, 0xf8, 0x5b, 0xa1, 0x89, 0xbf, 0x05, 0x60, -0x00, 0xfe, 0x76, 0x90, 0x01, 0xf8, 0xdb, 0x6b, 0x07, 0xa9, 0x10, 0xfe, 0xf6, 0xda, 0xc1, 0x6e, -0x84, 0xff, 0x20, 0xc3, 0x8e, 0xf8, 0x76, 0x00, 0xdf, 0xc1, 0x20, 0xc3, 0x8e, 0xfc, 0x76, 0x10, -0xdf, 0xc1, 0x20, 0xc3, 0x8e, 0x80, 0x77, 0x20, 0xdf, 0x81, 0xa1, 0x42, 0x21, 0xfe, 0x76, 0x0a, -0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa5, 0x02, 0x22, 0xfe, 0xc6, 0x0a, 0x88, 0xf8, 0x5b, 0x20, -0x84, 0xbf, 0x95, 0x02, 0x21, 0xfe, 0x36, 0x0a, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x82, -0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xb5, 0xe6, 0x41, -0x10, 0x0a, 0x16, 0x9c, 0x77, 0x20, 0xfe, 0x16, 0xa4, 0x77, 0x00, 0xfe, 0x36, 0xfc, 0x81, 0xf8, -0x5b, 0xb0, 0xde, 0x01, 0xf8, 0x5b, 0x10, 0x88, 0xbf, 0x11, 0x84, 0xf8, 0x5b, 0xc0, 0xde, 0x81, -0xf8, 0x5b, 0xc0, 0xde, 0x01, 0xf8, 0x1b, 0x11, 0x88, 0xbf, 0x05, 0x98, 0xf8, 0x5b, 0x18, 0x04, -0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0xa1, 0x89, 0xbf, 0x85, 0x41, 0x00, -0xfe, 0x16, 0x06, 0x07, 0xf8, 0x9b, 0x7b, 0x07, 0xea, 0x10, 0xfe, 0x83, 0x0c, 0x78, 0xe2, 0xdf, -0x41, 0x8c, 0x07, 0x83, 0x0c, 0x78, 0xf2, 0xdf, 0x81, 0x8c, 0x07, 0x83, 0x0c, 0x78, 0x02, 0xe2, -0xc1, 0x8c, 0x07, 0x86, 0x0e, 0x84, 0xf8, 0x5b, 0x10, 0x0a, 0xe0, 0x6f, 0xe8, 0x60, 0x88, 0xbf, -0x81, 0x42, 0x10, 0xfe, 0x36, 0x0e, 0x83, 0xf8, 0x5b, 0x38, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, -0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x55, -0xaa, 0x07, 0xc1, 0x2f, 0x58, 0x50, 0xe2, 0x81, 0xf8, 0x5b, 0x70, 0xe2, 0x01, 0xf8, 0xdb, 0xd0, -0x0b, 0xe2, 0x6f, 0x41, 0x8a, 0x07, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0x81, -0x8a, 0x07, 0xe2, 0x6f, 0x81, 0x8a, 0x07, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, -0x5e, 0x00, 0xfe, 0x36, 0x5c, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, -0xfe, 0xe6, 0x1d, 0xe0, 0x6f, 0x2b, 0x1e, 0xa0, 0x44, 0xf8, 0x0f, 0x32, 0xd8, 0x0a, 0x8f, 0x07, -0x6e, 0x1e, 0x0c, 0x32, 0xd8, 0x4a, 0x8f, 0x07, 0x6f, 0x1e, 0x0c, 0x32, 0xd8, 0x8a, 0x8f, 0x07, -0x70, 0x1e, 0x98, 0x49, 0x10, 0xe2, 0x6f, 0x81, 0x1f, 0x80, 0xbf, 0x99, 0x84, 0x21, 0xfe, 0xd6, -0x07, 0x41, 0xf8, 0x5b, 0x48, 0x0c, 0xe2, 0x6f, 0xff, 0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, -0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0xe7, -0x1e, 0x04, 0xfd, 0x60, 0xc1, 0x98, 0x07, 0xe2, 0x6f, 0x41, 0x99, 0x07, 0xe0, 0x6f, 0xc3, 0x3e, -0x88, 0xbf, 0x05, 0x67, 0x1e, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, 0x68, -0x1e, 0x88, 0xbf, 0x05, 0x68, 0x1e, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x60, 0x89, 0xbf, 0x79, -0x01, 0xf8, 0xdb, 0x70, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x5b, 0x81, 0x89, 0xbf, 0x79, 0x01, 0xf8, -0x9b, 0x77, 0x80, 0xbf, 0xbd, 0x79, 0x60, 0x16, 0xe1, 0x6f, 0x69, 0x1e, 0xe0, 0x49, 0xf8, 0x0f, -0x32, 0xc8, 0xcb, 0x9e, 0x07, 0xad, 0x1e, 0x0c, 0x32, 0xc8, 0x0b, 0x9f, 0x07, 0xae, 0x1e, 0x0c, -0x32, 0xc8, 0x4b, 0x9f, 0x07, 0xaf, 0x1e, 0x58, 0x59, 0x14, 0xe2, 0x6f, 0x64, 0x51, 0x88, 0xbf, -0x09, 0x01, 0xf8, 0x9b, 0x59, 0x20, 0xe2, 0x6f, 0x69, 0x81, 0x88, 0xbf, 0x05, 0x42, 0xf8, 0x9b, -0x58, 0x10, 0xe2, 0x6f, 0x60, 0x21, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, -0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x28, 0x1f, 0x04, 0x3e, 0x61, -0x01, 0xa9, 0x07, 0xe2, 0x6f, 0x81, 0xa9, 0x07, 0xe0, 0x6f, 0x03, 0x4f, 0x88, 0xbf, 0x05, 0xa8, -0x1e, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, 0xa9, 0x1e, 0x88, 0xbf, 0x05, -0xa9, 0x1e, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x80, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x36, -0x64, 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x15, 0x9a, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x61, -0x70, 0x80, 0xff, 0x18, 0x82, 0xf1, 0xf2, 0xc1, 0x18, 0xc2, 0xe1, 0xef, 0x81, 0x09, 0x01, 0xf8, -0xcf, 0x31, 0xec, 0x7a, 0x10, 0xb8, 0x7c, 0x30, 0x86, 0x80, 0xcc, 0x7c, 0x30, 0x86, 0x90, 0x88, -0x7c, 0x60, 0x42, 0x00, 0xfe, 0x73, 0x0c, 0x44, 0x50, 0xf3, 0xc1, 0x18, 0x82, 0x72, 0xf3, 0xc1, -0x18, 0xc2, 0x62, 0xf2, 0x81, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0xc1, 0xcd, 0x07, 0x63, 0x08, -0xcd, 0xce, 0x07, 0x63, 0x08, 0x8e, 0xca, 0x07, 0x26, 0x04, 0xe0, 0x3f, 0xc8, 0xe0, 0x1f, 0xeb, -0x21, 0xf2, 0xc1, 0x20, 0x43, 0x80, 0x1b, 0x22, 0x1f, 0x0c, 0x32, 0x80, 0x48, 0x7b, 0x88, 0x7c, -0x30, 0xc8, 0x10, 0xe8, 0x86, 0xc8, 0x07, 0xa6, 0xee, 0x41, 0x10, 0xfe, 0x36, 0xef, 0x81, 0x41, -0xfe, 0x73, 0x0c, 0xed, 0x1e, 0x04, 0x60, 0x1f, 0x0c, 0x32, 0x04, 0xee, 0x1e, 0x94, 0x7c, 0x60, -0x4c, 0x20, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x92, 0xdc, 0x07, 0x45, 0x30, -0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x21, 0xd1, 0x7d, 0x90, 0x04, 0x83, 0x0c, 0x81, 0xbc, -0x07, 0x2f, 0x1f, 0xcc, 0x31, 0x04, 0xfa, 0x1e, 0x80, 0x7d, 0x30, 0x62, 0x90, 0x0c, 0x21, 0x08, -0x06, 0x0f, 0xde, 0x07, 0x3f, 0x1f, 0xcc, 0x4e, 0x70, 0xf6, 0x01, 0xda, 0x07, 0x18, 0x10, 0x03, -0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x28, 0x48, 0x85, 0x2d, 0xc3, 0x14, 0xa4, 0xc2, -0x96, 0xa1, 0x0a, 0x52, 0x61, 0xcb, 0x70, 0x05, 0xa9, 0xb0, 0x65, 0x50, 0x9f, 0x20, 0x15, 0xb6, -0x0c, 0xeb, 0x13, 0xa4, 0xc2, 0x96, 0x81, 0x7d, 0x82, 0x54, 0xd8, 0x32, 0xb4, 0x4f, 0x90, 0x0a, -0x5b, 0x06, 0xd0, 0x0b, 0x52, 0x61, 0xcb, 0x10, 0x7a, 0x41, 0x2a, 0x6c, 0x19, 0x44, 0x2f, 0x48, -0x85, 0x2d, 0xc3, 0xe8, 0x05, 0xa9, 0xb0, 0x65, 0xa0, 0xd9, 0x20, 0x48, 0x85, 0x2d, 0x43, 0xcd, -0x06, 0x41, 0x2a, 0x6c, 0x19, 0x6c, 0x36, 0x08, 0x52, 0x61, 0xcb, 0x70, 0xb3, 0x41, 0x90, 0x0a, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x0e, -0x10, 0x22, 0x84, 0x01, 0xad, 0x07, 0x28, 0x70, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x0c, -0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x12, 0x03, 0x94, 0x78, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, -0x00, 0x00, 0x77, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, -0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0f, 0x00, -0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x19, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x01, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, -0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x00, 0x24, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x19, 0x00, -0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x00, 0x00, 0x7b, 0x00, -0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x95, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xa8, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xbb, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xce, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xe1, 0x00, -0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xf2, 0x00, -0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x03, 0x01, -0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x1a, 0x01, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x2d, 0x01, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x2d, 0x01, -0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x48, 0x01, -0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x48, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x5c, 0x01, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x5c, 0x01, -0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, -0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x0c, 0x00, 0x00, 0x6a, 0x00, -0x00, 0x00, 0x12, 0x03, 0x94, 0x39, 0x03, 0x00, 0x00, 0x00, 0x5f, 0x5f, 0x61, 0x69, 0x72, 0x5f, -0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x69, -0x6e, 0x43, 0x53, 0x5f, 0x5a, 0x34, 0x65, 0x61, 0x73, 0x75, 0x4e, 0x35, 0x6d, 0x65, 0x74, 0x61, -0x6c, 0x39, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x49, 0x66, 0x4c, 0x4e, 0x53, -0x5f, 0x36, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x45, 0x32, 0x45, 0x76, 0x45, 0x45, 0x4e, 0x53, -0x30, 0x5f, 0x49, 0x66, 0x4c, 0x53, 0x31, 0x5f, 0x30, 0x45, 0x76, 0x45, 0x45, 0x52, 0x55, 0x31, -0x31, 0x4d, 0x54, 0x4c, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4b, 0x31, 0x31, 0x47, -0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x44, 0x61, 0x74, 0x61, 0x44, 0x76, 0x33, 0x5f, 0x6a, 0x53, -0x37, 0x5f, 0x53, 0x37, 0x5f, 0x61, 0x69, 0x72, 0x2e, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x74, -0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x32, 0x64, 0x2e, 0x76, 0x34, 0x66, 0x33, 0x32, 0x61, -0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x69, 0x6e, 0x2e, 0x76, 0x33, 0x66, -0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, -0x76, 0x33, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, -0x69, 0x6e, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, -0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, -0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, -0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x62, 0x73, 0x2e, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, -0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x61, 0x74, 0x75, 0x72, 0x61, 0x74, 0x65, 0x2e, 0x76, -0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x62, -0x73, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x67, 0x61, 0x74, 0x68, 0x65, -0x72, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x32, 0x64, 0x2e, 0x76, 0x34, 0x66, -0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x6f, 0x72, -0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, -0x74, 0x2e, 0x66, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x2e, 0x75, 0x2e, 0x76, 0x32, 0x69, 0x33, -0x32, 0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x61, 0x69, 0x72, 0x36, 0x34, 0x2d, -0x61, 0x70, 0x70, 0x6c, 0x65, 0x2d, 0x6d, 0x61, 0x63, 0x6f, 0x73, 0x78, 0x31, 0x30, 0x2e, 0x31, -0x34, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00 \ No newline at end of file +0x4d, 0x54, 0x4c, 0x42, 0x01, 0x80, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xb2, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xb0, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x4e, 0x41, 0x4d, 0x45, 0x07, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x53, 0x00, 0x54, 0x59, 0x50, + 0x45, 0x01, 0x00, 0x02, 0x48, 0x41, 0x53, 0x48, 0x20, 0x00, 0xff, 0xc3, 0x7b, 0x71, 0xa3, 0xa3, + 0x10, 0xa1, 0x68, 0xe1, 0xe0, 0x76, 0x91, 0xea, 0x2b, 0x86, 0xc6, 0x34, 0x64, 0x13, 0x78, 0x04, + 0x8a, 0x06, 0xf6, 0xa9, 0x7b, 0x80, 0xec, 0x0e, 0x4e, 0x3f, 0x4f, 0x46, 0x46, 0x54, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x45, 0x52, 0x53, 0x08, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x4d, 0x44, 0x53, 0x5a, 0x08, 0x00, 0xb0, 0x3e, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x55, 0x55, 0x49, 0x44, 0x10, 0x00, 0xa8, 0xbb, + 0x4f, 0x33, 0x18, 0xd7, 0x30, 0xac, 0x94, 0x77, 0xc2, 0x6b, 0x4f, 0xaa, 0xac, 0xc3, 0x45, 0x4e, + 0x44, 0x54, 0x08, 0x00, 0x00, 0x00, 0x45, 0x4e, 0x44, 0x54, 0x08, 0x00, 0x00, 0x00, 0x45, 0x4e, + 0x44, 0x54, 0xde, 0xc0, 0x17, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x94, 0x3e, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x42, 0x43, 0xc0, 0xde, 0x35, 0x14, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x62, 0x0c, 0x30, 0x24, 0x80, 0x10, 0x05, 0xc8, 0x14, 0x00, 0x00, 0x00, 0x21, 0x0c, + 0x00, 0x00, 0xbe, 0x0e, 0x00, 0x00, 0x0b, 0x02, 0x21, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, + 0x00, 0x00, 0x07, 0x81, 0x23, 0x91, 0x41, 0xc8, 0x04, 0x49, 0x06, 0x10, 0x32, 0x39, 0x92, 0x01, + 0x84, 0x0c, 0x25, 0x05, 0x08, 0x19, 0x1e, 0x04, 0x8b, 0x62, 0x80, 0x18, 0x45, 0x02, 0x42, 0x92, + 0x0b, 0x42, 0xc4, 0x10, 0x32, 0x14, 0x38, 0x08, 0x18, 0x4b, 0x0a, 0x32, 0x62, 0x88, 0x48, 0x90, + 0x14, 0x20, 0x43, 0x46, 0x88, 0xa5, 0x00, 0x19, 0x32, 0x42, 0x04, 0x49, 0x0e, 0x90, 0x11, 0x23, + 0xc4, 0x50, 0x41, 0x51, 0x81, 0x8c, 0xe1, 0x83, 0xe5, 0x8a, 0x04, 0x31, 0x46, 0x06, 0x51, 0x18, + 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x1b, 0xc8, 0x25, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x01, 0x58, + 0x03, 0x40, 0x22, 0xc6, 0xe1, 0x1d, 0xe4, 0x41, 0x1e, 0xca, 0x61, 0x1c, 0xe8, 0x81, 0x1d, 0xf2, + 0xa1, 0x0d, 0xe4, 0xe1, 0x1d, 0xea, 0xc1, 0x1d, 0xc8, 0xa1, 0x1c, 0xc8, 0xa1, 0x0d, 0xc8, 0x21, + 0x1d, 0xec, 0x21, 0x1d, 0xc8, 0xa1, 0x1c, 0xda, 0x60, 0x1e, 0xe2, 0x41, 0x1e, 0xe8, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0x30, 0x87, 0x70, 0x60, 0x87, + 0x79, 0x28, 0x07, 0x80, 0x20, 0x87, 0x74, 0x98, 0x87, 0x70, 0x10, 0x07, 0x76, 0x28, 0x87, 0x36, + 0xa0, 0x87, 0x70, 0x48, 0x07, 0x76, 0x68, 0x83, 0x71, 0x08, 0x07, 0x76, 0x60, 0x87, 0x79, 0x00, + 0xcc, 0x21, 0x1c, 0xd8, 0x61, 0x1e, 0xca, 0x01, 0x20, 0xd8, 0xa1, 0x1c, 0xe6, 0x61, 0x1e, 0xda, + 0x00, 0x1e, 0xe4, 0xa1, 0x1c, 0xc6, 0x21, 0x1d, 0xe6, 0xa1, 0x1c, 0xda, 0xc0, 0x1c, 0xe0, 0xa1, + 0x1d, 0xc2, 0x81, 0x1c, 0x00, 0x73, 0x08, 0x07, 0x76, 0x98, 0x87, 0x72, 0x00, 0x08, 0x77, 0x78, + 0x87, 0x36, 0x30, 0x07, 0x79, 0x08, 0x87, 0x76, 0x28, 0x87, 0x36, 0x80, 0x87, 0x77, 0x48, 0x07, + 0x77, 0xa0, 0x87, 0x72, 0x90, 0x87, 0x36, 0x28, 0x07, 0x76, 0x48, 0x87, 0x76, 0x00, 0xe8, 0x41, + 0x1e, 0xea, 0xa1, 0x1c, 0x80, 0xc1, 0x1d, 0xde, 0xa1, 0x0d, 0xcc, 0x41, 0x1e, 0xc2, 0xa1, 0x1d, + 0xca, 0xa1, 0x0d, 0xe0, 0xe1, 0x1d, 0xd2, 0xc1, 0x1d, 0xe8, 0xa1, 0x1c, 0xe4, 0xa1, 0x0d, 0xca, + 0x81, 0x1d, 0xd2, 0xa1, 0x1d, 0xda, 0xc0, 0x1d, 0xde, 0xc1, 0x1d, 0xda, 0x80, 0x1d, 0xca, 0x21, + 0x1c, 0xcc, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x20, 0x1d, 0xdc, 0xc1, 0x1c, 0xe6, 0xa1, 0x0d, + 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, 0xa8, 0x87, + 0x72, 0x00, 0x08, 0x77, 0x78, 0x87, 0x36, 0x50, 0x87, 0x7a, 0x68, 0x07, 0x78, 0x68, 0x03, 0x7a, + 0x08, 0x07, 0x71, 0x60, 0x87, 0x72, 0x98, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, 0xa1, 0x1c, + 0x00, 0xc2, 0x1d, 0xde, 0xa1, 0x0d, 0xdc, 0x21, 0x1c, 0xdc, 0x61, 0x1e, 0xda, 0xc0, 0x1c, 0xe0, + 0xa1, 0x0d, 0xda, 0x21, 0x1c, 0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, + 0x70, 0x87, 0x77, 0x68, 0x83, 0x79, 0x48, 0x87, 0x73, 0x70, 0x87, 0x72, 0x20, 0x87, 0x36, 0xd0, + 0x87, 0x72, 0x90, 0x87, 0x77, 0x98, 0x87, 0x36, 0x30, 0x07, 0x78, 0x68, 0x83, 0x76, 0x08, 0x07, + 0x7a, 0x40, 0x07, 0x80, 0x1e, 0xe4, 0xa1, 0x1e, 0xca, 0x01, 0x20, 0xdc, 0xe1, 0x1d, 0xda, 0x80, + 0x1e, 0xe4, 0x21, 0x1c, 0xe0, 0x01, 0x1e, 0xd2, 0xc1, 0x1d, 0xce, 0xa1, 0x0d, 0xda, 0x21, 0x1c, + 0xe8, 0x01, 0x1d, 0x00, 0x7a, 0x90, 0x87, 0x7a, 0x28, 0x07, 0x80, 0x98, 0x07, 0x7a, 0x08, 0x87, + 0x71, 0x58, 0x87, 0x36, 0x80, 0x07, 0x79, 0x78, 0x07, 0x7a, 0x28, 0x87, 0x71, 0xa0, 0x87, 0x77, + 0x90, 0x87, 0x36, 0x10, 0x87, 0x7a, 0x30, 0x07, 0x73, 0x28, 0x07, 0x79, 0x68, 0x83, 0x79, 0x48, + 0x07, 0x7d, 0x28, 0x07, 0x00, 0x0f, 0x00, 0xa2, 0x1e, 0xdc, 0x61, 0x1e, 0xc2, 0xc1, 0x1c, 0xca, + 0xa1, 0x0d, 0xcc, 0x01, 0x1e, 0xda, 0xa0, 0x1d, 0xc2, 0x81, 0x1e, 0xd0, 0x01, 0xa0, 0x07, 0x79, + 0xa8, 0x87, 0x72, 0x00, 0x88, 0x7a, 0x98, 0x87, 0x72, 0x68, 0x83, 0x79, 0x78, 0x07, 0x73, 0xa0, + 0x87, 0x36, 0x30, 0x07, 0x76, 0x78, 0x87, 0x70, 0xa0, 0x07, 0xc0, 0x1c, 0xc2, 0x81, 0x1d, 0xe6, + 0xa1, 0x1c, 0x80, 0x0d, 0x84, 0x20, 0x00, 0xd5, 0x86, 0x65, 0x18, 0x80, 0x04, 0x58, 0x80, 0x2a, + 0x48, 0x03, 0x50, 0xd8, 0x20, 0x2e, 0xc4, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x80, 0x44, 0x8c, 0xc3, + 0x3b, 0xc8, 0x83, 0x3c, 0x94, 0xc3, 0x38, 0xd0, 0x03, 0x3b, 0xe4, 0x43, 0x1b, 0xc8, 0xc3, 0x3b, + 0xd4, 0x83, 0x3b, 0x90, 0x43, 0x39, 0x90, 0x43, 0x1b, 0x90, 0x43, 0x3a, 0xd8, 0x43, 0x3a, 0x90, + 0x43, 0x39, 0xb4, 0xc1, 0x3c, 0xc4, 0x83, 0x3c, 0xd0, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x60, 0x0e, 0xe1, 0xc0, 0x0e, 0xf3, 0x50, 0x0e, 0x00, 0x41, + 0x0e, 0xe9, 0x30, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x6d, 0x40, 0x0f, 0xe1, 0x90, 0x0e, + 0xec, 0xd0, 0x06, 0xe3, 0x10, 0x0e, 0xec, 0xc0, 0x0e, 0xf3, 0x00, 0x98, 0x43, 0x38, 0xb0, 0xc3, + 0x3c, 0x94, 0x03, 0x40, 0xb0, 0x43, 0x39, 0xcc, 0xc3, 0x3c, 0xb4, 0x01, 0x3c, 0xc8, 0x43, 0x39, + 0x8c, 0x43, 0x3a, 0xcc, 0x43, 0x39, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x3b, 0x84, 0x03, 0x39, 0x00, + 0xe6, 0x10, 0x0e, 0xec, 0x30, 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, 0x0e, 0x6d, 0x60, 0x0e, 0xf2, + 0x10, 0x0e, 0xed, 0x50, 0x0e, 0x6d, 0x00, 0x0f, 0xef, 0x90, 0x0e, 0xee, 0x40, 0x0f, 0xe5, 0x20, + 0x0f, 0x6d, 0x50, 0x0e, 0xec, 0x90, 0x0e, 0xed, 0x00, 0xd0, 0x83, 0x3c, 0xd4, 0x43, 0x39, 0x00, + 0x83, 0x3b, 0xbc, 0x43, 0x1b, 0x98, 0x83, 0x3c, 0x84, 0x43, 0x3b, 0x94, 0x43, 0x1b, 0xc0, 0xc3, + 0x3b, 0xa4, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xc8, 0x43, 0x1b, 0x94, 0x03, 0x3b, 0xa4, 0x43, 0x3b, + 0xb4, 0x81, 0x3b, 0xbc, 0x83, 0x3b, 0xb4, 0x01, 0x3b, 0x94, 0x43, 0x38, 0x98, 0x03, 0x40, 0xb8, + 0xc3, 0x3b, 0xb4, 0x41, 0x3a, 0xb8, 0x83, 0x39, 0xcc, 0x43, 0x1b, 0x98, 0x03, 0x3c, 0xb4, 0x41, + 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, 0xee, 0xf0, + 0x0e, 0x6d, 0xa0, 0x0e, 0xf5, 0xd0, 0x0e, 0xf0, 0xd0, 0x06, 0xf4, 0x10, 0x0e, 0xe2, 0xc0, 0x0e, + 0xe5, 0x30, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x84, 0x3b, 0xbc, 0x43, + 0x1b, 0xb8, 0x43, 0x38, 0xb8, 0xc3, 0x3c, 0xb4, 0x81, 0x39, 0xc0, 0x43, 0x1b, 0xb4, 0x43, 0x38, + 0xd0, 0x03, 0x3a, 0x00, 0xf4, 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0xe1, 0x0e, 0xef, 0xd0, 0x06, + 0xf3, 0x90, 0x0e, 0xe7, 0xe0, 0x0e, 0xe5, 0x40, 0x0e, 0x6d, 0xa0, 0x0f, 0xe5, 0x20, 0x0f, 0xef, + 0x30, 0x0f, 0x6d, 0x60, 0x0e, 0xf0, 0xd0, 0x06, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x00, 0x3d, + 0xc8, 0x43, 0x3d, 0x94, 0x03, 0x40, 0xb8, 0xc3, 0x3b, 0xb4, 0x01, 0x3d, 0xc8, 0x43, 0x38, 0xc0, + 0x03, 0x3c, 0xa4, 0x83, 0x3b, 0x9c, 0x43, 0x1b, 0xb4, 0x43, 0x38, 0xd0, 0x03, 0x3a, 0x00, 0xf4, + 0x20, 0x0f, 0xf5, 0x50, 0x0e, 0x00, 0x31, 0x0f, 0xf4, 0x10, 0x0e, 0xe3, 0xb0, 0x0e, 0x6d, 0x00, + 0x0f, 0xf2, 0xf0, 0x0e, 0xf4, 0x50, 0x0e, 0xe3, 0x40, 0x0f, 0xef, 0x20, 0x0f, 0x6d, 0x20, 0x0e, + 0xf5, 0x60, 0x0e, 0xe6, 0x50, 0x0e, 0xf2, 0xd0, 0x06, 0xf3, 0x90, 0x0e, 0xfa, 0x50, 0x0e, 0x00, + 0x1e, 0x00, 0x44, 0x3d, 0xb8, 0xc3, 0x3c, 0x84, 0x83, 0x39, 0x94, 0x43, 0x1b, 0x98, 0x03, 0x3c, + 0xb4, 0x41, 0x3b, 0x84, 0x03, 0x3d, 0xa0, 0x03, 0x40, 0x0f, 0xf2, 0x50, 0x0f, 0xe5, 0x00, 0x10, + 0xf5, 0x30, 0x0f, 0xe5, 0xd0, 0x06, 0xf3, 0xf0, 0x0e, 0xe6, 0x40, 0x0f, 0x6d, 0x60, 0x0e, 0xec, + 0xf0, 0x0e, 0xe1, 0x40, 0x0f, 0x80, 0x39, 0x84, 0x03, 0x3b, 0xcc, 0x43, 0x39, 0x00, 0x1b, 0x92, + 0x62, 0x00, 0x16, 0xa0, 0x0a, 0xd2, 0x00, 0x14, 0x36, 0x18, 0xc6, 0xff, 0xff, 0xff, 0xff, 0x0f, + 0x40, 0x1b, 0x00, 0xd2, 0x06, 0xe2, 0x08, 0x80, 0x65, 0x83, 0x81, 0xfc, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x48, 0x00, 0xb5, 0x01, 0x49, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xda, 0x00, 0x90, 0x80, + 0x6a, 0x83, 0xa1, 0x04, 0xc0, 0x02, 0x54, 0x1b, 0x8c, 0x45, 0x00, 0x16, 0xa0, 0xda, 0x50, 0x30, + 0x43, 0x90, 0x06, 0xa0, 0x00, 0x00, 0x49, 0x18, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x86, + 0x40, 0x18, 0x26, 0x0c, 0x84, 0x50, 0x4c, 0x10, 0x8c, 0x63, 0x42, 0x80, 0x4c, 0x18, 0x12, 0x65, + 0x99, 0x10, 0x30, 0x00, 0x00, 0x00, 0x89, 0x20, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x32, 0x22, + 0x88, 0x09, 0x20, 0x64, 0x85, 0x04, 0x13, 0x23, 0xa4, 0x84, 0x04, 0x13, 0x23, 0xe3, 0x84, 0xa1, + 0x90, 0x14, 0x12, 0x4c, 0x8c, 0x8c, 0x0b, 0x84, 0xc4, 0x4c, 0x10, 0xa0, 0xc1, 0x1c, 0x01, 0x28, + 0x0c, 0x22, 0x00, 0xc2, 0x08, 0xc0, 0x51, 0xd2, 0x14, 0x51, 0xc2, 0xe4, 0xff, 0x13, 0x71, 0x4d, + 0x54, 0x44, 0xfc, 0xf6, 0xf0, 0x4f, 0x63, 0x04, 0xc0, 0x20, 0xc2, 0x10, 0xcc, 0x11, 0x80, 0xc1, + 0x30, 0x02, 0x51, 0x9c, 0x24, 0x4d, 0x11, 0x25, 0x4c, 0x3e, 0xb8, 0x38, 0x01, 0xb0, 0x48, 0x1d, + 0x30, 0x01, 0x88, 0x30, 0x0c, 0xc3, 0x18, 0x44, 0x38, 0x84, 0x61, 0x84, 0xa1, 0x28, 0x87, 0x40, + 0x10, 0x48, 0x92, 0x24, 0xa4, 0x0c, 0x23, 0x08, 0xc5, 0x0c, 0xc0, 0x30, 0x02, 0xd1, 0x14, 0x43, + 0x20, 0x18, 0xa7, 0x28, 0xe8, 0x19, 0x46, 0x18, 0x9a, 0x32, 0x44, 0x51, 0x44, 0xd2, 0x30, 0x82, + 0xd0, 0x94, 0x81, 0xa2, 0x28, 0xaa, 0xca, 0xd0, 0x34, 0x0d, 0x5d, 0x45, 0x68, 0x1a, 0xca, 0x8a, + 0x40, 0x51, 0xb4, 0x5d, 0x24, 0x4d, 0x11, 0x25, 0x4c, 0xfe, 0x2f, 0x01, 0xcc, 0xb3, 0x10, 0xd1, + 0x3f, 0x8d, 0x11, 0x00, 0x83, 0x08, 0x9d, 0x30, 0x47, 0x10, 0x14, 0xc4, 0x21, 0x3c, 0xea, 0x63, + 0x8a, 0x82, 0xc0, 0x22, 0x50, 0x0c, 0x89, 0x03, 0x01, 0x83, 0x08, 0x86, 0x30, 0x0a, 0x30, 0x47, + 0x00, 0x01, 0x13, 0xb2, 0x70, 0x48, 0x07, 0x79, 0xb0, 0x03, 0x3a, 0x68, 0x83, 0x70, 0x80, 0x07, + 0x78, 0x60, 0x87, 0x72, 0x68, 0x83, 0x76, 0x08, 0x87, 0x71, 0x78, 0x87, 0x79, 0xc0, 0x87, 0x38, + 0x80, 0x03, 0x37, 0x88, 0x03, 0x3a, 0x70, 0x03, 0x38, 0xd8, 0x70, 0x1b, 0xe5, 0xd0, 0x06, 0xf0, + 0xa0, 0x07, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x90, + 0x0e, 0x71, 0xa0, 0x07, 0x78, 0xa0, 0x07, 0x78, 0xd0, 0x06, 0xe9, 0x80, 0x07, 0x7a, 0x80, 0x07, + 0x7a, 0x80, 0x07, 0x6d, 0x90, 0x0e, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, + 0x60, 0x07, 0x6d, 0x90, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, + 0x07, 0x6d, 0x90, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, + 0x6d, 0x60, 0x0e, 0x73, 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, + 0x60, 0x0e, 0x76, 0x40, 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, + 0x0f, 0x71, 0x60, 0x07, 0x7a, 0x10, 0x07, 0x76, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x6d, 0x60, 0x0f, + 0x72, 0x40, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x73, + 0x20, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0x07, 0x73, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x74, 0x80, + 0x07, 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x76, 0x40, 0x07, + 0x7a, 0x60, 0x07, 0x74, 0xa0, 0x07, 0x76, 0x40, 0x07, 0x6d, 0x60, 0x0f, 0x79, 0x60, 0x07, 0x7a, + 0x10, 0x07, 0x72, 0x80, 0x07, 0x7a, 0x10, 0x07, 0x72, 0x80, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x20, + 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xa0, 0x07, 0x71, 0x20, 0x07, 0x78, 0xd0, 0x06, + 0xf6, 0x10, 0x07, 0x79, 0x20, 0x07, 0x7a, 0x20, 0x07, 0x75, 0x60, 0x07, 0x7a, 0x20, 0x07, 0x75, + 0x60, 0x07, 0x6d, 0x60, 0x0f, 0x72, 0x50, 0x07, 0x76, 0xa0, 0x07, 0x72, 0x50, 0x07, 0x76, 0xa0, + 0x07, 0x72, 0x50, 0x07, 0x76, 0xd0, 0x06, 0xf6, 0x50, 0x07, 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, + 0x71, 0x20, 0x07, 0x7a, 0x50, 0x07, 0x71, 0x20, 0x07, 0x6d, 0x60, 0x0f, 0x71, 0x00, 0x07, 0x72, + 0x40, 0x07, 0x7a, 0x10, 0x07, 0x70, 0x20, 0x07, 0x74, 0xa0, 0x07, 0x71, 0x00, 0x07, 0x72, 0x40, + 0x07, 0x6d, 0xe0, 0x0e, 0x78, 0xa0, 0x07, 0x71, 0x60, 0x07, 0x7a, 0x30, 0x07, 0x72, 0xa0, 0xf4, + 0x80, 0x10, 0x21, 0x01, 0x64, 0xc8, 0x48, 0x91, 0x11, 0x40, 0x23, 0x84, 0x61, 0x0d, 0x06, 0x40, + 0x1a, 0x8e, 0x25, 0xc0, 0xc4, 0x02, 0x0d, 0x0e, 0x89, 0x26, 0x43, 0x01, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x00, 0x00, 0x80, 0x21, 0x51, 0x26, 0x0e, 0x0a, 0x02, 0x0c, 0x02, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x89, 0xf6, 0x41, 0x7b, 0x80, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x60, 0x48, 0x54, 0x13, 0x93, 0x04, 0x04, 0x00, 0x01, 0x00, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x43, 0x22, 0xb4, 0x98, 0x24, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x18, 0x12, 0xed, 0xc5, 0x54, 0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0xc0, 0x90, 0xc8, 0x35, 0xa6, 0x0a, 0x08, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x86, 0x44, 0xe1, 0x11, 0x5d, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x00, 0x30, 0x24, 0x92, 0x8f, 0x28, 0x03, 0x02, 0x80, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x80, 0x21, 0xd1, 0x88, 0x5c, 0x1b, 0x10, 0x00, 0x04, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x89, 0x74, 0x64, 0xda, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, + 0x48, 0xd4, 0x26, 0x1b, 0x18, 0x00, 0x01, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xc0, + 0x90, 0x08, 0x55, 0xa8, 0x0d, 0x08, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x86, + 0x44, 0xbc, 0xb2, 0x89, 0x01, 0x10, 0x00, 0x04, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x48, + 0x6c, 0x10, 0x28, 0x0c, 0xec, 0x00, 0x00, 0x90, 0x05, 0x02, 0x0d, 0x00, 0x00, 0x00, 0x32, 0x1e, + 0x98, 0x14, 0x19, 0x11, 0x4c, 0x90, 0x8c, 0x09, 0x26, 0x47, 0xc6, 0x04, 0x43, 0x02, 0xea, 0xdd, + 0xda, 0xf7, 0xff, 0xff, 0x17, 0x90, 0xf0, 0x3f, 0x60, 0x04, 0x80, 0x8a, 0x12, 0x28, 0x84, 0x22, + 0x18, 0x01, 0x28, 0x98, 0x02, 0x0c, 0x28, 0x90, 0x02, 0x2a, 0xb0, 0x32, 0x28, 0x05, 0x00, 0x00, + 0x00, 0x00, 0xb1, 0x18, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x33, 0x08, 0x80, 0x1c, 0xc4, 0xe1, + 0x1c, 0x66, 0x14, 0x01, 0x3d, 0x88, 0x43, 0x38, 0x84, 0xc3, 0x8c, 0x42, 0x80, 0x07, 0x79, 0x78, + 0x07, 0x73, 0x98, 0x71, 0x0c, 0xe6, 0x00, 0x0f, 0xed, 0x10, 0x0e, 0xf4, 0x80, 0x0e, 0x33, 0x0c, + 0x42, 0x1e, 0xc2, 0xc1, 0x1d, 0xce, 0xa1, 0x1c, 0x66, 0x30, 0x05, 0x3d, 0x88, 0x43, 0x38, 0x84, + 0x83, 0x1b, 0xcc, 0x03, 0x3d, 0xc8, 0x43, 0x3d, 0x8c, 0x03, 0x3d, 0xcc, 0x78, 0x8c, 0x74, 0x70, + 0x07, 0x7b, 0x08, 0x07, 0x79, 0x48, 0x87, 0x70, 0x70, 0x07, 0x7a, 0x70, 0x03, 0x76, 0x78, 0x87, + 0x70, 0x20, 0x87, 0x19, 0xcc, 0x11, 0x0e, 0xec, 0x90, 0x0e, 0xe1, 0x30, 0x0f, 0x6e, 0x30, 0x0f, + 0xe3, 0xf0, 0x0e, 0xf0, 0x50, 0x0e, 0x33, 0x10, 0xc4, 0x1d, 0xde, 0x21, 0x1c, 0xd8, 0x21, 0x1d, + 0xc2, 0x61, 0x1e, 0x66, 0x30, 0x89, 0x3b, 0xbc, 0x83, 0x3b, 0xd0, 0x43, 0x39, 0xb4, 0x03, 0x3c, + 0xbc, 0x83, 0x3c, 0x84, 0x03, 0x3b, 0xcc, 0xf0, 0x14, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, + 0x68, 0x87, 0x72, 0x68, 0x07, 0x37, 0x80, 0x87, 0x70, 0x90, 0x87, 0x70, 0x60, 0x07, 0x76, 0x28, + 0x07, 0x76, 0xf8, 0x05, 0x76, 0x78, 0x87, 0x77, 0x80, 0x87, 0x5f, 0x08, 0x87, 0x71, 0x18, 0x87, + 0x72, 0x98, 0x87, 0x79, 0x98, 0x81, 0x2c, 0xee, 0xf0, 0x0e, 0xee, 0xe0, 0x0e, 0xf5, 0xc0, 0x0e, + 0xec, 0x30, 0x03, 0x62, 0xc8, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, 0xcc, 0xa1, 0x1c, 0xe4, 0xa1, 0x1c, + 0xdc, 0x61, 0x1c, 0xca, 0x21, 0x1c, 0xc4, 0x81, 0x1d, 0xca, 0x61, 0x06, 0xd6, 0x90, 0x43, 0x39, + 0xc8, 0x43, 0x39, 0x98, 0x43, 0x39, 0xc8, 0x43, 0x39, 0xb8, 0xc3, 0x38, 0x94, 0x43, 0x38, 0x88, + 0x03, 0x3b, 0x94, 0xc3, 0x2f, 0xbc, 0x83, 0x3c, 0xfc, 0x82, 0x3b, 0xd4, 0x03, 0x3b, 0xb0, 0xc3, + 0x0c, 0xc7, 0x69, 0x87, 0x70, 0x58, 0x87, 0x72, 0x70, 0x83, 0x74, 0x68, 0x07, 0x78, 0x60, 0x87, + 0x74, 0x18, 0x87, 0x74, 0xa0, 0x87, 0x19, 0xce, 0x53, 0x0f, 0xee, 0x00, 0x0f, 0xf2, 0x50, 0x0e, + 0xe4, 0x90, 0x0e, 0xe3, 0x40, 0x0f, 0xe1, 0x20, 0x0e, 0xec, 0x50, 0x0e, 0x33, 0x20, 0x28, 0x1d, + 0xdc, 0xc1, 0x1e, 0xc2, 0x41, 0x1e, 0xd2, 0x21, 0x1c, 0xdc, 0x81, 0x1e, 0xdc, 0xe0, 0x1c, 0xe4, + 0xe1, 0x1d, 0xea, 0x01, 0x1e, 0x66, 0x18, 0x51, 0x38, 0xb0, 0x43, 0x3a, 0x9c, 0x83, 0x3b, 0xcc, + 0x50, 0x24, 0x76, 0x60, 0x07, 0x7b, 0x68, 0x07, 0x37, 0x60, 0x87, 0x77, 0x78, 0x07, 0x78, 0x98, + 0x51, 0x4c, 0xf4, 0x90, 0x0f, 0xf0, 0x50, 0x0e, 0x33, 0x1e, 0x6a, 0x1e, 0xca, 0x61, 0x1c, 0xe8, + 0x21, 0x1d, 0xde, 0xc1, 0x1d, 0x7e, 0x01, 0x1e, 0xe4, 0xa1, 0x1c, 0xcc, 0x21, 0x1d, 0xf0, 0x61, + 0x06, 0x54, 0x85, 0x83, 0x38, 0xcc, 0xc3, 0x3b, 0xb0, 0x43, 0x3d, 0xd0, 0x43, 0x39, 0xfc, 0xc2, + 0x3c, 0xe4, 0x43, 0x3b, 0x88, 0xc3, 0x3b, 0xb0, 0xc3, 0x8c, 0xc5, 0x0a, 0x87, 0x79, 0x98, 0x87, + 0x77, 0x18, 0x87, 0x74, 0x08, 0x07, 0x7a, 0x28, 0x07, 0x72, 0x98, 0x81, 0x5c, 0xe3, 0x10, 0x0e, + 0xec, 0xc0, 0x0e, 0xe5, 0x50, 0x0e, 0xf3, 0x30, 0x23, 0xc1, 0xd2, 0x41, 0x1e, 0xe4, 0xe1, 0x17, + 0xd8, 0xe1, 0x1d, 0xde, 0x01, 0x1e, 0x66, 0x50, 0x59, 0x38, 0xa4, 0x83, 0x3c, 0xb8, 0x81, 0x39, + 0xd4, 0x83, 0x3b, 0x8c, 0x03, 0x3d, 0xa4, 0xc3, 0x3b, 0xb8, 0xc3, 0x2f, 0x9c, 0x83, 0x3c, 0xbc, + 0x43, 0x3d, 0xc0, 0xc3, 0x3c, 0x00, 0x79, 0x20, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x32, 0x9a, + 0x08, 0x14, 0x02, 0x85, 0x8c, 0x27, 0x46, 0x46, 0xc8, 0x11, 0x32, 0x64, 0xd4, 0xca, 0x00, 0x0c, + 0xe8, 0x09, 0x4a, 0x1e, 0x14, 0x1b, 0x57, 0x06, 0x8b, 0x94, 0x44, 0x17, 0xd3, 0x28, 0x18, 0xa3, + 0x3c, 0x08, 0x55, 0x18, 0x86, 0x61, 0x44, 0xd7, 0x72, 0x88, 0x41, 0xd1, 0x80, 0xc1, 0xb2, 0x11, + 0x11, 0x00, 0x77, 0x63, 0x68, 0x61, 0x72, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x41, 0x70, 0x70, 0x6c, + 0x65, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, + 0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x20, 0x28, 0x6d, 0x65, 0x74, 0x61, 0x6c, + 0x66, 0x65, 0x2d, 0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x2d, 0x77, 0x69, 0x6e, + 0x64, 0x6f, 0x77, 0x73, 0x29, 0x4d, 0x65, 0x74, 0x61, 0x6c, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, + 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x64, 0x65, 0x6e, 0x6f, 0x72, 0x6d, 0x73, 0x5f, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, + 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x61, 0x74, 0x68, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x2e, 0x66, 0x72, 0x61, + 0x6d, 0x65, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x5f, 0x66, 0x65, 0x74, 0x63, 0x68, 0x5f, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, + 0x65, 0x61, 0x69, 0x72, 0x2e, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x61, 0x69, 0x72, 0x2e, 0x77, 0x72, 0x69, 0x74, 0x65, 0x61, 0x69, 0x72, 0x2e, + 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x78, + 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x77, 0x72, + 0x69, 0x74, 0x65, 0x3e, 0x61, 0x69, 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x61, 0x69, 0x72, + 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, + 0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x3e, 0x49, + 0x6e, 0x70, 0x75, 0x74, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x62, + 0x75, 0x66, 0x66, 0x65, 0x72, 0x61, 0x69, 0x72, 0x2e, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x5f, + 0x73, 0x69, 0x7a, 0x65, 0x61, 0x69, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x61, 0x69, 0x72, 0x2e, + 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, + 0x75, 0x69, 0x6e, 0x74, 0x34, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x30, 0x43, 0x6f, 0x6e, 0x73, 0x74, + 0x31, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x32, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x33, 0x61, 0x69, 0x72, + 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x61, 0x69, + 0x72, 0x2e, 0x61, 0x72, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x67, 0x6e, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x44, 0x61, 0x74, 0x61, + 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x61, + 0x64, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x74, 0x68, + 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x75, 0x69, 0x6e, 0x74, 0x33, 0x4c, 0x6f, + 0x63, 0x61, 0x6c, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x49, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x74, + 0x68, 0x72, 0x65, 0x61, 0x64, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x67, 0x72, 0x69, 0x64, 0x57, 0x6f, 0x72, 0x6b, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, + 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x67, 0x72, 0x69, + 0x64, 0x44, 0x74, 0x69, 0x64, 0x61, 0x69, 0x72, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x24, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x82, + 0x50, 0x44, 0x23, 0x08, 0x85, 0x34, 0x82, 0x50, 0x4c, 0x23, 0x08, 0x05, 0x35, 0x82, 0xb0, 0x04, + 0x23, 0x08, 0x45, 0x35, 0x82, 0x50, 0x58, 0x23, 0x08, 0xc5, 0x35, 0x82, 0x50, 0x60, 0x23, 0x08, + 0x45, 0x36, 0x82, 0x50, 0x68, 0x23, 0x08, 0xc5, 0x36, 0x82, 0x10, 0x00, 0x33, 0x0c, 0x66, 0x10, + 0x9c, 0xc1, 0x0c, 0x81, 0x30, 0xc3, 0x80, 0x06, 0x66, 0x90, 0x06, 0x33, 0x10, 0x03, 0x1a, 0x98, + 0x41, 0x1a, 0xcc, 0x10, 0x10, 0x33, 0x04, 0xc5, 0x0c, 0x81, 0x31, 0x03, 0x30, 0x83, 0x92, 0x06, + 0x07, 0xb2, 0x06, 0x66, 0x90, 0x28, 0x0b, 0xd3, 0xcc, 0xa0, 0x98, 0xc1, 0x81, 0x98, 0x81, 0x19, + 0x38, 0xca, 0xc3, 0x40, 0x33, 0x50, 0x69, 0xd0, 0x06, 0x69, 0x50, 0x59, 0x6d, 0xd0, 0x06, 0x69, + 0x50, 0x5d, 0x6e, 0xd0, 0x06, 0x69, 0x50, 0x61, 0x6f, 0xd0, 0x06, 0x69, 0x50, 0x65, 0x33, 0x48, + 0x68, 0x10, 0x49, 0x6c, 0x80, 0x9c, 0x81, 0x19, 0x4c, 0x54, 0x1f, 0x68, 0x6c, 0xb0, 0xb5, 0x81, + 0xc2, 0x31, 0xdd, 0x0c, 0x06, 0x1c, 0x78, 0xca, 0xc7, 0x80, 0xc1, 0x0c, 0xc6, 0x19, 0x84, 0x81, + 0xf2, 0x31, 0x62, 0x30, 0x83, 0x11, 0x07, 0x63, 0xa0, 0x7c, 0x0c, 0x19, 0xcc, 0x60, 0xec, 0x01, + 0x1f, 0xf8, 0xc1, 0x1f, 0x80, 0x42, 0x28, 0xcc, 0x30, 0xa8, 0x81, 0x1e, 0x88, 0xc2, 0x0c, 0x42, + 0x19, 0xc8, 0x41, 0x7d, 0x00, 0xc7, 0x71, 0x1c, 0xc7, 0x71, 0x1c, 0xc7, 0x71, 0x1c, 0xe7, 0x06, + 0x16, 0x1d, 0xe8, 0x81, 0x65, 0x59, 0x90, 0x2f, 0xf8, 0x02, 0x6c, 0x98, 0x05, 0x28, 0x98, 0x82, + 0x29, 0xe0, 0x02, 0x1d, 0xc8, 0x48, 0x60, 0x82, 0x2e, 0x62, 0x63, 0xb3, 0x6b, 0x73, 0x69, 0x7b, + 0x23, 0xab, 0x63, 0x2b, 0x73, 0x31, 0x63, 0x0b, 0x3b, 0x9b, 0x1b, 0x25, 0x90, 0x83, 0x53, 0xd8, + 0xd8, 0xec, 0xda, 0x5c, 0xd2, 0xc8, 0xca, 0xdc, 0xe8, 0x46, 0x09, 0xe6, 0xe0, 0x96, 0xb0, 0x34, + 0x39, 0x17, 0xbb, 0x32, 0xb9, 0xb9, 0xb4, 0x37, 0xb7, 0x51, 0x02, 0x3a, 0x38, 0x2a, 0x2c, 0x4d, + 0xce, 0x85, 0x2d, 0xcc, 0xed, 0xac, 0x2e, 0xec, 0xac, 0xec, 0xcb, 0xae, 0x4c, 0x6e, 0x2e, 0xed, + 0xcd, 0x6d, 0x94, 0xa0, 0x0e, 0x6e, 0x0a, 0x4b, 0x93, 0x73, 0x19, 0x7b, 0x6b, 0x83, 0x4b, 0x63, + 0x2b, 0xfb, 0x7a, 0x83, 0xa3, 0x4b, 0x7b, 0x73, 0x9b, 0x1b, 0x65, 0xb0, 0x83, 0x3b, 0xc0, 0x83, + 0x53, 0xc2, 0xd2, 0xe4, 0x5c, 0xd6, 0xca, 0xe4, 0xdc, 0xca, 0xd8, 0x46, 0x09, 0x44, 0xe1, 0xa4, + 0xb0, 0x34, 0x39, 0x97, 0xb9, 0xb0, 0x36, 0x38, 0xb6, 0x32, 0xb9, 0xaf, 0x39, 0xba, 0x30, 0xba, + 0xb2, 0xb9, 0x51, 0x82, 0x51, 0x00, 0xa9, 0x18, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0b, 0x0a, + 0x72, 0x28, 0x87, 0x77, 0x80, 0x07, 0x7a, 0x58, 0x70, 0x98, 0x43, 0x3d, 0xb8, 0xc3, 0x38, 0xb0, + 0x43, 0x39, 0xd0, 0xc3, 0x82, 0xe6, 0x1c, 0xc6, 0xa1, 0x0d, 0xe8, 0x41, 0x1e, 0xc2, 0xc1, 0x1d, + 0xe6, 0x21, 0x1d, 0xe8, 0x21, 0x1d, 0xde, 0xc1, 0x1d, 0x00, 0xd1, 0x10, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x07, 0xcc, 0x3c, 0xa4, 0x83, 0x3b, 0x9c, 0x03, 0x3b, 0x94, 0x03, 0x3d, 0xa0, 0x83, + 0x3c, 0x94, 0x43, 0x38, 0x90, 0xc3, 0x01, 0x00, 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x08, 0x00, + 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x94, 0xcc, + 0x00, 0x00, 0x23, 0x06, 0x8a, 0x11, 0x83, 0x60, 0xa0, 0x84, 0xc1, 0x61, 0x14, 0xc4, 0x10, 0x20, + 0x00, 0x00, 0x61, 0x20, 0x00, 0x00, 0x07, 0x0b, 0x00, 0x00, 0x13, 0x04, 0x41, 0x2c, 0x10, 0x00, + 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x04, 0x94, 0x40, 0x11, 0x94, 0x01, 0x15, 0x33, 0x00, 0x05, + 0x51, 0x0e, 0xc5, 0x40, 0xc6, 0x0c, 0xc0, 0x1c, 0x04, 0x15, 0x4d, 0x65, 0x40, 0xc9, 0x1c, 0x03, + 0x15, 0x95, 0xc1, 0x1c, 0x43, 0xa4, 0x95, 0xc1, 0x58, 0x03, 0x10, 0x10, 0x73, 0x0c, 0xd4, 0x54, + 0x06, 0x63, 0x0d, 0x40, 0x30, 0x8c, 0x00, 0x10, 0x33, 0x02, 0x30, 0x96, 0x00, 0x04, 0x63, 0x09, + 0xc2, 0x30, 0x96, 0x30, 0x08, 0x63, 0x09, 0x41, 0x30, 0x96, 0x20, 0x1c, 0x63, 0x09, 0x01, 0x31, + 0x96, 0x00, 0x08, 0x33, 0x00, 0x63, 0x09, 0x42, 0x40, 0x5f, 0x0d, 0xd0, 0x59, 0x88, 0xde, 0x03, + 0x25, 0x50, 0xc6, 0xe6, 0x02, 0xd4, 0x8c, 0x11, 0x80, 0x20, 0x08, 0x82, 0xa0, 0x30, 0x46, 0x00, + 0x82, 0x20, 0x88, 0x7f, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf0, 0x37, 0x46, 0x00, 0x82, 0x20, 0x08, + 0x72, 0x63, 0x04, 0x20, 0x08, 0x82, 0xf8, 0x2f, 0x8c, 0x11, 0x84, 0xb7, 0x8f, 0xa6, 0x1f, 0x39, + 0x33, 0x00, 0x63, 0x11, 0x20, 0x08, 0x82, 0xf0, 0x07, 0x82, 0x20, 0x08, 0x7f, 0x20, 0x08, 0x82, + 0xf0, 0x07, 0x82, 0x20, 0x08, 0x7f, 0x14, 0xcd, 0x00, 0x8c, 0x35, 0x80, 0x20, 0x08, 0x82, 0xa0, + 0x00, 0x82, 0x20, 0x08, 0x82, 0x02, 0x08, 0x82, 0x20, 0x08, 0x0a, 0x44, 0xcd, 0x00, 0x8c, 0x25, + 0x80, 0x20, 0x08, 0xe2, 0xbf, 0x00, 0x82, 0x20, 0x88, 0xff, 0xc2, 0x58, 0x42, 0x6b, 0xce, 0x39, + 0xfb, 0xb5, 0xe6, 0x9c, 0xb3, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x30, 0xff, 0x81, 0x20, 0x08, 0xf3, + 0xdf, 0x58, 0x02, 0x08, 0x82, 0x60, 0xfc, 0x0b, 0x20, 0x08, 0x82, 0xf1, 0x2f, 0x8c, 0x25, 0x80, + 0x20, 0x08, 0xe2, 0x1f, 0x08, 0x82, 0x20, 0xfe, 0x8d, 0x25, 0x80, 0x20, 0x08, 0xe2, 0x1f, 0x30, + 0x96, 0x00, 0x80, 0x20, 0x08, 0xe2, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x20, 0xfe, 0x0b, 0xc0, 0x58, + 0x02, 0x00, 0x82, 0x20, 0x88, 0xff, 0xc2, 0x58, 0x02, 0x08, 0x82, 0x20, 0x08, 0x0a, 0x20, 0x08, + 0x82, 0x20, 0x28, 0x8c, 0x25, 0x80, 0x20, 0x08, 0xe2, 0x1f, 0x08, 0x82, 0x20, 0x08, 0x06, 0x63, + 0x09, 0x20, 0x08, 0x82, 0x20, 0x18, 0x80, 0x20, 0x08, 0xe2, 0xdf, 0x58, 0x02, 0x08, 0x82, 0x20, + 0x08, 0x06, 0x20, 0x08, 0x82, 0x20, 0x18, 0x90, 0x67, 0x1b, 0x00, 0x00, 0x00, 0x00, 0xf1, 0x30, + 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x22, 0x47, 0xc8, 0x90, 0x51, 0x0a, 0x84, 0x18, 0x00, 0x00, + 0x00, 0x00, 0xcf, 0x03, 0x00, 0x00, 0x6f, 0x6d, 0x6e, 0x69, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x74, + 0x20, 0x63, 0x68, 0x61, 0x72, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x2b, 0x2b, 0x20, + 0x54, 0x42, 0x41, 0x41, 0x00, 0x00, 0x13, 0x04, 0x00, 0xda, 0x10, 0x98, 0xc2, 0x86, 0xa1, 0x14, + 0x50, 0xe1, 0x14, 0x36, 0x0c, 0xa9, 0x90, 0x0a, 0xa7, 0x00, 0x63, 0x08, 0x79, 0x80, 0x0a, 0x15, + 0xa0, 0x02, 0x56, 0x30, 0x07, 0x3a, 0xc7, 0x20, 0x06, 0xc1, 0x29, 0x14, 0x21, 0x0a, 0x58, 0x05, + 0x2b, 0x68, 0x09, 0x76, 0xa0, 0x15, 0x08, 0x3b, 0xc7, 0x50, 0x04, 0xaf, 0x30, 0x86, 0x10, 0x0a, + 0xb1, 0x50, 0x01, 0x2c, 0xdc, 0x1c, 0x83, 0x1a, 0x04, 0xaf, 0x30, 0x86, 0x40, 0x0a, 0xa2, 0x50, + 0xc1, 0x2c, 0xdc, 0x1c, 0xc3, 0x10, 0xd4, 0x42, 0x1d, 0x01, 0xec, 0x63, 0x50, 0x05, 0x5c, 0xa0, + 0x05, 0x0a, 0x8c, 0xb2, 0x8f, 0x81, 0x15, 0x74, 0x21, 0x17, 0x28, 0x30, 0xca, 0x3e, 0x06, 0x57, + 0xe0, 0x85, 0x5c, 0xa0, 0xc0, 0x28, 0xfb, 0x18, 0x60, 0xc1, 0x17, 0x68, 0x81, 0x02, 0xa3, 0x8c, + 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x88, 0x81, 0x38, 0x24, 0x83, 0x0c, 0x08, 0x2a, 0xfc, + 0xc1, 0x05, 0xd4, 0xda, 0x10, 0x88, 0xff, 0x20, 0xc3, 0xb2, 0x0a, 0xa1, 0x70, 0x01, 0xb5, 0x36, + 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xa9, 0x43, 0x60, 0x42, 0x10, + 0xfe, 0x83, 0x0c, 0x0e, 0x2c, 0x9c, 0xc2, 0x05, 0xd4, 0x1a, 0x11, 0x88, 0xff, 0x20, 0x43, 0x34, + 0x0b, 0xa9, 0x70, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x20, 0xd9, 0x42, 0x2b, 0x5c, 0x40, + 0xad, 0x0d, 0x01, 0xf8, 0x0f, 0x32, 0x54, 0xb9, 0xf0, 0x0a, 0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, + 0x83, 0x0c, 0x16, 0x2f, 0xcc, 0xc2, 0x05, 0xd4, 0x5a, 0x12, 0x80, 0xff, 0x88, 0x01, 0x53, 0x84, + 0x20, 0x58, 0xf8, 0x07, 0x18, 0xf0, 0xc3, 0x3a, 0xc4, 0x81, 0xd2, 0x0a, 0xb7, 0x40, 0x0f, 0xf4, + 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0xfd, 0xc0, 0x0e, 0x72, 0xb0, 0xb8, + 0x02, 0x2e, 0xe0, 0x43, 0x3d, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0x3f, + 0xb4, 0xc3, 0x1c, 0x30, 0xaf, 0x90, 0x0b, 0xf7, 0x60, 0x0f, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, + 0xe1, 0x1f, 0x60, 0xf0, 0x0f, 0xee, 0x40, 0x07, 0x0a, 0x2c, 0xe8, 0xc2, 0x3d, 0xdc, 0xc3, 0x88, + 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0x80, 0xc4, 0x3b, 0xd4, 0xc1, 0x12, 0x0b, 0xbb, + 0xb0, 0x0f, 0xf8, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x21, 0x01, 0x0f, + 0x76, 0xc0, 0xc8, 0x02, 0x2f, 0xe8, 0x43, 0x3e, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, + 0x80, 0x81, 0x48, 0xc4, 0xc3, 0x1d, 0x28, 0xb3, 0xd0, 0x0b, 0xfa, 0xa0, 0x0f, 0x23, 0x06, 0x4c, + 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x30, 0x12, 0xf2, 0x80, 0x07, 0x0b, 0x2d, 0xf8, 0x82, 0x3f, + 0xec, 0xc3, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0x90, 0xc4, 0x3c, 0xe4, 0x01, + 0x53, 0x0b, 0xbf, 0xd0, 0x0f, 0xfc, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, + 0x25, 0x41, 0x0f, 0x7a, 0xa0, 0xd8, 0x02, 0x38, 0xf4, 0x43, 0x3f, 0x8c, 0x18, 0x30, 0x45, 0x08, + 0x82, 0x85, 0x7f, 0x80, 0x81, 0x49, 0xd4, 0xc3, 0x1e, 0x2c, 0xb7, 0x10, 0x0e, 0x21, 0xe1, 0x0f, + 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x70, 0x12, 0xf6, 0xc0, 0x07, 0x0c, 0x2e, + 0x88, 0x03, 0x48, 0xfc, 0x83, 0x29, 0x0c, 0xf8, 0x5b, 0xf0, 0x0a, 0xe2, 0x6f, 0x41, 0x03, 0xfe, + 0xa6, 0x30, 0xe0, 0x6f, 0x81, 0x2c, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, + 0xb5, 0x20, 0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0xe0, 0x82, 0xf8, 0x5b, 0xd0, + 0x80, 0xff, 0x20, 0x83, 0xb2, 0x0b, 0xee, 0x30, 0xc8, 0x80, 0xf0, 0x42, 0x3b, 0x0c, 0x32, 0x24, + 0x06, 0x3b, 0x0c, 0x32, 0x1c, 0xbe, 0xf0, 0x0e, 0x83, 0x0c, 0x0b, 0xd2, 0x0e, 0x63, 0x08, 0x6d, + 0x50, 0x13, 0x76, 0x0e, 0x41, 0xf8, 0xcf, 0x31, 0xf8, 0x42, 0x30, 0x13, 0x83, 0x0c, 0x01, 0x1c, + 0xc0, 0x83, 0x05, 0xba, 0x00, 0xfe, 0x63, 0x08, 0x72, 0x80, 0x12, 0xb6, 0x0e, 0x41, 0xf8, 0xcf, + 0x31, 0x8c, 0x43, 0x80, 0x13, 0x83, 0x0c, 0x01, 0x39, 0xf0, 0x83, 0x15, 0x81, 0xf8, 0x1b, 0xd3, + 0x84, 0xbf, 0x39, 0x4f, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x66, 0x21, + 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x67, 0x21, 0x8c, 0x18, 0x1c, 0x44, 0x08, + 0x82, 0x85, 0x7f, 0x54, 0x6c, 0x21, 0x04, 0x66, 0x0e, 0x01, 0xf9, 0x9b, 0x44, 0x85, 0xbf, 0x05, + 0x88, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6c, 0x21, 0x58, 0x40, 0x88, + 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xf6, 0x16, 0x81, 0x05, 0x81, 0xf8, 0xdb, + 0x95, 0x85, 0xbf, 0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x72, + 0x21, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x73, 0x21, 0x8c, 0x18, 0x1c, 0x44, + 0x08, 0x82, 0x85, 0x7f, 0x54, 0x78, 0x21, 0x04, 0x26, 0x0f, 0x01, 0xf9, 0x5b, 0x17, 0x06, 0xe1, + 0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x5e, 0x08, 0x16, + 0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xed, 0x45, 0x60, 0x41, 0x20, + 0xfe, 0x83, 0x0c, 0x6e, 0x20, 0x12, 0x35, 0x31, 0xc8, 0xc0, 0x06, 0x23, 0x61, 0x13, 0x83, 0x0c, + 0x6a, 0x40, 0x12, 0x35, 0x31, 0xc8, 0x20, 0x0b, 0x21, 0x51, 0x13, 0x26, 0x06, 0x81, 0xf8, 0x1b, + 0x81, 0x06, 0xe1, 0x6f, 0x69, 0x60, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, + 0x36, 0x1a, 0xc2, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x46, 0x1a, 0xc2, 0x88, 0xc1, + 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x95, 0x1a, 0x42, 0x60, 0x23, 0x11, 0x90, 0xbf, 0x29, 0x4b, + 0xf8, 0x5b, 0x80, 0x88, 0xbf, 0x79, 0x01, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, + 0x6c, 0xaa, 0x31, 0x58, 0x50, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xd6, + 0x1a, 0x81, 0x05, 0x81, 0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, + 0xfe, 0xb1, 0xbd, 0x46, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xd1, 0x46, 0xe0, + 0x99, 0x4b, 0x04, 0xe4, 0x6f, 0xd4, 0x1e, 0x84, 0xbf, 0x05, 0x93, 0xf8, 0x5b, 0xd0, 0x81, 0xff, + 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x56, 0x1b, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, + 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb8, 0x11, 0x58, 0x10, 0x88, 0xbf, 0x05, 0x0c, 0xf8, + 0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, 0x20, 0xfe, 0x36, 0x04, 0xe0, + 0x3f, 0x86, 0x50, 0xe5, 0xc6, 0x18, 0x82, 0x85, 0x1a, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x30, 0x16, + 0x01, 0x6e, 0x8c, 0x21, 0x38, 0xbd, 0x31, 0x86, 0xf0, 0xb0, 0x86, 0x09, 0x01, 0xf8, 0xcf, 0x31, + 0x10, 0xc1, 0x6f, 0x8c, 0x21, 0x24, 0xe1, 0x31, 0x86, 0xa0, 0xc0, 0x86, 0x09, 0x01, 0xf8, 0x1b, + 0x41, 0x88, 0xff, 0x18, 0x42, 0x50, 0x1e, 0x63, 0x08, 0x02, 0x6d, 0x98, 0x10, 0x80, 0xff, 0x70, + 0x44, 0x60, 0x17, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0xe0, 0x17, 0x68, 0x7e, 0x11, + 0x84, 0xc0, 0x05, 0xe6, 0x5e, 0xd0, 0xe0, 0x74, 0xc3, 0x5f, 0x04, 0xc7, 0x74, 0x03, 0x68, 0x54, + 0xc8, 0x1c, 0x43, 0x14, 0xc4, 0xc7, 0x1c, 0x43, 0x5e, 0x0c, 0xee, 0x31, 0xc8, 0x10, 0xe8, 0x85, + 0x6c, 0x58, 0x30, 0x88, 0xbf, 0x49, 0xa4, 0x21, 0xfe, 0x16, 0x04, 0xe2, 0x3f, 0x86, 0x30, 0xdc, + 0x87, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0xe7, 0x61, 0x41, 0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, + 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0x8d, 0x48, 0x31, 0x62, 0x60, 0x10, 0x21, 0x08, + 0x16, 0xfe, 0x91, 0x91, 0x08, 0x31, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x71, 0x99, 0x88, + 0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x6d, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x68, 0x49, + 0x20, 0xfe, 0x16, 0xc8, 0x06, 0xf8, 0x5b, 0x00, 0x89, 0xbf, 0x05, 0xb7, 0x01, 0xfe, 0x26, 0xdd, + 0x86, 0xf8, 0x5b, 0x6e, 0x04, 0xe1, 0x6f, 0x94, 0x6d, 0x88, 0xbf, 0xe9, 0x46, 0x10, 0xfe, 0x17, + 0x98, 0x77, 0xc1, 0xb9, 0x25, 0x1e, 0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x8e, 0x21, 0xd8, 0x84, + 0x7f, 0xd8, 0x78, 0x04, 0xe1, 0x3f, 0xc7, 0xa0, 0x1b, 0xc1, 0x8b, 0xcc, 0x31, 0x04, 0xc3, 0x8c, + 0x8c, 0x21, 0xdc, 0x44, 0x88, 0xd8, 0x79, 0x04, 0xe1, 0x3f, 0xc7, 0xe0, 0x1b, 0xc1, 0x8c, 0xcc, + 0x31, 0x04, 0xc3, 0x8d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x62, 0x52, 0x04, + 0x63, 0x08, 0x3f, 0x81, 0x22, 0xc6, 0x1e, 0x41, 0xf8, 0xcf, 0x31, 0x8c, 0x47, 0x80, 0x23, 0x73, + 0x0c, 0xc1, 0xc0, 0x23, 0x63, 0x08, 0x60, 0xe1, 0x23, 0x06, 0x1f, 0x41, 0xf8, 0xcf, 0x31, 0x9c, + 0x47, 0xc0, 0x23, 0x73, 0x0c, 0xc1, 0x00, 0x26, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0xd5, 0x9a, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xc5, 0x26, 0x4a, 0x30, + 0x86, 0x80, 0x16, 0x31, 0x62, 0xf6, 0x11, 0x84, 0xff, 0x1c, 0x43, 0x7b, 0x04, 0x62, 0x32, 0xc7, + 0x10, 0x0c, 0x66, 0x32, 0x86, 0x90, 0x16, 0x34, 0x62, 0xfa, 0x11, 0x84, 0xff, 0x1c, 0x43, 0x7c, + 0x04, 0x66, 0x32, 0xc7, 0x10, 0x0c, 0x6a, 0x32, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, + 0xd5, 0x49, 0x11, 0x8c, 0x21, 0xc4, 0xc5, 0x8e, 0xd8, 0x7f, 0x04, 0xe1, 0x3f, 0xc7, 0x60, 0x1f, + 0xc1, 0x9a, 0xcc, 0x31, 0x04, 0xc3, 0x9b, 0x8c, 0x21, 0xc8, 0x45, 0x9c, 0xd8, 0x88, 0x04, 0xe1, + 0x3f, 0xc7, 0xa0, 0x1f, 0xc1, 0x9b, 0xcc, 0x31, 0x04, 0xc3, 0x9c, 0x8c, 0x18, 0x1c, 0x44, 0x08, + 0x82, 0x85, 0x7f, 0x54, 0x7e, 0x52, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, + 0x9f, 0x28, 0xc1, 0x18, 0x82, 0x5e, 0x90, 0x89, 0xa5, 0x48, 0x10, 0xfe, 0x73, 0x0c, 0x20, 0x12, + 0xd4, 0xc9, 0x1c, 0x43, 0x30, 0xe4, 0xc9, 0x18, 0xc2, 0x5e, 0x9c, 0x89, 0xb5, 0x48, 0x10, 0xfe, + 0x73, 0x0c, 0x24, 0x12, 0xe4, 0xc9, 0x1c, 0x43, 0x30, 0xf4, 0xc9, 0x88, 0xc1, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0x47, 0x85, 0x2a, 0x45, 0x30, 0x86, 0x30, 0x1a, 0x6e, 0x62, 0x32, 0x12, 0x84, 0xff, + 0x1c, 0x43, 0x8a, 0x04, 0x7e, 0x32, 0xc7, 0x10, 0x0c, 0xa2, 0x32, 0x86, 0x40, 0x1a, 0xa4, 0x62, + 0x36, 0x12, 0x84, 0xff, 0x1c, 0x43, 0x8b, 0x04, 0xa2, 0x32, 0xc7, 0x10, 0x0c, 0xa6, 0x32, 0x62, + 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xc5, 0x4a, 0x11, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, + 0x85, 0x7f, 0x54, 0xb2, 0xa2, 0x04, 0x83, 0x0c, 0x41, 0x8c, 0xbc, 0xc9, 0x20, 0xc3, 0x78, 0xc8, + 0x88, 0x9a, 0x18, 0x8b, 0x04, 0xe1, 0x6f, 0x33, 0x32, 0x13, 0xe1, 0x3f, 0xc8, 0x60, 0x1b, 0x39, + 0xc2, 0x26, 0x83, 0x0c, 0xb6, 0xa1, 0x23, 0x6d, 0x32, 0xc8, 0x60, 0x1b, 0x3b, 0xe2, 0x26, 0x83, + 0x0c, 0xbd, 0x80, 0x23, 0x70, 0x62, 0x81, 0x21, 0xfe, 0x83, 0x0c, 0xbf, 0xa0, 0x23, 0x6e, 0x62, + 0xc1, 0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, 0xe2, 0x6f, 0x81, 0x10, + 0xfe, 0x73, 0x0c, 0x60, 0x22, 0x0b, 0xb5, 0x32, 0xc8, 0x10, 0x84, 0x49, 0x9e, 0x58, 0x60, 0x88, + 0xff, 0x1c, 0xc3, 0x98, 0xcc, 0x02, 0xae, 0x0c, 0x32, 0x04, 0x64, 0xc2, 0x27, 0x16, 0x18, 0xe2, + 0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x73, 0x0c, 0x69, 0x22, 0x0b, + 0xbe, 0x32, 0xc8, 0x10, 0xa8, 0x89, 0xa8, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, + 0xee, 0x32, 0x04, 0x16, 0xa8, 0x89, 0xf8, 0x5b, 0xc0, 0x26, 0xe0, 0x3f, 0xc7, 0xe0, 0x26, 0xbc, + 0x30, 0x2e, 0x83, 0x0c, 0xc1, 0x9b, 0x9c, 0x8a, 0x05, 0x85, 0xf8, 0x5b, 0x00, 0x27, 0xe0, 0x6f, + 0x41, 0x20, 0xfe, 0x66, 0x18, 0xe2, 0x6f, 0x41, 0x9c, 0x88, 0xbf, 0x05, 0x71, 0x02, 0xfe, 0x46, + 0x04, 0xe2, 0x6f, 0x81, 0x18, 0x88, 0xbf, 0x09, 0x62, 0x20, 0xfe, 0x36, 0x88, 0x81, 0xf8, 0x9b, + 0x9c, 0xa0, 0x41, 0xf8, 0x9b, 0x9d, 0xe8, 0x45, 0xf8, 0x0f, 0x32, 0xe8, 0x07, 0xa8, 0xcc, 0xca, + 0x20, 0x83, 0x7e, 0x84, 0x0a, 0xad, 0x0c, 0x32, 0xe8, 0x87, 0xa8, 0xd4, 0x8a, 0x9d, 0x41, 0x21, + 0xfe, 0x66, 0x06, 0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa1, 0x01, 0x22, 0xfe, 0xb6, 0x06, 0x88, + 0xf8, 0x5b, 0x20, 0x84, 0xbf, 0x91, 0x01, 0x21, 0xfe, 0x26, 0x06, 0x82, 0xf8, 0x9b, 0x20, 0x88, + 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, + 0xd5, 0x32, 0x01, 0x18, 0x58, 0x90, 0x2a, 0xe2, 0x6f, 0xc1, 0xaa, 0x80, 0xbf, 0x0d, 0x9e, 0xf8, + 0x5b, 0xd0, 0x2a, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0x81, 0xab, 0x88, 0xbf, + 0x05, 0xae, 0x02, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x78, 0xe0, 0x6f, 0x43, + 0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, 0xf8, 0xdb, 0x41, 0x06, + 0xe0, 0x6f, 0xb2, 0x92, 0x0a, 0xe1, 0x6f, 0xb2, 0xb2, 0x1b, 0xe1, 0x3f, 0xc8, 0xb0, 0x23, 0xe1, + 0x32, 0x2f, 0x83, 0x0c, 0x3b, 0x22, 0x2e, 0xf4, 0x32, 0xc8, 0xb0, 0x23, 0xe3, 0x52, 0x2f, 0x86, + 0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, 0x0a, 0x88, 0xf8, 0x1b, + 0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, 0x28, 0x08, 0xe2, 0x6f, + 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, + 0xe1, 0x1f, 0x95, 0xdb, 0x04, 0xa1, 0x60, 0x81, 0xba, 0x88, 0xbf, 0x05, 0xec, 0x02, 0xfe, 0x36, + 0xfc, 0x81, 0xf8, 0x5b, 0xe0, 0x2e, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0xc1, + 0xbb, 0x88, 0xbf, 0x05, 0xef, 0x02, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x06, + 0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, 0xe2, 0x6f, 0x61, 0x10, + 0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x16, 0x2f, 0xea, 0x10, 0xfe, 0x83, 0x0c, 0x78, 0x12, 0x32, + 0x34, 0x33, 0xc8, 0x80, 0x27, 0x22, 0x53, 0x33, 0x83, 0x0c, 0x78, 0x32, 0x32, 0x36, 0x63, 0xe8, + 0x40, 0x88, 0xbf, 0x05, 0xa1, 0x00, 0xfe, 0x86, 0x0e, 0x86, 0xf8, 0x1b, 0x28, 0x04, 0xe1, 0x6f, + 0xe3, 0x30, 0x88, 0xbf, 0x85, 0x83, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, + 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xb1, 0x4e, 0xf0, 0x0b, 0x16, + 0xa0, 0x8c, 0xf8, 0x5b, 0xa0, 0x32, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, 0x05, 0x2c, 0x03, 0xfe, + 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0xb4, 0x8c, 0xf8, 0x5b, 0xd0, 0x32, 0xe0, 0x6f, + 0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x36, 0x5c, 0xe2, 0x6f, 0x5e, 0x00, + 0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0xe6, 0x1d, 0xe0, 0x6f, 0x2e, 0x83, 0x12, 0xe1, + 0x3f, 0xc8, 0x60, 0x2b, 0x3f, 0x13, 0x37, 0x83, 0x0c, 0xb6, 0x02, 0x36, 0x72, 0x33, 0xc8, 0x60, + 0x2b, 0x61, 0x33, 0x37, 0x66, 0x12, 0x84, 0xf8, 0x5b, 0xe0, 0x07, 0xe0, 0x6f, 0x26, 0x61, 0x88, + 0xbf, 0xf5, 0x41, 0x10, 0xfe, 0x16, 0x12, 0x83, 0xf8, 0xdb, 0x3f, 0x08, 0xe2, 0x6f, 0x82, 0x20, + 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0x95, 0xfa, 0x04, 0xfd, 0x60, 0x81, 0xd9, 0x88, 0xbf, 0x05, 0x68, 0x03, 0xfe, 0x36, 0xec, 0x83, + 0xf8, 0x5b, 0xa0, 0x36, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0xc1, 0xda, 0x88, + 0xbf, 0x05, 0x6b, 0x03, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, + 0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, 0x26, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xde, 0x01, + 0xfe, 0x26, 0x37, 0x66, 0x11, 0xfe, 0xc6, 0x36, 0x78, 0x12, 0xfe, 0x83, 0x0c, 0xf2, 0xe2, 0x37, + 0xb0, 0x33, 0xc8, 0x20, 0x2f, 0x7f, 0x13, 0x3b, 0x83, 0x0c, 0xf2, 0x02, 0x3a, 0xb2, 0x63, 0x65, + 0x51, 0x88, 0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, 0x81, 0x88, 0xbf, 0xa5, + 0x05, 0x22, 0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, 0x85, 0x20, 0xfe, 0x26, + 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, + 0xfe, 0x51, 0xad, 0x50, 0xe0, 0x13, 0x16, 0x9c, 0x8e, 0xf8, 0x5b, 0x90, 0x3a, 0xe0, 0x6f, 0x03, + 0x4f, 0x88, 0xbf, 0x05, 0xab, 0x03, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0xb0, + 0x8e, 0xf8, 0x5b, 0xc0, 0x3a, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x60, 0xe2, 0x6f, 0x61, 0x10, + 0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x06, 0x01, + 0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x3f, 0x86, 0x60, 0xc8, 0xd0, 0x18, 0xc2, 0x11, 0x42, 0x26, 0x04, + 0xe0, 0x3f, 0xc7, 0xe0, 0x3b, 0x41, 0x0c, 0x8d, 0x21, 0x20, 0x36, 0x34, 0x86, 0x90, 0x94, 0x90, + 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x01, 0x0e, 0x8d, 0x21, 0x28, 0x3a, 0x34, 0x86, 0xb0, 0xa4, + 0x90, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x81, 0x0e, 0x8d, 0x21, 0x34, 0x3e, 0x34, 0x86, 0xe0, + 0xb4, 0x90, 0x09, 0x01, 0xf8, 0x0f, 0x32, 0xf8, 0xc7, 0x7a, 0x94, 0xd0, 0x20, 0x43, 0x80, 0x1b, + 0x25, 0x34, 0xc8, 0x00, 0x22, 0xed, 0x51, 0x42, 0x83, 0x0c, 0x81, 0x6e, 0x94, 0x90, 0xb5, 0x4f, + 0x10, 0xfe, 0x66, 0x3f, 0x06, 0xf9, 0xcf, 0x31, 0xc0, 0x4f, 0x30, 0x46, 0x83, 0x0c, 0x41, 0xfc, + 0xa0, 0x90, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x48, 0x75, 0x54, + 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd2, 0x1d, 0x25, 0xc1, 0x20, 0x43, 0x50, + 0x3f, 0x32, 0x34, 0xc7, 0x10, 0xf4, 0xcf, 0x18, 0x8d, 0x18, 0x24, 0x43, 0x08, 0x82, 0xc1, 0xb3, + 0x47, 0x62, 0x74, 0x3b, 0x81, 0x1a, 0xad, 0xd1, 0x18, 0xc2, 0xed, 0xb8, 0x51, 0x05, 0x39, 0x04, + 0x73, 0x0c, 0xb9, 0x13, 0xc0, 0x11, 0xe5, 0x8e, 0x51, 0x08, 0x77, 0x8c, 0x42, 0xb7, 0x63, 0x14, + 0xb2, 0x1d, 0xa3, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x88, 0xc1, 0x1d, 0x15, 0x83, + 0x0c, 0x45, 0x0f, 0xd1, 0xd0, 0x05, 0xd4, 0xda, 0x10, 0x88, 0xff, 0x20, 0x03, 0x02, 0x46, 0x36, + 0x74, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xfd, + 0x51, 0x60, 0x42, 0x10, 0xfe, 0x83, 0x0c, 0x4c, 0x19, 0xf1, 0xd0, 0x05, 0xd4, 0x1a, 0x11, 0x88, + 0xff, 0x20, 0xc3, 0x83, 0x46, 0x3e, 0x74, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x10, 0xad, + 0x91, 0x18, 0x5d, 0x40, 0xad, 0x0d, 0x01, 0xf8, 0x0f, 0x32, 0x50, 0x6e, 0x44, 0x46, 0x17, 0x50, + 0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, 0x56, 0x1c, 0xa1, 0xd1, 0x05, 0xd4, 0x5a, 0x12, 0x80, 0xff, + 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xc4, 0x12, 0x28, 0x99, 0x90, 0x22, 0x46, + 0x6c, 0x94, 0x4a, 0xa9, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0xb2, 0x14, + 0x4a, 0x27, 0xb4, 0x8c, 0x51, 0x1b, 0xb5, 0x92, 0x2a, 0x8d, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, + 0x7f, 0x80, 0xc1, 0x2c, 0x89, 0x12, 0x0a, 0x31, 0x64, 0xe4, 0x46, 0xac, 0xb4, 0x4a, 0x23, 0x06, + 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x40, 0x4b, 0xa3, 0x94, 0x42, 0x4a, 0x19, 0xbd, 0x11, + 0x2b, 0xb1, 0xd2, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xd4, 0x12, 0x29, 0xa9, + 0xd0, 0x62, 0x46, 0x70, 0x04, 0x4b, 0xad, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, + 0x06, 0xb6, 0x54, 0x4a, 0x2b, 0xc4, 0x9c, 0x51, 0x1c, 0xbd, 0x92, 0x2b, 0x8d, 0x18, 0x30, 0x45, + 0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0x2d, 0x99, 0x12, 0x0b, 0x29, 0x68, 0x24, 0x47, 0xaf, 0xf4, + 0x4a, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x80, 0x4b, 0xa7, 0xd4, 0x42, 0x4b, + 0x1a, 0xcd, 0xd1, 0x2c, 0xc1, 0xd2, 0x88, 0x01, 0x53, 0x84, 0x20, 0x58, 0xf8, 0x07, 0x18, 0xe4, + 0x12, 0x2a, 0xb9, 0x10, 0xa3, 0x46, 0x74, 0x24, 0x4b, 0xb1, 0x34, 0x62, 0xc0, 0x14, 0x21, 0x08, + 0x16, 0xfe, 0x01, 0x06, 0xba, 0x94, 0x4a, 0x2f, 0xa4, 0xac, 0x51, 0x1d, 0xc9, 0x92, 0x2c, 0x8d, + 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0x2e, 0xa9, 0x12, 0x0c, 0x2d, 0x6c, 0x64, + 0x47, 0xb6, 0x34, 0x4b, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xc0, 0x4b, 0xab, + 0x14, 0x43, 0x4c, 0x1b, 0xdd, 0x51, 0x2d, 0xd1, 0x92, 0x29, 0x0c, 0xf8, 0x5b, 0x40, 0x46, 0xe2, + 0x6f, 0x41, 0x03, 0xfe, 0xa6, 0x30, 0xe0, 0x6f, 0xc1, 0x19, 0x89, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, + 0xc2, 0x80, 0xbf, 0x05, 0x6a, 0x24, 0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0xb4, + 0x91, 0xf8, 0x5b, 0xd0, 0x80, 0xff, 0x20, 0x83, 0x02, 0x47, 0xa3, 0x34, 0xc8, 0x80, 0xc4, 0x91, + 0x28, 0x0d, 0x32, 0x24, 0x46, 0x28, 0x0d, 0x32, 0x1c, 0x73, 0x44, 0x4a, 0x83, 0x0c, 0x0b, 0x22, + 0x4a, 0x63, 0x08, 0x6d, 0xa0, 0x4e, 0xc6, 0x47, 0x41, 0xf8, 0xcf, 0x31, 0xcc, 0x51, 0x80, 0x4e, + 0x83, 0x0c, 0x01, 0x1c, 0x94, 0x92, 0x05, 0x6f, 0x04, 0xfe, 0x63, 0x08, 0x72, 0xd0, 0x4b, 0x06, + 0x4a, 0x41, 0xf8, 0xcf, 0x31, 0xe0, 0x51, 0xd0, 0x4e, 0x83, 0x0c, 0x41, 0x1e, 0xc5, 0x92, 0x15, + 0x81, 0xf8, 0x1b, 0xd3, 0x84, 0xbf, 0x39, 0x4f, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, + 0x7f, 0x6c, 0xfb, 0x24, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xfc, 0x24, 0x8c, + 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x21, 0x25, 0x04, 0xb6, 0x47, 0x01, 0xf9, 0x9b, + 0x44, 0x85, 0xbf, 0x05, 0x88, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x21, + 0x25, 0x58, 0x40, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x46, 0x52, 0x81, + 0x05, 0x81, 0xf8, 0xdb, 0x95, 0x85, 0xbf, 0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, + 0x85, 0x7f, 0x6c, 0x27, 0x25, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x28, 0x25, + 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x2d, 0x25, 0x04, 0x76, 0x4a, 0x01, 0xf9, + 0x5b, 0x17, 0x06, 0xe1, 0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0x5b, 0x4b, 0x09, 0x16, 0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xc1, + 0x54, 0x60, 0x41, 0x20, 0xfe, 0x83, 0x0c, 0x6e, 0x70, 0x4b, 0xea, 0x34, 0xc8, 0xc0, 0x06, 0xb8, + 0xb4, 0x4e, 0x83, 0x0c, 0x6a, 0x90, 0x4b, 0xea, 0x34, 0xc8, 0x20, 0x0b, 0xb6, 0xa4, 0x4e, 0x26, + 0x06, 0x81, 0xf8, 0x1b, 0x81, 0x06, 0xe1, 0x6f, 0x69, 0x60, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, + 0x20, 0x58, 0xf8, 0xc7, 0x86, 0x53, 0xc2, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x96, + 0x53, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xe5, 0x53, 0x42, 0x60, 0xb8, 0x14, + 0x90, 0xbf, 0x29, 0x4b, 0xf8, 0x5b, 0x80, 0x88, 0xbf, 0x79, 0x01, 0xf8, 0x8f, 0x18, 0x18, 0x44, + 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x3f, 0x35, 0x58, 0x50, 0x88, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0xc7, 0x26, 0x56, 0x81, 0x05, 0x81, 0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, + 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0x91, 0x55, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, + 0x51, 0xa5, 0x55, 0xe0, 0xd9, 0x38, 0x05, 0xe4, 0x6f, 0xd4, 0x1e, 0x84, 0xbf, 0x05, 0x93, 0xf8, + 0x5b, 0xd0, 0x81, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0xa6, 0x56, 0x83, 0x05, + 0x85, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6d, 0x15, 0x58, 0x10, 0x88, + 0xbf, 0x05, 0x0c, 0xf8, 0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, 0x20, + 0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x86, 0x50, 0xb9, 0xd5, 0x18, 0x82, 0xd5, 0x53, 0x26, 0x04, 0xe0, + 0x3f, 0xc7, 0x80, 0x4f, 0x41, 0x5b, 0x8d, 0x21, 0x38, 0x72, 0x35, 0x86, 0xf0, 0x84, 0x95, 0x09, + 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x01, 0x5d, 0x8d, 0x21, 0x24, 0x76, 0x35, 0x86, 0xa0, 0x94, 0x95, + 0x09, 0x01, 0xf8, 0x1b, 0x41, 0x88, 0xff, 0x18, 0x42, 0xa0, 0x57, 0x63, 0x08, 0x42, 0x5a, 0x99, + 0x10, 0x80, 0xff, 0x70, 0x44, 0xb0, 0x52, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x30, + 0x53, 0x68, 0x33, 0x15, 0x84, 0xc0, 0x05, 0xe6, 0x5e, 0xd0, 0xe0, 0x74, 0x03, 0x4d, 0x05, 0xc7, + 0x74, 0x43, 0x4d, 0x55, 0xc8, 0x1c, 0x43, 0x14, 0x98, 0xd6, 0x1c, 0x83, 0x4b, 0x0d, 0xa3, 0x35, + 0xc8, 0x10, 0xbc, 0xd4, 0x59, 0x59, 0x30, 0x88, 0xbf, 0x49, 0x39, 0x25, 0xfe, 0x16, 0x04, 0xe2, + 0x3f, 0x86, 0x30, 0xb0, 0x96, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0x7c, 0x65, 0x41, 0x20, 0xfe, + 0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xe1, 0x56, 0x31, 0x62, + 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xe5, 0x16, 0x31, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, + 0xfe, 0x71, 0xed, 0x96, 0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x96, 0x5a, 0x05, 0x71, 0x81, 0xb9, + 0x17, 0x34, 0x68, 0x49, 0x20, 0xfe, 0x16, 0x9c, 0x15, 0xf8, 0x5b, 0x00, 0x89, 0xbf, 0x05, 0x6c, + 0x05, 0xfe, 0x26, 0xb1, 0x95, 0xf8, 0x9b, 0x5b, 0x05, 0xe1, 0x6f, 0xd4, 0x5a, 0x89, 0xbf, 0xbd, + 0x55, 0x10, 0xfe, 0x17, 0x98, 0x77, 0xc1, 0xb9, 0x75, 0x57, 0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, + 0x8e, 0x21, 0xd8, 0xc4, 0x6c, 0x19, 0x5e, 0x05, 0xe1, 0x3f, 0xc7, 0xf0, 0x56, 0x01, 0x79, 0xcd, + 0x31, 0x04, 0x03, 0x7a, 0x8d, 0x21, 0xdc, 0x84, 0x6d, 0x19, 0x5f, 0x05, 0xe1, 0x3f, 0xc7, 0x30, + 0x57, 0x01, 0x7a, 0xcd, 0x31, 0x04, 0x03, 0x7b, 0x8d, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, + 0x54, 0xf7, 0x55, 0x04, 0x63, 0x08, 0x3f, 0xd1, 0x5b, 0x16, 0x5a, 0x41, 0xf8, 0xcf, 0x31, 0xe0, + 0x55, 0xd0, 0x5e, 0x73, 0x0c, 0xc1, 0x10, 0x5f, 0x63, 0x08, 0x60, 0x31, 0x5f, 0x56, 0x5a, 0x41, + 0xf8, 0xcf, 0x31, 0xf0, 0x55, 0x10, 0x5f, 0x73, 0x0c, 0xc1, 0x50, 0x5f, 0x23, 0x06, 0x07, 0x11, + 0x82, 0x60, 0xe1, 0x1f, 0x15, 0x88, 0x15, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, + 0x15, 0x62, 0x4a, 0x30, 0x86, 0x80, 0x16, 0xe6, 0x65, 0xab, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x68, + 0x05, 0xf7, 0x35, 0xc7, 0x10, 0x0c, 0xfb, 0x35, 0x86, 0x90, 0x16, 0xe9, 0x65, 0xaf, 0x15, 0x84, + 0xff, 0x1c, 0x83, 0x69, 0x05, 0xfb, 0x35, 0xc7, 0x10, 0x0c, 0xff, 0x35, 0x62, 0x70, 0x10, 0x21, + 0x08, 0x16, 0xfe, 0x51, 0xa9, 0x58, 0x11, 0x8c, 0x21, 0xc4, 0x05, 0x7c, 0x19, 0x6d, 0x05, 0xe1, + 0x3f, 0xc7, 0xb0, 0x5a, 0x01, 0x88, 0xcd, 0x31, 0x04, 0x03, 0x89, 0x8d, 0x21, 0xc8, 0x85, 0x89, + 0x19, 0x6e, 0x05, 0xe1, 0x3f, 0xc7, 0xf0, 0x5a, 0x01, 0x89, 0xcd, 0x31, 0x04, 0x03, 0x8a, 0x8d, + 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x33, 0x56, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, + 0x60, 0xe1, 0x1f, 0x15, 0x8d, 0x29, 0xc1, 0x18, 0x82, 0x5e, 0xe4, 0x97, 0xf9, 0x56, 0x10, 0xfe, + 0x73, 0x0c, 0xb5, 0x15, 0xa8, 0xd8, 0x1c, 0x43, 0x30, 0xb8, 0xd8, 0x18, 0xc2, 0x5e, 0xf0, 0x97, + 0x89, 0x57, 0x10, 0xfe, 0x73, 0x0c, 0xb9, 0x15, 0xb8, 0xd8, 0x1c, 0x43, 0x30, 0xc8, 0xd8, 0x88, + 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xd5, 0x63, 0x45, 0x30, 0x86, 0x30, 0x1a, 0x23, 0x66, + 0xe7, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x6f, 0x05, 0x33, 0x36, 0xc7, 0x10, 0x0c, 0x37, 0x36, 0x86, + 0x40, 0x1a, 0x39, 0x66, 0xeb, 0x15, 0x84, 0xff, 0x1c, 0x83, 0x78, 0x05, 0x37, 0x36, 0xc7, 0x10, + 0x0c, 0x3b, 0x36, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x99, 0x59, 0x11, 0x8c, 0x18, + 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x67, 0xa6, 0x04, 0x83, 0x0c, 0x81, 0x79, 0x91, 0xd8, + 0x20, 0xc3, 0x78, 0x9c, 0xd7, 0x7f, 0x59, 0x78, 0x05, 0xe1, 0x6f, 0xe8, 0x35, 0x13, 0xe1, 0x3f, + 0xc8, 0x60, 0x1b, 0xee, 0x15, 0x62, 0x83, 0x0c, 0xb6, 0xf1, 0x5e, 0x22, 0x36, 0xc8, 0x60, 0x1b, + 0xf0, 0x35, 0x62, 0x83, 0x0c, 0xbd, 0xd0, 0x5e, 0x25, 0x66, 0x81, 0x21, 0xfe, 0x83, 0x0c, 0xbf, + 0xf0, 0x5e, 0x23, 0x66, 0xc1, 0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, + 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x73, 0x0c, 0xf5, 0x25, 0x0b, 0x6a, 0x36, 0xc8, 0x10, 0xd8, 0x97, + 0x8b, 0x59, 0x60, 0x88, 0xff, 0x1c, 0x03, 0x7e, 0xcd, 0x42, 0x9b, 0x0d, 0x32, 0x04, 0xf9, 0x15, + 0x63, 0x16, 0x18, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x73, + 0x0c, 0xfe, 0x25, 0x0b, 0x73, 0x36, 0xc8, 0x10, 0xfc, 0xd7, 0x8d, 0x8d, 0x18, 0x1c, 0x44, 0x08, + 0x82, 0x85, 0x7f, 0x54, 0xa3, 0x36, 0x04, 0x16, 0xfc, 0x97, 0xf8, 0x5b, 0x10, 0x62, 0xe0, 0x3f, + 0xc7, 0x30, 0x62, 0xbc, 0x80, 0x67, 0x83, 0x0c, 0x01, 0x89, 0xf1, 0x98, 0x05, 0x85, 0xf8, 0x5b, + 0x50, 0x62, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x66, 0x18, 0xe2, 0x6f, 0x81, 0x89, 0x89, 0xbf, 0x05, + 0x26, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x18, 0x88, 0xbf, 0x09, 0x62, 0x20, 0xfe, 0x36, + 0x88, 0x81, 0xf8, 0xdb, 0x89, 0xa1, 0x41, 0xf8, 0xdb, 0x8a, 0xe9, 0x45, 0xf8, 0x0f, 0x32, 0xe8, + 0x47, 0x8d, 0xa1, 0xd9, 0x20, 0x83, 0x7e, 0xd8, 0x58, 0x9a, 0x0d, 0x32, 0xe8, 0xc7, 0x8d, 0xa9, + 0x99, 0x9d, 0x41, 0x21, 0xfe, 0x66, 0x06, 0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa1, 0x01, 0x22, + 0xfe, 0xb6, 0x06, 0x88, 0xf8, 0x5b, 0x20, 0x84, 0xbf, 0x91, 0x01, 0x21, 0xfe, 0x26, 0x06, 0x82, + 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, + 0x20, 0x58, 0xf8, 0x47, 0x25, 0x6e, 0x01, 0x18, 0x58, 0xe0, 0x63, 0xe2, 0x6f, 0x01, 0x98, 0x81, + 0xbf, 0x0d, 0x9e, 0xf8, 0x5b, 0x20, 0x66, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, + 0xc1, 0x98, 0x89, 0xbf, 0x05, 0x63, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, + 0x78, 0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, 0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, + 0xf8, 0xdb, 0x41, 0x06, 0xe0, 0x6f, 0x67, 0x96, 0x0a, 0xe1, 0x6f, 0x67, 0xb6, 0x1b, 0xe1, 0x3f, + 0xc8, 0xb0, 0x23, 0x76, 0x86, 0x6a, 0x83, 0x0c, 0x3b, 0x72, 0x67, 0xa9, 0x36, 0xc8, 0xb0, 0x23, + 0x78, 0xa6, 0x6a, 0x86, 0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, + 0x0a, 0x88, 0xf8, 0x1b, 0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, + 0x28, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, + 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0xc8, 0x05, 0xa1, 0x60, 0xc1, 0x9f, 0x89, 0xbf, 0x05, + 0xa1, 0x06, 0xfe, 0x36, 0xfc, 0x81, 0xf8, 0x5b, 0x30, 0x6a, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, + 0x10, 0xe2, 0x6f, 0x01, 0xa9, 0x89, 0xbf, 0x05, 0xa4, 0x06, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, + 0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, + 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x66, 0x6a, 0xea, 0x10, 0xfe, 0x83, + 0x0c, 0x78, 0x62, 0x6b, 0xe9, 0x36, 0xc8, 0x80, 0x27, 0xb7, 0xa6, 0x6e, 0x83, 0x0c, 0x78, 0x82, + 0x6b, 0xeb, 0x66, 0xe8, 0x40, 0x88, 0xbf, 0x05, 0xa1, 0x00, 0xfe, 0x86, 0x0e, 0x86, 0xf8, 0x1b, + 0x28, 0x04, 0xe1, 0x6f, 0xe3, 0x30, 0x88, 0xbf, 0x85, 0x83, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, + 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x85, + 0x5d, 0xf0, 0x0b, 0x16, 0xf4, 0x9a, 0xf8, 0x5b, 0xf0, 0x6b, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, + 0x05, 0xe1, 0x06, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, 0x88, 0x9b, 0xf8, 0x5b, + 0x20, 0x6e, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x36, 0x5c, + 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0xe6, 0x1d, 0xe0, 0x6f, + 0xe3, 0x86, 0x12, 0xe1, 0x3f, 0xc8, 0x60, 0x2b, 0xf4, 0x66, 0x72, 0x83, 0x0c, 0xb6, 0x52, 0x6f, + 0x27, 0x37, 0xc8, 0x60, 0x2b, 0xf6, 0x86, 0x72, 0x66, 0x12, 0x84, 0xf8, 0x5b, 0xe0, 0x07, 0xe0, + 0x6f, 0x26, 0x61, 0x88, 0xbf, 0xf5, 0x41, 0x10, 0xfe, 0x16, 0x12, 0x83, 0xf8, 0xdb, 0x3f, 0x08, + 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, + 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0xdf, 0x05, 0xfd, 0x60, 0xc1, 0xbe, 0x89, 0xbf, 0x05, 0xfd, 0x06, + 0xfe, 0x36, 0xec, 0x83, 0xf8, 0x5b, 0xf0, 0x6f, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, + 0x6f, 0x01, 0xc8, 0x89, 0xbf, 0x05, 0x20, 0x07, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x81, 0x25, 0xfe, + 0xe6, 0x05, 0xe0, 0x6f, 0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, 0x26, 0xfe, 0xe6, 0x05, + 0xe0, 0x6f, 0xde, 0x01, 0xfe, 0x76, 0x72, 0x66, 0x11, 0xfe, 0x16, 0x72, 0x78, 0x12, 0xfe, 0x83, + 0x0c, 0xf2, 0x32, 0x73, 0x65, 0x37, 0xc8, 0x20, 0x2f, 0x34, 0x67, 0x76, 0x83, 0x0c, 0xf2, 0x52, + 0x73, 0x67, 0x67, 0x65, 0x51, 0x88, 0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, + 0x81, 0x88, 0xbf, 0xa5, 0x05, 0x22, 0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, + 0x85, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, + 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0x81, 0x5f, 0xe0, 0x13, 0x16, 0xf0, 0x9c, 0xf8, 0x5b, 0xe0, + 0x73, 0xe0, 0x6f, 0x03, 0x4f, 0x88, 0xbf, 0x05, 0x60, 0x07, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, + 0x21, 0xfe, 0x16, 0x84, 0x9d, 0xf8, 0x5b, 0x10, 0x76, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x60, + 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, 0x26, + 0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x3f, 0x86, 0x60, 0x9c, 0xdf, 0x18, 0xc2, + 0x61, 0x7b, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x30, 0x77, 0x81, 0xf9, 0x8d, 0x21, 0x20, 0xeb, 0x37, + 0x86, 0x90, 0xe8, 0x9e, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x41, 0xfb, 0x8d, 0x21, 0x28, 0xef, + 0x37, 0x86, 0xb0, 0xf8, 0x9e, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0xc1, 0xfb, 0x8d, 0x21, 0x34, + 0xf3, 0x37, 0x86, 0xe0, 0x88, 0x9f, 0x09, 0x01, 0xf8, 0x0f, 0x32, 0xf8, 0xc7, 0x7a, 0xe8, 0xde, + 0x20, 0x43, 0x80, 0x1b, 0xba, 0x37, 0xc8, 0x00, 0x22, 0xed, 0xa1, 0x7b, 0x83, 0x0c, 0x81, 0x6e, + 0xe8, 0x9e, 0x89, 0x5e, 0x10, 0xfe, 0xb6, 0x7a, 0x06, 0xf9, 0xcf, 0x31, 0x94, 0x5e, 0x80, 0x7f, + 0x83, 0x0c, 0x81, 0xe9, 0xf5, 0x9e, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, + 0x7f, 0x48, 0x2a, 0x18, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x87, 0xc4, 0x82, + 0x41, 0x12, 0x0c, 0x32, 0x04, 0xaa, 0x77, 0x7e, 0x73, 0x0c, 0x81, 0xec, 0xe1, 0xdf, 0x88, 0x41, + 0x32, 0x84, 0x20, 0x18, 0x3c, 0x30, 0x18, 0xdc, 0xdf, 0xec, 0x04, 0xff, 0x07, 0x82, 0xc1, 0x18, + 0x02, 0xdb, 0xc5, 0x5f, 0x05, 0xee, 0x07, 0x73, 0x0c, 0xb5, 0x13, 0xcc, 0x1f, 0xb9, 0x9d, 0x51, + 0xa8, 0xed, 0x8c, 0x42, 0x6c, 0x67, 0x14, 0x5a, 0x3b, 0xa3, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, + 0x85, 0x7f, 0x88, 0x01, 0x0b, 0x06, 0xc5, 0x20, 0x43, 0x21, 0x7f, 0xe9, 0x77, 0x01, 0xb5, 0x36, + 0x04, 0xe2, 0x3f, 0xc8, 0x80, 0xd4, 0xdf, 0xfa, 0x5d, 0x40, 0xad, 0x0d, 0x01, 0xf8, 0x8f, 0x18, + 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x34, 0x18, 0x04, 0x26, 0x04, 0xe1, 0x3f, 0xc8, 0xc0, + 0xe8, 0x5f, 0xfc, 0x5d, 0x40, 0xad, 0x11, 0x81, 0xf8, 0x0f, 0x32, 0x3c, 0xfd, 0x37, 0x7f, 0x17, + 0x50, 0x6b, 0x43, 0x00, 0xfe, 0x83, 0x0c, 0x11, 0x08, 0x06, 0xf7, 0x77, 0x01, 0xb5, 0x36, 0x04, + 0xe0, 0x3f, 0xc8, 0x40, 0x8d, 0x60, 0x90, 0x7f, 0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, + 0x96, 0x09, 0x06, 0xfd, 0x77, 0x01, 0xb5, 0x96, 0x04, 0xe0, 0x3f, 0x62, 0xc0, 0x14, 0x21, 0x08, + 0x16, 0xfe, 0x01, 0x06, 0x66, 0x18, 0xd4, 0x60, 0xb0, 0x7b, 0xca, 0xfd, 0x85, 0x60, 0xe0, 0x83, + 0x81, 0x0f, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x70, 0x86, 0x81, 0x0d, + 0x06, 0xbc, 0xb7, 0xe0, 0x9f, 0x08, 0x06, 0x62, 0x18, 0xfc, 0x60, 0x30, 0x62, 0xc0, 0x14, 0x21, + 0x08, 0x16, 0xfe, 0x01, 0x06, 0x68, 0x18, 0xdc, 0x60, 0xd0, 0x7b, 0x4c, 0xfe, 0x8d, 0x60, 0x10, + 0x86, 0x01, 0x18, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0x90, 0x86, 0x01, + 0x0e, 0x06, 0xbe, 0xa7, 0xe8, 0x1f, 0x09, 0x06, 0x61, 0x18, 0x84, 0x61, 0x30, 0x62, 0xc0, 0x14, + 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6a, 0x18, 0xe4, 0x60, 0xf0, 0x7b, 0xcb, 0xfe, 0x95, 0x60, + 0x50, 0x86, 0x81, 0x18, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xb0, 0x86, + 0x81, 0x0e, 0x06, 0xe0, 0xc7, 0xf0, 0x9f, 0x09, 0x06, 0x64, 0x18, 0x8c, 0x61, 0x30, 0x62, 0xc0, + 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6c, 0x18, 0xec, 0x60, 0x10, 0x7e, 0x4a, 0xff, 0x9d, + 0x60, 0x40, 0x86, 0x01, 0x19, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, 0xd0, + 0x86, 0x01, 0x0f, 0x06, 0xe2, 0xb7, 0xf8, 0x1f, 0x0a, 0x06, 0x68, 0x18, 0x94, 0x61, 0x30, 0x62, + 0xc0, 0x14, 0x21, 0x08, 0x16, 0xfe, 0x01, 0x06, 0x6e, 0x18, 0xf4, 0x60, 0x30, 0x7e, 0xcc, 0xff, + 0xa5, 0x60, 0x70, 0x86, 0x81, 0x19, 0x06, 0x23, 0x06, 0x4c, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x60, + 0xf0, 0x86, 0x81, 0x0f, 0x06, 0xe4, 0xa7, 0x80, 0x60, 0xa0, 0x82, 0xc1, 0x19, 0x06, 0x67, 0x18, + 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0x1c, 0x06, 0x3f, 0x18, 0x94, 0xdf, + 0x12, 0x82, 0xc1, 0x0a, 0x06, 0x6b, 0x18, 0xa0, 0x61, 0x30, 0x62, 0xc0, 0x14, 0x21, 0x08, 0x16, + 0xfe, 0x01, 0x06, 0x71, 0x18, 0x80, 0x61, 0x60, 0x7e, 0x8c, 0x08, 0x06, 0x2c, 0x18, 0xa8, 0x61, + 0x90, 0x86, 0x81, 0x29, 0x0c, 0xf8, 0x5b, 0x90, 0x7f, 0xe2, 0x6f, 0x41, 0x03, 0xfe, 0xa6, 0x30, + 0xe0, 0x6f, 0x01, 0xff, 0x89, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xff, 0x27, + 0xfe, 0x16, 0x34, 0xe0, 0x6f, 0x0a, 0x03, 0xfe, 0x16, 0x88, 0x60, 0x20, 0xfe, 0x16, 0x34, 0xe0, + 0x3f, 0xc8, 0xa0, 0x94, 0x60, 0x80, 0x83, 0xc1, 0x20, 0x03, 0x62, 0x82, 0xc1, 0x0d, 0x06, 0x83, + 0x0c, 0x89, 0x61, 0x83, 0xc1, 0x20, 0xc3, 0x81, 0x82, 0x41, 0x0e, 0x06, 0x83, 0x0c, 0x0b, 0x72, + 0x83, 0xc1, 0x18, 0x42, 0x1b, 0xfc, 0x61, 0x60, 0x31, 0x18, 0x04, 0xe1, 0x3f, 0xc7, 0x80, 0x82, + 0x41, 0xd0, 0x87, 0xc1, 0x20, 0x43, 0x00, 0x07, 0x3a, 0x18, 0x58, 0x40, 0x82, 0x01, 0xf8, 0x8f, + 0x21, 0xc8, 0x81, 0x1c, 0x06, 0x56, 0x83, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x2d, 0x18, 0x04, 0xa2, + 0x18, 0x0c, 0x32, 0x04, 0x2e, 0x18, 0x98, 0x61, 0x60, 0x45, 0x20, 0xfe, 0xc6, 0x34, 0xe1, 0x6f, + 0xce, 0x13, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x2c, 0x06, 0xc2, 0x88, + 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x16, 0x8b, 0x81, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, + 0x16, 0xfe, 0x51, 0xd9, 0x62, 0x20, 0x04, 0x06, 0x83, 0x41, 0x40, 0xfe, 0x26, 0x51, 0xe1, 0x6f, + 0x01, 0x22, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2d, 0x06, 0x82, 0x05, + 0x84, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb9, 0x18, 0x04, 0x16, 0x04, + 0xe2, 0x6f, 0x57, 0x16, 0xfe, 0xa6, 0x71, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, + 0xb1, 0xf1, 0x62, 0x20, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xbd, 0x18, 0x08, + 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x95, 0x38, 0x06, 0x42, 0x60, 0x3c, 0x18, 0x04, + 0xe4, 0x6f, 0x5d, 0x18, 0x84, 0xbf, 0x05, 0x94, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, + 0x7f, 0x6c, 0xe2, 0x18, 0x08, 0x16, 0x10, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, + 0xb1, 0x95, 0x63, 0x10, 0x58, 0x10, 0x88, 0xff, 0x20, 0x83, 0x1b, 0xb0, 0x61, 0xf0, 0x87, 0xc1, + 0x20, 0x03, 0x1b, 0xb4, 0x61, 0x00, 0x8a, 0xc1, 0x20, 0x83, 0x1a, 0xb8, 0x61, 0xf0, 0x87, 0xc1, + 0x20, 0x83, 0x2c, 0xac, 0x61, 0xf0, 0x87, 0x81, 0x89, 0x41, 0x20, 0xfe, 0x46, 0xa0, 0x41, 0xf8, + 0x5b, 0x1a, 0x18, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xb5, 0x63, 0x20, + 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xee, 0x18, 0x08, 0x23, 0x06, 0x07, 0x11, + 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0x3c, 0x06, 0x42, 0x60, 0x6d, 0x18, 0x04, 0xe4, 0x6f, 0xca, 0x12, + 0xfe, 0x16, 0x20, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0x1b, 0x3d, 0x06, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, + 0xf7, 0x18, 0x04, 0x16, 0x04, 0xe2, 0x6f, 0x50, 0x1d, 0x84, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0xc7, 0x96, 0x8f, 0x41, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xf9, + 0x63, 0x10, 0x78, 0x86, 0x87, 0x41, 0x40, 0xfe, 0x46, 0xed, 0x41, 0xf8, 0x5b, 0x30, 0x89, 0xbf, + 0x05, 0x1d, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xff, 0x18, 0x0c, 0x16, + 0x14, 0xe2, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0x89, 0x64, 0x10, 0x58, 0x10, + 0x88, 0xbf, 0x05, 0x0c, 0xf8, 0x5b, 0xa0, 0x89, 0xbf, 0x81, 0x01, 0x1b, 0x80, 0xbf, 0x05, 0x79, + 0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x86, 0x50, 0x8d, 0x64, 0x30, 0x86, 0x60, 0xc9, 0x63, 0x60, + 0x42, 0x00, 0xfe, 0x73, 0x0c, 0xad, 0x18, 0x04, 0x22, 0x19, 0x8c, 0x21, 0x38, 0x27, 0x19, 0x8c, + 0x21, 0x3c, 0xf6, 0x18, 0x98, 0x10, 0x80, 0xff, 0x1c, 0x03, 0x11, 0xa4, 0x64, 0x30, 0x86, 0x90, + 0xac, 0x64, 0x30, 0x86, 0xa0, 0xe8, 0x63, 0x60, 0x42, 0x00, 0xfe, 0x46, 0x10, 0xe2, 0x3f, 0x86, + 0x10, 0xbc, 0x64, 0x30, 0x86, 0x20, 0xf8, 0x63, 0x60, 0x42, 0x00, 0xfe, 0xc3, 0x11, 0x01, 0x38, + 0x06, 0x84, 0x7f, 0x9c, 0x60, 0xde, 0x05, 0xe7, 0x56, 0x80, 0x8e, 0x01, 0x1a, 0x3a, 0x06, 0x41, + 0x08, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x4e, 0x37, 0xa4, 0x63, 0x10, 0x1c, 0xd3, 0x0d, 0xea, 0x18, + 0x54, 0xc8, 0x1c, 0x43, 0x14, 0xec, 0x64, 0x30, 0xc7, 0x30, 0x8e, 0xc1, 0x80, 0x93, 0xc1, 0x20, + 0x43, 0x40, 0x8e, 0x01, 0x3f, 0x06, 0x16, 0x0c, 0xe2, 0x6f, 0x92, 0x3b, 0x06, 0xe2, 0x6f, 0x41, + 0x20, 0xfe, 0x63, 0x08, 0x43, 0x58, 0x06, 0x16, 0x04, 0xe2, 0x3f, 0x86, 0x50, 0xc4, 0x64, 0x60, + 0x41, 0x20, 0xfe, 0x36, 0x04, 0xe0, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x91, 0xb5, + 0x65, 0x50, 0x8c, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x64, 0x6e, 0x19, 0x10, 0x23, 0x06, + 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x17, 0x5c, 0x06, 0x42, 0x70, 0x81, 0x79, 0x17, 0x9c, 0x5b, + 0xff, 0x18, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x68, 0x49, 0x20, 0xfe, 0x16, 0xf0, 0x63, 0x00, + 0xfe, 0x16, 0x40, 0xe2, 0x6f, 0x41, 0x48, 0x06, 0xe0, 0x6f, 0x52, 0x48, 0x06, 0xe2, 0x6f, 0x23, + 0x19, 0x04, 0xe1, 0x6f, 0x14, 0x48, 0x06, 0xe2, 0x6f, 0x24, 0x19, 0x04, 0xe1, 0x7f, 0x81, 0x79, + 0x17, 0x9c, 0x5b, 0x2c, 0x19, 0x04, 0x71, 0x81, 0xb9, 0x17, 0x34, 0x38, 0x86, 0x60, 0x13, 0x68, + 0x19, 0x58, 0x4b, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0x90, 0x64, 0x10, 0xe4, 0x65, 0x30, 0xc7, 0x10, + 0x0c, 0x7d, 0x19, 0x8c, 0x21, 0xdc, 0xc4, 0x5a, 0x06, 0x16, 0x93, 0x41, 0x10, 0xfe, 0x73, 0x0c, + 0x28, 0x19, 0x04, 0x7d, 0x19, 0xcc, 0x31, 0x04, 0x43, 0x68, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, + 0x60, 0xe1, 0x1f, 0x15, 0x6b, 0x06, 0x45, 0x30, 0x86, 0xf0, 0x13, 0x72, 0x19, 0x98, 0x4d, 0x06, + 0x41, 0xf8, 0xcf, 0x31, 0xb4, 0x64, 0x10, 0x88, 0x66, 0x30, 0xc7, 0x10, 0x0c, 0xa6, 0x19, 0x8c, + 0x21, 0x80, 0x05, 0x6a, 0x06, 0xa6, 0x93, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x31, 0x19, 0x04, 0xa6, + 0x19, 0xcc, 0x31, 0x04, 0x83, 0x6a, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x55, + 0x6d, 0x06, 0x45, 0x30, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xd9, 0x66, 0xa0, 0x04, + 0x63, 0x08, 0x68, 0xb1, 0x97, 0x81, 0x81, 0x65, 0x10, 0x84, 0xff, 0x1c, 0xc3, 0x4d, 0x06, 0x01, + 0x6b, 0x06, 0x73, 0x0c, 0xc1, 0x00, 0x9b, 0xc1, 0x18, 0x42, 0x5a, 0xf8, 0x65, 0x60, 0x64, 0x19, + 0x04, 0xe1, 0x3f, 0xc7, 0xb0, 0x93, 0x41, 0x00, 0x9b, 0xc1, 0x1c, 0x43, 0x30, 0xd0, 0x66, 0x30, + 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, 0xfd, 0x66, 0x50, 0x04, 0x63, 0x08, 0x71, 0x51, + 0x9a, 0x81, 0xa5, 0x65, 0x10, 0x84, 0xff, 0x1c, 0x03, 0x58, 0x06, 0x41, 0x6d, 0x06, 0x73, 0x0c, + 0xc1, 0x90, 0x9b, 0xc1, 0x18, 0x82, 0x5c, 0xec, 0x66, 0x60, 0x6d, 0x19, 0x04, 0xe1, 0x3f, 0xc7, + 0x40, 0x96, 0x41, 0x90, 0x9b, 0xc1, 0x1c, 0x43, 0x30, 0xf4, 0x66, 0x30, 0x62, 0x70, 0x10, 0x21, + 0x08, 0x16, 0xfe, 0x51, 0xa1, 0x67, 0x50, 0x04, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0x55, 0x7a, 0x06, 0x4a, 0x30, 0x86, 0xa0, 0x17, 0xae, 0x19, 0xd8, 0x5c, 0x06, 0x41, 0xf8, 0xcf, + 0x31, 0xa8, 0x65, 0x10, 0xfc, 0x66, 0x30, 0xc7, 0x10, 0x0c, 0xe3, 0x19, 0x8c, 0x21, 0xec, 0x45, + 0x6c, 0x06, 0x76, 0x97, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x6e, 0x19, 0x04, 0xe3, 0x19, 0xcc, 0x31, + 0x04, 0xc3, 0x79, 0x06, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x95, 0x7c, 0x06, 0x45, + 0x30, 0x86, 0x30, 0x1a, 0xb8, 0x19, 0x18, 0x5f, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0xcc, 0x65, 0x10, + 0xa0, 0x67, 0x30, 0xc7, 0x10, 0x0c, 0xec, 0x19, 0x8c, 0x21, 0x90, 0x86, 0x7b, 0x06, 0x06, 0x9a, + 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x77, 0x19, 0x04, 0xec, 0x19, 0xcc, 0x31, 0x04, 0x03, 0x7c, 0x06, + 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0xd5, 0x7e, 0x06, 0x45, 0x30, 0x62, 0x70, 0x10, + 0x21, 0x08, 0x16, 0xfe, 0x51, 0xf1, 0x67, 0xa0, 0x04, 0x83, 0x0c, 0xc1, 0x5e, 0x06, 0xb9, 0x19, + 0x0c, 0x32, 0x8c, 0x07, 0x5f, 0x06, 0xb4, 0x19, 0x98, 0x5d, 0x06, 0x41, 0xf8, 0x5b, 0x5f, 0x06, + 0x33, 0x11, 0xfe, 0x83, 0x0c, 0xb6, 0x31, 0x9a, 0x81, 0x6d, 0x06, 0x83, 0x0c, 0xb6, 0x41, 0x9a, + 0xc1, 0x6d, 0x06, 0x83, 0x0c, 0xb6, 0x51, 0x9a, 0x01, 0x6e, 0x06, 0x83, 0x0c, 0xbd, 0x20, 0x9a, + 0x81, 0x6e, 0x06, 0x16, 0x18, 0xe2, 0x3f, 0xc8, 0xf0, 0x0b, 0xa4, 0x19, 0xe0, 0x66, 0x60, 0xc1, + 0x21, 0xfe, 0x36, 0x04, 0xe0, 0x6f, 0x83, 0x22, 0xfe, 0x66, 0x28, 0xe2, 0x6f, 0x81, 0x10, 0xfe, + 0x73, 0x0c, 0xaa, 0x19, 0xc8, 0xc2, 0x7f, 0x06, 0x83, 0x0c, 0xc1, 0x6a, 0x06, 0xe3, 0x19, 0x58, + 0x60, 0x88, 0xff, 0x1c, 0x43, 0x6b, 0x06, 0xb3, 0x20, 0xa2, 0xc1, 0x20, 0x43, 0xe0, 0x9a, 0x81, + 0x79, 0x06, 0x16, 0x18, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, + 0x73, 0x0c, 0xb3, 0x19, 0xc8, 0x02, 0x8a, 0x06, 0x83, 0x0c, 0x01, 0x6d, 0x06, 0xec, 0x19, 0x8c, + 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x38, 0x1a, 0x0c, 0x81, 0x05, 0xb4, 0x19, 0x88, + 0xbf, 0x05, 0xb6, 0x19, 0x80, 0xff, 0x1c, 0x03, 0x6e, 0x06, 0xbc, 0xd0, 0xa2, 0xc1, 0x20, 0x43, + 0x90, 0x9b, 0x41, 0x7c, 0x06, 0x16, 0x14, 0xe2, 0x6f, 0x81, 0x6e, 0x06, 0xe0, 0x6f, 0x41, 0x20, + 0xfe, 0x66, 0x18, 0xe2, 0x6f, 0xc1, 0x6e, 0x06, 0xe2, 0x6f, 0xc1, 0x6e, 0x06, 0xe0, 0x6f, 0x44, + 0x20, 0xfe, 0x16, 0x88, 0x81, 0xf8, 0x9b, 0x20, 0x06, 0xe2, 0x6f, 0x83, 0x18, 0x88, 0xbf, 0xf1, + 0x66, 0x80, 0x06, 0xe1, 0x6f, 0xe0, 0x19, 0xe8, 0x45, 0xf8, 0x0f, 0x32, 0xe8, 0x87, 0x7a, 0x06, + 0xfd, 0x19, 0x0c, 0x32, 0xe8, 0xc7, 0x7a, 0x06, 0xfe, 0x19, 0x0c, 0x32, 0xe8, 0x07, 0x7b, 0x06, + 0xff, 0x19, 0xd8, 0x19, 0x14, 0xe2, 0x6f, 0x66, 0x50, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x1b, 0x1a, + 0x20, 0xe2, 0x6f, 0x6b, 0x80, 0x88, 0xbf, 0x05, 0x42, 0xf8, 0x1b, 0x19, 0x10, 0xe2, 0x6f, 0x62, + 0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, + 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x77, 0x1a, 0x04, 0x60, 0x60, 0xc1, 0x7c, 0x06, 0xe2, 0x6f, + 0x41, 0x7d, 0x06, 0xe0, 0x6f, 0x83, 0x27, 0xfe, 0x16, 0xdc, 0x67, 0x00, 0xfe, 0x16, 0x04, 0xe2, + 0x6f, 0x04, 0x21, 0xfe, 0x16, 0xe0, 0x67, 0x20, 0xfe, 0x16, 0xe0, 0x67, 0x00, 0xfe, 0x46, 0x04, + 0xe2, 0x6f, 0x01, 0x26, 0xfe, 0x16, 0x78, 0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x7c, 0xe0, 0x6f, + 0x85, 0x26, 0xfe, 0x16, 0x80, 0x01, 0xf8, 0xdb, 0x41, 0x06, 0xe0, 0x6f, 0xfc, 0x19, 0xa4, 0x42, + 0xf8, 0x1b, 0x7f, 0x06, 0xbb, 0x11, 0xfe, 0x83, 0x0c, 0x3b, 0xb2, 0xa2, 0x41, 0x8f, 0x06, 0x83, + 0x0c, 0x3b, 0xc2, 0xa2, 0x81, 0x8f, 0x06, 0x83, 0x0c, 0x3b, 0xd2, 0xa2, 0xc1, 0x8f, 0x06, 0x86, + 0x0a, 0x85, 0xf8, 0xdb, 0x29, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x96, 0x0a, 0x88, 0xf8, 0x1b, + 0x2b, 0x20, 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x56, 0x0a, 0x84, 0xf8, 0xdb, 0x28, 0x08, 0xe2, 0x6f, + 0x82, 0x20, 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, + 0xe1, 0x1f, 0x15, 0xae, 0x06, 0x41, 0x28, 0x58, 0x40, 0xa3, 0x81, 0xf8, 0x5b, 0x60, 0xa3, 0x01, + 0xf8, 0xdb, 0xf0, 0x07, 0xe2, 0x6f, 0x01, 0x8e, 0x06, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, + 0xe2, 0x6f, 0x41, 0x8e, 0x06, 0xe2, 0x6f, 0x41, 0x8e, 0x06, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, + 0x60, 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x0d, 0x99, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x85, + 0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0x18, 0x1c, 0xe0, 0x6f, 0x3b, 0x1a, 0xa8, 0x43, 0xf8, + 0x0f, 0x32, 0xe0, 0xc9, 0x9a, 0x06, 0x7e, 0x1a, 0x0c, 0x32, 0xe0, 0x09, 0x9b, 0x06, 0x7f, 0x1a, + 0x0c, 0x32, 0xe0, 0x49, 0x9b, 0x06, 0xa0, 0x1a, 0x18, 0x3a, 0x10, 0xe2, 0x6f, 0x41, 0x28, 0x80, + 0xbf, 0xa1, 0x83, 0x21, 0xfe, 0x06, 0x0a, 0x41, 0xf8, 0xdb, 0x38, 0x0c, 0xe2, 0x6f, 0xe1, 0x20, + 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, + 0x08, 0x82, 0x85, 0x7f, 0x54, 0xf6, 0x1a, 0x04, 0xbf, 0x60, 0x81, 0x9c, 0x06, 0xe2, 0x6f, 0x01, + 0x9d, 0x06, 0xe0, 0x6f, 0x43, 0x2f, 0x88, 0xbf, 0x05, 0x76, 0x1a, 0x80, 0xbf, 0x05, 0x81, 0xf8, + 0x1b, 0x41, 0x88, 0xbf, 0x05, 0x77, 0x1a, 0x88, 0xbf, 0x05, 0x77, 0x1a, 0x80, 0xbf, 0x11, 0x81, + 0xf8, 0x5b, 0x60, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0xdb, 0x70, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x5b, + 0x81, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x9b, 0x77, 0x80, 0xbf, 0xe1, 0x69, 0x80, 0x12, 0xe1, 0x3f, + 0xc8, 0x60, 0x2b, 0xa9, 0x1a, 0xec, 0x6a, 0x30, 0xc8, 0x60, 0x2b, 0xaa, 0x1a, 0xf0, 0x6a, 0x30, + 0xc8, 0x60, 0x2b, 0xab, 0x1a, 0xf4, 0x6a, 0x60, 0x26, 0x41, 0x88, 0xbf, 0x05, 0x7e, 0x00, 0xfe, + 0x66, 0x12, 0x86, 0xf8, 0x5b, 0x1f, 0x04, 0xe1, 0x6f, 0x21, 0x31, 0x88, 0xbf, 0xfd, 0x83, 0x20, + 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, + 0x08, 0x16, 0xfe, 0x51, 0xd1, 0x6c, 0x10, 0xf4, 0x83, 0x05, 0xb0, 0x1a, 0x88, 0xbf, 0x05, 0xb2, + 0x1a, 0x80, 0xbf, 0x0d, 0xfb, 0x20, 0xfe, 0x16, 0xd0, 0x6a, 0x00, 0xfe, 0x16, 0x04, 0xe2, 0x6f, + 0x04, 0x21, 0xfe, 0x16, 0xd4, 0x6a, 0x20, 0xfe, 0x16, 0xd4, 0x6a, 0x00, 0xfe, 0x46, 0x04, 0xe2, + 0x6f, 0x81, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xc3, 0x25, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0x05, + 0x26, 0xfe, 0xe6, 0x05, 0xe0, 0x6f, 0xde, 0x01, 0xfe, 0xc6, 0xab, 0x81, 0x59, 0x84, 0xbf, 0xd9, + 0x6a, 0x80, 0x27, 0xe1, 0x3f, 0xc8, 0x20, 0x2f, 0xe8, 0x1a, 0xe8, 0x6b, 0x30, 0xc8, 0x20, 0x2f, + 0xe9, 0x1a, 0xec, 0x6b, 0x30, 0xc8, 0x20, 0x2f, 0xea, 0x1a, 0xf0, 0x6b, 0x60, 0x65, 0x51, 0x88, + 0xbf, 0x91, 0x45, 0x21, 0xfe, 0x26, 0x04, 0xe0, 0x6f, 0x66, 0x81, 0x88, 0xbf, 0xa5, 0x05, 0x22, + 0xfe, 0x16, 0x08, 0xe1, 0x6f, 0x62, 0x41, 0x88, 0xbf, 0x81, 0x85, 0x20, 0xfe, 0x26, 0x08, 0xe2, + 0x6f, 0x82, 0x20, 0xfe, 0x26, 0x04, 0xe0, 0x3f, 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x51, + 0xd5, 0x6d, 0x10, 0xf8, 0x84, 0x05, 0xf1, 0x1a, 0x88, 0xbf, 0x05, 0xf3, 0x1a, 0x80, 0xbf, 0x0d, + 0x3c, 0x21, 0xfe, 0x16, 0xd4, 0x6b, 0x00, 0xfe, 0x16, 0x04, 0xe2, 0x6f, 0x04, 0x21, 0xfe, 0x16, + 0xd8, 0x6b, 0x20, 0xfe, 0x16, 0xd8, 0x6b, 0x00, 0xfe, 0x46, 0x04, 0xe2, 0x6f, 0x01, 0x26, 0xfe, + 0x16, 0x06, 0x01, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x56, 0x68, 0xe2, 0x6f, + 0x61, 0x10, 0x80, 0xbf, 0x85, 0xc1, 0x01, 0xfe, 0x63, 0x08, 0x06, 0xdf, 0x06, 0x63, 0x08, 0xc7, + 0xda, 0x06, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x80, 0xb2, 0x41, 0xb0, 0xb7, 0xc1, 0x18, 0x02, 0x02, + 0xba, 0xc1, 0x18, 0x42, 0xf2, 0xb6, 0x81, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0x81, 0xe8, 0x06, + 0x63, 0x08, 0x0a, 0xe9, 0x06, 0x63, 0x08, 0xcb, 0xdc, 0x06, 0x26, 0x04, 0xe0, 0x3f, 0xc7, 0x40, + 0x04, 0xa4, 0x1b, 0x8c, 0x21, 0x34, 0xa8, 0x1b, 0x8c, 0x21, 0x38, 0x77, 0x1b, 0x98, 0x10, 0x80, + 0xff, 0x20, 0x83, 0x7f, 0xac, 0xc7, 0xdb, 0x06, 0x83, 0x0c, 0x01, 0x6e, 0xbc, 0x6d, 0x30, 0xc8, + 0x00, 0x22, 0xed, 0xf1, 0xb6, 0xc1, 0x20, 0x43, 0xa0, 0x1b, 0x6f, 0x1b, 0xd8, 0xcd, 0x06, 0x41, + 0xf8, 0x1b, 0xd8, 0x06, 0x06, 0xf9, 0xcf, 0x31, 0xe8, 0x6c, 0x10, 0xb4, 0x6e, 0x30, 0xc8, 0x10, + 0xec, 0x6c, 0x20, 0xb7, 0x81, 0x31, 0x81, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, + 0x48, 0xbf, 0x1b, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x87, 0x14, 0xbe, 0x41, + 0x12, 0x0c, 0x32, 0x04, 0x3f, 0x1b, 0xf0, 0x6d, 0x30, 0xc7, 0x10, 0x9c, 0x6d, 0xd0, 0xba, 0xc1, + 0x88, 0x41, 0x32, 0x84, 0x20, 0x18, 0x3c, 0xe5, 0x1b, 0xb0, 0x6e, 0x30, 0x3b, 0x01, 0xed, 0x06, + 0xb5, 0x1b, 0x0c, 0x32, 0xcc, 0x4e, 0xc8, 0x06, 0x6e, 0x1b, 0x50, 0xc8, 0x06, 0x46, 0x21, 0x90, + 0x0d, 0x8c, 0x42, 0xff, 0x1a, 0x18, 0x85, 0xfc, 0x35, 0x30, 0xca, 0x88, 0x81, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0x87, 0x18, 0xfc, 0x6e, 0x50, 0x0c, 0x32, 0x14, 0xa5, 0x1b, 0xf0, 0x6d, 0x70, 0x01, + 0xb5, 0x36, 0x04, 0xe2, 0x3f, 0xc8, 0x80, 0xa0, 0x6e, 0xe0, 0xb7, 0xc1, 0x05, 0xd4, 0xda, 0x10, + 0x80, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x76, 0xbe, 0x41, 0x60, 0x42, 0x10, + 0xfe, 0x83, 0x0c, 0x4c, 0xeb, 0x06, 0xa4, 0x1b, 0x5c, 0x40, 0xad, 0x11, 0x81, 0xf8, 0x0f, 0x32, + 0x3c, 0xb0, 0x1b, 0x98, 0x6e, 0x70, 0x01, 0xb5, 0x36, 0x04, 0xe0, 0x3f, 0xc8, 0x10, 0xcd, 0x6e, + 0xa0, 0xba, 0xc1, 0x05, 0xd4, 0xda, 0x10, 0x80, 0xff, 0x20, 0x03, 0x65, 0xbb, 0x01, 0xeb, 0x06, + 0x17, 0x50, 0x6b, 0x46, 0x00, 0xfe, 0x83, 0x0c, 0x56, 0xee, 0x06, 0xb0, 0x1b, 0x5c, 0x40, 0xad, + 0x25, 0x01, 0xf8, 0x8f, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x41, 0xfe, 0x06, 0xe8, + 0x1b, 0xb8, 0x6d, 0xa0, 0xa8, 0x6e, 0x40, 0xbb, 0x41, 0xfc, 0x06, 0xf1, 0x1b, 0x8c, 0x18, 0x30, + 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0xfe, 0x06, 0xe9, 0x1b, 0xbc, 0x6d, 0xb0, 0xac, 0x6e, + 0x50, 0xbb, 0x41, 0xfd, 0x06, 0xf2, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, + 0xc1, 0xfe, 0x06, 0xea, 0x1b, 0xc0, 0x6d, 0xc0, 0xb0, 0x6e, 0x60, 0xbb, 0x01, 0xfd, 0x06, 0xf3, + 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0xff, 0x06, 0xeb, 0x1b, 0xc4, + 0x6d, 0xa0, 0xb4, 0x6e, 0x70, 0xbb, 0x01, 0xfd, 0x06, 0xf4, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, + 0x82, 0x85, 0x7f, 0x80, 0x41, 0xff, 0x06, 0xec, 0x1b, 0xc8, 0x6d, 0xb0, 0xb8, 0x6e, 0x80, 0xbb, + 0x01, 0xfe, 0x06, 0xf5, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0xff, + 0x06, 0xed, 0x1b, 0xcc, 0x6d, 0xc0, 0xbc, 0x6e, 0x90, 0xbb, 0xc1, 0xfd, 0x06, 0xf6, 0x1b, 0x8c, + 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0xc1, 0xff, 0x06, 0xee, 0x1b, 0xd0, 0x6d, 0xa0, + 0xc0, 0x6e, 0xa0, 0xbb, 0xc1, 0xfd, 0x06, 0xf7, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, + 0x7f, 0x80, 0x01, 0x08, 0x07, 0xef, 0x1b, 0xd4, 0x6d, 0xb0, 0xc4, 0x6e, 0xb0, 0xbb, 0xc1, 0xfe, + 0x06, 0xf8, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x41, 0x08, 0x07, 0xf0, + 0x1b, 0xd8, 0x6d, 0xc0, 0xc8, 0x6e, 0xc0, 0xbb, 0x81, 0xfe, 0x06, 0xf9, 0x1b, 0x8c, 0x18, 0x30, + 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x81, 0x08, 0x07, 0xf1, 0x1b, 0xdc, 0x6d, 0xa0, 0xcc, 0x6e, + 0xd0, 0xbb, 0x81, 0xfe, 0x06, 0xfa, 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, + 0xc1, 0x08, 0x07, 0xf2, 0x1b, 0xe0, 0x6d, 0xb0, 0xd0, 0x6e, 0xe0, 0xbb, 0x81, 0xff, 0x06, 0xfb, + 0x1b, 0x8c, 0x18, 0x30, 0x45, 0x08, 0x82, 0x85, 0x7f, 0x80, 0x01, 0x09, 0x07, 0xf3, 0x1b, 0xe4, + 0x6d, 0xc0, 0xd4, 0x6e, 0xf0, 0xbb, 0x41, 0xff, 0x06, 0xfc, 0x1b, 0x98, 0xc2, 0x80, 0xbf, 0x05, + 0xac, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xaf, 0x1b, 0x88, 0xbf, + 0x05, 0x0d, 0xf8, 0x9b, 0xc2, 0x80, 0xbf, 0x05, 0xb2, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x9b, + 0xc2, 0x80, 0xbf, 0x05, 0xb5, 0x1b, 0x88, 0xbf, 0x05, 0x0d, 0xf8, 0x0f, 0x32, 0x28, 0xb8, 0x1b, + 0xac, 0x6f, 0x30, 0xc8, 0x80, 0xe4, 0x6e, 0xa0, 0xbe, 0xc1, 0x20, 0x43, 0x62, 0xa4, 0x6f, 0x30, + 0xc8, 0x70, 0xec, 0x6e, 0xc0, 0xbe, 0xc1, 0x20, 0xc3, 0x82, 0xa8, 0x6f, 0x30, 0x86, 0xd0, 0x06, + 0x32, 0x1c, 0x18, 0xf9, 0x06, 0x41, 0xf8, 0xcf, 0x31, 0xec, 0x6e, 0x10, 0xc0, 0x70, 0x30, 0xc8, + 0x10, 0xc0, 0x41, 0xfb, 0x06, 0x16, 0xdc, 0x6e, 0x00, 0xfe, 0x63, 0x08, 0x72, 0x50, 0xc2, 0x81, + 0xa1, 0x6f, 0x10, 0x84, 0xff, 0x1c, 0x03, 0xf8, 0x06, 0x41, 0x0d, 0x07, 0x83, 0x0c, 0x41, 0xf8, + 0x06, 0xf9, 0x1b, 0x58, 0x11, 0x88, 0xbf, 0x31, 0x4d, 0xf8, 0x9b, 0xf3, 0x84, 0xff, 0x88, 0x81, + 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x36, 0xc6, 0x81, 0x30, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, + 0xfe, 0xb1, 0x91, 0x71, 0x20, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x69, 0x1c, + 0x08, 0x81, 0x8d, 0x6f, 0x10, 0x90, 0xbf, 0x49, 0x54, 0xf8, 0x5b, 0x80, 0x88, 0xff, 0x88, 0x81, + 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x96, 0xc6, 0x81, 0x60, 0x01, 0x21, 0xfe, 0x23, 0x06, 0x06, + 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x1b, 0x07, 0x81, 0x05, 0x81, 0xf8, 0xdb, 0x95, 0x85, 0xbf, + 0x69, 0x5c, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x6f, 0x1c, 0x08, 0x23, + 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x1b, 0x1c, 0x07, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0x47, 0x55, 0xc7, 0x81, 0x10, 0xd8, 0xfb, 0x06, 0x01, 0xf9, 0x5b, 0x17, 0x06, 0xe1, + 0x6f, 0x01, 0x25, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x5b, 0x1d, 0x07, 0x82, + 0x05, 0x84, 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0x78, 0x1c, 0x04, 0x16, + 0x04, 0xe2, 0x3f, 0xc8, 0xe0, 0x06, 0xff, 0x1b, 0xc8, 0x70, 0x30, 0xc8, 0xc0, 0x06, 0x20, 0x1c, + 0xcc, 0x70, 0x30, 0xc8, 0xa0, 0x06, 0x21, 0x1c, 0xc8, 0x70, 0x30, 0xc8, 0x20, 0x0b, 0xfe, 0x1b, + 0xc8, 0x70, 0x60, 0x62, 0x10, 0x88, 0xbf, 0x11, 0x68, 0x10, 0xfe, 0x96, 0x06, 0x46, 0xf8, 0x8f, + 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xa0, 0x1c, 0x08, 0x23, 0x06, 0x06, 0x11, 0x82, + 0x60, 0xe1, 0x1f, 0x5b, 0x28, 0x07, 0xc2, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x65, + 0xca, 0x81, 0x10, 0x18, 0x08, 0x07, 0x01, 0xf9, 0x9b, 0xb2, 0x84, 0xbf, 0x05, 0x88, 0xf8, 0x9b, + 0x17, 0x80, 0xff, 0x88, 0x81, 0x41, 0x84, 0x20, 0x58, 0xf8, 0xc7, 0x76, 0xca, 0xc1, 0x60, 0x41, + 0x21, 0xfe, 0x23, 0x06, 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2a, 0x07, 0x81, 0x05, 0x81, + 0xf8, 0x1b, 0x54, 0x07, 0xe1, 0x3f, 0x62, 0x60, 0x10, 0x21, 0x08, 0x16, 0xfe, 0xb1, 0xb1, 0x72, + 0x10, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0xb1, 0x1c, 0x04, 0x9e, 0xad, 0x70, + 0x10, 0x90, 0xbf, 0x51, 0x7b, 0x10, 0xfe, 0x16, 0x4c, 0xe2, 0x6f, 0x41, 0x07, 0xfe, 0x23, 0x06, + 0x06, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x9b, 0x2c, 0x07, 0x83, 0x05, 0x85, 0xf8, 0x8f, 0x18, 0x18, + 0x44, 0x08, 0x82, 0x85, 0x7f, 0x6c, 0xb5, 0x1c, 0x04, 0x16, 0x04, 0xe2, 0x6f, 0x01, 0x03, 0xfe, + 0x16, 0x68, 0xe2, 0x6f, 0x60, 0xc0, 0x06, 0xe0, 0x6f, 0x41, 0x1e, 0x88, 0xbf, 0x0d, 0x01, 0xf8, + 0x8f, 0x21, 0x54, 0xb6, 0x1c, 0x8c, 0x21, 0x58, 0xa5, 0x1c, 0x98, 0x10, 0x80, 0xff, 0x1c, 0x03, + 0x18, 0x07, 0x41, 0x2d, 0x07, 0x63, 0x08, 0x8e, 0x2e, 0x07, 0x63, 0x08, 0x4f, 0x2a, 0x07, 0x26, + 0x04, 0xe0, 0x3f, 0xc7, 0x40, 0x04, 0xbc, 0x1c, 0x8c, 0x21, 0x24, 0xbe, 0x1c, 0x8c, 0x21, 0x28, + 0xad, 0x1c, 0x98, 0x10, 0x80, 0xbf, 0x11, 0x84, 0xf8, 0x8f, 0x21, 0x04, 0xe2, 0x1c, 0x8c, 0x21, + 0x08, 0xb1, 0x1c, 0x98, 0x10, 0x80, 0xff, 0x70, 0x44, 0x30, 0xc7, 0x01, 0xe1, 0x1f, 0x27, 0x98, + 0x77, 0xc1, 0xb9, 0x15, 0xec, 0x71, 0x80, 0xb6, 0xc7, 0x41, 0x10, 0x02, 0x17, 0x98, 0x7b, 0x41, + 0x83, 0xd3, 0x0d, 0x7c, 0x1c, 0x04, 0xc7, 0x74, 0x43, 0x1f, 0x07, 0x15, 0x32, 0xc7, 0x10, 0x05, + 0xee, 0x1c, 0xcc, 0x31, 0xd8, 0x71, 0x30, 0xac, 0x73, 0x30, 0xc8, 0x10, 0xdc, 0x71, 0xf0, 0xca, + 0x81, 0x05, 0x83, 0xf8, 0x9b, 0x14, 0xca, 0x81, 0xf8, 0x5b, 0x10, 0x88, 0xff, 0x18, 0xc2, 0x40, + 0xcf, 0x81, 0x05, 0x81, 0xf8, 0x8f, 0x21, 0x14, 0xe4, 0x1c, 0x58, 0x10, 0x88, 0xbf, 0x0d, 0x01, + 0xf8, 0x8f, 0x18, 0x18, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x64, 0x20, 0x1d, 0x14, 0x23, 0x06, 0x06, + 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x59, 0x48, 0x07, 0xc4, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, + 0xc7, 0x35, 0xd2, 0x81, 0x10, 0x5c, 0x60, 0xde, 0x05, 0xe7, 0x96, 0x2c, 0x07, 0x41, 0x5c, 0x60, + 0xee, 0x05, 0x0d, 0x5a, 0x12, 0x88, 0xbf, 0x05, 0xaf, 0x1c, 0x80, 0xbf, 0x05, 0x90, 0xf8, 0x5b, + 0x40, 0xcb, 0x01, 0xf8, 0x9b, 0x44, 0xcb, 0x81, 0xf8, 0x9b, 0x2d, 0x07, 0x41, 0xf8, 0x1b, 0x35, + 0xcb, 0x81, 0xf8, 0xdb, 0x2d, 0x07, 0x41, 0xf8, 0x5f, 0x60, 0xde, 0x05, 0xe7, 0xd6, 0x2f, 0x07, + 0x41, 0x5c, 0x60, 0xee, 0x05, 0x0d, 0x8e, 0x21, 0xd8, 0xc4, 0x3e, 0x07, 0x06, 0xce, 0x41, 0x10, + 0xfe, 0x73, 0x0c, 0xb7, 0x1c, 0x04, 0x2c, 0x1d, 0xcc, 0x31, 0x04, 0x03, 0x4c, 0x07, 0x63, 0x08, + 0x37, 0xe1, 0xcf, 0x81, 0x91, 0x73, 0x10, 0x84, 0xff, 0x1c, 0xc3, 0x2e, 0x07, 0x01, 0x4c, 0x07, + 0x73, 0x0c, 0xc1, 0x40, 0xd3, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xf5, 0xd3, + 0x41, 0x11, 0x8c, 0x21, 0xfc, 0x44, 0x49, 0x07, 0x96, 0xce, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0xe0, + 0x1c, 0x04, 0x35, 0x1d, 0xcc, 0x31, 0x04, 0x43, 0x4e, 0x07, 0x63, 0x08, 0x60, 0xb1, 0xd3, 0x81, + 0xb5, 0x73, 0x10, 0x84, 0xff, 0x1c, 0x03, 0x39, 0x07, 0x41, 0x4e, 0x07, 0x73, 0x0c, 0xc1, 0xd0, + 0xd3, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x85, 0xd6, 0x41, 0x11, 0x8c, 0x18, + 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x69, 0x1d, 0x28, 0xc1, 0x18, 0x02, 0x5a, 0xb8, 0x74, + 0x60, 0xf3, 0x1c, 0x04, 0xe1, 0x3f, 0xc7, 0xa0, 0xce, 0x41, 0xf0, 0xd3, 0xc1, 0x1c, 0x43, 0x30, + 0x8c, 0x75, 0x30, 0x86, 0x90, 0x16, 0x31, 0x1d, 0xd8, 0x3d, 0x07, 0x41, 0xf8, 0xcf, 0x31, 0xb8, + 0x73, 0x10, 0x8c, 0x75, 0x30, 0xc7, 0x10, 0x0c, 0x67, 0x1d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, + 0x85, 0x7f, 0x54, 0x72, 0x1d, 0x14, 0xc1, 0x18, 0x42, 0x5c, 0xe0, 0x74, 0x60, 0xfc, 0x1c, 0x04, + 0xe1, 0x3f, 0xc7, 0x30, 0xcf, 0x41, 0x80, 0xd6, 0xc1, 0x1c, 0x43, 0x30, 0xb0, 0x75, 0x30, 0x86, + 0x20, 0x17, 0x6e, 0x1d, 0x18, 0x48, 0x07, 0x41, 0xf8, 0xcf, 0x31, 0xdc, 0x73, 0x10, 0xb0, 0x75, + 0x30, 0xc7, 0x10, 0x0c, 0x70, 0x1d, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x7b, + 0x1d, 0x14, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xc5, 0xd7, 0x81, 0x12, 0x8c, + 0x21, 0xe8, 0x45, 0x58, 0x07, 0x66, 0xd2, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0xfd, 0x1c, 0x04, 0x72, + 0x1d, 0xcc, 0x31, 0x04, 0x83, 0x5d, 0x07, 0x63, 0x08, 0x7b, 0x41, 0xd6, 0x81, 0xa9, 0x74, 0x10, + 0x84, 0xff, 0x1c, 0x43, 0x48, 0x07, 0x81, 0x5d, 0x07, 0x73, 0x0c, 0xc1, 0xa0, 0xd7, 0xc1, 0x88, + 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0x55, 0xda, 0x41, 0x11, 0x8c, 0x21, 0x8c, 0xc6, 0x5a, + 0x07, 0xf6, 0xd2, 0x41, 0x10, 0xfe, 0x73, 0x0c, 0x26, 0x1d, 0x04, 0x7b, 0x1d, 0xcc, 0x31, 0x04, + 0xc3, 0x5f, 0x07, 0x63, 0x08, 0xa4, 0x11, 0xda, 0x81, 0xcd, 0x74, 0x10, 0x84, 0xff, 0x1c, 0x83, + 0x4a, 0x07, 0xc1, 0x5f, 0x07, 0x73, 0x0c, 0xc1, 0x30, 0xda, 0xc1, 0x88, 0xc1, 0x41, 0x84, 0x20, + 0x58, 0xf8, 0x47, 0xe5, 0xda, 0x41, 0x11, 0x8c, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, + 0xaf, 0x1d, 0x28, 0xc1, 0x20, 0x43, 0xe0, 0xd2, 0x01, 0x5b, 0x07, 0x83, 0x0c, 0xe3, 0xf1, 0xd2, + 0xc1, 0x59, 0x07, 0x96, 0xd2, 0x41, 0x10, 0xfe, 0x06, 0xd3, 0xc1, 0x4c, 0x84, 0xff, 0x20, 0x83, + 0x6d, 0xd8, 0x74, 0x90, 0xd6, 0xc1, 0x20, 0x83, 0x6d, 0xdc, 0x74, 0xa0, 0xd6, 0xc1, 0x20, 0x83, + 0x6d, 0xe0, 0x74, 0xb0, 0xd6, 0xc1, 0x20, 0x43, 0x2f, 0xd4, 0x74, 0xd0, 0xd6, 0x81, 0x05, 0x86, + 0xf8, 0x0f, 0x32, 0xfc, 0xc2, 0x4d, 0x07, 0x6b, 0x1d, 0x58, 0x70, 0x88, 0xbf, 0x0d, 0x01, 0xf8, + 0xdb, 0xa0, 0x88, 0xbf, 0x19, 0x8a, 0xf8, 0x5b, 0x20, 0x84, 0xff, 0x1c, 0x43, 0x4f, 0x07, 0xb2, + 0x20, 0xdb, 0xc1, 0x20, 0x43, 0xe0, 0xd3, 0x81, 0x5d, 0x07, 0x16, 0x18, 0xe2, 0x3f, 0xc7, 0x00, + 0xd6, 0xc1, 0x2c, 0xd4, 0x76, 0x30, 0xc8, 0x10, 0x84, 0x75, 0x90, 0xd7, 0x81, 0x05, 0x86, 0xf8, + 0x1b, 0x41, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x1c, 0x83, 0x59, 0x07, 0xb2, + 0xb0, 0xdb, 0xc1, 0x20, 0x43, 0x70, 0xd6, 0xc1, 0x5f, 0x07, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, + 0xe1, 0x1f, 0xd5, 0x7a, 0x07, 0x43, 0x60, 0xc1, 0x59, 0x07, 0xe2, 0x6f, 0x41, 0x5a, 0x07, 0xe0, + 0x3f, 0xc7, 0xb0, 0xd6, 0x01, 0x2f, 0x80, 0x77, 0x30, 0xc8, 0x10, 0xb0, 0x75, 0x40, 0xda, 0x81, + 0x05, 0x85, 0xf8, 0x5b, 0xd0, 0xd6, 0x01, 0xf8, 0x5b, 0x10, 0x88, 0xbf, 0x19, 0x86, 0xf8, 0x5b, + 0xe0, 0xd6, 0x81, 0xf8, 0x5b, 0xe0, 0xd6, 0x01, 0xf8, 0x1b, 0x11, 0x88, 0xbf, 0x05, 0x62, 0x20, + 0xfe, 0x26, 0x88, 0x81, 0xf8, 0xdb, 0x20, 0x06, 0xe2, 0x6f, 0x6f, 0x1d, 0xa0, 0x41, 0xf8, 0xdb, + 0x5c, 0x07, 0x7a, 0x11, 0xfe, 0x83, 0x0c, 0xfa, 0xd1, 0xd7, 0x01, 0x6c, 0x07, 0x83, 0x0c, 0xfa, + 0xe1, 0xd7, 0x41, 0x6c, 0x07, 0x83, 0x0c, 0xfa, 0xf1, 0xd7, 0x81, 0x6c, 0x07, 0x76, 0x06, 0x85, + 0xf8, 0x9b, 0x19, 0x14, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x86, 0x06, 0x88, 0xf8, 0xdb, 0x1a, 0x20, + 0xe2, 0x6f, 0x81, 0x10, 0xfe, 0x46, 0x06, 0x84, 0xf8, 0x9b, 0x18, 0x08, 0xe2, 0x6f, 0x82, 0x20, + 0xfe, 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, + 0x95, 0x8a, 0x07, 0x01, 0x18, 0x58, 0x60, 0xda, 0x81, 0xf8, 0x5b, 0x80, 0xda, 0x01, 0xf8, 0xdb, + 0xe0, 0x89, 0xbf, 0x05, 0xaa, 0x1d, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, + 0xab, 0x1d, 0x88, 0xbf, 0x05, 0xab, 0x1d, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x80, 0x89, 0xbf, + 0x05, 0x1e, 0xf8, 0xdb, 0x90, 0x89, 0xbf, 0x05, 0x1f, 0xf8, 0x5b, 0xa1, 0x89, 0xbf, 0x05, 0x60, + 0x00, 0xfe, 0x76, 0x90, 0x01, 0xf8, 0xdb, 0x6b, 0x07, 0xa9, 0x10, 0xfe, 0xf6, 0xda, 0xc1, 0x6e, + 0x84, 0xff, 0x20, 0xc3, 0x8e, 0xf8, 0x76, 0x00, 0xdf, 0xc1, 0x20, 0xc3, 0x8e, 0xfc, 0x76, 0x10, + 0xdf, 0xc1, 0x20, 0xc3, 0x8e, 0x80, 0x77, 0x20, 0xdf, 0x81, 0xa1, 0x42, 0x21, 0xfe, 0x76, 0x0a, + 0x85, 0xf8, 0x9b, 0x10, 0x80, 0xbf, 0xa5, 0x02, 0x22, 0xfe, 0xc6, 0x0a, 0x88, 0xf8, 0x5b, 0x20, + 0x84, 0xbf, 0x95, 0x02, 0x21, 0xfe, 0x36, 0x0a, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, 0x82, + 0xf8, 0x9b, 0x10, 0x80, 0xff, 0x88, 0xc1, 0x41, 0x84, 0x20, 0x58, 0xf8, 0x47, 0xb5, 0xe6, 0x41, + 0x10, 0x0a, 0x16, 0x9c, 0x77, 0x20, 0xfe, 0x16, 0xa4, 0x77, 0x00, 0xfe, 0x36, 0xfc, 0x81, 0xf8, + 0x5b, 0xb0, 0xde, 0x01, 0xf8, 0x5b, 0x10, 0x88, 0xbf, 0x11, 0x84, 0xf8, 0x5b, 0xc0, 0xde, 0x81, + 0xf8, 0x5b, 0xc0, 0xde, 0x01, 0xf8, 0x1b, 0x11, 0x88, 0xbf, 0x05, 0x98, 0xf8, 0x5b, 0x18, 0x04, + 0xe0, 0x6f, 0x43, 0x26, 0xfe, 0x16, 0x06, 0x01, 0xf8, 0x5b, 0xa1, 0x89, 0xbf, 0x85, 0x41, 0x00, + 0xfe, 0x16, 0x06, 0x07, 0xf8, 0x9b, 0x7b, 0x07, 0xea, 0x10, 0xfe, 0x83, 0x0c, 0x78, 0xe2, 0xdf, + 0x41, 0x8c, 0x07, 0x83, 0x0c, 0x78, 0xf2, 0xdf, 0x81, 0x8c, 0x07, 0x83, 0x0c, 0x78, 0x02, 0xe2, + 0xc1, 0x8c, 0x07, 0x86, 0x0e, 0x84, 0xf8, 0x5b, 0x10, 0x0a, 0xe0, 0x6f, 0xe8, 0x60, 0x88, 0xbf, + 0x81, 0x42, 0x10, 0xfe, 0x36, 0x0e, 0x83, 0xf8, 0x5b, 0x38, 0x08, 0xe2, 0x6f, 0x82, 0x20, 0xfe, + 0x26, 0x08, 0xe2, 0x6f, 0x42, 0x00, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x55, + 0xaa, 0x07, 0xc1, 0x2f, 0x58, 0x50, 0xe2, 0x81, 0xf8, 0x5b, 0x70, 0xe2, 0x01, 0xf8, 0xdb, 0xd0, + 0x0b, 0xe2, 0x6f, 0x41, 0x8a, 0x07, 0xe0, 0x6f, 0x41, 0x20, 0xfe, 0x46, 0x10, 0xe2, 0x6f, 0x81, + 0x8a, 0x07, 0xe2, 0x6f, 0x81, 0x8a, 0x07, 0xe0, 0x6f, 0x44, 0x20, 0xfe, 0x16, 0x58, 0xe2, 0x6f, + 0x5e, 0x00, 0xfe, 0x36, 0x5c, 0xe2, 0x6f, 0x5e, 0x00, 0xfe, 0x56, 0x60, 0xe2, 0x6f, 0x5e, 0x00, + 0xfe, 0xe6, 0x1d, 0xe0, 0x6f, 0x2b, 0x1e, 0xa0, 0x44, 0xf8, 0x0f, 0x32, 0xd8, 0x0a, 0x8f, 0x07, + 0x6e, 0x1e, 0x0c, 0x32, 0xd8, 0x4a, 0x8f, 0x07, 0x6f, 0x1e, 0x0c, 0x32, 0xd8, 0x8a, 0x8f, 0x07, + 0x70, 0x1e, 0x98, 0x49, 0x10, 0xe2, 0x6f, 0x81, 0x1f, 0x80, 0xbf, 0x99, 0x84, 0x21, 0xfe, 0xd6, + 0x07, 0x41, 0xf8, 0x5b, 0x48, 0x0c, 0xe2, 0x6f, 0xff, 0x20, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, + 0x20, 0x88, 0xbf, 0x09, 0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0xe7, + 0x1e, 0x04, 0xfd, 0x60, 0xc1, 0x98, 0x07, 0xe2, 0x6f, 0x41, 0x99, 0x07, 0xe0, 0x6f, 0xc3, 0x3e, + 0x88, 0xbf, 0x05, 0x67, 0x1e, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, 0x68, + 0x1e, 0x88, 0xbf, 0x05, 0x68, 0x1e, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x60, 0x89, 0xbf, 0x79, + 0x01, 0xf8, 0xdb, 0x70, 0x89, 0xbf, 0x79, 0x01, 0xf8, 0x5b, 0x81, 0x89, 0xbf, 0x79, 0x01, 0xf8, + 0x9b, 0x77, 0x80, 0xbf, 0xbd, 0x79, 0x60, 0x16, 0xe1, 0x6f, 0x69, 0x1e, 0xe0, 0x49, 0xf8, 0x0f, + 0x32, 0xc8, 0xcb, 0x9e, 0x07, 0xad, 0x1e, 0x0c, 0x32, 0xc8, 0x0b, 0x9f, 0x07, 0xae, 0x1e, 0x0c, + 0x32, 0xc8, 0x4b, 0x9f, 0x07, 0xaf, 0x1e, 0x58, 0x59, 0x14, 0xe2, 0x6f, 0x64, 0x51, 0x88, 0xbf, + 0x09, 0x01, 0xf8, 0x9b, 0x59, 0x20, 0xe2, 0x6f, 0x69, 0x81, 0x88, 0xbf, 0x05, 0x42, 0xf8, 0x9b, + 0x58, 0x10, 0xe2, 0x6f, 0x60, 0x21, 0x88, 0xbf, 0x09, 0x82, 0xf8, 0x9b, 0x20, 0x88, 0xbf, 0x09, + 0x01, 0xf8, 0x8f, 0x18, 0x1c, 0x44, 0x08, 0x82, 0x85, 0x7f, 0x54, 0x28, 0x1f, 0x04, 0x3e, 0x61, + 0x01, 0xa9, 0x07, 0xe2, 0x6f, 0x81, 0xa9, 0x07, 0xe0, 0x6f, 0x03, 0x4f, 0x88, 0xbf, 0x05, 0xa8, + 0x1e, 0x80, 0xbf, 0x05, 0x81, 0xf8, 0x1b, 0x41, 0x88, 0xbf, 0x05, 0xa9, 0x1e, 0x88, 0xbf, 0x05, + 0xa9, 0x1e, 0x80, 0xbf, 0x11, 0x81, 0xf8, 0x5b, 0x80, 0x89, 0xbf, 0x85, 0x41, 0x00, 0xfe, 0x36, + 0x64, 0xe2, 0x6f, 0x61, 0x10, 0x80, 0xbf, 0x15, 0x9a, 0xf8, 0x5b, 0x18, 0x04, 0xe0, 0x6f, 0x61, + 0x70, 0x80, 0xff, 0x18, 0x82, 0xf1, 0xf2, 0xc1, 0x18, 0xc2, 0xe1, 0xef, 0x81, 0x09, 0x01, 0xf8, + 0xcf, 0x31, 0xec, 0x7a, 0x10, 0xb8, 0x7c, 0x30, 0x86, 0x80, 0xcc, 0x7c, 0x30, 0x86, 0x90, 0x88, + 0x7c, 0x60, 0x42, 0x00, 0xfe, 0x73, 0x0c, 0x44, 0x50, 0xf3, 0xc1, 0x18, 0x82, 0x72, 0xf3, 0xc1, + 0x18, 0xc2, 0x62, 0xf2, 0x81, 0x09, 0x01, 0xf8, 0xcf, 0x31, 0x10, 0xc1, 0xcd, 0x07, 0x63, 0x08, + 0xcd, 0xce, 0x07, 0x63, 0x08, 0x8e, 0xca, 0x07, 0x26, 0x04, 0xe0, 0x3f, 0xc8, 0xe0, 0x1f, 0xeb, + 0x21, 0xf2, 0xc1, 0x20, 0x43, 0x80, 0x1b, 0x22, 0x1f, 0x0c, 0x32, 0x80, 0x48, 0x7b, 0x88, 0x7c, + 0x30, 0xc8, 0x10, 0xe8, 0x86, 0xc8, 0x07, 0xa6, 0xee, 0x41, 0x10, 0xfe, 0x36, 0xef, 0x81, 0x41, + 0xfe, 0x73, 0x0c, 0xed, 0x1e, 0x04, 0x60, 0x1f, 0x0c, 0x32, 0x04, 0xee, 0x1e, 0x94, 0x7c, 0x60, + 0x4c, 0x20, 0xfe, 0x23, 0x06, 0x07, 0x11, 0x82, 0x60, 0xe1, 0x1f, 0x92, 0xdc, 0x07, 0x45, 0x30, + 0x62, 0x70, 0x10, 0x21, 0x08, 0x16, 0xfe, 0x21, 0xd1, 0x7d, 0x90, 0x04, 0x83, 0x0c, 0x81, 0xbc, + 0x07, 0x2f, 0x1f, 0xcc, 0x31, 0x04, 0xfa, 0x1e, 0x80, 0x7d, 0x30, 0x62, 0x90, 0x0c, 0x21, 0x08, + 0x06, 0x0f, 0xde, 0x07, 0x3f, 0x1f, 0xcc, 0x4e, 0x70, 0xf6, 0x01, 0xda, 0x07, 0x18, 0x10, 0x03, + 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x5b, 0x86, 0x28, 0x48, 0x85, 0x2d, 0xc3, 0x14, 0xa4, 0xc2, + 0x96, 0xa1, 0x0a, 0x52, 0x61, 0xcb, 0x70, 0x05, 0xa9, 0xb0, 0x65, 0x50, 0x9f, 0x20, 0x15, 0xb6, + 0x0c, 0xeb, 0x13, 0xa4, 0xc2, 0x96, 0x81, 0x7d, 0x82, 0x54, 0xd8, 0x32, 0xb4, 0x4f, 0x90, 0x0a, + 0x5b, 0x06, 0xd0, 0x0b, 0x52, 0x61, 0xcb, 0x10, 0x7a, 0x41, 0x2a, 0x6c, 0x19, 0x44, 0x2f, 0x48, + 0x85, 0x2d, 0xc3, 0xe8, 0x05, 0xa9, 0xb0, 0x65, 0xa0, 0xd9, 0x20, 0x48, 0x85, 0x2d, 0x43, 0xcd, + 0x06, 0x41, 0x2a, 0x6c, 0x19, 0x6c, 0x36, 0x08, 0x52, 0x61, 0xcb, 0x70, 0xb3, 0x41, 0x90, 0x0a, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0x20, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x32, 0x0e, + 0x10, 0x22, 0x84, 0x01, 0xad, 0x07, 0x28, 0x70, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x0c, + 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x12, 0x03, 0x94, 0x78, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x77, 0x01, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0f, 0x00, + 0x00, 0x00, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x19, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x24, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x19, 0x00, + 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x30, 0x00, 0x00, 0x7b, 0x00, + 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x95, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xa8, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xbb, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xce, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xe1, 0x00, + 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0xf2, 0x00, + 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x03, 0x01, + 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x1a, 0x01, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x1a, 0x01, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x2d, 0x01, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x2d, 0x01, + 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x48, 0x01, + 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x48, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x5c, 0x01, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x5c, 0x01, + 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x24, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x0c, 0x00, 0x00, 0x6a, 0x00, + 0x00, 0x00, 0x12, 0x03, 0x94, 0x39, 0x03, 0x00, 0x00, 0x00, 0x5f, 0x5f, 0x61, 0x69, 0x72, 0x5f, + 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x61, 0x69, + 0x6e, 0x43, 0x53, 0x5f, 0x5a, 0x34, 0x65, 0x61, 0x73, 0x75, 0x4e, 0x35, 0x6d, 0x65, 0x74, 0x61, + 0x6c, 0x39, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x49, 0x66, 0x4c, 0x4e, 0x53, + 0x5f, 0x36, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x45, 0x32, 0x45, 0x76, 0x45, 0x45, 0x4e, 0x53, + 0x30, 0x5f, 0x49, 0x66, 0x4c, 0x53, 0x31, 0x5f, 0x30, 0x45, 0x76, 0x45, 0x45, 0x52, 0x55, 0x31, + 0x31, 0x4d, 0x54, 0x4c, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x4b, 0x31, 0x31, 0x47, + 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x44, 0x61, 0x74, 0x61, 0x44, 0x76, 0x33, 0x5f, 0x6a, 0x53, + 0x37, 0x5f, 0x53, 0x37, 0x5f, 0x61, 0x69, 0x72, 0x2e, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x74, + 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x32, 0x64, 0x2e, 0x76, 0x34, 0x66, 0x33, 0x32, 0x61, + 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x69, 0x6e, 0x2e, 0x76, 0x33, 0x66, + 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, + 0x76, 0x33, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, + 0x69, 0x6e, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, + 0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, + 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6d, 0x61, 0x78, 0x2e, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, + 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x62, 0x73, 0x2e, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, + 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x61, 0x74, 0x75, 0x72, 0x61, 0x74, 0x65, 0x2e, 0x76, + 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x62, + 0x73, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x67, 0x61, 0x74, 0x68, 0x65, + 0x72, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x32, 0x64, 0x2e, 0x76, 0x34, 0x66, + 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x66, 0x6c, 0x6f, 0x6f, 0x72, + 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x61, 0x69, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, + 0x74, 0x2e, 0x66, 0x2e, 0x76, 0x32, 0x66, 0x33, 0x32, 0x2e, 0x75, 0x2e, 0x76, 0x32, 0x69, 0x33, + 0x32, 0x33, 0x31, 0x30, 0x30, 0x31, 0x2e, 0x36, 0x36, 0x37, 0x61, 0x69, 0x72, 0x36, 0x34, 0x2d, + 0x61, 0x70, 0x70, 0x6c, 0x65, 0x2d, 0x6d, 0x61, 0x63, 0x6f, 0x73, 0x78, 0x31, 0x30, 0x2e, 0x31, + 0x34, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 \ No newline at end of file diff --git a/trinityal/include/upscaling/Tr2Fsr1Upscaling.h b/trinityal/include/upscaling/Tr2Fsr1Upscaling.h index 3e6d263ea..f9bd0eed4 100644 --- a/trinityal/include/upscaling/Tr2Fsr1Upscaling.h +++ b/trinityal/include/upscaling/Tr2Fsr1Upscaling.h @@ -11,18 +11,18 @@ #include "Tr2ShaderProgramAL.h" #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - #include "dx12/upscaling/Tr2UpscalingALDx12.h" - #define TECHNIQUE_PARENT_CLASS TrinityALImpl::Tr2UpscalingTechniqueDx12 +#include "dx12/upscaling/Tr2UpscalingALDx12.h" +#define TECHNIQUE_PARENT_CLASS TrinityALImpl::Tr2UpscalingTechniqueDx12 #elif TRINITY_PLATFORM == TRINITY_DIRECTX11 - #include "dx11/upscaling/Tr2UpscalingALDx11.h" - #define TECHNIQUE_PARENT_CLASS TrinityALImpl::Tr2UpscalingTechniqueDx11 +#include "dx11/upscaling/Tr2UpscalingALDx11.h" +#define TECHNIQUE_PARENT_CLASS TrinityALImpl::Tr2UpscalingTechniqueDx11 #else - #define TECHNIQUE_PARENT_CLASS Tr2UpscalingTechniqueAL +#define TECHNIQUE_PARENT_CLASS Tr2UpscalingTechniqueAL #endif class Tr2Fsr1UpscalingTechnique : public TECHNIQUE_PARENT_CLASS { -public: +public: Tr2Fsr1UpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); ~Tr2Fsr1UpscalingTechnique(); virtual std::vector GetAvailableSettings() const override; @@ -46,9 +46,8 @@ class Tr2Fsr1UpscalingContext : public Tr2UpscalingContextAL virtual Tr2UpscalingAL::Result Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) override; private: - Tr2SamplerStateAL m_sampler; - + Tr2ShaderProgramAL m_easuProgram; Tr2ConstantBufferAL m_constantBuffer; diff --git a/trinityal/include/upscaling/Tr2UpscalingAL.h b/trinityal/include/upscaling/Tr2UpscalingAL.h index ade09b5bc..766873165 100644 --- a/trinityal/include/upscaling/Tr2UpscalingAL.h +++ b/trinityal/include/upscaling/Tr2UpscalingAL.h @@ -9,120 +9,120 @@ class Tr2TextureAL; namespace Tr2UpscalingAL { - enum Technique - { - NONE, - FSR1, - FSR2, - FSR3, - DLSS, - XESS, - METALFX - }; - - enum Setting - { - NATIVE = 1 << 0, - ULTRA_QUALITY = 1 << 1, - QUALITY = 1 << 2, - BALANCED = 1 << 3, - PERFORMANCE = 1 << 4, - ULTRA_PERFORMANCE = 1 << 5 - }; - - enum Result - { - OK, - TECHNIQUE_NOT_SUPPORTED, - HARDWARE_NOT_SUPPORTED, - CONTEXT_SETUP_FAILED, - INCORRECT_INPUT - }; - - struct DispatchParameters - { - const Tr2TextureAL* input; - const Tr2TextureAL* opaqueOnly; - const Tr2TextureAL* output; - const Tr2TextureAL* depth; - const Tr2TextureAL* velocity; - const Tr2TextureAL* exposure; - const Tr2TextureAL* reactive; - const Tr2TextureAL* transparency; - - unsigned long long currentFrameIndex; - float frontClip; - float backClip; - float fieldOfView; - float aspectRatio; - float frameTimeDelta; - float preExposure; - float cameraForward[3]; - float cameraRight[3]; - float cameraUp[3]; - float cameraPos[3]; - float projection[16]; - float invProjection[16]; - float clipToPrevClip[16]; - float prevClipToClip[16]; - bool reset; - bool upscalingDebugView; - bool frameGenDebugView; - }; - - enum DispatchRequirements - { - VELOCITY = 1 << 0, - OPAQUE_ONLY = 1 << 1, - DEPTH = 1 << 2, - REACTIVE = 1 << 3, - OPTIONAL_EXPOSURE = 1 << 4, - TRANSPARENCY = 1 << 5, - }; - - void LogResult( Result result ); - - typedef std::vector> JitterSequence; - JitterSequence GenerateHaltonSequence( uint32_t totalPhases, uint32_t xBase, uint32_t yBase ); - float Halton( uint32_t index, uint32_t base ); - - uint32_t ConvertDisplaySizeToRenderSize( uint32_t displaySize, float upscaling ); - - struct UpscalingInfo - { - UpscalingInfo(); - - uint32_t displayWidth; - uint32_t displayHeight; - uint32_t renderWidth; - uint32_t renderHeight; - Technique technique; - Setting setting; - bool frameGeneration; - bool temporal; - bool hasSharpening; - float upscalingAmount; - float jitterX; - float jitterY; - float mipLevelBias; - }; - - struct UpscalingContextParams - { - UpscalingContextParams( Tr2RenderContextAL& renderContext ); - uint32_t displayWidth; - uint32_t displayHeight; - Tr2RenderContextEnum::PixelFormat sourceFormat; - Tr2RenderContextEnum::DepthStencilFormat depthFormat; - bool allowFramegen; - Tr2RenderContextAL& renderContext; - - bool operator==( const UpscalingContextParams& other ) const; - }; - - const char* GetTechniqueName( Technique technique ); - const char* GetSettingName( Setting setting ); - const uint32_t INVALID_CONTEXT_ID = std::numeric_limits::max(); +enum Technique +{ + NONE, + FSR1, + FSR2, + FSR3, + DLSS, + XESS, + METALFX +}; + +enum Setting +{ + NATIVE = 1 << 0, + ULTRA_QUALITY = 1 << 1, + QUALITY = 1 << 2, + BALANCED = 1 << 3, + PERFORMANCE = 1 << 4, + ULTRA_PERFORMANCE = 1 << 5 +}; + +enum Result +{ + OK, + TECHNIQUE_NOT_SUPPORTED, + HARDWARE_NOT_SUPPORTED, + CONTEXT_SETUP_FAILED, + INCORRECT_INPUT +}; + +struct DispatchParameters +{ + const Tr2TextureAL* input; + const Tr2TextureAL* opaqueOnly; + const Tr2TextureAL* output; + const Tr2TextureAL* depth; + const Tr2TextureAL* velocity; + const Tr2TextureAL* exposure; + const Tr2TextureAL* reactive; + const Tr2TextureAL* transparency; + + unsigned long long currentFrameIndex; + float frontClip; + float backClip; + float fieldOfView; + float aspectRatio; + float frameTimeDelta; + float preExposure; + float cameraForward[3]; + float cameraRight[3]; + float cameraUp[3]; + float cameraPos[3]; + float projection[16]; + float invProjection[16]; + float clipToPrevClip[16]; + float prevClipToClip[16]; + bool reset; + bool upscalingDebugView; + bool frameGenDebugView; +}; + +enum DispatchRequirements +{ + VELOCITY = 1 << 0, + OPAQUE_ONLY = 1 << 1, + DEPTH = 1 << 2, + REACTIVE = 1 << 3, + OPTIONAL_EXPOSURE = 1 << 4, + TRANSPARENCY = 1 << 5, +}; + +void LogResult( Result result ); + +typedef std::vector> JitterSequence; +JitterSequence GenerateHaltonSequence( uint32_t totalPhases, uint32_t xBase, uint32_t yBase ); +float Halton( uint32_t index, uint32_t base ); + +uint32_t ConvertDisplaySizeToRenderSize( uint32_t displaySize, float upscaling ); + +struct UpscalingInfo +{ + UpscalingInfo(); + + uint32_t displayWidth; + uint32_t displayHeight; + uint32_t renderWidth; + uint32_t renderHeight; + Technique technique; + Setting setting; + bool frameGeneration; + bool temporal; + bool hasSharpening; + float upscalingAmount; + float jitterX; + float jitterY; + float mipLevelBias; +}; + +struct UpscalingContextParams +{ + UpscalingContextParams( Tr2RenderContextAL& renderContext ); + uint32_t displayWidth; + uint32_t displayHeight; + Tr2RenderContextEnum::PixelFormat sourceFormat; + Tr2RenderContextEnum::DepthStencilFormat depthFormat; + bool allowFramegen; + Tr2RenderContextAL& renderContext; + + bool operator==( const UpscalingContextParams& other ) const; +}; + +const char* GetTechniqueName( Technique technique ); +const char* GetSettingName( Setting setting ); +const uint32_t INVALID_CONTEXT_ID = std::numeric_limits::max(); } // forward @@ -132,7 +132,7 @@ class Tr2UpscalingTechniqueAL { public: Tr2UpscalingTechniqueAL( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); - virtual ~Tr2UpscalingTechniqueAL() = default; + virtual ~Tr2UpscalingTechniqueAL() = default; // Called by the device to mark events if we need to trigger stuff at some point in time virtual void MarkFrameEvent( Tr2RenderContextEnum::FrameEvent& frameEvent ); @@ -141,8 +141,8 @@ class Tr2UpscalingTechniqueAL virtual void ReleaseResources(); - virtual bool IsAvailable( ) const; - virtual bool SupportsFrameGeneration( ) const; + virtual bool IsAvailable() const; + virtual bool SupportsFrameGeneration() const; virtual bool IsTemporal() const = 0; virtual std::vector GetAvailableSettings() const = 0; @@ -174,14 +174,14 @@ class Tr2UpscalingContextAL void GetRenderDimensions( uint32_t& width, uint32_t& height ) const; // What is the output dimensions void GetDisplayDimensions( uint32_t& width, uint32_t& height ) const; - + void GetJitter( float& x, float& y ) const; // the requirements of the dispatch (as in the textures needed) virtual uint32_t GetDispatchRequirements() const = 0; virtual void UpdateJitter() = 0; virtual bool HasSharpening() const = 0; - + float GetUpscalingAmount() const; float GetMipLevelBias( bool temporal ) const; @@ -216,4 +216,6 @@ class Tr2UpscalingContextAL }; +// clang-format off #include TRINITY_AL_PLATFORM_INCLUDE( upscaling/Tr2UpscalingAL ) +// clang-format on diff --git a/trinityal/metal/MetalContext.h b/trinityal/metal/MetalContext.h index 461fc91bd..7f6f74f05 100644 --- a/trinityal/metal/MetalContext.h +++ b/trinityal/metal/MetalContext.h @@ -31,43 +31,46 @@ class MetalContext MetalContext(); ~MetalContext(); - MetalUtils *m_utils; + MetalUtils* m_utils; + + id CreateMetalBuffer( MetalWorkQueue* workQueue, + size_t sizeInBytes, + MTLResourceOptions options, + const void* data ); + void DestroyMetalBuffer( id buffer ); + void IndicateBufferModified( id buffer, size_t offset, size_t length ); - id CreateMetalBuffer( MetalWorkQueue* workQueue, size_t sizeInBytes, MTLResourceOptions options, const void *data ); - void DestroyMetalBuffer(id buffer); - void IndicateBufferModified(id buffer, size_t offset, size_t length); - void DestroyConstantBuffer( void* buffer ); - id GetDevice(); - id GetCommandQueue(); + id GetDevice(); + id GetCommandQueue(); MTLSamplerDescriptor* CreateSamplerDescriptor(); - void DestroySamplerDescriptor(MTLSamplerDescriptor* samplerDescriptor); - id CreateSamplerState(MTLSamplerDescriptor* samplerDescriptor); - void DestroySamplerState(id samplerState); - - id CreateMetalTexture(MTLTextureType metalTextureType, - MTLPixelFormat pixelFormat, - size_t width, - size_t height, - size_t depth, - uint32 mipMapCount, - MTLStorageMode storageMode, - MTLTextureUsage textureUsage, - uint32 sampleCount = 1, - uint32 arrayLength = 1); + void DestroySamplerDescriptor( MTLSamplerDescriptor* samplerDescriptor ); + id CreateSamplerState( MTLSamplerDescriptor* samplerDescriptor ); + void DestroySamplerState( id samplerState ); + + id CreateMetalTexture( MTLTextureType metalTextureType, + MTLPixelFormat pixelFormat, + size_t width, + size_t height, + size_t depth, + uint32 mipMapCount, + MTLStorageMode storageMode, + MTLTextureUsage textureUsage, + uint32 sampleCount = 1, + uint32 arrayLength = 1 ); id CreateSRGBViewOfMetalTexture( id texture ); id CreateUAVOfMetalTexture( id texture, uint32_t mipLevel ); void DestroyMetalTexture( id texture ); - - uint32_t AllocateHeapIndex( id texture ); - uint32_t AllocateHeapIndex( id buffer ); - uint32_t AllocateHeapIndex( id sampler ); - void DeallocateHeapIndex( uint32_t index ); - id GetHeapViewBuffer() const; + + uint32_t AllocateHeapIndex( id texture ); + uint32_t AllocateHeapIndex( id buffer ); + uint32_t AllocateHeapIndex( id sampler ); + void DeallocateHeapIndex( uint32_t index ); + id GetHeapViewBuffer() const; MTLVertexDescriptor* CreateVertexLayout(); void DestroyVertexLayout( MTLVertexDescriptor* vertexDescriptor ); @@ -75,38 +78,40 @@ class MetalContext id GetDummyTexture( MTLTextureType textureType ); id GetDummySampler(); // Optional fields will contain info about the buffer - id GetDummyBuffer( NSUInteger *outSize = nil, MTLVertexFormat *outFormat = nil ); + id GetDummyBuffer( NSUInteger* outSize = nil, MTLVertexFormat* outFormat = nil ); bool IsResourceInUse( uint64 resourceLastAccessedFrame ) const; uint64_t GetRecordingFrameNumber() const; uint64_t GetRenderedFrameNumber() const; void BlitToDrawableAndPresent( id srcTexture, NSView* view ); - + double GetGpuTimerRate() const; id GetCachedRenderPipelineState( size_t renderPipelineDescriptorHash ); void AddRenderPipelineStateToCache( size_t renderPipelineDescriptorHash, id pipelineState ); id GetCachedComputePipelineState( size_t computePipelineDescriptorHash ); - void AddComputePipelineStateToCache( size_t computePipelineDescriptorHash, id pipelineState ); + void AddComputePipelineStateToCache( size_t computePipelineDescriptorHash, + id pipelineState ); - uint32_t BeginParallelEncoding(uint32_t requestedEncodersCount); + uint32_t BeginParallelEncoding( uint32_t requestedEncodersCount ); void EndParallelEncoding(); bool IsInParallelEncoding() const; MetalWorkQueue* GetSecondaryWorkQueue( uint32_t index ); MetalWorkQueue* GetPrimaryWorkQueue(); - - ConstantBufferAllocator& GetConstantBufferAllocator(); - - void ReleaseLater( id obj ); - void FlushPendingRelease( uint64_t renderedFrame ); + + ConstantBufferAllocator& GetConstantBufferAllocator(); + + void ReleaseLater( id obj ); + void FlushPendingRelease( uint64_t renderedFrame ); + private: - id m_device; + id m_device; id m_commandQueue; TrinityALImpl::MetalWorkQueue m_primaryWorkQueue; std::vector m_secondaryWorkQueues; - ConstantBufferAllocator m_cbAllocator[3]; + ConstantBufferAllocator m_cbAllocator[3]; uint32_t m_parallelEncodersCount; uint64_t m_recordingFrameNumber; uint64_t m_renderedFrameNumber; @@ -123,23 +128,23 @@ class MetalContext id m_dummyTexture[METAL_NUM_DUMMY_TEXTURES]; id m_dummySampler; id m_dummyBuffer; - - ResourceArrayArgumentBuffer m_resourceHeap; - - std::unordered_map> m_renderPipelineStateMap; - std::unordered_map> m_newRenderPipelineStateMap; + ResourceArrayArgumentBuffer m_resourceHeap; + + + std::unordered_map> m_renderPipelineStateMap; + std::unordered_map> m_newRenderPipelineStateMap; std::unordered_map> m_computePipelineStateMap; std::mutex m_pipelineCacheMutex; std::vector m_destroyedConstantBuffers; - - struct ReleasingItem - { - id object; - uint64_t frame; - }; - std::vector m_pendingRelease; + + struct ReleasingItem + { + id object; + uint64_t frame; + }; + std::vector m_pendingRelease; void GenerateDummyTexture(); void GenerateDummyBuffer(); diff --git a/trinityal/metal/MetalContext.mm b/trinityal/metal/MetalContext.mm index 494fe9526..dd33f4bd9 100644 --- a/trinityal/metal/MetalContext.mm +++ b/trinityal/metal/MetalContext.mm @@ -8,609 +8,632 @@ bool g_useParallelEncoding = false; extern bool g_brokenMacOSNvidiaDrivers; -CCP_STATS_DECLARE( constantDataSize, "Trinity/AL/constantDataSize", true, CST_MEMORY, "Total size of constant data uploaded per frame" ); +CCP_STATS_DECLARE( constantDataSize, + "Trinity/AL/constantDataSize", + true, + CST_MEMORY, + "Total size of constant data uploaded per frame" ); namespace TrinityALImpl { - MetalContext::MetalContext() - : m_recordingFrameNumber( 1 ) - , m_renderedFrameNumber( 0 ) - , m_parallelEncodersCount( 0 ) - , m_gpuTimerRate( 1 ) - , m_beginCpuTime( 0 ) - , m_beginGpuTime( 0 ) - , m_gpuTimerRateMeasured( false ) - { - m_utils = new MetalUtils; - m_device = MTLCreateSystemDefaultDevice(); - m_commandQueue = [m_device newCommandQueueWithMaxCommandBufferCount:1024]; - - bool isNvidia = [m_device.name rangeOfString:@"NVidia" options:NSCaseInsensitiveSearch].location != NSNotFound; - bool isIntel = [m_device.name rangeOfString:@"Intel" options:NSCaseInsensitiveSearch].location != NSNotFound; - - if( isNvidia || isIntel ) - { - CCP_LOGWARN("Disabling parallel rendering on nVidia/Intel GPU"); - g_useParallelEncoding = false; - } - if( g_useParallelEncoding ) +MetalContext::MetalContext() : + m_recordingFrameNumber( 1 ), + m_renderedFrameNumber( 0 ), + m_parallelEncodersCount( 0 ), + m_gpuTimerRate( 1 ), + m_beginCpuTime( 0 ), + m_beginGpuTime( 0 ), + m_gpuTimerRateMeasured( false ) +{ + m_utils = new MetalUtils; + m_device = MTLCreateSystemDefaultDevice(); + m_commandQueue = [m_device newCommandQueueWithMaxCommandBufferCount:1024]; + + bool isNvidia = [m_device.name rangeOfString:@"NVidia" options:NSCaseInsensitiveSearch].location != NSNotFound; + bool isIntel = [m_device.name rangeOfString:@"Intel" options:NSCaseInsensitiveSearch].location != NSNotFound; + + if( isNvidia || isIntel ) + { + CCP_LOGWARN( "Disabling parallel rendering on nVidia/Intel GPU" ); + g_useParallelEncoding = false; + } + if( g_useParallelEncoding ) + { + m_secondaryWorkQueues.resize( std::thread::hardware_concurrency() ); + for( auto& queue : m_secondaryWorkQueues ) { - m_secondaryWorkQueues.resize( std::thread::hardware_concurrency() ); - for( auto& queue : m_secondaryWorkQueues ) - { - queue.SetMetalContext( this ); - } + queue.SetMetalContext( this ); } - m_primaryWorkQueue.SetCommandQueue( m_commandQueue ); - m_primaryWorkQueue.SetMetalContext( this ); - - if( @available( macOS 13.0, * ) ) - { - if( m_device.argumentBuffersSupport >= MTLArgumentBuffersTier2 ) - { - m_resourceHeap.Initialize( 2048, m_device ); - } - } - - GenerateDummyTexture(); - GenerateDummyBuffer(); - - if( @available( macOS 10.15, * ) ) + } + m_primaryWorkQueue.SetCommandQueue( m_commandQueue ); + m_primaryWorkQueue.SetMetalContext( this ); + + if( @available( macOS 13.0, * ) ) + { + if( m_device.argumentBuffersSupport >= MTLArgumentBuffersTier2 ) { - [m_device sampleTimestamps:&m_beginCpuTime gpuTimestamp:&m_beginGpuTime]; + m_resourceHeap.Initialize( 2048, m_device ); } - else if( isNvidia ) - { - g_brokenMacOSNvidiaDrivers = true; - } - for( auto& alloc : m_cbAllocator ) - { - alloc.Initialize( m_device ); - } } - MetalContext::~MetalContext() + GenerateDummyTexture(); + GenerateDummyBuffer(); + + if( @available( macOS 10.15, * ) ) + { + [m_device sampleTimestamps:&m_beginCpuTime gpuTimestamp:&m_beginGpuTime]; + } + else if( isNvidia ) { - m_pendingRelease.clear(); - - delete m_utils; + g_brokenMacOSNvidiaDrivers = true; + } + for( auto& alloc : m_cbAllocator ) + { + alloc.Initialize( m_device ); + } +} - DestroyMetalBuffer( m_dummyBuffer ); +MetalContext::~MetalContext() +{ + m_pendingRelease.clear(); - for( int i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) - { - DestroyMetalTexture(m_dummyTexture[i]); - } - for( auto buffer : m_destroyedConstantBuffers ) - { - CCPAlignedFree( buffer ); - } - } + delete m_utils; + + DestroyMetalBuffer( m_dummyBuffer ); - id MetalContext::CreateMetalBuffer( MetalWorkQueue* workQueue, size_t sizeInBytes, MTLResourceOptions options, const void *data ) + for( int i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) { - id buffer; + DestroyMetalTexture( m_dummyTexture[i] ); + } + for( auto buffer : m_destroyedConstantBuffers ) + { + CCPAlignedFree( buffer ); + } +} + +id MetalContext::CreateMetalBuffer( MetalWorkQueue* workQueue, + size_t sizeInBytes, + MTLResourceOptions options, + const void* data ) +{ + id buffer; - MTLStorageMode storageMode = MTLStorageMode( ( options & MTLResourceStorageModeMask ) >> MTLResourceStorageModeShift ); - MTLCPUCacheMode cpuCacheMode = MTLCPUCacheMode( ( options & MTLResourceCPUCacheModeMask ) >> MTLResourceCPUCacheModeShift ); + MTLStorageMode storageMode = + MTLStorageMode( ( options & MTLResourceStorageModeMask ) >> MTLResourceStorageModeShift ); + MTLCPUCacheMode cpuCacheMode = + MTLCPUCacheMode( ( options & MTLResourceCPUCacheModeMask ) >> MTLResourceCPUCacheModeShift ); - METAL_LOG( @"Log:Creating buffer of length %lu", sizeInBytes ); - if( data ) + METAL_LOG( @"Log:Creating buffer of length %lu", sizeInBytes ); + if( data ) + { + if( storageMode == MTLStorageModePrivate ) { - if( storageMode == MTLStorageModePrivate ) - { - id staging = [m_device newBufferWithBytes:data length:sizeInBytes options:MTLResourceStorageModeManaged]; - buffer = [m_device newBufferWithLength:sizeInBytes options:options]; - workQueue->CopyBufferToBuffer( buffer, 0, staging, 0, sizeInBytes ); - DestroyMetalBuffer( staging ); - } - else - { - buffer = [m_device newBufferWithBytes:data length:sizeInBytes options:options]; - } + id staging = [m_device newBufferWithBytes:data + length:sizeInBytes + options:MTLResourceStorageModeManaged]; + buffer = [m_device newBufferWithLength:sizeInBytes options:options]; + workQueue->CopyBufferToBuffer( buffer, 0, staging, 0, sizeInBytes ); + DestroyMetalBuffer( staging ); } else { - buffer = [m_device newBufferWithLength:sizeInBytes options:options]; + buffer = [m_device newBufferWithBytes:data length:sizeInBytes options:options]; } - - return buffer; } - - void MetalContext::DestroyMetalBuffer( id buffer ) + else { -#if !__has_feature(objc_arc) - [buffer release]; -#endif + buffer = [m_device newBufferWithLength:sizeInBytes options:options]; } + return buffer; +} - MTLVertexDescriptor* MetalContext::CreateVertexLayout() - { - MTLVertexDescriptor *vertexDescriptor = [MTLVertexDescriptor vertexDescriptor]; - return vertexDescriptor; - } - - void MetalContext::DestroyVertexLayout( MTLVertexDescriptor *vertexDescriptor ) - { -#if !__has_feature(objc_arc) - [vertexDescriptor release]; +void MetalContext::DestroyMetalBuffer( id buffer ) +{ +#if !__has_feature( objc_arc ) + [buffer release]; #endif - } +} - void MetalContext::IndicateBufferModified( id buffer, size_t offset, size_t length ) - { - [buffer didModifyRange:NSMakeRange( offset, length )]; - } - - void MetalContext::DestroyConstantBuffer( void* buffer ) - { - m_destroyedConstantBuffers.push_back( buffer ); - } - MTLSamplerDescriptor* MetalContext::CreateSamplerDescriptor() - { - MTLSamplerDescriptor* samplerDescriptor = [MTLSamplerDescriptor new]; - return samplerDescriptor; - } +MTLVertexDescriptor* MetalContext::CreateVertexLayout() +{ + MTLVertexDescriptor* vertexDescriptor = [MTLVertexDescriptor vertexDescriptor]; + return vertexDescriptor; +} - void MetalContext::DestroySamplerDescriptor( MTLSamplerDescriptor* samplerDescriptor ) - { -#if !__has_feature(objc_arc) - [samplerDescriptor release]; +void MetalContext::DestroyVertexLayout( MTLVertexDescriptor* vertexDescriptor ) +{ +#if !__has_feature( objc_arc ) + [vertexDescriptor release]; #endif - } +} - id MetalContext::CreateSamplerState( MTLSamplerDescriptor* samplerDescriptor ) - { - id samplerState = [m_device newSamplerStateWithDescriptor:samplerDescriptor]; - return samplerState; - } +void MetalContext::IndicateBufferModified( id buffer, size_t offset, size_t length ) +{ + [buffer didModifyRange:NSMakeRange( offset, length )]; +} - void MetalContext::DestroySamplerState( id samplerState ) - { -#if !__has_feature(objc_arc) - [samplerState release]; +void MetalContext::DestroyConstantBuffer( void* buffer ) +{ + m_destroyedConstantBuffers.push_back( buffer ); +} + +MTLSamplerDescriptor* MetalContext::CreateSamplerDescriptor() +{ + MTLSamplerDescriptor* samplerDescriptor = [MTLSamplerDescriptor new]; + return samplerDescriptor; +} + +void MetalContext::DestroySamplerDescriptor( MTLSamplerDescriptor* samplerDescriptor ) +{ +#if !__has_feature( objc_arc ) + [samplerDescriptor release]; #endif - } +} - id MetalContext::CreateMetalTexture(MTLTextureType metalTextureType, - MTLPixelFormat pixelFormat, - size_t width, - size_t height, - size_t depth, - uint32 mipMapCount, - MTLStorageMode storageMode, - MTLTextureUsage textureUsage, - uint32 sampleCount, - uint32 arrayLength) - { - METAL_LOG(@"Log:Creating texture of size %lux%lu", width, height); +id MetalContext::CreateSamplerState( MTLSamplerDescriptor* samplerDescriptor ) +{ + id samplerState = [m_device newSamplerStateWithDescriptor:samplerDescriptor]; + return samplerState; +} - MTLTextureDescriptor *textureDescriptor = [[MTLTextureDescriptor alloc] init]; +void MetalContext::DestroySamplerState( id samplerState ) +{ +#if !__has_feature( objc_arc ) + [samplerState release]; +#endif +} - textureDescriptor.textureType = metalTextureType; - textureDescriptor.pixelFormat = pixelFormat; - textureDescriptor.width = width; - textureDescriptor.height = height; - textureDescriptor.depth = depth; - textureDescriptor.mipmapLevelCount = MAX(mipMapCount,1); - textureDescriptor.arrayLength = arrayLength; - textureDescriptor.usage = textureUsage; - textureDescriptor.sampleCount = sampleCount; - textureDescriptor.storageMode = storageMode; +id MetalContext::CreateMetalTexture( MTLTextureType metalTextureType, + MTLPixelFormat pixelFormat, + size_t width, + size_t height, + size_t depth, + uint32 mipMapCount, + MTLStorageMode storageMode, + MTLTextureUsage textureUsage, + uint32 sampleCount, + uint32 arrayLength ) +{ + METAL_LOG( @"Log:Creating texture of size %lux%lu", width, height ); - id texture = [m_device newTextureWithDescriptor: textureDescriptor]; + MTLTextureDescriptor* textureDescriptor = [[MTLTextureDescriptor alloc] init]; - if( !texture ) - { - CCP_AL_LOGERR( "Failed to create a texture." ); - } + textureDescriptor.textureType = metalTextureType; + textureDescriptor.pixelFormat = pixelFormat; + textureDescriptor.width = width; + textureDescriptor.height = height; + textureDescriptor.depth = depth; + textureDescriptor.mipmapLevelCount = MAX( mipMapCount, 1 ); + textureDescriptor.arrayLength = arrayLength; + textureDescriptor.usage = textureUsage; + textureDescriptor.sampleCount = sampleCount; + textureDescriptor.storageMode = storageMode; - return texture; + id texture = [m_device newTextureWithDescriptor:textureDescriptor]; + + if( !texture ) + { + CCP_AL_LOGERR( "Failed to create a texture." ); } - void MetalContext::GenerateDummyTexture() + return texture; +} + +void MetalContext::GenerateDummyTexture() +{ + constexpr uint32_t textureDim = 8; + // Enough size for TextureCube + uint32_t texData[textureDim][textureDim * textureDim]; + + struct TextureProperties { - constexpr uint32_t textureDim = 8; - // Enough size for TextureCube - uint32_t texData[textureDim][textureDim * textureDim]; - - struct TextureProperties - { - MTLTextureType type; - size_t width; - size_t height; - size_t depth; - uint32_t samples; - }; - - const TextureProperties dummyTextureProperties[METAL_NUM_DUMMY_TEXTURES] = { - TextureProperties{MTLTextureType1D, textureDim, 1, 1, 1}, - TextureProperties{MTLTextureType2D, textureDim, textureDim, 1, 1}, - // 4 samples is supported by all devices according to docs - TextureProperties{MTLTextureType2DMultisample, textureDim, textureDim, 1, 4}, - TextureProperties{MTLTextureTypeCube, textureDim, textureDim, 1, 1}, - TextureProperties{MTLTextureType3D, textureDim, textureDim, textureDim, 1}, - TextureProperties{MTLTextureType2DArray, textureDim, textureDim, 1, 1}, - }; - - // Generate texture data - for( int z = 0; z < textureDim; z++ ) + MTLTextureType type; + size_t width; + size_t height; + size_t depth; + uint32_t samples; + }; + + const TextureProperties dummyTextureProperties[METAL_NUM_DUMMY_TEXTURES] = { + TextureProperties{ MTLTextureType1D, textureDim, 1, 1, 1 }, + TextureProperties{ MTLTextureType2D, textureDim, textureDim, 1, 1 }, + // 4 samples is supported by all devices according to docs + TextureProperties{ MTLTextureType2DMultisample, textureDim, textureDim, 1, 4 }, + TextureProperties{ MTLTextureTypeCube, textureDim, textureDim, 1, 1 }, + TextureProperties{ MTLTextureType3D, textureDim, textureDim, textureDim, 1 }, + TextureProperties{ MTLTextureType2DArray, textureDim, textureDim, 1, 1 }, + }; + + // Generate texture data + for( int z = 0; z < textureDim; z++ ) + { + for( int y = 0; y < textureDim; y++ ) { - for( int y = 0; y < textureDim; y++ ) + for( int x = 0; x < textureDim; x++ ) { - for( int x = 0; x < textureDim; x++ ) - { - uint32_t colorSquare = ( (y + x) % 2 ); - texData[z][(y * textureDim) + x] = colorSquare ? 0xFFE542FA : 0xFFFFFFFF; - } + uint32_t colorSquare = ( ( y + x ) % 2 ); + texData[z][( y * textureDim ) + x] = colorSquare ? 0xFFE542FA : 0xFFFFFFFF; } } + } - for( uint32_t i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) + for( uint32_t i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) + { + uint32_t samples = dummyTextureProperties[i].samples; + + m_dummyTexture[i] = CreateMetalTexture( dummyTextureProperties[i].type, + MTLPixelFormatRGBA8Unorm, + dummyTextureProperties[i].width, + dummyTextureProperties[i].height, + dummyTextureProperties[i].depth, + 1, + MTLStorageModePrivate, + MTLTextureUsageShaderRead, + samples ); + + // Don't upload data to multisample texture + if( samples > 1 ) { - uint32_t samples = dummyTextureProperties[i].samples; - - m_dummyTexture[i] = CreateMetalTexture( - dummyTextureProperties[i].type, - MTLPixelFormatRGBA8Unorm, - dummyTextureProperties[i].width, - dummyTextureProperties[i].height, - dummyTextureProperties[i].depth, - 1, - MTLStorageModePrivate, - MTLTextureUsageShaderRead, - samples - ); - - // Don't upload data to multisample texture - if( samples > 1 ) - { - continue; - } + continue; + } - // Calculate the number of bytes per row in the image - uint32_t bytesPerRow = sizeof(uint32_t) * textureDim; - uint32_t bytesPerImage = bytesPerRow * textureDim; + // Calculate the number of bytes per row in the image + uint32_t bytesPerRow = sizeof( uint32_t ) * textureDim; + uint32_t bytesPerImage = bytesPerRow * textureDim; - m_primaryWorkQueue.UploadTexture( m_dummyTexture[i], texData, 0, 0, bytesPerRow, bytesPerImage, 0, false ); - } + m_primaryWorkQueue.UploadTexture( m_dummyTexture[i], texData, 0, 0, bytesPerRow, bytesPerImage, 0, false ); + } - MTLSamplerDescriptor *samplerDescriptor = [[MTLSamplerDescriptor alloc] init]; - m_dummySampler = [m_device newSamplerStateWithDescriptor:samplerDescriptor]; + MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init]; + m_dummySampler = [m_device newSamplerStateWithDescriptor:samplerDescriptor]; -#if !__has_feature(objc_arc) - [samplerDescriptor release]; +#if !__has_feature( objc_arc ) + [samplerDescriptor release]; #endif - } +} - void MetalContext::GenerateDummyBuffer() - { - float bufferData[1024] = {}; +void MetalContext::GenerateDummyBuffer() +{ + float bufferData[1024] = {}; - m_dummyBuffer = CreateMetalBuffer( &m_primaryWorkQueue, sizeof( bufferData ), MTLResourceStorageModePrivate, bufferData ); - } + m_dummyBuffer = + CreateMetalBuffer( &m_primaryWorkQueue, sizeof( bufferData ), MTLResourceStorageModePrivate, bufferData ); +} - id MetalContext::GetDummyTexture( MTLTextureType textureType ) +id MetalContext::GetDummyTexture( MTLTextureType textureType ) +{ + for( uint32_t i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) { - for( uint32_t i = 0; i < METAL_NUM_DUMMY_TEXTURES; ++i ) + if( m_dummyTexture[i].textureType == textureType ) { - if ( m_dummyTexture[i].textureType == textureType ) - { - return m_dummyTexture[i]; - } + return m_dummyTexture[i]; } - - CCP_AL_LOGERR( "Dummy texture type not available. Accessing this texture can cause crashes on certain GPUs." ); - CCP_ASSERT( false ); - - return nil; } - id MetalContext::GetDummySampler() + CCP_AL_LOGERR( "Dummy texture type not available. Accessing this texture can cause crashes on certain GPUs." ); + CCP_ASSERT( false ); + + return nil; +} + +id MetalContext::GetDummySampler() +{ + return m_dummySampler; +} + +id MetalContext::GetDummyBuffer( NSUInteger* outSize, MTLVertexFormat* outFormat ) +{ + if( outSize ) { - return m_dummySampler; + *outSize = m_dummyBuffer.allocatedSize; } - id MetalContext::GetDummyBuffer( NSUInteger *outSize, MTLVertexFormat *outFormat ) + if( outFormat ) { - if( outSize ) - { - *outSize = m_dummyBuffer.allocatedSize; - } + *outFormat = MTLVertexFormatFloat4; + } - if( outFormat ) - { - *outFormat = MTLVertexFormatFloat4; - } + return m_dummyBuffer; +} - return m_dummyBuffer; +id MetalContext::CreateSRGBViewOfMetalTexture( id texture ) +{ + switch( texture.pixelFormat ) + { + case MTLPixelFormatRGBA8Unorm: + case MTLPixelFormatBGRA8Unorm: + case MTLPixelFormatBC1_RGBA: + case MTLPixelFormatBC2_RGBA: + case MTLPixelFormatBC3_RGBA: + case MTLPixelFormatBC7_RGBAUnorm: + // Metal is nice enough to make the SRGB version always one greater than the base format + return [texture newTextureViewWithPixelFormat:MTLPixelFormat( (uint32_t)texture.pixelFormat + 1 )]; + default: + return texture; } +} - id MetalContext::CreateSRGBViewOfMetalTexture( id texture ) +id MetalContext::CreateUAVOfMetalTexture( id texture, uint32_t mipLevel ) +{ + switch( texture.textureType ) { - switch( texture.pixelFormat ) + case MTLTextureTypeCube: + return [texture newTextureViewWithPixelFormat:texture.pixelFormat + textureType:MTLTextureType2DArray + levels:NSMakeRange( mipLevel, 1 ) + slices:NSMakeRange( 0, 6 )]; + case MTLTextureTypeCubeArray: + return [texture newTextureViewWithPixelFormat:texture.pixelFormat + textureType:MTLTextureType2DArray + levels:NSMakeRange( mipLevel, 1 ) + slices:NSMakeRange( 0, 6 * texture.arrayLength )]; + default: + if( mipLevel > 0 ) { - case MTLPixelFormatRGBA8Unorm: - case MTLPixelFormatBGRA8Unorm: - case MTLPixelFormatBC1_RGBA: - case MTLPixelFormatBC2_RGBA: - case MTLPixelFormatBC3_RGBA: - case MTLPixelFormatBC7_RGBAUnorm: - // Metal is nice enough to make the SRGB version always one greater than the base format - return [texture newTextureViewWithPixelFormat:MTLPixelFormat((uint32_t)texture.pixelFormat + 1)]; - default: - return texture; + return [texture newTextureViewWithPixelFormat:texture.pixelFormat + textureType:texture.textureType + levels:NSMakeRange( mipLevel, 1 ) + slices:NSMakeRange( 0, texture.arrayLength )]; } + return texture; } - - id MetalContext::CreateUAVOfMetalTexture( id texture, uint32_t mipLevel ) - { - switch( texture.textureType ) - { - case MTLTextureTypeCube: - return [texture newTextureViewWithPixelFormat:texture.pixelFormat textureType:MTLTextureType2DArray levels:NSMakeRange( mipLevel, 1 ) slices:NSMakeRange(0, 6)]; - case MTLTextureTypeCubeArray: - return [texture newTextureViewWithPixelFormat:texture.pixelFormat textureType:MTLTextureType2DArray levels:NSMakeRange( mipLevel, 1 ) slices:NSMakeRange(0, 6 * texture.arrayLength)]; - default: - if( mipLevel > 0 ) - { - return [texture newTextureViewWithPixelFormat:texture.pixelFormat textureType:texture.textureType levels:NSMakeRange( mipLevel, 1 ) slices:NSMakeRange(0, texture.arrayLength)]; - } - return texture; - } +} - } +void MetalContext::DestroyMetalTexture( id texture ) +{ +#if !__has_feature( objc_arc ) + [texture release]; +#endif +} - void MetalContext::DestroyMetalTexture(id texture) +uint32_t MetalContext::AllocateHeapIndex( id texture ) +{ + if( !texture || !m_resourceHeap ) { - #if !__has_feature(objc_arc) - [texture release]; - #endif + return 0xffffffff; } - - uint32_t MetalContext::AllocateHeapIndex( id texture ) - { - if( !texture || !m_resourceHeap ) - { - return 0xffffffff; - } - if( @available( macOS 13.0, * ) ) - { - return m_resourceHeap.Allocate( texture.gpuResourceID._impl ); - } - else - { - return 0xffffffff; - } - } - - uint32_t MetalContext::AllocateHeapIndex( id buffer ) - { - if( !buffer || !m_resourceHeap ) - { - return 0xffffffff; - } - if( @available( macOS 13.0, * ) ) - { - return m_resourceHeap.Allocate( buffer.gpuAddress ); - } - else - { - return 0xffffffff; - } - } - - uint32_t MetalContext::AllocateHeapIndex( id sampler ) - { - if( !sampler || !m_resourceHeap ) - { - return 0xffffffff; - } - if( @available( macOS 13.0, * ) ) - { - return m_resourceHeap.Allocate( sampler.gpuResourceID._impl ); - } - else - { - return 0xffffffff; - } - } - - void MetalContext::DeallocateHeapIndex( uint32_t index ) - { - m_resourceHeap.Deallocate( index ); - } - - id MetalContext::GetHeapViewBuffer() const - { - return m_resourceHeap.GetBuffer(); - } - - bool MetalContext::IsResourceInUse( uint64_t resourceLastAccessedFrame ) const + if( @available( macOS 13.0, * ) ) { - return GetRenderedFrameNumber() < resourceLastAccessedFrame; + return m_resourceHeap.Allocate( texture.gpuResourceID._impl ); } + else + { + return 0xffffffff; + } +} - uint64_t MetalContext::GetRecordingFrameNumber() const +uint32_t MetalContext::AllocateHeapIndex( id buffer ) +{ + if( !buffer || !m_resourceHeap ) + { + return 0xffffffff; + } + if( @available( macOS 13.0, * ) ) + { + return m_resourceHeap.Allocate( buffer.gpuAddress ); + } + else { - return m_recordingFrameNumber; + return 0xffffffff; } +} - uint64_t MetalContext::GetRenderedFrameNumber() const +uint32_t MetalContext::AllocateHeapIndex( id sampler ) +{ + if( !sampler || !m_resourceHeap ) + { + return 0xffffffff; + } + if( @available( macOS 13.0, * ) ) { - return m_renderedFrameNumber; + return m_resourceHeap.Allocate( sampler.gpuResourceID._impl ); } + else + { + return 0xffffffff; + } +} + +void MetalContext::DeallocateHeapIndex( uint32_t index ) +{ + m_resourceHeap.Deallocate( index ); +} + +id MetalContext::GetHeapViewBuffer() const +{ + return m_resourceHeap.GetBuffer(); +} + +bool MetalContext::IsResourceInUse( uint64_t resourceLastAccessedFrame ) const +{ + return GetRenderedFrameNumber() < resourceLastAccessedFrame; +} + +uint64_t MetalContext::GetRecordingFrameNumber() const +{ + return m_recordingFrameNumber; +} - void MetalContext::BlitToDrawableAndPresent( id srcTexture, NSView* view ) +uint64_t MetalContext::GetRenderedFrameNumber() const +{ + return m_renderedFrameNumber; +} + +void MetalContext::BlitToDrawableAndPresent( id srcTexture, NSView* view ) +{ + if( m_primaryWorkQueue.BlitToDrawableAndPresent( srcTexture, view, &m_renderedFrameNumber ) ) { - if( m_primaryWorkQueue.BlitToDrawableAndPresent( srcTexture, view, &m_renderedFrameNumber ) ) + CCP_STATS_SET( constantDataSize, GetConstantBufferAllocator().GetTotalUploadedSize() ); + ++m_recordingFrameNumber; + for( auto& alloc : m_cbAllocator ) { - CCP_STATS_SET( constantDataSize, GetConstantBufferAllocator().GetTotalUploadedSize() ); - ++m_recordingFrameNumber; - for( auto& alloc : m_cbAllocator ) - { - alloc.Reset(); - } - for( auto buffer : m_destroyedConstantBuffers ) - { - CCPAlignedFree( buffer ); - } - m_destroyedConstantBuffers.clear(); - if( m_resourceHeap ) - { - m_resourceHeap.SetFrameIndices( m_recordingFrameNumber, m_renderedFrameNumber ); - } - - FlushPendingRelease( m_renderedFrameNumber ); + alloc.Reset(); } - if( !m_gpuTimerRateMeasured ) + for( auto buffer : m_destroyedConstantBuffers ) { - if( @available( macOS 10.15, * ) ) - { - DeviceTimestamp endCpuTime, endGpuTime; - [m_device sampleTimestamps:&endCpuTime gpuTimestamp:&endGpuTime]; - - m_gpuTimerRate = double( endCpuTime - m_beginCpuTime ) / double( endGpuTime - m_beginGpuTime ); - } - m_gpuTimerRateMeasured = true; + CCPAlignedFree( buffer ); } - } - - double MetalContext::GetGpuTimerRate() const - { - return m_gpuTimerRate; - } - - id MetalContext::GetDevice() - { - return m_device; - } - - id MetalContext::GetCommandQueue() - { - return m_commandQueue; - } - - id MetalContext::GetCachedRenderPipelineState( size_t renderPipelineDescriptorHash ) - { - id pipelineState = nil; - - auto pipelineStateIt = m_renderPipelineStateMap.find(renderPipelineDescriptorHash); - if (pipelineStateIt != m_renderPipelineStateMap.end()) - { - pipelineState = pipelineStateIt->second; - } - else if( IsInParallelEncoding() ) - { - m_pipelineCacheMutex.lock(); - pipelineStateIt = m_newRenderPipelineStateMap.find(renderPipelineDescriptorHash); - if (pipelineStateIt != m_newRenderPipelineStateMap.end()) - { - pipelineState = pipelineStateIt->second; - } - m_pipelineCacheMutex.unlock(); - } - return pipelineState; - } - - void MetalContext::AddRenderPipelineStateToCache( size_t renderPipelineDescriptorHash, id pipelineState ) - { - if( IsInParallelEncoding() ) - { - m_pipelineCacheMutex.lock(); - m_newRenderPipelineStateMap.emplace( renderPipelineDescriptorHash, pipelineState ); - m_pipelineCacheMutex.unlock(); - } - else - { - m_renderPipelineStateMap.emplace( renderPipelineDescriptorHash, pipelineState ); - } - } - - id MetalContext::GetCachedComputePipelineState( size_t computePipelineDescriptorHash ) - { - id pipelineState = nil; - - auto pipelineStateIt = m_computePipelineStateMap.find( computePipelineDescriptorHash ); - if( pipelineStateIt != m_computePipelineStateMap.end() ) - { - pipelineState = pipelineStateIt->second; - } - return pipelineState; - } - - void MetalContext::AddComputePipelineStateToCache( size_t computePipelineDescriptorHash, id pipelineState ) - { - m_computePipelineStateMap.emplace( computePipelineDescriptorHash, pipelineState ); - } - - uint32_t MetalContext::BeginParallelEncoding( uint32_t requestedEncodersCount ) - { - if( m_secondaryWorkQueues.empty() ) + m_destroyedConstantBuffers.clear(); + if( m_resourceHeap ) { - return 0; + m_resourceHeap.SetFrameIndices( m_recordingFrameNumber, m_renderedFrameNumber ); } - m_primaryWorkQueue.ReleaseEncoder( true ); - - m_parallelEncodersCount = std::min( uint32_t( m_secondaryWorkQueues.size() ), requestedEncodersCount ); - for( uint32_t i = 0; i < m_parallelEncodersCount; ++i ) + + FlushPendingRelease( m_renderedFrameNumber ); + } + if( !m_gpuTimerRateMeasured ) + { + if( @available( macOS 10.15, * ) ) { - m_secondaryWorkQueues[i].BeginParallelEncoding( &m_primaryWorkQueue ); + DeviceTimestamp endCpuTime, endGpuTime; + [m_device sampleTimestamps:&endCpuTime gpuTimestamp:&endGpuTime]; + + m_gpuTimerRate = double( endCpuTime - m_beginCpuTime ) / double( endGpuTime - m_beginGpuTime ); } - - return m_parallelEncodersCount; + m_gpuTimerRateMeasured = true; } +} + +double MetalContext::GetGpuTimerRate() const +{ + return m_gpuTimerRate; +} + +id MetalContext::GetDevice() +{ + return m_device; +} + +id MetalContext::GetCommandQueue() +{ + return m_commandQueue; +} - void MetalContext::EndParallelEncoding() - { - for( uint32_t i=0; i < m_parallelEncodersCount; ++i ) +id MetalContext::GetCachedRenderPipelineState( size_t renderPipelineDescriptorHash ) +{ + id pipelineState = nil; + + auto pipelineStateIt = m_renderPipelineStateMap.find( renderPipelineDescriptorHash ); + if( pipelineStateIt != m_renderPipelineStateMap.end() ) + { + pipelineState = pipelineStateIt->second; + } + else if( IsInParallelEncoding() ) + { + m_pipelineCacheMutex.lock(); + pipelineStateIt = m_newRenderPipelineStateMap.find( renderPipelineDescriptorHash ); + if( pipelineStateIt != m_newRenderPipelineStateMap.end() ) { - m_secondaryWorkQueues[i].EndParallelEncoding(); + pipelineState = pipelineStateIt->second; } - - m_primaryWorkQueue.EndParallelEncoding(); - - m_renderPipelineStateMap.merge( m_newRenderPipelineStateMap ); - m_newRenderPipelineStateMap.clear(); - - m_parallelEncodersCount = 0; + m_pipelineCacheMutex.unlock(); } - - bool MetalContext::IsInParallelEncoding() const + return pipelineState; +} + +void MetalContext::AddRenderPipelineStateToCache( size_t renderPipelineDescriptorHash, + id pipelineState ) +{ + if( IsInParallelEncoding() ) { - return m_parallelEncodersCount > 0; + m_pipelineCacheMutex.lock(); + m_newRenderPipelineStateMap.emplace( renderPipelineDescriptorHash, pipelineState ); + m_pipelineCacheMutex.unlock(); } + else + { + m_renderPipelineStateMap.emplace( renderPipelineDescriptorHash, pipelineState ); + } +} - MetalWorkQueue* MetalContext::GetSecondaryWorkQueue( uint32_t index ) +id MetalContext::GetCachedComputePipelineState( size_t computePipelineDescriptorHash ) +{ + id pipelineState = nil; + + auto pipelineStateIt = m_computePipelineStateMap.find( computePipelineDescriptorHash ); + if( pipelineStateIt != m_computePipelineStateMap.end() ) { - if( index >= m_secondaryWorkQueues.size() ) - { - return nullptr; - } - return &m_secondaryWorkQueues[index]; + pipelineState = pipelineStateIt->second; } - - MetalWorkQueue* MetalContext::GetPrimaryWorkQueue() + return pipelineState; +} + +void MetalContext::AddComputePipelineStateToCache( size_t computePipelineDescriptorHash, + id pipelineState ) +{ + m_computePipelineStateMap.emplace( computePipelineDescriptorHash, pipelineState ); +} + +uint32_t MetalContext::BeginParallelEncoding( uint32_t requestedEncodersCount ) +{ + if( m_secondaryWorkQueues.empty() ) + { + return 0; + } + m_primaryWorkQueue.ReleaseEncoder( true ); + + m_parallelEncodersCount = std::min( uint32_t( m_secondaryWorkQueues.size() ), requestedEncodersCount ); + for( uint32_t i = 0; i < m_parallelEncodersCount; ++i ) + { + m_secondaryWorkQueues[i].BeginParallelEncoding( &m_primaryWorkQueue ); + } + + return m_parallelEncodersCount; +} + +void MetalContext::EndParallelEncoding() +{ + for( uint32_t i = 0; i < m_parallelEncodersCount; ++i ) { - return &m_primaryWorkQueue; + m_secondaryWorkQueues[i].EndParallelEncoding(); } + m_primaryWorkQueue.EndParallelEncoding(); + + m_renderPipelineStateMap.merge( m_newRenderPipelineStateMap ); + m_newRenderPipelineStateMap.clear(); + + m_parallelEncodersCount = 0; +} + +bool MetalContext::IsInParallelEncoding() const +{ + return m_parallelEncodersCount > 0; +} + +MetalWorkQueue* MetalContext::GetSecondaryWorkQueue( uint32_t index ) +{ + if( index >= m_secondaryWorkQueues.size() ) + { + return nullptr; + } + return &m_secondaryWorkQueues[index]; +} + +MetalWorkQueue* MetalContext::GetPrimaryWorkQueue() +{ + return &m_primaryWorkQueue; +} + ConstantBufferAllocator& MetalContext::GetConstantBufferAllocator() { - return m_cbAllocator[GetRecordingFrameNumber() % 3]; + return m_cbAllocator[GetRecordingFrameNumber() % 3]; } void MetalContext::ReleaseLater( id obj ) { - m_pendingRelease.push_back( { obj, GetRecordingFrameNumber() } ); + m_pendingRelease.push_back( { obj, GetRecordingFrameNumber() } ); } void MetalContext::FlushPendingRelease( uint64_t renderedFrame ) { - m_pendingRelease.erase( std::remove_if( begin( m_pendingRelease ), end( m_pendingRelease ), [&]( auto& item ) { return item.frame <= renderedFrame; } ), end( m_pendingRelease ) ); + m_pendingRelease.erase( std::remove_if( begin( m_pendingRelease ), + end( m_pendingRelease ), + [&]( auto& item ) { return item.frame <= renderedFrame; } ), + end( m_pendingRelease ) ); } } // namespace TrinityALImpl diff --git a/trinityal/metal/MetalResourceArray.h b/trinityal/metal/MetalResourceArray.h index 7e406ba40..cdb53e9e8 100644 --- a/trinityal/metal/MetalResourceArray.h +++ b/trinityal/metal/MetalResourceArray.h @@ -12,27 +12,28 @@ namespace TrinityALImpl class ResourceArrayArgumentBuffer { public: - using GpuResourceID = uint64_t; - - void Initialize( uint32_t initialSize, id device ); - operator bool() const; - - uint32_t Allocate( GpuResourceID gpuResourceID ); - void Deallocate( uint32_t ); - - id GetBuffer() const; - - void SetFrameIndices( uint64_t recordingFrame, uint64_t renderedFrame ); + using GpuResourceID = uint64_t; + + void Initialize( uint32_t initialSize, id device ); + operator bool() const; + + uint32_t Allocate( GpuResourceID gpuResourceID ); + void Deallocate( uint32_t ); + + id GetBuffer() const; + + void SetFrameIndices( uint64_t recordingFrame, uint64_t renderedFrame ); + private: - void Grow( uint32_t newSize ); - - id m_buffer; - std::vector m_data; - std::vector m_free; - std::vector> m_pendingFree; - uint64_t m_recordingFrame = 0; - uint32_t m_size = 0; - id m_device; + void Grow( uint32_t newSize ); + + id m_buffer; + std::vector m_data; + std::vector m_free; + std::vector> m_pendingFree; + uint64_t m_recordingFrame = 0; + uint32_t m_size = 0; + id m_device; }; } diff --git a/trinityal/metal/MetalResourceArray.mm b/trinityal/metal/MetalResourceArray.mm index c87dc8736..b57642181 100644 --- a/trinityal/metal/MetalResourceArray.mm +++ b/trinityal/metal/MetalResourceArray.mm @@ -11,88 +11,90 @@ void ResourceArrayArgumentBuffer::Initialize( uint32_t initialSize, id device ) { - m_device = device; - Grow( initialSize ); + m_device = device; + Grow( initialSize ); } ResourceArrayArgumentBuffer::operator bool() const { - return m_buffer != nil; + return m_buffer != nil; } -uint32_t ResourceArrayArgumentBuffer::Allocate( GpuResourceID gpuResourceID ) +uint32_t ResourceArrayArgumentBuffer::Allocate( GpuResourceID gpuResourceID ) { - if( !m_buffer ) - { - return 0xffffffff; - } - if( m_free.empty() ) - { - Grow( m_size * 2 ); - } - if( m_free.empty() ) - { - CCP_ASSERT( false ); - return 0xffffffff; - } - auto index = m_free.back(); - m_free.pop_back(); - m_data[index] = gpuResourceID; - reinterpret_cast( m_buffer.contents )[index] = gpuResourceID; - [m_buffer didModifyRange:NSMakeRange( index * sizeof( GpuResourceID ), sizeof( GpuResourceID ) )]; - return index; + if( !m_buffer ) + { + return 0xffffffff; + } + if( m_free.empty() ) + { + Grow( m_size * 2 ); + } + if( m_free.empty() ) + { + CCP_ASSERT( false ); + return 0xffffffff; + } + auto index = m_free.back(); + m_free.pop_back(); + m_data[index] = gpuResourceID; + reinterpret_cast( m_buffer.contents )[index] = gpuResourceID; + [m_buffer didModifyRange:NSMakeRange( index * sizeof( GpuResourceID ), sizeof( GpuResourceID ) )]; + return index; } void ResourceArrayArgumentBuffer::Deallocate( uint32_t index ) { - if( index == 0xffffffff ) - { - return; - } - CCP_ASSERT( index < m_size ); - m_pendingFree.push_back( { index, m_recordingFrame } ); + if( index == 0xffffffff ) + { + return; + } + CCP_ASSERT( index < m_size ); + m_pendingFree.push_back( { index, m_recordingFrame } ); } void ResourceArrayArgumentBuffer::Grow( uint32_t size ) { - if( size <= m_size ) - { - return; - } - for( uint32_t i = size; i > m_size; --i ) - { - m_free.push_back( i - 1 ); - } - m_data.resize( size ); - id buffer; - buffer = [m_device newBufferWithBytes:m_data.data() length:size * sizeof( GpuResourceID ) options:MTLResourceStorageModeManaged]; - m_buffer = buffer; - m_size = size; + if( size <= m_size ) + { + return; + } + for( uint32_t i = size; i > m_size; --i ) + { + m_free.push_back( i - 1 ); + } + m_data.resize( size ); + id buffer; + buffer = [m_device newBufferWithBytes:m_data.data() + length:size * sizeof( GpuResourceID ) + options:MTLResourceStorageModeManaged]; + m_buffer = buffer; + m_size = size; } void ResourceArrayArgumentBuffer::SetFrameIndices( uint64_t recordingFrame, uint64_t renderedFrame ) { - m_recordingFrame = recordingFrame; - size_t i = 0; - while( i < m_pendingFree.size() ) - { - auto& it = m_pendingFree[i]; - if( it.second < renderedFrame ) - { - m_free.push_back( it.first ); - it = m_pendingFree.back(); - m_pendingFree.pop_back(); - } - else - { - ++i; - } - } + m_recordingFrame = recordingFrame; + size_t i = 0; + while( i < m_pendingFree.size() ) + { + auto& it = m_pendingFree[i]; + if( it.second < renderedFrame ) + { + m_free.push_back( it.first ); + it = m_pendingFree.back(); + m_pendingFree.pop_back(); + } + else + { + ++i; + } + } } id ResourceArrayArgumentBuffer::GetBuffer() const { - return m_buffer; + return m_buffer; } } diff --git a/trinityal/metal/MetalShaderTypes.h b/trinityal/metal/MetalShaderTypes.h index fd72b65c9..4a8de2564 100644 --- a/trinityal/metal/MetalShaderTypes.h +++ b/trinityal/metal/MetalShaderTypes.h @@ -15,7 +15,7 @@ enum BlitPresentVertexInputIndex enum BlitPresentFragmentInputIndex { - BlitPresentFragmentInputIndexTexture = 0, + BlitPresentFragmentInputIndexTexture = 0, }; diff --git a/trinityal/metal/MetalUtils.h b/trinityal/metal/MetalUtils.h index 7acc20ce6..c46b79211 100644 --- a/trinityal/metal/MetalUtils.h +++ b/trinityal/metal/MetalUtils.h @@ -14,100 +14,100 @@ // Remove for prodcution code #define METAL_LOG_OUTPUT 0 #if METAL_LOG_OUTPUT -#define METAL_LOG(...) NSLog(__VA_ARGS__) +#define METAL_LOG( ... ) NSLog( __VA_ARGS__ ) #else -#define METAL_LOG(...) +#define METAL_LOG( ... ) #endif namespace TrinityALImpl { - struct MetalColor - { - float red; - float green; - float blue; - float alpha; - }; +struct MetalColor +{ + float red; + float green; + float blue; + float alpha; +}; - class MetalUtils - { - public: - MetalUtils(); - ~MetalUtils(); - - MTLPixelFormat GetMTLPixelFormat(Tr2RenderContextEnum::PixelFormat pixelFormat); - MTLVertexFormat GetMTLVertexFormat(Tr2VertexDefinition::DataType dataType); - MTLTextureType GetMTLTextureType(Tr2RenderContextEnum::TextureType type, uint32 arrayLength, uint32 sampleCount); - MTLCullMode GetMTLCullMode(Tr2RenderContextEnum::CullMode cullMode); - MTLBlendFactor GetMTLBlendFactor(uint32_t value); - MTLCompareFunction GetMTLCompareFunction(uint32_t value); - MTLStencilOperation GetMTLStencilOperation(uint32_t value); - MTLBlendOperation GetMTLBlendOperation(uint32_t value); - MTLColorWriteMask GetMTLColorWriteMask(Tr2RenderContextEnum::ColorWriteEnable writeMask); - MetalColor GetMetalColorFromRGBA8(uint32_t color); - - private: - MTLPixelFormat PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_SENTINEL]; - // Uh, this array size is a little sketchy - MTLVertexFormat VertexFormatConversionTable[METAL_SIZEOF_VERTEX_FORMAT_TABLE]; - - void SetupPixelFormatConversionTable(); - void SetupVertexFormatConversionTable(); - }; +class MetalUtils +{ +public: + MetalUtils(); + ~MetalUtils(); + + MTLPixelFormat GetMTLPixelFormat( Tr2RenderContextEnum::PixelFormat pixelFormat ); + MTLVertexFormat GetMTLVertexFormat( Tr2VertexDefinition::DataType dataType ); + MTLTextureType GetMTLTextureType( Tr2RenderContextEnum::TextureType type, uint32 arrayLength, uint32 sampleCount ); + MTLCullMode GetMTLCullMode( Tr2RenderContextEnum::CullMode cullMode ); + MTLBlendFactor GetMTLBlendFactor( uint32_t value ); + MTLCompareFunction GetMTLCompareFunction( uint32_t value ); + MTLStencilOperation GetMTLStencilOperation( uint32_t value ); + MTLBlendOperation GetMTLBlendOperation( uint32_t value ); + MTLColorWriteMask GetMTLColorWriteMask( Tr2RenderContextEnum::ColorWriteEnable writeMask ); + MetalColor GetMetalColorFromRGBA8( uint32_t color ); + +private: + MTLPixelFormat PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_SENTINEL]; + // Uh, this array size is a little sketchy + MTLVertexFormat VertexFormatConversionTable[METAL_SIZEOF_VERTEX_FORMAT_TABLE]; + + void SetupPixelFormatConversionTable(); + void SetupVertexFormatConversionTable(); +}; struct ConstantBufferToken { - void Invalidate() - { - frame--; - } - void Reset() - { - frame = 0; - offset = 0; - } - - // page index (32 bits) and offset (32 bits) - std::atomic offset = 0; - std::atomic frame = 0; + void Invalidate() + { + frame--; + } + void Reset() + { + frame = 0; + offset = 0; + } + + // page index (32 bits) and offset (32 bits) + std::atomic offset = 0; + std::atomic frame = 0; }; class ConstantBufferAllocator { public: - struct Entry - { - uint32_t offset; - uint32_t page; - }; - - ConstantBufferAllocator(); - ConstantBufferAllocator( const ConstantBufferAllocator& ) = delete; - - void Initialize( id device ); - void Reset(); - - Entry Allocate( const void* data, uint32_t size ); - id GetPage( uint32_t page ); - - uint32_t GetTotalUploadedSize() const; - - static const uint32_t CONST_PAGE_SIZE = 2 * 1024 * 1024; - static const uint32_t CONST_ALIGNMENT = 256; - static const uint32_t MAX_PAGE_COUNT = 32; + struct Entry + { + uint32_t offset; + uint32_t page; + }; + + ConstantBufferAllocator(); + ConstantBufferAllocator( const ConstantBufferAllocator& ) = delete; + + void Initialize( id device ); + void Reset(); + + Entry Allocate( const void* data, uint32_t size ); + id GetPage( uint32_t page ); + + uint32_t GetTotalUploadedSize() const; + + static const uint32_t CONST_PAGE_SIZE = 2 * 1024 * 1024; + static const uint32_t CONST_ALIGNMENT = 256; + static const uint32_t MAX_PAGE_COUNT = 32; private: - void CreatePage( uint32_t index ); - - // page index (32 bits) and offset (32 bits) - std::atomic m_offset; - uint8_t* m_pageContents[MAX_PAGE_COUNT]; - id m_pages[MAX_PAGE_COUNT]; - id m_device; - std::mutex m_pagesMutex; - uint32_t m_totalUploadedSize; + void CreatePage( uint32_t index ); + + // page index (32 bits) and offset (32 bits) + std::atomic m_offset; + uint8_t* m_pageContents[MAX_PAGE_COUNT]; + id m_pages[MAX_PAGE_COUNT]; + id m_device; + std::mutex m_pagesMutex; + uint32_t m_totalUploadedSize; }; diff --git a/trinityal/metal/MetalUtils.mm b/trinityal/metal/MetalUtils.mm index 3e2182007..c03fa8159 100644 --- a/trinityal/metal/MetalUtils.mm +++ b/trinityal/metal/MetalUtils.mm @@ -17,110 +17,111 @@ PixelFormatConversionTable[i] = MTLPixelFormatInvalid; } - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT] = MTLPixelFormatRGBA32Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_UINT] = MTLPixelFormatRGBA32Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_SINT] = MTLPixelFormatRGBA32Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_UINT] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_SINT] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT] = MTLPixelFormatRGBA16Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UNORM] = MTLPixelFormatRGBA16Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UINT] = MTLPixelFormatRGBA16Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_SNORM] = MTLPixelFormatRGBA16Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_SINT] = MTLPixelFormatRGBA16Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_FLOAT] = MTLPixelFormatRG32Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_UINT] = MTLPixelFormatRG32Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_SINT] = MTLPixelFormatRG32Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G8X24_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT_S8X24_UINT] = MTLPixelFormatDepth32Float_Stencil8; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_UNORM] = MTLPixelFormatRGB10A2Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_UINT] = MTLPixelFormatRGB10A2Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R11G11B10_FLOAT] = MTLPixelFormatRG11B10Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_TYPELESS ] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM] = MTLPixelFormatRGBA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB] = MTLPixelFormatRGBA8Unorm_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UINT] = MTLPixelFormatRGBA8Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_SNORM] = MTLPixelFormatRGBA8Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_SINT] = MTLPixelFormatRGBA8Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_FLOAT] = MTLPixelFormatRG16Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_UNORM] = MTLPixelFormatRG16Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_UINT] = MTLPixelFormatRG16Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_SNORM] = MTLPixelFormatRG16Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_SINT] = MTLPixelFormatRG16Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT] = MTLPixelFormatDepth32Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT] = MTLPixelFormatR32Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_UINT] = MTLPixelFormatR32Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_SINT] = MTLPixelFormatR32Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R24G8_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT] = MTLPixelFormatRGBA32Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_UINT] = MTLPixelFormatRGBA32Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_SINT] = MTLPixelFormatRGBA32Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_UINT] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_SINT] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT] = MTLPixelFormatRGBA16Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UNORM] = MTLPixelFormatRGBA16Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_UINT] = MTLPixelFormatRGBA16Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_SNORM] = MTLPixelFormatRGBA16Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_SINT] = MTLPixelFormatRGBA16Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_FLOAT] = MTLPixelFormatRG32Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_UINT] = MTLPixelFormatRG32Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G32_SINT] = MTLPixelFormatRG32Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32G8X24_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT_S8X24_UINT] = + MTLPixelFormatDepth32Float_Stencil8; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_UNORM] = MTLPixelFormatRGB10A2Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10A2_UINT] = MTLPixelFormatRGB10A2Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R11G11B10_FLOAT] = MTLPixelFormatRG11B10Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM] = MTLPixelFormatRGBA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB] = MTLPixelFormatRGBA8Unorm_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UINT] = MTLPixelFormatRGBA8Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_SNORM] = MTLPixelFormatRGBA8Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_SINT] = MTLPixelFormatRGBA8Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_FLOAT] = MTLPixelFormatRG16Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_UNORM] = MTLPixelFormatRG16Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_UINT] = MTLPixelFormatRG16Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_SNORM] = MTLPixelFormatRG16Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_SINT] = MTLPixelFormatRG16Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D32_FLOAT] = MTLPixelFormatDepth32Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_FLOAT] = MTLPixelFormatR32Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_UINT] = MTLPixelFormatR32Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R32_SINT] = MTLPixelFormatR32Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R24G8_TYPELESS] = MTLPixelFormatInvalid; // HACK: D24S8 is emulated on Intel/AMD and is not supported on Apple Silicon. Use D32 or D32S8 instead. - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT] = MTLPixelFormatDepth32Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R24_UNORM_X8_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_X24_TYPELESS_G8_UINT] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_UNORM] = MTLPixelFormatRG8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_UINT] = MTLPixelFormatRG8Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_SNORM] = MTLPixelFormatRG8Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_SINT] = MTLPixelFormatRG8Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_FLOAT] = MTLPixelFormatR16Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D16_UNORM] = MTLPixelFormatDepth16Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_UNORM] = MTLPixelFormatR16Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT] = MTLPixelFormatR16Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_SNORM] = MTLPixelFormatR16Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_SINT] = MTLPixelFormatR16Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_UNORM] = MTLPixelFormatR8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_UINT] = MTLPixelFormatR8Uint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_SNORM] = MTLPixelFormatR8Snorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_SINT] = MTLPixelFormatR8Sint; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_A8_UNORM] = MTLPixelFormatA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R1_UNORM] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R9G9B9E5_SHAREDEXP] = MTLPixelFormatRGB9E5Float; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_B8G8_UNORM] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_G8R8_G8B8_UNORM] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM] = MTLPixelFormatBC1_RGBA; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM_SRGB] = MTLPixelFormatBC1_RGBA_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_UNORM] = MTLPixelFormatBC2_RGBA; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_UNORM_SRGB] = MTLPixelFormatBC2_RGBA_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM] = MTLPixelFormatBC3_RGBA; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM_SRGB] = MTLPixelFormatBC3_RGBA_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_UNORM] = MTLPixelFormatBC4_RUnorm; // Check - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_SNORM] = MTLPixelFormatBC4_RSnorm; // Check - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_UNORM] = MTLPixelFormatBC5_RGUnorm; // Check - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_SNORM] = MTLPixelFormatBC5_RGSnorm; // Check - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B5G6R5_UNORM] = MTLPixelFormatInvalid; // iOS only - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B5G5R5A1_UNORM] = MTLPixelFormatInvalid; // iOS only - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM] = MTLPixelFormatBGRA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM] = MTLPixelFormatBGRA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_TYPELESS] = MTLPixelFormatBGRA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB] = MTLPixelFormatBGRA8Unorm_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_TYPELESS] = MTLPixelFormatBGRA8Unorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB] = MTLPixelFormatBGRA8Unorm_sRGB; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_UF16] = MTLPixelFormatBC6H_RGBUfloat; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_SF16] = MTLPixelFormatBC6H_RGBFloat; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_TYPELESS] = MTLPixelFormatInvalid; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM] = MTLPixelFormatBC7_RGBAUnorm; - PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM_SRGB] = MTLPixelFormatBC7_RGBAUnorm_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT] = MTLPixelFormatDepth32Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R24_UNORM_X8_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_X24_TYPELESS_G8_UINT] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_UNORM] = MTLPixelFormatRG8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_UINT] = MTLPixelFormatRG8Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_SNORM] = MTLPixelFormatRG8Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_SINT] = MTLPixelFormatRG8Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_FLOAT] = MTLPixelFormatR16Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_D16_UNORM] = MTLPixelFormatDepth16Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_UNORM] = MTLPixelFormatR16Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT] = MTLPixelFormatR16Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_SNORM] = MTLPixelFormatR16Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R16_SINT] = MTLPixelFormatR16Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_UNORM] = MTLPixelFormatR8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_UINT] = MTLPixelFormatR8Uint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_SNORM] = MTLPixelFormatR8Snorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8_SINT] = MTLPixelFormatR8Sint; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_A8_UNORM] = MTLPixelFormatA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R1_UNORM] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R9G9B9E5_SHAREDEXP] = MTLPixelFormatRGB9E5Float; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R8G8_B8G8_UNORM] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_G8R8_G8B8_UNORM] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM] = MTLPixelFormatBC1_RGBA; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM_SRGB] = MTLPixelFormatBC1_RGBA_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_UNORM] = MTLPixelFormatBC2_RGBA; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC2_UNORM_SRGB] = MTLPixelFormatBC2_RGBA_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM] = MTLPixelFormatBC3_RGBA; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM_SRGB] = MTLPixelFormatBC3_RGBA_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_UNORM] = MTLPixelFormatBC4_RUnorm; // Check + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC4_SNORM] = MTLPixelFormatBC4_RSnorm; // Check + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_UNORM] = MTLPixelFormatBC5_RGUnorm; // Check + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC5_SNORM] = MTLPixelFormatBC5_RGSnorm; // Check + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B5G6R5_UNORM] = MTLPixelFormatInvalid; // iOS only + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B5G5R5A1_UNORM] = MTLPixelFormatInvalid; // iOS only + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM] = MTLPixelFormatBGRA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM] = MTLPixelFormatBGRA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_TYPELESS] = MTLPixelFormatBGRA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB] = MTLPixelFormatBGRA8Unorm_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_TYPELESS] = MTLPixelFormatBGRA8Unorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB] = MTLPixelFormatBGRA8Unorm_sRGB; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_UF16] = MTLPixelFormatBC6H_RGBUfloat; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC6H_SF16] = MTLPixelFormatBC6H_RGBFloat; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_TYPELESS] = MTLPixelFormatInvalid; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM] = MTLPixelFormatBC7_RGBAUnorm; + PixelFormatConversionTable[Tr2RenderContextEnum::PIXEL_FORMAT_BC7_UNORM_SRGB] = MTLPixelFormatBC7_RGBAUnorm_sRGB; } -MTLPixelFormat MetalUtils::GetMTLPixelFormat(Tr2RenderContextEnum::PixelFormat pixelFormat) +MTLPixelFormat MetalUtils::GetMTLPixelFormat( Tr2RenderContextEnum::PixelFormat pixelFormat ) { if( pixelFormat < Tr2RenderContextEnum::PIXEL_FORMAT_SENTINEL ) { @@ -132,20 +133,21 @@ } } -MTLTextureType MetalUtils::GetMTLTextureType(Tr2RenderContextEnum::TextureType type, uint32 arrayLength, uint32 sampleCount) +MTLTextureType + MetalUtils::GetMTLTextureType( Tr2RenderContextEnum::TextureType type, uint32 arrayLength, uint32 sampleCount ) { switch( type ) { case Tr2RenderContextEnum::TEX_TYPE_1D: - return (arrayLength > 1) ? MTLTextureType1DArray : MTLTextureType1D; + return ( arrayLength > 1 ) ? MTLTextureType1DArray : MTLTextureType1D; case Tr2RenderContextEnum::TEX_TYPE_2D: if( sampleCount > 1 ) { - return (arrayLength > 1) ? MTLTextureType2DMultisampleArray : MTLTextureType2DMultisample; + return ( arrayLength > 1 ) ? MTLTextureType2DMultisampleArray : MTLTextureType2DMultisample; } else { - return (arrayLength > 1) ? MTLTextureType2DArray : MTLTextureType2D; + return ( arrayLength > 1 ) ? MTLTextureType2DArray : MTLTextureType2D; } case Tr2RenderContextEnum::TEX_TYPE_3D: return MTLTextureType3D; @@ -167,66 +169,66 @@ VertexFormatConversionTable[i] = MTLVertexFormatInvalid; } - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_1] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_2] = MTLVertexFormatChar2; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_3] = MTLVertexFormatChar3; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_4] = MTLVertexFormatChar4; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_1] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_2] = MTLVertexFormatChar2; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_3] = MTLVertexFormatChar3; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_4] = MTLVertexFormatChar4; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_1] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_2] = MTLVertexFormatUChar2; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_3] = MTLVertexFormatUChar3; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_4] = MTLVertexFormatUChar4; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_1] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_2] = MTLVertexFormatUChar2; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_3] = MTLVertexFormatUChar3; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_4] = MTLVertexFormatUChar4; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_1_NORM] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_2_NORM] = MTLVertexFormatChar2Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_3_NORM] = MTLVertexFormatChar3Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::BYTE_4_NORM] = MTLVertexFormatChar4Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_1_NORM] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_2_NORM] = MTLVertexFormatChar2Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_3_NORM] = MTLVertexFormatChar3Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::BYTE_4_NORM] = MTLVertexFormatChar4Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_1_NORM] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_2_NORM] = MTLVertexFormatUChar2Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_3_NORM] = MTLVertexFormatUChar3Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_4_NORM] = MTLVertexFormatUChar4Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_1_NORM] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_2_NORM] = MTLVertexFormatUChar2Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_3_NORM] = MTLVertexFormatUChar3Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::UBYTE_4_NORM] = MTLVertexFormatUChar4Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_1] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_2] = MTLVertexFormatShort2; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_3] = MTLVertexFormatShort3; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_4] = MTLVertexFormatShort4; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_1] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_2] = MTLVertexFormatShort2; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_3] = MTLVertexFormatShort3; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_4] = MTLVertexFormatShort4; - VertexFormatConversionTable[Tr2VertexDefinition::USHORT_1] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::USHORT_2] = MTLVertexFormatUShort2; - VertexFormatConversionTable[Tr2VertexDefinition::USHORT_3] = MTLVertexFormatUShort3; - VertexFormatConversionTable[Tr2VertexDefinition::USHORT_4] = MTLVertexFormatUShort4; + VertexFormatConversionTable[Tr2VertexDefinition::USHORT_1] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::USHORT_2] = MTLVertexFormatUShort2; + VertexFormatConversionTable[Tr2VertexDefinition::USHORT_3] = MTLVertexFormatUShort3; + VertexFormatConversionTable[Tr2VertexDefinition::USHORT_4] = MTLVertexFormatUShort4; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_1_NORM] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_2_NORM] = MTLVertexFormatShort2Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_3_NORM] = MTLVertexFormatShort3Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::SHORT_4_NORM] = MTLVertexFormatShort4Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_1_NORM] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_2_NORM] = MTLVertexFormatShort2Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_3_NORM] = MTLVertexFormatShort3Normalized; + VertexFormatConversionTable[Tr2VertexDefinition::SHORT_4_NORM] = MTLVertexFormatShort4Normalized; VertexFormatConversionTable[Tr2VertexDefinition::USHORT_1_NORM] = MTLVertexFormatInvalid; VertexFormatConversionTable[Tr2VertexDefinition::USHORT_2_NORM] = MTLVertexFormatUShort2Normalized; VertexFormatConversionTable[Tr2VertexDefinition::USHORT_3_NORM] = MTLVertexFormatUShort3Normalized; VertexFormatConversionTable[Tr2VertexDefinition::USHORT_4_NORM] = MTLVertexFormatUShort4Normalized; - VertexFormatConversionTable[Tr2VertexDefinition::INT32_1] = MTLVertexFormatInt; - VertexFormatConversionTable[Tr2VertexDefinition::INT32_2] = MTLVertexFormatInt2; - VertexFormatConversionTable[Tr2VertexDefinition::INT32_3] = MTLVertexFormatInt3; - VertexFormatConversionTable[Tr2VertexDefinition::INT32_4] = MTLVertexFormatInt4; - - VertexFormatConversionTable[Tr2VertexDefinition::UINT32_1] = MTLVertexFormatUInt; - VertexFormatConversionTable[Tr2VertexDefinition::UINT32_2] = MTLVertexFormatUInt2; - VertexFormatConversionTable[Tr2VertexDefinition::UINT32_3] = MTLVertexFormatUInt3; - VertexFormatConversionTable[Tr2VertexDefinition::UINT32_4] = MTLVertexFormatUInt4; - - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_1] = MTLVertexFormatInvalid; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_2] = MTLVertexFormatHalf2; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_3] = MTLVertexFormatHalf3; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_4] = MTLVertexFormatHalf4; - - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_1] = MTLVertexFormatFloat; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_2] = MTLVertexFormatFloat2; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_3] = MTLVertexFormatFloat3; - VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_4] = MTLVertexFormatFloat4; + VertexFormatConversionTable[Tr2VertexDefinition::INT32_1] = MTLVertexFormatInt; + VertexFormatConversionTable[Tr2VertexDefinition::INT32_2] = MTLVertexFormatInt2; + VertexFormatConversionTable[Tr2VertexDefinition::INT32_3] = MTLVertexFormatInt3; + VertexFormatConversionTable[Tr2VertexDefinition::INT32_4] = MTLVertexFormatInt4; + + VertexFormatConversionTable[Tr2VertexDefinition::UINT32_1] = MTLVertexFormatUInt; + VertexFormatConversionTable[Tr2VertexDefinition::UINT32_2] = MTLVertexFormatUInt2; + VertexFormatConversionTable[Tr2VertexDefinition::UINT32_3] = MTLVertexFormatUInt3; + VertexFormatConversionTable[Tr2VertexDefinition::UINT32_4] = MTLVertexFormatUInt4; + + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_1] = MTLVertexFormatInvalid; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_2] = MTLVertexFormatHalf2; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_3] = MTLVertexFormatHalf3; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT16_4] = MTLVertexFormatHalf4; + + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_1] = MTLVertexFormatFloat; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_2] = MTLVertexFormatFloat2; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_3] = MTLVertexFormatFloat3; + VertexFormatConversionTable[Tr2VertexDefinition::FLOAT32_4] = MTLVertexFormatFloat4; } MTLVertexFormat MetalUtils::GetMTLVertexFormat( Tr2VertexDefinition::DataType dataType ) @@ -251,24 +253,24 @@ { // It seems like Trinity uses the D3D enums directly here static const MTLBlendFactor BlendFormatConversionTable[] = { - (MTLBlendFactor)-1, // -- - MTLBlendFactorZero, // D3DBLEND_ZERO - MTLBlendFactorOne, // D3DBLEND_ONE - MTLBlendFactorSourceColor, // D3DBLEND_SRCCOLOR - MTLBlendFactorOneMinusSourceColor, // D3DBLEND_INVSRCCOLOR - MTLBlendFactorSourceAlpha, // D3DBLEND_SRCALPHA - MTLBlendFactorOneMinusSourceAlpha, // D3DBLEND_INVSRCALPHA - MTLBlendFactorDestinationAlpha, // D3DBLEND_DESTALPHA - MTLBlendFactorOneMinusDestinationAlpha, // D3DBLEND_INVDESTALPHA - MTLBlendFactorDestinationColor, // D3DBLEND_DESTCOLOR - MTLBlendFactorOneMinusDestinationColor, // D3DBLEND_INVDESTCOLOR - MTLBlendFactorSourceAlphaSaturated, // D3DBLEND_SRCALPHASAT - MTLBlendFactorSource1Alpha, // D3DBLEND_BOTHSRCALPHA - MTLBlendFactorOneMinusSource1Alpha, // D3DBLEND_BOTHINVSRCALPHA - MTLBlendFactorBlendColor, // D3DBLEND_BLENDFACTOR - MTLBlendFactorOneMinusBlendColor, // D3DBLEND_INVBLENDFACTOR - MTLBlendFactorSource1Color, // D3DBLEND_SRCCOLOR2 - MTLBlendFactorOneMinusSource1Color, // D3DBLEND_INVSRCCOLOR2 + (MTLBlendFactor)-1, // -- + MTLBlendFactorZero, // D3DBLEND_ZERO + MTLBlendFactorOne, // D3DBLEND_ONE + MTLBlendFactorSourceColor, // D3DBLEND_SRCCOLOR + MTLBlendFactorOneMinusSourceColor, // D3DBLEND_INVSRCCOLOR + MTLBlendFactorSourceAlpha, // D3DBLEND_SRCALPHA + MTLBlendFactorOneMinusSourceAlpha, // D3DBLEND_INVSRCALPHA + MTLBlendFactorDestinationAlpha, // D3DBLEND_DESTALPHA + MTLBlendFactorOneMinusDestinationAlpha, // D3DBLEND_INVDESTALPHA + MTLBlendFactorDestinationColor, // D3DBLEND_DESTCOLOR + MTLBlendFactorOneMinusDestinationColor, // D3DBLEND_INVDESTCOLOR + MTLBlendFactorSourceAlphaSaturated, // D3DBLEND_SRCALPHASAT + MTLBlendFactorSource1Alpha, // D3DBLEND_BOTHSRCALPHA + MTLBlendFactorOneMinusSource1Alpha, // D3DBLEND_BOTHINVSRCALPHA + MTLBlendFactorBlendColor, // D3DBLEND_BLENDFACTOR + MTLBlendFactorOneMinusBlendColor, // D3DBLEND_INVBLENDFACTOR + MTLBlendFactorSource1Color, // D3DBLEND_SRCCOLOR2 + MTLBlendFactorOneMinusSource1Color, // D3DBLEND_INVSRCCOLOR2 }; @@ -278,46 +280,46 @@ MTLCompareFunction MetalUtils::GetMTLCompareFunction( uint32_t value ) { static const MTLCompareFunction CompareFunctionCoversionTable[] = { - (MTLCompareFunction)-1, // -- - MTLCompareFunctionNever, // D3DCMP_NEVER - MTLCompareFunctionLess, // D3DCMP_LESS - MTLCompareFunctionEqual, // D3DCMP_EQUAL - MTLCompareFunctionLessEqual, // D3DCMP_LESSEQUAL - MTLCompareFunctionGreater, // D3DCMP_GREATER - MTLCompareFunctionNotEqual, // D3DCMP_NOTEQUAL - MTLCompareFunctionGreaterEqual,// D3DCMP_GREATEREQUAL - MTLCompareFunctionAlways, // D3DCMP_ALWAYS + (MTLCompareFunction)-1, // -- + MTLCompareFunctionNever, // D3DCMP_NEVER + MTLCompareFunctionLess, // D3DCMP_LESS + MTLCompareFunctionEqual, // D3DCMP_EQUAL + MTLCompareFunctionLessEqual, // D3DCMP_LESSEQUAL + MTLCompareFunctionGreater, // D3DCMP_GREATER + MTLCompareFunctionNotEqual, // D3DCMP_NOTEQUAL + MTLCompareFunctionGreaterEqual, // D3DCMP_GREATEREQUAL + MTLCompareFunctionAlways, // D3DCMP_ALWAYS }; return CompareFunctionCoversionTable[value]; } -MTLStencilOperation MetalUtils::GetMTLStencilOperation( uint32_t value ) +MTLStencilOperation MetalUtils::GetMTLStencilOperation( uint32_t value ) { static const MTLStencilOperation StencilOperationConversionTable[] = { - (MTLStencilOperation)-1, // --- - MTLStencilOperationKeep, // D3DSTENCILOP_KEEP - MTLStencilOperationZero, // D3DSTENCILOP_ZERO - MTLStencilOperationReplace, // D3DSTENCILOP_REPLACE - MTLStencilOperationIncrementClamp, // D3DSTENCILOP_INCRSAT - MTLStencilOperationDecrementClamp, // D3DSTENCILOP_DECRSAT - MTLStencilOperationInvert, // D3DSTENCILOP_INVERT - MTLStencilOperationIncrementWrap, // D3DSTENCILOP_INCR - MTLStencilOperationDecrementWrap, // D3DSTENCILOP_DECR + (MTLStencilOperation)-1, // --- + MTLStencilOperationKeep, // D3DSTENCILOP_KEEP + MTLStencilOperationZero, // D3DSTENCILOP_ZERO + MTLStencilOperationReplace, // D3DSTENCILOP_REPLACE + MTLStencilOperationIncrementClamp, // D3DSTENCILOP_INCRSAT + MTLStencilOperationDecrementClamp, // D3DSTENCILOP_DECRSAT + MTLStencilOperationInvert, // D3DSTENCILOP_INVERT + MTLStencilOperationIncrementWrap, // D3DSTENCILOP_INCR + MTLStencilOperationDecrementWrap, // D3DSTENCILOP_DECR }; return StencilOperationConversionTable[value]; } -MTLBlendOperation MetalUtils::GetMTLBlendOperation( uint32_t value ) +MTLBlendOperation MetalUtils::GetMTLBlendOperation( uint32_t value ) { static const MTLBlendOperation BlendOperationConversionTable[] = { - (MTLBlendOperation)-1, // --- - MTLBlendOperationAdd, // D3DBLENDOP_ADD - MTLBlendOperationSubtract, // D3DBLENDOP_SUBTRACT - MTLBlendOperationReverseSubtract, // D3DBLENDOP_REVSUBTRACT - MTLBlendOperationMin, // D3DBLENDOP_MIN - MTLBlendOperationMax, // D3DBLENDOP_MAX + (MTLBlendOperation)-1, // --- + MTLBlendOperationAdd, // D3DBLENDOP_ADD + MTLBlendOperationSubtract, // D3DBLENDOP_SUBTRACT + MTLBlendOperationReverseSubtract, // D3DBLENDOP_REVSUBTRACT + MTLBlendOperationMin, // D3DBLENDOP_MIN + MTLBlendOperationMax, // D3DBLENDOP_MAX }; return BlendOperationConversionTable[value]; @@ -326,19 +328,23 @@ MTLColorWriteMask MetalUtils::GetMTLColorWriteMask( Tr2RenderContextEnum::ColorWriteEnable writeMask ) { MTLColorWriteMask metalWriteMask = MTLColorWriteMaskNone; - if (writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_RED) metalWriteMask |= MTLColorWriteMaskRed; - if (writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_GREEN) metalWriteMask |= MTLColorWriteMaskGreen; - if (writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_BLUE) metalWriteMask |= MTLColorWriteMaskBlue; - if (writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_ALPHA) metalWriteMask |= MTLColorWriteMaskAlpha; + if( writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_RED ) + metalWriteMask |= MTLColorWriteMaskRed; + if( writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_GREEN ) + metalWriteMask |= MTLColorWriteMaskGreen; + if( writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_BLUE ) + metalWriteMask |= MTLColorWriteMaskBlue; + if( writeMask & Tr2RenderContextEnum::COLORWRITEENABLE_ALPHA ) + metalWriteMask |= MTLColorWriteMaskAlpha; return metalWriteMask; } MetalColor MetalUtils::GetMetalColorFromRGBA8( uint32_t color ) { MetalColor metalColor; - metalColor.red = float( ( color >> 0 ) & 0xff ) / 255.f; - metalColor.green = float( ( color >> 8 ) & 0xff ) / 255.f; - metalColor.blue = float( ( color >> 16 ) & 0xff ) / 255.f; + metalColor.red = float( ( color >> 0 ) & 0xff ) / 255.f; + metalColor.green = float( ( color >> 8 ) & 0xff ) / 255.f; + metalColor.blue = float( ( color >> 16 ) & 0xff ) / 255.f; metalColor.alpha = float( ( color >> 24 ) & 0xff ) / 255.f; return metalColor; @@ -355,84 +361,81 @@ } -ConstantBufferAllocator::ConstantBufferAllocator() -: m_device( nullptr ), - m_offset( 0 ), - m_totalUploadedSize( 0 ) +ConstantBufferAllocator::ConstantBufferAllocator() : m_device( nullptr ), m_offset( 0 ), m_totalUploadedSize( 0 ) { - std::fill( std::begin( m_pages ), std::end( m_pages ), nullptr ); + std::fill( std::begin( m_pages ), std::end( m_pages ), nullptr ); } void ConstantBufferAllocator::Initialize( id device ) { - m_device = device; - std::fill( std::begin( m_pages ), std::end( m_pages ), nullptr ); - std::fill( std::begin( m_pageContents ), std::end( m_pageContents ), nullptr ); - CreatePage( 0 ); - m_offset = 0; - m_totalUploadedSize = 0; + m_device = device; + std::fill( std::begin( m_pages ), std::end( m_pages ), nullptr ); + std::fill( std::begin( m_pageContents ), std::end( m_pageContents ), nullptr ); + CreatePage( 0 ); + m_offset = 0; + m_totalUploadedSize = 0; } void ConstantBufferAllocator::Reset() { - m_offset = 0; - m_totalUploadedSize = 0; + m_offset = 0; + m_totalUploadedSize = 0; } uint32_t ConstantBufferAllocator::GetTotalUploadedSize() const { - return m_totalUploadedSize + ( m_offset & 0xffffffff ); + return m_totalUploadedSize + ( m_offset & 0xffffffff ); } ConstantBufferAllocator::Entry ConstantBufferAllocator::Allocate( const void* data, uint32_t size ) { - auto dataSize = size; - size = ( size + ( CONST_ALIGNMENT - 1 ) ) & ~( CONST_ALIGNMENT - 1 ); - - uint64_t offset = m_offset.fetch_add( size, std::memory_order_relaxed ); - if( ( offset & 0xffffffff ) + size > CONST_PAGE_SIZE ) - { - m_pagesMutex.lock(); - offset = m_offset.fetch_add( size, std::memory_order_relaxed ); - if( ( offset & 0xffffffff ) + size > CONST_PAGE_SIZE ) - { - auto pageIndex = offset >> 32; - ++pageIndex; - if( !m_pages[pageIndex] ) - { - CreatePage( uint32_t( pageIndex ) ); - } - m_totalUploadedSize += m_offset & 0xffffffff; - m_offset = ( pageIndex << 32 ) | size; - offset = pageIndex << 32; - } - m_pagesMutex.unlock(); - } - Entry entry; - entry.offset = offset & 0xffffffff; - entry.page = offset >> 32; - if( data ) - { - memcpy( m_pageContents[entry.page] + entry.offset, data, dataSize ); - } - return entry; + auto dataSize = size; + size = ( size + ( CONST_ALIGNMENT - 1 ) ) & ~( CONST_ALIGNMENT - 1 ); + + uint64_t offset = m_offset.fetch_add( size, std::memory_order_relaxed ); + if( ( offset & 0xffffffff ) + size > CONST_PAGE_SIZE ) + { + m_pagesMutex.lock(); + offset = m_offset.fetch_add( size, std::memory_order_relaxed ); + if( ( offset & 0xffffffff ) + size > CONST_PAGE_SIZE ) + { + auto pageIndex = offset >> 32; + ++pageIndex; + if( !m_pages[pageIndex] ) + { + CreatePage( uint32_t( pageIndex ) ); + } + m_totalUploadedSize += m_offset & 0xffffffff; + m_offset = ( pageIndex << 32 ) | size; + offset = pageIndex << 32; + } + m_pagesMutex.unlock(); + } + Entry entry; + entry.offset = offset & 0xffffffff; + entry.page = offset >> 32; + if( data ) + { + memcpy( m_pageContents[entry.page] + entry.offset, data, dataSize ); + } + return entry; } id ConstantBufferAllocator::GetPage( uint32_t page ) { - return m_pages[page]; + return m_pages[page]; } void ConstantBufferAllocator::CreatePage( uint32_t index ) { - auto options = MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined; - if( @available(macOS 10.15, *) ) - { - options |= MTLHazardTrackingModeUntracked; - } - m_pages[index] = [m_device newBufferWithLength:CONST_PAGE_SIZE options:options]; - m_pages[index].label = [NSString stringWithUTF8String:"Constant buffer"]; - m_pageContents[index] = static_cast( m_pages[index].contents ); + auto options = MTLResourceStorageModeShared | MTLResourceCPUCacheModeWriteCombined; + if( @available( macOS 10.15, * ) ) + { + options |= MTLHazardTrackingModeUntracked; + } + m_pages[index] = [m_device newBufferWithLength:CONST_PAGE_SIZE options:options]; + m_pages[index].label = [NSString stringWithUTF8String:"Constant buffer"]; + m_pageContents[index] = static_cast( m_pages[index].contents ); } diff --git a/trinityal/metal/MetalWorkQueue.h b/trinityal/metal/MetalWorkQueue.h index 98474d37c..e6c8d29b6 100644 --- a/trinityal/metal/MetalWorkQueue.h +++ b/trinityal/metal/MetalWorkQueue.h @@ -13,29 +13,29 @@ namespace TrinityALImpl { - class MetalContext; - class Tr2PipelineStatsQueryAL; - class Tr2VertexLayoutAL; - class Tr2RtPipelineStateAL; - class Tr2RtShaderTableAL; - - - // Values below must be synchronized with (propagated to) ShaderCompiler/EffectCompilerMetal.cpp - // and TrinityALTest/Shaders.metal/MetalDefines.h (CBUFFER, SRV, UAV, UAVT). - // See https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf -#define METAL_MAX_BOUND_BUFFERS 31 +class MetalContext; +class Tr2PipelineStatsQueryAL; +class Tr2VertexLayoutAL; +class Tr2RtPipelineStateAL; +class Tr2RtShaderTableAL; + + +// Values below must be synchronized with (propagated to) ShaderCompiler/EffectCompilerMetal.cpp +// and TrinityALTest/Shaders.metal/MetalDefines.h (CBUFFER, SRV, UAV, UAVT). +// See https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf +#define METAL_MAX_BOUND_BUFFERS 31 #define METAL_MAX_BOUND_TEXTURES 31 // 31+ on iOS, 128 on macOS #define METAL_MAX_BOUND_SAMPLERS 16 // #define METAL_MAX_VERTEX_STREAMS 31 #define METAL_MAX_VERTEX_ATTRIBUTES 31 -#define METAL_MAX_RENDER_TARGETS 4 // Matches DX12 define (RENDER_TARGET_COUNT) +#define METAL_MAX_RENDER_TARGETS 4 // Matches DX12 define (RENDER_TARGET_COUNT) - // If you change any of those values all shaders must be recompiled. +// If you change any of those values all shaders must be recompiled. #define METAL_VERTEX_STREAM_BUFFER_OFFSET 0 #define METAL_VERTEX_STREAM_BUFFER_COUNT 4 #define METAL_VERTEX_STREAM_BUFFER_MASK 0b1111 // Must take into account the value of METAL_VERTEX_STREAM_BUFFER_OFFSET #define METAL_VERTEX_STREAM_DUMMY 3 -#define METAL_CONST_BUFFER_OFFSET (METAL_VERTEX_STREAM_BUFFER_OFFSET + METAL_VERTEX_STREAM_BUFFER_COUNT) +#define METAL_CONST_BUFFER_OFFSET ( METAL_VERTEX_STREAM_BUFFER_OFFSET + METAL_VERTEX_STREAM_BUFFER_COUNT ) #define METAL_CONST_BUFFER_COUNT 20 // #define METAL_SRV_BUFFER_OFFSET (METAL_CONST_BUFFER_OFFSET + METAL_CONST_BUFFER_COUNT) #define METAL_SRV_BUFFER_OFFSET 0 @@ -51,493 +51,521 @@ namespace TrinityALImpl // 8 (depth compare functions) * 2 (depth on / off) + 1 (temporary state) #define METAL_DEPTHSTENCIL_CACHE_SIZE 17 - enum MetalEncoderType - { - MTLENCODERTYPE_NONE, - MTLENCODERTYPE_RENDER, - MTLENCODERTYPE_COMPUTE, - MTLENCODERTYPE_BLIT, - MTLENCODERTYPE_ACCELERATION_STRUCTURE - }; +enum MetalEncoderType +{ + MTLENCODERTYPE_NONE, + MTLENCODERTYPE_RENDER, + MTLENCODERTYPE_COMPUTE, + MTLENCODERTYPE_BLIT, + MTLENCODERTYPE_ACCELERATION_STRUCTURE +}; + +enum MetalWorkQueueType +{ + METALWORKQUEUE_INVALID = -1, + METALWORKQUEUE_RENDER = 0, - enum MetalWorkQueueType - { - METALWORKQUEUE_INVALID = -1, - METALWORKQUEUE_RENDER = 0, + METALWORKQUEUE_MAX = 1, // This should always be last +}; - METALWORKQUEUE_MAX = 1, // This should always be last - }; +enum MetalCBCommitFlags +{ + MTLCBCOMMIT_NOFLAGS = 0x0, + MTLCBCOMMIT_WAITUNTILSCHEDULED = 0x1, + MTLCBCOMMIT_WAITUNTILCOMPLETE = 0x2, + MTLCBCOMMIT_PRESENTDRAWABLE = 0x4, +}; - enum MetalCBCommitFlags - { - MTLCBCOMMIT_NOFLAGS = 0x0, - MTLCBCOMMIT_WAITUNTILSCHEDULED = 0x1, - MTLCBCOMMIT_WAITUNTILCOMPLETE = 0x2, - MTLCBCOMMIT_PRESENTDRAWABLE = 0x4, - }; +enum MetalRenderEncoderDirtyState : uint32_t +{ + METAL_RENDERENCODERDIRTYSTATE_NONE = 0u, + METAL_RENDERENCODERDIRTYSTATE_CULLMODE = 1u << 0, + METAL_RENDERENCODERDIRTYSTATE_VIEWPORT = 1u << 1, + METAL_RENDERENCODERDIRTYSTATE_BLENDCOLOR = 1u << 2, + METAL_RENDERENCODERDIRTYSTATE_DEPTHBIAS = 1u << 3, + METAL_RENDERENCODERDIRTYSTATE_DEPTHSTENCILSTATE = 1u << 4, + METAL_RENDERENCODERDIRTYSTATE_VERTEXDESCRIPTOR = 1u << 5, + METAL_RENDERENCODERDIRTYSTATE_ATTACHMENTS = 1u << 6, + METAL_RENDERENCODERDIRTYSTATE_FILLMODE = 1u << 7, + METAL_RENDERENCODERDIRTYSTATE_DEPTHCLIP = 1u << 8, + + METAL_RENDERENCODERDIRTYSTATE_ALL = 0b0111111111u +}; + +enum MetalBlendType +{ + METAL_BLENDING_DISABLED, + METAL_BLENDING_ENABLED, + METAL_BLENDING_ENABLED_SEPARATE_ALPHA +}; - enum MetalRenderEncoderDirtyState : uint32_t - { - METAL_RENDERENCODERDIRTYSTATE_NONE = 0u, - METAL_RENDERENCODERDIRTYSTATE_CULLMODE = 1u << 0, - METAL_RENDERENCODERDIRTYSTATE_VIEWPORT = 1u << 1, - METAL_RENDERENCODERDIRTYSTATE_BLENDCOLOR = 1u << 2, - METAL_RENDERENCODERDIRTYSTATE_DEPTHBIAS = 1u << 3, - METAL_RENDERENCODERDIRTYSTATE_DEPTHSTENCILSTATE = 1u << 4, - METAL_RENDERENCODERDIRTYSTATE_VERTEXDESCRIPTOR = 1u << 5, - METAL_RENDERENCODERDIRTYSTATE_ATTACHMENTS = 1u << 6, - METAL_RENDERENCODERDIRTYSTATE_FILLMODE = 1u << 7, - METAL_RENDERENCODERDIRTYSTATE_DEPTHCLIP = 1u << 8, - - METAL_RENDERENCODERDIRTYSTATE_ALL = 0b0111111111u - }; +struct MetalDepthBias +{ + float depthBias; + float slopeScale; + float clamp; +}; + +struct MetalBlendState +{ + MetalBlendType blendType; + bool alphaCoverageEnable; + MTLBlendOperation rgbBlendOp; + MTLBlendOperation alphaBlendOp; + MTLBlendFactor srcColorFactor; + MTLBlendFactor destColorFactor; + MTLBlendFactor srcAlphaFactor; + MTLBlendFactor destAlphaFactor; + MetalColor blendColor; + MTLColorWriteMask writeMask; + size_t hashValue; +}; + +struct MetalClearState +{ + MTLLoadAction colorLoadAction[METAL_MAX_RENDER_TARGETS]; + MTLStoreAction colorStoreAction[METAL_MAX_RENDER_TARGETS]; + MTLClearColor clearColorValue[METAL_MAX_RENDER_TARGETS]; + + MTLLoadAction depthLoadAction; + MTLStoreAction depthStoreAction; + float clearDepthValue; + + MTLLoadAction stencilLoadAction; + MTLStoreAction stencilStoreAction; + uint32_t clearStencilValue; +}; - enum MetalBlendType +struct ShaderResourceMask +{ + uint32_t constantBufferMask; + uint32_t bufferMask; + uint32_t textureMask; + uint32_t samplerMask; + uint8_t textureTypes[METAL_MAX_BOUND_TEXTURES]; + + void ResetMasks() { - METAL_BLENDING_DISABLED, - METAL_BLENDING_ENABLED, - METAL_BLENDING_ENABLED_SEPARATE_ALPHA - }; + constantBufferMask = 0; + bufferMask = 0; + textureMask = 0; + samplerMask = 0; + } +}; + +struct MetalRenderPassHint +{ + struct DepthAttachment + { + MTLLoadAction load; + MTLStoreAction store; + float clearValue; + } depth; - struct MetalDepthBias + struct ColorAttachment { - float depthBias; - float slopeScale; - float clamp; - }; + MTLLoadAction load; + MTLStoreAction store; + MTLClearColor clearColor; + } color[METAL_MAX_RENDER_TARGETS]; +}; - struct MetalBlendState +class MetalWorkQueue +{ +public: + MetalWorkQueue(); + ~MetalWorkQueue(); + void SetMetalContext( MetalContext* metalContext ); + void SetCommandQueue( id commandQueue ); + + void CommitCommandBuffer( MetalCBCommitFlags flags ); + bool BlitToDrawableAndPresent( id srcTexture, NSView* view, uint64_t* renderedFrameNumber ); + void BeginFrame(); + void EndFrame(); + void EndCurrentRenderPass(); + void RenderTargetBarrier(); + + id GetBlitEncoder( NSString* encoderLabel = nil ); + id GetComputeEncoder( NSString* encoderLabel = nil ); + id GetRenderEncoder( NSString* encoderLabel = nil ); + id GetParallelEncoder( NSString* encoderLabel = nil ); + API_AVAILABLE( macos( 11.0 ) ) + id GetAccelerationStructureEncoder( NSString* encoderLabel = nil ); + + void EndEncoder(); + void ReleaseEncoder( bool endEncoding ); + + void CopyDataToBuffer( id buffer, const void* data, size_t offset, size_t sizeInBytes ); + void CopyBufferToBuffer( id dest, size_t destOffset, id src, size_t srcOffset, size_t size ); + void ReadBackBufferToCPU( id buffer, bool waitForData ); + + void CopyTextureToMTLBuffer( id texture, + id destBuffer, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + MTLOrigin origin, + MTLSize size, + uint32_t mipLevel, + bool waitForData ); + + void CopyTextureToTexture( id srcTexture, + uint32_t srcSlice, + uint32_t srcMip, + MTLOrigin srcOrigin, + MTLSize srcSize, + id dstTexture, + uint32_t dstSlice, + uint32_t dstMip, + MTLOrigin dstOrigin ); + + void UploadTexture( id texture, + id srcBuffer, + uint32_t slice, + uint32_t mip, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ); + void UploadTexture( id texture, + const void* srcData, + uint32_t slice, + uint32_t mip, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ); + void UploadTexture( id texture, + id srcBuffer, + uint32_t slice, + uint32_t mip, + const MTLOrigin& origin, + const MTLSize& size, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ); + void GenerateMipMaps( id texture ); + + void ClearBuffer( id buffer, const float values[4] ); + void ClearBuffer( id buffer, const uint32_t values[4] ); + void ClearTexture( id texture, uint32_t mipLevel, const float values[4] ); + void ClearTexture( id texture, uint32_t mipLevel, const uint32_t values[4] ); + + void ResolveMsaa( id source, id destination ); + + void SetVertexDescriptor( MTLVertexDescriptor& vertexDescriptor ); + void SetShaders( id vertexFunction, + id fragmentFunction, + id computeFunction, + MTLSize threadGroupSize, + const ShaderResourceMask* resourceMasks ); + + void SetViewport( float originX, float originY, float width, float height, float znear, float zfar ); + void SetCullMode( MTLCullMode cullMode ); + void SetFillMode( MTLTriangleFillMode fillMode ); + void SetDepthBias( float* depthBias, float* slopeScale, float* clamp ); + void SetDepthClipEnable( bool enable ); + void SetBlendColor( uint32_t attachmentIndex, uint32_t blendColor ); + void SetSrcBlend( uint32_t attachmentIndex, MTLBlendFactor factor ); + void SetDestBlend( uint32_t attachmentIndex, MTLBlendFactor factor ); + void SetSrcBlendAlpha( uint32_t attachmentIndex, MTLBlendFactor factor ); + void SetDestBlendAlpha( uint32_t attachmentIndex, MTLBlendFactor factor ); + void SetBlendOp( uint32_t attachmentIndex, MTLBlendOperation op ); + void SetBlendOpAlpha( uint32_t attachmentIndex, MTLBlendOperation op ); + void SetBlendType( uint32_t attachmentIndex, MetalBlendType blendType ); + void SetColorWriteMask( uint32_t attachmentIndex, MTLColorWriteMask writeMask ); + void SetDepthState( bool enabled ); + void SetDepthCompareFn( MTLCompareFunction fn ); + void SetStencilState( bool enabled ); + void SetStencilDepthFailOp( MTLStencilOperation op ); + void SetStencilFailOp( MTLStencilOperation op ); + void SetStencilPassOp( MTLStencilOperation op ); + void SetStencilCompareFn( MTLCompareFunction fn ); + void SetStencilRefValue( uint32_t value ); + void SetStencilMask( uint32_t mask ); + + void SetRenderAttachments( id texture, uint32_t index, uint32_t slice = 0 ); + void SetDepthStencilAttachment( id texture ); + + void RenderPassHint( const MetalRenderPassHint& hint ); + void EndRenderPassHint(); + + void SetConstants( Tr2RenderContextEnum::ShaderType shaderType, + const void* constantBuffer, + uint32_t size, + ConstantBufferToken& token, + uint32_t constantIndex ); + void UploadConstants( const void* constantBuffer, uint32_t size, ConstantBufferToken& token ); + + void SetBuffers( Tr2RenderContextEnum::ShaderType shaderType, + const id* buffers, + uint32_t buffersMask, + id heapView, + uint32_t heapViewMask ); + void SetTextures( Tr2RenderContextEnum::ShaderType shaderType, + const id* textures, + NSRange texturesRange ); + void SetSamplers( Tr2RenderContextEnum::ShaderType shaderType, + const id* samplers, + NSRange samplersRange ); + void ResetBuffers( Tr2RenderContextEnum::ShaderType shaderType ); + void ResetTextures( Tr2RenderContextEnum::ShaderType shaderType ); + void ResetSamplers( Tr2RenderContextEnum::ShaderType shaderType ); + + void SetVertexStream( uint32 stream, id buffer, uint32 stride, uint32 offset ); + void SetCurrentVertexDescriptor( MTLVertexDescriptor* vertexDescriptor, uint8_t vertexStreamMask, size_t baseHash ); + + void ClearAttachment( MTLClearColor* clearColor, + float* clearDepth, + uint32_t* clearStencil, + uint32_t attachmentIndex ); + + void DrawPrimitives( MTLPrimitiveType primitiveType, + uint32_t numVertices, + uint32_t startVertex, + uint32_t numInstances, + uint32_t startInstance = 0 ); + void DrawPrimitives( MTLPrimitiveType primitiveType, id indirectBuffer, uint32_t indirectBufferOffset ); + + void DrawIndexedPrimitives( MTLPrimitiveType primitiveType, + uint32_t numIndices, + MTLIndexType indexType, + id indexBuffer, + uint32_t startIndex, + uint32_t numInstances, + int32_t baseVertex = 0, + uint32_t baseInstance = 0 ); + void DrawIndexedPrimitives( MTLPrimitiveType primitiveType, + MTLIndexType indexType, + id indexBuffer, + uint32_t indexBufferOffset, + id indirectBuffer, + uint32_t indirectBufferOffset ); + + void Dispatch( uint32_t groupDimX, uint32_t groupDimY, uint32_t groupDimZ ); + void Dispatch( id indirectBuffer, uint32_t indirectBufferOffset ); + API_AVAILABLE( macos( 11.0 ) ) + void DispatchRays( Tr2RtPipelineStateAL* pipeline, + Tr2RtShaderTableAL* shaderTable, + uint32_t rayGenIndex, + uint32_t width, + uint32_t height, + uint32_t depth ); + + void CreateVisibilityQueryBuffer( uint64_t maxNumQueries ); + uint64_t StartVisibilityQuery(); + void EndVisibilityQuery( uint64_t queryNumber ); + bool GetVisibilityQueryPixelCount( uint64_t queryNumber, uint64_t* pixelCount, bool finishOutstandingWork ); + + enum CounterType { - MetalBlendType blendType; - bool alphaCoverageEnable; - MTLBlendOperation rgbBlendOp; - MTLBlendOperation alphaBlendOp; - MTLBlendFactor srcColorFactor; - MTLBlendFactor destColorFactor; - MTLBlendFactor srcAlphaFactor; - MTLBlendFactor destAlphaFactor; - MetalColor blendColor; - MTLColorWriteMask writeMask; - size_t hashValue; + COUNTER_TIMER, + COUNTER_PIPELINE_STATS, }; + bool SampleCounter( id buffer, NSUInteger index, CounterType counter ); - struct MetalClearState - { - MTLLoadAction colorLoadAction[METAL_MAX_RENDER_TARGETS]; - MTLStoreAction colorStoreAction[METAL_MAX_RENDER_TARGETS]; - MTLClearColor clearColorValue[METAL_MAX_RENDER_TARGETS]; + void PushDebugGroup( const char* name ); + void PopDebugGroup(); + + void BeginParallelEncoding( MetalWorkQueue* primaryQueue ); + void EndParallelEncoding(); + + bool CanBeginParallelEncoding() const; + + void PipelineQueryStarted( Tr2PipelineStatsQueryAL* query ); + void PipelineQueryEnded( Tr2PipelineStatsQueryAL* query ); - MTLLoadAction depthLoadAction; - MTLStoreAction depthStoreAction; - float clearDepthValue; + MTLVertexDescriptor* GetCachedVertexDescriptor( Tr2VertexLayoutAL* layout, + size_t inputHash, + uint8_t& streamMask, + bool& needsDummyStream ) const; + void CacheVertexDescriptor( Tr2VertexLayoutAL* layout, + size_t inputHash, + MTLVertexDescriptor* descriptor, + uint8_t streamMask, + bool needsDummyStream ); + void FlushCachedVertexDescriptors(); - MTLLoadAction stencilLoadAction; - MTLStoreAction stencilStoreAction; - uint32_t clearStencilValue; + id GetCommandBuffer() + { + return m_commandBuffer; + } + + bool EmitRenderEncoderState(); + + uint64_t GetCurrentEncoderIndex() const; + void MarkConstantBuffersDirty(); + bool IsSilicon() const; + +private: + void CreateClearFunctions(); + void ResetWorkQueue(); + void ResetFrame(); + void ResetClearState(); + void InitRenderPassDescriptor(); + void CreateCommandBuffer(); + void FlushOutstandingOperations(); + void SetCurrentEncoder( MetalEncoderType encoderType, NSString* encoderLabel = nil ); + void SetupVertexDescriptors(); + bool EmitRenderPipelineState(); + bool EmitComputePipelineState(); + bool EmitComputeEncoderState(); + void SetVertexBufferBindings(); + void SetFragmentBufferBindings(); + void SetComputeBufferBindings(); + void SetupPresentBlitResources(); + ConstantBufferAllocator::Entry UploadArgumentBuffer( const Tr2ShaderSignatureAL& signature, + std::vector>& readResources, + std::vector>& writeResources ) const; + + size_t CalculateVertexDescriptorHash(); + size_t CalculateAttachmentsHash(); + + void SetRenderTargetSizedScissorRect(); + + id GetCachedDepthStencilState( MTLDepthStencilDescriptor* descriptor ); + void ApplyRenderPassHint(); + void SetRenderStatesDirty(); + + MetalContext* m_context; + bool m_isPrimary; + + id m_commandQueue; + id m_device; + id m_commandBuffer; + + MetalEncoderType m_currentEncoderType; + id m_currentBlitEncoder; + id m_currentRenderEncoder; + id m_currentParallelEncoder; + id m_currentComputeEncoder; + API_AVAILABLE( macos( 11.0 ) ) + id m_currentAccelerationStructureEncoder; + MTLRenderPipelineDescriptor* m_presentBlitPipelineDesciptor; + id m_presentBlitPipeline; + MTLRenderPassDescriptor* m_drawRenderPassDescriptor; + MTLRenderPassDescriptor* m_blitAndPresentRenderPassDescriptor; + + MTLRenderPassDescriptor* m_currentRenderPassDescriptor; + + id m_captureScopeFullFrame; + + uint64_t m_encoderIndex; + + uint32_t m_numRenderAttachments; + uint32_t m_dirtyRenderEncoderState; + uint32_t m_numCommands; + bool m_encoderInUse; + bool m_encoderEnded; + bool m_encoderHasWork; + bool m_generatesEndOfQueueEvent; + bool m_isIntelGpu; + bool m_isAppleSilicon; + + MTLViewport m_viewport; + MTLScissorRect m_scissorRect; + bool m_validViewport; + MTLCullMode m_cullMode; + MTLTriangleFillMode m_fillMode; + MetalDepthBias m_depthBias; + MetalBlendState m_blendState[METAL_MAX_RENDER_TARGETS]; + MTLDepthClipMode m_depthClipMode; + MTLDepthStencilDescriptor* m_depthStencilDescriptor; + MTLStencilDescriptor* m_frontFaceStencilDescriptor; + MTLStencilDescriptor* m_backFaceStencilDescriptor; + uint32_t m_stencilReferenceValue; + + // These should come from the attachment direectly + MTLPixelFormat m_outputPixelFormat; + MTLPixelFormat m_outputDepthFormat; + + MTLRenderPipelineColorAttachmentDescriptor* m_renderPipelineColorAttachmentDescriptor; + MTLRenderPipelineDescriptor* m_renderPipelineDescriptor; + + size_t m_currentVertexDescriptorHash; + size_t m_currentAttachmentsHash; + size_t m_currentRenderPipelineDescriptorHash; + size_t m_currentComputePipelineDescriptorHash; + size_t m_currentDepthStencilDescriptorHash; + + id m_currentRenderPipelineState; + id m_currentComputePipelineState; + id m_currentDepthStencilState; + + id m_depthStencilStateCache[METAL_DEPTHSTENCIL_CACHE_SIZE]; + + id m_vertexFunction; + id m_fragmentFunction; + id m_computeFunction; + id m_clearBufferComputeFunctions[2]; + id m_clearTextureComputeFunctions[2]; + MTLSize m_threadGroupSize; + const ShaderResourceMask* m_shaderResourceMasks; + + id m_drawable; + + struct MetalBuffer + { + id buffer; + NSUInteger offset; }; - struct ShaderResourceMask + struct ConstantBuffer { - uint32_t constantBufferMask; - uint32_t bufferMask; - uint32_t textureMask; - uint32_t samplerMask; - uint8_t textureTypes[METAL_MAX_BOUND_TEXTURES]; - - void ResetMasks() - { - constantBufferMask = 0; - bufferMask = 0; - textureMask = 0; - samplerMask = 0; - } + uint32_t page; + uint32_t offset; }; - - struct MetalRenderPassHint + + ConstantBuffer m_constBuffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_BUFFERS]; + MetalBuffer m_buffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_BUFFERS]; + id m_textures[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_TEXTURES]; + id m_samplers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_SAMPLERS]; + + uint32_t m_activeConstBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_activeBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_dirtyConstBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_dirtyConstBufferPageMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_dirtyBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_dirtyTexturesMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_dirtySamplersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + + struct VertexStream { - struct DepthAttachment - { - MTLLoadAction load; - MTLStoreAction store; - float clearValue; - } depth; - - struct ColorAttachment - { - MTLLoadAction load; - MTLStoreAction store; - MTLClearColor clearColor; - } color[METAL_MAX_RENDER_TARGETS]; + uint32_t stride; }; + VertexStream m_boundVertexStreams[METAL_VERTEX_STREAM_BUFFER_COUNT]; + MTLVertexDescriptor* m_currentVertexDescriptor; + uint8_t m_currentVertexStreamMask; + size_t m_currentVertexDescriptorBaseHash; - class MetalWorkQueue + + MetalRenderPassHint m_pendingRenderPassHint; + bool m_hasPendingRenderPassHint; + bool m_hasPendingRenderTargetBarrier; + + bool m_pendingClear; + bool m_visibilityQueryInProgress; + MetalClearState m_clearState; + id m_visibilityBuffer; + uint64_t m_maxVisibilityQueries; + uint64_t m_currentVisibilityQueryIndex; + uint64_t m_numCompletedVisibilityQueries; + uint64_t m_visibilityQueriesInThisEncoder; + + std::vector m_pipelineQueriesInProgress; + + struct CachedVertexLayout { - public: - MetalWorkQueue(); - ~MetalWorkQueue(); - void SetMetalContext( MetalContext* metalContext ); - void SetCommandQueue(id commandQueue); - - void CommitCommandBuffer( MetalCBCommitFlags flags ); - bool BlitToDrawableAndPresent( id srcTexture, NSView* view, uint64_t* renderedFrameNumber ); - void BeginFrame(); - void EndFrame(); - void EndCurrentRenderPass(); - void RenderTargetBarrier(); - - id GetBlitEncoder( NSString *encoderLabel = nil ); - id GetComputeEncoder( NSString *encoderLabel = nil ); - id GetRenderEncoder( NSString *encoderLabel = nil ); - id GetParallelEncoder( NSString *encoderLabel = nil ); - API_AVAILABLE(macos(11.0)) - id GetAccelerationStructureEncoder( NSString *encoderLabel = nil ); - - void EndEncoder(); - void ReleaseEncoder( bool endEncoding ); - - void CopyDataToBuffer( id buffer, const void *data, size_t offset, size_t sizeInBytes ); - void CopyBufferToBuffer( id dest, size_t destOffset, id src, size_t srcOffset, size_t size ); - void ReadBackBufferToCPU( id buffer, bool waitForData ); - - void CopyTextureToMTLBuffer(id texture, - id destBuffer, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - MTLOrigin origin, - MTLSize size, - uint32_t mipLevel, - bool waitForData); - - void CopyTextureToTexture( - id srcTexture, - uint32_t srcSlice, - uint32_t srcMip, - MTLOrigin srcOrigin, - MTLSize srcSize, - id dstTexture, - uint32_t dstSlice, - uint32_t dstMip, - MTLOrigin dstOrigin); - - void UploadTexture(id texture, - id srcBuffer, - uint32_t slice, - uint32_t mip, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer); - void UploadTexture(id texture, - const void *srcData, - uint32_t slice, - uint32_t mip, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer); - void UploadTexture(id texture, - id srcBuffer, - uint32_t slice, - uint32_t mip, - const MTLOrigin& origin, - const MTLSize& size, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer); - void GenerateMipMaps(id texture); - - void ClearBuffer( id buffer, const float values[4] ); - void ClearBuffer( id buffer, const uint32_t values[4]); - void ClearTexture( id texture, uint32_t mipLevel, const float values[4]); - void ClearTexture( id texture, uint32_t mipLevel, const uint32_t values[4]); - - void ResolveMsaa(id source, id destination); - - void SetVertexDescriptor(MTLVertexDescriptor &vertexDescriptor); - void SetShaders( - id vertexFunction, - id fragmentFunction, - id computeFunction, - MTLSize threadGroupSize, - const ShaderResourceMask* resourceMasks ); - - void SetViewport( float originX, float originY, float width, float height, float znear, float zfar ); - void SetCullMode( MTLCullMode cullMode ); - void SetFillMode( MTLTriangleFillMode fillMode ); - void SetDepthBias( float *depthBias, float *slopeScale, float *clamp ); - void SetDepthClipEnable( bool enable ); - void SetBlendColor( uint32_t attachmentIndex, uint32_t blendColor ); - void SetSrcBlend( uint32_t attachmentIndex, MTLBlendFactor factor ); - void SetDestBlend( uint32_t attachmentIndex, MTLBlendFactor factor ); - void SetSrcBlendAlpha( uint32_t attachmentIndex, MTLBlendFactor factor ); - void SetDestBlendAlpha( uint32_t attachmentIndex, MTLBlendFactor factor ); - void SetBlendOp( uint32_t attachmentIndex, MTLBlendOperation op ); - void SetBlendOpAlpha( uint32_t attachmentIndex, MTLBlendOperation op ); - void SetBlendType( uint32_t attachmentIndex, MetalBlendType blendType ); - void SetColorWriteMask( uint32_t attachmentIndex, MTLColorWriteMask writeMask ); - void SetDepthState( bool enabled ); - void SetDepthCompareFn( MTLCompareFunction fn ); - void SetStencilState( bool enabled ); - void SetStencilDepthFailOp( MTLStencilOperation op ); - void SetStencilFailOp( MTLStencilOperation op ); - void SetStencilPassOp( MTLStencilOperation op ); - void SetStencilCompareFn( MTLCompareFunction fn ); - void SetStencilRefValue( uint32_t value ); - void SetStencilMask( uint32_t mask ); - - void SetRenderAttachments( id texture, uint32_t index, uint32_t slice = 0 ); - void SetDepthStencilAttachment( id texture ); - - void RenderPassHint( const MetalRenderPassHint& hint ); - void EndRenderPassHint(); - - void SetConstants( Tr2RenderContextEnum::ShaderType shaderType, const void* constantBuffer, uint32_t size, ConstantBufferToken& token, uint32_t constantIndex ); - void UploadConstants( const void* constantBuffer, uint32_t size, ConstantBufferToken& token ); - - void SetBuffers( Tr2RenderContextEnum::ShaderType shaderType, const id* buffers, uint32_t buffersMask, id heapView, uint32_t heapViewMask ); - void SetTextures( Tr2RenderContextEnum::ShaderType shaderType, const id* textures, NSRange texturesRange ); - void SetSamplers( Tr2RenderContextEnum::ShaderType shaderType, const id* samplers, NSRange samplersRange ); - void ResetBuffers( Tr2RenderContextEnum::ShaderType shaderType ); - void ResetTextures( Tr2RenderContextEnum::ShaderType shaderType ); - void ResetSamplers( Tr2RenderContextEnum::ShaderType shaderType ); - - void SetVertexStream( uint32 stream, id buffer, uint32 stride, uint32 offset ); - void SetCurrentVertexDescriptor( MTLVertexDescriptor* vertexDescriptor, uint8_t vertexStreamMask, size_t baseHash ); - - void ClearAttachment( MTLClearColor *clearColor, float *clearDepth, uint32_t *clearStencil, uint32_t attachmentIndex ); - - void DrawPrimitives(MTLPrimitiveType primitiveType, - uint32_t numVertices, - uint32_t startVertex, - uint32_t numInstances, - uint32_t startInstance = 0 ); - void DrawPrimitives(MTLPrimitiveType primitiveType, - id indirectBuffer, - uint32_t indirectBufferOffset); - - void DrawIndexedPrimitives(MTLPrimitiveType primitiveType, - uint32_t numIndices, - MTLIndexType indexType, - id indexBuffer, - uint32_t startIndex, - uint32_t numInstances, - int32_t baseVertex = 0, - uint32_t baseInstance = 0 ); - void DrawIndexedPrimitives(MTLPrimitiveType primitiveType, - MTLIndexType indexType, - id indexBuffer, - uint32_t indexBufferOffset, - id indirectBuffer, - uint32_t indirectBufferOffset); - - void Dispatch( uint32_t groupDimX, uint32_t groupDimY, uint32_t groupDimZ ); - void Dispatch( id indirectBuffer, uint32_t indirectBufferOffset ); - API_AVAILABLE( macos(11.0) ) - void DispatchRays( Tr2RtPipelineStateAL* pipeline, Tr2RtShaderTableAL* shaderTable, uint32_t rayGenIndex, uint32_t width, uint32_t height, uint32_t depth ); - - void CreateVisibilityQueryBuffer(uint64_t maxNumQueries); - uint64_t StartVisibilityQuery(); - void EndVisibilityQuery(uint64_t queryNumber); - bool GetVisibilityQueryPixelCount(uint64_t queryNumber, uint64_t *pixelCount, bool finishOutstandingWork); - - enum CounterType - { - COUNTER_TIMER, - COUNTER_PIPELINE_STATS, - }; - bool SampleCounter( id buffer, NSUInteger index, CounterType counter ); - - void PushDebugGroup( const char* name ); - void PopDebugGroup(); - - void BeginParallelEncoding( MetalWorkQueue* primaryQueue ); - void EndParallelEncoding(); - - bool CanBeginParallelEncoding() const; - - void PipelineQueryStarted( Tr2PipelineStatsQueryAL* query ); - void PipelineQueryEnded( Tr2PipelineStatsQueryAL* query ); - - MTLVertexDescriptor* GetCachedVertexDescriptor( Tr2VertexLayoutAL* layout, size_t inputHash, uint8_t& streamMask, bool& needsDummyStream ) const; - void CacheVertexDescriptor( Tr2VertexLayoutAL* layout, size_t inputHash, MTLVertexDescriptor* descriptor, uint8_t streamMask, bool needsDummyStream ); - void FlushCachedVertexDescriptors(); - - id GetCommandBuffer() {return m_commandBuffer;} - - bool EmitRenderEncoderState(); - - uint64_t GetCurrentEncoderIndex() const; - void MarkConstantBuffersDirty(); - bool IsSilicon() const; - - private: - void CreateClearFunctions(); - void ResetWorkQueue(); - void ResetFrame(); - void ResetClearState(); - void InitRenderPassDescriptor(); - void CreateCommandBuffer(); - void FlushOutstandingOperations(); - void SetCurrentEncoder(MetalEncoderType encoderType, NSString *encoderLabel = nil); - void SetupVertexDescriptors(); - bool EmitRenderPipelineState(); - bool EmitComputePipelineState(); - bool EmitComputeEncoderState(); - void SetVertexBufferBindings(); - void SetFragmentBufferBindings(); - void SetComputeBufferBindings(); - void SetupPresentBlitResources(); - ConstantBufferAllocator::Entry UploadArgumentBuffer( const Tr2ShaderSignatureAL& signature, std::vector>& readResources, std::vector>& writeResources ) const; - - size_t CalculateVertexDescriptorHash(); - size_t CalculateAttachmentsHash(); - - void SetRenderTargetSizedScissorRect(); - - id GetCachedDepthStencilState( MTLDepthStencilDescriptor* descriptor ); - void ApplyRenderPassHint(); - void SetRenderStatesDirty(); - - MetalContext* m_context; - bool m_isPrimary; - - id m_commandQueue; - id m_device; - id m_commandBuffer; - - MetalEncoderType m_currentEncoderType; - id m_currentBlitEncoder; - id m_currentRenderEncoder; - id m_currentParallelEncoder; - id m_currentComputeEncoder; - API_AVAILABLE(macos(11.0)) - id m_currentAccelerationStructureEncoder; - MTLRenderPipelineDescriptor *m_presentBlitPipelineDesciptor; - id m_presentBlitPipeline; - MTLRenderPassDescriptor *m_drawRenderPassDescriptor; - MTLRenderPassDescriptor *m_blitAndPresentRenderPassDescriptor; - - MTLRenderPassDescriptor *m_currentRenderPassDescriptor; - - id m_captureScopeFullFrame; - - uint64_t m_encoderIndex; - - uint32_t m_numRenderAttachments; - uint32_t m_dirtyRenderEncoderState; - uint32_t m_numCommands; - bool m_encoderInUse; - bool m_encoderEnded; - bool m_encoderHasWork; - bool m_generatesEndOfQueueEvent; - bool m_isIntelGpu; - bool m_isAppleSilicon; - - MTLViewport m_viewport; - MTLScissorRect m_scissorRect; - bool m_validViewport; - MTLCullMode m_cullMode; - MTLTriangleFillMode m_fillMode; - MetalDepthBias m_depthBias; - MetalBlendState m_blendState[METAL_MAX_RENDER_TARGETS]; - MTLDepthClipMode m_depthClipMode; - MTLDepthStencilDescriptor *m_depthStencilDescriptor; - MTLStencilDescriptor *m_frontFaceStencilDescriptor; - MTLStencilDescriptor *m_backFaceStencilDescriptor; - uint32_t m_stencilReferenceValue; - - // These should come from the attachment direectly - MTLPixelFormat m_outputPixelFormat; - MTLPixelFormat m_outputDepthFormat; - - MTLRenderPipelineColorAttachmentDescriptor *m_renderPipelineColorAttachmentDescriptor; - MTLRenderPipelineDescriptor *m_renderPipelineDescriptor; - - size_t m_currentVertexDescriptorHash; - size_t m_currentAttachmentsHash; - size_t m_currentRenderPipelineDescriptorHash; - size_t m_currentComputePipelineDescriptorHash; - size_t m_currentDepthStencilDescriptorHash; - - id m_currentRenderPipelineState; - id m_currentComputePipelineState; - id m_currentDepthStencilState; - - id m_depthStencilStateCache[METAL_DEPTHSTENCIL_CACHE_SIZE]; - - id m_vertexFunction; - id m_fragmentFunction; - id m_computeFunction; - id m_clearBufferComputeFunctions[2]; - id m_clearTextureComputeFunctions[2]; - MTLSize m_threadGroupSize; - const ShaderResourceMask* m_shaderResourceMasks; - - id m_drawable; - - struct MetalBuffer - { - id buffer; - NSUInteger offset; - }; - - struct ConstantBuffer - { - uint32_t page; - uint32_t offset; - }; - - ConstantBuffer m_constBuffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_BUFFERS]; - MetalBuffer m_buffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_BUFFERS]; - id m_textures[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_TEXTURES]; - id m_samplers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][METAL_MAX_BOUND_SAMPLERS]; - - uint32_t m_activeConstBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_activeBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_dirtyConstBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_dirtyConstBufferPageMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_dirtyBuffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_dirtyTexturesMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_dirtySamplersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - - struct VertexStream - { - uint32_t stride; - }; - VertexStream m_boundVertexStreams[METAL_VERTEX_STREAM_BUFFER_COUNT]; - MTLVertexDescriptor *m_currentVertexDescriptor; - uint8_t m_currentVertexStreamMask; - size_t m_currentVertexDescriptorBaseHash; - - - MetalRenderPassHint m_pendingRenderPassHint; - bool m_hasPendingRenderPassHint; - bool m_hasPendingRenderTargetBarrier; - - bool m_pendingClear; - bool m_visibilityQueryInProgress; - MetalClearState m_clearState; - id m_visibilityBuffer; - uint64_t m_maxVisibilityQueries; - uint64_t m_currentVisibilityQueryIndex; - uint64_t m_numCompletedVisibilityQueries; - uint64_t m_visibilityQueriesInThisEncoder; - - std::vector m_pipelineQueriesInProgress; - - struct CachedVertexLayout - { - Tr2VertexLayoutAL* layout; - size_t inputHash; - MTLVertexDescriptor* descriptor; - uint8_t streamMask; - bool needsDummyStream; - }; - std::vector m_cachedVertexLayouts; - - dispatch_semaphore_t m_frameSemaphore; + Tr2VertexLayoutAL* layout; + size_t inputHash; + MTLVertexDescriptor* descriptor; + uint8_t streamMask; + bool needsDummyStream; }; + std::vector m_cachedVertexLayouts; + + dispatch_semaphore_t m_frameSemaphore; +}; } // namespace TrinityALImpl diff --git a/trinityal/metal/MetalWorkQueue.mm b/trinityal/metal/MetalWorkQueue.mm index ba153b187..8b6706bbe 100644 --- a/trinityal/metal/MetalWorkQueue.mm +++ b/trinityal/metal/MetalWorkQueue.mm @@ -29,69 +29,75 @@ namespace TrinityALImpl { -MetalWorkQueue::MetalWorkQueue() - : m_numRenderAttachments( 0 ) - , m_isPrimary( true ) - , m_dirtyRenderEncoderState( METAL_RENDERENCODERDIRTYSTATE_ALL ) - , m_numCommands( 0 ) - , m_encoderIndex( 1 ) - , m_encoderInUse( false ) - , m_encoderEnded( false ) - , m_encoderHasWork( false ) - , m_generatesEndOfQueueEvent( false ) - , m_isIntelGpu( false ) - , m_isAppleSilicon( false ) - , m_viewport( MTLViewport{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f} ) - , m_scissorRect( MTLScissorRect{0, 0, 0, 0} ) - , m_validViewport( false ) - , m_cullMode( MTLCullModeNone ) - , m_fillMode( MTLTriangleFillModeFill ) - , m_depthBias( MetalDepthBias{0.0f, 0.0f, FLT_MAX} ) - , m_depthClipMode( MTLDepthClipModeClip ) - , m_stencilReferenceValue( 0 ) - , m_outputPixelFormat( MTLPixelFormatInvalid ) - , m_outputDepthFormat( MTLPixelFormatInvalid ) - , m_currentVertexDescriptorHash( 0 ) - , m_currentAttachmentsHash( 0 ) - , m_currentRenderPipelineDescriptorHash( 0 ) - , m_currentComputePipelineDescriptorHash( 0 ) - , m_currentDepthStencilDescriptorHash( 0 ) - , m_threadGroupSize( MTLSizeMake( 1, 1, 1 ) ) - , m_shaderResourceMasks( nullptr ) - , m_currentVertexDescriptor( nil ) - , m_currentVertexStreamMask( 0 ) - , m_currentVertexDescriptorBaseHash( 0 ) - , m_hasPendingRenderPassHint( false ) - , m_hasPendingRenderTargetBarrier( false ) - , m_pendingClear( false ) - , m_visibilityQueryInProgress( false ) -{ - static_assert( sizeof( m_activeConstBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, "Mask data type is too small to hold all flags." ); - static_assert( sizeof( m_activeBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, "Mask data type is too small to hold all flags." ); - - static_assert( sizeof( m_dirtyConstBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, "Mask data type is too small to hold all buffer flags." ); - static_assert( sizeof( m_dirtyBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, "Mask data type is too small to hold all buffer flags." ); - static_assert( sizeof( m_dirtyTexturesMask[0] ) * 8 >= METAL_MAX_BOUND_TEXTURES, "Mask data type is too small to hold all texture flags." ); - static_assert( sizeof( m_dirtySamplersMask[0] ) * 8 >= METAL_MAX_BOUND_SAMPLERS, "Mask data type is too small to hold all sampler flags." ); +MetalWorkQueue::MetalWorkQueue() : + m_numRenderAttachments( 0 ), + m_isPrimary( true ), + m_dirtyRenderEncoderState( METAL_RENDERENCODERDIRTYSTATE_ALL ), + m_numCommands( 0 ), + m_encoderIndex( 1 ), + m_encoderInUse( false ), + m_encoderEnded( false ), + m_encoderHasWork( false ), + m_generatesEndOfQueueEvent( false ), + m_isIntelGpu( false ), + m_isAppleSilicon( false ), + m_viewport( MTLViewport{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } ), + m_scissorRect( MTLScissorRect{ 0, 0, 0, 0 } ), + m_validViewport( false ), + m_cullMode( MTLCullModeNone ), + m_fillMode( MTLTriangleFillModeFill ), + m_depthBias( MetalDepthBias{ 0.0f, 0.0f, FLT_MAX } ), + m_depthClipMode( MTLDepthClipModeClip ), + m_stencilReferenceValue( 0 ), + m_outputPixelFormat( MTLPixelFormatInvalid ), + m_outputDepthFormat( MTLPixelFormatInvalid ), + m_currentVertexDescriptorHash( 0 ), + m_currentAttachmentsHash( 0 ), + m_currentRenderPipelineDescriptorHash( 0 ), + m_currentComputePipelineDescriptorHash( 0 ), + m_currentDepthStencilDescriptorHash( 0 ), + m_threadGroupSize( MTLSizeMake( 1, 1, 1 ) ), + m_shaderResourceMasks( nullptr ), + m_currentVertexDescriptor( nil ), + m_currentVertexStreamMask( 0 ), + m_currentVertexDescriptorBaseHash( 0 ), + m_hasPendingRenderPassHint( false ), + m_hasPendingRenderTargetBarrier( false ), + m_pendingClear( false ), + m_visibilityQueryInProgress( false ) +{ + static_assert( sizeof( m_activeConstBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Mask data type is too small to hold all flags." ); + static_assert( sizeof( m_activeBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Mask data type is too small to hold all flags." ); + + static_assert( sizeof( m_dirtyConstBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Mask data type is too small to hold all buffer flags." ); + static_assert( sizeof( m_dirtyBuffersMask[0] ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Mask data type is too small to hold all buffer flags." ); + static_assert( sizeof( m_dirtyTexturesMask[0] ) * 8 >= METAL_MAX_BOUND_TEXTURES, + "Mask data type is too small to hold all texture flags." ); + static_assert( sizeof( m_dirtySamplersMask[0] ) * 8 >= METAL_MAX_BOUND_SAMPLERS, + "Mask data type is too small to hold all sampler flags." ); for( uint32_t i = 0; i < METAL_MAX_RENDER_TARGETS; ++i ) { - m_blendState[i].blendType = METAL_BLENDING_DISABLED; + m_blendState[i].blendType = METAL_BLENDING_DISABLED; m_blendState[i].alphaCoverageEnable = false; - m_blendState[i].rgbBlendOp = MTLBlendOperationAdd; - m_blendState[i].alphaBlendOp = MTLBlendOperationAdd; - m_blendState[i].srcColorFactor = MTLBlendFactorOne; - m_blendState[i].destColorFactor = MTLBlendFactorZero; - m_blendState[i].srcAlphaFactor = MTLBlendFactorOne; - m_blendState[i].destAlphaFactor = MTLBlendFactorZero; - m_blendState[i].blendColor = MetalColor{0.0f, 0.0f, 0.0f, 0.0f}; - m_blendState[i].writeMask = MTLColorWriteMaskAll; - } - - m_frameSemaphore = dispatch_semaphore_create( 2 ); + m_blendState[i].rgbBlendOp = MTLBlendOperationAdd; + m_blendState[i].alphaBlendOp = MTLBlendOperationAdd; + m_blendState[i].srcColorFactor = MTLBlendFactorOne; + m_blendState[i].destColorFactor = MTLBlendFactorZero; + m_blendState[i].srcAlphaFactor = MTLBlendFactorOne; + m_blendState[i].destAlphaFactor = MTLBlendFactorZero; + m_blendState[i].blendColor = MetalColor{ 0.0f, 0.0f, 0.0f, 0.0f }; + m_blendState[i].writeMask = MTLColorWriteMaskAll; + } + + m_frameSemaphore = dispatch_semaphore_create( 2 ); m_depthStencilDescriptor = [MTLDepthStencilDescriptor new]; - m_depthStencilDescriptor.depthWriteEnabled = false; + m_depthStencilDescriptor.depthWriteEnabled = false; m_depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionLessEqual; for( int i = 0; i < METAL_DEPTHSTENCIL_CACHE_SIZE; ++i ) @@ -116,9 +122,9 @@ m_clearState.clearStencilValue = 0; #endif - m_frontFaceStencilDescriptor = [[MTLStencilDescriptor alloc] init]; - m_backFaceStencilDescriptor = [[MTLStencilDescriptor alloc] init]; - m_drawRenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init]; + m_frontFaceStencilDescriptor = [[MTLStencilDescriptor alloc] init]; + m_backFaceStencilDescriptor = [[MTLStencilDescriptor alloc] init]; + m_drawRenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init]; m_blitAndPresentRenderPassDescriptor = [[MTLRenderPassDescriptor alloc] init]; for( int i = 0; i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) @@ -139,16 +145,16 @@ m_computeFunction = nil; m_shaderResourceMasks = nullptr; - m_clearBufferComputeFunctions[0] = nil; - m_clearBufferComputeFunctions[1] = nil; + m_clearBufferComputeFunctions[0] = nil; + m_clearBufferComputeFunctions[1] = nil; m_clearTextureComputeFunctions[0] = nil; m_clearTextureComputeFunctions[1] = nil; - m_visibilityBuffer = nil; - m_maxVisibilityQueries = 0; - m_currentVisibilityQueryIndex = 0; + m_visibilityBuffer = nil; + m_maxVisibilityQueries = 0; + m_currentVisibilityQueryIndex = 0; m_numCompletedVisibilityQueries = 0; - m_visibilityQueryInProgress = false; + m_visibilityQueryInProgress = false; ResetFrame(); ResetWorkQueue(); @@ -156,7 +162,7 @@ MetalWorkQueue::~MetalWorkQueue() { - METAL_LOG(@"Log:~MetalWorkQueue()"); + METAL_LOG( @"Log:~MetalWorkQueue()" ); // Flush all outstanding work and wait until it's done. if( m_commandBuffer ) @@ -166,12 +172,12 @@ // Release and terminate the current encoder. ReleaseEncoder( true ); } - + [m_commandBuffer commit]; [m_commandBuffer waitUntilCompleted]; } -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [m_depthStencilDescriptor release]; [m_frontFaceStencilDescriptor release]; [m_backFaceStencilDescriptor release]; @@ -202,33 +208,33 @@ void MetalWorkQueue::InitRenderPassDescriptor() { CCP_ASSERT( m_isPrimary ); - + METAL_LOG( @"Log:InitRenderPassDescriptor" ); for( int i = 0; i < METAL_MAX_RENDER_TARGETS; i++ ) { - m_drawRenderPassDescriptor.colorAttachments[i].clearColor = MTLClearColorMake( 0.0f, 0.0f, 0.0f, 0.0f ); - m_drawRenderPassDescriptor.colorAttachments[i].loadAction = MTLLoadActionDontCare; + m_drawRenderPassDescriptor.colorAttachments[i].clearColor = MTLClearColorMake( 0.0f, 0.0f, 0.0f, 0.0f ); + m_drawRenderPassDescriptor.colorAttachments[i].loadAction = MTLLoadActionDontCare; m_drawRenderPassDescriptor.colorAttachments[i].storeAction = MTLStoreActionDontCare; - m_drawRenderPassDescriptor.colorAttachments[i].texture = nil; + m_drawRenderPassDescriptor.colorAttachments[i].texture = nil; } - m_drawRenderPassDescriptor.depthAttachment.clearDepth = 0; - m_drawRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionDontCare; - m_drawRenderPassDescriptor.depthAttachment.storeAction = MTLStoreActionDontCare; - m_drawRenderPassDescriptor.depthAttachment.texture = nil; + m_drawRenderPassDescriptor.depthAttachment.clearDepth = 0; + m_drawRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionDontCare; + m_drawRenderPassDescriptor.depthAttachment.storeAction = MTLStoreActionDontCare; + m_drawRenderPassDescriptor.depthAttachment.texture = nil; m_drawRenderPassDescriptor.stencilAttachment.clearStencil = 0; - m_drawRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionDontCare; - m_drawRenderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; - m_drawRenderPassDescriptor.stencilAttachment.texture = nil; + m_drawRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionDontCare; + m_drawRenderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; + m_drawRenderPassDescriptor.stencilAttachment.texture = nil; m_drawRenderPassDescriptor.visibilityResultBuffer = m_visibilityBuffer; m_numRenderAttachments = 0; - m_numCommands = 0; + m_numCommands = 0; m_blitAndPresentRenderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; - m_blitAndPresentRenderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake( 0.0,0.0,0.0,1.0 ); + m_blitAndPresentRenderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake( 0.0, 0.0, 0.0, 1.0 ); } void MetalWorkQueue::CreateClearFunctions() @@ -242,7 +248,7 @@ { CCP_AL_LOGERR( "Couldn't create shader library. Error: %s", error.localizedDescription.UTF8String ); // assert here becuase if the shader libary isn't loading, nothing good will happen - CCP_ASSERT(shaderLib != nil); + CCP_ASSERT( shaderLib != nil ); } // for (int i = 0; i < shaderLib.functionNames.count; i++) @@ -254,89 +260,89 @@ if( !m_clearBufferComputeFunctions[0] ) { CCP_AL_LOGERR( "Couldn't load ClearFloatBuffer function from library." ); - CCP_ASSERT(false); + CCP_ASSERT( false ); } m_clearBufferComputeFunctions[1] = [shaderLib newFunctionWithName:@"ClearUIntBuffer"]; if( !m_clearBufferComputeFunctions[1] ) { CCP_AL_LOGERR( "Couldn't load ClearUIntBuffer function from library." ); - CCP_ASSERT(false); + CCP_ASSERT( false ); } m_clearTextureComputeFunctions[0] = [shaderLib newFunctionWithName:@"ClearFloatTexture"]; if( !m_clearTextureComputeFunctions[0] ) { CCP_AL_LOGERR( "Couldn't load ClearFloatTexture function from library." ); - CCP_ASSERT(false); + CCP_ASSERT( false ); } m_clearTextureComputeFunctions[1] = [shaderLib newFunctionWithName:@"ClearUIntTexture"]; if( !m_clearTextureComputeFunctions[1] ) { CCP_AL_LOGERR( "Couldn't load ClearUIntTexture function from library." ); - CCP_ASSERT(false); + CCP_ASSERT( false ); } } void MetalWorkQueue::SetCommandQueue( id commandQueue ) { CCP_ASSERT( m_isPrimary ); - + m_commandQueue = commandQueue; - m_device = commandQueue.device; - - m_isIntelGpu = [m_device.name containsString:@"Intel"]; - if( @available(macOS 10.15, *) ) + m_device = commandQueue.device; + + m_isIntelGpu = [m_device.name containsString:@"Intel"]; + if( @available( macOS 10.15, * ) ) { - m_isAppleSilicon = [m_device supportsFamily:MTLGPUFamilyMac2] && [m_device supportsFamily: MTLGPUFamilyApple7]; + m_isAppleSilicon = [m_device supportsFamily:MTLGPUFamilyMac2] && [m_device supportsFamily:MTLGPUFamilyApple7]; } - - SetupPresentBlitResources(); + + SetupPresentBlitResources(); CreateClearFunctions(); } void MetalWorkQueue::ResetWorkQueue() { - m_commandBuffer = nil; - - m_encoderInUse = false; - m_encoderEnded = false; - m_encoderHasWork = false; - m_currentEncoderType = MTLENCODERTYPE_NONE; - m_currentBlitEncoder = nil; - m_currentRenderEncoder = nil; - m_currentComputeEncoder = nil; - if (@available(macOS 11.0, *)) - { - m_currentAccelerationStructureEncoder = nil; - } + m_commandBuffer = nil; + + m_encoderInUse = false; + m_encoderEnded = false; + m_encoderHasWork = false; + m_currentEncoderType = MTLENCODERTYPE_NONE; + m_currentBlitEncoder = nil; + m_currentRenderEncoder = nil; + m_currentComputeEncoder = nil; + if( @available( macOS 11.0, * ) ) + { + m_currentAccelerationStructureEncoder = nil; + } m_generatesEndOfQueueEvent = false; - m_pendingClear = false; + m_pendingClear = false; // Can't reset vertex descriptor because operations like synchronising resources cause command buffer flushes // and we need to retain this. Probably applies to other state too so may have to rethink the point at which call this fn. // m_currentVertexDescriptor = nil; // m_currentVertexDescriptorHash = 0; - m_currentAttachmentsHash = 0; - m_currentRenderPipelineDescriptorHash = 0; - m_currentRenderPipelineState = nil; - m_currentDepthStencilDescriptorHash = 0; - m_currentDepthStencilState = nil; + m_currentAttachmentsHash = 0; + m_currentRenderPipelineDescriptorHash = 0; + m_currentRenderPipelineState = nil; + m_currentDepthStencilDescriptorHash = 0; + m_currentDepthStencilState = nil; m_currentComputePipelineDescriptorHash = 0; - m_currentComputePipelineState = nil; - m_currentRenderPassDescriptor = m_drawRenderPassDescriptor; - m_visibilityQueriesInThisEncoder = 0; - - m_numCommands = 0; + m_currentComputePipelineState = nil; + m_currentRenderPassDescriptor = m_drawRenderPassDescriptor; + m_visibilityQueriesInThisEncoder = 0; + + m_numCommands = 0; } void MetalWorkQueue::ResetFrame() { CCP_ASSERT( m_isPrimary ); - - m_pipelineQueriesInProgress.clear(); - + + m_pipelineQueriesInProgress.clear(); + for( int i = 0; i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) { m_boundVertexStreams[i].stride = 0; @@ -356,12 +362,12 @@ void MetalWorkQueue::CreateCommandBuffer() { CCP_ASSERT( m_isPrimary ); - + if( m_commandBuffer == nil ) { m_commandBuffer = [m_commandQueue commandBuffer]; -#if !__has_feature(objc_arc) - [m_commandBuffer retain]; +#if !__has_feature( objc_arc ) + [m_commandBuffer retain]; #endif } // We'll reuse an existing buffer silently if it's empty, otherwise emit warning @@ -374,7 +380,7 @@ void MetalWorkQueue::FlushOutstandingOperations() { CCP_ASSERT( m_isPrimary ); - + // The tests just do a present with no render if( !m_commandBuffer ) { @@ -390,11 +396,11 @@ // Flush any outstanding clears on the current surface if( m_pendingClear ) { - auto bkHasPendingRenderPassHint = m_hasPendingRenderPassHint; - m_hasPendingRenderPassHint = false; + auto bkHasPendingRenderPassHint = m_hasPendingRenderPassHint; + m_hasPendingRenderPassHint = false; GetRenderEncoder( @"Flush clears encoder" ); ReleaseEncoder( true ); - m_hasPendingRenderPassHint = bkHasPendingRenderPassHint; + m_hasPendingRenderPassHint = bkHasPendingRenderPassHint; } } @@ -406,16 +412,16 @@ void MetalWorkQueue::RenderTargetBarrier() { CCP_ASSERT( m_isPrimary ); - + if( !m_currentRenderEncoder ) { return; } - + if( m_isAppleSilicon ) { GetRenderEncoder(); - ReleaseEncoder(true); + ReleaseEncoder( true ); } else { @@ -426,7 +432,7 @@ void MetalWorkQueue::CommitCommandBuffer( MetalCBCommitFlags flags ) { CCP_ASSERT( m_isPrimary ); - + // Check if there was any work to submit on this queue if( m_commandBuffer == nil ) { @@ -446,17 +452,16 @@ if( !m_encoderEnded ) { m_encoderInUse = true; - ReleaseEncoder(true); + ReleaseEncoder( true ); } - METAL_LOG(@"Committing command buffer: %@", m_commandBuffer.label); + METAL_LOG( @"Committing command buffer: %@", m_commandBuffer.label ); } // Only schedule a callbvack if we have something to do. if( m_visibilityQueriesInThisEncoder ) { __block uint64_t block_numCompletedVisibilityQueries = m_currentVisibilityQueryIndex; - [m_commandBuffer addCompletedHandler:^(id buffer) - { + [m_commandBuffer addCompletedHandler:^( id buffer ) { m_numCompletedVisibilityQueries = block_numCompletedVisibilityQueries; METAL_LOG( @"Visibvility queries < (%llu) now valid", m_numCompletedVisibilityQueries ); }]; @@ -464,14 +469,16 @@ [m_commandBuffer commit]; - if( (flags & MTLCBCOMMIT_WAITUNTILSCHEDULED) && m_encoderHasWork ) { + if( ( flags & MTLCBCOMMIT_WAITUNTILSCHEDULED ) && m_encoderHasWork ) + { [m_commandBuffer waitUntilScheduled]; } - else if( (flags & MTLCBCOMMIT_WAITUNTILCOMPLETE) && m_encoderHasWork ) { + else if( ( flags & MTLCBCOMMIT_WAITUNTILCOMPLETE ) && m_encoderHasWork ) + { [m_commandBuffer waitUntilCompleted]; } -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [m_commandBuffer release]; #endif @@ -481,14 +488,14 @@ void MetalWorkQueue::BeginFrame() { CCP_ASSERT( m_isPrimary ); - - METAL_LOG(@"Log:------- BeginFrame() --------"); + + METAL_LOG( @"Log:------- BeginFrame() --------" ); } void MetalWorkQueue::EndFrame() { CCP_ASSERT( m_isPrimary ); - + FlushOutstandingOperations(); // Reset state at end of frame, not beginning of frame as some setup occurs prior to BeginScene being called @@ -496,14 +503,14 @@ // InitRenderPassDescriptor(); m_dirtyRenderEncoderState = METAL_RENDERENCODERDIRTYSTATE_ALL; - METAL_LOG(@"Log:------- EndFrame() -------"); + METAL_LOG( @"Log:------- EndFrame() -------" ); ResetFrame(); } void MetalWorkQueue::SetupPresentBlitResources() { CCP_ASSERT( m_isPrimary ); - + NSError* error; NSString* sBlitShaderSourceString = [[NSString alloc] initWithUTF8String:sBlitShaderSource]; id shaderLib = [m_device newLibraryWithSource:sBlitShaderSourceString options:nil error:&error]; @@ -515,39 +522,39 @@ CCP_ASSERT( shaderLib != nil ); } - id vertexProgram = [shaderLib newFunctionWithName:@"blitPresentVertexShader"]; + id vertexProgram = [shaderLib newFunctionWithName:@"blitPresentVertexShader"]; if( !vertexProgram ) { CCP_AL_LOGERR( "Couldn't load vertex function from default library." ); - CCP_ASSERT(vertexProgram != nil); + CCP_ASSERT( vertexProgram != nil ); } - id fragmentProgram = [shaderLib newFunctionWithName:@"blitPresentFragmentShader"]; + id fragmentProgram = [shaderLib newFunctionWithName:@"blitPresentFragmentShader"]; if( !fragmentProgram ) { CCP_AL_LOGERR( "Couldn't load fragment function from default library." ); - CCP_ASSERT(fragmentProgram != nil); + CCP_ASSERT( fragmentProgram != nil ); } // Create a pipeline state descriptor which can be used to create a compiled pipeline state object m_presentBlitPipelineDesciptor = [[MTLRenderPipelineDescriptor alloc] init]; - m_presentBlitPipelineDesciptor.label = @"PresentBlitPipeline"; - m_presentBlitPipelineDesciptor.vertexFunction = vertexProgram; - m_presentBlitPipelineDesciptor.fragmentFunction = fragmentProgram; + m_presentBlitPipelineDesciptor.label = @"PresentBlitPipeline"; + m_presentBlitPipelineDesciptor.vertexFunction = vertexProgram; + m_presentBlitPipelineDesciptor.fragmentFunction = fragmentProgram; m_presentBlitPipelineDesciptor.colorAttachments[0].pixelFormat = MTLPixelFormatInvalid; m_presentBlitPipeline = nil; - m_numCommands = 0; + m_numCommands = 0; } bool MetalWorkQueue::BlitToDrawableAndPresent( id srcTexture, NSView* view, uint64_t* renderedFrameNumber ) { CCP_ASSERT( m_isPrimary ); - - METAL_LOG(@"Log:BlitToDrawableAndPresent"); - - dispatch_semaphore_wait( m_frameSemaphore, DISPATCH_TIME_FOREVER ); + + METAL_LOG( @"Log:BlitToDrawableAndPresent" ); + + dispatch_semaphore_wait( m_frameSemaphore, DISPATCH_TIME_FOREVER ); // JM - this should not be done every blit but rather setup only when something changes. // Probably from the SwapChain or PresentParameters code. @@ -584,12 +591,12 @@ m_currentRenderPassDescriptor = m_blitAndPresentRenderPassDescriptor; // Create the render command encoder from the descriptor we just set up. - id renderEncoder = GetRenderEncoder( @"Present Blit" ); + id renderEncoder = GetRenderEncoder( @"Present Blit" ); // Check if we need to create a new pipeline if( m_presentBlitPipelineDesciptor.colorAttachments[0].pixelFormat != drawable.texture.pixelFormat ) { -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) if( m_presentBlitPipeline ) { [m_presentBlitPipeline release]; @@ -597,13 +604,14 @@ #endif m_presentBlitPipelineDesciptor.colorAttachments[0].pixelFormat = drawable.texture.pixelFormat; - NSError *error; + NSError* error; - m_presentBlitPipeline = [m_device newRenderPipelineStateWithDescriptor:m_presentBlitPipelineDesciptor error:&error]; + m_presentBlitPipeline = [m_device newRenderPipelineStateWithDescriptor:m_presentBlitPipelineDesciptor + error:&error]; if( !m_presentBlitPipeline ) { CCP_AL_LOGERR( "Failed aquiring pipeline state. Error: %s", error.localizedDescription.UTF8String ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [error release]; #endif return false; @@ -612,12 +620,11 @@ [renderEncoder setRenderPipelineState:m_presentBlitPipeline]; - static const BlitPresentVertex quad[] = { - (vector_float2){-1.0f, 1.0f}, (vector_float2){0.0, 0.0f}, - (vector_float2){ 1.0f, 1.0f}, (vector_float2){1.0f, 0.0f}, - (vector_float2){-1.0f, -1.0f}, (vector_float2){0.0f, 1.0f}, - (vector_float2){ 1.0f, -1.0f}, (vector_float2){1.0f, 1.0f}}; - uint32_t quadSizeInBytes = sizeof(quad); + static const BlitPresentVertex quad[] = { (vector_float2){ -1.0f, 1.0f }, (vector_float2){ 0.0, 0.0f }, + (vector_float2){ 1.0f, 1.0f }, (vector_float2){ 1.0f, 0.0f }, + (vector_float2){ -1.0f, -1.0f }, (vector_float2){ 0.0f, 1.0f }, + (vector_float2){ 1.0f, -1.0f }, (vector_float2){ 1.0f, 1.0f } }; + uint32_t quadSizeInBytes = sizeof( quad ); [renderEncoder setVertexBytes:&quad length:quadSizeInBytes atIndex:BlitPresentInputIndexVertices]; @@ -629,49 +636,49 @@ #define METAL_SERIALISE_PRESENT 0 #if METAL_SERIALISE_PRESENT - [m_commandBuffer addCompletedHandler:^(id commandBuffer) { - if (@available(macOS 10.15, *)) - { - auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; - s_gpuFrameTime += duration; + [m_commandBuffer addCompletedHandler:^( id commandBuffer ) { + if( @available( macOS 10.15, * ) ) + { + auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; + s_gpuFrameTime += duration; #if CCP_STATS_ENABLED - g_ccpStatistics_gpuFrameTime.Set( s_gpuFrameTime ); + g_ccpStatistics_gpuFrameTime.Set( s_gpuFrameTime ); #endif - s_gpuFrameTime = 0; - } - }]; + s_gpuFrameTime = 0; + } + }]; [m_commandBuffer presentDrawable:drawable]; - CommitCommandBuffer(MTLCBCOMMIT_WAITUNTILCOMPLETE); - ++*renderedFrameNumber; + CommitCommandBuffer( MTLCBCOMMIT_WAITUNTILCOMPLETE ); + ++*renderedFrameNumber; #else - __block dispatch_semaphore_t frameSemaphore = m_frameSemaphore; - [m_commandBuffer addCompletedHandler:^(id commandBuffer) { - if (@available(macOS 10.15, *)) - { - auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; - s_gpuFrameTime += duration; + __block dispatch_semaphore_t frameSemaphore = m_frameSemaphore; + [m_commandBuffer addCompletedHandler:^( id commandBuffer ) { + if( @available( macOS 10.15, * ) ) + { + auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; + s_gpuFrameTime += duration; #if CCP_STATS_ENABLED - g_ccpStatistics_gpuFrameTime.Set( s_gpuFrameTime ); + g_ccpStatistics_gpuFrameTime.Set( s_gpuFrameTime ); #endif - s_gpuFrameTime = 0; - } - ++*renderedFrameNumber; - dispatch_semaphore_signal( frameSemaphore ); + s_gpuFrameTime = 0; + } + ++*renderedFrameNumber; + dispatch_semaphore_signal( frameSemaphore ); }]; [m_commandBuffer presentDrawable:drawable]; - CommitCommandBuffer(MTLCBCOMMIT_NOFLAGS); + CommitCommandBuffer( MTLCBCOMMIT_NOFLAGS ); #endif m_currentRenderPassDescriptor = m_drawRenderPassDescriptor; - return true; + return true; } void MetalWorkQueue::EndEncoder() { - if( m_encoderInUse || !m_encoderEnded ) - { - ReleaseEncoder( true ); - } + if( m_encoderInUse || !m_encoderEnded ) + { + ReleaseEncoder( true ); + } } void MetalWorkQueue::ReleaseEncoder( bool endEncoding ) @@ -687,76 +694,73 @@ return; } - // Automatically create a new render encoder every 'IntelCommandCountPerEncoder'. - // This is only done on Intel GPU to save frametime. - static const int32_t IntelCommandCountPerEncoder = 32; - - m_numCommands++; - if( m_isIntelGpu && m_isPrimary ) - { - if( m_numCommands == IntelCommandCountPerEncoder ) - { - m_numCommands = 0; - endEncoding = true; - } - } - + // Automatically create a new render encoder every 'IntelCommandCountPerEncoder'. + // This is only done on Intel GPU to save frametime. + static const int32_t IntelCommandCountPerEncoder = 32; + + m_numCommands++; + if( m_isIntelGpu && m_isPrimary ) + { + if( m_numCommands == IntelCommandCountPerEncoder ) + { + m_numCommands = 0; + endEncoding = true; + } + } + if( endEncoding ) { - for( auto query : m_pipelineQueriesInProgress ) - { - query->EncoderEnding( this ); - } + for( auto query : m_pipelineQueriesInProgress ) + { + query->EncoderEnding( this ); + } + + m_hasPendingRenderTargetBarrier = false; - m_hasPendingRenderTargetBarrier = false; - switch( m_currentEncoderType ) { - case MTLENCODERTYPE_RENDER: - { + case MTLENCODERTYPE_RENDER: { METAL_LOG( @"Log:Releasing and ending render encoder %@", m_currentRenderEncoder.label ); CCP_ASSERT( !m_visibilityQueryInProgress ); [m_currentRenderEncoder endEncoding]; - m_currentRenderEncoder = nil; + m_currentRenderEncoder = nil; m_currentRenderPipelineState = nil; break; } - case MTLENCODERTYPE_COMPUTE: - { + case MTLENCODERTYPE_COMPUTE: { CCP_ASSERT( m_isPrimary ); - - METAL_LOG(@"Log:Releasing and ending compute encoder %@", m_currentComputeEncoder.label); + + METAL_LOG( @"Log:Releasing and ending compute encoder %@", m_currentComputeEncoder.label ); [m_currentComputeEncoder endEncoding]; m_currentComputePipelineState = nil; m_threadGroupSize = MTLSizeMake( 1, 1, 1 ); m_currentComputeEncoder = nil; break; } - case MTLENCODERTYPE_BLIT: - { + case MTLENCODERTYPE_BLIT: { CCP_ASSERT( m_isPrimary ); - - METAL_LOG(@"Log:Releasing and ending blit encoder %@", m_currentBlitEncoder.label); + + METAL_LOG( @"Log:Releasing and ending blit encoder %@", m_currentBlitEncoder.label ); [m_currentBlitEncoder endEncoding]; m_currentBlitEncoder = nil; break; } - case MTLENCODERTYPE_ACCELERATION_STRUCTURE: - { - if (@available(macOS 11.0, *)) - { - CCP_ASSERT( m_isPrimary ); - - METAL_LOG(@"Log:Releasing and ending acceleration structure encoder %@", m_currentAccelerationStructureEncoder.label); - [m_currentAccelerationStructureEncoder endEncoding]; - m_currentAccelerationStructureEncoder = nil; - } - break; - } + case MTLENCODERTYPE_ACCELERATION_STRUCTURE: { + if( @available( macOS 11.0, * ) ) + { + CCP_ASSERT( m_isPrimary ); + + METAL_LOG( @"Log:Releasing and ending acceleration structure encoder %@", + m_currentAccelerationStructureEncoder.label ); + [m_currentAccelerationStructureEncoder endEncoding]; + m_currentAccelerationStructureEncoder = nil; + } + break; + } case MTLENCODERTYPE_NONE: default: - CCP_ASSERT( m_isPrimary ); + CCP_ASSERT( m_isPrimary ); // CCP_AL_LOGERR( "Unsupported encoder type to flush." ); break; } @@ -769,13 +773,13 @@ void MetalWorkQueue::ApplyRenderPassHint() { CCP_ASSERT( m_isPrimary ); - + // Check we have a valid render pass descriptor if( !m_currentRenderPassDescriptor ) { CCP_AL_LOGERR( "Can ony pass null renderPassDescriptor if the render encoder is currently active." ); } - + if( m_hasPendingRenderPassHint ) { if( m_currentRenderPassDescriptor.depthAttachment.texture ) @@ -793,10 +797,12 @@ { if( m_currentRenderPassDescriptor.colorAttachments[i].loadAction != MTLLoadActionClear ) { - m_currentRenderPassDescriptor.colorAttachments[i].loadAction = m_pendingRenderPassHint.color[i].load; + m_currentRenderPassDescriptor.colorAttachments[i].loadAction = + m_pendingRenderPassHint.color[i].load; } m_currentRenderPassDescriptor.colorAttachments[i].storeAction = m_pendingRenderPassHint.color[i].store; - m_currentRenderPassDescriptor.colorAttachments[i].clearColor = m_pendingRenderPassHint.color[i].clearColor; + m_currentRenderPassDescriptor.colorAttachments[i].clearColor = + m_pendingRenderPassHint.color[i].clearColor; } } m_hasPendingRenderPassHint = false; @@ -808,13 +814,13 @@ m_dirtyRenderEncoderState = METAL_RENDERENCODERDIRTYSTATE_ALL; m_dirtyConstBuffersMask[VERTEX_SHADER] = ~0u; - m_dirtyConstBufferPageMask[VERTEX_SHADER] = ~0u; + m_dirtyConstBufferPageMask[VERTEX_SHADER] = ~0u; m_dirtyBuffersMask[VERTEX_SHADER] = ~0u; m_dirtyTexturesMask[VERTEX_SHADER] = ~0u; m_dirtySamplersMask[VERTEX_SHADER] = ~0u; m_dirtyConstBuffersMask[PIXEL_SHADER] = ~0u; - m_dirtyConstBufferPageMask[PIXEL_SHADER] = ~0u; + m_dirtyConstBufferPageMask[PIXEL_SHADER] = ~0u; m_dirtyBuffersMask[PIXEL_SHADER] = ~0u; m_dirtyTexturesMask[PIXEL_SHADER] = ~0u; m_dirtySamplersMask[PIXEL_SHADER] = ~0u; @@ -822,17 +828,17 @@ void MetalWorkQueue::MarkConstantBuffersDirty() { - m_dirtyConstBuffersMask[VERTEX_SHADER] = ~0u; - m_dirtyConstBufferPageMask[VERTEX_SHADER] = ~0u; + m_dirtyConstBuffersMask[VERTEX_SHADER] = ~0u; + m_dirtyConstBufferPageMask[VERTEX_SHADER] = ~0u; - m_dirtyConstBuffersMask[PIXEL_SHADER] = ~0u; - m_dirtyConstBufferPageMask[PIXEL_SHADER] = ~0u; + m_dirtyConstBuffersMask[PIXEL_SHADER] = ~0u; + m_dirtyConstBufferPageMask[PIXEL_SHADER] = ~0u; - m_dirtyConstBuffersMask[COMPUTE_SHADER] = ~0u; - m_dirtyConstBufferPageMask[COMPUTE_SHADER] = ~0u; + m_dirtyConstBuffersMask[COMPUTE_SHADER] = ~0u; + m_dirtyConstBufferPageMask[COMPUTE_SHADER] = ~0u; } -void MetalWorkQueue::SetCurrentEncoder( MetalEncoderType encoderType, NSString *encoderLabel ) +void MetalWorkQueue::SetCurrentEncoder( MetalEncoderType encoderType, NSString* encoderLabel ) { if( m_encoderInUse ) { @@ -857,7 +863,9 @@ { if( encoderType == MTLENCODERTYPE_RENDER && m_hasPendingRenderTargetBarrier ) { - [m_currentRenderEncoder memoryBarrierWithScope:MTLBarrierScopeRenderTargets afterStages:MTLRenderStageFragment beforeStages:MTLRenderStageVertex]; + [m_currentRenderEncoder memoryBarrierWithScope:MTLBarrierScopeRenderTargets + afterStages:MTLRenderStageFragment + beforeStages:MTLRenderStageVertex]; m_hasPendingRenderTargetBarrier = false; } // Mark that this curent encoder is in use and return @@ -869,7 +877,7 @@ { // Mark encoder in use so we can do release+end m_encoderInUse = true; - ReleaseEncoder(true); + ReleaseEncoder( true ); } } @@ -877,31 +885,29 @@ // Create a new encoder switch( encoderType ) { - case MTLENCODERTYPE_RENDER: - { + case MTLENCODERTYPE_RENDER: { ApplyRenderPassHint(); - + if( !m_isPrimary ) { CCP_AL_LOGERR( "We can't create encoder in this cotext" ); } - + m_currentRenderEncoder = [m_commandBuffer renderCommandEncoderWithDescriptor:m_currentRenderPassDescriptor]; m_currentRenderEncoder.label = encoderLabel ? encoderLabel : @"Standard render encoder"; - METAL_LOG(@"Log:SetCurrentEncoder(Render) %@", m_currentRenderEncoder.label); + METAL_LOG( @"Log:SetCurrentEncoder(Render) %@", m_currentRenderEncoder.label ); // Since the encoder is new we'll need to emit all the state again SetRenderStatesDirty(); // We should remove any clear state just processed by this render encoder ResetClearState(); - - ++m_encoderIndex; + + ++m_encoderIndex; break; } - case MTLENCODERTYPE_COMPUTE: - { + case MTLENCODERTYPE_COMPUTE: { #if 0 if( m_concurrentDispatchSupported ) { @@ -913,39 +919,39 @@ m_currentComputeEncoder = [m_commandBuffer computeCommandEncoder]; } m_currentComputeEncoder.label = encoderLabel ? encoderLabel : @"Standard compute encoder"; - METAL_LOG(@"Log:SetCurrentEncoder(Compute) %@", m_currentBlitEncoder.label); + METAL_LOG( @"Log:SetCurrentEncoder(Compute) %@", m_currentBlitEncoder.label ); - m_dirtyConstBuffersMask[COMPUTE_SHADER] = ~0u; - m_dirtyConstBufferPageMask[COMPUTE_SHADER] = ~0u; + m_dirtyConstBuffersMask[COMPUTE_SHADER] = ~0u; + m_dirtyConstBufferPageMask[COMPUTE_SHADER] = ~0u; m_dirtyBuffersMask[COMPUTE_SHADER] = ~0u; m_dirtyTexturesMask[COMPUTE_SHADER] = ~0u; m_dirtySamplersMask[COMPUTE_SHADER] = ~0u; - - ++m_encoderIndex; + + ++m_encoderIndex; break; } - case MTLENCODERTYPE_BLIT: - { + case MTLENCODERTYPE_BLIT: { m_currentBlitEncoder = [m_commandBuffer blitCommandEncoder]; m_currentBlitEncoder.label = encoderLabel ? encoderLabel : @"Standard blit encoder"; - METAL_LOG(@"Log:SetCurrentEncoder(Blit) %@", m_currentBlitEncoder.label); - - ++m_encoderIndex; + METAL_LOG( @"Log:SetCurrentEncoder(Blit) %@", m_currentBlitEncoder.label ); + + ++m_encoderIndex; + break; + } + case MTLENCODERTYPE_ACCELERATION_STRUCTURE: { + if( @available( macOS 11.0, * ) ) + { + m_currentAccelerationStructureEncoder = [m_commandBuffer accelerationStructureCommandEncoder]; + m_currentAccelerationStructureEncoder.label = + encoderLabel ? encoderLabel : @"Standard acceleration structure encoder"; + METAL_LOG( @"Log:SetCurrentEncoder(AccelerationStructure) %@", + m_currentAccelerationStructureEncoder.label ); + + ++m_encoderIndex; + } break; } - case MTLENCODERTYPE_ACCELERATION_STRUCTURE: - { - if( @available( macOS 11.0, * ) ) - { - m_currentAccelerationStructureEncoder = [m_commandBuffer accelerationStructureCommandEncoder]; - m_currentAccelerationStructureEncoder.label = encoderLabel ? encoderLabel : @"Standard acceleration structure encoder"; - METAL_LOG(@"Log:SetCurrentEncoder(AccelerationStructure) %@", m_currentAccelerationStructureEncoder.label); - - ++m_encoderIndex; - } - break; - } case MTLENCODERTYPE_NONE: default: CCP_AL_LOGERR( "Invalid encoder type!" ); @@ -953,66 +959,67 @@ // Mark that this curent encoder is in use m_currentEncoderType = encoderType; - m_encoderInUse = true; - m_encoderEnded = false; - m_encoderHasWork = true; + m_encoderInUse = true; + m_encoderEnded = false; + m_encoderHasWork = true; m_numCommands = 0; - - for( auto query : m_pipelineQueriesInProgress ) - { - query->EncoderStarted( this ); - } + + for( auto query : m_pipelineQueriesInProgress ) + { + query->EncoderStarted( this ); + } } -id MetalWorkQueue::GetBlitEncoder( NSString *encoderLabel ) +id MetalWorkQueue::GetBlitEncoder( NSString* encoderLabel ) { CCP_ASSERT( m_isPrimary ); - + SetCurrentEncoder( MTLENCODERTYPE_BLIT ); return m_currentBlitEncoder; } -id MetalWorkQueue::GetComputeEncoder( NSString *encoderLabel ) +id MetalWorkQueue::GetComputeEncoder( NSString* encoderLabel ) { CCP_ASSERT( m_isPrimary ); - + SetCurrentEncoder( MTLENCODERTYPE_COMPUTE ); return m_currentComputeEncoder; } // If a renderpass descriptor is provided a new render encoder will be created otherwise we'll use the current one -id MetalWorkQueue::GetRenderEncoder( NSString *encoderLabel ) +id MetalWorkQueue::GetRenderEncoder( NSString* encoderLabel ) { SetCurrentEncoder( MTLENCODERTYPE_RENDER, encoderLabel ); return m_currentRenderEncoder; } -id MetalWorkQueue::GetAccelerationStructureEncoder( NSString *encoderLabel ) +id MetalWorkQueue::GetAccelerationStructureEncoder( NSString* encoderLabel ) { - SetCurrentEncoder( MTLENCODERTYPE_ACCELERATION_STRUCTURE, encoderLabel ); - return m_currentAccelerationStructureEncoder; + SetCurrentEncoder( MTLENCODERTYPE_ACCELERATION_STRUCTURE, encoderLabel ); + return m_currentAccelerationStructureEncoder; } -id MetalWorkQueue::GetParallelEncoder( NSString *encoderLabel ) +id MetalWorkQueue::GetParallelEncoder( NSString* encoderLabel ) { if( m_currentParallelEncoder ) { return m_currentParallelEncoder; } - + ApplyRenderPassHint(); - - m_currentParallelEncoder = [m_commandBuffer parallelRenderCommandEncoderWithDescriptor:m_currentRenderPassDescriptor]; + + m_currentParallelEncoder = + [m_commandBuffer parallelRenderCommandEncoderWithDescriptor:m_currentRenderPassDescriptor]; m_currentParallelEncoder.label = encoderLabel ? encoderLabel : @"Standard parallel encoder"; - METAL_LOG(@"Log:CreateParallelEncoder(Render) %@", m_currentParallelEncoder.label); + METAL_LOG( @"Log:CreateParallelEncoder(Render) %@", m_currentParallelEncoder.label ); ResetClearState(); return m_currentParallelEncoder; } -void MetalWorkQueue::CopyDataToBuffer( id buffer, const void *data, size_t offset, size_t sizeInBytes ) +void MetalWorkQueue::CopyDataToBuffer( id buffer, const void* data, size_t offset, size_t sizeInBytes ) { if( buffer.storageMode == MTLResourceStorageModePrivate ) { @@ -1020,15 +1027,19 @@ } else { - void *offsetDest = (void*)&((char *)buffer.contents)[offset]; + void* offsetDest = (void*)&( (char*)buffer.contents )[offset]; - memcpy(offsetDest, data, sizeInBytes); + memcpy( offsetDest, data, sizeInBytes ); - [buffer didModifyRange:NSMakeRange(offset, sizeInBytes)]; + [buffer didModifyRange:NSMakeRange( offset, sizeInBytes )]; } } -void MetalWorkQueue::CopyBufferToBuffer( id dest, size_t destOffset, id src, size_t srcOffset, size_t size ) +void MetalWorkQueue::CopyBufferToBuffer( id dest, + size_t destOffset, + id src, + size_t srcOffset, + size_t size ) { CCP_ASSERT( m_isPrimary ); id blitEncoder = GetBlitEncoder(); @@ -1048,13 +1059,13 @@ if( waitForData ) { ReleaseEncoder( true ); - [m_commandBuffer addCompletedHandler:^(id commandBuffer) { - if (@available(macOS 10.15, *)) - { - auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; - s_gpuFrameTime += duration; - } - }]; + [m_commandBuffer addCompletedHandler:^( id commandBuffer ) { + if( @available( macOS 10.15, * ) ) + { + auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; + s_gpuFrameTime += duration; + } + }]; CommitCommandBuffer( MTLCBCOMMIT_WAITUNTILCOMPLETE ); } else @@ -1063,14 +1074,14 @@ } } -void MetalWorkQueue::UploadTexture(id texture, - id srcBuffer, - uint32_t slice, - uint32_t mip, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer) +void MetalWorkQueue::UploadTexture( id texture, + id srcBuffer, + uint32_t slice, + uint32_t mip, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ) { CCP_ASSERT( m_isPrimary ); // Do we need to wait for some operations on the buffer to complete? @@ -1081,24 +1092,33 @@ id blitEncoder = GetBlitEncoder(); - MTLSize dimensions = MTLSizeMake(MAX(texture.width >> mip, 1), MAX(texture.height >> mip, 1), MAX(texture.depth >> mip, 1)); - MTLOrigin origin = MTLOriginMake(0, 0, 0); + MTLSize dimensions = + MTLSizeMake( MAX( texture.width >> mip, 1 ), MAX( texture.height >> mip, 1 ), MAX( texture.depth >> mip, 1 ) ); + MTLOrigin origin = MTLOriginMake( 0, 0, 0 ); - [blitEncoder copyFromBuffer:srcBuffer sourceOffset:srcOffset sourceBytesPerRow:bytesPerRow sourceBytesPerImage:bytesPerSlice sourceSize:dimensions toTexture:texture destinationSlice:slice destinationLevel:mip destinationOrigin:origin]; + [blitEncoder copyFromBuffer:srcBuffer + sourceOffset:srcOffset + sourceBytesPerRow:bytesPerRow + sourceBytesPerImage:bytesPerSlice + sourceSize:dimensions + toTexture:texture + destinationSlice:slice + destinationLevel:mip + destinationOrigin:origin]; - ReleaseEncoder(false); + ReleaseEncoder( false ); } -void MetalWorkQueue::UploadTexture(id texture, - id srcBuffer, - uint32_t slice, - uint32_t mip, - const MTLOrigin& origin, - const MTLSize& size, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer) +void MetalWorkQueue::UploadTexture( id texture, + id srcBuffer, + uint32_t slice, + uint32_t mip, + const MTLOrigin& origin, + const MTLSize& size, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ) { CCP_ASSERT( m_isPrimary ); // Do we need to wait for some operations on the buffer to complete? @@ -1109,35 +1129,38 @@ id blitEncoder = GetBlitEncoder(); - [blitEncoder copyFromBuffer:srcBuffer sourceOffset:srcOffset sourceBytesPerRow:bytesPerRow sourceBytesPerImage:bytesPerSlice sourceSize:size toTexture:texture destinationSlice:slice destinationLevel:mip destinationOrigin:origin]; + [blitEncoder copyFromBuffer:srcBuffer + sourceOffset:srcOffset + sourceBytesPerRow:bytesPerRow + sourceBytesPerImage:bytesPerSlice + sourceSize:size + toTexture:texture + destinationSlice:slice + destinationLevel:mip + destinationOrigin:origin]; - ReleaseEncoder(false); + ReleaseEncoder( false ); } -void MetalWorkQueue::UploadTexture(id texture, - const void *srcData, - uint32_t slice, - uint32_t mip, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - uint32_t srcOffset, - bool syncOnBuffer) +void MetalWorkQueue::UploadTexture( id texture, + const void* srcData, + uint32_t slice, + uint32_t mip, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + uint32_t srcOffset, + bool syncOnBuffer ) { CCP_ASSERT( m_isPrimary ); size_t bytesPerTexture = MAX( texture.depth >> mip, 1 ) * bytesPerSlice; - id srcBuffer = [m_device newBufferWithBytes:srcData length:bytesPerTexture options:MTLResourceStorageModeShared]; + id srcBuffer = [m_device newBufferWithBytes:srcData + length:bytesPerTexture + options:MTLResourceStorageModeShared]; - UploadTexture(texture, - srcBuffer, - slice, - mip, - bytesPerRow, - bytesPerSlice, - srcOffset, - syncOnBuffer); + UploadTexture( texture, srcBuffer, slice, mip, bytesPerRow, bytesPerSlice, srcOffset, syncOnBuffer ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [srcBuffer release]; #endif } @@ -1145,12 +1168,12 @@ void MetalWorkQueue::GenerateMipMaps( id texture ) { CCP_ASSERT( m_isPrimary ); - if (texture.mipmapLevelCount > 1) + if( texture.mipmapLevelCount > 1 ) { id blitEncoder = GetBlitEncoder(); [blitEncoder generateMipmapsForTexture:texture]; - ReleaseEncoder(false); + ReleaseEncoder( false ); } } @@ -1162,7 +1185,7 @@ MTLSize threadGroupSize = MTLSizeMake( 32, 1, 1 ); NSUInteger width = buffer.length / sizeof( float ); - NSUInteger groupDimX = (width + threadGroupSize.width - 1) / threadGroupSize.width; + NSUInteger groupDimX = ( width + threadGroupSize.width - 1 ) / threadGroupSize.width; size_t length = buffer.length / sizeof( float ); id oldComputeFunction = m_computeFunction; @@ -1173,12 +1196,11 @@ // Create and set a new pipelinestate if required. if( EmitComputePipelineState() ) { - [computeEncoder setBytes:values length:4*sizeof(*values) atIndex:0]; - [computeEncoder setBytes:&length length:sizeof(length) atIndex:1]; + [computeEncoder setBytes:values length:4 * sizeof( *values ) atIndex:0]; + [computeEncoder setBytes:&length length:sizeof( length ) atIndex:1]; [computeEncoder setBuffer:buffer offset:0 atIndex:2]; - [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, 1, 1 ) - threadsPerThreadgroup:threadGroupSize]; + [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, 1, 1 ) threadsPerThreadgroup:threadGroupSize]; } ReleaseEncoder( false ); @@ -1207,7 +1229,7 @@ MTLSize threadGroupSize = MTLSizeMake( 32, 1, 1 ); NSUInteger width = buffer.length / sizeof( uint32_t ); - NSUInteger groupDimX = (width + threadGroupSize.width - 1) / threadGroupSize.width; + NSUInteger groupDimX = ( width + threadGroupSize.width - 1 ) / threadGroupSize.width; size_t length = buffer.length / sizeof( uint32_t ); id oldComputeFunction = m_computeFunction; @@ -1218,12 +1240,11 @@ // Create and set a new pipelinestate if required. if( EmitComputePipelineState() ) { - [computeEncoder setBytes:values length:4*sizeof(*values) atIndex:0]; - [computeEncoder setBytes:&length length:sizeof(length) atIndex:1]; + [computeEncoder setBytes:values length:4 * sizeof( *values ) atIndex:0]; + [computeEncoder setBytes:&length length:sizeof( length ) atIndex:1]; [computeEncoder setBuffer:buffer offset:0 atIndex:2]; - [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, 1, 1 ) - threadsPerThreadgroup:threadGroupSize]; + [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, 1, 1 ) threadsPerThreadgroup:threadGroupSize]; } ReleaseEncoder( false ); @@ -1245,10 +1266,10 @@ // (both are preperties of MTLComputePipelineState). MTLSize threadGroupSize = MTLSizeMake( 32, 32, 1 ); - NSUInteger width = std::max(texture.width >> mipLevel, 1); - NSUInteger height = std::max(texture.height >> mipLevel, 1); - NSUInteger groupDimX = (width + threadGroupSize.width - 1) / threadGroupSize.width; - NSUInteger groupDimY = (height + threadGroupSize.height - 1) / threadGroupSize.height; + NSUInteger width = std::max( texture.width >> mipLevel, 1 ); + NSUInteger height = std::max( texture.height >> mipLevel, 1 ); + NSUInteger groupDimX = ( width + threadGroupSize.width - 1 ) / threadGroupSize.width; + NSUInteger groupDimY = ( height + threadGroupSize.height - 1 ) / threadGroupSize.height; id oldComputeFunction = m_computeFunction; m_computeFunction = m_clearTextureComputeFunctions[0]; @@ -1258,7 +1279,7 @@ // Create and set a new pipelinestate if required. if( EmitComputePipelineState() ) { - [computeEncoder setBytes:values length:4*sizeof(*values) atIndex:0]; + [computeEncoder setBytes:values length:4 * sizeof( *values ) atIndex:0]; [computeEncoder setTexture:texture atIndex:0]; [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, groupDimY, 1 ) @@ -1284,10 +1305,10 @@ // (both are preperties of MTLComputePipelineState). MTLSize threadGroupSize = MTLSizeMake( 32, 32, 1 ); - NSUInteger width = std::max(texture.width >> mipLevel, 1); - NSUInteger height = std::max(texture.height >> mipLevel, 1); - NSUInteger groupDimX = (width + threadGroupSize.width - 1) / threadGroupSize.width; - NSUInteger groupDimY = (height + threadGroupSize.height - 1) / threadGroupSize.height; + NSUInteger width = std::max( texture.width >> mipLevel, 1 ); + NSUInteger height = std::max( texture.height >> mipLevel, 1 ); + NSUInteger groupDimX = ( width + threadGroupSize.width - 1 ) / threadGroupSize.width; + NSUInteger groupDimY = ( height + threadGroupSize.height - 1 ) / threadGroupSize.height; id oldComputeFunction = m_computeFunction; m_computeFunction = m_clearTextureComputeFunctions[1]; @@ -1297,7 +1318,7 @@ // Create and set a new pipelinestate if required. if( EmitComputePipelineState() ) { - [computeEncoder setBytes:values length:4*sizeof(*values) atIndex:0]; + [computeEncoder setBytes:values length:4 * sizeof( *values ) atIndex:0]; [computeEncoder setTexture:texture atIndex:0]; [computeEncoder dispatchThreadgroups:MTLSizeMake( groupDimX, groupDimY, 1 ) @@ -1310,14 +1331,14 @@ // TODO: Insert a resource barrier here, so the following render stage knows when clear is complete. } -void MetalWorkQueue::CopyTextureToMTLBuffer(id texture, - id destBuffer, - uint32_t bytesPerRow, - uint32_t bytesPerSlice, - MTLOrigin origin, - MTLSize size, - uint32_t mipLevel, - bool waitForData) +void MetalWorkQueue::CopyTextureToMTLBuffer( id texture, + id destBuffer, + uint32_t bytesPerRow, + uint32_t bytesPerSlice, + MTLOrigin origin, + MTLSize size, + uint32_t mipLevel, + bool waitForData ) { CCP_ASSERT( m_isPrimary ); FlushOutstandingOperations(); @@ -1325,48 +1346,47 @@ id blitEncoder = GetBlitEncoder(); [blitEncoder copyFromTexture:texture - sourceSlice:0 - sourceLevel:mipLevel - sourceOrigin:origin - sourceSize:size - toBuffer:destBuffer - destinationOffset:0 - destinationBytesPerRow:bytesPerRow - destinationBytesPerImage:bytesPerSlice]; - - ReleaseEncoder(true); + sourceSlice:0 + sourceLevel:mipLevel + sourceOrigin:origin + sourceSize:size + toBuffer:destBuffer + destinationOffset:0 + destinationBytesPerRow:bytesPerRow + destinationBytesPerImage:bytesPerSlice]; + + ReleaseEncoder( true ); blitEncoder = GetBlitEncoder(); [blitEncoder synchronizeResource:destBuffer]; // sync to CPU if( waitForData ) { - ReleaseEncoder(true); - [m_commandBuffer addCompletedHandler:^(id commandBuffer) { - if (@available(macOS 10.15, *)) - { - auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; - s_gpuFrameTime += duration; - } - }]; - CommitCommandBuffer(MTLCBCOMMIT_WAITUNTILCOMPLETE); + ReleaseEncoder( true ); + [m_commandBuffer addCompletedHandler:^( id commandBuffer ) { + if( @available( macOS 10.15, * ) ) + { + auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; + s_gpuFrameTime += duration; + } + }]; + CommitCommandBuffer( MTLCBCOMMIT_WAITUNTILCOMPLETE ); } else { - ReleaseEncoder(false); + ReleaseEncoder( false ); } } -void MetalWorkQueue::CopyTextureToTexture( - id srcTexture, - uint32_t srcSlice, - uint32_t srcMip, - MTLOrigin srcOrigin, - MTLSize srcSize, - id dstTexture, - uint32_t dstSlice, - uint32_t dstMip, - MTLOrigin dstOrigin) +void MetalWorkQueue::CopyTextureToTexture( id srcTexture, + uint32_t srcSlice, + uint32_t srcMip, + MTLOrigin srcOrigin, + MTLSize srcSize, + id dstTexture, + uint32_t dstSlice, + uint32_t dstMip, + MTLOrigin dstOrigin ) { CCP_ASSERT( m_isPrimary ); id blitEncoder = GetBlitEncoder(); @@ -1381,7 +1401,7 @@ destinationLevel:dstMip destinationOrigin:dstOrigin]; - ReleaseEncoder(false); + ReleaseEncoder( false ); } void MetalWorkQueue::ResolveMsaa( id source, id destination ) @@ -1389,12 +1409,11 @@ CCP_ASSERT( m_isPrimary ); auto bkHasPendingRenderPassHint = m_hasPendingRenderPassHint; m_hasPendingRenderPassHint = false; - + // Changing an attachment requires a new render encoder so we must flush any outstanding work. ReleaseEncoder( true ); - if( source.pixelFormat == MTLPixelFormatDepth16Unorm || - source.pixelFormat == MTLPixelFormatDepth32Float || + if( source.pixelFormat == MTLPixelFormatDepth16Unorm || source.pixelFormat == MTLPixelFormatDepth32Float || source.pixelFormat == MTLPixelFormatDepth24Unorm_Stencil8 || source.pixelFormat == MTLPixelFormatDepth32Float_Stencil8 ) { @@ -1414,9 +1433,9 @@ { uint32_t numOldColorAttachments = m_numRenderAttachments; id oldColorAttachments[METAL_MAX_RENDER_TARGETS]; - std::fill_n(oldColorAttachments, METAL_MAX_RENDER_TARGETS, nil); + std::fill_n( oldColorAttachments, METAL_MAX_RENDER_TARGETS, nil ); uint32_t oldAttachmentSlice[METAL_MAX_RENDER_TARGETS]; - std::fill_n(oldAttachmentSlice, METAL_MAX_RENDER_TARGETS, 0); + std::fill_n( oldAttachmentSlice, METAL_MAX_RENDER_TARGETS, 0 ); for( uint32_t i = 0; i < numOldColorAttachments; ++i ) { @@ -1427,7 +1446,8 @@ SetRenderAttachments( source, 0 ); m_currentRenderPassDescriptor.colorAttachments[0].resolveTexture = destination; - m_currentRenderPassDescriptor.colorAttachments[0].storeAction = MTLStoreAction::MTLStoreActionMultisampleResolve; + m_currentRenderPassDescriptor.colorAttachments[0].storeAction = + MTLStoreAction::MTLStoreActionMultisampleResolve; GetRenderEncoder( @"ResolveColorEncoder" ); ReleaseEncoder( true ); @@ -1443,11 +1463,10 @@ } // FROM BOOST -template -inline void hash_combine( std::size_t& seed, const T& v ) +template inline void hash_combine( std::size_t& seed, const T& v ) { std::hash hasher; - seed ^= hasher( v ) + 0x9e3779b9 + (seed << 6) + (seed >> 2); + seed ^= hasher( v ) + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 ); } id MetalWorkQueue::GetCachedDepthStencilState( MTLDepthStencilDescriptor* descriptor ) @@ -1479,7 +1498,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) } else { -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [m_depthStencilStateCache[index] release]; #endif @@ -1495,7 +1514,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) size_t hashVal = 0; if( m_currentVertexDescriptor ) { - hash_combine( hashVal, m_currentVertexDescriptorBaseHash ); + hash_combine( hashVal, m_currentVertexDescriptorBaseHash ); unsigned int mask = m_currentVertexStreamMask; for( int i = 0; mask && i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) { @@ -1519,34 +1538,34 @@ inline void hash_combine( std::size_t& seed, const T& v ) for( uint32_t i = 0; i < m_numRenderAttachments; ++i ) { - hash_combine( hashVal, (uint32_t) m_blendState[i].blendType ); - hash_combine( hashVal, (uint32_t) m_blendState[i].alphaCoverageEnable ); - hash_combine( hashVal, (uint32_t) m_blendState[i].rgbBlendOp ); - hash_combine( hashVal, (uint32_t) m_blendState[i].alphaBlendOp ); - hash_combine( hashVal, (uint32_t) m_blendState[i].srcColorFactor ); - hash_combine( hashVal, (uint32_t) m_blendState[i].srcAlphaFactor ); - hash_combine( hashVal, (uint32_t) m_blendState[i].destColorFactor ); - hash_combine( hashVal, (uint32_t) m_blendState[i].destAlphaFactor ); - hash_combine( hashVal, (uint32_t) m_blendState[i].writeMask ); + hash_combine( hashVal, (uint32_t)m_blendState[i].blendType ); + hash_combine( hashVal, (uint32_t)m_blendState[i].alphaCoverageEnable ); + hash_combine( hashVal, (uint32_t)m_blendState[i].rgbBlendOp ); + hash_combine( hashVal, (uint32_t)m_blendState[i].alphaBlendOp ); + hash_combine( hashVal, (uint32_t)m_blendState[i].srcColorFactor ); + hash_combine( hashVal, (uint32_t)m_blendState[i].srcAlphaFactor ); + hash_combine( hashVal, (uint32_t)m_blendState[i].destColorFactor ); + hash_combine( hashVal, (uint32_t)m_blendState[i].destAlphaFactor ); + hash_combine( hashVal, (uint32_t)m_blendState[i].writeMask ); if( m_currentRenderPassDescriptor.colorAttachments[i].texture ) { - hash_combine( hashVal, (uint32_t) m_currentRenderPassDescriptor.colorAttachments[i].texture.pixelFormat ); + hash_combine( hashVal, (uint32_t)m_currentRenderPassDescriptor.colorAttachments[i].texture.pixelFormat ); sampleCount = m_currentRenderPassDescriptor.colorAttachments[i].texture.sampleCount; } } if( m_currentRenderPassDescriptor.depthAttachment.texture ) { - hash_combine( hashVal, (uint32_t) m_currentRenderPassDescriptor.depthAttachment.texture.pixelFormat ); + hash_combine( hashVal, (uint32_t)m_currentRenderPassDescriptor.depthAttachment.texture.pixelFormat ); sampleCount = m_currentRenderPassDescriptor.depthAttachment.texture.sampleCount; } if( m_currentRenderPassDescriptor.stencilAttachment.texture ) { - hash_combine( hashVal, (uint32_t) m_currentRenderPassDescriptor.stencilAttachment.texture.pixelFormat ); + hash_combine( hashVal, (uint32_t)m_currentRenderPassDescriptor.stencilAttachment.texture.pixelFormat ); } - hash_combine( hashVal, (uint32_t) sampleCount ); + hash_combine( hashVal, (uint32_t)sampleCount ); return hashVal; } @@ -1586,9 +1605,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) #if METAL_ENABLE_RENDER_STATE_CACHING size_t hashVal = 0; - hash_combine( hashVal, (__bridge void*) m_device ); - hash_combine( hashVal, (__bridge void*) m_vertexFunction ); - hash_combine( hashVal, (__bridge void*) m_fragmentFunction ); + hash_combine( hashVal, (__bridge void*)m_device ); + hash_combine( hashVal, (__bridge void*)m_vertexFunction ); + hash_combine( hashVal, (__bridge void*)m_fragmentFunction ); hash_combine( hashVal, m_currentVertexDescriptorHash ); hash_combine( hashVal, m_currentAttachmentsHash ); @@ -1605,18 +1624,18 @@ inline void hash_combine( std::size_t& seed, const T& v ) renderPipelineStateDescriptor.vertexDescriptor = m_currentVertexDescriptor; renderPipelineStateDescriptor.inputPrimitiveTopology = MTLPrimitiveTopologyClassUnspecified; - renderPipelineStateDescriptor.vertexFunction = m_vertexFunction; - renderPipelineStateDescriptor.fragmentFunction = m_fragmentFunction; + renderPipelineStateDescriptor.vertexFunction = m_vertexFunction; + renderPipelineStateDescriptor.fragmentFunction = m_fragmentFunction; renderPipelineStateDescriptor.rasterizationEnabled = ( m_fragmentFunction != nil ); #if METAL_TESSELLATION_SUPPORT - renderPipelineStateDescriptor.maxTessellationFactor = 1; - renderPipelineStateDescriptor.tessellationFactorScaleEnabled = NO; - renderPipelineStateDescriptor.tessellationFactorFormat = MTLTessellationFactorFormatHalf; + renderPipelineStateDescriptor.maxTessellationFactor = 1; + renderPipelineStateDescriptor.tessellationFactorScaleEnabled = NO; + renderPipelineStateDescriptor.tessellationFactorFormat = MTLTessellationFactorFormatHalf; renderPipelineStateDescriptor.tessellationControlPointIndexType = MTLTessellationControlPointIndexTypeNone; - renderPipelineStateDescriptor.tessellationFactorStepFunction = MTLTessellationFactorStepFunctionConstant; - renderPipelineStateDescriptor.tessellationOutputWindingOrder = MTLWindingCounterClockwise; - renderPipelineStateDescriptor.tessellationPartitionMode = MTLTessellationPartitionModePow2; + renderPipelineStateDescriptor.tessellationFactorStepFunction = MTLTessellationFactorStepFunctionConstant; + renderPipelineStateDescriptor.tessellationOutputWindingOrder = MTLWindingCounterClockwise; + renderPipelineStateDescriptor.tessellationPartitionMode = MTLTessellationPartitionModePow2; #endif // This is set for all attachments so pick it off the first one. @@ -1627,35 +1646,42 @@ inline void hash_combine( std::size_t& seed, const T& v ) { if( m_blendState[0].blendType == METAL_BLENDING_ENABLED ) { - renderPipelineStateDescriptor.colorAttachments[i].blendingEnabled = YES; - renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; - renderPipelineStateDescriptor.colorAttachments[i].rgbBlendOperation = m_blendState[0].rgbBlendOp; - renderPipelineStateDescriptor.colorAttachments[i].sourceRGBBlendFactor = m_blendState[0].srcColorFactor; - renderPipelineStateDescriptor.colorAttachments[i].destinationRGBBlendFactor = m_blendState[0].destColorFactor; - renderPipelineStateDescriptor.colorAttachments[i].alphaBlendOperation = m_blendState[0].rgbBlendOp; - renderPipelineStateDescriptor.colorAttachments[i].sourceAlphaBlendFactor = m_blendState[0].srcColorFactor; - renderPipelineStateDescriptor.colorAttachments[i].destinationAlphaBlendFactor = m_blendState[0].destColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].blendingEnabled = YES; + renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; + renderPipelineStateDescriptor.colorAttachments[i].rgbBlendOperation = m_blendState[0].rgbBlendOp; + renderPipelineStateDescriptor.colorAttachments[i].sourceRGBBlendFactor = m_blendState[0].srcColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].destinationRGBBlendFactor = + m_blendState[0].destColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].alphaBlendOperation = m_blendState[0].rgbBlendOp; + renderPipelineStateDescriptor.colorAttachments[i].sourceAlphaBlendFactor = + m_blendState[0].srcColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].destinationAlphaBlendFactor = + m_blendState[0].destColorFactor; } else if( m_blendState[0].blendType == METAL_BLENDING_ENABLED_SEPARATE_ALPHA ) { - renderPipelineStateDescriptor.colorAttachments[i].blendingEnabled = YES; - renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; - renderPipelineStateDescriptor.colorAttachments[i].rgbBlendOperation = m_blendState[0].rgbBlendOp; - renderPipelineStateDescriptor.colorAttachments[i].sourceRGBBlendFactor = m_blendState[0].srcColorFactor; - renderPipelineStateDescriptor.colorAttachments[i].destinationRGBBlendFactor = m_blendState[0].destColorFactor; - renderPipelineStateDescriptor.colorAttachments[i].alphaBlendOperation = m_blendState[0].alphaBlendOp; - renderPipelineStateDescriptor.colorAttachments[i].sourceAlphaBlendFactor = m_blendState[0].srcAlphaFactor; - renderPipelineStateDescriptor.colorAttachments[i].destinationAlphaBlendFactor = m_blendState[0].destAlphaFactor; + renderPipelineStateDescriptor.colorAttachments[i].blendingEnabled = YES; + renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; + renderPipelineStateDescriptor.colorAttachments[i].rgbBlendOperation = m_blendState[0].rgbBlendOp; + renderPipelineStateDescriptor.colorAttachments[i].sourceRGBBlendFactor = m_blendState[0].srcColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].destinationRGBBlendFactor = + m_blendState[0].destColorFactor; + renderPipelineStateDescriptor.colorAttachments[i].alphaBlendOperation = m_blendState[0].alphaBlendOp; + renderPipelineStateDescriptor.colorAttachments[i].sourceAlphaBlendFactor = + m_blendState[0].srcAlphaFactor; + renderPipelineStateDescriptor.colorAttachments[i].destinationAlphaBlendFactor = + m_blendState[0].destAlphaFactor; } else { renderPipelineStateDescriptor.colorAttachments[i].blendingEnabled = NO; - renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; + renderPipelineStateDescriptor.colorAttachments[i].writeMask = m_blendState[0].writeMask; } if( m_currentRenderPassDescriptor.colorAttachments[i].texture ) { - renderPipelineStateDescriptor.colorAttachments[i].pixelFormat = m_currentRenderPassDescriptor.colorAttachments[i].texture.pixelFormat; + renderPipelineStateDescriptor.colorAttachments[i].pixelFormat = + m_currentRenderPassDescriptor.colorAttachments[i].texture.pixelFormat; // All sample counts should match so doesn't matter if we pick this up multiple times sampleCount = m_currentRenderPassDescriptor.colorAttachments[i].texture.sampleCount; } @@ -1667,7 +1693,8 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( m_currentRenderPassDescriptor.depthAttachment.texture ) { - renderPipelineStateDescriptor.depthAttachmentPixelFormat = m_currentRenderPassDescriptor.depthAttachment.texture.pixelFormat; + renderPipelineStateDescriptor.depthAttachmentPixelFormat = + m_currentRenderPassDescriptor.depthAttachment.texture.pixelFormat; sampleCount = m_currentRenderPassDescriptor.depthAttachment.texture.sampleCount; } else @@ -1677,7 +1704,8 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( m_currentRenderPassDescriptor.stencilAttachment.texture ) { - renderPipelineStateDescriptor.stencilAttachmentPixelFormat = m_currentRenderPassDescriptor.stencilAttachment.texture.pixelFormat; + renderPipelineStateDescriptor.stencilAttachmentPixelFormat = + m_currentRenderPassDescriptor.stencilAttachment.texture.pixelFormat; } else { @@ -1686,20 +1714,20 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Sample count can be derived from multiple sources - they should all be the same however (validation layer will complain if not). renderPipelineStateDescriptor.rasterSampleCount = sampleCount; - renderPipelineStateDescriptor.sampleCount = sampleCount; + renderPipelineStateDescriptor.sampleCount = sampleCount; NSError* error = nil; pipelineState = [m_device newRenderPipelineStateWithDescriptor:renderPipelineStateDescriptor error:&error]; -#if !__has_feature(objc_arc) - [renderPipelineStateDescriptor release]; +#if !__has_feature( objc_arc ) + [renderPipelineStateDescriptor release]; #endif if( !pipelineState ) { CCP_AL_LOGERR( "Failed to created pipeline state. Error: %s", error.localizedDescription.UTF8String ); -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [error release]; #endif return false; @@ -1743,17 +1771,17 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Flush pending render states. - if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_CULLMODE ) - { - [m_currentRenderEncoder setCullMode:m_cullMode]; - m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_CULLMODE; - } + if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_CULLMODE ) + { + [m_currentRenderEncoder setCullMode:m_cullMode]; + m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_CULLMODE; + } - if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_FILLMODE ) - { - [m_currentRenderEncoder setTriangleFillMode:m_fillMode]; - m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_FILLMODE; - } + if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_FILLMODE ) + { + [m_currentRenderEncoder setTriangleFillMode:m_fillMode]; + m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_FILLMODE; + } if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_VIEWPORT ) { @@ -1770,14 +1798,16 @@ inline void hash_combine( std::size_t& seed, const T& v ) { [m_currentRenderEncoder setBlendColorRed:m_blendState[0].blendColor.red green:m_blendState[0].blendColor.green - blue:m_blendState[0].blendColor.blue + blue:m_blendState[0].blendColor.blue alpha:m_blendState[0].blendColor.alpha]; m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_BLENDCOLOR; } if( m_dirtyRenderEncoderState & METAL_RENDERENCODERDIRTYSTATE_DEPTHBIAS ) { - [m_currentRenderEncoder setDepthBias:m_depthBias.depthBias slopeScale:m_depthBias.slopeScale clamp:m_depthBias.clamp]; + [m_currentRenderEncoder setDepthBias:m_depthBias.depthBias + slopeScale:m_depthBias.slopeScale + clamp:m_depthBias.clamp]; m_dirtyRenderEncoderState &= ~METAL_RENDERENCODERDIRTYSTATE_DEPTHBIAS; } @@ -1815,7 +1845,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) { for( int i = 0; i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) { - if( m_currentVertexStreamMask & (1 << i) ) + if( m_currentVertexStreamMask & ( 1 << i ) ) { m_currentVertexDescriptor.layouts[i].stride = m_boundVertexStreams[i].stride; } @@ -1869,8 +1899,8 @@ inline void hash_combine( std::size_t& seed, const T& v ) #if METAL_ENABLE_COMPUTE_STATE_CACHING size_t hashVal = 0; - hash_combine( hashVal, (__bridge void*) m_device ); - hash_combine( hashVal, (__bridge void*) m_computeFunction ); + hash_combine( hashVal, (__bridge void*)m_device ); + hash_combine( hashVal, (__bridge void*)m_computeFunction ); // If this matches the current pipeline state then we should already have the correct pipeline bound. if( hashVal == m_currentComputePipelineDescriptorHash && m_currentComputePipelineState != nil ) @@ -1889,8 +1919,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( !pipelineState ) { - CCP_AL_LOGERR( "Failed to create compute pipeline state. Error: %s", error.localizedDescription.UTF8String ); -#if !__has_feature(objc_arc) + CCP_AL_LOGERR( "Failed to create compute pipeline state. Error: %s", + error.localizedDescription.UTF8String ); +#if !__has_feature( objc_arc ) [error release]; #endif return false; @@ -1969,7 +2000,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::SetRenderAttachments( id texture, uint32_t index, uint32_t slice ) { CCP_ASSERT( m_isPrimary ); - CCP_ASSERT(index < METAL_MAX_RENDER_TARGETS); + CCP_ASSERT( index < METAL_MAX_RENDER_TARGETS ); // Check if there's soemthing to actually do. if( texture == m_currentRenderPassDescriptor.colorAttachments[index].texture ) @@ -1985,17 +2016,18 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( texture ) { - m_currentRenderPassDescriptor.colorAttachments[index].loadAction = MTLLoadActionLoad; + m_currentRenderPassDescriptor.colorAttachments[index].loadAction = MTLLoadActionLoad; m_currentRenderPassDescriptor.colorAttachments[index].storeAction = MTLStoreActionStore; - METAL_LOG(@"Log:SetRenderAttachments [%u] %lux%lu (%lu)", index, texture.width, texture.height, texture.sampleCount); + METAL_LOG( + @"Log:SetRenderAttachments [%u] %lux%lu (%lu)", index, texture.width, texture.height, texture.sampleCount ); m_numRenderAttachments = MAX( m_numRenderAttachments, index + 1 ); } else { - m_currentRenderPassDescriptor.colorAttachments[index].loadAction = MTLLoadActionDontCare; + m_currentRenderPassDescriptor.colorAttachments[index].loadAction = MTLLoadActionDontCare; m_currentRenderPassDescriptor.colorAttachments[index].storeAction = MTLStoreActionDontCare; - METAL_LOG(@"Log:SetRenderAttachments [%u] to nil", index); + METAL_LOG( @"Log:SetRenderAttachments [%u] to nil", index ); uint32_t i = m_numRenderAttachments; @@ -2065,17 +2097,20 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( depthTexture ) { - m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionLoad; + m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionLoad; m_currentRenderPassDescriptor.depthAttachment.storeAction = MTLStoreActionStore; - METAL_LOG(@"Log:SetDepthStencilAttachment - depth %lux%lu (%lu)", texture.width, texture.height, texture.sampleCount); + METAL_LOG( @"Log:SetDepthStencilAttachment - depth %lux%lu (%lu)", + texture.width, + texture.height, + texture.sampleCount ); } else { - m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionDontCare; + m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionDontCare; m_currentRenderPassDescriptor.depthAttachment.storeAction = MTLStoreActionDontCare; - METAL_LOG(@"Log:SetDepthStencilAttachment - depth to nil"); + METAL_LOG( @"Log:SetDepthStencilAttachment - depth to nil" ); } // Make sure depthWriteEnabled state will be recalculated. @@ -2091,19 +2126,22 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( stencilTexture ) { - m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionLoad; + m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionLoad; m_currentRenderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionStore; - METAL_LOG(@"Log:SetDepthStencilAttachment - stencil %lux%lu (%lu)", texture.width, texture.height, texture.sampleCount); + METAL_LOG( @"Log:SetDepthStencilAttachment - stencil %lux%lu (%lu)", + texture.width, + texture.height, + texture.sampleCount ); } else { - m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionDontCare; + m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionDontCare; m_currentRenderPassDescriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; SetStencilState( false ); - METAL_LOG(@"Log:SetDepthStencilAttachment - stencil to nil"); + METAL_LOG( @"Log:SetDepthStencilAttachment - stencil to nil" ); } m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_ATTACHMENTS; @@ -2112,17 +2150,16 @@ inline void hash_combine( std::size_t& seed, const T& v ) SetRenderTargetSizedScissorRect(); } -void MetalWorkQueue::SetShaders( - id vertexFunction, - id fragmentFunction, - id computeFunction, - MTLSize threadGroupSize, - const ShaderResourceMask* resourceMasks ) +void MetalWorkQueue::SetShaders( id vertexFunction, + id fragmentFunction, + id computeFunction, + MTLSize threadGroupSize, + const ShaderResourceMask* resourceMasks ) { - m_vertexFunction = vertexFunction; + m_vertexFunction = vertexFunction; m_fragmentFunction = fragmentFunction; - m_computeFunction = computeFunction; - m_threadGroupSize = threadGroupSize; + m_computeFunction = computeFunction; + m_threadGroupSize = threadGroupSize; m_shaderResourceMasks = resourceMasks; } @@ -2144,18 +2181,21 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::SetFillMode( MTLTriangleFillMode fillMode ) { - if( m_fillMode != fillMode ) - { - m_fillMode = fillMode; - m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_FILLMODE; - } + if( m_fillMode != fillMode ) + { + m_fillMode = fillMode; + m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_FILLMODE; + } } -void MetalWorkQueue::SetDepthBias( float *depthBias, float *slopeScale, float *clamp ) +void MetalWorkQueue::SetDepthBias( float* depthBias, float* slopeScale, float* clamp ) { - if (depthBias) m_depthBias.depthBias = *depthBias; - if (slopeScale) m_depthBias.slopeScale = *slopeScale; - if (clamp) m_depthBias.clamp = *clamp; + if( depthBias ) + m_depthBias.depthBias = *depthBias; + if( slopeScale ) + m_depthBias.slopeScale = *slopeScale; + if( clamp ) + m_depthBias.clamp = *clamp; m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_DEPTHBIAS; } @@ -2258,10 +2298,8 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::SetStencilMask( uint32_t mask ) { - if( m_frontFaceStencilDescriptor.readMask != mask || - m_frontFaceStencilDescriptor.writeMask != mask || - m_backFaceStencilDescriptor.readMask != mask || - m_backFaceStencilDescriptor.writeMask != mask ) + if( m_frontFaceStencilDescriptor.readMask != mask || m_frontFaceStencilDescriptor.writeMask != mask || + m_backFaceStencilDescriptor.readMask != mask || m_backFaceStencilDescriptor.writeMask != mask ) { m_frontFaceStencilDescriptor.readMask = mask; m_frontFaceStencilDescriptor.writeMask = mask; @@ -2273,11 +2311,11 @@ inline void hash_combine( std::size_t& seed, const T& v ) } } -void MetalWorkQueue::SetBlendColor( uint32_t attachmentIndex, uint32_t blendColor ) +void MetalWorkQueue::SetBlendColor( uint32_t attachmentIndex, uint32_t blendColor ) { - m_blendState[attachmentIndex].blendColor.red = float( ( blendColor >> 0 ) & 0xff ) / 255.f; - m_blendState[attachmentIndex].blendColor.green = float( ( blendColor >> 8 ) & 0xff ) / 255.f; - m_blendState[attachmentIndex].blendColor.blue = float( ( blendColor >> 16 ) & 0xff ) / 255.f; + m_blendState[attachmentIndex].blendColor.red = float( ( blendColor >> 0 ) & 0xff ) / 255.f; + m_blendState[attachmentIndex].blendColor.green = float( ( blendColor >> 8 ) & 0xff ) / 255.f; + m_blendState[attachmentIndex].blendColor.blue = float( ( blendColor >> 16 ) & 0xff ) / 255.f; m_blendState[attachmentIndex].blendColor.alpha = float( ( blendColor >> 24 ) & 0xff ) / 255.f; m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_BLENDCOLOR; @@ -2355,26 +2393,30 @@ inline void hash_combine( std::size_t& seed, const T& v ) } } -void MetalWorkQueue::SetConstants( Tr2RenderContextEnum::ShaderType shaderType, const void* constantBuffer, uint32_t size, ConstantBufferToken& token, uint32_t bufferIndex ) +void MetalWorkQueue::SetConstants( Tr2RenderContextEnum::ShaderType shaderType, + const void* constantBuffer, + uint32_t size, + ConstantBufferToken& token, + uint32_t bufferIndex ) { CCP_ASSERT( bufferIndex < METAL_CONST_BUFFER_COUNT ); ConstantBuffer& bufferSlot = m_constBuffers[shaderType][bufferIndex]; - uint32_t flag = (1 << bufferIndex); + uint32_t flag = ( 1 << bufferIndex ); + + UploadConstants( constantBuffer, size, token ); + uint32_t page, offset; + uint64_t offs = token.offset; - UploadConstants( constantBuffer, size, token ); - uint32_t page, offset; - uint64_t offs = token.offset; - - page = uint32_t( offs >> 32 ); - offset = uint32_t( offs & 0xffffffff ); + page = uint32_t( offs >> 32 ); + offset = uint32_t( offs & 0xffffffff ); - if( bufferSlot.offset != offset || bufferSlot.page != page ) + if( bufferSlot.offset != offset || bufferSlot.page != page ) { - if( bufferSlot.page != page ) - { - m_dirtyConstBufferPageMask[shaderType] |= flag; - } + if( bufferSlot.page != page ) + { + m_dirtyConstBufferPageMask[shaderType] |= flag; + } bufferSlot = { page, offset }; m_dirtyConstBuffersMask[shaderType] |= flag; } @@ -2383,23 +2425,27 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::UploadConstants( const void* constantBuffer, uint32_t size, ConstantBufferToken& token ) { - auto frameNo = m_context->GetRecordingFrameNumber(); - if( token.frame != frameNo ) - { - auto& allocator = m_context->GetConstantBufferAllocator(); - auto entry = allocator.Allocate( constantBuffer, size ); - token.offset = uint64_t( entry.offset ) | ( uint64_t( entry.page ) << 32 ); - token.frame = frameNo; - } + auto frameNo = m_context->GetRecordingFrameNumber(); + if( token.frame != frameNo ) + { + auto& allocator = m_context->GetConstantBufferAllocator(); + auto entry = allocator.Allocate( constantBuffer, size ); + token.offset = uint64_t( entry.offset ) | ( uint64_t( entry.page ) << 32 ); + token.frame = frameNo; + } } -void MetalWorkQueue::SetBuffers( Tr2RenderContextEnum::ShaderType shaderType, const id* buffers, uint32_t buffersMask, id heapView, uint32_t heapViewMask ) +void MetalWorkQueue::SetBuffers( Tr2RenderContextEnum::ShaderType shaderType, + const id* buffers, + uint32_t buffersMask, + id heapView, + uint32_t heapViewMask ) { static_assert( sizeof( buffersMask ) * 8 >= METAL_MAX_BOUND_BUFFERS ); CCP_ASSERT( ( buffersMask & METAL_VERTEX_STREAM_BUFFER_MASK ) == 0 ); - static_assert( sizeof( heapViewMask ) * 8 >= METAL_MAX_BOUND_BUFFERS ); - CCP_ASSERT( ( heapViewMask & METAL_VERTEX_STREAM_BUFFER_MASK ) == 0 ); + static_assert( sizeof( heapViewMask ) * 8 >= METAL_MAX_BOUND_BUFFERS ); + CCP_ASSERT( ( heapViewMask & METAL_VERTEX_STREAM_BUFFER_MASK ) == 0 ); if( buffersMask == 0 && heapViewMask == 0 ) { @@ -2421,28 +2467,31 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_dirtyBuffersMask[shaderType] |= flag; } } - mask = heapViewMask; - while( mask ) - { - int i = __builtin_ctz( mask ); - uint32_t flag = ( 1 << i ); + mask = heapViewMask; + while( mask ) + { + int i = __builtin_ctz( mask ); + uint32_t flag = ( 1 << i ); - mask &= ~flag; + mask &= ~flag; - MetalBuffer& bufferSlot = m_buffers[shaderType][i]; - if( bufferSlot.buffer != heapView ) - { - bufferSlot = { heapView, 0 }; - m_dirtyBuffersMask[shaderType] |= flag; - } - } + MetalBuffer& bufferSlot = m_buffers[shaderType][i]; + if( bufferSlot.buffer != heapView ) + { + bufferSlot = { heapView, 0 }; + m_dirtyBuffersMask[shaderType] |= flag; + } + } // Override all active buffers except stream buffers. uint32_t oldActiveBuffersMask = m_activeBuffersMask[shaderType]; - m_activeBuffersMask[shaderType] = buffersMask | heapViewMask | ( m_activeBuffersMask[shaderType] & METAL_VERTEX_STREAM_BUFFER_MASK ); + m_activeBuffersMask[shaderType] = + buffersMask | heapViewMask | ( m_activeBuffersMask[shaderType] & METAL_VERTEX_STREAM_BUFFER_MASK ); } -void MetalWorkQueue::SetTextures( Tr2RenderContextEnum::ShaderType shaderType, const id* textures, NSRange texturesRange ) +void MetalWorkQueue::SetTextures( Tr2RenderContextEnum::ShaderType shaderType, + const id* textures, + NSRange texturesRange ) { CCP_ASSERT( NSMaxRange( texturesRange ) <= METAL_MAX_BOUND_TEXTURES ); @@ -2461,7 +2510,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) } } -void MetalWorkQueue::SetSamplers( Tr2RenderContextEnum::ShaderType shaderType, const id* samplers, NSRange samplersRange ) +void MetalWorkQueue::SetSamplers( Tr2RenderContextEnum::ShaderType shaderType, + const id* samplers, + NSRange samplersRange ) { CCP_ASSERT( NSMaxRange( samplersRange ) <= METAL_MAX_BOUND_SAMPLERS ); @@ -2494,13 +2545,13 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_activeConstBuffersMask[shaderType] = 0; m_activeBuffersMask[shaderType] = 0; m_dirtyConstBuffersMask[shaderType] = ~0u; - m_dirtyConstBufferPageMask[shaderType] = ~0u; + m_dirtyConstBufferPageMask[shaderType] = ~0u; m_dirtyBuffersMask[shaderType] = ~0u; } void MetalWorkQueue::ResetTextures( Tr2RenderContextEnum::ShaderType shaderType ) { - const size_t size = sizeof(m_textures[shaderType]) / sizeof(*m_textures[shaderType]); + const size_t size = sizeof( m_textures[shaderType] ) / sizeof( *m_textures[shaderType] ); for( size_t i = 0; i < size; ++i ) { m_textures[shaderType][i] = nil; @@ -2511,7 +2562,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::ResetSamplers( Tr2RenderContextEnum::ShaderType shaderType ) { - const size_t size = sizeof(m_samplers[shaderType]) / sizeof(*m_samplers[shaderType]); + const size_t size = sizeof( m_samplers[shaderType] ) / sizeof( *m_samplers[shaderType] ); for( size_t i = 0; i < size; ++i ) { m_samplers[shaderType][i] = nil; @@ -2524,9 +2575,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) { CCP_ASSERT( stream < METAL_VERTEX_STREAM_BUFFER_COUNT ); const uint32_t bufferIndex = METAL_VERTEX_STREAM_BUFFER_OFFSET + stream; - + auto& boundBuffer = m_buffers[VERTEX_SHADER][bufferIndex]; - + if( boundBuffer.buffer == buffer && boundBuffer.offset == offset && m_boundVertexStreams[stream].stride == stride ) { return; @@ -2546,13 +2597,15 @@ inline void hash_combine( std::size_t& seed, const T& v ) } } -void MetalWorkQueue::SetCurrentVertexDescriptor( MTLVertexDescriptor* vertexDescriptor, uint8_t vertexStreamMask, size_t baseHash ) +void MetalWorkQueue::SetCurrentVertexDescriptor( MTLVertexDescriptor* vertexDescriptor, + uint8_t vertexStreamMask, + size_t baseHash ) { if( m_currentVertexDescriptor != vertexDescriptor || m_currentVertexStreamMask != vertexStreamMask ) { m_currentVertexDescriptor = vertexDescriptor; m_currentVertexStreamMask = vertexStreamMask; - m_currentVertexDescriptorBaseHash = baseHash; + m_currentVertexDescriptorBaseHash = baseHash; m_dirtyRenderEncoderState |= METAL_RENDERENCODERDIRTYSTATE_VERTEXDESCRIPTOR; } @@ -2564,7 +2617,8 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Bind buffers (excluding constant buffers). uint32_t dirtyMask = m_dirtyBuffersMask[VERTEX_SHADER]; - uint32_t mask = dirtyMask & m_activeBuffersMask[VERTEX_SHADER] & ( m_shaderResourceMasks[VERTEX_SHADER].bufferMask | METAL_VERTEX_STREAM_BUFFER_MASK ); + uint32_t mask = dirtyMask & m_activeBuffersMask[VERTEX_SHADER] & + ( m_shaderResourceMasks[VERTEX_SHADER].bufferMask | METAL_VERTEX_STREAM_BUFFER_MASK ); while( mask ) { int i = __builtin_ctz( mask ); @@ -2573,7 +2627,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) mask &= ~flag; m_dirtyBuffersMask[VERTEX_SHADER] &= ~flag; m_dirtyConstBuffersMask[VERTEX_SHADER] |= flag; - m_dirtyConstBufferPageMask[VERTEX_SHADER] |= flag; + m_dirtyConstBufferPageMask[VERTEX_SHADER] |= flag; [m_currentRenderEncoder setVertexBuffer:m_buffers[VERTEX_SHADER][i].buffer offset:m_buffers[VERTEX_SHADER][i].offset @@ -2582,8 +2636,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Bind constant buffers. dirtyMask = m_dirtyConstBuffersMask[VERTEX_SHADER]; - mask = dirtyMask & m_activeConstBuffersMask[VERTEX_SHADER] & m_shaderResourceMasks[VERTEX_SHADER].constantBufferMask; - auto& allocator = m_context->GetConstantBufferAllocator(); + mask = + dirtyMask & m_activeConstBuffersMask[VERTEX_SHADER] & m_shaderResourceMasks[VERTEX_SHADER].constantBufferMask; + auto& allocator = m_context->GetConstantBufferAllocator(); while( mask ) { int i = __builtin_ctz( mask ); @@ -2593,18 +2648,16 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_dirtyConstBuffersMask[VERTEX_SHADER] &= ~flag; m_dirtyBuffersMask[VERTEX_SHADER] |= flag; - auto& cbd = m_constBuffers[VERTEX_SHADER][i]; - if( ( m_dirtyConstBufferPageMask[VERTEX_SHADER] & flag ) != 0 ) - { - m_dirtyConstBufferPageMask[VERTEX_SHADER] &= ~flag; - [m_currentRenderEncoder setVertexBuffer:allocator.GetPage( cbd.page ) - offset:cbd.offset - atIndex:i]; - } - else - { - [m_currentRenderEncoder setVertexBufferOffset:cbd.offset atIndex:i]; - } + auto& cbd = m_constBuffers[VERTEX_SHADER][i]; + if( ( m_dirtyConstBufferPageMask[VERTEX_SHADER] & flag ) != 0 ) + { + m_dirtyConstBufferPageMask[VERTEX_SHADER] &= ~flag; + [m_currentRenderEncoder setVertexBuffer:allocator.GetPage( cbd.page ) offset:cbd.offset atIndex:i]; + } + else + { + [m_currentRenderEncoder setVertexBufferOffset:cbd.offset atIndex:i]; + } } dirtyMask = m_dirtyTexturesMask[VERTEX_SHADER]; @@ -2612,7 +2665,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2626,7 +2679,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2646,12 +2699,12 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; m_dirtyBuffersMask[PIXEL_SHADER] &= ~flag; - m_dirtyConstBuffersMask[PIXEL_SHADER] |= flag; - m_dirtyConstBufferPageMask[PIXEL_SHADER] |= flag; + m_dirtyConstBuffersMask[PIXEL_SHADER] |= flag; + m_dirtyConstBufferPageMask[PIXEL_SHADER] |= flag; [m_currentRenderEncoder setFragmentBuffer:m_buffers[PIXEL_SHADER][i].buffer offset:m_buffers[PIXEL_SHADER][i].offset @@ -2661,28 +2714,26 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Bind constant buffers. dirtyMask = m_dirtyConstBuffersMask[PIXEL_SHADER]; mask = dirtyMask & m_activeConstBuffersMask[PIXEL_SHADER] & m_shaderResourceMasks[PIXEL_SHADER].constantBufferMask; - auto& allocator = m_context->GetConstantBufferAllocator(); + auto& allocator = m_context->GetConstantBufferAllocator(); while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; m_dirtyConstBuffersMask[PIXEL_SHADER] &= ~flag; m_dirtyBuffersMask[PIXEL_SHADER] |= flag; - auto& cbd = m_constBuffers[PIXEL_SHADER][i]; - if( ( m_dirtyConstBufferPageMask[PIXEL_SHADER] & flag ) != 0 ) - { - m_dirtyConstBufferPageMask[PIXEL_SHADER] &= ~flag; - [m_currentRenderEncoder setFragmentBuffer:allocator.GetPage( cbd.page ) - offset:cbd.offset - atIndex:i]; - } - else - { - [m_currentRenderEncoder setFragmentBufferOffset:cbd.offset atIndex:i]; - } + auto& cbd = m_constBuffers[PIXEL_SHADER][i]; + if( ( m_dirtyConstBufferPageMask[PIXEL_SHADER] & flag ) != 0 ) + { + m_dirtyConstBufferPageMask[PIXEL_SHADER] &= ~flag; + [m_currentRenderEncoder setFragmentBuffer:allocator.GetPage( cbd.page ) offset:cbd.offset atIndex:i]; + } + else + { + [m_currentRenderEncoder setFragmentBufferOffset:cbd.offset atIndex:i]; + } } dirtyMask = m_dirtyTexturesMask[PIXEL_SHADER]; @@ -2690,7 +2741,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2704,7 +2755,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2725,12 +2776,12 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; m_dirtyBuffersMask[COMPUTE_SHADER] &= ~flag; m_dirtyConstBuffersMask[COMPUTE_SHADER] |= flag; - m_dirtyConstBufferPageMask[COMPUTE_SHADER] |= flag; + m_dirtyConstBufferPageMask[COMPUTE_SHADER] |= flag; [m_currentComputeEncoder setBuffer:m_buffers[COMPUTE_SHADER][i].buffer offset:m_buffers[COMPUTE_SHADER][i].offset @@ -2739,29 +2790,28 @@ inline void hash_combine( std::size_t& seed, const T& v ) // Bind constant buffers. dirtyMask = m_dirtyConstBuffersMask[COMPUTE_SHADER]; - mask = dirtyMask & m_activeConstBuffersMask[COMPUTE_SHADER] & m_shaderResourceMasks[COMPUTE_SHADER].constantBufferMask; - auto& allocator = m_context->GetConstantBufferAllocator(); + mask = + dirtyMask & m_activeConstBuffersMask[COMPUTE_SHADER] & m_shaderResourceMasks[COMPUTE_SHADER].constantBufferMask; + auto& allocator = m_context->GetConstantBufferAllocator(); while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; m_dirtyConstBuffersMask[COMPUTE_SHADER] &= ~flag; m_dirtyBuffersMask[COMPUTE_SHADER] |= flag; - auto& cbd = m_constBuffers[COMPUTE_SHADER][i]; - if( ( m_dirtyConstBufferPageMask[COMPUTE_SHADER] & flag ) != 0 ) - { - m_dirtyConstBufferPageMask[COMPUTE_SHADER] &= ~flag; - [m_currentComputeEncoder setBuffer:allocator.GetPage( cbd.page ) - offset:cbd.offset - atIndex:i]; - } - else - { - [m_currentComputeEncoder setBufferOffset:cbd.offset atIndex:i]; - } + auto& cbd = m_constBuffers[COMPUTE_SHADER][i]; + if( ( m_dirtyConstBufferPageMask[COMPUTE_SHADER] & flag ) != 0 ) + { + m_dirtyConstBufferPageMask[COMPUTE_SHADER] &= ~flag; + [m_currentComputeEncoder setBuffer:allocator.GetPage( cbd.page ) offset:cbd.offset atIndex:i]; + } + else + { + [m_currentComputeEncoder setBufferOffset:cbd.offset atIndex:i]; + } } dirtyMask = m_dirtyTexturesMask[COMPUTE_SHADER]; @@ -2769,7 +2819,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2783,7 +2833,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) while( mask ) { int i = __builtin_ctz( mask ); - uint32_t flag = (1 << i); + uint32_t flag = ( 1 << i ); mask &= ~flag; dirtyMask &= ~flag; @@ -2793,14 +2843,17 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_dirtySamplersMask[COMPUTE_SHADER] = dirtyMask; } -void MetalWorkQueue::ClearAttachment( MTLClearColor *clearColor, float *clearDepth, uint32_t *clearStencil, uint32_t attachmentIndex ) +void MetalWorkQueue::ClearAttachment( MTLClearColor* clearColor, + float* clearDepth, + uint32_t* clearStencil, + uint32_t attachmentIndex ) { CCP_ASSERT( m_isPrimary ); if( m_hasPendingRenderPassHint ) { return; } - + // If we have a current encoder release it and end it (so we can set some new clear state) FlushOutstandingOperations(); @@ -2814,34 +2867,31 @@ inline void hash_combine( std::size_t& seed, const T& v ) if( clearDepth ) { - m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionClear; - m_currentRenderPassDescriptor.depthAttachment.clearDepth = *clearDepth; + m_currentRenderPassDescriptor.depthAttachment.loadAction = MTLLoadActionClear; + m_currentRenderPassDescriptor.depthAttachment.clearDepth = *clearDepth; } if( clearStencil ) { - m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionClear; + m_currentRenderPassDescriptor.stencilAttachment.loadAction = MTLLoadActionClear; m_currentRenderPassDescriptor.stencilAttachment.clearStencil = *clearStencil; } m_pendingClear = true; } -void MetalWorkQueue::DrawPrimitives( - MTLPrimitiveType primitiveType, - uint32_t numVertices, - uint32_t startVertex, - uint32_t numInstances, - uint32_t startInstance ) +void MetalWorkQueue::DrawPrimitives( MTLPrimitiveType primitiveType, + uint32_t numVertices, + uint32_t startVertex, + uint32_t numInstances, + uint32_t startInstance ) { id renderEncoder = GetRenderEncoder(); if( EmitRenderEncoderState() ) { if( numInstances <= 1 ) { - [renderEncoder drawPrimitives:primitiveType - vertexStart:startVertex - vertexCount:numVertices]; + [renderEncoder drawPrimitives:primitiveType vertexStart:startVertex vertexCount:numVertices]; } else { @@ -2855,10 +2905,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) ReleaseEncoder( false ); } -void MetalWorkQueue::DrawPrimitives( - MTLPrimitiveType primitiveType, - id indirectBuffer, - uint32_t indirectBufferOffset) +void MetalWorkQueue::DrawPrimitives( MTLPrimitiveType primitiveType, + id indirectBuffer, + uint32_t indirectBufferOffset ) { id renderEncoder = GetRenderEncoder(); if( EmitRenderEncoderState() ) @@ -2867,41 +2916,39 @@ inline void hash_combine( std::size_t& seed, const T& v ) indirectBuffer:indirectBuffer indirectBufferOffset:indirectBufferOffset]; } - ReleaseEncoder(false); + ReleaseEncoder( false ); } -void MetalWorkQueue::DrawIndexedPrimitives( - MTLPrimitiveType primitiveType, - uint32_t numIndices, - MTLIndexType indexType, - id indexBuffer, - uint32_t startIndex, - uint32_t numInstances, - int32_t baseVertex, - uint32_t baseInstance ) +void MetalWorkQueue::DrawIndexedPrimitives( MTLPrimitiveType primitiveType, + uint32_t numIndices, + MTLIndexType indexType, + id indexBuffer, + uint32_t startIndex, + uint32_t numInstances, + int32_t baseVertex, + uint32_t baseInstance ) { id renderEncoder = GetRenderEncoder(); if( EmitRenderEncoderState() ) { - [renderEncoder drawIndexedPrimitives:primitiveType - indexCount:numIndices - indexType:indexType - indexBuffer:indexBuffer - indexBufferOffset:startIndex * ( indexType == MTLIndexTypeUInt16 ? 2 : 4 ) - instanceCount:MAX(1, numInstances) - baseVertex:baseVertex - baseInstance:baseInstance]; + [renderEncoder drawIndexedPrimitives:primitiveType + indexCount:numIndices + indexType:indexType + indexBuffer:indexBuffer + indexBufferOffset:startIndex * ( indexType == MTLIndexTypeUInt16 ? 2 : 4 ) + instanceCount:MAX( 1, numInstances ) + baseVertex:baseVertex + baseInstance:baseInstance]; } - ReleaseEncoder(false); + ReleaseEncoder( false ); } -void MetalWorkQueue::DrawIndexedPrimitives( - MTLPrimitiveType primitiveType, - MTLIndexType indexType, - id indexBuffer, - uint32_t indexBufferOffset, - id indirectBuffer, - uint32_t indirectBufferOffset ) +void MetalWorkQueue::DrawIndexedPrimitives( MTLPrimitiveType primitiveType, + MTLIndexType indexType, + id indexBuffer, + uint32_t indexBufferOffset, + id indirectBuffer, + uint32_t indirectBufferOffset ) { id renderEncoder = GetRenderEncoder(); if( EmitRenderEncoderState() ) @@ -2913,7 +2960,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) indirectBuffer:indirectBuffer indirectBufferOffset:indirectBufferOffset]; } - ReleaseEncoder(false); + ReleaseEncoder( false ); } void MetalWorkQueue::CreateVisibilityQueryBuffer( uint64_t maxNumQueries ) @@ -2973,20 +3020,22 @@ inline void hash_combine( std::size_t& seed, const T& v ) ReleaseEncoder( false ); } -bool MetalWorkQueue::GetVisibilityQueryPixelCount( uint64_t queryNumber, uint64_t *pixelCount, bool finishOutstandingWork ) +bool MetalWorkQueue::GetVisibilityQueryPixelCount( uint64_t queryNumber, + uint64_t* pixelCount, + bool finishOutstandingWork ) { CCP_ASSERT( m_isPrimary ); if( finishOutstandingWork ) { FlushOutstandingOperations(); - [m_commandBuffer addCompletedHandler:^(id commandBuffer) { - if (@available(macOS 10.15, *)) - { - auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; - s_gpuFrameTime += duration; - } - }]; - CommitCommandBuffer(MTLCBCOMMIT_WAITUNTILCOMPLETE); + [m_commandBuffer addCompletedHandler:^( id commandBuffer ) { + if( @available( macOS 10.15, * ) ) + { + auto duration = commandBuffer.GPUEndTime - commandBuffer.GPUStartTime; + s_gpuFrameTime += duration; + } + }]; + CommitCommandBuffer( MTLCBCOMMIT_WAITUNTILCOMPLETE ); } // See if this query has completed yet. @@ -3038,165 +3087,175 @@ inline void hash_combine( std::size_t& seed, const T& v ) ReleaseEncoder( false ); } -ConstantBufferAllocator::Entry MetalWorkQueue::UploadArgumentBuffer( const Tr2ShaderSignatureAL& signature, std::vector>& readResources, std::vector>& writeResources ) const -{ - if (@available(macOS 13.0, *)) - { - auto& allocator = m_context->GetConstantBufferAllocator(); - std::vector data; - - for( auto& reg : signature.registers ) - { - switch( reg.registerType ) - { - case Tr2ShaderRegisterAL::CONSTANT_BUFFER: - { - auto& cbd = m_constBuffers[COMPUTE_SHADER][METAL_CONST_BUFFER_OFFSET + reg.registerIndex]; - data.push_back( allocator.GetPage( cbd.page ).gpuAddress + cbd.offset ); - readResources.push_back( allocator.GetPage( cbd.page ) ); - } - break; - case Tr2ShaderRegisterAL::SAMPLER: - data.push_back( m_samplers[COMPUTE_SHADER][reg.registerIndex].gpuResourceID._impl ); - break; - case Tr2ShaderRegisterAL::SRV_BUFFER: - case Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER: - { - auto& buffer = m_buffers[COMPUTE_SHADER][METAL_SRV_BUFFER_OFFSET + reg.registerIndex]; - data.push_back( buffer.buffer.gpuAddress + buffer.offset ); - readResources.push_back( buffer.buffer ); - } - break; - case Tr2ShaderRegisterAL::UAV_BUFFER: - case Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER: - { - auto& buffer = m_buffers[COMPUTE_SHADER][METAL_UAV_BUFFER_OFFSET + reg.registerIndex]; - data.push_back( buffer.buffer.gpuAddress + buffer.offset ); - writeResources.push_back( buffer.buffer ); - } - break; - default: - if( reg.IsUav() ) - { - auto& texture = m_textures[COMPUTE_SHADER][METAL_UAV_TEXTURE_OFFSET + reg.registerIndex]; - data.push_back( texture.gpuResourceID._impl ); - writeResources.push_back( texture ); - } - else - { - auto& texture = m_textures[COMPUTE_SHADER][METAL_SRV_TEXTURE_OFFSET + reg.registerIndex]; - data.push_back( texture.gpuResourceID._impl ); - readResources.push_back( texture ); - } - break; - } - } - return allocator.Allocate( data.data(), uint32_t( data.size() * sizeof( uint64_t ) ) ); - } - else - { - return {}; - } -} - -void MetalWorkQueue::DispatchRays( Tr2RtPipelineStateAL* pipeline, Tr2RtShaderTableAL* shaderTable, uint32_t rayGenIndex, uint32_t width, uint32_t height, uint32_t depth ) -{ - CCP_ASSERT( m_isPrimary ); - if (@available(macOS 13.0, *)) - { - id computeEncoder = GetComputeEncoder(); - - auto& allocator = m_context->GetConstantBufferAllocator(); - - std::vector> readResources; - std::vector> writeResources; - - - [computeEncoder setBuffer:shaderTable->GetMaterialBuffer() offset:shaderTable->GetRayGenMaterialOffset(rayGenIndex) atIndex:METAL_SRV_BUFFER_OFFSET + 0]; - - - auto globalInputGpu = UploadArgumentBuffer( pipeline->m_globalSignature, readResources, writeResources ); - - [computeEncoder setBuffer:allocator.GetPage( globalInputGpu.page ) offset:globalInputGpu.offset atIndex:METAL_SRV_BUFFER_OFFSET + 1]; - readResources.push_back( allocator.GetPage( globalInputGpu.page ) ); - - auto shaderTableData = shaderTable->GetShaderTableData( rayGenIndex, allocator.GetPage( globalInputGpu.page ).gpuAddress + globalInputGpu.offset ); - auto shaderTableGpu = allocator.Allocate( &shaderTableData, sizeof( shaderTableData ) ); - [computeEncoder setBuffer:allocator.GetPage( shaderTableGpu.page ) offset:shaderTableGpu.offset atIndex:METAL_SRV_BUFFER_OFFSET + 2]; - readResources.push_back( allocator.GetPage( shaderTableGpu.page ) ); - - shaderTable->AddUsedResources( rayGenIndex, readResources ); - - shaderTable->SetGlobalInputBuffer( rayGenIndex, allocator.GetPage( globalInputGpu.page ), globalInputGpu.offset ); - - [computeEncoder useResources:readResources.data() count:readResources.size() usage:MTLResourceUsageRead]; - [computeEncoder useResources:writeResources.data() count:writeResources.size() usage:MTLResourceUsageWrite]; - [computeEncoder setComputePipelineState: pipeline->GetRtPipeline( rayGenIndex ) ]; - - // Launch a rectangular grid of threads on the GPU to perform ray tracing, with one thread per - // pixel. The sample needs to align the number of threads to a multiple of the threadgroup - // size, because earlier, when it created the pipeline objects, it declared that the pipeline - // would always use a threadgroup size that's a multiple of the thread execution width - // (SIMD group size). An 8x8 threadgroup is a safe threadgroup size and small enough to be - // supported on most devices. A more advanced app would choose the threadgroup size dynamically. - MTLSize threadsPerThreadgroup = MTLSizeMake(8, 8, 1); - if(depth > 1) - { - threadsPerThreadgroup = MTLSizeMake(4, 4, 4); - } - - MTLSize threadgroups = MTLSizeMake((width + threadsPerThreadgroup.width - 1) / threadsPerThreadgroup.width, - (height + threadsPerThreadgroup.height - 1) / threadsPerThreadgroup.height, - (depth + threadsPerThreadgroup.depth - 1) / threadsPerThreadgroup.depth); - - // Dispatch the compute kernel to perform ray tracing. - [computeEncoder dispatchThreadgroups:threadgroups threadsPerThreadgroup:threadsPerThreadgroup]; - - ReleaseEncoder( false ); - } +ConstantBufferAllocator::Entry + MetalWorkQueue::UploadArgumentBuffer( const Tr2ShaderSignatureAL& signature, + std::vector>& readResources, + std::vector>& writeResources ) const +{ + if( @available( macOS 13.0, * ) ) + { + auto& allocator = m_context->GetConstantBufferAllocator(); + std::vector data; + + for( auto& reg : signature.registers ) + { + switch( reg.registerType ) + { + case Tr2ShaderRegisterAL::CONSTANT_BUFFER: { + auto& cbd = m_constBuffers[COMPUTE_SHADER][METAL_CONST_BUFFER_OFFSET + reg.registerIndex]; + data.push_back( allocator.GetPage( cbd.page ).gpuAddress + cbd.offset ); + readResources.push_back( allocator.GetPage( cbd.page ) ); + } + break; + case Tr2ShaderRegisterAL::SAMPLER: + data.push_back( m_samplers[COMPUTE_SHADER][reg.registerIndex].gpuResourceID._impl ); + break; + case Tr2ShaderRegisterAL::SRV_BUFFER: + case Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER: { + auto& buffer = m_buffers[COMPUTE_SHADER][METAL_SRV_BUFFER_OFFSET + reg.registerIndex]; + data.push_back( buffer.buffer.gpuAddress + buffer.offset ); + readResources.push_back( buffer.buffer ); + } + break; + case Tr2ShaderRegisterAL::UAV_BUFFER: + case Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER: { + auto& buffer = m_buffers[COMPUTE_SHADER][METAL_UAV_BUFFER_OFFSET + reg.registerIndex]; + data.push_back( buffer.buffer.gpuAddress + buffer.offset ); + writeResources.push_back( buffer.buffer ); + } + break; + default: + if( reg.IsUav() ) + { + auto& texture = m_textures[COMPUTE_SHADER][METAL_UAV_TEXTURE_OFFSET + reg.registerIndex]; + data.push_back( texture.gpuResourceID._impl ); + writeResources.push_back( texture ); + } + else + { + auto& texture = m_textures[COMPUTE_SHADER][METAL_SRV_TEXTURE_OFFSET + reg.registerIndex]; + data.push_back( texture.gpuResourceID._impl ); + readResources.push_back( texture ); + } + break; + } + } + return allocator.Allocate( data.data(), uint32_t( data.size() * sizeof( uint64_t ) ) ); + } + else + { + return {}; + } +} + +void MetalWorkQueue::DispatchRays( Tr2RtPipelineStateAL* pipeline, + Tr2RtShaderTableAL* shaderTable, + uint32_t rayGenIndex, + uint32_t width, + uint32_t height, + uint32_t depth ) +{ + CCP_ASSERT( m_isPrimary ); + if( @available( macOS 13.0, * ) ) + { + id computeEncoder = GetComputeEncoder(); + + auto& allocator = m_context->GetConstantBufferAllocator(); + + std::vector> readResources; + std::vector> writeResources; + + + [computeEncoder setBuffer:shaderTable->GetMaterialBuffer() + offset:shaderTable->GetRayGenMaterialOffset( rayGenIndex ) + atIndex:METAL_SRV_BUFFER_OFFSET + 0]; + + + auto globalInputGpu = UploadArgumentBuffer( pipeline->m_globalSignature, readResources, writeResources ); + + [computeEncoder setBuffer:allocator.GetPage( globalInputGpu.page ) + offset:globalInputGpu.offset + atIndex:METAL_SRV_BUFFER_OFFSET + 1]; + readResources.push_back( allocator.GetPage( globalInputGpu.page ) ); + + auto shaderTableData = shaderTable->GetShaderTableData( + rayGenIndex, allocator.GetPage( globalInputGpu.page ).gpuAddress + globalInputGpu.offset ); + auto shaderTableGpu = allocator.Allocate( &shaderTableData, sizeof( shaderTableData ) ); + [computeEncoder setBuffer:allocator.GetPage( shaderTableGpu.page ) + offset:shaderTableGpu.offset + atIndex:METAL_SRV_BUFFER_OFFSET + 2]; + readResources.push_back( allocator.GetPage( shaderTableGpu.page ) ); + + shaderTable->AddUsedResources( rayGenIndex, readResources ); + + shaderTable->SetGlobalInputBuffer( + rayGenIndex, allocator.GetPage( globalInputGpu.page ), globalInputGpu.offset ); + + [computeEncoder useResources:readResources.data() count:readResources.size() usage:MTLResourceUsageRead]; + [computeEncoder useResources:writeResources.data() count:writeResources.size() usage:MTLResourceUsageWrite]; + [computeEncoder setComputePipelineState:pipeline->GetRtPipeline( rayGenIndex )]; + + // Launch a rectangular grid of threads on the GPU to perform ray tracing, with one thread per + // pixel. The sample needs to align the number of threads to a multiple of the threadgroup + // size, because earlier, when it created the pipeline objects, it declared that the pipeline + // would always use a threadgroup size that's a multiple of the thread execution width + // (SIMD group size). An 8x8 threadgroup is a safe threadgroup size and small enough to be + // supported on most devices. A more advanced app would choose the threadgroup size dynamically. + MTLSize threadsPerThreadgroup = MTLSizeMake( 8, 8, 1 ); + if( depth > 1 ) + { + threadsPerThreadgroup = MTLSizeMake( 4, 4, 4 ); + } + + MTLSize threadgroups = + MTLSizeMake( ( width + threadsPerThreadgroup.width - 1 ) / threadsPerThreadgroup.width, + ( height + threadsPerThreadgroup.height - 1 ) / threadsPerThreadgroup.height, + ( depth + threadsPerThreadgroup.depth - 1 ) / threadsPerThreadgroup.depth ); + + // Dispatch the compute kernel to perform ray tracing. + [computeEncoder dispatchThreadgroups:threadgroups threadsPerThreadgroup:threadsPerThreadgroup]; + + ReleaseEncoder( false ); + } } bool MetalWorkQueue::SampleCounter( id buffer, NSUInteger index, CounterType counter ) { CCP_ASSERT( m_isPrimary ); - if( @available(macOS 10.15, *) ) + if( @available( macOS 10.15, * ) ) { switch( m_currentEncoderType ) { - case MTLENCODERTYPE_RENDER: - { + case MTLENCODERTYPE_RENDER: { [m_currentRenderEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; return true; } - case MTLENCODERTYPE_COMPUTE: - { - if( counter != COUNTER_PIPELINE_STATS ) - { - [m_currentComputeEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; - return true; - } - break; + case MTLENCODERTYPE_COMPUTE: { + if( counter != COUNTER_PIPELINE_STATS ) + { + [m_currentComputeEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; + return true; + } + break; } - case MTLENCODERTYPE_BLIT: - { - if( counter != COUNTER_PIPELINE_STATS ) - { - [m_currentBlitEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; - return true; - } - break; + case MTLENCODERTYPE_BLIT: { + if( counter != COUNTER_PIPELINE_STATS ) + { + [m_currentBlitEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; + return true; + } + break; } - default: - { - id renderEncoder = GetRenderEncoder(); - [renderEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; - ReleaseEncoder(false); - return true; + default: { + id renderEncoder = GetRenderEncoder(); + [renderEncoder sampleCountersInBuffer:buffer atSampleIndex:index withBarrier:YES]; + ReleaseEncoder( false ); + return true; } } } - return false; + return false; } void MetalWorkQueue::PushDebugGroup( const char* name ) @@ -3208,18 +3267,18 @@ inline void hash_combine( std::size_t& seed, const T& v ) } NSString* nsName = [[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding]; [m_commandBuffer pushDebugGroup:nsName]; -#if !__has_feature(objc_arc) +#if !__has_feature( objc_arc ) [nsName release]; #endif } - + void MetalWorkQueue::PopDebugGroup() { CCP_ASSERT( m_isPrimary ); ReleaseEncoder( true ); [m_commandBuffer popDebugGroup]; } - + void MetalWorkQueue::RenderPassHint( const MetalRenderPassHint& hint ) { if( m_hasPendingRenderPassHint ) @@ -3233,17 +3292,17 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::EndRenderPassHint() { - if( m_hasPendingRenderPassHint || m_pendingClear ) - { - GetRenderEncoder(); - ReleaseEncoder( true ); - } + if( m_hasPendingRenderPassHint || m_pendingClear ) + { + GetRenderEncoder(); + ReleaseEncoder( true ); + } } void MetalWorkQueue::BeginParallelEncoding( MetalWorkQueue* primaryQueue ) { m_isPrimary = false; - + id masterEncoder = primaryQueue->GetParallelEncoder(); m_currentRenderEncoder = [masterEncoder renderCommandEncoder]; @@ -3252,74 +3311,74 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_currentRenderPassDescriptor = primaryQueue->m_currentRenderPassDescriptor; m_numRenderAttachments = primaryQueue->m_numRenderAttachments; m_currentAttachmentsHash = primaryQueue->m_currentAttachmentsHash; - + m_vertexFunction = primaryQueue->m_vertexFunction; m_fragmentFunction = primaryQueue->m_fragmentFunction; - - for( int i=0; im_activeConstBuffersMask[i]; m_activeBuffersMask[i] = primaryQueue->m_activeBuffersMask[i]; - - for( int b=0; bm_constBuffers[i][b]; m_buffers[i][b] = primaryQueue->m_buffers[i][b]; } - - for( int t=0; tm_textures[i][t]; } - - for( int s=0; sm_samplers[i][s]; } } - + m_cullMode = primaryQueue->m_cullMode; m_validViewport = primaryQueue->m_validViewport; m_viewport = primaryQueue->m_viewport; m_scissorRect = primaryQueue->m_scissorRect; - + for( uint32_t i = 0; i < METAL_MAX_RENDER_TARGETS; ++i ) { m_blendState[i] = primaryQueue->m_blendState[i]; } - + m_depthStencilDescriptor = [primaryQueue->m_depthStencilDescriptor copy]; m_frontFaceStencilDescriptor = [primaryQueue->m_frontFaceStencilDescriptor copy]; m_backFaceStencilDescriptor = [primaryQueue->m_backFaceStencilDescriptor copy]; - + m_depthBias = primaryQueue->m_depthBias; - + m_currentVertexDescriptor = [primaryQueue->m_currentVertexDescriptor copy]; m_currentVertexDescriptorHash = primaryQueue->m_currentVertexDescriptorHash; - m_currentVertexDescriptorBaseHash = primaryQueue->m_currentVertexDescriptorBaseHash; + m_currentVertexDescriptorBaseHash = primaryQueue->m_currentVertexDescriptorBaseHash; m_currentVertexStreamMask = primaryQueue->m_currentVertexStreamMask; - + for( int i = 0; i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) { m_boundVertexStreams[i] = primaryQueue->m_boundVertexStreams[i]; } - + // Since the encoder is new we'll need to emit all the state again SetRenderStatesDirty(); - + // Mark that this curent encoder is in use m_currentEncoderType = MTLENCODERTYPE_RENDER; - m_encoderInUse = false; - m_encoderEnded = false; - m_encoderHasWork = false; - + m_encoderInUse = false; + m_encoderEnded = false; + m_encoderHasWork = false; + m_numCommands = 0; } void MetalWorkQueue::EndParallelEncoding() { - FlushCachedVertexDescriptors(); - + FlushCachedVertexDescriptors(); + if( m_isPrimary ) { if( m_currentParallelEncoder ) @@ -3332,9 +3391,9 @@ inline void hash_combine( std::size_t& seed, const T& v ) { [m_currentRenderEncoder endEncoding]; m_currentRenderEncoder = nil; - + ResetWorkQueue(); - + m_device = nil; m_commandBuffer = nil; @@ -3345,7 +3404,7 @@ inline void hash_combine( std::size_t& seed, const T& v ) m_frontFaceStencilDescriptor = nil; m_backFaceStencilDescriptor = nil; m_currentVertexDescriptor = nil; - + const ShaderType shaderTypes[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; for( auto shaderType : shaderTypes ) { @@ -3353,23 +3412,22 @@ inline void hash_combine( std::size_t& seed, const T& v ) ResetTextures( shaderType ); ResetSamplers( shaderType ); } - + SetRenderStatesDirty(); - - m_vertexFunction = nil; + + m_vertexFunction = nil; m_fragmentFunction = nil; - m_computeFunction = nil; - m_threadGroupSize = MTLSizeMake( 1, 1, 1 ); + m_computeFunction = nil; + m_threadGroupSize = MTLSizeMake( 1, 1, 1 ); m_shaderResourceMasks = nullptr; - + m_currentVertexDescriptor = nil; - - m_currentRenderPipelineState = nullptr; - m_pipelineQueriesInProgress.clear(); + m_currentRenderPipelineState = nullptr; + m_pipelineQueriesInProgress.clear(); } } - + bool MetalWorkQueue::CanBeginParallelEncoding() const { return !m_visibilityQueryInProgress; @@ -3377,53 +3435,61 @@ inline void hash_combine( std::size_t& seed, const T& v ) void MetalWorkQueue::PipelineQueryStarted( Tr2PipelineStatsQueryAL* query ) { - m_pipelineQueriesInProgress.push_back( query ); + m_pipelineQueriesInProgress.push_back( query ); } void MetalWorkQueue::PipelineQueryEnded( Tr2PipelineStatsQueryAL* query ) { - auto found = std::find( begin( m_pipelineQueriesInProgress ), end( m_pipelineQueriesInProgress ), query ); - if( found != end( m_pipelineQueriesInProgress ) ) - { - m_pipelineQueriesInProgress.erase( found ); - } + auto found = std::find( begin( m_pipelineQueriesInProgress ), end( m_pipelineQueriesInProgress ), query ); + if( found != end( m_pipelineQueriesInProgress ) ) + { + m_pipelineQueriesInProgress.erase( found ); + } } -MTLVertexDescriptor* MetalWorkQueue::GetCachedVertexDescriptor( Tr2VertexLayoutAL* layout, size_t inputHash, uint8_t& streamMask, bool& needsDummyStream ) const +MTLVertexDescriptor* MetalWorkQueue::GetCachedVertexDescriptor( Tr2VertexLayoutAL* layout, + size_t inputHash, + uint8_t& streamMask, + bool& needsDummyStream ) const { - for( auto& desc : m_cachedVertexLayouts ) - { - if( desc.layout == layout && desc.inputHash == inputHash ) - { - streamMask = desc.streamMask; - needsDummyStream = desc.needsDummyStream; - return desc.descriptor; - } - } - return nullptr; + for( auto& desc : m_cachedVertexLayouts ) + { + if( desc.layout == layout && desc.inputHash == inputHash ) + { + streamMask = desc.streamMask; + needsDummyStream = desc.needsDummyStream; + return desc.descriptor; + } + } + return nullptr; } -void MetalWorkQueue::CacheVertexDescriptor( Tr2VertexLayoutAL* layout, size_t inputHash, MTLVertexDescriptor* descriptor, uint8_t streamMask, bool needsDummyStream ) +void MetalWorkQueue::CacheVertexDescriptor( Tr2VertexLayoutAL* layout, + size_t inputHash, + MTLVertexDescriptor* descriptor, + uint8_t streamMask, + bool needsDummyStream ) { - m_cachedVertexLayouts.push_back( { layout, inputHash, descriptor, streamMask, needsDummyStream } ); + m_cachedVertexLayouts.push_back( { layout, inputHash, descriptor, streamMask, needsDummyStream } ); } void MetalWorkQueue::FlushCachedVertexDescriptors() { - for( auto& desc : m_cachedVertexLayouts ) - { - desc.layout->AddVertexDescriptor( desc.inputHash, desc.descriptor, desc.streamMask, desc.needsDummyStream ); - } - m_cachedVertexLayouts.clear(); + for( auto& desc : m_cachedVertexLayouts ) + { + desc.layout->AddVertexDescriptor( desc.inputHash, desc.descriptor, desc.streamMask, desc.needsDummyStream ); + } + m_cachedVertexLayouts.clear(); } uint64_t MetalWorkQueue::GetCurrentEncoderIndex() const { - return m_encoderIndex; + return m_encoderIndex; } -bool MetalWorkQueue::IsSilicon() const { - return m_isAppleSilicon; +bool MetalWorkQueue::IsSilicon() const +{ + return m_isAppleSilicon; } } diff --git a/trinityal/metal/Tr2BufferALMetal.h b/trinityal/metal/Tr2BufferALMetal.h index 80603d4df..cf2615d9c 100644 --- a/trinityal/metal/Tr2BufferALMetal.h +++ b/trinityal/metal/Tr2BufferALMetal.h @@ -10,60 +10,69 @@ namespace TrinityALImpl { - class Tr2BufferAL : public Tr2DeviceResourceAL - { - public: - Tr2BufferAL(); - ~Tr2BufferAL(); - - ALResult Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); +class Tr2BufferAL : public Tr2DeviceResourceAL +{ +public: + Tr2BufferAL(); + ~Tr2BufferAL(); - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - const Tr2BufferDescriptionAL& GetDesc() const { return m_desc; } + ALResult Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } + const Tr2BufferDescriptionAL& GetDesc() const + { + return m_desc; + } - ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); - ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); - ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - id GetMetalBuffer() { return m_mtlBuffer; } + id GetMetalBuffer() + { + return m_mtlBuffer; + } - uint32_t GetSrvIndexInHeap() const; - uint32_t GetUavIndexInHeap() const; + uint32_t GetSrvIndexInHeap() const; + uint32_t GetUavIndexInHeap() const; - private: - Tr2BufferDescriptionAL m_desc; - Tr2RenderContextAL* m_owner; - MetalContext *m_metalContext; - MTLResourceOptions m_resourceMode; - id m_mtlBuffer; - Tr2MemoryCounterAL m_memory; - uint32_t m_heapIndex; - - uint64_t m_usedInEncoder; +private: + Tr2BufferDescriptionAL m_desc; + Tr2RenderContextAL* m_owner; + MetalContext* m_metalContext; + MTLResourceOptions m_resourceMode; + id m_mtlBuffer; + Tr2MemoryCounterAL m_memory; + uint32_t m_heapIndex; - struct StagingBuffer - { - id buffer; - uint64_t mappedFrameNumber; - }; - std::vector m_stagingBuffers; - id m_mappedBuffer; - std::string m_name; + uint64_t m_usedInEncoder; - friend class ::Tr2RenderContextAL; - friend class Tr2PrimaryRenderContextAL; + struct StagingBuffer + { + id buffer; + uint64_t mappedFrameNumber; }; + std::vector m_stagingBuffers; + id m_mappedBuffer; + std::string m_name; + + friend class ::Tr2RenderContextAL; + friend class Tr2PrimaryRenderContextAL; +}; } #endif diff --git a/trinityal/metal/Tr2BufferALMetal.mm b/trinityal/metal/Tr2BufferALMetal.mm index 3992d9106..fdee804b9 100644 --- a/trinityal/metal/Tr2BufferALMetal.mm +++ b/trinityal/metal/Tr2BufferALMetal.mm @@ -10,339 +10,347 @@ namespace { - template - bool HasFlag( T value, T flag ) - { - return ( value & flag ) == flag; - } +template bool HasFlag( T value, T flag ) +{ + return ( value & flag ) == flag; +} } namespace TrinityALImpl { - Tr2BufferAL::Tr2BufferAL() - : m_owner( nullptr ), - m_metalContext( nullptr ), - m_heapIndex( 0xffffffff ), - m_usedInEncoder( 0 ) - { - } - - Tr2BufferAL::~Tr2BufferAL() - { - Destroy(); - } - - ALResult Tr2BufferAL::Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ) +Tr2BufferAL::Tr2BufferAL() : + m_owner( nullptr ), m_metalContext( nullptr ), m_heapIndex( 0xffffffff ), m_usedInEncoder( 0 ) +{ +} + +Tr2BufferAL::~Tr2BufferAL() +{ + Destroy(); +} + +ALResult Tr2BufferAL::Create( const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( desc.count == 0 ) { - Destroy(); + return E_INVALIDARG; + } - if( desc.count == 0 ) - { - return E_INVALIDARG; - } + if( !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + bool isImmutable = + !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); + if( isImmutable && !initialData ) + { + return E_INVALIDARG; + } - bool isImmutable = !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ); - if( isImmutable && !initialData ) - { - return E_INVALIDARG; - } + if( HasFlag( desc.cpuUsage, Tr2CpuUsage::READ ) && HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + return E_INVALIDARG; + } - if( HasFlag( desc.cpuUsage, Tr2CpuUsage::READ ) && HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - return E_INVALIDARG; - } + auto stride = desc.stride; + if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) + { + stride = GetBytesPerPixel( desc.format ); + } - auto stride = desc.stride; - if( desc.format != Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN ) - { - stride = GetBytesPerPixel( desc.format ); - } + m_metalContext = renderContext.GetMetalContext(); + auto bufferSizeInBytes = desc.count * stride; + + // Default to managed storage. + m_resourceMode = MTLResourceStorageModeManaged; + + if( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && + !HasFlag( desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) + { + // No point keeping a copy on the CPU side if they'll never be modified. + // JM - this needs support in the API to do a blit upload of the data so disabling for now + m_resourceMode = MTLResourceStorageModePrivate; + } - m_metalContext = renderContext.GetMetalContext(); - auto bufferSizeInBytes = desc.count * stride; + m_owner = &renderContext; + m_mtlBuffer = m_metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), bufferSizeInBytes, m_resourceMode, initialData ); + m_desc = desc; + if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || + HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + m_heapIndex = m_metalContext->AllocateHeapIndex( m_mtlBuffer ); + } + m_memory.Set( Tr2MemoryCounterAL::BUFFER, bufferSizeInBytes ); - // Default to managed storage. - m_resourceMode = MTLResourceStorageModeManaged; + return m_mtlBuffer ? S_OK : E_FAIL; +} - if ( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) && !HasFlag( desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) +void Tr2BufferAL::Destroy() +{ + if( m_metalContext ) + { + m_metalContext->DeallocateHeapIndex( m_heapIndex ); + m_metalContext->DestroyMetalBuffer( m_mtlBuffer ); + m_metalContext->DestroyMetalBuffer( m_mappedBuffer ); + for( auto& staging : m_stagingBuffers ) { - // No point keeping a copy on the CPU side if they'll never be modified. - // JM - this needs support in the API to do a blit upload of the data so disabling for now - m_resourceMode = MTLResourceStorageModePrivate; + m_metalContext->DestroyMetalBuffer( staging.buffer ); } + } + m_stagingBuffers.clear(); + m_mtlBuffer = nil; + m_mappedBuffer = nil; + m_metalContext = nil; + m_desc.count = 0; + m_heapIndex = 0xffffffff; + m_owner = nullptr; + m_memory.Reset(); + m_usedInEncoder = 0; +} - m_owner = &renderContext; - m_mtlBuffer = m_metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), bufferSizeInBytes, m_resourceMode, initialData); - m_desc = desc; - if( HasFlag( desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || HasFlag( desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - m_heapIndex = m_metalContext->AllocateHeapIndex( m_mtlBuffer ); - } - m_memory.Set( Tr2MemoryCounterAL::BUFFER, bufferSizeInBytes ); +bool Tr2BufferAL::IsValid() const +{ + return m_mtlBuffer != nil; +} - return m_mtlBuffer ? S_OK : E_FAIL; +ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) + { + data = nullptr; + return E_INVALIDCALL; } + return MapForReading( data, 0, uint32_t( m_mtlBuffer.length ), renderContext ); +} - void Tr2BufferAL::Destroy() +ALResult + Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - if( m_metalContext ) - { - m_metalContext->DeallocateHeapIndex( m_heapIndex ); - m_metalContext->DestroyMetalBuffer(m_mtlBuffer); - m_metalContext->DestroyMetalBuffer(m_mappedBuffer); - for( auto& staging : m_stagingBuffers ) - { - m_metalContext->DestroyMetalBuffer( staging.buffer ); - } - } - m_stagingBuffers.clear(); - m_mtlBuffer = nil; - m_mappedBuffer = nil; - m_metalContext = nil; - m_desc.count = 0; - m_heapIndex = 0xffffffff; - m_owner = nullptr; - m_memory.Reset(); - m_usedInEncoder = 0; + data = nullptr; + return E_INVALIDCALL; } - - bool Tr2BufferAL::IsValid() const + if( size == 0 || offset + size > m_desc.stride * m_desc.count ) { - return m_mtlBuffer != nil; + data = nullptr; + return E_INVALIDARG; } - ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - return MapForReading( data, 0, uint32_t( m_mtlBuffer.length ), renderContext ); + return E_INVALIDCALL; } - ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) - { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( size == 0 || offset + size > m_desc.stride * m_desc.count ) - { - data = nullptr; - return E_INVALIDARG; - } + MetalContext* metalContext = renderContext.GetMetalContext(); - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } + m_mappedBuffer = + metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), size, MTLResourceStorageModeManaged, nil ); + renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mappedBuffer, 0, m_mtlBuffer, offset, size ); + renderContext.GetMetalWorkQueue()->ReadBackBufferToCPU( m_mappedBuffer, true ); - MetalContext *metalContext = renderContext.GetMetalContext(); + m_memory.Grow( m_mappedBuffer.length ); - m_mappedBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), size, MTLResourceStorageModeManaged, nil ); - renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mappedBuffer, 0, m_mtlBuffer, offset, size ); - renderContext.GetMetalWorkQueue()->ReadBackBufferToCPU( m_mappedBuffer, true ); - - m_memory.Grow( m_mappedBuffer.length ); + data = m_mappedBuffer.contents; + return S_OK; +} - data = m_mappedBuffer.contents; - return S_OK; +void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& renderContext ) +{ + if( m_mappedBuffer ) + { + m_memory.Shrink( m_mappedBuffer.length ); + MetalContext* metalContext = renderContext.GetMetalContext(); + metalContext->DestroyMetalBuffer( m_mappedBuffer ); + m_mappedBuffer = nil; } +} - void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& renderContext ) +ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - if( m_mappedBuffer ) - { - m_memory.Shrink( m_mappedBuffer.length ); - MetalContext *metalContext = renderContext.GetMetalContext(); - metalContext->DestroyMetalBuffer( m_mappedBuffer ); - m_mappedBuffer = nil; - } + data = nullptr; + return E_INVALIDCALL; } - - ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) - { - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - m_mappedBuffer = m_mtlBuffer; - for( auto& staging : m_stagingBuffers ) - { - if( staging.buffer == m_mappedBuffer ) - { - staging.mappedFrameNumber = m_metalContext->GetRecordingFrameNumber(); - break; - } - } - data = m_mappedBuffer.contents; - return S_OK; - } - else - { - m_mappedBuffer = m_mtlBuffer; - data = m_mappedBuffer.contents; - return S_OK; - } - } + return E_INVALIDCALL; + } + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) + { if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { + m_mappedBuffer = m_mtlBuffer; for( auto& staging : m_stagingBuffers ) { - if( !m_metalContext->IsResourceInUse( staging.mappedFrameNumber ) ) + if( staging.buffer == m_mappedBuffer ) { staging.mappedFrameNumber = m_metalContext->GetRecordingFrameNumber(); - m_mappedBuffer = staging.buffer; - data = m_mappedBuffer.contents; - return S_OK; + break; } } - m_mappedBuffer = m_metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), m_mtlBuffer.length, MTLResourceStorageModeManaged, nil ); - if( !m_name.empty() ) - { - m_mappedBuffer.label = [NSString stringWithUTF8String:m_name.c_str()]; - } - StagingBuffer staging = { m_mappedBuffer, m_metalContext->GetRecordingFrameNumber() }; - m_stagingBuffers.push_back( staging ); - m_memory.Grow( m_mtlBuffer.length ); + data = m_mappedBuffer.contents; + return S_OK; } else { - m_mappedBuffer = m_metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), m_mtlBuffer.length, MTLResourceStorageModeManaged, nil ); - m_memory.Grow( m_mtlBuffer.length ); + m_mappedBuffer = m_mtlBuffer; + data = m_mappedBuffer.contents; + return S_OK; } - data = m_mappedBuffer.contents; - return S_OK; } - void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - if( !m_mappedBuffer ) - { - return; - } - m_metalContext->IndicateBufferModified( m_mappedBuffer, 0, m_mtlBuffer.length ); - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) - { - m_mappedBuffer = nil; - } - else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + for( auto& staging : m_stagingBuffers ) { - if( HasFlag( m_desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || HasFlag( m_desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mtlBuffer, 0, m_mappedBuffer, 0, m_mtlBuffer.length ); - m_mappedBuffer = nil; - } - else + if( !m_metalContext->IsResourceInUse( staging.mappedFrameNumber ) ) { - m_owner->BufferRewritten( m_mtlBuffer, m_mappedBuffer ); - m_mtlBuffer = m_mappedBuffer; + staging.mappedFrameNumber = m_metalContext->GetRecordingFrameNumber(); + m_mappedBuffer = staging.buffer; + data = m_mappedBuffer.contents; + return S_OK; } } - else + m_mappedBuffer = m_metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), m_mtlBuffer.length, MTLResourceStorageModeManaged, nil ); + if( !m_name.empty() ) { - m_memory.Shrink( m_mappedBuffer.length ); - renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mtlBuffer, 0, m_mappedBuffer, 0, m_mtlBuffer.length ); - m_metalContext->DestroyMetalBuffer( m_mappedBuffer ); - m_mappedBuffer = nil; + m_mappedBuffer.label = [NSString stringWithUTF8String:m_name.c_str()]; } + StagingBuffer staging = { m_mappedBuffer, m_metalContext->GetRecordingFrameNumber() }; + m_stagingBuffers.push_back( staging ); + m_memory.Grow( m_mtlBuffer.length ); } - - ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ) + else { - if( !renderContext.IsValid() || !IsValid() ) - { - return E_INVALIDCALL; - } - if( offset + size > m_desc.count * m_desc.stride ) - { - return E_INVALIDARG; - } - if( size == 0 ) - { - return S_OK; - } + m_mappedBuffer = m_metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), m_mtlBuffer.length, MTLResourceStorageModeManaged, nil ); + m_memory.Grow( m_mtlBuffer.length ); + } + data = m_mappedBuffer.contents; + return S_OK; +} - if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) || HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) - { - void* dest; - CR_RETURN_HR( MapForWriting( dest, renderContext ) ); - uint8_t* dst = static_cast( dest ) + offset; - const uint8_t* src = static_cast( data ); - memcpy( dst, src, size ); - UnmapForWriting( renderContext ); - } - else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) +void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) +{ + if( !m_mappedBuffer ) + { + return; + } + m_metalContext->IndicateBufferModified( m_mappedBuffer, 0, m_mtlBuffer.length ); + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) + { + m_mappedBuffer = nil; + } + else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + if( HasFlag( m_desc.gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) || + HasFlag( m_desc.gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { - id staging = m_metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), size, MTLResourceStorageModeManaged, data ); - renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mtlBuffer, offset, staging, 0, size ); - m_metalContext->DestroyMetalBuffer( staging ); + renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( + m_mtlBuffer, 0, m_mappedBuffer, 0, m_mtlBuffer.length ); + m_mappedBuffer = nil; } else { - return E_INVALIDCALL; + m_owner->BufferRewritten( m_mtlBuffer, m_mappedBuffer ); + m_mtlBuffer = m_mappedBuffer; } + } + else + { + m_memory.Shrink( m_mappedBuffer.length ); + renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mtlBuffer, 0, m_mappedBuffer, 0, m_mtlBuffer.length ); + m_metalContext->DestroyMetalBuffer( m_mappedBuffer ); + m_mappedBuffer = nil; + } +} - +ALResult + Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) + { + return E_INVALIDCALL; + } + if( offset + size > m_desc.count * m_desc.stride ) + { + return E_INVALIDARG; + } + if( size == 0 ) + { return S_OK; } - uint32_t Tr2BufferAL::GetSrvIndexInHeap() const + if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) || + HasFlag( m_desc.cpuUsage, Tr2CpuUsage::NON_SYNCRONIZED_WRITE ) ) { - return m_heapIndex; + void* dest; + CR_RETURN_HR( MapForWriting( dest, renderContext ) ); + uint8_t* dst = static_cast( dest ) + offset; + const uint8_t* src = static_cast( data ); + memcpy( dst, src, size ); + UnmapForWriting( renderContext ); } - - uint32_t Tr2BufferAL::GetUavIndexInHeap() const + else if( HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - return m_heapIndex; + id staging = m_metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), size, MTLResourceStorageModeManaged, data ); + renderContext.GetMetalWorkQueue()->CopyBufferToBuffer( m_mtlBuffer, offset, staging, 0, size ); + m_metalContext->DestroyMetalBuffer( staging ); } - - void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + else { - description["type"] = "Tr2BufferAL"; - description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); - description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); - description["format"] = std::to_string( int( GetDesc().format ) ); - description["stride"] = std::to_string( GetDesc().stride ); - description["count"] = std::to_string( GetDesc().count ); - description["name"] = m_name; + return E_INVALIDCALL; } - ALResult Tr2BufferAL::SetName( const char* name ) + + return S_OK; +} + +uint32_t Tr2BufferAL::GetSrvIndexInHeap() const +{ + return m_heapIndex; +} + +uint32_t Tr2BufferAL::GetUavIndexInHeap() const +{ + return m_heapIndex; +} + +void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2BufferAL"; + description["size"] = std::to_string( GetDesc().count * GetDesc().stride ); + description["cpuUsage"] = std::to_string( int( GetDesc().cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( GetDesc().gpuUsage ) ); + description["format"] = std::to_string( int( GetDesc().format ) ); + description["stride"] = std::to_string( GetDesc().stride ); + description["count"] = std::to_string( GetDesc().count ); + description["name"] = m_name; +} + +ALResult Tr2BufferAL::SetName( const char* name ) +{ + m_name = name; + if( m_mtlBuffer ) { - m_name = name; - if( m_mtlBuffer ) - { - m_mtlBuffer.label = [NSString stringWithUTF8String:name]; - } - for( auto& staging : m_stagingBuffers ) - { - staging.buffer.label = [NSString stringWithUTF8String:name]; - } - return S_OK; + m_mtlBuffer.label = [NSString stringWithUTF8String:name]; + } + for( auto& staging : m_stagingBuffers ) + { + staging.buffer.label = [NSString stringWithUTF8String:name]; } + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2CapsALMetal.h b/trinityal/metal/Tr2CapsALMetal.h index 0786bde9a..c11d1cc4b 100644 --- a/trinityal/metal/Tr2CapsALMetal.h +++ b/trinityal/metal/Tr2CapsALMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #define TRINITY_PLATFORM_SUPPORTS_BUFFER_SHADER_RESOURCES 1 #define TRINITY_PLATFORM_SUPPORTS_BUFFER_COUNTERS 0 @@ -27,12 +27,12 @@ class Tr2CapsAL bool SupportsVariableRefreshRate() const; bool SupportsRaytracing() const; - bool m_supportsRaytracing; - - Tr2CapsAL(); - Tr2CapsAL(const Tr2CapsAL& other); - - Tr2CapsAL& operator=(const Tr2CapsAL& other); + bool m_supportsRaytracing; + + Tr2CapsAL(); + Tr2CapsAL( const Tr2CapsAL& other ); + + Tr2CapsAL& operator=( const Tr2CapsAL& other ); }; #endif diff --git a/trinityal/metal/Tr2CapsALMetal.mm b/trinityal/metal/Tr2CapsALMetal.mm index 38f865df3..928558fcc 100644 --- a/trinityal/metal/Tr2CapsALMetal.mm +++ b/trinityal/metal/Tr2CapsALMetal.mm @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2CapsALMetal.h" @@ -35,18 +35,18 @@ return m_supportsRaytracing; } -Tr2CapsAL::Tr2CapsAL() : m_supportsRaytracing(false) -{} +Tr2CapsAL::Tr2CapsAL() : m_supportsRaytracing( false ) +{ +} -Tr2CapsAL::Tr2CapsAL(const Tr2CapsAL& other) - :m_supportsRaytracing(other.m_supportsRaytracing) +Tr2CapsAL::Tr2CapsAL( const Tr2CapsAL& other ) : m_supportsRaytracing( other.m_supportsRaytracing ) { } -Tr2CapsAL& Tr2CapsAL::operator=(const Tr2CapsAL& other) +Tr2CapsAL& Tr2CapsAL::operator=( const Tr2CapsAL& other ) { - m_supportsRaytracing = other.m_supportsRaytracing; - return *this; + m_supportsRaytracing = other.m_supportsRaytracing; + return *this; } #endif diff --git a/trinityal/metal/Tr2ConstantBufferALMetal.h b/trinityal/metal/Tr2ConstantBufferALMetal.h index 3dc7563ec..b2b0f98d9 100644 --- a/trinityal/metal/Tr2ConstantBufferALMetal.h +++ b/trinityal/metal/Tr2ConstantBufferALMetal.h @@ -2,44 +2,48 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2ConstantBufferAL.h" #include "MetalContext.h" namespace TrinityALImpl { - class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +{ +public: + Tr2ConstantBufferAL(); + ~Tr2ConstantBufferAL(); + + ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL& renderContext ); + void Destroy(); + + ALResult Lock( void** data, Tr2RenderContextAL& renderContext ); + ALResult Unlock( Tr2RenderContextAL& renderContext ); + + bool IsValid() const; + uint32_t GetSize() const; + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2ConstantBufferAL(); - ~Tr2ConstantBufferAL(); - - ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL & renderContext ); - void Destroy(); - - ALResult Lock( void** data, Tr2RenderContextAL & renderContext ); - ALResult Unlock( Tr2RenderContextAL & renderContext ); - - bool IsValid() const; - uint32_t GetSize() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - ALResult SetConstants( Tr2RenderContextEnum::ShaderType, uint32_t constantIndex, Tr2RenderContextAL& renderContext ); - private: - Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; - Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; - - MetalContext *m_metalContext; - void* m_buffer; - mutable TrinityALImpl::ConstantBufferToken m_token; - uint32_t m_size; - std::string m_name; - - friend class ::Tr2RenderContextAL; - }; + return AL_MEMORY_MANAGED; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + + ALResult SetConstants( Tr2RenderContextEnum::ShaderType, uint32_t constantIndex, Tr2RenderContextAL& renderContext ); + +private: + Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; + Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; + + MetalContext* m_metalContext; + void* m_buffer; + mutable TrinityALImpl::ConstantBufferToken m_token; + uint32_t m_size; + std::string m_name; + + friend class ::Tr2RenderContextAL; +}; } #endif diff --git a/trinityal/metal/Tr2ConstantBufferALMetal.mm b/trinityal/metal/Tr2ConstantBufferALMetal.mm index 43b0d3251..617885a8b 100644 --- a/trinityal/metal/Tr2ConstantBufferALMetal.mm +++ b/trinityal/metal/Tr2ConstantBufferALMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2ConstantBufferALMetal.h" #include "ALLog.h" @@ -10,121 +10,120 @@ namespace TrinityALImpl { - Tr2ConstantBufferAL::Tr2ConstantBufferAL() - : m_metalContext( nullptr ), - m_buffer( nullptr ), - m_size( 0 ) - { - } - - Tr2ConstantBufferAL::~Tr2ConstantBufferAL() - { - Destroy(); - } +Tr2ConstantBufferAL::Tr2ConstantBufferAL() : m_metalContext( nullptr ), m_buffer( nullptr ), m_size( 0 ) +{ +} + +Tr2ConstantBufferAL::~Tr2ConstantBufferAL() +{ + Destroy(); +} - ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL &renderContext ) +ALResult Tr2ConstantBufferAL::Create( uint32_t size, + Tr2ConstantUsageAL::Type usage, + const void* initialData, + Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - if( size == 0 ) - { - return E_INVALIDARG; - } - - if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) && !initialData ) - { - CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); - return E_INVALIDARG; - } - - m_buffer = CCPAlignedMalloc( size, 32 ); - if( !m_buffer ) - { - return E_OUTOFMEMORY; - } - - if( initialData ) - { - memcpy( m_buffer, initialData, size ); - } - - m_metalContext = renderContext.GetMetalContext(); - m_size = size; - - return S_OK; + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL & /*renderContext*/ ) + if( size == 0 ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - - *data = m_buffer; - m_token.Invalidate(); - return S_OK; + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL & /*renderContext*/ ) + if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) && !initialData ) { - if( !IsValid() ) - { - return E_INVALIDCALL; - } - return S_OK; + CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::SetConstants( Tr2RenderContextEnum::ShaderType shaderType, uint32_t constantIndex, Tr2RenderContextAL & renderContext ) + m_buffer = CCPAlignedMalloc( size, 32 ); + if( !m_buffer ) { - if( m_buffer ) - { - renderContext.GetMetalWorkQueue()->SetConstants( shaderType, - m_buffer, - m_size, - m_token, - METAL_CONST_BUFFER_OFFSET + constantIndex ); - } - - return S_OK; + return E_OUTOFMEMORY; } - bool Tr2ConstantBufferAL::IsValid() const + if( initialData ) { - return m_buffer != nullptr; + memcpy( m_buffer, initialData, size ); } - void Tr2ConstantBufferAL::Destroy() + m_metalContext = renderContext.GetMetalContext(); + m_size = size; + + return S_OK; +} + +ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& /*renderContext*/ ) +{ + if( !IsValid() ) { - if( m_metalContext ) - { - m_metalContext->DestroyConstantBuffer( m_buffer ); - } - m_metalContext = nullptr; - m_buffer = nullptr; - m_size = 0; - m_token.Reset(); + return E_INVALIDCALL; } - uint32_t Tr2ConstantBufferAL::GetSize() const + *data = m_buffer; + m_token.Invalidate(); + return S_OK; +} + +ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& /*renderContext*/ ) +{ + if( !IsValid() ) { - return m_size; + return E_INVALIDCALL; } + return S_OK; +} - void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +ALResult Tr2ConstantBufferAL::SetConstants( Tr2RenderContextEnum::ShaderType shaderType, + uint32_t constantIndex, + Tr2RenderContextAL& renderContext ) +{ + if( m_buffer ) { - description["type"] = "Tr2ConstantBufferAL"; - description["size"] = std::to_string( m_size ); - description["name"] = m_name; + renderContext.GetMetalWorkQueue()->SetConstants( + shaderType, m_buffer, m_size, m_token, METAL_CONST_BUFFER_OFFSET + constantIndex ); } - ALResult Tr2ConstantBufferAL::SetName( const char* name ) + return S_OK; +} + +bool Tr2ConstantBufferAL::IsValid() const +{ + return m_buffer != nullptr; +} + +void Tr2ConstantBufferAL::Destroy() +{ + if( m_metalContext ) { - m_name = name; - return S_OK; + m_metalContext->DestroyConstantBuffer( m_buffer ); } + m_metalContext = nullptr; + m_buffer = nullptr; + m_size = 0; + m_token.Reset(); +} + +uint32_t Tr2ConstantBufferAL::GetSize() const +{ + return m_size; +} + +void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ConstantBufferAL"; + description["size"] = std::to_string( m_size ); + description["name"] = m_name; +} + +ALResult Tr2ConstantBufferAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2FenceALMetal.h b/trinityal/metal/Tr2FenceALMetal.h index a899c4336..8f69cd514 100644 --- a/trinityal/metal/Tr2FenceALMetal.h +++ b/trinityal/metal/Tr2FenceALMetal.h @@ -2,39 +2,42 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2FenceAL.h" #include "MetalContext.h" namespace TrinityALImpl { - class Tr2FenceAL : public Tr2DeviceResourceAL - { - public: - Tr2FenceAL(); - ~Tr2FenceAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; +class Tr2FenceAL : public Tr2DeviceResourceAL +{ +public: + Tr2FenceAL(); + ~Tr2FenceAL(); - ALResult PutFence( Tr2RenderContextAL& renderContext ); - ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); - ALResult Wait( Tr2RenderContextAL& renderContext ); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } + bool IsValid() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + ALResult PutFence( Tr2RenderContextAL& renderContext ); + ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); + ALResult Wait( Tr2RenderContextAL& renderContext ); - private: - uint64_t m_frame; - std::string m_name; - bool m_isValid; - bool m_hasBeenPut; - }; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + uint64_t m_frame; + std::string m_name; + bool m_isValid; + bool m_hasBeenPut; +}; } #endif diff --git a/trinityal/metal/Tr2FenceALMetal.mm b/trinityal/metal/Tr2FenceALMetal.mm index fb9493f71..88c1feee7 100644 --- a/trinityal/metal/Tr2FenceALMetal.mm +++ b/trinityal/metal/Tr2FenceALMetal.mm @@ -1,88 +1,84 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2FenceALMetal.h" #include "Tr2RenderContextMetal.h" namespace TrinityALImpl { - Tr2FenceAL::Tr2FenceAL() - : m_frame( 0 ), - m_isValid( false ), - m_hasBeenPut( false ) - { - } +Tr2FenceAL::Tr2FenceAL() : m_frame( 0 ), m_isValid( false ), m_hasBeenPut( false ) +{ +} - Tr2FenceAL::~Tr2FenceAL() - { - } +Tr2FenceAL::~Tr2FenceAL() +{ +} - ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - m_isValid = true; - m_hasBeenPut = false; - return S_OK; + return E_INVALIDARG; } + m_isValid = true; + m_hasBeenPut = false; + return S_OK; +} - void Tr2FenceAL::Destroy() - { - m_isValid = false; - } +void Tr2FenceAL::Destroy() +{ + m_isValid = false; +} - bool Tr2FenceAL::IsValid() const - { - return m_isValid; - } +bool Tr2FenceAL::IsValid() const +{ + return m_isValid; +} - ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& renderContext ) +ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& renderContext ) +{ + if( !m_isValid || !renderContext.IsValid() ) { - if( !m_isValid || !renderContext.IsValid() ) - { - return E_FAIL; - } - - MetalContext *metalContext = renderContext.GetMetalContext(); - m_frame = metalContext->GetRecordingFrameNumber(); - m_hasBeenPut = true; - return S_OK; - + return E_FAIL; } - ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& renderContext) - { - if( !m_isValid || !m_hasBeenPut || !renderContext.IsValid() ) - { - return E_FAIL; - } - - MetalContext *metalContext = renderContext.GetMetalContext(); - isReached = metalContext->GetRenderedFrameNumber() >= m_frame; - - return S_OK; - } + MetalContext* metalContext = renderContext.GetMetalContext(); + m_frame = metalContext->GetRecordingFrameNumber(); + m_hasBeenPut = true; + return S_OK; +} - ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& ) +ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& renderContext ) +{ + if( !m_isValid || !m_hasBeenPut || !renderContext.IsValid() ) { return E_FAIL; } - void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2FenceAL"; - description["name"] = m_name; - } + MetalContext* metalContext = renderContext.GetMetalContext(); + isReached = metalContext->GetRenderedFrameNumber() >= m_frame; - ALResult Tr2FenceAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } + return S_OK; +} + +ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& ) +{ + return E_FAIL; +} + +void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2FenceAL"; + description["name"] = m_name; +} + +ALResult Tr2FenceAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2GpuTimerALMetal.h b/trinityal/metal/Tr2GpuTimerALMetal.h index 5c2559176..4ddd18068 100644 --- a/trinityal/metal/Tr2GpuTimerALMetal.h +++ b/trinityal/metal/Tr2GpuTimerALMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2GpuTimerAL.h" #include "MetalContext.h" @@ -10,42 +10,45 @@ namespace TrinityALImpl { - class Tr2GpuTimerAL : public Tr2DeviceResourceAL +class Tr2GpuTimerAL : public Tr2DeviceResourceAL +{ +public: + Tr2GpuTimerAL(); + ~Tr2GpuTimerAL(); + + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool Begin( Tr2RenderContextAL& renderContext ); + void End( Tr2RenderContextAL& renderContext ); + + float GetTime( Tr2RenderContextAL& renderContext ); + + bool IsValid() const; + + bool operator==( const Tr2GpuTimerAL& other ) const + { + return this == &other; + } + + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + id m_buffer; + float m_lastTime; + enum { - public: - Tr2GpuTimerAL(); - ~Tr2GpuTimerAL(); - - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool Begin( Tr2RenderContextAL& renderContext ); - void End( Tr2RenderContextAL& renderContext ); - - float GetTime( Tr2RenderContextAL& renderContext ); - - bool IsValid() const; - - bool operator==( const Tr2GpuTimerAL& other ) const - { - return this == &other; - } - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - id m_buffer; - float m_lastTime; - enum - { - READY, - BEGIN_ISSUED, - END_ISSUED, - } m_state; - std::string m_name; - }; + READY, + BEGIN_ISSUED, + END_ISSUED, + } m_state; + std::string m_name; +}; } #endif diff --git a/trinityal/metal/Tr2GpuTimerALMetal.mm b/trinityal/metal/Tr2GpuTimerALMetal.mm index c71adf7f0..2528906cd 100644 --- a/trinityal/metal/Tr2GpuTimerALMetal.mm +++ b/trinityal/metal/Tr2GpuTimerALMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2GpuTimerALMetal.h" #include "Tr2PrimaryRenderContextMetal.h" @@ -13,169 +13,167 @@ namespace TrinityALImpl { - Tr2GpuTimerAL::Tr2GpuTimerAL() - : m_lastTime( -1.f ), - m_state( READY ), - m_buffer( nil ) +Tr2GpuTimerAL::Tr2GpuTimerAL() : m_lastTime( -1.f ), m_state( READY ), m_buffer( nil ) +{ +} + +Tr2GpuTimerAL::~Tr2GpuTimerAL() +{ + Destroy(); +} + +ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + // GPU timers on metal are not stable enough (cause crashes on some machines). + // Disabling them for now. + if( !g_enableMetalCounters ) { + return E_FAIL; } - - Tr2GpuTimerAL::~Tr2GpuTimerAL() + + Destroy(); + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) + if( @available( macOS 10.15, * ) ) { - // GPU timers on metal are not stable enough (cause crashes on some machines). - // Disabling them for now. - if( !g_enableMetalCounters ) - { - return E_FAIL; - } - - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } + MetalContext* metalContext = renderContext.GetMetalContext(); + id mtlDevice = metalContext->GetDevice(); - if (@available(macOS 10.15, *)) - { - MetalContext *metalContext = renderContext.GetMetalContext(); - id mtlDevice = metalContext->GetDevice(); - #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 - if( @available( macOS 11.0, * ) ) + if( @available( macOS 11.0, * ) ) + { + if( ![mtlDevice supportsCounterSampling:MTLCounterSamplingPointAtDispatchBoundary] ) { - if( ![mtlDevice supportsCounterSampling:MTLCounterSamplingPointAtDispatchBoundary] ) - { - return E_FAIL; - } + return E_FAIL; } + } #endif - - MTLCounterSampleBufferDescriptor* descriptor = [MTLCounterSampleBufferDescriptor new]; - descriptor.label = @"GPU Timer"; - descriptor.sampleCount = 2; - descriptor.storageMode = MTLStorageModeShared; - for( id counterSet in mtlDevice.counterSets ) - { - if( [counterSet.name isEqualToString:MTLCommonCounterSetTimestamp] ) - { - descriptor.counterSet = counterSet; - break; - } - } - if( !descriptor.counterSet ) + + MTLCounterSampleBufferDescriptor* descriptor = [MTLCounterSampleBufferDescriptor new]; + descriptor.label = @"GPU Timer"; + descriptor.sampleCount = 2; + descriptor.storageMode = MTLStorageModeShared; + for( id counterSet in mtlDevice.counterSets ) + { + if( [counterSet.name isEqualToString:MTLCommonCounterSetTimestamp] ) { - return E_FAIL; + descriptor.counterSet = counterSet; + break; } - - m_buffer = [mtlDevice newCounterSampleBufferWithDescriptor:descriptor error:nil]; } - else + if( !descriptor.counterSet ) { return E_FAIL; } - return S_OK; - } - void Tr2GpuTimerAL::Destroy() + m_buffer = [mtlDevice newCounterSampleBufferWithDescriptor:descriptor error:nil]; + } + else { -#if !__has_feature(objc_arc) - if( m_buffer ) - { - [m_buffer release]; - } -#endif - m_buffer = nil; - m_state = READY; - m_lastTime = -1.f; + return E_FAIL; } + return S_OK; +} - bool Tr2GpuTimerAL::IsValid() const +void Tr2GpuTimerAL::Destroy() +{ +#if !__has_feature( objc_arc ) + if( m_buffer ) { - return m_buffer != nil; + [m_buffer release]; } +#endif + m_buffer = nil; + m_state = READY; + m_lastTime = -1.f; +} + +bool Tr2GpuTimerAL::IsValid() const +{ + return m_buffer != nil; +} - bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) +bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( @available( macOS 10.15, * ) ) { - if (@available(macOS 10.15, *)) - { - if( !IsValid() || !renderContext.IsValid() || m_state != READY ) - { - return false; - } - renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 0, MetalWorkQueue::COUNTER_TIMER ); - m_state = BEGIN_ISSUED; - return true; - } - else + if( !IsValid() || !renderContext.IsValid() || m_state != READY ) { return false; } + renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 0, MetalWorkQueue::COUNTER_TIMER ); + m_state = BEGIN_ISSUED; + return true; + } + else + { + return false; } +} - void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) +void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) +{ + if( @available( macOS 10.15, * ) ) { - if (@available(macOS 10.15, *)) + if( !IsValid() || !renderContext.IsValid() || m_state != BEGIN_ISSUED ) { - if( !IsValid() || !renderContext.IsValid() || m_state != BEGIN_ISSUED ) - { - return; - } - renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 1, MetalWorkQueue::COUNTER_TIMER ); - m_state = END_ISSUED; + return; } + renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 1, MetalWorkQueue::COUNTER_TIMER ); + m_state = END_ISSUED; } +} - float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& renderContext ) +float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& renderContext ) +{ + if( @available( macOS 10.15, * ) ) { - if (@available(macOS 10.15, *)) + if( !IsValid() || m_state != END_ISSUED ) { - if( !IsValid() || m_state != END_ISSUED ) - { - return m_lastTime; - } - auto data = [m_buffer resolveCounterRange:NSMakeRange(0, 2)]; - if( !data ) - { - return m_lastTime; - } - auto timestamps = static_cast( data.bytes ); - - if( !timestamps || !timestamps[0].timestamp || !timestamps[1].timestamp ) - { - return m_lastTime; - } - m_state = READY; - if( timestamps[0].timestamp == MTLCounterErrorValue || timestamps[1].timestamp == MTLCounterErrorValue || - timestamps[0].timestamp > timestamps[1].timestamp ) - { - return m_lastTime; - } - auto elapsed = timestamps[1].timestamp - timestamps[0].timestamp; - m_lastTime = float( double( elapsed ) * renderContext.GetMetalContext()->GetGpuTimerRate() / double( NSEC_PER_SEC ) ); return m_lastTime; } - else + auto data = [m_buffer resolveCounterRange:NSMakeRange( 0, 2 )]; + if( !data ) { - return -1; + return m_lastTime; } - } + auto timestamps = static_cast( data.bytes ); - void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2GpuTimerAL"; - description["name"] = m_name; + if( !timestamps || !timestamps[0].timestamp || !timestamps[1].timestamp ) + { + return m_lastTime; + } + m_state = READY; + if( timestamps[0].timestamp == MTLCounterErrorValue || timestamps[1].timestamp == MTLCounterErrorValue || + timestamps[0].timestamp > timestamps[1].timestamp ) + { + return m_lastTime; + } + auto elapsed = timestamps[1].timestamp - timestamps[0].timestamp; + m_lastTime = + float( double( elapsed ) * renderContext.GetMetalContext()->GetGpuTimerRate() / double( NSEC_PER_SEC ) ); + return m_lastTime; } - - ALResult Tr2GpuTimerAL::SetName( const char* name ) + else { - m_name = name; - return S_OK; + return -1; } } +void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2GpuTimerAL"; + description["name"] = m_name; +} + +ALResult Tr2GpuTimerAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} +} + #endif diff --git a/trinityal/metal/Tr2OcclusionQueryALMetal.h b/trinityal/metal/Tr2OcclusionQueryALMetal.h index a7cf62c34..d554dcf79 100644 --- a/trinityal/metal/Tr2OcclusionQueryALMetal.h +++ b/trinityal/metal/Tr2OcclusionQueryALMetal.h @@ -2,41 +2,44 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2OcclusionQueryAL.h" #include "MetalContext.h" namespace TrinityALImpl { - class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL +class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL +{ +public: + Tr2OcclusionQueryAL(); + ~Tr2OcclusionQueryAL(); + + ALResult Create( Tr2RenderContextAL& renderContext ); + bool IsValid() const; + void Destroy(); + + ALResult Begin( Tr2RenderContextAL& renderContext ); + ALResult End( Tr2RenderContextAL& renderContext ); + ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2OcclusionQueryAL(); - ~Tr2OcclusionQueryAL(); - - ALResult Create( Tr2RenderContextAL& renderContext ); - bool IsValid() const; - void Destroy(); - - ALResult Begin( Tr2RenderContextAL& renderContext ); - ALResult End( Tr2RenderContextAL& renderContext ); - ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; - Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; - - bool m_isValid; - bool m_isRunning; - MetalContext *m_metalContext; - uint64_t m_currentQueryNumber; - std::string m_name; - }; + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; + Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; + + bool m_isValid; + bool m_isRunning; + MetalContext* m_metalContext; + uint64_t m_currentQueryNumber; + std::string m_name; +}; } #endif diff --git a/trinityal/metal/Tr2OcclusionQueryALMetal.mm b/trinityal/metal/Tr2OcclusionQueryALMetal.mm index 4d1085c04..97de729ce 100644 --- a/trinityal/metal/Tr2OcclusionQueryALMetal.mm +++ b/trinityal/metal/Tr2OcclusionQueryALMetal.mm @@ -2,109 +2,110 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2OcclusionQueryALMetal.h" #include "Tr2RenderContextMetal.h" namespace TrinityALImpl { - Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() - : m_isValid( false ) - , m_isRunning( false ) - { - } +Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() : m_isValid( false ), m_isRunning( false ) +{ +} + +Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() +{ + Destroy(); +} - Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() +ALResult Tr2OcclusionQueryAL::Create( Tr2RenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - ALResult Tr2OcclusionQueryAL::Create( Tr2RenderContextAL& renderContext ) - { - Destroy(); + m_currentQueryNumber = 0; + renderContext.GetMetalWorkQueue()->CreateVisibilityQueryBuffer( 1000 ); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } + m_isValid = true; + return S_OK; +} - m_currentQueryNumber = 0; - renderContext.GetMetalWorkQueue()->CreateVisibilityQueryBuffer( 1000 ); +bool Tr2OcclusionQueryAL::IsValid() const +{ + return m_isValid; +} - m_isValid = true; - return S_OK; - } +void Tr2OcclusionQueryAL::Destroy() +{ + m_isValid = false; +} - bool Tr2OcclusionQueryAL::IsValid() const +ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) +{ + if( !m_isValid || m_isRunning ) { - return m_isValid; + return E_INVALIDCALL; } - void Tr2OcclusionQueryAL::Destroy() - { - m_isValid = false; - } + m_currentQueryNumber = renderContext.GetMetalWorkQueue()->StartVisibilityQuery(); + m_isRunning = true; + return S_OK; +} - ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& renderContext ) +ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) +{ + if( !m_isValid ) { - if( !m_isValid || m_isRunning ) - { - return E_INVALIDCALL; - } - - m_currentQueryNumber = renderContext.GetMetalWorkQueue()->StartVisibilityQuery(); - m_isRunning = true; - return S_OK; + return E_INVALIDCALL; } - - ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& renderContext ) + if( !m_isRunning ) { - if( !m_isValid ) - { - return E_INVALIDCALL; - } - if( !m_isRunning ) - { - return E_INVALIDCALL; - } - - renderContext.GetMetalWorkQueue()->EndVisibilityQuery(m_currentQueryNumber); - m_isRunning = false; - return S_OK; + return E_INVALIDCALL; } - ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ) - { - if( !m_isValid ) - { - return E_INVALIDCALL; - } - - bool waitForOutstandingWork = waitMode == ::Tr2OcclusionQueryAL::WAIT ? true : false; - uint64_t pixelCount; - bool pixelCountReady; - pixelCountReady = renderContext.GetMetalWorkQueue()->GetVisibilityQueryPixelCount(m_currentQueryNumber, &pixelCount, waitForOutstandingWork); - if( pixelCountReady ) - { - count = (uint32_t)pixelCount; - return S_OK; - } - - return S_FALSE; - } + renderContext.GetMetalWorkQueue()->EndVisibilityQuery( m_currentQueryNumber ); + m_isRunning = false; + return S_OK; +} - void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& renderContext, + uint32_t& count, + ::Tr2OcclusionQueryAL::WaitMode waitMode ) +{ + if( !m_isValid ) { - description["type"] = "Tr2OcclusionQueryAL"; - description["name"] = m_name; + return E_INVALIDCALL; } - ALResult Tr2OcclusionQueryAL::SetName( const char* name ) + bool waitForOutstandingWork = waitMode == ::Tr2OcclusionQueryAL::WAIT ? true : false; + uint64_t pixelCount; + bool pixelCountReady; + pixelCountReady = renderContext.GetMetalWorkQueue()->GetVisibilityQueryPixelCount( + m_currentQueryNumber, &pixelCount, waitForOutstandingWork ); + if( pixelCountReady ) { - m_name = name; + count = (uint32_t)pixelCount; return S_OK; } + + return S_FALSE; +} + +void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2OcclusionQueryAL"; + description["name"] = m_name; +} + +ALResult Tr2OcclusionQueryAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2PipelineStatsQueryALMetal.h b/trinityal/metal/Tr2PipelineStatsQueryALMetal.h index ac5334432..9d0b1f9ff 100644 --- a/trinityal/metal/Tr2PipelineStatsQueryALMetal.h +++ b/trinityal/metal/Tr2PipelineStatsQueryALMetal.h @@ -14,18 +14,18 @@ class MetalWorkQueue; class Tr2PipelineStatsDataAL { public: - // This should be MTLCounterResultStatistic, but we are still compiling for 10.14... - struct Stats - { - uint64_t tessellationInputPatches; - uint64_t vertexInvocations; - uint64_t postTessellationVertexInvocations; - uint64_t clipperInvocations; - uint64_t clipperPrimitivesOut; - uint64_t fragmentInvocations; - uint64_t fragmentsPassed; - uint64_t computeKernelInvocations; - } data = {}; + // This should be MTLCounterResultStatistic, but we are still compiling for 10.14... + struct Stats + { + uint64_t tessellationInputPatches; + uint64_t vertexInvocations; + uint64_t postTessellationVertexInvocations; + uint64_t clipperInvocations; + uint64_t clipperPrimitivesOut; + uint64_t fragmentInvocations; + uint64_t fragmentsPassed; + uint64_t computeKernelInvocations; + } data = {}; }; @@ -33,7 +33,7 @@ class Tr2PipelineStatsQueryAL : public Tr2DeviceResourceAL mtlDevice = metalContext->GetDevice(); - + if( !g_enableMetalCounters ) + { + return E_FAIL; + } + + Destroy(); + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + + if( @available( macOS 10.15, * ) ) + { + MetalContext* metalContext = renderContext.GetMetalContext(); + id mtlDevice = metalContext->GetDevice(); + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 - if( @available( macOS 11.0, * ) ) - { - if( ![mtlDevice supportsCounterSampling:MTLCounterSamplingPointAtDispatchBoundary] ) - { - return E_FAIL; - } - } + if( @available( macOS 11.0, * ) ) + { + if( ![mtlDevice supportsCounterSampling:MTLCounterSamplingPointAtDispatchBoundary] ) + { + return E_FAIL; + } + } #endif - - MTLCounterSampleBufferDescriptor* descriptor = [MTLCounterSampleBufferDescriptor new]; - descriptor.label = @"Pipeline stats query"; - descriptor.sampleCount = MAX_SAMPLES_PER_QUERY; - descriptor.storageMode = MTLStorageModeShared; - for( id counterSet in mtlDevice.counterSets ) - { - if( [counterSet.name isEqualToString:MTLCommonCounterSetStatistic] ) - { - descriptor.counterSet = counterSet; - break; - } - } - if( !descriptor.counterSet ) - { - return E_FAIL; - } - - m_buffer = [mtlDevice newCounterSampleBufferWithDescriptor:descriptor error:nil]; - } - else - { - return E_FAIL; - } - return S_OK; + + MTLCounterSampleBufferDescriptor* descriptor = [MTLCounterSampleBufferDescriptor new]; + descriptor.label = @"Pipeline stats query"; + descriptor.sampleCount = MAX_SAMPLES_PER_QUERY; + descriptor.storageMode = MTLStorageModeShared; + for( id counterSet in mtlDevice.counterSets ) + { + if( [counterSet.name isEqualToString:MTLCommonCounterSetStatistic] ) + { + descriptor.counterSet = counterSet; + break; + } + } + if( !descriptor.counterSet ) + { + return E_FAIL; + } + + m_buffer = [mtlDevice newCounterSampleBufferWithDescriptor:descriptor error:nil]; + } + else + { + return E_FAIL; + } + return S_OK; } bool Tr2PipelineStatsQueryAL::IsValid() const @@ -142,171 +125,173 @@ void Tr2PipelineStatsQueryAL::Destroy() { -#if !__has_feature(objc_arc) - if( m_buffer ) - { - [m_buffer release]; - } +#if !__has_feature( objc_arc ) + if( m_buffer ) + { + [m_buffer release]; + } #endif - m_buffer = nil; - m_nextIndex = 0; - m_state = READY; - std::fill( std::begin( m_zeroSamples ), std::end( m_zeroSamples ), 0u ); + m_buffer = nil; + m_nextIndex = 0; + m_state = READY; + std::fill( std::begin( m_zeroSamples ), std::end( m_zeroSamples ), 0u ); } ALResult Tr2PipelineStatsQueryAL::Begin( Tr2RenderContextAL& renderContext ) { - if (@available(macOS 10.15, *)) - { - if( !IsValid() || !renderContext.IsValid() || m_state != READY ) - { - return E_INVALIDARG; - } - if( !renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 0, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) - { - m_zeroSamples[0] = 1; - } - renderContext.GetMetalWorkQueue()->PipelineQueryStarted( this ); - m_state = BEGIN_ISSUED; - m_nextIndex = 1; - return S_OK; - } - else - { - return E_INVALIDARG; - } + if( @available( macOS 10.15, * ) ) + { + if( !IsValid() || !renderContext.IsValid() || m_state != READY ) + { + return E_INVALIDARG; + } + if( !renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, 0, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) + { + m_zeroSamples[0] = 1; + } + renderContext.GetMetalWorkQueue()->PipelineQueryStarted( this ); + m_state = BEGIN_ISSUED; + m_nextIndex = 1; + return S_OK; + } + else + { + return E_INVALIDARG; + } } ALResult Tr2PipelineStatsQueryAL::End( Tr2RenderContextAL& renderContext ) { - if (@available(macOS 10.15, *)) - { - if( !IsValid() || !renderContext.IsValid() || m_state != BEGIN_ISSUED ) - { - return E_INVALIDARG; - } - if( m_nextIndex < MAX_SAMPLES_PER_QUERY ) - { - if( !renderContext.GetMetalWorkQueue()->SampleCounter( m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) - { - m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); - } - ++m_nextIndex; - m_state = END_ISSUED; - renderContext.GetMetalWorkQueue()->PipelineQueryEnded( this ); - return S_OK; - } - else - { - renderContext.GetMetalWorkQueue()->PipelineQueryEnded( this ); - return E_FAIL; - } - } - else - { - return E_INVALIDARG; - } + if( @available( macOS 10.15, * ) ) + { + if( !IsValid() || !renderContext.IsValid() || m_state != BEGIN_ISSUED ) + { + return E_INVALIDARG; + } + if( m_nextIndex < MAX_SAMPLES_PER_QUERY ) + { + if( !renderContext.GetMetalWorkQueue()->SampleCounter( + m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) + { + m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); + } + ++m_nextIndex; + m_state = END_ISSUED; + renderContext.GetMetalWorkQueue()->PipelineQueryEnded( this ); + return S_OK; + } + else + { + renderContext.GetMetalWorkQueue()->PipelineQueryEnded( this ); + return E_FAIL; + } + } + else + { + return E_INVALIDARG; + } } void Tr2PipelineStatsQueryAL::EncoderStarted( MetalWorkQueue* queue ) { - if (@available(macOS 10.15, *)) - { - if( m_buffer && m_nextIndex < MAX_SAMPLES_PER_QUERY ) - { - if( !queue->SampleCounter( m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) - { - m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); - } - ++m_nextIndex; - } - } + if( @available( macOS 10.15, * ) ) + { + if( m_buffer && m_nextIndex < MAX_SAMPLES_PER_QUERY ) + { + if( !queue->SampleCounter( m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) + { + m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); + } + ++m_nextIndex; + } + } } void Tr2PipelineStatsQueryAL::EncoderEnding( MetalWorkQueue* queue ) { - if (@available(macOS 10.15, *)) - { - if( m_buffer && m_nextIndex < MAX_SAMPLES_PER_QUERY ) - { - if( !queue->SampleCounter( m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) - { - m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); - } - ++m_nextIndex; - } - } + if( @available( macOS 10.15, * ) ) + { + if( m_buffer && m_nextIndex < MAX_SAMPLES_PER_QUERY ) + { + if( !queue->SampleCounter( m_buffer, m_nextIndex, MetalWorkQueue::COUNTER_PIPELINE_STATS ) ) + { + m_zeroSamples[m_nextIndex / 64] |= 1 << ( m_nextIndex % 64 ); + } + ++m_nextIndex; + } + } } ALResult Tr2PipelineStatsQueryAL::GetStats( Tr2PipelineStatsDataAL& results, Tr2RenderContextAL& renderContext ) { - if( !IsValid() ) - { - return E_INVALIDARG; - } - if (@available(macOS 10.15, *)) - { - if( !IsValid() || m_state != END_ISSUED ) - { - return S_FALSE; - } - auto data = [m_buffer resolveCounterRange:NSMakeRange( 0, m_nextIndex )]; - if( !data ) - { - return S_FALSE; - } - results.data = {}; - auto samples = static_cast( data.bytes ); - Tr2PipelineStatsDataAL::Stats zeroes = {}; - for( NSUInteger i = 0; i + 1 < m_nextIndex; i += 2 ) - { - auto& d0 = ( m_zeroSamples[i / 64] & ( 1 << ( i % 64 ) ) ) != 0 ? zeroes : samples[i]; - auto& d1 = ( m_zeroSamples[( i + 1 ) / 64] & ( 1 << ( ( i + 1 ) % 64 ) ) ) != 0 ? zeroes : samples[i + 1]; - #define DIFF_DATA(x) results.data.x += d0.x <= d1.x ? d1.x - d0.x : 0; - DIFF_DATA(tessellationInputPatches); - DIFF_DATA(vertexInvocations); - DIFF_DATA(postTessellationVertexInvocations); - DIFF_DATA(clipperInvocations); - DIFF_DATA(clipperPrimitivesOut); - DIFF_DATA(fragmentInvocations); - DIFF_DATA(fragmentsPassed); - DIFF_DATA(computeKernelInvocations); - #undef DIFF_DATA - } - m_state = READY; - m_nextIndex = 0; - return S_OK; - } - else - { - return -1; - } + if( !IsValid() ) + { + return E_INVALIDARG; + } + if( @available( macOS 10.15, * ) ) + { + if( !IsValid() || m_state != END_ISSUED ) + { + return S_FALSE; + } + auto data = [m_buffer resolveCounterRange:NSMakeRange( 0, m_nextIndex )]; + if( !data ) + { + return S_FALSE; + } + results.data = {}; + auto samples = static_cast( data.bytes ); + Tr2PipelineStatsDataAL::Stats zeroes = {}; + for( NSUInteger i = 0; i + 1 < m_nextIndex; i += 2 ) + { + auto& d0 = ( m_zeroSamples[i / 64] & ( 1 << ( i % 64 ) ) ) != 0 ? zeroes : samples[i]; + auto& d1 = ( m_zeroSamples[( i + 1 ) / 64] & ( 1 << ( ( i + 1 ) % 64 ) ) ) != 0 ? zeroes : samples[i + 1]; +#define DIFF_DATA( x ) results.data.x += d0.x <= d1.x ? d1.x - d0.x : 0; + DIFF_DATA( tessellationInputPatches ); + DIFF_DATA( vertexInvocations ); + DIFF_DATA( postTessellationVertexInvocations ); + DIFF_DATA( clipperInvocations ); + DIFF_DATA( clipperPrimitivesOut ); + DIFF_DATA( fragmentInvocations ); + DIFF_DATA( fragmentsPassed ); + DIFF_DATA( computeKernelInvocations ); +#undef DIFF_DATA + } + m_state = READY; + m_nextIndex = 0; + return S_OK; + } + else + { + return -1; + } return S_OK; } size_t Tr2PipelineStatsQueryAL::GetValueCount( const Tr2PipelineStatsDataAL& data ) { - return sizeof( s_fields ) / sizeof( s_fields[0] ); + return sizeof( s_fields ) / sizeof( s_fields[0] ); } const char* Tr2PipelineStatsQueryAL::GetLabel( const Tr2PipelineStatsDataAL& data, size_t index ) { - return s_fields[index].label; + return s_fields[index].label; } const char* Tr2PipelineStatsQueryAL::GetDescription( const Tr2PipelineStatsDataAL& data, size_t index ) { - return s_fields[index].description; + return s_fields[index].description; } ::Tr2PipelineStatsQueryAL::Value Tr2PipelineStatsQueryAL::GetValue( const Tr2PipelineStatsDataAL& data, size_t index ) { - return *reinterpret_cast( reinterpret_cast( &data.data ) + s_fields[index].offset ); + return *reinterpret_cast( reinterpret_cast( &data.data ) + + s_fields[index].offset ); } void Tr2PipelineStatsQueryAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const { - description["type"] = "Tr2PipelineStatsQueryAL"; + description["type"] = "Tr2PipelineStatsQueryAL"; description["name"] = m_name; } diff --git a/trinityal/metal/Tr2PrimaryRenderContextMetal.mm b/trinityal/metal/Tr2PrimaryRenderContextMetal.mm index 4b06d54a2..057016b41 100644 --- a/trinityal/metal/Tr2PrimaryRenderContextMetal.mm +++ b/trinityal/metal/Tr2PrimaryRenderContextMetal.mm @@ -2,5 +2,5 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #endif diff --git a/trinityal/metal/Tr2RenderContextMetal.h b/trinityal/metal/Tr2RenderContextMetal.h index eaeed2cf7..37a6ad952 100644 --- a/trinityal/metal/Tr2RenderContextMetal.h +++ b/trinityal/metal/Tr2RenderContextMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../Tr2RenderContextEnum.h" #include "../Tr2DrawUPHelper.h" @@ -63,10 +63,9 @@ class Tr2RenderContextAL static Tr2PrimaryRenderContextAL& GetPrimaryRenderContext(); static Tr2PrimaryRenderContextAL* GetPrimaryRenderContextPointer(); - ALResult CreateDevice( - uint32_t Adapter, - Tr2WindowHandle hFocusWindow, - const Tr2PresentParametersAL& presentationParameters ); + ALResult CreateDevice( uint32_t Adapter, + Tr2WindowHandle hFocusWindow, + const Tr2PresentParametersAL& presentationParameters ); ALResult SetPresentParameters( unsigned adapter, const Tr2PresentParametersAL& presentationParameters ); const Tr2CapsAL& GetCaps() const; @@ -79,13 +78,9 @@ class Tr2RenderContextAL void ReleaseDeviceResources(); - ALResult SetStreamSource( - uint32_t stream, - const Tr2BufferAL & buffer, - uint32_t offset, - uint32_t stride ) throw( ); + ALResult SetStreamSource( uint32_t stream, const Tr2BufferAL& buffer, uint32_t offset, uint32_t stride ) throw(); - ALResult SetIndices( const Tr2BufferAL& buffer ) throw( ); + ALResult SetIndices( const Tr2BufferAL& buffer ) throw(); ALResult SetIndices( const Tr2BufferAL& buffer, int stride ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw(); @@ -93,62 +88,50 @@ class Tr2RenderContextAL ALResult ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const float values[4] ) throw(); ALResult ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const uint32_t values[4] ) throw(); - ALResult CopySubBuffer( - Tr2BufferAL& dest, - uint32_t destOffset, - Tr2BufferAL& src, - uint32_t offset, - uint32_t length ); + ALResult + CopySubBuffer( Tr2BufferAL& dest, uint32_t destOffset, Tr2BufferAL& src, uint32_t offset, uint32_t length ); ALResult SetTopology( Tr2RenderContextEnum::Topology topology ); ALResult SetShaderProgram( const Tr2ShaderProgramAL& shaderProgram ); ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ); - - ALResult DrawIndexedPrimitive( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, - uint32_t minimumIndex = 0 ); + + ALResult DrawIndexedPrimitive( uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, + uint32_t minimumIndex = 0 ); ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ); - ALResult DrawIndexedInstanced( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, - uint32_t numInstances ); - - ALResult DrawIndexedInstanced( - uint32_t indexCountPerInstance, - uint32_t instanceCount, - uint32_t startIndexLocation, - int32_t baseVertexLocation, - uint32_t startInstanceLocation ); - ALResult DrawInstanced( - uint32_t vertexCountPerInstance, - uint32_t instanceCount, - uint32_t startVertexLocation, - uint32_t startInstanceLocation ); - - ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride); - - ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride); - - ALResult DrawPrimitiveUP( - uint32_t primitiveCount, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ); + ALResult DrawIndexedInstanced( uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, + uint32_t numInstances ); + + ALResult DrawIndexedInstanced( uint32_t indexCountPerInstance, + uint32_t instanceCount, + uint32_t startIndexLocation, + int32_t baseVertexLocation, + uint32_t startInstanceLocation ); + ALResult DrawInstanced( uint32_t vertexCountPerInstance, + uint32_t instanceCount, + uint32_t startVertexLocation, + uint32_t startInstanceLocation ); + + ALResult DrawIndexedPrimitiveUP( uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ); + + ALResult DrawIndexedPrimitiveUP( uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ); + + ALResult + DrawPrimitiveUP( uint32_t primitiveCount, const void* vertexStreamZeroData, uint32_t vertexStreamZeroStride ); ALResult DrawIndexedInstancedIndirect( Tr2BufferAL& params, uint32_t offset ); ALResult DrawInstancedIndirect( Tr2BufferAL& params, uint32_t offset ); @@ -156,29 +139,28 @@ class Tr2RenderContextAL ALResult RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ); ALResult RunComputeShaderIndirect( Tr2BufferAL& indirectParams, unsigned offset ); - ALResult DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2RtShaderTableAL& shaderTable, const wchar_t* rayGenShader, uint32_t width, uint32_t height, uint32_t depth ); - + ALResult DispatchRays( Tr2RtPipelineStateAL& pipeline, + Tr2RtShaderTableAL& shaderTable, + const wchar_t* rayGenShader, + uint32_t width, + uint32_t height, + uint32_t depth ); + ALResult SetVertexLayout( const Tr2VertexLayoutAL& layout ); ALResult SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ); - ALResult SetRenderStates( const uint32_t * stateValuePairs, uint32_t count ); + ALResult SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ); - ALResult SetConstants( - const Tr2ConstantBufferAL& buffer, - Tr2RenderContextEnum::ShaderType constantType, - uint32_t registerIndex, - uint32_t maxRegisterCount = 0 ); + ALResult SetConstants( const Tr2ConstantBufferAL& buffer, + Tr2RenderContextEnum::ShaderType constantType, + uint32_t registerIndex, + uint32_t maxRegisterCount = 0 ); - uint64_t UploadConstants( const void* data, size_t size ); - uint64_t UploadConstants( const Tr2ConstantBufferAL& buffer ); + uint64_t UploadConstants( const void* data, size_t size ); + uint64_t UploadConstants( const Tr2ConstantBufferAL& buffer ); // Helper function to clear the current primary backbuffer, depth and/or stencil. - ALResult Clear( - uint32_t clearFlags, - uint32_t color, - float depth, - uint32_t stencil = 0, - uint32_t slot = 0 ); + ALResult Clear( uint32_t clearFlags, uint32_t color, float depth, uint32_t stencil = 0, uint32_t slot = 0 ); ALResult SetDepthStencil( const Tr2TextureAL& depthStencil ); void SetReadOnlyDepth( bool enable ); @@ -186,8 +168,9 @@ class Tr2RenderContextAL ALResult SetRenderTarget( const Tr2TextureAL& renderTarget, uint32_t slot = 0, uint32_t slice = 0 ); void RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2DepthAttachment& depth ); - void RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2ColorAttachment& rt1, const Tr2DepthAttachment& depth ); - void EndRenderPassHint(); + void + RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2ColorAttachment& rt1, const Tr2DepthAttachment& depth ); + void EndRenderPassHint(); ALResult SetViewport( const Tr2Viewport& viewport ); ALResult GetViewport( Tr2Viewport& viewport ); @@ -196,10 +179,7 @@ class Tr2RenderContextAL ALResult PopRenderTarget( uint32_t slot = 0 ); ALResult PushDepthStencil(); ALResult PopDepthStencil(); - ALResult GetRenderTargetSize( - uint32_t& width, - uint32_t& height, - uint32_t slot = 0 ); + ALResult GetRenderTargetSize( uint32_t& width, uint32_t& height, uint32_t slot = 0 ); void ResetRenderTargets(); @@ -207,73 +187,101 @@ class Tr2RenderContextAL Tr2RenderContextEnum::PixelFormat GetBackBufferFormat() const; - static const uint32_t SHADER_TYPE_MASK = - ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ) | - ( 1 << Tr2RenderContextEnum::PIXEL_SHADER ) | - ( 1 << Tr2RenderContextEnum::COMPUTE_SHADER ); + static const uint32_t SHADER_TYPE_MASK = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ) | + ( 1 << Tr2RenderContextEnum::PIXEL_SHADER ) | ( 1 << Tr2RenderContextEnum::COMPUTE_SHADER ); // Debug helpers - size_t GetStackSizeRT( uint32_t RT = 0 ) const { return 0; } - size_t GetStackSizeDS() const { return 0; } + size_t GetStackSizeRT( uint32_t RT = 0 ) const + { + return 0; + } + size_t GetStackSizeDS() const + { + return 0; + } Tr2CapsAL m_caps; ITr2RenderContextEvents* m_events; - Tr2TextureAL& GetDefaultBackBuffer() { return m_defaultBackBuffer; } + Tr2TextureAL& GetDefaultBackBuffer() + { + return m_defaultBackBuffer; + } void AddGpuMarker( const char* marker ); void PushGpuMarker( const char* marker ); void PopGpuMarker(); ALResult GetGpuStateMarker( Tr2RenderContextEnum::RenderContextStatus& status, std::string& marker ) const; - ALResult GetGpuPageFaultResource( - Tr2RenderContextEnum::PixelFormat& format, - uint64_t& size, - uint32_t& width, - uint32_t& height, - uint32_t& depth, - uint32_t& mips ) const; - - TrinityALImpl::MetalContext *GetMetalContext() { return m_metalContext; } - TrinityALImpl::MetalWorkQueue *GetMetalWorkQueue() { return m_workQueue; } - Tr2PresentParametersAL *GetPresentParamaters() { return &m_presentParameters; } + ALResult GetGpuPageFaultResource( Tr2RenderContextEnum::PixelFormat& format, + uint64_t& size, + uint32_t& width, + uint32_t& height, + uint32_t& depth, + uint32_t& mips ) const; + + TrinityALImpl::MetalContext* GetMetalContext() + { + return m_metalContext; + } + TrinityALImpl::MetalWorkQueue* GetMetalWorkQueue() + { + return m_workQueue; + } + Tr2PresentParametersAL* GetPresentParamaters() + { + return &m_presentParameters; + } uint32_t ComputeVertexCount( uint32_t primitiveCount ); - + void BufferRewritten( id from, id to ); - + uint32_t BeginParallelEncoding( uint32_t requestedEncodersCount ); void EndParallelEncoding(); - + ALResult ForkContext( Tr2RenderContextAL* context, uint32_t index ) const; - ALResult UseResources( Tr2UseResourceDestination dest, Tr2GpuUsage::Type usage, const Tr2BindlessResourcesAL& resources ); - ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); - ALResult UseConstantBuffer( id constantBuffer ); + ALResult UseResources( Tr2UseResourceDestination dest, + Tr2GpuUsage::Type usage, + const Tr2BindlessResourcesAL& resources ); + ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); + ALResult UseConstantBuffer( id constantBuffer ); - bool SupportsBindlessTextures() const; + bool SupportsBindlessTextures() const; uint64_t GetRecordingFrameNumber() const; uint64_t GetRenderedFrameNumber() const; - - - Tr2UpscalingAL::Result EnableUpscaling( Tr2UpscalingAL::Technique tech, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); + + + Tr2UpscalingAL::Result EnableUpscaling( Tr2UpscalingAL::Technique tech, + Tr2UpscalingAL::Setting setting, + bool frameGeneration, + uint32_t adapter ); Tr2UpscalingContextAL* GetUpscalingContext( uint32_t upscalingContextID ) const; - Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID ); + Tr2UpscalingContextAL* CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, + uint32_t existingContext = Tr2UpscalingAL::INVALID_CONTEXT_ID ); void DeleteUpscalingContext( uint32_t contextID ); Tr2UpscalingAL::UpscalingInfo GetUpscalingInfo( uint32_t upscalingContextID ) const; - void GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, Tr2UpscalingAL::Setting& setting, bool& framegeneration, bool& temporal ) const; - std::vector> GetSupportedUpscalingTechniques( uint32_t adapter ); + void GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, + Tr2UpscalingAL::Setting& setting, + bool& framegeneration, + bool& temporal ) const; + std::vector> + GetSupportedUpscalingTechniques( uint32_t adapter ); void MarkFrameEvent( Tr2RenderContextEnum::FrameEvent frameEvent ); - - void ReleaseLater( id obj ); + + void ReleaseLater( id obj ); protected: - bool m_isValid; + bool m_isValid; - enum { MAX_RENDER_TARGET = 8 }; - Tr2SwapChainAL m_swapChain; + enum + { + MAX_RENDER_TARGET = 8 + }; + Tr2SwapChainAL m_swapChain; struct BoundRT { @@ -281,37 +289,37 @@ class Tr2RenderContextAL uint32_t slice; }; BoundRT m_boundRenderTargets[MAX_RENDER_TARGET]; - Tr2TextureAL m_boundDepthStencil; + Tr2TextureAL m_boundDepthStencil; TrackableStdStack m_stackRT[MAX_RENDER_TARGET]; - TrackableStdStack m_stackDS; - Tr2TextureAL m_defaultBackBuffer; + TrackableStdStack m_stackDS; + Tr2TextureAL m_defaultBackBuffer; - Tr2Viewport m_viewport; - TrinityALImpl::MetalContext *m_metalContext; - TrinityALImpl::MetalWorkQueue *m_workQueue; + Tr2Viewport m_viewport; + TrinityALImpl::MetalContext* m_metalContext; + TrinityALImpl::MetalWorkQueue* m_workQueue; - Tr2PresentParametersAL m_presentParameters; + Tr2PresentParametersAL m_presentParameters; - Tr2ShaderProgramAL m_shaderProgram; - Tr2ResourceSetAL m_resourceSet; - Tr2VertexLayoutAL m_vertexLayout; + Tr2ShaderProgramAL m_shaderProgram; + Tr2ResourceSetAL m_resourceSet; + Tr2VertexLayoutAL m_vertexLayout; - bool m_needsDrawResourceCheck; + bool m_needsDrawResourceCheck; struct MetalPrimitiveInfo { MTLPrimitiveType metalPrimitiveType; - uint32_t primitiveToIndexMultiplier; - uint32_t primtiveToIndexAddition; - bool validType; + uint32_t primitiveToIndexMultiplier; + uint32_t primtiveToIndexAddition; + bool validType; }; - MetalPrimitiveInfo m_metalPrimitiveInfo; - MTLCompareFunction m_depthCompareFunction; - CAMetalLayer *m_caMetalLayer; - + MetalPrimitiveInfo m_metalPrimitiveInfo; + MTLCompareFunction m_depthCompareFunction; + CAMetalLayer* m_caMetalLayer; + static const uint32_t VERTEX_STREAM_COUNT = METAL_VERTEX_STREAM_BUFFER_COUNT; - + struct { id buffer; @@ -329,19 +337,19 @@ class Tr2RenderContextAL bool m_alphaBlendEnable; bool m_separateAlphaBlendEnabled; bool m_isPrimary; - + uint32_t m_queueIndex; void SetAsPrimary(); - Tr2UpscalingTechniqueAL* m_upscalingTechnique; + Tr2UpscalingTechniqueAL* m_upscalingTechnique; public: - void CheckDrawResources(); + void CheckDrawResources(); - MTLIndexType m_metalIndexType; - id m_metalIndexBuffer; + MTLIndexType m_metalIndexType; + id m_metalIndexBuffer; - TrinityALImpl::Tr2SamplerStateALFactory m_samplerStateFactory; + TrinityALImpl::Tr2SamplerStateALFactory m_samplerStateFactory; }; #endif diff --git a/trinityal/metal/Tr2RenderContextMetal.mm b/trinityal/metal/Tr2RenderContextMetal.mm index 0f5430f1f..349292d96 100644 --- a/trinityal/metal/Tr2RenderContextMetal.mm +++ b/trinityal/metal/Tr2RenderContextMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2RenderContextMetal.h" #include "ITr2RenderContextEvents.h" @@ -23,72 +23,85 @@ #include "MetalContext.h" -CCP_STATS_DECLARE( primitiveCount , "Trinity/AL/primitiveCount" , true, CST_COUNTER_HIGH, "Primitive count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( vertexCount , "Trinity/AL/vertexCount" , true, CST_COUNTER_HIGH, "Vertex count in DrawPrimitive calls." ); -CCP_STATS_DECLARE( sceneDrawcallCount , "Trinity/AL/sceneDrawcallCount" , true, CST_COUNTER_LOW, "Number of DrawPrimitive calls." ); +CCP_STATS_DECLARE( primitiveCount, + "Trinity/AL/primitiveCount", + true, + CST_COUNTER_HIGH, + "Primitive count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( vertexCount, + "Trinity/AL/vertexCount", + true, + CST_COUNTER_HIGH, + "Vertex count in DrawPrimitive calls." ); +CCP_STATS_DECLARE( sceneDrawcallCount, + "Trinity/AL/sceneDrawcallCount", + true, + CST_COUNTER_LOW, + "Number of DrawPrimitive calls." ); using namespace Tr2RenderContextEnum; -#pragma warning( disable: 4189 ) // Scopeguard +#pragma warning( disable : 4189 ) // Scopeguard bool g_gatherPipelineStatistics = false; bool g_enableMetalCounters = false; namespace { - Tr2PrimaryRenderContextAL*& GetPrimaryRenderContextPointer() - { - static Tr2PrimaryRenderContextAL* primaryRenderContext = nullptr; - return primaryRenderContext; - } - - MTLClearColor MakeClearColor( uint32_t color ) - { - MTLClearColor clearColor; - clearColor.alpha = float( ( color >> 24 ) & 0xff ) / 255.f; - clearColor.red = float( ( color >> 16 ) & 0xff ) / 255.f; - clearColor.green = float( ( color >> 8 ) & 0xff ) / 255.f; - clearColor.blue = float( ( color >> 0 ) & 0xff ) / 255.f; - return clearColor; - } +Tr2PrimaryRenderContextAL*& GetPrimaryRenderContextPointer() +{ + static Tr2PrimaryRenderContextAL* primaryRenderContext = nullptr; + return primaryRenderContext; } -Tr2RenderContextAL::Tr2RenderContextAL() - : m_isValid(false) - , m_events( nullptr ) - , m_metalContext( nil ) - , m_workQueue( nil ) - , m_depthWriteEnabled( true ) - , m_depthCompareEnabled( false ) - , m_readOnlyDepth( false ) - , m_alphaBlendEnable( false ) - , m_separateAlphaBlendEnabled( false ) - , m_srgbWriteEnable( false ) - , m_isPrimary( false ) - , m_caps() - , m_upscalingTechnique( nullptr ) +MTLClearColor MakeClearColor( uint32_t color ) +{ + MTLClearColor clearColor; + clearColor.alpha = float( ( color >> 24 ) & 0xff ) / 255.f; + clearColor.red = float( ( color >> 16 ) & 0xff ) / 255.f; + clearColor.green = float( ( color >> 8 ) & 0xff ) / 255.f; + clearColor.blue = float( ( color >> 0 ) & 0xff ) / 255.f; + return clearColor; +} +} + +Tr2RenderContextAL::Tr2RenderContextAL() : + m_isValid( false ), + m_events( nullptr ), + m_metalContext( nil ), + m_workQueue( nil ), + m_depthWriteEnabled( true ), + m_depthCompareEnabled( false ), + m_readOnlyDepth( false ), + m_alphaBlendEnable( false ), + m_separateAlphaBlendEnabled( false ), + m_srgbWriteEnable( false ), + m_isPrimary( false ), + m_caps(), + m_upscalingTechnique( nullptr ) { } Tr2RenderContextAL::~Tr2RenderContextAL() { - - if( m_upscalingTechnique ){ - m_upscalingTechnique->ReleaseResources(); - delete m_upscalingTechnique; - m_upscalingTechnique = nullptr; - } - + + if( m_upscalingTechnique ) + { + m_upscalingTechnique->ReleaseResources(); + delete m_upscalingTechnique; + m_upscalingTechnique = nullptr; + } + m_vertexLayout = Tr2VertexLayoutAL(); m_resourceSet = Tr2ResourceSetAL(); m_shaderProgram = Tr2ShaderProgramAL(); - - std::fill( std::begin( m_boundRenderTargets ), std::end( m_boundRenderTargets ), BoundRT{} ); - std::fill( std::begin( m_stackRT ), std::end( m_stackRT ), TrackableStdStack{} ); - m_stackDS = TrackableStdStack(); - m_boundDepthStencil = {}; - m_defaultBackBuffer = {}; - m_swapChain = Tr2SwapChainAL(); + + std::fill( std::begin( m_boundRenderTargets ), std::end( m_boundRenderTargets ), BoundRT{} ); + std::fill( std::begin( m_stackRT ), std::end( m_stackRT ), TrackableStdStack{} ); + m_stackDS = TrackableStdStack(); + m_boundDepthStencil = {}; + m_defaultBackBuffer = {}; + m_swapChain = Tr2SwapChainAL(); if( m_isPrimary ) { @@ -105,11 +118,11 @@ MTLClearColor MakeClearColor( uint32_t color ) m_depthCompareFunction = MTLCompareFunctionAlways; m_metalIndexBuffer = nil; - m_caMetalLayer = nil; + m_caMetalLayer = nil; m_defaultBackBuffer.m_texture = std::make_shared(); m_boundDepthStencil.m_texture = nullptr; m_needsDrawResourceCheck = true; - + m_swapChain.m_swapChain = std::make_shared(); } @@ -143,10 +156,10 @@ MTLClearColor MakeClearColor( uint32_t color ) m_isValid = false; } -ALResult Tr2RenderContextAL::SetStreamSource(uint32_t stream, - const Tr2BufferAL & buffer, - uint32_t offset, - uint32_t stride ) throw( ) +ALResult Tr2RenderContextAL::SetStreamSource( uint32_t stream, + const Tr2BufferAL& buffer, + uint32_t offset, + uint32_t stride ) throw() { if( !IsValid() ) { @@ -172,19 +185,19 @@ MTLClearColor MakeClearColor( uint32_t color ) return S_OK; } -ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer) throw( ) +ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer ) throw() { return SetIndices( buffer, buffer.GetDesc().stride ); } -ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, int stride) throw( ) +ALResult Tr2RenderContextAL::SetIndices( const Tr2BufferAL& buffer, int stride ) throw() { if( !buffer.IsValid() ) { m_metalIndexBuffer = nil; return S_OK; } - + if( stride == 2 ) { m_metalIndexType = MTLIndexTypeUInt16; @@ -221,75 +234,76 @@ MTLClearColor MakeClearColor( uint32_t color ) } } -ALResult Tr2RenderContextAL::ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw( ) +ALResult Tr2RenderContextAL::ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw() { - if( !buffer.IsValid() ) - { - return E_INVALIDARG; - } + if( !buffer.IsValid() ) + { + return E_INVALIDARG; + } m_workQueue->ClearBuffer( buffer.m_buffer->GetMetalBuffer(), values ); return S_OK; } -ALResult Tr2RenderContextAL::ClearUav( const Tr2BufferAL& buffer, const uint32_t values[4] ) throw( ) +ALResult Tr2RenderContextAL::ClearUav( const Tr2BufferAL& buffer, const uint32_t values[4] ) throw() { - if( !buffer.IsValid() ) - { - return E_INVALIDARG; - } + if( !buffer.IsValid() ) + { + return E_INVALIDARG; + } m_workQueue->ClearBuffer( buffer.m_buffer->GetMetalBuffer(), values ); return S_OK; } -ALResult Tr2RenderContextAL::ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const float values[4] ) throw( ) +ALResult Tr2RenderContextAL::ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const float values[4] ) throw() { - if( !texture.IsValid() ) - { - return E_INVALIDARG; - } + if( !texture.IsValid() ) + { + return E_INVALIDARG; + } m_workQueue->ClearTexture( texture.m_texture->GetMetalTexture(), mipLevel, values ); return S_OK; } -ALResult Tr2RenderContextAL::ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const uint32_t values[4] ) throw( ) +ALResult + Tr2RenderContextAL::ClearUav( const Tr2TextureAL& texture, uint32_t mipLevel, const uint32_t values[4] ) throw() { - if( !texture.IsValid() ) - { - return E_INVALIDARG; - } + if( !texture.IsValid() ) + { + return E_INVALIDARG; + } m_workQueue->ClearTexture( texture.m_texture->GetMetalTexture(), mipLevel, values ); return S_OK; } -ALResult Tr2RenderContextAL::CopySubBuffer( Tr2BufferAL& dest, uint32_t destOffset, Tr2BufferAL& src, uint32_t srcOffset, uint32_t length ) +ALResult Tr2RenderContextAL::CopySubBuffer( Tr2BufferAL& dest, + uint32_t destOffset, + Tr2BufferAL& src, + uint32_t srcOffset, + uint32_t length ) { - if( !dest.IsValid() || !src.IsValid() ) - { - return E_INVALIDARG; - } - m_workQueue->CopyBufferToBuffer( dest.m_buffer->GetMetalBuffer(), destOffset, src.m_buffer->GetMetalBuffer(), srcOffset, length ); + if( !dest.IsValid() || !src.IsValid() ) + { + return E_INVALIDARG; + } + m_workQueue->CopyBufferToBuffer( + dest.m_buffer->GetMetalBuffer(), destOffset, src.m_buffer->GetMetalBuffer(), srcOffset, length ); return S_OK; } -ALResult Tr2RenderContextAL::Clear( - uint32_t clearFlags, - uint32_t color, - float depth, - uint32_t stencil, - uint32_t slot ) +ALResult Tr2RenderContextAL::Clear( uint32_t clearFlags, uint32_t color, float depth, uint32_t stencil, uint32_t slot ) { if( !IsValid() ) { return E_FAIL; } - MTLClearColor *clearColor = nullptr; - float *clearDepth = nullptr; - uint32_t *clearStencil = nullptr; + MTLClearColor* clearColor = nullptr; + float* clearDepth = nullptr; + uint32_t* clearStencil = nullptr; MTLClearColor metalClearColor; if( clearFlags & Tr2RenderContextEnum::CLEARFLAGS_TARGET ) @@ -343,20 +357,20 @@ MTLClearColor MakeClearColor( uint32_t color ) { return E_INVALIDARG; } - if (topology == TOP_TRIANGLE_FAN) + if( topology == TOP_TRIANGLE_FAN ) { CCP_AL_LOGERR( "Fan topology is not supported in Metal." ); return E_FAIL; } - static const MetalPrimitiveInfo topologyMapping[ TOP_MAX_TOPOLOGY ] = { - {MTLPrimitiveTypeTriangle, 3, 0, false}, // TOP_INVALID - {MTLPrimitiveTypeTriangle, 3, 0, true}, // TOP_TRIANGLES, - {MTLPrimitiveTypeTriangleStrip, 1, 2, true}, // TOP_TRIANGLE_STRIP - {MTLPrimitiveTypeTriangle, 3, 0, false}, // TOP_TRIANGLE_FAN - NOT SUPPORTED! - {MTLPrimitiveTypeLine, 2, 0, true}, // TOP_LINES - {MTLPrimitiveTypeLineStrip, 1, 1, true}, // TOP_LINE_STRIP - {MTLPrimitiveTypePoint, 1, 0, false} // TOP_POINTS + static const MetalPrimitiveInfo topologyMapping[TOP_MAX_TOPOLOGY] = { + { MTLPrimitiveTypeTriangle, 3, 0, false }, // TOP_INVALID + { MTLPrimitiveTypeTriangle, 3, 0, true }, // TOP_TRIANGLES, + { MTLPrimitiveTypeTriangleStrip, 1, 2, true }, // TOP_TRIANGLE_STRIP + { MTLPrimitiveTypeTriangle, 3, 0, false }, // TOP_TRIANGLE_FAN - NOT SUPPORTED! + { MTLPrimitiveTypeLine, 2, 0, true }, // TOP_LINES + { MTLPrimitiveTypeLineStrip, 1, 1, true }, // TOP_LINE_STRIP + { MTLPrimitiveTypePoint, 1, 0, false } // TOP_POINTS }; m_metalPrimitiveInfo = topologyMapping[topology]; @@ -369,20 +383,20 @@ MTLClearColor MakeClearColor( uint32_t color ) { CCP_ASSERT( m_metalPrimitiveInfo.validType ); - return (m_metalPrimitiveInfo.primitiveToIndexMultiplier * primitiveCount) + m_metalPrimitiveInfo.primtiveToIndexAddition; + return ( m_metalPrimitiveInfo.primitiveToIndexMultiplier * primitiveCount ) + + m_metalPrimitiveInfo.primtiveToIndexAddition; } -ALResult Tr2RenderContextAL::DrawIndexedPrimitive( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, - uint32_t minimumIndex ) +ALResult Tr2RenderContextAL::DrawIndexedPrimitive( uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, + uint32_t minimumIndex ) { - if( m_metalIndexBuffer == nil ) - { - return E_INVALIDARG; - } - + if( m_metalIndexBuffer == nil ) + { + return E_INVALIDARG; + } + auto vc = ComputeVertexCount( primitiveCount ); CCP_STATS_ADD( primitiveCount, primitiveCount ); @@ -391,22 +405,22 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - m_workQueue->DrawIndexedPrimitives(m_metalPrimitiveInfo.metalPrimitiveType, vc, m_metalIndexType, m_metalIndexBuffer, startIndex, 1); + m_workQueue->DrawIndexedPrimitives( + m_metalPrimitiveInfo.metalPrimitiveType, vc, m_metalIndexType, m_metalIndexBuffer, startIndex, 1 ); return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedInstanced( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, - uint32_t numInstances ) +ALResult Tr2RenderContextAL::DrawIndexedInstanced( uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, + uint32_t numInstances ) { - if( m_metalIndexBuffer == nil ) - { - return E_INVALIDARG; - } - + if( m_metalIndexBuffer == nil ) + { + return E_INVALIDARG; + } + auto vc = ComputeVertexCount( primitiveCount ); CCP_STATS_ADD( primitiveCount, primitiveCount * numInstances ); @@ -415,39 +429,45 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - m_workQueue->DrawIndexedPrimitives(m_metalPrimitiveInfo.metalPrimitiveType, vc, m_metalIndexType, m_metalIndexBuffer, startIndex, numInstances); + m_workQueue->DrawIndexedPrimitives( + m_metalPrimitiveInfo.metalPrimitiveType, vc, m_metalIndexType, m_metalIndexBuffer, startIndex, numInstances ); return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedInstanced( - uint32_t indexCountPerInstance, - uint32_t instanceCount, - uint32_t startIndexLocation, - int32_t baseVertexLocation, - uint32_t startInstanceLocation ) +ALResult Tr2RenderContextAL::DrawIndexedInstanced( uint32_t indexCountPerInstance, + uint32_t instanceCount, + uint32_t startIndexLocation, + int32_t baseVertexLocation, + uint32_t startInstanceLocation ) { - if( m_metalIndexBuffer == nil ) - { - return E_INVALIDARG; - } - + if( m_metalIndexBuffer == nil ) + { + return E_INVALIDARG; + } + CCP_STATS_ADD( primitiveCount, indexCountPerInstance * instanceCount / 3 ); CCP_STATS_ADD( vertexCount, indexCountPerInstance * instanceCount ); CCP_STATS_INC( sceneDrawcallCount ); CheckDrawResources(); - m_workQueue->DrawIndexedPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, indexCountPerInstance, m_metalIndexType, m_metalIndexBuffer, startIndexLocation, instanceCount, baseVertexLocation, startInstanceLocation ); + m_workQueue->DrawIndexedPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, + indexCountPerInstance, + m_metalIndexType, + m_metalIndexBuffer, + startIndexLocation, + instanceCount, + baseVertexLocation, + startInstanceLocation ); return S_OK; } -ALResult Tr2RenderContextAL::DrawInstanced( - uint32_t vertexCountPerInstance, - uint32_t instanceCount, - uint32_t startVertexLocation, - uint32_t startInstanceLocation ) +ALResult Tr2RenderContextAL::DrawInstanced( uint32_t vertexCountPerInstance, + uint32_t instanceCount, + uint32_t startVertexLocation, + uint32_t startInstanceLocation ) { CCP_STATS_ADD( primitiveCount, vertexCountPerInstance * instanceCount / 3 ); CCP_STATS_ADD( vertexCount, vertexCountPerInstance * instanceCount ); @@ -455,7 +475,11 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - m_workQueue->DrawPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, vertexCountPerInstance, startVertexLocation, instanceCount, startInstanceLocation ); + m_workQueue->DrawPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, + vertexCountPerInstance, + startVertexLocation, + instanceCount, + startInstanceLocation ); return S_OK; } @@ -471,7 +495,12 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - m_workQueue->DrawIndexedPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, m_metalIndexType, m_metalIndexBuffer, 0, params.m_buffer->GetMetalBuffer(), offset ); + m_workQueue->DrawIndexedPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, + m_metalIndexType, + m_metalIndexBuffer, + 0, + params.m_buffer->GetMetalBuffer(), + offset ); return S_OK; } @@ -496,10 +525,10 @@ MTLClearColor MakeClearColor( uint32_t color ) { // Only need to check resources if we don't have a resource set and the shader has changed since the last draw. if( m_needsDrawResourceCheck && !m_resourceSet.IsValid() ) - { - m_shaderProgram.m_program->SetDummyResources( *m_workQueue ); - m_needsDrawResourceCheck = false; - } + { + m_shaderProgram.m_program->SetDummyResources( *m_workQueue ); + m_needsDrawResourceCheck = false; + } if( m_vertexLayout.IsValid() ) { @@ -521,15 +550,14 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - m_workQueue->DrawPrimitives(m_metalPrimitiveInfo.metalPrimitiveType, vc, startVertex, 1); + m_workQueue->DrawPrimitives( m_metalPrimitiveInfo.metalPrimitiveType, vc, startVertex, 1 ); return S_OK; } -ALResult Tr2RenderContextAL::DrawPrimitiveUP( - uint32_t primitiveCount, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) +ALResult Tr2RenderContextAL::DrawPrimitiveUP( uint32_t primitiveCount, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ) { auto vc = ComputeVertexCount( primitiveCount ); @@ -537,33 +565,39 @@ MTLClearColor MakeClearColor( uint32_t color ) CCP_STATS_ADD( vertexCount, vc ); CCP_STATS_INC( sceneDrawcallCount ); - CheckDrawResources(); + CheckDrawResources(); - return m_drawUPHelper.DrawPrimitiveUP( m_topology, primitiveCount, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); + return m_drawUPHelper.DrawPrimitiveUP( + m_topology, primitiveCount, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ) { CCP_STATS_ADD( primitiveCount, primitiveCount ); CCP_STATS_ADD( vertexCount, numVertices ); CCP_STATS_INC( sceneDrawcallCount ); - CheckDrawResources(); + CheckDrawResources(); - return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); + return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, + numVertices, + primitiveCount, + indexData, + vertexStreamZeroData, + vertexStreamZeroStride, + *this, + GetPrimaryRenderContext() ); } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride ) +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ) { CCP_STATS_ADD( primitiveCount, primitiveCount ); CCP_STATS_ADD( vertexCount, numVertices ); @@ -571,7 +605,14 @@ MTLClearColor MakeClearColor( uint32_t color ) CheckDrawResources(); - return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, numVertices, primitiveCount, indexData, vertexStreamZeroData, vertexStreamZeroStride, *this, GetPrimaryRenderContext() ); + return m_drawUPHelper.DrawIndexedPrimitiveUP( m_topology, + numVertices, + primitiveCount, + indexData, + vertexStreamZeroData, + vertexStreamZeroStride, + *this, + GetPrimaryRenderContext() ); } ALResult Tr2RenderContextAL::RunComputeShader( unsigned groupDimX, unsigned groupDimY, unsigned groupDimZ ) @@ -593,31 +634,37 @@ MTLClearColor MakeClearColor( uint32_t color ) return S_OK; } -ALResult Tr2RenderContextAL::DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2RtShaderTableAL& shaderTable, const wchar_t* rayGenShader, uint32_t width, uint32_t height, uint32_t depth ) +ALResult Tr2RenderContextAL::DispatchRays( Tr2RtPipelineStateAL& pipeline, + Tr2RtShaderTableAL& shaderTable, + const wchar_t* rayGenShader, + uint32_t width, + uint32_t height, + uint32_t depth ) { - if( !pipeline.IsValid() ) - { - return E_FAIL; - } - auto rayGen = pipeline.TrinityALImpl_GetObject()->GetRayGenIndex( rayGenShader ); - if( !rayGen ) - { - return E_INVALIDARG; - } - if (@available(macOS 11.0, *)) { - // pass on shaderTable to bind it to the RayGen shader - SetShaderProgram( pipeline.TrinityALImpl_GetObject()->GetShaderProgram( *rayGen ) ); - m_workQueue->DispatchRays( pipeline.TrinityALImpl_GetObject(), shaderTable.TrinityALImpl_GetObject(), *rayGen, width, height, depth ); - } - - return S_OK; + if( !pipeline.IsValid() ) + { + return E_FAIL; + } + auto rayGen = pipeline.TrinityALImpl_GetObject()->GetRayGenIndex( rayGenShader ); + if( !rayGen ) + { + return E_INVALIDARG; + } + if( @available( macOS 11.0, * ) ) + { + // pass on shaderTable to bind it to the RayGen shader + SetShaderProgram( pipeline.TrinityALImpl_GetObject()->GetShaderProgram( *rayGen ) ); + m_workQueue->DispatchRays( + pipeline.TrinityALImpl_GetObject(), shaderTable.TrinityALImpl_GetObject(), *rayGen, width, height, depth ); + } + + return S_OK; } -ALResult Tr2RenderContextAL::SetConstants( - const Tr2ConstantBufferAL& buffer, - ShaderType shaderType, - uint32_t registerIndex, - uint32_t maxRegisterCount ) +ALResult Tr2RenderContextAL::SetConstants( const Tr2ConstantBufferAL& buffer, + ShaderType shaderType, + uint32_t registerIndex, + uint32_t maxRegisterCount ) { if( registerIndex >= METAL_CONST_BUFFER_COUNT ) { @@ -631,21 +678,22 @@ MTLClearColor MakeClearColor( uint32_t color ) uint64_t Tr2RenderContextAL::UploadConstants( const void* data, size_t size ) { - TrinityALImpl::ConstantBufferToken token; - token.frame = 0; - token.offset = 0; - GetMetalWorkQueue()->UploadConstants( data, uint32_t( size ), token ); - return token.offset; + TrinityALImpl::ConstantBufferToken token; + token.frame = 0; + token.offset = 0; + GetMetalWorkQueue()->UploadConstants( data, uint32_t( size ), token ); + return token.offset; } uint64_t Tr2RenderContextAL::UploadConstants( const Tr2ConstantBufferAL& buffer ) { - if( buffer.m_buffer->m_buffer ) - { - GetMetalWorkQueue()->UploadConstants( buffer.m_buffer->m_buffer, buffer.m_buffer->m_size, buffer.m_buffer->m_token ); - return buffer.m_buffer->m_token.offset; - } - return 0; + if( buffer.m_buffer->m_buffer ) + { + GetMetalWorkQueue()->UploadConstants( + buffer.m_buffer->m_buffer, buffer.m_buffer->m_size, buffer.m_buffer->m_token ); + return buffer.m_buffer->m_token.offset; + } + return 0; } void Tr2RenderContextAL::SetReadOnlyDepth( bool enable ) @@ -663,12 +711,12 @@ MTLClearColor MakeClearColor( uint32_t color ) // We don't need to do anything special for READ -> WRITE transition return; } - + if( !m_boundDepthStencil.IsValid() ) { return; } - + // JM - Blunt approach for now - barrier on render targets. Added proper resource tracking later (maybe). m_workQueue->RenderTargetBarrier(); } @@ -694,7 +742,7 @@ MTLClearColor MakeClearColor( uint32_t color ) m_boundDepthStencil = depthStencil; - m_workQueue->SetDepthStencilAttachment(depthStencilTexture); + m_workQueue->SetDepthStencilAttachment( depthStencilTexture ); return S_OK; } @@ -703,9 +751,8 @@ MTLClearColor MakeClearColor( uint32_t color ) id renderTargetTexture = nil; if( renderTarget.m_texture->IsValid() ) { - renderTargetTexture = !m_srgbWriteEnable ? - renderTarget.m_texture->GetMetalTexture() : - renderTarget.m_texture->GetSRGBViewMetalTexture(); + renderTargetTexture = !m_srgbWriteEnable ? renderTarget.m_texture->GetMetalTexture() : + renderTarget.m_texture->GetSRGBViewMetalTexture(); } m_workQueue->SetRenderAttachments( renderTargetTexture, slot, slice ); @@ -714,48 +761,48 @@ MTLClearColor MakeClearColor( uint32_t color ) if( m_boundRenderTargets[0].texture.IsValid() ) { - SetViewport( Tr2Viewport( m_boundRenderTargets[0].texture.GetWidth(), m_boundRenderTargets[0].texture.GetHeight() ) ); + SetViewport( + Tr2Viewport( m_boundRenderTargets[0].texture.GetWidth(), m_boundRenderTargets[0].texture.GetHeight() ) ); } return S_OK; } -ALResult Tr2RenderContextAL::CreateDevice( - uint32_t Adapter, - Tr2WindowHandle hFocusWindow, - const Tr2PresentParametersAL& presentationParameters ) +ALResult Tr2RenderContextAL::CreateDevice( uint32_t Adapter, + Tr2WindowHandle hFocusWindow, + const Tr2PresentParametersAL& presentationParameters ) { m_isValid = true; m_workQueue = m_metalContext->GetPrimaryWorkQueue(); #if 0 NSView *view = (NSView *)hFocusWindow; #else - NSView *view = (NSView *)presentationParameters.outputWindow; + NSView* view = (NSView*)presentationParameters.outputWindow; #endif - m_caMetalLayer = (CAMetalLayer *)view.layer; - METAL_LOG(@"Creating device"); + m_caMetalLayer = (CAMetalLayer*)view.layer; + METAL_LOG( @"Creating device" ); SetPresentParameters( Adapter, presentationParameters ); if( m_events ) { m_events->OnContextCreated( *this ); } - - if( @available( macOS 11.0, * ) ) - { - auto device = m_metalContext->GetDevice(); + + if( @available( macOS 11.0, * ) ) + { + auto device = m_metalContext->GetDevice(); bool isAppleSilicon = [device supportsFamily:MTLGPUFamilyMac2] && [device supportsFamily:MTLGPUFamilyApple7]; - bool raytracingAvailable = device.supportsRaytracing && isAppleSilicon; - m_caps.m_supportsRaytracing = raytracingAvailable; - if( m_caps.m_supportsRaytracing ) - { - CCP_LOGNOTICE( "Device supports raytracing" ); - } - else - { - CCP_LOGNOTICE( "Device does not support raytracing" ); - } - } + bool raytracingAvailable = device.supportsRaytracing && isAppleSilicon; + m_caps.m_supportsRaytracing = raytracingAvailable; + if( m_caps.m_supportsRaytracing ) + { + CCP_LOGNOTICE( "Device supports raytracing" ); + } + else + { + CCP_LOGNOTICE( "Device does not support raytracing" ); + } + } return S_OK; } @@ -764,9 +811,10 @@ MTLClearColor MakeClearColor( uint32_t color ) return m_defaultBackBuffer.GetFormat(); } -ALResult Tr2RenderContextAL::SetPresentParameters( unsigned adapter, const Tr2PresentParametersAL& presentationParameters ) +ALResult Tr2RenderContextAL::SetPresentParameters( unsigned adapter, + const Tr2PresentParametersAL& presentationParameters ) { - TrinityALImpl::MetalContext *metalContext = GetMetalContext(); + TrinityALImpl::MetalContext* metalContext = GetMetalContext(); #if 0 m_caMetalLayer.device = metalContext->GetDevice(); m_caMetalLayer.pixelFormat = metalContext->m_utils->GetMTLPixelFormat(PIXEL_FORMAT_B8G8R8A8_UNORM); @@ -785,25 +833,20 @@ MTLClearColor MakeClearColor( uint32_t color ) m_presentParameters.mode.format = PIXEL_FORMAT_B8G8R8A8_UNORM; } m_swapChain.m_swapChain->Create( presentationParameters.outputWindow, *this ); - + NSView* view = (NSView*)presentationParameters.outputWindow; if( view.layer && [view.layer isKindOfClass:CAMetalLayer.class] ) { - ((CAMetalLayer*)view.layer).displaySyncEnabled = presentationParameters.presentInterval == Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE ? NO : YES; + ( (CAMetalLayer*)view.layer ).displaySyncEnabled = + presentationParameters.presentInterval == Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE ? NO : YES; } m_defaultBackBuffer = m_swapChain.GetBackBuffer(); - // Set a default viewport based around this - m_workQueue->SetViewport( - 0.0, - 0.0, - m_defaultBackBuffer.GetWidth(), - m_defaultBackBuffer.GetHeight(), - 0.0, - 1.0); + // Set a default viewport based around this + m_workQueue->SetViewport( 0.0, 0.0, m_defaultBackBuffer.GetWidth(), m_defaultBackBuffer.GetHeight(), 0.0, 1.0 ); ResetRenderTargets(); - SetRenderTarget( m_defaultBackBuffer ); + SetRenderTarget( m_defaultBackBuffer ); Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0, 0, 0 ); return S_OK; @@ -859,20 +902,19 @@ MTLClearColor MakeClearColor( uint32_t color ) { if( m_shaderProgram == shaderProgram ) { - return S_OK; - } + return S_OK; + } m_shaderProgram = shaderProgram; // Move this into shaderProgram itself to remove need for getters. - m_workQueue->SetShaders( - shaderProgram.m_program->GetVertexShader(), - shaderProgram.m_program->GetFragmentShader(), - shaderProgram.m_program->GetComputeKernel(), - shaderProgram.m_program->GetThreadGroupSize(), - shaderProgram.m_program->GetResourceMasks() ); + m_workQueue->SetShaders( shaderProgram.m_program->GetVertexShader(), + shaderProgram.m_program->GetFragmentShader(), + shaderProgram.m_program->GetComputeKernel(), + shaderProgram.m_program->GetThreadGroupSize(), + shaderProgram.m_program->GetResourceMasks() ); - m_needsDrawResourceCheck = true; + m_needsDrawResourceCheck = true; return S_OK; } @@ -885,12 +927,11 @@ MTLClearColor MakeClearColor( uint32_t color ) // ALResult Tr2RenderContextAL::SetRenderState( RenderState state, uint32_t value ) { - TrinityALImpl::MetalContext *metalContext = GetMetalContext(); + TrinityALImpl::MetalContext* metalContext = GetMetalContext(); switch( state ) { - case RS_ZENABLE: - { + case RS_ZENABLE: { // You don't enable/disable depth test explicitly in Metal you just set the compare mode. if( !value ) { @@ -904,14 +945,12 @@ MTLClearColor MakeClearColor( uint32_t color ) } return S_OK; } - case RS_ZWRITEENABLE: - { + case RS_ZWRITEENABLE: { m_depthWriteEnabled = value ? true : false; m_workQueue->SetDepthState( m_depthWriteEnabled && !m_readOnlyDepth ); return S_OK; } - case RS_ZFUNC: - { + case RS_ZFUNC: { // Need to store this as depth test can be enabled/disabled (which Metal has no analog for - you just set the compare mode). m_depthCompareFunction = metalContext->m_utils->GetMTLCompareFunction( value ); if( !m_depthCompareEnabled ) @@ -928,132 +967,116 @@ MTLClearColor MakeClearColor( uint32_t color ) case RS_ALPHATESTENABLE: case RS_ALPHAREF: case RS_ALPHAFUNC: - return S_OK; + return S_OK; case RS_CLIPPING: case RS_CLIPPLANEENABLE: return S_OK; - case RS_SRCBLEND: - { + case RS_SRCBLEND: { MTLBlendFactor srcBlend = metalContext->m_utils->GetMTLBlendFactor( value ); m_workQueue->SetSrcBlend( 0, srcBlend ); return S_OK; } - case RS_DESTBLEND: - { + case RS_DESTBLEND: { MTLBlendFactor destBlend = metalContext->m_utils->GetMTLBlendFactor( value ); m_workQueue->SetDestBlend( 0, destBlend ); return S_OK; } - case RS_SRCBLENDALPHA: - { + case RS_SRCBLENDALPHA: { MTLBlendFactor srcBlend = metalContext->m_utils->GetMTLBlendFactor( value ); m_workQueue->SetSrcBlendAlpha( 0, srcBlend ); return S_OK; } - case RS_DESTBLENDALPHA: - { + case RS_DESTBLENDALPHA: { MTLBlendFactor destBlend = metalContext->m_utils->GetMTLBlendFactor( value ); m_workQueue->SetDestBlendAlpha( 0, destBlend ); return S_OK; } - case RS_BLENDOP: - { + case RS_BLENDOP: { MTLBlendOperation blendOp = metalContext->m_utils->GetMTLBlendOperation( value ); m_workQueue->SetBlendOp( 0, blendOp ); return S_OK; } - case RS_BLENDOPALPHA: - { + case RS_BLENDOPALPHA: { MTLBlendOperation blendOp = metalContext->m_utils->GetMTLBlendOperation( value ); m_workQueue->SetBlendOpAlpha( 0, blendOp ); return S_OK; } - case RS_CULLMODE: - { + case RS_CULLMODE: { MTLCullMode cullMode = metalContext->m_utils->GetMTLCullMode( (Tr2RenderContextEnum::CullMode)value ); m_workQueue->SetCullMode( cullMode ); return S_OK; } - case RS_ALPHABLENDENABLE: - { - TrinityALImpl::MetalBlendType blendType = value ? ( m_separateAlphaBlendEnabled ? TrinityALImpl::METAL_BLENDING_ENABLED_SEPARATE_ALPHA : TrinityALImpl::METAL_BLENDING_ENABLED ) : TrinityALImpl::METAL_BLENDING_DISABLED; + case RS_ALPHABLENDENABLE: { + TrinityALImpl::MetalBlendType blendType = value ? + ( m_separateAlphaBlendEnabled ? TrinityALImpl::METAL_BLENDING_ENABLED_SEPARATE_ALPHA : + TrinityALImpl::METAL_BLENDING_ENABLED ) : + TrinityALImpl::METAL_BLENDING_DISABLED; m_alphaBlendEnable = value != 0; m_workQueue->SetBlendType( 0, blendType ); return S_OK; } - case RS_STENCILENABLE: - { + case RS_STENCILENABLE: { bool stencilEnable = value ? true : false; m_workQueue->SetStencilState( stencilEnable ); return S_OK; } - case RS_STENCILFAIL: - { + case RS_STENCILFAIL: { MTLStencilOperation stencilOp = metalContext->m_utils->GetMTLStencilOperation( value ); m_workQueue->SetStencilFailOp( stencilOp ); return S_OK; } - case RS_STENCILZFAIL: - { + case RS_STENCILZFAIL: { MTLStencilOperation stencilOp = metalContext->m_utils->GetMTLStencilOperation( value ); m_workQueue->SetStencilDepthFailOp( stencilOp ); return S_OK; } - case RS_STENCILPASS: - { + case RS_STENCILPASS: { MTLStencilOperation stencilOp = metalContext->m_utils->GetMTLStencilOperation( value ); m_workQueue->SetStencilPassOp( stencilOp ); return S_OK; } - case RS_STENCILFUNC: - { + case RS_STENCILFUNC: { MTLCompareFunction stencilCompareFn = metalContext->m_utils->GetMTLCompareFunction( value ); m_workQueue->SetStencilCompareFn( stencilCompareFn ); return S_OK; } - case RS_STENCILREF: - { + case RS_STENCILREF: { m_workQueue->SetStencilRefValue( value ); return S_OK; } - case RS_STENCILMASK: - { + case RS_STENCILMASK: { m_workQueue->SetStencilMask( value ); return S_OK; } - case RS_COLORWRITEENABLE: - { + case RS_COLORWRITEENABLE: { MTLColorWriteMask writeMask = metalContext->m_utils->GetMTLColorWriteMask( (ColorWriteEnable)value ); m_workQueue->SetColorWriteMask( 0, writeMask ); return S_OK; } - case RS_SLOPESCALEDEPTHBIAS: - { - float slopeScale = *(float *)&value; + case RS_SLOPESCALEDEPTHBIAS: { + float slopeScale = *(float*)&value; m_workQueue->SetDepthBias( nil, &slopeScale, nil ); return S_OK; } - case RS_BLENDFACTOR: - { + case RS_BLENDFACTOR: { m_workQueue->SetBlendColor( 0, value ); return S_OK; } case RS_DEPTHBIAS: - case RS_ZBIAS: - { - float depthBias = *(float *)&value; + case RS_ZBIAS: { + float depthBias = *(float*)&value; m_workQueue->SetDepthBias( &depthBias, nil, nil ); return S_OK; } - case RS_DEPTH_CLIP_ENABLE: - { + case RS_DEPTH_CLIP_ENABLE: { m_workQueue->SetDepthClipEnable( value != 0 ); return S_OK; } - case RS_SEPARATEALPHABLENDENABLE: - { + case RS_SEPARATEALPHABLENDENABLE: { m_separateAlphaBlendEnabled = value != 0; - TrinityALImpl::MetalBlendType blendType = m_alphaBlendEnable ? ( value ? TrinityALImpl::METAL_BLENDING_ENABLED_SEPARATE_ALPHA : TrinityALImpl::METAL_BLENDING_ENABLED ) : TrinityALImpl::METAL_BLENDING_DISABLED; + TrinityALImpl::MetalBlendType blendType = m_alphaBlendEnable ? + ( value ? TrinityALImpl::METAL_BLENDING_ENABLED_SEPARATE_ALPHA : TrinityALImpl::METAL_BLENDING_ENABLED ) : + TrinityALImpl::METAL_BLENDING_DISABLED; m_workQueue->SetBlendType( 0, blendType ); return S_OK; } @@ -1066,7 +1089,8 @@ MTLClearColor MakeClearColor( uint32_t color ) { if( m_boundRenderTargets[i].texture.IsValid() ) { - id renderTargetTexture = m_boundRenderTargets[i].texture.m_texture->GetSRGBViewMetalTexture(); + id renderTargetTexture = + m_boundRenderTargets[i].texture.m_texture->GetSRGBViewMetalTexture(); m_workQueue->SetRenderAttachments( renderTargetTexture, i, m_boundRenderTargets[i].slice ); } } @@ -1083,18 +1107,18 @@ MTLClearColor MakeClearColor( uint32_t color ) } } return S_OK; - case RS_FILLMODE: - switch( value ) - { - case FM_SOLID: - m_workQueue->SetFillMode( MTLTriangleFillModeFill ); - return S_OK; - case FM_WIREFRAME: - m_workQueue->SetFillMode( MTLTriangleFillModeLines ); - return S_OK; - default: - return E_INVALIDARG; - } + case RS_FILLMODE: + switch( value ) + { + case FM_SOLID: + m_workQueue->SetFillMode( MTLTriangleFillModeFill ); + return S_OK; + case FM_WIREFRAME: + m_workQueue->SetFillMode( MTLTriangleFillModeLines ); + return S_OK; + default: + return E_INVALIDARG; + } default: return E_INVALIDARG; } @@ -1103,9 +1127,7 @@ MTLClearColor MakeClearColor( uint32_t color ) ALResult Tr2RenderContextAL::SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ) { - for( uint32_t i = 0; - ( count != 0 && i != count ) || ( count == 0 && *stateValuePairs ); - ++i, stateValuePairs += 2 ) + for( uint32_t i = 0; ( count != 0 && i != count ) || ( count == 0 && *stateValuePairs ); ++i, stateValuePairs += 2 ) { SetRenderState( static_cast( stateValuePairs[0] ), stateValuePairs[1] ); } @@ -1131,7 +1153,11 @@ MTLClearColor MakeClearColor( uint32_t color ) const ShaderType stages[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; for( auto stage : stages ) { - m_workQueue->SetBuffers( stage, rs.m_buffers[stage], rs.m_buffersMask[stage], GetMetalContext()->GetHeapViewBuffer(), rs.m_heapViewMask[stage] ); + m_workQueue->SetBuffers( stage, + rs.m_buffers[stage], + rs.m_buffersMask[stage], + GetMetalContext()->GetHeapViewBuffer(), + rs.m_heapViewMask[stage] ); m_workQueue->SetTextures( stage, rs.m_textures[stage], rs.m_texturesRange[stage] ); m_workQueue->SetSamplers( stage, rs.m_samplers[stage], rs.m_samplersRange[stage] ); } @@ -1147,7 +1173,7 @@ MTLClearColor MakeClearColor( uint32_t color ) } } - m_needsDrawResourceCheck = true; + m_needsDrawResourceCheck = true; return S_OK; } @@ -1155,7 +1181,8 @@ MTLClearColor MakeClearColor( uint32_t color ) { m_viewport = viewport; TrinityALImpl::MetalContext* metalContext = GetMetalContext(); - m_workQueue->SetViewport( viewport.m_x, viewport.m_y, viewport.m_width, viewport.m_height, viewport.m_minZ, viewport.m_maxZ ); + m_workQueue->SetViewport( + viewport.m_x, viewport.m_y, viewport.m_width, viewport.m_height, viewport.m_minZ, viewport.m_maxZ ); return S_OK; } @@ -1235,7 +1262,7 @@ MTLClearColor MakeClearColor( uint32_t color ) } else { - width = m_boundRenderTargets[slot].texture.GetWidth(); + width = m_boundRenderTargets[slot].texture.GetWidth(); height = m_boundRenderTargets[slot].texture.GetHeight(); } return S_OK; @@ -1285,13 +1312,12 @@ MTLClearColor MakeClearColor( uint32_t color ) return E_FAIL; } -ALResult Tr2RenderContextAL::GetGpuPageFaultResource( - Tr2RenderContextEnum::PixelFormat&, - uint64_t&, - uint32_t&, - uint32_t&, - uint32_t&, - uint32_t& ) const +ALResult Tr2RenderContextAL::GetGpuPageFaultResource( Tr2RenderContextEnum::PixelFormat&, + uint64_t&, + uint32_t&, + uint32_t&, + uint32_t&, + uint32_t& ) const { return E_FAIL; } @@ -1308,7 +1334,9 @@ MTLClearColor MakeClearColor( uint32_t color ) m_workQueue->RenderPassHint( hint ); } -void Tr2RenderContextAL::RenderPassHint( const Tr2ColorAttachment& rt0, const Tr2ColorAttachment& rt1, const Tr2DepthAttachment& depth ) +void Tr2RenderContextAL::RenderPassHint( const Tr2ColorAttachment& rt0, + const Tr2ColorAttachment& rt1, + const Tr2DepthAttachment& depth ) { TrinityALImpl::MetalRenderPassHint hint; hint.depth = { MTLLoadAction( depth.load ), MTLStoreAction( depth.store ), depth.clearValue }; @@ -1319,12 +1347,11 @@ MTLClearColor MakeClearColor( uint32_t color ) hint.color[i] = { MTLLoadActionDontCare, MTLStoreActionDontCare }; } m_workQueue->RenderPassHint( hint ); - } void Tr2RenderContextAL::EndRenderPassHint() { - m_workQueue->EndRenderPassHint(); + m_workQueue->EndRenderPassHint(); } uint32_t Tr2RenderContextAL::BeginParallelEncoding( uint32_t requestedEncodersCount ) @@ -1353,7 +1380,7 @@ MTLClearColor MakeClearColor( uint32_t color ) { return E_INVALIDCALL; } - + context->m_isValid = m_isValid; context->m_isPrimary = false; @@ -1366,11 +1393,11 @@ MTLClearColor MakeClearColor( uint32_t color ) context->m_srgbWriteEnable = m_srgbWriteEnable; context->m_alphaBlendEnable = m_alphaBlendEnable; context->m_separateAlphaBlendEnabled = m_separateAlphaBlendEnabled; - + context->m_metalPrimitiveInfo = m_metalPrimitiveInfo; context->m_metalIndexType = m_metalIndexType; context->m_depthCompareFunction = m_depthCompareFunction; - + context->m_vertexLayout = Tr2VertexLayoutAL(); context->m_resourceSet = Tr2ResourceSetAL(); context->m_shaderProgram = Tr2ShaderProgramAL(); @@ -1379,21 +1406,26 @@ MTLClearColor MakeClearColor( uint32_t color ) return S_OK; } -Tr2UpscalingAL::Result Tr2RenderContextAL::EnableUpscaling( Tr2UpscalingAL::Technique tech, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) +Tr2UpscalingAL::Result Tr2RenderContextAL::EnableUpscaling( Tr2UpscalingAL::Technique tech, + Tr2UpscalingAL::Setting setting, + bool frameGeneration, + uint32_t adapter ) { - if( m_upscalingTechnique ) - { - delete m_upscalingTechnique; - m_upscalingTechnique = nullptr; - } - - if( tech == Tr2UpscalingAL::Technique::NONE ) + if( m_upscalingTechnique ) + { + delete m_upscalingTechnique; + m_upscalingTechnique = nullptr; + } + + if( tech == Tr2UpscalingAL::Technique::NONE ) { return Tr2UpscalingAL::Result::OK; } // find the technique - auto supportedTechnique = std::find( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES.begin(), TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES.end(), tech ); + auto supportedTechnique = std::find( TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES.begin(), + TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES.end(), + tech ); if( supportedTechnique == TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES.end() ) { return Tr2UpscalingAL::Result::TECHNIQUE_NOT_SUPPORTED; @@ -1404,7 +1436,7 @@ MTLClearColor MakeClearColor( uint32_t color ) { return Tr2UpscalingAL::Result::TECHNIQUE_NOT_SUPPORTED; } - + return Tr2UpscalingAL::Result::OK; } @@ -1418,7 +1450,8 @@ MTLClearColor MakeClearColor( uint32_t color ) return m_upscalingTechnique->GetContext( upscalingContextID ); } -Tr2UpscalingContextAL* Tr2RenderContextAL::CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, uint32_t existingContext ) +Tr2UpscalingContextAL* Tr2RenderContextAL::CreateUpscalingContext( Tr2UpscalingAL::UpscalingContextParams params, + uint32_t existingContext ) { if( m_upscalingTechnique == nullptr ) { @@ -1438,7 +1471,8 @@ MTLClearColor MakeClearColor( uint32_t color ) return m_upscalingTechnique->DeleteContext( contextID ); } -std::vector> Tr2RenderContextAL::GetSupportedUpscalingTechniques( uint32_t adapter ) +std::vector> + Tr2RenderContextAL::GetSupportedUpscalingTechniques( uint32_t adapter ) { Tr2UpscalingAL::Technique activeTechnique = Tr2UpscalingAL::Technique::NONE; if( m_upscalingTechnique ) @@ -1448,11 +1482,11 @@ MTLClearColor MakeClearColor( uint32_t color ) m_upscalingTechnique->GetState( activeTechnique, setting, framegeneration ); } - std::vector> supportedTechniques; - for( auto& technique : TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ) - { - if( technique == activeTechnique && m_upscalingTechnique) - { + std::vector> supportedTechniques; + for( auto& technique : TrinityALImpl::AVAILABLE_UPSCALING_TECHNIQUES ) + { + if( technique == activeTechnique && m_upscalingTechnique ) + { uint32_t allSettings = 0; for( auto& setting : m_upscalingTechnique->GetAvailableSettings() ) @@ -1460,30 +1494,32 @@ MTLClearColor MakeClearColor( uint32_t color ) allSettings |= setting; } - supportedTechniques.push_back( { technique, allSettings, m_upscalingTechnique->SupportsFrameGeneration() } ); + supportedTechniques.push_back( + { technique, allSettings, m_upscalingTechnique->SupportsFrameGeneration() } ); continue; } - auto tech = TrinityALImpl::CreateUpscalingTechnique( *this, technique, Tr2UpscalingAL::Setting::NATIVE, false, adapter ); - if( tech ) - { - uint32_t allSettings = 0; + auto tech = TrinityALImpl::CreateUpscalingTechnique( + *this, technique, Tr2UpscalingAL::Setting::NATIVE, false, adapter ); + if( tech ) + { + uint32_t allSettings = 0; + + for( auto& setting : tech->GetAvailableSettings() ) + { + allSettings |= setting; + } - for( auto& setting : tech->GetAvailableSettings() ) - { - allSettings |= setting; - } + supportedTechniques.push_back( { technique, allSettings, tech->SupportsFrameGeneration() } ); + tech = nullptr; + } - supportedTechniques.push_back( { technique, allSettings, tech->SupportsFrameGeneration() } ); - tech = nullptr; - } - if( tech ) { tech = nullptr; } - } - return supportedTechniques; + } + return supportedTechniques; } Tr2UpscalingAL::UpscalingInfo Tr2RenderContextAL::GetUpscalingInfo( uint32_t upscalingContextID ) const @@ -1505,17 +1541,20 @@ MTLClearColor MakeClearColor( uint32_t color ) return info; } -void Tr2RenderContextAL::GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, Tr2UpscalingAL::Setting& setting, bool& framegeneration, bool& temporal ) const +void Tr2RenderContextAL::GetUpscalingSetup( Tr2UpscalingAL::Technique& technique, + Tr2UpscalingAL::Setting& setting, + bool& framegeneration, + bool& temporal ) const { - if( m_upscalingTechnique ) - { - m_upscalingTechnique->GetState( technique, setting, framegeneration ); + if( m_upscalingTechnique ) + { + m_upscalingTechnique->GetState( technique, setting, framegeneration ); temporal = m_upscalingTechnique->IsTemporal(); - return; - } - technique = Tr2UpscalingAL::Technique::NONE; - setting = Tr2UpscalingAL::Setting::NATIVE; - framegeneration = false; + return; + } + technique = Tr2UpscalingAL::Technique::NONE; + setting = Tr2UpscalingAL::Setting::NATIVE; + framegeneration = false; temporal = false; } @@ -1528,113 +1567,120 @@ MTLClearColor MakeClearColor( uint32_t color ) return m_upscalingTechnique->MarkFrameEvent( frameEvent ); } -ALResult Tr2RenderContextAL::UseResources( Tr2UseResourceDestination dest, Tr2GpuUsage::Type usage, const Tr2BindlessResourcesAL& resources ) +ALResult Tr2RenderContextAL::UseResources( Tr2UseResourceDestination dest, + Tr2GpuUsage::Type usage, + const Tr2BindlessResourcesAL& resources ) { - if( resources.m_textures.empty() && resources.m_buffers.empty() ) - { - return S_OK; - } - if( @available( macOS 13.0, * ) ) - { - - std::vector<__unsafe_unretained id> mtlResources; - mtlResources.reserve( resources.m_textures.size() * 2 + resources.m_buffers.size() ); - - auto CopyMtlResources = [&mtlResources, &resources]( uint64_t encoderIndex ) { - for( auto& tex : resources.m_textures ) - { - if( tex->IsValid() && tex->m_usedInEncoder != encoderIndex ) - { - tex->m_usedInEncoder = encoderIndex; - __unsafe_unretained auto t0 = tex->m_mtlTexture; - if( t0 ) - { - mtlResources.push_back( t0 ); - } - __unsafe_unretained auto t1 = tex->m_mtlTextureSRGBView; - if( t1 && t1 != t0 ) - { - mtlResources.push_back( t1 ); - } - } - } - for( auto& buffer : resources.m_buffers ) - { - if( buffer->IsValid() && buffer->m_usedInEncoder != encoderIndex ) - { - buffer->m_usedInEncoder = encoderIndex; - __unsafe_unretained auto t0 = buffer->m_mtlBuffer; - if( t0 ) - { - mtlResources.push_back( t0 ); - } - } - } - }; - if( dest == Tr2UseResourceDestination::RENDER ) - { - auto encoder = m_workQueue->GetRenderEncoder(); - CopyMtlResources( m_workQueue->GetCurrentEncoderIndex() ); - [encoder useResources:mtlResources.data() - count:NSUInteger( mtlResources.size()) - usage:usage == Tr2GpuUsage::UNORDERED_ACCESS ? MTLResourceUsageRead | MTLResourceUsageWrite : MTLResourceUsageRead]; - } - else - { - auto encoder = m_workQueue->GetComputeEncoder(); - CopyMtlResources( m_workQueue->GetCurrentEncoderIndex() ); - [encoder useResources:mtlResources.data() - count:NSUInteger( mtlResources.size()) - usage:usage == Tr2GpuUsage::UNORDERED_ACCESS ? MTLResourceUsageRead | MTLResourceUsageWrite : MTLResourceUsageRead]; - } - m_workQueue->ReleaseEncoder( false ); - } + if( resources.m_textures.empty() && resources.m_buffers.empty() ) + { + return S_OK; + } + if( @available( macOS 13.0, * ) ) + { + + std::vector<__unsafe_unretained id> mtlResources; + mtlResources.reserve( resources.m_textures.size() * 2 + resources.m_buffers.size() ); + + auto CopyMtlResources = [&mtlResources, &resources]( uint64_t encoderIndex ) { + for( auto& tex : resources.m_textures ) + { + if( tex->IsValid() && tex->m_usedInEncoder != encoderIndex ) + { + tex->m_usedInEncoder = encoderIndex; + __unsafe_unretained auto t0 = tex->m_mtlTexture; + if( t0 ) + { + mtlResources.push_back( t0 ); + } + __unsafe_unretained auto t1 = tex->m_mtlTextureSRGBView; + if( t1 && t1 != t0 ) + { + mtlResources.push_back( t1 ); + } + } + } + for( auto& buffer : resources.m_buffers ) + { + if( buffer->IsValid() && buffer->m_usedInEncoder != encoderIndex ) + { + buffer->m_usedInEncoder = encoderIndex; + __unsafe_unretained auto t0 = buffer->m_mtlBuffer; + if( t0 ) + { + mtlResources.push_back( t0 ); + } + } + } + }; + if( dest == Tr2UseResourceDestination::RENDER ) + { + auto encoder = m_workQueue->GetRenderEncoder(); + CopyMtlResources( m_workQueue->GetCurrentEncoderIndex() ); + [encoder + useResources:mtlResources.data() + count:NSUInteger( mtlResources.size() ) + usage:usage == Tr2GpuUsage::UNORDERED_ACCESS ? MTLResourceUsageRead | MTLResourceUsageWrite : + MTLResourceUsageRead]; + } + else + { + auto encoder = m_workQueue->GetComputeEncoder(); + CopyMtlResources( m_workQueue->GetCurrentEncoderIndex() ); + [encoder + useResources:mtlResources.data() + count:NSUInteger( mtlResources.size() ) + usage:usage == Tr2GpuUsage::UNORDERED_ACCESS ? MTLResourceUsageRead | MTLResourceUsageWrite : + MTLResourceUsageRead]; + } + m_workQueue->ReleaseEncoder( false ); + } return S_OK; } -ALResult Tr2RenderContextAL::UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ) +ALResult Tr2RenderContextAL::UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ) { - if( @available( macOS 11.0, * ) ) - { - id accelerationStructure = tlas.TrinityALImpl_GetObject()->GetInstanceAccelerationStructure(); - - auto computeEncoder = m_workQueue->GetComputeEncoder(); - - [computeEncoder useResource:accelerationStructure usage:MTLResourceUsageRead]; - - m_workQueue->ReleaseEncoder( false ); - - return S_OK; - } - return E_FAIL; + if( @available( macOS 11.0, * ) ) + { + id accelerationStructure = + tlas.TrinityALImpl_GetObject()->GetInstanceAccelerationStructure(); + + auto computeEncoder = m_workQueue->GetComputeEncoder(); + + [computeEncoder useResource:accelerationStructure usage:MTLResourceUsageRead]; + + m_workQueue->ReleaseEncoder( false ); + + return S_OK; + } + return E_FAIL; } ALResult Tr2RenderContextAL::UseConstantBuffer( id constantBuffer ) { - if( @available( macOS 11.0, * ) ) - { - auto computeEncoder = m_workQueue->GetComputeEncoder(); - - [computeEncoder useResource:constantBuffer usage:MTLResourceUsageRead]; - - m_workQueue->ReleaseEncoder( false ); - - return S_OK; - } - return E_FAIL; + if( @available( macOS 11.0, * ) ) + { + auto computeEncoder = m_workQueue->GetComputeEncoder(); + + [computeEncoder useResource:constantBuffer usage:MTLResourceUsageRead]; + + m_workQueue->ReleaseEncoder( false ); + + return S_OK; + } + return E_FAIL; } bool Tr2RenderContextAL::SupportsBindlessTextures() const { - if( @available( macOS 13.0, * ) ) - { - if( !m_metalContext || !m_metalContext->GetDevice() ) - { - return false; - } - return m_metalContext->GetDevice().argumentBuffersSupport == MTLArgumentBuffersTier2; - } - return false; + if( @available( macOS 13.0, * ) ) + { + if( !m_metalContext || !m_metalContext->GetDevice() ) + { + return false; + } + return m_metalContext->GetDevice().argumentBuffersSupport == MTLArgumentBuffersTier2; + } + return false; } uint64_t Tr2RenderContextAL::GetRecordingFrameNumber() const @@ -1649,7 +1695,7 @@ MTLClearColor MakeClearColor( uint32_t color ) void Tr2RenderContextAL::ReleaseLater( id obj ) { - m_metalContext->ReleaseLater( obj ); + m_metalContext->ReleaseLater( obj ); } void Tr2BindlessResourcesAL::Add( const Tr2TextureAL& texture ) diff --git a/trinityal/metal/Tr2ResourceSetALMetal.h b/trinityal/metal/Tr2ResourceSetALMetal.h index 32a95a1cd..95c64d45d 100644 --- a/trinityal/metal/Tr2ResourceSetALMetal.h +++ b/trinityal/metal/Tr2ResourceSetALMetal.h @@ -13,37 +13,44 @@ namespace TrinityALImpl { - class Tr2ResourceSetAL : public Tr2DeviceResourceAL - { - public: - Tr2ResourceSetAL(); - ~Tr2ResourceSetAL(); - - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - id m_buffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - id m_textures[Tr2RenderContextEnum::SHADER_TYPE_COUNT][Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - id m_samplers[Tr2RenderContextEnum::SHADER_TYPE_COUNT][Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; - - uint32_t m_buffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - uint32_t m_heapViewMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - NSRange m_texturesRange[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - NSRange m_samplersRange[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - std::string m_name; - - bool m_isValid; - - friend class ::Tr2RenderContextAL; - friend class ::Tr2RtPipelineStateAL; - }; +class Tr2ResourceSetAL : public Tr2DeviceResourceAL +{ +public: + Tr2ResourceSetAL(); + ~Tr2ResourceSetAL(); + + ALResult Create( const Tr2ResourceSetDescriptionAL& description, + const ::Tr2ShaderProgramAL& program, + Tr2PrimaryRenderContextAL& renderContext ); + ALResult Create( const Tr2ResourceSetDescriptionAL& description, + const ::Tr2RtPipelineStateAL& pipeline, + Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + id m_buffers[Tr2RenderContextEnum::SHADER_TYPE_COUNT] + [Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + id m_textures[Tr2RenderContextEnum::SHADER_TYPE_COUNT] + [Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + id m_samplers[Tr2RenderContextEnum::SHADER_TYPE_COUNT] + [Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE]; + + uint32_t m_buffersMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + uint32_t m_heapViewMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + NSRange m_texturesRange[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + NSRange m_samplersRange[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + std::string m_name; + + bool m_isValid; + + friend class ::Tr2RenderContextAL; + friend class ::Tr2RtPipelineStateAL; +}; } #endif diff --git a/trinityal/metal/Tr2ResourceSetALMetal.mm b/trinityal/metal/Tr2ResourceSetALMetal.mm index a0593afda..cf09886cf 100644 --- a/trinityal/metal/Tr2ResourceSetALMetal.mm +++ b/trinityal/metal/Tr2ResourceSetALMetal.mm @@ -13,221 +13,218 @@ #include "Tr2RtPipelineStateALMetal.h" #include "ALLog.h" -static_assert( - sizeof( TrinityALImpl::ShaderResourceMask::constantBufferMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, - "Please use a type with more bits for ShaderResourceMask::constantBufferMask." ); -static_assert( - sizeof( TrinityALImpl::ShaderResourceMask::bufferMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, - "Please use a type with more bits for ShaderResourceMask::bufferMask." ); -static_assert( - sizeof( TrinityALImpl::ShaderResourceMask::textureMask ) * 8 >= METAL_MAX_BOUND_TEXTURES, - "Please use a type with more bits for ShaderResourceMask::textureMask." ); -static_assert( - sizeof( TrinityALImpl::ShaderResourceMask::samplerMask ) * 8 >= METAL_MAX_BOUND_SAMPLERS, - "Please use a type with more bits for ShaderResourceMask::samplerMask." ); +static_assert( sizeof( TrinityALImpl::ShaderResourceMask::constantBufferMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Please use a type with more bits for ShaderResourceMask::constantBufferMask." ); +static_assert( sizeof( TrinityALImpl::ShaderResourceMask::bufferMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Please use a type with more bits for ShaderResourceMask::bufferMask." ); +static_assert( sizeof( TrinityALImpl::ShaderResourceMask::textureMask ) * 8 >= METAL_MAX_BOUND_TEXTURES, + "Please use a type with more bits for ShaderResourceMask::textureMask." ); +static_assert( sizeof( TrinityALImpl::ShaderResourceMask::samplerMask ) * 8 >= METAL_MAX_BOUND_SAMPLERS, + "Please use a type with more bits for ShaderResourceMask::samplerMask." ); namespace TrinityALImpl { - Tr2ResourceSetAL::Tr2ResourceSetAL() - :m_isValid( false ) - { - static_assert( - sizeof( m_buffersMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, - "Please use a type with more bits for m_buffersMask." ); +Tr2ResourceSetAL::Tr2ResourceSetAL() : m_isValid( false ) +{ + static_assert( sizeof( m_buffersMask ) * 8 >= METAL_MAX_BOUND_BUFFERS, + "Please use a type with more bits for m_buffersMask." ); + + Destroy(); +} + +Tr2ResourceSetAL::~Tr2ResourceSetAL() +{ + Destroy(); +} + +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, + const ::Tr2RtPipelineStateAL& pipeline, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - Destroy(); + if( !renderContext.IsValid() || !pipeline.IsValid() ) + { + return E_INVALIDARG; } - Tr2ResourceSetAL::~Tr2ResourceSetAL() + const ::Tr2ShaderProgramAL program = pipeline.m_pipeline->GetShaderProgram( 0 ); + + return Create( description, program, renderContext ); +} + +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, + const ::Tr2ShaderProgramAL& program, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() || !program.IsValid() ) { - Destroy(); + return E_INVALIDARG; } - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2RtPipelineStateAL &pipeline, Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); - - if( !renderContext.IsValid() || !pipeline.IsValid() ) - { - return E_INVALIDARG; - } - - const ::Tr2ShaderProgramAL program = pipeline.m_pipeline->GetShaderProgram( 0 ); - - return Create(description, program, renderContext); - - } - - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ) + using namespace Tr2RenderContextEnum; + const ShaderType stages[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; + for( auto stage : stages ) { - Destroy(); + uint32_t buffersMask = 0; + uint32_t heapViewMask = 0; + NSUInteger texturesMin = NSUIntegerMax; + NSUInteger texturesMax = 0; - if( !renderContext.IsValid() || !program.IsValid() ) - { - return E_INVALIDARG; - } + // Init required resource mask to that required by the shader. + // uint32_t bufferMask = program.m_program->m_resourceMask[stage].bufferMask; + uint32_t textureMask = program.m_program->m_resourceMask[stage].textureMask; + uint32_t samplerMask = program.m_program->m_resourceMask[stage].samplerMask; - using namespace Tr2RenderContextEnum; - const ShaderType stages[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; - for( auto stage : stages ) + for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) { - uint32_t buffersMask = 0; - uint32_t heapViewMask = 0; - NSUInteger texturesMin = NSUIntegerMax; - NSUInteger texturesMax = 0; - - // Init required resource mask to that required by the shader. - // uint32_t bufferMask = program.m_program->m_resourceMask[stage].bufferMask; - uint32_t textureMask = program.m_program->m_resourceMask[stage].textureMask; - uint32_t samplerMask = program.m_program->m_resourceMask[stage].samplerMask; + if( description.m_registerMap.srvs[stage][i] >= description.m_registerMap.srvCount ) + { + continue; + } + const Tr2ResourceSetDescriptionAL::Resource& resource = + description.m_srv[description.m_registerMap.srvs[stage][i]]; - for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + switch( resource.type ) { - if( description.m_registerMap.srvs[stage][i] >= description.m_registerMap.srvCount ) + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + if( resource.buffer.IsValid() ) { - continue; + CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); + + const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; + m_buffers[stage][bufferIndex] = resource.buffer.m_buffer->GetMetalBuffer(); + buffersMask |= ( 1 << bufferIndex ); + + // Remove this resource from mask. + // bufferMask &= ~(1 << bufferIndex); } - const Tr2ResourceSetDescriptionAL::Resource& resource = description.m_srv[description.m_registerMap.srvs[stage][i]]; + break; + case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: { + CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); - switch( resource.type ) + const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; + heapViewMask |= ( 1 << bufferIndex ); + } + break; + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + if( resource.texture.IsValid() ) { - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - if( resource.buffer.IsValid() ) - { - CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); + CCP_ASSERT( i < METAL_SRV_TEXTURE_COUNT ); - const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; - m_buffers[stage][bufferIndex] = resource.buffer.m_buffer->GetMetalBuffer(); - buffersMask |= (1 << bufferIndex); + const NSUInteger texIndex = METAL_SRV_TEXTURE_OFFSET + i; - // Remove this resource from mask. - // bufferMask &= ~(1 << bufferIndex); + if( resource.colorSpace == COLOR_SPACE_SRGB ) + { + m_textures[stage][texIndex] = resource.texture.m_texture->GetSRGBViewMetalTexture(); } - break; - case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: - { - CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); - - const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; - heapViewMask |= (1 << bufferIndex); - - } - break; - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - if( resource.texture.IsValid() ) + else { - CCP_ASSERT( i < METAL_SRV_TEXTURE_COUNT ); - - const NSUInteger texIndex = METAL_SRV_TEXTURE_OFFSET + i; - - if( resource.colorSpace == COLOR_SPACE_SRGB ) - { - m_textures[stage][texIndex] = resource.texture.m_texture->GetSRGBViewMetalTexture(); - } - else - { - m_textures[stage][texIndex] = resource.texture.m_texture->GetMetalTexture(); - } - - texturesMin = std::min( texturesMin, texIndex ); - texturesMax = std::max( texturesMax, texIndex ); - // Remove this resource from mask. - textureMask &= ~(1 << texIndex); + m_textures[stage][texIndex] = resource.texture.m_texture->GetMetalTexture(); } - break; - case Tr2ResourceSetDescriptionAL::Resource::NONE: - continue; - default: - CCP_AL_LOGWARN( "Unknown SRV resource type in resource set for register %d, stage %d", i, stage ); - return E_INVALIDARG; + + texturesMin = std::min( texturesMin, texIndex ); + texturesMax = std::max( texturesMax, texIndex ); + // Remove this resource from mask. + textureMask &= ~( 1 << texIndex ); } + break; + case Tr2ResourceSetDescriptionAL::Resource::NONE: + continue; + default: + CCP_AL_LOGWARN( "Unknown SRV resource type in resource set for register %d, stage %d", i, stage ); + return E_INVALIDARG; + } + } + + for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + { + if( description.m_registerMap.uavs[stage][i] >= description.m_registerMap.uavCount ) + { + continue; } + const Tr2ResourceSetDescriptionAL::Resource& resource = + description.m_uav[description.m_registerMap.uavs[stage][i]]; - for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + switch( resource.type ) { - if( description.m_registerMap.uavs[stage][i] >= description.m_registerMap.uavCount ) + case Tr2ResourceSetDescriptionAL::Resource::BUFFER: + if( resource.buffer.IsValid() ) { - continue; + CCP_ASSERT( i < METAL_UAV_BUFFER_COUNT ); + + const NSUInteger bufferIndex = METAL_UAV_BUFFER_OFFSET + i; + m_buffers[stage][bufferIndex] = resource.buffer.m_buffer->GetMetalBuffer(); + buffersMask |= ( 1 << bufferIndex ); + + // Remove this resource from mask. + // bufferMask &= ~(1 << bufferIndex); } - const Tr2ResourceSetDescriptionAL::Resource& resource = description.m_uav[description.m_registerMap.uavs[stage][i]]; + break; + case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: { + CCP_ASSERT( i < METAL_UAV_BUFFER_COUNT ); - switch (resource.type) + const NSUInteger bufferIndex = METAL_UAV_BUFFER_OFFSET + i; + heapViewMask |= ( 1 << bufferIndex ); + } + break; + case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: + if( resource.texture.IsValid() ) { - case Tr2ResourceSetDescriptionAL::Resource::BUFFER: - if( resource.buffer.IsValid() ) - { - CCP_ASSERT( i < METAL_UAV_BUFFER_COUNT ); + CCP_ASSERT( i < METAL_UAV_TEXTURE_COUNT ); - const NSUInteger bufferIndex = METAL_UAV_BUFFER_OFFSET + i; - m_buffers[stage][bufferIndex] = resource.buffer.m_buffer->GetMetalBuffer(); - buffersMask |= (1 << bufferIndex); - - // Remove this resource from mask. - // bufferMask &= ~(1 << bufferIndex); - } - break; - case Tr2ResourceSetDescriptionAL::Resource::HEAP_VIEW: - { - CCP_ASSERT( i < METAL_UAV_BUFFER_COUNT ); - - const NSUInteger bufferIndex = METAL_UAV_BUFFER_OFFSET + i; - heapViewMask |= (1 << bufferIndex); - } - break; - case Tr2ResourceSetDescriptionAL::Resource::TEXTURE: - if( resource.texture.IsValid() ) - { - CCP_ASSERT( i < METAL_UAV_TEXTURE_COUNT ); - - const NSUInteger texIndex = METAL_UAV_TEXTURE_OFFSET + i; - m_textures[stage][texIndex] = resource.texture.m_texture->GetUAVMetalTexture( resource.mip ); - texturesMin = std::min( texturesMin, texIndex ); - texturesMax = std::max( texturesMax, texIndex ); - // Remove this resource from mask. - textureMask &= ~(1 << texIndex); - } - break; - case Tr2ResourceSetDescriptionAL::Resource::NONE: - continue; - default: - CCP_AL_LOGWARN( "Unknown UAV resource type in resource set for register %d, stage %d", i, stage ); - return E_INVALIDARG; + const NSUInteger texIndex = METAL_UAV_TEXTURE_OFFSET + i; + m_textures[stage][texIndex] = resource.texture.m_texture->GetUAVMetalTexture( resource.mip ); + texturesMin = std::min( texturesMin, texIndex ); + texturesMax = std::max( texturesMax, texIndex ); + // Remove this resource from mask. + textureMask &= ~( 1 << texIndex ); } + break; + case Tr2ResourceSetDescriptionAL::Resource::NONE: + continue; + default: + CCP_AL_LOGWARN( "Unknown UAV resource type in resource set for register %d, stage %d", i, stage ); + return E_INVALIDARG; } + } - NSUInteger samplersMin = NSUIntegerMax; - NSUInteger samplersMax = 0; + NSUInteger samplersMin = NSUIntegerMax; + NSUInteger samplersMax = 0; - for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + { + if( description.m_registerMap.samplers[stage][i] >= description.m_registerMap.samplerCount ) { - if( description.m_registerMap.samplers[stage][i] >= description.m_registerMap.samplerCount ) - { - continue; - } - const Tr2ResourceSetDescriptionAL::Sampler& sampler = description.m_samplers[description.m_registerMap.samplers[stage][i]]; + continue; + } + const Tr2ResourceSetDescriptionAL::Sampler& sampler = + description.m_samplers[description.m_registerMap.samplers[stage][i]]; - if( sampler.type == Tr2ResourceSetDescriptionAL::Sampler::SAMPLER ) - { - m_samplers[stage][i] = sampler.sampler.m_sampler->GetMetalSamplerState(); - samplersMin = std::min( samplersMin, i ); - samplersMax = std::max( samplersMax, i ); - // Remove this resource from mask. - samplerMask &= ~(1 << i); - } - else if( sampler.type == Tr2ResourceSetDescriptionAL::Sampler::HEAP_VIEW ) - { - CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); - const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; - heapViewMask |= (1 << bufferIndex); - } + if( sampler.type == Tr2ResourceSetDescriptionAL::Sampler::SAMPLER ) + { + m_samplers[stage][i] = sampler.sampler.m_sampler->GetMetalSamplerState(); + samplersMin = std::min( samplersMin, i ); + samplersMax = std::max( samplersMax, i ); + // Remove this resource from mask. + samplerMask &= ~( 1 << i ); } + else if( sampler.type == Tr2ResourceSetDescriptionAL::Sampler::HEAP_VIEW ) + { + CCP_ASSERT( i < METAL_SRV_BUFFER_COUNT ); + const NSUInteger bufferIndex = METAL_SRV_BUFFER_OFFSET + i; + heapViewMask |= ( 1 << bufferIndex ); + } + } - // Replace any missing resources with dummy ones. + // Replace any missing resources with dummy ones. - MetalContext* metalContext = renderContext.GetMetalContext(); - unsigned int index = 0; - // Buffers not supported yet. + MetalContext* metalContext = renderContext.GetMetalContext(); + unsigned int index = 0; + // Buffers not supported yet. #if 0 while( bufferMask ) { @@ -240,85 +237,90 @@ } #endif - index = 0; - while( textureMask ) + index = 0; + while( textureMask ) + { + if( textureMask & 0x1 ) { - if( textureMask & 0x1 ) - { - m_textures[stage][index] = metalContext->GetDummyTexture( MTLTextureType( program.m_program->m_resourceMask[stage].textureTypes[index] ) ); - texturesMin = std::min( texturesMin, index ); - texturesMax = std::max( texturesMax, index ); - } - textureMask >>= 1; - ++index; + m_textures[stage][index] = metalContext->GetDummyTexture( + MTLTextureType( program.m_program->m_resourceMask[stage].textureTypes[index] ) ); + texturesMin = std::min( texturesMin, index ); + texturesMax = std::max( texturesMax, index ); } + textureMask >>= 1; + ++index; + } - index = 0; - while( samplerMask ) + index = 0; + while( samplerMask ) + { + if( samplerMask & 0x1 ) { - if( samplerMask & 0x1 ) - { - m_samplers[stage][index] = metalContext->GetDummySampler(); - samplersMin = std::min( samplersMin, index ); - samplersMax = std::max( samplersMax, index ); - } - samplerMask >>= 1; - ++index; + m_samplers[stage][index] = metalContext->GetDummySampler(); + samplersMin = std::min( samplersMin, index ); + samplersMax = std::max( samplersMax, index ); } - - m_buffersMask[stage] = buffersMask; - m_heapViewMask[stage] = heapViewMask; - m_texturesRange[stage] = ( texturesMin != NSUIntegerMax ) ? NSMakeRange( texturesMin, texturesMax - texturesMin + 1 ) : NSMakeRange( 0, 0 ); - m_samplersRange[stage] = ( samplersMin != NSUIntegerMax ) ? NSMakeRange( samplersMin, samplersMax - samplersMin + 1 ) : NSMakeRange( 0, 0 ); + samplerMask >>= 1; + ++index; } - m_isValid = true; - return S_OK; + m_buffersMask[stage] = buffersMask; + m_heapViewMask[stage] = heapViewMask; + m_texturesRange[stage] = ( texturesMin != NSUIntegerMax ) ? + NSMakeRange( texturesMin, texturesMax - texturesMin + 1 ) : + NSMakeRange( 0, 0 ); + m_samplersRange[stage] = ( samplersMin != NSUIntegerMax ) ? + NSMakeRange( samplersMin, samplersMax - samplersMin + 1 ) : + NSMakeRange( 0, 0 ); } - bool Tr2ResourceSetAL::IsValid() const - { - return m_isValid; - } + m_isValid = true; + return S_OK; +} - void Tr2ResourceSetAL::Destroy() - { - m_isValid = false; +bool Tr2ResourceSetAL::IsValid() const +{ + return m_isValid; +} - using namespace Tr2RenderContextEnum; - const ShaderType stages[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; - for( auto stage : stages ) - { - for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) - { - m_buffers[stage][i] = nil; - m_textures[stage][i] = nil; - m_samplers[stage][i] = nil; - } +void Tr2ResourceSetAL::Destroy() +{ + m_isValid = false; - m_buffersMask[stage] = 0; - m_heapViewMask[stage] = 0; - m_texturesRange[stage] = NSMakeRange( 0, 0 ); - m_samplersRange[stage] = NSMakeRange( 0, 0 ); + using namespace Tr2RenderContextEnum; + const ShaderType stages[] = { VERTEX_SHADER, PIXEL_SHADER, COMPUTE_SHADER }; + for( auto stage : stages ) + { + for( int i = 0; i < Tr2ResourceSetDescriptionAL::MAX_RESOURCES_IN_STAGE; ++i ) + { + m_buffers[stage][i] = nil; + m_textures[stage][i] = nil; + m_samplers[stage][i] = nil; } - } - Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; + m_buffersMask[stage] = 0; + m_heapViewMask[stage] = 0; + m_texturesRange[stage] = NSMakeRange( 0, 0 ); + m_samplersRange[stage] = NSMakeRange( 0, 0 ); } +} - void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ResourceSetAL"; - description["name"] = m_name; - } +Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - ALResult Tr2ResourceSetAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ResourceSetAL"; + description["name"] = m_name; +} + +ALResult Tr2ResourceSetAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.h b/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.h index d6fd7b4ed..9f04fb543 100644 --- a/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.h +++ b/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.h @@ -8,7 +8,7 @@ // -// NOTE: on DXR we have these things called BottomLevelAccelerationStructure (BLAS) and TopLevelAccelerationStructure (TLAS). +// NOTE: on DXR we have these things called BottomLevelAccelerationStructure (BLAS) and TopLevelAccelerationStructure (TLAS). // In Metal similar objects are referenced as primitive acceleration structure (BLAS) and instance acceleration structure (TLAS) #pragma once @@ -21,38 +21,38 @@ namespace TrinityALImpl { class Tr2RtBottomLevelAccelerationStructureAL : public Tr2DeviceResourceAL - { - public: - Tr2RtBottomLevelAccelerationStructureAL(); - ~Tr2RtBottomLevelAccelerationStructureAL(); - - ALResult Create( const Tr2RtGeometryAL& geometry, - const Tr2RtGeometryAL& capacity, - Tr2RtBlasGeometryFlags::Type geometryFlags, - Tr2RtBuildFlags::Type buildFlags, - Tr2PrimaryRenderContextAL& renderContext ); - ALResult Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ); - ALResult CompactBlas( Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - - void Destroy(); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - Tr2ALMemoryType GetMemoryClass() const; - - API_AVAILABLE(macos(11.0)) - id m_primitiveAccelerationStructure; - - private: - API_AVAILABLE(macos(11.0)) - MTLAccelerationStructureTriangleGeometryDescriptor* m_geomDesc; - - API_AVAILABLE(macos(11.0)) - MTLPrimitiveAccelerationStructureDescriptor* m_accelerationStructureDesc; - - NSUInteger m_scratchBufferSize; - - id m_scratchBuffer; - }; +{ +public: + Tr2RtBottomLevelAccelerationStructureAL(); + ~Tr2RtBottomLevelAccelerationStructureAL(); + + ALResult Create( const Tr2RtGeometryAL& geometry, + const Tr2RtGeometryAL& capacity, + Tr2RtBlasGeometryFlags::Type geometryFlags, + Tr2RtBuildFlags::Type buildFlags, + Tr2PrimaryRenderContextAL& renderContext ); + ALResult Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ); + ALResult CompactBlas( Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + + void Destroy(); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + Tr2ALMemoryType GetMemoryClass() const; + + API_AVAILABLE( macos( 11.0 ) ) + id m_primitiveAccelerationStructure; + +private: + API_AVAILABLE( macos( 11.0 ) ) + MTLAccelerationStructureTriangleGeometryDescriptor* m_geomDesc; + + API_AVAILABLE( macos( 11.0 ) ) + MTLPrimitiveAccelerationStructureDescriptor* m_accelerationStructureDesc; + + NSUInteger m_scratchBufferSize; + + id m_scratchBuffer; +}; } #endif diff --git a/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.mm b/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.mm index 27210867a..8125795de 100644 --- a/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.mm +++ b/trinityal/metal/Tr2RtBottomLevelAccelerationStructureALMetal.mm @@ -19,225 +19,238 @@ { MTLAttributeFormat ConvertVertexFormat( Tr2RenderContextEnum::PixelFormat format ) { - switch (format) - { - case Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT: - return MTLAttributeFormatFloat3; - case Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT: - return MTLAttributeFormatHalf3; - - default: - return MTLAttributeFormatInvalid; - } + switch( format ) + { + case Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT: + return MTLAttributeFormatFloat3; + case Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT: + return MTLAttributeFormatHalf3; + + default: + return MTLAttributeFormatInvalid; + } } // NOTE: this has no compaction -API_AVAILABLE(macos(11.0)) -std::pair, NSUInteger> BuildAccelerationStructure(MTLAccelerationStructureDescriptor* descriptor, TrinityALImpl::MetalContext* metalContext ) +API_AVAILABLE( macos( 11.0 ) ) +std::pair, NSUInteger> + BuildAccelerationStructure( MTLAccelerationStructureDescriptor* descriptor, + TrinityALImpl::MetalContext* metalContext ) +{ + id device = metalContext->GetDevice(); + + // Query for the sizes needed to store and build the acceleration structure. + MTLAccelerationStructureSizes accelSizes = [device accelerationStructureSizesWithDescriptor:descriptor]; + + // Allocate an acceleration structure large enough for this descriptor. This method + // doesn't actually build the acceleration structure, but rather allocates memory. + id accelerationStructure = + [device newAccelerationStructureWithSize:accelSizes.accelerationStructureSize]; + + // Allocate scratch space Metal uses to build the acceleration structure. + id scratchBuffer = [device newBufferWithLength:accelSizes.buildScratchBufferSize + options:MTLResourceStorageModePrivate]; + + auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); + [commandEncoder buildAccelerationStructure:accelerationStructure + descriptor:descriptor + scratchBuffer:scratchBuffer + scratchBufferOffset:0]; + metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); + + return { accelerationStructure, accelSizes.refitScratchBufferSize }; +} + +} + +namespace TrinityALImpl +{ + +Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() : m_scratchBufferSize( 0 ) { - id device = metalContext->GetDevice(); - - // Query for the sizes needed to store and build the acceleration structure. - MTLAccelerationStructureSizes accelSizes = [device accelerationStructureSizesWithDescriptor:descriptor]; - - // Allocate an acceleration structure large enough for this descriptor. This method - // doesn't actually build the acceleration structure, but rather allocates memory. - id accelerationStructure = [device newAccelerationStructureWithSize:accelSizes.accelerationStructureSize]; - - // Allocate scratch space Metal uses to build the acceleration structure. - id scratchBuffer = [device newBufferWithLength:accelSizes.buildScratchBufferSize options:MTLResourceStorageModePrivate]; - - auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); - [commandEncoder buildAccelerationStructure:accelerationStructure - descriptor:descriptor - scratchBuffer:scratchBuffer - scratchBufferOffset:0]; - metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); - - return { accelerationStructure, accelSizes.refitScratchBufferSize }; } +Tr2RtBottomLevelAccelerationStructureAL::~Tr2RtBottomLevelAccelerationStructureAL() +{ +} + +// Function to build a singular BLAS, list of BLAS to be kept elsewhere +ALResult Tr2RtBottomLevelAccelerationStructureAL::Create( const Tr2RtGeometryAL& geometry, + const Tr2RtGeometryAL&, + Tr2RtBlasGeometryFlags::Type geometryFlags, + Tr2RtBuildFlags::Type buildFlags, + Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) + { + return E_INVALIDCALL; + } + if( !geometry.positions.IsValid() || + !HasFlag( geometry.positions.m_vertexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + return E_INVALIDARG; + } + if( !geometry.indices.IsValid() || + !HasFlag( geometry.indices.m_indexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + return E_INVALIDARG; + } + if( @available( macOS 13.0, * ) ) + { + } + else + { + if( geometry.positions.m_positionFormat != Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT ) + { + return E_INVALIDARG; + } + } + + if( @available( macOS 11.0, * ) ) + { + + MetalContext* metalContext = renderContext.GetMetalContext(); + + // GEOMETRY DESCRIPTOR + m_geomDesc = [MTLAccelerationStructureTriangleGeometryDescriptor descriptor]; + + m_geomDesc.indexBuffer = geometry.indices.m_indexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); + m_geomDesc.indexType = geometry.indices.m_stride == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32; + m_geomDesc.indexBufferOffset = geometry.indices.m_stride * geometry.indices.m_indexOffset; + + m_geomDesc.vertexBuffer = geometry.positions.m_vertexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); + m_geomDesc.vertexStride = geometry.positions.m_stride; + m_geomDesc.vertexBufferOffset = + geometry.positions.m_vertexOffset * geometry.positions.m_stride + geometry.positions.m_positionOffset; + + m_geomDesc.triangleCount = geometry.indices.m_indexCount / 3; + if( @available( macOS 13.0, * ) ) + { + m_geomDesc.vertexFormat = ConvertVertexFormat( geometry.positions.m_positionFormat ); + } + + // Acceleration structure descriptor ( a descriptor for descriptors ) + m_accelerationStructureDesc = [MTLPrimitiveAccelerationStructureDescriptor descriptor]; + m_accelerationStructureDesc.geometryDescriptors = @[m_geomDesc]; + if( HasFlag( buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) + { + m_accelerationStructureDesc.usage |= MTLAccelerationStructureUsageRefit; + } + if( HasFlag( buildFlags, Tr2RtBuildFlags::PREFER_FAST_BUILD ) ) + { + m_accelerationStructureDesc.usage |= MTLAccelerationStructureUsagePreferFastBuild; + } + + auto result = BuildAccelerationStructure( m_accelerationStructureDesc, metalContext ); + m_primitiveAccelerationStructure = result.first; + m_scratchBufferSize = result.second; + + m_geomDesc.indexBuffer = nil; + m_geomDesc.vertexBuffer = nil; + + return S_OK; + } + else + { + return E_INVALIDCALL; + } } -namespace TrinityALImpl { - - Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() - :m_scratchBufferSize( 0 ) - { - - } - - Tr2RtBottomLevelAccelerationStructureAL::~Tr2RtBottomLevelAccelerationStructureAL() - { - - } - - // Function to build a singular BLAS, list of BLAS to be kept elsewhere - ALResult Tr2RtBottomLevelAccelerationStructureAL::Create( const Tr2RtGeometryAL& geometry, const Tr2RtGeometryAL&, Tr2RtBlasGeometryFlags::Type geometryFlags, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) - { - if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) - { - return E_INVALIDCALL; - } - if( !geometry.positions.IsValid() || !HasFlag( geometry.positions.m_vertexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDARG; - } - if( !geometry.indices.IsValid() || !HasFlag( geometry.indices.m_indexBuffer.GetDesc().gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDARG; - } - if( @available( macOS 13.0, * ) ) - { - } - else - { - if( geometry.positions.m_positionFormat != Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32_FLOAT ) - { - return E_INVALIDARG; - } - } - - if (@available(macOS 11.0, *)) { - - MetalContext *metalContext = renderContext.GetMetalContext(); - - // GEOMETRY DESCRIPTOR - m_geomDesc = [MTLAccelerationStructureTriangleGeometryDescriptor descriptor]; - - m_geomDesc.indexBuffer = geometry.indices.m_indexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); - m_geomDesc.indexType = geometry.indices.m_stride == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32; - m_geomDesc.indexBufferOffset = geometry.indices.m_stride * geometry.indices.m_indexOffset; - - m_geomDesc.vertexBuffer = geometry.positions.m_vertexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); - m_geomDesc.vertexStride = geometry.positions.m_stride; - m_geomDesc.vertexBufferOffset = geometry.positions.m_vertexOffset * geometry.positions.m_stride + geometry.positions.m_positionOffset; - - m_geomDesc.triangleCount = geometry.indices.m_indexCount / 3; - if( @available( macOS 13.0, * ) ) - { - m_geomDesc.vertexFormat = ConvertVertexFormat( geometry.positions.m_positionFormat ); - } - - // Acceleration structure descriptor ( a descriptor for descriptors ) - m_accelerationStructureDesc = [MTLPrimitiveAccelerationStructureDescriptor descriptor]; - m_accelerationStructureDesc.geometryDescriptors = @[m_geomDesc]; - if( HasFlag( buildFlags, Tr2RtBuildFlags::ALLOW_UPDATE ) ) - { - m_accelerationStructureDesc.usage |= MTLAccelerationStructureUsageRefit; - } - if( HasFlag( buildFlags, Tr2RtBuildFlags::PREFER_FAST_BUILD ) ) - { - m_accelerationStructureDesc.usage |= MTLAccelerationStructureUsagePreferFastBuild; - } - - auto result = BuildAccelerationStructure( m_accelerationStructureDesc, metalContext ); - m_primitiveAccelerationStructure = result.first; - m_scratchBufferSize = result.second; - - m_geomDesc.indexBuffer = nil; - m_geomDesc.vertexBuffer = nil; - - return S_OK; - } - else - { - return E_INVALIDCALL; - } - } - - - ALResult Tr2RtBottomLevelAccelerationStructureAL::Update( const Tr2RtGeometryAL& geometry, Tr2RenderContextAL& renderContext ) - { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - if( @available(macOS 11.0, *) ) - { - if( ( m_accelerationStructureDesc.usage & MTLAccelerationStructureUsageRefit ) == 0 ) - { - return E_INVALIDARG; - } - if( m_geomDesc.vertexStride != geometry.positions.m_stride || - m_geomDesc.indexType != ( geometry.indices.m_stride == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 ) || - m_geomDesc.triangleCount != geometry.indices.m_indexCount / 3 ) - { - return E_INVALIDARG; - } - - m_geomDesc.indexBuffer = geometry.indices.m_indexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); - m_geomDesc.indexBufferOffset = geometry.indices.m_stride * geometry.indices.m_indexOffset; - - m_geomDesc.vertexBuffer = geometry.positions.m_vertexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); - m_geomDesc.vertexBufferOffset = geometry.positions.m_vertexOffset * geometry.positions.m_stride + geometry.positions.m_positionOffset; - - MetalContext *metalContext = renderContext.GetMetalContext(); - - if( !m_scratchBuffer && m_scratchBufferSize > 0 ) - { - m_scratchBuffer = [metalContext->GetDevice() newBufferWithLength:m_scratchBufferSize options:MTLResourceStorageModePrivate]; - } - auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); - - // refit - [commandEncoder refitAccelerationStructure:m_primitiveAccelerationStructure - descriptor:m_accelerationStructureDesc - destination:m_primitiveAccelerationStructure - scratchBuffer:m_scratchBuffer - scratchBufferOffset:0]; - metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); - - m_geomDesc.indexBuffer = nil; - m_geomDesc.vertexBuffer = nil; - - return S_OK; - } - else - { - return E_INVALIDCALL; - } - } - - ALResult Tr2RtBottomLevelAccelerationStructureAL::CompactBlas( Tr2PrimaryRenderContextAL& renderContext ) - { - return S_OK; - } - - bool Tr2RtBottomLevelAccelerationStructureAL::IsValid() const - { - if( @available(macOS 11.0, *) ) - { - return m_primitiveAccelerationStructure != nullptr; - } - else - { - return false; - } - } - - Tr2ALMemoryType Tr2RtBottomLevelAccelerationStructureAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - void Tr2RtBottomLevelAccelerationStructureAL::Destroy() - { - if( @available(macOS 11.0, *) ) - { - m_primitiveAccelerationStructure = nullptr; - m_geomDesc = nullptr; - m_accelerationStructureDesc = nullptr; - } - m_scratchBuffer = nullptr; - m_scratchBufferSize = 0; - } - - void Tr2RtBottomLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtBottomLevelAccelerationStructureAL"; - } + +ALResult Tr2RtBottomLevelAccelerationStructureAL::Update( const Tr2RtGeometryAL& geometry, + Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) + { + return E_INVALIDARG; + } + + if( @available( macOS 11.0, * ) ) + { + if( ( m_accelerationStructureDesc.usage & MTLAccelerationStructureUsageRefit ) == 0 ) + { + return E_INVALIDARG; + } + if( m_geomDesc.vertexStride != geometry.positions.m_stride || + m_geomDesc.indexType != ( geometry.indices.m_stride == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 ) || + m_geomDesc.triangleCount != geometry.indices.m_indexCount / 3 ) + { + return E_INVALIDARG; + } + + m_geomDesc.indexBuffer = geometry.indices.m_indexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); + m_geomDesc.indexBufferOffset = geometry.indices.m_stride * geometry.indices.m_indexOffset; + + m_geomDesc.vertexBuffer = geometry.positions.m_vertexBuffer.TrinityALImpl_GetObject()->GetMetalBuffer(); + m_geomDesc.vertexBufferOffset = + geometry.positions.m_vertexOffset * geometry.positions.m_stride + geometry.positions.m_positionOffset; + + MetalContext* metalContext = renderContext.GetMetalContext(); + + if( !m_scratchBuffer && m_scratchBufferSize > 0 ) + { + m_scratchBuffer = [metalContext->GetDevice() newBufferWithLength:m_scratchBufferSize + options:MTLResourceStorageModePrivate]; + } + auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); + + // refit + [commandEncoder refitAccelerationStructure:m_primitiveAccelerationStructure + descriptor:m_accelerationStructureDesc + destination:m_primitiveAccelerationStructure + scratchBuffer:m_scratchBuffer + scratchBufferOffset:0]; + metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); + + m_geomDesc.indexBuffer = nil; + m_geomDesc.vertexBuffer = nil; + + return S_OK; + } + else + { + return E_INVALIDCALL; + } +} + +ALResult Tr2RtBottomLevelAccelerationStructureAL::CompactBlas( Tr2PrimaryRenderContextAL& renderContext ) +{ + return S_OK; +} + +bool Tr2RtBottomLevelAccelerationStructureAL::IsValid() const +{ + if( @available( macOS 11.0, * ) ) + { + return m_primitiveAccelerationStructure != nullptr; + } + else + { + return false; + } +} + +Tr2ALMemoryType Tr2RtBottomLevelAccelerationStructureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2RtBottomLevelAccelerationStructureAL::Destroy() +{ + if( @available( macOS 11.0, * ) ) + { + m_primitiveAccelerationStructure = nullptr; + m_geomDesc = nullptr; + m_accelerationStructureDesc = nullptr; + } + m_scratchBuffer = nullptr; + m_scratchBufferSize = 0; +} + +void Tr2RtBottomLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtBottomLevelAccelerationStructureAL"; +} } #endif diff --git a/trinityal/metal/Tr2RtPipelineStateALMetal.h b/trinityal/metal/Tr2RtPipelineStateALMetal.h index 78d2a131e..680f2510a 100644 --- a/trinityal/metal/Tr2RtPipelineStateALMetal.h +++ b/trinityal/metal/Tr2RtPipelineStateALMetal.h @@ -23,48 +23,48 @@ namespace TrinityALImpl class Tr2RtPipelineStateAL : public Tr2DeviceResourceAL { public: - Tr2RtPipelineStateAL(); - ~Tr2RtPipelineStateAL(); - - ALResult CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - struct HitGroupFunctions - { - id closestHit; - id intersection; - id anyHit; - }; - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - std::optional GetRayGenIndex( const wchar_t* rayGenName ) const; - id GetRtPipeline( uint32_t rayGenIndex ) const; - const ::Tr2ShaderProgramAL& GetShaderProgram( uint32_t rayGenIndex ) const; - const std::unordered_map>& GetFunctionMap() const; - const std::unordered_map& GetHitGroupMap() const; - NSString* NSStringFromWchar( std::wstring name ); + Tr2RtPipelineStateAL(); + ~Tr2RtPipelineStateAL(); - Tr2ShaderSignatureAL m_globalSignature; + ALResult CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + struct HitGroupFunctions + { + id closestHit; + id intersection; + id anyHit; + }; + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + std::optional GetRayGenIndex( const wchar_t* rayGenName ) const; + id GetRtPipeline( uint32_t rayGenIndex ) const; + const ::Tr2ShaderProgramAL& GetShaderProgram( uint32_t rayGenIndex ) const; + const std::unordered_map>& GetFunctionMap() const; + const std::unordered_map& GetHitGroupMap() const; + NSString* NSStringFromWchar( std::wstring name ); + + Tr2ShaderSignatureAL m_globalSignature; private: - id CreateFunction( std::wstring name, id device, dispatch_data_t shaderData ); - - std::unordered_map> m_intersectionFunctions; - std::unordered_map m_hitGroupMap; - - struct RayGenShader - { - std::wstring name; - ::Tr2ShaderProgramAL shaderProgram; - id pipeline; - }; - std::vector m_rayGenShaders; - - friend class Tr2RtShaderTableAL; + id CreateFunction( std::wstring name, id device, dispatch_data_t shaderData ); + + std::unordered_map> m_intersectionFunctions; + std::unordered_map m_hitGroupMap; + + struct RayGenShader + { + std::wstring name; + ::Tr2ShaderProgramAL shaderProgram; + id pipeline; + }; + std::vector m_rayGenShaders; + + friend class Tr2RtShaderTableAL; }; } #endif - diff --git a/trinityal/metal/Tr2RtPipelineStateALMetal.mm b/trinityal/metal/Tr2RtPipelineStateALMetal.mm index 2f55d8284..4e1a2c58a 100644 --- a/trinityal/metal/Tr2RtPipelineStateALMetal.mm +++ b/trinityal/metal/Tr2RtPipelineStateALMetal.mm @@ -19,267 +19,277 @@ namespace TrinityALImpl { - Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() - { - } - - Tr2RtPipelineStateAL::~Tr2RtPipelineStateAL() - { - } - - NSString* Tr2RtPipelineStateAL::NSStringFromWchar( std::wstring name ) - { - NSString* sName = [[NSString alloc] initWithBytes:name.data() - length:name.size() * sizeof(wchar_t) - encoding:NSUTF32LittleEndianStringEncoding]; - - return sName; - } - - id Tr2RtPipelineStateAL::CreateFunction( std::wstring name, id device, dispatch_data_t shaderData ) - { - NSError* error = nullptr; - id mtlLib = [device newLibraryWithData:shaderData error:&error]; -#if !__has_feature(objc_arc) - dispatch_release(shaderData); +Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() +{ +} + +Tr2RtPipelineStateAL::~Tr2RtPipelineStateAL() +{ +} + +NSString* Tr2RtPipelineStateAL::NSStringFromWchar( std::wstring name ) +{ + NSString* sName = [[NSString alloc] initWithBytes:name.data() + length:name.size() * sizeof( wchar_t ) + encoding:NSUTF32LittleEndianStringEncoding]; + + return sName; +} + +id + Tr2RtPipelineStateAL::CreateFunction( std::wstring name, id device, dispatch_data_t shaderData ) +{ + NSError* error = nullptr; + id mtlLib = [device newLibraryWithData:shaderData error:&error]; +#if !__has_feature( objc_arc ) + dispatch_release( shaderData ); #endif - - if( !mtlLib ) - { - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Failed to create Metal shader library. Error: %s", - error.localizedDescription.UTF8String ); -#if !__has_feature(objc_arc) - if( error ) - { - [error release]; - } + + if( !mtlLib ) + { + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Failed to create Metal shader library. Error: %s", + error.localizedDescription.UTF8String ); +#if !__has_feature( objc_arc ) + if( error ) + { + [error release]; + } #endif - return nil; - } - - NSString* NSname = NSStringFromWchar( name ); - - // Fill out a dictionary of function constant values. - // MTLFunctionConstantValues *constants = [[MTLFunctionConstantValues alloc] init]; - // The second constant turns the use of intersection functions on and off. - //bool _useIntersectionFunctions = true; - //[constants setConstantValue:&_useIntersectionFunctions type:MTLDataTypeBool atIndex:0]; - - id fn = [mtlLib newFunctionWithName:NSname]; //constantValues:constants error:&error]; - - return fn; - - } - - ALResult Tr2RtPipelineStateAL::CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, Tr2PrimaryRenderContextAL& renderContext ) - { - if (@available(macOS 11.0, *)) - { - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - - if( desc.m_shaders.empty() ) - { - return E_INVALIDCALL; - } - - // create shader programs for ray gen shaders - std::vector rayGenShaders; - - for( auto& shader : desc.m_shaders ) - { - for( auto& name : shader.names ) - { - if( name.name == L"RayGen" ) - { - ::Tr2ShaderAL rayGenShader; - FORWARD_HR( rayGenShader.Create(Tr2RenderContextEnum::COMPUTE_SHADER, shader.bytecode, desc.m_globalSignature, "", renderContext) ); - rayGenShader.TrinityALImpl_GetObject()->m_entryPointNameOverride = NSStringFromWchar( name.name ); - - ::Tr2ShaderProgramAL shaderProgram; - FORWARD_HR( shaderProgram.Create( &rayGenShader, 1, renderContext ) ); - rayGenShaders.push_back( { name.exportName, shaderProgram } ); - } - } - } - if( rayGenShaders.empty() ) - { - return E_INVALIDARG; - } - - id mtlDevice = renderContext.GetMetalContext()->GetDevice(); - - NSMutableArray *linkedFunctions = [[NSMutableArray alloc]init]; - - for( auto& shader : desc.m_shaders ) - { - dispatch_data_t shaderData = dispatch_data_create( - shader.bytecode.bytecode, - shader.bytecode.size, - dispatch_get_global_queue(0, 0), - DISPATCH_DATA_DESTRUCTOR_DEFAULT ); - NSError* error = nullptr; - id mtlLib = [mtlDevice newLibraryWithData:shaderData error:&error]; - if( !mtlLib ) - { - CCP_AL_LOGERR( "Tr2RtPipelineStateAL: Failed to create Metal shader library. Error: %s", error.localizedDescription.UTF8String ); - return E_FAIL; - } - - for( auto& name : shader.names ) - { - if( name.name == L"RayGen" ) - { - continue; - } - auto descriptor = [MTLFunctionDescriptor functionDescriptor]; - descriptor.name = NSStringFromWchar( name.name ); - descriptor.specializedName = NSStringFromWchar( name.exportName ); - - error = nullptr; - id fn = [mtlLib newFunctionWithDescriptor:descriptor error:&error]; - if( fn == nil ) - { - CCP_AL_LOGERR( "Tr2RtPipelineStateAL: Failed to get function %S from Metal shader library. Error: %s", name.name.c_str(), error.localizedDescription.UTF8String ); - return E_FAIL; - } - - m_intersectionFunctions[name.exportName] = fn; - [linkedFunctions addObject:fn]; - } - } - - if( m_intersectionFunctions.size() == 0 ) - { - return E_FAIL; - } - - for( auto& hGroup : desc.m_hitGroups ) - { - auto& dest = m_hitGroupMap[hGroup.exportName]; - - if( !hGroup.anyHit.empty() ) - { - auto found = m_intersectionFunctions.find( hGroup.anyHit ); - if( found == end( m_intersectionFunctions ) ) - { - return E_INVALIDARG; - } - dest.anyHit = found->second; - } - if( !hGroup.intersection.empty() ) - { - auto found = m_intersectionFunctions.find( hGroup.intersection ); - if( found == end( m_intersectionFunctions ) ) - { - return E_INVALIDARG; - } - dest.intersection = found->second; - } - if( !hGroup.closestHit.empty() ) - { - auto found = m_intersectionFunctions.find( hGroup.closestHit ); - if( found == end( m_intersectionFunctions ) ) - { - return E_INVALIDARG; - } - dest.closestHit = found->second; - } - } - - MTLLinkedFunctions *mtlLinkedFunctions = nil; - // Attach the additional functions to an MTLLinkedFunctions object - mtlLinkedFunctions = [[MTLLinkedFunctions alloc] init]; - mtlLinkedFunctions.functions = linkedFunctions; - - id device = renderContext.GetMetalContext()->GetDevice(); - - for( auto& rayGen : rayGenShaders ) - { - MTLComputePipelineDescriptor *descriptor = [[MTLComputePipelineDescriptor alloc] init]; - descriptor.computeFunction = rayGen.shaderProgram.TrinityALImpl_GetObject()->GetComputeKernel(); - // add the functions to the pipeline - descriptor.linkedFunctions = mtlLinkedFunctions; - // Set to YES to allow the compiler to make certain optimizations. - descriptor.threadGroupSizeIsMultipleOfThreadExecutionWidth = YES; - // Create compute pipelines will execute code on the GPU - // Create the compute pipeline state which does all the raytracing - NSError *error = nullptr; - rayGen.pipeline = [device newComputePipelineStateWithDescriptor:descriptor - options:0 - reflection:nil - error:&error]; - - if( !rayGen.pipeline ) - { - CCP_LOGERR("Failed to create a raytracing pipeline state: %s", error.localizedDescription.UTF8String ); - } - } - m_globalSignature = desc.m_globalSignature; - m_rayGenShaders = std::move( rayGenShaders ); - - return S_OK; - } - else - { - return E_FAIL; - } - } - - std::optional Tr2RtPipelineStateAL::GetRayGenIndex( const wchar_t* rayGenName ) const - { - auto found = find_if( begin( m_rayGenShaders ), end( m_rayGenShaders ), [rayGenName]( const auto& x ) { return x.name == rayGenName; } ); - if( found == end( m_rayGenShaders ) ) - { - return {}; - } - return found - begin( m_rayGenShaders ); - - } - - const ::Tr2ShaderProgramAL& Tr2RtPipelineStateAL::GetShaderProgram( uint32_t rayGenIndex ) const - { - return m_rayGenShaders[rayGenIndex].shaderProgram; - } - - bool Tr2RtPipelineStateAL::IsValid() const - { - return !m_rayGenShaders.empty(); - } - - Tr2ALMemoryType Tr2RtPipelineStateAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - id Tr2RtPipelineStateAL::GetRtPipeline( uint32_t rayGenIndex ) const - { - return m_rayGenShaders[rayGenIndex].pipeline; - } - - void Tr2RtPipelineStateAL::Destroy() - { - m_intersectionFunctions.clear(); - m_hitGroupMap.clear(); - m_rayGenShaders.clear(); - } - - void Tr2RtPipelineStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtPipelineStateAL"; - } - - const std::unordered_map>& Tr2RtPipelineStateAL::GetFunctionMap() const - { - return m_intersectionFunctions; - } - - const std::unordered_map& Tr2RtPipelineStateAL::GetHitGroupMap() const - { - return m_hitGroupMap; - } + return nil; + } + + NSString* NSname = NSStringFromWchar( name ); + + // Fill out a dictionary of function constant values. + // MTLFunctionConstantValues *constants = [[MTLFunctionConstantValues alloc] init]; + // The second constant turns the use of intersection functions on and off. + //bool _useIntersectionFunctions = true; + //[constants setConstantValue:&_useIntersectionFunctions type:MTLDataTypeBool atIndex:0]; + + id fn = [mtlLib newFunctionWithName:NSname]; //constantValues:constants error:&error]; + + return fn; +} + +ALResult Tr2RtPipelineStateAL::CreateRtPipelineState( const Tr2RtPipelineStateDescriptionAL& desc, + Tr2PrimaryRenderContextAL& renderContext ) +{ + if( @available( macOS 11.0, * ) ) + { + if( !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } + + if( desc.m_shaders.empty() ) + { + return E_INVALIDCALL; + } + + // create shader programs for ray gen shaders + std::vector rayGenShaders; + + for( auto& shader : desc.m_shaders ) + { + for( auto& name : shader.names ) + { + if( name.name == L"RayGen" ) + { + ::Tr2ShaderAL rayGenShader; + FORWARD_HR( rayGenShader.Create( Tr2RenderContextEnum::COMPUTE_SHADER, + shader.bytecode, + desc.m_globalSignature, + "", + renderContext ) ); + rayGenShader.TrinityALImpl_GetObject()->m_entryPointNameOverride = NSStringFromWchar( name.name ); + + ::Tr2ShaderProgramAL shaderProgram; + FORWARD_HR( shaderProgram.Create( &rayGenShader, 1, renderContext ) ); + rayGenShaders.push_back( { name.exportName, shaderProgram } ); + } + } + } + if( rayGenShaders.empty() ) + { + return E_INVALIDARG; + } + + id mtlDevice = renderContext.GetMetalContext()->GetDevice(); + + NSMutableArray* linkedFunctions = [[NSMutableArray alloc] init]; + + for( auto& shader : desc.m_shaders ) + { + dispatch_data_t shaderData = dispatch_data_create( shader.bytecode.bytecode, + shader.bytecode.size, + dispatch_get_global_queue( 0, 0 ), + DISPATCH_DATA_DESTRUCTOR_DEFAULT ); + NSError* error = nullptr; + id mtlLib = [mtlDevice newLibraryWithData:shaderData error:&error]; + if( !mtlLib ) + { + CCP_AL_LOGERR( "Tr2RtPipelineStateAL: Failed to create Metal shader library. Error: %s", + error.localizedDescription.UTF8String ); + return E_FAIL; + } + + for( auto& name : shader.names ) + { + if( name.name == L"RayGen" ) + { + continue; + } + auto descriptor = [MTLFunctionDescriptor functionDescriptor]; + descriptor.name = NSStringFromWchar( name.name ); + descriptor.specializedName = NSStringFromWchar( name.exportName ); + + error = nullptr; + id fn = [mtlLib newFunctionWithDescriptor:descriptor error:&error]; + if( fn == nil ) + { + CCP_AL_LOGERR( + "Tr2RtPipelineStateAL: Failed to get function %S from Metal shader library. Error: %s", + name.name.c_str(), + error.localizedDescription.UTF8String ); + return E_FAIL; + } + + m_intersectionFunctions[name.exportName] = fn; + [linkedFunctions addObject:fn]; + } + } + + if( m_intersectionFunctions.size() == 0 ) + { + return E_FAIL; + } + + for( auto& hGroup : desc.m_hitGroups ) + { + auto& dest = m_hitGroupMap[hGroup.exportName]; + + if( !hGroup.anyHit.empty() ) + { + auto found = m_intersectionFunctions.find( hGroup.anyHit ); + if( found == end( m_intersectionFunctions ) ) + { + return E_INVALIDARG; + } + dest.anyHit = found->second; + } + if( !hGroup.intersection.empty() ) + { + auto found = m_intersectionFunctions.find( hGroup.intersection ); + if( found == end( m_intersectionFunctions ) ) + { + return E_INVALIDARG; + } + dest.intersection = found->second; + } + if( !hGroup.closestHit.empty() ) + { + auto found = m_intersectionFunctions.find( hGroup.closestHit ); + if( found == end( m_intersectionFunctions ) ) + { + return E_INVALIDARG; + } + dest.closestHit = found->second; + } + } + + MTLLinkedFunctions* mtlLinkedFunctions = nil; + // Attach the additional functions to an MTLLinkedFunctions object + mtlLinkedFunctions = [[MTLLinkedFunctions alloc] init]; + mtlLinkedFunctions.functions = linkedFunctions; + + id device = renderContext.GetMetalContext()->GetDevice(); + + for( auto& rayGen : rayGenShaders ) + { + MTLComputePipelineDescriptor* descriptor = [[MTLComputePipelineDescriptor alloc] init]; + descriptor.computeFunction = rayGen.shaderProgram.TrinityALImpl_GetObject()->GetComputeKernel(); + // add the functions to the pipeline + descriptor.linkedFunctions = mtlLinkedFunctions; + // Set to YES to allow the compiler to make certain optimizations. + descriptor.threadGroupSizeIsMultipleOfThreadExecutionWidth = YES; + // Create compute pipelines will execute code on the GPU + // Create the compute pipeline state which does all the raytracing + NSError* error = nullptr; + rayGen.pipeline = [device newComputePipelineStateWithDescriptor:descriptor + options:0 + reflection:nil + error:&error]; + + if( !rayGen.pipeline ) + { + CCP_LOGERR( "Failed to create a raytracing pipeline state: %s", error.localizedDescription.UTF8String ); + } + } + m_globalSignature = desc.m_globalSignature; + m_rayGenShaders = std::move( rayGenShaders ); + + return S_OK; + } + else + { + return E_FAIL; + } +} + +std::optional Tr2RtPipelineStateAL::GetRayGenIndex( const wchar_t* rayGenName ) const +{ + auto found = find_if( begin( m_rayGenShaders ), end( m_rayGenShaders ), [rayGenName]( const auto& x ) { + return x.name == rayGenName; + } ); + if( found == end( m_rayGenShaders ) ) + { + return {}; + } + return found - begin( m_rayGenShaders ); +} + +const ::Tr2ShaderProgramAL& Tr2RtPipelineStateAL::GetShaderProgram( uint32_t rayGenIndex ) const +{ + return m_rayGenShaders[rayGenIndex].shaderProgram; +} + +bool Tr2RtPipelineStateAL::IsValid() const +{ + return !m_rayGenShaders.empty(); +} + +Tr2ALMemoryType Tr2RtPipelineStateAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +id Tr2RtPipelineStateAL::GetRtPipeline( uint32_t rayGenIndex ) const +{ + return m_rayGenShaders[rayGenIndex].pipeline; +} + +void Tr2RtPipelineStateAL::Destroy() +{ + m_intersectionFunctions.clear(); + m_hitGroupMap.clear(); + m_rayGenShaders.clear(); +} + +void Tr2RtPipelineStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtPipelineStateAL"; +} + +const std::unordered_map>& Tr2RtPipelineStateAL::GetFunctionMap() const +{ + return m_intersectionFunctions; +} + +const std::unordered_map& + Tr2RtPipelineStateAL::GetHitGroupMap() const +{ + return m_hitGroupMap; +} } #endif diff --git a/trinityal/metal/Tr2RtShaderTableALMetal.h b/trinityal/metal/Tr2RtShaderTableALMetal.h index 3b2ebe798..84b2b6f59 100644 --- a/trinityal/metal/Tr2RtShaderTableALMetal.h +++ b/trinityal/metal/Tr2RtShaderTableALMetal.h @@ -18,58 +18,60 @@ namespace TrinityALImpl { - class Tr2RtShaderTableAL : public Tr2DeviceResourceAL - { - public: - Tr2RtShaderTableAL(); - ~Tr2RtShaderTableAL(); - - ALResult Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - bool IsValid() const; - - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - struct API_AVAILABLE( macos(13.0)) ShaderTableData - { - MTLResourceID intersectionShaderTable; - MTLResourceID missShaderTable; - MTLResourceID closestHitShaderTable; - uint64_t missMaterials; - uint64_t hitMaterials; - uint64_t globalInput; - }; - - API_AVAILABLE( macos(13.0) ) - ShaderTableData GetShaderTableData( uint32_t rayGenIndex, uint64_t globalInputAddress ) const; - - API_AVAILABLE( macos(13.0) ) - void AddUsedResources( uint32_t rayGenIndex, std::vector>& readResources ) const; - - void SetGlobalInputBuffer( uint32_t rayGenIndex, const id& buffer, uint32_t offset ) const; - - id GetMaterialBuffer() const; - NSUInteger GetRayGenMaterialOffset(uint32_t rayGenIndex) const; - - - private: - Tr2RtShaderTableDescriptionAL m_desc; - - struct API_AVAILABLE( macos(11.0) ) FunctionTables - { - id anyHit; - id closestHit; - id miss; - }; - - API_AVAILABLE( macos(11.0) ) - std::vector m_functionTables; - - id m_materialBuffer; - NSUInteger m_missMaterialOffset = 0; - NSUInteger m_rayGenMaterialOffset = 0; - }; +class Tr2RtShaderTableAL : public Tr2DeviceResourceAL +{ +public: + Tr2RtShaderTableAL(); + ~Tr2RtShaderTableAL(); + + ALResult Create( const Tr2RtShaderTableDescriptionAL& desc, + const ::Tr2RtPipelineStateAL& pipeline, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + bool IsValid() const; + + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + struct API_AVAILABLE( macos( 13.0 ) ) ShaderTableData + { + MTLResourceID intersectionShaderTable; + MTLResourceID missShaderTable; + MTLResourceID closestHitShaderTable; + uint64_t missMaterials; + uint64_t hitMaterials; + uint64_t globalInput; + }; + + API_AVAILABLE( macos( 13.0 ) ) + ShaderTableData GetShaderTableData( uint32_t rayGenIndex, uint64_t globalInputAddress ) const; + + API_AVAILABLE( macos( 13.0 ) ) + void AddUsedResources( uint32_t rayGenIndex, std::vector>& readResources ) const; + + void SetGlobalInputBuffer( uint32_t rayGenIndex, const id& buffer, uint32_t offset ) const; + + id GetMaterialBuffer() const; + NSUInteger GetRayGenMaterialOffset( uint32_t rayGenIndex ) const; + + +private: + Tr2RtShaderTableDescriptionAL m_desc; + + struct API_AVAILABLE( macos( 11.0 ) ) FunctionTables + { + id anyHit; + id closestHit; + id miss; + }; + + API_AVAILABLE( macos( 11.0 ) ) + std::vector m_functionTables; + + id m_materialBuffer; + NSUInteger m_missMaterialOffset = 0; + NSUInteger m_rayGenMaterialOffset = 0; +}; } #endif diff --git a/trinityal/metal/Tr2RtShaderTableALMetal.mm b/trinityal/metal/Tr2RtShaderTableALMetal.mm index 393a73b96..27ce1f1a6 100644 --- a/trinityal/metal/Tr2RtShaderTableALMetal.mm +++ b/trinityal/metal/Tr2RtShaderTableALMetal.mm @@ -21,236 +21,243 @@ namespace TrinityALImpl { - Tr2RtShaderTableAL::Tr2RtShaderTableAL() - { - } - - Tr2RtShaderTableAL::~Tr2RtShaderTableAL() - { - Destroy(); - } - - // Shader tables contain shader records. Shader records contain a shader identifier and root arguments used to look up resources - ALResult Tr2RtShaderTableAL::Create( const Tr2RtShaderTableDescriptionAL& desc, const ::Tr2RtPipelineStateAL& pipeline, Tr2PrimaryRenderContextAL& renderContext ) - { - if (@available(macOS 13.0, *)) - { - auto missFunctionTableDescriptor = [[MTLVisibleFunctionTableDescriptor alloc] init]; - missFunctionTableDescriptor.functionCount = desc.m_missNames.size(); - - auto closestHitFunctionTableDescriptor = [[MTLVisibleFunctionTableDescriptor alloc] init]; - closestHitFunctionTableDescriptor.functionCount = desc.m_hitGroupNames.size(); - - auto anyHitFunctionTableDescriptor = [[MTLIntersectionFunctionTableDescriptor alloc] init]; - anyHitFunctionTableDescriptor.functionCount = desc.m_hitGroupNames.size(); - - const int BUFFERS_PER_SHADER = sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants ) / sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants[0] ); - - std::vector hitBuffers; - hitBuffers.reserve( desc.m_hitGroupNames.size() * BUFFERS_PER_SHADER ); - - auto FillMaterial = [&]( auto& ptrs, auto& material ) - { - for( auto& cb : material.m_constants ) - { - uint64_t address = 0; - if( cb && cb->IsValid() ) - { - uint64_t offset = renderContext.UploadConstants( *cb ); - uint32_t page = uint32_t( offset >> 32 ); - // have a vector of offsets (gpu address + addr) so for each instance it has it's own pointer into a large buffer. - // then bind that vector to the shadertable - id cBuffer = renderContext.GetMetalContext()->GetConstantBufferAllocator().GetPage( page ); - - renderContext.UseConstantBuffer(cBuffer); - address = cBuffer.gpuAddress + offset; - } - ptrs.push_back( address ); - } - }; - - auto& intersectionFunctions = pipeline.TrinityALImpl_GetObject()->GetFunctionMap(); - auto& hitGroupMap = pipeline.TrinityALImpl_GetObject()->GetHitGroupMap(); - - std::vector functionTables; - - // Create a table large enough to hold all of the intersection functions. Metal - // links intersection functions into the compute pipeline state, potentially with - // a different address for each compute pipeline. Therefore, the intersection - // function table is specific to the compute pipeline state that created it, and you - // can use it with only that pipeline. - for( auto& rayGen : pipeline.TrinityALImpl_GetObject()->m_rayGenShaders ) - { - FunctionTables functions; - functions.miss = [rayGen.pipeline newVisibleFunctionTableWithDescriptor:missFunctionTableDescriptor]; - functions.closestHit = [rayGen.pipeline newVisibleFunctionTableWithDescriptor:closestHitFunctionTableDescriptor]; - functions.anyHit = [rayGen.pipeline newIntersectionFunctionTableWithDescriptor:anyHitFunctionTableDescriptor]; - - auto SetFunction = [&]( auto& table, const id& function, int index ) - { - auto handle = [rayGen.pipeline functionHandleWithFunction:function]; - if( !handle ) - { - return E_INVALIDARG; - } - [table setFunction:handle atIndex:index]; - return S_OK; - }; - - // Map each piece of scene hit group to its intersection function. - int groupIndex = 0; - for( auto& hitGroup : desc.m_hitGroupNames ) - { - auto found = hitGroupMap.find( hitGroup.name ); - if( found == end( hitGroupMap ) ) - { - return E_FAIL; - } - if( found->second.intersection ) - { - return E_FAIL; - } - if( found->second.anyHit ) - { - CR_RETURN_HR( SetFunction( functions.anyHit, found->second.anyHit, groupIndex ) ); - } - else - { - auto signature = MTLIntersectionFunctionSignatureInstancing | MTLIntersectionFunctionSignatureTriangleData | MTLIntersectionFunctionSignatureWorldSpaceData; - [functions.anyHit setOpaqueTriangleIntersectionFunctionWithSignature:signature atIndex:groupIndex]; - } - if( found->second.closestHit ) - { - CR_RETURN_HR( SetFunction( functions.closestHit, found->second.closestHit, groupIndex ) ); - } - if( functionTables.empty() ) - { - FillMaterial( hitBuffers, hitGroup.material ); - } - ++groupIndex; - } - if( functionTables.empty() ) - { - m_missMaterialOffset = hitBuffers.size() * sizeof( uint64_t ); - } - int missIndex = 0; - for( auto& names : desc.m_missNames ) - { - auto found = intersectionFunctions.find( names.name ); - if( found == end( intersectionFunctions ) ) - { - return E_FAIL; - } - CR_RETURN_HR( !SetFunction( functions.miss, found->second, missIndex ) ); - if( functionTables.empty() ) - { - FillMaterial( hitBuffers, names.material ); - } - missIndex++; - } - functionTables.push_back( functions ); - } - - m_functionTables = std::move( functionTables ); - - m_rayGenMaterialOffset = hitBuffers.size() * sizeof( uint64_t ); - for( auto& name : desc.m_rayGenNames ) - { - FillMaterial( hitBuffers, name.material ); - } - - id device = renderContext.GetMetalContext()->GetDevice(); - if( !hitBuffers.empty() ) - { - m_materialBuffer = [device newBufferWithBytes:hitBuffers.data() - length:hitBuffers.size() * sizeof( uint64_t ) - options:MTLResourceStorageModeManaged]; - for( auto& tables : m_functionTables ) - { - [tables.anyHit setBuffer:m_materialBuffer offset:0 atIndex:0]; - } - } - - return S_OK; - } - else - { - return E_FAIL; - } - } - - void Tr2RtShaderTableAL::Destroy() - { - if( @available(macOS 11.0, *) ) - { - m_functionTables.clear(); - } - m_materialBuffer = nullptr; - } - - bool Tr2RtShaderTableAL::IsValid() const - { - if( @available(macOS 11.0, *) ) - { - return !m_functionTables.empty(); - } - return false; - } - - API_AVAILABLE( macos(13.0) ) - Tr2RtShaderTableAL::ShaderTableData Tr2RtShaderTableAL::GetShaderTableData( uint32_t rayGenIndex, uint64_t globalInputAddress ) const - { - auto& tables = m_functionTables[rayGenIndex]; - return ShaderTableData{ - tables.anyHit.gpuResourceID, - tables.miss.gpuResourceID, - tables.closestHit.gpuResourceID, - - m_materialBuffer.gpuAddress + m_missMaterialOffset, - m_materialBuffer.gpuAddress, - globalInputAddress - }; - } - - API_AVAILABLE( macos(13.0) ) - void Tr2RtShaderTableAL::AddUsedResources( uint32_t rayGenIndex, std::vector>& readResources ) const - { - auto& tables = m_functionTables[rayGenIndex]; - readResources.push_back( tables.anyHit ); - readResources.push_back( tables.miss ); - readResources.push_back( tables.closestHit ); - readResources.push_back( m_materialBuffer ); - } - - void Tr2RtShaderTableAL::SetGlobalInputBuffer( uint32_t rayGenIndex, const id& buffer, uint32_t offset ) const - { - if (@available(macOS 11.0, *)) - { - [m_functionTables[rayGenIndex].anyHit setBuffer:buffer offset:offset atIndex:1]; - } - } - - - id Tr2RtShaderTableAL::GetMaterialBuffer() const - { - return m_materialBuffer; - } - - NSUInteger Tr2RtShaderTableAL::GetRayGenMaterialOffset(uint32_t rayGenIndex) const - { - const int BUFFERS_PER_SHADER = sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants ) / sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants[0] ); - return m_rayGenMaterialOffset + sizeof(uint64_t) * BUFFERS_PER_SHADER * rayGenIndex; - } - - Tr2ALMemoryType Tr2RtShaderTableAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - void Tr2RtShaderTableAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtShaderTableAL"; - } +Tr2RtShaderTableAL::Tr2RtShaderTableAL() +{ +} + +Tr2RtShaderTableAL::~Tr2RtShaderTableAL() +{ + Destroy(); +} + +// Shader tables contain shader records. Shader records contain a shader identifier and root arguments used to look up resources +ALResult Tr2RtShaderTableAL::Create( const Tr2RtShaderTableDescriptionAL& desc, + const ::Tr2RtPipelineStateAL& pipeline, + Tr2PrimaryRenderContextAL& renderContext ) +{ + if( @available( macOS 13.0, * ) ) + { + auto missFunctionTableDescriptor = [[MTLVisibleFunctionTableDescriptor alloc] init]; + missFunctionTableDescriptor.functionCount = desc.m_missNames.size(); + + auto closestHitFunctionTableDescriptor = [[MTLVisibleFunctionTableDescriptor alloc] init]; + closestHitFunctionTableDescriptor.functionCount = desc.m_hitGroupNames.size(); + + auto anyHitFunctionTableDescriptor = [[MTLIntersectionFunctionTableDescriptor alloc] init]; + anyHitFunctionTableDescriptor.functionCount = desc.m_hitGroupNames.size(); + + const int BUFFERS_PER_SHADER = sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants ) / + sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants[0] ); + + std::vector hitBuffers; + hitBuffers.reserve( desc.m_hitGroupNames.size() * BUFFERS_PER_SHADER ); + + auto FillMaterial = [&]( auto& ptrs, auto& material ) { + for( auto& cb : material.m_constants ) + { + uint64_t address = 0; + if( cb && cb->IsValid() ) + { + uint64_t offset = renderContext.UploadConstants( *cb ); + uint32_t page = uint32_t( offset >> 32 ); + // have a vector of offsets (gpu address + addr) so for each instance it has it's own pointer into a large buffer. + // then bind that vector to the shadertable + id cBuffer = + renderContext.GetMetalContext()->GetConstantBufferAllocator().GetPage( page ); + + renderContext.UseConstantBuffer( cBuffer ); + address = cBuffer.gpuAddress + offset; + } + ptrs.push_back( address ); + } + }; + + auto& intersectionFunctions = pipeline.TrinityALImpl_GetObject()->GetFunctionMap(); + auto& hitGroupMap = pipeline.TrinityALImpl_GetObject()->GetHitGroupMap(); + + std::vector functionTables; + + // Create a table large enough to hold all of the intersection functions. Metal + // links intersection functions into the compute pipeline state, potentially with + // a different address for each compute pipeline. Therefore, the intersection + // function table is specific to the compute pipeline state that created it, and you + // can use it with only that pipeline. + for( auto& rayGen : pipeline.TrinityALImpl_GetObject()->m_rayGenShaders ) + { + FunctionTables functions; + functions.miss = [rayGen.pipeline newVisibleFunctionTableWithDescriptor:missFunctionTableDescriptor]; + functions.closestHit = + [rayGen.pipeline newVisibleFunctionTableWithDescriptor:closestHitFunctionTableDescriptor]; + functions.anyHit = + [rayGen.pipeline newIntersectionFunctionTableWithDescriptor:anyHitFunctionTableDescriptor]; + + auto SetFunction = [&]( auto& table, const id& function, int index ) { + auto handle = [rayGen.pipeline functionHandleWithFunction:function]; + if( !handle ) + { + return E_INVALIDARG; + } + [table setFunction:handle atIndex:index]; + return S_OK; + }; + + // Map each piece of scene hit group to its intersection function. + int groupIndex = 0; + for( auto& hitGroup : desc.m_hitGroupNames ) + { + auto found = hitGroupMap.find( hitGroup.name ); + if( found == end( hitGroupMap ) ) + { + return E_FAIL; + } + if( found->second.intersection ) + { + return E_FAIL; + } + if( found->second.anyHit ) + { + CR_RETURN_HR( SetFunction( functions.anyHit, found->second.anyHit, groupIndex ) ); + } + else + { + auto signature = MTLIntersectionFunctionSignatureInstancing | + MTLIntersectionFunctionSignatureTriangleData | MTLIntersectionFunctionSignatureWorldSpaceData; + [functions.anyHit setOpaqueTriangleIntersectionFunctionWithSignature:signature atIndex:groupIndex]; + } + if( found->second.closestHit ) + { + CR_RETURN_HR( SetFunction( functions.closestHit, found->second.closestHit, groupIndex ) ); + } + if( functionTables.empty() ) + { + FillMaterial( hitBuffers, hitGroup.material ); + } + ++groupIndex; + } + if( functionTables.empty() ) + { + m_missMaterialOffset = hitBuffers.size() * sizeof( uint64_t ); + } + int missIndex = 0; + for( auto& names : desc.m_missNames ) + { + auto found = intersectionFunctions.find( names.name ); + if( found == end( intersectionFunctions ) ) + { + return E_FAIL; + } + CR_RETURN_HR( !SetFunction( functions.miss, found->second, missIndex ) ); + if( functionTables.empty() ) + { + FillMaterial( hitBuffers, names.material ); + } + missIndex++; + } + functionTables.push_back( functions ); + } + + m_functionTables = std::move( functionTables ); + + m_rayGenMaterialOffset = hitBuffers.size() * sizeof( uint64_t ); + for( auto& name : desc.m_rayGenNames ) + { + FillMaterial( hitBuffers, name.material ); + } + + id device = renderContext.GetMetalContext()->GetDevice(); + if( !hitBuffers.empty() ) + { + m_materialBuffer = [device newBufferWithBytes:hitBuffers.data() + length:hitBuffers.size() * sizeof( uint64_t ) + options:MTLResourceStorageModeManaged]; + for( auto& tables : m_functionTables ) + { + [tables.anyHit setBuffer:m_materialBuffer offset:0 atIndex:0]; + } + } + + return S_OK; + } + else + { + return E_FAIL; + } +} + +void Tr2RtShaderTableAL::Destroy() +{ + if( @available( macOS 11.0, * ) ) + { + m_functionTables.clear(); + } + m_materialBuffer = nullptr; +} + +bool Tr2RtShaderTableAL::IsValid() const +{ + if( @available( macOS 11.0, * ) ) + { + return !m_functionTables.empty(); + } + return false; +} + +API_AVAILABLE( macos( 13.0 ) ) +Tr2RtShaderTableAL::ShaderTableData Tr2RtShaderTableAL::GetShaderTableData( uint32_t rayGenIndex, + uint64_t globalInputAddress ) const +{ + auto& tables = m_functionTables[rayGenIndex]; + return ShaderTableData{ tables.anyHit.gpuResourceID, + tables.miss.gpuResourceID, + tables.closestHit.gpuResourceID, + + m_materialBuffer.gpuAddress + m_missMaterialOffset, + m_materialBuffer.gpuAddress, + globalInputAddress }; +} + +API_AVAILABLE( macos( 13.0 ) ) +void Tr2RtShaderTableAL::AddUsedResources( uint32_t rayGenIndex, std::vector>& readResources ) const +{ + auto& tables = m_functionTables[rayGenIndex]; + readResources.push_back( tables.anyHit ); + readResources.push_back( tables.miss ); + readResources.push_back( tables.closestHit ); + readResources.push_back( m_materialBuffer ); +} + +void Tr2RtShaderTableAL::SetGlobalInputBuffer( uint32_t rayGenIndex, + const id& buffer, + uint32_t offset ) const +{ + if( @available( macOS 11.0, * ) ) + { + [m_functionTables[rayGenIndex].anyHit setBuffer:buffer offset:offset atIndex:1]; + } +} + + +id Tr2RtShaderTableAL::GetMaterialBuffer() const +{ + return m_materialBuffer; +} + +NSUInteger Tr2RtShaderTableAL::GetRayGenMaterialOffset( uint32_t rayGenIndex ) const +{ + const int BUFFERS_PER_SHADER = sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants ) / + sizeof( Tr2RtLocalMaterialDescriptionAL::m_constants[0] ); + return m_rayGenMaterialOffset + sizeof( uint64_t ) * BUFFERS_PER_SHADER * rayGenIndex; +} + +Tr2ALMemoryType Tr2RtShaderTableAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2RtShaderTableAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtShaderTableAL"; +} } diff --git a/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.h b/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.h index 44a91ce5a..dcc3ae3cc 100644 --- a/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.h +++ b/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.h @@ -20,41 +20,51 @@ namespace TrinityALImpl { class Tr2RtTopLevelAccelerationStructureAL : public Tr2DeviceResourceAL - { - public: - Tr2RtTopLevelAccelerationStructureAL(); - ~Tr2RtTopLevelAccelerationStructureAL(); - - ALResult Create( const size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ); - ALResult Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ); - - bool IsValid() const; - - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - - const ::Tr2BufferAL& GetBuffer() const; - size_t GetCapacity() const; - NSMutableArray *GetPrimitiveAccelerationStructures(){ return m_primitiveAccelerationStructures; } - - API_AVAILABLE(macos(11.0)) - id GetInstanceAccelerationStructure(){ return m_instanceAccelerationStructure; } - - private: - id m_instanceBuffer; - - ::Tr2BufferAL m_buffer; - - NSMutableArray* m_primitiveAccelerationStructures; - - API_AVAILABLE(macos(11.0)) - id m_instanceAccelerationStructure; - - API_AVAILABLE(macos(11.0)) - id BuildAccelerationStructure(MTLAccelerationStructureDescriptor* descriptor, id device, MetalContext* metalContext ); - - }; +{ +public: + Tr2RtTopLevelAccelerationStructureAL(); + ~Tr2RtTopLevelAccelerationStructureAL(); + + ALResult Create( const size_t count, + const Tr2RtInstanceAL* instances, + Tr2RtBuildFlags::Type buildFlags, + Tr2PrimaryRenderContextAL& renderContext ); + ALResult Update( const size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ); + + bool IsValid() const; + + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + + const ::Tr2BufferAL& GetBuffer() const; + size_t GetCapacity() const; + NSMutableArray* GetPrimitiveAccelerationStructures() + { + return m_primitiveAccelerationStructures; + } + + API_AVAILABLE( macos( 11.0 ) ) + id GetInstanceAccelerationStructure() + { + return m_instanceAccelerationStructure; + } + +private: + id m_instanceBuffer; + + ::Tr2BufferAL m_buffer; + + NSMutableArray* m_primitiveAccelerationStructures; + + API_AVAILABLE( macos( 11.0 ) ) + id m_instanceAccelerationStructure; + + API_AVAILABLE( macos( 11.0 ) ) + id BuildAccelerationStructure( MTLAccelerationStructureDescriptor* descriptor, + id device, + MetalContext* metalContext ); +}; } #endif diff --git a/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.mm b/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.mm index 47f4f75c7..f28fcfbe5 100644 --- a/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.mm +++ b/trinityal/metal/Tr2RtTopLevelAccelerationStructureALMetal.mm @@ -17,184 +17,200 @@ namespace TrinityALImpl { - + Tr2RtTopLevelAccelerationStructureAL::Tr2RtTopLevelAccelerationStructureAL() - { - } - - - Tr2RtTopLevelAccelerationStructureAL::~Tr2RtTopLevelAccelerationStructureAL() - { - } - - // NOTE: this has no compaction - id Tr2RtTopLevelAccelerationStructureAL::BuildAccelerationStructure(MTLAccelerationStructureDescriptor* descriptor, id device, MetalContext* metalContext) - { - // Query for the sizes needed to store and build the acceleration structure. - MTLAccelerationStructureSizes accelSizes = [device accelerationStructureSizesWithDescriptor:descriptor]; - - // Allocate an acceleration structure large enough for this descriptor. This method - // doesn't actually build the acceleration structure, but rather allocates memory. - id accelerationStructure = [device newAccelerationStructureWithSize:accelSizes.accelerationStructureSize]; - - // Allocate scratch space Metal uses to build the acceleration structure. - // Use MTLResourceStorageModePrivate for the best performance because the sample - // doesn't need access to buffer's contents. - id scratchBuffer = [device newBufferWithLength:accelSizes.buildScratchBufferSize options:MTLResourceStorageModeShared]; - - auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); - [commandEncoder buildAccelerationStructure:accelerationStructure - descriptor:descriptor - scratchBuffer:scratchBuffer - scratchBufferOffset:0]; - metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); - return accelerationStructure; - } - - ALResult Tr2RtTopLevelAccelerationStructureAL::Create( size_t count, const Tr2RtInstanceAL* instances, Tr2RtBuildFlags::Type buildFlags, Tr2PrimaryRenderContextAL& renderContext ) - { - if (@available(macOS 11.0, *)) { - if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) - { - return E_INVALIDCALL; - } - if( count == 0 ) - { - return E_INVALIDARG; - } - - m_primitiveAccelerationStructures = [[NSMutableArray alloc] init]; - - MetalContext *metalContext = renderContext.GetMetalContext(); - id device = metalContext->GetDevice(); - - // Allocate a buffer of acceleration structure instance descriptors. Each descriptor represents - // an instance of one of the primitive acceleration structures created above, with its own - // transformation matrix. - - // maybe the option should be MTLResourceStorageModePrivate - m_instanceBuffer = [device newBufferWithLength:sizeof(MTLAccelerationStructureInstanceDescriptor) * count options:MTLResourceStorageModeShared]; - - MTLAccelerationStructureInstanceDescriptor *instanceDescriptors = (MTLAccelerationStructureInstanceDescriptor *)m_instanceBuffer.contents; - - std::vector offsets; - offsets.reserve( 2 + count ); - offsets.push_back( 0 ); - offsets.push_back( 0 ); - - // Fill out instance descriptors. - for( NSUInteger instanceIndex = 0; instanceIndex < count; ++instanceIndex ) { - - if( !instances[instanceIndex].blas->IsValid()) - { - return E_INVALIDARG; - } - - // TODO: FIX THIS - // it's supposed to map the instance to its acceleration structure. - instanceDescriptors[instanceIndex].accelerationStructureIndex = (uint32_t)instanceIndex; - - // Mark the instance as opaque so that the - // ray intersector doesn't attempt to execute a function that doesn't exist. - instanceDescriptors[instanceIndex].options = 0;//MTLAccelerationStructureInstanceOptionOpaque; - - // Metal adds the geometry intersection function table offset and instance intersection - // function table offset together to determine which intersection function to execute. - - // Metal adds the geometry intersection function table offset and instance intersection - // function table offset together to determine which intersection function to execute. - instanceDescriptors[instanceIndex].intersectionFunctionTableOffset = instances[instanceIndex].materialIndex; - - // Set the instance mask, which the sample uses to filter out intersections between rays - // and geometry. For example, it uses masks to prevent light sources from being visible - // to secondary rays, which would result in their contribution being double-counted. - instanceDescriptors[instanceIndex].mask = 3; - - // Copy the first three rows of the instance transformation matrix. Metal - // assumes that the bottom row is (0, 0, 0, 1), which allows the renderer to - // tightly pack instance descriptors in memory. - for(int column = 0; column < 4; column++) - for(int row = 0; row < 3; row++) - instanceDescriptors[instanceIndex].transformationMatrix.columns[column][row] = instances[instanceIndex].transform[row][column]; - - id blas = instances[instanceIndex].blas->m_primitiveAccelerationStructure; - - if( blas != nil ) - { - //gather all the BLAS in one list - [m_primitiveAccelerationStructures addObject:blas]; - offsets.push_back( instances[instanceIndex].materialIndex ); - } - } - - // Create an instance acceleration structure descriptor - MTLInstanceAccelerationStructureDescriptor *accelDescriptor = [MTLInstanceAccelerationStructureDescriptor descriptor]; - - accelDescriptor.instancedAccelerationStructures = m_primitiveAccelerationStructures; - accelDescriptor.instanceCount = count; - accelDescriptor.instanceDescriptorBuffer = m_instanceBuffer; - - // Create the instance acceleration structure that contains all instances in the scene. - m_instanceAccelerationStructure = BuildAccelerationStructure( accelDescriptor, device, metalContext ); - - // add vector of contents - // gpu usage is probs srv and cpu none - if (@available(macOS 13.0, *)) { - Tr2BufferDescriptionAL bufferDesc = Tr2BufferDescriptionAL(1, uint32_t( offsets.size() * sizeof( uint32_t ) ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE); - - auto gpuID = m_instanceAccelerationStructure.gpuResourceID; - - memcpy( offsets.data(), &gpuID, sizeof( gpuID ) ); - - m_buffer.Create(bufferDesc, offsets.data(), renderContext); - m_buffer.SetName("TLASBuffer"); - } - - return S_OK; - } - else - { - return E_FAIL; - } - - } - - ALResult Tr2RtTopLevelAccelerationStructureAL::Update( size_t count, const Tr2RtInstanceAL* instances, Tr2RenderContextAL& renderContext ) - { - return E_FAIL; - } - - bool Tr2RtTopLevelAccelerationStructureAL::IsValid() const - { - return m_instanceBuffer != nullptr; - } - - const ::Tr2BufferAL& Tr2RtTopLevelAccelerationStructureAL::GetBuffer() const - { - return m_buffer; - //return nullptr; - } - - size_t Tr2RtTopLevelAccelerationStructureAL::GetCapacity() const - { - return 0; - } - - Tr2ALMemoryType Tr2RtTopLevelAccelerationStructureAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - void Tr2RtTopLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2RtTopLevelAccelerationStructureAL"; - } - - void Tr2RtTopLevelAccelerationStructureAL::Destroy() - { - - } +{ +} + + +Tr2RtTopLevelAccelerationStructureAL::~Tr2RtTopLevelAccelerationStructureAL() +{ +} + +// NOTE: this has no compaction +id + Tr2RtTopLevelAccelerationStructureAL::BuildAccelerationStructure( MTLAccelerationStructureDescriptor* descriptor, + id device, + MetalContext* metalContext ) +{ + // Query for the sizes needed to store and build the acceleration structure. + MTLAccelerationStructureSizes accelSizes = [device accelerationStructureSizesWithDescriptor:descriptor]; + + // Allocate an acceleration structure large enough for this descriptor. This method + // doesn't actually build the acceleration structure, but rather allocates memory. + id accelerationStructure = + [device newAccelerationStructureWithSize:accelSizes.accelerationStructureSize]; + + // Allocate scratch space Metal uses to build the acceleration structure. + // Use MTLResourceStorageModePrivate for the best performance because the sample + // doesn't need access to buffer's contents. + id scratchBuffer = [device newBufferWithLength:accelSizes.buildScratchBufferSize + options:MTLResourceStorageModeShared]; + + auto commandEncoder = metalContext->GetPrimaryWorkQueue()->GetAccelerationStructureEncoder(); + [commandEncoder buildAccelerationStructure:accelerationStructure + descriptor:descriptor + scratchBuffer:scratchBuffer + scratchBufferOffset:0]; + metalContext->GetPrimaryWorkQueue()->ReleaseEncoder( false ); + return accelerationStructure; +} + +ALResult Tr2RtTopLevelAccelerationStructureAL::Create( size_t count, + const Tr2RtInstanceAL* instances, + Tr2RtBuildFlags::Type buildFlags, + Tr2PrimaryRenderContextAL& renderContext ) +{ + if( @available( macOS 11.0, * ) ) + { + if( !renderContext.IsValid() || !renderContext.GetCaps().SupportsRaytracing() ) + { + return E_INVALIDCALL; + } + if( count == 0 ) + { + return E_INVALIDARG; + } + + m_primitiveAccelerationStructures = [[NSMutableArray alloc] init]; + + MetalContext* metalContext = renderContext.GetMetalContext(); + id device = metalContext->GetDevice(); + + // Allocate a buffer of acceleration structure instance descriptors. Each descriptor represents + // an instance of one of the primitive acceleration structures created above, with its own + // transformation matrix. + + // maybe the option should be MTLResourceStorageModePrivate + m_instanceBuffer = [device newBufferWithLength:sizeof( MTLAccelerationStructureInstanceDescriptor ) * count + options:MTLResourceStorageModeShared]; + + MTLAccelerationStructureInstanceDescriptor* instanceDescriptors = + (MTLAccelerationStructureInstanceDescriptor*)m_instanceBuffer.contents; + + std::vector offsets; + offsets.reserve( 2 + count ); + offsets.push_back( 0 ); + offsets.push_back( 0 ); + + // Fill out instance descriptors. + for( NSUInteger instanceIndex = 0; instanceIndex < count; ++instanceIndex ) + { + + if( !instances[instanceIndex].blas->IsValid() ) + { + return E_INVALIDARG; + } + + // TODO: FIX THIS + // it's supposed to map the instance to its acceleration structure. + instanceDescriptors[instanceIndex].accelerationStructureIndex = (uint32_t)instanceIndex; + + // Mark the instance as opaque so that the + // ray intersector doesn't attempt to execute a function that doesn't exist. + instanceDescriptors[instanceIndex].options = 0; //MTLAccelerationStructureInstanceOptionOpaque; + + // Metal adds the geometry intersection function table offset and instance intersection + // function table offset together to determine which intersection function to execute. + + // Metal adds the geometry intersection function table offset and instance intersection + // function table offset together to determine which intersection function to execute. + instanceDescriptors[instanceIndex].intersectionFunctionTableOffset = instances[instanceIndex].materialIndex; + + // Set the instance mask, which the sample uses to filter out intersections between rays + // and geometry. For example, it uses masks to prevent light sources from being visible + // to secondary rays, which would result in their contribution being double-counted. + instanceDescriptors[instanceIndex].mask = 3; + + // Copy the first three rows of the instance transformation matrix. Metal + // assumes that the bottom row is (0, 0, 0, 1), which allows the renderer to + // tightly pack instance descriptors in memory. + for( int column = 0; column < 4; column++ ) + for( int row = 0; row < 3; row++ ) + instanceDescriptors[instanceIndex].transformationMatrix.columns[column][row] = + instances[instanceIndex].transform[row][column]; + + id blas = instances[instanceIndex].blas->m_primitiveAccelerationStructure; + + if( blas != nil ) + { + //gather all the BLAS in one list + [m_primitiveAccelerationStructures addObject:blas]; + offsets.push_back( instances[instanceIndex].materialIndex ); + } + } + + // Create an instance acceleration structure descriptor + MTLInstanceAccelerationStructureDescriptor* accelDescriptor = + [MTLInstanceAccelerationStructureDescriptor descriptor]; + + accelDescriptor.instancedAccelerationStructures = m_primitiveAccelerationStructures; + accelDescriptor.instanceCount = count; + accelDescriptor.instanceDescriptorBuffer = m_instanceBuffer; + + // Create the instance acceleration structure that contains all instances in the scene. + m_instanceAccelerationStructure = BuildAccelerationStructure( accelDescriptor, device, metalContext ); + + // add vector of contents + // gpu usage is probs srv and cpu none + if( @available( macOS 13.0, * ) ) + { + Tr2BufferDescriptionAL bufferDesc = Tr2BufferDescriptionAL( + 1, uint32_t( offsets.size() * sizeof( uint32_t ) ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE ); + + auto gpuID = m_instanceAccelerationStructure.gpuResourceID; + + memcpy( offsets.data(), &gpuID, sizeof( gpuID ) ); + + m_buffer.Create( bufferDesc, offsets.data(), renderContext ); + m_buffer.SetName( "TLASBuffer" ); + } + + return S_OK; + } + else + { + return E_FAIL; + } +} + +ALResult Tr2RtTopLevelAccelerationStructureAL::Update( size_t count, + const Tr2RtInstanceAL* instances, + Tr2RenderContextAL& renderContext ) +{ + return E_FAIL; +} + +bool Tr2RtTopLevelAccelerationStructureAL::IsValid() const +{ + return m_instanceBuffer != nullptr; +} + +const ::Tr2BufferAL& Tr2RtTopLevelAccelerationStructureAL::GetBuffer() const +{ + return m_buffer; + //return nullptr; +} + +size_t Tr2RtTopLevelAccelerationStructureAL::GetCapacity() const +{ + return 0; +} + +Tr2ALMemoryType Tr2RtTopLevelAccelerationStructureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2RtTopLevelAccelerationStructureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2RtTopLevelAccelerationStructureAL"; +} + +void Tr2RtTopLevelAccelerationStructureAL::Destroy() +{ +} } #endif diff --git a/trinityal/metal/Tr2SamplerStateALMetal.h b/trinityal/metal/Tr2SamplerStateALMetal.h index a0b3a2c4d..4972d5650 100644 --- a/trinityal/metal/Tr2SamplerStateALMetal.h +++ b/trinityal/metal/Tr2SamplerStateALMetal.h @@ -2,38 +2,44 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2SamplerStateAL.h" #include "MetalContext.h" namespace TrinityALImpl { - class Tr2SamplerStateAL : public Tr2DeviceResourceAL - { - public: - Tr2SamplerStateAL(); - - ALResult Create( const Tr2SamplerDescription& description, Tr2RenderContextAL& renderContext ); - void Destroy(); +class Tr2SamplerStateAL : public Tr2DeviceResourceAL +{ +public: + Tr2SamplerStateAL(); - uint32_t GetIndexInHeap() const; + ALResult Create( const Tr2SamplerDescription& description, Tr2RenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + uint32_t GetIndexInHeap() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } + bool IsValid() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } - id GetMetalSamplerState() { return m_mtlSamplerState; }; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - MetalContext* m_metalContext; - id m_mtlSamplerState; - uint32_t m_heapIndex; - std::string m_name; + id GetMetalSamplerState() + { + return m_mtlSamplerState; }; + +private: + MetalContext* m_metalContext; + id m_mtlSamplerState; + uint32_t m_heapIndex; + std::string m_name; +}; } #endif diff --git a/trinityal/metal/Tr2SamplerStateALMetal.mm b/trinityal/metal/Tr2SamplerStateALMetal.mm index 5381bd150..7fb6bd787 100644 --- a/trinityal/metal/Tr2SamplerStateALMetal.mm +++ b/trinityal/metal/Tr2SamplerStateALMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2SamplerStateALMetal.h" #include "Tr2RenderContextMetal.h" @@ -13,260 +13,263 @@ namespace { - bool MapMinMagFilter( const Tr2RenderContextEnum::TextureFilter filter, MTLSamplerMinMagFilter& result ) +bool MapMinMagFilter( const Tr2RenderContextEnum::TextureFilter filter, MTLSamplerMinMagFilter& result ) +{ + using namespace Tr2RenderContextEnum; + + switch( filter ) { - using namespace Tr2RenderContextEnum; + case TF_POINT: + result = MTLSamplerMinMagFilterNearest; + break; + case TF_LINEAR: + case TF_ANISOTROPIC: + result = MTLSamplerMinMagFilterLinear; + break; + default: + CCP_AL_LOGERR( "Cannot map sampler min-mag filter (%d) to Metal enum.", filter ); + return false; + } + // TODO: TF_COMPARISON is unused? - switch( filter ) - { - case TF_POINT: - result = MTLSamplerMinMagFilterNearest; - break; - case TF_LINEAR: - case TF_ANISOTROPIC: - result = MTLSamplerMinMagFilterLinear; - break; - default: - CCP_AL_LOGERR( "Cannot map sampler min-mag filter (%d) to Metal enum.", filter ); - return false; - } - // TODO: TF_COMPARISON is unused? + return true; +} - return true; - } +bool MapMipFilter( const Tr2RenderContextEnum::TextureFilter filter, MTLSamplerMipFilter& result ) +{ + using namespace Tr2RenderContextEnum; - bool MapMipFilter( const Tr2RenderContextEnum::TextureFilter filter, MTLSamplerMipFilter& result ) + switch( filter ) { - using namespace Tr2RenderContextEnum; + case TF_NONE: + result = MTLSamplerMipFilterNotMipmapped; + break; + case TF_POINT: + result = MTLSamplerMipFilterNearest; + break; + case TF_LINEAR: + case TF_ANISOTROPIC: + result = MTLSamplerMipFilterLinear; + break; + default: + CCP_AL_LOGERR( "Cannot map sampler mip filter (%d) to Metal enum.", filter ); + return false; + } - switch( filter ) - { - case TF_NONE: - result = MTLSamplerMipFilterNotMipmapped; - break; - case TF_POINT: - result = MTLSamplerMipFilterNearest; - break; - case TF_LINEAR: - case TF_ANISOTROPIC: - result = MTLSamplerMipFilterLinear; - break; - default: - CCP_AL_LOGERR( "Cannot map sampler mip filter (%d) to Metal enum.", filter ); - return false; - } + return true; +} - return true; - } +bool MapAddressMode( const Tr2RenderContextEnum::TextureAddressMode mode, MTLSamplerAddressMode& result ) +{ + using namespace Tr2RenderContextEnum; - bool MapAddressMode( const Tr2RenderContextEnum::TextureAddressMode mode, MTLSamplerAddressMode& result ) + switch( mode ) { - using namespace Tr2RenderContextEnum; + case TA_WRAP: + result = MTLSamplerAddressModeRepeat; + break; + case TA_MIRROR: + result = MTLSamplerAddressModeMirrorRepeat; + break; + case TA_CLAMP: + result = MTLSamplerAddressModeClampToEdge; + break; + case TA_BORDER: + result = MTLSamplerAddressModeClampToBorderColor; + break; + case TA_MIRROR_ONCE: + result = MTLSamplerAddressModeMirrorClampToEdge; + break; + default: + CCP_AL_LOGERR( "Cannot map sampler address mode (%d) to Metal enum.", mode ); + return false; + } - switch( mode ) - { - case TA_WRAP: - result = MTLSamplerAddressModeRepeat; - break; - case TA_MIRROR: - result = MTLSamplerAddressModeMirrorRepeat; - break; - case TA_CLAMP: - result = MTLSamplerAddressModeClampToEdge; - break; - case TA_BORDER: - result = MTLSamplerAddressModeClampToBorderColor; - break; - case TA_MIRROR_ONCE: - result = MTLSamplerAddressModeMirrorClampToEdge; - break; - default: - CCP_AL_LOGERR( "Cannot map sampler address mode (%d) to Metal enum.", mode ); - return false; - } + return true; +} +bool MapCompareFunction( const Tr2RenderContextEnum::CompareFunc func, MTLCompareFunction& result ) +{ + using namespace Tr2RenderContextEnum; + + // Default value set by ShaderCompiler, basically it means the function + // wasn't initialized in the shader. So we pick a sensible default mapping. + // Can't put this in the switch statement as it causes compile errors in Xcode as 0 is not a valid enum. + if( func == 0 ) + { + result = MTLCompareFunctionAlways; return true; } - bool MapCompareFunction( const Tr2RenderContextEnum::CompareFunc func, MTLCompareFunction& result ) + switch( func ) { - using namespace Tr2RenderContextEnum; - - // Default value set by ShaderCompiler, basically it means the function - // wasn't initialized in the shader. So we pick a sensible default mapping. - // Can't put this in the switch statement as it causes compile errors in Xcode as 0 is not a valid enum. - if (func == 0) { - result = MTLCompareFunctionAlways; - return true; - } - - switch( func ) - { - case CMP_NEVER: - result = MTLCompareFunctionNever; - break; - case CMP_LESS: - result = MTLCompareFunctionLess; - break; - case CMP_EQUAL: - result = MTLCompareFunctionEqual; - break; - case CMP_LESSEQUAL: - result = MTLCompareFunctionLessEqual; - break; - case CMP_GREATER: - result = MTLCompareFunctionGreater; - break; - case CMP_NOTEQUAL: - result = MTLCompareFunctionNotEqual; - break; - case CMP_GREATEREQUAL: - result = MTLCompareFunctionGreaterEqual; - break; - case CMP_ALWAYS: - result = MTLCompareFunctionAlways; - break; - default: - CCP_AL_LOGERR( "Cannot map sampler compare function (%d) to Metal enum.", func ); - return false; - } - - return true; + case CMP_NEVER: + result = MTLCompareFunctionNever; + break; + case CMP_LESS: + result = MTLCompareFunctionLess; + break; + case CMP_EQUAL: + result = MTLCompareFunctionEqual; + break; + case CMP_LESSEQUAL: + result = MTLCompareFunctionLessEqual; + break; + case CMP_GREATER: + result = MTLCompareFunctionGreater; + break; + case CMP_NOTEQUAL: + result = MTLCompareFunctionNotEqual; + break; + case CMP_GREATEREQUAL: + result = MTLCompareFunctionGreaterEqual; + break; + case CMP_ALWAYS: + result = MTLCompareFunctionAlways; + break; + default: + CCP_AL_LOGERR( "Cannot map sampler compare function (%d) to Metal enum.", func ); + return false; } - bool MapBorderColor( const float borderColor[4], MTLSamplerBorderColor result ) + return true; +} + +bool MapBorderColor( const float borderColor[4], MTLSamplerBorderColor result ) +{ + if( borderColor[0] == 0.f && borderColor[1] == 0.f && borderColor[2] == 0.f ) { - if( borderColor[0] == 0.f && borderColor[1] == 0.f && borderColor[2] == 0.f ) + if( borderColor[3] == 0.f ) { - if( borderColor[3] == 0.f ) - { - result = MTLSamplerBorderColorTransparentBlack; - return true; - } - else if( borderColor[3] == 1.f ) - { - result = MTLSamplerBorderColorOpaqueBlack; - return true; - } + result = MTLSamplerBorderColorTransparentBlack; + return true; } - else if( borderColor[0] == 1.f && borderColor[1] == 1.f && borderColor[2] == 1.f && borderColor[3] == 1.f ) + else if( borderColor[3] == 1.f ) { - result = MTLSamplerBorderColorOpaqueWhite; + result = MTLSamplerBorderColorOpaqueBlack; return true; } - - CCP_AL_LOGERR( "Cannot map sampler border color (%.f, %.f, %.f, %.f) to Metal enum.", borderColor[0], borderColor[1], borderColor[2], borderColor[3] ); - return false; } + else if( borderColor[0] == 1.f && borderColor[1] == 1.f && borderColor[2] == 1.f && borderColor[3] == 1.f ) + { + result = MTLSamplerBorderColorOpaqueWhite; + return true; + } + + CCP_AL_LOGERR( "Cannot map sampler border color (%.f, %.f, %.f, %.f) to Metal enum.", + borderColor[0], + borderColor[1], + borderColor[2], + borderColor[3] ); + return false; +} } namespace TrinityALImpl { - Tr2SamplerStateAL::Tr2SamplerStateAL() - : m_metalContext( nullptr ) - , m_mtlSamplerState( nullptr ) - , m_heapIndex( 0xffffffff ) - { - } +Tr2SamplerStateAL::Tr2SamplerStateAL() : + m_metalContext( nullptr ), m_mtlSamplerState( nullptr ), m_heapIndex( 0xffffffff ) +{ +} - ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& desc, Tr2RenderContextAL& renderContext ) - { - Destroy(); +ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& desc, Tr2RenderContextAL& renderContext ) +{ + Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + if( !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } - bool success = true; + bool success = true; - MTLSamplerAddressMode rAddressMode = MTLSamplerAddressModeClampToEdge; - MTLSamplerAddressMode sAddressMode = MTLSamplerAddressModeClampToEdge; - MTLSamplerAddressMode tAddressMode = MTLSamplerAddressModeClampToEdge; - MTLSamplerBorderColor borderColor = MTLSamplerBorderColorTransparentBlack; - MTLSamplerMinMagFilter minFilter = MTLSamplerMinMagFilterNearest; - MTLSamplerMinMagFilter magFilter = MTLSamplerMinMagFilterNearest; - MTLSamplerMipFilter mipFilter = MTLSamplerMipFilterNotMipmapped; - MTLCompareFunction compareFunction = MTLCompareFunctionNever; + MTLSamplerAddressMode rAddressMode = MTLSamplerAddressModeClampToEdge; + MTLSamplerAddressMode sAddressMode = MTLSamplerAddressModeClampToEdge; + MTLSamplerAddressMode tAddressMode = MTLSamplerAddressModeClampToEdge; + MTLSamplerBorderColor borderColor = MTLSamplerBorderColorTransparentBlack; + MTLSamplerMinMagFilter minFilter = MTLSamplerMinMagFilterNearest; + MTLSamplerMinMagFilter magFilter = MTLSamplerMinMagFilterNearest; + MTLSamplerMipFilter mipFilter = MTLSamplerMipFilterNotMipmapped; + MTLCompareFunction compareFunction = MTLCompareFunctionNever; - success = success && MapAddressMode( desc.m_addressU, sAddressMode ); - success = success && MapAddressMode( desc.m_addressV, tAddressMode ); - success = success && MapAddressMode( desc.m_addressW, rAddressMode ); - // Border color value is used only when any of the address modes is - // MTLSamplerAddressModeClampToBorderColor. In all other cases we can - // choose a default value for border color and assume a successful remapping. - success = success && MapBorderColor( desc.m_borderColor, borderColor ); + success = success && MapAddressMode( desc.m_addressU, sAddressMode ); + success = success && MapAddressMode( desc.m_addressV, tAddressMode ); + success = success && MapAddressMode( desc.m_addressW, rAddressMode ); + // Border color value is used only when any of the address modes is + // MTLSamplerAddressModeClampToBorderColor. In all other cases we can + // choose a default value for border color and assume a successful remapping. + success = success && MapBorderColor( desc.m_borderColor, borderColor ); - success = success && MapMinMagFilter( desc.m_minFilter, minFilter ); - success = success && MapMinMagFilter( desc.m_magFilter, magFilter ); - success = success && MapMipFilter( desc.m_mipFilter , mipFilter ); + success = success && MapMinMagFilter( desc.m_minFilter, minFilter ); + success = success && MapMinMagFilter( desc.m_magFilter, magFilter ); + success = success && MapMipFilter( desc.m_mipFilter, mipFilter ); - success = success && MapCompareFunction( desc.m_comparisonFunc, compareFunction ); + success = success && MapCompareFunction( desc.m_comparisonFunc, compareFunction ); - if( !success ) - { - return E_INVALIDARG; - } + if( !success ) + { + return E_INVALIDARG; + } - m_metalContext = renderContext.GetMetalContext(); - MTLSamplerDescriptor* metalSamplerDescriptor = m_metalContext->CreateSamplerDescriptor(); + m_metalContext = renderContext.GetMetalContext(); + MTLSamplerDescriptor* metalSamplerDescriptor = m_metalContext->CreateSamplerDescriptor(); - metalSamplerDescriptor.rAddressMode = rAddressMode; - metalSamplerDescriptor.sAddressMode = sAddressMode; - metalSamplerDescriptor.tAddressMode = tAddressMode; - metalSamplerDescriptor.borderColor = borderColor; + metalSamplerDescriptor.rAddressMode = rAddressMode; + metalSamplerDescriptor.sAddressMode = sAddressMode; + metalSamplerDescriptor.tAddressMode = tAddressMode; + metalSamplerDescriptor.borderColor = borderColor; - metalSamplerDescriptor.minFilter = minFilter; - metalSamplerDescriptor.magFilter = magFilter; - metalSamplerDescriptor.mipFilter = mipFilter; + metalSamplerDescriptor.minFilter = minFilter; + metalSamplerDescriptor.magFilter = magFilter; + metalSamplerDescriptor.mipFilter = mipFilter; - metalSamplerDescriptor.lodMinClamp = desc.m_minLOD; - metalSamplerDescriptor.lodMaxClamp = desc.m_maxLOD; - // metalSamplerDescriptor.lodAverage = NO; // iOS only - metalSamplerDescriptor.maxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : desc.m_maxAnisotropy; - // desc.m_mipLODBias + metalSamplerDescriptor.lodMinClamp = desc.m_minLOD; + metalSamplerDescriptor.lodMaxClamp = desc.m_maxLOD; + // metalSamplerDescriptor.lodAverage = NO; // iOS only + metalSamplerDescriptor.maxAnisotropy = g_forceAnisotropy ? g_forceAnisotropy : desc.m_maxAnisotropy; + // desc.m_mipLODBias - metalSamplerDescriptor.compareFunction = compareFunction; - // desc.m_isComparisonFilter + metalSamplerDescriptor.compareFunction = compareFunction; + // desc.m_isComparisonFilter - metalSamplerDescriptor.supportArgumentBuffers = YES; + metalSamplerDescriptor.supportArgumentBuffers = YES; - m_mtlSamplerState = m_metalContext->CreateSamplerState( metalSamplerDescriptor ); - m_metalContext->DestroySamplerDescriptor( metalSamplerDescriptor ); - m_heapIndex = m_metalContext->AllocateHeapIndex( m_mtlSamplerState ); + m_mtlSamplerState = m_metalContext->CreateSamplerState( metalSamplerDescriptor ); + m_metalContext->DestroySamplerDescriptor( metalSamplerDescriptor ); + m_heapIndex = m_metalContext->AllocateHeapIndex( m_mtlSamplerState ); - return S_OK; - } + return S_OK; +} - void Tr2SamplerStateAL::Destroy() - { - m_metalContext->DestroySamplerState( m_mtlSamplerState ); - m_mtlSamplerState = nil; - m_metalContext = nil; - m_heapIndex = 0xffffffff; - } +void Tr2SamplerStateAL::Destroy() +{ + m_metalContext->DestroySamplerState( m_mtlSamplerState ); + m_mtlSamplerState = nil; + m_metalContext = nil; + m_heapIndex = 0xffffffff; +} - uint32_t Tr2SamplerStateAL::GetIndexInHeap() const - { - return m_heapIndex; - } +uint32_t Tr2SamplerStateAL::GetIndexInHeap() const +{ + return m_heapIndex; +} - bool Tr2SamplerStateAL::IsValid() const - { - return ( m_mtlSamplerState != nil ); - } +bool Tr2SamplerStateAL::IsValid() const +{ + return ( m_mtlSamplerState != nil ); +} - void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2SamplerStateAL"; - description["name"] = m_name; - } +void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SamplerStateAL"; + description["name"] = m_name; +} - ALResult Tr2SamplerStateAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +ALResult Tr2SamplerStateAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2ShaderALMetal.h b/trinityal/metal/Tr2ShaderALMetal.h index 9982f2a89..8bf29c80b 100644 --- a/trinityal/metal/Tr2ShaderALMetal.h +++ b/trinityal/metal/Tr2ShaderALMetal.h @@ -10,50 +10,52 @@ namespace TrinityALImpl { - // ------------------------------------------------------------- - // Description: - // A low level wrapper around shaders / shader programs. - // 32bit - no support for shader blobs > 4 gig - // ------------------------------------------------------------- - class Tr2ShaderAL : public Tr2DeviceResourceAL +// ------------------------------------------------------------- +// Description: +// A low level wrapper around shaders / shader programs. +// 32bit - no support for shader blobs > 4 gig +// ------------------------------------------------------------- +class Tr2ShaderAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderAL(); + ~Tr2ShaderAL(); + + ALResult Create( Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ); + + void Destroy(); + + bool IsValid() const; + Tr2RenderContextEnum::ShaderType GetType() const; + ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; + const Tr2ShaderSignatureAL& GetSignature() const; + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2ShaderAL(); - ~Tr2ShaderAL(); - - ALResult Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ); - - void Destroy(); - - bool IsValid() const; - Tr2RenderContextEnum::ShaderType GetType() const; - ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; - const Tr2ShaderSignatureAL& GetSignature() const; - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - - void SetNullShaderType( Tr2RenderContextEnum::ShaderType type ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - NSString* m_entryPointNameOverride = nullptr; - - private: - Tr2ShaderSignatureAL m_signature; - CcpMallocBuffer m_bytecode; - Tr2RenderContextEnum::ShaderType m_type; - - // Used to quickly compare the resources declared here and those required by the shader - ShaderResourceMask m_resourceMask; - std::string m_name; - - friend class Tr2ShaderProgramAL; - }; + return AL_MEMORY_MANAGED; + } + + void SetNullShaderType( Tr2RenderContextEnum::ShaderType type ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + + NSString* m_entryPointNameOverride = nullptr; + +private: + Tr2ShaderSignatureAL m_signature; + CcpMallocBuffer m_bytecode; + Tr2RenderContextEnum::ShaderType m_type; + + // Used to quickly compare the resources declared here and those required by the shader + ShaderResourceMask m_resourceMask; + std::string m_name; + + friend class Tr2ShaderProgramAL; +}; } #endif diff --git a/trinityal/metal/Tr2ShaderALMetal.mm b/trinityal/metal/Tr2ShaderALMetal.mm index 864f836d4..88b5c9093 100644 --- a/trinityal/metal/Tr2ShaderALMetal.mm +++ b/trinityal/metal/Tr2ShaderALMetal.mm @@ -11,291 +11,267 @@ namespace TrinityALImpl { - Tr2ShaderAL::Tr2ShaderAL() - : m_type( INVALID_SHADER ) +Tr2ShaderAL::Tr2ShaderAL() : m_type( INVALID_SHADER ) +{ +} + +ALResult Tr2ShaderAL::Create( Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !signature.samplers.empty() ) { + return E_INVALIDARG; } - - ALResult Tr2ShaderAL::Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ) + m_bytecode.resize( "Tr2ShaderALMetal::m_bytecode", bytecode.size ); + if( m_bytecode.empty() ) { - if( !signature.samplers.empty() ) - { - return E_INVALIDARG; - } - m_bytecode.resize( "Tr2ShaderALMetal::m_bytecode", bytecode.size ); - if( m_bytecode.empty() ) - { - return E_OUTOFMEMORY; - } + return E_OUTOFMEMORY; + } - memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); - m_signature = signature; - m_type = type; + memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); + m_signature = signature; + m_type = type; - m_resourceMask.constantBufferMask = 0; - m_resourceMask.bufferMask = 0; - m_resourceMask.textureMask = 0; - m_resourceMask.samplerMask = 0; - // for (auto pipelineInput : signature.pipelineInputs) - // { - // int index = METAL_VERTEX_STREAM_BUFFER_OFFSET + reg.registerIndex; - // m_resourceMask.bufferMask |= 1 << pipelineInput.registerIndex; - // } - for (auto reg : signature.registers) + m_resourceMask.constantBufferMask = 0; + m_resourceMask.bufferMask = 0; + m_resourceMask.textureMask = 0; + m_resourceMask.samplerMask = 0; + // for (auto pipelineInput : signature.pipelineInputs) + // { + // int index = METAL_VERTEX_STREAM_BUFFER_OFFSET + reg.registerIndex; + // m_resourceMask.bufferMask |= 1 << pipelineInput.registerIndex; + // } + for( auto reg : signature.registers ) + { + switch( reg.registerType ) { - switch (reg.registerType) - { - case Tr2ShaderRegisterAL::CONSTANT_BUFFER: - { - int index = METAL_CONST_BUFFER_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.constantBufferMask & (1 << index) ) == 0 ); - m_resourceMask.constantBufferMask |= 1 << index; - break; - } - case Tr2ShaderRegisterAL::SAMPLER: - { - if( reg.arrayCount != 1 ) - { - // This is an array of samplers, and it's bound as an SRV buffer - m_resourceMask.bufferMask |= 1 << ( METAL_SRV_BUFFER_OFFSET + reg.registerIndex ); - } - else - { - m_resourceMask.samplerMask|= 1 << reg.registerIndex; - } - break; - } - case Tr2ShaderRegisterAL::SRV_BUFFER: - case Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER: - { - int index = METAL_SRV_BUFFER_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.bufferMask & (1 << index) ) == 0 ); - m_resourceMask.bufferMask |= 1 << index; - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE1D: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1D ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE1DARRAY: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1DArray ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE2D: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2D ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE2DARRAY: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DArray ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE2DMS: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisample ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE2DMSARRAY: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisampleArray ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURE3D: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType3D ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURECUBE: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCube ); - break; - } - case Tr2ShaderRegisterAL::SRV_TEXTURECUBEARRAY: - { - int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCubeArray ); - break; - } - case Tr2ShaderRegisterAL::UAV_BUFFER: - case Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER: - { - int index = METAL_UAV_BUFFER_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.bufferMask & (1 << index) ) == 0 ); - m_resourceMask.bufferMask |= 1 << index; - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE1D: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1D ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE1DARRAY: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1DArray ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE2D: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2D ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE2DARRAY: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DArray ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE2DMS: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisample ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE2DMSARRAY: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisampleArray ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURE3D: - { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType3D ); - break; - } - case Tr2ShaderRegisterAL::UAV_TEXTURECUBE: + case Tr2ShaderRegisterAL::CONSTANT_BUFFER: { + int index = METAL_CONST_BUFFER_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.constantBufferMask & ( 1 << index ) ) == 0 ); + m_resourceMask.constantBufferMask |= 1 << index; + break; + } + case Tr2ShaderRegisterAL::SAMPLER: { + if( reg.arrayCount != 1 ) { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCube ); - break; + // This is an array of samplers, and it's bound as an SRV buffer + m_resourceMask.bufferMask |= 1 << ( METAL_SRV_BUFFER_OFFSET + reg.registerIndex ); } - case Tr2ShaderRegisterAL::UAV_TEXTURECUBEARRAY: + else { - int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; - assert( ( m_resourceMask.textureMask & (1 << index) ) == 0 ); - m_resourceMask.textureMask |= 1 << index; - m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCubeArray ); - break; - } - default: - assert( false ); - break; + m_resourceMask.samplerMask |= 1 << reg.registerIndex; } + break; + } + case Tr2ShaderRegisterAL::SRV_BUFFER: + case Tr2ShaderRegisterAL::SRV_STRUCTURED_BUFFER: { + int index = METAL_SRV_BUFFER_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.bufferMask & ( 1 << index ) ) == 0 ); + m_resourceMask.bufferMask |= 1 << index; + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE1D: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1D ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE1DARRAY: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1DArray ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE2D: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2D ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE2DARRAY: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DArray ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE2DMS: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisample ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE2DMSARRAY: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisampleArray ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURE3D: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType3D ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURECUBE: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCube ); + break; + } + case Tr2ShaderRegisterAL::SRV_TEXTURECUBEARRAY: { + int index = METAL_SRV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCubeArray ); + break; + } + case Tr2ShaderRegisterAL::UAV_BUFFER: + case Tr2ShaderRegisterAL::UAV_STRUCTURED_BUFFER: { + int index = METAL_UAV_BUFFER_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.bufferMask & ( 1 << index ) ) == 0 ); + m_resourceMask.bufferMask |= 1 << index; + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE1D: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1D ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE1DARRAY: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType1DArray ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE2D: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2D ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE2DARRAY: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DArray ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE2DMS: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisample ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE2DMSARRAY: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType2DMultisampleArray ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURE3D: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureType3D ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURECUBE: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCube ); + break; + } + case Tr2ShaderRegisterAL::UAV_TEXTURECUBEARRAY: { + int index = METAL_UAV_TEXTURE_OFFSET + reg.registerIndex; + assert( ( m_resourceMask.textureMask & ( 1 << index ) ) == 0 ); + m_resourceMask.textureMask |= 1 << index; + m_resourceMask.textureTypes[index] = uint8_t( MTLTextureTypeCubeArray ); + break; + } + default: + assert( false ); + break; } - - return S_OK; } - Tr2ShaderAL::~Tr2ShaderAL() - { - Destroy(); - } + return S_OK; +} - void Tr2ShaderAL::Destroy() - { - m_signature = Tr2ShaderSignatureAL(); - m_bytecode.clear(); - m_type = INVALID_SHADER; - } +Tr2ShaderAL::~Tr2ShaderAL() +{ + Destroy(); +} - bool Tr2ShaderAL::IsValid() const - { - return m_type != INVALID_SHADER && !m_bytecode.empty(); - } +void Tr2ShaderAL::Destroy() +{ + m_signature = Tr2ShaderSignatureAL(); + m_bytecode.clear(); + m_type = INVALID_SHADER; +} - Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const +bool Tr2ShaderAL::IsValid() const +{ + return m_type != INVALID_SHADER && !m_bytecode.empty(); +} + +Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const +{ + return m_type; +} + +ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const +{ + if( m_bytecode.empty() ) { - return m_type; + bytecode = Tr2ShaderBytecodeAL(); + return E_INVALIDCALL; } - ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const - { - if( m_bytecode.empty() ) - { - bytecode = Tr2ShaderBytecodeAL(); - return E_INVALIDCALL; - } + bytecode.bytecode = m_bytecode.get(); - bytecode.bytecode = m_bytecode.get(); + bytecode.size = m_bytecode.size(); + return S_OK; +} - bytecode.size = m_bytecode.size(); - return S_OK; - } +const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +{ + return m_signature; +} - const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const - { - return m_signature; - } - - void Tr2ShaderAL::SetNullShaderType( Tr2RenderContextEnum::ShaderType type ) - { - m_type = type; - } +void Tr2ShaderAL::SetNullShaderType( Tr2RenderContextEnum::ShaderType type ) +{ + m_type = type; +} - void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ShaderAL"; - description["name"] = m_name; - } +void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderAL"; + description["name"] = m_name; +} - ALResult Tr2ShaderAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +ALResult Tr2ShaderAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} } #endif diff --git a/trinityal/metal/Tr2ShaderProgramALMetal.h b/trinityal/metal/Tr2ShaderProgramALMetal.h index 5c810ea26..cb01c9748 100644 --- a/trinityal/metal/Tr2ShaderProgramALMetal.h +++ b/trinityal/metal/Tr2ShaderProgramALMetal.h @@ -12,54 +12,55 @@ namespace TrinityALImpl { - class Tr2ShaderProgramAL : public Tr2DeviceResourceAL - { - public: - Tr2ShaderProgramAL(); +class Tr2ShaderProgramAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderProgramAL(); - ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; + Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - id GetVertexShader() const; - id GetFragmentShader() const; - id GetComputeKernel() const; - MTLSize GetThreadGroupSize() const; - const ShaderResourceMask* GetResourceMasks() const; + id GetVertexShader() const; + id GetFragmentShader() const; + id GetComputeKernel() const; + MTLSize GetThreadGroupSize() const; + const ShaderResourceMask* GetResourceMasks() const; - const Tr2RegisterMapAL& GetRegisterMap() const; + const Tr2RegisterMapAL& GetRegisterMap() const; - const std::vector& GetInputs() const; - size_t GetInputsHash() const; + const std::vector& GetInputs() const; + size_t GetInputsHash() const; - void SetDummyResources( TrinityALImpl::MetalWorkQueue& workQueue ); + void SetDummyResources( TrinityALImpl::MetalWorkQueue& workQueue ); - private: - id CompileShader( const ::Tr2ShaderAL& shader, NSString* entryFunction, Tr2PrimaryRenderContextAL& renderContext ); +private: + id + CompileShader( const ::Tr2ShaderAL& shader, NSString* entryFunction, Tr2PrimaryRenderContextAL& renderContext ); - id m_vertexFunction; - id m_fragmentFunction; - id m_computeFunction; - std::vector m_iaInputs; - size_t m_iaInputsHash; - ShaderResourceMask m_resourceMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; - MetalContext *m_metalContext; - Tr2RegisterMapAL m_registerMap; + id m_vertexFunction; + id m_fragmentFunction; + id m_computeFunction; + std::vector m_iaInputs; + size_t m_iaInputsHash; + ShaderResourceMask m_resourceMask[Tr2RenderContextEnum::SHADER_TYPE_COUNT]; + MetalContext* m_metalContext; + Tr2RegisterMapAL m_registerMap; - MTLSize m_threadGroupSize; - std::string m_name; + MTLSize m_threadGroupSize; + std::string m_name; - bool m_isValid; + bool m_isValid; - friend class Tr2RenderContextAL; - friend class Tr2ResourceSetAL; - }; + friend class Tr2RenderContextAL; + friend class Tr2ResourceSetAL; +}; } #endif diff --git a/trinityal/metal/Tr2ShaderProgramALMetal.mm b/trinityal/metal/Tr2ShaderProgramALMetal.mm index 1e4903a4e..f61fc9981 100644 --- a/trinityal/metal/Tr2ShaderProgramALMetal.mm +++ b/trinityal/metal/Tr2ShaderProgramALMetal.mm @@ -12,289 +12,294 @@ namespace TrinityALImpl { - Tr2ShaderProgramAL::Tr2ShaderProgramAL() : - m_isValid( false ), - m_vertexFunction (nil), - m_fragmentFunction (nil), - m_computeFunction(nil), - m_iaInputsHash( 0 ), - m_threadGroupSize( MTLSizeMake( 1, 1, 1 ) ) +Tr2ShaderProgramAL::Tr2ShaderProgramAL() : + m_isValid( false ), + m_vertexFunction( nil ), + m_fragmentFunction( nil ), + m_computeFunction( nil ), + m_iaInputsHash( 0 ), + m_threadGroupSize( MTLSizeMake( 1, 1, 1 ) ) +{ + for( uint32_t i = 0; i < Tr2RenderContextEnum::SHADER_TYPE_COUNT; i++ ) { - for (uint32_t i = 0; i < Tr2RenderContextEnum::SHADER_TYPE_COUNT; i++) - { - m_resourceMask[i].ResetMasks(); - } - m_iaInputs.clear(); + m_resourceMask[i].ResetMasks(); } + m_iaInputs.clear(); +} - // Like the DX12 implementation we'll do everything here rather than in the shader abstraction. - ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) +// Like the DX12 implementation we'll do everything here rather than in the shader abstraction. +ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() || count == 0 ) { - Destroy(); + return E_INVALIDARG; + } - if( !renderContext.IsValid() || count == 0 ) + uint32_t bitmask = 0; + for( size_t i = 0; i < count; ++i ) + { + if( !shaders[i].IsValid() ) { return E_INVALIDARG; } + auto mask = 1 << shaders[i].GetType(); + if( ( mask & bitmask ) != 0 ) + { + return E_INVALIDARG; + } + bitmask |= mask; + } + + // Checks that Compute kernels and other types don't concurrently exist + auto csBit = 1 << COMPUTE_SHADER; + if( ( bitmask & csBit ) != 0 && ( bitmask & ~csBit ) != 0 ) + { + return E_INVALIDARG; + } - uint32_t bitmask = 0; - for( size_t i = 0; i < count; ++i ) + m_metalContext = renderContext.GetMetalContext(); + for( size_t i = 0; i < count; ++i ) + { + ::Tr2ShaderAL* shader = &shaders[i]; + auto shaderType = shader->GetType(); + + m_resourceMask[shaderType] = shader->m_shader->m_resourceMask; + + NSString* entryPointOverride = shader->m_shader->m_entryPointNameOverride; + + switch( shaderType ) { - if( !shaders[i].IsValid() ) + case VERTEX_SHADER: + if( m_vertexFunction ) { return E_INVALIDARG; } - auto mask = 1 << shaders[i].GetType(); - if( ( mask & bitmask ) != 0 ) + m_vertexFunction = + CompileShader( *shader, entryPointOverride ? entryPointOverride : @"mainVS", renderContext ); + if( !m_vertexFunction ) { - return E_INVALIDARG; + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Vertex shader creation failed." ); + return E_FAIL; } - bitmask |= mask; - } - - // Checks that Compute kernels and other types don't concurrently exist - auto csBit = 1 << COMPUTE_SHADER; - if( ( bitmask & csBit ) != 0 && ( bitmask & ~csBit ) != 0 ) - { - return E_INVALIDARG; - } - - m_metalContext = renderContext.GetMetalContext(); - for( size_t i = 0; i < count; ++i ) - { - ::Tr2ShaderAL* shader = &shaders[i]; - auto shaderType = shader->GetType(); - - m_resourceMask[shaderType] = shader->m_shader->m_resourceMask; - - NSString* entryPointOverride = shader->m_shader->m_entryPointNameOverride; - - switch( shaderType ) + m_iaInputs = shader->m_shader->m_signature.pipelineInputs; + break; + case PIXEL_SHADER: + if( m_fragmentFunction ) { - case VERTEX_SHADER: - if( m_vertexFunction ) - { - return E_INVALIDARG; - } - m_vertexFunction = CompileShader(*shader, entryPointOverride ? entryPointOverride : @"mainVS", renderContext); - if( !m_vertexFunction ) - { - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Vertex shader creation failed." ); - return E_FAIL; - } - m_iaInputs = shader->m_shader->m_signature.pipelineInputs; - break; - case PIXEL_SHADER: - if( m_fragmentFunction ) - { - return E_INVALIDARG; - } - m_fragmentFunction = CompileShader(*shader, entryPointOverride ? entryPointOverride : @"mainPS", renderContext); - if( !m_fragmentFunction ) - { - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Fragment shader creation failed." ); - return E_FAIL; - } - break; - case COMPUTE_SHADER: - if( m_computeFunction ) - { - return E_INVALIDARG; - } - m_computeFunction = CompileShader(*shader, entryPointOverride ? entryPointOverride : @"mainCS", renderContext); - if( !m_computeFunction ) - { - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Compute shader creation failed." ); - return E_FAIL; - } - { - const Tr2ShaderThreadGroupSizeAL& size = shader->m_shader->m_signature.threadGroupSize; - m_threadGroupSize = MTLSizeMake( size.x, size.y, size.z ); - } - break; - case GEOMETRY_SHADER: - case HULL_SHADER: - case DOMAIN_SHADER: - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Unsupported shader type - %d.", shaderType ); return E_INVALIDARG; - break; - default: - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Invalid shader type." ); + } + m_fragmentFunction = + CompileShader( *shader, entryPointOverride ? entryPointOverride : @"mainPS", renderContext ); + if( !m_fragmentFunction ) + { + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Fragment shader creation failed." ); + return E_FAIL; + } + break; + case COMPUTE_SHADER: + if( m_computeFunction ) + { return E_INVALIDARG; } - } - - m_registerMap = Tr2RegisterMapAL( shaders, count ); - if( m_iaInputs.empty() ) - { - m_iaInputsHash = 0; - } - else - { - m_iaInputsHash = CcpHashFNV1( m_iaInputs.data(), m_iaInputs.size() * sizeof( Tr2ShaderPipelineInputAL ) ); - } - - m_isValid = true; - return S_OK; - } - - id Tr2ShaderProgramAL::CompileShader( const ::Tr2ShaderAL& shader, NSString* entryFunction, Tr2PrimaryRenderContextAL& renderContext ) - { - id mtlDevice = m_metalContext->GetDevice(); - - dispatch_data_t shaderData = dispatch_data_create( - shader.m_shader->m_bytecode.get(), - shader.m_shader->m_bytecode.size(), - dispatch_get_global_queue(0, 0), - DISPATCH_DATA_DESTRUCTOR_DEFAULT ); - NSError* error = nullptr; - id mtlLib = [mtlDevice newLibraryWithData:shaderData error:&error]; -#if !__has_feature(objc_arc) - dispatch_release(shaderData); -#endif - if( !mtlLib ) - { - CCP_AL_LOGERR( "Tr2ShaderProgramAL: Failed to create Metal shader library. Error: %s", - error.localizedDescription.UTF8String ); -#if !__has_feature(objc_arc) - if( error ) + m_computeFunction = + CompileShader( *shader, entryPointOverride ? entryPointOverride : @"mainCS", renderContext ); + if( !m_computeFunction ) { - [error release]; + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Compute shader creation failed." ); + return E_FAIL; } -#endif - return nil; + { + const Tr2ShaderThreadGroupSizeAL& size = shader->m_shader->m_signature.threadGroupSize; + m_threadGroupSize = MTLSizeMake( size.x, size.y, size.z ); + } + break; + case GEOMETRY_SHADER: + case HULL_SHADER: + case DOMAIN_SHADER: + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Unsupported shader type - %d.", shaderType ); + return E_INVALIDARG; + break; + default: + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Invalid shader type." ); + return E_INVALIDARG; } - id fn = [mtlLib newFunctionWithName:entryFunction]; - return fn; } - void Tr2ShaderProgramAL::Destroy() + m_registerMap = Tr2RegisterMapAL( shaders, count ); + if( m_iaInputs.empty() ) { - m_isValid = false; -#if !__has_feature(objc_arc) - [m_vertexFunction release]; - [m_fragmentFunction release]; - [m_computeFunction release]; -#endif - m_vertexFunction = nil; - m_fragmentFunction = nil; - m_computeFunction = nil; - m_threadGroupSize = MTLSizeMake( 1, 1, 1 ); - m_iaInputs.clear(); m_iaInputsHash = 0; - m_registerMap = Tr2RegisterMapAL(); } - - bool Tr2ShaderProgramAL::IsValid() const + else { - return m_isValid; + m_iaInputsHash = CcpHashFNV1( m_iaInputs.data(), m_iaInputs.size() * sizeof( Tr2ShaderPipelineInputAL ) ); } - id Tr2ShaderProgramAL::GetVertexShader() const - { - return m_vertexFunction; - } + m_isValid = true; + return S_OK; +} - id Tr2ShaderProgramAL::GetFragmentShader() const - { - return m_fragmentFunction; - } +id Tr2ShaderProgramAL::CompileShader( const ::Tr2ShaderAL& shader, + NSString* entryFunction, + Tr2PrimaryRenderContextAL& renderContext ) +{ + id mtlDevice = m_metalContext->GetDevice(); - id Tr2ShaderProgramAL::GetComputeKernel() const + dispatch_data_t shaderData = dispatch_data_create( shader.m_shader->m_bytecode.get(), + shader.m_shader->m_bytecode.size(), + dispatch_get_global_queue( 0, 0 ), + DISPATCH_DATA_DESTRUCTOR_DEFAULT ); + NSError* error = nullptr; + id mtlLib = [mtlDevice newLibraryWithData:shaderData error:&error]; +#if !__has_feature( objc_arc ) + dispatch_release( shaderData ); +#endif + if( !mtlLib ) { - return m_computeFunction; + CCP_AL_LOGERR( "Tr2ShaderProgramAL: Failed to create Metal shader library. Error: %s", + error.localizedDescription.UTF8String ); +#if !__has_feature( objc_arc ) + if( error ) + { + [error release]; + } +#endif + return nil; } + id fn = [mtlLib newFunctionWithName:entryFunction]; + return fn; +} - MTLSize Tr2ShaderProgramAL::GetThreadGroupSize() const - { - return m_threadGroupSize; - } - - const ShaderResourceMask* Tr2ShaderProgramAL::GetResourceMasks() const - { - return m_resourceMask; - } +void Tr2ShaderProgramAL::Destroy() +{ + m_isValid = false; +#if !__has_feature( objc_arc ) + [m_vertexFunction release]; + [m_fragmentFunction release]; + [m_computeFunction release]; +#endif + m_vertexFunction = nil; + m_fragmentFunction = nil; + m_computeFunction = nil; + m_threadGroupSize = MTLSizeMake( 1, 1, 1 ); + m_iaInputs.clear(); + m_iaInputsHash = 0; + m_registerMap = Tr2RegisterMapAL(); +} + +bool Tr2ShaderProgramAL::IsValid() const +{ + return m_isValid; +} + +id Tr2ShaderProgramAL::GetVertexShader() const +{ + return m_vertexFunction; +} + +id Tr2ShaderProgramAL::GetFragmentShader() const +{ + return m_fragmentFunction; +} + +id Tr2ShaderProgramAL::GetComputeKernel() const +{ + return m_computeFunction; +} + +MTLSize Tr2ShaderProgramAL::GetThreadGroupSize() const +{ + return m_threadGroupSize; +} + +const ShaderResourceMask* Tr2ShaderProgramAL::GetResourceMasks() const +{ + return m_resourceMask; +} + +const std::vector& Tr2ShaderProgramAL::GetInputs() const +{ + return m_iaInputs; +} + +size_t Tr2ShaderProgramAL::GetInputsHash() const +{ + return m_iaInputsHash; +} - const std::vector& Tr2ShaderProgramAL::GetInputs() const +const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const +{ + return m_registerMap; +} + +Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2ShaderProgramAL"; + description["name"] = m_name; +} + +ALResult Tr2ShaderProgramAL::SetName( const char* name ) +{ + m_name = name; + if( m_vertexFunction ) { - return m_iaInputs; + m_vertexFunction.label = [NSString stringWithUTF8String:name]; } - - size_t Tr2ShaderProgramAL::GetInputsHash() const + if( m_fragmentFunction ) { - return m_iaInputsHash; + m_fragmentFunction.label = [NSString stringWithUTF8String:name]; } - - const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const + if( m_computeFunction ) { - return m_registerMap; + m_computeFunction.label = [NSString stringWithUTF8String:name]; } + return S_OK; +} - Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const +void Tr2ShaderProgramAL::SetDummyResources( TrinityALImpl::MetalWorkQueue& workQueue ) +{ + for( uint32_t i = 0; i < Tr2RenderContextEnum::SHADER_TYPE_COUNT; ++i ) { - return AL_MEMORY_MANAGED; - } + Tr2RenderContextEnum::ShaderType shaderType = (Tr2RenderContextEnum::ShaderType)i; - void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2ShaderProgramAL"; - description["name"] = m_name; - } + // If there's not resource set then we need to set dummies for all textures and samplers. + uint32_t missingTextureMask = m_resourceMask[i].textureMask; + uint32_t missingSamplerMask = m_resourceMask[i].samplerMask; - ALResult Tr2ShaderProgramAL::SetName( const char* name ) - { - m_name = name; - if( m_vertexFunction ) - { - m_vertexFunction.label = [NSString stringWithUTF8String:name]; - } - if( m_fragmentFunction ) + if( !missingTextureMask && !missingSamplerMask ) { - m_fragmentFunction.label = [NSString stringWithUTF8String:name]; + continue; } - if( m_computeFunction ) - { - m_computeFunction.label = [NSString stringWithUTF8String:name]; - } - return S_OK; - } - void Tr2ShaderProgramAL::SetDummyResources( TrinityALImpl::MetalWorkQueue& workQueue ) - { - for( uint32_t i = 0; i < Tr2RenderContextEnum::SHADER_TYPE_COUNT; ++i ) + // Set any missing textures and samplers to the dummy object. + uint32_t index = 0; + while( missingTextureMask && missingSamplerMask ) { - Tr2RenderContextEnum::ShaderType shaderType = (Tr2RenderContextEnum::ShaderType)i; - - // If there's not resource set then we need to set dummies for all textures and samplers. - uint32_t missingTextureMask = m_resourceMask[i].textureMask; - uint32_t missingSamplerMask = m_resourceMask[i].samplerMask; - - if( !missingTextureMask && !missingSamplerMask ) + if( missingTextureMask & 0x1 ) { - continue; + auto dummyTexture = + m_metalContext->GetDummyTexture( MTLTextureType( m_resourceMask[i].textureTypes[index] ) ); + workQueue.SetTextures( shaderType, &dummyTexture, NSMakeRange( index, 1 ) ); } + missingTextureMask >>= 1; - // Set any missing textures and samplers to the dummy object. - uint32_t index = 0; - while( missingTextureMask && missingSamplerMask ) + if( missingSamplerMask & 0x1 ) { - if( missingTextureMask & 0x1 ) - { - auto dummyTexture = m_metalContext->GetDummyTexture( MTLTextureType( m_resourceMask[i].textureTypes[index] ) ); - workQueue.SetTextures( shaderType, &dummyTexture, NSMakeRange( index, 1 ) ); - } - missingTextureMask >>= 1; - - if( missingSamplerMask & 0x1 ) - { - auto dummySampler = m_metalContext->GetDummySampler(); - workQueue.SetSamplers( shaderType, &dummySampler, NSMakeRange( index, 1 ) ); - } - missingSamplerMask >>= 1; - - ++index; + auto dummySampler = m_metalContext->GetDummySampler(); + workQueue.SetSamplers( shaderType, &dummySampler, NSMakeRange( index, 1 ) ); } + missingSamplerMask >>= 1; + + ++index; } } } +} #endif diff --git a/trinityal/metal/Tr2SwapChainALMetal.h b/trinityal/metal/Tr2SwapChainALMetal.h index ada2034f4..9e0345a0d 100644 --- a/trinityal/metal/Tr2SwapChainALMetal.h +++ b/trinityal/metal/Tr2SwapChainALMetal.h @@ -11,33 +11,36 @@ namespace TrinityALImpl { - class Tr2SwapChainAL : public Tr2DeviceResourceAL - { - public: - Tr2SwapChainAL(); +class Tr2SwapChainAL : public Tr2DeviceResourceAL +{ +public: + Tr2SwapChainAL(); - ALResult Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ); - void Destroy(); + ALResult Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - ALResult Present( Tr2RenderContextAL& renderContext ); + ALResult Present( Tr2RenderContextAL& renderContext ); - uint32_t GetWidth() const; - uint32_t GetHeight() const; + uint32_t GetWidth() const; + uint32_t GetHeight() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - ::Tr2TextureAL m_backBuffer; + ::Tr2TextureAL m_backBuffer; - private: - void GetNextBackbuffer(); +private: + void GetNextBackbuffer(); - Tr2WindowHandle m_windowHandle; - std::string m_name; - }; + Tr2WindowHandle m_windowHandle; + std::string m_name; +}; } #endif diff --git a/trinityal/metal/Tr2SwapChainALMetal.mm b/trinityal/metal/Tr2SwapChainALMetal.mm index eaf8da2df..ab96016db 100644 --- a/trinityal/metal/Tr2SwapChainALMetal.mm +++ b/trinityal/metal/Tr2SwapChainALMetal.mm @@ -12,107 +12,106 @@ namespace TrinityALImpl { - Tr2SwapChainAL::Tr2SwapChainAL() - : m_windowHandle( Tr2WindowHandle() ) +Tr2SwapChainAL::Tr2SwapChainAL() : m_windowHandle( Tr2WindowHandle() ) +{ + m_backBuffer.m_texture = std::make_shared(); +} + +ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - m_backBuffer.m_texture = std::make_shared(); + return E_INVALIDARG; } - - ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ) + NSView* view = (NSView*)windowHandle; + if( !view.layer || ![view.layer isKindOfClass:CAMetalLayer.class] ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - NSView* view = (NSView *)windowHandle; - if( !view.layer || ![view.layer isKindOfClass:CAMetalLayer.class]) - { - return E_INVALIDARG; - } - Destroy(); - - uint32_t width = 0; - uint32_t height = 0; - Tr2RenderContextEnum::PixelFormat pixelFormat = Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN; - - Tr2PresentParametersAL* presentParameters = renderContext.GetPresentParamaters(); - if( windowHandle == presentParameters->outputWindow ) - { - width = presentParameters->mode.width; - height = presentParameters->mode.height; - pixelFormat = presentParameters->mode.format; - } - else - { - auto layer = (CAMetalLayer*)view.layer; - auto scale = layer.contentsScale; - layer.drawableSize = CGSizeMake( layer.bounds.size.width * scale, layer.bounds.size.height * scale ); - width = layer.drawableSize.width; - height = layer.drawableSize.height; - pixelFormat = Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM; - } - - Tr2MsaaDesc msaaDesc = Tr2MsaaDesc( presentParameters->msaaType, presentParameters->msaaQuality ); - Tr2BitmapDimensions textureInfo = Tr2BitmapDimensions( width, height, 1, pixelFormat ); - - Tr2GpuUsage::Type gpuUsage = Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE; - // Have to make this READ to get the screeshot facility to work - Tr2CpuUsage::Type cpuUsage = Tr2CpuUsage::READ; - - CR_RETURN_HR( m_backBuffer.m_texture->Create( textureInfo, msaaDesc, gpuUsage, cpuUsage, nil, renderContext ) ); - - m_windowHandle = windowHandle; - - return S_OK; + return E_INVALIDARG; } + Destroy(); + + uint32_t width = 0; + uint32_t height = 0; + Tr2RenderContextEnum::PixelFormat pixelFormat = Tr2RenderContextEnum::PIXEL_FORMAT_UNKNOWN; - void Tr2SwapChainAL::Destroy() + Tr2PresentParametersAL* presentParameters = renderContext.GetPresentParamaters(); + if( windowHandle == presentParameters->outputWindow ) { - m_backBuffer.m_texture->Destroy(); + width = presentParameters->mode.width; + height = presentParameters->mode.height; + pixelFormat = presentParameters->mode.format; } - - bool Tr2SwapChainAL::IsValid() const + else { - return m_backBuffer.IsValid(); + auto layer = (CAMetalLayer*)view.layer; + auto scale = layer.contentsScale; + layer.drawableSize = CGSizeMake( layer.bounds.size.width * scale, layer.bounds.size.height * scale ); + width = layer.drawableSize.width; + height = layer.drawableSize.height; + pixelFormat = Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM; } - ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& renderContext ) - { - MetalContext* metalContext = renderContext.GetMetalContext(); - NSView* view = (NSView*)m_windowHandle; - id backBufferTexture = m_backBuffer.m_texture->GetMetalTexture(); - metalContext->BlitToDrawableAndPresent( backBufferTexture, view ); + Tr2MsaaDesc msaaDesc = Tr2MsaaDesc( presentParameters->msaaType, presentParameters->msaaQuality ); + Tr2BitmapDimensions textureInfo = Tr2BitmapDimensions( width, height, 1, pixelFormat ); - GetNextBackbuffer(); + Tr2GpuUsage::Type gpuUsage = Tr2GpuUsage::RENDER_TARGET | Tr2GpuUsage::SHADER_RESOURCE; + // Have to make this READ to get the screeshot facility to work + Tr2CpuUsage::Type cpuUsage = Tr2CpuUsage::READ; - return S_OK; - } + CR_RETURN_HR( m_backBuffer.m_texture->Create( textureInfo, msaaDesc, gpuUsage, cpuUsage, nil, renderContext ) ); - uint32_t Tr2SwapChainAL::GetWidth() const - { - return m_backBuffer.GetWidth(); - } + m_windowHandle = windowHandle; - uint32_t Tr2SwapChainAL::GetHeight() const - { - return m_backBuffer.GetHeight(); - } + return S_OK; +} - void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2SwapChainAL"; - description["name"] = m_name; - } +void Tr2SwapChainAL::Destroy() +{ + m_backBuffer.m_texture->Destroy(); +} - ALResult Tr2SwapChainAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +bool Tr2SwapChainAL::IsValid() const +{ + return m_backBuffer.IsValid(); +} - void Tr2SwapChainAL::GetNextBackbuffer() - { - } +ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& renderContext ) +{ + MetalContext* metalContext = renderContext.GetMetalContext(); + NSView* view = (NSView*)m_windowHandle; + id backBufferTexture = m_backBuffer.m_texture->GetMetalTexture(); + metalContext->BlitToDrawableAndPresent( backBufferTexture, view ); + + GetNextBackbuffer(); + + return S_OK; +} + +uint32_t Tr2SwapChainAL::GetWidth() const +{ + return m_backBuffer.GetWidth(); +} + +uint32_t Tr2SwapChainAL::GetHeight() const +{ + return m_backBuffer.GetHeight(); +} + +void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2SwapChainAL"; + description["name"] = m_name; +} + +ALResult Tr2SwapChainAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} + +void Tr2SwapChainAL::GetNextBackbuffer() +{ +} } #endif // TRINITY_PLATFORM == TRINITY_METAL diff --git a/trinityal/metal/Tr2TextureALMetal.h b/trinityal/metal/Tr2TextureALMetal.h index e78eaab59..b549be943 100644 --- a/trinityal/metal/Tr2TextureALMetal.h +++ b/trinityal/metal/Tr2TextureALMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2TextureAL.h" #include "../Tr2HalHelperStructures.h" @@ -11,85 +11,88 @@ namespace TrinityALImpl { - class Tr2TextureAL : public Tr2DeviceResourceAL +class Tr2TextureAL : public Tr2DeviceResourceAL +{ +public: + Tr2TextureAL(); + ~Tr2TextureAL(); + + ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); + ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BitmapDimensions& GetDesc() const; + const Tr2MsaaDesc& GetMsaaDesc() const; + Tr2GpuUsage::Type GetGpuUsage() const; + Tr2CpuUsage::Type GetCpuUsage() const; + + ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + { + return MapForReading( region, true, data, pitch, renderContext ); + } + ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); + + ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); + ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); + ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); + ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); + uintptr_t GetSharedHandle() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + const char* GetName() const; + ALResult SetName( const char* name ); + + id GetMetalTexture() + { + return m_mtlTexture; + }; + id GetSRGBViewMetalTexture(); + id GetUAVMetalTexture( uint32_t mipLevel ); + + void AssignFromTexture( Tr2TextureAL& backBuffer ); + + uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; + uint32_t GetUavIndexInHeap( uint32_t mip ) const; + +private: + Tr2BitmapDimensions m_desc; + Tr2MsaaDesc m_msaa; + Tr2GpuUsage::Type m_gpuUsage; + Tr2CpuUsage::Type m_cpuUsage; + Tr2SubresourceData m_dataLayout; + + Tr2TextureSubresource m_mappedRegion; + + struct MappedRange { - public: - Tr2TextureAL(); - ~Tr2TextureAL(); - - ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); - ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BitmapDimensions& GetDesc() const; - const Tr2MsaaDesc& GetMsaaDesc() const; - Tr2GpuUsage::Type GetGpuUsage() const; - Tr2CpuUsage::Type GetCpuUsage() const; - - ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - return MapForReading( region, true, data, pitch, renderContext ); - } - ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); - - ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); - ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); - ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); - ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); - uintptr_t GetSharedHandle() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - const char* GetName() const; - ALResult SetName( const char* name ); - - id GetMetalTexture() { return m_mtlTexture; }; - id GetSRGBViewMetalTexture(); - id GetUAVMetalTexture( uint32_t mipLevel ); - - void AssignFromTexture( Tr2TextureAL& backBuffer ); - - uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; - uint32_t GetUavIndexInHeap( uint32_t mip ) const; - - private: - Tr2BitmapDimensions m_desc; - Tr2MsaaDesc m_msaa; - Tr2GpuUsage::Type m_gpuUsage; - Tr2CpuUsage::Type m_cpuUsage; - Tr2SubresourceData m_dataLayout; - - Tr2TextureSubresource m_mappedRegion; - - struct MappedRange - { - uint32_t offset; - uint32_t size; - uint64_t frame; - }; - - id m_mtlWriteBuffer; - std::vector m_mappedRanges; - MappedRange m_mappedRange; - - id m_mtlReadBackBuffer; - id m_mtlTexture; - id m_mtlTextureSRGBView; - uint32_t m_srvHeapIndices[2]; - std::vector> m_mtlTextureUAV; - std::vector m_uavHeapIndices; - - uint64_t m_usedInEncoder; - - MetalContext *m_metalContext; - std::string m_name; - Tr2MemoryCounterAL m_memory; - bool m_wrappedTexture; - friend class ::Tr2RenderContextAL; + uint32_t offset; + uint32_t size; + uint64_t frame; }; + + id m_mtlWriteBuffer; + std::vector m_mappedRanges; + MappedRange m_mappedRange; + + id m_mtlReadBackBuffer; + id m_mtlTexture; + id m_mtlTextureSRGBView; + uint32_t m_srvHeapIndices[2]; + std::vector> m_mtlTextureUAV; + std::vector m_uavHeapIndices; + + uint64_t m_usedInEncoder; + + MetalContext* m_metalContext; + std::string m_name; + Tr2MemoryCounterAL m_memory; + bool m_wrappedTexture; + friend class ::Tr2RenderContextAL; +}; } #endif diff --git a/trinityal/metal/Tr2TextureALMetal.mm b/trinityal/metal/Tr2TextureALMetal.mm index 798a87cf0..be093dd64 100644 --- a/trinityal/metal/Tr2TextureALMetal.mm +++ b/trinityal/metal/Tr2TextureALMetal.mm @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2TextureALMetal.h" #include "Tr2RenderContextMetal.h" @@ -12,136 +12,141 @@ namespace TrinityALImpl { - Tr2TextureAL::Tr2TextureAL() - : m_gpuUsage( Tr2GpuUsage::NONE ) - , m_cpuUsage( Tr2CpuUsage::NONE ) - , m_dataLayout( {nullptr, 0, 0} ) - , m_mtlWriteBuffer( nil ) - , m_mappedRange{ 0, 0, 0 } - , m_mtlReadBackBuffer( nil ) - , m_mtlTexture( nil ) - , m_mtlTextureSRGBView( nil ) - , m_metalContext( nullptr ) - , m_usedInEncoder( 0 ) - , m_wrappedTexture( false ) +Tr2TextureAL::Tr2TextureAL() : + m_gpuUsage( Tr2GpuUsage::NONE ), + m_cpuUsage( Tr2CpuUsage::NONE ), + m_dataLayout( { nullptr, 0, 0 } ), + m_mtlWriteBuffer( nil ), + m_mappedRange{ 0, 0, 0 }, + m_mtlReadBackBuffer( nil ), + m_mtlTexture( nil ), + m_mtlTextureSRGBView( nil ), + m_metalContext( nullptr ), + m_usedInEncoder( 0 ), + m_wrappedTexture( false ) +{ + m_srvHeapIndices[0] = m_srvHeapIndices[1] = 0xffffffff; +} + +Tr2TextureAL::~Tr2TextureAL() +{ + Destroy(); +} + +ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, + const Tr2MsaaDesc& msaa, + Tr2GpuUsage::Type gpuUsage, + Tr2CpuUsage::Type cpuUsage, + Tr2SubresourceData* initialData, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( HasBufferFlags( gpuUsage ) ) { - m_srvHeapIndices[0] = m_srvHeapIndices[1] = 0xffffffff; + return E_INVALIDARG; } - Tr2TextureAL::~Tr2TextureAL() - { - Destroy(); - } + if( !renderContext.IsValid() ) + { + return E_FAIL; + } - ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) + if( desc.GetWidth() == 0 || desc.GetHeight() == 0 ) + { + return E_INVALIDARG; + } + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && desc.GetDepth() == 0 ) { - Destroy(); + return E_INVALIDARG; + } - if( HasBufferFlags( gpuUsage ) ) + if( msaa.samples > 1 ) + { + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { return E_INVALIDARG; } - - if( !renderContext.IsValid() ) + if( cpuUsage != Tr2CpuUsage::NONE ) { - return E_FAIL; + return E_INVALIDARG; } - - if( desc.GetWidth() == 0 || desc.GetHeight() == 0 ) - { - return E_INVALIDARG; - } - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && desc.GetDepth() == 0 ) - { - return E_INVALIDARG; - } - - if( msaa.samples > 1 ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) { - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - return E_INVALIDARG; - } - if( cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - return E_INVALIDARG; - } + return E_INVALIDARG; } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) + } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) + { + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - if( desc.GetArraySize() != 6 ) - { - return E_INVALIDARG; - } - } - else if( desc.GetArraySize() > 1 ) + if( desc.GetArraySize() != 6 ) { return E_INVALIDARG; } } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - return E_INVALIDARG; - } - if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) - { - return E_INVALIDARG; - } - if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) + else if( desc.GetArraySize() > 1 ) { return E_INVALIDARG; } + } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + return E_INVALIDARG; + } + if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) + { + return E_INVALIDARG; + } + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) + { + return E_INVALIDARG; + } + if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) + { + return E_INVALIDARG; + } - // TODO: MTLTextureUsagePixelFormatView has been removed but might be necessary in the future (e.g. if we need a special pixel format/component layout). - MTLTextureUsage metalTextureUsage = 0; + // TODO: MTLTextureUsagePixelFormatView has been removed but might be necessary in the future (e.g. if we need a special pixel format/component layout). + MTLTextureUsage metalTextureUsage = 0; - MetalContext *metalContext = renderContext.GetMetalContext(); - MetalWorkQueue* workQueue = renderContext.GetMetalWorkQueue(); + MetalContext* metalContext = renderContext.GetMetalContext(); + MetalWorkQueue* workQueue = renderContext.GetMetalWorkQueue(); - // It seems that trinity will assume that a depth stencil can be used as a render target and doesn't set the RENDER_TARGET flag - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || - HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) - { - metalTextureUsage |= MTLTextureUsageRenderTarget; - } + // It seems that trinity will assume that a depth stencil can be used as a render target and doesn't set the RENDER_TARGET flag + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + { + metalTextureUsage |= MTLTextureUsageRenderTarget; + } - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - metalTextureUsage |= MTLTextureUsageShaderRead; - } + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + metalTextureUsage |= MTLTextureUsageShaderRead; + } - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - metalTextureUsage |= MTLTextureUsageShaderWrite; - } + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) + { + metalTextureUsage |= MTLTextureUsageShaderWrite; + } - MTLPixelFormat metalPixelFormat = metalContext->m_utils->GetMTLPixelFormat( desc.GetFormat() ); + MTLPixelFormat metalPixelFormat = metalContext->m_utils->GetMTLPixelFormat( desc.GetFormat() ); - if( metalPixelFormat == MTLPixelFormatInvalid ) - { - return E_INVALIDARG; - } + if( metalPixelFormat == MTLPixelFormatInvalid ) + { + return E_INVALIDARG; + } - MTLTextureType metalTextureType = metalContext->m_utils->GetMTLTextureType( desc.GetType(), desc.GetArraySize(), msaa.samples ); - MTLStorageMode metalStorageMode = MTLStorageModePrivate; + MTLTextureType metalTextureType = + metalContext->m_utils->GetMTLTextureType( desc.GetType(), desc.GetArraySize(), msaa.samples ); + MTLStorageMode metalStorageMode = MTLStorageModePrivate; #if 0 // Might want to revisit this wrapping a texture approach and seperate it out. Use this now for expediency. @@ -154,299 +159,334 @@ } else #endif - bool needsDecompression = false; - - Tr2BitmapDimensions realDesc = desc; - - // macOS 10.14 can't handle compressed volume textures, so we decompress them on the fly - // This only works with an assumption that we have BC 1, 2, 3 compression only and that such - // textures are immutable textures only participating in draw commands (not copy/map, etc.) - if( @available( macOS 10.15, * ) ) - { + bool needsDecompression = false; + + Tr2BitmapDimensions realDesc = desc; + + // macOS 10.14 can't handle compressed volume textures, so we decompress them on the fly + // This only works with an assumption that we have BC 1, 2, 3 compression only and that such + // textures are immutable textures only participating in draw commands (not copy/map, etc.) + if( @available( macOS 10.15, * ) ) + { + } + else + { + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && IsCompressedFormat( desc.GetFormat() ) ) + { + metalPixelFormat = MTLPixelFormatBGRA8Unorm; + needsDecompression = true; + realDesc = Tr2BitmapDimensions( desc.GetType(), + Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM, + desc.GetWidth(), + desc.GetHeight(), + desc.GetDepth(), + desc.GetMipCount(), + desc.GetArraySize() ); } - else + } + + { + uint32_t mipMapCount = desc.GetTrueMipCount(); + + m_mtlTexture = metalContext->CreateMetalTexture( + metalTextureType, + metalPixelFormat, + desc.GetWidth(), + desc.GetHeight(), + desc.GetDepth(), + mipMapCount, + metalStorageMode, + metalTextureUsage, + msaa.samples, + desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ? 1 : desc.GetArraySize() ); + + if( initialData ) { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && IsCompressedFormat( desc.GetFormat() ) ) + uint32_t sliceCount = desc.GetArraySize(); + uint32_t index = 0; + std::unique_ptr decompressed; + for( uint32_t slice = 0; slice < sliceCount; ++slice ) { - metalPixelFormat = MTLPixelFormatBGRA8Unorm; - needsDecompression = true; - realDesc = Tr2BitmapDimensions( - desc.GetType(), - Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM, - desc.GetWidth(), - desc.GetHeight(), - desc.GetDepth(), - desc.GetMipCount(), - desc.GetArraySize() ); - } - } - - { - uint32_t mipMapCount = desc.GetTrueMipCount(); - - m_mtlTexture = metalContext->CreateMetalTexture(metalTextureType, - metalPixelFormat, - desc.GetWidth(), - desc.GetHeight(), - desc.GetDepth(), - mipMapCount, - metalStorageMode, - metalTextureUsage, - msaa.samples, - desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ? 1 : desc.GetArraySize()); - - if( initialData ) - { - uint32_t sliceCount = desc.GetArraySize(); - uint32_t index = 0; - std::unique_ptr decompressed; - for( uint32_t slice = 0; slice < sliceCount; ++slice ) + for( uint32_t mip = 0; mip < mipMapCount; ++mip ) { - for( uint32_t mip = 0; mip < mipMapCount; ++mip ) + if( needsDecompression ) { - if( needsDecompression ) - { - uint32_t levelWidth = std::max( desc.GetWidth() >> mip, 1U ); - uint32_t levelHeight = std::max( desc.GetHeight() >> mip, 1U ); - uint32_t levelDepth = std::max( desc.GetDepth() >> mip, 1U ); - if( !BcDecompress( levelWidth, levelHeight, levelDepth, desc.GetFormat(), initialData[mip], decompressed ) ) - { - return E_FAIL; - } - workQueue->UploadTexture( m_mtlTexture, decompressed.get(), slice, mip, levelWidth * 4, levelWidth * levelHeight * 4, 0, false ); - } - else + uint32_t levelWidth = std::max( desc.GetWidth() >> mip, 1U ); + uint32_t levelHeight = std::max( desc.GetHeight() >> mip, 1U ); + uint32_t levelDepth = std::max( desc.GetDepth() >> mip, 1U ); + if( !BcDecompress( levelWidth, + levelHeight, + levelDepth, + desc.GetFormat(), + initialData[mip], + decompressed ) ) { - workQueue->UploadTexture( m_mtlTexture, initialData[index].m_sysMem, slice, mip, initialData[index].m_sysMemPitch, initialData[index].m_sysMemSlicePitch, 0, false ); + return E_FAIL; } - ++index; - } - } - } - - m_wrappedTexture = false; - } - m_mtlTextureSRGBView = metalContext->CreateSRGBViewOfMetalTexture( m_mtlTexture ); - if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - m_srvHeapIndices[0] = metalContext->AllocateHeapIndex( m_mtlTexture ); - if( m_mtlTextureSRGBView == m_mtlTexture ) - { - m_srvHeapIndices[1] = m_srvHeapIndices[0]; - } - else - { - m_srvHeapIndices[1] = metalContext->AllocateHeapIndex( m_mtlTextureSRGBView ); - } - } - m_memory.Set( Tr2MemoryCounterAL::TEXTURE, realDesc, msaa ); - - m_metalContext = metalContext; - m_desc = desc; - m_gpuUsage = gpuUsage; - m_cpuUsage = cpuUsage; - m_msaa = msaa; - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - m_mtlTextureUAV.resize( desc.GetTrueMipCount() ); - m_uavHeapIndices.resize( desc.GetTrueMipCount() ); - for( uint32_t i = 0; i < desc.GetTrueMipCount(); ++i ) - { - m_mtlTextureUAV[i] = m_metalContext->CreateUAVOfMetalTexture( m_mtlTexture, i ); - m_uavHeapIndices[i] = m_metalContext->AllocateHeapIndex( m_mtlTextureUAV[i] ); - } - } - if( initialData ) - { - m_dataLayout = *initialData; + workQueue->UploadTexture( m_mtlTexture, + decompressed.get(), + slice, + mip, + levelWidth * 4, + levelWidth * levelHeight * 4, + 0, + false ); + } + else + { + workQueue->UploadTexture( m_mtlTexture, + initialData[index].m_sysMem, + slice, + mip, + initialData[index].m_sysMemPitch, + initialData[index].m_sysMemSlicePitch, + 0, + false ); + } + ++index; + } + } } - return S_OK; + m_wrappedTexture = false; } - - id Tr2TextureAL::GetSRGBViewMetalTexture() + m_mtlTextureSRGBView = metalContext->CreateSRGBViewOfMetalTexture( m_mtlTexture ); + if( HasFlag( gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - return m_mtlTextureSRGBView; + m_srvHeapIndices[0] = metalContext->AllocateHeapIndex( m_mtlTexture ); + if( m_mtlTextureSRGBView == m_mtlTexture ) + { + m_srvHeapIndices[1] = m_srvHeapIndices[0]; + } + else + { + m_srvHeapIndices[1] = metalContext->AllocateHeapIndex( m_mtlTextureSRGBView ); + } } - - id Tr2TextureAL::GetUAVMetalTexture( uint32_t mipLevel ) + m_memory.Set( Tr2MemoryCounterAL::TEXTURE, realDesc, msaa ); + + m_metalContext = metalContext; + m_desc = desc; + m_gpuUsage = gpuUsage; + m_cpuUsage = cpuUsage; + m_msaa = msaa; + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { - if( mipLevel >= m_mtlTextureUAV.size() ) + m_mtlTextureUAV.resize( desc.GetTrueMipCount() ); + m_uavHeapIndices.resize( desc.GetTrueMipCount() ); + for( uint32_t i = 0; i < desc.GetTrueMipCount(); ++i ) { - return nil; + m_mtlTextureUAV[i] = m_metalContext->CreateUAVOfMetalTexture( m_mtlTexture, i ); + m_uavHeapIndices[i] = m_metalContext->AllocateHeapIndex( m_mtlTextureUAV[i] ); } - return m_mtlTextureUAV[mipLevel]; } - - ALResult Tr2TextureAL::OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ) + if( initialData ) { - return E_FAIL; + m_dataLayout = *initialData; } - void Tr2TextureAL::Destroy() - { - m_usedInEncoder = 0; - if( m_mtlTexture ) - { - m_metalContext->DeallocateHeapIndex( m_srvHeapIndices[0] ); - m_metalContext->DestroyMetalTexture(m_mtlTexture); - } - if( m_mtlTextureSRGBView ) - { - if( m_srvHeapIndices[1] != m_srvHeapIndices[0] ) - { - m_metalContext->DeallocateHeapIndex( m_srvHeapIndices[1] ); - } - m_metalContext->DestroyMetalTexture(m_mtlTextureSRGBView); - } - m_srvHeapIndices[0] = m_srvHeapIndices[1] = 0xffffffff; - for( auto& idx : m_uavHeapIndices ) - { - m_metalContext->DeallocateHeapIndex( idx ); - } - m_uavHeapIndices.clear(); - for( auto texture : m_mtlTextureUAV ) - { - m_metalContext->DestroyMetalTexture( texture ); - } - m_mtlTextureUAV.clear(); - if( m_mtlReadBackBuffer ) - { - m_metalContext->DestroyMetalBuffer(m_mtlReadBackBuffer); - } - if( m_mtlWriteBuffer ) - { - m_metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); - } - m_mappedRanges.clear(); - m_mappedRange.size = 0; - - memset( &m_desc, 0, sizeof( m_desc ) ); - m_msaa = Tr2MsaaDesc(); - m_gpuUsage = Tr2GpuUsage::NONE; - m_cpuUsage = Tr2CpuUsage::NONE; - - m_dataLayout.m_sysMem = nullptr; - m_dataLayout.m_sysMemPitch = 0; - m_dataLayout.m_sysMemSlicePitch = 0; - - m_mtlReadBackBuffer = nil; - m_mtlTexture = nil; - m_mtlTextureSRGBView = nil; - - - m_metalContext = nil; - m_wrappedTexture = false; - m_memory.Reset(); - } + return S_OK; +} - bool Tr2TextureAL::IsValid() const +id Tr2TextureAL::GetSRGBViewMetalTexture() +{ + return m_mtlTextureSRGBView; +} + +id Tr2TextureAL::GetUAVMetalTexture( uint32_t mipLevel ) +{ + if( mipLevel >= m_mtlTextureUAV.size() ) { - return m_desc.GetWidth() != 0; + return nil; } + return m_mtlTextureUAV[mipLevel]; +} + +ALResult + Tr2TextureAL::OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ) +{ + return E_FAIL; +} - Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const +void Tr2TextureAL::Destroy() +{ + m_usedInEncoder = 0; + if( m_mtlTexture ) { - return AL_MEMORY_MANAGED; + m_metalContext->DeallocateHeapIndex( m_srvHeapIndices[0] ); + m_metalContext->DestroyMetalTexture( m_mtlTexture ); } - - const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const + if( m_mtlTextureSRGBView ) { - return m_desc; + if( m_srvHeapIndices[1] != m_srvHeapIndices[0] ) + { + m_metalContext->DeallocateHeapIndex( m_srvHeapIndices[1] ); + } + m_metalContext->DestroyMetalTexture( m_mtlTextureSRGBView ); } - - const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const + m_srvHeapIndices[0] = m_srvHeapIndices[1] = 0xffffffff; + for( auto& idx : m_uavHeapIndices ) { - return m_msaa; + m_metalContext->DeallocateHeapIndex( idx ); } - - Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const + m_uavHeapIndices.clear(); + for( auto texture : m_mtlTextureUAV ) { - return m_gpuUsage; + m_metalContext->DestroyMetalTexture( texture ); } - - Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const + m_mtlTextureUAV.clear(); + if( m_mtlReadBackBuffer ) { - return m_cpuUsage; + m_metalContext->DestroyMetalBuffer( m_mtlReadBackBuffer ); } - - ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + if( m_mtlWriteBuffer ) { - data = nullptr; - MetalContext *metalContext = renderContext.GetMetalContext(); + m_metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); + } + m_mappedRanges.clear(); + m_mappedRange.size = 0; - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } + memset( &m_desc, 0, sizeof( m_desc ) ); + m_msaa = Tr2MsaaDesc(); + m_gpuUsage = Tr2GpuUsage::NONE; + m_cpuUsage = Tr2CpuUsage::NONE; - if( !IsValid() || !renderContext.IsValid() ) - { - return E_FAIL; - } - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } + m_dataLayout.m_sysMem = nullptr; + m_dataLayout.m_sysMemPitch = 0; + m_dataLayout.m_sysMemSlicePitch = 0; - CCP_ASSERT(region.m_startFace == 0 && region.m_endFace == 1); + m_mtlReadBackBuffer = nil; + m_mtlTexture = nil; + m_mtlTextureSRGBView = nil; - MTLOrigin readOrigin; - MTLSize readSize; - uint32_t readMipLevel = region.m_startMipLevel; - if( readMipLevel >= m_mtlTexture.mipmapLevelCount ) - { - CCP_AL_LOGWARN( "Mip level %d does not exist for this texture. Defaulting to 0.", (int)readMipLevel ); - readMipLevel = 0; - } + m_metalContext = nil; + m_wrappedTexture = false; + m_memory.Reset(); +} - if( region.HasBox() ) - { - readOrigin = MTLOriginMake(region.m_box.left, region.m_box.bottom, region.m_box.front); - readSize = MTLSizeMake(region.GetWidth(), region.GetHeight(), region.GetDepth()); - } - else - { - readOrigin = MTLOriginMake(0, 0, 0); - readSize = MTLSizeMake(m_desc.GetMipWidth(readMipLevel), m_desc.GetMipHeight(readMipLevel), m_desc.GetMipDepth(readMipLevel)); - } +bool Tr2TextureAL::IsValid() const +{ + return m_desc.GetWidth() != 0; +} - auto mipPitch = m_desc.GetMipPitch( readMipLevel ); - auto bufferSize = m_desc.GetMipSize( readMipLevel ); +Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - if( !m_mtlReadBackBuffer ) - { - m_mtlReadBackBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), bufferSize, MTLResourceStorageModeManaged, nil); - m_memory.Grow( bufferSize ); - } - // We recreate the buffer if it's not an exact match but we could just do this for larger buffers if performance is an issue - if( m_mtlReadBackBuffer.length != bufferSize ) - { - m_memory.Shrink( m_mtlReadBackBuffer.length ); - metalContext->DestroyMetalBuffer(m_mtlReadBackBuffer); - m_mtlReadBackBuffer = metalContext->CreateMetalBuffer(renderContext.GetMetalWorkQueue(), bufferSize, MTLResourceStorageModeManaged, nil); - m_memory.Grow( bufferSize ); - } +const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const +{ + return m_desc; +} - renderContext.GetMetalWorkQueue()->CopyTextureToMTLBuffer( m_mtlTexture, m_mtlReadBackBuffer, mipPitch, bufferSize / std::max( 1u, m_desc.GetDepth() ), readOrigin, readSize, readMipLevel, synchronize ); +const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const +{ + return m_msaa; +} - pitch = mipPitch; - data = m_mtlReadBackBuffer.contents; +Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const +{ + return m_gpuUsage; +} + +Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const +{ + return m_cpuUsage; +} + +ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, + bool synchronize, + const void*& data, + uint32_t& pitch, + Tr2RenderContextAL& renderContext ) +{ + data = nullptr; + MetalContext* metalContext = renderContext.GetMetalContext(); - m_dataLayout.m_sysMem = data; - m_dataLayout.m_sysMemPitch = mipPitch; - m_dataLayout.m_sysMemSlicePitch = bufferSize; + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) + { + return E_INVALIDCALL; + } - return S_OK; + if( !IsValid() || !renderContext.IsValid() ) + { + return E_FAIL; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + + CCP_ASSERT( region.m_startFace == 0 && region.m_endFace == 1 ); + + MTLOrigin readOrigin; + MTLSize readSize; + uint32_t readMipLevel = region.m_startMipLevel; + + if( readMipLevel >= m_mtlTexture.mipmapLevelCount ) + { + CCP_AL_LOGWARN( "Mip level %d does not exist for this texture. Defaulting to 0.", (int)readMipLevel ); + readMipLevel = 0; + } + + if( region.HasBox() ) + { + readOrigin = MTLOriginMake( region.m_box.left, region.m_box.bottom, region.m_box.front ); + readSize = MTLSizeMake( region.GetWidth(), region.GetHeight(), region.GetDepth() ); + } + else + { + readOrigin = MTLOriginMake( 0, 0, 0 ); + readSize = MTLSizeMake( m_desc.GetMipWidth( readMipLevel ), + m_desc.GetMipHeight( readMipLevel ), + m_desc.GetMipDepth( readMipLevel ) ); } - void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& renderContext ) + auto mipPitch = m_desc.GetMipPitch( readMipLevel ); + auto bufferSize = m_desc.GetMipSize( readMipLevel ); + + if( !m_mtlReadBackBuffer ) + { + m_mtlReadBackBuffer = metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), bufferSize, MTLResourceStorageModeManaged, nil ); + m_memory.Grow( bufferSize ); + } + // We recreate the buffer if it's not an exact match but we could just do this for larger buffers if performance is an issue + if( m_mtlReadBackBuffer.length != bufferSize ) { + m_memory.Shrink( m_mtlReadBackBuffer.length ); + metalContext->DestroyMetalBuffer( m_mtlReadBackBuffer ); + m_mtlReadBackBuffer = metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), bufferSize, MTLResourceStorageModeManaged, nil ); + m_memory.Grow( bufferSize ); + } + + renderContext.GetMetalWorkQueue()->CopyTextureToMTLBuffer( m_mtlTexture, + m_mtlReadBackBuffer, + mipPitch, + bufferSize / std::max( 1u, m_desc.GetDepth() ), + readOrigin, + readSize, + readMipLevel, + synchronize ); + + pitch = mipPitch; + data = m_mtlReadBackBuffer.contents; + + m_dataLayout.m_sysMem = data; + m_dataLayout.m_sysMemPitch = mipPitch; + m_dataLayout.m_sysMemSlicePitch = bufferSize; + + return S_OK; +} + +void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& renderContext ) +{ #if 0 if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) && !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { @@ -454,401 +494,437 @@ } #endif - m_dataLayout.m_sysMem = nullptr; - m_dataLayout.m_sysMemPitch = 0; - m_dataLayout.m_sysMemSlicePitch = 0; - } + m_dataLayout.m_sysMem = nullptr; + m_dataLayout.m_sysMemPitch = 0; + m_dataLayout.m_sysMemSlicePitch = 0; +} + +ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, + void*& data, + uint32_t& pitch, + Tr2RenderContextAL& renderContext ) +{ + MetalContext* metalContext = renderContext.GetMetalContext(); + data = nullptr; - ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) + { + return E_INVALIDCALL; + } + if( !IsValid() || !renderContext.IsValid() ) + { + return E_FAIL; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) { - MetalContext *metalContext = renderContext.GetMetalContext(); - data = nullptr; + return E_INVALIDARG; + } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_FAIL; - } - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } - if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) - { - return E_INVALIDARG; - } - - CCP_ASSERT(region.m_startFace == 0 && region.m_endFace == 1); - - auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); - auto bufferSize = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); - - if( region.HasBox() ) - { - auto width = MAX( MIN( region.GetWidth(), m_desc.GetMipWidth( region.m_startMipLevel ) ), 1); - auto height = MAX( MIN( region.GetHeight(), m_desc.GetMipHeight( region.m_startMipLevel ) ), 1 ); - auto depth = MAX( MIN( region.GetDepth(), m_desc.GetMipDepth( region.m_startMipLevel ) ), 1 ); - if( m_desc.IsCompressed() ) - { - mipPitch = MAX( width / 4u, 1 ) * GetBlockByteSize( m_desc.GetFormat() ); - } - else - { - mipPitch = width * GetBytesPerPixel( m_desc.GetFormat() ); - } - bufferSize = mipPitch * height * depth; - } - - auto renderedFrame = metalContext->GetRenderedFrameNumber(); - - while( !m_mappedRanges.empty() ) - { - auto& r = m_mappedRanges.front(); - if( r.frame < renderedFrame ) - { - m_mappedRanges.erase( m_mappedRanges.begin() ); - } - else - { - break; - } - } - - if( !m_mtlWriteBuffer ) - { - m_mtlWriteBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), m_desc.GetMipSize( 0 ), MTLResourceStorageModeManaged, nil ); - m_memory.Grow( m_mtlWriteBuffer.length ); - } - uint32_t start = 0; - if( !m_mappedRanges.empty() ) - { - auto head = m_mappedRanges.front().offset; - auto tail = m_mappedRanges.back().offset + m_mappedRanges.back().size; - - if( head < tail ) - { - if( tail + bufferSize <= m_mtlWriteBuffer.length ) - { - start = tail; - } - else if( bufferSize <= head ) - { - auto remainder = m_mtlWriteBuffer.length - tail; - start = 0; - } - else - { - m_memory.Shrink( m_mtlWriteBuffer.length ); - metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); - m_mtlWriteBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), m_desc.GetMipSize( 0 ) + m_mtlWriteBuffer.length, MTLResourceStorageModeManaged, nil ); - m_memory.Grow( m_mtlWriteBuffer.length ); - m_mappedRanges.clear(); - start = 0; - } - } - else - { - if( tail + bufferSize <= head ) - { - start = tail; - } - else - { - m_memory.Shrink( m_mtlWriteBuffer.length ); - metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); - m_mtlWriteBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), m_desc.GetMipSize( 0 ) + m_mtlWriteBuffer.length, MTLResourceStorageModeManaged, nil ); - m_memory.Grow( m_mtlWriteBuffer.length ); - m_mappedRanges.clear(); - start = 0; - } - } - } - - m_mappedRange = { start, bufferSize, metalContext->GetRecordingFrameNumber() }; - m_mappedRanges.push_back( m_mappedRange ); - - pitch = mipPitch; - data = static_cast( m_mtlWriteBuffer.contents ) + start; - - m_mappedRegion = region; - - m_dataLayout.m_sysMem = data; - m_dataLayout.m_sysMemPitch = mipPitch; - m_dataLayout.m_sysMemSlicePitch = bufferSize; - - return S_OK; - } - - void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) - { - if( m_mappedRange.size == 0 ) - { - return; - } - - m_metalContext->IndicateBufferModified( m_mtlWriteBuffer, m_mappedRange.offset, m_mappedRange.size ); - - if( m_mappedRegion.HasBox() ) - { - MTLOrigin origin = MTLOriginMake( m_mappedRegion.m_box.left, m_mappedRegion.m_box.top, m_mappedRegion.m_box.front ); + CCP_ASSERT( region.m_startFace == 0 && region.m_endFace == 1 ); - MTLSize size = MTLSizeMake( - MAX( MIN( m_mappedRegion.GetWidth(), m_desc.GetMipWidth( m_mappedRegion.m_startMipLevel ) ), 1), - MAX( MIN( m_mappedRegion.GetHeight(), m_desc.GetMipHeight( m_mappedRegion.m_startMipLevel ) ), 1), - MAX( MIN( m_mappedRegion.GetDepth(), m_desc.GetMipDepth( m_mappedRegion.m_startMipLevel ) ), 1) ); + auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); + auto bufferSize = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); - renderContext.GetMetalWorkQueue()->UploadTexture(m_mtlTexture, m_mtlWriteBuffer, m_mappedRegion.m_startFace, m_mappedRegion.m_startMipLevel, origin, size, m_dataLayout.m_sysMemPitch, m_dataLayout.m_sysMemSlicePitch, m_mappedRange.offset, false); + if( region.HasBox() ) + { + auto width = MAX( MIN( region.GetWidth(), m_desc.GetMipWidth( region.m_startMipLevel ) ), 1 ); + auto height = MAX( MIN( region.GetHeight(), m_desc.GetMipHeight( region.m_startMipLevel ) ), 1 ); + auto depth = MAX( MIN( region.GetDepth(), m_desc.GetMipDepth( region.m_startMipLevel ) ), 1 ); + if( m_desc.IsCompressed() ) + { + mipPitch = MAX( width / 4u, 1 ) * GetBlockByteSize( m_desc.GetFormat() ); } else { - renderContext.GetMetalWorkQueue()->UploadTexture(m_mtlTexture, m_mtlWriteBuffer, m_mappedRegion.m_startFace, m_mappedRegion.m_startMipLevel, m_dataLayout.m_sysMemPitch, m_dataLayout.m_sysMemSlicePitch, m_mappedRange.offset, false); + mipPitch = width * GetBytesPerPixel( m_desc.GetFormat() ); } - - m_dataLayout.m_sysMem = nullptr; - m_dataLayout.m_sysMemPitch = 0; - m_dataLayout.m_sysMemSlicePitch = 0; - m_mappedRange.size = 0; + bufferSize = mipPitch * height * depth; } - ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ) + auto renderedFrame = metalContext->GetRenderedFrameNumber(); + + while( !m_mappedRanges.empty() ) { - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + auto& r = m_mappedRanges.front(); + if( r.frame < renderedFrame ) { - return E_INVALIDCALL; + m_mappedRanges.erase( m_mappedRanges.begin() ); } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + else { - return E_INVALIDCALL; + break; } + } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + if( !m_mtlWriteBuffer ) + { + m_mtlWriteBuffer = metalContext->CreateMetalBuffer( + renderContext.GetMetalWorkQueue(), m_desc.GetMipSize( 0 ), MTLResourceStorageModeManaged, nil ); + m_memory.Grow( m_mtlWriteBuffer.length ); + } + uint32_t start = 0; + if( !m_mappedRanges.empty() ) + { + auto head = m_mappedRanges.front().offset; + auto tail = m_mappedRanges.back().offset + m_mappedRanges.back().size; - if( !region.IsValidForBitmap( m_desc ) ) + if( head < tail ) { - return E_INVALIDARG; + if( tail + bufferSize <= m_mtlWriteBuffer.length ) + { + start = tail; + } + else if( bufferSize <= head ) + { + auto remainder = m_mtlWriteBuffer.length - tail; + start = 0; + } + else + { + m_memory.Shrink( m_mtlWriteBuffer.length ); + metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); + m_mtlWriteBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), + m_desc.GetMipSize( 0 ) + m_mtlWriteBuffer.length, + MTLResourceStorageModeManaged, + nil ); + m_memory.Grow( m_mtlWriteBuffer.length ); + m_mappedRanges.clear(); + start = 0; + } } - if( !region.IsSingleSubresource() ) + else { - return E_INVALIDARG; + if( tail + bufferSize <= head ) + { + start = tail; + } + else + { + m_memory.Shrink( m_mtlWriteBuffer.length ); + metalContext->DestroyMetalBuffer( m_mtlWriteBuffer ); + m_mtlWriteBuffer = metalContext->CreateMetalBuffer( renderContext.GetMetalWorkQueue(), + m_desc.GetMipSize( 0 ) + m_mtlWriteBuffer.length, + MTLResourceStorageModeManaged, + nil ); + m_memory.Grow( m_mtlWriteBuffer.length ); + m_mappedRanges.clear(); + start = 0; + } } + } - void* dest; - uint32_t destPitch; - FORWARD_HR( MapForWriting( region, dest, destPitch, renderContext ) ); + m_mappedRange = { start, bufferSize, metalContext->GetRecordingFrameNumber() }; + m_mappedRanges.push_back( m_mappedRange ); - auto clamped = region; - clamped.ClampToTexture( m_desc ); + pitch = mipPitch; + data = static_cast( m_mtlWriteBuffer.contents ) + start; - auto bpp = Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); - auto width = clamped.m_box.GetWidth(); - width *= bpp; - auto depthSlice = static_cast( source ); + m_mappedRegion = region; - for( uint32_t j = clamped.m_box.front; j != clamped.m_box.back; ++j ) - { - auto src = depthSlice; - for( uint32_t i = clamped.m_box.top; i != clamped.m_box.bottom; ++i ) - { - memcpy( dest, src, width ); - dest = static_cast( dest ) + destPitch; - src += pitch; - } - depthSlice += slicePitch; - } - UnmapForWriting( renderContext ); + m_dataLayout.m_sysMem = data; + m_dataLayout.m_sysMemPitch = mipPitch; + m_dataLayout.m_sysMemSlicePitch = bufferSize; - return S_OK; + return S_OK; +} + +void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& renderContext ) +{ + if( m_mappedRange.size == 0 ) + { + return; } - ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) + m_metalContext->IndicateBufferModified( m_mtlWriteBuffer, m_mappedRange.offset, m_mappedRange.size ); + + if( m_mappedRegion.HasBox() ) { - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !source.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) - { - return E_INVALIDCALL; - } + MTLOrigin origin = + MTLOriginMake( m_mappedRegion.m_box.left, m_mappedRegion.m_box.top, m_mappedRegion.m_box.front ); + + MTLSize size = MTLSizeMake( + MAX( MIN( m_mappedRegion.GetWidth(), m_desc.GetMipWidth( m_mappedRegion.m_startMipLevel ) ), 1 ), + MAX( MIN( m_mappedRegion.GetHeight(), m_desc.GetMipHeight( m_mappedRegion.m_startMipLevel ) ), 1 ), + MAX( MIN( m_mappedRegion.GetDepth(), m_desc.GetMipDepth( m_mappedRegion.m_startMipLevel ) ), 1 ) ); + + renderContext.GetMetalWorkQueue()->UploadTexture( m_mtlTexture, + m_mtlWriteBuffer, + m_mappedRegion.m_startFace, + m_mappedRegion.m_startMipLevel, + origin, + size, + m_dataLayout.m_sysMemPitch, + m_dataLayout.m_sysMemSlicePitch, + m_mappedRange.offset, + false ); + } + else + { + renderContext.GetMetalWorkQueue()->UploadTexture( m_mtlTexture, + m_mtlWriteBuffer, + m_mappedRegion.m_startFace, + m_mappedRegion.m_startMipLevel, + m_dataLayout.m_sysMemPitch, + m_dataLayout.m_sysMemSlicePitch, + m_mappedRange.offset, + false ); + } - Tr2TextureSubresource src = sourceSubresource; - Tr2TextureSubresource dst = destSubresource; + m_dataLayout.m_sysMem = nullptr; + m_dataLayout.m_sysMemPitch = 0; + m_dataLayout.m_sysMemSlicePitch = 0; + m_mappedRange.size = 0; +} - if( !Crop( src, source.m_desc, dst, m_desc ) ) - { - return E_FAIL; - } +ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, + const void* source, + uint32_t pitch, + uint32_t slicePitch, + Tr2RenderContextAL& renderContext ) +{ + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + return E_INVALIDCALL; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; + } - MetalContext* metalContext = renderContext.GetMetalContext(); - - uint32_t slices = src.m_endFace - src.m_startFace; - uint32_t mips = src.m_endMipLevel - src.m_startMipLevel; - - for( uint32_t slice = 0; slice < slices; ++slice ) - { - for( uint32_t mip = 0; mip < mips; ++mip ) - { - renderContext.GetMetalWorkQueue()->CopyTextureToTexture( - source.GetMetalTexture(), - src.m_startFace + slice, - src.m_startMipLevel + mip, - MTLOriginMake( src.m_box.left, src.m_box.top, src.m_box.front ), - MTLSizeMake( src.GetWidth(), src.GetHeight(), src.GetDepth() ), - GetMetalTexture(), - dst.m_startFace + slice, - dst.m_startMipLevel + mip, - MTLOriginMake( dst.m_box.left, dst.m_box.top, dst.m_box.front ) ); - } - } + if( !IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } - return S_OK; + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; } - ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) + void* dest; + uint32_t destPitch; + FORWARD_HR( MapForWriting( region, dest, destPitch, renderContext ) ); + + auto clamped = region; + clamped.ClampToTexture( m_desc ); + + auto bpp = Tr2RenderContextEnum::GetBytesPerPixel( m_desc.GetFormat() ); + auto width = clamped.m_box.GetWidth(); + width *= bpp; + auto depthSlice = static_cast( source ); + + for( uint32_t j = clamped.m_box.front; j != clamped.m_box.back; ++j ) { - if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + auto src = depthSlice; + for( uint32_t i = clamped.m_box.top; i != clamped.m_box.bottom; ++i ) { - return E_INVALIDCALL; + memcpy( dest, src, width ); + dest = static_cast( dest ) + destPitch; + src += pitch; } + depthSlice += slicePitch; + } + UnmapForWriting( renderContext ); - renderContext.GetMetalWorkQueue()->GenerateMipMaps(m_mtlTexture); + return S_OK; +} - return S_OK; +ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, + Tr2TextureAL& source, + const Tr2TextureSubresource& sourceSubresource, + Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } + if( !source.IsValid() ) + { + return E_INVALIDARG; } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; + } + + Tr2TextureSubresource src = sourceSubresource; + Tr2TextureSubresource dst = destSubresource; - ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) + if( !Crop( src, source.m_desc, dst, m_desc ) ) { - if( m_msaa.samples <= 1 ) - { - return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); - } + return E_FAIL; + } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !destination.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) - { - return E_INVALIDARG; - } - if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) - { - return E_INVALIDARG; - } - if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) - { - return E_INVALIDARG; - } - if( destination.m_msaa.samples > 1 ) - { - return E_INVALIDARG; + MetalContext* metalContext = renderContext.GetMetalContext(); + + uint32_t slices = src.m_endFace - src.m_startFace; + uint32_t mips = src.m_endMipLevel - src.m_startMipLevel; + + for( uint32_t slice = 0; slice < slices; ++slice ) + { + for( uint32_t mip = 0; mip < mips; ++mip ) + { + renderContext.GetMetalWorkQueue()->CopyTextureToTexture( + source.GetMetalTexture(), + src.m_startFace + slice, + src.m_startMipLevel + mip, + MTLOriginMake( src.m_box.left, src.m_box.top, src.m_box.front ), + MTLSizeMake( src.GetWidth(), src.GetHeight(), src.GetDepth() ), + GetMetalTexture(), + dst.m_startFace + slice, + dst.m_startMipLevel + mip, + MTLOriginMake( dst.m_box.left, dst.m_box.top, dst.m_box.front ) ); } - - renderContext.GetMetalWorkQueue()->ResolveMsaa(GetMetalTexture(), destination.GetMetalTexture()); - - return S_OK; } - uintptr_t Tr2TextureAL::GetSharedHandle() const + return S_OK; +} + +ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) +{ + if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) { - return 0; + return E_INVALIDCALL; } - uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace space ) const + renderContext.GetMetalWorkQueue()->GenerateMipMaps( m_mtlTexture ); + + return S_OK; +} + +ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) +{ + if( m_msaa.samples <= 1 ) { - return m_srvHeapIndices[space]; + return destination.CopySubresourceRegion( + Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); } - - uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t mip ) const + + if( !IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } + if( !destination.IsValid() ) + { + return E_INVALIDARG; + } + if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) + { + return E_INVALIDARG; + } + if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) + { + return E_INVALIDARG; + } + if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) { - if( mip < m_uavHeapIndices.size() ) - { - return 0xffffffff; - } - return m_uavHeapIndices[mip]; + return E_INVALIDARG; } + if( destination.m_msaa.samples > 1 ) + { + return E_INVALIDARG; + } + + renderContext.GetMetalWorkQueue()->ResolveMsaa( GetMetalTexture(), destination.GetMetalTexture() ); - void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const + return S_OK; +} + +uintptr_t Tr2TextureAL::GetSharedHandle() const +{ + return 0; +} + +uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace space ) const +{ + return m_srvHeapIndices[space]; +} + +uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t mip ) const +{ + if( mip < m_uavHeapIndices.size() ) { - description["type"] = "Tr2TextureAL"; + return 0xffffffff; + } + return m_uavHeapIndices[mip]; +} - unsigned size = 0; - for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) - { - size += m_desc.GetMipSize( i ); - } +void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2TextureAL"; - description["size"] = std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); - description["width"] = std::to_string( m_desc.GetWidth() ); - description["height"] = std::to_string( m_desc.GetHeight() ); - description["depth"] = std::to_string( m_desc.GetDepth() ); - description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); - description["format"] = std::to_string( int( m_desc.GetFormat() ) ); - description["texType"] = std::to_string( int( m_desc.GetType() ) ); - description["array"] = std::to_string( m_desc.GetArraySize() ); - description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); - description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); - description["msaa"] = std::to_string( m_msaa.samples ); - description["name"] = m_name; - } - - ALResult Tr2TextureAL::SetName( const char* name ) - { - m_name = name; - auto nsname = [NSString stringWithUTF8String:name]; - if( m_mtlTexture ) - { - m_mtlTexture.label = nsname; - } - if( m_mtlTextureSRGBView ) - { - m_mtlTextureSRGBView.label = nsname; - } - for( auto& uav : m_mtlTextureUAV ) - { - uav.label = nsname; - } - return S_OK; + unsigned size = 0; + for( unsigned i = 0; i < m_desc.GetTrueMipCount(); ++i ) + { + size += m_desc.GetMipSize( i ); } - const char* Tr2TextureAL::GetName() const + description["size"] = + std::to_string( size * std::max( 1u, m_desc.GetArraySize() ) * std::max( 1u, m_msaa.samples ) ); + description["width"] = std::to_string( m_desc.GetWidth() ); + description["height"] = std::to_string( m_desc.GetHeight() ); + description["depth"] = std::to_string( m_desc.GetDepth() ); + description["mipLevels"] = std::to_string( m_desc.GetTrueMipCount() ); + description["format"] = std::to_string( int( m_desc.GetFormat() ) ); + description["texType"] = std::to_string( int( m_desc.GetType() ) ); + description["array"] = std::to_string( m_desc.GetArraySize() ); + description["cpuUsage"] = std::to_string( int( m_cpuUsage ) ); + description["gpuUsage"] = std::to_string( int( m_gpuUsage ) ); + description["msaa"] = std::to_string( m_msaa.samples ); + description["name"] = m_name; +} + +ALResult Tr2TextureAL::SetName( const char* name ) +{ + m_name = name; + auto nsname = [NSString stringWithUTF8String:name]; + if( m_mtlTexture ) { - return m_name.c_str(); + m_mtlTexture.label = nsname; } - - void Tr2TextureAL::AssignFromTexture( Tr2TextureAL& backBuffer ) + if( m_mtlTextureSRGBView ) { - Destroy(); - m_desc = backBuffer.m_desc; - m_msaa = backBuffer.m_msaa; - m_gpuUsage = backBuffer.m_gpuUsage; - m_cpuUsage = backBuffer.m_cpuUsage; - m_mtlTexture = backBuffer.m_mtlTexture; - m_mtlTextureSRGBView = backBuffer.m_mtlTextureSRGBView; - m_metalContext = backBuffer.m_metalContext; -#if !__has_feature(objc_arc) - [m_mtlTexture retain]; - [m_mtlTextureSRGBView retain]; -#endif + m_mtlTextureSRGBView.label = nsname; + } + for( auto& uav : m_mtlTextureUAV ) + { + uav.label = nsname; } + return S_OK; +} + +const char* Tr2TextureAL::GetName() const +{ + return m_name.c_str(); +} + +void Tr2TextureAL::AssignFromTexture( Tr2TextureAL& backBuffer ) +{ + Destroy(); + m_desc = backBuffer.m_desc; + m_msaa = backBuffer.m_msaa; + m_gpuUsage = backBuffer.m_gpuUsage; + m_cpuUsage = backBuffer.m_cpuUsage; + m_mtlTexture = backBuffer.m_mtlTexture; + m_mtlTextureSRGBView = backBuffer.m_mtlTextureSRGBView; + m_metalContext = backBuffer.m_metalContext; +#if !__has_feature( objc_arc ) + [m_mtlTexture retain]; + [m_mtlTextureSRGBView retain]; +#endif +} } #endif diff --git a/trinityal/metal/Tr2VertexLayoutALMetal.h b/trinityal/metal/Tr2VertexLayoutALMetal.h index 77f283ce5..a5a44df99 100644 --- a/trinityal/metal/Tr2VertexLayoutALMetal.h +++ b/trinityal/metal/Tr2VertexLayoutALMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../include/Tr2VertexLayoutAL.h" #include "../Tr2VertexDefinition.h" @@ -13,54 +13,58 @@ struct Tr2ShaderPipelineInputAL; namespace TrinityALImpl { - class Tr2VertexLayoutAL : public Tr2DeviceResourceAL - { - public: - Tr2VertexLayoutAL(); - ~Tr2VertexLayoutAL(); +class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +{ +public: + Tr2VertexLayoutAL(); + ~Tr2VertexLayoutAL(); - ALResult Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ); - bool IsValid() const; - void Destroy(); + ALResult Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ); + bool IsValid() const; + void Destroy(); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - void SetVertexLayout( const std::shared_ptr& shaderProgram, Tr2RenderContextAL& renderContext ); - void AddVertexDescriptor( size_t inputHash, MTLVertexDescriptor* descriptor, uint8_t streamMask, bool needsDummyStream ); - private: - Tr2VertexLayoutAL( const Tr2VertexLayoutAL& ) = delete; - Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& ) = delete; + void SetVertexLayout( const std::shared_ptr& shaderProgram, Tr2RenderContextAL& renderContext ); + void AddVertexDescriptor( size_t inputHash, MTLVertexDescriptor* descriptor, uint8_t streamMask, bool needsDummyStream ); - struct MetalVertexDescriptor - { - MTLVertexDescriptor* descriptor; - size_t baseHash; - uint8_t streamMask; - bool needsDummyStream; - }; +private: + Tr2VertexLayoutAL( const Tr2VertexLayoutAL& ) = delete; + Tr2VertexLayoutAL& operator=( const Tr2VertexLayoutAL& ) = delete; - struct Item - { - Tr2VertexDefinition::UsageCode m_usage; - unsigned m_usageIndex; - unsigned m_offset; - unsigned m_stream; + struct MetalVertexDescriptor + { + MTLVertexDescriptor* descriptor; + size_t baseHash; + uint8_t streamMask; + bool needsDummyStream; + }; - MTLVertexFormat m_format; - MTLVertexStepFunction m_stepFunction; - unsigned m_stepRate; - }; - - MetalVertexDescriptor GenerateVertexDescriptor( const std::vector& shaderInputs ) const; - void CalculateHash( MetalVertexDescriptor& result ) const; + struct Item + { + Tr2VertexDefinition::UsageCode m_usage; + unsigned m_usageIndex; + unsigned m_offset; + unsigned m_stream; - std::vector m_items; - Tr2RenderContextAL *m_renderContext; - std::unordered_map m_metalVertexDescriptors; - std::string m_name; + MTLVertexFormat m_format; + MTLVertexStepFunction m_stepFunction; + unsigned m_stepRate; }; + + MetalVertexDescriptor GenerateVertexDescriptor( const std::vector& shaderInputs ) const; + void CalculateHash( MetalVertexDescriptor& result ) const; + + std::vector m_items; + Tr2RenderContextAL* m_renderContext; + std::unordered_map m_metalVertexDescriptors; + std::string m_name; +}; } #endif diff --git a/trinityal/metal/Tr2VertexLayoutALMetal.mm b/trinityal/metal/Tr2VertexLayoutALMetal.mm index c6f9a74be..28fd68268 100644 --- a/trinityal/metal/Tr2VertexLayoutALMetal.mm +++ b/trinityal/metal/Tr2VertexLayoutALMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2VertexLayoutALMetal.h" #include "Tr2VertexDefinition.h" @@ -16,236 +16,242 @@ namespace TrinityALImpl { - Tr2VertexLayoutAL::Tr2VertexLayoutAL() - : m_renderContext( nullptr ) - { - } +Tr2VertexLayoutAL::Tr2VertexLayoutAL() : m_renderContext( nullptr ) +{ +} + +Tr2VertexLayoutAL::~Tr2VertexLayoutAL() +{ + Destroy(); +} - Tr2VertexLayoutAL::~Tr2VertexLayoutAL() +ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { - Destroy(); + return E_INVALIDCALL; } - ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ) + m_renderContext = &renderContext; + MetalContext* metalContext = m_renderContext->GetMetalContext(); + + for( const auto& src : definition.m_items ) { - Destroy(); + MTLVertexStepFunction metalStepFunction; + unsigned stepRate = src.m_instanceStepRate; - if( !renderContext.IsValid() ) + if( stepRate ) { - return E_INVALIDCALL; + metalStepFunction = MTLVertexStepFunctionPerInstance; } - - m_renderContext = &renderContext; - MetalContext* metalContext = m_renderContext->GetMetalContext(); - - for( const auto& src : definition.m_items ) + else { - MTLVertexStepFunction metalStepFunction; - unsigned stepRate = src.m_instanceStepRate; + metalStepFunction = MTLVertexStepFunctionPerVertex; + // Metal requires step rate to be 1 for per vertex function. + stepRate = 1; + } - if( stepRate ) - { - metalStepFunction = MTLVertexStepFunctionPerInstance; - } - else - { - metalStepFunction = MTLVertexStepFunctionPerVertex; - // Metal requires step rate to be 1 for per vertex function. - stepRate = 1; - } + MTLVertexFormat metalVertexFormat = metalContext->m_utils->GetMTLVertexFormat( src.m_dataType ); + CCP_ASSERT( metalVertexFormat != MTLVertexFormatInvalid ); - MTLVertexFormat metalVertexFormat = metalContext->m_utils->GetMTLVertexFormat( src.m_dataType ); - CCP_ASSERT( metalVertexFormat != MTLVertexFormatInvalid ); + Item dst; + dst.m_usage = src.m_usage; + dst.m_usageIndex = src.m_usageIndex; + dst.m_offset = src.m_offset; + dst.m_stream = src.m_stream; + dst.m_format = metalVertexFormat; + dst.m_stepFunction = metalStepFunction; + dst.m_stepRate = stepRate; - Item dst; - dst.m_usage = src.m_usage; - dst.m_usageIndex = src.m_usageIndex; - dst.m_offset = src.m_offset; - dst.m_stream = src.m_stream; - dst.m_format = metalVertexFormat; - dst.m_stepFunction = metalStepFunction; - dst.m_stepRate = stepRate; + m_items.push_back( dst ); + }; - m_items.push_back( dst ); - }; + return S_OK; +} - return S_OK; - } +bool Tr2VertexLayoutAL::IsValid() const +{ + return m_renderContext != nullptr; +} - bool Tr2VertexLayoutAL::IsValid() const +void Tr2VertexLayoutAL::Destroy() +{ + if( m_renderContext ) { - return m_renderContext != nullptr; - } + MetalContext* metalContext = m_renderContext->GetMetalContext(); - void Tr2VertexLayoutAL::Destroy() - { - if( m_renderContext ) + for( auto descriptor : m_metalVertexDescriptors ) { - MetalContext* metalContext = m_renderContext->GetMetalContext(); - - for( auto descriptor : m_metalVertexDescriptors ) - { - metalContext->DestroyVertexLayout( descriptor.second.descriptor ); - } - m_metalVertexDescriptors.clear(); + metalContext->DestroyVertexLayout( descriptor.second.descriptor ); } - m_items.clear(); - m_renderContext = nullptr; + m_metalVertexDescriptors.clear(); } + m_items.clear(); + m_renderContext = nullptr; +} - void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const - { - description["type"] = "Tr2VertexLayoutAL"; - description["name"] = m_name; - } +void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& description ) const +{ + description["type"] = "Tr2VertexLayoutAL"; + description["name"] = m_name; +} - ALResult Tr2VertexLayoutAL::SetName( const char* name ) - { - m_name = name; - return S_OK; - } +ALResult Tr2VertexLayoutAL::SetName( const char* name ) +{ + m_name = name; + return S_OK; +} - Tr2VertexLayoutAL::MetalVertexDescriptor Tr2VertexLayoutAL::GenerateVertexDescriptor( const std::vector& shaderInputs ) const - { - MetalContext* metalContext = m_renderContext->GetMetalContext(); - MetalVertexDescriptor result = { metalContext->CreateVertexLayout(), 0, 0, false }; +Tr2VertexLayoutAL::MetalVertexDescriptor + Tr2VertexLayoutAL::GenerateVertexDescriptor( const std::vector& shaderInputs ) const +{ + MetalContext* metalContext = m_renderContext->GetMetalContext(); + MetalVertexDescriptor result = { metalContext->CreateVertexLayout(), 0, 0, false }; - static_assert( - sizeof( result.streamMask ) * 8 >= METAL_VERTEX_STREAM_BUFFER_COUNT, - "Please use a type with more bits for m_vertexStreamMask." ); + static_assert( sizeof( result.streamMask ) * 8 >= METAL_VERTEX_STREAM_BUFFER_COUNT, + "Please use a type with more bits for m_vertexStreamMask." ); - for( auto& input : shaderInputs ) + for( auto& input : shaderInputs ) + { + bool found = false; + for( auto& item : m_items ) { - bool found = false; - for( auto& item : m_items ) + if( input.usage == item.m_usage && input.usageIndex == item.m_usageIndex ) { - if( input.usage == item.m_usage && input.usageIndex == item.m_usageIndex ) - { - auto attrIndex = input.registerIndex; - auto stream = item.m_stream; + auto attrIndex = input.registerIndex; + auto stream = item.m_stream; - result.descriptor.attributes[attrIndex].format = item.m_format; - result.descriptor.attributes[attrIndex].offset = item.m_offset; - result.descriptor.attributes[attrIndex].bufferIndex = stream; + result.descriptor.attributes[attrIndex].format = item.m_format; + result.descriptor.attributes[attrIndex].offset = item.m_offset; + result.descriptor.attributes[attrIndex].bufferIndex = stream; - result.descriptor.layouts[stream].stepFunction = item.m_stepFunction; - result.descriptor.layouts[stream].stepRate = item.m_stepRate; + result.descriptor.layouts[stream].stepFunction = item.m_stepFunction; + result.descriptor.layouts[stream].stepRate = item.m_stepRate; - result.streamMask |= 1 << stream; + result.streamMask |= 1 << stream; - found = true; - break; - } + found = true; + break; } + } - // Point any missing inputs at the dummy stream. - if( !found ) + // Point any missing inputs at the dummy stream. + if( !found ) + { + auto attrIndex = input.registerIndex; + switch( input.type ) { - auto attrIndex = input.registerIndex; - switch( input.type ) - { - case Tr2ShaderPipelineInputAL::INT: - result.descriptor.attributes[attrIndex].format = MTLVertexFormatChar4; - break; - case Tr2ShaderPipelineInputAL::UINT: - result.descriptor.attributes[attrIndex].format = MTLVertexFormatUChar4; - break; - default: - result.descriptor.attributes[attrIndex].format = MTLVertexFormatFloat4; - break; - } - result.descriptor.attributes[attrIndex].offset = 0; - result.descriptor.attributes[attrIndex].bufferIndex = METAL_VERTEX_STREAM_DUMMY; - result.descriptor.layouts[METAL_VERTEX_STREAM_DUMMY].stepFunction = MTLVertexStepFunctionConstant; - result.descriptor.layouts[METAL_VERTEX_STREAM_DUMMY].stepRate = 0; - - result.streamMask |= 1 << METAL_VERTEX_STREAM_DUMMY; - - result.needsDummyStream = true; + case Tr2ShaderPipelineInputAL::INT: + result.descriptor.attributes[attrIndex].format = MTLVertexFormatChar4; + break; + case Tr2ShaderPipelineInputAL::UINT: + result.descriptor.attributes[attrIndex].format = MTLVertexFormatUChar4; + break; + default: + result.descriptor.attributes[attrIndex].format = MTLVertexFormatFloat4; + break; } - } - CalculateHash( result ); + result.descriptor.attributes[attrIndex].offset = 0; + result.descriptor.attributes[attrIndex].bufferIndex = METAL_VERTEX_STREAM_DUMMY; + result.descriptor.layouts[METAL_VERTEX_STREAM_DUMMY].stepFunction = MTLVertexStepFunctionConstant; + result.descriptor.layouts[METAL_VERTEX_STREAM_DUMMY].stepRate = 0; + + result.streamMask |= 1 << METAL_VERTEX_STREAM_DUMMY; - return result; + result.needsDummyStream = true; + } } + CalculateHash( result ); - void Tr2VertexLayoutAL::CalculateHash( MetalVertexDescriptor& result ) const - { - auto hash_combine = []( std::size_t& seed, uint32_t v ) - { - std::hash hasher; - seed ^= hasher( v ) + 0x9e3779b9 + (seed << 6) + (seed >> 2); - }; - - size_t hashVal = 0; - unsigned int mask = result.streamMask; - for( int i = 0; mask && i < METAL_MAX_VERTEX_ATTRIBUTES; ++i ) - { - auto stream = result.descriptor.attributes[i].bufferIndex; - unsigned int flag = ( 1 << stream ); - if( mask & flag ) - { - hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].bufferIndex ); - hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].offset ); - hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].format ); - } - } - - mask = result.streamMask; - for( int i = 0; mask && i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) - { - unsigned int flag = ( 1 << i ); - if( mask & flag ) - { - hash_combine( hashVal, (uint32_t)result.descriptor.layouts[i].stepFunction ); - hash_combine( hashVal, (uint32_t)result.descriptor.layouts[i].stepRate ); - - mask = mask & ~flag; - } - } - result.baseHash = hashVal; - } - - void Tr2VertexLayoutAL::SetVertexLayout( const std::shared_ptr& shaderProgram, Tr2RenderContextAL& renderContext ) - { - MetalVertexDescriptor descriptor; + return result; +} - bool isInParallelEncoding = renderContext.GetMetalContext()->IsInParallelEncoding(); - - auto inputHash = shaderProgram->GetInputsHash(); - auto found = m_metalVertexDescriptors.find( inputHash ); - if( found != end( m_metalVertexDescriptors ) ) +void Tr2VertexLayoutAL::CalculateHash( MetalVertexDescriptor& result ) const +{ + auto hash_combine = []( std::size_t& seed, uint32_t v ) { + std::hash hasher; + seed ^= hasher( v ) + 0x9e3779b9 + ( seed << 6 ) + ( seed >> 2 ); + }; + + size_t hashVal = 0; + unsigned int mask = result.streamMask; + for( int i = 0; mask && i < METAL_MAX_VERTEX_ATTRIBUTES; ++i ) + { + auto stream = result.descriptor.attributes[i].bufferIndex; + unsigned int flag = ( 1 << stream ); + if( mask & flag ) { - descriptor = found->second; + hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].bufferIndex ); + hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].offset ); + hash_combine( hashVal, (uint32_t)result.descriptor.attributes[i].format ); } - else if( isInParallelEncoding ) - { - auto queue = renderContext.GetMetalWorkQueue(); - descriptor.descriptor = queue->GetCachedVertexDescriptor( this, inputHash, descriptor.streamMask, descriptor.needsDummyStream ); - if( !descriptor.descriptor ) - { - descriptor = GenerateVertexDescriptor( shaderProgram->GetInputs() ); - queue->CacheVertexDescriptor( this, inputHash, descriptor.descriptor, descriptor.streamMask, descriptor.needsDummyStream ); - } - } - else + } + + mask = result.streamMask; + for( int i = 0; mask && i < METAL_VERTEX_STREAM_BUFFER_COUNT; ++i ) + { + unsigned int flag = ( 1 << i ); + if( mask & flag ) { - descriptor = GenerateVertexDescriptor( shaderProgram->GetInputs() ); - m_metalVertexDescriptors[inputHash] = descriptor; + hash_combine( hashVal, (uint32_t)result.descriptor.layouts[i].stepFunction ); + hash_combine( hashVal, (uint32_t)result.descriptor.layouts[i].stepRate ); + + mask = mask & ~flag; } + } + result.baseHash = hashVal; +} + +void Tr2VertexLayoutAL::SetVertexLayout( const std::shared_ptr& shaderProgram, + Tr2RenderContextAL& renderContext ) +{ + MetalVertexDescriptor descriptor; + + bool isInParallelEncoding = renderContext.GetMetalContext()->IsInParallelEncoding(); - if( descriptor.needsDummyStream ) + auto inputHash = shaderProgram->GetInputsHash(); + auto found = m_metalVertexDescriptors.find( inputHash ); + if( found != end( m_metalVertexDescriptors ) ) + { + descriptor = found->second; + } + else if( isInParallelEncoding ) + { + auto queue = renderContext.GetMetalWorkQueue(); + descriptor.descriptor = + queue->GetCachedVertexDescriptor( this, inputHash, descriptor.streamMask, descriptor.needsDummyStream ); + if( !descriptor.descriptor ) { - renderContext.GetMetalWorkQueue()->SetVertexStream( METAL_VERTEX_STREAM_DUMMY, renderContext.GetMetalContext()->GetDummyBuffer(), sizeof(float) * 4, 0 ); + descriptor = GenerateVertexDescriptor( shaderProgram->GetInputs() ); + queue->CacheVertexDescriptor( + this, inputHash, descriptor.descriptor, descriptor.streamMask, descriptor.needsDummyStream ); } - renderContext.GetMetalWorkQueue()->SetCurrentVertexDescriptor( descriptor.descriptor, descriptor.streamMask, descriptor.baseHash ); + } + else + { + descriptor = GenerateVertexDescriptor( shaderProgram->GetInputs() ); + m_metalVertexDescriptors[inputHash] = descriptor; } - void Tr2VertexLayoutAL::AddVertexDescriptor( size_t inputHash, MTLVertexDescriptor* descriptor, uint8_t streamMask, bool needsDummyStream ) - { - auto& desc = m_metalVertexDescriptors[inputHash] = { descriptor, inputHash, streamMask, needsDummyStream }; - CalculateHash( desc ); - } + if( descriptor.needsDummyStream ) + { + renderContext.GetMetalWorkQueue()->SetVertexStream( + METAL_VERTEX_STREAM_DUMMY, renderContext.GetMetalContext()->GetDummyBuffer(), sizeof( float ) * 4, 0 ); + } + renderContext.GetMetalWorkQueue()->SetCurrentVertexDescriptor( + descriptor.descriptor, descriptor.streamMask, descriptor.baseHash ); +} + +void Tr2VertexLayoutAL::AddVertexDescriptor( size_t inputHash, + MTLVertexDescriptor* descriptor, + uint8_t streamMask, + bool needsDummyStream ) +{ + auto& desc = m_metalVertexDescriptors[inputHash] = { descriptor, inputHash, streamMask, needsDummyStream }; + CalculateHash( desc ); +} } #endif diff --git a/trinityal/metal/Tr2VideoAdapterInfoALMetal.h b/trinityal/metal/Tr2VideoAdapterInfoALMetal.h index 74db34265..10cac3459 100644 --- a/trinityal/metal/Tr2VideoAdapterInfoALMetal.h +++ b/trinityal/metal/Tr2VideoAdapterInfoALMetal.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../ALResult.h" #include "../Tr2RenderContextEnum.h" diff --git a/trinityal/metal/Tr2VideoAdapterInfoALMetal.mm b/trinityal/metal/Tr2VideoAdapterInfoALMetal.mm index e1c927219..9ddc26bca 100644 --- a/trinityal/metal/Tr2VideoAdapterInfoALMetal.mm +++ b/trinityal/metal/Tr2VideoAdapterInfoALMetal.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2VideoAdapterInfoALMetal.h" #include "Tr2AdapterStructures.h" @@ -15,233 +15,235 @@ namespace { - struct Display - { - CGDirectDisplayID displayID; - std::string name; - std::wstring description; - uint32_t vendorID; - uint32_t deviceID; - - std::vector modes; - }; - std::vector s_displays; - - void GetDisplayModes( CGDirectDisplayID display, std::vector& modes ) +struct Display +{ + CGDirectDisplayID displayID; + std::string name; + std::wstring description; + uint32_t vendorID; + uint32_t deviceID; + + std::vector modes; +}; +std::vector s_displays; + +void GetDisplayModes( CGDirectDisplayID display, std::vector& modes ) +{ + const CFStringRef keys[] = { kCGDisplayShowDuplicateLowResolutionModes }; + const CFBooleanRef values[] = { kCFBooleanTrue }; + auto dict = CFDictionaryCreate( nullptr, + (const void**)keys, + (const void**)values, + 1, + &kCFCopyStringDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks ); + + auto allModes = CGDisplayCopyAllDisplayModes( display, dict ); + CFRelease( dict ); + + auto count = CFArrayGetCount( allModes ); + + for( CFIndex i = 0; i < count; ++i ) { - const CFStringRef keys[] = { kCGDisplayShowDuplicateLowResolutionModes }; - const CFBooleanRef values[] = { kCFBooleanTrue }; - auto dict = CFDictionaryCreate( - nullptr, - (const void**)keys, - (const void**)values, - 1, - &kCFCopyStringDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks ); - - auto allModes = CGDisplayCopyAllDisplayModes( display, dict ); - CFRelease( dict ); - - auto count = CFArrayGetCount( allModes ); - - for( CFIndex i = 0; i < count; ++i ) + auto modeRef = (CGDisplayModeRef)CFArrayGetValueAtIndex( allModes, i ); + + Tr2DisplayModeInfo mode; + mode.format = PIXEL_FORMAT_B8G8R8X8_UNORM; + mode.width = (uint32_t)CGDisplayModeGetPixelWidth( modeRef ); + mode.height = (uint32_t)CGDisplayModeGetPixelHeight( modeRef ); + mode.refreshRateDenominator = 1; + mode.refreshRateNumerator = 1; + mode.scaling = DISPLAY_SCALING_UNSPECIFIED; + mode.scanlineOrdering = SCANLINE_ORDER_UNSPECIFIED; + + auto found = std::find_if( begin( modes ), end( modes ), [&mode]( auto& other ) { + return mode.width == other.width && mode.height == other.height; + } ); + if( found == end( modes ) ) { - auto modeRef = (CGDisplayModeRef)CFArrayGetValueAtIndex( allModes, i ); - - Tr2DisplayModeInfo mode; - mode.format = PIXEL_FORMAT_B8G8R8X8_UNORM; - mode.width = (uint32_t)CGDisplayModeGetPixelWidth( modeRef ); - mode.height = (uint32_t)CGDisplayModeGetPixelHeight( modeRef ); - mode.refreshRateDenominator = 1; - mode.refreshRateNumerator = 1; - mode.scaling = DISPLAY_SCALING_UNSPECIFIED; - mode.scanlineOrdering = SCANLINE_ORDER_UNSPECIFIED; - - auto found = std::find_if( begin( modes ), end( modes ), [&mode]( auto& other ) { - return mode.width == other.width && mode.height == other.height; - } ); - if( found == end( modes ) ) - { - modes.push_back( mode ); - } + modes.push_back( mode ); } - - std::sort( begin( modes ), end( modes ), []( auto& m1, auto& m2 ) { - if( m1.width == m2.width ) - { - return m1.height > m2.height; - } - return m1.width > m2.width; - } ); - CFRelease( allModes ); } - - uint32_t GetEntryProperty( io_registry_entry_t entry, CFStringRef propertyName ) - { - uint32_t value = 0; - CFTypeRef property = IORegistryEntrySearchCFProperty( entry, - kIOServicePlane, - propertyName, - kCFAllocatorDefault, - kIORegistryIterateRecursively | kIORegistryIterateParents ); - if( property ) + + std::sort( begin( modes ), end( modes ), []( auto& m1, auto& m2 ) { + if( m1.width == m2.width ) { - if( auto data = reinterpret_cast( CFDataGetBytePtr( (CFDataRef)property ) ) ) - { - value = *data; - } - CFRelease( property ); + return m1.height > m2.height; } - return value; - } + return m1.width > m2.width; + } ); + CFRelease( allModes ); +} - std::string ToString( NSString* string ) +uint32_t GetEntryProperty( io_registry_entry_t entry, CFStringRef propertyName ) +{ + uint32_t value = 0; + CFTypeRef property = IORegistryEntrySearchCFProperty( entry, + kIOServicePlane, + propertyName, + kCFAllocatorDefault, + kIORegistryIterateRecursively | kIORegistryIterateParents ); + if( property ) { - NSData* data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; - int32_t length = int32_t( [data length] ); - return std::string( reinterpret_cast( [data bytes] ), length ); + if( auto data = reinterpret_cast( CFDataGetBytePtr( (CFDataRef)property ) ) ) + { + value = *data; + } + CFRelease( property ); } + return value; +} - std::wstring ToWString( NSString* string ) - { - NSData* data = [string dataUsingEncoding:NSUTF32LittleEndianStringEncoding]; - int32_t length = int32_t( [data length] ) / sizeof( wchar_t ); - return std::wstring( reinterpret_cast( [data bytes] ), length ); - } +std::string ToString( NSString* string ) +{ + NSData* data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + int32_t length = int32_t( [data length] ); + return std::string( reinterpret_cast( [data bytes] ), length ); +} - io_service_t IOServicePortFromCGDisplayID( CGDirectDisplayID displayID ) - { - io_iterator_t iter; - io_service_t serv, servicePort = 0; +std::wstring ToWString( NSString* string ) +{ + NSData* data = [string dataUsingEncoding:NSUTF32LittleEndianStringEncoding]; + int32_t length = int32_t( [data length] ) / sizeof( wchar_t ); + return std::wstring( reinterpret_cast( [data bytes] ), length ); +} - CFMutableDictionaryRef matching = IOServiceMatching( "IODisplayConnect" ); - if( IOServiceGetMatchingServices( kIOMasterPortDefault, matching, &iter ) ) - { - return 0; - } +io_service_t IOServicePortFromCGDisplayID( CGDirectDisplayID displayID ) +{ + io_iterator_t iter; + io_service_t serv, servicePort = 0; - auto displayVendorID = CGDisplayVendorNumber( displayID ); - auto displayModelID = CGDisplayModelNumber( displayID ); - auto displaySerial = CGDisplaySerialNumber( displayID ); + CFMutableDictionaryRef matching = IOServiceMatching( "IODisplayConnect" ); + if( IOServiceGetMatchingServices( kIOMasterPortDefault, matching, &iter ) ) + { + return 0; + } - while( ( serv = IOIteratorNext( iter ) ) != 0 ) - { - CFIndex vendorID, productID, serialNumber; - Boolean success; + auto displayVendorID = CGDisplayVendorNumber( displayID ); + auto displayModelID = CGDisplayModelNumber( displayID ); + auto displaySerial = CGDisplaySerialNumber( displayID ); - auto info = IODisplayCreateInfoDictionary( serv, kIODisplayOnlyPreferredName ); - ON_BLOCK_EXIT( [&] { CFRelease( info ); } ); + while( ( serv = IOIteratorNext( iter ) ) != 0 ) + { + CFIndex vendorID, productID, serialNumber; + Boolean success; - auto vendorIDRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayVendorID ) ) ); - auto productIDRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayProductID ) ) ); - // Serial number no longer supported - //auto serialNumberRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplaySerialNumber ) ) ); + auto info = IODisplayCreateInfoDictionary( serv, kIODisplayOnlyPreferredName ); + ON_BLOCK_EXIT( [&] { CFRelease( info ); } ); - success = CFNumberGetValue( vendorIDRef, kCFNumberCFIndexType, &vendorID ); - success &= CFNumberGetValue( productIDRef, kCFNumberCFIndexType, &productID ); + auto vendorIDRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayVendorID ) ) ); + auto productIDRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayProductID ) ) ); + // Serial number no longer supported + //auto serialNumberRef = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplaySerialNumber ) ) ); - if( !success ) - { - continue; - } + success = CFNumberGetValue( vendorIDRef, kCFNumberCFIndexType, &vendorID ); + success &= CFNumberGetValue( productIDRef, kCFNumberCFIndexType, &productID ); - if( displayVendorID != (uint32_t)vendorID || displayModelID != (uint32_t)productID ) - { - continue; - } + if( !success ) + { + continue; + } - servicePort = serv; - break; + if( displayVendorID != (uint32_t)vendorID || displayModelID != (uint32_t)productID ) + { + continue; } - IOObjectRelease( iter ); - return servicePort; + servicePort = serv; + break; } - void RefreshDisplays() - { - s_displays.clear(); + IOObjectRelease( iter ); + return servicePort; +} + +void RefreshDisplays() +{ + s_displays.clear(); - id device = MTLCreateSystemDefaultDevice(); - if( !device ) + id device = MTLCreateSystemDefaultDevice(); + if( !device ) + { + return; + } + if( @available( macOS 10.15, * ) ) + { + if( ![device supportsFamily:MTLGPUFamilyMac1] ) { return; } - if( @available(macOS 10.15, *) ) - { - if( ![device supportsFamily:MTLGPUFamilyMac1] ) - { - return; - } - } + } + + std::wstring deviceDescription = ToWString( [device name] ); - std::wstring deviceDescription = ToWString( [device name] ); - - uint32_t vendorID = 0; - uint32_t deviceID = 0; - if( uint64_t regID = [device respondsToSelector: @selector(registryID)] ? device.registryID : 0 ) + uint32_t vendorID = 0; + uint32_t deviceID = 0; + if( uint64_t regID = [device respondsToSelector:@selector( registryID )] ? device.registryID : 0 ) + { + if( io_registry_entry_t entry = + IOServiceGetMatchingService( kIOMasterPortDefault, IORegistryEntryIDMatching( regID ) ) ) { - if( io_registry_entry_t entry = IOServiceGetMatchingService( kIOMasterPortDefault, IORegistryEntryIDMatching( regID ) ) ) + io_registry_entry_t parent; + if( IORegistryEntryGetParentEntry( entry, kIOServicePlane, &parent ) == kIOReturnSuccess ) { - io_registry_entry_t parent; - if( IORegistryEntryGetParentEntry( entry, kIOServicePlane, &parent ) == kIOReturnSuccess ) - { - vendorID = GetEntryProperty( parent, CFSTR( "vendor-id" ) ); - deviceID = GetEntryProperty( parent, CFSTR( "device-id" ) ); - IOObjectRelease( parent ); - } - IOObjectRelease( entry ); + vendorID = GetEntryProperty( parent, CFSTR( "vendor-id" ) ); + deviceID = GetEntryProperty( parent, CFSTR( "device-id" ) ); + IOObjectRelease( parent ); } + IOObjectRelease( entry ); } + } - uint32_t displayCount; - CGGetOnlineDisplayList(0, NULL, &displayCount); - std::unique_ptr displays( new CGDirectDisplayID[displayCount] ); - CGGetOnlineDisplayList( displayCount, displays.get(), &displayCount ); - for( uint32_t i = 0; i < displayCount; ++i ) + uint32_t displayCount; + CGGetOnlineDisplayList( 0, NULL, &displayCount ); + std::unique_ptr displays( new CGDirectDisplayID[displayCount] ); + CGGetOnlineDisplayList( displayCount, displays.get(), &displayCount ); + for( uint32_t i = 0; i < displayCount; ++i ) + { + if( !CGDisplayIsActive( displays[i] ) ) { - if( !CGDisplayIsActive( displays[i] ) ) - { - continue; - } + continue; + } - Display display = { displays[i] }; + Display display = { displays[i] }; - if( auto port = IOServicePortFromCGDisplayID( display.displayID ) ) + if( auto port = IOServicePortFromCGDisplayID( display.displayID ) ) + { + auto info = IODisplayCreateInfoDictionary( port, kIODisplayOnlyPreferredName ); + if( auto names = + static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayProductName ) ) ) ) { - auto info = IODisplayCreateInfoDictionary( port, kIODisplayOnlyPreferredName ); - if( auto names = static_cast( CFDictionaryGetValue( info, CFSTR( kDisplayProductName ) ) ) ) + CFStringRef value; + if( CFDictionaryGetValueIfPresent( names, CFSTR( "en_US" ), (const void**)&value ) ) { - CFStringRef value; - if( CFDictionaryGetValueIfPresent( names, CFSTR( "en_US" ), (const void**)&value ) ) - { - auto size = CFStringGetMaximumSizeForEncoding( CFStringGetLength(value), kCFStringEncodingWindowsLatin1 ); - std::unique_ptr name( new char[size + 1] ); - CFStringGetCString( value, name.get(), size + 1, kCFStringEncodingWindowsLatin1 ); - display.name = name.get(); - } + auto size = + CFStringGetMaximumSizeForEncoding( CFStringGetLength( value ), kCFStringEncodingWindowsLatin1 ); + std::unique_ptr name( new char[size + 1] ); + CFStringGetCString( value, name.get(), size + 1, kCFStringEncodingWindowsLatin1 ); + display.name = name.get(); } - CFRelease(info); } + CFRelease( info ); + } - display.description = deviceDescription; - display.vendorID = vendorID; - display.deviceID = deviceID; - - GetDisplayModes( displays[i], display.modes ); + display.description = deviceDescription; + display.vendorID = vendorID; + display.deviceID = deviceID; - if( CGDisplayIsMain( displays[i] ) ) - { - s_displays.insert( s_displays.begin(), display ); - } - else - { - s_displays.push_back( display ); - } + GetDisplayModes( displays[i], display.modes ); + + if( CGDisplayIsMain( displays[i] ) ) + { + s_displays.insert( s_displays.begin(), display ); + } + else + { + s_displays.push_back( display ); } } } +} ALResult Tr2VideoAdapterInfo::GetAdapterCount( unsigned& count ) { @@ -253,18 +255,17 @@ void RefreshDisplays() return S_OK; } -#define CHECK_ADAPTER \ - if( s_displays.empty() ) \ - { \ - RefreshDisplays(); \ - } \ - if( adapterIndex >= s_displays.size() ) \ - { \ - return E_INVALIDARG; \ - } - -ALResult Tr2VideoAdapterInfo::GetAdapterInfo( unsigned adapterIndex, - Tr2AdapterInfo& info ) +#define CHECK_ADAPTER \ + if( s_displays.empty() ) \ + { \ + RefreshDisplays(); \ + } \ + if( adapterIndex >= s_displays.size() ) \ + { \ + return E_INVALIDARG; \ + } + +ALResult Tr2VideoAdapterInfo::GetAdapterInfo( unsigned adapterIndex, Tr2AdapterInfo& info ) { CHECK_ADAPTER; @@ -283,7 +284,7 @@ void RefreshDisplays() giud.data1 = 0; giud.data2 = 0; giud.data3 = 0; - for( int i = 0; i < 8; i++) + for( int i = 0; i < 8; i++ ) { giud.data4[i] = 0; } @@ -291,8 +292,7 @@ void RefreshDisplays() return S_OK; } -ALResult Tr2VideoAdapterInfo::GetAdapterMonitor( unsigned adapterIndex, - void*& monitor ) +ALResult Tr2VideoAdapterInfo::GetAdapterMonitor( unsigned adapterIndex, void*& monitor ) { CHECK_ADAPTER; @@ -300,8 +300,7 @@ void RefreshDisplays() return S_OK; } -ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, - Tr2DisplayModeInfo& mode ) +ALResult Tr2VideoAdapterInfo::GetAdapterDisplayMode( unsigned adapterIndex, Tr2DisplayModeInfo& mode ) { CHECK_ADAPTER; @@ -314,7 +313,7 @@ void RefreshDisplays() { for( CFIndex i = 0, n = CFArrayGetCount( modes ); i < n; ++i ) { - CGDisplayModeRef currentMode = (CGDisplayModeRef) CFArrayGetValueAtIndex( modes, i ); + CGDisplayModeRef currentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex( modes, i ); uint32_t ioFlags = CGDisplayModeGetIOFlags( currentMode ); if( ioFlags & kDisplayModeNativeFlag ) @@ -344,8 +343,8 @@ void RefreshDisplays() } mode.format = PIXEL_FORMAT_B8G8R8A8_UNORM; - mode.width = (uint32_t) w; - mode.height = (uint32_t) h; + mode.width = (uint32_t)w; + mode.height = (uint32_t)h; mode.refreshRateDenominator = 1; mode.refreshRateNumerator = 1; mode.scaling = DISPLAY_SCALING_UNSPECIFIED; @@ -360,7 +359,7 @@ void RefreshDisplays() { CHECK_ADAPTER; - count = unsigned( s_displays[adapterIndex].modes.size() ); + count = unsigned( s_displays[adapterIndex].modes.size() ); return S_OK; } @@ -370,20 +369,19 @@ void RefreshDisplays() Tr2DisplayModeInfo& mode ) { CHECK_ADAPTER; - - auto& modes = s_displays[adapterIndex].modes; + + auto& modes = s_displays[adapterIndex].modes; if( modeIndex >= modes.size() ) { return E_INVALIDARG; } - - mode = modes[modeIndex]; + + mode = modes[modeIndex]; return S_OK; } -ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned adapterIndex, - unsigned& maxWidth ) +ALResult Tr2VideoAdapterInfo::GetAdapterMaxTextureWidth( unsigned adapterIndex, unsigned& maxWidth ) { CHECK_ADAPTER; @@ -463,14 +461,13 @@ void RefreshDisplays() return true; } -bool Tr2VideoAdapterInfo::AreAdaptersDifferent( unsigned adapter1, - unsigned adapter2 ) +bool Tr2VideoAdapterInfo::AreAdaptersDifferent( unsigned adapter1, unsigned adapter2 ) { - if ( adapter1 == adapter2 ) + if( adapter1 == adapter2 ) { return false; } - if ( adapter1 >= s_displays.size() || adapter2 >= s_displays.size() ) + if( adapter1 >= s_displays.size() || adapter2 >= s_displays.size() ) { return true; } diff --git a/trinityal/metal/upscaling/Tr2MetalFxUpscaling.h b/trinityal/metal/upscaling/Tr2MetalFxUpscaling.h index 5ac1d8672..0306d3b06 100644 --- a/trinityal/metal/upscaling/Tr2MetalFxUpscaling.h +++ b/trinityal/metal/upscaling/Tr2MetalFxUpscaling.h @@ -10,61 +10,61 @@ class Tr2MetalFxUpscalingTechnique : public Tr2UpscalingTechniqueAL { public: Tr2MetalFxUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); - ~Tr2MetalFxUpscalingTechnique(); + ~Tr2MetalFxUpscalingTechnique(); - virtual bool IsAvailable() const override; - virtual std::vector GetAvailableSettings() const override; - virtual bool IsTemporal() const override; + virtual bool IsAvailable() const override; + virtual std::vector GetAvailableSettings() const override; + virtual bool IsTemporal() const override; private: virtual Tr2UpscalingContextAL* CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) override; - bool m_temporal; + bool m_temporal; }; class Tr2MetalFxUpscalingContext : public Tr2UpscalingContextAL { public: Tr2MetalFxUpscalingContext( Tr2UpscalingAL::Setting setting, bool temporal, Tr2UpscalingAL::UpscalingContextParams params ); - ~Tr2MetalFxUpscalingContext(); + ~Tr2MetalFxUpscalingContext(); - virtual bool HasSharpening() const override; - virtual void UpdateJitter() override; + virtual bool HasSharpening() const override; + virtual void UpdateJitter() override; virtual uint32_t GetDispatchRequirements() const override; - - virtual Tr2UpscalingAL::Result Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) override; + + virtual Tr2UpscalingAL::Result Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) override; private: - void CreateTemporalScaler( ); - void CreateSpatialScaler( ); - - void SetSiliconUpscalingAmount( ); - void SetIntelUpscalingAmount( ); - - API_AVAILABLE(macos(13.0)) - id m_mfxSpatialScaler; - - bool m_setup; + void CreateTemporalScaler(); + void CreateSpatialScaler(); + + void SetSiliconUpscalingAmount(); + void SetIntelUpscalingAmount(); + + API_AVAILABLE( macos( 13.0 ) ) + id m_mfxSpatialScaler; + + bool m_setup; bool m_temporal; - Tr2UpscalingAL::JitterSequence m_jitterSequence; - - Tr2RenderContextAL& m_renderContext; - - struct TemporalScaler - { - API_AVAILABLE(macos(13.0)) - MTLFXTemporalScalerDescriptor* desc; - - API_AVAILABLE(macos(13.0)) - id temporalScaler; - - id device; - std::atomic canceled = false; - std::atomic created = false; - }; - - std::shared_ptr m_temporalScaler; - - friend class Tr2MetalFxUpscalingTechnique; + Tr2UpscalingAL::JitterSequence m_jitterSequence; + + Tr2RenderContextAL& m_renderContext; + + struct TemporalScaler + { + API_AVAILABLE( macos( 13.0 ) ) + MTLFXTemporalScalerDescriptor* desc; + + API_AVAILABLE( macos( 13.0 ) ) + id temporalScaler; + + id device; + std::atomic canceled = false; + std::atomic created = false; + }; + + std::shared_ptr m_temporalScaler; + + friend class Tr2MetalFxUpscalingTechnique; }; #endif diff --git a/trinityal/metal/upscaling/Tr2MetalFxUpscaling.mm b/trinityal/metal/upscaling/Tr2MetalFxUpscaling.mm index e2c5b05bc..08a352677 100644 --- a/trinityal/metal/upscaling/Tr2MetalFxUpscaling.mm +++ b/trinityal/metal/upscaling/Tr2MetalFxUpscaling.mm @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include #include "Tr2MetalFxUpscaling.h" @@ -13,93 +13,92 @@ namespace MetalUpscalingUtils { - id GetMetalTexture( const Tr2TextureAL* texture ) - { - if( texture && texture->TrinityALImpl_GetObject()) - { - return texture->TrinityALImpl_GetObject()->GetMetalTexture(); - } - return nil; - } +id GetMetalTexture( const Tr2TextureAL* texture ) +{ + if( texture && texture->TrinityALImpl_GetObject() ) + { + return texture->TrinityALImpl_GetObject()->GetMetalTexture(); + } + return nil; +} } namespace { -template -class WorkQueue +template class WorkQueue { public: - WorkQueue( Processor processor ) - : m_processor( processor ) - { - std::thread( [this]() { - Worker(); - } ).detach(); - } - - void Add( const std::shared_ptr& item ) - { - std::unique_lock lock( m_mutex ); - m_queue.push_back( item ); - m_added.notify_one(); - } - - void Process( const std::shared_ptr& item ) - { - m_processor( item ); - } + WorkQueue( Processor processor ) : m_processor( processor ) + { + std::thread( [this]() { Worker(); } ).detach(); + } + + void Add( const std::shared_ptr& item ) + { + std::unique_lock lock( m_mutex ); + m_queue.push_back( item ); + m_added.notify_one(); + } + + void Process( const std::shared_ptr& item ) + { + m_processor( item ); + } + private: - void Worker() - { - for( ;; ) - { - m_processor( GetItem() ); - } - } - - std::shared_ptr GetItem() - { - for( ;; ) - { - std::unique_lock scope( m_mutex ); - if( !m_queue.empty() ) - { - auto item = m_queue.front(); - m_queue.erase( m_queue.begin() ); - return item; - } - m_added.wait( scope, [this] { return !m_queue.empty(); } ); - } - } - - std::mutex m_mutex; - std::condition_variable m_added; - std::vector> m_queue; - Processor m_processor; + void Worker() + { + for( ;; ) + { + m_processor( GetItem() ); + } + } + + std::shared_ptr GetItem() + { + for( ;; ) + { + std::unique_lock scope( m_mutex ); + if( !m_queue.empty() ) + { + auto item = m_queue.front(); + m_queue.erase( m_queue.begin() ); + return item; + } + m_added.wait( scope, [this] { return !m_queue.empty(); } ); + } + } + + std::mutex m_mutex; + std::condition_variable m_added; + std::vector> m_queue; + Processor m_processor; }; } -Tr2MetalFxUpscalingTechnique::Tr2MetalFxUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ): - Tr2UpscalingTechniqueAL( renderContext, technique, setting, frameGeneration, adapter ), - m_temporal( false ) +Tr2MetalFxUpscalingTechnique::Tr2MetalFxUpscalingTechnique( Tr2RenderContextAL& renderContext, + Tr2UpscalingAL::Technique technique, + Tr2UpscalingAL::Setting setting, + bool frameGeneration, + uint32_t adapter ) : + Tr2UpscalingTechniqueAL( renderContext, technique, setting, frameGeneration, adapter ), m_temporal( false ) { - if( @available(macOS 13.0, *) ) - { - TrinityALImpl::MetalContext* metalContext = m_renderContext.GetPrimaryRenderContext().GetMetalContext(); - auto device = metalContext->GetDevice(); - - // need to check if system supports temporal upscalers - m_temporal = [MTLFXTemporalScalerDescriptor supportsDevice:device]; - } - this->SanitizeState(); + if( @available( macOS 13.0, * ) ) + { + TrinityALImpl::MetalContext* metalContext = m_renderContext.GetPrimaryRenderContext().GetMetalContext(); + auto device = metalContext->GetDevice(); + + // need to check if system supports temporal upscalers + m_temporal = [MTLFXTemporalScalerDescriptor supportsDevice:device]; + } + this->SanitizeState(); } Tr2MetalFxUpscalingTechnique::~Tr2MetalFxUpscalingTechnique() { - } bool Tr2MetalFxUpscalingTechnique::IsTemporal() const @@ -107,72 +106,70 @@ void Worker() return m_temporal; } - bool Tr2MetalFxUpscalingTechnique::IsAvailable() const +bool Tr2MetalFxUpscalingTechnique::IsAvailable() const { - if( @available(macOS 13.0, *) ) - { - return true; - } - CCP_LOGNOTICE( "MetalFX upscaling is not supported for MacOS < 13.0" ); - return false; -} - -Tr2UpscalingContextAL* Tr2MetalFxUpscalingTechnique::CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) + if( @available( macOS 13.0, * ) ) + { + return true; + } + CCP_LOGNOTICE( "MetalFX upscaling is not supported for MacOS < 13.0" ); + return false; +} + +Tr2UpscalingContextAL* + Tr2MetalFxUpscalingTechnique::CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) { - return new Tr2MetalFxUpscalingContext( m_setting, m_temporal, params ); + return new Tr2MetalFxUpscalingContext( m_setting, m_temporal, params ); } -std::vector Tr2MetalFxUpscalingTechnique::GetAvailableSettings() const { - if( m_temporal ) +std::vector Tr2MetalFxUpscalingTechnique::GetAvailableSettings() const +{ + if( m_temporal ) { - return { - Tr2UpscalingAL::Setting::ULTRA_QUALITY, - Tr2UpscalingAL::Setting::QUALITY, - Tr2UpscalingAL::Setting::BALANCED, - Tr2UpscalingAL::Setting::PERFORMANCE, - Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE - }; + return { Tr2UpscalingAL::Setting::ULTRA_QUALITY, + Tr2UpscalingAL::Setting::QUALITY, + Tr2UpscalingAL::Setting::BALANCED, + Tr2UpscalingAL::Setting::PERFORMANCE, + Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE }; } - return { - Tr2UpscalingAL::Setting::QUALITY, - Tr2UpscalingAL::Setting::BALANCED, - Tr2UpscalingAL::Setting::PERFORMANCE, - Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE - }; + return { Tr2UpscalingAL::Setting::QUALITY, + Tr2UpscalingAL::Setting::BALANCED, + Tr2UpscalingAL::Setting::PERFORMANCE, + Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE }; } -Tr2MetalFxUpscalingContext::Tr2MetalFxUpscalingContext( Tr2UpscalingAL::Setting setting, bool temporal, Tr2UpscalingAL::UpscalingContextParams params ) : - Tr2UpscalingContextAL( setting, false, params ), - m_setup( false ), - m_renderContext( params.renderContext ) +Tr2MetalFxUpscalingContext::Tr2MetalFxUpscalingContext( Tr2UpscalingAL::Setting setting, + bool temporal, + Tr2UpscalingAL::UpscalingContextParams params ) : + Tr2UpscalingContextAL( setting, false, params ), m_setup( false ), m_renderContext( params.renderContext ) { - if( @available(macOS 13.0, *) ) + if( @available( macOS 13.0, * ) ) { m_mfxSpatialScaler = nil; - + m_jitterXScale = 1.0f; m_jitterYScale = -1.0f; m_temporal = temporal; - auto queue = m_renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); - if( queue->IsSilicon() ) - { - SetSiliconUpscalingAmount(); - } - else - { - SetIntelUpscalingAmount(); - } - + auto queue = m_renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); + if( queue->IsSilicon() ) + { + SetSiliconUpscalingAmount(); + } + else + { + SetIntelUpscalingAmount(); + } + m_renderWidth = Tr2UpscalingAL::ConvertDisplaySizeToRenderSize( m_displayWidth, m_upscaling ); m_renderHeight = Tr2UpscalingAL::ConvertDisplaySizeToRenderSize( m_displayHeight, m_upscaling ); - + if( m_temporal ) { CreateTemporalScaler(); m_jitterSequence = Tr2UpscalingAL::GenerateHaltonSequence( 8 * m_upscaling * m_upscaling, 2, 3 ); } CreateSpatialScaler(); - + if( m_mfxSpatialScaler == nil ) { return; @@ -181,258 +178,263 @@ void Worker() } } -Tr2MetalFxUpscalingContext::~Tr2MetalFxUpscalingContext() { - - if( @available(macos 13.0, *) ) +Tr2MetalFxUpscalingContext::~Tr2MetalFxUpscalingContext() +{ + + if( @available( macos 13.0, * ) ) { if( m_temporalScaler ) { m_temporalScaler->canceled = true; - if( m_temporalScaler->created ) - { - m_renderContext.ReleaseLater( m_temporalScaler->temporalScaler ); - } + if( m_temporalScaler->created ) + { + m_renderContext.ReleaseLater( m_temporalScaler->temporalScaler ); + } } m_mfxSpatialScaler = nil; } } -void Tr2MetalFxUpscalingContext::SetSiliconUpscalingAmount() +void Tr2MetalFxUpscalingContext::SetSiliconUpscalingAmount() { - switch( m_setting ) - { - case Tr2UpscalingAL::Setting::ULTRA_QUALITY: - m_upscaling = 1.1; // ultra quality is only available on temporal upscaler - break; - case Tr2UpscalingAL::Setting::QUALITY: - m_upscaling = 1.4; - break; - case Tr2UpscalingAL::Setting::BALANCED: - m_upscaling = 1.7; - break; - case Tr2UpscalingAL::Setting::PERFORMANCE: - m_upscaling = 2.0; - break; - case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: - m_upscaling = 2.3; - break; - default: - m_upscaling = 1.0; - break; - } + switch( m_setting ) + { + case Tr2UpscalingAL::Setting::ULTRA_QUALITY: + m_upscaling = 1.1; // ultra quality is only available on temporal upscaler + break; + case Tr2UpscalingAL::Setting::QUALITY: + m_upscaling = 1.4; + break; + case Tr2UpscalingAL::Setting::BALANCED: + m_upscaling = 1.7; + break; + case Tr2UpscalingAL::Setting::PERFORMANCE: + m_upscaling = 2.0; + break; + case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: + m_upscaling = 2.3; + break; + default: + m_upscaling = 1.0; + break; + } } -void Tr2MetalFxUpscalingContext::SetIntelUpscalingAmount() +void Tr2MetalFxUpscalingContext::SetIntelUpscalingAmount() { - if( m_temporal ) - { - switch( m_setting ) - { - case Tr2UpscalingAL::Setting::ULTRA_QUALITY: - m_upscaling = 1.1; // ultra quality is only available on temporal upscaler - break; - case Tr2UpscalingAL::Setting::QUALITY: - m_upscaling = 1.4; - break; - case Tr2UpscalingAL::Setting::BALANCED: - m_upscaling = 1.6; - break; - case Tr2UpscalingAL::Setting::PERFORMANCE: - m_upscaling = 1.8; - break; - case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: - m_upscaling = 2.0; - break; - default: - m_upscaling = 1.0; - break; - } - } - else - { - switch( m_setting ) - { - case Tr2UpscalingAL::Setting::QUALITY: - m_upscaling = 1.25; - break; - case Tr2UpscalingAL::Setting::BALANCED: - m_upscaling = 1.5; - break; - case Tr2UpscalingAL::Setting::PERFORMANCE: - m_upscaling = 1.75; - break; - case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: - m_upscaling = 2.0; - break; - default: - m_upscaling = 1.0; - break; - } - } + if( m_temporal ) + { + switch( m_setting ) + { + case Tr2UpscalingAL::Setting::ULTRA_QUALITY: + m_upscaling = 1.1; // ultra quality is only available on temporal upscaler + break; + case Tr2UpscalingAL::Setting::QUALITY: + m_upscaling = 1.4; + break; + case Tr2UpscalingAL::Setting::BALANCED: + m_upscaling = 1.6; + break; + case Tr2UpscalingAL::Setting::PERFORMANCE: + m_upscaling = 1.8; + break; + case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: + m_upscaling = 2.0; + break; + default: + m_upscaling = 1.0; + break; + } + } + else + { + switch( m_setting ) + { + case Tr2UpscalingAL::Setting::QUALITY: + m_upscaling = 1.25; + break; + case Tr2UpscalingAL::Setting::BALANCED: + m_upscaling = 1.5; + break; + case Tr2UpscalingAL::Setting::PERFORMANCE: + m_upscaling = 1.75; + break; + case Tr2UpscalingAL::Setting::ULTRA_PERFORMANCE: + m_upscaling = 2.0; + break; + default: + m_upscaling = 1.0; + break; + } + } } void Tr2MetalFxUpscalingContext::CreateTemporalScaler() { - if( @available(macOS 13.0, *) ) - { - static WorkQueue& )> s_queue( []( auto scaler ) { - if( !scaler->canceled ) - { - scaler->temporalScaler = [scaler->desc newTemporalScalerWithDevice:scaler->device]; - if( scaler->temporalScaler == nil ) - { - CCP_LOGERR("Could not create a MetalFX Temporal Scaler"); - return; - } - scaler->temporalScaler.motionVectorScaleX = scaler->desc.inputWidth; - scaler->temporalScaler.motionVectorScaleY = scaler->desc.inputHeight; - scaler->created = true; - } - } ); - - auto& renderContext = m_params.renderContext; - - TrinityALImpl::MetalContext* metalContext = renderContext.GetPrimaryRenderContext().GetMetalContext(); - auto pixelFormat = metalContext->m_utils->GetMTLPixelFormat( m_params.sourceFormat ); - auto depthPixelFormat = metalContext->m_utils->GetMTLPixelFormat( Tr2RenderContextEnum::ConvertDepthStencilFormat( m_params.depthFormat ) ); - // motion pixel format is always the same, true as of April 2024 - auto motionPixelFormat = metalContext->m_utils->GetMTLPixelFormat( Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_FLOAT ); - - auto device = metalContext->GetDevice(); - - MTLFXTemporalScalerDescriptor* desc = [MTLFXTemporalScalerDescriptor new]; - desc.inputWidth = m_renderWidth; - desc.inputHeight = m_renderHeight; - desc.outputWidth = m_displayWidth; - desc.outputHeight = m_displayHeight; - desc.colorTextureFormat = pixelFormat; - desc.depthTextureFormat = depthPixelFormat; - desc.motionTextureFormat = motionPixelFormat; - desc.outputTextureFormat = pixelFormat; - - m_temporalScaler = std::make_shared(); - m_temporalScaler->desc = desc; - m_temporalScaler->device = device; - - s_queue.Add( m_temporalScaler ); - } + if( @available( macOS 13.0, * ) ) + { + static WorkQueue& )> s_queue( + []( auto scaler ) { + if( !scaler->canceled ) + { + scaler->temporalScaler = [scaler->desc newTemporalScalerWithDevice:scaler->device]; + if( scaler->temporalScaler == nil ) + { + CCP_LOGERR( "Could not create a MetalFX Temporal Scaler" ); + return; + } + scaler->temporalScaler.motionVectorScaleX = scaler->desc.inputWidth; + scaler->temporalScaler.motionVectorScaleY = scaler->desc.inputHeight; + scaler->created = true; + } + } ); + + auto& renderContext = m_params.renderContext; + + TrinityALImpl::MetalContext* metalContext = renderContext.GetPrimaryRenderContext().GetMetalContext(); + auto pixelFormat = metalContext->m_utils->GetMTLPixelFormat( m_params.sourceFormat ); + auto depthPixelFormat = metalContext->m_utils->GetMTLPixelFormat( + Tr2RenderContextEnum::ConvertDepthStencilFormat( m_params.depthFormat ) ); + // motion pixel format is always the same, true as of April 2024 + auto motionPixelFormat = + metalContext->m_utils->GetMTLPixelFormat( Tr2RenderContextEnum::PIXEL_FORMAT_R16G16_FLOAT ); + + auto device = metalContext->GetDevice(); + + MTLFXTemporalScalerDescriptor* desc = [MTLFXTemporalScalerDescriptor new]; + desc.inputWidth = m_renderWidth; + desc.inputHeight = m_renderHeight; + desc.outputWidth = m_displayWidth; + desc.outputHeight = m_displayHeight; + desc.colorTextureFormat = pixelFormat; + desc.depthTextureFormat = depthPixelFormat; + desc.motionTextureFormat = motionPixelFormat; + desc.outputTextureFormat = pixelFormat; + + m_temporalScaler = std::make_shared(); + m_temporalScaler->desc = desc; + m_temporalScaler->device = device; + + s_queue.Add( m_temporalScaler ); + } } void Tr2MetalFxUpscalingContext::CreateSpatialScaler() { - if( @available(macOS 13.0, *) ) - { - auto& renderContext = m_params.renderContext; - - TrinityALImpl::MetalContext* metalContext = renderContext.GetPrimaryRenderContext().GetMetalContext(); - auto pixelFormat = metalContext->m_utils->GetMTLPixelFormat( m_params.sourceFormat ); - auto device = metalContext->GetDevice(); - - MTLFXSpatialScalerDescriptor* desc = [MTLFXSpatialScalerDescriptor new]; - - desc.inputWidth = m_renderWidth; - desc.inputHeight = m_renderHeight; - desc.outputWidth = m_displayWidth; - desc.outputHeight = m_displayHeight; - - desc.colorTextureFormat = pixelFormat; - desc.outputTextureFormat = pixelFormat; - desc.colorProcessingMode = MTLFXSpatialScalerColorProcessingMode::MTLFXSpatialScalerColorProcessingModeLinear; - - m_mfxSpatialScaler = [desc newSpatialScalerWithDevice:device]; - - if( m_mfxSpatialScaler == nil ) - { - CCP_LOGERR("Could not create a MetalFX Spatial Scaler"); - } - } + if( @available( macOS 13.0, * ) ) + { + auto& renderContext = m_params.renderContext; + + TrinityALImpl::MetalContext* metalContext = renderContext.GetPrimaryRenderContext().GetMetalContext(); + auto pixelFormat = metalContext->m_utils->GetMTLPixelFormat( m_params.sourceFormat ); + auto device = metalContext->GetDevice(); + + MTLFXSpatialScalerDescriptor* desc = [MTLFXSpatialScalerDescriptor new]; + + desc.inputWidth = m_renderWidth; + desc.inputHeight = m_renderHeight; + desc.outputWidth = m_displayWidth; + desc.outputHeight = m_displayHeight; + + desc.colorTextureFormat = pixelFormat; + desc.outputTextureFormat = pixelFormat; + desc.colorProcessingMode = MTLFXSpatialScalerColorProcessingMode::MTLFXSpatialScalerColorProcessingModeLinear; + + m_mfxSpatialScaler = [desc newSpatialScalerWithDevice:device]; + + if( m_mfxSpatialScaler == nil ) + { + CCP_LOGERR( "Could not create a MetalFX Spatial Scaler" ); + } + } } -bool Tr2MetalFxUpscalingContext::HasSharpening() const { - return false; +bool Tr2MetalFxUpscalingContext::HasSharpening() const +{ + return false; } void Tr2MetalFxUpscalingContext::UpdateJitter() { - if( m_temporal && m_temporalScaler && m_temporalScaler->created ) - { - m_jitterX = m_jitterSequence[m_jitterIndex].first; - m_jitterY = m_jitterSequence[m_jitterIndex].second; + if( m_temporal && m_temporalScaler && m_temporalScaler->created ) + { + m_jitterX = m_jitterSequence[m_jitterIndex].first; + m_jitterY = m_jitterSequence[m_jitterIndex].second; - m_jitterIndex = ++m_jitterIndex % m_jitterSequence.size(); - } + m_jitterIndex = ++m_jitterIndex % m_jitterSequence.size(); + } } uint32_t Tr2MetalFxUpscalingContext::GetDispatchRequirements() const { - if( m_temporal ) - { - return Tr2UpscalingAL::DispatchRequirements::VELOCITY & Tr2UpscalingAL::DispatchRequirements::DEPTH; - } - return 0; + if( m_temporal ) + { + return Tr2UpscalingAL::DispatchRequirements::VELOCITY & Tr2UpscalingAL::DispatchRequirements::DEPTH; + } + return 0; } Tr2UpscalingAL::Result Tr2MetalFxUpscalingContext::Dispatch( Tr2UpscalingAL::DispatchParameters& dispatchParameters ) { - if( @available( macOS 13.0, * ) ) - { - if( !m_setup ) - { - return Tr2UpscalingAL::Result::CONTEXT_SETUP_FAILED; - } - - if( !AreDispatchParametersValid( dispatchParameters ) ) - { - return Tr2UpscalingAL::Result::INCORRECT_INPUT; - } - - bool reset = dispatchParameters.reset; - - auto& renderContext = m_params.renderContext; - - if( m_temporalScaler && m_temporalScaler->created ) - { - if( m_mfxSpatialScaler ) - { - reset = true; - m_mfxSpatialScaler = nil; - } - - auto scaler = m_temporalScaler->temporalScaler; - auto queue = renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); - queue->EndEncoder(); - - scaler.reset = reset; - scaler.colorTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.input ); - scaler.depthTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.depth ); - scaler.motionTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.velocity ); - scaler.outputTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.output ); - scaler.depthReversed = true; - scaler.jitterOffsetX = m_jitterX; - scaler.jitterOffsetY = m_jitterY; - - [scaler encodeToCommandBuffer:queue->GetCommandBuffer()]; - - return Tr2UpscalingAL::Result::OK; - } - - if( m_mfxSpatialScaler != nil ) - { - auto queue = renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); - queue->EndEncoder(); - - m_mfxSpatialScaler.colorTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.input ); - m_mfxSpatialScaler.outputTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.output ); - - [m_mfxSpatialScaler encodeToCommandBuffer:queue->GetCommandBuffer()]; - } - else - { - CCP_LOGERR( "Trying to dispatch upscaling without temporal or spatial scaler..." ); - return Tr2UpscalingAL::Result::CONTEXT_SETUP_FAILED; - } - } - return Tr2UpscalingAL::Result::OK; + if( @available( macOS 13.0, * ) ) + { + if( !m_setup ) + { + return Tr2UpscalingAL::Result::CONTEXT_SETUP_FAILED; + } + + if( !AreDispatchParametersValid( dispatchParameters ) ) + { + return Tr2UpscalingAL::Result::INCORRECT_INPUT; + } + + bool reset = dispatchParameters.reset; + + auto& renderContext = m_params.renderContext; + + if( m_temporalScaler && m_temporalScaler->created ) + { + if( m_mfxSpatialScaler ) + { + reset = true; + m_mfxSpatialScaler = nil; + } + + auto scaler = m_temporalScaler->temporalScaler; + auto queue = renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); + queue->EndEncoder(); + + scaler.reset = reset; + scaler.colorTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.input ); + scaler.depthTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.depth ); + scaler.motionTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.velocity ); + scaler.outputTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.output ); + scaler.depthReversed = true; + scaler.jitterOffsetX = m_jitterX; + scaler.jitterOffsetY = m_jitterY; + + [scaler encodeToCommandBuffer:queue->GetCommandBuffer()]; + + return Tr2UpscalingAL::Result::OK; + } + + if( m_mfxSpatialScaler != nil ) + { + auto queue = renderContext.GetPrimaryRenderContext().GetMetalWorkQueue(); + queue->EndEncoder(); + + m_mfxSpatialScaler.colorTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.input ); + m_mfxSpatialScaler.outputTexture = MetalUpscalingUtils::GetMetalTexture( dispatchParameters.output ); + + [m_mfxSpatialScaler encodeToCommandBuffer:queue->GetCommandBuffer()]; + } + else + { + CCP_LOGERR( "Trying to dispatch upscaling without temporal or spatial scaler..." ); + return Tr2UpscalingAL::Result::CONTEXT_SETUP_FAILED; + } + } + return Tr2UpscalingAL::Result::OK; } #endif diff --git a/trinityal/metal/upscaling/Tr2UpscalingALMetal.h b/trinityal/metal/upscaling/Tr2UpscalingALMetal.h index 500f57b92..3d568568d 100644 --- a/trinityal/metal/upscaling/Tr2UpscalingALMetal.h +++ b/trinityal/metal/upscaling/Tr2UpscalingALMetal.h @@ -2,18 +2,18 @@ #pragma once -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "../../include/upscaling/Tr2UpscalingAL.h" namespace TrinityALImpl { - static const std::vector AVAILABLE_UPSCALING_TECHNIQUES = { - Tr2UpscalingAL::Technique::FSR1, - Tr2UpscalingAL::Technique::METALFX - }; - Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2RenderContextAL &renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); +static const std::vector AVAILABLE_UPSCALING_TECHNIQUES = { + Tr2UpscalingAL::Technique::FSR1, + Tr2UpscalingAL::Technique::METALFX +}; +Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ); - Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration ); +Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration ); } #endif diff --git a/trinityal/metal/upscaling/Tr2UpscalingALMetal.mm b/trinityal/metal/upscaling/Tr2UpscalingALMetal.mm index 8cb6c06e6..5c8f84494 100644 --- a/trinityal/metal/upscaling/Tr2UpscalingALMetal.mm +++ b/trinityal/metal/upscaling/Tr2UpscalingALMetal.mm @@ -1,7 +1,7 @@ // Copyright © 2024 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM == TRINITY_METAL ) +#if ( TRINITY_PLATFORM == TRINITY_METAL ) #include "Tr2UpscalingALMetal.h" #include "Tr2MetalFxUpscaling.h" @@ -9,27 +9,32 @@ namespace TrinityALImpl { - Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2RenderContextAL &renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) +Tr2UpscalingTechniqueAL* CreateUpscalingTechnique( Tr2RenderContextAL& renderContext, + Tr2UpscalingAL::Technique technique, + Tr2UpscalingAL::Setting setting, + bool frameGeneration, + uint32_t adapter ) +{ + Tr2UpscalingTechniqueAL* tech = nullptr; + switch( technique ) { - Tr2UpscalingTechniqueAL* tech = nullptr; - switch( technique ){ - case Tr2UpscalingAL::Technique::METALFX: - tech = new Tr2MetalFxUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - case Tr2UpscalingAL::Technique::FSR1: - tech = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); - break; - default: - break; - } + case Tr2UpscalingAL::Technique::METALFX: + tech = new Tr2MetalFxUpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + case Tr2UpscalingAL::Technique::FSR1: + tech = new Tr2Fsr1UpscalingTechnique( renderContext, technique, setting, frameGeneration, adapter ); + break; + default: + break; + } - if( tech && !tech->IsAvailable( ) ) - { - delete tech; - tech = nullptr; - } - return tech; + if( tech && !tech->IsAvailable() ) + { + delete tech; + tech = nullptr; } + return tech; +} } diff --git a/trinityal/src/Tr2BufferAL.cpp b/trinityal/src/Tr2BufferAL.cpp index a7d00843a..b345eb4a2 100644 --- a/trinityal/src/Tr2BufferAL.cpp +++ b/trinityal/src/Tr2BufferAL.cpp @@ -8,8 +8,8 @@ using namespace Tr2RenderContextEnum; -Tr2BufferDescriptionAL::Tr2BufferDescriptionAL() - :format( PIXEL_FORMAT_UNKNOWN ), +Tr2BufferDescriptionAL::Tr2BufferDescriptionAL() : + format( PIXEL_FORMAT_UNKNOWN ), stride( 0 ), count( 0 ), gpuUsage( Tr2GpuUsage::NONE ), @@ -21,8 +21,8 @@ Tr2BufferDescriptionAL::Tr2BufferDescriptionAL( Tr2RenderContextEnum::PixelFormat format_, uint32_t count_, Tr2GpuUsage::Type gpuUsage_, - Tr2CpuUsage::Type cpuUsage_ ) - :format( format_ ), + Tr2CpuUsage::Type cpuUsage_ ) : + format( format_ ), stride( GetBytesPerPixel( format_ ) ), count( count_ ), gpuUsage( gpuUsage_ ), @@ -34,8 +34,8 @@ Tr2BufferDescriptionAL::Tr2BufferDescriptionAL( uint32_t stride_, uint32_t count_, Tr2GpuUsage::Type gpuUsage_, - Tr2CpuUsage::Type cpuUsage_ ) - :format( PIXEL_FORMAT_UNKNOWN ), + Tr2CpuUsage::Type cpuUsage_ ) : + format( PIXEL_FORMAT_UNKNOWN ), stride( stride_ ), count( count_ ), gpuUsage( gpuUsage_ ), @@ -46,11 +46,11 @@ Tr2BufferDescriptionAL::Tr2BufferDescriptionAL( namespace { - std::shared_ptr nullBuffer = std::make_shared(); +std::shared_ptr nullBuffer = std::make_shared(); } -Tr2BufferAL::Tr2BufferAL() - :m_buffer( nullBuffer ) +Tr2BufferAL::Tr2BufferAL() : + m_buffer( nullBuffer ) { if( m_buffer == nullptr ) { diff --git a/trinityal/src/Tr2ConstantBufferAL.cpp b/trinityal/src/Tr2ConstantBufferAL.cpp index 2e12d6bdc..03ee9f5a1 100644 --- a/trinityal/src/Tr2ConstantBufferAL.cpp +++ b/trinityal/src/Tr2ConstantBufferAL.cpp @@ -7,25 +7,25 @@ namespace { - std::shared_ptr NullCB() - { - static std::shared_ptr nullCB = std::make_shared(); - return nullCB; - } +std::shared_ptr NullCB() +{ + static std::shared_ptr nullCB = std::make_shared(); + return nullCB; +} } -Tr2ConstantBufferAL::Tr2ConstantBufferAL() - :m_buffer( NullCB() ) +Tr2ConstantBufferAL::Tr2ConstantBufferAL() : + m_buffer( NullCB() ) { } -ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2PrimaryRenderContextAL & renderContext ) +ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2PrimaryRenderContextAL& renderContext ) { return Create( size, Tr2ConstantUsageAL::REUSABLE, nullptr, renderContext ); } -ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL & renderContext ) +ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2PrimaryRenderContextAL& renderContext ) { if( size == 0 || size > TRINITY_PLATFORM_MAX_CONSTANT_BUFFER_SIZE ) { @@ -46,12 +46,12 @@ ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type us return hr; } -ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL & renderContext ) +ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& renderContext ) { return m_buffer->Lock( data, renderContext ); } -ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL & renderContext ) +ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& renderContext ) { return m_buffer->Unlock( renderContext ); } diff --git a/trinityal/src/Tr2FenceAL.cpp b/trinityal/src/Tr2FenceAL.cpp index 671e16693..ee50995f9 100644 --- a/trinityal/src/Tr2FenceAL.cpp +++ b/trinityal/src/Tr2FenceAL.cpp @@ -7,15 +7,15 @@ namespace { - std::shared_ptr NullFence() - { - static std::shared_ptr nullFence = std::make_shared(); - return nullFence; - } +std::shared_ptr NullFence() +{ + static std::shared_ptr nullFence = std::make_shared(); + return nullFence; +} } -Tr2FenceAL::Tr2FenceAL() - :m_fence( NullFence() ) +Tr2FenceAL::Tr2FenceAL() : + m_fence( NullFence() ) { } diff --git a/trinityal/src/Tr2GpuTimerAl.cpp b/trinityal/src/Tr2GpuTimerAl.cpp index 5fa9b7e62..3ad3d22f4 100644 --- a/trinityal/src/Tr2GpuTimerAl.cpp +++ b/trinityal/src/Tr2GpuTimerAl.cpp @@ -9,11 +9,11 @@ bool g_gpuTimersEnabled = true; namespace { - auto nullGpuTimer = std::make_shared(); +auto nullGpuTimer = std::make_shared(); } -Tr2GpuTimerAL::Tr2GpuTimerAL() - :m_gpu_timer(nullGpuTimer) +Tr2GpuTimerAL::Tr2GpuTimerAL() : + m_gpu_timer( nullGpuTimer ) { } @@ -24,10 +24,10 @@ ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) m_gpu_timer = nullGpuTimer; return E_FAIL; } - + m_gpu_timer = std::make_shared(); - auto hr = m_gpu_timer->Create(renderContext); - if( FAILED( hr)) + auto hr = m_gpu_timer->Create( renderContext ); + if( FAILED( hr ) ) { m_gpu_timer = nullGpuTimer; } @@ -37,17 +37,17 @@ ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& renderContext ) const { - return m_gpu_timer->Begin(renderContext); + return m_gpu_timer->Begin( renderContext ); } void Tr2GpuTimerAL::End( Tr2RenderContextAL& renderContext ) const { - m_gpu_timer->End(renderContext); + m_gpu_timer->End( renderContext ); } float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& renderContext ) const { - return m_gpu_timer->GetTime(renderContext); + return m_gpu_timer->GetTime( renderContext ); } bool Tr2GpuTimerAL::IsValid() const diff --git a/trinityal/src/Tr2OcclusionQueryAL.cpp b/trinityal/src/Tr2OcclusionQueryAL.cpp index 06c4aa0bc..375afe6d6 100644 --- a/trinityal/src/Tr2OcclusionQueryAL.cpp +++ b/trinityal/src/Tr2OcclusionQueryAL.cpp @@ -7,16 +7,16 @@ namespace { - std::shared_ptr NullQuery() - { - static std::shared_ptr nullQuery = std::make_shared(); - return nullQuery; - } +std::shared_ptr NullQuery() +{ + static std::shared_ptr nullQuery = std::make_shared(); + return nullQuery; +} } -Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() - :m_query( NullQuery() ) +Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() : + m_query( NullQuery() ) { } diff --git a/trinityal/src/Tr2ResourceSetAL.cpp b/trinityal/src/Tr2ResourceSetAL.cpp index 43ac9cb1f..da64763b6 100644 --- a/trinityal/src/Tr2ResourceSetAL.cpp +++ b/trinityal/src/Tr2ResourceSetAL.cpp @@ -473,8 +473,8 @@ uint32_t Tr2ResourceSetDescriptionAL::ComputeHash() const } -Tr2ResourceSetDescriptionAL::Resource::Resource() - :type( NONE ), +Tr2ResourceSetDescriptionAL::Resource::Resource() : + type( NONE ), colorSpace( Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) { } @@ -515,8 +515,8 @@ void Tr2ResourceSetDescriptionAL::Resource::UpdateHash( uint32_t& hash ) const } } -Tr2ResourceSetDescriptionAL::Sampler::Sampler() - :type( NONE ) +Tr2ResourceSetDescriptionAL::Sampler::Sampler() : + type( NONE ) { } @@ -543,14 +543,14 @@ void Tr2ResourceSetDescriptionAL::Sampler::UpdateHash( uint32_t& hash ) const } -namespace +namespace { - std::shared_ptr nullRS = std::make_shared(); +std::shared_ptr nullRS = std::make_shared(); } -Tr2ResourceSetAL::Tr2ResourceSetAL() - :m_resourceSet( nullRS ) +Tr2ResourceSetAL::Tr2ResourceSetAL() : + m_resourceSet( nullRS ) { } diff --git a/trinityal/src/Tr2RtBottomLevelAccelerationStructureAL.cpp b/trinityal/src/Tr2RtBottomLevelAccelerationStructureAL.cpp index d6957cbd2..fcddeafa2 100644 --- a/trinityal/src/Tr2RtBottomLevelAccelerationStructureAL.cpp +++ b/trinityal/src/Tr2RtBottomLevelAccelerationStructureAL.cpp @@ -10,15 +10,15 @@ namespace { - std::shared_ptr NullBlas() - { - static std::shared_ptr nullBlas = std::make_shared(); - return nullBlas; - } +std::shared_ptr NullBlas() +{ + static std::shared_ptr nullBlas = std::make_shared(); + return nullBlas; +} } -Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() - :m_blas( NullBlas() ) +Tr2RtBottomLevelAccelerationStructureAL::Tr2RtBottomLevelAccelerationStructureAL() : + m_blas( NullBlas() ) { } @@ -112,16 +112,16 @@ TrinityALImpl::Tr2RtBottomLevelAccelerationStructureAL* Tr2RtBottomLevelAccelera #endif -Tr2RtPositionStreamAL::Tr2RtPositionStreamAL() - :m_vertexCount( 0 ), +Tr2RtPositionStreamAL::Tr2RtPositionStreamAL() : + m_vertexCount( 0 ), m_vertexOffset( 0 ), m_positionOffset( 0 ), m_stride( 0 ) { } -Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) - :m_vertexBuffer( vb ), +Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) : + m_vertexBuffer( vb ), m_positionOffset( positionOffset ), m_vertexOffset( 0 ), m_positionFormat( positionFormat ), @@ -130,8 +130,8 @@ Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t po { } -Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t vertexCount, uint32_t vertexOffset, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) - :m_vertexBuffer( vb ), +Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t vertexCount, uint32_t vertexOffset, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) : + m_vertexBuffer( vb ), m_positionOffset( positionOffset ), m_vertexOffset( vertexOffset ), m_positionFormat( positionFormat ), @@ -140,8 +140,8 @@ Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t ve { } -Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t stride, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) - :m_vertexBuffer( vb ), +Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t stride, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) : + m_vertexBuffer( vb ), m_positionOffset( positionOffset ), m_vertexOffset( 0 ), m_positionFormat( positionFormat ), @@ -150,8 +150,8 @@ Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t st { } -Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t stride, uint32_t vertexCount, uint32_t vertexOffset, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) - :m_vertexBuffer( vb ), +Tr2RtPositionStreamAL::Tr2RtPositionStreamAL( const Tr2BufferAL& vb, uint32_t stride, uint32_t vertexCount, uint32_t vertexOffset, uint32_t positionOffset, Tr2RenderContextEnum::PixelFormat positionFormat ) : + m_vertexBuffer( vb ), m_positionOffset( positionOffset ), m_vertexOffset( vertexOffset ), m_positionFormat( positionFormat ), @@ -167,23 +167,23 @@ bool Tr2RtPositionStreamAL::IsValid() const } -Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL() - :m_indexCount( 0 ), +Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL() : + m_indexCount( 0 ), m_indexOffset( 0 ), m_stride( 0 ) { } -Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL( const Tr2BufferAL& ib ) - :m_indexBuffer( ib ), +Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL( const Tr2BufferAL& ib ) : + m_indexBuffer( ib ), m_indexCount( ib.GetDesc().count ), m_indexOffset( 0 ), m_stride( ib.GetDesc().stride ) { } -Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL( const Tr2BufferAL& ib, uint32_t offset, uint32_t count ) - :m_indexBuffer( ib ), +Tr2RtIndicesStreamAL::Tr2RtIndicesStreamAL( const Tr2BufferAL& ib, uint32_t offset, uint32_t count ) : + m_indexBuffer( ib ), m_indexCount( count ), m_indexOffset( offset ), m_stride( ib.GetDesc().stride ) diff --git a/trinityal/src/Tr2RtPipelineStateAL.cpp b/trinityal/src/Tr2RtPipelineStateAL.cpp index 6b683a2e8..5b2f9987f 100644 --- a/trinityal/src/Tr2RtPipelineStateAL.cpp +++ b/trinityal/src/Tr2RtPipelineStateAL.cpp @@ -11,16 +11,16 @@ namespace { - std::shared_ptr NullRtPipeline() - { - static std::shared_ptr nullPipeline = std::make_shared(); - return nullPipeline; - } +std::shared_ptr NullRtPipeline() +{ + static std::shared_ptr nullPipeline = std::make_shared(); + return nullPipeline; +} } -Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() - :m_pipeline( NullRtPipeline() ) +Tr2RtPipelineStateAL::Tr2RtPipelineStateAL() : + m_pipeline( NullRtPipeline() ) { } diff --git a/trinityal/src/Tr2RtShaderTableAL.cpp b/trinityal/src/Tr2RtShaderTableAL.cpp index c6067b5d1..f86516dac 100644 --- a/trinityal/src/Tr2RtShaderTableAL.cpp +++ b/trinityal/src/Tr2RtShaderTableAL.cpp @@ -11,16 +11,16 @@ namespace { - std::shared_ptr NullRtShaderTable() - { - static std::shared_ptr nullTable = std::make_shared(); - return nullTable; - } +std::shared_ptr NullRtShaderTable() +{ + static std::shared_ptr nullTable = std::make_shared(); + return nullTable; +} } -Tr2RtShaderTableAL::Tr2RtShaderTableAL() - :m_shaderTable( NullRtShaderTable() ) +Tr2RtShaderTableAL::Tr2RtShaderTableAL() : + m_shaderTable( NullRtShaderTable() ) { } diff --git a/trinityal/src/Tr2RtTopLevelAccelerationStructureAL.cpp b/trinityal/src/Tr2RtTopLevelAccelerationStructureAL.cpp index 9a279b124..6ce40afd2 100644 --- a/trinityal/src/Tr2RtTopLevelAccelerationStructureAL.cpp +++ b/trinityal/src/Tr2RtTopLevelAccelerationStructureAL.cpp @@ -11,15 +11,15 @@ namespace { - std::shared_ptr NullTlas() - { - static std::shared_ptr nullTlas = std::make_shared(); - return nullTlas; - } +std::shared_ptr NullTlas() +{ + static std::shared_ptr nullTlas = std::make_shared(); + return nullTlas; +} } -Tr2RtTopLevelAccelerationStructureAL::Tr2RtTopLevelAccelerationStructureAL() - :m_tlas( NullTlas() ) +Tr2RtTopLevelAccelerationStructureAL::Tr2RtTopLevelAccelerationStructureAL() : + m_tlas( NullTlas() ) { } @@ -98,4 +98,3 @@ TrinityALImpl::Tr2RtTopLevelAccelerationStructureAL* Tr2RtTopLevelAccelerationSt #endif - diff --git a/trinityal/src/Tr2SamplerStateAL.cpp b/trinityal/src/Tr2SamplerStateAL.cpp index dd9894374..8250220d0 100644 --- a/trinityal/src/Tr2SamplerStateAL.cpp +++ b/trinityal/src/Tr2SamplerStateAL.cpp @@ -7,7 +7,7 @@ namespace { - std::shared_ptr nullSampler = std::make_shared(); +std::shared_ptr nullSampler = std::make_shared(); } // Force anisotropic filtering switch: @@ -17,12 +17,12 @@ namespace uint32_t g_forceAnisotropy = 0; -Tr2SamplerStateAL::Tr2SamplerStateAL() - :m_sampler( nullSampler ) +Tr2SamplerStateAL::Tr2SamplerStateAL() : + m_sampler( nullSampler ) { } -ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL &renderContext ) +ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription& description, Tr2PrimaryRenderContextAL& renderContext ) { return renderContext.m_samplerStateFactory.Get( m_sampler, description, renderContext ); } diff --git a/trinityal/src/Tr2ShaderAL.cpp b/trinityal/src/Tr2ShaderAL.cpp index db3baf427..4de9024e1 100644 --- a/trinityal/src/Tr2ShaderAL.cpp +++ b/trinityal/src/Tr2ShaderAL.cpp @@ -7,37 +7,37 @@ namespace { - std::shared_ptr NullShader() - { - static std::shared_ptr nullShader = std::make_shared(); - return nullShader; - } +std::shared_ptr NullShader() +{ + static std::shared_ptr nullShader = std::make_shared(); + return nullShader; +} } -Tr2ShaderBytecodeAL::Tr2ShaderBytecodeAL() - :bytecode( nullptr ), +Tr2ShaderBytecodeAL::Tr2ShaderBytecodeAL() : + bytecode( nullptr ), size( 0 ) { } -Tr2ShaderBytecodeAL::Tr2ShaderBytecodeAL( const void* bytecode_, size_t size_ ) - : bytecode( bytecode_ ), +Tr2ShaderBytecodeAL::Tr2ShaderBytecodeAL( const void* bytecode_, size_t size_ ) : + bytecode( bytecode_ ), size( size_ ) { } Tr2ShaderBytecodeAL::~Tr2ShaderBytecodeAL() { - bytecode = nullptr; + bytecode = nullptr; } Tr2ShaderPipelineInputAL::Tr2ShaderPipelineInputAL() { } -Tr2ShaderPipelineInputAL::Tr2ShaderPipelineInputAL( Tr2VertexDefinition::UsageCode usage_, uint32_t usageIndex_, uint32_t registerIndex_, Type type_, uint32_t dimension_, uint32_t usedMask_ ) - :usage( usage_ ), +Tr2ShaderPipelineInputAL::Tr2ShaderPipelineInputAL( Tr2VertexDefinition::UsageCode usage_, uint32_t usageIndex_, uint32_t registerIndex_, Type type_, uint32_t dimension_, uint32_t usedMask_ ) : + usage( usage_ ), usageIndex( usageIndex_ ), registerIndex( registerIndex_ ), usedMask( usedMask_ ), @@ -52,15 +52,15 @@ bool Tr2ShaderPipelineInputAL::operator==( const Tr2ShaderPipelineInputAL& other } -Tr2ShaderRegisterAL::Tr2ShaderRegisterAL() - :registerType( CONSTANT_BUFFER ), +Tr2ShaderRegisterAL::Tr2ShaderRegisterAL() : + registerType( CONSTANT_BUFFER ), registerIndex( 0 ), dynamic( true ) { } -Tr2ShaderRegisterAL::Tr2ShaderRegisterAL( RegisterType registerType_, uint32_t registerIndex_, uint32_t registerSpace_, uint32_t arrayCount_, bool dynamic_ ) - : registerType( registerType_ ), +Tr2ShaderRegisterAL::Tr2ShaderRegisterAL( RegisterType registerType_, uint32_t registerIndex_, uint32_t registerSpace_, uint32_t arrayCount_, bool dynamic_ ) : + registerType( registerType_ ), registerIndex( registerIndex_ ), registerSpace( registerSpace_ ), arrayCount( arrayCount_ ), @@ -129,13 +129,13 @@ bool Tr2ShaderSignatureAL::operator==( const Tr2ShaderSignatureAL& other ) const return registers == other.registers && pipelineInputs == other.pipelineInputs; } -Tr2ShaderAL::Tr2ShaderAL() - :m_shader( NullShader() ) +Tr2ShaderAL::Tr2ShaderAL() : + m_shader( NullShader() ) { } -Tr2ShaderAL::Tr2ShaderAL( std::shared_ptr shader ) - :m_shader( shader ) +Tr2ShaderAL::Tr2ShaderAL( std::shared_ptr shader ) : + m_shader( shader ) { } @@ -144,7 +144,7 @@ ALResult Tr2ShaderAL::Create( const Tr2ShaderBytecodeAL& bytecode, const Tr2ShaderSignatureAL& signature, const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ) + Tr2PrimaryRenderContextAL& renderContext ) { m_shader = std::make_shared(); auto result = m_shader->Create( type, bytecode, signature, shaderPath, renderContext ); @@ -200,5 +200,5 @@ ALResult Tr2ShaderAL::SetName( const char* name ) TrinityALImpl::Tr2ShaderAL* Tr2ShaderAL::TrinityALImpl_GetObject() const { - return m_shader.get(); + return m_shader.get(); } diff --git a/trinityal/src/Tr2ShaderProgramAL.cpp b/trinityal/src/Tr2ShaderProgramAL.cpp index e35fbfdeb..870edaa0f 100644 --- a/trinityal/src/Tr2ShaderProgramAL.cpp +++ b/trinityal/src/Tr2ShaderProgramAL.cpp @@ -7,16 +7,16 @@ namespace { - std::shared_ptr NullProgram() - { - static std::shared_ptr nullProgram = std::make_shared(); - return nullProgram; - } +std::shared_ptr NullProgram() +{ + static std::shared_ptr nullProgram = std::make_shared(); + return nullProgram; +} } -Tr2ShaderProgramAL::Tr2ShaderProgramAL() - :m_program( NullProgram() ) +Tr2ShaderProgramAL::Tr2ShaderProgramAL() : + m_program( NullProgram() ) { } diff --git a/trinityal/src/Tr2StreamlineAL.cpp b/trinityal/src/Tr2StreamlineAL.cpp index 4511935a0..c05cc8db8 100644 --- a/trinityal/src/Tr2StreamlineAL.cpp +++ b/trinityal/src/Tr2StreamlineAL.cpp @@ -13,612 +13,613 @@ extern bool g_upscalingDebug; namespace Tr2StreamlineAL { - static HMODULE STREAMLINE_MODULE = nullptr; - static bool STREAMLINE_INITIALIZED = false; - static sl::Result STREAMLINE_INITIALIZATION_RESULT = sl::Result::eOk; +static HMODULE STREAMLINE_MODULE = nullptr; +static bool STREAMLINE_INITIALIZED = false; +static sl::Result STREAMLINE_INITIALIZATION_RESULT = sl::Result::eOk; - - static bool STREAMLINE_DEVICE_SET = false; - static bool STREAMLINE_DLSS_SUPPORTED = false; + +static bool STREAMLINE_DEVICE_SET = false; +static bool STREAMLINE_DLSS_SUPPORTED = false; #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - static bool STREAMLINE_FRAME_GENERATION_SUPPORTED = false; +static bool STREAMLINE_FRAME_GENERATION_SUPPORTED = false; #endif - #define INITIALIZE_FUNCTION( func ) \ - FUNCTIONS.m_##func = reinterpret_cast( GetProcAddress( STREAMLINE_MODULE, #func ) ) +#define INITIALIZE_FUNCTION( func ) \ + FUNCTIONS.m_##func = reinterpret_cast( GetProcAddress( STREAMLINE_MODULE, #func ) ) - #define INITIALIZE_FEATURE_FUNCTION( feature, func ) \ - if( SL_FAILED( res, FUNCTIONS.m_slGetFeatureFunction( feature, #func, (void*&)FEATURE_FUNCTIONS.m_##func ) ) ) \ - { \ - CCP_LOGERR( "Unable to find function %s for feature %s Error: %s", #func, #feature, GetSlResultMessage( res ) ); \ - return res; \ - } - +#define INITIALIZE_FEATURE_FUNCTION( feature, func ) \ + if( SL_FAILED( res, FUNCTIONS.m_slGetFeatureFunction( feature, #func, (void*&)FEATURE_FUNCTIONS.m_##func ) ) ) \ + { \ + CCP_LOGERR( "Unable to find function %s for feature %s Error: %s", #func, #feature, GetSlResultMessage( res ) ); \ + return res; \ + } - //These two structs are automatically zero-initialized - static struct - { - //initialization - PFun_slInit* m_slInit; - // shutdown - PFun_slShutdown* m_slShutdown; - PFun_slFreeResources* m_slFreeResources; +//These two structs are automatically zero-initialized +static struct +{ + //initialization + PFun_slInit* m_slInit; - //wrapping - PFun_slSetD3DDevice* m_slSetD3DDevice; - PFun_slUpgradeInterface* m_slUpgradeInterface; + // shutdown + PFun_slShutdown* m_slShutdown; + PFun_slFreeResources* m_slFreeResources; - //feature support - PFun_slIsFeatureSupported* m_slIsFeatureSupported; - PFun_slSetFeatureLoaded* m_slSetFeatureLoaded; - PFun_slGetFeatureFunction* m_slGetFeatureFunction; + //wrapping + PFun_slSetD3DDevice* m_slSetD3DDevice; + PFun_slUpgradeInterface* m_slUpgradeInterface; - //frame tokens - PFun_slGetNewFrameToken* m_slGetNewFrameToken; + //feature support + PFun_slIsFeatureSupported* m_slIsFeatureSupported; + PFun_slSetFeatureLoaded* m_slSetFeatureLoaded; + PFun_slGetFeatureFunction* m_slGetFeatureFunction; - //dispatching - PFun_slSetTagForFrame* m_slSetTagForFrame; - PFun_slSetConstants* m_slSetConstants; - PFun_slEvaluateFeature* m_slEvaluateFeature; + //frame tokens + PFun_slGetNewFrameToken* m_slGetNewFrameToken; - } FUNCTIONS; + //dispatching + PFun_slSetTagForFrame* m_slSetTagForFrame; + PFun_slSetConstants* m_slSetConstants; + PFun_slEvaluateFeature* m_slEvaluateFeature; - static struct - { +} FUNCTIONS; - //DLSS - PFun_slDLSSGetOptimalSettings* m_slDLSSGetOptimalSettings; - PFun_slDLSSSetOptions* m_slDLSSSetOptions; +static struct +{ + + //DLSS + PFun_slDLSSGetOptimalSettings* m_slDLSSGetOptimalSettings; + PFun_slDLSSSetOptions* m_slDLSSSetOptions; + + //NIS + PFun_slNISSetOptions* m_slNISSetOptions; - //NIS - PFun_slNISSetOptions* m_slNISSetOptions; - #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - //DLSSG - PFun_slDLSSGSetOptions* m_slDLSSGSetOptions; - PFun_slDLSSGGetState* m_slDLSSGGetState; + //DLSSG + PFun_slDLSSGSetOptions* m_slDLSSGSetOptions; + PFun_slDLSSGGetState* m_slDLSSGGetState; - //Reflex - PFun_slReflexSetOptions* m_slReflexSetOptions; + //Reflex + PFun_slReflexSetOptions* m_slReflexSetOptions; - //PCL - PFun_slPCLSetMarker* m_slPCLSetMarker; + //PCL + PFun_slPCLSetMarker* m_slPCLSetMarker; #endif - } FEATURE_FUNCTIONS; +} FEATURE_FUNCTIONS; - void Tr2StreamlineLog( sl::LogType type, const char* msg ) +void Tr2StreamlineLog( sl::LogType type, const char* msg ) +{ + switch( type ) { - switch( type ) - { - case sl::LogType::eInfo: - CCP_LOGNOTICE( msg ); - break; - - case sl::LogType::eWarn: - CCP_LOGWARN( msg ); - break; - - case sl::LogType::eError: - CCP_LOGERR( msg ); - break; - default: - break; - } + case sl::LogType::eInfo: + CCP_LOGNOTICE( msg ); + break; + + case sl::LogType::eWarn: + CCP_LOGWARN( msg ); + break; + + case sl::LogType::eError: + CCP_LOGERR( msg ); + break; + default: + break; } +} - const char* GetPluginName( sl::Feature feature ) +const char* GetPluginName( sl::Feature feature ) +{ + switch( feature ) { - switch( feature ) - { - case sl::kFeatureDLSS: - return "DLSS"; - case sl::kFeatureDLSS_G: - return "DLSSG"; - case sl::kFeatureNIS: - return "NIS"; - case sl::kFeatureImGUI: - return "ImGUI"; - case sl::kFeatureReflex: - return "Reflex"; - case sl::kFeaturePCL: - return "PCL"; - default: - return "N/A"; - } + case sl::kFeatureDLSS: + return "DLSS"; + case sl::kFeatureDLSS_G: + return "DLSSG"; + case sl::kFeatureNIS: + return "NIS"; + case sl::kFeatureImGUI: + return "ImGUI"; + case sl::kFeatureReflex: + return "Reflex"; + case sl::kFeaturePCL: + return "PCL"; + default: + return "N/A"; } +} - sl::float4x4 F16AsFloat4x4( const float f[16] ) - { - sl::float4x4 m; - m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); - m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); - m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); - m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); - return m; - } +sl::float4x4 F16AsFloat4x4( const float f[16] ) +{ + sl::float4x4 m; + m.setRow( 0, sl::float4( f[0], f[1], f[2], f[3] ) ); + m.setRow( 1, sl::float4( f[4], f[5], f[6], f[7] ) ); + m.setRow( 2, sl::float4( f[8], f[9], f[10], f[11] ) ); + m.setRow( 3, sl::float4( f[12], f[13], f[14], f[15] ) ); + return m; +} - const char* GetSlResultMessage( sl::Result res ) +const char* GetSlResultMessage( sl::Result res ) +{ + switch( res ) { - switch( res ) - { - case sl::Result::eOk: - return "No error"; - case sl::Result::eErrorIO: - return "I/O error"; - case sl::Result::eErrorDriverOutOfDate: - return "Driver out of date"; - case sl::Result::eErrorOSOutOfDate: - return "Operating system out of date"; - case sl::Result::eErrorOSDisabledHWS: - return "Operating system disabled hardware support"; - case sl::Result::eErrorDeviceNotCreated: - return "Device not created"; - case sl::Result::eErrorNoSupportedAdapterFound: - return "No supported adapter found"; - case sl::Result::eErrorAdapterNotSupported: - return "Adapter not supported"; - case sl::Result::eErrorNoPlugins: - return "No plugins found"; - case sl::Result::eErrorVulkanAPI: - return "Vulkan API error"; - case sl::Result::eErrorDXGIAPI: - return "DXGI API error"; - case sl::Result::eErrorD3DAPI: - return "D3D API error"; - case sl::Result::eErrorNRDAPI: - return "NRD API error"; - case sl::Result::eErrorNVAPI: - return "NVAPI error"; - case sl::Result::eErrorReflexAPI: - return "Reflex API error"; - case sl::Result::eErrorNGXFailed: - return "NGX failed to load"; - case sl::Result::eErrorJSONParsing: - return "JSON parsing error"; - case sl::Result::eErrorMissingProxy: - return "Missing proxy"; - case sl::Result::eErrorMissingResourceState: - return "Missing resource state"; - case sl::Result::eErrorInvalidIntegration: - return "Invalid integration"; - case sl::Result::eErrorMissingInputParameter: - return "Missing input parameter"; - case sl::Result::eErrorNotInitialized: - return "Not initialized"; - case sl::Result::eErrorComputeFailed: - return "Compute shader failed"; - case sl::Result::eErrorInitNotCalled: - return "Initialization not called"; - case sl::Result::eErrorExceptionHandler: - return "Exception handler error"; - case sl::Result::eErrorInvalidParameter: - return "Invalid parameter"; - case sl::Result::eErrorMissingConstants: - return "Missing constants"; - case sl::Result::eErrorDuplicatedConstants: - return "Duplicate constants"; - case sl::Result::eErrorMissingOrInvalidAPI: - return "Missing or invalid API"; - case sl::Result::eErrorCommonConstantsMissing: - return "Common constants missing"; - case sl::Result::eErrorUnsupportedInterface: - return "Unsupported interface"; - case sl::Result::eErrorFeatureMissing: - return "Feature missing"; - case sl::Result::eErrorFeatureNotSupported: - return "Feature not supported"; - case sl::Result::eErrorFeatureMissingHooks: - return "Feature missing hooks"; - case sl::Result::eErrorFeatureFailedToLoad: - return "Feature failed to load"; - case sl::Result::eErrorFeatureWrongPriority: - return "Feature wrong priority"; - case sl::Result::eErrorFeatureMissingDependency: - return "Feature missing dependency"; - case sl::Result::eErrorFeatureManagerInvalidState: - return "Feature manager in invalid state"; - case sl::Result::eErrorInvalidState: - return "Invalid state"; - case sl::Result::eWarnOutOfVRAM: - return "Warning: Out of VRAM"; - default: - return "Unknown error"; - } + case sl::Result::eOk: + return "No error"; + case sl::Result::eErrorIO: + return "I/O error"; + case sl::Result::eErrorDriverOutOfDate: + return "Driver out of date"; + case sl::Result::eErrorOSOutOfDate: + return "Operating system out of date"; + case sl::Result::eErrorOSDisabledHWS: + return "Operating system disabled hardware support"; + case sl::Result::eErrorDeviceNotCreated: + return "Device not created"; + case sl::Result::eErrorNoSupportedAdapterFound: + return "No supported adapter found"; + case sl::Result::eErrorAdapterNotSupported: + return "Adapter not supported"; + case sl::Result::eErrorNoPlugins: + return "No plugins found"; + case sl::Result::eErrorVulkanAPI: + return "Vulkan API error"; + case sl::Result::eErrorDXGIAPI: + return "DXGI API error"; + case sl::Result::eErrorD3DAPI: + return "D3D API error"; + case sl::Result::eErrorNRDAPI: + return "NRD API error"; + case sl::Result::eErrorNVAPI: + return "NVAPI error"; + case sl::Result::eErrorReflexAPI: + return "Reflex API error"; + case sl::Result::eErrorNGXFailed: + return "NGX failed to load"; + case sl::Result::eErrorJSONParsing: + return "JSON parsing error"; + case sl::Result::eErrorMissingProxy: + return "Missing proxy"; + case sl::Result::eErrorMissingResourceState: + return "Missing resource state"; + case sl::Result::eErrorInvalidIntegration: + return "Invalid integration"; + case sl::Result::eErrorMissingInputParameter: + return "Missing input parameter"; + case sl::Result::eErrorNotInitialized: + return "Not initialized"; + case sl::Result::eErrorComputeFailed: + return "Compute shader failed"; + case sl::Result::eErrorInitNotCalled: + return "Initialization not called"; + case sl::Result::eErrorExceptionHandler: + return "Exception handler error"; + case sl::Result::eErrorInvalidParameter: + return "Invalid parameter"; + case sl::Result::eErrorMissingConstants: + return "Missing constants"; + case sl::Result::eErrorDuplicatedConstants: + return "Duplicate constants"; + case sl::Result::eErrorMissingOrInvalidAPI: + return "Missing or invalid API"; + case sl::Result::eErrorCommonConstantsMissing: + return "Common constants missing"; + case sl::Result::eErrorUnsupportedInterface: + return "Unsupported interface"; + case sl::Result::eErrorFeatureMissing: + return "Feature missing"; + case sl::Result::eErrorFeatureNotSupported: + return "Feature not supported"; + case sl::Result::eErrorFeatureMissingHooks: + return "Feature missing hooks"; + case sl::Result::eErrorFeatureFailedToLoad: + return "Feature failed to load"; + case sl::Result::eErrorFeatureWrongPriority: + return "Feature wrong priority"; + case sl::Result::eErrorFeatureMissingDependency: + return "Feature missing dependency"; + case sl::Result::eErrorFeatureManagerInvalidState: + return "Feature manager in invalid state"; + case sl::Result::eErrorInvalidState: + return "Invalid state"; + case sl::Result::eWarnOutOfVRAM: + return "Warning: Out of VRAM"; + default: + return "Unknown error"; } +} - sl::Result ReportSlError( sl::Result res, const char* file, int line, const char* message ) +sl::Result ReportSlError( sl::Result res, const char* file, int line, const char* message ) +{ + if( res != sl::Result::eOk ) { - if( res != sl::Result::eOk ) + CCP_LOGERR( "Streamline error %s in %s", message, GetSlResultMessage( res ) ); + if( g_upscalingDebug ) { - CCP_LOGERR( "Streamline error %s in %s", message, GetSlResultMessage( res ) ); - if( g_upscalingDebug ) + char buffer[1024] = ""; + _snprintf_s( buffer, _TRUNCATE, "%s(%i): error streamline %s: %s\n", file, line, GetSlResultMessage( res ), message ); + OutputDebugString( buffer ); + __try + { + DebugBreak(); + } + __except( GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) { - char buffer[1024] = ""; - _snprintf_s( buffer, _TRUNCATE, "%s(%i): error streamline %s: %s\n", file, line, GetSlResultMessage( res ), message ); - OutputDebugString( buffer ); - __try - { - DebugBreak(); - } - __except( GetExceptionCode() == EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ) - { - } } } - return res; } + return res; +} -#define CR_SL( res ) ReportSlError( res, __FILE__, __LINE__, #res) +#define CR_SL( res ) ReportSlError( res, __FILE__, __LINE__, #res ) - sl::Result InitializeStreamline( uint32_t appID ) +sl::Result InitializeStreamline( uint32_t appID ) +{ + if( STREAMLINE_INITIALIZED ) { - if( STREAMLINE_INITIALIZED ) - { - CCP_LOGERR( "Streamline already initialized with result code %d", STREAMLINE_INITIALIZATION_RESULT ); + CCP_LOGERR( "Streamline already initialized with result code %d", STREAMLINE_INITIALIZATION_RESULT ); - return STREAMLINE_INITIALIZATION_RESULT; - } + return STREAMLINE_INITIALIZATION_RESULT; + } - // load the DLL + // load the DLL + { + wchar_t abs_path[4096]; + auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 4096, abs_path, nullptr ); + if( size == 0 ) { - wchar_t abs_path[4096]; - auto size = SearchPathW( nullptr, L"sl.interposer.dll", L"", 4096, abs_path, nullptr ); - if( size == 0 ) - { - CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); + CCP_LOGERR( "Unable to find sl.interposer.dll in path for secure load." ); - return sl::Result::eErrorIO; //Most fitting error... - } - else if( g_upscalingDebug ) - { - STREAMLINE_MODULE = LoadLibraryW( abs_path ); - } - else if( sl::security::verifyEmbeddedSignature( abs_path ) ) - { - STREAMLINE_MODULE = LoadLibraryW( abs_path ); - } -# - CCP_LOGNOTICE( "NVidia Streamline library loaded" ); + return sl::Result::eErrorIO; //Most fitting error... } - - // initialize function pointers + else if( g_upscalingDebug ) + { + STREAMLINE_MODULE = LoadLibraryW( abs_path ); + } + else if( sl::security::verifyEmbeddedSignature( abs_path ) ) { - INITIALIZE_FUNCTION( slInit ); - INITIALIZE_FUNCTION( slShutdown ); - INITIALIZE_FUNCTION( slFreeResources ); + STREAMLINE_MODULE = LoadLibraryW( abs_path ); + } +# + CCP_LOGNOTICE( "NVidia Streamline library loaded" ); + } - INITIALIZE_FUNCTION( slSetD3DDevice ); - INITIALIZE_FUNCTION( slUpgradeInterface ); + // initialize function pointers + { + INITIALIZE_FUNCTION( slInit ); + INITIALIZE_FUNCTION( slShutdown ); + INITIALIZE_FUNCTION( slFreeResources ); - INITIALIZE_FUNCTION( slIsFeatureSupported ); - INITIALIZE_FUNCTION( slSetFeatureLoaded ); - INITIALIZE_FUNCTION( slGetFeatureFunction ); + INITIALIZE_FUNCTION( slSetD3DDevice ); + INITIALIZE_FUNCTION( slUpgradeInterface ); - INITIALIZE_FUNCTION( slGetNewFrameToken ); + INITIALIZE_FUNCTION( slIsFeatureSupported ); + INITIALIZE_FUNCTION( slSetFeatureLoaded ); + INITIALIZE_FUNCTION( slGetFeatureFunction ); - INITIALIZE_FUNCTION( slSetTagForFrame ); - INITIALIZE_FUNCTION( slSetConstants ); - INITIALIZE_FUNCTION( slEvaluateFeature ); - } + INITIALIZE_FUNCTION( slGetNewFrameToken ); - if( !FUNCTIONS.m_slInit || !FUNCTIONS.m_slShutdown || !FUNCTIONS.m_slIsFeatureSupported ) - { - CCP_LOGERR( "Library sl.interposer.dll is missing critical functions slInit, slShutdown, slIsFeatureSupported making streamline unusable. Updating nVidia driver version may halp." ); - ReleaseStreamline(); - return sl::Result::eErrorDriverOutOfDate; - } + INITIALIZE_FUNCTION( slSetTagForFrame ); + INITIALIZE_FUNCTION( slSetConstants ); + INITIALIZE_FUNCTION( slEvaluateFeature ); + } + if( !FUNCTIONS.m_slInit || !FUNCTIONS.m_slShutdown || !FUNCTIONS.m_slIsFeatureSupported ) + { + CCP_LOGERR( "Library sl.interposer.dll is missing critical functions slInit, slShutdown, slIsFeatureSupported making streamline unusable. Updating nVidia driver version may halp." ); + ReleaseStreamline(); + return sl::Result::eErrorDriverOutOfDate; + } - // now set it up - { - sl::Preferences pref{}; + // now set it up + + { + sl::Preferences pref{}; #if TRINITY_PLATFORM == TRINITY_DIRECTX11 - pref.renderAPI = sl::RenderAPI::eD3D11; + pref.renderAPI = sl::RenderAPI::eD3D11; #elif TRINITY_PLATFORM == TRINITY_DIRECTX12 - pref.renderAPI = sl::RenderAPI::eD3D12; + pref.renderAPI = sl::RenderAPI::eD3D12; #endif - std::vector features; + std::vector features; - features.push_back( sl::kFeatureDLSS ); // dlss module + features.push_back( sl::kFeatureDLSS ); // dlss module #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - features.push_back( sl::kFeatureDLSS_G ); // frame generation is only available on dx12 - features.push_back( sl::kFeatureReflex ); // dlssg requires reflex - features.push_back( sl::kFeaturePCL ); + features.push_back( sl::kFeatureDLSS_G ); // frame generation is only available on dx12 + features.push_back( sl::kFeatureReflex ); // dlssg requires reflex + features.push_back( sl::kFeaturePCL ); #endif - if( g_upscalingDebug ) - { - pref.showConsole = true; // for debugging, set to false in production - pref.logLevel = sl::LogLevel::eVerbose; + if( g_upscalingDebug ) + { + pref.showConsole = true; // for debugging, set to false in production + pref.logLevel = sl::LogLevel::eVerbose; #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - // note that imgui will only work for non-production builds of streamline plugins - features.push_back( sl::kFeatureImGUI ); + // note that imgui will only work for non-production builds of streamline plugins + features.push_back( sl::kFeatureImGUI ); #endif - } - else - { - pref.showConsole = false; - pref.logLevel = sl::LogLevel::eOff; - } + } + else + { + pref.showConsole = false; + pref.logLevel = sl::LogLevel::eOff; + } - sl::Feature* featuresToEnable = features.data(); - pref.numFeaturesToLoad = (uint32_t)features.size(); - pref.featuresToLoad = featuresToEnable; - pref.logMessageCallback = Tr2StreamlineLog; + sl::Feature* featuresToEnable = features.data(); + pref.numFeaturesToLoad = (uint32_t)features.size(); + pref.featuresToLoad = featuresToEnable; + pref.logMessageCallback = Tr2StreamlineLog; - // the appID comes from python, through the trinity settings - pref.applicationId = appID; - pref.flags |= sl::PreferenceFlags::eUseManualHooking | sl::PreferenceFlags::eUseFrameBasedResourceTagging; - STREAMLINE_INITIALIZATION_RESULT = FUNCTIONS.m_slInit( pref, sl::kSDKVersion ); + // the appID comes from python, through the trinity settings + pref.applicationId = appID; + pref.flags |= sl::PreferenceFlags::eUseManualHooking | sl::PreferenceFlags::eUseFrameBasedResourceTagging; + STREAMLINE_INITIALIZATION_RESULT = FUNCTIONS.m_slInit( pref, sl::kSDKVersion ); - if( STREAMLINE_INITIALIZATION_RESULT != sl::Result::eOk ) - { - CCP_LOGERR( "NVidia Streamline NOT initialized. Error code: %d", STREAMLINE_INITIALIZATION_RESULT ); - ReleaseStreamline(); - return STREAMLINE_INITIALIZATION_RESULT; - } + if( STREAMLINE_INITIALIZATION_RESULT != sl::Result::eOk ) + { + CCP_LOGERR( "NVidia Streamline NOT initialized. Error code: %d", STREAMLINE_INITIALIZATION_RESULT ); + ReleaseStreamline(); + return STREAMLINE_INITIALIZATION_RESULT; } + } - STREAMLINE_INITIALIZED = true; - CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); + STREAMLINE_INITIALIZED = true; + CCP_LOGNOTICE( "NVidia Streamline successfully initialized" ); - return STREAMLINE_INITIALIZATION_RESULT; - } + return STREAMLINE_INITIALIZATION_RESULT; +} - void ReleaseStreamline( ) +void ReleaseStreamline() +{ + if( STREAMLINE_MODULE ) { - if( STREAMLINE_MODULE ) + if( STREAMLINE_INITIALIZED ) { - if (STREAMLINE_INITIALIZED) + if( SL_FAILED( res, FUNCTIONS.m_slShutdown() ) ) { - if( SL_FAILED( res, FUNCTIONS.m_slShutdown() ) ) - { - CCP_LOGERR( "Could not release streamline %d", res ); - } - else - { - CCP_LOGNOTICE( "NVidia Streamline successfully released" ); - } + CCP_LOGERR( "Could not release streamline %d", res ); } + else + { + CCP_LOGNOTICE( "NVidia Streamline successfully released" ); + } + } - memset( &FUNCTIONS, 0, sizeof( FUNCTIONS ) ); - memset( &FEATURE_FUNCTIONS, 0, sizeof( FEATURE_FUNCTIONS ) ); + memset( &FUNCTIONS, 0, sizeof( FUNCTIONS ) ); + memset( &FEATURE_FUNCTIONS, 0, sizeof( FEATURE_FUNCTIONS ) ); - FreeLibrary( STREAMLINE_MODULE ); + FreeLibrary( STREAMLINE_MODULE ); - STREAMLINE_INITIALIZED = false; - STREAMLINE_MODULE = nullptr; - STREAMLINE_DEVICE_SET = false; - STREAMLINE_DLSS_SUPPORTED = false; + STREAMLINE_INITIALIZED = false; + STREAMLINE_MODULE = nullptr; + STREAMLINE_DEVICE_SET = false; + STREAMLINE_DLSS_SUPPORTED = false; #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - STREAMLINE_FRAME_GENERATION_SUPPORTED = false; + STREAMLINE_FRAME_GENERATION_SUPPORTED = false; #endif - } } +} - sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) - { +sl::CommandBuffer* GetCommandBuffer( Tr2RenderContextAL& renderContext ) +{ #if TRINITY_PLATFORM == TRINITY_DIRECTX11 - return renderContext.m_context; + return renderContext.m_context; #elif TRINITY_PLATFORM == TRINITY_DIRECTX12 - return renderContext.m_commandList; + return renderContext.m_commandList; #endif - } +} - bool CheckFeature( sl::AdapterInfo adapterInfo, sl::Feature feature ) - { - auto pluginName = GetPluginName( feature ); +bool CheckFeature( sl::AdapterInfo adapterInfo, sl::Feature feature ) +{ + auto pluginName = GetPluginName( feature ); - auto result = FUNCTIONS.m_slIsFeatureSupported( feature, adapterInfo ); - if( result != sl::Result::eOk ) - { - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is not available because of error %d: '%s'", pluginName, result, GetSlResultMessage(result) ); - } - else - { - CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", pluginName ); - } - return result == sl::Result::eOk; + auto result = FUNCTIONS.m_slIsFeatureSupported( feature, adapterInfo ); + if( result != sl::Result::eOk ) + { + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is not available because of error %d: '%s'", pluginName, result, GetSlResultMessage( result ) ); } + else + { + CCP_LOGNOTICE( "NVidia Streamline plugin '%s' is available", pluginName ); + } + return result == sl::Result::eOk; +} - sl::Result SetDevice( void* d3dDevice, uint32_t adapter ) +sl::Result SetDevice( void* d3dDevice, uint32_t adapter ) +{ + if( STREAMLINE_DEVICE_SET ) { - if (STREAMLINE_DEVICE_SET) - { - CCP_LOGERR( "Streamline D3D device already set!" ); - return sl::Result::eOk; - } + CCP_LOGERR( "Streamline D3D device already set!" ); + return sl::Result::eOk; + } - sl::Result result = CR_SL( FUNCTIONS.m_slSetD3DDevice( d3dDevice ) ); + sl::Result result = CR_SL( FUNCTIONS.m_slSetD3DDevice( d3dDevice ) ); - if (result != sl::Result::eOk) - { - CCP_LOGERR( "Failed to set Streamline D3D device!" ); - return result; - } + if( result != sl::Result::eOk ) + { + CCP_LOGERR( "Failed to set Streamline D3D device!" ); + return result; + } - STREAMLINE_DEVICE_SET = true; + STREAMLINE_DEVICE_SET = true; - Tr2AdapterInfo videoAdapterInfo; - Tr2VideoAdapterInfo::GetAdapterInfo( adapter, videoAdapterInfo ); - sl::AdapterInfo info; - info.deviceLUID = videoAdapterInfo.luid; - info.deviceLUIDSizeInBytes = sizeof( LUID ); + Tr2AdapterInfo videoAdapterInfo; + Tr2VideoAdapterInfo::GetAdapterInfo( adapter, videoAdapterInfo ); + sl::AdapterInfo info; + info.deviceLUID = videoAdapterInfo.luid; + info.deviceLUIDSizeInBytes = sizeof( LUID ); - bool dlssSupported = true; - dlssSupported &= CheckFeature( info, sl::kFeatureDLSS ); - if (dlssSupported) - { - INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS, slDLSSGetOptimalSettings ); - INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS, slDLSSSetOptions ); - STREAMLINE_DLSS_SUPPORTED = true; - } + bool dlssSupported = true; + dlssSupported &= CheckFeature( info, sl::kFeatureDLSS ); + if( dlssSupported ) + { + INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS, slDLSSGetOptimalSettings ); + INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS, slDLSSSetOptions ); + STREAMLINE_DLSS_SUPPORTED = true; + } #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - bool frameGenerationSupport = dlssSupported; - frameGenerationSupport &= CheckFeature( info, sl::kFeatureDLSS_G ); - frameGenerationSupport &= CheckFeature( info, sl::kFeatureReflex ); - frameGenerationSupport &= CheckFeature( info, sl::kFeaturePCL ); + bool frameGenerationSupport = dlssSupported; + frameGenerationSupport &= CheckFeature( info, sl::kFeatureDLSS_G ); + frameGenerationSupport &= CheckFeature( info, sl::kFeatureReflex ); + frameGenerationSupport &= CheckFeature( info, sl::kFeaturePCL ); - if( frameGenerationSupport ) { - INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS_G, slDLSSGSetOptions ); - INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS_G, slDLSSGGetState ); + if( frameGenerationSupport ) + { + INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS_G, slDLSSGSetOptions ); + INITIALIZE_FEATURE_FUNCTION( sl::kFeatureDLSS_G, slDLSSGGetState ); - INITIALIZE_FEATURE_FUNCTION( sl::kFeatureReflex, slReflexSetOptions ); + INITIALIZE_FEATURE_FUNCTION( sl::kFeatureReflex, slReflexSetOptions ); - INITIALIZE_FEATURE_FUNCTION( sl::kFeaturePCL, slPCLSetMarker ); - STREAMLINE_FRAME_GENERATION_SUPPORTED = true; - } + INITIALIZE_FEATURE_FUNCTION( sl::kFeaturePCL, slPCLSetMarker ); + STREAMLINE_FRAME_GENERATION_SUPPORTED = true; + } #endif - return result; - } + return result; +} - sl::Result UpgradeInterface( void** nativeInterface ) - { - return CR_SL( FUNCTIONS.m_slUpgradeInterface( nativeInterface ) ); - } +sl::Result UpgradeInterface( void** nativeInterface ) +{ + return CR_SL( FUNCTIONS.m_slUpgradeInterface( nativeInterface ) ); +} - sl::Result SetFeatureLoaded( sl::Feature feature, bool enable ) - { - return CR_SL( FUNCTIONS.m_slSetFeatureLoaded( feature, enable ) ); - } +sl::Result SetFeatureLoaded( sl::Feature feature, bool enable ) +{ + return CR_SL( FUNCTIONS.m_slSetFeatureLoaded( feature, enable ) ); +} - sl::Result GetNewFrameToken( sl::FrameToken*& m_frameToken ) - { - return CR_SL( FUNCTIONS.m_slGetNewFrameToken( m_frameToken, nullptr ) ); - } +sl::Result GetNewFrameToken( sl::FrameToken*& m_frameToken ) +{ + return CR_SL( FUNCTIONS.m_slGetNewFrameToken( m_frameToken, nullptr ) ); +} - sl::Result SetTagsForFrame( Tr2RenderContextAL& renderContext, const sl::FrameToken& frame, const sl::ViewportHandle& viewport, const sl::ResourceTag* tags, uint32_t numTags ) - { - return CR_SL( FUNCTIONS.m_slSetTagForFrame( frame, viewport, tags, numTags, GetCommandBuffer( renderContext ) ) ); - } +sl::Result SetTagsForFrame( Tr2RenderContextAL& renderContext, const sl::FrameToken& frame, const sl::ViewportHandle& viewport, const sl::ResourceTag* tags, uint32_t numTags ) +{ + return CR_SL( FUNCTIONS.m_slSetTagForFrame( frame, viewport, tags, numTags, GetCommandBuffer( renderContext ) ) ); +} - sl::Result SetConstants( const sl::Constants& values, const sl::FrameToken& frame, const sl::ViewportHandle& viewport ) - { - return CR_SL( FUNCTIONS.m_slSetConstants( values, frame, viewport ) ); - } +sl::Result SetConstants( const sl::Constants& values, const sl::FrameToken& frame, const sl::ViewportHandle& viewport ) +{ + return CR_SL( FUNCTIONS.m_slSetConstants( values, frame, viewport ) ); +} - sl::Result EvaluateFeature( Tr2RenderContextAL& renderContext, sl::Feature feature, const sl::FrameToken& frame, const sl::BaseStructure** inputs, uint32_t numInputs ) - { - return CR_SL( FUNCTIONS.m_slEvaluateFeature( feature, frame, inputs, numInputs, GetCommandBuffer( renderContext ) ) ); - } +sl::Result EvaluateFeature( Tr2RenderContextAL& renderContext, sl::Feature feature, const sl::FrameToken& frame, const sl::BaseStructure** inputs, uint32_t numInputs ) +{ + return CR_SL( FUNCTIONS.m_slEvaluateFeature( feature, frame, inputs, numInputs, GetCommandBuffer( renderContext ) ) ); +} - sl::Result GetDLSSOptimalSettings( const sl::DLSSOptions& options, sl::DLSSOptimalSettings& settings ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGetOptimalSettings( options, settings ) ); - } +sl::Result GetDLSSOptimalSettings( const sl::DLSSOptions& options, sl::DLSSOptimalSettings& settings ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGetOptimalSettings( options, settings ) ); +} - sl::Result SetDLSSOptions( const sl::ViewportHandle& viewport, const sl::DLSSOptions& options ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slDLSSSetOptions( viewport, options ) ); - } +sl::Result SetDLSSOptions( const sl::ViewportHandle& viewport, const sl::DLSSOptions& options ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slDLSSSetOptions( viewport, options ) ); +} + +sl::Result SetNISOptions( const sl::ViewportHandle& viewport, const sl::NISOptions& options ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slNISSetOptions( viewport, options ) ); +} - sl::Result SetNISOptions( const sl::ViewportHandle& viewport, const sl::NISOptions& options ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slNISSetOptions( viewport, options ) ); - } - #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - - sl::Result SetDLSSGOptions( const sl::ViewportHandle& viewport, const sl::DLSSGOptions& options ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGSetOptions(viewport, options) ); - } - sl::Result GetDLSSGState( const sl::ViewportHandle& viewport, sl::DLSSGState& state, const sl::DLSSGOptions* options ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGGetState( viewport, state, options ) ); - } +sl::Result SetDLSSGOptions( const sl::ViewportHandle& viewport, const sl::DLSSGOptions& options ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGSetOptions( viewport, options ) ); +} +sl::Result GetDLSSGState( const sl::ViewportHandle& viewport, sl::DLSSGState& state, const sl::DLSSGOptions* options ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slDLSSGGetState( viewport, state, options ) ); +} - sl::Result SetReflexOptions( const sl::ReflexOptions& options ) - { - return CR_SL( FEATURE_FUNCTIONS.m_slReflexSetOptions( options ) ); - } +sl::Result SetReflexOptions( const sl::ReflexOptions& options ) +{ + return CR_SL( FEATURE_FUNCTIONS.m_slReflexSetOptions( options ) ); +} - void SetPCLMarker( Tr2RenderContextEnum::FrameEvent& frameEvent, sl::FrameToken* m_frameToken ) - { - if( !m_frameToken ) - { - return; - } +void SetPCLMarker( Tr2RenderContextEnum::FrameEvent& frameEvent, sl::FrameToken* m_frameToken ) +{ - sl::PCLMarker slEvent = (sl::PCLMarker)0; + if( !m_frameToken ) + { + return; + } - switch( frameEvent ) - { - case Tr2RenderContextEnum::FRAME_EVENT_PRESENT_STARTED: - slEvent = sl::PCLMarker::ePresentStart; - break; - case Tr2RenderContextEnum::FRAME_EVENT_PRESENT_FINISHED: - slEvent = sl::PCLMarker::ePresentEnd; - break; - case Tr2RenderContextEnum::FRAME_EVENT_UPDATE_STARTED: - slEvent = sl::PCLMarker::eSimulationStart; - break; - case Tr2RenderContextEnum::FRAME_EVENT_UPDATE_FINISHED: - slEvent = sl::PCLMarker::eSimulationEnd; - break; - case Tr2RenderContextEnum::FRAME_EVENT_RENDERING_STARTED: - slEvent = sl::PCLMarker::eRenderSubmitStart; - break; - case Tr2RenderContextEnum::FRAME_EVENT_RENDERING_FINISHED: - slEvent = sl::PCLMarker::eRenderSubmitEnd; - break; - } + sl::PCLMarker slEvent = (sl::PCLMarker)0; - if( SL_FAILED( result, FEATURE_FUNCTIONS.m_slPCLSetMarker( slEvent, *m_frameToken ) ) ) - { - CCP_LOGERR( "Reflex failed to set marker %d (%d)", slEvent, result ); - } + switch( frameEvent ) + { + case Tr2RenderContextEnum::FRAME_EVENT_PRESENT_STARTED: + slEvent = sl::PCLMarker::ePresentStart; + break; + case Tr2RenderContextEnum::FRAME_EVENT_PRESENT_FINISHED: + slEvent = sl::PCLMarker::ePresentEnd; + break; + case Tr2RenderContextEnum::FRAME_EVENT_UPDATE_STARTED: + slEvent = sl::PCLMarker::eSimulationStart; + break; + case Tr2RenderContextEnum::FRAME_EVENT_UPDATE_FINISHED: + slEvent = sl::PCLMarker::eSimulationEnd; + break; + case Tr2RenderContextEnum::FRAME_EVENT_RENDERING_STARTED: + slEvent = sl::PCLMarker::eRenderSubmitStart; + break; + case Tr2RenderContextEnum::FRAME_EVENT_RENDERING_FINISHED: + slEvent = sl::PCLMarker::eRenderSubmitEnd; + break; + } + + if( SL_FAILED( result, FEATURE_FUNCTIONS.m_slPCLSetMarker( slEvent, *m_frameToken ) ) ) + { + CCP_LOGERR( "Reflex failed to set marker %d (%d)", slEvent, result ); } +} #endif - bool IsDLSSAvailable() +bool IsDLSSAvailable() +{ + if( !STREAMLINE_DEVICE_SET ) { - if( !STREAMLINE_DEVICE_SET ) - { - CCP_LOGERR( "Tr2StreamlineAL::IsDLSSAvailable() called before D3D device was set!" ); - } - return STREAMLINE_DLSS_SUPPORTED; + CCP_LOGERR( "Tr2StreamlineAL::IsDLSSAvailable() called before D3D device was set!" ); } + return STREAMLINE_DLSS_SUPPORTED; +} #if TRINITY_PLATFORM == TRINITY_DIRECTX12 - bool IsFrameGenerationAvailable() +bool IsFrameGenerationAvailable() +{ + if( !STREAMLINE_DEVICE_SET ) { - if (!STREAMLINE_DEVICE_SET) - { - CCP_LOGERR( "Tr2StreamlineAL::IsFrameGenerationAvailable() called before D3D device was set!" ); - } - return STREAMLINE_FRAME_GENERATION_SUPPORTED; + CCP_LOGERR( "Tr2StreamlineAL::IsFrameGenerationAvailable() called before D3D device was set!" ); } + return STREAMLINE_FRAME_GENERATION_SUPPORTED; +} #endif - - void FreeResources( sl::Feature feature, const sl::ViewportHandle& viewport ) + +void FreeResources( sl::Feature feature, const sl::ViewportHandle& viewport ) +{ + if( SL_FAILED( res, FUNCTIONS.m_slFreeResources( feature, viewport ) ) ) { - if( SL_FAILED(res, FUNCTIONS.m_slFreeResources(feature, viewport) ) ) - { - CCP_LOGERR( "Tr2StreamlineAL::FreeResources failed to free resources for %s", GetPluginName( feature ) ); - } + CCP_LOGERR( "Tr2StreamlineAL::FreeResources failed to free resources for %s", GetPluginName( feature ) ); } +} } #endif diff --git a/trinityal/src/Tr2SwapChainAL.cpp b/trinityal/src/Tr2SwapChainAL.cpp index ac90fb6c8..42399eae7 100644 --- a/trinityal/src/Tr2SwapChainAL.cpp +++ b/trinityal/src/Tr2SwapChainAL.cpp @@ -6,19 +6,19 @@ namespace { - std::shared_ptr NullSC() - { - static std::shared_ptr nullSC = std::make_shared(); - return nullSC; - } +std::shared_ptr NullSC() +{ + static std::shared_ptr nullSC = std::make_shared(); + return nullSC; +} } -Tr2SwapChainAL::Tr2SwapChainAL() - :m_swapChain( NullSC() ) +Tr2SwapChainAL::Tr2SwapChainAL() : + m_swapChain( NullSC() ) { } -ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL &renderContext ) +ALResult Tr2SwapChainAL::Create( Tr2WindowHandle windowHandle, Tr2PrimaryRenderContextAL& renderContext ) { m_swapChain = std::make_shared(); auto hr = m_swapChain->Create( windowHandle, renderContext ); @@ -60,9 +60,9 @@ bool Tr2SwapChainAL::operator==( const Tr2SwapChainAL& other ) const return m_swapChain == other.m_swapChain; } -Tr2ALMemoryType Tr2SwapChainAL::GetMemoryClass() const -{ - return m_swapChain->GetMemoryClass(); +Tr2ALMemoryType Tr2SwapChainAL::GetMemoryClass() const +{ + return m_swapChain->GetMemoryClass(); } ALResult Tr2SwapChainAL::SetName( const char* name ) diff --git a/trinityal/src/Tr2TextureAL.cpp b/trinityal/src/Tr2TextureAL.cpp index 6ed8e27be..4c71ff62e 100644 --- a/trinityal/src/Tr2TextureAL.cpp +++ b/trinityal/src/Tr2TextureAL.cpp @@ -16,7 +16,7 @@ std::shared_ptr& NullTexture() static std::shared_ptr nullTexture = std::make_shared(); return nullTexture; } - + } @@ -189,20 +189,20 @@ ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destS namespace { - bool FormatIsBGR( Tr2RenderContextEnum::PixelFormat format ) +bool FormatIsBGR( Tr2RenderContextEnum::PixelFormat format ) +{ + switch( format ) { - switch( format ) - { - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM: - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM: - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: - case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB: - return true; - default: - return false; - } + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM: + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM: + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB: + case Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB: + return true; + default: + return false; } } +} ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& renderContext ) const { @@ -273,34 +273,34 @@ TrinityALImpl::Tr2TextureAL* Tr2TextureAL::TrinityALImpl_GetObject() const namespace { - void ConvertUsage( Tr2RenderContextEnum::BufferUsage usage, Tr2GpuUsage::Type& gpuUsage, Tr2CpuUsage::Type& cpuUsage ) +void ConvertUsage( Tr2RenderContextEnum::BufferUsage usage, Tr2GpuUsage::Type& gpuUsage, Tr2CpuUsage::Type& cpuUsage ) +{ + gpuUsage = Tr2GpuUsage::SHADER_RESOURCE; + cpuUsage = Tr2CpuUsage::NONE; + + if( ( usage & Tr2RenderContextEnum::USAGE_IMMUTABLE ) != 0 ) + { + cpuUsage = cpuUsage | Tr2CpuUsage::READ; + } + else if( ( usage & Tr2RenderContextEnum::USAGE_LOCK_FREQUENTLY ) != 0 ) + { + cpuUsage = cpuUsage | Tr2CpuUsage::WRITE_OFTEN; + } + else + { + cpuUsage = cpuUsage | Tr2CpuUsage::WRITE; + } + if( ( usage & Tr2RenderContextEnum::USAGE_CPU_READ ) != 0 ) + { + cpuUsage = cpuUsage | Tr2CpuUsage::READ; + } + if( ( usage & Tr2RenderContextEnum::USAGE_UNORDERED_ACCESS ) != 0 ) + { + gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; + } + if( ( usage & Tr2RenderContextEnum::USAGE_SHADER_RESOURCE ) != 0 ) { - gpuUsage = Tr2GpuUsage::SHADER_RESOURCE; - cpuUsage = Tr2CpuUsage::NONE; - - if( ( usage & Tr2RenderContextEnum::USAGE_IMMUTABLE ) != 0 ) - { - cpuUsage = cpuUsage | Tr2CpuUsage::READ; - } - else if( ( usage & Tr2RenderContextEnum::USAGE_LOCK_FREQUENTLY ) != 0 ) - { - cpuUsage = cpuUsage | Tr2CpuUsage::WRITE_OFTEN; - } - else - { - cpuUsage = cpuUsage | Tr2CpuUsage::WRITE; - } - if( ( usage & Tr2RenderContextEnum::USAGE_CPU_READ ) != 0 ) - { - cpuUsage = cpuUsage | Tr2CpuUsage::READ; - } - if( ( usage & Tr2RenderContextEnum::USAGE_UNORDERED_ACCESS ) != 0 ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::UNORDERED_ACCESS; - } - if( ( usage & Tr2RenderContextEnum::USAGE_SHADER_RESOURCE ) != 0 ) - { - gpuUsage = gpuUsage | Tr2GpuUsage::SHARED; - } + gpuUsage = gpuUsage | Tr2GpuUsage::SHARED; } } +} diff --git a/trinityal/src/Tr2VertexLayoutAL.cpp b/trinityal/src/Tr2VertexLayoutAL.cpp index 523153630..a6ba76a85 100644 --- a/trinityal/src/Tr2VertexLayoutAL.cpp +++ b/trinityal/src/Tr2VertexLayoutAL.cpp @@ -6,15 +6,15 @@ namespace { - std::shared_ptr NullLayout() - { - static std::shared_ptr nullLayout = std::make_shared(); - return nullLayout; - } +std::shared_ptr NullLayout() +{ + static std::shared_ptr nullLayout = std::make_shared(); + return nullLayout; +} } -Tr2VertexLayoutAL::Tr2VertexLayoutAL() - :m_layout( NullLayout() ) +Tr2VertexLayoutAL::Tr2VertexLayoutAL() : + m_layout( NullLayout() ) { } diff --git a/trinityal/src/upscaling/Tr2Fsr1Upscaling.cpp b/trinityal/src/upscaling/Tr2Fsr1Upscaling.cpp index d471a25fa..8611290af 100644 --- a/trinityal/src/upscaling/Tr2Fsr1Upscaling.cpp +++ b/trinityal/src/upscaling/Tr2Fsr1Upscaling.cpp @@ -12,37 +12,37 @@ namespace FSR1 { - const uint8_t SHADER_BYTECODE[] = { +const uint8_t SHADER_BYTECODE[] = { - #if TRINITY_PLATFORM == TRINITY_METAL - #include "include/upscaling/Fsr1Metal.h" - #else - #include "include/upscaling/Fsr1DX.h" - #endif - }; +#if TRINITY_PLATFORM == TRINITY_METAL +#include "include/upscaling/Fsr1Metal.h" +#else +#include "include/upscaling/Fsr1DX.h" +#endif +}; - //For some reason, metal uses the same register space for SRVs and UAVs, so the index is different for the Metal shader. - #if TRINITY_PLATFORM == TRINITY_METAL - const uint32_t SRV_REGISTER_INDEX = 1; - const uint32_t UAV_REGISTER_INDEX = 24; - #else - const uint32_t SRV_REGISTER_INDEX = 0; - const uint32_t UAV_REGISTER_INDEX = 0; - #endif - - struct FSRConstants - { - float Const0[4]; - float Const1[4]; - float Const2[4]; - float Const3[4]; - }; +//For some reason, metal uses the same register space for SRVs and UAVs, so the index is different for the Metal shader. +#if TRINITY_PLATFORM == TRINITY_METAL +const uint32_t SRV_REGISTER_INDEX = 1; +const uint32_t UAV_REGISTER_INDEX = 24; +#else +const uint32_t SRV_REGISTER_INDEX = 0; +const uint32_t UAV_REGISTER_INDEX = 0; +#endif + +struct FSRConstants +{ + float Const0[4]; + float Const1[4]; + float Const2[4]; + float Const3[4]; +}; } Tr2Fsr1UpscalingTechnique::Tr2Fsr1UpscalingTechnique( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : TECHNIQUE_PARENT_CLASS( renderContext, technique, setting, frameGeneration, adapter ) { - SanitizeState(); + SanitizeState(); } Tr2Fsr1UpscalingTechnique::~Tr2Fsr1UpscalingTechnique() @@ -75,7 +75,7 @@ bool Tr2Fsr1UpscalingTechnique::IsAvailable() const } #endif return true; -} +} Tr2UpscalingContextAL* Tr2Fsr1UpscalingTechnique::CreateContextInstance( Tr2UpscalingAL::UpscalingContextParams params ) { @@ -153,7 +153,6 @@ Tr2Fsr1UpscalingContext::Tr2Fsr1UpscalingContext( Tr2UpscalingAL::Setting settin Tr2Fsr1UpscalingContext::~Tr2Fsr1UpscalingContext() { - } bool Tr2Fsr1UpscalingContext::HasSharpening() const @@ -181,8 +180,8 @@ Tr2UpscalingAL::Result Tr2Fsr1UpscalingContext::Dispatch( Tr2UpscalingAL::Dispat GPU_REGION_AL( renderContext, "FSR1 Upscaling" ); - renderContext.SetShaderProgram(m_easuProgram); - + renderContext.SetShaderProgram( m_easuProgram ); + Tr2ResourceSetDescriptionAL desc( m_easuProgram ); desc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, FSR1::SRV_REGISTER_INDEX, *dispatchParameters.input ); desc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, FSR1::UAV_REGISTER_INDEX, *dispatchParameters.output ); @@ -192,12 +191,12 @@ Tr2UpscalingAL::Result Tr2Fsr1UpscalingContext::Dispatch( Tr2UpscalingAL::Dispat resourceSet.Create( desc, m_easuProgram, m_params.renderContext.GetPrimaryRenderContext() ); renderContext.SetResourceSet( resourceSet ); - + renderContext.SetConstants( m_constantBuffer, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ); - - - int workgroupSize = 16; - renderContext.RunComputeShader((m_displayWidth + workgroupSize - 1) / workgroupSize, (m_displayHeight + workgroupSize - 1) / workgroupSize, 1); + + + int workgroupSize = 16; + renderContext.RunComputeShader( ( m_displayWidth + workgroupSize - 1 ) / workgroupSize, ( m_displayHeight + workgroupSize - 1 ) / workgroupSize, 1 ); return Tr2UpscalingAL::Result::OK; } diff --git a/trinityal/src/upscaling/Tr2UpscalingAL.cpp b/trinityal/src/upscaling/Tr2UpscalingAL.cpp index 210f0fb45..54f0660c8 100644 --- a/trinityal/src/upscaling/Tr2UpscalingAL.cpp +++ b/trinityal/src/upscaling/Tr2UpscalingAL.cpp @@ -12,139 +12,141 @@ bool g_force_fsr1_availability = false; namespace Tr2UpscalingAL { - void LogResult( Result result ) +void LogResult( Result result ) +{ + switch( result ) { - switch( result ) - { - case OK: - CCP_LOGWARN( "Tr2Upscaling: OK" ); - break; - - case TECHNIQUE_NOT_SUPPORTED: - CCP_LOGWARN( "Tr2Upscaling: Platform is not supported for the selected upscaling technique" ); - break; - - case HARDWARE_NOT_SUPPORTED: - CCP_LOGWARN( "Tr2Upscaling: Hardware is not supported" ); - break; - case CONTEXT_SETUP_FAILED: - CCP_LOGWARN( "Tr2Upscaling: Context setup failed" ); - break; - case INCORRECT_INPUT: - CCP_LOGWARN( "Tr2Upscaling: Incorrect input" ); - break; - } + case OK: + CCP_LOGWARN( "Tr2Upscaling: OK" ); + break; + + case TECHNIQUE_NOT_SUPPORTED: + CCP_LOGWARN( "Tr2Upscaling: Platform is not supported for the selected upscaling technique" ); + break; + + case HARDWARE_NOT_SUPPORTED: + CCP_LOGWARN( "Tr2Upscaling: Hardware is not supported" ); + break; + case CONTEXT_SETUP_FAILED: + CCP_LOGWARN( "Tr2Upscaling: Context setup failed" ); + break; + case INCORRECT_INPUT: + CCP_LOGWARN( "Tr2Upscaling: Incorrect input" ); + break; } +} - JitterSequence GenerateHaltonSequence( uint32_t totalPhases, uint32_t xBase, uint32_t yBase ) - { - auto result = JitterSequence(); - result.reserve( totalPhases ); - - for( uint32_t i = 0; i < totalPhases; ++i ) - { - result.push_back( { Halton( i, xBase ), Halton( i, yBase ) } ); - } - - return result; - } +JitterSequence GenerateHaltonSequence( uint32_t totalPhases, uint32_t xBase, uint32_t yBase ) +{ + auto result = JitterSequence(); + result.reserve( totalPhases ); - float Halton( uint32_t index, uint32_t base ) + for( uint32_t i = 0; i < totalPhases; ++i ) { - float result = 0.0; - float fractional = 1.0; - while( index > 0 ) - { - fractional /= float( base ); - result += fractional * float( index % base ); - index /= base; - } - return result - 0.5f; + result.push_back( { Halton( i, xBase ), Halton( i, yBase ) } ); } - uint32_t ConvertDisplaySizeToRenderSize( uint32_t displaySize, float upscaling ) - { - uint32_t renderSize = uint32_t( (float)displaySize / (float)upscaling ); - uint32_t addition = displaySize % 2 != renderSize % 2; - return renderSize + addition; - } + return result; +} - UpscalingInfo::UpscalingInfo(): - displayWidth( 0 ), - displayHeight( 0 ), - renderWidth( 0 ), - renderHeight( 0 ), - technique( Tr2UpscalingAL::Technique::NONE ), - setting( Tr2UpscalingAL::Setting::NATIVE ), - frameGeneration( false ), - temporal(false), - hasSharpening(false), - upscalingAmount( 1.0f ), - jitterX( 0.0f ), - jitterY( 0.0f ), - mipLevelBias( 0.0f ) - {} - - UpscalingContextParams::UpscalingContextParams( Tr2RenderContextAL& renderContext ) : - displayWidth( 0 ), - displayHeight( 0 ), - sourceFormat( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_UNKNOWN ), - depthFormat( Tr2RenderContextEnum::DepthStencilFormat::DSFMT_UNKNOWN ), - allowFramegen( false ), - renderContext( renderContext ) - {} - - //implement the equal operator - bool UpscalingContextParams::operator==( const UpscalingContextParams& other ) const +float Halton( uint32_t index, uint32_t base ) +{ + float result = 0.0; + float fractional = 1.0; + while( index > 0 ) { - return displayWidth == other.displayWidth && - displayHeight == other.displayHeight && - sourceFormat == other.sourceFormat && - depthFormat == other.depthFormat && - allowFramegen == other.allowFramegen; + fractional /= float( base ); + result += fractional * float( index % base ); + index /= base; } + return result - 0.5f; +} - const char* GetTechniqueName( Technique technique ) +uint32_t ConvertDisplaySizeToRenderSize( uint32_t displaySize, float upscaling ) +{ + uint32_t renderSize = uint32_t( (float)displaySize / (float)upscaling ); + uint32_t addition = displaySize % 2 != renderSize % 2; + return renderSize + addition; +} + +UpscalingInfo::UpscalingInfo() : + displayWidth( 0 ), + displayHeight( 0 ), + renderWidth( 0 ), + renderHeight( 0 ), + technique( Tr2UpscalingAL::Technique::NONE ), + setting( Tr2UpscalingAL::Setting::NATIVE ), + frameGeneration( false ), + temporal( false ), + hasSharpening( false ), + upscalingAmount( 1.0f ), + jitterX( 0.0f ), + jitterY( 0.0f ), + mipLevelBias( 0.0f ) +{ +} + +UpscalingContextParams::UpscalingContextParams( Tr2RenderContextAL& renderContext ) : + displayWidth( 0 ), + displayHeight( 0 ), + sourceFormat( Tr2RenderContextEnum::PixelFormat::PIXEL_FORMAT_UNKNOWN ), + depthFormat( Tr2RenderContextEnum::DepthStencilFormat::DSFMT_UNKNOWN ), + allowFramegen( false ), + renderContext( renderContext ) +{ +} + +//implement the equal operator +bool UpscalingContextParams::operator==( const UpscalingContextParams& other ) const +{ + return displayWidth == other.displayWidth && + displayHeight == other.displayHeight && + sourceFormat == other.sourceFormat && + depthFormat == other.depthFormat && + allowFramegen == other.allowFramegen; +} + +const char* GetTechniqueName( Technique technique ) +{ + switch( technique ) { - switch( technique ) - { - case NONE: - return "None"; - case FSR1: - return "FSR1"; - case FSR2: - return "FSR2"; - case FSR3: - return "FSR3"; - case DLSS: - return "DLSS"; - case METALFX: - return "MetalFx"; - case XESS: - return "XeSS"; - } - return "Unknown"; + case NONE: + return "None"; + case FSR1: + return "FSR1"; + case FSR2: + return "FSR2"; + case FSR3: + return "FSR3"; + case DLSS: + return "DLSS"; + case METALFX: + return "MetalFx"; + case XESS: + return "XeSS"; } - - const char* GetSettingName( Setting setting ) + return "Unknown"; +} + +const char* GetSettingName( Setting setting ) +{ + switch( setting ) { - switch( setting ) - { - case NATIVE: - return "Native"; - case ULTRA_QUALITY: - return "Ultra Quality"; - case QUALITY: - return "Quality"; - case BALANCED: - return "Balanced"; - case PERFORMANCE: - return "Performance"; - case ULTRA_PERFORMANCE: - return "Ultra Performance"; - } - return "Unknown"; + case NATIVE: + return "Native"; + case ULTRA_QUALITY: + return "Ultra Quality"; + case QUALITY: + return "Quality"; + case BALANCED: + return "Balanced"; + case PERFORMANCE: + return "Performance"; + case ULTRA_PERFORMANCE: + return "Ultra Performance"; } + return "Unknown"; +} } @@ -152,7 +154,7 @@ namespace Tr2UpscalingAL Tr2UpscalingTechniqueAL::Tr2UpscalingTechniqueAL( Tr2RenderContextAL& renderContext, Tr2UpscalingAL::Technique technique, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) : m_frameGeneration( frameGeneration ), m_setting( setting ), - m_technique( technique ), + m_technique( technique ), m_renderContext( renderContext ) { m_contexts = std::map>(); @@ -174,7 +176,7 @@ void Tr2UpscalingTechniqueAL::SanitizeState() uint32_t leastDistance = std::numeric_limits().max(); for( auto& availableSetting : availableSettings ) { - uint32_t currentDistance = abs(int(m_setting) - int(availableSetting)); + uint32_t currentDistance = abs( int( m_setting ) - int( availableSetting ) ); if( leastDistance > currentDistance ) { bestCandidate = availableSetting; @@ -222,30 +224,30 @@ Tr2UpscalingContextAL* Tr2UpscalingTechniqueAL::GetContext( uint32_t upscalingCo Tr2UpscalingContextAL* Tr2UpscalingTechniqueAL::CreateContext( Tr2UpscalingAL::UpscalingContextParams params, uint32_t existingContext ) { - if( existingContext != Tr2UpscalingAL::INVALID_CONTEXT_ID ) - { - auto context = m_contexts.find( existingContext ); - if( context != m_contexts.end() ) - { - if( context->second->Reuse( params) ) - { + if( existingContext != Tr2UpscalingAL::INVALID_CONTEXT_ID ) + { + auto context = m_contexts.find( existingContext ); + if( context != m_contexts.end() ) + { + if( context->second->Reuse( params ) ) + { context->second->SetupForReuse(); - return context->second.get(); - } - } - DeleteContext( existingContext ); - } - // safety harness, displayWidth and displayHeight need to be bigger than 1 since it is hard to render into something - // that is smaller than a pixel... - if( params.displayWidth < 2 || params.displayHeight < 2 ) - { - CCP_LOGWARN( "Cannot create an upscaler for output that is less than 2x2 pixels. Ignoring context creation" ); - return nullptr; - } - auto context = CreateContextInstance( params ); - m_contexts[context->GetID()].reset( context ); - - return context; + return context->second.get(); + } + } + DeleteContext( existingContext ); + } + // safety harness, displayWidth and displayHeight need to be bigger than 1 since it is hard to render into something + // that is smaller than a pixel... + if( params.displayWidth < 2 || params.displayHeight < 2 ) + { + CCP_LOGWARN( "Cannot create an upscaler for output that is less than 2x2 pixels. Ignoring context creation" ); + return nullptr; + } + auto context = CreateContextInstance( params ); + m_contexts[context->GetID()].reset( context ); + + return context; } void Tr2UpscalingTechniqueAL::DeleteContext( uint32_t contextID ) @@ -260,18 +262,18 @@ void Tr2UpscalingTechniqueAL::DeleteContext( uint32_t contextID ) m_contexts.erase( context ); } -bool Tr2UpscalingTechniqueAL::IsAvailable( ) const +bool Tr2UpscalingTechniqueAL::IsAvailable() const { return true; } -bool Tr2UpscalingTechniqueAL::SupportsFrameGeneration( ) const +bool Tr2UpscalingTechniqueAL::SupportsFrameGeneration() const { return false; } Tr2UpscalingContextAL::Tr2UpscalingContextAL( Tr2UpscalingAL::Setting setting, bool frameGeneration, Tr2UpscalingAL::UpscalingContextParams params ) : - m_setting(setting), + m_setting( setting ), m_displayWidth( params.displayWidth ), m_displayHeight( params.displayHeight ), m_renderWidth( 0 ), @@ -281,10 +283,10 @@ Tr2UpscalingContextAL::Tr2UpscalingContextAL( Tr2UpscalingAL::Setting setting, b m_jitterX( 0.0f ), m_jitterY( 0.0f ), m_jitterXScale( 2.0f ), - m_jitterYScale( -2.0f ), + m_jitterYScale( -2.0f ), m_params( params ) { - static uint32_t CONTEXT_ID = 0; + static uint32_t CONTEXT_ID = 0; m_id = CONTEXT_ID++; if( m_id == Tr2UpscalingAL::INVALID_CONTEXT_ID ) @@ -308,7 +310,6 @@ bool Tr2UpscalingContextAL::Reuse( Tr2UpscalingAL::UpscalingContextParams params void Tr2UpscalingContextAL::SetupForReuse() { - } diff --git a/trinityal/stub/Tr2BufferALStub.cpp b/trinityal/stub/Tr2BufferALStub.cpp index 0bcc3aa38..c75aae08e 100644 --- a/trinityal/stub/Tr2BufferALStub.cpp +++ b/trinityal/stub/Tr2BufferALStub.cpp @@ -9,161 +9,161 @@ namespace { - template - bool HasFlag( T value, T flag ) - { - return ( value & flag ) == flag; - } +template +bool HasFlag( T value, T flag ) +{ + return ( value & flag ) == flag; +} } namespace TrinityALImpl { - ALResult Tr2BufferAL::Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ) - { - Destroy(); - - if( desc.count == 0 ) - { - return E_INVALIDARG; - } - - if( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) - { - return E_INVALIDARG; - } - - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - - m_desc = desc; - m_buffer.resize( "Tr2BufferAL", m_desc.count * m_desc.stride ); - return S_OK; - } +ALResult Tr2BufferAL::Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); - void Tr2BufferAL::Destroy() + if( desc.count == 0 ) { - m_desc.count = 0; - m_buffer.clear(); + return E_INVALIDARG; } - bool Tr2BufferAL::IsValid() const + if( !HasFlag( desc.cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) { - return m_buffer.size() > 0; + return E_INVALIDARG; } - Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const + if( !renderContext.IsValid() ) { - return AL_MEMORY_MANAGED; + return E_INVALIDCALL; } - const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const + m_desc = desc; + m_buffer.resize( "Tr2BufferAL", m_desc.count * m_desc.stride ); + return S_OK; +} + +void Tr2BufferAL::Destroy() +{ + m_desc.count = 0; + m_buffer.clear(); +} + +bool Tr2BufferAL::IsValid() const +{ + return m_buffer.size() > 0; +} + +Tr2ALMemoryType Tr2BufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +const Tr2BufferDescriptionAL& Tr2BufferAL::GetDesc() const +{ + return m_desc; +} + +ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - return m_desc; + data = nullptr; + return E_INVALIDCALL; } - - ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } - data = m_buffer.get(); - return S_OK; + return E_INVALIDCALL; } + data = m_buffer.get(); + return S_OK; +} - ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) +ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( size == 0 || offset + size > m_desc.stride * m_desc.count ) - { - data = nullptr; - return E_INVALIDARG; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } - data = m_buffer.get(); - return S_OK; + data = nullptr; + return E_INVALIDCALL; } - - void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& ) + if( size == 0 || offset + size > m_desc.stride * m_desc.count ) { + data = nullptr; + return E_INVALIDARG; } - - ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - data = nullptr; - return E_INVALIDCALL; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - data = m_buffer.get(); - return S_OK; + return E_INVALIDCALL; } + data = m_buffer.get(); + return S_OK; +} - void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& ) +void Tr2BufferAL::UnmapForReading( Tr2RenderContextAL& ) +{ +} + +ALResult Tr2BufferAL::MapForWriting( void*& data, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { + data = nullptr; + return E_INVALIDCALL; } - - ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void*, Tr2RenderContextAL & renderContext ) + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) ) { - if( !renderContext.IsValid() || !IsValid() ) - { - return E_INVALIDCALL; - } - if( offset + size > m_desc.count * m_desc.stride ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) || HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - return E_INVALIDCALL; - } - if( size == 0 ) - { - return S_OK; - } - return S_OK; + return E_INVALIDCALL; } + data = m_buffer.get(); + return S_OK; +} + +void Tr2BufferAL::UnmapForWriting( Tr2RenderContextAL& ) +{ +} - uint32_t Tr2BufferAL::GetSrvIndexInHeap() const +ALResult Tr2BufferAL::UpdateBuffer( uint32_t offset, uint32_t size, const void*, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() || !IsValid() ) { - return 0xffffffff; + return E_INVALIDCALL; } - - uint32_t Tr2BufferAL::GetUavIndexInHeap() const + if( offset + size > m_desc.count * m_desc.stride ) { - return 0xffffffff; + return E_INVALIDARG; } - - void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& ) const + if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE ) || HasFlag( m_desc.cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { + return E_INVALIDCALL; } - - ALResult Tr2BufferAL::SetName( const char* ) + if( size == 0 ) { return S_OK; } + return S_OK; +} + +uint32_t Tr2BufferAL::GetSrvIndexInHeap() const +{ + return 0xffffffff; +} + +uint32_t Tr2BufferAL::GetUavIndexInHeap() const +{ + return 0xffffffff; +} + +void Tr2BufferAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2BufferAL::SetName( const char* ) +{ + return S_OK; +} } diff --git a/trinityal/stub/Tr2BufferALStub.h b/trinityal/stub/Tr2BufferALStub.h index 1978160f1..5111c0c11 100644 --- a/trinityal/stub/Tr2BufferALStub.h +++ b/trinityal/stub/Tr2BufferALStub.h @@ -8,39 +8,39 @@ namespace TrinityALImpl { - class Tr2BufferAL : public Tr2DeviceResourceAL - { - public: - ALResult Create( - const Tr2BufferDescriptionAL& desc, - const void* initialData, - Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BufferDescriptionAL& GetDesc() const; - - ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); - ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); - - ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL & renderContext ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - uint32_t GetSrvIndexInHeap() const; - uint32_t GetUavIndexInHeap() const; - - private: - CcpMallocBuffer m_buffer; - Tr2BufferDescriptionAL m_desc; - - friend class Tr2RenderContextAL; - friend class Tr2PrimaryRenderContextAL; - }; +class Tr2BufferAL : public Tr2DeviceResourceAL +{ +public: + ALResult Create( + const Tr2BufferDescriptionAL& desc, + const void* initialData, + Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BufferDescriptionAL& GetDesc() const; + + ALResult MapForReading( const void*& data, Tr2RenderContextAL& renderContext ); + ALResult MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( void*& data, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); + + ALResult UpdateBuffer( uint32_t offset, uint32_t size, const void* data, Tr2RenderContextAL& renderContext ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + + uint32_t GetSrvIndexInHeap() const; + uint32_t GetUavIndexInHeap() const; + +private: + CcpMallocBuffer m_buffer; + Tr2BufferDescriptionAL m_desc; + + friend class Tr2RenderContextAL; + friend class Tr2PrimaryRenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2CapsALStub.cpp b/trinityal/stub/Tr2CapsALStub.cpp index 955fedb55..6d667db19 100644 --- a/trinityal/stub/Tr2CapsALStub.cpp +++ b/trinityal/stub/Tr2CapsALStub.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2CapsALStub.h" diff --git a/trinityal/stub/Tr2CapsALStub.h b/trinityal/stub/Tr2CapsALStub.h index d2914db49..32e9fe550 100644 --- a/trinityal/stub/Tr2CapsALStub.h +++ b/trinityal/stub/Tr2CapsALStub.h @@ -4,7 +4,7 @@ #ifndef Tr2CapsALStub_H #define Tr2CapsALStub_H -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #define TRINITY_PLATFORM_SUPPORTS_BUFFER_SHADER_RESOURCES 0 diff --git a/trinityal/stub/Tr2ConstantBufferALStub.cpp b/trinityal/stub/Tr2ConstantBufferALStub.cpp index ff24a211c..43eb8a843 100644 --- a/trinityal/stub/Tr2ConstantBufferALStub.cpp +++ b/trinityal/stub/Tr2ConstantBufferALStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2ConstantBufferALStub.h" #include "ALLog.h" @@ -10,81 +10,81 @@ namespace TrinityALImpl { - Tr2ConstantBufferAL::Tr2ConstantBufferAL() - { - } +Tr2ConstantBufferAL::Tr2ConstantBufferAL() +{ +} - ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL &renderContext ) +ALResult Tr2ConstantBufferAL::Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - - if( size == 0 ) - { - return E_INVALIDARG; - } - - if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) && !initialData ) - { - CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); - return E_INVALIDARG; - } - - m_shadowCopy.resize( "Tr2ConstantBufferAL::m_shadowCopy", size ); - if( m_shadowCopy.empty() ) - { - return E_OUTOFMEMORY; - } - - return S_OK; + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL & /*renderContext*/ ) + if( size == 0 ) { - if( m_shadowCopy.empty() ) - { - *data = nullptr; - return E_FAIL; - } - - *data = m_shadowCopy.get(); - return S_OK; + return E_INVALIDARG; } - ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL & /*renderContext*/ ) + if( ( usage == Tr2ConstantUsageAL::IMMUTABLE ) && !initialData ) { - return S_OK; + CCP_AL_LOGERR( "Create: Trying to create an immutable buffer without providing data" ); + return E_INVALIDARG; } - bool Tr2ConstantBufferAL::IsValid() const + m_shadowCopy.resize( "Tr2ConstantBufferAL::m_shadowCopy", size ); + if( m_shadowCopy.empty() ) { - return !m_shadowCopy.empty(); + return E_OUTOFMEMORY; } - void Tr2ConstantBufferAL::Destroy() - { - m_shadowCopy.clear(); - } + return S_OK; +} - uint32_t Tr2ConstantBufferAL::GetSize() const +ALResult Tr2ConstantBufferAL::Lock( void** data, Tr2RenderContextAL& /*renderContext*/ ) +{ + if( m_shadowCopy.empty() ) { - return static_cast( m_shadowCopy.size() ); + *data = nullptr; + return E_FAIL; } - Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } + *data = m_shadowCopy.get(); + return S_OK; +} - void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +ALResult Tr2ConstantBufferAL::Unlock( Tr2RenderContextAL& /*renderContext*/ ) +{ + return S_OK; +} - ALResult Tr2ConstantBufferAL::SetName( const char* ) - { - return S_OK; - } +bool Tr2ConstantBufferAL::IsValid() const +{ + return !m_shadowCopy.empty(); +} + +void Tr2ConstantBufferAL::Destroy() +{ + m_shadowCopy.clear(); +} + +uint32_t Tr2ConstantBufferAL::GetSize() const +{ + return static_cast( m_shadowCopy.size() ); +} + +Tr2ALMemoryType Tr2ConstantBufferAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2ConstantBufferAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2ConstantBufferAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2ConstantBufferALStub.h b/trinityal/stub/Tr2ConstantBufferALStub.h index 4a1f5c87a..990c51ad1 100644 --- a/trinityal/stub/Tr2ConstantBufferALStub.h +++ b/trinityal/stub/Tr2ConstantBufferALStub.h @@ -2,37 +2,37 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2ConstantBufferAL.h" namespace TrinityALImpl { - class Tr2ConstantBufferAL : public Tr2DeviceResourceAL - { - public: - Tr2ConstantBufferAL(); +class Tr2ConstantBufferAL : public Tr2DeviceResourceAL +{ +public: + Tr2ConstantBufferAL(); - ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL & renderContext ); - void Destroy(); + ALResult Create( uint32_t size, Tr2ConstantUsageAL::Type usage, const void* initialData, Tr2RenderContextAL& renderContext ); + void Destroy(); - ALResult Lock( void** data, Tr2RenderContextAL & renderContext ); - ALResult Unlock( Tr2RenderContextAL & renderContext ); + ALResult Lock( void** data, Tr2RenderContextAL& renderContext ); + ALResult Unlock( Tr2RenderContextAL& renderContext ); - bool IsValid() const; - uint32_t GetSize() const; - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + bool IsValid() const; + uint32_t GetSize() const; + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; - Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; +private: + Tr2ConstantBufferAL( const Tr2ConstantBufferAL& ) /* = delete */; + Tr2ConstantBufferAL& operator=( const Tr2ConstantBufferAL& ) /* = delete */; - CcpMallocBuffer m_shadowCopy; + CcpMallocBuffer m_shadowCopy; - friend class Tr2RenderContextAL; - }; + friend class Tr2RenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2FenceALStub.cpp b/trinityal/stub/Tr2FenceALStub.cpp index 901d26924..c6e3a370b 100644 --- a/trinityal/stub/Tr2FenceALStub.cpp +++ b/trinityal/stub/Tr2FenceALStub.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2FenceALStub.h" #include "Tr2RenderContextStub.h" @@ -9,84 +9,83 @@ namespace TrinityALImpl { - Tr2FenceAL::Tr2FenceAL() - :m_isValid( false ), - m_hasFence( false ) - { - } +Tr2FenceAL::Tr2FenceAL() : + m_isValid( false ), + m_hasFence( false ) +{ +} - Tr2FenceAL::~Tr2FenceAL() - { - } +Tr2FenceAL::~Tr2FenceAL() +{ +} - ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2FenceAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - m_isValid = true; - return S_OK; + return E_INVALIDARG; } + m_isValid = true; + return S_OK; +} - void Tr2FenceAL::Destroy() - { - m_isValid = false; - m_hasFence = false; - } +void Tr2FenceAL::Destroy() +{ + m_isValid = false; + m_hasFence = false; +} - bool Tr2FenceAL::IsValid() const - { - return m_isValid; - } +bool Tr2FenceAL::IsValid() const +{ + return m_isValid; +} - ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& ) +ALResult Tr2FenceAL::PutFence( Tr2RenderContextAL& ) +{ + if( !m_isValid ) { - if( !m_isValid ) - { - return E_FAIL; - } - if( m_hasFence ) - { - return E_INVALIDCALL; - } - m_hasFence = true; - return S_OK; - + return E_FAIL; } - - ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& ) + if( m_hasFence ) { - if( !m_isValid ) - { - return E_FAIL; - } - isReached = !m_hasFence; - return S_OK; + return E_INVALIDCALL; } + m_hasFence = true; + return S_OK; +} - ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& ) +ALResult Tr2FenceAL::IsReached( bool& isReached, Tr2RenderContextAL& ) +{ + if( !m_isValid ) { - if( !m_isValid ) - { - return E_FAIL; - } - if( !m_hasFence ) - { - return E_INVALIDCALL; - } - m_hasFence = false; - return S_OK; + return E_FAIL; } + isReached = !m_hasFence; + return S_OK; +} - void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +ALResult Tr2FenceAL::Wait( Tr2RenderContextAL& ) +{ + if( !m_isValid ) { + return E_FAIL; } - - ALResult Tr2FenceAL::SetName( const char* ) + if( !m_hasFence ) { - return S_OK; + return E_INVALIDCALL; } + m_hasFence = false; + return S_OK; +} + +void Tr2FenceAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2FenceAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2FenceALStub.h b/trinityal/stub/Tr2FenceALStub.h index 54056b68f..bb7388c48 100644 --- a/trinityal/stub/Tr2FenceALStub.h +++ b/trinityal/stub/Tr2FenceALStub.h @@ -2,37 +2,39 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2FenceAL.h" namespace TrinityALImpl { - class Tr2FenceAL : - public Tr2DeviceResourceAL - { - public: - Tr2FenceAL(); - ~Tr2FenceAL(); +class Tr2FenceAL : public Tr2DeviceResourceAL +{ +public: + Tr2FenceAL(); + ~Tr2FenceAL(); - ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - ALResult PutFence( Tr2RenderContextAL& renderContext ); - ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); - ALResult Wait( Tr2RenderContextAL& renderContext ); + ALResult PutFence( Tr2RenderContextAL& renderContext ); + ALResult IsReached( bool& isReached, Tr2RenderContextAL& renderContext ); + ALResult Wait( Tr2RenderContextAL& renderContext ); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - bool m_isValid; - bool m_hasFence; - }; +private: + bool m_isValid; + bool m_hasFence; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2GpuTimerALStub.cpp b/trinityal/stub/Tr2GpuTimerALStub.cpp index ee653787d..47aacc00c 100644 --- a/trinityal/stub/Tr2GpuTimerALStub.cpp +++ b/trinityal/stub/Tr2GpuTimerALStub.cpp @@ -1,61 +1,61 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2GpuTimerALStub.h" #include "Tr2PrimaryRenderContextStub.h" namespace TrinityALImpl { - Tr2GpuTimerAL::Tr2GpuTimerAL() - :m_isValid( false ) - { - } +Tr2GpuTimerAL::Tr2GpuTimerAL() : + m_isValid( false ) +{ +} - ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +ALResult Tr2GpuTimerAL::Create( Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + if( !renderContext.IsValid() ) { - Destroy(); - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - m_isValid = true; - return S_OK; + return E_INVALIDARG; } + m_isValid = true; + return S_OK; +} - void Tr2GpuTimerAL::Destroy() - { - m_isValid = false; - } +void Tr2GpuTimerAL::Destroy() +{ + m_isValid = false; +} - bool Tr2GpuTimerAL::IsValid() const - { - return m_isValid; - } +bool Tr2GpuTimerAL::IsValid() const +{ + return m_isValid; +} - bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& ) - { - return true; - } +bool Tr2GpuTimerAL::Begin( Tr2RenderContextAL& ) +{ + return true; +} - void Tr2GpuTimerAL::End( Tr2RenderContextAL& ) - { - } +void Tr2GpuTimerAL::End( Tr2RenderContextAL& ) +{ +} - float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& ) - { - return m_isValid ? 0.0001f : -1.f; - } +float Tr2GpuTimerAL::GetTime( Tr2RenderContextAL& ) +{ + return m_isValid ? 0.0001f : -1.f; +} - void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +void Tr2GpuTimerAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} - ALResult Tr2GpuTimerAL::SetName( const char* ) - { - return S_OK; - } +ALResult Tr2GpuTimerAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2GpuTimerALStub.h b/trinityal/stub/Tr2GpuTimerALStub.h index 8a4d369ba..e0b075e57 100644 --- a/trinityal/stub/Tr2GpuTimerALStub.h +++ b/trinityal/stub/Tr2GpuTimerALStub.h @@ -2,41 +2,43 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2GpuTimerAL.h" namespace TrinityALImpl { - class Tr2GpuTimerAL : - public Tr2DeviceResourceAL - { - public: - Tr2GpuTimerAL(); - - ALResult Create(Tr2PrimaryRenderContextAL& renderContext); - void Destroy(); +class Tr2GpuTimerAL : public Tr2DeviceResourceAL +{ +public: + Tr2GpuTimerAL(); - bool Begin(Tr2RenderContextAL& renderContext); - void End(Tr2RenderContextAL& renderContext); + ALResult Create( Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - float GetTime(Tr2RenderContextAL& renderContext); + bool Begin( Tr2RenderContextAL& renderContext ); + void End( Tr2RenderContextAL& renderContext ); - bool IsValid() const; + float GetTime( Tr2RenderContextAL& renderContext ); - bool operator==(const Tr2GpuTimerAL& other) const - { - return this == &other; - } + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + bool operator==( const Tr2GpuTimerAL& other ) const + { + return this == &other; + } - private: - bool m_isValid; - }; + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + bool m_isValid; +}; } #endif diff --git a/trinityal/stub/Tr2OcclusionQueryALStub.cpp b/trinityal/stub/Tr2OcclusionQueryALStub.cpp index 02e3a5ea5..1a6d4d5fe 100644 --- a/trinityal/stub/Tr2OcclusionQueryALStub.cpp +++ b/trinityal/stub/Tr2OcclusionQueryALStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2OcclusionQueryALStub.h" #include "Tr2RenderContextStub.h" @@ -10,77 +10,77 @@ namespace TrinityALImpl { - Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() - : m_isValid( false ), - m_isRunning( false ) - { - } +Tr2OcclusionQueryAL::Tr2OcclusionQueryAL() : + m_isValid( false ), + m_isRunning( false ) +{ +} - Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() - { - } +Tr2OcclusionQueryAL::~Tr2OcclusionQueryAL() +{ +} - ALResult Tr2OcclusionQueryAL::Create( Tr2RenderContextAL& renderContext ) +ALResult Tr2OcclusionQueryAL::Create( Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - m_isValid = true; - return S_OK; + return E_INVALIDARG; } + m_isValid = true; + return S_OK; +} - bool Tr2OcclusionQueryAL::IsValid() const - { - return m_isValid; - } +bool Tr2OcclusionQueryAL::IsValid() const +{ + return m_isValid; +} - void Tr2OcclusionQueryAL::Destroy() - { - m_isValid = false; - } +void Tr2OcclusionQueryAL::Destroy() +{ + m_isValid = false; +} - ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& /*renderContext*/ ) +ALResult Tr2OcclusionQueryAL::Begin( Tr2RenderContextAL& /*renderContext*/ ) +{ + if( !m_isValid ) { - if( !m_isValid ) - { - return E_INVALIDCALL; - } - m_isRunning = true; - return S_OK; + return E_INVALIDCALL; } + m_isRunning = true; + return S_OK; +} - ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& /*renderContext*/ ) +ALResult Tr2OcclusionQueryAL::End( Tr2RenderContextAL& /*renderContext*/ ) +{ + if( !m_isValid ) { - if( !m_isValid ) - { - return E_INVALIDCALL; - } - if( !m_isRunning ) - { - return E_INVALIDCALL; - } - m_isRunning = false; - return S_OK; + return E_INVALIDCALL; } - - ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& /*renderContext*/, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode ) + if( !m_isRunning ) { - if( !m_isValid ) - { - return E_INVALIDCALL; - } - count = 0; - return S_OK; + return E_INVALIDCALL; } + m_isRunning = false; + return S_OK; +} - void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +ALResult Tr2OcclusionQueryAL::GetPixelCount( Tr2RenderContextAL& /*renderContext*/, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode ) +{ + if( !m_isValid ) { + return E_INVALIDCALL; } + count = 0; + return S_OK; +} - ALResult Tr2OcclusionQueryAL::SetName( const char* ) - { - return S_OK; - } +void Tr2OcclusionQueryAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2OcclusionQueryAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2OcclusionQueryALStub.h b/trinityal/stub/Tr2OcclusionQueryALStub.h index 746d7a6bd..92afd9f37 100644 --- a/trinityal/stub/Tr2OcclusionQueryALStub.h +++ b/trinityal/stub/Tr2OcclusionQueryALStub.h @@ -2,37 +2,39 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2OcclusionQueryAL.h" namespace TrinityALImpl { - class Tr2OcclusionQueryAL : - public Tr2DeviceResourceAL +class Tr2OcclusionQueryAL : public Tr2DeviceResourceAL +{ +public: + Tr2OcclusionQueryAL(); + ~Tr2OcclusionQueryAL(); + + ALResult Create( Tr2RenderContextAL& renderContext ); + bool IsValid() const; + void Destroy(); + + ALResult Begin( Tr2RenderContextAL& renderContext ); + ALResult End( Tr2RenderContextAL& renderContext ); + ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2OcclusionQueryAL(); - ~Tr2OcclusionQueryAL(); - - ALResult Create( Tr2RenderContextAL& renderContext ); - bool IsValid() const; - void Destroy(); - - ALResult Begin( Tr2RenderContextAL& renderContext ); - ALResult End( Tr2RenderContextAL& renderContext ); - ALResult GetPixelCount( Tr2RenderContextAL& renderContext, uint32_t& count, ::Tr2OcclusionQueryAL::WaitMode waitMode ); - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - bool m_isValid; - bool m_isRunning; - Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; - Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; - }; + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + bool m_isValid; + bool m_isRunning; + Tr2OcclusionQueryAL( const Tr2OcclusionQueryAL& ) /* = delete */; + Tr2OcclusionQueryAL& operator=( const Tr2OcclusionQueryAL& ) /* = delete */; +}; } #endif diff --git a/trinityal/stub/Tr2RenderContextStub.cpp b/trinityal/stub/Tr2RenderContextStub.cpp index 3790db352..797c1a342 100644 --- a/trinityal/stub/Tr2RenderContextStub.cpp +++ b/trinityal/stub/Tr2RenderContextStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2RenderContextStub.h" #include "ITr2RenderContextEvents.h" @@ -14,7 +14,7 @@ CCP_STATS_DECLARE( vertexCount, "Trinity/AL/vertexCount", true, CST_COUNTER_HIGH using namespace Tr2RenderContextEnum; -#pragma warning( disable: 4189 ) // Scopeguard +#pragma warning( disable : 4189 ) // Scopeguard bool g_gatherPipelineStatistics = false; @@ -31,8 +31,8 @@ Tr2PrimaryRenderContextAL*& GetPrimaryRenderContextPointer() -Tr2RenderContextAL::Tr2RenderContextAL() - : m_isValid(false), +Tr2RenderContextAL::Tr2RenderContextAL() : + m_isValid( false ), m_events( nullptr ), m_frameNumber( 0 ) { @@ -70,7 +70,7 @@ void Tr2RenderContextAL::Destroy() -ALResult Tr2RenderContextAL::SetStreamSource( uint32_t, const Tr2BufferAL&, uint32_t, uint32_t ) throw( ) +ALResult Tr2RenderContextAL::SetStreamSource( uint32_t, const Tr2BufferAL&, uint32_t, uint32_t ) throw() { return S_OK; } @@ -100,10 +100,10 @@ ALResult Tr2RenderContextAL::CopySubBuffer( Tr2BufferAL&, uint32_t, Tr2BufferAL& return E_FAIL; } -ALResult Tr2RenderContextAL::Clear( - uint32_t, - uint32_t, - float, +ALResult Tr2RenderContextAL::Clear( + uint32_t, + uint32_t, + float, uint32_t, uint32_t ) { @@ -120,19 +120,19 @@ ALResult Tr2RenderContextAL::SetTopology( long topology ) } -ALResult Tr2RenderContextAL::DrawIndexedPrimitive( - uint32_t, - uint32_t, - uint32_t, +ALResult Tr2RenderContextAL::DrawIndexedPrimitive( + uint32_t, + uint32_t, + uint32_t, uint32_t ) { return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedInstanced( - uint32_t, - uint32_t, - uint32_t, +ALResult Tr2RenderContextAL::DrawIndexedInstanced( + uint32_t, + uint32_t, + uint32_t, uint32_t ) { return S_OK; @@ -163,19 +163,19 @@ ALResult Tr2RenderContextAL::DrawPrimitive( uint32_t, uint32_t ) return S_OK; } -ALResult Tr2RenderContextAL::DrawPrimitiveUP( - uint32_t, - const void*, +ALResult Tr2RenderContextAL::DrawPrimitiveUP( + uint32_t, + const void*, uint32_t ) { return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t, - uint32_t, - const uint32_t* indexData, - const void* vertexStreamZeroData, +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( + uint32_t, + uint32_t, + const uint32_t* indexData, + const void* vertexStreamZeroData, uint32_t ) { if( !indexData || !vertexStreamZeroData ) @@ -185,11 +185,11 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( return S_OK; } -ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( - uint32_t, - uint32_t, - const uint16_t* indexData, - const void* vertexStreamZeroData, +ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( + uint32_t, + uint32_t, + const uint16_t* indexData, + const void* vertexStreamZeroData, uint32_t ) { if( !indexData || !vertexStreamZeroData ) @@ -201,14 +201,14 @@ ALResult Tr2RenderContextAL::DrawIndexedPrimitiveUP( ALResult Tr2RenderContextAL::SetConstants( const Tr2ConstantBufferAL&, - ShaderType, - uint32_t, + ShaderType, + uint32_t, uint32_t ) { return S_OK; } -void Tr2RenderContextAL::SetReadOnlyDepth( bool /*enable*/ ) +void Tr2RenderContextAL::SetReadOnlyDepth( bool /*enable*/ ) { } @@ -227,9 +227,9 @@ ALResult Tr2RenderContextAL::SetRenderTarget( const Tr2TextureAL& renderTarget, return S_OK; } -ALResult Tr2RenderContextAL::CreateDevice( - uint32_t Adapter, - Tr2WindowHandle, +ALResult Tr2RenderContextAL::CreateDevice( + uint32_t Adapter, + Tr2WindowHandle, const Tr2PresentParametersAL& presentationParameters ) { m_isValid = true; @@ -238,7 +238,7 @@ ALResult Tr2RenderContextAL::CreateDevice( { m_events->OnContextCreated( *this ); } - + return S_OK; } @@ -249,7 +249,7 @@ PixelFormat Tr2RenderContextAL::GetBackBufferFormat() const ALResult Tr2RenderContextAL::SetPresentParameters( unsigned, const Tr2PresentParametersAL& presentationParameters ) { - CR_RETURN_HR( m_defaultBackBuffer.Create( + CR_RETURN_HR( m_defaultBackBuffer.Create( Tr2BitmapDimensions( presentationParameters.mode.width, presentationParameters.mode.height, 1, PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::RENDER_TARGET, *this ) ); @@ -334,7 +334,7 @@ ALResult Tr2RenderContextAL::PushRenderTarget( uint32_t slot ) { return E_INVALIDARG; } - + m_stackRT[slot].push( m_boundRenderTarget[slot] ); return S_OK; } @@ -356,7 +356,7 @@ ALResult Tr2RenderContextAL::PopRenderTarget( uint32_t slot ) m_stackRT[slot].pop(); return S_OK; } - + ALResult Tr2RenderContextAL::PushDepthStencil() { return S_OK; @@ -391,7 +391,7 @@ void Tr2RenderContextAL::ReleaseDeviceResources() { m_boundRenderTarget[i] = Tr2TextureAL(); } - + m_defaultBackBuffer = Tr2TextureAL(); } @@ -442,7 +442,7 @@ ALResult Tr2RenderContextAL::UseResources( Tr2UseResourceDestination, Tr2GpuUsag ALResult Tr2RenderContextAL::UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ) { - return S_OK; + return S_OK; } bool Tr2RenderContextAL::SupportsBindlessTextures() const @@ -450,10 +450,10 @@ bool Tr2RenderContextAL::SupportsBindlessTextures() const return false; } -uint64_t Tr2RenderContextAL::GetRecordingFrameNumber() const +uint64_t Tr2RenderContextAL::GetRecordingFrameNumber() const { return m_frameNumber + 1; -} +} Tr2UpscalingAL::Result Tr2RenderContextAL::EnableUpscaling( Tr2UpscalingAL::Technique tech, Tr2UpscalingAL::Setting setting, bool frameGeneration, uint32_t adapter ) @@ -472,7 +472,8 @@ Tr2UpscalingContextAL* Tr2RenderContextAL::CreateUpscalingContext( Tr2UpscalingA } void Tr2RenderContextAL::DeleteUpscalingContext( uint32_t contextID ) -{} +{ +} Tr2UpscalingAL::UpscalingInfo Tr2RenderContextAL::GetUpscalingInfo( uint32_t upscalingContextID ) { diff --git a/trinityal/stub/Tr2RenderContextStub.h b/trinityal/stub/Tr2RenderContextStub.h index d70718d69..2d781346b 100644 --- a/trinityal/stub/Tr2RenderContextStub.h +++ b/trinityal/stub/Tr2RenderContextStub.h @@ -4,7 +4,7 @@ #ifndef Tr2RenderContextStub_h_ #define Tr2RenderContextStub_h_ -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../Tr2RenderContextEnum.h" #include "../include/Tr2TextureAL.h" @@ -53,7 +53,7 @@ class Tr2BindlessResourcesAL class Tr2RenderContextAL { public: - Tr2RenderContextAL(); + Tr2RenderContextAL(); ~Tr2RenderContextAL(); void Destroy(); @@ -61,9 +61,9 @@ class Tr2RenderContextAL static Tr2PrimaryRenderContextAL& GetPrimaryRenderContext(); static Tr2PrimaryRenderContextAL* GetPrimaryRenderContextPointer(); - ALResult CreateDevice( - uint32_t Adapter, - Tr2WindowHandle hFocusWindow, + ALResult CreateDevice( + uint32_t Adapter, + Tr2WindowHandle hFocusWindow, const Tr2PresentParametersAL& presentationParameters ); ALResult SetPresentParameters( unsigned adapter, const Tr2PresentParametersAL& presentationParameters ); @@ -82,10 +82,10 @@ class Tr2RenderContextAL ALResult SetStreamSource( uint32_t stream, - const Tr2BufferAL & buffer, + const Tr2BufferAL& buffer, uint32_t offset, - uint32_t stride ) throw( ); - ALResult SetIndices( const Tr2BufferAL& buffer ) throw( ); + uint32_t stride ) throw(); + ALResult SetIndices( const Tr2BufferAL& buffer ) throw(); ALResult SetIndices( const Tr2BufferAL& buffer, uint32_t stride ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const float values[4] ) throw(); ALResult ClearUav( const Tr2BufferAL& buffer, const uint32_t values[4] ) throw(); @@ -112,19 +112,19 @@ class Tr2RenderContextAL } ALResult SetResourceSet( const Tr2ResourceSetAL& resourceSet ); - - ALResult DrawIndexedPrimitive( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, + + ALResult DrawIndexedPrimitive( + uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t minimumIndex = 0 ); - ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ); + ALResult DrawPrimitive( uint32_t startVertex, uint32_t primitiveCount ); - ALResult DrawIndexedInstanced( - uint32_t numVertices, - uint32_t startIndex, - uint32_t primitiveCount, + ALResult DrawIndexedInstanced( + uint32_t numVertices, + uint32_t startIndex, + uint32_t primitiveCount, uint32_t numInstances ); ALResult DrawIndexedInstanced( @@ -139,23 +139,23 @@ class Tr2RenderContextAL uint32_t startVertexLocation, uint32_t startInstanceLocation ); - ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint32_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride); - - ALResult DrawIndexedPrimitiveUP( - uint32_t numVertices, - uint32_t primitiveCount, - const uint16_t* indexData, - const void* vertexStreamZeroData, - uint32_t vertexStreamZeroStride); - - ALResult DrawPrimitiveUP( - uint32_t primitiveCount, - const void* vertexStreamZeroData, + ALResult DrawIndexedPrimitiveUP( + uint32_t numVertices, + uint32_t primitiveCount, + const uint32_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ); + + ALResult DrawIndexedPrimitiveUP( + uint32_t numVertices, + uint32_t primitiveCount, + const uint16_t* indexData, + const void* vertexStreamZeroData, + uint32_t vertexStreamZeroStride ); + + ALResult DrawPrimitiveUP( + uint32_t primitiveCount, + const void* vertexStreamZeroData, uint32_t vertexStreamZeroStride ); ALResult DrawIndexedInstancedIndirect( Tr2BufferAL&, uint32_t ) @@ -176,7 +176,7 @@ class Tr2RenderContextAL { return E_FAIL; } - + ALResult DispatchRays( Tr2RtPipelineStateAL& pipeline, Tr2RtShaderTableAL& shaderTable, const wchar_t* rayGenShader, uint32_t width, uint32_t height, uint32_t depth ) { return E_FAIL; @@ -185,24 +185,24 @@ class Tr2RenderContextAL ALResult SetVertexLayout( const Tr2VertexLayoutAL& layout ); ALResult SetRenderState( Tr2RenderContextEnum::RenderState state, uint32_t value ); - ALResult SetRenderStates( const uint32_t * stateValuePairs, uint32_t count ); + ALResult SetRenderStates( const uint32_t* stateValuePairs, uint32_t count ); - ALResult SetConstants( - const Tr2ConstantBufferAL& buffer, - Tr2RenderContextEnum::ShaderType constantType, - uint32_t registerIndex, + ALResult SetConstants( + const Tr2ConstantBufferAL& buffer, + Tr2RenderContextEnum::ShaderType constantType, + uint32_t registerIndex, uint32_t maxRegisterCount = 0 ); // Helper function to clear the current primary backbuffer, depth and/or stencil. - ALResult Clear( - uint32_t clearFlags, - uint32_t color, - float depth, + ALResult Clear( + uint32_t clearFlags, + uint32_t color, + float depth, uint32_t stencil = 0, uint32_t slot = 0 ); ALResult SetDepthStencil( const Tr2TextureAL& depthStencil ); - void SetReadOnlyDepth( bool enable ); + void SetReadOnlyDepth( bool enable ); bool GetReadOnlyDepth() const; ALResult SetRenderTarget( const Tr2TextureAL& renderTarget, uint32_t slot = 0, uint32_t slice = 0 ); @@ -216,16 +216,16 @@ class Tr2RenderContextAL ALResult PopRenderTarget( uint32_t slot = 0 ); ALResult PushDepthStencil(); ALResult PopDepthStencil(); - ALResult GetRenderTargetSize( - uint32_t& width, - uint32_t& height, + ALResult GetRenderTargetSize( + uint32_t& width, + uint32_t& height, uint32_t slot = 0 ); long GetTotalVideoMemory(); Tr2RenderContextEnum::PixelFormat GetBackBufferFormat() const; - static const uint32_t SHADER_TYPE_MASK = + static const uint32_t SHADER_TYPE_MASK = ( 1 << Tr2RenderContextEnum::VERTEX_SHADER ) | ( 1 << Tr2RenderContextEnum::PIXEL_SHADER ); @@ -234,12 +234,18 @@ class Tr2RenderContextAL { return 0; } - size_t GetStackSizeDS() const { return 0; } + size_t GetStackSizeDS() const + { + return 0; + } Tr2CapsAL m_caps; ITr2RenderContextEvents* m_events; - Tr2TextureAL& GetDefaultBackBuffer() { return m_defaultBackBuffer; } + Tr2TextureAL& GetDefaultBackBuffer() + { + return m_defaultBackBuffer; + } void AddGpuMarker( const char* marker ); void PushGpuMarker( const char* marker ); @@ -254,8 +260,8 @@ class Tr2RenderContextAL uint32_t& mips ) const; ALResult UseResources( Tr2UseResourceDestination dest, Tr2GpuUsage::Type usage, const Tr2BindlessResourcesAL& resources ); - ALResult UseAccelerationStructure(Tr2RtTopLevelAccelerationStructureAL tlas ); - + ALResult UseAccelerationStructure( Tr2RtTopLevelAccelerationStructureAL tlas ); + bool SupportsBindlessTextures() const; uint64_t GetRecordingFrameNumber() const; @@ -272,18 +278,21 @@ class Tr2RenderContextAL void MarkFrameEvent( Tr2RenderContextEnum::FrameEvent frameEvent ); private: - enum { MAX_RENDER_TARGET = 8 }; + enum + { + MAX_RENDER_TARGET = 8 + }; Tr2TextureAL m_boundRenderTarget[MAX_RENDER_TARGET]; bool m_isValid; Tr2TextureAL m_defaultBackBuffer; Tr2Viewport m_viewport; - TrackableStdStack m_stackRT[MAX_RENDER_TARGET]; + TrackableStdStack m_stackRT[MAX_RENDER_TARGET]; uint64_t m_frameNumber; public: TrinityALImpl::Tr2SamplerStateALFactory m_samplerStateFactory; }; -#endif // #if( TRINITY_PLATFORM==TRINITY_STUB ) +#endif // #if( TRINITY_PLATFORM==TRINITY_STUB ) #endif //Tr2RenderContextStub_h_ diff --git a/trinityal/stub/Tr2ResourceSetALStub.cpp b/trinityal/stub/Tr2ResourceSetALStub.cpp index 1d6bad583..91c54f6ef 100644 --- a/trinityal/stub/Tr2ResourceSetALStub.cpp +++ b/trinityal/stub/Tr2ResourceSetALStub.cpp @@ -8,40 +8,40 @@ namespace TrinityALImpl { - Tr2ResourceSetAL::Tr2ResourceSetAL() - :m_isValid( false ) - { - } - - ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL&, const ::Tr2ShaderProgramAL&, Tr2PrimaryRenderContextAL& ) - { - m_isValid = true; - return S_OK; - } - - bool Tr2ResourceSetAL::IsValid() const - { - return m_isValid; - } - - void Tr2ResourceSetAL::Destroy() - { - m_isValid = false; - } - - Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - - void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } - - ALResult Tr2ResourceSetAL::SetName( const char* ) - { - return S_OK; - } +Tr2ResourceSetAL::Tr2ResourceSetAL() : + m_isValid( false ) +{ +} + +ALResult Tr2ResourceSetAL::Create( const Tr2ResourceSetDescriptionAL&, const ::Tr2ShaderProgramAL&, Tr2PrimaryRenderContextAL& ) +{ + m_isValid = true; + return S_OK; +} + +bool Tr2ResourceSetAL::IsValid() const +{ + return m_isValid; +} + +void Tr2ResourceSetAL::Destroy() +{ + m_isValid = false; +} + +Tr2ALMemoryType Tr2ResourceSetAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +void Tr2ResourceSetAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2ResourceSetAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2ResourceSetALStub.h b/trinityal/stub/Tr2ResourceSetALStub.h index cc786951c..19198aca9 100644 --- a/trinityal/stub/Tr2ResourceSetALStub.h +++ b/trinityal/stub/Tr2ResourceSetALStub.h @@ -8,22 +8,22 @@ namespace TrinityALImpl { - class Tr2ResourceSetAL : public Tr2DeviceResourceAL - { - public: - Tr2ResourceSetAL(); - - ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); - bool IsValid() const; - - void Destroy(); - Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - bool m_isValid; - }; +class Tr2ResourceSetAL : public Tr2DeviceResourceAL +{ +public: + Tr2ResourceSetAL(); + + ALResult Create( const Tr2ResourceSetDescriptionAL& description, const ::Tr2ShaderProgramAL& program, Tr2PrimaryRenderContextAL& renderContext ); + bool IsValid() const; + + void Destroy(); + Tr2ALMemoryType GetMemoryClass() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + bool m_isValid; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2SamplerStateALStub.cpp b/trinityal/stub/Tr2SamplerStateALStub.cpp index b94de4ba5..62694f219 100644 --- a/trinityal/stub/Tr2SamplerStateALStub.cpp +++ b/trinityal/stub/Tr2SamplerStateALStub.cpp @@ -2,46 +2,46 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2SamplerStateALStub.h" namespace TrinityALImpl { - Tr2SamplerStateAL::Tr2SamplerStateAL() - { - m_isValid = false; - } - - ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription&, Tr2RenderContextAL& ) - { - m_isValid = true; - return S_OK; - } - - void Tr2SamplerStateAL::Destroy() - { - m_isValid = false; - } - - uint32_t Tr2SamplerStateAL::GetIndexInHeap() const - { - return 0xffffffff; - } - - bool Tr2SamplerStateAL::IsValid() const - { - return m_isValid; - } - - void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } - - ALResult Tr2SamplerStateAL::SetName( const char* ) - { - return S_OK; - } +Tr2SamplerStateAL::Tr2SamplerStateAL() +{ + m_isValid = false; +} + +ALResult Tr2SamplerStateAL::Create( const Tr2SamplerDescription&, Tr2RenderContextAL& ) +{ + m_isValid = true; + return S_OK; +} + +void Tr2SamplerStateAL::Destroy() +{ + m_isValid = false; +} + +uint32_t Tr2SamplerStateAL::GetIndexInHeap() const +{ + return 0xffffffff; +} + +bool Tr2SamplerStateAL::IsValid() const +{ + return m_isValid; +} + +void Tr2SamplerStateAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2SamplerStateAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2SamplerStateALStub.h b/trinityal/stub/Tr2SamplerStateALStub.h index 310ffb916..931b9531d 100644 --- a/trinityal/stub/Tr2SamplerStateALStub.h +++ b/trinityal/stub/Tr2SamplerStateALStub.h @@ -2,32 +2,35 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2SamplerStateAL.h" namespace TrinityALImpl { - class Tr2SamplerStateAL : public Tr2DeviceResourceAL - { - public: - Tr2SamplerStateAL(); +class Tr2SamplerStateAL : public Tr2DeviceResourceAL +{ +public: + Tr2SamplerStateAL(); - ALResult Create( const Tr2SamplerDescription& description, Tr2RenderContextAL& renderContext ); - void Destroy(); + ALResult Create( const Tr2SamplerDescription& description, Tr2RenderContextAL& renderContext ); + void Destroy(); - uint32_t GetIndexInHeap() const; + uint32_t GetIndexInHeap() const; - bool IsValid() const; + bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_MANAGED; + } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - bool m_isValid; - }; +private: + bool m_isValid; +}; } #endif diff --git a/trinityal/stub/Tr2ShaderALStub.cpp b/trinityal/stub/Tr2ShaderALStub.cpp index 593fe66b3..f073952b5 100644 --- a/trinityal/stub/Tr2ShaderALStub.cpp +++ b/trinityal/stub/Tr2ShaderALStub.cpp @@ -11,79 +11,79 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - Tr2ShaderAL::Tr2ShaderAL() - :m_type( INVALID_SHADER ) - { - } +Tr2ShaderAL::Tr2ShaderAL() : + m_type( INVALID_SHADER ) +{ +} - ALResult Tr2ShaderAL::Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL&, - const char*, - Tr2PrimaryRenderContextAL & ) +ALResult Tr2ShaderAL::Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL&, + const char*, + Tr2PrimaryRenderContextAL& ) +{ + m_bytecode.resize( "Tr2ShaderALStub::m_bytecode", bytecode.size ); + if( m_bytecode.empty() ) { - m_bytecode.resize( "Tr2ShaderALStub::m_bytecode", bytecode.size ); - if( m_bytecode.empty() ) - { - return E_OUTOFMEMORY; - } - memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); - m_type = type; - - return S_OK; + return E_OUTOFMEMORY; } + memcpy( m_bytecode.get(), bytecode.bytecode, bytecode.size ); + m_type = type; - Tr2ShaderAL::~Tr2ShaderAL() - { - Destroy(); - } + return S_OK; +} - void Tr2ShaderAL::Destroy() - { - m_type = INVALID_SHADER; - m_bytecode.clear(); - } +Tr2ShaderAL::~Tr2ShaderAL() +{ + Destroy(); +} - bool Tr2ShaderAL::IsValid() const - { - return m_type != INVALID_SHADER && !m_bytecode.empty(); - } +void Tr2ShaderAL::Destroy() +{ + m_type = INVALID_SHADER; + m_bytecode.clear(); +} - Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const - { - return m_type; - } +bool Tr2ShaderAL::IsValid() const +{ + return m_type != INVALID_SHADER && !m_bytecode.empty(); +} - ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const - { - if( m_bytecode.empty() ) - { - bytecode = Tr2ShaderBytecodeAL(); - return E_INVALIDCALL; - } - bytecode.bytecode = m_bytecode.get(); - bytecode.size = m_bytecode.size(); - return S_OK; - } +Tr2RenderContextEnum::ShaderType Tr2ShaderAL::GetType() const +{ + return m_type; +} - const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +ALResult Tr2ShaderAL::GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const +{ + if( m_bytecode.empty() ) { - return m_signature; + bytecode = Tr2ShaderBytecodeAL(); + return E_INVALIDCALL; } + bytecode.bytecode = m_bytecode.get(); + bytecode.size = m_bytecode.size(); + return S_OK; +} - void Tr2ShaderAL::SetNullShaderType( Tr2RenderContextEnum::ShaderType type ) - { - m_type = type; - } +const Tr2ShaderSignatureAL& Tr2ShaderAL::GetSignature() const +{ + return m_signature; +} - void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +void Tr2ShaderAL::SetNullShaderType( Tr2RenderContextEnum::ShaderType type ) +{ + m_type = type; +} - ALResult Tr2ShaderAL::SetName( const char* ) - { - return S_OK; - } +void Tr2ShaderAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2ShaderAL::SetName( const char* ) +{ + return S_OK; +} } #endif diff --git a/trinityal/stub/Tr2ShaderALStub.h b/trinityal/stub/Tr2ShaderALStub.h index b6974a260..db06c979a 100644 --- a/trinityal/stub/Tr2ShaderALStub.h +++ b/trinityal/stub/Tr2ShaderALStub.h @@ -9,43 +9,45 @@ namespace TrinityALImpl { - // ------------------------------------------------------------- - // Description: - // A low level wrapper around shaders / shader programs. - // 32bit - no support for shader blobs > 4 gig - // ------------------------------------------------------------- - class Tr2ShaderAL : - public Tr2DeviceResourceAL +// ------------------------------------------------------------- +// Description: +// A low level wrapper around shaders / shader programs. +// 32bit - no support for shader blobs > 4 gig +// ------------------------------------------------------------- +class Tr2ShaderAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderAL(); + ~Tr2ShaderAL(); + + ALResult Create( + Tr2RenderContextEnum::ShaderType type, + const Tr2ShaderBytecodeAL& bytecode, + const Tr2ShaderSignatureAL& signature, + const char* shaderPath, + Tr2PrimaryRenderContextAL& renderContext ); + + void Destroy(); + + bool IsValid() const; + Tr2RenderContextEnum::ShaderType GetType() const; + ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; + const Tr2ShaderSignatureAL& GetSignature() const; + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2ShaderAL(); - ~Tr2ShaderAL(); - - ALResult Create( - Tr2RenderContextEnum::ShaderType type, - const Tr2ShaderBytecodeAL& bytecode, - const Tr2ShaderSignatureAL& signature, - const char* shaderPath, - Tr2PrimaryRenderContextAL &renderContext ); - - void Destroy(); - - bool IsValid() const; - Tr2RenderContextEnum::ShaderType GetType() const; - ALResult GetBytecode( Tr2ShaderBytecodeAL& bytecode ) const; - const Tr2ShaderSignatureAL& GetSignature() const; - - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_MANAGED; } - - void SetNullShaderType( Tr2RenderContextEnum::ShaderType type ); - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - Tr2RenderContextEnum::ShaderType m_type; - CcpMallocBuffer m_bytecode; - Tr2ShaderSignatureAL m_signature; - }; + return AL_MEMORY_MANAGED; } -#endif + void SetNullShaderType( Tr2RenderContextEnum::ShaderType type ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + Tr2RenderContextEnum::ShaderType m_type; + CcpMallocBuffer m_bytecode; + Tr2ShaderSignatureAL m_signature; +}; +} + +#endif diff --git a/trinityal/stub/Tr2ShaderProgramALStub.cpp b/trinityal/stub/Tr2ShaderProgramALStub.cpp index b490a4d25..c2a0abeb8 100644 --- a/trinityal/stub/Tr2ShaderProgramALStub.cpp +++ b/trinityal/stub/Tr2ShaderProgramALStub.cpp @@ -13,70 +13,70 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - Tr2ShaderProgramAL::Tr2ShaderProgramAL() - :m_isValid( false ) +Tr2ShaderProgramAL::Tr2ShaderProgramAL() : + m_isValid( false ) +{ +} + +ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( !renderContext.IsValid() ) { + return E_INVALIDCALL; } - ALResult Tr2ShaderProgramAL::Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ) + if( count == 0 ) { - Destroy(); - - if( !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + return E_INVALIDARG; + } - if( count == 0 ) + uint32_t mask = 0; + for( size_t i = 0; i < count; ++i ) + { + if( !shaders[i].IsValid() ) { return E_INVALIDARG; } - - uint32_t mask = 0; - for( size_t i = 0; i < count; ++i ) + uint32_t bit = 1 << shaders[i].GetType(); + if( ( mask & bit ) != 0 ) { - if( !shaders[i].IsValid() ) - { - return E_INVALIDARG; - } - uint32_t bit = 1 << shaders[i].GetType(); - if( ( mask & bit ) != 0 ) - { - return E_INVALIDARG; - } - mask |= bit; + return E_INVALIDARG; } - m_isValid = true; - return S_OK; + mask |= bit; } + m_isValid = true; + return S_OK; +} - void Tr2ShaderProgramAL::Destroy() - { - m_isValid = false; - } +void Tr2ShaderProgramAL::Destroy() +{ + m_isValid = false; +} - bool Tr2ShaderProgramAL::IsValid() const - { - return m_isValid; - } +bool Tr2ShaderProgramAL::IsValid() const +{ + return m_isValid; +} - Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } +Tr2ALMemoryType Tr2ShaderProgramAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} - void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +void Tr2ShaderProgramAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} - const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const - { - return m_registerMap; - } +const Tr2RegisterMapAL& Tr2ShaderProgramAL::GetRegisterMap() const +{ + return m_registerMap; +} - ALResult Tr2ShaderProgramAL::SetName( const char* ) - { - return S_OK; - } +ALResult Tr2ShaderProgramAL::SetName( const char* ) +{ + return S_OK; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2ShaderProgramALStub.h b/trinityal/stub/Tr2ShaderProgramALStub.h index 63a11aed0..a40bb55ec 100644 --- a/trinityal/stub/Tr2ShaderProgramALStub.h +++ b/trinityal/stub/Tr2ShaderProgramALStub.h @@ -9,28 +9,28 @@ namespace TrinityALImpl { - class Tr2ShaderProgramAL : public Tr2DeviceResourceAL - { - public: - Tr2ShaderProgramAL(); +class Tr2ShaderProgramAL : public Tr2DeviceResourceAL +{ +public: + Tr2ShaderProgramAL(); - ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); + ALResult Create( ::Tr2ShaderAL* shaders, size_t count, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; - const Tr2RegisterMapAL& GetRegisterMap() const; + bool IsValid() const; + const Tr2RegisterMapAL& GetRegisterMap() const; - Tr2ALMemoryType GetMemoryClass() const; + Tr2ALMemoryType GetMemoryClass() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - private: - Tr2RegisterMapAL m_registerMap; - bool m_isValid; +private: + Tr2RegisterMapAL m_registerMap; + bool m_isValid; - friend class Tr2RenderContextAL; - }; + friend class Tr2RenderContextAL; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2SwapChainALStub.cpp b/trinityal/stub/Tr2SwapChainALStub.cpp index 553678ead..053fea362 100644 --- a/trinityal/stub/Tr2SwapChainALStub.cpp +++ b/trinityal/stub/Tr2SwapChainALStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if TRINITY_PLATFORM==TRINITY_STUB +#if TRINITY_PLATFORM == TRINITY_STUB #include "Tr2SwapChainALStub.h" #include "Tr2RenderContextStub.h" @@ -11,57 +11,57 @@ namespace TrinityALImpl { - Tr2SwapChainAL::Tr2SwapChainAL() - :m_windowHandle( Tr2WindowHandle() ) - { - } +Tr2SwapChainAL::Tr2SwapChainAL() : + m_windowHandle( Tr2WindowHandle() ) +{ +} - ALResult Tr2SwapChainAL::Create( Tr2WindowHandle, Tr2RenderContextAL& renderContext ) +ALResult Tr2SwapChainAL::Create( Tr2WindowHandle, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_INVALIDARG; - } - Destroy(); - return m_backBuffer.Create( - Tr2BitmapDimensions( 4, 4, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM ), - Tr2GpuUsage::RENDER_TARGET, - renderContext ); + return E_INVALIDARG; } + Destroy(); + return m_backBuffer.Create( + Tr2BitmapDimensions( 4, 4, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM ), + Tr2GpuUsage::RENDER_TARGET, + renderContext ); +} - void Tr2SwapChainAL::Destroy() - { - m_backBuffer = ::Tr2TextureAL(); - } +void Tr2SwapChainAL::Destroy() +{ + m_backBuffer = ::Tr2TextureAL(); +} - bool Tr2SwapChainAL::IsValid() const - { - return m_backBuffer.IsValid(); - } +bool Tr2SwapChainAL::IsValid() const +{ + return m_backBuffer.IsValid(); +} - ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& ) - { - return S_OK; - } +ALResult Tr2SwapChainAL::Present( Tr2RenderContextAL& ) +{ + return S_OK; +} - uint32_t Tr2SwapChainAL::GetWidth() const - { - return m_backBuffer.GetWidth(); - } +uint32_t Tr2SwapChainAL::GetWidth() const +{ + return m_backBuffer.GetWidth(); +} - uint32_t Tr2SwapChainAL::GetHeight() const - { - return m_backBuffer.GetHeight(); - } +uint32_t Tr2SwapChainAL::GetHeight() const +{ + return m_backBuffer.GetHeight(); +} - void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +void Tr2SwapChainAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} - ALResult Tr2SwapChainAL::SetName( const char* ) - { - return S_OK; - } +ALResult Tr2SwapChainAL::SetName( const char* ) +{ + return S_OK; +} } diff --git a/trinityal/stub/Tr2SwapChainALStub.h b/trinityal/stub/Tr2SwapChainALStub.h index 0006000d1..a04737f4b 100644 --- a/trinityal/stub/Tr2SwapChainALStub.h +++ b/trinityal/stub/Tr2SwapChainALStub.h @@ -3,7 +3,7 @@ #pragma once -#if TRINITY_PLATFORM==TRINITY_STUB +#if TRINITY_PLATFORM == TRINITY_STUB #include "../include/Tr2SwapChainAL.h" #include "../include/Tr2TextureAL.h" @@ -11,30 +11,33 @@ namespace TrinityALImpl { - class Tr2SwapChainAL : - public Tr2DeviceResourceAL - { - public: - Tr2SwapChainAL(); +class Tr2SwapChainAL : public Tr2DeviceResourceAL +{ +public: + Tr2SwapChainAL(); - ALResult Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ); - void Destroy(); + ALResult Create( Tr2WindowHandle windowHandle, Tr2RenderContextAL& renderContext ); + void Destroy(); - bool IsValid() const; + bool IsValid() const; - ALResult Present( Tr2RenderContextAL& renderContext ); + ALResult Present( Tr2RenderContextAL& renderContext ); - uint32_t GetWidth() const; - uint32_t GetHeight() const; + uint32_t GetWidth() const; + uint32_t GetHeight() const; + + Tr2ALMemoryType GetMemoryClass() const + { + return AL_MEMORY_VIDEO; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); - Tr2ALMemoryType GetMemoryClass() const { return AL_MEMORY_VIDEO; } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); + ::Tr2TextureAL m_backBuffer; - ::Tr2TextureAL m_backBuffer; - private: - Tr2WindowHandle m_windowHandle; - }; +private: + Tr2WindowHandle m_windowHandle; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2TextureALStub.cpp b/trinityal/stub/Tr2TextureALStub.cpp index 5398dc000..6c364536b 100644 --- a/trinityal/stub/Tr2TextureALStub.cpp +++ b/trinityal/stub/Tr2TextureALStub.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2TextureALStub.h" #include "Tr2RenderContextStub.h" @@ -9,360 +9,360 @@ namespace TrinityALImpl { - Tr2TextureAL::Tr2TextureAL() - :m_gpuUsage( Tr2GpuUsage::NONE ), - m_cpuUsage( Tr2CpuUsage::NONE ) +Tr2TextureAL::Tr2TextureAL() : + m_gpuUsage( Tr2GpuUsage::NONE ), + m_cpuUsage( Tr2CpuUsage::NONE ) +{ +} + +ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) +{ + Destroy(); + + if( HasBufferFlags( gpuUsage ) ) { + return E_INVALIDARG; } - ALResult Tr2TextureAL::Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ) + if( !renderContext.IsValid() ) { - Destroy(); - - if( HasBufferFlags( gpuUsage ) ) + return E_FAIL; + } + if( msaa.samples > 1 ) + { + if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) { return E_INVALIDARG; } - - if( !renderContext.IsValid() ) + if( cpuUsage != Tr2CpuUsage::NONE ) { - return E_FAIL; + return E_INVALIDARG; } - if( msaa.samples > 1 ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) { - if( HasFlag( gpuUsage, Tr2GpuUsage::UNORDERED_ACCESS ) ) - { - return E_INVALIDARG; - } - if( cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) - { - return E_INVALIDARG; - } + return E_INVALIDARG; } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) + } + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D ) + { + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) { - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_CUBE ) - { - if( desc.GetArraySize() != 6 ) - { - return E_INVALIDARG; - } - } - else if( desc.GetArraySize() > 1 ) + if( desc.GetArraySize() != 6 ) { return E_INVALIDARG; } } - if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) + else if( desc.GetArraySize() > 1 ) { return E_INVALIDARG; } - if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) - { - return E_INVALIDARG; - } - if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && cpuUsage != Tr2CpuUsage::NONE ) - { - return E_INVALIDARG; - } - if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) - { - return E_INVALIDARG; - } - - m_desc = desc; - m_gpuUsage = gpuUsage; - m_cpuUsage = cpuUsage; - m_msaa = msaa; - - return S_OK; } - - ALResult Tr2TextureAL::OpenShared( uintptr_t, Tr2GpuUsage::Type, Tr2PrimaryRenderContextAL& ) + if( desc.GetType() != Tr2RenderContextEnum::TEX_TYPE_2D && HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) ) { - return E_FAIL; + return E_INVALIDARG; } - - void Tr2TextureAL::Destroy() + if( msaa.samples > 1 && desc.GetTrueMipCount() > 1 ) { - memset( &m_desc, 0, sizeof( m_desc ) ); - m_msaa = Tr2MsaaDesc(); - m_gpuUsage = Tr2GpuUsage::NONE; - m_cpuUsage = Tr2CpuUsage::NONE; + return E_INVALIDARG; } - - bool Tr2TextureAL::IsValid() const + if( HasFlag( gpuUsage, Tr2GpuUsage::RENDER_TARGET ) && HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) ) { - return m_desc.GetWidth() != 0; + return E_INVALIDARG; } - - Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && cpuUsage != Tr2CpuUsage::NONE ) { - return AL_MEMORY_MANAGED; + return E_INVALIDARG; } - - const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const + if( HasFlag( gpuUsage, Tr2GpuUsage::DEPTH_STENCIL ) && desc.GetTrueMipCount() > 1 ) { - return m_desc; + return E_INVALIDARG; } - - const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const + if( desc.GetType() == Tr2RenderContextEnum::TEX_TYPE_3D && cpuUsage != Tr2CpuUsage::NONE ) { - return m_msaa; + return E_INVALIDARG; } - - Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const + if( !IsWritable( gpuUsage ) && !HasFlag( cpuUsage, Tr2CpuUsage::WRITE ) && !initialData ) { - return m_gpuUsage; + return E_INVALIDARG; } - Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const - { - return m_cpuUsage; - } + m_desc = desc; + m_gpuUsage = gpuUsage; + m_cpuUsage = cpuUsage; + m_msaa = msaa; - ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - data = nullptr; - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) - { - return E_INVALIDCALL; - } + return S_OK; +} - if( !IsValid() || !renderContext.IsValid() ) - { - return E_FAIL; - } - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } +ALResult Tr2TextureAL::OpenShared( uintptr_t, Tr2GpuUsage::Type, Tr2PrimaryRenderContextAL& ) +{ + return E_FAIL; +} - auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); - auto size = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); +void Tr2TextureAL::Destroy() +{ + memset( &m_desc, 0, sizeof( m_desc ) ); + m_msaa = Tr2MsaaDesc(); + m_gpuUsage = Tr2GpuUsage::NONE; + m_cpuUsage = Tr2CpuUsage::NONE; +} - if( m_data.size() != size ) - { - m_data.resize( "Tr2TextureAL::m_data", size ); - if( m_data.empty() ) - { - return E_FAIL; - } - } +bool Tr2TextureAL::IsValid() const +{ + return m_desc.GetWidth() != 0; +} - pitch = mipPitch; - data = m_data.get(); - return S_OK; - } +Tr2ALMemoryType Tr2TextureAL::GetMemoryClass() const +{ + return AL_MEMORY_MANAGED; +} + +const Tr2BitmapDimensions& Tr2TextureAL::GetDesc() const +{ + return m_desc; +} + +const Tr2MsaaDesc& Tr2TextureAL::GetMsaaDesc() const +{ + return m_msaa; +} + +Tr2GpuUsage::Type Tr2TextureAL::GetGpuUsage() const +{ + return m_gpuUsage; +} + +Tr2CpuUsage::Type Tr2TextureAL::GetCpuUsage() const +{ + return m_cpuUsage; +} - void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& ) +ALResult Tr2TextureAL::MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + data = nullptr; + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ ) ) { - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) && !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - m_data.clear(); - } + return E_INVALIDCALL; } - ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) + if( !IsValid() || !renderContext.IsValid() ) + { + return E_FAIL; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) { - data = nullptr; + return E_INVALIDARG; + } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) - { - return E_INVALIDCALL; - } - if( !IsValid() || !renderContext.IsValid() ) + auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); + auto size = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); + + if( m_data.size() != size ) + { + m_data.resize( "Tr2TextureAL::m_data", size ); + if( m_data.empty() ) { return E_FAIL; } - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) - { - return E_INVALIDARG; - } - if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) - { - return E_INVALIDARG; - } - - auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); - auto size = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); + } - if( m_data.size() != size ) - { - m_data.resize( "Tr2TextureAL::m_data", size ); - if( m_data.empty() ) - { - return E_FAIL; - } - } + pitch = mipPitch; + data = m_data.get(); + return S_OK; +} - pitch = mipPitch; - data = m_data.get(); - return S_OK; +void Tr2TextureAL::UnmapForReading( Tr2RenderContextAL& ) +{ + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) && !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + m_data.clear(); } +} + +ALResult Tr2TextureAL::MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) +{ + data = nullptr; - void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& ) + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) ) { - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) && !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - m_data.clear(); - } + return E_INVALIDCALL; } - - ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void*, uint32_t, uint32_t, Tr2RenderContextAL& renderContext ) + if( !IsValid() || !renderContext.IsValid() ) { - if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) - { - return E_INVALIDCALL; - } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) - { - return E_INVALIDCALL; - } + return E_FAIL; + } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + if( region.HasBox() && Tr2RenderContextEnum::IsCompressedFormat( m_desc.GetFormat() ) ) + { + return E_INVALIDARG; + } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } + auto mipPitch = m_desc.GetMipPitch( region.m_startMipLevel ); + auto size = mipPitch * m_desc.GetMipHeight( region.m_startMipLevel ); - if( !region.IsValidForBitmap( m_desc ) ) - { - return E_INVALIDARG; - } - if( !region.IsSingleSubresource() ) + if( m_data.size() != size ) + { + m_data.resize( "Tr2TextureAL::m_data", size ); + if( m_data.empty() ) { - return E_INVALIDARG; + return E_FAIL; } - return S_OK; } - ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) + pitch = mipPitch; + data = m_data.get(); + return S_OK; +} + +void Tr2TextureAL::UnmapForWriting( Tr2RenderContextAL& ) +{ + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::READ_OFTEN ) && !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) { - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !source.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) - { - return E_INVALIDCALL; - } + m_data.clear(); + } +} - if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) - { - return S_OK; - } +ALResult Tr2TextureAL::UpdateSubresource( const Tr2TextureSubresource& region, const void*, uint32_t, uint32_t, Tr2RenderContextAL& renderContext ) +{ + if( HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE_OFTEN ) ) + { + return E_INVALIDCALL; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; + } - Tr2TextureSubresource src = sourceSubresource; - Tr2TextureSubresource dst = destSubresource; + if( !IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } - if( !Crop( src, source.m_desc, dst, m_desc ) ) - { - return E_FAIL; - } + if( !region.IsValidForBitmap( m_desc ) ) + { + return E_INVALIDARG; + } + if( !region.IsSingleSubresource() ) + { + return E_INVALIDARG; + } + return S_OK; +} - return S_OK; +ALResult Tr2TextureAL::CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ) +{ + if( !IsValid() || !renderContext.IsValid() ) + { + return E_INVALIDCALL; + } + if( !source.IsValid() ) + { + return E_INVALIDARG; + } + if( !HasFlag( m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( m_gpuUsage ) ) + { + return E_INVALIDCALL; } - ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& ) + if( destSubresource.IsSubresourceFull( m_desc ) && sourceSubresource.IsSubresourceFull( source.m_desc ) ) { - if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) - { - return E_INVALIDCALL; - } return S_OK; } - ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) + Tr2TextureSubresource src = sourceSubresource; + Tr2TextureSubresource dst = destSubresource; + + if( !Crop( src, source.m_desc, dst, m_desc ) ) { - if( m_msaa.samples <= 1 ) - { - return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); - } + return E_FAIL; + } - if( !IsValid() || !renderContext.IsValid() ) - { - return E_INVALIDCALL; - } - if( !destination.IsValid() ) - { - return E_INVALIDARG; - } - if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) - { - return E_INVALIDARG; - } - if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) - { - return E_INVALIDARG; - } - if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) - { - return E_INVALIDARG; - } - if( destination.m_msaa.samples > 1 ) - { - return E_INVALIDARG; - } + return S_OK; +} - return S_OK; +ALResult Tr2TextureAL::GenerateMipMaps( Tr2RenderContextAL& ) +{ + if( !HasFlag( m_gpuUsage, Tr2GpuUsage::RENDER_TARGET ) || !HasFlag( m_gpuUsage, Tr2GpuUsage::SHADER_RESOURCE ) ) + { + return E_INVALIDCALL; } + return S_OK; +} - uintptr_t Tr2TextureAL::GetSharedHandle() const +ALResult Tr2TextureAL::Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ) +{ + if( m_msaa.samples <= 1 ) { - return 0; + return destination.CopySubresourceRegion( Tr2TextureSubresource(), *this, Tr2TextureSubresource(), renderContext ); } - uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace ) const + if( !IsValid() || !renderContext.IsValid() ) { - return 0xffffffff; + return E_INVALIDCALL; } - - uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t ) const + if( !destination.IsValid() ) { - return 0xffffffff; + return E_INVALIDARG; } - - void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& ) const + if( !HasFlag( destination.m_cpuUsage, Tr2CpuUsage::WRITE ) && !IsWritable( destination.m_gpuUsage ) ) { + return E_INVALIDARG; } - - ALResult Tr2TextureAL::SetName( const char* ) + if( m_desc.GetWidth() != destination.m_desc.GetWidth() || m_desc.GetHeight() != destination.m_desc.GetHeight() ) { - return S_OK; + return E_INVALIDARG; } - - const char* Tr2TextureAL::GetName() const + if( m_desc.GetFormat() != destination.m_desc.GetFormat() ) + { + return E_INVALIDARG; + } + if( destination.m_msaa.samples > 1 ) { - return nullptr; + return E_INVALIDARG; } + + return S_OK; +} + +uintptr_t Tr2TextureAL::GetSharedHandle() const +{ + return 0; +} + +uint32_t Tr2TextureAL::GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace ) const +{ + return 0xffffffff; +} + +uint32_t Tr2TextureAL::GetUavIndexInHeap( uint32_t ) const +{ + return 0xffffffff; +} + +void Tr2TextureAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2TextureAL::SetName( const char* ) +{ + return S_OK; +} + +const char* Tr2TextureAL::GetName() const +{ + return nullptr; +} } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2TextureALStub.h b/trinityal/stub/Tr2TextureALStub.h index 82e2f6279..029c978df 100644 --- a/trinityal/stub/Tr2TextureALStub.h +++ b/trinityal/stub/Tr2TextureALStub.h @@ -2,58 +2,57 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2TextureAL.h" #include "../Tr2HalHelperStructures.h" namespace TrinityALImpl { - class Tr2TextureAL : public Tr2DeviceResourceAL +class Tr2TextureAL : public Tr2DeviceResourceAL +{ +public: + Tr2TextureAL(); + + ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); + ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); + void Destroy(); + + bool IsValid() const; + Tr2ALMemoryType GetMemoryClass() const; + const Tr2BitmapDimensions& GetDesc() const; + const Tr2MsaaDesc& GetMsaaDesc() const; + Tr2GpuUsage::Type GetGpuUsage() const; + Tr2CpuUsage::Type GetCpuUsage() const; + + ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) { - public: - Tr2TextureAL(); - - ALResult Create( const Tr2BitmapDimensions& desc, const Tr2MsaaDesc& msaa, Tr2GpuUsage::Type gpuUsage, Tr2CpuUsage::Type cpuUsage, Tr2SubresourceData* initialData, Tr2PrimaryRenderContextAL& renderContext ); - ALResult OpenShared( uintptr_t handle, Tr2GpuUsage::Type gpuUsage, Tr2PrimaryRenderContextAL& renderContext ); - void Destroy(); - - bool IsValid() const; - Tr2ALMemoryType GetMemoryClass() const; - const Tr2BitmapDimensions& GetDesc() const; - const Tr2MsaaDesc& GetMsaaDesc() const; - Tr2GpuUsage::Type GetGpuUsage() const; - Tr2CpuUsage::Type GetCpuUsage() const; - - ALResult MapForReading( const Tr2TextureSubresource& region, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ) - { - return MapForReading( region, true, data, pitch, renderContext ); - } - ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForReading( Tr2RenderContextAL& renderContext ); - ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); - void UnmapForWriting( Tr2RenderContextAL& renderContext ); - - ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); - ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); - ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); - ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); - uintptr_t GetSharedHandle() const; - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - const char* GetName() const; - - uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; - uint32_t GetUavIndexInHeap( uint32_t mip ) const; - - private: - - Tr2BitmapDimensions m_desc; - Tr2MsaaDesc m_msaa; - Tr2GpuUsage::Type m_gpuUsage; - Tr2CpuUsage::Type m_cpuUsage; - CcpMallocBuffer m_data; - }; + return MapForReading( region, true, data, pitch, renderContext ); + } + ALResult MapForReading( const Tr2TextureSubresource& region, bool synchronize, const void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForReading( Tr2RenderContextAL& renderContext ); + ALResult MapForWriting( const Tr2TextureSubresource& region, void*& data, uint32_t& pitch, Tr2RenderContextAL& renderContext ); + void UnmapForWriting( Tr2RenderContextAL& renderContext ); + + ALResult UpdateSubresource( const Tr2TextureSubresource& region, const void* source, uint32_t pitch, uint32_t slicePitch, Tr2RenderContextAL& renderContext ); + ALResult CopySubresourceRegion( const Tr2TextureSubresource& destSubresource, Tr2TextureAL& source, const Tr2TextureSubresource& sourceSubresource, Tr2RenderContextAL& renderContext ); + ALResult GenerateMipMaps( Tr2RenderContextAL& renderContext ); + ALResult Resolve( Tr2TextureAL& destination, Tr2RenderContextAL& renderContext ); + uintptr_t GetSharedHandle() const; + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + const char* GetName() const; + + uint32_t GetSrvIndexInHeap( Tr2RenderContextEnum::ColorSpace colorSpace = Tr2RenderContextEnum::COLOR_SPACE_LINEAR ) const; + uint32_t GetUavIndexInHeap( uint32_t mip ) const; + +private: + Tr2BitmapDimensions m_desc; + Tr2MsaaDesc m_msaa; + Tr2GpuUsage::Type m_gpuUsage; + Tr2CpuUsage::Type m_cpuUsage; + CcpMallocBuffer m_data; +}; } diff --git a/trinityal/stub/Tr2VertexLayoutALStub.cpp b/trinityal/stub/Tr2VertexLayoutALStub.cpp index de6560ed5..978a6c530 100644 --- a/trinityal/stub/Tr2VertexLayoutALStub.cpp +++ b/trinityal/stub/Tr2VertexLayoutALStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2VertexLayoutALStub.h" #include "Tr2VertexDefinition.h" @@ -14,33 +14,33 @@ using namespace Tr2RenderContextEnum; namespace TrinityALImpl { - ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ) +ALResult Tr2VertexLayoutAL::Create( const Tr2VertexDefinition& definition, Tr2RenderContextAL& renderContext ) +{ + if( !renderContext.IsValid() ) { - if( !renderContext.IsValid() ) - { - return E_FAIL; - } - - m_definition = std::unique_ptr( new Tr2VertexDefinition( definition ) ); - if( definition.m_items.empty() ) - { - return E_FAIL; - } - return S_OK; + return E_FAIL; } - void Tr2VertexLayoutAL::Destroy() + m_definition = std::unique_ptr( new Tr2VertexDefinition( definition ) ); + if( definition.m_items.empty() ) { - m_definition.reset(); + return E_FAIL; } + return S_OK; +} - void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& ) const - { - } +void Tr2VertexLayoutAL::Destroy() +{ + m_definition.reset(); +} - ALResult Tr2VertexLayoutAL::SetName( const char* ) - { - return S_OK; - } +void Tr2VertexLayoutAL::Describe( Tr2DeviceResourceDescriptionAL& ) const +{ +} + +ALResult Tr2VertexLayoutAL::SetName( const char* ) +{ + return S_OK; +} } #endif diff --git a/trinityal/stub/Tr2VertexLayoutALStub.h b/trinityal/stub/Tr2VertexLayoutALStub.h index 8012ea281..64065e39a 100644 --- a/trinityal/stub/Tr2VertexLayoutALStub.h +++ b/trinityal/stub/Tr2VertexLayoutALStub.h @@ -2,7 +2,7 @@ #pragma once -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "../include/Tr2VertexLayoutAL.h" #include "../Tr2VertexDefinition.h" @@ -10,31 +10,32 @@ namespace TrinityALImpl { - class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +class Tr2VertexLayoutAL : public Tr2DeviceResourceAL +{ +public: + Tr2VertexLayoutAL() + { + } + + ALResult Create( const Tr2VertexDefinition& definition, + Tr2RenderContextAL& renderContext ); + bool IsValid() const + { + return m_definition.get() != nullptr; + ; + } + void Destroy(); + + Tr2ALMemoryType GetMemoryClass() const { - public: - Tr2VertexLayoutAL() - { - } - - ALResult Create( const Tr2VertexDefinition& definition, - Tr2RenderContextAL& renderContext ); - bool IsValid() const - { - return m_definition.get() != nullptr;; - } - void Destroy(); - - Tr2ALMemoryType GetMemoryClass() const - { - return AL_MEMORY_MANAGED; - } - void Describe( Tr2DeviceResourceDescriptionAL& description ) const; - ALResult SetName( const char* name ); - - private: - std::unique_ptr m_definition; - }; + return AL_MEMORY_MANAGED; + } + void Describe( Tr2DeviceResourceDescriptionAL& description ) const; + ALResult SetName( const char* name ); + +private: + std::unique_ptr m_definition; +}; } #endif \ No newline at end of file diff --git a/trinityal/stub/Tr2VideoAdapterInfoALStub.cpp b/trinityal/stub/Tr2VideoAdapterInfoALStub.cpp index b137dcc1c..a3678d069 100644 --- a/trinityal/stub/Tr2VideoAdapterInfoALStub.cpp +++ b/trinityal/stub/Tr2VideoAdapterInfoALStub.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) #include "Tr2VideoAdapterInfoALStub.h" #include "Tr2AdapterStructures.h" @@ -17,29 +17,29 @@ ALResult Tr2VideoAdapterInfo::GetAdapterCount( unsigned& count ) bool GetDeviceId( uint32_t& deviceId ) { - deviceId = 0; - return true; + deviceId = 0; + return true; } ALResult Tr2VideoAdapterInfo::GetAdapterInfo( unsigned, Tr2AdapterInfo& info ) { - - - + + + info.driver = "stub"; info.description = L"Not an actual adapter."; info.deviceName = "stub"; info.driverVersion = 2533352100662421; info.vendorID = 0; - GetDeviceId(info.deviceID); + GetDeviceId( info.deviceID ); info.subSystemID = 0; info.revision = 163; AdapterGuid id; id.data1 = 0; id.data2 = 0; id.data3 = 0; - for( int i = 0; i < 8; i++) + for( int i = 0; i < 8; i++ ) { id.data4[i] = 0; } @@ -86,7 +86,7 @@ ALResult Tr2VideoAdapterInfo::GetAdapterMode( unsigned, mode.scaling = DISPLAY_SCALING_UNSPECIFIED; mode.scanlineOrdering = SCANLINE_ORDER_UNSPECIFIED; mode.width = 1920; - + return S_OK; } diff --git a/trinityal/stub/Tr2VideoAdapterInfoALStub.h b/trinityal/stub/Tr2VideoAdapterInfoALStub.h index abcdb25f5..b78aedca6 100644 --- a/trinityal/stub/Tr2VideoAdapterInfoALStub.h +++ b/trinityal/stub/Tr2VideoAdapterInfoALStub.h @@ -13,7 +13,7 @@ struct Tr2AdapterInfo; struct Tr2DisplayModeInfo; -#if( TRINITY_PLATFORM==TRINITY_STUB ) +#if ( TRINITY_PLATFORM == TRINITY_STUB ) class Tr2VideoAdapterInfo { @@ -44,7 +44,6 @@ class Tr2VideoAdapterInfo unsigned adapter2 ); static ALResult RefreshData(); - }; #endif diff --git a/trinityal/tests/BitmapDimensions.cpp b/trinityal/tests/BitmapDimensions.cpp index a66df3239..7680c32c3 100644 --- a/trinityal/tests/BitmapDimensions.cpp +++ b/trinityal/tests/BitmapDimensions.cpp @@ -7,9 +7,11 @@ using namespace Tr2RenderContextEnum; namespace { -struct BitmapDimensionsTest: public Tr2BitmapDimensions +struct BitmapDimensionsTest : public Tr2BitmapDimensions { - BitmapDimensionsTest() {} + BitmapDimensionsTest() + { + } void SetType( TextureType type ) { m_type = type; @@ -100,7 +102,7 @@ TEST( BitmapDimensions, CalculatesTrueMipCountAndMipSizes ) dim.SetMipCount( 0 ); uint32_t level = 0; - while( depth > 1 ) + while( depth > 1 ) { EXPECT_EQ( width, dim.GetMipWidth( level ) ); EXPECT_EQ( height, dim.GetMipHeight( level ) ); @@ -171,11 +173,13 @@ TEST( BitmapDimensions, CalculatesCorrectMipSize ) Tr2RenderContextEnum::PixelFormat formats[] = { Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM, Tr2RenderContextEnum::PIXEL_FORMAT_R16G16B16A16_FLOAT, - Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM, }; + Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM, + }; uint32_t bpp[] = { 32, 64, - 4, }; + 4, + }; for( uint32_t i = 0; i < sizeof( formats ) / sizeof( formats[0] ); ++i ) { dim.SetFormat( formats[i] ); diff --git a/trinityal/tests/Compute.cpp b/trinityal/tests/Compute.cpp index 8f096279f..bfa33a5da 100644 --- a/trinityal/tests/Compute.cpp +++ b/trinityal/tests/Compute.cpp @@ -5,7 +5,9 @@ #if TRINITY_PLATFORM_SUPPORTS_COMPUTE -struct Compute: public WithValidRenderContext {}; +struct Compute : public WithValidRenderContext +{ +}; using namespace Tr2RenderContextEnum; @@ -17,8 +19,8 @@ TEST_F( Compute, CanReadCSResult ) }; auto signature = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) - .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); + .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) + .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); Tr2ShaderAL cs; ASSERT_HRESULT_SUCCEEDED( cs.Create( COMPUTE_SHADER, vsBytecode, signature, "", *renderContext ) ); @@ -59,10 +61,10 @@ TEST_F( Compute, DISABLED_CanAddInCS ) }; auto signature = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ) - .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); + .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ) + .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); Tr2ShaderAL cs; ASSERT_HRESULT_SUCCEEDED( cs.Create( COMPUTE_SHADER, vsBytecode, signature, "", *renderContext ) ); @@ -117,10 +119,10 @@ TEST_F( Compute, CanAddConstantInCS ) }; auto signature = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ) - .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); + .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ) + .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); Tr2ShaderAL cs; ASSERT_HRESULT_SUCCEEDED( cs.Create( COMPUTE_SHADER, vsBytecode, signature, "", *renderContext ) ); @@ -180,10 +182,10 @@ TEST_F( Compute, DISABLED_CanRead2DTextureInCS ) }; auto signature = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) - .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ) - .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); + .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) + .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ) + .Add( Tr2ShaderThreadGroupSizeAL( 1, 1, 1 ) ); Tr2ShaderAL cs; ASSERT_HRESULT_SUCCEEDED( cs.Create( COMPUTE_SHADER, vsBytecode, signature, "", *renderContext ) ); @@ -208,8 +210,8 @@ TEST_F( Compute, DISABLED_CanRead2DTextureInCS ) float border[4] = { 0 }; Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TA_WRAP, 1, @@ -253,8 +255,8 @@ TEST_F( Compute, CanDispatchCSGroups ) }; auto signature = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) - .Add( Tr2ShaderThreadGroupSizeAL( 10, 10, 2 ) ); + .Add( Tr2ShaderRegisterAL::UAV_BUFFER, 0 ) + .Add( Tr2ShaderThreadGroupSizeAL( 10, 10, 2 ) ); Tr2ShaderAL cs; ASSERT_HRESULT_SUCCEEDED( cs.Create( COMPUTE_SHADER, vsBytecode, signature, "", *renderContext ) ); diff --git a/trinityal/tests/ConstantBuffer.cpp b/trinityal/tests/ConstantBuffer.cpp index 92d0ba6c4..cdd74bca7 100644 --- a/trinityal/tests/ConstantBuffer.cpp +++ b/trinityal/tests/ConstantBuffer.cpp @@ -94,7 +94,7 @@ TEST_F( ConstantBuffer, CanLockConstantBuffer ) ASSERT_HRESULT_SUCCEEDED( vb.Unlock( *renderContext ) ); } -#if( TRINITYPLATFORM == TRINITY_STUB ) +#if ( TRINITYPLATFORM == TRINITY_STUB ) TEST_F( ConstantBuffer, UnlockingConstantBufferThatHasNotBeenLockedFails ) { Tr2ConstantBufferAL vb; diff --git a/trinityal/tests/Dxt1Image.h b/trinityal/tests/Dxt1Image.h index cfd71cbf7..14c810883 100644 --- a/trinityal/tests/Dxt1Image.h +++ b/trinityal/tests/Dxt1Image.h @@ -1,6 +1,6 @@ // Copyright © 2023 CCP ehf. - 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000800, 0xddf775dd, 0x00000800, 0x775f77d7, 0x00001020, 0xfdd5ddd5, 0x00210800, 0x2a822202, diff --git a/trinityal/tests/Dxt3Image.h b/trinityal/tests/Dxt3Image.h index b21b87a61..a2ea95be4 100644 --- a/trinityal/tests/Dxt3Image.h +++ b/trinityal/tests/Dxt3Image.h @@ -1,6 +1,6 @@ // Copyright © 2023 CCP ehf. - 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, diff --git a/trinityal/tests/Dxt5Image.h b/trinityal/tests/Dxt5Image.h index 45dbe4ce9..c3c3e4c1b 100644 --- a/trinityal/tests/Dxt5Image.h +++ b/trinityal/tests/Dxt5Image.h @@ -1,6 +1,6 @@ // Copyright © 2023 CCP ehf. - 0x00000000, 0x00000000, 0x00000000, 0x00000000, +0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, diff --git a/trinityal/tests/FakeGoogleTest.h b/trinityal/tests/FakeGoogleTest.h index cdeb505d7..1a3aec6f2 100644 --- a/trinityal/tests/FakeGoogleTest.h +++ b/trinityal/tests/FakeGoogleTest.h @@ -4,9 +4,9 @@ #ifndef FakeGoogleTest_H #define FakeGoogleTest_H -#if defined(TRINITY_AL_MOBILE) +#if defined( TRINITY_AL_MOBILE ) -#if defined(__ANDROID__) +#if defined( __ANDROID__ ) #include #endif @@ -30,16 +30,26 @@ struct TestInfo std::string m_name; }; -struct Test: public TestInfo +struct Test : public TestInfo { - static void SetUpTestCase() {} - static void TearDownTestCase() {} - virtual void SetUp() {} - virtual void TearDown() {} + static void SetUpTestCase() + { + } + static void TearDownTestCase() + { + } + virtual void SetUp() + { + } + virtual void TearDown() + { + } - virtual void Run() {} + virtual void Run() + { + } - typedef void (*SetUpTestCase_t)(); + typedef void ( *SetUpTestCase_t )(); bool m_succeeded; @@ -67,7 +77,7 @@ struct UnitTest } }; -inline void InitGoogleTest( int* argc, char **argv ) +inline void InitGoogleTest( int* argc, char** argv ) { } @@ -82,9 +92,9 @@ struct strcomp } }; -inline std::map, strcomp >& GetAllTests() +inline std::map, strcomp>& GetAllTests() { - static std::map, strcomp > allTests; + static std::map, strcomp> allTests; return allTests; } @@ -92,8 +102,8 @@ inline void AddTest( const char* parent, Test* newTest ) { GetAllTests()[parent].push_back( newTest ); } - -#if defined(__ANDROID__) + +#if defined( __ANDROID__ ) #define PrintMessage( ... ) __android_log_print( ANDROID_LOG_ERROR, "TrinityALTest", __VA_ARGS__ ) #else #define PrintMessage( ... ) printf( __VA_ARGS__ ) @@ -117,8 +127,8 @@ inline int RUN_ALL_TESTS() for( auto jt = std::begin( it->second ); jt != std::end( it->second ); ++jt ) { PrintMessage( - "%s %s\t\t\tRUN\n--------------------------------------------------------\n", - ( *jt )->m_category.c_str(), + "%s %s\t\t\tRUN\n--------------------------------------------------------\n", + ( *jt )->m_category.c_str(), ( *jt )->m_name.c_str() ); ::testing::UnitTest::GetCurrentTest() = *jt; ( *jt )->SetUp(); @@ -135,31 +145,39 @@ inline int RUN_ALL_TESTS() totalFailed++; } PrintMessage( - "%s %s\t\t\t%s\n--------------------------------------------------------\n", - ( *jt )->m_category.c_str(), - ( *jt )->m_name.c_str(), + "%s %s\t\t\t%s\n--------------------------------------------------------\n", + ( *jt )->m_category.c_str(), + ( *jt )->m_name.c_str(), ( *jt )->m_succeeded ? "SUCCESS" : "FAIL" ); } ( *it->second.front()->m_tearDownTestCase )(); } } - PrintMessage( - "\n\n\nRun total %i tests; %i succeeded; %i failed\n\n\n", - totalSucceeded + totalFailed, - totalSucceeded, + PrintMessage( + "\n\n\nRun total %i tests; %i succeeded; %i failed\n\n\n", + totalSucceeded + totalFailed, + totalSucceeded, totalFailed ); return 0; } -#define TEST_( category, name, parent ) struct Test_##category##name: public parent { void Run(); }; \ - struct Test_##category##name##_Factory { Test_##category##name##_Factory() { \ - auto p = new Test_##category##name(); \ - p->m_category = #category; \ - p->m_name = #name; \ - p->m_setUpTestCase = &parent::SetUpTestCase; \ - p->m_tearDownTestCase = &parent::TearDownTestCase; \ - testing::internal::AddTest( #category, p ); } \ - } s_Test_##category##name##_Factory; \ +#define TEST_( category, name, parent ) \ + struct Test_##category##name : public parent \ + { \ + void Run(); \ + }; \ + struct Test_##category##name##_Factory \ + { \ + Test_##category##name##_Factory() \ + { \ + auto p = new Test_##category##name(); \ + p->m_category = #category; \ + p->m_name = #name; \ + p->m_setUpTestCase = &parent::SetUpTestCase; \ + p->m_tearDownTestCase = &parent::TearDownTestCase; \ + testing::internal::AddTest( #category, p ); \ + } \ + } s_Test_##category##name##_Factory; \ void Test_##category##name::Run() #define TEST( category, name ) TEST_( category, name, ::testing::Test ) @@ -173,21 +191,120 @@ inline void FailCurrentTest() } } -#define ASSERT_EQ( val1, val2 ) { if( (val1) != (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); return; } }; -#define ASSERT_NE( val1, val2 ) { if( (val1) == (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 != val2\n", __FILE__, __LINE__ ); return; } }; -#define ASSERT_TRUE( val1 ) { if( !(val1) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 == true\n", __FILE__, __LINE__ ); return; } }; -#define ASSERT_FALSE( val1 ) { if( (val1) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 == false\n", __FILE__, __LINE__ ); return; } }; - -#define EXPECT_EQ( val1, val2 ) { if( (val1) != (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); } }; -#define EXPECT_NE( val1, val2 ) { if( (val1) == (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); } }; -#define EXPECT_GT( val1, val2 ) { if( (val1) <= (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 > val2\n", __FILE__, __LINE__ ); } }; -#define EXPECT_GE( val1, val2 ) { if( (val1) < (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 >= val2\n", __FILE__, __LINE__ ); } }; -#define EXPECT_LE( val1, val2 ) { if( (val1) > (val2) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected val1 <= val2\n", __FILE__, __LINE__ ); } }; -#define EXPECT_TRUE( val ) { if( !( val ) ) { FailCurrentTest(); PrintMessage( "%s (%i): expected true, got false\n", __FILE__, __LINE__ ); } }; -#define EXPECT_FALSE( val ) { if( val ) { FailCurrentTest(); PrintMessage( "%s (%i): expected false, got true\n", __FILE__, __LINE__ ); } }; - -#define ASSERT_HRESULT_SUCCEEDED( hr ) { HRESULT ___hr = (HRESULT)(hr); if( ___hr < 0 ) { FailCurrentTest(); PrintMessage( "%s (%i): expected SUCCEEDED HRESULT, got FAILED (%i)\n", __FILE__, __LINE__, int( ___hr ) ); return; } }; -#define ASSERT_HRESULT_FAILED( hr ) { HRESULT ___hr = (HRESULT)(hr); if( ___hr >= 0 ) { FailCurrentTest(); PrintMessage( "%s (%i): expected FAILED HRESULT, got SUCCEEDED (%i)\n", __FILE__, __LINE__, int( ___hr ) ); return; } }; +#define ASSERT_EQ( val1, val2 ) \ + { \ + if( ( val1 ) != ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); \ + return; \ + } \ + }; +#define ASSERT_NE( val1, val2 ) \ + { \ + if( ( val1 ) == ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 != val2\n", __FILE__, __LINE__ ); \ + return; \ + } \ + }; +#define ASSERT_TRUE( val1 ) \ + { \ + if( !( val1 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 == true\n", __FILE__, __LINE__ ); \ + return; \ + } \ + }; +#define ASSERT_FALSE( val1 ) \ + { \ + if( ( val1 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 == false\n", __FILE__, __LINE__ ); \ + return; \ + } \ + }; + +#define EXPECT_EQ( val1, val2 ) \ + { \ + if( ( val1 ) != ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_NE( val1, val2 ) \ + { \ + if( ( val1 ) == ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 == val2\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_GT( val1, val2 ) \ + { \ + if( ( val1 ) <= ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 > val2\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_GE( val1, val2 ) \ + { \ + if( ( val1 ) < ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 >= val2\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_LE( val1, val2 ) \ + { \ + if( ( val1 ) > ( val2 ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected val1 <= val2\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_TRUE( val ) \ + { \ + if( !( val ) ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected true, got false\n", __FILE__, __LINE__ ); \ + } \ + }; +#define EXPECT_FALSE( val ) \ + { \ + if( val ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected false, got true\n", __FILE__, __LINE__ ); \ + } \ + }; + +#define ASSERT_HRESULT_SUCCEEDED( hr ) \ + { \ + HRESULT ___hr = (HRESULT)( hr ); \ + if( ___hr < 0 ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected SUCCEEDED HRESULT, got FAILED (%i)\n", __FILE__, __LINE__, int( ___hr ) ); \ + return; \ + } \ + }; +#define ASSERT_HRESULT_FAILED( hr ) \ + { \ + HRESULT ___hr = (HRESULT)( hr ); \ + if( ___hr >= 0 ) \ + { \ + FailCurrentTest(); \ + PrintMessage( "%s (%i): expected FAILED HRESULT, got SUCCEEDED (%i)\n", __FILE__, __LINE__, int( ___hr ) ); \ + return; \ + } \ + }; #endif diff --git a/trinityal/tests/GPUTimer.cpp b/trinityal/tests/GPUTimer.cpp index a0f355c82..585ff0c36 100644 --- a/trinityal/tests/GPUTimer.cpp +++ b/trinityal/tests/GPUTimer.cpp @@ -14,14 +14,14 @@ struct GpuTimer : public WithValidRenderContext TEST_F( GpuTimer, TimerIsInvalidBeforeCreation ) { Tr2GpuTimerAL timer; - EXPECT_FALSE(timer.IsValid()); + EXPECT_FALSE( timer.IsValid() ); } TEST_F( WithRenderContext, CreatingWithoutRenderContext ) { Tr2GpuTimerAL timer; - auto hrResult = timer.Create(*renderContext); - ASSERT_HRESULT_FAILED(hrResult); + auto hrResult = timer.Create( *renderContext ); + ASSERT_HRESULT_FAILED( hrResult ); } // GPU timers are disabled for now on Metal because of stability issues @@ -31,30 +31,30 @@ TEST_F( GpuTimer, IsValidAfterCreation ) { ENSURE_GPU_OR_SKIP Tr2GpuTimerAL timer; - auto hrResult = timer.Create(*renderContext); - ASSERT_HRESULT_SUCCEEDED(hrResult); - EXPECT_TRUE(timer.IsValid()); + auto hrResult = timer.Create( *renderContext ); + ASSERT_HRESULT_SUCCEEDED( hrResult ); + EXPECT_TRUE( timer.IsValid() ); } TEST_F( GpuTimer, Begins ) { ENSURE_GPU_OR_SKIP Tr2GpuTimerAL timer; - const auto hrResult = timer.Create(*renderContext); - ASSERT_HRESULT_SUCCEEDED(hrResult); - const auto begins = timer.Begin(*renderContext); - EXPECT_TRUE(begins); + const auto hrResult = timer.Create( *renderContext ); + ASSERT_HRESULT_SUCCEEDED( hrResult ); + const auto begins = timer.Begin( *renderContext ); + EXPECT_TRUE( begins ); } TEST_F( GpuTimer, ValidAfterStopping ) { ENSURE_GPU_OR_SKIP Tr2GpuTimerAL timer; - const auto hrResult = timer.Create(*renderContext); - ASSERT_HRESULT_SUCCEEDED(hrResult); - timer.Begin(*renderContext); - timer.End(*renderContext); - EXPECT_TRUE(timer.IsValid()); + const auto hrResult = timer.Create( *renderContext ); + ASSERT_HRESULT_SUCCEEDED( hrResult ); + timer.Begin( *renderContext ); + timer.End( *renderContext ); + EXPECT_TRUE( timer.IsValid() ); } #endif diff --git a/trinityal/tests/Raytracing.cpp b/trinityal/tests/Raytracing.cpp index bcf86682b..5ac5c879f 100644 --- a/trinityal/tests/Raytracing.cpp +++ b/trinityal/tests/Raytracing.cpp @@ -8,248 +8,274 @@ #if TRINITY_PLATFORM_SUPPORTS_RAY_TRACING -struct Raytracing : public WithValidRenderContext {}; +struct Raytracing : public WithValidRenderContext +{ +}; namespace { - struct Vector3 - { - float x, y, z; - - Vector3() - { - } - - Vector3( float x_, float y_, float z_ ) - :x( x_ ), - y( y_ ), - z( z_ ) - { - } - }; - - struct Vector4 +struct Vector3 +{ + float x, y, z; + + Vector3() { - float x, y, z, w; - }; + } + + Vector3( float x_, float y_, float z_ ) : + x( x_ ), + y( y_ ), + z( z_ ) + { + } +}; - Vector3 cubeVertices[] = { - Vector3( -1, -1, 1 ), - Vector3( 1, -1, 1 ), - Vector3( 1, 1, 1 ), - Vector3( -1, 1, 1 ), - Vector3( -1, -1, -1 ), - Vector3( 1, -1, -1 ), - Vector3( 1, 1, -1 ), - Vector3( -1, 1, -1 ), - }; - - uint16_t cubeIndices[] = { - 0, 1, 2, - 2, 3, 0, - 1, 5, 6, - 6, 2, 1, - 7, 6, 5, - 5, 4, 7, - 4, 0, 3, - 3, 7, 4, - 4, 5, 1, - 1, 0, 4, - 3, 2, 6, - 6, 7, 3 - }; +struct Vector4 +{ + float x, y, z, w; +}; + +Vector3 cubeVertices[] = { + Vector3( -1, -1, 1 ), + Vector3( 1, -1, 1 ), + Vector3( 1, 1, 1 ), + Vector3( -1, 1, 1 ), + Vector3( -1, -1, -1 ), + Vector3( 1, -1, -1 ), + Vector3( 1, 1, -1 ), + Vector3( -1, 1, -1 ), +}; + +uint16_t cubeIndices[] = { + 0, + 1, + 2, + 2, + 3, + 0, + 1, + 5, + 6, + 6, + 2, + 1, + 7, + 6, + 5, + 5, + 4, + 7, + 4, + 0, + 3, + 3, + 7, + 4, + 4, + 5, + 1, + 1, + 0, + 4, + 3, + 2, + 6, + 6, + 7, + 3 +}; } TEST_F( Raytracing, BLASIsInvalidBeforeCreation ) { - Tr2RtBottomLevelAccelerationStructureAL blas; - EXPECT_FALSE( blas.IsValid() ); + Tr2RtBottomLevelAccelerationStructureAL blas; + EXPECT_FALSE( blas.IsValid() ); } TEST_F( Raytracing, BLASIsValidAfterCreation ) { - Tr2BufferAL vb, ib; - // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers + Tr2BufferAL vb, ib; + // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers #if TRINITY_PLATFORM == TRINITY_METAL - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); #else - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); #endif - Tr2RtBottomLevelAccelerationStructureAL blas; + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - ASSERT_TRUE( blas.IsValid() ); + ASSERT_TRUE( blas.IsValid() ); } TEST_F( Raytracing, BLASIsValidAfterUpdate ) { - Tr2BufferAL vb, ib; - // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers + Tr2BufferAL vb, ib; + // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers #if TRINITY_PLATFORM == TRINITY_METAL - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); #else - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); #endif - Tr2RtBottomLevelAccelerationStructureAL blas; + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::ALLOW_UPDATE, *renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( blas.Update( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, *renderContext ) ); - - ASSERT_TRUE( blas.IsValid() ); + + ASSERT_HRESULT_SUCCEEDED( blas.Update( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, *renderContext ) ); + + ASSERT_TRUE( blas.IsValid() ); } TEST_F( Raytracing, TLASIsInvalidBeforeCreation ) { - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_FALSE( tlas.IsValid() ); + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_FALSE( tlas.IsValid() ); } TEST_F( Raytracing, TLASIsValidAfterCreation ) { - Tr2BufferAL vb, ib; - // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers + Tr2BufferAL vb, ib; + // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers #if TRINITY_PLATFORM == TRINITY_METAL - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); #else - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); #endif - Tr2RtBottomLevelAccelerationStructureAL blas; + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - Tr2RtInstanceAL instance; - instance.blas = blas.TrinityALImpl_GetObject(); - memset( instance.transform, 0, sizeof( instance.transform ) ); - instance.transform[0][0] = 1; - instance.transform[1][1] = 1; - instance.transform[2][2] = 1; - instance.materialIndex = 0; + Tr2RtInstanceAL instance; + instance.blas = blas.TrinityALImpl_GetObject(); + memset( instance.transform, 0, sizeof( instance.transform ) ); + instance.transform[0][0] = 1; + instance.transform[1][1] = 1; + instance.transform[2][2] = 1; + instance.materialIndex = 0; - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - ASSERT_TRUE( tlas.IsValid() ); + ASSERT_TRUE( tlas.IsValid() ); } TEST_F( Raytracing, CanCreateStateObject ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; + }; - uint8_t missCode[] = { + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; + }; - uint8_t closestHitCode[] = { + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHit.rs ) - }; - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); - signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); - signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); - - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); - stateDesc.AddGlobalSignature( signature ); - - Tr2RtPipelineStateAL state; - ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); + }; + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); + signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); + signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); + + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); + stateDesc.AddGlobalSignature( signature ); + + Tr2RtPipelineStateAL state; + ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); } TEST_F( Raytracing, CanCreateShaderTable ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; + }; - uint8_t missCode[] = { + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; + }; - uint8_t closestHitCode[] = { + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHit.rs ) - }; - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); - signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); - signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); - - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); - stateDesc.AddGlobalSignature( signature ); - - Tr2RtPipelineStateAL state; - ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); - - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"RayGen_12" ); - shaderTableDesc.AddMissShader( L"Miss_5" ); - shaderTableDesc.AddHitGroup( L"HitGroup" ); - - Tr2RtShaderTableAL shaderTable; - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + }; + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); + signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); + signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); + + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); + stateDesc.AddGlobalSignature( signature ); + + Tr2RtPipelineStateAL state; + ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); + + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"RayGen_12" ); + shaderTableDesc.AddMissShader( L"Miss_5" ); + shaderTableDesc.AddHitGroup( L"HitGroup" ); + + Tr2RtShaderTableAL shaderTable; + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); } TEST_F( Raytracing, ShaderTableCreationFailsWithInvalidShaderName ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; + }; - uint8_t missCode[] = { + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; + }; - uint8_t closestHitCode[] = { + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHit.rs ) - }; + }; - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); - signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); - signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); + signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); + signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); - stateDesc.AddGlobalSignature( signature ); + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", 4 * sizeof( float ) ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", 4 * sizeof( float ) ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", 4 * sizeof( float ) ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); + stateDesc.AddGlobalSignature( signature ); - Tr2RtPipelineStateAL state; - ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); + Tr2RtPipelineStateAL state; + ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); + + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"Blah" ); - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"Blah" ); + Tr2RtShaderTableAL shaderTable; - Tr2RtShaderTableAL shaderTable; - - // metal behaves differently because past the pipeline state we don't really care about the raygen shader + // metal behaves differently because past the pipeline state we don't really care about the raygen shader #if TRINITY_PLATFORM == TRINITY_METAL - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); #else - ASSERT_HRESULT_FAILED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + ASSERT_HRESULT_FAILED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); #endif } @@ -257,754 +283,776 @@ TEST_F( Raytracing, ShaderTableCreationFailsWithInvalidShaderName ) struct QuadRenderer { - ALResult Create( const Tr2TextureAL& texture, Tr2PrimaryRenderContextAL* renderContext ) - { - Tr2ShaderAL vs; - CR_RETURN_HR( CreateTexCoordAndPositionVS( vs, *renderContext ) ); - Tr2ShaderAL ps; - CR_RETURN_HR( CreateSampleTextureFromTexCoordPS( ps, *renderContext ) ); - - Tr2ShaderAL shaders2[] = { vs, ps }; - CR_RETURN_HR( m_shaderProgram.Create( shaders2, 2, *renderContext ) ); - - - Tr2VertexDefinition definition; - definition.Add( Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::POSITION ); - definition.Add( Tr2VertexDefinition::FLOAT32_2, Tr2VertexDefinition::TEXCOORD ); - - CR_RETURN_HR( m_vertexLayout.Create( definition, *renderContext ) ); - - const float hw = 0.8f; - - float quad[] = { - -hw, -hw, 0, 0, 1, - -hw, hw, 0, 0, 0, - hw, -hw, 0, 1, 1, - - hw, -hw, 0, 1, 1, - -hw, hw, 0, 0, 0, - hw, hw, 0, 1, 0, - }; - CR_RETURN_HR( m_quadVb.Create( VB_STRIDE, sizeof( quad ) / VB_STRIDE, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, quad, *renderContext ) ); - - Tr2SamplerStateAL sampl; - CR_RETURN_HR( sampl.Create( - Tr2SamplerDescription( - Tr2RenderContextEnum::TF_POINT, - Tr2RenderContextEnum::TA_WRAP, - 1, - 0.0f, - 0.0f ), - *renderContext ) ); - - Tr2ResourceSetDescriptionAL resourceSetDescription( m_shaderProgram ); - resourceSetDescription.SetSrv( Tr2RenderContextEnum::PIXEL_SHADER, 0, texture ); - resourceSetDescription.SetSampler( Tr2RenderContextEnum::PIXEL_SHADER, 0, sampl ); - - CR_RETURN_HR( m_resourceSet.Create( resourceSetDescription, m_shaderProgram, *renderContext ) ); - return S_OK; - } - - ALResult Render( Tr2RenderContextAL* renderContext ) - { - CR_RETURN_HR( renderContext->SetVertexLayout( m_vertexLayout ) ); - CR_RETURN_HR( renderContext->SetTopology( Tr2RenderContextEnum::TOP_TRIANGLES ) ); - CR_RETURN_HR( renderContext->SetRenderState( Tr2RenderContextEnum::RS_ZENABLE, 0 ) ); + ALResult Create( const Tr2TextureAL& texture, Tr2PrimaryRenderContextAL* renderContext ) + { + Tr2ShaderAL vs; + CR_RETURN_HR( CreateTexCoordAndPositionVS( vs, *renderContext ) ); + Tr2ShaderAL ps; + CR_RETURN_HR( CreateSampleTextureFromTexCoordPS( ps, *renderContext ) ); + + Tr2ShaderAL shaders2[] = { vs, ps }; + CR_RETURN_HR( m_shaderProgram.Create( shaders2, 2, *renderContext ) ); + + + Tr2VertexDefinition definition; + definition.Add( Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::POSITION ); + definition.Add( Tr2VertexDefinition::FLOAT32_2, Tr2VertexDefinition::TEXCOORD ); + + CR_RETURN_HR( m_vertexLayout.Create( definition, *renderContext ) ); + + const float hw = 0.8f; + + float quad[] = { + -hw, + -hw, + 0, + 0, + 1, + -hw, + hw, + 0, + 0, + 0, + hw, + -hw, + 0, + 1, + 1, + + hw, + -hw, + 0, + 1, + 1, + -hw, + hw, + 0, + 0, + 0, + hw, + hw, + 0, + 1, + 0, + }; + CR_RETURN_HR( m_quadVb.Create( VB_STRIDE, sizeof( quad ) / VB_STRIDE, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, quad, *renderContext ) ); + + Tr2SamplerStateAL sampl; + CR_RETURN_HR( sampl.Create( + Tr2SamplerDescription( + Tr2RenderContextEnum::TF_POINT, + Tr2RenderContextEnum::TA_WRAP, + 1, + 0.0f, + 0.0f ), + *renderContext ) ); + + Tr2ResourceSetDescriptionAL resourceSetDescription( m_shaderProgram ); + resourceSetDescription.SetSrv( Tr2RenderContextEnum::PIXEL_SHADER, 0, texture ); + resourceSetDescription.SetSampler( Tr2RenderContextEnum::PIXEL_SHADER, 0, sampl ); + + CR_RETURN_HR( m_resourceSet.Create( resourceSetDescription, m_shaderProgram, *renderContext ) ); + return S_OK; + } + + ALResult Render( Tr2RenderContextAL* renderContext ) + { + CR_RETURN_HR( renderContext->SetVertexLayout( m_vertexLayout ) ); + CR_RETURN_HR( renderContext->SetTopology( Tr2RenderContextEnum::TOP_TRIANGLES ) ); + CR_RETURN_HR( renderContext->SetRenderState( Tr2RenderContextEnum::RS_ZENABLE, 0 ) ); CR_RETURN_HR( renderContext->SetRenderState( Tr2RenderContextEnum::RS_ALPHABLENDENABLE, 0 ) ); CR_RETURN_HR( renderContext->SetRenderState( Tr2RenderContextEnum::RS_CULLMODE, Tr2RenderContextEnum::CULLMODE_NONE ) ); - CR_RETURN_HR( renderContext->SetStreamSource( 0, m_quadVb, 0, VB_STRIDE ) ); - CR_RETURN_HR( renderContext->SetShaderProgram( m_shaderProgram ) ); - CR_RETURN_HR( renderContext->SetResourceSet( m_resourceSet ) ); - CR_RETURN_HR( renderContext->DrawPrimitive( 0, 2 ) ); - return S_OK; - } - - ALResult CreateTexCoordAndPositionVS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) - { - uint8_t bytecode[] = { - #include INCLUDE_SHADER_CODE( TexCoordAndPosition.vs ) - }; - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ); - signature.Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); - - return shader.Create( Tr2RenderContextEnum::VERTEX_SHADER, bytecode, signature, "", renderContext); - } - - ALResult CreateSampleTextureFromTexCoordPS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) - { - uint8_t bytecode[] = { - #include INCLUDE_SHADER_CODE( SampleTextureFromTexCoord.ps ) - }; - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ); - signature.Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); - - return shader.Create( Tr2RenderContextEnum::PIXEL_SHADER, bytecode, signature, "", renderContext); - } - - Tr2ShaderProgramAL m_shaderProgram; - Tr2ResourceSetAL m_resourceSet; - Tr2BufferAL m_quadVb; - Tr2VertexLayoutAL m_vertexLayout; - static const uint32_t VB_STRIDE = 5 * sizeof( float ); + CR_RETURN_HR( renderContext->SetStreamSource( 0, m_quadVb, 0, VB_STRIDE ) ); + CR_RETURN_HR( renderContext->SetShaderProgram( m_shaderProgram ) ); + CR_RETURN_HR( renderContext->SetResourceSet( m_resourceSet ) ); + CR_RETURN_HR( renderContext->DrawPrimitive( 0, 2 ) ); + return S_OK; + } + + ALResult CreateTexCoordAndPositionVS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) + { + uint8_t bytecode[] = { +#include INCLUDE_SHADER_CODE( TexCoordAndPosition.vs ) + }; + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ); + signature.Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); + return shader.Create( Tr2RenderContextEnum::VERTEX_SHADER, bytecode, signature, "", renderContext ); + } + + ALResult CreateSampleTextureFromTexCoordPS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) + { + uint8_t bytecode[] = { +#include INCLUDE_SHADER_CODE( SampleTextureFromTexCoord.ps ) + }; + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ); + signature.Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); + + return shader.Create( Tr2RenderContextEnum::PIXEL_SHADER, bytecode, signature, "", renderContext ); + } + + Tr2ShaderProgramAL m_shaderProgram; + Tr2ResourceSetAL m_resourceSet; + Tr2BufferAL m_quadVb; + Tr2VertexLayoutAL m_vertexLayout; + static const uint32_t VB_STRIDE = 5 * sizeof( float ); }; struct RayGenData { - float viewMatrix[4][4]; - float viewOrigin[3]; - float tanHalfFOV; - float width; - float height; + float viewMatrix[4][4]; + float viewOrigin[3]; + float tanHalfFOV; + float width; + float height; }; void Rotate( float* vector, float angle ) { - float sa = sin( angle ); - float ca = cos( angle ); + float sa = sin( angle ); + float ca = cos( angle ); - float x = vector[0]; - float z = vector[2]; - vector[0] = x * ca - z * sa; - vector[2] = x * sa + z * ca; + float x = vector[0]; + float z = vector[2]; + vector[0] = x * ca - z * sa; + vector[2] = x * sa + z * ca; } void Transpose( float viewMatrix[4][4] ) { - std::swap( viewMatrix[0][1], viewMatrix[1][0] ); - std::swap( viewMatrix[0][2], viewMatrix[2][0] ); - std::swap( viewMatrix[0][3], viewMatrix[3][0] ); + std::swap( viewMatrix[0][1], viewMatrix[1][0] ); + std::swap( viewMatrix[0][2], viewMatrix[2][0] ); + std::swap( viewMatrix[0][3], viewMatrix[3][0] ); - std::swap( viewMatrix[1][2], viewMatrix[2][1] ); - std::swap( viewMatrix[1][3], viewMatrix[3][1] ); + std::swap( viewMatrix[1][2], viewMatrix[2][1] ); + std::swap( viewMatrix[1][3], viewMatrix[3][1] ); - std::swap( viewMatrix[2][3], viewMatrix[3][2] ); + std::swap( viewMatrix[2][3], viewMatrix[3][2] ); } /************* render test *************/ TEST_F( Raytracing, TraceRays ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; - uint8_t missCode[] = { + }; + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; - uint8_t closestHitCode[] = { + }; + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHit.rs ) - }; - - const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms - signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); // RTOutput - signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); // accelStruct, set as 1 because of metal compute buffer binding (4+1) - - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); - stateDesc.AddGlobalSignature( signature ); - - Tr2RtPipelineStateAL state; + }; + + const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms + signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); // RTOutput + signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); // accelStruct, set as 1 because of metal compute buffer binding (4+1) + + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); + stateDesc.AddGlobalSignature( signature ); + + Tr2RtPipelineStateAL state; ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"RayGen_12" ); - shaderTableDesc.AddMissShader( L"Miss_5" ); - shaderTableDesc.AddHitGroup( L"HitGroup" ); - - Tr2RtShaderTableAL shaderTable; - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); - - const uint32_t WIDTH = 512; - const uint32_t HEIGHT = 512; - - Tr2ConstantBufferAL cb; - cb.Create( 6 * 4 * sizeof( float ), *renderContext ); - - // create output texture for shader - Tr2TextureAL resultTex; - ASSERT_HRESULT_SUCCEEDED(resultTex.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ) ); - - Tr2BufferAL vb, ib; - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); - - Tr2RtBottomLevelAccelerationStructureAL blas; + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"RayGen_12" ); + shaderTableDesc.AddMissShader( L"Miss_5" ); + shaderTableDesc.AddHitGroup( L"HitGroup" ); + + Tr2RtShaderTableAL shaderTable; + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + + const uint32_t WIDTH = 512; + const uint32_t HEIGHT = 512; + + Tr2ConstantBufferAL cb; + cb.Create( 6 * 4 * sizeof( float ), *renderContext ); + + // create output texture for shader + Tr2TextureAL resultTex; + ASSERT_HRESULT_SUCCEEDED( resultTex.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ) ); + + Tr2BufferAL vb, ib; + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - - Tr2RtInstanceAL instance; + + Tr2RtInstanceAL instance; instance.blas = blas.TrinityALImpl_GetObject(); - memset( instance.transform, 0, sizeof( instance.transform ) ); - instance.transform[0][0] = 1; - instance.transform[1][1] = 1; - instance.transform[2][2] = 1; - instance.materialIndex = 0; - - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - - auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; - Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); - - // We need to insert a UAV barrier before using the acceleration structures in a raytracing - Tr2ResourceSetDescriptionAL rsDesc( registerMap ); - rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); // accelerationStructure - rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, resultTex ); // RTOutput - - Tr2ResourceSetAL rs; - rs.Create( rsDesc, state, *renderContext ); - - QuadRenderer quadRenderer; - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( resultTex, renderContext ) ); - - uint32_t g = 127; - uint32_t offset = 4; - auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); - ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ((g & 0xff) << 8), 1.0f ) ); - - float angle = float( g - 127 ) * 0.01f; - - RayGenData* cbData; - ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); - memset( cbData, 0, cb.GetSize() ); - cbData->viewMatrix[0][0] = 1; - cbData->viewMatrix[1][1] = 1; - cbData->viewMatrix[2][2] = 1; - cbData->viewMatrix[3][3] = 1; - cbData->viewOrigin[2] = -3; - Rotate( cbData->viewMatrix[0], angle ); - Rotate( cbData->viewMatrix[2], angle ); - Rotate( cbData->viewOrigin, angle ); - Transpose( cbData->viewMatrix ); - cbData->tanHalfFOV = 1; - cbData->width = float( WIDTH ); - cbData->height = float( HEIGHT ); - cb.Unlock( *renderContext ); - - float clearColor[] = { 0, 0, float( g & 0xff ) / 255.f, 0 }; - ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( resultTex, 0, clearColor ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0) ); - ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); - - // mac specific - renderContext->UseAccelerationStructure( tlas ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); - - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); - MakeTestScreenShot(); - ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); - g++; - }; - - RunLoop( frame ); + memset( instance.transform, 0, sizeof( instance.transform ) ); + instance.transform[0][0] = 1; + instance.transform[1][1] = 1; + instance.transform[2][2] = 1; + instance.materialIndex = 0; + + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); + + auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; + Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); + + // We need to insert a UAV barrier before using the acceleration structures in a raytracing + Tr2ResourceSetDescriptionAL rsDesc( registerMap ); + rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); // accelerationStructure + rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, resultTex ); // RTOutput + + Tr2ResourceSetAL rs; + rs.Create( rsDesc, state, *renderContext ); + + QuadRenderer quadRenderer; + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( resultTex, renderContext ) ); + + uint32_t g = 127; + uint32_t offset = 4; + auto frame = [&] { + ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); + ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); + + float angle = float( g - 127 ) * 0.01f; + + RayGenData* cbData; + ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); + memset( cbData, 0, cb.GetSize() ); + cbData->viewMatrix[0][0] = 1; + cbData->viewMatrix[1][1] = 1; + cbData->viewMatrix[2][2] = 1; + cbData->viewMatrix[3][3] = 1; + cbData->viewOrigin[2] = -3; + Rotate( cbData->viewMatrix[0], angle ); + Rotate( cbData->viewMatrix[2], angle ); + Rotate( cbData->viewOrigin, angle ); + Transpose( cbData->viewMatrix ); + cbData->tanHalfFOV = 1; + cbData->width = float( WIDTH ); + cbData->height = float( HEIGHT ); + cb.Unlock( *renderContext ); + + float clearColor[] = { 0, 0, float( g & 0xff ) / 255.f, 0 }; + ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( resultTex, 0, clearColor ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); + + // mac specific + renderContext->UseAccelerationStructure( tlas ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); + + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); + MakeTestScreenShot(); + ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); + g++; + }; + + RunLoop( frame ); } TEST_F( Raytracing, CanUpdateBlas ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; - uint8_t missCode[] = { + }; + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; - uint8_t closestHitCode[] = { + }; + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHit.rs ) - }; - - const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); - - Tr2ShaderSignatureAL signature; - signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms - signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); // RTOutput - signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); // accelStruct, set as 1 because of metal compute buffer binding (4+1) - - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); - stateDesc.AddGlobalSignature( signature ); - - Tr2RtPipelineStateAL state; - ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); - - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"RayGen_12" ); - shaderTableDesc.AddMissShader( L"Miss_5" ); - shaderTableDesc.AddHitGroup( L"HitGroup" ); - - Tr2RtShaderTableAL shaderTable; - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); - - const uint32_t WIDTH = 512; - const uint32_t HEIGHT = 512; - - Tr2ConstantBufferAL cb; - cb.Create( 6 * 4 * sizeof( float ), *renderContext ); - - // create output texture for shader - Tr2TextureAL resultTex; - ASSERT_HRESULT_SUCCEEDED(resultTex.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ) ); - - Tr2BufferAL vb, ib; - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); - - Tr2RtBottomLevelAccelerationStructureAL blas; + }; + + const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); + + Tr2ShaderSignatureAL signature; + signature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms + signature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); // RTOutput + signature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); // accelStruct, set as 1 because of metal compute buffer binding (4+1) + + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr ); + stateDesc.AddGlobalSignature( signature ); + + Tr2RtPipelineStateAL state; + ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); + + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"RayGen_12" ); + shaderTableDesc.AddMissShader( L"Miss_5" ); + shaderTableDesc.AddHitGroup( L"HitGroup" ); + + Tr2RtShaderTableAL shaderTable; + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + + const uint32_t WIDTH = 512; + const uint32_t HEIGHT = 512; + + Tr2ConstantBufferAL cb; + cb.Create( 6 * 4 * sizeof( float ), *renderContext ); + + // create output texture for shader + Tr2TextureAL resultTex; + ASSERT_HRESULT_SUCCEEDED( resultTex.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R8G8B8A8_UNORM ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ) ); + + Tr2BufferAL vb, ib; + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::ALLOW_UPDATE, *renderContext ) ); - - Tr2RtInstanceAL instance; + + Tr2RtInstanceAL instance; instance.blas = blas.TrinityALImpl_GetObject(); - memset( instance.transform, 0, sizeof( instance.transform ) ); - instance.transform[0][0] = 1; - instance.transform[1][1] = 1; - instance.transform[2][2] = 1; - instance.materialIndex = 0; - - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - - auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; - Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); - - // We need to insert a UAV barrier before using the acceleration structures in a raytracing - Tr2ResourceSetDescriptionAL rsDesc( registerMap ); - rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); // accelerationStructure - rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, resultTex ); // RTOutput - - Tr2ResourceSetAL rs; - rs.Create( rsDesc, state, *renderContext ); - - QuadRenderer quadRenderer; - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( resultTex, renderContext ) ); - - uint32_t g = 127; - uint32_t offset = 4; - auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); - ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ((g & 0xff) << 0), 1.0f ) ); - - float angle = 0.2f;//float( g - 127 ) * 0.01f; - - RayGenData* cbData; - ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); - memset( cbData, 0, cb.GetSize() ); - cbData->viewMatrix[0][0] = 1; - cbData->viewMatrix[1][1] = 1; - cbData->viewMatrix[2][2] = 1; - cbData->viewMatrix[3][3] = 1; - cbData->viewOrigin[2] = -3; - Rotate( cbData->viewMatrix[0], angle ); - Rotate( cbData->viewMatrix[2], angle ); - Rotate( cbData->viewOrigin, angle ); - Transpose( cbData->viewMatrix ); - cbData->tanHalfFOV = 1; - cbData->width = float( WIDTH ); - cbData->height = float( HEIGHT ); - cb.Unlock( *renderContext ); - - float dx = sin( g / 100.f ) * 0.1f; - float dy = cos( g / 100.f ) * 0.1f; - Vector3 animatedCube[] = { - Vector3( -1, -1, 1 ), - Vector3( 1, -1, 1 ), - Vector3( 1 + dx, 1, 1 + dy ), - Vector3( -1 + dx, 1, 1 + dy ), - Vector3( -1, -1, -1 ), - Vector3( 1, -1, -1 ), - Vector3( 1 + dx, 1, -1 + dy ), - Vector3( -1 + dx, 1, -1 + dy ), - }; - - ASSERT_HRESULT_SUCCEEDED( vb.UpdateBuffer( 0, sizeof( animatedCube ), animatedCube, *renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( blas.Update( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, *renderContext ) ); - - float clearColor[] = { 0, 0, float( g & 0xff ) / 255.f, 0 }; - ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( resultTex, 0, clearColor ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0) ); - ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); - - // mac specific - renderContext->UseAccelerationStructure( tlas ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); - - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); - MakeTestScreenShot(); - ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); - g++; - }; - - RunLoop( frame ); + memset( instance.transform, 0, sizeof( instance.transform ) ); + instance.transform[0][0] = 1; + instance.transform[1][1] = 1; + instance.transform[2][2] = 1; + instance.materialIndex = 0; + + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_HRESULT_SUCCEEDED( tlas.Create( 1, &instance, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); + + auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; + Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &signature, 1 ); + + // We need to insert a UAV barrier before using the acceleration structures in a raytracing + Tr2ResourceSetDescriptionAL rsDesc( registerMap ); + rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); // accelerationStructure + rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, resultTex ); // RTOutput + + Tr2ResourceSetAL rs; + rs.Create( rsDesc, state, *renderContext ); + + QuadRenderer quadRenderer; + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( resultTex, renderContext ) ); + + uint32_t g = 127; + uint32_t offset = 4; + auto frame = [&] { + ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); + ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 0 ), 1.0f ) ); + + float angle = 0.2f; //float( g - 127 ) * 0.01f; + + RayGenData* cbData; + ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); + memset( cbData, 0, cb.GetSize() ); + cbData->viewMatrix[0][0] = 1; + cbData->viewMatrix[1][1] = 1; + cbData->viewMatrix[2][2] = 1; + cbData->viewMatrix[3][3] = 1; + cbData->viewOrigin[2] = -3; + Rotate( cbData->viewMatrix[0], angle ); + Rotate( cbData->viewMatrix[2], angle ); + Rotate( cbData->viewOrigin, angle ); + Transpose( cbData->viewMatrix ); + cbData->tanHalfFOV = 1; + cbData->width = float( WIDTH ); + cbData->height = float( HEIGHT ); + cb.Unlock( *renderContext ); + + float dx = sin( g / 100.f ) * 0.1f; + float dy = cos( g / 100.f ) * 0.1f; + Vector3 animatedCube[] = { + Vector3( -1, -1, 1 ), + Vector3( 1, -1, 1 ), + Vector3( 1 + dx, 1, 1 + dy ), + Vector3( -1 + dx, 1, 1 + dy ), + Vector3( -1, -1, -1 ), + Vector3( 1, -1, -1 ), + Vector3( 1 + dx, 1, -1 + dy ), + Vector3( -1 + dx, 1, -1 + dy ), + }; + + ASSERT_HRESULT_SUCCEEDED( vb.UpdateBuffer( 0, sizeof( animatedCube ), animatedCube, *renderContext ) ); + + ASSERT_HRESULT_SUCCEEDED( blas.Update( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, *renderContext ) ); + + float clearColor[] = { 0, 0, float( g & 0xff ) / 255.f, 0 }; + ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( resultTex, 0, clearColor ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); + + // mac specific + renderContext->UseAccelerationStructure( tlas ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); + + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); + MakeTestScreenShot(); + ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); + g++; + }; + + RunLoop( frame ); } TEST_F( Raytracing, CanUseLocalConstants ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; + }; - uint8_t missCode[] = { + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; + }; - uint8_t closestHitCode[] = { + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHitWithMaterial.rs ) - }; + }; - Tr2ShaderSignatureAL globalSignature; - globalSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms - globalSignature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); //RTOutput - globalSignature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); //AccelStruct + Tr2ShaderSignatureAL globalSignature; + globalSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms + globalSignature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); //RTOutput + globalSignature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); //AccelStruct - Tr2ShaderSignatureAL localSignature; - localSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ); + Tr2ShaderSignatureAL localSignature; + localSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ); - const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); + const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr, localSignature ); - stateDesc.AddGlobalSignature( globalSignature ); + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHit", PAYLOAD_SIZE ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr, localSignature ); + stateDesc.AddGlobalSignature( globalSignature ); - Tr2RtPipelineStateAL state; + Tr2RtPipelineStateAL state; ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, renderContext->GetPrimaryRenderContext() ) ); - float* materialData; - - Tr2ConstantBufferAL cb1; - cb1.Create( 4 * 4, *renderContext ); - cb1.Lock( (void**)&materialData, *renderContext ); - materialData[0] = 1; - materialData[1] = 0; - materialData[2] = 1; - materialData[3] = 1; - cb1.Unlock( *renderContext ); - - Tr2ConstantBufferAL cb2; - cb2.Create( 4 * 4, *renderContext ); - cb2.Lock( (void**)&materialData, *renderContext ); - materialData[0] = 1; - materialData[1] = 1; - materialData[2] = 0; - materialData[3] = 1; - cb2.Unlock( *renderContext ); - - - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"RayGen_12" ); - shaderTableDesc.AddMissShader( L"Miss_5" ); - shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb1 ) ); - shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb2 ) ); - - const uint32_t WIDTH = 512; - const uint32_t HEIGHT = 512; - - Tr2ConstantBufferAL cb; - cb.Create( 6 * 4 * sizeof( float ), *renderContext ); - - Tr2TextureAL result; - result.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ); - - Tr2BufferAL vb, ib; - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); - - Tr2RtBottomLevelAccelerationStructureAL blas; + float* materialData; + + Tr2ConstantBufferAL cb1; + cb1.Create( 4 * 4, *renderContext ); + cb1.Lock( (void**)&materialData, *renderContext ); + materialData[0] = 1; + materialData[1] = 0; + materialData[2] = 1; + materialData[3] = 1; + cb1.Unlock( *renderContext ); + + Tr2ConstantBufferAL cb2; + cb2.Create( 4 * 4, *renderContext ); + cb2.Lock( (void**)&materialData, *renderContext ); + materialData[0] = 1; + materialData[1] = 1; + materialData[2] = 0; + materialData[3] = 1; + cb2.Unlock( *renderContext ); + + + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"RayGen_12" ); + shaderTableDesc.AddMissShader( L"Miss_5" ); + shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb1 ) ); + shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb2 ) ); + + const uint32_t WIDTH = 512; + const uint32_t HEIGHT = 512; + + Tr2ConstantBufferAL cb; + cb.Create( 6 * 4 * sizeof( float ), *renderContext ); + + Tr2TextureAL result; + result.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ); + + Tr2BufferAL vb, ib; + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - Tr2RtInstanceAL instances[2]; + Tr2RtInstanceAL instances[2]; instances[0].blas = blas.TrinityALImpl_GetObject(); - memset( instances[0].transform, 0, sizeof( instances[0].transform ) ); - instances[0].transform[0][0] = 0.5f; - instances[0].transform[1][1] = 0.5f; - instances[0].transform[2][2] = 0.5f; - instances[0].transform[0][3] = -0.6f; - instances[0].materialIndex = 0; - - instances[1].blas = blas.TrinityALImpl_GetObject(); - memset( instances[1].transform, 0, sizeof( instances[1].transform ) ); - instances[1].transform[0][0] = 0.5f; - instances[1].transform[1][1] = 0.5f; - instances[1].transform[2][2] = 0.5f; - instances[1].transform[0][3] = 0.6f; - instances[1].materialIndex = 1; - - - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_HRESULT_SUCCEEDED( tlas.Create( 2, instances, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - - auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; - Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &globalSignature, 1 ); - - Tr2ResourceSetDescriptionAL rsDesc(registerMap); - rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); - rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, result ); - - Tr2ResourceSetAL rs; - rs.Create( rsDesc, state, *renderContext ); - - QuadRenderer quadRenderer; - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( result, renderContext ) ); - - uint32_t g = 127; - - auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); - ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ((g & 0xff) << 8), 1.0f ) ); - - Tr2RtShaderTableAL shaderTable; - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); - - float angle = float( g - 127 ) * 0.01f; - - RayGenData* cbData; - ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); - memset( cbData, 0, cb.GetSize() ); - cbData->viewMatrix[0][0] = 1; - cbData->viewMatrix[1][1] = 1; - cbData->viewMatrix[2][2] = 1; - cbData->viewMatrix[3][3] = 1; - cbData->viewOrigin[2] = -3; - Rotate( cbData->viewMatrix[0], angle ); - Rotate( cbData->viewMatrix[2], angle ); - Rotate( cbData->viewOrigin, angle ); - Transpose( cbData->viewMatrix ); - cbData->tanHalfFOV = 1; - cbData->width = float( WIDTH ); - cbData->height = float( HEIGHT ); - cb.Unlock( *renderContext ); - - float clearColor[] = { 0, float( g & 0xff ) / 255.f, 0, 0 }; - ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( result, 0, clearColor ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); - ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); - - renderContext->UseAccelerationStructure( tlas ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); - - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); - MakeTestScreenShot(); - ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); - g++; - }; - - RunLoop( frame ); + memset( instances[0].transform, 0, sizeof( instances[0].transform ) ); + instances[0].transform[0][0] = 0.5f; + instances[0].transform[1][1] = 0.5f; + instances[0].transform[2][2] = 0.5f; + instances[0].transform[0][3] = -0.6f; + instances[0].materialIndex = 0; + + instances[1].blas = blas.TrinityALImpl_GetObject(); + memset( instances[1].transform, 0, sizeof( instances[1].transform ) ); + instances[1].transform[0][0] = 0.5f; + instances[1].transform[1][1] = 0.5f; + instances[1].transform[2][2] = 0.5f; + instances[1].transform[0][3] = 0.6f; + instances[1].materialIndex = 1; + + + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_HRESULT_SUCCEEDED( tlas.Create( 2, instances, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); + + auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; + Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &globalSignature, 1 ); + + Tr2ResourceSetDescriptionAL rsDesc( registerMap ); + rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); + rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, result ); + + Tr2ResourceSetAL rs; + rs.Create( rsDesc, state, *renderContext ); + + QuadRenderer quadRenderer; + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( result, renderContext ) ); + + uint32_t g = 127; + + auto frame = [&] { + ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); + ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); + + Tr2RtShaderTableAL shaderTable; + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + + float angle = float( g - 127 ) * 0.01f; + + RayGenData* cbData; + ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); + memset( cbData, 0, cb.GetSize() ); + cbData->viewMatrix[0][0] = 1; + cbData->viewMatrix[1][1] = 1; + cbData->viewMatrix[2][2] = 1; + cbData->viewMatrix[3][3] = 1; + cbData->viewOrigin[2] = -3; + Rotate( cbData->viewMatrix[0], angle ); + Rotate( cbData->viewMatrix[2], angle ); + Rotate( cbData->viewOrigin, angle ); + Transpose( cbData->viewMatrix ); + cbData->tanHalfFOV = 1; + cbData->width = float( WIDTH ); + cbData->height = float( HEIGHT ); + cb.Unlock( *renderContext ); + + float clearColor[] = { 0, float( g & 0xff ) / 255.f, 0, 0 }; + ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( result, 0, clearColor ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); + + renderContext->UseAccelerationStructure( tlas ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); + + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); + MakeTestScreenShot(); + ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); + g++; + }; + + RunLoop( frame ); } #if TRINITY_PLATFORM == TRINITY_METAL struct PerObjectData { - Vector4 material; - Vector4 clipData; + Vector4 material; + Vector4 clipData; }; TEST_F( Raytracing, CanUsePerObjectData ) { - uint8_t rayGenCode[] = { + uint8_t rayGenCode[] = { #include INCLUDE_SHADER_CODE( RayGen.rs ) - }; + }; - uint8_t missCode[] = { + uint8_t missCode[] = { #include INCLUDE_SHADER_CODE( Miss.rs ) - }; + }; - uint8_t closestHitCode[] = { + uint8_t closestHitCode[] = { #include INCLUDE_SHADER_CODE( ClosestHitWithMaterial.rs ) - }; - - Tr2ShaderSignatureAL globalSignature; - globalSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms - globalSignature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); //RTOutput - globalSignature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); //AccelStruct - - Tr2ShaderSignatureAL localSignature; - localSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ); - - const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); - - Tr2RtPipelineStateDescriptionAL stateDesc; - stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); - stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); - stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHitWithPerObjData", PAYLOAD_SIZE ); - stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr, localSignature ); - stateDesc.AddGlobalSignature( globalSignature ); - - Tr2RtPipelineStateAL state; - ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, *renderContext ) ); - - PerObjectData* materialData; - - Tr2ConstantBufferAL cb1; - cb1.Create( sizeof(PerObjectData), *renderContext ); - cb1.Lock( (void**)&materialData, *renderContext ); - materialData->material.x = 1; - materialData->material.y = 0; - materialData->material.z = 1; - materialData->material.w = 1; - - materialData->clipData.x = 1; - materialData->clipData.y = 1; - materialData->clipData.z = 1; - materialData->clipData.w = 1; - cb1.Unlock( *renderContext ); - - Tr2ConstantBufferAL cb2; - cb2.Create( sizeof(PerObjectData), *renderContext ); - cb2.Lock( (void**)&materialData, *renderContext ); - materialData->material.x = 1; - materialData->material.y = 1; - materialData->material.z = 0; - materialData->material.w = 1; - - materialData->clipData.x = 0; - materialData->clipData.y = 0; - materialData->clipData.z = 0; - materialData->clipData.w = 1; - cb2.Unlock( *renderContext ); - - Tr2RtShaderTableDescriptionAL shaderTableDesc; - shaderTableDesc.AddRayGenShader( L"RayGen_12" ); - shaderTableDesc.AddMissShader( L"Miss_5" ); - shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb1 ) ); - shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb2 ) ); - - const uint32_t WIDTH = 512; - const uint32_t HEIGHT = 512; - - Tr2ConstantBufferAL cb; - cb.Create( 6 * 4 * sizeof( float ), *renderContext ); - - Tr2TextureAL result; - result.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ); - - Tr2BufferAL vb, ib; - // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers + }; + + Tr2ShaderSignatureAL globalSignature; + globalSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); //uniforms + globalSignature.Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 0 ); //RTOutput + globalSignature.Add( Tr2ShaderRegisterAL::SRV_BUFFER, 1 ); //AccelStruct + + Tr2ShaderSignatureAL localSignature; + localSignature.Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 1 ); + + const uint32_t PAYLOAD_SIZE = 4 * sizeof( float ); + + Tr2RtPipelineStateDescriptionAL stateDesc; + stateDesc.AddShader( L"RayGen_12", Tr2ShaderBytecodeAL( rayGenCode ), L"RayGen", PAYLOAD_SIZE ); + stateDesc.AddShader( L"Miss_5", Tr2ShaderBytecodeAL( missCode ), L"Miss", PAYLOAD_SIZE ); + stateDesc.AddShader( L"ClosestHit_76", Tr2ShaderBytecodeAL( closestHitCode ), L"ClosestHitWithPerObjData", PAYLOAD_SIZE ); + stateDesc.AddHitGroup( L"HitGroup", nullptr, L"ClosestHit_76", nullptr, localSignature ); + stateDesc.AddGlobalSignature( globalSignature ); + + Tr2RtPipelineStateAL state; + ASSERT_HRESULT_SUCCEEDED( state.CreateRtPipelineState( stateDesc, *renderContext ) ); + + PerObjectData* materialData; + + Tr2ConstantBufferAL cb1; + cb1.Create( sizeof( PerObjectData ), *renderContext ); + cb1.Lock( (void**)&materialData, *renderContext ); + materialData->material.x = 1; + materialData->material.y = 0; + materialData->material.z = 1; + materialData->material.w = 1; + + materialData->clipData.x = 1; + materialData->clipData.y = 1; + materialData->clipData.z = 1; + materialData->clipData.w = 1; + cb1.Unlock( *renderContext ); + + Tr2ConstantBufferAL cb2; + cb2.Create( sizeof( PerObjectData ), *renderContext ); + cb2.Lock( (void**)&materialData, *renderContext ); + materialData->material.x = 1; + materialData->material.y = 1; + materialData->material.z = 0; + materialData->material.w = 1; + + materialData->clipData.x = 0; + materialData->clipData.y = 0; + materialData->clipData.z = 0; + materialData->clipData.w = 1; + cb2.Unlock( *renderContext ); + + Tr2RtShaderTableDescriptionAL shaderTableDesc; + shaderTableDesc.AddRayGenShader( L"RayGen_12" ); + shaderTableDesc.AddMissShader( L"Miss_5" ); + shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb1 ) ); + shaderTableDesc.AddHitGroup( L"HitGroup", Tr2RtLocalMaterialDescriptionAL().SetConstants( 1, cb2 ) ); + + const uint32_t WIDTH = 512; + const uint32_t HEIGHT = 512; + + Tr2ConstantBufferAL cb; + cb.Create( 6 * 4 * sizeof( float ), *renderContext ); + + Tr2TextureAL result; + result.Create( Tr2BitmapDimensions( WIDTH, HEIGHT, 1, Tr2RenderContextEnum::PIXEL_FORMAT_R32G32B32A32_FLOAT ), Tr2GpuUsage::UNORDERED_ACCESS | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ); + + Tr2BufferAL vb, ib; + // UNSURE ABOUT CPUUSAGE AND HOW TO NAVIGATE THAT ONE, need to have leave it like this for now because of possible metal bug w. buffers #if TRINITY_PLATFORM == TRINITY_METAL - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE_OFTEN, cubeIndices, *renderContext ) ); #else - ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); - ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vb.Create( sizeof( Vector3 ), 8, Tr2GpuUsage::VERTEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeVertices, *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( cubeIndices ) / sizeof( cubeIndices[0] ), Tr2GpuUsage::INDEX_BUFFER | Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::NONE, cubeIndices, *renderContext ) ); #endif - - Tr2RtBottomLevelAccelerationStructureAL blas; + + Tr2RtBottomLevelAccelerationStructureAL blas; ASSERT_HRESULT_SUCCEEDED( blas.Create( { Tr2RtPositionStreamAL( vb ), Tr2RtIndicesStreamAL( ib ) }, Tr2RtBlasGeometryFlags::OPAQUE_GEOMETRY, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - Tr2RtInstanceAL instances[2]; - instances[0].blas = blas; - memset( instances[0].transform, 0, sizeof( instances[0].transform ) ); - instances[0].transform[0][0] = 0.5f; - instances[0].transform[1][1] = 0.5f; - instances[0].transform[2][2] = 0.5f; - instances[0].transform[0][3] = -0.6f; - instances[0].materialIndex = 0; - - instances[1].blas = blas; - memset( instances[1].transform, 0, sizeof( instances[1].transform ) ); - instances[1].transform[0][0] = 0.5f; - instances[1].transform[1][1] = 0.5f; - instances[1].transform[2][2] = 0.5f; - instances[1].transform[0][3] = 0.6f; - instances[1].materialIndex = 1; - - - Tr2RtTopLevelAccelerationStructureAL tlas; - ASSERT_HRESULT_SUCCEEDED( tlas.Create( 2, instances, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); - - auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; - Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &globalSignature, 1 ); - - Tr2ResourceSetDescriptionAL rsDesc(registerMap); - rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); - rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, result ); - - Tr2ResourceSetAL rs; - rs.Create( rsDesc, state, *renderContext ); - - QuadRenderer quadRenderer; - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( result, renderContext ) ); - - uint32_t g = 127; - - auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); - ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ((g & 0xff) << 8), 1.0f ) ); - - Tr2RtShaderTableAL shaderTable; - ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); - - float angle = float( g - 127 ) * 0.01f; - - RayGenData* cbData; - ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); - memset( cbData, 0, cb.GetSize() ); - cbData->viewMatrix[0][0] = 1; - cbData->viewMatrix[1][1] = 1; - cbData->viewMatrix[2][2] = 1; - cbData->viewMatrix[3][3] = 1; - cbData->viewOrigin[2] = -3; - //Rotate( cbData->viewMatrix[0], angle ); - //Rotate( cbData->viewMatrix[2], angle ); - //Rotate( cbData->viewOrigin, angle ); - Transpose( cbData->viewMatrix ); - cbData->tanHalfFOV = 1; - cbData->width = float( WIDTH ); - cbData->height = float( HEIGHT ); - cb.Unlock( *renderContext ); - - float clearColor[] = { 0, float( g & 0xff ) / 255.f, 0, 0 }; - ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( result, 0, clearColor ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); - ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); - - renderContext->UseAccelerationStructure( tlas ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); - - ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); - - ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); - MakeTestScreenShot(); - ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); - g++; - }; - - RunLoop( frame ); + Tr2RtInstanceAL instances[2]; + instances[0].blas = blas; + memset( instances[0].transform, 0, sizeof( instances[0].transform ) ); + instances[0].transform[0][0] = 0.5f; + instances[0].transform[1][1] = 0.5f; + instances[0].transform[2][2] = 0.5f; + instances[0].transform[0][3] = -0.6f; + instances[0].materialIndex = 0; + + instances[1].blas = blas; + memset( instances[1].transform, 0, sizeof( instances[1].transform ) ); + instances[1].transform[0][0] = 0.5f; + instances[1].transform[1][1] = 0.5f; + instances[1].transform[2][2] = 0.5f; + instances[1].transform[0][3] = 0.6f; + instances[1].materialIndex = 1; + + + Tr2RtTopLevelAccelerationStructureAL tlas; + ASSERT_HRESULT_SUCCEEDED( tlas.Create( 2, instances, Tr2RtBuildFlags::PREFER_FAST_TRACE, *renderContext ) ); + + auto shaderType = Tr2RenderContextEnum::COMPUTE_SHADER; + Tr2RegisterMapAL registerMap = Tr2RegisterMapAL( &shaderType, &globalSignature, 1 ); + + Tr2ResourceSetDescriptionAL rsDesc( registerMap ); + rsDesc.SetSrv( Tr2RenderContextEnum::COMPUTE_SHADER, 1, tlas.GetBuffer() ); + rsDesc.SetUav( Tr2RenderContextEnum::COMPUTE_SHADER, 0, result ); + + Tr2ResourceSetAL rs; + rs.Create( rsDesc, state, *renderContext ); + + QuadRenderer quadRenderer; + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Create( result, renderContext ) ); + + uint32_t g = 127; + + auto frame = [&] { + ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); + ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); + + Tr2RtShaderTableAL shaderTable; + ASSERT_HRESULT_SUCCEEDED( shaderTable.Create( shaderTableDesc, state, *renderContext ) ); + + float angle = float( g - 127 ) * 0.01f; + + RayGenData* cbData; + ASSERT_HRESULT_SUCCEEDED( cb.Lock( (void**)&cbData, *renderContext ) ); + memset( cbData, 0, cb.GetSize() ); + cbData->viewMatrix[0][0] = 1; + cbData->viewMatrix[1][1] = 1; + cbData->viewMatrix[2][2] = 1; + cbData->viewMatrix[3][3] = 1; + cbData->viewOrigin[2] = -3; + //Rotate( cbData->viewMatrix[0], angle ); + //Rotate( cbData->viewMatrix[2], angle ); + //Rotate( cbData->viewOrigin, angle ); + Transpose( cbData->viewMatrix ); + cbData->tanHalfFOV = 1; + cbData->width = float( WIDTH ); + cbData->height = float( HEIGHT ); + cb.Unlock( *renderContext ); + + float clearColor[] = { 0, float( g & 0xff ) / 255.f, 0, 0 }; + ASSERT_HRESULT_SUCCEEDED( renderContext->ClearUav( result, 0, clearColor ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::COMPUTE_SHADER, 0 ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->SetResourceSet( rs ) ); + + renderContext->UseAccelerationStructure( tlas ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->DispatchRays( state, shaderTable, L"RayGen_12", WIDTH, HEIGHT, 1 ) ); + + ASSERT_HRESULT_SUCCEEDED( quadRenderer.Render( renderContext ) ); + + ASSERT_HRESULT_SUCCEEDED( renderContext->EndScene() ); + MakeTestScreenShot(); + ASSERT_HRESULT_SUCCEEDED( renderContext->Present() ); + g++; + }; + + RunLoop( frame ); } #endif #endif - diff --git a/trinityal/tests/RenderContext.cpp b/trinityal/tests/RenderContext.cpp index d62aab0bf..4acc3c322 100644 --- a/trinityal/tests/RenderContext.cpp +++ b/trinityal/tests/RenderContext.cpp @@ -121,106 +121,8 @@ TEST_F( PrimaryRenderContext, ValidRenderContextHasValidBackBuffer ) TEST( RenderContextEnum, CanConvertPixelFormatToTypeless ) { Tr2RenderContextEnum::PixelFormat formats[] = { - PIXEL_FORMAT_UNKNOWN , PIXEL_FORMAT_UNKNOWN , - PIXEL_FORMAT_R32G32B32A32_TYPELESS , PIXEL_FORMAT_R32G32B32A32_TYPELESS , - PIXEL_FORMAT_R32G32B32A32_FLOAT , PIXEL_FORMAT_R32G32B32A32_TYPELESS , - PIXEL_FORMAT_R32G32B32A32_UINT , PIXEL_FORMAT_R32G32B32A32_TYPELESS , - PIXEL_FORMAT_R32G32B32A32_SINT , PIXEL_FORMAT_R32G32B32A32_TYPELESS , - PIXEL_FORMAT_R32G32B32_TYPELESS , PIXEL_FORMAT_R32G32B32_TYPELESS , - PIXEL_FORMAT_R32G32B32_FLOAT , PIXEL_FORMAT_R32G32B32_TYPELESS , - PIXEL_FORMAT_R32G32B32_UINT , PIXEL_FORMAT_R32G32B32_TYPELESS , - PIXEL_FORMAT_R32G32B32_SINT , PIXEL_FORMAT_R32G32B32_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_TYPELESS , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_FLOAT , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_UNORM , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_UINT , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_SNORM , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_SINT , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R32G32_TYPELESS , PIXEL_FORMAT_R32G32_TYPELESS , - PIXEL_FORMAT_R32G32_FLOAT , PIXEL_FORMAT_R32G32_TYPELESS , - PIXEL_FORMAT_R32G32_UINT , PIXEL_FORMAT_R32G32_TYPELESS , - PIXEL_FORMAT_R32G32_SINT , PIXEL_FORMAT_R32G32_TYPELESS , - PIXEL_FORMAT_R32G8X24_TYPELESS , PIXEL_FORMAT_R32G8X24_TYPELESS , - PIXEL_FORMAT_D32_FLOAT_S8X24_UINT , PIXEL_FORMAT_D32_FLOAT_S8X24_UINT , - PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS , PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS , - PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT , PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT , - PIXEL_FORMAT_R10G10B10A2_TYPELESS , PIXEL_FORMAT_R10G10B10A2_TYPELESS , - PIXEL_FORMAT_R10G10B10A2_UNORM , PIXEL_FORMAT_R10G10B10A2_TYPELESS , - PIXEL_FORMAT_R10G10B10A2_UINT , PIXEL_FORMAT_R10G10B10A2_TYPELESS , - PIXEL_FORMAT_R11G11B10_FLOAT , PIXEL_FORMAT_R11G11B10_FLOAT , - PIXEL_FORMAT_R8G8B8A8_TYPELESS , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R8G8B8A8_UNORM , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R8G8B8A8_UINT , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R8G8B8A8_SNORM , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R8G8B8A8_SINT , PIXEL_FORMAT_R8G8B8A8_TYPELESS , - PIXEL_FORMAT_R16G16_TYPELESS , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_FLOAT , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_UNORM , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_UINT , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_SNORM , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_SINT , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R32_TYPELESS , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_D32_FLOAT , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_R32_FLOAT , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_R32_UINT , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_R32_SINT , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_R24G8_TYPELESS , PIXEL_FORMAT_R24G8_TYPELESS , - PIXEL_FORMAT_D24_UNORM_S8_UINT , PIXEL_FORMAT_R24G8_TYPELESS , - PIXEL_FORMAT_R24_UNORM_X8_TYPELESS , PIXEL_FORMAT_R24_UNORM_X8_TYPELESS , - PIXEL_FORMAT_X24_TYPELESS_G8_UINT , PIXEL_FORMAT_X24_TYPELESS_G8_UINT , - PIXEL_FORMAT_R8G8_TYPELESS , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R8G8_UNORM , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R8G8_UINT , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R8G8_SNORM , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R8G8_SINT , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R16_TYPELESS , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R16_FLOAT , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_D16_UNORM , PIXEL_FORMAT_D16_UNORM , - PIXEL_FORMAT_R16_UNORM , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R16_UINT , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R16_SNORM , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R16_SINT , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R8_TYPELESS , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_R8_UNORM , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_R8_UINT , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_R8_SNORM , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_R8_SINT , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_A8_UNORM , PIXEL_FORMAT_A8_UNORM , - PIXEL_FORMAT_R1_UNORM , PIXEL_FORMAT_R1_UNORM , - PIXEL_FORMAT_R9G9B9E5_SHAREDEXP , PIXEL_FORMAT_R9G9B9E5_SHAREDEXP , - PIXEL_FORMAT_R8G8_B8G8_UNORM , PIXEL_FORMAT_R8G8_B8G8_UNORM , - PIXEL_FORMAT_G8R8_G8B8_UNORM , PIXEL_FORMAT_G8R8_G8B8_UNORM , - PIXEL_FORMAT_BC1_TYPELESS , PIXEL_FORMAT_BC1_TYPELESS , - PIXEL_FORMAT_BC1_UNORM , PIXEL_FORMAT_BC1_TYPELESS , - PIXEL_FORMAT_BC1_UNORM_SRGB , PIXEL_FORMAT_BC1_TYPELESS , - PIXEL_FORMAT_BC2_TYPELESS , PIXEL_FORMAT_BC2_TYPELESS , - PIXEL_FORMAT_BC2_UNORM , PIXEL_FORMAT_BC2_TYPELESS , - PIXEL_FORMAT_BC2_UNORM_SRGB , PIXEL_FORMAT_BC2_TYPELESS , - PIXEL_FORMAT_BC3_TYPELESS , PIXEL_FORMAT_BC3_TYPELESS , - PIXEL_FORMAT_BC3_UNORM , PIXEL_FORMAT_BC3_TYPELESS , - PIXEL_FORMAT_BC3_UNORM_SRGB , PIXEL_FORMAT_BC3_TYPELESS , - PIXEL_FORMAT_BC4_TYPELESS , PIXEL_FORMAT_BC4_TYPELESS , - PIXEL_FORMAT_BC4_UNORM , PIXEL_FORMAT_BC4_TYPELESS , - PIXEL_FORMAT_BC4_SNORM , PIXEL_FORMAT_BC4_TYPELESS , - PIXEL_FORMAT_BC5_TYPELESS , PIXEL_FORMAT_BC5_TYPELESS , - PIXEL_FORMAT_BC5_UNORM , PIXEL_FORMAT_BC5_TYPELESS , - PIXEL_FORMAT_BC5_SNORM , PIXEL_FORMAT_BC5_TYPELESS , - PIXEL_FORMAT_B5G6R5_UNORM , PIXEL_FORMAT_B5G6R5_UNORM , - PIXEL_FORMAT_B5G5R5A1_UNORM , PIXEL_FORMAT_B5G5R5A1_UNORM , - PIXEL_FORMAT_B8G8R8A8_UNORM , PIXEL_FORMAT_B8G8R8A8_TYPELESS , - PIXEL_FORMAT_B8G8R8X8_UNORM , PIXEL_FORMAT_B8G8R8X8_TYPELESS , - PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM , PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM , - PIXEL_FORMAT_B8G8R8A8_TYPELESS , PIXEL_FORMAT_B8G8R8A8_TYPELESS , - PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB , PIXEL_FORMAT_B8G8R8A8_TYPELESS , - PIXEL_FORMAT_B8G8R8X8_TYPELESS , PIXEL_FORMAT_B8G8R8X8_TYPELESS , - PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB , PIXEL_FORMAT_B8G8R8X8_TYPELESS , - PIXEL_FORMAT_BC6H_TYPELESS , PIXEL_FORMAT_BC6H_TYPELESS , - PIXEL_FORMAT_BC6H_UF16 , PIXEL_FORMAT_BC6H_TYPELESS , - PIXEL_FORMAT_BC6H_SF16 , PIXEL_FORMAT_BC6H_TYPELESS , - PIXEL_FORMAT_BC7_TYPELESS , PIXEL_FORMAT_BC7_TYPELESS , - PIXEL_FORMAT_BC7_UNORM , PIXEL_FORMAT_BC7_TYPELESS , - PIXEL_FORMAT_BC7_UNORM_SRGB , PIXEL_FORMAT_BC7_TYPELESS }; + PIXEL_FORMAT_UNKNOWN, PIXEL_FORMAT_UNKNOWN, PIXEL_FORMAT_R32G32B32A32_TYPELESS, PIXEL_FORMAT_R32G32B32A32_TYPELESS, PIXEL_FORMAT_R32G32B32A32_FLOAT, PIXEL_FORMAT_R32G32B32A32_TYPELESS, PIXEL_FORMAT_R32G32B32A32_UINT, PIXEL_FORMAT_R32G32B32A32_TYPELESS, PIXEL_FORMAT_R32G32B32A32_SINT, PIXEL_FORMAT_R32G32B32A32_TYPELESS, PIXEL_FORMAT_R32G32B32_TYPELESS, PIXEL_FORMAT_R32G32B32_TYPELESS, PIXEL_FORMAT_R32G32B32_FLOAT, PIXEL_FORMAT_R32G32B32_TYPELESS, PIXEL_FORMAT_R32G32B32_UINT, PIXEL_FORMAT_R32G32B32_TYPELESS, PIXEL_FORMAT_R32G32B32_SINT, PIXEL_FORMAT_R32G32B32_TYPELESS, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_FLOAT, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_UNORM, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_UINT, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_SNORM, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R16G16B16A16_SINT, PIXEL_FORMAT_R16G16B16A16_TYPELESS, PIXEL_FORMAT_R32G32_TYPELESS, PIXEL_FORMAT_R32G32_TYPELESS, PIXEL_FORMAT_R32G32_FLOAT, PIXEL_FORMAT_R32G32_TYPELESS, PIXEL_FORMAT_R32G32_UINT, PIXEL_FORMAT_R32G32_TYPELESS, PIXEL_FORMAT_R32G32_SINT, PIXEL_FORMAT_R32G32_TYPELESS, PIXEL_FORMAT_R32G8X24_TYPELESS, PIXEL_FORMAT_R32G8X24_TYPELESS, PIXEL_FORMAT_D32_FLOAT_S8X24_UINT, PIXEL_FORMAT_D32_FLOAT_S8X24_UINT, PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS, PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS, PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT, PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT, PIXEL_FORMAT_R10G10B10A2_TYPELESS, PIXEL_FORMAT_R10G10B10A2_TYPELESS, PIXEL_FORMAT_R10G10B10A2_UNORM, PIXEL_FORMAT_R10G10B10A2_TYPELESS, PIXEL_FORMAT_R10G10B10A2_UINT, PIXEL_FORMAT_R10G10B10A2_TYPELESS, PIXEL_FORMAT_R11G11B10_FLOAT, PIXEL_FORMAT_R11G11B10_FLOAT, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_UNORM, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_UINT, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_SNORM, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R8G8B8A8_SINT, PIXEL_FORMAT_R8G8B8A8_TYPELESS, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_FLOAT, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_UNORM, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_UINT, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_SNORM, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R16G16_SINT, PIXEL_FORMAT_R16G16_TYPELESS, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_D32_FLOAT, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_R32_FLOAT, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_R32_UINT, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_R32_SINT, PIXEL_FORMAT_R32_TYPELESS, PIXEL_FORMAT_R24G8_TYPELESS, PIXEL_FORMAT_R24G8_TYPELESS, PIXEL_FORMAT_D24_UNORM_S8_UINT, PIXEL_FORMAT_R24G8_TYPELESS, PIXEL_FORMAT_R24_UNORM_X8_TYPELESS, PIXEL_FORMAT_R24_UNORM_X8_TYPELESS, PIXEL_FORMAT_X24_TYPELESS_G8_UINT, PIXEL_FORMAT_X24_TYPELESS_G8_UINT, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R8G8_UNORM, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R8G8_UINT, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R8G8_SNORM, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R8G8_SINT, PIXEL_FORMAT_R8G8_TYPELESS, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R16_FLOAT, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_D16_UNORM, PIXEL_FORMAT_D16_UNORM, PIXEL_FORMAT_R16_UNORM, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R16_UINT, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R16_SNORM, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R16_SINT, PIXEL_FORMAT_R16_TYPELESS, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_R8_UNORM, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_R8_UINT, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_R8_SNORM, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_R8_SINT, PIXEL_FORMAT_R8_TYPELESS, PIXEL_FORMAT_A8_UNORM, PIXEL_FORMAT_A8_UNORM, PIXEL_FORMAT_R1_UNORM, PIXEL_FORMAT_R1_UNORM, PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, PIXEL_FORMAT_R8G8_B8G8_UNORM, PIXEL_FORMAT_R8G8_B8G8_UNORM, PIXEL_FORMAT_G8R8_G8B8_UNORM, PIXEL_FORMAT_G8R8_G8B8_UNORM, PIXEL_FORMAT_BC1_TYPELESS, PIXEL_FORMAT_BC1_TYPELESS, PIXEL_FORMAT_BC1_UNORM, PIXEL_FORMAT_BC1_TYPELESS, PIXEL_FORMAT_BC1_UNORM_SRGB, PIXEL_FORMAT_BC1_TYPELESS, PIXEL_FORMAT_BC2_TYPELESS, PIXEL_FORMAT_BC2_TYPELESS, PIXEL_FORMAT_BC2_UNORM, PIXEL_FORMAT_BC2_TYPELESS, PIXEL_FORMAT_BC2_UNORM_SRGB, PIXEL_FORMAT_BC2_TYPELESS, PIXEL_FORMAT_BC3_TYPELESS, PIXEL_FORMAT_BC3_TYPELESS, PIXEL_FORMAT_BC3_UNORM, PIXEL_FORMAT_BC3_TYPELESS, PIXEL_FORMAT_BC3_UNORM_SRGB, PIXEL_FORMAT_BC3_TYPELESS, PIXEL_FORMAT_BC4_TYPELESS, PIXEL_FORMAT_BC4_TYPELESS, PIXEL_FORMAT_BC4_UNORM, PIXEL_FORMAT_BC4_TYPELESS, PIXEL_FORMAT_BC4_SNORM, PIXEL_FORMAT_BC4_TYPELESS, PIXEL_FORMAT_BC5_TYPELESS, PIXEL_FORMAT_BC5_TYPELESS, PIXEL_FORMAT_BC5_UNORM, PIXEL_FORMAT_BC5_TYPELESS, PIXEL_FORMAT_BC5_SNORM, PIXEL_FORMAT_BC5_TYPELESS, PIXEL_FORMAT_B5G6R5_UNORM, PIXEL_FORMAT_B5G6R5_UNORM, PIXEL_FORMAT_B5G5R5A1_UNORM, PIXEL_FORMAT_B5G5R5A1_UNORM, PIXEL_FORMAT_B8G8R8A8_UNORM, PIXEL_FORMAT_B8G8R8A8_TYPELESS, PIXEL_FORMAT_B8G8R8X8_UNORM, PIXEL_FORMAT_B8G8R8X8_TYPELESS, PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, PIXEL_FORMAT_B8G8R8A8_TYPELESS, PIXEL_FORMAT_B8G8R8A8_TYPELESS, PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, PIXEL_FORMAT_B8G8R8A8_TYPELESS, PIXEL_FORMAT_B8G8R8X8_TYPELESS, PIXEL_FORMAT_B8G8R8X8_TYPELESS, PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, PIXEL_FORMAT_B8G8R8X8_TYPELESS, PIXEL_FORMAT_BC6H_TYPELESS, PIXEL_FORMAT_BC6H_TYPELESS, PIXEL_FORMAT_BC6H_UF16, PIXEL_FORMAT_BC6H_TYPELESS, PIXEL_FORMAT_BC6H_SF16, PIXEL_FORMAT_BC6H_TYPELESS, PIXEL_FORMAT_BC7_TYPELESS, PIXEL_FORMAT_BC7_TYPELESS, PIXEL_FORMAT_BC7_UNORM, PIXEL_FORMAT_BC7_TYPELESS, PIXEL_FORMAT_BC7_UNORM_SRGB, PIXEL_FORMAT_BC7_TYPELESS + }; for( uint32_t i = 0; i < sizeof( formats ) / sizeof( formats[0] ); i += 2 ) { @@ -231,106 +133,207 @@ TEST( RenderContextEnum, CanConvertPixelFormatToTypeless ) TEST( RenderContextEnum, CanConvertPixelFormatTosRgb ) { Tr2RenderContextEnum::PixelFormat formats[] = { - PIXEL_FORMAT_UNKNOWN , PIXEL_FORMAT_UNKNOWN , - PIXEL_FORMAT_R32G32B32A32_TYPELESS , PIXEL_FORMAT_R32G32B32A32_TYPELESS , - PIXEL_FORMAT_R32G32B32A32_FLOAT , PIXEL_FORMAT_R32G32B32A32_FLOAT , - PIXEL_FORMAT_R32G32B32A32_UINT , PIXEL_FORMAT_R32G32B32A32_UINT , - PIXEL_FORMAT_R32G32B32A32_SINT , PIXEL_FORMAT_R32G32B32A32_SINT , - PIXEL_FORMAT_R32G32B32_TYPELESS , PIXEL_FORMAT_R32G32B32_TYPELESS , - PIXEL_FORMAT_R32G32B32_FLOAT , PIXEL_FORMAT_R32G32B32_FLOAT , - PIXEL_FORMAT_R32G32B32_UINT , PIXEL_FORMAT_R32G32B32_UINT , - PIXEL_FORMAT_R32G32B32_SINT , PIXEL_FORMAT_R32G32B32_SINT , - PIXEL_FORMAT_R16G16B16A16_TYPELESS , PIXEL_FORMAT_R16G16B16A16_TYPELESS , - PIXEL_FORMAT_R16G16B16A16_FLOAT , PIXEL_FORMAT_R16G16B16A16_FLOAT , - PIXEL_FORMAT_R16G16B16A16_UNORM , PIXEL_FORMAT_R16G16B16A16_UNORM , - PIXEL_FORMAT_R16G16B16A16_UINT , PIXEL_FORMAT_R16G16B16A16_UINT , - PIXEL_FORMAT_R16G16B16A16_SNORM , PIXEL_FORMAT_R16G16B16A16_SNORM , - PIXEL_FORMAT_R16G16B16A16_SINT , PIXEL_FORMAT_R16G16B16A16_SINT , - PIXEL_FORMAT_R32G32_TYPELESS , PIXEL_FORMAT_R32G32_TYPELESS , - PIXEL_FORMAT_R32G32_FLOAT , PIXEL_FORMAT_R32G32_FLOAT , - PIXEL_FORMAT_R32G32_UINT , PIXEL_FORMAT_R32G32_UINT , - PIXEL_FORMAT_R32G32_SINT , PIXEL_FORMAT_R32G32_SINT , - PIXEL_FORMAT_R32G8X24_TYPELESS , PIXEL_FORMAT_R32G8X24_TYPELESS , - PIXEL_FORMAT_D32_FLOAT_S8X24_UINT , PIXEL_FORMAT_D32_FLOAT_S8X24_UINT , - PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS , PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS , - PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT , PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT , - PIXEL_FORMAT_R10G10B10A2_TYPELESS , PIXEL_FORMAT_R10G10B10A2_TYPELESS , - PIXEL_FORMAT_R10G10B10A2_UNORM , PIXEL_FORMAT_R10G10B10A2_UNORM , - PIXEL_FORMAT_R10G10B10A2_UINT , PIXEL_FORMAT_R10G10B10A2_UINT , - PIXEL_FORMAT_R11G11B10_FLOAT , PIXEL_FORMAT_R11G11B10_FLOAT , - PIXEL_FORMAT_R8G8B8A8_TYPELESS , PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB , - PIXEL_FORMAT_R8G8B8A8_UNORM , PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB , - PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB , PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB , - PIXEL_FORMAT_R8G8B8A8_UINT , PIXEL_FORMAT_R8G8B8A8_UINT , - PIXEL_FORMAT_R8G8B8A8_SNORM , PIXEL_FORMAT_R8G8B8A8_SNORM , - PIXEL_FORMAT_R8G8B8A8_SINT , PIXEL_FORMAT_R8G8B8A8_SINT , - PIXEL_FORMAT_R16G16_TYPELESS , PIXEL_FORMAT_R16G16_TYPELESS , - PIXEL_FORMAT_R16G16_FLOAT , PIXEL_FORMAT_R16G16_FLOAT , - PIXEL_FORMAT_R16G16_UNORM , PIXEL_FORMAT_R16G16_UNORM , - PIXEL_FORMAT_R16G16_UINT , PIXEL_FORMAT_R16G16_UINT , - PIXEL_FORMAT_R16G16_SNORM , PIXEL_FORMAT_R16G16_SNORM , - PIXEL_FORMAT_R16G16_SINT , PIXEL_FORMAT_R16G16_SINT , - PIXEL_FORMAT_R32_TYPELESS , PIXEL_FORMAT_R32_TYPELESS , - PIXEL_FORMAT_D32_FLOAT , PIXEL_FORMAT_D32_FLOAT , - PIXEL_FORMAT_R32_FLOAT , PIXEL_FORMAT_R32_FLOAT , - PIXEL_FORMAT_R32_UINT , PIXEL_FORMAT_R32_UINT , - PIXEL_FORMAT_R32_SINT , PIXEL_FORMAT_R32_SINT , - PIXEL_FORMAT_R24G8_TYPELESS , PIXEL_FORMAT_R24G8_TYPELESS , - PIXEL_FORMAT_D24_UNORM_S8_UINT , PIXEL_FORMAT_D24_UNORM_S8_UINT , - PIXEL_FORMAT_R24_UNORM_X8_TYPELESS , PIXEL_FORMAT_R24_UNORM_X8_TYPELESS , - PIXEL_FORMAT_X24_TYPELESS_G8_UINT , PIXEL_FORMAT_X24_TYPELESS_G8_UINT , - PIXEL_FORMAT_R8G8_TYPELESS , PIXEL_FORMAT_R8G8_TYPELESS , - PIXEL_FORMAT_R8G8_UNORM , PIXEL_FORMAT_R8G8_UNORM , - PIXEL_FORMAT_R8G8_UINT , PIXEL_FORMAT_R8G8_UINT , - PIXEL_FORMAT_R8G8_SNORM , PIXEL_FORMAT_R8G8_SNORM , - PIXEL_FORMAT_R8G8_SINT , PIXEL_FORMAT_R8G8_SINT , - PIXEL_FORMAT_R16_TYPELESS , PIXEL_FORMAT_R16_TYPELESS , - PIXEL_FORMAT_R16_FLOAT , PIXEL_FORMAT_R16_FLOAT , - PIXEL_FORMAT_D16_UNORM , PIXEL_FORMAT_D16_UNORM , - PIXEL_FORMAT_R16_UNORM , PIXEL_FORMAT_R16_UNORM , - PIXEL_FORMAT_R16_UINT , PIXEL_FORMAT_R16_UINT , - PIXEL_FORMAT_R16_SNORM , PIXEL_FORMAT_R16_SNORM , - PIXEL_FORMAT_R16_SINT , PIXEL_FORMAT_R16_SINT , - PIXEL_FORMAT_R8_TYPELESS , PIXEL_FORMAT_R8_TYPELESS , - PIXEL_FORMAT_R8_UNORM , PIXEL_FORMAT_R8_UNORM , - PIXEL_FORMAT_R8_UINT , PIXEL_FORMAT_R8_UINT , - PIXEL_FORMAT_R8_SNORM , PIXEL_FORMAT_R8_SNORM , - PIXEL_FORMAT_R8_SINT , PIXEL_FORMAT_R8_SINT , - PIXEL_FORMAT_A8_UNORM , PIXEL_FORMAT_A8_UNORM , - PIXEL_FORMAT_R1_UNORM , PIXEL_FORMAT_R1_UNORM , - PIXEL_FORMAT_R9G9B9E5_SHAREDEXP , PIXEL_FORMAT_R9G9B9E5_SHAREDEXP , - PIXEL_FORMAT_R8G8_B8G8_UNORM , PIXEL_FORMAT_R8G8_B8G8_UNORM , - PIXEL_FORMAT_G8R8_G8B8_UNORM , PIXEL_FORMAT_G8R8_G8B8_UNORM , - PIXEL_FORMAT_BC1_TYPELESS , PIXEL_FORMAT_BC1_UNORM_SRGB , - PIXEL_FORMAT_BC1_UNORM , PIXEL_FORMAT_BC1_UNORM_SRGB , - PIXEL_FORMAT_BC1_UNORM_SRGB , PIXEL_FORMAT_BC1_UNORM_SRGB , - PIXEL_FORMAT_BC2_TYPELESS , PIXEL_FORMAT_BC2_UNORM_SRGB , - PIXEL_FORMAT_BC2_UNORM , PIXEL_FORMAT_BC2_UNORM_SRGB , - PIXEL_FORMAT_BC2_UNORM_SRGB , PIXEL_FORMAT_BC2_UNORM_SRGB , - PIXEL_FORMAT_BC3_TYPELESS , PIXEL_FORMAT_BC3_UNORM_SRGB , - PIXEL_FORMAT_BC3_UNORM , PIXEL_FORMAT_BC3_UNORM_SRGB , - PIXEL_FORMAT_BC3_UNORM_SRGB , PIXEL_FORMAT_BC3_UNORM_SRGB , - PIXEL_FORMAT_BC4_TYPELESS , PIXEL_FORMAT_BC4_TYPELESS , - PIXEL_FORMAT_BC4_UNORM , PIXEL_FORMAT_BC4_UNORM , - PIXEL_FORMAT_BC4_SNORM , PIXEL_FORMAT_BC4_SNORM , - PIXEL_FORMAT_BC5_TYPELESS , PIXEL_FORMAT_BC5_TYPELESS , - PIXEL_FORMAT_BC5_UNORM , PIXEL_FORMAT_BC5_UNORM , - PIXEL_FORMAT_BC5_SNORM , PIXEL_FORMAT_BC5_SNORM , - PIXEL_FORMAT_B5G6R5_UNORM , PIXEL_FORMAT_B5G6R5_UNORM , - PIXEL_FORMAT_B5G5R5A1_UNORM , PIXEL_FORMAT_B5G5R5A1_UNORM , - PIXEL_FORMAT_B8G8R8A8_UNORM , PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB , - PIXEL_FORMAT_B8G8R8X8_UNORM , PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB , - PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM , PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM , - PIXEL_FORMAT_B8G8R8A8_TYPELESS , PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB , - PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB , PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB , - PIXEL_FORMAT_B8G8R8X8_TYPELESS , PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB , - PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB , PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB , - PIXEL_FORMAT_BC6H_TYPELESS , PIXEL_FORMAT_BC6H_TYPELESS , - PIXEL_FORMAT_BC6H_UF16 , PIXEL_FORMAT_BC6H_UF16 , - PIXEL_FORMAT_BC6H_SF16 , PIXEL_FORMAT_BC6H_SF16 , - PIXEL_FORMAT_BC7_TYPELESS , PIXEL_FORMAT_BC7_UNORM_SRGB , - PIXEL_FORMAT_BC7_UNORM , PIXEL_FORMAT_BC7_UNORM_SRGB , - PIXEL_FORMAT_BC7_UNORM_SRGB , PIXEL_FORMAT_BC7_UNORM_SRGB , }; + PIXEL_FORMAT_UNKNOWN, + PIXEL_FORMAT_UNKNOWN, + PIXEL_FORMAT_R32G32B32A32_TYPELESS, + PIXEL_FORMAT_R32G32B32A32_TYPELESS, + PIXEL_FORMAT_R32G32B32A32_FLOAT, + PIXEL_FORMAT_R32G32B32A32_FLOAT, + PIXEL_FORMAT_R32G32B32A32_UINT, + PIXEL_FORMAT_R32G32B32A32_UINT, + PIXEL_FORMAT_R32G32B32A32_SINT, + PIXEL_FORMAT_R32G32B32A32_SINT, + PIXEL_FORMAT_R32G32B32_TYPELESS, + PIXEL_FORMAT_R32G32B32_TYPELESS, + PIXEL_FORMAT_R32G32B32_FLOAT, + PIXEL_FORMAT_R32G32B32_FLOAT, + PIXEL_FORMAT_R32G32B32_UINT, + PIXEL_FORMAT_R32G32B32_UINT, + PIXEL_FORMAT_R32G32B32_SINT, + PIXEL_FORMAT_R32G32B32_SINT, + PIXEL_FORMAT_R16G16B16A16_TYPELESS, + PIXEL_FORMAT_R16G16B16A16_TYPELESS, + PIXEL_FORMAT_R16G16B16A16_FLOAT, + PIXEL_FORMAT_R16G16B16A16_FLOAT, + PIXEL_FORMAT_R16G16B16A16_UNORM, + PIXEL_FORMAT_R16G16B16A16_UNORM, + PIXEL_FORMAT_R16G16B16A16_UINT, + PIXEL_FORMAT_R16G16B16A16_UINT, + PIXEL_FORMAT_R16G16B16A16_SNORM, + PIXEL_FORMAT_R16G16B16A16_SNORM, + PIXEL_FORMAT_R16G16B16A16_SINT, + PIXEL_FORMAT_R16G16B16A16_SINT, + PIXEL_FORMAT_R32G32_TYPELESS, + PIXEL_FORMAT_R32G32_TYPELESS, + PIXEL_FORMAT_R32G32_FLOAT, + PIXEL_FORMAT_R32G32_FLOAT, + PIXEL_FORMAT_R32G32_UINT, + PIXEL_FORMAT_R32G32_UINT, + PIXEL_FORMAT_R32G32_SINT, + PIXEL_FORMAT_R32G32_SINT, + PIXEL_FORMAT_R32G8X24_TYPELESS, + PIXEL_FORMAT_R32G8X24_TYPELESS, + PIXEL_FORMAT_D32_FLOAT_S8X24_UINT, + PIXEL_FORMAT_D32_FLOAT_S8X24_UINT, + PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS, + PIXEL_FORMAT_R32_FLOAT_X8X24_TYPELESS, + PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT, + PIXEL_FORMAT_X32_TYPELESS_G8X24_UINT, + PIXEL_FORMAT_R10G10B10A2_TYPELESS, + PIXEL_FORMAT_R10G10B10A2_TYPELESS, + PIXEL_FORMAT_R10G10B10A2_UNORM, + PIXEL_FORMAT_R10G10B10A2_UNORM, + PIXEL_FORMAT_R10G10B10A2_UINT, + PIXEL_FORMAT_R10G10B10A2_UINT, + PIXEL_FORMAT_R11G11B10_FLOAT, + PIXEL_FORMAT_R11G11B10_FLOAT, + PIXEL_FORMAT_R8G8B8A8_TYPELESS, + PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, + PIXEL_FORMAT_R8G8B8A8_UNORM, + PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, + PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, + PIXEL_FORMAT_R8G8B8A8_UNORM_SRGB, + PIXEL_FORMAT_R8G8B8A8_UINT, + PIXEL_FORMAT_R8G8B8A8_UINT, + PIXEL_FORMAT_R8G8B8A8_SNORM, + PIXEL_FORMAT_R8G8B8A8_SNORM, + PIXEL_FORMAT_R8G8B8A8_SINT, + PIXEL_FORMAT_R8G8B8A8_SINT, + PIXEL_FORMAT_R16G16_TYPELESS, + PIXEL_FORMAT_R16G16_TYPELESS, + PIXEL_FORMAT_R16G16_FLOAT, + PIXEL_FORMAT_R16G16_FLOAT, + PIXEL_FORMAT_R16G16_UNORM, + PIXEL_FORMAT_R16G16_UNORM, + PIXEL_FORMAT_R16G16_UINT, + PIXEL_FORMAT_R16G16_UINT, + PIXEL_FORMAT_R16G16_SNORM, + PIXEL_FORMAT_R16G16_SNORM, + PIXEL_FORMAT_R16G16_SINT, + PIXEL_FORMAT_R16G16_SINT, + PIXEL_FORMAT_R32_TYPELESS, + PIXEL_FORMAT_R32_TYPELESS, + PIXEL_FORMAT_D32_FLOAT, + PIXEL_FORMAT_D32_FLOAT, + PIXEL_FORMAT_R32_FLOAT, + PIXEL_FORMAT_R32_FLOAT, + PIXEL_FORMAT_R32_UINT, + PIXEL_FORMAT_R32_UINT, + PIXEL_FORMAT_R32_SINT, + PIXEL_FORMAT_R32_SINT, + PIXEL_FORMAT_R24G8_TYPELESS, + PIXEL_FORMAT_R24G8_TYPELESS, + PIXEL_FORMAT_D24_UNORM_S8_UINT, + PIXEL_FORMAT_D24_UNORM_S8_UINT, + PIXEL_FORMAT_R24_UNORM_X8_TYPELESS, + PIXEL_FORMAT_R24_UNORM_X8_TYPELESS, + PIXEL_FORMAT_X24_TYPELESS_G8_UINT, + PIXEL_FORMAT_X24_TYPELESS_G8_UINT, + PIXEL_FORMAT_R8G8_TYPELESS, + PIXEL_FORMAT_R8G8_TYPELESS, + PIXEL_FORMAT_R8G8_UNORM, + PIXEL_FORMAT_R8G8_UNORM, + PIXEL_FORMAT_R8G8_UINT, + PIXEL_FORMAT_R8G8_UINT, + PIXEL_FORMAT_R8G8_SNORM, + PIXEL_FORMAT_R8G8_SNORM, + PIXEL_FORMAT_R8G8_SINT, + PIXEL_FORMAT_R8G8_SINT, + PIXEL_FORMAT_R16_TYPELESS, + PIXEL_FORMAT_R16_TYPELESS, + PIXEL_FORMAT_R16_FLOAT, + PIXEL_FORMAT_R16_FLOAT, + PIXEL_FORMAT_D16_UNORM, + PIXEL_FORMAT_D16_UNORM, + PIXEL_FORMAT_R16_UNORM, + PIXEL_FORMAT_R16_UNORM, + PIXEL_FORMAT_R16_UINT, + PIXEL_FORMAT_R16_UINT, + PIXEL_FORMAT_R16_SNORM, + PIXEL_FORMAT_R16_SNORM, + PIXEL_FORMAT_R16_SINT, + PIXEL_FORMAT_R16_SINT, + PIXEL_FORMAT_R8_TYPELESS, + PIXEL_FORMAT_R8_TYPELESS, + PIXEL_FORMAT_R8_UNORM, + PIXEL_FORMAT_R8_UNORM, + PIXEL_FORMAT_R8_UINT, + PIXEL_FORMAT_R8_UINT, + PIXEL_FORMAT_R8_SNORM, + PIXEL_FORMAT_R8_SNORM, + PIXEL_FORMAT_R8_SINT, + PIXEL_FORMAT_R8_SINT, + PIXEL_FORMAT_A8_UNORM, + PIXEL_FORMAT_A8_UNORM, + PIXEL_FORMAT_R1_UNORM, + PIXEL_FORMAT_R1_UNORM, + PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, + PIXEL_FORMAT_R9G9B9E5_SHAREDEXP, + PIXEL_FORMAT_R8G8_B8G8_UNORM, + PIXEL_FORMAT_R8G8_B8G8_UNORM, + PIXEL_FORMAT_G8R8_G8B8_UNORM, + PIXEL_FORMAT_G8R8_G8B8_UNORM, + PIXEL_FORMAT_BC1_TYPELESS, + PIXEL_FORMAT_BC1_UNORM_SRGB, + PIXEL_FORMAT_BC1_UNORM, + PIXEL_FORMAT_BC1_UNORM_SRGB, + PIXEL_FORMAT_BC1_UNORM_SRGB, + PIXEL_FORMAT_BC1_UNORM_SRGB, + PIXEL_FORMAT_BC2_TYPELESS, + PIXEL_FORMAT_BC2_UNORM_SRGB, + PIXEL_FORMAT_BC2_UNORM, + PIXEL_FORMAT_BC2_UNORM_SRGB, + PIXEL_FORMAT_BC2_UNORM_SRGB, + PIXEL_FORMAT_BC2_UNORM_SRGB, + PIXEL_FORMAT_BC3_TYPELESS, + PIXEL_FORMAT_BC3_UNORM_SRGB, + PIXEL_FORMAT_BC3_UNORM, + PIXEL_FORMAT_BC3_UNORM_SRGB, + PIXEL_FORMAT_BC3_UNORM_SRGB, + PIXEL_FORMAT_BC3_UNORM_SRGB, + PIXEL_FORMAT_BC4_TYPELESS, + PIXEL_FORMAT_BC4_TYPELESS, + PIXEL_FORMAT_BC4_UNORM, + PIXEL_FORMAT_BC4_UNORM, + PIXEL_FORMAT_BC4_SNORM, + PIXEL_FORMAT_BC4_SNORM, + PIXEL_FORMAT_BC5_TYPELESS, + PIXEL_FORMAT_BC5_TYPELESS, + PIXEL_FORMAT_BC5_UNORM, + PIXEL_FORMAT_BC5_UNORM, + PIXEL_FORMAT_BC5_SNORM, + PIXEL_FORMAT_BC5_SNORM, + PIXEL_FORMAT_B5G6R5_UNORM, + PIXEL_FORMAT_B5G6R5_UNORM, + PIXEL_FORMAT_B5G5R5A1_UNORM, + PIXEL_FORMAT_B5G5R5A1_UNORM, + PIXEL_FORMAT_B8G8R8A8_UNORM, + PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8X8_UNORM, + PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, + PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, + PIXEL_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, + PIXEL_FORMAT_B8G8R8A8_TYPELESS, + PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8A8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8X8_TYPELESS, + PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, + PIXEL_FORMAT_B8G8R8X8_UNORM_SRGB, + PIXEL_FORMAT_BC6H_TYPELESS, + PIXEL_FORMAT_BC6H_TYPELESS, + PIXEL_FORMAT_BC6H_UF16, + PIXEL_FORMAT_BC6H_UF16, + PIXEL_FORMAT_BC6H_SF16, + PIXEL_FORMAT_BC6H_SF16, + PIXEL_FORMAT_BC7_TYPELESS, + PIXEL_FORMAT_BC7_UNORM_SRGB, + PIXEL_FORMAT_BC7_UNORM, + PIXEL_FORMAT_BC7_UNORM_SRGB, + PIXEL_FORMAT_BC7_UNORM_SRGB, + PIXEL_FORMAT_BC7_UNORM_SRGB, + }; for( uint32_t i = 0; i < sizeof( formats ) / sizeof( formats[0] ); i += 2 ) { diff --git a/trinityal/tests/RenderContextCreation.cpp b/trinityal/tests/RenderContextCreation.cpp index 6dae46657..965df8968 100644 --- a/trinityal/tests/RenderContextCreation.cpp +++ b/trinityal/tests/RenderContextCreation.cpp @@ -4,7 +4,9 @@ #include "WithRenderContextFixture.h" #include -struct RenderContextCreation: public WithRenderContext {}; +struct RenderContextCreation : public WithRenderContext +{ +}; namespace { @@ -23,7 +25,7 @@ void SetUpPresentParameters( Tr2PresentParametersAL& presentParameters ) presentParameters.presentInterval = Tr2RenderContextEnum::PRESENT_INTERVAL_IMMEDIATE; } -struct RenderContextEvents: public ITr2RenderContextEvents +struct RenderContextEvents : public ITr2RenderContextEvents { RenderContextEvents() { @@ -59,62 +61,80 @@ TEST_F( RenderContextCreation, RenderContextStartsAsInvalid ) TEST_F( RenderContextCreation, CanCreateRenderContext ) { - if( !MachineHasGfxAdapter() ) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); - ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); } TEST_F( RenderContextCreation, RenderContextIsValidAfterCreation ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); - ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); - EXPECT_TRUE( renderContext->IsValid() ); + ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); + EXPECT_TRUE( renderContext->IsValid() ); } TEST_F( RenderContextCreation, RenderContextIsInvalidAfterDestroy ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); - ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); renderContext->Destroy(); - EXPECT_FALSE( renderContext->IsValid() ); + EXPECT_FALSE( renderContext->IsValid() ); } TEST_F( RenderContextCreation, CanChangeRenderContextPresentParameters ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); - ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); + ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->SetPresentParameters( 0, presentParameters ) ); } TEST_F( RenderContextCreation, CreateDeviceCallsEventsOnContextCreated ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); RenderContextEvents events; renderContext->m_events = &events; - ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); - EXPECT_EQ( 1, events.m_timesOnContextCreatedCalled ); + ASSERT_HRESULT_SUCCEEDED( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); + EXPECT_EQ( 1, events.m_timesOnContextCreatedCalled ); renderContext->m_events = nullptr; } TEST_F( RenderContextCreation, RenderContextBackBufferWithCorrectDimensionsAfterCreation ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); @@ -126,7 +146,10 @@ TEST_F( RenderContextCreation, RenderContextBackBufferWithCorrectDimensionsAfter TEST_F( RenderContextCreation, RenderContextBackBufferWithCorrectDimensionsAfterReset ) { - if (!MachineHasGfxAdapter()) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); @@ -141,7 +164,10 @@ TEST_F( RenderContextCreation, RenderContextBackBufferWithCorrectDimensionsAfter TEST_F( RenderContextCreation, RenderContextCanRecreateTheDevice ) { - if( !MachineHasGfxAdapter() ) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !MachineHasGfxAdapter() ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2PresentParametersAL presentParameters; SetUpPresentParameters( presentParameters ); diff --git a/trinityal/tests/RenderWindow.h b/trinityal/tests/RenderWindow.h index a0a86cd3c..37204e9bd 100644 --- a/trinityal/tests/RenderWindow.h +++ b/trinityal/tests/RenderWindow.h @@ -10,7 +10,7 @@ class RenderWindow RenderWindow( uint32_t width = 128, uint32_t height = 64 ); ~RenderWindow(); -#if !defined(__APPLE__) +#if !defined( __APPLE__ ) Tr2WindowHandle GetHandle() const { return m_handle; @@ -18,8 +18,8 @@ class RenderWindow #else Tr2WindowHandle GetHandle() const; #endif - - operator Tr2WindowHandle () const + + operator Tr2WindowHandle() const { return GetHandle(); } @@ -28,6 +28,7 @@ class RenderWindow uint32_t GetClientHeight() const; bool Resize( uint32_t width, uint32_t height ); + private: Tr2WindowHandle m_handle; }; diff --git a/trinityal/tests/RenderWindow_Macos.mm b/trinityal/tests/RenderWindow_Macos.mm index e373fc73e..8a4970a51 100644 --- a/trinityal/tests/RenderWindow_Macos.mm +++ b/trinityal/tests/RenderWindow_Macos.mm @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if defined(__APPLE__) && TRINITY_PLATFORM != TRINITY_STUB +#if defined( __APPLE__ ) && TRINITY_PLATFORM != TRINITY_STUB #include "RenderWindow.h" #import @@ -16,12 +16,12 @@ @implementation TrinityALTestWindow - (BOOL)canBecomeKeyWindow { - return YES; + return YES; } - (BOOL)canBecomeMainWindow { - return YES; + return YES; } @end @@ -31,34 +31,34 @@ @interface TrinityALTestContentView : NSView @implementation TrinityALTestContentView -- (CALayer *)makeBackingLayer +- (CALayer*)makeBackingLayer { - return [CAMetalLayer layer]; + return [CAMetalLayer layer]; } - (BOOL)wantsLayer { - return YES; + return YES; } - (BOOL)canBecomeKeyView { - return YES; + return YES; } - (BOOL)acceptsFirstResponder { - return YES; + return YES; } -- (void)keyDown:(NSEvent *)event +- (void)keyDown:(NSEvent*)event { - s_keyPressed = true; + s_keyPressed = true; } -- (void)mouseDown:(NSEvent *)event +- (void)mouseDown:(NSEvent*)event { - s_keyPressed = true; + s_keyPressed = true; } @end @@ -66,49 +66,50 @@ - (void)mouseDown:(NSEvent *)event RenderWindow::RenderWindow( uint32_t width, uint32_t height ) { - NSRect frame = NSMakeRect(0, 0, width, height); - TrinityALTestWindow* window = [[TrinityALTestWindow alloc] initWithContentRect:frame - styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable - backing:NSBackingStoreBuffered - defer:NO]; - - TrinityALTestContentView* view = [[TrinityALTestContentView alloc] init]; - [window setContentView:view]; - - // Explicitly set this to force creation of backing layer (makeBackingLayer) for our view. - // By default backing layer is created only when the window is shown, which is not - // the default behavior for TrinityALTest. - view.wantsLayer = YES; - - [window makeKeyAndOrderFront:nil]; - m_handle = window; + NSRect frame = NSMakeRect( 0, 0, width, height ); + TrinityALTestWindow* window = + [[TrinityALTestWindow alloc] initWithContentRect:frame + styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable + backing:NSBackingStoreBuffered + defer:NO]; + + TrinityALTestContentView* view = [[TrinityALTestContentView alloc] init]; + [window setContentView:view]; + + // Explicitly set this to force creation of backing layer (makeBackingLayer) for our view. + // By default backing layer is created only when the window is shown, which is not + // the default behavior for TrinityALTest. + view.wantsLayer = YES; + + [window makeKeyAndOrderFront:nil]; + m_handle = window; } RenderWindow::~RenderWindow() { - if( m_handle ) - { - [(TrinityALTestWindow*)m_handle close]; - } - m_handle = nullptr; + if( m_handle ) + { + [(TrinityALTestWindow*)m_handle close]; + } + m_handle = nullptr; } uint32_t RenderWindow::GetClientWidth() const { - auto size = [(TrinityALTestWindow*)m_handle contentView].frame.size; - return uint32_t( size.width ); + auto size = [(TrinityALTestWindow*)m_handle contentView].frame.size; + return uint32_t( size.width ); } uint32_t RenderWindow::GetClientHeight() const { - auto size = [(TrinityALTestWindow*)m_handle contentView].frame.size; - return uint32_t( size.height ); + auto size = [(TrinityALTestWindow*)m_handle contentView].frame.size; + return uint32_t( size.height ); } bool RenderWindow::Resize( uint32_t width, uint32_t height ) { - [(TrinityALTestWindow*)m_handle setContentSize:NSMakeSize( width, height )]; - return true; + [(TrinityALTestWindow*)m_handle setContentSize:NSMakeSize( width, height )]; + return true; } Tr2WindowHandle RenderWindow::GetHandle() const diff --git a/trinityal/tests/RenderWindow_Stub.cpp b/trinityal/tests/RenderWindow_Stub.cpp index eaa86aec7..24282f50a 100644 --- a/trinityal/tests/RenderWindow_Stub.cpp +++ b/trinityal/tests/RenderWindow_Stub.cpp @@ -1,13 +1,13 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if !defined(_WIN32) && !defined(TRINITY_AL_MOBILE) && (TRINITY_PLATFORM == TRINITY_STUB) +#if !defined( _WIN32 ) && !defined( TRINITY_AL_MOBILE ) && ( TRINITY_PLATFORM == TRINITY_STUB ) #include "RenderWindow.h" #include "WithWindowFixture.h" RenderWindow::RenderWindow( uint32_t width, uint32_t height ) { - m_handle = reinterpret_cast( ( width & 0xffff ) | ( ( height & 0xffff ) << 16 ) ); + m_handle = reinterpret_cast( ( width & 0xffff ) | ( ( height & 0xffff ) << 16 ) ); } RenderWindow::~RenderWindow() @@ -16,12 +16,12 @@ RenderWindow::~RenderWindow() uint32_t RenderWindow::GetClientWidth() const { - return reinterpret_cast( m_handle ) & 0xffff; + return reinterpret_cast( m_handle ) & 0xffff; } uint32_t RenderWindow::GetClientHeight() const { - return ( reinterpret_cast( m_handle ) >> 16 ) & 0xffff; + return ( reinterpret_cast( m_handle ) >> 16 ) & 0xffff; } bool RenderWindow::Resize( uint32_t width, uint32_t height ) diff --git a/trinityal/tests/RenderWindow_Win32.cpp b/trinityal/tests/RenderWindow_Win32.cpp index 880a3063c..3857f44f8 100644 --- a/trinityal/tests/RenderWindow_Win32.cpp +++ b/trinityal/tests/RenderWindow_Win32.cpp @@ -10,17 +10,17 @@ RenderWindow::RenderWindow( uint32_t width, uint32_t height ) static bool wndClassInitialized = false; if( !wndClassInitialized ) { - wndClass.style = CS_HREDRAW | CS_VREDRAW; - wndClass.lpfnWndProc = DefWindowProc; - wndClass.cbClsExtra = 0; - wndClass.cbWndExtra = 0; - wndClass.hInstance = GetModuleHandle( nullptr ); - wndClass.hIcon = nullptr; - wndClass.hCursor = nullptr; + wndClass.style = CS_HREDRAW | CS_VREDRAW; + wndClass.lpfnWndProc = DefWindowProc; + wndClass.cbClsExtra = 0; + wndClass.cbWndExtra = 0; + wndClass.hInstance = GetModuleHandle( nullptr ); + wndClass.hIcon = nullptr; + wndClass.hCursor = nullptr; wndClass.hbrBackground = nullptr; - wndClass.lpszMenuName = nullptr; + wndClass.lpszMenuName = nullptr; wndClass.lpszClassName = g_moduleName; - + RegisterClass( &wndClass ); wndClassInitialized = true; } @@ -31,14 +31,14 @@ RenderWindow::RenderWindow( uint32_t width, uint32_t height ) wndClass.lpszClassName, g_moduleName, style, - CW_USEDEFAULT, CW_USEDEFAULT, - rect.right - rect.left, + CW_USEDEFAULT, + rect.right - rect.left, rect.bottom - rect.top, 0L, NULL, wndClass.hInstance, - 0L); + 0L ); ::ShowWindow( m_handle, SW_SHOW ); } diff --git a/trinityal/tests/Rendering.cpp b/trinityal/tests/Rendering.cpp index abbb3755b..0d520b75e 100644 --- a/trinityal/tests/Rendering.cpp +++ b/trinityal/tests/Rendering.cpp @@ -5,7 +5,9 @@ using namespace Tr2RenderContextEnum; -struct Rendering: public WithValidRenderContext {}; +struct Rendering : public WithValidRenderContext +{ +}; namespace { @@ -45,8 +47,8 @@ ALResult CreateTexCoordAndPositionVS( Tr2ShaderAL& shader, Tr2PrimaryRenderConte }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ) - .Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); + .Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ) + .Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); return shader.Create( VERTEX_SHADER, bytecode, input, "", renderContext ); } @@ -58,8 +60,8 @@ ALResult CreateSampleTextureFromTexCoordPS( Tr2ShaderAL& shader, Tr2PrimaryRende }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) - .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); + .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) + .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); return shader.Create( PIXEL_SHADER, bytecode, input, "", renderContext ); } @@ -71,8 +73,8 @@ ALResult CreatePositionOnlyWithPerObjectDataVS( Tr2ShaderAL& shader, Tr2PrimaryR }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ) - .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); + .Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ) + .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); return shader.Create( VERTEX_SHADER, bytecode, input, "", renderContext ); } @@ -84,8 +86,8 @@ ALResult CreateInstancedRenderingVS( Tr2ShaderAL& shader, Tr2PrimaryRenderContex }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ) - .Add( Tr2VertexDefinition::POSITION, 8, 1, Tr2ShaderPipelineInputAL::FLOAT, 2 ); + .Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ) + .Add( Tr2VertexDefinition::POSITION, 8, 1, Tr2ShaderPipelineInputAL::FLOAT, 2 ); return shader.Create( VERTEX_SHADER, bytecode, input, "", renderContext ); } @@ -106,9 +108,9 @@ ALResult CreateSampleTextureMipFromTexCoordPS( Tr2ShaderAL& shader, Tr2PrimaryRe }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) - .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); + .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2D, 0 ) + .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); return shader.Create( PIXEL_SHADER, bytecode, input, "", renderContext ); } @@ -120,9 +122,9 @@ ALResult CreateSampleVolumeTexturePS( Tr2ShaderAL& shader, Tr2PrimaryRenderConte }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ) - .Add( Tr2ShaderRegisterAL::SRV_TEXTURE3D, 0 ) - .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); + .Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ) + .Add( Tr2ShaderRegisterAL::SRV_TEXTURE3D, 0 ) + .Add( Tr2ShaderRegisterAL::SAMPLER, 0 ); return shader.Create( PIXEL_SHADER, bytecode, input, "", renderContext ); } @@ -136,7 +138,7 @@ ALResult CreateWriteToUavPS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& ren }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 1 ); + .Add( Tr2ShaderRegisterAL::UAV_TEXTURE2D, 1 ); return shader.Create( PIXEL_SHADER, bytecode, input, "", renderContext ); } @@ -152,7 +154,7 @@ ALResult CreateLoadMsaaTexturePS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL }; auto input = Tr2ShaderSignatureAL() - .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2DMS, 0 ); + .Add( Tr2ShaderRegisterAL::SRV_TEXTURE2DMS, 0 ); return shader.Create( PIXEL_SHADER, bytecode, input, "", renderContext ); } @@ -190,9 +192,15 @@ TEST_F( Rendering, CanRenderASingleTriangle ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -242,10 +250,18 @@ TEST_F( Rendering, CanRenderTriangleStrip ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, - 0.5f, 0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -295,10 +311,18 @@ TEST_F( Rendering, CanRenderIndexedTriangles ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, - 0.5f, 0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -353,11 +377,11 @@ TEST_F( Rendering, CanReorderInputsToVertexShader ) }; auto vsInput = Tr2ShaderSignatureAL() - .Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ) - .Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); + .Add( Tr2VertexDefinition::TEXCOORD, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 2 ) + .Add( Tr2VertexDefinition::POSITION, 0, 1, Tr2ShaderPipelineInputAL::FLOAT, 3 ); Tr2ShaderAL vs; - ASSERT_HRESULT_SUCCEEDED( vs.Create( VERTEX_SHADER, vsBytecode, vsInput, "", *renderContext ) ); + ASSERT_HRESULT_SUCCEEDED( vs.Create( VERTEX_SHADER, vsBytecode, vsInput, "", *renderContext ) ); Tr2ShaderAL ps; ASSERT_HRESULT_SUCCEEDED( CreateOutputTexCoordPS( ps, *renderContext ) ); @@ -367,9 +391,21 @@ TEST_F( Rendering, CanReorderInputsToVertexShader ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -420,9 +456,21 @@ TEST_F( Rendering, CanSampleTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -436,10 +484,22 @@ TEST_F( Rendering, CanSampleTexture ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); uint32_t texturePixels0[] = { - 0xff00ff00, 0xff0000ff, 0xff00ff00, 0xff0000ff, - 0xffff0000, 0x00ffffff, 0xffff0000, 0x00ffffff, - 0xff00ff00, 0xff0000ff, 0xff00ff00, 0xff0000ff, - 0xffff0000, 0x00ffffff, 0xffff0000, 0x00ffffff, + 0xff00ff00, + 0xff0000ff, + 0xff00ff00, + 0xff0000ff, + 0xffff0000, + 0x00ffffff, + 0xffff0000, + 0x00ffffff, + 0xff00ff00, + 0xff0000ff, + 0xff00ff00, + 0xff0000ff, + 0xffff0000, + 0x00ffffff, + 0xffff0000, + 0x00ffffff, }; Tr2SubresourceData textureData[1]; textureData[0].m_sysMem = texturePixels0; @@ -450,8 +510,8 @@ TEST_F( Rendering, CanSampleTexture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( 4, 4, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -507,9 +567,21 @@ TEST_F( Rendering, CanSampleMipMappedTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -523,14 +595,28 @@ TEST_F( Rendering, CanSampleMipMappedTexture ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); uint32_t texturePixels0[] = { - 0xff00ff00, 0xff0000ff, 0xff00ff00, 0xff0000ff, - 0xffff0000, 0x00ffffff, 0xffff0000, 0x00ffffff, - 0xff00ff00, 0xff0000ff, 0xff00ff00, 0xff0000ff, - 0xffff0000, 0x00ffffff, 0xffff0000, 0x00ffffff, + 0xff00ff00, + 0xff0000ff, + 0xff00ff00, + 0xff0000ff, + 0xffff0000, + 0x00ffffff, + 0xffff0000, + 0x00ffffff, + 0xff00ff00, + 0xff0000ff, + 0xff00ff00, + 0xff0000ff, + 0xffff0000, + 0x00ffffff, + 0xffff0000, + 0x00ffffff, }; uint32_t texturePixels1[] = { - 0xff00ff00, 0xff0000ff, - 0xffff0000, 0x00ffffff, + 0xff00ff00, + 0xff0000ff, + 0xffff0000, + 0x00ffffff, }; uint32_t texturePixels2[] = { 0xff00ff00, @@ -552,10 +638,9 @@ TEST_F( Rendering, CanSampleMipMappedTexture ) uint32_t g = 127; auto frame = [&] { - Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TA_WRAP, 1, @@ -608,9 +693,15 @@ TEST_F( Rendering, CanPassConstantBufferToRendering ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -672,10 +763,18 @@ TEST_F( Rendering, CanDoInstancedRendering ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.25f, -0.25f, 0.0f, - -0.25f, 0.25f, 0.0f, - 0.25f, -0.25f, 0.0f, - 0.25f, 0.25f, 0.0f, + -0.25f, + -0.25f, + 0.0f, + -0.25f, + 0.25f, + 0.0f, + 0.25f, + -0.25f, + 0.0f, + 0.25f, + 0.25f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -686,8 +785,10 @@ TEST_F( Rendering, CanDoInstancedRendering ) ASSERT_HRESULT_SUCCEEDED( ib.Create( Tr2RenderContextEnum::PIXEL_FORMAT_R16_UINT, sizeof( indices ) / sizeof( indices[0] ), Tr2GpuUsage::INDEX_BUFFER, Tr2CpuUsage::NONE, indices, *renderContext ) ); float instances[] = { - -0.5f, 0.2f, - 0.5f, -0.2f, + -0.5f, + 0.2f, + 0.5f, + -0.2f, }; const uint32_t instanceVbStride = 2 * sizeof( float ); Tr2BufferAL instanceVb; @@ -741,13 +842,37 @@ TEST_F( Rendering, CanClearRenderTarget ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 1.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -761,8 +886,8 @@ TEST_F( Rendering, CanClearRenderTarget ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -784,7 +909,6 @@ TEST_F( Rendering, CanClearRenderTarget ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); @@ -837,13 +961,37 @@ TEST_F( Rendering, CanRenderToRenderTarget ) ASSERT_HRESULT_SUCCEEDED( spFill.Create( shadersFill, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -857,8 +1005,8 @@ TEST_F( Rendering, CanRenderToRenderTarget ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -880,7 +1028,6 @@ TEST_F( Rendering, CanRenderToRenderTarget ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); @@ -943,13 +1090,37 @@ TEST_F( Rendering, CanRenderToMsaaRenderTarget ) ASSERT_HRESULT_SUCCEEDED( spFill.Create( shadersFill, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -963,8 +1134,8 @@ TEST_F( Rendering, CanRenderToMsaaRenderTarget ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -989,7 +1160,6 @@ TEST_F( Rendering, CanRenderToMsaaRenderTarget ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); @@ -1048,9 +1218,15 @@ TEST_F( Rendering, CanClearDepthBuffer ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 1.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -1110,13 +1286,37 @@ TEST_F( Rendering, CanRenderIntoDepthBuffer ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 0.0f, - 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, - -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, + -0.5f, + 0.5f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.5f, + 1.0f, + 1.0f, + -0.5f, + -0.5f, + 0.5f, + 1.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -1184,26 +1384,74 @@ TEST_F( Rendering, CanSampleDepthBuffer ) ASSERT_HRESULT_SUCCEEDED( sp2.Create( shaders2, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 0.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 0.0f, - 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, - -0.5f, -0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, + -0.5f, + 0.5f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.5f, + 1.0f, + 1.0f, + -0.5f, + -0.5f, + 0.5f, + 1.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; ASSERT_HRESULT_SUCCEEDED( vb.Create( vbStride, sizeof( vertices ) / vbStride, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, vertices, *renderContext ) ); float quad[] = { - 0, 0, 0, 0, 1, - 0, 1, 0, 0, 0, - 1, 0, 0, 1, 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, - 1, 0, 0, 1, 1, - 0, 1, 0, 0, 0, - 1, 1, 0, 1, 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, }; Tr2BufferAL quadVb; ASSERT_HRESULT_SUCCEEDED( quadVb.Create( vbStride, sizeof( quad ) / vbStride, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, quad, *renderContext ) ); @@ -1228,9 +1476,9 @@ TEST_F( Rendering, CanSampleDepthBuffer ) auto backBuffer = renderContext->GetDefaultBackBuffer(); Tr2TextureAL depthBuffer; - ASSERT_HRESULT_SUCCEEDED( depthBuffer.Create( - Tr2BitmapDimensions( backBuffer.GetWidth(), backBuffer.GetHeight(), 1, Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT ), - Tr2GpuUsage::DEPTH_STENCIL | Tr2GpuUsage::SHADER_RESOURCE, + ASSERT_HRESULT_SUCCEEDED( depthBuffer.Create( + Tr2BitmapDimensions( backBuffer.GetWidth(), backBuffer.GetHeight(), 1, Tr2RenderContextEnum::PIXEL_FORMAT_D24_UNORM_S8_UINT ), + Tr2GpuUsage::DEPTH_STENCIL | Tr2GpuUsage::SHADER_RESOURCE, *renderContext ) ); Tr2ResourceSetDescriptionAL resourceSetDescription( sp2 ); @@ -1299,9 +1547,15 @@ TEST_F( Rendering, CanRenderASingleTriangleWithDrawPrimitiveUP ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; Tr2VertexDefinition definition; @@ -1347,10 +1601,18 @@ TEST_F( Rendering, CanRenderIndexedTrianglesWith16BitDrawIndexedPrimitiveUP ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, - 0.5f, 0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, }; uint16_t indices[] = { 0, 1, 2, 1, 2, 3 }; @@ -1398,10 +1660,18 @@ TEST_F( Rendering, CanRenderIndexedTrianglesWith32BitDrawIndexedPrimitiveUP ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, - 0.5f, 0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, }; uint32_t indices[] = { 0, 1, 2, 1, 2, 3 }; @@ -1449,14 +1719,26 @@ TEST_F( Rendering, CanUseOcclusionQueries ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; float verticesBg[] = { - -0.5f, -0.5f, 0.5f, - -0.5f, 0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, + -0.5f, + -0.5f, + 0.5f, + -0.5f, + 0.5f, + 0.5f, + 0.5f, + -0.5f, + 0.5f, }; const uint32_t vbStride = 3 * sizeof( float ); @@ -1519,7 +1801,7 @@ TEST_F( Rendering, CanUseOcclusionQueries ) ASSERT_HRESULT_SUCCEEDED( cb.Unlock( *renderContext ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->SetConstants( cb, Tr2RenderContextEnum::VERTEX_SHADER, 0 ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->SetStreamSource( 0, vbBg, 0, vbStride ) ); - + if( issueQueries ) { ASSERT_HRESULT_SUCCEEDED( queryOccluded.Begin( *renderContext ) ); @@ -1579,9 +1861,15 @@ TEST_F( Rendering, CanUseViewport ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; Tr2VertexDefinition definition; @@ -1595,8 +1883,10 @@ TEST_F( Rendering, CanUseViewport ) Tr2Viewport viewport( 250, 250 ); uint32_t renderStates[] = { - Tr2RenderContextEnum::RS_ZENABLE, 0, - Tr2RenderContextEnum::RS_CULLMODE, Tr2RenderContextEnum::CULLMODE_NONE, + Tr2RenderContextEnum::RS_ZENABLE, + 0, + Tr2RenderContextEnum::RS_CULLMODE, + Tr2RenderContextEnum::CULLMODE_NONE, }; Tr2Viewport bkViewport; @@ -1638,10 +1928,26 @@ TEST_F( Rendering, CanPerformAlphaBlend ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -1679,8 +1985,8 @@ TEST_F( Rendering, CanPerformAlphaBlend ) float border[4] = { 0 }; Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TF_POINT, @@ -1757,13 +2063,37 @@ TEST_F( Rendering, CanGenerateRenderTargetMips ) ASSERT_HRESULT_SUCCEEDED( spFill.Create( shadersFill, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -1771,10 +2101,27 @@ TEST_F( Rendering, CanGenerateRenderTargetMips ) Tr2BufferAL quads[8]; float quadVertices[] = { - -0.85f, -0.1f, 0.0f, 0.0f, 1.0f, - -0.85f, 0.1f, 0.0f, 0.0f, 0.0f, - -0.65f, -0.1f, 0.0f, 1.0f, 1.0f, - -0.65f, 0.1f, 0.0f, 1.0f, 0.0f, }; + -0.85f, + -0.1f, + 0.0f, + 0.0f, + 1.0f, + -0.85f, + 0.1f, + 0.0f, + 0.0f, + 0.0f, + -0.65f, + -0.1f, + 0.0f, + 1.0f, + 1.0f, + -0.65f, + 0.1f, + 0.0f, + 1.0f, + 0.0f, + }; for( uint32_t i = 0; i < 8; ++i ) { @@ -1797,7 +2144,7 @@ TEST_F( Rendering, CanGenerateRenderTargetMips ) float border[4] = { 0 }; Tr2SamplerStateAL sampler; - Tr2SamplerDescription samplerDesc( + Tr2SamplerDescription samplerDesc( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TF_POINT, @@ -1824,7 +2171,6 @@ TEST_F( Rendering, CanGenerateRenderTargetMips ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); @@ -1899,13 +2245,37 @@ TEST_F( Rendering, CanCopyRenderTargetRegion ) ASSERT_HRESULT_SUCCEEDED( spFill.Create( shadersFill, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -1919,8 +2289,8 @@ TEST_F( Rendering, CanCopyRenderTargetRegion ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -1945,7 +2315,6 @@ TEST_F( Rendering, CanCopyRenderTargetRegion ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 16 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); @@ -2011,10 +2380,26 @@ TEST_F( Rendering, CanSampleBc1Texture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2042,8 +2427,8 @@ TEST_F( Rendering, CanSampleBc1Texture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( width, height, 1, Tr2RenderContextEnum::PIXEL_FORMAT_BC1_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2101,9 +2486,15 @@ TEST_F( Rendering, CanPassDynamicConstantBufferToRendering ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -2165,10 +2556,26 @@ TEST_F( Rendering, CanSampleBc2Texture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2196,8 +2603,8 @@ TEST_F( Rendering, CanSampleBc2Texture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( width, height, 1, Tr2RenderContextEnum::PIXEL_FORMAT_BC2_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2256,10 +2663,26 @@ TEST_F( Rendering, CanSampleBc3Texture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2287,8 +2710,8 @@ TEST_F( Rendering, CanSampleBc3Texture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( width, height, 1, Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2347,10 +2770,26 @@ TEST_F( Rendering, CanSampleVolumeTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2379,8 +2818,8 @@ TEST_F( Rendering, CanSampleVolumeTexture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( Tr2RenderContextEnum::TEX_TYPE_3D, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8X8_UNORM, width, height, depth, 1 ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2450,10 +2889,26 @@ TEST_F( Rendering, CanSampleBc3VolumeTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2482,8 +2937,8 @@ TEST_F( Rendering, CanSampleBc3VolumeTexture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( Tr2RenderContextEnum::TEX_TYPE_3D, Tr2RenderContextEnum::PIXEL_FORMAT_BC3_UNORM, width, height, depth, 1 ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_LINEAR, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2552,10 +3007,26 @@ TEST_F( Rendering, CanSampleUnassignedTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2609,10 +3080,26 @@ TEST_F( Rendering, CanLockTextureTwice ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices1[] = { - -0.75f, -0.25f, 0.0f, 1.0f, 1.0f, - -0.75f, 0.25f, 0.0f, 1.0f, 0.0f, - -0.25f, -0.25f, 0.0f, 0.0f, 1.0f, - -0.25f, 0.25f, 0.0f, 0.0f, 0.0f, + -0.75f, + -0.25f, + 0.0f, + 1.0f, + 1.0f, + -0.75f, + 0.25f, + 0.0f, + 1.0f, + 0.0f, + -0.25f, + -0.25f, + 0.0f, + 0.0f, + 1.0f, + -0.25f, + 0.25f, + 0.0f, + 0.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb1; @@ -2620,10 +3107,26 @@ TEST_F( Rendering, CanLockTextureTwice ) float vertices2[] = { - 0.25f, -0.25f, 0.0f, 1.0f, 1.0f, - 0.25f, 0.25f, 0.0f, 1.0f, 0.0f, - 0.75f, -0.25f, 0.0f, 0.0f, 1.0f, - 0.75f, 0.25f, 0.0f, 0.0f, 0.0f, + 0.25f, + -0.25f, + 0.0f, + 1.0f, + 1.0f, + 0.25f, + 0.25f, + 0.0f, + 1.0f, + 0.0f, + 0.75f, + -0.25f, + 0.0f, + 0.0f, + 1.0f, + 0.75f, + 0.25f, + 0.0f, + 0.0f, + 0.0f, }; Tr2BufferAL vb2; ASSERT_HRESULT_SUCCEEDED( vb2.Create( vbStride, sizeof( vertices2 ) / vbStride, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, vertices2, *renderContext ) ); @@ -2638,7 +3141,7 @@ TEST_F( Rendering, CanLockTextureTwice ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); uint32_t texturePixels0[] = { - 0xff00ff00, + 0xff00ff00, }; Tr2SubresourceData textureData[1]; textureData[0].m_sysMem = texturePixels0; @@ -2649,8 +3152,8 @@ TEST_F( Rendering, CanLockTextureTwice ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( 1, 1, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, Tr2CpuUsage::WRITE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2723,10 +3226,26 @@ TEST_F( Rendering, CanSampleSrgbTexture ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2740,10 +3259,22 @@ TEST_F( Rendering, CanSampleSrgbTexture ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); uint32_t texturePixels0[] = { - 0xffffffff, 0xff7f7f7f, 0xff7f7f7f, 0xffffffff, - 0xff000000, 0xff7f7f7f, 0xff7f7f7f, 0xff000000, - 0xffffffff, 0xff7f7f7f, 0xff7f7f7f, 0xffffffff, - 0xff000000, 0xff7f7f7f, 0xff7f7f7f, 0xff000000, + 0xffffffff, + 0xff7f7f7f, + 0xff7f7f7f, + 0xffffffff, + 0xff000000, + 0xff7f7f7f, + 0xff7f7f7f, + 0xff000000, + 0xffffffff, + 0xff7f7f7f, + 0xff7f7f7f, + 0xffffffff, + 0xff000000, + 0xff7f7f7f, + 0xff7f7f7f, + 0xff000000, }; Tr2SubresourceData textureData[1]; textureData[0].m_sysMem = texturePixels0; @@ -2754,8 +3285,8 @@ TEST_F( Rendering, CanSampleSrgbTexture ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( 4, 4, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2811,10 +3342,26 @@ TEST_F( Rendering, CanOutputToSrgbTarget ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + 0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2828,10 +3375,22 @@ TEST_F( Rendering, CanOutputToSrgbTarget ) ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); uint32_t texturePixels0[] = { - 0xffffffff, 0xff7f7f7f, 0xff7f7f7f, 0xffffffff, - 0xff000000, 0xff7f7f7f, 0xff7f7f7f, 0xff000000, - 0xffffffff, 0xff7f7f7f, 0xff7f7f7f, 0xffffffff, - 0xff000000, 0xff7f7f7f, 0xff7f7f7f, 0xff000000, + 0xffffffff, + 0xff7f7f7f, + 0xff7f7f7f, + 0xffffffff, + 0xff000000, + 0xff7f7f7f, + 0xff7f7f7f, + 0xff000000, + 0xffffffff, + 0xff7f7f7f, + 0xff7f7f7f, + 0xffffffff, + 0xff000000, + 0xff7f7f7f, + 0xff7f7f7f, + 0xff000000, }; Tr2SubresourceData textureData[1]; textureData[0].m_sysMem = texturePixels0; @@ -2842,8 +3401,8 @@ TEST_F( Rendering, CanOutputToSrgbTarget ) ASSERT_HRESULT_SUCCEEDED( tex.Create( Tr2BitmapDimensions( 4, 4, 1, Tr2RenderContextEnum::PIXEL_FORMAT_B8G8R8A8_UNORM ), Tr2GpuUsage::SHADER_RESOURCE, textureData, *renderContext ) ); Tr2SamplerStateAL sampl; - ASSERT_HRESULT_SUCCEEDED( sampl.Create( - Tr2SamplerDescription( + ASSERT_HRESULT_SUCCEEDED( sampl.Create( + Tr2SamplerDescription( Tr2RenderContextEnum::TF_POINT, Tr2RenderContextEnum::TA_WRAP, 1, @@ -2904,9 +3463,21 @@ TEST_F( Rendering, CanUsePsUavs ) float vertices[] = { - -0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -2931,13 +3502,37 @@ TEST_F( Rendering, CanUsePsUavs ) float quad[] = { - 0, 0, 0, 0, 1, - 0, 1, 0, 0, 0, - 1, 0, 0, 1, 1, + 0, + 0, + 0, + 0, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 1, - 1, 0, 0, 1, 1, - 0, 1, 0, 0, 0, - 1, 1, 0, 1, 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 1, + 1, + 0, + 1, + 0, }; Tr2BufferAL quadVb; ASSERT_HRESULT_SUCCEEDED( quadVb.Create( vbStride, sizeof( quad ) / vbStride, Tr2GpuUsage::VERTEX_BUFFER, Tr2CpuUsage::NONE, quad, *renderContext ) ); @@ -3002,7 +3597,6 @@ TEST_F( Rendering, CanUsePsUavs ) ASSERT_HRESULT_SUCCEEDED( renderContext->SetStreamSource( 0, Tr2BufferAL(), 0, 0 ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->SetShaderProgram( Tr2ShaderProgramAL() ) ); - } @@ -3020,9 +3614,15 @@ TEST_F( Rendering, CanDrawIndirect ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -3034,7 +3634,7 @@ TEST_F( Rendering, CanDrawIndirect ) Tr2VertexLayoutAL vertexLayout; ASSERT_HRESULT_SUCCEEDED( vertexLayout.Create( definition, *renderContext ) ); - struct + struct { uint32_t vertexCountPerInstance; uint32_t instanceCount; @@ -3086,9 +3686,15 @@ TEST_F( Rendering, CanWriteToVB ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -3145,9 +3751,15 @@ TEST_F( Rendering, CanWriteToDynamicVB ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -3204,9 +3816,15 @@ TEST_F( Rendering, CanWriteToDynamicVBWithoutSynchronization ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); @@ -3276,9 +3894,15 @@ TEST_F( Rendering, CanHaveMissingIAElements ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -3337,13 +3961,37 @@ TEST_F( Rendering, CanLoadMsaaRenderTarget ) ASSERT_HRESULT_SUCCEEDED( spFill.Create( shadersFill, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, + -0.5f, + -0.5f, + 0.0f, + 0.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, - 0.5f, -0.5f, 0.0f, 1.0f, 1.0f, - -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, - 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, + -0.5f, + 0.0f, + 1.0f, + 1.0f, + -0.5f, + 0.5f, + 0.0f, + 0.0f, + 0.0f, + 0.5f, + 0.5f, + 0.0f, + 1.0f, + 0.0f, }; const uint32_t vbStride = 5 * sizeof( float ); Tr2BufferAL vb; @@ -3379,7 +4027,6 @@ TEST_F( Rendering, CanLoadMsaaRenderTarget ) uint32_t g = 127; auto frame = [&] { - ASSERT_HRESULT_SUCCEEDED( renderContext->BeginScene() ); ASSERT_HRESULT_SUCCEEDED( renderContext->Clear( Tr2RenderContextEnum::CLEARFLAGS_TARGET, 0xff000000 | ( ( g & 0xff ) << 8 ), 1.0f ) ); ASSERT_HRESULT_SUCCEEDED( renderContext->PushRenderTarget() ); diff --git a/trinityal/tests/Shader.cpp b/trinityal/tests/Shader.cpp index 1169b1e32..624385ed8 100644 --- a/trinityal/tests/Shader.cpp +++ b/trinityal/tests/Shader.cpp @@ -6,7 +6,9 @@ using namespace Tr2RenderContextEnum; -struct Shader : public WithValidRenderContext {}; +struct Shader : public WithValidRenderContext +{ +}; TEST_F( Shader, ShaderIsInvalidBeforeCreation ) { @@ -24,7 +26,7 @@ TEST_F( Shader, CanCreateShader ) auto vsInput = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ); Tr2ShaderAL vs; - ASSERT_HRESULT_SUCCEEDED( vs.Create( + ASSERT_HRESULT_SUCCEEDED( vs.Create( Tr2RenderContextEnum::VERTEX_SHADER, vsBytecode, vsInput, @@ -50,7 +52,7 @@ TEST_F( Shader, ShaderEqualsItself ) auto vsInput = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ); Tr2ShaderAL vs; - ASSERT_HRESULT_SUCCEEDED( vs.Create( + ASSERT_HRESULT_SUCCEEDED( vs.Create( Tr2RenderContextEnum::VERTEX_SHADER, vsBytecode, vsInput, @@ -70,7 +72,7 @@ TEST_F( Shader, DifferentShadersAreNotEqual ) auto vsInput = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ); Tr2ShaderAL vs1; - ASSERT_HRESULT_SUCCEEDED( vs1.Create( + ASSERT_HRESULT_SUCCEEDED( vs1.Create( Tr2RenderContextEnum::VERTEX_SHADER, vsBytecode1, vsInput, @@ -83,17 +85,17 @@ TEST_F( Shader, DifferentShadersAreNotEqual ) auto vsInput2 = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ).Add( Tr2ShaderRegisterAL::CONSTANT_BUFFER, 0 ); Tr2ShaderAL vs2; - ASSERT_HRESULT_SUCCEEDED( vs2.Create( + ASSERT_HRESULT_SUCCEEDED( vs2.Create( Tr2RenderContextEnum::VERTEX_SHADER, vsBytecode2, vsInput2, - "", + "", *renderContext ) ); EXPECT_FALSE( vs1 == vs2 ); } -#if( TRINITYPLATFORM == TRINITY_STUB ) +#if ( TRINITYPLATFORM == TRINITY_STUB ) TEST_F( Shader, ShaderStoresType ) { uint8_t vsBytecode[] = { @@ -103,7 +105,7 @@ TEST_F( Shader, ShaderStoresType ) auto vsInput = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0 ); Tr2ShaderAL vs; - ASSERT_HRESULT_SUCCEEDED( vs.Create( + ASSERT_HRESULT_SUCCEEDED( vs.Create( Tr2RenderContextEnum::HULL_SHADER, vsBytecode, vsInput, @@ -111,6 +113,6 @@ TEST_F( Shader, ShaderStoresType ) Tr2RenderContextEnum::ShaderType expected = Tr2RenderContextEnum::HULL_SHADER; int actual = vs.GetType(); - EXPECT_EQ( expected, actual ); + EXPECT_EQ( expected, actual ); } #endif diff --git a/trinityal/tests/Shaders.metal/MetalDefines.h b/trinityal/tests/Shaders.metal/MetalDefines.h index 6d82c7221..bcad5b985 100644 --- a/trinityal/tests/Shaders.metal/MetalDefines.h +++ b/trinityal/tests/Shaders.metal/MetalDefines.h @@ -7,56 +7,56 @@ // These values must be synchronized with defines in TrinityAL/metal/MetalWorkQueue.h // buffers -#define CBUFFER(i) buffer(4 + i) -#define SRV(i) buffer(4 + i) -#define UAV(i) buffer(24 + i) +#define CBUFFER( i ) buffer( 4 + i ) +#define SRV( i ) buffer( 4 + i ) +#define UAV( i ) buffer( 24 + i ) // textures -#define UAVT(i) texture(24 + i) +#define UAVT( i ) texture( 24 + i ) struct RayDesc { - float3 Origin; - float3 Direction; - float TMin; - float TMax; + float3 Origin; + float3 Direction; + float TMin; + float TMax; }; -#define RAY_FLAG_NONE 0x00 -#define RAY_FLAG_FORCE_OPAQUE 0x01 -#define RAY_FLAG_FORCE_NON_OPAQUE 0x02 +#define RAY_FLAG_NONE 0x00 +#define RAY_FLAG_FORCE_OPAQUE 0x01 +#define RAY_FLAG_FORCE_NON_OPAQUE 0x02 #define RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH 0x04 -#define RAY_FLAG_SKIP_CLOSEST_HIT_SHADER 0x08 -#define RAY_FLAG_CULL_BACK_FACING_TRIANGLES 0x10 -#define RAY_FLAG_CULL_FRONT_FACING_TRIANGLES 0x20 -#define RAY_FLAG_CULL_OPAQUE 0x40 -#define RAY_FLAG_CULL_NON_OPAQUE 0x80 -#define RAY_FLAG_SKIP_TRIANGLES 0x100 -#define RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES 0x200 +#define RAY_FLAG_SKIP_CLOSEST_HIT_SHADER 0x08 +#define RAY_FLAG_CULL_BACK_FACING_TRIANGLES 0x10 +#define RAY_FLAG_CULL_FRONT_FACING_TRIANGLES 0x20 +#define RAY_FLAG_CULL_OPAQUE 0x40 +#define RAY_FLAG_CULL_NON_OPAQUE 0x80 +#define RAY_FLAG_SKIP_TRIANGLES 0x100 +#define RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES 0x200 struct __MetalHitSV { - uint instance_id; - float3 origin; - float3 direction; - float min_distance; - float distance; - float2 barycentric_coord; + uint instance_id; + float3 origin; + float3 direction; + float min_distance; + float distance; + float2 barycentric_coord; }; #define __INTERSECION_TAGS metal::raytracing::instancing, metal::raytracing::triangle_data, metal::raytracing::world_space_data struct __RtLocalMaterial { - device void* buffer; + device void* buffer; }; struct RaytracingAccelerationStructureT { - metal::raytracing::instance_acceleration_structure tlas; + metal::raytracing::instance_acceleration_structure tlas; }; #define RaytracingAccelerationStructure const RaytracingAccelerationStructureT* @@ -64,90 +64,89 @@ struct RaytracingAccelerationStructureT template struct ShaderTableT { - metal::raytracing::intersection_function_table<__INTERSECION_TAGS> intersectionTable; - metal::visible_function_table&)> missShaderTable; - metal::visible_function_table&)> hitShaderTable; - device __RtLocalMaterial* missMaterials; - device __RtLocalMaterial* hitMaterials; - constant global_input_t& globalInput; + metal::raytracing::intersection_function_table<__INTERSECION_TAGS> intersectionTable; + metal::visible_function_table& )> missShaderTable; + metal::visible_function_table& )> hitShaderTable; + device __RtLocalMaterial* missMaterials; + device __RtLocalMaterial* hitMaterials; + constant global_input_t& globalInput; }; template void __GetLocalRTBufferT( device __RtLocalMaterial* materials, uint index, thread T& dest ) { - dest = ((device T*)materials[index].buffer)[0]; + dest = ( (device T*)materials[index].buffer )[0]; } -#define __GetLocalRTBuffer(index, dest) __GetLocalRTBufferT(__rtMaterials, index, dest) +#define __GetLocalRTBuffer( index, dest ) __GetLocalRTBufferT( __rtMaterials, index, dest ) template void __TraceRay( - device RaytracingAccelerationStructure accelerationStructure, - uint rayFlags, - uint instanceInclusionMask, - uint rayContributionToHitGroupIndex, - uint multiplierForGeometryContributionToHitGroupIndex, - uint missShaderIndex, - RayDesc ray_, - thread payload_t& payload, - - constant ShaderTableT& shaderTable, - constant global_input_t& globalInput ) + device RaytracingAccelerationStructure accelerationStructure, + uint rayFlags, + uint instanceInclusionMask, + uint rayContributionToHitGroupIndex, + uint multiplierForGeometryContributionToHitGroupIndex, + uint missShaderIndex, + RayDesc ray_, + thread payload_t& payload, + + constant ShaderTableT& shaderTable, + constant global_input_t& globalInput ) { - metal::raytracing::intersector<__INTERSECION_TAGS> i; - i.assume_geometry_type(metal::raytracing::geometry_type::triangle); - i.accept_any_intersection(rayFlags & RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH); - - metal::raytracing::ray r; - r.origin = ray_.Origin; - r.direction = ray_.Direction; - r.min_distance = ray_.TMin; - r.max_distance = ray_.TMax; - - typename metal::raytracing::intersector<__INTERSECION_TAGS>::result_type intersection = i.intersect(r, accelerationStructure[0].tlas, instanceInclusionMask, shaderTable.intersectionTable, payload); - - __MetalHitSV hit; - - if (intersection.type == metal::raytracing::intersection_type::none) - { - hit.instance_id = 0; - hit.origin = r.origin; - hit.direction = r.direction; - hit.min_distance = r.min_distance; - hit.distance = r.max_distance; - hit.barycentric_coord = { 0.0, 0.0 }; - - shaderTable.missShaderTable[missShaderIndex](payload, hit, shaderTable.missMaterials + 8 * missShaderIndex, globalInput, shaderTable); - } - else if( ( rayFlags & RAY_FLAG_SKIP_CLOSEST_HIT_SHADER ) == 0 ) - { - hit.instance_id = intersection.instance_id; - hit.origin = intersection.world_to_object_transform * float4( r.origin, 1.0 ); - hit.direction = intersection.world_to_object_transform * float4( r.direction, 0.0 ); - hit.min_distance = r.min_distance; - hit.distance = intersection.distance; - hit.barycentric_coord = intersection.triangle_barycentric_coord; - - uint offset = ((device uint*)accelerationStructure)[2 + intersection.instance_id]; - - shaderTable.hitShaderTable[intersection.instance_id](payload, hit, shaderTable.hitMaterials + 8 * offset, globalInput, shaderTable); - } + metal::raytracing::intersector<__INTERSECION_TAGS> i; + i.assume_geometry_type( metal::raytracing::geometry_type::triangle ); + i.accept_any_intersection( rayFlags & RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH ); + + metal::raytracing::ray r; + r.origin = ray_.Origin; + r.direction = ray_.Direction; + r.min_distance = ray_.TMin; + r.max_distance = ray_.TMax; + + typename metal::raytracing::intersector<__INTERSECION_TAGS>::result_type intersection = i.intersect( r, accelerationStructure[0].tlas, instanceInclusionMask, shaderTable.intersectionTable, payload ); + + __MetalHitSV hit; + + if( intersection.type == metal::raytracing::intersection_type::none ) + { + hit.instance_id = 0; + hit.origin = r.origin; + hit.direction = r.direction; + hit.min_distance = r.min_distance; + hit.distance = r.max_distance; + hit.barycentric_coord = { 0.0, 0.0 }; + + shaderTable.missShaderTable[missShaderIndex]( payload, hit, shaderTable.missMaterials + 8 * missShaderIndex, globalInput, shaderTable ); + } + else if( ( rayFlags & RAY_FLAG_SKIP_CLOSEST_HIT_SHADER ) == 0 ) + { + hit.instance_id = intersection.instance_id; + hit.origin = intersection.world_to_object_transform * float4( r.origin, 1.0 ); + hit.direction = intersection.world_to_object_transform * float4( r.direction, 0.0 ); + hit.min_distance = r.min_distance; + hit.distance = intersection.distance; + hit.barycentric_coord = intersection.triangle_barycentric_coord; + + uint offset = ( (device uint*)accelerationStructure )[2 + intersection.instance_id]; + + shaderTable.hitShaderTable[intersection.instance_id]( payload, hit, shaderTable.hitMaterials + 8 * offset, globalInput, shaderTable ); + } } -#define TraceRay(accelerationStructure, rayFlags, instanceInclusionMask, rayContributionToHitGroupIndex, multiplierForGeometryContributionToHitGroupIndex, missShaderIndex, ray, payload) \ - __TraceRay(accelerationStructure, rayFlags, instanceInclusionMask, rayContributionToHitGroupIndex, multiplierForGeometryContributionToHitGroupIndex, missShaderIndex, ray, payload, __rtShaderTable, __rtGlobals ) +#define TraceRay( accelerationStructure, rayFlags, instanceInclusionMask, rayContributionToHitGroupIndex, multiplierForGeometryContributionToHitGroupIndex, missShaderIndex, ray, payload ) \ + __TraceRay( accelerationStructure, rayFlags, instanceInclusionMask, rayContributionToHitGroupIndex, multiplierForGeometryContributionToHitGroupIndex, missShaderIndex, ray, payload, __rtShaderTable, __rtGlobals ) -#define DispatchRaysIndex() (__dispatchRaysIndex) -#define DispatchRaysDimensions() (__dispatchRaysDimensions) +#define DispatchRaysIndex() ( __dispatchRaysIndex ) +#define DispatchRaysDimensions() ( __dispatchRaysDimensions ) -#define InstanceID() (__metalHitSV.instance_id) -#define ObjectRayOrigin() (__metalHitSV.origin) -#define ObjectRayDirection() (__metalHitSV.direction) -#define RayTMin() (__metalHitSV.min_distance) -#define RayTCurrent() (__metalHitSV.distance) +#define InstanceID() ( __metalHitSV.instance_id ) +#define ObjectRayOrigin() ( __metalHitSV.origin ) +#define ObjectRayDirection() ( __metalHitSV.direction ) +#define RayTMin() ( __metalHitSV.min_distance ) +#define RayTCurrent() ( __metalHitSV.distance ) #define IgnoreHit() return false - diff --git a/trinityal/tests/StdAfx.h b/trinityal/tests/StdAfx.h index 97d1cbdab..fed14fbec 100644 --- a/trinityal/tests/StdAfx.h +++ b/trinityal/tests/StdAfx.h @@ -13,7 +13,7 @@ #include typedef HWND Tr2WindowHandle; -#elif defined(__APPLE__) +#elif defined( __APPLE__ ) #include typedef id Tr2WindowHandle; #else @@ -23,19 +23,21 @@ typedef uintptr_t Tr2WindowHandle; #include -#if( TRINITY_PLATFORM==TRINITY_DIRECTX11 ) +#if ( TRINITY_PLATFORM == TRINITY_DIRECTX11 ) #define SHADER_PATH Shaders.DX11 -#elif( TRINITY_PLATFORM==TRINITY_STUB ) +#elif ( TRINITY_PLATFORM == TRINITY_STUB ) #define SHADER_PATH Shaders.DX11 -#elif( TRINITY_PLATFORM==TRINITY_DIRECTX12 ) +#elif ( TRINITY_PLATFORM == TRINITY_DIRECTX12 ) #define SHADER_PATH Shaders.DX12 -#elif( TRINITY_PLATFORM==TRINITY_METAL ) +#elif ( TRINITY_PLATFORM == TRINITY_METAL ) #define SHADER_PATH Shaders.metal #else #error Define shader path for this TrinityAL platform #endif -#define INCLUDE_SHADER_CODE( name ) CCP_STRINGIZE(SHADER_PATH/name.h) +// clang-format off +#define INCLUDE_SHADER_CODE( name ) CCP_STRINGIZE( SHADER_PATH/name.h ) +// clang-format on #include "gtest/gtest.h" @@ -43,45 +45,46 @@ typedef uintptr_t Tr2WindowHandle; namespace testing { - namespace internal - { - inline AssertionResult HRESULTFailureHelper( const char* expr, const char* expected, HRESULT hr ) - { +namespace internal +{ +inline AssertionResult HRESULTFailureHelper( const char* expr, const char* expected, HRESULT hr ) +{ #if __APPLE__ - std::stringstream error_hex; - error_hex << "0x" << std::hex << hr; - return AssertionFailure() << "Expected: " << expr << " " << expected << ".\n" << " Actual: " << error_hex.str() << "\n"; + std::stringstream error_hex; + error_hex << "0x" << std::hex << hr; + return AssertionFailure() << "Expected: " << expr << " " << expected << ".\n" + << " Actual: " << error_hex.str() << "\n"; #else - const std::string error_hex( "0x" + String::FormatHexInt( hr ) ); - return AssertionFailure() << "Expected: " << expr << " " << expected << ".\n" - << " Actual: " << error_hex << "\n"; + const std::string error_hex( "0x" + String::FormatHexInt( hr ) ); + return AssertionFailure() << "Expected: " << expr << " " << expected << ".\n" + << " Actual: " << error_hex << "\n"; #endif - } - - inline AssertionResult IsHRESULTSuccess( const char* expr, HRESULT hr ) - { - if( SUCCEEDED( hr ) ) - { - return AssertionSuccess(); - } - return HRESULTFailureHelper( expr, "succeeds", hr ); - } - - inline AssertionResult IsHRESULTFailure( const char* expr, HRESULT hr ) - { - if( FAILED( hr ) ) - { - return AssertionSuccess(); - } - return HRESULTFailureHelper( expr, "succeeds", hr ); - } - } } -#define EXPECT_HRESULT_SUCCEEDED(expr) EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) -#define ASSERT_HRESULT_SUCCEEDED(expr) ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) -#define EXPECT_HRESULT_FAILED(expr) EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) -#define ASSERT_HRESULT_FAILED(expr) ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) +inline AssertionResult IsHRESULTSuccess( const char* expr, HRESULT hr ) +{ + if( SUCCEEDED( hr ) ) + { + return AssertionSuccess(); + } + return HRESULTFailureHelper( expr, "succeeds", hr ); +} + +inline AssertionResult IsHRESULTFailure( const char* expr, HRESULT hr ) +{ + if( FAILED( hr ) ) + { + return AssertionSuccess(); + } + return HRESULTFailureHelper( expr, "succeeds", hr ); +} +} +} + +#define EXPECT_HRESULT_SUCCEEDED( expr ) EXPECT_PRED_FORMAT1( ::testing::internal::IsHRESULTSuccess, ( expr ) ) +#define ASSERT_HRESULT_SUCCEEDED( expr ) ASSERT_PRED_FORMAT1( ::testing::internal::IsHRESULTSuccess, ( expr ) ) +#define EXPECT_HRESULT_FAILED( expr ) EXPECT_PRED_FORMAT1( ::testing::internal::IsHRESULTFailure, ( expr ) ) +#define ASSERT_HRESULT_FAILED( expr ) ASSERT_PRED_FORMAT1( ::testing::internal::IsHRESULTFailure, ( expr ) ) #endif diff --git a/trinityal/tests/SwapChain.cpp b/trinityal/tests/SwapChain.cpp index 27b1d4c19..312c25c08 100644 --- a/trinityal/tests/SwapChain.cpp +++ b/trinityal/tests/SwapChain.cpp @@ -32,7 +32,7 @@ TEST_F( SwapChain, CanCreateSwapChain ) ASSERT_HRESULT_SUCCEEDED( sc.Create( window, *renderContext ) ); EXPECT_TRUE( sc.IsValid() ); EXPECT_TRUE( sc.GetBackBuffer().IsValid() ); -#if( TRINITY_PLATFORM != TRINITY_STUB ) +#if ( TRINITY_PLATFORM != TRINITY_STUB ) EXPECT_EQ( window.GetClientWidth(), sc.GetWidth() ); EXPECT_EQ( window.GetClientHeight(), sc.GetHeight() ); EXPECT_EQ( sc.GetWidth(), sc.GetBackBuffer().GetWidth() ); diff --git a/trinityal/tests/SwapChainResizing.cpp b/trinityal/tests/SwapChainResizing.cpp index c4c750957..05c0e4ac5 100644 --- a/trinityal/tests/SwapChainResizing.cpp +++ b/trinityal/tests/SwapChainResizing.cpp @@ -5,7 +5,7 @@ #include "WithValidRenderContextFixture.h" -struct SwapChainResizing : public WithValidRenderContext +struct SwapChainResizing : public WithValidRenderContext { static ALResult ResizeWindow( uint32_t width, uint32_t height, bool windowed = true ) { @@ -23,25 +23,25 @@ using namespace Tr2RenderContextEnum; namespace { - ALResult CreatePositionOnlyVS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) - { - uint8_t bytecode[] = { - #include INCLUDE_SHADER_CODE( PositionOnly.vs ) - }; +ALResult CreatePositionOnlyVS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) +{ + uint8_t bytecode[] = { +#include INCLUDE_SHADER_CODE( PositionOnly.vs ) + }; - auto input = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ); + auto input = Tr2ShaderSignatureAL().Add( Tr2VertexDefinition::POSITION, 0, 0, Tr2ShaderPipelineInputAL::FLOAT, 3 ); - return shader.Create( VERTEX_SHADER, bytecode, input, "", renderContext ); - } + return shader.Create( VERTEX_SHADER, bytecode, input, "", renderContext ); +} - ALResult CreateConstantColorPS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) - { - uint8_t bytecode[] = { - #include INCLUDE_SHADER_CODE( ConstantColor.ps ) - }; +ALResult CreateConstantColorPS( Tr2ShaderAL& shader, Tr2PrimaryRenderContextAL& renderContext ) +{ + uint8_t bytecode[] = { +#include INCLUDE_SHADER_CODE( ConstantColor.ps ) + }; - return shader.Create( PIXEL_SHADER, bytecode, Tr2ShaderSignatureAL(), "", renderContext ); - } + return shader.Create( PIXEL_SHADER, bytecode, Tr2ShaderSignatureAL(), "", renderContext ); +} } @@ -59,9 +59,15 @@ TEST_F( SwapChainResizing, CanResizeSwapChainWhileRendering ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -124,9 +130,15 @@ TEST_F( SwapChainResizing, CanSwitchToFullScreen ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; @@ -187,9 +199,15 @@ TEST_F( SwapChainResizing, CanChangeFullscreenResolution ) ASSERT_HRESULT_SUCCEEDED( sp.Create( shaders, 2, *renderContext ) ); float vertices[] = { - -0.5f, -0.5f, 0.0f, - -0.5f, 0.5f, 0.0f, - 0.5f, -0.5f, 0.0f, + -0.5f, + -0.5f, + 0.0f, + -0.5f, + 0.5f, + 0.0f, + 0.5f, + -0.5f, + 0.0f, }; const uint32_t vbStride = 3 * sizeof( float ); Tr2BufferAL vb; diff --git a/trinityal/tests/Texture.cpp b/trinityal/tests/Texture.cpp index e03e48e06..18c941a73 100644 --- a/trinityal/tests/Texture.cpp +++ b/trinityal/tests/Texture.cpp @@ -6,7 +6,9 @@ using namespace Tr2RenderContextEnum; -struct Texture : public WithValidRenderContext {}; +struct Texture : public WithValidRenderContext +{ +}; TEST_F( Texture, TextureIsInvalidBeforeCreation ) { @@ -65,7 +67,7 @@ TEST_F( Texture, Texture2DIsValidAfterCreation ) EXPECT_EQ( TEX_TYPE_2D, tex.GetType() ); } -#if TRINITY_PLATFORM_SUPPORTS_TEXTURE_ARRAYS +#if TRINITY_PLATFORM_SUPPORTS_TEXTURE_ARRAYS TEST_F( Texture, Texture2DArrayIsValidAfterCreation ) { ENSURE_GPU_OR_SKIP diff --git a/trinityal/tests/TextureSubresource.cpp b/trinityal/tests/TextureSubresource.cpp index 41cb0ffe3..edb59d0cd 100644 --- a/trinityal/tests/TextureSubresource.cpp +++ b/trinityal/tests/TextureSubresource.cpp @@ -7,9 +7,11 @@ using namespace Tr2RenderContextEnum; namespace { -struct BitmapDimensionsTest: public Tr2BitmapDimensions +struct BitmapDimensionsTest : public Tr2BitmapDimensions { - BitmapDimensionsTest() {} + BitmapDimensionsTest() + { + } void SetType( TextureType type ) { m_type = type; diff --git a/trinityal/tests/TrinityALTest.cpp b/trinityal/tests/TrinityALTest.cpp index 12b9d626b..0529d60c1 100644 --- a/trinityal/tests/TrinityALTest.cpp +++ b/trinityal/tests/TrinityALTest.cpp @@ -27,11 +27,11 @@ void PrintAdapterInfo( unsigned index ) return; } - printf( - "Device name: %s\nDescription: %ls\nVendor ID: %u\nDevice ID: %u\n", - info.deviceName.c_str(), - info.description.c_str(), - info.vendorID, + printf( + "Device name: %s\nDescription: %ls\nVendor ID: %u\nDevice ID: %u\n", + info.deviceName.c_str(), + info.description.c_str(), + info.vendorID, info.deviceID ); Tr2VideoDriverInfo driverInfo; @@ -63,7 +63,7 @@ void PrintAllAdapterInfo() } } -int main( int argc, char **argv ) +int main( int argc, char** argv ) { CCP::SetLogMainThreadId(); @@ -113,7 +113,7 @@ int main( int argc, char **argv ) return result; } -#if defined(__ANDROID__) +#if defined( __ANDROID__ ) #include @@ -123,33 +123,31 @@ bool g_windowResized = false; uint32_t mainThread( void* ) { - char* args[] = { - strdup( "TrinityALTest" ), - strdup( "--interactive" ), - }; - main( 2, args ); - ANativeActivity_finish( g_androidActivity ); - return 0; + char* args[] = { + strdup( "TrinityALTest" ), + strdup( "--interactive" ), + }; + main( 2, args ); + ANativeActivity_finish( g_androidActivity ); + return 0; } static void onNativeWindowCreated( ANativeActivity*, ANativeWindow* window ) { - g_androidWindow = window; - CcpCreateThread( &mainThread, nullptr, CCP_THREAD_PRIORITY_NORMAL ); - + g_androidWindow = window; + CcpCreateThread( &mainThread, nullptr, CCP_THREAD_PRIORITY_NORMAL ); } static void onNativeWindowResized( ANativeActivity*, ANativeWindow* window ) { - g_windowResized = true; + g_windowResized = true; } void ANativeActivity_onCreate( ANativeActivity* activity, void*, size_t ) { - g_androidActivity = activity; - activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; - activity->callbacks->onNativeWindowResized = onNativeWindowResized; - + g_androidActivity = activity; + activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; + activity->callbacks->onNativeWindowResized = onNativeWindowResized; } #endif \ No newline at end of file diff --git a/trinityal/tests/VertexDefinition.cpp b/trinityal/tests/VertexDefinition.cpp index 3bec449f2..370a5b760 100644 --- a/trinityal/tests/VertexDefinition.cpp +++ b/trinityal/tests/VertexDefinition.cpp @@ -118,7 +118,7 @@ TEST( VertexDefinition, CanCompareVertexDefinitions ) def2.Add( Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::NORMAL, 0, 1 ); EXPECT_TRUE( def1 == def2 ); - + def2.Add( Tr2VertexDefinition::FLOAT32_3, Tr2VertexDefinition::TEXCOORD, 0, 2 ); EXPECT_FALSE( def1 == def2 ); diff --git a/trinityal/tests/VertexLayout.cpp b/trinityal/tests/VertexLayout.cpp index e5491728d..eceee220e 100644 --- a/trinityal/tests/VertexLayout.cpp +++ b/trinityal/tests/VertexLayout.cpp @@ -4,7 +4,9 @@ #include "WithValidRenderContextFixture.h" #include "WithRenderContextFixture.h" -struct VertexLayout : public WithValidRenderContext {}; +struct VertexLayout : public WithValidRenderContext +{ +}; void InitializeSampleVertexDefinition( Tr2VertexDefinition& def ) { diff --git a/trinityal/tests/VideoAdapterInfo.cpp b/trinityal/tests/VideoAdapterInfo.cpp index 4ce6c6684..aef7143a9 100644 --- a/trinityal/tests/VideoAdapterInfo.cpp +++ b/trinityal/tests/VideoAdapterInfo.cpp @@ -9,15 +9,21 @@ TEST( VideoAdapterInfo, HasAtLeastOneAdapter ) { unsigned count = 0; ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterCount( count ) ); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } EXPECT_GT( count, 0u ); } TEST( VideoAdapterInfo, CanGetDefaultAdapterInfo ) { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( count ); + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2AdapterInfo info; ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterInfo( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, info ) ); @@ -26,8 +32,11 @@ TEST( VideoAdapterInfo, CanGetDefaultAdapterInfo ) TEST( VideoAdapterInfo, CanGetDefaultAdapterMonitor ) { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( count ); + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } void* monitor; ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterMonitor( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, monitor ) ); @@ -36,8 +45,11 @@ TEST( VideoAdapterInfo, CanGetDefaultAdapterMonitor ) TEST( VideoAdapterInfo, CanGetDefaultAdapterDisplayMode ) { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( count ); + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2DisplayModeInfo mode; memset( &mode, 0, sizeof( mode ) ); @@ -50,13 +62,16 @@ TEST( VideoAdapterInfo, CanGetDefaultAdapterDisplayMode ) TEST( VideoAdapterInfo, CanEnumerateModesForDefaultAdapter ) { unsigned adapter_count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(adapter_count); - if (!adapter_count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( adapter_count ); + if( !adapter_count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2DisplayModeInfo mode; memset( &mode, 0, sizeof( mode ) ); ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, mode ) ); - + PixelFormat backBufferFormat = mode.format; unsigned count = 0; ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterModeCount( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, backBufferFormat, count ) ); @@ -76,13 +91,16 @@ TEST( VideoAdapterInfo, CanEnumerateModesForDefaultAdapter ) TEST( VideoAdapterInfo, DefaultAdapterSupportsItsCurrentBackBufferFormat ) { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( count ); + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2DisplayModeInfo mode; memset( &mode, 0, sizeof( mode ) ); ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterDisplayMode( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, mode ) ); - + EXPECT_TRUE( Tr2VideoAdapterInfo::SupportsBackBufferFormat( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, mode.format ) ); } @@ -93,8 +111,8 @@ TEST( VideoAdapterInfo, SameAdaptersAreNotDifferent ) TEST( VideoAdapterInfo, DefaultAdapterSupports32bppRenderTarget ) { - EXPECT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::SupportsRenderTargetFormat( - Tr2VideoAdapterInfo::DEFAULT_ADAPTER, + EXPECT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::SupportsRenderTargetFormat( + Tr2VideoAdapterInfo::DEFAULT_ADAPTER, PIXEL_FORMAT_B8G8R8A8_UNORM ) ); } @@ -102,8 +120,11 @@ TEST( VideoAdapterInfo, DefaultAdapterSupports32bppRenderTarget ) TEST( VideoAdapterInfo, CanGetDriverInfo ) { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); - if (!count) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } + Tr2VideoAdapterInfo::GetAdapterCount( count ); + if( !count ) + { + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; + } Tr2AdapterInfo info; ASSERT_HRESULT_SUCCEEDED( Tr2VideoAdapterInfo::GetAdapterInfo( Tr2VideoAdapterInfo::DEFAULT_ADAPTER, info ) ); diff --git a/trinityal/tests/WithRenderContextFixture.cpp b/trinityal/tests/WithRenderContextFixture.cpp index 30241faf2..04a9a5deb 100644 --- a/trinityal/tests/WithRenderContextFixture.cpp +++ b/trinityal/tests/WithRenderContextFixture.cpp @@ -2,4 +2,3 @@ #include "StdAfx.h" #include "WithRenderContextFixture.h" - diff --git a/trinityal/tests/WithRenderContextFixture.h b/trinityal/tests/WithRenderContextFixture.h index a2462b0c6..6e2c3c091 100644 --- a/trinityal/tests/WithRenderContextFixture.h +++ b/trinityal/tests/WithRenderContextFixture.h @@ -6,7 +6,7 @@ #include "WithWindowFixture.h" -struct WithRenderContext: public WithWindow +struct WithRenderContext : public WithWindow { public: void SetUp() @@ -24,7 +24,7 @@ struct WithRenderContext: public WithWindow static bool MachineHasGfxAdapter() { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); + Tr2VideoAdapterInfo::GetAdapterCount( count ); return count > 0; } diff --git a/trinityal/tests/WithValidRenderContextFixture.cpp b/trinityal/tests/WithValidRenderContextFixture.cpp index 6f0fd8225..3c9e0063e 100644 --- a/trinityal/tests/WithValidRenderContextFixture.cpp +++ b/trinityal/tests/WithValidRenderContextFixture.cpp @@ -4,14 +4,14 @@ #include "WithValidRenderContextFixture.h" #include -#if defined(__ANDROID__) +#if defined( __ANDROID__ ) #include extern volatile bool g_windowResized; #endif -WithValidRenderContext::WithValidRenderContext() - :m_madeScreenshot( false ) +WithValidRenderContext::WithValidRenderContext() : + m_madeScreenshot( false ) { } @@ -34,14 +34,14 @@ void WithValidRenderContext::SetUpTestCase() presentParameters.software = false; presentParameters.presentInterval = Tr2RenderContextEnum::PRESENT_INTERVAL_ONE; - + CR( renderContext->CreateDevice( 0, WithWindow::GetWindowHandle(), presentParameters ) ); - -#if defined(__ANDROID__) - __android_log_print( ANDROID_LOG_INFO, "TrinityALTest", "OpenGL extensions: %s", glGetString( GL_EXTENSIONS ) ); - while( !g_windowResized ) - { - } + +#if defined( __ANDROID__ ) + __android_log_print( ANDROID_LOG_INFO, "TrinityALTest", "OpenGL extensions: %s", glGetString( GL_EXTENSIONS ) ); + while( !g_windowResized ) + { + } #endif } @@ -59,47 +59,47 @@ namespace struct DDS_PIXELFORMAT { - uint32_t dwSize; // 4 + uint32_t dwSize; // 4 uint32_t dwFlags; uint32_t dwFourCC; - uint32_t dwRGBBitCount; // 16 + uint32_t dwRGBBitCount; // 16 uint32_t dwRBitMask; uint32_t dwGBitMask; uint32_t dwBBitMask; - uint32_t dwABitMask; // 32 + uint32_t dwABitMask; // 32 }; struct DDS_HEADER { - uint32_t dwFourCC; // 4 + uint32_t dwFourCC; // 4 uint32_t dwSize; uint32_t dwHeaderFlags; - uint32_t dwHeight; // 16 + uint32_t dwHeight; // 16 uint32_t dwWidth; uint32_t dwPitchOrLinearSize; - uint32_t dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwHeaderFlags - uint32_t dwMipMapCount; // 32 - uint32_t dwReserved1[11]; // 76 - DDS_PIXELFORMAT ddspf; // 108 + uint32_t dwDepth; // only if DDS_HEADER_FLAGS_VOLUME is set in dwHeaderFlags + uint32_t dwMipMapCount; // 32 + uint32_t dwReserved1[11]; // 76 + DDS_PIXELFORMAT ddspf; // 108 uint32_t dwSurfaceFlags; - uint32_t dwCubemapFlags; // 116 - uint32_t dwReserved2[3]; // 128 + uint32_t dwCubemapFlags; // 116 + uint32_t dwReserved2[3]; // 128 }; #ifndef MAKEFOURCC - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) +#define MAKEFOURCC( ch0, ch1, ch2, ch3 ) \ + ( (uint32_t)(uint8_t)( ch0 ) | ( (uint32_t)(uint8_t)( ch1 ) << 8 ) | \ + ( (uint32_t)(uint8_t)( ch2 ) << 16 ) | ( (uint32_t)(uint8_t)( ch3 ) << 24 ) ) #endif -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE -#define DDS_RGB 0x00000040 // DDPF_RGB +#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT +#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT +#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH +#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH +#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE +#define DDS_RGB 0x00000040 // DDPF_RGB #define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE void SaveReadableRenderTarget( Tr2TextureAL& rt, const char* outFilePath, Tr2RenderContextAL& renderContext ) @@ -128,8 +128,8 @@ void SaveReadableRenderTarget( Tr2TextureAL& rt, const char* outFilePath, Tr2Ren header.ddspf.dwBBitMask = 0xFF; header.dwSurfaceFlags = DDS_SURFACE_FLAGS_TEXTURE; - header.dwPitchOrLinearSize = (header.ddspf.dwRGBBitCount * header.dwWidth * header.dwHeight) / 8; - + header.dwPitchOrLinearSize = ( header.ddspf.dwRGBBitCount * header.dwWidth * header.dwHeight ) / 8; + auto sz = pitch * rt.GetHeight(); std::unique_ptr rgbx( new uint8_t[sz] ); memcpy( rgbx.get(), data, sz ); @@ -258,11 +258,11 @@ size_t FindSlash( const std::string& path, size_t offset ) #ifdef _MSC_VER #define mkdir( path ) _mkdir( path ) -#elif defined(__ANDROID__) +#elif defined( __ANDROID__ ) #include #define mkdir( path ) mkdir( path, 0777 ); #else -#define mkdir( path ) mkdir( path, S_IRWXU|S_IRGRP|S_IXGRP ) +#define mkdir( path ) mkdir( path, S_IRWXU | S_IRGRP | S_IXGRP ) #endif void MkDirs( const std::string& path ) @@ -285,7 +285,7 @@ void MkDirs( const std::string& path ) bool WithValidRenderContext::MachineHasGfxAdapter() { unsigned count = 0; - Tr2VideoAdapterInfo::GetAdapterCount(count); + Tr2VideoAdapterInfo::GetAdapterCount( count ); return count > 0; } @@ -299,7 +299,7 @@ void WithValidRenderContext::MakeScreenShot( const char* outFilePath ) void WithValidRenderContext::MakeTestScreenShot() { -#if TRINITY_PLATFORM == TRINITY_STUB +#if TRINITY_PLATFORM == TRINITY_STUB return; #endif @@ -314,7 +314,7 @@ void WithValidRenderContext::MakeTestScreenShot() m_madeScreenshot = true; const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - + std::string path = g_screenshotFolder; path += std::string( "/" ) + test_info->test_case_name(); MkDirs( path.c_str() ); diff --git a/trinityal/tests/WithValidRenderContextFixture.h b/trinityal/tests/WithValidRenderContextFixture.h index 7f04efa58..b9e38bd6e 100644 --- a/trinityal/tests/WithValidRenderContextFixture.h +++ b/trinityal/tests/WithValidRenderContextFixture.h @@ -6,9 +6,13 @@ #include "WithWindowFixture.h" -#define ENSURE_GPU_OR_SKIP if( !MachineHasGfxAdapter() ) { GTEST_SKIP() << "Test Skipped as no adapters present on machine."; } +#define ENSURE_GPU_OR_SKIP \ + if( !MachineHasGfxAdapter() ) \ + { \ + GTEST_SKIP() << "Test Skipped as no adapters present on machine."; \ + } -struct WithValidRenderContext: public WithWindow +struct WithValidRenderContext : public WithWindow { public: WithValidRenderContext(); @@ -22,6 +26,7 @@ struct WithValidRenderContext: public WithWindow static Tr2PresentParametersAL presentParameters; static Tr2PrimaryRenderContextAL* renderContext; + private: bool m_madeScreenshot; }; diff --git a/trinityal/tests/WithWindowFixture.h b/trinityal/tests/WithWindowFixture.h index 98eca63af..fd1c99102 100644 --- a/trinityal/tests/WithWindowFixture.h +++ b/trinityal/tests/WithWindowFixture.h @@ -6,14 +6,13 @@ class RenderWindow; -class WithWindow: public ::testing::Test +class WithWindow : public ::testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); - template - static void RunLoop( T& t ) + template static void RunLoop( T& t ) { extern bool g_interactive; if( g_interactive ) @@ -22,19 +21,20 @@ class WithWindow: public ::testing::Test while( true ) { #if __OBJC__ - @autoreleasepool { -#endif - if( !DoLoopProcessing() ) - { - return; - } - t(); - if( HasFatalFailure() ) + @autoreleasepool { - return; - } +#endif + if( !DoLoopProcessing() ) + { + return; + } + t(); + if( HasFatalFailure() ) + { + return; + } #if __OBJC__ - } + } #endif } } @@ -46,6 +46,7 @@ class WithWindow: public ::testing::Test static Tr2WindowHandle GetWindowHandle(); static RenderWindow* GetWindow(); + private: static void BeginLoopProcessing(); static bool DoLoopProcessing(); diff --git a/trinityal/tests/WithWindowFixture_Macos.mm b/trinityal/tests/WithWindowFixture_Macos.mm index 393b0b608..c8720224d 100644 --- a/trinityal/tests/WithWindowFixture_Macos.mm +++ b/trinityal/tests/WithWindowFixture_Macos.mm @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if defined(__APPLE__) && TRINITY_PLATFORM != TRINITY_STUB +#if defined( __APPLE__ ) && TRINITY_PLATFORM != TRINITY_STUB #include "WithWindowFixture.h" #include "RenderWindow.h" @@ -12,51 +12,51 @@ namespace { - RenderWindow* s_wnd = nullptr; +RenderWindow* s_wnd = nullptr; } void WithWindow::SetUpTestCase() { - CCP_DELETE s_wnd; - s_wnd = CCP_NEW( "WithWindowFixture/s_wnd" ) RenderWindow( 640, 480 ); + CCP_DELETE s_wnd; + s_wnd = CCP_NEW( "WithWindowFixture/s_wnd" ) RenderWindow( 640, 480 ); } void WithWindow::TearDownTestCase() { - CCP_DELETE s_wnd; - s_wnd = nullptr; + CCP_DELETE s_wnd; + s_wnd = nullptr; } void WithWindow::BeginLoopProcessing() { - s_keyPressed = false; + s_keyPressed = false; } bool WithWindow::DoLoopProcessing() { - while( true ) - { - NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:[NSDate distantPast] - inMode:NSDefaultRunLoopMode - dequeue:YES]; - if (event == nil) - { - break; - } - [NSApp sendEvent:event]; - } - return !s_keyPressed; + while( true ) + { + NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + if( event == nil ) + { + break; + } + [NSApp sendEvent:event]; + } + return !s_keyPressed; } Tr2WindowHandle WithWindow::GetWindowHandle() { - return s_wnd ? s_wnd->GetHandle() : Tr2WindowHandle( 0 ); + return s_wnd ? s_wnd->GetHandle() : Tr2WindowHandle( 0 ); } RenderWindow* WithWindow::GetWindow() { - return s_wnd; + return s_wnd; } #endif diff --git a/trinityal/tests/WithWindowFixture_Stub.cpp b/trinityal/tests/WithWindowFixture_Stub.cpp index 851b2b8d2..7fa7c02ad 100644 --- a/trinityal/tests/WithWindowFixture_Stub.cpp +++ b/trinityal/tests/WithWindowFixture_Stub.cpp @@ -1,7 +1,7 @@ // Copyright © 2023 CCP ehf. #include "StdAfx.h" -#if !defined(_WIN32) && !defined(TRINITY_AL_MOBILE) && (TRINITY_PLATFORM == TRINITY_STUB) +#if !defined( _WIN32 ) && !defined( TRINITY_AL_MOBILE ) && ( TRINITY_PLATFORM == TRINITY_STUB ) #include "WithWindowFixture.h" #include "RenderWindow.h" @@ -9,7 +9,7 @@ namespace { - RenderWindow* s_wnd = nullptr; +RenderWindow* s_wnd = nullptr; } void WithWindow::SetUpTestCase() @@ -30,7 +30,7 @@ void WithWindow::BeginLoopProcessing() bool WithWindow::DoLoopProcessing() { - return true; + return true; } Tr2WindowHandle WithWindow::GetWindowHandle() diff --git a/trinityal/tests/WithWindowFixture_Win32.cpp b/trinityal/tests/WithWindowFixture_Win32.cpp index 0cb5d52fe..13d50cadd 100644 --- a/trinityal/tests/WithWindowFixture_Win32.cpp +++ b/trinityal/tests/WithWindowFixture_Win32.cpp @@ -12,13 +12,13 @@ RenderWindow* s_wnd = nullptr; } -void WithWindow::SetUpTestCase() +void WithWindow::SetUpTestCase() { CCP_DELETE s_wnd; s_wnd = CCP_NEW( "WithWindowFixture/s_wnd" ) RenderWindow( 640, 480 ); } -void WithWindow::TearDownTestCase() +void WithWindow::TearDownTestCase() { CCP_DELETE s_wnd; s_wnd = nullptr;