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

Function SpawnSplashDrips

TombEngine/Game/effects/drip.cpp:46–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 void SpawnSplashDrips(const Vector3& pos, int roomNumber, unsigned int count, bool isSmallSplash)
47 {
48 constexpr auto LIFE_MAX = 4.0f;
49 constexpr auto VELOCITY_BASE = 16.0f;
50 constexpr auto VERTICAL_VELOCITY_HIGH_MAX = 64.0f;
51 constexpr auto VERTICAL_VELOCITY_HIGH_MIN = 32.0f;
52 constexpr auto VERTICAL_VELOCITY_LOW_MAX = 24.0f;
53 constexpr auto VERTICAL_VELOCITY_LOW_MIN = 16.0f;
54 constexpr auto SPAWN_RADIUS_LARGE = BLOCK(1 / 8.0f);
55 constexpr auto SPAWN_RADIUS_SMALL = BLOCK(1 / 64.0f);
56
57 // TODO: Can spawn beneath water surface.
58 auto sphere = BoundingSphere(pos, isSmallSplash ? SPAWN_RADIUS_SMALL : SPAWN_RADIUS_LARGE);
59
60 for (int i = 0; i < count; i++)
61 {
62 auto dripPos = Random::GeneratePointInSphere(sphere);
63 auto direction = dripPos - pos;
64 direction.Normalize();
65
66 float verticalVel = isSmallSplash ?
67 Random::GenerateFloat(VERTICAL_VELOCITY_LOW_MIN, VERTICAL_VELOCITY_LOW_MAX) :
68 Random::GenerateFloat(VERTICAL_VELOCITY_HIGH_MIN, VERTICAL_VELOCITY_HIGH_MAX);
69 auto vel = (direction * VELOCITY_BASE) + Vector3(0.0f, -verticalVel, 0.0f);
70
71 float systemGravity = g_GameFlow->GetSettings()->Physics.Gravity;
72
73 float gravity = isSmallSplash ?
74 Random::GenerateFloat(systemGravity / 3, systemGravity / 2) :
75 Random::GenerateFloat(systemGravity / 2, systemGravity);
76
77 SpawnDrip(dripPos, roomNumber, vel, LIFE_MAX, gravity);
78 }
79 }
80
81 void SpawnWetnessDrip(const Vector3& pos, int roomNumber)
82 {

Callers 3

TestProjectileNewRoomFunction · 0.85
SetupSplashFunction · 0.85
UpdateGunShellsFunction · 0.85

Calls 6

GeneratePointInSphereFunction · 0.85
GenerateFloatFunction · 0.85
SpawnDripFunction · 0.85
GetSettingsMethod · 0.80
Vector3Function · 0.50
NormalizeMethod · 0.45

Tested by 1

TestProjectileNewRoomFunction · 0.68