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

Method RebuildCachedData

trinity/Eve/Turret/EveTurretSet.cpp:1035–1104  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: This gets called when the geometry data has finished loading, so we have a whole lot of init's to do: - take the original vertex declaration, extend by one member for the 2nd stream, and create a new one - grab bounding sphere from mesh - analyze the skeleton: find the system bones and remember their indi

Source from the content-addressed store, hash-verified

1033// TriGeometryResMeshData, Tr2EffectStateManager, TriGeometryResSkeletonData
1034// --------------------------------------------------------------------------------
1035void EveTurretSet::RebuildCachedData( BlueAsyncRes* p )
1036{
1037 if( p == m_geometryResource )
1038 {
1039 // finished loading the turret geometry resource, so grab vertex decl and bounding sphere
1040 if( m_geometryResource->GetMeshCount() )
1041 {
1042 const TriGeometryResMeshData* meshData = m_geometryResource->GetMeshData( 0 );
1043 if( meshData )
1044 {
1045 // gemoetry's original vertex-decl must exist
1046 if( meshData->m_vertexDeclarationHandle != Tr2EffectStateManager::UNINITIALIZED_DECLARATION )
1047 {
1048 // get gemoetry's original vertex-decl...
1049 Tr2EffectStateManager::GetVertexDeclarationElements( meshData->m_vertexDeclarationHandle, m_turretVertexDecl );
1050 // ...expand it with instances stream elements...
1051 auto& item = m_turretVertexDecl.Add( m_turretVertexDecl.FLOAT32_1, m_turretVertexDecl.TEXCOORD, 2, 1, 1 );
1052 item.m_offset = 0;
1053 // ...and create new vertex dcel again
1054 m_vertexDeclHandle = Tr2EffectStateManager::GetVertexDeclarationHandle( m_turretVertexDecl );
1055 m_turretVertexDeclElementCount = (unsigned int)m_turretVertexDecl.m_items.size();
1056 }
1057
1058 // get a bounding box for visibilty detection, if this is not already set in the redfile
1059 if( m_boundingSphere.w == 0.f )
1060 {
1061 m_geometryResource->RecalculateBoundingSphere();
1062 m_geometryResource->GetBoundingSphere( 0, m_boundingSphere );
1063 }
1064 }
1065 }
1066
1067 // hunt for the system-controlled bones and positional bones
1068 if( m_geometryResource->GetSkeletonCount() )
1069 {
1070 TriGeometryResSkeletonData* skeletonData = m_geometryResource->GetSkeletonData( 0 );
1071 if( skeletonData )
1072 {
1073 for( int i = 0; i < SYSBONE_MAX; ++i )
1074 {
1075 // in case we don't find system bone, ::FindJoint() returns 0xffffffff
1076 m_systemBoneID[i] = skeletonData->FindJoint( s_systemBoneSkeletonNames[i].c_str() );
1077 }
1078
1079 // try to link an existing firing effect to skeleton's bones
1080 InitializeFiringEffect();
1081 }
1082 }
1083
1084 InitializeAnimation();
1085
1086 // animation already requested in a queue?
1087 if( !m_animationQueue.empty() )
1088 {
1089 std::vector<AnimationRequest> queueSnapshot = m_animationQueue;
1090 for( const auto& request : queueSnapshot )
1091 {
1092 PlayAnimation( request.turretIndex, request.animName, request.animNameIdle );

Callers

nothing calls this directly

Calls 11

GetMeshDataMethod · 0.80
sizeMethod · 0.80
GetSkeletonCountMethod · 0.80
GetSkeletonDataMethod · 0.80
emptyMethod · 0.80
GetMeshCountMethod · 0.45
AddMethod · 0.45
GetBoundingSphereMethod · 0.45
FindJointMethod · 0.45

Tested by

no test coverage detected