Char[] → FString

Char[] ← *FString ↔ FCString

 

Char[]
FString
FCString
Char[]   FString   FCString
Char[]
( *Char )
-> FString <-> FCString
Char[]
( *Char )
<- *FString    

 

FString

FCString

  • 메모리수준 조작이라고 하는데 사실 언제 쓸지 감이 안잡힘 

 

'Unreal > UE Architecture' 카테고리의 다른 글

Gameplay Ability System  (0) 2024.06.13
Cpp -> BP Pipeline 1  (0) 2024.05.17
UE Macro & Reflection System  (0) 2024.05.16
Smart Pointer & Container & Serialize  (0) 2024.05.16
Input  (0) 2024.05.16

Unreal Macro 선언 및 flag

  • UCLASS( )
  • UENUM( )
    • BlueprintType : Blueprint에서 read / write 가능
  • USTRUCT
    • Atomic : 하나단위로 직렬화
    • BlueprintType : Blueprint에서 read / write 가능
  • UFUNCTION( )
    • BlueprintCallable : Blueprint에서 사용 가능
    • Category = <string>("TopCategory|SubCategory|Etc") : function은 필수 항목
  • UPROPERTY( )
    • EditAnywhere / VisibleAnywhere : architecture type / level에 배치된 instance 양쪽에서 수정 가능
    • BlueprintReadWrite / BlueprintReadOnly : blueprint에서 read, write
    • Category = <string> : detail 패널에서 categorizing

 

Refleaction System

클래스 관리, 참조, 접근을 위해 클래스 포맷을 관리하는 시스템

  • C#이나 Java같은 후발 객체지향언어에는 언어자체에서 구현되어있는 개념

 

UBT(unreal build tool) 및 UHT(unreal header tool)을 통해 모사

  • 클래스 생성 시, 클래스에 대한 형태를 관리하는 매크로를 자동 생성
  • 런타임에 클래스 포맷 혹은 포맷분석을 통해 역으로 바이너리 데이터를 탐색/조작하기 위함 ( 자기 자신을 파악 )
  • UHT에 의해 만들어진 리플렉션 포맷 파일은 intermediate 폴더 내에 자동으로 생성
    • 구문이 변경될떄마다 자동으로 수정됨
    • 컴파일 분석 수준의 기능은 제공하지 않음
  • 주 용도
    • 런타임에 class내의 property 접근(읽기/쓰기) ( editor환경 등 )
    • 직렬화
    • 자체적인 GC시스템
  • 주 관리
    • <UClass> {class}::staticclass를 통해 class포맷에 접근 가능 ( 자기자신은 getClass() )
      • createdefaultsubobject(cdo), newobject(runtime)
      • <UProperty> FindPropertyByName
    • 생성자에서 명시한 건 CDO(class default object) 수준에서 관리 ( UClass에서 CDO를 참조함 )
    •  
  • 클래스 하이어라키
    • UField
      • UStruct
        • UClass
        • UScriptStruct
        • UFunction
      • UEnum
      • UProperty

 

'Unreal > UE Architecture' 카테고리의 다른 글

Cpp -> BP Pipeline 1  (0) 2024.05.17
문자열 처리  (0) 2024.05.16
Smart Pointer & Container & Serialize  (0) 2024.05.16
Input  (0) 2024.05.16
기본 구성  (0) 2024.05.16
  • Subsystem 의 자식class들은 자동으로 SubsystemCollection class에 의해 생성, 관리됨
    • ubsystemCollectionBase::Initialize
      에서 생성
    • USubsystem* GetSubsystemInternal(UClass* SubsystemClass) const;
      에서 관리되며, 외부에서는 UWorld.GetSubsystem<class명>( ) 을 통해 접근 가능
      • 주로 static ::get( ) 에 해당 메서드를 연결시키는 듯

'Unreal > UE Class :: UObject' 카테고리의 다른 글

Field  (0) 2024.05.16
기본 구성 리스트  (0) 2024.05.16
Procedural Mesh  (0) 2024.05.16

Smart Pointer

  • 구조
  • 구성
  Own the object Prevent Deletion Unique Property Converted by
TSharedPtr yes yes
(ref counting)
can point null MakeShared()
TSharedRef yes yes must point valid object MakeShareable()
TWeakPtr no no breaks ref cycle  
  • TSharePtr - 참조 카운트 기반 GC, 오브젝트 소유
  • TShareRef - Ptr과 동일하나, null값 미허용
  • TWeakPtr - Ptr과 동일하나, 오브젝트 미소유
  • TUniquePtr - Ptr과 동일하나, 하나의 오브젝트는 여러개의 UniquePtr을 가질 수 없음 ( 소유권 이전은 가능 )
  • ( MakeSharable )

 

Hard, Soft referencing

    • A가 B를 Hard Reference 하고 있다면, A가 로딩될 때 B도 로딩된다.
      반면 A가 B를 Soft Reference 한다면, B 애셋의 경로 등을 string의 형태로 가지고 있다는 뜻이다.

Direct Property Reference (Hard Reference)

    • UPROPERTY를 붙여 변수를 선언하면, 해당 변수(혹은 블루프린트)가 로드될 때 이에 대응하는 애셋 또한 로딩된다.
    • Hard Reference
      /** construction start sound stinger */
      UPROPERTY(EditDefaultsOnly, Category=Building)
      USoundCue* ConstructionStartStinger;

Construction Time Reference (Hard Reference)

    • ConstructorHelpers 클래스를 이용해 애셋을 로딩할 때도 동일하다.
    • Hard Reference
      /** gray health bar texture */
      UPROPERTY()
      class UTexture2D* BarFillTexture;
       
      AStrategyHUD::AStrategyHUD(const FObjectInitializer& ObjectInitializer) :
          Super(ObjectInitializer)
      {
          static ConstructorHelpers::FObjectFinder<UTexture2D> BarFillObj(TEXT("/Game/UI/HUD/BarFill"));
          assert(nullptr != BarFillObj);
          BarFillTexture = BarFillObj.Object;
      }

Indirect Property Reference (Soft Reference)

    • FSoftObjectPath를 이용해 경로를 보관한다. 그 후 TSoftObjectPtr를 사용해 템플릿화 된 코드를 저장한다.
      실제로 애셋을 로딩할 때는 LoadObject<T>() 함수를 호출해야 한다.
    • Soft Reference
      UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category=Building)
      TSoftObjectPtr<UStaticMesh> BaseMesh;
       
      UStaticMesh* GetLazyLoadedMesh()
      {
          if (BaseMesh.IsPending())
          {
              const FSoftObjectPath& AssetRef = BaseMesh.ToStringReference();
              BaseMesh = Cast< UStaticMesh>(Streamable.SynchronousLoad(AssetRef));
          }
          return BaseMesh.Get();
      }

Find / Load Object (Soft Reference)

    • UPROPERTY를 이용하지 않고, 애셋과 경로 정보를 가지고 직접 애셋을 로드할 수 도 있다.
      만약 이미 로드된 애셋(혹은 UObject)을 찾는다면 FindObject<T>()를 사용하면 된다.
      만약 로드되지 않은 애셋을 로드하고 싶다면 LoadObject<T>()를 사용한다.
    • Soft Reference
      AFunctionalTest* TestToRun = FindObject<AFunctionalTest>(TestsOuter, *TestName);
      GridTexture = LoadObject<UTexture2D>(NULL, TEXT("/Engine/EngineMaterials/DefaultWhiteGrid.DefaultWhiteGrid"), NULL, LOAD_None, NULL);

 

Container

  • Common
    • 값복사 : FMemory::Memcpy( {복사될 컨테이너}, {복사할 컨테이너}, 복사할 메모리 크기 ( ex, sizeof(int32) * {복사될 컨테이너}.Num )
    • 언리얼 배열 초기화 : { 값1, 값2, ... 값n }
    • 기본 메서드
      • Num : 배열 길이 반환
      • Add / Emplace : 끝에 값 추가 ( add는 임시변수에 넣은 다음 컨테이너에 복사하므로, 보통 emplace가 낫다는듯 )
    • Contains는 체크용. (if true, get return)값도 얻을거면 Find

 

 

 

  •  TMap
    • key-value map
    • Find( {key} ) → return할때 value의 pointer를 반환하는것에 주의
    • 동적배열이라 iteration 속도 괜춘
    • 해시 기반이라 searching 빠름 ( TSet 형태 따름 )
      • 기본이 key값 Unique. key값 중복 필요하면 TMultiMap 사용
    • TSet의 항목을 TPair<KeyType, ValueType>으로 구성한 구조

 

  • UStruct
    • Generated_body 매크로 선언시, 실제로는 UScriptStruct 클래스로 구현됨
      • 제한적 리플렉션. UPROPERTY만 선언가능, UFUNCTION은 불가
    • F가 접두로 붙음
      • 힙 메모리 할당(포인터 연산) 없이 스택내 데이터로 사용 ( new, newobject 사용 불가 )

 

 

Serialize

  • Path Manager
    • FPaths
      • <FString> Combine ( <FString> PrePath, <FString> PostPath ) : 경로 string을 합쳐주는듯..? 그냥 concat, join이랑 동일한듯..?
        • 사이에 "/" 붙여주는 듯
      • <void> MakeStandardFileName ( <FString> 변환할 ptr ) : 변환할 ptr을 스탠다트 경로로 바꿔줌 ( 절대경로)
        • 현재의 상대경로를 절대경로로 변경 해줌
    • FPlatformMisc
      • <FString> ProjectDir( ) : 프로젝트 루트 경로 반환

 

'Unreal > UE Architecture' 카테고리의 다른 글

Cpp -> BP Pipeline 1  (0) 2024.05.17
문자열 처리  (0) 2024.05.16
UE Macro & Reflection System  (0) 2024.05.16
Input  (0) 2024.05.16
기본 구성  (0) 2024.05.16

컬리전 매트릭스

2개의 object가 서로에 대해 다른 collision 판정을 가지고 있을 때, 더 낮은 충돌단계를 적용

  Object A
Ignore Overlap Block
Object B Ignore Ignore Ignore Ignore
Overlap Ignore Overlap Overlap
Block Ignore Overlap Block

 

 

관련 프로퍼티

Transform Mobility

  • static
  • stationary
  • movable

 

Physics

  • simulate physics ( bool )
  • mass ( kg )
  • force ( N )
  • enable gravity ( bool )
  • constraints

 

 

 

interaction query

  • collide
  • chaos

 

add force

  • crash and physics sim
  • add force ( continuous )
  • add impulse ( 1 frame )
  • damping / friction

 

calc force

  • constraint
    • physics stat ( 축제어 회전3자유도 + 이동3자유도 )
    • constraint component
  • Ignore
    • FieldSystem → kill / sleep
    • transform mobility = static / stationary

 

apply velocity

 

'Unreal > UE Feature' 카테고리의 다른 글

Projectile & Spline  (0) 2024.05.17
AI  (0) 2024.05.17
Texture  (0) 2024.05.17
Modeling  (0) 2024.05.17
(Character) Movement  (0) 2024.05.16

입력 전달 플로우

 

기본 Input Binding Delegate

subsystem인 InputComponent instance의 delegate를 통해 input-action binding하는 구조
InputComponent→BindAxis(" input name ", target instance, & exec function )
InputComponent→BindAction(" input name ", target instance, & exec function )


  • bind axis의 타겟 function은 float 파라미터를 가져야 함
  • input name은 editor - project setting - input 의 keybinding에 할당한 key값


ex)
class hi()
{
  • InputComponent→BindAxis ( "move_forward", this, hi::movef )
  • hi::movef ( float move_f ) { character.move_forward }
}

 

 

 

Enhanced Input System

  • input modifier
  • input action
  • input mapping context

 

구조 개요

회전 입력 전달 경로

  • 이동
    • Pawn :: AddMovementInput
      • Controller Rotation기준으로 forward, right vector 계산

 

Input Action

  • Input Action : 여러 input을 종합해 float1 ~ float3 의 output을 내보낼 수 있는 단위
  • Consume Input : 입력 소모해버리는지 여부?
  • Value Type : bool, float 1 ~ 3 가능하며, modifier에서 각 입력을 어떻게 값으로 변환할지 제어
    • ex. swizzle input axis value - bool이면 ( 1or0 , 0, 0 ) , float 1 이면 ( value, 0, 0 ), float 2면 ( value_x, value_y, 0 ), float 3이면 ( value_x, value_y, value_z ) 이런형태 ( 아래는 인풋타입에 따른 value 생성자. 다음 생성자에서 값 적용

 

Input Modifier

  • 커스텀 타입으로, Input 시, virtual ModifyRaw_Implementation( 인풋, FInputActionValue ( bool ~ float3 ), DeltaTime ) method를 customize하여 → output value를 줄 수 있는 연산모듈
    Input Modifier Class & Modify Raw ( override function )

 

더보기

.h

UCLASS(NotBlueprintable, MinimalAPI, meta = (DisplayName = "Swizzle Input Axis Values"))
class UInputModifierSwizzleAxis : public UInputModifier
{
   GENERATED_BODY()
 
public:
 
   // Default to XY swap, useful for binding 1D inputs to the Y axis.
   UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Settings)
   EInputAxisSwizzle Order = EInputAxisSwizzle::YXZ;
 
protected:
   virtual FInputActionValue ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime) override;
   virtual FLinearColor GetVisualizationColor_Implementation(FInputActionValue SampleValue, FInputActionValue FinalValue) const override;
};

 

.cpp

FInputActionValue UInputModifierSwizzleAxis::ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime)
{
    FVector Value = CurrentValue.Get<FVector>();
    switch (Order)
    {
    case EInputAxisSwizzle::YXZ:
        Swap(Value.X, Value.Y);
        break;
    case EInputAxisSwizzle::ZYX:
        Swap(Value.X, Value.Z);
        break;
    case EInputAxisSwizzle::XZY:
        Swap(Value.Y, Value.Z);
        break;
    case EInputAxisSwizzle::YZX:
        Value = FVector(Value.Y, Value.Z, Value.X);
        break;
    case EInputAxisSwizzle::ZXY:
        Value = FVector(Value.Z, Value.X, Value.Y);
        break;
    }
    return FInputActionValue(CurrentValue.GetValueType(), Value);

axis에 사용되는 swizzle axis 예시

  • bool이면 ( 1or0 , 0, 0 ) , float 1 이면 ( value, 0, 0 ), float 2면 ( value_x, value_y, 0 ), float 3이면 ( value_x, value_y, value_z ) 이런형태 ( 아래는 인풋타입에 따른 value 생성자. 다음 생성자에서 값 적용

 

Input Mapping Context

 

 

입력 설정

활성화된 PlayerController의 Enhanced Input Local Player Subsystem 소켓에  특정 Input Mapping Context를 추가

  • PlayerController
    • Enhanced Input Local Player Subsystem
      • Input Mappings[]
        • ← add Mapping Context
  • Input_Mappin_Context에서 할당했던 [Input_Action]의 이름을 통해 event 연결

 

'Unreal > UE Architecture' 카테고리의 다른 글

Cpp -> BP Pipeline 1  (0) 2024.05.17
문자열 처리  (0) 2024.05.16
UE Macro & Reflection System  (0) 2024.05.16
Smart Pointer & Container & Serialize  (0) 2024.05.16
기본 구성  (0) 2024.05.16

샘플링된 공간단위로 로직을 적용하기 위한 시스템

 

 

 - FS_MasterField
 - Field System Actor
    - Field System Component ( 기본 root )
        - Add Transient Field
            - Target = Component
            - Enable Field = 활성여부인듯 ( 지속작동 막기위해? )
            - Physical Type = 폭발타입 ( external strain은 그냥 임계값 넘으면 자가붕괴인듯 )
            - Meta Data = 몰?루
            - Field Node = component의 "필드"항목들 중 하나 component로 만들고 -> Set ( 컴포넌트이름 ) -> Field Node로 연결
            
    - Prototype
        - Engine - Content - EditorResources - FieldNodes
            - FS_AnchorField_Generic : 부셔지지 않는 필드
            - FS_BombField_Prototype : 폭발모사
            - FS_MasterField : 만능
            - FS_SleepDisable_Generic : Sleep ( physics 완충 + destruction 감쇄 )

'Unreal > UE Class :: UObject' 카테고리의 다른 글

Subsystem  (0) 2024.05.16
기본 구성 리스트  (0) 2024.05.16
Procedural Mesh  (0) 2024.05.16

참고자료

 

 

Character Movement 기본 구조

 

Character Movement 네트워크 구조

Architecture & Example

 

클라이언트 / 서버 파이프라인
  • Check or Input Vector ( from controller.h → [Possess Actor or Binded? ] movementComponent.h? )
  • Controlled Character Move (State adjust) ( movementComponent.h → [movementComp→UpdatedComponent] collisionComponent(or any component which have Location)]
    • delta Time + input Vector 
    • [Input] Vector → [Output] Acceleration ( temporary )
  • Perform Move
    • calc Acceleration → force/Impulse
  • Start New Physics
    • calc force/Impulse → velocity → location ( depend on movement Mode )

 Character movement compoent 구성

하위프로퍼티 변경 -> 물리처리 phase에서 movement mode체크 -> 해당 movement mode의 연산식에의해, 상위프로퍼티 산출 -> movement

 

movement mode

  • character movement component → movement mode
    • 틱마다 호출 ( movement mode == phys_... )
      • Tick → (root motion, movement, etc...) → StartNewPhysics → <UEnum> MovementMode → Phys{None/Walking 등등}
    • Mode 전환 호출
      • SetMovementMode( movementmode, custom enum )
    • 변환시 처리
      • OnMovementModeChanged
        • prev movement mode를 기반으로 종료되는 mode에 대한 처리
        • 만약 시작될때를 기점으로 하고싶다면, setmovementmode가 호출되는 조건 ( IsClimbing등 별도 변수 )를 기준으로 사용하는 듯

 

 

 

Add Force

더보기
void UCharacterMovementComponent::AddForce( FVector Force )
{
    if (HasValidData() && !Force.IsZero())
    {
        if (Mass > SMALL_NUMBER)
        {
            PendingForceToApply += Force / Mass;
        }
        else
        {
            UE_LOG(LogCharacterMovement, Warning, TEXT("Attempt to apply force to zero or negative Mass in CharacterMovement"));
        }
    }
}

 

[Character] BP에서 movementComponent는 root component를 제어함

  • ACharacter class에서 할당
더보기
ACharacter::ACharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
    // ...
 
    RootComponent = CapsuleComponent;
 
    // ...
 
    CharacterMovement = CreateDefaultSubobject<UCharacterMovementComponent>(ACharacter::CharacterMovementComponentName);
    if (CharacterMovement)
    {
        CharacterMovement->UpdatedComponent = CapsuleComponent;
        CrouchedEyeHeight = CharacterMovement->CrouchedHalfHeight * 0.80f;
    }
 
    // ...
 
}

 

프레임 내 최종 위치 결정 순서

 

'Unreal > UE Feature' 카테고리의 다른 글

Projectile & Spline  (0) 2024.05.17
AI  (0) 2024.05.17
Texture  (0) 2024.05.17
Modeling  (0) 2024.05.17
Physics  (0) 2024.05.16

+ Recent posts