Batch #1389 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_02254 LightmappedBuffer::Clear: logic confirmed by peer review Reviewed-by: ragnarok-clanker
98 lines
2.5 KiB
C++
98 lines
2.5 KiB
C++
#include "Render/Primitives/DepthAlpha.h"
|
|
#include "Render/Primitives/LightmappedPrimitive.h"
|
|
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <windows.h>
|
|
#include <d3d9types.h>
|
|
#include <new>
|
|
|
|
// OFFSET: 0x005690E0
|
|
// FUNCTION: fn_02248
|
|
LightmappedCommand::LightmappedCommand()
|
|
: vertices(nullptr), vertexCount(0), indices(nullptr), indexCount(0), texture(nullptr), lightmap(nullptr), primitiveType(D3DPT_TRIANGLESTRIP) {
|
|
}
|
|
|
|
struct LightmappedBuffer {
|
|
void* vertices;
|
|
int count;
|
|
void* indices;
|
|
void Clear();
|
|
};
|
|
|
|
// OFFSET: 0x00569310
|
|
// FUNCTION: fn_02254
|
|
void LightmappedBuffer::Clear() {
|
|
if (this->vertices) {
|
|
std::free(this->vertices);
|
|
this->vertices = nullptr;
|
|
}
|
|
if (this->indices) {
|
|
std::free(this->indices);
|
|
this->indices = nullptr;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00569020
|
|
// FUNCTION: fn_02246
|
|
LightmappedPrimitive::LightmappedPrimitive() : vertices(this->quad), vertexCount(4), indices(nullptr), indexCount(0), primitiveType(D3DPT_TRIANGLESTRIP) {
|
|
for (LightmappedVertex& vertex : this->quad) {
|
|
vertex.x = 0.0f;
|
|
vertex.y = 0.0f;
|
|
vertex.z = 0.0f;
|
|
vertex.rhw = 0.0f;
|
|
vertex.diffuse = 0;
|
|
vertex.specular = 0xFF000000u;
|
|
vertex.u = 0.0f;
|
|
vertex.v = 0.0f;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00568F90
|
|
// FUNCTION: fn_02245
|
|
LightmappedPrimitive::LightmappedPrimitive(const LightmappedPrimitive& other) : LightmappedPrimitive() {
|
|
std::memcpy(this->quad, other.quad, sizeof(this->quad));
|
|
}
|
|
|
|
// INLINED
|
|
LightmappedPrimitivePool::LightmappedPrimitivePool() {
|
|
this->m_commands.resize(8192, LightmappedPrimitive());
|
|
this->m_current = this->m_commands.begin();
|
|
}
|
|
|
|
// INLINED
|
|
LightmappedPrimitive* LightmappedPrimitivePool::Acquire() {
|
|
if (this->m_current == this->m_commands.end()) {
|
|
this->m_commands.emplace_back();
|
|
this->m_current = this->m_commands.end();
|
|
return &this->m_commands.back();
|
|
}
|
|
|
|
LightmappedPrimitive* primitive = &*this->m_current++;
|
|
return new (primitive) LightmappedPrimitive;
|
|
}
|
|
|
|
// INLINED
|
|
void LightmappedPrimitivePool::Rewind() {
|
|
this->m_current = this->m_commands.begin();
|
|
}
|
|
|
|
// OFFSET: 0x00559BE0
|
|
// FUNCTION: fn_02071
|
|
void LightmappedQueues::Submit(LightmappedPrimitive* primitive, int queue, bool depthAlpha, float depthStart, float depthEnd) {
|
|
if (depthAlpha) {
|
|
ApplyDepthAlpha(*primitive, depthStart, depthEnd);
|
|
}
|
|
|
|
if (queue == 0) {
|
|
this->first.push_back(primitive);
|
|
} else if (queue == 1) {
|
|
this->second.push_back(primitive);
|
|
}
|
|
}
|
|
|
|
// INLINED
|
|
void LightmappedQueues::Clear() {
|
|
this->first.clear();
|
|
this->second.clear();
|
|
}
|