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

Method GetCenterOfMass

trinity/Tr2SolidSet.cpp:113–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113Vector3 Tr2SolidSet::GetCenterOfMass( void )
114{
115 Vector3 result = Vector3( 0.0f, 0.0f, 0.0f );
116 for( unsigned int i = 0; i < m_triangles.size(); i++ )
117 {
118 result.x += m_triangles[i].m_position1.x;
119 result.x += m_triangles[i].m_position2.x;
120 result.x += m_triangles[i].m_position3.x;
121 result.y += m_triangles[i].m_position1.y;
122 result.y += m_triangles[i].m_position2.y;
123 result.y += m_triangles[i].m_position3.y;
124 result.z += m_triangles[i].m_position1.z;
125 result.z += m_triangles[i].m_position2.z;
126 result.z += m_triangles[i].m_position3.z;
127 }
128
129 result.x /= ( m_triangles.size() * 3 );
130 result.y /= ( m_triangles.size() * 3 );
131 result.z /= ( m_triangles.size() * 3 );
132 result = TransformCoord( result, m_worldTransform );
133 return result;
134}
135
136
137void Tr2SolidSet::GetBatchesImpl( ITriRenderBatchAccumulator* accumulator, const Tr2PerObjectData* perObjectData, Tr2Material* effect, GetBatchesReason reason )

Callers 2

UpdateLinesMethod · 0.80
InitMethod · 0.80

Calls 2

sizeMethod · 0.80
Vector3Class · 0.70

Tested by

no test coverage detected