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)
 
virtual bool Execute ()
 
virtual void CompileFunc (StdCompiler *pComp)
 
virtual void DenumeratePointers ()
 
virtual void ClearPointers (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 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

virtual void C4ValueProviderAction::ClearPointers ( C4Object pObj)
inlinevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 328 of file C4MeshAnimation.h.

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

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:129
void Value(const T &rStruct)
Definition: StdCompiler.h:170
void CompileFunc(C4Real &rValue, StdCompiler *pComp)
Definition: C4Real.cpp:9033

Here is the call graph for this function:

virtual void C4ValueProviderAction::DenumeratePointers ( )
inlinevirtual

Reimplemented from StdMeshInstance::SerializableValueProvider.

Definition at line 327 of file C4MeshAnimation.h.

References C4ObjectPtr::DenumeratePointers().

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

Here is the call graph for this function:

bool C4ValueProviderAction::Execute ( )
virtual

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:2689
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:841
const StdMeshAnimation * GetAnimation() const
Definition: StdMesh.h:352
C4Action Action
Definition: C4Object.h:147

Here is the call graph for this function:

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

Definition at line 462 of file StdMesh.h.

463  {
464  if(!IDs) return nullptr;
465  for(unsigned int i = 0; i < IDs->size(); ++i)
466  if(strcmp((*IDs)[i]->name, name) == 0)
467  return (*IDs)[i];
468  return nullptr;
469  }
static const IDBase* StdMeshInstance::SerializableValueProvider::Lookup ( const std::type_info &  type)
inlinestaticinherited

Definition at line 471 of file StdMesh.h.

472  {
473  if(!IDs) return nullptr;
474  for(unsigned int i = 0; i < IDs->size(); ++i)
475  if((*IDs)[i]->type == type)
476  return (*IDs)[i];
477  return nullptr;
478  }

Member Data Documentation


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