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

Function ExtractFaceData

trinity/Eve/UI/EveSpherePinIndexTree.cpp:151–191  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

149
150// ------------------------------------------------------------------------------------------------------
151EveSpherePinIndexTree::Face* ExtractFaceData( const cmf::Data& cmfData, const void* ibSectionData, std::vector<Vector3>& verts )
152{
153 const cmf::MeshLod& mesh = cmfData.meshes[0].lods[0];
154 uint32_t numPrim = cmf::GetStreamElementCount( mesh.ib ) / 3;
155 EveSpherePinIndexTree::Face* faces = new EveSpherePinIndexTree::Face[numPrim];
156
157 auto indices = cmf::ConstIndexBufferStream( ibSectionData, mesh.ib );
158
159 for( uint32_t i = 0; i < numPrim; i++ )
160 {
161 uint32_t index1 = indices[( i * 3 ) + 0];
162 uint32_t index2 = indices[( i * 3 ) + 1];
163 uint32_t index3 = indices[( i * 3 ) + 2];
164
165 faces[i].index1 = index1;
166 faces[i].index2 = index2;
167 faces[i].index3 = index3;
168
169 faces[i].center.x =
170 ( min( min( verts[index1].x, verts[index2].x ), verts[index3].x ) +
171 max( max( verts[index1].x, verts[index2].x ), verts[index3].x ) ) /
172 2.0f;
173 faces[i].center.y =
174 ( min( min( verts[index1].y, verts[index2].y ), verts[index3].y ) +
175 max( max( verts[index1].y, verts[index2].y ), verts[index3].y ) ) /
176 2.0f;
177 faces[i].center.z =
178 ( min( min( verts[index1].z, verts[index2].z ), verts[index3].z ) +
179 max( max( verts[index1].z, verts[index2].z ), verts[index3].z ) ) /
180 2.0f;
181
182 Vector3 d1( verts[index1] - faces[i].center );
183 Vector3 d2( verts[index2] - faces[i].center );
184 Vector3 d3( verts[index3] - faces[i].center );
185 faces[i].radius = Length( d1 );
186 faces[i].radius = max( faces[i].radius, Length( d2 ) );
187 faces[i].radius = max( faces[i].radius, Length( d3 ) );
188 }
189
190 return faces;
191}
192
193#if WITH_GRANNY
194// ------------------------------------------------------------------------------------------------------

Callers 1

InitializeMethod · 0.85

Calls 1

LengthFunction · 0.85

Tested by

no test coverage detected