Patch Update - Remove The """Instancing""" due to unwanted behavior - V10.4.1
This commit is contained in:
@@ -201,7 +201,8 @@ protected:
|
||||
|
||||
public:
|
||||
ModelClass();
|
||||
ModelClass(const ModelClass&);
|
||||
ModelClass(const ModelClass&) = delete;
|
||||
ModelClass& operator=(const ModelClass&) = delete;
|
||||
~ModelClass();
|
||||
|
||||
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
||||
|
@@ -32,6 +32,9 @@ public:
|
||||
Object();
|
||||
~Object();
|
||||
|
||||
Object(const Object&) = delete;
|
||||
Object& operator=(const Object&) = delete;
|
||||
|
||||
void SetScaleMatrix(XMMATRIX scaleMatrix);
|
||||
void SetRotateMatrix(XMMATRIX rotateMatrix);
|
||||
void SetTranslateMatrix(XMMATRIX translateMatrix);
|
||||
@@ -50,7 +53,6 @@ public:
|
||||
|
||||
XMVECTOR GetPosition();
|
||||
XMVECTOR GetRotation();
|
||||
void Render(ID3D11DeviceContext* deviceContext);
|
||||
XMVECTOR GetScale();
|
||||
|
||||
void SetVelocity(XMVECTOR);
|
||||
@@ -148,10 +150,5 @@ private:
|
||||
float m_alpha = 0.0f;
|
||||
float m_initialStretch = 0.0f;
|
||||
float m_springConstant = 10.0f;
|
||||
|
||||
bool m_instancingEnabled;
|
||||
int m_instanceCount;
|
||||
ID3D11Buffer* m_instanceBuffer;
|
||||
std::vector<XMMATRIX> m_instanceTransforms;
|
||||
|
||||
};
|
||||
|
@@ -1286,7 +1286,7 @@ void ApplicationClass::AddKobject(std::wstring& filepath)
|
||||
string filename = p.stem().string();
|
||||
|
||||
size_t convertedChars = 0;
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), filepath.c_str(), _TRUNCATE);
|
||||
(void)wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), filepath.c_str(), _TRUNCATE);
|
||||
|
||||
filesystem::current_path(m_WFolder);
|
||||
|
||||
@@ -1672,7 +1672,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
|
||||
int renderCount = 0;
|
||||
|
||||
ConstructFrustum();
|
||||
//ConstructFrustum();
|
||||
|
||||
for (const auto& RenderQueue : RenderQueues)
|
||||
{
|
||||
@@ -1696,8 +1696,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
{
|
||||
object->UpdatePosition(m_Timer->GetTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!object->IsVisible())
|
||||
{
|
||||
continue;
|
||||
|
@@ -644,23 +644,6 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// int input area for the number of cubes
|
||||
static int numCubes = 10;
|
||||
ImGui::InputInt("Number of Cubes", &numCubes);
|
||||
if (numCubes < 1)
|
||||
{
|
||||
numCubes = 1;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Generate Big Cube Terrain"))
|
||||
{
|
||||
app->CreateBigCube(numCubes);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("Delete All Terrain Cubes"))
|
||||
{
|
||||
app->DeleteTerrain();
|
||||
|
@@ -6,16 +6,23 @@ ModelClass::ModelClass()
|
||||
m_vertexBuffer = 0;
|
||||
m_indexBuffer = 0;
|
||||
m_model = 0;
|
||||
m_vertexCount = 0;
|
||||
m_indexCount = 0;
|
||||
m_Textures.diffuse.clear();
|
||||
m_Textures.normal.clear();
|
||||
m_Textures.specular.clear();
|
||||
m_Textures.alpha.clear();
|
||||
m_Textures.diffusePaths.clear();
|
||||
m_Textures.normalPaths.clear();
|
||||
m_Textures.specularPaths.clear();
|
||||
m_Textures.alphaPaths.clear();
|
||||
}
|
||||
|
||||
|
||||
ModelClass::ModelClass(const ModelClass& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ModelClass::~ModelClass()
|
||||
{
|
||||
|
||||
// Destructor
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
|
||||
|
@@ -18,19 +18,10 @@ Object::Object()// Initialize the reference here
|
||||
m_isGrounded = false;
|
||||
m_id = NULL;
|
||||
m_boundingRadius = 1.0f;
|
||||
m_instancingEnabled = false;
|
||||
m_instanceCount = 0;
|
||||
m_instanceBuffer = nullptr;
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
// Lib<69>rer le buffer d'instances
|
||||
if (m_instanceBuffer)
|
||||
{
|
||||
m_instanceBuffer->Release();
|
||||
m_instanceBuffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||
@@ -100,45 +91,6 @@ XMVECTOR Object::GetRotation()
|
||||
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||
}
|
||||
|
||||
void Object::Render(ID3D11DeviceContext* deviceContext)
|
||||
{
|
||||
unsigned int strides[2];
|
||||
unsigned int offsets[2];
|
||||
ID3D11Buffer* bufferPointers[2];
|
||||
|
||||
// Configurer les vertex et index buffers
|
||||
strides[0] = sizeof(VertexType);
|
||||
offsets[0] = 0;
|
||||
bufferPointers[0] = m_vertexBuffer;
|
||||
|
||||
// Si l'instanciation est activ<69>e
|
||||
if (m_instancingEnabled && m_instanceBuffer)
|
||||
{
|
||||
// Configurer le buffer d'instances
|
||||
strides[1] = sizeof(XMMATRIX);
|
||||
offsets[1] = 0;
|
||||
bufferPointers[1] = m_instanceBuffer;
|
||||
|
||||
// D<>finir les deux buffers (vertex et instance) sur le pipeline
|
||||
deviceContext->IASetVertexBuffers(0, 2, bufferPointers, strides, offsets);
|
||||
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
||||
// Dessiner les instances
|
||||
deviceContext->DrawIndexedInstanced(m_indexCount, m_instanceCount, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rendu normal sans instanciation
|
||||
deviceContext->IASetVertexBuffers(0, 1, bufferPointers, strides, offsets);
|
||||
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
||||
// Dessiner l'objet normalement
|
||||
deviceContext->DrawIndexed(m_indexCount, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
XMVECTOR Object::GetScale()
|
||||
{
|
||||
XMFLOAT4X4 matrix;
|
||||
@@ -435,66 +387,4 @@ bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Object::SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms)
|
||||
{
|
||||
// Stocker les matrices de transformation
|
||||
m_instanceTransforms = instanceTransforms;
|
||||
m_instanceCount = static_cast<int>(instanceTransforms.size());
|
||||
|
||||
// Lib<69>rer le buffer d'instances existant si n<>cessaire
|
||||
if (m_instanceBuffer)
|
||||
{
|
||||
m_instanceBuffer->Release();
|
||||
m_instanceBuffer = nullptr;
|
||||
}
|
||||
|
||||
// Cr<43>er le buffer d'instances
|
||||
D3D11_BUFFER_DESC instanceBufferDesc;
|
||||
ZeroMemory(&instanceBufferDesc, sizeof(instanceBufferDesc));
|
||||
instanceBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
instanceBufferDesc.ByteWidth = sizeof(XMMATRIX) * m_instanceCount;
|
||||
instanceBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
instanceBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
instanceBufferDesc.MiscFlags = 0;
|
||||
instanceBufferDesc.StructureByteStride = 0;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA instanceData;
|
||||
ZeroMemory(&instanceData, sizeof(instanceData));
|
||||
instanceData.pSysMem = instanceTransforms.data();
|
||||
|
||||
HRESULT result = device->CreateBuffer(&instanceBufferDesc, &instanceData, &m_instanceBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Object::EnableInstancing(bool enabled)
|
||||
{
|
||||
m_instancingEnabled = enabled;
|
||||
}
|
||||
|
||||
void Object::SetInstanceCount(int count)
|
||||
{
|
||||
m_instanceCount = count;
|
||||
}
|
||||
|
||||
// Ajoutez <20>galement ces m<>thodes pour acc<63>der aux donn<6E>es d'instanciation
|
||||
bool Object::IsInstancingEnabled() const
|
||||
{
|
||||
return m_instancingEnabled;
|
||||
}
|
||||
|
||||
int Object::GetInstanceCount() const
|
||||
{
|
||||
return m_instanceCount;
|
||||
}
|
||||
|
||||
ID3D11Buffer* Object::GetInstanceBuffer() const
|
||||
{
|
||||
return m_instanceBuffer;
|
||||
}
|
Reference in New Issue
Block a user