Minetest  5.4.0
numeric.h File Reference
#include "basic_macros.h"
#include "irrlichttypes.h"
#include "irr_v2d.h"
#include "irr_v3d.h"
#include "irr_aabb3d.h"
#include "SColor.h"
#include <matrix4.h>
+ Include dependency graph for numeric.h:

Go to the source code of this file.

Classes

class  IntervalLimiter
 

Macros

#define rangelim(d, min, max)   ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))
 
#define myfloor(x)   ((x) < 0.0 ? (int)(x) - 1 : (int)(x))
 
#define SWAP(t, x, y)
 
#define MYRAND_RANGE   0xffffffff
 

Functions

s16 getContainerPos (s16 p, s16 d)
 
v2s16 getContainerPos (v2s16 p, s16 d)
 
v3s16 getContainerPos (v3s16 p, s16 d)
 
v2s16 getContainerPos (v2s16 p, v2s16 d)
 
v3s16 getContainerPos (v3s16 p, v3s16 d)
 
void getContainerPosWithOffset (s16 p, s16 d, s16 &container, s16 &offset)
 
void getContainerPosWithOffset (const v2s16 &p, s16 d, v2s16 &container, v2s16 &offset)
 
void getContainerPosWithOffset (const v3s16 &p, s16 d, v3s16 &container, v3s16 &offset)
 
bool isInArea (v3s16 p, s16 d)
 
bool isInArea (v2s16 p, s16 d)
 
bool isInArea (v3s16 p, v3s16 d)
 
void sortBoxVerticies (v3s16 &p1, v3s16 &p2)
 
v3s16 componentwise_min (const v3s16 &a, const v3s16 &b)
 
v3s16 componentwise_max (const v3s16 &a, const v3s16 &b)
 
float modulo360f (float f)
 Returns f wrapped to the range [-360, 360]. More...
 
float wrapDegrees_0_360 (float f)
 Returns f wrapped to the range [0, 360]. More...
 
v3f wrapDegrees_0_360_v3f (v3f v)
 Returns v3f wrapped to the range [0, 360]. More...
 
float wrapDegrees_180 (float f)
 Returns f wrapped to the range [-180, 180]. More...
 
u32 myrand ()
 
void mysrand (unsigned int seed)
 
void myrand_bytes (void *out, size_t len)
 
int myrand_range (int min, int max)
 
u32 get_bits (u32 x, u32 pos, u32 len)
 
void set_bits (u32 *x, u32 pos, u32 len, u32 val)
 
u32 calc_parity (u32 v)
 
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)
 
s32 myround (f32 f)
 
constexpr f32 sqr (f32 f)
 
v3s16 floatToInt (v3f p, f32 d)
 
v3s16 doubleToInt (v3d p, double d)
 
v3f intToFloat (v3s16 p, f32 d)
 
aabb3f getNodeBox (v3s16 p, float d)
 
void paging (u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex)
 
float cycle_shift (float value, float by=0, float max=1)
 
bool is_power_of_two (u32 n)
 
u32 npot2 (u32 orig)
 
template<typename T >
void wrappedApproachShortest (T &current, const T target, const T stepsize, const T maximum)
 
void setPitchYawRollRad (core::matrix4 &m, const v3f &rot)
 
void setPitchYawRoll (core::matrix4 &m, const v3f &rot)
 
v3f getPitchYawRollRad (const core::matrix4 &m)
 
v3f getPitchYawRoll (const core::matrix4 &m)
 
irr::video::SColor multiplyColorValue (const irr::video::SColor &color, float mod)
 

Macro Definition Documentation

◆ myfloor

#define myfloor (   x)    ((x) < 0.0 ? (int)(x) - 1 : (int)(x))

◆ MYRAND_RANGE

#define MYRAND_RANGE   0xffffffff

◆ rangelim

#define rangelim (   d,
  min,
  max 
)    ((d) < (min) ? (min) : ((d) > (max) ? (max) : (d)))

◆ SWAP

#define SWAP (   t,
  x,
 
)
Value:
do { \
t temp = x; \
x = y; \
y = temp; \
} while (0)

Function Documentation

◆ adjustDist()

s16 adjustDist ( s16  dist,
float  zoom_fov 
)

Referenced by RemoteClient::GetNextBlocks(), and Camera::updateViewingRange().

+ Here is the caller graph for this function:

◆ calc_parity()

u32 calc_parity ( u32  v)
inline

Referenced by ObjDefManager::createHandle(), and ObjDefManager::decodeHandle().

+ Here is the caller graph for this function:

◆ componentwise_max()

v3s16 componentwise_max ( const v3s16 a,
const v3s16 b 
)
inline

References MYMAX.

