-------------------------------------------------------------------------------------- Description: Convert Trinity vertex definition back to a granny layout. Arguments: vd - input definition grannyVertexDecl - pointer to at least maxSize elements maxSize - size of grannyVertexDecl array Return Value: true - If successful false - On error -----------------------------------------------------------
| 146 | // false - On error |
| 147 | // -------------------------------------------------------------------------------------- |
| 148 | bool ConvertVertexDeclToGranny( Tr2VertexDefinition vd, granny_data_type_definition* grannyVertexDecl, unsigned maxSize ) |
| 149 | { |
| 150 | // Note: This function assumes the D3D vertex layout is described in increasing offset order |
| 151 | // ... so make sure. |
| 152 | std::sort( begin( vd.m_items ), end( vd.m_items ) ); |
| 153 | |
| 154 | // shorten the namespace... |
| 155 | typedef Tr2VertexDefinition tvd; |
| 156 | |
| 157 | for( size_t i = 0; i != std::min( maxSize, (unsigned int)vd.m_items.size() ); ++i ) |
| 158 | { |
| 159 | const auto& src = vd.m_items[i]; |
| 160 | |
| 161 | granny_data_type_definition& dst = grannyVertexDecl[i]; |
| 162 | |
| 163 | dst.ArrayWidth = ( ( src.m_dataType & tvd::DT_SIZE_MASK ) >> tvd::DT_SIZE_OFFSET ) + 1; |
| 164 | const bool isUnsigned = ( src.m_dataType & tvd::DT_UNSIGNED_BIT ) != 0; |
| 165 | const bool isNormalized = ( src.m_dataType & tvd::DT_NORMALIZED_BIT ) != 0; |
| 166 | |
| 167 | switch( src.m_dataType & tvd::DT_TYPE_MASK ) |
| 168 | { |
| 169 | case tvd::DT_INT8: |
| 170 | dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt8Member : GrannyUInt8Member : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt8Member; |
| 171 | break; |
| 172 | |
| 173 | case tvd::DT_INT16: |
| 174 | dst.Type = isUnsigned ? isNormalized ? GrannyNormalUInt16Member : GrannyUInt16Member : /*isNormalized ? GrannyNormalInt8Member :*/ GrannyInt16Member; |
| 175 | break; |
| 176 | |
| 177 | case tvd::DT_INT32: |
| 178 | dst.Type = isUnsigned ? GrannyUInt32Member : GrannyInt16Member; |
| 179 | break; |
| 180 | |
| 181 | case tvd::DT_FLOAT16: |
| 182 | dst.Type = GrannyReal16Member; |
| 183 | break; |
| 184 | |
| 185 | case tvd::DT_FLOAT32: |
| 186 | dst.Type = GrannyReal32Member; |
| 187 | break; |
| 188 | |
| 189 | default: |
| 190 | CCP_ASSERT( false && "Missing datatype support in granny conversion" ); |
| 191 | return false; |
| 192 | } |
| 193 | |
| 194 | static const char* grannyTexcoordNames[8] = { |
| 195 | GrannyVertexTextureCoordinatesName "0", |
| 196 | GrannyVertexTextureCoordinatesName "1", |
| 197 | GrannyVertexTextureCoordinatesName "2", |
| 198 | GrannyVertexTextureCoordinatesName "3", |
| 199 | GrannyVertexTextureCoordinatesName "4", |
| 200 | GrannyVertexTextureCoordinatesName "5", |
| 201 | GrannyVertexTextureCoordinatesName "6", |
| 202 | GrannyVertexTextureCoordinatesName "7", |
| 203 | }; |
| 204 | |
| 205 | static const char* grannyPositionNames[4] = { |
no test coverage detected