Luanti 5.19.0-dev
Loading...
Searching...
No Matches
numeric.cpp File Reference
#include "numeric.h"
#include "constants.h"
#include "noise.h"
#include <cstring>
#include <cmath>
Include dependency graph for numeric.cpp:

Functions

u32 myrand ()
void mysrand (u64 seed)
void myrand_bytes (void *out, size_t len)
float myrand_float ()
int myrand_range (int min, int max)
float myrand_range (float min, float max)
u64 murmur_hash_64_ua (const void *key, size_t len, unsigned int seed)
 Calculate MurmurHash64A hash for an arbitrary block of data.
bool isBlockInSight (const v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, const f32 camera_fov, const f32 range, f32 *distance_ptr)
bool isBlockInSightEx (const v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, const f32 target_cos_sq, const f32 adjdist, f32 range, f32 *distance_ptr)
float adjustDist (float dist, float zoom_fov)
s16 adjustDist (s16 dist, float zoom_fov)
void setPitchYawRollRad (core::matrix4 &m, v3f rot)
v3f getPitchYawRollRad (const core::matrix4 &m)

Variables

static PcgRandom g_pcgrand

Function Documentation

◆ adjustDist() [1/2]

float adjustDist ( float dist,
float zoom_fov )
inline

References adjustDist().

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

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

◆ adjustDist() [2/2]

s16 adjustDist ( s16 dist,
float zoom_fov )

References adjustDist().

Here is the call graph for this function:

◆ getPitchYawRollRad()

v3f getPitchYawRollRad ( const core::matrix4 & m)
See also
setPitchYawRollRad

References getPitchYawRollRad().

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

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

◆ isBlockInSight()

bool isBlockInSight ( const v3s16 blockpos_b,
v3f camera_pos,
v3f camera_dir,
const f32 camera_fov,
const f32 range,
f32 * distance_ptr = nullptr )
Parameters
blockpos_bposition of block in block coordinates
camera_posposition of camera in nodes
camera_diran unit vector pointing to camera direction
camera_fovin rad
rangeviewing range
distance_ptrreturn location for distance from the camera

References getFovAdj(), getFovCosSq(), isBlockInSight(), and isBlockInSightEx().

Referenced by fillViewConeBlock(), RemoteClient::GetNextBlocks(), isBlockInSight(), and TestUtilities::testIsBlockInSight().

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

◆ isBlockInSightEx()

bool isBlockInSightEx ( const v3s16 blockpos_b,
v3f camera_pos,
v3f camera_dir,
const f32 target_cos_sq,
const f32 adjdist,
const f32 range,
f32 * distance_ptr )
Parameters
blockpos_bposition of block in block coordinates
camera_posposition of camera in nodes
camera_diran unit vector pointing to camera direction
target_cos_sqpre-computed adjusted cos^2(camera fov) (use getFovCosSq(...))
adjdistpre-computed camera distance adjustment (use getFovAdj(...))
rangeviewing range
distance_ptrreturn location for distance from the camera

References BS, intToFloat(), isBlockInSightEx(), and MAP_BLOCKSIZE.

Referenced by RemoteClient::GetNextBlocks(), isBlockInSight(), and isBlockInSightEx().

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

◆ murmur_hash_64_ua()

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

Calculate MurmurHash64A hash for an arbitrary block of data.

Parameters
keydata to hash (does not need to be aligned)
lenlength in bytes
seedinitial seed value
Returns
hash value

References murmur_hash_64_ua().

Referenced by check_field_or_nil(), getHashForString(), init_common(), ModApiBase::l_deprecated_function(), logOnce(), murmur_hash_64_ua(), read_seed(), and script_log_unique().

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

◆ myrand()

u32 myrand ( )

References g_pcgrand, myrand(), and PcgRandom::next().

Referenced by Sky::Sky(), ObjDefManager::addRaw(), ScriptApiServer::allocateDynamicMediaCallback(), ISoundManager::allocateId(), ABMHandler::apply(), Game::createClient(), ImageSource::generateImagePart(), sound::OpenALSoundManager::getLoadedSoundNameFromGroup(), TestBase::getTestTempFile(), myrand(), MyRandGenerator::operator()(), MapgenV6::placeTreesAndJungleGrass(), RandomInputHandler::Rand(), and UDPSocket::Send().

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(), g_pcgrand, and myrand_bytes().

Referenced by GUIDGenerator::GUIDGenerator(), httpfetch_caller_alloc_secure(), myrand_bytes(), and MapgenParams::readParams().

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

◆ myrand_float()

float myrand_float ( )

References g_pcgrand, myrand_float(), PcgRandom::next(), and U32_MAX.

Referenced by myrand_float(), myrand_range(), ParticleParamTypes::RangedParameter< T >::pickWithin(), and ParticleSpawner::step().

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

◆ myrand_range() [1/2]

float myrand_range ( float min,
float max )

References myrand_float(), and myrand_range().

Here is the call graph for this function:

◆ myrand_range() [2/2]

int myrand_range ( int min,
int max )

References g_pcgrand, myrand_range(), and PcgRandom::range().

Referenced by ABMWithState::ABMWithState(), ParticleManager::addNodeParticle(), MapBlockMesh::animate(), benchGetObjectsInArea(), ParticleParamTypes::TweenedParameter< T >::blend(), Schematic::blitToVManip(), con::Connection::createPeer(), Server::findSpawnPos(), ClientMap::getBackgroundBrightness(), ParticleManager::getNodeParticleParams(), myrand_range(), myrand_range(), Schematic::placeOnMap(), Schematic::placeOnVManip(), MapgenV6::placeTreesAndJungleGrass(), readRandomBlocks(), and ParticleSpawner::spawnParticle().

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

◆ mysrand()

void mysrand ( u64 seed)

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

Referenced by init_common(), and mysrand().

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

◆ setPitchYawRollRad()

void setPitchYawRollRad ( core::matrix4 & m,
v3f rot )
Note
Uses (extrinsic) Z-X-Y rotation order, left-handed rotation
This is not consistent with matrix4::setRotationRadians

References setPitchYawRollRad().

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

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

Variable Documentation

◆ g_pcgrand

PcgRandom g_pcgrand
static