| 144 | } |
| 145 | |
| 146 | void BehaviorKnowledge::InitMemory(BehaviorTree* tree) |
| 147 | { |
| 148 | PROFILE_MEM(AI); |
| 149 | if (Tree) |
| 150 | FreeMemory(); |
| 151 | if (!tree) |
| 152 | return; |
| 153 | Tree = tree; |
| 154 | Blackboard = Variant::NewValue(tree->Graph.Root->BlackboardType); |
| 155 | RelevantNodes.Resize(tree->Graph.NodesCount, false); |
| 156 | RelevantNodes.SetAll(false); |
| 157 | if (!Memory && tree->Graph.NodesStatesSize) |
| 158 | { |
| 159 | Memory = Allocator::Allocate(tree->Graph.NodesStatesSize); |
| 160 | #if !BUILD_RELEASE |
| 161 | // Clear memory to make it easier to spot missing data issues (eg. zero GCHandle in C# BT node due to missing state init) |
| 162 | Platform::MemoryClear(Memory, tree->Graph.NodesStatesSize); |
| 163 | #endif |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void BehaviorKnowledge::FreeMemory() |
| 168 | { |
no test coverage detected