OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ValueProviderLinear Class Reference

#include <C4MeshAnimation.h>

Inheritance diagram for C4ValueProviderLinear:
[legend]
Collaboration diagram for C4ValueProviderLinear:
[legend]

Public Member Functions

 C4ValueProviderLinear ()
 
 C4ValueProviderLinear (C4Real pos, C4Real begin, C4Real end, int32_t length, C4AnimationEnding ending)
 
bool Execute () override
 
void CompileFunc (StdCompiler *pComp) override
 
virtual void DenumeratePointers ()
 
virtual void ClearPointers (class C4Object *pObj)
 

Static Public Member Functions

static const IDBaseLookup (const char *name)
 
static const IDBaseLookup (const std::type_info &type)
 

Public Attributes

C4Real Value
 

Detailed Description

Definition at line 63 of file C4MeshAnimation.h.

Constructor & Destructor Documentation

C4ValueProviderLinear::C4ValueProviderLinear ( )
inline

Definition at line 66 of file C4MeshAnimation.h.

66 : Begin(Fix0), End(Fix0) {}
const C4Real Fix0
Definition: C4Real.h:312
C4ValueProviderLinear::C4ValueProviderLinear ( C4Real  pos,
C4Real  begin,
C4Real  end,
int32_t  length,
C4AnimationEnding  ending 
)

Definition at line 151 of file C4MeshAnimation.cpp.

References StdMeshInstanceValueProvider::Value.

151  :
152  Begin(begin), End(end), Length(length), Ending(ending), LastTick(Game.FrameCounter)
153 {
154  Value = pos;
155 }
C4Game Game
Definition: C4Globals.cpp:52
int32_t FrameCounter
Definition: C4Game.h:128

Member Function Documentation

virtual void StdMeshInstance::SerializableValueProvider::ClearPointers ( class C4Object pObj)
inlinevirtualinherited

Reimplemented in C4ValueProviderAction, C4ValueProviderSinV, C4ValueProviderCosV, C4ValueProviderSinR, C4ValueProviderCosR, C4ValueProviderAbsRDir, C4ValueProviderRDir, C4ValueProviderYDir, C4ValueProviderXDir, C4ValueProviderDist, C4ValueProviderAbsY, C4ValueProviderAbsX, C4ValueProviderR, C4ValueProviderY, and C4ValueProviderX.

Definition at line 480 of file StdMesh.h.

Referenced by StdMeshInstanceAnimationNode::ClearPointers().

480 {}

Here is the caller graph for this function:

void C4ValueProviderLinear::CompileFunc ( StdCompiler pComp)
overridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 182 of file C4MeshAnimation.cpp.

References ANIM_Hold, ANIM_Loop, ANIM_Remove, CompileFunc(), C4Game::FrameCounter, Game, StdCompiler::isDeserializer(), StdCompiler::Separator(), and StdCompiler::Value().

183 {
184  const StdEnumEntry<C4AnimationEnding> Endings[] =
185  {
186  { "Loop", ANIM_Loop },
187  { "Hold", ANIM_Hold },
188  { "Remove", ANIM_Remove },
189 
190  { nullptr, static_cast<C4AnimationEnding>(0) }
191  };
192 
194  pComp->Separator();
195  pComp->Value(Begin);
196  pComp->Separator();
197  pComp->Value(End);
198  pComp->Separator();
199  pComp->Value(Length);
200  pComp->Separator();
201  pComp->Value(mkEnumAdaptT<uint8_t>(Ending, Endings));
202  pComp->Separator();
203  pComp->Value(LastTick);
204 
205  // When a scenario is saved as scenario the FrameCounter will be reset
206  // upon scenario start. The LastTick variable is fixed here.
207  // TODO: A nicer solution would be to always set LastTick to
208  // Game.FrameCounter and to make sure that the Value is always up to
209  // date (current frame) when saving by running Execute(). This could
210  // even be done in the base class.
211  if(pComp->isDeserializer())
212  if(LastTick > Game.FrameCounter)
213  LastTick = 0;
214 }
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
Definition: StdAdaptors.h:762
C4Game Game
Definition: C4Globals.cpp:52
int32_t FrameCounter
Definition: C4Game.h:128
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53
C4AnimationEnding
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
Definition: C4Real.cpp:9033

Here is the call graph for this function:

virtual void StdMeshInstance::SerializableValueProvider::DenumeratePointers ( )
inlinevirtualinherited

Reimplemented in C4ValueProviderAction, C4ValueProviderSinV, C4ValueProviderCosV, C4ValueProviderSinR, C4ValueProviderCosR, C4ValueProviderAbsRDir, C4ValueProviderRDir, C4ValueProviderYDir, C4ValueProviderXDir, C4ValueProviderDist, C4ValueProviderAbsY, C4ValueProviderAbsX, C4ValueProviderR, C4ValueProviderY, and C4ValueProviderX.

Definition at line 479 of file StdMesh.h.

Referenced by StdMeshInstanceAnimationNode::DenumeratePointers().

479 {}

Here is the caller graph for this function:

bool C4ValueProviderLinear::Execute ( )
overridevirtual

Implements StdMeshInstanceValueProvider.

Definition at line 157 of file C4MeshAnimation.cpp.

References ANIM_Hold, ANIM_Loop, ANIM_Remove, C4Game::FrameCounter, Game, itofix(), and StdMeshInstanceValueProvider::Value.

158 {
159  Value += (End - Begin) * itofix(Game.FrameCounter - LastTick) / Length;
160  LastTick = Game.FrameCounter;
161 
162  assert( (End >= Begin && Value >= Begin) || (End <= Begin && Value <= Begin));
163  while ( (End > Begin && Value > End) || (End < Begin && Value < End))
164  {
165  switch (Ending)
166  {
167  case ANIM_Loop:
168  Value -= (End - Begin);
169  return true;
170  case ANIM_Hold:
171  Value = End;
172  return true;
173  case ANIM_Remove:
174  Value = End;
175  return false;
176  }
177  }
178 
179  return true;
180 }
C4Game Game
Definition: C4Globals.cpp:52
int32_t FrameCounter
Definition: C4Game.h:128
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261

Here is the call graph for this function:

static const IDBase* StdMeshInstance::SerializableValueProvider::Lookup ( const char *  name)
inlinestaticinherited

Definition at line 460 of file StdMesh.h.

References StdMeshInstance::SerializableValueProvider::IDBase::name.

461  {
462  if(!IDs) return nullptr;
463  for(auto & ID : *IDs)
464  if(strcmp(ID->name, name) == 0)
465  return ID;
466  return nullptr;
467  }
static const IDBase* StdMeshInstance::SerializableValueProvider::Lookup ( const std::type_info &  type)
inlinestaticinherited

Definition at line 469 of file StdMesh.h.

References StdMeshInstance::SerializableValueProvider::IDBase::type.

470  {
471  if(!IDs) return nullptr;
472  for(auto & ID : *IDs)
473  if(ID->type == type)
474  return ID;
475  return nullptr;
476  }

Member Data Documentation


The documentation for this class was generated from the following files: