MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetPerObjectData

Method GetPerObjectData

trinity/Eve/SpaceObject/Children/EveChildMesh.cpp:797–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

795}
796
797Tr2PerObjectData* EveChildMesh::GetPerObjectData( ITriRenderBatchAccumulator* accumulator )
798{
799 m_vsData.activeMorphTargetsCount = 0;
800
801 m_vsData.bakedMorphTargetVertexDataOffset = std::numeric_limits<uint32_t>::max();
802
803 if( m_animationUpdater && m_animationUpdater->IsInitialized() )
804 {
805 auto meshIndex = m_mesh->GetMeshIndex();
806 if( auto mesh = m_mesh->GetGeometryResource()->GetMeshData( meshIndex ) )
807 {
808 auto lod = m_mesh->GetGeometryResource()->GetMeshLod( meshIndex, m_currentScreenSize );
809 if( lod->m_morphTargetAllocation.IsValid() )
810 {
811 auto [morphTargets, morphTargetCount] = GetMorphTargets( MorphTargetAnimationFilter::RUNTIME_EVALUATED );
812 m_morphTargetOffsets.UploadTransforms<Tr2MorphTargetAnimationData>( Tr2RingBuffer::GetInstance<Tr2MorphTargetAnimationData>(), reinterpret_cast<const Tr2MorphTargetAnimationData*>( morphTargets ), uint32_t( morphTargetCount ) );
813
814 // for velocity buffer, we would need previous morphTargetAnimationDataOffset and previous activeMorphTargetsCount!
815 m_vsData.activeMorphTargetsCount = uint32_t( morphTargetCount );
816 m_vsData.morphTargetAnimationDataOffset = m_morphTargetOffsets.GetCurrentFrameOffset();
817 m_vsData.morphTargetVertexDataOffset = lod->m_morphTargetAllocation.GetOffset();
818
819 if( m_bakedMorphAllocation.IsValid() && IsMorphsBaked() )
820 {
821 m_vsData.bakedMorphTargetVertexDataOffset = m_bakedMorphAllocation.GetOffset();
822 }
823 }
824 }
825
826 auto [bones, boneCount] = GetBoneTransforms();
827 m_vsData.boneOffsets[2] = uint32_t( boneCount );
828 m_boneOffsets.UploadTransforms( Tr2RingBuffer::GetInstance<Float4x3>(), reinterpret_cast<const Float4x3*>( bones ), uint32_t( boneCount ) );
829 }
830 m_vsData.boneOffsets[0] = m_boneOffsets.GetCurrentFrameOffset();
831 m_vsData.boneOffsets[1] = m_boneOffsets.GetPreviousFrameOffset();
832
833 Tr2PerObjectDataWithPersistentBuffers<EveChildMesh>* perObjectData = accumulator->Allocate<Tr2PerObjectDataWithPersistentBuffers<EveChildMesh>>();
834 if( !perObjectData )
835 {
836 return nullptr;
837 }
838 perObjectData->Initialize( this, &m_perObjectDataVs, &m_perObjectDataPs );
839
840 return perObjectData;
841}
842
843uint32_t EveChildMesh::GetPerObjectDataSize( Tr2RenderContextEnum::ShaderType shaderType ) const
844{

Callers

nothing calls this directly

Calls 11

GetMeshIndexMethod · 0.80
GetMeshDataMethod · 0.80
GetGeometryResourceMethod · 0.80
GetCurrentFrameOffsetMethod · 0.80
UploadTransformsMethod · 0.80
IsInitializedMethod · 0.45
GetMeshLodMethod · 0.45
IsValidMethod · 0.45
GetOffsetMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected