coastline 0.0.4
Loading...
Searching...
No Matches
trackrender.h File Reference

The drawing of the placed models of the track near the camera, and of the shadows of the vehicles on them. More...

#include <PR/gbi.h>
#include <PR/ultratypes.h>
#include "common/shadowbuffers.h"
#include "common/vecmath.h"
#include "common/vehicle.h"
Include dependency graph for trackrender.h:

Go to the source code of this file.

Classes

struct  VisibleCell
 A cell of the grid of the track in view, and its squared distance from the camera in cells. More...

Macros

#define VISIBLE_CELLS   192
 The most cells in view, past which the farthest are left out.

Functions

void ProjectWorldToScreenRect (const Vec3f *point, s32 size, s16 low[2], s16 high[2])
 Take a point and a size around it to the corners of the rectangle of the screen they cover in the view being drawn, which are left as they were when the point is at the camera.
void RenderTrackInstance (s32 index, s32 vehicles, s32 deferred)
 Draw a placed model, and on it the shadow of each vehicle in a mask, by its vertices taken to the texture of the shadow and its triangles outside the texture omitted.
s32 CompareVisibleCellDistance (const void *a, const void *b)
 Order two cells in view by their distance from the camera.
void BuildVisibleInstanceList (void)
 List the placed models of the cells in view, the nearest cells first, mark the models the nearest vehicles cast shadows on, set the lights and the reflections of the track, and find the rectangle of the screen of the shadow of each vehicle.
void RenderTrackGeometry (s32 deferred)
 Draw the placed models in view: in the first pass the opaque ones, leaving the translucent ones, and in the second pass those, the farthest first.

Variables

PlayerProfile * g_pActiveProfile
 The profile used for the active season when selecting track instances.
s32 g_bShadowCullDisabled
 Whether shadows include triangles outside their texture and extend beyond their vehicle's screen rectangle.
VisibleCell g_aVisibleCellTuples [VISIBLE_CELLS+1]
 The cells in view, the nearest first, ending with a column of 0xFF.
s32 g_bVisibleCellListOverflow
 Whether the cells in view were more than VISIBLE_CELLS.
s32 g_nVisibleInstanceCount
 The placed models in view this frame.
u8 g_abInstanceVisibilityMask []
 For each placed model: 0xFF until it is listed in view, then 0 with a bit for each vehicle near enough to cast its shadow on it.
s32 g_nVisibleCellIdxNear
 Where in the list of the models the cells start that are at least 3 cells from the camera, more than 1 or, in a replay from the trackside camera, 3, and within 3 cells of the far plane, or -1.
s32 g_nVisibleCellIdxMid
 Where the middle-distance model group starts, or -1.
s32 g_nVisibleCellIdxFar
 Where the models of cells within three cells of the far plane start, or -1.
s32 g_nTrackTransparentStartIdx
 Where the translucent models past g_nVisibleCellIdxMid start in the second pass, which draws them without shadows, and 0x1000 until it is known.
s32 g_nDeferredInstanceLastIdx
 The last translucent model left for the second pass, or -1.
u32 g_dwInstanceHideFlags
 The TRACK_INSTANCE_ flags of the placed models not drawn.
u16 g_wActiveInstanceHideMask
 The groups of placed models hidden from the camera.
s32 g_bDebugHideInstance
 Whether g_nDebugHiddenInstanceIndex is left undrawn.
u32 g_dwTrackOtherModeLBlend
 The blender and the other bits of the render mode of the track.
u32 g_dwTrackOtherModeLFlags
 The render-mode flags applied with g_dwTrackOtherModeLBlend.
s32 g_nNearbyVehicleCount
 The vehicles nearest the camera that cast shadows, nearest first.
s32 g_anNearbyVehicleIdx [MAX_VEHICLES]
 The indices of the vehicles near enough to cast shadows on placed models.
f32 g_afNearbyVehicleDot [MAX_VEHICLES]
 How far ahead of the camera each one is.
Vec3f g_vVehicleVisibilityDelta
 From the camera to a vehicle.
