diff options
| author | void_17 <heroerror3@gmail.com> | 2026-03-02 15:58:20 +0700 |
|---|---|---|
| committer | void_17 <heroerror3@gmail.com> | 2026-03-02 15:58:20 +0700 |
| commit | 7074f35e4ba831e358117842b99ee35b87f85ae5 (patch) | |
| tree | 7d440d23473196af3056bf2ff4c59d9e740a06f5 /Minecraft.Client/ViewportCuller.cpp | |
| parent | d63f79325f85e014361eb8cf1e41eaebedb1ae71 (diff) | |
shared_ptr -> std::shared_ptr
This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today.
Diffstat (limited to 'Minecraft.Client/ViewportCuller.cpp')
| -rw-r--r-- | Minecraft.Client/ViewportCuller.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Minecraft.Client/ViewportCuller.cpp b/Minecraft.Client/ViewportCuller.cpp index bc22faa6..a6d3c87e 100644 --- a/Minecraft.Client/ViewportCuller.cpp +++ b/Minecraft.Client/ViewportCuller.cpp @@ -7,17 +7,17 @@ ViewportCuller::Face::Face(double x, double y, double z, float yRot, float xRot) this->xc = x; this->yc = y; this->zc = z; - + xd = Mth::sin(yRot / 180 * PI) * Mth::cos(xRot / 180 * PI); zd = -Mth::cos(yRot / 180 * PI) * Mth::cos(xRot / 180 * PI); yd = -Mth::sin(xRot / 180 * PI); - - cullOffs = xc*xd+yc*yd+zc*zd; + + cullOffs = xc*xd+yc*yd+zc*zd; } - + bool ViewportCuller::Face::inFront(double x, double y, double z, double r) { - return x*xd+y*yd+z*zd>cullOffs-r; + return x*xd+y*yd+z*zd>cullOffs-r; } bool ViewportCuller::Face::inFront(double x0, double y0, double z0, double x1, double y1, double z1) @@ -30,7 +30,7 @@ bool ViewportCuller::Face::inFront(double x0, double y0, double z0, double x1, d x0*xd+y0*yd+z1*zd>cullOffs || x1*xd+y0*yd+z1*zd>cullOffs || x0*xd+y1*yd+z1*zd>cullOffs || - x1*xd+y1*yd+z1*zd>cullOffs + x1*xd+y1*yd+z1*zd>cullOffs ) return true; return false; } @@ -44,18 +44,18 @@ bool ViewportCuller::Face::fullyInFront(double x0, double y0, double z0, double x0*xd+y0*yd+z1*zd<cullOffs || x1*xd+y0*yd+z1*zd<cullOffs || x0*xd+y1*yd+z1*zd<cullOffs || - x1*xd+y1*yd+z1*zd<cullOffs + x1*xd+y1*yd+z1*zd<cullOffs ) return false; return true; } -ViewportCuller::ViewportCuller(shared_ptr<Mob> mob, double fogDistance, float a) +ViewportCuller::ViewportCuller(std::shared_ptr<Mob> mob, double fogDistance, float a) { float yRot = mob->yRotO+(mob->yRot-mob->yRotO)*a; float xRot = mob->xRotO+(mob->xRot-mob->xRotO)*a; - - double x = mob->xOld+(mob->x-mob->xOld)*a; - double y = mob->yOld+(mob->y-mob->yOld)*a; + + double x = mob->xOld+(mob->x-mob->xOld)*a; + double y = mob->yOld+(mob->y-mob->yOld)*a; double z = mob->zOld+(mob->z-mob->zOld)*a; double xd = Mth::sin(yRot / 180 * PI) * Mth::cos(xRot / 180 * PI); @@ -69,7 +69,7 @@ ViewportCuller::ViewportCuller(shared_ptr<Mob> mob, double fogDistance, float a) faces[2] = Face(x, y, z, yRot-xFov, xRot); faces[3] = Face(x, y, z, yRot, xRot+yFov); faces[4] = Face(x, y, z, yRot, xRot-yFov); - faces[5] = Face(x+xd*fogDistance, y+yd*fogDistance, z+zd*fogDistance, yRot+180, -xRot); + faces[5] = Face(x+xd*fogDistance, y+yd*fogDistance, z+zd*fogDistance, yRot+180, -xRot); } bool ViewportCuller::isVisible(AABB bb) @@ -88,12 +88,12 @@ bool ViewportCuller::cubeInFrustum(double x0, double y0, double z0, double x1, d double xd = (x1-x0)/2.0f; double yd = (y1-y0)/2.0f; double zd = (z1-z0)/2.0f; - + double xc = x0+xd; double yc = y0+yd; double zc = z0+zd; double r = _max(xd, yd, zd)*1.5f; - + if (!faces[0].inFront(xc, yc, zc, r)) return false; if (!faces[1].inFront(xc, yc, zc, r)) return false; if (!faces[2].inFront(xc, yc, zc, r)) return false; @@ -123,7 +123,7 @@ bool ViewportCuller::cubeFullyInFrustum(double x0, double y0, double z0, double double xd = (x1-x0)/2.0f; double yd = (y1-y0)/2.0f; double zd = (z1-z0)/2.0f; - + double xc = x0+xd; double yc = y0+yd; double zc = z0+zd; @@ -135,8 +135,8 @@ bool ViewportCuller::cubeFullyInFrustum(double x0, double y0, double z0, double if (!faces[3].inFront(xc, yc, zc, r)) return false; if (!faces[4].inFront(xc, yc, zc, r)) return false; if (!faces[5].inFront(xc, yc, zc, r)) return false; - - + + if (!faces[0].fullyInFront(x0, y0, z0, x1, y1, z1)) return false; if (!faces[1].fullyInFront(x0, y0, z0, x1, y1, z1)) return false; if (!faces[2].fullyInFront(x0, y0, z0, x1, y1, z1)) return false; |
