Skip to content

Commit

Permalink
Merge pull request #5 from Panakotta00/development
Browse files Browse the repository at this point in the history
Merge Update v0.2.2
  • Loading branch information
Panakotta00 authored Feb 1, 2022
2 parents 67cce68 + 6a208e8 commit 0af7d42
Show file tree
Hide file tree
Showing 24 changed files with 700 additions and 144 deletions.
2 changes: 1 addition & 1 deletion FicsItCam.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"FileVersion": 3,
"Version": 0,
"VersionName": "0.2",
"SemVersion": "0.2.0",
"SemVersion": "0.2.2",
"FriendlyName": "FicsIt-Cam",
"Description": "This mod allows you to create beautiful camera animations in-game.",
"Category": "Modding",
Expand Down
20 changes: 16 additions & 4 deletions Source/FicsItCam/FICAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,25 @@ void FFICFloatAttribute::RecalculateKeyframe(int64 Time) {
}
}

void FFICFloatAttribute::Set(TSharedPtr<FFICAttribute> InAttrib) {
FOnUpdate OnUpdateBuf = OnUpdate;
if (InAttrib && InAttrib->GetAttributeType() == GetAttributeType()) {
*this = *StaticCastSharedPtr<FFICFloatAttribute>(InAttrib);
}
OnUpdate = OnUpdateBuf;
OnUpdate.Broadcast();
}

TSharedPtr<FFICAttribute> FFICFloatAttribute::Get() {
return MakeShared<FFICFloatAttribute>(*this);
}

FFICFloatKeyframe* FFICFloatAttribute::SetKeyframe(int64 Time, FFICFloatKeyframe Keyframe) {
FFICFloatKeyframe* KF = &Keyframes.FindOrAdd(Time);
*KF = Keyframe;
return KF;
}
#pragma optimize("", off)

float FFICFloatAttribute::GetValue(float Time) {
float Time1 = TNumericLimits<float>::Lowest();
FFICFloatKeyframe KF1;
Expand Down Expand Up @@ -244,7 +257,6 @@ float FFICFloatAttribute::GetValue(float Time) {
}
return Interpolated;
}
#pragma optimize("", on)

TMap<int64, TSharedPtr<FFICKeyframeRef>> FFICGroupAttribute::GetKeyframes() {
TMap<int64, TSharedPtr<FFICKeyframeRef>> Keyframes;
Expand Down Expand Up @@ -317,9 +329,9 @@ void AFICAnimation::RecalculateAllKeyframes() {
}

float AFICAnimation::GetEndOfAnimation() {
return AnimationEnd / FPS;
return (float)AnimationEnd / (float)FPS;
}

float AFICAnimation::GetStartOfAnimation() {
return AnimationStart / FPS;
return (float)AnimationStart / (float)FPS;
}
7 changes: 7 additions & 0 deletions Source/FicsItCam/FICAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ struct FFICAttribute {
FOnUpdate OnUpdate;

virtual ~FFICAttribute() = default;
virtual FName GetAttributeType() { return FName(); }
virtual TMap<int64, TSharedPtr<FFICKeyframeRef>> GetKeyframes() { return TMap<int64, TSharedPtr<FFICKeyframeRef>>(); }
virtual EFICKeyframeType GetAllowedKeyframeTypes() const { return FIC_KF_NONE; }
virtual TSharedPtr<FFICKeyframeRef> AddKeyframe(int64 Time) { return nullptr; }
virtual void RemoveKeyframe(int64 Time) {}
virtual void MoveKeyframe(int64 From, int64 To) {}
virtual void RecalculateKeyframe(int64 Time) {}
virtual void Set(TSharedPtr<FFICAttribute> InAttrib) {}
virtual TSharedPtr<FFICAttribute> Get() { return nullptr; }

void RecalculateAllKeyframes();
bool GetNextKeyframe(int64 Time, int64& outTime, TSharedPtr<FFICKeyframeRef>& outKeyframe);
Expand Down Expand Up @@ -131,12 +134,15 @@ struct FFICFloatAttribute : public FFICAttribute {
float FallBackValue = 0.0f;

// Begin FFICAttribute
virtual FName GetAttributeType() { return FName(TEXT("FloatAttribute")); }
virtual TMap<int64, TSharedPtr<FFICKeyframeRef>> GetKeyframes() override;
virtual EFICKeyframeType GetAllowedKeyframeTypes() const override;
virtual TSharedPtr<FFICKeyframeRef> AddKeyframe(int64 Time) override;
virtual void RemoveKeyframe(int64 Time) override;
virtual void MoveKeyframe(int64 From, int64 To) override;
virtual void RecalculateKeyframe(int64 Time) override;
virtual void Set(TSharedPtr<FFICAttribute> InAttrib) override;
virtual TSharedPtr<FFICAttribute> Get() override;
// End FFICAttribute

FFICFloatKeyframe* SetKeyframe(int64 Time, FFICFloatKeyframe Keyframe);
Expand All @@ -152,6 +158,7 @@ struct FFICGroupAttribute : public FFICAttribute {
TMap<FString, TAttribute<FFICAttribute*>> Children;

// Begin FFICAttribute
virtual FName GetAttributeType() { return FName(TEXT("GroupAttribute")); }
virtual TMap<int64, TSharedPtr<FFICKeyframeRef>> GetKeyframes() override;
virtual EFICKeyframeType GetAllowedKeyframeTypes() const override;
virtual TSharedPtr<FFICKeyframeRef> AddKeyframe(int64 Time) override;
Expand Down
16 changes: 16 additions & 0 deletions Source/FicsItCam/FICCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ EExecutionStatus AFICCommand::ExecuteCommand_Implementation(UCommandSender* Send
Sender->SendChatMessage("Timelapse-Camera '" + CameraName + "' stopped.");
return EExecutionStatus::COMPLETED;
}
} else if (Arguments[1] == "tp") {
if (Arguments.Num() < 3) {
Sender->SendChatMessage(TEXT("Syntax: /fic timelapse stop <name>"), FColor::Red);
return EExecutionStatus::BAD_ARGUMENTS;
}
FString CameraName = FString::Printf(TEXT("%s-Timelapse"), *Arguments[2]);
if (!SubSys->TimelapseCameras.Contains(CameraName)) {
Sender->SendChatMessage("Timelapse-Camera '" + CameraName + "' doesn't exists.");
return EExecutionStatus::UNCOMPLETED;
} else {
AFICTimelapseCamera* timelapseCamera = SubSys->TimelapseCameras[CameraName];
Sender->GetPlayer()->GetCharacter()->SetActorLocation(timelapseCamera->CaptureComponent->GetComponentLocation());
Sender->GetPlayer()->SetControlRotation(timelapseCamera->CaptureComponent->GetComponentRotation());
Sender->SendChatMessage("Teleported to Timelapse-Camera '" + CameraName + "'.");
return EExecutionStatus::COMPLETED;
}
}
}
Sender->SendChatMessage(TEXT("No valid Sub-Subcommand!"), FColor::Red);
Expand Down
Loading

0 comments on commit 0af7d42

Please sign in to comment.