-
Notifications
You must be signed in to change notification settings - Fork 4
/
QTreeTester.cpp
73 lines (55 loc) · 1.49 KB
/
QTreeTester.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Fill out your copyright notice in the Description page of Project Settings.
#include "QTreeTester.h"
#include "QTree.h"
#include "Helpers.h"
#include "Runtime/Engine/Classes/GameFramework/Actor.h"
// Sets default values
AQTreeTester::AQTreeTester() : testPoints()
{
tree = new QTree(FVector2D(-100, -100), FVector2D(100, 100));
tree->bCanExpandBounds = true;
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void AQTreeTester::BeginPlay()
{
Super::BeginPlay();
TestAutoAddingSpawnPoints();
}
// Called every frame
void AQTreeTester::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AQTreeTester::TestAddingPoints()
{
for (AActor *act : testPoints)
{
if (!tree->Add(act))
print("Could not add.");
}
TArray<AActor *> arr = tree->GetAllActors();
for (AActor *act : arr)
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *act->GetActorLocation().ToString());
}
tree->SetBounds(FVector2D(-100, -100), FVector2D(500, 500));
TArray<AActor *> arr2 = tree->GetAllActors();
UE_LOG(LogTemp, Warning, TEXT("Tree after boundry change"));
for (AActor *act : arr2)
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *act->GetActorLocation().ToString());
}
}
void AQTreeTester::TestAutoAddingSpawnPoints()
{
UE_LOG(LogTemp, Warning, TEXT("List of auto added points"));
TArray<AActor *> arr = tree->GetAllActors();
for (AActor *act : arr)
{
UE_LOG(LogTemp, Warning, TEXT("%s"), *act->GetActorLocation().ToString());
}
}
void AQTreeTester::TestRandomSpawning()
{
}