Skip to content

Commit

Permalink
TestCommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnjiwoo committed Oct 3, 2024
1 parent 6a3c899 commit 0cef26b
Show file tree
Hide file tree
Showing 72 changed files with 1,001 additions and 342 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/MyD3DFramework.exe
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.
2 changes: 2 additions & 0 deletions MyD3DFramework/Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "pch.h"
#include "Array.h"
210 changes: 210 additions & 0 deletions MyD3DFramework/Array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#pragma once
#include <cstddef>
#include <cassert>

namespace CM
{
template<typename Ty, std::size_t N>
class Array
{
public:
Array() : mSize(0) {}

void PushBack(const Ty& value)
{
assert(mSize < N && "Array capacity exceeded");
mDatas[mSize++] = value;
}

void PopBack()
{
assert(mSize > 0 && "Array is empty");
--mSize;
}

Ty& operator[](std::size_t index)
{
assert(index < mSize && "Index out of bounds");
return mDatas[index];
}

const Ty& operator[](std::size_t index) const
{
assert(index < mSize && "Index out of bounds");
return mDatas[index];
}

std::size_t Size() const noexcept
{
return mSize;
}

constexpr std::size_t Capacity() const noexcept
{
return N;
}

Ty* begin() noexcept { return mDatas; }
const Ty* begin() const noexcept { return mDatas; }

Ty* end() noexcept { return mDatas + mSize; }
const Ty* end() const noexcept { return mDatas + mSize; }


Ty* Find(const Ty& value) noexcept
{
for (std::size_t i = 0; i < mSize; ++i)
{
if (mDatas[i] == value)
{
return &mDatas[i];
}
}
return end();
}

const Ty* Find(const Ty& value) const noexcept
{
for (std::size_t i = 0; i < mSize; ++i)
{
if (mDatas[i] == value)
{
return &mDatas[i];
}
}
return end();
}

void Erase(std::size_t index)
{
assert(index < mSize && "Index out of bounds");
for (std::size_t i = index; i < mSize - 1; ++i)
{
mDatas[i] = mDatas[i + 1];
}
--mSize;
}

private:
Ty mDatas[N];
std::size_t mSize;
};
}

namespace CM
{
template<typename Ty, std::size_t N>
class Array<Ty*, N>
{
public:
Array() : mSize(0)
{
for (std::size_t i = 0; i < N; ++i)
{
mDatas[i] = nullptr;
}
}

void PushBack(Ty* value)
{
assert(mSize < N && "Array capacity exceeded");
mDatas[mSize++] = value;
}

void PopBack()
{
assert(mSize > 0 && "Array is empty");
--mSize;
mDatas[mSize] = nullptr;
}

Ty*& operator[](std::size_t index)
{
assert(index < mSize && "Index out of bounds");
return mDatas[index];
}

const Ty* const& operator[](std::size_t index) const
{
assert(index < mSize && "Index out of bounds");
return mDatas[index];
}

std::size_t Size() const noexcept
{
return mSize;
}

constexpr std::size_t Capacity() const noexcept
{
return N;
}

Ty** begin() noexcept { return mDatas; }
Ty* const* begin() const noexcept { return mDatas; }

Ty** end() noexcept { return mDatas + mSize; }
Ty* const* end() const noexcept { return mDatas + mSize; }

Ty** Find(Ty* value) noexcept
{
for (std::size_t i = 0; i < mSize; ++i)
{
if (mDatas[i] == value)
{
return &mDatas[i];
}
}
return end();
}

Ty* const* Find(Ty* value) const noexcept
{
for (std::size_t i = 0; i < mSize; ++i)
{
if (mDatas[i] == value)
{
return &mDatas[i];
}
}
return end();
}

void Erase(Ty* value)
{
size_t idx = 0;
for (; idx < mSize; ++idx)
{
if (value == mDatas[idx])
{
break;
}
}

if (idx != mSize)
{
for (std::size_t i = idx; i < mSize - 1; ++i)
{
mDatas[i] = mDatas[i + 1];
}
--mSize;
mDatas[mSize] = nullptr;
}
}

void Erase(std::size_t index)
{
assert(index < mSize && "Index out of bounds");
for (std::size_t i = index; i < mSize - 1; ++i)
{
mDatas[i] = mDatas[i + 1];
}
--mSize;
mDatas[mSize] = nullptr;
}

private:
Ty* mDatas[N];
std::size_t mSize;
};
}
9 changes: 5 additions & 4 deletions MyD3DFramework/CCamera.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once
#include "CAttribute.h"
#include "CTransform.h"
#include "WindowsApp.h"
#include "Renderer.h"

class CCamera : public CAttribute
Expand All @@ -28,10 +27,12 @@ class CCamera : public CAttribute
void SetFarPlane(float inFarPlane);

Matrix GetViewMatrix(const Vector3& inUp = Vector3::Up) const;
Matrix GetPerspectiveMatrix() const;
Matrix GetPerspectiveMatrix(float inAspectRatio) const;

void RegisterToMainCamera();

Vector3 GetPosition() { return m_offsetPosition + m_ownerTrans->GetPosition(); }

private:
const CTransform* m_ownerTrans = nullptr;

Expand Down Expand Up @@ -99,9 +100,9 @@ Matrix CCamera::GetViewMatrix(const Vector3& inUp) const
return ::XMMatrixLookToLH(m_ownerTrans->GetPosition() + m_offsetPosition, lookVec, inUp);
}

Matrix CCamera::GetPerspectiveMatrix() const
inline Matrix CCamera::GetPerspectiveMatrix(float inAspectRatio) const
{
return ::XMMatrixPerspectiveFovLH(m_fov, WindowsApp::GetInst().GetAspectRatio(), m_nearPlane, m_farPlane);
return ::XMMatrixPerspectiveFovLH(m_fov, inAspectRatio, m_nearPlane, m_farPlane);
}

void CCamera::SetNearPlane(float inNearPlane)
Expand Down
2 changes: 0 additions & 2 deletions MyD3DFramework/CDirectionalLight.cpp

This file was deleted.

21 changes: 0 additions & 21 deletions MyD3DFramework/CDirectionalLight.h

This file was deleted.

14 changes: 14 additions & 0 deletions MyD3DFramework/CKeyInput.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "pch.h"
#include "CKeyInput.h"

void CKeyInput::Update()
{
for (auto& action : m_actionVector)
{
const ActionKey& key = action->Key;
if (CheckKeyState(key.KeyState, key.KeyCode))
{
action->Action();
}
}
}
Loading

0 comments on commit 0cef26b

Please sign in to comment.