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

Definition at line 322 of file C4MeshAnimation.h.

322 : Object(nullptr) {}
C4ValueProviderAction::C4ValueProviderAction ( C4Object object)

Definition at line 687 of file C4MeshAnimation.cpp.

687  :
688  Object(object)
689 {
690 }

Member Function Documentation

void C4ValueProviderAction::ClearPointers ( C4Object pObj)
inlineoverridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 328 of file C4MeshAnimation.h.

328 { if(Object == pObj) Object = nullptr; }
void C4ValueProviderAction::CompileFunc ( StdCompiler pComp)
overridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 713 of file C4MeshAnimation.cpp.

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

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

Here is the call graph for this function:

void C4ValueProviderAction::DenumeratePointers ( )
inlineoverridevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 327 of file C4MeshAnimation.h.

References C4ObjectPtr::DenumeratePointers().

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

Here is the call graph for this function:

bool C4ValueProviderAction::Execute ( )
overridevirtual

Implements StdMeshInstanceValueProvider.

Definition at line 692 of file C4MeshAnimation.cpp.

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

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 }
C4PropList * GetAction() const
Definition: C4Object.cpp:2678
StdMeshInstanceAnimationNode * Animation
Definition: C4Object.h:90
int32_t PhaseDelay
Definition: C4Object.h:85
C4Fixed itofix(int32_t x)
Definition: C4Real.h:261
C4Fixed ftofix(float x)
Definition: C4Real.h:258
int32_t Phase
Definition: C4Object.h:85
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:882
const StdMeshAnimation * GetAnimation() const
Definition: StdMesh.h:350
C4Action Action
Definition: C4Object.h:147
float Length
Definition: StdMesh.h:98

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: