MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / FindClosestNode

Method FindClosestNode

Source/Engine/Level/Actors/AnimatedModel.cpp:314–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314int32 AnimatedModel::FindClosestNode(const Vector3& location, bool worldSpace) const
315{
316 if (GraphInstance.NodesPose.IsEmpty())
317 const_cast<AnimatedModel*>(this)->PreInitSkinningData(); // Ensure to have valid nodes pose to return
318 const Vector3 pos = worldSpace ? _transform.WorldToLocal(location) : location;
319 int32 result = -1;
320 Real closest = MAX_Real;
321 for (int32 nodeIndex = 0; nodeIndex < GraphInstance.NodesPose.Count(); nodeIndex++)
322 {
323 const Vector3 node = GraphInstance.NodesPose[nodeIndex].GetTranslation();
324 const Real dst = Vector3::DistanceSquared(node, pos);
325 if (dst < closest)
326 {
327 closest = dst;
328 result = nodeIndex;
329 }
330 }
331 return result;
332}
333
334void AnimatedModel::SetMasterPoseModel(AnimatedModel* masterPose)
335{

Callers

nothing calls this directly

Calls 4

PreInitSkinningDataMethod · 0.80
IsEmptyMethod · 0.45
WorldToLocalMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected