OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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

#define C4REAL_USE_FIXNUM   1

Definition at line 36 of file C4Real.h.

#define FIXED_FPF   int32_t(1 << FIXED_SHIFT)
#define FIXED_SHIFT   16

Definition at line 54 of file C4Real.h.

Referenced by C4Fixed::operator*=().

#define inline   ALWAYS_INLINE

Definition at line 37 of file C4Real.h.

Typedef Documentation

typedef C4Fixed C4Real

Definition at line 254 of file C4Real.h.

Function Documentation

C4Real C4REAL10 ( int  x)
inline

Definition at line 269 of file C4Real.h.

References itofix().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4Real C4REAL100 ( int  x)
inline

Definition at line 267 of file C4Real.h.

References itofix().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4Real C4REAL256 ( int  x)
inline

Definition at line 268 of file C4Real.h.

References FIXED_FPF, and C4Fixed::val.

Referenced by C4PXS::Execute().

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

Here is the caller graph for this function:

void CompileFunc ( C4Real rValue,
StdCompiler pComp 
)

Definition at line 9033 of file C4Real.cpp.

References StdCompiler::Character(), FLOAT_TO_FIXED(), and StdCompiler::Value().

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().

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 Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual void Character(char &rChar)=0
void FLOAT_TO_FIXED(C4Real *pVal)
Definition: C4Real.h:318

Here is the call graph for this function:

Here is the caller graph for this function:

C4Real Cos ( const C4Real fAngle)
inline

Definition at line 266 of file C4Real.h.

References C4Fixed::cos_deg().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

float fixtof ( const C4Fixed x)
inline

Definition at line 257 of file C4Real.h.

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

257 { return x.to_float(); }

Here is the caller graph for this function:

int fixtoi ( const C4Fixed x,
int32_t  prec 
)
inline

Definition at line 260 of file C4Real.h.

260 { return x.to_int(prec); }
void FLOAT_TO_FIXED ( C4Real pVal)
inline

Definition at line 318 of file C4Real.h.

References ftofix().

Referenced by CompileFunc(), and C4PXSSystem::Load().

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4Fixed ftofix ( float  x)
inline

Definition at line 258 of file C4Real.h.

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().

258 { return C4Fixed(x); }
Definition: C4Real.h:58

Here is the caller graph for this function:

C4Fixed itofix ( int32_t  x)
inline

Definition at line 261 of file C4Real.h.

Referenced by C4Object::AdjustWalkRotation(), AlgoSin(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4REAL10(), C4REAL100(), C4PXSSystem::Cast(), C4Game::CastObjects(), C4Landscape::CheckInstability(), C4MCOverlay::CheckMask(), CreateValueProviderFromArray(), C4Object::DoMovement(), C4Object::ExecAction(), C4PXS::Execute(), C4Weather::Execute(), C4Sky::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(), FindClosestFree(), C4Object::Init(), StdMeshInstance::InsertAnimationNode(), C4Landscape::InsertMaterial(), C4EditCursor::Move(), C4Object::MovePosition(), C4Command::MoveTo(), C4MaterialMap::mrfConvert(), mrfInsertCheck(), C4Object::NoAttachAction(), ObjectActionCornerScale(), 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().

261 { return C4Fixed(x); }
Definition: C4Real.h:58

Here is the caller graph for this function:

C4Fixed itofix ( int32_t  x,
int32_t  prec 
)
inline

Definition at line 262 of file C4Real.h.

262 { return C4Fixed(x, prec); }
Definition: C4Real.h:58
C4Real Sin ( const C4Real fAngle)
inline

Definition at line 265 of file C4Real.h.

References C4Fixed::sin_deg().

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const C4Real Fix1 = itofix(1)

Definition at line 313 of file C4Real.h.

long SineTable[9001]