diff --git a/Unreal/Environments/Blocks/Blocks.uproject b/Unreal/Environments/Blocks/Blocks.uproject index 589d42e59d..4740a3a5e5 100644 --- a/Unreal/Environments/Blocks/Blocks.uproject +++ b/Unreal/Environments/Blocks/Blocks.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "4.27", + "EngineAssociation": "5.0", "Category": "", "Description": "", "Modules": [ diff --git a/Unreal/Plugins/AirSim/AirSim.uplugin b/Unreal/Plugins/AirSim/AirSim.uplugin index 8d0420b2b2..74c9d517e4 100644 --- a/Unreal/Plugins/AirSim/AirSim.uplugin +++ b/Unreal/Plugins/AirSim/AirSim.uplugin @@ -22,9 +22,9 @@ } ], "Plugins": [ - { - "Name": "PhysXVehicles", - "Enabled": true - } + { + "Name": "ChaosVehiclesPlugin", + "Enabled": true + } ] } diff --git a/Unreal/Plugins/AirSim/Source/AirSim.Build.cs b/Unreal/Plugins/AirSim/Source/AirSim.Build.cs index 17024a35b6..bb9e354317 100644 --- a/Unreal/Plugins/AirSim/Source/AirSim.Build.cs +++ b/Unreal/Plugins/AirSim/Source/AirSim.Build.cs @@ -78,7 +78,7 @@ public AirSim(ReadOnlyTargetRules Target) : base(Target) bEnableExceptions = true; - PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ImageWrapper", "RenderCore", "RHI", "AssetRegistry", "PhysicsCore", "PhysXVehicles", "PhysXVehicleLib", "PhysX", "APEX", "Landscape", "CinematicCamera" }); + PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ImageWrapper", "RenderCore", "RHI", "PhysicsCore", "APEX", "AssetRegistry", "ChaosVehicles", "Landscape", "CinematicCamera" }); PrivateDependencyModuleNames.AddRange(new string[] { "UMG", "Slate", "SlateCore" }); //suppress VC++ proprietary warnings diff --git a/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp b/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp index 75a689e94e..9fa99abaab 100644 --- a/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp +++ b/Unreal/Plugins/AirSim/Source/PawnSimApi.cpp @@ -229,7 +229,7 @@ msr::airlib::RCData PawnSimApi::getRCData() const void PawnSimApi::displayCollisionEffect(FVector hit_location, const FHitResult& hit) { - if (params_.collision_display_template != nullptr && Utils::isDefinitelyLessThan(hit.ImpactNormal.Z, 0.0f)) { + if (params_.collision_display_template != nullptr && Utils::isDefinitelyLessThan(hit.ImpactNormal.Z, 0.0f)) { UParticleSystemComponent* particles = UGameplayStatics::SpawnEmitterAtLocation(params_.pawn->GetWorld(), params_.collision_display_template, FTransform(hit_location), diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp index db41000a1a..50f54a6a11 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.cpp @@ -4,7 +4,7 @@ #include "Components/TextRenderComponent.h" #include "Components/AudioComponent.h" #include "Sound/SoundCue.h" -#include "WheeledVehicleMovementComponent4W.h" +#include "ChaosWheeledVehicleMovementComponent.h" #include "CarWheelFront.h" #include "CarWheelRear.h" @@ -85,32 +85,33 @@ ACarPawn::ACarPawn() void ACarPawn::setupVehicleMovementComponent() { - UWheeledVehicleMovementComponent4W* movement = CastChecked(getVehicleMovementComponent()); + UChaosWheeledVehicleMovementComponent* movement = CastChecked(getVehicleMovementComponent()); + movement->WheelSetups.SetNum(4); check(movement->WheelSetups.Num() == 4); // Wheels/Tires // Setup the wheels movement->WheelSetups[0].WheelClass = UCarWheelFront::StaticClass(); - movement->WheelSetups[0].BoneName = FName("PhysWheel_FL"); + movement->WheelSetups[0].BoneName = FName("WheelFL"); movement->WheelSetups[0].AdditionalOffset = FVector(0.f, -8.f, 0.f); movement->WheelSetups[1].WheelClass = UCarWheelFront::StaticClass(); - movement->WheelSetups[1].BoneName = FName("PhysWheel_FR"); + movement->WheelSetups[1].BoneName = FName("WheelFR"); movement->WheelSetups[1].AdditionalOffset = FVector(0.f, 8.f, 0.f); movement->WheelSetups[2].WheelClass = UCarWheelRear::StaticClass(); - movement->WheelSetups[2].BoneName = FName("PhysWheel_BL"); + movement->WheelSetups[2].BoneName = FName("WheelBL"); movement->WheelSetups[2].AdditionalOffset = FVector(0.f, -8.f, 0.f); movement->WheelSetups[3].WheelClass = UCarWheelRear::StaticClass(); - movement->WheelSetups[3].BoneName = FName("PhysWheel_BR"); + movement->WheelSetups[3].BoneName = FName("WheelBR"); movement->WheelSetups[3].AdditionalOffset = FVector(0.f, 8.f, 0.f); // Adjust the tire loading - movement->MinNormalizedTireLoad = 0.0f; - movement->MinNormalizedTireLoadFiltered = 0.2308f; - movement->MaxNormalizedTireLoad = 2.0f; - movement->MaxNormalizedTireLoadFiltered = 2.0f; + //movement->MinNormalizedTireLoad = 0.0f; + //movement->MinNormalizedTireLoadFiltered = 0.2308f; + //movement->MaxNormalizedTireLoad = 2.0f; + //movement->MaxNormalizedTireLoadFiltered = 2.0f; // Engine // Torque setup @@ -121,22 +122,22 @@ void ACarPawn::setupVehicleMovementComponent() movement->EngineSetup.TorqueCurve.GetRichCurve()->AddKey(5730.0f, 400.0f); // Adjust the steering - movement->SteeringCurve.GetRichCurve()->Reset(); - movement->SteeringCurve.GetRichCurve()->AddKey(0.0f, 1.0f); - movement->SteeringCurve.GetRichCurve()->AddKey(40.0f, 0.7f); - movement->SteeringCurve.GetRichCurve()->AddKey(120.0f, 0.6f); + movement->SteeringSetup.SteeringCurve.GetRichCurve()->Reset(); + movement->SteeringSetup.SteeringCurve.GetRichCurve()->AddKey(0.0f, 1.0f); + movement->SteeringSetup.SteeringCurve.GetRichCurve()->AddKey(40.0f, 0.7f); + movement->SteeringSetup.SteeringCurve.GetRichCurve()->AddKey(120.0f, 0.6f); // Transmission // We want 4wd - movement->DifferentialSetup.DifferentialType = EVehicleDifferential4W::LimitedSlip_4W; + movement->DifferentialSetup.DifferentialType = EVehicleDifferential::AllWheelDrive; // Drive the front wheels a little more than the rear movement->DifferentialSetup.FrontRearSplit = 0.65; // Automatic gearbox - movement->TransmissionSetup.bUseGearAutoBox = true; - movement->TransmissionSetup.GearSwitchTime = 0.15f; - movement->TransmissionSetup.GearAutoBoxLatency = 1.0f; + movement->TransmissionSetup.bUseAutomaticGears = true; + movement->TransmissionSetup.GearChangeTime = 0.15f; + //movement->TransmissionSetup.GearAutoBoxLatency = 1.0f; // Disable reverse as brake, this is needed for SetBreakInput() to take effect movement->bReverseAsBrake = false; @@ -147,10 +148,11 @@ void ACarPawn::setupVehicleMovementComponent() if (primitive) { primitive->BodyInstance.COMNudge = FVector(8.0f, 0.0f, 0.0f); } - + movement->UpdatedPrimitive = primitive; // Set the inertia scale. This controls how the mass of the vehicle is distributed. movement->InertiaTensorScale = FVector(1.0f, 1.333f, 1.2f); - movement->bDeprecatedSpringOffsetMode = true; + //movement->bDeprecatedSpringOffsetMode = true; + movement->bAutoRegisterUpdatedComponent = true; } void ACarPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, class UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, @@ -159,7 +161,7 @@ void ACarPawn::NotifyHit(class UPrimitiveComponent* MyComp, class AActor* Other, pawn_events_.getCollisionSignal().emit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit); } -UWheeledVehicleMovementComponent* ACarPawn::getVehicleMovementComponent() const +UChaosVehicleMovementComponent* ACarPawn::getVehicleMovementComponent() const { return GetVehicleMovement(); } @@ -250,8 +252,9 @@ void ACarPawn::Tick(float Delta) updateInCarHUD(); // Pass the engine RPM to the sound component - float RPMToAudioScale = 2500.0f / GetVehicleMovement()->GetEngineMaxRotationSpeed(); - engine_sound_audio_->SetFloatParameter(FName("RPM"), GetVehicleMovement()->GetEngineRotationSpeed() * RPMToAudioScale); + UChaosWheeledVehicleMovementComponent* movement = CastChecked(getVehicleMovementComponent()); + float RPMToAudioScale = 2500.0f / movement->GetEngineMaxRotationSpeed(); + engine_sound_audio_->SetFloatParameter(FName("RPM"), movement->GetEngineRotationSpeed() * RPMToAudioScale); pawn_events_.getPawnTickSignal().emit(Delta); } @@ -283,9 +286,10 @@ void ACarPawn::updateHUDStrings() last_gear_ = (Gear == 0) ? LOCTEXT("N", "N") : FText::AsNumber(Gear); } + UChaosWheeledVehicleMovementComponent* movement = CastChecked(getVehicleMovementComponent()); UAirBlueprintLib::LogMessage(TEXT("Speed: "), last_speed_.ToString(), LogDebugLevel::Informational); UAirBlueprintLib::LogMessage(TEXT("Gear: "), last_gear_.ToString(), LogDebugLevel::Informational); - UAirBlueprintLib::LogMessage(TEXT("RPM: "), FText::AsNumber(GetVehicleMovement()->GetEngineRotationSpeed()).ToString(), LogDebugLevel::Informational); + UAirBlueprintLib::LogMessage(TEXT("RPM: "), FText::AsNumber(movement->GetEngineRotationSpeed()).ToString(), LogDebugLevel::Informational); } void ACarPawn::updateInCarHUD() diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.h b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.h index 16f12f9c72..f8637b7bc0 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.h +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawn.h @@ -1,7 +1,8 @@ #pragma once #include "CoreMinimal.h" -#include "WheeledVehicle.h" +#include "ChaosWheeledVehicleMovementComponent.h" +#include "WheeledVehiclePawn.h" #include "Components/SkeletalMeshComponent.h" #include "PhysicalMaterials/PhysicalMaterial.h" #include "UObject/ConstructorHelpers.h" @@ -26,7 +27,7 @@ class UInputComponent; class UAudioComponent; UCLASS(config = Game) -class ACarPawn : public AWheeledVehicle +class ACarPawn : public AWheeledVehiclePawn { GENERATED_BODY() @@ -46,7 +47,7 @@ class ACarPawn : public AWheeledVehicle { return &pawn_events_; } - UWheeledVehicleMovementComponent* getVehicleMovementComponent() const; + UChaosVehicleMovementComponent* getVehicleMovementComponent() const; const msr::airlib::CarApiBase::CarControls& getKeyBoardControls() const { return keyboard_controls_; diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.cpp index 3a0272d19b..e0f3e3d7b1 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.cpp @@ -1,13 +1,13 @@ #include "CarPawnApi.h" #include "AirBlueprintLib.h" -#include "PhysXVehicleManager.h" +#include "ChaosVehicleManager.h" CarPawnApi::CarPawnApi(ACarPawn* pawn, const msr::airlib::Kinematics::State* pawn_kinematics, msr::airlib::CarApiBase* vehicle_api) : pawn_(pawn), pawn_kinematics_(pawn_kinematics), vehicle_api_(vehicle_api) { - movement_ = pawn->GetVehicleMovement(); + movement_ = CastChecked(pawn->GetVehicleMovement()); } void CarPawnApi::updateMovement(const msr::airlib::CarApiBase::CarControls& controls) @@ -23,7 +23,7 @@ void CarPawnApi::updateMovement(const msr::airlib::CarApiBase::CarControls& cont movement_->SetSteeringInput(controls.steering); movement_->SetBrakeInput(controls.brake); movement_->SetHandbrakeInput(controls.handbrake); - movement_->SetUseAutoGears(!controls.is_manual_gear); + movement_->SetUseAutomaticGears(!controls.is_manual_gear); } msr::airlib::CarApiBase::CarState CarPawnApi::getCarState() const @@ -56,15 +56,15 @@ void CarPawnApi::reset() movement_->SetActive(true, true); vehicle_api_->setCarControls(msr::airlib::CarApiBase::CarControls()); updateMovement(msr::airlib::CarApiBase::CarControls()); - - auto pv = movement_->PVehicle; - if (pv) { - pv->mWheelsDynData.setToRestState(); - } - auto pvd = movement_->PVehicleDrive; - if (pvd) { - pvd->mDriveDynData.setToRestState(); - } + movement_->ResetVehicleState(); + //auto pv = movement_->PVehicle; + //if (pv) { + // pv->mWheelsDynData.setToRestState(); + //} + //auto pvd = movement_->PVehicleDrive; + //if (pvd) { + // pvd->mDriveDynData.setToRestState(); + //} }, true); diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.h b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.h index 7bb391bdbc..301b137ceb 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.h +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnApi.h @@ -1,7 +1,7 @@ #pragma once #include "vehicles/car/api/CarApiBase.hpp" -#include "WheeledVehicleMovementComponent4W.h" +#include "ChaosWheeledVehicleMovementComponent.h" #include "physics/Kinematics.hpp" #include "CarPawn.h" @@ -23,7 +23,7 @@ class CarPawnApi virtual ~CarPawnApi(); private: - UWheeledVehicleMovementComponent* movement_; + UChaosWheeledVehicleMovementComponent* movement_; msr::airlib::CarApiBase::CarControls last_controls_; ACarPawn* pawn_; const msr::airlib::Kinematics::State* pawn_kinematics_; diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnSimApi.h b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnSimApi.h index fe09411a69..5c7a906b34 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnSimApi.h +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarPawnSimApi.h @@ -1,7 +1,7 @@ #pragma once #include "CoreMinimal.h" -#include "WheeledVehicleMovementComponent4W.h" +#include "ChaosWheeledVehicleMovementComponent.h" #include "CarPawn.h" #include "CarPawnApi.h" diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.cpp index 72afaeea80..6346306993 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.cpp @@ -1,26 +1,22 @@ // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "CarWheelFront.h" -#include "TireConfig.h" #include "UObject/ConstructorHelpers.h" UCarWheelFront::UCarWheelFront() { - ShapeRadius = 18.f; - ShapeWidth = 15.0f; - Mass = 20.0f; - DampingRate = 0.25f; + WheelRadius = 38.f; + WheelWidth = 17.0f; + //WheelMass = 20.0f; bAffectedByHandbrake = false; - SteerAngle = 40.f; + bAffectedBySteering = true; + MaxSteerAngle = 50.f; + AxleType = EAxleType::Front; // Setup suspension forces - SuspensionForceOffset = 0.0f; + SuspensionForceOffset = FVector(0.0f, 0.0f, 0.0f); SuspensionMaxRaise = 10.0f; SuspensionMaxDrop = 10.0f; - SuspensionNaturalFrequency = 9.0f; - SuspensionDampingRatio = 1.05f; - - // Find the tire object and set the data for it - static ConstructorHelpers::FObjectFinder TireData(TEXT("/AirSim/VehicleAdv/Vehicle/WheelData/Vehicle_FrontTireConfig.Vehicle_FrontTireConfig")); - TireConfig = TireData.Object; + //SuspensionNaturalFrequency = 9.0f; + SuspensionDampingRatio = 1.5f; } diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.h b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.h index fd9d088d99..44f098d114 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.h +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelFront.h @@ -3,11 +3,11 @@ #pragma once #include "CoreMinimal.h" -#include "VehicleWheel.h" +#include "ChaosVehicleWheel.h" #include "CarWheelFront.generated.h" UCLASS() -class UCarWheelFront : public UVehicleWheel +class UCarWheelFront : public UChaosVehicleWheel { GENERATED_BODY() diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.cpp b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.cpp index d7ce40aac5..30c9caa379 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.cpp +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.cpp @@ -1,24 +1,21 @@ // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved. #include "CarWheelRear.h" -#include "TireConfig.h" +//#include "TireConfig.h" #include "UObject/ConstructorHelpers.h" UCarWheelRear::UCarWheelRear() { - ShapeRadius = 18.f; - ShapeWidth = 15.0f; + WheelRadius = 38.f; + WheelWidth = 17.0f; bAffectedByHandbrake = true; - SteerAngle = 0.f; + MaxSteerAngle = 0.f; + AxleType = EAxleType::Rear; // Setup suspension forces - SuspensionForceOffset = -0.0f; + SuspensionForceOffset = FVector(0.0f, 0.0f, 0.0f); SuspensionMaxRaise = 10.0f; SuspensionMaxDrop = 10.0f; - SuspensionNaturalFrequency = 9.0f; - SuspensionDampingRatio = 1.05f; - - // Find the tire object and set the data for it - static ConstructorHelpers::FObjectFinder TireData(TEXT("/AirSim/VehicleAdv/Vehicle/WheelData/Vehicle_BackTireConfig.Vehicle_BackTireConfig")); - TireConfig = TireData.Object; + //SuspensionNaturalFrequency = 9.0f; + SuspensionDampingRatio = 1.5f; } diff --git a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.h b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.h index 6bd933747c..64b5df89c1 100644 --- a/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.h +++ b/Unreal/Plugins/AirSim/Source/Vehicles/Car/CarWheelRear.h @@ -3,11 +3,11 @@ #pragma once #include "CoreMinimal.h" -#include "VehicleWheel.h" +#include "ChaosVehicleWheel.h" #include "CarWheelRear.generated.h" UCLASS() -class UCarWheelRear : public UVehicleWheel +class UCarWheelRear : public UChaosVehicleWheel { GENERATED_BODY()