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

Driving: the controls of a player's vehicle and the views a replay chooses, where a vehicle is on the route, and the computer's drivers, which look ahead along the route for the farthest point they can drive straight to. More...

#include <PR/ultratypes.h>
#include "common/frameclear.h"
#include "common/track.h"
#include "common/vecmath.h"
#include "common/vehicle.h"
Include dependency graph for driving.h:

Go to the source code of this file.

Macros

#define TRACE_DEPTH   8
 The points of the route a search for a straight line looks ahead.

Functions

void AddVehicleJolt (s32 index, f32 amount)
 Add a jolt to a vehicle, at most 2.5 at once and 5 in all.
void ChooseReplayCamera (Vehicle *vehicle)
 Stand the trackside camera of a vehicle at the nearest point of the track no more than 10 below the vehicle and within 150 of it, or switch from the trackside camera to the cockpit or the chase camera when there is none.
void ProcessVehicleInputAndPhysics (Vehicle *vehicle)
 Read the controls of a vehicle, choose the view of a replay, and step the vehicle.
s32 TraceTrackSplineRecursive (Vehicle *vehicle, s32 depth, s32 pointIndex, TrackSection *section)
 Search the route ahead of a vehicle for straight lines it could drive, keeping the deepest.
void ComputeTrackPosition (Vehicle *vehicle)
 Find the point of the route nearest a vehicle along a curve through the points, with the axes of the route there and the offset of the vehicle from it.
void UpdateAiVehicleBehavior (Vehicle *vehicle)
 Drive a computer's vehicle for a frame: steer for a point ahead, keep to the route, pass the others, back out when stuck, and step it.

Variables

Vec3f g_vUpAxis
 The axis that points up.
f32 g_aafAiVelocityRetention [SEASONS][SEASON_RACES][2]
 How much of its velocity a computer's vehicle retains each frame in the championship, by season, race and the class of the racer.
s32 g_bReplayCockpitNext
 Whether a replay switches from the trackside camera to the cockpit next.
f32 g_afVehicleJolts []
 The jolts each vehicle took, from 0 to 5.
s32 g_dwBestTraceDepth
 The deepest level found by a straight-line search.
TrackSection * g_pBestTraceSection
 The section and point at the deepest end of the search.
s32 g_dwBestTracePoint
 The point index in the section at the deepest end of the search.
s32 g_dwBestTraceLength
 The number of points in the deepest straight line.
s32 g_dwTraceUnusedA
 Cleared at the start of a search and never read.
s32 g_dwTraceUnusedB
 Cleared at the start of a search and never read.
s32 g_bTraceBlocked
 Set when a searched line crosses outside the route; never read.
s32 g_bAiNudgeLeft
 Whether a computer's vehicle should ease to the left or to the right of where it steers.
s32 g_bAiNudgeRight
 Whether a computer's vehicle should ease to the right of where it steers.
Vec3f g_avBestLeftLane [TRACE_DEPTH]
 The lanes and the middle of the deepest straight line.
Vec3f g_avBestCenterLine [TRACE_DEPTH]
 The centre points of the deepest straight line found.
Vec3f g_avBestRightLane [TRACE_DEPTH]
 The right lane points of the deepest straight line found.
Vec3f g_avTraceLeftLane [TRACE_DEPTH]
 The points of the line a search follows: a fifth of the way in from each side, halfway from there to the middle, and the middle.
Vec3f g_avTraceLeftHalf [TRACE_DEPTH]
 The points halfway between the left lane and centre line of the search.
Vec3f g_avTraceCenterLine [TRACE_DEPTH]
 The centre points of the line the search follows.
Vec3f g_avTraceRightHalf [TRACE_DEPTH]
 The points halfway between the right lane and centre line of the search.
Vec3f g_avTraceRightLane [TRACE_DEPTH]
 The right lane points of the line the search follows.
Vec3f g_vTraceFarPoint
 The last point of the deepest line, and its point halfway.
Vec3f g_vTraceHalfwayPoint
 The centre point halfway along the deepest straight line found.

Detailed Description

Driving: the controls of a player's vehicle and the views a replay chooses, where a vehicle is on the route, and the computer's drivers, which look ahead along the route for the farthest point they can drive straight to.

Macro Definition Documentation

◆ TRACE_DEPTH

