Following code works as a work around.
The code updates placement information of instances.
TMap<UFoliageType*, TArray<const FFoliageInstancePlacementInfo*>> AInstancedFoliageActor::GetInstancesForComponent(UActorComponent* InComponent) { TMap<UFoliageType*, TArray<const FFoliageInstancePlacementInfo*>> Result; const auto BaseId = InstanceBaseCache.GetInstanceBaseId(InComponent); if (BaseId != FFoliageInstanceBaseCache::InvalidBaseId) { #if 0 for (auto& Pair : FoliageInfos) { const FFoliageInfo& Info = *Pair.Value; const auto* InstanceSet = Info.ComponentHash.Find(BaseId); if (InstanceSet) { TArray<const FFoliageInstancePlacementInfo*>& Array = Result.Add(Pair.Key, TArray<const FFoliageInstancePlacementInfo*>()); Array.Empty(InstanceSet->Num()); for (int32 InstanceIndex : *InstanceSet) { const FFoliageInstancePlacementInfo* Instance = &Info.Instances[InstanceIndex]; Array.Add(Instance); } } } #else const auto CurrentBaseInfo = InstanceBaseCache.GetInstanceBaseInfo(BaseId); const auto NewBaseInfo = InstanceBaseCache.UpdateInstanceBaseInfoTransform(InComponent); FMatrix DeltaTransfrom = FTranslationMatrix(-CurrentBaseInfo.CachedLocation) * FInverseRotationMatrix(CurrentBaseInfo.CachedRotation) * FScaleMatrix(NewBaseInfo.CachedDrawScale / CurrentBaseInfo.CachedDrawScale) * FRotationMatrix(NewBaseInfo.CachedRotation) * FTranslationMatrix(NewBaseInfo.CachedLocation); for (auto& Pair : FoliageInfos) { FFoliageInfo& Info = *Pair.Value; const auto* InstanceSet = Info.ComponentHash.Find(BaseId); if (InstanceSet) { TArray<const FFoliageInstancePlacementInfo*>& Array = Result.Add(Pair.Key, TArray<const FFoliageInstancePlacementInfo*>()); Array.Empty(InstanceSet->Num()); for (int32 InstanceIndex : *InstanceSet) { FFoliageInstancePlacementInfo& Instance = Info.Instances[InstanceIndex]; FMatrix NewTransform = FRotationMatrix(Instance.Rotation) * FTranslationMatrix(Instance.Location) * DeltaTransfrom; // Update rotation and position Instance.Location = NewTransform.GetOrigin(); Instance.Rotation = NewTransform.Rotator(); Array.Add(&Instance); } } } #endif } return Result; }
Result:
Foliage instances is placed in wrong location
[Link Removed]
[Link Removed]
How do I set a material as a post-processing material?
How does TextureRenderTarget2D get TArray<uint8> type data?
Why does the REMOVE method of map container remove elements have memory leaks?
What is the difference between Camera and CineCamera?
What controls of umg have mouse wheel events in UE4.27?
How to use the.usf file in the ue4 engine Shader in the material?
Why does UV setting float2(1,1) display incorrectly in the material's custom node?
What ConsoleCommand can be executed to improve the quality of pixel stream images?
How to convert the datasmith scene file to BluePrint. Create animations in BluePrint.
What is the method to dynamically set the original texture when ue4 is running?
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-190262 in the post.
1 |
Component | UE - World Creation - Worldbuilding Tools - Level Instances |
---|---|
Affects Versions | 5.2 |
Target Fix | 5.6 |
Created | Jul 8, 2023 |
---|---|
Updated | Oct 11, 2024 |