Rise
The Vieneo Province
Loading...
Searching...
No Matches
framemove.cpp
Go to the documentation of this file.
1#include "FlightLoads.h"
2#include "Viewscreen.h"
3#include "VehicleVisibility.h"
6#include "ReentryRadio.h"
7#include "../MathUtilities.h"
11#include "../VehicleHorn.h"
12#include "BiometerState.h"
13
14//#define SOFTRACKING
15
16
22
24{
25 const bool damageReady = ourcockpit.landingDamageVehicleId == playerships[0].vehicleId;
27 const bool inVehicle = gameclass->GUI->player[ourcockpit.ourplyrC].frame == 0;
28 if (damageReady && inVehicle)
29 {
30 const unsigned mismatch = LandingLights::InstallationMismatch(modelCount, ourcockpit.vdat.landing);
32 {
33 char message[192];
34 sprintf_s(message, sizeof message,
35 "Landing light vdat/model mismatch: vehicle %u type %u, model beams %u, landing0=%d landing1=%d, slot mask %u (-1 means not installed)",
36 unsigned(playerships[0].vehicleId), unsigned(playerships[0].type), modelCount,
37 ourcockpit.vdat.landing[0], ourcockpit.vdat.landing[1], mismatch);
38 logger->Log(message, Logger::Level::Error); // Existing local log and server error report.
40 }
41 }
42 const bool enclosed = playerships[0].reference == REF_INANOTHER &&
44 const bool enabled = playerships[0].headlight && ourcockpit.power > .5f && inVehicle && !enclosed && damageReady;
47 std::array<float, LandingLights::MaxLights> emissionBrightness{};
51 for (unsigned source = 0; source < modelCount; ++source)
52 {
53 if (!damageReady) continue;
54 const uint32_t seed = uint32_t(playerships[0].vehicleId) * 0x85ebca6bu ^ (source + 1) * 0x9e3779b9u;
55 const float brightness = ourcockpit.landingLightCondition[source].Sample(ourcockpit.vdat.landing[source],
56 seconds, seed, playerships[0].isSimulator);
57 // The mesh's existing headlight/alarm switch controls whether it emits;
58 // its damage multiplier must also work when an alarm flashes parked lamps.
59 emissionBrightness[source] = brightness;
60 if (!enabled || brightness <= 0) continue;
61 ourcockpit.landingLightBrightness[source] = brightness;
62 const unsigned i = activeLandingLightCount++;
63 // Physics has since reused ownship's matrixWorld for attitude only.
64 // Keep the model-axis conversion and pose used to draw the exterior.
65 const auto& transform = playerships[0].type == VehicleType::EVA_SUIT
67 auto& light = landingLights[i];
68 light = LandingLights::Transform(ourcockpit.landingLights[source], transform);
69 light.color *= brightness;
70 light.extinctionPerKm = 3.912f / RiseMath::Max(.05f, ptrWeather->GetVisibilityKm());
71 positions[i] = {light.origin.x, light.origin.y, light.origin.z, light.profile.rangeKm};
72 directions[i] = {light.direction.x, light.direction.y, light.direction.z, 0};
73 colors[i] = {light.color.r, light.color.g, light.color.b, 1};
74 ups[i] = {light.up.x, light.up.y, light.up.z, 0};
75 angles[i] = light.profile.Angles<RiseMath::Vector4>();
76 profiles[i] = light.profile.Parameters<RiseMath::Vector4>(light.extinctionPerKm);
77 Rendering::Light fixed{};
79 fixed.Position = light.origin;
80 fixed.Direction = light.direction;
81 fixed.Diffuse = light.color;
82 fixed.ProfiledBeam=true;fixed.BeamUp=light.up;fixed.BeamAngles=angles[i];fixed.BeamParameters=profiles[i];
83 fixed.Range = light.profile.rangeKm;
84 fixed.Falloff = 1;
85 fixed.Attenuation0 = .25f;
86 fixed.Attenuation2 = 20000000.f / light.profile.peakCandela;
87 // Fixed-function theta/phi are full angles; shaders use their half angles.
88 fixed.Theta = RiseMath::ToRadian(RiseMath::Max(light.profile.coreHorizontal,light.profile.coreVertical));
89 fixed.Phi = RiseMath::ToRadian(RiseMath::Max(light.profile.outerHorizontal,light.profile.outerVertical));
91 }
93 auto* effect = gameclass->graphics->g_pEffect;
94 if (effect)
95 {
96 const auto emitters = LandingLights::EmissionSources(ourcockpit.landingLights, modelCount,
97 emissionBrightness, playerships[0].matrixExterior);
98 effect->SetVectorArray("HeadlightEmission", emitters.data(), LandingLights::MaxLights);
99 effect->SetInt("LandingLightCount", static_cast<int>(activeLandingLightCount));
100 effect->SetVectorArray("LandingLightPosition", positions, LandingLights::MaxLights);
101 effect->SetVectorArray("LandingLightDirection", directions, LandingLights::MaxLights);
102 effect->SetVectorArray("LandingLightColor", colors, LandingLights::MaxLights);
103 effect->SetVectorArray("LandingLightUp", ups, LandingLights::MaxLights);
104 effect->SetVectorArray("LandingLightAngles", angles, LandingLights::MaxLights);
105 effect->SetVectorArray("LandingLightParameters", profiles, LandingLights::MaxLights);
106 }
107}
108
110{
111 pressed = pressed && !playerships[0].isSimulator && playerships[0].groundvehicle;
112 const auto command = VehicleHorn::SetPressed(playerships[0].hornPressed, pressed);
113 if (command != VehicleHorn::Command::None)
116}
117
119{
120 if (playerships[0].isSimulator) return;
121 if (WindshieldWipers::SetEnabled(playerships[0].rainProtectionEnabled, enabled))
123}
124
126{
127 if (playerships[0].isSimulator) return;
128 // Keep event 30 compatible with older clients, but only latch the horn.
129 // A hand hitting the wiper stalk is a separate command on event 29.
130 if (playerships[0].crashHornFault == enabled) return;
131 playerships[0].crashHornFault = enabled;
133}
134
135void Viewscreen::UpdateCrashDamage(const RiseMath::Vector3& frameForces, float seconds)
136{
137 // Consume even an inhibited event so it cannot replay after a transition.
138 const auto impactImpulse = structuralImpactImpulse;
140 // Keep simulator training at its original cadence. Real impulses cannot
141 // wait for the independent 24 Hz animation tick.
142 if (dead || deathinhibit || playerships[0].reference == REF_BUILDING ||
143 playerships[0].reference == REF_WINDOWLESS || (playerships[0].isSimulator && !advanceframe)) return;
144 // The occupant includes acceleration at the seat (rotation as well as the
145 // CG impulse). Arm/stalk contact does not require glass or frame damage.
146 const float joltSeverity = CollisionDamage::Severity(sumofforces.x, sumofforces.y, sumofforces.z);
147 if (!playerships[0].isSimulator && gameclass->GUI->player[ourcockpit.ourplyrC].frame == 0 &&
148 joltSeverity > 1.f && controlJoltEpisode.Begin(gameclass->bus->ProgramTime))
149 {
150 const bool wipersBefore = playerships[0].rainProtectionEnabled;
151 if (hasAnimatedWipers && !wipersBefore && CollisionDamage::TriggersFault(joltSeverity, rand(), RAND_MAX))
152 SetRainProtection(true);
153 sprintf_s(msg, sizeof msg, "Cockpit jolt: severity %.2f chance %.0f%%; wiper stalk %i->%i", joltSeverity,
154 CollisionDamage::FaultProbability(joltSeverity) * 100.f, int(wipersBefore),
155 int(playerships[0].rainProtectionEnabled));
156 logger->Log(msg);
157 }
158
159 // Only a discrete collision may use the 60 Hz impulse scale. Multiplying
160 // ordinary lift/thrust/support by dt turns scenery-loading stalls into crashes.
161 const auto impactForces = seconds > 0 && std::isfinite(seconds)
162 ? impactImpulse * (oneOvergForceKmssC / seconds) : RiseMath::Vector3{};
163 const auto sustainedForces = frameForces - impactForces;
164 const float impactSeverity = CollisionDamage::ImpactSeverity(impactForces.x, impactForces.y, impactForces.z, seconds);
165 const float loadSeverity = CollisionDamage::Severity(sustainedForces.x, sustainedForces.y, sustainedForces.z);
166 const float severity = playerships[0].isSimulator
168 : (std::max)(loadSeverity, impactSeverity);
169 if (severity > 1.f)
170 {
172 if (!fresh && CollisionDamage::HullDamage(severity) <= crashDamageEpisode.appliedDamage) return;
173 if (fresh)
174 {
175 // these are considered a crash, so we need to cue the crash noises
176 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
177 switch (causechain)
178 {
179 case 1: // Ground impact
180 logger->Log("Ground impact!");
181 if (g_bEnabled)
182 {
183 if (rand() > 16383)
185 else
187 }
188 break;
189 case 4: // City impact
190 logger->Log("Impacted with city!");
191 if (g_bEnabled)
192 {
193 if (rand() > 16383)
195 else
197 }
198 break;
199 case 9: // Water impact
200 logger->Log("Water impact!");
201 if (g_bEnabled)
202 {
203 if (rand() > 16383)
205 else
207 }
208 break;
209 }
210
211 // and for distributing damage
212 if (ourcockpit.vdat.vtail > 0)
213 {
214 const auto damage = static_cast<char>(rand() % ourcockpit.vdat.vtail + 1); // thanks canary
215 ourcockpit.vdat.vtail -= damage;
216 ourcockpit.vdatChanged = true;
217 if (damage > 32)
218 {
219 if (rand() < 16384)
221 else
223 }
224 }
225
226 if (ourcockpit.vdat.htail > 0)
227 {
228 // rand()%8 returns 0 to 7
229 const auto damage = static_cast<char>(rand() % ourcockpit.vdat.htail + 1); // thanks canary
230 ourcockpit.vdat.htail -= damage;
231 if (ourcockpit.vdat.htail < 0)
232 {
234 sprintf_s(msg, sizeof msg, "Trapped h-tail issue...");
236 }
237 ourcockpit.vdatChanged = true;
238 if (damage > 32)
239 {
240 if (rand() < 16384)
242 else
244 }
245 }
246
247 }
248 const int hullBefore = ourcockpit.vdat.hullintegrity;
250 {
252 ? hullBefore - (rand() % hullBefore + 1)
253 : crashDamageEpisode.Apply(hullBefore, severity));
254 ourcockpit.vdatChanged = true;
255 }
256
257 const int hullLoss = (std::max)(0, hullBefore - int(ourcockpit.vdat.hullintegrity));
258 if (hullLoss > 0)
259 {
260 sprintf_s(msg, sizeof msg, "Hull impact: severity %.3f dt %.6f s health %d->%d; %s; impact %.3f load %.3f dV=(%.6f,%.6f,%.6f) km/s",
261 severity, seconds, hullBefore, int(ourcockpit.vdat.hullintegrity),
262 playerships[0].isSimulator ? "simulator baseline" : "separate impact/load damage",
263 impactSeverity, loadSeverity, impactImpulse.x, impactImpulse.y, impactImpulse.z);
264 logger->Log(msg);
265 }
266 if (!playerships[0].isSimulator && hullLoss > 0 &&
269 {
270 for (unsigned lamp = 0; lamp < ourcockpit.landingLightCount && lamp < LandingLights::MaxLights; ++lamp)
271 {
272 const int before = ourcockpit.vdat.landing[lamp];
273 const int after = ourcockpit.landingLightImpact[lamp].ApplyFrameDamage(before, crashDamageEpisode.appliedDamage,
275 if (after == before) continue;
276 ourcockpit.vdat.landing[lamp] = static_cast<char>(after);
277 ourcockpit.vdatChanged = true;
278 ourcockpit.vdatTime = 5.f;
279 RiseMath::Vector3 mount;
281 sprintf_s(msg, sizeof msg,
282 "Landing light crush: vehicle %u lamp %u (%s from driver) %d->%d; hull/frame proxy %d->%d; contact age %.3f s",
283 unsigned(playerships[0].vehicleId), lamp, LandingLights::BodySide(mount.x), before, after,
284 hullBefore, int(ourcockpit.vdat.hullintegrity),
286 logger->Log(msg);
287 }
288 }
289 if (!playerships[0].isSimulator && playerships[0].groundvehicle && hullLoss > 0 &&
291 {
292 // Negative longitudinal load denotes front-end deceleration. Keep
293 // an electrical fault independent of arm/stalk contact and glass.
294 const float frontalSeverity = (std::max)(CollisionDamage::Severity(0, 0, (std::min)(0.f, sustainedForces.z)),
295 CollisionDamage::ImpactSeverity(0, 0, (std::min)(0.f, impactForces.z), seconds));
296 const float chance = CollisionDamage::HornFaultProbability(frontalSeverity,
297 hullBefore, ourcockpit.vdat.hullintegrity);
298 if (chance > 0)
299 {
300 const bool before = playerships[0].crashHornFault;
301 if (!before && CollisionDamage::TriggersHornFault(frontalSeverity, hullBefore,
302 ourcockpit.vdat.hullintegrity, rand(), RAND_MAX)) SetCrashHornFault(true);
303 sprintf_s(msg, sizeof msg,
304 "Front structural damage: severity %.2f hull/frame proxy %d->%d; horn circuit chance %.0f%% fault %i->%i",
305 frontalSeverity, hullBefore, int(ourcockpit.vdat.hullintegrity), chance * 100.f,
306 int(before), int(playerships[0].crashHornFault));
307 logger->Log(msg);
308 }
309 }
310
311 if (ourcockpit.vdat.windshield > 0)
312 {
313 const int before = ourcockpit.vdat.windshield;
314 const int damage = playerships[0].isSimulator ? rand() % before + 1 :
316 ourcockpit.vdat.windshield = static_cast<char>(before - damage);
317 if (damage > 0)
318 {
319 sprintf_s(msg, sizeof msg, "Windshield %i->%i from %s; hull/frame proxy %i->%i; structural severity %.2f",
320 before, int(ourcockpit.vdat.windshield), playerships[0].isSimulator ? "simulator damage" : "frame damage",
321 hullBefore, int(ourcockpit.vdat.hullintegrity), severity);
322 logger->Log(msg);
323 ourcockpit.vdatChanged = true;
324 }
325 }
326 }
327
330}
331
332void Viewscreen::ResetHeadAccelerationEffects(const char* reason, bool waitForTerrain)
333{
334 if (ptrCockpit) ptrCockpit->ResetProps(reason);
335 char diagnostic[768];
337 sprintf_s(diagnostic, sizeof diagnostic,
338 "HEAD reset #%u reason=%s ref=%d terrainReady=%d terrainPending=%d waitTerrain=%d "
339 "oldG=(%.9g,%.9g,%.9g) oldCounter=(%.9g,%.9g,%.9g) oldLeanDeg=(%.9g,%.9g)",
340 headAccelerationResetSequence, reason, int(playerships[0].reference), int(ptrGrid->dataReady),
341 int(ptrGrid->wholeGridPending), int(waitForTerrain), sumofforces.x, sumofforces.y, sumofforces.z,
343 logger->Log(diagnostic);
344 // Destination terrain corrections can produce new impulses after the reset.
345 headAccelerationGuard.Reset(waitForTerrain);
349 headAccelerationDiagnosticUntil = GetTickCount64() + 30000;
351 counteri = counterj = counterk = 0.0f;
352 headback = headtilt = 0.0f;
353}
354
356{
359 suspensionHeaveG = 0.0f;
360 for (auto& wheel : suspensionWheels)
361 wheel = SuspensionWheelState();
362}
363
365{
366 if (ourcockpit.suspensionTravelKm <= 0.0f)
367 return 0.0f;
368
370 {
371 const float weightRatio = Clamp(ptrPropulsion->totalWeightLbs / RiseMath::Max(ourcockpit.maxGrossLbs, 1.0f), 0.25f, 2.0f);
372 const float sagKm = RiseMath::Min(ourcockpit.suspensionTravelKm,
374 Clamp(suspensionNormalLoadG, 0.0f, 3.0f));
375 return RiseMath::Max(0.0f, ourcockpit.suspensionTravelKm - sagKm);
376 }
377
378 float remainingBumpKm = 0.0f;
379 for (const auto& wheel : suspensionWheels)
380 remainingBumpKm += RiseMath::Max(0.0f, ourcockpit.suspensionTravelKm - wheel.compressionKm);
381 return remainingBumpKm / static_cast<float>(suspensionWheels.size());
382}
383
384void Viewscreen::ApplySuspensionImpact(float absorbedVelocityKms)
385{
386 if (!playerships[0].groundvehicle || ourcockpit.suspensionTravelKm <= 0.0f || absorbedVelocityKms <= 0.0f)
387 return;
388
390 {
391 const float initialCompressionKm = ourcockpit.suspensionTravelKm - GetAverageSuspensionBumpTravelKm();
392 for (auto& wheel : suspensionWheels)
393 wheel.compressionKm = initialCompressionKm;
395 }
396
397 const float maxCompressionVelocityKms =
399 for (auto& wheel : suspensionWheels)
400 wheel.velocityKms = Clamp(wheel.velocityKms + absorbedVelocityKms,
401 -maxCompressionVelocityKms, maxCompressionVelocityKms);
402}
403
404float Viewscreen::UpdateSuspensionState(float elapsedTime, const RiseMath::Vector3& vehicleG)
405{
406 if (!playerships[0].groundvehicle || ourcockpit.suspensionTravelKm <= 0.0f || elapsedTime <= 0.0f)
407 return 0.0f;
408
409 const float dt = RiseMath::Min(elapsedTime, 0.1f);
410 const float weightRatio = Clamp(ptrPropulsion->totalWeightLbs / RiseMath::Max(ourcockpit.maxGrossLbs, 1.0f), 0.25f, 2.0f);
411 const float normalLoadG = Clamp(vehicleG.y, 0.0f, 3.0f);
412 const float baseCompressionKm = ourcockpit.suspensionTravelKm *
413 ourcockpit.suspensionStaticSagRatio * weightRatio * normalLoadG;
414 const float longitudinalTransferKm = ourcockpit.suspensionTravelKm *
415 ourcockpit.suspensionLongitudinalLoadTransferPerG * Clamp(-vehicleG.z, -2.0f, 2.0f);
416 // Match the requested handling convention: lateral acceleration compresses the two wheels on the inside of the turn.
417 const float lateralTransferKm = ourcockpit.suspensionTravelKm *
418 ourcockpit.suspensionLateralLoadTransferPerG * Clamp(vehicleG.x, -2.0f, 2.0f);
419
420 std::array<float, 4> targets =
421 {
422 baseCompressionKm + longitudinalTransferKm - lateralTransferKm,
423 baseCompressionKm + longitudinalTransferKm + lateralTransferKm,
424 baseCompressionKm - longitudinalTransferKm - lateralTransferKm,
425 baseCompressionKm - longitudinalTransferKm + lateralTransferKm
426 };
427 for (auto& target : targets)
428 target = Clamp(target, 0.0f, ourcockpit.suspensionTravelKm);
429
431 {
432 for (size_t i = 0; i < suspensionWheels.size(); ++i)
433 suspensionWheels[i].compressionKm = targets[i];
435 return 0.0f;
436 }
437
439 const float damping = 2.0f * Clamp(ourcockpit.suspensionDampingRatio, 0.0f, 2.0f) * omega;
440 float averageAccelerationKmss = 0.0f;
441 for (size_t i = 0; i < suspensionWheels.size(); ++i)
442 {
443 auto& wheel = suspensionWheels[i];
444 const float accelerationKmss = omega * omega * (targets[i] - wheel.compressionKm) - damping * wheel.velocityKms;
445 wheel.velocityKms += accelerationKmss * dt;
446 wheel.compressionKm += wheel.velocityKms * dt;
447
448 if (wheel.compressionKm <= 0.0f)
449 {
450 wheel.compressionKm = 0.0f;
451 if (wheel.velocityKms < 0.0f)
452 wheel.velocityKms = 0.0f;
453 }
454 else if (wheel.compressionKm >= ourcockpit.suspensionTravelKm)
455 {
456 wheel.compressionKm = ourcockpit.suspensionTravelKm;
457 if (wheel.velocityKms > 0.0f)
458 wheel.velocityKms = 0.0f;
459 }
460
461 averageAccelerationKmss += accelerationKmss;
462 }
463
464 averageAccelerationKmss /= static_cast<float>(suspensionWheels.size());
465 return Clamp(-averageAccelerationKmss * oneOvergForceKmssC, -1.0f, 1.0f);
466}
467
469{
471 return 0.0f;
472
473 const float frontCompressionKm =
474 (suspensionWheels[FrontLeft].compressionKm + suspensionWheels[FrontRight].compressionKm) * 0.5f;
475 const float rearCompressionKm =
476 (suspensionWheels[RearLeft].compressionKm + suspensionWheels[RearRight].compressionKm) * 0.5f;
477 // Positive matches the existing missing-nose-strut convention: the nose sits lower.
478 return Clamp(atan2f(frontCompressionKm - rearCompressionKm, ourcockpit.suspensionWheelbaseKm) *
480 -RiseMath::ToRadian(10.0f), RiseMath::ToRadian(10.0f));
481}
482
484{
486 return 0.0f;
487
488 const float leftCompressionKm =
489 (suspensionWheels[FrontLeft].compressionKm + suspensionWheels[RearLeft].compressionKm) * 0.5f;
490 const float rightCompressionKm =
491 (suspensionWheels[FrontRight].compressionKm + suspensionWheels[RearRight].compressionKm) * 0.5f;
492 // Positive matches the existing missing-left-strut convention: the left side sits lower.
493 return Clamp(atan2f(leftCompressionKm - rightCompressionKm, ourcockpit.suspensionTrackWidthKm) *
495 -RiseMath::ToRadian(10.0f), RiseMath::ToRadian(10.0f));
496}
497
499{
500 float distance = RiseMath::Vec3Length(&pos);
501 if (distance > 2.0f || distance < 0.001f) return 0.0f;
502
503 RiseMath::Vector3 dir = pos;
504 RiseMath::Vec3Normalize(&dir, &dir);
505 float cosAngle = -dir.z;
506
507 float cosTheta = cosf(0.1f);
508 float cosPhi = cosf(0.2f);
509 float spotFactor = 0.0f;
510
511 if (cosAngle >= cosTheta)
512 spotFactor = 1.0f;
513 else if (cosAngle >= cosPhi)
514 spotFactor = (cosAngle - cosPhi) / (cosTheta - cosPhi);
515
516 float attenuation = 1.0f / (15.0f * distance);
517 return spotFactor * attenuation;
518}
519
520//-----------------------------------------------------------------------------
521// Name: FrameMove()
522// Desc: Animates the scene
523//-----------------------------------------------------------------------------
524void Viewscreen::OnFrameMove(double fTime, float fElapsedTime)
525{
526 logger->AddToCallStack("Viewscreen::OnFrameMove");
528 [this](const CityLogos::AssignmentAsset& asset)
529 {
530 SPacketBig request = {};
532 strcpy_s(request.msg, asset.filename.c_str());
533 request.vehicleId = asset.token;
534 gameclass->networking->SendToServer(&request, sizeof request, true);
536
537 if (!g_bEnabled)
538 {
540 return;
541 }
542
543 const float moduleFrameSeconds = fElapsedTime; // preserve real timing before physics clamps
544 HRESULT hr;
545
546 double fTimeFreezable;
547 if (playerships[0].isSimulator)
548 {
551 gameclass->bus->SimulatorTimeOffset += fElapsedTime;
552 fTimeFreezable = fTime - gameclass->bus->SimulatorTimeOffset;
553 }
554 else
555 fTimeFreezable = fTime;
556
557
558 gameclass->bus->NormalAcceleration = sumofforces; // from previous frame ... this is in G's now but sumofforces is usually kmss
559 sumofforces = centerC; // reset sum of forces counter
561 sofTracking.clear();
563
565
568
570 gameclass->bus->LatitudeDeg = latlng.x;
571 gameclass->bus->LongitudeDeg = latlng.y;
573 // Map cell and within-cell position are published together by CalculateAGLd.
574
575 gameclass->bus->ProgramTime = fTime;
576
577 short t, r, s;
578
579
580#ifndef _DEBUG
581 // Needs to be done before we manipulate fElapsedTime
582 const float m_fFPS = Rendering::ClientFPS();
583 lowframeTime = 0.0f;
584 const float minFrameRate = (Rendering::ClientWindow() == Rendering::ClientWindow()) ? 12.0f : 4.0f;
585 if (m_fFPS < minFrameRate)
586 {
587 lowframeTime += fElapsedTime;
588 if (lowframeTime > 5.0f)
589 {
590 sprintf_s(msg, sizeof msg, "FPS %.2f below threshold %.2f for %.1f seconds: %.1f", m_fFPS, minFrameRate, lowframeTime, fElapsedTime);
592 }
593 if (lowframeTime > 60.0f && m_fFPS < 4.0f)
594 {
595 strcpy_s(msg, sizeof msg, "We're sorry, your computer does not have sufficient processing power to run this program.");
596 // Please check that your graphics drivers are up-to-date and close any other applications that may be using CPU and RAM to try again
598 }
599 }
600 else
601 {
602 lowframeTime = 0.0f;
603 }
604#endif
605
606#if !_DEBUG
607 frameRateHeartbeat += fElapsedTime;
608 if (frameRateHeartbeat > 300.0f) // 5 minutes
609 {
610 frameRateHeartbeat = 0.0f;
611 SClientPacket outpacket; // NOLINT
612 outpacket.type = 20; // Frame rate heartbeat
613 outpacket.f_x = Rendering::ClientFPS();
614 outpacket.f_y = 0.0f; // NULL static_cast<float>(frequency.QuadPart);
615 outpacket.f_z = 0.0f; // NULL
616 outpacket.f_w = 0.0f; // NULL
617 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
618 }
619#endif
620
621 healTimer += fElapsedTime;
622 if (healTimer > 900.0f) // 15 minutes
623 {
624 healTimer = 0.0f;
625 if (ourcockpit.hitpoints < 255)
626 {
628 ourcockpit.vdatChanged = true;
629 }
630 }
631
632 // Too short, fastest monitor in the world on 4/19/2020 is 360 HZ
633 if (fElapsedTime < 0.00277778f)
634 {
635 sprintf_s(msg, sizeof msg, "FrameMove() elapsed %.3f with deathinhibit %.3f set 0.00277778!", fElapsedTime, deathinhibit);
636 logger->Log(msg);
637 // Fast machines end up having too small of an elapsed time variable...
638 // We should never see these because of VSYNC?
639 const auto sleepMs = static_cast<DWORD>((0.00277778f - fElapsedTime) * 1000.0f);
640 Sleep(sleepMs);
641 fElapsedTime = 0.00277778f;
642 }
643
644 // Too long
645 if (fElapsedTime > 1.0f)
646 {
647 sprintf_s(msg, sizeof msg, "FrameMove() elapsed %.3f with deathinhibit %.3f set 1.0f!", fElapsedTime, deathinhibit);
648 logger->Log(msg);
650 fElapsedTime = 0.00277778f;
651 }
652
653
654
655 // for autoflyte acknowledgement indicators
656 verticaltime -= fElapsedTime;
657 if (verticaltime < 0.0f)
658 verticaltime = 0.0f;
659 lateraltime -= fElapsedTime;
660 if (lateraltime < 0.0f)
661 lateraltime = 0.0f;
662
663
664 // for trim runaway
665 pitchTrimMod = false;
666
667
668 // Shockwaves
669 for (size_t i = 0; i < shockwaves.size(); i++)
670 {
671 SShockWave* shockwave = &shockwaves.at(i);
672 shockwave->timetoshock -= fElapsedTime;
673 if (shockwave->timetoshock <= 0.0f)
674 {
675 shockwave->shockramp += shockwave->shockspeed * fElapsedTime;
676 if (shockwave->shockramp >= 2.0f)
677 {
678 shockwaves.erase(shockwaves.begin() + i);
679 break;
680 }
681
682 float f_temp;
683 if (shockwave->shockramp > 1.0f)
684 f_temp = 2.0f - shockwave->shockramp;
685 else
686 f_temp = shockwave->shockramp;
687
688 f_temp *= fElapsedTime;
689
690 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f shockmag #%zu", -f_temp * shockwave->shockmag.x * oneOvergForceKmssC / fElapsedTime, -f_temp * shockwave->shockmag.y * oneOvergForceKmssC / fElapsedTime, -f_temp * shockwave->shockmag.z * oneOvergForceKmssC / fElapsedTime, i);
691 sofTracking.emplace_back(msg);
692
693 // verified above that we apply fElapsedTime
694 sumofforces -= f_temp * shockwave->shockmag;
695
697 }
698 }
699
700 // monitor interlacing
701 interlace += fElapsedTime;
702 if (interlace > 0.04f)
703 {
704 interlace = 0.0f;
705 if (flicker == 0)
706 flicker = 1;
707 else
708 flicker = 0;
709 }
710
711 // Lamp test
712 lampTest -= fElapsedTime;
713 if (lampTest < 0.0f)
714 lampTest = 0.0f;
715
716
717 Rendering::ProfileScope11 displayUpdateTiming("Display update", false);
718 // Display processing
719 const auto& gpws = gameclass->bus->GPWS;
720 if ((playerships[0].reference == REF_APNMODE || playerships[0].reference == REF_ACLMODE) &&
721 TerrainAwareness::DisplayAllowed(playerships[0].isSimulator, playerships[0].groundvehicle, ourcockpit.power) &&
722 !gpws.inhibited && !gpws.testLevel && (gpws.warningLamp || gpws.cautionLamp || gpws.TerrainDisplayActive()))
723 {
724 // These cockpits put the map on the MFD; A-4 and W-6 have permanent map displays.
725 switch (ourcockpit.texturelib)
726 {
729 gameclass->displays->ChangePage("MFD", "Moving Map");
730 break;
731 }
732 }
733 gameclass->displays->FrameMove(fElapsedTime);
734 displayUpdateTiming.Stop();
735
736
737 Rendering::ProfileScope11 moduleUpdateTiming("Module update", false);
738 // Module processing
739 gameclass->moduleScheduler.Advance(moduleFrameSeconds, gameclass->modules.size(),
740 [&](size_t index, float elapsed, float maxFrameSeconds) {
741 auto& module = gameclass->modules[index];
742 module->maxFrameSeconds = maxFrameSeconds;
743 module->FrameMove(elapsed);
744 });
745 moduleUpdateTiming.Stop();
746
747
748 AssertTelemetry("FrameMove::OnFrameMove1", 0);
749
750
751
752 RiseMath::Matrix matrixTemp;
753
754
755 g_bRunning = true;
756
757
758 for (t = 0; t < 2; t++)
759 {
760 weapontimer[t] += fElapsedTime;
767 }
768
769
770 deathinhibit -= fElapsedTime;
771 if (deathinhibit < 0.0f)
772 deathinhibit = 0.0f;
773
774
775 RiseMath::Vector3 result;
776
777
778
779 // BPM
780 const float previousBPM = currentBPM;
781 // RHR based on age
782 float baseBPM = 70.0f + (static_cast<float>(gameclass->GUI->player[gameclass->GUI->ourplayerC].age) - 20.0f) / 5.0f;
783 // based on gender
784 baseBPM += (gameclass->GUI->player[gameclass->GUI->ourplayerC].sex == 2) ? 7.0f : 0.0f;
785 // Based on BMI
786 baseBPM += (ourcockpit.bmi - 22.0f) * 0.5f;
787 // RHR based on cabin altitude
789 baseBPM += -0.06451925f * gameclass->bus->CabinPressureMb + 65.37413f;
790 else
791 baseBPM -= 0.009869233f * gameclass->bus->CabinPressureMb - 10.0f;
792
793 // external factors
794 float vasoBPM = baseBPM;
795
796 // Hitpoints
797 vasoBPM += (255.0f - static_cast<float>(ourcockpit.hitpoints)) / 255.0f * 70.0f;
798 // based on vertical G-force
800 // lateral G-force
801 vasoBPM *= (1.0f + 0.15f * fabsf(gameclass->bus->NormalAcceleration.x));
802 // longitudinal G-force
803 vasoBPM *= (1.0f + 0.1f * fabsf(gameclass->bus->NormalAcceleration.z));
804
805 vasoBPM -= baseBPM;
806
807 // additional adrenalin
808 if (ourcockpit.adrenolinBPM > 40.0f)
809 ourcockpit.adrenolinBPM = 40.0f;
810 float targetBPM = baseBPM + vasoBPM + ourcockpit.adrenolinBPM;
811
812 // Ongoing stressors would only elevate 20 BPM and it would be like the combination
813 // 6.66666 BPM per stressor so low to ground relative to obstacles at high groundspeed ?
814 float aglEffect = 0.0f;
815 if (f_AGL < 1.0f && playerships[0].reference == Reference::REF_APNMODE) // 1km cutoff due to highest buildings being 700m AGL
816 aglEffect = 1.0f - f_AGL; // lower to ground is higher effect
817 float gsEffect = gameclass->bus->GroundSpeedKms / 0.0268224f; // 60 MPH to Kms
818 if (gsEffect > 1.0f)
819 gsEffect = 1.0f;
820 float nightEffect = 1.0f - ptrWeather->elevation;
821 float vizEffect = 0.0f;
823 vizEffect = 1.0f - (gameclass->viewscreen->ptrWeather->GetVisibilityKm() / f_AGL);
824 // viz3 and i am at 3 then 1 = 0
825 // viz2 and I am at 3km then i can't see the ground ... 0.66 = 0.33
826 // viz1 and I am at 3 ... .33 = 0.66
827 // viz0 and I am at 3 ... 0 = 1
828 targetBPM += 40.0f * aglEffect * gsEffect * RiseMath::Min(nightEffect + vizEffect, 1.0f);
829
830
831 gameclass->bus->DebugBaseBPM = baseBPM;
832 gameclass->bus->DebugVasoBPM = vasoBPM;
834 gameclass->bus->DebugStressBPM = 40.0f * aglEffect * gsEffect * RiseMath::Min(nightEffect + vizEffect, 1.0f);
835
836
837
838 const float wakeFactor = !dead && currentBPM == 0 ? .7f + RandomFloat() * .2f : .8f;
839 const auto bpmStep = BiometerState::Advance(currentBPM, targetBPM, baseBPM,
840 ourcockpit.maxBPM, fElapsedTime, dead != DeathType::ImNotDeadYet, wakeFactor);
841 currentBPM = bpmStep.value;
842
843 // Diagnostic values come from the simulated character/physics calculation.
845 bpmSample.time = fTime;
846 bpmSample.dt = fElapsedTime;
847 bpmSample.previous = previousBPM;
848 bpmSample.integrationStart = bpmStep.start;
849 bpmSample.integrated = bpmStep.value;
850 bpmSample.current = currentBPM;
851 bpmSample.maximum = ourcockpit.maxBPM;
852 bpmSample.target = targetBPM;
853 bpmSample.base = baseBPM;
854 bpmSample.vaso = vasoBPM;
856 bpmSample.stress = gameclass->bus->DebugStressBPM;
857 bpmSample.gx = gameclass->bus->NormalAcceleration.x;
858 bpmSample.gy = gameclass->bus->NormalAcceleration.y;
859 bpmSample.gz = gameclass->bus->NormalAcceleration.z;
861 bpmSample.agl = f_AGL;
862 bpmSample.speed = gameclass->bus->GroundSpeedKms;
863 bpmSample.elevation = ptrWeather->elevation;
865 bpmSample.heartFrame = heartloop;
866 bpmSample.dead = dead != DeathType::ImNotDeadYet;
867 bpmSample.simulator = playerships[0].isSimulator;
868 biometerDiagnostics.Observe(bpmSample, GetTickCount64(), [this](const char* line, bool report)
869 {
870 // Forward calculation faults to the connected Rise game server using
871 // its existing nonblocking, rate-limited error/trace path.
872 logger->Log(line, report ? Logger::Error : Logger::Info);
873 });
874
875 if (ourcockpit.adrenolinBPM > 0)
876 {
877 ourcockpit.adrenolinBPM -= 20.0f * fElapsedTime / 60.0f; // Gradual Recovery Time: 20-60 seconds for the heart rate to return to baseline or adjusted stress level.
878 if (ourcockpit.adrenolinBPM < 0.0f)
880 }
881
882 const float percentBPM = BiometerState::Effort(currentBPM, baseBPM, ourcockpit.maxBPM);
883
884 // volume at baseBPM is 0 ... maxBPM is 1
885 if (currentBPM > 0)
886 gameclass->sound->PlayEx(SOUND_HEARTBEAT, true, RiseMath::Max(0.05f, percentBPM), currentBPM / 60.0f, 0, false);
887 else
889
890
892
894 {
895 // we have a resp rate based on heart rate ... 15 at rest to 60 at exertion
896 float breathPerMinute = percentBPM * 45.0f + 15.0f;
897 // 2.7 average at 1x ... 19.5 seconds of silence total in a minute ... 1.3 seconds between breathes
898 breathTimer += fElapsedTime;
899 if (breathTimer > 60.0f / breathPerMinute)
900 {
901 gameclass->sound->PlayEx(static_cast<SOUNDS>(SOUND_RESP0 + rand() % 10), false, 0.5f, percentBPM * 2.0f + 1.0f, 0, true);
902 breathTimer = 0.0f;
903 }
904 }
905
906
907 m_fAnimateFrame += fElapsedTime;
908 if (m_fAnimateFrame >= 0.0416667f) // 24 fps
909 {
910 m_fAnimateFrame = 0.0f;
911 advanceframe = true;
912
914 flasher += 0.0416667f;
915 if (flasher >= 1.0f)
916 flasher = 0.0f;
917
918 // Fireworks
919 for (t = 0; t < fireworksC; t++)
920 {
921 if (fireworks[t].inuse)
922 {
923 fireworks[t].texture++;
924 if (fireworks[t].texture >= firework1C && fireworks[t].type == 0)
925 fireworks[t].inuse = false;
926 else if (fireworks[t].texture >= firework2C && fireworks[t].type == 1)
927 fireworks[t].inuse = false;
928 else if (fireworks[t].texture >= firework3C && fireworks[t].type == 2)
929 fireworks[t].inuse = false;
930 }
931 }
932 }
933 else
934 advanceframe = false;
935
936 // water animation
937 H2Ooffsetu += 0.001f * fElapsedTime; // 2 m/s ... 2000 meters means 1000 seconds ... 1 UV per 1000 seconds
938 if (H2Ooffsetu >= 1.0f)
939 H2Ooffsetu--;
940
941 Rendering::ProfileScope11 inputTiming("Input update", false);
942 hornBindingDown = false; // keyboard and all controller bindings contribute to this frame
943 if (!dead)
944 {
945 ptrKeyboard->Update(fElapsedTime);
946 ptrJoystick->Update(fElapsedTime);
948 }
949 else
952 inputTiming.Stop();
953
954
955#pragma region Flight state update
956
957
958
959
960 // turned off 5/22/2018 because mouse for steering is pissing me off
961 /*
962 if (!game->gameclass->config.g_bMoveJoystick && game->gameclass->GUI->g_bLeftDown && !dead &&
963 game->gameclass->GUI->cursoroverwindow == -1 && !game->gameclass->GUI->g_bDragging)
964 {
965 // make sure ptClick is within the view region (not letterboxes)
966 if (game->gameclass->GUI->ptClick.x >= 0 && game->gameclass->GUI->ptClick.x <= (long)pp->Width &&
967 game->gameclass->GUI->ptClick.y >= 0 && game->gameclass->GUI->ptClick.y <= (long)pp->Height)
968 {
969 if (playerships[0].reference != REF_ONGROUND)
970 {
971 if (game->gameclass->bus->AFCS->CurrentLateralMode == Bus::Afcs::LateralModes::Takeoff && g_bCoupled)
972 {
973 desiredroll = (float)(game->gameclass->GUI->ptCursor.x - (long)pp->Width / 2)*0.0025f;
974 if (desiredroll > limiterC)
975 desiredroll = limiterC;
976 else if (desiredroll < -limiterC)
977 desiredroll = -limiterC;
978 }
979 else
980 {
981 game->roll = (float)(game->gameclass->GUI->ptCursor.x - (long)pp->Width / 2)*0.0025f;
982 if (game->roll > limiterC)
983 game->roll = limiterC;
984 else if (game->roll < -limiterC)
985 game->roll = -limiterC;
986 }
987 }
988 else
989 {
990 game->yaw = (float)(game->gameclass->GUI->ptCursor.x - (long)pp->Width / 2)*0.0025f;
991 float limit = limiterC*2.0f*0.001f / RiseMath::Max(0.001f, fabsf(groundspeed));
992 if (game->yaw > limit)
993 game->yaw = limit;
994 else if (game->yaw < -limit)
995 game->yaw = -limit;
996 }
997
998 if (game->gameclass->bus->AFCS->CurrentVerticalMode == Bus::Afcs::VerticalModes::Takeoff && g_bCoupled)
999 {
1000 desiredvsi = (float)(game->gameclass->GUI->ptCursor.y - (long)pp->Height / 2)*0.0025f;
1001 }
1002 else
1003 {
1004 game->pitch = (float)(game->gameclass->GUI->ptCursor.y - (long)pp->Height / 2)*0.0025f;
1005 if (game->pitch > limiterC)
1006 game->pitch = limiterC;
1007 else if (game->pitch < -limiterC)
1008 game->pitch = -limiterC;
1009 }
1010 }
1011 }
1012 */
1013
1014 RiseMath::Vector3 cross;
1015 RiseMath::Quaternion quaternionTemp;
1016
1017 float f_temp;
1018
1019
1020 // Orbit processor for non-human-driven objects, not necessary here, no access protected
1021 // should be done in hierarchy, the stars and sun then...
1022 // the planets (including Iomere)
1023 // the moons (including Vieneo)
1024 // then do our barycentric trick to keep the ground steady
1025 // then do the cloud layers
1026 // and the docks
1027 Rendering::ProfileScope11 celestialTiming("Celestial and cloud motion", false);
1028 logger->AddToCallStack("FrameMove::Celestial");
1029 for (t = maxdockC; t < maxstarC; t++)
1030 {
1032
1033 if (t == cloudBaseObjC)
1034 {
1035 // wind speed in kms over 2 km for the grid size times 2.1 for average cloud base 10.5 m/s winds if surface is 5 m/s
1036 allobjects[cloudBaseObjC].rotprog -= ptrWeather->GetWindspeedKms() / 2.0f * 2.1f * fElapsedTime;
1037
1038 // allobjects[cloudBaseObjC].rotprog is NOT in radians ... it is a texture offset!
1039 if (allobjects[cloudBaseObjC].rotprog >= 1.0f)
1041 //else if (allobjects[cloudBaseObjC].rotprog < 0.0f)
1042 // allobjects[cloudBaseObjC].rotprog++;
1043 }
1044 else if (allobjects[t].rotation)
1045 {
1046 const double dTemp = static_cast<double>(RiseMath::Tau) / static_cast<double>(allobjects[t].rotation);
1047 double test = static_cast<double>(allobjects[t].rotoffset);
1048 test += static_cast<double>(f_Uphours) * 3600.0 / dTemp;
1049 test -= floor(test);
1050 test += (static_cast<double>(g_UniverseTime) + fTimeFreezable) / dTemp;
1051 test -= floor(test);
1052 test *= static_cast<double>(RiseMath::Tau);
1053 allobjects[t].rotprog = static_cast<float>(test);
1054 }
1055
1056 if (t != ourmoonC) // Don't rotate Vieneo, barycentric
1057 {
1058 RiseMath::MatrixRotationZ(&matrixTemp, allobjects[t].rotprog);
1059 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &matrixTemp, &allobjects[t].matrixWorld);
1060
1061 if (allobjects[t].revolution)
1062 {
1063 const double dTemp = static_cast<double>(RiseMath::Tau) / static_cast<double>(allobjects[t].revolution);
1064 double test = static_cast<double>(allobjects[t].revoffset);
1065 test += static_cast<double>(f_Uphours) * 3600.0 / dTemp;
1066 test -= floor(test);
1067 test += (static_cast<double>(g_UniverseTime) + fTimeFreezable) / dTemp;
1068 test -= floor(test);
1069 test *= static_cast<double>(RiseMath::Tau);
1070 allobjects[t].revprog = static_cast<float>(test);
1071 }
1072
1073 // Rotation after tilt adjustment is remember LEFT=LOCAL
1074 RiseMath::MatrixRotationZ(&matrixTemp, allobjects[t].revprog);
1075 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1076 RiseMath::MatrixRotationX(&matrixTemp, allobjects[ourmoonC].tilt); // Rotate plane by tilt
1077 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1078 RiseMath::MatrixRotationZ(&matrixTemp, -allobjects[ourmoonC].rotprog); // -barycentric
1079 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1080 }
1081
1082 // Save it so everyone can use it before it is mucked up
1084
1085 // lets try the deal where the range has nothing to do with the matrix;
1086// allobjects[t].position.x=0.0f;
1087// allobjects[t].position.y=allobjects[t].range;
1088// allobjects[t].position.z=0.0f;
1089// RiseMath::Vec3TransformCoord( &allobjects[t].position, &allobjects[t].position, &allobjects[t].matrixWorld );
1090
1094
1095 if (allobjects[t].type != -5 && t != ourstarC) // Static Stars and sun are always same distance from us
1096 {
1098 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1099 }
1100 else if (allobjects[t].type == -7) // We grab sunlight parameters for Yonmara
1101 {
1102 // Universe coordinates for sunlight parameters
1104
1105 RiseMath::Vec3Normalize(&cross, &cross);
1106
1107 // Keep the clock tied to the real orbit, even during a visual sun override.
1109 const float sunLogitudeNorm = CalculateLatLng(cross).y / 180.0f;
1110 const float ourLogitudeNorm = (roundf(gameclass->bus->LongitudeDeg / 24.0f) * 24.0f) / 180.0f;
1111 // 0 is midnight, 0.5 is 12 noon, 1 is midnight ... at .9 it is 23
1112 float diff = (ourLogitudeNorm - sunLogitudeNorm) * 0.5f + 0.5f;
1113 // we want 0 is 4am and 1 is 4pm
1114 if (diff < 0.0f) diff += 1.0f;
1115 else if (diff > 1.0f) diff -= 1.0f;
1116 diff *= 24.0f; // to hours
1117 gameclass->bus->LocalTimeHours = floorf(diff);
1118 diff -= gameclass->bus->LocalTimeHours;
1119 diff *= 36.075f;
1120 gameclass->bus->LocalTimeMinutes = floorf(diff);
1121
1122 // One position drives the disc, sky ring, weather, clouds and scene lighting.
1123 // matrixBase/matrixReal retain the orbit; SUN-1 resumes its current position.
1124 // Keep the clock calculation above intact. The solar billboard is a
1125 // distant directional source with no observer translation; illumination
1126 // and eclipse geometry must use that same apparent direction.
1127 if (!playerships[0].isSimulator)
1130 allobjects[t].matrixWorld, cross);
1131 sunlight.Direction = cross;
1133 }
1134
1135 if (t == UCLobjC && playerships[0].mslKm != -1.0f) // upper cloud layer
1136 {
1137 // Always running closest facet regardless if on surface or in orbit
1138 // Always running closest macro facet
1139 float dist[4500];
1140 bool swapflag;
1141 RiseVertexVertex temp_vertex2[3];
1142 RiseMath::Vector3 temp_vector[3], temp, result1;
1143 RiseMath::MatrixInverse(&matrixTemp, nullptr, &allobjects[t].matrixReal);
1144 RiseMath::Vec3TransformCoord(&result, &position, &matrixTemp);
1145 for (s = 0; s < 4500; s++)
1146 {
1147 RiseMath::Vec3Subtract(&temp, &result, &polyextras2.center[s]);
1148 dist[s] = RiseMath::Vec3LengthSq(&temp);
1149 }
1150 do
1151 {
1152 swapflag = false;
1153 for (s = 0; s < 4499; s++) // 4500-1
1154 {
1155 if (dist[s] > dist[s + 1])
1156 {
1157 temp_vertex2[0] = polyextras2.vertexbackup[s * 3 + 0];
1158 temp_vertex2[1] = polyextras2.vertexbackup[s * 3 + 1];
1159 temp_vertex2[2] = polyextras2.vertexbackup[s * 3 + 2];
1160 f_temp = dist[s]; temp = polyextras2.center[s]; r = polyextras2.index[s];
1161 polyextras2.vertexbackup[s * 3 + 0] = polyextras2.vertexbackup[(s + 1) * 3 + 0];
1162 polyextras2.vertexbackup[s * 3 + 1] = polyextras2.vertexbackup[(s + 1) * 3 + 1];
1163 polyextras2.vertexbackup[s * 3 + 2] = polyextras2.vertexbackup[(s + 1) * 3 + 2];
1164 dist[s] = dist[s + 1]; polyextras2.center[s] = polyextras2.center[s + 1]; polyextras2.index[s] = polyextras2.index[s + 1];
1165 polyextras2.vertexbackup[(s + 1) * 3 + 0] = temp_vertex2[0];
1166 polyextras2.vertexbackup[(s + 1) * 3 + 1] = temp_vertex2[1];
1167 polyextras2.vertexbackup[(s + 1) * 3 + 2] = temp_vertex2[2];
1168 dist[s + 1] = f_temp; polyextras2.center[s + 1] = temp; polyextras2.index[s + 1] = r;
1169 swapflag = true;
1170 }
1171 }
1172 } while (swapflag && g_bAboveClouds);
1173
1174 RiseMath::Plane aglplane;
1175 temp_vector[0].x = polyextras2.vertexbackup[0].x;
1176 temp_vector[0].y = polyextras2.vertexbackup[0].y;
1177 temp_vector[0].z = polyextras2.vertexbackup[0].z;
1178 temp_vector[1].x = polyextras2.vertexbackup[1].x;
1179 temp_vector[1].y = polyextras2.vertexbackup[1].y;
1180 temp_vector[1].z = polyextras2.vertexbackup[1].z;
1181 temp_vector[2].x = polyextras2.vertexbackup[2].x;
1182 temp_vector[2].y = polyextras2.vertexbackup[2].y;
1183 temp_vector[2].z = polyextras2.vertexbackup[2].z;
1184
1185 // temp=(temp_vector[0]+temp_vector[1]+temp_vector[2])/3.0f;
1186 // sprintf_s(msg, sizeof msg, "Deep sucker %f", RiseMath::Vec3Length(&temp) );
1187 // _write(logfile, msg, strlen(msg));
1188
1189 RiseMath::PlaneFromPoints(&aglplane, &temp_vector[0], &temp_vector[1], &temp_vector[2]);
1190
1191 RiseMath::PlaneNormalize(&aglplane, &aglplane);
1192 RiseMath::MatrixInverse(&matrixTemp, nullptr, &allobjects[t].matrixReal);
1193 RiseMath::MatrixTranspose(&matrixTemp, &matrixTemp);
1194
1195 RiseMath::PlaneTransform(&aglplane, &aglplane, &matrixTemp);
1196
1197 // See where line intersects plane (line starts 5km below cloud tops to 5km above)
1199 RiseMath::Vec3Scale(&result1, &posnorml, cloudTopsRadiusC + 5.0f);
1200 RiseMath::PlaneIntersectLine(&temp, &aglplane, &result, &result1);
1201 f_ACL = radiusC + playerships[0].mslKm - RiseMath::Vec3Length(&temp) - 0.5f; // take off 500 meters because of the polygons being clipped before we got to the cloud layer because of the size of the polygons probably
1202 }
1203 }
1204
1205 celestialTiming.Stop();
1206 Rendering::ProfileScope11 dockMotionTiming("Dock motion", false);
1207 logger->AddToCallStack("FrameMove::Docks");
1208 // must do docks first since they can be reference items
1209 for (t = 0; t < maxdockC; t++) // after the moon has been calculated, find the docks
1210 {
1212
1213 allobjects[t].revprog = static_cast<float>(allobjects[t].revoffset + allobjects[t].revolution * fTimeFreezable);
1214
1215 // Rotation after tilt adjustment is remember LEFT=LOCAL
1216 RiseMath::MatrixRotationZ(&matrixTemp, allobjects[t].revprog);
1217 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1218 RiseMath::MatrixRotationX(&matrixTemp, allobjects[t].inclination); // Rotate plane by tilt
1219 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1220 RiseMath::MatrixRotationZ(&matrixTemp, -allobjects[ourmoonC].rotprog); // -barycentric
1221 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
1222
1223 // Save it so everyone can use it before it is mucked up (we don't actually use this for docks at all)
1225
1229
1230
1231 // calculate velocity (for TVM)
1232 // done by calculating position 1 second in the future?
1233 RiseMath::Matrix matrixPos = allobjects[t].matrixBase;
1234 RiseMath::MatrixRotationZ(&matrixTemp, allobjects[t].revprog + allobjects[t].revolution);
1235 RiseMath::MatrixMultiply(&matrixPos, &matrixPos, &matrixTemp);
1236 RiseMath::MatrixRotationX(&matrixTemp, allobjects[t].inclination); // Rotate plane by tilt
1237 RiseMath::MatrixMultiply(&matrixPos, &matrixPos, &matrixTemp);
1238 RiseMath::MatrixRotationZ(&matrixTemp, -allobjects[ourmoonC].rotprog);
1239 RiseMath::MatrixMultiply(&matrixPos, &matrixPos, &matrixTemp);
1240
1241 RiseMath::Vector3 nextPosition;
1242 nextPosition.x = -matrixPos._41;
1243 nextPosition.y = -matrixPos._42;
1244 nextPosition.z = -matrixPos._43;
1245
1246 RiseMath::Vec3Subtract(&allobjects[t].velocity, &nextPosition, &allobjects[t].position);
1247
1248
1249 // calculate orientation
1251
1252
1253 for (s = 0; s < allobjects[t].components; s++)
1254 {
1255 allobjects[t].componentarray[s].extended += fElapsedTime * 0.05f;
1256 if (allobjects[t].componentarray[s].extended >= 1.0f)
1258 }
1259 }
1260
1261 dockMotionTiming.Stop();
1262 Rendering::ProfileScope11 parentMotionTiming("Parent vehicle motion", false);
1263 logger->AddToCallStack("Viewscreen::OnFrameMove Network Objects1");
1264 // Network objects processing for our parent vehicle
1265 if (playerships[0].reference == REF_INANOTHER)
1266 {
1267 t = playerships[0].inarray;
1268 if (playerships[t].visible && playerships[t].active)
1269 {
1270 if (!ApplyBufferedVehicleState(t, fElapsedTime))
1271 {
1272 // Nicely interpolate position
1273 cross = playerships[t].positer * fElapsedTime;
1274 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].posleft))
1275 cross = playerships[t].posleft;
1276 playerships[t].posleft -= cross;
1277 if (playerships[t].reference < REF_INANOTHER)
1278 {
1279 playerships[t].precisionx += static_cast<double>(cross.x);
1280 playerships[t].precisiony += static_cast<double>(cross.y);
1281 playerships[t].precisionz += static_cast<double>(cross.z);
1282 }
1283 else
1284 RiseMath::Vec3Add(&playerships[t].dockoffset, &playerships[t].dockoffset, &cross);
1285
1286 // Nicely interpolate velocity
1287 cross = playerships[t].veliter * fElapsedTime;
1288 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].velleft))
1289 cross = playerships[t].velleft;
1290 playerships[t].velleft -= cross;
1291
1292 if (playerships[t].reference < REF_INANOTHER)
1293 RiseMath::Vec3Add(&playerships[t].velocity, &playerships[t].velocity, &cross);
1294 else
1295 RiseMath::Vec3Add(&playerships[t].dockingvel, &playerships[t].dockingvel, &cross);
1296
1297 // Nicely interpolate acceleration
1298 cross = playerships[t].acciter * fElapsedTime;
1299 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].accleft))
1300 cross = playerships[t].accleft;
1301 playerships[t].accleft -= cross;
1302 RiseMath::Vec3Add(&playerships[t].acc, &playerships[t].acc, &cross);
1303
1304#pragma region Nicely interpolate YPR
1305 // so if iter is .2 and left is .1 then .2>.1 ... iter -.2 left is -.1
1306 f_temp = playerships[t].pitchiter * fElapsedTime;
1307 if (fabsf(f_temp) > fabsf(playerships[t].pitchleft))
1308 f_temp = playerships[t].pitchleft;
1309 playerships[t].pitchleft -= f_temp;
1310 playerships[t].pitch += f_temp;
1311
1312 f_temp = playerships[t].rolliter * fElapsedTime;
1313 if (fabsf(f_temp) > fabsf(playerships[t].rollleft))
1314 f_temp = playerships[t].rollleft;
1315 playerships[t].rollleft -= f_temp;
1316 playerships[t].rollRadPerSec += f_temp;
1317
1318 f_temp = playerships[t].yawiter * fElapsedTime;
1319 if (fabsf(f_temp) > fabsf(playerships[t].yawleft))
1320 f_temp = playerships[t].yawleft;
1321 playerships[t].yawleft -= f_temp;
1322 playerships[t].yawRadPerSec += f_temp;
1323#pragma endregion
1324
1325#pragma region Nicely interpolate Thrust
1326 // so if iter is .2 and left is .1 then .2>.1 ... iter -.2 left is -.1
1327 f_temp = playerships[t].txiter * fElapsedTime;
1328 if (fabsf(f_temp) > fabsf(playerships[t].txleft))
1329 f_temp = playerships[t].txleft;
1330 playerships[t].txleft -= f_temp;
1331 playerships[t].tx += f_temp;
1332 playerships[t].tx = Clamp(playerships[t].tx, -1, 1);
1333
1334 f_temp = playerships[t].tyiter * fElapsedTime;
1335 if (fabsf(f_temp) > fabsf(playerships[t].tyleft))
1336 f_temp = playerships[t].tyleft;
1337 playerships[t].tyleft -= f_temp;
1338 playerships[t].ty += f_temp;
1339 playerships[t].ty = Clamp(playerships[t].ty, -1, 1);
1340
1341 f_temp = playerships[t].tziter * fElapsedTime;
1342 if (fabsf(f_temp) > fabsf(playerships[t].tzleft))
1343 f_temp = playerships[t].tzleft;
1344 playerships[t].tzleft -= f_temp;
1345 playerships[t].tz += f_temp;
1346 playerships[t].tz = Clamp(playerships[t].tz, -1, 1);
1347#pragma endregion
1348
1349 // Move based on gravity and barycentric rotation adjustment depending on reference
1350 Movement(t, fElapsedTime);
1351 }
1352 }
1353 }
1354
1355
1356
1357 parentMotionTiming.Stop();
1358 Rendering::ProfileScope11 ownMotionTiming("Own vehicle movement", false);
1359 // Has to be done here before the ship matrices are made
1360 // MOVED TO DO THIS BEFORE MOVEMENT(T) on 9/2/2019 BECAUSE ARJS WERE JUMPING AROUND IN BAY
1361 const float ourPositionLength = RiseMath::Vec3Length(&playerships[0].position);
1362 playerships[0].mslKm = ourPositionLength - radiusC;
1364 if (!dead)
1365 {
1366 logger->AddToCallStack("Viewscreen::OnFrameMove Our Movement");
1367 if (!gameclass->bus->FlightFreeze)
1368 Movement(0, fElapsedTime);
1369 else
1370 Movement(0, 0);
1371 }
1372
1373
1374
1375 AssertTelemetry("FrameMove::OnFrameMove4", 0);
1376
1377
1378
1379
1380 ownMotionTiming.Stop();
1381 Rendering::ProfileScope11 otherMotionTiming("Other vehicle movement", false);
1382 logger->AddToCallStack("Viewscreen::OnFrameMove Network Objects2");
1383 // Network objects processing, everyone but us and our parent
1384 for (t = 1; t < MAX_SCAN; t++) // not us
1385 {
1386 if (playerships[t].reference == REF_INANOTHER) // do these last
1387 continue;
1388
1389 NetworkObjectsProcessing(t, fElapsedTime);
1390 }
1391
1392 for (t = 1; t < MAX_SCAN; t++) // not us
1393 {
1394 if (playerships[t].reference != REF_INANOTHER) // already done above
1395 continue;
1396
1397 NetworkObjectsProcessing(t, fElapsedTime);
1398 }
1399
1400
1401
1402 otherMotionTiming.Stop();
1403 Rendering::ProfileScope11 dockingTiming("Docking update", false);
1404 // DOCKING ----------------------------------------------------------------------------------
1405 if (playerships[0].reference >= REF_DOCKENUMCPOC)
1406 {
1407 logger->AddToCallStack("Viewscreen::OnFrameMove Docking");
1408 s = playerships[0].portassigned; // Interface
1410
1411 if (oldportassigned != playerships[0].portassigned || olddocked != playerships[0].docked)
1412 {
1415
1416 if (s != -1)
1417 {
1418 // Extensions
1419 RiseMath::Vec3Scale(&result, &allobjects[t].componentarray[s].extendby, allobjects[t].componentarray[s].extended);
1420 RiseMath::Vec3Add(&result, &allobjects[t].componentarray[s].nominalxyz, &result);
1421 // result=allobjects[t].componentarray[s].nominalxyz;
1422
1423 RiseMath::Vector3 docknormal, nosenormal;
1424 docknormal.x = 0.0f;
1425 docknormal.y = 0.0f;
1426 docknormal.z = 1.0f; // easydock down
1427 nosenormal.x = -cosf(allobjects[t].componentarray[s].nominalypr.z);
1428 nosenormal.y = -sinf(allobjects[t].componentarray[s].nominalypr.z);
1429 nosenormal.z = 0.0f;
1430
1431 result -= 8.0f * shipdockscaleC * docknormal; // docking interface face is 8 dock units down from module CG
1432 result -= 4.0f * shipdockscaleC * nosenormal; // CG of ship is offset by 4 on the nose
1433
1434 result -= ourcockpit.dockOffsetKmZ * docknormal; // CG of ship is 8 below interface
1435 result -= ourcockpit.dockOffsetKmY * nosenormal; // CG of ship is 8 below interface, might need to be a +
1436
1437 RiseMath::MatrixRotationQuaternion(&matrixTemp, &allobjects[t].orientation);
1438 RiseMath::MatrixInverse(&matrixTemp, nullptr, &matrixTemp);
1439
1440 RiseMath::Vec3TransformCoord(&dockInterface, &result, &matrixTemp);
1442
1443 result -= nosenormal; // 1km marker
1444
1445 // This now contains rotated and adjusted for ship scale and CG offset
1446 RiseMath::Vec3TransformCoord(&dockMarker, &result, &matrixTemp);
1448
1451 }
1452 }
1453
1454 if (playerships[0].docked)
1455 {
1456 if (dockprogress < 1.0f)
1457 {
1459 dockprogress += fElapsedTime * 0.05f;
1460 if (dockprogress > 1.0f)
1461 {
1462 dockprogress = 1.0f;
1464
1465 if (!playerships[0].isSimulator)
1466 {
1467 SClientPacket outpacket; // NOLINT
1468 outpacket.type = 2; // Docking change
1469 outpacket.f_x = static_cast<float>(playerships[0].portassigned);
1470 outpacket.f_y = 1.0f; // docked
1471 outpacket.f_z = 0.0f; // NULL
1472 outpacket.f_w = 0.0f; // NULL
1473 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
1474 }
1475
1476 sprintf_s(msg, sizeof msg, "Client docked to port %i...", playerships[0].portassigned);
1477 logger->Log(msg);
1478
1480
1481 if ((playerships[0].reference == REF_DOCKENUMCPOC && allobjects[0].evac) ||
1482 (playerships[0].reference == REF_DOCKTAC && allobjects[1].evac))
1483 gameclass->sound->PlayEx(SOUND_DOCKEVAC, true, 1, 1, 0, false);
1484 }
1485 }// progress less than 100%
1486
1487 // Now come up with desired ship orientation
1488 RiseMath::Quaternion desiredorient = allobjects[t].orientation;
1489 RiseMath::Quaternion quatTemp;
1491 desiredorient *= quatTemp;
1492
1493 // First do this in the first 1/2 of dockprogress
1494 if (dockprogress <= 0.5f)
1495 f_temp = dockprogress * 2.0f;
1496 else
1497 f_temp = 1.0f;
1498
1499 RiseMath::QuaternionSlerp(&playerships[0].orientation, &startorient, &desiredorient, f_temp);
1500
1501 if (dockprogress >= 0.5f)
1502 RiseMath::Vec3Lerp(&playerships[0].dockoffset, &dockMarker, &dockInterface, (dockprogress - 0.5f) * 2.0f);
1503 else
1505
1506
1509 }
1510 else
1511 {
1512 if (dockprogress > 0.0f)
1513 {
1514 dockprogress -= fElapsedTime * 0.05f;
1515 if (dockprogress < 0.0f)
1516 {
1517 dockprogress = 0.0f;
1518
1519 playerships[0].portassigned = -1;
1520
1521 if (!playerships[0].isSimulator)
1522 {
1523 SClientPacket outpacket; // NOLINT
1524 outpacket.type = 2; // Docking change
1525 outpacket.f_x = -1.0f; // no more port
1526 outpacket.f_y = 0.0f; // undocked
1527 outpacket.f_z = 0.0f; // NULL
1528 outpacket.f_w = 0.0f; // NULL
1529 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
1530 }
1531 }
1532
1534
1537 }
1538 }
1539 }
1540
1541
1542
1543 AssertTelemetry("FrameMove::OnFrameMove2", 0);
1544
1545
1546
1547 dockingTiming.Stop();
1548 // Terrain and ground grid processor
1549 Rendering::ProfileScope11 gridTiming("Terrain grid update", false);
1550 ptrGrid->Process(); // This shifts us to the correct location
1551 gridTiming.Stop();
1552 // AGL calc should be done BEFORE we move and AFTER we shift, so since AGL calc comes after this
1553 // we must use ACTUAL location NOT proposed
1554
1555
1556
1557 AssertTelemetry("FrameMove::OnFrameMove3", 0);
1558
1559
1560
1561 // Network objects processing, only protected section in FrameMove --------------------------
1562 Rendering::ProfileScope11 vehiclePoseTiming("Vehicle visibility and component animation", false);
1563 logger->AddToCallStack("Viewscreen::OnFrameMove Network Objects");
1565 for (t = 0; t < MAX_SCAN; t++)
1566 {
1567 if (playerships[t].active && playerships[t].visible && !playerships[t].isSimulator)
1568 {
1569 if (t != 0)
1570 {
1572
1573 const float oldDistance = playerships[t].distance;
1574 result = playerships[t].position - playerships[0].position;
1576
1577 if ((t + gameclass->bus->scanscroll - 1) == gameclass->bus->targetC)
1579
1580 // 250 is too far away ... really I had this idea if they pull up to a vehicle
1581 if (playerships[t].distance <= 0.05f && oldDistance > 0.05f && playerships[0].reference != REF_BUILDING)
1583
1585 if (playerships[t].distance < playerships[t].bound || // we are inside
1586 (playerships[t].reference == REF_INANOTHER && playerships[t].inarray == 0)) // our bay
1587 {
1588 playerships[t].drawflag = true;
1589 }
1590 else if (playerships[0].reference == REF_WINDOWLESS && gameclass->GUI->player[ourcockpit.ourplyrC].bldg == 2 && // hangar
1591 (playerships[t].reference != REF_INANOTHER || playerships[t].inarray != 0)) // not in our ship
1592 {
1593 playerships[t].drawflag = false;
1594 }
1595 else
1596 {
1597 RiseMath::Vec3Normalize(&result, &result);
1599 const float directto = -RiseMath::Vec3Dot(&result, &lookvec); // so that direct to is +1 and acos(1) is 0, acos(0) is 90, acos(-1) is 180
1600 //if (t == scanslot[gameclass->bus->targetC])
1601 // gameclass->bus->DebugFloat8 = directto;
1602
1603 if (directto > 0.0f) // in front of our view
1604 {
1605 // if their bound is .349 they take up .349/1km dist radians or .349 radians
1606 // if it is 0 degrees, dot is 1, acos is 0
1607 // if it is 57.5 degrees, dot is XX, acos is 0.5373
1608 if (cameraOrdinal > 0 || (acosf(directto) - atan(playerships[t].bound / playerships[t].distance)) < f_compareFOV)
1609 playerships[t].drawflag = true;
1610 else
1611 playerships[t].drawflag = false;
1612 }
1613 else
1614 playerships[t].drawflag = false;
1615 }
1616
1617 // The opaque cloud deck separates upper and lower vehicle visibility.
1618 // Only cull rendering; continue telemetry, physics, and orientation updates.
1620 playerships[t].drawflag=false;
1621
1622 // Nicely interpolate orientation to where they SHOULD be over 2 seconds
1623 if (!Telemetry::gSnapshotSystem.HasVehicleSamples(t) &&
1624 playerships[t].reference != REF_INANOTHER)
1625 {
1626 RiseMath::Quaternion crossorient = playerships[t].orientiter * fElapsedTime;
1627 if (RiseMath::QuaternionLength(&crossorient) > RiseMath::QuaternionLength(&playerships[t].orientleft))
1628 crossorient = playerships[t].orientleft;
1629 playerships[t].orientleft -= crossorient;
1630 playerships[t].orientation += crossorient;
1631
1632 RiseMath::QuaternionRotationYawPitchRoll(&quaternionTemp, playerships[t].yawRadPerSec * fElapsedTime, playerships[t].pitch * fElapsedTime, playerships[t].rollRadPerSec * fElapsedTime);
1633 RiseMath::QuaternionMultiply(&playerships[t].orientation, &playerships[t].orientation, &quaternionTemp);
1634 RiseMath::QuaternionNormalize(&playerships[t].orientation, &playerships[t].orientation);
1635 }
1636 }
1637 else if (playerships[0].reference != REF_BUILDING && playerships[0].reference != REF_WINDOWLESS) // our ship not in hangar
1638 {
1641 }
1642 else if (playerships[0].reference == REF_WINDOWLESS && gameclass->GUI->player[ourcockpit.ourplyrC].bldg == 2) // hangar
1643 {
1644 playerships[0].drawflag = true;
1645 }
1646 else
1647 {
1648 playerships[0].drawflag = false;
1649 }
1650
1651 /* // Test for inertial rotation match
1652 location=-playerships[t].position;
1653 float radii=RiseMath::Vec3Length( &location )/radiusC; // Radii from CM, could be stolen from earlier
1654 RiseMath::Vec3Cross( &cross, &location, &playerships[t].velocity ); // Find perpendicular vector
1655 RiseMath::MatrixRotationAxis( &dor, &cross, RiseMath::Vec3Length( &playerships[t].velocity )/(radiusC*radii)*fElapsedTime );
1656 RiseMath::MatrixMultiply( &matrixTempRotation, &dor, &matrixTempRotation );
1657 // End inertial rotation
1658 */
1659
1660 RiseMath::MatrixRotationQuaternion(&playerships[t].matrixInvOrientation, &playerships[t].orientation);
1661 RiseMath::MatrixInverse(&playerships[t].matrixInvOrientation, nullptr, &playerships[t].matrixInvOrientation);
1662 RiseMath::MatrixMultiply(&playerships[t].dor, &playerships[t].matrixBase, &playerships[t].matrixInvOrientation);
1663
1664 RiseMath::MatrixTranslation(&matrixTemp, static_cast<float>(playerships[0].precisionx - playerships[t].precisionx),
1665 static_cast<float>(playerships[0].precisiony - playerships[t].precisiony),
1666 static_cast<float>(playerships[0].precisionz - playerships[t].precisionz));
1667 RiseMath::MatrixMultiply(&playerships[t].matrixExterior, &playerships[t].dor, &matrixTemp);
1669
1670 // cloaking - not us or our parent ship or a ship inside us
1671 if (t != 0 && (playerships[0].reference != REF_INANOTHER || t != playerships[0].inarray) && (playerships[t].reference != REF_INANOTHER || playerships[t].inarray != 0))
1672 {
1674 if (!g_bAboveClouds)
1675 {
1676 const char cloudcube = CalculateCube(playerships[t].position);
1677 VECTOR2SHORT cloudtcp = CalculateCGC(playerships[t].position, cloudcube);
1678 cloudtcp.u = (ptrGrid->tcp.u - cloudtcp.u) + 31;
1679 cloudtcp.v = (ptrGrid->tcp.v - cloudtcp.v) + 31;
1680 if (cloudtcp.u >= 0 && cloudtcp.u <= 62 && cloudtcp.v >= 0 && cloudtcp.v <= 62) // within visible grid
1681 {
1682 const float shipBCL = ptrWeather->GetCloudCeilingMslKm() - playerships[t].mslKm;
1683
1684 playerships[t].emissive = gridarray[cloudtcp.u][cloudtcp.v].emissive;
1685
1686 if (shipBCL < 0.0f)
1687 playerships[t].cloaking = 0.0f;
1688 else if (shipBCL <= 0.075f)
1689 playerships[t].cloaking = shipBCL / 0.075f;
1690 else
1691 playerships[t].cloaking = 1.0f;
1692 }
1693 else
1694 {
1695 playerships[t].cloaking = 1.0f;
1696 }
1697
1698 if (playerships[t].mslKm < cloudTopsMslC && playerships[t].logolight && playerships[t].online)
1700 }
1701 else
1702 {
1703 const float shipACL = playerships[t].mslKm - cloudTopsMslC; // so 10.1 vs 10.0 ... that is .1
1704 if (shipACL < 0.0f)
1705 playerships[t].cloaking = 0.0f;
1706 else if (shipACL <= 0.150f)
1707 playerships[t].cloaking = shipACL / 0.150f;
1708 else
1709 playerships[t].cloaking = 1.0f;
1710 }
1711 }
1712 else
1713 {
1714 playerships[t].cloaking = 1.0f;
1715 if (playerships[0].reference == REF_INANOTHER && t == playerships[0].inarray)
1716 {
1717 onlinePlayersInVicinity++; // count our parent
1718 }
1719 }
1720 }
1721 else
1722 {
1723 playerships[t].drawflag = false;
1724 playerships[t].distance = -1.0f; // to keep TCAS from going off when they are added
1725 }
1726
1727 if ((fTime - playerships[t].timer) > playerships[t].speed)
1728 {
1729 playerships[t].compare >>= 1;
1730 if (playerships[t].compare == 0)
1732 playerships[t].timer = static_cast<float>(fTime);
1733 }
1734
1735 // Advance once per vehicle, including our own cockpit/exterior pair.
1736 // OFF completes the current sweep; only our vehicle uses local cockpit power.
1737 playerships[t].wipers.Update(fElapsedTime, playerships[t].rainProtectionEnabled,
1738 playerships[t].active && !playerships[t].isSimulator && (t != 0 || (!dead && ourcockpit.power > .5f)));
1739
1740 for (s = 0; s < playerships[t].components; s++)
1741 {
1743 //sprintf_s(msg, sizeof msg, "CMPT %i %i %i %i", t, playerships[t].type, s, playerships[t].componentarray[s].type);
1744 //logger->AddToCallStack(msg);
1745
1746 // Apply cargo-interior visibility after all doors have been animated.
1749
1750 if (!playerships[t].componentarray[s].visible)
1751 continue;
1752
1753 // Start by rotating to the correct orientation
1754 RiseMath::MatrixRotationYawPitchRoll(&playerships[t].componentarray[s].matWorld, playerships[t].componentarray[s].nominalypr.x, playerships[t].componentarray[s].nominalypr.y, playerships[t].componentarray[s].nominalypr.z);
1755
1756 // Set the wiper pose before applying the authored hinge transform.
1757 if (playerships[t].componentarray[s].type == 47)
1758 playerships[t].componentarray[s].extended = .5f - .5f * cosf(playerships[t].wipers.phase * RiseMath::Pi * 2.f);
1759
1760 // Animated rotations...
1761 RiseMath::MatrixTranslation(&matrixTemp, -playerships[t].componentarray[s].hingeCG.x, -playerships[t].componentarray[s].hingeCG.y, -playerships[t].componentarray[s].hingeCG.z);
1763 RiseMath::MatrixRotationAxis(&matrixTemp, &playerships[t].componentarray[s].hingeaxis, playerships[t].componentarray[s].extended * playerships[t].componentarray[s].hingeextent);
1765
1766 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
1767 switch (playerships[t].componentarray[s].type)
1768 {
1769 case 1: // Main gear
1770 case 2: // Nose gear
1771 case 6: // Main wheel
1772 case 9: // Nose wheel
1773 {
1774 if (playerships[t].geardown)
1775 {
1776 if (playerships[t].componentarray[s].extended < 1.0f) // not yet fully down
1778 if (playerships[t].componentarray[s].extended > 1.0f)
1779 {
1780 if (t == 0 && !ourcockpit.sentgearvoice &&
1781 (ourcockpit.vdat.leftStrut == -1 || ourcockpit.vdat.leftStrut >= 64) &&
1784 {
1785 Command command;
1786 command.name = "AuralGearDown"; // down and locked
1787 command.delay = 2.0f;
1788 gameclass->bus->commandStream.emplace_back(command);
1790 }
1791 playerships[t].componentarray[s].extended = 1.0f;
1792 }
1793 }
1794 else
1795 {
1796 if (playerships[t].componentarray[s].extended > 0.0f) // not yet fully up
1798 if (playerships[t].componentarray[s].extended < 0.0f)
1799 playerships[t].componentarray[s].extended = 0.0f;
1800 }
1801 if (t == 0)
1802 {
1806 }
1807
1808 // first spin the tires before we change the axis
1809 if (playerships[t].reference != REF_INANOTHER && (
1810 playerships[t].componentarray[s].type == 6 || // main wheel
1811 playerships[t].componentarray[s].type == 9)) // nose wheel
1812 {
1814 RiseMath::MatrixRotationX(&matrixTemp, -playerships[t].tirePositionRad);
1816 RiseMath::MatrixInverse(&matrixTemp, nullptr, &playerships[t].matrixBase);
1818 }
1819
1820 // now rotate the gear and wheel on the nose
1821 if (playerships[t].componentarray[s].type == 2 || // nose gear
1822 playerships[t].componentarray[s].type == 9) // nose wheel
1823 {
1824 RiseMath::MatrixRotationZ(&matrixTemp, playerships[t].steerdeflect * playerships[t].steerLimitRadian);
1825 RiseMath::MatrixInverse(&matrixTemp, nullptr, &matrixTemp);
1827 }
1828 }
1829 break;
1830 case 16: // flaps (TE)
1831 case 68: // flaps (LE)
1832 {
1833 if (playerships[t].componentarray[s].extended < playerships[t].flapdown)
1834 {
1836 if (playerships[t].componentarray[s].extended > playerships[t].flapdown)
1838 }
1839 else if (playerships[t].componentarray[s].extended > playerships[t].flapdown)
1840 {
1842 if (playerships[t].componentarray[s].extended < playerships[t].flapdown)
1844 }
1845
1846 if (t == 0)
1847 {
1851 }
1852 }
1853 break;
1854 case 30: // Bay doors
1855 {
1856 if (playerships[t].baydoor) // opening
1857 {
1858 if (playerships[t].componentarray[s].extended < 1.0f) // not yet fully down
1860 if (playerships[t].componentarray[s].extended > 1.0f)
1861 playerships[t].componentarray[s].extended = 1.0f;
1862 }
1863 else // closing
1864 {
1865 if (playerships[t].componentarray[s].extended > 0.0f) // not yet fully up
1867 if (playerships[t].componentarray[s].extended < 0.0f)
1868 playerships[t].componentarray[s].extended = 0.0f;
1869 }
1870 }
1871 break;
1872 case 10: // Ailerons Left
1873 case 11: // Ailerons Right
1874 {
1875 f_temp = -playerships[t].rolldeflect;
1876 f_temp -= playerships[t].componentarray[s].extended; // difference
1877 playerships[t].componentarray[s].extended += f_temp * fElapsedTime;
1878 }
1879 break;
1880 case 12: // Elevators
1881 {
1882 f_temp = -playerships[t].pitchdeflect;
1883 f_temp -= playerships[t].componentarray[s].extended; // difference
1884 playerships[t].componentarray[s].extended += f_temp * fElapsedTime;
1885 }
1886 break;
1887 case 13: // Rudders
1888 {
1889 f_temp = playerships[t].yawdeflect;
1890 f_temp -= playerships[t].componentarray[s].extended; // difference
1891 playerships[t].componentarray[s].extended += f_temp * fElapsedTime;
1892 }
1893 break;
1894 case 14: // Left Ruddervator
1895 {
1896 f_temp = (playerships[t].yawdeflect + playerships[t].pitchdeflect) * 0.5f;
1897 f_temp -= playerships[t].componentarray[s].extended; // difference
1898 playerships[t].componentarray[s].extended += f_temp * fElapsedTime;
1899 }
1900 break;
1901 case 15: // Right Ruddervator
1902 {
1903 f_temp = (playerships[t].yawdeflect - playerships[t].pitchdeflect) * 0.5f;
1904 f_temp -= playerships[t].componentarray[s].extended; // difference
1905 playerships[t].componentarray[s].extended += f_temp * fElapsedTime;
1906 }
1907 break;
1908 case 200: // left engine accelerate cone
1909 case 210: // right engine accelerate cone
1910 case 220: // center engine accelerate cone
1911 {
1912 // extended will be used for thrust vectoring so we have no variable to smooth so we assume tz is smoothed
1913 const float extended = RiseMath::Max(playerships[t].tz, 0);
1914
1915 // fluctuate more rapidly the flicker and rotation based on thrust
1916 // speedExtend, speedRetract, extended, extendBy are all unused
1917 // so at 10% this is .9 ... at 0 it is 0
1918 playerships[t].componentarray[s].speedRetract = RiseMath::Min(0.9f, extended * 4.5f) + extended * RandomFloat() * 0.1f;
1919
1920 playerships[t].componentarray[s].speedExtend += extended * (RandomFloat() - 0.5f) * fElapsedTime * 25.0f;
1921 RiseMath::MatrixRotationY(&matrixTemp, playerships[t].componentarray[s].speedExtend);
1923
1924 RiseMath::MatrixScaling(&matrixTemp, 1, extended, 1);
1926 }
1927 break;
1928 case 205: // left engine decelerate cone
1929 case 215: // right engine decelerate cone
1930 case 225: // center engine decelerate cone
1931 {
1932 // extended will be used for thrust vectoring so we have no variable to smooth so we assume tz is smoothed
1933 const float extended = RiseMath::Max(-playerships[t].tz, 0);
1934
1935 // fluctuate more rapidly the flicker and rotation based on thrust
1936 // speedExtend, speedRetract, extended, extendBy are all unused
1937 // so at 10% this is .9 ... at 0 it is 0
1938 playerships[t].componentarray[s].speedRetract = RiseMath::Min(0.9f, extended * 4.5f) + extended * RandomFloat() * 0.1f;
1939
1940 playerships[t].componentarray[s].speedExtend += extended * (RandomFloat() - 0.5f) * fElapsedTime * 25.0f;
1941 RiseMath::MatrixRotationY(&matrixTemp, playerships[t].componentarray[s].speedExtend);
1943
1944 RiseMath::MatrixScaling(&matrixTemp, 1, extended, 1);
1946 }
1947 break;
1948 case 69: // spoilers
1949 {
1950 if (playerships[t].componentarray[s].extended < playerships[t].spoilersUp)
1951 {
1953 if (playerships[t].componentarray[s].extended > playerships[t].spoilersUp)
1955 }
1956 else if (playerships[t].componentarray[s].extended > playerships[t].spoilersUp)
1957 {
1959 if (playerships[t].componentarray[s].extended < playerships[t].spoilersUp)
1961 }
1962
1963 //if (t == 0)
1964 //{
1965 // ourcockpit.flapExtent = playerships[t].componentarray[s].extended;
1966 // gameclass->bus->TrailingEdgeFlapsPosition = ourcockpit.flapExtent * ourcockpit.flapMaxDegrees;
1967 // gameclass->bus->LeadingEdgeFlapsPosition = ourcockpit.flapExtent * ourcockpit.flapMaxDegrees;
1968 //}
1969 }
1970 break;
1971 }
1972
1973 // Animated extensions...
1974 RiseMath::Vec3Scale(&result, &playerships[t].componentarray[s].extendby, playerships[t].componentarray[s].extended);
1975 RiseMath::Vec3Add(&result, &playerships[t].componentarray[s].nominalxyz, &result);
1976
1977 // If it is attached... move to correct location
1978 result += playerships[t].componentarray[s].hingeCG;
1979
1980 RiseMath::MatrixTranslation(&matrixTemp, result.x, result.y, result.z);
1982
1983 RiseMath::MatrixMultiply(&playerships[t].componentarray[s].matWorld, &playerships[t].componentarray[s].matWorld, &playerships[t].matrixExterior);
1984 }
1985
1987 playerships[t].componentarray, playerships[t].components,
1988 playerships[0].reference == REF_INANOTHER && t == playerships[0].inarray);
1989 }
1990
1991
1992 vehiclePoseTiming.Stop();
1993 Rendering::ProfileScope11 dockEffectsTiming("DIHV and dock effects", false);
1994 logger->AddToCallStack("Viewscreen::OnFrameMove DIHV");
1995 for (t = 1; t < MAX_SCAN; ++t)
1996 {
1997 auto& contact = playerships[t];
1998 if (!contact.active || contact.type != VehicleType::DIHV)
1999 continue;
2000 // The server supplies all position, orientation, velocity and lifecycle data.
2001 // This countdown only schedules the warp sound and texture animation.
2002 if (!contact.dihvComing && contact.dihvSequence > 0.0f)
2003 {
2004 contact.dihvSequence -= fElapsedTime;
2005 if (contact.dihvSequence <= 0.0f)
2006 contact.dihvAnimate = 63;
2007 }
2008 if (advanceframe && contact.dihvAnimate >= 0 && contact.dihvAnimate < 64)
2009 {
2010 if (contact.dihvComing)
2011 {
2012 if (contact.dihvAnimate == 0)
2014 ++contact.dihvAnimate;
2015 contact.visible = contact.dihvAnimate >= 33;
2016 }
2017 else
2018 {
2019 --contact.dihvAnimate;
2020 if (contact.dihvAnimate == 10)
2022 contact.visible = contact.dihvAnimate > 32;
2023 }
2024 }
2025 }
2026
2027
2028 AssertTelemetry("FrameMove::OnFrameMove5", 0);
2029
2030
2031
2032 logger->AddToCallStack("Viewscreen::OnFrameMove Dock Matrices");
2033 float distcompare = FLT_MAX;
2034 dockTexture = 0;
2035 for (t = 0; t < maxdockC; t++) // matrices for docks
2036 {
2037 RiseMath::MatrixIdentity(&allobjects[t].matrixWorld);
2038 RiseMath::MatrixTranslation(&matrixTemp,
2039 static_cast<float>(playerships[0].precisionx - static_cast<double>(allobjects[t].position.x)),
2040 static_cast<float>(playerships[0].precisiony - static_cast<double>(allobjects[t].position.y)),
2041 static_cast<float>(playerships[0].precisionz - static_cast<double>(allobjects[t].position.z)));
2042 RiseMath::MatrixMultiply(&allobjects[t].matrixWorld, &allobjects[t].matrixWorld, &matrixTemp);
2043
2045
2046 // Must run loop first to determine distances
2047 if (allobjects[t].distance < (allobjects[t].bound * 1000.0f)) // In visual range
2048 {
2049 if (allobjects[t].distance < distcompare)
2050 {
2051 distcompare = allobjects[t].distance;
2052 dockTexture = t + 1; // CP is 1, Easydock is 2, YSP is 3, starts as 0
2053 // DO NOT ZERO OUT SINCE WE DUMP FRAMEMOVE BIGGER THAN A SECOND
2054 }
2055 }
2056
2057#pragma region Dock Space calculation and port speed calculation
2059 {
2060 if (allobjects[t].distance < 30.0f)
2061 {
2062 if (playerships[0].reference < REF_INANOTHER)
2063 {
2064 playerships[0].reference = static_cast<char>(t) + REF_DOCKENUMCPOC;
2066 RiseMath::Vec3Subtract(&playerships[0].dockingvel, &playerships[0].velocity, &allobjects[t].velocity);
2067 logger->Log("Entered dock bubble!");
2068
2070 }
2071
2072 if (RiseMath::Vec3Length(&playerships[0].dockingvel) > 0.250f)
2073 {
2075 }
2076 }
2077 else if (allobjects[t].distance > 40.0f && playerships[0].reference == (static_cast<char>(t) + REF_DOCKENUMCPOC))
2078 {
2080 sprintf_s(msg, sizeof msg, "Left dock bubble at %.3f km!", allobjects[t].distance);
2081 logger->Log(msg);
2082 sprintf_s(msg, sizeof msg, " Dock positionX %.3f Y %.3f Z %.3f (%.3f)!", allobjects[t].position.x, allobjects[t].position.y, allobjects[t].position.z, RiseMath::Vec3Length(&allobjects[t].position));
2083 logger->Log(msg);
2084 sprintf_s(msg, sizeof msg, " Dock velocityX %.3f Y %.3f Z %.3f (%.3f)!", allobjects[t].velocity.x, allobjects[t].velocity.y, allobjects[t].velocity.z, RiseMath::Vec3Length(&allobjects[t].velocity));
2085 logger->Log(msg);
2087 }
2088 }
2089#pragma endregion
2090
2091 if ((fTime - allobjects[t].timer) > allobjects[t].speed)
2092 {
2093 allobjects[t].compare >>= 1;
2094 if (allobjects[t].compare == 0)
2095 allobjects[t].compare = maxcompareC >> 1;
2096 allobjects[t].timer = static_cast<float>(fTime);
2097 }
2098 }
2099
2100 // dock textures
2102 {
2104 //dockTextureStage = 1;
2105
2106 if (dockTexture)
2107 {
2108 int handle;
2109 switch (dockTexture)
2110 {
2111 case 1: _sopen_s(&handle, "Meshes\\cutters.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
2112 break;
2113 case 2: _sopen_s(&handle, "Meshes\\easydock.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
2114 break;
2115 case 3: _sopen_s(&handle, "Meshes\\sentry station 12.DAW", _O_RDONLY | _O_BINARY | _O_SEQUENTIAL, _SH_DENYWR, _S_IWRITE);
2116 break;
2117 default: handle = -1;
2118 }
2119 if (handle == -1)
2120 {
2121 char msg[99];
2122 char strerr[99];
2123 strerror_s(strerr, 99, errno);
2124 sprintf_s(msg, sizeof(msg), "Could not load dock (DAW file %i) number %i: %s", dockTexture, 1, strerr);
2126 }
2127
2128 char msg[99];
2129 // Vertices -----------------------------------------------------------------------------
2130 _lseek(handle, 0L, SEEK_SET);
2131 _read(handle, &polyobjects[1].vertices, 2);
2132 polyobjects[1].polygons = static_cast<short>(polyobjects[1].vertices / 3);
2133
2134 sprintf_s(msg, sizeof(msg), "Loading file (%i vertices) for polygon object number %i...", polyobjects[1].vertices, 1);
2135 logger->Log(msg);
2136
2137 if (polyobjects[1].vertices > dockvertC)
2138 {
2139 sprintf_s(msg, sizeof(msg), "Failure, out-of-bounds number of vertices %i/%i maximum", polyobjects[1].vertices, dockvertC);
2141 }
2142
2143 RiseVertexVertex* vtx;
2144
2145 // Lock the vertex buffer
2146 V(polyobjects[1].VB->Lock(0, 0, reinterpret_cast<void**>(&vtx), Rendering::LockFlags::DISCARD));
2147
2148 RiseMath::Vector3 tempnormal;
2149
2150 for (s = 0; s < polyobjects[1].vertices; s++)
2151 {
2152 _lseek(handle, 2L + s * 32L + 0L, SEEK_SET);
2153 _read(handle, &tempnormal, 12);
2154 vtx->x = tempnormal.x;
2155 vtx->y = tempnormal.y;
2156 vtx->z = tempnormal.z;
2157
2158 _lseek(handle, 2L + s * 32L + 12L, SEEK_SET);
2159 _read(handle, &tempnormal, 12);
2160 vtx->nx = tempnormal.x;
2161 vtx->ny = tempnormal.y;
2162 vtx->nz = tempnormal.z;
2163 _lseek(handle, 2L + s * 32L + 24L, SEEK_SET);
2164 _read(handle, &tempnormal.x, 4);
2165 _read(handle, &tempnormal.y, 4);
2166 vtx->tu = tempnormal.x;
2167 vtx->tv = tempnormal.y;
2168 vtx++;
2169 }
2170
2171 V(polyobjects[1].VB->Unlock());
2172
2173
2174 t = 1;
2175 short numberOfEffects;
2176 _read(handle, &numberOfEffects, 2);
2177 sprintf_s(msg, sizeof(msg), "RenderDocks loading %i light(s) for polygon object number %i...", numberOfEffects, t);
2178 logger->Log(msg);
2179 polyobjects[t].effects.clear();
2180 for (s = 0; s < numberOfEffects; s++)
2181 {
2182 s_light_effect lightEffect;
2183 _read(handle, &lightEffect.position, 12);
2184 _read(handle, &lightEffect.normal, 12);
2185 DWORD diffuse;
2186 _read(handle, &diffuse, 4);
2187 lightEffect.diffuse = diffuse;
2188 _read(handle, &lightEffect.sequencing, 4);
2189 _read(handle, &lightEffect.speed, 4); // unused
2190 _read(handle, &lightEffect.power, 4);
2191 _read(handle, &lightEffect.attachto, 2); // unused
2192 lightEffect.primitive = 0;
2193 sprintf_s(msg, sizeof(msg), "\tx%f y%f z%f nx%f ny%f nz%f %x p%f", lightEffect.position.x, lightEffect.position.y, lightEffect.position.z, lightEffect.normal.x, lightEffect.normal.y, lightEffect.normal.z, (DWORD)lightEffect.diffuse, lightEffect.power);
2194 logger->Log(msg);
2195 polyobjects[t].effects.emplace_back(lightEffect);
2196 }
2197
2198 _close(handle);
2199 }
2200
2202
2203 sprintf_s(msg, sizeof(msg), "Dock DAW/DIX library number changed to %i...", dockTexture);
2204 logger->Log(msg);
2205 }
2206
2207
2208 dockEffectsTiming.Stop();
2209 Rendering::ProfileScope11 buildingUpdateTiming("Building sort and city lights", false);
2210 // city lights
2211 logger->AddToCallStack("Viewscreen::OnFrameMove City Lights");
2212 for (t = 0; t < PlotType::PlotTypeEnum; t++)
2213 {
2214 if ((fTime - citystuff.timer[t]) > citystuff.speed[t])
2215 {
2216 citystuff.compare[t] >>= 1;
2217 if (citystuff.compare[t] == 0)
2218 citystuff.compare[t] = maxcompareC >> 1;
2219 citystuff.timer[t] = static_cast<float>(fTime);
2220 }
2221 }
2222
2223
2224 // buildings sort
2225 ptrBuildings->Sort();
2226 buildingUpdateTiming.Stop();
2227
2228
2229#pragma region Halloween 2018
2230
2231 if (!playerships[0].isSimulator && ourcockpit.vdat.holiday > 1)
2232 {
2233 // so 127 seconds in clouds or in heavy rain
2234 // we were using UniverseRelativeSpeedKms + ptrWeather->GetWindspeedKms() but isn't that just ground speed?
2235 // and why ground speed... it is the air flow over the aircraft that matters!
2236 const float speedFactor = fElapsedTime * RiseMath::Min(ptrPropulsion->ias / 0.125f, 1.0f); // 0-1
2237 // Match visible precipitation: silent through 3, full intensity at 16.
2238 const float precipitation = ptrWeather->GetPrecip();
2239 float normPrecip = precipitation <= 3.0f ? 0.0f : (precipitation - 3.0f) / 13.0f;
2240 timeToNextDecrement -= speedFactor * normPrecip; // 0-1 x 0-1
2241 timeToNextDecrement -= speedFactor * alphascreen.a * 0.2f; // 0-1 x 0.0-0.2
2242 timeToNextDecrement -= fElapsedTime * reentryDamageIntensity * 3.0f; // 0-3 // reentry
2243 if (timeToNextDecrement < 0.0f)
2244 {
2246 ourcockpit.vdatChanged = true;
2247
2248 timeToNextDecrement += 1.0f;
2249 }
2250 }
2251
2252#pragma endregion
2253
2254
2255
2256#pragma endregion Flight state update
2257
2258 Rendering::ProfileScope11 weaponUpdateTiming("Weapon update", false);
2259 ptrWeapon->Update(fElapsedTime);
2260 weaponUpdateTiming.Stop();
2261
2262
2265 RiseMath::Vec3Scale(&compassnorth, &compassnorth, ourPositionLength);
2268
2269
2270 // Resolve rain-air supply before physics so thrust and glass use the same
2271 // current-frame state, independent of rain intensity or camera visibility.
2272 // The damage vehicle ID tracks receipt of the whole VDAT, not just lighting.
2273 const bool rainAirReady = ourcockpit.landingDamageVehicleId == playerships[0].vehicleId;
2274 const bool engineAirAvailable = ourcockpit.engines > 0 && (ourcockpit.vdat.leftengine > 0
2276 || (ourcockpit.engines >= 3 && ourcockpit.vdat.clengine > 0));
2278 rainAirReady && playerships[0].active && !playerships[0].isSimulator && !dead && !hasAnimatedWipers,
2279 ourcockpit.power, engineAirAvailable);
2280
2281 Rendering::ProfileScope11 propulsionTiming("Propulsion update", false);
2282 if (!dead)
2283 {
2284 if (!gameclass->bus->FlightFreeze)
2285 ptrPropulsion->Update(fElapsedTime);
2286 else
2288 }
2289 else
2290 {
2291 logger->AddToCallStack("Viewscreen::OnFrameMove Dead");
2292
2293 // if at a dock then we set it zero in relation to the dock
2294 if (playerships[0].reference >= REF_DOCKENUMCPOC)
2296 else
2297 {
2298 RiseMath::Vector3 gthrust;
2299 float radius;
2301 }
2302
2303 if (playerships[0].reference < REF_INANOTHER)
2304 {
2305 // below clouds we just put them safely on the ground
2306 if (!g_bAboveClouds)
2308 else if (playerships[0].mslKm > 5000.0f)
2309 {
2310 // above 5000km we put them at 5000km
2312 playerships[0].position *= radiusC + 5000.0f;
2317 logger->Log("Repositioned player at 5,000 km MSL because they were above 5,000 km MSL!", Logger::Level::Warn);
2318 }
2319 // Bill experienced multiple decompression deaths
2321 {
2322 playerships[0].velocity = playerships[0].barycentric; // arrest climb
2324 logger->Log("Adjusted maxPressureDiffMb because they were above pressureDiffMb!", Logger::Level::Warn);
2325 }
2326 }
2327
2330 for (int i = 0; i < MAX_ENGINES; i++)
2331 {
2332 if (playerships[0].groundvehicle)
2333 gameclass->bus->EngineThrustLever[i] = 0.1f;
2334 else
2335 gameclass->bus->EngineThrustLever[i] = 0.0f;
2336 gameclass->bus->ThrustReverserCommand[i] = false;
2337 }
2338
2339 gameclass->ChangeGear(-2); // on death we switch to park
2340
2342 // ReSharper disable once CppExpressionWithoutSideEffects
2344 // ReSharper disable once CppExpressionWithoutSideEffects
2346 }
2347 propulsionTiming.Stop();
2348
2349
2350
2351
2352
2353 Rendering::ProfileScope11 cameraTiming("Camera and environmental effects", false);
2354 logger->AddToCallStack("Viewscreen::OnFrameMove Reentry Effects");
2355 // Simulator entry and diagnostic commands must not retain a preview for exit.
2356 ptrPropulsion->tat_mod_qz_x = ptrPropulsion->tatCelsius * ptrPropulsion->qz_lbsPerSqFt; // tat runs up to 13000 in his video ... qz is 32 ... that is 416k is limit normally
2359 if (ptrPropulsion->tat_mod_qz_x > 140000.0f)
2360 {
2361 reentryDamageIntensity = (ptrPropulsion->tat_mod_qz_x - 140000.0f) / 484000.0f; // 0-1 ... based on 1.5*normal limit of 416-140
2362 if (reentryDamageIntensity > 1.0f)
2364 }
2365 else
2366 {
2368 }
2369
2370 if (ptrWeather->gammascreenOverride != -1.0f)
2372
2373 // Shared world-space entry glow. Automatic radio/damage calibration is independent.
2374 const bool envelopeAllowed = playerships[0].active && !playerships[0].isSimulator &&
2377 const auto airflow = ptrPropulsion->AirflowBodyKms();
2380 reentryState.Update(envelope.strength, fElapsedTime, envelopeAllowed, playerships[0].vehicleId);
2381 reentryWindward = {};
2382 if (envelopeAllowed && reentryState.strength > 0.f)
2383 {
2384 // World rendering uses -position. Airflow TO in physical coordinates is
2385 // therefore the windward direction in rendered coordinates (no extra negation).
2386 RiseMath::Matrix bodyToWorld, orientation;
2387 RiseMath::MatrixRotationQuaternion(&orientation, &playerships[0].orientation);
2388 RiseMath::MatrixInverse(&bodyToWorld, nullptr, &orientation);
2389 RiseMath::Vec3TransformNormal(&reentryWindward, &envelope.windwardBody, &bodyToWorld);
2390 }
2391
2392 // Set up the Rendering::TransformSlot::VIEW based on the rotation and location of our ship ------------------
2393
2394 const bool useParentExternalCamera = camera->outside &&
2397 if (useParentExternalCamera)
2398 {
2399 const s_network_objects& parentVehicle = playerships[playerships[0].inarray];
2401
2402 // World objects are positioned relative to the child. Translate back to the
2403 // parent's origin before applying the parent's camera mount.
2404 const RiseMath::Vector3 cameraFromChild = camera->position - playerships[0].dockoffset;
2405 RiseMath::MatrixTranslation(&matrixTemp, cameraFromChild.x, cameraFromChild.y, cameraFromChild.z);
2407 }
2408 else
2409 {
2411 if (!camera->outside)
2412 {
2415 }
2416 else
2417 {
2420 }
2421 }
2422
2423
2424
2425
2426
2428 {
2430 {
2432 targetLeftright -= static_cast<float>(old41 - gameclass->GUI->ptCursor.x) * 0.00125f * g_fFOV;
2433 else
2434 targetLeftright += static_cast<float>(old41 - gameclass->GUI->ptCursor.x) * 0.00125f * g_fFOV;
2438 }
2439 }
2442 {
2444 {
2446 targetUpdown += static_cast<float>(old42 - gameclass->GUI->ptCursor.y) * 0.00125f * g_fFOV;
2447 else
2448 targetUpdown -= static_cast<float>(old42 - gameclass->GUI->ptCursor.y) * 0.00125f * g_fFOV;
2452 }
2453 }
2455
2456 // need to identify per quadrant
2457 float mag = 1.0f;
2458 if (targetLeftright > 0.0f && targetUpdown > 0.0f) // up and right
2459 mag = sqrtf(powf(targetUpdown / camera->uplimit, 2.0f) + powf(targetLeftright / camera->rightlimit, 2.0f)); // avg
2460 else if (targetLeftright > 0.0f && targetUpdown < 0.0f) // down and right
2461 mag = sqrtf(powf(targetUpdown / camera->downlimit, 2.0f) + powf(targetLeftright / camera->rightlimit, 2.0f)); // avg
2462 else if (targetLeftright < 0.0f && targetUpdown < 0.0f) // down and left
2463 mag = sqrtf(powf(targetUpdown / camera->downlimit, 2.0f) + powf(targetLeftright / camera->leftlimit, 2.0f)); // avg
2464 else if (targetLeftright < 0.0f && targetUpdown>0.0f) // up and left
2465 mag = sqrtf(powf(targetUpdown / camera->uplimit, 2.0f) + powf(targetLeftright / camera->leftlimit, 2.0f)); // avg
2466 if (mag > 1.0f)
2467 {
2468 targetUpdown /= mag;
2469 targetLeftright /= mag;
2470 }
2471
2472 mag = 1.0f;
2473 if (targetLeftright > 0.0f && rolltilt > 0.0f) // up and right
2474 mag = sqrtf(powf(rolltilt / camera->tiltlimitR, 2.0f) + powf(targetLeftright / camera->rightlimit, 2.0f)); // avg
2475 else if (targetLeftright > 0.0f && rolltilt < 0.0f) // down and right
2476 mag = sqrtf(powf(rolltilt / camera->tiltlimitL, 2.0f) + powf(targetLeftright / camera->rightlimit, 2.0f)); // avg
2477 else if (targetLeftright < 0.0f && rolltilt < 0.0f) // down and left
2478 mag = sqrtf(powf(rolltilt / camera->tiltlimitL, 2.0f) + powf(targetLeftright / camera->leftlimit, 2.0f)); // avg
2479 else if (targetLeftright < 0.0f && rolltilt>0.0f) // up and left
2480 mag = sqrtf(powf(rolltilt / camera->tiltlimitR, 2.0f) + powf(targetLeftright / camera->leftlimit, 2.0f)); // avg
2481 if (mag > 1.0f)
2482 {
2483 rolltilt /= mag;
2484 targetLeftright /= mag;
2485 }
2486
2487
2488 camera->currentPan += Clamp((targetLeftright - camera->currentPan) * fElapsedTime * 8.0f, -0.1f, 0.1f);
2489 camera->currentTilt += Clamp((targetUpdown - camera->currentTilt) * fElapsedTime * 8.0f, -0.1f, 0.1f);
2490 camera->currentZoom += Clamp((targetZoom - camera->currentZoom) * fElapsedTime * 8.0f, -0.1f, 0.1f);
2491
2492
2493#pragma region Acceleration Effects
2494 // Capture CG force before the camera-position rotational terms. The loose
2495 // can adds Euler/centrifugal/Coriolis acceleration at its own moving position.
2496 const RiseMath::Vector3 cockpitOriginSpecificImpulse = sumofforces;
2497 // Rotational effects
2498 result = centerC;
2499 result.z -= cockpitCamera->position.z * powf(playerships[0].yawRadPerSec, 2.0f) * fElapsedTime;
2500 result.z -= cockpitCamera->position.z * powf(playerships[0].pitch, 2.0f) * fElapsedTime;
2501 result.x += cockpitCamera->position.x * powf(playerships[0].rollRadPerSec, 2.0f) * fElapsedTime;
2502 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f centripetal", result.x * oneOvergForceKmssC / fElapsedTime, result.y * oneOvergForceKmssC / fElapsedTime, result.z * oneOvergForceKmssC / fElapsedTime);
2503 sofTracking.emplace_back(msg);
2504 // verified above fElapsedTime
2505 sumofforces += result; // centripetal
2506
2507 result = centerC;
2508 // force into our seat or out of our seat as we increase or decrease pitch for example (or roll)
2511 // throw us left or right as we yaw
2513 sprintf_s(msg, sizeof msg, "X%7.3f Y%7.3f Z%7.3f rotRateDelta", result.x * oneOvergForceKmssC / fElapsedTime, result.y * oneOvergForceKmssC / fElapsedTime, result.z * oneOvergForceKmssC / fElapsedTime);
2514 sofTracking.emplace_back(msg);
2515 // verified "snapshot" used to derive "result" means in a frame already adjusted for elapsedTime
2516 sumofforces += result; // rotRateDelta
2517
2518
2519
2520 // So these are the final sumofforces ... we now check the vehicle because in the simulator we would base damage off of the actual forces
2521 sumofforces *= oneOvergForceKmssC / fElapsedTime; // now in G, before that it was km/s/s ...
2522 if (playerships[0].groundvehicle)
2523 {
2527 }
2528 else
2529 suspensionHeaveG = 0.0f;
2530 cockpitSpecificForceMss = fElapsedTime > 0.0f
2531 ? cockpitOriginSpecificImpulse * (1000.0f / fElapsedTime) : centerC;
2532 cockpitSpecificForceMss.y += suspensionHeaveG * 9.80665f; // G unit conversion, not Vieneo gravity.
2533
2535 {
2537 char diagnostic[1024];
2538 sprintf_s(diagnostic, sizeof(diagnostic),
2539 "FORCE #%u frame=%i dt=%.5f vehicleG=(%+.3f,%+.3f,%+.3f) springHeave=%+.3fG "
2540 "suspensionAttitude=(pitch=%+.2f,roll=%+.2f)deg "
2541 "wheelCompression=(%.1f,%.1f,%.1f,%.1f)mm wheelVelocity=(%.3f,%.3f,%.3f,%.3f)mps "
2542 "hp=%u injuryThreshold=(5,5-from-1,10)",
2548 suspensionWheels[FrontLeft].compressionKm * 1000000.0f,
2549 suspensionWheels[FrontRight].compressionKm * 1000000.0f,
2550 suspensionWheels[RearLeft].compressionKm * 1000000.0f,
2551 suspensionWheels[RearRight].compressionKm * 1000000.0f,
2552 suspensionWheels[FrontLeft].velocityKms * 1000.0f,
2553 suspensionWheels[FrontRight].velocityKms * 1000.0f,
2554 suspensionWheels[RearLeft].velocityKms * 1000.0f,
2555 suspensionWheels[RearRight].velocityKms * 1000.0f,
2556 static_cast<unsigned int>(ourcockpit.hitpoints));
2557 LogCurbDiagnostic(diagnostic);
2558 }
2559
2560
2561 //sprintf_s(msg, sizeof msg, "forces x%f y%f z%f", sumofforces.x, sumofforces.y, sumofforces.z);
2562 //_write(logfile, msg, strlen(msg));
2563
2565
2566 // check accelerations for death limits exceeded
2567 if (advanceframe && !dead && playerships[0].reference != REF_BUILDING && playerships[0].reference != REF_WINDOWLESS && !deathinhibit)
2568 {
2569 if (rand() < 2730 && ourcockpit.vdat.leftwing > 0) // one 12th the time or 2 times per second
2570 {
2571 // 4.4 and -1.8 with 1G bias
2573 // upside down this is -1.1, minus 1 is -2.1
2574 if (fabsf(sumofforces.y - 1.0f) > f_temp)
2575 {
2576 f_temp = fabsf(sumofforces.y - 1.0f) / f_temp - 1.0f; // 0.0f to 0.5f is ultimate limit
2577 char damage;
2578 if (f_temp > 0.5f)
2579 damage = 127; // failure
2580 else
2581 damage = static_cast<char>(f_temp / 0.03225806452f); // takes about a minute at 3.2G, 8 sec at 4.65
2582
2583 if (damage > 64 || damage > ourcockpit.vdat.leftwing)
2584 gameclass->sound->PlayEx(SOUND_ODEATH2, false, 1, 1, -1);
2585
2586 if (damage > ourcockpit.vdat.leftwing)
2588 else
2589 ourcockpit.vdat.leftwing -= damage;
2590 ourcockpit.vdatChanged = true;
2591 }
2592 }
2593 if (rand() < 2730 && ourcockpit.vdat.rightwing > 0) // one 12th the time or 2 times per second
2594 {
2595 // 4.4 and -1.8 with 1G bias
2597 if (fabsf(sumofforces.y - 1.0f) > f_temp)
2598 {
2599 f_temp = fabsf(sumofforces.y - 1.0f) / f_temp - 1.0f; // 0.0f to 0.5f is ultimate limit
2600 char damage;
2601 if (f_temp > 0.5f)
2602 damage = 127; // failure
2603 else
2604 damage = static_cast<char>(f_temp / 0.03225806452f); // takes about a minute at 3.2G
2605
2606 if (damage > 64 || damage > ourcockpit.vdat.rightwing)
2607 gameclass->sound->PlayEx(SOUND_ODEATH2, false, 1, 1, 1);
2608
2609 if (damage > ourcockpit.vdat.rightwing)
2611 else
2612 ourcockpit.vdat.rightwing -= damage;
2613 ourcockpit.vdatChanged = true;
2614 }
2615 }
2616
2617
2620 }
2621
2622 UpdateCrashDamage(cockpitOriginSpecificImpulse * (oneOvergForceKmssC / fElapsedTime), fElapsedTime);
2623
2624
2625#if defined(SOFTRACKING) && defined(_DEBUG)
2626 if (RiseMath::Vec3Length(&sumofforces) > 1.2f)
2628#endif
2629
2630
2631 // now if we are applying stuff to the character in the simulator it should be done with an amended value
2632 RiseMath::Vector3 charSumOfForces = sumofforces;
2633 if (playerships[0].isSimulator && !deathinhibit)
2634 {
2635 charSumOfForces.x = Clamp(charSumOfForces.x, -0.7f, 0.7f);
2636 charSumOfForces.y = Clamp(charSumOfForces.x, -0.7f, 0.7f);
2637 charSumOfForces.z = Clamp(charSumOfForces.x, -0.7f, 0.7f);
2638
2639 if (ourcockpit.vdat.leftwing == 0 || ourcockpit.vdat.rightwing == 0 ||
2641 {
2642 deathinhibit = FLT_MAX;
2644 }
2646 {
2647 deathinhibit = FLT_MAX;
2649 }
2650 }
2651
2652
2653 // if it is getting heavy make him grunt
2655 if (!dead && !deathinhibit &&
2656 playerships[0].reference != REF_BUILDING && playerships[0].reference != REF_WINDOWLESS)
2657 {
2658 if (oldsumofforces.x < charSumOfForces.x)
2659 oldsumofforces.x += 0.05f * fElapsedTime;
2660 else if (oldsumofforces.x > charSumOfForces.x)
2661 oldsumofforces.x -= 0.05f * fElapsedTime;
2662 if (oldsumofforces.y < charSumOfForces.y)
2663 oldsumofforces.y += 0.05f * fElapsedTime;
2664 else if (oldsumofforces.x > charSumOfForces.y)
2665 oldsumofforces.y -= 0.05f * fElapsedTime;
2666 if (oldsumofforces.z < charSumOfForces.z)
2667 oldsumofforces.z += 0.05f * fElapsedTime;
2668 else if (oldsumofforces.x > charSumOfForces.z)
2669 oldsumofforces.z -= 0.05f * fElapsedTime;
2670
2671
2672 // 1-6-12 seconds to get out of g-loc
2673 // usual relaxed tolerance is 5 g's
2674 // 2 g-s more based on training for 1 week
2675 // 1 g-s more with g-suit?
2676 // 2-6 second buffer period switching from + to - G?
2677 // same for women and men
2678 // track blood pressure as part of biometer
2679 // lowers blood pressure and pulse 10-15 seconds in response to -G
2680 // raise blood pressure and pulse 10 seconds in response to +G
2681 // brain functions for 6 seconds without any blood flow then shuts down!
2682
2683 // so if you can tolerate +5G and you onset over 10 seconds you should be GTG
2684 // because your blood pressure and pulse will rise to compensate
2685
2686 // max BP systolic 370
2687 // double the pulse so if they are 60 then it becomes 120
2688 // 2.5 each means 240 BP and 120 pulse
2689
2690
2691
2692 if (fabsf(charSumOfForces.x - oldsumofforces.x) > 3.0f ||
2693 fabsf(charSumOfForces.z - oldsumofforces.z) > 6.0f ||
2694 fabsf(charSumOfForces.y - oldsumofforces.y) > 3.0f)
2695 {
2696 if (!grunt)
2697 {
2698 grunt = true;
2699 logger->Log("Pulling some G's!");
2700 // ReSharper disable once CppDefaultCaseNotHandledInSwitchStatement
2701 switch (rand() % 3)
2702 {
2703 case 0: gameclass->sound->PlayEx(SOUND_PEOPLEGRUNT1, false, camera->attenuate); break;
2704 case 1: gameclass->sound->PlayEx(SOUND_PEOPLEGRUNT2, false, camera->attenuate); break;
2705 case 2: gameclass->sound->PlayEx(SOUND_PEOPLEGRUNT3, false, camera->attenuate); break;
2706 }
2707 }
2708 }
2709 else
2710 grunt = false;
2711
2712
2713 // above this level also starts to detract hitpoints from our character
2714 if (FlightLoads::OccupantExceeded(charSumOfForces.x, charSumOfForces.y, charSumOfForces.z))
2715 {
2716 float injury = 0.0f;
2717 // affect hitpoints, impacts are considered less than 1 second
2718
2719 // into seat 6G for 5 seconds progressive blackout (30G for 1 sec)
2720 injury += powf(8.3f * (charSumOfForces.y - 1.0f) * fElapsedTime, 2.0f);
2721
2722 // leftright 5G for 14.5 seconds results in external hemorrhaging (72.5G for 1 sec)
2723 // 3.5 hp per G per sec
2724 injury += powf(3.4f * charSumOfForces.x * fElapsedTime, 2.0f);
2725
2726 // deceleration forward >60G for <1 second tears the pulmonary artery, 35G breaks a rib
2727 // 4 hp per G per sec
2728 injury += powf(4.2f * charSumOfForces.z * fElapsedTime, 2.0f);
2729
2730 // we can take 175-250G into back once but only 105-150G into bottom of seat
2731 const auto damage = static_cast<unsigned char>(floorf((injury * 2.5f)));
2733 {
2734 char diagnostic[512];
2735 sprintf_s(diagnostic, sizeof(diagnostic),
2736 "INJURY #%u characterG=(%+.3f,%+.3f,%+.3f) injury=%.5f damage=%u hpBefore=%u lethal=%i",
2737 curbDiagnosticSequence, charSumOfForces.x, charSumOfForces.y, charSumOfForces.z,
2738 injury, static_cast<unsigned int>(damage),
2739 static_cast<unsigned int>(ourcockpit.hitpoints), damage > ourcockpit.hitpoints);
2740 LogCurbDiagnostic(diagnostic);
2741 }
2742 if (damage <= ourcockpit.hitpoints)
2743 {
2744 ourcockpit.hitpoints -= damage;
2745
2746 if (!DialogBase::dialogs[D_BIOMETER]->active)
2747 {
2750 }
2751
2753
2754 if (cash && !playerships[0].isSimulator)
2756
2757 ourcockpit.vdatChanged = true;
2758 }
2759 else
2760 {
2761 // splat
2762 SClientPacket outpacket; // NOLINT
2763 outpacket.type = 15; // Death report
2764 outpacket.f_x = charSumOfForces.x;
2765 outpacket.f_y = charSumOfForces.y;
2766 if (causechain == DeathType::MidairCollision) // collision with another vehicle
2767 outpacket.f_z = static_cast<float>(causearray);
2768 else
2769 outpacket.f_z = charSumOfForces.z;
2770 if (causechain)
2771 {
2772 outpacket.f_w = static_cast<float>(causechain);
2773 deathinhibit = FLT_MAX;
2774 dead = causechain;
2775
2777 Undock();
2778 }
2779 else
2780 {
2781 outpacket.f_w = 3.0f; // must be translational related
2782 deathinhibit = FLT_MAX;
2784 }
2785
2786 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
2787
2789 gameclass->sound->GlobalAttenuate(0.5f, 1.5f, 6.0f, SOUND_EXPLODERING, 0.5f, 1.5f, 6.0f);
2790 gameclass->sound->PlayEx(SOUND_EXPLODERING, true, 0.0f);
2791
2792 sprintf_s(msg, sizeof msg, "Player perished, cause %i, forces %.1f %.1f %.1f...", dead, charSumOfForces.x, charSumOfForces.y, charSumOfForces.z);
2793 logger->Log(msg);
2794
2795 ourcockpit.hitpoints = 255;
2796
2798 }
2799 }
2800
2803
2804#pragma region Pressurization
2805
2806 if (playerships[0].reference == REF_INANOTHER && !playerships[playerships[0].inarray].baydoor)
2807 {
2808 // we get manifest2 packets to update this from the parent
2809 }
2810 else if (playerships[0].reference >= REF_DOCKENUMCPOC)
2811 {
2812 if (!playerships[0].docked)
2814 else
2816 }
2817 else
2819
2821
2822 // cargo bay is not pressurized
2823 // pax are either in PAX ARJ which ARE pressurized OR in the crew cabin
2824 // unloading passengers we assume that they have a place (in the truck, in the colony, in the city, in the dock) that
2825 // can allow them to acclimate/deconaminate/etc
2826
2827
2828 if (playerships[0].groundvehicle) // unpressurized
2829 {
2830 float absDiff = fabsf(gameclass->bus->PressureDiffMb) / 344.0f; // 5 psi is threshold for eardrum
2831 if (absDiff > 1.0f)
2833 else if (absDiff > 0.003f)
2834 gameclass->sound->PlayEx(SOUND_PRESSUREDUMP, false, absDiff);
2835 if (absDiff > 2.0f)
2836 {
2837 sprintf_s(msg, sizeof msg, "Rapid depressurization vehicle %.0f Mb ... outside %.3f Mb", gameclass->bus->CabinPressureMb, gameclass->bus->StaticAirPressureMb);
2838 logger->Log(msg);
2839
2840 // rapid decompression is 781.854
2841 gameclass->sound->GlobalAttenuate(0.5f, 1.5f, 6.0f, SOUND_EXPLODERING, 0.5f, 1.5f, 6.0f);
2842 gameclass->sound->PlayEx(SOUND_EXPLODERING, true, 0.0f);
2843 }
2846 }
2847 else // air and space
2848 {
2849 if (playerships[0].reference == REF_ONGROUND || playerships[0].docked)
2850 {
2851 const float absDiff = fabsf(gameclass->bus->PressureDiffMb) / 344.0f; // 5 psi is threshold for eardrum (103 mb)
2852 if (absDiff < 0.3f)
2853 {
2855 if (absDiff > 0.003f)
2856 gameclass->sound->PlayEx(SOUND_PRESSUREDUMP, false, absDiff);
2857 }
2858
2860
2861 // @todo technically if we have a CPAM module there are rules about "Pre-pressure mode"
2862 // takeoff abort mode
2863 // climb mode
2864 // cruise mode
2865 // descent mode is triggered with a minimum 200 fpm descent for 10 minutes
2866 }
2867 else
2868 {
2869 // we could track internally if we were on the ground and we are climbing
2870 //if (gameclass->bus->VerticalSpeedKms > 0.001f) // climbing 200fpm
2871 // gameclass->bus->TargetPressureMb = OneAtmosphereMb;
2872 //else // descdending 200fpm
2873 // so if we are climbing it needs to go to OAP but no less than 11psi
2874 // if we are descending and we have a destination then do that
2875 // if we are descending when we have radar altimetry?
2876 if (gameclass->bus->targetC < -1) // orbit
2878 // if he has a waypoint set
2879 else if (gameclass->bus->targetC == -1 && gameclass->bus->WPtargetC >= 0 && gameclass->bus->WPtargetC < static_cast<long>(gameclass->bus->waypoint.size()) && gameclass->bus->waypoint.at(gameclass->bus->WPtargetC).location.x != 0.0f)
2881 else if (!g_bAboveClouds)
2883 else
2885
2886 // this is a new idea to keep from pressurizing until we are descending!
2887 if (gameclass->bus->VerticalSpeedKms > 0.001f && // climbing 200fpm
2890 }
2891
2892 if (ourcockpit.power)
2893 {
2894 const float diff = gameclass->bus->TargetPressureMb - gameclass->bus->CabinPressureMb;
2895 if (diff < 0 || (ourcockpit.spaceCapable || gameclass->bus->StaticAirPressureMb > 25.0f))
2896 gameclass->bus->CabinPressureMb += Clamp(diff, -0.322f, 0.322f) * fElapsedTime; // 500 fpm
2897 // in space capable they have tanks for nitrogen and oxygen
2898 // when the OAP is >25mb something can intake and compress and separate and store the N and O2
2899
2900 // air vehicles don't have tanks so there is a limit to how high they can go before you start to lose pressurization
2901
2902 // @todo we can't do hypoxia effects yet ... 350 mb is the min for normal operation ... 250 mb is death cutoff
2903
2904
2905
2906 // ground vehicles don't even bother with pressurization since they can't climb/descend fast enough
2907 }
2908 }
2909
2910 // explosive decompression
2911 // so 127 and 127 is 127/127 is 1 + 0.5 is 1.5x the published number
2912 // so 0 and 127 is 0/127 is 0 is 0+0.5 is 0.5
2913 const float bias = 0.5f + static_cast<float>(RiseMath::Min(ourcockpit.vdat.hullintegrity, ourcockpit.vdat.windshield)) / 127.0f;
2915 {
2916 deathinhibit = FLT_MAX;
2918
2919 if (!playerships[0].isSimulator)
2920 {
2921 SClientPacket outpacket; // NOLINT
2922 outpacket.type = 15; // Death report
2923 outpacket.f_x = 0.0f; // NULL
2924 outpacket.f_y = 0.0f; // NULL
2925 outpacket.f_z = 0.0f; // NULL
2926 outpacket.f_w = static_cast<float>(dead);
2927 gameclass->networking->SendToServer(&outpacket, sizeof(SClientPacket), true);
2928 ourcockpit.hitpoints = 255;
2929
2931 gameclass->sound->GlobalAttenuate(0.5f, 1.5f, 6.0f, SOUND_EXPLODERING, 0.5f, 1.5f, 6.0f);
2932 gameclass->sound->PlayEx(SOUND_EXPLODERING, true, 0.0f);
2933
2934 sprintf_s(msg, sizeof msg, "Player perished, explosive decompression, OAP %.3f IAP %.3f DIF %.3f HUL %i WND %i", gameclass->bus->StaticAirPressureMb, gameclass->bus->CabinPressureMb, gameclass->bus->PressureDiffMb, ourcockpit.vdat.hullintegrity, ourcockpit.vdat.windshield);
2935 logger->Log(msg);
2936
2938 }
2939 }
2940
2941#pragma endregion
2942
2943 }
2944
2945
2946 const RiseMath::Vector3 headCounterBefore(counteri, counterj, counterk);
2947 const float headbackBefore = headback, headtiltBefore = headtilt;
2948 const bool wasHeadSettling = headAccelerationGuard.Active();
2949 const bool suppressHeadAcceleration = headAccelerationGuard.Suppress(fElapsedTime,
2951 charSumOfForces.x, charSumOfForces.y, charSumOfForces.z) || dead != DeathType::ImNotDeadYet;
2952 if (suppressHeadAcceleration)
2953 {
2954 counteri = counterj = counterk = 0.0f;
2955 headback = headtilt = 0.0f;
2956 }
2957 if (wasHeadSettling && !suppressHeadAcceleration)
2958 {
2959 char diagnostic[128];
2960 sprintf_s(diagnostic, sizeof diagnostic, "HEAD resume #%u: reposition settled; normal head effects enabled",
2962 logger->Log(diagnostic);
2963 }
2964 // Bound only the cosmetic response; collision, damage and telemetry keep
2965 // the physical forces. Huge impacts must not leave minutes of head debt.
2966 const RiseMath::Vector3 headForces = suppressHeadAcceleration ? centerC : RiseMath::Vector3(
2973 float igs = headForces.x - counteri;
2974 float jgs = headForces.y - counterj;
2975 float kgs = headForces.z - counterk;
2976
2977 counteri = HeadAcceleration::AdvanceCounter(counteri, headForces.x, fElapsedTime);
2978 counterj = HeadAcceleration::AdvanceCounter(counterj, headForces.y, fElapsedTime);
2979 counterk = HeadAcceleration::AdvanceCounter(counterk, headForces.z, fElapsedTime);
2980
2981 igs *= 0.25f; // scale to 1
2982 jgs *= 0.25f; // scale to 1
2983 kgs *= 0.25f; // scale to 1
2984
2985 // set up for 4G's based on http://msis.jsc.nasa.gov/images/section03/image106.gif
2986 igs = Clamp(igs, -4.0f, 4.0f);
2987 jgs = Clamp(jgs, -4.0f, 4.0f);
2988 kgs = Clamp(kgs, -4.0f, 4.0f);
2989
2990 // Head translation
2991 if (jgs > 0.0f)
2992 ourcockpit.position.z = 0.00003475f + Clamp(-jgs * 0.000015f + ptrFreeTrack->input.z, -0.00006f, 0.00006f) + ourcockpit.chaireye.z;
2993 else
2994 ourcockpit.position.z = 0.00003475f + Clamp(-jgs * 0.000015f + ptrFreeTrack->input.z, -0.00006f, 0.00006f) + ourcockpit.chaireye.z;
2995 if (kgs > 0.0f) // limit 0.6 travel into headrest?
2996 ourcockpit.position.y = 0.000018f + Clamp(kgs * 0.000009f + ptrFreeTrack->input.y, -0.00006f, 0.000009f + ourcockpit.chairFwdRemaining) + ourcockpit.chaireye.y;
2997 else
2998 ourcockpit.position.y = 0.000018f + Clamp(kgs * 0.000015f + ptrFreeTrack->input.y, -0.00006f, 0.000009f + ourcockpit.chairFwdRemaining) + ourcockpit.chaireye.y;
2999 if (igs > 0.0f) // side to side
3000 ourcockpit.position.x = Clamp(igs * 0.0001f + ptrFreeTrack->input.x, -0.0004f, 0.0004f) + ourcockpit.chaireye.x; // 15.75 inches?
3001 else
3002 ourcockpit.position.x = Clamp(igs * 0.0001f + ptrFreeTrack->input.x, -0.0004f, 0.0004f) + ourcockpit.chaireye.x;
3003 // ACCELERATION EFFECTS --------------------------------------------------------------------------
3004#pragma endregion
3005
3006
3007 if (fuel <= 0.0f)
3008 {
3009 fuel = 0.0f;
3010 if (ourcockpit.startcycle != 3 && ourcockpit.startcycle != 0)
3011 ourcockpit.startcycle = 3; // shutting down
3012 }
3015
3016 if (ourcockpit.power < 1.0f && ourcockpit.startcycle > 0 && ourcockpit.startcycle < 3)
3017 {
3018 ourcockpit.power += fElapsedTime * 0.1f; // 10 sec
3019 if (ourcockpit.power >= 1.0f)
3020 {
3021 ourcockpit.power = 1.0f;
3022 // turn on lights
3023 if (!playerships[0].logolight)
3024 {
3025 playerships[0].logolight = true;
3027 //gameclass->sound->Play(SOUND_COCKPITSTART);
3028 lampTest = 5.0f;
3029 }
3030
3031 // Startup initiated by player
3033 Command command;
3034 command.name = "AuralScannerSync";
3035 command.delay = 2.0f;
3036 gameclass->bus->commandStream.emplace_back(command);
3037 }
3038 }
3039 else if (ourcockpit.power >= 0.0f && (ourcockpit.startcycle == 0 || ourcockpit.startcycle == 3))
3040 {
3041 ourcockpit.power -= fElapsedTime * 0.1f; // 10 sec
3042
3043 // Kill Autoflyte (autopilot)
3044 if (ourcockpit.power < 0.75f)
3046
3047 if (ourcockpit.power <= 0.0f)
3048 {
3049 ourcockpit.power = 0.0f;
3050 // shut off lights
3051 if (playerships[0].logolight)
3052 {
3053 playerships[0].logolight = false;
3055 if (!playerships[0].isSimulator)
3058 }
3059 }
3060 }
3061
3062 if (ourcockpit.startcycle == 1) // starting
3063 {
3064 if (ourcockpit.startupextend < 1.0f) // not yet fully down
3065 ourcockpit.startupextend += fElapsedTime * 0.25f;
3066 if (ourcockpit.startupextend >= 1.0f)
3067 {
3069 ourcockpit.startcycle = 2; // running
3070 }
3071 }
3072 else if (ourcockpit.startcycle == 3) // stopping
3073 {
3074 if (ourcockpit.startupextend > 0.0f) // not yet fully down
3075 ourcockpit.startupextend -= fElapsedTime * 0.25f;
3076 if (ourcockpit.startupextend <= 0.0f)
3077 {
3079 ourcockpit.startcycle = 0; // off
3080 }
3081 }
3082
3083
3084 float targetheadback, targetheadtilt;
3085 if (kgs > 0.0f) // into headrest, limit 0.6
3086 targetheadback = kgs * camera->uplimit * 0.6f;
3087 else
3088 targetheadback = -kgs * camera->downlimit;
3089 if (igs > 0.0f) // tilt right
3090 targetheadtilt = -igs * camera->tiltlimitR * 0.5f;
3091 else
3092 targetheadtilt = igs * camera->tiltlimitL * 0.5f;
3093
3094 targetheadback = HeadAcceleration::Bound(targetheadback, HeadAcceleration::MaximumPitchRadians);
3095 targetheadtilt = HeadAcceleration::Bound(targetheadtilt, HeadAcceleration::MaximumRollRadians);
3098
3099 const ULONGLONG headDiagnosticNow = GetTickCount64();
3100 const bool headForceSpike = !HeadAcceleration::SettledForces(charSumOfForces.x, charSumOfForces.y, charSumOfForces.z);
3101 const bool headCounterFault = !HeadAcceleration::SettledForces(headCounterBefore.x, headCounterBefore.y, headCounterBefore.z) ||
3103 const bool headLeanFault = !std::isfinite(headback) || !std::isfinite(headtilt) ||
3104 !std::isfinite(headbackBefore) || !std::isfinite(headtiltBefore) ||
3105 fabsf(headbackBefore) > HeadAcceleration::MaximumPitchRadians || fabsf(headtiltBefore) > HeadAcceleration::MaximumRollRadians ||
3107 const bool headAnomalyDue = (headForceSpike || headCounterFault || headLeanFault) && headDiagnosticNow >= headAccelerationNextAnomaly;
3108 if (headAnomalyDue || (headDiagnosticNow < headAccelerationDiagnosticUntil && headDiagnosticNow >= headAccelerationNextSample))
3109 {
3110 char diagnostic[1536];
3111 sprintf_s(diagnostic, sizeof diagnostic,
3112 "HEAD sample #%u time=%.9g dt=%.9g settling=%d suppressed=%d dead=%d ref=%d outside=%d terrainReady=%d terrainPending=%d "
3113 "aglKm=%.9g deathInhibit=%.9g g=(%.9g,%.9g,%.9g) beforeCounter=(%.9g,%.9g,%.9g) counter=(%.9g,%.9g,%.9g) "
3114 "beforeLeanDeg=(%.9g,%.9g) leanDeg=(%.9g,%.9g) targetLeanDeg=(%.9g,%.9g) "
3115 "vehicleAttitudeDeg=(%.9g,%.9g) cameraPanTiltRollDeg=(%.9g,%.9g,%.9g) rotRate=(%.9g,%.9g,%.9g) rotAccel=(%.9g,%.9g,%.9g)",
3116 headAccelerationResetSequence, fTime, fElapsedTime, int(headAccelerationGuard.Active()), int(suppressHeadAcceleration),
3119 charSumOfForces.x, charSumOfForces.y, charSumOfForces.z, headCounterBefore.x, headCounterBefore.y, headCounterBefore.z,
3120 counteri, counterj, counterk, RiseMath::ToDegree(headbackBefore), RiseMath::ToDegree(headtiltBefore),
3126 logger->Log(diagnostic);
3127 headAccelerationNextSample = headDiagnosticNow + 1000;
3128 if (headAnomalyDue)
3129 {
3130 for (const auto& force : sofTracking)
3131 logger->Log((std::string("HEAD force ") + force).c_str());
3132 headAccelerationNextAnomaly = headDiagnosticNow + 5000;
3133 if (!suppressHeadAcceleration && (headForceSpike || headCounterFault || headLeanFault))
3134 {
3135 sprintf_s(diagnostic, sizeof diagnostic,
3136 "HEAD anomaly #%u dt=%.5g g=(%.5g,%.5g,%.5g) counter=(%.5g,%.5g,%.5g) leanDeg=(%.5g,%.5g)",
3137 headAccelerationResetSequence, fElapsedTime, charSumOfForces.x, charSumOfForces.y, charSumOfForces.z,
3139 const bool invalidForce = !std::isfinite(charSumOfForces.x) || !std::isfinite(charSumOfForces.y) || !std::isfinite(charSumOfForces.z);
3140 logger->Log(diagnostic, (invalidForce || headCounterFault || headLeanFault) ? Logger::Error : Logger::Warn);
3141 }
3142 }
3143 }
3144
3145
3146
3147
3148
3149 // first pass is where we are looking with mouse or VR or TrackIR
3151 RiseMath::MatrixInverse(&matrixLookAdj, nullptr, &matrixTemp);
3152
3153 if (!camera->outside)
3154 {
3155 RiseMath::Matrix accEffect;
3157 RiseMath::MatrixInverse(&accEffect, nullptr, &accEffect);
3159 }
3160
3161
3162 if (camera->currentZoom != 1.0f)
3163 {
3166 }
3167
3168
3170
3172
3173
3174
3175#pragma region lookhdg
3176 // Look heading -------------------------------------------------------------------------------------------
3177 result.x = 0.0f; result.y = 0.0f; result.z = -1.0f;
3178 RiseMath::MatrixInverse(&matrixTemp, nullptr, &matrixLook);
3179 RiseMath::Vec3TransformNormal(&lookvec, &result, &matrixTemp); // Find straight ahead vector
3181 RiseMath::Vector3 result1;
3182 RiseMath::Vec3Add(&result1, &lookvec, &playerships[0].position); // it is now a point 1km ahead
3183
3184 // snap to present altitude
3185 RiseMath::Vec3Normalize(&result1, &result1);
3186 RiseMath::Vec3Scale(&result1, &result1, ourPositionLength);
3187
3188 // our look vector snapped to the grid plane
3189 RiseMath::Vec3Subtract(&result1, &result1, &playerships[0].position);
3190 RiseMath::Vec3Normalize(&result1, &result1);
3191
3192
3193
3194 // Now this one can be compared with the vector viewnorth
3195 f_temp = RiseMath::Vec3Dot(&result1, &compassnorth);
3196 if (f_temp >= 1.0f)
3197 lookhdg = 0.0f;
3198 else if (f_temp <= -1.0f)
3199 lookhdg = 180.0f;
3200 else
3201 lookhdg = RiseMath::ToDegree(acosf(f_temp));
3202
3203 // Adjust for the 3rd and 4th quadrants
3204 RiseMath::Vec3Cross(&result1, &result1, &compassnorth);
3205 RiseMath::Vec3Add(&result1, &result1, &playerships[0].position);
3206 if (RiseMath::Vec3Length(&result1) > ourPositionLength)
3207 lookhdg = 360.0f - lookhdg;
3208
3209
3211#pragma endregion
3212
3213
3214 if (ptrGrid->dataReady)
3215 {
3216 RiseMath::Vector3 plotnorth = gridarray[31][31].position - gridarray[31][32].position;
3217 RiseMath::Vec3Normalize(&plotnorth, &plotnorth);
3218 RiseMath::Vec3Add(&plotnorth, &plotnorth, &playerships[0].position);
3219 RiseMath::Vec3Normalize(&plotnorth, &plotnorth);
3220 RiseMath::Vec3Scale(&plotnorth, &plotnorth, ourPositionLength);
3221 RiseMath::Vec3Subtract(&plotnorth, &plotnorth, &playerships[0].position);
3222 RiseMath::Vec3Normalize(&plotnorth, &plotnorth);
3223
3224 // Look heading -------------------------------------------------------------------------------------------
3225 RiseMath::Vec3Add(&result1, &lookvec, &playerships[0].position); // it is now a point 1km ahead
3226
3227 // snap to present altitude
3228 RiseMath::Vec3Normalize(&result1, &result1);
3229 RiseMath::Vec3Scale(&result1, &result1, ourPositionLength);
3230
3231 // our look vector snapped to the grid plane
3232 RiseMath::Vec3Subtract(&result1, &result1, &playerships[0].position);
3233 RiseMath::Vec3Normalize(&result1, &result1);
3234
3235 // Now this one can be compared with the vector viewnorth
3236 f_temp = RiseMath::Vec3Dot(&result1, &plotnorth);
3237 float plothdg;
3238 if (f_temp >= 1.0f)
3239 plothdg = 0.0f;
3240 else if (f_temp <= -1.0f)
3241 plothdg = 180.0f;
3242 else
3243 plothdg = RiseMath::ToDegree(acosf(f_temp));
3244
3245 // Adjust for the 3rd and 4th quadrants
3246 RiseMath::Vec3Cross(&result1, &result1, &plotnorth);
3247 RiseMath::Vec3Add(&result1, &result1, &playerships[0].position);
3248 if (RiseMath::Vec3Length(&result1) > ourPositionLength)
3249 plothdg = 360.0f - plothdg;
3250
3252
3253 gameclass->bus->DebugFloat9 = plothdg;
3254 }
3255 else
3256 {
3257 gameclass->bus->DebugFloat9 = NAN;
3258 }
3259
3260
3261
3262 RiseMath::Matrix matrixInverse;
3263 RiseMath::MatrixInverse(&matrixInverse, nullptr, &playerships[0].matrixWorld);
3264 RiseMath::MatrixMultiply(&matrixInverse, &allobjects[ourmoonC].matrixWorld, &matrixInverse);
3265 RiseMath::MatrixMultiply(&matrixInverse, &matrixInverse, &matrixLookAdj);
3266 result.x = matrixInverse._41;
3267 result.y = matrixInverse._42;
3268 result.z = matrixInverse._43;
3269 if (fabsf(result.y) > FLT_EPSILON)
3270 lookAzimuthDegrees = -RiseMath::ToDegree(atanf(result.z / sqrtf(result.y * result.y + result.x * result.x)));
3271 else
3272 lookAzimuthDegrees = 0.0f;
3273
3274
3275
3276 cameraTiming.Stop();
3277 Rendering::ProfileScope11 scannerTiming("Scanner contacts", false);
3278 // this is scanner contact list ... not VPT ... VPT is for identification ... it might show up PRONLY but it will show up unless vdat.scanner <= 0
3279 for (t = 0; t < MAX_SCAN; t++)
3280 {
3281 if (gameclass->bus->scanslot[t] != 0 &&
3285 {
3287 // if (playerships[game->scanslot[t]].type>=10 && playerships[game->scanslot[t]].type<=19 &&
3288 // game->scandist[t]>1.0f) // ARJs
3289 // {
3290 // game->scandist[t]=FLT_MAX;
3291 //if (gameclass->bus->targetC == t)
3292 //gameclass->LostScannerTarget("ARJ Filter");
3293 // playerships[scanslot[t]].isOnScanner = false;
3294 // }
3295 // else
3296 /*if (playerships[scanslot[t]].groundvehicle && !gameclass->GUI->g_bGVfilter)
3297 {
3298 scandist[t] = FLT_MAX;
3299 if (gameclass->bus->targetC == t)
3300 gameclass->LostScannerTarget("GV Filter");
3301 playerships[scanslot[t]].isOnScanner = false;
3302 }
3303 else*/
3305 {
3306 if (playerships[gameclass->bus->scanslot[t]].distance < 0.016f)
3307 {
3308 // 95 enables cracks; zero would also severely reduce pressure tolerance.
3309 if (ourcockpit.vdat.windshield > 95)
3310 {
3312 ourcockpit.vdatChanged = true; // Existing damage-control upload persists this.
3313 }
3314 gameclass->sound->GlobalAttenuate(0.0f, 2.0f, 2.0f, SOUND_HOLIDAY2019, 0.0f, 4.0f, 0.0f);
3315 gameclass->sound->PlayEx(SOUND_HOLIDAY2019, false, 1, 1, 0.4f); // right
3318 gameclass->bus->ProximityAlert = false;
3319 }
3320 else if (playerships[gameclass->bus->scanslot[t]].distance < 0.25f)
3321 {
3322 gameclass->bus->ProximityAlert = true;
3323 }
3324
3325 if (!gameclass->GUI->IsAdmin)
3326 {
3327 gameclass->bus->scandist[t] = FLT_MAX;
3329 }
3330 else
3331 {
3334 }
3335 }
3337 {
3338 gameclass->bus->scandist[t] = FLT_MAX;
3340 }
3341 else
3342 {
3345 }
3346 }
3347 else
3348 {
3349 gameclass->bus->scandist[t] = FLT_MAX;
3351 if (gameclass->bus->targetC == t)
3352 gameclass->LostScannerTarget("Framemove2");
3353 }
3354 }
3355
3356 // For Sorting @TODO move to a ContactList module?
3357 for (t = 0; t < (MAX_SCAN - 1); t++)
3358 {
3359 if (gameclass->bus->scandist[t] > gameclass->bus->scandist[t + 1])
3360 {
3361 f_temp = gameclass->bus->scandist[t + 1];
3362 const short i_temp = gameclass->bus->scanslot[t + 1];
3363 gameclass->bus->scandist[t + 1] = gameclass->bus->scandist[t];
3364 gameclass->bus->scanslot[t + 1] = gameclass->bus->scanslot[t];
3365 gameclass->bus->scandist[t] = f_temp;
3366 gameclass->bus->scanslot[t] = i_temp;
3367 if (gameclass->bus->targetC == t)
3368 gameclass->bus->targetC++;
3369 else if (gameclass->bus->targetC == (t + 1))
3370 gameclass->bus->targetC--;
3371 }
3372 }
3373
3374 // For scrolling
3375 gameclass->bus->topscroll = 0;
3376 for (t = 0; t < MAX_SCAN; t++)
3377 {
3379 gameclass->bus->topscroll = t;
3380 else
3381 break;
3382 }
3385 if (gameclass->bus->scanscroll < 0)
3386 gameclass->bus->scanscroll = 0;
3387
3388
3389
3390
3391 scannerTiming.Stop();
3392 Rendering::ProfileScope11 walkingTiming("Walking and building collision", false);
3393 AssertTelemetry("FrameMove::OnFrameMove6", 0);
3394
3395
3396 if (gameclass->GUI->player[ourcockpit.ourplyrC].frame > REF_INANOTHER) // in a building
3397 {
3398 //for (t = 0; t < MAX_ONLINEPLAYERS; t++)
3399 t = ourcockpit.ourplyrC;
3400 {
3401 //gameclass->GUI->player[t].smoothleftright += ((float)gameclass->GUI->player[t].leftright*0.014981273408239700374531835205993f - gameclass->GUI->player[t].smoothleftright)*fElapsedTime;
3402 //gameclass->GUI->player[t].smoothupdown += ((float)gameclass->GUI->player[t].updown*0.014981273408239700374531835205993f - gameclass->GUI->player[t].smoothupdown)*fElapsedTime;
3403 //gameclass->GUI->player[t].smoothrolltilt += ((float)gameclass->GUI->player[t].rolltilt*0.014981273408239700374531835205993f - gameclass->GUI->player[t].smoothrolltilt)*fElapsedTime;
3404
3406
3407 if (t == ourcockpit.ourplyrC)
3408 {
3409 if (ourcockpit.moving > 0.0f) // wanting to walk forward
3410 {
3411 footstep += fElapsedTime * 6.0f;
3412 if (footstep >= 1.0f)
3413 {
3414 footstep = 0.0f;
3415 gameclass->sound->PlayEx(SOUND_COCKPITLAND, false, 1, 1, leftfoot ? -0.25f : 0.25f, false);
3416 leftfoot = !leftfoot;
3417 }
3418 if (gameclass->GUI->player[t].ani == 1 || gameclass->GUI->player[t].ani == 2 || gameclass->GUI->player[t].ani == 10 || gameclass->GUI->player[t].ani == 12) // started walking on left, was on left
3419 {
3420 //if (ourcockpit.turnin < 0) // left turn with right foot
3421 // gameclass->GUI->player[t].queueani = 11;
3422 //else if (ourcockpit.turnin > 0) // right turn with right foot
3423 // gameclass->GUI->player[t].queueani = 13;
3424 //else
3425 gameclass->GUI->player[t].queueani = 4; // right foot
3426 }
3427 else if (gameclass->GUI->player[t].ani == 4 || gameclass->GUI->player[t].ani == 11 || gameclass->GUI->player[t].ani == 13) // was on right foot
3428 {
3429 //if (ourcockpit.turnin < 0) // left turn with left foot
3430 // gameclass->GUI->player[t].queueani = 10;
3431 //else if (ourcockpit.turnin > 0) // right turn with left foot
3432 // gameclass->GUI->player[t].queueani = 12;
3433 //else
3434 gameclass->GUI->player[t].queueani = 2; // left foot
3435 }
3436 else if (gameclass->GUI->player[t].ani == 0 || gameclass->GUI->player[t].ani == 14) // had hand on hip
3437 gameclass->GUI->player[t].queueani = 15; // put arm down
3438 else
3439 gameclass->GUI->player[t].queueani = 1; // start walking
3440 ourcockpit.impatientime = 0.0f;
3441 gameclass->GUI->player[t].hdg += 100.0f * ourcockpit.turnin * fElapsedTime;
3442 }
3443 else if (ourcockpit.turnin != 0.0f) // wanting to turn in place
3444 {
3445 if (gameclass->GUI->player[t].ani == 0 || gameclass->GUI->player[t].ani == 14)
3446 gameclass->GUI->player[t].ani = 15;
3447 else if (gameclass->GUI->player[t].ani == 7)
3448 {
3449 if (ourcockpit.turnin < 0) // left
3450 gameclass->GUI->player[t].queueani = 8;
3451 else
3452 gameclass->GUI->player[t].queueani = 9;
3453 }
3454 ourcockpit.impatientime = 0.0f;
3455 gameclass->GUI->player[t].hdg += 100.0f * ourcockpit.turnin * fElapsedTime;
3456 }
3457 else if (ourcockpit.moving <= 0) // wanting to stop
3458 {
3459 if (gameclass->GUI->player[t].ani == 7) // was ready
3460 {
3461 if (ourcockpit.impatientime > 20.0f) // standing for 20 sec
3462 {
3463 gameclass->GUI->player[t].queueani = 0; // impatiently standing
3464 }
3465 else
3466 {
3467 gameclass->GUI->player[t].queueani = 7; // still ready
3468 ourcockpit.impatientime += fElapsedTime;
3469 leftfoot = false;
3470 footstep = 0.0f;
3471 }
3472 }
3473 else if (gameclass->GUI->player[t].ani == 0 || gameclass->GUI->player[t].ani == 14)
3474 gameclass->GUI->player[t].queueani = 14;
3475 else if (gameclass->GUI->player[t].ani == 1 || gameclass->GUI->player[t].ani == 2 || gameclass->GUI->player[t].ani == 10 || gameclass->GUI->player[t].ani == 12) // walk loop or started
3476 gameclass->GUI->player[t].queueani = 3;
3477 else if (gameclass->GUI->player[t].ani == 4 || gameclass->GUI->player[t].ani == 11 || gameclass->GUI->player[t].ani == 13)
3478 gameclass->GUI->player[t].queueani = 5;
3479 else
3480 gameclass->GUI->player[t].queueani = 7;
3481 }
3482
3484 {
3485 if (ourcockpit.turnin && ourcockpit.moving > 0.0f) // forward
3486 {
3487 const float newOnFootTarget = ourcockpit.turnin * RiseMath::ToRadian(15.0f);
3488 targetLeftright += (newOnFootTarget - targetLeftright) * fElapsedTime * 2.0f;
3489 }
3490 else if (ourcockpit.moving > 0.0f) // forward
3491 {
3492 if (targetLeftright > 0)
3493 {
3494 targetLeftright -= fElapsedTime;
3495 if (targetLeftright < 0)
3496 targetLeftright = 0;
3497 }
3498 else if (targetLeftright < 0)
3499 {
3500 targetLeftright += fElapsedTime;
3501 if (targetLeftright > 0)
3502 targetLeftright = 0;
3503 }
3504 }
3505 }
3506
3507 //if (!gameclass->config.inputConfigWalkLateral.g_pJoystick)
3508 ourcockpit.turnin = 0;
3509 //if (!gameclass->config.inputConfigWalkVertical.g_pJoystick)
3510 ourcockpit.moving = 0; // 1 is walking forward by keyboard request
3511 }
3512
3513 gameclass->GUI->player[t].anitime += fElapsedTime;// *RiseMath::Max(fabsf(ourcockpit.moving), 0.2f);
3514 Sani tempani = GetAni(gameclass->GUI->player[t].anitime, gameclass->GUI->player[t].ani);
3515
3516 if (tempani.end == -353.0f || // end
3517 (gameclass->GUI->player[t].ani != gameclass->GUI->player[t].queueani && // new ani
3518 gameclass->GUI->player[t].queueani != 7 && gameclass->GUI->player[t].queueani != 14 && // not to interrupt for
3519 (gameclass->GUI->player[t].ani == 7 || gameclass->GUI->player[t].ani == 14))) // interrupt-able
3520 {
3522 gameclass->GUI->player[t].anitime = 0.0f;
3523 tempani = GetAni(gameclass->GUI->player[t].anitime, gameclass->GUI->player[t].ani);
3524 // set new start (right now we have end in .x and .y)
3525 //Sani offset = game->GetAni(10.0f, game->gameclass->GUI->player[t].ani); // where they end up
3526 gameclass->GUI->player[t].startx = static_cast<float>(gameclass->GUI->player[t].x);
3527 gameclass->GUI->player[t].starty = static_cast<float>(gameclass->GUI->player[t].y);
3528 }
3529
3530 float proposedX = gameclass->GUI->player[t].startx + cosf(gameclass->GUI->player[t].smoothhdg + RiseMath::HalfPi) * static_cast<float>(tempani.xyz.y) + sinf(gameclass->GUI->player[t].smoothhdg + RiseMath::HalfPi) * static_cast<float>(tempani.xyz.x);
3531 float proposedY = gameclass->GUI->player[t].starty - sinf(gameclass->GUI->player[t].smoothhdg + RiseMath::HalfPi) * static_cast<float>(tempani.xyz.y) - cosf(gameclass->GUI->player[t].smoothhdg + RiseMath::HalfPi) * static_cast<float>(tempani.xyz.x);
3532 if (t == ourcockpit.ourplyrC)
3533 {
3534 short roomIndex = -1;
3535
3537 {
3538 if (gameclass->GUI->player[t].bldg == 1) // bradbury apartment
3539 {
3540 RECT proposedRoom = WhichRoom(rooms, proposedX, proposedY, &roomIndex);
3541 if (RectEquality(proposedRoom, RECT()))
3542 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), proposedY, &roomIndex);
3543 if (RectEquality(proposedRoom, RECT()))
3544 proposedRoom = WhichRoom(rooms, proposedX, static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3545 if (RectEquality(proposedRoom, RECT()))
3546 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3547 if (RectEquality(proposedRoom, RECT()))
3548 {
3549 roomIndex = 7;
3550 proposedRoom = rooms.at(roomIndex);
3551 logger->Log("Had to reposition the player to the foyer (Bradbury Building)", Logger::Level::Error);
3552 }
3553
3554 if (proposedX > static_cast<float>(proposedRoom.right))
3555 proposedX = static_cast<float>(proposedRoom.right);
3556 if (proposedX < static_cast<float>(proposedRoom.left))
3557 proposedX = static_cast<float>(proposedRoom.left);
3558 if (proposedY < static_cast<float>(proposedRoom.bottom))
3559 proposedY = static_cast<float>(proposedRoom.bottom);
3560 if (proposedY > static_cast<float>(proposedRoom.top))
3561 proposedY = static_cast<float>(proposedRoom.top);
3562
3563 if (RectEquality(proposedRoom, rooms.at(0)) && proposedY == proposedRoom.top)
3565 else if (RectEquality(proposedRoom, rooms.at(3)))
3567
3568 if (RectEquality(proposedRoom, rooms.at(7)))
3569 {
3572 }
3573 else
3575 }
3576 else if (gameclass->GUI->player[t].bldg == 2) // control tower
3577 {
3578 if (proposedX > 830)
3579 proposedX = 830;
3580 else if (proposedX < -785)
3581 proposedX = -785;
3582 if (proposedY > 780)
3583 proposedY = 780;
3584 else if (proposedY < -707)
3585 proposedY = -707;
3586
3587 // over stairwell
3588 if (proposedX > -253 && proposedX<230 && proposedY>-258 && proposedY < 212)
3589 {
3590 // which edge are they closest to?
3591 const int northEdge = abs(-258 - static_cast<int>(proposedY));
3592 const int southEdge = abs(212 - static_cast<int>(proposedY));
3593 const int eastEdge = abs(-253 - static_cast<int>(proposedX));
3594 const int westEdge = abs(230 - static_cast<int>(proposedX));
3595 if (westEdge < eastEdge && westEdge < northEdge && westEdge < southEdge)
3596 proposedX = 230;
3597 else if (eastEdge < westEdge && eastEdge < northEdge && eastEdge < southEdge)
3598 proposedX = -253;
3599 else if (southEdge < northEdge && southEdge < westEdge && southEdge < eastEdge)
3600 proposedY = 212;
3601 else if (northEdge < southEdge && northEdge < westEdge && northEdge < eastEdge)
3602 proposedY = -258;
3603 }
3604 }
3605 else if (gameclass->GUI->player[t].bldg == 3) // estate
3606 {
3607 RECT proposedRoom = WhichRoom(rooms, proposedX, proposedY, &roomIndex);
3608 if (RectEquality(proposedRoom, RECT()))
3609 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), proposedY, &roomIndex);
3610 if (RectEquality(proposedRoom, RECT()))
3611 proposedRoom = WhichRoom(rooms, proposedX, static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3612 if (RectEquality(proposedRoom, RECT()))
3613 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3614 if (RectEquality(proposedRoom, RECT()))
3615 {
3616 roomIndex = 0;
3617 proposedRoom = rooms.at(roomIndex);
3618 logger->Log("Had to reposition the player to the foyer (Estate)", Logger::Level::Error);
3619 }
3620
3621 if (proposedX > static_cast<float>(proposedRoom.right))
3622 proposedX = static_cast<float>(proposedRoom.right);
3623 if (proposedX < static_cast<float>(proposedRoom.left))
3624 proposedX = static_cast<float>(proposedRoom.left);
3625 if (proposedY < static_cast<float>(proposedRoom.bottom))
3626 proposedY = static_cast<float>(proposedRoom.bottom);
3627 if (proposedY > static_cast<float>(proposedRoom.top))
3628 proposedY = static_cast<float>(proposedRoom.top);
3629 }
3630 }
3631 else if (gameclass->GUI->player[t].frame == REF_WINDOWLESS)
3632 {
3633 if (gameclass->GUI->player[t].bldg == 1) // simulator bay
3634 {
3635 RECT proposedRoom = WhichRoom(rooms, proposedX, proposedY, &roomIndex);
3636 if (RectEquality(proposedRoom, RECT()))
3637 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), proposedY, &roomIndex);
3638 if (RectEquality(proposedRoom, RECT()))
3639 proposedRoom = WhichRoom(rooms, proposedX, static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3640 if (RectEquality(proposedRoom, RECT()))
3641 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3642 if (RectEquality(proposedRoom, RECT()))
3643 {
3644 roomIndex = 0;
3645 proposedRoom = rooms.at(roomIndex);
3646 logger->Log("Had to reposition the player to the west entrance (Simulator Bay)", Logger::Level::Error);
3647 }
3648
3649 if (proposedX > static_cast<float>(proposedRoom.right))
3650 proposedX = static_cast<float>(proposedRoom.right);
3651 if (proposedX < static_cast<float>(proposedRoom.left))
3652 proposedX = static_cast<float>(proposedRoom.left);
3653 if (proposedY < static_cast<float>(proposedRoom.bottom))
3654 proposedY = static_cast<float>(proposedRoom.bottom);
3655 if (proposedY > static_cast<float>(proposedRoom.top))
3656 proposedY = static_cast<float>(proposedRoom.top);
3657 }
3658 else if (gameclass->GUI->player[t].bldg == 2) // hangar
3659 {
3660 RECT proposedRoom = WhichRoom(rooms, proposedX, proposedY, &roomIndex);
3661 if (RectEquality(proposedRoom, RECT()))
3662 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), proposedY, &roomIndex);
3663 if (RectEquality(proposedRoom, RECT()))
3664 proposedRoom = WhichRoom(rooms, proposedX, static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3665 if (RectEquality(proposedRoom, RECT()))
3666 proposedRoom = WhichRoom(rooms, static_cast<float>(gameclass->GUI->player[t].x), static_cast<float>(gameclass->GUI->player[t].y), &roomIndex);
3667 if (RectEquality(proposedRoom, RECT()))
3668 {
3669 roomIndex = 0;
3670 proposedRoom = rooms.at(roomIndex);
3671 logger->Log("Had to reposition the player to the SE end of the platform", Logger::Level::Error);
3672 }
3673
3674 if (proposedX > static_cast<float>(proposedRoom.right))
3675 proposedX = static_cast<float>(proposedRoom.right);
3676 if (proposedX < static_cast<float>(proposedRoom.left))
3677 proposedX = static_cast<float>(proposedRoom.left);
3678 if (proposedY < static_cast<float>(proposedRoom.bottom))
3679 proposedY = static_cast<float>(proposedRoom.bottom);
3680 if (proposedY > static_cast<float>(proposedRoom.top))
3681 proposedY = static_cast<float>(proposedRoom.top);
3682 }
3683 }
3684
3685 if (oldRoomIndex != roomIndex)
3686 {
3687 SClientPacket ourpacket; // NOLINT
3688 ourpacket.type = 6; // character movement
3689 ourpacket.f_x = static_cast<float>(roomIndex);
3690 ourpacket.f_y = 0.0f; // UNUSED
3691 ourpacket.f_z = 0.0f; // UNUSED
3692 ourpacket.f_w = 0.0f; // UNUSED
3693 gameclass->networking->SendToServer(&ourpacket, sizeof(SClientPacket), true);
3694 oldRoomIndex = roomIndex;
3695 }
3696
3697 ourcockpit.chaireye.x = proposedX * INTERIOR_SCALE;
3698 ourcockpit.chaireye.y = proposedY * INTERIOR_SCALE;
3699 //ourcockpit.chaireye.z = gameclass->GUI->player[t].smoothz + 236.0f*InteriorScaleC; // don't touch ... this comes from server character height
3700 }
3701
3702 gameclass->GUI->player[t].smoothx = proposedX * INTERIOR_SCALE;
3703 gameclass->GUI->player[t].smoothy = proposedY * INTERIOR_SCALE;
3704 gameclass->GUI->player[t].smoothz = tempani.xyz.z * INTERIOR_SCALE;
3705 gameclass->GUI->player[t].x = static_cast<int>(proposedX);
3706 gameclass->GUI->player[t].y = static_cast<int>(proposedY);
3709 }
3710 }
3711 else
3712 {
3713 ourcockpit.chaireye.x = 0.0f;
3716 {
3717 ourcockpit.chaireye.y += 0.00006f;
3718 ourcockpit.chaireye.z = -0.00003f;// static_cast<float>(gameclass->GUI->player[gameclass->GUI->ourplayerC].heightCm - 12) * 0.00001f; //0.0f;
3719 }
3720 else
3721 ourcockpit.chaireye.z = 0;// static_cast<float>(gameclass->GUI->player[gameclass->GUI->ourplayerC].heightCm - 12) * 0.00001f; //0.0f;
3722 }
3723
3724
3725
3726 {
3727 walkingTiming.Stop();
3728 Rendering::ProfileScope11 timing("Weather update", false);
3729 ptrWeather->FrameMove(fElapsedTime);
3730 }
3731
3732
3733#pragma region Halloween handprint trigger
3734
3735 // Evaluate after the weather update so the final countdown frame uses current light.
3736 // This is unamplified ambient luminance, including cloud transmission and sun/altitude
3737 // effects, before lightning, fireworks or NVG gain. 0.01 is an artistic darkness
3738 // cutoff on the client's lighting scale, not a physical lux or Earth-night threshold.
3739 const float handprintAmbient = ptrWeather->lightningAfterimageAmbient;
3740 const bool handprintDark = handprintAmbient >= 0.0f && handprintAmbient <= 0.01f;
3741 if (playerships[0].isSimulator)
3742 {
3743 holidayTimer = 0.0f;
3744 timeToNextDecrement = 1.0f;
3745 }
3746 else if (ourcockpit.vdat.holiday == -2 && handprintDark &&
3747 !camera->outside && camera->currentPan <= 0 &&
3749 {
3750 holidayTimer += fElapsedTime;
3751 if (holidayTimer >= 30.0f)
3752 {
3753 gameclass->sound->GlobalAttenuate(0.0f, 2.0f, 2.0f, SOUND_HOLIDAY2018, 0.0f, 4.0f, 0.0f);
3754 gameclass->sound->PlayEx(SOUND_HOLIDAY2018, false, 1, 1, 1); // right
3755
3756 ourcockpit.vdat.holiday = 127;
3757 ourcockpit.vdatChanged = true;
3758 }
3759 }
3760 else
3761 holidayTimer = 0.0f;
3762
3763#pragma endregion
3764
3765 Rendering::ProfileScope11 rainUpdateTiming("Landing lights and exterior rain update", false);
3766 UpdateLandingLights(fTimeFreezable);
3767
3768 // Weather has just sampled the same advected density field as the clouds.
3769 const float cloudRain = WindshieldRain::CloudRainFactor(
3771 // The real field supplies the transition through cloud tops and wisps.
3772 // Only legacy clouds use the fixed 5-to-10 km precipitation fade.
3773 const float rainFadeAltitude=VolumeCloudsEnabled() ? 0.f : playerships[0].mslKm;
3774 const float rainAltitude=RiseMath::Max(0.f,playerships[0].mslKm);
3775 const float exteriorRainAirDensity=SeaLevelDensityKgM3*expf(-rainAltitude/ScaleHeightC);
3776 const float rainGravity=gravityKmssC*1000.f/powf((radiusC+rainAltitude)/radiusC,2.f);
3777
3778 // Fixed GPU seeds; only four advection phases change each frame.
3780 {
3782 rain.intensity = cloudRain * WindshieldRain::PrecipitationIntensity(ptrWeather->GetRainPrecip(), rainFadeAltitude);
3784 rain.snow = ptrWeather->snowBlend;
3785 rain.airDensityKgM3 = exteriorRainAirDensity;
3786 rain.gravityMs2 = rainGravity;
3789 rain.upWorld = posnorml;
3790 rain.sunlight = sunlight.Diffuse;
3792 for (unsigned i = 0; i < activeLandingLightCount; ++i)
3793 {
3794 const auto& light = landingLights[i];
3795 rain.headlights[i].color = light.color;
3796 rain.headlights[i].position = light.origin;
3797 rain.headlights[i].direction = light.direction;
3798 rain.headlights[i].range = light.profile.rangeKm;
3799 rain.headlights[i].up = light.up;
3800 rain.headlights[i].profile = light.profile;
3801 rain.headlights[i].extinctionPerKm = light.extinctionPerKm;
3802 }
3803 // Reuse the physical orientation, which is valid even in vertical flight.
3804 exteriorRainRenderer.Update(fElapsedTime, rain, playerships[0].matrixWorld);
3805 raindrops = static_cast<short>(exteriorRainRenderer.DropCount());
3807 }
3808 // Preserve the old path when Shader Model 3/resources are unavailable.
3809 else if (m_avRainDrops)
3810 {
3811 const float exteriorRain = cloudRain * WindshieldRain::PrecipitationIntensity(
3812 ptrWeather->GetRainPrecip(), rainFadeAltitude);
3813 raindrops = static_cast<short>(WindshieldRain::ExteriorDropCount(exteriorRain, MAX_RAINDROPS));
3815
3816 if (raindrops)
3817 {
3818 result = ptrPropulsion->groundvec * fElapsedTime;
3819 result.z = -result.z;
3820
3821 // wind effect on rain
3822 result += ptrPropulsion->localWindVector * fElapsedTime;
3823
3824 // gravity
3825 const float rainFallRateKms = ExteriorRain::FallSpeedKms(ptrWeather->GetRainPrecip(),0.f,1,exteriorRainAirDensity,rainGravity);
3826 const float snowFallRateKms = (ptrWeather->GetRainPrecip() - 4.0f) / 12.0f * 0.0000165f + 0.0000055f;
3827 const float fallRateKms = Lerp(rainFallRateKms, snowFallRateKms*10.f, ptrWeather->snowBlend);
3828 result.y -= fallRateKms * fElapsedTime;
3829
3830 RiseMath::Color rainColor = Rendering::ColorARGB(0, 170, 190, 200); // fully faded tail
3831 RiseMath::Color rainColorEnd = Rendering::ColorARGB(128, 170, 190, 200); // alpha 96 ~ 38%
3832 RiseMath::Color snowColor = Rendering::ColorARGB(0, 248, 252, 255); // Faded white or cool white
3833 RiseMath::Color snowColorEnd = Rendering::ColorARGB(255, 255, 255, 255);
3834
3835 RiseMath::Color dropColor, dropColorEnd;
3836 RiseMath::ColorLerp(&dropColor, &rainColor, &snowColor, ptrWeather->snowBlend);
3837 RiseMath::ColorLerp(&dropColorEnd, &rainColorEnd, &snowColorEnd, ptrWeather->snowBlend);
3838
3839 RiseRaindropVertex* vtxs;
3840 // Lock the vertex buffer
3841 V(m_avRainDrops->Lock(0, 0, reinterpret_cast<void**>(&vtxs), Rendering::LockFlags::DISCARD));
3842 for (t = 0; t < raindrops; t++)
3843 {
3844 const float opacity = WindshieldRain::ExteriorDropOpacity(t, exteriorRain, MAX_RAINDROPS);
3845 float dist = RiseMath::Vec3Length(&rainarray[t]);
3846
3847 RiseMath::Color light;
3848 float attenuation = 1.0f / (15.0f * RiseMath::Max(dist, 0.001f));
3849 attenuation = RiseMath::Max(0.0f, RiseMath::Min(attenuation, 1.0f));
3850
3851 light = sunlight.Diffuse;
3852 RiseMath::Vector3 worldDrop;
3853 RiseMath::Vec3TransformNormal(&worldDrop, &rainarray[t], &playerships[0].matrixInvOrientation);
3854 RiseMath::Color lampLight(0, 0, 0, 0);
3855 for (unsigned i = 0; i < activeLandingLightCount; ++i)
3856 {
3857 const auto& lamp = landingLights[i];
3858 const auto delta = worldDrop - lamp.origin;
3859 lampLight += lamp.color * LandingLights::Intensity(lamp, delta);
3860 }
3861 light.r = RiseMath::Max(light.r, lampLight.r);
3862 light.g = RiseMath::Max(light.g, lampLight.g);
3863 light.b = RiseMath::Max(light.b, lampLight.b);
3864
3865 RiseMath::Color final;
3866 final.r = dropColor.r * light.r;
3867 final.g = dropColor.g * light.g;
3868 final.b = dropColor.b * light.b;
3869 final.a = dropColor.a * attenuation * opacity;
3870
3871 // enhance streak by panning
3872 RiseMath::MatrixRotationYawPitchRoll(&matrixTemp, -playerships[0].yawRadPerSec * fElapsedTime,
3873 -playerships[0].pitch * fElapsedTime,
3874 -playerships[0].rollRadPerSec * fElapsedTime);
3875 RiseMath::Vec3TransformCoord(&rainarray[t], &rainarray[t], &matrixTemp);
3876
3877 vtxs->x = rainarray[t].x - result.x * 3.0f;
3878 vtxs->y = rainarray[t].y - result.y * 3.0f;
3879 vtxs->z = rainarray[t].z - result.z * 3.0f;
3880 vtxs->diffuse = final;
3881
3882 rainarray[t] += result; // this is the streak length
3883 bool regen = false;
3884 if (rainarray[t].y > 0.025f) // above or below out of site
3885 {
3886 rainarray[t].y -= 0.05f;
3887 if (rainarray[t].y > 0.025f)
3888 rainarray[t].y = RandomFloat() * 0.05f - 0.025f;
3889 regen = true;
3890 }
3891 else if (rainarray[t].y < -0.025f) // above or below out of site
3892 {
3893 rainarray[t].y += 0.05f;
3894 if (rainarray[t].y < -0.025f)
3895 rainarray[t].y = RandomFloat() * 0.05f - 0.025f;
3896 regen = true;
3897 }
3898 if (rainarray[t].x > 0.1f) // || //half || //(-rainarray[t].z/0.2f*half))
3899 {
3900 rainarray[t].x -= 0.2f;
3901 if (rainarray[t].x > 0.1f)
3902 rainarray[t].x = RandomFloat() * 0.2f - 0.1f;
3903 regen = true;
3904 }
3905 else if (rainarray[t].x < -0.1f) // || //half || //(-rainarray[t].z/0.2f*half))
3906 {
3907 rainarray[t].x += 0.2f;
3908 if (rainarray[t].x < -0.1f)
3909 rainarray[t].x = RandomFloat() * 0.2f - 0.1f;
3910 regen = true;
3911 }
3912 if (rainarray[t].z > 0.1f) //rainarray[t].z<-0.2f || rainarray[t].z>=0.0f)
3913 {
3914 rainarray[t].z -= 0.2f;
3915 if (rainarray[t].z > 0.1f)
3916 rainarray[t].z = RandomFloat() * 0.2f - 0.1f;
3917 regen = true;
3918 }
3919 else if (rainarray[t].z < -0.1f) //rainarray[t].z<-0.2f || rainarray[t].z>=0.0f)
3920 {
3921 rainarray[t].z += 0.2f;
3922 if (rainarray[t].z < -0.1f)
3923 rainarray[t].z = RandomFloat() * 0.2f - 0.1f;
3924 regen = true;
3925 }
3926 if (regen)
3927 {
3928 vtxs->x = rainarray[t].x;
3929 vtxs->y = rainarray[t].y;
3930 vtxs->z = rainarray[t].z;
3931 }
3932 vtxs++;
3933
3934 vtxs->x = rainarray[t].x;
3935 vtxs->y = rainarray[t].y;
3936 vtxs->z = rainarray[t].z;
3937
3938 final.r = dropColorEnd.r * light.r;
3939 final.g = dropColorEnd.g * light.g;
3940 final.b = dropColorEnd.b * light.b;
3941 final.a = dropColorEnd.a * attenuation * opacity;
3942
3943 vtxs->diffuse = final;
3944 vtxs++;
3945 }
3947 }
3948 }
3949
3950 rainUpdateTiming.Stop();
3951 Rendering::ProfileScope11 cockpitUpdateTiming("Cockpit and water update", false);
3952 ptrCockpit->FrameMove(fElapsedTime);
3953 windshieldRain.SetSimulator(playerships[0].isSimulator);
3954 if (!playerships[0].isSimulator && !dead && ourcockpit.texturelib != VehicleType::EVA_SUIT)
3955 {
3956 Rendering::ProfileScope11 timing("Windshield water update", false);
3957 // Match the existing precipitation threshold; snow and sheltered interiors
3958 // do not create liquid impacts. Existing water dries after entering shelter.
3959 const bool buildingWindows = playerships[0].reference == REF_BUILDING
3961 const bool exposed = buildingWindows || (playerships[0].reference != REF_INANOTHER
3963 const float rain = cloudRain * WindshieldRain::LiquidRainIntensity(
3964 ptrWeather->GetRainPrecip(), ptrWeather->snowBlend, exposed, rainFadeAltitude);
3965 std::vector<RiseMath::Matrix> transforms(ourcockpit.components);
3966 for (int component = 0; component < ourcockpit.components; ++component)
3967 transforms[component] = WindshieldRainRenderer::ToPhysicsTransform(
3969 // Specific force already includes attitude, gravity/support, acceleration,
3970 // braking, and turning. Convert G to m/s^2 with the inertial sign.
3971 RiseMath::Vector3 rainAcceleration = -sumofforces * 9.80665f;
3973 float rainDensity = ptrPropulsion->staticDensity;
3974 if (buildingWindows)
3975 {
3976 // Buildings bypass vehicle support forces. Use local gravity and outdoor
3977 // wind/density; walking inside must not accelerate water on fixed windows.
3978 const float altitude = RiseMath::Max(0.f, playerships[0].mslKm);
3979 // Both interiors are upright: physics +Y is up, regardless of heading.
3980 rainAcceleration = RiseMath::Vector3(0.f, -gravityKmssC * 1000.f
3981 / powf((radiusC + altitude) / radiusC, 2.f), 0.f);
3982 rainWind = ptrPropulsion->localWindVector * 1000.f;
3983 rainDensity = expf(-altitude / ScaleHeightC);
3984 }
3985 // Density is 1 at Vieneo sea level (2630.397 mB), 0 in space.
3986 // Normalize to one atmosphere for the droplet wind-drag coefficient.
3987 const float rainAirDensity = Clamp(rainDensity, 0.f, 1.f)
3989 windshieldRain.Update(fElapsedTime, rain, rainAcceleration,
3990 rainWind, transforms, rainAirDensity, playerships[0].wipers.moving,
3992 }
3993 cockpitUpdateTiming.Stop();
3994
3995
3996 Rendering::ProfileScope11 instrumentUpdateTiming("Instrument update", false);
3997 ptrInstruments->FrameMove(fElapsedTime);
3998 instrumentUpdateTiming.Stop();
3999
4000
4001 lateralmod = false;
4002 verticalmod = false;
4003 yawmod = false;
4004
4005 if (pitchTrimMod)
4006 {
4007 pitchTrimTime += fElapsedTime;
4008 if (pitchTrimTime > 3.0f)
4009 gameclass->sound->PlayEx(SOUND_APTRIMCLACKER, false, 1, 1, 0, false);
4010 }
4011 else
4012 pitchTrimTime = 0.0f;
4013
4014
4015
4016 // @TODO should be moved to a ContactList module?
4017 if (gameclass->bus->WPtargetC >= 0 && gameclass->bus->WPtargetC < static_cast<long>(gameclass->bus->waypoint.size()) && gameclass->bus->waypoint.at(gameclass->bus->WPtargetC).location.x != 0.0f)
4019 else
4021 if (gameclass->bus->targetC == -1)
4023
4024
4025
4026
4027 logger->AddToCallStack("Viewscreen::OnFrameMove DONE");
4028}
4029
4030bool Viewscreen::ApplyBufferedVehicleState(int t, float fElapsedTime)
4031{
4032 if (t <= 0 || t >= MAX_SCAN ||
4034 !Telemetry::gSnapshotSystem.HasVehicleSamples(t))
4035 return false;
4036
4038 t, Telemetry::MonotonicSeconds(), static_cast<double>(fElapsedTime));
4039 if (!state.valid)
4040 return false;
4041
4042 s_network_objects& vehicle = playerships[t];
4043 vehicle.acc = RiseMath::Vector3(static_cast<float>(state.acceleration.x),
4044 static_cast<float>(state.acceleration.y), static_cast<float>(state.acceleration.z));
4045 vehicle.pitch = static_cast<float>(state.angularVelocity.x);
4046 vehicle.yawRadPerSec = static_cast<float>(state.angularVelocity.y);
4047 vehicle.rollRadPerSec = static_cast<float>(state.angularVelocity.z);
4048 vehicle.tx = static_cast<float>(state.thrust.x);
4049 vehicle.ty = static_cast<float>(state.thrust.y);
4050 vehicle.tz = static_cast<float>(state.thrust.z);
4051 vehicle.pitchdeflect = static_cast<float>(state.controlDeflection.x);
4052 vehicle.rolldeflect = static_cast<float>(state.controlDeflection.y);
4053 vehicle.yawdeflect = static_cast<float>(state.controlDeflection.z);
4054 vehicle.steerdeflect = static_cast<float>(state.steerDeflection);
4055 vehicle.orientation = RiseMath::Quaternion(static_cast<float>(state.orientation.x),
4056 static_cast<float>(state.orientation.y), static_cast<float>(state.orientation.z),
4057 static_cast<float>(state.orientation.w));
4059
4060 const RiseMath::Vector3 samplePosition(static_cast<float>(state.position.x),
4061 static_cast<float>(state.position.y), static_cast<float>(state.position.z));
4062 const RiseMath::Vector3 sampleVelocity(static_cast<float>(state.velocity.x),
4063 static_cast<float>(state.velocity.y), static_cast<float>(state.velocity.z));
4064
4065 if (vehicle.reference < REF_INANOTHER)
4066 {
4067 vehicle.position = samplePosition;
4068 vehicle.precisionx = state.position.x;
4069 vehicle.precisiony = state.position.y;
4070 vehicle.precisionz = state.position.z;
4071 vehicle.velocity = vehicle.isSimulator ? centerC : sampleVelocity;
4072 RiseMath::Vector3 gravityDirection;
4073 float radius;
4074 vehicle.barycentric = CalculateBarycentric(&vehicle.position, &gravityDirection, &radius);
4075 }
4076 else if (vehicle.reference == REF_INANOTHER)
4077 {
4078 if (vehicle.inarray >= MAX_SCAN || vehicle.inarray == t || !playerships[vehicle.inarray].active)
4079 return false;
4080 vehicle.dockoffset = samplePosition;
4081 vehicle.dockingvel = sampleVelocity;
4082 RiseMath::Matrix inverseParentOrientation;
4083 RiseMath::MatrixRotationQuaternion(&inverseParentOrientation, &playerships[vehicle.inarray].orientation);
4084 RiseMath::MatrixInverse(&inverseParentOrientation, nullptr, &inverseParentOrientation);
4085 RiseMath::Vector3 worldOffset;
4086 RiseMath::Vec3TransformNormal(&worldOffset, &vehicle.dockoffset, &inverseParentOrientation);
4087 vehicle.position = playerships[vehicle.inarray].position + worldOffset;
4088 vehicle.precisionx = playerships[vehicle.inarray].precisionx + static_cast<double>(worldOffset.x);
4089 vehicle.precisiony = playerships[vehicle.inarray].precisiony + static_cast<double>(worldOffset.y);
4090 vehicle.precisionz = playerships[vehicle.inarray].precisionz + static_cast<double>(worldOffset.z);
4091 vehicle.velocity = playerships[vehicle.inarray].velocity + vehicle.dockingvel;
4092 RiseMath::Vector3 gravityDirection;
4093 float radius;
4094 vehicle.barycentric = CalculateBarycentric(&vehicle.position, &gravityDirection, &radius);
4095 }
4096 else if (vehicle.reference >= REF_DOCKENUMCPOC &&
4098 {
4099 const int dock = vehicle.reference - REF_DOCKENUMCPOC;
4100 vehicle.dockoffset = samplePosition;
4101 vehicle.dockingvel = sampleVelocity;
4102 vehicle.position = allobjects[dock].position + vehicle.dockoffset;
4103 vehicle.precisionx = static_cast<double>(allobjects[dock].position.x) + state.position.x;
4104 vehicle.precisiony = static_cast<double>(allobjects[dock].position.y) + state.position.y;
4105 vehicle.precisionz = static_cast<double>(allobjects[dock].position.z) + state.position.z;
4106 vehicle.velocity = allobjects[dock].velocity + vehicle.dockingvel;
4107 }
4108 else if (vehicle.reference == REF_PROXIMITY && vehicle.inarray < MAX_SCAN &&
4109 playerships[vehicle.inarray].active)
4110 {
4111 vehicle.dockoffset = samplePosition;
4112 vehicle.dockingvel = sampleVelocity;
4113 vehicle.position = playerships[vehicle.inarray].position + vehicle.dockoffset;
4114 vehicle.precisionx = playerships[vehicle.inarray].precisionx + state.position.x;
4115 vehicle.precisiony = playerships[vehicle.inarray].precisiony + state.position.y;
4116 vehicle.precisionz = playerships[vehicle.inarray].precisionz + state.position.z;
4117 vehicle.velocity = playerships[vehicle.inarray].velocity + vehicle.dockingvel;
4118 }
4119 else
4120 {
4121 vehicle.dockoffset = samplePosition;
4122 vehicle.dockingvel = sampleVelocity;
4123 vehicle.position = samplePosition;
4124 vehicle.precisionx = state.position.x;
4125 vehicle.precisiony = state.position.y;
4126 vehicle.precisionz = state.position.z;
4127 vehicle.velocity = sampleVelocity;
4128 }
4129
4130 vehicle.positer = vehicle.posleft = vehicle.veliter = vehicle.velleft = centerC;
4131 vehicle.acciter = vehicle.accleft = centerC;
4132 vehicle.orientiter = vehicle.orientleft = RiseMath::Quaternion(0, 0, 0, 0);
4133 vehicle.pitchleft = vehicle.pitchiter = vehicle.rollleft = vehicle.rolliter = 0.0f;
4134 vehicle.yawleft = vehicle.yawiter = 0.0f;
4135 vehicle.txleft = vehicle.tyleft = vehicle.tzleft = 0.0f;
4136 vehicle.txiter = vehicle.tyiter = vehicle.tziter = 0.0f;
4137 return true;
4138}
4139
4140void Viewscreen::NetworkObjectsProcessing(int t, float fElapsedTime, bool allowOurParent)
4141{
4142 if (!allowOurParent && playerships[0].reference == REF_INANOTHER && t == playerships[0].inarray) // processed earlier
4143 return;
4144
4145 if (!playerships[t].visible || !playerships[t].active)
4146 return;
4147
4148 if (ApplyBufferedVehicleState(t, fElapsedTime))
4149 return;
4150
4151 // Nicely interpolate position
4152 RiseMath::Vector3 cross = playerships[t].positer * fElapsedTime;
4153 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].posleft))
4154 cross = playerships[t].posleft;
4155 playerships[t].posleft -= cross;
4156 if (playerships[t].reference < REF_INANOTHER)
4157 {
4158 playerships[t].precisionx += static_cast<double>(cross.x);
4159 playerships[t].precisiony += static_cast<double>(cross.y);
4160 playerships[t].precisionz += static_cast<double>(cross.z);
4161 }
4162 else
4163 RiseMath::Vec3Add(&playerships[t].dockoffset, &playerships[t].dockoffset, &cross);
4164
4165 // Nicely interpolate velocity
4166 cross = playerships[t].veliter * fElapsedTime;
4167 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].velleft))
4168 cross = playerships[t].velleft;
4169 playerships[t].velleft -= cross;
4170
4171 if (playerships[t].reference < REF_INANOTHER)
4172 RiseMath::Vec3Add(&playerships[t].velocity, &playerships[t].velocity, &cross);
4173 else
4174 RiseMath::Vec3Add(&playerships[t].dockingvel, &playerships[t].dockingvel, &cross);
4175
4176 // Nicely interpolate acceleration
4177 cross = playerships[t].acciter * fElapsedTime;
4178 if (RiseMath::Vec3Length(&cross) > RiseMath::Vec3Length(&playerships[t].accleft))
4179 cross = playerships[t].accleft;
4180 playerships[t].accleft -= cross;
4181 RiseMath::Vec3Add(&playerships[t].acc, &playerships[t].acc, &cross);
4182
4183#pragma region Nicely interpolate YPR
4184 float f_temp = playerships[t].pitchiter * fElapsedTime;
4185 if (fabsf(f_temp) > fabsf(playerships[t].pitchleft))
4186 f_temp = playerships[t].pitchleft;
4187 playerships[t].pitchleft -= f_temp;
4188 playerships[t].pitch += f_temp;
4189
4190 f_temp = playerships[t].rolliter * fElapsedTime;
4191 if (fabsf(f_temp) > fabsf(playerships[t].rollleft))
4192 f_temp = playerships[t].rollleft;
4193 playerships[t].rollleft -= f_temp;
4194 playerships[t].rollRadPerSec += f_temp;
4195
4196 f_temp = playerships[t].yawiter * fElapsedTime;
4197 if (fabsf(f_temp) > fabsf(playerships[t].yawleft))
4198 f_temp = playerships[t].yawleft;
4199 playerships[t].yawleft -= f_temp;
4200 playerships[t].yawRadPerSec += f_temp;
4201#pragma endregion
4202
4203#pragma region Nicely interpolate Thrust
4204 // so if iter is .2 and left is .1 then .2>.1 ... iter -.2 left is -.1
4205 f_temp = playerships[t].txiter * fElapsedTime;
4206 if (fabsf(f_temp) > fabsf(playerships[t].txleft))
4207 f_temp = playerships[t].txleft;
4208 playerships[t].txleft -= f_temp;
4209 playerships[t].tx += f_temp;
4210 playerships[t].tx = Clamp(playerships[t].tx, -1, 1);
4211
4212 f_temp = playerships[t].tyiter * fElapsedTime;
4213 if (fabsf(f_temp) > fabsf(playerships[t].tyleft))
4214 f_temp = playerships[t].tyleft;
4215 playerships[t].tyleft -= f_temp;
4216 playerships[t].ty += f_temp;
4217 playerships[t].ty = Clamp(playerships[t].ty, -1, 1);
4218
4219 f_temp = playerships[t].tziter * fElapsedTime;
4220 if (fabsf(f_temp) > fabsf(playerships[t].tzleft))
4221 f_temp = playerships[t].tzleft;
4222 playerships[t].tzleft -= f_temp;
4223 playerships[t].tz += f_temp;
4224 playerships[t].tz = Clamp(playerships[t].tz, -1, 1);
4225#pragma endregion
4226
4227 // Move based on gravity and barycentric rotation adjustment depending on reference
4228 Movement(t, fElapsedTime);
4229}
4230
4231bool Viewscreen::AssertTelemetry(const char* location, short id)
4232{
4233 sprintf_s(msg, sizeof msg, "V::AssertTelemetry %s (%i)", location, id);
4235
4236 msg[0] = 0;
4237
4238 if (playerships[id].reference <= Reference::REF_ENUMMIN || playerships[id].reference >= Reference::REF_ENUMMAX)
4239 {
4240 sprintf_s(msg, sizeof msg, "Reference: %i", playerships[id].reference);
4242 }
4243 if (_isnan(playerships[id].velocity.x) || isinf(playerships[id].velocity.x) || playerships[id].velocity.x > 100.0f || playerships[id].velocity.x < -100.0f)
4244 {
4245 sprintf_s(msg, sizeof msg, "Velocity I: %f", playerships[id].velocity.x);
4247 }
4248 if (_isnan(playerships[id].velocity.y) || isinf(playerships[id].velocity.y) || playerships[id].velocity.y > 100.0f || playerships[id].velocity.y < -100.0f)
4249 {
4250 sprintf_s(msg, sizeof msg, "Velocity J: %f", playerships[id].velocity.y);
4252 }
4253 if (_isnan(playerships[id].velocity.z) || isinf(playerships[id].velocity.z) || playerships[id].velocity.z > 100.0f || playerships[id].velocity.z < -100.0f)
4254 {
4255 sprintf_s(msg, sizeof msg, "Velocity K: %f", playerships[id].velocity.z);
4257 }
4258 if (_isnan(playerships[id].veliter.x) || isinf(playerships[id].veliter.x) || playerships[id].veliter.x > 100.0f || playerships[id].veliter.x < -100.0f)
4259 {
4260 sprintf_s(msg, sizeof msg, "Velocity Iter I: %f", playerships[id].veliter.x);
4262 }
4263 if (_isnan(playerships[id].veliter.y) || isinf(playerships[id].veliter.y) || playerships[id].veliter.y > 100.0f || playerships[id].veliter.y < -100.0f)
4264 {
4265 sprintf_s(msg, sizeof msg, "Velocity Iter J: %f", playerships[id].veliter.y);
4267 }
4268 if (_isnan(playerships[id].veliter.z) || isinf(playerships[id].veliter.z) || playerships[id].veliter.z > 100.0f || playerships[id].veliter.z < -100.0f)
4269 {
4270 sprintf_s(msg, sizeof msg, "Velocity Iter K: %f", playerships[id].veliter.z);
4272 }
4273 if (_isnan(playerships[id].velleft.x) || isinf(playerships[id].velleft.x) || playerships[id].velleft.x > 100.0f || playerships[id].velleft.x < -100.0f)
4274 {
4275 sprintf_s(msg, sizeof msg, "Velocity Left I: %f", playerships[id].velleft.x);
4277 }
4278 if (_isnan(playerships[id].velleft.y) || isinf(playerships[id].velleft.y) || playerships[id].velleft.y > 100.0f || playerships[id].velleft.y < -100.0f)
4279 {
4280 sprintf_s(msg, sizeof msg, "Velocity Left J: %f", playerships[id].velleft.y);
4282 }
4283 if (_isnan(playerships[id].velleft.z) || isinf(playerships[id].velleft.z) || playerships[id].velleft.z > 100.0f || playerships[id].velleft.z < -100.0f)
4284 {
4285 sprintf_s(msg, sizeof msg, "Velocity Left K: %f", playerships[id].velleft.z);
4287 }
4288 if (_isnan(playerships[id].position.x) || isinf(playerships[id].position.x) || playerships[id].position.x > 1000000.0f || playerships[id].position.x < -1000000.0f)
4289 {
4290 sprintf_s(msg, sizeof msg, "Position X: %f", playerships[id].position.x);
4292 }
4293 if (_isnan(playerships[id].position.y) || isinf(playerships[id].position.y) || playerships[id].position.y > 1000000.0f || playerships[id].position.y < -1000000.0f)
4294 {
4295 sprintf_s(msg, sizeof msg, "Position Y: %f", playerships[id].position.y);
4297 }
4298 if (_isnan(playerships[id].position.z) || isinf(playerships[id].position.z) || playerships[id].position.z > 1000000.0f || playerships[id].position.z < -1000000.0f)
4299 {
4300 sprintf_s(msg, sizeof msg, "Position Z: %f", playerships[id].position.z);
4302 }
4303 if (_isnan(playerships[id].positer.x) || isinf(playerships[id].positer.x) || playerships[id].positer.x > 1000000.0f || playerships[id].positer.x < -1000000.0f)
4304 {
4305 sprintf_s(msg, sizeof msg, "Position Iter I: %f", playerships[id].positer.x);
4307 }
4308 if (_isnan(playerships[id].positer.y) || isinf(playerships[id].positer.y) || playerships[id].positer.y > 1000000.0f || playerships[id].positer.y < -1000000.0f)
4309 {
4310 sprintf_s(msg, sizeof msg, "Position Iter J: %f", playerships[id].positer.y);
4312 }
4313 if (_isnan(playerships[id].positer.z) || isinf(playerships[id].positer.z) || playerships[id].positer.z > 1000000.0f || playerships[id].positer.z < -1000000.0f)
4314 {
4315 sprintf_s(msg, sizeof msg, "Position Iter K: %f", playerships[id].positer.z);
4317 }
4318 if (_isnan(playerships[id].posleft.x) || isinf(playerships[id].posleft.x) || playerships[id].posleft.x > 1000000.0f || playerships[id].posleft.x < -1000000.0f)
4319 {
4320 sprintf_s(msg, sizeof msg, "Position Left I: %f", playerships[id].posleft.x);
4322 }
4323 if (_isnan(playerships[id].posleft.y) || isinf(playerships[id].posleft.y) || playerships[id].posleft.y > 1000000.0f || playerships[id].posleft.y < -1000000.0f)
4324 {
4325 sprintf_s(msg, sizeof msg, "Position Left J: %f", playerships[id].posleft.y);
4327 }
4328 if (_isnan(playerships[id].posleft.z) || isinf(playerships[id].posleft.z) || playerships[id].posleft.z > 1000000.0f || playerships[id].posleft.z < -1000000.0f)
4329 {
4330 sprintf_s(msg, sizeof msg, "Position Left K: %f", playerships[id].posleft.z);
4332 }
4333 if (_isnan(playerships[id].pitchdeflect) || isinf(playerships[id].pitchdeflect) || playerships[id].pitchdeflect > 10.0f || playerships[id].pitchdeflect < -10.0f)
4334 {
4335 sprintf_s(msg, sizeof msg, "Pitchdeflect: %f", playerships[id].pitchdeflect);
4337 }
4338 if (_isnan(playerships[id].rolldeflect) || isinf(playerships[id].rolldeflect) || playerships[id].rolldeflect > 10.0f || playerships[id].rolldeflect < -10.0f)
4339 {
4340 sprintf_s(msg, sizeof msg, "Rolldeflect: %f", playerships[id].rolldeflect);
4342 }
4343 if (_isnan(playerships[id].yawdeflect) || isinf(playerships[id].yawdeflect) || playerships[id].yawdeflect > 10.0f || playerships[id].yawdeflect < -10.0f)
4344 {
4345 sprintf_s(msg, sizeof msg, "Yawdeflect: %f", playerships[id].yawdeflect);
4347 }
4348 if (_isnan(playerships[id].steerdeflect) || isinf(playerships[id].steerdeflect) || playerships[id].steerdeflect > 10.0f || playerships[id].steerdeflect < -10.0f)
4349 {
4350 sprintf_s(msg, sizeof msg, "steerdeflect: %f", playerships[id].steerdeflect);
4352 }
4353 if (_isnan(playerships[id].pitch) || isinf(playerships[id].pitch) || playerships[id].pitch > 1000.0f || playerships[id].pitch < -1000.0f)
4354 {
4355 sprintf_s(msg, sizeof msg, "Pitch: %f", playerships[id].pitch);
4357 }
4358 if (_isnan(playerships[id].rollRadPerSec) || isinf(playerships[id].rollRadPerSec) || playerships[id].rollRadPerSec > 1000.0f || playerships[id].rollRadPerSec < -1000.0f)
4359 {
4360 sprintf_s(msg, sizeof msg, "Roll: %f", playerships[id].rollRadPerSec);
4362 }
4363 if (_isnan(playerships[id].yawRadPerSec) || isinf(playerships[id].yawRadPerSec) || playerships[id].yawRadPerSec > 1000.0f || playerships[id].yawRadPerSec < -1000.0f)
4364 {
4365 sprintf_s(msg, sizeof msg, "Yaw: %f", playerships[id].yawRadPerSec);
4367 }
4368 if (_isnan(playerships[id].acc.x) || isinf(playerships[id].acc.x) || playerships[id].acc.x > 1000.0f || playerships[id].acc.x < -1000.0f)
4369 {
4370 sprintf_s(msg, sizeof msg, "Acceleration I: %f", playerships[id].acc.x);
4372 }
4373 if (_isnan(playerships[id].acc.y) || isinf(playerships[id].acc.y) || playerships[id].acc.y > 1000.0f || playerships[id].acc.y < -1000.0f)
4374 {
4375 sprintf_s(msg, sizeof msg, "Acceleration J: %f", playerships[id].acc.y);
4377 }
4378 if (_isnan(playerships[id].acc.z) || isinf(playerships[id].acc.z) || playerships[id].acc.z > 1000.0f || playerships[id].acc.z < -1000.0f)
4379 {
4380 sprintf_s(msg, sizeof msg, "Acceleration K: %f", playerships[id].acc.z);
4382 }
4383 if (_isnan(playerships[id].acciter.x) || isinf(playerships[id].acciter.x) || playerships[id].acciter.x > 1000.0f || playerships[id].acciter.x < -1000.0f)
4384 {
4385 sprintf_s(msg, sizeof msg, "Acc Iter I: %f", playerships[id].acciter.x);
4387 }
4388 if (_isnan(playerships[id].acciter.y) || isinf(playerships[id].acciter.y) || playerships[id].acciter.y > 1000.0f || playerships[id].acciter.y < -1000.0f)
4389 {
4390 sprintf_s(msg, sizeof msg, "Acc Iter J: %f", playerships[id].acciter.y);
4392 }
4393 if (_isnan(playerships[id].acciter.z) || isinf(playerships[id].acciter.z) || playerships[id].acciter.z > 1000.0f || playerships[id].acciter.z < -1000.0f)
4394 {
4395 sprintf_s(msg, sizeof msg, "Acc Iter K: %f", playerships[id].acciter.z);
4397 }
4398 if (_isnan(playerships[id].accleft.x) || isinf(playerships[id].accleft.x) || playerships[id].accleft.x > 1000.0f || playerships[id].accleft.x < -1000.0f)
4399 {
4400 sprintf_s(msg, sizeof msg, "Acc Left I: %f", playerships[id].accleft.x);
4402 }
4403 if (_isnan(playerships[id].accleft.y) || isinf(playerships[id].accleft.y) || playerships[id].accleft.y > 1000.0f || playerships[id].accleft.y < -1000.0f)
4404 {
4405 sprintf_s(msg, sizeof msg, "Acc Left J: %f", playerships[id].accleft.y);
4407 }
4408 if (_isnan(playerships[id].accleft.z) || isinf(playerships[id].accleft.z) || playerships[id].accleft.z > 1000.0f || playerships[id].accleft.z < -1000.0f)
4409 {
4410 sprintf_s(msg, sizeof msg, "Acc Left K: %f", playerships[id].accleft.z);
4412 }
4413 if (_isnan(playerships[id].tx) || isinf(playerships[id].tx) || playerships[id].tx > 1.0f || playerships[id].tx < -1.0f)
4414 {
4415 sprintf_s(msg, sizeof msg, "Thrust I: %f", playerships[id].tx);
4417 }
4418 if (_isnan(playerships[id].ty) || isinf(playerships[id].ty) || playerships[id].ty > 1.0f || playerships[id].ty < -1.0f)
4419 {
4420 sprintf_s(msg, sizeof msg, "Thrust J: %f", playerships[id].ty);
4422 }
4423 if (_isnan(playerships[id].tz) || isinf(playerships[id].tz) || playerships[id].tz > 1.0f || playerships[id].tz < -1.0f)
4424 {
4425 sprintf_s(msg, sizeof msg, "Thrust K: %f", playerships[id].tz);
4427 }
4428 if (_isnan(playerships[id].orientation.x) || isinf(playerships[id].orientation.x) || playerships[id].orientation.x > 10.0f || playerships[id].orientation.x < -10.0f)
4429 {
4430 sprintf_s(msg, sizeof msg, "Orientation X: %f", playerships[id].orientation.x);
4432 }
4433 if (_isnan(playerships[id].orientation.y) || isinf(playerships[id].orientation.y) || playerships[id].orientation.y > 10.0f || playerships[id].orientation.y < -10.0f)
4434 {
4435 sprintf_s(msg, sizeof msg, "Orientation Y: %f", playerships[id].orientation.y);
4437 }
4438 if (_isnan(playerships[id].orientation.z) || isinf(playerships[id].orientation.z) || playerships[id].orientation.z > 10.0f || playerships[id].orientation.z < -10.0f)
4439 {
4440 sprintf_s(msg, sizeof msg, "Orientation Z: %f", playerships[id].orientation.z);
4442 }
4443 if (_isnan(playerships[id].orientation.w) || isinf(playerships[id].orientation.w) || playerships[id].orientation.w > 10.0f || playerships[id].orientation.w < -10.0f)
4444 {
4445 sprintf_s(msg, sizeof msg, "Orientation W: %f", playerships[id].orientation.w);
4447 }
4448
4449 //sprintf_s(msg, sizeof msg, "ID: %i (%i) (ours is %i (%i))", id, playerships[id].vehicleId, 0, playerships[0].vehicleId);
4450 //logger->Log(msg, Logger::Level::Debug);
4451 //sprintf_s(msg, sizeof msg, "Matrix: %f %f %f %f", playerships[id].matrixWorld._11, playerships[id].matrixWorld._12, playerships[id].matrixWorld._13, playerships[id].matrixWorld._14);
4452 //logger->Log(msg, Logger::Level::Debug);
4453 //sprintf_s(msg, sizeof msg, "Matrix: %f %f %f %f", playerships[id].matrixWorld._21, playerships[id].matrixWorld._22, playerships[id].matrixWorld._23, playerships[id].matrixWorld._24);
4454 //logger->Log(msg, Logger::Level::Debug);
4455 //sprintf_s(msg, sizeof msg, "Matrix: %f %f %f %f", playerships[id].matrixWorld._31, playerships[id].matrixWorld._32, playerships[id].matrixWorld._33, playerships[id].matrixWorld._34);
4456 //logger->Log(msg, Logger::Level::Debug);
4457 //sprintf_s(msg, sizeof msg, "Matrix: %f %f %f %f", playerships[id].matrixWorld._41, playerships[id].matrixWorld._42, playerships[id].matrixWorld._43, playerships[id].matrixWorld._44);
4458 //logger->Log(msg, Logger::Level::Debug);
4459
4460 if (msg[0])
4461 {
4462 sprintf_s(msg, sizeof msg, "Trapped a telemetry violation: %s (slot %i id %i)", location, id, playerships[id].vehicleId);
4464
4465 if (id == 0)
4466 {
4468 deathinhibit = FLT_MAX;
4470 }
4471
4473 MessageBox(Rendering::ClientWindow(), L"Encountered a telemetry error!\n\nWe automatically reported the details.\n\nSorry for the inconvenience and thanks for helping us track down a bug!", L"Program fault!", MB_OK | MB_ICONERROR);
4474
4475 return false;
4476 }
4477
4478 logger->AddToCallStack("Viewscreen::AssertTelemetry END");
4479
4480 return true;
4481}
4482
4501
4502void Viewscreen::CheckLogo(unsigned char array, char* logofile)
4503{
4504 // Metadata replaces the assignment, including when a scan slot is reused.
4505 playerships[array].logoOrdinal = -1;
4506 if (logofile[0] != '\0' && logofile[0] != '_')
4507 {
4508 // so we have a ship with a logo request
4509 auto it = std::find(logofiles.begin(), logofiles.end(), logofile);
4510 // if it isn't in our logofiles list then we need to add it and request it
4511 if (it == logofiles.end())
4512 {
4513 playerships[array].logoOrdinal = logofiles.size();
4514
4515 logofiles.emplace_back(logofile);
4516 m_pddsLogos.emplace_back(nullptr);
4517
4518 // send request over the wire
4519 SPacketBig bigpacket;
4520 bigpacket.type = 15;
4521 strcpy_s(bigpacket.msg, 84, logofile);
4522 bigpacket.ship = bigpacket.array = bigpacket.inarray = 0; // all unused
4523 bigpacket.vehicleId = playerships[array].logoOrdinal;
4524 gameclass->networking->SendToServer(&bigpacket, sizeof SPacketBig, true);
4525 }
4526 else
4527 {
4528 playerships[array].logoOrdinal = std::distance(logofiles.begin(), it);
4529 }
4530 }
4531}
4532
4533RECT Viewscreen::WhichRoom(const std::vector<tagRECT>& rooms, float x, float y, short* roomIndex)
4534{
4535 for (size_t i = 0; i < rooms.size(); i++)
4536 {
4537 const RECT room = rooms.at(i);
4538 if (x >= room.left && x <= room.right && y <= room.top && y >= room.bottom)
4539 {
4540 *roomIndex = static_cast<short>(i);
4541 return room;
4542 }
4543 }
4544 *roomIndex = -1;
4545 return {};
4546}
@ KeyboardBindings
Definition ActiveHelp.h:412
@ Biometer
Definition ActiveHelp.h:360
@ LookAroundGamepad
Definition ActiveHelp.h:419
@ Garage
Definition ActiveHelp.h:363
@ VehicleProximity
Definition ActiveHelp.h:395
@ Heal
Definition ActiveHelp.h:445
@ LookAroundMouse
Definition ActiveHelp.h:384
@ Intermedia2
Definition ActiveHelp.h:415
@ PortSpeed
Definition ActiveHelp.h:359
@ Repair
Definition ActiveHelp.h:417
@ CashInHand
Definition ActiveHelp.h:364
@ AptWindows
Definition ActiveHelp.h:355
#define V(expression)
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
@ D_BIOMETER
Definition DialogBase.h:8
float Lerp(float val1, float val2, float lerp)
float RandomFloat()
constexpr auto Clamp(T1 val, T2 min, T3 max)
bool RectEquality(RECT rect1, RECT rect2)
RiseMath::Vector2 CalculateLatLng(RiseMath::Vector3 position)
float GetArcDist(RiseMath::Vector3 from, RiseMath::Vector3 to, bool includeAltDiff)
@ EVENT_WINDSHIELD_FAULT
Definition Networking.h:68
@ EVENT_HORN_STOP
Definition Networking.h:70
@ EVENT_HORN_START
Definition Networking.h:69
@ EVENT_WIPERS
Definition Networking.h:67
@ EVENT_LOGOLIGHT_ON
Definition Networking.h:50
@ EVENT_LOGOLIGHT_OFF
Definition Networking.h:51
@ EVA_SUIT
Definition ServerTypes.h:69
@ ControlTower
Definition ServerTypes.h:86
@ BeishtKione
Definition ServerTypes.h:83
@ T19
Definition ServerTypes.h:87
@ P13
Definition ServerTypes.h:64
@ Apartment
Definition ServerTypes.h:80
@ E10
Definition ServerTypes.h:63
@ T27
Definition ServerTypes.h:82
@ E11
Definition ServerTypes.h:68
@ FloatingMan
Definition ServerTypes.h:88
@ DIHV
Definition ServerTypes.h:62
#define MAX_ENGINES
#define MAX_SCAN
@ PlotTypeEnum
const RiseMath::Vector3 northpoleK
@ Binoculars
#define maxdockC
const RiseMath::Vector3 centerC
@ REF_BUILDING
Definition ServerTypes.h:46
@ REF_DOCKTAC
Definition ServerTypes.h:54
@ REF_ACLMODE
Definition ServerTypes.h:44
@ REF_PROXIMITY
Definition ServerTypes.h:48
@ REF_DOCKENUMCPOC
Definition ServerTypes.h:53
@ REF_INANOTHER
Definition ServerTypes.h:45
@ REF_ENUMMIN
Definition ServerTypes.h:41
@ REF_APNMODE
Definition ServerTypes.h:42
@ REF_ONGROUND
Definition ServerTypes.h:43
@ REF_ENUMMAX
Definition ServerTypes.h:56
@ REF_WINDOWLESS
Definition ServerTypes.h:50
SOUNDS
Definition Sound.h:23
@ SOUND_PEOPLEGRUNT3
Definition Sound.h:118
@ SOUND_DOCK
Definition Sound.h:207
@ SOUND_GDEATH1
Definition Sound.h:242
@ SOUND_EXPLODERING
Definition Sound.h:303
@ SOUND_APTRIMCLACKER
Definition Sound.h:169
@ SOUND_COCKPITSTART
Definition Sound.h:26
@ SOUND_ODEATH2
Definition Sound.h:245
@ SOUND_TDEATH1
Definition Sound.h:246
@ SOUND_DEPLANING
Definition Sound.h:189
@ SOUND_HOLIDAY2019
Definition Sound.h:291
@ SOUND_CRUISE
Definition Sound.h:185
@ SOUND_PEOPLEDEATH
Definition Sound.h:275
@ SOUND_COCKPITAMBIENT
Definition Sound.h:27
@ SOUND_PEOPLEGRUNT1
Definition Sound.h:116
@ SOUND_DOCKING
Definition Sound.h:187
@ SOUND_HEARTBEAT
Definition Sound.h:276
@ SOUND_RESP0
Definition Sound.h:277
@ SOUND_GDEATH2
Definition Sound.h:243
@ SOUND_TDEATH2
Definition Sound.h:247
@ SOUND_WDEATH1
Definition Sound.h:240
@ SOUND_DOCKEVAC
Definition Sound.h:204
@ SOUND_DIHV
Definition Sound.h:219
@ SOUND_PEOPLEGRUNT2
Definition Sound.h:117
@ SOUND_COCKPITLAND
Definition Sound.h:28
@ SOUND_HOLIDAY2018
Definition Sound.h:290
@ SOUND_WDEATH2
Definition Sound.h:241
@ SOUND_PRESSUREDUMP
Definition Sound.h:215
void Observe(const Sample &sample, std::uint64_t now, Emit emit)
float RightBrake
Definition Bus.h:383
float DebugVasoBPM
Definition Bus.h:558
float StaticAirPressureMb
Definition Bus.h:406
float DebugFloat2
Definition Bus.h:540
float TargetDistanceKm
Definition Bus.h:502
float DebugAdrenoBPM
Definition Bus.h:559
float RollAttitudeRadians
Definition Bus.h:48
float DebugFloat9
Definition Bus.h:546
float PressureAltitudeKm
Definition Bus.h:31
float PressureDiffMb
Definition Bus.h:405
float LatitudeDeg
Definition Bus.h:312
float GroundSpeedKms
Definition Bus.h:179
int DebugFloorY
Definition Bus.h:567
float DebugStressBPM
Definition Bus.h:560
float PitchAttitudeRadians
Definition Bus.h:47
RainAir::State RainAirStatus
Definition Bus.h:488
float TrailingEdgeFlapsPosition
Definition Bus.h:424
float CabinPressureMb
Definition Bus.h:403
float TargetPressureMb
Definition Bus.h:404
struct Bus::Gpws GPWS
float LeftBrake
Definition Bus.h:383
float DebugBaseBPM
Definition Bus.h:557
short targetC
Definition Bus.h:480
long topscroll
Definition Bus.h:483
float LandingGearExtended
Definition Bus.h:301
bool ProximityAlert
Definition Bus.h:477
float EngineThrustLever[MAX_ENGINES]
Definition Bus.h:357
RiseMath::Vector3 NormalAcceleration
Definition Bus.h:45
double SimulatorTimeOffset
Definition Bus.h:475
float LeadingEdgeFlapsPosition
Definition Bus.h:426
float scandist[MAX_SCAN]
Definition Bus.h:486
std::vector< Swaypoint > waypoint
Definition Bus.h:500
float LocalTimeMinutes
Definition Bus.h:459
float RadioAltitudeKm
Definition Bus.h:157
short scanslot[MAX_SCAN]
Definition Bus.h:485
float LatitudeRad
Definition Bus.h:313
int WPtargetC
Definition Bus.h:499
long scanscroll
Definition Bus.h:483
bool FlightFreeze
Definition Bus.h:474
float waypointDistanceKm
Definition Bus.h:482
double ProgramTime
Definition Bus.h:473
float LocalTimeHours
Definition Bus.h:458
float HeadingMagneticDegrees
Definition Bus.h:42
int DebugRaindrops
Definition Bus.h:565
float VerticalSpeedKms
Definition Bus.h:451
float FuelWeightLbs
Definition Bus.h:462
float LongitudeDeg
Definition Bus.h:312
int DebugFloorX
Definition Bus.h:566
bool ThrustReverserCommand[MAX_ENGINES]
Definition Bus.h:72
std::vector< Command > commandStream
Definition Bus.h:442
void Update(Rendering::RenderDevice *device, uint64_t now, const std::function< void(const CityLogos::AssignmentAsset &)> &send, bool measure=false)
SoundConfig soundConfigComms
Definition config.h:50
SoundConfig soundConfigLegacy
Definition config.h:51
SoundConfig soundConfigComputer
Definition config.h:49
InputConfig inputConfigLookLateral
Definition config.h:43
InputConfig inputConfigLookVertical
Definition config.h:44
SoundConfig soundConfigRadio
Definition config.h:52
static DialogBase * dialogs[D_ENUMERATION]
Definition DialogBase.h:41
void PopUpDialog()
void FrameMove(float fElapsed)
Definition Displays.cpp:677
void ChangePage(std::string screenName, std::string pageName)
Definition Displays.cpp:750
void Update(float elapsed, const ExteriorRain::Parameters &parameters, const RiseMath::Matrix &localToWorld)
void Poll()
Definition FreeTrack.cpp:35
FreeTrackInput input
Definition FreeTrack.h:49
void Reset()
Definition FreeTrack.cpp:29
std::unique_ptr< Bus > bus
Definition GameClass.h:108
Config config
Definition GameClass.h:100
void LostScannerTarget(const char *msg) const
void RequestScannerData() const
std::unique_ptr< HMI > GUI
Definition GameClass.h:106
std::unique_ptr< Sound > sound
Definition GameClass.h:104
bool TurnOffTVM() const
std::unique_ptr< Networking > networking
Definition GameClass.h:103
std::unique_ptr< Displays > displays
Definition GameClass.h:110
std::vector< std::unique_ptr< Module > > modules
Definition GameClass.h:113
ModuleScheduler moduleScheduler
Definition GameClass.h:114
void KillScannerData() const
std::unique_ptr< Viewscreen > viewscreen
Definition GameClass.h:107
bool TurnOffDOR(bool preserveGuidance=false) const
void ChangeGear(char newGear, bool isInit=false) const
std::unique_ptr< Graphics > graphics
Definition GameClass.h:105
float displayWidth
Definition GameClass.h:131
float displayHeight
Definition GameClass.h:131
void ToggleFullScreen(bool goFullScreen)
void AutopilotDisconnect() const
Rendering::RenderMaterial * g_pEffect
Definition Graphics.h:30
SPlayerData player[MAX_ONLINEPLAYERS]
Definition gui.h:1093
POINT ptCursor
Definition gui.h:1049
InformationDialog * informationDialog
Definition gui.h:1120
unsigned char ourplayerC
Definition gui.h:1094
bool g_bRightDown
Definition gui.h:1045
bool IsAdmin
Definition gui.h:1108
void Reset(bool terrainRequired)
bool Suppress(float dt, bool terrainReady, float x, float y, float z)
bool DismissHelp(int helpId, int nControlID=GUI_UNDERSTOOD)
bool PopUpHelp(short helpId, bool allowDismiss=true, bool isLearnMore=false)
void Log(const char *msg, Level level=Info, int errorCode=0)
Definition Logger.cpp:283
void AddToCallStack(const char *msg)
Definition Logger.cpp:355
@ Debug
Definition Logger.h:27
@ Info
Definition Logger.h:25
@ Warn
Definition Logger.h:26
@ Fatal
Definition Logger.h:29
@ Error
Definition Logger.h:28
void Advance(float frameSeconds, size_t count, Dispatch dispatch)
void SendToServer(void *pData, DWORD dwSize, bool bGuaranteed, PacketOrdering order=ORDERING_NONE) const
void SendEvent(EventType eventType, float extent=0.0f) const
HRESULT Lock(UINT offset, UINT bytes, void **output, DWORD flags)
HRESULT LightEnable(DWORD index, BOOL enabled)
HRESULT SetLight(DWORD index, const Light *value)
HRESULT SetTransform(DWORD slot, const RiseMath::Matrix *value)
float tiltlimitR
Definition Camera.h:27
float tiltlimitL
Definition Camera.h:26
float currentPan
Definition Camera.h:12
RiseMath::Vector3 position
Definition Camera.h:11
bool allowPan
Definition Camera.h:18
float rightlimit
Definition Camera.h:23
float leftlimit
Definition Camera.h:22
float currentTilt
Definition Camera.h:13
bool allowTilt
Definition Camera.h:19
bool outside
Definition Camera.h:17
float currentZoom
Definition Camera.h:21
float uplimit
Definition Camera.h:24
float attenuate
Definition Camera.h:28
float downlimit
Definition Camera.h:25
void ChangeVolume(SoundConfig *config, float modVolume)
Definition Sound.cpp:551
void Stop(SOUNDS soundEnum) const
Definition Sound.cpp:3397
void PlayCabinAnnouncement(SOUNDS sound_enum)
Definition Sound.cpp:3456
float Play(SOUNDS soundEnum, float volume=1.0f)
Definition Sound.cpp:802
void PlayEx(SOUNDS soundEnum, bool loop, float volume=1.0f, float frequencyMod=1.0f, float pan=0.0f, bool restart=true, bool fromOutside=false, bool partOfHull=false)
Definition Sound.cpp:1006
void GlobalAttenuate(float prmGaTimeToFadeOut, float prmGaTimeToHold, float prmGaTimeToFadeIn, SOUNDS soundEnum, float prmExTimeToFadeIn, float prmExTimeToHold, float prmExTimeToFadeOut, float volumeAdj=1.0f)
Definition Sound.cpp:536
void LoadDockSounds(short dockTexture)
Definition Sound.cpp:3575
PresentationState SampleVehicle(std::size_t slot, double nowSeconds, double elapsedSeconds)
float lateraltime
Definition Viewscreen.h:378
void ChangeCamera()
short oldRoomIndex
Definition Viewscreen.h:380
RiseMath::Vector3 position
Definition Viewscreen.h:382
ULONGLONG headAccelerationDiagnosticUntil
Definition Viewscreen.h:64
void EnableLandingLights() const
Definition framemove.cpp:17
ULONGLONG headAccelerationNextSample
Definition Viewscreen.h:64
float reentryDamageIntensity
Definition Viewscreen.h:365
RiseMath::Quaternion startorient
Definition Viewscreen.h:70
float GetSuspensionRollOffsetRadians() const
float suspensionNormalLoadG
Definition Viewscreen.h:113
bool olddocked
Definition Viewscreen.h:69
float lookAzimuthDegrees
Definition Viewscreen.h:369
void ResetSuspensionState()
bool ApplyBufferedVehicleState(int t, float fElapsedTime)
bool pitchTrimMod
Definition Viewscreen.h:101
void Movement(short t, float ElapsedTime)
std::unique_ptr< keyboard > ptrKeyboard
Definition Viewscreen.h:429
RiseMath::Vector3 startoffset
Definition Viewscreen.h:71
float steerInput
Definition Viewscreen.h:372
float GetSuspensionPitchOffsetRadians() const
char msg[199]
Definition Viewscreen.h:50
float yawInput
Definition Viewscreen.h:372
short oldDockTexture
Definition Viewscreen.h:421
unsigned activeLandingLightCount
Definition Viewscreen.h:330
bool advanceframe
Definition Viewscreen.h:375
static float ComputeSpotlightBrightness(const RiseMath::Vector3 &pos)
bool hasAnimatedWipers
Definition Viewscreen.h:410
float targetZoom
Definition Viewscreen.h:446
float pitchTrimTime
Definition Viewscreen.h:74
float pitchInput
Definition Viewscreen.h:372
float H2Ooffsetu
Definition Viewscreen.h:420
float GetAverageSuspensionBumpTravelKm() const
DeathType causechain
Definition Viewscreen.h:376
Rendering::RenderBuffer * m_avRainDrops
Definition Viewscreen.h:225
std::array< LandingLights::Light, LandingLights::MaxLights > landingLights
Definition Viewscreen.h:329
void SetHornPressed(bool pressed)
RiseMath::Vector3 rainarray[MAX_RAINDROPS]
Definition Viewscreen.h:393
static RECT WhichRoom(const std::vector< tagRECT > &rooms, float x, float y, short *roomIndex)
Sani GetAni(float f_time, unsigned char ani) const
std::vector< std::string > logofiles
Definition Viewscreen.h:308
bool VolumeCloudsEnabled() const
Definition Viewscreen.h:404
GameClass * gameclass
Definition Viewscreen.h:439
HeadAcceleration::RepositionGuard headAccelerationGuard
Definition Viewscreen.h:62
BiometerDiagnostics::Monitor biometerDiagnostics
Definition Viewscreen.h:122
RiseMath::Matrix matrixLookAdj
Definition Viewscreen.h:346
RiseMath::Vector3 compassnorth
Definition Viewscreen.h:107
ReentryEnvelope::State reentryState
Definition Viewscreen.h:399
bool InventoryItemEffectsEnabled() const
Definition Viewscreen.h:169
float headtilt
Definition Viewscreen.h:61
float rolltilt
Definition Viewscreen.h:447
void SetRainProtection(bool enabled)
std::unique_ptr< propulsion > ptrPropulsion
Definition Viewscreen.h:432
RiseMath::Matrix matrixView
Definition Viewscreen.h:346
RiseMath::Vector3 oldsumofforces
Definition Viewscreen.h:60
RiseMath::Matrix matrixLook
Definition Viewscreen.h:346
int curbDiagnosticFramesRemaining
Definition Viewscreen.h:119
RiseMath::Vector3 reentryWindward
Definition Viewscreen.h:400
std::unique_ptr< weather > ptrWeather
Definition Viewscreen.h:434
float lampTest
Definition Viewscreen.h:424
size_t cameraOrdinal
Definition Viewscreen.h:139
std::vector< SCamera > cameras
Definition Viewscreen.h:136
unsigned int curbDiagnosticSequence
Definition Viewscreen.h:117
RiseMath::Vector3 posnorml
Definition Viewscreen.h:383
bool lateralmod
Definition Viewscreen.h:379
std::unique_ptr< grid > ptrGrid
Definition Viewscreen.h:426
unsigned short causearray
Definition Viewscreen.h:377
ULONGLONG headAccelerationNextAnomaly
Definition Viewscreen.h:64
void SetCrashHornFault(bool enabled)
void SetProjectionMatrices()
std::array< SuspensionWheelState, 4 > suspensionWheels
Definition Viewscreen.h:116
float lookhdg
Definition Viewscreen.h:369
void NetworkObjectsProcessing(int t, float fElapsedTime, bool allowOurParent=false)
std::vector< std::string > sofTracking
Definition Viewscreen.h:134
Rendering::Light sunlight
Definition Viewscreen.h:328
float counteri
Definition Viewscreen.h:448
float currentBPM
Definition Viewscreen.h:121
bool AssertTelemetry(const char *location, short id)
void LogCurbDiagnostic(const char *text)
std::unique_ptr< instruments > ptrInstruments
Definition Viewscreen.h:436
Rendering::AdDiagnostics11 adDiagnostics
Definition Viewscreen.h:401
float lowframeTime
Definition Viewscreen.h:52
short dockTexture
Definition Viewscreen.h:421
float rollInput
Definition Viewscreen.h:372
CityCampaignLogos cityCampaignLogos
Definition Viewscreen.h:309
float verticaltime
Definition Viewscreen.h:378
VECTOR2SHORT CalculateCGC(RiseMath::Vector3 position, char cube) const
RiseMath::Color alphascreen
Definition Viewscreen.h:364
void DumpSofTracking()
void UpdateCrashDamage(const RiseMath::Vector3 &frameForces, float seconds)
RiseMath::Vector3 cockpitSpecificForceMss
Definition Viewscreen.h:151
unsigned int curbDiagnosticFrame
Definition Viewscreen.h:118
float heartloop
Definition Viewscreen.h:418
static RiseMath::Vector3 CalculateBarycentric(RiseMath::Vector3 *position, RiseMath::Vector3 *gthrust, float *radius)
std::unique_ptr< buildings > ptrBuildings
Definition Viewscreen.h:428
float counterj
Definition Viewscreen.h:448
void OnFrameMove(double fTime, float fElapsedTime)
short oldportassigned
Definition Viewscreen.h:68
void ApplySuspensionImpact(float absorbedVelocityKms)
RiseMath::Vector3 sumofforces
Definition Viewscreen.h:108
std::vector< Rendering::RenderTexture * > m_pddsLogos
Definition Viewscreen.h:307
unsigned int headAccelerationResetSequence
Definition Viewscreen.h:63
float breathTimer
Definition Viewscreen.h:123
bool suspensionStateInitialized
Definition Viewscreen.h:115
float suspensionHeaveG
Definition Viewscreen.h:114
short raindrops
Definition Viewscreen.h:394
CollisionDamage::StructuralEpisode crashDamageEpisode
Definition Viewscreen.h:338
float targetUpdown
Definition Viewscreen.h:445
void Undock() const
float holidayTimer
Definition Viewscreen.h:56
std::unique_ptr< cockpit > ptrCockpit
Definition Viewscreen.h:435
s_polygon_extras2 polyextras2
Definition Viewscreen.h:390
bool leftfoot
Definition Viewscreen.h:65
bool hornBindingDown
Definition Viewscreen.h:413
void UpdateLandingLights(double seconds)
Definition framemove.cpp:23
std::unique_ptr< joystick > ptrJoystick
Definition Viewscreen.h:430
bool verticalmod
Definition Viewscreen.h:379
RiseMath::Vector3 lookvec
Definition Viewscreen.h:363
float onlinePlayersInVicinity
Definition Viewscreen.h:100
WindshieldRainRenderer windshieldRain
Definition Viewscreen.h:395
float radioBlackout
Definition Viewscreen.h:104
SCamera * cockpitCamera
Definition Viewscreen.h:138
float headback
Definition Viewscreen.h:61
char CalculateCube(RiseMath::Vector3 position) const
std::unique_ptr< FreeTrack > ptrFreeTrack
Definition Viewscreen.h:431
std::unique_ptr< weapon > ptrWeapon
Definition Viewscreen.h:427
float targetLeftright
Definition Viewscreen.h:444
float healTimer
Definition Viewscreen.h:54
void CheckLogo(unsigned char array, char *logofile)
float m_fAnimateFrame
Definition Viewscreen.h:55
float counterk
Definition Viewscreen.h:448
ExteriorRainRenderer exteriorRainRenderer
Definition Viewscreen.h:403
Logger * logger
Definition Viewscreen.h:440
float interlace
Definition Viewscreen.h:423
CollisionDamage::Episode controlJoltEpisode
Definition Viewscreen.h:339
float frameRateHeartbeat
Definition Viewscreen.h:53
void ClearCollisionEffects()
SCamera * camera
Definition Viewscreen.h:137
float footstep
Definition Viewscreen.h:66
float UpdateSuspensionState(float elapsedTime, const RiseMath::Vector3 &vehicleG)
RiseMath::Vector3 structuralImpactImpulse
Definition Viewscreen.h:111
void ResetHeadAccelerationEffects(const char *reason, bool waitForTerrain=false)
std::vector< RECT > rooms
Definition Viewscreen.h:106
float timeToNextDecrement
Definition Viewscreen.h:57
static RiseMath::Matrix ToPhysicsTransform(const RiseMath::Matrix &value)
void Update(float elapsed, float rain, const RiseMath::Vector3 &acceleration, const RiseMath::Vector3 &wind, const std::vector< RiseMath::Matrix > &transforms, float density, bool wiping, float rainAir=0)
void Sort()
void ResetProps(const char *reason) const
Definition cockpit.cpp:25
bool UsesParentExternalCameras() const
Definition cockpit.h:25
void FrameMove(float fElapsedTime) const
Definition cockpit.cpp:2202
bool wholeGridPending
Definition grid.h:40
bool dataReady
Definition grid.h:36
void Process()
Definition grid.cpp:310
VECTOR2SHORT tcp
Definition grid.h:44
void FrameMove(float fElapsedTime) const
void Update(float fElapsedTime)
Definition joystick.cpp:271
void Update(float fElapsedTime)
Definition keyboard.cpp:68
RiseMath::Vector3 groundvec
Definition propulsion.h:100
void Update(float fElapsedTime)
void ResetControlLoops()
float totalWeightLbs
Definition propulsion.h:81
RiseMath::Vector3 localWindVector
Definition propulsion.h:99
float staticDensity
Definition propulsion.h:94
float tatCelsius
Definition propulsion.h:88
float yawAccelerationSnapshot
Definition propulsion.h:93
RiseMath::Vector3 AirflowBodyKms() const
Definition propulsion.h:108
float rollAccelerationSnapshot
Definition propulsion.h:93
float tat_mod_qz_x
Definition propulsion.h:92
float ias
Definition propulsion.h:90
float pitchAccelerationSnapshot
Definition propulsion.h:93
float qz_lbsPerSqFt
Definition propulsion.h:89
void Update(float fElapsedTime)
Definition weapon.cpp:82
float GetPrecip() const
Definition weather.cpp:1365
float GetRainPrecip() const
Definition weather.cpp:1360
float daylightOverride
Definition weather.h:223
float GetWindspeedKms() const
Definition weather.cpp:1352
void FrameMove(float fElapsedTime)
Definition weather.cpp:32
float orbitSunLatitude
Definition weather.h:117
float elevation
Definition weather.h:197
float snowBlend
Definition weather.h:202
float cloudRainDensity
Definition weather.h:220
float GetCloudCeilingMslKm() const
Definition weather.cpp:1483
float GetVisibilityKm() const
Definition weather.cpp:1411
float lightningAfterimageAmbient
Definition weather.h:185
float gammascreenOverride
Definition weather.h:225
float weapontimer[2]
Definition globals.cpp:89
float fuel
Definition globals.cpp:90
s_city_stuff citystuff
Definition globals.cpp:110
float deathfuel
Definition globals.cpp:91
DeathType dead
Definition globals.cpp:37
bool g_bRunning
Definition globals.cpp:98
float flasher
Definition globals.cpp:49
unsigned char UCLobjC
Definition globals.cpp:23
float f_ACL
Definition globals.cpp:11
float g_UniverseTime
Definition globals.cpp:18
float f_AGL
Definition globals.cpp:9
FIREWORKS fireworks[fireworksC]
Definition globals.cpp:118
s_network_objects playerships[MAX_SCAN]
Definition globals.cpp:112
RiseMath::Vector3 dockMarker
Definition globals.cpp:34
unsigned char ourmoonC
Definition globals.cpp:21
float f_BCL
Definition globals.cpp:12
std::vector< SShockWave > shockwaves
Definition globals.cpp:43
float f_compareFOV
Definition globals.cpp:81
float cash
Definition globals.cpp:93
bool g_bEnabled
Definition globals.cpp:96
float deathinhibit
Definition globals.cpp:39
s_universe_object allobjects[maxstarC]
Definition globals.cpp:108
Scockpit ourcockpit
Definition globals.cpp:114
float dockprogress
Definition globals.cpp:32
unsigned char cloudBaseObjC
Definition globals.cpp:22
bool g_bAboveClouds
Definition globals.cpp:16
float oldflasher
Definition globals.cpp:50
s_polygon_object polyobjects[maxpolyC]
Definition globals.cpp:106
LOCALGRID2 gridarray[64][64]
Definition globals.cpp:100
float g_fFOV
Definition globals.cpp:80
float f_Uphours
Definition globals.cpp:19
RiseMath::Vector3 dockInterface
Definition globals.cpp:35
unsigned char ourstarC
Definition globals.cpp:24
#define MAX_RAINDROPS
Definition globals.h:80
#define oneOvergForceKmssC
Definition globals.h:109
#define firework1C
Definition globals.h:60
#define firework3C
Definition globals.h:62
#define weaponlongarmreadyC
Definition globals.h:79
#define ScaleHeightC
Definition globals.h:98
#define radiusC
Definition globals.h:87
#define SeaLevelPressureMb
Definition globals.h:102
@ MidairCollision
Definition globals.h:156
@ Shockwave
Definition globals.h:160
@ VesselHadAProblem
Definition globals.h:158
@ ExplosiveDecompression
Definition globals.h:157
@ StructuralFailure
Definition globals.h:152
@ AccelerationLimit
Definition globals.h:153
@ ImNotDeadYet
Definition globals.h:150
#define weaponfuzerreadyC
Definition globals.h:77
#define cloudTopsRadiusC
Definition globals.h:112
#define maxcompareC
Definition globals.h:71
#define cloudTopsMslC
Definition globals.h:110
#define weaponsinkerreadyC
Definition globals.h:78
#define dockvertC
Definition globals.h:68
#define INTERIOR_SCALE
Definition globals.h:37
#define fireworksC
Definition globals.h:769
#define firework2C
Definition globals.h:61
#define SeaLevelDensityKgM3
Definition globals.h:99
#define maxstarC
Definition globals.h:33
#define gravityKmssC
Definition globals.h:88
#define heartanimateC
Definition globals.h:64
#define shipdockscaleC
Definition globals.h:36
#define OneAtmosphereMb
Definition globals.h:104
@ GUI_REMINDME
Definition gui.h:984
float Effort(float current, float baseline, float maximum)
Step Advance(float previous, float target, float baseline, float maximum, float dt, bool dead, float wakeFactor)
float VerticalGMultiplier(float verticalG)
float AdvanceFrame(float frame, float dt, float bpm, unsigned frameCount)
float Update(Component *components, std::size_t count, bool viewerInside)
constexpr unsigned char RequestType
float Severity(float x, float y, float z)
int HullDamage(float severity)
bool TriggersHornFault(float frontalSeverity, int hullBefore, int hullAfter, unsigned roll, unsigned maxRoll)
float FaultProbability(float severity)
bool TriggersFault(float severity, unsigned roll, unsigned maxRoll)
float HornFaultProbability(float frontalSeverity, int hullBefore, int hullAfter)
float ImpactSeverity(float x, float y, float z, float seconds)
int WindshieldAfterFrameDamage(int windshield, int hullBefore, int hullAfter)
float FallSpeedKms(float precipitation, float snow, unsigned group, float airDensityKgM3, float gravityMs2)
BasicParameters< RiseMath::Vector3, RiseMath::Color > Parameters
Definition ExteriorRain.h:7
double WingExcursion(double health)
Definition FlightLoads.h:15
bool OccupantExceeded(double side, double normal, double fore)
Definition FlightLoads.h:16
constexpr float MaximumForceG
float Bound(float value, float limit)
constexpr float MaximumPitchRadians
bool SettledForces(float x, float y, float z)
float AdvanceCounter(float previous, float force, float dt)
constexpr float MaximumRollRadians
float AdvanceLean(float previous, float target, float dt, float limit)
constexpr unsigned MaxLights
unsigned InstallationMismatch(unsigned modelCount, const char *health)
float Intensity(const Light &light, const RiseMath::Vector3 &delta)
std::array< RiseMath::Vector4, MaxLights > EmissionSources(const std::array< Light, MaxLights > &lights, unsigned count, const std::array< float, MaxLights > &brightness, const RiseMath::Matrix &modelToWorld)
constexpr unsigned DeviceSlots[MaxLights]
const char * BodySide(float x)
Light Transform(const Light &source, const RiseMath::Matrix &modelToWorld)
State Evaluate(int equipment, bool selected, bool operating, float power, bool engineAvailable)
Definition RainAir.h:10
float Flow(State state)
Definition RainAir.h:18
Conditions Resolve(float density, Vector3 airVelocity, float strengthOverride)
float UpdateBlackout(float thermalLoad, float &gammaOverride, bool simulator)
constexpr uint32_t SPOT
constexpr uint32_t DISCARD
constexpr uint32_t VIEW
HWND ClientWindow()
float ClientFPS()
RenderDevice * ClientRenderer()
constexpr PackedColor ColorARGB(unsigned a, unsigned r, unsigned g, unsigned b)
auto ToRadian(T value)
Definition ClientMath.h:13
float Vec3Length(const Vector3 *a)
Definition ClientMath.h:95
constexpr float Pi
Definition ClientMath.h:12
Vector3 * Vec3Cross(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:105
constexpr auto Min(A first, B second)
Definition ClientMath.h:15
Vector3 * Vec3TransformCoord(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:109
Vector3 * Vec3Add(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:96
Plane * PlaneFromPoints(Plane *out, const Vector3 *a, const Vector3 *b, const Vector3 *c)
Definition ClientMath.h:175
Matrix * MatrixRotationX(Matrix *out, float value)
Definition ClientMath.h:126
Quaternion * QuaternionMultiply(Quaternion *out, const Quaternion *a, const Quaternion *b)
Definition ClientMath.h:168
Matrix * MatrixMultiply(Matrix *out, const Matrix *a, const Matrix *b)
Definition ClientMath.h:116
Plane * PlaneNormalize(Plane *out, const Plane *a)
Definition ClientMath.h:180
Color * ColorLerp(Color *out, const Color *a, const Color *b, float t)
Definition ClientMath.h:173
Matrix * MatrixRotationQuaternion(Matrix *out, const Quaternion *q)
Definition ClientMath.h:135
Quaternion * QuaternionNormalize(Quaternion *out, const Quaternion *q)
Definition ClientMath.h:165
Vector3 * Vec3Lerp(Vector3 *out, const Vector3 *a, const Vector3 *b, float t)
Definition ClientMath.h:99
float Vec3LengthSq(const Vector3 *a)
Definition ClientMath.h:94
Vector3 * Vec3Subtract(Vector3 *out, const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:97
Quaternion * QuaternionRotationYawPitchRoll(Quaternion *out, float yaw, float pitch, float roll)
Definition ClientMath.h:169
Vector3 * Vec3TransformNormal(Vector3 *out, const Vector3 *a, const Matrix *m)
Definition ClientMath.h:107
Matrix * MatrixRotationY(Matrix *out, float value)
Definition ClientMath.h:127
Matrix * MatrixRotationYawPitchRoll(Matrix *out, float yaw, float pitch, float roll)
Definition ClientMath.h:137
Matrix * MatrixInverse(Matrix *out, float *determinant, const Matrix *a)
Definition ClientMath.h:118
constexpr float Tau
Definition ClientMath.h:12
Matrix * MatrixIdentity(Matrix *out)
Definition ClientMath.h:115
float QuaternionLength(const Quaternion *q)
Definition ClientMath.h:167
Quaternion * QuaternionSlerp(Quaternion *out, const Quaternion *a, const Quaternion *b, float t)
Definition ClientMath.h:171
Quaternion * QuaternionIdentity(Quaternion *out)
Definition ClientMath.h:164
Matrix * MatrixRotationAxis(Matrix *out, const Vector3 *axis, float angle)
Definition ClientMath.h:129
Plane * PlaneTransform(Plane *out, const Plane *a, const Matrix *matrix)
Definition ClientMath.h:185
float Vec3Dot(const Vector3 *a, const Vector3 *b)
Definition ClientMath.h:93
Matrix * MatrixScaling(Matrix *out, float x, float y, float z)
Definition ClientMath.h:124
Vector3 * Vec3Normalize(Vector3 *out, const Vector3 *a)
Definition ClientMath.h:103
Vector3 * Vec3Scale(Vector3 *out, const Vector3 *a, float scale)
Definition ClientMath.h:98
Matrix * MatrixTranspose(Matrix *out, const Matrix *a)
Definition ClientMath.h:117
Matrix * MatrixRotationZ(Matrix *out, float value)
Definition ClientMath.h:128
auto ToDegree(T value)
Definition ClientMath.h:14
constexpr auto Max(A first, B second)
Definition ClientMath.h:16
Matrix * MatrixTranslation(Matrix *out, float x, float y, float z)
Definition ClientMath.h:125
Vector3 * PlaneIntersectLine(Vector3 *out, const Plane *plane, const Vector3 *first, const Vector3 *second)
Definition ClientMath.h:191
constexpr float HalfPi
Definition ClientMath.h:12
void Apply(float mode, const RiseMath::Vector3 &outwardNormal, RiseMath::Matrix &sunWorld, RiseMath::Vector3 &incomingLight)
double MonotonicSeconds()
SnapshotSystem gSnapshotSystem
bool ShouldBufferVehicleReference(int reference)
bool DisplayAllowed(bool simulator, bool groundVehicle, float power)
Command SetPressed(bool &current, bool pressed)
Definition VehicleHorn.h:10
constexpr bool AcrossCloudDeck(float observerMslKm, float targetMslKm, float topMslKm=10.f)
float ExteriorDropOpacity(int index, float intensity, int maximum)
float PrecipitationIntensity(float precipitation, float altitudeKm=0.f)
float LiquidRainIntensity(float precipitation, float snowBlend, bool exposed, float altitudeKm=0.f)
float CloudRainFactor(float density, float belowBaseKm, bool volumeEnabled)
int ExteriorDropCount(float intensity, int maximum)
bool SetEnabled(bool &current, bool enabled)
bool Begin(double seconds)
int Apply(int health, float severity)
std::string name
Definition Command.h:11
float delay
Definition Command.h:8
bool inuse
Definition globals.h:772
short texture
Definition globals.h:773
bool UsesMouse() const
Definition InputConfig.h:24
RiseMath::Vector3 position
Definition globals.h:273
RiseMath::Color emissive
Definition globals.h:274
void Update(float target, float dt, bool allowed, uint64_t id)
RiseMath::Vector3 Direction
RiseMath::Color Diffuse
unsigned char type
unsigned char array
unsigned char ship
unsigned char inarray
unsigned char type
unsigned char queueani
unsigned char bldg
unsigned char age
unsigned char ani
float timetoshock
Definition globals.h:818
RiseMath::Vector3 shockmag
Definition globals.h:822
float shockspeed
Definition globals.h:820
float shockramp
Definition globals.h:819
char weapontype[MAX_WEAPPERSHIP]
char leftengine
char hullintegrity
char windshield
char rightStrut
char leftwing
char landing[2]
char noseStrut
char rightwing
char rightengine
char leftStrut
signed char rainAir
char clengine
float end
Definition globals.h:809
RiseMath::Vector3 xyz
Definition globals.h:811
float startupextend
Definition globals.h:599
short scanDisplayVesselLimit
Definition globals.h:725
float suspensionSpringFrequencyHz
Definition globals.h:621
int inventoryItemInUseSubType
Definition globals.h:700
float maxGrossLbs
Definition globals.h:634
short texturelib
Definition globals.h:602
float dockOffsetKmZ
Definition globals.h:722
float chairfwdeye
Definition globals.h:613
float impatientime
Definition globals.h:685
short ourplyrC
Definition globals.h:682
float moving
Definition globals.h:683
float dockOffsetKmY
Definition globals.h:723
float power
Definition globals.h:599
float flapExtent
Definition globals.h:660
unsigned short components
Definition globals.h:626
int landingDamageVehicleId
Definition globals.h:606
float suspensionVisualLeanScale
Definition globals.h:623
std::array< LandingLights::ImpactCondition, LandingLights::MaxLights > landingLightImpact
Definition globals.h:608
float dockingOrientationZ
Definition globals.h:724
SVesselDC vdat
Definition globals.h:664
std::array< LandingLights::Condition, LandingLights::MaxLights > landingLightCondition
Definition globals.h:607
std::array< float, LandingLights::MaxLights > landingLightBrightness
Definition globals.h:609
float maxPressureDiffMb
Definition globals.h:635
float gearextent
Definition globals.h:617
float flapMaxDegrees
Definition globals.h:714
float scanrange
Definition globals.h:670
float suspensionDampingRatio
Definition globals.h:621
std::array< LandingLights::Light, LandingLights::MaxLights > landingLights
Definition globals.h:604
float suspensionTravelKm
Definition globals.h:618
float adrenolinBPM
Definition globals.h:741
float suspensionTrackWidthKm
Definition globals.h:619
float suspensionLateralLoadTransferPerG
Definition globals.h:622
bool vdatChanged
Definition globals.h:665
float suspensionStaticSagRatio
Definition globals.h:620
char startcycle
Definition globals.h:599
bool sentgearvoice
Definition globals.h:625
unsigned char hitpoints
Definition globals.h:686
float bmi
Definition globals.h:739
float turnin
Definition globals.h:684
RiseMath::Vector3 chaireye
Definition globals.h:615
bool spaceCapable
Definition globals.h:596
char engines
Definition globals.h:630
int inventoryItemInUseType
Definition globals.h:699
float vdatTime
Definition globals.h:666
float suspensionWheelbaseKm
Definition globals.h:619
float maxBPM
Definition globals.h:740
s_mesh_component * componentarray
Definition globals.h:704
unsigned landingLightMismatchReported
Definition globals.h:610
RiseMath::Vector3 position
Definition globals.h:616
unsigned landingLightCount
Definition globals.h:605
float chairFwdRemaining
Definition globals.h:613
float suspensionLongitudinalLoadTransferPerG
Definition globals.h:622
void Update(float elapsed, bool enabled, bool powered=true)
float timer[PlotType::PlotTypeEnum]
Definition globals.h:480
unsigned long compare[PlotType::PlotTypeEnum]
Definition globals.h:479
float speed[PlotType::PlotTypeEnum]
Definition globals.h:480
RiseMath::Vector3 normal
Definition globals.h:350
RiseMath::Vector3 position
Definition globals.h:350
unsigned long sequencing
Definition globals.h:352
short attachto
Definition globals.h:354
RiseMath::Color diffuse
Definition globals.h:351
unsigned char primitive
Definition globals.h:349
RiseMath::Matrix matWorld
Definition globals.h:425
RiseMath::Vector3 nominalypr
Definition globals.h:414
float speedExtend
Definition globals.h:409
RiseMath::Vector3 hingeCG
Definition globals.h:420
float speedRetract
Definition globals.h:409
RiseMath::Vector3 barycentric
Definition globals.h:500
RiseMath::Quaternion orientation
Definition globals.h:521
RiseMath::Vector3 acciter
Definition globals.h:504
RiseMath::Vector3 dockingvel
Definition globals.h:500
RiseMath::Color emissive
Definition globals.h:487
RiseMath::Vector3 position
Definition globals.h:511
RiseMath::Vector3 positer
Definition globals.h:501
RiseMath::Vector3 accleft
Definition globals.h:504
unsigned short components
Definition globals.h:551
double precisionz
Definition globals.h:512
unsigned long compare
Definition globals.h:514
RiseMath::Vector3 acc
Definition globals.h:504
bool inhibitvisibility
Definition globals.h:528
unsigned char type
Definition globals.h:488
RiseMath::Quaternion orientleft
Definition globals.h:521
bool rainProtectionEnabled
Definition globals.h:532
RiseMath::Vector3 dockoffset
Definition globals.h:511
RiseMath::Matrix matrixInvOrientation
Definition globals.h:519
RiseMath::Vector3 velleft
Definition globals.h:501
unsigned short vehicleId
Definition globals.h:537
s_mesh_component * componentarray
Definition globals.h:552
double precisiony
Definition globals.h:512
RiseMath::Quaternion orientiter
Definition globals.h:521
RiseMath::Vector3 posleft
Definition globals.h:501
RiseMath::Vector3 velocity
Definition globals.h:500
float rollRadPerSec
Definition globals.h:523
WindshieldWipers::Motion wipers
Definition globals.h:535
double precisionx
Definition globals.h:512
unsigned char inarray
Definition globals.h:509
float baydoorextent
Definition globals.h:539
RiseMath::Vector3 veliter
Definition globals.h:501
RiseMath::Matrix matrixBase
Definition globals.h:519
RiseMath::Matrix matrixExterior
Definition globals.h:518
RiseMath::Matrix matrixWorld
Definition globals.h:517
RiseMath::Vector3 center[4500]
Definition globals.h:342
RiseVertexVertex * vertexbackup
Definition globals.h:341
short index[4500]
Definition globals.h:343
std::vector< s_light_effect > effects
Definition globals.h:361
RiseMath::Matrix matrixBase
Definition globals.h:452
s_mesh_component * componentarray
Definition globals.h:458
RiseMath::Vector3 velocity
Definition globals.h:461
RiseMath::Quaternion orientation
Definition globals.h:460
RiseMath::Matrix matrixWorld
Definition globals.h:452
RiseMath::Vector3 position
Definition globals.h:454
unsigned short components
Definition globals.h:457
RiseMath::Matrix matrixReal
Definition globals.h:452
unsigned long compare
Definition globals.h:467