Referenced by MinimapUpdateThread::getMap().

+ Here is the caller graph for this function:

◆ componentwise_min()

v3s16 componentwise_min ( const v3s16 a,
const v3s16 b 
)
inline

References MYMIN.

Referenced by MinimapUpdateThread::getMap().

+ Here is the caller graph for this function:

◆ cycle_shift()

float cycle_shift ( float  value,
float  by = 0,
float  max = 1 
)
inline

◆ doubleToInt()

v3s16 doubleToInt ( v3d  p,
double  d 
)
inline

References p().

Referenced by check_v3s16(), and read_v3s16().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ floatToInt()

◆ get_bits()

u32 get_bits ( u32  x,
u32  pos,
u32  len 
)
inline

Referenced by ObjDefManager::decodeHandle().

+ Here is the caller graph for this function:

◆ getContainerPos() [1/5]

s16 getContainerPos ( s16  p,
s16  d 
)
inline

References p().

Referenced by RollbackAction::applyRevert(), AreaStore::getAreasForPos(), getContainerPos(), EmergeManager::getContainingChunk(), getNodeBlockPos(), and ModApiEnvMod::l_fix_light().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContainerPos() [2/5]

v2s16 getContainerPos ( v2s16  p,
s16  d 
)
inline

References getContainerPos(), and p().

+ Here is the call graph for this function:

◆ getContainerPos() [3/5]

v2s16 getContainerPos ( v2s16  p,
v2s16  d 
)
inline

References getContainerPos(), and p().

+ Here is the call graph for this function:

◆ getContainerPos() [4/5]

v3s16 getContainerPos ( v3s16  p,
s16  d 
)
inline

References getContainerPos(), and p().

+ Here is the call graph for this function:

◆ getContainerPos() [5/5]

v3s16 getContainerPos ( v3s16  p,
v3s16  d 
)
inline

References getContainerPos(), and p().

+ Here is the call graph for this function:

◆ getContainerPosWithOffset() [1/3]

void getContainerPosWithOffset ( const v2s16 p,
s16  d,
v2s16 container,
v2s16 offset 
)
inline

References getContainerPosWithOffset(), and p().

+ Here is the call graph for this function:

◆ getContainerPosWithOffset() [2/3]

void getContainerPosWithOffset ( const v3s16 p,
s16  d,
v3s16 container,
v3s16 offset 
)
inline

References getContainerPosWithOffset(), and p().

+ Here is the call graph for this function:

◆ getContainerPosWithOffset() [3/3]

void getContainerPosWithOffset ( s16  p,
s16  d,
s16 &  container,
s16 &  offset 
)
inline

References p().

Referenced by getContainerPosWithOffset(), and getNodeBlockPosWithOffset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodeBox()

aabb3f getNodeBox ( v3s16  p,
float  d 
)
inline

References p().

Referenced by collisionMoveSimple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPitchYawRoll()

v3f getPitchYawRoll ( const core::matrix4 &  m)
inline

References getPitchYawRollRad().

Referenced by roundTripsDeg(), and TestUtilities::testEulerConversion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPitchYawRollRad()

v3f getPitchYawRollRad ( const core::matrix4 &  m)

Referenced by getPitchYawRoll(), and TestUtilities::testEulerConversion().

+ Here is the caller graph for this function:

◆ intToFloat()

◆ is_power_of_two()

bool is_power_of_two ( u32  n)
inline

Referenced by ExtrusionMeshCache::create(), and TestUtilities::testIsPowerOfTwo().

+ Here is the caller graph for this function:

◆ isBlockInSight()

bool isBlockInSight ( v3s16  blockpos_b,
v3f  camera_pos,
v3f  camera_dir,
f32  camera_fov,
f32  range,
f32 *  distance_ptr = NULL 
)

References BS, MAP_BLOCKSIZE, and MYMAX.

Referenced by fillViewConeBlock(), RemoteClient::GetNextBlocks(), ClientMap::renderMap(), and ClientMap::updateDrawList().

+ Here is the caller graph for this function:

◆ isInArea() [1/3]

bool isInArea ( v2s16  p,
s16  d 
)
inline

References p().

+ Here is the call graph for this function:

◆ isInArea() [2/3]

bool isInArea ( v3s16  p,
s16  d 
)
inline

References p().

+ Here is the call graph for this function:

◆ isInArea() [3/3]

bool isInArea ( v3s16  p,
v3s16  d 
)
inline

References p().

+ Here is the call graph for this function:

◆ modulo360f()

float modulo360f ( float  f)
inline

Returns 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)

Referenced by Server::process_PlayerPos(), GenericCAO::step(), TestUtilities::testAngleWrapAround(), wrapDegrees_0_360(), wrapDegrees_0_360_v3f(), and wrapDegrees_180().

+ Here is the caller graph for this function:

◆ multiplyColorValue()

irr::video::SColor multiplyColorValue ( const irr::video::SColor &  color,
float  mod 
)
inline

Referenced by GUIButton::setFromStyle().

+ Here is the caller graph for this function:

◆ murmur_hash_64_ua()

u64 murmur_hash_64_ua ( const void *  key,
int  len,
unsigned int  seed 
)

References seed.

Referenced by check_field_or_nil(), getHashForString(), ModApiBase::l_deprecated_function(), and read_seed().

+ Here is the caller graph for this function:

◆ myrand()

u32 myrand ( )

References g_pcgrand, and PcgRandom::next().

Referenced by ObjDefManager::addRaw(), ABMHandler::apply(), Server::findSpawnPos(), TextureSource::generateImagePart(), OpenALSoundManager::getBuffer(), TestBase::getTestTempDirectory(), TestBase::getTestTempFile(), MapgenV6::placeTreesAndJungleGrass(), RandomInputHandler::Rand(), UDPSocket::Send(), and Sky::setStarCount().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myrand_bytes()

void myrand_bytes ( void *  out,
size_t  len 
)

References PcgRandom::bytes(), and g_pcgrand.

Referenced by MapgenParams::readParams().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myrand_range()

int myrand_range ( int  min,
int  max 
)

References g_pcgrand, and PcgRandom::range().

Referenced by ABMWithState::ABMWithState(), MapBlockMesh::animate(), Schematic::blitToVManip(), ClientMap::getBackgroundBrightness(), ClientLauncher::launch_game(), Schematic::placeOnMap(), Schematic::placeOnVManip(), and MapgenV6::placeTreesAndJungleGrass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ myround()

◆ mysrand()

void mysrand ( unsigned int  seed)

References g_pcgrand, PcgRandom::seed(), and seed.

Referenced by init_common().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ npot2()

u32 npot2 ( u32  orig)
inline

Referenced by createInventoryCubeImage(), and guiScalingResizeCached().

+ Here is the caller graph for this function:

◆ paging()

void paging ( u32  length,
u32  page,
u32  pagecount,
u32 &  minindex,
u32 &  maxindex 
)
inline

Referenced by Profiler::getPage().

+ Here is the caller graph for this function:

◆ set_bits()

void set_bits ( u32 *  x,
u32  pos,
u32  len,
u32  val 
)
inline

Referenced by ObjDefManager::createHandle(), and ObjDefManager::decodeHandle().

+ Here is the caller graph for this function:

◆ setPitchYawRoll()

void setPitchYawRoll ( core::matrix4 &  m,
const v3f rot 
)
inline

References setPitchYawRollRad().

Referenced by roundTripsDeg(), TestUtilities::testEulerConversion(), and GenericCAO::updateNodePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPitchYawRollRad()

void setPitchYawRollRad ( core::matrix4 &  m,
const v3f rot 
)

Referenced by setPitchYawRoll(), and TestUtilities::testEulerConversion().

+ Here is the caller graph for this function:

◆ sortBoxVerticies()

◆ sqr()

constexpr f32 sqr ( f32  f)
inlineconstexpr

Referenced by decode_light_f().

+ Here is the caller graph for this function:

◆ wrapDegrees_0_360()

float wrapDegrees_0_360 ( float  f)
inline

Returns f wrapped to the range [0, 360].

References modulo360f().

Referenced by Server::process_PlayerPos(), LuaEntitySAO::step(), GenericCAO::step(), TestUtilities::testAngleWrapAround(), GameUI::update(), Sky::update(), and yawToDirectionString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wrapDegrees_0_360_v3f()

v3f wrapDegrees_0_360_v3f ( v3f  v)
inline

Returns v3f wrapped to the range [0, 360].

References modulo360f().

Referenced by GenericCAO::processInitData(), GenericCAO::processMessage(), and TestUtilities::testWrapDegrees_0_360_v3f().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wrapDegrees_180()

float wrapDegrees_180 ( float  f)
inline

Returns f wrapped to the range [-180, 180].

References modulo360f().

Referenced by TestUtilities::testAngleWrapAround(), GameUI::update(), and GenericCAO::updateTexturePos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wrappedApproachShortest()

template<typename T >
void wrappedApproachShortest ( T &  current,
const T  target,
const T  stepsize,
const T  maximum 
)
inline

Referenced by LuaEntitySAO::step(), GenericCAO::step(), SmoothTranslatorWrapped::translate(), and SmoothTranslatorWrappedv3f::translate().

+ Here is the caller graph for this function: