MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / SpawnVehicleWake

Function SpawnVehicleWake

TombEngine/Objects/Utils/VehicleHelpers.cpp:364–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362 }
363
364 void SpawnVehicleWake(const ItemInfo& vehicleItem, const Vector3& relOffset, int waterHeight, bool isUnderwater)
365 {
366 constexpr auto COLOR_START = Color(0.75f, 0.75f, 0.75f, 0.75f);
367 constexpr auto COLOR_END = Color(0.0f, 0.0f, 0.0f, 0.0f);
368 constexpr auto LIFE_MAX = 2.5f;
369 constexpr auto VEL_ABS = 4.0f;
370 constexpr auto EXP_RATE_ON_WATER = 6.0f;
371 constexpr auto EXP_RATE_UNDERWATER = 1.5f;
372
373 // Vehicle is out of water; return early.
374 if (waterHeight == NO_HEIGHT)
375 return;
376
377 bool isMovingForward = (vehicleItem.Animation.Velocity.z >= 0.0f);
378
379 // Determine tags.
380 auto tagLeft = isMovingForward ? VehicleWakeEffectTag::FrontLeft : VehicleWakeEffectTag::BackLeft;
381 auto tagRight = isMovingForward ? VehicleWakeEffectTag::FrontRight : VehicleWakeEffectTag::BackRight;
382
383 // Determine key parameters.
384 auto positions = GetVehicleWakePositions(vehicleItem, relOffset, waterHeight, isUnderwater, isMovingForward);
385 auto dir = -vehicleItem.Pose.Orientation.ToDirection();
386 short orient2D = isUnderwater ? vehicleItem.Pose.Orientation.z : 0;
387 float life = isUnderwater ? (LIFE_MAX / 2) : LIFE_MAX;
388 float vel = isMovingForward ? VEL_ABS : -VEL_ABS;
389 float expRate = isUnderwater ? EXP_RATE_UNDERWATER : EXP_RATE_ON_WATER;
390
391 // Spawn left wake.
392 StreamerEffect.Spawn(
393 vehicleItem.Index, (int)tagLeft,
394 positions.first, dir, orient2D, COLOR_START, COLOR_END,
395 0.0f, life, vel, expRate, 0,
396 StreamerFeatherMode::Right, BlendMode::Additive);
397
398 // Spawn right wake.
399 StreamerEffect.Spawn(
400 vehicleItem.Index, (int)tagRight,
401 positions.second, dir, orient2D, COLOR_START, COLOR_END,
402 0.0f, life, vel, expRate, 0,
403 StreamerFeatherMode::Left, BlendMode::Additive);
404 }
405
406 void HandleVehicleSpeedometer(float vel, float velMax)
407 {

Callers 5

SpeedboatControlFunction · 0.85
DoVehicleWaterMovementFunction · 0.85
UPVControlFunction · 0.85
RubberBoatControlFunction · 0.85
KayakControlFunction · 0.85

Calls 3

GetVehicleWakePositionsFunction · 0.85
SpawnMethod · 0.80
ToDirectionMethod · 0.45

Tested by

no test coverage detected