Hi all,
Here is DrawPreviewInfrastructure.h :
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "DrawPreviewInfrastructure.generated.h"
UCLASS()
class CITYBUILDER_API ADrawPreviewInfrastructure : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ADrawPreviewInfrastructure();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintCallable, Category = "Preview")
bool CollisionPointPolygone(TArray<FVector> Polygone, int32 nbp, FVector Point);
};
DrawPreviewInfrastructure.cpp :
#include "CityBuilder.h"
#include "DrawPreviewInfrastructure.h"
#include "Kismet/KismetMathLibrary.h"
// Sets default values
ADrawPreviewInfrastructure::ADrawPreviewInfrastructure()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
// Called when the game starts or when spawned
void ADrawPreviewInfrastructure::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ADrawPreviewInfrastructure::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
bool ADrawPreviewInfrastructure::CollisionPointPolygone(TArray<FVector> Polygone, int32 nbp, FVector Point){
FVector A, B, D, T;
float d;
UE_LOG(LogTemp, Warning, TEXT("Your message"));
for (int32 i = 0; i<nbp; i++)
{
UE_LOG(LogTemp, Warning, TEXT("test"));
A = Polygone*;
if (i == nbp - 1) // si c'est le dernier point, on relie au premier
B = Polygone[0];
else // sinon on relie au suivant.
B = Polygone[i + 1];
D.X = B.X - A.X;
D.Y = B.Y - A.Y;
T.X = Point.X - A.X;
T.Y = Point.Y - A.Y;
d = D.X*T.Y - D.Y*T.X;
if (d<0)
return false; // un point à droite et on arrête tout.
}
return true; // si on sort du for, c'est qu'aucun point n'est à gauche, donc c'est bon.
}
In DrawPreviewInfrastructure_BP blueprint, which inherits from DrawPreviewInfrastructure, i call CollisionPointPolygone() function, but the UE_LOG message is not displayed in the output log window. I launch the game in standalone game mode. Why so please ?