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

Method AddFreeNode

Source/Engine/Utilities/RectPack.h:74–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 };
73
74 void AddFreeNode(NodeType* node)
75 {
76 // Use binary search to find the insert location (assumes that FreeNodes are always sorted)
77 int32 left = 0, right = FreeNodes.Count() - 1;
78 const uint32 nodeSize = (uint32)node->Width * (uint32)node->Height;
79 while (left <= right)
80 {
81 int32 mid = left + (right - left) / 2;
82 const NodeType* midNode = FreeNodes.Get()[mid];
83 const uint32 midSize = (uint32)midNode->Width * (uint32)midNode->Height;
84 if (nodeSize == midSize)
85 {
86 // Insert right after node of the same size
87 left = mid;
88 break;
89 }
90 if (nodeSize > midSize)
91 {
92 // Go to the left half (contains nodes with higher sizes)
93 right = mid - 1;
94 }
95 else
96 {
97 // Go to the right half (contains nodes with lower sizes)
98 left = mid + 1;
99 }
100 }
101 FreeNodes.Insert(left, node);
102 }
103
104public:
105 FORCE_INLINE bool IsInitialized()

Callers

nothing calls this directly

Calls 3

CountMethod · 0.45
GetMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected