Vehicle detection box now is not affected by scale
Exposed hide material distance to bp.
This commit is contained in:
parent
d001e1b78c
commit
2925c33ce0
|
@ -339,8 +339,6 @@ void AVegetationManager::SetMaterialCache(FTileData& TileData)
|
||||||
if (TileData.MaterialInstanceDynamicCache.Num() > 0)
|
if (TileData.MaterialInstanceDynamicCache.Num() > 0)
|
||||||
TileData.MaterialInstanceDynamicCache.Empty();
|
TileData.MaterialInstanceDynamicCache.Empty();
|
||||||
|
|
||||||
#define MATERIAL_HIDE_DISTANCE 350.0f
|
|
||||||
const float Distance = MATERIAL_HIDE_DISTANCE;
|
|
||||||
for (FTileMeshComponent& Element : TileData.TileMeshesCache)
|
for (FTileMeshComponent& Element : TileData.TileMeshesCache)
|
||||||
{
|
{
|
||||||
UInstancedStaticMeshComponent* Mesh = Element.InstancedStaticMeshComponent;
|
UInstancedStaticMeshComponent* Mesh = Element.InstancedStaticMeshComponent;
|
||||||
|
@ -359,7 +357,7 @@ void AVegetationManager::SetMaterialCache(FTileData& TileData)
|
||||||
continue;
|
continue;
|
||||||
MaterialInstanceDynamic->SetScalarParameterValue("ActivateOpacity", 0);
|
MaterialInstanceDynamic->SetScalarParameterValue("ActivateOpacity", 0);
|
||||||
MaterialInstanceDynamic->SetScalarParameterValue("ActivateDebug", 0);
|
MaterialInstanceDynamic->SetScalarParameterValue("ActivateDebug", 0);
|
||||||
MaterialInstanceDynamic->SetScalarParameterValue("Distance", Distance);
|
MaterialInstanceDynamic->SetScalarParameterValue("Distance", HideMaterialDistance);
|
||||||
Mesh->SetMaterial(Index, MaterialInstanceDynamic);
|
Mesh->SetMaterial(Index, MaterialInstanceDynamic);
|
||||||
TileData.MaterialInstanceDynamicCache.Emplace(MaterialInstanceDynamic);
|
TileData.MaterialInstanceDynamicCache.Emplace(MaterialInstanceDynamic);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,10 @@ public:
|
||||||
public:
|
public:
|
||||||
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
||||||
bool DebugMaterials {false};
|
bool DebugMaterials {false};
|
||||||
|
|
||||||
|
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
||||||
|
float HideMaterialDistance {500.0f};
|
||||||
|
|
||||||
//Filters for debug
|
//Filters for debug
|
||||||
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
||||||
bool SpawnBushes {true};
|
bool SpawnBushes {true};
|
||||||
|
@ -105,7 +109,7 @@ public:
|
||||||
float SpawnScale {1.0f};
|
float SpawnScale {1.0f};
|
||||||
|
|
||||||
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
UPROPERTY(Category = "CARLA Vegetation Spwaner", EditDefaultsOnly)
|
||||||
int32 InitialPoolSize {5};
|
int32 InitialPoolSize {10};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
|
@ -214,10 +214,11 @@ void ACarlaWheeledVehicle::UpdateDetectionBox()
|
||||||
ALargeMapManager* LargeMap = UCarlaStatics::GetLargeMapManager(GetWorld());
|
ALargeMapManager* LargeMap = UCarlaStatics::GetLargeMapManager(GetWorld());
|
||||||
if (!IsValid(LargeMap))
|
if (!IsValid(LargeMap))
|
||||||
return;
|
return;
|
||||||
FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(GetActorTransform());
|
const FTransform GlobalTransform = LargeMap->LocalToGlobalTransform(GetActorTransform());
|
||||||
const FVector Vec { DetectionSize, DetectionSize, DetectionSize };
|
const FVector Vec { DetectionSize, DetectionSize, DetectionSize };
|
||||||
FBox Box = FBox(-Vec, Vec);
|
FBox Box = FBox(-Vec, Vec);
|
||||||
FoliageBoundingBox = Box.TransformBy(GlobalTransform);
|
const FTransform NonScaledTransform(GlobalTransform.GetRotation(), GlobalTransform.GetLocation(), {1.0f, 1.0f, 1.0f});
|
||||||
|
FoliageBoundingBox = Box.TransformBy(NonScaledTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TArray<int32> ACarlaWheeledVehicle::GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent* Component) const
|
const TArray<int32> ACarlaWheeledVehicle::GetFoliageInstancesCloseToVehicle(const UInstancedStaticMeshComponent* Component) const
|
||||||
|
|
|
@ -354,7 +354,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(Category = "CARLA Wheeled Vehicle", EditDefaultsOnly)
|
UPROPERTY(Category = "CARLA Wheeled Vehicle", EditDefaultsOnly)
|
||||||
float DetectionSize { 500.0f };
|
float DetectionSize { 750.0f };
|
||||||
|
|
||||||
UPROPERTY(Category = "CARLA Wheeled Vehicle", VisibleAnywhere, BlueprintReadOnly)
|
UPROPERTY(Category = "CARLA Wheeled Vehicle", VisibleAnywhere, BlueprintReadOnly)
|
||||||
FBox FoliageBoundingBox;
|
FBox FoliageBoundingBox;
|
||||||
|
|
Loading…
Reference in New Issue