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

Method GetIntersectionPoints

trinity/Resources/TriGeometryRes.cpp:1632–1765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1630}
1631
1632bool TriGeometryRes::GetIntersectionPoints( const Vector3* pos, const Vector3* dir, Vector3* hitpointNear, Vector3* hitpointNearNormal, Vector3* hitpointFar, Vector3* hitpointFarNormal, int* boneIndexNear, int* boneIndexFar, unsigned int areaIx )
1633{
1634 CCP_STATS_ZONE( __FUNCTION__ );
1635
1636 USE_MAIN_THREAD_RENDER_CONTEXT();
1637
1638 *boneIndexFar = *boneIndexNear = -1;
1639 int boneIndex = 0;
1640 float minDist = FLT_MAX;
1641 float maxDist = FLT_MIN;
1642 bool result = false;
1643
1644 for( size_t i = 0; i < m_meshes.size(); i++ )
1645 {
1646 if( m_meshes[i] == NULL )
1647 {
1648 continue;
1649 }
1650
1651 //Get the first LOD.
1652 auto& lod = m_meshes[i]->m_lods[0];
1653
1654 const uint8_t* pVertices;
1655 const uint8_t* pIndices;
1656
1657 int vertSize = m_meshes[i]->m_bytesPerVertex;
1658 if( FAILED( lod->m_vertexAllocation.MapForReading( pVertices, renderContext ) ) )
1659 {
1660 return 0;
1661 }
1662 ON_BLOCK_EXIT( [&] { lod->m_vertexAllocation.UnmapForReading( renderContext ); } );
1663 if( FAILED( lod->m_indexAllocation.MapForReading( pIndices, renderContext ) ) )
1664 {
1665 return false;
1666 }
1667 ON_BLOCK_EXIT( [&] { lod->m_indexAllocation.UnmapForReading( renderContext ); } );
1668
1669 const uint16_t* pShortIndices = (uint16_t*)pIndices;
1670 const uint32_t* pLongIndices = (uint32_t*)pIndices;
1671
1672 Tr2VertexDefinition decl;
1673 if( !Tr2EffectStateManager::GetVertexDeclarationElements( m_meshes[i]->m_vertexDeclarationHandle, decl ) )
1674 {
1675 return false;
1676 }
1677 const Tr2VertexDefinition::Item* const position = decl.Find( decl.POSITION );
1678 if( !position )
1679 {
1680 return false;
1681 }
1682
1683 const Tr2VertexDefinition::Item* const blendIndices = decl.Find( decl.BLENDINDICES );
1684 int numPrim = lod->m_primitiveCount;
1685 auto currentIndex = 0;
1686 if( areaIx != -1 )
1687 {
1688 if( areaIx >= lod->m_areas.size() )
1689 {

Callers

nothing calls this directly

Calls 9

ConvertTriangleDataFunction · 0.85
IntersectTriFunction · 0.85
CrossFunction · 0.85
GetBoneIndexFunction · 0.85
sizeMethod · 0.80
FindMethod · 0.80
MapForReadingMethod · 0.45
UnmapForReadingMethod · 0.45
GetStrideMethod · 0.45

Tested by

no test coverage detected