Adds landscape hack
This commit is contained in:
30
Source/lidarforest/Private/LFLandscapeGrassHack.cpp
Normal file
30
Source/lidarforest/Private/LFLandscapeGrassHack.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#include "LFLandscapeGrassHack.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
ALFLandscapeGrassHack::ALFLandscapeGrassHack()
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
Root = CreateDefaultSubobject<USceneComponent>("Root");
|
||||||
|
RootComponent = Root;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void ALFLandscapeGrassHack::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
UpdateGrass(Landscape);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ALFLandscapeGrassHack::UpdateGrass(ALandscapeProxy* LandscapeToUpdate)
|
||||||
|
{
|
||||||
|
if(!IsValid(LandscapeToUpdate))
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Warning, TEXT("NO landscape has been assigned, cannot recreate grass"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FOccluderVertexArray arr;
|
||||||
|
LandscapeToUpdate->UpdateGrass(arr, true);
|
||||||
|
}
|
||||||
27
Source/lidarforest/Private/MyActor.cpp
Normal file
27
Source/lidarforest/Private/MyActor.cpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "MyActor.h"
|
||||||
|
|
||||||
|
// Sets default values
|
||||||
|
AMyActor::AMyActor()
|
||||||
|
{
|
||||||
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
void AMyActor::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame
|
||||||
|
void AMyActor::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
31
Source/lidarforest/Public/LFLandscapeGrassHack.h
Normal file
31
Source/lidarforest/Public/LFLandscapeGrassHack.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "LandscapeProxy.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "LFLandscapeGrassHack.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class LIDARFOREST_API ALFLandscapeGrassHack : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
ALFLandscapeGrassHack();
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
USceneComponent* Root;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
ALandscapeProxy* Landscape;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
void UpdateGrass(ALandscapeProxy* LandscapeToUpdate);
|
||||||
|
|
||||||
|
};
|
||||||
26
Source/lidarforest/Public/MyActor.h
Normal file
26
Source/lidarforest/Public/MyActor.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "GameFramework/Actor.h"
|
||||||
|
#include "MyActor.generated.h"
|
||||||
|
|
||||||
|
UCLASS()
|
||||||
|
class LIDARFOREST_API AMyActor : public AActor
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Sets default values for this actor's properties
|
||||||
|
AMyActor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Called when the game starts or when spawned
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Called every frame
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
|
};
|
||||||
@@ -8,7 +8,8 @@ public class lidarforest : ModuleRules
|
|||||||
{
|
{
|
||||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||||
|
|
||||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ForestImporter"});
|
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore",
|
||||||
|
"Landscape"});
|
||||||
|
|
||||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||||
|
|
||||||
|
|||||||
@@ -4,3 +4,4 @@
|
|||||||
#include "Modules/ModuleManager.h"
|
#include "Modules/ModuleManager.h"
|
||||||
|
|
||||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, lidarforest, "lidarforest" );
|
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, lidarforest, "lidarforest" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user