From 2fcd4717c6811375473527bf20b292a2598a2302 Mon Sep 17 00:00:00 2001 From: shiiion Date: Sat, 23 Oct 2021 06:28:46 -0700 Subject: [PATCH] Fixed some mistakes, generates impacts now --- Runtime/World/CIceImpact.cpp | 12 ++++++------ Runtime/World/CMarkerGrid.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Runtime/World/CIceImpact.cpp b/Runtime/World/CIceImpact.cpp index 1a1da5d37..e6bbc6e16 100644 --- a/Runtime/World/CIceImpact.cpp +++ b/Runtime/World/CIceImpact.cpp @@ -156,10 +156,10 @@ std::optional CIceImpact::GenerateNewSphere() { for (u32 z = 8; loop_cond(fwd_z, z); z = loop_step(fwd_z, z)) { for (u32 y = 8; loop_cond(fwd_y, y); y = loop_step(fwd_y, y)) { for (u32 x = 8; loop_cond(fwd_x, x); x = loop_step(fwd_x, x)) { - u32 grid_val = x118_grid.GetValue(z, y, x); - if (grid_val != 1) { - zeus::CVector3f pos = x118_grid.GetWorldPositionForCell(z, y, x); - x118_grid.SetValue(z, y, x, 3); + u32 grid_val = x118_grid.GetValue(x, y, z); + if (grid_val == 1) { + zeus::CVector3f pos = x118_grid.GetWorldPositionForCell(x, y, z); + x118_grid.SetValue(x, y, z, 3); if (PointInSphere(x108_sphereGenRange, pos)) { x118_grid.MarkCells(zeus::CSphere(pos, 1.6f), 2); return SImpactSphere(pos, 1.6f, 1.6f, 0.f, 0.f); @@ -249,7 +249,7 @@ void CIceImpact::GenerateParticlesAgainstWorld(CStateManager& mgr, CCollisionSurface surface = node.GetOwner().GetMasterListTriangle(arr.GetAt(i)); if (filter.Passes(CMaterialList(surface.GetSurfaceFlags()))) { subdivide_result = - SubdivideAndGenerateParticles(mgr, surface.GetVert(0), surface.GetVert(1), surface.GetVert(1), a, b); + SubdivideAndGenerateParticles(mgr, surface.GetVert(0), surface.GetVert(1), surface.GetVert(2), a, b); } } } @@ -312,7 +312,7 @@ bool CIceImpact::SubdivideAndGenerateParticles(CStateManager& mgr, zeus::CVector if (!CollisionUtil::TriSphereOverlap(a, v1, v2, v3)) { return false; } - if (!PointInSphere(b, v1) && !PointInSphere(b, v2) && !PointInSphere(b, v3)) { + if (PointInSphere(b, v1) && PointInSphere(b, v2) && PointInSphere(b, v3)) { return false; } diff --git a/Runtime/World/CMarkerGrid.cpp b/Runtime/World/CMarkerGrid.cpp index 3f94a4af2..58107e4f9 100644 --- a/Runtime/World/CMarkerGrid.cpp +++ b/Runtime/World/CMarkerGrid.cpp @@ -26,9 +26,9 @@ void CMarkerGrid::MarkCells(const zeus::CSphere& area, u32 val) { bool CMarkerGrid::GetCoords(zeus::CVector3f const& vec, u32& x, u32& y, u32& z) const { if (x0_bounds.pointInside(vec)) { - x = static_cast((vec.x() - x0_bounds.min.x()) / x); - y = static_cast((vec.y() - x0_bounds.min.y()) / y); - z = static_cast((vec.z() - x0_bounds.min.z()) / z); + x = static_cast((vec.x() - x0_bounds.min.x()) / x18_gridUnits.x()); + y = static_cast((vec.y() - x0_bounds.min.y()) / x18_gridUnits.y()); + z = static_cast((vec.z() - x0_bounds.min.z()) / x18_gridUnits.z()); return true; } return false; @@ -83,4 +83,4 @@ zeus::CVector3f CMarkerGrid::GetWorldPositionForCell(u32 x, u32 y, u32 z) const return zeus::CVector3f(static_cast(x), static_cast(y), static_cast(z)) * x18_gridUnits + x0_bounds.min + (x18_gridUnits / 2.f); } -} // namespace urde \ No newline at end of file +} // namespace urde