OpenClonk
C4ValueProviderAction Class Reference

#include <C4MeshAnimation.h>

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

Public Member Functions

 C4ValueProviderAction ()
 
 C4ValueProviderAction (C4Object *object)
 
bool Execute () override
 
void CompileFunc (StdCompiler *pComp) override
 
void DenumeratePointers () override
 
void ClearPointers (C4Object *pObj) override
 

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 319 of file C4MeshAnimation.h.

Constructor & Destructor Documentation

◆ C4ValueProviderAction() [1/2]

C4ValueProviderAction::C4ValueProviderAction ( )
inline

Definition at line 322 of file C4MeshAnimation.h.

322 : Object(nullptr) {}

◆ C4ValueProviderAction() [2/2]

C4ValueProviderAction::C4ValueProviderAction ( C4Object object)

Definition at line 687 of file C4MeshAnimation.cpp.

687  :
688  Object(object)
689 {
690 }

Member Function Documentation

◆ ClearPointers()

void C4ValueProviderAction::ClearPointers ( C4Object pObj)
inlineoverridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 328 of file C4MeshAnimation.h.

328 { if(Object == pObj) Object = nullptr; }

◆ CompileFunc()

void C4ValueProviderAction::CompileFunc ( StdCompiler pComp)
overridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 713 of file C4MeshAnimation.cpp.

714 {
716  pComp->Separator();
717  pComp->Value(Object);
718 }
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
Definition: C4Real.cpp:9033
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References CompileFunc(), StdCompiler::Separator(), and StdCompiler::Value().

Here is the call graph for this function:

◆ DenumeratePointers()

void C4ValueProviderAction::DenumeratePointers ( )
inlineoverridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 327 of file C4MeshAnimation.h.

327 { Object.DenumeratePointers(); }
void DenumeratePointers()
Definition: C4ObjectPtr.cpp:49

References C4ObjectPtr::DenumeratePointers().

Here is the call graph for this function:

◆ Execute()

bool C4ValueProviderAction::Execute ( )
overridevirtual

Implements StdMeshInstanceValueProvider.

Definition at line 692 of file C4MeshAnimation.cpp.

693 {
694  // Object might have been removed
695  if(!Object) return false;
696 
697  const C4Action& Action = Object->Action;
698  C4PropList* pActionDef = Object->GetAction();
699 
700  // TODO: We could cache these...
701  const StdMeshAnimation* animation = Action.Animation->GetAnimation();
702  const int32_t length = pActionDef->GetPropertyInt(P_Length);
703  const int32_t delay = pActionDef->GetPropertyInt(P_Delay);
704 
705  if (delay)
706  Value = itofix(Action.Phase * delay + Action.PhaseDelay) * ftofix(animation->Length) / (delay * length);
707  else
708  Value = itofix(Action.Phase) * ftofix(animation->Length) / length;
709 
710  return true;
711 }
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Fixed ftofix(float x)
Definition: C4Real.h:258
@ P_Delay
@ P_Length
int32_t PhaseDelay
Definition: C4Object.h:85
int32_t Phase
Definition: C4Object.h:85
StdMeshInstanceAnimationNode * Animation
Definition: C4Object.h:90
C4PropList * GetAction() const
C4Action Action
Definition: C4Object.h:145
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855
float Length
Definition: StdMesh.h:98
const StdMeshAnimation * GetAnimation() const
Definition: StdMesh.h:350

References C4Object::Action, C4Action::Animation, ftofix(), C4Object::GetAction(), StdMeshInstanceAnimationNode::GetAnimation(), C4PropList::GetPropertyInt(), itofix(), StdMeshAnimation::Length, P_Delay, P_Length, C4Action::Phase, C4Action::PhaseDelay, and StdMeshInstanceValueProvider::Value.

Here is the call graph for this function:

◆ Lookup() [1/2]

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

Definition at line 460 of file StdMesh.h.

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  }

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

◆ Lookup() [2/2]

static const IDBase* StdMeshInstance::SerializableValueProvider::Lookup ( const std::type_info &  type)
inlinestaticinherited

Definition at line 469 of file StdMesh.h.

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

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

Member Data Documentation

◆ Value


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