Skip to content

Commit 01f65ef

Browse files
committed
Better line drawing for Legend
This should also be the line drawing for Anniversary if the compiler there didn't completely optimize away all functions needed for it.
1 parent 35b2b84 commit 01f65ef

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

src/render/Draw.cpp

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ void TRANS_RotTransPersVectorf(cdc::Vector3* srcvector, cdc::Vector3* dstvector)
1515
Hooking::Call(addr, srcvector, dstvector);
1616
}
1717

18+
#ifdef TR8
1819
void TRANS_TransToDrawVertex(cdc::Vector3* vec, DRAWVERTEX* v)
1920
{
2021
auto addr = GET_ADDRESS(0x000000, 0x000000, 0x48A450);
@@ -28,6 +29,7 @@ void TRANS_TransToLineVertex(cdc::Vector3* vec, LINEVERTEX* v)
2829

2930
Hooking::Call(addr, vec, v);
3031
}
32+
#endif
3133

3234
void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads)
3335
{
@@ -38,7 +40,7 @@ void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads)
3840

3941
void DRAW_DrawLines(LINEVERTEX* verts, int numlines)
4042
{
41-
auto addr = GET_ADDRESS(0x000000, 0x000000, 0x5BFCD0);
43+
auto addr = GET_ADDRESS(0x406120, 0x000000, 0x5BFCD0);
4244

4345
Hooking::Call(addr, verts, numlines);
4446
}
@@ -50,7 +52,7 @@ void DRAW_DrawTriangles(int flags, int tpage, DRAWVERTEX* verts, int numtris)
5052
Hooking::Call(addr, flags, tpage, verts, numtris);
5153
}
5254

53-
inline void TransformToVertex(DRAWVERTEX* v, cdc::Vector3* vec)
55+
inline void TransformToDrawVertex(DRAWVERTEX* v, cdc::Vector3* vec)
5456
{
5557
#ifndef TR8
5658
TRANS_TransToDrawVertexV4f(v, vec);
@@ -59,13 +61,22 @@ inline void TransformToVertex(DRAWVERTEX* v, cdc::Vector3* vec)
5961
#endif
6062
}
6163

64+
inline void TransformToLineVertex(LINEVERTEX* v, cdc::Vector3* vec)
65+
{
66+
#ifndef TR8
67+
TRANS_TransToDrawVertexV4f((DRAWVERTEX*)v, vec);
68+
#else
69+
TRANS_TransToLineVertex(vec, v);
70+
#endif
71+
}
72+
6273
void DrawTriangle(cdc::Vector3* v0, cdc::Vector3* v1, cdc::Vector3* v2, int color)
6374
{
6475
DRAWVERTEX verts[3];
6576

66-
TransformToVertex(verts, v0);
67-
TransformToVertex(&verts[1], v1);
68-
TransformToVertex(&verts[2], v2);
77+
TransformToDrawVertex(verts, v0);
78+
TransformToDrawVertex(&verts[1], v1);
79+
TransformToDrawVertex(&verts[2], v2);
6980

7081
verts[0].color = color;
7182
verts[1].color = color;
@@ -81,12 +92,12 @@ void DrawPlane(cdc::Vector3* v0, cdc::Vector3* v1, int color)
8192
auto v2 = cdc::Vector3{ v0->x, v0->y, v1->z };
8293
auto v3 = cdc::Vector3{ v1->x, v1->y, v0->z };
8394

84-
TransformToVertex(verts, v0);
85-
TransformToVertex(&verts[1], &v2);
86-
TransformToVertex(&verts[2], v1);
87-
TransformToVertex(&verts[3], &v3);
88-
TransformToVertex(&verts[4], v1);
89-
TransformToVertex(&verts[5], v0);
95+
TransformToDrawVertex(verts, v0);
96+
TransformToDrawVertex(&verts[1], &v2);
97+
TransformToDrawVertex(&verts[2], v1);
98+
TransformToDrawVertex(&verts[3], &v3);
99+
TransformToDrawVertex(&verts[4], v1);
100+
TransformToDrawVertex(&verts[5], v0);
90101

91102
verts[0].color = color;
92103
verts[1].color = color;
@@ -98,10 +109,9 @@ void DrawPlane(cdc::Vector3* v0, cdc::Vector3* v1, int color)
98109
DRAW_DrawTriangles(2, 0, verts, 2);
99110
}
100111

101-
// Scuffed ass line, TODO fix
102112
void DrawLine(cdc::Vector3* v0, cdc::Vector3* v1, int color)
103113
{
104-
#ifndef TR8
114+
#ifdef TRAE
105115
DRAWVERTEX verts[6];
106116

107117
auto v2 = *v1;
@@ -112,12 +122,12 @@ void DrawLine(cdc::Vector3* v0, cdc::Vector3* v1, int color)
112122
v2.y += 20.f;
113123
v3.y += 20.f;
114124

115-
TransformToVertex(verts, v0);
116-
TransformToVertex(&verts[1], &v2);
117-
TransformToVertex(&verts[2], v1);
118-
TransformToVertex(&verts[3], &v3);
119-
TransformToVertex(&verts[4], v1);
120-
TransformToVertex(&verts[5], v0);
125+
TransformToDrawVertex(verts, v0);
126+
TransformToDrawVertex(&verts[1], &v2);
127+
TransformToDrawVertex(&verts[2], v1);
128+
TransformToDrawVertex(&verts[3], &v3);
129+
TransformToDrawVertex(&verts[4], v1);
130+
TransformToDrawVertex(&verts[5], v0);
121131

122132
verts[0].color = color;
123133
verts[1].color = color;
@@ -130,8 +140,8 @@ void DrawLine(cdc::Vector3* v0, cdc::Vector3* v1, int color)
130140
#else
131141
LINEVERTEX lines[2];
132142

133-
TRANS_TransToLineVertex(v0, lines);
134-
TRANS_TransToLineVertex(v1, &lines[1]);
143+
TransformToLineVertex(lines, v0);
144+
TransformToLineVertex(&lines[1], v1);
135145

136146
lines[0].color = color;
137147
lines[1].color = color;

src/render/Draw.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ struct LINEVERTEX
3232

3333
void TRANS_TransToDrawVertexV4f(DRAWVERTEX* v, cdc::Vector3* vec);
3434
void TRANS_RotTransPersVectorf(cdc::Vector3* srcvector, cdc::Vector3* dstvector);
35+
36+
#ifdef TR8
3537
void TRANS_TransToDrawVertex(cdc::Vector3* vec, DRAWVERTEX* v);
3638
void TRANS_TransToLineVertex(cdc::Vector3* vec, LINEVERTEX* v);
39+
#endif
3740

3841
void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads);
3942
void DRAW_DrawTriangles(int flags, int tpage, DRAWVERTEX* verts, int numtris);
4043
void DRAW_DrawLines(LINEVERTEX* verts, int numlines);
4144

42-
void TransformToVertex(DRAWVERTEX* v, cdc::Vector3* vec);
45+
void TransformToDrawVertex(DRAWVERTEX* v, cdc::Vector3* vec);
46+
void TransformToLineVertex(LINEVERTEX* v, cdc::Vector3* vec);
4347

4448
void DrawTriangle(cdc::Vector3* v0, cdc::Vector3* v1, cdc::Vector3* v2, int color);
4549
void DrawPlane(cdc::Vector3* v0, cdc::Vector3* v1, int color);
4650
void DrawLine(cdc::Vector3* v0, cdc::Vector3* v1, int color);
4751
void DrawBoundingBox(cdc::Vector3* v0, cdc::Vector3* v1, int color);
4852
void DrawBoundingBox(cdc::Vector3* v0, cdc::Vector3* v1, cdc::Vector3* v2, cdc::Vector3* v3, int color);
49-
5053
void DrawBox(cdc::Vector3* v0, cdc::Vector3* v1, cdc::Vector3* v2, cdc::Vector3* v3, int color);

0 commit comments

Comments
 (0)