Files
MinecraftConsoles/Minecraft.Client/OffsettedRenderList.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

65 lines
1.4 KiB
C++

#include "stdafx.h"
#include "..\Minecraft.World\IntBuffer.h"
#include "OffsettedRenderList.h"
// 4J added
OffsettedRenderList::OffsettedRenderList()
{
x = y = z = 0;
xOff = yOff = zOff = 0;
lists = MemoryTracker::createIntBuffer(1024 * 64);
inited = false;
rendered = false;
}
void OffsettedRenderList::init(int x, int y, int z, double xOff, double yOff, double zOff)
{
inited = true;
lists->clear();
this->x = x;
this->y = y;
this->z = z;
this->xOff = static_cast<float>(xOff);
this->yOff = static_cast<float>(yOff);
this->zOff = static_cast<float>(zOff);
}
bool OffsettedRenderList::isAt(int x, int y, int z)
{
if (!inited) return false;
return x == this->x && y == this->y && z == this->z;
}
void OffsettedRenderList::add(int list)
{
// 4J - added - chunkList::getList returns -1 when chunks aren't visible, we really don't want to end up sending that to glCallLists
if( list >= 0 )
{
lists->put(list);
}
if (lists->remaining() == 0) render();
}
void OffsettedRenderList::render()
{
if (!inited) return;
if (!rendered)
{
lists->flip();
rendered = true;
}
if (lists->remaining() > 0)
{
glPushMatrix();
glTranslatef(x - xOff, y - yOff, z - zOff);
glCallLists(lists);
glPopMatrix();
}
}
void OffsettedRenderList::clear()
{
inited = false;
rendered = false;
}