f32 g_fViewMatrixMaxAbs
 The largest absolute value of the first three rows of g_afViewProjMatrix.
LookAt * g_pTrackLookAt
 The look-at of the reflections of the track.
Lights1 g_aTrackLights [4]
 The lights of the track, one of four in turn each frame.
s32 g_nTrackLightBufferIndex
 The index of the light buffer used to draw the track this frame.
Vec3f g_vTrackLightDirection
 The direction of the light of the track.
Vec3f g_vShadowForward
 The forward of the vehicle whose shadow is being cast, on the ground.
const f32 g_fShadowLengthScale
 Scale of the vehicle shadow along its length.
const f32 g_fShadowWidthScale
 Scale of the vehicle shadow across its width.

Detailed Description

The drawing of the placed models of the track near the camera, and of the shadows of the vehicles on them.

Macro Definition Documentation

◆ VISIBLE_CELLS

#define VISIBLE_CELLS   192

The most cells in view, past which the farthest are left out.

Function Documentation

◆ ProjectWorldToScreenRect()

void ProjectWorldToScreenRect ( const Vec3f * point,
s32 size,
s16 low[2],
s16 high[2] )

Take a point and a size around it to the corners of the rectangle of the screen they cover in the view being drawn, which are left as they were when the point is at the camera.

Parameters
pointThe point.
sizeThe size around it.
lowThe left and the lower edge.
highThe right and the upper edge.
Ghidra address:
USA: 0x80233e10
Ghidra address:
Asia: 0x80233960
Ghidra address:
EUR: 0x80235320
Ghidra address:
JPN: 0x80235120

◆ RenderTrackInstance()

void RenderTrackInstance ( s32 index,
s32 vehicles,
s32 deferred )

Draw a placed model, and on it the shadow of each vehicle in a mask, by its vertices taken to the texture of the shadow and its triangles outside the texture omitted.

Parameters
indexThe placed model.
vehiclesA bit for each vehicle whose shadow falls on it.
deferredWhether to draw shadows as translucent in the second pass.
Ghidra address:
USA: 0x80234050
Ghidra address:
Asia: 0x80233BA0
Ghidra address:
EUR: 0x80235560
Ghidra address:
JPN: 0x80235360

◆ CompareVisibleCellDistance()

s32 CompareVisibleCellDistance ( const void * a,
const void * b )

Order two cells in view by their distance from the camera.

Parameters
aThe first cell.
bThe second cell.
Returns
-1 when the first is nearer, 1 when the second is, or 0 when they are as near.
Ghidra address:
USA: 0x80234fc0
Ghidra address:
Asia: 0x80234B10
Ghidra address:
EUR: 0x802364d0
Ghidra address:
JPN: 0x802362d0
Ghidra address:
BRD3D: 0x10010d90
Ghidra address:
BRGlide: 0x1000e2f0

◆ BuildVisibleInstanceList()

void BuildVisibleInstanceList ( void )

List the placed models of the cells in view, the nearest cells first, mark the models the nearest vehicles cast shadows on, set the lights and the reflections of the track, and find the rectangle of the screen of the shadow of each vehicle.

Ghidra address:
USA: 0x80234ff8
Ghidra address:
Asia: 0x80234B48
Ghidra address:
EUR: 0x80236508
Ghidra address:
JPN: 0x80236308

◆ RenderTrackGeometry()

void RenderTrackGeometry ( s32 deferred)

Draw the placed models in view: in the first pass the opaque ones, leaving the translucent ones, and in the second pass those, the farthest first.

Parameters
deferredWhether this is the second pass.
Ghidra address:
USA: 0x80235bac
Ghidra address:
Asia: 0x802356FC
Ghidra address:
EUR: 0x802370bc
Ghidra address:
JPN: 0x80236ebc

Variable Documentation

◆ g_pActiveProfile

PlayerProfile* g_pActiveProfile
extern

The profile used for the active season when selecting track instances.

Ghidra address:
USA: 0x8031c5bc
Ghidra address:
Asia: 0x8031C06C
Ghidra address:
EUR: 0x8031eabc
Ghidra address:
JPN: 0x8031d6ec

