Changes from the Pull Request

This commit is contained in:
bernatx 2019-04-25 18:04:38 +02:00 committed by nsubiron
parent a407c44ea3
commit be61f80caf
5 changed files with 21 additions and 62 deletions

View File

@ -4,12 +4,12 @@
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
// #include "Carla.h"
#include "Carla/Actor/ActorDescription.h"
#include "Carla/Walker/WalkerControl.h"
#include "Carla/Walker/WalkerController.h"
#include "CarlaRecorder.h"
#include "CarlaReplayerHelper.h"
#include "Carla/Actor/ActorDescription.h"
#include "Carla/Walker/WalkerController.h"
#include "Carla/Walker/WalkerControl.h"
#include <ctime>
#include <sstream>

View File

@ -8,19 +8,21 @@
// #include "GameFramework/Actor.h"
#include <fstream>
#include "CarlaRecorderInfo.h"
#include "CarlaRecorderFrames.h"
#include "Carla/Actor/ActorDescription.h"
#include "CarlaRecorderAnimVehicle.h"
#include "CarlaRecorderAnimWalker.h"
#include "CarlaRecorderCollision.h"
#include "CarlaRecorderEventAdd.h"
#include "CarlaRecorderEventDel.h"
#include "CarlaRecorderEventParent.h"
#include "CarlaRecorderCollision.h"
#include "CarlaRecorderFrames.h"
#include "CarlaRecorderInfo.h"
#include "CarlaRecorderPosition.h"
#include "CarlaRecorderState.h"
#include "CarlaRecorderAnimVehicle.h"
#include "CarlaRecorderAnimWalker.h"
#include "CarlaRecorderQuery.h"
#include "CarlaRecorderState.h"
#include "CarlaReplayer.h"
#include "Carla/Actor/ActorDescription.h"
#include "CarlaRecorder.generated.h"

View File

@ -7,15 +7,16 @@
#pragma once
#include <fstream>
#include "CarlaRecorderInfo.h"
#include "CarlaRecorderFrames.h"
#include "CarlaRecorderAnimWalker.h"
#include "CarlaRecorderCollision.h"
#include "CarlaRecorderEventAdd.h"
#include "CarlaRecorderEventDel.h"
#include "CarlaRecorderEventParent.h"
#include "CarlaRecorderCollision.h"
#include "CarlaRecorderFrames.h"
#include "CarlaRecorderInfo.h"
#include "CarlaRecorderPosition.h"
#include "CarlaRecorderState.h"
#include "CarlaRecorderAnimWalker.h"
class CarlaRecorderQuery
{

View File

@ -4,11 +4,11 @@
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "CarlaReplayerHelper.h"
#include "Carla/Actor/ActorView.h"
#include "Carla/Actor/ActorDescription.h"
#include "Carla/Walker/WalkerController.h"
#include "Carla/Actor/ActorView.h"
#include "Carla/Walker/WalkerControl.h"
#include "Carla/Walker/WalkerController.h"
#include "CarlaReplayerHelper.h"
// create or reuse an actor for replaying
std::pair<int, FActorView>CarlaReplayerHelper::TryToCreateReplayerActor(
@ -242,60 +242,21 @@ bool CarlaReplayerHelper::ProcessReplayerPosition(CarlaRecorderPosition Pos1, Ca
// assign position 1
Location = FVector(Pos1.Location);
Rotation = FRotator::MakeFromEuler(Pos1.Rotation);
// reset velocities
// ResetVelocities(Actor);
}
else
{
// interpolate positions
Location = FMath::Lerp(FVector(Pos1.Location), FVector(Pos2.Location), Per);
Rotation = FMath::Lerp(FRotator::MakeFromEuler(Pos1.Rotation), FRotator::MakeFromEuler(Pos2.Rotation), Per);
// apply new velocities
// FVector Vel((Location - FVector(Pos1.Location)) / DeltaTime);
// FVector Rot((Rotation - FRotator::MakeFromEuler(Pos1.Rotation)).Euler() / DeltaTime);
// SetVelocities(Actor, Vel, Rot);
// UE_LOG(LogCarla, Log, TEXT("Set velocities for %d at [%f,%f,%f] [%f,%f,%f]"), Pos1.DatabaseId, Vel.X, Vel.Y, Vel.Z, Rot.X, Rot.Y, Rot.Z);
}
// set new transform
FTransform Trans(Rotation, Location, FVector(1, 1, 1));
Actor->SetActorTransform(Trans, false, nullptr, ETeleportType::None);
// Actor->SetActorTransform(Trans, false, nullptr, ETeleportType::TeleportPhysics);
return true;
}
return false;
}
// reset velocity vectors on actor
void CarlaReplayerHelper::ResetVelocities(AActor *Actor)
{
if (Actor && !Actor->IsPendingKill())
{
auto RootComponent = Cast<UPrimitiveComponent>(Actor->GetRootComponent());
if (RootComponent != nullptr)
{
FVector Vector(0, 0, 0);
// reset velocities
RootComponent->SetPhysicsLinearVelocity(Vector, false, "None");
RootComponent->SetPhysicsAngularVelocityInDegrees(Vector, false, "None");
}
}
}
// apply new velocities
void CarlaReplayerHelper::SetVelocities(AActor *Actor, FVector Linear, FVector Angular)
{
if (Actor && !Actor->IsPendingKill())
{
auto RootComponent = Cast<UPrimitiveComponent>(Actor->GetRootComponent());
if (RootComponent != nullptr)
{
// velocities
RootComponent->SetPhysicsLinearVelocity(Linear, false, "None");
RootComponent->SetPhysicsAngularVelocityInDegrees(Angular, false, "None");
}
}
}
// reposition the camera
bool CarlaReplayerHelper::SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
{
@ -379,7 +340,6 @@ void CarlaReplayerHelper::ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walk
FWalkerControl Control;
Control.Speed = Walker.Speed;
Controller->ApplyWalkerControl(Control);
// UE_LOG(LogCarla, Log, TEXT("Set Speed for %f"), Control.Speed);
}
}
}

View File

@ -68,8 +68,4 @@ private:
bool SetActorSimulatePhysics(FActorView &ActorView, bool bEnabled);
// enable / disable autopilot for an actor
bool SetActorAutopilot(FActorView &ActorView, bool bEnabled);
// reset velocity vectors on actor
void ResetVelocities(AActor *Actor);
// apply new velocities
void SetVelocities(AActor *Actor, FVector Linear, FVector Angular);
};