Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TArray<int32> ABenchmark::M_CleanGetInstancesOverlappingBox(const FBox& InBox, bool bBoxInWorldSpace, UInstancedStaticMeshComponent* ISMToAnalyze, UInstancedStaticMeshComponent* ISMRef) const
- {
- TArray<int32> Result;
- if (UStaticMesh* Mesh = ISMRef->GetStaticMesh())
- {
- FBox Box(InBox);
- if (bBoxInWorldSpace)
- {
- Box = Box.TransformBy(ISMRef->GetComponentTransform().Inverse());
- }
- FTransform ComponentTransform = ISMToAnalyze->GetComponentTransform();
- const FVector StaticMeshBoundsExtent = Mesh->GetBounds().BoxExtent;
- for (int32 Index = 0; Index < ISMToAnalyze->PerInstanceSMData.Num(); Index++)
- {
- const FMatrix& Matrix2 = ISMToAnalyze->PerInstanceSMData[Index].Transform;
- FVector WorldPosition = ComponentTransform.TransformPosition(Matrix2.GetOrigin());
- FBox InstanceBox(WorldPosition - StaticMeshBoundsExtent, WorldPosition + StaticMeshBoundsExtent);
- if (Box.Intersect(InstanceBox))
- {
- Result.Add(Index);
- }
- }
- }
- return Result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement