Delta time : 1Frame 당 걸리는 시간
ex) 1200 fps -> 1/1200 dt
void CEngine::tick()
{
// Manager Tick
CResMgr::GetInst()->tick();
CTimeMgr::GetInst()->tick();
CKeyMgr::GetInst()->tick();
// FMOD Update
CSound::g_pFMOD->update();
// Level Update
CLevelMgr::GetInst()->tick();
CCollisionMgr::GetInst()->tick();
}
CTimeMgr -> FPS, DT
CGameObject::tick() -> 본인이 소유하고 있는 Component, Script 에게 tick 을 준다.
CLevelMgr -> Level 안에 존재하는 모든 GameObject들이 tick 을 호출받는다.
CCollisionMgr -> Level 내에 GameObject 들의 변경점에 의해 발생한 충돌을 체크한다.
void CEngine::progress()
{
tick();
render();
CEventMgr::GetInst()->tick();
}
tick -> 엔진 매니저 및 레벨, 오브젝트 논리구조 실행
render -> 카메라를 지정, 카메라가 바라보는 시점으로 화면을 윈도우에 그림
CEventMgr::GetInst()->tick(); -> tick 에서 바로 처리가 불가능한 것들을 모아서 지연처리하기 위해 생성.
지연처리 예시
func.cpp
void DestroyObject(CGameObject* _DeletObject)
{
if (_DeletObject->IsDead())
return;
tEvent evn = {};
evn.Type = EVENT_TYPE::DELETE_OBJECT;
evn.wParam = (DWORD_PTR)_DeletObject;
CEventMgr::GetInst()->AddEvent(evn);
}
ex) 몬스터에 유도탄을 여러 발 쐈을 때, 1번 유도탄이 monster에 부딪혔다고 destroy 시키게 된다면 2번, 3번 유도탄은 계속해서 monster 로 접근하고 있는데, 삭제된 주소를 들고 있으니까 메모리가 밀려서 쓰레기 값이 얻어져 이상한 방향으로 갈 수 있다.
그래서 삭제 처리를 EventMgr 로 보내 지연 처리를 한다.
void SpawnGameObject(CGameObject* _NewObject, Vec3 _vWorldPos, int _LayerIdx)
{
_NewObject->Transform()->SetRelativePos(_vWorldPos);
tEvent evn = {};
evn.Type = EVENT_TYPE::CREATE_OBJECT;
evn.wParam = (DWORD_PTR)_NewObject;
evn.lParam = _LayerIdx;
CEventMgr::GetInst()->AddEvent(evn);
}
void SpawnGameObject(CGameObject* _NewObject, Vec3 _vWorldPos, const wstring& _LayerName)
{
_NewObject->Transform()->SetRelativePos(_vWorldPos);
tEvent evn = {};
evn.Type = EVENT_TYPE::CREATE_OBJECT;
evn.wParam = (DWORD_PTR)_NewObject;
evn.lParam = CLevelMgr::GetInst()->GetCurLevel()->FindLayerByName(_LayerName)->GetLayerIndex();
CEventMgr::GetInst()->AddEvent(evn);
}
begin 과 생성자의 차이
begin -> 게임이 시작됐을 때, 그것을 시작으로 보고 해야할 일이 있을 때의 작업들을 배치해둠
레벨이 시작될 때 호출 or 시작 된 레벨에 합류할 때 호출
생성자 -> 객체가 생성되고 호출
'DirectX 11 복습' 카테고리의 다른 글
복습4 (0) | 2023.12.26 |
---|---|
복습3 (0) | 2023.12.26 |
엔진 솔루션 설명 (0) | 2023.12.19 |