MSVC another fix

This commit is contained in:
JackCarterSmith 2025-01-02 22:33:44 +01:00
parent bab7fc8f12
commit d6236a7857
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24
2 changed files with 15 additions and 10 deletions

View File

@ -13,7 +13,7 @@ endif()
if(NOT MSVC)
add_compile_options(-Wall)
else()
add_compile_options(/Wall)
add_compile_options(/Wall /wd4710 /wd4711)
endif()
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")

View File

@ -9,7 +9,7 @@
//#define DISABLE_AABB_CLIPPING
//#define DISABLE_TRIANGLE_CLIPPING
//#define DISABLE_WIREFRAME_MODE
#define DISABLE_WIREFRAME_MODE
// Rendering pipeline:
@ -149,6 +149,8 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
#endif
// Process scene's objects
size_t prevVCount = 0;
std::vector<M3D_F4> projVertices;
for (auto& obj : mRenderList) {
M3D_BoundingBox projAABB = obj->GetAABB();
auto oTMat = obj->GetTransform();
@ -162,11 +164,12 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
{
size_t vCount = obj->GetObjectVerticesCount();
auto& oMesh = obj->GetObjectMesh();
M3D_F4 projVertices[vCount] = {};
if (vCount > prevVCount)
projVertices.resize(vCount);
// Vertices homogeneous clip space transformation
M3D_V3Transform(
projVertices, sizeof(M3D_F4),
projVertices.data(), sizeof(M3D_F4),
reinterpret_cast<const M3D_F3*>(oMesh.vertices.data()), sizeof(Vertex),
vCount,
oTMat * viewProjMat
@ -185,15 +188,15 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
// Triangle clipping
#ifndef DISABLE_TRIANGLE_CLIPPING
//TODO: scissor/clipping depending of how many vertices are outside/inside the clipspace, implement complete Cohen-Sutherland algo or CyrusBeck one
if (VertexClipTest(projVertices[indicePtr[i]], mRTSize, 2.5f) &&
VertexClipTest(projVertices[indicePtr[i+1]], mRTSize, 2.5f) &&
VertexClipTest(projVertices[indicePtr[i+2]], mRTSize, 2.5f))
if (VertexClipTest(projVertices.at(indicePtr[i]), mRTSize, 2.5f) &&
VertexClipTest(projVertices.at(indicePtr[i+1]), mRTSize, 2.5f) &&
VertexClipTest(projVertices.at(indicePtr[i+2]), mRTSize, 2.5f))
#endif
{
M3D_VECTOR V1 = M3D_V4LoadF4(&projVertices[indicePtr[i]]);
M3D_VECTOR V2 = M3D_V4LoadF4(&projVertices[indicePtr[i+1]]);
M3D_VECTOR V3 = M3D_V4LoadF4(&projVertices[indicePtr[i+2]]);
M3D_VECTOR V1 = M3D_V4LoadF4(&projVertices.at(indicePtr[i]));
M3D_VECTOR V2 = M3D_V4LoadF4(&projVertices.at(indicePtr[i+1]));
M3D_VECTOR V3 = M3D_V4LoadF4(&projVertices.at(indicePtr[i+2]));
// Do the perspective divide
V1 = M3D_V4Divide(V1, M3D_V4SplatW(V1));
@ -234,6 +237,8 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
}
}
}
prevVCount = prevVCount;
}
}