30 #define rangelim(d, min, max) ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
31 #define myfloor(x) ((x) < 0.0 ? (int)(x) - 1 : (int)(x))
33 #define SWAP(t, x, y) do { \
42 return (
p >= 0 ?
p :
p - d + 1) / d;
81 container = (
p >= 0 ?
p :
p - d + 1) / d;
102 p.X >= 0 &&
p.X < d &&
103 p.Y >= 0 &&
p.Y < d &&
111 p.X >= 0 &&
p.X < d &&
119 p.X >= 0 &&
p.X < d.X &&
120 p.Y >= 0 &&
p.Y < d.Y &&
121 p.Z >= 0 &&
p.Z < d.Z
127 SWAP(s16, p1.X, p2.X);
129 SWAP(s16, p1.Y, p2.Y);
131 SWAP(s16, p1.Z, p2.Z);
171 fraction = f - whole;
174 return sign * (whole + fraction);
183 return value < 0 ? value + 360 : value;
197 value_v3f.X = value_v3f.X < 0 ? value_v3f.X + 360 : value_v3f.X;
198 value_v3f.Y = value_v3f.Y < 0 ? value_v3f.Y + 360 : value_v3f.Y;
199 value_v3f.Z = value_v3f.Z < 0 ? value_v3f.Z + 360 : value_v3f.Z;
217 #define MYRAND_RANGE 0xffffffff
229 u32 mask = (1 << len) - 1;
230 return (x >> pos) & mask;
233 inline void set_bits(u32 *x, u32 pos, u32 len, u32 val)
235 u32 mask = (1 << len) - 1;
236 *x &= ~(mask << pos);
237 *x |= (val & mask) << pos;
246 return (0x6996 >> v) & 1;
252 f32 camera_fov, f32 range, f32 *distance_ptr=NULL);
262 return (s32)(f < 0.f ? (f - 0.5f) : (f + 0.5f));
265 inline constexpr f32
sqr(f32 f)
276 (
p.X + (
p.X > 0 ? d / 2 : -d / 2)) / d,
277 (
p.Y + (
p.Y > 0 ? d / 2 : -d / 2)) / d,
278 (
p.Z + (
p.Z > 0 ? d / 2 : -d / 2)) / d);
287 (
p.X + (
p.X > 0 ? d / 2 : -d / 2)) / d,
288 (
p.Y + (
p.Y > 0 ? d / 2 : -d / 2)) / d,
289 (
p.Z + (
p.Z > 0 ? d / 2 : -d / 2)) / d);
308 (
float)
p.X * d - 0.5f * d,
309 (
float)
p.Y * d - 0.5f * d,
310 (
float)
p.Z * d - 0.5f * d,
311 (
float)
p.X * d + 0.5f * d,
312 (
float)
p.Y * d + 0.5f * d,
313 (
float)
p.Z * d + 0.5f * d
330 bool step(
float dtime,
float wanted_interval)
357 inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex)
359 if (length < 1 || pagecount < 1 || page < 1 || page > pagecount) {
361 minindex = maxindex = 0;
362 }
else if(pagecount <= length) {
365 minindex = (length * (page-1) + (pagecount-1)) / pagecount;
366 maxindex = (length * page + (pagecount-1)) / pagecount;
380 inline float cycle_shift(
float value,
float by = 0,
float max = 1)
382 if (value + by < 0)
return value + by + max;
383 if (value + by > max)
return value + by - max;
389 return n != 0 && (n & (n - 1)) == 0;
410 T delta = target - current;
414 if (delta > stepsize && maximum - delta > stepsize) {
415 current += (delta < maximum / 2) ? stepsize : -stepsize;
416 if (current >= maximum)
440 return irr::video::SColor(color.getAlpha(),
441 core::clamp<u32>(color.getRed() * mod, 0, 255),
442 core::clamp<u32>(color.getGreen() * mod, 0, 255),
443 core::clamp<u32>(color.getBlue() * mod, 0, 255));
#define MYMIN(a, b)
Definition: basic_macros.h:24
#define MYMAX(a, b)
Definition: basic_macros.h:26
Definition: numeric.h:319
float m_accumulator
Definition: numeric.h:340
IntervalLimiter()=default
bool step(float dtime, float wanted_interval)
Definition: numeric.h:330
core::aabbox3d< f32 > aabb3f
Definition: irr_aabb3d.h:26
core::vector2d< s16 > v2s16
Definition: irr_v2d.h:27
core::vector3d< double > v3d
Definition: irr_v3d.h:27
core::vector3d< s16 > v3s16
Definition: irr_v3d.h:28
core::vector3df v3f
Definition: irr_v3d.h:26
s16 getContainerPos(s16 p, s16 d)
Definition: numeric.h:40
v3s16 componentwise_max(const v3s16 &a, const v3s16 &b)
Definition: numeric.h:139
v3f getPitchYawRollRad(const core::matrix4 &m)
Definition: numeric.cpp:199
v3s16 componentwise_min(const v3s16 &a, const v3s16 &b)
Definition: numeric.h:134
bool isInArea(v3s16 p, s16 d)
Definition: numeric.h:99
void setPitchYawRollRad(core::matrix4 &m, const v3f &rot)
Definition: numeric.cpp:178
void wrappedApproachShortest(T ¤t, const T target, const T stepsize, const T maximum)
Definition: numeric.h:407
v3s16 floatToInt(v3f p, f32 d)
Definition: numeric.h:273
u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed)
Definition: numeric.cpp:58
float wrapDegrees_0_360(float f)
Returns f wrapped to the range [0, 360].
Definition: numeric.h:180
u32 npot2(u32 orig)
Definition: numeric.h:394
v3f getPitchYawRoll(const core::matrix4 &m)
Definition: numeric.h:432
constexpr f32 sqr(f32 f)
Definition: numeric.h:265
v3f wrapDegrees_0_360_v3f(v3f v)
Returns v3f wrapped to the range [0, 360].
Definition: numeric.h:189
s16 adjustDist(s16 dist, float zoom_fov)
Definition: numeric.cpp:166
void set_bits(u32 *x, u32 pos, u32 len, u32 val)
Definition: numeric.h:233
irr::video::SColor multiplyColorValue(const irr::video::SColor &color, float mod)
Definition: numeric.h:438
u32 myrand()
Definition: numeric.cpp:34
v3f intToFloat(v3s16 p, f32 d)
Definition: numeric.h:295
u32 get_bits(u32 x, u32 pos, u32 len)
Definition: numeric.h:227
float cycle_shift(float value, float by=0, float max=1)
Definition: numeric.h:380
bool is_power_of_two(u32 n)
Definition: numeric.h:387
bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 camera_fov, f32 range, f32 *distance_ptr=NULL)
Definition: numeric.cpp:106
float modulo360f(float f)
Returns f wrapped to the range [-360, 360].
Definition: numeric.h:156
v3s16 doubleToInt(v3d p, double d)
Definition: numeric.h:284
float wrapDegrees_180(float f)
Returns f wrapped to the range [-180, 180].
Definition: numeric.h:206
aabb3f getNodeBox(v3s16 p, float d)
Definition: numeric.h:305
void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex)
Definition: numeric.h:357
void sortBoxVerticies(v3s16 &p1, v3s16 &p2)
Definition: numeric.h:125
void getContainerPosWithOffset(s16 p, s16 d, s16 &container, s16 &offset)
Definition: numeric.h:79
#define SWAP(t, x, y)
Definition: numeric.h:33
void mysrand(unsigned int seed)
Definition: numeric.cpp:39
void setPitchYawRoll(core::matrix4 &m, const v3f &rot)
Definition: numeric.h:425
s32 myround(f32 f)
Definition: numeric.h:260
int myrand_range(int min, int max)
Definition: numeric.cpp:49
u32 calc_parity(u32 v)
Definition: numeric.h:240
void myrand_bytes(void *out, size_t len)
Definition: numeric.cpp:44
static std::random_device seed
Definition: serverenvironment.cpp:392
std::string p(std::string path)
Definition: test_filepath.cpp:59