◆ g_bShadowCullDisabled

s32 g_bShadowCullDisabled
extern

Whether shadows include triangles outside their texture and extend beyond their vehicle's screen rectangle.

Ghidra address:
USA: 0x8028aa60
Ghidra address:
Asia: 0x8028A5B0
Ghidra address:
EUR: 0x8028cc68
Ghidra address:
JPN: 0x8028c738
Ghidra address:
BRD3D: 0x106c660c
Ghidra address:
BRGlide: 0x106ed69c

◆ g_aVisibleCellTuples

VisibleCell g_aVisibleCellTuples[VISIBLE_CELLS+1]
extern

The cells in view, the nearest first, ending with a column of 0xFF.

Ghidra address:
USA: 0x8035d1d0
Ghidra address:
Asia: 0x8035CC80
Ghidra address:
EUR: 0x8035f6d0
Ghidra address:
JPN: 0x8035e340
Ghidra address:
BRD3D: 0x10364000

◆ g_bVisibleCellListOverflow

s32 g_bVisibleCellListOverflow
extern

Whether the cells in view were more than VISIBLE_CELLS.

Ghidra address:
USA: 0x8028c76c
Ghidra address:
Asia: 0x8028C2BC
Ghidra address:
EUR: 0x8028eecc
Ghidra address:
JPN: 0x8028e91c
Ghidra address:
BRD3D: 0x102e5ed0

◆ g_nVisibleInstanceCount

s32 g_nVisibleInstanceCount
extern

The placed models in view this frame.

Ghidra address:
USA: 0x8028c740
Ghidra address:
Asia: 0x8028C290
Ghidra address:
EUR: 0x8028eea0
Ghidra address:
JPN: 0x8028e8f0
Ghidra address:
BRD3D: 0x103643a4
Ghidra address:
BRGlide: 0x1035fb8c

◆ g_abInstanceVisibilityMask

u8 g_abInstanceVisibilityMask[]
extern

For each placed model: 0xFF until it is listed in view, then 0 with a bit for each vehicle near enough to cast its shadow on it.

Ghidra address:
USA: 0x80351d80
Ghidra address:
Asia: 0x80351830
Ghidra address:
EUR: 0x80354280
Ghidra address:
JPN: 0x80352ef0
Ghidra address:
BRD3D: 0x1038b4c0
Ghidra address:
BRGlide: 0x10386ca8

◆ g_nVisibleCellIdxNear

s32 g_nVisibleCellIdxNear
extern

Where in the list of the models the cells start that are at least 3 cells from the camera, more than 1 or, in a replay from the trackside camera, 3, and within 3 cells of the far plane, or -1.

Ghidra address:
USA: 0x8028c778
Ghidra address:
Asia: 0x8028C2C8
Ghidra address:
EUR: 0x8028eed8
Ghidra address:
JPN: 0x8028e928
Ghidra address:
BRD3D: 0x10363fec
Ghidra address:
BRGlide: 0x1035f7d4

◆ g_nVisibleCellIdxMid

s32 g_nVisibleCellIdxMid
extern

Where the middle-distance model group starts, or -1.

Ghidra address:
USA: 0x8028c788
Ghidra address:
Asia: 0x8028C2D8
Ghidra address:
EUR: 0x8028eee8
Ghidra address:
JPN: 0x8028e938
Ghidra address:
BRD3D: 0x102e5ec0
Ghidra address:
BRGlide: 0x102e16a8

◆ g_nVisibleCellIdxFar

s32 g_nVisibleCellIdxFar
extern

Where the models of cells within three cells of the far plane start, or -1.

Ghidra address:
USA: 0x8028c780
Ghidra address:
Asia: 0x8028C2D0
Ghidra address:
EUR: 0x8028eee0
Ghidra address:
JPN: 0x8028e930
Ghidra address:
BRD3D: 0x102e5f24
Ghidra address:
BRGlide: 0x102e170c

◆ g_nTrackTransparentStartIdx

s32 g_nTrackTransparentStartIdx
extern

