Compare commits
7 Commits
87dce70aa5
...
7613ad2811
Author | SHA1 | Date |
---|---|---|
Jose | 7613ad2811 | |
JoseM98 | 1ec58b4cf5 | |
Blyron | bc96c5feb9 | |
Blyron | 200b138dbc | |
JoseMartinez | 19227624d7 | |
JoseMartinez | 914007b2ce | |
JoseMartinez | 5488f1bea6 |
|
@ -1,6 +1,7 @@
|
||||||
## Latest Changes
|
## Latest Changes
|
||||||
* Prevent from segfault on failing SignalReference identification when loading OpenDrive files
|
* Prevent from segfault on failing SignalReference identification when loading OpenDrive files
|
||||||
* Added vehicle doors to the recorder
|
* Added vehicle doors to the recorder
|
||||||
|
* Adjusted vehicle BoundingBox when the vehicle opens the doors.
|
||||||
* Added functions to get actor' components transform
|
* Added functions to get actor' components transform
|
||||||
* Added posibility to Digital Twins to work with local files (osm and xodr)
|
* Added posibility to Digital Twins to work with local files (osm and xodr)
|
||||||
* Enable proper material merging for Building in Digital Twins
|
* Enable proper material merging for Building in Digital Twins
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "Rendering/SkeletalMeshRenderData.h"
|
#include "Rendering/SkeletalMeshRenderData.h"
|
||||||
#include "Engine/SkeletalMeshSocket.h"
|
#include "Engine/SkeletalMeshSocket.h"
|
||||||
|
#include "Kismet/KismetMathLibrary.h"
|
||||||
|
|
||||||
namespace crp = carla::rpc;
|
namespace crp = carla::rpc;
|
||||||
|
|
||||||
|
@ -30,10 +31,11 @@ static FBoundingBox ApplyTransformToBB(
|
||||||
FBoundingBox InBB,
|
FBoundingBox InBB,
|
||||||
const FTransform& Transform)
|
const FTransform& Transform)
|
||||||
{
|
{
|
||||||
auto Scale = Transform.GetScale3D();
|
const auto Scale = Transform.GetScale3D();
|
||||||
|
const auto TransformRotation = Transform.GetRotation().Rotator();
|
||||||
InBB.Origin *= Scale;
|
InBB.Origin *= Scale;
|
||||||
InBB.Rotation = Transform.GetRotation().Rotator();
|
InBB.Rotation = UKismetMathLibrary::ComposeRotators(TransformRotation, InBB.Rotation);
|
||||||
InBB.Origin = InBB.Rotation.RotateVector(InBB.Origin) + Transform.GetLocation();
|
InBB.Origin = TransformRotation.RotateVector(InBB.Origin) + Transform.GetLocation();
|
||||||
InBB.Extent *= Scale;
|
InBB.Extent *= Scale;
|
||||||
return InBB;
|
return InBB;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +185,14 @@ FBoundingBox UBoundingBoxCalculator::GetVehicleBoundingBox(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate bounding boxes of the doors.
|
||||||
|
FBoundingBox DoorsBB = GetVehicleDoorsBoundingBox(Vehicle);
|
||||||
|
if(DoorsBB.Extent != FVector::ZeroVector)
|
||||||
|
{
|
||||||
|
// Combine doors Bounding Box with the vehicle BB.
|
||||||
|
BB = CombineBBs({DoorsBB, BB});
|
||||||
|
}
|
||||||
|
|
||||||
// Component-to-world transform for this component
|
// Component-to-world transform for this component
|
||||||
auto& CompToWorldTransform = ParentComp->GetComponentTransform();
|
auto& CompToWorldTransform = ParentComp->GetComponentTransform();
|
||||||
BB = ApplyTransformToBB(BB, CompToWorldTransform);
|
BB = ApplyTransformToBB(BB, CompToWorldTransform);
|
||||||
|
@ -445,7 +455,7 @@ TArray<FBoundingBox> UBoundingBoxCalculator::GetBBsOfActor(
|
||||||
{
|
{
|
||||||
Result.Add(BoundingBox);
|
Result.Add(BoundingBox);
|
||||||
}
|
}
|
||||||
return Result;;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pedestrians, we just use the capsule component at the moment.
|
// Pedestrians, we just use the capsule component at the moment.
|
||||||
|
@ -645,3 +655,34 @@ void UBoundingBoxCalculator::GetMeshCompsFromActorBoundingBox(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FBoundingBox UBoundingBoxCalculator::GetVehicleDoorsBoundingBox(const ACarlaWheeledVehicle* Vehicle)
|
||||||
|
{
|
||||||
|
FBoundingBox DoorsBB;
|
||||||
|
if(Vehicle && Vehicle->GetConstraintsComponents().Num() > 0)
|
||||||
|
{
|
||||||
|
FBox DoorsBox(ForceInit);
|
||||||
|
const FTransform& ActorToWorld = Vehicle->GetActorTransform();
|
||||||
|
const FTransform WorldToActor = ActorToWorld.Inverse();
|
||||||
|
|
||||||
|
// Iterates over all doors of the vehicle
|
||||||
|
for(const UPhysicsConstraintComponent* ConstraintComp : Vehicle->GetConstraintsComponents())
|
||||||
|
{
|
||||||
|
const UPrimitiveComponent* DoorComponent = Vehicle->GetConstraintDoor()[ConstraintComp];
|
||||||
|
if(const UStaticMeshComponent* StaticMeshComp = Cast<UStaticMeshComponent>(DoorComponent))
|
||||||
|
{
|
||||||
|
const FTransform ComponentToActor = StaticMeshComp->GetComponentTransform() * WorldToActor;
|
||||||
|
DoorsBox += StaticMeshComp->CalcBounds(ComponentToActor).GetBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(DoorsBox.IsValid)
|
||||||
|
{
|
||||||
|
// DoorBB is aligned with the Vehicle orientation, for this reason it is not necessary to assign rotation.
|
||||||
|
DoorsBB.Origin = DoorsBox.GetCenter();
|
||||||
|
DoorsBB.Extent = DoorsBox.GetExtent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoorsBB;
|
||||||
|
}
|
||||||
|
|
|
@ -110,4 +110,7 @@ public:
|
||||||
const FBoundingBox& InBB,
|
const FBoundingBox& InBB,
|
||||||
TArray<UStaticMeshComponent*>& OutStaticMeshComps);
|
TArray<UStaticMeshComponent*>& OutStaticMeshComps);
|
||||||
|
|
||||||
|
// Return the combined BB of all doors of the vehicle, with the same orientation.
|
||||||
|
UFUNCTION(Category = "Carla Actor", BlueprintCallable)
|
||||||
|
static FBoundingBox GetVehicleDoorsBoundingBox(const ACarlaWheeledVehicle* Vehicle);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1085,6 +1085,15 @@ void ACarlaWheeledVehicle::OpenDoorPhys(const EVehicleDoor DoorIdx)
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordDoorChange(DoorIdx, true);
|
RecordDoorChange(DoorIdx, true);
|
||||||
|
|
||||||
|
// Wait until door is max opened to recalculate its bounds.
|
||||||
|
float TimeNeededToHaveItOpened = (AngleLimit + Constraint->ConstraintInstance.AngularRotationOffset.Yaw) / (DoorOpenStrength > 0.f ? DoorOpenStrength : 1.f);
|
||||||
|
TimeNeededToHaveItOpened = TimeNeededToHaveItOpened < 0.f ? TimeNeededToHaveItOpened * -1.f : TimeNeededToHaveItOpened;
|
||||||
|
FTimerHandle DoorMaxOpenRangeTimerHandle;
|
||||||
|
GetWorldTimerManager().SetTimer(DoorMaxOpenRangeTimerHandle, [this]()
|
||||||
|
{
|
||||||
|
AdjustVehicleBounds();
|
||||||
|
}, TimeNeededToHaveItOpened, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaWheeledVehicle::CloseDoorPhys(const EVehicleDoor DoorIdx)
|
void ACarlaWheeledVehicle::CloseDoorPhys(const EVehicleDoor DoorIdx)
|
||||||
|
@ -1099,6 +1108,8 @@ void ACarlaWheeledVehicle::CloseDoorPhys(const EVehicleDoor DoorIdx)
|
||||||
DoorComponent->AttachToComponent(
|
DoorComponent->AttachToComponent(
|
||||||
GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepWorld, true));
|
GetMesh(), FAttachmentTransformRules(EAttachmentRule::KeepWorld, true));
|
||||||
RecordDoorChange(DoorIdx, false);
|
RecordDoorChange(DoorIdx, false);
|
||||||
|
|
||||||
|
AdjustVehicleBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACarlaWheeledVehicle::RecordDoorChange(const EVehicleDoor DoorIdx, bool bIsOpen)
|
void ACarlaWheeledVehicle::RecordDoorChange(const EVehicleDoor DoorIdx, bool bIsOpen)
|
||||||
|
|
|
@ -432,6 +432,10 @@ public:
|
||||||
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
UFUNCTION(Category = "CARLA Wheeled Vehicle", BlueprintCallable)
|
||||||
static void SetPhysicsConstraintAngle(
|
static void SetPhysicsConstraintAngle(
|
||||||
UPhysicsConstraintComponent*Component, const FRotator &NewAngle);
|
UPhysicsConstraintComponent*Component, const FRotator &NewAngle);
|
||||||
|
|
||||||
|
const TArray<UPhysicsConstraintComponent*>& GetConstraintsComponents() const { return ConstraintsComponents; }
|
||||||
|
|
||||||
|
const TMap<UPhysicsConstraintComponent*, UPrimitiveComponent*>& GetConstraintDoor() const {return ConstraintDoor; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue