@@ -25,6 +25,17 @@ undefined2 g_unk0x004c4814[42];
2525extern const LegoFloat g_unk0x004afde0 = 10 .0f ;
2626
2727extern 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
3041extern 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
367378void 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;
0 commit comments