Skip to content

Commit 0d598fb

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
2 parents 4a44a1b + e0ac6bc commit 0d598fb

14 files changed

Lines changed: 168 additions & 127 deletions

GolDP/src/font/golfont.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ void GolFont::RefreshSurfaces(GolD3DRenderDevice* p_renderer)
121121
// STUB: GOLDP 0x100047b0
122122
void GolFont::VTable0x04(GolD3DRenderDevice* p_renderer, GolSurfaceFormat* p_textureFormat)
123123
{
124-
STUB(0x100047b0);
125-
126124
m_textures = new PurpleDune0x7c[m_surfaceCount];
127125
if (m_textures == NULL) {
128126
GOL_FATALERROR(c_golErrorOutOfMemory);
@@ -226,8 +224,6 @@ void GolFont::SelectSurface(LegoU32 p_index)
226224
// STUB: GOLDP 0x10004c20
227225
void GolFont::VTable0x14(Rect* p_sourceRect, Rect* p_destRect)
228226
{
229-
STUB(0x10004c20);
230-
231227
LegoS32 sourceBottom = p_sourceRect->m_bottom - 1;
232228
D3DTLVERTEX vertices[4];
233229

GolDP/src/render/gold3drenderdevice.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,16 +1646,16 @@ void GolD3DRenderDevice::VTable0x70(
16461646
p_image->FUN_100054d0(this, p_unk0x08, &destRect, 0);
16471647
}
16481648

1649-
// STUB: GOLDP 0x10009a70
1649+
// FUNCTION: GOLDP 0x10009a70
16501650
void GolD3DRenderDevice::VTable0xb4(GolBillboard& p_param)
16511651
{
16521652
LegoBool32 visibility[2];
16531653
p_param.FUN_10029fa0(m_unk0x4c.m_position, visibility);
16541654
if (visibility[0]) {
16551655
GolVec3 forward;
16561656
GolVec3 right;
1657-
GolTransformBase* orbit = m_unk0x0c->m_transform;
1658-
orbit->VTable0x1c(&right, &forward);
1657+
GolCamera* camera = m_unk0x0c;
1658+
camera->m_transform->VTable0x1c(&right, &forward);
16591659

16601660
forward.m_x = -forward.m_x;
16611661
forward.m_y = -forward.m_y;
@@ -4039,13 +4039,11 @@ void GolD3DRenderDevice::FUN_1000e930(LegoU32 p_outputFirst, LegoU32 p_firstVert
40394039
cache[p_vertexCount].m_unk0x10 = savedCacheIndex;
40404040
}
40414041

4042-
// STUB: GOLDP 0x1000eb90
4042+
// FUNCTION: GOLDP 0x1000eb90
40434043
void GolD3DRenderDevice::FUN_1000eb90(undefined4 p_firstTriangle, undefined4 p_triangleCount, undefined4)
40444044
{
4045-
DuskwindBananaRelic0x24* material = m_unk0xc8530.m_material;
4046-
undefined4 firstTriangle = p_firstTriangle;
4047-
m_unk0xc854c.m_firstTriangle = firstTriangle;
4048-
m_unk0xc854c.m_material = material;
4045+
m_unk0xc854c.m_material = m_unk0xc8530.m_material;
4046+
m_unk0xc854c.m_firstTriangle = p_firstTriangle;
40494047
m_unk0xc854c.m_triangleCount = p_triangleCount;
40504048
m_unk0xc8524->VTable0x0c(&m_unk0xc854c);
40514049
}

GolDP/src/scene/golbillboardex.cpp

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void GolBillboard::FUN_10014e20()
3333
g_billboardTexCoords[3].m_y = g_unk0x1005675c;
3434
}
3535

36-
// STUB: GOLDP 0x10014e50
36+
// FUNCTION: GOLDP 0x10014e50
3737
LegoBool32 GolBillboard::FUN_10014e50(const GolVec3* p_arg1, const GolVec3* p_arg2, GolMatrix4* p_matrix)
3838
{
3939
GolVec3 row0;
@@ -49,20 +49,37 @@ LegoBool32 GolBillboard::FUN_10014e50(const GolVec3* p_arg1, const GolVec3* p_ar
4949

5050
if (m_flags & c_flagBit1) {
5151
row2 = &m_unk0x30;
52-
LegoFloat dot = row0.m_x * row2->m_x + row0.m_y * row2->m_y + row2->m_z * row0.m_z;
53-
row0.m_x -= dot * m_unk0x30.m_x;
54-
row0.m_y -= dot * m_unk0x30.m_y;
55-
row0.m_z -= dot * m_unk0x30.m_z;
52+
LegoFloat dot = row2->m_z;
53+
dot *= row0.m_z;
54+
dot += row0.m_y * row2->m_y;
55+
dot += row0.m_x * row2->m_x;
56+
row0.m_x -= dot * row2->m_x;
57+
LegoFloat projection = row2->m_y;
58+
projection *= dot;
59+
row0.m_y -= projection;
60+
projection = row2->m_z;
61+
projection *= dot;
62+
row0.m_z -= projection;
5663
}
5764
else {
5865
row2 = p_arg2;
5966
}
6067

6168
GolMath::NormalizeVector3(row0, &row0);
6269

63-
row1.m_x = row2->m_y * row0.m_z - row2->m_z * row0.m_y;
64-
row1.m_y = row2->m_z * row0.m_x - row2->m_x * row0.m_z;
65-
row1.m_z = row2->m_x * row0.m_y - row2->m_y * row0.m_x;
70+
row1.m_x = row0.m_z;
71+
row1.m_x *= row2->m_y;
72+
LegoFloat term = row2->m_z;
73+
term *= row0.m_y;
74+
row1.m_x -= term;
75+
row1.m_y = row2->m_z;
76+
row1.m_y *= row0.m_x;
77+
row1.m_y -= row0.m_z * row2->m_x;
78+
row1.m_z = row0.m_y;
79+
row1.m_z *= row2->m_x;
80+
term = row2->m_y;
81+
term *= row0.m_x;
82+
row1.m_z -= term;
6683

6784
p_matrix->m_m[0][0] = row0.m_x;
6885
p_matrix->m_m[0][1] = row0.m_y;
@@ -82,8 +99,12 @@ LegoBool32 GolBillboard::FUN_10014e50(const GolVec3* p_arg1, const GolVec3* p_ar
8299
LegoFloat halfWidth = m_width / 2.0f;
83100
LegoFloat halfHeight = m_height / 2.0f;
84101
p_matrix->m_m[3][0] = position.m_x - halfWidth * row1.m_x - halfHeight * row2->m_x;
85-
p_matrix->m_m[3][1] = position.m_y - halfWidth * row1.m_y - halfHeight * row2->m_y;
86-
p_matrix->m_m[3][2] = position.m_z - halfWidth * row1.m_z - halfHeight * row2->m_z;
102+
LegoFloat offset = row2->m_y;
103+
offset *= halfHeight;
104+
p_matrix->m_m[3][1] = position.m_y - halfWidth * row1.m_y - offset;
105+
offset = row2->m_z;
106+
offset *= halfHeight;
107+
p_matrix->m_m[3][2] = position.m_z - halfWidth * row1.m_z - offset;
87108
p_matrix->m_m[3][3] = 1.0f;
88109

89110
return TRUE;

LEGORacers/src/race/cobalttrail0x140.cpp

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ undefined2 g_unk0x004c4814[42];
2525
extern const LegoFloat g_unk0x004afde0 = 10.0f;
2626

2727
extern const LegoFloat g_ghostAnimationRateScale;
28+
extern const LegoFloat g_ghostSpeedScale;
29+
extern const LegoFloat g_raceSessionField0xf8CollisionStartOffset;
30+
31+
// GLOBAL: LEGORACERS 0x004b02a0
32+
extern const LegoFloat g_cobaltTrailBaseLength = 6.5f;
33+
34+
// GLOBAL: LEGORACERS 0x004b02a4
35+
extern const LegoFloat g_cobaltTrailBaseHalfWidth = 5.5f;
36+
37+
// GLOBAL: LEGORACERS 0x004b02a8
38+
extern const LegoFloat g_cobaltTrailTipLength = 9.5f;
2839

2940
// GLOBAL: LEGORACERS 0x004b02ac
3041
extern const LegoFloat g_unk0x004b02ac = 128.0f;
@@ -363,49 +374,70 @@ LegoU32 CobaltTrail0x140::FUN_004246d0(LegoChar* p_buffer, LegoU32 p_time)
363374
return extraMinutes;
364375
}
365376

366-
// STUB: LEGORACERS 0x004247d0
377+
// FUNCTION: LEGORACERS 0x004247d0
367378
void CobaltTrail0x140::FUN_004247d0(LegoS32 p_x, LegoS32 p_y, LegoFloat p_directionX, LegoFloat p_directionY)
368379
{
369-
const LegoFloat tipLength = 9.5f;
370-
const LegoFloat baseLength = 6.5f;
371-
const LegoFloat baseHalfWidth = 5.5f;
372-
const LegoFloat tailLength = 5.0f;
373-
const LegoFloat tailHalfWidth = 4.0f;
374380
const LegoFloat tailEndLength = 8.0f;
375381

382+
LegoU8 colorAlpha = 0xff;
376383
GolRenderDevice::TexturedVertex vertices[6];
377384

378-
vertices[0].m_x = p_directionX * tipLength;
379-
vertices[0].m_y = p_directionY * tipLength;
380-
vertices[1].m_x = p_directionY * baseHalfWidth - p_directionX * baseLength;
381-
vertices[1].m_y = -p_directionX * baseHalfWidth - p_directionY * baseLength;
382-
vertices[2].m_x = -p_directionY * baseHalfWidth - p_directionX * baseLength;
383-
vertices[2].m_y = p_directionX * baseHalfWidth - p_directionY * baseLength;
385+
LegoFloat tipX = p_directionX;
386+
tipX *= g_cobaltTrailTipLength;
387+
vertices[0].m_x = tipX;
388+
LegoFloat tipY = p_directionY;
389+
tipY *= g_cobaltTrailTipLength;
390+
vertices[0].m_y = tipY;
391+
392+
LegoFloat baseSide = p_directionY;
393+
baseSide *= g_cobaltTrailBaseHalfWidth;
394+
LegoFloat baseForward = p_directionX;
395+
baseForward *= g_cobaltTrailBaseLength;
396+
vertices[1].m_x = baseSide - baseForward;
397+
398+
LegoFloat baseForwardY = p_directionY;
399+
baseForwardY *= g_cobaltTrailBaseLength;
400+
LegoFloat baseSideX = p_directionX;
401+
baseSideX *= g_cobaltTrailBaseHalfWidth;
402+
vertices[1].m_y = -baseForwardY - baseSideX;
403+
vertices[2].m_x = -baseForward - baseSide;
404+
vertices[2].m_y = baseSideX - baseForwardY;
384405

385406
vertices[3].m_x = p_directionX * tailEndLength;
386407
vertices[3].m_y = p_directionY * tailEndLength;
387-
vertices[4].m_x = p_directionY * tailHalfWidth - p_directionX * tailLength;
388-
vertices[4].m_y = -p_directionX * tailHalfWidth - p_directionY * tailLength;
389-
vertices[5].m_x = -p_directionY * tailHalfWidth - p_directionX * tailLength;
390-
vertices[5].m_y = p_directionX * tailHalfWidth - p_directionY * tailLength;
408+
LegoFloat tailSide = p_directionY;
409+
tailSide *= g_ghostSpeedScale;
410+
LegoFloat tailForward = p_directionX;
411+
tailForward *= g_raceSessionField0xf8CollisionStartOffset;
412+
vertices[4].m_x = tailSide - tailForward;
413+
414+
LegoFloat tailForwardY = p_directionY;
415+
tailForwardY *= g_raceSessionField0xf8CollisionStartOffset;
416+
LegoFloat tailSideX = p_directionX;
417+
tailSideX *= g_ghostSpeedScale;
418+
vertices[4].m_y = -tailForwardY - tailSideX;
419+
vertices[5].m_x = -tailForward - tailSide;
420+
vertices[5].m_y = tailSideX - tailForwardY;
391421

392422
LegoFloat originX = static_cast<LegoFloat>(p_x);
393423
LegoFloat originY = static_cast<LegoFloat>(p_y);
394424
for (LegoS32 i = 0; i < sizeOfArray(vertices); i++) {
395425
vertices[i].m_color.m_red = 0;
396426
vertices[i].m_color.m_grn = 0;
397427
vertices[i].m_color.m_blu = 0;
398-
vertices[i].m_color.m_alp = 0xff;
428+
vertices[i].m_color.m_alp = colorAlpha;
399429
vertices[i].m_z = 0.0f;
400-
vertices[i].m_x = vertices[i].m_x * m_unk0x104 + originX;
401-
vertices[i].m_y = vertices[i].m_y * m_unk0x114 + originY;
430+
LegoFloat scaledX = vertices[i].m_x;
431+
scaledX *= m_unk0x104;
432+
vertices[i].m_x = scaledX + originX;
433+
vertices[i].m_y = m_unk0x114 * vertices[i].m_y + originY;
402434
}
403435

404436
DuskwindBananaRelic0x24* material = m_unk0x118;
405437
m_unk0x118 = NULL;
406-
vertices[3].m_color.m_grn = 0xff;
407-
vertices[4].m_color.m_grn = 0xff;
408-
vertices[5].m_color.m_grn = 0xff;
438+
vertices[3].m_color.m_grn = colorAlpha;
439+
vertices[4].m_color.m_grn = colorAlpha;
440+
vertices[5].m_color.m_grn = colorAlpha;
409441
FUN_00423fc0(&vertices[1], &vertices[0], &vertices[2]);
410442
FUN_00423fc0(&vertices[4], &vertices[3], &vertices[5]);
411443
m_unk0x118 = material;

LEGORacers/src/race/racesessionfield0x2098.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,10 +1631,10 @@ void RaceSession::Field0x2098::FUN_00460ad0(GolFileParser* p_parser)
16311631
for (token = p_parser->GetNextToken(); token != GolFileParser::e_rightCurly; token = p_parser->GetNextToken()) {
16321632
switch (token) {
16331633
case GolFileParser::e_unknown0x49:
1634-
params.m_unk0x14 = p_parser->ReadInteger();
1634+
params.m_unk0x18 = p_parser->ReadInteger();
16351635
break;
16361636
case GolFileParser::e_unknown0x4c:
1637-
params.m_unk0x18 = p_parser->ReadInteger();
1637+
params.m_unk0x14 = p_parser->ReadInteger();
16381638
break;
16391639
case GolFileParser::e_unknown0x27: {
16401640
LegoS32 eventIndex = p_parser->GetNextToken() - GolFileParser::e_unknown0x34;
@@ -2721,12 +2721,14 @@ void RaceSession::Field0x2098::AnimatedPartResource0x34::VTable0x04(GolVec3*)
27212721
}
27222722
}
27232723

2724-
// STUB: LEGORACERS 0x004635c0
2724+
// FUNCTION: LEGORACERS 0x004635c0
27252725
void RaceSession::Field0x2098::AnimatedPartResource0x34::VTable0x0c()
27262726
{
27272727
LegoU32 state = m_state0x18;
2728-
LegoU32 nextState = c_state0x18One;
2729-
if (state != nextState) {
2728+
LegoU32 nextState = state;
2729+
LegoU32 resetState = c_state0x18One;
2730+
if (state != resetState) {
2731+
nextState = resetState;
27302732
GolAnimatedEntity* entity = m_unk0x20;
27312733
LegoS32 targetPart = m_unk0x28;
27322734
LegoS32 currentPart = entity->GetCurrentPartIndex();

LEGORacers/src/race/racesessionfield0x2148.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,14 +2692,14 @@ RaceEventDispatcher0x08::Item0x2e::~Item0x2e()
26922692
// FUNCTION: LEGORACERS 0x0048e370
26932693
LegoS32 RaceEventDispatcher0x08::Item0x2e::ClearFields()
26942694
{
2695-
m_unk0x3c = NULL;
2696-
m_unk0x40 = NULL;
2697-
m_unk0x44 = NULL;
2698-
m_unk0x38 = NULL;
2699-
m_unk0x48 = NULL;
27002695
m_unk0x4c[0] = 0.0f;
27012696
m_unk0x4c[1] = 0.0f;
27022697
m_unk0x4c[2] = 0.0f;
2698+
m_unk0x40 = NULL;
2699+
m_unk0x44 = NULL;
2700+
m_unk0x48 = NULL;
2701+
m_unk0x38 = NULL;
2702+
m_unk0x3c = NULL;
27032703
m_unk0x58 = 1;
27042704

27052705
return 0;

LEGORacers/src/race/racesessionfield0x27d4.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -519,31 +519,22 @@ void RaceSessionField0x27d4::FUN_00492680(
519519
}
520520
}
521521

522-
// STUB: LEGORACERS 0x004927c0
522+
// FUNCTION: LEGORACERS 0x004927c0
523523
RaceSessionField0x27d4::Item* RaceSessionField0x27d4::FUN_004927c0(LegoU32 p_unk0x04)
524524
{
525525
LegoU32 i = 0;
526526
LegoU32 count = m_count;
527-
if (count) {
528-
LegoU8* flags = &m_items[0].m_flags0x328;
529-
do {
530-
if (!(*flags & Item::c_flags0x328Bit0)) {
531-
break;
532-
}
533-
534-
i++;
535-
flags += sizeof(Item);
536-
} while (i < count);
527+
while (i < count && m_items[i].IsActive()) {
528+
i++;
537529
}
538530

539531
if (i == count) {
540532
return NULL;
541533
}
542534

543-
Item* items = m_items;
544-
items[i].FUN_00491d90(p_unk0x04);
535+
m_items[i].FUN_00491d90(p_unk0x04);
545536

546-
return &items[i];
537+
return &m_items[i];
547538
}
548539

549540
// FUNCTION: LEGORACERS 0x00492820

LEGORacers/src/race/racesessionfield0x6dcfield0x238.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void RacePowerupManager::Field0x238::VTable0x14()
100100
m_unk0x0a8.FUN_00493e60();
101101
}
102102

103-
// STUB: LEGORACERS 0x00444490
103+
// FUNCTION: LEGORACERS 0x00444490
104104
LegoS32 RacePowerupManager::Field0x238::VTable0x18(LegoU32 p_elapsedMs)
105105
{
106106
if (m_unk0x234 & c_flags0x234Bit1) {
@@ -111,8 +111,9 @@ LegoS32 RacePowerupManager::Field0x238::VTable0x18(LegoU32 p_elapsedMs)
111111
return FUN_00444820(p_elapsedMs);
112112
}
113113

114-
LegoS32 result = RaceSessionField0x6dcField0xa8::VTable0x18(p_elapsedMs);
115-
if (m_unk0x004 == 1) {
114+
RaceSessionField0x6dcField0xa8::VTable0x18(p_elapsedMs);
115+
LegoS32 result = m_unk0x004;
116+
if (result == 1) {
116117
LegoFloat elapsedMs = static_cast<LegoFloat>(m_unk0x050);
117118
LegoFloat elapsed = elapsedMs / static_cast<LegoFloat>(static_cast<LegoS32>(m_unk0x054));
118119
m_unk0x220 = (1.0f - elapsed) * m_unk0x21c;
@@ -138,15 +139,13 @@ void RacePowerupManager::Field0x238::FUN_00444540(const GolVec3* p_position, Leg
138139
m_unk0x09c->m_unk0x018.m_unk0x044->VTable0x04(&origin);
139140
origin.m_z += m_unk0x218;
140141

141-
GolVec3 delta;
142-
delta.m_x = p_position->m_x - origin.m_x;
143-
delta.m_y = p_position->m_y - origin.m_y;
144-
delta.m_z = p_position->m_z - origin.m_z;
142+
LegoFloat deltaX = p_position->m_x - origin.m_x;
143+
LegoFloat deltaY = p_position->m_y - origin.m_y;
145144

146145
GolVec3 step;
147-
step.m_x = delta.m_x * g_unk0x004b02e0;
148-
step.m_y = delta.m_y * g_unk0x004b02e0;
149-
step.m_z = delta.m_z;
146+
step.m_x = deltaX * g_unk0x004b02e0;
147+
step.m_y = deltaY * g_unk0x004b02e0;
148+
step.m_z = p_position->m_z - origin.m_z;
150149
m_unk0x0a8.FUN_00493ea0(&origin, &step);
151150

152151
LegoFloat elapsed = 0.0f;
@@ -177,8 +176,9 @@ LegoS32 RacePowerupManager::Field0x238::FUN_00444690(LegoU32 p_elapsedMs)
177176
m_unk0x09c->m_unk0x018.m_unk0x044->VTable0x04(&position);
178177
position.m_z += m_unk0x218;
179178

179+
GolVec3* target = &m_unk0x228;
180180
if (GolMath::FUN_00449a90(
181-
&m_unk0x228,
181+
target,
182182
&position,
183183
g_unk0x004b0c98,
184184
g_unk0x004b0ca0,
@@ -195,9 +195,9 @@ LegoS32 RacePowerupManager::Field0x238::FUN_00444690(LegoU32 p_elapsedMs)
195195

196196
LegoFloat amount = m_unk0x224 * g_unk0x004b0ca4;
197197
GolVec3 delta;
198-
delta.m_x = m_unk0x228.m_x - position.m_x;
199-
delta.m_y = m_unk0x228.m_y - position.m_y;
200-
delta.m_z = m_unk0x228.m_z - position.m_z;
198+
delta.m_x = target->m_x - position.m_x;
199+
delta.m_y = target->m_y - position.m_y;
200+
delta.m_z = target->m_z - position.m_z;
201201

202202
GolVec3 step;
203203
step.m_x = delta.m_x * g_unk0x004b02e0;
@@ -213,7 +213,7 @@ LegoS32 RacePowerupManager::Field0x238::FUN_00444690(LegoU32 p_elapsedMs)
213213
amount = -amount;
214214
}
215215

216-
m_unk0x0a8.FUN_00494870(&m_unk0x228, amount);
216+
m_unk0x0a8.FUN_00494870(target, amount);
217217
m_unk0x0a8.FUN_00494230();
218218

219219
return 1;

0 commit comments

Comments
 (0)