OpenClonk
C4Real.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  C4Fixed
 

Macros

#define C4REAL_USE_FIXNUM   1
 
#define inline   ALWAYS_INLINE
 
#define FIXED_SHIFT   16
 
#define FIXED_FPF   int32_t(1 << FIXED_SHIFT)
 

Typedefs

typedef C4Fixed C4Real
 

Functions

float fixtof (const C4Fixed &x)
 
C4Fixed ftofix (float x)
 
int fixtoi (const C4Fixed &x)
 
int fixtoi (const C4Fixed &x, int32_t prec)
 
C4Fixed itofix (int32_t x)
 
C4Fixed itofix (int32_t x, int32_t prec)
 
C4Real Sin (const C4Real &fAngle)
 
C4Real Cos (const C4Real &fAngle)
 
C4Real C4REAL100 (int x)
 
C4Real C4REAL256 (int x)
 
C4Real C4REAL10 (int x)
 
void FLOAT_TO_FIXED (C4Real *pVal)
 
void CompileFunc (C4Real &rValue, StdCompiler *pComp)
 

Variables

long SineTable [9001]
 
const C4Real Fix0 = itofix(0)
 
const C4Real Fix1 = itofix(1)
 

Macro Definition Documentation

◆ C4REAL_USE_FIXNUM

#define C4REAL_USE_FIXNUM   1

Definition at line 36 of file C4Real.h.

◆ FIXED_FPF

#define FIXED_FPF   int32_t(1 << FIXED_SHIFT)

Definition at line 56 of file C4Real.h.

◆ FIXED_SHIFT

#define FIXED_SHIFT   16

Definition at line 54 of file C4Real.h.

◆ inline

#define inline   ALWAYS_INLINE

Definition at line 37 of file C4Real.h.

Typedef Documentation

◆ C4Real

typedef C4Fixed C4Real

Definition at line 254 of file C4Real.h.

Function Documentation

◆ C4REAL10()

C4Real C4REAL10 ( int  x)
inline

Definition at line 269 of file C4Real.h.

269 { return itofix(x, 10); }
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261

References itofix().

Referenced by C4Game::CastObjects(), C4MCOverlay::CheckMask(), C4Landscape::InsertMaterial(), and ObjectComDrop().

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

◆ C4REAL100()

C4Real C4REAL100 ( int  x)
inline

Definition at line 267 of file C4Real.h.

267 { return itofix(x, 100); }

References itofix().

Referenced by C4Object::ContactAction(), C4Sky::Execute(), C4Command::MoveTo(), mrfInsertCheck(), C4MaterialMap::mrfScript(), ObjectActionThrow(), ObjectComDrop(), ObjectComJump(), ObjectComPunch(), C4Command::Put(), C4Landscape::ScenarioInit(), and C4Command::Throw().

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

◆ C4REAL256()

C4Real C4REAL256 ( int  x)
inline

Definition at line 268 of file C4Real.h.

268 { C4Fixed r; r.val = x * FIXED_FPF / 256; return r; }
#define FIXED_FPF
Definition: C4Real.h:56
Definition: C4Real.h:59
int32_t val
Definition: C4Real.h:73

References FIXED_FPF, and C4Fixed::val.

Referenced by C4PXS::Execute().

Here is the caller graph for this function:

◆ CompileFunc()

void CompileFunc ( C4Real rValue,
StdCompiler pComp 
)

Definition at line 70 of file C4Real.cpp.

9034 {
9035 #ifdef C4REAL_USE_FIXNUM
9036  char cFormat = 'F';
9037 #else
9038  char cFormat = 'f';
9039 #endif
9040  try
9041  {
9042  // Read/write type
9043  pComp->Character(cFormat);
9044 
9045  }
9046  catch (StdCompiler::NotFoundException *pEx)
9047  {
9048  delete pEx;
9049  // Expect old format if not found
9050  cFormat = 'F';
9051  }
9052  // Read value (as int32_t)
9053  pComp->Value(mkCastAdapt<int32_t>(rValue));
9054  // convert, if neccessary
9055 #ifdef C4REAL_USE_FIXNUM
9056  if (cFormat == 'f')
9057  FLOAT_TO_FIXED(&rValue);
9058 #else
9059  if (cFormat == 'F')
9060  FIXED_TO_FLOAT(&rValue);
9061 #endif
9062 }
void FLOAT_TO_FIXED(C4Real *pVal)
Definition: C4Real.h:318
virtual void Character(char &rChar)=0
void Value(const T &rStruct)
Definition: StdCompiler.h:161

Referenced by C4ValueProviderLinear::CompileFunc(), C4ValueProviderX::CompileFunc(), C4ValueProviderY::CompileFunc(), C4ValueProviderR::CompileFunc(), C4ValueProviderAbsX::CompileFunc(), C4ValueProviderAbsY::CompileFunc(), C4ValueProviderDist::CompileFunc(), C4ValueProviderXDir::CompileFunc(), C4ValueProviderYDir::CompileFunc(), C4ValueProviderRDir::CompileFunc(), C4ValueProviderAbsRDir::CompileFunc(), C4ValueProviderCosR::CompileFunc(), C4ValueProviderSinR::CompileFunc(), C4ValueProviderCosV::CompileFunc(), C4ValueProviderSinV::CompileFunc(), and C4ValueProviderAction::CompileFunc().

Here is the caller graph for this function:

◆ Cos()

C4Real Cos ( const C4Real fAngle)
inline

Definition at line 266 of file C4Real.h.

266 { return fAngle.cos_deg(); }
C4Fixed cos_deg() const
Definition: C4Real.h:233

References C4Fixed::cos_deg().

Referenced by C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MCOverlay::CheckMask(), C4Weather::Execute(), C4ValueProviderCosR::Execute(), C4ValueProviderCosV::Execute(), InitCoreFunctionMap(), C4SolidMask::Put(), and C4Shape::Rotate().

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

◆ fixtof()

float fixtof ( const C4Fixed x)
inline

Definition at line 257 of file C4Real.h.

257 { return x.to_float(); }

Referenced by C4Viewport::AdjustPosition(), C4PXSSystem::Draw(), C4Sky::Draw(), C4Object::Draw(), C4ParticleChunk::Draw(), C4Object::DrawActionFace(), C4Game::DrawCrewOverheadText(), C4Object::DrawFace(), C4Object::DrawFaceImpl(), StdMeshInstanceAnimationNode::GetBoneTransform(), C4Object::GetDrawPosition(), C4Object::GetViewPosPar(), C4Player::ZoomLimitsToViewport(), and C4Player::ZoomToViewport().

Here is the caller graph for this function:

◆ fixtoi() [1/2]

◆ fixtoi() [2/2]

int fixtoi ( const C4Fixed x,
int32_t  prec 
)
inline

Definition at line 260 of file C4Real.h.

260 { return x.to_int(prec); }

◆ FLOAT_TO_FIXED()

void FLOAT_TO_FIXED ( C4Real pVal)
inline

Definition at line 318 of file C4Real.h.

319 {
320  *pVal = ftofix (*reinterpret_cast<float *>(pVal));
321 }
C4Fixed ftofix(float x)
Definition: C4Real.h:258

References ftofix().

Referenced by C4PXSSystem::Load().

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

◆ ftofix()

C4Fixed ftofix ( float  x)
inline

Definition at line 258 of file C4Real.h.

258 { return C4Fixed(x); }

Referenced by C4EditCursor::ApplyCreateObject(), CreateValueProviderFromArray(), C4Game::DropDef(), C4ValueProviderAction::Execute(), StdMeshInstance::ExecuteAnimationNode(), FLOAT_TO_FIXED(), C4EditCursor::Move(), StdMeshInstance::PlayAnimation(), C4Player::ScrollView(), StdMeshInstance::SetAnimationPosition(), and C4GraphicsOverlay::UpdateFacet().

Here is the caller graph for this function:

◆ itofix() [1/2]

C4Fixed itofix ( int32_t  x)
inline

Definition at line 261 of file C4Real.h.

261 { return C4Fixed(x); }

Referenced by C4Object::AdjustWalkRotation(), AlgoSin(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4REAL10(), C4REAL100(), C4PXSSystem::Cast(), C4Game::CastObjects(), C4Landscape::CheckInstability(), C4MCOverlay::CheckMask(), CreateValueProviderFromArray(), C4Object::DoMovement(), C4PXS::Execute(), C4Sky::Execute(), C4Weather::Execute(), C4ValueProviderLinear::Execute(), C4ValueProviderAbsX::Execute(), C4ValueProviderDist::Execute(), C4ValueProviderXDir::Execute(), C4ValueProviderYDir::Execute(), C4ValueProviderRDir::Execute(), C4ValueProviderAbsRDir::Execute(), C4ValueProviderCosV::Execute(), C4ValueProviderSinV::Execute(), C4ValueProviderAction::Execute(), StdMeshInstance::ExecuteAnimationNode(), C4Object::Exit(), C4Object::Init(), StdMeshInstance::InsertAnimationNode(), C4Landscape::InsertMaterial(), C4EditCursor::Move(), C4Object::MovePosition(), C4Command::MoveTo(), C4MaterialMap::mrfConvert(), mrfInsertCheck(), C4Object::NoAttachAction(), ObjectComJump(), ObjectComLetGo(), ObjectComPunch(), C4SolidMask::Put(), C4Object::SetAction(), StdMeshInstance::SetAnimationWeight(), C4Object::SetRotation(), C4Landscape::P::ShakeFreePix(), C4Object::SideBounds(), SimFlight(), C4Object::Stabilize(), TrajectoryDistance(), C4GraphicsOverlay::UpdateFacet(), and C4Object::VerticalBounds().

Here is the caller graph for this function:

◆ itofix() [2/2]

C4Fixed itofix ( int32_t  x,
int32_t  prec 
)
inline

Definition at line 262 of file C4Real.h.

262 { return C4Fixed(x, prec); }

◆ Sin()

C4Real Sin ( const C4Real fAngle)
inline

Definition at line 265 of file C4Real.h.

265 { return fAngle.sin_deg(); }
C4Fixed sin_deg() const
Definition: C4Real.h:218

References C4Fixed::sin_deg().

Referenced by AlgoSin(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MCOverlay::CheckMask(), C4ValueProviderSinR::Execute(), C4ValueProviderSinV::Execute(), InitCoreFunctionMap(), C4SolidMask::Put(), and C4Shape::Rotate().

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

Variable Documentation

◆ Fix0

◆ Fix1

const C4Real Fix1 = itofix(1)

Definition at line 313 of file C4Real.h.

◆ SineTable

long SineTable[9001]
extern