| 1752 | } |
| 1753 | |
| 1754 | Be::Result<std::string> TriGrannyRes::BakeBlendshapeFromScript( unsigned int meshIx, const std::vector<float>& weights, TriGeometryRes* geom ) |
| 1755 | { |
| 1756 | if( IsUsingCMF() ) |
| 1757 | { |
| 1758 | auto errorMessage = ValidateMeshIndex( meshIx ); |
| 1759 | if( !BeIsSuccess( errorMessage ) ) |
| 1760 | { |
| 1761 | return errorMessage; |
| 1762 | } |
| 1763 | } |
| 1764 | #if WITH_GRANNY |
| 1765 | else |
| 1766 | { |
| 1767 | granny_file* gf = GetGrannyFile(); |
| 1768 | if( !gf ) |
| 1769 | { |
| 1770 | return Be::Result<std::string>( "No granny_file structure" ); |
| 1771 | } |
| 1772 | |
| 1773 | granny_file_info* fi = GrannyGetFileInfo( gf ); |
| 1774 | |
| 1775 | if( (granny_int32x)meshIx >= fi->MeshCount ) |
| 1776 | { |
| 1777 | return Be::Result<std::string>( "Mesh index out of range" ); |
| 1778 | } |
| 1779 | } |
| 1780 | #endif |
| 1781 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 1782 | |
| 1783 | |
| 1784 | |
| 1785 | TriGeometryResLodData* lod = geom->GetMeshLod( meshIx, 0 ); |
| 1786 | if( !lod ) |
| 1787 | { |
| 1788 | return Be::Result<std::string>( "Trying to bake using geometryRes with NULL lod" ); |
| 1789 | } |
| 1790 | if( !lod->m_allocationsValid ) |
| 1791 | { |
| 1792 | return Be::Result<std::string>( "Trying to bake to a null vertex buffer" ); |
| 1793 | } |
| 1794 | |
| 1795 | bool success = BakeBlendshape( meshIx, weights, lod->m_vertexAllocation, renderContext, lod->m_vertexCount * lod->m_mesh->m_bytesPerVertex ); |
| 1796 | |
| 1797 | return success ? Be::Result<std::string>() : Be::Result<std::string>( " TriGrannyRes::BakeBlendshape encountered problems. " ); |
| 1798 | } |
| 1799 | |
| 1800 | bool TriGrannyRes::IsUsingCMF() const |
| 1801 | { |
nothing calls this directly
no test coverage detected