#define TRACE_DEPTH   8

The points of the route a search for a straight line looks ahead.

Function Documentation

◆ AddVehicleJolt()

void AddVehicleJolt ( s32 index,
f32 amount )

Add a jolt to a vehicle, at most 2.5 at once and 5 in all.

Parameters
indexThe index of the vehicle.
amountThe jolt.
Ghidra address:
USA: 0x8021be28
Ghidra address:
Asia: 0x8021B978
Ghidra address:
EUR: 0x8021d008
Ghidra address:
JPN: 0x8021c8d8
Ghidra address:
BRD3D: 0x100347ba
Ghidra address:
BRGlide: 0x1002de6b

◆ ChooseReplayCamera()

void ChooseReplayCamera ( Vehicle * vehicle)

Stand the trackside camera of a vehicle at the nearest point of the track no more than 10 below the vehicle and within 150 of it, or switch from the trackside camera to the cockpit or the chase camera when there is none.

Parameters
vehicleThe vehicle the camera watches.
Ghidra address:
EUR: 0x802277d0
Ghidra address:
JPN: 0x80226fc0

◆ ProcessVehicleInputAndPhysics()

void ProcessVehicleInputAndPhysics ( Vehicle * vehicle)

Read the controls of a vehicle, choose the view of a replay, and step the vehicle.

Parameters
vehicleThe vehicle.
Ghidra address:
USA: 0x80226488
Ghidra address:
Asia: 0x80225FD8
Ghidra address:
EUR: 0x80227980
Ghidra address:
JPN: 0x80227170

◆ TraceTrackSplineRecursive()

s32 TraceTrackSplineRecursive ( Vehicle * vehicle,
s32 depth,
s32 pointIndex,
TrackSection * section )

Search the route ahead of a vehicle for straight lines it could drive, keeping the deepest.

Parameters
vehicleThe vehicle.
depthThe points searched so far; 0 starts a search.
pointIndexThe point of the section to search from.
sectionThe section to search, or NULL for the start of the route.
Returns
Whether this search or one it made found a deeper line.
Ghidra address:
USA: 0x80226d9c
Ghidra address:
Asia: 0x802268EC
Ghidra address:
EUR: 0x80228100
Ghidra address:
JPN: 0x802278f0

◆ ComputeTrackPosition()

void ComputeTrackPosition ( Vehicle * vehicle)

Find the point of the route nearest a vehicle along a curve through the points, with the axes of the route there and the offset of the vehicle from it.

Parameters
vehicleThe vehicle.
Ghidra address:
USA: 0x80227214
Ghidra address:
Asia: 0x80226D64
Ghidra address:
EUR: 0x80228578
Ghidra address:
JPN: 0x80227d68

◆ UpdateAiVehicleBehavior()

void UpdateAiVehicleBehavior ( Vehicle * vehicle)

Drive a computer's vehicle for a frame: steer for a point ahead, keep to the route, pass the others, back out when stuck, and step it.

Parameters
vehicleThe vehicle.
Ghidra address:
USA: 0x8022762c
Ghidra address:
Asia: 0x8022717C
Ghidra address:
EUR: 0x80228990
Ghidra address:
JPN: 0x80228180

Variable Documentation

◆ g_vUpAxis

Vec3f g_vUpAxis
extern

The axis that points up.

Ghidra address:
USA: 0x8028bab0
Ghidra address:
Asia: 0x8028B600
Ghidra address:
EUR: 0x8028dd64
Ghidra address:
JPN: 0x8028d794

◆ g_aafAiVelocityRetention

f32 g_aafAiVelocityRetention[SEASONS][SEASON_RACES][2]
extern

How much of its velocity a computer's vehicle retains each frame in the championship, by season, race and the class of the racer.

Ghidra address:
USA: 0x8028b9f0
Ghidra address:
Asia: 0x8028B540
Ghidra address:
EUR: 0x8028dca4
Ghidra address:
JPN: 0x8028d6d4
Ghidra address:
BRD3D: 0x100b38a0

◆ g_bReplayCockpitNext

s32 g_bReplayCockpitNext
extern

Whether a replay switches from the trackside camera to the cockpit next.

Ghidra address:
USA: 0x8028b9ec
Ghidra address:
Asia: 0x8028B53C
Ghidra address:
EUR: 0x8028dca0
Ghidra address:
JPN: 0x8028d6d0
Ghidra address:
BRD3D: 0x10af9bb8

◆ g_afVehicleJolts

f32 g_afVehicleJolts[]
extern

The jolts each vehicle took, from 0 to 5.

Ghidra address:
USA: 0x8031b1d8
Ghidra address:
Asia: 0x8031AC88
Ghidra address:
EUR: 0x8031d6d8
Ghidra address:
JPN: 0x8031c308
Ghidra address:
BRD3D: 0x106c5468
Ghidra address:
BRGlide: 0x106ec4f8

◆ g_dwBestTraceDepth

s32 g_dwBestTraceDepth
extern

The deepest level found by a straight-line search.

Ghidra address:
USA: 0x8028b804
Ghidra address:
Asia: 0x8028B354
Ghidra address:
EUR: 0x8028dab4
Ghidra address:
JPN: 0x8028d4e4
Ghidra address:
BRD3D: 0x10aa34ac

◆ g_pBestTraceSection

TrackSection* g_pBestTraceSection
extern

The section and point at the deepest end of the search.

Ghidra address:
USA: 0x8028b814
Ghidra address:
Asia: 0x8028B364
Ghidra address:
EUR: 0x8028dac4
Ghidra address:
JPN: 0x8028d4f4
Ghidra address:
BRD3D: 0x10aa3474

◆ g_dwBestTracePoint

s32 g_dwBestTracePoint
extern

The point index in the section at the deepest end of the search.

Ghidra address:
USA: 0x8028b810
Ghidra address:
Asia: 0x8028B360
Ghidra address:
EUR: 0x8028dac0
Ghidra address:
JPN: 0x8028d4f0
Ghidra address:
BRD3D: 0x10af9528
Ghidra address:
BRGlide: 0x10b1c888

◆ g_dwBestTraceLength

s32 g_dwBestTraceLength
extern

The number of points in the deepest straight line.

Ghidra address:
USA: 0x8028b800
Ghidra address:
Asia: 0x8028B350
Ghidra address:
EUR: 0x8028dab0
Ghidra address:
JPN: 0x8028d4e0
Ghidra address:
BRD3D: 0x10af96bc

◆ g_dwTraceUnusedA

s32 g_dwTraceUnusedA
extern

Cleared at the start of a search and never read.

Ghidra address:
USA: 0x8028b81c
Ghidra address:
Asia: 0x8028B36C
Ghidra address:
EUR: 0x8028dacc
Ghidra address:
JPN: 0x8028d4fc
Ghidra address:
BRD3D: 0x10af96b8

◆ g_dwTraceUnusedB

s32 g_dwTraceUnusedB
extern

Cleared at the start of a search and never read.

Ghidra address:
USA: 0x8028b818
Ghidra address:
Asia: 0x8028B368
Ghidra address:
EUR: 0x8028dac8
Ghidra address:
JPN: 0x8028d4f8
Ghidra address:
BRD3D: 0x10af9ba8

◆ g_bTraceBlocked

s32 g_bTraceBlocked
extern

Set when a searched line crosses outside the route; never read.

Ghidra address:
USA: 0x8028b820
Ghidra address:
Asia: 0x8028B370
Ghidra address:
EUR: 0x8028dad0
Ghidra address:
JPN: 0x8028d500
Ghidra address:
BRD3D: 0x10af9bac

◆ g_bAiNudgeLeft

s32 g_bAiNudgeLeft
extern

Whether a computer's vehicle should ease to the left or to the right of where it steers.

Ghidra address:
USA: 0x8028b80c
Ghidra address:
Asia: 0x8028B35C
Ghidra address:
EUR: 0x8028dabc
Ghidra address:
JPN: 0x8028d4ec
Ghidra address:
BRD3D: 0x10af9888

◆ g_bAiNudgeRight

s32 g_bAiNudgeRight
extern

Whether a computer's vehicle should ease to the right of where it steers.

Ghidra address:
USA: 0x8028b808
Ghidra address:
Asia: 0x8028B358
Ghidra address:
EUR: 0x8028dab8
Ghidra address:
JPN: 0x8028d4e8
Ghidra address:
BRD3D: 0x10af9ba4

