Cache whether vehicle is currently drawn: Vehicle::IsDrawn()

This commit is contained in:
Jonathan G Rennison
2020-02-02 22:59:18 +00:00
parent 81a67b5b24
commit 76f68c48f5
13 changed files with 46 additions and 5 deletions

View File

@@ -134,7 +134,8 @@ enum GroundVehicleSubtypeFlags {
*/
enum VehicleCacheFlags {
VCF_LAST_VISUAL_EFFECT = 0, ///< Last vehicle in the consist with a visual effect.
VCF_GV_ZERO_SLOPE_RESIST = 1, ///< GrounVehicle: Consist has zero slope resistance (valid only for the first engine), may be false negative.
VCF_GV_ZERO_SLOPE_RESIST = 1, ///< GroundVehicle: Consist has zero slope resistance (valid only for the first engine), may be false negative.
VCF_IS_DRAWN = 2, ///< Vehicle is currently drawn
};
/** Cached often queried values common to all vehicles. */
@@ -1093,7 +1094,12 @@ public:
return v;
}
bool IsDrawn() const;
bool IsDrawn() const
{
return HasBit(this->vcache.cached_veh_flags, VCF_IS_DRAWN);
}
void UpdateIsDrawn();
inline void UpdateSpriteSeqBound()
{
@@ -1311,5 +1317,6 @@ inline void InvalidateVehicleTickCaches()
void ClearVehicleTickCaches();
void RemoveFromOtherVehicleTickCache(const Vehicle *v);
void UpdateAllVehiclesIsDrawn();
#endif /* VEHICLE_BASE_H */