aboutsummaryrefslogtreecommitdiff
path: root/advtrains/textures
ModeNameSize
-rwxr-xr-xadvtrains_across.png302logplain
-rwxr-xr-xadvtrains_across_anim.png524logplain
-rwxr-xr-xadvtrains_boiler.png413logplain
-rwxr-xr-xadvtrains_chimney.png309logplain
-rw-r--r--advtrains_copytool.png779logplain
-rwxr-xr-xadvtrains_couple.png339logplain
-rw-r--r--advtrains_cpl_lock.png209logplain
-rw-r--r--advtrains_cpl_unlock.png213logplain
-rwxr-xr-xadvtrains_discouple.png293logplain
-rwxr-xr-xadvtrains_driver_cab.png352logplain
-rwxr-xr-xadvtrains_dtrack_atc_placer.png1259logplain
-rwxr-xr-xadvtrains_dtrack_bumper_placer.png2213logplain
-rwxr-xr-xadvtrains_dtrack_detector_placer.png1253logplain
-rwxr-xr-xadvtrains_dtrack_load_placer.png1248logplain
-rwxr-xr-xadvtrains_dtrack_placer.png1097logplain
-rwxr-xr-xadvtrains_dtrack_rail.png4582logplain
-rwxr-xr-xadvtrains_dtrack_shared.png7141logplain
-rwxr-xr-xadvtrains_dtrack_shared_atc.png7215logplain
-rwxr-xr-xadvtrains_dtrack_shared_detector_off.png7180logplain
-rwxr-xr-xadvtrains_dtrack_shared_detector_on.png7181logplain
-rwxr-xr-xadvtrains_dtrack_shared_load.png7339logplain
-rwxr-xr-xadvtrains_dtrack_shared_unload.png7338logplain
-rwxr-xr-xadvtrains_dtrack_slopeplacer.png2415logplain
-rwxr-xr-xadvtrains_dtrack_unload_placer.png1260logplain
-rw-r--r--advtrains_hud_arrow.png91logplain
-rw-r--r--advtrains_hud_atc.png528logplain
-rw-r--r--advtrains_hud_bg.png67logplain
-rw-r--r--advtrains_hud_lzb.png398logplain
-rw-r--r--advtrains_hud_shunt.png476logplain
-rwxr-xr-xadvtrains_platform.png193logplain
-rw-r--r--advtrains_platform_diag.png93logplain
-rwxr-xr-xadvtrains_retrosignal.png8496logplain
-rwxr-xr-xadvtrains_retrosignal_inv.png2242logplain
-rwxr-xr-xadvtrains_signal_inv.png856logplain
-rwxr-xr-xadvtrains_signal_off.png5882logplain
-rwxr-xr-xadvtrains_signal_on.png5884logplain
-rwxr-xr-xadvtrains_signal_wall_off.png3056logplain
-rwxr-xr-xadvtrains_signal_wall_on.png3043logplain
-rwxr-xr-xadvtrains_track_cr.png33370logplain
-rwxr-xr-xadvtrains_track_cr_45.png33938logplain
-rwxr-xr-xadvtrains_track_placer.png32349logplain
-rwxr-xr-xadvtrains_track_st.png20405logplain
-rwxr-xr-xadvtrains_track_st_45.png39977logplain
-rwxr-xr-xadvtrains_track_swlcr.png33378logplain
-rwxr-xr-xadvtrains_track_swlcr_45.png45772logplain
-rwxr-xr-xadvtrains_track_swlst.png32321logplain
-rwxr-xr-xadvtrains_track_swlst_45.png46408logplain
-rwxr-xr-xadvtrains_track_swrcr.png33670logplain
-rwxr-xr-xadvtrains_track_swrcr_45.png46865logplain
-rwxr-xr-xadvtrains_track_swrst.png32654logplain
-rwxr-xr-xadvtrains_track_swrst_45.png47636logplain
-rwxr-xr-xadvtrains_trackworker.png328logplain
-rw-r--r--advtrains_wagon_placeholder.png723logplain
-rwxr-xr-xadvtrains_wheel.png582logplain
-rwxr-xr-xdrwho_screwdriver.png328logplain
">/** Returns \p f wrapped to the range [-360, 360] * * See test.cpp for example cases. * * \note This is also used in cases where degrees wrapped to the range [0, 360] * is innapropriate (e.g. pitch needs negative values) * * \internal functionally equivalent -- although precision may vary slightly -- * to fmodf((f), 360.0f) however empirical tests indicate that this approach is * faster. */ inline float modulo360f(float f) { int sign; int whole; float fraction; if (f < 0) { f = -f; sign = -1; } else { sign = 1; } whole = f; fraction = f - whole; whole %= 360; return sign * (whole + fraction); } /** Returns \p f wrapped to the range [0, 360] */ inline float wrapDegrees_0_360(float f) { float value = modulo360f(f); return value < 0 ? value + 360 : value; } /** Returns \p v3f wrapped to the range [0, 360] */ inline v3f wrapDegrees_0_360_v3f(v3f v) { v3f value_v3f; value_v3f.X = modulo360f(v.X); value_v3f.Y = modulo360f(v.Y); value_v3f.Z = modulo360f(v.Z); // Now that values are wrapped, use to get values for certain ranges value_v3f.X = value_v3f.X < 0 ? value_v3f.X + 360 : value_v3f.X; value_v3f.Y = value_v3f.Y < 0 ? value_v3f.Y + 360 : value_v3f.Y; value_v3f.Z = value_v3f.Z < 0 ? value_v3f.Z + 360 : value_v3f.Z; return value_v3f; } /** Returns \p f wrapped to the range [-180, 180] */ inline float wrapDegrees_180(float f) { float value = modulo360f(f + 180); if (value < 0) value += 360; return value - 180; } /* Pseudo-random (VC++ rand() sucks) */ #define MYRAND_RANGE 0xffffffff u32 myrand(); void mysrand(unsigned int seed); void myrand_bytes(void *out, size_t len); int myrand_range(int min, int max); /* Miscellaneous functions */ inline u32 get_bits(u32 x, u32 pos, u32 len) { u32 mask = (1 << len) - 1; return (x >> pos) & mask; } inline void set_bits(u32 *x, u32 pos, u32 len, u32 val) { u32 mask = (1 << len) - 1; *x &= ~(mask << pos); *x |= (val & mask) << pos; } inline u32 calc_parity(u32 v) { v ^= v >> 16; v ^= v >> 8; v ^= v >> 4; v &= 0xf; return (0x6996 >> v) & 1; } u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed); bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 camera_fov, f32 range, f32 *distance_ptr=NULL); s16 adjustDist(s16 dist, float zoom_fov); /* Returns nearest 32-bit integer for given floating point number. <cmath> and <math.h> in VC++ don't provide round(). */ inline s32 myround(f32 f) { return (s32)(f < 0.f ? (f - 0.5f) : (f + 0.5f)); } inline constexpr f32 sqr(f32 f) { return f * f; } /* Returns integer position of node in given floating point position */ inline v3s16 floatToInt(v3f p, f32 d) { return v3s16( (p.X + (p.X > 0 ? d / 2 : -d / 2)) / d, (p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d, (p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d); } /* Returns integer position of node in given double precision position */ inline v3s16 doubleToInt(v3d p, double d) { return v3s16( (p.X + (p.X > 0 ? d / 2 : -d / 2)) / d, (p.Y + (p.Y > 0 ? d / 2 : -d / 2)) / d, (p.Z + (p.Z > 0 ? d / 2 : -d / 2)) / d); } /* Returns floating point position of node in given integer position */ inline v3f intToFloat(v3s16 p, f32 d) { return v3f( (f32)p.X * d, (f32)p.Y * d, (f32)p.Z * d ); } // Random helper. Usually d=BS inline aabb3f getNodeBox(v3s16 p, float d) { return aabb3f( (float)p.X * d - 0.5f * d, (float)p.Y * d - 0.5f * d, (float)p.Z * d - 0.5f * d, (float)p.X * d + 0.5f * d, (float)p.Y * d + 0.5f * d, (float)p.Z * d + 0.5f * d ); } class IntervalLimiter { public: IntervalLimiter() = default; /* dtime: time from last call to this method wanted_interval: interval wanted return value: true: action should be skipped false: action should be done */ bool step(float dtime, float wanted_interval) { m_accumulator += dtime; if (m_accumulator < wanted_interval) return false; m_accumulator -= wanted_interval; return true; } private: float m_accumulator = 0.0f; }; /* Splits a list into "pages". For example, the list [1,2,3,4,5] split into two pages would be [1,2,3],[4,5]. This function computes the minimum and maximum indices of a single page. length: Length of the list that should be split page: Page number, 1 <= page <= pagecount pagecount: The number of pages, >= 1 minindex: Receives the minimum index (inclusive). maxindex: Receives the maximum index (exclusive). Ensures 0 <= minindex <= maxindex <= length. */ inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex) { if (length < 1 || pagecount < 1 || page < 1 || page > pagecount) { // Special cases or invalid parameters minindex = maxindex = 0; } else if(pagecount <= length) { // Less pages than entries in the list: // Each page contains at least one entry minindex = (length * (page-1) + (pagecount-1)) / pagecount; maxindex = (length * page + (pagecount-1)) / pagecount; } else { // More pages than entries in the list: // Make sure the empty pages are at the end if (page < length) { minindex = page-1; maxindex = page; } else { minindex = 0; maxindex = 0; } } } inline float cycle_shift(float value, float by = 0, float max = 1) { if (value + by < 0) return value + by + max; if (value + by > max) return value + by - max; return value + by; } inline bool is_power_of_two(u32 n) { return n != 0 && (n & (n - 1)) == 0; } // Compute next-higher power of 2 efficiently, e.g. for power-of-2 texture sizes. // Public Domain: https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 inline u32 npot2(u32 orig) { orig--; orig |= orig >> 1; orig |= orig >> 2; orig |= orig >> 4; orig |= orig >> 8; orig |= orig >> 16; return orig + 1; } // Gradual steps towards the target value in a wrapped (circular) system // using the shorter of both ways template<typename T> inline void wrappedApproachShortest(T &current, const T target, const T stepsize, const T maximum) { T delta = target - current; if (delta < 0) delta += maximum; if (delta > stepsize && maximum - delta > stepsize) { current += (delta < maximum / 2) ? stepsize : -stepsize; if (current >= maximum) current -= maximum; } else { current = target; } } void setPitchYawRollRad(core::matrix4 &m, const v3f &rot); inline void setPitchYawRoll(core::matrix4 &m, const v3f &rot) { setPitchYawRollRad(m, rot * core::DEGTORAD64); } v3f getPitchYawRollRad(const core::matrix4 &m); inline v3f getPitchYawRoll(const core::matrix4 &m) { return getPitchYawRollRad(m) * core::RADTODEG64; } // Muliply the RGB value of a color linearly, and clamp to black/white inline irr::video::SColor multiplyColorValue(const irr::video::SColor &color, float mod) { return irr::video::SColor(color.getAlpha(), core::clamp<u32>(color.getRed() * mod, 0, 255), core::clamp<u32>(color.getGreen() * mod, 0, 255), core::clamp<u32>(color.getBlue() * mod, 0, 255)); }