18#define rangelim(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
19#define myfloor(x) ((x) < 0.0 ? (int)(x) - 1 : (int)(x))
21#define SWAP(t, x, y) do { \
33 return (
p >= 0 ?
p :
p - d + 1) / d;
72 container = (
p >= 0 ?
p :
p - d + 1) / d;
93 p.X >= 0 &&
p.X < d &&
94 p.Y >= 0 &&
p.Y < d &&
102 p.X >= 0 &&
p.X < d &&
110 p.X >= 0 &&
p.X < d.X &&
111 p.Y >= 0 &&
p.Y < d.Y &&
112 p.Z >= 0 &&
p.Z < d.Z
118 SWAP(s16, p1.X, p2.X);
120 SWAP(s16, p1.Y, p2.Y);
122 SWAP(s16, p1.Z, p2.Z);
190 return fmodf(f, 360.0f);
199 return value < 0 ? value + 360 : value;
213 value_v3f.X = value_v3f.X < 0 ? value_v3f.X + 360 : value_v3f.X;
214 value_v3f.Y = value_v3f.Y < 0 ? value_v3f.Y + 360 : value_v3f.Y;
215 value_v3f.Z = value_v3f.Z < 0 ? value_v3f.Z + 360 : value_v3f.Z;
233#define MYRAND_RANGE 0xffffffff
235void mysrand(
unsigned int seed);
257 u32 mask = (1 << len) - 1;
258 return (x >> pos) & mask;
261inline void set_bits(u32 *x, u32 pos, u32 len, u32 val)
263 u32 mask = (1 << len) - 1;
264 *x &= ~(mask << pos);
265 *x |= (val & mask) << pos;
274 return (0x6996 >> v) & 1;
280 f32 camera_fov, f32 range, f32 *distance_ptr=NULL);
290 return (s32)(f < 0.f ? (f - 0.5f) : (f + 0.5f));
293inline constexpr f32
sqr(f32 f)
304 (
p.X + (
p.X > 0 ? d / 2 : -d / 2)) / d,
305 (
p.Y + (
p.Y > 0 ? d / 2 : -d / 2)) / d,
306 (
p.Z + (
p.Z > 0 ? d / 2 : -d / 2)) / d);
315 (
p.X + (
p.X > 0 ? d / 2 : -d / 2)) / d,
316 (
p.Y + (
p.Y > 0 ? d / 2 : -d / 2)) / d,
317 (
p.Z + (
p.Z > 0 ? d / 2 : -d / 2)) / d);
336 (
float)
p.X * d - 0.5f * d,
337 (
float)
p.Y * d - 0.5f * d,
338 (
float)
p.Z * d - 0.5f * d,
339 (
float)
p.X * d + 0.5f * d,
340 (
float)
p.Y * d + 0.5f * d,
341 (
float)
p.Z * d + 0.5f * d
356 bool step(
float dtime,
float wanted_interval)
383inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex)
385 if (length < 1 || pagecount < 1 || page < 1 || page > pagecount) {
387 minindex = maxindex = 0;
388 }
else if(pagecount <= length) {
391 minindex = (length * (page-1) + (pagecount-1)) / pagecount;
392 maxindex = (length * page + (pagecount-1)) / pagecount;
408 if (value + by < 0)
return value + by + max;
409 if (value + by > max)
return value + by - max;
415 return n != 0 && (n & (n - 1)) == 0;
437 unsigned s = b - a, l =
static_cast<unsigned>(maximum - b) + a + 1;
438 return std::min(s, l);
447 T delta = target - current;
451 if (delta > stepsize && maximum - delta > stepsize) {
452 current += (delta < maximum / 2) ? stepsize : -stepsize;
453 if (current >= maximum)
477 return irr::video::SColor(color.getAlpha(),
478 core::clamp<u32>(color.getRed() * mod, 0, 255),
479 core::clamp<u32>(color.getGreen() * mod, 0, 255),
480 core::clamp<u32>(color.getBlue() * mod, 0, 255));
484template <
typename T>
inline T
numericSign(T v) {
return T(v < 0 ? -1 : (v == 0 ? 0 : 1)); }
#define MYMIN(a, b)
Definition basic_macros.h:9
#define MYMAX(a, b)
Definition basic_macros.h:11
float m_accumulator
Definition numeric.h:366
IntervalLimiter()=default
bool step(float dtime, float wanted_interval)
Definition numeric.h:356
#define BS
Definition constants.h:61
#define MAP_BLOCKSIZE
Definition constants.h:64
core::aabbox3d< f32 > aabb3f
Definition irr_aabb3d.h:11
core::vector2d< s16 > v2s16
Definition irr_v2d.h:12
core::vector3d< double > v3d
Definition irr_v3d.h:12
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
s16 getContainerPos(s16 p, s16 d)
Definition numeric.h:31
v3s16 componentwise_max(const v3s16 &a, const v3s16 &b)
Definition numeric.h:130
v3f getPitchYawRollRad(const core::matrix4 &m)
Definition numeric.cpp:196
v3s16 componentwise_min(const v3s16 &a, const v3s16 &b)
Definition numeric.h:125
bool isInArea(v3s16 p, s16 d)
Definition numeric.h:90
void wrappedApproachShortest(T ¤t, const T target, const T stepsize, const T maximum)
Definition numeric.h:444
T numericAbsolute(T v)
Definition numeric.h:483
v3s16 floatToInt(v3f p, f32 d)
Definition numeric.h:301
u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed)
Definition numeric.cpp:54
T numericSign(T v)
Definition numeric.h:484
float wrapDegrees_0_360(float f)
Returns f wrapped to the range [0, 360].
Definition numeric.h:196
u32 npot2(u32 orig)
Definition numeric.h:420
void setPitchYawRoll(core::matrix4 &m, v3f rot)
Definition numeric.h:462
v3f getPitchYawRoll(const core::matrix4 &m)
Definition numeric.h:469
constexpr f32 sqr(f32 f)
Definition numeric.h:293
v3f wrapDegrees_0_360_v3f(v3f v)
Returns v3f wrapped to the range [0, 360].
Definition numeric.h:205
s16 adjustDist(s16 dist, float zoom_fov)
Definition numeric.cpp:170
void set_bits(u32 *x, u32 pos, u32 len, u32 val)
Definition numeric.h:261
void setPitchYawRollRad(core::matrix4 &m, v3f rot)
Definition numeric.cpp:175
irr::video::SColor multiplyColorValue(const irr::video::SColor &color, float mod)
Definition numeric.h:475
u32 myrand()
Definition numeric.cpp:19
v3f intToFloat(v3s16 p, f32 d)
Definition numeric.h:323
u32 get_bits(u32 x, u32 pos, u32 len)
Definition numeric.h:255
float cycle_shift(float value, float by=0, float max=1)
Definition numeric.h:406
bool is_power_of_two(u32 n)
Definition numeric.h:413
bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 camera_fov, f32 range, f32 *distance_ptr=NULL)
Definition numeric.cpp:102
static constexpr const f32 BLOCK_MAX_RADIUS
Definition numeric.h:29
unsigned wrappedDifference(T a, T b, const T maximum)
Definition numeric.h:432
float modulo360f(float f)
Returns f wrapped to the range [-360, 360].
Definition numeric.h:188
v3s16 doubleToInt(v3d p, double d)
Definition numeric.h:312
#define MYRAND_RANGE
Definition numeric.h:233
float wrapDegrees_180(float f)
Returns f wrapped to the range [-180, 180].
Definition numeric.h:222
aabb3f getNodeBox(v3s16 p, float d)
Definition numeric.h:333
void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex)
Definition numeric.h:383
v3f vecAbsolute(v3f v)
Definition numeric.h:486
void sortBoxVerticies(v3s16 &p1, v3s16 &p2)
Definition numeric.h:116
void getContainerPosWithOffset(s16 p, s16 d, s16 &container, s16 &offset)
Definition numeric.h:70
#define SWAP(t, x, y)
Definition numeric.h:21
void mysrand(unsigned int seed)
Definition numeric.cpp:24
v3f vecSign(v3f v)
Definition numeric.h:495
float myrand_float()
Definition numeric.cpp:34
s32 myround(f32 f)
Definition numeric.h:288
int myrand_range(int min, int max)
Definition numeric.cpp:40
u32 calc_parity(u32 v)
Definition numeric.h:268
void myrand_bytes(void *out, size_t len)
Definition numeric.cpp:29
Describes a grid with given step, oirginating at (0,0,0)
Definition numeric.h:136
bool isMeshPos(v3s16 &p) const
Returns true if p is an origin of a cell in the grid.
Definition numeric.h:166
v3s16 getMeshPos(v3s16 p) const
Returns coordinates of the origin of the grid cell containing p.
Definition numeric.h:160
u16 cell_size
Definition numeric.h:137
s16 getCellPos(s16 p) const
returns coordinate of mesh cell given coordinate of a map block
Definition numeric.h:142
u32 getCellVolume() const
Definition numeric.h:139
v3s16 getCellPos(v3s16 block_pos) const
returns position of mesh cell in the grid given position of a map block
Definition numeric.h:148
s16 getMeshPos(s16 p) const
returns closest step of the grid smaller than p
Definition numeric.h:154
u16 getOffsetIndex(v3s16 offset) const
Returns index of the given offset in a grid cell All offset coordinates must be smaller than the size...
Definition numeric.h:175
static constexpr result_type max()
Definition numeric.h:245
u32 result_type
Definition numeric.h:243
static constexpr result_type min()
Definition numeric.h:244
result_type operator()()
Definition numeric.h:246
static std::string p(std::string path)
Definition test_filesys.cpp:53