Batch #1559 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_02257 RenderCommand::Draw: logic confirmed by peer review Reviewed-by: ragnarok-clanker
113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
#include "Render/Primitives/RenderPrimitive.h"
|
|
#include "Render/Renderer.h"
|
|
|
|
#include <cstring>
|
|
#include <d3d9types.h>
|
|
#include <new>
|
|
|
|
// GLOBAL: gl_24481
|
|
CRenderer* g_renderer;
|
|
|
|
// OFFSET: 0x00569270
|
|
// FUNCTION: fn_02251
|
|
RenderVertex* RenderVertex::Reset() {
|
|
this->x = 0;
|
|
this->y = 0;
|
|
this->z = 0;
|
|
this->rhw = 0;
|
|
this->diffuse = 0;
|
|
this->specular = 0xFF000000;
|
|
this->u = 0;
|
|
this->v = 0;
|
|
|
|
return this;
|
|
}
|
|
|
|
// OFFSET: 0x00569560
|
|
// FUNCTION: fn_02263
|
|
bool RenderTriangle::Visible() const {
|
|
for (const RenderVertex& vertex : this->vertices) {
|
|
if (vertex.rhw <= 0.0f) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// OFFSET: 0x00568F40
|
|
// FUNCTION: fn_02244
|
|
RenderCommand::RenderCommand()
|
|
: vertices(nullptr), vertexCount(0), texture(nullptr), indices(nullptr), indexCount(0), unknown_0014(1), unknown_0018(0), unknown_001C(0), unknown_0020(0),
|
|
primitiveType(D3DPT_TRIANGLELIST) {
|
|
}
|
|
|
|
// OFFSET: 0x005691D0
|
|
// FUNCTION: fn_02250
|
|
RenderPrimitive::RenderPrimitive() : RenderCommand() {
|
|
this->vertices = this->quad;
|
|
this->vertexCount = 4;
|
|
this->primitiveType = D3DPT_TRIANGLESTRIP;
|
|
|
|
for (RenderVertex& vertex : this->quad) {
|
|
vertex.x = 0;
|
|
vertex.y = 0;
|
|
vertex.z = 0;
|
|
vertex.rhw = 0;
|
|
vertex.diffuse = 0;
|
|
vertex.specular = 0xFF000000;
|
|
vertex.u = 0;
|
|
vertex.v = 0;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00569120
|
|
// FUNCTION: fn_02249
|
|
RenderPrimitive::RenderPrimitive(const RenderPrimitive& other) : RenderPrimitive() {
|
|
std::memcpy(this->quad, other.quad, sizeof(this->quad));
|
|
}
|
|
|
|
// OFFSET: 0x005692F0
|
|
// FUNCTION: fn_02253
|
|
RenderCommand* RenderCommand::FreeVertices() {
|
|
if (this->vertices != nullptr) {
|
|
::operator delete(this->vertices);
|
|
this->vertices = nullptr;
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
// OFFSET: 0x00569360
|
|
// FUNCTION: fn_02255
|
|
RenderPrimitive& RenderPrimitive::operator=(const RenderPrimitive& other) {
|
|
std::memcpy(this->quad, other.quad, sizeof(this->quad));
|
|
return *this;
|
|
}
|
|
|
|
// OFFSET: 0x00569380
|
|
// FUNCTION: fn_02256
|
|
void RenderCommand::AllocateTriangles(std::uint32_t triangleCount) {
|
|
const std::uint32_t vertexCount = triangleCount * 3;
|
|
auto* vertices = new RenderVertex[vertexCount];
|
|
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
vertices[i].Reset();
|
|
}
|
|
this->vertices = vertices;
|
|
}
|
|
|
|
// OFFSET: 0x00569470
|
|
// FUNCTION: fn_02257
|
|
void RenderCommand::Draw(int unused) {
|
|
g_renderer->DrawPrimitive(this);
|
|
}
|
|
|
|
// OFFSET: 0x00569580
|
|
// FUNCTION: fn_02264
|
|
void RenderCommand::SetPosition(std::uint32_t index, const float* position) {
|
|
RenderVertex& vertex = this->vertices[index];
|
|
vertex.x = position[0];
|
|
vertex.y = position[1];
|
|
vertex.z = position[2];
|
|
vertex.rhw = position[3];
|
|
}
|