Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
powercrabman committed Sep 27, 2024
1 parent efd379a commit 7dccf64
Show file tree
Hide file tree
Showing 59 changed files with 416 additions and 171 deletions.
Binary file modified Binaries/Debug/LightPixelShader.cso
Binary file not shown.
Binary file modified Binaries/Debug/LightVertexShader.cso
Binary file not shown.
Binary file modified Binaries/Debug/SimplePixelShader.cso
Binary file not shown.
Binary file modified Binaries/Debug/SimpleVertexShader.cso
Binary file not shown.
1 change: 0 additions & 1 deletion MyD3DFramework/CAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ class CAttribute : public Component
protected:
CAttribute() = default;
};

18 changes: 12 additions & 6 deletions MyD3DFramework/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,49 @@ class Component
assert(m_owner);
return m_owner;
}
inline CM::TypeInfo GetTypeInfo() const { return m_typeInfo; }
inline CM::TypeID GetTypeInfo() const { return m_typeID; }

inline void Enable() { m_enable = true; }
inline void Disable() { m_enable = false; }
inline bool IsEnable() const { return m_enable; }

inline const std::wstring& GetName() const;

protected:
Component();

private:
virtual inline void InitComponent(
const CM::TypeInfo& inTypeInfo,
const CM::TypeID& inTypeID,
GameObject* inOwner,
const std::wstring& inName
) final;

private:
std::wstring m_name = {};

CM::TypeInfo m_typeInfo = {};
CM::TypeID m_typeID = {};
GameObject* m_owner = nullptr;

bool m_enable = true;
};

inline const std::wstring& Component::GetName() const
{
return m_name;
}

inline Component::Component()
{
}

inline void Component::InitComponent(const CM::TypeInfo& inTypeInfo, GameObject* inOwner, const std::wstring& inName)
inline void Component::InitComponent(const CM::TypeID& inTypeID, GameObject* inOwner, const std::wstring& inName)
{
//생성자 간략화를 위해서 사용

assert(inOwner);

m_name = inName;
m_owner = inOwner;
m_typeInfo = inTypeInfo;
m_typeID = inTypeID;
}

9 changes: 6 additions & 3 deletions MyD3DFramework/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class GameObject
{
friend class Renderer; /* 나중에 ObjectManager로 변경 */
friend class Scene;

public:
GameObject();
Expand Down Expand Up @@ -37,8 +37,8 @@ class GameObject
CM::TypeInfo m_typeInfo = {};

//컴포넌트를 저정하는 컨테이너
std::unordered_map<CM::TypeID, std::vector<std::unique_ptr<Component>>> m_compRepo{ 16 };
std::vector<CBehavior*> m_updateCompRepo{ 16 };
std::unordered_map<CM::TypeID, std::vector<std::unique_ptr<Component>>> m_compRepo;
std::vector<CBehavior*> m_updateCompRepo;
};

template<typename CompTy, typename ...Args>
Expand Down Expand Up @@ -111,6 +111,9 @@ inline bool GameObject::HasComponent()
inline GameObject::GameObject()
{
m_objectID = ++ObjectIDCounter;

m_compRepo.reserve(16);
m_updateCompRepo.reserve(16);
}

inline void GameObject::SetTypeInfo(const CM::TypeInfo& inTypeInfo)
Expand Down
8 changes: 7 additions & 1 deletion MyD3DFramework/Macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ inline static classname& GetInst() \

#define NODISCARD [[nodiscard]]

#define USING_SUPER(classname) using Super = classname
#define USING_SUPER(classname) using Super = classname

#ifdef _DEBUG
#define TEMP_TYPE int
#else
#define TEMP_TYPE static_assert(false, "You must change this part! template type fail.")
#endif
3 changes: 3 additions & 0 deletions MyD3DFramework/MyD3DFramework.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<ClInclude Include="ContantBuffers.h" />
<ClInclude Include="CPointLight.h" />
<ClInclude Include="CSpotLight.h" />
<ClInclude Include="CTag.h" />
<ClInclude Include="DevScene.h" />
<ClInclude Include="Effect.h" />
<ClInclude Include="Engine.h" />
Expand Down Expand Up @@ -207,6 +208,7 @@
<ClCompile Include="ContantBuffers.cpp" />
<ClCompile Include="CPointLight.cpp" />
<ClCompile Include="CSpotLight.cpp" />
<ClCompile Include="CTag.cpp" />
<ClCompile Include="DevScene.cpp" />
<ClCompile Include="Effect.cpp" />
<ClCompile Include="Engine.cpp" />
Expand Down Expand Up @@ -272,6 +274,7 @@
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">5.0</ShaderModel>
</None>
<None Include="packages.config" />
<None Include="ObjectRepo Optimize Steragy.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DirectXTK\DirectXTK_Desktop_2022.vcxproj">
Expand Down
29 changes: 18 additions & 11 deletions MyD3DFramework/MyD3DFramework.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@
<ClInclude Include="CDirectionalLight.h">
<Filter>06.GameModules\Attribute\Light</Filter>
</ClInclude>
<ClInclude Include="CBehavior.h">
<Filter>06.GameModules\Abstract\CBehavior</Filter>
</ClInclude>
<ClInclude Include="CLight.h">
<Filter>06.GameModules\Abstract\CBehavior</Filter>
</ClInclude>
Expand All @@ -136,11 +133,17 @@
<ClInclude Include="SceneManager.h">
<Filter>03.System</Filter>
</ClInclude>
<ClInclude Include="DevScene.h">
<Filter>04.GameScene\Concrete</Filter>
</ClInclude>
<ClInclude Include="Scene.h">
<Filter>04.GameScene\Abstract</Filter>
</ClInclude>
<ClInclude Include="DevScene.h">
<Filter>04.GameScene\Concrete</Filter>
<ClInclude Include="CTag.h">
<Filter>06.GameModules\Attribute</Filter>
</ClInclude>
<ClInclude Include="CBehavior.h">
<Filter>06.GameModules\Abstract</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -218,9 +221,6 @@
<Filter Include="06.GameModules\Attribute\Light">
<UniqueIdentifier>{0f0c2a6a-e08d-42d1-8513-7efb53aea42e}</UniqueIdentifier>
</Filter>
<Filter Include="06.GameModules\Abstract\CBehavior">
<UniqueIdentifier>{44f5167e-fe27-4c9f-aa6d-6f2d970594cc}</UniqueIdentifier>
</Filter>
<Filter Include="04.GameScene">
<UniqueIdentifier>{0e1a8674-65c9-481c-b799-4c5e89457b52}</UniqueIdentifier>
</Filter>
Expand All @@ -236,6 +236,9 @@
<Filter Include="04.GameScene\Concrete">
<UniqueIdentifier>{4b8b861d-a73a-47a5-a9fb-4049e7fa9a88}</UniqueIdentifier>
</Filter>
<Filter Include="06.GameModules\Abstract\CBehavior">
<UniqueIdentifier>{44f5167e-fe27-4c9f-aa6d-6f2d970594cc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
Expand Down Expand Up @@ -337,9 +340,6 @@
<ClCompile Include="CDirectionalLight.cpp">
<Filter>06.GameModules\Attribute\Light</Filter>
</ClCompile>
<ClCompile Include="CBehavior.cpp">
<Filter>06.GameModules\Abstract\CBehavior</Filter>
</ClCompile>
<ClCompile Include="CLight.cpp">
<Filter>06.GameModules\Abstract\CBehavior</Filter>
</ClCompile>
Expand All @@ -358,6 +358,12 @@
<ClCompile Include="DevScene.cpp">
<Filter>04.GameScene\Concrete</Filter>
</ClCompile>
<ClCompile Include="CTag.cpp">
<Filter>06.GameModules\Attribute</Filter>
</ClCompile>
<ClCompile Include="CBehavior.cpp">
<Filter>06.GameModules\Abstract</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="MyD3DFramework.rc">
Expand All @@ -377,6 +383,7 @@
<None Include="ShaderHeader.hlsli">
<Filter>07.RenderModules\Shader</Filter>
</None>
<None Include="ObjectRepo Optimize Steragy.txt" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="SimpleVertexShader.hlsl">
Expand Down
24 changes: 7 additions & 17 deletions MyD3DFramework/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ class Renderer
inline void RegisterCMeshRenderer(CMeshRenderer* inMesh);
inline void CleanGarbageInCMeshRendererList();

template<typename ObjectType, typename ...Args>
inline ObjectType* RegisterGameObject(Args... args)
{
static_assert(std::is_base_of<GameObject, ObjectType>::value);

std::unique_ptr<> inst = std::make_unique<ObjectType>(args...);
inst->InitalizeCore();
inst->SetTypeInfo(CM::TypeTrait<ObjectType>::GetInfo());

ObjectType* returnObj = inst.get();
m_rObjRepo.push_back(std::move(inst));

return returnObj;
}

public:
//참조용 Static 변수들
const static std::wstring BasicEffectKey;
Expand All @@ -101,7 +86,7 @@ class Renderer
const static std::wstring CbPerObjectKey;

private:
Renderer() = default;
Renderer();;
~Renderer() = default;

private:
Expand Down Expand Up @@ -139,7 +124,7 @@ class Renderer
cbPerFrame m_cbPerFrame = {};

//3D 메쉬 집합
std::vector<CMeshRenderer*> m_cMashRendererRepo{1024};
std::vector<CMeshRenderer*> m_cMashRendererRepo;

//
//std::array<CLight*, USABLE_LIGHT_MAXIMUM_COUNT> m_cLightRepo;
Expand Down Expand Up @@ -297,6 +282,11 @@ inline void Renderer::CleanGarbageInCMeshRendererList()
m_cMashRendererRepo = std::move(newVector);
}

inline Renderer::Renderer()
{
m_cMashRendererRepo.reserve(1024);
}

inline Mesh* Renderer::GetMesh(const std::wstring& inKey)
{
assert(m_meshRepo.contains(inKey));
Expand Down
63 changes: 31 additions & 32 deletions MyD3DFramework/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

class GameObject;

//-------------------------------------
// 씬은 유일하게 존재해야함
//-------------------------------------

class Scene
{
public:
Expand All @@ -16,33 +12,8 @@ class Scene
void UpdateSceneCore(float inDeltaTime);
void ExitSceneCore();


template <typename ObjType, typename... Args>
inline GameObject* RegisterGameObject(Args&&... args)
{
static_assert(std::is_base_of<GameObject, ObjType>::value, "RegisterGameObject must use GameObject Based Class.");

std::unique_ptr<GameObject> gObj = std::make_unique<ObjType>(std::forward<Args>(args...));
GameObject* gPtr = gObj.get();

CM::TypeID id = CM::TypeTrait<ObjType>::GetInfo().ID;
auto repo = m_objRepo.find(id);

if (repo != m_objRepo.end())
{
repo->second.push_back(std::move(gObj));
}
else
{
std::vector<std::unique_ptr<GameObject>> vec;
vec.reserve(32);
vec.push_back(std::move(gObj));
m_objRepo[id] = std::move(vec);
}

m_updateObjRepo.push_back(gPtr);
return gPtr;
}
inline GameObject* RegisterGameObject(Args&&... args);

protected:
Scene() = default;
Expand All @@ -54,8 +25,36 @@ class Scene
CM::TypeInfo m_typeInfo = {};

//오브젝트를 저장하는 컨테이너
std::unordered_map<CM::TypeID, std::vector<std::unique_ptr<GameObject>>> m_objRepo;
std::unordered_map<uint64, std::unique_ptr<GameObject>> m_objRepo;

//오브젝트를 순회하는 컨테이너
std::vector<GameObject*> m_updateObjRepo;
};
};

template<typename ObjType, typename ...Args>
inline GameObject* Scene::RegisterGameObject(Args && ...args)
{
static_assert(std::is_base_of<GameObject, ObjType>::value, "RegisterGameObject must use GameObject Based Class.");

std::unique_ptr<GameObject> gObj = std::make_unique<ObjType>(std::forward<Args>(args...));
GameObject* gPtr = gObj.get();

CM::TypeID id = CM::TypeTrait<ObjType>::GetInfo().ID;
auto repo = m_objRepo.find(id);

if (repo != m_objRepo.end())
{
repo->second.push_back(std::move(gObj));
}
else
{
std::vector<std::unique_ptr<GameObject>> vec;
vec.reserve(32);
vec.push_back(std::move(gObj));
m_objRepo[id] = std::move(vec);
}

m_updateObjRepo.push_back(gPtr);
return gPtr;
}

Binary file modified MyD3DFramework/x64/Debug/Algorithm.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/BufferPool.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CAttribute.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CBehavior.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CDirectionalLight.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CLight.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CMeshRenderer.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CPointLight.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CSpotLight.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CTransform.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/CircularArray.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Component.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/ConstexprHash.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/ContantBuffers.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Effect.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Engine.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Font.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/GameTimer.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/InputManager.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Main.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Material.obj
Binary file not shown.
Binary file modified MyD3DFramework/x64/Debug/Mesh.obj
Binary file not shown.
Loading

0 comments on commit 7dccf64

Please sign in to comment.