◆ g_avBestLeftLane

Vec3f g_avBestLeftLane[TRACE_DEPTH]
extern

The lanes and the middle of the deepest straight line.

Ghidra address:
USA: 0x8031b430
Ghidra address:
Asia: 0x8031AEE0
Ghidra address:
EUR: 0x8031d930
Ghidra address:
JPN: 0x8031c560
Ghidra address:
BRD3D: 0x10af9658

◆ g_avBestCenterLine

Vec3f g_avBestCenterLine[TRACE_DEPTH]
extern

The centre points of the deepest straight line found.

Ghidra address:
USA: 0x8031b490
Ghidra address:
Asia: 0x8031AF40
Ghidra address:
EUR: 0x8031d990
Ghidra address:
JPN: 0x8031c5c0
Ghidra address:
BRD3D: 0x10af96c8

◆ g_avBestRightLane

Vec3f g_avBestRightLane[TRACE_DEPTH]
extern

The right lane points of the deepest straight line found.

Ghidra address:
USA: 0x8031b4f0
Ghidra address:
Asia: 0x8031AFA0
Ghidra address:
EUR: 0x8031d9f0
Ghidra address:
JPN: 0x8031c620
Ghidra address:
BRD3D: 0x10af95f8

◆ g_avTraceLeftLane

Vec3f g_avTraceLeftLane[TRACE_DEPTH]
extern

The points of the line a search follows: a fifth of the way in from each side, halfway from there to the middle, and the middle.

Ghidra address:
USA: 0x8031b550
Ghidra address:
Asia: 0x8031B000
Ghidra address:
EUR: 0x8031da50
Ghidra address:
JPN: 0x8031c680
Ghidra address:
BRD3D: 0x10af9788

◆ g_avTraceLeftHalf

Vec3f g_avTraceLeftHalf[TRACE_DEPTH]
extern

The points halfway between the left lane and centre line of the search.

Ghidra address:
USA: 0x8031b5b0
Ghidra address:
Asia: 0x8031B060
Ghidra address:
EUR: 0x8031dab0
Ghidra address:
JPN: 0x8031c6e0
Ghidra address:
BRD3D: 0x10af9590

◆ g_avTraceCenterLine

Vec3f g_avTraceCenterLine[TRACE_DEPTH]
extern

The centre points of the line the search follows.

Ghidra address:
USA: 0x8031b610
Ghidra address:
Asia: 0x8031B0C0
Ghidra address:
EUR: 0x8031db10
Ghidra address:
JPN: 0x8031c740
Ghidra address:
BRD3D: 0x10af9728

◆ g_avTraceRightHalf

Vec3f g_avTraceRightHalf[TRACE_DEPTH]
extern

The points halfway between the right lane and centre line of the search.

Ghidra address:
USA: 0x8031b670
Ghidra address:
Asia: 0x8031B120
Ghidra address:
EUR: 0x8031db70
Ghidra address:
JPN: 0x8031c7a0
Ghidra address:
BRD3D: 0x10af9530

◆ g_avTraceRightLane

Vec3f g_avTraceRightLane[TRACE_DEPTH]
extern

The right lane points of the line the search follows.

Ghidra address:
USA: 0x8031b6d0
Ghidra address:
Asia: 0x8031B180
Ghidra address:
EUR: 0x8031dbd0
Ghidra address:
JPN: 0x8031c800
Ghidra address:
BRD3D: 0x10af97e8
Ghidra address:
BRGlide: 0x10b1cb48

◆ g_vTraceFarPoint

Vec3f g_vTraceFarPoint
extern

The last point of the deepest line, and its point halfway.

Ghidra address:
USA: 0x8031b730
Ghidra address:
Asia: 0x8031B1E0
Ghidra address:
EUR: 0x8031dc30
Ghidra address:
JPN: 0x8031c860
Ghidra address:
BRD3D: 0x10af9b28

◆ g_vTraceHalfwayPoint

Vec3f g_vTraceHalfwayPoint
extern

The centre point halfway along the deepest straight line found.

Ghidra address:
USA: 0x8031b740
Ghidra address:
Asia: 0x8031B1F0
Ghidra address:
EUR: 0x8031dc40
Ghidra address:
JPN: 0x8031c870
Ghidra address:
BRD3D: 0x10acde98