MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / GetTargetFrame

Function GetTargetFrame

src/openrct2/ride/Vehicle.Animation.cpp:903–913  ·  view source on GitHub ↗

* Get the frame of animation for the current animationState based on animation speed and animation frames */

Source from the content-addressed store, hash-verified

901 * Get the frame of animation for the current animationState based on animation speed and animation frames
902 */
903static uint8_t GetTargetFrame(const CarEntry& carEntry, uint32_t animationState)
904{
905 if (carEntry.AnimationSpeed == 0)
906 return 0;
907 auto targetFrame = animationState / (carEntry.AnimationSpeed << 2);
908 // mask of 0xFF
909 targetFrame &= std::numeric_limits<uint8_t>::max();
910 // multiply by number of frames. After the bitshift 8, the range will be 0 to AnimationFrames - 1
911 targetFrame *= carEntry.AnimationFrames;
912 return targetFrame >> std::numeric_limits<uint8_t>::digits;
913}
914
915/**
916 * Compute the position that steam should be spawned

Callers 3

AnimateSimpleVehicleFunction · 0.85
AnimateSteamLocomotiveFunction · 0.85
AnimateSwanBoatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected