11#include " Draw.h"
22#include " util/Hooking.h"
33
4+ #ifdef TRAE
5+ #include " cdc/render/PCDeviceManager.h"
6+ #include " cdc/render/PCPrimitivePool.h"
7+ #endif
8+
49void TRANS_TransToDrawVertexV4f (DRAWVERTEX* v, cdc::Vector3* vec)
510{
611 auto addr = GET_ADDRESS (0x402EF0 , 0x402F20 , 0x49F990 );
@@ -40,9 +45,27 @@ void DRAW_DrawQuads(int flags, int tpage, DRAWVERTEX* verts, int numquads)
4045
4146void DRAW_DrawLines (LINEVERTEX* verts, int numlines)
4247{
48+ #ifndef TRAE
4349 auto addr = GET_ADDRESS (0x406120 , 0x000000 , 0x5BFCD0 );
4450
4551 Hooking::Call (addr, verts, numlines);
52+ #else
53+ // The DRAW_DrawLines method has been optimized away in Anniversary
54+ // the code below is a reimplementation of the code from Legend
55+ if (cdc::PCDeviceManager::s_pInstance->IsStatusOk ())
56+ {
57+ auto linePool = *(cdc::PCPrimitivePool**)0x7545E0 ;
58+ auto vertices = (LINEVERTEX*)linePool->AllocateVertices (numlines * 2 );
59+
60+ for (int i = 0 ; i < numlines * 2 ; i++)
61+ {
62+ vertices[i] = verts[i];
63+
64+ // Swap RGBA to ARGB
65+ vertices[i].color = (verts[i].color << 24 ) | (verts[i].color >> 8 );
66+ }
67+ }
68+ #endif
4669}
4770
4871void DRAW_DrawTriangles (int flags, int tpage, DRAWVERTEX* verts, int numtris)
@@ -111,33 +134,6 @@ void DrawPlane(cdc::Vector3* v0, cdc::Vector3* v1, int color)
111134
112135void DrawLine (cdc::Vector3* v0, cdc::Vector3* v1, int color)
113136{
114- #ifdef TRAE
115- DRAWVERTEX verts[6 ];
116-
117- auto v2 = *v1;
118- auto v3 = *v0;
119-
120- v2.z += 20 .f ;
121- v3.z += 20 .f ;
122- v2.y += 20 .f ;
123- v3.y += 20 .f ;
124-
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);
131-
132- verts[0 ].color = color;
133- verts[1 ].color = color;
134- verts[2 ].color = color;
135- verts[3 ].color = color;
136- verts[4 ].color = color;
137- verts[5 ].color = color;
138-
139- DRAW_DrawTriangles (2 , 0 , verts, 2 );
140- #else
141137 LINEVERTEX lines[2 ];
142138
143139 TransformToLineVertex (lines, v0);
@@ -147,7 +143,6 @@ void DrawLine(cdc::Vector3* v0, cdc::Vector3* v1, int color)
147143 lines[1 ].color = color;
148144
149145 DRAW_DrawLines (lines, 1 );
150- #endif
151146}
152147
153148void DrawBoundingBox (cdc::Vector3* v0, cdc::Vector3* v1, int color)
0 commit comments