Where the translucent models past g_nVisibleCellIdxMid start in the second pass, which draws them without shadows, and 0x1000 until it is known.

Ghidra address:
USA: 0x8028c78c
Ghidra address:
Asia: 0x8028C2DC
Ghidra address:
EUR: 0x8028eeec
Ghidra address:
JPN: 0x8028e93c
Ghidra address:
BRD3D: 0x102e54b8
Ghidra address:
BRGlide: 0x102e0ca0

◆ g_nDeferredInstanceLastIdx

s32 g_nDeferredInstanceLastIdx
extern

The last translucent model left for the second pass, or -1.

Ghidra address:
USA: 0x8028c748
Ghidra address:
Asia: 0x8028C298
Ghidra address:
EUR: 0x8028eea8
Ghidra address:
JPN: 0x8028e8f8

◆ g_dwInstanceHideFlags

u32 g_dwInstanceHideFlags
extern

The TRACK_INSTANCE_ flags of the placed models not drawn.

Ghidra address:
USA: 0x8035d520
Ghidra address:
Asia: 0x8035CFD0
Ghidra address:
EUR: 0x8035fa20
Ghidra address:
JPN: 0x8035e690

◆ g_wActiveInstanceHideMask

u16 g_wActiveInstanceHideMask
extern

The groups of placed models hidden from the camera.

Ghidra address:
USA: 0x8028c770
Ghidra address:
Asia: 0x8028C2C0
Ghidra address:
EUR: 0x8028eed0
Ghidra address:
JPN: 0x8028e920
Ghidra address:
BRD3D: 0x1039b6cc
Ghidra address:
BRGlide: 0x10396eb4

◆ g_bDebugHideInstance

s32 g_bDebugHideInstance
extern

Whether g_nDebugHiddenInstanceIndex is left undrawn.

Ghidra address:
USA: 0x8028c758
Ghidra address:
Asia: 0x8028C2A8
Ghidra address:
EUR: 0x8028eeb8
Ghidra address:
JPN: 0x8028e908
Ghidra address:
BRD3D: 0x1039b6c4
Ghidra address:
BRGlide: 0x10396eac

◆ g_dwTrackOtherModeLBlend

u32 g_dwTrackOtherModeLBlend
extern

The blender and the other bits of the render mode of the track.

Ghidra address:
USA: 0x8028c74c
Ghidra address:
Asia: 0x8028C29C
Ghidra address:
EUR: 0x8028eeac
Ghidra address:
JPN: 0x8028e8fc
Ghidra address:
BRD3D: 0x1036439c
Ghidra address:
BRGlide: 0x1035fb84

◆ g_dwTrackOtherModeLFlags

u32 g_dwTrackOtherModeLFlags
extern

The render-mode flags applied with g_dwTrackOtherModeLBlend.

Ghidra address:
USA: 0x8028c750
Ghidra address:
Asia: 0x8028C2A0
Ghidra address:
EUR: 0x8028eeb0
Ghidra address:
JPN: 0x8028e900
Ghidra address:
BRD3D: 0x103643a0
Ghidra address:
BRGlide: 0x1035fb88

◆ g_nNearbyVehicleCount

s32 g_nNearbyVehicleCount
extern

The vehicles nearest the camera that cast shadows, nearest first.

Ghidra address:
USA: 0x8035d4fc
Ghidra address:
Asia: 0x8035CFAC
Ghidra address:
EUR: 0x8035f9fc
Ghidra address:
JPN: 0x8035e66c
Ghidra address:
BRD3D: 0x102e5ed8

◆ g_anNearbyVehicleIdx

s32 g_anNearbyVehicleIdx[MAX_VEHICLES]
extern

The indices of the vehicles near enough to cast shadows on placed models.

Ghidra address:
USA: 0x8035d4e8
Ghidra address:
Asia: 0x8035CF98
Ghidra address:
EUR: 0x8035f9e8
Ghidra address:
JPN: 0x8035e658
Ghidra address:
BRD3D: 0x102e5ee0

◆ g_afNearbyVehicleDot

f32 g_afNearbyVehicleDot[MAX_VEHICLES]
extern

How far ahead of the camera each one is.

Ghidra address:
USA: 0x8035d4d8
Ghidra address:
Asia: 0x8035CF88
Ghidra address:
EUR: 0x8035f9d8
Ghidra address:
JPN: 0x8035e648
Ghidra address:
BRD3D: 0x10363f28

◆ g_vVehicleVisibilityDelta

Vec3f g_vVehicleVisibilityDelta
extern

From the camera to a vehicle.

Ghidra address:
USA: 0x8035d500
Ghidra address:
Asia: 0x8035CFB0
Ghidra address:
EUR: 0x8035fa00
Ghidra address:
JPN: 0x8035e670
Ghidra address:
BRD3D: 0x102e54a8

◆ g_fViewMatrixMaxAbs

f32 g_fViewMatrixMaxAbs
extern

The largest absolute value of the first three rows of g_afViewProjMatrix.

Ghidra address:
USA: 0x8035d51c
Ghidra address:
Asia: 0x8035CFCC
Ghidra address:
EUR: 0x8035fa1c
Ghidra address:
JPN: 0x8035e68c

◆ g_pTrackLookAt

LookAt* g_pTrackLookAt
extern

The look-at of the reflections of the track.

Ghidra address:
USA: 0x8028c774
Ghidra address:
Asia: 0x8028C2C4
Ghidra address:
EUR: 0x8028eed4
Ghidra address:
JPN: 0x8028e924
Ghidra address:
BRD3D: 0x103643b8
Ghidra address:
BRGlide: 0x1035fba0

◆ g_aTrackLights

Lights1 g_aTrackLights[4]
extern

The lights of the track, one of four in turn each frame.

Ghidra address:
USA: 0x8028c640
Ghidra address:
Asia: 0x8028C190
Ghidra address:
EUR: 0x8028eda0
Ghidra address:
JPN: 0x8028e7f0
Ghidra address:
BRD3D: 0x100a64e8
Ghidra address:
BRGlide: 0x100a5ca8

◆ g_nTrackLightBufferIndex

s32 g_nTrackLightBufferIndex
extern

The index of the light buffer used to draw the track this frame.

Ghidra address:
USA: 0x8028c6a0
Ghidra address:
Asia: 0x8028C1F0
Ghidra address:
EUR: 0x8028ee00
Ghidra address:
JPN: 0x8028e850
Ghidra address:
BRD3D: 0x10364388
Ghidra address:
BRGlide: 0x1035fb70

◆ g_vTrackLightDirection

Vec3f g_vTrackLightDirection
extern

The direction of the light of the track.

Ghidra address:
USA: 0x8035d510
Ghidra address:
Asia: 0x8035CFC0
Ghidra address:
EUR: 0x8035fa10
Ghidra address:
JPN: 0x8035e680
Ghidra address:
BRD3D: 0x103643a8

◆ g_vShadowForward

Vec3f g_vShadowForward
extern

The forward of the vehicle whose shadow is being cast, on the ground.

Ghidra address:
USA: 0x8035d1c0
Ghidra address:
Asia: 0x8035CC70
Ghidra address:
EUR: 0x8035f6c0
Ghidra address:
JPN: 0x8035e330
Ghidra address:
BRD3D: 0x10364390
Ghidra address:
BRGlide: 0x1035fb78

◆ g_fShadowLengthScale

const f32 g_fShadowLengthScale
extern

Scale of the vehicle shadow along its length.

Ghidra address:
USA: 0x802aa004
Ghidra address:
Asia: 0x802A9AC4
Ghidra address:
EUR: 0x802abd54
Ghidra address:
JPN: 0x802aabe4

◆ g_fShadowWidthScale

const f32 g_fShadowWidthScale
extern

Scale of the vehicle shadow across its width.

Ghidra address:
USA: 0x802aa008
Ghidra address:
Asia: 0x802A9AC8
Ghidra address:
EUR: 0x802abd58
Ghidra address:
JPN: 0x802aabe8